@arbidocs/react 0.4.138 → 0.4.140
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 +8 -8
- package/dist/artifacts/index.js +3 -3
- package/dist/{chunk-KMMBMYJQ.js → chunk-2NDXBQAT.js} +7 -3
- package/dist/chunk-2NDXBQAT.js.map +1 -0
- package/dist/{chunk-Q2QUWZYX.cjs → chunk-QXGGFMMX.cjs} +7 -3
- package/dist/chunk-QXGGFMMX.cjs.map +1 -0
- package/dist/document-tools/index.cjs +1 -1
- package/dist/document-tools/index.js +1 -1
- package/dist/index.cjs +1436 -270
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1223 -4
- package/dist/index.d.ts +1223 -4
- package/dist/index.js +1076 -16
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-KMMBMYJQ.js.map +0 -1
- package/dist/chunk-Q2QUWZYX.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { arbiQueryKeys, arbiMutationKeys, 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 { 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';
|
|
4
|
-
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';
|
|
5
|
-
import { MarkdownRenderer } from './chunk-C44GO33B.js';
|
|
6
|
-
export { MarkdownCode, MarkdownLink, MarkdownRenderer, MarkdownStreamingContext, markdownBaseComponents, markdownSanitizeSchema, splitMarkdownBlocks } from './chunk-C44GO33B.js';
|
|
1
|
+
import { arbiQueryKeys, arbiMutationKeys, useDocuments, useConversations, useAssistantQuery, useConversationThreads, useWorkspaces, useParsedDocument, useTags, useActivity, useThumbnails } from './chunk-2NDXBQAT.js';
|
|
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-2NDXBQAT.js';
|
|
7
3
|
import { downloadBlob } from './chunk-ZJ6NQ4M4.js';
|
|
8
4
|
import { parseVersionRef } from './chunk-NNWMHMEC.js';
|
|
9
5
|
export { cleanDraftMarkdown, cleanDraftWithReport, promoteBoldTitle, repairParsedStructure, repairParsedTitle, stripAgentPreamble, unescapeMarkdown, unwrapCitationLinks } from './chunk-NNWMHMEC.js';
|
|
10
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
|
+
import { AudioViewer, ImageViewer, VideoViewer } from './chunk-HDCRPPBW.js';
|
|
10
|
+
import { useArbi, ArbiContext } from './chunk-CPPBN2JB.js';
|
|
11
|
+
export { ArbiProvider, useArbi, useDeploymentDomain } from './chunk-CPPBN2JB.js';
|
|
12
|
+
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';
|
|
13
|
+
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';
|
|
14
|
+
import { MarkdownRenderer } from './chunk-C44GO33B.js';
|
|
15
|
+
export { MarkdownCode, MarkdownLink, MarkdownRenderer, MarkdownStreamingContext, markdownBaseComponents, markdownSanitizeSchema, splitMarkdownBlocks } from './chunk-C44GO33B.js';
|
|
11
16
|
import { Button, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from './chunk-YNNAJJ5Z.js';
|
|
12
17
|
export { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, buttonVariants } from './chunk-YNNAJJ5Z.js';
|
|
13
18
|
import { normalizeCitationMarkup } from './chunk-QRCMKEE6.js';
|
|
14
19
|
export { closeOpenEmphasis, normalizeCitationMarkup, trimOpenCitation } from './chunk-QRCMKEE6.js';
|
|
15
|
-
import { formatRelativeTime } from './chunk-MFMJHBJR.js';
|
|
16
|
-
export { DEFAULT_NOTIFY_TONE, MAX_SESSION_NOTIFICATIONS, NotificationBell, Toaster, configureNotify, formatRelativeTime, notify, persistNotifyHistory, seedNotifications, selectUnread, toast, useNotify } from './chunk-MFMJHBJR.js';
|
|
17
20
|
import { ScrollArea } from './chunk-W4H6XAIU.js';
|
|
18
21
|
export { ScrollArea, ScrollBar } from './chunk-W4H6XAIU.js';
|
|
19
22
|
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from './chunk-47CCGUWR.js';
|
|
20
23
|
export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, PortalContainerProvider, usePortalContainer } from './chunk-47CCGUWR.js';
|
|
21
24
|
import { cn } from './chunk-SN5YV6FF.js';
|
|
22
25
|
export { cn } from './chunk-SN5YV6FF.js';
|
|
23
|
-
import { AudioViewer, ImageViewer, VideoViewer } from './chunk-HDCRPPBW.js';
|
|
24
|
-
import { useArbi, ArbiContext } from './chunk-CPPBN2JB.js';
|
|
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
27
|
import { useQueryClient, useMutation, useQuery, onlineManager } from '@tanstack/react-query';
|
|
28
|
-
import { resolveCitations, summarizeCitations, settings, formatFileSize, connectWithReconnect, chats, identityErrorCode } from '@arbidocs/sdk/browser';
|
|
29
|
-
export { Arbi, ArbiError, DEFAULT_AI_USD_PER_GBP, formatGbp, formatGbpPerMillionTokens, usdToGbp } from '@arbidocs/sdk/browser';
|
|
28
|
+
import { resolveCitations, summarizeCitations, settings, ArbiApiError, ACCOUNT_VENDOR, formatFileSize, connectWithReconnect, chats, identityErrorCode } from '@arbidocs/sdk/browser';
|
|
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';
|
|
32
32
|
import { isMessageType, passwordChangeErrorMessage, createRecoveryFile } from '@arbidocs/client';
|
|
@@ -1773,6 +1773,26 @@ function useDeleteContact() {
|
|
|
1773
1773
|
onSuccess: () => invalidate()
|
|
1774
1774
|
});
|
|
1775
1775
|
}
|
|
1776
|
+
function useSearchContacts(q, { debounceMs = 200 } = {}) {
|
|
1777
|
+
const arbi = useArbi();
|
|
1778
|
+
const term = useDebounced(q.trim(), debounceMs);
|
|
1779
|
+
return useQuery({
|
|
1780
|
+
queryKey: [...arbiQueryKeys.contacts(), "search", term],
|
|
1781
|
+
queryFn: () => arbi.contacts.search(term),
|
|
1782
|
+
enabled: term.length > 0 && arbi.isLoggedIn,
|
|
1783
|
+
staleTime: 6e4,
|
|
1784
|
+
placeholderData: (previous) => previous,
|
|
1785
|
+
retry: false
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
function useDebounced(value, ms) {
|
|
1789
|
+
const [debounced, setDebounced] = useState(value);
|
|
1790
|
+
useEffect(() => {
|
|
1791
|
+
const t = setTimeout(() => setDebounced(value), ms);
|
|
1792
|
+
return () => clearTimeout(t);
|
|
1793
|
+
}, [value, ms]);
|
|
1794
|
+
return debounced;
|
|
1795
|
+
}
|
|
1776
1796
|
var AccountClientContext = createContext(null);
|
|
1777
1797
|
function arbiProfile(arbi) {
|
|
1778
1798
|
const profile = arbi.user.profile();
|
|
@@ -2771,7 +2791,8 @@ var mailQueryKeys = {
|
|
|
2771
2791
|
folders: (accountId) => ["mail", "folders", accountId],
|
|
2772
2792
|
allMessages: () => ["mail", "messages"],
|
|
2773
2793
|
messages: (accountId, folderId, query, cursor) => ["mail", "messages", accountId, folderId, query, cursor],
|
|
2774
|
-
message: (accountId, messageId) => ["mail", "message", accountId, messageId]
|
|
2794
|
+
message: (accountId, messageId) => ["mail", "message", accountId, messageId],
|
|
2795
|
+
attachmentText: (accountId, messageId, attachmentId) => ["mail", "attachment-text", accountId, messageId, attachmentId]
|
|
2775
2796
|
};
|
|
2776
2797
|
function useMailOnline() {
|
|
2777
2798
|
return useSyncExternalStore(
|
|
@@ -2847,6 +2868,25 @@ function useMailMessage(account, messageId, options = {}) {
|
|
|
2847
2868
|
retry: false
|
|
2848
2869
|
});
|
|
2849
2870
|
}
|
|
2871
|
+
function decodeBase64Text(b64) {
|
|
2872
|
+
const bytes = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
|
|
2873
|
+
return new TextDecoder().decode(bytes);
|
|
2874
|
+
}
|
|
2875
|
+
function useMailAttachmentText(accountId, messageId, attachment, options = {}) {
|
|
2876
|
+
const { client } = useMailClient();
|
|
2877
|
+
return useQuery({
|
|
2878
|
+
queryKey: mailQueryKeys.attachmentText(accountId, messageId, attachment?.id ?? ""),
|
|
2879
|
+
queryFn: async () => {
|
|
2880
|
+
const a = attachment;
|
|
2881
|
+
if (a.content_base64) return decodeBase64Text(a.content_base64);
|
|
2882
|
+
const path = `${accountPath(accountId)}/messages/${encodeURIComponent(messageId)}/attachments/${encodeURIComponent(a.id)}`;
|
|
2883
|
+
return (await client.fetch(path)).text();
|
|
2884
|
+
},
|
|
2885
|
+
enabled: !!attachment && (options.enabled ?? true),
|
|
2886
|
+
staleTime: Infinity,
|
|
2887
|
+
retry: false
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2850
2890
|
function useClaimNativeAlias(onClaimed) {
|
|
2851
2891
|
const { client } = useMailClient();
|
|
2852
2892
|
const queryClient = useQueryClient();
|
|
@@ -3047,6 +3087,631 @@ function useMailDraftReplaced(draftId, onReplaced) {
|
|
|
3047
3087
|
return () => window.removeEventListener(MAIL_DRAFT_REPLACED_EVENT, listener);
|
|
3048
3088
|
}, [draftId]);
|
|
3049
3089
|
}
|
|
3090
|
+
|
|
3091
|
+
// src/calendar/keys.ts
|
|
3092
|
+
var calendarQueryKeys = {
|
|
3093
|
+
all: () => ["arbi", "calendar"],
|
|
3094
|
+
settings: () => ["arbi", "calendar", "settings"],
|
|
3095
|
+
calendars: () => ["arbi", "calendar", "calendars"],
|
|
3096
|
+
/** Every event list: the prefix an event write invalidates. */
|
|
3097
|
+
events: () => ["arbi", "calendar", "events"],
|
|
3098
|
+
eventList: (p) => [
|
|
3099
|
+
"arbi",
|
|
3100
|
+
"calendar",
|
|
3101
|
+
"events",
|
|
3102
|
+
{ start: p.start, end: p.end, calendars: p.calendars?.join(",") ?? null }
|
|
3103
|
+
],
|
|
3104
|
+
/** Every single event read. */
|
|
3105
|
+
eventDetails: () => ["arbi", "calendar", "event"],
|
|
3106
|
+
event: (id, recurrenceId) => ["arbi", "calendar", "event", id, recurrenceId ?? null],
|
|
3107
|
+
shares: (calId) => ["arbi", "calendar", "shares", calId],
|
|
3108
|
+
invitations: () => ["arbi", "calendar", "invitations"],
|
|
3109
|
+
holidayCountries: () => ["arbi", "calendar", "holiday-countries"],
|
|
3110
|
+
allRooms: () => ["arbi", "calendar", "rooms"],
|
|
3111
|
+
rooms: (q) => ["arbi", "calendar", "rooms", q],
|
|
3112
|
+
freebusy: (attendees, start, end) => ["arbi", "calendar", "freebusy", attendees.join(","), start, end],
|
|
3113
|
+
allLookups: () => ["arbi", "calendar", "lookup"],
|
|
3114
|
+
lookup: (uid) => ["arbi", "calendar", "lookup", uid],
|
|
3115
|
+
overlays: (workspaceId, w, layers) => [
|
|
3116
|
+
"arbi",
|
|
3117
|
+
"calendar",
|
|
3118
|
+
"overlays",
|
|
3119
|
+
workspaceId,
|
|
3120
|
+
w ? { start: w.start, end: w.end, layers: layers?.join(",") } : null
|
|
3121
|
+
],
|
|
3122
|
+
accounts: () => ["arbi", "calendar", "accounts"],
|
|
3123
|
+
caldavProfiles: () => ["arbi", "calendar", "caldav-profiles"],
|
|
3124
|
+
appPasswords: () => ["arbi", "calendar", "app-passwords"],
|
|
3125
|
+
bookingPages: () => ["arbi", "calendar", "booking-pages"],
|
|
3126
|
+
/** The offline outbox (writes made offline, not yet sent). */
|
|
3127
|
+
outbox: () => ["arbi", "calendar", "outbox"]
|
|
3128
|
+
};
|
|
3129
|
+
function isQueuedCalendarWrite(value) {
|
|
3130
|
+
return !!value && typeof value === "object" && value.queued === true;
|
|
3131
|
+
}
|
|
3132
|
+
var CalendarSupportContext = createContext({});
|
|
3133
|
+
function CalendarSupportProvider({
|
|
3134
|
+
value,
|
|
3135
|
+
children
|
|
3136
|
+
}) {
|
|
3137
|
+
return /* @__PURE__ */ jsx(CalendarSupportContext.Provider, { value, children });
|
|
3138
|
+
}
|
|
3139
|
+
function useCalendarSupport() {
|
|
3140
|
+
return useContext(CalendarSupportContext);
|
|
3141
|
+
}
|
|
3142
|
+
function invalidateCalendarEvents(qc) {
|
|
3143
|
+
return Promise.all([
|
|
3144
|
+
qc.invalidateQueries({ queryKey: calendarQueryKeys.events() }),
|
|
3145
|
+
qc.invalidateQueries({ queryKey: calendarQueryKeys.eventDetails() }),
|
|
3146
|
+
qc.invalidateQueries({ queryKey: calendarQueryKeys.invitations() }),
|
|
3147
|
+
qc.invalidateQueries({ queryKey: calendarQueryKeys.allLookups() })
|
|
3148
|
+
]);
|
|
3149
|
+
}
|
|
3150
|
+
function invalidateCalendars(qc) {
|
|
3151
|
+
return Promise.all([
|
|
3152
|
+
qc.invalidateQueries({ queryKey: calendarQueryKeys.calendars() }),
|
|
3153
|
+
qc.invalidateQueries({ queryKey: calendarQueryKeys.events() })
|
|
3154
|
+
]);
|
|
3155
|
+
}
|
|
3156
|
+
function useOfflineRead() {
|
|
3157
|
+
const { offline } = useCalendarSupport();
|
|
3158
|
+
return {
|
|
3159
|
+
read: (key, fetch) => offline ? offline.read(key, fetch) : fetch(),
|
|
3160
|
+
// Offline-capable queries must run without the network to reach the saved copy.
|
|
3161
|
+
networkMode: offline ? "always" : void 0
|
|
3162
|
+
};
|
|
3163
|
+
}
|
|
3164
|
+
function useOfflineWrite() {
|
|
3165
|
+
const { offline } = useCalendarSupport();
|
|
3166
|
+
return {
|
|
3167
|
+
write: (op, send) => offline ? offline.write(op, send) : send(),
|
|
3168
|
+
networkMode: offline ? "always" : void 0
|
|
3169
|
+
};
|
|
3170
|
+
}
|
|
3171
|
+
function useCalendarSettings(enabled = true) {
|
|
3172
|
+
const arbi = useArbi();
|
|
3173
|
+
const { read, networkMode } = useOfflineRead();
|
|
3174
|
+
return useQuery({
|
|
3175
|
+
queryKey: calendarQueryKeys.settings(),
|
|
3176
|
+
queryFn: () => read(calendarQueryKeys.settings(), () => arbi.calendar.getSettings()),
|
|
3177
|
+
networkMode,
|
|
3178
|
+
enabled: enabled && arbi.isLoggedIn,
|
|
3179
|
+
staleTime: 5 * 6e4,
|
|
3180
|
+
retry: false
|
|
3181
|
+
});
|
|
3182
|
+
}
|
|
3183
|
+
function useCalendars(enabled = true) {
|
|
3184
|
+
const arbi = useArbi();
|
|
3185
|
+
const { read, networkMode } = useOfflineRead();
|
|
3186
|
+
return useQuery({
|
|
3187
|
+
queryKey: calendarQueryKeys.calendars(),
|
|
3188
|
+
queryFn: () => read(calendarQueryKeys.calendars(), () => arbi.calendar.listCalendars()),
|
|
3189
|
+
networkMode,
|
|
3190
|
+
enabled: enabled && arbi.isLoggedIn,
|
|
3191
|
+
staleTime: 6e4,
|
|
3192
|
+
retry: false
|
|
3193
|
+
});
|
|
3194
|
+
}
|
|
3195
|
+
function useCalendarEvents(params) {
|
|
3196
|
+
const arbi = useArbi();
|
|
3197
|
+
const { read, networkMode } = useOfflineRead();
|
|
3198
|
+
return useQuery({
|
|
3199
|
+
queryKey: params ? calendarQueryKeys.eventList(params) : calendarQueryKeys.events(),
|
|
3200
|
+
queryFn: () => read(
|
|
3201
|
+
calendarQueryKeys.eventList(params),
|
|
3202
|
+
() => arbi.calendar.listEvents(params)
|
|
3203
|
+
),
|
|
3204
|
+
networkMode,
|
|
3205
|
+
enabled: !!params && arbi.isLoggedIn,
|
|
3206
|
+
staleTime: 3e4,
|
|
3207
|
+
placeholderData: (previous) => previous,
|
|
3208
|
+
retry: false
|
|
3209
|
+
});
|
|
3210
|
+
}
|
|
3211
|
+
function useCalendarEvent(id, recurrenceId) {
|
|
3212
|
+
const arbi = useArbi();
|
|
3213
|
+
const { read, networkMode } = useOfflineRead();
|
|
3214
|
+
return useQuery({
|
|
3215
|
+
queryKey: calendarQueryKeys.event(id ?? "", recurrenceId),
|
|
3216
|
+
queryFn: () => read(
|
|
3217
|
+
calendarQueryKeys.event(id, recurrenceId),
|
|
3218
|
+
() => arbi.calendar.getEvent(id, recurrenceId)
|
|
3219
|
+
),
|
|
3220
|
+
networkMode,
|
|
3221
|
+
enabled: !!id && arbi.isLoggedIn,
|
|
3222
|
+
retry: false
|
|
3223
|
+
});
|
|
3224
|
+
}
|
|
3225
|
+
function useFetchCalendarEvent() {
|
|
3226
|
+
const arbi = useArbi();
|
|
3227
|
+
const qc = useQueryClient();
|
|
3228
|
+
const { read, networkMode } = useOfflineRead();
|
|
3229
|
+
return (id, recurrenceId) => qc.fetchQuery({
|
|
3230
|
+
queryKey: calendarQueryKeys.event(id, recurrenceId),
|
|
3231
|
+
queryFn: () => read(
|
|
3232
|
+
calendarQueryKeys.event(id, recurrenceId),
|
|
3233
|
+
() => arbi.calendar.getEvent(id, recurrenceId)
|
|
3234
|
+
),
|
|
3235
|
+
networkMode,
|
|
3236
|
+
retry: false
|
|
3237
|
+
});
|
|
3238
|
+
}
|
|
3239
|
+
function useCalendarOverlays(range, layers) {
|
|
3240
|
+
const arbi = useArbi();
|
|
3241
|
+
const workspaceId = arbi.hasWorkspace ? arbi.getWorkspaceId() : null;
|
|
3242
|
+
return useQuery({
|
|
3243
|
+
queryKey: calendarQueryKeys.overlays(workspaceId, range ?? void 0, layers),
|
|
3244
|
+
queryFn: () => arbi.calendar.listOverlays(range, layers),
|
|
3245
|
+
enabled: !!workspaceId && !!range && layers.length > 0,
|
|
3246
|
+
staleTime: 6e4,
|
|
3247
|
+
placeholderData: (previous) => previous,
|
|
3248
|
+
retry: false
|
|
3249
|
+
});
|
|
3250
|
+
}
|
|
3251
|
+
function useCalendarOutbox() {
|
|
3252
|
+
const qc = useQueryClient();
|
|
3253
|
+
const { offline } = useCalendarSupport();
|
|
3254
|
+
useEffect(
|
|
3255
|
+
() => offline?.subscribe(() => {
|
|
3256
|
+
void qc.invalidateQueries({ queryKey: calendarQueryKeys.outbox() });
|
|
3257
|
+
}),
|
|
3258
|
+
[offline, qc]
|
|
3259
|
+
);
|
|
3260
|
+
return useQuery({
|
|
3261
|
+
queryKey: calendarQueryKeys.outbox(),
|
|
3262
|
+
queryFn: () => offline ? offline.pending() : Promise.resolve([]),
|
|
3263
|
+
networkMode: "always",
|
|
3264
|
+
staleTime: Infinity
|
|
3265
|
+
});
|
|
3266
|
+
}
|
|
3267
|
+
function useCalendarShares(calId) {
|
|
3268
|
+
const arbi = useArbi();
|
|
3269
|
+
return useQuery({
|
|
3270
|
+
queryKey: calendarQueryKeys.shares(calId ?? ""),
|
|
3271
|
+
queryFn: () => arbi.calendar.listShares(calId),
|
|
3272
|
+
enabled: !!calId && arbi.isLoggedIn,
|
|
3273
|
+
retry: false
|
|
3274
|
+
});
|
|
3275
|
+
}
|
|
3276
|
+
function useHolidayCountries(enabled = true) {
|
|
3277
|
+
const arbi = useArbi();
|
|
3278
|
+
return useQuery({
|
|
3279
|
+
queryKey: calendarQueryKeys.holidayCountries(),
|
|
3280
|
+
queryFn: () => arbi.calendar.listHolidayCountries(),
|
|
3281
|
+
enabled: enabled && arbi.isLoggedIn,
|
|
3282
|
+
staleTime: Infinity,
|
|
3283
|
+
retry: false
|
|
3284
|
+
});
|
|
3285
|
+
}
|
|
3286
|
+
function useRooms(q) {
|
|
3287
|
+
const arbi = useArbi();
|
|
3288
|
+
return useQuery({
|
|
3289
|
+
queryKey: calendarQueryKeys.rooms(q ?? {}),
|
|
3290
|
+
queryFn: () => arbi.calendar.listRooms(q ?? {}),
|
|
3291
|
+
enabled: !!q && arbi.isLoggedIn,
|
|
3292
|
+
staleTime: 3e4,
|
|
3293
|
+
placeholderData: (previous) => previous,
|
|
3294
|
+
retry: false
|
|
3295
|
+
});
|
|
3296
|
+
}
|
|
3297
|
+
function useFreeBusy(attendees, start, end) {
|
|
3298
|
+
const arbi = useArbi();
|
|
3299
|
+
return useQuery({
|
|
3300
|
+
queryKey: calendarQueryKeys.freebusy(attendees, start ?? "", end ?? ""),
|
|
3301
|
+
queryFn: () => arbi.calendar.freeBusy({ attendees, start, end }),
|
|
3302
|
+
enabled: attendees.length > 0 && !!start && !!end && arbi.isLoggedIn,
|
|
3303
|
+
staleTime: 3e4,
|
|
3304
|
+
placeholderData: (previous) => previous,
|
|
3305
|
+
retry: false
|
|
3306
|
+
});
|
|
3307
|
+
}
|
|
3308
|
+
function useCalendarInvitations() {
|
|
3309
|
+
const arbi = useArbi();
|
|
3310
|
+
return useQuery({
|
|
3311
|
+
queryKey: calendarQueryKeys.invitations(),
|
|
3312
|
+
queryFn: () => arbi.calendar.listInvitations(),
|
|
3313
|
+
enabled: arbi.isLoggedIn,
|
|
3314
|
+
staleTime: 3e4,
|
|
3315
|
+
refetchInterval: 6e4,
|
|
3316
|
+
retry: false
|
|
3317
|
+
});
|
|
3318
|
+
}
|
|
3319
|
+
function useCalendarEventByUid(uid) {
|
|
3320
|
+
const arbi = useArbi();
|
|
3321
|
+
return useQuery({
|
|
3322
|
+
queryKey: calendarQueryKeys.lookup(uid ?? ""),
|
|
3323
|
+
queryFn: () => arbi.calendar.lookupByUid(uid),
|
|
3324
|
+
enabled: !!uid && arbi.isLoggedIn,
|
|
3325
|
+
retry: false
|
|
3326
|
+
});
|
|
3327
|
+
}
|
|
3328
|
+
function useSaveCalendarSettings() {
|
|
3329
|
+
const arbi = useArbi();
|
|
3330
|
+
const qc = useQueryClient();
|
|
3331
|
+
return useMutation({
|
|
3332
|
+
mutationFn: (body) => arbi.calendar.putSettings(body),
|
|
3333
|
+
onSuccess: (data) => qc.setQueryData(calendarQueryKeys.settings(), data)
|
|
3334
|
+
});
|
|
3335
|
+
}
|
|
3336
|
+
function useCreateCalendar() {
|
|
3337
|
+
const arbi = useArbi();
|
|
3338
|
+
const qc = useQueryClient();
|
|
3339
|
+
return useMutation({
|
|
3340
|
+
mutationFn: (body) => arbi.calendar.createCalendar(body),
|
|
3341
|
+
onSuccess: () => invalidateCalendars(qc)
|
|
3342
|
+
});
|
|
3343
|
+
}
|
|
3344
|
+
function useUpdateCalendar() {
|
|
3345
|
+
const arbi = useArbi();
|
|
3346
|
+
const qc = useQueryClient();
|
|
3347
|
+
return useMutation({
|
|
3348
|
+
mutationFn: ({ id, body }) => arbi.calendar.updateCalendar(id, body),
|
|
3349
|
+
onSuccess: () => invalidateCalendars(qc)
|
|
3350
|
+
});
|
|
3351
|
+
}
|
|
3352
|
+
function useDeleteCalendar() {
|
|
3353
|
+
const arbi = useArbi();
|
|
3354
|
+
const qc = useQueryClient();
|
|
3355
|
+
return useMutation({
|
|
3356
|
+
mutationFn: (calId) => arbi.calendar.deleteCalendar(calId),
|
|
3357
|
+
onSuccess: () => invalidateCalendars(qc)
|
|
3358
|
+
});
|
|
3359
|
+
}
|
|
3360
|
+
function useCreateEvent() {
|
|
3361
|
+
const arbi = useArbi();
|
|
3362
|
+
const qc = useQueryClient();
|
|
3363
|
+
const { write, networkMode } = useOfflineWrite();
|
|
3364
|
+
return useMutation({
|
|
3365
|
+
mutationFn: (body) => write({ kind: "create", body }, () => arbi.calendar.createEvent(body)),
|
|
3366
|
+
networkMode,
|
|
3367
|
+
onSuccess: () => invalidateCalendarEvents(qc)
|
|
3368
|
+
});
|
|
3369
|
+
}
|
|
3370
|
+
function useUpdateEvent() {
|
|
3371
|
+
const arbi = useArbi();
|
|
3372
|
+
const qc = useQueryClient();
|
|
3373
|
+
const { write, networkMode } = useOfflineWrite();
|
|
3374
|
+
return useMutation({
|
|
3375
|
+
mutationFn: ({ target, body }) => write({ kind: "update", target, body }, () => arbi.calendar.updateEvent(target, body)),
|
|
3376
|
+
networkMode,
|
|
3377
|
+
onSuccess: () => invalidateCalendarEvents(qc)
|
|
3378
|
+
});
|
|
3379
|
+
}
|
|
3380
|
+
function useDeleteEvent() {
|
|
3381
|
+
const arbi = useArbi();
|
|
3382
|
+
const qc = useQueryClient();
|
|
3383
|
+
const { write, networkMode } = useOfflineWrite();
|
|
3384
|
+
return useMutation({
|
|
3385
|
+
mutationFn: (target) => write({ kind: "delete", target }, () => arbi.calendar.deleteEvent(target)),
|
|
3386
|
+
networkMode,
|
|
3387
|
+
onSuccess: () => invalidateCalendarEvents(qc)
|
|
3388
|
+
});
|
|
3389
|
+
}
|
|
3390
|
+
function useMoveEvent() {
|
|
3391
|
+
const arbi = useArbi();
|
|
3392
|
+
const qc = useQueryClient();
|
|
3393
|
+
return useMutation({
|
|
3394
|
+
mutationFn: ({ id, calendarId }) => arbi.calendar.moveEvent(id, calendarId),
|
|
3395
|
+
onSuccess: () => invalidateCalendarEvents(qc)
|
|
3396
|
+
});
|
|
3397
|
+
}
|
|
3398
|
+
function useRespondToEvent() {
|
|
3399
|
+
const arbi = useArbi();
|
|
3400
|
+
const qc = useQueryClient();
|
|
3401
|
+
const { write, networkMode } = useOfflineWrite();
|
|
3402
|
+
return useMutation({
|
|
3403
|
+
mutationFn: (params) => write({ kind: "respond", params }, () => arbi.calendar.respond(params)),
|
|
3404
|
+
networkMode,
|
|
3405
|
+
onSuccess: () => invalidateCalendarEvents(qc)
|
|
3406
|
+
});
|
|
3407
|
+
}
|
|
3408
|
+
function useImportCalendar() {
|
|
3409
|
+
const arbi = useArbi();
|
|
3410
|
+
const qc = useQueryClient();
|
|
3411
|
+
return useMutation({
|
|
3412
|
+
mutationFn: ({ ics, calendarId }) => arbi.calendar.importIcs(ics, calendarId),
|
|
3413
|
+
onSuccess: () => invalidateCalendarEvents(qc)
|
|
3414
|
+
});
|
|
3415
|
+
}
|
|
3416
|
+
function useShareCalendar() {
|
|
3417
|
+
const arbi = useArbi();
|
|
3418
|
+
const qc = useQueryClient();
|
|
3419
|
+
return useMutation({
|
|
3420
|
+
mutationFn: ({ calId, grantee, role }) => arbi.calendar.share(calId, grantee, role),
|
|
3421
|
+
onSuccess: (_d, v) => qc.invalidateQueries({ queryKey: calendarQueryKeys.shares(v.calId) })
|
|
3422
|
+
});
|
|
3423
|
+
}
|
|
3424
|
+
function useUnshareCalendar() {
|
|
3425
|
+
const arbi = useArbi();
|
|
3426
|
+
const qc = useQueryClient();
|
|
3427
|
+
return useMutation({
|
|
3428
|
+
mutationFn: ({ calId, userId }) => arbi.calendar.unshare(calId, userId),
|
|
3429
|
+
onSuccess: (_d, v) => qc.invalidateQueries({ queryKey: calendarQueryKeys.shares(v.calId) })
|
|
3430
|
+
});
|
|
3431
|
+
}
|
|
3432
|
+
function useSubscribeCalendar() {
|
|
3433
|
+
const arbi = useArbi();
|
|
3434
|
+
const qc = useQueryClient();
|
|
3435
|
+
return useMutation({
|
|
3436
|
+
mutationFn: (body) => arbi.calendar.subscribe(body),
|
|
3437
|
+
onSuccess: () => invalidateCalendars(qc)
|
|
3438
|
+
});
|
|
3439
|
+
}
|
|
3440
|
+
function useRefreshCalendar() {
|
|
3441
|
+
const arbi = useArbi();
|
|
3442
|
+
const qc = useQueryClient();
|
|
3443
|
+
return useMutation({
|
|
3444
|
+
mutationFn: (calId) => arbi.calendar.refresh(calId),
|
|
3445
|
+
onSuccess: () => invalidateCalendars(qc)
|
|
3446
|
+
});
|
|
3447
|
+
}
|
|
3448
|
+
function useAddHolidayCalendar() {
|
|
3449
|
+
const arbi = useArbi();
|
|
3450
|
+
const qc = useQueryClient();
|
|
3451
|
+
return useMutation({
|
|
3452
|
+
mutationFn: (body) => arbi.calendar.addHolidays(body),
|
|
3453
|
+
onSuccess: () => invalidateCalendars(qc)
|
|
3454
|
+
});
|
|
3455
|
+
}
|
|
3456
|
+
function useCreateRoom() {
|
|
3457
|
+
const arbi = useArbi();
|
|
3458
|
+
const qc = useQueryClient();
|
|
3459
|
+
return useMutation({
|
|
3460
|
+
mutationFn: (body) => arbi.calendar.createRoom(body),
|
|
3461
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: calendarQueryKeys.allRooms() })
|
|
3462
|
+
});
|
|
3463
|
+
}
|
|
3464
|
+
function useFindTime() {
|
|
3465
|
+
const arbi = useArbi();
|
|
3466
|
+
return useMutation({ mutationFn: (body) => arbi.calendar.findTime(body) });
|
|
3467
|
+
}
|
|
3468
|
+
function useDecideCounter() {
|
|
3469
|
+
const arbi = useArbi();
|
|
3470
|
+
const qc = useQueryClient();
|
|
3471
|
+
return useMutation({
|
|
3472
|
+
mutationFn: ({
|
|
3473
|
+
id,
|
|
3474
|
+
accept,
|
|
3475
|
+
comment
|
|
3476
|
+
}) => arbi.calendar.decideCounter(id, accept, comment),
|
|
3477
|
+
onSuccess: () => invalidateCalendarEvents(qc)
|
|
3478
|
+
});
|
|
3479
|
+
}
|
|
3480
|
+
function usePublishCalendar() {
|
|
3481
|
+
const arbi = useArbi();
|
|
3482
|
+
const qc = useQueryClient();
|
|
3483
|
+
return useMutation({
|
|
3484
|
+
mutationFn: ({ accountId, calendarId }) => arbi.calendar.publishToAccount(accountId, calendarId),
|
|
3485
|
+
onSuccess: () => {
|
|
3486
|
+
void invalidateCalendars(qc);
|
|
3487
|
+
void qc.invalidateQueries({ queryKey: calendarQueryKeys.accounts() });
|
|
3488
|
+
}
|
|
3489
|
+
});
|
|
3490
|
+
}
|
|
3491
|
+
function invalidateAccounts(qc) {
|
|
3492
|
+
return Promise.all([
|
|
3493
|
+
qc.invalidateQueries({ queryKey: calendarQueryKeys.accounts() }),
|
|
3494
|
+
qc.invalidateQueries({ queryKey: calendarQueryKeys.calendars() }),
|
|
3495
|
+
qc.invalidateQueries({ queryKey: calendarQueryKeys.events() })
|
|
3496
|
+
]);
|
|
3497
|
+
}
|
|
3498
|
+
function useCalendarAccounts(enabled = true) {
|
|
3499
|
+
const arbi = useArbi();
|
|
3500
|
+
return useQuery({
|
|
3501
|
+
queryKey: calendarQueryKeys.accounts(),
|
|
3502
|
+
queryFn: () => arbi.calendar.listAccounts(),
|
|
3503
|
+
enabled: enabled && arbi.isLoggedIn,
|
|
3504
|
+
staleTime: 3e4,
|
|
3505
|
+
retry: false
|
|
3506
|
+
});
|
|
3507
|
+
}
|
|
3508
|
+
function useCalDavProfiles(enabled = true) {
|
|
3509
|
+
const arbi = useArbi();
|
|
3510
|
+
return useQuery({
|
|
3511
|
+
queryKey: calendarQueryKeys.caldavProfiles(),
|
|
3512
|
+
queryFn: () => arbi.calendar.listCalDavProfiles(),
|
|
3513
|
+
enabled: enabled && arbi.isLoggedIn,
|
|
3514
|
+
staleTime: 10 * 6e4,
|
|
3515
|
+
retry: false
|
|
3516
|
+
});
|
|
3517
|
+
}
|
|
3518
|
+
async function connectOAuthCalendarAccount(arbi, connectors, kind, backgroundSync = false) {
|
|
3519
|
+
try {
|
|
3520
|
+
return await arbi.calendar.connectOAuthAccount(kind, backgroundSync);
|
|
3521
|
+
} catch (err) {
|
|
3522
|
+
if (!(err instanceof ArbiApiError) || err.status !== 401 || !connectors) throw err;
|
|
3523
|
+
await connectors.bridge(ACCOUNT_VENDOR[kind]);
|
|
3524
|
+
return arbi.calendar.connectOAuthAccount(kind, backgroundSync);
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
function useConnectOAuthAccount() {
|
|
3528
|
+
const arbi = useArbi();
|
|
3529
|
+
const { connectors } = useCalendarSupport();
|
|
3530
|
+
const qc = useQueryClient();
|
|
3531
|
+
return useMutation({
|
|
3532
|
+
mutationFn: ({ kind, backgroundSync }) => connectOAuthCalendarAccount(arbi, connectors, kind, !!backgroundSync),
|
|
3533
|
+
onSuccess: () => invalidateAccounts(qc)
|
|
3534
|
+
});
|
|
3535
|
+
}
|
|
3536
|
+
function useConnectCalDavAccount() {
|
|
3537
|
+
const arbi = useArbi();
|
|
3538
|
+
const qc = useQueryClient();
|
|
3539
|
+
return useMutation({
|
|
3540
|
+
mutationFn: (body) => arbi.calendar.connectCalDavAccount(body),
|
|
3541
|
+
onSuccess: () => invalidateAccounts(qc)
|
|
3542
|
+
});
|
|
3543
|
+
}
|
|
3544
|
+
function useUpdateCalendarAccount() {
|
|
3545
|
+
const arbi = useArbi();
|
|
3546
|
+
const qc = useQueryClient();
|
|
3547
|
+
return useMutation({
|
|
3548
|
+
mutationFn: ({ id, backgroundSync }) => arbi.calendar.updateAccount(id, backgroundSync),
|
|
3549
|
+
onSuccess: () => invalidateAccounts(qc)
|
|
3550
|
+
});
|
|
3551
|
+
}
|
|
3552
|
+
function useSyncCalendarAccount() {
|
|
3553
|
+
const arbi = useArbi();
|
|
3554
|
+
const qc = useQueryClient();
|
|
3555
|
+
return useMutation({
|
|
3556
|
+
mutationFn: (id) => arbi.calendar.syncAccount(id),
|
|
3557
|
+
onSettled: () => invalidateAccounts(qc)
|
|
3558
|
+
});
|
|
3559
|
+
}
|
|
3560
|
+
function useDisconnectCalendarAccount() {
|
|
3561
|
+
const arbi = useArbi();
|
|
3562
|
+
const qc = useQueryClient();
|
|
3563
|
+
return useMutation({
|
|
3564
|
+
mutationFn: (id) => arbi.calendar.disconnectAccount(id),
|
|
3565
|
+
onSuccess: () => invalidateAccounts(qc)
|
|
3566
|
+
});
|
|
3567
|
+
}
|
|
3568
|
+
var PENDING_CONNECT_KEY = "arbi-calendar-pending-account-connect";
|
|
3569
|
+
function readPendingConnect() {
|
|
3570
|
+
try {
|
|
3571
|
+
const raw = window.sessionStorage.getItem(PENDING_CONNECT_KEY);
|
|
3572
|
+
if (!raw) return null;
|
|
3573
|
+
const value = JSON.parse(raw);
|
|
3574
|
+
if (!value || Date.now() - value.at > 30 * 6e4) return null;
|
|
3575
|
+
return value;
|
|
3576
|
+
} catch {
|
|
3577
|
+
return null;
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3580
|
+
function clearPendingConnect() {
|
|
3581
|
+
try {
|
|
3582
|
+
window.sessionStorage.removeItem(PENDING_CONNECT_KEY);
|
|
3583
|
+
} catch {
|
|
3584
|
+
}
|
|
3585
|
+
}
|
|
3586
|
+
function useStartCalendarAccountOAuth() {
|
|
3587
|
+
const { connectors, oauthReturnPath } = useCalendarSupport();
|
|
3588
|
+
if (!connectors) return void 0;
|
|
3589
|
+
return async (kind, backgroundSync = false) => {
|
|
3590
|
+
try {
|
|
3591
|
+
window.sessionStorage.setItem(
|
|
3592
|
+
PENDING_CONNECT_KEY,
|
|
3593
|
+
JSON.stringify({ kind, backgroundSync, at: Date.now() })
|
|
3594
|
+
);
|
|
3595
|
+
} catch {
|
|
3596
|
+
}
|
|
3597
|
+
const returnPath = oauthReturnPath ?? `${window.location.pathname}${window.location.search}`;
|
|
3598
|
+
window.location.assign(await connectors.authorize(ACCOUNT_VENDOR[kind], returnPath));
|
|
3599
|
+
};
|
|
3600
|
+
}
|
|
3601
|
+
function useResumeCalendarAccountConnect(onDone) {
|
|
3602
|
+
const { connectors } = useCalendarSupport();
|
|
3603
|
+
const connect = useConnectOAuthAccount();
|
|
3604
|
+
const started = useRef(false);
|
|
3605
|
+
useEffect(() => {
|
|
3606
|
+
if (started.current || !connectors) return;
|
|
3607
|
+
const pending = readPendingConnect();
|
|
3608
|
+
if (!pending) return;
|
|
3609
|
+
let live = true;
|
|
3610
|
+
void connectors.connectedVendors().then((vendors) => {
|
|
3611
|
+
if (!live || started.current || !vendors.includes(ACCOUNT_VENDOR[pending.kind])) return;
|
|
3612
|
+
started.current = true;
|
|
3613
|
+
clearPendingConnect();
|
|
3614
|
+
connect.mutate(
|
|
3615
|
+
{ kind: pending.kind, backgroundSync: pending.backgroundSync },
|
|
3616
|
+
{
|
|
3617
|
+
onSuccess: (account) => onDone?.({ account }),
|
|
3618
|
+
onError: (error) => onDone?.({ error })
|
|
3619
|
+
}
|
|
3620
|
+
);
|
|
3621
|
+
}).catch(() => {
|
|
3622
|
+
});
|
|
3623
|
+
return () => {
|
|
3624
|
+
live = false;
|
|
3625
|
+
};
|
|
3626
|
+
}, [connectors]);
|
|
3627
|
+
return connect;
|
|
3628
|
+
}
|
|
3629
|
+
var syncedThisSession = /* @__PURE__ */ new Set();
|
|
3630
|
+
function resetCalendarAccountSyncState() {
|
|
3631
|
+
syncedThisSession.clear();
|
|
3632
|
+
}
|
|
3633
|
+
function useSyncAccountsOnOpen(enabled = true) {
|
|
3634
|
+
const arbi = useArbi();
|
|
3635
|
+
const { data: accounts } = useCalendarAccounts(enabled);
|
|
3636
|
+
const qc = useQueryClient();
|
|
3637
|
+
const [syncing, setSyncing] = useState(false);
|
|
3638
|
+
useEffect(() => {
|
|
3639
|
+
if (!enabled || !accounts?.length) return;
|
|
3640
|
+
const due = accounts.filter((a) => !syncedThisSession.has(a.id));
|
|
3641
|
+
if (!due.length) return;
|
|
3642
|
+
for (const a of due) syncedThisSession.add(a.id);
|
|
3643
|
+
setSyncing(true);
|
|
3644
|
+
void Promise.allSettled(due.map((a) => arbi.calendar.syncAccount(a.id))).then(() => {
|
|
3645
|
+
setSyncing(false);
|
|
3646
|
+
void invalidateAccounts(qc);
|
|
3647
|
+
});
|
|
3648
|
+
}, [enabled, accounts, arbi, qc]);
|
|
3649
|
+
return { syncing };
|
|
3650
|
+
}
|
|
3651
|
+
function useAppPasswords(enabled = true) {
|
|
3652
|
+
const arbi = useArbi();
|
|
3653
|
+
return useQuery({
|
|
3654
|
+
queryKey: calendarQueryKeys.appPasswords(),
|
|
3655
|
+
queryFn: () => arbi.calendar.listAppPasswords(),
|
|
3656
|
+
enabled: enabled && arbi.isLoggedIn,
|
|
3657
|
+
staleTime: 3e4,
|
|
3658
|
+
retry: false
|
|
3659
|
+
});
|
|
3660
|
+
}
|
|
3661
|
+
function useInvalidateAppPasswords() {
|
|
3662
|
+
const qc = useQueryClient();
|
|
3663
|
+
return () => qc.invalidateQueries({ queryKey: calendarQueryKeys.appPasswords() });
|
|
3664
|
+
}
|
|
3665
|
+
function useCreateAppPassword() {
|
|
3666
|
+
const arbi = useArbi();
|
|
3667
|
+
const invalidate = useInvalidateAppPasswords();
|
|
3668
|
+
return useMutation({
|
|
3669
|
+
mutationFn: (body) => arbi.calendar.createAppPassword(body),
|
|
3670
|
+
onSuccess: () => invalidate()
|
|
3671
|
+
});
|
|
3672
|
+
}
|
|
3673
|
+
function useCreateFeed() {
|
|
3674
|
+
const arbi = useArbi();
|
|
3675
|
+
const invalidate = useInvalidateAppPasswords();
|
|
3676
|
+
return useMutation({
|
|
3677
|
+
mutationFn: (body) => arbi.calendar.createFeed(body),
|
|
3678
|
+
onSuccess: () => invalidate()
|
|
3679
|
+
});
|
|
3680
|
+
}
|
|
3681
|
+
function useRevokeAppPassword() {
|
|
3682
|
+
const arbi = useArbi();
|
|
3683
|
+
const invalidate = useInvalidateAppPasswords();
|
|
3684
|
+
return useMutation({
|
|
3685
|
+
mutationFn: (id) => arbi.calendar.revokeAppPassword(id),
|
|
3686
|
+
onSuccess: () => invalidate()
|
|
3687
|
+
});
|
|
3688
|
+
}
|
|
3689
|
+
function useBookingPages(enabled = true) {
|
|
3690
|
+
const arbi = useArbi();
|
|
3691
|
+
return useQuery({
|
|
3692
|
+
queryKey: calendarQueryKeys.bookingPages(),
|
|
3693
|
+
queryFn: () => arbi.calendar.listBookingPages(),
|
|
3694
|
+
enabled: enabled && arbi.isLoggedIn,
|
|
3695
|
+
staleTime: 3e4,
|
|
3696
|
+
retry: false
|
|
3697
|
+
});
|
|
3698
|
+
}
|
|
3699
|
+
function useSaveBookingPage() {
|
|
3700
|
+
const arbi = useArbi();
|
|
3701
|
+
const qc = useQueryClient();
|
|
3702
|
+
return useMutation({
|
|
3703
|
+
mutationFn: (body) => arbi.calendar.putBookingPage(body),
|
|
3704
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: calendarQueryKeys.bookingPages() })
|
|
3705
|
+
});
|
|
3706
|
+
}
|
|
3707
|
+
function useDeleteBookingPage() {
|
|
3708
|
+
const arbi = useArbi();
|
|
3709
|
+
const qc = useQueryClient();
|
|
3710
|
+
return useMutation({
|
|
3711
|
+
mutationFn: (slug) => arbi.calendar.deleteBookingPage(slug),
|
|
3712
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: calendarQueryKeys.bookingPages() })
|
|
3713
|
+
});
|
|
3714
|
+
}
|
|
3050
3715
|
function useWorkspaceDocs(workspaceId) {
|
|
3051
3716
|
const { data: docs = [], isLoading, isError } = useDocuments(workspaceId);
|
|
3052
3717
|
const docIds = useMemo(
|
|
@@ -5065,7 +5730,7 @@ function useWorkNotifications(options) {
|
|
|
5065
5730
|
const queryKey = ["work-notifications", options.apiUrl, options.userId];
|
|
5066
5731
|
const query = useQuery({
|
|
5067
5732
|
queryKey,
|
|
5068
|
-
queryFn: async () => (await Promise.all(workTypes.map((type) => arbi.notifications.list(type)))).flat(),
|
|
5733
|
+
queryFn: async () => (await Promise.all(workTypes.map((type) => arbi.notifications.list({ type })))).flat(),
|
|
5069
5734
|
enabled: options.enabled && Boolean(options.userId),
|
|
5070
5735
|
refetchInterval: 3e4
|
|
5071
5736
|
});
|
|
@@ -5079,6 +5744,401 @@ function useWorkNotifications(options) {
|
|
|
5079
5744
|
});
|
|
5080
5745
|
return { ...query, markRead: receipt.mutateAsync };
|
|
5081
5746
|
}
|
|
5747
|
+
function useNotifications(options = {}) {
|
|
5748
|
+
const arbi = useArbi();
|
|
5749
|
+
const queries = useQueryClient();
|
|
5750
|
+
const limit = options.limit ?? 100;
|
|
5751
|
+
const ws = useContext(ArbiWsContext);
|
|
5752
|
+
useEffect(
|
|
5753
|
+
() => ws?.subscribe((message) => {
|
|
5754
|
+
if ("sender" in message && "recipient" in message)
|
|
5755
|
+
void queries.invalidateQueries({ queryKey: arbiQueryKeys.allNotifications() });
|
|
5756
|
+
}),
|
|
5757
|
+
[ws, queries]
|
|
5758
|
+
);
|
|
5759
|
+
return useQuery({
|
|
5760
|
+
queryKey: arbiQueryKeys.notifications(limit),
|
|
5761
|
+
queryFn: () => arbi.notifications.list({ limit }),
|
|
5762
|
+
enabled: (options.enabled ?? true) && arbi.isLoggedIn
|
|
5763
|
+
});
|
|
5764
|
+
}
|
|
5765
|
+
function useDeleteNotifications() {
|
|
5766
|
+
const arbi = useArbi();
|
|
5767
|
+
const queries = useQueryClient();
|
|
5768
|
+
return useMutation({
|
|
5769
|
+
mutationFn: (ids) => arbi.notifications.delete(ids),
|
|
5770
|
+
onSuccess: () => queries.invalidateQueries({ queryKey: arbiQueryKeys.allNotifications() })
|
|
5771
|
+
});
|
|
5772
|
+
}
|
|
5773
|
+
function useMarkNotificationsRead() {
|
|
5774
|
+
const arbi = useArbi();
|
|
5775
|
+
const queries = useQueryClient();
|
|
5776
|
+
return useMutation({
|
|
5777
|
+
mutationFn: (ids) => arbi.notifications.markRead(ids),
|
|
5778
|
+
onSuccess: () => queries.invalidateQueries({ queryKey: arbiQueryKeys.allNotifications() })
|
|
5779
|
+
});
|
|
5780
|
+
}
|
|
5781
|
+
|
|
5782
|
+
// src/notifications/server-notifications.ts
|
|
5783
|
+
function notificationUserName(user) {
|
|
5784
|
+
return [user.given_name, user.family_name].filter(Boolean).join(" ") || user.email;
|
|
5785
|
+
}
|
|
5786
|
+
var CONVERSATION_ID = /^con-[a-zA-Z0-9]+$/;
|
|
5787
|
+
var DOCUMENT_ID = /^doc-[a-zA-Z0-9]+$/;
|
|
5788
|
+
function parse(content) {
|
|
5789
|
+
try {
|
|
5790
|
+
const value = JSON.parse(content || "{}");
|
|
5791
|
+
return value && typeof value === "object" ? value : null;
|
|
5792
|
+
} catch {
|
|
5793
|
+
return null;
|
|
5794
|
+
}
|
|
5795
|
+
}
|
|
5796
|
+
function inputRequestTitle(content) {
|
|
5797
|
+
const metadata = parse(content);
|
|
5798
|
+
if (!metadata) return "ARBI needs your input \u2014 open the thread to reply";
|
|
5799
|
+
const timeout = typeof metadata.timeout_seconds === "number" ? metadata.timeout_seconds : 300;
|
|
5800
|
+
const minutes = Math.ceil(timeout / 60);
|
|
5801
|
+
const deadline = typeof metadata.expires_at === "string" ? new Date(metadata.expires_at) : null;
|
|
5802
|
+
if (deadline && Number.isFinite(deadline.getTime())) {
|
|
5803
|
+
return `ARBI needs your input \u2014 ${minutes} min to reply (until ${deadline.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })})`;
|
|
5804
|
+
}
|
|
5805
|
+
return `ARBI needs your input \u2014 ${minutes} min to reply`;
|
|
5806
|
+
}
|
|
5807
|
+
function documentActivityMeta(content) {
|
|
5808
|
+
const meta = parse(content);
|
|
5809
|
+
if (!meta) return {};
|
|
5810
|
+
const documentId = typeof meta.doc_ext_id === "string" && DOCUMENT_ID.test(meta.doc_ext_id) ? meta.doc_ext_id : void 0;
|
|
5811
|
+
const version = typeof meta.version === "number" && Number.isInteger(meta.version) && meta.version > 0 ? meta.version : void 0;
|
|
5812
|
+
const reason = typeof meta.reason === "string" ? meta.reason : void 0;
|
|
5813
|
+
return { documentId, reason, version };
|
|
5814
|
+
}
|
|
5815
|
+
function documentActivityPhrase(content) {
|
|
5816
|
+
const { reason, version } = documentActivityMeta(content);
|
|
5817
|
+
if (reason === "signed") return "signed a document";
|
|
5818
|
+
return version ? `saved version ${version} of a document` : "saved a new version of a document";
|
|
5819
|
+
}
|
|
5820
|
+
function docxMentionMeta(content) {
|
|
5821
|
+
const meta = parse(content);
|
|
5822
|
+
if (!meta || typeof meta.document_id !== "string" || !DOCUMENT_ID.test(meta.document_id))
|
|
5823
|
+
return {};
|
|
5824
|
+
return {
|
|
5825
|
+
documentId: meta.document_id,
|
|
5826
|
+
commentId: typeof meta.comment_id === "string" && meta.comment_id ? meta.comment_id : void 0
|
|
5827
|
+
};
|
|
5828
|
+
}
|
|
5829
|
+
function signatureRequestMeta(content) {
|
|
5830
|
+
const meta = parse(content);
|
|
5831
|
+
if (!meta) return {};
|
|
5832
|
+
const documentId = typeof meta.document_id === "string" && DOCUMENT_ID.test(meta.document_id) ? meta.document_id : void 0;
|
|
5833
|
+
const version = typeof meta.signed_version === "number" && Number.isInteger(meta.signed_version) ? meta.signed_version : void 0;
|
|
5834
|
+
return { documentId, version };
|
|
5835
|
+
}
|
|
5836
|
+
var SIGNATURE_NOTIFICATION_TYPES = [
|
|
5837
|
+
"signature_requested",
|
|
5838
|
+
"signature_completed",
|
|
5839
|
+
"signature_declined"
|
|
5840
|
+
];
|
|
5841
|
+
function isSignatureNotificationType(type) {
|
|
5842
|
+
return SIGNATURE_NOTIFICATION_TYPES.includes(type ?? "");
|
|
5843
|
+
}
|
|
5844
|
+
function signatureNotificationPhrase(type, incoming) {
|
|
5845
|
+
if (incoming) {
|
|
5846
|
+
switch (type) {
|
|
5847
|
+
case "signature_requested":
|
|
5848
|
+
return { lead: "", showPerson: true, verb: "asked you to sign", tail: "" };
|
|
5849
|
+
case "signature_completed":
|
|
5850
|
+
return { lead: "", showPerson: true, verb: "signed", tail: " \u2014 everyone has now signed" };
|
|
5851
|
+
case "signature_declined":
|
|
5852
|
+
return { lead: "", showPerson: true, verb: "declined to sign", tail: "" };
|
|
5853
|
+
}
|
|
5854
|
+
}
|
|
5855
|
+
switch (type) {
|
|
5856
|
+
case "signature_requested":
|
|
5857
|
+
return { lead: "You asked", showPerson: true, verb: "to sign", tail: "" };
|
|
5858
|
+
case "signature_completed":
|
|
5859
|
+
return { lead: "You signed", showPerson: false, verb: "", tail: " \u2014 everyone has now signed" };
|
|
5860
|
+
case "signature_declined":
|
|
5861
|
+
return { lead: "You declined to sign", showPerson: false, verb: "", tail: "" };
|
|
5862
|
+
}
|
|
5863
|
+
}
|
|
5864
|
+
function callNotificationMeta(content) {
|
|
5865
|
+
const meta = parse(content);
|
|
5866
|
+
return {
|
|
5867
|
+
callExtId: typeof meta?.call_ext_id === "string" && /^call-[a-zA-Z0-9]{8}$/.test(meta.call_ext_id) ? meta.call_ext_id : void 0
|
|
5868
|
+
};
|
|
5869
|
+
}
|
|
5870
|
+
var BOX_SEAT_REFUSED = "box_seat_refused";
|
|
5871
|
+
var BOX_SEAT_REFUSED_TITLE = "Invitation not sent: your Box has no seat left. Your Box admins have been notified and can add users in the ARBI portal.";
|
|
5872
|
+
var BOX_SEAT_REFUSED_ACTION = "Open the ARBI portal";
|
|
5873
|
+
function isDeploymentUserNotification(type) {
|
|
5874
|
+
return type === "deployment_user_invited" || type === "deployment_user_registered";
|
|
5875
|
+
}
|
|
5876
|
+
var ALLOWED_PORTAL_ORIGINS = ["https://portal.arbicity.com"];
|
|
5877
|
+
function safePortalUrl(value, origins = ALLOWED_PORTAL_ORIGINS) {
|
|
5878
|
+
if (typeof value !== "string") return void 0;
|
|
5879
|
+
try {
|
|
5880
|
+
const url = new URL(value);
|
|
5881
|
+
if (url.protocol !== "https:" || !origins.includes(url.origin)) return void 0;
|
|
5882
|
+
return url.href;
|
|
5883
|
+
} catch {
|
|
5884
|
+
return void 0;
|
|
5885
|
+
}
|
|
5886
|
+
}
|
|
5887
|
+
function deploymentUserMeta(content, origins = ALLOWED_PORTAL_ORIGINS) {
|
|
5888
|
+
const meta = parse(content);
|
|
5889
|
+
if (!meta) return { external: false };
|
|
5890
|
+
const email = typeof meta.email === "string" && meta.email.trim() ? meta.email.trim() : void 0;
|
|
5891
|
+
return {
|
|
5892
|
+
email,
|
|
5893
|
+
external: meta.user_type === "external",
|
|
5894
|
+
portalUrl: safePortalUrl(meta.portal_url, origins)
|
|
5895
|
+
};
|
|
5896
|
+
}
|
|
5897
|
+
function documentDisplayName(doc) {
|
|
5898
|
+
return doc?.doc_metadata?.title || doc?.file_name || void 0;
|
|
5899
|
+
}
|
|
5900
|
+
var WORK_NOTIFICATION_LABELS = {
|
|
5901
|
+
conversation_ready: "A task is ready",
|
|
5902
|
+
conversation_done: "A task was marked done",
|
|
5903
|
+
conversation_notified: "You were notified in a thread",
|
|
5904
|
+
workflow_failed: "A workflow failed to run"
|
|
5905
|
+
};
|
|
5906
|
+
function conversationTarget(n) {
|
|
5907
|
+
if (!n.conversation_ext_id || !CONVERSATION_ID.test(n.conversation_ext_id)) return void 0;
|
|
5908
|
+
return {
|
|
5909
|
+
kind: "conversation",
|
|
5910
|
+
workspaceId: n.workspace_ext_id ?? void 0,
|
|
5911
|
+
conversationId: n.conversation_ext_id,
|
|
5912
|
+
...n.message_ext_id ? { messageId: n.message_ext_id } : {}
|
|
5913
|
+
};
|
|
5914
|
+
}
|
|
5915
|
+
function signatureTitle(n, senderName, documentName) {
|
|
5916
|
+
const type = n.type;
|
|
5917
|
+
const { documentId } = signatureRequestMeta(n.content);
|
|
5918
|
+
const name = documentId ? documentName?.(n.workspace_ext_id, documentId) : void 0;
|
|
5919
|
+
const fallback = type === "signature_requested" ? "a document" : "your document";
|
|
5920
|
+
const { verb, tail } = signatureNotificationPhrase(type, true);
|
|
5921
|
+
return `${senderName} ${verb} ${name ?? fallback}${tail}`;
|
|
5922
|
+
}
|
|
5923
|
+
function quotaPercent(type) {
|
|
5924
|
+
if (type === "quota_threshold_100") return 100;
|
|
5925
|
+
if (type === "quota_threshold_90") return 90;
|
|
5926
|
+
if (type === "quota_threshold_50") return 50;
|
|
5927
|
+
return null;
|
|
5928
|
+
}
|
|
5929
|
+
function describeServerNotification(n, options = {}) {
|
|
5930
|
+
const senderName = options.senderName ?? notificationUserName(n.sender);
|
|
5931
|
+
const workspace = n.workspace_ext_id ? { kind: "workspace", workspaceId: n.workspace_ext_id } : void 0;
|
|
5932
|
+
const type = n.type;
|
|
5933
|
+
if (type === BOX_SEAT_REFUSED) {
|
|
5934
|
+
return {
|
|
5935
|
+
title: BOX_SEAT_REFUSED_TITLE,
|
|
5936
|
+
variant: "warning",
|
|
5937
|
+
actionLabel: BOX_SEAT_REFUSED_ACTION,
|
|
5938
|
+
target: { kind: "seats" }
|
|
5939
|
+
};
|
|
5940
|
+
}
|
|
5941
|
+
const pct = quotaPercent(type);
|
|
5942
|
+
if (pct !== null) {
|
|
5943
|
+
return {
|
|
5944
|
+
title: `You have used ${pct}% of your daily AI limit for this project.`,
|
|
5945
|
+
variant: pct === 100 ? "error" : pct === 90 ? "warning" : "info",
|
|
5946
|
+
target: { kind: "projects" }
|
|
5947
|
+
};
|
|
5948
|
+
}
|
|
5949
|
+
switch (type) {
|
|
5950
|
+
case "call_missed":
|
|
5951
|
+
return {
|
|
5952
|
+
title: `Missed call from ${senderName}`,
|
|
5953
|
+
variant: "warning",
|
|
5954
|
+
actionLabel: "Call back",
|
|
5955
|
+
target: { kind: "call-back", user: n.sender }
|
|
5956
|
+
};
|
|
5957
|
+
case "native_mail_received":
|
|
5958
|
+
return {
|
|
5959
|
+
title: "New email in your encrypted inbox",
|
|
5960
|
+
variant: "info",
|
|
5961
|
+
target: { kind: "mail" }
|
|
5962
|
+
};
|
|
5963
|
+
case "mail_draft_ready": {
|
|
5964
|
+
const draftId = mailDraftIdFromContent(n.content);
|
|
5965
|
+
return {
|
|
5966
|
+
title: `${senderName} left a draft email for you to review`,
|
|
5967
|
+
variant: "info",
|
|
5968
|
+
target: { kind: "mail", ...draftId ? { draftId } : {} }
|
|
5969
|
+
};
|
|
5970
|
+
}
|
|
5971
|
+
case "workspaceuser_added_owner":
|
|
5972
|
+
return { title: `${senderName} added you as owner`, variant: "info", target: workspace };
|
|
5973
|
+
case "workspaceuser_added_collaborator":
|
|
5974
|
+
return {
|
|
5975
|
+
title: `${senderName} added you as collaborator`,
|
|
5976
|
+
variant: "info",
|
|
5977
|
+
target: workspace
|
|
5978
|
+
};
|
|
5979
|
+
case "workspaceuser_added_guest":
|
|
5980
|
+
return { title: `${senderName} added you as guest`, variant: "info", target: workspace };
|
|
5981
|
+
case "workspaceuser_removed":
|
|
5982
|
+
return { title: `${senderName} removed you from a workspace`, variant: "warning" };
|
|
5983
|
+
case "workspaceuser_updated_owner":
|
|
5984
|
+
return {
|
|
5985
|
+
title: `${senderName} changed your role to owner`,
|
|
5986
|
+
variant: "info",
|
|
5987
|
+
target: workspace
|
|
5988
|
+
};
|
|
5989
|
+
case "workspaceuser_updated_collaborator":
|
|
5990
|
+
return {
|
|
5991
|
+
title: `${senderName} changed your role to collaborator`,
|
|
5992
|
+
variant: "info",
|
|
5993
|
+
target: workspace
|
|
5994
|
+
};
|
|
5995
|
+
case "workspaceuser_updated_guest":
|
|
5996
|
+
return {
|
|
5997
|
+
title: `${senderName} changed your role to guest`,
|
|
5998
|
+
variant: "info",
|
|
5999
|
+
target: workspace
|
|
6000
|
+
};
|
|
6001
|
+
case "signature_requested":
|
|
6002
|
+
case "signature_completed":
|
|
6003
|
+
case "signature_declined": {
|
|
6004
|
+
const { documentId, version } = signatureRequestMeta(n.content);
|
|
6005
|
+
return {
|
|
6006
|
+
title: signatureTitle(n, senderName, options.documentName),
|
|
6007
|
+
variant: type === "signature_completed" ? "success" : type === "signature_declined" ? "warning" : "info",
|
|
6008
|
+
actionLabel: type === "signature_requested" ? "Review and sign" : "Open",
|
|
6009
|
+
// A request opens the current version on its PDF, where the banner offers "Review and
|
|
6010
|
+
// sign"; a completed request opens the signed copy.
|
|
6011
|
+
target: documentId ? {
|
|
6012
|
+
kind: "document",
|
|
6013
|
+
workspaceId: n.workspace_ext_id ?? void 0,
|
|
6014
|
+
documentId,
|
|
6015
|
+
...version ? { version } : {},
|
|
6016
|
+
tab: "pdf"
|
|
6017
|
+
} : void 0
|
|
6018
|
+
};
|
|
6019
|
+
}
|
|
6020
|
+
case "docx_mention": {
|
|
6021
|
+
const { documentId, commentId } = docxMentionMeta(n.content);
|
|
6022
|
+
return {
|
|
6023
|
+
title: `${senderName} mentioned you in a document comment`,
|
|
6024
|
+
variant: "info",
|
|
6025
|
+
target: documentId ? {
|
|
6026
|
+
kind: "document",
|
|
6027
|
+
workspaceId: n.workspace_ext_id ?? void 0,
|
|
6028
|
+
documentId,
|
|
6029
|
+
...commentId ? { commentId } : {}
|
|
6030
|
+
} : void 0
|
|
6031
|
+
};
|
|
6032
|
+
}
|
|
6033
|
+
case "agent_input_requested":
|
|
6034
|
+
return { title: inputRequestTitle(n.content), variant: "info", target: conversationTarget(n) };
|
|
6035
|
+
case "mention":
|
|
6036
|
+
return {
|
|
6037
|
+
title: `${senderName} mentioned you in a conversation`,
|
|
6038
|
+
variant: "info",
|
|
6039
|
+
target: conversationTarget(n)
|
|
6040
|
+
};
|
|
6041
|
+
case "thread_reply":
|
|
6042
|
+
return {
|
|
6043
|
+
title: `${senderName} replied in a thread`,
|
|
6044
|
+
variant: "info",
|
|
6045
|
+
target: conversationTarget(n)
|
|
6046
|
+
};
|
|
6047
|
+
case "document_activity": {
|
|
6048
|
+
const { documentId, version } = documentActivityMeta(n.content);
|
|
6049
|
+
return {
|
|
6050
|
+
title: `${senderName} ${documentActivityPhrase(n.content)}`,
|
|
6051
|
+
variant: "info",
|
|
6052
|
+
target: documentId ? {
|
|
6053
|
+
kind: "document",
|
|
6054
|
+
workspaceId: n.workspace_ext_id ?? void 0,
|
|
6055
|
+
documentId,
|
|
6056
|
+
...version ? { version } : {}
|
|
6057
|
+
} : void 0
|
|
6058
|
+
};
|
|
6059
|
+
}
|
|
6060
|
+
// Each of these opens the thread, so the person it is for finds it. One about your own thread
|
|
6061
|
+
// (you started the work) says so.
|
|
6062
|
+
case "conversation_ready":
|
|
6063
|
+
return {
|
|
6064
|
+
title: n.sender.external_id === n.recipient.external_id ? "Your thread is ready" : `${senderName}\u2019s thread is ready`,
|
|
6065
|
+
variant: "info",
|
|
6066
|
+
target: conversationTarget(n)
|
|
6067
|
+
};
|
|
6068
|
+
case "conversation_notified":
|
|
6069
|
+
return {
|
|
6070
|
+
title: `${senderName} notified you in a thread`,
|
|
6071
|
+
variant: "info",
|
|
6072
|
+
target: conversationTarget(n)
|
|
6073
|
+
};
|
|
6074
|
+
case "conversation_done":
|
|
6075
|
+
return {
|
|
6076
|
+
title: `${senderName} marked a thread done`,
|
|
6077
|
+
variant: "success",
|
|
6078
|
+
target: conversationTarget(n)
|
|
6079
|
+
};
|
|
6080
|
+
case "workflow_completed": {
|
|
6081
|
+
const workflowId = parse(n.content)?.workflow_ext_id;
|
|
6082
|
+
return {
|
|
6083
|
+
title: "A workflow completed",
|
|
6084
|
+
variant: "success",
|
|
6085
|
+
target: {
|
|
6086
|
+
kind: "workflows",
|
|
6087
|
+
...typeof workflowId === "string" ? { workflowId } : {}
|
|
6088
|
+
}
|
|
6089
|
+
};
|
|
6090
|
+
}
|
|
6091
|
+
case "workflow_failed":
|
|
6092
|
+
return {
|
|
6093
|
+
title: "A workflow failed to start",
|
|
6094
|
+
variant: "error",
|
|
6095
|
+
target: { kind: "workflows" }
|
|
6096
|
+
};
|
|
6097
|
+
case "deployment_user_invited":
|
|
6098
|
+
case "deployment_user_registered": {
|
|
6099
|
+
const { email, external, portalUrl } = deploymentUserMeta(n.content, options.portalOrigins);
|
|
6100
|
+
const suffix = external ? " \xB7 External" : "";
|
|
6101
|
+
return {
|
|
6102
|
+
title: type === "deployment_user_invited" ? `${senderName} invited ${email ?? "a new user"}${suffix}` : `${email ?? senderName} joined${suffix}`,
|
|
6103
|
+
variant: "info",
|
|
6104
|
+
...portalUrl && {
|
|
6105
|
+
actionLabel: "Manage users",
|
|
6106
|
+
target: { kind: "url", url: portalUrl }
|
|
6107
|
+
}
|
|
6108
|
+
};
|
|
6109
|
+
}
|
|
6110
|
+
case "contact_accepted":
|
|
6111
|
+
return { title: `${senderName} joined the platform`, variant: "success", target: workspace };
|
|
6112
|
+
case "workspace_access_request":
|
|
6113
|
+
return {
|
|
6114
|
+
title: `${senderName} asked for workspace access`,
|
|
6115
|
+
variant: "info",
|
|
6116
|
+
// Straight into the review — granting needs a workspace choice and a role, so a bare
|
|
6117
|
+
// "grant" action could never be right here.
|
|
6118
|
+
target: { kind: "access-request", notification: n }
|
|
6119
|
+
};
|
|
6120
|
+
case "storage_quota_exceeded":
|
|
6121
|
+
return {
|
|
6122
|
+
title: "Your storage is full. Mail still arrives, but new uploads and attachments are paused until you free space or add storage.",
|
|
6123
|
+
variant: "error",
|
|
6124
|
+
target: { kind: "storage" }
|
|
6125
|
+
};
|
|
6126
|
+
case "signup_reward":
|
|
6127
|
+
return {
|
|
6128
|
+
title: n.content ? `\u{1F389} Signup bonus \u2014 ${n.content}` : "\u{1F389} You earned a signup bonus!",
|
|
6129
|
+
variant: "success",
|
|
6130
|
+
target: { kind: "projects" }
|
|
6131
|
+
};
|
|
6132
|
+
case "referral_reward":
|
|
6133
|
+
return {
|
|
6134
|
+
title: n.content ? `\u{1F381} Reward \u2014 ${n.content}` : "\u{1F381} You earned a reward!",
|
|
6135
|
+
variant: "success",
|
|
6136
|
+
target: { kind: "projects" }
|
|
6137
|
+
};
|
|
6138
|
+
default:
|
|
6139
|
+
return null;
|
|
6140
|
+
}
|
|
6141
|
+
}
|
|
5082
6142
|
|
|
5083
6143
|
// src/directmessages/utils.ts
|
|
5084
6144
|
function userInitials(user) {
|
|
@@ -7387,6 +8447,6 @@ function hasVideoTrack(blob) {
|
|
|
7387
8447
|
});
|
|
7388
8448
|
}
|
|
7389
8449
|
|
|
7390
|
-
export { AccountClientProvider, ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotIcon, ArbiSessionStateProvider, 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, 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, SemanticSearch, StartByEmail, TypingIndicator, VideoCapture, VoiceNoteRecorder, accountPath, aliasTakenMessage, annotateThread, announceMailDraftReplaced, arbiAccountClient, arbiMailClient, captureFrameAsBlob, createArbiSessionStore, createMailClient, cropImage, dayKey, defaultMailAlias, describeActivity, downloadRecoveryFile, fileAttachment, formatIdentityPrice, getNotificationTypeMeta, getWorkspaceActionText, getWorkspaceKind, getWorkspaceSentPhrase, hasVideoTrack, identityStepFor, invalidateTagData, isAliasTakenError, isWorkspaceNotificationType, mailDraftIdFromContent, mailJson, mailQueryKeys, mountDiditVerification, nextAliasSuggestion, nextViewingDocument, parseActivityContent, parseDeleteAccountBlockers, pickRecentWorkspaces, redlineStats, resolveActiveWorkspace, selectIsGenerating, selectViewingDocumentId, textToArtifact, titleFromQuestion, toChatCitations, toNotificationPreferences, toProfileView, toRedlineMarkdown, toShellWorkspace, useAccountClient, useActOnStep, useAgentChats, useAgentConfig, useAgentModels, useAgentSession, useAgentWorkspaces, useAiTask, useArbiChat, useArbiConnected, useArbiDocumentSync, useArbiSessionState, useArbiSessionStore, useArbiShellWorkspaces, useArbiWebSocket, useArbiWsContext, useArbiWsMessage, useArbiWsStatus, useArbiWsStore, useArbiWsTask, useArbiWsTasks, useAuthorizeLimits, useAvatarCrop, useCameraStream, useClaimNativeAlias, useCloseAgentSession, useCommandPalette, useConfirmEmailChange, useConnectMailAccount, useContacts, useConversationActivity, useConversationPendingAuth, useConversationUsage, useCreateAgent, useCreateContact, useCreateFact, useCreateFacts, useCreateWork, useCreateWorkflow, useCurrentSessionId, useDeleteAccount, useDeleteAccountFlow, useDeleteContact, useDeleteFact, useDeleteSkill, useDeleteWorkflow, useDirectMessages, useDisconnectMailAccount, useEmailChange, useFacts, useFilteredProjects, useFollowThread, useGenerateAgentAvatar, useGrantAgentAccess, useIdentityVerification, useIdentityVerificationFlow, useInvalidateTagData, useInviteContacts, useMailAccounts, useMailCache, useMailClient, useMailDraftCompose, useMailDraftEditor, useMailDraftReplaced, useMailFolders, useMailMessage, useMailMessages, useMailOnline, useMailPolicy, useMailProjects, useMailUnlock, useMcpTools, useNameEditor, useNotificationPreferences, usePasswordChange, usePasswordChangeForm, usePendingContacts, usePlanWork, useProfile, useProjectConversationUsage, useProjectEvents, useRequestEmailChange, useRevokeAgentAccess, useRunConversation, useRunWorkflow, useSaveAgentConfig, useSaveMailDraft, useSearchFacts, useSemanticSearch, useSendBackStep, useSendMail, useSessions, useSetSkillVisibility, useSetTagValues, useShellWorkspaces, useSignOut, useSkillSource, useSkills, useStartAgentSession, useStartWorkQuery, useTagKindSchema, useTerminateSession, useUpdateContact, useUpdateConversation, useUpdateFact, useUpdateMailMessage, useUpdateProfile, useUpdateProjectFields, useUpdateTagKindSchema, useUpdateWorkflow, useUploadSkillFiles, useUserSettings, useVideoRecorder, useWorkNotifications, useWorkflowRuns, useWorkflows, useWorkspaceDocs, useWorkspaceNotificationLevel, userDisplayName, userInitials, workflowStepOf };
|
|
8450
|
+
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, invalidateTagData, isAliasTakenError, isDeploymentUserNotification, isQueuedCalendarWrite, isSignatureNotificationType, isWorkspaceNotificationType, mailDraftIdFromContent, mailJson, mailQueryKeys, mountDiditVerification, nextAliasSuggestion, nextViewingDocument, notificationUserName, parseActivityContent, parseDeleteAccountBlockers, pickRecentWorkspaces, redlineStats, resetCalendarAccountSyncState, resolveActiveWorkspace, safePortalUrl, selectIsGenerating, selectViewingDocumentId, signatureNotificationPhrase, signatureRequestMeta, textToArtifact, titleFromQuestion, toChatCitations, toNotificationPreferences, toProfileView, toRedlineMarkdown, toShellWorkspace, useAccountClient, useActOnStep, useAddHolidayCalendar, useAgentChats, useAgentConfig, useAgentModels, useAgentSession, useAgentWorkspaces, useAiTask, useAppPasswords, useArbiChat, useArbiConnected, useArbiDocumentSync, useArbiSessionState, useArbiSessionStore, useArbiShellWorkspaces, useArbiWebSocket, useArbiWsContext, useArbiWsMessage, useArbiWsStatus, useArbiWsStore, useArbiWsTask, useArbiWsTasks, 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, useDeleteEvent, useDeleteFact, useDeleteNotifications, useDeleteSkill, useDeleteWorkflow, useDirectMessages, useDisconnectCalendarAccount, useDisconnectMailAccount, useEmailChange, useFacts, useFetchCalendarEvent, useFilteredProjects, useFindTime, useFollowThread, useFreeBusy, useGenerateAgentAvatar, useGrantAgentAccess, useHolidayCountries, useIdentityVerification, useIdentityVerificationFlow, useImportCalendar, useInvalidateTagData, 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, useRequestEmailChange, useRespondToEvent, useResumeCalendarAccountConnect, useRevokeAgentAccess, useRevokeAppPassword, useRooms, useRunConversation, useRunWorkflow, useSaveAgentConfig, useSaveBookingPage, useSaveCalendarSettings, useSaveMailDraft, useSearchContacts, useSearchFacts, useSemanticSearch, useSendBackStep, useSendMail, useSessions, useSetSkillVisibility, useSetTagValues, useShareCalendar, useShellWorkspaces, useSignOut, useSkillSource, useSkills, useStartAgentSession, useStartCalendarAccountOAuth, useStartWorkQuery, useSubscribeCalendar, useSyncAccountsOnOpen, useSyncCalendarAccount, useTagKindSchema, useTerminateSession, useUnshareCalendar, useUpdateCalendar, useUpdateCalendarAccount, useUpdateContact, useUpdateConversation, useUpdateEvent, useUpdateFact, useUpdateMailMessage, useUpdateProfile, useUpdateProjectFields, useUpdateTagKindSchema, useUpdateWorkflow, useUploadSkillFiles, useUserSettings, useVideoRecorder, useWorkNotifications, useWorkflowRuns, useWorkflows, useWorkspaceDocs, useWorkspaceNotificationLevel, userDisplayName, userInitials, workflowStepOf };
|
|
7391
8451
|
//# sourceMappingURL=index.js.map
|
|
7392
8452
|
//# sourceMappingURL=index.js.map
|