Compare commits
13 Commits
7f91070906
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c2038b8421 | |||
| daf0b6b31d | |||
| 450fbc7167 | |||
| 544b1defff | |||
| b3993f654c | |||
| c7ddaf88f6 | |||
| b0bd771e3d | |||
| 958ac3f009 | |||
| 3cf26e3eed | |||
| 633eee4bee | |||
| d29f69452c | |||
| 391c43c6b7 | |||
| 9ac04821f5 |
9
.env.example
Normal file
9
.env.example
Normal file
@@ -0,0 +1,9 @@
|
||||
POSTGRES_HOST=localhost
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=
|
||||
POSTGRES_DB=postgres
|
||||
|
||||
REDIS_HOST=localhost
|
||||
REDIS_PORT=6379
|
||||
REDIS_PASSWORD=
|
||||
12
.gitmodules
vendored
12
.gitmodules
vendored
@@ -1,12 +0,0 @@
|
||||
[submodule "submodules/code-center-module"]
|
||||
path = submodules/code-center-module
|
||||
url = git@git.xiongxiao.me:kevisual/code-center-module.git
|
||||
[submodule "submodules/permission"]
|
||||
path = submodules/permission
|
||||
url = git@git.xiongxiao.me:kevisual/kevsiual-permission.git
|
||||
[submodule "submodules/oss"]
|
||||
path = submodules/oss
|
||||
url = git@git.xiongxiao.me:kevisual/kevisual-oss.git
|
||||
[submodule "submodules/pay-center-code"]
|
||||
path = submodules/pay-center-code
|
||||
url = git@git.xiongxiao.me:kevisual/pay-center-code.git
|
||||
@@ -1,5 +1,5 @@
|
||||
// @ts-check
|
||||
import { resolvePath } from '@kevisual/use-config/env';
|
||||
import { resolvePath } from '@kevisual/use-config';
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
const entry = 'src/index.ts';
|
||||
|
||||
103
package.json
103
package.json
@@ -10,32 +10,29 @@
|
||||
"type": "pm2-system-app",
|
||||
"key": "code-center",
|
||||
"entry": "./dist/app.js",
|
||||
"engine": "bun",
|
||||
"runtime": [
|
||||
"client"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tsx test/**/*.ts",
|
||||
"dev": "bun run --watch --hot --inspect src/index.ts",
|
||||
"dev": "bun run --watch --hot src/index.ts",
|
||||
"dev:inspect": "bun run --watch --hot --inspect src/index.ts",
|
||||
"cmd": "bun run src/run.ts ",
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "NODE_ENV=production bun bun.config.mjs",
|
||||
"deploy": "rsync -avz --delete ./dist/ light:/root/kevisual/assistant-app/apps/code-center/dist",
|
||||
"deploy:sky": "rsync -avz --delete ./dist/ sky:~/kevisual/dist",
|
||||
"deploy:envision": "rsync -avz --delete ./dist/ envision:~/kevisual/assistant-app/apps/code-center/dist",
|
||||
"clean": "rm -rf dist",
|
||||
"reload": "ssh light pm2 restart code-center",
|
||||
"reload:sky": "ssh sky pm2 restart code-center",
|
||||
"reload:envision": "ssh envision pm2 restart code-center",
|
||||
"pub:me": "npm run build && npm run deploy && npm run reload",
|
||||
"pub:sky": "npm run build && npm run deploy:sky && npm run reload:sky",
|
||||
"pub:envision": "npm run build && npm run deploy:envision && npm run reload:envision",
|
||||
"start": "pm2 start dist/app.js --name code-center",
|
||||
"client:start": "pm2 start apps/code-center/dist/app.js --name code-center",
|
||||
"pub": "envision pack -p -u -c",
|
||||
"dev:lib": "turbo run dev:lib",
|
||||
"build:lib": "turbo run build",
|
||||
"dev:oss": "turbo run dev:lib --filter=@kevisual/oss"
|
||||
"ssl": "ssh -L 5432:localhost:5432 light",
|
||||
"pub": "envision pack -p -u -c"
|
||||
},
|
||||
"keywords": [],
|
||||
"types": "types/index.d.ts",
|
||||
@@ -44,78 +41,72 @@
|
||||
],
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"commander": "^14.0.0",
|
||||
"ioredis": "^5.6.1",
|
||||
"minio": "^8.0.5",
|
||||
"pg": "^8.16.0",
|
||||
"pm2": "^6.0.8",
|
||||
"sequelize": "^6.37.7",
|
||||
"sqlite3": "^5.1.7"
|
||||
"commander": "^14.0.1",
|
||||
"cookie": "^1.0.2",
|
||||
"ioredis": "^5.8.1",
|
||||
"minio": "^8.0.6",
|
||||
"pg": "^8.16.3",
|
||||
"pm2": "^6.0.13",
|
||||
"sequelize": "^6.37.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kevisual/code-center-module": "workspace:*",
|
||||
"@kevisual/code-center-module": "0.0.24",
|
||||
"@kevisual/context": "^0.0.4",
|
||||
"@kevisual/file-listener": "^0.0.2",
|
||||
"@kevisual/local-app-manager": "0.1.22",
|
||||
"@kevisual/logger": "^0.0.4",
|
||||
"@kevisual/oss": "workspace:*",
|
||||
"@kevisual/oss": "0.0.12",
|
||||
"@kevisual/permission": "^0.0.3",
|
||||
"@kevisual/router": "0.0.22",
|
||||
"@kevisual/router": "0.0.28",
|
||||
"@kevisual/types": "^0.0.10",
|
||||
"@kevisual/use-config": "^1.0.18",
|
||||
"@rollup/plugin-alias": "^5.1.1",
|
||||
"@rollup/plugin-commonjs": "^28.0.3",
|
||||
"@rollup/plugin-json": "^6.1.0",
|
||||
"@rollup/plugin-node-resolve": "^16.0.1",
|
||||
"@rollup/plugin-replace": "^6.0.2",
|
||||
"@rollup/plugin-typescript": "^12.1.2",
|
||||
"@kevisual/use-config": "^1.0.19",
|
||||
"@types/archiver": "^6.0.3",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/formidable": "^3.4.5",
|
||||
"@types/jsonwebtoken": "^9.0.9",
|
||||
"@types/formidable": "^3.4.6",
|
||||
"@types/jsonwebtoken": "^9.0.10",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^22.15.30",
|
||||
"@types/react": "^19.1.6",
|
||||
"@types/semver": "^7.7.0",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"@types/node": "^24.7.2",
|
||||
"@types/react": "^19.2.2",
|
||||
"@types/semver": "^7.7.1",
|
||||
"@types/uuid": "^11.0.0",
|
||||
"archiver": "^7.0.1",
|
||||
"concurrently": "^9.1.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"cross-env": "^10.1.0",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dayjs": "^1.11.13",
|
||||
"dotenv": "^16.5.0",
|
||||
"dayjs": "^1.11.18",
|
||||
"dotenv": "^17.2.3",
|
||||
"formidable": "3.5.4",
|
||||
"ioredis": "^5.6.1",
|
||||
"ioredis": "^5.8.1",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"lodash-es": "^4.17.21",
|
||||
"minio": "^8.0.5",
|
||||
"nanoid": "^5.1.5",
|
||||
"minio": "^8.0.6",
|
||||
"nanoid": "^5.1.6",
|
||||
"node-fetch": "^3.3.2",
|
||||
"nodemon": "^3.1.10",
|
||||
"p-queue": "^8.1.0",
|
||||
"pg": "^8.16.0",
|
||||
"pm2": "^6.0.8",
|
||||
"p-queue": "^9.0.0",
|
||||
"pg": "^8.16.3",
|
||||
"pm2": "^6.0.13",
|
||||
"rimraf": "^6.0.1",
|
||||
"rollup": "^4.42.0",
|
||||
"rollup-plugin-copy": "^3.5.0",
|
||||
"rollup-plugin-dts": "^6.2.1",
|
||||
"rollup-plugin-esbuild": "^6.2.1",
|
||||
"semver": "^7.7.2",
|
||||
"semver": "^7.7.3",
|
||||
"sequelize": "^6.37.7",
|
||||
"socket.io": "^4.8.1",
|
||||
"strip-ansi": "^7.1.0",
|
||||
"strip-ansi": "^7.1.2",
|
||||
"tape": "^5.9.0",
|
||||
"tar": "^7.4.3",
|
||||
"tsx": "^4.19.4",
|
||||
"turbo": "^2.5.4",
|
||||
"typescript": "^5.8.3",
|
||||
"uuid": "^11.1.0",
|
||||
"zod": "^3.25.56"
|
||||
"tar": "^7.5.1",
|
||||
"tsx": "^4.20.6",
|
||||
"turbo": "^2.5.8",
|
||||
"typescript": "^5.9.3",
|
||||
"uuid": "^13.0.0",
|
||||
"zod": "^4.1.12"
|
||||
},
|
||||
"resolutions": {
|
||||
"inflight": "latest",
|
||||
"rimraf": "latest",
|
||||
"picomatch": "^4.0.2"
|
||||
},
|
||||
"pnpm": {},
|
||||
"packageManager": "pnpm@10.11.1"
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"esbuild",
|
||||
"sqlite3"
|
||||
]
|
||||
},
|
||||
"packageManager": "pnpm@10.18.3"
|
||||
}
|
||||
3937
pnpm-lock.yaml
generated
3937
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,7 @@ app
|
||||
|
||||
const { rows: appDemo, count } = await AppDemoModel.findAndCountAll({
|
||||
where: {
|
||||
uid: tokenUser.uid,
|
||||
uid: tokenUser.id,
|
||||
...searchWhere,
|
||||
},
|
||||
offset: (page - 1) * pageSize,
|
||||
@@ -90,7 +90,7 @@ app
|
||||
ctx.throw(400, 'id is required');
|
||||
}
|
||||
const appDemo = await AppDemoModel.findByPk(id);
|
||||
if (appDemo.uid !== tokenUser.uid) {
|
||||
if (appDemo.uid !== tokenUser.id) {
|
||||
ctx.throw(403, 'No permission');
|
||||
}
|
||||
await appDemo.destroy({ force });
|
||||
@@ -111,7 +111,7 @@ app
|
||||
ctx.throw(400, 'id is required');
|
||||
}
|
||||
const appDemo = await AppDemoModel.findByPk(id);
|
||||
if (appDemo.uid !== tokenUser.uid) {
|
||||
if (appDemo.uid !== tokenUser.id) {
|
||||
ctx.throw(403, 'No permission');
|
||||
}
|
||||
ctx.body = appDemo;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { App } from '@kevisual/router';
|
||||
import * as redisLib from './modules/redis.ts';
|
||||
import * as minioLib from './modules/minio.ts';
|
||||
import * as sequelizeLib from './modules/sequelize.ts';
|
||||
import { useContextKey, useContext } from '@kevisual/use-config/context';
|
||||
import { useContextKey } from '@kevisual/context';
|
||||
import { SimpleRouter } from '@kevisual/router/simple';
|
||||
import { OssBase } from '@kevisual/oss/services';
|
||||
export const router = useContextKey('router', () => new SimpleRouter());
|
||||
|
||||
18
src/aura/asr/index.ts
Normal file
18
src/aura/asr/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { app } from '@/app.ts'
|
||||
import { asr } from './modules/index.ts'
|
||||
app.route({
|
||||
path: 'asr',
|
||||
key: 'text'
|
||||
}).define(async (ctx) => {
|
||||
const base64Audio = ctx.query.base64Audio as string
|
||||
if (!base64Audio) {
|
||||
ctx.throw('Missing base64Audio parameter')
|
||||
}
|
||||
const result = await asr.getText({
|
||||
audio: {
|
||||
data: base64Audio
|
||||
}
|
||||
})
|
||||
ctx.body = result
|
||||
})
|
||||
.addTo(app)
|
||||
7
src/aura/asr/modules/index.ts
Normal file
7
src/aura/asr/modules/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Asr } from '../../libs/auc.ts'
|
||||
import { auraConfig } from '../../config.ts'
|
||||
|
||||
export const asr = new Asr({
|
||||
appid: auraConfig.VOLCENGINE_AUC_APPID,
|
||||
token: auraConfig.VOLCENGINE_AUC_TOKEN,
|
||||
})
|
||||
6
src/aura/config.ts
Normal file
6
src/aura/config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { config } from '@/modules/config.ts'
|
||||
export type AIConfig = {
|
||||
VOLCENGINE_AUC_APPID: string
|
||||
VOLCENGINE_AUC_TOKEN: string
|
||||
}
|
||||
export const auraConfig: AIConfig = config as unknown as AIConfig;
|
||||
1
src/aura/index.ts
Normal file
1
src/aura/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
import './asr/index.ts'
|
||||
136
src/aura/libs/auc.ts
Normal file
136
src/aura/libs/auc.ts
Normal file
@@ -0,0 +1,136 @@
|
||||
// https://git.xiongxiao.me/kevisual/video-tools/raw/branch/main/src/asr/provider/volcengine/auc.ts
|
||||
import { nanoid } from "nanoid"
|
||||
|
||||
export const FlashURL = "https://openspeech.bytedance.com/api/v3/auc/bigmodel/recognize/flash"
|
||||
export const AsrBaseURL = 'https://openspeech.bytedance.com/api/v3/auc/bigmodel/submit'
|
||||
export const AsrBase = 'volc.bigasr.auc'
|
||||
export const AsrTurbo = 'volc.bigasr.auc_turbo'
|
||||
|
||||
const uuid = () => nanoid()
|
||||
|
||||
type AsrOptions = {
|
||||
url?: string
|
||||
appid?: string
|
||||
token?: string
|
||||
type?: AsrType
|
||||
}
|
||||
|
||||
type AsrType = 'flash' | 'standard' | 'turbo'
|
||||
export class Asr {
|
||||
url: string = FlashURL
|
||||
appid: string = ""
|
||||
token: string = ""
|
||||
type: AsrType = 'flash'
|
||||
constructor(options: AsrOptions = {}) {
|
||||
this.appid = options.appid || ""
|
||||
this.token = options.token || ""
|
||||
this.type = options.type || 'flash'
|
||||
if (this.type !== 'flash') {
|
||||
this.url = AsrBaseURL
|
||||
}
|
||||
if (!this.appid || !this.token) {
|
||||
throw new Error("VOLCENGINE_Asr_APPID or VOLCENGINE_Asr_TOKEN is not set")
|
||||
}
|
||||
}
|
||||
|
||||
header() {
|
||||
const model = this.type === 'flash' ? AsrTurbo : AsrBase
|
||||
return {
|
||||
"X-Api-App-Key": this.appid,
|
||||
"X-Api-Access-Key": this.token,
|
||||
"X-Api-Resource-Id": model,
|
||||
"X-Api-Request-Id": uuid(),
|
||||
"X-Api-Sequence": "-1",
|
||||
}
|
||||
}
|
||||
submit(body: AsrRequest) {
|
||||
if (!body.audio || (!body.audio.url && !body.audio.data)) {
|
||||
throw new Error("audio.url or audio.data is required")
|
||||
}
|
||||
const data: AsrRequest = {
|
||||
...body,
|
||||
}
|
||||
return fetch(this.url, { method: "POST", headers: this.header(), body: JSON.stringify(data) })
|
||||
}
|
||||
async getText(body: AsrRequest) {
|
||||
const res = await this.submit(body)
|
||||
return res.json()
|
||||
}
|
||||
}
|
||||
|
||||
export type AsrResponse = {
|
||||
audio_info: {
|
||||
/**
|
||||
* 音频时长,单位为 ms
|
||||
*/
|
||||
duration: number;
|
||||
};
|
||||
result: {
|
||||
additions: {
|
||||
duration: string;
|
||||
};
|
||||
text: string;
|
||||
utterances: Array<{
|
||||
end_time: number;
|
||||
start_time: number;
|
||||
text: string;
|
||||
words: Array<{
|
||||
confidence: number;
|
||||
end_time: number;
|
||||
start_time: number;
|
||||
text: string;
|
||||
}>;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
export interface AsrRequest {
|
||||
user?: {
|
||||
uid: string;
|
||||
};
|
||||
audio: {
|
||||
url?: string;
|
||||
data?: string;
|
||||
format?: 'wav' | 'pcm' | 'mp3' | 'ogg';
|
||||
codec?: 'raw' | 'opus'; // raw / opus,默认为 raw(pcm) 。
|
||||
rate?: 8000 | 16000; // 采样率,支持 8000 或 16000,默认为 16000 。
|
||||
channel?: 1 | 2; // 声道数,支持 1 或 2,默认为 1。
|
||||
};
|
||||
|
||||
|
||||
request?: {
|
||||
model_name?: string; // 识别模型名称,如 "bigmodel"
|
||||
enable_words?: boolean; // 是否开启词级别时间戳,默认为 false。
|
||||
enable_sentence_info?: boolean; // 是否开启句子级别时间戳,默认为 false。
|
||||
enable_utterance_info?: boolean; // 是否开启语句级别时间戳,默认为 true。
|
||||
enable_punctuation_prediction?: boolean; // 是否开启标点符号预测,默认为 true。
|
||||
enable_inverse_text_normalization?: boolean; // 是否开启文本规范化,默认为 true。
|
||||
enable_separate_recognition_per_channel?: boolean; // 是否开启声道分离识别,默认为 false。
|
||||
audio_channel_count?: 1 | 2; // 音频声道数,仅在 enable_separate_recognition_per_channel 开启时有效,支持 1 或 2,默认为 1。
|
||||
max_sentence_silence?: number; // 句子最大静音时间,仅在 enable_sentence_info 开启时有效,单位为 ms,默认为 800。
|
||||
custom_words?: string[];
|
||||
enable_channel_split?: boolean; // 是否开启声道分离
|
||||
enable_ddc?: boolean; // 是否开启 DDC(双通道降噪)
|
||||
enable_speaker_info?: boolean; // 是否开启说话人分离
|
||||
enable_punc?: boolean; // 是否开启标点符号预测(简写)
|
||||
enable_itn?: boolean; // 是否开启文本规范化(简写)
|
||||
vad_segment?: boolean; // 是否开启 VAD 断句
|
||||
show_utterances?: boolean; // 是否返回语句级别结果
|
||||
corpus?: {
|
||||
boosting_table_name?: string;
|
||||
correct_table_name?: string;
|
||||
context?: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// const main = async () => {
|
||||
// const base64Audio = wavToBase64(audioPath);
|
||||
// const auc = new Asr({
|
||||
// appid: config.VOLCENGINE_AUC_APPID,
|
||||
// token: config.VOLCENGINE_AUC_TOKEN,
|
||||
// });
|
||||
// const result = await auc.getText({ audio: { data: base64Audio } });
|
||||
// console.log(util.inspect(result, { showHidden: false, depth: null, colors: true }))
|
||||
// }
|
||||
|
||||
// main();
|
||||
@@ -1,5 +1,5 @@
|
||||
// import { DataTypes, Model, Sequelize } from 'sequelize';
|
||||
// import { useContextKey } from '@kevisual/use-config/context';
|
||||
// import { useContextKey } from '@kevisual/context';
|
||||
// const sequelize = useContextKey<Sequelize>('sequelize');
|
||||
// export class Org extends Model {
|
||||
// declare id: string;
|
||||
@@ -42,7 +42,5 @@
|
||||
// });
|
||||
|
||||
// useContextKey('OrgModel', () => Org);
|
||||
import { Org, OrgInit } from '@kevisual/code-center-module/models';
|
||||
import { Org } from '@kevisual/code-center-module/models';
|
||||
export { Org };
|
||||
|
||||
OrgInit();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { User, UserInit, UserServices } from '@kevisual/code-center-module/models';
|
||||
export { User, UserInit, UserServices };
|
||||
import { UserSecretInit, UserSecret } from '@kevisual/code-center-module/models';
|
||||
import { OrgInit } from '@kevisual/code-center-module/models';
|
||||
export { User, UserInit, UserServices, UserSecret };
|
||||
const init = async () => {
|
||||
await OrgInit(null, null, {
|
||||
alter: true,
|
||||
@@ -14,5 +15,11 @@ const init = async () => {
|
||||
}).catch((e) => {
|
||||
console.error('User sync', e);
|
||||
});
|
||||
await UserSecretInit(null, null, {
|
||||
alter: true,
|
||||
logging: false,
|
||||
}).catch((e) => {
|
||||
console.error('UserSecret sync', e);
|
||||
});
|
||||
};
|
||||
init();
|
||||
|
||||
20
src/modules/logger.ts
Normal file
20
src/modules/logger.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useConfig } from '@kevisual/use-config/env';
|
||||
import { Logger } from '@kevisual/logger';
|
||||
const config = useConfig();
|
||||
|
||||
export const logger = new Logger({
|
||||
level: config.LOG_LEVEL || 'info',
|
||||
showTime: true,
|
||||
});
|
||||
|
||||
export const logError = (message: string, data?: any) => logger.error({ data }, message);
|
||||
export const logWarning = (message: string, data?: any) => logger.warn({ data }, message);
|
||||
export const logInfo = (message: string, data?: any) => logger.info({ data }, message);
|
||||
export const logDebug = (message: string, data?: any) => logger.debug({ data }, message);
|
||||
|
||||
export const log = {
|
||||
error: logError,
|
||||
warn: logWarning,
|
||||
info: logInfo,
|
||||
debug: logDebug,
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Client, ClientOptions } from 'minio';
|
||||
import { config } from './config.ts';
|
||||
import { OssBase } from '@kevisual/oss/services';
|
||||
const minioConfig = {
|
||||
endPoint: config.MINIO_ENDPOINT || 'localhost',
|
||||
port: parseInt(config.MINIO_PORT || '9000'),
|
||||
@@ -24,3 +25,9 @@ if (!minioClient) {
|
||||
// const res = await minioClient.putObject(bucketName, 'root/test/0.0.1/a.txt', 'test');
|
||||
// console.log('minio putObject', res);
|
||||
})();
|
||||
|
||||
export const oss = new OssBase({
|
||||
client: minioClient,
|
||||
bucketName: bucketName,
|
||||
prefix: '',
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Sequelize } from 'sequelize';
|
||||
import { config } from './config.ts';
|
||||
import { log } from '../logger/index.ts';
|
||||
import { log } from './logger.ts';
|
||||
export type PostgresConfig = {
|
||||
postgres: {
|
||||
username: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { program, Command } from 'commander';
|
||||
// import { useContextKey } from '@kevisual/use-config/context';
|
||||
// import { useContextKey } from '@kevisual/context';
|
||||
// import * as redisLib from './modules/redis.ts';
|
||||
// import * as sequelizeLib from './modules/sequelize.ts';
|
||||
// import * as minioLib from './modules/minio.ts';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import './routes/index.ts';
|
||||
import './aura/index.ts';
|
||||
import { app } from './app.ts';
|
||||
import type { App } from '@kevisual/router';
|
||||
import { User } from './models/user.ts';
|
||||
// import { addAuth } from '@kevisual/code-center-module/models';
|
||||
// addAuth(app);
|
||||
import { createCookie, getSomeInfoFromReq } from './routes/user/me.ts';
|
||||
|
||||
/**
|
||||
|
||||
@@ -97,7 +97,6 @@ export const authMinio = async (req: IncomingMessage, res: ServerResponse, objec
|
||||
etag,
|
||||
'last-modified': lastModified,
|
||||
'Content-Disposition': contentDisposition,
|
||||
'file-name': filename,
|
||||
...filteredMetaData,
|
||||
});
|
||||
const objectStream = await minioClient.getObject(bucketName, objectName);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { useFileStore } from '@kevisual/use-config/file-store';
|
||||
import { checkAuth, error, router, writeEvents, getKey, getTaskId } from '../router.ts';
|
||||
import { IncomingForm } from 'formidable';
|
||||
import { app, minioClient } from '@/app.ts';
|
||||
import { app, oss } from '@/app.ts';
|
||||
|
||||
import { bucketName } from '@/modules/minio.ts';
|
||||
import { getContentType } from '@/utils/get-content-type.ts';
|
||||
import { User } from '@/models/user.ts';
|
||||
import fs from 'fs';
|
||||
@@ -124,8 +123,9 @@ router.post('/api/s1/resources/upload/chunk', async (req, res) => {
|
||||
if (share) {
|
||||
metadata.share = 'public';
|
||||
}
|
||||
const bucketName = oss.bucketName;
|
||||
// All chunks uploaded, now upload to MinIO
|
||||
await minioClient.fPutObject(bucketName, minioPath, finalFilePath, {
|
||||
await oss.client.fPutObject(bucketName, minioPath, finalFilePath, {
|
||||
'Content-Type': getContentType(relativePath),
|
||||
'app-source': 'user-app',
|
||||
'Cache-Control': relativePath.endsWith('.html') ? 'no-cache' : 'max-age=31536000, immutable',
|
||||
|
||||
@@ -5,7 +5,8 @@ router.all('/api/s1/share/*splat', async (req, res) => {
|
||||
try {
|
||||
const url = req.url;
|
||||
const _url = new URL(url || '', 'http://localhost');
|
||||
const objectName = _url.pathname.replace('/api/s1/share/', '');
|
||||
let objectName = _url.pathname.replace('/api/s1/share/', '');
|
||||
objectName = decodeURIComponent(objectName);
|
||||
await authMinio(req, res, objectName);
|
||||
} catch (e) {
|
||||
console.log('get share resource error url', req.url);
|
||||
|
||||
@@ -35,6 +35,7 @@ router.post('/api/s1/resources/upload/check', async (req, res) => {
|
||||
return;
|
||||
}
|
||||
console.log('data', req.url);
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
const data = await router.getBody(req);
|
||||
type Data = {
|
||||
appKey: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { router } from '@/app.ts';
|
||||
import http from 'http';
|
||||
import { useContextKey } from '@kevisual/use-config/context';
|
||||
import { useContextKey } from '@kevisual/context';
|
||||
import { checkAuth, error } from './middleware/auth.ts';
|
||||
import formidable from 'formidable';
|
||||
export { router, checkAuth, error };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { App, CustomError } from '@kevisual/router';
|
||||
import { AppModel, AppListModel } from './module/index.ts';
|
||||
import { app, redis } from '@/app.ts';
|
||||
import _ from 'lodash';
|
||||
import { uniqBy } from 'lodash-es';
|
||||
import { getUidByUsername, prefixFix } from './util.ts';
|
||||
import { deleteFiles, getMinioListAndSetToAppList } from '../file/index.ts';
|
||||
import { setExpire } from './revoke.ts';
|
||||
@@ -207,7 +207,7 @@ app
|
||||
});
|
||||
}
|
||||
const dataFiles = app.data.files || [];
|
||||
const newFiles = _.uniqBy([...dataFiles, ...files], 'name');
|
||||
const newFiles = uniqBy([...dataFiles, ...files], 'name');
|
||||
const res = await app.update({ data: { ...app.data, files: newFiles } });
|
||||
if (version === am.version && !appIsNew) {
|
||||
await am.update({ data: { ...am.data, files: newFiles } });
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
import './list.ts';
|
||||
|
||||
import './post.ts'
|
||||
111
src/routes/app-manager/public/post.ts
Normal file
111
src/routes/app-manager/public/post.ts
Normal file
@@ -0,0 +1,111 @@
|
||||
import { app } from '@/app.ts';
|
||||
import { AppModel } from '../module/index.ts';
|
||||
import { AppListModel } from '../module/index.ts';
|
||||
import { oss } from '@/app.ts';
|
||||
import { User } from '@/models/user.ts';
|
||||
import { permission } from 'process';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const letter = 'abcdefghijklmnopqrstuvwxyz';
|
||||
const number = '0123456789';
|
||||
const randomId = customAlphabet(letter + number, 16);
|
||||
const getShareUser = async () => {
|
||||
const shareUser = await User.findOne({
|
||||
where: {
|
||||
username: 'share',
|
||||
},
|
||||
});
|
||||
return shareUser?.id || '';
|
||||
};
|
||||
app
|
||||
.route({
|
||||
path: 'app',
|
||||
key: 'public-upload-html',
|
||||
middleware: ['auth-can'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser || {};
|
||||
|
||||
let uid = tokenUser?.id;
|
||||
let username = tokenUser?.username;
|
||||
if (!uid) {
|
||||
uid = await getShareUser();
|
||||
username = 'share';
|
||||
}
|
||||
if (!uid) {
|
||||
ctx.throw(403, 'No permission to upload');
|
||||
}
|
||||
let { title, description, version = '1.0.0', key, content } = ctx.query.data || {};
|
||||
if (!content) {
|
||||
ctx.throw(400, 'Content is required');
|
||||
}
|
||||
if (!key) {
|
||||
key = randomId(16);
|
||||
}
|
||||
if (!title) {
|
||||
const day = dayjs().format('YYYY-MM-DD HH:mm');
|
||||
const time = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
||||
title = `分享应用 - ${day}`;
|
||||
|
||||
description = `创建于 ${time},分享应用,key: ${key},用户: ${username}`;
|
||||
if (!tokenUser) {
|
||||
description = description + `,会自动删除,过期时间为30天`;
|
||||
}
|
||||
}
|
||||
const urlPath = `${username}/${key}/${version}/index.html`;
|
||||
await oss.putObject(urlPath, content, {
|
||||
'Content-Type': 'text/html; charset=utf-8',
|
||||
'app-source': 'user-app',
|
||||
'Cache-Control': 'no-cache',
|
||||
});
|
||||
const files = [
|
||||
{
|
||||
name: 'index.html',
|
||||
path: urlPath,
|
||||
},
|
||||
];
|
||||
const appModel = await AppModel.create({
|
||||
title,
|
||||
description,
|
||||
version,
|
||||
key,
|
||||
user: username,
|
||||
uid,
|
||||
proxy: true,
|
||||
data: {
|
||||
delete: 'share',
|
||||
permission: {
|
||||
share: 'public',
|
||||
},
|
||||
files: files,
|
||||
},
|
||||
});
|
||||
const appVersionModel = await AppListModel.create({
|
||||
data: {
|
||||
files: files,
|
||||
},
|
||||
version: appModel.version,
|
||||
key: appModel.key,
|
||||
uid: appModel.uid,
|
||||
});
|
||||
|
||||
ctx.body = {
|
||||
url: `/${username}/${key}/`,
|
||||
username: username,
|
||||
appModel: {
|
||||
id: appModel.id,
|
||||
title: appModel.title,
|
||||
description: appModel.description,
|
||||
version: appModel.version,
|
||||
data: appModel.data,
|
||||
},
|
||||
appVersionModel: {
|
||||
id: appVersionModel.id,
|
||||
version: appVersionModel.version,
|
||||
key: appVersionModel.key,
|
||||
data: appVersionModel.data,
|
||||
},
|
||||
};
|
||||
})
|
||||
.addTo(app);
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useContextKey } from '@kevisual/use-config/context';
|
||||
import { useContextKey } from '@kevisual/context';
|
||||
import { sequelize } from '../../../modules/sequelize.ts';
|
||||
import { DataTypes, Model } from 'sequelize';
|
||||
import { Permission } from '@kevisual/permission';
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import { FileSyncModel, FileSyncModelType } from '@kevisual/file-listener/src/file-sync/model.ts';
|
||||
|
||||
import { FileSyncModel } from '@kevisual/file-listener/src/file-sync/model.ts';
|
||||
import type { FileSyncModelType } from '@kevisual/file-listener/src/file-sync/model.ts';
|
||||
export { FileSyncModel, FileSyncModelType };
|
||||
|
||||
327
src/routes/mark/mark-model.ts
Normal file
327
src/routes/mark/mark-model.ts
Normal file
@@ -0,0 +1,327 @@
|
||||
import { useContextKey } from '@kevisual/context';
|
||||
import { nanoid, customAlphabet } from 'nanoid';
|
||||
import { DataTypes, Model, ModelAttributes } from 'sequelize';
|
||||
import type { Sequelize } from 'sequelize';
|
||||
export const random = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
||||
export type Mark = Partial<InstanceType<typeof MarkModel>>;
|
||||
export type MarkData = {
|
||||
md?: string; // markdown
|
||||
mdList?: string[]; // markdown list
|
||||
type?: string; // 类型 markdown | json | html | image | video | audio | code | link | file
|
||||
data?: any;
|
||||
key?: string; // 文件的名称, 唯一
|
||||
push?: boolean; // 是否推送到elasticsearch
|
||||
pushTime?: Date; // 推送时间
|
||||
summary?: string; // 摘要
|
||||
nodes?: MarkDataNode[]; // 节点
|
||||
[key: string]: any;
|
||||
};
|
||||
export type MarkFile = {
|
||||
id: string;
|
||||
name: string;
|
||||
url: string;
|
||||
size: number;
|
||||
type: 'self' | 'data' | 'generate'; // generate为生成文件
|
||||
query: string; // 'data.nodes[id].content';
|
||||
hash: string;
|
||||
fileKey: string; // 文件的名称, 唯一
|
||||
};
|
||||
export type MarkDataNode = {
|
||||
id?: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
export type MarkConfig = {
|
||||
[key: string]: any;
|
||||
};
|
||||
export type MarkAuth = {
|
||||
[key: string]: any;
|
||||
};
|
||||
/**
|
||||
* 隐秘内容
|
||||
* auth
|
||||
* config
|
||||
*
|
||||
*/
|
||||
export class MarkModel extends Model {
|
||||
declare id: string;
|
||||
declare title: string; // 标题,可以ai生成
|
||||
declare description: string; // 描述,可以ai生成
|
||||
declare cover: string; // 封面,可以ai生成
|
||||
declare thumbnail: string; // 缩略图
|
||||
declare key: string; // 文件路径
|
||||
declare markType: string; // markdown | json | html | image | video | audio | code | link | file
|
||||
declare link: string; // 访问链接
|
||||
declare tags: string[]; // 标签
|
||||
declare summary: string; // 摘要, description的简化版
|
||||
declare data: MarkData; // 数据
|
||||
|
||||
declare uid: string; // 操作用户的id
|
||||
declare puid: string; // 父级用户的id, 真实用户
|
||||
declare config: MarkConfig; // mark属于一定不会暴露的内容。
|
||||
|
||||
declare fileList: MarkFile[]; // 文件管理
|
||||
declare uname: string; // 用户的名称, 或者着别名
|
||||
|
||||
declare markedAt: Date; // 标记时间
|
||||
declare createdAt: Date;
|
||||
declare updatedAt: Date;
|
||||
declare version: number;
|
||||
/**
|
||||
* 加锁更新data中的node的节点,通过node的id
|
||||
* @param param0
|
||||
*/
|
||||
static async updateJsonNode(id: string, node: MarkDataNode, opts?: { operate?: 'update' | 'delete'; Model?: any; sequelize?: Sequelize }) {
|
||||
const sequelize = opts?.sequelize || (await useContextKey('sequelize'));
|
||||
const transaction = await sequelize.transaction(); // 开启事务
|
||||
const operate = opts.operate || 'update';
|
||||
const isUpdate = operate === 'update';
|
||||
const Model = opts.Model || MarkModel;
|
||||
try {
|
||||
// 1. 获取当前的 JSONB 字段值(加锁)
|
||||
const mark = await Model.findByPk(id, {
|
||||
transaction,
|
||||
lock: transaction.LOCK.UPDATE, // 加锁,防止其他事务同时修改
|
||||
});
|
||||
if (!mark) {
|
||||
throw new Error('Mark not found');
|
||||
}
|
||||
// 2. 修改特定的数组元素
|
||||
const data = mark.data as MarkData;
|
||||
const items = data.nodes;
|
||||
if (!node.id) {
|
||||
node.id = random(12);
|
||||
}
|
||||
|
||||
// 找到要更新的元素
|
||||
const itemIndex = items.findIndex((item) => item.id === node.id);
|
||||
if (itemIndex === -1) {
|
||||
isUpdate && items.push(node);
|
||||
} else {
|
||||
if (isUpdate) {
|
||||
items[itemIndex] = node;
|
||||
} else {
|
||||
items.splice(itemIndex, 1);
|
||||
}
|
||||
}
|
||||
const version = Number(mark.version) + 1;
|
||||
// 4. 更新 JSONB 字段
|
||||
const result = await mark.update(
|
||||
{
|
||||
data: {
|
||||
...data,
|
||||
nodes: items,
|
||||
},
|
||||
version,
|
||||
},
|
||||
{ transaction },
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
return result;
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
static async updateJsonNodes(id: string, nodes: { node: MarkDataNode; operate?: 'update' | 'delete' }[], opts?: { Model?: any; sequelize?: Sequelize }) {
|
||||
const sequelize = opts?.sequelize || (await useContextKey('sequelize'));
|
||||
const transaction = await sequelize.transaction(); // 开启事务
|
||||
const Model = opts?.Model || MarkModel;
|
||||
try {
|
||||
const mark = await Model.findByPk(id, {
|
||||
transaction,
|
||||
lock: transaction.LOCK.UPDATE, // 加锁,防止其他事务同时修改
|
||||
});
|
||||
if (!mark) {
|
||||
throw new Error('Mark not found');
|
||||
}
|
||||
const data = mark.data as MarkData;
|
||||
const _nodes = data.nodes || [];
|
||||
// 过滤不在nodes中的节点
|
||||
const blankNodes = nodes.filter((node) => !_nodes.find((n) => n.id === node.node.id)).map((node) => node.node);
|
||||
// 更新或删除节点
|
||||
const newNodes = _nodes
|
||||
.map((node) => {
|
||||
const nodeOperate = nodes.find((n) => n.node.id === node.id);
|
||||
if (nodeOperate) {
|
||||
if (nodeOperate.operate === 'delete') {
|
||||
return null;
|
||||
}
|
||||
return nodeOperate.node;
|
||||
}
|
||||
return node;
|
||||
})
|
||||
.filter((node) => node !== null);
|
||||
const version = Number(mark.version) + 1;
|
||||
const result = await mark.update(
|
||||
{
|
||||
data: {
|
||||
...data,
|
||||
nodes: [...blankNodes, ...newNodes],
|
||||
},
|
||||
version,
|
||||
},
|
||||
{ transaction },
|
||||
);
|
||||
await transaction.commit();
|
||||
return result;
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
static async updateData(id: string, data: MarkData, opts: { Model?: any; sequelize?: Sequelize }) {
|
||||
const sequelize = opts.sequelize || (await useContextKey('sequelize'));
|
||||
const transaction = await sequelize.transaction(); // 开启事务
|
||||
const Model = opts.Model || MarkModel;
|
||||
const mark = await Model.findByPk(id, {
|
||||
transaction,
|
||||
lock: transaction.LOCK.UPDATE, // 加锁,防止其他事务同时修改
|
||||
});
|
||||
if (!mark) {
|
||||
throw new Error('Mark not found');
|
||||
}
|
||||
const version = Number(mark.version) + 1;
|
||||
const result = await mark.update(
|
||||
{
|
||||
...mark.data,
|
||||
...data,
|
||||
data: {
|
||||
...mark.data,
|
||||
...data,
|
||||
},
|
||||
version,
|
||||
},
|
||||
{ transaction },
|
||||
);
|
||||
await transaction.commit();
|
||||
return result;
|
||||
}
|
||||
static async createNew(data: any, opts: { Model?: any; sequelize?: Sequelize }) {
|
||||
const sequelize = opts.sequelize || (await useContextKey('sequelize'));
|
||||
const transaction = await sequelize.transaction(); // 开启事务
|
||||
const Model = opts.Model || MarkModel;
|
||||
const result = await Model.create({ ...data, version: 1 }, { transaction });
|
||||
await transaction.commit();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
export type MarkInitOpts<T = any> = {
|
||||
tableName: string;
|
||||
sequelize?: Sequelize;
|
||||
callInit?: (attribute: ModelAttributes) => ModelAttributes;
|
||||
Model?: T extends typeof MarkModel ? T : typeof MarkModel;
|
||||
};
|
||||
export type Opts = {
|
||||
sync?: boolean;
|
||||
alter?: boolean;
|
||||
logging?: boolean | ((...args: any) => any);
|
||||
force?: boolean;
|
||||
};
|
||||
export const MarkMInit = async <T = any>(opts: MarkInitOpts<T>, sync?: Opts) => {
|
||||
const sequelize = await useContextKey('sequelize');
|
||||
opts.sequelize = opts.sequelize || sequelize;
|
||||
const { callInit, Model, ...optsRest } = opts;
|
||||
const modelAttribute = {
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
comment: 'id',
|
||||
},
|
||||
title: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
},
|
||||
key: {
|
||||
type: DataTypes.TEXT, // 对应的minio的文件路径
|
||||
defaultValue: '',
|
||||
},
|
||||
markType: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: 'md', // markdown | json | html | image | video | audio | code | link | file
|
||||
comment: '类型',
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
},
|
||||
cover: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
comment: '封面',
|
||||
},
|
||||
thumbnail: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
comment: '缩略图',
|
||||
},
|
||||
link: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
comment: '链接',
|
||||
},
|
||||
tags: {
|
||||
type: DataTypes.JSONB,
|
||||
defaultValue: [],
|
||||
},
|
||||
summary: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
comment: '摘要',
|
||||
},
|
||||
config: {
|
||||
type: DataTypes.JSONB,
|
||||
defaultValue: {},
|
||||
},
|
||||
data: {
|
||||
type: DataTypes.JSONB,
|
||||
defaultValue: {},
|
||||
},
|
||||
fileList: {
|
||||
type: DataTypes.JSONB,
|
||||
defaultValue: [],
|
||||
},
|
||||
uname: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: '',
|
||||
comment: '用户的名称, 更新后的用户的名称',
|
||||
},
|
||||
version: {
|
||||
type: DataTypes.INTEGER, // 更新刷新版本,多人协作
|
||||
defaultValue: 1,
|
||||
},
|
||||
markedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: true,
|
||||
comment: '标记时间',
|
||||
},
|
||||
uid: {
|
||||
type: DataTypes.UUID,
|
||||
allowNull: true,
|
||||
},
|
||||
puid: {
|
||||
type: DataTypes.UUID,
|
||||
allowNull: true,
|
||||
},
|
||||
};
|
||||
const InitModel = Model || MarkModel;
|
||||
InitModel.init(callInit ? callInit(modelAttribute) : modelAttribute, {
|
||||
sequelize,
|
||||
paranoid: true,
|
||||
...optsRest,
|
||||
});
|
||||
if (sync && sync.sync) {
|
||||
const { sync: _, ...rest } = sync;
|
||||
MarkModel.sync({ alter: true, logging: false, ...rest }).catch((e) => {
|
||||
console.error('MarkModel sync', e);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const markModelInit = MarkMInit;
|
||||
|
||||
export const syncMarkModel = async (sync?: Opts, tableName = 'micro_mark') => {
|
||||
const sequelize = await useContextKey('sequelize');
|
||||
await MarkMInit({ sequelize, tableName }, sync);
|
||||
};
|
||||
@@ -1,324 +1,5 @@
|
||||
import { useContextKey } from '@kevisual/use-config/context';
|
||||
import { nanoid, customAlphabet } from 'nanoid';
|
||||
import { DataTypes, Model, ModelAttributes } from 'sequelize';
|
||||
import type { Sequelize } from 'sequelize';
|
||||
export const random = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
||||
export type Mark = Partial<InstanceType<typeof MarkModel>>;
|
||||
export type MarkData = {
|
||||
md?: string; // markdown
|
||||
mdList?: string[]; // markdown list
|
||||
type?: string; // 类型 markdown | json | html | image | video | audio | code | link | file
|
||||
data?: any;
|
||||
key?: string; // 文件的名称, 唯一
|
||||
push?: boolean; // 是否推送到elasticsearch
|
||||
pushTime?: Date; // 推送时间
|
||||
summary?: string; // 摘要
|
||||
nodes?: MarkDataNode[]; // 节点
|
||||
[key: string]: any;
|
||||
};
|
||||
export type MarkFile = {
|
||||
id: string;
|
||||
name: string;
|
||||
url: string;
|
||||
size: number;
|
||||
type: 'self' | 'data' | 'generate'; // generate为生成文件
|
||||
query: string; // 'data.nodes[id].content';
|
||||
hash: string;
|
||||
fileKey: string; // 文件的名称, 唯一
|
||||
};
|
||||
export type MarkDataNode = {
|
||||
id?: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
export type MarkConfig = {
|
||||
[key: string]: any;
|
||||
};
|
||||
export type MarkAuth = {
|
||||
[key: string]: any;
|
||||
};
|
||||
/**
|
||||
* 隐秘内容
|
||||
* auth
|
||||
* config
|
||||
*
|
||||
*/
|
||||
export class MarkModel extends Model {
|
||||
declare id: string;
|
||||
declare title: string; // 标题,可以ai生成
|
||||
declare description: string; // 描述,可以ai生成
|
||||
declare cover: string; // 封面,可以ai生成
|
||||
declare thumbnail: string; // 缩略图
|
||||
declare key: string; // 文件路径
|
||||
declare markType: string; // markdown | json | html | image | video | audio | code | link | file
|
||||
declare link: string; // 访问链接
|
||||
declare tags: string[]; // 标签
|
||||
declare summary: string; // 摘要, description的简化版
|
||||
declare data: MarkData; // 数据
|
||||
|
||||
declare uid: string; // 操作用户的id
|
||||
declare puid: string; // 父级用户的id, 真实用户
|
||||
declare config: MarkConfig; // mark属于一定不会暴露的内容。
|
||||
|
||||
declare fileList: MarkFile[]; // 文件管理
|
||||
declare uname: string; // 用户的名称, 或者着别名
|
||||
|
||||
declare createdAt: Date;
|
||||
declare updatedAt: Date;
|
||||
declare version: number;
|
||||
/**
|
||||
* 加锁更新data中的node的节点,通过node的id
|
||||
* @param param0
|
||||
*/
|
||||
static async updateJsonNode(id: string, node: MarkDataNode, opts?: { operate?: 'update' | 'delete'; Model?: any; sequelize?: Sequelize }) {
|
||||
const sequelize = opts?.sequelize || (await useContextKey('sequelize'));
|
||||
const transaction = await sequelize.transaction(); // 开启事务
|
||||
const operate = opts.operate || 'update';
|
||||
const isUpdate = operate === 'update';
|
||||
const Model = opts.Model || MarkModel;
|
||||
try {
|
||||
// 1. 获取当前的 JSONB 字段值(加锁)
|
||||
const mark = await Model.findByPk(id, {
|
||||
transaction,
|
||||
lock: transaction.LOCK.UPDATE, // 加锁,防止其他事务同时修改
|
||||
});
|
||||
if (!mark) {
|
||||
throw new Error('Mark not found');
|
||||
}
|
||||
// 2. 修改特定的数组元素
|
||||
const data = mark.data as MarkData;
|
||||
const items = data.nodes;
|
||||
if (!node.id) {
|
||||
node.id = random(12);
|
||||
}
|
||||
|
||||
// 找到要更新的元素
|
||||
const itemIndex = items.findIndex((item) => item.id === node.id);
|
||||
if (itemIndex === -1) {
|
||||
isUpdate && items.push(node);
|
||||
} else {
|
||||
if (isUpdate) {
|
||||
items[itemIndex] = node;
|
||||
} else {
|
||||
items.splice(itemIndex, 1);
|
||||
}
|
||||
}
|
||||
const version = Number(mark.version) + 1;
|
||||
// 4. 更新 JSONB 字段
|
||||
const result = await mark.update(
|
||||
{
|
||||
data: {
|
||||
...data,
|
||||
nodes: items,
|
||||
},
|
||||
version,
|
||||
},
|
||||
{ transaction },
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
return result;
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
static async updateJsonNodes(id: string, nodes: { node: MarkDataNode; operate?: 'update' | 'delete' }[], opts?: { Model?: any; sequelize?: Sequelize }) {
|
||||
const sequelize = opts?.sequelize || (await useContextKey('sequelize'));
|
||||
const transaction = await sequelize.transaction(); // 开启事务
|
||||
const Model = opts?.Model || MarkModel;
|
||||
try {
|
||||
const mark = await Model.findByPk(id, {
|
||||
transaction,
|
||||
lock: transaction.LOCK.UPDATE, // 加锁,防止其他事务同时修改
|
||||
});
|
||||
if (!mark) {
|
||||
throw new Error('Mark not found');
|
||||
}
|
||||
const data = mark.data as MarkData;
|
||||
const _nodes = data.nodes || [];
|
||||
// 过滤不在nodes中的节点
|
||||
const blankNodes = nodes.filter((node) => !_nodes.find((n) => n.id === node.node.id)).map((node) => node.node);
|
||||
// 更新或删除节点
|
||||
const newNodes = _nodes
|
||||
.map((node) => {
|
||||
const nodeOperate = nodes.find((n) => n.node.id === node.id);
|
||||
if (nodeOperate) {
|
||||
if (nodeOperate.operate === 'delete') {
|
||||
return null;
|
||||
}
|
||||
return nodeOperate.node;
|
||||
}
|
||||
return node;
|
||||
})
|
||||
.filter((node) => node !== null);
|
||||
const version = Number(mark.version) + 1;
|
||||
const result = await mark.update(
|
||||
{
|
||||
data: {
|
||||
...data,
|
||||
nodes: [...blankNodes, ...newNodes],
|
||||
},
|
||||
version,
|
||||
},
|
||||
{ transaction },
|
||||
);
|
||||
await transaction.commit();
|
||||
return result;
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
static async updateData(id: string, data: MarkData, opts: { Model?: any; sequelize?: Sequelize }) {
|
||||
const sequelize = opts.sequelize || (await useContextKey('sequelize'));
|
||||
const transaction = await sequelize.transaction(); // 开启事务
|
||||
const Model = opts.Model || MarkModel;
|
||||
const mark = await Model.findByPk(id, {
|
||||
transaction,
|
||||
lock: transaction.LOCK.UPDATE, // 加锁,防止其他事务同时修改
|
||||
});
|
||||
if (!mark) {
|
||||
throw new Error('Mark not found');
|
||||
}
|
||||
const version = Number(mark.version) + 1;
|
||||
const result = await mark.update(
|
||||
{
|
||||
...mark.data,
|
||||
...data,
|
||||
data: {
|
||||
...mark.data,
|
||||
...data,
|
||||
},
|
||||
version,
|
||||
},
|
||||
{ transaction },
|
||||
);
|
||||
await transaction.commit();
|
||||
return result;
|
||||
}
|
||||
static async createNew(data: any, opts: { Model?: any; sequelize?: Sequelize }) {
|
||||
const sequelize = opts.sequelize || (await useContextKey('sequelize'));
|
||||
const transaction = await sequelize.transaction(); // 开启事务
|
||||
const Model = opts.Model || MarkModel;
|
||||
const result = await Model.create({ ...data, version: 1 }, { transaction });
|
||||
await transaction.commit();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
export type MarkInitOpts<T = any> = {
|
||||
tableName: string;
|
||||
sequelize?: Sequelize;
|
||||
callInit?: (attribute: ModelAttributes) => ModelAttributes;
|
||||
Model?: T;
|
||||
};
|
||||
export type Opts = {
|
||||
sync?: boolean;
|
||||
alter?: boolean;
|
||||
logging?: boolean;
|
||||
force?: boolean;
|
||||
};
|
||||
export const MarkMInit = async <T = any>(opts: MarkInitOpts<T>, sync?: Opts) => {
|
||||
const sequelize = await useContextKey('sequelize');
|
||||
opts.sequelize = opts.sequelize || sequelize;
|
||||
const { callInit, Model, ...optsRest } = opts;
|
||||
const modelAttribute = {
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
comment: 'id',
|
||||
},
|
||||
title: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
},
|
||||
key: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
},
|
||||
markType: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: 'md', // markdown | json | html | image | video | audio | code | link | file
|
||||
comment: '类型',
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
},
|
||||
cover: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
comment: '封面',
|
||||
},
|
||||
thumbnail: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
comment: '缩略图',
|
||||
},
|
||||
link: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
comment: '链接',
|
||||
},
|
||||
tags: {
|
||||
type: DataTypes.JSONB,
|
||||
defaultValue: [],
|
||||
},
|
||||
summary: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
comment: '摘要',
|
||||
},
|
||||
config: {
|
||||
type: DataTypes.JSONB,
|
||||
defaultValue: {},
|
||||
},
|
||||
data: {
|
||||
type: DataTypes.JSONB,
|
||||
defaultValue: {},
|
||||
},
|
||||
fileList: {
|
||||
type: DataTypes.JSONB,
|
||||
defaultValue: [],
|
||||
},
|
||||
uname: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: '',
|
||||
comment: '用户的名称, 更新后的用户的名称',
|
||||
},
|
||||
version: {
|
||||
type: DataTypes.INTEGER, // 更新刷新版本,多人协作
|
||||
defaultValue: 1,
|
||||
},
|
||||
uid: {
|
||||
type: DataTypes.UUID,
|
||||
allowNull: true,
|
||||
},
|
||||
puid: {
|
||||
type: DataTypes.UUID,
|
||||
allowNull: true,
|
||||
},
|
||||
};
|
||||
const InitModel = Model || MarkModel;
|
||||
// @ts-ignore
|
||||
InitModel.init(callInit ? callInit(modelAttribute) : modelAttribute, {
|
||||
sequelize,
|
||||
paranoid: true,
|
||||
...optsRest,
|
||||
});
|
||||
if (sync && sync.sync) {
|
||||
const { sync: _, ...rest } = sync;
|
||||
MarkModel.sync({ alter: true, logging: false, ...rest }).catch((e) => {
|
||||
console.error('MarkModel sync', e);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const markModelInit = MarkMInit;
|
||||
|
||||
export const syncMarkModel = async (sync?: Opts) => {
|
||||
const sequelize = await useContextKey('sequelize');
|
||||
await MarkMInit({ sequelize, tableName: 'micro_mark' }, sync);
|
||||
};
|
||||
export * from '@kevisual/code-center-module/src/mark/mark-model.ts';
|
||||
import { markModelInit, MarkModel, syncMarkModel } from '@kevisual/code-center-module/src/mark/mark-model.ts';
|
||||
export { markModelInit, MarkModel };
|
||||
|
||||
syncMarkModel({ sync: true, alter: true, logging: false });
|
||||
|
||||
@@ -18,17 +18,33 @@ app
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const data = ctx.query?.data;
|
||||
const { id, key, force, install } = data;
|
||||
if (!id) {
|
||||
ctx.throw(400, 'Invalid id');
|
||||
const { id, key, force, install, appKey: postAppKey, version: postVersion = '1.0.0' } = data;
|
||||
if (!id && !postAppKey) {
|
||||
ctx.throw(400, 'Invalid id or postAppKey');
|
||||
}
|
||||
let username = tokenUser.username;
|
||||
if (data.username) {
|
||||
// username = data.username;
|
||||
if (data.username && username === 'admin') {
|
||||
username = data.username;
|
||||
}
|
||||
const microApp = await AppListModel.findByPk(id);
|
||||
let microApp: AppListModel;
|
||||
if (!microApp && id) {
|
||||
microApp = await AppListModel.findByPk(id);
|
||||
}
|
||||
if (!microApp && postAppKey) {
|
||||
microApp = await AppListModel.findOne({
|
||||
where: {
|
||||
key: postAppKey,
|
||||
version: postVersion,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (!microApp) {
|
||||
ctx.throw(400, 'Invalid id');
|
||||
if (id) {
|
||||
ctx.throw(400, 'Invalid id');
|
||||
} else {
|
||||
ctx.throw(400, `Invalid appKey , no found app with key: ${postAppKey} and version: ${postVersion}`);
|
||||
}
|
||||
}
|
||||
const { key: appKey, version } = microApp;
|
||||
const check = await appPathCheck({ key: key });
|
||||
|
||||
@@ -25,7 +25,7 @@ export const installAppFromKey = async (key: string) => {
|
||||
}
|
||||
let showAppInfo = {
|
||||
key,
|
||||
status: 'inactive',
|
||||
status: 'inactive' as const,
|
||||
type: app?.type || 'system-app',
|
||||
description: readmeDesc || '',
|
||||
version,
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ContainerModel } from '../container/models/index.ts';
|
||||
import { Op } from 'sequelize';
|
||||
import { AppListModel, AppModel } from '../app-manager/index.ts';
|
||||
import { cachePage, getZip } from './module/cache-file.ts';
|
||||
import _ from 'lodash';
|
||||
import { uniqBy } from 'lodash-es';
|
||||
import semver from 'semver';
|
||||
|
||||
app
|
||||
@@ -53,7 +53,7 @@ app
|
||||
// 上传文件
|
||||
const res = await cachePage(page, { tokenUser, key, version: _version });
|
||||
const appFiles = appList?.data?.files || [];
|
||||
const newFiles = _.uniqBy([...appFiles, ...res], 'name');
|
||||
const newFiles = uniqBy([...appFiles, ...res], 'name');
|
||||
appList.data = {
|
||||
...appList?.data,
|
||||
files: newFiles,
|
||||
|
||||
@@ -3,12 +3,14 @@ import './org.ts';
|
||||
|
||||
import './me.ts';
|
||||
|
||||
import './update.ts'
|
||||
import './update.ts';
|
||||
|
||||
import './init.ts'
|
||||
import './init.ts';
|
||||
|
||||
import './web-login.ts'
|
||||
import './web-login.ts';
|
||||
|
||||
import './org-user/list.ts'
|
||||
import './org-user/list.ts';
|
||||
|
||||
import './admin/user.ts';
|
||||
import './admin/user.ts';
|
||||
|
||||
import './secret-key/list.ts';
|
||||
|
||||
136
src/routes/user/secret-key/list.ts
Normal file
136
src/routes/user/secret-key/list.ts
Normal file
@@ -0,0 +1,136 @@
|
||||
import { Op } from 'sequelize';
|
||||
import { User, UserSecret } from '@/models/user.ts';
|
||||
import { app } from '@/app.ts';
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'secret',
|
||||
key: 'list',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const { page = 1, pageSize = 20, search, sort = 'DESC', orgId } = ctx.query;
|
||||
const searchWhere: Record<string, any> = search
|
||||
? {
|
||||
[Op.or]: [{ title: { [Op.like]: `%${search}%` } }, { description: { [Op.like]: `%${search}%` } }],
|
||||
}
|
||||
: {};
|
||||
if (orgId) {
|
||||
searchWhere.orgId = orgId;
|
||||
}
|
||||
const { rows: secrets, count } = await UserSecret.findAndCountAll({
|
||||
where: {
|
||||
userId: tokenUser.userId,
|
||||
...searchWhere,
|
||||
},
|
||||
offset: (page - 1) * pageSize,
|
||||
limit: pageSize,
|
||||
attributes: {
|
||||
exclude: ['token'], // Exclude sensitive token field
|
||||
},
|
||||
order: [['updatedAt', sort]],
|
||||
});
|
||||
|
||||
ctx.body = {
|
||||
list: secrets,
|
||||
pagination: {
|
||||
page,
|
||||
current: page,
|
||||
pageSize,
|
||||
total: count,
|
||||
},
|
||||
};
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'secret',
|
||||
key: 'update',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const { id, updatedAt: _clear, createdAt: _clear2, token, ...rest } = ctx.query.data;
|
||||
let secret: UserSecret;
|
||||
let isNew = false;
|
||||
|
||||
if (id) {
|
||||
secret = await UserSecret.findByPk(id);
|
||||
if (!secret) {
|
||||
ctx.throw(404, 'Secret not found');
|
||||
}
|
||||
|
||||
if (secret.userId !== tokenUser.userId) {
|
||||
ctx.throw(403, 'No permission');
|
||||
}
|
||||
} else {
|
||||
secret = await UserSecret.createSecret(tokenUser);
|
||||
isNew = true;
|
||||
}
|
||||
if (secret) {
|
||||
secret = await secret.update({
|
||||
...rest,
|
||||
});
|
||||
}
|
||||
|
||||
ctx.body = secret;
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'secret',
|
||||
key: 'delete',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const { id } = ctx.query.data || {};
|
||||
|
||||
if (!id) {
|
||||
ctx.throw(400, 'id is required');
|
||||
}
|
||||
|
||||
const secret = await UserSecret.findByPk(id);
|
||||
|
||||
if (!secret) {
|
||||
ctx.throw(404, 'Secret not found');
|
||||
}
|
||||
if (secret.userId !== tokenUser.userId) {
|
||||
ctx.throw(403, 'No permission');
|
||||
}
|
||||
|
||||
await secret.destroy();
|
||||
ctx.body = secret;
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'secret',
|
||||
key: 'get',
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const { id } = ctx.query.data || {};
|
||||
|
||||
if (!id) {
|
||||
ctx.throw(400, 'id is required');
|
||||
}
|
||||
|
||||
const secret = await UserSecret.findByPk(id);
|
||||
|
||||
if (!secret) {
|
||||
ctx.throw(404, 'Secret not found');
|
||||
}
|
||||
|
||||
if (secret.userId !== tokenUser.uid) {
|
||||
ctx.throw(403, 'No permission');
|
||||
}
|
||||
|
||||
ctx.body = secret;
|
||||
})
|
||||
.addTo(app);
|
||||
3
src/scripts/common-redis.ts
Normal file
3
src/scripts/common-redis.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import * as redisLib from '../modules/redis.ts';
|
||||
import { useContextKey, useContext } from '@kevisual/context';
|
||||
export const redis = useContextKey('redis', () => redisLib.redis);
|
||||
@@ -1,7 +1,8 @@
|
||||
import { config } from '../modules/config.ts';
|
||||
import { sequelize } from '../modules/sequelize.ts';
|
||||
export { program, Command } from '../program.ts';
|
||||
import { User, UserInit, OrgInit, Org } from '@kevisual/code-center-module/models';
|
||||
// import { User, UserInit, OrgInit, Org, UserSecretInit, UserSecret } from '@kevisual/code-center-module/models';
|
||||
import { User, UserInit, OrgInit, Org, UserSecretInit, UserSecret } from '@kevisual/code-center-module/src/core-models.ts';
|
||||
import { Logger } from '@kevisual/logger';
|
||||
export const close = async () => {
|
||||
process.exit(0);
|
||||
@@ -22,8 +23,13 @@ export const initUser = async () => {
|
||||
alter: true,
|
||||
logging: false,
|
||||
});
|
||||
await UserSecretInit(sequelize, undefined, {
|
||||
alter: true,
|
||||
logging: false,
|
||||
});
|
||||
return {
|
||||
User: User,
|
||||
Org: Org,
|
||||
UserSecret: UserSecret,
|
||||
};
|
||||
};
|
||||
|
||||
62
src/test/create-user-secret.ts
Normal file
62
src/test/create-user-secret.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { sequelize } from '../modules/sequelize.ts';
|
||||
import { initUser } from '../scripts/common.ts';
|
||||
import '../scripts/common-redis.ts';
|
||||
import { useContextKey } from '@kevisual/context';
|
||||
|
||||
export const main = async () => {
|
||||
const models = await initUser();
|
||||
|
||||
const username = 'root';
|
||||
const orgname = 'admin';
|
||||
|
||||
const user = await models.User.findOne({ where: { username } });
|
||||
const org = await models.User.findOne({ where: { username: orgname } });
|
||||
|
||||
console.log('user.id', user?.id);
|
||||
console.log('org.id', org?.id);
|
||||
// const userSecret1 = await models.UserSecret.createSecret(user?.id!);
|
||||
// userSecret1.title = 'root secret';
|
||||
// await userSecret1.save();
|
||||
// await models.UserSecret.destroy({
|
||||
// where: {
|
||||
// orgId: '16a496d4-8cd6-4e02-b403-c2adc006a53d',
|
||||
// },
|
||||
// });
|
||||
const userSecret2 = await models.UserSecret.createSecret(user?.id!, org?.id!);
|
||||
userSecret2.title = 'root org secret';
|
||||
await userSecret2.save();
|
||||
|
||||
const secretList = await models.UserSecret.findAll();
|
||||
for (const secret of secretList) {
|
||||
console.log(`\nSecret ID: ${secret.id}, User ID: ${secret.userId}, Org ID: ${secret.orgId}, Token: ${secret.token}, Expired Time: ${secret.expiredTime}`);
|
||||
}
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
main();
|
||||
|
||||
export const dropTable = async () => {
|
||||
await sequelize.query('DROP TABLE IF EXISTS "cf_user_secrets"');
|
||||
console.log('UserSecret table dropped');
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
// dropTable()
|
||||
|
||||
const token1 = 'sk_tvwzgp5lky8iupawh0encvd52vji4o8argvd2x668gn15q83xpgo8fe10ny7wfsq';
|
||||
const orgToken2 = 'sk_x37p8iifh6k18c3f121w49nmfy1sbjqpyol9fcsz0lmc5dz493wrfwvtxc4gi9od';
|
||||
|
||||
export const main2 = async () => {
|
||||
const redis = useContextKey('redis');
|
||||
if (!redis) {
|
||||
console.error('Redis is not initialized');
|
||||
return;
|
||||
}
|
||||
const models = await initUser();
|
||||
const UserSecret = models.UserSecret;
|
||||
const v = await models.UserSecret.verifyToken(token1);
|
||||
console.log('verifyToken', v);
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
// main2();
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useContextKey } from '@kevisual/use-config/context';
|
||||
import { useContextKey } from '@kevisual/context';
|
||||
import { sequelize } from '../modules/sequelize.ts';
|
||||
import { MarkModel, syncMarkModel } from '../routes/mark/model.ts';
|
||||
export const sequelize2 = useContextKey('sequelize', () => sequelize);
|
||||
|
||||
10
src/test/test-sql.ts
Normal file
10
src/test/test-sql.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { sequelize } from '../modules/sequelize.ts';
|
||||
|
||||
console.log('sequelize');
|
||||
|
||||
// 获取所有表名
|
||||
const [tables] = await sequelize.query(
|
||||
"SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';"
|
||||
);
|
||||
|
||||
console.log('tables', tables);
|
||||
Submodule submodules/code-center-module deleted from 83f65e1554
Submodule submodules/oss deleted from cd43d66265
Submodule submodules/pay-center-code deleted from 2a53b82fde
Submodule submodules/permission deleted from dc56548cdf
17
turbo.json
17
turbo.json
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"$schema": "https://turbo.build/schema.json",
|
||||
"tasks": {
|
||||
"build": {
|
||||
"dependsOn": [
|
||||
"^build"
|
||||
],
|
||||
"outputs": [
|
||||
"dist/**"
|
||||
]
|
||||
},
|
||||
"dev:lib": {
|
||||
"persistent": true,
|
||||
"cache": true
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user