@overmap-ai/core 1.0.71-fields.5 → 1.0.71-fields.7
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 +85 -56
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +85 -56
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/AssetTypeFieldValuesAttachmentService.d.ts +2 -3
- package/dist/sdk/services/AssetTypeFieldValuesService.d.ts +2 -2
- package/package.json +1 -1
package/dist/overmap-core.js
CHANGED
|
@@ -7572,24 +7572,39 @@ class AssetTypeFieldValuesService extends BaseApiService {
|
|
|
7572
7572
|
return [offlineAssetTypeFieldValues, promise];
|
|
7573
7573
|
}
|
|
7574
7574
|
bulkAdd(payload, batchSize) {
|
|
7575
|
+
var _a2;
|
|
7575
7576
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7576
7577
|
const { values } = separateFilesFromValues(payload.values);
|
|
7577
|
-
const
|
|
7578
|
-
const
|
|
7579
|
-
|
|
7578
|
+
const offlineAssetTypeFieldValuesMany = [];
|
|
7579
|
+
const batches = chunkArray(payload.payloads, batchSize ?? payload.payloads.length);
|
|
7580
|
+
const batchPayloads = [];
|
|
7581
|
+
for (const batch of batches) {
|
|
7582
|
+
const assetTypeFieldValuesPayloads = [];
|
|
7583
|
+
for (const payload2 of batch) {
|
|
7584
|
+
const offlineAssetTypeFieldValues = offline({
|
|
7585
|
+
...payload2,
|
|
7586
|
+
values: separateFilesFromValues(payload2.values).values,
|
|
7587
|
+
created_by: (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
7588
|
+
submitted_at: submittedAt
|
|
7589
|
+
});
|
|
7590
|
+
offlineAssetTypeFieldValuesMany.push(offlineAssetTypeFieldValues);
|
|
7591
|
+
assetTypeFieldValuesPayloads.push({
|
|
7592
|
+
offline_id: offlineAssetTypeFieldValues.offline_id,
|
|
7593
|
+
asset: payload2.asset,
|
|
7594
|
+
fields_revision: payload2.fields_revision,
|
|
7595
|
+
published_at: payload2.published_at,
|
|
7596
|
+
values: offlineAssetTypeFieldValues.values
|
|
7597
|
+
});
|
|
7598
|
+
}
|
|
7599
|
+
batchPayloads.push({
|
|
7580
7600
|
submitted_at: submittedAt,
|
|
7581
7601
|
values,
|
|
7582
|
-
field_values:
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
values: values2
|
|
7587
|
-
});
|
|
7588
|
-
})
|
|
7589
|
-
};
|
|
7590
|
-
});
|
|
7602
|
+
field_values: assetTypeFieldValuesPayloads
|
|
7603
|
+
});
|
|
7604
|
+
}
|
|
7605
|
+
this.dispatch(addAssetTypeFieldValuesMany(offlineAssetTypeFieldValuesMany));
|
|
7591
7606
|
const promises = [];
|
|
7592
|
-
for (const payload2 of
|
|
7607
|
+
for (const payload2 of batchPayloads) {
|
|
7593
7608
|
const assetIds = payload2.field_values.map((x) => x.asset);
|
|
7594
7609
|
const assetTypeFieldsIds = payload2.field_values.map((x) => x.fields_revision);
|
|
7595
7610
|
const assetTypeFieldValuesIds = payload2.field_values.map((x) => x.offline_id);
|
|
@@ -7604,9 +7619,11 @@ class AssetTypeFieldValuesService extends BaseApiService {
|
|
|
7604
7619
|
promises.push(promise);
|
|
7605
7620
|
}
|
|
7606
7621
|
void Promise.all(promises).then((results) => {
|
|
7607
|
-
this.dispatch(
|
|
7622
|
+
this.dispatch(updateAssetTypeFieldValuesMany(results.flat()));
|
|
7623
|
+
}).catch(() => {
|
|
7624
|
+
this.dispatch(deleteAssetTypeFieldValuesMany(offlineAssetTypeFieldValuesMany.map((x) => x.offline_id)));
|
|
7608
7625
|
});
|
|
7609
|
-
return promises;
|
|
7626
|
+
return [offlineAssetTypeFieldValuesMany, promises];
|
|
7610
7627
|
}
|
|
7611
7628
|
update(payload) {
|
|
7612
7629
|
const { store } = this.client;
|
|
@@ -7684,54 +7701,63 @@ class AssetTypeFieldValuesService extends BaseApiService {
|
|
|
7684
7701
|
}
|
|
7685
7702
|
}
|
|
7686
7703
|
class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
7687
|
-
async bulkAdd(payloads) {
|
|
7704
|
+
async bulkAdd(payloads, batchSize) {
|
|
7688
7705
|
var _a2;
|
|
7689
7706
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7690
7707
|
const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7691
|
-
const
|
|
7708
|
+
const batches = chunkArray(payloads, batchSize ?? payloads.length);
|
|
7692
7709
|
const offlineAssetTypeFieldValuesAttachments = [];
|
|
7693
|
-
const
|
|
7694
|
-
for (const
|
|
7695
|
-
const
|
|
7696
|
-
const
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7710
|
+
const batchPayloads = [];
|
|
7711
|
+
for (const batch of batches) {
|
|
7712
|
+
const filePayloads = {};
|
|
7713
|
+
const attachmentPayloads = [];
|
|
7714
|
+
for (const payload of batch) {
|
|
7715
|
+
const { fieldValuesId, fieldIdentifier, file } = payload;
|
|
7716
|
+
const filePayload = await this.getFilePayload(file);
|
|
7717
|
+
if (!(filePayload.sha1 in filePayloads))
|
|
7718
|
+
filePayloads[filePayload.sha1] = filePayload;
|
|
7719
|
+
const offlineAssetTypeFieldValuesAttachment = offline({
|
|
7720
|
+
file: URL.createObjectURL(file),
|
|
7721
|
+
file_type: file.type,
|
|
7722
|
+
file_name: file.name,
|
|
7723
|
+
file_sha1: filePayload.sha1,
|
|
7724
|
+
created_by: createdBy,
|
|
7725
|
+
field_values: fieldValuesId,
|
|
7726
|
+
submitted_at: submittedAt,
|
|
7727
|
+
field_identifier: fieldIdentifier
|
|
7728
|
+
});
|
|
7729
|
+
offlineAssetTypeFieldValuesAttachments.push(offlineAssetTypeFieldValuesAttachment);
|
|
7730
|
+
const attachmentPayload = {
|
|
7731
|
+
offline_id: offlineAssetTypeFieldValuesAttachment.offline_id,
|
|
7732
|
+
file_name: file.name,
|
|
7733
|
+
file_sha1: filePayload.sha1,
|
|
7734
|
+
file_extension: filePayload.extension,
|
|
7735
|
+
field_identifier: fieldIdentifier,
|
|
7736
|
+
field_values: fieldValuesId
|
|
7737
|
+
};
|
|
7738
|
+
attachmentPayloads.push(attachmentPayload);
|
|
7739
|
+
}
|
|
7740
|
+
batchPayloads.push({
|
|
7706
7741
|
submitted_at: submittedAt,
|
|
7707
|
-
|
|
7742
|
+
attachments: attachmentPayloads,
|
|
7743
|
+
files: Object.values(filePayloads)
|
|
7708
7744
|
});
|
|
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
7745
|
}
|
|
7720
7746
|
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)
|
|
7747
|
+
const promises = batchPayloads.map((payload) => {
|
|
7748
|
+
return this.enqueueRequest({
|
|
7749
|
+
description: "Add asset type field values attachments",
|
|
7750
|
+
method: HttpMethod.POST,
|
|
7751
|
+
url: "/asset-type-field-values-attachments/bulk/",
|
|
7752
|
+
payload,
|
|
7753
|
+
blockers: payload.attachments.map((payload2) => payload2.field_values),
|
|
7754
|
+
blocks: payload.attachments.map((payload2) => payload2.offline_id)
|
|
7755
|
+
});
|
|
7732
7756
|
});
|
|
7733
|
-
|
|
7734
|
-
|
|
7757
|
+
Promise.all(promises).then((result) => {
|
|
7758
|
+
for (const res of result)
|
|
7759
|
+
this.processPresignedUrls(res.presigned_urls);
|
|
7760
|
+
const attachments = result.flatMap((res) => res.attachments);
|
|
7735
7761
|
this.dispatch(updateAssetTypeFieldValuesAttachments(attachments));
|
|
7736
7762
|
}).catch((error) => {
|
|
7737
7763
|
this.dispatch(
|
|
@@ -7741,7 +7767,10 @@ class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
|
7741
7767
|
);
|
|
7742
7768
|
throw error;
|
|
7743
7769
|
});
|
|
7744
|
-
return [
|
|
7770
|
+
return [
|
|
7771
|
+
offlineAssetTypeFieldValuesAttachments,
|
|
7772
|
+
promises.map((promise) => promise.then(({ attachments }) => attachments))
|
|
7773
|
+
];
|
|
7745
7774
|
}
|
|
7746
7775
|
async bulkDelete(ids) {
|
|
7747
7776
|
const { store } = this.client;
|
|
@@ -7764,7 +7793,7 @@ class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
|
7764
7793
|
}
|
|
7765
7794
|
async refreshStore(projectId) {
|
|
7766
7795
|
const result = await this.enqueueRequest({
|
|
7767
|
-
description: "
|
|
7796
|
+
description: "Get asset type field values attachments",
|
|
7768
7797
|
method: HttpMethod.GET,
|
|
7769
7798
|
url: "/asset-type-field-values-attachments/",
|
|
7770
7799
|
queryParams: {
|