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.
@@ -8307,6 +8307,79 @@ var Calculator;
8307
8307
  // Fallback to min (static, no data path resolved).
8308
8308
  return { result: Color.ColorFromStr(points[0].color), attrPath: null, eValue: null };
8309
8309
  }
8310
+ /**
8311
+ * Lists every attribute path a set of fields could read from an entity record.
8312
+ * Returns null when the fields depend on more than attribute values (tags, or a function).
8313
+ * @param fields
8314
+ */
8315
+ function GetFieldPaths(fields) {
8316
+ var _a, _b;
8317
+ if (fields == null) {
8318
+ return [];
8319
+ }
8320
+ const fieldsArr = Array.isArray(fields) ? fields : [fields];
8321
+ const paths = [];
8322
+ const seen = new Set();
8323
+ const add = (path) => {
8324
+ if (!path.length || path.some(segment => !segment || segment.includes("\""))) {
8325
+ return;
8326
+ }
8327
+ const key = JSON.stringify(path);
8328
+ if (!seen.has(key)) {
8329
+ seen.add(key);
8330
+ paths.push(path);
8331
+ }
8332
+ };
8333
+ // Mirrors BruceVariable.SwapValues, which reads every ${...} with PathUtils.Parse.
8334
+ // TODO: expand BruceVariable to include a util for this instead of duping logic.
8335
+ const addVariables = (template) => {
8336
+ if (typeof template != "string") {
8337
+ return;
8338
+ }
8339
+ const variableRegex = /\${([^}]*)}/g;
8340
+ let match;
8341
+ while ((match = variableRegex.exec(template)) != null) {
8342
+ const pathStr = match[1].trim();
8343
+ if (pathStr) {
8344
+ add(PathUtils.Parse(pathStr));
8345
+ }
8346
+ }
8347
+ };
8348
+ for (const field of fieldsArr) {
8349
+ if (field == null) {
8350
+ continue;
8351
+ }
8352
+ if (field.value instanceof Function) {
8353
+ return null;
8354
+ }
8355
+ switch (field.type) {
8356
+ case EValueType.Color:
8357
+ case EValueType.Input:
8358
+ addVariables(field.value);
8359
+ break;
8360
+ case EValueType.Gradient:
8361
+ parseLegacyPath((_a = field.value) === null || _a === void 0 ? void 0 : _a.field).forEach(add);
8362
+ break;
8363
+ case EValueType.Mapping:
8364
+ {
8365
+ const mapping = field.value;
8366
+ parseLegacyPath(mapping === null || mapping === void 0 ? void 0 : mapping.field).forEach(add);
8367
+ // A JS: row can read other attributes besides the mapped one.
8368
+ for (const option of (_b = mapping === null || mapping === void 0 ? void 0 : mapping.values) !== null && _b !== void 0 ? _b : []) {
8369
+ const fieldValues = Array.isArray(option.fieldValue) ? option.fieldValue : [option.fieldValue];
8370
+ fieldValues.filter(v => typeof v == "string" && v.startsWith("JS:")).forEach(addVariables);
8371
+ }
8372
+ }
8373
+ break;
8374
+ case EValueType.RandomColor:
8375
+ break;
8376
+ default:
8377
+ return null;
8378
+ }
8379
+ }
8380
+ return paths;
8381
+ }
8382
+ Calculator.GetFieldPaths = GetFieldPaths;
8310
8383
  /**
8311
8384
  * Like Calculate, but also returns an 'effective' key describing how the value
8312
8385
  * was derived. See ITraceResult for the key format.
@@ -19828,9 +19901,16 @@ var Plugin;
19828
19901
  if (plugin.IsLoginRequired) {
19829
19902
  headers[api.GetSessionHeader()] = api.GetSessionId();
19830
19903
  }
19904
+ // A refusal must not be cached and run as if it were the plugin's code.
19831
19905
  fileContentProm = fetch(indexFileUrl, {
19832
19906
  headers: headers
19833
- }).then((res) => res.text());
19907
+ }).then((res) => {
19908
+ if (!res.ok) {
19909
+ api.Cache.Remove(GetIndexFileCacheKey(pluginId, indexFileUrl));
19910
+ throw new Error(`Failed to load plugin "${pluginId}" (${res.status}).`);
19911
+ }
19912
+ return res.text();
19913
+ });
19834
19914
  api.SetCacheItem({
19835
19915
  key: GetIndexFileCacheKey(pluginId, indexFileUrl),
19836
19916
  value: fileContentProm,
@@ -24396,6 +24476,39 @@ var WorkflowItem;
24396
24476
  });
24397
24477
  }
24398
24478
  WorkflowItem.GetList = GetList;
24479
+ /**
24480
+ * Gets Workflow Item counts grouped by the Entity Types of their Subject Entities.
24481
+ * Parent Entity Type and Ontology breakdowns are returned only when expanded.
24482
+ */
24483
+ function GetStatistics(params) {
24484
+ return __awaiter(this, void 0, void 0, function* () {
24485
+ if (!params) {
24486
+ params = {};
24487
+ }
24488
+ let { api, req } = params;
24489
+ if (!api) {
24490
+ api = ENVIRONMENT.Api().GetBruceApi();
24491
+ }
24492
+ const url = BuildStatisticsUrl(params);
24493
+ const key = GetStatisticsCacheKey(params);
24494
+ const cache = api.GetCacheItem(key, req);
24495
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
24496
+ return cache.data;
24497
+ }
24498
+ const request = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
24499
+ try {
24500
+ const data = yield api.GET(url, Api.PrepReqParams(req));
24501
+ res(ParseStatisticsResponse(data));
24502
+ }
24503
+ catch (e) {
24504
+ rej(e);
24505
+ }
24506
+ }));
24507
+ api.SetCacheItem({ key, value: request, req });
24508
+ return request;
24509
+ });
24510
+ }
24511
+ WorkflowItem.GetStatistics = GetStatistics;
24399
24512
  function Create(params) {
24400
24513
  var _a, _b, _c, _d, _e;
24401
24514
  return __awaiter(this, void 0, void 0, function* () {
@@ -24478,12 +24591,32 @@ var WorkflowItem;
24478
24591
  appendParam(q, "SlideID", params === null || params === void 0 ? void 0 : params.slideId);
24479
24592
  appendParam(q, "EntityID", params === null || params === void 0 ? void 0 : params.entityId);
24480
24593
  appendParam(q, "SubjectEntityID", params === null || params === void 0 ? void 0 : params.subjectEntityId);
24594
+ appendParam(q, "SubjectEntityTypeID", params === null || params === void 0 ? void 0 : params.subjectEntityTypeId);
24595
+ appendParam(q, "SubjectParentEntityTypeID", params === null || params === void 0 ? void 0 : params.subjectParentEntityTypeId);
24596
+ appendParam(q, "SubjectOntologyID", params === null || params === void 0 ? void 0 : params.subjectOntologyId);
24481
24597
  appendParam(q, "Description", params === null || params === void 0 ? void 0 : params.description);
24482
24598
  appendParam(q, "Search", params === null || params === void 0 ? void 0 : params.search);
24483
24599
  const qs = q.toString();
24484
24600
  return qs ? `workflow/itemsquery?${qs}` : "workflow/itemsquery";
24485
24601
  }
24486
24602
  WorkflowItem.BuildListUrl = BuildListUrl;
24603
+ function BuildStatisticsUrl(params) {
24604
+ const q = new URLSearchParams();
24605
+ appendParam(q, "itemtypeid", params === null || params === void 0 ? void 0 : params.itemTypeId);
24606
+ appendParam(q, "statusid", params === null || params === void 0 ? void 0 : params.statusId);
24607
+ appendParam(q, "queueid", params === null || params === void 0 ? void 0 : params.queueId);
24608
+ const expand = [];
24609
+ if (params === null || params === void 0 ? void 0 : params.expandParentEntityTypes) {
24610
+ expand.push("ParentEntityTypes");
24611
+ }
24612
+ if (params === null || params === void 0 ? void 0 : params.expandOntologies) {
24613
+ expand.push("Ontologies");
24614
+ }
24615
+ appendParam(q, "Expand", expand);
24616
+ const qs = q.toString();
24617
+ return qs ? `workflow/items/statistics?${qs}` : "workflow/items/statistics";
24618
+ }
24619
+ WorkflowItem.BuildStatisticsUrl = BuildStatisticsUrl;
24487
24620
  function ParseResponse(response) {
24488
24621
  var _a, _b, _c, _d;
24489
24622
  const parsed = parseObject$5(response);
@@ -24509,6 +24642,23 @@ var WorkflowItem;
24509
24642
  };
24510
24643
  }
24511
24644
  WorkflowItem.ParseListResponse = ParseListResponse;
24645
+ function ParseStatisticsResponse(response) {
24646
+ var _a, _b;
24647
+ const parsed = parseObject$5(response);
24648
+ 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;
24649
+ const source = (_b = parsedResult !== null && parsedResult !== void 0 ? parsedResult : parsed) !== null && _b !== void 0 ? _b : {};
24650
+ const result = {
24651
+ EntityTypes: Array.isArray(source.EntityTypes) ? source.EntityTypes : []
24652
+ };
24653
+ if (Array.isArray(source.ParentEntityTypes)) {
24654
+ result.ParentEntityTypes = source.ParentEntityTypes;
24655
+ }
24656
+ if (Array.isArray(source.Ontologies)) {
24657
+ result.Ontologies = source.Ontologies;
24658
+ }
24659
+ return result;
24660
+ }
24661
+ WorkflowItem.ParseStatisticsResponse = ParseStatisticsResponse;
24512
24662
  function GetCacheKey(id) {
24513
24663
  return `${Api.ECacheKey.WorkflowItem}${Api.ECacheKey.Id}${id}`;
24514
24664
  }
@@ -24517,6 +24667,10 @@ var WorkflowItem;
24517
24667
  return `${Api.ECacheKey.WorkflowItem}${Api.ECacheKey.ListId}${BuildListUrl(params)}`;
24518
24668
  }
