@overmap-ai/core 1.0.50-document-attachments.1 → 1.0.50-fix-error-messaging.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/README.md +4 -4
- package/dist/overmap-core.js +133 -177
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +133 -177
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/errors.d.ts +6 -3
- package/dist/sdk/services/AttachmentService.d.ts +5 -6
- package/dist/sdk/services/CategoryService.d.ts +2 -2
- package/dist/sdk/services/ComponentStageCompletionService.d.ts +2 -2
- package/dist/sdk/services/WorkspaceService.d.ts +2 -2
- package/dist/store/slices/componentSlice.d.ts +0 -1
- package/dist/store/slices/documentSlice.d.ts +2 -35
- package/dist/store/slices/issueSlice.d.ts +0 -1
- package/dist/store/store.d.ts +1 -1
- package/dist/typings/models/attachments.d.ts +0 -4
- package/package.json +152 -152
|
@@ -208,18 +208,64 @@ var __publicField = (obj, key, value) => {
|
|
|
208
208
|
this.requestAttemptCounter[uuid2] = (this.requestAttemptCounter[uuid2] || 0) + 1;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
+
const UNKNOWN_ERROR_MESSAGE = "An unknown error occurred";
|
|
212
|
+
const MAX_ERROR_MESSAGE_LENGTH = 500;
|
|
213
|
+
const _SPECIAL_KEYS = ["non_field_errors", "detail"];
|
|
214
|
+
function extractErrorMessage(errorRes, err) {
|
|
215
|
+
let ret;
|
|
216
|
+
if (errorRes == null ? void 0 : errorRes.body) {
|
|
217
|
+
if (typeof errorRes.body === "object") {
|
|
218
|
+
const responseBody = errorRes.body;
|
|
219
|
+
if (typeof responseBody.error === "string") {
|
|
220
|
+
ret = responseBody.error;
|
|
221
|
+
} else if (typeof responseBody.message === "string") {
|
|
222
|
+
ret = responseBody.message;
|
|
223
|
+
} else if (responseBody.body) {
|
|
224
|
+
try {
|
|
225
|
+
ret = Object.entries(responseBody.body).map(([key, value]) => {
|
|
226
|
+
if (typeof value === "string") {
|
|
227
|
+
if (_SPECIAL_KEYS.includes(key))
|
|
228
|
+
return value;
|
|
229
|
+
return `${key}: ${value}`;
|
|
230
|
+
}
|
|
231
|
+
if (Array.isArray(value)) {
|
|
232
|
+
if (_SPECIAL_KEYS.includes(key))
|
|
233
|
+
return value.join("\n");
|
|
234
|
+
return value.map((v) => `${key}: ${v}`).join("\n");
|
|
235
|
+
}
|
|
236
|
+
return `${key}: ${JSON.stringify(value)}`;
|
|
237
|
+
}).join("\n");
|
|
238
|
+
} catch (e) {
|
|
239
|
+
console.error("Failed to extract error message from response body", e);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
} else if (typeof errorRes.body === "string") {
|
|
243
|
+
ret = errorRes.body;
|
|
244
|
+
}
|
|
245
|
+
} else if (errorRes == null ? void 0 : errorRes.text) {
|
|
246
|
+
ret = errorRes.text;
|
|
247
|
+
} else if (err instanceof Error) {
|
|
248
|
+
ret = err.message;
|
|
249
|
+
}
|
|
250
|
+
if (!ret || ret.length > MAX_ERROR_MESSAGE_LENGTH) {
|
|
251
|
+
return UNKNOWN_ERROR_MESSAGE;
|
|
252
|
+
}
|
|
253
|
+
return ret;
|
|
254
|
+
}
|
|
211
255
|
class APIError extends Error {
|
|
212
|
-
constructor(
|
|
213
|
-
super(
|
|
256
|
+
constructor(options) {
|
|
257
|
+
super(UNKNOWN_ERROR_MESSAGE);
|
|
214
258
|
// NOTE: Needs to conform to NetworkError in @redux-offline/redux-offline, which has `status` and `response`.
|
|
215
259
|
__publicField(this, "status");
|
|
216
|
-
__publicField(this, "message");
|
|
217
260
|
__publicField(this, "response");
|
|
261
|
+
__publicField(this, "message");
|
|
218
262
|
__publicField(this, "options");
|
|
219
|
-
|
|
263
|
+
const { response, innerError } = options;
|
|
264
|
+
this.message = options.message ?? extractErrorMessage(response, innerError) ?? UNKNOWN_ERROR_MESSAGE;
|
|
220
265
|
this.status = (response == null ? void 0 : response.status) ?? 0;
|
|
221
266
|
this.response = response;
|
|
222
|
-
|
|
267
|
+
options.discard = options.discard ?? false;
|
|
268
|
+
this.options = options;
|
|
223
269
|
}
|
|
224
270
|
}
|
|
225
271
|
class DeferredPromise {
|
|
@@ -1506,7 +1552,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1506
1552
|
};
|
|
1507
1553
|
const categoryReducer = categorySlice.reducer;
|
|
1508
1554
|
function setAttachments(state, action) {
|
|
1509
|
-
state.attachments = {};
|
|
1510
1555
|
for (const attachment of action.payload) {
|
|
1511
1556
|
state.attachments[attachment.offline_id] = attachment;
|
|
1512
1557
|
}
|
|
@@ -1661,9 +1706,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1661
1706
|
[selectComponentAttachmentMapping],
|
|
1662
1707
|
(mapping) => Object.values(mapping)
|
|
1663
1708
|
);
|
|
1664
|
-
const selectComponentAttachment = (attachmentId) => (state) => {
|
|
1665
|
-
return state.componentReducer.attachments[attachmentId];
|
|
1666
|
-
};
|
|
1667
1709
|
const selectAttachmentsOfComponent = restructureCreateSelectorWithArgs(
|
|
1668
1710
|
toolkit.createSelector(
|
|
1669
1711
|
[selectAllComponentAttachments, (_state, componentId) => componentId],
|
|
@@ -2347,9 +2389,6 @@ var __publicField = (obj, key, value) => {
|
|
|
2347
2389
|
}
|
|
2348
2390
|
)
|
|
2349
2391
|
);
|
|
2350
|
-
const selectIssueAttachment = (attachmentId) => (root) => {
|
|
2351
|
-
return root.issueReducer.attachments[attachmentId];
|
|
2352
|
-
};
|
|
2353
2392
|
const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
|
|
2354
2393
|
toolkit.createSelector(
|
|
2355
2394
|
[selectIssueAttachments, (_state, issueId) => issueId],
|
|
@@ -3804,8 +3843,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3804
3843
|
);
|
|
3805
3844
|
const emailDomainsReducer = emailDomainsSlice.reducer;
|
|
3806
3845
|
const initialState$1 = {
|
|
3807
|
-
documents: {}
|
|
3808
|
-
attachments: {}
|
|
3846
|
+
documents: {}
|
|
3809
3847
|
};
|
|
3810
3848
|
const documentSlice = toolkit.createSlice({
|
|
3811
3849
|
name: "documents",
|
|
@@ -3942,28 +3980,10 @@ var __publicField = (obj, key, value) => {
|
|
|
3942
3980
|
}
|
|
3943
3981
|
delete state.documents[documentId];
|
|
3944
3982
|
}
|
|
3945
|
-
}
|
|
3946
|
-
setDocumentAttachments: setAttachments,
|
|
3947
|
-
addDocumentAttachment: addAttachment,
|
|
3948
|
-
addDocumentAttachments: addAttachments,
|
|
3949
|
-
updateDocumentAttachment: updateAttachment,
|
|
3950
|
-
removeDocumentAttachment: removeAttachment,
|
|
3951
|
-
removeDocumentAttachments: removeAttachments
|
|
3983
|
+
}
|
|
3952
3984
|
}
|
|
3953
3985
|
});
|
|
3954
|
-
const {
|
|
3955
|
-
setDocuments,
|
|
3956
|
-
addDocuments,
|
|
3957
|
-
updateDocuments,
|
|
3958
|
-
moveDocument,
|
|
3959
|
-
removeDocuments,
|
|
3960
|
-
setDocumentAttachments,
|
|
3961
|
-
addDocumentAttachment,
|
|
3962
|
-
addDocumentAttachments,
|
|
3963
|
-
updateDocumentAttachment,
|
|
3964
|
-
removeDocumentAttachment,
|
|
3965
|
-
removeDocumentAttachments
|
|
3966
|
-
} = documentSlice.actions;
|
|
3986
|
+
const { setDocuments, addDocuments, updateDocuments, moveDocument, removeDocuments } = documentSlice.actions;
|
|
3967
3987
|
const selectDocumentsMapping = (state) => state.documentsReducer.documents;
|
|
3968
3988
|
const selectDocuments = toolkit.createSelector(
|
|
3969
3989
|
[selectDocumentsMapping],
|
|
@@ -3993,39 +4013,6 @@ var __publicField = (obj, key, value) => {
|
|
|
3993
4013
|
[selectDocuments],
|
|
3994
4014
|
(documents) => documents.filter((document2) => !document2.parent_document)
|
|
3995
4015
|
);
|
|
3996
|
-
const selectDocumentAttachmentMapping = (state) => state.documentsReducer.attachments;
|
|
3997
|
-
const selectAllDocumentAttachments = toolkit.createSelector(
|
|
3998
|
-
[selectDocumentAttachmentMapping],
|
|
3999
|
-
(mapping) => Object.values(mapping)
|
|
4000
|
-
);
|
|
4001
|
-
const selectDocumentAttachment = (attachmentId) => (state) => {
|
|
4002
|
-
return state.documentsReducer.attachments[attachmentId];
|
|
4003
|
-
};
|
|
4004
|
-
const selectAttachmentsOfDocument = restructureCreateSelectorWithArgs(
|
|
4005
|
-
toolkit.createSelector(
|
|
4006
|
-
[selectAllDocumentAttachments, (_state, documentId) => documentId],
|
|
4007
|
-
(attachments, documentId) => {
|
|
4008
|
-
return attachments.filter(({ document: document2 }) => documentId === document2);
|
|
4009
|
-
}
|
|
4010
|
-
)
|
|
4011
|
-
);
|
|
4012
|
-
const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
|
|
4013
|
-
toolkit.createSelector(
|
|
4014
|
-
[selectAllDocumentAttachments, (_state, documentId) => documentId],
|
|
4015
|
-
(attachments, documentId) => {
|
|
4016
|
-
const attachmentsOfProject = attachments.filter(({ document: document2 }) => documentId === document2);
|
|
4017
|
-
const fileAttachments = attachmentsOfProject.filter(
|
|
4018
|
-
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
4019
|
-
({ file_type }) => !file_type || !file_type.startsWith("image/")
|
|
4020
|
-
);
|
|
4021
|
-
const imageAttachments = attachmentsOfProject.filter(
|
|
4022
|
-
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
4023
|
-
({ file_type }) => file_type && file_type.startsWith("image/")
|
|
4024
|
-
);
|
|
4025
|
-
return { fileAttachments, imageAttachments };
|
|
4026
|
-
}
|
|
4027
|
-
)
|
|
4028
|
-
);
|
|
4029
4016
|
const documentsReducer = documentSlice.reducer;
|
|
4030
4017
|
const initialState = {
|
|
4031
4018
|
version: 0
|
|
@@ -4227,35 +4214,6 @@ var __publicField = (obj, key, value) => {
|
|
|
4227
4214
|
}
|
|
4228
4215
|
return void 0;
|
|
4229
4216
|
}
|
|
4230
|
-
function extractErrorMessage(errorRes, err) {
|
|
4231
|
-
if (errorRes == null ? void 0 : errorRes.body) {
|
|
4232
|
-
if (typeof errorRes.body === "object") {
|
|
4233
|
-
if (typeof errorRes.body.error === "string")
|
|
4234
|
-
return errorRes.body.error;
|
|
4235
|
-
if (typeof errorRes.body.message === "string")
|
|
4236
|
-
return errorRes.body.message;
|
|
4237
|
-
try {
|
|
4238
|
-
return Object.entries(errorRes.body).map(([key, value]) => {
|
|
4239
|
-
if (typeof value === "string") {
|
|
4240
|
-
return `${key}: ${value}`;
|
|
4241
|
-
}
|
|
4242
|
-
if (Array.isArray(value)) {
|
|
4243
|
-
return value.map((v) => `${key}: ${v}`).join("\n");
|
|
4244
|
-
}
|
|
4245
|
-
return `${key}: ${JSON.stringify(value)}`;
|
|
4246
|
-
}).join("\n");
|
|
4247
|
-
} catch (e) {
|
|
4248
|
-
console.error("Failed to extract error message from response body", e);
|
|
4249
|
-
}
|
|
4250
|
-
} else if (typeof errorRes.body === "string")
|
|
4251
|
-
return errorRes.body;
|
|
4252
|
-
} else if (errorRes == null ? void 0 : errorRes.text) {
|
|
4253
|
-
return errorRes.text;
|
|
4254
|
-
} else if (err instanceof Error) {
|
|
4255
|
-
return err.message;
|
|
4256
|
-
}
|
|
4257
|
-
return void 0;
|
|
4258
|
-
}
|
|
4259
4217
|
async function performRequest(action, client) {
|
|
4260
4218
|
async function checkToken() {
|
|
4261
4219
|
if (client.auth.tokenIsExpiringSoon()) {
|
|
@@ -4358,19 +4316,29 @@ var __publicField = (obj, key, value) => {
|
|
|
4358
4316
|
console.warn("No signed-in user to sign out.");
|
|
4359
4317
|
}
|
|
4360
4318
|
await client.auth.logout();
|
|
4361
|
-
throw new APIError(
|
|
4362
|
-
|
|
4319
|
+
throw new APIError({
|
|
4320
|
+
message: "You have been signed out due to inactivity.",
|
|
4321
|
+
response: errorResponse,
|
|
4322
|
+
discard: true,
|
|
4323
|
+
innerError: error2
|
|
4324
|
+
});
|
|
4325
|
+
}
|
|
4326
|
+
if (state.authReducer.isLoggedIn) {
|
|
4327
|
+
console.debug("Forbidden; renewing tokens and retrying.");
|
|
4328
|
+
await client.auth.renewTokens();
|
|
4329
|
+
console.debug("Successfully renewed tokens; retrying request.");
|
|
4330
|
+
return requestToSend.query(queryParams);
|
|
4331
|
+
} else {
|
|
4332
|
+
console.debug("Forbidden; user is not logged in.");
|
|
4333
|
+
throw new APIError({
|
|
4334
|
+
message: "Incorrect username or password.",
|
|
4335
|
+
response: errorResponse,
|
|
4336
|
+
discard: true,
|
|
4337
|
+
innerError: error2
|
|
4363
4338
|
});
|
|
4364
4339
|
}
|
|
4365
|
-
console.debug("Forbidden; renewing tokens and retrying.");
|
|
4366
|
-
await client.auth.renewTokens();
|
|
4367
|
-
console.debug("Successfully renewed tokens; retrying request.");
|
|
4368
|
-
return requestToSend.query(queryParams);
|
|
4369
4340
|
}
|
|
4370
|
-
|
|
4371
|
-
throw new APIError(apiErrorMessage, errorResponse, {
|
|
4372
|
-
discard: discardStatuses.includes(status)
|
|
4373
|
-
});
|
|
4341
|
+
throw new APIError({ response: errorResponse, innerError: error2, discard: discardStatuses.includes(status) });
|
|
4374
4342
|
}
|
|
4375
4343
|
}
|
|
4376
4344
|
class MiddlewareChainerPrivate {
|
|
@@ -4581,18 +4549,29 @@ var __publicField = (obj, key, value) => {
|
|
|
4581
4549
|
if (response) {
|
|
4582
4550
|
promise.resolve(response.body);
|
|
4583
4551
|
} else {
|
|
4584
|
-
const error2 = new APIError(
|
|
4585
|
-
"Could not get a response from the server.",
|
|
4552
|
+
const error2 = new APIError({
|
|
4553
|
+
message: "Could not get a response from the server.",
|
|
4586
4554
|
response,
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
}
|
|
4590
|
-
);
|
|
4555
|
+
discard: true
|
|
4556
|
+
});
|
|
4591
4557
|
promise.reject(error2);
|
|
4592
4558
|
}
|
|
4593
4559
|
};
|
|
4594
4560
|
const errorHandler = (error2) => {
|
|
4595
|
-
error2
|
|
4561
|
+
if (error2 instanceof APIError) {
|
|
4562
|
+
error2.options.discard = true;
|
|
4563
|
+
} else {
|
|
4564
|
+
console.error(
|
|
4565
|
+
"Received an unexpected error while processing a request:",
|
|
4566
|
+
error2,
|
|
4567
|
+
"\nConverting error to APIError and discarding."
|
|
4568
|
+
);
|
|
4569
|
+
error2 = new APIError({
|
|
4570
|
+
message: "An error occurred while processing the request.",
|
|
4571
|
+
innerError: error2,
|
|
4572
|
+
discard: true
|
|
4573
|
+
});
|
|
4574
|
+
}
|
|
4596
4575
|
promise.reject(error2);
|
|
4597
4576
|
};
|
|
4598
4577
|
innerPromise.then(successOrUndefinedHandler, errorHandler);
|
|
@@ -4614,8 +4593,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4614
4593
|
issue_attachments: Object.values(state.issueReducer.attachments),
|
|
4615
4594
|
component_attachments: Object.values(state.componentReducer.attachments),
|
|
4616
4595
|
component_type_attachments: Object.values(state.componentTypeReducer.attachments),
|
|
4617
|
-
project_attachments: Object.values(state.projectReducer.attachments)
|
|
4618
|
-
document_attachments: Object.values(state.documentsReducer.attachments)
|
|
4596
|
+
project_attachments: Object.values(state.projectReducer.attachments)
|
|
4619
4597
|
};
|
|
4620
4598
|
return [allAttachments, promise];
|
|
4621
4599
|
}
|
|
@@ -4719,8 +4697,8 @@ var __publicField = (obj, key, value) => {
|
|
|
4719
4697
|
});
|
|
4720
4698
|
return [offlineAttachment, promise];
|
|
4721
4699
|
}
|
|
4722
|
-
async
|
|
4723
|
-
const { description: description2,
|
|
4700
|
+
async addProjectAttachment(attachmentPayload) {
|
|
4701
|
+
const { description: description2, project, file_sha1, offline_id } = attachmentPayload;
|
|
4724
4702
|
if (!attachmentPayload.file.objectURL) {
|
|
4725
4703
|
throw new Error("Expected attachmentPayload.file.objectURL to be defined.");
|
|
4726
4704
|
}
|
|
@@ -4733,24 +4711,24 @@ var __publicField = (obj, key, value) => {
|
|
|
4733
4711
|
created_by: this.client.store.getState().userReducer.currentUser.id
|
|
4734
4712
|
};
|
|
4735
4713
|
await this.client.files.addCache(attachmentPayload.file, file_sha1);
|
|
4736
|
-
this.client.store.dispatch(
|
|
4714
|
+
this.client.store.dispatch(addProjectAttachment(offlineAttachment));
|
|
4737
4715
|
const [fileProps] = await this.client.files.uploadFileToS3(file_sha1);
|
|
4738
4716
|
const promise = this.enqueueRequest({
|
|
4739
4717
|
description: "Create attachment",
|
|
4740
4718
|
method: HttpMethod.POST,
|
|
4741
|
-
url: `/
|
|
4742
|
-
blocks: [offline_id,
|
|
4719
|
+
url: `/projects/${project}/attach/`,
|
|
4720
|
+
blocks: [offline_id, project.toString()],
|
|
4743
4721
|
blockers: [file_sha1],
|
|
4744
4722
|
payload: {
|
|
4745
4723
|
offline_id,
|
|
4746
|
-
|
|
4724
|
+
project,
|
|
4747
4725
|
description: description2 ?? "",
|
|
4748
4726
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4749
4727
|
...fileProps
|
|
4750
4728
|
}
|
|
4751
4729
|
});
|
|
4752
4730
|
promise.catch((error2) => {
|
|
4753
|
-
this.client.store.dispatch(
|
|
4731
|
+
this.client.store.dispatch(removeProjectAttachment(offlineAttachment.offline_id));
|
|
4754
4732
|
throw error2;
|
|
4755
4733
|
});
|
|
4756
4734
|
return [offlineAttachment, promise];
|
|
@@ -4821,7 +4799,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4821
4799
|
return photoAttachmentPromise(file);
|
|
4822
4800
|
});
|
|
4823
4801
|
}
|
|
4824
|
-
|
|
4802
|
+
attachFilesToProject(filesToSubmit, projectId) {
|
|
4825
4803
|
return filesToSubmit.map((file) => {
|
|
4826
4804
|
if (!(file instanceof File)) {
|
|
4827
4805
|
throw new Error("Expected a File instance.");
|
|
@@ -4832,12 +4810,12 @@ var __publicField = (obj, key, value) => {
|
|
|
4832
4810
|
file: file2,
|
|
4833
4811
|
file_name: file2.name,
|
|
4834
4812
|
file_type: file2.type,
|
|
4835
|
-
|
|
4813
|
+
project: projectId,
|
|
4836
4814
|
file_sha1: hash,
|
|
4837
4815
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4838
4816
|
created_by: this.client.store.getState().userReducer.currentUser.id
|
|
4839
4817
|
});
|
|
4840
|
-
return this.
|
|
4818
|
+
return this.addProjectAttachment(attachment);
|
|
4841
4819
|
};
|
|
4842
4820
|
return photoAttachmentPromise(file);
|
|
4843
4821
|
});
|
|
@@ -5017,9 +4995,9 @@ var __publicField = (obj, key, value) => {
|
|
|
5017
4995
|
const promise = performRequest2();
|
|
5018
4996
|
return [offlineAttachment, promise];
|
|
5019
4997
|
}
|
|
5020
|
-
async
|
|
4998
|
+
async replaceProjectAttachmentFile(attachmentId, newFile) {
|
|
5021
4999
|
const { store } = this.client;
|
|
5022
|
-
const attachment = store.getState().
|
|
5000
|
+
const attachment = store.getState().projectReducer.attachments[attachmentId];
|
|
5023
5001
|
if (!attachment)
|
|
5024
5002
|
throw new Error(`Attachment ${attachmentId} not found`);
|
|
5025
5003
|
let oldFile = void 0;
|
|
@@ -5033,7 +5011,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5033
5011
|
throw new Error(`newFile["objectURL"] is unexpectedly ${newFile.objectURL}`);
|
|
5034
5012
|
}
|
|
5035
5013
|
store.dispatch(
|
|
5036
|
-
|
|
5014
|
+
updateProjectAttachment({
|
|
5037
5015
|
...attachment,
|
|
5038
5016
|
file_sha1: newSha1,
|
|
5039
5017
|
file: URL.createObjectURL(newFile)
|
|
@@ -5041,13 +5019,13 @@ var __publicField = (obj, key, value) => {
|
|
|
5041
5019
|
);
|
|
5042
5020
|
await this.client.files.addCache(newFile, newSha1);
|
|
5043
5021
|
const [fileProps] = await this.client.files.uploadFileToS3(newSha1).catch((e) => {
|
|
5044
|
-
store.dispatch(
|
|
5022
|
+
store.dispatch(updateProjectAttachment(attachment));
|
|
5045
5023
|
throw e;
|
|
5046
5024
|
});
|
|
5047
5025
|
const promise2 = this.enqueueRequest({
|
|
5048
5026
|
description: "Edit attachment",
|
|
5049
5027
|
method: HttpMethod.PATCH,
|
|
5050
|
-
url: `/attachments/
|
|
5028
|
+
url: `/attachments/projects/${attachment.offline_id}/`,
|
|
5051
5029
|
isResponseBlob: false,
|
|
5052
5030
|
payload: fileProps,
|
|
5053
5031
|
blockers: [attachmentId, newSha1],
|
|
@@ -5060,7 +5038,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5060
5038
|
} catch (e) {
|
|
5061
5039
|
if (oldFile) {
|
|
5062
5040
|
store.dispatch(
|
|
5063
|
-
|
|
5041
|
+
updateProjectAttachment({
|
|
5064
5042
|
...attachment,
|
|
5065
5043
|
file_sha1: attachment.file_sha1,
|
|
5066
5044
|
file: URL.createObjectURL(oldFile)
|
|
@@ -5130,20 +5108,20 @@ var __publicField = (obj, key, value) => {
|
|
|
5130
5108
|
blocks: [componentTypeAttachmentId]
|
|
5131
5109
|
});
|
|
5132
5110
|
}
|
|
5133
|
-
|
|
5111
|
+
deleteProjectAttachment(projectAttachmentId) {
|
|
5134
5112
|
const { store } = this.client;
|
|
5135
|
-
const attachment = store.getState()
|
|
5113
|
+
const attachment = selectProjectAttachmentMapping(store.getState())[projectAttachmentId];
|
|
5136
5114
|
if (!attachment) {
|
|
5137
|
-
throw new Error(`Attachment ${
|
|
5115
|
+
throw new Error(`Attachment ${projectAttachmentId} not found`);
|
|
5138
5116
|
}
|
|
5139
|
-
store.dispatch(
|
|
5117
|
+
store.dispatch(removeProjectAttachment(projectAttachmentId));
|
|
5140
5118
|
void this.client.files.removeCache(attachment.file_sha1);
|
|
5141
5119
|
return this.enqueueRequest({
|
|
5142
|
-
description: "Delete
|
|
5120
|
+
description: "Delete attachment",
|
|
5143
5121
|
method: HttpMethod.DELETE,
|
|
5144
|
-
url: `/attachments/
|
|
5145
|
-
blockers: [
|
|
5146
|
-
blocks: [
|
|
5122
|
+
url: `/attachments/projects/${projectAttachmentId}/`,
|
|
5123
|
+
blockers: [projectAttachmentId],
|
|
5124
|
+
blocks: [projectAttachmentId]
|
|
5147
5125
|
});
|
|
5148
5126
|
}
|
|
5149
5127
|
}
|
|
@@ -5173,24 +5151,23 @@ var __publicField = (obj, key, value) => {
|
|
|
5173
5151
|
*/
|
|
5174
5152
|
__publicField(this, "_getTokenPair", (credentials, logoutOnFailure = true) => {
|
|
5175
5153
|
const uuid$1 = uuid.v4();
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
return [responsePromise.then(parseTokens), uuid$1];
|
|
5188
|
-
} catch (e) {
|
|
5154
|
+
const responsePromise = this.enqueueRequest({
|
|
5155
|
+
uuid: uuid$1,
|
|
5156
|
+
description: "Get token pair",
|
|
5157
|
+
method: HttpMethod.POST,
|
|
5158
|
+
url: "/api/token/",
|
|
5159
|
+
payload: credentials,
|
|
5160
|
+
isAuthNeeded: false,
|
|
5161
|
+
checkAuth: false,
|
|
5162
|
+
blockers: [],
|
|
5163
|
+
blocks: []
|
|
5164
|
+
}).then(parseTokens).catch((e) => {
|
|
5189
5165
|
if (logoutOnFailure) {
|
|
5190
5166
|
void this.logout().then();
|
|
5191
5167
|
}
|
|
5192
5168
|
throw e;
|
|
5193
|
-
}
|
|
5169
|
+
});
|
|
5170
|
+
return [responsePromise, uuid$1];
|
|
5194
5171
|
});
|
|
5195
5172
|
/**
|
|
5196
5173
|
* Takes refresh token and gets a new token pair
|
|
@@ -5251,7 +5228,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5251
5228
|
timedOut = true;
|
|
5252
5229
|
store.dispatch(markForDeletion(uuid$1));
|
|
5253
5230
|
store.dispatch(markForDeletion(initialDataUuid));
|
|
5254
|
-
reject(new
|
|
5231
|
+
reject(new APIError({ message: `Request timed out after ${timeout} seconds` }));
|
|
5255
5232
|
}, timeout * 1e3);
|
|
5256
5233
|
});
|
|
5257
5234
|
const successPromise = promise.then((tokens) => {
|
|
@@ -6381,18 +6358,11 @@ var __publicField = (obj, key, value) => {
|
|
|
6381
6358
|
if (currentProjectId) {
|
|
6382
6359
|
const [_offlineAttachments, promise] = this.client.attachments.fetchAll(currentProjectId);
|
|
6383
6360
|
void promise.then((result) => {
|
|
6384
|
-
const {
|
|
6385
|
-
issue_attachments,
|
|
6386
|
-
component_type_attachments,
|
|
6387
|
-
component_attachments,
|
|
6388
|
-
project_attachments,
|
|
6389
|
-
document_attachments
|
|
6390
|
-
} = result;
|
|
6361
|
+
const { issue_attachments, component_type_attachments, component_attachments, project_attachments } = result;
|
|
6391
6362
|
store.dispatch(setIssueAttachments(issue_attachments));
|
|
6392
6363
|
store.dispatch(setComponentAttachments(component_attachments));
|
|
6393
6364
|
store.dispatch(setComponentTypeAttachments(component_type_attachments));
|
|
6394
6365
|
store.dispatch(setProjectAttachments(project_attachments));
|
|
6395
|
-
store.dispatch(setDocumentAttachments(document_attachments));
|
|
6396
6366
|
});
|
|
6397
6367
|
void this.client.documents.refreshStore();
|
|
6398
6368
|
void this.client.issueUpdates.refreshStore();
|
|
@@ -7227,8 +7197,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7227
7197
|
blockers: [],
|
|
7228
7198
|
blocks: []
|
|
7229
7199
|
});
|
|
7230
|
-
|
|
7231
|
-
store.dispatch(setOrganizationAccesses(organizationAccesses));
|
|
7200
|
+
store.dispatch(setOrganizationAccesses(result));
|
|
7232
7201
|
}
|
|
7233
7202
|
}
|
|
7234
7203
|
const cachedRequestPromises = {};
|
|
@@ -15652,8 +15621,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15652
15621
|
exports2.addComponentTypeAttachment = addComponentTypeAttachment;
|
|
15653
15622
|
exports2.addComponentTypeAttachments = addComponentTypeAttachments;
|
|
15654
15623
|
exports2.addComponentsInBatches = addComponentsInBatches;
|
|
15655
|
-
exports2.addDocumentAttachment = addDocumentAttachment;
|
|
15656
|
-
exports2.addDocumentAttachments = addDocumentAttachments;
|
|
15657
15624
|
exports2.addDocuments = addDocuments;
|
|
15658
15625
|
exports2.addEmailDomain = addEmailDomain;
|
|
15659
15626
|
exports2.addFavouriteProjectId = addFavouriteProjectId;
|
|
@@ -15817,8 +15784,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15817
15784
|
exports2.removeComponentAttachments = removeComponentAttachments;
|
|
15818
15785
|
exports2.removeComponentTypeAttachment = removeComponentTypeAttachment;
|
|
15819
15786
|
exports2.removeComponentTypeAttachments = removeComponentTypeAttachments;
|
|
15820
|
-
exports2.removeDocumentAttachment = removeDocumentAttachment;
|
|
15821
|
-
exports2.removeDocumentAttachments = removeDocumentAttachments;
|
|
15822
15787
|
exports2.removeDocuments = removeDocuments;
|
|
15823
15788
|
exports2.removeEmailDomain = removeEmailDomain;
|
|
15824
15789
|
exports2.removeFavouriteProjectId = removeFavouriteProjectId;
|
|
@@ -15866,7 +15831,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15866
15831
|
exports2.selectAllAttachments = selectAllAttachments;
|
|
15867
15832
|
exports2.selectAllComponentAttachments = selectAllComponentAttachments;
|
|
15868
15833
|
exports2.selectAllComponentTypeAttachments = selectAllComponentTypeAttachments;
|
|
15869
|
-
exports2.selectAllDocumentAttachments = selectAllDocumentAttachments;
|
|
15870
15834
|
exports2.selectAllProjectAttachments = selectAllProjectAttachments;
|
|
15871
15835
|
exports2.selectAncestorIdsOfDocument = selectAncestorIdsOfDocument;
|
|
15872
15836
|
exports2.selectAppearance = selectAppearance;
|
|
@@ -15874,8 +15838,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15874
15838
|
exports2.selectAttachmentsOfComponentByType = selectAttachmentsOfComponentByType;
|
|
15875
15839
|
exports2.selectAttachmentsOfComponentType = selectAttachmentsOfComponentType;
|
|
15876
15840
|
exports2.selectAttachmentsOfComponentTypeByType = selectAttachmentsOfComponentTypeByType;
|
|
15877
|
-
exports2.selectAttachmentsOfDocument = selectAttachmentsOfDocument;
|
|
15878
|
-
exports2.selectAttachmentsOfDocumentByType = selectAttachmentsOfDocumentByType;
|
|
15879
15841
|
exports2.selectAttachmentsOfIssue = selectAttachmentsOfIssue;
|
|
15880
15842
|
exports2.selectAttachmentsOfIssueByType = selectAttachmentsOfIssueByType;
|
|
15881
15843
|
exports2.selectAttachmentsOfProject = selectAttachmentsOfProject;
|
|
@@ -15891,7 +15853,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15891
15853
|
exports2.selectCompletedStageIdsForComponent = selectCompletedStageIdsForComponent;
|
|
15892
15854
|
exports2.selectCompletedStages = selectCompletedStages;
|
|
15893
15855
|
exports2.selectComponent = selectComponent;
|
|
15894
|
-
exports2.selectComponentAttachment = selectComponentAttachment;
|
|
15895
15856
|
exports2.selectComponentAttachmentMapping = selectComponentAttachmentMapping;
|
|
15896
15857
|
exports2.selectComponentSubmissionMapping = selectComponentSubmissionMapping;
|
|
15897
15858
|
exports2.selectComponentType = selectComponentType;
|
|
@@ -15912,8 +15873,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15912
15873
|
exports2.selectCurrentUser = selectCurrentUser;
|
|
15913
15874
|
exports2.selectDeletedRequests = selectDeletedRequests;
|
|
15914
15875
|
exports2.selectDocument = selectDocument;
|
|
15915
|
-
exports2.selectDocumentAttachment = selectDocumentAttachment;
|
|
15916
|
-
exports2.selectDocumentAttachmentMapping = selectDocumentAttachmentMapping;
|
|
15917
15876
|
exports2.selectDocuments = selectDocuments;
|
|
15918
15877
|
exports2.selectDocumentsMapping = selectDocumentsMapping;
|
|
15919
15878
|
exports2.selectEmailDomainsAsMapping = selectEmailDomainsAsMapping;
|
|
@@ -15935,7 +15894,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15935
15894
|
exports2.selectIsLoading = selectIsLoading;
|
|
15936
15895
|
exports2.selectIsLoggedIn = selectIsLoggedIn;
|
|
15937
15896
|
exports2.selectIssue = selectIssue;
|
|
15938
|
-
exports2.selectIssueAttachment = selectIssueAttachment;
|
|
15939
15897
|
exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
|
|
15940
15898
|
exports2.selectIssueAttachments = selectIssueAttachments;
|
|
15941
15899
|
exports2.selectIssueMapping = selectIssueMapping;
|
|
@@ -16029,7 +15987,6 @@ var __publicField = (obj, key, value) => {
|
|
|
16029
15987
|
exports2.setComponents = setComponents;
|
|
16030
15988
|
exports2.setCreateProjectType = setCreateProjectType;
|
|
16031
15989
|
exports2.setCurrentUser = setCurrentUser;
|
|
16032
|
-
exports2.setDocumentAttachments = setDocumentAttachments;
|
|
16033
15990
|
exports2.setDocuments = setDocuments;
|
|
16034
15991
|
exports2.setEmailDomains = setEmailDomains;
|
|
16035
15992
|
exports2.setEnableClustering = setEnableClustering;
|
|
@@ -16084,7 +16041,6 @@ var __publicField = (obj, key, value) => {
|
|
|
16084
16041
|
exports2.updateComponent = updateComponent;
|
|
16085
16042
|
exports2.updateComponentAttachment = updateComponentAttachment;
|
|
16086
16043
|
exports2.updateComponentTypeAttachment = updateComponentTypeAttachment;
|
|
16087
|
-
exports2.updateDocumentAttachment = updateDocumentAttachment;
|
|
16088
16044
|
exports2.updateDocuments = updateDocuments;
|
|
16089
16045
|
exports2.updateIssue = updateIssue;
|
|
16090
16046
|
exports2.updateIssueAttachment = updateIssueAttachment;
|