@certd/lib-server 1.40.5 → 1.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/basic/base-controller.d.ts +1 -0
  2. package/dist/basic/base-controller.js +1 -1
  3. package/dist/basic/base-service.d.ts +15 -1
  4. package/dist/basic/base-service.js +27 -2
  5. package/dist/basic/constants.d.ts +2 -0
  6. package/dist/basic/constants.js +2 -0
  7. package/dist/basic/crud-controller.d.ts +1 -0
  8. package/dist/basic/enum-item.d.ts +1 -0
  9. package/dist/basic/exception/auth-exception.d.ts +1 -0
  10. package/dist/basic/exception/base-exception.d.ts +1 -0
  11. package/dist/basic/exception/code-error-exception.d.ts +1 -0
  12. package/dist/basic/exception/common-exception.d.ts +1 -0
  13. package/dist/basic/exception/index.d.ts +1 -0
  14. package/dist/basic/exception/login-error-exception.d.ts +1 -0
  15. package/dist/basic/exception/not-found-exception.d.ts +1 -0
  16. package/dist/basic/exception/param-exception.d.ts +1 -0
  17. package/dist/basic/exception/permission-exception.d.ts +1 -0
  18. package/dist/basic/exception/preview-exception.d.ts +1 -0
  19. package/dist/basic/exception/site-off-exception.d.ts +1 -0
  20. package/dist/basic/exception/validation-exception.d.ts +1 -0
  21. package/dist/basic/exception/vip-exception.d.ts +1 -0
  22. package/dist/basic/index.d.ts +1 -0
  23. package/dist/basic/mode.d.ts +1 -0
  24. package/dist/basic/result.d.ts +1 -0
  25. package/dist/configuration.d.ts +1 -0
  26. package/dist/index.d.ts +1 -0
  27. package/dist/system/basic/index.d.ts +1 -0
  28. package/dist/system/basic/service/encryptor.d.ts +1 -0
  29. package/dist/system/basic/service/executor-queue.d.ts +1 -0
  30. package/dist/system/basic/service/file-service.d.ts +2 -1
  31. package/dist/system/basic/service/file-service.js +2 -2
  32. package/dist/system/basic/service/ocr-service.d.ts +1 -0
  33. package/dist/system/basic/service/plus-service.d.ts +1 -0
  34. package/dist/system/index.d.ts +1 -0
  35. package/dist/system/settings/entity/sys-settings.d.ts +1 -0
  36. package/dist/system/settings/index.d.ts +1 -0
  37. package/dist/system/settings/service/models.d.ts +1 -0
  38. package/dist/system/settings/service/sys-settings-service.d.ts +1 -0
  39. package/dist/user/access/entity/access.d.ts +2 -0
  40. package/dist/user/access/entity/access.js +5 -0
  41. package/dist/user/access/index.d.ts +1 -0
  42. package/dist/user/access/service/access-getter.d.ts +2 -1
  43. package/dist/user/access/service/access-service.d.ts +6 -3
  44. package/dist/user/access/service/access-service.js +31 -25
  45. package/dist/user/access/service/access-sys-getter.d.ts +1 -0
  46. package/dist/user/access/service/encrypt-service.d.ts +1 -0
  47. package/dist/user/addon/api/api.d.ts +1 -0
  48. package/dist/user/addon/api/decorator.d.ts +1 -0
  49. package/dist/user/addon/api/index.d.ts +1 -0
  50. package/dist/user/addon/api/registry.d.ts +1 -0
  51. package/dist/user/addon/entity/addon.d.ts +1 -0
  52. package/dist/user/addon/index.d.ts +1 -0
  53. package/dist/user/addon/service/addon-service.d.ts +1 -0
  54. package/dist/user/addon/service/addon-service.js +12 -16
  55. package/dist/user/index.d.ts +1 -0
  56. package/package.json +7 -7
@@ -52,3 +52,4 @@ export declare abstract class BaseController {
52
52
  userId: any;
53
53
  }>;
54
54
  }
55
+ //# sourceMappingURL=base-controller.d.ts.map
@@ -61,7 +61,7 @@ export class BaseController {
61
61
  }
