bruce-models 7.1.129 → 7.1.130

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.
@@ -51,6 +51,8 @@
51
51
  ECacheKey["DataFeed"] = "datafeed";
52
52
  ECacheKey["ProjectView"] = "projectview";
53
53
  ECacheKey["ProjectViewBookmark"] = "pvbookmark";
54
+ ECacheKey["ReportTemplate"] = "reporttemplate";
55
+ ECacheKey["ReportTemplateSection"] = "reporttemplatesection";
54
56
  ECacheKey["Tileset"] = "tileset";
55
57
  ECacheKey["ClientFile"] = "clientfile";
56
58
  ECacheKey["ClientFileFolder"] = "clientfilefolder";
@@ -362,6 +364,9 @@
362
364
  EConcept["PROJECT_VIEW"] = "pv";
363
365
  EConcept["PENDING_ACTION"] = "pa";
364
366
  EConcept["RELATION_TYPE"] = "rt";
367
+ // Reusable report definitions and their individually permissioned sections.
368
+ EConcept["REPORT_TEMPLATE"] = "rpt";
369
+ EConcept["REPORT_TEMPLATE_SECTION"] = "rpts";
365
370
  EConcept["SCENARIO"] = "sc";
366
371
  EConcept["TILESET"] = "ts";
367
372
  EConcept["UI_DASHBOARD_VIEW"] = "dbv";
@@ -436,6 +441,8 @@
436
441
  { concept: EConcept.LOD_CATEGORY, label: "LOD Category", description: undefined },
437
442
  { concept: EConcept.PROGRAM_KEY, label: "Third Party Key", description: undefined },
438
443
  { concept: EConcept.RELATION_TYPE, label: "Relation Type", description: undefined },
444
+ { concept: EConcept.REPORT_TEMPLATE, label: "Report Template", description: "Reusable report definitions with ordered sections" },
445
+ { concept: EConcept.REPORT_TEMPLATE_SECTION, label: "Report Template Section", description: "Ordered sections belonging to a Report Template" },
439
446
  { concept: EConcept.SCENARIO, label: "Scenario", description: undefined },
440
447
  { concept: EConcept.PROJECT_VIEW, label: "Project View", description: undefined },
441
448
  { concept: EConcept.TILESET, label: "Tileset", description: undefined },
@@ -710,6 +717,10 @@
710
717
  return [exports.Api.ECacheKey.ProjectView, exports.Api.ECacheKey.ProjectViewBookmark];
711
718
  case exports.AccountConcept.EConcept.RELATION_TYPE:
712
719
  return [exports.Api.ECacheKey.RelationType];
720
+ case exports.AccountConcept.EConcept.REPORT_TEMPLATE:
721
+ return [exports.Api.ECacheKey.ReportTemplate, exports.Api.ECacheKey.ReportTemplateSection];
722
+ case exports.AccountConcept.EConcept.REPORT_TEMPLATE_SECTION:
723
+ return [exports.Api.ECacheKey.ReportTemplateSection];
713
724
  case exports.AccountConcept.EConcept.WORKFLOW_ITEM:
714
725
  return [exports.Api.ECacheKey.WorkflowItem];
715
726
  case exports.AccountConcept.EConcept.WORKFLOW_ITEM_STATUS:
@@ -743,6 +754,14 @@
743
754
  if (!cacheKeys.length) {
744
755
  return;
745
756
  }
757
+ if (event.concept === exports.AccountConcept.EConcept.REPORT_TEMPLATE ||
758
+ event.concept === exports.AccountConcept.EConcept.REPORT_TEMPLATE_SECTION) {
759
+ // Events can contain ID ranges and omit section parents; evict the affected namespaces in full.
760
+ for (const cacheKey of cacheKeys) {
761
+ cache.RemoveByCallback(key => key === cacheKey || String(key).startsWith(cacheKey + exports.Api.ECacheKey.Id));
762
+ }
763
+ return;
764
+ }
746
765
  // Entity-concept events use internal ID ranges, not public record IDs,
747
766
  // so individual entity cache entries cannot be matched.
748
767
  const isEntityConcept = event.concept === ENTITY_CONCEPT;
@@ -22445,6 +22464,214 @@
22445
22464
  ];
22446
22465
  })(exports.ProjectViewTile || (exports.ProjectViewTile = {}));
