bruce-models 7.1.12 → 7.1.14

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.
@@ -39,6 +39,7 @@ var Api;
39
39
  ECacheKey["Assembly"] = "assembly";
40
40
  ECacheKey["Entity"] = "entity";
41
41
  ECacheKey["EntityType"] = "entitytype";
42
+ ECacheKey["EntityTypeTrigger"] = "entitytypetrigger";
42
43
  ECacheKey["ProjectView"] = "projectview";
43
44
  ECacheKey["ProjectViewBookmark"] = "pvbookmark";
44
45
  ECacheKey["Tileset"] = "tileset";
@@ -8412,6 +8413,249 @@ var EntityTag;
8412
8413
  EntityTag.GetListCacheKey = GetListCacheKey;
8413
8414
  })(EntityTag || (EntityTag = {}));
8414
8415
 
8416
+ /**
8417
+ * Describes the "BruceEntityTypeTrigger" concept within Nextspace.
8418
+ * These records define trigger rules that are scoped to an Entity Type.
8419
+ */
8420
+ var EntityTypeTrigger;
8421
+ (function (EntityTypeTrigger) {
8422
+ /**
8423
+ * Gets a single Entity Type Trigger record.
8424
+ * @param params
8425
+ */
8426
+ function Get(params) {
8427
+ return __awaiter(this, void 0, void 0, function* () {
8428
+ let { api, entityTypeTriggerId, req: reqParams } = params;
8429
+ if (entityTypeTriggerId == null || entityTypeTriggerId === "") {
8430
+ throw ("Entity Type Trigger ID is required.");
8431
+ }
8432
+ if (!api) {
8433
+ api = ENVIRONMENT.Api().GetBruceApi();
8434
+ }
8435
+ const key = GetCacheKey(entityTypeTriggerId);
8436
+ const cache = api.GetCacheItem(key, reqParams);
8437
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
8438
+ return cache.data;
8439
+ }
8440
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
8441
+ try {
8442
+ const data = yield requestWithFallback(getSingleEndpoints(entityTypeTriggerId), (url) => api.GET(url, Api.PrepReqParams(reqParams)));
8443
+ res({
8444
+ trigger: ParseResponse(data)
8445
+ });
8446
+ }
8447
+ catch (e) {
8448
+ rej(e);
8449
+ }
8450
+ }));
8451
+ api.SetCacheItem({
8452
+ key,
8453
+ value: req,
8454
+ req: reqParams
8455
+ });
8456
+ return req;
8457
+ });
8458
+ }
8459
+ EntityTypeTrigger.Get = Get;
8460
+ /**
8461
+ * Deletes an Entity Type Trigger record.
8462
+ * @param params
8463
+ */
8464
+ function Delete(params) {
8465
+ return __awaiter(this, void 0, void 0, function* () {
8466
+ let { api, entityTypeTriggerId, req: reqParams } = params;
8467
+ if (entityTypeTriggerId == null || entityTypeTriggerId === "") {
8468
+ throw ("Entity Type Trigger ID is required.");
8469
+ }
8470
+ if (!api) {
8471
+ api = ENVIRONMENT.Api().GetBruceApi();
8472
+ }
8473
+ yield requestWithFallback(getSingleEndpoints(entityTypeTriggerId), (url) => api.DELETE(url, Api.PrepReqParams(reqParams)));
8474
+ api.Cache.Remove(GetCacheKey(entityTypeTriggerId));
8475
+ api.Cache.RemoveByStartsWith(GetListCacheKey());
8476
+ });
8477
+ }
8478
+ EntityTypeTrigger.Delete = Delete;
8479
+ /**
8480
+ * Gets a list of Entity Type Trigger records.
8481
+ * @param params
8482
+ */
8483
+ function GetList(params) {
8484
+ return __awaiter(this, void 0, void 0, function* () {
8485
+ let { api, entityTypeId, req: reqParams } = params;
8486
+ if (!api) {
8487
+ api = ENVIRONMENT.Api().GetBruceApi();
8488
+ }
8489
+ const key = GetListCacheKey(entityTypeId);
8490
+ const cache = api.GetCacheItem(key, reqParams);
8491
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
8492
+ return cache.data;
8493
+ }
8494
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
8495
+ try {
8496
+ const data = yield requestWithFallback(getListEndpoints(entityTypeId), (url) => api.GET(url, Api.PrepReqParams(reqParams)));
8497
+ res({
8498
+ triggers: ParseListResponse(data)
8499
+ });
8500
+ }
8501
+ catch (e) {
8502
+ rej(e);
8503
+ }
8504
+ }));
8505
+ api.SetCacheItem({
8506
+ key,
8507
+ value: req,
8508
+ req: reqParams
8509
+ });
8510
+ return req;
8511
+ });
8512
+ }
8513
+ EntityTypeTrigger.GetList = GetList;
8514
+ /**
8515
+ * Creates or updates an Entity Type Trigger record.
8516
+ * @param params
8517
+ */
8518
+ function Update(params) {
8519
+ return __awaiter(this, void 0, void 0, function* () {
8520
+ let { api, trigger: data, req: reqParams } = params;
8521
+ if (!api) {
8522
+ api = ENVIRONMENT.Api().GetBruceApi();
8523
+ }
8524
+ if (!data) {
8525
+ data = {};
8526
+ }
8527
+ if (data.ID == null || data.ID === "") {
8528
+ data.ID = ObjectUtils.UId();
8529
+ }
8530
+ const res = yield requestWithFallback(getSingleEndpoints(data.ID), (url) => api.POST(url, data, Api.PrepReqParams(reqParams)));
8531
+ api.Cache.Remove(GetCacheKey(data.ID));
8532
+ api.Cache.RemoveByStartsWith(GetListCacheKey());
8533
+ return {
8534
+ trigger: ParseResponse(res)
8535
+ };
8536
+ });
8537
+ }
8538
+ EntityTypeTrigger.Update = Update;
8539
+ /**
8540
+ * Normalizes response from trigger get/update endpoints.
8541
+ * Supports wrapper payloads and direct object payloads.
8542
+ */
8543
+ function ParseResponse(response) {
8544
+ var _a, _b, _c, _d, _e, _f;
8545
+ const parsed = parseObject$1(response);
8546
+ const parsedResult = (_a = parseObject$1(parsed === null || parsed === void 0 ? void 0 : parsed.Result)) !== null && _a !== void 0 ? _a : parsed === null || parsed === void 0 ? void 0 : parsed.Result;
8547
+ return (_f = (_e = (_d = (_c = (_b = parsed === null || parsed === void 0 ? void 0 : parsed.EntityTypeTrigger) !== null && _b !== void 0 ? _b : parsed === null || parsed === void 0 ? void 0 : parsed.BruceEntityTypeTrigger) !== null && _c !== void 0 ? _c : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.EntityTypeTrigger) !== null && _d !== void 0 ? _d : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.BruceEntityTypeTrigger) !== null && _e !== void 0 ? _e : parsedResult) !== null && _f !== void 0 ? _f : parsed;
8548
+ }
8549
+ EntityTypeTrigger.ParseResponse = ParseResponse;
8550
+ /**
8551
+ * Normalizes response from trigger list endpoints.
8552
+ * Supports list wrappers and direct arrays.
8553
+ */
8554
+ function ParseListResponse(response) {
8555
+ var _a, _b, _c, _d, _e, _f, _g, _h;
8556
+ const parsed = parseObject$1(response);
8557
+ const parsedResult = (_a = parseObject$1(parsed === null || parsed === void 0 ? void 0 : parsed.Result)) !== null && _a !== void 0 ? _a : parsed === null || parsed === void 0 ? void 0 : parsed.Result;
8558
+ const list = (_h = (_g = (_f = (_e = (_d = (_c = (_b = parsed === null || parsed === void 0 ? void 0 : parsed.Items) !== null && _b !== void 0 ? _b : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.Items) !== null && _c !== void 0 ? _c : parsed === null || parsed === void 0 ? void 0 : parsed.EntityTypeTriggers) !== null && _d !== void 0 ? _d : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.EntityTypeTriggers) !== null && _e !== void 0 ? _e : parsed === null || parsed === void 0 ? void 0 : parsed.BruceEntityTypeTriggers) !== null && _f !== void 0 ? _f : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.BruceEntityTypeTriggers) !== null && _g !== void 0 ? _g : parsedResult) !== null && _h !== void 0 ? _h : parsed;
8559
+ if (Array.isArray(list)) {
8560
+ return list;
8561
+ }
8562
+ return [];
8563
+ }
8564
+ EntityTypeTrigger.ParseListResponse = ParseListResponse;
8565
+ /**
8566
+ * Returns cache identifier for an Entity Type Trigger record.
8567
+ * @param id
8568
+ * @returns
8569
+ */
8570
+ function GetCacheKey(id) {
8571
+ return `${Api.ECacheKey.EntityTypeTrigger}${Api.ECacheKey.Id}${id}`;
8572
+ }
8573
+ EntityTypeTrigger.GetCacheKey = GetCacheKey;
8574
+ /**
8575
+ * Returns cache identifier for a list of Entity Type Triggers.
8576
+ * @param entityTypeId
8577
+ * @returns
8578
+ */
8579
+ function GetListCacheKey(entityTypeId) {
8580
+ if (entityTypeId) {
8581
+ return `${Api.ECacheKey.EntityTypeTrigger}${Api.ECacheKey.EntityType}${Api.ECacheKey.Id}${entityTypeId}`;
8582
+ }
8583
+ return Api.ECacheKey.EntityTypeTrigger;
8584
+ }
8585
+ EntityTypeTrigger.GetListCacheKey = GetListCacheKey;
8586
+ })(EntityTypeTrigger || (EntityTypeTrigger = {}));
8587
+ function parseObject$1(data) {
8588
+ if (data == null || data == undefined) {
8589
+ return null;
8590
+ }
8591
+ if (typeof data == "string") {
8592
+ try {
8593
+ return JSON.parse(data);
8594
+ }
8595
+ catch (_a) {
8596
+ return null;
8597
+ }
8598
+ }
8599
+ return data;
8600
+ }
8601
+ function getSingleEndpoints(id) {
8602
+ return dedupe([
8603
+ `v1/entityTypeTrigger/${id}`,
8604
+ `v1/entityTypeTriggers/${id}`,
8605
+ `entityTypeTrigger/${id}`,
8606
+ `entityTypeTriggers/${id}`
8607
+ ]);
8608
+ }
8609
+ function getListEndpoints(entityTypeId) {
8610
+ if (entityTypeId) {
8611
+ return dedupe([
8612
+ `v1/entityType/${entityTypeId}/entityTypeTriggers`,
8613
+ `v1/entityType/${entityTypeId}/triggers`,
8614
+ `entityType/${entityTypeId}/entityTypeTriggers`,
8615
+ `entityType/${entityTypeId}/triggers`
8616
+ ]);
8617
+ }
8618
+ return dedupe([
8619
+ "v1/entityTypeTriggers",
8620
+ "entityTypeTriggers"
8621
+ ]);
8622
+ }
8623
+ function dedupe(values) {
8624
+ return [...new Set(values)];
8625
+ }
8626
+ function requestWithFallback(urls, perform) {
8627
+ return __awaiter(this, void 0, void 0, function* () {
8628
+ let lastErr;
8629
+ for (let i = 0; i < urls.length; i++) {
8630
+ const url = urls[i];
8631
+ try {
8632
+ return yield perform(url);
8633
+ }
8634
+ catch (e) {
8635
+ lastErr = e;
8636
+ const hasNext = i < urls.length - 1;
8637
+ if (!hasNext || !isUnknownEdgeError(e)) {
8638
+ throw e;
8639
+ }
8640
+ }
8641
+ }
8642
+ throw lastErr;
8643
+ });
8644
+ }
8645
+ function isUnknownEdgeError(error) {
8646
+ var _a, _b, _c, _d, _e;
8647
+ const status = (_b = (_a = error === null || error === void 0 ? void 0 : error.StatusCode) !== null && _a !== void 0 ? _a : error === null || error === void 0 ? void 0 : error.status) !== null && _b !== void 0 ? _b : error === null || error === void 0 ? void 0 : error.statusCode;
8648
+ if (status === 404) {
8649
+ return true;
8650
+ }
8651
+ const rawMessage = (_e = (_d = (_c = error === null || error === void 0 ? void 0 : error.Message) !== null && _c !== void 0 ? _c : error === null || error === void 0 ? void 0 : error.message) !== null && _d !== void 0 ? _d : error === null || error === void 0 ? void 0 : error.Result) !== null && _e !== void 0 ? _e : error;
8652
+ const message = typeof rawMessage === "string" ? rawMessage : JSON.stringify(rawMessage || {});
8653
+ return (message.toLowerCase().includes("specified edge is not found")
8654
+ || message.toLowerCase().includes("doesn't support requested method")
8655
+ || message.toLowerCase().includes("does not support requested method")
8656
+ || message.toLowerCase().includes("not found"));
8657
+ }
8658
+
8415
8659
  var MathUtils;
