bruce-models 1.7.8 → 1.8.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.
@@ -1070,15 +1070,18 @@
1070
1070
  ssidHeader: "x-sessionid"
1071
1071
  });
1072
1072
  this.loadCancelled = false;
1073
- let { accountId, env, cam, loadRegionalBaseUrl } = params;
1073
+ let { accountId, env, cam, loadRegionalBaseUrl, loadConfig } = params;
1074
1074
  this.accountId = accountId;
1075
1075
  this.env = env !== null && env !== void 0 ? env : exports.Api.EEnv.PROD;
1076
- if (loadRegionalBaseUrl && !cam) {
1076
+ if (loadRegionalBaseUrl) {
1077
+ loadConfig = true;
1078
+ }
1079
+ if (!cam && loadConfig) {
1077
1080
  cam = new exports.CamApi.Api({
1078
1081
  env: this.env
1079
1082
  });
1080
1083
  }
1081
- this.loadProm = this.init(cam, loadRegionalBaseUrl);
1084
+ this.loadProm = this.init(cam, loadConfig);
1082
1085
  }
1083
1086
  get MessageBroker() {
1084
1087
  return this.messageBroker;
@@ -1091,11 +1094,11 @@
1091
1094
  /**
1092
1095
  * Loads regional base url and sets up message broker.
1093
1096
  * @param cam Required for loading regional base url.
1094
- * @param loadRegionalUrl
1097
+ * @param loadConfig
1095
1098
  * @returns
1096
1099
  */
1097
- init(cam, loadRegionalUrl) {
1098
- var _a;
1100
+ init(cam, loadConfig) {
1101
+ var _a, _b, _c;
1099
1102
  return __awaiter(this, void 0, void 0, function* () {
1100
1103
  if (!this.accountId) {
1101
1104
  throw ("accountId is required.");
@@ -1121,32 +1124,47 @@
1121
1124
  throw ("Specified Environment is not valid. SuppliedEnv=" + env);
1122
1125
  }
1123
1126
  this.baseUrl = url;
1124
- if (cam) {
1125
- if (loadRegionalUrl) {
1126
- // Attempt to load an account specific base url.
1127
- // This could be one with a region specific endpoint.
1128
- try {
1129
- const settings = (yield exports.Account.GetAppSettings({
1130
- api: cam,
1131
- accountId: this.accountId,
1132
- appId: exports.Account.EAppId.BruceApi
1133
- })).settings;
1134
- if (this.loadCancelled) {
1135
- console.warn("BruceApi: Loading was cancelled due to SetBaseUrl being called, not setting regional base url.");
1136
- return;
1137
- }
1138
- let endpoint = (_a = settings.BruceAPIURL) === null || _a === void 0 ? void 0 : _a[env];
1139
- if (typeof endpoint == "string") {
1140
- if (!endpoint.endsWith("/")) {
1141
- endpoint += "/";
1142
- }
1143
- this.baseUrl = endpoint;
1127
+ if (cam && loadConfig) {
1128
+ // Attempt to load an account specific base url.
1129
+ // This could be one with a region specific endpoint.
1130
+ try {
1131
+ const settings = (yield exports.Account.GetAppSettings({
1132
+ api: cam,
1133
+ accountId: this.accountId,
1134
+ appId: exports.Account.EAppId.BruceApi
1135
+ })).settings;
1136
+ if (this.loadCancelled) {
1137
+ console.warn("BruceApi: Loading was cancelled due to SetBaseUrl being called, not setting regional base url.");
1138
+ return;
1139
+ }
1140
+ let endpoint = (_a = settings.BruceAPIURL) === null || _a === void 0 ? void 0 : _a[env];
1141
+ if (typeof endpoint == "string") {
1142
+ if (!endpoint.endsWith("/")) {
1143
+ endpoint += "/";
1144
1144
  }
1145
+ this.baseUrl = endpoint;
1145
1146
  }
1146
- catch (e) {
1147
- console.error(e);
1147
+ const api = new BruceApi.Api({
1148
+ accountId: this.accountId,
1149
+ cam: cam,
1150
+ env: this.env,
1151
+ // Must be false.
1152
+ // Else we get stuck in nested init loop.
1153
+ loadConfig: false
1154
+ });
1155
+ // CDN urls.
1156
+ const region = (yield exports.Account.GetDbRegions({
1157
+ api,
1158
+ key: settings.DBServer
1159
+ })).regions[0];
1160
+ if (region === null || region === void 0 ? void 0 : region.CDN) {
1161
+ this.EntityCdnUrl = (_b = region.CDN.entityURL) === null || _b === void 0 ? void 0 : _b[env];
1162
+ this.LegacyTilesetCdnUrl = (_c = region.CDN.legacyTilesetURL) === null || _c === void 0 ? void 0 : _c[env];
1148
1163
  }
1149
1164
  }
1165
+ catch (e) {
1166
+ console.error(e);
1167
+ }
1150
1168
  }
1151
1169
  try {
1152
1170
  this.messageBroker = new exports.MessageBroker.WebSocketBroker(this.baseUrl, this.env);
@@ -3727,9 +3745,6 @@
3727
3745
  function Update(params) {
3728
3746
  return __awaiter(this, void 0, void 0, function* () {
3729
3747
  const { api, tag: data, req: reqParams } = params;
3730
- if (!(data === null || data === void 0 ? void 0 : data.ID)) {
3731
- throw ("Tag ID is required.");
3732
- }
3733
3748
  const url = data.ID ? `layer/${data.ID}` : "layer";
3734
3749
  const res = yield api.POST(url, data, exports.Api.PrepReqParams(reqParams));
3735
3750
  api.Cache.Remove(GetCacheKey(data.ID));