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.
@@ -76,6 +76,7 @@
76
76
  ECacheKey["CustomForm"] = "customform";
77
77
  ECacheKey["ImportedFile"] = "importedfile";
78
78
  ECacheKey["Plugin"] = "plugin";
79
+ ECacheKey["PluginIndexFile"] = "pluginindexfile";
79
80
  })(ECacheKey = Api.ECacheKey || (Api.ECacheKey = {}));
80
81
  // 1 minute.
81
82
  Api.DEFAULT_CACHE_DURATION = 60 * 1000;
@@ -9755,6 +9756,93 @@
9755
9756
  AccountInvite.Create = Create;
9756
9757
  })(exports.AccountInvite || (exports.AccountInvite = {}));
9757
9758
 
9759
+ (function (AccountFeatures) {
9760
+ let EFeature;
9761
+ (function (EFeature) {
9762
+ // Flag to enable data to be stored in the JSON column type.
9763
+ // This will enable conversion of the data, and will also enable searches to use that instead.
9764
+ EFeature["EntityJsonData"] = "Feature_Entity_JSONData";
9765
+ // Flag to enable a text search against JSON data values.
9766
+ // 'EntityJsonData' must also be enabled.
9767
+ EFeature["EntityLexicalSearch"] = "Feature_Entity_Lexical_Search";
9768
+ })(EFeature = AccountFeatures.EFeature || (AccountFeatures.EFeature = {}));
9769
+ /**
9770
+ * Gets account features corresponding to an account ID.
9771
+ * @param params
9772
+ * @returns
9773
+ */
9774
+ function Get(params) {
9775
+ return __awaiter(this, void 0, void 0, function* () {
9776
+ let { api, accountId: id, req: reqParams } = params;
9777
+ if (!api) {
9778
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
9779
+ }
9780
+ const cache = yield api.GetCacheItem(GetCacheKey(id), reqParams);
9781
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
9782
+ return cache.data;
9783
+ }
9784
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
9785
+ try {
9786
+ const data = yield api.GET("features", reqParams);
9787
+ const features = data === null || data === void 0 ? void 0 : data.Features;
9788
+ res({
9789
+ features: features ? features : {}
9790
+ });
9791
+ }
9792
+ catch (e) {
9793
+ rej(e);
9794
+ }
9795
+ }));
9796
+ api.SetCacheItem({
9797
+ key: GetCacheKey(id),
9798
+ value: prom,
9799
+ req: reqParams
9800
+ });
9801
+ return prom;
9802
+ });
9803
+ }
9804
+ AccountFeatures.Get = Get;
9805
+ function Update(params) {
9806
+ return __awaiter(this, void 0, void 0, function* () {
9807
+ let { api, accountId: id, features, req: reqParams } = params;
9808
+ if (!api) {
9809
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
9810
+ }
9811
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
9812
+ try {
9813
+ const data = yield api.POST("features", {
9814
+ Features: features
9815
+ }, reqParams);
9816
+ const updated = data === null || data === void 0 ? void 0 : data.Features;
9817
+ res({
9818
+ features: updated ? updated : {}
9819
+ });
9820
+ }
9821
+ catch (e) {
9822
+ rej(e);
9823
+ }
9824
+ }));
9825
+ api.Cache.Remove(GetCacheKey(id));
9826
+ return prom;
9827
+ });
9828
+ }
9829
+ AccountFeatures.Update = Update;
9830
+ /**
9831
+ * Returns cache identifier for an account by ID.
9832
+ * Example: {
9833
+ * const api: BruceApi.Api = ...;
9834
+ * const key = GetCacheKey("my-account-id");
9835
+ * api.Cache.Remove(key);
9836
+ * }
9837
+ * @param accountId
9838
+ * @returns
9839
+ */
9840
+ function GetCacheKey(accountId) {
9841
+ return exports.Api.ECacheKey.AccountFeatures + exports.Api.ECacheKey.Id + accountId;
9842
+ }
9843
+ AccountFeatures.GetCacheKey = GetCacheKey;
9844
+ })(exports.AccountFeatures || (exports.AccountFeatures = {}));
9845
+
9758
9846
  (function (EncryptUtils) {
9759
9847
  // https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
9760
9848
  function Cyrb53Hash(str, seed = 0) {
@@ -10284,33 +10372,6 @@
10284
10372
  })(exports.Markup || (exports.Markup = {}));
10285
10373
 
10286
10374
  (function (Plugin) {
10287
- /**
10288
- * Returns cache identifier for a plugin.
10289
- * Example: {
10290
- * const api: BruceApi.Api = ...;
10291
- * const key = GetCacheKey("abc");
10292
- * api.Cache.Remove(key);
10293
- * }
10294
- * @param pluginId
10295
- * @returns
10296
- */
10297
- function GetCacheKey(pluginId) {
10298
- return `${exports.Api.ECacheKey.Plugin}${exports.Api.ECacheKey.Id}${pluginId}`;
10299
- }
10300
- Plugin.GetCacheKey = GetCacheKey;
10301
- /**
10302
- * Returns cache identifier for a list of plugins.
10303
- * Example: {
10304
- * const api: BruceApi.Api = ...;
10305
- * const key = GetListCacheKey();
10306
- * api.Cache.Remove(key);
10307
- * }
10308
- * @returns
10309
- */
10310
- function GetListCacheKey() {
10311
- return exports.Api.ECacheKey.Plugin;
10312
- }
10313
- Plugin.GetListCacheKey = GetListCacheKey;
10314
10375
  /**
10315
10376
  * Returns a plugin record.
10316
10377
  * @param params
@@ -10421,6 +10482,7 @@
10421
10482
  yield api.POST(`ui.plugin/${plugin.ID}`, plugin, exports.Api.PrepReqParams(req));
10422
10483
  api.Cache.Remove(GetCacheKey(plugin.ID));
10423
10484
  api.Cache.Remove(GetListCacheKey());
10485
+ api.Cache.RemoveByStartsWith(GetIndexFileCacheKey(plugin.ID, ""));
10424
10486
  });
10425
10487
  }
10426
10488
  Plugin.Update = Update;
@@ -10440,6 +10502,7 @@
10440
10502
  yield api.DELETE(`ui.plugin/${pluginId}`, exports.Api.PrepReqParams(req));
10441
10503
  api.Cache.Remove(GetCacheKey(pluginId));
10442
10504
  api.Cache.Remove(GetListCacheKey());
10505
+ api.Cache.RemoveByStartsWith(GetIndexFileCacheKey(pluginId, ""));
10443
10506
  });
10444
10507
  }
10445
10508
  Plugin.Delete = Delete;
@@ -10468,6 +10531,7 @@
10468
10531
  yield api.UPLOAD(`ui.plugin/${pluginId}/file`, file, req);
10469
10532
  api.Cache.Remove(GetCacheKey(pluginId));
10470
10533
  api.Cache.Remove(GetListCacheKey());
10534
+ api.Cache.RemoveByStartsWith(GetIndexFileCacheKey(pluginId, ""));
10471
10535
  });
10472
10536
  }
10473
10537
  Plugin.Upload = Upload;
@@ -10479,7 +10543,7 @@
10479
10543
  */
10480
10544
  function GetRunFunction(params) {
10481
10545
  return __awaiter(this, void 0, void 0, function* () {
10482
- let { containerId, container, pluginParams, pluginId, plugin, api } = params;
10546
+ let { containerId, container, pluginParams, pluginId, plugin, api, req } = params;
10483
10547
  if (!containerId && container) {
10484
10548
  containerId = container.id;
10485
10549
  if (!containerId) {
@@ -10501,7 +10565,21 @@
10501
10565
  pluginId,
10502
10566
  cacheKey: plugin.Version
10503
10567
  });
10504
- let fileContent = yield fetch(indexFileUrl).then((res) => res.text());
10568
+ req = exports.Api.PrepReqParams(req);
10569
+ const cacheData = api.GetCacheItem(GetIndexFileCacheKey(pluginId, indexFileUrl), req);
10570
+ let fileContentProm = null;
10571
+ if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
10572
+ fileContentProm = cacheData.data;
10573
+ }
10574
+ else {
10575
+ fileContentProm = fetch(indexFileUrl).then((res) => res.text());
10576
+ api.SetCacheItem({
10577
+ key: GetIndexFileCacheKey(pluginId, indexFileUrl),
10578
+ value: fileContentProm,
10579
+ req: req
10580
+ });
10581
+ }
10582
+ let fileContent = yield fileContentProm;
10505
10583
  const start = fileContent.indexOf("{");
10506
10584
  const end = fileContent.lastIndexOf("}");
10507
10585
  fileContent = fileContent.substring(start + 1, end);
@@ -10567,6 +10645,43 @@
10567
10645
  });
10568
10646
  }
10569
10647
  Plugin.GetRunFunction = GetRunFunction;
10648
+ /**
10649
+ * Returns cache identifier for a plugin.
10650
+ * Example: {
10651
+ * const api: BruceApi.Api = ...;
10652
+ * const key = GetCacheKey("abc");
10653
+ * api.Cache.Remove(key);
10654
+ * }
10655
+ * @param pluginId
10656
+ * @returns
10657
+ */
10658
+ function GetCacheKey(pluginId) {
10659
+ return `${exports.Api.ECacheKey.Plugin}${exports.Api.ECacheKey.Id}${pluginId}`;
10660
+ }
10661
+ Plugin.GetCacheKey = GetCacheKey;
10662
+ /**
10663
+ * Returns cache identifier for a list of plugins.
10664
+ * Example: {
10665
+ * const api: BruceApi.Api = ...;
10666
+ * const key = GetListCacheKey();
10667
+ * api.Cache.Remove(key);
10668
+ * }
10669
+ * @returns
10670
+ */
10671
+ function GetListCacheKey() {
10672
+ return exports.Api.ECacheKey.Plugin;
10673
+ }
10674
+ Plugin.GetListCacheKey = GetListCacheKey;
10675
+ /**
10676
+ * Returns cache identifier for a plugin index file.
10677
+ * @param pluginId
10678
+ * @param indexFileUrl
10679
+ * @returns
10680
+ */
10681
+ function GetIndexFileCacheKey(pluginId, indexFileUrl) {
10682
+ return `${exports.Api.ECacheKey.PluginIndexFile}${exports.Api.ECacheKey.Id}${pluginId}${exports.Api.ECacheKey.Id}${indexFileUrl}`;
10683
+ }
10684
+ Plugin.GetIndexFileCacheKey = GetIndexFileCacheKey;
10570
10685
  })(exports.Plugin || (exports.Plugin = {}));
10571
10686
 
10572
10687
  (function (DataSource) {
@@ -10716,7 +10831,7 @@
10716
10831
  })(exports.DataSource || (exports.DataSource = {}));
10717
10832
 
10718
10833
  // This is updated with the package.json version on build.
10719
- const VERSION = "3.6.8";
10834
+ const VERSION = "3.7.0";
10720
10835
 
10721
10836
  exports.VERSION = VERSION;
10722
10837
  exports.AbstractApi = AbstractApi;