@creatio-devkit/common 0.812.0 → 0.813.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/esm2020/lib/base-exports.mjs +4 -2
  3. package/esm2020/lib/internal/decorators/request/request.decorator.mjs +1 -1
  4. package/esm2020/lib/internal/models/converter/converter-registry-item.mjs +1 -1
  5. package/esm2020/lib/internal/models/index.mjs +3 -1
  6. package/esm2020/lib/internal/models/internal-interface-designer-item-registration-config.model.mjs +1 -1
  7. package/esm2020/lib/internal/models/internal-module-definition.mjs +2 -0
  8. package/esm2020/lib/internal/models/lazy-module-metadata.mjs +2 -0
  9. package/esm2020/lib/internal/models/lazy-module-ref.mjs +23 -0
  10. package/esm2020/lib/internal/models/lazy-registry-item.mjs +2 -0
  11. package/esm2020/lib/internal/models/request-handler/handler-config.mjs +1 -1
  12. package/esm2020/lib/internal/models/request-handler/request-handler-registration-config.model.mjs +1 -1
  13. package/esm2020/lib/internal/models/validator/validator-registry-item.mjs +1 -1
  14. package/esm2020/lib/internal/models/view-element/angular-view-element-registration-config.model.mjs +1 -1
  15. package/esm2020/lib/internal/models/view-element-registry-item.mjs +1 -1
  16. package/esm2020/lib/internal/services/global-converters-registry/converter-registry.mjs +9 -2
  17. package/esm2020/lib/internal/services/index.mjs +2 -1
  18. package/esm2020/lib/internal/services/lazy-modules-manager/index.mjs +2 -0
  19. package/esm2020/lib/internal/services/lazy-modules-manager/lazy-modules-manager.mjs +32 -0
  20. package/esm2020/lib/internal/services/request-handler-registry/request-handler-registry.service.mjs +17 -4
  21. package/esm2020/lib/internal/services/request-registry/request-registry.service.mjs +1 -1
  22. package/esm2020/lib/internal/services/validator-registry/validator-registry.mjs +11 -3
  23. package/esm2020/lib/internal/services/view-element-registry/view-element-registry.mjs +14 -2
  24. package/esm2020/lib/internal/utils/index.mjs +2 -1
  25. package/esm2020/lib/internal/utils/metadata-utils.mjs +1 -1
  26. package/esm2020/lib/internal/utils/request-handler-scopes.mjs +10 -0
  27. package/esm2020/lib/public/decorators/module/module.decorator.mjs +2 -18
  28. package/esm2020/lib/public/decorators/view-element/view-element.decorator.mjs +1 -1
  29. package/esm2020/lib/public/functions/bootstrap-crt-module-handler-chain-services.mjs +6 -2
  30. package/esm2020/lib/public/functions/bootstrap-crt-module.mjs +92 -4
  31. package/esm2020/lib/public/functions/index.mjs +2 -1
  32. package/esm2020/lib/public/functions/reset-globals.mjs +35 -0
  33. package/esm2020/lib/public/models/index.mjs +2 -1
  34. package/esm2020/lib/public/models/license/index.mjs +2 -0
  35. package/esm2020/lib/public/models/license/license-restriction-operation-values.model.mjs +2 -0
  36. package/esm2020/lib/public/models/request/index.mjs +1 -2
  37. package/esm2020/lib/public/services/handler-chain/handler-chain.service.mjs +13 -1
  38. package/esm2020/lib/public/services/handler-chain/internal-handler-chain.mjs +43 -11
  39. package/esm2020/lib/public/services/index.mjs +2 -1
  40. package/esm2020/lib/public/services/license/index.mjs +2 -0
  41. package/esm2020/lib/public/services/license/license.service.mjs +22 -0
  42. package/esm2020/lib/public/services/mask-service/index.mjs +1 -2
  43. package/esm2020/lib/public/services/mask-service/mask.service.mjs +2 -2
  44. package/esm2020/lib/public/services/model/model.mjs +4 -1
  45. package/fesm2015/creatio-devkit-common.mjs +295 -59
  46. package/fesm2015/creatio-devkit-common.mjs.map +1 -1
  47. package/fesm2020/creatio-devkit-common.mjs +306 -58
  48. package/fesm2020/creatio-devkit-common.mjs.map +1 -1
  49. package/index.d.ts +57 -4
  50. package/package.json +2 -2
  51. package/esm2020/lib/public/models/request/request-registration-config.model.mjs +0 -2
  52. package/esm2020/lib/public/services/mask-service/schema-view-mask.request.mjs +0 -22
