@overmap-ai/core 1.0.50-fix-error-messaging.0 → 1.0.51-add-submitted-at-to-form-revisions.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.
@@ -1552,6 +1552,7 @@ var __publicField = (obj, key, value) => {
1552
1552
  };
1553
1553
  const categoryReducer = categorySlice.reducer;
1554
1554
  function setAttachments(state, action) {
1555
+ state.attachments = {};
1555
1556
  for (const attachment of action.payload) {
1556
1557
  state.attachments[attachment.offline_id] = attachment;
1557
1558
  }
@@ -1706,6 +1707,9 @@ var __publicField = (obj, key, value) => {
1706
1707
  [selectComponentAttachmentMapping],
1707
1708
  (mapping) => Object.values(mapping)
1708
1709
  );
1710
+ const selectComponentAttachment = (attachmentId) => (state) => {
1711
+ return state.componentReducer.attachments[attachmentId];
1712
+ };
1709
1713
  const selectAttachmentsOfComponent = restructureCreateSelectorWithArgs(
1710
1714
  toolkit.createSelector(
1711
1715
  [selectAllComponentAttachments, (_state, componentId) => componentId],
@@ -1995,6 +1999,9 @@ var __publicField = (obj, key, value) => {
1995
1999
  [selectComponentTypeAttachmentMapping],
1996
2000
  (mapping) => Object.values(mapping)
1997
2001
  );
2002
+ const selectComponentTypeAttachment = (attachmentId) => (state) => {
2003
+ return state.componentTypeReducer.attachments[attachmentId];
2004
+ };
1998
2005
  const selectAttachmentsOfComponentType = restructureCreateSelectorWithArgs(
1999
2006
  toolkit.createSelector(
2000
2007
  [selectAllComponentTypeAttachments, (_state, componentTypeId) => componentTypeId],
@@ -2389,6 +2396,9 @@ var __publicField = (obj, key, value) => {
2389
2396
  }
2390
2397
  )
2391
2398
  );
2399
+ const selectIssueAttachment = (attachmentId) => (root) => {
2400
+ return root.issueReducer.attachments[attachmentId];
2401
+ };
2392
2402
  const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
2393
2403
  toolkit.createSelector(
2394
2404
  [selectIssueAttachments, (_state, issueId) => issueId],
@@ -3843,7 +3853,8 @@ var __publicField = (obj, key, value) => {
3843
3853
  );
3844
3854
  const emailDomainsReducer = emailDomainsSlice.reducer;
3845
3855
  const initialState$1 = {
3846
- documents: {}
3856
+ documents: {},
3857
+ attachments: {}
3847
3858
  };
3848
3859
  const documentSlice = toolkit.createSlice({
3849
3860
  name: "documents",
@@ -3980,10 +3991,28 @@ var __publicField = (obj, key, value) => {
3980
3991
  }
3981
3992
  delete state.documents[documentId];
3982
3993
  }
3983
- }
3994
+ },
3995
+ setDocumentAttachments: setAttachments,
3996
+ addDocumentAttachment: addAttachment,
3997
+ addDocumentAttachments: addAttachments,
3998
+ updateDocumentAttachment: updateAttachment,
3999
+ removeDocumentAttachment: removeAttachment,
4000
+ removeDocumentAttachments: removeAttachments
3984
4001
  }
3985
4002
  });
3986
- const { setDocuments, addDocuments, updateDocuments, moveDocument, removeDocuments } = documentSlice.actions;
4003
+ const {
4004
+ setDocuments,
4005
+ addDocuments,
4006
+ updateDocuments,
4007
+ moveDocument,
4008
+ removeDocuments,
4009
+ setDocumentAttachments,
4010
+ addDocumentAttachment,
4011
+ addDocumentAttachments,
4012
+ updateDocumentAttachment,
4013
+ removeDocumentAttachment,
4014
+ removeDocumentAttachments
4015
+ } = documentSlice.actions;
3987
4016
  const selectDocumentsMapping = (state) => state.documentsReducer.documents;