24519
24669
  WorkflowItem.GetListCacheKey = GetListCacheKey;
24670
+ function GetStatisticsCacheKey(params) {
24671
+ return `${Api.ECacheKey.WorkflowItem}${Api.ECacheKey.ListId}${BuildStatisticsUrl(params)}`;
24672
+ }
24673
+ WorkflowItem.GetStatisticsCacheKey = GetStatisticsCacheKey;
24520
24674
  })(WorkflowItem || (WorkflowItem = {}));
24521
24675
  function appendParam(q, key, value) {
24522
24676
  if (value == null || value === "") {
@@ -25035,7 +25189,7 @@ function getFirstWrappedArray(data, wrapperKeys) {
25035
25189
  }
25036
25190
 
25037
25191
  // This is updated with the package.json version on build.
25038
- const VERSION = "7.1.112";
25192
+ const VERSION = "7.1.114";
25039
25193
 
25040
25194
  export { VERSION, Account, AccountAudit, AccountConcept, AccountFeatures, AccountInvite, AccountLimits, AccountTemplate, AccountType, AnnDocument, AbstractApi, Api, ApiGetters, BruceApi, GlobalApi, GuardianApi, Assembly, Calculator, ChangeSet, ClientFile, ClientFileValueMap, Bounds, BruceEvent, BruceVariable, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, RequestLane, GeoJson, Geometry, LRUCache, UTC, CustomForm, DashboardView, DataFeed, DataLab, DataLabGroup, DataSource, DataTransform, Comment, Entity, EntityAttachment, EntityAttachmentType, EntityAttribute, EntityComment, EntityCoords, EntityHistoricData, EntityLink, EntityLod, EntityLodCategory, EntityRelation, EntityRelationType, EntitySource, EntityTableView, EntityTag, EntityType, EntityTypeRelation, EntityTypeSource, EntityTypeTrigger, Ontology, OntologyDocument, ENVIRONMENT, ExportBrz, ExportCsv, ExportNsx, ExportUsd, Hexbin, ImportAssembly, ImportCad, ImportCsv, ImportGeoJson, ImportJson, ImportKml, ImportLcc, ImportTif, ImportedFile, Uploader, Markup, UIMarkup, NAVIGATOR_CHAT_EVENT_ENTITY_HIGHLIGHT_APPLIED, NAVIGATOR_CHAT_EVENT_SCENE_CONTEXT_PREFETCHED, NavigatorChatClient, NavigatorMcpWebSocketClient, Plugin, PluginAiTool, ProgramKey, MenuItem, ProjectView, ProjectViewBookmark, ProjectViewBookmarkGroup, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewLegacyTile, ProjectViewTile, ZoomControl, Scenario, HostingLocation, MessageBroker, PendingAction, RecordChangeFeed, Style, Tileset, Tracking, Permission, Session, User, UserGroup, UserMfaMethod, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, WorkflowItem, WorkflowSchedule, WorkflowType, WorkflowItemType };
25041
25195
  //# sourceMappingURL=bruce-models.es5.js.map