bruce-models 3.6.8 → 3.7.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.
@@ -71,6 +71,7 @@ var Api;
71
71
  ECacheKey["CustomForm"] = "customform";
72
72
  ECacheKey["ImportedFile"] = "importedfile";
73
73
  ECacheKey["Plugin"] = "plugin";
74
+ ECacheKey["PluginIndexFile"] = "pluginindexfile";
74
75
  })(ECacheKey = Api.ECacheKey || (Api.ECacheKey = {}));
75
76
  // 1 minute.
76
77
  Api.DEFAULT_CACHE_DURATION = 60 * 1000;
@@ -9984,6 +9985,98 @@ var AccountInvite;
9984
9985
  AccountInvite.Create = Create;
9985
9986
  })(AccountInvite || (AccountInvite = {}));
9986
9987
 
9988
+ /**
9989
+ * Account Features are a set of flags that can be enabled or disabled for an account.
9990
+ * These flags usually represent how data is stored and managed.
9991
+ */
9992
+ var AccountFeatures;
9993
+ (function (AccountFeatures) {
9994
+ let EFeature;
9995
+ (function (EFeature) {
9996
+ // Flag to enable data to be stored in the JSON column type.
9997
+ // This will enable conversion of the data, and will also enable searches to use that instead.
9998
+ EFeature["EntityJsonData"] = "Feature_Entity_JSONData";
9999
+ // Flag to enable a text search against JSON data values.
10000
+ // 'EntityJsonData' must also be enabled.
10001
+ EFeature["EntityLexicalSearch"] = "Feature_Entity_Lexical_Search";
10002
+ })(EFeature = AccountFeatures.EFeature || (AccountFeatures.EFeature = {}));
10003
+ /**
10004
+ * Gets account features corresponding to an account ID.
10005
+ * @param params
10006
+ * @returns
10007
+ */
10008
+ function Get(params) {
10009
+ return __awaiter(this, void 0, void 0, function* () {
10010
+ let { api, accountId: id, req: reqParams } = params;
10011
+ if (!api) {
10012
+ api = ENVIRONMENT.Api().GetBruceApi();
10013
+ }
10014
+ const cache = yield api.GetCacheItem(GetCacheKey(id), reqParams);
10015
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
10016
+ return cache.data;
10017
+ }
10018
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
10019
+ try {
10020
+ const data = yield api.GET("features", reqParams);
10021
+ const features = data === null || data === void 0 ? void 0 : data.Features;
10022
+ res({
10023
+ features: features ? features : {}
10024
+ });
10025
+ }
10026
+ catch (e) {
10027
+ rej(e);
10028
+ }
10029
+ }));
10030
+ api.SetCacheItem({
10031
+ key: GetCacheKey(id),
10032
+ value: prom,
10033
+ req: reqParams
10034
+ });
10035
+ return prom;
10036
+ });
10037
+ }
10038
+ AccountFeatures.Get = Get;
10039
+ function Update(params) {
10040
+ return __awaiter(this, void 0, void 0, function* () {
10041
+ let { api, accountId: id, features, req: reqParams } = params;
10042
+ if (!api) {
10043
+ api = ENVIRONMENT.Api().GetBruceApi();
10044
+ }
10045
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
10046
+ try {
10047
+ const data = yield api.POST("features", {
10048
+ Features: features
10049
+ }, reqParams);
10050
+ const updated = data === null || data === void 0 ? void 0 : data.Features;
10051
+ res({
10052
+ features: updated ? updated : {}
10053
+ });
10054
+ }
10055
+ catch (e) {
10056
+ rej(e);
10057
+ }
10058
+ }));
10059
+ api.Cache.Remove(GetCacheKey(id));
10060
+ return prom;
10061
+ });
10062
+ }
10063
+ AccountFeatures.Update = Update;
10064
+ /**
10065
+ * Returns cache identifier for an account by ID.
10066
+ * Example: {
10067
+ * const api: BruceApi.Api = ...;
10068
+ * const key = GetCacheKey("my-account-id");
10069
+ * api.Cache.Remove(key);
10070
+ * }
10071
+ * @param accountId
10072
+ * @returns
10073
+ */
10074
+ function GetCacheKey(accountId) {
10075
+ return Api.ECacheKey.AccountFeatures + Api.ECacheKey.Id + accountId;
10076
+ }
10077
+ AccountFeatures.GetCacheKey = GetCacheKey;
10078
+ })(AccountFeatures || (AccountFeatures = {}));
10079
+
9987
10080
  var EncryptUtils;
