bruce-models 7.1.112 → 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.
@@ -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) => res.text());
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,
@@ -24011,6 +24091,39 @@
24011
24091
  });
24012
24092
  }
24013
24093
  WorkflowItem.GetList = GetList;
24094
+ /**
24095
+ * Gets Workflow Item counts grouped by the Entity Types of their Subject Entities.
24096
+ * Parent Entity Type and Ontology breakdowns are returned only when expanded.
24097
+ */
24098
+ function GetStatistics(params) {
24099
+ return __awaiter(this, void 0, void 0, function* () {
24100
+ if (!params) {
24101
+ params = {};
24102
+ }
24103
+ let { api, req } = params;
24104
+ if (!api) {
24105
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
24106
+ }
24107
+ const url = BuildStatisticsUrl(params);
24108
+ const key = GetStatisticsCacheKey(params);
24109
+ const cache = api.GetCacheItem(key, req);
24110
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
24111
+ return cache.data;
24112
+ }
24113
+ const request = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
24114
+ try {
24115
+ const data = yield api.GET(url, exports.Api.PrepReqParams(req));
24116
+ res(ParseStatisticsResponse(data));
24117
+ }
24118
+ catch (e) {
24119
+ rej(e);
24120
+ }
24121
+ }));
24122
+ api.SetCacheItem({ key, value: request, req });
24123
+ return request;
24124
+ });
24125
+ }
24126
+ WorkflowItem.GetStatistics = GetStatistics;
24014
24127
  function Create(params) {
24015
24128
  var _a, _b, _c, _d, _e;
24016
24129
  return __awaiter(this, void 0, void 0, function* () {
@@ -24093,12 +24206,32 @@
24093
24206
  appendParam(q, "SlideID", params === null || params === void 0 ? void 0 : params.slideId);
24094
24207
  appendParam(q, "EntityID", params === null || params === void 0 ? void 0 : params.entityId);
24095
24208
  appendParam(q, "SubjectEntityID", params === null || params === void 0 ? void 0 : params.subjectEntityId);
24209
+ appendParam(q, "SubjectEntityTypeID", params === null || params === void 0 ? void 0 : params.subjectEntityTypeId);
24210
+ appendParam(q, "SubjectParentEntityTypeID", params === null || params === void 0 ? void 0 : params.subjectParentEntityTypeId);
24211
+ appendParam(q, "SubjectOntologyID", params === null || params === void 0 ? void 0 : params.subjectOntologyId);
24096
24212
  appendParam(q, "Description", params === null || params === void 0 ? void 0 : params.description);
24097
24213
  appendParam(q, "Search", params === null || params === void 0 ? void 0 : params.search);
24098
24214
  const qs = q.toString();
24099
24215
  return qs ? `workflow/itemsquery?${qs}` : "workflow/itemsquery";
24100
24216
  }
24101
24217
  WorkflowItem.BuildListUrl = BuildListUrl;
24218
+ function BuildStatisticsUrl(params) {
24219
+ const q = new URLSearchParams();
24220
+ appendParam(q, "itemtypeid", params === null || params === void 0 ? void 0 : params.itemTypeId);
24221
+ appendParam(q, "statusid", params === null || params === void 0 ? void 0 : params.statusId);
24222
+ appendParam(q, "queueid", params === null || params === void 0 ? void 0 : params.queueId);
24223
+ const expand = [];
24224
+ if (params === null || params === void 0 ? void 0 : params.expandParentEntityTypes) {
24225
+ expand.push("ParentEntityTypes");
24226
+ }
24227
+ if (params === null || params === void 0 ? void 0 : params.expandOntologies) {
24228
+ expand.push("Ontologies");
24229
+ }
24230
+ appendParam(q, "Expand", expand);
24231
+ const qs = q.toString();
24232
+ return qs ? `workflow/items/statistics?${qs}` : "workflow/items/statistics";
24233
+ }
24234
+ WorkflowItem.BuildStatisticsUrl = BuildStatisticsUrl;
24102
24235
  function ParseResponse(response) {
24103
24236
  var _a, _b, _c, _d;
24104
24237
  const parsed = parseObject$5(response);
@@ -24124,6 +24257,23 @@
24124
24257
  };
24125
24258
  }
24126
24259
  WorkflowItem.ParseListResponse = ParseListResponse;
24260
+ function ParseStatisticsResponse(response) {
24261
+ var _a, _b;
24262
+ const parsed = parseObject$5(response);
24263
+ const parsedResult = (_a = parseObject$5(parsed === null || parsed === void 0 ? void 0 : parsed.Result)) !== null && _a !== void 0 ? _a : parsed === null || parsed === void 0 ? void 0 : parsed.Result;
24264
+ const source = (_b = parsedResult !== null && parsedResult !== void 0 ? parsedResult : parsed) !== null && _b !== void 0 ? _b : {};
24265
+ const result = {
24266
+ EntityTypes: Array.isArray(source.EntityTypes) ? source.EntityTypes : []
24267
+ };
24268
+ if (Array.isArray(source.ParentEntityTypes)) {
24269
+ result.ParentEntityTypes = source.ParentEntityTypes;
24270
+ }
24271
+ if (Array.isArray(source.Ontologies)) {
24272
+ result.Ontologies = source.Ontologies;
24273
+ }
24274
+ return result;
24275
+ }
24276
+ WorkflowItem.ParseStatisticsResponse = ParseStatisticsResponse;
24127
24277
  function GetCacheKey(id) {
24128
24278
  return `${exports.Api.ECacheKey.WorkflowItem}${exports.Api.ECacheKey.Id}${id}`;
24129
24279
  }
@@ -24132,6 +24282,10 @@
24132
24282
  return `${exports.Api.ECacheKey.WorkflowItem}${exports.Api.ECacheKey.ListId}${BuildListUrl(params)}`;
24133
24283
  }
24134
24284
  WorkflowItem.GetListCacheKey = GetListCacheKey;
24285
+ function GetStatisticsCacheKey(params) {
24286
+ return `${exports.Api.ECacheKey.WorkflowItem}${exports.Api.ECacheKey.ListId}${BuildStatisticsUrl(params)}`;
24287
+ }
24288
+ WorkflowItem.GetStatisticsCacheKey = GetStatisticsCacheKey;
24135
24289
  })(exports.WorkflowItem || (exports.WorkflowItem = {}));
24136
24290
  function appendParam(q, key, value) {
24137
24291
  if (value == null || value === "") {
@@ -24644,7 +24798,7 @@
24644
24798
  }
24645
24799
 
24646
24800
  // This is updated with the package.json version on build.
24647
- const VERSION = "7.1.112";
24801
+ const VERSION = "7.1.114";
24648
24802
 
24649
24803
  exports.VERSION = VERSION;
24650
24804
  exports.AbstractApi = AbstractApi;