bruce-models 7.1.123 → 7.1.124
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 +90 -16
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +90 -16
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/abstract-api.js +7 -6
- package/dist/lib/api/abstract-api.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/plugin/plugin.js +82 -9
- package/dist/lib/plugin/plugin.js.map +1 -1
- package/dist/types/api/abstract-api.d.ts +2 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/plugin/plugin.d.ts +28 -0
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -1222,8 +1222,9 @@
|
|
|
1222
1222
|
}
|
|
1223
1223
|
/**
|
|
1224
1224
|
* Injects auth header into the headers object.
|
|
1225
|
+
* Use this for a request made outside the GET/POST/PUT/DELETE/UPLOAD methods, such as a raw fetch.
|
|
1225
1226
|
*/
|
|
1226
|
-
|
|
1227
|
+
ApplyAuthHeader(headers) {
|
|
1227
1228
|
if (!this.ssidHeader) {
|
|
1228
1229
|
return;
|
|
1229
1230
|
}
|
|
@@ -1266,7 +1267,7 @@
|
|
|
1266
1267
|
}
|
|
1267
1268
|
params.headers = params.headers || {};
|
|
1268
1269
|
params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
|
|
1269
|
-
this.
|
|
1270
|
+
this.ApplyAuthHeader(params.headers);
|
|
1270
1271
|
const res = yield fetch(url, {
|
|
1271
1272
|
headers: params.headers,
|
|
1272
1273
|
signal: params.abortSignal
|
|
@@ -1288,7 +1289,7 @@
|
|
|
1288
1289
|
}
|
|
1289
1290
|
params.headers = params.headers || {};
|
|
1290
1291
|
params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
|
|
1291
|
-
this.
|
|
1292
|
+
this.ApplyAuthHeader(params.headers);
|
|
1292
1293
|
if (data != null && typeof data != "string") {
|
|
1293
1294
|
data = JSON.stringify(data);
|
|
1294
1295
|
}
|
|
@@ -1316,7 +1317,7 @@
|
|
|
1316
1317
|
}
|
|
1317
1318
|
params.headers = params.headers || {};
|
|
1318
1319
|
params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
|
|
1319
|
-
this.
|
|
1320
|
+
this.ApplyAuthHeader(params.headers);
|
|
1320
1321
|
if (!data) {
|
|
1321
1322
|
data = {};
|
|
1322
1323
|
}
|
|
@@ -1347,7 +1348,7 @@
|
|
|
1347
1348
|
}
|
|
1348
1349
|
params.headers = params.headers || {};
|
|
1349
1350
|
params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
|
|
1350
|
-
this.
|
|
1351
|
+
this.ApplyAuthHeader(params.headers);
|
|
1351
1352
|
if (!data) {
|
|
1352
1353
|
data = {};
|
|
1353
1354
|
}
|
|
@@ -1377,7 +1378,7 @@
|
|
|
1377
1378
|
params = {};
|
|
1378
1379
|
}
|
|
1379
1380
|
params.headers = Object.assign({}, params.headers);
|
|
1380
|
-
this.
|
|
1381
|
+
this.ApplyAuthHeader(params.headers);
|
|
1381
1382
|
const formData = params.formData instanceof FormData ? params.formData : new FormData();
|
|
1382
1383
|
if (formData.has("file")) {
|
|
1383
1384
|
formData.delete("file");
|
|
@@ -19735,16 +19736,31 @@
|
|
|
19735
19736
|
* @returns
|
|
19736
19737
|
*/
|
|
19737
19738
|
function GetLoadUrl(params) {
|
|
19738
|
-
|
|
19739
|
+
const { fileUrl } = GetFileUrl(Object.assign(Object.assign({}, params), { filePath: "index.jsc" }));
|
|
19740
|
+
return {
|
|
19741
|
+
indexFileUrl: fileUrl
|
|
19742
|
+
};
|
|
19743
|
+
}
|
|
19744
|
+
Plugin.GetLoadUrl = GetLoadUrl;
|
|
19745
|
+
/**
|
|
19746
|
+
* Returns a URL to a file within a plugin's ZIP.
|
|
19747
|
+
* @param params
|
|
19748
|
+
* @returns
|
|
19749
|
+
*/
|
|
19750
|
+
function GetFileUrl(params) {
|
|
19751
|
+
let { api, pluginId, filePath, cacheKey, viaCdn } = params;
|
|
19739
19752
|
if (!api) {
|
|
19740
19753
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
19741
19754
|
}
|
|
19742
19755
|
if (!cacheKey) {
|
|
19743
19756
|
cacheKey = 0;
|
|
19744
19757
|
}
|
|
19758
|
+
if (filePath.startsWith("/")) {
|
|
19759
|
+
filePath = filePath.substring(1);
|
|
19760
|
+
}
|
|
19745
19761
|
return {
|
|
19746
|
-
|
|
19747
|
-
url: `ui.plugin/${pluginId}/file
|
|
19762
|
+
fileUrl: api.ConstructUrl({
|
|
19763
|
+
url: `ui.plugin/${pluginId}/file/${filePath}`,
|
|
19748
19764
|
urlParams: {
|
|
19749
19765
|
"version": String(cacheKey)
|
|
19750
19766
|
},
|
|
@@ -19752,7 +19768,53 @@
|
|
|
19752
19768
|
})
|
|
19753
19769
|
};
|
|
19754
19770
|
}
|
|
19755
|
-
Plugin.
|
|
19771
|
+
Plugin.GetFileUrl = GetFileUrl;
|
|
19772
|
+
/**
|
|
19773
|
+
* Fetches a file within a plugin's ZIP, with the session attached.
|
|
19774
|
+
* Read the returned response as text, blob or JSON depending on the file.
|
|
19775
|
+
* @param params
|
|
19776
|
+
* @returns
|
|
19777
|
+
*/
|
|
19778
|
+
function LoadFile(params) {
|
|
19779
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19780
|
+
let { api, pluginId, plugin, filePath, req } = params;
|
|
19781
|
+
if (!filePath) {
|
|
19782
|
+
throw ("File path is required.");
|
|
19783
|
+
}
|
|
19784
|
+
if (!api) {
|
|
19785
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
19786
|
+
}
|
|
19787
|
+
yield api.Loading;
|
|
19788
|
+
if (!plugin && pluginId) {
|
|
19789
|
+
plugin = (yield Plugin.Get({
|
|
19790
|
+
pluginId,
|
|
19791
|
+
api,
|
|
19792
|
+
req
|
|
19793
|
+
})).plugin;
|
|
19794
|
+
}
|
|
19795
|
+
if (plugin && !pluginId) {
|
|
19796
|
+
pluginId = plugin.ID;
|
|
19797
|
+
}
|
|
19798
|
+
const { fileUrl } = GetFileUrl({
|
|
19799
|
+
api,
|
|
19800
|
+
pluginId,
|
|
19801
|
+
filePath,
|
|
19802
|
+
cacheKey: plugin.Version,
|
|
19803
|
+
viaCdn: !plugin.IsLoginRequired
|
|
19804
|
+
});
|
|
19805
|
+
const headers = {};
|
|
19806
|
+
api.ApplyAuthHeader(headers);
|
|
19807
|
+
const res = yield fetch(fileUrl, {
|
|
19808
|
+
headers: headers,
|
|
19809
|
+
signal: req === null || req === void 0 ? void 0 : req.abortSignal
|
|
19810
|
+
});
|
|
19811
|
+
if (!res.ok) {
|
|
19812
|
+
throw new Error(`Failed to load "${filePath}" from plugin "${pluginId}" (${res.status}).`);
|
|
19813
|
+
}
|
|
19814
|
+
return res;
|
|
19815
|
+
});
|
|
19816
|
+
}
|
|
19817
|
+
Plugin.LoadFile = LoadFile;
|
|
19756
19818
|
/**
|
|
19757
19819
|
* Creates or updates a plugin.
|
|
19758
19820
|
* @param params
|
|
@@ -19862,9 +19924,7 @@
|
|
|
19862
19924
|
}
|
|
19863
19925
|
else {
|
|
19864
19926
|
const headers = {};
|
|
19865
|
-
|
|
19866
|
-
headers[api.GetSessionHeader()] = api.GetSessionId();
|
|
19867
|
-
}
|
|
19927
|
+
api.ApplyAuthHeader(headers);
|
|
19868
19928
|
// A refusal must not be cached and run as if it were the plugin's code.
|
|
19869
19929
|
fileContentProm = fetch(indexFileUrl, {
|
|
19870
19930
|
headers: headers
|
|
@@ -19923,6 +19983,13 @@
|
|
|
19923
19983
|
const paramsId = exports.ObjectUtils.UId();
|
|
19924
19984
|
window[paramsId] = pluginParams ? pluginParams : {};
|
|
19925
19985
|
window["PLUGIN_" + pluginId] = plugin;
|
|
19986
|
+
const loadFileId = exports.ObjectUtils.UId();
|
|
19987
|
+
window[loadFileId] = (filePath) => LoadFile({
|
|
19988
|
+
api: loaded.api,
|
|
19989
|
+
plugin,
|
|
19990
|
+
filePath,
|
|
19991
|
+
req
|
|
19992
|
+
});
|
|
19926
19993
|
const disposeId = exports.ObjectUtils.UId();
|
|
19927
19994
|
const elementId = exports.ObjectUtils.UId();
|
|
19928
19995
|
let script = `
|
|
@@ -19953,7 +20020,8 @@
|
|
|
19953
20020
|
container: container,
|
|
19954
20021
|
pluginParams: params,
|
|
19955
20022
|
pluginId: "${pluginId}",
|
|
19956
|
-
plugin: plugin
|
|
20023
|
+
plugin: plugin,
|
|
20024
|
+
loadFile: window["${loadFileId}"]
|
|
19957
20025
|
});
|
|
19958
20026
|
}
|
|
19959
20027
|
run();
|
|
@@ -19988,6 +20056,7 @@
|
|
|
19988
20056
|
}
|
|
19989
20057
|
}
|
|
19990
20058
|
callDispose();
|
|
20059
|
+
delete window[loadFileId];
|
|
19991
20060
|
};
|
|
19992
20061
|
}
|
|
19993
20062
|
};
|
|
@@ -20015,7 +20084,12 @@
|
|
|
20015
20084
|
const contextId = "PLUGIN_CONTEXT_" + callId;
|
|
20016
20085
|
const resultId = "PLUGIN_RESULT_" + callId;
|
|
20017
20086
|
window[argsId] = args ? args : {};
|
|
20018
|
-
window[contextId] = Object.assign({ config: loaded.plugin.Settings ? loaded.plugin.Settings.config : undefined, plugin: loaded.plugin
|
|
20087
|
+
window[contextId] = Object.assign({ config: loaded.plugin.Settings ? loaded.plugin.Settings.config : undefined, plugin: loaded.plugin, loadFile: (filePath) => LoadFile({
|
|
20088
|
+
api: loaded.api,
|
|
20089
|
+
plugin: loaded.plugin,
|
|
20090
|
+
filePath,
|
|
20091
|
+
req
|
|
20092
|
+
}) }, (context ? context : {}));
|
|
20019
20093
|
const script = `
|
|
20020
20094
|
function invoke() {
|
|
20021
20095
|
"use strict";
|
|
@@ -25205,7 +25279,7 @@
|
|
|
25205
25279
|
}
|
|
25206
25280
|
|
|
25207
25281
|
// This is updated with the package.json version on build.
|
|
25208
|
-
const VERSION = "7.1.
|
|
25282
|
+
const VERSION = "7.1.124";
|
|
25209
25283
|
|
|
25210
25284
|
exports.VERSION = VERSION;
|
|
25211
25285
|
exports.AbstractApi = AbstractApi;
|