bruce-models 5.2.8 → 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.
@@ -3490,28 +3490,63 @@ var Entity;
3490
3490
  * @returns
3491
3491
  */
3492
3492
  function Update(params) {
3493
- var _a, _b;
3494
- return __awaiter(this, void 0, void 0, function* () {
3495
- let { api, entity: data, override, req: reqParams, migrated } = params;
3496
- if (!((_a = data === null || data === void 0 ? void 0 : data.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"])) {
3497
- throw ("Entity Type ID is required.");
3498
- }
3499
- if (!api) {
3500
- api = ENVIRONMENT.Api().GetBruceApi();
3501
- }
3502
- if (!((_b = data === null || data === void 0 ? void 0 : data.Bruce) === null || _b === void 0 ? void 0 : _b.ID)) {
3503
- data.Bruce = Object.assign(Object.assign({}, data.Bruce), { ID: ObjectUtils.UId() });
3493
+ var _a, _b, _c, _d, _e;
3494
+ return __awaiter(this, void 0, void 0, function* () {
3495
+ let { api, entity: data, entities, override, req: reqParams, migrated } = params;
3496
+ // Bulk save.
3497
+ if ((entities === null || entities === void 0 ? void 0 : entities.length) && entities.length > 1) {
3498
+ // If the Entities don't have IDs, then they must have a Type ID.
3499
+ for (let i = 0; i < entities.length; i++) {
3500
+ const entity = entities[i];
3501
+ if (!((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID) && !((_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"])) {
3502
+ throw ("Entity Type ID is required for new Entity records.");
3503
+ }
3504
+ }
3505
+ if (!api) {
3506
+ api = ENVIRONMENT.Api().GetBruceApi();
3507
+ }
3508
+ const reqUrl = `v3/entities`;
3509
+ const reqBody = {
3510
+ Items: entities,
3511
+ Override: override
3512
+ };
3513
+ const res = yield api.POST(reqUrl, reqBody, Api.PrepReqParams(reqParams));
3514
+ entities = res.Items;
3515
+ for (let i = 0; i < entities.length; i++) {
3516
+ const entity = entities[i];
3517
+ const entityId = (_c = entity.Bruce) === null || _c === void 0 ? void 0 : _c.ID; // Should never be null.
3518
+ api.Cache.RemoveByContains(GetContainsKey(entityId));
3519
+ EntityHistoricData.ClearCacheByEntityIds(api, [entityId]);
3520
+ }
3521
+ return {
3522
+ entities
3523
+ };
3504
3524
  }
3505
- let reqUrl = `entity/${data.Bruce.ID}/?dataoverride=${override}&BruceEntityType=${data.Bruce["EntityType.ID"]}`;
3506
- if (migrated) {
3507
- reqUrl += "&hasMigrated=true";
3525
+ // Single save.
3526
+ else {
3527
+ if (!data && (entities === null || entities === void 0 ? void 0 : entities.length)) {
3528
+ data = entities[0];
3529
+ }
3530
+ if (!((_d = data === null || data === void 0 ? void 0 : data.Bruce) === null || _d === void 0 ? void 0 : _d["EntityType.ID"])) {
3531
+ throw ("Entity Type ID is required.");
3532
+ }
3533
+ if (!api) {
3534
+ api = ENVIRONMENT.Api().GetBruceApi();
3535
+ }
3536
+ if (!((_e = data === null || data === void 0 ? void 0 : data.Bruce) === null || _e === void 0 ? void 0 : _e.ID)) {
3537
+ data.Bruce = Object.assign(Object.assign({}, data.Bruce), { ID: ObjectUtils.UId() });
3538
+ }
3539
+ let reqUrl = `entity/${data.Bruce.ID}/?dataoverride=${override}&BruceEntityType=${data.Bruce["EntityType.ID"]}`;
3540
+ if (migrated) {
3541
+ reqUrl += "&hasMigrated=true";
3542
+ }
3543
+ const res = yield api.POST(reqUrl, data, Api.PrepReqParams(reqParams));
3544
+ api.Cache.RemoveByContains(GetContainsKey(data.Bruce.ID));
3545
+ EntityHistoricData.ClearCacheByEntityIds(api, [data.Bruce.ID]);
3546
+ return {
3547
+ entity: res
3548
+ };
3508
3549
  }
3509
- const res = yield api.POST(reqUrl, data, Api.PrepReqParams(reqParams));
3510
- api.Cache.RemoveByContains(GetContainsKey(data.Bruce.ID));
3511
- EntityHistoricData.ClearCacheByEntityIds(api, [data.Bruce.ID]);
3512
- return {
3513
- entity: res
3514
- };
3515
3550
  });
3516
3551
  }
3517
3552
  Entity.Update = Update;
@@ -14614,7 +14649,7 @@ var DataSource;
14614
14649
  })(DataSource || (DataSource = {}));
14615
14650
 
14616
14651
  // This is updated with the package.json version on build.
14617
- const VERSION = "5.2.8";
14652
+ const VERSION = "5.2.9";
14618
14653
 
14619
14654
  export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, GeoJson, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, AccountLimits, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportedFile, ExportBrz, ExportUsd, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
14620
14655
  //# sourceMappingURL=bruce-models.es5.js.map