62
62
  async getProjectId(permission) {
63
63
  if (!isEnterprise()) {
64
- return null;
64
+ return undefined;
65
65
  }
66
66
  let projectIdStr = this.ctx.headers["project-id"];
67
67
  if (!projectIdStr) {
@@ -1,4 +1,4 @@
1
- import { FindOneOptions, Repository, SelectQueryBuilder } from 'typeorm';
1
+ import { EntityTarget, FindOneOptions, Repository, SelectQueryBuilder } from 'typeorm';
2
2
  import { TypeORMDataSourceManager } from '@midwayjs/typeorm';
3
3
  import { EntityManager } from 'typeorm/entity-manager/EntityManager.js';
4
4
  import { FindManyOptions } from 'typeorm';
@@ -17,6 +17,9 @@ export type ListReq<T = any> = {
17
17
  buildQuery?: (bq: SelectQueryBuilder<any>) => void;
18
18
  select?: any;
19
19
  };
20
+ export type ServiceContext = {
21
+ manager?: EntityManager;
22
+ };
20
23
  /**
21
24
  * 服务基类
22
25
  */
@@ -24,6 +27,16 @@ export declare abstract class BaseService<T> {
24
27
  dataSourceManager: TypeORMDataSourceManager;
25
28
  abstract getRepository(): Repository<T>;
26
29
  transaction(callback: (entityManager: EntityManager) => Promise<any>): Promise<unknown>;
30
+ /**
31
+ * 如果 ctx 有 manager 则复用已有事务,否则开启新事务
32
+ */
33
+ protected transactionWithCtx<T>(ctx: ServiceContext, callback: (manager: EntityManager) => Promise<T>): Promise<T>;
34
+ protected getRepo<E>(ctx: ServiceContext, entity: EntityTarget<E>): Repository<E>;
35
+ protected buildUserProjectQuery(userId: number, projectId?: number): {
36
+ [key: string]: any;
37
+ userId: number;
38
+ projectId?: number;
39
+ };
27
40
  /**
28
41
  * 获得单个ID
29
42
  * @param id ID
@@ -89,3 +102,4 @@ export declare abstract class BaseService<T> {
89
102
  findOne(options: FindOneOptions<T>): Promise<T>;
90
103
  }
91
104
  export declare function checkUserProjectParam(userId: number, projectId: number): boolean;
105
+ //# sourceMappingURL=base-service.d.ts.map
@@ -21,6 +21,31 @@ export class BaseService {
21
21
  const dataSource = this.dataSourceManager.getDataSource('default');
22
22
  return await dataSource.transaction(callback);
23
23
  }
24
+ /**
25
+ * 如果 ctx 有 manager 则复用已有事务,否则开启新事务
26
+ */
27
+ async transactionWithCtx(ctx, callback) {
28
+ if (ctx.manager) {
29
+ return await callback(ctx.manager);
30
+ }
31
+ return (await this.transaction(callback));
32
+ }
33
+ getRepo(ctx, entity) {
34
+ if (ctx.manager) {
35
+ return ctx.manager.getRepository(entity);
36
+ }
37
+ const dataSource = this.dataSourceManager.getDataSource('default');
38
+ return dataSource.getRepository(entity);
39
+ }
40
+ buildUserProjectQuery(userId, projectId) {
41
+ const query = {
42
+ userId,
43
+ };
44
+ if (projectId != null) {
45
+ query.projectId = projectId;
46
+ }
47
+ return query;
48
+ }
24
49
  /**
25
50
  * 获得单个ID
26
51
  * @param id ID
@@ -224,12 +249,12 @@ export class BaseService {
224
249
  async batchDelete(ids, userId, projectId) {
225
250
  ids = this.filterIds(ids);
226
251
  if (userId != null) {
252
+ const userProjectQuery = this.buildUserProjectQuery(userId, projectId);
227
253
  const list = await this.getRepository().find({
228
254
  where: {
229
255
  // @ts-ignore
230
256
  id: In(ids),
231
- userId,
232
- projectId,
257
+ ...userProjectQuery,
233
258
  },
234
259
  });
235
260
  // @ts-ignore
@@ -6,6 +6,7 @@ export declare const Constants: {
6
6
  per: {
7
7
  guest: string;
8
8
  anonymous: string;
9
+ guestOptionalAuth: string;
9
10
  authOnly: string;
10
11
  loginOnly: string;
11
12
  open: string;
@@ -115,3 +116,4 @@ export declare const Constants: {
115
116
  systemUserId: number;
116
117
  enterpriseUserId: number;
117
118
  };
119
+ //# sourceMappingURL=constants.d.ts.map
@@ -8,6 +8,8 @@ export const Constants = {
8
8
  guest: '_guest_',
9
9
  //无需登录
10
10
  anonymous: '_guest_',
11
+ //无需登录,有 token 时解析当前用户
12
+ guestOptionalAuth: '_guestOptionalAuth_',
11
13
  //仅需要登录
12
14
  authOnly: '_authOnly_',
13
15
  //仅需要登录
@@ -37,3 +37,4 @@ export declare abstract class CrudController<T> extends BaseController {
37
37
  message: string;
38
38
  }>;
39
39
  }
40
+ //# sourceMappingURL=crud-controller.d.ts.map
@@ -4,3 +4,4 @@ export declare class EnumItem {
4
4
  color: string;
5
5
  constructor(value: any, label: any, color: any);
6
6
  }
7
+ //# sourceMappingURL=enum-item.d.ts.map
@@ -9,3 +9,4 @@ export declare class AuthException extends BaseException {
9
9
  export declare class Need2FAException extends TextException {
10
10
  constructor(message: string, data: any);
11
11
  }
12
+ //# sourceMappingURL=auth-exception.d.ts.map
@@ -6,3 +6,4 @@ export declare class BaseException extends Error {
6
6
  data?: any;
7
7
  constructor(name: string, code: number, message: string, data?: any);
8
8
  }
9
+ //# sourceMappingURL=base-exception.d.ts.map
@@ -5,3 +5,4 @@ import { BaseException } from './base-exception.js';
5
5
  export declare class CodeErrorException extends BaseException {
6
6
  constructor(message: any);
7
7
  }
8
+ //# sourceMappingURL=code-error-exception.d.ts.map
@@ -15,3 +15,4 @@ export declare class CodeException extends BaseException {
15
15
  export declare class TextException extends BaseException {
16
16
  constructor(name: any, code: any, message: any, data?: any);
17
17
  }
18
+ //# sourceMappingURL=common-exception.d.ts.map
@@ -10,3 +10,4 @@ export * from './param-exception.js';
10
10
  export * from './site-off-exception.js';
11
11
  export * from './login-error-exception.js';
12
12
  export * from './code-error-exception.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -6,3 +6,4 @@ export declare class LoginErrorException extends BaseException {
6
6
  leftCount: number;
7
7
  constructor(message: any, leftCount: number);
8
8
  }
9
+ //# sourceMappingURL=login-error-exception.d.ts.map
@@ -5,3 +5,4 @@ import { BaseException } from './base-exception.js';
5
5
  export declare class NotFoundException extends BaseException {
6
6
  constructor(message: any);
7
7
  }
8
+ //# sourceMappingURL=not-found-exception.d.ts.map
@@ -5,3 +5,4 @@ import { BaseException } from './base-exception.js';
5
5
  export declare class ParamException extends BaseException {
6
6
  constructor(message: any);
7
7
  }
8
+ //# sourceMappingURL=param-exception.d.ts.map
@@ -5,3 +5,4 @@ import { BaseException } from './base-exception.js';
5
5
  export declare class PermissionException extends BaseException {
6
6
  constructor(message?: string);
7
7
  }
8
+ //# sourceMappingURL=permission-exception.d.ts.map
@@ -5,3 +5,4 @@ import { BaseException } from './base-exception.js';
5
5
  export declare class PreviewException extends BaseException {
6
6
  constructor(message: any);
7
7
  }
8
+ //# sourceMappingURL=preview-exception.d.ts.map
@@ -4,3 +4,4 @@ import { BaseException } from './base-exception.js';
4
4
  export declare class SiteOffException extends BaseException {
5
5
  constructor(message: any);
6
6
  }
7
+ //# sourceMappingURL=site-off-exception.d.ts.map
@@ -5,3 +5,4 @@ import { BaseException } from './base-exception.js';
5
5
  export declare class ValidateException extends BaseException {
6
6
  constructor(message: any);
7
7
  }
8
+ //# sourceMappingURL=validation-exception.d.ts.map
@@ -8,3 +8,4 @@ export declare class NeedVIPException extends BaseException {
8
8
  export declare class NeedSuiteException extends BaseException {
9
9
  constructor(message: any);
10
10
  }
11
+ //# sourceMappingURL=vip-exception.d.ts.map
@@ -6,3 +6,4 @@ export * from './exception/index.js';
6
6
  export * from './result.js';
7
7
  export * from './base-service.js';
8
8
  export * from "./mode.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,4 @@
1
1
  export declare function setAdminMode(mode?: string): void;
2
2
  export declare function getAdminMode(): string;
3
3
  export declare function isEnterprise(): boolean;
4
+ //# sourceMappingURL=mode.d.ts.map
@@ -6,3 +6,4 @@ export declare class Result<T> {
6
6
  static error(code: number, message: any, data?: any): Result<unknown>;
7
7
  static success(message: any, data?: any): Result<unknown>;
8
8
  }
9
+ //# sourceMappingURL=result.d.ts.map
@@ -2,3 +2,4 @@ import type { IMidwayContainer } from '@midwayjs/core';
2
2
  export declare class LibServerConfiguration {
3
3
  onReady(container: IMidwayContainer): Promise<void>;
4
4
  }
5
+ //# sourceMappingURL=configuration.d.ts.map
package/dist/index.d.ts CHANGED
@@ -6,3 +6,4 @@ export * from './system/index.js';
6
6
  export * from './user/index.js';
7
7
  export { LibServerConfiguration as Configuration } from './configuration.js';
8
8
  export declare const libServerEntities: (typeof SysSettingsEntity | typeof AccessEntity | typeof AddonEntity)[];
9
+ //# sourceMappingURL=index.d.ts.map
@@ -3,3 +3,4 @@ export * from './service/file-service.js';
3
3
  export * from './service/encryptor.js';
4
4
  export * from './service/ocr-service.js';
5
5
  export * from './service/executor-queue.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -4,3 +4,4 @@ export declare class Encryptor {
4
4
  encrypt(text: string): string;
5
5
  decrypt(encryptedText: string): string;
6
6
  }
7
+ //# sourceMappingURL=encryptor.d.ts.map
@@ -21,3 +21,4 @@ export declare class ExecutorQueue {
21
21
  addTask(userId: number, task: TaskItem): void;
22
22
  }
23
23
  export declare const executorQueue: ExecutorQueue;
24
+ //# sourceMappingURL=executor-queue.d.ts.map
@@ -7,5 +7,6 @@ export declare const uploadTmpFileCacheKey = "tmpfile_key_";
7
7
  */
8
8
  export declare class FileService {
9
9
  saveFile(userId: number, tmpCacheKey: any, permission: 'public' | 'private'): Promise<any>;
10
- getFile(key: string, userId?: number): string;
10
+ getFile(key: string, userId?: number, allowAnyPrivateUser?: boolean): string;
11
11
  }
12
+ //# sourceMappingURL=file-service.d.ts.map
@@ -54,7 +54,7 @@ let FileService = class FileService {
54
54
  }
55
55
  return key;
56
56
  }
57
- getFile(key, userId) {
57
+ getFile(key, userId, allowAnyPrivateUser = false) {
58
58
  if (!key) {
59
59
  throw new ParamException('参数错误');
60
60
  }
@@ -68,7 +68,7 @@ let FileService = class FileService {
68
68
  const keyArr = key.split('/');
69
69
  const permission = keyArr[1];
70
70
  const userIdMd5 = keyArr[2];
71
- if (permission !== 'public') {
71
+ if (permission !== 'public' && !allowAnyPrivateUser) {
72
72
  //非公开文件需要验证用户
73
73
  const userIdStr = Buffer.from(Buffer.from(userIdMd5, 'hex').toString('base64')).toString();
74
74
  const userIdInt = parseInt(userIdStr, 10);
@@ -10,3 +10,4 @@ export declare class OcrService implements IOcrService {
10
10
  texts: string[];
11
11
  }>;
12
12
  }
13
+ //# sourceMappingURL=ocr-service.d.ts.map
@@ -20,3 +20,4 @@ export declare class PlusService {
20
20
  getTodayOrderCount(): Promise<any>;
21
21
  requestWithToken(config: HttpRequestConfig): Promise<any>;
22
22
  }
23
+ //# sourceMappingURL=plus-service.d.ts.map
@@ -1,2 +1,3 @@
1
1
  export * from './settings/index.js';
2
2
  export * from './basic/index.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -9,3 +9,4 @@ export declare class SysSettingsEntity {
9
9
  createTime: Date;
10
10
  updateTime: Date;
11
11
  }
12
+ //# sourceMappingURL=sys-settings.d.ts.map
@@ -1,3 +1,4 @@
1
1
  export * from './service/sys-settings-service.js';
2
2
  export * from './service/models.js';
3
3
  export * from './entity/sys-settings.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -200,3 +200,4 @@ export declare class SysSafeSetting extends BaseSettings {
200
200
  static __access__: string;
201
201
  hidden: SiteHidden;
202
202
  }
203
+ //# sourceMappingURL=models.d.ts.map
@@ -27,3 +27,4 @@ export declare class SysSettingsService extends BaseService<SysSettingsEntity> {
27
27
  backupSecret(): Promise<void>;
28
28
  getSecret(): Promise<SysSecret>;
29
29
  }
30
+ //# sourceMappingURL=sys-settings-service.d.ts.map
@@ -7,9 +7,11 @@ export declare class AccessEntity {
7
7
  userId: number;
8
8
  name: string;
9
9
  type: string;
10
+ subtype: string;
10
11
  setting: string;
11
12
  encryptSetting: string;
12
13
  projectId: number;
13
14
  createTime: Date;
14
15
  updateTime: Date;
15
16
  }
17
+ //# sourceMappingURL=access.d.ts.map
@@ -17,6 +17,7 @@ let AccessEntity = class AccessEntity {
17
17
  userId; // 0为系统级别, -1为企业,大于1为用户
18
18
  name;
19
19
  type;
20
+ subtype;
20
21
  setting;
21
22
  encryptSetting;
22
23
  projectId;
@@ -43,6 +44,10 @@ __decorate([
43
44
  Column({ comment: '类型', length: 100 }),
44
45
  __metadata("design:type", String)
45
46
  ], AccessEntity.prototype, "type", void 0);
47
+ __decorate([
48
+ Column({ name: 'subtype', comment: '子类型', length: 100, nullable: true }),
49
+ __metadata("design:type", String)
50
+ ], AccessEntity.prototype, "subtype", void 0);
46
51
  __decorate([
47
52
  Column({ name: 'setting', comment: '设置', length: 10240, nullable: true }),
48
53
  __metadata("design:type", String)
@@ -3,3 +3,4 @@ export * from './service/access-service.js';
3
3
  export * from './service/access-sys-getter.js';
4
4
  export * from './service/access-getter.js';
5
5
  export * from './service/encrypt-service.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import { IAccessService } from '@certd/pipeline';
1
+ import { IAccessService } from "@certd/pipeline";
2
2
  export declare class AccessGetter implements IAccessService {
3
3
  userId: number;
4
4
  projectId?: number;
@@ -7,3 +7,4 @@ export declare class AccessGetter implements IAccessService {
7
7
  getById<T = any>(id: any): Promise<T>;
8
8
  getCommonById<T = any>(id: any): Promise<T>;
9
9
  }
10
+ //# sourceMappingURL=access-getter.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { Repository } from "typeorm";
2
- import { BaseService, PageReq } from '../../../index.js';
3
- import { AccessEntity } from '../entity/access.js';
4
- import { EncryptService } from './encrypt-service.js';
2
+ import { BaseService, PageReq } from "../../../index.js";
3
+ import { AccessEntity } from "../entity/access.js";
4
+ import { EncryptService } from "./encrypt-service.js";
5
5
  /**
6
6
  * 授权
7
7
  */
@@ -28,6 +28,8 @@ export declare class AccessService extends BaseService<AccessEntity> {
28
28
  getSimpleInfo(id: number): Promise<{
29
29
  id: number;
30
30
  name: string;
31
+ type: string;
32
+ subtype: string;
31
33
  userId: number;
32
34
  projectId: number;
33
35
  }>;
@@ -52,3 +54,4 @@ export declare class AccessService extends BaseService<AccessEntity> {
52
54
  */
53
55
  copyTo(accessId: number, projectId?: number): Promise<any>;
54
56
  }
57
+ //# sourceMappingURL=access-service.d.ts.map
@@ -7,14 +7,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
11
- import { InjectEntityModel } from '@midwayjs/typeorm';
10
+ import { Inject, Provide, Scope, ScopeEnum } from "@midwayjs/core";
11
+ import { InjectEntityModel } from "@midwayjs/typeorm";
12
12
  import { In, Repository } from "typeorm";
13
- import { AccessGetter, BaseService, PermissionException, ValidateException } from '../../../index.js';
14
- import { AccessEntity } from '../entity/access.js';
15
- import { accessRegistry, newAccess } from '@certd/pipeline';
16
- import { EncryptService } from './encrypt-service.js';
17
- import { logger, utils } from '@certd/basic';
13
+ import { AccessGetter, BaseService, PermissionException, ValidateException } from "../../../index.js";
14
+ import { AccessEntity } from "../entity/access.js";
15
+ import { accessRegistry, newAccess } from "@certd/pipeline";
16
+ import { EncryptService } from "./encrypt-service.js";
17
+ import { logger, utils } from "@certd/basic";
18
18
  /**
19
19
  * 授权
20
20
  */
@@ -39,10 +39,10 @@ let AccessService = class AccessService extends BaseService {
39
39
  if (param._copyFrom) {
40
40
  oldEntity = await this.info(param._copyFrom);
41
41
  if (oldEntity == null) {
42
- throw new ValidateException('该授权配置不存在,请确认是否已被删除');
42
+ throw new ValidateException("该授权配置不存在,请确认是否已被删除");
43
43
  }
44
44
  if (oldEntity.userId !== param.userId) {
45
- throw new ValidateException('您无权查看该授权配置');
45
+ throw new ValidateException("您无权查看该授权配置");
46
46
  }
47
47
  }
48
48
  delete param._copyFrom;
@@ -61,17 +61,20 @@ let AccessService = class AccessService extends BaseService {
61
61
  return;
62
62
  }
63
63
  const json = JSON.parse(setting);
64
+ if (accessDefine.subtype) {
65
+ param.subtype = json[accessDefine.subtype] || null;
66
+ }
64
67
  let oldSetting = {};
65
68
  let encryptSetting = {};
66
- const firstEncrypt = !oldSettingEntity || !oldSettingEntity.encryptSetting || oldSettingEntity.encryptSetting === '{}';
69
+ const firstEncrypt = !oldSettingEntity || !oldSettingEntity.encryptSetting || oldSettingEntity.encryptSetting === "{}";
67
70
  if (oldSettingEntity) {
68
- oldSetting = JSON.parse(oldSettingEntity.setting || '{}');
69
- encryptSetting = JSON.parse(oldSettingEntity.encryptSetting || '{}');
71
+ oldSetting = JSON.parse(oldSettingEntity.setting || "{}");
72
+ encryptSetting = JSON.parse(oldSettingEntity.encryptSetting || "{}");
70
73
  }
71
74
  for (const key in json) {
72
75
  //加密
73
76
  let value = json[key];
74
- if (value && typeof value === 'string') {
77
+ if (value && typeof value === "string") {
75
78
  //去除前后空格
76
79
  value = value.trim();
77
80
  json[key] = value;
@@ -80,7 +83,7 @@ let AccessService = class AccessService extends BaseService {
80
83
  if (!accessInputDefine) {
81
84
  continue;
82
85
  }
83
- if (!accessInputDefine.encrypt || !value || typeof value !== 'string') {
86
+ if (!accessInputDefine.encrypt || !value || typeof value !== "string") {
84
87
  //定义无需加密、value为空、不是字符串 这些不需要加密
85
88
  encryptSetting[key] = {
86
89
  value: value,
@@ -94,7 +97,7 @@ let AccessService = class AccessService extends BaseService {
94
97
  const subIndex = Math.min(2, length);
95
98
  let starLength = length - subIndex * 2;
96
99
  starLength = Math.max(2, starLength);
97
- const starString = '*'.repeat(starLength);
100
+ const starString = "*".repeat(starLength);
98
101
  json[key] = value.substring(0, subIndex) + starString + value.substring(value.length - subIndex);
99
102
  encryptSetting[key] = {
100
103
  value: this.encryptService.encrypt(value),
@@ -113,7 +116,7 @@ let AccessService = class AccessService extends BaseService {
113
116
  async update(param) {
114
117
  const oldEntity = await this.info(param.id);
115
118
  if (oldEntity == null) {
116
- throw new ValidateException('该授权配置不存在,请确认是否已被删除');
119
+ throw new ValidateException("该授权配置不存在,请确认是否已被删除");
117
120
  }
118
121
  this.encryptSetting(param, oldEntity);
119
122
  delete param.keyId;
@@ -122,11 +125,11 @@ let AccessService = class AccessService extends BaseService {
122
125
  async updateAccess(access) {
123
126
  const oldEntity = await this.info(access.id);
124
127
  if (oldEntity == null) {
125
- throw new ValidateException('该授权配置不存在,请确认是否已被删除');
128
+ throw new ValidateException("该授权配置不存在,请确认是否已被删除");
126
129
  }
127
130
  const setting = this.decryptAccessEntity(oldEntity);
128
131
  for (const key of Object.keys(access)) {
129
- if (key === 'id') {
132
+ if (key === "id") {
130
133
  continue;
131
134
  }
132
135
  setting[key] = access[key];
@@ -140,11 +143,13 @@ let AccessService = class AccessService extends BaseService {
140
143
  async getSimpleInfo(id) {
141
144
  const entity = await this.info(id);
142
145
  if (entity == null) {
143
- throw new ValidateException('该授权配置不存在,请确认是否已被删除');
146
+ throw new ValidateException("该授权配置不存在,请确认是否已被删除");
144
147
  }
145
148
  return {
146
149
  id: entity.id,
147
150
  name: entity.name,
151
+ type: entity.type,
152
+ subtype: entity.subtype,
148
153
  userId: entity.userId,
149
154
  projectId: entity.projectId,
150
155
  };
@@ -156,14 +161,14 @@ let AccessService = class AccessService extends BaseService {
156
161
  }
157
162
  if (checkUserId) {
158
163
  if (userId == null) {
159
- throw new ValidateException('userId不能为空');
164
+ throw new ValidateException("userId不能为空");
160
165
  }
161
166
  if (userId !== entity.userId) {
162
- throw new PermissionException('您对该Access授权无访问权限');
167
+ throw new PermissionException("您对该Access授权无访问权限");
163
168
  }
164
169
  }
165
170
  if (projectId != null && projectId !== entity.projectId) {
166
- throw new PermissionException('您对该Access授权无访问权限');
171
+ throw new PermissionException("您对该Access授权无访问权限");
167
172
  }
168
173
  // const access = accessRegistry.get(entity.type);
169
174
  const setting = this.decryptAccessEntity(entity);
@@ -179,7 +184,7 @@ let AccessService = class AccessService extends BaseService {
179
184
  }
180
185
  decryptAccessEntity(entity) {
181
186
  let setting = {};
182
- if (entity.encryptSetting && entity.encryptSetting !== '{}') {
187
+ if (entity.encryptSetting && entity.encryptSetting !== "{}") {
183
188
  setting = JSON.parse(entity.encryptSetting);
184
189
  for (const key in setting) {
185
190
  //解密
@@ -209,16 +214,17 @@ let AccessService = class AccessService extends BaseService {
209
214
  if (userId == null) {
210
215
  return [];
211
216
  }
217
+ const userProjectQuery = this.buildUserProjectQuery(userId, projectId);
212
218
  return await this.repository.find({
213
219
  where: {
214
220
  id: In(ids),
215
- userId,
216
- projectId,
221
+ ...userProjectQuery,
217
222
  },
218
223
  select: {
219
224
  id: true,
220
225
  name: true,
221
226
  type: true,
227
+ subtype: true,
222
228
  userId: true,
223
229
  projectId: true,
224
230
  },
@@ -6,3 +6,4 @@ export declare class AccessSysGetter implements IAccessService {
6
6
  getById<T = any>(id: any): Promise<any>;
7
7
  getCommonById<T = any>(id: any): Promise<any>;
8
8
  }
9
+ //# sourceMappingURL=access-sys-getter.d.ts.map
@@ -9,3 +9,4 @@ export declare class EncryptService {
9
9
  encrypt(text: string): string;
10
10
  decrypt(encryptedText: string): string;
11
11
  }
12
+ //# sourceMappingURL=encrypt-service.d.ts.map
@@ -57,3 +57,4 @@ export interface IAddonGetter {
57
57
  getById<T = any>(id: any): Promise<T>;
58
58
  getCommonById<T = any>(id: any): Promise<T>;
59
59
  }
60
+ //# sourceMappingURL=api.d.ts.map
@@ -4,3 +4,4 @@ export declare const ADDON_INPUT_KEY = "pipeline:addon:input";
4
4
  export declare function IsAddon(define: AddonDefine): ClassDecorator;
5
5
  export declare function AddonInput(input?: AddonInputDefine): PropertyDecorator;
6
6
  export declare function newAddon(addonType: string, type: string, input: any, ctx: AddonContext): Promise<any>;
7
+ //# sourceMappingURL=decorator.d.ts.map
@@ -1,3 +1,4 @@
1
1
  export * from "./api.js";
2
2
  export * from "./registry.js";
3
3
  export * from "./decorator.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +1,2 @@
1
1
  export declare const addonRegistry: import("@certd/pipeline").Registry<unknown>;
2
+ //# sourceMappingURL=registry.d.ts.map
@@ -14,3 +14,4 @@ export declare class AddonEntity {
14
14
  createTime: Date;
15
15
  updateTime: Date;
16
16
  }
17
+ //# sourceMappingURL=addon.d.ts.map
@@ -1,3 +1,4 @@
1
1
  export * from './api/index.js';
2
2
  export * from './entity/addon.js';
3
3
  export * from './service/addon-service.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -58,3 +58,4 @@ export declare class AddonService extends BaseService<AddonEntity> {
58
58
  projectId?: number;
59
59
  }): Promise<AddonEntity>;
60
60
  }
61
+ //# sourceMappingURL=addon-service.d.ts.map
@@ -91,11 +91,11 @@ let AddonService = class AddonService extends BaseService {
91
91
  if (userId == null) {
92
92
  return [];
93
93
  }
94
+ const userProjectQuery = this.buildUserProjectQuery(userId, projectId);
94
95
  return await this.repository.find({
95
96
  where: {
96
97
  id: In(ids),
97
- userId,
98
- projectId
98
+ ...userProjectQuery,
99
99
  },
100
100
  select: {
101
101
  id: true,
@@ -109,11 +109,11 @@ let AddonService = class AddonService extends BaseService {
109
109
  });
110
110
  }
111
111
  async getDefault(userId, addonType, projectId) {
112
+ const userProjectQuery = this.buildUserProjectQuery(userId, projectId);
112
113
  const res = await this.repository.findOne({
113
114
  where: {
114
- userId,
115
115
  addonType,
116
- projectId
116
+ ...userProjectQuery,
117
117
  },
118
118
  order: {
119
119
  isDefault: "DESC"
@@ -144,19 +144,15 @@ let AddonService = class AddonService extends BaseService {
144
144
  if (userId == null) {
145
145
  throw new ValidateException("userId不能为空");
146
146
  }
147
- await this.repository.update({
148
- userId,
147
+ const userProjectQuery = this.buildUserProjectQuery(userId, projectId);
148
+ const query = {
149
149
  addonType,
150
- projectId
151
- }, {
150
+ ...userProjectQuery,
151
+ };
152
+ await this.repository.update(query, {
152
153
  isDefault: false
153
154
  });
154
- await this.repository.update({
155
- id,
156
- userId,
157
- addonType,
158
- projectId
159
- }, {
155
+ await this.repository.update({ ...query, id }, {
160
156
  isDefault: true
161
157
  });
162
158
  }
@@ -182,12 +178,12 @@ let AddonService = class AddonService extends BaseService {
182
178
  return this.buildAddonInstanceConfig(res);
183
179
  }
184
180
  async getOneByType(req) {
181
+ const userProjectQuery = this.buildUserProjectQuery(req.userId, req.projectId);
185
182
  return await this.repository.findOne({
186
183
  where: {
187
184
  addonType: req.addonType,
188
185
  type: req.type,
189
- userId: req.userId,
190
- projectId: req.projectId
186
+ ...userProjectQuery,
191
187
  }
192
188
  });
193
189
  }
@@ -1,2 +1,3 @@
1
1
  export * from './access/index.js';
2
2
  export * from './addon/index.js';
3
+ //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certd/lib-server",
3
- "version": "1.40.5",
3
+ "version": "1.41.0",
4
4
  "description": "midway with flyway, sql upgrade way ",
5
5
  "private": false,
6
6
  "type": "module",
@@ -29,11 +29,11 @@
29
29
  ],
30
30
  "license": "AGPL",
31
31
  "dependencies": {
32
- "@certd/acme-client": "^1.40.5",
33
- "@certd/basic": "^1.40.5",
34
- "@certd/pipeline": "^1.40.5",
35
- "@certd/plugin-lib": "^1.40.5",
36
- "@certd/plus-core": "^1.40.5",
32
+ "@certd/acme-client": "^1.41.0",
33
+ "@certd/basic": "^1.41.0",
34
+ "@certd/pipeline": "^1.41.0",
35
+ "@certd/plugin-lib": "^1.41.0",
36
+ "@certd/plus-core": "^1.41.0",
37
37
  "@midwayjs/cache": "3.14.0",
38
38
  "@midwayjs/core": "3.20.11",
39
39
  "@midwayjs/i18n": "3.20.13",
@@ -69,5 +69,5 @@
69
69
  "typeorm": "^0.3.11",
70
70
  "typescript": "^5.4.2"
71
71
  },
72
- "gitHead": "7ceb0f6306b8b5e9ab875b9f7c41cc7d56209ea4"
72
+ "gitHead": "d368f9666abf71d7f56891b6cbedeb618b82701c"
73
73
  }