@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 { get, set, upperFirst, camelCase, isEqual, cloneDeep } from 'lodash';
4
4
  import 'reflect-metadata';
5
5
  import { __decorate, __metadata } from 'tslib';
@@ -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
@@ -323,6 +354,16 @@ class HandlersOrderComparer {
323
354
  }
324
355
  }
325
356
 
357
+ /**
358
+ * @internal
359
+ */
360
+ function matchScopes(handlerScopes, requestScopes) {
361
+ if (!handlerScopes?.length) {
362
+ return true;
363
+ }
364
+ return handlerScopes.some((s) => requestScopes?.includes(s));
365
+ }
366
+
326
367
  /**
327
368
  * @internal
328
369
  * @hostPublicApi available through window.handlerChain
@@ -341,7 +382,17 @@ class InternalHandlerChain {
341
382
  * @hostPublicApi
342
383
  */
343
384
  process: async (request) => {
344
- const handler = this._getHandler(request);
385
+ let handler;
386
+ if (this._hasCacheHandler(request)) {
387
+ handler = this._getCacheHandler(request);
388
+ }
389
+ else {
390
+ const handlers = this._getMatchedHandlers(request);
391
+ if (!LazyModulesManager.instance.lazyLoadingDisabled) {
392
+ await this._loadLazyHandlers(handlers);
393
+ }
394
+ handler = this._buildHandlersChain(request, handlers);
395
+ }
345
396
  this._requestListeners.forEach((listener) => listener?.(request));
346
397
  return handler?.handle(request);
347
398
  },
@@ -362,6 +413,15 @@ class InternalHandlerChain {
362
413
  }
363
414
  };
364
415
  },
416
+ /**
417
+ * @hostPublicApi
418
+ */
419
+ update: (updatedInfo) => {
420
+ const config = this._handlers.find((h) => h.type === updatedInfo.type);
421
+ if (config) {
422
+ config.createHandler = updatedInfo.createHandler;
423
+ }
424
+ },
365
425
  /**
366
426
  * @hostPublicApi
367
427
  */
@@ -387,8 +447,11 @@ class InternalHandlerChain {
387
447
  const configs = this._handlersScopesByContextId.get(contextId) ?? [];
388
448
  return configs.every(({ requestType, scope }) => this._handlersCache.get(requestType)?.delete(scope));
389
449
  }
