@overmap-ai/core 1.0.71-fields.5 → 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
CHANGED
|
@@ -7684,54 +7684,63 @@ class AssetTypeFieldValuesService extends BaseApiService {
|
|
|
7684
7684
|
}
|
|
7685
7685
|
}
|
|
7686
7686
|
class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
7687
|
-
async bulkAdd(payloads) {
|
|
7687
|
+
async bulkAdd(payloads, batchSize) {
|
|
7688
7688
|
var _a2;
|
|
7689
7689
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7690
7690
|
const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7691
|
-
const
|
|
7691
|
+
const batches = chunkArray(payloads, batchSize ?? payloads.length);
|
|
7692
7692
|
const offlineAssetTypeFieldValuesAttachments = [];
|
|
7693
|
-
const
|
|
7694
|
-
for (const
|
|
7695
|
-
const
|
|
7696
|
-
const
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
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({
|
|
7706
7724
|
submitted_at: submittedAt,
|
|
7707
|
-
|
|
7725
|
+
attachments: attachmentPayloads,
|
|
7726
|
+
files: Object.values(filePayloads)
|
|
7708
7727
|
});
|
|
7709
|
-
offlineAssetTypeFieldValuesAttachments.push(offlineAssetTypeFieldValuesAttachment);
|
|
7710
|
-
const attachmentPayload = {
|
|
7711
|
-
offline_id: offlineAssetTypeFieldValuesAttachment.offline_id,
|
|
7712
|
-
file_name: file.name,
|
|
7713
|
-
file_sha1: filePayload.sha1,
|
|
7714
|
-
file_extension: filePayload.extension,
|
|
7715
|
-
field_identifier: fieldIdentifier,
|
|
7716
|
-
field_values: fieldValuesId
|
|
7717
|
-
};
|
|
7718
|
-
attachmentPayloads.push(attachmentPayload);
|
|
7719
7728
|
}
|
|
7720
7729
|
this.dispatch(addAssetTypeFieldValuesAttachments(offlineAssetTypeFieldValuesAttachments));
|
|
7721
|
-
const
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
}
|
|
7730
|
-
blockers: offlineAssetTypeFieldValuesAttachments.map((attachment) => attachment.field_values),
|
|
7731
|
-
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
|
+
});
|
|
7732
7739
|
});
|
|
7733
|
-
|
|
7734
|
-
|
|
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);
|
|
7735
7744
|
this.dispatch(updateAssetTypeFieldValuesAttachments(attachments));
|
|
7736
7745
|
}).catch((error) => {
|
|
7737
7746
|
this.dispatch(
|
|
@@ -7741,7 +7750,10 @@ class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
|
7741
7750
|
);
|
|
7742
7751
|
throw error;
|
|
7743
7752
|
});
|
|
7744
|
-
return [
|
|
7753
|
+
return [
|
|
7754
|
+
offlineAssetTypeFieldValuesAttachments,
|
|
7755
|
+
Promise.all(promises).then((result) => result.flatMap((res) => res.attachments))
|
|
7756
|
+
];
|
|
7745
7757
|
}
|
|
7746
7758
|
async bulkDelete(ids) {
|
|
7747
7759
|
const { store } = this.client;
|
|
@@ -7764,7 +7776,7 @@ class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
|
7764
7776
|
}
|
|
7765
7777
|
async refreshStore(projectId) {
|
|
7766
7778
|
const result = await this.enqueueRequest({
|
|
7767
|
-
description: "
|
|
7779
|
+
description: "Get asset type field values attachments",
|
|
7768
7780
|
method: HttpMethod.GET,
|
|
7769
7781
|
url: "/asset-type-field-values-attachments/",
|
|
7770
7782
|
queryParams: {
|