@creatio-devkit/common 0.808.0 → 0.809.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 (31) hide show
  1. package/CHANGELOG.md +7 -5
  2. package/esm2020/lib/internal/enums/data-schema-type.enum.mjs +10 -0
  3. package/esm2020/lib/internal/enums/index.mjs +2 -1
  4. package/esm2020/lib/internal/models/interface-designer-item/toolbar-view-element-config.mjs +1 -1
  5. package/esm2020/lib/internal/models/request-handler/handler-source.mjs +1 -1
  6. package/esm2020/lib/internal/models/request-handler/request-handler-registration-config.model.mjs +1 -1
  7. package/esm2020/lib/internal/services/element-registration-checker/element-registration-checker.mjs +1 -1
  8. package/esm2020/lib/internal/services/handler-chain-services-registry/handler-chain-services-registry.mjs +3 -2
  9. package/esm2020/lib/internal/services/interface-designer-item-registry/interface-designer-item-registry.mjs +3 -2
  10. package/esm2020/lib/internal/utils/handlers-order-comparer.mjs +2 -2
  11. package/esm2020/lib/public/esq/data-model/enums/function-type.enum.mjs +5 -1
  12. package/esm2020/lib/public/esq/data-model/filters/between-filter.mjs +1 -1
  13. package/esm2020/lib/public/esq/data-model/filters/compare-filter.mjs +1 -1
  14. package/esm2020/lib/public/esq/data-model/filters/in-filter.mjs +1 -1
  15. package/esm2020/lib/public/esq/data-model/filters/isnull-filter.mjs +1 -1
  16. package/esm2020/lib/public/esq/data-model/filters/single-filter.mjs +1 -1
  17. package/esm2020/lib/public/handlers/base-request-handler.mjs +2 -2
  18. package/esm2020/lib/public/models/image-value.model.mjs +1 -1
  19. package/esm2020/lib/public/models/lookup-value.model.mjs +1 -1
  20. package/esm2020/lib/public/models/validation/crt-validator-fn.mjs +1 -1
  21. package/esm2020/lib/public/services/handler-chain/handler-chain.service.mjs +1 -1
  22. package/esm2020/lib/public/services/handler-chain/internal-handler-chain.mjs +4 -3
  23. package/esm2020/lib/public/services/model/data-schema.mjs +1 -1
  24. package/esm2020/lib/public/services/sys-values/sys-values.mjs +1 -1
  25. package/esm2020/lib/public/types/entity-column-value.mjs +1 -1
  26. package/fesm2015/creatio-devkit-common.mjs +412 -397
  27. package/fesm2015/creatio-devkit-common.mjs.map +1 -1
  28. package/fesm2020/creatio-devkit-common.mjs +404 -389
  29. package/fesm2020/creatio-devkit-common.mjs.map +1 -1
  30. package/index.d.ts +13 -1
  31. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
2
  import { Exclude, Expose, classToPlain } from 'class-transformer';
3
- import { upperFirst, camelCase, isEqual, get, set, cloneDeep } from 'lodash';
3
+ import { get, set, upperFirst, camelCase, isEqual, cloneDeep } from 'lodash';
4
4
  import 'reflect-metadata';
5
5
 
6
6
  var DataValueType;
@@ -189,6 +189,10 @@ var FunctionType;
189
189
  FunctionType[FunctionType["Length"] = 4] = "Length";
190
190
  /** Window query function */
191
191
  FunctionType[FunctionType["Window"] = 5] = "Window";
192
+ /** Date add. */
193
+ FunctionType[FunctionType["DateAdd"] = 6] = "DateAdd";
194
+ /** Date diff. */
195
+ FunctionType[FunctionType["DateDiff"] = 7] = "DateDiff";
192
196
  })(FunctionType || (FunctionType = {}));
193
197
 
194
198
  var OrderDirection;
@@ -1132,6 +1136,375 @@ const crtValidationInputPrefix = 'crtValidationInput:';
1132
1136
  */
1133
1137
  const crtInjectPrefix = 'crtInject:';
1134
1138
 
