bruce-models 4.9.8 → 5.0.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 (71) hide show
  1. package/dist/bruce-models.es5.js +397 -328
  2. package/dist/bruce-models.es5.js.map +1 -1
  3. package/dist/bruce-models.umd.js +397 -328
  4. package/dist/bruce-models.umd.js.map +1 -1
  5. package/dist/lib/account/account-features.js +1 -1
  6. package/dist/lib/account/account-features.js.map +1 -1
  7. package/dist/lib/account/account.js +11 -11
  8. package/dist/lib/account/account.js.map +1 -1
  9. package/dist/lib/ann-document/ann-document.js +4 -4
  10. package/dist/lib/ann-document/ann-document.js.map +1 -1
  11. package/dist/lib/api/abstract-api.js +1 -1
  12. package/dist/lib/api/abstract-api.js.map +1 -1
  13. package/dist/lib/api/api-getters.js +12 -3
  14. package/dist/lib/api/api-getters.js.map +1 -1
  15. package/dist/lib/bruce-models.js +1 -1
  16. package/dist/lib/calculator/calculator.js +223 -172
  17. package/dist/lib/calculator/calculator.js.map +1 -1
  18. package/dist/lib/client-file/client-file.js +2 -2
  19. package/dist/lib/client-file/client-file.js.map +1 -1
  20. package/dist/lib/custom-form/custom-form.js +6 -6
  21. package/dist/lib/custom-form/custom-form.js.map +1 -1
  22. package/dist/lib/data-source/data-source.js +6 -6
  23. package/dist/lib/data-source/data-source.js.map +1 -1
  24. package/dist/lib/entity/entity-attachment-type.js +2 -2
  25. package/dist/lib/entity/entity-attachment-type.js.map +1 -1
  26. package/dist/lib/entity/entity-attachment.js +6 -6
  27. package/dist/lib/entity/entity-attachment.js.map +1 -1
  28. package/dist/lib/entity/entity-comment.js +4 -4
  29. package/dist/lib/entity/entity-comment.js.map +1 -1
  30. package/dist/lib/entity/entity-coords.js +2 -2
  31. package/dist/lib/entity/entity-coords.js.map +1 -1
  32. package/dist/lib/entity/entity-link.js +4 -4
  33. package/dist/lib/entity/entity-link.js.map +1 -1
  34. package/dist/lib/entity/entity-lod-category.js +4 -4
  35. package/dist/lib/entity/entity-lod-category.js.map +1 -1
  36. package/dist/lib/entity/entity-lod.js +6 -6
  37. package/dist/lib/entity/entity-lod.js.map +1 -1
  38. package/dist/lib/entity/entity-relation-type.js +4 -4
  39. package/dist/lib/entity/entity-relation-type.js.map +1 -1
  40. package/dist/lib/entity/entity-relation.js +15 -15
  41. package/dist/lib/entity/entity-relation.js.map +1 -1
  42. package/dist/lib/entity/entity-source.js +2 -2
  43. package/dist/lib/entity/entity-source.js.map +1 -1
  44. package/dist/lib/entity/entity-tag.js +5 -5
  45. package/dist/lib/entity/entity-tag.js.map +1 -1
  46. package/dist/lib/entity/entity-type.js +4 -4
  47. package/dist/lib/entity/entity-type.js.map +1 -1
  48. package/dist/lib/environment.js +1 -1
  49. package/dist/lib/environment.js.map +1 -1
  50. package/dist/lib/import/imported-file.js +6 -6
  51. package/dist/lib/import/imported-file.js.map +1 -1
  52. package/dist/lib/plugin/plugin.js +4 -4
  53. package/dist/lib/plugin/plugin.js.map +1 -1
  54. package/dist/lib/program-key/program-key.js +4 -4
  55. package/dist/lib/program-key/program-key.js.map +1 -1
  56. package/dist/lib/project/project-view-bookmark.js +6 -6
  57. package/dist/lib/project/project-view-bookmark.js.map +1 -1
  58. package/dist/lib/project/project-view.js +4 -4
  59. package/dist/lib/project/project-view.js.map +1 -1
  60. package/dist/lib/style/style.js +4 -4
  61. package/dist/lib/style/style.js.map +1 -1
  62. package/dist/lib/tileset/tileset.js +15 -15
  63. package/dist/lib/tileset/tileset.js.map +1 -1
  64. package/dist/lib/user/session.js +2 -2
  65. package/dist/lib/user/session.js.map +1 -1
  66. package/dist/lib/user/user.js +26 -17
  67. package/dist/lib/user/user.js.map +1 -1
  68. package/dist/types/api/api-getters.d.ts +1 -0
  69. package/dist/types/bruce-models.d.ts +1 -1
  70. package/dist/types/calculator/calculator.d.ts +22 -6
  71. package/package.json +1 -1
@@ -373,7 +373,7 @@
373
373
  if (noCache) {
374
374
  return;
375
375
  }
376
- if (isNaN(duration)) {
376
+ if (isNaN(duration) || duration == null) {
377
377
  duration = exports.Api.DEFAULT_CACHE_DURATION;
378
378
  }
379
379
  this.Cache.Set({
@@ -1384,6 +1384,15 @@
1384
1384
  this.env = (params === null || params === void 0 ? void 0 : params.env) ? params.env : exports.Api.EEnv.PROD;
1385
1385
  this.sessionId = params === null || params === void 0 ? void 0 : params.sessionId;
1386
1386
  }
1387
+ prepEnv(_env) {
1388
+ if (!_env) {
1389
+ _env = this.env;
1390
+ }
1391
+ if (!_env) {
1392
+ _env = exports.Api.EEnv.PROD;
1393
+ }
1394
+ return _env.toUpperCase();
1395
+ }
1387
1396
  /**
1388
1397
  * Clears all cache items in all API instances.
1389
1398
  */
@@ -1474,7 +1483,7 @@
1474
1483
  }
1475
1484
  let { accountId, env, loadConfig, loadWebSocket } = params;
1476
1485
  accountId = accountId ? accountId : this.accountId;
1477
- env = env ? env : this.env;
1486
+ env = this.prepEnv(env);
1478
1487
  const key = `${accountId}-${env}`;
1479
1488
  if (!this.bruce[key]) {
1480
1489
  this.bruce[key] = new exports.BruceApi.Api({
@@ -1518,7 +1527,7 @@
1518
1527
  params = {};
1519
1528
  }
1520
1529
  let { env } = params;
1521
- env = env ? env : this.env;
1530
+ env = this.prepEnv(env);
1522
1531
  const key = `${env}`;
1523
1532
  if (!this.global[key]) {
1524
1533
  this.global[key] = new exports.GlobalApi.Api({
@@ -1538,7 +1547,7 @@
1538
1547
  params = {};
1539
1548
  }
1540
1549
  let { env } = params;
1541
- env = env ? env : this.env;
1550
+ env = this.prepEnv(env);
1542
1551
  const key = `${env}`;
1543
1552
  if (!this.guardian[key]) {
1544
1553
  this.guardian[key] = new exports.GuardianApi.Api({
@@ -1641,7 +1650,7 @@
1641
1650
  if (!_getters) {
1642
1651
  _getters = new ApiGetters({
1643
1652
  accountId: ENVIRONMENT.PARAMS.accountId,
1644
- env: ENVIRONMENT.PARAMS.env ? ENVIRONMENT.PARAMS.env : exports.Api.EEnv.UAT,
1653
+ env: ENVIRONMENT.PARAMS.env ? ENVIRONMENT.PARAMS.env : exports.Api.EEnv.PROD,
1645
1654
  sessionId: ENVIRONMENT.PARAMS.sessionId
1646
1655
  });
1647
1656
  }
@@ -1698,7 +1707,7 @@
1698
1707
  api = exports.ENVIRONMENT.Api().GetBruceApi();
1699
1708
  }
1700
1709
  const key = GetCacheKey(docId);
1701
- const cache = yield api.GetCacheItem(key, reqParams);
1710
+ const cache = api.GetCacheItem(key, reqParams);
1702
1711
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
1703
1712
  return cache.data;
1704
1713
  }
@@ -1713,7 +1722,7 @@
1713
1722
  rej(e);
1714
1723
  }
1715
1724
  }));
1716
- yield api.SetCacheItem({
1725
+ api.SetCacheItem({
1717
1726
  key,
1718
1727
  value: prom,
1719
1728
  req: reqParams
@@ -1736,7 +1745,7 @@
1736
1745
  if (!type) {
1737
1746
  type = "";
1738
1747
  }
1739
- const cache = yield api.GetCacheItem(GetListCacheKey(type, entityId, expandSettings), reqParams);
1748
+ const cache = api.GetCacheItem(GetListCacheKey(type, entityId, expandSettings), reqParams);
1740
1749
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
1741
1750
  return cache.data;
1742
1751
  }
@@ -1762,7 +1771,7 @@
1762
1771
  rej(e);
1763
1772
  }
1764
1773
  }));
1765
- yield api.SetCacheItem({
1774
+ api.SetCacheItem({
1766
1775
  key: GetListCacheKey(type, entityId, expandSettings),
1767
1776
  value: req,
1768
1777
  req: reqParams
@@ -1835,7 +1844,7 @@
1835
1844
  if (!api) {
1836
1845
  api = exports.ENVIRONMENT.Api().GetBruceApi();
1837
1846
  }
1838
- const cache = yield api.GetCacheItem(GetCacheKey(id), reqParams);
1847
+ const cache = api.GetCacheItem(GetCacheKey(id), reqParams);
1839
1848
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
1840
1849
  return cache.data;
1841
1850
  }
@@ -1850,7 +1859,7 @@
1850
1859
  rej(err);
1851
1860
  }
1852
1861
  }));
1853
- yield api.SetCacheItem({
1862
+ api.SetCacheItem({
1854
1863
  key: GetCacheKey(id),
1855
1864
  value: prom,
1856
1865
  req: reqParams
@@ -1873,7 +1882,7 @@
1873
1882
  api = exports.ENVIRONMENT.Api().GetBruceApi();
1874
1883
  }
1875
1884
  yield api.DELETE(`customForm/${id}`, exports.Api.PrepReqParams(reqParams));
1876
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.CustomForm);
1885
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.CustomForm);
1877
1886
  });
