bruce-models 7.1.113 → 7.1.114
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 +82 -2
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +82 -2
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/calculator/calculator.js +73 -0
- package/dist/lib/calculator/calculator.js.map +1 -1
- package/dist/lib/plugin/plugin.js +8 -1
- package/dist/lib/plugin/plugin.js.map +1 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/calculator/calculator.d.ts +6 -0
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -8217,6 +8217,79 @@
|
|
|
8217
8217
|
// Fallback to min (static, no data path resolved).
|
|
8218
8218
|
return { result: exports.Color.ColorFromStr(points[0].color), attrPath: null, eValue: null };
|
|
8219
8219
|
}
|
|
8220
|
+
/**
|
|
8221
|
+
* Lists every attribute path a set of fields could read from an entity record.
|
|
8222
|
+
* Returns null when the fields depend on more than attribute values (tags, or a function).
|
|
8223
|
+
* @param fields
|
|
8224
|
+
*/
|
|
8225
|
+
function GetFieldPaths(fields) {
|
|
8226
|
+
var _a, _b;
|
|
8227
|
+
if (fields == null) {
|
|
8228
|
+
return [];
|
|
8229
|
+
}
|
|
8230
|
+
const fieldsArr = Array.isArray(fields) ? fields : [fields];
|
|
8231
|
+
const paths = [];
|
|
8232
|
+
const seen = new Set();
|
|
8233
|
+
const add = (path) => {
|
|
8234
|
+
if (!path.length || path.some(segment => !segment || segment.includes("\""))) {
|
|
8235
|
+
return;
|
|
8236
|
+
}
|
|
8237
|
+
const key = JSON.stringify(path);
|
|
8238
|
+
if (!seen.has(key)) {
|
|
8239
|
+
seen.add(key);
|
|
8240
|
+
paths.push(path);
|
|
8241
|
+
}
|
|
8242
|
+
};
|
|
8243
|
+
// Mirrors BruceVariable.SwapValues, which reads every ${...} with PathUtils.Parse.
|
|
8244
|
+
// TODO: expand BruceVariable to include a util for this instead of duping logic.
|
|
8245
|
+
const addVariables = (template) => {
|
|
8246
|
+
if (typeof template != "string") {
|
|
8247
|
+
return;
|
|
8248
|
+
}
|
|
8249
|
+
const variableRegex = /\${([^}]*)}/g;
|
|
8250
|
+
let match;
|
|
8251
|
+
while ((match = variableRegex.exec(template)) != null) {
|
|
8252
|
+
const pathStr = match[1].trim();
|
|
8253
|
+
if (pathStr) {
|
|
8254
|
+
add(exports.PathUtils.Parse(pathStr));
|
|
8255
|
+
}
|
|
8256
|
+
}
|
|
8257
|
+
};
|
|
8258
|
+
for (const field of fieldsArr) {
|
|
8259
|
+
if (field == null) {
|
|
8260
|
+
continue;
|
|
8261
|
+
}
|
|
8262
|
+
if (field.value instanceof Function) {
|
|
8263
|
+
return null;
|
|
8264
|
+
}
|
|
8265
|
+
switch (field.type) {
|
|
8266
|
+
case EValueType.Color:
|
|
8267
|
+
case EValueType.Input:
|
|
8268
|
+
addVariables(field.value);
|
|
8269
|
+
break;
|
|
8270
|
+
case EValueType.Gradient:
|
|
8271
|
+
parseLegacyPath((_a = field.value) === null || _a === void 0 ? void 0 : _a.field).forEach(add);
|
|
8272
|
+
break;
|
|
8273
|
+
case EValueType.Mapping:
|
|
8274
|
+
{
|
|
8275
|
+
const mapping = field.value;
|
|
8276
|
+
parseLegacyPath(mapping === null || mapping === void 0 ? void 0 : mapping.field).forEach(add);
|
|
8277
|
+
// A JS: row can read other attributes besides the mapped one.
|
|
8278
|
+
for (const option of (_b = mapping === null || mapping === void 0 ? void 0 : mapping.values) !== null && _b !== void 0 ? _b : []) {
|
|
8279
|
+
const fieldValues = Array.isArray(option.fieldValue) ? option.fieldValue : [option.fieldValue];
|
|
8280
|
+
fieldValues.filter(v => typeof v == "string" && v.startsWith("JS:")).forEach(addVariables);
|
|
8281
|
+
}
|
|
8282
|
+
}
|
|
8283
|
+
break;
|
|
8284
|
+
case EValueType.RandomColor:
|
|
8285
|
+
break;
|
|
8286
|
+
default:
|
|
8287
|
+
return null;
|
|
8288
|
+
}
|
|
8289
|
+
}
|
|
8290
|
+
return paths;
|
|
8291
|
+
}
|
|
8292
|
+
Calculator.GetFieldPaths = GetFieldPaths;
|
|
8220
8293
|
/**
|
|
8221
8294
|
* Like Calculate, but also returns an 'effective' key describing how the value
|
|
8222
8295
|
* was derived. See ITraceResult for the key format.
|
|
@@ -19541,9 +19614,16 @@
|
|
|
19541
19614
|
if (plugin.IsLoginRequired) {
|
|
19542
19615
|
headers[api.GetSessionHeader()] = api.GetSessionId();
|
|
19543
19616
|
}
|
|
19617
|
+
// A refusal must not be cached and run as if it were the plugin's code.
|
|
19544
19618
|
fileContentProm = fetch(indexFileUrl, {
|
|
19545
19619
|
headers: headers
|
|
19546
|
-
}).then((res) =>
|
|
19620
|
+
}).then((res) => {
|
|
19621
|
+
if (!res.ok) {
|
|
19622
|
+
api.Cache.Remove(GetIndexFileCacheKey(pluginId, indexFileUrl));
|
|
19623
|
+
throw new Error(`Failed to load plugin "${pluginId}" (${res.status}).`);
|
|
19624
|
+
}
|
|
19625
|
+
return res.text();
|
|
19626
|
+
});
|
|
19547
19627
|
api.SetCacheItem({
|
|
19548
19628
|
key: GetIndexFileCacheKey(pluginId, indexFileUrl),
|
|
19549
19629
|
value: fileContentProm,
|
|
@@ -24718,7 +24798,7 @@
|
|
|
24718
24798
|
}
|
|
24719
24799
|
|
|
24720
24800
|
// This is updated with the package.json version on build.
|
|
24721
|
-
const VERSION = "7.1.
|
|
24801
|
+
const VERSION = "7.1.114";
|
|
24722
24802
|
|
|
24723
24803
|
exports.VERSION = VERSION;
|
|
24724
24804
|
exports.AbstractApi = AbstractApi;
|