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.
@@ -1317,15 +1317,35 @@ var BruceApi;
1317
1317
  api: guardian
1318
1318
  });
1319
1319
  if (host === null || host === void 0 ? void 0 : host.location) {
1320
+ const settings = host.location.Settings;
1320
1321
  // Attempt to load regional base url.
1321
- if (host.location.BruceAPIURL) {
1322
- const regionalUrl = host.location.BruceAPIURL.replace("<ACCOUNT>", this.accountId).replace("<DOMAIN>", domain);
1322
+ // First try go through settings.
1323
+ let urlSet = false;
1324
+ if (settings === null || settings === void 0 ? void 0 : settings.BruceAPIURL) {
1325
+ let envUrl = settings.BruceAPIURL[env];
1326
+ if (envUrl) {
1327
+ envUrl = envUrl
1328
+ .replace("<ACCOUNTID>", this.accountId)
1329
+ .replace("<ACCOUNT>", this.accountId);
1330
+ if (envUrl && envUrl.length > 1) {
1331
+ this.baseUrl = envUrl;
1332
+ urlSet = true;
1333
+ }
1334
+ }
1335
+ }
1336
+ // Try go through host location's base url.
1337
+ // This may be wrong env which is why it's used as fallback right now.
1338
+ if (!urlSet && host.location.BruceAPIURL) {
1339
+ const regionalUrl = host.location.BruceAPIURL
1340
+ .replace("<ACCOUNTID>", this.accountId)
1341
+ .replace("<ACCOUNT>", this.accountId)
1342
+ .replace("<DOMAIN>", domain);
1323
1343
  if (regionalUrl && regionalUrl.length > 1) {
1324
1344
  this.baseUrl = regionalUrl;
1345
+ urlSet = true;
1325
1346
  }
1326
1347
  }
1327
1348
  // Attempt to load CDN settings.
1328
- const settings = host.location.Settings;
1329
1349
  if (settings === null || settings === void 0 ? void 0 : settings.CDN) {
1330
1350
  this.EntityCdnUrl = (_a = settings.CDN.entityURL) === null || _a === void 0 ? void 0 : _a[env];
1331
1351
  // We need to fix our configs.
@@ -5341,6 +5361,15 @@ var ClientFile;
5341
5361
  req,
5342
5362
  onProgress
5343
5363
  });
5364
+ // TODO: Check if we can add it to the request like the small file upload.
5365
+ if ((clientFile === null || clientFile === void 0 ? void 0 : clientFile.ID) && purpose) {
5366
+ yield UpdatePurpose({
5367
+ api,
5368
+ fileId: clientFile.ID,
5369
+ purpose,
5370
+ req
5371
+ });
5372
+ }
5344
5373
  }
5345
5374
  else {
5346
5375
  req.onProgress = (progress) => {
@@ -5350,16 +5379,13 @@ var ClientFile;
5350
5379
  uploaded: false
5351
5380
  });
5352
5381
  };
5382
+ if (purpose) {
5383
+ req.formData = {
5384
+ Purpose: purpose
5385
+ };
5386
+ }
5353
5387
  clientFile = yield api.UPLOAD("file/uploadNew", file, req);
5354
5388
  }
5355
- if ((clientFile === null || clientFile === void 0 ? void 0 : clientFile.ID) && purpose) {
5356
- yield UpdatePurpose({
5357
- api,
5358
- fileId: clientFile.ID,
5359
- purpose,
5360
- req
5361
- });
5362
- }
5363
5389
  onProgress === null || onProgress === void 0 ? void 0 : onProgress({
5364
5390
  percent: 100,
5365
5391
  uploaded: true