@creatio-devkit/common 0.821.0 → 0.822.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/CHANGELOG.md +3 -0
- package/esm2022/lib/internal/models/internal-module-definition.mjs +1 -1
- package/esm2022/lib/internal/models/lazy-module-metadata.mjs +1 -1
- package/esm2022/lib/internal/models/lazy-module-ref.mjs +4 -4
- package/esm2022/lib/internal/services/global-converters-registry/converter-registry.mjs +8 -4
- package/esm2022/lib/internal/services/request-handler-registry/request-handler-registry.service.mjs +23 -21
- package/esm2022/lib/internal/services/validator-registry/validator-registry.mjs +9 -6
- package/esm2022/lib/public/decorators/inject/inject.decorator.mjs +1 -1
- package/esm2022/lib/public/functions/bootstrap-crt-module.mjs +8 -8
- package/fesm2022/creatio-devkit-common.mjs +47 -38
- package/fesm2022/creatio-devkit-common.mjs.map +1 -1
- package/index.d.ts +5 -1
- package/package.json +2 -2
|
@@ -1027,18 +1027,19 @@ class InternalRequestHandlerRegistryType {
|
|
|
1027
1027
|
*/
|
|
1028
1028
|
static addRequestHandler(handlerType, config) {
|
|
1029
1029
|
const existingHandler = this._requestHandlersMap.get(handlerType);
|
|
1030
|
-
if (
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
},
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1030
|
+
if (existingHandler && (!existingHandler.instanceConfig?.lazy || existingHandler.instanceType)) {
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
const mergedConfig = {
|
|
1034
|
+
instanceType: config.instanceType,
|
|
1035
|
+
instanceConfig: {
|
|
1036
|
+
...(existingHandler?.instanceConfig ?? {}),
|
|
1037
|
+
...config.instanceConfig,
|
|
1038
|
+
},
|
|
1039
|
+
};
|
|
1040
|
+
this._requestHandlersMap.set(handlerType, mergedConfig);
|
|
1041
|
+
for (const listener of this._addItemListeners) {
|
|
1042
|
+
listener(handlerType, mergedConfig);
|
|
1042
1043
|
}
|
|
1043
1044
|
}
|
|
1044
1045
|
/**
|
|
@@ -1046,11 +1047,12 @@ class InternalRequestHandlerRegistryType {
|
|
|
1046
1047
|
*/
|
|
1047
1048
|
static removeRequestHandler(handlerType) {
|
|
1048
1049
|
const config = this._requestHandlersMap.get(handlerType);
|
|
1049
|
-
if (config) {
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1050
|
+
if (!config) {
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
this._requestHandlersMap.delete(handlerType);
|
|
1054
|
+
for (const listener of this._removeItemListeners) {
|
|
1055
|
+
listener(handlerType, config);
|
|
1054
1056
|
}
|
|
1055
1057
|
}
|
|
1056
1058
|
static clear() {
|
|
@@ -1080,16 +1082,16 @@ class RequestHandlerRegistryService {
|
|
|
1080
1082
|
/**
|
|
1081
1083
|
* Register request handler class.
|
|
1082
1084
|
* @param config Request handler registration config.
|
|
1083
|
-
* @param
|
|
1085
|
+
* @param typeRef Request handler type reference (constructor).
|
|
1084
1086
|
*/
|
|
1085
|
-
static register(config,
|
|
1087
|
+
static register(config, typeRef) {
|
|
1086
1088
|
const requestType = config.requestType;
|
|
1087
1089
|
const requestHandlerType = config.type;
|
|
1088
1090
|
if (!requestType) {
|
|
1089
1091
|
throw new Error(`Error when register ${requestHandlerType}. Request type not specified.`);
|
|
1090
1092
|
}
|
|
1091
1093
|
const requestHandlerMapValue = {
|
|
1092
|
-
instanceType:
|
|
1094
|
+
instanceType: typeRef,
|
|
1093
1095
|
instanceConfig: config,
|
|
1094
1096
|
};
|
|
1095
1097
|
RequestHandlerRegistryService._internalRegistry.addRequestHandler(requestHandlerType, requestHandlerMapValue);
|
|
@@ -1137,17 +1139,21 @@ class ConverterRegistry extends ɵBaseRegistry {
|
|
|
1137
1139
|
static has(type) {
|
|
1138
1140
|
return this.store.typeInfos.has(type);
|
|
1139
1141
|
}
|
|
1142
|
+
static find(type) {
|
|
1143
|
+
return this.store.typeInfos.get(type);
|
|
1144
|
+
}
|
|
1140
1145
|
static get(type) {
|
|
1141
|
-
|
|
1146
|
+
const registryItem = this.find(type);
|
|
1147
|
+
if (!registryItem) {
|
|
1142
1148
|
throw new Error(`'${type}' converter doesn't exist`);
|
|
1143
1149
|
}
|
|
1144
|
-
return
|
|
1150
|
+
return registryItem;
|
|
1145
1151
|
}
|
|
1146
1152
|
static register(item) {
|
|
1147
1153
|
checkTypeNameFormat(item.type, 'ConverterTypeName');
|
|
1148
1154
|
checkCrtTypeNamePascalCase(item.type);
|
|
1149
1155
|
// TODO RND-21723
|
|
1150
|
-
const existingItem = this.
|
|
1156
|
+
const existingItem = this.find(item.type);
|
|
1151
1157
|
this.store.typeInfos.set(item.type, {
|
|
1152
1158
|
...(existingItem ?? {}),
|
|
1153
1159
|
...item,
|
|
@@ -1354,16 +1360,19 @@ const validatorRegistryKey = 'ValidatorRegistry';
|
|
|
1354
1360
|
*/
|
|
1355
1361
|
class ValidatorRegistry extends ɵBaseRegistry {
|
|
1356
1362
|
static { this.registryKey = validatorRegistryKey; }
|
|
1357
|
-
static
|
|
1358
|
-
const
|
|
1359
|
-
if (
|
|
1363
|
+
static _hasWithAnotherTypeRef(configType, typeRef) {
|
|
1364
|
+
const existingItem = ValidatorRegistry.items.get(configType);
|
|
1365
|
+
if (!existingItem) {
|
|
1366
|
+
return false;
|
|
1367
|
+
}
|
|
1368
|
+
if (existingItem.lazy && !existingItem.typeRef) {
|
|
1360
1369
|
return false;
|
|
1361
1370
|
}
|
|
1362
|
-
return
|
|
1371
|
+
return existingItem.typeRef !== typeRef;
|
|
1363
1372
|
}
|
|
1364
1373
|
static validate(config) {
|
|
1365
1374
|
checkTypeNameFormat(config.type, 'ValidatorTypeName');
|
|
1366
|
-
if (config.typeRef && ValidatorRegistry.
|
|
1375
|
+
if (config.typeRef && ValidatorRegistry._hasWithAnotherTypeRef(config.type, config.typeRef)) {
|
|
1367
1376
|
throw new Error(`Error when register ${config.type}. Element with this type has already exist`);
|
|
1368
1377
|
}
|
|
1369
1378
|
}
|
|
@@ -1456,16 +1465,16 @@ class LazyModuleRef {
|
|
|
1456
1465
|
get typeRef() {
|
|
1457
1466
|
return this._typeRef;
|
|
1458
1467
|
}
|
|
1459
|
-
constructor(
|
|
1468
|
+
constructor(_moduleDefinition, _bootstrapFn,
|
|
1460
1469
|
/** Name of source build ('host' or remote name) */
|
|
1461
1470
|
sourceName) {
|
|
1462
|
-
this.
|
|
1471
|
+
this._moduleDefinition = _moduleDefinition;
|
|
1463
1472
|
this._bootstrapFn = _bootstrapFn;
|
|
1464
1473
|
this.sourceName = sourceName;
|
|
1465
1474
|
}
|
|
1466
1475
|
loadAndBootstrap() {
|
|
1467
1476
|
if (!this._modulePromise) {
|
|
1468
|
-
this._modulePromise = this.
|
|
1477
|
+
this._modulePromise = this._moduleDefinition.load().then((type) => {
|
|
1469
1478
|
this._typeRef = type;
|
|
1470
1479
|
this._bootstrapFn(type);
|
|
1471
1480
|
return type;
|
|
@@ -1932,18 +1941,18 @@ function bootstrapDefaultCrtModule(name, type, options, root) {
|
|
|
1932
1941
|
if (moduleDefinition.converters) {
|
|
1933
1942
|
registerConverters(moduleDefinition.converters, options);
|
|
1934
1943
|
}
|
|
1935
|
-
moduleDefinition.includes?.forEach((
|
|
1936
|
-
if (typeof
|
|
1937
|
-
bootstrapDefaultCrtModule(name,
|
|
1938
|
-
bootstrapPredefinedModules(name,
|
|
1944
|
+
moduleDefinition.includes?.forEach((includedModuleMetadata) => {
|
|
1945
|
+
if (typeof includedModuleMetadata === 'function') {
|
|
1946
|
+
bootstrapDefaultCrtModule(name, includedModuleMetadata, options, false);
|
|
1947
|
+
bootstrapPredefinedModules(name, includedModuleMetadata, options);
|
|
1939
1948
|
}
|
|
1940
|
-
else if (typeof
|
|
1949
|
+
else if (typeof includedModuleMetadata === 'object') {
|
|
1941
1950
|
if (options.moduleType === 'remote' && !name) {
|
|
1942
1951
|
console.error("To use lazy loading, 'remoteName' parameter should be specified.");
|
|
1943
1952
|
return;
|
|
1944
1953
|
}
|
|
1945
|
-
const ref = new LazyModuleRef(
|
|
1946
|
-
bootstrapLazyCrtModule(name,
|
|
1954
|
+
const ref = new LazyModuleRef(includedModuleMetadata, (x) => bootstrapDefaultCrtModule(name, x, options, false), source);
|
|
1955
|
+
bootstrapLazyCrtModule(name, includedModuleMetadata, options, ref);
|
|
1947
1956
|
LazyModulesManager.instance.add(ref);
|
|
1948
1957
|
}
|
|
1949
1958
|
});
|