1878
1887
  }
1879
1888
  CustomForm.Delete = Delete;
@@ -1889,7 +1898,7 @@
1889
1898
  api = exports.ENVIRONMENT.Api().GetBruceApi();
1890
1899
  }
1891
1900
  const url = typeId ? `entityType/${typeId}/customForms` : "customForms";
1892
- const cache = yield api.GetCacheItem(GetListCacheKey(typeId), reqParams);
1901
+ const cache = api.GetCacheItem(GetListCacheKey(typeId), reqParams);
1893
1902
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
1894
1903
  return cache.data;
1895
1904
  }
@@ -1899,7 +1908,7 @@
1899
1908
  forms: data.Items
1900
1909
  };
1901
1910
  });
1902
- yield api.SetCacheItem({
1911
+ api.SetCacheItem({
1903
1912
  key: GetListCacheKey(typeId),
1904
1913
  value: prom,
1905
1914
  req: reqParams
@@ -1923,7 +1932,7 @@
1923
1932
  data.ID = 0;
1924
1933
  }
1925
1934
  const res = yield api.POST(`customForm/${data.ID}`, data, exports.Api.PrepReqParams(reqParams));
1926
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.CustomForm);
1935
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.CustomForm);
1927
1936
  return {
1928
1937
  form: res
1929
1938
  };
@@ -2372,7 +2381,7 @@
2372
2381
  api = exports.ENVIRONMENT.Api().GetBruceApi();
2373
2382
  }
2374
2383
  const key = GetCacheKey(typeId);
2375
- const cache = yield api.GetCacheItem(key, reqParams);
2384
+ const cache = api.GetCacheItem(key, reqParams);
2376
2385
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
2377
2386
  return cache.data;
2378
2387
  }
@@ -2388,7 +2397,7 @@
2388
2397
  rej(e);
2389
2398
  }
2390
2399
  }));
