@nest-omni/core 1.0.3 → 1.0.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/package.json +1 -4
- package/src/boilerplate.polyfill.d.ts +39 -0
- package/src/boilerplate.polyfill.js +78 -0
- package/src/boilerplate.polyfill.ts +202 -0
- package/src/common/abstract-client.service.d.ts +20 -0
- package/src/common/abstract-client.service.js +39 -0
- package/src/common/abstract-client.service.ts +56 -0
- package/src/common/abstract.entity.d.ts +24 -0
- package/src/common/abstract.entity.js +152 -0
- package/src/common/abstract.entity.ts +73 -0
- package/src/common/dto/abstract.dto.d.ts +13 -0
- package/src/common/dto/abstract.dto.js +96 -0
- package/src/common/dto/abstract.dto.ts +64 -0
- package/src/common/dto/bulk-id.dto.d.ts +3 -0
- package/src/common/dto/bulk-id.dto.js +63 -0
- package/src/common/dto/bulk-id.dto.ts +13 -0
- package/src/common/dto/create-translation.dto.d.ts +5 -0
- package/src/common/dto/create-translation.dto.js +63 -0
- package/src/common/dto/create-translation.dto.ts +10 -0
- package/src/common/dto/page-meta.dto.d.ts +15 -0
- package/src/common/dto/page-meta.dto.js +88 -0
- package/src/common/dto/page-meta.dto.ts +37 -0
- package/src/common/dto/page-options.dto.d.ts +8 -0
- package/src/common/dto/page-options.dto.js +87 -0
- package/src/common/dto/page-options.dto.ts +35 -0
- package/src/common/dto/page.dto.d.ts +11 -0
- package/src/common/dto/page.dto.js +94 -0
- package/src/common/dto/page.dto.ts +36 -0
- package/src/common/utils.d.ts +14 -0
- package/src/common/utils.js +39 -0
- package/src/common/utils.ts +45 -0
- package/src/constants/index.d.ts +4 -0
- package/src/constants/index.js +20 -0
- package/src/constants/index.ts +4 -0
- package/src/constants/language-code.d.ts +5 -0
- package/src/constants/language-code.js +10 -0
- package/src/constants/language-code.ts +7 -0
- package/src/constants/order.d.ts +4 -0
- package/src/constants/order.js +8 -0
- package/src/constants/order.ts +4 -0
- package/src/constants/role-type.d.ts +4 -0
- package/src/constants/role-type.js +8 -0
- package/src/constants/role-type.ts +4 -0
- package/src/constants/token-type.d.ts +4 -0
- package/src/constants/token-type.js +8 -0
- package/src/constants/token-type.ts +4 -0
- package/src/decorators/api-page-ok-response.decorator.d.ts +5 -0
- package/src/decorators/api-page-ok-response.decorator.js +25 -0
- package/src/decorators/api-page-ok-response.decorator.ts +31 -0
- package/src/decorators/auth-user.decorator.d.ts +1 -0
- package/src/decorators/auth-user.decorator.js +15 -0
- package/src/decorators/auth-user.decorator.ts +16 -0
- package/src/decorators/controller.decorator.d.ts +1 -0
- package/src/decorators/controller.decorator.js +34 -0
- package/src/decorators/controller.decorator.ts +8 -0
- package/src/decorators/field.decorators.d.ts +71 -0
- package/src/decorators/field.decorators.js +455 -0
- package/src/decorators/field.decorators.ts +773 -0
- package/src/decorators/http.decorators.d.ts +3 -0
- package/src/decorators/http.decorators.js +8 -0
- package/src/decorators/http.decorators.ts +10 -0
- package/src/decorators/index.d.ts +12 -0
- package/src/decorators/index.js +28 -0
- package/src/decorators/index.ts +12 -0
- package/src/decorators/omni-auth.decorator.d.ts +8 -0
- package/src/decorators/omni-auth.decorator.js +60 -0
- package/src/decorators/omni-auth.decorator.ts +46 -0
- package/src/decorators/operation.decorator.d.ts +1 -0
- package/src/decorators/operation.decorator.js +6 -0
- package/src/decorators/operation.decorator.ts +4 -0
- package/src/decorators/property.decorators.d.ts +15 -0
- package/src/decorators/property.decorators.js +36 -0
- package/src/decorators/property.decorators.ts +62 -0
- package/src/decorators/public-route.decorator.d.ts +3 -0
- package/src/decorators/public-route.decorator.js +8 -0
- package/src/decorators/public-route.decorator.ts +8 -0
- package/src/decorators/swagger.schema.d.ts +5 -0
- package/src/decorators/swagger.schema.js +82 -0
- package/src/decorators/swagger.schema.ts +117 -0
- package/src/decorators/timestamp-column.decorator.d.ts +1 -0
- package/src/decorators/timestamp-column.decorator.js +28 -0
- package/src/decorators/timestamp-column.decorator.ts +29 -0
- package/src/decorators/transform.decorators.d.ts +35 -0
- package/src/decorators/transform.decorators.js +122 -0
- package/src/decorators/transform.decorators.ts +147 -0
- package/src/decorators/translate.decorator.d.ts +5 -0
- package/src/decorators/translate.decorator.js +18 -0
- package/src/decorators/translate.decorator.ts +19 -0
- package/src/decorators/use-dto.decorator.d.ts +4 -0
- package/src/decorators/use-dto.decorator.js +9 -0
- package/src/decorators/use-dto.decorator.ts +11 -0
- package/src/decorators/user-check.decorator.d.ts +6 -0
- package/src/decorators/user-check.decorator.js +44 -0
- package/src/decorators/user-check.decorator.ts +30 -0
- package/src/decorators/user.decorator.d.ts +8 -0
- package/src/decorators/user.decorator.js +62 -0
- package/src/decorators/user.decorator.ts +48 -0
- package/src/decorators/user_auth.decorator.d.ts +1 -0
- package/src/decorators/user_auth.decorator.js +16 -0
- package/src/decorators/user_auth.decorator.ts +15 -0
- package/src/decorators/validator.decorators.d.ts +10 -0
- package/src/decorators/validator.decorators.js +59 -0
- package/src/decorators/validator.decorators.ts +78 -0
- package/src/exceptions/file-not-image.exception.d.ts +4 -0
- package/src/exceptions/file-not-image.exception.js +10 -0
- package/src/exceptions/file-not-image.exception.ts +7 -0
- package/src/exceptions/index.d.ts +2 -0
- package/src/exceptions/index.js +18 -0
- package/src/exceptions/index.ts +2 -0
- package/src/exceptions/page-type.exception.d.ts +4 -0
- package/src/exceptions/page-type.exception.js +10 -0
- package/src/exceptions/page-type.exception.ts +7 -0
- package/src/exceptions/user-not-found.exception.d.ts +4 -0
- package/src/exceptions/user-not-found.exception.js +10 -0
- package/src/exceptions/user-not-found.exception.ts +7 -0
- package/src/filters/bad-request.filter.d.ts +5 -0
- package/src/filters/bad-request.filter.js +104 -0
- package/src/filters/bad-request.filter.ts +67 -0
- package/src/filters/constraint-errors.d.ts +1 -0
- package/src/filters/constraint-errors.js +7 -0
- package/src/filters/constraint-errors.ts +5 -0
- package/src/filters/index.d.ts +3 -0
- package/src/filters/index.js +19 -0
- package/src/filters/index.ts +3 -0
- package/src/filters/query-failed.filter.d.ts +10 -0
- package/src/filters/query-failed.filter.js +81 -0
- package/src/filters/query-failed.filter.ts +32 -0
- package/src/health-checker/health-checker.controller.d.ts +15 -0
- package/src/health-checker/health-checker.controller.js +104 -0
- package/src/health-checker/health-checker.controller.ts +51 -0
- package/src/health-checker/health-checker.module.d.ts +2 -0
- package/src/health-checker/health-checker.module.js +69 -0
- package/src/health-checker/health-checker.module.ts +13 -0
- package/src/health-checker/health-indicators/service.indicator.d.ts +8 -0
- package/src/health-checker/health-indicators/service.indicator.js +102 -0
- package/src/health-checker/health-indicators/service.indicator.ts +44 -0
- package/src/helpers/common.helper.d.ts +16 -0
- package/src/helpers/common.helper.js +49 -0
- package/src/helpers/common.helper.ts +49 -0
- package/src/helpers/date.helper.d.ts +10 -0
- package/src/helpers/date.helper.js +81 -0
- package/src/helpers/date.helper.ts +64 -0
- package/src/helpers/excel.helper.d.ts +27 -0
- package/src/helpers/excel.helper.js +338 -0
- package/src/helpers/index.d.ts +3 -0
- package/src/helpers/index.js +19 -0
- package/src/helpers/index.ts +3 -0
- package/src/i18n/en_US/validation.json +38 -0
- package/src/i18n/zh_CN/validation.json +38 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +28 -0
- package/src/index.ts +12 -0
- package/src/interceptors/auth-user.interceptor.d.ts +4 -0
- package/src/interceptors/auth-user.interceptor.js +68 -0
- package/src/interceptors/auth-user.interceptor.ts +20 -0
- package/src/interceptors/index.d.ts +2 -0
- package/src/interceptors/index.js +18 -0
- package/src/interceptors/index.ts +2 -0
- package/src/interceptors/language-interceptor.service.d.ts +6 -0
- package/src/interceptors/language-interceptor.service.js +74 -0
- package/src/interceptors/language-interceptor.service.ts +31 -0
- package/src/interceptors/translation-interceptor.service.d.ts +5 -0
- package/src/interceptors/translation-interceptor.service.js +83 -0
- package/src/interceptors/translation-interceptor.service.ts +43 -0
- package/src/interfaces/IApiFile.d.ts +4 -0
- package/src/interfaces/IApiFile.js +2 -0
- package/src/interfaces/IApiFile.ts +4 -0
- package/src/interfaces/IFile.d.ts +9 -0
- package/src/interfaces/IFile.js +2 -0
- package/src/interfaces/IFile.ts +8 -0
- package/src/interfaces/ITranslationDecoratorInterface.d.ts +3 -0
- package/src/interfaces/ITranslationDecoratorInterface.js +2 -0
- package/src/interfaces/ITranslationDecoratorInterface.ts +3 -0
- package/src/interfaces/index.d.ts +3 -0
- package/src/interfaces/index.js +19 -0
- package/src/interfaces/index.ts +3 -0
- package/src/interfaces/response.d.ts +25 -0
- package/src/interfaces/response.js +2 -0
- package/src/interfaces/response.ts +37 -0
- package/src/middlewares/index.d.ts +3 -0
- package/src/middlewares/index.js +19 -0
- package/src/middlewares/index.ts +3 -0
- package/src/middlewares/omni-auth.middleware.d.ts +1 -0
- package/src/middlewares/omni-auth.middleware.js +13 -0
- package/src/middlewares/omni-auth.middleware.ts +10 -0
- package/src/middlewares/powerby.middleware.d.ts +1 -0
- package/src/middlewares/powerby.middleware.js +10 -0
- package/src/middlewares/powerby.middleware.ts +6 -0
- package/src/middlewares/request-id.middleware.d.ts +7 -0
- package/src/middlewares/request-id.middleware.js +22 -0
- package/src/middlewares/request-id.middleware.ts +28 -0
- package/src/providers/context.provider.d.ts +32 -0
- package/src/providers/context.provider.js +73 -0
- package/src/providers/context.provider.ts +98 -0
- package/src/providers/generator.provider.d.ts +13 -0
- package/src/providers/generator.provider.js +54 -0
- package/src/providers/generator.provider.ts +66 -0
- package/src/providers/index.d.ts +2 -0
- package/src/providers/index.js +18 -0
- package/src/providers/index.ts +2 -0
- package/src/setup/bootstrap.setup.d.ts +5 -0
- package/src/setup/bootstrap.setup.js +138 -0
- package/src/setup/bootstrap.setup.ts +139 -0
- package/src/setup/index.d.ts +1 -0
- package/src/setup/index.js +17 -0
- package/src/setup/index.ts +1 -0
- package/src/setup/microservices.setup.js +55 -0
- package/src/setup-swagger.d.ts +2 -0
- package/src/setup-swagger.js +62 -0
- package/src/setup-swagger.ts +67 -0
- package/src/shared/index.d.ts +2 -0
- package/src/shared/index.js +18 -0
- package/src/shared/index.ts +2 -0
- package/src/shared/serviceRegistryModule.d.ts +2 -0
- package/src/shared/serviceRegistryModule.js +176 -0
- package/src/shared/serviceRegistryModule.ts +110 -0
- package/src/shared/services/api-config.service.d.ts +73 -0
- package/src/shared/services/api-config.service.js +335 -0
- package/src/shared/services/api-config.service.ts +319 -0
- package/src/shared/services/aws-s3.service.d.ts +10 -0
- package/src/shared/services/aws-s3.service.js +96 -0
- package/src/shared/services/aws-s3.service.ts +39 -0
- package/src/shared/services/generator.service.d.ts +4 -0
- package/src/shared/services/generator.service.js +67 -0
- package/src/shared/services/generator.service.ts +13 -0
- package/src/shared/services/index.d.ts +5 -0
- package/src/shared/services/index.js +21 -0
- package/src/shared/services/index.ts +5 -0
- package/src/shared/services/translation.service.d.ts +9 -0
- package/src/shared/services/translation.service.js +109 -0
- package/src/shared/services/translation.service.ts +59 -0
- package/src/shared/services/validator.service.d.ts +3 -0
- package/src/shared/services/validator.service.js +64 -0
- package/src/shared/services/validator.service.ts +10 -0
- package/src/snake-naming.strategy.d.ts +11 -0
- package/src/snake-naming.strategy.js +37 -0
- package/src/snake-naming.strategy.ts +64 -0
- package/src/types.d.ts +9 -0
- package/src/types.js +2 -0
- package/src/types.ts +44 -0
- package/src/validators/file-mimetype.validator.d.ts +13 -0
- package/src/validators/file-mimetype.validator.js +21 -0
- package/src/validators/file-mimetype.validator.ts +34 -0
- package/src/validators/index.d.ts +3 -0
- package/src/validators/index.js +19 -0
- package/src/validators/index.ts +3 -0
- package/src/validators/is-exists.validator.d.ts +18 -0
- package/src/validators/is-exists.validator.js +99 -0
- package/src/validators/is-exists.validator.ts +60 -0
- package/src/validators/is-unique.validator.d.ts +17 -0
- package/src/validators/is-unique.validator.js +131 -0
- package/src/validators/is-unique.validator.ts +93 -0
- package/src/validators/phone-country-code.validator.d.ts +2 -0
- package/src/validators/phone-country-code.validator.js +30 -0
- package/src/validators/phone-country-code.validator.ts +36 -0
- package/src/validators/same-as.validator.d.ts +2 -0
- package/src/validators/same-as.validator.js +25 -0
- package/src/validators/same-as.validator.ts +27 -0
- package/src/validators/skip-empty.validator.d.ts +6 -0
- package/src/validators/skip-empty.validator.js +23 -0
- package/src/validators/skip-empty.validator.ts +25 -0
- package/tsconfig.json +26 -0
- package/tsconfig.lib.json +16 -0
- package/tsconfig.tsbuildinfo +1 -0
- /package/{README → README.md} +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ValidationOptions } from 'class-validator';
|
|
2
|
+
import { registerDecorator } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
export function SameAs(
|
|
5
|
+
property: string,
|
|
6
|
+
validationOptions?: ValidationOptions,
|
|
7
|
+
): PropertyDecorator {
|
|
8
|
+
return function (object, propertyName: string) {
|
|
9
|
+
registerDecorator({
|
|
10
|
+
name: 'sameAs',
|
|
11
|
+
target: object.constructor,
|
|
12
|
+
propertyName,
|
|
13
|
+
options: validationOptions,
|
|
14
|
+
constraints: [property],
|
|
15
|
+
validator: {
|
|
16
|
+
validate(value, args) {
|
|
17
|
+
const [relatedPropertyName] = args!.constraints;
|
|
18
|
+
|
|
19
|
+
return args?.object[relatedPropertyName] === value;
|
|
20
|
+
},
|
|
21
|
+
defaultMessage() {
|
|
22
|
+
return '$property must match $constraint1';
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When the value is emtpy, validation is skipped
|
|
3
|
+
* @param field
|
|
4
|
+
* @constructor
|
|
5
|
+
*/
|
|
6
|
+
export declare function SkipEmpty(field?: string): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SkipEmpty = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
+
const class_validator_1 = require("class-validator");
|
|
7
|
+
const lodash_1 = require("lodash");
|
|
8
|
+
/**
|
|
9
|
+
* When the value is emtpy, validation is skipped
|
|
10
|
+
* @param field
|
|
11
|
+
* @constructor
|
|
12
|
+
*/
|
|
13
|
+
function SkipEmpty(field) {
|
|
14
|
+
return (0, common_1.applyDecorators)((0, swagger_1.ApiProperty)({ required: false }), (0, class_validator_1.ValidateIf)((obj, value) => {
|
|
15
|
+
if (field) {
|
|
16
|
+
value = obj[field];
|
|
17
|
+
}
|
|
18
|
+
return !(value === null ||
|
|
19
|
+
value === undefined ||
|
|
20
|
+
((0, lodash_1.isString)(value) && value.trim() === ''));
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
exports.SkipEmpty = SkipEmpty;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { applyDecorators } from '@nestjs/common';
|
|
2
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
3
|
+
import { ValidateIf } from 'class-validator';
|
|
4
|
+
import { isString } from 'lodash';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* When the value is emtpy, validation is skipped
|
|
8
|
+
* @param field
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
export function SkipEmpty(field?: string) {
|
|
12
|
+
return applyDecorators(
|
|
13
|
+
ApiProperty({ required: false }),
|
|
14
|
+
ValidateIf((obj, value) => {
|
|
15
|
+
if (field) {
|
|
16
|
+
value = obj[field];
|
|
17
|
+
}
|
|
18
|
+
return !(
|
|
19
|
+
value === null ||
|
|
20
|
+
value === undefined ||
|
|
21
|
+
(isString(value) && value.trim() === '')
|
|
22
|
+
);
|
|
23
|
+
}),
|
|
24
|
+
);
|
|
25
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"target": "es6",
|
|
10
|
+
"sourceMap": false,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"rootDir": "./src",
|
|
13
|
+
"incremental": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"strictNullChecks": false,
|
|
16
|
+
"noImplicitAny": false,
|
|
17
|
+
"strictBindCallApply": false,
|
|
18
|
+
"forceConsistentCasingInFileNames": false,
|
|
19
|
+
"noFallthroughCasesInSwitch": false,
|
|
20
|
+
"resolveJsonModule": true,
|
|
21
|
+
},
|
|
22
|
+
"include": [
|
|
23
|
+
"./src/**/*.ts",
|
|
24
|
+
"./src/i18n/**/*.json"
|
|
25
|
+
]
|
|
26
|
+
}
|