3988
4017
  const selectDocuments = toolkit.createSelector(
3989
4018
  [selectDocumentsMapping],
@@ -4013,6 +4042,39 @@ var __publicField = (obj, key, value) => {
4013
4042
  [selectDocuments],
4014
4043
  (documents) => documents.filter((document2) => !document2.parent_document)
4015
4044
  );
4045
+ const selectDocumentAttachmentMapping = (state) => state.documentsReducer.attachments;
4046
+ const selectAllDocumentAttachments = toolkit.createSelector(
4047
+ [selectDocumentAttachmentMapping],
4048
+ (mapping) => Object.values(mapping)
4049
+ );
4050
+ const selectDocumentAttachment = (attachmentId) => (state) => {
4051
+ return state.documentsReducer.attachments[attachmentId];
4052
+ };
4053
+ const selectAttachmentsOfDocument = restructureCreateSelectorWithArgs(
4054
+ toolkit.createSelector(
4055
+ [selectAllDocumentAttachments, (_state, documentId) => documentId],
4056
+ (attachments, documentId) => {
4057
+ return attachments.filter(({ document: document2 }) => documentId === document2);
4058
+ }
4059
+ )
4060
+ );
4061
+ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
4062
+ toolkit.createSelector(
4063
+ [selectAllDocumentAttachments, (_state, documentId) => documentId],
4064
+ (attachments, documentId) => {
4065
+ const attachmentsOfProject = attachments.filter(({ document: document2 }) => documentId === document2);
4066
+ const fileAttachments = attachmentsOfProject.filter(
4067
+ // this null check here is necessary, there are cases where file_type is null or undefined
4068
+ ({ file_type }) => !file_type || !file_type.startsWith("image/")
4069
+ );
4070
+ const imageAttachments = attachmentsOfProject.filter(
4071
+ // this null check here is necessary, there are cases where file_type is null or undefined
4072
+ ({ file_type }) => file_type && file_type.startsWith("image/")
4073
+ );
4074
+ return { fileAttachments, imageAttachments };
4075
+ }
4076
+ )
4077
+ );
4016
4078
  const documentsReducer = documentSlice.reducer;
4017
4079
  const initialState = {
4018
4080
  version: 0
@@ -4593,7 +4655,8 @@ var __publicField = (obj, key, value) => {
4593
4655
  issue_attachments: Object.values(state.issueReducer.attachments),
4594
4656
  component_attachments: Object.values(state.componentReducer.attachments),
4595
4657
  component_type_attachments: Object.values(state.componentTypeReducer.attachments),
4596
- project_attachments: Object.values(state.projectReducer.attachments)
4658
+ project_attachments: Object.values(state.projectReducer.attachments),
4659
+ document_attachments: Object.values(state.documentsReducer.attachments)
4597
4660
  };
4598
4661
  return [allAttachments, promise];
4599
4662
  }
@@ -4697,8 +4760,8 @@ var __publicField = (obj, key, value) => {
4697
4760
  });
4698
4761
  return [offlineAttachment, promise];
4699
4762
  }
4700
- async addProjectAttachment(attachmentPayload) {
4701
- const { description: description2, project, file_sha1, offline_id } = attachmentPayload;
4763
+ async addDocumentAttachment(attachmentPayload) {
4764
+ const { description: description2, document: document2, file_sha1, offline_id } = attachmentPayload;
4702
4765
  if (!attachmentPayload.file.objectURL) {
4703
4766
  throw new Error("Expected attachmentPayload.file.objectURL to be defined.");
4704
4767
  }
@@ -4711,24 +4774,24 @@ var __publicField = (obj, key, value) => {
4711
4774
  created_by: this.client.store.getState().userReducer.currentUser.id
4712
4775
  };
4713
4776
  await this.client.files.addCache(attachmentPayload.file, file_sha1);
4714
- this.client.store.dispatch(addProjectAttachment(offlineAttachment));
4777
+ this.client.store.dispatch(addDocumentAttachment(offlineAttachment));
4715
4778
  const [fileProps] = await this.client.files.uploadFileToS3(file_sha1);
4716
4779
  const promise = this.enqueueRequest({
4717
4780
  description: "Create attachment",
4718
4781
  method: HttpMethod.POST,
4719
- url: `/projects/${project}/attach/`,
4720
- blocks: [offline_id, project.toString()],
4782
+ url: `/documents/${document2}/attach/`,
4783
+ blocks: [offline_id, document2],
4721
4784
  blockers: [file_sha1],
4722
4785
  payload: {
4723
4786
  offline_id,
4724
- project,
4787
+ document: document2,
4725
4788
  description: description2 ?? "",
4726
4789
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
4727
4790
  ...fileProps
4728
4791
  }
4729
4792
  });
4730
4793
  promise.catch((error2) => {
4731
- this.client.store.dispatch(removeProjectAttachment(offlineAttachment.offline_id));
4794
+ this.client.store.dispatch(removeDocumentAttachment(offlineAttachment.offline_id));
4732
4795
  throw error2;
4733
4796
  });
4734
4797
  return [offlineAttachment, promise];
@@ -4799,7 +4862,7 @@ var __publicField = (obj, key, value) => {
4799
4862
  return photoAttachmentPromise(file);
4800
4863
  });
4801
4864
  }