2391
- yield api.SetCacheItem({
2400
+ api.SetCacheItem({
2392
2401
  key,
2393
2402
  value: prom,
2394
2403
  req: reqParams
@@ -2427,7 +2436,7 @@
2427
2436
  if (!api) {
2428
2437
  api = exports.ENVIRONMENT.Api().GetBruceApi();
2429
2438
  }
2430
- const cache = yield api.GetCacheItem(GetListCacheKey({
2439
+ const cache = api.GetCacheItem(GetListCacheKey({
2431
2440
  typeIds: entityTypeIds,
2432
2441
  parentTypeId,
2433
2442
  expandSettings,
@@ -2493,7 +2502,7 @@
2493
2502
  }
2494
2503
  }));
2495
2504
  if (!parentTypeId) {
2496
- yield api.SetCacheItem({
2505
+ api.SetCacheItem({
2497
2506
  key: GetListCacheKey({
2498
2507
  typeIds: entityTypeIds,
2499
2508
  parentTypeId,
@@ -4083,61 +4092,228 @@
4083
4092
  EValueType[EValueType["RandomColor"] = 5] = "RandomColor";
4084
4093
  })(EValueType = Calculator.EValueType || (Calculator.EValueType = {}));
4085
4094
  /**
4086
- * Calculates the value of arbitrary field options.
4087
- * The context calling this should validate results and parse stuff if needed.
4088
- * @deprecated use specific calls: eg GetColor or GetNumber.
4089
- * @param fields
4090
- * @param entity
4091
- * @param tags
4092
- * @returns
4095
+ * Calculates a value-type 'T' based on given set of fields.
4096
+ * The supplied data + tags are fed into the calculation.
4097
+ * When a value fails to be calculated, the 'defaultValue' is returned.
4098
+ * If no 'defaultValue' is provided, then 'null' is returned.
4093
4099
  */
4094
- function GetValue(fields, entity, tags) {
4095
- if (!(fields === null || fields === void 0 ? void 0 : fields.length)) {
4096
- return null;
4100
+ function Calculate(params) {
4101
+ let { fields, tags, data, defaultValue, type } = params;
4102
+ if (fields == null) {
4103
+ return defaultValue;
4104
+ }
4105
+ if (data == null || typeof data != "object") {
4106
+ data = {};
4097
4107
  }
4098
- if (!tags) {
4108
+ if (tags == null || !Array.isArray(tags)) {
4099
4109
  tags = [];
4100
4110
  }
4101
- if (!entity) {
4102
- entity = {};
4111
+ if (type == null) {
4112
+ type = "any";
4103
4113
  }
4104
- for (let i = 0; i < fields.length; i++) {
4105
- const field = fields[i];
4106
- let value;
4114
+ // Normalize fields to be an array of options.
4115
+ let fieldsArr = [];
4116
+ if (Array.isArray(fields)) {
4117
+ fieldsArr = fields;
4118
+ }
4119
+ else {
4120
+ fieldsArr = [fields];
4121
+ }
4122
+ // Indicator for old data.
4123
+ // When a range is provided in older data, it is expected that invalid/failed mappings should default to the minimum value.
4124
+ // We are deprecating this logic.
4125
+ // The first step of deprecation is to avoid using this logic when multiple calculations are provided.
4126
+ // TODO: When we've reviewed all existing uses, we can remove this logic entirely and just update the needed style records.
4127
+ let shouldRangesDefaultToMin = true;
4128
+ // This reduce totals the number of mappings and gradients.
4129
+ // >1 means we should not default to min as there are multiple calculations.
4130
+ if (fieldsArr.reduce((acc, field) => acc += (field.type == EValueType.Mapping || field.type == EValueType.Gradient) ? 1 : 0, 0) > 1) {
4131
+ shouldRangesDefaultToMin = false;
4132
+ }
4133
+ const assertColor = (color) => {
4134
+ if (color && typeof color == "string") {
4135
+ color = exports.Color.ColorFromStr(color);
4136
+ }
4137
+ if (color && typeof color == "object" && !isNaN(color.red) && color.red != null) {
4138
+ return color;
4139
+ }
4140
+ return null;
4141
+ };
4142
+ const isColor = (value) => {
4143
+ if (value && typeof value == "object" && !isNaN(value.red) && value.red != null) {
4144
+ return true;
4145
+ }
4146
+ return false;
4147
+ };
4148
+ // Calculate the value.
4149
+ let value = null;
4150
+ for (let i = 0; i < fieldsArr.length; i++) {
4151
+ let field = fieldsArr[i];
4152
+ if (field) {
4153
+ // Dereference.
4154
+ // We do this because we'll be modifying the field to fix bad data.
4155
+ field = JSON.parse(JSON.stringify(field));
4156
+ }
4157
+ // Bad data has it set to 'color' but expects the input to be a number.
4158
+ if (type == "number" && field.type == EValueType.Color) {
4159
+ field.type = EValueType.Input;
4160
+ }
4107
4161
  switch (field.type) {
4108
4162
  case EValueType.Color:
4163
+ if (type === "number") {
4164
+ break;
4165
+ }
4109
4166
  value = field.value;
4110
- if (value) {
4111
- value = exports.Color.ColorFromStr(value);
4167
+ value = assertColor(value);
4168
+ if (value && type == "string") {
4169
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
4112
4170
  }
4113
4171
  break;
4114
4172
  case EValueType.Gradient:
4115
- value = GetGradientValue(field.value, entity);
4116
- break;
4117
- case EValueType.Input:
4118
- value = GetInputValue(field.value, entity);
4119
- break;
4120
- case EValueType.Mapping:
4121
- value = GetMappingValue(field.value, entity);
4173
+ if (type === "number") {
4174
+ break;
4175
+ }
4176
+ value = GetGradientValue(field.value, data, shouldRangesDefaultToMin);
4177
+ value = assertColor(value);
4178
+ if (value && type == "string") {
4179
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
4180
+ }
4122
4181
  break;
4123
4182
  case EValueType.RandomColor:
4183
+ if (type === "number") {
4184
+ break;
4185
+ }
4124
4186
  value = exports.Color.RandomColor();
4187
+ value = assertColor(value);
4188
+ if (value && type == "string") {
4189
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
4190
+ }
4125
4191
  break;
4126
4192
  case EValueType.TagColor:
4193
+ if (type === "number") {
4194
+ break;
4195
+ }
4127
4196
  for (let i = 0; i < tags.length; i++) {
4128
4197
  const tag = tags[i];
4129
4198
  if (tag.Color) {
4130
4199
  value = exports.Color.ColorFromStr(tag.Color);
4131
- break;
4200
+ value = assertColor(value);
4201
+ if (value) {
4202
+ break;
4203
+ }
4204
+ }
4205
+ }
4206
+ if (value && type == "string") {
4207
+ const cColor = value;
4208
+ value = `rgba(${cColor.red},${cColor.green},${cColor.blue},${cColor.alpha})`;
4209
+ }
4210
+ break;
4211
+ // Input can be an arbitrary value.
4212
+ // Eg: Result is a colour, a number, a string.
4213
+ // This means we first calculate the value, then validate it in the context of the desired type.
4214
+ case EValueType.Input:
4215
+ value = GetInputValue(field.value, data);
4216
+ if (value != null) {
4217
+ if (type == "number") {
4218
+ if (typeof value == "string" && value != "" && value != null && value != undefined) {
4219
+ value = Number(value);
4220
+ }
4221
+ else if (typeof value != "number") {
4222
+ value = null;
4223
+ }
4224
+ }
4225
+ else if (type == "string") {
4226
+ if (typeof value == "number") {
4227
+ value = String(value);
4228
+ }
4229
+ else if (typeof value == "object") {
4230
+ if (isColor(value)) {
4231
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
4232
+ }
4233
+ else {
4234
+ value = null;
4235
+ }
4236
+ }
4237
+ }
4238
+ else if (type == "color") {
4239
+ value = assertColor(value);
4240
+ }
4241
+ }
4242
+ break;
4243
+ // Mapping can be an arbitrary value.
4244
+ // Eg: mapping a value to a Client File ID, or a colour, or a number.
4245
+ // This means we first calculate the value, then validate it in the context of the desired type.
4246
+ case EValueType.Mapping:
4247
+ value = GetMappingValue(field.value, data);
4248
+ if (value != null) {
4249
+ if (type == "number") {
4250
+ if (typeof value == "string" && value != "" && value != null && value != undefined) {
4251
+ value = Number(value);
4252
+ }
4253
+ else if (typeof value != "number") {
4254
+ value = null;
4255
+ }
4256
+ }
4257
+ else if (type == "string") {
4258
+ if (typeof value == "number") {
4259
+ value = String(value);
4260
+ }
4261
+ else if (typeof value == "object") {
4262
+ if (isColor(value)) {
4263
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
4264
+ }
4265
+ else {
4266
+ value = null;
4267
+ }
4268
+ }
4269
+ }
4270
+ else if (type == "color") {
4271
+ value = assertColor(typeof value === "number" ? String(value) : value);
4132
4272
  }
4133
4273
  }
4134
4274
  break;
4135
4275
  }
4136
- if (value || value == 0) {
4137
- return value;
4276
+ // Extra layer of validation.
4277
+ // This is a backup in case some branch above failed to convert into the right type.
4278
+ if (type == "number") {
4279
+ if (typeof value !== "number" || isNaN(value)) {
4280
+ value = null;
4281
+ }
4282
+ }
4283
+ else if (type == "color") {
4284
+ if (typeof value !== "object" || !value) {
4285
+ value = null;
4286
+ }
4287
+ }
4288
+ else if (type == "string") {
4289
+ if (typeof value !== "string" || !value) {
4290
+ value = null;
4291
+ }
4292
+ }
4293
+ if (value != null) {
4294
+ break;
4138
4295
  }
4139
4296
  }
4140
- return null;
4297
+ // Return the value or default.
4298
+ return value != null ? value : defaultValue;
4299
+ }
4300
+ Calculator.Calculate = Calculate;
4301
+ /**
4302
+ * Calculates the value of arbitrary field options.
4303
+ * The context calling this should validate results and parse stuff if needed.
4304
+ * @param fields
4305
+ * @param entity
4306
+ * @param tags
4307
+ * @returns
4308
+ */
4309
+ function GetValue(fields, entity = {}, tags = []) {
4310
+ return Calculate({
4311
+ fields: fields,
4312
+ data: entity,
4313
+ defaultValue: null,
4314
+ tags: tags,
4315
+ type: "any"
4316
+ });
4141
4317
  }
4142
4318
  Calculator.GetValue = GetValue;
4143
4319
  /**
@@ -4147,53 +4323,14 @@
4147
4323
  * @param entity
4148
4324
  * @param tags
4149
4325
  */
4150
- function GetColor(fields, entity, tags) {
4151
- if (!(fields === null || fields === void 0 ? void 0 : fields.length)) {
4152
- return null;
4153
- }
4154
- if (!tags) {
4155
- tags = [];
4156
- }
4157
- if (!entity) {
4158
- entity = {};
4159
- }
4160
- for (let i = 0; i < fields.length; i++) {
4161
- const field = fields[i];
4162
- let value;
4163
- switch (field.type) {
4164
- case EValueType.Color:
4165
- value = field.value;
4166
- break;
4167
- case EValueType.Gradient:
4168
- value = GetGradientValue(field.value, entity);
4169
- break;
4170
- case EValueType.Input:
4171
- value = GetInputValue(field.value, entity);
4172
- break;
4173
- case EValueType.Mapping:
4174
- value = GetMappingValue(field.value, entity);
4175
- break;
4176
- case EValueType.RandomColor:
4177
- value = exports.Color.RandomColor();
4178
- break;
4179
- case EValueType.TagColor:
4180
- for (let i = 0; i < tags.length; i++) {
4181
- const tag = tags[i];
4182
- if (tag.Color) {
4183
- value = exports.Color.ColorFromStr(tag.Color);
4184
- break;
4185
- }
4186
- }
4187
- break;
4188
- }
4189
- if (typeof value === "string") {
4190
- value = exports.Color.ColorFromStr(value);
4191
- }
4192
- if (value && typeof value === "object" && (value.red || value.red == 0)) {
4193
- return value;
4194
- }
4195
- }
4196
- return null;
4326
+ function GetColor(fields, entity = {}, tags = []) {
4327
+ return Calculate({
4328
+ fields: fields,
4329
+ data: entity,
4330
+ defaultValue: null,
4331
+ tags: tags,
4332
+ type: "color"
4333
+ });
4197
4334
  }
4198
4335
  Calculator.GetColor = GetColor;
4199
4336
  /**
@@ -4204,39 +4341,14 @@
4204
4341
  * @param tags
4205
4342
  * @returns
4206
4343
  */
4207
- function GetNumber(fields, entity, tags) {
4208
- if (!(fields === null || fields === void 0 ? void 0 : fields.length)) {
4209
- return null;
4210
- }
4211
- if (!tags) {
4212
- tags = [];
4213
- }
4214
- if (!entity) {
4215
- entity = {};
4216
- }
4217
- for (let i = 0; i < fields.length; i++) {
4218
- const field = fields[i];
4219
- let value;
4220
- switch (field.type) {
4221
- case EValueType.Gradient:
4222
- value = GetGradientValue(field.value, entity);
4223
- break;
4224
- case EValueType.Color:
4225
- case EValueType.Input:
4226
- value = GetInputValue(field.value, entity);
4227
- break;
4228
- case EValueType.Mapping:
4229
- value = GetMappingValue(field.value, entity);
4230
- break;
4231
- }
4232
- if (value != "" && value != null && value != undefined) {
4233
- value = Number(value);
4234
- }
4235
- if (value || value == 0) {
4236
- return value;
4237
- }
4238
- }
4239
- return null;
4344
+ function GetNumber(fields, entity = {}, tags = []) {
4345
+ return Calculate({
4346
+ fields: fields,
4347
+ data: entity,
4348
+ defaultValue: null,
4349
+ tags: tags,
4350
+ type: "number"
4351
+ });
4240
4352
  }
4241
4353
  Calculator.GetNumber = GetNumber;
4242
4354
  /**
@@ -4247,68 +4359,14 @@
4247
4359
  * @param tags
4248
4360
  * @returns
4249
4361
  */
4250
- function GetString(fields, entity, tags) {
4251
- if (!(fields === null || fields === void 0 ? void 0 : fields.length)) {
4252
- return null;
4253
- }
4254
- if (!tags) {
4255
- tags = [];
4256
- }
4257
- if (!entity) {
4258
- entity = {};
4259
- }
4260
- for (let i = 0; i < fields.length; i++) {
4261
- const field = fields[i];
4262
- let value;
4263
- switch (field.type) {
4264
- case EValueType.Gradient:
4265
- {
4266
- const tmp = GetGradientValue(field.value, entity);
4267
- // This avoids null turning into "null".
4268
- if (tmp) {
4269
- value = String(tmp);
4270
- }
4271
- }
4272
- break;
4273
- case EValueType.Color:
4274
- case EValueType.Input:
4275
- {
4276
- const tmp = GetInputValue(field.value, entity);
4277
- // This avoids null turning into "null".
4278
- if (tmp) {
4279
- value = String(tmp);
4280
- }
4281
- }
4282
- break;
4283
- case EValueType.Mapping:
4284
- {
4285
- const tmp = GetMappingValue(field.value, entity);
4286
- // This avoids null turning into "null".
4287
- if (tmp) {
4288
- value = String(tmp);
4289
- }
4290
- }
4291
- break;
4292
- case EValueType.RandomColor:
4293
- // Would be nice to randomize based on an attribute or entity ID instead of pure random.
4294
- var color = exports.Color.RandomColor();
4295
- value = `rgba(${color.red},${color.green},${color.blue},${color.alpha})`;
4296
- break;
4297
- case EValueType.TagColor:
4298
- for (let i = 0; i < tags.length; i++) {
4299
- const tag = tags[i];
4300
- if (tag.Color) {
4301
- value = tag.Color;
4302
- break;
4303
- }
4304
- }
4305
- break;
4306
- }
4307
- if (value) {
4308
- return value;
4309
- }
4310
- }
4311
- return null;
4362
+ function GetString(fields, entity = {}, tags = []) {
4363
+ return Calculate({
4364
+ fields: fields,
4365
+ data: entity,
4366
+ defaultValue: null,
4367
+ tags: tags,
4368
+ type: "string"
4369
+ });
4312
4370
  }
4313
4371
  Calculator.GetString = GetString;
4314
4372
  /**
@@ -4376,9 +4434,11 @@
4376
4434
  * It is intended to be parsed and validated within a value-type context. Eg: GetColor, GetNumber, GetString.
4377
4435
  * @param value
4378
4436
  * @param entity
4437
+ * @param defaultToMin if a value fails to be calculated, should we default to the minimum value?
4438
+ * Default is true for backwards compatibility.
4379
4439
  * @returns
4380
4440
  */
4381
- function GetGradientValue(value, entity) {
4441
+ function GetGradientValue(value, entity, defaultToMin) {
4382
4442
  const min = +value.points[0].position;
4383
4443
  const max = +value.points[value.points.length - 1].position;
4384
4444
  const attrPaths = parseLegacyPath(value.field);
@@ -5541,7 +5601,7 @@
5541
5601
  if (!api) {
5542
5602
  api = exports.ENVIRONMENT.Api().GetBruceApi();
5543
5603
  }
5544
- const cache = yield api.GetCacheItem(GetListCacheKey(), reqParams);
5604
+ const cache = api.GetCacheItem(GetListCacheKey(), reqParams);
5545
5605
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
5546
5606
  return cache.data;
5547
5607
  }
@@ -5556,7 +5616,7 @@
5556
5616
  rej(e);
5557
5617
  }
5558
5618
  }));
5559
- yield api.SetCacheItem({
5619
+ api.SetCacheItem({
5560
5620
  key: GetListCacheKey(),
5561
5621
  value: req,
5562
5622
  req: reqParams
@@ -5620,7 +5680,7 @@
5620
5680
  api.Cache.Remove(GetCacheKey(attachments[i].ID));
5621
5681
  }
5622
5682
  }
5623
- yield api.Cache.Remove(GetListCacheKey(entityId));
5683
+ api.Cache.Remove(GetListCacheKey(entityId));
5624
5684
  return {
5625
5685
  attachments: res.attachments
5626
5686
  };
@@ -5651,7 +5711,7 @@
5651
5711
  for (let i = 0; i < attachments.length; i++) {
5652
5712
  api.Cache.Remove(GetCacheKey(attachments[i].ID));
5653
5713
  }
5654
- yield api.Cache.RemoveByStartsWith(GetListCacheKey(entityId));
5714
+ api.Cache.RemoveByStartsWith(GetListCacheKey(entityId));
5655
5715
  });
5656
5716
  }
5657
5717
  EntityAttachment.UpdateOrder = UpdateOrder;
@@ -5669,8 +5729,8 @@
5669
5729
  api = exports.ENVIRONMENT.Api().GetBruceApi();
5670
5730
  }
5671
5731
  yield api.DELETE(`entity/${entityId}/attachments/${attachmentId}`, exports.Api.PrepReqParams(req));
5672
- yield api.Cache.Remove(GetCacheKey(attachmentId));
5673
- yield api.Cache.Remove(GetListCacheKey(params.entityId));
5732
+ api.Cache.Remove(GetCacheKey(attachmentId));
5733
+ api.Cache.Remove(GetListCacheKey(params.entityId));
5674
5734
  });
5675
5735
  }
5676
5736
  EntityAttachment.Delete = Delete;
@@ -5688,7 +5748,7 @@
5688
5748
  if (!api) {
5689
5749
  api = exports.ENVIRONMENT.Api().GetBruceApi();
5690
5750
  }
5691
- const cache = yield api.GetCacheItem(GetListCacheKey(entityId), reqParams);
5751
+ const cache = api.GetCacheItem(GetListCacheKey(entityId), reqParams);
5692
5752
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
5693
5753
  return cache.data;
5694
5754
  }
@@ -5703,7 +5763,7 @@
5703
5763
  rej(e);
5704
5764
  }
5705
5765
  }));
5706
- yield api.SetCacheItem({
5766
+ api.SetCacheItem({
5707
5767
  key: GetListCacheKey(entityId),
5708
5768
  value: req,
5709
5769
  req: reqParams
@@ -5784,7 +5844,7 @@
5784
5844
  const url = `entity/${data["TargetObject.ID"]}/comment` + (data.ID == null ? "" : "/" + data.ID);
5785
5845
  const res = yield api.POST(url, data, exports.Api.PrepReqParams(reqParams));
5786
5846
  api.Cache.Remove(GetCacheKey(data.ID));
5787
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Comment + exports.Api.ECacheKey.Entity);
5847
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Comment + exports.Api.ECacheKey.Entity);
5788
5848
  return {
5789
5849
  comment: res
5790
5850
  };
@@ -5806,7 +5866,7 @@
5806
5866
  }
5807
5867
  yield api.DELETE(`entity/${entityId}/comment/${commentId}`, exports.Api.PrepReqParams(reqParams));
5808
5868
  api.Cache.Remove(GetCacheKey(commentId));
5809
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Comment + exports.Api.ECacheKey.Entity);
5869
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Comment + exports.Api.ECacheKey.Entity);
5810
5870
  });
5811
5871
  }
5812
5872
  EntityComment.Delete = Delete;
@@ -5824,7 +5884,7 @@
5824
5884
  if (!api) {
5825
5885
  api = exports.ENVIRONMENT.Api().GetBruceApi();
5826
5886
  }
5827
- const cache = yield api.GetCacheItem(GetListCacheKey(entityId), reqParams);
5887
+ const cache = api.GetCacheItem(GetListCacheKey(entityId), reqParams);
5828
5888
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
5829
5889
  return cache.data;
5830
5890
  }
@@ -5839,7 +5899,7 @@
5839
5899
  rej(e);
5840
5900
  }
5841
5901
  }));
