@overmap-ai/core 1.0.71-fields.4 → 1.0.71-fields.6
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/overmap-core.js +56 -103
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +56 -103
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/AssetTypeFieldValuesAttachmentService.d.ts +1 -1
- package/dist/sdk/services/FormService.d.ts +2 -2
- package/dist/store/slices/formRevisionSlice.d.ts +1 -2
- package/dist/store/slices/formSlice.d.ts +1 -3
- package/dist/store/slices/formSubmissionSlice.d.ts +0 -2
- package/package.json +1 -1
|
@@ -2093,17 +2093,6 @@ var __publicField = (obj, key, value) => {
|
|
|
2093
2093
|
}
|
|
2094
2094
|
)
|
|
2095
2095
|
);
|
|
2096
|
-
const selectLatestFormRevisionByForm = toolkit.createSelector([selectFormRevisionMapping], (revisions) => {
|
|
2097
|
-
const latestRevisions = {};
|
|
2098
|
-
for (const revision of Object.values(revisions)) {
|
|
2099
|
-
const formId = revision.form;
|
|
2100
|
-
const currentLatestRevision = latestRevisions[formId];
|
|
2101
|
-
if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
|
|
2102
|
-
latestRevisions[formId] = revision;
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
return latestRevisions;
|
|
2106
|
-
});
|
|
2107
2096
|
const formRevisionReducer = formRevisionsSlice.reducer;
|
|
2108
2097
|
const formAdapter = createModelAdapter((form) => form.offline_id);
|
|
2109
2098
|
const initialState$n = formAdapter.getInitialState({});
|
|
@@ -2128,6 +2117,9 @@ var __publicField = (obj, key, value) => {
|
|
|
2128
2117
|
const selectForms = toolkit.createSelector([selectFormMapping], (formsMapping) => {
|
|
2129
2118
|
return Object.values(formsMapping);
|
|
2130
2119
|
});
|
|
2120
|
+
const selectFormById = (formId) => (state) => {
|
|
2121
|
+
return state.formReducer.instances[formId];
|
|
2122
|
+
};
|
|
2131
2123
|
const selectFilteredForms = restructureCreateSelectorWithArgs(
|
|
2132
2124
|
toolkit.createSelector(
|
|
2133
2125
|
[
|
|
@@ -2153,15 +2145,6 @@ var __publicField = (obj, key, value) => {
|
|
|
2153
2145
|
{ memoizeOptions: { equalityCheck: shallowEqual } }
|
|
2154
2146
|
)
|
|
2155
2147
|
);
|
|
2156
|
-
const selectFormById = (formId) => (state) => {
|
|
2157
|
-
return state.formReducer.instances[formId];
|
|
2158
|
-
};
|
|
2159
|
-
const selectFormsCount = toolkit.createSelector([selectFormMapping], (formsMapping) => {
|
|
2160
|
-
return Object.keys(formsMapping).length;
|
|
2161
|
-
});
|
|
2162
|
-
const selectGeneralFormCount = toolkit.createSelector([selectFormMapping], (formsMapping) => {
|
|
2163
|
-
return Object.values(formsMapping).length;
|
|
2164
|
-
});
|
|
2165
2148
|
const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
|
|
2166
2149
|
const initialState$m = submissionAdapter.getInitialState({});
|
|
2167
2150
|
const formSubmissionSlice = toolkit.createSlice({
|
|
@@ -2223,43 +2206,6 @@ var __publicField = (obj, key, value) => {
|
|
|
2223
2206
|
}
|
|
2224
2207
|
)
|
|
2225
2208
|
);
|
|
2226
|
-
const selectFormSubmissionsByFormRevisions = toolkit.createSelector([selectFormRevisionMapping, selectFormSubmissions], (revisions, submissions) => {
|
|
2227
|
-
var _a2;
|
|
2228
|
-
const submissionMapping = {};
|
|
2229
|
-
for (const revisionId in revisions) {
|
|
2230
|
-
submissionMapping[revisionId] = [];
|
|
2231
|
-
}
|
|
2232
|
-
for (const submission of submissions) {
|
|
2233
|
-
(_a2 = submissionMapping[submission.form_revision]) == null ? void 0 : _a2.push(submission);
|
|
2234
|
-
}
|
|
2235
|
-
return submissionMapping;
|
|
2236
|
-
});
|
|
2237
|
-
const selectSortedFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
|
|
2238
|
-
toolkit.createSelector(
|
|
2239
|
-
[
|
|
2240
|
-
selectFormRevisionMapping,
|
|
2241
|
-
selectFormSubmissionsByFormRevisions,
|
|
2242
|
-
(_state, formId) => formId
|
|
2243
|
-
],
|
|
2244
|
-
(revisionsMapping, submissionsByRevision, formId) => {
|
|
2245
|
-
const submissionsByFormRevisions = {};
|
|
2246
|
-
for (const revisionId in revisionsMapping) {
|
|
2247
|
-
const revision = revisionsMapping[revisionId];
|
|
2248
|
-
const submissionsOfRevision = submissionsByRevision[revisionId];
|
|
2249
|
-
if (revision && submissionsOfRevision && revision.form === formId) {
|
|
2250
|
-
submissionsByFormRevisions[revisionId] = submissionsOfRevision.sort(
|
|
2251
|
-
(a, b) => a.submitted_at < b.submitted_at ? -1 : 1
|
|
2252
|
-
);
|
|
2253
|
-
}
|
|
2254
|
-
}
|
|
2255
|
-
return Object.entries(submissionsByFormRevisions).sort((a, b) => {
|
|
2256
|
-
const aRevision = revisionsMapping[a[0]];
|
|
2257
|
-
const bRevision = revisionsMapping[b[0]];
|
|
2258
|
-
return formRevisionSortFn(aRevision, bRevision);
|
|
2259
|
-
}).map(([_revisionId, submissions]) => submissions).flat();
|
|
2260
|
-
}
|
|
2261
|
-
)
|
|
2262
|
-
);
|
|
2263
2209
|
const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
|
|
2264
2210
|
toolkit.createSelector(
|
|
2265
2211
|
[selectFormSubmissions, (_state, issueId) => issueId],
|
|
@@ -7727,54 +7673,63 @@ var __publicField = (obj, key, value) => {
|
|
|
7727
7673
|
}
|
|
7728
7674
|
}
|
|
7729
7675
|
class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
7730
|
-
async bulkAdd(payloads) {
|
|
7676
|
+
async bulkAdd(payloads, batchSize) {
|
|
7731
7677
|
var _a2;
|
|
7732
7678
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7733
7679
|
const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7734
|
-
const
|
|
7680
|
+
const batches = chunkArray(payloads, batchSize ?? payloads.length);
|
|
7735
7681
|
const offlineAssetTypeFieldValuesAttachments = [];
|
|
7736
|
-
const
|
|
7737
|
-
for (const
|
|
7738
|
-
const
|
|
7739
|
-
const
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7682
|
+
const batchPayloads = [];
|
|
7683
|
+
for (const batch of batches) {
|
|
7684
|
+
const filePayloads = {};
|
|
7685
|
+
const attachmentPayloads = [];
|
|
7686
|
+
for (const payload of batch) {
|
|
7687
|
+
const { fieldValuesId, fieldIdentifier, file } = payload;
|
|
7688
|
+
const filePayload = await this.getFilePayload(file);
|
|
7689
|
+
if (!(filePayload.sha1 in filePayloads))
|
|
7690
|
+
filePayloads[filePayload.sha1] = filePayload;
|
|
7691
|
+
const offlineAssetTypeFieldValuesAttachment = offline({
|
|
7692
|
+
file: URL.createObjectURL(file),
|
|
7693
|
+
file_type: file.type,
|
|
7694
|
+
file_name: file.name,
|
|
7695
|
+
file_sha1: filePayload.sha1,
|
|
7696
|
+
created_by: createdBy,
|
|
7697
|
+
field_values: fieldValuesId,
|
|
7698
|
+
submitted_at: submittedAt,
|
|
7699
|
+
field_identifier: fieldIdentifier
|
|
7700
|
+
});
|
|
7701
|
+
offlineAssetTypeFieldValuesAttachments.push(offlineAssetTypeFieldValuesAttachment);
|
|
7702
|
+
const attachmentPayload = {
|
|
7703
|
+
offline_id: offlineAssetTypeFieldValuesAttachment.offline_id,
|
|
7704
|
+
file_name: file.name,
|
|
7705
|
+
file_sha1: filePayload.sha1,
|
|
7706
|
+
file_extension: filePayload.extension,
|
|
7707
|
+
field_identifier: fieldIdentifier,
|
|
7708
|
+
field_values: fieldValuesId
|
|
7709
|
+
};
|
|
7710
|
+
attachmentPayloads.push(attachmentPayload);
|
|
7711
|
+
}
|
|
7712
|
+
batchPayloads.push({
|
|
7749
7713
|
submitted_at: submittedAt,
|
|
7750
|
-
|
|
7714
|
+
attachments: attachmentPayloads,
|
|
7715
|
+
files: Object.values(filePayloads)
|
|
7751
7716
|
});
|
|
7752
|
-
offlineAssetTypeFieldValuesAttachments.push(offlineAssetTypeFieldValuesAttachment);
|
|
7753
|
-
const attachmentPayload = {
|
|
7754
|
-
offline_id: offlineAssetTypeFieldValuesAttachment.offline_id,
|
|
7755
|
-
file_name: file.name,
|
|
7756
|
-
file_sha1: filePayload.sha1,
|
|
7757
|
-
file_extension: filePayload.extension,
|
|
7758
|
-
field_identifier: fieldIdentifier,
|
|
7759
|
-
field_values: fieldValuesId
|
|
7760
|
-
};
|
|
7761
|
-
attachmentPayloads.push(attachmentPayload);
|
|
7762
7717
|
}
|
|
7763
7718
|
this.dispatch(addAssetTypeFieldValuesAttachments(offlineAssetTypeFieldValuesAttachments));
|
|
7764
|
-
const
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
}
|
|
7773
|
-
blockers: offlineAssetTypeFieldValuesAttachments.map((attachment) => attachment.field_values),
|
|
7774
|
-
blocks: offlineAssetTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
|
|
7719
|
+
const promises = batchPayloads.map((payload) => {
|
|
7720
|
+
return this.enqueueRequest({
|
|
7721
|
+
description: "Add asset type field values attachments",
|
|
7722
|
+
method: HttpMethod.POST,
|
|
7723
|
+
url: "/asset-type-field-values-attachments/bulk/",
|
|
7724
|
+
payload,
|
|
7725
|
+
blockers: payload.attachments.map((payload2) => payload2.field_values),
|
|
7726
|
+
blocks: payload.attachments.map((payload2) => payload2.offline_id)
|
|
7727
|
+
});
|
|
7775
7728
|
});
|
|
7776
|
-
|
|
7777
|
-
|
|
7729
|
+
Promise.all(promises).then((result) => {
|
|
7730
|
+
for (const res of result)
|
|
7731
|
+
this.processPresignedUrls(res.presigned_urls);
|
|
7732
|
+
const attachments = result.flatMap((res) => res.attachments);
|
|
7778
7733
|
this.dispatch(updateAssetTypeFieldValuesAttachments(attachments));
|
|
7779
7734
|
}).catch((error) => {
|
|
7780
7735
|
this.dispatch(
|
|
@@ -7784,7 +7739,10 @@ var __publicField = (obj, key, value) => {
|
|
|
7784
7739
|
);
|
|
7785
7740
|
throw error;
|
|
7786
7741
|
});
|
|
7787
|
-
return [
|
|
7742
|
+
return [
|
|
7743
|
+
offlineAssetTypeFieldValuesAttachments,
|
|
7744
|
+
Promise.all(promises).then((result) => result.flatMap((res) => res.attachments))
|
|
7745
|
+
];
|
|
7788
7746
|
}
|
|
7789
7747
|
async bulkDelete(ids) {
|
|
7790
7748
|
const { store } = this.client;
|
|
@@ -7807,7 +7765,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7807
7765
|
}
|
|
7808
7766
|
async refreshStore(projectId) {
|
|
7809
7767
|
const result = await this.enqueueRequest({
|
|
7810
|
-
description: "
|
|
7768
|
+
description: "Get asset type field values attachments",
|
|
7811
7769
|
method: HttpMethod.GET,
|
|
7812
7770
|
url: "/asset-type-field-values-attachments/",
|
|
7813
7771
|
queryParams: {
|
|
@@ -8617,14 +8575,11 @@ var __publicField = (obj, key, value) => {
|
|
|
8617
8575
|
exports2.selectFormSubmissionAttachmentsMapping = selectFormSubmissionAttachmentsMapping;
|
|
8618
8576
|
exports2.selectFormSubmissionById = selectFormSubmissionById;
|
|
8619
8577
|
exports2.selectFormSubmissions = selectFormSubmissions;
|
|
8620
|
-
exports2.selectFormSubmissionsByFormRevisions = selectFormSubmissionsByFormRevisions;
|
|
8621
8578
|
exports2.selectFormSubmissionsMapping = selectFormSubmissionsMapping;
|
|
8622
8579
|
exports2.selectFormSubmissionsOfAsset = selectFormSubmissionsOfAsset;
|
|
8623
8580
|
exports2.selectFormSubmissionsOfForm = selectFormSubmissionsOfForm;
|
|
8624
8581
|
exports2.selectFormSubmissionsOfIssue = selectFormSubmissionsOfIssue;
|
|
8625
8582
|
exports2.selectForms = selectForms;
|
|
8626
|
-
exports2.selectFormsCount = selectFormsCount;
|
|
8627
|
-
exports2.selectGeneralFormCount = selectGeneralFormCount;
|
|
8628
8583
|
exports2.selectGeoImageById = selectGeoImageById;
|
|
8629
8584
|
exports2.selectGeoImageMapping = selectGeoImageMapping;
|
|
8630
8585
|
exports2.selectGeoImages = selectGeoImages;
|
|
@@ -8671,7 +8626,6 @@ var __publicField = (obj, key, value) => {
|
|
|
8671
8626
|
exports2.selectIssuesOfIssueType = selectIssuesOfIssueType;
|
|
8672
8627
|
exports2.selectIssuesOfIssueTypeCount = selectIssuesOfIssueTypeCount;
|
|
8673
8628
|
exports2.selectLatestAssetTypeFieldsOfAssetType = selectLatestAssetTypeFieldsOfAssetType;
|
|
8674
|
-
exports2.selectLatestFormRevisionByForm = selectLatestFormRevisionByForm;
|
|
8675
8629
|
exports2.selectLatestFormRevisionOfForm = selectLatestFormRevisionOfForm;
|
|
8676
8630
|
exports2.selectLatestIssueTypeFieldsOfIssueType = selectLatestIssueTypeFieldsOfIssueType;
|
|
8677
8631
|
exports2.selectLatestRetryTime = selectLatestRetryTime;
|
|
@@ -8710,7 +8664,6 @@ var __publicField = (obj, key, value) => {
|
|
|
8710
8664
|
exports2.selectProjectsOfOrganization = selectProjectsOfOrganization;
|
|
8711
8665
|
exports2.selectRehydrated = selectRehydrated;
|
|
8712
8666
|
exports2.selectRootDocuments = selectRootDocuments;
|
|
8713
|
-
exports2.selectSortedFormSubmissionsOfForm = selectSortedFormSubmissionsOfForm;
|
|
8714
8667
|
exports2.selectSortedOrganizationUsers = selectSortedOrganizationUsers;
|
|
8715
8668
|
exports2.selectSortedProjectUsers = selectSortedProjectUsers;
|
|
8716
8669
|
exports2.selectStageFormIdsFromStageIds = selectStageFormIdsFromStageIds;
|