fix: fix error

This commit is contained in:
xion 2025-01-03 21:33:01 +08:00
parent edde6181f7
commit a97bb5f732
8 changed files with 468 additions and 104 deletions

View File

@ -35,19 +35,19 @@
"@kevisual/ai-graph": "workspace:^",
"@kevisual/ai-lang": "workspace:^",
"@kevisual/auth": "1.0.5",
"@kevisual/local-app-manager": "0.1.6-alpha.3",
"@kevisual/router": "^0.0.6-alpha-3",
"@kevisual/local-app-manager": "0.1.6-alpha.5",
"@kevisual/router": "^0.0.6-alpha-5",
"@types/semver": "^7.5.8",
"archiver": "^7.0.1",
"bullmq": "^5.34.0",
"bullmq": "^5.34.6",
"dayjs": "^1.11.13",
"dts-bundle-generator": "^9.5.1",
"formidable": "^3.5.2",
"ioredis": "^5.4.1",
"ioredis": "^5.4.2",
"json5": "^2.2.3",
"jsonwebtoken": "^9.0.2",
"lodash-es": "^4.17.21",
"minio": "^8.0.2",
"minio": "^8.0.3",
"nanoid": "^5.0.9",
"neo4j-driver": "^5.27.0",
"neode": "^0.4.9",
@ -68,26 +68,26 @@
"devDependencies": {
"@kevisual/use-config": "^1.0.7",
"@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-commonjs": "^28.0.2",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-replace": "^6.0.1",
"@rollup/plugin-typescript": "^12.1.1",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-replace": "^6.0.2",
"@rollup/plugin-typescript": "^12.1.2",
"@types/archiver": "^6.0.3",
"@types/crypto-js": "^4.2.2",
"@types/formidable": "^3.4.5",
"@types/jsonwebtoken": "^9.0.7",
"@types/lodash-es": "^4.17.12",
"@types/node": "^22.10.2",
"@types/react": "^19.0.1",
"@types/node": "^22.10.5",
"@types/react": "^19.0.2",
"@types/uuid": "^10.0.0",
"concurrently": "^9.1.0",
"concurrently": "^9.1.2",
"cross-env": "^7.0.3",
"nodemon": "^3.1.7",
"nodemon": "^3.1.9",
"pm2": "^5.4.3",
"pm2-dev": "^5.4.1",
"rimraf": "^6.0.1",
"rollup": "^4.28.1",
"rollup": "^4.29.1",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-dts": "^6.1.1",
"tape": "^5.9.0",

460
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -26,6 +26,8 @@ app
path: item.path,
key: item.key,
description: item.description,
validator: item.validator,
// schema: item.schema,
};
});
})

View File

@ -9,7 +9,7 @@ import { app, minioClient } from '@/app.ts';
import { bucketName } from '@/modules/minio.ts';
import { getContentType } from '@/utils/get-content-type.ts';
import { hash } from 'crypto';
import { MicroAppModel } from '@/routes/micro-app/models.ts';
import { MicroAppUploadModel } from '@/routes/micro-app/models.ts';
const cacheFilePath = useFileStore('cache-file', { needExists: true });
router.post('/api/micro-app/upload', async (req, res) => {
@ -137,7 +137,7 @@ router.get('/api/micro-app/download/:id', async (req, res) => {
tokenUser = auth.tokenUser;
if (!tokenUser) return;
}
const file = await MicroAppModel.findByPk(id);
const file = await MicroAppUploadModel.findByPk(id);
if (!DEV_SERVER) {
file.uid !== tokenUser.id && res.end(error('No permission', 403));
return;

View File

@ -1 +1,2 @@
import './list.ts';
import './upload-list.ts'

View File

@ -1,5 +1,5 @@
import { app } from '@/app.ts';
import { MicroAppModel } from './models.ts';
import { MicroAppUploadModel } from './models.ts';
import { appPathCheck, installApp } from './module/install-app.ts';
import { manager } from './manager-app.ts';
@ -21,7 +21,7 @@ app
if (collection?.tags) {
tags.push(...collection.tags);
}
const microApp = await MicroAppModel.create({
const microApp = await MicroAppUploadModel.create({
title: name,
description: collection?.readme || '',
type: 'micro-app',
@ -63,7 +63,7 @@ app
if (!id) {
ctx.throw(400, 'Invalid id');
}
const microApp = await MicroAppModel.findByPk(id);
const microApp = await MicroAppUploadModel.findByPk(id);
const { file } = microApp.data || {};
const path = file?.path;
if (!path) {

View File

@ -1,7 +1,7 @@
import { sequelize } from '@/modules/sequelize.ts';
import { DataTypes, Model } from 'sequelize';
export type MicroApp = Partial<InstanceType<typeof MicroAppModel>>;
export type MicroApp = Partial<InstanceType<typeof MicroAppUploadModel>>;
type MicroAppData = {
file?: {
@ -14,7 +14,7 @@ type MicroAppData = {
data?: any;
collection?: any; // 上传的信息汇总
};
export class MicroAppModel extends Model {
export class MicroAppUploadModel extends Model {
declare id: string;
declare title: string;
declare description: string;
@ -29,7 +29,7 @@ export class MicroAppModel extends Model {
declare uname: string;
}
MicroAppModel.init(
MicroAppUploadModel.init(
{
id: {
type: DataTypes.UUID,
@ -76,11 +76,11 @@ MicroAppModel.init(
},
{
sequelize,
tableName: 'micro_apps',
tableName: 'micro_apps_upload',
// paranoid: true,
},
);
MicroAppModel.sync({ alter: true, logging: false }).catch((e) => {
console.error('MicroAppModel sync', e);
MicroAppUploadModel.sync({ alter: true, logging: false }).catch((e) => {
console.error('MicroAppUploadModel sync', e);
});

View File

@ -0,0 +1,57 @@
import { app } from '@/app.ts';
import { MicroAppUploadModel } from './models.ts';
// 获取MicroAppUpload的uploadList的接口
app
.route({
path: 'micro-app-upload',
key: 'list',
middleware: ['auth'],
description: 'Get micro app upload list',
})
.define(async (ctx) => {
const { uid } = ctx.state.tokenUser;
const uploadList = await MicroAppUploadModel.findAll({
where: { uid },
});
ctx.body = uploadList;
})
.addTo(app);
// 获取单个MicroAppUpload的接口
app
.route({
path: 'micro-app-upload',
key: 'get',
middleware: ['auth'],
description: 'Get a single micro app upload',
})
.define(async (ctx) => {
const { id } = ctx.query;
const upload = await MicroAppUploadModel.findOne({
where: { id },
});
if (upload) {
ctx.body = upload;
} else {
ctx.throw(404, 'Not found');
}
})
.addTo(app);
// 删除MicroAppUpload的接口
app
.route({
path: 'micro-app-upload',
key: 'delete',
middleware: ['auth'],
description: 'Delete a micro app upload',
})
.define(async (ctx) => {
const { id } = ctx.query;
const deleted = await MicroAppUploadModel.destroy({
where: { id },
});
ctx.body = { deleted };
})
.addTo(app);