@nest-omni/core 4.1.3-5 → 4.1.3-6
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.
- package/decorators/auth-user.decorator.d.ts +1 -1
- package/decorators/controller.decorator.d.ts +1 -1
- package/decorators/operation.decorator.d.ts +1 -1
- package/decorators/timestamp-column.decorator.d.ts +1 -1
- package/decorators/user-check.decorator.d.ts +1 -1
- package/decorators/user.decorator.d.ts +1 -1
- package/decorators/user_auth.decorator.d.ts +1 -1
- package/health-checker/health-checker.controller.js +4 -2
- package/interceptors/language-interceptor.service.d.ts +1 -1
- package/package.json +1 -1
- package/setup/bootstrap.setup.d.ts +2 -1
- package/shared/services/api-config.service.js +1 -2
- package/validators/is-unique.validator.js +12 -10
- package/validators/skip-empty.validator.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function AuthUser():
|
|
1
|
+
export declare function AuthUser(): ParameterDecorator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function Controller(field: string):
|
|
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) =>
|
|
1
|
+
export declare const OperationLog: (operation: string) => import("@nestjs/common").CustomDecorator<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function TimestampColumn(name: string, description?: string):
|
|
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):
|
|
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,
|
|
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():
|
|
6
|
+
export declare function UseLanguageInterceptor(): MethodDecorator & ClassDecorator;
|
package/package.json
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
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", [
|
|
297
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
299
298
|
], ApiConfigService);
|
|
@@ -94,7 +94,8 @@ let IsUniqueValidator = class IsUniqueValidator {
|
|
|
94
94
|
// 获取用于判断是否为新建的字段
|
|
95
95
|
// 优先使用手动配置的 uniqueKeys,否则使用主键
|
|
96
96
|
let pkCols;
|
|
97
|
-
|
|
97
|
+
const hasUniqueKeys = (options === null || options === void 0 ? void 0 : options.uniqueKeys) && options.uniqueKeys.length > 0;
|
|
98
|
+
if (hasUniqueKeys) {
|
|
98
99
|
// 使用手动指定的字段
|
|
99
100
|
pkCols = options.uniqueKeys;
|
|
100
101
|
}
|
|
@@ -102,15 +103,17 @@ let IsUniqueValidator = class IsUniqueValidator {
|
|
|
102
103
|
// 使用实体的主键
|
|
103
104
|
pkCols = repository.metadata
|
|
104
105
|
.primaryColumns.map((column) => column.propertyName);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
}
|
|
107
|
+
// 如果没有主键也没有 uniqueKeys,使用简化逻辑
|
|
108
|
+
// 查询条件本身就能表示唯一性:0-1条允许,2条及以上不允许
|
|
109
|
+
if (pkCols.length === 0) {
|
|
110
|
+
const count = yield repository.count({ where: defCon });
|
|
111
|
+
// 0条(不存在)或1条(认为是自己)都允许,2条及以上不允许
|
|
112
|
+
exists = count <= 1;
|
|
113
|
+
return exists;
|
|
111
114
|
}
|
|
112
115
|
// 修复:检查是否为新建记录
|
|
113
|
-
//
|
|
116
|
+
// 如果所有 uniqueKeys/主键都没有值(null/undefined),则为新建
|
|
114
117
|
const isNew = !pkCols.some((pk) => {
|
|
115
118
|
const pkValue = args.object[pk];
|
|
116
119
|
return pkValue !== null && pkValue !== undefined && pkValue !== '';
|
|
@@ -126,9 +129,8 @@ let IsUniqueValidator = class IsUniqueValidator {
|
|
|
126
129
|
const entities = yield repository
|
|
127
130
|
.createQueryBuilder()
|
|
128
131
|
.where(defCon)
|
|
129
|
-
.select(pkCols)
|
|
130
132
|
.limit(2)
|
|
131
|
-
.
|
|
133
|
+
.getMany();
|
|
132
134
|
const entityCount = entities.length;
|
|
133
135
|
if (entityCount === 1) {
|
|
134
136
|
// 只有一条记录,检查是否是当前记录本身
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @param field
|
|
4
4
|
* @constructor
|
|
5
5
|
*/
|
|
6
|
-
export declare function SkipEmpty(field?: string):
|
|
6
|
+
export declare function SkipEmpty(field?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|