5842
- yield api.SetCacheItem({
5902
+ api.SetCacheItem({
5843
5903
  key: GetListCacheKey(entityId),
5844
5904
  value: req,
5845
5905
  req: reqParams
@@ -5896,7 +5956,7 @@
5896
5956
  const url = `entity/${data["Entity.ID"]}/link` + (data.ID == null ? "" : "/" + data.ID);
5897
5957
  const res = yield api.POST(url, data, exports.Api.PrepReqParams(reqParams));
5898
5958
  api.Cache.Remove(GetCacheKey(data.ID));
5899
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Link + exports.Api.ECacheKey.Entity);
5959
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Link + exports.Api.ECacheKey.Entity);
5900
5960
  return {
5901
5961
  link: res
5902
5962
  };
@@ -5918,7 +5978,7 @@
5918
5978
  }
5919
5979
  yield api.DELETE(`entity/${entityId}/link/${linkId}`, exports.Api.PrepReqParams(reqParams));
5920
5980
  api.Cache.Remove(GetCacheKey(linkId));
5921
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Link + exports.Api.ECacheKey.Entity);
5981
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Link + exports.Api.ECacheKey.Entity);
5922
5982
  });
5923
5983
  }
5924
5984
  EntityLink.Delete = Delete;
@@ -5936,7 +5996,7 @@
5936
5996
  if (!api) {
5937
5997
  api = exports.ENVIRONMENT.Api().GetBruceApi();
5938
5998
  }
5939
- const cache = yield api.GetCacheItem(GetListCacheKey(entityId), reqParams);
5999
+ const cache = api.GetCacheItem(GetListCacheKey(entityId), reqParams);
5940
6000
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
5941
6001
  return cache.data;
5942
6002
  }
@@ -5951,7 +6011,7 @@
5951
6011
  rej(e);
5952
6012
  }
5953
6013
  }));
5954
- yield api.SetCacheItem({
6014
+ api.SetCacheItem({
5955
6015
  key: GetListCacheKey(entityId),
5956
6016
  value: req,
5957
6017
  req: reqParams
@@ -6034,7 +6094,7 @@
6034
6094
  if (!api) {
6035
6095
  api = exports.ENVIRONMENT.Api().GetBruceApi();
6036
6096
  }
6037
- const cache = yield api.GetCacheItem(GetCacheKey(url), reqParams);
6097
+ const cache = api.GetCacheItem(GetCacheKey(url), reqParams);
6038
6098
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
6039
6099
  return cache.data;
6040
6100
  }
@@ -6049,7 +6109,7 @@
6049
6109
  rej(e);
6050
6110
  }
6051
6111
  }));
6052
- yield api.SetCacheItem({
6112
+ api.SetCacheItem({
6053
6113
  key: GetCacheKey(url),
6054
6114
  value: req,
6055
6115
  req: reqParams
@@ -6096,7 +6156,7 @@
6096
6156
  if (!entityId) {
6097
6157
  throw ("Entity id is required.");
6098
6158
  }
6099
- const cache = yield api.GetCacheItem(GetEntityListKey(entityId), reqParams);
6159
+ const cache = api.GetCacheItem(GetEntityListKey(entityId), reqParams);
6100
6160
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
6101
6161
  return cache.data;
6102
6162
  }
@@ -6112,7 +6172,7 @@
6112
6172
  rej(e);
6113
6173
  }
6114
6174
  }));
6115
- yield api.SetCacheItem({
6175
+ api.SetCacheItem({
6116
6176
  key: GetEntityListKey(entityId),
6117
6177
  value: prom,
6118
6178
  req: reqParams
@@ -6134,7 +6194,7 @@
6134
6194
  if (!group) {
6135
6195
  group = "DEFAULT";
6136
6196
  }
6137
- const cache = yield api.GetCacheItem(GetTypeListKey(typeId, group), reqParams);
6197
+ const cache = api.GetCacheItem(GetTypeListKey(typeId, group), reqParams);
6138
6198
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
6139
6199
  return cache.data;
6140
6200
  }
@@ -6151,7 +6211,7 @@
6151
6211
  rej(e);
6152
6212
  }
6153
6213
  }));
6154
- yield api.SetCacheItem({
6214
+ api.SetCacheItem({
6155
6215
  key: GetTypeListKey(typeId, group),
6156
6216
  value: prom,
6157
6217
  req: reqParams
@@ -6264,7 +6324,7 @@
6264
6324
  if (!api) {
6265
6325
  api = exports.ENVIRONMENT.Api().GetBruceApi();
6266
6326
  }
6267
- const cache = yield api.GetCacheItem(GetListCacheKey(), reqParams);
6327
+ const cache = api.GetCacheItem(GetListCacheKey(), reqParams);
6268
6328
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
6269
6329
  return cache.data;
6270
6330
  }
@@ -6279,7 +6339,7 @@
6279
6339
  rej(e);
6280
6340
  }
6281
6341
  }));
6282
- yield api.SetCacheItem({
6342
+ api.SetCacheItem({
6283
6343
  key: GetListCacheKey(),
6284
6344
  value: req,
6285
6345
  req: reqParams
@@ -6302,7 +6362,7 @@
6302
6362
  if (!api) {
6303
6363
  api = exports.ENVIRONMENT.Api().GetBruceApi();
6304
6364
  }
6305
- const cache = yield api.GetCacheItem(GetCacheKey(id), reqParams);
6365
+ const cache = api.GetCacheItem(GetCacheKey(id), reqParams);
6306
6366
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
6307
6367
  return cache.data;
6308
6368
  }
@@ -6317,7 +6377,7 @@
6317
6377
  rej(e);
6318
6378
  }
6319
6379
  }));
