bruce-models 7.1.68 → 7.1.70

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.
@@ -84,6 +84,7 @@
84
84
  ECacheKey["DatabaseRegion"] = "databaseregion";
85
85
  ECacheKey["CustomForm"] = "customform";
86
86
  ECacheKey["ImportedFile"] = "importedfile";
87
+ ECacheKey["UIMarkup"] = "uimarkup";
87
88
  ECacheKey["Plugin"] = "plugin";
88
89
  ECacheKey["PluginIndexFile"] = "pluginindexfile";
89
90
  ECacheKey["EntityHistoricData"] = "entityhistoricdata";
@@ -353,6 +354,7 @@
353
354
  EConcept["TILESET"] = "ts";
354
355
  EConcept["UI_DASHBOARD_VIEW"] = "dbv";
355
356
  EConcept["UI_ENTITY_DISPLAY_SETTING"] = "s";
357
+ EConcept["UI_MARKUP"] = "um";
356
358
  EConcept["UI_PLUGIN"] = "pg";
357
359
  EConcept["UI_SLIDE"] = "pvs";
358
360
  EConcept["UI_SLIDE_GROUP"] = "sg";
@@ -418,6 +420,7 @@
418
420
  { concept: EConcept.TILESET, label: "Tileset", description: undefined },
419
421
  { concept: EConcept.UI_DASHBOARD_VIEW, label: "Dashboard View", description: undefined },
420
422
  { concept: EConcept.UI_ENTITY_DISPLAY_SETTING, label: "Style", description: undefined },
423
+ { concept: EConcept.UI_MARKUP, label: "Markup", description: undefined },
421
424
  { concept: EConcept.UI_PLUGIN, label: "Plugin", description: undefined },
422
425
  { concept: EConcept.UI_SLIDE, label: "Bookmark", description: undefined },
423
426
  { concept: EConcept.UI_SLIDE_GROUP, label: "Bookmark Group", description: undefined },
@@ -655,6 +658,8 @@
655
658
  return [exports.Api.ECacheKey.Tileset, exports.Api.ECacheKey.PublishTileset, exports.Api.ECacheKey.TilesetAccess];
656
659
  case exports.AccountConcept.EConcept.UI_ENTITY_DISPLAY_SETTING:
657
660
  return [exports.Api.ECacheKey.Style];
661
+ case exports.AccountConcept.EConcept.UI_MARKUP:
662
+ return [exports.Api.ECacheKey.UIMarkup];
658
663
  case exports.AccountConcept.EConcept.UI_PLUGIN:
659
664
  return [exports.Api.ECacheKey.Plugin, exports.Api.ECacheKey.PluginIndexFile];
660
665
  case exports.AccountConcept.EConcept.UI_SLIDE:
@@ -5290,13 +5295,18 @@
5290
5295
  }
5291
5296
  const data = yield Promise.all(reqs);
5292
5297
  // Populate array, while checking for already added types.
5298
+ // Batched ID requests can overlap.
5293
5299
  const types = [];
