@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,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
46
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
47
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.AwsS3Service = void 0;
|
|
54
|
-
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
55
|
-
const common_1 = require("@nestjs/common");
|
|
56
|
-
const mime_types_1 = __importDefault(require("mime-types"));
|
|
57
|
-
let AwsS3Service = (() => {
|
|
58
|
-
let _classDecorators = [(0, common_1.Injectable)()];
|
|
59
|
-
let _classDescriptor;
|
|
60
|
-
let _classExtraInitializers = [];
|
|
61
|
-
let _classThis;
|
|
62
|
-
var AwsS3Service = _classThis = class {
|
|
63
|
-
constructor(configService, generatorService) {
|
|
64
|
-
this.configService = configService;
|
|
65
|
-
this.generatorService = generatorService;
|
|
66
|
-
const awsS3Config = configService.awsS3Config;
|
|
67
|
-
this.s3 = new client_s3_1.S3({
|
|
68
|
-
apiVersion: awsS3Config.bucketApiVersion,
|
|
69
|
-
region: awsS3Config.bucketRegion,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
uploadImage(file) {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
const fileName = this.generatorService.fileName(mime_types_1.default.extension(file.mimetype));
|
|
75
|
-
const key = 'images/' + fileName;
|
|
76
|
-
yield this.s3.putObject({
|
|
77
|
-
Bucket: this.configService.awsS3Config.bucketName,
|
|
78
|
-
Body: file.buffer,
|
|
79
|
-
ACL: 'public-read',
|
|
80
|
-
Key: key,
|
|
81
|
-
});
|
|
82
|
-
return key;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
__setFunctionName(_classThis, "AwsS3Service");
|
|
87
|
-
(() => {
|
|
88
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
89
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
90
|
-
AwsS3Service = _classThis = _classDescriptor.value;
|
|
91
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
92
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
93
|
-
})();
|
|
94
|
-
return AwsS3Service = _classThis;
|
|
95
|
-
})();
|
|
96
|
-
exports.AwsS3Service = AwsS3Service;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { S3 } from '@aws-sdk/client-s3';
|
|
2
|
-
import { Injectable } from '@nestjs/common';
|
|
3
|
-
import mime from 'mime-types';
|
|
4
|
-
|
|
5
|
-
import type { IFile } from '../../interfaces';
|
|
6
|
-
import { ApiConfigService } from './api-config.service';
|
|
7
|
-
import { GeneratorService } from './generator.service';
|
|
8
|
-
|
|
9
|
-
@Injectable()
|
|
10
|
-
export class AwsS3Service {
|
|
11
|
-
private readonly s3: S3;
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
14
|
-
public configService: ApiConfigService,
|
|
15
|
-
public generatorService: GeneratorService,
|
|
16
|
-
) {
|
|
17
|
-
const awsS3Config = configService.awsS3Config;
|
|
18
|
-
|
|
19
|
-
this.s3 = new S3({
|
|
20
|
-
apiVersion: awsS3Config.bucketApiVersion,
|
|
21
|
-
region: awsS3Config.bucketRegion,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async uploadImage(file: IFile): Promise<string> {
|
|
26
|
-
const fileName = this.generatorService.fileName(
|
|
27
|
-
<string>mime.extension(file.mimetype),
|
|
28
|
-
);
|
|
29
|
-
const key = 'images/' + fileName;
|
|
30
|
-
await this.s3.putObject({
|
|
31
|
-
Bucket: this.configService.awsS3Config.bucketName,
|
|
32
|
-
Body: file.buffer,
|
|
33
|
-
ACL: 'public-read',
|
|
34
|
-
Key: key,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return key;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
-
};
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.GeneratorService = void 0;
|
|
42
|
-
const common_1 = require("@nestjs/common");
|
|
43
|
-
const uuid_1 = require("uuid");
|
|
44
|
-
let GeneratorService = (() => {
|
|
45
|
-
let _classDecorators = [(0, common_1.Injectable)()];
|
|
46
|
-
let _classDescriptor;
|
|
47
|
-
let _classExtraInitializers = [];
|
|
48
|
-
let _classThis;
|
|
49
|
-
var GeneratorService = _classThis = class {
|
|
50
|
-
uuid() {
|
|
51
|
-
return (0, uuid_1.v1)();
|
|
52
|
-
}
|
|
53
|
-
fileName(ext) {
|
|
54
|
-
return this.uuid() + '.' + ext;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
__setFunctionName(_classThis, "GeneratorService");
|
|
58
|
-
(() => {
|
|
59
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
60
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
61
|
-
GeneratorService = _classThis = _classDescriptor.value;
|
|
62
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
63
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
64
|
-
})();
|
|
65
|
-
return GeneratorService = _classThis;
|
|
66
|
-
})();
|
|
67
|
-
exports.GeneratorService = GeneratorService;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { v1 as uuid } from 'uuid';
|
|
3
|
-
|
|
4
|
-
@Injectable()
|
|
5
|
-
export class GeneratorService {
|
|
6
|
-
public uuid(): string {
|
|
7
|
-
return uuid();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public fileName(ext: string): string {
|
|
11
|
-
return this.uuid() + '.' + ext;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,21 +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-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);
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
46
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
47
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.TranslationService = void 0;
|
|
51
|
-
const common_1 = require("@nestjs/common");
|
|
52
|
-
const lodash_1 = require("lodash");
|
|
53
|
-
const abstract_dto_1 = require("../../common/dto/abstract.dto");
|
|
54
|
-
const decorators_1 = require("../../decorators");
|
|
55
|
-
const providers_1 = require("../../providers");
|
|
56
|
-
let TranslationService = (() => {
|
|
57
|
-
let _classDecorators = [(0, common_1.Injectable)()];
|
|
58
|
-
let _classDescriptor;
|
|
59
|
-
let _classExtraInitializers = [];
|
|
60
|
-
let _classThis;
|
|
61
|
-
var TranslationService = _classThis = class {
|
|
62
|
-
constructor(i18n) {
|
|
63
|
-
this.i18n = i18n;
|
|
64
|
-
}
|
|
65
|
-
translate(key, options) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
return this.i18n.translate(`${key}`, Object.assign(Object.assign({}, options), { lang: providers_1.ContextProvider.getLanguage() }));
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
translateNecessaryKeys(dto) {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
if ((0, lodash_1.isString)(dto)) {
|
|
73
|
-
return dto;
|
|
74
|
-
}
|
|
75
|
-
yield Promise.all((0, lodash_1.map)(dto, (value, key) => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
var _a;
|
|
77
|
-
if ((0, lodash_1.isString)(value)) {
|
|
78
|
-
const translateDec = Reflect.getMetadata(decorators_1.STATIC_TRANSLATION_DECORATOR_KEY, dto, key);
|
|
79
|
-
if (translateDec) {
|
|
80
|
-
return this.translate(`${(_a = translateDec.translationKey) !== null && _a !== void 0 ? _a : key}.${value}`);
|
|
81
|
-
}
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
if (value instanceof abstract_dto_1.AbstractDto) {
|
|
85
|
-
return this.translateNecessaryKeys(value);
|
|
86
|
-
}
|
|
87
|
-
if ((0, lodash_1.isArray)(value)) {
|
|
88
|
-
return Promise.all((0, lodash_1.map)(value, (v) => {
|
|
89
|
-
if (v instanceof abstract_dto_1.AbstractDto) {
|
|
90
|
-
return this.translateNecessaryKeys(v);
|
|
91
|
-
}
|
|
92
|
-
}));
|
|
93
|
-
}
|
|
94
|
-
})));
|
|
95
|
-
return dto;
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
__setFunctionName(_classThis, "TranslationService");
|
|
100
|
-
(() => {
|
|
101
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
102
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
103
|
-
TranslationService = _classThis = _classDescriptor.value;
|
|
104
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
105
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
106
|
-
})();
|
|
107
|
-
return TranslationService = _classThis;
|
|
108
|
-
})();
|
|
109
|
-
exports.TranslationService = TranslationService;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { isArray, isString, map } from 'lodash';
|
|
3
|
-
import type { TranslateOptions } from 'nestjs-i18n';
|
|
4
|
-
import { I18nService } from 'nestjs-i18n';
|
|
5
|
-
|
|
6
|
-
import { AbstractDto } from '../../common/dto/abstract.dto';
|
|
7
|
-
import { STATIC_TRANSLATION_DECORATOR_KEY } from '../../decorators';
|
|
8
|
-
import type { ITranslationDecoratorInterface } from '../../interfaces';
|
|
9
|
-
import { ContextProvider } from '../../providers';
|
|
10
|
-
|
|
11
|
-
@Injectable()
|
|
12
|
-
export class TranslationService {
|
|
13
|
-
constructor(private readonly i18n: I18nService) {}
|
|
14
|
-
|
|
15
|
-
async translate(key: string, options?: TranslateOptions): Promise<string> {
|
|
16
|
-
return this.i18n.translate(`${key}`, {
|
|
17
|
-
...options,
|
|
18
|
-
lang: ContextProvider.getLanguage(),
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async translateNecessaryKeys<T extends AbstractDto>(dto: T): Promise<T> {
|
|
23
|
-
if (isString(dto)) {
|
|
24
|
-
return dto;
|
|
25
|
-
}
|
|
26
|
-
await Promise.all(
|
|
27
|
-
map(dto, async (value, key) => {
|
|
28
|
-
if (isString(value)) {
|
|
29
|
-
const translateDec: ITranslationDecoratorInterface | undefined =
|
|
30
|
-
Reflect.getMetadata(STATIC_TRANSLATION_DECORATOR_KEY, dto, key);
|
|
31
|
-
|
|
32
|
-
if (translateDec) {
|
|
33
|
-
return this.translate(
|
|
34
|
-
`${translateDec.translationKey ?? key}.${value}`,
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (value instanceof AbstractDto) {
|
|
42
|
-
return this.translateNecessaryKeys(value);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (isArray(value)) {
|
|
46
|
-
return Promise.all(
|
|
47
|
-
map(value, (v) => {
|
|
48
|
-
if (v instanceof AbstractDto) {
|
|
49
|
-
return this.translateNecessaryKeys(v);
|
|
50
|
-
}
|
|
51
|
-
}),
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
}),
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
return dto;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
-
};
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.ValidatorService = void 0;
|
|
42
|
-
const common_1 = require("@nestjs/common");
|
|
43
|
-
let ValidatorService = (() => {
|
|
44
|
-
let _classDecorators = [(0, common_1.Injectable)()];
|
|
45
|
-
let _classDescriptor;
|
|
46
|
-
let _classExtraInitializers = [];
|
|
47
|
-
let _classThis;
|
|
48
|
-
var ValidatorService = _classThis = class {
|
|
49
|
-
isImage(mimeType) {
|
|
50
|
-
const imageMimeTypes = ['image/jpeg', 'image/png'];
|
|
51
|
-
return imageMimeTypes.includes(mimeType);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
__setFunctionName(_classThis, "ValidatorService");
|
|
55
|
-
(() => {
|
|
56
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
57
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
58
|
-
ValidatorService = _classThis = _classDescriptor.value;
|
|
59
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
60
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
61
|
-
})();
|
|
62
|
-
return ValidatorService = _classThis;
|
|
63
|
-
})();
|
|
64
|
-
exports.ValidatorService = ValidatorService;
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
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;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { NamingStrategyInterface } from 'typeorm';
|
|
2
|
-
import { DefaultNamingStrategy } from 'typeorm';
|
|
3
|
-
import { snakeCase } from 'typeorm/util/StringUtils';
|
|
4
|
-
|
|
5
|
-
export class SnakeNamingStrategy
|
|
6
|
-
extends DefaultNamingStrategy
|
|
7
|
-
implements NamingStrategyInterface
|
|
8
|
-
{
|
|
9
|
-
tableName(className: string, customName: string | undefined): string {
|
|
10
|
-
if (className.includes('Entity')) {
|
|
11
|
-
className = className.replace('Entity', '');
|
|
12
|
-
}
|
|
13
|
-
return customName ?? snakeCase(className);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
columnName(
|
|
17
|
-
propertyName: string,
|
|
18
|
-
customName: string | undefined,
|
|
19
|
-
embeddedPrefixes: string[],
|
|
20
|
-
): string {
|
|
21
|
-
return (
|
|
22
|
-
snakeCase(embeddedPrefixes.join('_')) +
|
|
23
|
-
(customName ?? snakeCase(propertyName))
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
relationName(propertyName: string): string {
|
|
28
|
-
return snakeCase(propertyName);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
joinColumnName(relationName: string, referencedColumnName: string): string {
|
|
32
|
-
return snakeCase(relationName + '_' + referencedColumnName);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
joinTableName(
|
|
36
|
-
firstTableName: string,
|
|
37
|
-
secondTableName: string,
|
|
38
|
-
firstPropertyName: string,
|
|
39
|
-
_secondPropertyName: string,
|
|
40
|
-
): string {
|
|
41
|
-
return snakeCase(
|
|
42
|
-
firstTableName +
|
|
43
|
-
'_' +
|
|
44
|
-
firstPropertyName.replace(/\./gi, '_') +
|
|
45
|
-
'_' +
|
|
46
|
-
secondTableName,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
joinTableColumnName(
|
|
51
|
-
tableName: string,
|
|
52
|
-
propertyName: string,
|
|
53
|
-
columnName?: string,
|
|
54
|
-
): string {
|
|
55
|
-
return snakeCase(tableName + '_' + (columnName ?? propertyName));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
classTableInheritanceParentColumnName(
|
|
59
|
-
parentTableName: string,
|
|
60
|
-
parentTableIdPropertyName: string,
|
|
61
|
-
): string {
|
|
62
|
-
return snakeCase(`${parentTableName}_${parentTableIdPropertyName}`);
|
|
63
|
-
}
|
|
64
|
-
}
|
package/src/types.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type Constructor<T, Arguments extends unknown[] = undefined[]> = new (...arguments_: Arguments) => T;
|
|
2
|
-
export type Plain<T> = T;
|
|
3
|
-
export type PathImpl<T, Key extends keyof T> = Key extends string ? T[Key] extends Record<string, any> ? `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> & string}` | `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : never : never;
|
|
4
|
-
export type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
|
|
5
|
-
export type Path<T> = keyof T extends string ? PathImpl2<T> extends string | keyof T ? PathImpl2<T> : keyof T : never;
|
|
6
|
-
export type PathValue<T, P extends Path<T>> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends Path<T[Key]> ? PathValue<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
|
|
7
|
-
export type KeyOfType<Entity, U> = {
|
|
8
|
-
[P in keyof Required<Entity>]: Required<Entity>[P] extends U ? P : Required<Entity>[P] extends U[] ? P : never;
|
|
9
|
-
}[keyof Entity];
|
package/src/types.js
DELETED