6320
- yield api.SetCacheItem({
6380
+ api.SetCacheItem({
6321
6381
  key: GetCacheKey(id),
6322
6382
  value: req,
6323
6383
  req: reqParams
@@ -6413,7 +6473,7 @@
6413
6473
  api = exports.ENVIRONMENT.Api().GetBruceApi();
6414
6474
  }
6415
6475
  const key = GetCacheKey(typeId);
6416
- const cache = yield api.GetCacheItem(key, reqParams);
6476
+ const cache = api.GetCacheItem(key, reqParams);
6417
6477
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
6418
6478
  return cache.data;
6419
6479
  }
@@ -6428,7 +6488,7 @@
6428
6488
  rej(e);
6429
6489
  }
6430
6490
  }));
6431
- yield api.SetCacheItem({
6491
+ api.SetCacheItem({
6432
6492
  key,
6433
6493
  value: prom,
6434
6494
  req: reqParams
@@ -6467,7 +6527,7 @@
6467
6527
  if (!api) {
6468
6528
  api = exports.ENVIRONMENT.Api().GetBruceApi();
6469
6529
  }
6470
- const cache = yield api.GetCacheItem(GetListCacheKey(), reqParams);
6530
+ const cache = api.GetCacheItem(GetListCacheKey(), reqParams);
6471
6531
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
6472
6532
  return cache.data;
6473
6533
  }
@@ -6482,7 +6542,7 @@
6482
6542
  rej(e);
6483
6543
  }
6484
6544
  }));
6485
- yield api.SetCacheItem({
6545
+ api.SetCacheItem({
6486
6546
  key: GetListCacheKey(),
6487
6547
  value: req,
6488
6548
  req: reqParams
@@ -6565,11 +6625,11 @@
6565
6625
  };
6566
6626
  const url = `entity/${data["Principal.Entity.ID"]}/relation/${data["Relation.Type.ID"]}/add`;
6567
6627
  yield api.POST(url, reqData, exports.Api.PrepReqParams(reqParams));
6568
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + data["Principal.Entity.ID"]);
6569
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + data["Related.Entity.ID"]);
6570
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.RelationType);
6628
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + data["Principal.Entity.ID"]);
6629
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + data["Related.Entity.ID"]);
6630
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.RelationType);
6571
6631
  if (data["Data.Entity.ID"]) {
6572
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Entity + exports.Api.ECacheKey.Id + data["Data.Entity.ID"]);
6632
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Entity + exports.Api.ECacheKey.Id + data["Data.Entity.ID"]);
6573
6633
  }
6574
6634
  });
6575
6635
  }
@@ -6592,9 +6652,9 @@
6592
6652
  "Related.Entity.ID": [relatedEntityId]
6593
6653
  }, exports.Api.PrepReqParams(reqParams));
6594
6654
  // Remove related cache entries
6595
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + principalEntityId);
6596
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + relatedEntityId);
6597
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.RelationType + exports.Api.ECacheKey.Id + relationTypeId);
6655
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + principalEntityId);
6656
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + relatedEntityId);
6657
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.RelationType + exports.Api.ECacheKey.Id + relationTypeId);
6598
6658
  });
6599
6659
  }
6600
6660
  EntityRelation.Delete = Delete;
@@ -6614,11 +6674,11 @@
6614
6674
  }
6615
6675
  const url = `entity/${data["Principal.Entity.ID"]}/otherEntityID/${data["Related.Entity.ID"]}/relation/${data["Relation.Type.ID"]}/update`;
6616
6676
  const res = yield api.POST(url, data, exports.Api.PrepReqParams(reqParams));
6617
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + data["Principal.Entity.ID"]);
6618
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + data["Related.Entity.ID"]);
6619
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.RelationType + exports.Api.ECacheKey.Id + data["Relation.Type.ID"]);
6677
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + data["Principal.Entity.ID"]);
6678
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Id + data["Related.Entity.ID"]);
6679
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.RelationType + exports.Api.ECacheKey.Id + data["Relation.Type.ID"]);
6620
6680
  if (data["Data.Entity.ID"]) {
6621
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Entity + exports.Api.ECacheKey.Id + data["Data.Entity.ID"]);
6681
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Relation + exports.Api.ECacheKey.Entity + exports.Api.ECacheKey.Id + data["Data.Entity.ID"]);
6622
6682
  }
6623
6683
  });
6624
6684
  }
@@ -6638,7 +6698,7 @@
6638
6698
  api = exports.ENVIRONMENT.Api().GetBruceApi();
6639
6699
  }
6640
6700
  filter = Object.assign({ relationTypeId: "", oneWayOnly: false, loadEntityData: false }, filter);
6641
- const cache = yield api.GetCacheItem(GetListCacheKey(entityId, filter), reqParams);
6701
+ const cache = api.GetCacheItem(GetListCacheKey(entityId, filter), reqParams);
6642
6702
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
6643
6703
  return cache.data;
6644
6704
  }
@@ -6658,7 +6718,7 @@
6658
6718
  rej(e);
6659
6719
  }
6660
6720
  }));
6661
- yield api.SetCacheItem({
6721
+ api.SetCacheItem({
6662
6722
  key: GetListCacheKey(entityId, filter),
6663
6723
  value: req,
6664
6724
  req: reqParams
@@ -6681,7 +6741,7 @@
6681
6741
  if (!api) {
6682
6742
  api = exports.ENVIRONMENT.Api().GetBruceApi();
6683
6743
  }
6684
- const cache = yield api.GetCacheItem(GetEntityCacheKey(entityId), reqParams);
6744
+ const cache = api.GetCacheItem(GetEntityCacheKey(entityId), reqParams);
6685
6745
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
6686
6746
  return cache.data;
6687
6747
  }
@@ -6696,7 +6756,7 @@
6696
6756
  rej(e);
6697
6757
  }
6698
6758
  }));
6699
- yield api.SetCacheItem({
6759
+ api.SetCacheItem({
6700
6760
  key: GetEntityCacheKey(entityId),
6701
6761
  value: prom,
6702
6762
  req: reqParams
@@ -6804,7 +6864,7 @@
6804
6864
  const reqs = [];
6805
6865
  for (let i = 0; i < sourceKeys.length; i++) {
6806
6866
  const sourceKey = sourceKeys[i];
6807
- const cache = yield api.GetCacheItem(GetCacheKey(sourceId, sourceKey), reqParams);
6867
+ const cache = api.GetCacheItem(GetCacheKey(sourceId, sourceKey), reqParams);
6808
6868
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
6809
6869
  reqs.push(cache.data);
6810
6870
  }
@@ -6900,7 +6960,7 @@
6900
6960
  }
6901
6961
  const res = yield api.POST("entitysource", source);
6902
6962
  const cacheKey = GetCacheKey(source["Source.ID"], source["SourceRecord.Key"]);
6903
- yield api.Cache.Remove(cacheKey);
6963
+ api.Cache.Remove(cacheKey);
6904
6964
  return {
6905
6965
  source: res
6906
6966
  };
@@ -7017,7 +7077,7 @@
7017
7077
  rej(e);
7018
7078
  }
7019
7079
  }));
7020
- yield api.SetCacheItem({
7080
+ api.SetCacheItem({
7021
7081
  key: GetCacheKey(id),
7022
7082
  value: req,
7023
7083
  req: reqParams
@@ -7042,7 +7102,7 @@
7042
7102
  if (!api) {
7043
7103
  api = exports.ENVIRONMENT.Api().GetBruceApi();
7044
7104
  }
7045
- const cache = yield api.GetCacheItem(GetListCacheKey(entityTypeId), reqParams);
7105
+ const cache = api.GetCacheItem(GetListCacheKey(entityTypeId), reqParams);
7046
7106
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
7047
7107
  return cache.data;
7048
7108
  }
@@ -7057,7 +7117,7 @@
7057
7117
  rej(e);
7058
7118
  }
7059
7119
  }));
7060
- yield api.SetCacheItem({
7120
+ api.SetCacheItem({
7061
7121
  key: GetListCacheKey(entityTypeId),
7062
7122
  value: req,
7063
7123
  req: reqParams
@@ -7081,7 +7141,7 @@
7081
7141
  }
7082
7142
  yield api.DELETE(`layer/${tagId}`, exports.Api.PrepReqParams(reqParams));
7083
7143
  api.Cache.Remove(GetCacheKey(tagId));
7084
- yield api.Cache.RemoveByStartsWith(GetListCacheKey());
7144
+ api.Cache.RemoveByStartsWith(GetListCacheKey());
7085
7145
  });
7086
7146
  }
7087
7147
  EntityTag.Delete = Delete;
@@ -7099,7 +7159,7 @@
7099
7159
  const url = data.ID ? `layer/${data.ID}` : "layer";
7100
7160
  const res = yield api.POST(url, data, exports.Api.PrepReqParams(reqParams));
7101
7161
  api.Cache.Remove(GetCacheKey(data.ID));
7102
- yield api.Cache.RemoveByStartsWith(GetListCacheKey());
7162
+ api.Cache.RemoveByStartsWith(GetListCacheKey());
7103
7163
  return {
7104
7164
  tag: res
7105
7165
  };
@@ -7189,7 +7249,7 @@
7189
7249
  if (!api) {
7190
7250
  api = exports.ENVIRONMENT.Api().GetBruceApi();
7191
7251
  }
7192
- const cache = yield api.GetCacheItem(GetCacheKey(entityId), reqParams);
7252
+ const cache = api.GetCacheItem(GetCacheKey(entityId), reqParams);
7193
7253
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
7194
7254
  return cache.data;
7195
7255
  }
@@ -7204,7 +7264,7 @@
7204
7264
  rej(e);
7205
7265
  }
7206
7266
  }));
