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.
- package/dist/bruce-models.es5.js +103 -45
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +101 -44
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/api.js +1 -0
- package/dist/lib/api/api.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -0
- package/dist/lib/bruce-models.js.map +1 -1
- package/dist/lib/entity/entity-attachment.js +30 -44
- package/dist/lib/entity/entity-attachment.js.map +1 -1
- package/dist/lib/plugin/plugin.js +84 -0
- package/dist/lib/plugin/plugin.js.map +1 -0
- package/dist/types/api/api.d.ts +2 -1
- package/dist/types/bruce-models.d.ts +1 -0
- package/dist/types/entity/entity-attachment.d.ts +10 -17
- package/dist/types/plugin/plugin.d.ts +37 -0
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -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";
|
|
@@ -2883,8 +2884,8 @@
|
|
|
2883
2884
|
})(exports.EntityAttachmentType || (exports.EntityAttachmentType = {}));
|
|
2884
2885
|
|
|
2885
2886
|
(function (EntityAttachment) {
|
|
2886
|
-
function GetCacheKey(
|
|
2887
|
-
return exports.Api.ECacheKey.Attachment + exports.Api.ECacheKey.Id +
|
|
2887
|
+
function GetCacheKey(id) {
|
|
2888
|
+
return exports.Api.ECacheKey.Attachment + exports.Api.ECacheKey.Id + id;
|
|
2888
2889
|
}
|
|
2889
2890
|
EntityAttachment.GetCacheKey = GetCacheKey;
|
|
2890
2891
|
function GetListCacheKey(entityId) {
|
|
@@ -2893,33 +2894,40 @@
|
|
|
2893
2894
|
EntityAttachment.GetListCacheKey = GetListCacheKey;
|
|
2894
2895
|
function Update(params) {
|
|
2895
2896
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2896
|
-
const { api,
|
|
2897
|
-
if (!(
|
|
2898
|
-
|
|
2897
|
+
const { api, attachments, req, entityId } = params;
|
|
2898
|
+
if (!(attachments === null || attachments === void 0 ? void 0 : attachments.length)) {
|
|
2899
|
+
return {
|
|
2900
|
+
attachments: []
|
|
2901
|
+
};
|
|
2902
|
+
}
|
|
2903
|
+
const res = yield api.POST(`entity/${entityId}/attachments`, {
|
|
2904
|
+
attachments
|
|
2905
|
+
}, exports.Api.PrepReqParams(req));
|
|
2906
|
+
for (let i = 0; i < attachments.length; i++) {
|
|
2907
|
+
if (attachments[i].ID) {
|
|
2908
|
+
api.Cache.Remove(GetCacheKey(attachments[i].ID));
|
|
2909
|
+
}
|
|
2899
2910
|
}
|
|
2900
|
-
|
|
2901
|
-
const res = yield api.PUT(url, data, exports.Api.PrepReqParams(reqParams));
|
|
2902
|
-
api.Cache.Remove(GetCacheKey(data["Entity.ID"], data["EntityAttachmentType.ID"], data["ClientFile.ID"]));
|
|
2903
|
-
api.Cache.RemoveByStartsWith(GetListCacheKey(data["Entity.ID"]));
|
|
2911
|
+
api.Cache.Remove(GetListCacheKey(entityId));
|
|
2904
2912
|
return {
|
|
2905
|
-
|
|
2913
|
+
attachments: res.attachments
|
|
2906
2914
|
};
|
|
2907
2915
|
});
|
|
2908
2916
|
}
|
|
2909
2917
|
EntityAttachment.Update = Update;
|
|
2910
2918
|
function UpdateOrder(params) {
|
|
2911
2919
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2912
|
-
const { api, entityId, attachmentTypeId: typeId,
|
|
2913
|
-
if (!entityId || !typeId || !(
|
|
2914
|
-
throw ("Entity ID, Type ID, and
|
|
2920
|
+
const { api, entityId, attachmentTypeId: typeId, attachments, req: reqParams } = params;
|
|
2921
|
+
if (!entityId || !typeId || !(attachments === null || attachments === void 0 ? void 0 : attachments.length)) {
|
|
2922
|
+
throw ("Entity ID, Type ID, and Attachments are required.");
|
|
2915
2923
|
}
|
|
2916
2924
|
const reqData = {
|
|
2917
2925
|
"DisplayOrder.Start": 0,
|
|
2918
|
-
"ClientFile.ID":
|
|
2926
|
+
"ClientFile.ID": attachments.map(x => x["ClientFile.ID"])
|
|
2919
2927
|
};
|
|
2920
2928
|
yield api.POST(`entity/${entityId}/attachments/${typeId}/setOrder`, reqData, exports.Api.PrepReqParams(reqParams));
|
|
2921
|
-
for (let i = 0; i <
|
|
2922
|
-
api.Cache.Remove(GetCacheKey(
|
|
2929
|
+
for (let i = 0; i < attachments.length; i++) {
|
|
2930
|
+
api.Cache.Remove(GetCacheKey(attachments[i].ID));
|
|
2923
2931
|
}
|
|
2924
2932
|
api.Cache.RemoveByStartsWith(GetListCacheKey(entityId));
|
|
2925
2933
|
});
|
|
@@ -2927,36 +2935,15 @@
|
|
|
2927
2935
|
EntityAttachment.UpdateOrder = UpdateOrder;
|
|
2928
2936
|
function Delete(params) {
|
|
2929
2937
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2930
|
-
const { api,
|
|
2931
|
-
if (!
|
|
2932
|
-
throw ("Entity
|
|
2938
|
+
const { api, attachmentId, entityId, req } = params;
|
|
2939
|
+
if (!attachmentId || !entityId) {
|
|
2940
|
+
throw ("Entity id and attachment id.");
|
|
2933
2941
|
}
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
};
|
|
2937
|
-
yield api.POST(`entity/${data["Entity.ID"]}/attachments/${data["EntityAttachmentType.ID"]}/delete`, reqData, exports.Api.PrepReqParams(reqParams));
|
|
2938
|
-
api.Cache.Remove(GetCacheKey(data["Entity.ID"], data["EntityAttachmentType.ID"], data["ClientFile.ID"]));
|
|
2939
|
-
api.Cache.RemoveByStartsWith(GetListCacheKey(data["Entity.ID"]));
|
|
2942
|
+
yield api.DELETE(`entity/${entityId}/attachments/${attachmentId}`, exports.Api.PrepReqParams(req));
|
|
2943
|
+
api.Cache.Remove(GetCacheKey(attachmentId));
|
|
2940
2944
|
});
|
|
2941
2945
|
}
|
|
2942
2946
|
EntityAttachment.Delete = Delete;
|
|
2943
|
-
function DeleteByFileIds(params) {
|
|
2944
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2945
|
-
const { api, entityId, attachmentTypeId: typeId, fileIds, req: reqParams } = params;
|
|
2946
|
-
if (!entityId || !typeId || !(fileIds === null || fileIds === void 0 ? void 0 : fileIds.length)) {
|
|
2947
|
-
throw ("Entity ID, Type ID, and File IDs are required.");
|
|
2948
|
-
}
|
|
2949
|
-
const reqData = {
|
|
2950
|
-
"ClientFile.ID": fileIds
|
|
2951
|
-
};
|
|
2952
|
-
yield api.POST(`entity/${entityId}/attachments/${typeId}/delete`, reqData, exports.Api.PrepReqParams(reqParams));
|
|
2953
|
-
for (let i = 0; i < fileIds.length; i++) {
|
|
2954
|
-
api.Cache.Remove(GetCacheKey(entityId, typeId, fileIds[i]));
|
|
2955
|
-
}
|
|
2956
|
-
api.Cache.RemoveByStartsWith(GetListCacheKey(entityId));
|
|
2957
|
-
});
|
|
2958
|
-
}
|
|
2959
|
-
EntityAttachment.DeleteByFileIds = DeleteByFileIds;
|
|
2960
2947
|
function GetListByEntityId(params) {
|
|
2961
2948
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2962
2949
|
const { api, entityId, req: reqParams } = params;
|
|
@@ -2971,7 +2958,7 @@
|
|
|
2971
2958
|
try {
|
|
2972
2959
|
const data = yield api.GET(`entity/${entityId}/attachments`, exports.Api.PrepReqParams(reqParams));
|
|
2973
2960
|
res({
|
|
2974
|
-
attachments: data.Items
|
|
2961
|
+
attachments: (data.attachments ? data.attachments : data.Items)
|
|
2975
2962
|
});
|
|
2976
2963
|
}
|
|
2977
2964
|
catch (e) {
|
|
@@ -2991,7 +2978,7 @@
|
|
|
2991
2978
|
}
|
|
2992
2979
|
const url = `entity/${entityId}/attachment/${typeId}`;
|
|
2993
2980
|
const res = yield api.UPLOAD(url, file, exports.Api.PrepReqParams(reqParams));
|
|
2994
|
-
api.Cache.
|
|
2981
|
+
api.Cache.Remove(GetListCacheKey(entityId));
|
|
2995
2982
|
return {
|
|
2996
2983
|
attachment: res
|
|
2997
2984
|
};
|
|
@@ -7256,6 +7243,76 @@
|
|
|
7256
7243
|
})(Circle = Markup.Circle || (Markup.Circle = {}));
|
|
7257
7244
|
})(exports.Markup || (exports.Markup = {}));
|
|
7258
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
|
+
|
|
7259
7316
|
exports.AbstractApi = AbstractApi;
|
|
7260
7317
|
exports.ApiGetters = ApiGetters;
|
|
7261
7318
|
exports.BruceEvent = BruceEvent;
|