@overmap-ai/core 1.0.63-selector-standardization.9 → 1.0.63
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 +81 -2
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +81 -2
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/BaseAttachmentService.d.ts +7 -1
- package/dist/sdk/services/BaseUploadService.d.ts +1 -1
- package/dist/sdk/services/DocumentAttachmentService.d.ts +1 -0
- package/package.json +1 -1
package/dist/overmap-core.js
CHANGED
|
@@ -4526,8 +4526,9 @@ class BaseUploadService extends BaseApiService {
|
|
|
4526
4526
|
return objectsWithSha1.filter((object) => object.file_sha1 === sha1).length;
|
|
4527
4527
|
}
|
|
4528
4528
|
processPresignedUrls(presignedUrls) {
|
|
4529
|
+
const promisesBySha1 = {};
|
|
4529
4530
|
for (const [sha1, presignedUrl] of Object.entries(presignedUrls)) {
|
|
4530
|
-
|
|
4531
|
+
promisesBySha1[sha1] = this.enqueueRequest({
|
|
4531
4532
|
url: presignedUrl.url,
|
|
4532
4533
|
description: "Upload file to S3",
|
|
4533
4534
|
method: HttpMethod.POST,
|
|
@@ -4540,6 +4541,7 @@ class BaseUploadService extends BaseApiService {
|
|
|
4540
4541
|
s3url: presignedUrl
|
|
4541
4542
|
});
|
|
4542
4543
|
}
|
|
4544
|
+
return promisesBySha1;
|
|
4543
4545
|
}
|
|
4544
4546
|
}
|
|
4545
4547
|
const AttachmentModelMeta = {
|
|
@@ -6925,12 +6927,89 @@ class DocumentAttachmentService extends BaseAttachmentService {
|
|
|
6925
6927
|
document: data.modelId
|
|
6926
6928
|
});
|
|
6927
6929
|
}
|
|
6930
|
+
// NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
|
|
6928
6931
|
async attachFilesToDocument(files, documentId) {
|
|
6929
|
-
|
|
6932
|
+
const { store } = this.client;
|
|
6933
|
+
const currentUser = store.getState().userReducer.currentUser;
|
|
6934
|
+
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
6935
|
+
const offlineAttachments = [];
|
|
6936
|
+
const attachmentPayloads = [];
|
|
6937
|
+
const filePayloads = {};
|
|
6938
|
+
const sha1ToAttachmentIds = {};
|
|
6939
|
+
for (const file of files) {
|
|
6940
|
+
const sha1 = await hashFile(file);
|
|
6941
|
+
if (!(sha1 in filePayloads)) {
|
|
6942
|
+
filePayloads[sha1] = {
|
|
6943
|
+
sha1,
|
|
6944
|
+
file_type: file.type,
|
|
6945
|
+
extension: file.name.split(".").pop(),
|
|
6946
|
+
size: file.size
|
|
6947
|
+
};
|
|
6948
|
+
sha1ToAttachmentIds[sha1] = [];
|
|
6949
|
+
await this.client.files.addCache(file, sha1);
|
|
6950
|
+
}
|
|
6951
|
+
const offlineAttachment = this.buildOfflineAttachment({
|
|
6952
|
+
file,
|
|
6953
|
+
sha1,
|
|
6954
|
+
submittedAt,
|
|
6955
|
+
createdBy: currentUser.id,
|
|
6956
|
+
description: "",
|
|
6957
|
+
modelId: documentId
|
|
6958
|
+
});
|
|
6959
|
+
offlineAttachments.push(offlineAttachment);
|
|
6960
|
+
attachmentPayloads.push({
|
|
6961
|
+
offline_id: offlineAttachment.offline_id,
|
|
6962
|
+
name: offlineAttachment.file_name,
|
|
6963
|
+
sha1: offlineAttachment.file_sha1,
|
|
6964
|
+
description: offlineAttachment.description
|
|
6965
|
+
});
|
|
6966
|
+
sha1ToAttachmentIds[sha1].push(offlineAttachment.offline_id);
|
|
6967
|
+
}
|
|
6968
|
+
this.dispatch(this.addAttachments(offlineAttachments));
|
|
6969
|
+
const promise = this.enqueueRequest({
|
|
6970
|
+
description: "Attach files to document",
|
|
6971
|
+
method: HttpMethod.POST,
|
|
6972
|
+
url: `/documents/${documentId}/attach/`,
|
|
6973
|
+
payload: {
|
|
6974
|
+
submitted_at: submittedAt,
|
|
6975
|
+
attachments: attachmentPayloads,
|
|
6976
|
+
files: Object.values(filePayloads)
|
|
6977
|
+
},
|
|
6978
|
+
blocks: offlineAttachments.map((attachment) => attachment.offline_id),
|
|
6979
|
+
blockers: offlineAttachments.map((attachment) => attachment.file_sha1)
|
|
6980
|
+
});
|
|
6981
|
+
promise.then(({ attachments, presigned_urls }) => {
|
|
6982
|
+
this.dispatch(this.updateAttachments(attachments));
|
|
6983
|
+
const promisesBySha1 = this.processPresignedUrls(presigned_urls);
|
|
6984
|
+
for (const [sha1, promise2] of Object.entries(promisesBySha1)) {
|
|
6985
|
+
void promise2.then(() => {
|
|
6986
|
+
const attachmentIds = sha1ToAttachmentIds[sha1];
|
|
6987
|
+
for (const attachmentId of attachmentIds) {
|
|
6988
|
+
this.makeReadable(attachmentId);
|
|
6989
|
+
}
|
|
6990
|
+
});
|
|
6991
|
+
}
|
|
6992
|
+
}).catch(() => {
|
|
6993
|
+
this.dispatch(this.removeAttachments(offlineAttachments.map((attachment) => attachment.offline_id)));
|
|
6994
|
+
});
|
|
6995
|
+
return [offlineAttachments, promise.then(({ attachments }) => attachments)];
|
|
6930
6996
|
}
|
|
6931
6997
|
async deleteDocumentAttachment(attachmentId) {
|
|
6932
6998
|
return this.deleteAttachment(attachmentId);
|
|
6933
6999
|
}
|
|
7000
|
+
makeReadable(attachmnentId) {
|
|
7001
|
+
void this.enqueueRequest({
|
|
7002
|
+
description: "Add attachment to AI assistant",
|
|
7003
|
+
method: HttpMethod.PATCH,
|
|
7004
|
+
url: `/document-attachments/${attachmnentId}/`,
|
|
7005
|
+
payload: {
|
|
7006
|
+
readable_to_assistant: true
|
|
7007
|
+
},
|
|
7008
|
+
// passing through "index-document-attachment" so at most one document attachment being indexed at a time
|
|
7009
|
+
blockers: ["index-document-attachment", attachmnentId],
|
|
7010
|
+
blocks: ["index-document-attachment"]
|
|
7011
|
+
});
|
|
7012
|
+
}
|
|
6934
7013
|
async refreshStore(projectId, organizationId) {
|
|
6935
7014
|
const projectDocumentAttachments = await this.enqueueRequest({
|
|
6936
7015
|
description: "Get document attachments",
|