@arbidocs/react 0.4.83 → 0.4.85
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/README.md +3 -0
- package/dist/artifacts/index.cjs +9 -9
- package/dist/artifacts/index.js +2 -2
- package/dist/{chunk-WBYNKFUO.js → chunk-BUFDJCDS.js} +3 -3
- package/dist/chunk-BUFDJCDS.js.map +1 -0
- package/dist/{chunk-PXHRLAOX.cjs → chunk-E26JGYT4.cjs} +40 -29
- package/dist/chunk-E26JGYT4.cjs.map +1 -0
- package/dist/{chunk-2JPBOZIH.js → chunk-KYCCIEXA.js} +18 -7
- package/dist/chunk-KYCCIEXA.js.map +1 -0
- package/dist/{chunk-IIT7DMQL.cjs → chunk-XIDDXD5Y.cjs} +3 -2
- package/dist/chunk-XIDDXD5Y.cjs.map +1 -0
- package/dist/document-tools/index.cjs +36 -10
- package/dist/document-tools/index.cjs.map +1 -1
- package/dist/document-tools/index.d.cts +21 -3
- package/dist/document-tools/index.d.ts +21 -3
- package/dist/document-tools/index.js +35 -10
- package/dist/document-tools/index.js.map +1 -1
- package/dist/index.cjs +562 -176
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +331 -31
- package/dist/index.d.ts +331 -31
- package/dist/index.js +374 -18
- package/dist/index.js.map +1 -1
- package/dist/viewers/index.cjs +2 -2
- package/dist/viewers/index.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-2JPBOZIH.js.map +0 -1
- package/dist/chunk-IIT7DMQL.cjs.map +0 -1
- package/dist/chunk-PXHRLAOX.cjs.map +0 -1
- package/dist/chunk-WBYNKFUO.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { arbiQueryKeys, useDocuments, useConversations, useAssistantQuery, useConversationThreads, useWorkspaces, useParsedDocument, useTags, useActivity, useThumbnails } from './chunk-
|
|
2
|
-
export { DEFAULT_USD_PER_CREDIT, arbiQueryKeys, creditsToUsd, formatCredits, isUsageMetered, useActivity, useAgents, useAssistantQuery, useConfigs, useConversationThreads, useConversations, useDeleteAgents, useDocuments, useFacts, useHealth, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSessions, useTags, useThumbnails, useUserUsageToday, useWorkspaceUsers, useWorkspaces } from './chunk-
|
|
1
|
+
import { arbiQueryKeys, useDocuments, useConversations, useAssistantQuery, useConversationThreads, useWorkspaces, useParsedDocument, useTags, useActivity, useThumbnails } from './chunk-KYCCIEXA.js';
|
|
2
|
+
export { DEFAULT_USD_PER_CREDIT, arbiQueryKeys, creditsToUsd, formatCredits, isUsageMetered, useActivity, useAgents, useAssistantQuery, useConfigs, useConversationThreads, useConversations, useDeleteAgents, useDocuments, useFacts, useHealth, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSessions, useTags, useThumbnails, useUserUsageToday, useWorkspaceUsers, useWorkspaces } from './chunk-KYCCIEXA.js';
|
|
3
3
|
export { cleanDraftMarkdown, cleanDraftWithReport, promoteBoldTitle, repairParsedStructure, repairParsedTitle, stripAgentPreamble, unescapeMarkdown, unwrapCitationLinks } from './chunk-G6FHNURH.js';
|
|
4
4
|
import { formatRelativeTime } from './chunk-ECOSGMTW.js';
|
|
5
5
|
export { DEFAULT_NOTIFY_TONE, NotificationBell, Toaster, formatRelativeTime, notify, seedNotifications, selectUnread, toast, useNotify } from './chunk-ECOSGMTW.js';
|
|
@@ -18,10 +18,10 @@ export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMe
|
|
|
18
18
|
import { cn } from './chunk-SN5YV6FF.js';
|
|
19
19
|
export { cn } from './chunk-SN5YV6FF.js';
|
|
20
20
|
import { AudioViewer, ImageViewer, VideoViewer } from './chunk-HDCRPPBW.js';
|
|
21
|
-
import { useArbi } from './chunk-
|
|
22
|
-
export { ArbiProvider, useArbi, useDeploymentDomain } from './chunk-
|
|
23
|
-
import React, { memo, useState, createContext, useMemo, useCallback, useEffect, useRef, useLayoutEffect, useContext, useId, Fragment as Fragment$1 } from 'react';
|
|
24
|
-
import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
|
|
21
|
+
import { useArbi, ArbiContext } from './chunk-BUFDJCDS.js';
|
|
22
|
+
export { ArbiProvider, useArbi, useDeploymentDomain } from './chunk-BUFDJCDS.js';
|
|
23
|
+
import React, { memo, useState, createContext, useMemo, useCallback, useEffect, useRef, useLayoutEffect, useContext, useId, useSyncExternalStore, Fragment as Fragment$1 } from 'react';
|
|
24
|
+
import { useQueryClient, useMutation, useQuery, onlineManager } from '@tanstack/react-query';
|
|
25
25
|
import { resolveCitations, summarizeCitations, formatFileSize, connectWithReconnect, dm, identityErrorCode } from '@arbidocs/sdk/browser';
|
|
26
26
|
export { Arbi, ArbiError } from '@arbidocs/sdk/browser';
|
|
27
27
|
import { Link, Trash2, CheckCheck, Check, Loader2, AlertTriangle, ShieldCheck, Copy, Sparkles, FileText, GitCompareArrows, Download, Image as Image$1, Search, CornerDownLeft, X, ArrowLeft, Send, Tags, Crown, Info, Activity, Gauge, Gift, PartyPopper, UserCheck, AtSign, MessageCircleMore, FileX2, FileCheck2, Pencil, FolderPlus, SquareArrowOutUpRight, MessagesSquare, Paperclip, ArrowRight, MoreHorizontal, SquarePen, Mic, Pause, Play, Square, RotateCcw, Camera, Circle } from 'lucide-react';
|
|
@@ -1480,7 +1480,6 @@ function useArbiShellWorkspaces(options = {}) {
|
|
|
1480
1480
|
select: select ?? defaultSelect
|
|
1481
1481
|
});
|
|
1482
1482
|
}
|
|
1483
|
-
var selectionKey = (selection) => !selection ? "" : "parentId" in selection ? `parent:${selection.parentId}` : `tags:${selection.tagIds.join(",")}`;
|
|
1484
1483
|
function invalidateTagData(qc, workspaceId) {
|
|
1485
1484
|
return Promise.all([
|
|
1486
1485
|
qc.invalidateQueries({ queryKey: arbiQueryKeys.tags(workspaceId) }),
|
|
@@ -1495,26 +1494,39 @@ function useInvalidateTagData() {
|
|
|
1495
1494
|
return workspaceId ? invalidateTagData(qc, workspaceId) : Promise.resolve();
|
|
1496
1495
|
}, [arbi, qc]);
|
|
1497
1496
|
}
|
|
1498
|
-
function
|
|
1497
|
+
function useTagKindSchema(kind, options) {
|
|
1499
1498
|
const arbi = useArbi();
|
|
1500
1499
|
const workspaceId = arbi.getWorkspaceId() ?? "";
|
|
1501
|
-
const key = selectionKey(selection);
|
|
1502
|
-
const hasSelection = !!selection && ("parentId" in selection ? !!selection.parentId : selection.tagIds.length > 0);
|
|
1503
1500
|
return useQuery({
|
|
1504
|
-
queryKey: arbiQueryKeys.
|
|
1505
|
-
queryFn: () => arbi.
|
|
1506
|
-
enabled: (options?.enabled ?? true) &&
|
|
1501
|
+
queryKey: arbiQueryKeys.tagKind(workspaceId, kind ?? ""),
|
|
1502
|
+
queryFn: () => arbi.tagKinds.get(kind),
|
|
1503
|
+
enabled: (options?.enabled ?? true) && !!kind && !!workspaceId && arbi.hasWorkspace
|
|
1507
1504
|
});
|
|
1508
1505
|
}
|
|
1509
|
-
function
|
|
1506
|
+
function useUpdateTagKindSchema() {
|
|
1507
|
+
const arbi = useArbi();
|
|
1508
|
+
const qc = useQueryClient();
|
|
1509
|
+
return useMutation({
|
|
1510
|
+
mutationFn: ({
|
|
1511
|
+
kind,
|
|
1512
|
+
fields
|
|
1513
|
+
}) => arbi.tagKinds.update(kind, fields),
|
|
1514
|
+
onSuccess: (schema) => {
|
|
1515
|
+
const workspaceId = arbi.getWorkspaceId();
|
|
1516
|
+
if (!workspaceId) return;
|
|
1517
|
+
qc.setQueryData(arbiQueryKeys.tagKind(workspaceId, schema.kind), schema);
|
|
1518
|
+
return invalidateTagData(qc, workspaceId);
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
function useSetTagValues() {
|
|
1510
1523
|
const arbi = useArbi();
|
|
1511
1524
|
const qc = useQueryClient();
|
|
1512
1525
|
return useMutation({
|
|
1513
1526
|
mutationFn: ({
|
|
1514
1527
|
tagId,
|
|
1515
|
-
fields,
|
|
1516
1528
|
values
|
|
1517
|
-
}) => arbi.tags.
|
|
1529
|
+
}) => arbi.tags.setValues(tagId, values),
|
|
1518
1530
|
onSuccess: (tag) => invalidateTagData(qc, tag.workspace_ext_id)
|
|
1519
1531
|
});
|
|
1520
1532
|
}
|
|
@@ -2314,6 +2326,349 @@ function useIdentityVerification(options = {}) {
|
|
|
2314
2326
|
}
|
|
2315
2327
|
});
|
|
2316
2328
|
}
|
|
2329
|
+
|
|
2330
|
+
// src/mail/client.ts
|
|
2331
|
+
var MailOfflineUnavailableError = class extends Error {
|
|
2332
|
+
constructor(message) {
|
|
2333
|
+
super(message);
|
|
2334
|
+
this.name = "MailOfflineUnavailableError";
|
|
2335
|
+
}
|
|
2336
|
+
};
|
|
2337
|
+
function accountPath(id) {
|
|
2338
|
+
return `/accounts/${encodeURIComponent(id)}`;
|
|
2339
|
+
}
|
|
2340
|
+
async function mailJson(fetch, path, init) {
|
|
2341
|
+
const response = await fetch(path, init);
|
|
2342
|
+
return response.status === 204 ? void 0 : response.json();
|
|
2343
|
+
}
|
|
2344
|
+
function createMailClient(fetch, overrides = {}) {
|
|
2345
|
+
return {
|
|
2346
|
+
fetch,
|
|
2347
|
+
getPolicy: () => mailJson(fetch, "/policy"),
|
|
2348
|
+
listAccounts: () => mailJson(fetch, "/accounts"),
|
|
2349
|
+
listFolders: (account) => mailJson(fetch, `${accountPath(account.id)}/folders`),
|
|
2350
|
+
listMessages: (account, folderId, query, cursor) => mailJson(
|
|
2351
|
+
fetch,
|
|
2352
|
+
`${accountPath(account.id)}/messages?${new URLSearchParams({ folder_id: folderId, q: query, ...cursor ? { cursor } : {} })}`
|
|
2353
|
+
),
|
|
2354
|
+
getMessage: (account, messageId) => mailJson(fetch, `${accountPath(account.id)}/messages/${encodeURIComponent(messageId)}`),
|
|
2355
|
+
unlock: async () => {
|
|
2356
|
+
},
|
|
2357
|
+
...overrides
|
|
2358
|
+
};
|
|
2359
|
+
}
|
|
2360
|
+
function arbiMailClient(arbi) {
|
|
2361
|
+
let unlocking = null;
|
|
2362
|
+
const unlockNative = () => {
|
|
2363
|
+
unlocking ??= arbi.mail.unlockNative().finally(() => {
|
|
2364
|
+
unlocking = null;
|
|
2365
|
+
});
|
|
2366
|
+
return unlocking;
|
|
2367
|
+
};
|
|
2368
|
+
const fetch = async (path, init = {}) => {
|
|
2369
|
+
if (path.startsWith("/accounts/native/") && (init.method ?? "GET") !== "POST")
|
|
2370
|
+
await unlockNative();
|
|
2371
|
+
return arbi.mail.fetch(path, init);
|
|
2372
|
+
};
|
|
2373
|
+
return createMailClient(fetch, {
|
|
2374
|
+
unlock: async (account) => {
|
|
2375
|
+
if (account.provider === "native") await unlockNative();
|
|
2376
|
+
}
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
async function fileAttachment(file) {
|
|
2380
|
+
const data = await new Promise((resolve, reject) => {
|
|
2381
|
+
const reader = new FileReader();
|
|
2382
|
+
reader.onload = () => resolve(String(reader.result).split(",")[1]);
|
|
2383
|
+
reader.onerror = () => reject(new Error(`Could not read ${file.name}`));
|
|
2384
|
+
reader.readAsDataURL(file);
|
|
2385
|
+
});
|
|
2386
|
+
return {
|
|
2387
|
+
id: "",
|
|
2388
|
+
name: file.name,
|
|
2389
|
+
content_type: file.type || "application/octet-stream",
|
|
2390
|
+
size: file.size,
|
|
2391
|
+
content_base64: data
|
|
2392
|
+
};
|
|
2393
|
+
}
|
|
2394
|
+
function defaultMailAlias(user) {
|
|
2395
|
+
return [user?.given_name, user?.family_name].filter(Boolean).map(
|
|
2396
|
+
(name) => name.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]/g, "")
|
|
2397
|
+
).filter(Boolean).join(".").slice(0, 63);
|
|
2398
|
+
}
|
|
2399
|
+
function nextAliasSuggestion(alias) {
|
|
2400
|
+
const number = /(\d+)$/.exec(alias);
|
|
2401
|
+
if (!number) return `${alias}2`;
|
|
2402
|
+
return `${alias.slice(0, -number[1].length)}${Number(number[1]) + 1}`;
|
|
2403
|
+
}
|
|
2404
|
+
function isAliasTakenError(err) {
|
|
2405
|
+
return "status" in err && err.status === 409;
|
|
2406
|
+
}
|
|
2407
|
+
function aliasTakenMessage(alias, suggestion, domain) {
|
|
2408
|
+
return `${alias}@${domain} is already taken. Try ${suggestion}@${domain}: we check it when you confirm.`;
|
|
2409
|
+
}
|
|
2410
|
+
function mailDraftIdFromContent(content) {
|
|
2411
|
+
try {
|
|
2412
|
+
const meta = JSON.parse(content || "{}");
|
|
2413
|
+
return typeof meta.mail_id === "string" && meta.mail_id ? meta.mail_id : void 0;
|
|
2414
|
+
} catch {
|
|
2415
|
+
return void 0;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
var MailClientContext = createContext(null);
|
|
2419
|
+
var NO_MAIL = {
|
|
2420
|
+
client: createMailClient(
|
|
2421
|
+
() => Promise.reject(new Error("Mail needs a <MailClientProvider> or an <ArbiProvider> above it"))
|
|
2422
|
+
),
|
|
2423
|
+
enabled: false,
|
|
2424
|
+
sessionKey: null
|
|
2425
|
+
};
|
|
2426
|
+
function MailClientProvider({
|
|
2427
|
+
client,
|
|
2428
|
+
enabled = true,
|
|
2429
|
+
sessionKey = "session",
|
|
2430
|
+
children
|
|
2431
|
+
}) {
|
|
2432
|
+
const value = useMemo(() => ({ client, enabled, sessionKey }), [client, enabled, sessionKey]);
|
|
2433
|
+
return /* @__PURE__ */ jsx(MailClientContext.Provider, { value, children });
|
|
2434
|
+
}
|
|
2435
|
+
function useMailClient() {
|
|
2436
|
+
const provided = useContext(MailClientContext);
|
|
2437
|
+
const arbi = useContext(ArbiContext);
|
|
2438
|
+
const fallback = useMemo(() => arbi ? arbiMailClient(arbi) : null, [arbi]);
|
|
2439
|
+
if (provided) return provided;
|
|
2440
|
+
if (!arbi || !fallback) return NO_MAIL;
|
|
2441
|
+
let identity = null;
|
|
2442
|
+
try {
|
|
2443
|
+
identity = arbi.isLoggedIn ? arbi.user.identity()?.externalId ?? "session" : null;
|
|
2444
|
+
} catch {
|
|
2445
|
+
identity = null;
|
|
2446
|
+
}
|
|
2447
|
+
return { client: fallback, enabled: identity !== null, sessionKey: identity };
|
|
2448
|
+
}
|
|
2449
|
+
var mailQueryKeys = {
|
|
2450
|
+
all: () => ["mail"],
|
|
2451
|
+
policy: () => ["mail", "policy"],
|
|
2452
|
+
accounts: () => ["mail", "accounts"],
|
|
2453
|
+
unlock: (accountId, sessionKey) => ["mail", "unlock", accountId, sessionKey ?? ""],
|
|
2454
|
+
allFolders: () => ["mail", "folders"],
|
|
2455
|
+
folders: (accountId) => ["mail", "folders", accountId],
|
|
2456
|
+
allMessages: () => ["mail", "messages"],
|
|
2457
|
+
messages: (accountId, folderId, query, cursor) => ["mail", "messages", accountId, folderId, query, cursor],
|
|
2458
|
+
message: (accountId, messageId) => ["mail", "message", accountId, messageId]
|
|
2459
|
+
};
|
|
2460
|
+
function useMailOnline() {
|
|
2461
|
+
return useSyncExternalStore(
|
|
2462
|
+
(onChange) => onlineManager.subscribe(onChange),
|
|
2463
|
+
() => onlineManager.isOnline(),
|
|
2464
|
+
() => true
|
|
2465
|
+
);
|
|
2466
|
+
}
|
|
2467
|
+
function useMailPolicy() {
|
|
2468
|
+
const { client, enabled } = useMailClient();
|
|
2469
|
+
return useQuery({
|
|
2470
|
+
queryKey: mailQueryKeys.policy(),
|
|
2471
|
+
queryFn: () => client.getPolicy(),
|
|
2472
|
+
networkMode: "always",
|
|
2473
|
+
enabled,
|
|
2474
|
+
staleTime: 6e4,
|
|
2475
|
+
retry: false
|
|
2476
|
+
});
|
|
2477
|
+
}
|
|
2478
|
+
function useMailAccounts(options = {}) {
|
|
2479
|
+
const { client, enabled } = useMailClient();
|
|
2480
|
+
return useQuery({
|
|
2481
|
+
queryKey: mailQueryKeys.accounts(),
|
|
2482
|
+
queryFn: () => client.listAccounts(),
|
|
2483
|
+
networkMode: "always",
|
|
2484
|
+
enabled: enabled && (options.enabled ?? true),
|
|
2485
|
+
retry: false
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
function useMailUnlock(account) {
|
|
2489
|
+
const { client, enabled, sessionKey } = useMailClient();
|
|
2490
|
+
const isOnline = useMailOnline();
|
|
2491
|
+
return useQuery({
|
|
2492
|
+
queryKey: mailQueryKeys.unlock(account?.id, sessionKey),
|
|
2493
|
+
queryFn: async () => {
|
|
2494
|
+
if (!account) throw new Error("Sign in to unlock your mailbox");
|
|
2495
|
+
await client.unlock(account);
|
|
2496
|
+
return true;
|
|
2497
|
+
},
|
|
2498
|
+
enabled: enabled && !!account && sessionKey !== null && !account.needs_reconsent && isOnline,
|
|
2499
|
+
staleTime: Infinity,
|
|
2500
|
+
retry: false
|
|
2501
|
+
});
|
|
2502
|
+
}
|
|
2503
|
+
function useMailFolders(account, options) {
|
|
2504
|
+
const { client } = useMailClient();
|
|
2505
|
+
return useQuery({
|
|
2506
|
+
queryKey: mailQueryKeys.folders(account?.id),
|
|
2507
|
+
queryFn: () => client.listFolders(account),
|
|
2508
|
+
networkMode: "always",
|
|
2509
|
+
enabled: !!account && (options.enabled ?? true),
|
|
2510
|
+
retry: false
|
|
2511
|
+
});
|
|
2512
|
+
}
|
|
2513
|
+
function useMailMessages(account, folderId, query, cursor, options = {}) {
|
|
2514
|
+
const { client } = useMailClient();
|
|
2515
|
+
return useQuery({
|
|
2516
|
+
queryKey: mailQueryKeys.messages(account?.id, folderId, query, cursor),
|
|
2517
|
+
queryFn: () => client.listMessages(account, folderId, query, cursor),
|
|
2518
|
+
networkMode: "always",
|
|
2519
|
+
enabled: !!account && !!folderId && (options.enabled ?? true),
|
|
2520
|
+
retry: false,
|
|
2521
|
+
refetchInterval: options.refetchInterval
|
|
2522
|
+
});
|
|
2523
|
+
}
|
|
2524
|
+
function useMailMessage(account, messageId, options = {}) {
|
|
2525
|
+
const { client } = useMailClient();
|
|
2526
|
+
return useQuery({
|
|
2527
|
+
queryKey: mailQueryKeys.message(account?.id, messageId),
|
|
2528
|
+
queryFn: () => client.getMessage(account, messageId),
|
|
2529
|
+
networkMode: "always",
|
|
2530
|
+
enabled: !!account && !!messageId && (options.enabled ?? true),
|
|
2531
|
+
retry: false
|
|
2532
|
+
});
|
|
2533
|
+
}
|
|
2534
|
+
function useClaimNativeAlias(onClaimed) {
|
|
2535
|
+
const { client } = useMailClient();
|
|
2536
|
+
const queryClient = useQueryClient();
|
|
2537
|
+
return useMutation({
|
|
2538
|
+
mutationFn: (alias) => mailJson(client.fetch, "/native/alias", { method: "POST", body: JSON.stringify({ alias }) }),
|
|
2539
|
+
onSuccess: async (_data, alias) => {
|
|
2540
|
+
await queryClient.invalidateQueries({ queryKey: mailQueryKeys.all() });
|
|
2541
|
+
onClaimed?.(alias);
|
|
2542
|
+
}
|
|
2543
|
+
});
|
|
2544
|
+
}
|
|
2545
|
+
function useConnectMailAccount() {
|
|
2546
|
+
const { client } = useMailClient();
|
|
2547
|
+
const queryClient = useQueryClient();
|
|
2548
|
+
return useMutation({
|
|
2549
|
+
mutationFn: (input) => mailJson(client.fetch, "/accounts", {
|
|
2550
|
+
method: "POST",
|
|
2551
|
+
body: JSON.stringify({
|
|
2552
|
+
profile_id: input.profileId,
|
|
2553
|
+
email: input.email,
|
|
2554
|
+
username: input.username || input.email,
|
|
2555
|
+
password: input.password
|
|
2556
|
+
})
|
|
2557
|
+
}),
|
|
2558
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: mailQueryKeys.accounts() })
|
|
2559
|
+
});
|
|
2560
|
+
}
|
|
2561
|
+
function useDisconnectMailAccount() {
|
|
2562
|
+
const { client } = useMailClient();
|
|
2563
|
+
const queryClient = useQueryClient();
|
|
2564
|
+
return useMutation({
|
|
2565
|
+
mutationFn: (accountId) => mailJson(client.fetch, accountPath(accountId), { method: "DELETE" }),
|
|
2566
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: mailQueryKeys.all() })
|
|
2567
|
+
});
|
|
2568
|
+
}
|
|
2569
|
+
function useMailCache() {
|
|
2570
|
+
const queryClient = useQueryClient();
|
|
2571
|
+
return useMemo(() => {
|
|
2572
|
+
const refreshAll = () => queryClient.invalidateQueries({ queryKey: mailQueryKeys.all() });
|
|
2573
|
+
return {
|
|
2574
|
+
refreshAll,
|
|
2575
|
+
refreshFolders: () => queryClient.invalidateQueries({ queryKey: mailQueryKeys.allFolders() }),
|
|
2576
|
+
/** After a write to one message: drop a read of it still in flight (it may carry the old state), then refresh. */
|
|
2577
|
+
settleMessage: async (accountId, messageId) => {
|
|
2578
|
+
await queryClient.cancelQueries({ queryKey: mailQueryKeys.message(accountId, messageId) });
|
|
2579
|
+
await refreshAll();
|
|
2580
|
+
}
|
|
2581
|
+
};
|
|
2582
|
+
}, [queryClient]);
|
|
2583
|
+
}
|
|
2584
|
+
function useUpdateMailMessage() {
|
|
2585
|
+
const { client } = useMailClient();
|
|
2586
|
+
return useMutation({
|
|
2587
|
+
mutationFn: ({
|
|
2588
|
+
accountId,
|
|
2589
|
+
messageId,
|
|
2590
|
+
update
|
|
2591
|
+
}) => mailJson(
|
|
2592
|
+
client.fetch,
|
|
2593
|
+
`${accountPath(accountId)}/messages/${encodeURIComponent(messageId)}`,
|
|
2594
|
+
{
|
|
2595
|
+
method: "PATCH",
|
|
2596
|
+
body: JSON.stringify(update)
|
|
2597
|
+
}
|
|
2598
|
+
)
|
|
2599
|
+
});
|
|
2600
|
+
}
|
|
2601
|
+
async function withFallback(compose, fallback, online) {
|
|
2602
|
+
if (fallback && !onlineManager.isOnline()) {
|
|
2603
|
+
await fallback.keep(compose);
|
|
2604
|
+
return { onDevice: true };
|
|
2605
|
+
}
|
|
2606
|
+
try {
|
|
2607
|
+
return await online();
|
|
2608
|
+
} catch (error) {
|
|
2609
|
+
if (!fallback?.isNetworkFailure(error)) throw error;
|
|
2610
|
+
await fallback.keep(compose);
|
|
2611
|
+
return { onDevice: true };
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
function useSaveMailDraft(fallback) {
|
|
2615
|
+
const { client } = useMailClient();
|
|
2616
|
+
const queryClient = useQueryClient();
|
|
2617
|
+
return useMutation({
|
|
2618
|
+
// networkMode 'always': offline the save runs (to the device) instead of pausing on "Saving…".
|
|
2619
|
+
networkMode: "always",
|
|
2620
|
+
mutationFn: ({ accountId, compose }) => withFallback(
|
|
2621
|
+
compose,
|
|
2622
|
+
fallback,
|
|
2623
|
+
() => mailJson(client.fetch, `${accountPath(accountId)}/drafts`, {
|
|
2624
|
+
method: "POST",
|
|
2625
|
+
body: JSON.stringify(compose)
|
|
2626
|
+
})
|
|
2627
|
+
),
|
|
2628
|
+
onSuccess: (result) => {
|
|
2629
|
+
if (!("onDevice" in result))
|
|
2630
|
+
void queryClient.invalidateQueries({ queryKey: mailQueryKeys.allMessages() });
|
|
2631
|
+
}
|
|
2632
|
+
});
|
|
2633
|
+
}
|
|
2634
|
+
function useSendMail(fallback) {
|
|
2635
|
+
const { client } = useMailClient();
|
|
2636
|
+
const queryClient = useQueryClient();
|
|
2637
|
+
return useMutation({
|
|
2638
|
+
networkMode: "always",
|
|
2639
|
+
retry: false,
|
|
2640
|
+
mutationFn: ({
|
|
2641
|
+
accountId,
|
|
2642
|
+
compose,
|
|
2643
|
+
requestId,
|
|
2644
|
+
secure
|
|
2645
|
+
}) => withFallback(
|
|
2646
|
+
compose,
|
|
2647
|
+
fallback,
|
|
2648
|
+
async () => secure ? mailJson(client.fetch, "/secure/send", {
|
|
2649
|
+
method: "POST",
|
|
2650
|
+
body: JSON.stringify(await secure())
|
|
2651
|
+
}) : mailJson(client.fetch, `${accountPath(accountId)}/send`, {
|
|
2652
|
+
method: "POST",
|
|
2653
|
+
body: JSON.stringify({ ...compose, request_id: requestId })
|
|
2654
|
+
})
|
|
2655
|
+
),
|
|
2656
|
+
onSuccess: (result) => {
|
|
2657
|
+
if (!(result && typeof result === "object" && "onDevice" in result))
|
|
2658
|
+
void queryClient.invalidateQueries({ queryKey: mailQueryKeys.all() });
|
|
2659
|
+
}
|
|
2660
|
+
});
|
|
2661
|
+
}
|
|
2662
|
+
function useMailDraftCompose(account, draftId, prepare, options = {}) {
|
|
2663
|
+
return useQuery({
|
|
2664
|
+
queryKey: ["mail", "draft-compose", account?.id, draftId],
|
|
2665
|
+
queryFn: () => prepare(account, draftId),
|
|
2666
|
+
networkMode: "always",
|
|
2667
|
+
enabled: !!account && !!draftId && (options.enabled ?? true),
|
|
2668
|
+
retry: false,
|
|
2669
|
+
staleTime: Infinity
|
|
2670
|
+
});
|
|
2671
|
+
}
|
|
2317
2672
|
function useWorkspaceDocs(workspaceId) {
|
|
2318
2673
|
const { data: docs = [], isLoading, isError } = useDocuments(workspaceId);
|
|
2319
2674
|
const docIds = useMemo(
|
|
@@ -4298,7 +4653,8 @@ var workTypes = [
|
|
|
4298
4653
|
"workspace_access_request",
|
|
4299
4654
|
"conversation_ready",
|
|
4300
4655
|
"conversation_done",
|
|
4301
|
-
"workflow_failed"
|
|
4656
|
+
"workflow_failed",
|
|
4657
|
+
"mail_draft_ready"
|
|
4302
4658
|
];
|
|
4303
4659
|
function useWorkNotifications(options) {
|
|
4304
4660
|
const arbi = useArbi();
|
|
@@ -6524,6 +6880,6 @@ function hasVideoTrack(blob) {
|
|
|
6524
6880
|
});
|
|
6525
6881
|
}
|
|
6526
6882
|
|
|
6527
|
-
export { ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotIcon, ArbiIcon, ArbiWebSocketProvider, ArtifactCanvas, 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, FileIcon, FireworksIcon, GeminiIcon, GitHubIcon, GoogleIcon, ImageCropModal, ImageCropper, LinkedInIcon, MAX_AVATAR_FILE_BYTES, MessageArtifactCard, MessageBubble, MessageThread, OpenAIIcon, PhotoCapture, ProviderIcon, RUN_WINDOW_MS, SemanticSearch, StartByEmail, TypingIndicator, VideoCapture, VoiceNoteRecorder, annotateThread, captureFrameAsBlob, cropImage, dayKey, describeActivity, formatIdentityPrice, getNotificationTypeMeta, getWorkspaceActionText, getWorkspaceKind, getWorkspaceSentPhrase, hasVideoTrack, identityStepFor, invalidateTagData, isWorkspaceNotificationType, mountDiditVerification, parseActivityContent, parseDeleteAccountBlockers, pickRecentWorkspaces, redlineStats, resolveActiveWorkspace, textToArtifact, titleFromQuestion, toChatCitations, toNotificationPreferences, toProfileView, toRedlineMarkdown, toShellWorkspace, useActOnStep, useAddContacts, useAgentChats, useAgentConfig, useAgentModels, useAgentSession, useAgentWorkspaces, useAiTask, useArbiChat, useArbiConnected, useArbiDocumentSync, useArbiShellWorkspaces, useArbiUiStore, useArbiWebSocket, useArbiWsContext, useArbiWsMessage, useArbiWsStatus, useArbiWsStore, useArbiWsTask, useArbiWsTasks, useAvatarCrop, useCameraStream, useCloseAgentSession, useCommandPalette, useConfirmEmailChange, useContacts, useConversationActivity, useConversationPendingAuth, useConversationUsage, useCreateAgent, useCreateWork, useCreateWorkflow, useCurrentSessionId, useDeleteAccount, useDeleteAccountFlow, useDeleteWorkflow, useDirectMessages, useEmailChange, useFilteredProjects, useGrantAgentAccess, useIdentityVerification, useIdentityVerificationFlow, useInvalidateTagData, useLogoutAllSessions, useNameEditor, useNotificationPreferences, usePasswordChange, usePasswordChangeForm, usePendingContacts, usePlanWork, useProfile, useProjectConversationUsage, useProjectEvents, useRemoveContacts, useRequestEmailChange, useRevokeAgentAccess, useRunConversation, useRunWorkflow, useSaveAgentConfig, useSemanticSearch, useSendBackStep, useShellWorkspaces, useSkills, useStartAgentSession, useStartWorkQuery,
|
|
6883
|
+
export { ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotIcon, ArbiIcon, ArbiWebSocketProvider, ArtifactCanvas, 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, FileIcon, FireworksIcon, GeminiIcon, GitHubIcon, GoogleIcon, ImageCropModal, ImageCropper, LinkedInIcon, MAX_AVATAR_FILE_BYTES, MailClientProvider, MailOfflineUnavailableError, MessageArtifactCard, MessageBubble, MessageThread, OpenAIIcon, PhotoCapture, ProviderIcon, RUN_WINDOW_MS, SemanticSearch, StartByEmail, TypingIndicator, VideoCapture, VoiceNoteRecorder, accountPath, aliasTakenMessage, annotateThread, arbiMailClient, captureFrameAsBlob, createMailClient, cropImage, dayKey, defaultMailAlias, describeActivity, fileAttachment, formatIdentityPrice, getNotificationTypeMeta, getWorkspaceActionText, getWorkspaceKind, getWorkspaceSentPhrase, hasVideoTrack, identityStepFor, invalidateTagData, isAliasTakenError, isWorkspaceNotificationType, mailDraftIdFromContent, mailJson, mailQueryKeys, mountDiditVerification, nextAliasSuggestion, parseActivityContent, parseDeleteAccountBlockers, pickRecentWorkspaces, redlineStats, resolveActiveWorkspace, textToArtifact, titleFromQuestion, toChatCitations, toNotificationPreferences, toProfileView, toRedlineMarkdown, toShellWorkspace, useActOnStep, useAddContacts, useAgentChats, useAgentConfig, useAgentModels, useAgentSession, useAgentWorkspaces, useAiTask, useArbiChat, useArbiConnected, useArbiDocumentSync, useArbiShellWorkspaces, useArbiUiStore, useArbiWebSocket, useArbiWsContext, useArbiWsMessage, useArbiWsStatus, useArbiWsStore, useArbiWsTask, useArbiWsTasks, useAvatarCrop, useCameraStream, useClaimNativeAlias, useCloseAgentSession, useCommandPalette, useConfirmEmailChange, useConnectMailAccount, useContacts, useConversationActivity, useConversationPendingAuth, useConversationUsage, useCreateAgent, useCreateWork, useCreateWorkflow, useCurrentSessionId, useDeleteAccount, useDeleteAccountFlow, useDeleteWorkflow, useDirectMessages, useDisconnectMailAccount, useEmailChange, useFilteredProjects, useGrantAgentAccess, useIdentityVerification, useIdentityVerificationFlow, useInvalidateTagData, useLogoutAllSessions, useMailAccounts, useMailCache, useMailClient, useMailDraftCompose, useMailFolders, useMailMessage, useMailMessages, useMailOnline, useMailPolicy, useMailUnlock, useNameEditor, useNotificationPreferences, usePasswordChange, usePasswordChangeForm, usePendingContacts, usePlanWork, useProfile, useProjectConversationUsage, useProjectEvents, useRemoveContacts, useRequestEmailChange, useRevokeAgentAccess, useRunConversation, useRunWorkflow, useSaveAgentConfig, useSaveMailDraft, useSemanticSearch, useSendBackStep, useSendMail, useSetTagValues, useShellWorkspaces, useSkills, useStartAgentSession, useStartWorkQuery, useTagKindSchema, useTerminateSession, useUpdateConversation, useUpdateMailMessage, useUpdateProfile, useUpdateProjectFields, useUpdateTagKindSchema, useUpdateWorkflow, useUploadSkillFiles, useUserSettings, useVideoRecorder, useWorkNotifications, useWorkflows, useWorkspaceDocs, userDisplayName, userInitials, workflowStepOf };
|
|
6528
6884
|
//# sourceMappingURL=index.js.map
|
|
6529
6885
|
//# sourceMappingURL=index.js.map
|