7207
- yield api.SetCacheItem({
7267
+ api.SetCacheItem({
7208
7268
  key: GetCacheKey(entityId),
7209
7269
  value: prom,
7210
7270
  req: reqParams
@@ -7496,7 +7556,7 @@
7496
7556
  if (!api) {
7497
7557
  api = exports.ENVIRONMENT.Api().GetBruceApi();
7498
7558
  }
7499
- const cache = yield api.GetCacheItem(GetListCacheKey(), reqParams);
7559
+ const cache = api.GetCacheItem(GetListCacheKey(), reqParams);
7500
7560
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
7501
7561
  return cache.data;
7502
7562
  }
@@ -7511,7 +7571,7 @@
7511
7571
  rej(e);
7512
7572
  }
7513
7573
  }));
7514
- yield api.SetCacheItem({
7574
+ api.SetCacheItem({
7515
7575
  key: GetListCacheKey(),
7516
7576
  value: res,
7517
7577
  req: reqParams
@@ -7534,7 +7594,7 @@
7534
7594
  if (!api) {
7535
7595
  api = exports.ENVIRONMENT.Api().GetBruceApi();
7536
7596
  }
7537
- const cache = yield api.GetCacheItem(GetCacheKey(id), reqParams);
7597
+ const cache = api.GetCacheItem(GetCacheKey(id), reqParams);
7538
7598
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
7539
7599
  return cache.data;
7540
7600
  }
@@ -7549,7 +7609,7 @@
7549
7609
  rej(e);
7550
7610
  }
7551
7611
  }));
7552
- yield api.SetCacheItem({
7612
+ api.SetCacheItem({
7553
7613
  key: GetCacheKey(id),
7554
7614
  value: prom,
7555
7615
  req: reqParams
@@ -8227,7 +8287,7 @@
8227
8287
  throw ("File ID is required.");
8228
8288
  }
8229
8289
  const key = GetCacheKey(fileId);
8230
- const cache = yield api.GetCacheItem(key, reqParams);
8290
+ const cache = api.GetCacheItem(key, reqParams);
8231
8291
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
8232
8292
  return cache.data;
8233
8293
  }
@@ -8242,7 +8302,7 @@
8242
8302
  rej(e);
8243
8303
  }
8244
8304
  }));
8245
- yield api.SetCacheItem({
8305
+ api.SetCacheItem({
8246
8306
  key,
8247
8307
  value: prom,
8248
8308
  req: reqParams
@@ -8748,7 +8808,7 @@
8748
8808
  });
8749
8809
  const key = prom.programKeys.find(k => k.ProgramId === programId);
8750
8810
  // const key = GetCacheKey(programId);
8751
- // const cache = await api.GetCacheItem(key, reqParams);
8811
+ // const cache = api.GetCacheItem(key, reqParams);
8752
8812
  // if (cache?.found) {
8753
8813
  // return cache.data;
8754
8814
  // }
@@ -8763,7 +8823,7 @@
8763
8823
  // rej(e);
8764
8824
  // }
8765
8825
  // });
8766
- // await api.SetCacheItem({
8826
+ // api.SetCacheItem({
8767
8827
  // key,
8768
8828
  // value: prom,
8769
8829
  // req: reqParams
@@ -8785,7 +8845,7 @@
8785
8845
  if (!api) {
8786
8846
  api = exports.ENVIRONMENT.Api().GetBruceApi();
8787
8847
  }
8788
- const cache = yield api.GetCacheItem(GetListCacheKey(), reqParams);
8848
+ const cache = api.GetCacheItem(GetListCacheKey(), reqParams);
8789
8849
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
8790
8850
  return cache.data;
8791
8851
  }
@@ -8800,7 +8860,7 @@
8800
8860
  rej(e);
8801
8861
  }
8802
8862
  }));
8803
- yield api.SetCacheItem({
8863
+ api.SetCacheItem({
8804
8864
  key: GetListCacheKey(),
8805
8865
  value: req,
8806
8866
  req: reqParams
@@ -9023,7 +9083,7 @@
9023
9083
  if (!api) {
9024
9084
  api = exports.ENVIRONMENT.Api().GetBruceApi();
9025
9085
  }
9026
- const cache = yield api.GetCacheItem(GetCacheKey(tilesetId, loadFiles), reqParams);
9086
+ const cache = api.GetCacheItem(GetCacheKey(tilesetId, loadFiles), reqParams);
9027
9087
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
9028
9088
  return cache.data;
9029
9089
  }
@@ -9043,7 +9103,7 @@
9043
9103
  rej(e);
9044
9104
  }
9045
9105
  }));
9046
- yield api.SetCacheItem({
9106
+ api.SetCacheItem({
9047
9107
  key: GetCacheKey(tilesetId, loadFiles),
9048
9108
  value: prom,
9049
9109
  req: reqParams
@@ -9099,7 +9159,7 @@
9099
9159
  if (!api) {
9100
9160
  api = exports.ENVIRONMENT.Api().GetBruceApi();
9101
9161
  }
9102
- const cache = yield api.GetCacheItem(GetListCacheKey({
9162
+ const cache = api.GetCacheItem(GetListCacheKey({
9103
9163
  assertLocation: assertLocation,
9104
9164
  expandSettings: expandSettings,
9105
9165
  type: type
@@ -9139,7 +9199,7 @@
9139
9199
  rej(e);
9140
9200
  }
9141
9201
  }));
9142
- yield api.SetCacheItem({
9202
+ api.SetCacheItem({
9143
9203
  key: GetListCacheKey({
9144
9204
  assertLocation: assertLocation,
9145
9205
  expandSettings: expandSettings,
@@ -9166,8 +9226,8 @@
9166
9226
  api = exports.ENVIRONMENT.Api().GetBruceApi();
9167
9227
  }
9168
9228
  yield api.DELETE(`tileset/delete/${tilesetId}`, reqParams);
9169
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Tileset + exports.Api.ECacheKey.Id + tilesetId);
9170
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Tileset);
9229
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Tileset + exports.Api.ECacheKey.Id + tilesetId);
9230
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Tileset);
9171
9231
  });
9172
9232
  }
9173
9233
  Tileset.Delete = Delete;
@@ -9204,8 +9264,8 @@
9204
9264
  yield api.POST(`tileset/update/${data.id}`, data, exports.Api.PrepReqParams(reqParams));
9205
9265
  }
9206
9266
  }
9207
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Tileset + exports.Api.ECacheKey.Id + data.id);
9208
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Tileset);
9267
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Tileset + exports.Api.ECacheKey.Id + data.id);
9268
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Tileset);
9209
9269
  return {
9210
9270
  tileset: data
9211
9271
  };
@@ -9490,9 +9550,9 @@
9490
9550
  };
9491
9551
  data.ID = res.ID;
9492
9552
  yield api.POST(`tileset/${data.ID}/enableForAccounts`, req, reqParams);
9493
- yield api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"], data["Tileset.ID"]));
9494
- yield api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"]));
9495
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.PublishTileset + exports.Api.ECacheKey.TilesetAccess);
9553
+ api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"], data["Tileset.ID"]));
9554
+ api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"]));
9555
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.PublishTileset + exports.Api.ECacheKey.TilesetAccess);
9496
9556
  return {
9497
9557
  published: data
9498
9558
  };
@@ -9508,7 +9568,7 @@
9508
9568
  if (!accountId || !tilesetId) {
9509
9569
  throw ("Client account ID and tileset ID are required.");
9510
9570
  }
9511
- const cache = yield api.GetCacheItem(GetCacheKey(accountId, tilesetId), reqParams);
9571
+ const cache = api.GetCacheItem(GetCacheKey(accountId, tilesetId), reqParams);
9512
9572
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
9513
9573
  return cache.data;
9514
9574
  }
@@ -9523,7 +9583,7 @@
9523
9583
  rej(e);
9524
9584
  }
9525
9585
  }));
9526
- yield api.SetCacheItem({
9586
+ api.SetCacheItem({
9527
9587
  key: GetCacheKey(accountId, tilesetId),
9528
9588
  value: prom,
9529
9589
  req: reqParams
@@ -9541,7 +9601,7 @@
9541
9601
  if (!accountId) {
9542
9602
  throw ("Client account ID is required.");
9543
9603
  }
9544
- const cache = yield api.GetCacheItem(GetCacheKey(accountId), reqParams);
9604
+ const cache = api.GetCacheItem(GetCacheKey(accountId), reqParams);
9545
9605
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
9546
9606
  return cache.data;
9547
9607
  }
@@ -9556,7 +9616,7 @@
9556
9616
  rej(e);
9557
9617
  }
9558
9618
  }));
9559
- yield api.SetCacheItem({
9619
+ api.SetCacheItem({
9560
9620
  key: GetCacheKey(accountId),
9561
9621
  value: req,
9562
9622
  req: reqParams
@@ -9882,7 +9942,7 @@
9882
9942
  api = exports.ENVIRONMENT.Api().GetBruceApi();
9883
9943
  }
9884
9944
  const key = GetCacheKey(viewId, bookmarkId);
9885
- const cache = yield api.GetCacheItem(key, reqParams);
9945
+ const cache = api.GetCacheItem(key, reqParams);
9886
9946
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
9887
9947
  return cache.data;
9888
9948
  }
@@ -9897,7 +9957,7 @@
9897
9957
  rej(e);
9898
9958
  }
9899
9959
  }));
9900
- yield api.SetCacheItem({
9960
+ api.SetCacheItem({
9901
9961
  key,
9902
9962
  value: prom,
9903
9963
  req: reqParams
@@ -9939,7 +9999,7 @@
9939
9999
  if (!api) {
9940
10000
  api = exports.ENVIRONMENT.Api().GetBruceApi();
9941
10001
  }
9942
- const cache = yield api.GetCacheItem(GetListCacheKey(viewId), reqParams);
10002
+ const cache = api.GetCacheItem(GetListCacheKey(viewId), reqParams);
9943
10003
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
9944
10004
  return cache.data;
9945
10005
  }
@@ -9957,7 +10017,7 @@
9957
10017
  bookmark: item
9958
10018
  });
9959
10019
  });
9960
- yield api.SetCacheItem({
10020
+ api.SetCacheItem({
9961
10021
  key: GetCacheKey(viewId, item.ID),
9962
10022
  value: prom,
9963
10023
  req: reqParams
@@ -9971,7 +10031,7 @@
9971
10031
  rej(e);
9972
10032
  }
9973
10033
  }));