4802
- attachFilesToProject(filesToSubmit, projectId) {
4865
+ attachFilesToDocument(filesToSubmit, documentId) {
4803
4866
  return filesToSubmit.map((file) => {
4804
4867
  if (!(file instanceof File)) {
4805
4868
  throw new Error("Expected a File instance.");
@@ -4810,12 +4873,12 @@ var __publicField = (obj, key, value) => {
4810
4873
  file: file2,
4811
4874
  file_name: file2.name,
4812
4875
  file_type: file2.type,
4813
- project: projectId,
4876
+ document: documentId,
4814
4877
  file_sha1: hash,
4815
4878
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
4816
4879
  created_by: this.client.store.getState().userReducer.currentUser.id
4817
4880
  });
4818
- return this.addProjectAttachment(attachment);
4881
+ return this.addDocumentAttachment(attachment);
4819
4882
  };
4820
4883
  return photoAttachmentPromise(file);
4821
4884
  });
@@ -4995,9 +5058,9 @@ var __publicField = (obj, key, value) => {
4995
5058
  const promise = performRequest2();
4996
5059
  return [offlineAttachment, promise];
4997
5060
  }
4998
- async replaceProjectAttachmentFile(attachmentId, newFile) {
5061
+ async replaceDocumentAttachmentFile(attachmentId, newFile) {
4999
5062
  const { store } = this.client;
5000
- const attachment = store.getState().projectReducer.attachments[attachmentId];
5063
+ const attachment = store.getState().documentsReducer.attachments[attachmentId];
5001
5064
  if (!attachment)
5002
5065
  throw new Error(`Attachment ${attachmentId} not found`);
5003
5066
  let oldFile = void 0;
@@ -5011,7 +5074,7 @@ var __publicField = (obj, key, value) => {
5011
5074
  throw new Error(`newFile["objectURL"] is unexpectedly ${newFile.objectURL}`);
5012
5075
  }
5013
5076
  store.dispatch(
5014
- updateProjectAttachment({
5077
+ updateDocumentAttachment({
5015
5078
  ...attachment,
5016
5079
  file_sha1: newSha1,
5017
5080
  file: URL.createObjectURL(newFile)
@@ -5019,13 +5082,13 @@ var __publicField = (obj, key, value) => {
5019
5082
  );
5020
5083
  await this.client.files.addCache(newFile, newSha1);
5021
5084
  const [fileProps] = await this.client.files.uploadFileToS3(newSha1).catch((e) => {
5022
- store.dispatch(updateProjectAttachment(attachment));
5085
+ store.dispatch(updateDocumentAttachment(attachment));
5023
5086
  throw e;
5024
5087
  });
5025
5088
  const promise2 = this.enqueueRequest({
5026
5089
  description: "Edit attachment",
5027
5090
  method: HttpMethod.PATCH,
5028
- url: `/attachments/projects/${attachment.offline_id}/`,
5091
+ url: `/attachments/documents/${attachment.offline_id}/`,
5029
5092
  isResponseBlob: false,
5030
5093
  payload: fileProps,
5031
5094
  blockers: [attachmentId, newSha1],
@@ -5038,7 +5101,7 @@ var __publicField = (obj, key, value) => {
5038
5101
  } catch (e) {
5039
5102
  if (oldFile) {
5040
5103
  store.dispatch(
5041
- updateProjectAttachment({
5104
+ updateDocumentAttachment({
5042
5105
  ...attachment,
5043
5106
  file_sha1: attachment.file_sha1,
5044
5107
  file: URL.createObjectURL(oldFile)
@@ -5108,20 +5171,20 @@ var __publicField = (obj, key, value) => {
5108
5171
  blocks: [componentTypeAttachmentId]
5109
5172
  });
5110
5173
  }
5111
- deleteProjectAttachment(projectAttachmentId) {
5174
+ deleteDocumentAttachment(documentAttachmentId) {
5112
5175
  const { store } = this.client;
5113
- const attachment = selectProjectAttachmentMapping(store.getState())[projectAttachmentId];
5176
+ const attachment = store.getState().documentsReducer.attachments[documentAttachmentId];
5114
5177
  if (!attachment) {
5115
- throw new Error(`Attachment ${projectAttachmentId} not found`);
5178
+ throw new Error(`Attachment ${documentAttachmentId} not found`);
5116
5179
  }
5117
- store.dispatch(removeProjectAttachment(projectAttachmentId));
5180
+ store.dispatch(removeDocumentAttachment(documentAttachmentId));
5118
5181
  void this.client.files.removeCache(attachment.file_sha1);
5119
5182
  return this.enqueueRequest({
5120
- description: "Delete attachment",
5183
+ description: "Delete document attachment",
5121
5184
  method: HttpMethod.DELETE,
5122
- url: `/attachments/projects/${projectAttachmentId}/`,
5123
- blockers: [projectAttachmentId],
5124
- blocks: [projectAttachmentId]
5185
+ url: `/attachments/documents/${documentAttachmentId}/`,
5186
+ blockers: [documentAttachmentId],
5187
+ blocks: [documentAttachmentId]
5125
5188
  });
5126
5189
  }
5127
5190
  }
@@ -6358,11 +6421,18 @@ var __publicField = (obj, key, value) => {
6358
6421
  if (currentProjectId) {
6359
6422
  const [_offlineAttachments, promise] = this.client.attachments.fetchAll(currentProjectId);
6360
6423
  void promise.then((result) => {
6361
- const { issue_attachments, component_type_attachments, component_attachments, project_attachments } = result;
6424
+ const {
6425
+ issue_attachments,
6426
+ component_type_attachments,
6427
+ component_attachments,
6428
+ project_attachments,
6429
+ document_attachments
6430
+ } = result;
6362
6431
  store.dispatch(setIssueAttachments(issue_attachments));
6363
6432
  store.dispatch(setComponentAttachments(component_attachments));
6364
6433
  store.dispatch(setComponentTypeAttachments(component_type_attachments));
6365
6434
  store.dispatch(setProjectAttachments(project_attachments));
6435
+ store.dispatch(setDocumentAttachments(document_attachments));
6366
6436
  });
6367
6437
  void this.client.documents.refreshStore();
6368
6438
  void this.client.issueUpdates.refreshStore();
@@ -6761,7 +6831,8 @@ var __publicField = (obj, key, value) => {
6761
6831
  ...payloadWithoutImage,
6762
6832
  created_by: currentUser.id,
6763
6833
  form: retForm.offline_id,
6764
- revision: 0
6834
+ revision: 0,
6835
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
6765
6836
  };
6766
6837
  const { store } = this.client;
6767
6838
  store.dispatch(addUserForm(retForm));
@@ -6824,7 +6895,8 @@ var __publicField = (obj, key, value) => {
6824
6895
  ...payloadWithoutImage,
6825
6896
  created_by: currentUserId,
6826
6897
  revision: "Pending",
6827
- form: formId2
6898
+ form: formId2,
6899
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
6828
6900
  };
6829
6901
  store.dispatch(addUserFormRevision(fullRevision));
6830
6902
  const promise = this.enqueueRequest({
@@ -15621,6 +15693,8 @@ var __publicField = (obj, key, value) => {
15621
15693
  exports2.addComponentTypeAttachment = addComponentTypeAttachment;
15622
15694
  exports2.addComponentTypeAttachments = addComponentTypeAttachments;
15623
15695
  exports2.addComponentsInBatches = addComponentsInBatches;
15696
+ exports2.addDocumentAttachment = addDocumentAttachment;
15697
+ exports2.addDocumentAttachments = addDocumentAttachments;
15624
15698
  exports2.addDocuments = addDocuments;
15625
15699
  exports2.addEmailDomain = addEmailDomain;
15626
15700
  exports2.addFavouriteProjectId = addFavouriteProjectId;
@@ -15784,6 +15858,8 @@ var __publicField = (obj, key, value) => {
15784
15858
  exports2.removeComponentAttachments = removeComponentAttachments;
15785
15859
  exports2.removeComponentTypeAttachment = removeComponentTypeAttachment;
15786
15860
  exports2.removeComponentTypeAttachments = removeComponentTypeAttachments;
15861
+ exports2.removeDocumentAttachment = removeDocumentAttachment;
15862
+ exports2.removeDocumentAttachments = removeDocumentAttachments;
15787
15863
  exports2.removeDocuments = removeDocuments;
15788
15864
  exports2.removeEmailDomain = removeEmailDomain;
15789
15865
  exports2.removeFavouriteProjectId = removeFavouriteProjectId;
@@ -15831,6 +15907,7 @@ var __publicField = (obj, key, value) => {
15831
15907
  exports2.selectAllAttachments = selectAllAttachments;
15832
15908
  exports2.selectAllComponentAttachments = selectAllComponentAttachments;
15833
15909
  exports2.selectAllComponentTypeAttachments = selectAllComponentTypeAttachments;
15910
+ exports2.selectAllDocumentAttachments = selectAllDocumentAttachments;
15834
15911
  exports2.selectAllProjectAttachments = selectAllProjectAttachments;
15835
15912
  exports2.selectAncestorIdsOfDocument = selectAncestorIdsOfDocument;
15836
15913
  exports2.selectAppearance = selectAppearance;
@@ -15838,6 +15915,8 @@ var __publicField = (obj, key, value) => {
15838
15915
  exports2.selectAttachmentsOfComponentByType = selectAttachmentsOfComponentByType;
15839
15916
  exports2.selectAttachmentsOfComponentType = selectAttachmentsOfComponentType;
15840
15917
  exports2.selectAttachmentsOfComponentTypeByType = selectAttachmentsOfComponentTypeByType;
15918
+ exports2.selectAttachmentsOfDocument = selectAttachmentsOfDocument;
15919
+ exports2.selectAttachmentsOfDocumentByType = selectAttachmentsOfDocumentByType;
15841
15920
  exports2.selectAttachmentsOfIssue = selectAttachmentsOfIssue;
15842
15921
  exports2.selectAttachmentsOfIssueByType = selectAttachmentsOfIssueByType;
15843
15922
  exports2.selectAttachmentsOfProject = selectAttachmentsOfProject;
@@ -15853,9 +15932,11 @@ var __publicField = (obj, key, value) => {
15853
15932
  exports2.selectCompletedStageIdsForComponent = selectCompletedStageIdsForComponent;
15854
15933
  exports2.selectCompletedStages = selectCompletedStages;
15855
15934
  exports2.selectComponent = selectComponent;
15935
+ exports2.selectComponentAttachment = selectComponentAttachment;
15856
15936
  exports2.selectComponentAttachmentMapping = selectComponentAttachmentMapping;
15857
15937
  exports2.selectComponentSubmissionMapping = selectComponentSubmissionMapping;
15858
15938
  exports2.selectComponentType = selectComponentType;
15939
+ exports2.selectComponentTypeAttachment = selectComponentTypeAttachment;
15859
15940
  exports2.selectComponentTypeAttachmentMapping = selectComponentTypeAttachmentMapping;
15860
15941
  exports2.selectComponentTypeForm = selectComponentTypeForm;
15861
15942
  exports2.selectComponentTypeFromComponent = selectComponentTypeFromComponent;
@@ -15873,6 +15954,8 @@ var __publicField = (obj, key, value) => {
15873
15954
  exports2.selectCurrentUser = selectCurrentUser;
15874
15955
  exports2.selectDeletedRequests = selectDeletedRequests;
15875
15956
  exports2.selectDocument = selectDocument;
15957
+ exports2.selectDocumentAttachment = selectDocumentAttachment;
15958
+ exports2.selectDocumentAttachmentMapping = selectDocumentAttachmentMapping;
15876
15959
  exports2.selectDocuments = selectDocuments;
15877
15960
  exports2.selectDocumentsMapping = selectDocumentsMapping;
15878
15961
  exports2.selectEmailDomainsAsMapping = selectEmailDomainsAsMapping;
@@ -15894,6 +15977,7 @@ var __publicField = (obj, key, value) => {
15894
15977
  exports2.selectIsLoading = selectIsLoading;
15895
15978
  exports2.selectIsLoggedIn = selectIsLoggedIn;
15896
15979
  exports2.selectIssue = selectIssue;
15980
+ exports2.selectIssueAttachment = selectIssueAttachment;
15897
15981
  exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
15898
15982
  exports2.selectIssueAttachments = selectIssueAttachments;
15899
15983
  exports2.selectIssueMapping = selectIssueMapping;
@@ -15987,6 +16071,7 @@ var __publicField = (obj, key, value) => {
15987
16071
  exports2.setComponents = setComponents;
15988
16072
  exports2.setCreateProjectType = setCreateProjectType;
15989
16073
  exports2.setCurrentUser = setCurrentUser;
16074
+ exports2.setDocumentAttachments = setDocumentAttachments;
15990
16075
  exports2.setDocuments = setDocuments;
15991
16076
  exports2.setEmailDomains = setEmailDomains;
15992
16077
  exports2.setEnableClustering = setEnableClustering;
@@ -16041,6 +16126,7 @@ var __publicField = (obj, key, value) => {
16041
16126
  exports2.updateComponent = updateComponent;
16042
16127
  exports2.updateComponentAttachment = updateComponentAttachment;
16043
16128
  exports2.updateComponentTypeAttachment = updateComponentTypeAttachment;
16129
+ exports2.updateDocumentAttachment = updateDocumentAttachment;
16044
16130
  exports2.updateDocuments = updateDocuments;
16045
16131
  exports2.updateIssue = updateIssue;
16046
16132
  exports2.updateIssueAttachment = updateIssueAttachment;