bruce-models 5.2.7 → 5.2.9

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.
@@ -3268,7 +3268,7 @@
3268
3268
  */
3269
3269
  function GetListByIds(params) {
3270
3270
  return __awaiter(this, void 0, void 0, function* () {
3271
- let { api, entityIds, migrated, schemaId, req: reqParams, expandRelations, expandLocation, historicFrom, historicKey, historicTo, historicPoint, expandSources, expandImports } = params;
3271
+ let { api, entityIds, migrated, schemaId, req: reqParams, expandRelations, expandLocation, historicFrom, historicKey, historicTo, historicPoint, expandSources, expandImports, maxSearchTimeSec } = params;
3272
3272
  if (!entityIds.length) {
3273
3273
  throw ("Entity IDs are required.");
3274
3274
  }
@@ -3334,6 +3334,9 @@
3334
3334
  if (schemaId) {
3335
3335
  urlParams.set("schema", schemaId);
3336
3336
  }
3337
+ if (maxSearchTimeSec) {
3338
+ urlParams.set("MaxSearchTimeSec", String(Math.ceil(maxSearchTimeSec)));
3339
+ }
3337
3340
  urlParams.set("hasMigrated", String(Boolean(migrated)));
3338
3341
  const url = `entities?${urlParams.toString()}`;
3339
3342
  const reqs = [];
@@ -3444,28 +3447,63 @@
3444
3447
  * @returns
3445
3448
  */
3446
3449
  function Update(params) {
3447
- var _a, _b;
3448
- return __awaiter(this, void 0, void 0, function* () {
3449
- let { api, entity: data, override, req: reqParams, migrated } = params;
3450
- if (!((_a = data === null || data === void 0 ? void 0 : data.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"])) {
3451
- throw ("Entity Type ID is required.");
3452
- }
3453
- if (!api) {
3454
- api = exports.ENVIRONMENT.Api().GetBruceApi();
3455
- }
3456
- if (!((_b = data === null || data === void 0 ? void 0 : data.Bruce) === null || _b === void 0 ? void 0 : _b.ID)) {
3457
- data.Bruce = Object.assign(Object.assign({}, data.Bruce), { ID: exports.ObjectUtils.UId() });
3450
+ var _a, _b, _c, _d, _e;
3451
+ return __awaiter(this, void 0, void 0, function* () {
3452
+ let { api, entity: data, entities, override, req: reqParams, migrated } = params;
3453
+ // Bulk save.
3454
+ if ((entities === null || entities === void 0 ? void 0 : entities.length) && entities.length > 1) {
3455
+ // If the Entities don't have IDs, then they must have a Type ID.
3456
+ for (let i = 0; i < entities.length; i++) {
3457
+ const entity = entities[i];
3458
+ if (!((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID) && !((_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"])) {
3459
+ throw ("Entity Type ID is required for new Entity records.");
3460
+ }
3461
+ }
3462
+ if (!api) {
3463
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
3464
+ }
3465
+ const reqUrl = `v3/entities`;
3466
+ const reqBody = {
3467
+ Items: entities,
3468
+ Override: override
3469
+ };
3470
+ const res = yield api.POST(reqUrl, reqBody, exports.Api.PrepReqParams(reqParams));
3471
+ entities = res.Items;
3472
+ for (let i = 0; i < entities.length; i++) {
3473
+ const entity = entities[i];
3474
+ const entityId = (_c = entity.Bruce) === null || _c === void 0 ? void 0 : _c.ID; // Should never be null.
3475
+ api.Cache.RemoveByContains(GetContainsKey(entityId));
3476
+ exports.EntityHistoricData.ClearCacheByEntityIds(api, [entityId]);
3477
+ }
3478
+ return {
3479
+ entities
3480
+ };
3458
3481
  }
3459
- let reqUrl = `entity/${data.Bruce.ID}/?dataoverride=${override}&BruceEntityType=${data.Bruce["EntityType.ID"]}`;
3460
- if (migrated) {
3461
- reqUrl += "&hasMigrated=true";
3482
+ // Single save.
3483
+ else {
3484
+ if (!data && (entities === null || entities === void 0 ? void 0 : entities.length)) {
3485
+ data = entities[0];
3486
+ }
3487
+ if (!((_d = data === null || data === void 0 ? void 0 : data.Bruce) === null || _d === void 0 ? void 0 : _d["EntityType.ID"])) {
3488
+ throw ("Entity Type ID is required.");
3489
+ }
3490
+ if (!api) {
3491
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
3492
+ }
3493
+ if (!((_e = data === null || data === void 0 ? void 0 : data.Bruce) === null || _e === void 0 ? void 0 : _e.ID)) {
3494
+ data.Bruce = Object.assign(Object.assign({}, data.Bruce), { ID: exports.ObjectUtils.UId() });
3495
+ }
3496
+ let reqUrl = `entity/${data.Bruce.ID}/?dataoverride=${override}&BruceEntityType=${data.Bruce["EntityType.ID"]}`;
3497
+ if (migrated) {
3498
+ reqUrl += "&hasMigrated=true";
3499
+ }
3500
+ const res = yield api.POST(reqUrl, data, exports.Api.PrepReqParams(reqParams));
3501
+ api.Cache.RemoveByContains(GetContainsKey(data.Bruce.ID));
3502
+ exports.EntityHistoricData.ClearCacheByEntityIds(api, [data.Bruce.ID]);
3503
+ return {
3504
+ entity: res
3505
+ };
3462
3506
  }
3463
- const res = yield api.POST(reqUrl, data, exports.Api.PrepReqParams(reqParams));
3464
- api.Cache.RemoveByContains(GetContainsKey(data.Bruce.ID));
3465
- exports.EntityHistoricData.ClearCacheByEntityIds(api, [data.Bruce.ID]);
3466
- return {
3467
- entity: res
3468
- };
3469
3507
  });
3470
3508
  }
3471
3509
  Entity.Update = Update;
@@ -3741,7 +3779,7 @@
3741
3779
  function GetList(params) {
3742
3780
  var _a;
3743
3781
  return __awaiter(this, void 0, void 0, function* () {
3744
- let { api, filter, migrated, schemaId, req: reqParams, viaCdn, viaCdnCacheToken, analysis, expandRelations, expandImports, historicFrom, historicKey, historicTo, historicPoint, expandLocation, expandSources } = params;
3782
+ let { api, filter, migrated, schemaId, req: reqParams, viaCdn, viaCdnCacheToken, analysis, expandRelations, expandImports, historicFrom, historicKey, historicTo, historicPoint, expandLocation, expandSources, maxSearchTimeSec } = params;
3745
3783
  if (!api) {
3746
3784
  api = exports.ENVIRONMENT.Api().GetBruceApi();
3747
3785
  }
@@ -3859,6 +3897,9 @@
3859
3897
  if (schemaId) {
3860
3898
  urlParams.set("schema", schemaId);
3861
3899
  }
3900
+ if (maxSearchTimeSec) {
3901
+ urlParams.set("MaxSearchTimeSec", String(Math.ceil(maxSearchTimeSec)));
3902
+ }
3862
3903
  urlParams.set("hasMigrated", String(Boolean(migrated)));
3863
3904
  let url = analysis ? "entities/summary" : "entities";
3864
3905
  // Adding url params here because this will avoid making them encoded.
@@ -3889,6 +3930,9 @@
3889
3930
  if (schemaId) {
3890
3931
  urlParams.set("schema", schemaId);
3891
3932
  }
3933
+ if (maxSearchTimeSec) {
3934
+ urlParams.set("MaxSearchTimeSec", String(Math.ceil(maxSearchTimeSec)));
3935
+ }
3892
3936
  urlParams.set("hasMigrated", String(Boolean(migrated)));
3893
3937
  let url = analysis ? "entities/summary" : "entities";
3894
3938
  // Adding url params here because this will avoid making them encoded.
@@ -14325,7 +14369,7 @@
14325
14369
  })(exports.DataSource || (exports.DataSource = {}));
14326
14370
 
14327
14371
  // This is updated with the package.json version on build.
14328
- const VERSION = "5.2.7";
14372
+ const VERSION = "5.2.9";
14329
14373
 
14330
14374
  exports.VERSION = VERSION;
14331
14375
  exports.AbstractApi = AbstractApi;