@overmap-ai/core 1.0.50-bulk-form-submission.1 → 1.0.50-bulk-form-submission.3
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.
|
@@ -1542,15 +1542,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1542
1542
|
throw new Error(`Attachment ${action.payload.offline_id} does not exist.`);
|
|
1543
1543
|
}
|
|
1544
1544
|
}
|
|
1545
|
-
function updateAttachments(state, action) {
|
|
1546
|
-
for (const attachment of action.payload) {
|
|
1547
|
-
if (attachment.offline_id in state.attachments) {
|
|
1548
|
-
state.attachments[attachment.offline_id] = attachment;
|
|
1549
|
-
} else {
|
|
1550
|
-
throw new Error(`Attachment ${attachment.offline_id} does not exist.`);
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
1545
|
function removeAttachment(state, action) {
|
|
1555
1546
|
if (action.payload in state.attachments) {
|
|
1556
1547
|
delete state.attachments[action.payload];
|
|
@@ -2150,7 +2141,6 @@ var __publicField = (obj, key, value) => {
|
|
|
2150
2141
|
}
|
|
2151
2142
|
},
|
|
2152
2143
|
updateIssueAttachment: updateAttachment,
|
|
2153
|
-
updateIssueAttachments: updateAttachments,
|
|
2154
2144
|
removeIssue: (state, action) => {
|
|
2155
2145
|
if (action.payload in state.issues) {
|
|
2156
2146
|
delete state.issues[action.payload];
|
|
@@ -2159,7 +2149,6 @@ var __publicField = (obj, key, value) => {
|
|
|
2159
2149
|
}
|
|
2160
2150
|
},
|
|
2161
2151
|
removeIssueAttachment: removeAttachment,
|
|
2162
|
-
removeIssueAttachments: removeAttachments,
|
|
2163
2152
|
removeIssueUpdate: (state, action) => {
|
|
2164
2153
|
if (action.payload in state.updates) {
|
|
2165
2154
|
delete state.updates[action.payload];
|
|
@@ -2269,7 +2258,6 @@ var __publicField = (obj, key, value) => {
|
|
|
2269
2258
|
addToRecentIssues,
|
|
2270
2259
|
cleanRecentIssues,
|
|
2271
2260
|
removeIssueAttachment,
|
|
2272
|
-
removeIssueAttachments,
|
|
2273
2261
|
removeAttachmentsOfIssue,
|
|
2274
2262
|
removeIssue,
|
|
2275
2263
|
removeIssueUpdate,
|
|
@@ -2283,7 +2271,6 @@ var __publicField = (obj, key, value) => {
|
|
|
2283
2271
|
setVisibleStatuses,
|
|
2284
2272
|
setVisibleUserIds,
|
|
2285
2273
|
updateIssueAttachment,
|
|
2286
|
-
updateIssueAttachments,
|
|
2287
2274
|
updateIssue,
|
|
2288
2275
|
// Commments
|
|
2289
2276
|
addIssueComment,
|
|
@@ -4796,23 +4783,6 @@ var __publicField = (obj, key, value) => {
|
|
|
4796
4783
|
}
|
|
4797
4784
|
}
|
|
4798
4785
|
class AttachmentService extends BaseApiService {
|
|
4799
|
-
processPresignedUrls(presignedUrls) {
|
|
4800
|
-
for (const [sha1, presignedUrl] of Object.entries(presignedUrls)) {
|
|
4801
|
-
console.debug(sha1, presignedUrl);
|
|
4802
|
-
void this.enqueueRequest({
|
|
4803
|
-
url: presignedUrl.url,
|
|
4804
|
-
description: "Upload file to S3",
|
|
4805
|
-
method: HttpMethod.POST,
|
|
4806
|
-
isExternalUrl: true,
|
|
4807
|
-
isAuthNeeded: false,
|
|
4808
|
-
attachmentHash: sha1,
|
|
4809
|
-
// TODO: can we use the sha1 as the blocker?
|
|
4810
|
-
blockers: [`s3-${sha1}`],
|
|
4811
|
-
blocks: [sha1],
|
|
4812
|
-
s3url: presignedUrl
|
|
4813
|
-
});
|
|
4814
|
-
}
|
|
4815
|
-
}
|
|
4816
4786
|
fetchAll(projectId) {
|
|
4817
4787
|
const promise = this.enqueueRequest({
|
|
4818
4788
|
description: "Fetch attachments",
|
|
@@ -4839,7 +4809,6 @@ var __publicField = (obj, key, value) => {
|
|
|
4839
4809
|
}
|
|
4840
4810
|
const offlineAttachment = {
|
|
4841
4811
|
...attachmentPayload,
|
|
4842
|
-
// TODO: just handle creating the objectURL in here, then the front end doesn't need to worry about it
|
|
4843
4812
|
file: attachmentPayload.file.objectURL,
|
|
4844
4813
|
file_name: attachmentPayload.file.name,
|
|
4845
4814
|
file_type: attachmentPayload.file.type,
|
|
@@ -4873,7 +4842,6 @@ var __publicField = (obj, key, value) => {
|
|
|
4873
4842
|
}
|
|
4874
4843
|
const offlineAttachment = {
|
|
4875
4844
|
...attachmentPayload,
|
|
4876
|
-
// TODO: just handle creating the objectURL in here, then the front end doesn't need to worry about it
|
|
4877
4845
|
file: attachmentPayload.file.objectURL,
|
|
4878
4846
|
file_name: attachmentPayload.file.name,
|
|
4879
4847
|
file_type: attachmentPayload.file.type,
|
|
@@ -4907,7 +4875,6 @@ var __publicField = (obj, key, value) => {
|
|
|
4907
4875
|
}
|
|
4908
4876
|
const offlineAttachment = {
|
|
4909
4877
|
...attachmentPayload,
|
|
4910
|
-
// TODO: just handle creating the objectURL in here, then the front end doesn't need to worry about it
|
|
4911
4878
|
file: attachmentPayload.file.objectURL,
|
|
4912
4879
|
file_name: attachmentPayload.file.name,
|
|
4913
4880
|
file_type: attachmentPayload.file.type,
|
|
@@ -4973,54 +4940,26 @@ var __publicField = (obj, key, value) => {
|
|
|
4973
4940
|
/** the outer Promise is needed to await the hashing of each file, which is required before offline use. If wanting to
|
|
4974
4941
|
* attach promise handlers to the request to add the attachment in the backend, apply it on the promise returned from the
|
|
4975
4942
|
* OptimisticModelResult. */
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
}
|
|
4994
|
-
|
|
4995
|
-
offline_id: attachment.offline_id,
|
|
4996
|
-
name: attachment.file_name,
|
|
4997
|
-
sha1: attachment.file_sha1,
|
|
4998
|
-
description: attachment.description,
|
|
4999
|
-
created_by: attachment.created_by,
|
|
5000
|
-
issue_id: attachment.issue
|
|
5001
|
-
});
|
|
5002
|
-
offlineAttachments.push(attachment);
|
|
5003
|
-
}
|
|
5004
|
-
store.dispatch(addIssueAttachments(offlineAttachments));
|
|
5005
|
-
const promise = this.enqueueRequest({
|
|
5006
|
-
description: "Attach files to issue",
|
|
5007
|
-
method: HttpMethod.POST,
|
|
5008
|
-
url: `/issues/${issueId}/attach/`,
|
|
5009
|
-
payload: {
|
|
5010
|
-
submitted_at: submittedAt,
|
|
5011
|
-
attachments: attachmentsPayload,
|
|
5012
|
-
files: await constructUploadedFilePayloads(files)
|
|
5013
|
-
},
|
|
5014
|
-
blocks: offlineAttachments.map((attachment) => attachment.offline_id),
|
|
5015
|
-
blockers: offlineAttachments.map((attachment) => attachment.file_sha1)
|
|
5016
|
-
});
|
|
5017
|
-
promise.then(({ attachments, presigned_urls }) => {
|
|
5018
|
-
store.dispatch(updateIssueAttachments(attachments));
|
|
5019
|
-
this.processPresignedUrls(presigned_urls);
|
|
5020
|
-
}).catch(() => {
|
|
5021
|
-
store.dispatch(removeIssueAttachments(offlineAttachments.map((attachment) => attachment.offline_id)));
|
|
4943
|
+
attachFilesToIssue(filesToSubmit, issueId) {
|
|
4944
|
+
return filesToSubmit.map((file) => {
|
|
4945
|
+
if (!(file instanceof File)) {
|
|
4946
|
+
throw new Error("Expected a File instance.");
|
|
4947
|
+
}
|
|
4948
|
+
const photoAttachmentPromise = async (file2) => {
|
|
4949
|
+
const hash = await hashFile(file2);
|
|
4950
|
+
const attachment = offline({
|
|
4951
|
+
file: file2,
|
|
4952
|
+
file_name: file2.name,
|
|
4953
|
+
file_type: file2.type,
|
|
4954
|
+
issue: issueId,
|
|
4955
|
+
file_sha1: hash,
|
|
4956
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4957
|
+
created_by: this.client.store.getState().userReducer.currentUser.id
|
|
4958
|
+
});
|
|
4959
|
+
return this.addIssueAttachment(attachment);
|
|
4960
|
+
};
|
|
4961
|
+
return photoAttachmentPromise(file);
|
|
5022
4962
|
});
|
|
5023
|
-
return [offlineAttachments, promise.then(({ attachments }) => attachments)];
|
|
5024
4963
|
}
|
|
5025
4964
|
attachFilesToComponent(filesToSubmit, componentId) {
|
|
5026
4965
|
return filesToSubmit.map((file) => {
|
|
@@ -16166,7 +16105,6 @@ var __publicField = (obj, key, value) => {
|
|
|
16166
16105
|
exports2.removeFavouriteProjectId = removeFavouriteProjectId;
|
|
16167
16106
|
exports2.removeIssue = removeIssue;
|
|
16168
16107
|
exports2.removeIssueAttachment = removeIssueAttachment;
|
|
16169
|
-
exports2.removeIssueAttachments = removeIssueAttachments;
|
|
16170
16108
|
exports2.removeIssueComment = removeIssueComment;
|
|
16171
16109
|
exports2.removeIssueComments = removeIssueComments;
|
|
16172
16110
|
exports2.removeIssueUpdate = removeIssueUpdate;
|
|
@@ -16445,7 +16383,6 @@ var __publicField = (obj, key, value) => {
|
|
|
16445
16383
|
exports2.updateFormSubmissions = updateFormSubmissions;
|
|
16446
16384
|
exports2.updateIssue = updateIssue;
|
|
16447
16385
|
exports2.updateIssueAttachment = updateIssueAttachment;
|
|
16448
|
-
exports2.updateIssueAttachments = updateIssueAttachments;
|
|
16449
16386
|
exports2.updateLicense = updateLicense;
|
|
16450
16387
|
exports2.updateOrCreateProject = updateOrCreateProject;
|
|
16451
16388
|
exports2.updateOrganizationAccess = updateOrganizationAccess;
|