5300
+ const seenIds = new Set();
5294
5301
  for (const item of data) {
5295
5302
  for (const type of item.Items) {
5296
- appendInternalAttrSchema(type);
5297
- if (!types.find(x => x.ID == type.ID)) {
5298
- types.push(type);
5303
+ const key = String(type.ID);
5304
+ if (seenIds.has(key)) {
5305
+ continue;
5299
5306
  }
5307
+ seenIds.add(key);
5308
+ appendInternalAttrSchema(type);
5309
+ types.push(type);
5300
5310
  }
5301
5311
  }
5302
5312
  res({
@@ -6287,13 +6297,22 @@
6287
6297
  const reqs = [];
6288
6298
  if (reqIds.length > 0) {
6289
6299
  const req = api.POST(url, reqData, exports.Api.PrepReqParams(reqParams));
6300
+ const itemsById = req.then(data => {
6301
+ const map = new Map();
6302
+ for (const item of data.Items) {
6303
+ const id = String(item.Bruce.ID);
6304
+ if (!map.has(id)) {
6305
+ map.set(id, item);
6306
+ }
6307
+ }
6308
+ return map;
6309
+ });
6290
6310
  for (let i = 0; i < reqIds.length; i++) {
6291
6311
  const entityId = reqIds[i];
6292
6312
  const key = GetCacheKey(Object.assign(Object.assign({}, cacheKeyData), { entityId }));
6293
6313
  const prom = new Promise((res) => __awaiter(this, void 0, void 0, function* () {
6294
6314
  try {
6295
- const data = yield req;
6296
- const item = data.Items.find(x => x.Bruce.ID == entityId);
6315
+ const item = (yield itemsById).get(String(entityId));
6297
6316
  res({
6298
6317
  entity: item
6299
6318
  });
@@ -13183,11 +13202,19 @@
13183
13202
  rej(e);
13184
13203
  }
13185
13204
  }));
13205
+ const sourcesByKey = prom.then((sources) => {
13206
+ const map = new Map();
13207
+ for (const s of sources) {
13208
+ if (!map.has(s["SourceRecord.Key"])) {
13209
+ map.set(s["SourceRecord.Key"], s);
13210
+ }
13211
+ }
13212
+ return map;
13213
+ });
13186
13214
  for (let i = 0; i < reqKeys.length; i++) {
13187
13215
  const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
13188
13216
  try {
13189
- const sources = yield prom;
13190
- res(sources.find((s) => s["SourceRecord.Key"] === reqKeys[i]));
13217
+ res((yield sourcesByKey).get(reqKeys[i]));
13191
13218
  }
13192
13219
  catch (e) {
13193
13220
  rej(e);
@@ -13447,12 +13474,20 @@
13447
13474
  rej(e);
13448
13475
  }
13449
13476
  }));
13477
+ const tagsById = prom.then((tags) => {
13478
+ const map = new Map();
13479
+ for (const t of tags) {
13480
+ if (!map.has(t.ID)) {
13481
+ map.set(t.ID, t);
13482
+ }
13483
+ }
13484
+ return map;
13485
+ });
13450
13486
  for (let i = 0; i < reqIds.length; i++) {
13451
13487
  const id = reqIds[i];
13452
13488
  const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
13453
13489
  try {
13454
- const tags = yield prom;
13455
- const tag = tags.find((t) => t.ID === id);
13490
+ const tag = (yield tagsById).get(id);
13456
13491
  res({
13457
13492
  tag: tag
13458
13493
  });
@@ -14529,6 +14564,148 @@
14529
14564
  })(Circle = Markup.Circle || (Markup.Circle = {}));
14530
14565
  })(exports.Markup || (exports.Markup = {}));
14531
14566
 
14567
+ (function (UIMarkup) {
14568
+ /**
14569
+ * Returns a UI.Markup record.
14570
+ * @param params
14571
+ */
14572
+ function Get(params) {
14573
+ return __awaiter(this, void 0, void 0, function* () {
14574
+ let { api, markupId, req: reqParams } = params;
14575
+ if (markupId == null || markupId <= 0) {
14576
+ throw ("Markup ID is required.");
14577
+ }
14578
+ if (!api) {
14579
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
14580
+ }
14581
+ const key = GetCacheKey(markupId);
14582
+ const cache = api.GetCacheItem(key, reqParams);
14583
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
14584
+ return cache.data;
14585
+ }
14586
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
14587
+ try {
14588
+ const data = yield api.GET(`ui.markup/${markupId}`, exports.Api.PrepReqParams(reqParams));
14589
+ res({
14590
+ markup: data
14591
+ });
14592
+ }
14593
+ catch (e) {
14594
+ rej(e);
14595
+ }
14596
+ }));
14597
+ api.SetCacheItem({
14598
+ key,
14599
+ value: req,
14600
+ req: reqParams
14601
+ });
14602
+ return req;
14603
+ });
14604
+ }
14605
+ UIMarkup.Get = Get;
14606
+ /**
14607
+ * Returns the list of UI.Markup records.
14608
+ * @param params
14609
+ */
14610
+ function GetList(params) {
14611
+ return __awaiter(this, void 0, void 0, function* () {
14612
+ if (!params) {
14613
+ params = {};
14614
+ }
14615
+ let { api, req: reqParams } = params;
14616
+ if (!api) {
14617
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
14618
+ }
14619
+ const key = GetListCacheKey();
14620
+ const cache = api.GetCacheItem(key, reqParams);
14621
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
14622
+ return cache.data;
14623
+ }
14624
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
14625
+ var _a;
14626
+ try {
14627
+ const data = yield api.GET("ui.markups", exports.Api.PrepReqParams(reqParams));
14628
+ res({
14629
+ markups: (_a = data === null || data === void 0 ? void 0 : data.Items) !== null && _a !== void 0 ? _a : []
14630
+ });
14631
+ }
14632
+ catch (e) {
14633
+ rej(e);
14634
+ }
14635
+ }));
14636
+ api.SetCacheItem({
14637
+ key,
14638
+ value: req,
14639
+ req: reqParams
14640
+ });
14641
+ return req;
14642
+ });
14643
+ }
14644
+ UIMarkup.GetList = GetList;
14645
+ /**
14646
+ * Creates or updates a UI.Markup record.
14647
+ * @param params
14648
+ */
14649
+ function Update(params) {
14650
+ return __awaiter(this, void 0, void 0, function* () {
14651
+ let { markup, api, req: reqParams } = params;
14652
+ if (!api) {
14653
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
14654
+ }
14655
+ if (!markup) {
14656
+ markup = {};
14657
+ }
14658
+ const markupId = markup.ID && markup.ID > 0 ? markup.ID : 0;
14659
+ const res = yield api.POST(`ui.markup/${markupId}`, markup, exports.Api.PrepReqParams(reqParams));
14660
+ if (markup.ID && markup.ID > 0) {
14661
+ api.Cache.Remove(GetCacheKey(markup.ID));
14662
+ }
14663
+ if ((res === null || res === void 0 ? void 0 : res.ID) && res.ID > 0) {
14664
+ api.Cache.Remove(GetCacheKey(res.ID));
14665
+ }
14666
+ api.Cache.RemoveByStartsWith(GetListCacheKey());
14667
+ return {
14668
+ markup: res
14669
+ };
14670
+ });
14671
+ }
14672
+ UIMarkup.Update = Update;
14673
+ /**
14674
+ * Deletes a UI.Markup record.
14675
+ * @param params
14676
+ */
14677
+ function Delete(params) {
14678
+ return __awaiter(this, void 0, void 0, function* () {
14679
+ let { markupId, api, req: reqParams } = params;
14680
+ if (markupId == null || markupId <= 0) {
14681
+ throw ("Markup ID is required.");
14682
+ }
14683
+ if (!api) {
14684
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
14685
+ }
14686
+ yield api.DELETE(`ui.markup/${markupId}`, exports.Api.PrepReqParams(reqParams));
14687
+ api.Cache.Remove(GetCacheKey(markupId));
14688
+ api.Cache.RemoveByStartsWith(GetListCacheKey());
14689
+ });
14690
+ }
14691
+ UIMarkup.Delete = Delete;
14692
+ /**
14693
+ * Returns cache identifier for a UI.Markup record.
14694
+ * @param id
14695
+ */
14696
+ function GetCacheKey(id) {
14697
+ return `${exports.Api.ECacheKey.UIMarkup}${exports.Api.ECacheKey.Id}${id}`;
14698
+ }
14699
+ UIMarkup.GetCacheKey = GetCacheKey;
14700
+ /**
14701
+ * Returns cache identifier for the UI.Markup list.
14702
+ */
14703
+ function GetListCacheKey() {
14704
+ return exports.Api.ECacheKey.UIMarkup;
14705
+ }
14706
+ UIMarkup.GetListCacheKey = GetListCacheKey;
14707
+ })(exports.UIMarkup || (exports.UIMarkup = {}));
14708
+
14532
14709
  const DEFAULT_JOB_POLL_INTERVAL_MS = 1000;
