bruce-models 3.6.7 → 3.6.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.
@@ -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;
@@ -10284,33 +10285,6 @@
10284
10285
  })(exports.Markup || (exports.Markup = {}));
10285
10286
 
10286
10287
  (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
10288
  /**
10315
10289
  * Returns a plugin record.
10316
10290
  * @param params
@@ -10421,6 +10395,7 @@
10421
10395
  yield api.POST(`ui.plugin/${plugin.ID}`, plugin, exports.Api.PrepReqParams(req));
10422
10396
  api.Cache.Remove(GetCacheKey(plugin.ID));
10423
10397
  api.Cache.Remove(GetListCacheKey());
10398
+ api.Cache.RemoveByStartsWith(GetIndexFileCacheKey(plugin.ID, ""));
10424
10399
  });
10425
10400
  }
10426
10401
  Plugin.Update = Update;
@@ -10440,6 +10415,7 @@
10440
10415
  yield api.DELETE(`ui.plugin/${pluginId}`, exports.Api.PrepReqParams(req));
10441
10416
  api.Cache.Remove(GetCacheKey(pluginId));
10442
10417
  api.Cache.Remove(GetListCacheKey());
10418
+ api.Cache.RemoveByStartsWith(GetIndexFileCacheKey(pluginId, ""));
10443
10419
  });
10444
10420
  }
10445
10421
  Plugin.Delete = Delete;
@@ -10468,6 +10444,7 @@
10468
10444
  yield api.UPLOAD(`ui.plugin/${pluginId}/file`, file, req);
10469
10445
  api.Cache.Remove(GetCacheKey(pluginId));
10470
10446
  api.Cache.Remove(GetListCacheKey());
10447
+ api.Cache.RemoveByStartsWith(GetIndexFileCacheKey(pluginId, ""));
10471
10448
  });
10472
10449
  }
10473
10450
  Plugin.Upload = Upload;
@@ -10479,7 +10456,7 @@
10479
10456
  */
10480
10457
  function GetRunFunction(params) {
10481
10458
  return __awaiter(this, void 0, void 0, function* () {
10482
- let { containerId, container, pluginParams, pluginId, plugin, api } = params;
10459
+ let { containerId, container, pluginParams, pluginId, plugin, api, req } = params;
10483
10460
  if (!containerId && container) {
10484
10461
  containerId = container.id;
10485
10462
  if (!containerId) {
@@ -10501,7 +10478,21 @@
10501
10478
  pluginId,
10502
10479
  cacheKey: plugin.Version
10503
10480
  });
10504
- let fileContent = yield fetch(indexFileUrl).then((res) => res.text());
10481
+ req = exports.Api.PrepReqParams(req);
10482
+ const cacheData = api.GetCacheItem(GetIndexFileCacheKey(pluginId, indexFileUrl), req);
10483
+ let fileContentProm = null;
10484
+ if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
10485
+ fileContentProm = cacheData.data;
10486
+ }
10487
+ else {
10488
+ fileContentProm = fetch(indexFileUrl).then((res) => res.text());
10489
+ api.SetCacheItem({
10490
+ key: GetIndexFileCacheKey(pluginId, indexFileUrl),
10491
+ value: fileContentProm,
10492
+ req: req
10493
+ });
10494
+ }
10495
+ let fileContent = yield fileContentProm;
10505
10496
  const start = fileContent.indexOf("{");
10506
10497
  const end = fileContent.lastIndexOf("}");
10507
10498
  fileContent = fileContent.substring(start + 1, end);
@@ -10567,6 +10558,43 @@
10567
10558
  });
10568
10559
  }
10569
10560
  Plugin.GetRunFunction = GetRunFunction;
10561
+ /**
10562
+ * Returns cache identifier for a plugin.
10563
+ * Example: {
10564
+ * const api: BruceApi.Api = ...;
10565
+ * const key = GetCacheKey("abc");
10566
+ * api.Cache.Remove(key);
10567
+ * }
10568
+ * @param pluginId
10569
+ * @returns
10570
+ */
10571
+ function GetCacheKey(pluginId) {
10572
+ return `${exports.Api.ECacheKey.Plugin}${exports.Api.ECacheKey.Id}${pluginId}`;
10573
+ }
10574
+ Plugin.GetCacheKey = GetCacheKey;
10575
+ /**
10576
+ * Returns cache identifier for a list of plugins.
10577
+ * Example: {
10578
+ * const api: BruceApi.Api = ...;
10579
+ * const key = GetListCacheKey();
10580
+ * api.Cache.Remove(key);
10581
+ * }
10582
+ * @returns
10583
+ */
10584
+ function GetListCacheKey() {
10585
+ return exports.Api.ECacheKey.Plugin;
10586
+ }
10587
+ Plugin.GetListCacheKey = GetListCacheKey;
10588
+ /**
10589
+ * Returns cache identifier for a plugin index file.
10590
+ * @param pluginId
10591
+ * @param indexFileUrl
10592
+ * @returns
10593
+ */
10594
+ function GetIndexFileCacheKey(pluginId, indexFileUrl) {
10595
+ return `${exports.Api.ECacheKey.PluginIndexFile}${exports.Api.ECacheKey.Id}${pluginId}${exports.Api.ECacheKey.Id}${indexFileUrl}`;
10596
+ }
10597
+ Plugin.GetIndexFileCacheKey = GetIndexFileCacheKey;
10570
10598
  })(exports.Plugin || (exports.Plugin = {}));
10571
10599
 
10572
10600
  (function (DataSource) {
@@ -10716,7 +10744,7 @@
10716
10744
  })(exports.DataSource || (exports.DataSource = {}));
10717
10745
 
10718
10746
  // This is updated with the package.json version on build.
10719
- const VERSION = "3.6.7";
10747
+ const VERSION = "3.6.9";
10720
10748
 
10721
10749
  exports.VERSION = VERSION;
10722
10750
  exports.AbstractApi = AbstractApi;