bruce-models 1.8.7 → 1.9.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.
- package/dist/bruce-models.es5.js +33 -45
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +33 -45
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/common/bruce-variable.js +3 -1
- package/dist/lib/common/bruce-variable.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/types/entity/entity-attachment.d.ts +10 -17
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -2002,7 +2002,9 @@ function getVariable(str) {
|
|
|
2002
2002
|
const end = str.indexOf("}");
|
|
2003
2003
|
if (end > -1) {
|
|
2004
2004
|
if (start < end) {
|
|
2005
|
-
|
|
2005
|
+
const path = str.substring(start + 2, end);
|
|
2006
|
+
const txt = str.substring(start, end + 1);
|
|
2007
|
+
return { path: path, text: txt };
|
|
2006
2008
|
}
|
|
2007
2009
|
}
|
|
2008
2010
|
}
|
|
@@ -2939,8 +2941,8 @@ var EntityAttachmentType;
|
|
|
2939
2941
|
*/
|
|
2940
2942
|
var EntityAttachment;
|
|
2941
2943
|
(function (EntityAttachment) {
|
|
2942
|
-
function GetCacheKey(
|
|
2943
|
-
return Api.ECacheKey.Attachment + Api.ECacheKey.Id +
|
|
2944
|
+
function GetCacheKey(id) {
|
|
2945
|
+
return Api.ECacheKey.Attachment + Api.ECacheKey.Id + id;
|
|
2944
2946
|
}
|
|
2945
2947
|
EntityAttachment.GetCacheKey = GetCacheKey;
|
|
2946
2948
|
function GetListCacheKey(entityId) {
|
|
@@ -2949,33 +2951,40 @@ var EntityAttachment;
|
|
|
2949
2951
|
EntityAttachment.GetListCacheKey = GetListCacheKey;
|
|
2950
2952
|
function Update(params) {
|
|
2951
2953
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2952
|
-
const { api,
|
|
2953
|
-
if (!(
|
|
2954
|
-
|
|
2954
|
+
const { api, attachments, req, entityId } = params;
|
|
2955
|
+
if (!(attachments === null || attachments === void 0 ? void 0 : attachments.length)) {
|
|
2956
|
+
return {
|
|
2957
|
+
attachments: []
|
|
2958
|
+
};
|
|
2959
|
+
}
|
|
2960
|
+
const res = yield api.POST(`entity/${entityId}/attachments`, {
|
|
2961
|
+
attachments
|
|
2962
|
+
}, Api.PrepReqParams(req));
|
|
2963
|
+
for (let i = 0; i < attachments.length; i++) {
|
|
2964
|
+
if (attachments[i].ID) {
|
|
2965
|
+
api.Cache.Remove(GetCacheKey(attachments[i].ID));
|
|
2966
|
+
}
|
|
2955
2967
|
}
|
|
2956
|
-
|
|
2957
|
-
const res = yield api.PUT(url, data, Api.PrepReqParams(reqParams));
|
|
2958
|
-
api.Cache.Remove(GetCacheKey(data["Entity.ID"], data["EntityAttachmentType.ID"], data["ClientFile.ID"]));
|
|
2959
|
-
api.Cache.RemoveByStartsWith(GetListCacheKey(data["Entity.ID"]));
|
|
2968
|
+
api.Cache.Remove(GetListCacheKey(entityId));
|
|
2960
2969
|
return {
|
|
2961
|
-
|
|
2970
|
+
attachments: res.attachments
|
|
2962
2971
|
};
|
|
2963
2972
|
});
|
|
2964
2973
|
}
|
|
2965
2974
|
EntityAttachment.Update = Update;
|
|
2966
2975
|
function UpdateOrder(params) {
|
|
2967
2976
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2968
|
-
const { api, entityId, attachmentTypeId: typeId,
|
|
2969
|
-
if (!entityId || !typeId || !(
|
|
2970
|
-
throw ("Entity ID, Type ID, and
|
|
2977
|
+
const { api, entityId, attachmentTypeId: typeId, attachments, req: reqParams } = params;
|
|
2978
|
+
if (!entityId || !typeId || !(attachments === null || attachments === void 0 ? void 0 : attachments.length)) {
|
|
2979
|
+
throw ("Entity ID, Type ID, and Attachments are required.");
|
|
2971
2980
|
}
|
|
2972
2981
|
const reqData = {
|
|
2973
2982
|
"DisplayOrder.Start": 0,
|
|
2974
|
-
"ClientFile.ID":
|
|
2983
|
+
"ClientFile.ID": attachments.map(x => x["ClientFile.ID"])
|
|
2975
2984
|
};
|
|
2976
2985
|
yield api.POST(`entity/${entityId}/attachments/${typeId}/setOrder`, reqData, Api.PrepReqParams(reqParams));
|
|
2977
|
-
for (let i = 0; i <
|
|
2978
|
-
api.Cache.Remove(GetCacheKey(
|
|
2986
|
+
for (let i = 0; i < attachments.length; i++) {
|
|
2987
|
+
api.Cache.Remove(GetCacheKey(attachments[i].ID));
|
|
2979
2988
|
}
|
|
2980
2989
|
api.Cache.RemoveByStartsWith(GetListCacheKey(entityId));
|
|
2981
2990
|
});
|
|
@@ -2983,36 +2992,15 @@ var EntityAttachment;
|
|
|
2983
2992
|
EntityAttachment.UpdateOrder = UpdateOrder;
|
|
2984
2993
|
function Delete(params) {
|
|
2985
2994
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2986
|
-
const { api,
|
|
2987
|
-
if (!
|
|
2988
|
-
throw ("Entity
|
|
2995
|
+
const { api, attachmentId, entityId, req } = params;
|
|
2996
|
+
if (!attachmentId || !entityId) {
|
|
2997
|
+
throw ("Entity id and attachment id.");
|
|
2989
2998
|
}
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
};
|
|
2993
|
-
yield api.POST(`entity/${data["Entity.ID"]}/attachments/${data["EntityAttachmentType.ID"]}/delete`, reqData, Api.PrepReqParams(reqParams));
|
|
2994
|
-
api.Cache.Remove(GetCacheKey(data["Entity.ID"], data["EntityAttachmentType.ID"], data["ClientFile.ID"]));
|
|
2995
|
-
api.Cache.RemoveByStartsWith(GetListCacheKey(data["Entity.ID"]));
|
|
2999
|
+
yield api.DELETE(`entity/${entityId}/attachments/${attachmentId}`, Api.PrepReqParams(req));
|
|
3000
|
+
api.Cache.Remove(GetCacheKey(attachmentId));
|
|
2996
3001
|
});
|
|
2997
3002
|
}
|
|
2998
3003
|
EntityAttachment.Delete = Delete;
|
|
2999
|
-
function DeleteByFileIds(params) {
|
|
3000
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3001
|
-
const { api, entityId, attachmentTypeId: typeId, fileIds, req: reqParams } = params;
|
|
3002
|
-
if (!entityId || !typeId || !(fileIds === null || fileIds === void 0 ? void 0 : fileIds.length)) {
|
|
3003
|
-
throw ("Entity ID, Type ID, and File IDs are required.");
|
|
3004
|
-
}
|
|
3005
|
-
const reqData = {
|
|
3006
|
-
"ClientFile.ID": fileIds
|
|
3007
|
-
};
|
|
3008
|
-
yield api.POST(`entity/${entityId}/attachments/${typeId}/delete`, reqData, Api.PrepReqParams(reqParams));
|
|
3009
|
-
for (let i = 0; i < fileIds.length; i++) {
|
|
3010
|
-
api.Cache.Remove(GetCacheKey(entityId, typeId, fileIds[i]));
|
|
3011
|
-
}
|
|
3012
|
-
api.Cache.RemoveByStartsWith(GetListCacheKey(entityId));
|
|
3013
|
-
});
|
|
3014
|
-
}
|
|
3015
|
-
EntityAttachment.DeleteByFileIds = DeleteByFileIds;
|
|
3016
3004
|
function GetListByEntityId(params) {
|
|
3017
3005
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3018
3006
|
const { api, entityId, req: reqParams } = params;
|
|
@@ -3027,7 +3015,7 @@ var EntityAttachment;
|
|
|
3027
3015
|
try {
|
|
3028
3016
|
const data = yield api.GET(`entity/${entityId}/attachments`, Api.PrepReqParams(reqParams));
|
|
3029
3017
|
res({
|
|
3030
|
-
attachments: data.Items
|
|
3018
|
+
attachments: (data.attachments ? data.attachments : data.Items)
|
|
3031
3019
|
});
|
|
3032
3020
|
}
|
|
3033
3021
|
catch (e) {
|
|
@@ -3047,7 +3035,7 @@ var EntityAttachment;
|
|
|
3047
3035
|
}
|
|
3048
3036
|
const url = `entity/${entityId}/attachment/${typeId}`;
|
|
3049
3037
|
const res = yield api.UPLOAD(url, file, Api.PrepReqParams(reqParams));
|
|
3050
|
-
api.Cache.
|
|
3038
|
+
api.Cache.Remove(GetListCacheKey(entityId));
|
|
3051
3039
|
return {
|
|
3052
3040
|
attachment: res
|
|
3053
3041
|
};
|