bruce-models 5.2.8 → 5.3.0

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.
@@ -3447,28 +3447,63 @@
3447
3447
  * @returns
3448
3448
  */
3449
3449
  function Update(params) {
3450
- var _a, _b;
3451
- return __awaiter(this, void 0, void 0, function* () {
3452
- let { api, entity: data, override, req: reqParams, migrated } = params;
3453
- if (!((_a = data === null || data === void 0 ? void 0 : data.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"])) {
3454
- throw ("Entity Type ID is required.");
3455
- }
3456
- if (!api) {
3457
- api = exports.ENVIRONMENT.Api().GetBruceApi();
3458
- }
3459
- if (!((_b = data === null || data === void 0 ? void 0 : data.Bruce) === null || _b === void 0 ? void 0 : _b.ID)) {
3460
- 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
+ };
3461
3481
  }
3462
- let reqUrl = `entity/${data.Bruce.ID}/?dataoverride=${override}&BruceEntityType=${data.Bruce["EntityType.ID"]}`;
3463
- if (migrated) {
3464
- 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
+ };
3465
3506
  }
3466
- const res = yield api.POST(reqUrl, data, exports.Api.PrepReqParams(reqParams));
3467
- api.Cache.RemoveByContains(GetContainsKey(data.Bruce.ID));
3468
- exports.EntityHistoricData.ClearCacheByEntityIds(api, [data.Bruce.ID]);
3469
- return {
3470
- entity: res
3471
- };
3472
3507
  });
3473
3508
  }
3474
3509
  Entity.Update = Update;
@@ -10016,6 +10051,7 @@
10016
10051
  let EContentType;
10017
10052
  (function (EContentType) {
10018
10053
  EContentType["WEB_3D"] = "WEB_3D";
10054
+ EContentType["WEB_3D_SPLIT_PLUGIN"] = "WEB_3D_SPLIT_PLUGIN";
10019
10055
  EContentType["IFRAME"] = "IFRAME";
10020
10056
  })(EContentType = ProjectViewBookmark.EContentType || (ProjectViewBookmark.EContentType = {}));
10021
10057
  /**
@@ -14334,7 +14370,7 @@
14334
14370
  })(exports.DataSource || (exports.DataSource = {}));
14335
14371
 
14336
14372
  // This is updated with the package.json version on build.
14337
- const VERSION = "5.2.8";
14373
+ const VERSION = "5.3.0";
14338
14374
 
14339
14375
  exports.VERSION = VERSION;
14340
14376
  exports.AbstractApi = AbstractApi;