@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
package/dist/overmap-core.js
CHANGED
|
@@ -2104,17 +2104,6 @@ const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
|
|
|
2104
2104
|
}
|
|
2105
2105
|
)
|
|
2106
2106
|
);
|
|
2107
|
-
const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping], (revisions) => {
|
|
2108
|
-
const latestRevisions = {};
|
|
2109
|
-
for (const revision of Object.values(revisions)) {
|
|
2110
|
-
const formId = revision.form;
|
|
2111
|
-
const currentLatestRevision = latestRevisions[formId];
|
|
2112
|
-
if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
|
|
2113
|
-
latestRevisions[formId] = revision;
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
2116
|
-
return latestRevisions;
|
|
2117
|
-
});
|
|
2118
2107
|
const formRevisionReducer = formRevisionsSlice.reducer;
|
|
2119
2108
|
const formAdapter = createModelAdapter((form) => form.offline_id);
|
|
2120
2109
|
const initialState$n = formAdapter.getInitialState({});
|
|
@@ -2139,6 +2128,9 @@ const selectFormMapping = (state) => {
|
|
|
2139
2128
|
const selectForms = createSelector([selectFormMapping], (formsMapping) => {
|
|
2140
2129
|
return Object.values(formsMapping);
|
|
2141
2130
|
});
|
|
2131
|
+
const selectFormById = (formId) => (state) => {
|
|
2132
|
+
return state.formReducer.instances[formId];
|
|
2133
|
+
};
|
|
2142
2134
|
const selectFilteredForms = restructureCreateSelectorWithArgs(
|
|
2143
2135
|
createSelector(
|
|
2144
2136
|
[
|
|
@@ -2164,15 +2156,6 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
|
|
|
2164
2156
|
{ memoizeOptions: { equalityCheck: shallowEqual } }
|
|
2165
2157
|
)
|
|
2166
2158
|
);
|
|
2167
|
-
const selectFormById = (formId) => (state) => {
|
|
2168
|
-
return state.formReducer.instances[formId];
|
|
2169
|
-
};
|
|
2170
|
-
const selectFormsCount = createSelector([selectFormMapping], (formsMapping) => {
|
|
2171
|
-
return Object.keys(formsMapping).length;
|
|
2172
|
-
});
|
|
2173
|
-
const selectGeneralFormCount = createSelector([selectFormMapping], (formsMapping) => {
|
|
2174
|
-
return Object.values(formsMapping).length;
|
|
2175
|
-
});
|
|
2176
2159
|
const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
|
|
2177
2160
|
const initialState$m = submissionAdapter.getInitialState({});
|
|
2178
2161
|
const formSubmissionSlice = createSlice({
|
|
@@ -2234,43 +2217,6 @@ const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
|
|
|
2234
2217
|
}
|
|
2235
2218
|
)
|
|
2236
2219
|
);
|
|
2237
|
-
const selectFormSubmissionsByFormRevisions = createSelector([selectFormRevisionMapping, selectFormSubmissions], (revisions, submissions) => {
|
|
2238
|
-
var _a2;
|
|
2239
|
-
const submissionMapping = {};
|
|
2240
|
-
for (const revisionId in revisions) {
|
|
2241
|
-
submissionMapping[revisionId] = [];
|
|
2242
|
-
}
|
|
2243
|
-
for (const submission of submissions) {
|
|
2244
|
-
(_a2 = submissionMapping[submission.form_revision]) == null ? void 0 : _a2.push(submission);
|
|
2245
|
-
}
|
|
2246
|
-
return submissionMapping;
|
|
2247
|
-
});
|
|
2248
|
-
const selectSortedFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
|
|
2249
|
-
createSelector(
|
|
2250
|
-
[
|
|
2251
|
-
selectFormRevisionMapping,
|
|
2252
|
-
selectFormSubmissionsByFormRevisions,
|
|
2253
|
-
(_state, formId) => formId
|
|
2254
|
-
],
|
|
2255
|
-
(revisionsMapping, submissionsByRevision, formId) => {
|
|
2256
|
-
const submissionsByFormRevisions = {};
|
|
2257
|
-
for (const revisionId in revisionsMapping) {
|
|
2258
|
-
const revision = revisionsMapping[revisionId];
|
|
2259
|
-
const submissionsOfRevision = submissionsByRevision[revisionId];
|
|
2260
|
-
if (revision && submissionsOfRevision && revision.form === formId) {
|
|
2261
|
-
submissionsByFormRevisions[revisionId] = submissionsOfRevision.sort(
|
|
2262
|
-
(a, b) => a.submitted_at < b.submitted_at ? -1 : 1
|
|
2263
|
-
);
|
|
2264
|
-
}
|
|
2265
|
-
}
|
|
2266
|
-
return Object.entries(submissionsByFormRevisions).sort((a, b) => {
|
|
2267
|
-
const aRevision = revisionsMapping[a[0]];
|
|
2268
|
-
const bRevision = revisionsMapping[b[0]];
|
|
2269
|
-
return formRevisionSortFn(aRevision, bRevision);
|
|
2270
|
-
}).map(([_revisionId, submissions]) => submissions).flat();
|
|
2271
|
-
}
|
|
2272
|
-
)
|
|
2273
|
-
);
|
|
2274
2220
|
const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
|
|
2275
2221
|
createSelector(
|
|
2276
2222
|
[selectFormSubmissions, (_state, issueId) => issueId],
|
|
@@ -7738,54 +7684,63 @@ class AssetTypeFieldValuesService extends BaseApiService {
|
|
|
7738
7684
|
}
|
|
7739
7685
|
}
|
|
7740
7686
|
class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
7741
|
-
async bulkAdd(payloads) {
|
|
7687
|
+
async bulkAdd(payloads, batchSize) {
|
|
7742
7688
|
var _a2;
|
|
7743
7689
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7744
7690
|
const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7745
|
-
const
|
|
7691
|
+
const batches = chunkArray(payloads, batchSize ?? payloads.length);
|
|
7746
7692
|
const offlineAssetTypeFieldValuesAttachments = [];
|
|
7747
|
-
const
|
|
7748
|
-
for (const
|
|
7749
|
-
const
|
|
7750
|
-
const
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7693
|
+
const batchPayloads = [];
|
|
7694
|
+
for (const batch of batches) {
|
|
7695
|
+
const filePayloads = {};
|
|
7696
|
+
const attachmentPayloads = [];
|
|
7697
|
+
for (const payload of batch) {
|
|
7698
|
+
const { fieldValuesId, fieldIdentifier, file } = payload;
|
|
7699
|
+
const filePayload = await this.getFilePayload(file);
|
|
7700
|
+
if (!(filePayload.sha1 in filePayloads))
|
|
7701
|
+
filePayloads[filePayload.sha1] = filePayload;
|
|
7702
|
+
const offlineAssetTypeFieldValuesAttachment = offline({
|
|
7703
|
+
file: URL.createObjectURL(file),
|
|
7704
|
+
file_type: file.type,
|
|
7705
|
+
file_name: file.name,
|
|
7706
|
+
file_sha1: filePayload.sha1,
|
|
7707
|
+
created_by: createdBy,
|
|
7708
|
+
field_values: fieldValuesId,
|
|
7709
|
+
submitted_at: submittedAt,
|
|
7710
|
+
field_identifier: fieldIdentifier
|
|
7711
|
+
});
|
|
7712
|
+
offlineAssetTypeFieldValuesAttachments.push(offlineAssetTypeFieldValuesAttachment);
|
|
7713
|
+
const attachmentPayload = {
|
|
7714
|
+
offline_id: offlineAssetTypeFieldValuesAttachment.offline_id,
|
|
7715
|
+
file_name: file.name,
|
|
7716
|
+
file_sha1: filePayload.sha1,
|
|
7717
|
+
file_extension: filePayload.extension,
|
|
7718
|
+
field_identifier: fieldIdentifier,
|
|
7719
|
+
field_values: fieldValuesId
|
|
7720
|
+
};
|
|
7721
|
+
attachmentPayloads.push(attachmentPayload);
|
|
7722
|
+
}
|
|
7723
|
+
batchPayloads.push({
|
|
7760
7724
|
submitted_at: submittedAt,
|
|
7761
|
-
|
|
7725
|
+
attachments: attachmentPayloads,
|
|
7726
|
+
files: Object.values(filePayloads)
|
|
7762
7727
|
});
|
|
7763
|
-
offlineAssetTypeFieldValuesAttachments.push(offlineAssetTypeFieldValuesAttachment);
|
|
7764
|
-
const attachmentPayload = {
|
|
7765
|
-
offline_id: offlineAssetTypeFieldValuesAttachment.offline_id,
|
|
7766
|
-
file_name: file.name,
|
|
7767
|
-
file_sha1: filePayload.sha1,
|
|
7768
|
-
file_extension: filePayload.extension,
|
|
7769
|
-
field_identifier: fieldIdentifier,
|
|
7770
|
-
field_values: fieldValuesId
|
|
7771
|
-
};
|
|
7772
|
-
attachmentPayloads.push(attachmentPayload);
|
|
7773
7728
|
}
|
|
7774
7729
|
this.dispatch(addAssetTypeFieldValuesAttachments(offlineAssetTypeFieldValuesAttachments));
|
|
7775
|
-
const
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
}
|
|
7784
|
-
blockers: offlineAssetTypeFieldValuesAttachments.map((attachment) => attachment.field_values),
|
|
7785
|
-
blocks: offlineAssetTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
|
|
7730
|
+
const promises = batchPayloads.map((payload) => {
|
|
7731
|
+
return this.enqueueRequest({
|
|
7732
|
+
description: "Add asset type field values attachments",
|
|
7733
|
+
method: HttpMethod.POST,
|
|
7734
|
+
url: "/asset-type-field-values-attachments/bulk/",
|
|
7735
|
+
payload,
|
|
7736
|
+
blockers: payload.attachments.map((payload2) => payload2.field_values),
|
|
7737
|
+
blocks: payload.attachments.map((payload2) => payload2.offline_id)
|
|
7738
|
+
});
|
|
7786
7739
|
});
|
|
7787
|
-
|
|
7788
|
-
|
|
7740
|
+
Promise.all(promises).then((result) => {
|
|
7741
|
+
for (const res of result)
|
|
7742
|
+
this.processPresignedUrls(res.presigned_urls);
|
|
7743
|
+
const attachments = result.flatMap((res) => res.attachments);
|
|
7789
7744
|
this.dispatch(updateAssetTypeFieldValuesAttachments(attachments));
|
|
7790
7745
|
}).catch((error) => {
|
|
7791
7746
|
this.dispatch(
|
|
@@ -7795,7 +7750,10 @@ class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
|
7795
7750
|
);
|
|
7796
7751
|
throw error;
|
|
7797
7752
|
});
|
|
7798
|
-
return [
|
|
7753
|
+
return [
|
|
7754
|
+
offlineAssetTypeFieldValuesAttachments,
|
|
7755
|
+
Promise.all(promises).then((result) => result.flatMap((res) => res.attachments))
|
|
7756
|
+
];
|
|
7799
7757
|
}
|
|
7800
7758
|
async bulkDelete(ids) {
|
|
7801
7759
|
const { store } = this.client;
|
|
@@ -7818,7 +7776,7 @@ class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
|
7818
7776
|
}
|
|
7819
7777
|
async refreshStore(projectId) {
|
|
7820
7778
|
const result = await this.enqueueRequest({
|
|
7821
|
-
description: "
|
|
7779
|
+
description: "Get asset type field values attachments",
|
|
7822
7780
|
method: HttpMethod.GET,
|
|
7823
7781
|
url: "/asset-type-field-values-attachments/",
|
|
7824
7782
|
queryParams: {
|
|
@@ -8629,14 +8587,11 @@ export {
|
|
|
8629
8587
|
selectFormSubmissionAttachmentsMapping,
|
|
8630
8588
|
selectFormSubmissionById,
|
|
8631
8589
|
selectFormSubmissions,
|
|
8632
|
-
selectFormSubmissionsByFormRevisions,
|
|
8633
8590
|
selectFormSubmissionsMapping,
|
|
8634
8591
|
selectFormSubmissionsOfAsset,
|
|
8635
8592
|
selectFormSubmissionsOfForm,
|
|
8636
8593
|
selectFormSubmissionsOfIssue,
|
|
8637
8594
|
selectForms,
|
|
8638
|
-
selectFormsCount,
|
|
8639
|
-
selectGeneralFormCount,
|
|
8640
8595
|
selectGeoImageById,
|
|
8641
8596
|
selectGeoImageMapping,
|
|
8642
8597
|
selectGeoImages,
|
|
@@ -8683,7 +8638,6 @@ export {
|
|
|
8683
8638
|
selectIssuesOfIssueType,
|
|
8684
8639
|
selectIssuesOfIssueTypeCount,
|
|
8685
8640
|
selectLatestAssetTypeFieldsOfAssetType,
|
|
8686
|
-
selectLatestFormRevisionByForm,
|
|
8687
8641
|
selectLatestFormRevisionOfForm,
|
|
8688
8642
|
selectLatestIssueTypeFieldsOfIssueType,
|
|
8689
8643
|
selectLatestRetryTime,
|
|
@@ -8722,7 +8676,6 @@ export {
|
|
|
8722
8676
|
selectProjectsOfOrganization,
|
|
8723
8677
|
selectRehydrated,
|
|
8724
8678
|
selectRootDocuments,
|
|
8725
|
-
selectSortedFormSubmissionsOfForm,
|
|
8726
8679
|
selectSortedOrganizationUsers,
|
|
8727
8680
|
selectSortedProjectUsers,
|
|
8728
8681
|
selectStageFormIdsFromStageIds,
|