1139
+ /**
1140
+ * @internal
1141
+ */
1142
+ var ViewElementGroupType;
1143
+ (function (ViewElementGroupType) {
1144
+ ViewElementGroupType["Charts"] = "Charts";
1145
+ ViewElementGroupType["Components"] = "Components";
1146
+ ViewElementGroupType["LayoutElements"] = "LayoutElements";
1147
+ ViewElementGroupType["Inputs"] = "Inputs";
1148
+ ViewElementGroupType["CustomElements"] = "CustomElements";
1149
+ })(ViewElementGroupType || (ViewElementGroupType = {}));
1150
+
1151
+ /**
1152
+ * @internal
1153
+ */
1154
+ var ViewElementDataGroupType;
1155
+ (function (ViewElementDataGroupType) {
1156
+ ViewElementDataGroupType["Data"] = "Data";
1157
+ })(ViewElementDataGroupType || (ViewElementDataGroupType = {}));
1158
+ /**
1159
+ * @internal
1160
+ */
1161
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1162
+ const DesignerToolGroupType = { ...ViewElementDataGroupType, ...ViewElementGroupType };
1163
+
1164
+ /**
1165
+ * @internal
1166
+ */
1167
+ var DataSourceScope;
1168
+ (function (DataSourceScope) {
1169
+ DataSourceScope["ViewElement"] = "viewElement";
1170
+ DataSourceScope["Page"] = "page";
1171
+ })(DataSourceScope || (DataSourceScope = {}));
1172
+
1173
+ /**
1174
+ * @internal
1175
+ */
1176
+ var ModelInPageAction;
1177
+ (function (ModelInPageAction) {
1178
+ ModelInPageAction["Edit"] = "edit";
1179
+ ModelInPageAction["Add"] = "add";
1180
+ ModelInPageAction["Copy"] = "copy";
1181
+ })(ModelInPageAction || (ModelInPageAction = {}));
1182
+
1183
+ /**
1184
+ * Handler source types in order of call priority.
1185
+ * @internal
1186
+ */
1187
+ var HandlerSourceType;
1188
+ (function (HandlerSourceType) {
1189
+ HandlerSourceType[HandlerSourceType["Schema"] = 0] = "Schema";
1190
+ HandlerSourceType[HandlerSourceType["Remote"] = 1] = "Remote";
1191
+ HandlerSourceType[HandlerSourceType["Host"] = 2] = "Host";
1192
+ })(HandlerSourceType || (HandlerSourceType = {}));
1193
+
1194
+ /**
1195
+ * @internal
1196
+ */
1197
+ var DataSchemaAttributeType;
1198
+ (function (DataSchemaAttributeType) {
1199
+ DataSchemaAttributeType["OwnAttribute"] = "Own";
1200
+ DataSchemaAttributeType["ForwardReferenceAttribute"] = "ForwardReference";
1201
+ DataSchemaAttributeType["BackReferenceAttribute"] = "BackReference";
1202
+ DataSchemaAttributeType["AggregationAttribute"] = "Aggregation";
1203
+ DataSchemaAttributeType["FunctionAttribute"] = "Function";
1204
+ })(DataSchemaAttributeType || (DataSchemaAttributeType = {}));
1205
+ /**
1206
+ * @internal
1207
+ */
1208
+ var DataSchemaAttributeUsageType;
1209
+ (function (DataSchemaAttributeUsageType) {
1210
+ DataSchemaAttributeUsageType[DataSchemaAttributeUsageType["General"] = 0] = "General";
1211
+ DataSchemaAttributeUsageType[DataSchemaAttributeUsageType["Advanced"] = 1] = "Advanced";
1212
+ DataSchemaAttributeUsageType[DataSchemaAttributeUsageType["None"] = 2] = "None";
1213
+ })(DataSchemaAttributeUsageType || (DataSchemaAttributeUsageType = {}));
1214
+
1215
+ /**
1216
+ * Type of DataSchema. In combination with the name is used for unique identification of {@link DataSchema}.
1217
+ * @internal
1218
+ */
1219
+ var DataSchemaType;
1220
+ (function (DataSchemaType) {
1221
+ DataSchemaType["Entity"] = "Entity";
1222
+ DataSchemaType["ClientUnit"] = "ClientUnit";
1223
+ })(DataSchemaType || (DataSchemaType = {}));
1224
+
1225
+ /**
1226
+ * @internal
1227
+ */
1228
+ var DefaultValueSource;
1229
+ (function (DefaultValueSource) {
1230
+ DefaultValueSource[DefaultValueSource["None"] = 0] = "None";
1231
+ DefaultValueSource[DefaultValueSource["Const"] = 1] = "Const";
1232
+ DefaultValueSource[DefaultValueSource["Settings"] = 2] = "Settings";
1233
+ DefaultValueSource[DefaultValueSource["SystemValue"] = 3] = "SystemValue";
1234
+ DefaultValueSource[DefaultValueSource["Sequence"] = 4] = "Sequence";
1235
+ })(DefaultValueSource || (DefaultValueSource = {}));
1236
+
1237
+ const global$3 = window;
1238
+ /**
1239
+ * @internal
1240
+ */
1241
+ class BaseRegistry {
1242
+ constructor() {
1243
+ this.store = {
1244
+ typeInfos: new Map(),
1245
+ };
1246
+ }
1247
+ static get store() {
1248
+ if (!this._instance) {
1249
+ let globalInstance = get(global$3, this._prefix + this.registryKey);
1250
+ if (!globalInstance) {
1251
+ globalInstance = new this();
1252
+ set(global$3, this._prefix + this.registryKey, globalInstance);
1253
+ }
1254
+ this._instance = globalInstance;
1255
+ }
1256
+ return this._instance.store;
1257
+ }
1258
+ }
1259
+ BaseRegistry._prefix = 'creatio.registry.';
1260
+
1261
+ /**
1262
+ * @internal
1263
+ */
1264
+ class PkgTopology extends BaseRegistry {
1265
+ static get items() {
1266
+ return this.store.typeInfos;
1267
+ }
1268
+ static get(pkgName) {
1269
+ const order = this.items.get(pkgName);
1270
+ if (order === undefined) {
1271
+ throw new Error(`Package with name ${pkgName} not found in topology`);
1272
+ }
1273
+ return order;
1274
+ }
1275
+ }
1276
+ PkgTopology.registryKey = 'pkgTopology';
1277
+
1278
+ /**
1279
+ * @internal
1280
+ */
1281
+ class HandlersOrderComparer {
1282
+ constructor(_request) {
1283
+ this._request = _request;
1284
+ const scopesOrderEntries = [...(this._request.scopes ?? [])].reverse().map((scope, index) => [scope, index]);
1285
+ this._scopesOrder = Object.fromEntries(scopesOrderEntries);
1286
+ }
1287
+ _getOrderByScopes(handler) {
1288
+ if (!handler.scopes) {
1289
+ return Number.MAX_VALUE;
1290
+ }
1291
+ const scopesOrder = handler.scopes.filter((s) => s in this._scopesOrder).map((s) => this._scopesOrder[s]);
1292
+ return Math.min(...scopesOrder);
1293
+ }
1294
+ _getOrderByPkgTopology(handler) {
1295
+ if (handler.source.type === HandlerSourceType.Host) {
1296
+ return Number.MAX_VALUE;
1297
+ }
1298
+ return PkgTopology.get(handler.source.packageName);
1299
+ }
1300
+ compare(a, b) {
1301
+ const aScopeOrder = this._getOrderByScopes(a);
1302
+ const bScopeOrder = this._getOrderByScopes(b);
1303
+ let diff = aScopeOrder - bScopeOrder;
1304
+ if (diff) {
1305
+ return diff;
1306
+ }
1307
+ const aPkgTopologyOrder = this._getOrderByPkgTopology(a);
1308
+ const bPkgTopologyOrder = this._getOrderByPkgTopology(b);
1309
+ diff = aPkgTopologyOrder - bPkgTopologyOrder;
1310
+ if (diff) {
1311
+ return diff;
1312
+ }
1313
+ diff = a.source.type - b.source.type;
1314
+ return diff;
1315
+ }
1316
+ }
1317
+
1318
+ /**
1319
+ * @internal
1320
+ */
1321
+ class InternalHandlerChain {
1322
+ constructor() {
1323
+ this._handlers = [];
1324
+ this._handlersCache = new Map();
1325
+ this._handlersScopesByContextId = new Map();
1326
+ this.handlerChain$ = {
1327
+ process: async (request) => {
1328
+ const handler = this._getHandler(request);
1329
+ return handler?.handle(request);
1330
+ },
1331
+ register: (info) => {
1332
+ this._handlersCache.delete(info.requestType);
1333
+ this._handlers.push(info);
1334
+ return () => {
1335
+ const index = this._handlers.indexOf(info);
1336
+ if (index > -1) {
1337
+ this._handlers.splice(index, 1);
1338
+ this._handlersCache.delete(info.requestType);
1339
+ }
1340
+ else {
1341
+ console.warn(`${info?.requestType} not found to unsubscribe`);
1342
+ }
1343
+ };
1344
+ },
1345
+ };
1346
+ }
1347
+ clearContextedHandlersCache(contextId) {
1348
+ const configs = this._handlersScopesByContextId.get(contextId) ?? [];
1349
+ return configs.every(({ requestType, scope }) => this._handlersCache.get(requestType)?.delete(scope));
1350
+ }
1351
+ _getHandler(request) {
1352
+ return this._hasCacheHandler(request) ? this._getCacheHandler(request) : this._buildHandlersChain(request);
1353
+ }
1354
+ _getCacheHandler(request) {
1355
+ const map = this._handlersCache.get(request.type);
1356
+ const key = this._getCacheScopesKey(request);
1357
+ return map.get(key);
1358
+ }
1359
+ _hasCacheHandler(request) {
1360
+ const map = this._handlersCache.get(request.type);
1361
+ const key = this._getCacheScopesKey(request);
1362
+ return map && map.has(key);
1363
+ }
1364
+ _getCacheScopesKey(request) {
1365
+ const injectionContextKey = this._getInjectionContext(request?.$context)?.id ?? '';
1366
+ return (request.scopes || ['']).join('_').concat(injectionContextKey);
1367
+ }
1368
+ _getInjectionContext(viewModel) {
1369
+ return (viewModel?.['_injectionContext'] ||
1370
+ (viewModel?.['parent'] && this._getInjectionContext(viewModel['parent'])));
1371
+ }
1372
+ _setContextedScopes(request, scope) {
1373
+ const injectionContext = this._getInjectionContext(request?.$context)?.id;
1374
+ const configs = this._handlersScopesByContextId.has(injectionContext)
1375
+ ? this._handlersScopesByContextId.get(injectionContext)
1376
+ : [];
1377
+ configs.push({ requestType: request.type, scope });
1378
+ this._handlersScopesByContextId.set(injectionContext, configs);
1379
+ }
1380
+ _setCacheHandler(request, handler) {
1381
+ const map = this._handlersCache.has(request.type)
1382
+ ? this._handlersCache.get(request.type)
1383
+ : new Map();
1384
+ const key = this._getCacheScopesKey(request);
1385
+ map.set(key, handler);
1386
+ if (this._getInjectionContext(request?.$context)?.id) {
1387
+ this._setContextedScopes(request, key);
1388
+ }
1389
+ this._handlersCache.set(request.type, map);
1390
+ }
1391
+ _isRequestHandler(handler) {
1392
+ return (typeof handler.handle === 'function' &&
1393
+ typeof handler.setNext === 'function');
1394
+ }
1395
+ _checkHandlerInstanceOf(handler) {
1396
+ if (!this._isRequestHandler(handler)) {
1397
+ throw new Error('Handler should implement "BaseRequestHandler"');
1398
+ }
1399
+ }
1400
+ _buildHandlersChain(request) {
1401
+ const handlers = this._handlers.filter((h) => {
1402
+ if (h.requestType !== request.type) {
1403
+ return false;
1404
+ }
1405
+ if (!h.scopes?.length) {
1406
+ return true;
1407
+ }
1408
+ return h.scopes.some((s) => request.scopes?.includes(s));
1409
+ });
1410
+ const comparer = new HandlersOrderComparer(request);
1411
+ handlers.sort((a, b) => comparer.compare(a, b));
1412
+ const handlerInstances = handlers.map((handlerConfig) => {
1413
+ const injectionContext = this._getInjectionContext(request?.$context);
1414
+ return handlerConfig.createHandler(injectionContext);
1415
+ });
1416
+ handlerInstances.forEach((handler) => this._checkHandlerInstanceOf(handler));
1417
+ this._joinHandlersInChain(handlerInstances);
1418
+ const result = handlerInstances[0];
1419
+ this._setCacheHandler(request, result);
1420
+ return result;
1421
+ }
1422
+ _joinHandlersInChain(handlers) {
1423
+ for (let index = 0; index < handlers.length - 1; index++) {
1424
+ try {
1425
+ handlers[index].setNext(handlers[index + 1]);
1426
+ }
1427
+ catch (error) {
1428
+ if (error instanceof NextHandlerAlreadySpecifiedException) {
1429
+ throw new Error('Handler factory should return new instance of ' +
1430
+ 'BaseRequestHandler class or its subclass ' +
1431
+ '(next handler should not be specified)');
1432
+ }
1433
+ throw error;
1434
+ }
1435
+ }
1436
+ }
1437
+ }
1438
+
1439
+ const global$2 = window;
1440
+ /**
1441
+ * @public
1442
+ * @class HandlerChainService
1443
+ * @classdesc Service to design handlers in chain.
1444
+ */
1445
+ class HandlerChainService {
1446
+ constructor() {
1447
+ if (!this._chain) {
1448
+ this._createGlobalHandlerChain();
1449
+ }
1450
+ }
1451
+ get _chain() {
1452
+ return global$2.handlerChain;
1453
+ }
1454
+ set _chain(value) {
1455
+ global$2.handlerChain = value;
1456
+ }
1457
+ static get instance() {
1458
+ return HandlerChainService._instance || (HandlerChainService._instance = new HandlerChainService());
1459
+ }
1460
+ _createGlobalHandlerChain() {
1461
+ this._chain = new InternalHandlerChain();
1462
+ }
1463
+ /**
1464
+ * @internal
1465
+ */
1466
+ clearContextedHandlersCache(contextId) {
1467
+ return this._chain.clearContextedHandlersCache(contextId);
1468
+ }
1469
+ /**
1470
+ * @internal
1471
+ */
1472
+ register(handlerConfig) {
1473
+ return this._chain.handlerChain$.register(handlerConfig);
1474
+ }
1475
+ /**
1476
+ * @description Method to process passed request
1477
+ * @param request - {@link BaseRequest}
1478
+ * @return `Promise<unknown>`
1479
+ */
1480
+ process(request) {
1481
+ return this._chain.handlerChain$.process(request);
1482
+ }
1483
+ }
1484
+
1485
+ /**
1486
+ * @internal
1487
+ */
1488
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1489
+ function ImplementUsingHandlerChain(config) {
1490
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1491
+ return function (target, method, descriptor) {
1492
+ const methodImplementation = function (...args) {
1493
+ return HandlerChainService.instance.process({
1494
+ type: config?.requestType ? config.requestType : this.requestType,
1495
+ method: config?.methodName ? config.methodName : method,
1496
+ args,
1497
+ });
1498
+ };
1499
+ if (descriptor) {
1500
+ descriptor.value = methodImplementation;
1501
+ }
1502
+ else {
1503
+ target[method] = methodImplementation;
1504
+ }
1505
+ };
1506
+ }
1507
+
1135
1508
  /**
1136
1509
  * @internal
1137
1510
  */
