@arbidocs/react 0.5.149 → 0.5.151
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/chunk-BI7HFGXF.cjs +507 -0
- package/dist/chunk-BI7HFGXF.cjs.map +1 -0
- package/dist/{chunk-YNOKH4FX.cjs → chunk-SKJWJ3OY.cjs} +25 -248
- package/dist/chunk-SKJWJ3OY.cjs.map +1 -0
- package/dist/directmessages/file-shares.js +88 -0
- package/dist/directmessages/file-shares.js.map +7 -0
- package/dist/directmessages/index.js +8 -0
- package/dist/directmessages/index.js.map +2 -2
- package/dist/document-tools/core.cjs +155 -147
- package/dist/document-tools/core.d.ts +5 -477
- package/dist/document-tools/core.js +4 -0
- package/dist/document-tools/core.js.map +2 -2
- package/dist/document-tools/file-shares.js +24 -5
- package/dist/document-tools/file-shares.js.map +2 -2
- package/dist/document-tools/index.cjs +157 -149
- package/dist/document-tools/index.d.ts +5 -5
- package/dist/{query-keys.d-BZolSssa.d.ts → file-shares.d-CamKxNLC.d.ts} +517 -1
- package/dist/index.cjs +112 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +118 -13
- package/dist/notifications/index.js +2 -0
- package/dist/notifications/index.js.map +2 -2
- package/dist/notifications/server-notifications.js +29 -7
- package/dist/notifications/server-notifications.js.map +2 -2
- package/package.json +3 -3
- package/dist/chunk-ASL7H2TF.cjs +0 -264
- package/dist/chunk-ASL7H2TF.cjs.map +0 -1
- package/dist/chunk-YNOKH4FX.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ var chunkTMPDW7J5_cjs = require('./chunk-TMPDW7J5.cjs');
|
|
|
4
4
|
var chunkGFX7LQGR_cjs = require('./chunk-GFX7LQGR.cjs');
|
|
5
5
|
var chunkVXFTVWEI_cjs = require('./chunk-VXFTVWEI.cjs');
|
|
6
6
|
var chunkMK5L56Z3_cjs = require('./chunk-MK5L56Z3.cjs');
|
|
7
|
-
var
|
|
7
|
+
var chunkBI7HFGXF_cjs = require('./chunk-BI7HFGXF.cjs');
|
|
8
8
|
var chunkP2DPOZBS_cjs = require('./chunk-P2DPOZBS.cjs');
|
|
9
9
|
var chunk6RRKO4ZK_cjs = require('./chunk-6RRKO4ZK.cjs');
|
|
10
10
|
var chunkIX4HOS5Z_cjs = require('./chunk-IX4HOS5Z.cjs');
|
|
@@ -2384,7 +2384,7 @@ function useDownloadDocuments({ workspaceName } = {}) {
|
|
|
2384
2384
|
const [isDownloading, setIsDownloading] = React.useState(false);
|
|
2385
2385
|
const fetchNamedFile = React.useCallback(
|
|
2386
2386
|
async (doc) => {
|
|
2387
|
-
const blob = await
|
|
2387
|
+
const blob = await chunkBI7HFGXF_cjs.fetchDocumentFile(arbi.getClient().fetch, doc.external_id);
|
|
2388
2388
|
return { blob, name: blob instanceof File && blob.name ? blob.name : fallbackFileName(doc) };
|
|
2389
2389
|
},
|
|
2390
2390
|
[arbi]
|
|
@@ -2426,7 +2426,7 @@ function useDownloadDocuments({ workspaceName } = {}) {
|
|
|
2426
2426
|
);
|
|
2427
2427
|
}
|
|
2428
2428
|
const zipFileName = archiveName(workspaceName, `${successCount}_documents`);
|
|
2429
|
-
|
|
2429
|
+
chunkBI7HFGXF_cjs.downloadBlob(await zip.generateAsync({ type: "blob" }), zipFileName);
|
|
2430
2430
|
const documentsLabel = `${successCount} document${successCount !== 1 ? "s" : ""}`;
|
|
2431
2431
|
const contents = includeMetadataCsv ? `${documentsLabel} and index.csv in ${zipFileName}` : `${documentsLabel} in ${zipFileName}`;
|
|
2432
2432
|
if (failedDocs.length === 0) chunkIX4HOS5Z_cjs.notify.success(`Successfully downloaded ${contents}`);
|
|
@@ -2445,7 +2445,7 @@ function useDownloadDocuments({ workspaceName } = {}) {
|
|
|
2445
2445
|
setIsDownloading(true);
|
|
2446
2446
|
try {
|
|
2447
2447
|
const file = await fetchNamedFile(doc);
|
|
2448
|
-
|
|
2448
|
+
chunkBI7HFGXF_cjs.downloadBlob(file.blob, file.name);
|
|
2449
2449
|
chunkIX4HOS5Z_cjs.notify.success(`Successfully downloaded ${file.name}`);
|
|
2450
2450
|
} catch (error) {
|
|
2451
2451
|
console.error("Failed to download document", error);
|
|
@@ -4124,7 +4124,7 @@ async function keepDocumentsOffline(client$1, docs) {
|
|
|
4124
4124
|
if (!keypair) throw new Error("Could not derive an encryption key for the offline copy.");
|
|
4125
4125
|
for (const doc of docs) {
|
|
4126
4126
|
const original = chunkB6T54X65_cjs.usesOriginalBytesForViewer(doc.file_name);
|
|
4127
|
-
const blob = original ? await
|
|
4127
|
+
const blob = original ? await chunkBI7HFGXF_cjs.fetchDocumentFile(client$1, doc.external_id) : await chunkBI7HFGXF_cjs.fetchDocumentPdf(client$1, doc.external_id);
|
|
4128
4128
|
const plain = new Uint8Array(await blob.arrayBuffer());
|
|
4129
4129
|
await putOfflineDocument({
|
|
4130
4130
|
docExtId: doc.external_id,
|
|
@@ -9773,12 +9773,12 @@ function useWorkspaceExportDownload({
|
|
|
9773
9773
|
const client = arbi.getClient().fetch;
|
|
9774
9774
|
const archive = await buildWorkspaceArchive({
|
|
9775
9775
|
exportData: data,
|
|
9776
|
-
fetchFile: async (docExtId, version, kind) => kind === "markup" ? (await
|
|
9776
|
+
fetchFile: async (docExtId, version, kind) => kind === "markup" ? (await chunkBI7HFGXF_cjs.fetchMarkupPdf(client, docExtId, version, workspaceId)).blob : chunkBI7HFGXF_cjs.fetchDocumentFile(client, docExtId, { version, workspaceExtId: workspaceId }),
|
|
9777
9777
|
metadataCsv,
|
|
9778
9778
|
onProgress: (done, total) => setProgress({ done, total })
|
|
9779
9779
|
});
|
|
9780
9780
|
const fileName = archiveName(workspaceName, "export");
|
|
9781
|
-
|
|
9781
|
+
chunkBI7HFGXF_cjs.downloadBlob(archive.blob, fileName);
|
|
9782
9782
|
const files = `${archive.fileCount} file${archive.fileCount !== 1 ? "s" : ""}`;
|
|
9783
9783
|
if (archive.failed.length === 0) {
|
|
9784
9784
|
chunkIX4HOS5Z_cjs.notify.success(`Successfully downloaded ${files} and data in ${fileName}`);
|
|
@@ -13586,7 +13586,7 @@ async function downloadRecoveryFile(params) {
|
|
|
13586
13586
|
...params,
|
|
13587
13587
|
origin: params.origin ?? window.location.origin
|
|
13588
13588
|
});
|
|
13589
|
-
|
|
13589
|
+
chunkBI7HFGXF_cjs.downloadBlob(new Blob([file.html], { type: "text/html" }), file.filename);
|
|
13590
13590
|
}
|
|
13591
13591
|
async function documentMailAttachment(arbi, doc, maxBytes, version) {
|
|
13592
13592
|
const older = version && version !== (doc.current_version ?? 1) ? version : null;
|
|
@@ -16258,6 +16258,7 @@ function notificationUserName(user) {
|
|
|
16258
16258
|
var CONVERSATION_ID = /^con-[a-zA-Z0-9]+$/;
|
|
16259
16259
|
var WORKFLOW_ID = /^wfl-[a-zA-Z0-9]+$/;
|
|
16260
16260
|
var DOCUMENT_ID = /^doc-[a-zA-Z0-9]+$/;
|
|
16261
|
+
var FILE_SHARE_ID = /^fsh-[0-9a-f]{32}$/;
|
|
16261
16262
|
function parse(content) {
|
|
16262
16263
|
try {
|
|
16263
16264
|
const value = JSON.parse(content || "{}");
|
|
@@ -16266,6 +16267,20 @@ function parse(content) {
|
|
|
16266
16267
|
return null;
|
|
16267
16268
|
}
|
|
16268
16269
|
}
|
|
16270
|
+
function fileShareNotificationMeta(content) {
|
|
16271
|
+
const meta = parse(content);
|
|
16272
|
+
const shareId = meta?.file_share_id;
|
|
16273
|
+
if (typeof shareId !== "string" || !FILE_SHARE_ID.test(shareId)) return null;
|
|
16274
|
+
const event = meta?.declined === true ? "declined" : meta?.completed === true ? "completed" : meta?.signed === true ? "signed" : meta?.signature === true ? "signature-requested" : "shared";
|
|
16275
|
+
return { shareId, event };
|
|
16276
|
+
}
|
|
16277
|
+
var FILE_SHARE_TITLES = {
|
|
16278
|
+
shared: (sender) => `${sender} shared a file with you`,
|
|
16279
|
+
"signature-requested": (sender) => `${sender} asked you to sign a file`,
|
|
16280
|
+
signed: (sender) => `${sender} signed a file`,
|
|
16281
|
+
completed: () => "Everyone has signed. Your PDF is ready.",
|
|
16282
|
+
declined: (sender) => `${sender} declined to sign a file`
|
|
16283
|
+
};
|
|
16269
16284
|
function uploadSetMeta(content) {
|
|
16270
16285
|
const meta = parse(content) ?? {};
|
|
16271
16286
|
const count = (key) => {
|
|
@@ -16540,15 +16555,21 @@ function describeServerNotification(n, options = {}) {
|
|
|
16540
16555
|
target: conversationTarget(n) ?? workflowTarget(n)
|
|
16541
16556
|
};
|
|
16542
16557
|
}
|
|
16558
|
+
// A shared file opens in the direct chat with the person on the other side.
|
|
16543
16559
|
case "file_shared": {
|
|
16544
|
-
const meta =
|
|
16545
|
-
|
|
16546
|
-
|
|
16560
|
+
const meta = fileShareNotificationMeta(n.content);
|
|
16561
|
+
if (!meta) return null;
|
|
16562
|
+
const { event } = meta;
|
|
16547
16563
|
return {
|
|
16548
|
-
title:
|
|
16549
|
-
variant:
|
|
16550
|
-
actionLabel:
|
|
16551
|
-
target: {
|
|
16564
|
+
title: FILE_SHARE_TITLES[event](senderName),
|
|
16565
|
+
variant: event === "declined" ? "warning" : event === "completed" || event === "signed" ? "success" : "info",
|
|
16566
|
+
actionLabel: event === "signature-requested" ? "Review and sign" : "Open file",
|
|
16567
|
+
target: {
|
|
16568
|
+
kind: "file-share",
|
|
16569
|
+
shareId: meta.shareId,
|
|
16570
|
+
senderId: n.sender.external_id,
|
|
16571
|
+
recipientId: n.recipient.external_id
|
|
16572
|
+
}
|
|
16552
16573
|
};
|
|
16553
16574
|
}
|
|
16554
16575
|
// One upload action finished (however many batches it was sent and processed in). A failed
|
|
@@ -17543,6 +17564,78 @@ function annotateThread(messages, accessors, runWindowMs = RUN_WINDOW_MS) {
|
|
|
17543
17564
|
};
|
|
17544
17565
|
});
|
|
17545
17566
|
}
|
|
17567
|
+
var time2 = (iso) => iso === null ? -Infinity : Date.parse(iso);
|
|
17568
|
+
function dmFileShareEntries({
|
|
17569
|
+
notifications,
|
|
17570
|
+
shares,
|
|
17571
|
+
me,
|
|
17572
|
+
peerId,
|
|
17573
|
+
peerEmail
|
|
17574
|
+
}) {
|
|
17575
|
+
const byShare = /* @__PURE__ */ new Map();
|
|
17576
|
+
for (const n of notifications) {
|
|
17577
|
+
if (n.type !== "file_shared") continue;
|
|
17578
|
+
const from = n.sender.external_id;
|
|
17579
|
+
const to = n.recipient.external_id;
|
|
17580
|
+
if (!(from === peerId && to === me || from === me && to === peerId)) continue;
|
|
17581
|
+
const meta = fileShareNotificationMeta(n.content);
|
|
17582
|
+
if (!meta) continue;
|
|
17583
|
+
const known = byShare.get(meta.shareId);
|
|
17584
|
+
if (!known || time2(n.created_at) > time2(known.at))
|
|
17585
|
+
byShare.set(meta.shareId, { shareId: meta.shareId, at: n.created_at, event: meta.event });
|
|
17586
|
+
}
|
|
17587
|
+
const email = peerEmail?.toLowerCase();
|
|
17588
|
+
if (email) {
|
|
17589
|
+
for (const share of shares)
|
|
17590
|
+
if (share.owner && !byShare.has(share.external_id) && share.recipients.some((r) => r.email.toLowerCase() === email))
|
|
17591
|
+
byShare.set(share.external_id, { shareId: share.external_id, at: null, event: null });
|
|
17592
|
+
}
|
|
17593
|
+
return [...byShare.values()].sort((a, b) => time2(a.at) - time2(b.at));
|
|
17594
|
+
}
|
|
17595
|
+
function useDmFileShares(peer) {
|
|
17596
|
+
const arbi = chunkP2DPOZBS_cjs.useArbi();
|
|
17597
|
+
const queryClient = reactQuery.useQueryClient();
|
|
17598
|
+
const me = chunkGFX7LQGR_cjs.myChatId(arbi);
|
|
17599
|
+
const person = peer && peer.external_id.startsWith("usr-") && me ? peer : null;
|
|
17600
|
+
const list = chunkBI7HFGXF_cjs.useFileShares(person && arbi.isLoggedIn ? arbi.getClient().fetch : null);
|
|
17601
|
+
const { data: notifications = [] } = useNotifications({ enabled: !!person });
|
|
17602
|
+
const entries = React.useMemo(
|
|
17603
|
+
() => person && me ? dmFileShareEntries({
|
|
17604
|
+
notifications,
|
|
17605
|
+
shares: list.data ?? [],
|
|
17606
|
+
me,
|
|
17607
|
+
peerId: person.external_id,
|
|
17608
|
+
peerEmail: person.email
|
|
17609
|
+
}) : [],
|
|
17610
|
+
[notifications, list.data, me, person]
|
|
17611
|
+
);
|
|
17612
|
+
const shareById = React.useMemo(
|
|
17613
|
+
() => new Map((list.data ?? []).map((share) => [share.external_id, share])),
|
|
17614
|
+
[list.data]
|
|
17615
|
+
);
|
|
17616
|
+
const newest = entries.reduce((max, e) => e.at && e.at > max ? e.at : max, "");
|
|
17617
|
+
const seen = React.useRef(newest);
|
|
17618
|
+
React.useEffect(() => {
|
|
17619
|
+
const previous = seen.current;
|
|
17620
|
+
seen.current = newest;
|
|
17621
|
+
if (previous && previous !== newest)
|
|
17622
|
+
void queryClient.invalidateQueries({ queryKey: chunkP2DPOZBS_cjs.arbiQueryKeys.fileShares() });
|
|
17623
|
+
}, [newest, queryClient]);
|
|
17624
|
+
return { entries, shareById, loaded: list.isSuccess, failed: list.isError };
|
|
17625
|
+
}
|
|
17626
|
+
function useFileSharePerson(userId) {
|
|
17627
|
+
const person = !!userId && userId.startsWith("usr-");
|
|
17628
|
+
const { data: notifications = [] } = useNotifications({ enabled: person });
|
|
17629
|
+
return React.useMemo(() => {
|
|
17630
|
+
if (!person) return null;
|
|
17631
|
+
for (const n of notifications) {
|
|
17632
|
+
if (n.type !== "file_shared") continue;
|
|
17633
|
+
if (n.sender.external_id === userId) return n.sender;
|
|
17634
|
+
if (n.recipient.external_id === userId) return n.recipient;
|
|
17635
|
+
}
|
|
17636
|
+
return null;
|
|
17637
|
+
}, [notifications, person, userId]);
|
|
17638
|
+
}
|
|
17546
17639
|
var DEFAULT_ASPECT_OPTIONS = [
|
|
17547
17640
|
{ label: "1:1", value: 1 },
|
|
17548
17641
|
{ label: "4:3", value: 4 / 3 },
|
|
@@ -20596,6 +20689,7 @@ exports.describeCalendarNotification = describeCalendarNotification;
|
|
|
20596
20689
|
exports.describeServerNotification = describeServerNotification;
|
|
20597
20690
|
exports.discardStreamingTokensForMessage = discardStreamingTokensForMessage;
|
|
20598
20691
|
exports.disconnectAttachedRun = disconnectAttachedRun;
|
|
20692
|
+
exports.dmFileShareEntries = dmFileShareEntries;
|
|
20599
20693
|
exports.documentActivityMeta = documentActivityMeta;
|
|
20600
20694
|
exports.documentActivityPhrase = documentActivityPhrase;
|
|
20601
20695
|
exports.documentDisplayName = documentDisplayName;
|
|
@@ -20608,6 +20702,7 @@ exports.ensureAssistantMessageLoading = ensureAssistantMessageLoading;
|
|
|
20608
20702
|
exports.extractZipFile = extractZipFile;
|
|
20609
20703
|
exports.fallbackFileName = fallbackFileName;
|
|
20610
20704
|
exports.fileAttachment = fileAttachment;
|
|
20705
|
+
exports.fileShareNotificationMeta = fileShareNotificationMeta;
|
|
20611
20706
|
exports.filesFromDrop = filesFromDrop;
|
|
20612
20707
|
exports.fillTimeGaps = fillTimeGaps;
|
|
20613
20708
|
exports.filterRows = filterRows;
|
|
@@ -20871,6 +20966,7 @@ exports.useDisconnectConnector = useDisconnectConnector;
|
|
|
20871
20966
|
exports.useDisconnectMailAccount = useDisconnectMailAccount;
|
|
20872
20967
|
exports.useDisconnectSlack = useDisconnectSlack;
|
|
20873
20968
|
exports.useDismissedTips = useDismissedTips;
|
|
20969
|
+
exports.useDmFileShares = useDmFileShares;
|
|
20874
20970
|
exports.useDocumentAutoAdd = useDocumentAutoAdd;
|
|
20875
20971
|
exports.useDocumentHostActions = useDocumentHostActions;
|
|
20876
20972
|
exports.useDocumentPendingSync = useDocumentPendingSync;
|
|
@@ -20889,6 +20985,7 @@ exports.useExportDatabase = useExportDatabase;
|
|
|
20889
20985
|
exports.useFacts = useFacts;
|
|
20890
20986
|
exports.useFactsSearch = useFactsSearch;
|
|
20891
20987
|
exports.useFetchCalendarEvent = useFetchCalendarEvent;
|
|
20988
|
+
exports.useFileSharePerson = useFileSharePerson;
|
|
20892
20989
|
exports.useFileWaitingNativeMail = useFileWaitingNativeMail;
|
|
20893
20990
|
exports.useFinaliseTranslation = useFinaliseTranslation;
|
|
20894
20991
|
exports.useFindTime = useFindTime;
|