@nest-omni/core 1.0.5 → 1.0.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.
- package/dist/boilerplate.polyfill.d.ts +39 -0
- package/dist/boilerplate.polyfill.js +77 -0
- package/dist/common/abstract-client.service.d.ts +16 -0
- package/dist/common/abstract-client.service.js +35 -0
- package/dist/common/abstract.entity.d.ts +17 -0
- package/dist/common/abstract.entity.js +64 -0
- package/dist/common/dto/abstract.dto.d.ts +13 -0
- package/dist/common/dto/abstract.dto.js +59 -0
- package/dist/common/dto/bulk-id.dto.d.ts +3 -0
- package/dist/common/dto/bulk-id.dto.js +27 -0
- package/dist/common/dto/create-translation.dto.d.ts +5 -0
- package/dist/common/dto/create-translation.dto.js +25 -0
- package/dist/common/dto/page-meta.dto.d.ts +15 -0
- package/dist/common/dto/page-meta.dto.js +48 -0
- package/dist/common/dto/page-options.dto.d.ts +8 -0
- package/dist/common/dto/page-options.dto.js +52 -0
- package/dist/common/dto/page.dto.d.ts +11 -0
- package/dist/common/dto/page.dto.js +53 -0
- package/dist/common/utils.d.ts +3 -0
- package/dist/common/utils.js +25 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.js +20 -0
- package/dist/constants/language-code.d.ts +5 -0
- package/dist/constants/language-code.js +9 -0
- package/dist/constants/order.d.ts +4 -0
- package/dist/constants/order.js +8 -0
- package/dist/constants/role-type.d.ts +4 -0
- package/dist/constants/role-type.js +8 -0
- package/dist/constants/token-type.d.ts +4 -0
- package/dist/constants/token-type.js +8 -0
- package/dist/decorators/api-page-ok-response.decorator.d.ts +5 -0
- package/dist/decorators/api-page-ok-response.decorator.js +25 -0
- package/dist/decorators/auth-user.decorator.d.ts +1 -0
- package/dist/decorators/auth-user.decorator.js +15 -0
- package/dist/decorators/controller.decorator.d.ts +1 -0
- package/dist/decorators/controller.decorator.js +11 -0
- package/dist/decorators/field.decorators.d.ts +71 -0
- package/dist/decorators/field.decorators.js +449 -0
- package/dist/decorators/http.decorators.d.ts +3 -0
- package/dist/decorators/http.decorators.js +8 -0
- package/dist/decorators/index.d.ts +12 -0
- package/dist/decorators/index.js +28 -0
- package/dist/decorators/omni-auth.decorator.d.ts +8 -0
- package/dist/decorators/omni-auth.decorator.js +35 -0
- package/dist/decorators/operation.decorator.d.ts +1 -0
- package/dist/decorators/operation.decorator.js +6 -0
- package/dist/decorators/property.decorators.d.ts +15 -0
- package/dist/decorators/property.decorators.js +32 -0
- package/dist/decorators/public-route.decorator.d.ts +3 -0
- package/dist/decorators/public-route.decorator.js +7 -0
- package/dist/decorators/swagger.schema.d.ts +5 -0
- package/dist/decorators/swagger.schema.js +79 -0
- package/dist/decorators/timestamp-column.decorator.d.ts +1 -0
- package/dist/decorators/timestamp-column.decorator.js +28 -0
- package/dist/decorators/transform.decorators.d.ts +8 -0
- package/dist/decorators/transform.decorators.js +95 -0
- package/dist/decorators/translate.decorator.d.ts +5 -0
- package/dist/decorators/translate.decorator.js +17 -0
- package/dist/decorators/use-dto.decorator.d.ts +4 -0
- package/dist/decorators/use-dto.decorator.js +9 -0
- package/dist/decorators/user-check.decorator.d.ts +6 -0
- package/dist/decorators/user-check.decorator.js +21 -0
- package/dist/decorators/user.decorator.d.ts +8 -0
- package/dist/decorators/user.decorator.js +38 -0
- package/dist/decorators/user_auth.decorator.d.ts +1 -0
- package/dist/decorators/user_auth.decorator.js +16 -0
- package/dist/decorators/validator.decorators.d.ts +10 -0
- package/dist/decorators/validator.decorators.js +59 -0
- package/dist/exceptions/file-not-image.exception.d.ts +4 -0
- package/dist/exceptions/file-not-image.exception.js +10 -0
- package/dist/exceptions/index.d.ts +2 -0
- package/dist/exceptions/index.js +18 -0
- package/dist/exceptions/page-type.exception.d.ts +4 -0
- package/dist/exceptions/page-type.exception.js +10 -0
- package/dist/exceptions/user-not-found.exception.d.ts +4 -0
- package/dist/exceptions/user-not-found.exception.js +10 -0
- package/dist/filters/bad-request.filter.d.ts +5 -0
- package/dist/filters/bad-request.filter.js +60 -0
- package/dist/filters/constraint-errors.d.ts +1 -0
- package/dist/filters/constraint-errors.js +6 -0
- package/dist/filters/index.d.ts +3 -0
- package/dist/filters/index.js +19 -0
- package/dist/filters/query-failed.filter.d.ts +10 -0
- package/dist/filters/query-failed.filter.js +42 -0
- package/dist/health-checker/health-checker.controller.d.ts +15 -0
- package/dist/health-checker/health-checker.controller.js +72 -0
- package/dist/health-checker/health-checker.module.d.ts +2 -0
- package/dist/health-checker/health-checker.module.js +25 -0
- package/dist/health-checker/health-indicators/service.indicator.d.ts +8 -0
- package/dist/health-checker/health-indicators/service.indicator.js +66 -0
- package/dist/helpers/common.helper.d.ts +3 -0
- package/dist/helpers/common.helper.js +36 -0
- package/dist/helpers/date.helper.d.ts +10 -0
- package/dist/helpers/date.helper.js +58 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.js +19 -0
- package/dist/i18n/en_US/validation.json +38 -0
- package/dist/i18n/zh_CN/validation.json +38 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +27 -0
- package/dist/interceptors/auth-user.interceptor.d.ts +4 -0
- package/dist/interceptors/auth-user.interceptor.js +24 -0
- package/dist/interceptors/index.d.ts +2 -0
- package/dist/interceptors/index.js +18 -0
- package/dist/interceptors/language-interceptor.service.d.ts +6 -0
- package/dist/interceptors/language-interceptor.service.js +30 -0
- package/dist/interceptors/translation-interceptor.service.d.ts +5 -0
- package/dist/interceptors/translation-interceptor.service.js +34 -0
- package/dist/interfaces/IApiFile.d.ts +4 -0
- package/dist/interfaces/IApiFile.js +2 -0
- package/dist/interfaces/IFile.d.ts +9 -0
- package/dist/interfaces/IFile.js +2 -0
- package/dist/interfaces/ITranslationDecoratorInterface.d.ts +3 -0
- package/dist/interfaces/ITranslationDecoratorInterface.js +2 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/index.js +19 -0
- package/dist/interfaces/response.d.ts +25 -0
- package/dist/interfaces/response.js +2 -0
- package/dist/middlewares/index.d.ts +3 -0
- package/dist/middlewares/index.js +19 -0
- package/dist/middlewares/omni-auth.middleware.d.ts +1 -0
- package/dist/middlewares/omni-auth.middleware.js +13 -0
- package/dist/middlewares/powerby.middleware.d.ts +1 -0
- package/dist/middlewares/powerby.middleware.js +10 -0
- package/dist/middlewares/request-id.middleware.d.ts +7 -0
- package/dist/middlewares/request-id.middleware.js +22 -0
- package/dist/providers/context.provider.d.ts +32 -0
- package/dist/providers/context.provider.js +71 -0
- package/dist/providers/generator.provider.d.ts +9 -0
- package/dist/providers/generator.provider.js +50 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +18 -0
- package/dist/setup/bootstrap.setup.d.ts +5 -0
- package/dist/setup/bootstrap.setup.js +112 -0
- package/dist/setup/index.d.ts +1 -0
- package/dist/setup/index.js +17 -0
- package/dist/setup-swagger.d.ts +2 -0
- package/dist/setup-swagger.js +62 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/index.js +18 -0
- package/dist/shared/serviceRegistryModule.d.ts +2 -0
- package/dist/shared/serviceRegistryModule.js +110 -0
- package/dist/shared/services/api-config.service.d.ts +70 -0
- package/dist/shared/services/api-config.service.js +290 -0
- package/dist/shared/services/aws-s3.service.d.ts +10 -0
- package/dist/shared/services/aws-s3.service.js +56 -0
- package/dist/shared/services/generator.service.d.ts +4 -0
- package/dist/shared/services/generator.service.js +23 -0
- package/dist/shared/services/index.d.ts +5 -0
- package/dist/shared/services/index.js +21 -0
- package/dist/shared/services/translation.service.d.ts +9 -0
- package/dist/shared/services/translation.service.js +70 -0
- package/dist/shared/services/validator.service.d.ts +3 -0
- package/dist/shared/services/validator.service.js +20 -0
- package/dist/snake-naming.strategy.d.ts +11 -0
- package/dist/snake-naming.strategy.js +37 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.js +2 -0
- package/dist/validators/file-mimetype.validator.d.ts +13 -0
- package/dist/validators/file-mimetype.validator.js +21 -0
- package/dist/validators/index.d.ts +3 -0
- package/dist/validators/index.js +19 -0
- package/dist/validators/is-exists.validator.d.ts +18 -0
- package/dist/validators/is-exists.validator.js +61 -0
- package/dist/validators/is-unique.validator.d.ts +17 -0
- package/dist/validators/is-unique.validator.js +92 -0
- package/dist/validators/phone-country-code.validator.d.ts +2 -0
- package/dist/validators/phone-country-code.validator.js +30 -0
- package/dist/validators/same-as.validator.d.ts +2 -0
- package/dist/validators/same-as.validator.js +25 -0
- package/dist/validators/skip-empty.validator.d.ts +1 -0
- package/dist/validators/skip-empty.validator.js +18 -0
- package/package.json +1 -1
- package/tsconfig.json +6 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
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-config.service"), exports);
|
|
18
|
+
__exportStar(require("./aws-s3.service"), exports);
|
|
19
|
+
__exportStar(require("./generator.service"), exports);
|
|
20
|
+
__exportStar(require("./translation.service"), exports);
|
|
21
|
+
__exportStar(require("./validator.service"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TranslateOptions } from 'nestjs-i18n';
|
|
2
|
+
import { I18nService } from 'nestjs-i18n';
|
|
3
|
+
import { AbstractDto } from '../../common/dto/abstract.dto';
|
|
4
|
+
export declare class TranslationService {
|
|
5
|
+
private readonly i18n;
|
|
6
|
+
constructor(i18n: I18nService);
|
|
7
|
+
translate(key: string, options?: TranslateOptions): Promise<string>;
|
|
8
|
+
translateNecessaryKeys<T extends AbstractDto>(dto: T): Promise<T>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.TranslationService = void 0;
|
|
22
|
+
const common_1 = require("@nestjs/common");
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
24
|
+
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
25
|
+
const abstract_dto_1 = require("../../common/dto/abstract.dto");
|
|
26
|
+
const decorators_1 = require("../../decorators");
|
|
27
|
+
const providers_1 = require("../../providers");
|
|
28
|
+
let TranslationService = class TranslationService {
|
|
29
|
+
constructor(i18n) {
|
|
30
|
+
this.i18n = i18n;
|
|
31
|
+
}
|
|
32
|
+
translate(key, options) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return this.i18n.translate(`${key}`, Object.assign(Object.assign({}, options), { lang: providers_1.ContextProvider.getLanguage() }));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
translateNecessaryKeys(dto) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
if ((0, lodash_1.isString)(dto)) {
|
|
40
|
+
return dto;
|
|
41
|
+
}
|
|
42
|
+
yield Promise.all((0, lodash_1.map)(dto, (value, key) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
var _a;
|
|
44
|
+
if ((0, lodash_1.isString)(value)) {
|
|
45
|
+
const translateDec = Reflect.getMetadata(decorators_1.STATIC_TRANSLATION_DECORATOR_KEY, dto, key);
|
|
46
|
+
if (translateDec) {
|
|
47
|
+
return this.translate(`${(_a = translateDec.translationKey) !== null && _a !== void 0 ? _a : key}.${value}`);
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (value instanceof abstract_dto_1.AbstractDto) {
|
|
52
|
+
return this.translateNecessaryKeys(value);
|
|
53
|
+
}
|
|
54
|
+
if ((0, lodash_1.isArray)(value)) {
|
|
55
|
+
return Promise.all((0, lodash_1.map)(value, (v) => {
|
|
56
|
+
if (v instanceof abstract_dto_1.AbstractDto) {
|
|
57
|
+
return this.translateNecessaryKeys(v);
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
})));
|
|
62
|
+
return dto;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
exports.TranslationService = TranslationService;
|
|
67
|
+
exports.TranslationService = TranslationService = __decorate([
|
|
68
|
+
(0, common_1.Injectable)(),
|
|
69
|
+
__metadata("design:paramtypes", [nestjs_i18n_1.I18nService])
|
|
70
|
+
], TranslationService);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ValidatorService = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
let ValidatorService = class ValidatorService {
|
|
12
|
+
isImage(mimeType) {
|
|
13
|
+
const imageMimeTypes = ['image/jpeg', 'image/png'];
|
|
14
|
+
return imageMimeTypes.includes(mimeType);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.ValidatorService = ValidatorService;
|
|
18
|
+
exports.ValidatorService = ValidatorService = __decorate([
|
|
19
|
+
(0, common_1.Injectable)()
|
|
20
|
+
], ValidatorService);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { NamingStrategyInterface } from 'typeorm';
|
|
2
|
+
import { DefaultNamingStrategy } from 'typeorm';
|
|
3
|
+
export declare class SnakeNamingStrategy extends DefaultNamingStrategy implements NamingStrategyInterface {
|
|
4
|
+
tableName(className: string, customName: string | undefined): string;
|
|
5
|
+
columnName(propertyName: string, customName: string | undefined, embeddedPrefixes: string[]): string;
|
|
6
|
+
relationName(propertyName: string): string;
|
|
7
|
+
joinColumnName(relationName: string, referencedColumnName: string): string;
|
|
8
|
+
joinTableName(firstTableName: string, secondTableName: string, firstPropertyName: string, _secondPropertyName: string): string;
|
|
9
|
+
joinTableColumnName(tableName: string, propertyName: string, columnName?: string): string;
|
|
10
|
+
classTableInheritanceParentColumnName(parentTableName: string, parentTableIdPropertyName: string): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnakeNamingStrategy = void 0;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
const StringUtils_1 = require("typeorm/util/StringUtils");
|
|
6
|
+
class SnakeNamingStrategy extends typeorm_1.DefaultNamingStrategy {
|
|
7
|
+
tableName(className, customName) {
|
|
8
|
+
if (className.includes('Entity')) {
|
|
9
|
+
className = className.replace('Entity', '');
|
|
10
|
+
}
|
|
11
|
+
return customName !== null && customName !== void 0 ? customName : (0, StringUtils_1.snakeCase)(className);
|
|
12
|
+
}
|
|
13
|
+
columnName(propertyName, customName, embeddedPrefixes) {
|
|
14
|
+
return ((0, StringUtils_1.snakeCase)(embeddedPrefixes.join('_')) +
|
|
15
|
+
(customName !== null && customName !== void 0 ? customName : (0, StringUtils_1.snakeCase)(propertyName)));
|
|
16
|
+
}
|
|
17
|
+
relationName(propertyName) {
|
|
18
|
+
return (0, StringUtils_1.snakeCase)(propertyName);
|
|
19
|
+
}
|
|
20
|
+
joinColumnName(relationName, referencedColumnName) {
|
|
21
|
+
return (0, StringUtils_1.snakeCase)(relationName + '_' + referencedColumnName);
|
|
22
|
+
}
|
|
23
|
+
joinTableName(firstTableName, secondTableName, firstPropertyName, _secondPropertyName) {
|
|
24
|
+
return (0, StringUtils_1.snakeCase)(firstTableName +
|
|
25
|
+
'_' +
|
|
26
|
+
firstPropertyName.replace(/\./gi, '_') +
|
|
27
|
+
'_' +
|
|
28
|
+
secondTableName);
|
|
29
|
+
}
|
|
30
|
+
joinTableColumnName(tableName, propertyName, columnName) {
|
|
31
|
+
return (0, StringUtils_1.snakeCase)(tableName + '_' + (columnName !== null && columnName !== void 0 ? columnName : propertyName));
|
|
32
|
+
}
|
|
33
|
+
classTableInheritanceParentColumnName(parentTableName, parentTableIdPropertyName) {
|
|
34
|
+
return (0, StringUtils_1.snakeCase)(`${parentTableName}_${parentTableIdPropertyName}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.SnakeNamingStrategy = SnakeNamingStrategy;
|