bruce-models 1.8.8 → 1.9.1

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.
@@ -62,6 +62,7 @@ var Api;
62
62
  ECacheKey["DatabaseRegion"] = "databaseregion";
63
63
  ECacheKey["CustomForm"] = "customform";
64
64
  ECacheKey["ImportedFile"] = "importedfile";
65
+ ECacheKey["Plugin"] = "plugin";
65
66
  })(ECacheKey = Api.ECacheKey || (Api.ECacheKey = {}));
66
67
  Api.DEFAULT_CACHE_DURATION = 60 * 5; // 5 minutes.
67
68
  Api.TEMPLATE_ACCOUNT_ID = "template";
@@ -2941,8 +2942,8 @@ var EntityAttachmentType;
2941
2942
  */
2942
2943
  var EntityAttachment;
2943
2944
  (function (EntityAttachment) {
2944
- function GetCacheKey(entityId, typeId, fileId) {
2945
- return Api.ECacheKey.Attachment + Api.ECacheKey.Id + entityId + Api.ECacheKey.Id + typeId + Api.ECacheKey.Id + fileId;
2945
+ function GetCacheKey(id) {
2946
+ return Api.ECacheKey.Attachment + Api.ECacheKey.Id + id;
2946
2947
  }
2947
2948
  EntityAttachment.GetCacheKey = GetCacheKey;
2948
2949
  function GetListCacheKey(entityId) {
@@ -2951,33 +2952,40 @@ var EntityAttachment;
2951
2952
  EntityAttachment.GetListCacheKey = GetListCacheKey;
2952
2953
  function Update(params) {
2953
2954
  return __awaiter(this, void 0, void 0, function* () {
2954
- const { api, attachment: data, req: reqParams } = params;
2955
- if (!(data === null || data === void 0 ? void 0 : data["Entity.ID"]) || !(data === null || data === void 0 ? void 0 : data["EntityAttachmentType.ID"]) || !(data === null || data === void 0 ? void 0 : data["ClientFile.ID"])) {
2956
- throw ("Entity ID, Type ID, and File ID are required.");
2955
+ const { api, attachments, req, entityId } = params;
2956
+ if (!(attachments === null || attachments === void 0 ? void 0 : attachments.length)) {
2957
+ return {
2958
+ attachments: []
2959
+ };
2960
+ }
2961
+ const res = yield api.POST(`entity/${entityId}/attachments`, {
2962
+ attachments
2963
+ }, Api.PrepReqParams(req));
2964
+ for (let i = 0; i < attachments.length; i++) {
2965
+ if (attachments[i].ID) {
2966
+ api.Cache.Remove(GetCacheKey(attachments[i].ID));
2967
+ }
2957
2968
  }
2958
- const url = `entity/${data["Entity.ID"]}/attachment/${data.oldAttachmentTypeId}/${data["ClientFile.ID"]}`;
2959
- const res = yield api.PUT(url, data, Api.PrepReqParams(reqParams));
2960
- api.Cache.Remove(GetCacheKey(data["Entity.ID"], data["EntityAttachmentType.ID"], data["ClientFile.ID"]));
2961
- api.Cache.RemoveByStartsWith(GetListCacheKey(data["Entity.ID"]));
2969
+ api.Cache.Remove(GetListCacheKey(entityId));
2962
2970
  return {
2963
- attachment: res
2971
+ attachments: res.attachments
2964
2972
  };
2965
2973
  });
2966
2974
  }
2967
2975
  EntityAttachment.Update = Update;
2968
2976
  function UpdateOrder(params) {
2969
2977
  return __awaiter(this, void 0, void 0, function* () {
2970
- const { api, entityId, attachmentTypeId: typeId, fileIds, req: reqParams } = params;
2971
- if (!entityId || !typeId || !(fileIds === null || fileIds === void 0 ? void 0 : fileIds.length)) {
2972
- throw ("Entity ID, Type ID, and File IDs are required.");
2978
+ const { api, entityId, attachmentTypeId: typeId, attachments, req: reqParams } = params;
2979
+ if (!entityId || !typeId || !(attachments === null || attachments === void 0 ? void 0 : attachments.length)) {
2980
+ throw ("Entity ID, Type ID, and Attachments are required.");
2973
2981
  }
2974
2982
  const reqData = {
2975
2983
  "DisplayOrder.Start": 0,
2976
- "ClientFile.ID": fileIds
2984
+ "ClientFile.ID": attachments.map(x => x["ClientFile.ID"])
2977
2985
  };
2978
2986
  yield api.POST(`entity/${entityId}/attachments/${typeId}/setOrder`, reqData, Api.PrepReqParams(reqParams));
2979
- for (let i = 0; i < fileIds.length; i++) {
2980
- api.Cache.Remove(GetCacheKey(entityId, typeId, fileIds[i]));
2987
+ for (let i = 0; i < attachments.length; i++) {
2988
+ api.Cache.Remove(GetCacheKey(attachments[i].ID));
2981
2989
  }
2982
2990
  api.Cache.RemoveByStartsWith(GetListCacheKey(entityId));
2983
2991
  });
@@ -2985,36 +2993,15 @@ var EntityAttachment;
2985
2993
  EntityAttachment.UpdateOrder = UpdateOrder;
2986
2994
  function Delete(params) {
2987
2995
  return __awaiter(this, void 0, void 0, function* () {
2988
- const { api, attachment: data, req: reqParams } = params;
2989
- if (!(data === null || data === void 0 ? void 0 : data["Entity.ID"]) || !(data === null || data === void 0 ? void 0 : data["EntityAttachmentType.ID"]) || !(data === null || data === void 0 ? void 0 : data["ClientFile.ID"])) {
2990
- throw ("Entity ID, Type ID, and File ID are required.");
2996
+ const { api, attachmentId, entityId, req } = params;
2997
+ if (!attachmentId || !entityId) {
2998
+ throw ("Entity id and attachment id.");
2991
2999
  }
2992
- const reqData = {
2993
- "ClientFile.ID": [data["ClientFile.ID"]]
2994
- };
2995
- yield api.POST(`entity/${data["Entity.ID"]}/attachments/${data["EntityAttachmentType.ID"]}/delete`, reqData, Api.PrepReqParams(reqParams));
2996
- api.Cache.Remove(GetCacheKey(data["Entity.ID"], data["EntityAttachmentType.ID"], data["ClientFile.ID"]));
2997
- api.Cache.RemoveByStartsWith(GetListCacheKey(data["Entity.ID"]));
3000
+ yield api.DELETE(`entity/${entityId}/attachments/${attachmentId}`, Api.PrepReqParams(req));
3001
+ api.Cache.Remove(GetCacheKey(attachmentId));
2998
3002
  });
2999
3003
  }
3000
3004
  EntityAttachment.Delete = Delete;
3001
- function DeleteByFileIds(params) {
3002
- return __awaiter(this, void 0, void 0, function* () {
3003
- const { api, entityId, attachmentTypeId: typeId, fileIds, req: reqParams } = params;
3004
- if (!entityId || !typeId || !(fileIds === null || fileIds === void 0 ? void 0 : fileIds.length)) {
3005
- throw ("Entity ID, Type ID, and File IDs are required.");
3006
- }
3007
- const reqData = {
3008
- "ClientFile.ID": fileIds
3009
- };
3010
- yield api.POST(`entity/${entityId}/attachments/${typeId}/delete`, reqData, Api.PrepReqParams(reqParams));
3011
- for (let i = 0; i < fileIds.length; i++) {
3012
- api.Cache.Remove(GetCacheKey(entityId, typeId, fileIds[i]));
3013
- }
3014
- api.Cache.RemoveByStartsWith(GetListCacheKey(entityId));
3015
- });
3016
- }
3017
- EntityAttachment.DeleteByFileIds = DeleteByFileIds;
3018
3005
  function GetListByEntityId(params) {
3019
3006
  return __awaiter(this, void 0, void 0, function* () {
3020
3007
  const { api, entityId, req: reqParams } = params;
@@ -3029,7 +3016,7 @@ var EntityAttachment;
3029
3016
  try {
3030
3017
  const data = yield api.GET(`entity/${entityId}/attachments`, Api.PrepReqParams(reqParams));
3031
3018
  res({
3032
- attachments: data.Items
3019
+ attachments: (data.attachments ? data.attachments : data.Items)
3033
3020
  });
3034
3021
  }
3035
3022
  catch (e) {
@@ -3049,7 +3036,7 @@ var EntityAttachment;
3049
3036
  }
3050
3037
  const url = `entity/${entityId}/attachment/${typeId}`;
3051
3038
  const res = yield api.UPLOAD(url, file, Api.PrepReqParams(reqParams));
3052
- api.Cache.RemoveByStartsWith(GetListCacheKey(entityId));
3039
+ api.Cache.Remove(GetListCacheKey(entityId));
3053
3040
  return {
3054
3041
  attachment: res
3055
3042
  };
@@ -7473,5 +7460,76 @@ var Markup;
7473
7460
  })(Circle = Markup.Circle || (Markup.Circle = {}));
7474
7461
  })(Markup || (Markup = {}));
7475
7462
 
7476
- export { AnnDocument, CustomForm, CustomFormContent, AbstractApi, Api, BruceApi, CamApi, IdmApi, GlobalApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityGlobe, EntityFilterGetter, BatchedDataGetter, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, PendingAction, MessageBroker, Style, Tileset, Permission, Session, UserGroup, User, Account, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader };
7463
+ var Plugin;
7464
+ (function (Plugin$$1) {
7465
+ function GetCacheKey(pluginId) {
7466
+ return `${Api.ECacheKey.Plugin}${Api.ECacheKey.Id}${pluginId}`;
7467
+ }
7468
+ Plugin$$1.GetCacheKey = GetCacheKey;
7469
+ function GetListCacheKey() {
7470
+ return Api.ECacheKey.Plugin;
7471
+ }
7472
+ Plugin$$1.GetListCacheKey = GetListCacheKey;
7473
+ function Get(params) {
7474
+ return __awaiter(this, void 0, void 0, function* () {
7475
+ const { api, pluginId, req } = params;
7476
+ if (!pluginId) {
7477
+ throw ("Plugin ID is required.");
7478
+ }
7479
+ const cacheData = api.GetCacheItem(GetCacheKey(pluginId), req);
7480
+ if (cacheData) {
7481
+ return cacheData;
7482
+ }
7483
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
7484
+ try {
7485
+ const data = yield api.GET(`ui.plugin/${pluginId}`, Api.PrepReqParams(req));
7486
+ res({
7487
+ plugin: data
7488
+ });
7489
+ }
7490
+ catch (e) {
7491
+ rej(e);
7492
+ }
7493
+ }));
7494
+ api.Cache.Set(GetCacheKey(pluginId), prom, Api.DEFAULT_CACHE_DURATION);
7495
+ return prom;
7496
+ });
7497
+ }
7498
+ Plugin$$1.Get = Get;
7499
+ function GetList(params) {
7500
+ return __awaiter(this, void 0, void 0, function* () {
7501
+ const { api, req } = params;
7502
+ const cacheData = api.GetCacheItem(GetListCacheKey(), req);
7503
+ if (cacheData) {
7504
+ return cacheData;
7505
+ }
7506
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
7507
+ try {
7508
+ const data = yield api.GET("ui.plugins", Api.PrepReqParams(req));
7509
+ res({
7510
+ plugins: data.Items
7511
+ });
7512
+ }
7513
+ catch (e) {
7514
+ rej(e);
7515
+ }
7516
+ }));
7517
+ api.Cache.Set(GetListCacheKey(), prom, Api.DEFAULT_CACHE_DURATION);
7518
+ return prom;
7519
+ });
7520
+ }
7521
+ Plugin$$1.GetList = GetList;
7522
+ function GetLoadUrl(params) {
7523
+ let { api, pluginId, req, cacheKey } = params;
7524
+ if (!cacheKey) {
7525
+ cacheKey = 0;
7526
+ }
7527
+ return {
7528
+ indexFileUrl: `${api.GetBaseUrl()}ui.plugin/${pluginId}/file/index.jsc?version=${cacheKey}`
7529
+ };
7530
+ }
7531
+ Plugin$$1.GetLoadUrl = GetLoadUrl;
7532
+ })(Plugin || (Plugin = {}));
7533
+
7534
+ export { AnnDocument, CustomForm, CustomFormContent, AbstractApi, Api, BruceApi, CamApi, IdmApi, GlobalApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityGlobe, EntityFilterGetter, BatchedDataGetter, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, PendingAction, MessageBroker, Style, Tileset, Permission, Session, UserGroup, User, Account, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin };
7477
7535
  //# sourceMappingURL=bruce-models.es5.js.map