bruce-models 1.9.0 → 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.
@@ -67,6 +67,7 @@
67
67
  ECacheKey["DatabaseRegion"] = "databaseregion";
68
68
  ECacheKey["CustomForm"] = "customform";
69
69
  ECacheKey["ImportedFile"] = "importedfile";
70
+ ECacheKey["Plugin"] = "plugin";
70
71
  })(ECacheKey = Api.ECacheKey || (Api.ECacheKey = {}));
71
72
  Api.DEFAULT_CACHE_DURATION = 60 * 5; // 5 minutes.
72
73
  Api.TEMPLATE_ACCOUNT_ID = "template";
@@ -7242,6 +7243,76 @@
7242
7243
  })(Circle = Markup.Circle || (Markup.Circle = {}));
7243
7244
  })(exports.Markup || (exports.Markup = {}));
7244
7245
 
7246
+ (function (Plugin) {
7247
+ function GetCacheKey(pluginId) {
7248
+ return `${exports.Api.ECacheKey.Plugin}${exports.Api.ECacheKey.Id}${pluginId}`;
7249
+ }
7250
+ Plugin.GetCacheKey = GetCacheKey;
7251
+ function GetListCacheKey() {
7252
+ return exports.Api.ECacheKey.Plugin;
7253
+ }
7254
+ Plugin.GetListCacheKey = GetListCacheKey;
7255
+ function Get(params) {
7256
+ return __awaiter(this, void 0, void 0, function* () {
7257
+ const { api, pluginId, req } = params;
7258
+ if (!pluginId) {
7259
+ throw ("Plugin ID is required.");
7260
+ }
7261
+ const cacheData = api.GetCacheItem(GetCacheKey(pluginId), req);
7262
+ if (cacheData) {
7263
+ return cacheData;
7264
+ }
7265
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
7266
+ try {
7267
+ const data = yield api.GET(`ui.plugin/${pluginId}`, exports.Api.PrepReqParams(req));
7268
+ res({
7269
+ plugin: data
7270
+ });
7271
+ }
7272
+ catch (e) {
7273
+ rej(e);
7274
+ }
7275
+ }));
7276
+ api.Cache.Set(GetCacheKey(pluginId), prom, exports.Api.DEFAULT_CACHE_DURATION);
7277
+ return prom;
7278
+ });
7279
+ }
7280
+ Plugin.Get = Get;
7281
+ function GetList(params) {
7282
+ return __awaiter(this, void 0, void 0, function* () {
7283
+ const { api, req } = params;
7284
+ const cacheData = api.GetCacheItem(GetListCacheKey(), req);
7285
+ if (cacheData) {
7286
+ return cacheData;
7287
+ }
7288
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
7289
+ try {
7290
+ const data = yield api.GET("ui.plugins", exports.Api.PrepReqParams(req));
7291
+ res({
7292
+ plugins: data.Items
7293
+ });
7294
+ }
7295
+ catch (e) {
7296
+ rej(e);
7297
+ }
7298
+ }));
7299
+ api.Cache.Set(GetListCacheKey(), prom, exports.Api.DEFAULT_CACHE_DURATION);
7300
+ return prom;
7301
+ });
7302
+ }
7303
+ Plugin.GetList = GetList;
7304
+ function GetLoadUrl(params) {
7305
+ let { api, pluginId, req, cacheKey } = params;
7306
+ if (!cacheKey) {
7307
+ cacheKey = 0;
7308
+ }
7309
+ return {
7310
+ indexFileUrl: `${api.GetBaseUrl()}ui.plugin/${pluginId}/file/index.jsc?version=${cacheKey}`
7311
+ };
7312
+ }
7313
+ Plugin.GetLoadUrl = GetLoadUrl;
7314
+ })(exports.Plugin || (exports.Plugin = {}));
7315
+
7245
7316
  exports.AbstractApi = AbstractApi;
7246
7317
  exports.ApiGetters = ApiGetters;
7247
7318
  exports.BruceEvent = BruceEvent;