bruce-models 3.2.4 → 3.2.6
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.
- package/dist/bruce-models.es5.js +64 -10
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +64 -10
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/api-getters.js +12 -3
- package/dist/lib/api/api-getters.js.map +1 -1
- package/dist/lib/api/bruce-api.js +19 -0
- package/dist/lib/api/bruce-api.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/client-file/client-file.js +14 -4
- package/dist/lib/client-file/client-file.js.map +1 -1
- package/dist/lib/server/hosting-location.js +18 -2
- package/dist/lib/server/hosting-location.js.map +1 -1
- package/dist/types/account/account-settings.d.ts +2 -0
- package/dist/types/api/api-getters.d.ts +2 -0
- package/dist/types/api/bruce-api.d.ts +8 -0
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/client-file/client-file.d.ts +2 -0
- package/dist/types/server/hosting-location.d.ts +3 -0
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -1128,13 +1128,28 @@
|
|
|
1128
1128
|
*/
|
|
1129
1129
|
function GetKeyByAccountId(params) {
|
|
1130
1130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1131
|
-
let { accountId, apiSettings, api, req } = params;
|
|
1131
|
+
let { accountId, apiSettings, api, account, req } = params;
|
|
1132
1132
|
if (!accountId && !apiSettings) {
|
|
1133
1133
|
throw ("Invalid accountId or apiSettings");
|
|
1134
1134
|
}
|
|
1135
1135
|
if (!api) {
|
|
1136
1136
|
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
1137
1137
|
}
|
|
1138
|
+
// We'll prioritize account record if provided.
|
|
1139
|
+
if (accountId && !account) {
|
|
1140
|
+
account = (yield exports.Account.Get({
|
|
1141
|
+
accountId,
|
|
1142
|
+
api,
|
|
1143
|
+
req
|
|
1144
|
+
})).account;
|
|
1145
|
+
}
|
|
1146
|
+
if (account === null || account === void 0 ? void 0 : account["HostingLocation.Key"]) {
|
|
1147
|
+
return {
|
|
1148
|
+
key: account["HostingLocation.Key"],
|
|
1149
|
+
isLegacy: false
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
// Fallback to settings JSON for older records.
|
|
1138
1153
|
const settings = apiSettings ? apiSettings : (yield exports.Account.GetAppSettings({
|
|
1139
1154
|
api,
|
|
1140
1155
|
accountId,
|
|
@@ -1166,12 +1181,13 @@
|
|
|
1166
1181
|
*/
|
|
1167
1182
|
function GetByAccountId(params) {
|
|
1168
1183
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1169
|
-
let { accountId, apiSettings, api, req } = params;
|
|
1184
|
+
let { accountId, apiSettings, api, req, account } = params;
|
|
1170
1185
|
if (!api) {
|
|
1171
1186
|
api = exports.ENVIRONMENT.Api().GetGuardianApi();
|
|
1172
1187
|
}
|
|
1173
1188
|
const data = yield GetKeyByAccountId({
|
|
1174
1189
|
accountId,
|
|
1190
|
+
account,
|
|
1175
1191
|
apiSettings,
|
|
1176
1192
|
api,
|
|
1177
1193
|
req
|
|
@@ -1357,6 +1373,25 @@
|
|
|
1357
1373
|
GetCdnBaseUrl() {
|
|
1358
1374
|
return this.cdnBaseUrl;
|
|
1359
1375
|
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Returns a url routed through the API's CDN.
|
|
1378
|
+
* If the CDN is not enabled for the account, this will return null.
|
|
1379
|
+
* @param url suffix to append to the base url.
|
|
1380
|
+
* @param urlParams
|
|
1381
|
+
* @returns
|
|
1382
|
+
*/
|
|
1383
|
+
ConstructCdnUrl(url, urlParams) {
|
|
1384
|
+
if (!this.cdnBaseUrl) {
|
|
1385
|
+
return null;
|
|
1386
|
+
}
|
|
1387
|
+
let cdnUrl = this.cdnBaseUrl + url;
|
|
1388
|
+
if (!urlParams) {
|
|
1389
|
+
urlParams = new URLSearchParams();
|
|
1390
|
+
}
|
|
1391
|
+
urlParams.set("accountId", this.accountId);
|
|
1392
|
+
cdnUrl += "?" + urlParams.toString();
|
|
1393
|
+
return cdnUrl;
|
|
1394
|
+
}
|
|
1360
1395
|
/**
|
|
1361
1396
|
* Warning: This will cancel the init process.
|
|
1362
1397
|
* The init process loads a region specific endpoint.
|
|
@@ -1664,7 +1699,7 @@
|
|
|
1664
1699
|
if (!params) {
|
|
1665
1700
|
params = {};
|
|
1666
1701
|
}
|
|
1667
|
-
let { accountId, env } = params;
|
|
1702
|
+
let { accountId, env, loadConfig, loadWebSocket } = params;
|
|
1668
1703
|
accountId = accountId ? accountId : this.accountId;
|
|
1669
1704
|
env = env ? env : this.env;
|
|
1670
1705
|
const key = `${accountId}-${env}`;
|
|
@@ -1672,7 +1707,11 @@
|
|
|
1672
1707
|
this.bruce[key] = new exports.BruceApi.Api({
|
|
1673
1708
|
accountId,
|
|
1674
1709
|
env,
|
|
1675
|
-
|
|
1710
|
+
loadConfig: loadConfig,
|
|
1711
|
+
loadWebSocket: loadWebSocket,
|
|
1712
|
+
guardian: this.GetGuardianApi({
|
|
1713
|
+
env
|
|
1714
|
+
}),
|
|
1676
1715
|
});
|
|
1677
1716
|
this.bruce[key].SetSessionId(this.sessionId);
|
|
1678
1717
|
}
|
|
@@ -1689,7 +1728,12 @@
|
|
|
1689
1728
|
accountId: this.accountId,
|
|
1690
1729
|
env: this.env,
|
|
1691
1730
|
getApi: (accountId, env) => {
|
|
1692
|
-
return this.GetBruceApi({
|
|
1731
|
+
return this.GetBruceApi({
|
|
1732
|
+
accountId,
|
|
1733
|
+
env,
|
|
1734
|
+
loadWebSocket: this.accountId == accountId,
|
|
1735
|
+
loadConfig: this.accountId == accountId
|
|
1736
|
+
});
|
|
1693
1737
|
}
|
|
1694
1738
|
};
|
|
1695
1739
|
}
|
|
@@ -6151,11 +6195,16 @@
|
|
|
6151
6195
|
* @returns
|
|
6152
6196
|
*/
|
|
6153
6197
|
function GetUrl(params) {
|
|
6154
|
-
let { api, fileId } = params;
|
|
6198
|
+
let { api, fileId, viaCdn } = params;
|
|
6155
6199
|
if (!api) {
|
|
6156
6200
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
6157
6201
|
}
|
|
6158
|
-
|
|
6202
|
+
const urlSuffix = `file/${fileId}`;
|
|
6203
|
+
const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
|
|
6204
|
+
if (cdnUrl) {
|
|
6205
|
+
return cdnUrl;
|
|
6206
|
+
}
|
|
6207
|
+
return `${api.GetBaseUrl()}${urlSuffix}`;
|
|
6159
6208
|
}
|
|
6160
6209
|
ClientFile.GetUrl = GetUrl;
|
|
6161
6210
|
/**
|
|
@@ -6164,11 +6213,16 @@
|
|
|
6164
6213
|
* @returns
|
|
6165
6214
|
*/
|
|
6166
6215
|
function GetUrlWithExt(params) {
|
|
6167
|
-
let { api, file } = params;
|
|
6216
|
+
let { api, file, viaCdn } = params;
|
|
6168
6217
|
if (!api) {
|
|
6169
6218
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
6170
6219
|
}
|
|
6171
|
-
|
|
6220
|
+
const urlSuffix = file.FileExt ? `file/${file.ID}${file.FileExt}` : `file/${file.ID}`;
|
|
6221
|
+
const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
|
|
6222
|
+
if (cdnUrl) {
|
|
6223
|
+
return cdnUrl;
|
|
6224
|
+
}
|
|
6225
|
+
return `${api.GetBaseUrl()}${urlSuffix}`;
|
|
6172
6226
|
}
|
|
6173
6227
|
ClientFile.GetUrlWithExt = GetUrlWithExt;
|
|
6174
6228
|
/**
|
|
@@ -10229,7 +10283,7 @@
|
|
|
10229
10283
|
DataSource.GetList = GetList;
|
|
10230
10284
|
})(exports.DataSource || (exports.DataSource = {}));
|
|
10231
10285
|
|
|
10232
|
-
const VERSION = "3.2.
|
|
10286
|
+
const VERSION = "3.2.6";
|
|
10233
10287
|
|
|
10234
10288
|
exports.VERSION = VERSION;
|
|
10235
10289
|
exports.AbstractApi = AbstractApi;
|