feat: 更新依赖版本,优化用户模型构造函数和域名管理路由
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kevisual/code-center",
|
||||
"version": "0.0.12",
|
||||
"version": "0.0.13",
|
||||
"description": "code center",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
@@ -47,7 +47,7 @@
|
||||
"@types/busboy": "^1.5.4",
|
||||
"@types/send": "^1.2.1",
|
||||
"@types/ws": "^8.18.1",
|
||||
"bullmq": "^5.69.3",
|
||||
"bullmq": "^5.70.1",
|
||||
"busboy": "^1.6.0",
|
||||
"drizzle-kit": "^0.31.9",
|
||||
"drizzle-orm": "^0.45.1",
|
||||
@@ -59,14 +59,14 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@aws-sdk/client-s3": "^3.995.0",
|
||||
"@kevisual/api": "^0.0.57",
|
||||
"@kevisual/api": "^0.0.59",
|
||||
"@kevisual/cnb": "^0.0.28",
|
||||
"@kevisual/context": "^0.0.8",
|
||||
"@kevisual/local-app-manager": "0.1.32",
|
||||
"@kevisual/logger": "^0.0.4",
|
||||
"@kevisual/oss": "0.0.19",
|
||||
"@kevisual/permission": "^0.0.4",
|
||||
"@kevisual/router": "0.0.83",
|
||||
"@kevisual/router": "0.0.84",
|
||||
"@kevisual/types": "^0.0.12",
|
||||
"@kevisual/use-config": "^1.0.30",
|
||||
"@types/archiver": "^7.0.0",
|
||||
|
||||
30
pnpm-lock.yaml
generated
30
pnpm-lock.yaml
generated
@@ -35,8 +35,8 @@ importers:
|
||||
specifier: ^8.18.1
|
||||
version: 8.18.1
|
||||
bullmq:
|
||||
specifier: ^5.69.3
|
||||
version: 5.69.3
|
||||
specifier: ^5.70.1
|
||||
version: 5.70.1
|
||||
busboy:
|
||||
specifier: ^1.6.0
|
||||
version: 1.6.0
|
||||
@@ -66,8 +66,8 @@ importers:
|
||||
specifier: ^3.995.0
|
||||
version: 3.995.0
|
||||
'@kevisual/api':
|
||||
specifier: ^0.0.57
|
||||
version: 0.0.57(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
|
||||
specifier: ^0.0.59
|
||||
version: 0.0.59(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
|
||||
'@kevisual/cnb':
|
||||
specifier: ^0.0.28
|
||||
version: 0.0.28(dotenv@17.3.1)(ioredis@5.9.3)
|
||||
@@ -87,8 +87,8 @@ importers:
|
||||
specifier: ^0.0.4
|
||||
version: 0.0.4
|
||||
'@kevisual/router':
|
||||
specifier: 0.0.83
|
||||
version: 0.0.83
|
||||
specifier: 0.0.84
|
||||
version: 0.0.84
|
||||
'@kevisual/types':
|
||||
specifier: ^0.0.12
|
||||
version: 0.0.12
|
||||
@@ -665,8 +665,8 @@ packages:
|
||||
'@kevisual/ai@0.0.24':
|
||||
resolution: {integrity: sha512-7jvZk1/L//VIClK7usuNgN4ZA9Etgbooka1Sj5quE/0UywR+NNnwqXVZ89Y1fBhI1TkhauDsdJBAtcQ7r/vbVw==}
|
||||
|
||||
'@kevisual/api@0.0.57':
|
||||
resolution: {integrity: sha512-U2nz+ckWZ4XGASC08xJT6WKQajhFQDd1iDb9tU1dHZECsvNvIzpHLG7RHFN1vahG1MdbQtppPmHgVTF2Zw7RWg==}
|
||||
'@kevisual/api@0.0.59':
|
||||
resolution: {integrity: sha512-2w6GBG2mS92dz8afB0hLfjTw8lBGD5oXU5bw/QglFugHHp24fISZkEW1Hc+jP/jOiYlMzphws2/31DIXdDoGkg==}
|
||||
|
||||
'@kevisual/auth@2.0.3':
|
||||
resolution: {integrity: sha512-4xpijaIhlCTr/DlJaV/gmkCQeg45EO1yxWpRvUX+1jCdVbuxSR0wZrF0SD9oybnjmKWMKDNPLsXyduFjMGcItA==}
|
||||
@@ -716,8 +716,8 @@ packages:
|
||||
'@kevisual/router@0.0.80':
|
||||
resolution: {integrity: sha512-rVwi6Yf411bnNm2x94lMm+s4Csw0Yb7u/aj+VJJ59iouAYhjLuL7Rs1EcARhnQf47cegBJi6zozfGHgLsLHN2w==}
|
||||
|
||||
'@kevisual/router@0.0.83':
|
||||
resolution: {integrity: sha512-CVazzM1rXVyvU7QcMQr0/EuqacRNEGalThDDLGQcvKEVHyduJ9yWddn6kezgWFCpNlPKhzSCKkIFuZVixNVxDQ==}
|
||||
'@kevisual/router@0.0.84':
|
||||
resolution: {integrity: sha512-l/TUFuqTJegB/S3FZQRBMUoz0Spvg8EzV3C/kBi/VO9KKCzjqZDVvhZJJbTQh9879CBY6vUy1ajo9WcLYnwbNA==}
|
||||
|
||||
'@kevisual/types@0.0.12':
|
||||
resolution: {integrity: sha512-zJXH2dosir3jVrQ6QG4i0+iLQeT9gJ3H+cKXs8ReWboxBSYzUZO78XssVeVrFPsJ33iaAqo4q3DWbSS1dWGn7Q==}
|
||||
@@ -1182,8 +1182,8 @@ packages:
|
||||
buffer@6.0.3:
|
||||
resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
|
||||
|
||||
bullmq@5.69.3:
|
||||
resolution: {integrity: sha512-P9uLsR7fDvejH/1m6uur6j7U9mqY6nNt+XvhlhStOUe7jdwbZoP/c2oWNtE+8ljOlubw4pRUKymtRqkyvloc4A==}
|
||||
bullmq@5.70.1:
|
||||
resolution: {integrity: sha512-HjfGHfICkAClrFL0Y07qNbWcmiOCv1l+nusupXUjrvTPuDEyPEJ23MP0lUwUs/QEy1a3pWt/P/sCsSZ1RjRK+w==}
|
||||
|
||||
bun-types@1.3.9:
|
||||
resolution: {integrity: sha512-+UBWWOakIP4Tswh0Bt0QD0alpTY8cb5hvgiYeWCMet9YukHbzuruIEeXC2D7nMJPB12kbh8C7XJykSexEqGKJg==}
|
||||
@@ -3128,7 +3128,7 @@ snapshots:
|
||||
'@kevisual/permission': 0.0.3
|
||||
'@kevisual/query': 0.0.38
|
||||
|
||||
'@kevisual/api@0.0.57(react-dom@19.2.4(react@19.2.4))(react@19.2.4)':
|
||||
'@kevisual/api@0.0.59(react-dom@19.2.4(react@19.2.4))(react@19.2.4)':
|
||||
dependencies:
|
||||
'@kevisual/context': 0.0.8
|
||||
'@kevisual/js-filter': 0.0.5
|
||||
@@ -3227,7 +3227,7 @@ snapshots:
|
||||
dependencies:
|
||||
es-toolkit: 1.44.0
|
||||
|
||||
'@kevisual/router@0.0.83':
|
||||
'@kevisual/router@0.0.84':
|
||||
dependencies:
|
||||
es-toolkit: 1.44.0
|
||||
|
||||
@@ -3845,7 +3845,7 @@ snapshots:
|
||||
base64-js: 1.5.1
|
||||
ieee754: 1.2.1
|
||||
|
||||
bullmq@5.69.3:
|
||||
bullmq@5.70.1:
|
||||
dependencies:
|
||||
cron-parser: 4.9.0
|
||||
ioredis: 5.9.3
|
||||
|
||||
@@ -67,8 +67,10 @@ export class User {
|
||||
avatar: string;
|
||||
tokenUser: any;
|
||||
|
||||
constructor(data: UserSelect) {
|
||||
Object.assign(this, data);
|
||||
constructor(data?: UserSelect) {
|
||||
if (data) {
|
||||
Object.assign(this, data);
|
||||
}
|
||||
}
|
||||
|
||||
setTokenUser(tokenUser: any) {
|
||||
@@ -91,7 +93,7 @@ export class User {
|
||||
exp: Math.floor(Date.now() / 1000) + expiresIn,
|
||||
});
|
||||
await oauth.setJwksToken(accessToken, { id: user.id, expire: expiresIn });
|
||||
|
||||
|
||||
const token = {
|
||||
accessToken,
|
||||
refreshToken: accessToken,
|
||||
@@ -99,7 +101,7 @@ export class User {
|
||||
refreshTokenExpiresIn: expiresIn,
|
||||
accessTokenExpiresIn: expiresIn,
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
type: 'jwks',
|
||||
...token,
|
||||
@@ -150,9 +152,9 @@ export class User {
|
||||
throw new CustomError('Invalid refresh token');
|
||||
}
|
||||
const decoded = await jwksManager.decode(jwsRefreshToken);
|
||||
return await User.createJwksTokenResponse({
|
||||
id: decoded.sub.replace('user:', ''),
|
||||
username: decoded.name
|
||||
return await User.createJwksTokenResponse({
|
||||
id: decoded.sub.replace('user:', ''),
|
||||
username: decoded.name
|
||||
});
|
||||
}
|
||||
if (!refreshToken && !accessToken) {
|
||||
@@ -212,9 +214,9 @@ export class User {
|
||||
throw new CustomError('Invalid refresh token');
|
||||
}
|
||||
const decoded = await jwksManager.decode(refreshToken);
|
||||
return await User.createJwksTokenResponse({
|
||||
id: decoded.sub.replace('user:', ''),
|
||||
username: decoded.name
|
||||
return await User.createJwksTokenResponse({
|
||||
id: decoded.sub.replace('user:', ''),
|
||||
username: decoded.name
|
||||
});
|
||||
}
|
||||
return await oauth.resetToken(refreshToken, expand);
|
||||
|
||||
@@ -17,7 +17,7 @@ app
|
||||
}
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const { domain } = ctx.query.data;
|
||||
const { domain } = ctx.args.data;
|
||||
const domainInfos = await db.select().from(schema.kvAppDomain).where(eq(schema.kvAppDomain.domain, domain)).limit(1);
|
||||
const domainInfo = domainInfos[0];
|
||||
if (!domainInfo || !domainInfo.appId) {
|
||||
@@ -38,11 +38,20 @@ app
|
||||
path: 'app-domain',
|
||||
key: 'create',
|
||||
middleware: ['auth'],
|
||||
description: '创建应用域名绑定',
|
||||
metadata: {
|
||||
args: {
|
||||
data: z.object({
|
||||
domain: z.string().describe('域名'),
|
||||
appId: z.string().describe('应用ID'),
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const uid = tokenUser.uid;
|
||||
const { domain, appId } = ctx.query.data || {};
|
||||
const { domain, appId } = ctx.args.data || {};
|
||||
if (!domain || !appId) {
|
||||
ctx.throw(400, 'domain and appId are required');
|
||||
}
|
||||
@@ -58,11 +67,21 @@ app
|
||||
path: 'app-domain',
|
||||
key: 'update',
|
||||
middleware: ['auth'],
|
||||
metadata: {
|
||||
args: {
|
||||
data: z.object({
|
||||
id: z.string().optional().describe('域名ID'),
|
||||
domain: z.string().optional().describe('域名'),
|
||||
appId: z.string().optional().describe('应用ID'),
|
||||
status: z.string().describe('状态'),
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const uid = tokenUser.uid;
|
||||
const { id, domain, appId, status } = ctx.query.data || {};
|
||||
const { id, domain, appId, status } = ctx.args.data || {};
|
||||
if (!domain && !id) {
|
||||
ctx.throw(400, 'domain and id are required at least one');
|
||||
}
|
||||
@@ -87,7 +106,7 @@ app
|
||||
if (domainInfo.uid !== uid) {
|
||||
ctx.throw(403, 'domain must be owned by the user');
|
||||
}
|
||||
if (!AppDomainHelper.checkCanUpdateStatus(domainInfo.status!, status)) {
|
||||
if (!AppDomainHelper.checkCanUpdateStatus(domainInfo.status!, status as any)) {
|
||||
ctx.throw(400, 'domain status can not be updated');
|
||||
}
|
||||
const updateData: any = {};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { eq, desc, and, like, or } from 'drizzle-orm';
|
||||
import { app, db, schema } from '../../app.ts';
|
||||
import { CustomError } from '@kevisual/router';
|
||||
import { filter } from '@kevisual/js-filter'
|
||||
import { z } from 'zod';
|
||||
app
|
||||
@@ -77,7 +76,7 @@ app
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const id = ctx.query.id;
|
||||
if (!id) {
|
||||
throw new CustomError('id is required');
|
||||
ctx.throw(400, 'id is required');
|
||||
}
|
||||
const result = await db
|
||||
.select()
|
||||
|
||||
Reference in New Issue
Block a user