390
- _getHandler(request) {
391
- return this._hasCacheHandler(request) ? this._getCacheHandler(request) : this._buildHandlersChain(request);
450
+ clear() {
451
+ this._handlers.splice(0);
452
+ this._requestListeners.clear();
453
+ this._handlersCache.clear();
454
+ this._handlersScopesByContextId.clear();
392
455
  }
393
456
  _getCacheHandler(request) {
394
457
  const map = this._handlersCache.get(request.type);
@@ -436,21 +499,29 @@ class InternalHandlerChain {
436
499
  throw new Error('Handler should implement "BaseRequestHandler"');
437
500
  }
438
501
  }
439
- _buildHandlersChain(request) {
440
- const handlers = this._handlers.filter((h) => {
502
+ async _loadLazyHandlers(configs) {
503
+ const lazyModules = new Set();
504
+ configs.forEach((config) => {
505
+ if (config.lazy && !config.createHandler) {
506
+ lazyModules.add(config.lazyModuleRef);
507
+ }
508
+ });
509
+ await Promise.all(Array.from(lazyModules).map((m) => m.loadAndBootstrap()));
510
+ }
511
+ _getMatchedHandlers(request) {
512
+ return this._handlers.filter((h) => {
441
513
  if (h.requestType !== request.type) {
442
514
  return false;
443
515
  }
444
- if (!h.scopes?.length) {
445
- return true;
446
- }
447
- return h.scopes.some((s) => request.scopes?.includes(s));
516
+ return matchScopes(h.scopes, request.scopes);
448
517
  });
518
+ }
519
+ _buildHandlersChain(request, handlers) {
449
520
  const comparer = new HandlersOrderComparer(request);
450
521
  handlers.sort((a, b) => comparer.compare(a, b));
451
522
  const handlerInstances = handlers.map((handlerConfig) => {
452
523
  const injectionContext = this._getInjectionContext(request?.$context);
453
- return handlerConfig.createHandler(injectionContext);
524
+ return handlerConfig.createHandler.call(handlerConfig, injectionContext);
454
525
  });
455
526
  handlerInstances.forEach((handler) => this._checkHandlerInstanceOf(handler));
456
527
  this._joinHandlersInChain(handlerInstances);
@@ -511,6 +582,12 @@ class HandlerChainService {
511
582
  register(handlerConfig) {
512
583
  return this._chain.handlerChain$.register(handlerConfig);
513
584
  }
585
+ /**
586
+ * @internal
587
+ */
588
+ update(handlerConfig) {
589
+ return this._chain.handlerChain$.update(handlerConfig);
590
+ }
514
591
  /**
515
592
  * @description Method to process passed request
516
593
  * @param request - {@link ɵBaseRequest}
@@ -531,6 +608,12 @@ class HandlerChainService {
531
608
  subscribe(callback, context) {
532
609
  return this._chain.handlerChain$.subscribe(callback, context);
533
610
  }
611
+ /**
612
+ * @internal
613
+ */
614
+ clear() {
615
+ this._chain.clear();
616
+ }
534
617
  }
535
618
 
536
619
  /**
@@ -661,10 +744,18 @@ class InternalRequestHandlerRegistryType {
661
744
  * @publicHostApi
662
745
  */
663
746
  static addRequestHandler(handlerType, config) {
664
- if (!this._requestHandlersMap.has(handlerType)) {
665
- this._requestHandlersMap.set(handlerType, config);
747
+ const existingHandler = this._requestHandlersMap.get(handlerType);
748
+ if (!existingHandler || (existingHandler.instanceConfig?.lazy && !existingHandler.instanceType)) {
749
+ const mergedConfig = {
750
+ instanceType: config.instanceType,
751
+ instanceConfig: {
752
+ ...(existingHandler?.instanceConfig ?? {}),
753
+ ...config.instanceConfig,
754
+ },
755
+ };
756
+ this._requestHandlersMap.set(handlerType, mergedConfig);
666
757
  for (const listener of this._addItemListeners) {
667
- listener(handlerType, config);
758
+ listener(handlerType, mergedConfig);
668
759
  }
669
760
  }
670
761
  }
@@ -680,6 +771,11 @@ class InternalRequestHandlerRegistryType {
680
771
  }
681
772
  }
682
773
  }
774
+ static clear() {
775
+ for (const type of this._requestHandlersMap.keys()) {
776
+ this.removeRequestHandler(type);
777
+ }
778
+ }
683
779
  }
684
780
  InternalRequestHandlerRegistryType._addItemListeners = [];
685
781
  InternalRequestHandlerRegistryType._removeItemListeners = [];
@@ -758,6 +854,9 @@ RequestRegistryService._requestsRegistrationInfos = new Map();
758
854
  * @hostPublicApi available through window.creatio.registry.ConverterRegistry
759
855
  */
760
856
  class ConverterRegistry extends ɵBaseRegistry {
857
+ static has(type) {
858
+ return this.store.typeInfos.has(type);
859
+ }
761
860
  static get(type) {
762
861
  if (!this.store.typeInfos.has(type)) {
763
862
  throw new Error(`'${type}' converter doesn't exist`);
@@ -768,7 +867,11 @@ class ConverterRegistry extends ɵBaseRegistry {
768
867
  checkTypeNameFormat(item.type, 'ConverterTypeName');
769
868
  checkCrtTypeNamePascalCase(item.type);
770
869
  // TODO RND-21723
771
- this.store.typeInfos.set(item.type, item);
870
+ const existingItem = this.store.typeInfos.get(item.type);
871
+ this.store.typeInfos.set(item.type, {
872
+ ...(existingItem ?? {}),
873
+ ...item,
874
+ });
772
875
  }
773
876
  static clear() {
774
877
  this.store.typeInfos.clear();
@@ -787,13 +890,21 @@ const viewElementRegistryKey = 'ViewElementRegistry';
787
890
  class ViewElementRegistry extends ɵBaseRegistry {
788
891
  static validate(config) {
789
892
  checkTypeNameFormat(config.type, 'ViewElementTypeName');
893
+ const existingItem = ViewElementRegistry.viewElements.get(config.type);
894
+ if (existingItem?.lazy && !('selector' in existingItem) && !existingItem.typeRef) {
895
+ return;
896
+ }
790
897
  checkOnlyOneRegistration(config.type, config, ViewElementRegistry.viewElements);
791
898
  }
792
899
  static get viewElements() {
793
900
  return this.store.typeInfos;
794
901
  }
795
902
  static register(config) {
796
- this.viewElements.set(config.type, config);
903
+ const existingConfig = this.viewElements.get(config.type);
904
+ this.viewElements.set(config.type, {
905
+ ...(existingConfig ?? {}),
906
+ ...config,
907
+ });
797
908
  }
798
909
  static getFormControlRelatesAttribute(type) {
799
910
  const config = this.store.typeInfos.get(type);
@@ -803,6 +914,10 @@ class ViewElementRegistry extends ɵBaseRegistry {
803
914
  const config = this.store.typeInfos.get(type);
804
915
  return config?.inputs ?? {};
805
916
  }
917
+ static getViewElementOutputs(type) {
918
+ const config = this.store.typeInfos.get(type);
919
+ return config?.outputs ?? {};
920
+ }
806
921
  static getViewElementPropertiesDefaultValues(type) {
807
922
  const config = this.store.typeInfos.get(type);
808
923
  const propertiesDefaultValues = Object.entries(config?.inputs ?? {})
@@ -945,11 +1060,15 @@ const validatorRegistryKey = 'ValidatorRegistry';
945
1060
  */
946
1061
  class ValidatorRegistry extends ɵBaseRegistry {
947
1062
  static _has(configType, type) {
1063
+ const config = ValidatorRegistry.items.get(configType);
1064
+ if (config?.lazy && !config?.typeRef) {
1065
+ return false;
1066
+ }
948
1067
  return ValidatorRegistry.items.has(configType) && ValidatorRegistry.items.get(configType)?.typeRef !== type;
949
1068
  }
950
1069
  static validate(config) {
951
1070
  checkTypeNameFormat(config.type, 'ValidatorTypeName');
952
- if (ValidatorRegistry._has(config.type, config.typeRef)) {
1071
+ if (config.typeRef && ValidatorRegistry._has(config.type, config.typeRef)) {
953
1072
  throw new Error(`Error when register ${config.type}. Element with this type has already exist`);
954
1073
  }
955
1074
  }
@@ -957,7 +1076,11 @@ class ValidatorRegistry extends ɵBaseRegistry {
957
1076
  return this.store.typeInfos;
958
1077
  }
959
1078
  static register(config) {
960
- this.items.set(config.type, config);
1079
+ const existingConfig = this.items.get(config.type);
1080
+ this.items.set(config.type, {
1081
+ ...(existingConfig ?? {}),
1082
+ ...config,
1083
+ });
961
1084
  }
962
1085
  }
963
1086
  ValidatorRegistry.registryKey = validatorRegistryKey;
@@ -1407,6 +1530,29 @@ var RemoteEntryType;
1407
1530
  RemoteEntryType["Module"] = "module";
1408
1531
  })(RemoteEntryType || (RemoteEntryType = {}));
1409
1532
 
1533
+ /**
1534
+ * @internal
1535
+ */
1536
+ class LazyModuleRef {
1537
+ get typeRef() {
1538
+ return this._typeRef;
1539
+ }
1540
+ constructor(_metadata, _bootstrapFn) {
1541
+ this._metadata = _metadata;
1542
+ this._bootstrapFn = _bootstrapFn;
1543
+ }
1544
+ loadAndBootstrap() {
1545
+ if (!this._modulePromise) {
1546
+ this._modulePromise = this._metadata.load().then((type) => {
1547
+ this._typeRef = type;
1548
+ this._bootstrapFn(type);
1549
+ return type;
1550
+ });
1551
+ }
1552
+ return this._modulePromise;
1553
+ }
1554
+ }
1555
+
1410
1556
  /**
1411
1557
  * @public
1412
1558
  * @description Creatio platform interacts with input's of user-defined component through CrtInput decorator.
@@ -1500,23 +1646,7 @@ function CrtViewElement(config) {
1500
1646
  }
1501
1647
 
1502
1648
  /**
1503
- * @public
1504
- * @description CrtModule decorator is a 'container' where user actually setup elements.
1505
- * In could contain viewElements, definitions of other CrtModules.
1506
- * @param moduleDefinition - {@link ModuleDefinition}
1507
- *
1508
- * @example
1509
- * @CrtModule({
1510
- * viewElements: [AppComponent],
1511
- * requestHandlers: [SomeRequestHandler],
1512
- * validators: [SomeValidator],
1513
- * })
1514
- * @NgModule({
1515
- * declarations: [AppComponent],
1516
- * imports: [BrowserModule],
1517
- * providers: [],
1518
- * })
1519
- * export class AppModule {}
1649
+ * @internal
1520
1650
  */
1521
1651
  function CrtModule(moduleDefinition) {
1522
1652
  return (type) => setModuleMetadata(moduleDefinition, type);
@@ -1699,6 +1829,16 @@ function registerViewElements(types) {
1699
1829
  ViewElementRegistry.register(registrationConfig);
1700
1830
  });
1701
1831
  }
1832
+ /**
1833
+ * @internal
1834
+ */
1835
+ function registerLazyViewElements(configs, lazyModuleRef) {
1836
+ resistantForEach(configs, (config) => {
1837
+ const registryItem = { ...config, lazy: true, lazyModuleRef };
1838
+ ViewElementRegistry.validate(registryItem);
1839
+ ViewElementRegistry.register(registryItem);
1840
+ });
1841
+ }
1702
1842
  /**
1703
1843
  * @internal
1704
1844
  */
@@ -1744,6 +1884,16 @@ function registerValidators(types, options) {
1744
1884
  ValidatorRegistry.register(registrationConfig);
1745
1885
  });
1746
1886
  }
1887
+ /**
1888
+ * @internal
1889
+ */
1890
+ function registerLazyValidators(configs, lazyModuleRef) {
1891
+ resistantForEach(configs, (config) => {
1892
+ const registryItem = { ...config, lazy: true, lazyModuleRef };
1893
+ ValidatorRegistry.validate(registryItem);
1894
+ ValidatorRegistry.register(registryItem);
1895
+ });
1896
+ }
1747
1897
  /**
1748
1898
  * @internal
1749
1899
  */
@@ -1762,6 +1912,15 @@ function registerConverters(types, options) {
1762
1912
  ConverterRegistry.register(registrationConfig);
1763
1913
  });
1764
1914
  }
1915
+ /**
1916
+ * @internal
1917
+ */
1918
+ function registerLazyConverters(descriptors, lazyModuleRef) {
1919
+ resistantForEach(descriptors, (descriptor) => {
1920
+ const registryItem = { ...descriptor, lazy: true, lazyModuleRef };
1921
+ ConverterRegistry.register(registryItem);
1922
+ });
1923
+ }
1765
1924
  /**
1766
1925
  * @internal
1767
1926
  */
@@ -1800,6 +1959,57 @@ function registerRequestHandlers(types, options, remoteName) {
1800
1959
  RequestHandlerRegistryService.register(registrationConfig, type);
1801
1960
  });
1802
1961
  }
1962
+ /**
1963
+ * @internal
1964
+ */
1965
+ function registerLazyRequestHandlers(descriptors, options, remoteName, lazyModuleRef) {
1966
+ resistantForEach(descriptors, (descriptor) => {
1967
+ const registrationConfig = {
1968
+ ...descriptor,
1969
+ lazy: true,
1970
+ lazyModuleRef,
1971
+ };
1972
+ if (options.moduleType === 'host') {
1973
+ registrationConfig.source = { type: HandlerSourceType.Host };
1974
+ }
1975
+ else {
1976
+ const remote = RemoteEntriesRegistry.items.get(remoteName);
1977
+ registrationConfig.source = {
1978
+ type: HandlerSourceType.Remote,
1979
+ packageName: remote.packageName,
1980
+ };
1981
+ }
1982
+ RequestHandlerRegistryService.register(registrationConfig);
1983
+ });
1984
+ }
1985
+ /**
1986
+ * @internal
1987
+ */
1988
+ function bootstrapLazyCrtModule(name, descriptor, options, lazyModuleRef) {
1989
+ try {
1990
+ if (descriptor.viewElements) {
1991
+ registerLazyViewElements(descriptor.viewElements, lazyModuleRef);
1992
+ }
1993
+ if (descriptor.requestHandlers) {
1994
+ registerLazyRequestHandlers(descriptor.requestHandlers, options, name, lazyModuleRef);
1995
+ }
1996
+ if (descriptor.validators) {
1997
+ registerLazyValidators(descriptor.validators, lazyModuleRef);
1998
+ }
1999
+ if (descriptor.converters) {
2000
+ registerLazyConverters(descriptor.converters, lazyModuleRef);
2001
+ }
2002
+ descriptor.includes?.forEach((m) => {
2003
+ bootstrapLazyCrtModule(name, m, options, lazyModuleRef);
2004
+ });
2005
+ }
2006
+ catch (error) {
2007
+ console.error(error);
2008
+ }
2009
+ }
2010
+ /**
2011
+ * @internal
2012
+ */
1803
2013
  function bootstrapDefaultCrtModule(name, type, options) {
1804
2014
  try {
1805
2015
  const moduleDefinition = getModuleMetadata(type);
@@ -1820,8 +2030,15 @@ function bootstrapDefaultCrtModule(name, type, options) {
1820
2030
  registerConverters(moduleDefinition.converters, options);
1821
2031
  }
1822
2032
  moduleDefinition.includes?.forEach((t) => {
1823
- bootstrapDefaultCrtModule(name, t, options);
1824
- bootstrapPredefinedModules(name, t, options);
2033
+ if (typeof t === 'function') {
2034
+ bootstrapDefaultCrtModule(name, t, options);
2035
+ bootstrapPredefinedModules(name, t, options);
2036
+ }
2037
+ else if (typeof t === 'object') {
2038
+ const ref = new LazyModuleRef(t, (x) => bootstrapDefaultCrtModule(name, x, options));
2039
+ bootstrapLazyCrtModule(name, t, options, ref);
2040
+ LazyModulesManager.instance.add(ref);
2041
+ }
1825
2042
  });
1826
2043
  }
1827
2044
  catch (error) {
@@ -1915,7 +2132,11 @@ function _bootstrapCrtModuleHandlerChainServices(type) {
1915
2132
  if (moduleDefinition.handlerChainServices) {
1916
2133
  registerHandlerChainServices(moduleDefinition.handlerChainServices);
1917
2134
  }
1918
- moduleDefinition.includes?.forEach((t) => _bootstrapCrtModuleHandlerChainServices(t));
2135
+ moduleDefinition.includes?.forEach((t) => {
2136
+ if (typeof t === 'function') {
2137
+ _bootstrapCrtModuleHandlerChainServices(t);
2138
+ }
2139
+ });
1919
2140
  }
1920
2141
  /**
1921
2142
  * @internal
@@ -1924,6 +2145,32 @@ function bootstrapCrtModuleHandlerChainServices(type) {
1924
2145
  _bootstrapCrtModuleHandlerChainServices(type);
1925
2146
  }
1926
2147
 
2148
+ /**
2149
+ * @internal
2150
+ * Clears global registries, resets state of global services.
2151
+ * Can be used in unit tests to clear global registries after bootstrapping module.
2152
+ * @example
2153
+ * beforeEach(() => {
2154
+ * bootstrapCrtModule('test', TestModule);
2155
+ * });
2156
+ *
2157
+ * afterEach(() => {
2158
+ * resetGlobals();
2159
+ * });
2160
+ */
2161
+ function resetGlobals() {
2162
+ ViewElementRegistry.viewElements.clear();
2163
+ InternalRequestHandlerRegistry.clear();
2164
+ HandlerChainService.instance.clear();
2165
+ ValidatorRegistry.items.clear();
2166
+ ConverterRegistry.clear();
2167
+ RemoteEntriesRegistry.items.clear();
2168
+ PkgTopology.items.clear();
2169
+ LazyModulesManager.instance.clear();
2170
+ LazyModulesManager.instance.lazyLoadingDisabled = false;
2171
+ DesignTimeViewElementRegistry.infos.clear();
2172
+ }
2173
+
1927
2174
  /**
1928
2175
  * @public
1929
2176
  * @abstract
@@ -2166,25 +2413,23 @@ __decorate([
2166
2413
  ], HttpClientService.prototype, "patch", null);
2167
2414
 
2168
2415
  /**
2169
- * @internal
2170
- */
2171
- var SchemaViewMaskRequestAction;
2172
- (function (SchemaViewMaskRequestAction) {
2173
- SchemaViewMaskRequestAction["AddTask"] = "addTask";
2174
- SchemaViewMaskRequestAction["RemoveTask"] = "removeTask";
2175
- })(SchemaViewMaskRequestAction || (SchemaViewMaskRequestAction = {}));
2176
- /**
2177
- * @internal
2416
+ * @public
2417
+ * @classdesc Represents a service to working with license restrictions.
2418
+ * @extends {BaseHandlerChainService}
2178
2419
  */
2179
- class SchemaViewMaskRequest extends ɵBaseRequest {
2180
- constructor(action, taskName, $context) {
2181
- super();
2182
- this.action = action;
2183
- this.taskName = taskName;
2184
- this.$context = $context;
2185
- this.type = 'crt.SchemaViewMaskRequest';
2420
+ class LicenseService extends BaseHandlerChainService {
2421
+ constructor() {
2422
+ super(...arguments);
2423
+ /**
2424
+ * @internal
2425
+ */
2426
+ this.requestType = 'crt.LicenseService';
2186
2427
  }
2187
2428
  }
2429
+ __decorate([
2430
+ ImplementUsingHandlerChain(),
2431
+ __metadata("design:type", Function)
2432
+ ], LicenseService.prototype, "loadLicenseOperationStatuses", void 0);
2188
2433
 
2189
2434
  /**
2190
2435
  * @public
@@ -2205,7 +2450,7 @@ class MaskService extends BaseHandlerChainService {
2205
2450
  * @param context
2206
2451
  */
2207
2452
  async showMask(taskName, context) {
2208
- const request = new SchemaViewMaskRequest(SchemaViewMaskRequestAction.AddTask, taskName, context);
2453
+ const request = new ɵSchemaViewMaskRequest(ɵSchemaViewMaskRequestAction.AddTask, taskName, context);
2209
2454
  await HandlerChainService.instance.process(request);
2210
2455
  }
2211
2456
  /**
@@ -2214,7 +2459,7 @@ class MaskService extends BaseHandlerChainService {
2214
2459
  * @param context
2215
2460
  */
2216
2461
  async hideMask(taskName, context) {
2217
- const request = new SchemaViewMaskRequest(SchemaViewMaskRequestAction.RemoveTask, taskName, context);
2462
+ const request = new ɵSchemaViewMaskRequest(ɵSchemaViewMaskRequestAction.RemoveTask, taskName, context);
2218
2463
  await HandlerChainService.instance.process(request);
2219
2464
  }
2220
2465
  }
@@ -2275,6 +2520,9 @@ class Model extends BaseHandlerChainService {
2275
2520
  return this._crtModel._getAsyncResult(this._crtModel.getSchema());
2276
2521
  }
2277
2522
  load(config) {
2523
+ if (config?.loadOptions && !config?.options) {
2524
+ config.options = config.loadOptions;
2525
+ }
2278
2526
  return this._crtModel._getAsyncResult(this._crtModel.load(config));
2279
2527
  }
2280
2528
  insert(dto) {
@@ -2329,5 +2577,5 @@ __decorate([
2329
2577
  * Generated bundle index. Do not edit.
2330
2578
  */
2331
2579
 
2332
- 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 };
2580
+ 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 };
2333
2581
  //# sourceMappingURL=creatio-devkit-common.mjs.map