@nest-omni/core 4.1.3-5 → 4.1.3-7

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.
@@ -1 +1 @@
1
- export declare function AuthUser(): any;
1
+ export declare function AuthUser(): ParameterDecorator;
@@ -1 +1 @@
1
- export declare function Controller(field: string): any;
1
+ export declare function Controller(field: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -1 +1 @@
1
- export declare const OperationLog: (operation: string) => any;
1
+ export declare const OperationLog: (operation: string) => import("@nestjs/common").CustomDecorator<string>;
@@ -1 +1 @@
1
- export declare function TimestampColumn(name: string, description?: string): any;
1
+ export declare function TimestampColumn(name: string, description?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -2,5 +2,5 @@ export interface IUser {
2
2
  uid: number;
3
3
  username: string;
4
4
  }
5
- export declare const User: any;
5
+ export declare const User: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
6
6
  export declare function getUserData(req: any, data?: string): IUser | null;
@@ -6,7 +6,7 @@ export interface IUser {
6
6
  admin: boolean;
7
7
  role: string;
8
8
  }
9
- export declare const User: any;
9
+ export declare const User: (...dataOrPipes: (import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>> | keyof IUser)[]) => ParameterDecorator;
10
10
  export declare function getOmniAuthData<T extends keyof IUser>(request: {
11
11
  headers: Record<string, string>;
12
12
  }, key?: T): IUser[T] | IUser;
@@ -1 +1 @@
1
- export declare function UserFilter(field: string): any;
1
+ export declare function UserFilter(field: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -17,7 +17,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
- var _a, _b;
21
20
  Object.defineProperty(exports, "__esModule", { value: true });
22
21
  exports.HealthCheckerController = void 0;
23
22
  const ioredis_1 = require("ioredis");
@@ -63,5 +62,8 @@ __decorate([
63
62
  ], HealthCheckerController.prototype, "check", null);
64
63
  exports.HealthCheckerController = HealthCheckerController = __decorate([
65
64
  (0, common_1.Controller)('health'),
66
- __metadata("design:paramtypes", [services_1.ApiConfigService, typeof (_a = typeof terminus_1.HealthCheckService !== "undefined" && terminus_1.HealthCheckService) === "function" ? _a : Object, typeof (_b = typeof terminus_1.TypeOrmHealthIndicator !== "undefined" && terminus_1.TypeOrmHealthIndicator) === "function" ? _b : Object, nestjs_redis_health_1.RedisHealthIndicator])
65
+ __metadata("design:paramtypes", [services_1.ApiConfigService,
66
+ terminus_1.HealthCheckService,
67
+ terminus_1.TypeOrmHealthIndicator,
68
+ nestjs_redis_health_1.RedisHealthIndicator])
67
69
  ], HealthCheckerController);
@@ -3,4 +3,4 @@ import type { Observable } from 'rxjs';
3
3
  export declare class LanguageInterceptor implements NestInterceptor {
4
4
  intercept(context: ExecutionContext, next: CallHandler): Observable<undefined>;
5
5
  }
6
- export declare function UseLanguageInterceptor(): any;
6
+ export declare function UseLanguageInterceptor(): MethodDecorator & ClassDecorator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nest-omni/core",
3
- "version": "4.1.3-5",
3
+ "version": "4.1.3-7",
4
4
  "description": "A comprehensive NestJS framework for building enterprise-grade applications with best practices",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1 +1,2 @@
1
- export declare function bootstrapSetup(AppModule: any, SetupSwagger: any): Promise<NestExpressApplication>;
1
+ import type { NestExpressApplication } from '@nestjs/platform-express';
2
+ export declare function bootstrapSetup(AppModule: any, SetupSwagger: any): Promise<NestExpressApplication<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>>>;
@@ -9,7 +9,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  var ApiConfigService_1;
12
- var _a;
13
12
  Object.defineProperty(exports, "__esModule", { value: true });
14
13
  exports.ApiConfigService = void 0;
15
14
  const common_1 = require("@nestjs/common");
@@ -295,5 +294,5 @@ let ApiConfigService = ApiConfigService_1 = class ApiConfigService {
295
294
  exports.ApiConfigService = ApiConfigService;
296
295
  exports.ApiConfigService = ApiConfigService = ApiConfigService_1 = __decorate([
297
296
  (0, common_1.Injectable)(),
298
- __metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object])
297
+ __metadata("design:paramtypes", [config_1.ConfigService])
299
298
  ], ApiConfigService);
@@ -92,26 +92,25 @@ let IsUniqueValidator = class IsUniqueValidator {
92
92
  let exists;
93
93
  const defCon = findCondition(args);
94
94
  // 获取用于判断是否为新建的字段
95
- // 优先使用手动配置的 uniqueKeys,否则使用主键
95
+ // 优先级:手动配置的 uniqueKeys > 实体主键 > 查询条件的 keys
96
96
  let pkCols;
97
- if ((options === null || options === void 0 ? void 0 : options.uniqueKeys) && options.uniqueKeys.length > 0) {
98
- // 使用手动指定的字段
97
+ const hasUniqueKeys = (options === null || options === void 0 ? void 0 : options.uniqueKeys) && options.uniqueKeys.length > 0;
98
+ if (hasUniqueKeys) {
99
+ // 1. 使用手动指定的字段
99
100
  pkCols = options.uniqueKeys;
100
101
  }
101
102
  else {
102
- // 使用实体的主键
103
+ // 2. 使用实体的主键
103
104
  pkCols = repository.metadata
104
105
  .primaryColumns.map((column) => column.propertyName);
105
- // 如果没有主键(例如视图),抛出错误提示
106
- if (pkCols.length === 0) {
107
- throw new Error(`[IsUnique] Entity "${entityClass}" has no primary key. ` +
108
- `For views or entities without primary keys, please specify uniqueKeys option:\\n` +
109
- `Example: @IsUnique([Entity, condition, { uniqueKeys: ['id'] }])`);
106
+ // 3. 如果没有主键,从查询条件的 keys 中提取
107
+ if (pkCols.length === 0 && defCon && typeof defCon === 'object') {
108
+ pkCols = Object.keys(defCon);
110
109
  }
111
110
  }
112
111
  // 修复:检查是否为新建记录
113
- // 如果所有主键都没有值(null/undefined),则为新建
114
- const isNew = !pkCols.some((pk) => {
112
+ // 如果所有 uniqueKeys/主键都没有值(null/undefined),则为新建
113
+ const isNew = pkCols.length === 0 || !pkCols.some((pk) => {
115
114
  const pkValue = args.object[pk];
116
115
  return pkValue !== null && pkValue !== undefined && pkValue !== '';
117
116
  });
@@ -126,9 +125,8 @@ let IsUniqueValidator = class IsUniqueValidator {
126
125
  const entities = yield repository
127
126
  .createQueryBuilder()
128
127
  .where(defCon)
129
- .select(pkCols)
130
128
  .limit(2)
131
- .execute();
129
+ .getMany();
132
130
  const entityCount = entities.length;
133
131
  if (entityCount === 1) {
134
132
  // 只有一条记录,检查是否是当前记录本身
@@ -3,4 +3,4 @@
3
3
  * @param field
4
4
  * @constructor
5
5
  */
6
- export declare function SkipEmpty(field?: string): any;
6
+ export declare function SkipEmpty(field?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;