bruce-models 7.1.110 → 7.1.111

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.
@@ -17328,6 +17328,34 @@
17328
17328
  }
17329
17329
 
17330
17330
  (function (OntologyDocument) {
17331
+ let ESummaryStatus;
17332
+ (function (ESummaryStatus) {
17333
+ // No summary is linked.
17334
+ ESummaryStatus["None"] = "none";
17335
+ // Produced from the PDF's current Version, so it can stand in for the PDF.
17336
+ ESummaryStatus["Current"] = "current";
17337
+ // Produced from another or an unknown Version. Keep it for review, but read the PDF instead.
17338
+ ESummaryStatus["Outdated"] = "outdated";
17339
+ })(ESummaryStatus = OntologyDocument.ESummaryStatus || (OntologyDocument.ESummaryStatus = {}));
17340
+ /**
17341
+ * Returns whether the record's summary may be used in place of its PDF.
17342
+ * It is only current while its file exists and it was produced from the PDF's current Version.
17343
+ * An unknown version counts as outdated, so a replaced PDF never passes its old summary off as current.
17344
+ * @param record Record as returned by the API, including its nested ClientFile and SummaryClientFile.
17345
+ */
17346
+ function GetSummaryStatus(record) {
17347
+ var _a;
17348
+ if (!(record === null || record === void 0 ? void 0 : record["SummaryClientFile.ID"])) {
17349
+ return ESummaryStatus.None;
17350
+ }
17351
+ const sourceVersion = record.SummarySourceVersion;
17352
+ const currentVersion = (_a = record.ClientFile) === null || _a === void 0 ? void 0 : _a.Version;
17353
+ if (!record.SummaryClientFile || sourceVersion == null || currentVersion == null) {
17354
+ return ESummaryStatus.Outdated;
17355
+ }
17356
+ return Number(sourceVersion) === Number(currentVersion) ? ESummaryStatus.Current : ESummaryStatus.Outdated;
17357
+ }
17358
+ OntologyDocument.GetSummaryStatus = GetSummaryStatus;
17331
17359
  function GetListByOntologyId(params) {
17332
17360
  return __awaiter(this, void 0, void 0, function* () {
17333
17361
  let { api, ontologyId, req: reqParams } = params;
@@ -17396,6 +17424,44 @@
17396
17424
  });
17397
17425
  }
17398
17426
  OntologyDocument.GetListByClientFileId = GetListByClientFileId;
17427
+ /**
17428
+ * Returns the documents that use the given ClientFile as their summary.
17429
+ * GetListByClientFileId() only matches documents made of the file, so check both before deleting a file.
17430
+ */
17431
+ function GetListBySummaryClientFileId(params) {
17432
+ return __awaiter(this, void 0, void 0, function* () {
17433
+ let { api, clientFileId, req: reqParams } = params;
17434
+ if (!clientFileId) {
17435
+ throw ("Client file ID is required.");
17436
+ }
17437
+ if (!api) {
17438
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
17439
+ }
17440
+ const key = GetSummaryListCacheKey(clientFileId);
17441
+ const cache = api.GetCacheItem(key, reqParams);
17442
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
17443
+ return cache.data;
17444
+ }
17445
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
17446
+ try {
17447
+ const data = yield api.GET(`ontology/documents?summary_client_file_id=${encodeURIComponent(clientFileId)}`, exports.Api.PrepReqParams(reqParams));
17448
+ res({
17449
+ ontologyDocuments: ParseListResponse(data)
17450
+ });
17451
+ }
17452
+ catch (e) {
17453
+ rej(e);
17454
+ }
17455
+ }));
17456
+ api.SetCacheItem({
17457
+ key,
17458
+ value: req,
17459
+ req: reqParams
17460
+ });
17461
+ return req;
17462
+ });
17463
+ }
17464
+ OntologyDocument.GetListBySummaryClientFileId = GetListBySummaryClientFileId;
17399
17465
  function Update(params) {
17400
17466
  return __awaiter(this, void 0, void 0, function* () {
17401
17467
  let { api, ontologyDocument: data, req: reqParams } = params;
@@ -17409,7 +17475,8 @@
17409
17475
  if (data.ID) {
17410
17476
  api.Cache.Remove(GetCacheKey(data.ID));
17411
17477
  }
17412
- api.Cache.RemoveByStartsWith(GetListCacheKey(data["Ontology.ID"]));
17478
+ // A save can move a document in or out of any list, eg: by linking a different summary file.
17479
+ api.Cache.RemoveByStartsWith(GetListCacheKeyPrefix());
17413
17480
  return {
17414
17481
  ontologyDocument: ParseResponse(res)
17415
17482
  };
@@ -17427,7 +17494,8 @@
17427
17494
  }
17428
17495
  yield api.DELETE(`ontology/document/${documentId}`, exports.Api.PrepReqParams(reqParams));
17429
17496
  api.Cache.Remove(GetCacheKey(documentId));
17430
- api.Cache.RemoveByStartsWith(GetListCacheKey(documentId));
17497
+ // Only the document ID is known here, not the lists it was part of.
17498
+ api.Cache.RemoveByStartsWith(GetListCacheKeyPrefix());
17431
17499
  });
17432
17500
  }
17433
17501
  OntologyDocument.Delete = Delete;
@@ -17454,9 +17522,18 @@
17454
17522
  }
17455
17523
  OntologyDocument.GetCacheKey = GetCacheKey;
17456
17524
  function GetListCacheKey(id) {
17457
- return exports.Api.ECacheKey.Ontology + ":documents:" + id;
17525
+ return GetListCacheKeyPrefix() + id;
17458
17526
  }
17459
17527
  OntologyDocument.GetListCacheKey = GetListCacheKey;
17528
+ function GetSummaryListCacheKey(clientFileId) {
17529
+ return GetListCacheKeyPrefix() + "summary:" + clientFileId;
17530
+ }
17531
+ OntologyDocument.GetSummaryListCacheKey = GetSummaryListCacheKey;
17532
+ // Shared by every document list cache key.
17533
+ function GetListCacheKeyPrefix() {
17534
+ return exports.Api.ECacheKey.Ontology + ":documents:";
17535
+ }
17536
+ OntologyDocument.GetListCacheKeyPrefix = GetListCacheKeyPrefix;
17460
17537
  })(exports.OntologyDocument || (exports.OntologyDocument = {}));
17461
17538
  function parseObject$4(data) {
17462
17539
  if (data == null || data == undefined) {
@@ -24565,7 +24642,7 @@
24565
24642
  }
24566
24643
 
24567
24644
  // This is updated with the package.json version on build.
24568
- const VERSION = "7.1.110";
24645
+ const VERSION = "7.1.111";
24569
24646
 
24570
24647
  exports.VERSION = VERSION;
24571
24648
  exports.AbstractApi = AbstractApi;