@@ -1,5 +1,5 @@
1
- import { ɵAggregationType, ɵAggregationFunction, ɵAggregationEvalType, ɵDatePartType, ɵFunctionType, ɵOrderDirection, ɵgenerateGuid, ɵNextHandlerAlreadySpecifiedException, ɵBaseRequest } from '@creatio/base';
2
- export { ɵAggregationEvalType as AggregationEvalType, ɵAggregationFunction as AggregationFunction, ɵAggregationFunctionColumn as AggregationFunctionColumn, ɵAggregationFunctionExpression as AggregationFunctionExpression, ɵAggregationSubQueryColumn as AggregationSubQueryColumn, ɵAggregationSubQueryExpression as AggregationSubQueryExpression, ɵAggregationType as AggregationType, ɵArgumentEmptyException as ArgumentEmptyException, ɵArgumentFunctionExpression as ArgumentFunctionExpression, ɵArgumentOutOfRangeException as ArgumentOutOfRangeException, ɵArithmeticExpression as ArithmeticExpression, ɵArithmeticOperation as ArithmeticOperation, ɵArithmeticQueryColumn as ArithmeticQueryColumn, ɵBaseExpression as BaseExpression, ɵBaseExpressionParser as BaseExpressionParser, ɵBaseFilter as BaseFilter, ɵBaseFilterParser as BaseFilterParser, ɵBaseFilterableQuery as BaseFilterableQuery, ɵBaseQuery as BaseQuery, ɵBaseQueryColumn as BaseQueryColumn, ɵBaseRequest as BaseRequest, ɵBetweenFilter as BetweenFilter, ɵColumnExpression as ColumnExpression, ɵCompareFilter as CompareFilter, ɵComparisonType as ComparisonType, ɵDEFAULT_COLUMN_PLAIN_OBJ as DEFAULT_COLUMN_PLAIN_OBJ, ɵDEFAULT_FILTER_PLAIN_OBJ as DEFAULT_FILTER_PLAIN_OBJ, ɵDataSchemaAttributeType as DataSchemaAttributeType, ɵDataSchemaAttributeUsageType as DataSchemaAttributeUsageType, ɵDataSchemaType as DataSchemaType, ɵDataSourceScope as DataSourceScope, ɵDataValueType as DataValueType, ɵDatePartFunctionColumn as DatePartFunctionColumn, ɵDatePartFunctionExpression as DatePartFunctionExpression, ɵDatePartType as DatePartType, ɵDefaultValueSource as DefaultValueSource, ɵDeleteQuery as DeleteQuery, ɵEMPTY_GUID as EMPTY_GUID, ɵEntityQueryColumn as EntityQueryColumn, ɵEntitySchemaQuery as EntitySchemaQuery, ɵExistsFilter as ExistsFilter, ɵExpressionMock as ExpressionMock, ɵExpressionParser as ExpressionParser, ɵExpressionResolver as ExpressionResolver, ɵExpressionType as ExpressionType, ɵFilterGroup as FilterGroup, ɵFilterMock as FilterMock, ɵFilterParser as FilterParser, ɵFilterResolver as FilterResolver, ɵFilterType as FilterType, ɵFunctionExpression as FunctionExpression, ɵFunctionType as FunctionType, ɵInFilter as InFilter, ɵInsertQuery as InsertQuery, ɵIsNullFilter as IsNullFilter, ɵItemNotFoundException as ItemNotFoundException, ɵLengthFunctionColumn as LengthFunctionColumn, ɵLengthFunctionExpression as LengthFunctionExpression, ɵLogicalOperatorType as LogicalOperatorType, ɵMacrosFunctionColumn as MacrosFunctionColumn, ɵMacrosFunctionExpression as MacrosFunctionExpression, ɵModelInPageAction as ModelInPageAction, ɵModelParameterType as ModelParameterType, ɵNextHandlerAlreadySpecifiedException as NextHandlerAlreadySpecifiedException, ɵOrderDirection as OrderDirection, ɵParameterExpression as ParameterExpression, ɵParameterQueryColumn as ParameterQueryColumn, ɵQueryMacrosType as QueryMacrosType, ɵQueryOperationType as QueryOperationType, ɵSelectLocalizationQuery as SelectLocalizationQuery, ɵSingleFilter as SingleFilter, ɵSubQueryColumn as SubQueryColumn, ɵSubQueryExpression as SubQueryExpression, ɵUpdateQuery as UpdateQuery, ɵValidationUtilities as ValidationUtilities, ɵWindowFunctionColumn as WindowFunctionColumn, ɵWindowFunctionExpression as WindowFunctionExpression, ɵencodeDate as encodeDate, ɵgenerateGuid as generateGuid, ɵgetColumnPlainObj as getColumnPlainObj, ɵgetFilterPlainObj as getFilterPlainObj, ɵisEmptyGuid as isEmptyGuid, ɵisGuid as isGuid, ɵparserMock as parserMock, ɵtoLocalISOString as toLocalISOString } from '@creatio/base';
1
+ import { ɵAggregationType, ɵAggregationFunction, ɵAggregationEvalType, ɵDatePartType, ɵFunctionType, ɵOrderDirection, ɵgenerateGuid, ɵNextHandlerAlreadySpecifiedException, ɵBaseRequest, ɵSchemaViewMaskRequest, ɵSchemaViewMaskRequestAction } from '@creatio/base';
2
+ export { ɵAggregationEvalType as AggregationEvalType, ɵAggregationFunction as AggregationFunction, ɵAggregationFunctionColumn as AggregationFunctionColumn, ɵAggregationFunctionExpression as AggregationFunctionExpression, ɵAggregationSubQueryColumn as AggregationSubQueryColumn, ɵAggregationSubQueryExpression as AggregationSubQueryExpression, ɵAggregationType as AggregationType, ɵArgumentEmptyException as ArgumentEmptyException, ɵArgumentFunctionExpression as ArgumentFunctionExpression, ɵArgumentOutOfRangeException as ArgumentOutOfRangeException, ɵArithmeticExpression as ArithmeticExpression, ɵArithmeticOperation as ArithmeticOperation, ɵArithmeticQueryColumn as ArithmeticQueryColumn, ɵBaseExpression as BaseExpression, ɵBaseExpressionParser as BaseExpressionParser, ɵBaseFilter as BaseFilter, ɵBaseFilterParser as BaseFilterParser, ɵBaseFilterableQuery as BaseFilterableQuery, ɵBaseQuery as BaseQuery, ɵBaseQueryColumn as BaseQueryColumn, ɵBaseRequest as BaseRequest, ɵBetweenFilter as BetweenFilter, ɵColumnExpression as ColumnExpression, ɵCompareFilter as CompareFilter, ɵComparisonType as ComparisonType, ɵDEFAULT_COLUMN_PLAIN_OBJ as DEFAULT_COLUMN_PLAIN_OBJ, ɵDEFAULT_FILTER_PLAIN_OBJ as DEFAULT_FILTER_PLAIN_OBJ, ɵDataSchemaAttributeType as DataSchemaAttributeType, ɵDataSchemaAttributeUsageType as DataSchemaAttributeUsageType, ɵDataSchemaType as DataSchemaType, ɵDataSourceScope as DataSourceScope, ɵDataValueType as DataValueType, ɵDatePartFunctionColumn as DatePartFunctionColumn, ɵDatePartFunctionExpression as DatePartFunctionExpression, ɵDatePartType as DatePartType, ɵDefaultValueSource as DefaultValueSource, ɵDeleteQuery as DeleteQuery, ɵEMPTY_GUID as EMPTY_GUID, ɵEntityQueryColumn as EntityQueryColumn, ɵEntitySchemaQuery as EntitySchemaQuery, ɵExistsFilter as ExistsFilter, ɵExpressionMock as ExpressionMock, ɵExpressionParser as ExpressionParser, ɵExpressionResolver as ExpressionResolver, ɵExpressionType as ExpressionType, ɵFilterGroup as FilterGroup, ɵFilterMock as FilterMock, ɵFilterParser as FilterParser, ɵFilterResolver as FilterResolver, ɵFilterType as FilterType, ɵFunctionExpression as FunctionExpression, ɵFunctionType as FunctionType, ɵInFilter as InFilter, ɵInsertQuery as InsertQuery, ɵIsNullFilter as IsNullFilter, ɵItemNotFoundException as ItemNotFoundException, ɵLengthFunctionColumn as LengthFunctionColumn, ɵLengthFunctionExpression as LengthFunctionExpression, ɵLogicalOperatorType as LogicalOperatorType, ɵMacrosFunctionColumn as MacrosFunctionColumn, ɵMacrosFunctionExpression as MacrosFunctionExpression, ɵModelInPageAction as ModelInPageAction, ɵModelParameterType as ModelParameterType, ɵNextHandlerAlreadySpecifiedException as NextHandlerAlreadySpecifiedException, ɵOrderDirection as OrderDirection, ɵParameterExpression as ParameterExpression, ɵParameterQueryColumn as ParameterQueryColumn, ɵQueryMacrosType as QueryMacrosType, ɵQueryOperationType as QueryOperationType, ɵSchemaViewMaskRequest as SchemaViewMaskRequest, ɵSchemaViewMaskRequestAction as SchemaViewMaskRequestAction, ɵSelectLocalizationQuery as SelectLocalizationQuery, ɵSingleFilter as SingleFilter, ɵSubQueryColumn as SubQueryColumn, ɵSubQueryExpression as SubQueryExpression, ɵUpdateQuery as UpdateQuery, ɵValidationUtilities as ValidationUtilities, ɵWindowFunctionColumn as WindowFunctionColumn, ɵWindowFunctionExpression as WindowFunctionExpression, ɵencodeDate as encodeDate, ɵgenerateGuid as generateGuid, ɵgetColumnPlainObj as getColumnPlainObj, ɵgetFilterPlainObj as getFilterPlainObj, ɵisEmptyGuid as isEmptyGuid, ɵisGuid as isGuid, ɵparserMock as parserMock, ɵtoLocalISOString as toLocalISOString } from '@creatio/base';
3
3
  import { __awaiter, __decorate, __metadata } from 'tslib';