@@ -1237,10 +1610,10 @@ class InternalRequestHandlerRegistryType {
1237
1610
  InternalRequestHandlerRegistryType._addItemListeners = [];
1238
1611
  InternalRequestHandlerRegistryType._removeItemListeners = [];
1239
1612
  InternalRequestHandlerRegistryType._requestHandlersMap = new Map();
1240
- const global$3 = window;
1241
- global$3.creatio ?? (global$3.creatio = {});
1242
- if (!global$3.creatio.requestHandlerRegistry) {
1243
- Object.defineProperty(global$3.creatio, 'requestHandlerRegistry', {
1613
+ const global$1 = window;
1614
+ global$1.creatio ?? (global$1.creatio = {});
1615
+ if (!global$1.creatio.requestHandlerRegistry) {
1616
+ Object.defineProperty(global$1.creatio, 'requestHandlerRegistry', {
1244
1617
  get: () => InternalRequestHandlerRegistryType,
1245
1618
  configurable: false,
1246
1619
  });
@@ -1272,7 +1645,7 @@ class RequestHandlerRegistryService {
1272
1645
  RequestHandlerRegistryService._internalRegistry.addRequestHandler(requestHandlerType, requestHandlerMapValue);
1273
1646
  }
1274
1647
  }
1275
- RequestHandlerRegistryService._internalRegistry = global$3.creatio.requestHandlerRegistry;
1648
+ RequestHandlerRegistryService._internalRegistry = global$1.creatio.requestHandlerRegistry;
1276
1649
 
1277
1650
  /**
1278
1651
  * @internal
@@ -1306,30 +1679,6 @@ class RequestRegistryService {
1306
1679
  RequestRegistryService._requestsMap = new Map();
1307
1680
  RequestRegistryService._requestsRegistrationInfos = new Map();
1308
1681
 
1309
- const global$2 = window;
1310
- /**
1311
- * @internal
1312
- */
1313
- class BaseRegistry {
1314
- constructor() {
1315
- this.store = {
1316
- typeInfos: new Map(),
1317
- };
1318
- }
1319
- static get store() {
1320
- if (!this._instance) {
1321
- let globalInstance = get(global$2, this._prefix + this.registryKey);
1322
- if (!globalInstance) {
1323
- globalInstance = new this();
1324
- set(global$2, this._prefix + this.registryKey, globalInstance);
1325
- }
1326
- this._instance = globalInstance;
1327
- }
1328
- return this._instance.store;
1329
- }
1330
- }
1331
- BaseRegistry._prefix = 'creatio.registry.';
1332
-
1333
1682
  /**
1334
1683
  * @internal
1335
1684
  */
@@ -1402,7 +1751,7 @@ class InterfaceDesignerItemRegistry extends BaseRegistry {
1402
1751
  }
1403
1752
  InterfaceDesignerItemRegistry.registryKey = interfaceDesignerItemRegistryKey;
1404
1753
 
1405
- const global$1 = window;
1754
+ const global = window;
1406
1755
  /**
1407
1756
  * @internal
1408
1757
  */
@@ -1411,10 +1760,10 @@ class BootstrapNotifier {
1411
1760
  this._subscribers = new Set();
1412
1761
  }
1413
1762
  static get instance() {
1414
- if (!global$1.__crtModuleBootstrapNotifier) {
1415
- global$1.__crtModuleBootstrapNotifier = new BootstrapNotifier();
1763
+ if (!global.__crtModuleBootstrapNotifier) {
1764
+ global.__crtModuleBootstrapNotifier = new BootstrapNotifier();
1416
1765
  }
1417
- return global$1.__crtModuleBootstrapNotifier;
1766
+ return global.__crtModuleBootstrapNotifier;
1418
1767
  }
1419
1768
  notify(moduleType) {
1420
1769
  for (const subscriber of this._subscribers.values()) {
@@ -1509,181 +1858,36 @@ class ValidatorRegistry extends BaseRegistry {
1509
1858
  }
1510
1859
  static register(config) {
1511
1860
  this.items.set(config.type, config);
1512
- }
1513
- }
1514
- ValidatorRegistry.registryKey = validatorRegistryKey;
1515
-
1516
- /**
1517
- * @internal
1518
- */
1519
- class PkgTopology extends BaseRegistry {
1520
- static get items() {
1521
- return this.store.typeInfos;
1522
- }
1523
- static get(pkgName) {
1524
- const order = this.items.get(pkgName);
1525
- if (order === undefined) {
1526
- throw new Error(`Package with name ${pkgName} not found in topology`);
1527
- }
1528
- return order;
1529
- }
1530
- }
1531
- PkgTopology.registryKey = 'pkgTopology';
1532
-
1533
- /**
1534
- * @internal
1535
- * @dontChange
1536
- */
1537
- class RemoteEntriesRegistry extends BaseRegistry {
1538
- /**
1539
- * @dontChange
1540
- */
1541
- static get items() {
1542
- return this.store.typeInfos;
1543
- }
1544
- }
1545
- /**
1546
- * @dontChange
1547
- */
1548
- RemoteEntriesRegistry.registryKey = 'remotes';
1549
-
1550
- /**
1551
- * @internal
1552
- */
1553
- function isComponentPropertyBindable(viewConfigType, componentProperty) {
1554
- const componentConfig = ViewElementRegistry.viewElements.get(viewConfigType);
1555
- if (!componentConfig?.inputs) {
1556
- return false;
1557
- }
1558
- return !!componentConfig?.inputs[componentProperty]?.propertyBindable;
1559
- }
1560
-
1561
- /**
1562
- * @internal
1563
- */
1564
- var ViewElementGroupType;
1565
- (function (ViewElementGroupType) {
1566
- ViewElementGroupType["Charts"] = "Charts";
1567
- ViewElementGroupType["Components"] = "Components";
1568
- ViewElementGroupType["LayoutElements"] = "LayoutElements";
1569
- ViewElementGroupType["Inputs"] = "Inputs";
1570
- ViewElementGroupType["CustomElements"] = "CustomElements";
1571
- })(ViewElementGroupType || (ViewElementGroupType = {}));
1572
-
1573
- /**
1574
- * @internal
1575
- */
1576
- var ViewElementDataGroupType;
1577
- (function (ViewElementDataGroupType) {
1578
- ViewElementDataGroupType["Data"] = "Data";
1579
- })(ViewElementDataGroupType || (ViewElementDataGroupType = {}));
1580
- /**
1581
- * @internal
1582
- */
1583
- // eslint-disable-next-line @typescript-eslint/naming-convention
1584
- const DesignerToolGroupType = { ...ViewElementDataGroupType, ...ViewElementGroupType };
1585
-
1586
- /**
1587
- * @internal
1588
- */
1589
- var DataSourceScope;
1590
- (function (DataSourceScope) {
1591
- DataSourceScope["ViewElement"] = "viewElement";
1592
- DataSourceScope["Page"] = "page";
1593
- })(DataSourceScope || (DataSourceScope = {}));
1594
-
1595
- /**
1596
- * @internal
1597
- */
1598
- var ModelInPageAction;
1599
- (function (ModelInPageAction) {
1600
- ModelInPageAction["Edit"] = "edit";
1601
- ModelInPageAction["Add"] = "add";
1602
- ModelInPageAction["Copy"] = "copy";
1603
- })(ModelInPageAction || (ModelInPageAction = {}));
1604
-
1605
- /**
1606
- * Handler source types in order of call priority.
1607
- * @internal
1608
- */
1609
- var HandlerSourceType;
1610
- (function (HandlerSourceType) {
1611
- HandlerSourceType[HandlerSourceType["Schema"] = 0] = "Schema";
1612
- HandlerSourceType[HandlerSourceType["Remote"] = 1] = "Remote";
1613
- HandlerSourceType[HandlerSourceType["Host"] = 2] = "Host";
1614
- })(HandlerSourceType || (HandlerSourceType = {}));
1615
-
1616
- /**
1617
- * @internal
1618
- */
1619
- var DataSchemaAttributeType;
1620
- (function (DataSchemaAttributeType) {
1621
- DataSchemaAttributeType["OwnAttribute"] = "Own";
1622
- DataSchemaAttributeType["ForwardReferenceAttribute"] = "ForwardReference";
1623
- DataSchemaAttributeType["BackReferenceAttribute"] = "BackReference";
1624
- DataSchemaAttributeType["AggregationAttribute"] = "Aggregation";
1625
- DataSchemaAttributeType["FunctionAttribute"] = "Function";
1626
- })(DataSchemaAttributeType || (DataSchemaAttributeType = {}));
1861
+ }
1862
+ }
1863
+ ValidatorRegistry.registryKey = validatorRegistryKey;
1864
+
1627
1865
  /**
1628
1866
  * @internal
1867
+ * @dontChange
1629
1868
  */
1630
- var DataSchemaAttributeUsageType;
1631
- (function (DataSchemaAttributeUsageType) {
1632
- DataSchemaAttributeUsageType[DataSchemaAttributeUsageType["General"] = 0] = "General";
1633
- DataSchemaAttributeUsageType[DataSchemaAttributeUsageType["Advanced"] = 1] = "Advanced";
1634
- DataSchemaAttributeUsageType[DataSchemaAttributeUsageType["None"] = 2] = "None";
1635
- })(DataSchemaAttributeUsageType || (DataSchemaAttributeUsageType = {}));
1636
-
1869
+ class RemoteEntriesRegistry extends BaseRegistry {
1870
+ /**
1871
+ * @dontChange
1872
+ */
1873
+ static get items() {
1874
+ return this.store.typeInfos;
1875
+ }
1876
+ }
1637
1877
  /**
1638
- * @internal
1878
+ * @dontChange
1639
1879
  */
1640
- var DefaultValueSource;
1641
- (function (DefaultValueSource) {
1642
- DefaultValueSource[DefaultValueSource["None"] = 0] = "None";
1643
- DefaultValueSource[DefaultValueSource["Const"] = 1] = "Const";
1644
- DefaultValueSource[DefaultValueSource["Settings"] = 2] = "Settings";
1645
- DefaultValueSource[DefaultValueSource["SystemValue"] = 3] = "SystemValue";
1646
- DefaultValueSource[DefaultValueSource["Sequence"] = 4] = "Sequence";
1647
- })(DefaultValueSource || (DefaultValueSource = {}));
1880
+ RemoteEntriesRegistry.registryKey = 'remotes';
1648
1881
 
1649
1882
  /**
1650
1883
  * @internal
1651
1884
  */
1652
- class HandlersOrderComparer {
1653
- constructor(_request) {
1654
- this._request = _request;
1655
- const scopesOrderEntries = [...(this._request.scopes ?? [])].reverse().map((scope, index) => [scope, index]);
1656
- this._scopesOrder = Object.fromEntries(scopesOrderEntries);
1657
- }
1658
- _getOrderByScopes(handler) {
1659
- if (!handler.scopes) {
1660
- return Number.MAX_VALUE;
1661
- }
1662
- const scopesOrder = handler.scopes.filter((s) => s in this._scopesOrder).map((s) => this._scopesOrder[s]);
1663
- return Math.min(...scopesOrder);
1664
- }
1665
- _getOrderByPkgTopology(handler) {
1666
- if (handler.source.type === HandlerSourceType.Host) {
1667
- return Number.MAX_VALUE;
1668
- }
1669
- return PkgTopology.get(handler.source.packageName);
1670
- }
1671
- compare(a, b) {
1672
- const aScopeOrder = this._getOrderByScopes(a);
1673
- const bScopeOrder = this._getOrderByScopes(b);
1674
- let diff = aScopeOrder - bScopeOrder;
1675
- if (diff) {
1676
- return diff;
1677
- }
1678
- const aPkgTopologyOrder = this._getOrderByPkgTopology(a);
1679
- const bPkgTopologyOrder = this._getOrderByPkgTopology(b);
1680
- diff = aPkgTopologyOrder - bPkgTopologyOrder;
1681
- if (diff) {
1682
- return diff;
1683
- }
1684
- diff = a.source.type - b.source.type;
1685
- return diff;
1885
+ function isComponentPropertyBindable(viewConfigType, componentProperty) {
1886
+ const componentConfig = ViewElementRegistry.viewElements.get(viewConfigType);
1887
+ if (!componentConfig?.inputs) {
1888
+ return false;
1686
1889
  }
1890
+ return !!componentConfig?.inputs[componentProperty]?.propertyBindable;
1687
1891
  }
1688
1892
 
1689
1893
  const moduleMetadataKey = 'module';
@@ -2021,195 +2225,6 @@ function applyLocalizeMetadataFn(obj, localizeMetadata) {
2021
2225
  return localized;
2022
2226
  }
2023
2227
 
2024
- /**
2025
- * @internal
2026
- */
2027
- class InternalHandlerChain {
2028
- constructor() {
2029
- this._handlers = [];
2030
- this._handlersCache = new Map();
2031
- this._handlersScopesByContextId = new Map();
2032
- this.handlerChain$ = {
2033
- process: async (request) => {
2034
- const handler = this._getHandler(request);
2035
- return handler?.handle(request);
2036
- },
2037
- register: (info) => {
2038
- this._handlersCache.delete(info.requestType);
2039
- this._handlers.push(info);
2040
- return () => {
2041
- const index = this._handlers.indexOf(info);
2042
- if (index > -1) {
2043
- this._handlers.splice(index, 1);
2044
- this._handlersCache.delete(info.requestType);
2045
- }
2046
- else {
2047
- console.warn(`${info?.requestType} not found to unsubscribe`);
2048
- }
2049
- };
2050
- },
2051
- };
2052
- }
2053
- clearContextedHandlersCache(contextId) {
2054
- const configs = this._handlersScopesByContextId.get(contextId) ?? [];
2055
- return configs.every(({ requestType, scope }) => this._handlersCache.get(requestType)?.delete(scope));
2056
- }
2057
- _getHandler(request) {
2058
- return this._hasCacheHandler(request) ? this._getCacheHandler(request) : this._buildHandlersChain(request);
2059
- }
2060
- _getCacheHandler(request) {
2061
- const map = this._handlersCache.get(request.type);
2062
- const key = this._getCacheScopesKey(request);
2063
- return map.get(key);
2064
- }
2065
- _hasCacheHandler(request) {
2066
- const map = this._handlersCache.get(request.type);
2067
- const key = this._getCacheScopesKey(request);
2068
- return map && map.has(key);
2069
- }
2070
- _getCacheScopesKey(request) {
2071
- const injectionContextKey = this._getInjectionContext(request?.$context)?.id ?? '';
2072
- return (request.scopes || ['']).join('_').concat(injectionContextKey);
2073
- }
2074
- _getInjectionContext(viewModel) {
2075
- return viewModel?.['_injectionContext'] || (viewModel?.parent && this._getInjectionContext(viewModel.parent));
2076
- }
2077
- _setContextedScopes(request, scope) {
2078
- const injectionContext = this._getInjectionContext(request?.$context)?.id;
2079
- const configs = this._handlersScopesByContextId.has(injectionContext)
2080
- ? this._handlersScopesByContextId.get(injectionContext)
2081
- : [];
2082
- configs.push({ requestType: request.type, scope });
2083
- this._handlersScopesByContextId.set(injectionContext, configs);
2084
- }
2085
- _setCacheHandler(request, handler) {
2086
- const map = this._handlersCache.has(request.type)
2087
- ? this._handlersCache.get(request.type)
2088
- : new Map();
2089
- const key = this._getCacheScopesKey(request);
2090
- map.set(key, handler);
2091
- if (this._getInjectionContext(request?.$context)?.id) {
2092
- this._setContextedScopes(request, key);
2093
- }
2094
- this._handlersCache.set(request.type, map);
2095
- }
2096
- _isRequestHandler(handler) {
2097
- return (typeof handler.handle === 'function' &&
2098
- typeof handler.setNext === 'function');
2099
- }
2100
- _checkHandlerInstanceOf(handler) {
2101
- if (!this._isRequestHandler(handler)) {
2102
- throw new Error('Handler should implement "BaseRequestHandler"');
2103
- }
2104
- }
2105
- _buildHandlersChain(request) {
2106
- const handlers = this._handlers.filter((h) => {
2107
- if (h.requestType !== request.type) {
2108
- return false;
2109
- }
2110
- if (!h.scopes?.length) {
2111
- return true;
2112
- }
2113
- return h.scopes.some((s) => request.scopes?.includes(s));
2114
- });
2115
- const comparer = new HandlersOrderComparer(request);
2116
- handlers.sort((a, b) => comparer.compare(a, b));
2117
- const handlerInstances = handlers.map((handlerConfig) => {
2118
- const injectionContext = this._getInjectionContext(request?.$context);
2119
- return handlerConfig.createHandler(injectionContext);
2120
- });
2121
- handlerInstances.forEach((handler) => this._checkHandlerInstanceOf(handler));
2122
- this._joinHandlersInChain(handlerInstances);
2123
- const result = handlerInstances[0];
2124
- this._setCacheHandler(request, result);
2125
- return result;
2126
- }
2127
- _joinHandlersInChain(handlers) {
2128
- for (let index = 0; index < handlers.length - 1; index++) {
2129
- try {
2130
- handlers[index].setNext(handlers[index + 1]);
2131
- }
2132
- catch (error) {
2133
- if (error instanceof NextHandlerAlreadySpecifiedException) {
2134
- throw new Error('Handler factory should return new instance of ' +
2135
- 'BaseRequestHandler class or its subclass ' +
2136
- '(next handler should not be specified)');
2137
- }
2138
- throw error;
2139
- }
2140
- }
2141
- }
2142
- }
2143
-
2144
- const global = window;
2145
- /**
2146
- * @public
2147
- * @class HandlerChainService
2148
- * @classdesc Service to design handlers in chain.
2149
- */
2150
- class HandlerChainService {
2151
- constructor() {
2152
- if (!this._chain) {
2153
- this._createGlobalHandlerChain();
2154
- }
2155
- }
2156
- get _chain() {
2157
- return global.handlerChain;
2158
- }
2159
- set _chain(value) {
2160
- global.handlerChain = value;
2161
- }
2162
- static get instance() {
2163
- return HandlerChainService._instance || (HandlerChainService._instance = new HandlerChainService());
2164
- }
2165
- _createGlobalHandlerChain() {
2166
- this._chain = new InternalHandlerChain();
2167
- }
2168
- /**
2169
- * @internal
2170
- */
2171
- clearContextedHandlersCache(contextId) {
2172
- return this._chain.clearContextedHandlersCache(contextId);
2173
- }
2174
- /**
2175
- * @internal
2176
- */
2177
- register(handlerConfig) {
2178
- return this._chain.handlerChain$.register(handlerConfig);
2179
- }
2180
- /**
2181
- * @description Method to process passed request
2182
- * @param request - {@link BaseRequest}
2183
- * @return `Promise<unknown>`
2184
- */
2185
- process(request) {
2186
- return this._chain.handlerChain$.process(request);
2187
- }
2188
- }
2189
-
2190
- /**
2191
- * @internal
2192
- */
2193
- // eslint-disable-next-line @typescript-eslint/naming-convention
2194
- function ImplementUsingHandlerChain(config) {
2195
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2196
- return function (target, method, descriptor) {
2197
- const methodImplementation = function (...args) {
2198
- return HandlerChainService.instance.process({
2199
- type: config?.requestType ? config.requestType : this.requestType,
2200
- method: config?.methodName ? config.methodName : method,
2201
- args,
2202
- });
2203
- };
2204
- if (descriptor) {
2205
- descriptor.value = methodImplementation;
2206
- }
2207
- else {
2208
- target[method] = methodImplementation;
2209
- }
2210
- };
2211
- }
2212
-
2213
2228
  /**
2214
2229
  * @internal
2215
2230
  */
@@ -3432,5 +3447,5 @@ var ModelParameterType;
3432
3447
  * Generated bundle index. Do not edit.
3433
3448
  */
3434
3449
 
3435
- export { AggregationEvalType, AggregationFunction, AggregationFunctionColumn, AggregationFunctionExpression, AggregationSubQueryColumn, AggregationSubQueryExpression, AggregationType, ArgumentEmptyException, ArgumentFunctionExpression, ArgumentOutOfRangeException, ArithmeticExpression, ArithmeticOperation, ArithmeticQueryColumn, BaseExpression, BaseFilter, BaseFilterableQuery, BaseQuery, BaseQueryColumn, BaseRegistry, BaseRequest, BaseRequestHandler, BaseValidator, BetweenFilter, BootstrapNotifier, ColumnExpression, CompareFilter, ComparisonType, ConverterRegistry, CrtConverter, CrtDesignTimeViewElement, CrtInject, CrtInput, CrtInputRegistrationConfig, CrtInterfaceDesignerItem, CrtModule, CrtOutput, CrtRequest, CrtRequestHandler, CrtValidationInput, CrtValidator, CrtViewElement, DataRequest, DataSchemaAttributeType, DataSchemaAttributeUsageType, DataSourceScope, DataValueType, DatePartFunctionColumn, DatePartFunctionExpression, DatePartType, DefaultValueSource, DeleteQuery, DesignTimeViewElementRegistry, DesignerToolGroupType, EMPTY_GUID, EXPRESSION_TYPE_MOCK, EntityQueryColumn, EntitySchemaQuery, ExistsFilter, ExpressionMock, ExpressionType, FeatureService, FilterGroup, FilterMock, FilterType, FunctionExpression, FunctionType, HandlerChainService, HandlerChainServicesRegistry, HandlerSourceType, HandlersOrderComparer, HttpClientService, ImplementUsingHandlerChain, InFilter, InsertQuery, InterfaceDesignerItemRegistrationConfig, InterfaceDesignerItemRegistry, InternalRequestHandlerRegistry, InternalRequestHandlerRegistryType, IsNullFilter, ItemNotFoundException, LengthFunctionColumn, LengthFunctionExpression, LocalizableValue, LogicalOperatorType, MacrosFunctionColumn, MacrosFunctionExpression, MaskService, MethodInvokeRequest, Model, ModelInPageAction, ModelParameterType, NextHandlerAlreadySpecifiedException, OrderDirection, ParameterExpression, ParameterQueryColumn, PkgTopology, QueryMacrosType, QueryOperationType, RemoteEntriesRegistry, RemoteEntryType, RequestHandlerRegistryService, RequestRegistryService, RightsService, SchemaViewMaskRequest, SchemaViewMaskRequestAction, SelectLocalizationQuery, SingleFilter, SubQueryColumn, SubQueryExpression, SysSetting, SysSettingValue, SysSettingsService, SysValuesService, UpdateQuery, ValidationUtilities, ValidatorMapValue, ValidatorRegistry, ViewElementDataGroupType, ViewElementGroupType, ViewElementRegistry, WindowFunctionColumn, WindowFunctionExpression, _bootstrapCrtModule, applyLocalizeMetadataFn, bootstrapCrtModule, bootstrapCrtModuleHandlerChainServices, checkCrtTypeNamePascalCase, checkIfTypeRegistered, checkOnlyOneRegistration, checkTypeNameFormat, checkTypeNamePascalCase, crtInjectPrefix, crtInputPrefix, crtOutputPrefix, crtValidationInputPrefix, designTimeViewElementRegistryKey, encodeDate, generateGuid, getConverterMetadata, getCrtInputsMetadata, getCrtOutputsMetadata, getCrtValidationInputsMetadata, getDesignTimeViewElementMetadata, getHandlerChainServiceMetadata, getInterfaceDesignerItemMetadata, getModuleMetadata, getRequestHandlerMetadata, getTypeDependencies, getValidatorMetadata, getViewElementMetadata, hasInterfaceDesignerItemMetadata, instantiate, interfaceDesignerItemRegistryKey, isComponentPropertyBindable, isEmptyGuid, isGuid, localize, objectDeepKeys, registerAngularViewElement, registerViewElement, setConverterMetadata, setDesignTimeViewElementMetadata, setInterfaceDesignerItemMetadata, setModuleMetadata, setRequestHandlerMetadata, setValidatorMetadata, setViewElementMetadata, toAggregationEval, toAggregationEvalType, toAggregationFunction, toAggregationType, toDatePart, toDatePartType, toLocalISOString, toNumericFunctionType, toOrderDirection, toPascalCase, toSortDirection, toStringFunctionType, validatorRegistryKey, viewElementRegistryKey };
3450
+ export { AggregationEvalType, AggregationFunction, AggregationFunctionColumn, AggregationFunctionExpression, AggregationSubQueryColumn, AggregationSubQueryExpression, AggregationType, ArgumentEmptyException, ArgumentFunctionExpression, ArgumentOutOfRangeException, ArithmeticExpression, ArithmeticOperation, ArithmeticQueryColumn, BaseExpression, BaseFilter, BaseFilterableQuery, BaseQuery, BaseQueryColumn, BaseRegistry, BaseRequest, BaseRequestHandler, BaseValidator, BetweenFilter, BootstrapNotifier, ColumnExpression, CompareFilter, ComparisonType, ConverterRegistry, CrtConverter, CrtDesignTimeViewElement, CrtInject, CrtInput, CrtInputRegistrationConfig, CrtInterfaceDesignerItem, CrtModule, CrtOutput, CrtRequest, CrtRequestHandler, CrtValidationInput, CrtValidator, CrtViewElement, DataRequest, DataSchemaAttributeType, DataSchemaAttributeUsageType, DataSchemaType, DataSourceScope, DataValueType, DatePartFunctionColumn, DatePartFunctionExpression, DatePartType, DefaultValueSource, DeleteQuery, DesignTimeViewElementRegistry, DesignerToolGroupType, EMPTY_GUID, EXPRESSION_TYPE_MOCK, EntityQueryColumn, EntitySchemaQuery, ExistsFilter, ExpressionMock, ExpressionType, FeatureService, FilterGroup, FilterMock, FilterType, FunctionExpression, FunctionType, HandlerChainService, HandlerChainServicesRegistry, HandlerSourceType, HandlersOrderComparer, HttpClientService, ImplementUsingHandlerChain, InFilter, InsertQuery, InterfaceDesignerItemRegistrationConfig, InterfaceDesignerItemRegistry, InternalRequestHandlerRegistry, InternalRequestHandlerRegistryType, IsNullFilter, ItemNotFoundException, LengthFunctionColumn, LengthFunctionExpression, LocalizableValue, LogicalOperatorType, MacrosFunctionColumn, MacrosFunctionExpression, MaskService, MethodInvokeRequest, Model, ModelInPageAction, ModelParameterType, NextHandlerAlreadySpecifiedException, OrderDirection, ParameterExpression, ParameterQueryColumn, PkgTopology, QueryMacrosType, QueryOperationType, RemoteEntriesRegistry, RemoteEntryType, RequestHandlerRegistryService, RequestRegistryService, RightsService, SchemaViewMaskRequest, SchemaViewMaskRequestAction, SelectLocalizationQuery, SingleFilter, SubQueryColumn, SubQueryExpression, SysSetting, SysSettingValue, SysSettingsService, SysValuesService, UpdateQuery, ValidationUtilities, ValidatorMapValue, ValidatorRegistry, ViewElementDataGroupType, ViewElementGroupType, ViewElementRegistry, WindowFunctionColumn, WindowFunctionExpression, _bootstrapCrtModule, applyLocalizeMetadataFn, bootstrapCrtModule, bootstrapCrtModuleHandlerChainServices, checkCrtTypeNamePascalCase, checkIfTypeRegistered, checkOnlyOneRegistration, checkTypeNameFormat, checkTypeNamePascalCase, crtInjectPrefix, crtInputPrefix, crtOutputPrefix, crtValidationInputPrefix, designTimeViewElementRegistryKey, encodeDate, generateGuid, getConverterMetadata, getCrtInputsMetadata, getCrtOutputsMetadata, getCrtValidationInputsMetadata, getDesignTimeViewElementMetadata, getHandlerChainServiceMetadata, getInterfaceDesignerItemMetadata, getModuleMetadata, getRequestHandlerMetadata, getTypeDependencies, getValidatorMetadata, getViewElementMetadata, hasInterfaceDesignerItemMetadata, instantiate, interfaceDesignerItemRegistryKey, isComponentPropertyBindable, isEmptyGuid, isGuid, localize, objectDeepKeys, registerAngularViewElement, registerViewElement, setConverterMetadata, setDesignTimeViewElementMetadata, setInterfaceDesignerItemMetadata, setModuleMetadata, setRequestHandlerMetadata, setValidatorMetadata, setViewElementMetadata, toAggregationEval, toAggregationEvalType, toAggregationFunction, toAggregationType, toDatePart, toDatePartType, toLocalISOString, toNumericFunctionType, toOrderDirection, toPascalCase, toSortDirection, toStringFunctionType, validatorRegistryKey, viewElementRegistryKey };
3436
3451
  //# sourceMappingURL=creatio-devkit-common.mjs.map