8416
8660
  (function (MathUtils) {
8417
8661
  /**
@@ -17242,7 +17486,7 @@ var ChangeSet;
17242
17486
  })(ChangeSet || (ChangeSet = {}));
17243
17487
 
17244
17488
  // This is updated with the package.json version on build.
17245
- const VERSION = "7.1.12";
17489
+ const VERSION = "7.1.14";
17246
17490
 
17247
- export { VERSION, Assembly, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, GeoJson, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewBookmarkGroup, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, UserMfaMethod, Account, AccountInvite, AccountFeatures, AccountLimits, AccountTemplate, AccountType, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, DataLabGroup, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportedFile, ExportBrz, ExportUsd, Markup, Uploader, Plugin, ENVIRONMENT, DataSource, Scenario, Tracking, NavigatorChatClient, NavigatorMcpWebSocketClient, ChangeSet };
17491
+ export { VERSION, Assembly, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, GeoJson, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityTypeTrigger, EntityType, Entity, EntityCoords, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewBookmarkGroup, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, UserMfaMethod, Account, AccountInvite, AccountFeatures, AccountLimits, AccountTemplate, AccountType, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, DataLabGroup, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportedFile, ExportBrz, ExportUsd, Markup, Uploader, Plugin, ENVIRONMENT, DataSource, Scenario, Tracking, NavigatorChatClient, NavigatorMcpWebSocketClient, ChangeSet };
17248
17492
  //# sourceMappingURL=bruce-models.es5.js.map