4
4
  import { get, set, upperFirst, camelCase, isEqual, cloneDeep } from 'lodash';
5
5
  import 'reflect-metadata';
@@ -196,6 +196,37 @@ const crtInjectPrefix = 'crtInject:';
196
196
  */
197
197
  const VIEW_ELEMENT_DEFAULT_HEIGHT = '39px';
198
198
 
199
+ /**
200
+ * @internal
201
+ */
202
+ class LazyModulesManager {
203
+ constructor() {
204
+ this._refs = new Set();
205
+ this.lazyLoadingDisabled = false;
206
+ }
207
+ static get instance() {
208
+ if (!this._instance) {
209
+ let globalInstance = get(window, this._globalInstancePath);
210
+ if (!globalInstance) {
211
+ globalInstance = new this();
212
+ set(window, this._globalInstancePath, globalInstance);
213
+ }
214
+ this._instance = globalInstance;
215
+ }
216
+ return this._instance;
217
+ }
218
+ add(ref) {
219
+ this._refs.add(ref);
220
+ }
221
+ loadAll() {
222
+ return Promise.all(Array.from(this._refs).map((ref) => ref.loadAndBootstrap()));
223
+ }
224
+ clear() {
225
+ this._refs.clear();
226
+ }
227
+ }
228
+ LazyModulesManager._globalInstancePath = 'creatio._lazyModulesManager';
229
+
199
230
  /**
200
231
  * @internal
201
232
  * @hostPublicApi
@@ -324,6 +355,16 @@ class HandlersOrderComparer {
324
355
  }
325
356
  }
326
357
 
358
+ /**
359
+ * @internal
360
+ */
361
+ function matchScopes(handlerScopes, requestScopes) {
362
+ if (!(handlerScopes === null || handlerScopes === void 0 ? void 0 : handlerScopes.length)) {
363
+ return true;
364
+ }
365
+ return handlerScopes.some((s) => requestScopes === null || requestScopes === void 0 ? void 0 : requestScopes.includes(s));
366
+ }
367
+
327
368
  /**
328
369
  * @internal
329
370
  * @hostPublicApi available through window.handlerChain
@@ -342,7 +383,17 @@ class InternalHandlerChain {
342
383
  * @hostPublicApi
343
384
  */
344
385
  process: (request) => __awaiter(this, void 0, void 0, function* () {
345
- const handler = this._getHandler(request);
386
+ let handler;
387
+ if (this._hasCacheHandler(request)) {
388
+ handler = this._getCacheHandler(request);
389
+ }
390
+ else {
391
+ const handlers = this._getMatchedHandlers(request);
392
+ if (!LazyModulesManager.instance.lazyLoadingDisabled) {
393
+ yield this._loadLazyHandlers(handlers);
394
+ }
395
+ handler = this._buildHandlersChain(request, handlers);
396
+ }
346
397
  this._requestListeners.forEach((listener) => listener === null || listener === void 0 ? void 0 : listener(request));
347
398
  return handler === null || handler === void 0 ? void 0 : handler.handle(request);
348
399
  }),
@@ -363,6 +414,15 @@ class InternalHandlerChain {
363
414
  }
364
415
  };
365
416
  },
417
+ /**
418
+ * @hostPublicApi
419
+ */
420
+ update: (updatedInfo) => {
421
+ const config = this._handlers.find((h) => h.type === updatedInfo.type);
422
+ if (config) {
423
+ config.createHandler = updatedInfo.createHandler;
424
+ }
425
+ },
366
426
  /**
367
427
  * @hostPublicApi
368
428
  */
