@overmap-ai/core 1.0.50-document-attachments.2 → 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 -181
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +133 -181
- 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/componentTypeSlice.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],
|
|
@@ -1953,9 +1995,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1953
1995
|
[selectComponentTypeAttachmentMapping],
|
|
1954
1996
|
(mapping) => Object.values(mapping)
|
|
1955
1997
|
);
|
|
1956
|
-
const selectComponentTypeAttachment = (attachmentId) => (state) => {
|
|
1957
|
-
return state.componentTypeReducer.attachments[attachmentId];
|
|
1958
|
-
};
|
|
1959
1998
|
const selectAttachmentsOfComponentType = restructureCreateSelectorWithArgs(
|
|
1960
1999
|
toolkit.createSelector(
|
|
1961
2000
|
[selectAllComponentTypeAttachments, (_state, componentTypeId) => componentTypeId],
|
|
@@ -2350,9 +2389,6 @@ var __publicField = (obj, key, value) => {
|
|
|
2350
2389
|
}
|
|
2351
2390
|
)
|
|
2352
2391
|
);
|
|
2353
|
-
const selectIssueAttachment = (attachmentId) => (root) => {
|
|
2354
|
-
return root.issueReducer.attachments[attachmentId];
|
|
2355
|
-
};
|
|
2356
2392
|
const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
|
|
2357
2393
|
toolkit.createSelector(
|
|
2358
2394
|
[selectIssueAttachments, (_state, issueId) => issueId],
|
|
@@ -3807,8 +3843,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3807
3843
|
);
|
|
3808
3844
|
const emailDomainsReducer = emailDomainsSlice.reducer;
|
|
3809
3845
|
const initialState$1 = {
|
|
3810
|
-
documents: {}
|
|
3811
|
-
attachments: {}
|
|
3846
|
+
documents: {}
|
|
3812
3847
|
};
|
|
3813
3848
|
const documentSlice = toolkit.createSlice({
|
|
3814
3849
|
name: "documents",
|
|
@@ -3945,28 +3980,10 @@ var __publicField = (obj, key, value) => {
|
|
|
3945
3980
|
}
|
|
3946
3981
|
delete state.documents[documentId];
|
|
3947
3982
|
}
|
|
3948
|
-
}
|
|
3949
|
-
setDocumentAttachments: setAttachments,
|
|
3950
|
-
addDocumentAttachment: addAttachment,
|
|
3951
|
-
addDocumentAttachments: addAttachments,
|
|
3952
|
-
updateDocumentAttachment: updateAttachment,
|
|
3953
|
-
removeDocumentAttachment: removeAttachment,
|
|
3954
|
-
removeDocumentAttachments: removeAttachments
|
|
3983
|
+
}
|
|
3955
3984
|
}
|
|
3956
3985
|
});
|
|
3957
|
-
const {
|
|
3958
|
-
setDocuments,
|
|
3959
|
-
addDocuments,
|
|
3960
|
-
updateDocuments,
|
|
3961
|
-
moveDocument,
|
|
3962
|
-
removeDocuments,
|
|
3963
|
-
setDocumentAttachments,
|
|
3964
|
-
addDocumentAttachment,
|
|
3965
|
-
addDocumentAttachments,
|
|
3966
|
-
updateDocumentAttachment,
|
|
3967
|
-
removeDocumentAttachment,
|
|
3968
|
-
removeDocumentAttachments
|
|
3969
|
-
} = documentSlice.actions;
|
|
3986
|
+
const { setDocuments, addDocuments, updateDocuments, moveDocument, removeDocuments } = documentSlice.actions;
|
|
3970
3987
|
const selectDocumentsMapping = (state) => state.documentsReducer.documents;
|
|
3971
3988
|
const selectDocuments = toolkit.createSelector(
|
|
3972
3989
|
[selectDocumentsMapping],
|
|
@@ -3996,39 +4013,6 @@ var __publicField = (obj, key, value) => {
|
|
|
3996
4013
|
[selectDocuments],
|
|
3997
4014
|
(documents) => documents.filter((document2) => !document2.parent_document)
|
|
3998
4015
|
);
|
|
3999
|
-
const selectDocumentAttachmentMapping = (state) => state.documentsReducer.attachments;
|
|
4000
|
-
const selectAllDocumentAttachments = toolkit.createSelector(
|
|
4001
|
-
[selectDocumentAttachmentMapping],
|
|
4002
|
-
(mapping) => Object.values(mapping)
|
|
4003
|
-
);
|
|
4004
|
-
const selectDocumentAttachment = (attachmentId) => (state) => {
|
|
4005
|
-
return state.documentsReducer.attachments[attachmentId];
|
|
4006
|
-
};
|
|
4007
|
-
const selectAttachmentsOfDocument = restructureCreateSelectorWithArgs(
|
|
4008
|
-
toolkit.createSelector(
|
|
4009
|
-
[selectAllDocumentAttachments, (_state, documentId) => documentId],
|
|
4010
|
-
(attachments, documentId) => {
|
|
4011
|
-
return attachments.filter(({ document: document2 }) => documentId === document2);
|
|
4012
|
-
}
|
|
4013
|
-
)
|
|
4014
|
-
);
|
|
4015
|
-
const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
|
|
4016
|
-
toolkit.createSelector(
|
|
4017
|
-
[selectAllDocumentAttachments, (_state, documentId) => documentId],
|
|
4018
|
-
(attachments, documentId) => {
|
|
4019
|
-
const attachmentsOfProject = attachments.filter(({ document: document2 }) => documentId === document2);
|
|
4020
|
-
const fileAttachments = attachmentsOfProject.filter(
|
|
4021
|
-
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
4022
|
-
({ file_type }) => !file_type || !file_type.startsWith("image/")
|
|
4023
|
-
);
|
|
4024
|
-
const imageAttachments = attachmentsOfProject.filter(
|
|
4025
|
-
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
4026
|
-
({ file_type }) => file_type && file_type.startsWith("image/")
|
|
4027
|
-
);
|
|
4028
|
-
return { fileAttachments, imageAttachments };
|
|
4029
|
-
}
|
|
4030
|
-
)
|
|
4031
|
-
);
|
|
4032
4016
|
const documentsReducer = documentSlice.reducer;
|
|
4033
4017
|
const initialState = {
|
|
4034
4018
|
version: 0
|
|
@@ -4230,35 +4214,6 @@ var __publicField = (obj, key, value) => {
|
|
|
4230
4214
|
}
|
|
4231
4215
|
return void 0;
|
|
4232
4216
|
}
|
|
4233
|
-
function extractErrorMessage(errorRes, err) {
|
|
4234
|
-
if (errorRes == null ? void 0 : errorRes.body) {
|
|
4235
|
-
if (typeof errorRes.body === "object") {
|
|
4236
|
-
if (typeof errorRes.body.error === "string")
|
|
4237
|
-
return errorRes.body.error;
|
|
4238
|
-
if (typeof errorRes.body.message === "string")
|
|
4239
|
-
return errorRes.body.message;
|
|
4240
|
-
try {
|
|
4241
|
-
return Object.entries(errorRes.body).map(([key, value]) => {
|
|
4242
|
-
if (typeof value === "string") {
|
|
4243
|
-
return `${key}: ${value}`;
|
|
4244
|
-
}
|
|
4245
|
-
if (Array.isArray(value)) {
|
|
4246
|
-
return value.map((v) => `${key}: ${v}`).join("\n");
|
|
4247
|
-
}
|
|
4248
|
-
return `${key}: ${JSON.stringify(value)}`;
|
|
4249
|
-
}).join("\n");
|
|
4250
|
-
} catch (e) {
|
|
4251
|
-
console.error("Failed to extract error message from response body", e);
|
|
4252
|
-
}
|
|
4253
|
-
} else if (typeof errorRes.body === "string")
|
|
4254
|
-
return errorRes.body;
|
|
4255
|
-
} else if (errorRes == null ? void 0 : errorRes.text) {
|
|
4256
|
-
return errorRes.text;
|
|
4257
|
-
} else if (err instanceof Error) {
|
|
4258
|
-
return err.message;
|
|
4259
|
-
}
|
|
4260
|
-
return void 0;
|
|
4261
|
-
}
|
|
4262
4217
|
async function performRequest(action, client) {
|
|
4263
4218
|
async function checkToken() {
|
|
4264
4219
|
if (client.auth.tokenIsExpiringSoon()) {
|
|
@@ -4361,19 +4316,29 @@ var __publicField = (obj, key, value) => {
|
|
|
4361
4316
|
console.warn("No signed-in user to sign out.");
|
|
4362
4317
|
}
|
|
4363
4318
|
await client.auth.logout();
|
|
4364
|
-
throw new APIError(
|
|
4365
|
-
|
|
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
|
|
4366
4338
|
});
|
|
4367
4339
|
}
|
|
4368
|
-
console.debug("Forbidden; renewing tokens and retrying.");
|
|
4369
|
-
await client.auth.renewTokens();
|
|
4370
|
-
console.debug("Successfully renewed tokens; retrying request.");
|
|
4371
|
-
return requestToSend.query(queryParams);
|
|
4372
4340
|
}
|
|
4373
|
-
|
|
4374
|
-
throw new APIError(apiErrorMessage, errorResponse, {
|
|
4375
|
-
discard: discardStatuses.includes(status)
|
|
4376
|
-
});
|
|
4341
|
+
throw new APIError({ response: errorResponse, innerError: error2, discard: discardStatuses.includes(status) });
|
|
4377
4342
|
}
|
|
4378
4343
|
}
|
|
4379
4344
|
class MiddlewareChainerPrivate {
|
|
@@ -4584,18 +4549,29 @@ var __publicField = (obj, key, value) => {
|
|
|
4584
4549
|
if (response) {
|
|
4585
4550
|
promise.resolve(response.body);
|
|
4586
4551
|
} else {
|
|
4587
|
-
const error2 = new APIError(
|
|
4588
|
-
"Could not get a response from the server.",
|
|
4552
|
+
const error2 = new APIError({
|
|
4553
|
+
message: "Could not get a response from the server.",
|
|
4589
4554
|
response,
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
}
|
|
4593
|
-
);
|
|
4555
|
+
discard: true
|
|
4556
|
+
});
|
|
4594
4557
|
promise.reject(error2);
|
|
4595
4558
|
}
|
|
4596
4559
|
};
|
|
4597
4560
|
const errorHandler = (error2) => {
|
|
4598
|
-
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
|
+
}
|
|
4599
4575
|
promise.reject(error2);
|
|
4600
4576
|
};
|
|
4601
4577
|
innerPromise.then(successOrUndefinedHandler, errorHandler);
|
|
@@ -4617,8 +4593,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4617
4593
|
issue_attachments: Object.values(state.issueReducer.attachments),
|
|
4618
4594
|
component_attachments: Object.values(state.componentReducer.attachments),
|
|
4619
4595
|
component_type_attachments: Object.values(state.componentTypeReducer.attachments),
|
|
4620
|
-
project_attachments: Object.values(state.projectReducer.attachments)
|
|
4621
|
-
document_attachments: Object.values(state.documentsReducer.attachments)
|
|
4596
|
+
project_attachments: Object.values(state.projectReducer.attachments)
|
|
4622
4597
|
};
|
|
4623
4598
|
return [allAttachments, promise];
|
|
4624
4599
|
}
|
|
@@ -4722,8 +4697,8 @@ var __publicField = (obj, key, value) => {
|
|
|
4722
4697
|
});
|
|
4723
4698
|
return [offlineAttachment, promise];
|
|
4724
4699
|
}
|
|
4725
|
-
async
|
|
4726
|
-
const { description: description2,
|
|
4700
|
+
async addProjectAttachment(attachmentPayload) {
|
|
4701
|
+
const { description: description2, project, file_sha1, offline_id } = attachmentPayload;
|
|
4727
4702
|
if (!attachmentPayload.file.objectURL) {
|
|
4728
4703
|
throw new Error("Expected attachmentPayload.file.objectURL to be defined.");
|
|
4729
4704
|
}
|
|
@@ -4736,24 +4711,24 @@ var __publicField = (obj, key, value) => {
|
|
|
4736
4711
|
created_by: this.client.store.getState().userReducer.currentUser.id
|
|
4737
4712
|
};
|
|
4738
4713
|
await this.client.files.addCache(attachmentPayload.file, file_sha1);
|
|
4739
|
-
this.client.store.dispatch(
|
|
4714
|
+
this.client.store.dispatch(addProjectAttachment(offlineAttachment));
|
|
4740
4715
|
const [fileProps] = await this.client.files.uploadFileToS3(file_sha1);
|
|
4741
4716
|
const promise = this.enqueueRequest({
|
|
4742
4717
|
description: "Create attachment",
|
|
4743
4718
|
method: HttpMethod.POST,
|
|
4744
|
-
url: `/
|
|
4745
|
-
blocks: [offline_id,
|
|
4719
|
+
url: `/projects/${project}/attach/`,
|
|
4720
|
+
blocks: [offline_id, project.toString()],
|
|
4746
4721
|
blockers: [file_sha1],
|
|
4747
4722
|
payload: {
|
|
4748
4723
|
offline_id,
|
|
4749
|
-
|
|
4724
|
+
project,
|
|
4750
4725
|
description: description2 ?? "",
|
|
4751
4726
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4752
4727
|
...fileProps
|
|
4753
4728
|
}
|
|
4754
4729
|
});
|
|
4755
4730
|
promise.catch((error2) => {
|
|
4756
|
-
this.client.store.dispatch(
|
|
4731
|
+
this.client.store.dispatch(removeProjectAttachment(offlineAttachment.offline_id));
|
|
4757
4732
|
throw error2;
|
|
4758
4733
|
});
|
|
4759
4734
|
return [offlineAttachment, promise];
|
|
@@ -4824,7 +4799,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4824
4799
|
return photoAttachmentPromise(file);
|
|
4825
4800
|
});
|
|
4826
4801
|
}
|
|
4827
|
-
|
|
4802
|
+
attachFilesToProject(filesToSubmit, projectId) {
|
|
4828
4803
|
return filesToSubmit.map((file) => {
|
|
4829
4804
|
if (!(file instanceof File)) {
|
|
4830
4805
|
throw new Error("Expected a File instance.");
|
|
@@ -4835,12 +4810,12 @@ var __publicField = (obj, key, value) => {
|
|
|
4835
4810
|
file: file2,
|
|
4836
4811
|
file_name: file2.name,
|
|
4837
4812
|
file_type: file2.type,
|
|
4838
|
-
|
|
4813
|
+
project: projectId,
|
|
4839
4814
|
file_sha1: hash,
|
|
4840
4815
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4841
4816
|
created_by: this.client.store.getState().userReducer.currentUser.id
|
|
4842
4817
|
});
|
|
4843
|
-
return this.
|
|
4818
|
+
return this.addProjectAttachment(attachment);
|
|
4844
4819
|
};
|
|
4845
4820
|
return photoAttachmentPromise(file);
|
|
4846
4821
|
});
|
|
@@ -5020,9 +4995,9 @@ var __publicField = (obj, key, value) => {
|
|
|
5020
4995
|
const promise = performRequest2();
|
|
5021
4996
|
return [offlineAttachment, promise];
|
|
5022
4997
|
}
|
|
5023
|
-
async
|
|
4998
|
+
async replaceProjectAttachmentFile(attachmentId, newFile) {
|
|
5024
4999
|
const { store } = this.client;
|
|
5025
|
-
const attachment = store.getState().
|
|
5000
|
+
const attachment = store.getState().projectReducer.attachments[attachmentId];
|
|
5026
5001
|
if (!attachment)
|
|
5027
5002
|
throw new Error(`Attachment ${attachmentId} not found`);
|
|
5028
5003
|
let oldFile = void 0;
|
|
@@ -5036,7 +5011,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5036
5011
|
throw new Error(`newFile["objectURL"] is unexpectedly ${newFile.objectURL}`);
|
|
5037
5012
|
}
|
|
5038
5013
|
store.dispatch(
|
|
5039
|
-
|
|
5014
|
+
updateProjectAttachment({
|
|
5040
5015
|
...attachment,
|
|
5041
5016
|
file_sha1: newSha1,
|
|
5042
5017
|
file: URL.createObjectURL(newFile)
|
|
@@ -5044,13 +5019,13 @@ var __publicField = (obj, key, value) => {
|
|
|
5044
5019
|
);
|
|
5045
5020
|
await this.client.files.addCache(newFile, newSha1);
|
|
5046
5021
|
const [fileProps] = await this.client.files.uploadFileToS3(newSha1).catch((e) => {
|
|
5047
|
-
store.dispatch(
|
|
5022
|
+
store.dispatch(updateProjectAttachment(attachment));
|
|
5048
5023
|
throw e;
|
|
5049
5024
|
});
|
|
5050
5025
|
const promise2 = this.enqueueRequest({
|
|
5051
5026
|
description: "Edit attachment",
|
|
5052
5027
|
method: HttpMethod.PATCH,
|
|
5053
|
-
url: `/attachments/
|
|
5028
|
+
url: `/attachments/projects/${attachment.offline_id}/`,
|
|
5054
5029
|
isResponseBlob: false,
|
|
5055
5030
|
payload: fileProps,
|
|
5056
5031
|
blockers: [attachmentId, newSha1],
|
|
@@ -5063,7 +5038,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5063
5038
|
} catch (e) {
|
|
5064
5039
|
if (oldFile) {
|
|
5065
5040
|
store.dispatch(
|
|
5066
|
-
|
|
5041
|
+
updateProjectAttachment({
|
|
5067
5042
|
...attachment,
|
|
5068
5043
|
file_sha1: attachment.file_sha1,
|
|
5069
5044
|
file: URL.createObjectURL(oldFile)
|
|
@@ -5133,20 +5108,20 @@ var __publicField = (obj, key, value) => {
|
|
|
5133
5108
|
blocks: [componentTypeAttachmentId]
|
|
5134
5109
|
});
|
|
5135
5110
|
}
|
|
5136
|
-
|
|
5111
|
+
deleteProjectAttachment(projectAttachmentId) {
|
|
5137
5112
|
const { store } = this.client;
|
|
5138
|
-
const attachment = store.getState()
|
|
5113
|
+
const attachment = selectProjectAttachmentMapping(store.getState())[projectAttachmentId];
|
|
5139
5114
|
if (!attachment) {
|
|
5140
|
-
throw new Error(`Attachment ${
|
|
5115
|
+
throw new Error(`Attachment ${projectAttachmentId} not found`);
|
|
5141
5116
|
}
|
|
5142
|
-
store.dispatch(
|
|
5117
|
+
store.dispatch(removeProjectAttachment(projectAttachmentId));
|
|
5143
5118
|
void this.client.files.removeCache(attachment.file_sha1);
|
|
5144
5119
|
return this.enqueueRequest({
|
|
5145
|
-
description: "Delete
|
|
5120
|
+
description: "Delete attachment",
|
|
5146
5121
|
method: HttpMethod.DELETE,
|
|
5147
|
-
url: `/attachments/
|
|
5148
|
-
blockers: [
|
|
5149
|
-
blocks: [
|
|
5122
|
+
url: `/attachments/projects/${projectAttachmentId}/`,
|
|
5123
|
+
blockers: [projectAttachmentId],
|
|
5124
|
+
blocks: [projectAttachmentId]
|
|
5150
5125
|
});
|
|
5151
5126
|
}
|
|
5152
5127
|
}
|
|
@@ -5176,24 +5151,23 @@ var __publicField = (obj, key, value) => {
|
|
|
5176
5151
|
*/
|
|
5177
5152
|
__publicField(this, "_getTokenPair", (credentials, logoutOnFailure = true) => {
|
|
5178
5153
|
const uuid$1 = uuid.v4();
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
return [responsePromise.then(parseTokens), uuid$1];
|
|
5191
|
-
} 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) => {
|
|
5192
5165
|
if (logoutOnFailure) {
|
|
5193
5166
|
void this.logout().then();
|
|
5194
5167
|
}
|
|
5195
5168
|
throw e;
|
|
5196
|
-
}
|
|
5169
|
+
});
|
|
5170
|
+
return [responsePromise, uuid$1];
|
|
5197
5171
|
});
|
|
5198
5172
|
/**
|
|
5199
5173
|
* Takes refresh token and gets a new token pair
|
|
@@ -5254,7 +5228,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5254
5228
|
timedOut = true;
|
|
5255
5229
|
store.dispatch(markForDeletion(uuid$1));
|
|
5256
5230
|
store.dispatch(markForDeletion(initialDataUuid));
|
|
5257
|
-
reject(new
|
|
5231
|
+
reject(new APIError({ message: `Request timed out after ${timeout} seconds` }));
|
|
5258
5232
|
}, timeout * 1e3);
|
|
5259
5233
|
});
|
|
5260
5234
|
const successPromise = promise.then((tokens) => {
|
|
@@ -6384,18 +6358,11 @@ var __publicField = (obj, key, value) => {
|
|
|
6384
6358
|
if (currentProjectId) {
|
|
6385
6359
|
const [_offlineAttachments, promise] = this.client.attachments.fetchAll(currentProjectId);
|
|
6386
6360
|
void promise.then((result) => {
|
|
6387
|
-
const {
|
|
6388
|
-
issue_attachments,
|
|
6389
|
-
component_type_attachments,
|
|
6390
|
-
component_attachments,
|
|
6391
|
-
project_attachments,
|
|
6392
|
-
document_attachments
|
|
6393
|
-
} = result;
|
|
6361
|
+
const { issue_attachments, component_type_attachments, component_attachments, project_attachments } = result;
|
|
6394
6362
|
store.dispatch(setIssueAttachments(issue_attachments));
|
|
6395
6363
|
store.dispatch(setComponentAttachments(component_attachments));
|
|
6396
6364
|
store.dispatch(setComponentTypeAttachments(component_type_attachments));
|
|
6397
6365
|
store.dispatch(setProjectAttachments(project_attachments));
|
|
6398
|
-
store.dispatch(setDocumentAttachments(document_attachments));
|
|
6399
6366
|
});
|
|
6400
6367
|
void this.client.documents.refreshStore();
|
|
6401
6368
|
void this.client.issueUpdates.refreshStore();
|
|
@@ -7230,8 +7197,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7230
7197
|
blockers: [],
|
|
7231
7198
|
blocks: []
|
|
7232
7199
|
});
|
|
7233
|
-
|
|
7234
|
-
store.dispatch(setOrganizationAccesses(organizationAccesses));
|
|
7200
|
+
store.dispatch(setOrganizationAccesses(result));
|
|
7235
7201
|
}
|
|
7236
7202
|
}
|
|
7237
7203
|
const cachedRequestPromises = {};
|
|
@@ -15655,8 +15621,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15655
15621
|
exports2.addComponentTypeAttachment = addComponentTypeAttachment;
|
|
15656
15622
|
exports2.addComponentTypeAttachments = addComponentTypeAttachments;
|
|
15657
15623
|
exports2.addComponentsInBatches = addComponentsInBatches;
|
|
15658
|
-
exports2.addDocumentAttachment = addDocumentAttachment;
|
|
15659
|
-
exports2.addDocumentAttachments = addDocumentAttachments;
|
|
15660
15624
|
exports2.addDocuments = addDocuments;
|
|
15661
15625
|
exports2.addEmailDomain = addEmailDomain;
|
|
15662
15626
|
exports2.addFavouriteProjectId = addFavouriteProjectId;
|
|
@@ -15820,8 +15784,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15820
15784
|
exports2.removeComponentAttachments = removeComponentAttachments;
|
|
15821
15785
|
exports2.removeComponentTypeAttachment = removeComponentTypeAttachment;
|
|
15822
15786
|
exports2.removeComponentTypeAttachments = removeComponentTypeAttachments;
|
|
15823
|
-
exports2.removeDocumentAttachment = removeDocumentAttachment;
|
|
15824
|
-
exports2.removeDocumentAttachments = removeDocumentAttachments;
|
|
15825
15787
|
exports2.removeDocuments = removeDocuments;
|
|
15826
15788
|
exports2.removeEmailDomain = removeEmailDomain;
|
|
15827
15789
|
exports2.removeFavouriteProjectId = removeFavouriteProjectId;
|
|
@@ -15869,7 +15831,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15869
15831
|
exports2.selectAllAttachments = selectAllAttachments;
|
|
15870
15832
|
exports2.selectAllComponentAttachments = selectAllComponentAttachments;
|
|
15871
15833
|
exports2.selectAllComponentTypeAttachments = selectAllComponentTypeAttachments;
|
|
15872
|
-
exports2.selectAllDocumentAttachments = selectAllDocumentAttachments;
|
|
15873
15834
|
exports2.selectAllProjectAttachments = selectAllProjectAttachments;
|
|
15874
15835
|
exports2.selectAncestorIdsOfDocument = selectAncestorIdsOfDocument;
|
|
15875
15836
|
exports2.selectAppearance = selectAppearance;
|
|
@@ -15877,8 +15838,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15877
15838
|
exports2.selectAttachmentsOfComponentByType = selectAttachmentsOfComponentByType;
|
|
15878
15839
|
exports2.selectAttachmentsOfComponentType = selectAttachmentsOfComponentType;
|
|
15879
15840
|
exports2.selectAttachmentsOfComponentTypeByType = selectAttachmentsOfComponentTypeByType;
|
|
15880
|
-
exports2.selectAttachmentsOfDocument = selectAttachmentsOfDocument;
|
|
15881
|
-
exports2.selectAttachmentsOfDocumentByType = selectAttachmentsOfDocumentByType;
|
|
15882
15841
|
exports2.selectAttachmentsOfIssue = selectAttachmentsOfIssue;
|
|
15883
15842
|
exports2.selectAttachmentsOfIssueByType = selectAttachmentsOfIssueByType;
|
|
15884
15843
|
exports2.selectAttachmentsOfProject = selectAttachmentsOfProject;
|
|
@@ -15894,11 +15853,9 @@ var __publicField = (obj, key, value) => {
|
|
|
15894
15853
|
exports2.selectCompletedStageIdsForComponent = selectCompletedStageIdsForComponent;
|
|
15895
15854
|
exports2.selectCompletedStages = selectCompletedStages;
|
|
15896
15855
|
exports2.selectComponent = selectComponent;
|
|
15897
|
-
exports2.selectComponentAttachment = selectComponentAttachment;
|
|
15898
15856
|
exports2.selectComponentAttachmentMapping = selectComponentAttachmentMapping;
|
|
15899
15857
|
exports2.selectComponentSubmissionMapping = selectComponentSubmissionMapping;
|
|
15900
15858
|
exports2.selectComponentType = selectComponentType;
|
|
15901
|
-
exports2.selectComponentTypeAttachment = selectComponentTypeAttachment;
|
|
15902
15859
|
exports2.selectComponentTypeAttachmentMapping = selectComponentTypeAttachmentMapping;
|
|
15903
15860
|
exports2.selectComponentTypeForm = selectComponentTypeForm;
|
|
15904
15861
|
exports2.selectComponentTypeFromComponent = selectComponentTypeFromComponent;
|
|
@@ -15916,8 +15873,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15916
15873
|
exports2.selectCurrentUser = selectCurrentUser;
|
|
15917
15874
|
exports2.selectDeletedRequests = selectDeletedRequests;
|
|
15918
15875
|
exports2.selectDocument = selectDocument;
|
|
15919
|
-
exports2.selectDocumentAttachment = selectDocumentAttachment;
|
|
15920
|
-
exports2.selectDocumentAttachmentMapping = selectDocumentAttachmentMapping;
|
|
15921
15876
|
exports2.selectDocuments = selectDocuments;
|
|
15922
15877
|
exports2.selectDocumentsMapping = selectDocumentsMapping;
|
|
15923
15878
|
exports2.selectEmailDomainsAsMapping = selectEmailDomainsAsMapping;
|
|
@@ -15939,7 +15894,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15939
15894
|
exports2.selectIsLoading = selectIsLoading;
|
|
15940
15895
|
exports2.selectIsLoggedIn = selectIsLoggedIn;
|
|
15941
15896
|
exports2.selectIssue = selectIssue;
|
|
15942
|
-
exports2.selectIssueAttachment = selectIssueAttachment;
|
|
15943
15897
|
exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
|
|
15944
15898
|
exports2.selectIssueAttachments = selectIssueAttachments;
|
|
15945
15899
|
exports2.selectIssueMapping = selectIssueMapping;
|
|
@@ -16033,7 +15987,6 @@ var __publicField = (obj, key, value) => {
|
|
|
16033
15987
|
exports2.setComponents = setComponents;
|
|
16034
15988
|
exports2.setCreateProjectType = setCreateProjectType;
|
|
16035
15989
|
exports2.setCurrentUser = setCurrentUser;
|
|
16036
|
-
exports2.setDocumentAttachments = setDocumentAttachments;
|
|
16037
15990
|
exports2.setDocuments = setDocuments;
|
|
16038
15991
|
exports2.setEmailDomains = setEmailDomains;
|
|
16039
15992
|
exports2.setEnableClustering = setEnableClustering;
|
|
@@ -16088,7 +16041,6 @@ var __publicField = (obj, key, value) => {
|
|
|
16088
16041
|
exports2.updateComponent = updateComponent;
|
|
16089
16042
|
exports2.updateComponentAttachment = updateComponentAttachment;
|
|
16090
16043
|
exports2.updateComponentTypeAttachment = updateComponentTypeAttachment;
|
|
16091
|
-
exports2.updateDocumentAttachment = updateDocumentAttachment;
|
|
16092
16044
|
exports2.updateDocuments = updateDocuments;
|
|
16093
16045
|
exports2.updateIssue = updateIssue;
|
|
16094
16046
|
exports2.updateIssueAttachment = updateIssueAttachment;
|