@elsikora/nestjs-crud-config 1.0.0
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/LICENSE +21 -0
- package/README.md +633 -0
- package/dist/cjs/external/tslib/tslib.es6.js +43 -0
- package/dist/cjs/external/tslib/tslib.es6.js.map +1 -0
- package/dist/cjs/index.d.ts +13 -0
- package/dist/cjs/index.js +52 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/modules/config/config.module.d.ts +13 -0
- package/dist/cjs/modules/config/config.module.js +230 -0
- package/dist/cjs/modules/config/config.module.js.map +1 -0
- package/dist/cjs/modules/config/config.service.d.ts +50 -0
- package/dist/cjs/modules/config/config.service.js +355 -0
- package/dist/cjs/modules/config/config.service.js.map +1 -0
- package/dist/cjs/modules/config/data/controller.d.ts +10 -0
- package/dist/cjs/modules/config/data/controller.js +76 -0
- package/dist/cjs/modules/config/data/controller.js.map +1 -0
- package/dist/cjs/modules/config/data/entity/entity.d.ts +20 -0
- package/dist/cjs/modules/config/data/entity/entity.js +158 -0
- package/dist/cjs/modules/config/data/entity/entity.js.map +1 -0
- package/dist/cjs/modules/config/data/entity/index.d.ts +1 -0
- package/dist/cjs/modules/config/data/event/before-insert.event.d.ts +20 -0
- package/dist/cjs/modules/config/data/event/before-insert.event.js +23 -0
- package/dist/cjs/modules/config/data/event/before-insert.event.js.map +1 -0
- package/dist/cjs/modules/config/data/event/index.d.ts +1 -0
- package/dist/cjs/modules/config/data/index.d.ts +6 -0
- package/dist/cjs/modules/config/data/interface/index.d.ts +1 -0
- package/dist/cjs/modules/config/data/interface/interface.d.ts +12 -0
- package/dist/cjs/modules/config/data/listener/before-insert.listener.d.ts +19 -0
- package/dist/cjs/modules/config/data/listener/before-insert.listener.js +59 -0
- package/dist/cjs/modules/config/data/listener/before-insert.listener.js.map +1 -0
- package/dist/cjs/modules/config/data/listener/index.d.ts +1 -0
- package/dist/cjs/modules/config/data/subscriber/before-insert.subscriber.d.ts +26 -0
- package/dist/cjs/modules/config/data/subscriber/before-insert.subscriber.js +74 -0
- package/dist/cjs/modules/config/data/subscriber/before-insert.subscriber.js.map +1 -0
- package/dist/cjs/modules/config/data/subscriber/index.d.ts +1 -0
- package/dist/cjs/modules/config/index.d.ts +9 -0
- package/dist/cjs/modules/config/interface/delete-options.interface.d.ts +22 -0
- package/dist/cjs/modules/config/interface/get-list-options.interface.d.ts +22 -0
- package/dist/cjs/modules/config/interface/get-options.interface.d.ts +30 -0
- package/dist/cjs/modules/config/interface/index.d.ts +4 -0
- package/dist/cjs/modules/config/interface/set-options.interface.d.ts +34 -0
- package/dist/cjs/modules/config/section/controller.d.ts +10 -0
- package/dist/cjs/modules/config/section/controller.js +46 -0
- package/dist/cjs/modules/config/section/controller.js.map +1 -0
- package/dist/cjs/modules/config/section/entity/entity.d.ts +14 -0
- package/dist/cjs/modules/config/section/entity/entity.js +96 -0
- package/dist/cjs/modules/config/section/entity/entity.js.map +1 -0
- package/dist/cjs/modules/config/section/entity/index.d.ts +1 -0
- package/dist/cjs/modules/config/section/index.d.ts +2 -0
- package/dist/cjs/modules/config/section/interface/index.d.ts +1 -0
- package/dist/cjs/modules/config/section/interface/interface.d.ts +7 -0
- package/dist/cjs/modules/config/type/index.d.ts +2 -0
- package/dist/cjs/modules/config/type/item.type.d.ts +1 -0
- package/dist/cjs/modules/config/type/type.d.ts +2 -0
- package/dist/cjs/package.json +8 -0
- package/dist/cjs/shared/constant/api-property.constant.d.ts +4 -0
- package/dist/cjs/shared/constant/api-property.constant.js +11 -0
- package/dist/cjs/shared/constant/api-property.constant.js.map +1 -0
- package/dist/cjs/shared/constant/config/data.constant.d.ts +7 -0
- package/dist/cjs/shared/constant/config/data.constant.js +17 -0
- package/dist/cjs/shared/constant/config/data.constant.js.map +1 -0
- package/dist/cjs/shared/constant/config/index.d.ts +2 -0
- package/dist/cjs/shared/constant/config/section.constant.d.ts +5 -0
- package/dist/cjs/shared/constant/config/section.constant.js +13 -0
- package/dist/cjs/shared/constant/config/section.constant.js.map +1 -0
- package/dist/cjs/shared/constant/crypto.constant.d.ts +7 -0
- package/dist/cjs/shared/constant/crypto.constant.js +17 -0
- package/dist/cjs/shared/constant/crypto.constant.js.map +1 -0
- package/dist/cjs/shared/constant/index.d.ts +4 -0
- package/dist/cjs/shared/constant/token.constant.d.ts +8 -0
- package/dist/cjs/shared/constant/token.constant.js +20 -0
- package/dist/cjs/shared/constant/token.constant.js.map +1 -0
- package/dist/cjs/shared/enum/environment.enum.d.ts +16 -0
- package/dist/cjs/shared/enum/environment.enum.js +20 -0
- package/dist/cjs/shared/enum/environment.enum.js.map +1 -0
- package/dist/cjs/shared/enum/index.d.ts +6 -0
- package/dist/cjs/shared/enum/instance-name.enum.d.ts +7 -0
- package/dist/cjs/shared/enum/instance-name.enum.js +11 -0
- package/dist/cjs/shared/enum/instance-name.enum.js.map +1 -0
- package/dist/cjs/shared/enum/service.enum.d.ts +220 -0
- package/dist/cjs/shared/enum/service.enum.js +224 -0
- package/dist/cjs/shared/enum/service.enum.js.map +1 -0
- package/dist/cjs/shared/index.d.ts +5 -0
- package/dist/cjs/shared/interface/config/async-module-properties.interface.d.ts +16 -0
- package/dist/cjs/shared/interface/config/cache-options.interface.d.ts +17 -0
- package/dist/cjs/shared/interface/config/config-data-entity-options.interface.d.ts +25 -0
- package/dist/cjs/shared/interface/config/controller-options.interface.d.ts +28 -0
- package/dist/cjs/shared/interface/config/encryption-options.interface.d.ts +13 -0
- package/dist/cjs/shared/interface/config/entity/data-options.interface.d.ts +25 -0
- package/dist/cjs/shared/interface/config/entity/index.d.ts +3 -0
- package/dist/cjs/shared/interface/config/entity/options.interface.d.ts +18 -0
- package/dist/cjs/shared/interface/config/entity/section-options.interface.d.ts +17 -0
- package/dist/cjs/shared/interface/config/index.d.ts +7 -0
- package/dist/cjs/shared/interface/config/options.interface.d.ts +37 -0
- package/dist/cjs/shared/interface/config/properties-factory.interface.d.ts +11 -0
- package/dist/cjs/shared/interface/index.d.ts +2 -0
- package/dist/cjs/shared/interface/utility/create-dynamic-entity/index.d.ts +2 -0
- package/dist/cjs/shared/interface/utility/create-dynamic-entity/options.interface.d.ts +15 -0
- package/dist/cjs/shared/interface/utility/create-dynamic-entity/relation-options.interface.d.ts +9 -0
- package/dist/cjs/shared/interface/utility/index.d.ts +1 -0
- package/dist/cjs/shared/type/dynamic-entity.type.d.ts +1 -0
- package/dist/cjs/shared/type/index.d.ts +1 -0
- package/dist/cjs/shared/utility/create-dynamic/entity.utility.d.ts +9 -0
- package/dist/cjs/shared/utility/create-dynamic/entity.utility.js +67 -0
- package/dist/cjs/shared/utility/create-dynamic/entity.utility.js.map +1 -0
- package/dist/cjs/shared/utility/create-dynamic/index.d.ts +2 -0
- package/dist/cjs/shared/utility/create-dynamic/service.utility.d.ts +9 -0
- package/dist/cjs/shared/utility/create-dynamic/service.utility.js +34 -0
- package/dist/cjs/shared/utility/create-dynamic/service.utility.js.map +1 -0
- package/dist/cjs/shared/utility/create-dynamic-entity.utility.d.ts +9 -0
- package/dist/cjs/shared/utility/create-dynamic-entity.utility.js +67 -0
- package/dist/cjs/shared/utility/create-dynamic-entity.utility.js.map +1 -0
- package/dist/cjs/shared/utility/crypto.utility.d.ts +27 -0
- package/dist/cjs/shared/utility/crypto.utility.js +72 -0
- package/dist/cjs/shared/utility/crypto.utility.js.map +1 -0
- package/dist/cjs/shared/utility/index.d.ts +3 -0
- package/dist/esm/external/tslib/tslib.es6.js +39 -0
- package/dist/esm/external/tslib/tslib.es6.js.map +1 -0
- package/dist/esm/index.d.ts +13 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/modules/config/config.module.d.ts +13 -0
- package/dist/esm/modules/config/config.module.js +230 -0
- package/dist/esm/modules/config/config.module.js.map +1 -0
- package/dist/esm/modules/config/config.service.d.ts +50 -0
- package/dist/esm/modules/config/config.service.js +355 -0
- package/dist/esm/modules/config/config.service.js.map +1 -0
- package/dist/esm/modules/config/data/controller.d.ts +10 -0
- package/dist/esm/modules/config/data/controller.js +74 -0
- package/dist/esm/modules/config/data/controller.js.map +1 -0
- package/dist/esm/modules/config/data/entity/entity.d.ts +20 -0
- package/dist/esm/modules/config/data/entity/entity.js +156 -0
- package/dist/esm/modules/config/data/entity/entity.js.map +1 -0
- package/dist/esm/modules/config/data/entity/index.d.ts +1 -0
- package/dist/esm/modules/config/data/event/before-insert.event.d.ts +20 -0
- package/dist/esm/modules/config/data/event/before-insert.event.js +21 -0
- package/dist/esm/modules/config/data/event/before-insert.event.js.map +1 -0
- package/dist/esm/modules/config/data/event/index.d.ts +1 -0
- package/dist/esm/modules/config/data/index.d.ts +6 -0
- package/dist/esm/modules/config/data/interface/index.d.ts +1 -0
- package/dist/esm/modules/config/data/interface/interface.d.ts +12 -0
- package/dist/esm/modules/config/data/listener/before-insert.listener.d.ts +19 -0
- package/dist/esm/modules/config/data/listener/before-insert.listener.js +59 -0
- package/dist/esm/modules/config/data/listener/before-insert.listener.js.map +1 -0
- package/dist/esm/modules/config/data/listener/index.d.ts +1 -0
- package/dist/esm/modules/config/data/subscriber/before-insert.subscriber.d.ts +26 -0
- package/dist/esm/modules/config/data/subscriber/before-insert.subscriber.js +74 -0
- package/dist/esm/modules/config/data/subscriber/before-insert.subscriber.js.map +1 -0
- package/dist/esm/modules/config/data/subscriber/index.d.ts +1 -0
- package/dist/esm/modules/config/index.d.ts +9 -0
- package/dist/esm/modules/config/interface/delete-options.interface.d.ts +22 -0
- package/dist/esm/modules/config/interface/get-list-options.interface.d.ts +22 -0
- package/dist/esm/modules/config/interface/get-options.interface.d.ts +30 -0
- package/dist/esm/modules/config/interface/index.d.ts +4 -0
- package/dist/esm/modules/config/interface/set-options.interface.d.ts +34 -0
- package/dist/esm/modules/config/section/controller.d.ts +10 -0
- package/dist/esm/modules/config/section/controller.js +44 -0
- package/dist/esm/modules/config/section/controller.js.map +1 -0
- package/dist/esm/modules/config/section/entity/entity.d.ts +14 -0
- package/dist/esm/modules/config/section/entity/entity.js +94 -0
- package/dist/esm/modules/config/section/entity/entity.js.map +1 -0
- package/dist/esm/modules/config/section/entity/index.d.ts +1 -0
- package/dist/esm/modules/config/section/index.d.ts +2 -0
- package/dist/esm/modules/config/section/interface/index.d.ts +1 -0
- package/dist/esm/modules/config/section/interface/interface.d.ts +7 -0
- package/dist/esm/modules/config/type/index.d.ts +2 -0
- package/dist/esm/modules/config/type/item.type.d.ts +1 -0
- package/dist/esm/modules/config/type/type.d.ts +2 -0
- package/dist/esm/package.json +8 -0
- package/dist/esm/shared/constant/api-property.constant.d.ts +4 -0
- package/dist/esm/shared/constant/api-property.constant.js +9 -0
- package/dist/esm/shared/constant/api-property.constant.js.map +1 -0
- package/dist/esm/shared/constant/config/data.constant.d.ts +7 -0
- package/dist/esm/shared/constant/config/data.constant.js +15 -0
- package/dist/esm/shared/constant/config/data.constant.js.map +1 -0
- package/dist/esm/shared/constant/config/index.d.ts +2 -0
- package/dist/esm/shared/constant/config/section.constant.d.ts +5 -0
- package/dist/esm/shared/constant/config/section.constant.js +11 -0
- package/dist/esm/shared/constant/config/section.constant.js.map +1 -0
- package/dist/esm/shared/constant/crypto.constant.d.ts +7 -0
- package/dist/esm/shared/constant/crypto.constant.js +15 -0
- package/dist/esm/shared/constant/crypto.constant.js.map +1 -0
- package/dist/esm/shared/constant/index.d.ts +4 -0
- package/dist/esm/shared/constant/token.constant.d.ts +8 -0
- package/dist/esm/shared/constant/token.constant.js +18 -0
- package/dist/esm/shared/constant/token.constant.js.map +1 -0
- package/dist/esm/shared/enum/environment.enum.d.ts +16 -0
- package/dist/esm/shared/enum/environment.enum.js +20 -0
- package/dist/esm/shared/enum/environment.enum.js.map +1 -0
- package/dist/esm/shared/enum/index.d.ts +6 -0
- package/dist/esm/shared/enum/instance-name.enum.d.ts +7 -0
- package/dist/esm/shared/enum/instance-name.enum.js +11 -0
- package/dist/esm/shared/enum/instance-name.enum.js.map +1 -0
- package/dist/esm/shared/enum/service.enum.d.ts +220 -0
- package/dist/esm/shared/enum/service.enum.js +224 -0
- package/dist/esm/shared/enum/service.enum.js.map +1 -0
- package/dist/esm/shared/index.d.ts +5 -0
- package/dist/esm/shared/interface/config/async-module-properties.interface.d.ts +16 -0
- package/dist/esm/shared/interface/config/cache-options.interface.d.ts +17 -0
- package/dist/esm/shared/interface/config/config-data-entity-options.interface.d.ts +25 -0
- package/dist/esm/shared/interface/config/controller-options.interface.d.ts +28 -0
- package/dist/esm/shared/interface/config/encryption-options.interface.d.ts +13 -0
- package/dist/esm/shared/interface/config/entity/data-options.interface.d.ts +25 -0
- package/dist/esm/shared/interface/config/entity/index.d.ts +3 -0
- package/dist/esm/shared/interface/config/entity/options.interface.d.ts +18 -0
- package/dist/esm/shared/interface/config/entity/section-options.interface.d.ts +17 -0
- package/dist/esm/shared/interface/config/index.d.ts +7 -0
- package/dist/esm/shared/interface/config/options.interface.d.ts +37 -0
- package/dist/esm/shared/interface/config/properties-factory.interface.d.ts +11 -0
- package/dist/esm/shared/interface/index.d.ts +2 -0
- package/dist/esm/shared/interface/utility/create-dynamic-entity/index.d.ts +2 -0
- package/dist/esm/shared/interface/utility/create-dynamic-entity/options.interface.d.ts +15 -0
- package/dist/esm/shared/interface/utility/create-dynamic-entity/relation-options.interface.d.ts +9 -0
- package/dist/esm/shared/interface/utility/index.d.ts +1 -0
- package/dist/esm/shared/type/dynamic-entity.type.d.ts +1 -0
- package/dist/esm/shared/type/index.d.ts +1 -0
- package/dist/esm/shared/utility/create-dynamic/entity.utility.d.ts +9 -0
- package/dist/esm/shared/utility/create-dynamic/entity.utility.js +65 -0
- package/dist/esm/shared/utility/create-dynamic/entity.utility.js.map +1 -0
- package/dist/esm/shared/utility/create-dynamic/index.d.ts +2 -0
- package/dist/esm/shared/utility/create-dynamic/service.utility.d.ts +9 -0
- package/dist/esm/shared/utility/create-dynamic/service.utility.js +32 -0
- package/dist/esm/shared/utility/create-dynamic/service.utility.js.map +1 -0
- package/dist/esm/shared/utility/create-dynamic-entity.utility.d.ts +9 -0
- package/dist/esm/shared/utility/create-dynamic-entity.utility.js +65 -0
- package/dist/esm/shared/utility/create-dynamic-entity.utility.js.map +1 -0
- package/dist/esm/shared/utility/crypto.utility.d.ts +27 -0
- package/dist/esm/shared/utility/crypto.utility.js +72 -0
- package/dist/esm/shared/utility/crypto.utility.js.map +1 -0
- package/dist/esm/shared/utility/index.d.ts +3 -0
- package/package.json +115 -0
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib_es6 = require('../../external/tslib/tslib.es6.js');
|
|
4
|
+
var nestjsCrudAutomator = require('@elsikora/nestjs-crud-automator');
|
|
5
|
+
var cacheManager = require('@nestjs/cache-manager');
|
|
6
|
+
var common = require('@nestjs/common');
|
|
7
|
+
var token_constant = require('../../shared/constant/token.constant.js');
|
|
8
|
+
var typeorm = require('typeorm');
|
|
9
|
+
require('@nestjs/typeorm');
|
|
10
|
+
var crypto_utility = require('../../shared/utility/crypto.utility.js');
|
|
11
|
+
|
|
12
|
+
var CrudConfigService_1;
|
|
13
|
+
/**
|
|
14
|
+
* Service for managing configuration data with caching support
|
|
15
|
+
* Provides methods to retrieve configuration values with optional decryption
|
|
16
|
+
*/
|
|
17
|
+
exports.CrudConfigService = CrudConfigService_1 = class CrudConfigService {
|
|
18
|
+
sectionService;
|
|
19
|
+
dataService;
|
|
20
|
+
cacheManager;
|
|
21
|
+
options;
|
|
22
|
+
dataSource;
|
|
23
|
+
cryptoUtility;
|
|
24
|
+
LOGGER = new common.Logger(CrudConfigService_1.name);
|
|
25
|
+
constructor(sectionService, dataService, cacheManager, options, dataSource, cryptoUtility) {
|
|
26
|
+
this.sectionService = sectionService;
|
|
27
|
+
this.dataService = dataService;
|
|
28
|
+
this.cacheManager = cacheManager;
|
|
29
|
+
this.options = options;
|
|
30
|
+
this.dataSource = dataSource;
|
|
31
|
+
this.cryptoUtility = cryptoUtility;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Deletes a configuration value
|
|
35
|
+
* @param {IConfigDeleteOptions} options Configuration options to identify the value to delete
|
|
36
|
+
* @returns {Promise<void>} Promise resolving when the configuration is deleted
|
|
37
|
+
*/
|
|
38
|
+
async delete(options) {
|
|
39
|
+
if (this.options?.isVerbose) {
|
|
40
|
+
this.LOGGER.verbose(`Entering delete method with options: ${JSON.stringify(options)}`);
|
|
41
|
+
}
|
|
42
|
+
const { environment, eventManager, name, section: sectionName } = options;
|
|
43
|
+
const finalEnvironment = environment ?? this.options?.environment ?? "default";
|
|
44
|
+
try {
|
|
45
|
+
const section = await this.sectionService.get({ where: { name: sectionName } }, eventManager);
|
|
46
|
+
const data = await this.dataService.get({
|
|
47
|
+
where: {
|
|
48
|
+
environment: finalEnvironment,
|
|
49
|
+
name,
|
|
50
|
+
section: { id: section.id },
|
|
51
|
+
},
|
|
52
|
+
}, eventManager);
|
|
53
|
+
await this.dataService.delete({ id: data.id }, eventManager);
|
|
54
|
+
if (this.options?.cacheOptions?.isEnabled && this.cacheManager) {
|
|
55
|
+
const cacheKey = `config:${sectionName}:${name}:${finalEnvironment}`;
|
|
56
|
+
const listCacheKey = `config:list:${sectionName}:${finalEnvironment}`;
|
|
57
|
+
await Promise.all([this.cacheManager.del(cacheKey), this.cacheManager.del(listCacheKey)]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (this.options?.isVerbose) {
|
|
62
|
+
this.LOGGER.error(`Error in delete method: ${error.message}`);
|
|
63
|
+
}
|
|
64
|
+
if (error instanceof common.HttpException) {
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.DELETING_ERROR }));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves configuration data based on the provided options
|
|
72
|
+
* @param {IConfigGetOptions} options Configuration retrieval options
|
|
73
|
+
* @returns {Promise<IConfigData>} Promise resolving to the configuration data
|
|
74
|
+
*/
|
|
75
|
+
async get(options) {
|
|
76
|
+
if (this.options?.isVerbose) {
|
|
77
|
+
this.LOGGER.verbose(`Entering get method with options: ${JSON.stringify(options)}`);
|
|
78
|
+
}
|
|
79
|
+
const { environment, eventManager, name, section, shouldLoadSectionInfo, useCache, } = options;
|
|
80
|
+
const finalEnvironment = environment ?? this.options?.environment ?? "default";
|
|
81
|
+
const cacheKey = `config:${section}:${name}:${finalEnvironment}`;
|
|
82
|
+
try {
|
|
83
|
+
// Check cache first if enabled
|
|
84
|
+
if (useCache && this.options?.cacheOptions?.isEnabled && this.cacheManager) {
|
|
85
|
+
const cachedData = await this.cacheManager.get(cacheKey);
|
|
86
|
+
if (cachedData) {
|
|
87
|
+
if (this.options?.isVerbose) {
|
|
88
|
+
this.LOGGER.verbose(`Returning cached config data for ${name}`);
|
|
89
|
+
}
|
|
90
|
+
return cachedData;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Fetch section
|
|
94
|
+
if (this.options?.isVerbose) {
|
|
95
|
+
this.LOGGER.verbose(`Fetching section: ${section}`);
|
|
96
|
+
}
|
|
97
|
+
const sectionData = await this.sectionService.get({ where: { name: section } }, eventManager);
|
|
98
|
+
if (this.options?.isVerbose) {
|
|
99
|
+
this.LOGGER.verbose(`Fetching config data for name: ${name}, environment: ${finalEnvironment}`);
|
|
100
|
+
}
|
|
101
|
+
const data = await this.dataService.get({
|
|
102
|
+
// eslint-disable-next-line @elsikora/typescript/naming-convention
|
|
103
|
+
relations: { section: shouldLoadSectionInfo },
|
|
104
|
+
where: { environment: finalEnvironment, name, section: { id: sectionData.id } },
|
|
105
|
+
}, eventManager);
|
|
106
|
+
if (data.isEncrypted) {
|
|
107
|
+
if (!this.options?.encryptionOptions?.encryptionKey) {
|
|
108
|
+
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.KEY_NOT_FOUND }));
|
|
109
|
+
}
|
|
110
|
+
if (!this.cryptoUtility) {
|
|
111
|
+
throw new common.InternalServerErrorException("CryptoUtility not available");
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
data.value = this.cryptoUtility.decrypt(data.value, this.options.encryptionOptions.encryptionKey);
|
|
115
|
+
if (this.options?.isVerbose) {
|
|
116
|
+
this.LOGGER.verbose(`Decrypted value for ${name}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
if (this.options?.isVerbose) {
|
|
121
|
+
this.LOGGER.error(`Decryption error for ${name}: ${error.message}`);
|
|
122
|
+
}
|
|
123
|
+
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.DECRYPTION_ERROR }));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (useCache && this.options?.cacheOptions?.isEnabled && this.cacheManager) {
|
|
127
|
+
const ttl = this.options.cacheOptions.maxCacheTTL;
|
|
128
|
+
await this.cacheManager.set(cacheKey, data, ttl);
|
|
129
|
+
}
|
|
130
|
+
if (this.options?.isVerbose) {
|
|
131
|
+
this.LOGGER.verbose(`Returning config data for ${name}`);
|
|
132
|
+
}
|
|
133
|
+
return data;
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (this.options?.isVerbose) {
|
|
137
|
+
this.LOGGER.error(`Error in get method: ${error.message}`);
|
|
138
|
+
}
|
|
139
|
+
if (error instanceof common.HttpException) {
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.FETCHING_ERROR }));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Lists all configuration values in a section.
|
|
147
|
+
* Supports caching and running within a TypeORM transaction.
|
|
148
|
+
* @param {IConfigGetListOptions} options Options for listing configurations.
|
|
149
|
+
* @returns {Promise<Array<IConfigData>>} Promise resolving to an array of configuration data.
|
|
150
|
+
*/
|
|
151
|
+
async getList(options) {
|
|
152
|
+
if (this.options?.isVerbose) {
|
|
153
|
+
this.LOGGER.verbose(`Entering getList method with options: ${JSON.stringify(options)}`);
|
|
154
|
+
}
|
|
155
|
+
const { environment, eventManager, section: sectionName, useCache, } = options;
|
|
156
|
+
const finalEnvironment = environment ?? this.options?.environment ?? "default";
|
|
157
|
+
const cacheKey = `config:list:${sectionName}:${finalEnvironment}`;
|
|
158
|
+
try {
|
|
159
|
+
// Check cache first if enabled
|
|
160
|
+
if (useCache && this.options?.cacheOptions?.isEnabled && this.cacheManager) {
|
|
161
|
+
const cachedItems = await this.cacheManager.get(cacheKey);
|
|
162
|
+
if (cachedItems) {
|
|
163
|
+
if (this.options?.isVerbose) {
|
|
164
|
+
this.LOGGER.verbose(`Returning cached config list for ${sectionName}`);
|
|
165
|
+
}
|
|
166
|
+
return cachedItems;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (this.options?.isVerbose) {
|
|
170
|
+
this.LOGGER.verbose(`Fetching section: ${sectionName}`);
|
|
171
|
+
}
|
|
172
|
+
const section = await this.sectionService.get({ where: { name: sectionName } }, eventManager);
|
|
173
|
+
if (this.options?.isVerbose) {
|
|
174
|
+
this.LOGGER.verbose(`Fetching config list for section: ${sectionName}, environment: ${finalEnvironment}`);
|
|
175
|
+
}
|
|
176
|
+
const result = await this.dataService.getList({ where: { environment: finalEnvironment, section: { id: section.id } } }, eventManager);
|
|
177
|
+
if (useCache && this.options?.cacheOptions?.isEnabled && this.cacheManager) {
|
|
178
|
+
const ttl = this.options?.cacheOptions?.maxCacheTTL;
|
|
179
|
+
await this.cacheManager.set(cacheKey, result.items, ttl);
|
|
180
|
+
}
|
|
181
|
+
if (this.options?.isVerbose) {
|
|
182
|
+
this.LOGGER.verbose(`Returning ${result.items.length} config items`);
|
|
183
|
+
}
|
|
184
|
+
return result.items;
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
if (this.options?.isVerbose) {
|
|
188
|
+
this.LOGGER.error(`Error in getList method: ${error.message}`);
|
|
189
|
+
}
|
|
190
|
+
if (error instanceof common.HttpException) {
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.FETCHING_LIST_ERROR }));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Sets a configuration value with optional encryption.
|
|
198
|
+
* The specified section must already exist.
|
|
199
|
+
* If a configuration with the same name and environment already exists, it will be updated. Otherwise, a new one will be created.
|
|
200
|
+
* @param {IConfigSetOptions} options Configuration set options
|
|
201
|
+
* @returns {Promise<IConfigData>} Promise resolving to the saved configuration data
|
|
202
|
+
*/
|
|
203
|
+
async set(options) {
|
|
204
|
+
if (this.options?.isVerbose) {
|
|
205
|
+
const maskedOptions = {
|
|
206
|
+
...options,
|
|
207
|
+
value: "***",
|
|
208
|
+
};
|
|
209
|
+
this.LOGGER.verbose(`Entering set method with options: ${JSON.stringify(maskedOptions)}`);
|
|
210
|
+
}
|
|
211
|
+
const { description, environment, eventManager, name, section: sectionName, value, } = options;
|
|
212
|
+
const finalEnvironment = environment ?? this.options?.environment ?? "default";
|
|
213
|
+
const shouldApplyEncryption = this.options?.encryptionOptions?.isEnabled ?? false;
|
|
214
|
+
let finalValue = value;
|
|
215
|
+
let isEncrypted = false;
|
|
216
|
+
if (shouldApplyEncryption) {
|
|
217
|
+
if (!this.options?.encryptionOptions?.encryptionKey) {
|
|
218
|
+
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.KEY_NOT_FOUND }));
|
|
219
|
+
}
|
|
220
|
+
if (!this.cryptoUtility) {
|
|
221
|
+
throw new common.InternalServerErrorException("CryptoUtility not available");
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
finalValue = this.cryptoUtility.encrypt(value, this.options.encryptionOptions.encryptionKey);
|
|
225
|
+
isEncrypted = true;
|
|
226
|
+
if (this.options?.isVerbose) {
|
|
227
|
+
this.LOGGER.verbose(`Encrypted value for ${name}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
if (this.options?.isVerbose) {
|
|
232
|
+
this.LOGGER.error(`Encryption error for ${name}: ${error.message}`);
|
|
233
|
+
}
|
|
234
|
+
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.ENCRYPTION_ERROR }));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
let queryRunner;
|
|
238
|
+
let useTransaction = false;
|
|
239
|
+
let localEventManager = eventManager;
|
|
240
|
+
try {
|
|
241
|
+
useTransaction = !eventManager;
|
|
242
|
+
if (useTransaction) {
|
|
243
|
+
if (!this.dataSource) {
|
|
244
|
+
throw new common.InternalServerErrorException("DataSource not available for transaction");
|
|
245
|
+
}
|
|
246
|
+
queryRunner = this.dataSource.createQueryRunner();
|
|
247
|
+
await queryRunner.connect();
|
|
248
|
+
await queryRunner.startTransaction();
|
|
249
|
+
localEventManager = queryRunner.manager;
|
|
250
|
+
}
|
|
251
|
+
if (this.options?.isVerbose) {
|
|
252
|
+
this.LOGGER.verbose(`Fetching or creating section: ${sectionName}`);
|
|
253
|
+
}
|
|
254
|
+
const section = await this.getOrCreateSection(sectionName, localEventManager);
|
|
255
|
+
if (this.options?.isVerbose) {
|
|
256
|
+
this.LOGGER.verbose(`Preparing config data for ${name}`);
|
|
257
|
+
}
|
|
258
|
+
const configData = {
|
|
259
|
+
description: description ?? undefined,
|
|
260
|
+
environment: finalEnvironment,
|
|
261
|
+
isEncrypted,
|
|
262
|
+
name,
|
|
263
|
+
section: { id: section.id },
|
|
264
|
+
value: finalValue,
|
|
265
|
+
};
|
|
266
|
+
let result;
|
|
267
|
+
try {
|
|
268
|
+
if (this.options?.isVerbose) {
|
|
269
|
+
this.LOGGER.verbose(`Checking for existing config: ${name}`);
|
|
270
|
+
}
|
|
271
|
+
const existingData = await this.dataService.get({ where: { environment: finalEnvironment, name, section: { id: section.id } } }, localEventManager);
|
|
272
|
+
if (this.options?.isVerbose) {
|
|
273
|
+
this.LOGGER.verbose(`Updating existing config: ${name}`);
|
|
274
|
+
}
|
|
275
|
+
result = await this.dataService.update({ id: existingData.id }, configData, localEventManager);
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
if (error instanceof common.NotFoundException) {
|
|
279
|
+
if (this.options?.isVerbose) {
|
|
280
|
+
this.LOGGER.verbose(`Config ${name} not found, creating new one`);
|
|
281
|
+
}
|
|
282
|
+
result = await this.dataService.create(configData, localEventManager);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
if (this.options?.isVerbose) {
|
|
286
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
287
|
+
this.LOGGER.error(`Error updating config: ${errorMessage}`);
|
|
288
|
+
}
|
|
289
|
+
throw error;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (this.options?.cacheOptions?.isEnabled && this.cacheManager) {
|
|
293
|
+
const cacheKey = `config:${sectionName}:${name}:${finalEnvironment}`;
|
|
294
|
+
const listCacheKey = `config:list:${sectionName}:${finalEnvironment}`;
|
|
295
|
+
await Promise.all([this.cacheManager.del(cacheKey), this.cacheManager.del(listCacheKey)]);
|
|
296
|
+
}
|
|
297
|
+
if (useTransaction && queryRunner) {
|
|
298
|
+
await queryRunner.commitTransaction();
|
|
299
|
+
await queryRunner.release();
|
|
300
|
+
}
|
|
301
|
+
if (this.options?.isVerbose) {
|
|
302
|
+
this.LOGGER.verbose(`Set method completed successfully for ${name}`);
|
|
303
|
+
}
|
|
304
|
+
return result;
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
if (useTransaction && queryRunner) {
|
|
308
|
+
await queryRunner.rollbackTransaction();
|
|
309
|
+
await queryRunner.release();
|
|
310
|
+
}
|
|
311
|
+
if (this.options?.isVerbose) {
|
|
312
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
313
|
+
this.LOGGER.error(`Error in set method: ${errorMessage}`);
|
|
314
|
+
}
|
|
315
|
+
if (error instanceof common.HttpException) {
|
|
316
|
+
throw error;
|
|
317
|
+
}
|
|
318
|
+
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.CREATING_ERROR }));
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
async getOrCreateSection(sectionName, eventManager) {
|
|
322
|
+
try {
|
|
323
|
+
return await this.sectionService.get({ where: { name: sectionName } }, eventManager);
|
|
324
|
+
}
|
|
325
|
+
catch (error) {
|
|
326
|
+
if (error instanceof common.NotFoundException && this.options?.shouldAutoCreateSections) {
|
|
327
|
+
if (this.options?.isVerbose) {
|
|
328
|
+
this.LOGGER.verbose(`Section ${sectionName} not found, creating new one`);
|
|
329
|
+
}
|
|
330
|
+
return await this.sectionService.create({ name: sectionName }, eventManager);
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
if (this.options?.isVerbose) {
|
|
334
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
335
|
+
this.LOGGER.error(`Error fetching section: ${errorMessage}`);
|
|
336
|
+
}
|
|
337
|
+
throw error;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
exports.CrudConfigService = CrudConfigService_1 = tslib_es6.__decorate([
|
|
343
|
+
common.Injectable(),
|
|
344
|
+
tslib_es6.__param(0, common.Inject(token_constant.TOKEN_CONSTANT.CONFIG_SECTION_SERVICE)),
|
|
345
|
+
tslib_es6.__param(1, common.Inject(token_constant.TOKEN_CONSTANT.CONFIG_DATA_SERVICE)),
|
|
346
|
+
tslib_es6.__param(2, common.Optional()),
|
|
347
|
+
tslib_es6.__param(2, common.Inject(cacheManager.CACHE_MANAGER)),
|
|
348
|
+
tslib_es6.__param(3, common.Optional()),
|
|
349
|
+
tslib_es6.__param(3, common.Inject(token_constant.TOKEN_CONSTANT.CONFIG_OPTIONS)),
|
|
350
|
+
tslib_es6.__metadata("design:paramtypes", [nestjsCrudAutomator.ApiServiceBase,
|
|
351
|
+
nestjsCrudAutomator.ApiServiceBase,
|
|
352
|
+
cacheManager.Cache, Object, typeorm.DataSource,
|
|
353
|
+
crypto_utility.CryptoUtility])
|
|
354
|
+
], exports.CrudConfigService);
|
|
355
|
+
//# sourceMappingURL=config.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.service.js","sources":["../../../../../src/modules/config/config.service.ts"],"sourcesContent":[null],"names":["CrudConfigService","Logger","HttpException","InternalServerErrorException","ErrorString","EErrorStringAction","NotFoundException","__decorate","Injectable","__param","Inject","TOKEN_CONSTANT","Optional","CACHE_MANAGER","ApiServiceBase","Cache","DataSource","CryptoUtility"],"mappings":";;;;;;;;;;;;AA+BA;;;AAGG;AAEUA,yBAAiB,GAAA,mBAAA,GAAvB,MAAM,iBAAiB,CAAA;AAKX,IAAA,cAAA;AAEA,IAAA,WAAA;AAEmC,IAAA,YAAA;AACgB,IAAA,OAAA;AACnD,IAAA,UAAA;AACA,IAAA,aAAA;IAXD,MAAM,GAAW,IAAIC,aAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC;IAEpE,WAAA,CAEkB,cAA8C,EAE9C,WAAwC,EAEL,YAAmB,EACH,OAAwB,EAC3E,UAAuB,EACvB,aAA6B,EAAA;QAP7B,IAAA,CAAA,cAAc,GAAd,cAAc;QAEd,IAAA,CAAA,WAAW,GAAX,WAAW;QAEwB,IAAA,CAAA,YAAY,GAAZ,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,CAAA;AAE7C,IAAAF,iBAAA,CAAA,CAAA,EAAAC,aAAM,CAACC,6BAAc,CAAC,mBAAmB,CAAC,CAAA;IAG1CF,iBAAA,CAAA,CAAA,EAAAG,eAAQ,EAAE,CAAA;AAAE,IAAAH,iBAAA,CAAA,CAAA,EAAAC,aAAM,CAACG,0BAAa,CAAC,CAAA;IACjCJ,iBAAA,CAAA,CAAA,EAAAG,eAAQ,EAAE,CAAA;AAAE,IAAAH,iBAAA,CAAA,CAAA,EAAAC,aAAM,CAACC,6BAAc,CAAC,cAAc,CAAC,CAAA;+CALjBG,kCAAc;QAEjBA,kCAAc;AAEsB,QAAAC,kBAAK,UAEzCC,kBAAU;QACPC,4BAAa,CAAA;AAZnC,CAAA,EAAAjB,yBAAiB,CAgc7B;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Type } from "@nestjs/common/interfaces";
|
|
2
|
+
import { IConfigControllerOptions } from '../../../shared/interface/config/index';
|
|
3
|
+
import { TDynamicEntity } from '../../../shared/type/index';
|
|
4
|
+
/**
|
|
5
|
+
* Factory to create dynamic ConfigData controller with the correct entity
|
|
6
|
+
* @param {TDynamicEntity} entity The entity type to create controller for
|
|
7
|
+
* @param {IConfigControllerOptions} [options] Controller configuration options
|
|
8
|
+
* @returns {Type} The dynamic controller class
|
|
9
|
+
*/
|
|
10
|
+
export declare function createDynamicDataController(entity: TDynamicEntity, options?: IConfigControllerOptions): Type;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib_es6 = require('../../../external/tslib/tslib.es6.js');
|
|
4
|
+
var nestjsCrudAutomator = require('@elsikora/nestjs-crud-automator');
|
|
5
|
+
var common = require('@nestjs/common');
|
|
6
|
+
var token_constant = require('../../../shared/constant/token.constant.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Factory to create dynamic ConfigData controller with the correct entity
|
|
10
|
+
* @param {TDynamicEntity} entity The entity type to create controller for
|
|
11
|
+
* @param {IConfigControllerOptions} [options] Controller configuration options
|
|
12
|
+
* @returns {Type} The dynamic controller class
|
|
13
|
+
*/
|
|
14
|
+
function createDynamicDataController(entity, options) {
|
|
15
|
+
const defaultConfig = {
|
|
16
|
+
entity,
|
|
17
|
+
name: "ConfigData",
|
|
18
|
+
path: "config/data",
|
|
19
|
+
routes: {
|
|
20
|
+
[nestjsCrudAutomator.EApiRouteType.CREATE]: {
|
|
21
|
+
isEnabled: true,
|
|
22
|
+
request: {
|
|
23
|
+
relations: {
|
|
24
|
+
relationsLoadStrategy: nestjsCrudAutomator.EApiControllerLoadRelationsStrategy.MANUAL,
|
|
25
|
+
relationsServices: {
|
|
26
|
+
section: "sectionService",
|
|
27
|
+
},
|
|
28
|
+
relationsToLoad: ["section"],
|
|
29
|
+
servicesLoadStrategy: nestjsCrudAutomator.EApiControllerLoadRelationsStrategy.MANUAL,
|
|
30
|
+
shouldLoadRelations: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
[nestjsCrudAutomator.EApiRouteType.DELETE]: { isEnabled: true },
|
|
35
|
+
[nestjsCrudAutomator.EApiRouteType.GET]: { isEnabled: true },
|
|
36
|
+
[nestjsCrudAutomator.EApiRouteType.GET_LIST]: { isEnabled: true },
|
|
37
|
+
[nestjsCrudAutomator.EApiRouteType.UPDATE]: {
|
|
38
|
+
isEnabled: true,
|
|
39
|
+
request: {
|
|
40
|
+
relations: {
|
|
41
|
+
relationsLoadStrategy: nestjsCrudAutomator.EApiControllerLoadRelationsStrategy.MANUAL,
|
|
42
|
+
relationsServices: {
|
|
43
|
+
section: "sectionService",
|
|
44
|
+
},
|
|
45
|
+
relationsToLoad: ["section"],
|
|
46
|
+
servicesLoadStrategy: nestjsCrudAutomator.EApiControllerLoadRelationsStrategy.MANUAL,
|
|
47
|
+
shouldLoadRelations: true,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
const config = {
|
|
54
|
+
...defaultConfig,
|
|
55
|
+
...options?.properties,
|
|
56
|
+
};
|
|
57
|
+
let DynamicConfigDataController = class DynamicConfigDataController {
|
|
58
|
+
service;
|
|
59
|
+
sectionService;
|
|
60
|
+
constructor(service, sectionService) {
|
|
61
|
+
this.service = service;
|
|
62
|
+
this.sectionService = sectionService;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
DynamicConfigDataController = tslib_es6.__decorate([
|
|
66
|
+
nestjsCrudAutomator.ApiController(config),
|
|
67
|
+
tslib_es6.__param(0, common.Inject(token_constant.TOKEN_CONSTANT.CONFIG_DATA_SERVICE)),
|
|
68
|
+
tslib_es6.__param(1, common.Inject(token_constant.TOKEN_CONSTANT.CONFIG_SECTION_SERVICE)),
|
|
69
|
+
tslib_es6.__metadata("design:paramtypes", [nestjsCrudAutomator.ApiServiceBase,
|
|
70
|
+
nestjsCrudAutomator.ApiServiceBase])
|
|
71
|
+
], DynamicConfigDataController);
|
|
72
|
+
return DynamicConfigDataController;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
exports.createDynamicDataController = createDynamicDataController;
|
|
76
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sources":["../../../../../../src/modules/config/data/controller.ts"],"sourcesContent":[null],"names":["EApiRouteType","EApiControllerLoadRelationsStrategy","__decorate","ApiController","__param","Inject","TOKEN_CONSTANT","ApiServiceBase"],"mappings":";;;;;;;AAcA;;;;;AAKG;AACG,SAAU,2BAA2B,CAC1C,MAAsB,EACtB,OAAkC,EAAA;AAElC,IAAA,MAAM,aAAa,GAA4C;QAC9D,MAAM;AACN,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,IAAI,EAAE,aAAa;AACnB,QAAA,MAAM,EAAE;AACP,YAAA,CAACA,iCAAa,CAAC,MAAM,GAAG;AACvB,gBAAA,SAAS,EAAE,IAAI;AACf,gBAAA,OA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AC,oBAAA,CAAA;QADhCC,iCAAa,CAAC,MAAM,CAAC;AAGnB,QAAAC,iBAAA,CAAA,CAAA,EAAAC,aAAM,CAACC,6BAAc,CAAC,mBAAmB,CAAC,CAAA;AAE1C,QAAAF,iBAAA,CAAA,CAAA,EAAAC,aAAM,CAACC,6BAAc,CAAC,sBAAsB,CAAC,CAAA;mDADrBC,kCAAc;YAEPA,kCAAc,CAAA;AAL1C,KAAA,EAAA,2BAA2B,CAOhC;AAED,IAAA,OAAO,2BAA2B;AACnC;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TDynamicEntity } from '../../../../shared/type/index';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a dynamic ConfigData entity with TypeORM decorators
|
|
4
|
+
* @param {object} options - Configuration options for the entity
|
|
5
|
+
* @param {TDynamicEntity} options.configSectionEntity - The ConfigSection entity to create relation with
|
|
6
|
+
* @param {number} options.maxDescriptionLength - Maximum length for description field
|
|
7
|
+
* @param {number} options.maxEnvironmentLength - Maximum length for environment field
|
|
8
|
+
* @param {number} options.maxNameLength - Maximum length for name field
|
|
9
|
+
* @param {number} options.maxValueLength - Maximum length for value field
|
|
10
|
+
* @param {string} options.tableName - Name of the database table
|
|
11
|
+
* @returns {TDynamicEntity} Dynamically created ConfigData entity class
|
|
12
|
+
*/
|
|
13
|
+
export declare function createConfigDataEntity(options: {
|
|
14
|
+
configSectionEntity: TDynamicEntity;
|
|
15
|
+
maxDescriptionLength: number;
|
|
16
|
+
maxEnvironmentLength: number;
|
|
17
|
+
maxNameLength: number;
|
|
18
|
+
maxValueLength: number;
|
|
19
|
+
tableName: string;
|
|
20
|
+
}): TDynamicEntity;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var nestjsCrudAutomator = require('@elsikora/nestjs-crud-automator');
|
|
4
|
+
var apiProperty_constant = require('../../../../shared/constant/api-property.constant.js');
|
|
5
|
+
var entity_utility = require('../../../../shared/utility/create-dynamic/entity.utility.js');
|
|
6
|
+
require('../../../../external/tslib/tslib.es6.js');
|
|
7
|
+
require('@nestjs/common');
|
|
8
|
+
require('@nestjs/typeorm');
|
|
9
|
+
var typeorm = require('typeorm');
|
|
10
|
+
require('../../../../shared/utility/crypto.utility.js');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates a dynamic ConfigData entity with TypeORM decorators
|
|
14
|
+
* @param {object} options - Configuration options for the entity
|
|
15
|
+
* @param {TDynamicEntity} options.configSectionEntity - The ConfigSection entity to create relation with
|
|
16
|
+
* @param {number} options.maxDescriptionLength - Maximum length for description field
|
|
17
|
+
* @param {number} options.maxEnvironmentLength - Maximum length for environment field
|
|
18
|
+
* @param {number} options.maxNameLength - Maximum length for name field
|
|
19
|
+
* @param {number} options.maxValueLength - Maximum length for value field
|
|
20
|
+
* @param {string} options.tableName - Name of the database table
|
|
21
|
+
* @returns {TDynamicEntity} Dynamically created ConfigData entity class
|
|
22
|
+
*/
|
|
23
|
+
function createConfigDataEntity(options) {
|
|
24
|
+
return entity_utility.createDynamicEntityClass({
|
|
25
|
+
columns: {
|
|
26
|
+
createdAt: {
|
|
27
|
+
default: () => "CURRENT_TIMESTAMP",
|
|
28
|
+
nullable: false,
|
|
29
|
+
type: "timestamp",
|
|
30
|
+
},
|
|
31
|
+
description: {
|
|
32
|
+
length: options.maxDescriptionLength,
|
|
33
|
+
nullable: true,
|
|
34
|
+
type: "varchar",
|
|
35
|
+
},
|
|
36
|
+
environment: {
|
|
37
|
+
length: options.maxEnvironmentLength,
|
|
38
|
+
nullable: false,
|
|
39
|
+
type: "varchar",
|
|
40
|
+
},
|
|
41
|
+
isEncrypted: {
|
|
42
|
+
default: false,
|
|
43
|
+
nullable: false,
|
|
44
|
+
type: "boolean",
|
|
45
|
+
},
|
|
46
|
+
name: {
|
|
47
|
+
length: options.maxNameLength,
|
|
48
|
+
nullable: false,
|
|
49
|
+
type: "varchar",
|
|
50
|
+
},
|
|
51
|
+
updatedAt: {
|
|
52
|
+
default: () => "CURRENT_TIMESTAMP",
|
|
53
|
+
nullable: false,
|
|
54
|
+
type: "timestamp",
|
|
55
|
+
},
|
|
56
|
+
value: {
|
|
57
|
+
length: options.maxValueLength,
|
|
58
|
+
nullable: false,
|
|
59
|
+
type: "varchar",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
decorators: {
|
|
63
|
+
createdAt: [
|
|
64
|
+
typeorm.CreateDateColumn(),
|
|
65
|
+
nestjsCrudAutomator.ApiPropertyDescribe({
|
|
66
|
+
format: nestjsCrudAutomator.EApiPropertyDateType.DATE_TIME,
|
|
67
|
+
identifier: nestjsCrudAutomator.EApiPropertyDateIdentifier.CREATED_AT,
|
|
68
|
+
type: nestjsCrudAutomator.EApiPropertyDescribeType.DATE,
|
|
69
|
+
}),
|
|
70
|
+
],
|
|
71
|
+
description: [
|
|
72
|
+
nestjsCrudAutomator.ApiPropertyDescribe({
|
|
73
|
+
description: "description",
|
|
74
|
+
exampleValue: "API key for third-party service",
|
|
75
|
+
format: nestjsCrudAutomator.EApiPropertyStringType.STRING,
|
|
76
|
+
isNullable: true,
|
|
77
|
+
maxLength: options.maxDescriptionLength,
|
|
78
|
+
minLength: apiProperty_constant.API_PROPERTY_CONSTANT.MIN_STRING_LENGTH,
|
|
79
|
+
pattern: `/.{0,${options.maxDescriptionLength}}/`,
|
|
80
|
+
type: nestjsCrudAutomator.EApiPropertyDescribeType.STRING,
|
|
81
|
+
}),
|
|
82
|
+
],
|
|
83
|
+
environment: [
|
|
84
|
+
nestjsCrudAutomator.ApiPropertyDescribe({
|
|
85
|
+
description: "environment",
|
|
86
|
+
exampleValue: "production",
|
|
87
|
+
format: nestjsCrudAutomator.EApiPropertyStringType.STRING,
|
|
88
|
+
maxLength: options.maxEnvironmentLength,
|
|
89
|
+
minLength: apiProperty_constant.API_PROPERTY_CONSTANT.MIN_NAME_LENGTH,
|
|
90
|
+
pattern: `/.{1,${options.maxEnvironmentLength}}/`,
|
|
91
|
+
type: nestjsCrudAutomator.EApiPropertyDescribeType.STRING,
|
|
92
|
+
}),
|
|
93
|
+
],
|
|
94
|
+
id: [
|
|
95
|
+
nestjsCrudAutomator.ApiPropertyDescribe({
|
|
96
|
+
type: nestjsCrudAutomator.EApiPropertyDescribeType.UUID,
|
|
97
|
+
}),
|
|
98
|
+
],
|
|
99
|
+
isEncrypted: [
|
|
100
|
+
nestjsCrudAutomator.ApiPropertyDescribe({
|
|
101
|
+
description: "isEncrypted",
|
|
102
|
+
type: nestjsCrudAutomator.EApiPropertyDescribeType.BOOLEAN,
|
|
103
|
+
}),
|
|
104
|
+
],
|
|
105
|
+
name: [
|
|
106
|
+
nestjsCrudAutomator.ApiPropertyDescribe({
|
|
107
|
+
description: "name",
|
|
108
|
+
exampleValue: "API_KEY",
|
|
109
|
+
format: nestjsCrudAutomator.EApiPropertyStringType.STRING,
|
|
110
|
+
maxLength: options.maxNameLength,
|
|
111
|
+
minLength: apiProperty_constant.API_PROPERTY_CONSTANT.MIN_NAME_LENGTH,
|
|
112
|
+
pattern: `/^[A-Za-z0-9_-]{1,${options.maxNameLength}}/`,
|
|
113
|
+
type: nestjsCrudAutomator.EApiPropertyDescribeType.STRING,
|
|
114
|
+
}),
|
|
115
|
+
],
|
|
116
|
+
section: [
|
|
117
|
+
nestjsCrudAutomator.ApiPropertyDescribe({
|
|
118
|
+
description: "section",
|
|
119
|
+
type: nestjsCrudAutomator.EApiPropertyDescribeType.RELATION,
|
|
120
|
+
}),
|
|
121
|
+
],
|
|
122
|
+
updatedAt: [
|
|
123
|
+
typeorm.UpdateDateColumn(),
|
|
124
|
+
nestjsCrudAutomator.ApiPropertyDescribe({
|
|
125
|
+
format: nestjsCrudAutomator.EApiPropertyDateType.DATE_TIME,
|
|
126
|
+
identifier: nestjsCrudAutomator.EApiPropertyDateIdentifier.UPDATED_AT,
|
|
127
|
+
type: nestjsCrudAutomator.EApiPropertyDescribeType.DATE,
|
|
128
|
+
}),
|
|
129
|
+
],
|
|
130
|
+
value: [
|
|
131
|
+
nestjsCrudAutomator.ApiPropertyDescribe({
|
|
132
|
+
description: "value",
|
|
133
|
+
exampleValue: "configuration-value",
|
|
134
|
+
format: nestjsCrudAutomator.EApiPropertyStringType.STRING,
|
|
135
|
+
maxLength: options.maxValueLength,
|
|
136
|
+
minLength: apiProperty_constant.API_PROPERTY_CONSTANT.MIN_STRING_LENGTH,
|
|
137
|
+
pattern: `/.{0,${options.maxValueLength}}/`,
|
|
138
|
+
type: nestjsCrudAutomator.EApiPropertyDescribeType.STRING,
|
|
139
|
+
}),
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
name: "ConfigData",
|
|
143
|
+
relations: {
|
|
144
|
+
section: {
|
|
145
|
+
decorator: { target: options.configSectionEntity },
|
|
146
|
+
eager: false,
|
|
147
|
+
nullable: false,
|
|
148
|
+
onDelete: "CASCADE",
|
|
149
|
+
type: "ManyToOne",
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
tableName: options.tableName,
|
|
153
|
+
uniques: [["name", "environment", "section"]],
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
exports.createConfigDataEntity = createConfigDataEntity;
|
|
158
|
+
//# sourceMappingURL=entity.js.map
|