@nest-omni/core 3.1.1-9 → 3.1.1
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/.hygen/new/crud/controller.ejs.t +82 -0
- package/.hygen/new/crud/create.dto.ejs.t +12 -0
- package/.hygen/new/crud/entity.ejs.t +26 -0
- package/.hygen/new/crud/get.dto.ejs.t +19 -0
- package/.hygen/new/crud/index-dto.ejs.t +29 -0
- package/.hygen/new/crud/index-response.dto.ejs.t +18 -0
- package/.hygen/new/crud/module.ejs.t +32 -0
- package/.hygen/new/crud/prompt.js +89 -0
- package/.hygen/new/crud/service.ejs.t +76 -0
- package/.hygen/new/crud/update.dto.ejs.t +11 -0
- package/.hygen/new/module/controller.ejs.t +93 -0
- package/.hygen/new/module/create-command.ejs.t +90 -0
- package/.hygen/new/module/create.dto.ejs.t +11 -0
- package/.hygen/new/module/dto.ejs.t +24 -0
- package/.hygen/new/module/entity.ejs.t +33 -0
- package/.hygen/new/module/get-query.ejs.t +57 -0
- package/.hygen/new/module/module.ejs.t +44 -0
- package/.hygen/new/module/not-found.exception.ejs.t +18 -0
- package/.hygen/new/module/page-options.dto.ejs.t +12 -0
- package/.hygen/new/module/prompt.js +104 -0
- package/.hygen/new/module/repository.ejs.t +16 -0
- package/.hygen/new/module/service.ejs.t +139 -0
- package/.hygen/new/module/translation-dto.ejs.t +27 -0
- package/.hygen/new/module/translation-entity.ejs.t +40 -0
- package/.hygen/new/module/translation-repository.ejs.t +16 -0
- package/.hygen/new/module/update.dto.ejs.t +10 -0
- package/.hygen.js +116 -0
- package/cache/cache-metrics.service.d.ts +83 -0
- package/cache/cache-metrics.service.js +298 -0
- package/cache/cache-serialization.service.d.ts +22 -0
- package/cache/cache-serialization.service.js +122 -0
- package/cache/cache.constants.d.ts +2 -0
- package/cache/cache.constants.js +5 -0
- package/cache/cache.health.d.ts +35 -0
- package/cache/cache.health.js +193 -0
- package/cache/cache.module.d.ts +26 -0
- package/cache/cache.module.js +155 -0
- package/cache/cache.service.d.ts +37 -0
- package/cache/cache.service.js +308 -0
- package/cache/cache.warmup.service.d.ts +34 -0
- package/cache/cache.warmup.service.js +199 -0
- package/cache/decorators/cache-evict.decorator.d.ts +2 -0
- package/cache/decorators/cache-evict.decorator.js +72 -0
- package/cache/decorators/cache-put.decorator.d.ts +2 -0
- package/cache/decorators/cache-put.decorator.js +48 -0
- package/cache/decorators/cacheable.decorator.d.ts +4 -0
- package/cache/decorators/cacheable.decorator.js +68 -0
- package/cache/decorators/index.d.ts +3 -0
- package/cache/decorators/index.js +11 -0
- package/cache/dependencies/callback.dependency.d.ts +11 -0
- package/cache/dependencies/callback.dependency.js +92 -0
- package/cache/dependencies/chain.dependency.d.ts +20 -0
- package/cache/dependencies/chain.dependency.js +113 -0
- package/cache/dependencies/db.dependency.d.ts +15 -0
- package/cache/dependencies/db.dependency.js +71 -0
- package/cache/dependencies/file.dependency.d.ts +17 -0
- package/cache/dependencies/file.dependency.js +63 -0
- package/cache/dependencies/index.d.ts +6 -0
- package/cache/dependencies/index.js +22 -0
- package/cache/dependencies/tag.dependency.d.ts +16 -0
- package/cache/dependencies/tag.dependency.js +75 -0
- package/cache/dependencies/time.dependency.d.ts +19 -0
- package/cache/dependencies/time.dependency.js +71 -0
- package/cache/examples/basic-usage.d.ts +58 -0
- package/cache/examples/basic-usage.js +379 -0
- package/cache/index.d.ts +15 -0
- package/cache/index.js +44 -0
- package/cache/interfaces/cache-dependency.interface.d.ts +11 -0
- package/cache/interfaces/cache-dependency.interface.js +2 -0
- package/cache/interfaces/cache-options.interface.d.ts +32 -0
- package/cache/interfaces/cache-options.interface.js +9 -0
- package/cache/interfaces/cache-provider.interface.d.ts +28 -0
- package/cache/interfaces/cache-provider.interface.js +2 -0
- package/cache/interfaces/index.d.ts +3 -0
- package/cache/interfaces/index.js +19 -0
- package/cache/providers/base-cache.provider.d.ts +16 -0
- package/cache/providers/base-cache.provider.js +32 -0
- package/cache/providers/cls-cache.provider.d.ts +16 -0
- package/cache/providers/cls-cache.provider.js +140 -0
- package/cache/providers/index.d.ts +4 -0
- package/cache/providers/index.js +23 -0
- package/cache/providers/memory-cache.provider.d.ts +26 -0
- package/cache/providers/memory-cache.provider.js +171 -0
- package/cache/providers/redis-cache.provider.d.ts +23 -0
- package/cache/providers/redis-cache.provider.js +215 -0
- package/cache/utils/dependency-manager.util.d.ts +15 -0
- package/cache/utils/dependency-manager.util.js +141 -0
- package/cache/utils/index.d.ts +2 -0
- package/cache/utils/index.js +18 -0
- package/cache/utils/key-generator.util.d.ts +13 -0
- package/cache/utils/key-generator.util.js +74 -0
- package/common/abstract.entity.d.ts +20 -0
- package/common/abstract.entity.js +81 -0
- package/common/boilerplate.polyfill.d.ts +50 -0
- package/common/boilerplate.polyfill.js +152 -0
- package/common/dto/abstract.dto.d.ts +13 -0
- package/common/dto/abstract.dto.js +59 -0
- package/common/dto/bulk-id.dto.d.ts +3 -0
- package/common/dto/bulk-id.dto.js +27 -0
- package/common/dto/create-translation.dto.d.ts +5 -0
- package/common/dto/create-translation.dto.js +25 -0
- package/common/dto/dto-container.d.ts +9 -0
- package/common/dto/dto-container.js +59 -0
- package/common/dto/dto-decorators.d.ts +18 -0
- package/common/dto/dto-decorators.js +59 -0
- package/common/dto/dto-extensions.d.ts +12 -0
- package/common/dto/dto-extensions.js +63 -0
- package/common/dto/dto-service-accessor.d.ts +7 -0
- package/common/dto/dto-service-accessor.js +49 -0
- package/common/dto/dto-transformer.d.ts +11 -0
- package/common/dto/dto-transformer.js +49 -0
- package/common/dto/index.d.ts +12 -0
- package/common/dto/index.js +28 -0
- package/common/dto/page-meta.dto.d.ts +15 -0
- package/common/dto/page-meta.dto.js +48 -0
- package/common/dto/page-options.dto.d.ts +5 -0
- package/common/dto/page-options.dto.js +40 -0
- package/common/dto/page.dto.d.ts +11 -0
- package/common/dto/page.dto.js +53 -0
- package/common/examples/paginate-and-map.example.d.ts +14 -0
- package/common/examples/paginate-and-map.example.js +158 -0
- package/common/index.d.ts +6 -0
- package/common/index.js +22 -0
- package/common/snake-naming.strategy.d.ts +11 -0
- package/common/snake-naming.strategy.js +37 -0
- package/common/types.d.ts +9 -0
- package/common/types.js +2 -0
- package/common/utils.d.ts +3 -0
- package/common/utils.js +24 -0
- package/constants/index.d.ts +2 -0
- package/constants/index.js +18 -0
- package/constants/language-code.d.ts +5 -0
- package/constants/language-code.js +9 -0
- package/constants/order.d.ts +4 -0
- package/constants/order.js +8 -0
- package/decorators/api-page-ok-response.decorator.d.ts +5 -0
- package/decorators/api-page-ok-response.decorator.js +24 -0
- package/decorators/auth-user.decorator.d.ts +1 -0
- package/decorators/auth-user.decorator.js +14 -0
- package/decorators/controller.decorator.d.ts +1 -0
- package/decorators/controller.decorator.js +10 -0
- package/decorators/examples/validation-decorators.example.d.ts +69 -0
- package/decorators/examples/validation-decorators.example.js +331 -0
- package/decorators/field.decorators.d.ts +79 -0
- package/decorators/field.decorators.js +499 -0
- package/decorators/http.decorators.d.ts +3 -0
- package/decorators/http.decorators.js +7 -0
- package/decorators/index.d.ts +12 -0
- package/decorators/index.js +28 -0
- package/decorators/operation.decorator.d.ts +1 -0
- package/decorators/operation.decorator.js +6 -0
- package/decorators/property.decorators.d.ts +15 -0
- package/decorators/property.decorators.js +31 -0
- package/decorators/public-route.decorator.d.ts +3 -0
- package/decorators/public-route.decorator.js +7 -0
- package/decorators/swagger.schema.d.ts +5 -0
- package/decorators/swagger.schema.js +78 -0
- package/decorators/timestamp-column.decorator.d.ts +1 -0
- package/decorators/timestamp-column.decorator.js +27 -0
- package/decorators/transform.decorators.d.ts +8 -0
- package/decorators/transform.decorators.js +100 -0
- package/decorators/translate.decorator.d.ts +5 -0
- package/decorators/translate.decorator.js +17 -0
- package/decorators/use-dto.decorator.d.ts +4 -0
- package/decorators/use-dto.decorator.js +8 -0
- package/decorators/user-check.decorator.d.ts +6 -0
- package/decorators/user-check.decorator.js +21 -0
- package/decorators/user.decorator.d.ts +12 -0
- package/decorators/user.decorator.js +44 -0
- package/decorators/user_auth.decorator.d.ts +1 -0
- package/decorators/user_auth.decorator.js +15 -0
- package/decorators/validator.decorators.d.ts +18 -0
- package/decorators/validator.decorators.js +193 -0
- package/exceptions/file-not-image.exception.d.ts +4 -0
- package/exceptions/file-not-image.exception.js +10 -0
- package/exceptions/index.d.ts +2 -0
- package/exceptions/index.js +18 -0
- package/exceptions/page-type.exception.d.ts +4 -0
- package/exceptions/page-type.exception.js +10 -0
- package/exceptions/user-not-found.exception.d.ts +4 -0
- package/exceptions/user-not-found.exception.js +10 -0
- package/filters/bad-request.filter.d.ts +5 -0
- package/filters/bad-request.filter.js +71 -0
- package/filters/constraint-errors.d.ts +1 -0
- package/filters/constraint-errors.js +6 -0
- package/filters/index.d.ts +3 -0
- package/filters/index.js +19 -0
- package/filters/query-failed.filter.d.ts +10 -0
- package/filters/query-failed.filter.js +42 -0
- package/health-checker/health-checker.controller.d.ts +13 -0
- package/health-checker/health-checker.controller.js +69 -0
- package/health-checker/health-checker.module.d.ts +2 -0
- package/health-checker/health-checker.module.js +24 -0
- package/health-checker/index.d.ts +2 -0
- package/health-checker/index.js +18 -0
- package/helpers/common.helper.d.ts +3 -0
- package/helpers/common.helper.js +36 -0
- package/helpers/date.helper.d.ts +10 -0
- package/helpers/date.helper.js +57 -0
- package/helpers/index.d.ts +2 -0
- package/helpers/index.js +18 -0
- package/i18n/en_US/validation.json +44 -0
- package/i18n/zh_CN/validation.json +44 -0
- package/index.d.ts +18 -0
- package/index.js +3 -0
- package/interceptors/index.d.ts +2 -0
- package/interceptors/index.js +18 -0
- package/interceptors/language-interceptor.service.d.ts +6 -0
- package/interceptors/language-interceptor.service.js +29 -0
- package/interceptors/translation-interceptor.service.d.ts +5 -0
- package/interceptors/translation-interceptor.service.js +34 -0
- package/interfaces/IApiFile.d.ts +4 -0
- package/interfaces/IApiFile.js +2 -0
- package/interfaces/IFile.d.ts +8 -0
- package/interfaces/IFile.js +2 -0
- package/interfaces/ITranslationDecoratorInterface.d.ts +3 -0
- package/interfaces/ITranslationDecoratorInterface.js +2 -0
- package/interfaces/index.d.ts +3 -0
- package/interfaces/index.js +19 -0
- package/interfaces/response.d.ts +25 -0
- package/interfaces/response.js +2 -0
- package/middlewares/index.d.ts +4 -0
- package/middlewares/index.js +20 -0
- package/middlewares/omni-auth.middleware.d.ts +1 -0
- package/middlewares/omni-auth.middleware.js +13 -0
- package/middlewares/powerby.middleware.d.ts +1 -0
- package/middlewares/powerby.middleware.js +10 -0
- package/middlewares/request-id.middleware.d.ts +7 -0
- package/middlewares/request-id.middleware.js +22 -0
- package/middlewares/xml.middleware.d.ts +4 -0
- package/middlewares/xml.middleware.js +24 -0
- package/package.json +41 -116
- package/providers/context.provider.d.ts +34 -0
- package/providers/context.provider.js +80 -0
- package/providers/generator.provider.d.ts +9 -0
- package/providers/generator.provider.js +50 -0
- package/providers/index.d.ts +2 -0
- package/providers/index.js +18 -0
- package/redis-lock/examples/lock-strategy.examples.d.ts +73 -0
- package/redis-lock/examples/lock-strategy.examples.js +387 -0
- package/redis-lock/index.d.ts +4 -0
- package/redis-lock/index.js +16 -0
- package/redis-lock/redis-lock.decorator.d.ts +12 -0
- package/redis-lock/redis-lock.decorator.js +125 -0
- package/redis-lock/redis-lock.module.d.ts +23 -0
- package/redis-lock/redis-lock.module.js +117 -0
- package/redis-lock/redis-lock.service.d.ts +66 -0
- package/redis-lock/redis-lock.service.js +413 -0
- package/setup/bootstrap.setup.d.ts +2 -0
- package/setup/bootstrap.setup.js +184 -0
- package/setup/index.d.ts +4 -0
- package/setup/index.js +20 -0
- package/setup/mode.setup.d.ts +12 -0
- package/setup/mode.setup.js +60 -0
- package/setup/schedule.decorator.d.ts +23 -0
- package/setup/schedule.decorator.js +233 -0
- package/setup/worker.decorator.d.ts +14 -0
- package/setup/worker.decorator.js +130 -0
- package/shared/index.d.ts +2 -0
- package/shared/index.js +18 -0
- package/shared/serviceRegistryModule.d.ts +2 -0
- package/shared/serviceRegistryModule.js +170 -0
- package/shared/services/api-config.service.d.ts +54 -0
- package/shared/services/api-config.service.js +287 -0
- package/shared/services/generator.service.d.ts +4 -0
- package/shared/services/generator.service.js +23 -0
- package/shared/services/index.d.ts +4 -0
- package/shared/services/index.js +20 -0
- package/shared/services/translation.service.d.ts +9 -0
- package/shared/services/translation.service.js +70 -0
- package/shared/services/validator.service.d.ts +3 -0
- package/shared/services/validator.service.js +20 -0
- package/validator-json/decorators.d.ts +6 -0
- package/validator-json/decorators.js +22 -0
- package/validator-json/default.d.ts +6 -0
- package/validator-json/default.js +138 -0
- package/validator-json/defaultConverters.d.ts +8 -0
- package/validator-json/defaultConverters.js +376 -0
- package/validator-json/index.d.ts +4 -0
- package/validator-json/index.js +20 -0
- package/validator-json/options.d.ts +11 -0
- package/validator-json/options.js +10 -0
- package/validators/file-mimetype.validator.d.ts +13 -0
- package/validators/file-mimetype.validator.js +21 -0
- package/validators/index.d.ts +6 -0
- package/validators/index.js +22 -0
- package/validators/is-exists.validator.d.ts +18 -0
- package/validators/is-exists.validator.js +60 -0
- package/validators/is-unique.validator.d.ts +17 -0
- package/validators/is-unique.validator.js +91 -0
- package/validators/phone-country-code.validator.d.ts +2 -0
- package/validators/phone-country-code.validator.js +29 -0
- package/validators/same-as.validator.d.ts +2 -0
- package/validators/same-as.validator.js +24 -0
- package/validators/skip-empty.validator.d.ts +1 -0
- package/validators/skip-empty.validator.js +17 -0
- package/vault/index.d.ts +4 -0
- package/vault/index.js +20 -0
- package/vault/interfaces/vault-options.interface.d.ts +22 -0
- package/vault/interfaces/vault-options.interface.js +2 -0
- package/vault/vault-config.loader.d.ts +13 -0
- package/vault/vault-config.loader.js +246 -0
- package/vault/vault-config.service.d.ts +18 -0
- package/vault/vault-config.service.js +174 -0
- package/vault/vault.module.d.ts +2 -0
- package/vault/vault.module.js +21 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var m = o[Symbol.asyncIterator], i;
|
|
14
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.basicPaginationExample = basicPaginationExample;
|
|
20
|
+
exports.syncTransformExample = syncTransformExample;
|
|
21
|
+
exports.asyncTransformExample = asyncTransformExample;
|
|
22
|
+
exports.asyncBatchTransformExample = asyncBatchTransformExample;
|
|
23
|
+
exports.complexAsyncTransformExample = complexAsyncTransformExample;
|
|
24
|
+
exports.iterateExample = iterateExample;
|
|
25
|
+
exports.eachBatchSingleExample = eachBatchSingleExample;
|
|
26
|
+
exports.eachBatchGroupExample = eachBatchGroupExample;
|
|
27
|
+
function basicPaginationExample(repository, pageOptions) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const result = yield repository
|
|
30
|
+
.createQueryBuilder('entity')
|
|
31
|
+
.paginateAndMap(pageOptions);
|
|
32
|
+
return result;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function syncTransformExample(repository, pageOptions) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const result = yield repository
|
|
38
|
+
.createQueryBuilder('entity')
|
|
39
|
+
.where('entity.isActive = :isActive', { isActive: true })
|
|
40
|
+
.paginateAndMap(pageOptions, {
|
|
41
|
+
transform: (items) => {
|
|
42
|
+
return items.filter(item => item.status === 'approved');
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
return result;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function asyncTransformExample(repository, pageOptions, externalService) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const result = yield repository
|
|
51
|
+
.createQueryBuilder('entity')
|
|
52
|
+
.where('entity.isActive = :isActive', { isActive: true })
|
|
53
|
+
.paginateAndMap(pageOptions, {
|
|
54
|
+
transform: (items) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const enrichedItems = yield Promise.all(items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const additionalData = yield externalService.fetchData(item.id);
|
|
57
|
+
return Object.assign(Object.assign({}, item), { additionalData });
|
|
58
|
+
})));
|
|
59
|
+
return enrichedItems.filter(item => { var _a; return (_a = item.additionalData) === null || _a === void 0 ? void 0 : _a.isValid; });
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
return result;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function asyncBatchTransformExample(repository, pageOptions, batchProcessor) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const result = yield repository
|
|
68
|
+
.createQueryBuilder('entity')
|
|
69
|
+
.leftJoinAndSelect('entity.relations', 'relations')
|
|
70
|
+
.paginateAndMap(pageOptions, {
|
|
71
|
+
dtoOptions: { includeRelations: true },
|
|
72
|
+
transform: (items) => __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const processedItems = yield batchProcessor.processBatch(items);
|
|
74
|
+
return processedItems.map(item => (Object.assign(Object.assign({}, item), { processed: true, processedAt: new Date() })));
|
|
75
|
+
}),
|
|
76
|
+
});
|
|
77
|
+
return result;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function complexAsyncTransformExample(repository, pageOptions, services) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const result = yield repository
|
|
83
|
+
.createQueryBuilder('entity')
|
|
84
|
+
.where('entity.createdAt > :date', { date: new Date('2024-01-01') })
|
|
85
|
+
.paginateAndMap(pageOptions, {
|
|
86
|
+
skipCount: false,
|
|
87
|
+
transform: (items) => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
const validatedItems = yield Promise.all(items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
try {
|
|
90
|
+
const isValid = yield services.validation.validate(item);
|
|
91
|
+
return isValid ? item : null;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
console.error(`Validation failed for item ${item.id}:`, error);
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
})));
|
|
98
|
+
const validItems = validatedItems.filter(item => item !== null);
|
|
99
|
+
const enrichedItems = yield Promise.all(validItems.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
const enrichmentData = yield services.enrichment.enrich(item.id);
|
|
101
|
+
return Object.assign(Object.assign({}, item), enrichmentData);
|
|
102
|
+
})));
|
|
103
|
+
const finalItems = yield Promise.all(enrichedItems.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
const calculatedFields = yield services.calculation.calculate(item);
|
|
105
|
+
return Object.assign(Object.assign({}, item), calculatedFields);
|
|
106
|
+
})));
|
|
107
|
+
return finalItems;
|
|
108
|
+
}),
|
|
109
|
+
});
|
|
110
|
+
return result;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function iterateExample(repository, processor) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
var _a, e_1, _b, _c;
|
|
116
|
+
const queryBuilder = repository
|
|
117
|
+
.createQueryBuilder('entity')
|
|
118
|
+
.where('entity.needsProcessing = :needsProcessing', { needsProcessing: true });
|
|
119
|
+
try {
|
|
120
|
+
for (var _d = true, _e = __asyncValues(queryBuilder.iterate({ batchSize: 500 })), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
121
|
+
_c = _f.value;
|
|
122
|
+
_d = false;
|
|
123
|
+
const batch = _c;
|
|
124
|
+
console.log(`Processing batch of ${batch.length} entities`);
|
|
125
|
+
yield processor.processBatch(batch);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
129
|
+
finally {
|
|
130
|
+
try {
|
|
131
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
132
|
+
}
|
|
133
|
+
finally { if (e_1) throw e_1.error; }
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function eachBatchSingleExample(repository, processor) {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
yield repository
|
|
140
|
+
.createQueryBuilder('entity')
|
|
141
|
+
.where('entity.status = :status', { status: 'pending' })
|
|
142
|
+
.eachBatch((entity) => __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
console.log(`Processing entity ${entity.id}`);
|
|
144
|
+
yield processor.processOne(entity);
|
|
145
|
+
}), { batchSize: 100, mode: 'single' });
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function eachBatchGroupExample(repository, processor) {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
yield repository
|
|
151
|
+
.createQueryBuilder('entity')
|
|
152
|
+
.where('entity.status = :status', { status: 'pending' })
|
|
153
|
+
.eachBatch((batch) => __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
console.log(`Processing batch of ${batch.length} entities`);
|
|
155
|
+
yield processor.processBatch(batch);
|
|
156
|
+
}), { batchSize: 500, mode: 'batch' });
|
|
157
|
+
});
|
|
158
|
+
}
|
package/common/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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("./abstract.entity"), exports);
|
|
18
|
+
__exportStar(require("./utils"), exports);
|
|
19
|
+
__exportStar(require("./dto"), exports);
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
__exportStar(require("./snake-naming.strategy"), exports);
|
|
22
|
+
__exportStar(require("./boilerplate.polyfill"), exports);
|
|
@@ -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;
|
|
@@ -0,0 +1,9 @@
|
|
|
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/common/types.js
ADDED
package/common/utils.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateHash = generateHash;
|
|
4
|
+
exports.validateHash = validateHash;
|
|
5
|
+
exports.getVariableName = getVariableName;
|
|
6
|
+
const bcrypt_1 = require("bcrypt");
|
|
7
|
+
function generateHash(password) {
|
|
8
|
+
return bcrypt_1.default.hashSync(password, 10);
|
|
9
|
+
}
|
|
10
|
+
function validateHash(password, hash) {
|
|
11
|
+
if (!password || !hash) {
|
|
12
|
+
return Promise.resolve(false);
|
|
13
|
+
}
|
|
14
|
+
return bcrypt_1.default.compare(password, hash);
|
|
15
|
+
}
|
|
16
|
+
function getVariableName(getVar) {
|
|
17
|
+
const m = /\(\)=>(.*)/.exec(getVar.toString().replace(/(\r\n|\n|\r|\s)/gm, ''));
|
|
18
|
+
if (!m) {
|
|
19
|
+
throw new Error("The function does not contain a statement matching 'return variableName;'");
|
|
20
|
+
}
|
|
21
|
+
const fullMemberName = m[1];
|
|
22
|
+
const memberParts = fullMemberName.split('.');
|
|
23
|
+
return memberParts[memberParts.length - 1];
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./language-code"), exports);
|
|
18
|
+
__exportStar(require("./order"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.supportedLanguageCount = exports.LanguageCode = void 0;
|
|
4
|
+
var LanguageCode;
|
|
5
|
+
(function (LanguageCode) {
|
|
6
|
+
LanguageCode["en_US"] = "en-US";
|
|
7
|
+
LanguageCode["zh_CN"] = "zh-CN";
|
|
8
|
+
})(LanguageCode || (exports.LanguageCode = LanguageCode = {}));
|
|
9
|
+
exports.supportedLanguageCount = Object.values(LanguageCode).length;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiPageResponse = ApiPageResponse;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
+
const page_dto_1 = require("../common/dto/page.dto");
|
|
7
|
+
function ApiPageResponse(options) {
|
|
8
|
+
return (0, common_1.applyDecorators)((0, swagger_1.ApiExtraModels)(page_dto_1.PageDto), (0, swagger_1.ApiExtraModels)(options.type), (0, swagger_1.ApiOkResponse)({
|
|
9
|
+
description: options.description,
|
|
10
|
+
schema: {
|
|
11
|
+
allOf: [
|
|
12
|
+
{ $ref: (0, swagger_1.getSchemaPath)(page_dto_1.PageDto) },
|
|
13
|
+
{
|
|
14
|
+
properties: {
|
|
15
|
+
results: {
|
|
16
|
+
type: 'array',
|
|
17
|
+
items: { $ref: (0, swagger_1.getSchemaPath)(options.type) },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AuthUser(): ParameterDecorator;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthUser = AuthUser;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
function AuthUser() {
|
|
6
|
+
return (0, common_1.createParamDecorator)((_data, context) => {
|
|
7
|
+
const request = context.switchToHttp().getRequest();
|
|
8
|
+
const user = request.user;
|
|
9
|
+
if (user === null || user === void 0 ? void 0 : user[Symbol.for('isPublic')]) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return user;
|
|
13
|
+
})();
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Controller(field: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Controller = Controller;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const crud_1 = require("@dataui/crud");
|
|
6
|
+
const _ = require("lodash");
|
|
7
|
+
function Controller(field) {
|
|
8
|
+
const featureName = _.upperFirst(field);
|
|
9
|
+
return (0, common_1.applyDecorators)((0, common_1.Controller)(field), (0, crud_1.Feature)(featureName));
|
|
10
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export declare class ContactDto {
|
|
2
|
+
email?: string;
|
|
3
|
+
phone?: string;
|
|
4
|
+
wechat?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class SearchDto {
|
|
7
|
+
keyword?: string;
|
|
8
|
+
category?: string;
|
|
9
|
+
tags?: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare class PasswordDto {
|
|
12
|
+
password: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class EmailCheckDto {
|
|
15
|
+
email: string;
|
|
16
|
+
userService?: any;
|
|
17
|
+
}
|
|
18
|
+
export declare class OrderDto {
|
|
19
|
+
orderType: 'standard' | 'express';
|
|
20
|
+
deliveryDate?: Date;
|
|
21
|
+
}
|
|
22
|
+
export declare class DiscountDto {
|
|
23
|
+
discountType: 'percentage' | 'fixed';
|
|
24
|
+
discountValue: number;
|
|
25
|
+
get validatedDiscountValue(): number;
|
|
26
|
+
}
|
|
27
|
+
export declare class UserRegistrationDto {
|
|
28
|
+
username: string;
|
|
29
|
+
password: string;
|
|
30
|
+
confirmPassword: string;
|
|
31
|
+
validatePassword(password: string): boolean;
|
|
32
|
+
validatePasswordMatch(confirmPassword: string): boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare class CreateProductDto {
|
|
35
|
+
name: string;
|
|
36
|
+
sku: string;
|
|
37
|
+
categoryId: string;
|
|
38
|
+
get validatedCategoryId(): string;
|
|
39
|
+
productService?: any;
|
|
40
|
+
categoryService?: any;
|
|
41
|
+
checkSkuUniqueness(sku: string): Promise<boolean>;
|
|
42
|
+
validateCategoryExists(categoryId: string): Promise<boolean>;
|
|
43
|
+
}
|
|
44
|
+
export declare class EmployeeDto {
|
|
45
|
+
name: string;
|
|
46
|
+
personalEmail?: string;
|
|
47
|
+
workEmail?: string;
|
|
48
|
+
phone?: string;
|
|
49
|
+
validatePhoneFormat(phone: string): boolean;
|
|
50
|
+
}
|
|
51
|
+
export declare class PaymentMethodDto {
|
|
52
|
+
paymentType: 'credit_card' | 'bank_transfer' | 'digital_wallet';
|
|
53
|
+
creditCard?: {
|
|
54
|
+
number: string;
|
|
55
|
+
expiryDate: string;
|
|
56
|
+
cvv: string;
|
|
57
|
+
};
|
|
58
|
+
bankAccount?: {
|
|
59
|
+
accountNumber: string;
|
|
60
|
+
routingNumber: string;
|
|
61
|
+
};
|
|
62
|
+
digitalWallet?: {
|
|
63
|
+
provider: string;
|
|
64
|
+
walletId: string;
|
|
65
|
+
};
|
|
66
|
+
validateCreditCard(creditCard: any): boolean;
|
|
67
|
+
validateBankAccount(bankAccount: any): boolean;
|
|
68
|
+
validateDigitalWallet(digitalWallet: any): boolean;
|
|
69
|
+
}
|