@arbidocs/react 0.5.85 → 0.5.86
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/index.cjs +31 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +31 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -11123,6 +11123,36 @@ async function downloadRecoveryFile(params) {
|
|
|
11123
11123
|
});
|
|
11124
11124
|
chunkTAVS54EN_cjs.downloadBlob(new Blob([file.html], { type: "text/html" }), file.filename);
|
|
11125
11125
|
}
|
|
11126
|
+
async function documentMailAttachment(arbi, doc, maxBytes, version) {
|
|
11127
|
+
const older = version && version !== (doc.current_version ?? 1) ? version : null;
|
|
11128
|
+
if (!reactQuery.onlineManager.isOnline() && !older) return offlineDocumentAttachment(doc, maxBytes);
|
|
11129
|
+
const failed = (cause) => new Error(`Could not download ${chunkPXWKJI4K_cjs.getDocumentTitle(doc, "the document")}`, { cause });
|
|
11130
|
+
const response = await arbi.documents.download(doc.external_id, older ?? void 0).catch((error) => {
|
|
11131
|
+
throw failed(error);
|
|
11132
|
+
});
|
|
11133
|
+
if (!response.ok) throw failed();
|
|
11134
|
+
const blob = await response.blob();
|
|
11135
|
+
if (blob.size > maxBytes) throw new Error("Document exceeds the email attachment limit");
|
|
11136
|
+
const fileName = older ? doc.versions?.find((v) => v.n === older)?.file_name ?? doc.file_name : doc.file_name;
|
|
11137
|
+
return fileAttachment(
|
|
11138
|
+
new File([blob], fileName || chunkPXWKJI4K_cjs.getDocumentTitle(doc, "document"), { type: blob.type })
|
|
11139
|
+
);
|
|
11140
|
+
}
|
|
11141
|
+
async function offlineDocumentAttachment(doc, maxBytes) {
|
|
11142
|
+
const title = chunkPXWKJI4K_cjs.getDocumentTitle(doc, "This document");
|
|
11143
|
+
const record = await getOfflineDocument(doc.external_id);
|
|
11144
|
+
const isPdf = /\.pdf$/i.test(doc.file_name ?? "");
|
|
11145
|
+
if (!record || record.kind === "pdf" && !isPdf)
|
|
11146
|
+
throw new Error(
|
|
11147
|
+
`${title} isn't available offline. Make it available offline first, or attach it when you're back online.`
|
|
11148
|
+
);
|
|
11149
|
+
const blob = await loadOfflineDocument(doc.external_id);
|
|
11150
|
+
if (!blob) throw new Error(`${title} isn't available offline.`);
|
|
11151
|
+
if (blob.size > maxBytes) throw new Error("Document exceeds the email attachment limit");
|
|
11152
|
+
return fileAttachment(
|
|
11153
|
+
new File([blob], doc.file_name || chunkPXWKJI4K_cjs.getDocumentTitle(doc, "document"), { type: blob.type })
|
|
11154
|
+
);
|
|
11155
|
+
}
|
|
11126
11156
|
var OfflineMailLockedError = class extends Error {
|
|
11127
11157
|
constructor() {
|
|
11128
11158
|
super("Sign in to open the mail saved on this device");
|
|
@@ -19271,6 +19301,7 @@ exports.disconnectAttachedRun = disconnectAttachedRun;
|
|
|
19271
19301
|
exports.documentActivityMeta = documentActivityMeta;
|
|
19272
19302
|
exports.documentActivityPhrase = documentActivityPhrase;
|
|
19273
19303
|
exports.documentDisplayName = documentDisplayName;
|
|
19304
|
+
exports.documentMailAttachment = documentMailAttachment;
|
|
19274
19305
|
exports.docxMentionMeta = docxMentionMeta;
|
|
19275
19306
|
exports.downloadRecoveryFile = downloadRecoveryFile;
|
|
19276
19307
|
exports.enqueueOutbox = enqueueOutbox;
|