@@ -389,8 +449,11 @@ class InternalHandlerChain {
389
449
  const configs = (_a = this._handlersScopesByContextId.get(contextId)) !== null && _a !== void 0 ? _a : [];
390
450
  return configs.every(({ requestType, scope }) => { var _a; return (_a = this._handlersCache.get(requestType)) === null || _a === void 0 ? void 0 : _a.delete(scope); });
391
451
  }
392
- _getHandler(request) {
393
- return this._hasCacheHandler(request) ? this._getCacheHandler(request) : this._buildHandlersChain(request);
452
+ clear() {
453
+ this._handlers.splice(0);
454
+ this._requestListeners.clear();
455
+ this._handlersCache.clear();
456
+ this._handlersScopesByContextId.clear();
394
457
  }
395
458
  _getCacheHandler(request) {
396
459
  const map = this._handlersCache.get(request.type);
@@ -441,22 +504,31 @@ class InternalHandlerChain {
441
504
  throw new Error('Handler should implement "BaseRequestHandler"');
442
505
  }
443
506
  }
444
- _buildHandlersChain(request) {
445
- const handlers = this._handlers.filter((h) => {
446
- var _a;
507
+ _loadLazyHandlers(configs) {
508
+ return __awaiter(this, void 0, void 0, function* () {
509
+ const lazyModules = new Set();
510
+ configs.forEach((config) => {
511
+ if (config.lazy && !config.createHandler) {
512
+ lazyModules.add(config.lazyModuleRef);
513
+ }
514
+ });
515
+ yield Promise.all(Array.from(lazyModules).map((m) => m.loadAndBootstrap()));
516
+ });
517
+ }
518
+ _getMatchedHandlers(request) {
519
+ return this._handlers.filter((h) => {
447
520
  if (h.requestType !== request.type) {
448
521
  return false;
449
522
  }
450
- if (!((_a = h.scopes) === null || _a === void 0 ? void 0 : _a.length)) {
451
- return true;
452
- }
453
- return h.scopes.some((s) => { var _a; return (_a = request.scopes) === null || _a === void 0 ? void 0 : _a.includes(s); });
523
+ return matchScopes(h.scopes, request.scopes);
454
524
  });
525
+ }
526
+ _buildHandlersChain(request, handlers) {
455
527
  const comparer = new HandlersOrderComparer(request);
456
528
  handlers.sort((a, b) => comparer.compare(a, b));
457
529
  const handlerInstances = handlers.map((handlerConfig) => {
458
530
  const injectionContext = this._getInjectionContext(request === null || request === void 0 ? void 0 : request.$context);
459
- return handlerConfig.createHandler(injectionContext);
531
+ return handlerConfig.createHandler.call(handlerConfig, injectionContext);
460
532
  });
461
533
  handlerInstances.forEach((handler) => this._checkHandlerInstanceOf(handler));
462
534
  this._joinHandlersInChain(handlerInstances);
@@ -517,6 +589,12 @@ class HandlerChainService {
517
589
  register(handlerConfig) {
518
590
  return this._chain.handlerChain$.register(handlerConfig);
519
591
  }
592
+ /**
593
+ * @internal
594
+ */
595
+ update(handlerConfig) {
596
+ return this._chain.handlerChain$.update(handlerConfig);
597
+ }
520
598
  /**
521
599
  * @description Method to process passed request
522
600
  * @param request - {@link ɵBaseRequest}
@@ -537,6 +615,12 @@ class HandlerChainService {
537
615
  subscribe(callback, context) {
538
616
  return this._chain.handlerChain$.subscribe(callback, context);
539
617
  }
618
+ /**
619
+ * @internal
620
+ */
621
+ clear() {
622
+ this._chain.clear();
623
+ }
540
624
  }
541
625
 
542
626
  /**
@@ -668,10 +752,16 @@ class InternalRequestHandlerRegistryType {
668
752
  * @publicHostApi
669
753
  */
670
754
  static addRequestHandler(handlerType, config) {
671
- if (!this._requestHandlersMap.has(handlerType)) {
672
- this._requestHandlersMap.set(handlerType, config);
755
+ var _a, _b;
756
+ const existingHandler = this._requestHandlersMap.get(handlerType);
757
+ if (!existingHandler || (((_a = existingHandler.instanceConfig) === null || _a === void 0 ? void 0 : _a.lazy) && !existingHandler.instanceType)) {
758
+ const mergedConfig = {
759
+ instanceType: config.instanceType,
760
+ instanceConfig: Object.assign(Object.assign({}, ((_b = existingHandler === null || existingHandler === void 0 ? void 0 : existingHandler.instanceConfig) !== null && _b !== void 0 ? _b : {})), config.instanceConfig),
761
+ };
762
+ this._requestHandlersMap.set(handlerType, mergedConfig);
673
763
  for (const listener of this._addItemListeners) {
674
- listener(handlerType, config);
764
+ listener(handlerType, mergedConfig);
675
765
  }
676
766
  }
677
767
  }
@@ -687,6 +777,11 @@ class InternalRequestHandlerRegistryType {
687
777
  }
688
778
  }
689
779
  }
780
+ static clear() {
781
+ for (const type of this._requestHandlersMap.keys()) {
782
+ this.removeRequestHandler(type);
783
+ }
784
+ }
690
785
  }
691
786
  InternalRequestHandlerRegistryType._addItemListeners = [];
692
787
  InternalRequestHandlerRegistryType._removeItemListeners = [];
@@ -765,6 +860,9 @@ RequestRegistryService._requestsRegistrationInfos = new Map();
765
860
  * @hostPublicApi available through window.creatio.registry.ConverterRegistry
766
861
  */
767
862
  class ConverterRegistry extends ɵBaseRegistry {
863
+ static has(type) {
864
+ return this.store.typeInfos.has(type);
865
+ }
768
866
  static get(type) {
769
867
  if (!this.store.typeInfos.has(type)) {
770
868
  throw new Error(`'${type}' converter doesn't exist`);
@@ -775,7 +873,8 @@ class ConverterRegistry extends ɵBaseRegistry {
775
873
  checkTypeNameFormat(item.type, 'ConverterTypeName');
776
874
  checkCrtTypeNamePascalCase(item.type);
777
875
  // TODO RND-21723
778
- this.store.typeInfos.set(item.type, item);
876
+ const existingItem = this.store.typeInfos.get(item.type);
877
+ this.store.typeInfos.set(item.type, Object.assign(Object.assign({}, (existingItem !== null && existingItem !== void 0 ? existingItem : {})), item));
779
878
  }
780
879
  static clear() {
781
880
  this.store.typeInfos.clear();
@@ -794,13 +893,18 @@ const viewElementRegistryKey = 'ViewElementRegistry';
794
893
  class ViewElementRegistry extends ɵBaseRegistry {
795
894
  static validate(config) {
796
895
  checkTypeNameFormat(config.type, 'ViewElementTypeName');
896
+ const existingItem = ViewElementRegistry.viewElements.get(config.type);
897
+ if ((existingItem === null || existingItem === void 0 ? void 0 : existingItem.lazy) && !('selector' in existingItem) && !existingItem.typeRef) {
898
+ return;
899
+ }
797
900
  checkOnlyOneRegistration(config.type, config, ViewElementRegistry.viewElements);
798
901
  }
799
902
  static get viewElements() {
800
903
  return this.store.typeInfos;
801
904
  }
802
905
  static register(config) {
803
- this.viewElements.set(config.type, config);
906
+ const existingConfig = this.viewElements.get(config.type);
907
+ this.viewElements.set(config.type, Object.assign(Object.assign({}, (existingConfig !== null && existingConfig !== void 0 ? existingConfig : {})), config));
804
908
  }
805
909
  static getFormControlRelatesAttribute(type) {
806
910
  var _a;
@@ -812,6 +916,11 @@ class ViewElementRegistry extends ɵBaseRegistry {
812
916
  const config = this.store.typeInfos.get(type);
813
917
  return (_a = config === null || config === void 0 ? void 0 : config.inputs) !== null && _a !== void 0 ? _a : {};
814
918
  }
919
+ static getViewElementOutputs(type) {
920
+ var _a;
921
+ const config = this.store.typeInfos.get(type);
922
+ return (_a = config === null || config === void 0 ? void 0 : config.outputs) !== null && _a !== void 0 ? _a : {};
923
+ }
815
924
  static getViewElementPropertiesDefaultValues(type) {
816
925
  var _a;
817
926
  const config = this.store.typeInfos.get(type);
@@ -956,11 +1065,15 @@ const validatorRegistryKey = 'ValidatorRegistry';
956
1065
  class ValidatorRegistry extends ɵBaseRegistry {
957
1066
  static _has(configType, type) {
958
1067
  var _a;
1068
+ const config = ValidatorRegistry.items.get(configType);
1069
+ if ((config === null || config === void 0 ? void 0 : config.lazy) && !(config === null || config === void 0 ? void 0 : config.typeRef)) {
1070
+ return false;
1071
+ }
959
1072
  return ValidatorRegistry.items.has(configType) && ((_a = ValidatorRegistry.items.get(configType)) === null || _a === void 0 ? void 0 : _a.typeRef) !== type;
960
1073
  }
961
1074
  static validate(config) {
962
1075
  checkTypeNameFormat(config.type, 'ValidatorTypeName');
963
- if (ValidatorRegistry._has(config.type, config.typeRef)) {
1076
+ if (config.typeRef && ValidatorRegistry._has(config.type, config.typeRef)) {
964
1077
  throw new Error(`Error when register ${config.type}. Element with this type has already exist`);
965
1078
  }
966
1079
  }
@@ -968,7 +1081,8 @@ class ValidatorRegistry extends ɵBaseRegistry {
968
1081
  return this.store.typeInfos;
969
1082
  }
970
1083
  static register(config) {
971
- this.items.set(config.type, config);
1084
+ const existingConfig = this.items.get(config.type);
1085
+ this.items.set(config.type, Object.assign(Object.assign({}, (existingConfig !== null && existingConfig !== void 0 ? existingConfig : {})), config));
972
1086
  }
973
1087
  }
974
1088
  ValidatorRegistry.registryKey = validatorRegistryKey;
@@ -1412,6 +1526,29 @@ var RemoteEntryType;
1412
1526
  RemoteEntryType["Module"] = "module";
1413
1527
  })(RemoteEntryType || (RemoteEntryType = {}));
1414
1528
 
1529
+ /**
1530
+ * @internal
1531
+ */
1532
+ class LazyModuleRef {
1533
+ get typeRef() {
1534
+ return this._typeRef;
1535
+ }
1536
+ constructor(_metadata, _bootstrapFn) {
1537
+ this._metadata = _metadata;
1538
+ this._bootstrapFn = _bootstrapFn;
1539
+ }
1540
+ loadAndBootstrap() {
1541
+ if (!this._modulePromise) {
1542
+ this._modulePromise = this._metadata.load().then((type) => {
1543
+ this._typeRef = type;
1544
+ this._bootstrapFn(type);
1545
+ return type;
1546
+ });
1547
+ }
1548
+ return this._modulePromise;
1549
+ }
1550
+ }
1551
+
1415
1552
  /**
1416
1553
  * @public
1417
1554
  * @description Creatio platform interacts with input's of user-defined component through CrtInput decorator.
@@ -1502,23 +1639,7 @@ function CrtViewElement(config) {
1502
1639
  }
1503
1640
 
1504
1641
  /**
1505
- * @public
1506
- * @description CrtModule decorator is a 'container' where user actually setup elements.
1507
- * In could contain viewElements, definitions of other CrtModules.
1508
- * @param moduleDefinition - {@link ModuleDefinition}
1509
- *
1510
- * @example
1511
- * @CrtModule({
1512
- * viewElements: [AppComponent],
1513
- * requestHandlers: [SomeRequestHandler],
1514
- * validators: [SomeValidator],
1515
- * })
1516
- * @NgModule({
1517
- * declarations: [AppComponent],
1518
- * imports: [BrowserModule],
1519
- * providers: [],
1520
- * })
1521
- * export class AppModule {}
1642
+ * @internal
1522
1643
  */
1523
1644
  function CrtModule(moduleDefinition) {
1524
1645
  return (type) => setModuleMetadata(moduleDefinition, type);
@@ -1696,6 +1817,16 @@ function registerViewElements(types) {
1696
1817
  ViewElementRegistry.register(registrationConfig);
1697
1818
  });
1698
1819
  }
1820
+ /**
1821
+ * @internal
1822
+ */
1823
+ function registerLazyViewElements(configs, lazyModuleRef) {
1824
+ resistantForEach(configs, (config) => {
1825
+ const registryItem = Object.assign(Object.assign({}, config), { lazy: true, lazyModuleRef });
1826
+ ViewElementRegistry.validate(registryItem);
1827
+ ViewElementRegistry.register(registryItem);
1828
+ });
1829
+ }
1699
1830
  /**
1700
1831
  * @internal
1701
1832
  */
@@ -1738,6 +1869,16 @@ function registerValidators(types, options) {
1738
1869
  ValidatorRegistry.register(registrationConfig);
1739
1870
  });
1740
1871
  }
1872
+ /**
1873
+ * @internal
1874
+ */
1875
+ function registerLazyValidators(configs, lazyModuleRef) {
1876
+ resistantForEach(configs, (config) => {
1877
+ const registryItem = Object.assign(Object.assign({}, config), { lazy: true, lazyModuleRef });
1878
+ ValidatorRegistry.validate(registryItem);
1879
+ ValidatorRegistry.register(registryItem);
1880
+ });
1881
+ }
1741
1882
  /**
1742
1883
  * @internal
1743
1884
  */
@@ -1753,6 +1894,15 @@ function registerConverters(types, options) {
1753
1894
  ConverterRegistry.register(registrationConfig);
1754
1895
  });
1755
1896
  }
1897
+ /**
1898
+ * @internal
1899
+ */
1900
+ function registerLazyConverters(descriptors, lazyModuleRef) {
1901
+ resistantForEach(descriptors, (descriptor) => {
1902
+ const registryItem = Object.assign(Object.assign({}, descriptor), { lazy: true, lazyModuleRef });
1903
+ ConverterRegistry.register(registryItem);
1904
+ });
1905
+ }
1756
1906
  /**
1757
1907
  * @internal
1758
1908
  */
@@ -1783,6 +1933,54 @@ function registerRequestHandlers(types, options, remoteName) {
1783
1933
  RequestHandlerRegistryService.register(registrationConfig, type);
1784
1934
  });
1785
1935
  }
1936
+ /**
1937
+ * @internal
1938
+ */
1939
+ function registerLazyRequestHandlers(descriptors, options, remoteName, lazyModuleRef) {
1940
+ resistantForEach(descriptors, (descriptor) => {
1941
+ const registrationConfig = Object.assign(Object.assign({}, descriptor), { lazy: true, lazyModuleRef });
1942
+ if (options.moduleType === 'host') {
1943
+ registrationConfig.source = { type: HandlerSourceType.Host };
1944
+ }
1945
+ else {
1946
+ const remote = RemoteEntriesRegistry.items.get(remoteName);
1947
+ registrationConfig.source = {
1948
+ type: HandlerSourceType.Remote,
1949
+ packageName: remote.packageName,
1950
+ };
1951
+ }
1952
+ RequestHandlerRegistryService.register(registrationConfig);
1953
+ });
1954
+ }
1955
+ /**
1956
+ * @internal
1957
+ */
1958
+ function bootstrapLazyCrtModule(name, descriptor, options, lazyModuleRef) {
1959
+ var _a;
1960
+ try {
1961
+ if (descriptor.viewElements) {
1962
+ registerLazyViewElements(descriptor.viewElements, lazyModuleRef);
1963
+ }
1964
+ if (descriptor.requestHandlers) {
1965
+ registerLazyRequestHandlers(descriptor.requestHandlers, options, name, lazyModuleRef);
1966
+ }
1967
+ if (descriptor.validators) {
1968
+ registerLazyValidators(descriptor.validators, lazyModuleRef);
1969
+ }
1970
+ if (descriptor.converters) {
1971
+ registerLazyConverters(descriptor.converters, lazyModuleRef);
1972
+ }
1973
+ (_a = descriptor.includes) === null || _a === void 0 ? void 0 : _a.forEach((m) => {
1974
+ bootstrapLazyCrtModule(name, m, options, lazyModuleRef);
1975
+ });
1976
+ }
1977
+ catch (error) {
1978
+ console.error(error);
1979
+ }
1980
+ }
1981
+ /**
1982
+ * @internal
1983
+ */
1786
1984
  function bootstrapDefaultCrtModule(name, type, options) {
1787
1985
  var _a;
1788
1986
  try {
@@ -1804,8 +2002,15 @@ function bootstrapDefaultCrtModule(name, type, options) {
1804
2002
  registerConverters(moduleDefinition.converters, options);
1805
2003
  }
1806
2004
  (_a = moduleDefinition.includes) === null || _a === void 0 ? void 0 : _a.forEach((t) => {
1807
- bootstrapDefaultCrtModule(name, t, options);
1808
- bootstrapPredefinedModules(name, t, options);
2005
+ if (typeof t === 'function') {
2006
+ bootstrapDefaultCrtModule(name, t, options);
2007
+ bootstrapPredefinedModules(name, t, options);
2008
+ }
2009
+ else if (typeof t === 'object') {
2010
+ const ref = new LazyModuleRef(t, (x) => bootstrapDefaultCrtModule(name, x, options));
2011
+ bootstrapLazyCrtModule(name, t, options, ref);
2012
+ LazyModulesManager.instance.add(ref);
2013
+ }
1809
2014
  });
1810
2015
  }
1811
2016
  catch (error) {
@@ -1901,7 +2106,11 @@ function _bootstrapCrtModuleHandlerChainServices(type) {
1901
2106
  if (moduleDefinition.handlerChainServices) {
1902
2107
  registerHandlerChainServices(moduleDefinition.handlerChainServices);
1903
2108
  }
1904
- (_a = moduleDefinition.includes) === null || _a === void 0 ? void 0 : _a.forEach((t) => _bootstrapCrtModuleHandlerChainServices(t));
2109
+ (_a = moduleDefinition.includes) === null || _a === void 0 ? void 0 : _a.forEach((t) => {
2110
+ if (typeof t === 'function') {
2111
+ _bootstrapCrtModuleHandlerChainServices(t);
2112
+ }
2113
+ });
1905
2114
  }
1906
2115
  /**
1907
2116
  * @internal
@@ -1910,6 +2119,32 @@ function bootstrapCrtModuleHandlerChainServices(type) {
1910
2119
  _bootstrapCrtModuleHandlerChainServices(type);
1911
2120
  }
1912
2121
 
2122
+ /**
2123
+ * @internal
2124
+ * Clears global registries, resets state of global services.
2125
+ * Can be used in unit tests to clear global registries after bootstrapping module.
2126
+ * @example
2127
+ * beforeEach(() => {
2128
+ * bootstrapCrtModule('test', TestModule);
2129
+ * });
2130
+ *
2131
+ * afterEach(() => {
2132
+ * resetGlobals();
2133
+ * });
2134
+ */
2135
+ function resetGlobals() {
2136
+ ViewElementRegistry.viewElements.clear();
2137
+ InternalRequestHandlerRegistry.clear();
2138
+ HandlerChainService.instance.clear();
2139
+ ValidatorRegistry.items.clear();
2140
+ ConverterRegistry.clear();
2141
+ RemoteEntriesRegistry.items.clear();
2142
+ PkgTopology.items.clear();
2143
+ LazyModulesManager.instance.clear();
2144
+ LazyModulesManager.instance.lazyLoadingDisabled = false;
2145
+ DesignTimeViewElementRegistry.infos.clear();
2146
+ }
2147
+
1913
2148
  /**
1914
2149
  * @public
1915
2150
  * @abstract
@@ -2153,25 +2388,23 @@ __decorate([
2153
2388
  ], HttpClientService.prototype, "patch", null);
2154
2389
 
2155
2390
  /**
2156
- * @internal
2157
- */
2158
- var SchemaViewMaskRequestAction;
2159
- (function (SchemaViewMaskRequestAction) {
2160
- SchemaViewMaskRequestAction["AddTask"] = "addTask";
2161
- SchemaViewMaskRequestAction["RemoveTask"] = "removeTask";
2162
- })(SchemaViewMaskRequestAction || (SchemaViewMaskRequestAction = {}));
2163
- /**
2164
- * @internal
2391
+ * @public
2392
+ * @classdesc Represents a service to working with license restrictions.
2393
+ * @extends {BaseHandlerChainService}
2165
2394
  */
2166
- class SchemaViewMaskRequest extends ɵBaseRequest {
2167
- constructor(action, taskName, $context) {
2168
- super();
2169
- this.action = action;
2170
- this.taskName = taskName;
2171
- this.$context = $context;
2172
- this.type = 'crt.SchemaViewMaskRequest';
2395
+ class LicenseService extends BaseHandlerChainService {
2396
+ constructor() {
2397
+ super(...arguments);
2398
+ /**
2399
+ * @internal
2400
+ */
2401
+ this.requestType = 'crt.LicenseService';
2173
2402
  }
2174
2403
  }
2404
+ __decorate([
2405
+ ImplementUsingHandlerChain(),
2406
+ __metadata("design:type", Function)
2407
+ ], LicenseService.prototype, "loadLicenseOperationStatuses", void 0);
2175
2408
 
2176
2409
  /**
2177
2410
  * @public
@@ -2193,7 +2426,7 @@ class MaskService extends BaseHandlerChainService {
2193
2426
  */
2194
2427
  showMask(taskName, context) {
2195
2428
  return __awaiter(this, void 0, void 0, function* () {
2196
- const request = new SchemaViewMaskRequest(SchemaViewMaskRequestAction.AddTask, taskName, context);
2429
+ const request = new ɵSchemaViewMaskRequest(ɵSchemaViewMaskRequestAction.AddTask, taskName, context);
2197
2430
  yield HandlerChainService.instance.process(request);
2198
2431
  });
2199
2432
  }
@@ -2204,7 +2437,7 @@ class MaskService extends BaseHandlerChainService {
2204
2437
  */
2205
2438
  hideMask(taskName, context) {
2206
2439
  return __awaiter(this, void 0, void 0, function* () {
2207
- const request = new SchemaViewMaskRequest(SchemaViewMaskRequestAction.RemoveTask, taskName, context);
2440
+ const request = new ɵSchemaViewMaskRequest(ɵSchemaViewMaskRequestAction.RemoveTask, taskName, context);
2208
2441
  yield HandlerChainService.instance.process(request);
2209
2442
  });
2210
2443
  }
@@ -2269,6 +2502,9 @@ class Model extends BaseHandlerChainService {
2269
2502
  return this._crtModel._getAsyncResult(this._crtModel.getSchema());
2270
2503
  }
2271
2504
  load(config) {
2505
+ if ((config === null || config === void 0 ? void 0 : config.loadOptions) && !(config === null || config === void 0 ? void 0 : config.options)) {
2506
+ config.options = config.loadOptions;
2507
+ }
2272
2508
  return this._crtModel._getAsyncResult(this._crtModel.load(config));
2273
2509
  }
2274
2510
  insert(dto) {
@@ -2323,5 +2559,5 @@ __decorate([
2323
2559
  * Generated bundle index. Do not edit.
2324
2560
  */
2325
2561
 
2326
- export { BaseRequestHandler, BaseValidator, BootstrapNotifier, ConverterRegistry, CrtConverter, CrtDesignTimeViewElement, CrtInject, CrtInput, CrtInputRegistrationConfig, CrtInterfaceDesignerItem, CrtModule, CrtOutput, CrtRequest, CrtRequestHandler, CrtValidationInput, CrtValidator, CrtViewElement, CrtZoneService, DataRequest, DataSourceLoadType, DesignTimeViewElementRegistry, DesignerToolGroupType, FeatureService, HandlerChainService, HandlerChainServicesRegistry, HandlerSourceType, HandlersOrderComparer, HttpClientService, ImplementUsingHandlerChain, InterfaceDesignerItemRegistrationConfig, InterfaceDesignerItemRegistry, InternalRequestHandlerRegistry, InternalRequestHandlerRegistryType, LocalizableValue, MaskService, MethodInvokeRequest, Model, PkgTopology, RemoteEntriesRegistry, RemoteEntryType, RequestHandlerRegistryService, RequestRegistryService, RightsService, SchemaViewMaskRequest, SchemaViewMaskRequestAction, SysSetting, SysSettingValue, SysSettingsService, SysValuesService, VIEW_ELEMENT_DEFAULT_HEIGHT, ValidatorMapValue, ValidatorRegistry, ViewElementDataGroupType, ViewElementGroupType, ViewElementProperty, ViewElementRegistry, ViewElementReuseStrategy, ViewElementVisibilityStrategy, _from, applyLocalizeMetadataFn, bootstrapCrtModule, bootstrapCrtModuleHandlerChainServices, checkCrtTypeNamePascalCase, checkIfTypeRegistered, checkOnlyOneRegistration, checkTypeNameFormat, checkTypeNamePascalCase, crtInjectPrefix, crtInputPrefix, crtOutputPrefix, crtValidationInputPrefix, designTimeViewElementRegistryKey, getConverterMetadata, getCrtInputsMetadata, getCrtOutputsMetadata, getCrtValidationInputsMetadata, getDesignTimeViewElementMetadata, getHandlerChainServiceMetadata, getInterfaceDesignerItemMetadata, getModuleMetadata, getRequestHandlerMetadata, getTypeDependencies, getValidatorMetadata, getViewElementMetadata, hasInterfaceDesignerItemMetadata, instantiate, interfaceDesignerItemRegistryKey, isComponentPropertyBindable, localize, objectDeepKeys, registerAngularViewElement, registerViewElement, setConverterMetadata, setDesignTimeViewElementMetadata, setInterfaceDesignerItemMetadata, setModuleMetadata, setRequestHandlerMetadata, setValidatorMetadata, setViewElementMetadata, toAggregationEval, toAggregationEvalType, toAggregationFunction, toAggregationType, toDatePart, toDatePartType, toNumericFunctionType, toOrderDirection, toPascalCase, toSortDirection, toStringFunctionType, validatorRegistryKey, viewElementRegistryKey, ɵBaseRegistry, ɵcheckTypeNameFormat, ɵinstantiate };
2562
+ export { BaseRequestHandler, BaseValidator, BootstrapNotifier, ConverterRegistry, CrtConverter, CrtDesignTimeViewElement, CrtInject, CrtInput, CrtInputRegistrationConfig, CrtInterfaceDesignerItem, CrtModule, CrtOutput, CrtRequest, CrtRequestHandler, CrtValidationInput, CrtValidator, CrtViewElement, CrtZoneService, DataRequest, DataSourceLoadType, DesignTimeViewElementRegistry, DesignerToolGroupType, FeatureService, HandlerChainService, HandlerChainServicesRegistry, HandlerSourceType, HandlersOrderComparer, HttpClientService, ImplementUsingHandlerChain, InterfaceDesignerItemRegistrationConfig, InterfaceDesignerItemRegistry, InternalRequestHandlerRegistry, InternalRequestHandlerRegistryType, LazyModuleRef, LazyModulesManager, LicenseService, LocalizableValue, MaskService, MethodInvokeRequest, Model, PkgTopology, RemoteEntriesRegistry, RemoteEntryType, RequestHandlerRegistryService, RequestRegistryService, RightsService, SysSetting, SysSettingValue, SysSettingsService, SysValuesService, VIEW_ELEMENT_DEFAULT_HEIGHT, ValidatorMapValue, ValidatorRegistry, ViewElementDataGroupType, ViewElementGroupType, ViewElementProperty, ViewElementRegistry, ViewElementReuseStrategy, ViewElementVisibilityStrategy, _from, applyLocalizeMetadataFn, bootstrapCrtModule, bootstrapCrtModuleHandlerChainServices, checkCrtTypeNamePascalCase, checkIfTypeRegistered, checkOnlyOneRegistration, checkTypeNameFormat, checkTypeNamePascalCase, crtInjectPrefix, crtInputPrefix, crtOutputPrefix, crtValidationInputPrefix, designTimeViewElementRegistryKey, getConverterMetadata, getCrtInputsMetadata, getCrtOutputsMetadata, getCrtValidationInputsMetadata, getDesignTimeViewElementMetadata, getHandlerChainServiceMetadata, getInterfaceDesignerItemMetadata, getModuleMetadata, getRequestHandlerMetadata, getTypeDependencies, getValidatorMetadata, getViewElementMetadata, hasInterfaceDesignerItemMetadata, instantiate, interfaceDesignerItemRegistryKey, isComponentPropertyBindable, localize, matchScopes, objectDeepKeys, registerAngularViewElement, registerViewElement, resetGlobals, setConverterMetadata, setDesignTimeViewElementMetadata, setInterfaceDesignerItemMetadata, setModuleMetadata, setRequestHandlerMetadata, setValidatorMetadata, setViewElementMetadata, toAggregationEval, toAggregationEvalType, toAggregationFunction, toAggregationType, toDatePart, toDatePartType, toNumericFunctionType, toOrderDirection, toPascalCase, toSortDirection, toStringFunctionType, validatorRegistryKey, viewElementRegistryKey, ɵBaseRegistry, ɵcheckTypeNameFormat, ɵinstantiate };
2327
2563
  //# sourceMappingURL=creatio-devkit-common.mjs.map