9988
10081
  (function (EncryptUtils) {
9989
10082
  // https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
@@ -10536,33 +10629,6 @@ var Markup;
10536
10629
 
10537
10630
  var Plugin;
10538
10631
  (function (Plugin) {
10539
- /**
10540
- * Returns cache identifier for a plugin.
10541
- * Example: {
10542
- * const api: BruceApi.Api = ...;
10543
- * const key = GetCacheKey("abc");
10544
- * api.Cache.Remove(key);
10545
- * }
10546
- * @param pluginId
10547
- * @returns
10548
- */
10549
- function GetCacheKey(pluginId) {
10550
- return `${Api.ECacheKey.Plugin}${Api.ECacheKey.Id}${pluginId}`;
10551
- }
10552
- Plugin.GetCacheKey = GetCacheKey;
10553
- /**
10554
- * Returns cache identifier for a list of plugins.
10555
- * Example: {
10556
- * const api: BruceApi.Api = ...;
10557
- * const key = GetListCacheKey();
10558
- * api.Cache.Remove(key);
10559
- * }
10560
- * @returns
10561
- */
10562
- function GetListCacheKey() {
10563
- return Api.ECacheKey.Plugin;
10564
- }
10565
- Plugin.GetListCacheKey = GetListCacheKey;
10566
10632
  /**
10567
10633
  * Returns a plugin record.
10568
10634
  * @param params
@@ -10673,6 +10739,7 @@ var Plugin;
10673
10739
  yield api.POST(`ui.plugin/${plugin.ID}`, plugin, Api.PrepReqParams(req));
10674
10740
  api.Cache.Remove(GetCacheKey(plugin.ID));
10675
10741
  api.Cache.Remove(GetListCacheKey());
10742
+ api.Cache.RemoveByStartsWith(GetIndexFileCacheKey(plugin.ID, ""));
10676
10743
  });
10677
10744
  }
10678
10745
  Plugin.Update = Update;
@@ -10692,6 +10759,7 @@ var Plugin;
10692
10759
  yield api.DELETE(`ui.plugin/${pluginId}`, Api.PrepReqParams(req));
10693
10760
  api.Cache.Remove(GetCacheKey(pluginId));
10694
10761
  api.Cache.Remove(GetListCacheKey());
10762
+ api.Cache.RemoveByStartsWith(GetIndexFileCacheKey(pluginId, ""));
10695
10763
  });
10696
10764
  }
10697
10765
  Plugin.Delete = Delete;
@@ -10720,6 +10788,7 @@ var Plugin;
10720
10788
  yield api.UPLOAD(`ui.plugin/${pluginId}/file`, file, req);
10721
10789
  api.Cache.Remove(GetCacheKey(pluginId));
10722
10790
  api.Cache.Remove(GetListCacheKey());
10791
+ api.Cache.RemoveByStartsWith(GetIndexFileCacheKey(pluginId, ""));
10723
10792
  });
10724
10793
  }
10725
10794
  Plugin.Upload = Upload;
@@ -10731,7 +10800,7 @@ var Plugin;
10731
10800
  */
10732
10801
  function GetRunFunction(params) {
10733
10802
  return __awaiter(this, void 0, void 0, function* () {
10734
- let { containerId, container, pluginParams, pluginId, plugin, api } = params;
10803
+ let { containerId, container, pluginParams, pluginId, plugin, api, req } = params;
10735
10804
  if (!containerId && container) {
10736
10805
  containerId = container.id;
10737
10806
  if (!containerId) {
@@ -10753,7 +10822,21 @@ var Plugin;
10753
10822
  pluginId,
10754
10823
  cacheKey: plugin.Version
10755
10824
  });
10756
- let fileContent = yield fetch(indexFileUrl).then((res) => res.text());
10825
+ req = Api.PrepReqParams(req);
10826
+ const cacheData = api.GetCacheItem(GetIndexFileCacheKey(pluginId, indexFileUrl), req);
10827
+ let fileContentProm = null;
10828
+ if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
10829
+ fileContentProm = cacheData.data;
10830
+ }
10831
+ else {
10832
+ fileContentProm = fetch(indexFileUrl).then((res) => res.text());
10833
+ api.SetCacheItem({
10834
+ key: GetIndexFileCacheKey(pluginId, indexFileUrl),
10835
+ value: fileContentProm,
10836
+ req: req
10837
+ });
10838
+ }
10839
+ let fileContent = yield fileContentProm;
10757
10840
  const start = fileContent.indexOf("{");
10758
10841
  const end = fileContent.lastIndexOf("}");
10759
10842
  fileContent = fileContent.substring(start + 1, end);
@@ -10819,6 +10902,43 @@ var Plugin;
10819
10902
  });
10820
10903
  }
10821
10904
  Plugin.GetRunFunction = GetRunFunction;
10905
+ /**
10906
+ * Returns cache identifier for a plugin.
10907
+ * Example: {
10908
+ * const api: BruceApi.Api = ...;
10909
+ * const key = GetCacheKey("abc");
10910
+ * api.Cache.Remove(key);
10911
+ * }
10912
+ * @param pluginId
10913
+ * @returns
10914
+ */
10915
+ function GetCacheKey(pluginId) {
10916
+ return `${Api.ECacheKey.Plugin}${Api.ECacheKey.Id}${pluginId}`;
10917
+ }
10918
+ Plugin.GetCacheKey = GetCacheKey;
10919
+ /**
10920
+ * Returns cache identifier for a list of plugins.
10921
+ * Example: {
10922
+ * const api: BruceApi.Api = ...;
10923
+ * const key = GetListCacheKey();
10924
+ * api.Cache.Remove(key);
10925
+ * }
10926
+ * @returns
10927
+ */
10928
+ function GetListCacheKey() {
10929
+ return Api.ECacheKey.Plugin;
10930
+ }
10931
+ Plugin.GetListCacheKey = GetListCacheKey;
10932
+ /**
10933
+ * Returns cache identifier for a plugin index file.
10934
+ * @param pluginId
10935
+ * @param indexFileUrl
10936
+ * @returns
10937
+ */
10938
+ function GetIndexFileCacheKey(pluginId, indexFileUrl) {
10939
+ return `${Api.ECacheKey.PluginIndexFile}${Api.ECacheKey.Id}${pluginId}${Api.ECacheKey.Id}${indexFileUrl}`;
10940
+ }
10941
+ Plugin.GetIndexFileCacheKey = GetIndexFileCacheKey;
10822
10942
  })(Plugin || (Plugin = {}));
10823
10943
 
10824
10944
  var DataSource;
@@ -10969,7 +11089,7 @@ var DataSource;
10969
11089
  })(DataSource || (DataSource = {}));
10970
11090
 
10971
11091
  // This is updated with the package.json version on build.
10972
- const VERSION = "3.6.8";
11092
+ const VERSION = "3.7.0";
10973
11093
 
10974
- export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
11094
+ export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
10975
11095
  //# sourceMappingURL=bruce-models.es5.js.map