14533
14710
  const DEFAULT_JOB_POLL_TIMEOUT_MS = 10 * 60 * 1000; // match server timeout (10 minutes)
14534
14711
  const NAVIGATOR_CHAT_EVENT_ENTITY_HIGHLIGHT_APPLIED = "entity_highlight_applied";
@@ -15625,8 +15802,9 @@
15625
15802
  }
15626
15803
  else if (tilesetIds.length > 1) {
15627
15804
  const tilesets = yield api.GET("ui.tilesets", exports.Api.PrepReqParams(reqParams));
15805
+ const tilesetIdsSet = new Set(tilesetIds);
15628
15806
  for (const tileset of tilesets) {
15629
- if (tilesetIds.indexOf(tileset.ID) >= 0) {
15807
+ if (tilesetIdsSet.has(tileset.ID)) {
15630
15808
  mapping[tileset.ID] = tileset.Type;
15631
15809
  }
15632
15810
  }
@@ -19258,7 +19436,7 @@
19258
19436
  })(exports.UrlUtils || (exports.UrlUtils = {}));
19259
19437
 
19260
19438
  // This is updated with the package.json version on build.
19261
- const VERSION = "7.1.68";
19439
+ const VERSION = "7.1.70";
19262
19440
 
19263
19441
  exports.VERSION = VERSION;
19264
19442
  exports.AbstractApi = AbstractApi;