9974
- yield api.SetCacheItem({
10034
+ api.SetCacheItem({
9975
10035
  key: GetListCacheKey(viewId),
9976
10036
  value: req,
9977
10037
  req: reqParams
@@ -10018,7 +10078,7 @@
10018
10078
  "DisplayOrder.Start": 0
10019
10079
  };
10020
10080
  yield api.POST(`ui.view/${viewId}/slides/setOrder`, reqData, exports.Api.PrepReqParams(reqParams));
10021
- yield api.Cache.RemoveByStartsWith(GetListCacheKey(viewId));
10081
+ api.Cache.RemoveByStartsWith(GetListCacheKey(viewId));
10022
10082
  });
10023
10083
  }
10024
10084
  ProjectViewBookmark.SetOrder = SetOrder;
@@ -10078,7 +10138,7 @@
10078
10138
  api = exports.ENVIRONMENT.Api().GetBruceApi();
10079
10139
  }
10080
10140
  const key = GetCacheKey(viewId);
10081
- const cache = yield api.GetCacheItem(key, reqParams);
10141
+ const cache = api.GetCacheItem(key, reqParams);
10082
10142
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
10083
10143
  return cache.data;
10084
10144
  }
@@ -10093,7 +10153,7 @@
10093
10153
  rej(e);
10094
10154
  }
10095
10155
  }));
10096
- yield api.SetCacheItem({
10156
+ api.SetCacheItem({
10097
10157
  key,
10098
10158
  value: prom,
10099
10159
  req: reqParams
@@ -10113,7 +10173,7 @@
10113
10173
  if (!api) {
10114
10174
  api = exports.ENVIRONMENT.Api().GetBruceApi();
10115
10175
  }
10116
- const cache = yield api.GetCacheItem(GetListCacheKey(type), reqParams);
10176
+ const cache = api.GetCacheItem(GetListCacheKey(type), reqParams);
10117
10177
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
10118
10178
  return cache.data;
10119
10179
  }
@@ -10128,7 +10188,7 @@
10128
10188
  rej(e);
10129
10189
  }
10130
10190
  }));
10131
- yield api.SetCacheItem({
10191
+ api.SetCacheItem({
10132
10192
  key: GetListCacheKey(type),
10133
10193
  value: prom,
10134
10194
  req: reqParams
@@ -10722,7 +10782,7 @@
10722
10782
  if (!api) {
10723
10783
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
10724
10784
  }
10725
- const cache = yield api.GetCacheItem(GetCacheKey(id), reqParams);
10785
+ const cache = api.GetCacheItem(GetCacheKey(id), reqParams);
10726
10786
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
10727
10787
  return cache.data;
10728
10788
  }
@@ -10731,7 +10791,7 @@
10731
10791
  const data = yield api.GET(`accountbyid/${id}`, reqParams);
10732
10792
  // Update the cache by subdomain as well in case it's different to the ID.
10733
10793
  if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
10734
- yield api.SetCacheItem({
10794
+ api.SetCacheItem({
10735
10795
  key: data.Subdomain,
10736
10796
  value: prom,
10737
10797
  req: reqParams
@@ -10745,7 +10805,7 @@
10745
10805
  rej(e);
10746
10806
  }
10747
10807
  }));
10748
- yield api.SetCacheItem({
10808
+ api.SetCacheItem({
10749
10809
  key: GetCacheKey(id),
10750
10810
  value: prom,
10751
10811
  req: reqParams
@@ -10765,7 +10825,7 @@
10765
10825
  if (!api) {
10766
10826
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
10767
10827
  }
10768
- const cache = yield api.GetCacheItem(GetCacheKey(subdomain), reqParams);
10828
+ const cache = api.GetCacheItem(GetCacheKey(subdomain), reqParams);
10769
10829
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
10770
10830
  return cache.data;
10771
10831
  }
@@ -10774,7 +10834,7 @@
10774
10834
  const data = yield api.GET(`account/${subdomain}`, reqParams);
10775
10835
  // Update the cache by ID as well in case it's different to the subdomain.
10776
10836
  if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
10777
- yield api.SetCacheItem({
10837
+ api.SetCacheItem({
10778
10838
  key: data.ID,
10779
10839
  value: prom,
10780
10840
  req: reqParams
@@ -10788,7 +10848,7 @@
10788
10848
  rej(e);
10789
10849
  }
10790
10850
  }));
10791
- yield api.SetCacheItem({
10851
+ api.SetCacheItem({
10792
10852
  key: GetCacheKey(subdomain),
10793
10853
  value: prom,
10794
10854
  req: reqParams
@@ -10808,7 +10868,7 @@
10808
10868
  if (!api) {
10809
10869
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
10810
10870
  }
10811
- const cache = yield api.GetCacheItem(GetListCacheKey(api.GetSessionId()), reqParams);
10871
+ const cache = api.GetCacheItem(GetListCacheKey(api.GetSessionId()), reqParams);
10812
10872
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
10813
10873
  return cache.data;
10814
10874
  }
@@ -10825,7 +10885,7 @@
10825
10885
  rej(e);
10826
10886
  }
10827
10887
  }));
10828
- yield api.SetCacheItem({
10888
+ api.SetCacheItem({
10829
10889
  key: GetListCacheKey(api.GetSessionId()),
10830
10890
  value: prom,
10831
10891
  req: reqParams
@@ -10845,7 +10905,7 @@
10845
10905
  if (!api) {
10846
10906
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
10847
10907
  }
10848
- const cache = yield api.GetCacheItem(GetCacheKey(id, appId), reqParams);
10908
+ const cache = api.GetCacheItem(GetCacheKey(id, appId), reqParams);
10849
10909
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
10850
10910
  return cache.data;
10851
10911
  }
@@ -10863,7 +10923,7 @@
10863
10923
  rej(e);
10864
10924
  }
10865
10925
  }));
10866
- yield api.SetCacheItem({
10926
+ api.SetCacheItem({
10867
10927
  key: GetCacheKey(id, appId),
10868
10928
  value: prom,
10869
10929
  req: reqParams
@@ -10885,7 +10945,7 @@
10885
10945
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
10886
10946
  }
10887
10947
  const res = yield api.POST(`account/${id}/applicationSettings/${appId}`, data, reqParams);
10888
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + id);
10948
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + id);
10889
10949
  return {
10890
10950
  settings: res
10891
10951
  };
@@ -11214,7 +11274,7 @@
11214
11274
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11215
11275
  }
11216
11276
  const key = GetCacheKey(sessionId);
11217
- const cache = yield api.GetCacheItem(key, reqParams);
11277
+ const cache = api.GetCacheItem(key, reqParams);
11218
11278
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11219
11279
  return cache.data;
11220
11280
  }
@@ -11229,7 +11289,7 @@
11229
11289
  rej(e);
11230
11290
  }
11231
11291
  }));
11232
- yield api.SetCacheItem({
11292
+ api.SetCacheItem({
11233
11293
  key,
11234
11294
  value: prom,
11235
11295
  req: reqParams,
@@ -11606,13 +11666,22 @@
11606
11666
  if (!api) {
11607
11667
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11608
11668
  }
11609
- const cache = yield api.GetCacheItem(GetCacheKey(id, accountId), reqParams);
11669
+ const cacheKey = GetCacheKey(id, accountId);
11670
+ const cache = api.GetCacheItem(cacheKey, reqParams);
11610
11671
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11611
11672
  return cache.data;
11612
11673
  }
11613
11674
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
11614
11675
  try {
11615
- const data = yield api.GET(`user/${id}${accountId ? `?clientAccountID=${accountId}` : ""}`, reqParams);
11676
+ const urlParams = new URLSearchParams();
11677
+ if (accountId) {
11678
+ urlParams.append("clientAccountID", accountId);
11679
+ }
11680
+ let url = `user/${id}`;
11681
+ if (urlParams.toString().length) {
11682
+ url += "?" + urlParams.toString();
11683
+ }
11684
+ const data = yield api.GET(url, reqParams);
11616
11685
  res({
11617
11686
  user: data
11618
11687
  });
@@ -11621,8 +11690,8 @@
11621
11690
  rej(e);
11622
11691
  }
11623
11692
  }));
11624
- yield api.SetCacheItem({
11625
- key: GetCacheKey(id, accountId),
11693
+ api.SetCacheItem({
11694
+ key: cacheKey,
11626
11695
  value: prom,
11627
11696
  req: reqParams
11628
11697
  });
@@ -11661,10 +11730,10 @@
11661
11730
  const res = yield api.POST(`user/${data.ID}`, data, reqParams);
11662
11731
  api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + data.ID);
11663
11732
  if (data.Type == EType.AccessToken) {
11664
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
11733
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
11665
11734
  }
11666
11735
  else if (data.Type == EType.User) {
11667
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account);
11736
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account);
11668
11737
  }
11669
11738
  return {
11670
11739
  user: res
@@ -11686,7 +11755,7 @@
11686
11755
  if (!api) {
11687
11756
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11688
11757
  }
11689
- const cache = yield api.GetCacheItem(GetSettingsCacheKey(userId, appId), req);
11758
+ const cache = api.GetCacheItem(GetSettingsCacheKey(userId, appId), req);
11690
11759
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11691
11760
  return cache.data;
11692
11761
  }
@@ -11712,7 +11781,7 @@
11712
11781
  rej(e);
11713
11782
  }
11714
11783
  }));
11715
- yield api.SetCacheItem({
11784
+ api.SetCacheItem({
11716
11785
  key: GetSettingsCacheKey(userId, appId),
11717
11786
  value: prom,
11718
11787
  req: req
@@ -11808,7 +11877,7 @@
11808
11877
  if (!api) {
11809
11878
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11810
11879
  }
11811
- const cache = yield api.GetCacheItem(GetEmailCacheKey(email, accountId), reqParams);
11880
+ const cache = api.GetCacheItem(GetEmailCacheKey(email, accountId), reqParams);
11812
11881
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11813
11882
  return cache.data;
11814
11883
  }
@@ -11823,7 +11892,7 @@
11823
11892
  rej(e);
11824
11893
  }
11825
11894
  }));
