bruce-models 2.3.1 → 2.3.3

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.
@@ -1294,15 +1294,35 @@
1294
1294
  api: guardian
1295
1295
  });
1296
1296
  if (host === null || host === void 0 ? void 0 : host.location) {
1297
+ const settings = host.location.Settings;
1297
1298
  // Attempt to load regional base url.
1298
- if (host.location.BruceAPIURL) {
1299
- const regionalUrl = host.location.BruceAPIURL.replace("<ACCOUNT>", this.accountId).replace("<DOMAIN>", domain);
1299
+ // First try go through settings.
1300
+ let urlSet = false;
1301
+ if (settings === null || settings === void 0 ? void 0 : settings.BruceAPIURL) {
1302
+ let envUrl = settings.BruceAPIURL[env];
1303
+ if (envUrl) {
1304
+ envUrl = envUrl
1305
+ .replace("<ACCOUNTID>", this.accountId)
1306
+ .replace("<ACCOUNT>", this.accountId);
1307
+ if (envUrl && envUrl.length > 1) {
1308
+ this.baseUrl = envUrl;
1309
+ urlSet = true;
1310
+ }
1311
+ }
1312
+ }
1313
+ // Try go through host location's base url.
1314
+ // This may be wrong env which is why it's used as fallback right now.
1315
+ if (!urlSet && host.location.BruceAPIURL) {
1316
+ const regionalUrl = host.location.BruceAPIURL
1317
+ .replace("<ACCOUNTID>", this.accountId)
1318
+ .replace("<ACCOUNT>", this.accountId)
1319
+ .replace("<DOMAIN>", domain);
1300
1320
  if (regionalUrl && regionalUrl.length > 1) {
1301
1321
  this.baseUrl = regionalUrl;
1322
+ urlSet = true;
1302
1323
  }
1303
1324
  }
1304
1325
  // Attempt to load CDN settings.
1305
- const settings = host.location.Settings;
1306
1326
  if (settings === null || settings === void 0 ? void 0 : settings.CDN) {
1307
1327
  this.EntityCdnUrl = (_a = settings.CDN.entityURL) === null || _a === void 0 ? void 0 : _a[env];
1308
1328
  // We need to fix our configs.
@@ -5200,6 +5220,15 @@
5200
5220
  req,
5201
5221
  onProgress
5202
5222
  });
5223
+ // TODO: Check if we can add it to the request like the small file upload.
5224
+ if ((clientFile === null || clientFile === void 0 ? void 0 : clientFile.ID) && purpose) {
5225
+ yield UpdatePurpose({
5226
+ api,
5227
+ fileId: clientFile.ID,
5228
+ purpose,
5229
+ req
5230
+ });
5231
+ }
5203
5232
  }
5204
5233
  else {
5205
5234
  req.onProgress = (progress) => {
@@ -5209,16 +5238,13 @@
5209
5238
  uploaded: false
5210
5239
  });
5211
5240
  };
5241
+ if (purpose) {
5242
+ req.formData = {
5243
+ Purpose: purpose
5244
+ };
5245
+ }
5212
5246
  clientFile = yield api.UPLOAD("file/uploadNew", file, req);
5213
5247
  }
5214
- if ((clientFile === null || clientFile === void 0 ? void 0 : clientFile.ID) && purpose) {
5215
- yield UpdatePurpose({
5216
- api,
5217
- fileId: clientFile.ID,
5218
- purpose,
5219
- req
5220
- });
5221
- }
5222
5248
  onProgress === null || onProgress === void 0 ? void 0 : onProgress({
5223
5249
  percent: 100,
5224
5250
  uploaded: true