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