@nest-omni/core 1.0.7 → 1.0.8
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/package.json +4 -1
- package/src/boilerplate.polyfill.d.ts +0 -39
- package/src/boilerplate.polyfill.js +0 -78
- package/src/boilerplate.polyfill.ts +0 -202
- package/src/common/abstract-client.service.d.ts +0 -20
- package/src/common/abstract-client.service.js +0 -39
- package/src/common/abstract-client.service.ts +0 -56
- package/src/common/abstract.entity.d.ts +0 -24
- package/src/common/abstract.entity.js +0 -152
- package/src/common/abstract.entity.ts +0 -73
- package/src/common/dto/abstract.dto.d.ts +0 -13
- package/src/common/dto/abstract.dto.js +0 -96
- package/src/common/dto/abstract.dto.ts +0 -64
- package/src/common/dto/bulk-id.dto.d.ts +0 -3
- package/src/common/dto/bulk-id.dto.js +0 -63
- package/src/common/dto/bulk-id.dto.ts +0 -13
- package/src/common/dto/create-translation.dto.d.ts +0 -5
- package/src/common/dto/create-translation.dto.js +0 -63
- package/src/common/dto/create-translation.dto.ts +0 -10
- package/src/common/dto/page-meta.dto.d.ts +0 -15
- package/src/common/dto/page-meta.dto.js +0 -88
- package/src/common/dto/page-meta.dto.ts +0 -37
- package/src/common/dto/page-options.dto.d.ts +0 -8
- package/src/common/dto/page-options.dto.js +0 -87
- package/src/common/dto/page-options.dto.ts +0 -35
- package/src/common/dto/page.dto.d.ts +0 -11
- package/src/common/dto/page.dto.js +0 -94
- package/src/common/dto/page.dto.ts +0 -36
- package/src/common/utils.d.ts +0 -14
- package/src/common/utils.js +0 -39
- package/src/common/utils.ts +0 -45
- package/src/constants/index.d.ts +0 -4
- package/src/constants/index.js +0 -20
- package/src/constants/index.ts +0 -4
- package/src/constants/language-code.d.ts +0 -5
- package/src/constants/language-code.js +0 -10
- package/src/constants/language-code.ts +0 -7
- package/src/constants/order.d.ts +0 -4
- package/src/constants/order.js +0 -8
- package/src/constants/order.ts +0 -4
- package/src/constants/role-type.d.ts +0 -4
- package/src/constants/role-type.js +0 -8
- package/src/constants/role-type.ts +0 -4
- package/src/constants/token-type.d.ts +0 -4
- package/src/constants/token-type.js +0 -8
- package/src/constants/token-type.ts +0 -4
- package/src/decorators/api-page-ok-response.decorator.d.ts +0 -5
- package/src/decorators/api-page-ok-response.decorator.js +0 -25
- package/src/decorators/api-page-ok-response.decorator.ts +0 -31
- package/src/decorators/auth-user.decorator.d.ts +0 -1
- package/src/decorators/auth-user.decorator.js +0 -15
- package/src/decorators/auth-user.decorator.ts +0 -16
- package/src/decorators/controller.decorator.d.ts +0 -1
- package/src/decorators/controller.decorator.js +0 -34
- package/src/decorators/controller.decorator.ts +0 -8
- package/src/decorators/field.decorators.d.ts +0 -71
- package/src/decorators/field.decorators.js +0 -455
- package/src/decorators/field.decorators.ts +0 -773
- package/src/decorators/http.decorators.d.ts +0 -3
- package/src/decorators/http.decorators.js +0 -8
- package/src/decorators/http.decorators.ts +0 -10
- package/src/decorators/index.d.ts +0 -12
- package/src/decorators/index.js +0 -28
- package/src/decorators/index.ts +0 -12
- package/src/decorators/omni-auth.decorator.d.ts +0 -8
- package/src/decorators/omni-auth.decorator.js +0 -60
- package/src/decorators/omni-auth.decorator.ts +0 -46
- package/src/decorators/operation.decorator.d.ts +0 -1
- package/src/decorators/operation.decorator.js +0 -6
- package/src/decorators/operation.decorator.ts +0 -4
- package/src/decorators/property.decorators.d.ts +0 -15
- package/src/decorators/property.decorators.js +0 -36
- package/src/decorators/property.decorators.ts +0 -62
- package/src/decorators/public-route.decorator.d.ts +0 -3
- package/src/decorators/public-route.decorator.js +0 -8
- package/src/decorators/public-route.decorator.ts +0 -8
- package/src/decorators/swagger.schema.d.ts +0 -5
- package/src/decorators/swagger.schema.js +0 -82
- package/src/decorators/swagger.schema.ts +0 -117
- package/src/decorators/timestamp-column.decorator.d.ts +0 -1
- package/src/decorators/timestamp-column.decorator.js +0 -28
- package/src/decorators/timestamp-column.decorator.ts +0 -29
- package/src/decorators/transform.decorators.d.ts +0 -35
- package/src/decorators/transform.decorators.js +0 -122
- package/src/decorators/transform.decorators.ts +0 -147
- package/src/decorators/translate.decorator.d.ts +0 -5
- package/src/decorators/translate.decorator.js +0 -18
- package/src/decorators/translate.decorator.ts +0 -19
- package/src/decorators/use-dto.decorator.d.ts +0 -4
- package/src/decorators/use-dto.decorator.js +0 -9
- package/src/decorators/use-dto.decorator.ts +0 -11
- package/src/decorators/user-check.decorator.d.ts +0 -6
- package/src/decorators/user-check.decorator.js +0 -44
- package/src/decorators/user-check.decorator.ts +0 -30
- package/src/decorators/user.decorator.d.ts +0 -8
- package/src/decorators/user.decorator.js +0 -62
- package/src/decorators/user.decorator.ts +0 -48
- package/src/decorators/user_auth.decorator.d.ts +0 -1
- package/src/decorators/user_auth.decorator.js +0 -16
- package/src/decorators/user_auth.decorator.ts +0 -15
- package/src/decorators/validator.decorators.d.ts +0 -10
- package/src/decorators/validator.decorators.js +0 -59
- package/src/decorators/validator.decorators.ts +0 -78
- package/src/exceptions/file-not-image.exception.d.ts +0 -4
- package/src/exceptions/file-not-image.exception.js +0 -10
- package/src/exceptions/file-not-image.exception.ts +0 -7
- package/src/exceptions/index.d.ts +0 -2
- package/src/exceptions/index.js +0 -18
- package/src/exceptions/index.ts +0 -2
- package/src/exceptions/page-type.exception.d.ts +0 -4
- package/src/exceptions/page-type.exception.js +0 -10
- package/src/exceptions/page-type.exception.ts +0 -7
- package/src/exceptions/user-not-found.exception.d.ts +0 -4
- package/src/exceptions/user-not-found.exception.js +0 -10
- package/src/exceptions/user-not-found.exception.ts +0 -7
- package/src/filters/bad-request.filter.d.ts +0 -5
- package/src/filters/bad-request.filter.js +0 -104
- package/src/filters/bad-request.filter.ts +0 -67
- package/src/filters/constraint-errors.d.ts +0 -1
- package/src/filters/constraint-errors.js +0 -7
- package/src/filters/constraint-errors.ts +0 -5
- package/src/filters/index.d.ts +0 -3
- package/src/filters/index.js +0 -19
- package/src/filters/index.ts +0 -3
- package/src/filters/query-failed.filter.d.ts +0 -10
- package/src/filters/query-failed.filter.js +0 -81
- package/src/filters/query-failed.filter.ts +0 -32
- package/src/health-checker/health-checker.controller.d.ts +0 -15
- package/src/health-checker/health-checker.controller.js +0 -104
- package/src/health-checker/health-checker.controller.ts +0 -51
- package/src/health-checker/health-checker.module.d.ts +0 -2
- package/src/health-checker/health-checker.module.js +0 -69
- package/src/health-checker/health-checker.module.ts +0 -13
- package/src/health-checker/health-indicators/service.indicator.d.ts +0 -8
- package/src/health-checker/health-indicators/service.indicator.js +0 -102
- package/src/health-checker/health-indicators/service.indicator.ts +0 -44
- package/src/helpers/common.helper.d.ts +0 -16
- package/src/helpers/common.helper.js +0 -49
- package/src/helpers/common.helper.ts +0 -49
- package/src/helpers/date.helper.d.ts +0 -10
- package/src/helpers/date.helper.js +0 -81
- package/src/helpers/date.helper.ts +0 -64
- package/src/helpers/excel.helper.d.ts +0 -27
- package/src/helpers/excel.helper.js +0 -338
- package/src/helpers/index.d.ts +0 -3
- package/src/helpers/index.js +0 -19
- package/src/helpers/index.ts +0 -3
- package/src/i18n/en_US/validation.json +0 -38
- package/src/i18n/zh_CN/validation.json +0 -38
- package/src/index.d.ts +0 -11
- package/src/index.js +0 -28
- package/src/index.ts +0 -12
- package/src/interceptors/auth-user.interceptor.d.ts +0 -4
- package/src/interceptors/auth-user.interceptor.js +0 -68
- package/src/interceptors/auth-user.interceptor.ts +0 -20
- package/src/interceptors/index.d.ts +0 -2
- package/src/interceptors/index.js +0 -18
- package/src/interceptors/index.ts +0 -2
- package/src/interceptors/language-interceptor.service.d.ts +0 -6
- package/src/interceptors/language-interceptor.service.js +0 -74
- package/src/interceptors/language-interceptor.service.ts +0 -31
- package/src/interceptors/translation-interceptor.service.d.ts +0 -5
- package/src/interceptors/translation-interceptor.service.js +0 -83
- package/src/interceptors/translation-interceptor.service.ts +0 -43
- package/src/interfaces/IApiFile.d.ts +0 -4
- package/src/interfaces/IApiFile.js +0 -2
- package/src/interfaces/IApiFile.ts +0 -4
- package/src/interfaces/IFile.d.ts +0 -9
- package/src/interfaces/IFile.js +0 -2
- package/src/interfaces/IFile.ts +0 -8
- package/src/interfaces/ITranslationDecoratorInterface.d.ts +0 -3
- package/src/interfaces/ITranslationDecoratorInterface.js +0 -2
- package/src/interfaces/ITranslationDecoratorInterface.ts +0 -3
- package/src/interfaces/index.d.ts +0 -3
- package/src/interfaces/index.js +0 -19
- package/src/interfaces/index.ts +0 -3
- package/src/interfaces/response.d.ts +0 -25
- package/src/interfaces/response.js +0 -2
- package/src/interfaces/response.ts +0 -37
- package/src/middlewares/index.d.ts +0 -3
- package/src/middlewares/index.js +0 -19
- package/src/middlewares/index.ts +0 -3
- package/src/middlewares/omni-auth.middleware.d.ts +0 -1
- package/src/middlewares/omni-auth.middleware.js +0 -13
- package/src/middlewares/omni-auth.middleware.ts +0 -10
- package/src/middlewares/powerby.middleware.d.ts +0 -1
- package/src/middlewares/powerby.middleware.js +0 -10
- package/src/middlewares/powerby.middleware.ts +0 -6
- package/src/middlewares/request-id.middleware.d.ts +0 -7
- package/src/middlewares/request-id.middleware.js +0 -22
- package/src/middlewares/request-id.middleware.ts +0 -28
- package/src/providers/context.provider.d.ts +0 -32
- package/src/providers/context.provider.js +0 -73
- package/src/providers/context.provider.ts +0 -98
- package/src/providers/generator.provider.d.ts +0 -13
- package/src/providers/generator.provider.js +0 -54
- package/src/providers/generator.provider.ts +0 -66
- package/src/providers/index.d.ts +0 -2
- package/src/providers/index.js +0 -18
- package/src/providers/index.ts +0 -2
- package/src/setup/bootstrap.setup.d.ts +0 -5
- package/src/setup/bootstrap.setup.js +0 -138
- package/src/setup/bootstrap.setup.ts +0 -139
- package/src/setup/index.d.ts +0 -1
- package/src/setup/index.js +0 -17
- package/src/setup/index.ts +0 -1
- package/src/setup/microservices.setup.js +0 -55
- package/src/setup-swagger.d.ts +0 -2
- package/src/setup-swagger.js +0 -62
- package/src/setup-swagger.ts +0 -67
- package/src/shared/index.d.ts +0 -2
- package/src/shared/index.js +0 -18
- package/src/shared/index.ts +0 -2
- package/src/shared/serviceRegistryModule.d.ts +0 -2
- package/src/shared/serviceRegistryModule.js +0 -176
- package/src/shared/serviceRegistryModule.ts +0 -110
- package/src/shared/services/api-config.service.d.ts +0 -73
- package/src/shared/services/api-config.service.js +0 -335
- package/src/shared/services/api-config.service.ts +0 -319
- package/src/shared/services/aws-s3.service.d.ts +0 -10
- package/src/shared/services/aws-s3.service.js +0 -96
- package/src/shared/services/aws-s3.service.ts +0 -39
- package/src/shared/services/generator.service.d.ts +0 -4
- package/src/shared/services/generator.service.js +0 -67
- package/src/shared/services/generator.service.ts +0 -13
- package/src/shared/services/index.d.ts +0 -5
- package/src/shared/services/index.js +0 -21
- package/src/shared/services/index.ts +0 -5
- package/src/shared/services/translation.service.d.ts +0 -9
- package/src/shared/services/translation.service.js +0 -109
- package/src/shared/services/translation.service.ts +0 -59
- package/src/shared/services/validator.service.d.ts +0 -3
- package/src/shared/services/validator.service.js +0 -64
- package/src/shared/services/validator.service.ts +0 -10
- package/src/snake-naming.strategy.d.ts +0 -11
- package/src/snake-naming.strategy.js +0 -37
- package/src/snake-naming.strategy.ts +0 -64
- package/src/types.d.ts +0 -9
- package/src/types.js +0 -2
- package/src/types.ts +0 -44
- package/src/validators/file-mimetype.validator.d.ts +0 -13
- package/src/validators/file-mimetype.validator.js +0 -21
- package/src/validators/file-mimetype.validator.ts +0 -34
- package/src/validators/index.d.ts +0 -3
- package/src/validators/index.js +0 -19
- package/src/validators/index.ts +0 -3
- package/src/validators/is-exists.validator.d.ts +0 -18
- package/src/validators/is-exists.validator.js +0 -99
- package/src/validators/is-exists.validator.ts +0 -60
- package/src/validators/is-unique.validator.d.ts +0 -17
- package/src/validators/is-unique.validator.js +0 -131
- package/src/validators/is-unique.validator.ts +0 -93
- package/src/validators/phone-country-code.validator.d.ts +0 -2
- package/src/validators/phone-country-code.validator.js +0 -30
- package/src/validators/phone-country-code.validator.ts +0 -36
- package/src/validators/same-as.validator.d.ts +0 -2
- package/src/validators/same-as.validator.js +0 -25
- package/src/validators/same-as.validator.ts +0 -27
- package/src/validators/skip-empty.validator.d.ts +0 -6
- package/src/validators/skip-empty.validator.js +0 -23
- package/src/validators/skip-empty.validator.ts +0 -25
- package/tsconfig.json +0 -30
- package/tsconfig.lib.json +0 -16
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UUIDParam = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
function UUIDParam(property, ...pipes) {
|
|
6
|
-
return (0, common_1.Param)(property, new common_1.ParseUUIDPipe({ version: '4' }), ...pipes);
|
|
7
|
-
}
|
|
8
|
-
exports.UUIDParam = UUIDParam;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { PipeTransform } from '@nestjs/common';
|
|
2
|
-
import { Param, ParseUUIDPipe } from '@nestjs/common';
|
|
3
|
-
import type { Type } from '@nestjs/common/interfaces';
|
|
4
|
-
|
|
5
|
-
export function UUIDParam(
|
|
6
|
-
property: string,
|
|
7
|
-
...pipes: Array<Type<PipeTransform> | PipeTransform>
|
|
8
|
-
): ParameterDecorator {
|
|
9
|
-
return Param(property, new ParseUUIDPipe({ version: '4' }), ...pipes);
|
|
10
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from './api-page-ok-response.decorator';
|
|
2
|
-
export * from './auth-user.decorator';
|
|
3
|
-
export * from './field.decorators';
|
|
4
|
-
export * from './http.decorators';
|
|
5
|
-
export * from './property.decorators';
|
|
6
|
-
export * from './public-route.decorator';
|
|
7
|
-
export * from './swagger.schema';
|
|
8
|
-
export * from './transform.decorators';
|
|
9
|
-
export * from './translate.decorator';
|
|
10
|
-
export * from './use-dto.decorator';
|
|
11
|
-
export * from './validator.decorators';
|
|
12
|
-
export * from './controller.decorator';
|
package/src/decorators/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./api-page-ok-response.decorator"), exports);
|
|
18
|
-
__exportStar(require("./auth-user.decorator"), exports);
|
|
19
|
-
__exportStar(require("./field.decorators"), exports);
|
|
20
|
-
__exportStar(require("./http.decorators"), exports);
|
|
21
|
-
__exportStar(require("./property.decorators"), exports);
|
|
22
|
-
__exportStar(require("./public-route.decorator"), exports);
|
|
23
|
-
__exportStar(require("./swagger.schema"), exports);
|
|
24
|
-
__exportStar(require("./transform.decorators"), exports);
|
|
25
|
-
__exportStar(require("./translate.decorator"), exports);
|
|
26
|
-
__exportStar(require("./use-dto.decorator"), exports);
|
|
27
|
-
__exportStar(require("./validator.decorators"), exports);
|
|
28
|
-
__exportStar(require("./controller.decorator"), exports);
|
package/src/decorators/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from './api-page-ok-response.decorator';
|
|
2
|
-
export * from './auth-user.decorator';
|
|
3
|
-
export * from './field.decorators';
|
|
4
|
-
export * from './http.decorators';
|
|
5
|
-
export * from './property.decorators';
|
|
6
|
-
export * from './public-route.decorator';
|
|
7
|
-
export * from './swagger.schema';
|
|
8
|
-
export * from './transform.decorators';
|
|
9
|
-
export * from './translate.decorator';
|
|
10
|
-
export * from './use-dto.decorator';
|
|
11
|
-
export * from './validator.decorators';
|
|
12
|
-
export * from './controller.decorator';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface IOmniAuth {
|
|
2
|
-
uid: number;
|
|
3
|
-
username: string;
|
|
4
|
-
tenantId: string;
|
|
5
|
-
appId: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const OmniAuth: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
8
|
-
export declare function getOmniAuthData(req: any, data?: string): IOmniAuth;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getOmniAuthData = exports.OmniAuth = void 0;
|
|
27
|
-
const common_1 = require("@nestjs/common");
|
|
28
|
-
const lodash = __importStar(require("lodash"));
|
|
29
|
-
const config_1 = require("@nestjs/config");
|
|
30
|
-
exports.OmniAuth = (0, common_1.createParamDecorator)((field, ctx) => {
|
|
31
|
-
return getOmniAuthData(ctx.switchToHttp().getRequest(), field);
|
|
32
|
-
});
|
|
33
|
-
function getOmniAuthData(req, data) {
|
|
34
|
-
const headers = req.headers;
|
|
35
|
-
let user;
|
|
36
|
-
const configService = new config_1.ConfigService(req);
|
|
37
|
-
// 未通过网关透传用户信息且处于local开发环境,则从配置获取用户信息
|
|
38
|
-
if (lodash.isEmpty(headers['x-userid']) ||
|
|
39
|
-
lodash.isEmpty(headers['x-username'])) {
|
|
40
|
-
//todo 需要删除
|
|
41
|
-
if (process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'uat') {
|
|
42
|
-
user = {
|
|
43
|
-
uid: configService.get('MOCK_UID'),
|
|
44
|
-
username: configService.get('MOCK_USERNAME'),
|
|
45
|
-
appId: configService.get('MOCK_APP_ID'),
|
|
46
|
-
tenantId: configService.get('MOCK_TENANT_ID'),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
user = {
|
|
52
|
-
uid: headers['x-userid'],
|
|
53
|
-
username: headers['x-username'],
|
|
54
|
-
appId: headers['x-appid'],
|
|
55
|
-
tenantId: headers['x-tenantid'],
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return data ? user[data] : user;
|
|
59
|
-
}
|
|
60
|
-
exports.getOmniAuthData = getOmniAuthData;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
|
|
2
|
-
import * as lodash from 'lodash';
|
|
3
|
-
import { ConfigService } from '@nestjs/config';
|
|
4
|
-
|
|
5
|
-
export interface IOmniAuth {
|
|
6
|
-
uid: number;
|
|
7
|
-
username: string;
|
|
8
|
-
tenantId: string;
|
|
9
|
-
appId: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const OmniAuth = createParamDecorator(
|
|
13
|
-
(field: string, ctx: ExecutionContext): IOmniAuth => {
|
|
14
|
-
return getOmniAuthData(ctx.switchToHttp().getRequest(), field);
|
|
15
|
-
},
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
export function getOmniAuthData(req, data?: string): IOmniAuth {
|
|
19
|
-
const headers = req.headers;
|
|
20
|
-
let user: IOmniAuth;
|
|
21
|
-
const configService = new ConfigService(req);
|
|
22
|
-
// 未通过网关透传用户信息且处于local开发环境,则从配置获取用户信息
|
|
23
|
-
if (
|
|
24
|
-
lodash.isEmpty(headers['x-userid']) ||
|
|
25
|
-
lodash.isEmpty(headers['x-username'])
|
|
26
|
-
) {
|
|
27
|
-
//todo 需要删除
|
|
28
|
-
if (process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'uat') {
|
|
29
|
-
user = {
|
|
30
|
-
uid: configService.get('MOCK_UID'),
|
|
31
|
-
username: configService.get('MOCK_USERNAME'),
|
|
32
|
-
appId: configService.get('MOCK_APP_ID'),
|
|
33
|
-
tenantId: configService.get('MOCK_TENANT_ID'),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
user = {
|
|
38
|
-
uid: headers['x-userid'],
|
|
39
|
-
username: headers['x-username'],
|
|
40
|
-
appId: headers['x-appid'],
|
|
41
|
-
tenantId: headers['x-tenantid'],
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return data ? user[data] : user;
|
|
46
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const OperationLog: (operation: string) => import("@nestjs/common").CustomDecorator<string>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OperationLog = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const OperationLog = (operation) => (0, common_1.SetMetadata)('operation-log', operation);
|
|
6
|
-
exports.OperationLog = OperationLog;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ApiPropertyOptions } from '@nestjs/swagger';
|
|
2
|
-
export declare function ApiBooleanProperty(options?: Omit<ApiPropertyOptions, 'type'>): PropertyDecorator;
|
|
3
|
-
export declare function ApiBooleanPropertyOptional(options?: Omit<ApiPropertyOptions, 'type' | 'required'>): PropertyDecorator;
|
|
4
|
-
export declare function ApiUUIDProperty(options?: Omit<ApiPropertyOptions, 'type' | 'format'> & Partial<{
|
|
5
|
-
each: boolean;
|
|
6
|
-
}>): PropertyDecorator;
|
|
7
|
-
export declare function ApiUUIDPropertyOptional(options?: Omit<ApiPropertyOptions, 'type' | 'format' | 'required'> & Partial<{
|
|
8
|
-
each: boolean;
|
|
9
|
-
}>): PropertyDecorator;
|
|
10
|
-
export declare function ApiEnumProperty<TEnum>(getEnum: () => TEnum, options?: Omit<ApiPropertyOptions, 'type'> & {
|
|
11
|
-
each?: boolean;
|
|
12
|
-
}): PropertyDecorator;
|
|
13
|
-
export declare function ApiEnumPropertyOptional<TEnum>(getEnum: () => TEnum, options?: Omit<ApiPropertyOptions, 'type' | 'required'> & {
|
|
14
|
-
each?: boolean;
|
|
15
|
-
}): PropertyDecorator;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiEnumPropertyOptional = exports.ApiEnumProperty = exports.ApiUUIDPropertyOptional = exports.ApiUUIDProperty = exports.ApiBooleanPropertyOptional = exports.ApiBooleanProperty = void 0;
|
|
4
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
5
|
-
const utils_1 = require("../common/utils");
|
|
6
|
-
const field_decorators_1 = require("../decorators/field.decorators");
|
|
7
|
-
function ApiBooleanProperty(options = {}) {
|
|
8
|
-
return (0, swagger_1.ApiProperty)(Object.assign({ type: Boolean }, options));
|
|
9
|
-
}
|
|
10
|
-
exports.ApiBooleanProperty = ApiBooleanProperty;
|
|
11
|
-
function ApiBooleanPropertyOptional(options = {}) {
|
|
12
|
-
return ApiBooleanProperty(Object.assign({ required: false }, options));
|
|
13
|
-
}
|
|
14
|
-
exports.ApiBooleanPropertyOptional = ApiBooleanPropertyOptional;
|
|
15
|
-
function ApiUUIDProperty(options = {}) {
|
|
16
|
-
return (0, swagger_1.ApiProperty)(Object.assign({ type: options.each ? [String] : String, format: 'uuid', isArray: options.each }, options));
|
|
17
|
-
}
|
|
18
|
-
exports.ApiUUIDProperty = ApiUUIDProperty;
|
|
19
|
-
function ApiUUIDPropertyOptional(options = {}) {
|
|
20
|
-
return ApiUUIDProperty(Object.assign({ required: false }, options));
|
|
21
|
-
}
|
|
22
|
-
exports.ApiUUIDPropertyOptional = ApiUUIDPropertyOptional;
|
|
23
|
-
function ApiEnumProperty(getEnum, options = {}) {
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
-
const enumValue = getEnum();
|
|
26
|
-
options.description = (0, field_decorators_1.getEnumDescription)(enumValue);
|
|
27
|
-
return (0, swagger_1.ApiProperty)(Object.assign({ type: 'enum',
|
|
28
|
-
// throw error during the compilation of swagger
|
|
29
|
-
// isArray: options.each,
|
|
30
|
-
enum: enumValue, enumName: (0, utils_1.getVariableName)(getEnum) }, options));
|
|
31
|
-
}
|
|
32
|
-
exports.ApiEnumProperty = ApiEnumProperty;
|
|
33
|
-
function ApiEnumPropertyOptional(getEnum, options = {}) {
|
|
34
|
-
return ApiEnumProperty(getEnum, Object.assign({ required: false }, options));
|
|
35
|
-
}
|
|
36
|
-
exports.ApiEnumPropertyOptional = ApiEnumPropertyOptional;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { ApiPropertyOptions } from '@nestjs/swagger';
|
|
2
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
3
|
-
|
|
4
|
-
import { getVariableName } from '../common/utils';
|
|
5
|
-
import { getEnumDescription } from '../decorators/field.decorators';
|
|
6
|
-
|
|
7
|
-
export function ApiBooleanProperty(
|
|
8
|
-
options: Omit<ApiPropertyOptions, 'type'> = {},
|
|
9
|
-
): PropertyDecorator {
|
|
10
|
-
return ApiProperty({ type: Boolean, ...options });
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function ApiBooleanPropertyOptional(
|
|
14
|
-
options: Omit<ApiPropertyOptions, 'type' | 'required'> = {},
|
|
15
|
-
): PropertyDecorator {
|
|
16
|
-
return ApiBooleanProperty({ required: false, ...options });
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function ApiUUIDProperty(
|
|
20
|
-
options: Omit<ApiPropertyOptions, 'type' | 'format'> &
|
|
21
|
-
Partial<{ each: boolean }> = {},
|
|
22
|
-
): PropertyDecorator {
|
|
23
|
-
return ApiProperty({
|
|
24
|
-
type: options.each ? [String] : String,
|
|
25
|
-
format: 'uuid',
|
|
26
|
-
isArray: options.each,
|
|
27
|
-
...options,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function ApiUUIDPropertyOptional(
|
|
32
|
-
options: Omit<ApiPropertyOptions, 'type' | 'format' | 'required'> &
|
|
33
|
-
Partial<{ each: boolean }> = {},
|
|
34
|
-
): PropertyDecorator {
|
|
35
|
-
return ApiUUIDProperty({ required: false, ...options });
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function ApiEnumProperty<TEnum>(
|
|
39
|
-
getEnum: () => TEnum,
|
|
40
|
-
options: Omit<ApiPropertyOptions, 'type'> & { each?: boolean } = {},
|
|
41
|
-
): PropertyDecorator {
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
-
const enumValue = getEnum() as any;
|
|
44
|
-
options.description = getEnumDescription(enumValue);
|
|
45
|
-
return ApiProperty({
|
|
46
|
-
type: 'enum',
|
|
47
|
-
// throw error during the compilation of swagger
|
|
48
|
-
// isArray: options.each,
|
|
49
|
-
enum: enumValue,
|
|
50
|
-
enumName: getVariableName(getEnum),
|
|
51
|
-
...options,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function ApiEnumPropertyOptional<TEnum>(
|
|
56
|
-
getEnum: () => TEnum,
|
|
57
|
-
options: Omit<ApiPropertyOptions, 'type' | 'required'> & {
|
|
58
|
-
each?: boolean;
|
|
59
|
-
} = {},
|
|
60
|
-
): PropertyDecorator {
|
|
61
|
-
return ApiEnumProperty(getEnum, { required: false, ...options });
|
|
62
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PublicRoute = exports.PUBLIC_ROUTE_KEY = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
exports.PUBLIC_ROUTE_KEY = 'public_route';
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
-
const PublicRoute = (isPublic = false) => (0, common_1.SetMetadata)(exports.PUBLIC_ROUTE_KEY, isPublic);
|
|
8
|
-
exports.PublicRoute = PublicRoute;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { CustomDecorator } from '@nestjs/common';
|
|
2
|
-
import { SetMetadata } from '@nestjs/common';
|
|
3
|
-
|
|
4
|
-
export const PUBLIC_ROUTE_KEY = 'public_route';
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
-
export const PublicRoute = (isPublic = false): CustomDecorator =>
|
|
8
|
-
SetMetadata(PUBLIC_ROUTE_KEY, isPublic);
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ApiFile = void 0;
|
|
7
|
-
const common_1 = require("@nestjs/common");
|
|
8
|
-
const constants_1 = require("@nestjs/common/constants");
|
|
9
|
-
const route_paramtypes_enum_1 = require("@nestjs/common/enums/route-paramtypes.enum");
|
|
10
|
-
const platform_express_1 = require("@nestjs/platform-express");
|
|
11
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
12
|
-
const reverse_object_keys_util_1 = require("@nestjs/swagger/dist/utils/reverse-object-keys.util");
|
|
13
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
14
|
-
function explore(instance, propertyKey) {
|
|
15
|
-
const types = Reflect.getMetadata(constants_1.PARAMTYPES_METADATA, instance, propertyKey);
|
|
16
|
-
const routeArgsMetadata = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, instance.constructor, propertyKey) || {};
|
|
17
|
-
const parametersWithType = lodash_1.default.mapValues((0, reverse_object_keys_util_1.reverseObjectKeys)(routeArgsMetadata), (param) => ({
|
|
18
|
-
type: types[param.index],
|
|
19
|
-
name: param.data,
|
|
20
|
-
required: true,
|
|
21
|
-
}));
|
|
22
|
-
for (const [key, value] of Object.entries(parametersWithType)) {
|
|
23
|
-
const keyPair = key.split(':');
|
|
24
|
-
if (Number(keyPair[0]) === route_paramtypes_enum_1.RouteParamtypes.BODY) {
|
|
25
|
-
return value.type;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function RegisterModels() {
|
|
30
|
-
return (target, propertyKey, descriptor) => {
|
|
31
|
-
const body = explore(target, propertyKey);
|
|
32
|
-
return body && (0, swagger_1.ApiExtraModels)(body)(target, propertyKey, descriptor);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function ApiFileDecorator(files = [], options = {}) {
|
|
36
|
-
return (target, propertyKey, descriptor) => {
|
|
37
|
-
const { isRequired = false } = options;
|
|
38
|
-
const fileSchema = {
|
|
39
|
-
type: 'string',
|
|
40
|
-
format: 'binary',
|
|
41
|
-
};
|
|
42
|
-
const properties = {};
|
|
43
|
-
for (const file of files) {
|
|
44
|
-
if (file.isArray) {
|
|
45
|
-
properties[file.name] = {
|
|
46
|
-
type: 'array',
|
|
47
|
-
items: fileSchema,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
properties[file.name] = fileSchema;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
let schema = {
|
|
55
|
-
properties,
|
|
56
|
-
type: 'object',
|
|
57
|
-
};
|
|
58
|
-
const body = explore(target, propertyKey);
|
|
59
|
-
if (body) {
|
|
60
|
-
schema = {
|
|
61
|
-
allOf: [
|
|
62
|
-
{
|
|
63
|
-
$ref: (0, swagger_1.getSchemaPath)(body),
|
|
64
|
-
},
|
|
65
|
-
{ properties, type: 'object' },
|
|
66
|
-
],
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
return (0, swagger_1.ApiBody)({
|
|
70
|
-
schema,
|
|
71
|
-
required: isRequired,
|
|
72
|
-
})(target, propertyKey, descriptor);
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
function ApiFile(files, options = {}) {
|
|
76
|
-
const filesArray = lodash_1.default.castArray(files);
|
|
77
|
-
const apiFileInterceptors = filesArray.map((file) => file.isArray
|
|
78
|
-
? (0, common_1.UseInterceptors)((0, platform_express_1.FilesInterceptor)(file.name))
|
|
79
|
-
: (0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)(file.name)));
|
|
80
|
-
return (0, common_1.applyDecorators)(RegisterModels(), (0, swagger_1.ApiConsumes)('multipart/form-data'), ApiFileDecorator(filesArray, options), ...apiFileInterceptors);
|
|
81
|
-
}
|
|
82
|
-
exports.ApiFile = ApiFile;
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-types,@typescript-eslint/no-unsafe-argument */
|
|
2
|
-
import type { Type } from '@nestjs/common';
|
|
3
|
-
import { applyDecorators, UseInterceptors } from '@nestjs/common';
|
|
4
|
-
import { PARAMTYPES_METADATA, ROUTE_ARGS_METADATA } from '@nestjs/common/constants';
|
|
5
|
-
import { RouteParamtypes } from '@nestjs/common/enums/route-paramtypes.enum';
|
|
6
|
-
import { FileInterceptor, FilesInterceptor } from '@nestjs/platform-express';
|
|
7
|
-
import { ApiBody, ApiConsumes, ApiExtraModels, getSchemaPath } from '@nestjs/swagger';
|
|
8
|
-
import type { ReferenceObject, SchemaObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
|
|
9
|
-
import { reverseObjectKeys } from '@nestjs/swagger/dist/utils/reverse-object-keys.util';
|
|
10
|
-
import _ from 'lodash';
|
|
11
|
-
|
|
12
|
-
import type { IApiFile } from '../interfaces';
|
|
13
|
-
|
|
14
|
-
function explore(instance: Object, propertyKey: string | symbol) {
|
|
15
|
-
const types: Array<Type<unknown>> = Reflect.getMetadata(
|
|
16
|
-
PARAMTYPES_METADATA,
|
|
17
|
-
instance,
|
|
18
|
-
propertyKey,
|
|
19
|
-
);
|
|
20
|
-
const routeArgsMetadata =
|
|
21
|
-
Reflect.getMetadata(
|
|
22
|
-
ROUTE_ARGS_METADATA,
|
|
23
|
-
instance.constructor,
|
|
24
|
-
propertyKey,
|
|
25
|
-
) || {};
|
|
26
|
-
|
|
27
|
-
const parametersWithType = _.mapValues(
|
|
28
|
-
reverseObjectKeys(routeArgsMetadata),
|
|
29
|
-
(param) => ({
|
|
30
|
-
type: types[param.index],
|
|
31
|
-
name: param.data,
|
|
32
|
-
required: true,
|
|
33
|
-
}),
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
for (const [key, value] of Object.entries(parametersWithType)) {
|
|
37
|
-
const keyPair = key.split(':');
|
|
38
|
-
|
|
39
|
-
if (Number(keyPair[0]) === RouteParamtypes.BODY) {
|
|
40
|
-
return value.type;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function RegisterModels(): MethodDecorator {
|
|
46
|
-
return (target, propertyKey, descriptor: PropertyDescriptor) => {
|
|
47
|
-
const body = explore(target, propertyKey);
|
|
48
|
-
|
|
49
|
-
return body && ApiExtraModels(body)(target, propertyKey, descriptor);
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function ApiFileDecorator(
|
|
54
|
-
files: IApiFile[] = [],
|
|
55
|
-
options: Partial<{ isRequired: boolean }> = {},
|
|
56
|
-
): MethodDecorator {
|
|
57
|
-
return (target, propertyKey, descriptor: PropertyDescriptor) => {
|
|
58
|
-
const { isRequired = false } = options;
|
|
59
|
-
const fileSchema: SchemaObject = {
|
|
60
|
-
type: 'string',
|
|
61
|
-
format: 'binary',
|
|
62
|
-
};
|
|
63
|
-
const properties: Record<string, SchemaObject | ReferenceObject> = {};
|
|
64
|
-
|
|
65
|
-
for (const file of files) {
|
|
66
|
-
if (file.isArray) {
|
|
67
|
-
properties[file.name] = {
|
|
68
|
-
type: 'array',
|
|
69
|
-
items: fileSchema,
|
|
70
|
-
};
|
|
71
|
-
} else {
|
|
72
|
-
properties[file.name] = fileSchema;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
let schema: SchemaObject = {
|
|
77
|
-
properties,
|
|
78
|
-
type: 'object',
|
|
79
|
-
};
|
|
80
|
-
const body = explore(target, propertyKey);
|
|
81
|
-
|
|
82
|
-
if (body) {
|
|
83
|
-
schema = {
|
|
84
|
-
allOf: [
|
|
85
|
-
{
|
|
86
|
-
$ref: getSchemaPath(body),
|
|
87
|
-
},
|
|
88
|
-
{ properties, type: 'object' },
|
|
89
|
-
],
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return ApiBody({
|
|
94
|
-
schema,
|
|
95
|
-
required: isRequired,
|
|
96
|
-
})(target, propertyKey, descriptor);
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function ApiFile(
|
|
101
|
-
files: _.Many<IApiFile>,
|
|
102
|
-
options: Partial<{ isRequired: boolean }> = {},
|
|
103
|
-
): MethodDecorator {
|
|
104
|
-
const filesArray = _.castArray(files);
|
|
105
|
-
const apiFileInterceptors = filesArray.map((file) =>
|
|
106
|
-
file.isArray
|
|
107
|
-
? UseInterceptors(FilesInterceptor(file.name))
|
|
108
|
-
: UseInterceptors(FileInterceptor(file.name)),
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
return applyDecorators(
|
|
112
|
-
RegisterModels(),
|
|
113
|
-
ApiConsumes('multipart/form-data'),
|
|
114
|
-
ApiFileDecorator(filesArray, options),
|
|
115
|
-
...apiFileInterceptors,
|
|
116
|
-
);
|
|
117
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function TimestampColumn(name: string, description?: string): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TimestampColumn = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
-
const typeorm_1 = require("typeorm");
|
|
7
|
-
const helpers_1 = require("./helpers");
|
|
8
|
-
function TimestampColumn(name, description) {
|
|
9
|
-
return (0, common_1.applyDecorators)((0, swagger_1.ApiProperty)({
|
|
10
|
-
required: false,
|
|
11
|
-
type: 'string',
|
|
12
|
-
format: 'date-time',
|
|
13
|
-
example: '2018-10-01 12:18:48',
|
|
14
|
-
description,
|
|
15
|
-
}), (0, typeorm_1.Column)({
|
|
16
|
-
type: 'int',
|
|
17
|
-
name,
|
|
18
|
-
nullable: false,
|
|
19
|
-
unsigned: true,
|
|
20
|
-
default: 0,
|
|
21
|
-
comment: description,
|
|
22
|
-
transformer: {
|
|
23
|
-
to: (value) => value === 0 || /\d{10}/.test(value) ? value : (0, helpers_1.strToTimeStamp)(value),
|
|
24
|
-
from: (value) => (0, helpers_1.formatDateTime)(value),
|
|
25
|
-
},
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
exports.TimestampColumn = TimestampColumn;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { applyDecorators } from '@nestjs/common';
|
|
2
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
3
|
-
import { Column } from 'typeorm';
|
|
4
|
-
import { formatDateTime, strToTimeStamp } from '../helpers';
|
|
5
|
-
|
|
6
|
-
export function TimestampColumn(name: string, description?: string) {
|
|
7
|
-
return applyDecorators(
|
|
8
|
-
ApiProperty({
|
|
9
|
-
required: false,
|
|
10
|
-
type: 'string',
|
|
11
|
-
format: 'date-time',
|
|
12
|
-
example: '2018-10-01 12:18:48',
|
|
13
|
-
description,
|
|
14
|
-
}),
|
|
15
|
-
Column({
|
|
16
|
-
type: 'int',
|
|
17
|
-
name,
|
|
18
|
-
nullable: false,
|
|
19
|
-
unsigned: true,
|
|
20
|
-
default: 0,
|
|
21
|
-
comment: description,
|
|
22
|
-
transformer: {
|
|
23
|
-
to: (value) =>
|
|
24
|
-
value === 0 || /\d{10}/.test(value) ? value : strToTimeStamp(value),
|
|
25
|
-
from: (value) => formatDateTime(value),
|
|
26
|
-
},
|
|
27
|
-
}),
|
|
28
|
-
);
|
|
29
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description trim spaces from start and end, replace multiple spaces with one.
|
|
3
|
-
* @example
|
|
4
|
-
* @ApiProperty()
|
|
5
|
-
* @IsString()
|
|
6
|
-
* @Trim()
|
|
7
|
-
* name: string;
|
|
8
|
-
* @returns PropertyDecorator
|
|
9
|
-
* @constructor
|
|
10
|
-
*/
|
|
11
|
-
export declare function Trim(): PropertyDecorator;
|
|
12
|
-
export declare function ToBoolean(): PropertyDecorator;
|
|
13
|
-
/**
|
|
14
|
-
* @description convert string or number to integer
|
|
15
|
-
* @example
|
|
16
|
-
* @NumberField()
|
|
17
|
-
* @ToInt()
|
|
18
|
-
* name: number;
|
|
19
|
-
* @returns PropertyDecorator
|
|
20
|
-
* @constructor
|
|
21
|
-
*/
|
|
22
|
-
export declare function ToInt(): PropertyDecorator;
|
|
23
|
-
/**
|
|
24
|
-
* @description transforms to array, specially for query params
|
|
25
|
-
* @example
|
|
26
|
-
* @NumberField()
|
|
27
|
-
* @ToArray()
|
|
28
|
-
* name: number;
|
|
29
|
-
* @constructor
|
|
30
|
-
*/
|
|
31
|
-
export declare function ToArray(): PropertyDecorator;
|
|
32
|
-
export declare function ToLowerCase(): PropertyDecorator;
|
|
33
|
-
export declare function ToUpperCase(): PropertyDecorator;
|
|
34
|
-
export declare function S3UrlParser(): PropertyDecorator;
|
|
35
|
-
export declare function PhoneNumberSerializer(): PropertyDecorator;
|