@elsikora/nestjs-crud-config 4.1.0-dev.1 → 5.0.0-dev.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/README.md +31 -24
- package/dist/{esm/external → external}/tslib/tslib.es6.js +0 -1
- package/dist/{esm/index.d.ts → index.d.ts} +2 -2
- package/dist/{esm/index.js → index.js} +0 -1
- package/dist/{esm/modules → modules}/config/config.module.d.ts +1 -1
- package/dist/{esm/modules → modules}/config/config.module.js +0 -1
- package/dist/{cjs/modules → modules}/config/config.service.d.ts +5 -5
- package/dist/{esm/modules → modules}/config/config.service.js +0 -1
- package/dist/{cjs/modules → modules}/config/data/controller.d.ts +4 -4
- package/dist/{esm/modules → modules}/config/data/controller.js +0 -1
- package/dist/{cjs/modules → modules}/config/data/entity/entity.d.ts +3 -3
- package/dist/{esm/modules → modules}/config/data/entity/entity.js +0 -1
- package/dist/modules/config/data/entity/index.d.ts +1 -0
- package/dist/modules/config/data/index.d.ts +3 -0
- package/dist/modules/config/data/interface/index.d.ts +1 -0
- package/dist/{cjs/modules → modules}/config/data/interface/interface.d.ts +1 -1
- package/dist/modules/config/index.d.ts +11 -0
- package/dist/modules/config/interface/index.d.ts +4 -0
- package/dist/{cjs/modules → modules}/config/migration/entity/entity.d.ts +2 -2
- package/dist/{esm/modules → modules}/config/migration/entity/entity.js +0 -1
- package/dist/modules/config/migration/entity/index.d.ts +1 -0
- package/dist/modules/config/migration/enum/index.d.ts +1 -0
- package/dist/{esm/modules → modules}/config/migration/enum/status.js +0 -1
- package/dist/modules/config/migration/index.d.ts +5 -0
- package/dist/{cjs/modules → modules}/config/migration/interface/index.d.ts +3 -3
- package/dist/{esm/modules → modules}/config/migration/interface/interface.d.ts +1 -1
- package/dist/{cjs/modules → modules}/config/migration/interface/migration-definition.interface.d.ts +1 -1
- package/dist/{esm/modules → modules}/config/migration/interface/migration-options.interface.d.ts +1 -1
- package/dist/{esm/modules → modules}/config/migration/migration-runner.service.d.ts +2 -2
- package/dist/{esm/modules → modules}/config/migration/migration-runner.service.js +0 -1
- package/dist/{esm/modules → modules}/config/migration/migration.service.d.ts +3 -3
- package/dist/{esm/modules → modules}/config/migration/migration.service.js +2 -6
- package/dist/{cjs/modules → modules}/config/section/controller.d.ts +4 -4
- package/dist/{esm/modules → modules}/config/section/controller.js +0 -1
- package/dist/{esm/modules → modules}/config/section/entity/entity.d.ts +2 -2
- package/dist/{esm/modules → modules}/config/section/entity/entity.js +0 -1
- package/dist/modules/config/section/entity/index.d.ts +1 -0
- package/dist/modules/config/section/index.d.ts +2 -0
- package/dist/modules/config/section/interface/index.d.ts +1 -0
- package/dist/modules/config/type/index.d.ts +2 -0
- package/dist/{cjs/modules → modules}/config/type/type.d.ts +1 -1
- package/dist/modules/index.d.ts +1 -0
- package/dist/{esm/shared → shared}/constant/api-property.constant.js +0 -1
- package/dist/{esm/shared → shared}/constant/config/data.constant.js +0 -1
- package/dist/shared/constant/config/index.d.ts +3 -0
- package/dist/{esm/shared → shared}/constant/config/migration.constant.js +0 -1
- package/dist/{esm/shared → shared}/constant/config/section.constant.js +0 -1
- package/dist/{esm/shared → shared}/constant/crypto.constant.js +0 -1
- package/dist/shared/constant/index.d.ts +4 -0
- package/dist/{esm/shared → shared}/constant/token.constant.js +0 -1
- package/dist/{esm/shared → shared}/enum/environment.enum.js +0 -1
- package/dist/shared/enum/index.d.ts +6 -0
- package/dist/{esm/shared → shared}/enum/instance-name.enum.js +0 -1
- package/dist/{esm/shared → shared}/enum/service.enum.js +0 -1
- package/dist/shared/index.d.ts +5 -0
- package/dist/{cjs/shared → shared}/interface/config/async-module-properties.interface.d.ts +4 -4
- package/dist/{cjs/shared → shared}/interface/config/controller-options.interface.d.ts +2 -2
- package/dist/{cjs/shared → shared}/interface/config/entity/index.d.ts +3 -3
- package/dist/{esm/shared → shared}/interface/config/entity/options.interface.d.ts +1 -1
- package/dist/{cjs/shared → shared}/interface/config/index.d.ts +8 -8
- package/dist/{esm/shared → shared}/interface/config/options.interface.d.ts +5 -5
- package/dist/{cjs/shared → shared}/interface/config/properties-factory.interface.d.ts +1 -1
- package/dist/{esm/shared → shared}/interface/config/static-options.interface.d.ts +2 -2
- package/dist/shared/interface/index.d.ts +2 -0
- package/dist/{cjs/shared → shared}/interface/utility/create-dynamic-entity/index.d.ts +2 -2
- package/dist/{esm/shared → shared}/interface/utility/create-dynamic-entity/options.interface.d.ts +1 -1
- package/dist/shared/interface/utility/index.d.ts +1 -0
- package/dist/shared/type/index.d.ts +1 -0
- package/dist/{cjs/shared → shared}/utility/create-dynamic/entity.utility.d.ts +2 -2
- package/dist/{esm/shared → shared}/utility/create-dynamic/entity.utility.js +0 -1
- package/dist/shared/utility/create-dynamic/index.d.ts +2 -0
- package/dist/{cjs/shared → shared}/utility/create-dynamic/service.utility.d.ts +1 -1
- package/dist/{esm/shared → shared}/utility/create-dynamic/service.utility.js +0 -1
- package/dist/{cjs/shared → shared}/utility/crypto.utility.d.ts +1 -1
- package/dist/{esm/shared → shared}/utility/crypto.utility.js +0 -1
- package/dist/shared/utility/index.d.ts +4 -0
- package/dist/shared/utility/logger.utility.d.ts +37 -0
- package/dist/{esm/shared → shared}/utility/logger.utility.js +26 -6
- package/package.json +72 -65
- package/dist/cjs/external/tslib/tslib.es6.js +0 -43
- package/dist/cjs/external/tslib/tslib.es6.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -11
- package/dist/cjs/index.js +0 -81
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/modules/config/config.module.d.ts +0 -33
- package/dist/cjs/modules/config/config.module.js +0 -321
- package/dist/cjs/modules/config/config.module.js.map +0 -1
- package/dist/cjs/modules/config/config.service.js +0 -315
- package/dist/cjs/modules/config/config.service.js.map +0 -1
- package/dist/cjs/modules/config/data/controller.js +0 -124
- package/dist/cjs/modules/config/data/controller.js.map +0 -1
- package/dist/cjs/modules/config/data/entity/entity.js +0 -161
- package/dist/cjs/modules/config/data/entity/entity.js.map +0 -1
- package/dist/cjs/modules/config/data/entity/index.d.ts +0 -1
- package/dist/cjs/modules/config/data/index.d.ts +0 -3
- package/dist/cjs/modules/config/data/interface/index.d.ts +0 -1
- package/dist/cjs/modules/config/index.d.ts +0 -11
- package/dist/cjs/modules/config/interface/index.d.ts +0 -4
- package/dist/cjs/modules/config/migration/entity/entity.js +0 -141
- package/dist/cjs/modules/config/migration/entity/entity.js.map +0 -1
- package/dist/cjs/modules/config/migration/entity/index.d.ts +0 -1
- package/dist/cjs/modules/config/migration/enum/index.d.ts +0 -1
- package/dist/cjs/modules/config/migration/enum/status.js +0 -11
- package/dist/cjs/modules/config/migration/enum/status.js.map +0 -1
- package/dist/cjs/modules/config/migration/index.d.ts +0 -5
- package/dist/cjs/modules/config/migration/interface/interface.d.ts +0 -12
- package/dist/cjs/modules/config/migration/interface/migration-options.interface.d.ts +0 -39
- package/dist/cjs/modules/config/migration/migration-runner.service.d.ts +0 -26
- package/dist/cjs/modules/config/migration/migration-runner.service.js +0 -93
- package/dist/cjs/modules/config/migration/migration-runner.service.js.map +0 -1
- package/dist/cjs/modules/config/migration/migration.service.d.ts +0 -79
- package/dist/cjs/modules/config/migration/migration.service.js +0 -377
- package/dist/cjs/modules/config/migration/migration.service.js.map +0 -1
- package/dist/cjs/modules/config/section/controller.js +0 -86
- package/dist/cjs/modules/config/section/controller.js.map +0 -1
- package/dist/cjs/modules/config/section/entity/entity.d.ts +0 -18
- package/dist/cjs/modules/config/section/entity/entity.js +0 -99
- package/dist/cjs/modules/config/section/entity/entity.js.map +0 -1
- package/dist/cjs/modules/config/section/entity/index.d.ts +0 -1
- package/dist/cjs/modules/config/section/index.d.ts +0 -2
- package/dist/cjs/modules/config/section/interface/index.d.ts +0 -1
- package/dist/cjs/modules/config/type/index.d.ts +0 -2
- package/dist/cjs/modules/index.d.ts +0 -1
- package/dist/cjs/package.json +0 -8
- package/dist/cjs/shared/constant/api-property.constant.js +0 -11
- package/dist/cjs/shared/constant/api-property.constant.js.map +0 -1
- package/dist/cjs/shared/constant/config/data.constant.js +0 -17
- package/dist/cjs/shared/constant/config/data.constant.js.map +0 -1
- package/dist/cjs/shared/constant/config/index.d.ts +0 -3
- package/dist/cjs/shared/constant/config/migration.constant.js +0 -15
- package/dist/cjs/shared/constant/config/migration.constant.js.map +0 -1
- package/dist/cjs/shared/constant/config/section.constant.js +0 -13
- package/dist/cjs/shared/constant/config/section.constant.js.map +0 -1
- package/dist/cjs/shared/constant/crypto.constant.js +0 -17
- package/dist/cjs/shared/constant/crypto.constant.js.map +0 -1
- package/dist/cjs/shared/constant/index.d.ts +0 -4
- package/dist/cjs/shared/constant/token.constant.js +0 -24
- package/dist/cjs/shared/constant/token.constant.js.map +0 -1
- package/dist/cjs/shared/enum/environment.enum.js +0 -20
- package/dist/cjs/shared/enum/environment.enum.js.map +0 -1
- package/dist/cjs/shared/enum/index.d.ts +0 -6
- package/dist/cjs/shared/enum/instance-name.enum.js +0 -11
- package/dist/cjs/shared/enum/instance-name.enum.js.map +0 -1
- package/dist/cjs/shared/enum/service.enum.js +0 -224
- package/dist/cjs/shared/enum/service.enum.js.map +0 -1
- package/dist/cjs/shared/index.d.ts +0 -5
- package/dist/cjs/shared/interface/config/entity/options.interface.d.ts +0 -25
- package/dist/cjs/shared/interface/config/options.interface.d.ts +0 -39
- package/dist/cjs/shared/interface/config/static-options.interface.d.ts +0 -45
- package/dist/cjs/shared/interface/index.d.ts +0 -2
- package/dist/cjs/shared/interface/utility/create-dynamic-entity/options.interface.d.ts +0 -15
- package/dist/cjs/shared/interface/utility/index.d.ts +0 -1
- package/dist/cjs/shared/type/index.d.ts +0 -1
- package/dist/cjs/shared/utility/create-dynamic/entity.utility.js +0 -68
- package/dist/cjs/shared/utility/create-dynamic/entity.utility.js.map +0 -1
- package/dist/cjs/shared/utility/create-dynamic/index.d.ts +0 -2
- package/dist/cjs/shared/utility/create-dynamic/service.utility.js +0 -35
- package/dist/cjs/shared/utility/create-dynamic/service.utility.js.map +0 -1
- package/dist/cjs/shared/utility/crypto.utility.js +0 -133
- package/dist/cjs/shared/utility/crypto.utility.js.map +0 -1
- package/dist/cjs/shared/utility/index.d.ts +0 -4
- package/dist/cjs/shared/utility/logger.utility.d.ts +0 -21
- package/dist/cjs/shared/utility/logger.utility.js +0 -68
- package/dist/cjs/shared/utility/logger.utility.js.map +0 -1
- package/dist/esm/external/tslib/tslib.es6.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/modules/config/config.module.js.map +0 -1
- package/dist/esm/modules/config/config.service.d.ts +0 -56
- package/dist/esm/modules/config/config.service.js.map +0 -1
- package/dist/esm/modules/config/data/controller.d.ts +0 -11
- package/dist/esm/modules/config/data/controller.js.map +0 -1
- package/dist/esm/modules/config/data/entity/entity.d.ts +0 -25
- package/dist/esm/modules/config/data/entity/entity.js.map +0 -1
- package/dist/esm/modules/config/data/entity/index.d.ts +0 -1
- package/dist/esm/modules/config/data/index.d.ts +0 -3
- package/dist/esm/modules/config/data/interface/index.d.ts +0 -1
- package/dist/esm/modules/config/data/interface/interface.d.ts +0 -13
- package/dist/esm/modules/config/index.d.ts +0 -11
- package/dist/esm/modules/config/interface/delete-options.interface.d.ts +0 -24
- package/dist/esm/modules/config/interface/get-list-options.interface.d.ts +0 -24
- package/dist/esm/modules/config/interface/get-options.interface.d.ts +0 -32
- package/dist/esm/modules/config/interface/index.d.ts +0 -4
- package/dist/esm/modules/config/interface/set-options.interface.d.ts +0 -36
- package/dist/esm/modules/config/migration/entity/entity.d.ts +0 -16
- package/dist/esm/modules/config/migration/entity/entity.js.map +0 -1
- package/dist/esm/modules/config/migration/entity/index.d.ts +0 -1
- package/dist/esm/modules/config/migration/enum/index.d.ts +0 -1
- package/dist/esm/modules/config/migration/enum/status.d.ts +0 -7
- package/dist/esm/modules/config/migration/enum/status.js.map +0 -1
- package/dist/esm/modules/config/migration/index.d.ts +0 -5
- package/dist/esm/modules/config/migration/interface/index.d.ts +0 -3
- package/dist/esm/modules/config/migration/interface/migration-definition.interface.d.ts +0 -31
- package/dist/esm/modules/config/migration/migration-runner.service.js.map +0 -1
- package/dist/esm/modules/config/migration/migration.service.js.map +0 -1
- package/dist/esm/modules/config/section/controller.d.ts +0 -11
- package/dist/esm/modules/config/section/controller.js.map +0 -1
- package/dist/esm/modules/config/section/entity/entity.js.map +0 -1
- package/dist/esm/modules/config/section/entity/index.d.ts +0 -1
- package/dist/esm/modules/config/section/index.d.ts +0 -2
- package/dist/esm/modules/config/section/interface/index.d.ts +0 -1
- package/dist/esm/modules/config/section/interface/interface.d.ts +0 -8
- package/dist/esm/modules/config/type/index.d.ts +0 -2
- package/dist/esm/modules/config/type/item.type.d.ts +0 -1
- package/dist/esm/modules/config/type/type.d.ts +0 -2
- package/dist/esm/modules/index.d.ts +0 -1
- package/dist/esm/package.json +0 -8
- package/dist/esm/shared/constant/api-property.constant.d.ts +0 -4
- package/dist/esm/shared/constant/api-property.constant.js.map +0 -1
- package/dist/esm/shared/constant/config/data.constant.d.ts +0 -7
- package/dist/esm/shared/constant/config/data.constant.js.map +0 -1
- package/dist/esm/shared/constant/config/index.d.ts +0 -3
- package/dist/esm/shared/constant/config/migration.constant.d.ts +0 -6
- package/dist/esm/shared/constant/config/migration.constant.js.map +0 -1
- package/dist/esm/shared/constant/config/section.constant.d.ts +0 -5
- package/dist/esm/shared/constant/config/section.constant.js.map +0 -1
- package/dist/esm/shared/constant/crypto.constant.d.ts +0 -7
- package/dist/esm/shared/constant/crypto.constant.js.map +0 -1
- package/dist/esm/shared/constant/index.d.ts +0 -4
- package/dist/esm/shared/constant/token.constant.d.ts +0 -10
- package/dist/esm/shared/constant/token.constant.js.map +0 -1
- package/dist/esm/shared/enum/environment.enum.d.ts +0 -16
- package/dist/esm/shared/enum/environment.enum.js.map +0 -1
- package/dist/esm/shared/enum/index.d.ts +0 -6
- package/dist/esm/shared/enum/instance-name.enum.d.ts +0 -7
- package/dist/esm/shared/enum/instance-name.enum.js.map +0 -1
- package/dist/esm/shared/enum/service.enum.d.ts +0 -220
- package/dist/esm/shared/enum/service.enum.js.map +0 -1
- package/dist/esm/shared/index.d.ts +0 -5
- package/dist/esm/shared/interface/config/async-module-properties.interface.d.ts +0 -47
- package/dist/esm/shared/interface/config/cache-options.interface.d.ts +0 -18
- package/dist/esm/shared/interface/config/controller-options.interface.d.ts +0 -32
- package/dist/esm/shared/interface/config/encryption-options.interface.d.ts +0 -19
- package/dist/esm/shared/interface/config/entity/data-options.interface.d.ts +0 -25
- package/dist/esm/shared/interface/config/entity/index.d.ts +0 -3
- package/dist/esm/shared/interface/config/entity/section-options.interface.d.ts +0 -17
- package/dist/esm/shared/interface/config/index.d.ts +0 -8
- package/dist/esm/shared/interface/config/properties-factory.interface.d.ts +0 -11
- package/dist/esm/shared/interface/index.d.ts +0 -2
- package/dist/esm/shared/interface/utility/create-dynamic-entity/index.d.ts +0 -2
- package/dist/esm/shared/interface/utility/create-dynamic-entity/relation-options.interface.d.ts +0 -9
- package/dist/esm/shared/interface/utility/index.d.ts +0 -1
- package/dist/esm/shared/type/dynamic-entity.type.d.ts +0 -2
- package/dist/esm/shared/type/index.d.ts +0 -1
- package/dist/esm/shared/utility/create-dynamic/entity.utility.d.ts +0 -11
- package/dist/esm/shared/utility/create-dynamic/entity.utility.js.map +0 -1
- package/dist/esm/shared/utility/create-dynamic/index.d.ts +0 -2
- package/dist/esm/shared/utility/create-dynamic/service.utility.d.ts +0 -10
- package/dist/esm/shared/utility/create-dynamic/service.utility.js.map +0 -1
- package/dist/esm/shared/utility/crypto.utility.d.ts +0 -37
- package/dist/esm/shared/utility/crypto.utility.js.map +0 -1
- package/dist/esm/shared/utility/index.d.ts +0 -4
- package/dist/esm/shared/utility/logger.utility.d.ts +0 -21
- package/dist/esm/shared/utility/logger.utility.js.map +0 -1
- /package/dist/{cjs/modules → modules}/config/interface/delete-options.interface.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/config/interface/get-list-options.interface.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/config/interface/get-options.interface.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/config/interface/set-options.interface.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/config/migration/enum/status.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/config/section/interface/interface.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/config/type/item.type.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/constant/api-property.constant.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/constant/config/data.constant.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/constant/config/migration.constant.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/constant/config/section.constant.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/constant/crypto.constant.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/constant/token.constant.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/enum/environment.enum.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/enum/instance-name.enum.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/enum/service.enum.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/interface/config/cache-options.interface.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/interface/config/encryption-options.interface.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/interface/config/entity/data-options.interface.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/interface/config/entity/section-options.interface.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/interface/utility/create-dynamic-entity/relation-options.interface.d.ts +0 -0
- /package/dist/{cjs/shared → shared}/type/dynamic-entity.type.d.ts +0 -0
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var tslib_es6 = require('../../external/tslib/tslib.es6.js');
|
|
4
|
-
var controller$1 = require('./data/controller.js');
|
|
5
|
-
var entity$1 = require('./data/entity/entity.js');
|
|
6
|
-
var entity$2 = require('./migration/entity/entity.js');
|
|
7
|
-
require('./migration/enum/status.js');
|
|
8
|
-
var migrationRunner_service = require('./migration/migration-runner.service.js');
|
|
9
|
-
var migration_service = require('./migration/migration.service.js');
|
|
10
|
-
var entity = require('./section/entity/entity.js');
|
|
11
|
-
var controller = require('./section/controller.js');
|
|
12
|
-
var cacheManager = require('@nestjs/cache-manager');
|
|
13
|
-
var common = require('@nestjs/common');
|
|
14
|
-
var typeorm = require('@nestjs/typeorm');
|
|
15
|
-
var data_constant = require('../../shared/constant/config/data.constant.js');
|
|
16
|
-
var migration_constant = require('../../shared/constant/config/migration.constant.js');
|
|
17
|
-
var section_constant = require('../../shared/constant/config/section.constant.js');
|
|
18
|
-
var token_constant = require('../../shared/constant/token.constant.js');
|
|
19
|
-
require('typeorm');
|
|
20
|
-
var service_utility = require('../../shared/utility/create-dynamic/service.utility.js');
|
|
21
|
-
var crypto_utility = require('../../shared/utility/crypto.utility.js');
|
|
22
|
-
require('../../shared/utility/logger.utility.js');
|
|
23
|
-
var config_service = require('./config.service.js');
|
|
24
|
-
|
|
25
|
-
var CrudConfigModule_1;
|
|
26
|
-
exports.CrudConfigModule = CrudConfigModule_1 = class CrudConfigModule {
|
|
27
|
-
static register(options) {
|
|
28
|
-
const prefix = options.entityOptions?.tablePrefix ?? "";
|
|
29
|
-
const timestampColumnType = options.entityOptions?.timestampColumnType ?? "timestamp";
|
|
30
|
-
const sectionEntity = entity.createConfigSectionEntity({
|
|
31
|
-
maxDescriptionLength: options.entityOptions?.configSection?.maxDescriptionLength ??
|
|
32
|
-
section_constant.CONFIG_SECTION_CONSTANT.MAX_DESCRIPTION_LENGTH,
|
|
33
|
-
maxNameLength: options.entityOptions?.configSection?.maxNameLength ?? section_constant.CONFIG_SECTION_CONSTANT.MAX_NAME_LENGTH,
|
|
34
|
-
tableName: prefix +
|
|
35
|
-
(options.entityOptions?.configSection?.tableName ?? section_constant.CONFIG_SECTION_CONSTANT.DEFAULT_TABLE_NAME),
|
|
36
|
-
timestampColumnType,
|
|
37
|
-
});
|
|
38
|
-
const dataEntity = entity$1.createConfigDataEntity({
|
|
39
|
-
configSectionEntity: sectionEntity,
|
|
40
|
-
maxDescriptionLength: options.entityOptions?.configData?.maxDescriptionLength ??
|
|
41
|
-
data_constant.CONFIG_DATA_CONSTANT.MAX_DESCRIPTION_LENGTH,
|
|
42
|
-
maxEnvironmentLength: options.entityOptions?.configData?.maxEnvironmentLength ??
|
|
43
|
-
data_constant.CONFIG_DATA_CONSTANT.MAX_ENVIRONMENT_LENGTH,
|
|
44
|
-
maxNameLength: options.entityOptions?.configData?.maxNameLength ?? data_constant.CONFIG_DATA_CONSTANT.MAX_NAME_LENGTH,
|
|
45
|
-
maxValueLength: options.entityOptions?.configData?.maxValueLength ?? data_constant.CONFIG_DATA_CONSTANT.MAX_VALUE_LENGTH,
|
|
46
|
-
tableName: prefix +
|
|
47
|
-
(options.entityOptions?.configData?.tableName ?? data_constant.CONFIG_DATA_CONSTANT.DEFAULT_TABLE_NAME),
|
|
48
|
-
timestampColumnType,
|
|
49
|
-
});
|
|
50
|
-
const migrationEntity = entity$2.createConfigMigrationEntity({
|
|
51
|
-
maxNameLength: options.migrationOptions?.maxNameLength ?? migration_constant.CONFIG_MIGRATION_CONSTANT.MAX_NAME_LENGTH,
|
|
52
|
-
tableName: prefix + (options.migrationOptions?.tableName ?? migration_constant.CONFIG_MIGRATION_CONSTANT.DEFAULT_TABLE_NAME),
|
|
53
|
-
timestampColumnType,
|
|
54
|
-
});
|
|
55
|
-
const propertiesProvider = {
|
|
56
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_OPTIONS,
|
|
57
|
-
useValue: options,
|
|
58
|
-
};
|
|
59
|
-
const sectionEntityProvider = {
|
|
60
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_SECTION_ENTITY,
|
|
61
|
-
useValue: sectionEntity,
|
|
62
|
-
};
|
|
63
|
-
const dataEntityProvider = {
|
|
64
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_DATA_ENTITY,
|
|
65
|
-
useValue: dataEntity,
|
|
66
|
-
};
|
|
67
|
-
const migrationEntityProvider = {
|
|
68
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_MIGRATION_ENTITY,
|
|
69
|
-
useValue: migrationEntity,
|
|
70
|
-
};
|
|
71
|
-
const sectionRepositoryProvider = {
|
|
72
|
-
inject: [typeorm.getDataSourceToken()],
|
|
73
|
-
provide: typeorm.getRepositoryToken(sectionEntity),
|
|
74
|
-
useFactory: (dataSource) => {
|
|
75
|
-
return dataSource.getRepository(sectionEntity);
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
const dataRepositoryProvider = {
|
|
79
|
-
inject: [typeorm.getDataSourceToken()],
|
|
80
|
-
provide: typeorm.getRepositoryToken(dataEntity),
|
|
81
|
-
useFactory: (dataSource) => {
|
|
82
|
-
return dataSource.getRepository(dataEntity);
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
const migrationRepositoryProvider = {
|
|
86
|
-
inject: [typeorm.getDataSourceToken()],
|
|
87
|
-
provide: typeorm.getRepositoryToken(migrationEntity),
|
|
88
|
-
useFactory: (dataSource) => {
|
|
89
|
-
return dataSource.getRepository(migrationEntity);
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
const DynamicConfigSectionService = service_utility.createDynamicService(sectionEntity, "ConfigSectionService");
|
|
93
|
-
const DynamicConfigDataService = service_utility.createDynamicService(dataEntity, "ConfigDataService");
|
|
94
|
-
const sectionServiceProvider = {
|
|
95
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_SECTION_SERVICE,
|
|
96
|
-
useClass: DynamicConfigSectionService,
|
|
97
|
-
};
|
|
98
|
-
const dataServiceProvider = {
|
|
99
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_DATA_SERVICE,
|
|
100
|
-
useClass: DynamicConfigDataService,
|
|
101
|
-
};
|
|
102
|
-
const DynamicConfigMigrationService = service_utility.createDynamicService(migrationEntity, "ConfigMigrationService");
|
|
103
|
-
const migrationServiceProvider = {
|
|
104
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_MIGRATION_SERVICE,
|
|
105
|
-
useClass: DynamicConfigMigrationService,
|
|
106
|
-
};
|
|
107
|
-
const DynamicConfigSectionController = options.controllersOptions?.section?.isEnabled === false
|
|
108
|
-
? null
|
|
109
|
-
: controller.createDynamicSectionController(sectionEntity, options.controllersOptions?.section);
|
|
110
|
-
const DynamicConfigDataController = options.controllersOptions?.data?.isEnabled === false
|
|
111
|
-
? null
|
|
112
|
-
: controller$1.createDynamicDataController(dataEntity, options.controllersOptions?.data);
|
|
113
|
-
const imports = [];
|
|
114
|
-
if (options.cacheOptions?.isEnabled) {
|
|
115
|
-
imports.push(cacheManager.CacheModule.register({
|
|
116
|
-
max: options.cacheOptions.maxCacheItems,
|
|
117
|
-
ttl: options.cacheOptions.maxCacheTTL,
|
|
118
|
-
}));
|
|
119
|
-
}
|
|
120
|
-
const controllers = [];
|
|
121
|
-
if (DynamicConfigSectionController)
|
|
122
|
-
controllers.push(DynamicConfigSectionController);
|
|
123
|
-
if (DynamicConfigDataController)
|
|
124
|
-
controllers.push(DynamicConfigDataController);
|
|
125
|
-
return {
|
|
126
|
-
controllers,
|
|
127
|
-
exports: [
|
|
128
|
-
config_service.CrudConfigService,
|
|
129
|
-
token_constant.TOKEN_CONSTANT.CONFIG_SECTION_ENTITY,
|
|
130
|
-
token_constant.TOKEN_CONSTANT.CONFIG_DATA_ENTITY,
|
|
131
|
-
token_constant.TOKEN_CONSTANT.CONFIG_MIGRATION_ENTITY,
|
|
132
|
-
token_constant.TOKEN_CONSTANT.CONFIG_SECTION_SERVICE,
|
|
133
|
-
token_constant.TOKEN_CONSTANT.CONFIG_DATA_SERVICE,
|
|
134
|
-
token_constant.TOKEN_CONSTANT.CONFIG_MIGRATION_SERVICE,
|
|
135
|
-
migration_service.ConfigMigrationService,
|
|
136
|
-
migrationRunner_service.ConfigMigrationRunnerService,
|
|
137
|
-
crypto_utility.CryptoUtility,
|
|
138
|
-
],
|
|
139
|
-
imports,
|
|
140
|
-
module: CrudConfigModule_1,
|
|
141
|
-
providers: [
|
|
142
|
-
propertiesProvider,
|
|
143
|
-
sectionEntityProvider,
|
|
144
|
-
dataEntityProvider,
|
|
145
|
-
migrationEntityProvider,
|
|
146
|
-
sectionRepositoryProvider,
|
|
147
|
-
dataRepositoryProvider,
|
|
148
|
-
migrationRepositoryProvider,
|
|
149
|
-
sectionServiceProvider,
|
|
150
|
-
dataServiceProvider,
|
|
151
|
-
migrationServiceProvider,
|
|
152
|
-
config_service.CrudConfigService,
|
|
153
|
-
migration_service.ConfigMigrationService,
|
|
154
|
-
migrationRunner_service.ConfigMigrationRunnerService,
|
|
155
|
-
crypto_utility.CryptoUtility,
|
|
156
|
-
],
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Registers the module asynchronously. This implementation defers all dynamic provider
|
|
161
|
-
* creation into factories to ensure correct instantiation order.
|
|
162
|
-
*
|
|
163
|
-
* Controllers and entities must be configured via the `staticOptions` property,
|
|
164
|
-
* as NestJS does not support async controller registration. Options provided in
|
|
165
|
-
* `staticOptions.entityOptions` will be used for both controllers and service providers.
|
|
166
|
-
* @see {@link https://elsikora.com/docs/nestjs-crud-config/core-concepts/module-registration | Core Concepts - Module Registration}
|
|
167
|
-
* @see {@link https://elsikora.com/docs/nestjs-crud-config/api-reference/classes/crud-config-module | API Reference - CrudConfigModule}
|
|
168
|
-
* @param {ICrudConfigAsyncModuleProperties} properties Async configuration options
|
|
169
|
-
* @returns {DynamicModule} Dynamic module configuration
|
|
170
|
-
* @example
|
|
171
|
-
* ```typescript
|
|
172
|
-
* CrudConfigModule.registerAsync({
|
|
173
|
-
* imports: [ConfigModule],
|
|
174
|
-
* inject: [ConfigService],
|
|
175
|
-
* useFactory: (config: ConfigService) => ({
|
|
176
|
-
* encryptionOptions: { isEnabled: true, encryptionKey: config.get('KEY') },
|
|
177
|
-
* }),
|
|
178
|
-
* staticOptions: {
|
|
179
|
-
* controllersOptions: { section: { isEnabled: true } },
|
|
180
|
-
* entityOptions: { tablePrefix: 'app_' },
|
|
181
|
-
* },
|
|
182
|
-
* });
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
static registerAsync(properties) {
|
|
186
|
-
const staticEntityOptions = properties.staticOptions?.entityOptions;
|
|
187
|
-
const prefix = staticEntityOptions?.tablePrefix ?? "";
|
|
188
|
-
const timestampColumnType = staticEntityOptions?.timestampColumnType ?? "timestamp";
|
|
189
|
-
const sectionEntity = entity.createConfigSectionEntity({
|
|
190
|
-
maxDescriptionLength: staticEntityOptions?.configSection?.maxDescriptionLength ??
|
|
191
|
-
section_constant.CONFIG_SECTION_CONSTANT.MAX_DESCRIPTION_LENGTH,
|
|
192
|
-
maxNameLength: staticEntityOptions?.configSection?.maxNameLength ?? section_constant.CONFIG_SECTION_CONSTANT.MAX_NAME_LENGTH,
|
|
193
|
-
tableName: prefix +
|
|
194
|
-
(staticEntityOptions?.configSection?.tableName ?? section_constant.CONFIG_SECTION_CONSTANT.DEFAULT_TABLE_NAME),
|
|
195
|
-
timestampColumnType,
|
|
196
|
-
});
|
|
197
|
-
const dataEntity = entity$1.createConfigDataEntity({
|
|
198
|
-
configSectionEntity: sectionEntity,
|
|
199
|
-
maxDescriptionLength: staticEntityOptions?.configData?.maxDescriptionLength ??
|
|
200
|
-
data_constant.CONFIG_DATA_CONSTANT.MAX_DESCRIPTION_LENGTH,
|
|
201
|
-
maxEnvironmentLength: staticEntityOptions?.configData?.maxEnvironmentLength ??
|
|
202
|
-
data_constant.CONFIG_DATA_CONSTANT.MAX_ENVIRONMENT_LENGTH,
|
|
203
|
-
maxNameLength: staticEntityOptions?.configData?.maxNameLength ?? data_constant.CONFIG_DATA_CONSTANT.MAX_NAME_LENGTH,
|
|
204
|
-
maxValueLength: staticEntityOptions?.configData?.maxValueLength ?? data_constant.CONFIG_DATA_CONSTANT.MAX_VALUE_LENGTH,
|
|
205
|
-
tableName: prefix +
|
|
206
|
-
(staticEntityOptions?.configData?.tableName ?? data_constant.CONFIG_DATA_CONSTANT.DEFAULT_TABLE_NAME),
|
|
207
|
-
timestampColumnType,
|
|
208
|
-
});
|
|
209
|
-
const staticControllersOptions = properties.staticOptions?.controllersOptions;
|
|
210
|
-
const DynamicConfigSectionController = staticControllersOptions?.section?.isEnabled === false
|
|
211
|
-
? null
|
|
212
|
-
: controller.createDynamicSectionController(sectionEntity, staticControllersOptions?.section);
|
|
213
|
-
const DynamicConfigDataController = staticControllersOptions?.data?.isEnabled === false
|
|
214
|
-
? null
|
|
215
|
-
: controller$1.createDynamicDataController(dataEntity, staticControllersOptions?.data);
|
|
216
|
-
const controllers = [];
|
|
217
|
-
if (DynamicConfigSectionController)
|
|
218
|
-
controllers.push(DynamicConfigSectionController);
|
|
219
|
-
if (DynamicConfigDataController)
|
|
220
|
-
controllers.push(DynamicConfigDataController);
|
|
221
|
-
const staticMigrationOptions = properties.staticOptions?.migrationEntityOptions;
|
|
222
|
-
const migrationEntity = entity$2.createConfigMigrationEntity({
|
|
223
|
-
maxNameLength: staticMigrationOptions?.maxNameLength ?? migration_constant.CONFIG_MIGRATION_CONSTANT.MAX_NAME_LENGTH,
|
|
224
|
-
tableName: prefix + (staticMigrationOptions?.tableName ?? migration_constant.CONFIG_MIGRATION_CONSTANT.DEFAULT_TABLE_NAME),
|
|
225
|
-
timestampColumnType,
|
|
226
|
-
});
|
|
227
|
-
const providers = [
|
|
228
|
-
this.createAsyncOptionsProvider(properties),
|
|
229
|
-
{
|
|
230
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_SECTION_ENTITY,
|
|
231
|
-
useValue: sectionEntity,
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_DATA_ENTITY,
|
|
235
|
-
useValue: dataEntity,
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_MIGRATION_ENTITY,
|
|
239
|
-
useValue: migrationEntity,
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
inject: [typeorm.getDataSourceToken(), token_constant.TOKEN_CONSTANT.CONFIG_SECTION_ENTITY],
|
|
243
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_SECTION_SERVICE,
|
|
244
|
-
useFactory: (dataSource, sectionEntity) => {
|
|
245
|
-
const repository = dataSource.getRepository(sectionEntity);
|
|
246
|
-
const DynamicService = service_utility.createDynamicService(sectionEntity, "ConfigSectionService");
|
|
247
|
-
return new DynamicService(repository);
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
inject: [typeorm.getDataSourceToken(), token_constant.TOKEN_CONSTANT.CONFIG_DATA_ENTITY],
|
|
252
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_DATA_SERVICE,
|
|
253
|
-
useFactory: (dataSource, dataEntity) => {
|
|
254
|
-
const repository = dataSource.getRepository(dataEntity);
|
|
255
|
-
const DynamicService = service_utility.createDynamicService(dataEntity, "ConfigDataService");
|
|
256
|
-
return new DynamicService(repository);
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
inject: [typeorm.getDataSourceToken(), token_constant.TOKEN_CONSTANT.CONFIG_MIGRATION_ENTITY],
|
|
261
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_MIGRATION_SERVICE,
|
|
262
|
-
useFactory: (dataSource, migrationEntity) => {
|
|
263
|
-
const repository = dataSource.getRepository(migrationEntity);
|
|
264
|
-
const DynamicService = service_utility.createDynamicService(migrationEntity, "ConfigMigrationService");
|
|
265
|
-
return new DynamicService(repository);
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
config_service.CrudConfigService,
|
|
269
|
-
migration_service.ConfigMigrationService,
|
|
270
|
-
migrationRunner_service.ConfigMigrationRunnerService,
|
|
271
|
-
crypto_utility.CryptoUtility,
|
|
272
|
-
];
|
|
273
|
-
if (properties.useClass) {
|
|
274
|
-
providers.push({
|
|
275
|
-
provide: properties.useClass,
|
|
276
|
-
useClass: properties.useClass,
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
return {
|
|
280
|
-
controllers,
|
|
281
|
-
exports: [
|
|
282
|
-
config_service.CrudConfigService,
|
|
283
|
-
token_constant.TOKEN_CONSTANT.CONFIG_OPTIONS,
|
|
284
|
-
token_constant.TOKEN_CONSTANT.CONFIG_SECTION_ENTITY,
|
|
285
|
-
token_constant.TOKEN_CONSTANT.CONFIG_DATA_ENTITY,
|
|
286
|
-
token_constant.TOKEN_CONSTANT.CONFIG_MIGRATION_ENTITY,
|
|
287
|
-
token_constant.TOKEN_CONSTANT.CONFIG_SECTION_SERVICE,
|
|
288
|
-
token_constant.TOKEN_CONSTANT.CONFIG_DATA_SERVICE,
|
|
289
|
-
token_constant.TOKEN_CONSTANT.CONFIG_MIGRATION_SERVICE,
|
|
290
|
-
migration_service.ConfigMigrationService,
|
|
291
|
-
migrationRunner_service.ConfigMigrationRunnerService,
|
|
292
|
-
crypto_utility.CryptoUtility,
|
|
293
|
-
],
|
|
294
|
-
imports: [...(properties.imports ?? [])],
|
|
295
|
-
module: CrudConfigModule_1,
|
|
296
|
-
providers: providers,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
static createAsyncOptionsProvider(properties) {
|
|
300
|
-
if (properties.useFactory) {
|
|
301
|
-
return {
|
|
302
|
-
inject: properties.inject ?? [],
|
|
303
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_OPTIONS,
|
|
304
|
-
useFactory: properties.useFactory,
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
const inject = properties.useExisting ?? properties.useClass;
|
|
308
|
-
return {
|
|
309
|
-
inject: inject ? [inject] : [],
|
|
310
|
-
provide: token_constant.TOKEN_CONSTANT.CONFIG_OPTIONS,
|
|
311
|
-
useFactory: async (optionsFactory) => {
|
|
312
|
-
return optionsFactory.createOptions();
|
|
313
|
-
},
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
exports.CrudConfigModule = CrudConfigModule_1 = tslib_es6.__decorate([
|
|
318
|
-
common.Global(),
|
|
319
|
-
common.Module({})
|
|
320
|
-
], exports.CrudConfigModule);
|
|
321
|
-
//# sourceMappingURL=config.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.module.js","sources":["../../../../../src/modules/config/config.module.ts"],"sourcesContent":[null],"names":["CrudConfigModule","createConfigSectionEntity","CONFIG_SECTION_CONSTANT","createConfigDataEntity","CONFIG_DATA_CONSTANT","createConfigMigrationEntity","CONFIG_MIGRATION_CONSTANT","TOKEN_CONSTANT","getDataSourceToken","getRepositoryToken","createDynamicService","createDynamicSectionController","createDynamicDataController","CacheModule","CrudConfigService","ConfigMigrationService","ConfigMigrationRunnerService","CryptoUtility","__decorate","Global","Module"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmCaA,wBAAgB,GAAA,kBAAA,GAAtB,MAAM,gBAAgB,CAAA;IACrB,OAAO,QAAQ,CAAC,OAAuB,EAAA;QAC7C,MAAM,MAAM,GAAW,OAAO,CAAC,aAAa,EAAE,WAAW,IAAI,EAAE;QAE/D,MAAM,mBAAmB,GACxB,OAAO,CAAC,aAAa,EAAE,mBAAmB,IAAI,WAAW;QAE1D,MAAM,aAAa,GAAmCC,gCAAyB,CAAC;AAC/E,YAAA,oBAAoB,EACnB,OAAO,CAAC,aAAa,EAAE,aAAa,EAAE,oBAAoB;AAC1D,gBAAAC,wCAAuB,CAAC,sBAAsB;YAC/C,aAAa,EACZ,OAAO,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,IAAIA,wCAAuB,CAAC,eAAe;AAC/F,YAAA,SAAS,EACR,MAAM;iBACL,OAAO,CAAC,aAAa,EAAE,aAAa,EAAE,SAAS,IAAIA,wCAAuB,CAAC,kBAAkB,CAAC;YAChG,mBAAmB;AACnB,SAAA,CAAC;QAEF,MAAM,UAAU,GAAgCC,+BAAsB,CAAC;AACtE,YAAA,mBAAmB,EAAE,aAAa;AAClC,YAAA,oB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AM,EAAE,MAAM,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE;YAC9B,OAAO,EAAEA,6BAAc,CAAC,cAAc;AACtC,YAAA,UAAU,EAAE,OAAO,cAAwC,KAA6B;AACvF,gBAAA,OAAO,cAAc,CAAC,aAAa,EAAE;YACtC,CAAC;SACD;IACF;;AApYYP,wBAAgB,GAAA,kBAAA,GAAAkB,oBAAA,CAAA;AAF5B,IAAAC,aAAM,EAAE;IACRC,aAAM,CAAC,EAAE;AACG,CAAA,EAAApB,wBAAgB,CAqY5B"}
|
|
@@ -1,315 +0,0 @@
|
|
|
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
|
-
var logger_utility = require('../../shared/utility/logger.utility.js');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Service for managing configuration data with caching support
|
|
15
|
-
* Provides methods to retrieve configuration values with optional decryption
|
|
16
|
-
* @see {@link https://elsikora.com/docs/nestjs-crud-config/core-concepts/config-service | Core Concepts - Config Service}
|
|
17
|
-
* @see {@link https://elsikora.com/docs/nestjs-crud-config/api-reference/classes/crud-config-service | API Reference - CrudConfigService}
|
|
18
|
-
*/
|
|
19
|
-
exports.CrudConfigService = class CrudConfigService {
|
|
20
|
-
sectionService;
|
|
21
|
-
dataService;
|
|
22
|
-
cacheManager;
|
|
23
|
-
options;
|
|
24
|
-
dataSource;
|
|
25
|
-
cryptoUtility;
|
|
26
|
-
LOGGER = logger_utility.LoggerUtility.getLogger("CrudConfigService");
|
|
27
|
-
constructor(sectionService, dataService, cacheManager, options, dataSource, cryptoUtility) {
|
|
28
|
-
this.sectionService = sectionService;
|
|
29
|
-
this.dataService = dataService;
|
|
30
|
-
this.cacheManager = cacheManager;
|
|
31
|
-
this.options = options;
|
|
32
|
-
this.dataSource = dataSource;
|
|
33
|
-
this.cryptoUtility = cryptoUtility;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Deletes a configuration value
|
|
37
|
-
* @param {IConfigDeleteOptions} options Configuration options to identify the value to delete
|
|
38
|
-
* @returns {Promise<void>} Promise resolving when the configuration is deleted
|
|
39
|
-
*/
|
|
40
|
-
async delete(options) {
|
|
41
|
-
const maskedOptions = {
|
|
42
|
-
...options,
|
|
43
|
-
eventManager: options.eventManager ? "[EntityManager]" : undefined,
|
|
44
|
-
};
|
|
45
|
-
this.LOGGER.verbose(`Entering delete method with options: ${JSON.stringify(maskedOptions)}`);
|
|
46
|
-
const { environment, eventManager, name, section: sectionName } = options;
|
|
47
|
-
const finalEnvironment = environment ?? this.options?.environment ?? "default";
|
|
48
|
-
try {
|
|
49
|
-
const section = await this.runWithEventManager(eventManager, () => this.sectionService.get({ where: { name: sectionName } }));
|
|
50
|
-
const data = await this.runWithEventManager(eventManager, () => this.dataService.get({
|
|
51
|
-
where: {
|
|
52
|
-
environment: finalEnvironment,
|
|
53
|
-
name,
|
|
54
|
-
section: typeorm.Equal(section.id),
|
|
55
|
-
},
|
|
56
|
-
}));
|
|
57
|
-
await this.runWithEventManager(eventManager, () => this.dataService.delete({ id: data.id }));
|
|
58
|
-
if (this.options?.cacheOptions?.isEnabled && this.cacheManager) {
|
|
59
|
-
const cacheKey = `config:${sectionName}:${name}:${finalEnvironment}`;
|
|
60
|
-
const listCacheKey = `config:list:${sectionName}:${finalEnvironment}`;
|
|
61
|
-
await Promise.all([this.cacheManager.del(cacheKey), this.cacheManager.del(listCacheKey)]);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
this.LOGGER.error(`Error in delete method: ${error.message}`);
|
|
66
|
-
if (error instanceof common.HttpException) {
|
|
67
|
-
throw error;
|
|
68
|
-
}
|
|
69
|
-
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.DELETING_ERROR }));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Retrieves configuration data based on the provided options
|
|
74
|
-
* @param {IConfigGetOptions} options Configuration retrieval options
|
|
75
|
-
* @returns {Promise<IConfigData>} Promise resolving to the configuration data
|
|
76
|
-
*/
|
|
77
|
-
async get(options) {
|
|
78
|
-
const maskedOptions = {
|
|
79
|
-
...options,
|
|
80
|
-
eventManager: options.eventManager ? "[EntityManager]" : undefined,
|
|
81
|
-
};
|
|
82
|
-
this.LOGGER.verbose(`Entering get method with options: ${JSON.stringify(maskedOptions)}`);
|
|
83
|
-
const { environment, eventManager, name, section, shouldLoadSectionInfo, useCache, } = options;
|
|
84
|
-
const finalEnvironment = environment ?? this.options?.environment ?? "default";
|
|
85
|
-
const cacheKey = `config:${section}:${name}:${finalEnvironment}`;
|
|
86
|
-
try {
|
|
87
|
-
// Check cache first if enabled
|
|
88
|
-
if (useCache && this.options?.cacheOptions?.isEnabled && this.cacheManager) {
|
|
89
|
-
const cachedData = await this.cacheManager.get(cacheKey);
|
|
90
|
-
if (cachedData) {
|
|
91
|
-
this.LOGGER.verbose(`Returning cached config data for ${name}`);
|
|
92
|
-
return cachedData;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// Fetch section
|
|
96
|
-
this.LOGGER.verbose(`Fetching section: ${section}`);
|
|
97
|
-
const sectionData = await this.runWithEventManager(eventManager, () => this.sectionService.get({ where: { name: section } }));
|
|
98
|
-
this.LOGGER.verbose(`Fetching config data for name: ${name}, environment: ${finalEnvironment}`);
|
|
99
|
-
const data = await this.runWithEventManager(eventManager, () => this.dataService.get({
|
|
100
|
-
// eslint-disable-next-line @elsikora/typescript/naming-convention
|
|
101
|
-
relations: { section: shouldLoadSectionInfo },
|
|
102
|
-
where: { environment: finalEnvironment, name, section: typeorm.Equal(sectionData.id) },
|
|
103
|
-
}));
|
|
104
|
-
if (data.isEncrypted) {
|
|
105
|
-
if (!this.options?.encryptionOptions?.encryptionKey) {
|
|
106
|
-
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.KEY_NOT_FOUND }));
|
|
107
|
-
}
|
|
108
|
-
if (!this.cryptoUtility) {
|
|
109
|
-
throw new common.InternalServerErrorException("CryptoUtility not available");
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
data.value = this.cryptoUtility.decrypt(data.value, this.options.encryptionOptions.encryptionKey);
|
|
113
|
-
this.LOGGER.verbose(`Decrypted value for ${name}`);
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
this.LOGGER.error(`Decryption error for ${name}: ${error.message}`);
|
|
117
|
-
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.DECRYPTION_ERROR }));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (useCache && this.options?.cacheOptions?.isEnabled && this.cacheManager) {
|
|
121
|
-
const ttl = this.options.cacheOptions.maxCacheTTL;
|
|
122
|
-
await this.cacheManager.set(cacheKey, data, ttl);
|
|
123
|
-
}
|
|
124
|
-
this.LOGGER.verbose(`Returning config data for ${name}`);
|
|
125
|
-
return data;
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
this.LOGGER.error(`Error in get method: ${error.message}`);
|
|
129
|
-
if (error instanceof common.HttpException) {
|
|
130
|
-
throw error;
|
|
131
|
-
}
|
|
132
|
-
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.FETCHING_ERROR }));
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Lists all configuration values in a section.
|
|
137
|
-
* Supports caching and running within a TypeORM transaction.
|
|
138
|
-
* @param {IConfigGetListOptions} options Options for listing configurations.
|
|
139
|
-
* @returns {Promise<Array<IConfigData>>} Promise resolving to an array of configuration data.
|
|
140
|
-
*/
|
|
141
|
-
async getList(options) {
|
|
142
|
-
const maskedOptions = {
|
|
143
|
-
...options,
|
|
144
|
-
eventManager: options.eventManager ? "[EntityManager]" : undefined,
|
|
145
|
-
};
|
|
146
|
-
this.LOGGER.verbose(`Entering getList method with options: ${JSON.stringify(maskedOptions)}`);
|
|
147
|
-
const { environment, eventManager, section: sectionName, useCache, } = options;
|
|
148
|
-
const finalEnvironment = environment ?? this.options?.environment ?? "default";
|
|
149
|
-
const cacheKey = `config:list:${sectionName}:${finalEnvironment}`;
|
|
150
|
-
try {
|
|
151
|
-
// Check cache first if enabled
|
|
152
|
-
if (useCache && this.options?.cacheOptions?.isEnabled && this.cacheManager) {
|
|
153
|
-
const cachedItems = await this.cacheManager.get(cacheKey);
|
|
154
|
-
if (cachedItems) {
|
|
155
|
-
this.LOGGER.verbose(`Returning cached config list for ${sectionName}`);
|
|
156
|
-
return cachedItems;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
this.LOGGER.verbose(`Fetching section: ${sectionName}`);
|
|
160
|
-
const section = await this.runWithEventManager(eventManager, () => this.sectionService.get({ where: { name: sectionName } }));
|
|
161
|
-
this.LOGGER.verbose(`Fetching config list for section: ${sectionName}, environment: ${finalEnvironment}`);
|
|
162
|
-
const result = await this.runWithEventManager(eventManager, () => this.dataService.getList({
|
|
163
|
-
where: { environment: finalEnvironment, section: typeorm.Equal(section.id) },
|
|
164
|
-
}));
|
|
165
|
-
if (useCache && this.options?.cacheOptions?.isEnabled && this.cacheManager) {
|
|
166
|
-
const ttl = this.options?.cacheOptions?.maxCacheTTL;
|
|
167
|
-
await this.cacheManager.set(cacheKey, result.items, ttl);
|
|
168
|
-
}
|
|
169
|
-
this.LOGGER.verbose(`Returning ${result.items.length} config items`);
|
|
170
|
-
return result.items;
|
|
171
|
-
}
|
|
172
|
-
catch (error) {
|
|
173
|
-
this.LOGGER.error(`Error in getList method: ${error.message}`);
|
|
174
|
-
if (error instanceof common.HttpException) {
|
|
175
|
-
throw error;
|
|
176
|
-
}
|
|
177
|
-
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.FETCHING_LIST_ERROR }));
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Sets a configuration value with optional encryption.
|
|
182
|
-
* The specified section must already exist.
|
|
183
|
-
* If a configuration with the same name and environment already exists, it will be updated. Otherwise, a new one will be created.
|
|
184
|
-
* Owns the named crud-config-set Automator transaction when eventManager is omitted.
|
|
185
|
-
* A provided eventManager must already belong to an active Automator owner.
|
|
186
|
-
* @param {IConfigSetOptions} options Configuration set options
|
|
187
|
-
* @returns {Promise<IConfigData>} Promise resolving to the saved configuration data
|
|
188
|
-
*/
|
|
189
|
-
async set(options) {
|
|
190
|
-
const maskedOptions = {
|
|
191
|
-
...options,
|
|
192
|
-
eventManager: options.eventManager ? "[EntityManager]" : undefined,
|
|
193
|
-
value: "***",
|
|
194
|
-
};
|
|
195
|
-
this.LOGGER.verbose(`Entering set method with options: ${JSON.stringify(maskedOptions)}`);
|
|
196
|
-
const { environment, eventManager, name, section: sectionName, value, } = options;
|
|
197
|
-
const finalEnvironment = environment ?? this.options?.environment ?? "default";
|
|
198
|
-
const shouldApplyEncryption = this.options?.encryptionOptions?.isEnabled ?? false;
|
|
199
|
-
let finalValue = value;
|
|
200
|
-
let isEncrypted = false;
|
|
201
|
-
if (shouldApplyEncryption) {
|
|
202
|
-
if (!this.options?.encryptionOptions?.encryptionKey) {
|
|
203
|
-
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.KEY_NOT_FOUND }));
|
|
204
|
-
}
|
|
205
|
-
if (!this.cryptoUtility) {
|
|
206
|
-
throw new common.InternalServerErrorException("CryptoUtility not available");
|
|
207
|
-
}
|
|
208
|
-
try {
|
|
209
|
-
finalValue = this.cryptoUtility.encrypt(value, this.options.encryptionOptions.encryptionKey);
|
|
210
|
-
isEncrypted = true;
|
|
211
|
-
this.LOGGER.verbose(`Encrypted value for ${name}`);
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
this.LOGGER.error(`Encryption error for ${name}: ${error.message}`);
|
|
215
|
-
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.ENCRYPTION_ERROR }));
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
try {
|
|
219
|
-
let result;
|
|
220
|
-
if (eventManager) {
|
|
221
|
-
result = await this.setWithEntityManager(options, finalValue, isEncrypted, eventManager);
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
if (!this.dataSource) {
|
|
225
|
-
throw new common.InternalServerErrorException("DataSource not available for transaction");
|
|
226
|
-
}
|
|
227
|
-
result = await nestjsCrudAutomator.ApiFunctionTransactionScope.runWithDataSource(this.dataSource, { name: "crud-config-set" }, async (transactionalEntityManager) => await this.setWithEntityManager(options, finalValue, isEncrypted, transactionalEntityManager));
|
|
228
|
-
}
|
|
229
|
-
if (this.options?.cacheOptions?.isEnabled && this.cacheManager) {
|
|
230
|
-
const cacheKey = `config:${sectionName}:${name}:${finalEnvironment}`;
|
|
231
|
-
const listCacheKey = `config:list:${sectionName}:${finalEnvironment}`;
|
|
232
|
-
await Promise.all([this.cacheManager.del(cacheKey), this.cacheManager.del(listCacheKey)]);
|
|
233
|
-
}
|
|
234
|
-
this.LOGGER.verbose(`Set method completed successfully for ${name}`);
|
|
235
|
-
return result;
|
|
236
|
-
}
|
|
237
|
-
catch (error) {
|
|
238
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
239
|
-
this.LOGGER.error(`Error in set method: ${errorMessage}`);
|
|
240
|
-
if (error instanceof common.HttpException) {
|
|
241
|
-
throw error;
|
|
242
|
-
}
|
|
243
|
-
throw new common.InternalServerErrorException(nestjsCrudAutomator.ErrorString({ entity: { name: "ConfigData" }, type: nestjsCrudAutomator.EErrorStringAction.CREATING_ERROR }));
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
async getOrCreateSection(sectionName, eventManager) {
|
|
247
|
-
try {
|
|
248
|
-
return await this.runWithEventManager(eventManager, () => this.sectionService.get({ where: { name: sectionName } }));
|
|
249
|
-
}
|
|
250
|
-
catch (error) {
|
|
251
|
-
if (error instanceof common.NotFoundException && this.options?.shouldAutoCreateSections) {
|
|
252
|
-
this.LOGGER.verbose(`Section ${sectionName} not found, creating new one`);
|
|
253
|
-
return await this.runWithEventManager(eventManager, () => this.sectionService.create({ name: sectionName }));
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
257
|
-
this.LOGGER.error(`Error fetching section: ${errorMessage}`);
|
|
258
|
-
throw error;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
async runWithEventManager(eventManager, callback) {
|
|
263
|
-
if (!eventManager) {
|
|
264
|
-
return await callback();
|
|
265
|
-
}
|
|
266
|
-
return await nestjsCrudAutomator.ApiFunctionTransactionScope.runWithEntityManager(eventManager, callback);
|
|
267
|
-
}
|
|
268
|
-
async setWithEntityManager(options, value, isEncrypted, entityManager) {
|
|
269
|
-
const { description, environment, name, section: sectionName } = options;
|
|
270
|
-
const finalEnvironment = environment ?? this.options?.environment ?? "default";
|
|
271
|
-
this.LOGGER.verbose(`Fetching or creating section: ${sectionName}`);
|
|
272
|
-
const section = await this.getOrCreateSection(sectionName, entityManager);
|
|
273
|
-
this.LOGGER.verbose(`Preparing config data for ${name}`);
|
|
274
|
-
const configData = {
|
|
275
|
-
description: description ?? undefined,
|
|
276
|
-
environment: finalEnvironment,
|
|
277
|
-
isEncrypted,
|
|
278
|
-
name,
|
|
279
|
-
section: { id: section.id },
|
|
280
|
-
value,
|
|
281
|
-
};
|
|
282
|
-
try {
|
|
283
|
-
this.LOGGER.verbose(`Checking for existing config: ${name}`);
|
|
284
|
-
const existingData = await this.runWithEventManager(entityManager, () => this.dataService.get({
|
|
285
|
-
where: { environment: finalEnvironment, name, section: typeorm.Equal(section.id) },
|
|
286
|
-
}));
|
|
287
|
-
this.LOGGER.verbose(`Updating existing config: ${name}`);
|
|
288
|
-
return await this.runWithEventManager(entityManager, () => this.dataService.update({ id: existingData.id }, configData));
|
|
289
|
-
}
|
|
290
|
-
catch (error) {
|
|
291
|
-
if (error instanceof common.NotFoundException) {
|
|
292
|
-
this.LOGGER.verbose(`Config ${name} not found, creating new one`);
|
|
293
|
-
return await this.runWithEventManager(entityManager, () => this.dataService.create(configData));
|
|
294
|
-
}
|
|
295
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
296
|
-
this.LOGGER.error(`Error updating config: ${errorMessage}`);
|
|
297
|
-
throw error;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
exports.CrudConfigService = tslib_es6.__decorate([
|
|
302
|
-
common.Injectable(),
|
|
303
|
-
tslib_es6.__param(0, common.Inject(token_constant.TOKEN_CONSTANT.CONFIG_SECTION_SERVICE)),
|
|
304
|
-
tslib_es6.__param(1, common.Inject(token_constant.TOKEN_CONSTANT.CONFIG_DATA_SERVICE)),
|
|
305
|
-
tslib_es6.__param(2, common.Inject(cacheManager.CACHE_MANAGER)),
|
|
306
|
-
tslib_es6.__param(2, common.Optional()),
|
|
307
|
-
tslib_es6.__param(3, common.Inject(token_constant.TOKEN_CONSTANT.CONFIG_OPTIONS)),
|
|
308
|
-
tslib_es6.__param(3, common.Optional()),
|
|
309
|
-
tslib_es6.__param(4, common.Inject(typeorm.DataSource)),
|
|
310
|
-
tslib_es6.__param(4, common.Optional()),
|
|
311
|
-
tslib_es6.__metadata("design:paramtypes", [nestjsCrudAutomator.ApiServiceBase,
|
|
312
|
-
nestjsCrudAutomator.ApiServiceBase, Object, Object, typeorm.DataSource,
|
|
313
|
-
crypto_utility.CryptoUtility])
|
|
314
|
-
], exports.CrudConfigService);
|
|
315
|
-
//# sourceMappingURL=config.service.js.map
|