bruce-models 7.1.13 → 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.
@@ -8303,7 +8303,7 @@
8303
8303
  }
8304
8304
  const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
8305
8305
  try {
8306
- const data = yield api.GET(`entityTypeTrigger/${entityTypeTriggerId}`, exports.Api.PrepReqParams(reqParams));
8306
+ const data = yield requestWithFallback(getSingleEndpoints(entityTypeTriggerId), (url) => api.GET(url, exports.Api.PrepReqParams(reqParams)));
8307
8307
  res({
8308
8308
  trigger: ParseResponse(data)
8309
8309
  });
@@ -8334,7 +8334,7 @@
8334
8334
  if (!api) {
8335
8335
  api = exports.ENVIRONMENT.Api().GetBruceApi();
8336
8336
  }
8337
- yield api.DELETE(`entityTypeTrigger/${entityTypeTriggerId}`, exports.Api.PrepReqParams(reqParams));
8337
+ yield requestWithFallback(getSingleEndpoints(entityTypeTriggerId), (url) => api.DELETE(url, exports.Api.PrepReqParams(reqParams)));
8338
8338
  api.Cache.Remove(GetCacheKey(entityTypeTriggerId));
8339
8339
  api.Cache.RemoveByStartsWith(GetListCacheKey());
8340
8340
  });
@@ -8357,7 +8357,7 @@
8357
8357
  }
8358
8358
  const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
8359
8359
  try {
8360
- const data = yield api.GET(entityTypeId ? `entityType/${entityTypeId}/triggers` : "entityTypeTriggers", exports.Api.PrepReqParams(reqParams));
8360
+ const data = yield requestWithFallback(getListEndpoints(entityTypeId), (url) => api.GET(url, exports.Api.PrepReqParams(reqParams)));
8361
8361
  res({
8362
8362
  triggers: ParseListResponse(data)
8363
8363
  });
@@ -8391,7 +8391,7 @@
8391
8391
  if (data.ID == null || data.ID === "") {
8392
8392
  data.ID = exports.ObjectUtils.UId();
8393
8393
  }
8394
- const res = yield api.POST(`entityTypeTrigger/${data.ID}`, data, exports.Api.PrepReqParams(reqParams));
8394
+ const res = yield requestWithFallback(getSingleEndpoints(data.ID), (url) => api.POST(url, data, exports.Api.PrepReqParams(reqParams)));
8395
8395
  api.Cache.Remove(GetCacheKey(data.ID));
8396
8396
  api.Cache.RemoveByStartsWith(GetListCacheKey());
8397
8397
  return {
@@ -8462,6 +8462,63 @@
8462
8462
  }
8463
8463
  return data;
8464
8464
  }
8465
+ function getSingleEndpoints(id) {
8466
+ return dedupe([
8467
+ `v1/entityTypeTrigger/${id}`,
8468
+ `v1/entityTypeTriggers/${id}`,
8469
+ `entityTypeTrigger/${id}`,
8470
+ `entityTypeTriggers/${id}`
8471
+ ]);
8472
+ }
8473
+ function getListEndpoints(entityTypeId) {
8474
+ if (entityTypeId) {
8475
+ return dedupe([
8476
+ `v1/entityType/${entityTypeId}/entityTypeTriggers`,
8477
+ `v1/entityType/${entityTypeId}/triggers`,
8478
+ `entityType/${entityTypeId}/entityTypeTriggers`,
8479
+ `entityType/${entityTypeId}/triggers`
8480
+ ]);
8481
+ }
8482
+ return dedupe([
8483
+ "v1/entityTypeTriggers",
8484
+ "entityTypeTriggers"
8485
+ ]);
8486
+ }
8487
+ function dedupe(values) {
8488
+ return [...new Set(values)];
8489
+ }
8490
+ function requestWithFallback(urls, perform) {
8491
+ return __awaiter(this, void 0, void 0, function* () {
8492
+ let lastErr;
8493
+ for (let i = 0; i < urls.length; i++) {
8494
+ const url = urls[i];
8495
+ try {
8496
+ return yield perform(url);
8497
+ }
8498
+ catch (e) {
8499
+ lastErr = e;
8500
+ const hasNext = i < urls.length - 1;
8501
+ if (!hasNext || !isUnknownEdgeError(e)) {
8502
+ throw e;
8503
+ }
8504
+ }
8505
+ }
8506
+ throw lastErr;
8507
+ });
8508
+ }
8509
+ function isUnknownEdgeError(error) {
8510
+ var _a, _b, _c, _d, _e;
8511
+ 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;
8512
+ if (status === 404) {
8513
+ return true;
8514
+ }
8515
+ 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;
8516
+ const message = typeof rawMessage === "string" ? rawMessage : JSON.stringify(rawMessage || {});
8517
+ return (message.toLowerCase().includes("specified edge is not found")
8518
+ || message.toLowerCase().includes("doesn't support requested method")
8519
+ || message.toLowerCase().includes("does not support requested method")
8520
+ || message.toLowerCase().includes("not found"));
8521
+ }
8465
8522
 
8466
8523
  (function (MathUtils) {
8467
8524
  /**
@@ -17108,7 +17165,7 @@
17108
17165
  })(exports.ChangeSet || (exports.ChangeSet = {}));
17109
17166
 
17110
17167
  // This is updated with the package.json version on build.
17111
- const VERSION = "7.1.13";
17168
+ const VERSION = "7.1.14";
17112
17169
 
17113
17170
  exports.VERSION = VERSION;
17114
17171
  exports.AbstractApi = AbstractApi;