22447
22466
 
22467
+ (function (ReportTemplate) {
22468
+ /**
22469
+ * Validates and normalizes a signed 64-bit identity for routes and cache keys without rounding it.
22470
+ * Zero is accepted only for creation; decimal strings can represent the full positive bigint range.
22471
+ */
22472
+ function NormalizeId(id, allowZero = false) {
22473
+ if (typeof id === "number" && (!Number.isSafeInteger(id) || id < 0)) {
22474
+ throw new Error("Report Template ID must be a safe integer or a decimal string for a larger bigint ID.");
22475
+ }
22476
+ if ((typeof id !== "number" && typeof id !== "string") || !/^\d+$/.test(String(id))) {
22477
+ throw new Error("Report Template ID must be a non-negative decimal integer.");
22478
+ }
22479
+ const value = String(id).replace(/^0+(?=\d)/, "");
22480
+ if ((!allowZero && value === "0") || value.length > 19 ||
22481
+ (value.length === 19 && value > "9223372036854775807")) {
22482
+ throw new Error("Report Template ID must be a positive signed 64-bit integer; use 0 only to create.");
22483
+ }
22484
+ return value;
22485
+ }
22486
+ ReportTemplate.NormalizeId = NormalizeId;
22487
+ /**
22488
+ * Reads a template by ID, subject to the caller's template view permission.
22489
+ */
22490
+ function Get(params) {
22491
+ return __awaiter(this, void 0, void 0, function* () {
22492
+ const id = NormalizeId(params.reportTemplateId);
22493
+ const api = params.api || exports.ENVIRONMENT.Api().GetBruceApi();
22494
+ const key = GetCacheKey(id);
22495
+ const cache = api.GetCacheItem(key, params.req);
22496
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
22497
+ return cache.data;
22498
+ }
22499
+ const promise = api.GET(`reportTemplate/${id}`, exports.Api.PrepReqParams(params.req))
22500
+ .then(reportTemplate => ({ reportTemplate }));
22501
+ api.SetCacheItem({ key, value: promise, req: params.req });
22502
+ return promise;
22503
+ });
22504
+ }
22505
+ ReportTemplate.Get = Get;
22506
+ /**
22507
+ * Lists visible templates in name order; the server filters out records the caller cannot view.
22508
+ */
22509
+ function GetList(params = {}) {
22510
+ return __awaiter(this, void 0, void 0, function* () {
22511
+ const api = params.api || exports.ENVIRONMENT.Api().GetBruceApi();
22512
+ const key = GetListCacheKey();
22513
+ const cache = api.GetCacheItem(key, params.req);
22514
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
22515
+ return cache.data;
22516
+ }
22517
+ const promise = api.GET("reportTemplates", exports.Api.PrepReqParams(params.req))
22518
+ .then(data => { var _a; return ({ reportTemplates: (_a = data === null || data === void 0 ? void 0 : data.Items) !== null && _a !== void 0 ? _a : [] }); });
22519
+ api.SetCacheItem({ key, value: promise, req: params.req });
22520
+ return promise;
22521
+ });
22522
+ }
22523
+ ReportTemplate.GetList = GetList;
22524
+ /**
22525
+ * Creates with ID 0 or updates the identified template, preserving omitted fields on the server.
22526
+ * Explicit null clears Description or Settings; identity and creation metadata come from the server.
22527
+ */
22528
+ function Update(params) {
22529
+ var _a;
22530
+ return __awaiter(this, void 0, void 0, function* () {
22531
+ if (!params.reportTemplate) {
22532
+ throw new Error("Report Template data is required.");
22533
+ }
22534
+ const id = NormalizeId(params.reportTemplateId !== undefined
22535
+ ? params.reportTemplateId : (_a = params.reportTemplate.ID) !== null && _a !== void 0 ? _a : 0, true);
22536
+ const api = params.api || exports.ENVIRONMENT.Api().GetBruceApi();
22537
+ const reportTemplate = yield api.POST(`reportTemplate/${id}`, params.reportTemplate, exports.Api.PrepReqParams(params.req));
22538
+ api.Cache.Remove(GetCacheKey(id));
22539
+ if (reportTemplate === null || reportTemplate === void 0 ? void 0 : reportTemplate.ID) {
22540
+ api.Cache.Remove(GetCacheKey(reportTemplate.ID));
22541
+ }
22542
+ api.Cache.Remove(GetListCacheKey());
22543
+ return { reportTemplate };
22544
+ });
22545
+ }
22546
+ ReportTemplate.Update = Update;
22547
+ /**
22548
+ * Deletes a template and every section it owns; requires template delete permission.
22549
+ */
22550
+ function Delete(params) {
22551
+ return __awaiter(this, void 0, void 0, function* () {
22552
+ const id = NormalizeId(params.reportTemplateId);
22553
+ const api = params.api || exports.ENVIRONMENT.Api().GetBruceApi();
22554
+ yield api.DELETE(`reportTemplate/${id}`, exports.Api.PrepReqParams(params.req));
22555
+ api.Cache.Remove(GetCacheKey(id));
22556
+ api.Cache.Remove(GetListCacheKey());
22557
+ const sectionsKey = `${exports.Api.ECacheKey.ReportTemplateSection}${exports.Api.ECacheKey.Id}${id}`;
22558
+ api.Cache.Remove(sectionsKey);
22559
+ api.Cache.RemoveByStartsWith(`${sectionsKey}${exports.Api.ECacheKey.Id}`);
22560
+ });
22561
+ }
22562
+ ReportTemplate.Delete = Delete;
22563
+ /**
22564
+ * Cache identifier for one template, shared by numeric IDs and their decimal string equivalents.
22565
+ */
22566
+ function GetCacheKey(reportTemplateId) {
22567
+ return `${exports.Api.ECacheKey.ReportTemplate}${exports.Api.ECacheKey.Id}${NormalizeId(reportTemplateId, true)}`;
22568
+ }
22569
+ ReportTemplate.GetCacheKey = GetCacheKey;
22570
+ /**
22571
+ * Cache identifier for the account's visible template list.
22572
+ */
22573
+ function GetListCacheKey() {
22574
+ return exports.Api.ECacheKey.ReportTemplate;
22575
+ }
22576
+ ReportTemplate.GetListCacheKey = GetListCacheKey;
22577
+ })(exports.ReportTemplate || (exports.ReportTemplate = {}));
22578
+
22579
+ (function (ReportTemplateSection) {
22580
+ /**
22581
+ * Reads one section; a section belonging to another template is rejected by the server.
22582
+ */
22583
+ function Get(params) {
22584
+ return __awaiter(this, void 0, void 0, function* () {
22585
+ const templateId = exports.ReportTemplate.NormalizeId(params.reportTemplateId);
22586
+ const sectionId = exports.ReportTemplate.NormalizeId(params.sectionId);
22587
+ const api = params.api || exports.ENVIRONMENT.Api().GetBruceApi();
22588
+ const key = GetCacheKey(templateId, sectionId);
22589
+ const cache = api.GetCacheItem(key, params.req);
22590
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
22591
+ return cache.data;
22592
+ }
22593
+ const promise = api.GET(`reportTemplate/${templateId}/section/${sectionId}`, exports.Api.PrepReqParams(params.req))
22594
+ .then(reportTemplateSection => ({ reportTemplateSection }));
22595
+ api.SetCacheItem({ key, value: promise, req: params.req });
22596
+ return promise;
22597
+ });
22598
+ }
22599
+ ReportTemplateSection.Get = Get;
22600
+ /**
22601
+ * Lists visible sections of a template in display order, filtered by the caller's permissions.
22602
+ */
22603
+ function GetList(params) {
22604
+ return __awaiter(this, void 0, void 0, function* () {
22605
+ const templateId = exports.ReportTemplate.NormalizeId(params.reportTemplateId);
22606
+ const api = params.api || exports.ENVIRONMENT.Api().GetBruceApi();
22607
+ const key = GetListCacheKey(templateId);
22608
+ const cache = api.GetCacheItem(key, params.req);
22609
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
22610
+ return cache.data;
22611
+ }
22612
+ const promise = api.GET(`reportTemplate/${templateId}/sections`, exports.Api.PrepReqParams(params.req))
22613
+ .then(data => { var _a; return ({ reportTemplateSections: (_a = data === null || data === void 0 ? void 0 : data.Items) !== null && _a !== void 0 ? _a : [] }); });
22614
+ api.SetCacheItem({ key, value: promise, req: params.req });
22615
+ return promise;
22616
+ });
22617
+ }
22618
+ ReportTemplateSection.GetList = GetList;
22619
+ /**
22620
+ * Creates with section ID 0 or updates under an existing parent; Settings accepts null to clear it.
22621
+ * The server ignores body IDs, preserves omitted fields and never moves a section to another parent.
22622
+ */
22623
+ function Update(params) {
22624
+ var _a;
22625
+ return __awaiter(this, void 0, void 0, function* () {
22626
+ if (!params.reportTemplateSection) {
22627
+ throw new Error("Report Template Section data is required.");
22628
+ }
22629
+ const section = params.reportTemplateSection;
22630
+ const templateId = exports.ReportTemplate.NormalizeId(params.reportTemplateId !== undefined
22631
+ ? params.reportTemplateId : section["ReportTemplate.ID"]);
22632
+ const sectionId = exports.ReportTemplate.NormalizeId(params.sectionId !== undefined
22633
+ ? params.sectionId : (_a = section.ID) !== null && _a !== void 0 ? _a : 0, true);
22634
+ const api = params.api || exports.ENVIRONMENT.Api().GetBruceApi();
22635
+ const reportTemplateSection = yield api.POST(`reportTemplate/${templateId}/section/${sectionId}`, section, exports.Api.PrepReqParams(params.req));
22636
+ api.Cache.Remove(GetCacheKey(templateId, sectionId));
22637
+ if (reportTemplateSection === null || reportTemplateSection === void 0 ? void 0 : reportTemplateSection.ID) {
22638
+ api.Cache.Remove(GetCacheKey(templateId, reportTemplateSection.ID));
22639
+ }
22640
+ api.Cache.Remove(GetListCacheKey(templateId));
22641
+ return { reportTemplateSection };
22642
+ });
22643
+ }
22644
+ ReportTemplateSection.Update = Update;
22645
+ /**
22646
+ * Deletes only the identified section, preserving its template and sibling sections.
22647
+ */
22648
+ function Delete(params) {
22649
+ return __awaiter(this, void 0, void 0, function* () {
22650
+ const templateId = exports.ReportTemplate.NormalizeId(params.reportTemplateId);
22651
+ const sectionId = exports.ReportTemplate.NormalizeId(params.sectionId);
22652
+ const api = params.api || exports.ENVIRONMENT.Api().GetBruceApi();
22653
+ yield api.DELETE(`reportTemplate/${templateId}/section/${sectionId}`, exports.Api.PrepReqParams(params.req));
22654
+ api.Cache.Remove(GetCacheKey(templateId, sectionId));
22655
+ api.Cache.Remove(GetListCacheKey(templateId));
22656
+ });
22657
+ }
22658
+ ReportTemplateSection.Delete = Delete;
22659
+ /**
22660
+ * Cache identifier scoped to both parent and section, so another parent's read cannot reuse it.
22661
+ */
22662
+ function GetCacheKey(reportTemplateId, sectionId) {
22663
+ return `${GetListCacheKey(reportTemplateId)}${exports.Api.ECacheKey.Id}${exports.ReportTemplate.NormalizeId(sectionId, true)}`;
22664
+ }
22665
+ ReportTemplateSection.GetCacheKey = GetCacheKey;
22666
+ /**
22667
+ * Cache identifier for one template's visible section list.
22668
+ */
22669
+ function GetListCacheKey(reportTemplateId) {
22670
+ return `${exports.Api.ECacheKey.ReportTemplateSection}${exports.Api.ECacheKey.Id}${exports.ReportTemplate.NormalizeId(reportTemplateId)}`;
22671
+ }
22672
+ ReportTemplateSection.GetListCacheKey = GetListCacheKey;
22673
+ })(exports.ReportTemplateSection || (exports.ReportTemplateSection = {}));
22674
+
22448
22675
  (function (Scenario) {
22449
22676
  /**
22450
22677
  * Returns a scenario record matching the provided ID or Key.
@@ -25551,7 +25778,7 @@
25551
25778
  }
25552
25779
 
25553
25780
  // This is updated with the package.json version on build.
25554
- const VERSION = "7.1.129";
25781
+ const VERSION = "7.1.130";
25555
25782
 
25556
25783
  exports.VERSION = VERSION;
25557
25784
  exports.AbstractApi = AbstractApi;