11826
- yield api.SetCacheItem({
11895
+ api.SetCacheItem({
11827
11896
  key: GetEmailCacheKey(email, accountId),
11828
11897
  value: prom,
11829
11898
  req: reqParams
@@ -11849,7 +11918,7 @@
11849
11918
  if (!exclusive) {
11850
11919
  exclusive = false;
11851
11920
  }
11852
- const cache = exclusive ? null : yield api.GetCacheItem(GetListCacheKey(accountId), reqParams);
11921
+ const cache = exclusive ? null : api.GetCacheItem(GetListCacheKey(accountId), reqParams);
11853
11922
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11854
11923
  return cache.data;
11855
11924
  }
@@ -11867,7 +11936,7 @@
11867
11936
  req.then((data) => __awaiter(this, void 0, void 0, function* () {
11868
11937
  const users = data.users;
11869
11938
  for (let i = 0; i < users.length; i++) {
11870
- yield api.SetCacheItem({
11939
+ api.SetCacheItem({
11871
11940
  key: GetCacheKey(users[i].ID, accountId),
11872
11941
  value: {
11873
11942
  user: users[i]
@@ -11877,7 +11946,7 @@
11877
11946
  }
11878
11947
  }));
11879
11948
  if (!exclusive) {
11880
- yield api.SetCacheItem({
11949
+ api.SetCacheItem({
11881
11950
  key: GetListCacheKey(accountId),
11882
11951
  value: req,
11883
11952
  req: reqParams
@@ -12044,7 +12113,7 @@
12044
12113
  if (!api) {
12045
12114
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
12046
12115
  }
12047
- const cache = yield api.GetCacheItem(GetListCacheKey(accountId), reqParams);
12116
+ const cache = api.GetCacheItem(GetListCacheKey(accountId), reqParams);
12048
12117
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12049
12118
  return cache.data;
12050
12119
  }
@@ -12059,7 +12128,7 @@
12059
12128
  rej(e);
12060
12129
  }
12061
12130
  }));
12062
- yield api.SetCacheItem({
12131
+ api.SetCacheItem({
12063
12132
  key: GetListCacheKey(accountId),
12064
12133
  value: req,
12065
12134
  req: reqParams
@@ -12080,7 +12149,7 @@
12080
12149
  }
12081
12150
  yield api.DELETE(`accessToken/${id}`, reqParams);
12082
12151
  api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + id);
12083
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
12152
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
12084
12153
  });
12085
12154
  }
12086
12155
  AccessToken.Delete = Delete;
@@ -12105,7 +12174,7 @@
12105
12174
  data.Type = EType.AccessToken;
12106
12175
  }
12107
12176
  data = yield api.POST("accessToken", data, reqParams);
12108
- yield api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
12177
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
12109
12178
  return {
12110
12179
  user: data
12111
12180
  };
@@ -12309,7 +12378,7 @@
12309
12378
  api = exports.ENVIRONMENT.Api().GetBruceApi();
12310
12379
  }
12311
12380
  const accountId = api.AccountId;
12312
- const cache = yield api.GetCacheItem(GetCacheKey(accountId), reqParams);
12381
+ const cache = api.GetCacheItem(GetCacheKey(accountId), reqParams);
12313
12382
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12314
12383
  return cache.data;
12315
12384
  }
@@ -13322,7 +13391,7 @@
13322
13391
  if (!pageIndex) {
13323
13392
  pageIndex = 0;
13324
13393
  }
13325
- const cache = yield api.GetCacheItem(GetListCacheKey(type, pageIndex), reqParams);
13394
+ const cache = api.GetCacheItem(GetListCacheKey(type, pageIndex), reqParams);
13326
13395
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
13327
13396
  return cache.data;
13328
13397
  }
@@ -13347,7 +13416,7 @@
13347
13416
  rej(e);
13348
13417
  }
13349
13418
  }));
13350
- yield api.SetCacheItem({
13419
+ api.SetCacheItem({
13351
13420
  key: GetListCacheKey(type, pageIndex),
13352
13421
  value: prom,
13353
13422
  req: reqParams
@@ -13367,7 +13436,7 @@
13367
13436
  if (!api) {
13368
13437
  api = exports.ENVIRONMENT.Api().GetBruceApi();
13369
13438
  }
13370
- const cache = yield api.GetCacheItem(GetCacheKeyByRootId(rootId), reqParams);
13439
+ const cache = api.GetCacheItem(GetCacheKeyByRootId(rootId), reqParams);
13371
13440
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
13372
13441
  return cache.data;
13373
13442
  }
@@ -13382,7 +13451,7 @@
13382
13451
  rej(e);
13383
13452
  }
13384
13453
  }));
13385
- yield api.SetCacheItem({
13454
+ api.SetCacheItem({
13386
13455
  key: GetCacheKeyByRootId(rootId),
13387
13456
  value: prom,
13388
13457
  req: reqParams
@@ -13402,7 +13471,7 @@
13402
13471
  if (!api) {
13403
13472
  api = exports.ENVIRONMENT.Api().GetBruceApi();
13404
13473
  }
13405
- const cache = yield api.GetCacheItem(GetCacheKey(fileId), reqParams);
13474
+ const cache = api.GetCacheItem(GetCacheKey(fileId), reqParams);
13406
13475
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
13407
13476
  return cache.data;
13408
13477
  }
@@ -13417,7 +13486,7 @@
13417
13486
  rej(e);
13418
13487
  }
13419
13488
  }));
13420
- yield api.SetCacheItem({
13489
+ api.SetCacheItem({
13421
13490
  key: GetCacheKey(fileId),
13422
13491
  value: prom,
13423
13492
  req: reqParams
@@ -13637,7 +13706,7 @@
13637
13706
  if (!api) {
13638
13707
  api = exports.ENVIRONMENT.Api().GetBruceApi();
13639
13708
  }
13640
- const cache = yield api.GetCacheItem(GetCacheKey(pluginId), req);
13709
+ const cache = api.GetCacheItem(GetCacheKey(pluginId), req);
13641
13710
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
13642
13711
  return cache.data;
13643
13712
  }
@@ -13652,7 +13721,7 @@
13652
13721
  rej(e);
13653
13722
  }
13654
13723
  }));
13655
- yield api.SetCacheItem({
13724
+ api.SetCacheItem({
13656
13725
  key: GetCacheKey(pluginId),
13657
13726
  value: prom,
13658
13727
  req: req
@@ -13672,7 +13741,7 @@
13672
13741
  if (!api) {
13673
13742
  api = exports.ENVIRONMENT.Api().GetBruceApi();
13674
13743
  }
13675
- const cache = yield api.GetCacheItem(GetListCacheKey(), req);
13744
+ const cache = api.GetCacheItem(GetListCacheKey(), req);
13676
13745
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
13677
13746
  return cache.data;
13678
13747
  }
@@ -13687,7 +13756,7 @@
13687
13756
  rej(e);
13688
13757
  }
13689
13758
  }));
13690
- yield api.SetCacheItem({
13759
+ api.SetCacheItem({
13691
13760
  key: GetListCacheKey(),
13692
13761
  value: prom,
13693
13762
  req: req
@@ -13971,8 +14040,8 @@
13971
14040
  }
13972
14041
  const url = `source` + (data.ID == null ? "" : "/" + data.ID);
13973
14042
  const res = yield api.POST(url, data, exports.Api.PrepReqParams(reqParams));
13974
- yield api.Cache.Remove(GetCacheKey(data.ID));
13975
- yield api.Cache.Remove(GetListCacheKey());
14043
+ api.Cache.Remove(GetCacheKey(data.ID));
14044
+ api.Cache.Remove(GetListCacheKey());
13976
14045
  return {
13977
14046
  source: res
13978
14047
  };
@@ -13990,8 +14059,8 @@
13990
14059
  api = exports.ENVIRONMENT.Api().GetBruceApi();
13991
14060
  }
13992
14061
  yield api.DELETE(`source/${id}`, exports.Api.PrepReqParams(reqParams));
13993
- yield api.Cache.Remove(GetCacheKey(id));
13994
- yield api.Cache.Remove(GetListCacheKey());
14062
+ api.Cache.Remove(GetCacheKey(id));
14063
+ api.Cache.Remove(GetListCacheKey());
13995
14064
  });
13996
14065
  }
13997
14066
  DataSource.Delete = Delete;
@@ -14007,7 +14076,7 @@
14007
14076
  api = exports.ENVIRONMENT.Api().GetBruceApi();
14008
14077
  }
14009
14078
  reqParams = exports.Api.PrepReqParams(reqParams);
14010
- const cacheData = yield api.GetCacheItem(GetCacheKey(id), reqParams);
14079
+ const cacheData = api.GetCacheItem(GetCacheKey(id), reqParams);
14011
14080
  if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
14012
14081
  return cacheData.data;
14013
14082
  }
@@ -14043,7 +14112,7 @@
14043
14112
  api = exports.ENVIRONMENT.Api().GetBruceApi();
14044
14113
  }
14045
14114
  reqParams = exports.Api.PrepReqParams(reqParams);
14046
- const cacheData = yield api.GetCacheItem(GetListCacheKey(), reqParams);
14115
+ const cacheData = api.GetCacheItem(GetListCacheKey(), reqParams);
14047
14116
  if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
14048
14117
  return cacheData.data;
14049
14118
  }
@@ -14121,7 +14190,7 @@
14121
14190
  })(exports.DataSource || (exports.DataSource = {}));
14122
14191
 
14123
14192
  // This is updated with the package.json version on build.
14124
- const VERSION = "4.9.8";
14193
+ const VERSION = "5.0.0";
14125
14194
 
14126
14195
  exports.VERSION = VERSION;
14127
14196
  exports.AbstractApi = AbstractApi;