@arbidocs/react 0.4.144 → 0.4.146
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/artifacts/index.cjs +11 -14
- package/dist/artifacts/index.cjs.map +1 -1
- package/dist/artifacts/index.d.cts +1 -3
- package/dist/artifacts/index.d.ts +1 -3
- package/dist/artifacts/index.js +7 -10
- package/dist/artifacts/index.js.map +1 -1
- package/dist/chunk-7AFGROHZ.js +861 -0
- package/dist/chunk-7AFGROHZ.js.map +1 -0
- package/dist/{chunk-CVJ25DFD.cjs → chunk-YIFUMQGA.cjs} +494 -11
- package/dist/chunk-YIFUMQGA.cjs.map +1 -0
- package/dist/index.cjs +668 -327
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +731 -179
- package/dist/index.d.ts +731 -179
- package/dist/index.js +358 -157
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +9 -9
- package/dist/ui/index.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-CVJ25DFD.cjs.map +0 -1
- package/dist/chunk-E4VILXG5.js +0 -411
- package/dist/chunk-E4VILXG5.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { arbiMutationKeys, arbiQueryKeys, useDocuments, useConversations, useAssistantQuery, useConversationThreads, useWorkspaces, useParsedDocument, useTags, useActivity, useThumbnails } from './chunk-
|
|
2
|
-
export { PROJECT_CREATION_DENIED_REASON, arbiMutationKeys, arbiQueryKeys, isUsageMetered, useActivity, useAgents, useAssistantQuery, useCanCreateProjects, useConfigs, useConversationThreads, useConversations, useCurrentUser, useDeleteAgents, useDocuments, useFirmPool, useHealth, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useTags, useThumbnails, useTopUpFirmPool, useUserUsageToday, useWorkspaceActivity, useWorkspaceUsers, useWorkspaces } from './chunk-
|
|
3
|
-
import { formatRelativeTime } from './chunk-MFMJHBJR.js';
|
|
4
|
-
export { DEFAULT_NOTIFY_TONE, MAX_SESSION_NOTIFICATIONS, NotificationBell, Toaster, configureNotify, formatRelativeTime, notify, persistNotifyHistory, seedNotifications, selectUnread, toast, useNotify } from './chunk-MFMJHBJR.js';
|
|
1
|
+
import { arbiMutationKeys, replayableTagMutations, patchDocuments, setCachedDocument, adjustTagCounts, arbiQueryKeys, patchCachedDocument, useDocuments, useConversations, useAssistantQuery, useConversationThreads, refreshDocuments, FINISHED_DOCUMENT_STATUSES, useWorkspaces, forgetDocuments, getCachedDocuments, useParsedDocument, useTags, useActivity, useThumbnails } from './chunk-7AFGROHZ.js';
|
|
2
|
+
export { DOCUMENTS_FIRST_PAGE_MEASURE, DOCUMENTS_FIRST_PAGE_SIZE, DOCUMENTS_PAGE_SIZE, FINISHED_DOCUMENT_STATUSES, PROJECT_CREATION_DENIED_REASON, SIMILARITY_THRESHOLD, adjustTagCounts, arbiMutationKeys, arbiQueryKeys, forgetDocuments, getCachedDocuments, invalidateTagData, invalidateTagTables, isDocumentsLoading, isUsageMetered, patchCachedDocument, patchDocuments, patchWorkspaceTags, refreshDocuments, setCachedDocument, stopDocumentsLoading, subscribeDocumentRows, upsertDocuments, useActivity, useAgents, useAssistantQuery, useAvailableModels, useCanCreateProjects, useConfigs, useConversationThreads, useConversations, useCreateTag, useCurrentUser, useDeleteAgents, useDeleteTag, useDocument, useDocumentVersionList, useDocuments, useDocumentsById, useDocumentsLoading, useExtractEntities, useFirmPool, useHealth, useInvalidateTagData, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSetTagValues, useSimilarDocuments, useTagKindSchema, useTags, useThumbnails, useTopUpFirmPool, useUpdateTag, useUpdateTagKindSchema, useUserUsageToday, useWorkspaceActivity, useWorkspaceUsers, useWorkspaces } from './chunk-7AFGROHZ.js';
|
|
5
3
|
import { downloadBlob } from './chunk-YYTX3W6C.js';
|
|
6
4
|
import { parseVersionRef } from './chunk-NNWMHMEC.js';
|
|
7
5
|
export { cleanDraftMarkdown, cleanDraftWithReport, promoteBoldTitle, repairParsedStructure, repairParsedTitle, stripAgentPreamble, unescapeMarkdown, unwrapCitationLinks } from './chunk-NNWMHMEC.js';
|
|
8
6
|
import './chunk-WUTL62MC.js';
|
|
7
|
+
import { formatRelativeTime } from './chunk-MFMJHBJR.js';
|
|
8
|
+
export { DEFAULT_NOTIFY_TONE, MAX_SESSION_NOTIFICATIONS, NotificationBell, Toaster, configureNotify, formatRelativeTime, notify, persistNotifyHistory, seedNotifications, selectUnread, toast, useNotify } from './chunk-MFMJHBJR.js';
|
|
9
9
|
import { returnFocusToMark, MarkMenu, AiMarkdown, Card, Badge, TagEntity, Input, FILE_TYPE_COLORS, getEntityIcon, UserEntity, getEntityColorStyles, AgentBadge, Textarea, Label, Slider, DocumentEntity, DocumentCard, useAudioRecorder, MicWaveformIndicator, IconToggle, classifyMediaError, formatElapsed, PassageCard } from './chunk-J3BYHBKW.js';
|
|
10
10
|
export { AUDIO_MIME_PREFERENCE, AgentBadge, AiMarkdown, ArbiBotHeadIcon, ArbiIcon, AudIcon, Avatar, AvatarFallback, AvatarImage, BASE_COLORS, Badge, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, DEFAULT_SEGMENTER_CONFIG, DebouncedInput, DictateProvider, DocIcon, DocumentCard, DocumentEntity, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, HoverCard, HoverCardContent, HoverCardTrigger, HtmlIcon, INITIAL_SEGMENTER_STATE, IconToggle, ImgIcon, InlineMicButton, Input, Label, MarkMenu, MicRecordingOverlay, MicWaveformIndicator, NEUTRAL_GRAY, PLACEHOLDER_COLOR, PassageCard, PdfIcon, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, PresenceLabel, Progress, ProjectEntity, RadioGroup, RadioGroupItem, RagDot, RelevanceDot, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, ShieldIcon, Slider, StatusPill, Switch, TAG_TYPE_ICONS, TAG_TYPE_LABELS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TagEntity, Textarea, ThreadVisibilityIcon, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TxtIcon, UserEntity, UserMenu, VIDEO_MIME_PREFERENCE, VISIBILITY_ICONS, VerifiedBadge, VidIcon, VisibilityIcon, VisibilityToggle, XlsIcon, agentAvatarColors, badgeVariants, cardVariants, classifyMediaError, configureEntityRegistry, configureRagLabels, configureStatusRegistry, createChunkedRecorder, flushSegmenter, formatElapsed, getDocIcon, getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getWorkspaceColor, levelFromRms, pickRecorderMimeType, stepSegmenter, toggleVariants, useAudioRecorder } from './chunk-J3BYHBKW.js';
|
|
11
11
|
import { MarkdownRenderer } from './chunk-C44GO33B.js';
|
|
12
12
|
export { MarkdownCode, MarkdownLink, MarkdownRenderer, MarkdownStreamingContext, markdownBaseComponents, markdownSanitizeSchema, splitMarkdownBlocks } from './chunk-C44GO33B.js';
|
|
13
|
-
import { ScrollArea } from './chunk-W4H6XAIU.js';
|
|
14
|
-
export { ScrollArea, ScrollBar } from './chunk-W4H6XAIU.js';
|
|
15
13
|
import { Button, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from './chunk-YNNAJJ5Z.js';
|
|
16
14
|
export { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, buttonVariants } from './chunk-YNNAJJ5Z.js';
|
|
17
15
|
import { normalizeCitationMarkup } from './chunk-QRCMKEE6.js';
|
|
18
16
|
export { closeOpenEmphasis, normalizeCitationMarkup, trimOpenCitation } from './chunk-QRCMKEE6.js';
|
|
17
|
+
import { ScrollArea } from './chunk-W4H6XAIU.js';
|
|
18
|
+
export { ScrollArea, ScrollBar } from './chunk-W4H6XAIU.js';
|
|
19
19
|
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from './chunk-47CCGUWR.js';
|
|
20
20
|
export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, PortalContainerProvider, usePortalContainer } from './chunk-47CCGUWR.js';
|
|
21
21
|
import { cn } from './chunk-SN5YV6FF.js';
|
|
@@ -24,8 +24,8 @@ import { AudioViewer, ImageViewer, VideoViewer } from './chunk-HDCRPPBW.js';
|
|
|
24
24
|
import { useArbi, ArbiContext } from './chunk-CPPBN2JB.js';
|
|
25
25
|
export { ArbiProvider, useArbi, useDeploymentDomain } from './chunk-CPPBN2JB.js';
|
|
26
26
|
import React, { memo, useState, createContext, useMemo, useCallback, useEffect, useRef, useLayoutEffect, useContext, useId, useSyncExternalStore, Fragment as Fragment$1 } from 'react';
|
|
27
|
-
import { useQueryClient, useMutation, useQuery,
|
|
28
|
-
import {
|
|
27
|
+
import { useQueryClient, useMutation, useQuery, onlineManager, partialMatchKey } from '@tanstack/react-query';
|
|
28
|
+
import { documents, doctags, houseTemplates, resolveCitations, summarizeCitations, settings, ArbiApiError, ACCOUNT_VENDOR, formatFileSize, connectWithReconnect, chats, identityErrorCode } from '@arbidocs/sdk/browser';
|
|
29
29
|
export { ACCOUNT_VENDOR, Arbi, ArbiError, DEFAULT_AI_USD_PER_GBP, PublicBookingError, bookPublicSlot, cancelPublicBooking, formatGbp, formatGbpPerMillionTokens, getPublicBookingPage, splitAppPasswords, usdToGbp } from '@arbidocs/sdk/browser';
|
|
30
30
|
import { Link, Trash2, CheckCheck, Check, Loader2, AlertTriangle, ShieldCheck, Copy, Sparkles, FileText, GitCompareArrows, Download, Search, CornerDownLeft, X, ArrowLeft, Send, Tags, Crown, Info, Activity, HardDrive, Gauge, Gift, PartyPopper, UserPlus, UserCheck, Reply, PenLine, AtSign, MessageCircleMore, FileX2, FileCheck2, Pencil, FolderPlus, SquareArrowOutUpRight, MessagesSquare, Paperclip, ArrowRight, MoreHorizontal, SquarePen, Mic, Pause, Play, Square, RotateCcw, Camera, Circle, Image as Image$1, AppWindow } from 'lucide-react';
|
|
31
31
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -559,7 +559,8 @@ function useArbiChat(options = {}) {
|
|
|
559
559
|
const recoveryIntervalMs = streamRecovery?.intervalMs ?? 3e3;
|
|
560
560
|
const recoveryTimeoutMs = streamRecovery?.timeoutMs ?? 12e4;
|
|
561
561
|
const arbi = useArbi();
|
|
562
|
-
const
|
|
562
|
+
const queryClient = useQueryClient();
|
|
563
|
+
const { data: docs = [], isLoading: isLoadingDocuments } = useDocuments(workspaceId);
|
|
563
564
|
const ordinaryHistory = useConversations(workspaceId, { enabled: !agentId, live: true });
|
|
564
565
|
const agentHistory = useAgentChats(agentId);
|
|
565
566
|
const stored = useMemo(
|
|
@@ -1099,6 +1100,7 @@ function useArbiChat(options = {}) {
|
|
|
1099
1100
|
setIsUploading(true);
|
|
1100
1101
|
setUploadError(null);
|
|
1101
1102
|
try {
|
|
1103
|
+
const uploaded = [];
|
|
1102
1104
|
for (const file of files) {
|
|
1103
1105
|
if (agentId) {
|
|
1104
1106
|
const staged = await arbi.agents.stageFile(agentId, file, file.name);
|
|
@@ -1106,16 +1108,17 @@ function useArbiChat(options = {}) {
|
|
|
1106
1108
|
...all.filter((existing) => existing.id !== staged.path),
|
|
1107
1109
|
{ id: staged.path, name: staged.name }
|
|
1108
1110
|
]);
|
|
1109
|
-
} else
|
|
1111
|
+
} else
|
|
1112
|
+
uploaded.push(...(await arbi.documents.uploadFile(file, file.name)).doc_ext_ids ?? []);
|
|
1110
1113
|
}
|
|
1111
|
-
if (
|
|
1114
|
+
if (uploaded.length) await refreshDocuments(queryClient, arbi, uploaded);
|
|
1112
1115
|
} catch (e) {
|
|
1113
1116
|
setUploadError(messageOf(e, "The upload failed."));
|
|
1114
1117
|
} finally {
|
|
1115
1118
|
setIsUploading(false);
|
|
1116
1119
|
}
|
|
1117
1120
|
},
|
|
1118
|
-
[arbi,
|
|
1121
|
+
[arbi, queryClient, agentId]
|
|
1119
1122
|
);
|
|
1120
1123
|
return {
|
|
1121
1124
|
assistantMode,
|
|
@@ -1403,28 +1406,21 @@ function useArbiWsTasks() {
|
|
|
1403
1406
|
function useArbiWsTask(docId) {
|
|
1404
1407
|
return useArbiWsStore((s) => s.tasks[docId]);
|
|
1405
1408
|
}
|
|
1406
|
-
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
1407
|
-
"completed",
|
|
1408
|
-
"failed",
|
|
1409
|
-
"skipped",
|
|
1410
|
-
"empty",
|
|
1411
|
-
"low-content"
|
|
1412
|
-
]);
|
|
1413
1409
|
function useArbiDocumentSync(workspaceId) {
|
|
1414
1410
|
const queryClient = useQueryClient();
|
|
1411
|
+
const arbi = useArbi();
|
|
1415
1412
|
useArbiWebSocket((msg) => {
|
|
1416
1413
|
if (!workspaceId) return;
|
|
1417
1414
|
if (isMessageType(msg, "batch_complete")) {
|
|
1418
1415
|
if (msg.workspace_ext_id !== workspaceId) return;
|
|
1419
|
-
void queryClient
|
|
1416
|
+
if (msg.doc_ext_ids?.length) void refreshDocuments(queryClient, arbi, msg.doc_ext_ids);
|
|
1420
1417
|
void queryClient.invalidateQueries({ queryKey: arbiQueryKeys.tags(workspaceId) });
|
|
1421
1418
|
return;
|
|
1422
1419
|
}
|
|
1423
1420
|
if (isMessageType(msg, "task_update")) {
|
|
1424
1421
|
if (msg.workspace_ext_id !== workspaceId) return;
|
|
1425
|
-
if (
|
|
1426
|
-
void queryClient
|
|
1427
|
-
}
|
|
1422
|
+
if (FINISHED_DOCUMENT_STATUSES.has(msg.status))
|
|
1423
|
+
void refreshDocuments(queryClient, arbi, [msg.doc_ext_id]);
|
|
1428
1424
|
}
|
|
1429
1425
|
});
|
|
1430
1426
|
}
|
|
@@ -1566,6 +1562,41 @@ function useArbiShellWorkspaces(options = {}) {
|
|
|
1566
1562
|
select: select ?? defaultSelect
|
|
1567
1563
|
});
|
|
1568
1564
|
}
|
|
1565
|
+
function useInvalidateMembership() {
|
|
1566
|
+
const qc = useQueryClient();
|
|
1567
|
+
return () => Promise.all([
|
|
1568
|
+
qc.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() }),
|
|
1569
|
+
qc.invalidateQueries({ queryKey: ["arbi", "workspaceUsers"] }),
|
|
1570
|
+
qc.invalidateQueries({ queryKey: arbiQueryKeys.projects() }),
|
|
1571
|
+
qc.invalidateQueries({ queryKey: arbiQueryKeys.contacts() })
|
|
1572
|
+
]);
|
|
1573
|
+
}
|
|
1574
|
+
function useUpdateWorkspace() {
|
|
1575
|
+
const arbi = useArbi();
|
|
1576
|
+
const qc = useQueryClient();
|
|
1577
|
+
return useMutation({
|
|
1578
|
+
mutationFn: (body) => arbi.workspaces.update(body),
|
|
1579
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() })
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
function useAddWorkspaceMembers() {
|
|
1583
|
+
const arbi = useArbi();
|
|
1584
|
+
const invalidate = useInvalidateMembership();
|
|
1585
|
+
return useMutation({
|
|
1586
|
+
mutationKey: arbiMutationKeys.workspaceMembership(),
|
|
1587
|
+
mutationFn: ({ emails, role, confirmInvite }) => arbi.workspaces.addUsers(emails, role, { confirmInvite }),
|
|
1588
|
+
onSuccess: () => invalidate()
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
function useRemoveWorkspaceMembers() {
|
|
1592
|
+
const arbi = useArbi();
|
|
1593
|
+
const invalidate = useInvalidateMembership();
|
|
1594
|
+
return useMutation({
|
|
1595
|
+
mutationKey: arbiMutationKeys.workspaceMembership(),
|
|
1596
|
+
mutationFn: (userIds) => arbi.workspaces.removeUsers(userIds),
|
|
1597
|
+
onSuccess: () => invalidate()
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1569
1600
|
function useFacts(workspaceId, options) {
|
|
1570
1601
|
const arbi = useArbi();
|
|
1571
1602
|
const { enabled = true, ...filter } = options ?? {};
|
|
@@ -1619,143 +1650,291 @@ function useSearchFacts() {
|
|
|
1619
1650
|
mutationFn: (body) => arbi.facts.search(body)
|
|
1620
1651
|
});
|
|
1621
1652
|
}
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
if (!current) return;
|
|
1629
|
-
const next = reducer(current);
|
|
1630
|
-
if (next !== current) qc.setQueryData(key, next);
|
|
1653
|
+
var DocumentsSupportContext = createContext({});
|
|
1654
|
+
function DocumentsSupportProvider({
|
|
1655
|
+
support,
|
|
1656
|
+
children
|
|
1657
|
+
}) {
|
|
1658
|
+
return /* @__PURE__ */ jsx(DocumentsSupportContext.Provider, { value: support, children });
|
|
1631
1659
|
}
|
|
1632
|
-
function
|
|
1633
|
-
return
|
|
1660
|
+
function useDocumentsSupport() {
|
|
1661
|
+
return useContext(DocumentsSupportContext);
|
|
1634
1662
|
}
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
]
|
|
1663
|
+
|
|
1664
|
+
// src/documents/documents-writes.ts
|
|
1665
|
+
function applyOptimisticDocumentEdit(qc, updates) {
|
|
1666
|
+
const byId = new Map(updates.map((update) => [update.external_id, update]));
|
|
1667
|
+
const previous = [];
|
|
1668
|
+
patchDocuments(qc, (old) => {
|
|
1669
|
+
let changed = false;
|
|
1670
|
+
const next = old.map((doc) => {
|
|
1671
|
+
const update = byId.get(doc.external_id);
|
|
1672
|
+
if (!update) return doc;
|
|
1673
|
+
changed = true;
|
|
1674
|
+
previous.push(doc);
|
|
1675
|
+
return { ...doc, ...update };
|
|
1676
|
+
});
|
|
1677
|
+
return changed ? next : old;
|
|
1678
|
+
});
|
|
1679
|
+
const previousOwn = updates.map((update) => {
|
|
1680
|
+
const own = qc.getQueryData(
|
|
1681
|
+
arbiQueryKeys.document(update.external_id)
|
|
1682
|
+
);
|
|
1683
|
+
if (own) setCachedDocument(qc, { ...own, ...update });
|
|
1684
|
+
return [update.external_id, own];
|
|
1685
|
+
});
|
|
1686
|
+
return { optimistic: true, previous, previousOwn };
|
|
1687
|
+
}
|
|
1688
|
+
function rollbackOptimisticDocumentEdit(qc, context) {
|
|
1689
|
+
const edit = context;
|
|
1690
|
+
if (!edit?.optimistic) return;
|
|
1691
|
+
if (edit.previous.length) {
|
|
1692
|
+
const restore = new Map(edit.previous.map((doc) => [doc.external_id, doc]));
|
|
1693
|
+
patchDocuments(
|
|
1694
|
+
qc,
|
|
1695
|
+
(old) => old.some((doc) => restore.has(doc.external_id)) ? old.map((doc) => restore.get(doc.external_id) ?? doc) : old
|
|
1696
|
+
);
|
|
1697
|
+
}
|
|
1698
|
+
for (const [id, own] of edit.previousOwn) qc.setQueryData(arbiQueryKeys.document(id), own);
|
|
1640
1699
|
}
|
|
1641
|
-
function
|
|
1642
|
-
|
|
1643
|
-
const
|
|
1644
|
-
|
|
1645
|
-
const workspaceId = openWorkspaceId(arbi);
|
|
1646
|
-
return workspaceId ? invalidateTagData(qc, workspaceId) : Promise.resolve();
|
|
1647
|
-
}, [arbi, qc]);
|
|
1648
|
-
}
|
|
1649
|
-
function settleCreatedTag(qc, created) {
|
|
1650
|
-
const workspaceId = created.workspace_ext_id;
|
|
1651
|
-
patchWorkspaceTags(
|
|
1700
|
+
function settleUpdatedDocuments(qc, updated) {
|
|
1701
|
+
if (!updated.length) return;
|
|
1702
|
+
const byId = new Map(updated.map((doc) => [doc.external_id, doc]));
|
|
1703
|
+
patchDocuments(
|
|
1652
1704
|
qc,
|
|
1653
|
-
|
|
1654
|
-
(old) => old.some((t) => t.external_id === created.external_id) ? old : [...old, created]
|
|
1705
|
+
(old) => old.some((doc) => byId.has(doc.external_id)) ? old.map((doc) => byId.get(doc.external_id) ?? doc) : old
|
|
1655
1706
|
);
|
|
1656
|
-
|
|
1707
|
+
for (const doc of updated) setCachedDocument(qc, doc);
|
|
1657
1708
|
}
|
|
1658
|
-
function
|
|
1659
|
-
const
|
|
1660
|
-
|
|
1709
|
+
function patchEachDocument(qc, docIds, reducer) {
|
|
1710
|
+
const ids = new Set(docIds);
|
|
1711
|
+
patchDocuments(
|
|
1661
1712
|
qc,
|
|
1662
|
-
|
|
1663
|
-
(old) => old.map((t) => t.external_id === tag.external_id ? { ...t, ...tag } : t)
|
|
1713
|
+
(old) => old.some((doc) => ids.has(doc.external_id)) ? old.map((doc) => ids.has(doc.external_id) ? reducer(doc) : doc) : old
|
|
1664
1714
|
);
|
|
1665
|
-
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1715
|
+
for (const id of ids) patchCachedDocument(qc, id, reducer);
|
|
1716
|
+
}
|
|
1717
|
+
function workspaceOf(qc, docId) {
|
|
1718
|
+
for (const [, docs] of qc.getQueriesData({
|
|
1719
|
+
queryKey: arbiQueryKeys.allDocuments()
|
|
1720
|
+
})) {
|
|
1721
|
+
const doc = Array.isArray(docs) ? docs.find((d) => d.external_id === docId) : void 0;
|
|
1722
|
+
if (doc) return doc.workspace_ext_id;
|
|
1723
|
+
}
|
|
1724
|
+
return qc.getQueryData(arbiQueryKeys.document(docId))?.workspace_ext_id;
|
|
1725
|
+
}
|
|
1726
|
+
function settleAssignedDocTags(qc, created) {
|
|
1727
|
+
const byDoc = /* @__PURE__ */ new Map();
|
|
1728
|
+
for (const doctag of created)
|
|
1729
|
+
byDoc.set(doctag.doc_ext_id, [...byDoc.get(doctag.doc_ext_id) ?? [], doctag]);
|
|
1730
|
+
const workspaces = /* @__PURE__ */ new Map();
|
|
1731
|
+
for (const doctag of created) {
|
|
1732
|
+
const workspaceId = workspaceOf(qc, doctag.doc_ext_id);
|
|
1733
|
+
if (!workspaceId) continue;
|
|
1734
|
+
const delta = workspaces.get(workspaceId) ?? /* @__PURE__ */ new Map();
|
|
1735
|
+
delta.set(doctag.tag_ext_id, (delta.get(doctag.tag_ext_id) ?? 0) + 1);
|
|
1736
|
+
workspaces.set(workspaceId, delta);
|
|
1737
|
+
}
|
|
1738
|
+
patchEachDocument(qc, byDoc.keys(), (doc) => ({
|
|
1739
|
+
...doc,
|
|
1740
|
+
doctags: [...doc.doctags ?? [], ...byDoc.get(doc.external_id) ?? []]
|
|
1741
|
+
}));
|
|
1742
|
+
for (const [workspaceId, delta] of workspaces) adjustTagCounts(qc, workspaceId, delta);
|
|
1743
|
+
}
|
|
1744
|
+
function settleRemovedDocTags(qc, { tagId, docIds }) {
|
|
1745
|
+
const ids = new Set(docIds);
|
|
1746
|
+
const removedByWorkspace = /* @__PURE__ */ new Map();
|
|
1747
|
+
for (const [, docs] of qc.getQueriesData({
|
|
1748
|
+
queryKey: arbiQueryKeys.allDocuments()
|
|
1749
|
+
})) {
|
|
1750
|
+
for (const doc of Array.isArray(docs) ? docs : []) {
|
|
1751
|
+
if (!ids.has(doc.external_id)) continue;
|
|
1752
|
+
if (!doc.doctags?.some((dt) => dt.tag_ext_id === tagId)) continue;
|
|
1753
|
+
removedByWorkspace.set(
|
|
1754
|
+
doc.workspace_ext_id,
|
|
1755
|
+
(removedByWorkspace.get(doc.workspace_ext_id) ?? 0) + 1
|
|
1756
|
+
);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
patchEachDocument(qc, ids, (doc) => ({
|
|
1760
|
+
...doc,
|
|
1761
|
+
doctags: (doc.doctags ?? []).filter((dt) => dt.tag_ext_id !== tagId)
|
|
1762
|
+
}));
|
|
1763
|
+
for (const [workspaceId, removed] of removedByWorkspace)
|
|
1764
|
+
adjustTagCounts(qc, workspaceId, /* @__PURE__ */ new Map([[tagId, -removed]]));
|
|
1765
|
+
}
|
|
1766
|
+
function settleUpdatedDocTag(qc, updated) {
|
|
1767
|
+
patchEachDocument(qc, [updated.doc_ext_id], (doc) => ({
|
|
1768
|
+
...doc,
|
|
1769
|
+
doctags: (doc.doctags ?? []).map((dt) => dt.tag_ext_id === updated.tag_ext_id ? updated : dt)
|
|
1770
|
+
}));
|
|
1771
|
+
}
|
|
1772
|
+
var replayableDocumentMutations = [
|
|
1773
|
+
{
|
|
1774
|
+
mutationKey: arbiMutationKeys.updateDocuments(),
|
|
1775
|
+
run: (client, input) => documents.updateDocuments(client, input.documents),
|
|
1776
|
+
settle: (qc, updated) => settleUpdatedDocuments(qc, updated)
|
|
1777
|
+
},
|
|
1778
|
+
{
|
|
1779
|
+
mutationKey: arbiMutationKeys.assignDocTags(),
|
|
1780
|
+
run: (client, input) => doctags.assignDocTags(client, input.tagId, input.docIds, input.note, input.citations),
|
|
1781
|
+
settle: (qc, created) => settleAssignedDocTags(qc, created)
|
|
1782
|
+
},
|
|
1668
1783
|
{
|
|
1669
|
-
mutationKey: arbiMutationKeys.
|
|
1670
|
-
run: (client, input) =>
|
|
1671
|
-
settle: (qc,
|
|
1784
|
+
mutationKey: arbiMutationKeys.removeDocTags(),
|
|
1785
|
+
run: (client, input) => doctags.removeDocTags(client, input.tagId, input.docIds),
|
|
1786
|
+
settle: (qc, _data, input) => settleRemovedDocTags(qc, input)
|
|
1787
|
+
},
|
|
1788
|
+
{
|
|
1789
|
+
mutationKey: arbiMutationKeys.updateDocTag(),
|
|
1790
|
+
run: (client, input) => doctags.updateDocTag(client, input.tagId, input.docId, {
|
|
1791
|
+
note: input.note,
|
|
1792
|
+
citations: input.citations
|
|
1793
|
+
}),
|
|
1794
|
+
settle: (qc, updated) => settleUpdatedDocTag(qc, updated)
|
|
1672
1795
|
}
|
|
1673
1796
|
];
|
|
1674
|
-
function
|
|
1797
|
+
function resolvingOffline(mutation) {
|
|
1798
|
+
const mutateAsync = ((variables, options) => {
|
|
1799
|
+
if (!onlineManager.isOnline()) {
|
|
1800
|
+
mutation.mutate(variables, options);
|
|
1801
|
+
return Promise.resolve(void 0);
|
|
1802
|
+
}
|
|
1803
|
+
return mutation.mutateAsync(variables, options);
|
|
1804
|
+
});
|
|
1805
|
+
return { ...mutation, mutateAsync };
|
|
1806
|
+
}
|
|
1807
|
+
function useUpdateDocuments() {
|
|
1675
1808
|
const arbi = useArbi();
|
|
1676
1809
|
const qc = useQueryClient();
|
|
1677
|
-
return
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1810
|
+
return resolvingOffline(
|
|
1811
|
+
useMutation({
|
|
1812
|
+
mutationKey: arbiMutationKeys.updateDocuments(),
|
|
1813
|
+
mutationFn: ({ documents }) => arbi.documents.update(documents),
|
|
1814
|
+
onMutate: ({ documents }) => onlineManager.isOnline() || !documents.length ? void 0 : applyOptimisticDocumentEdit(qc, documents),
|
|
1815
|
+
onError: (_error, _input, context) => rollbackOptimisticDocumentEdit(qc, context),
|
|
1816
|
+
onSuccess: (updated) => settleUpdatedDocuments(qc, updated)
|
|
1817
|
+
})
|
|
1818
|
+
);
|
|
1682
1819
|
}
|
|
1683
|
-
function
|
|
1820
|
+
function useDeleteDocuments() {
|
|
1684
1821
|
const arbi = useArbi();
|
|
1685
1822
|
const qc = useQueryClient();
|
|
1823
|
+
const { onDocumentsDeleted } = useDocumentsSupport();
|
|
1686
1824
|
return useMutation({
|
|
1687
|
-
mutationKey: arbiMutationKeys.
|
|
1688
|
-
mutationFn: (
|
|
1689
|
-
onSuccess: (
|
|
1825
|
+
mutationKey: arbiMutationKeys.deleteDocuments(),
|
|
1826
|
+
mutationFn: (docIds) => arbi.documents.delete(docIds),
|
|
1827
|
+
onSuccess: (_data, docIds) => {
|
|
1828
|
+
const gone = new Set(docIds);
|
|
1829
|
+
patchDocuments(
|
|
1830
|
+
qc,
|
|
1831
|
+
(old) => old.some((doc) => gone.has(doc.external_id)) ? old.filter((doc) => !gone.has(doc.external_id)) : old
|
|
1832
|
+
);
|
|
1833
|
+
forgetDocuments(qc, docIds);
|
|
1834
|
+
onDocumentsDeleted?.(docIds);
|
|
1835
|
+
return qc.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() });
|
|
1836
|
+
}
|
|
1690
1837
|
});
|
|
1691
1838
|
}
|
|
1692
|
-
function
|
|
1839
|
+
async function settleUpload(qc, arbi, docIds, processingStatus) {
|
|
1840
|
+
if (docIds?.length) await refreshDocuments(qc, arbi, docIds, { processingStatus });
|
|
1841
|
+
await qc.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() });
|
|
1842
|
+
}
|
|
1843
|
+
function useUploadDocuments() {
|
|
1693
1844
|
const arbi = useArbi();
|
|
1694
1845
|
const qc = useQueryClient();
|
|
1846
|
+
const { processingStatus } = useDocumentsSupport();
|
|
1695
1847
|
return useMutation({
|
|
1696
|
-
mutationKey: arbiMutationKeys.
|
|
1697
|
-
mutationFn: ({
|
|
1698
|
-
|
|
1699
|
-
values
|
|
1700
|
-
}) => arbi.tags.setValues(tagId, values),
|
|
1701
|
-
onSuccess: (tag) => settleChangedTag(qc, tag)
|
|
1848
|
+
mutationKey: arbiMutationKeys.uploadDocuments(),
|
|
1849
|
+
mutationFn: ({ files, options }) => arbi.documents.upload(files, options),
|
|
1850
|
+
onSuccess: (result) => settleUpload(qc, arbi, result.doc_ext_ids, processingStatus)
|
|
1702
1851
|
});
|
|
1703
1852
|
}
|
|
1704
|
-
function
|
|
1853
|
+
function useUploadUrls() {
|
|
1705
1854
|
const arbi = useArbi();
|
|
1706
1855
|
const qc = useQueryClient();
|
|
1856
|
+
const { processingStatus } = useDocumentsSupport();
|
|
1707
1857
|
return useMutation({
|
|
1708
|
-
mutationKey: arbiMutationKeys.
|
|
1709
|
-
mutationFn: (
|
|
1710
|
-
onSuccess: (
|
|
1711
|
-
const workspaceId = openWorkspaceId(arbi);
|
|
1712
|
-
if (!workspaceId) return;
|
|
1713
|
-
patchWorkspaceTags(
|
|
1714
|
-
qc,
|
|
1715
|
-
workspaceId,
|
|
1716
|
-
(old) => old.filter((t) => t.external_id !== tagId).map((t) => t.parent_ext_id === tagId ? { ...t, parent_ext_id: null } : t)
|
|
1717
|
-
);
|
|
1718
|
-
return Promise.all([
|
|
1719
|
-
invalidateTagTables(qc, workspaceId),
|
|
1720
|
-
qc.invalidateQueries({ queryKey: arbiQueryKeys.facts(workspaceId) })
|
|
1721
|
-
]);
|
|
1722
|
-
}
|
|
1858
|
+
mutationKey: arbiMutationKeys.uploadUrls(),
|
|
1859
|
+
mutationFn: ({ urls, shared, configExtId }) => arbi.documents.uploadUrl(urls, { shared, configExtId }),
|
|
1860
|
+
onSuccess: (result) => settleUpload(qc, arbi, result.doc_ext_ids, processingStatus)
|
|
1723
1861
|
});
|
|
1724
1862
|
}
|
|
1725
|
-
function
|
|
1863
|
+
function useAssignDocTags() {
|
|
1726
1864
|
const arbi = useArbi();
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1865
|
+
const qc = useQueryClient();
|
|
1866
|
+
return resolvingOffline(
|
|
1867
|
+
useMutation({
|
|
1868
|
+
mutationKey: arbiMutationKeys.assignDocTags(),
|
|
1869
|
+
mutationFn: ({ tagId, docIds, note, citations }) => arbi.doctags.assign(tagId, docIds, note, citations),
|
|
1870
|
+
onSuccess: (created) => settleAssignedDocTags(qc, created)
|
|
1871
|
+
})
|
|
1872
|
+
);
|
|
1731
1873
|
}
|
|
1732
|
-
function
|
|
1874
|
+
function useRemoveDocTags() {
|
|
1733
1875
|
const arbi = useArbi();
|
|
1734
|
-
const
|
|
1735
|
-
return
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1876
|
+
const qc = useQueryClient();
|
|
1877
|
+
return resolvingOffline(
|
|
1878
|
+
useMutation({
|
|
1879
|
+
mutationKey: arbiMutationKeys.removeDocTags(),
|
|
1880
|
+
mutationFn: ({ tagId, docIds }) => arbi.doctags.remove(tagId, docIds),
|
|
1881
|
+
onSuccess: (_data, input) => settleRemovedDocTags(qc, input)
|
|
1882
|
+
})
|
|
1883
|
+
);
|
|
1884
|
+
}
|
|
1885
|
+
function useUpdateDocTag() {
|
|
1886
|
+
const arbi = useArbi();
|
|
1887
|
+
const qc = useQueryClient();
|
|
1888
|
+
return resolvingOffline(
|
|
1889
|
+
useMutation({
|
|
1890
|
+
mutationKey: arbiMutationKeys.updateDocTag(),
|
|
1891
|
+
mutationFn: ({ tagId, docId, note, citations }) => arbi.doctags.update(tagId, docId, { note, citations }),
|
|
1892
|
+
onSuccess: (updated) => settleUpdatedDocTag(qc, updated)
|
|
1893
|
+
})
|
|
1894
|
+
);
|
|
1895
|
+
}
|
|
1896
|
+
function useGenerateDocTags() {
|
|
1897
|
+
const arbi = useArbi();
|
|
1898
|
+
const qc = useQueryClient();
|
|
1899
|
+
const { onProcessingQueued } = useDocumentsSupport();
|
|
1900
|
+
return useMutation({
|
|
1901
|
+
mutationKey: arbiMutationKeys.generateDocTags(),
|
|
1902
|
+
mutationFn: ({ tagIds, docIds, overwrite }) => arbi.doctags.generate(tagIds, docIds, { overwrite }),
|
|
1903
|
+
onMutate: ({ docIds }) => {
|
|
1904
|
+
if (!onProcessingQueued || !docIds.length) return void 0;
|
|
1905
|
+
const workspaceId = arbi.hasWorkspace ? arbi.getWorkspaceId() : "";
|
|
1906
|
+
const listed = new Map(
|
|
1907
|
+
(getCachedDocuments(qc, workspaceId) ?? []).map((doc) => [doc.external_id, doc])
|
|
1908
|
+
);
|
|
1909
|
+
return {
|
|
1910
|
+
undo: onProcessingQueued(
|
|
1911
|
+
docIds.map((docId) => ({
|
|
1912
|
+
docId,
|
|
1913
|
+
workspaceId,
|
|
1914
|
+
fileName: listed.get(docId)?.file_name ?? "",
|
|
1915
|
+
version: listed.get(docId)?.current_version ?? 1
|
|
1916
|
+
}))
|
|
1917
|
+
)
|
|
1918
|
+
};
|
|
1919
|
+
},
|
|
1920
|
+
onError: (_error, _input, context) => context?.undo()
|
|
1739
1921
|
});
|
|
1740
1922
|
}
|
|
1741
|
-
function
|
|
1923
|
+
function useFinaliseTranslation() {
|
|
1742
1924
|
const arbi = useArbi();
|
|
1743
1925
|
const qc = useQueryClient();
|
|
1926
|
+
const { processingStatus } = useDocumentsSupport();
|
|
1744
1927
|
return useMutation({
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
kind,
|
|
1748
|
-
fields
|
|
1749
|
-
}) => arbi.tagKinds.update(kind, fields),
|
|
1750
|
-
onSuccess: (schema) => {
|
|
1751
|
-
const workspaceId = openWorkspaceId(arbi);
|
|
1752
|
-
if (!workspaceId) return;
|
|
1753
|
-
qc.setQueryData(arbiQueryKeys.tagKind(workspaceId, schema.kind), schema);
|
|
1754
|
-
return invalidateTagData(qc, workspaceId);
|
|
1755
|
-
}
|
|
1928
|
+
mutationFn: (docId) => arbi.documents.finaliseTranslation(docId),
|
|
1929
|
+
onSuccess: (result) => void refreshDocuments(qc, arbi, [result.document_ext_id], { processingStatus })
|
|
1756
1930
|
});
|
|
1757
1931
|
}
|
|
1758
|
-
|
|
1932
|
+
|
|
1933
|
+
// src/offline.ts
|
|
1934
|
+
var REPLAYABLE = [
|
|
1935
|
+
...replayableTagMutations,
|
|
1936
|
+
...replayableDocumentMutations
|
|
1937
|
+
];
|
|
1759
1938
|
function isReplayableArbiMutation(mutationKey) {
|
|
1760
1939
|
return !!mutationKey && REPLAYABLE.some((m) => partialMatchKey(mutationKey, m.mutationKey));
|
|
1761
1940
|
}
|
|
@@ -1767,6 +1946,25 @@ function registerArbiMutationDefaults(queryClient, client) {
|
|
|
1767
1946
|
});
|
|
1768
1947
|
}
|
|
1769
1948
|
}
|
|
1949
|
+
var OFFLINE_READABLE = [
|
|
1950
|
+
"documents",
|
|
1951
|
+
"document",
|
|
1952
|
+
"documentsById",
|
|
1953
|
+
"documentVersions",
|
|
1954
|
+
"similarDocuments"
|
|
1955
|
+
];
|
|
1956
|
+
function isOfflineReadableArbiQuery(queryKey) {
|
|
1957
|
+
return queryKey[0] === "arbi" && OFFLINE_READABLE.includes(queryKey[1]);
|
|
1958
|
+
}
|
|
1959
|
+
function isRestorableArbiQueryOnline(queryKey, data) {
|
|
1960
|
+
if (queryKey[0] !== "arbi") return true;
|
|
1961
|
+
if (queryKey[1] === "documents") return false;
|
|
1962
|
+
const docs = Array.isArray(data) ? data : [data];
|
|
1963
|
+
return !docs.some((doc) => {
|
|
1964
|
+
const status = doc?.status;
|
|
1965
|
+
return !!status && !FINISHED_DOCUMENT_STATUSES.has(status);
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1770
1968
|
function useFilteredProjects(filters, options) {
|
|
1771
1969
|
const arbi = useArbi();
|
|
1772
1970
|
return useQuery({
|
|
@@ -2262,6 +2460,34 @@ function usePasswordChangeForm({
|
|
|
2262
2460
|
}
|
|
2263
2461
|
};
|
|
2264
2462
|
}
|
|
2463
|
+
function useUserSettings(options) {
|
|
2464
|
+
const arbi = useArbi();
|
|
2465
|
+
return useQuery({
|
|
2466
|
+
queryKey: arbiQueryKeys.userSettings(),
|
|
2467
|
+
queryFn: () => arbi.settings.get(),
|
|
2468
|
+
enabled: (options?.enabled ?? true) && arbi.isLoggedIn
|
|
2469
|
+
});
|
|
2470
|
+
}
|
|
2471
|
+
function useUpdateUserSettings() {
|
|
2472
|
+
const arbi = useArbi();
|
|
2473
|
+
const qc = useQueryClient();
|
|
2474
|
+
return useMutation({
|
|
2475
|
+
mutationFn: (patch) => arbi.settings.update(patch),
|
|
2476
|
+
onMutate: async (patch) => {
|
|
2477
|
+
await qc.cancelQueries({ queryKey: arbiQueryKeys.userSettings() });
|
|
2478
|
+
const previous = qc.getQueryData(arbiQueryKeys.userSettings());
|
|
2479
|
+
qc.setQueryData(
|
|
2480
|
+
arbiQueryKeys.userSettings(),
|
|
2481
|
+
(old) => old ? { ...old, ...patch } : old
|
|
2482
|
+
);
|
|
2483
|
+
return { previous };
|
|
2484
|
+
},
|
|
2485
|
+
onError: (_err, _patch, context) => {
|
|
2486
|
+
qc.setQueryData(arbiQueryKeys.userSettings(), context?.previous);
|
|
2487
|
+
},
|
|
2488
|
+
onSettled: () => qc.invalidateQueries({ queryKey: arbiQueryKeys.userSettings() })
|
|
2489
|
+
});
|
|
2490
|
+
}
|
|
2265
2491
|
function toNotificationPreferences(stored, keys) {
|
|
2266
2492
|
const checked = Object.fromEntries(keys.map((key) => [key, stored?.[key] ?? true]));
|
|
2267
2493
|
return {
|
|
@@ -2271,14 +2497,6 @@ function toNotificationPreferences(stored, keys) {
|
|
|
2271
2497
|
categoryPatch: (key, value) => ({ [key]: value })
|
|
2272
2498
|
};
|
|
2273
2499
|
}
|
|
2274
|
-
function useUserSettings(options) {
|
|
2275
|
-
const arbi = useArbi();
|
|
2276
|
-
return useQuery({
|
|
2277
|
-
queryKey: arbiQueryKeys.userSettings(),
|
|
2278
|
-
queryFn: () => arbi.settings.get(),
|
|
2279
|
-
enabled: (options?.enabled ?? true) && arbi.isLoggedIn
|
|
2280
|
-
});
|
|
2281
|
-
}
|
|
2282
2500
|
function useNotificationPreferences(keys, options) {
|
|
2283
2501
|
const arbi = useArbi();
|
|
2284
2502
|
const qc = useQueryClient();
|
|
@@ -7791,13 +8009,6 @@ function DocumentCardMenu({
|
|
|
7791
8009
|
testId = "document-card-menu"
|
|
7792
8010
|
}) {
|
|
7793
8011
|
const arbi = useArbi();
|
|
7794
|
-
const queryClient = useQueryClient();
|
|
7795
|
-
const invalidateDocuments = () => {
|
|
7796
|
-
const workspaceId = arbi.getWorkspaceId();
|
|
7797
|
-
if (workspaceId) {
|
|
7798
|
-
void queryClient.invalidateQueries({ queryKey: arbiQueryKeys.documents(workspaceId) });
|
|
7799
|
-
}
|
|
7800
|
-
};
|
|
7801
8012
|
const download = useMutation({
|
|
7802
8013
|
mutationFn: async () => {
|
|
7803
8014
|
const response = await arbi.documents.download(docId);
|
|
@@ -7813,10 +8024,7 @@ function DocumentCardMenu({
|
|
|
7813
8024
|
URL.revokeObjectURL(url);
|
|
7814
8025
|
}
|
|
7815
8026
|
});
|
|
7816
|
-
const remove =
|
|
7817
|
-
mutationFn: () => arbi.documents.delete([docId]),
|
|
7818
|
-
onSuccess: invalidateDocuments
|
|
7819
|
-
});
|
|
8027
|
+
const remove = useDeleteDocuments();
|
|
7820
8028
|
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
7821
8029
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
7822
8030
|
"button",
|
|
@@ -7855,7 +8063,7 @@ function DocumentCardMenu({
|
|
|
7855
8063
|
/* @__PURE__ */ jsxs(
|
|
7856
8064
|
DropdownMenuItem,
|
|
7857
8065
|
{
|
|
7858
|
-
onSelect: () => remove.mutate(),
|
|
8066
|
+
onSelect: () => remove.mutate([docId]),
|
|
7859
8067
|
disabled: remove.isPending,
|
|
7860
8068
|
className: "text-destructive focus:text-destructive",
|
|
7861
8069
|
"data-testid": `${testId}-delete`,
|
|
@@ -7934,21 +8142,14 @@ function DocumentGallery({
|
|
|
7934
8142
|
},
|
|
7935
8143
|
[onOpenDocument, session]
|
|
7936
8144
|
);
|
|
7937
|
-
const arbi = useArbi();
|
|
7938
|
-
const queryClient = useQueryClient();
|
|
7939
8145
|
const [renamingId, setRenamingId] = React.useState(null);
|
|
7940
|
-
const
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
if (activeWorkspace) {
|
|
7948
|
-
void queryClient.invalidateQueries({ queryKey: arbiQueryKeys.documents(activeWorkspace) });
|
|
7949
|
-
}
|
|
7950
|
-
}
|
|
7951
|
-
});
|
|
8146
|
+
const update = useUpdateDocuments();
|
|
8147
|
+
const rename = (doc, title) => update.mutate(
|
|
8148
|
+
{
|
|
8149
|
+
documents: [{ external_id: doc.external_id, doc_metadata: { ...doc.doc_metadata, title } }]
|
|
8150
|
+
},
|
|
8151
|
+
{ onSettled: () => setRenamingId(null) }
|
|
8152
|
+
);
|
|
7952
8153
|
if (isLoading) {
|
|
7953
8154
|
return /* @__PURE__ */ jsx(
|
|
7954
8155
|
"div",
|
|
@@ -7997,7 +8198,7 @@ function DocumentGallery({
|
|
|
7997
8198
|
viewing: viewingDocId === id,
|
|
7998
8199
|
onOpen: () => openDocument(id),
|
|
7999
8200
|
renaming: renamingId === id,
|
|
8000
|
-
onCommitRename: (newTitle) => rename
|
|
8201
|
+
onCommitRename: (newTitle) => rename(doc, newTitle),
|
|
8001
8202
|
onCancelRename: () => setRenamingId(null),
|
|
8002
8203
|
actions: /* @__PURE__ */ jsx(
|
|
8003
8204
|
DocumentCardMenu,
|
|
@@ -8561,6 +8762,6 @@ function hasVideoTrack(blob) {
|
|
|
8561
8762
|
});
|
|
8562
8763
|
}
|
|
8563
8764
|
|
|
8564
|
-
export { ALLOWED_PORTAL_ORIGINS, AccountClientProvider, ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotIcon, ArbiSessionStateProvider, ArbiWebSocketProvider, ArtifactCanvas, BOX_SEAT_REFUSED, BOX_SEAT_REFUSED_ACTION, BOX_SEAT_REFUSED_TITLE, CalendarSupportProvider, ChatBubble, CitationRenderer, ClaudeIcon, CommandPalette, CommandPaletteProvider, ConversationList, DEFAULT_ASPECT_OPTIONS, DEFAULT_PASSWORD_CHANGE_FORM_MESSAGES, DEFAULT_START_BY_EMAIL_LABELS, DateSeparator, DirectMessages, DmAvatar, DmComposer, DocQaPanel, DocSearch, DocumentCardMenu, DocumentGallery, DocumentReview, DocumentTable, DraftTitleControls, EMPTY_SESSION_STATE, FileIcon, FireworksIcon, GeminiIcon, GitHubIcon, GoogleIcon, ImageCropModal, ImageCropper, LinkedInIcon, MAIL_DRAFT_REPLACED_EVENT, MAX_AVATAR_FILE_BYTES, MailClientProvider, MailOfflineUnavailableError, MessageArtifactCard, MessageBubble, MessageThread, OpenAIIcon, PhotoCapture, ProviderIcon, RUN_WINDOW_MS, SIGNATURE_NOTIFICATION_TYPES, SemanticSearch, StartByEmail, TypingIndicator, VideoCapture, VoiceNoteRecorder, WORK_NOTIFICATION_LABELS, accountPath, aliasTakenMessage, annotateThread, announceMailDraftReplaced, arbiAccountClient, arbiMailClient, calendarQueryKeys, callNotificationMeta, captureFrameAsBlob, connectOAuthCalendarAccount, createArbiSessionStore, createMailClient, cropImage, dayKey, defaultMailAlias, deploymentUserMeta, describeActivity, describeServerNotification, documentActivityMeta, documentActivityPhrase, documentDisplayName, docxMentionMeta, downloadRecoveryFile, fileAttachment, formatIdentityPrice, getNotificationTypeMeta, getWorkspaceActionText, getWorkspaceKind, getWorkspaceSentPhrase, hasVideoTrack, identityStepFor, inputRequestTitle, invalidateCalendarEvents, invalidateCalendars,
|
|
8765
|
+
export { ALLOWED_PORTAL_ORIGINS, AccountClientProvider, ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotIcon, ArbiSessionStateProvider, ArbiWebSocketProvider, ArtifactCanvas, BOX_SEAT_REFUSED, BOX_SEAT_REFUSED_ACTION, BOX_SEAT_REFUSED_TITLE, CalendarSupportProvider, ChatBubble, CitationRenderer, ClaudeIcon, CommandPalette, CommandPaletteProvider, ConversationList, DEFAULT_ASPECT_OPTIONS, DEFAULT_PASSWORD_CHANGE_FORM_MESSAGES, DEFAULT_START_BY_EMAIL_LABELS, DateSeparator, DirectMessages, DmAvatar, DmComposer, DocQaPanel, DocSearch, DocumentCardMenu, DocumentGallery, DocumentReview, DocumentTable, DocumentsSupportProvider, DraftTitleControls, EMPTY_SESSION_STATE, FileIcon, FireworksIcon, GeminiIcon, GitHubIcon, GoogleIcon, ImageCropModal, ImageCropper, LinkedInIcon, MAIL_DRAFT_REPLACED_EVENT, MAX_AVATAR_FILE_BYTES, MailClientProvider, MailOfflineUnavailableError, MessageArtifactCard, MessageBubble, MessageThread, OpenAIIcon, PhotoCapture, ProviderIcon, RUN_WINDOW_MS, SIGNATURE_NOTIFICATION_TYPES, SemanticSearch, StartByEmail, TypingIndicator, VideoCapture, VoiceNoteRecorder, WORK_NOTIFICATION_LABELS, accountPath, aliasTakenMessage, annotateThread, announceMailDraftReplaced, applyOptimisticDocumentEdit, arbiAccountClient, arbiMailClient, calendarQueryKeys, callNotificationMeta, captureFrameAsBlob, connectOAuthCalendarAccount, createArbiSessionStore, createMailClient, cropImage, dayKey, defaultMailAlias, deploymentUserMeta, describeActivity, describeServerNotification, documentActivityMeta, documentActivityPhrase, documentDisplayName, docxMentionMeta, downloadRecoveryFile, fileAttachment, formatIdentityPrice, getNotificationTypeMeta, getWorkspaceActionText, getWorkspaceKind, getWorkspaceSentPhrase, hasVideoTrack, identityStepFor, inputRequestTitle, invalidateCalendarEvents, invalidateCalendars, isAliasTakenError, isDeploymentAdmin, isDeploymentUserNotification, isOfflineReadableArbiQuery, isQueuedCalendarWrite, isReplayableArbiMutation, isRestorableArbiQueryOnline, isSignatureNotificationType, isWorkspaceNotificationType, mailDraftIdFromContent, mailJson, mailQueryKeys, mountDiditVerification, nextAliasSuggestion, nextViewingDocument, notificationUserName, parseActivityContent, parseDeleteAccountBlockers, pickRecentWorkspaces, redlineStats, registerArbiMutationDefaults, resetCalendarAccountSyncState, resolveActiveWorkspace, rollbackOptimisticDocumentEdit, safePortalUrl, selectIsGenerating, selectViewingDocumentId, signatureNotificationPhrase, signatureRequestMeta, supportsHouseTemplates, textToArtifact, titleFromQuestion, toChatCitations, toNotificationPreferences, toProfileView, toRedlineMarkdown, toShellWorkspace, useAccountClient, useActOnStep, useAddHolidayCalendar, useAddWorkspaceMembers, useAgentChats, useAgentConfig, useAgentModels, useAgentSession, useAgentWorkspaces, useAiTask, useAppPasswords, useArbiChat, useArbiConnected, useArbiDocumentSync, useArbiSessionState, useArbiSessionStore, useArbiShellWorkspaces, useArbiWebSocket, useArbiWsContext, useArbiWsMessage, useArbiWsStatus, useArbiWsStore, useArbiWsTask, useArbiWsTasks, useAssignDocTags, useAuthorizeLimits, useAvatarCrop, useBookingPages, useCalDavProfiles, useCalendarAccounts, useCalendarEvent, useCalendarEventByUid, useCalendarEvents, useCalendarInvitations, useCalendarOutbox, useCalendarOverlays, useCalendarSettings, useCalendarShares, useCalendarSupport, useCalendars, useCameraStream, useClaimNativeAlias, useCloseAgentSession, useCommandPalette, useConfirmEmailChange, useConnectCalDavAccount, useConnectMailAccount, useConnectOAuthAccount, useContacts, useConversationActivity, useConversationPendingAuth, useConversationUsage, useCreateAgent, useCreateAppPassword, useCreateCalendar, useCreateContact, useCreateEvent, useCreateFact, useCreateFacts, useCreateFeed, useCreateRoom, useCreateWork, useCreateWorkflow, useCurrentSessionId, useDecideCounter, useDeleteAccount, useDeleteAccountFlow, useDeleteBookingPage, useDeleteCalendar, useDeleteContact, useDeleteDocuments, useDeleteEvent, useDeleteFact, useDeleteNotifications, useDeleteSkill, useDeleteWorkflow, useDirectMessages, useDisconnectCalendarAccount, useDisconnectMailAccount, useDocumentsSupport, useEmailChange, useFacts, useFetchCalendarEvent, useFilteredProjects, useFinaliseTranslation, useFindTime, useFollowThread, useFreeBusy, useGenerateAgentAvatar, useGenerateDocTags, useGrantAgentAccess, useHolidayCountries, useHouseTemplateCandidates, useIdentityVerification, useIdentityVerificationFlow, useImportCalendar, useInviteContacts, useMailAccounts, useMailAttachmentText, useMailCache, useMailClient, useMailDraftCompose, useMailDraftEditor, useMailDraftReplaced, useMailFolders, useMailMessage, useMailMessages, useMailOnline, useMailPolicy, useMailProjects, useMailUnlock, useMarkNotificationsRead, useMcpTools, useMoveEvent, useNameEditor, useNotificationPreferences, useNotifications, usePasswordChange, usePasswordChangeForm, usePendingContacts, usePlanWork, useProfile, useProjectConversationUsage, useProjectEvents, usePublishCalendar, useRefreshCalendar, useRemoveDocTags, useRemoveWorkspaceMembers, useRequestEmailChange, useRespondToEvent, useResumeCalendarAccountConnect, useRevokeAgentAccess, useRevokeAppPassword, useRooms, useRunConversation, useRunWorkflow, useSaveAgentConfig, useSaveBookingPage, useSaveCalendarSettings, useSaveMailDraft, useSearchContacts, useSearchFacts, useSemanticSearch, useSendBackStep, useSendMail, useSessions, useSetSkillVisibility, useSetWorkspaceHouseTemplate, useShareCalendar, useShellWorkspaces, useSignOut, useSkillSource, useSkills, useStartAgentSession, useStartCalendarAccountOAuth, useStartWorkQuery, useSubscribeCalendar, useSyncAccountsOnOpen, useSyncCalendarAccount, useTerminateSession, useUnshareCalendar, useUpdateCalendar, useUpdateCalendarAccount, useUpdateContact, useUpdateConversation, useUpdateDocTag, useUpdateDocuments, useUpdateEvent, useUpdateFact, useUpdateMailMessage, useUpdateProfile, useUpdateProjectFields, useUpdateUserSettings, useUpdateWorkflow, useUpdateWorkspace, useUploadDocuments, useUploadSkillFiles, useUploadUrls, useUserSettings, useVideoRecorder, useWorkNotifications, useWorkflowRuns, useWorkflows, useWorkspaceDocs, useWorkspaceNotificationLevel, userDisplayName, userInitials, workflowStepOf, workspaceHouseTemplateId };
|
|
8565
8766
|
//# sourceMappingURL=index.js.map
|
|
8566
8767
|
//# sourceMappingURL=index.js.map
|