@arbidocs/react 0.5.132 → 0.5.134

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/notifications/server-notifications.ts"],
4
- "sourcesContent": ["/**\n * What a server-persisted notification (`NotificationResponse`) says and where it leads \u2014 the one\n * type\u2192presentation mapping every surface reads (the arrival toast, the bell entry, the\n * notification centre), so wording cannot drift between them or between hosts.\n *\n * Titles derive from `type`, the sender and plaintext routing metadata only: the E2E-encrypted\n * content is never needed. Where an entry leads is data ({@link NotificationTarget}); the host\n * owns navigation and turns a target into its own route.\n */\n\nimport type { components } from '@arbidocs/client'\nimport { mailDraftIdFromContent } from '../mail/client'\nimport type { NotifyVariant } from './notify-store'\n\ntype NotificationResponse = components['schemas']['NotificationResponse']\ntype NotificationUser = NotificationResponse['sender']\n\n/** Where a notification leads. The host maps each kind onto its routes. */\nexport type NotificationTarget =\n /** A workspace's own page (a membership change). */\n | { kind: 'workspace'; workspaceId: string }\n /** A thread, scrolled to a message when given. */\n | { kind: 'conversation'; workspaceId?: string; conversationId: string; messageId?: string }\n /** A document: at a version, on a comment, or on a viewer tab when given. */\n | {\n kind: 'document'\n workspaceId?: string\n documentId: string\n version?: number\n commentId?: string\n tab?: 'pdf'\n }\n /** The mailbox, on a draft when given. */\n | { kind: 'mail'; draftId?: string }\n /** The workflows page, on a workflow (in its workspace) when given. */\n | { kind: 'workflows'; workflowId?: string; workspaceId?: string }\n /** Projects and their AI usage. */\n | { kind: 'projects' }\n | { kind: 'support'; ticketId: number }\n /** Storage settings. */\n | { kind: 'storage' }\n /** Where seats are added (the Box's licence page). */\n | { kind: 'seats' }\n /** Review a workspace access request (choose a workspace and a role). */\n | { kind: 'access-request'; notification: NotificationResponse }\n /** Call the sender back. */\n | { kind: 'call-back'; user: NotificationUser }\n /** An external page, opened in a new tab. */\n | { kind: 'url'; url: string }\n /** The calendar, on an event when given; `join`: join the event's online meeting. */\n | { kind: 'calendar'; eventId?: string; recurrenceId?: string | null; join?: boolean }\n\n/** A server notification's presentation: its sentence, severity, and where it leads. */\nexport interface ServerNotificationDescription {\n title: string\n variant: NotifyVariant\n /** The label of the action that opens {@link target} (\"Review and sign\"); default \"View\". */\n actionLabel?: string\n target?: NotificationTarget\n}\n\nexport interface DescribeServerNotificationOptions {\n /** The sender's display name; default their given and family name, else their email. */\n senderName?: string\n /** The name of a document the notification is about, when the host knows it (names are\n * encrypted, so a notification carries only the id). */\n documentName?: (workspaceId: string | null | undefined, documentId: string) => string | undefined\n /** The portal origins a deployment-user notice may link to. */\n portalOrigins?: readonly string[]\n}\n\n/** A person's display name: given and family name, else their email. */\nexport function notificationUserName(user: NotificationUser): string {\n return [user.given_name, user.family_name].filter(Boolean).join(' ') || user.email\n}\n\nconst CONVERSATION_ID = /^con-[a-zA-Z0-9]+$/\nconst WORKFLOW_ID = /^wfl-[a-zA-Z0-9]+$/\nconst DOCUMENT_ID = /^doc-[a-zA-Z0-9]+$/\n\nfunction parse(content: string | null | undefined): Record<string, unknown> | null {\n try {\n const value = JSON.parse(content || '{}') as unknown\n return value && typeof value === 'object' ? (value as Record<string, unknown>) : null\n } catch {\n return null\n }\n}\n\n/** Deadline metadata is intentionally plaintext; the confidential question stays in the thread. */\nexport function inputRequestTitle(content: string | null | undefined): string {\n const metadata = parse(content)\n if (!metadata) return 'ARBI needs your input \u2014 open the thread to reply'\n const timeout = typeof metadata.timeout_seconds === 'number' ? metadata.timeout_seconds : 300\n const minutes = Math.ceil(timeout / 60)\n const deadline = typeof metadata.expires_at === 'string' ? new Date(metadata.expires_at) : null\n if (deadline && Number.isFinite(deadline.getTime())) {\n return `ARBI needs your input \u2014 ${minutes} min to reply (until ${deadline.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })})`\n }\n return `ARBI needs your input \u2014 ${minutes} min to reply`\n}\n\n/**\n * The plaintext routing content of a `document_activity` notification: `{doc_ext_id, event,\n * reason, version}`. Opaque ids and a closed vocabulary only; never the file name.\n */\nexport function documentActivityMeta(content: string | null | undefined): {\n documentId?: string\n reason?: string\n version?: number\n} {\n const meta = parse(content)\n if (!meta) return {}\n const documentId =\n typeof meta.doc_ext_id === 'string' && DOCUMENT_ID.test(meta.doc_ext_id)\n ? meta.doc_ext_id\n : undefined\n const version =\n typeof meta.version === 'number' && Number.isInteger(meta.version) && meta.version > 0\n ? meta.version\n : undefined\n const reason = typeof meta.reason === 'string' ? meta.reason : undefined\n return { documentId, reason, version }\n}\n\n/** What a `document_activity` says after its sender: \"signed a document\", \"saved version 3 of a document\". */\nexport function documentActivityPhrase(content: string | null | undefined): string {\n const { reason, version } = documentActivityMeta(content)\n if (reason === 'signed') return 'signed a document'\n return version ? `saved version ${version} of a document` : 'saved a new version of a document'\n}\n\n/** The document and comment a `docx_mention` points at (routing ids only). */\nexport function docxMentionMeta(content: string | null | undefined): {\n documentId?: string\n commentId?: string\n} {\n const meta = parse(content)\n if (!meta || typeof meta.document_id !== 'string' || !DOCUMENT_ID.test(meta.document_id))\n return {}\n return {\n documentId: meta.document_id,\n commentId: typeof meta.comment_id === 'string' && meta.comment_id ? meta.comment_id : undefined,\n }\n}\n\n/**\n * The plaintext routing content of a signature-request notification: `{request_id, document_id,\n * signed_version?}`. Opaque ids only: the document's name is encrypted, so it is never in a\n * notification.\n */\nexport function signatureRequestMeta(content: string | null | undefined): {\n documentId?: string\n version?: number\n} {\n const meta = parse(content)\n if (!meta) return {}\n const documentId =\n typeof meta.document_id === 'string' && DOCUMENT_ID.test(meta.document_id)\n ? meta.document_id\n : undefined\n const version =\n typeof meta.signed_version === 'number' && Number.isInteger(meta.signed_version)\n ? meta.signed_version\n : undefined\n return { documentId, version }\n}\n\n/** The notification types of a signature request. */\nexport const SIGNATURE_NOTIFICATION_TYPES = [\n 'signature_requested',\n 'signature_completed',\n 'signature_declined',\n] as const\nexport type SignatureNotificationType = (typeof SIGNATURE_NOTIFICATION_TYPES)[number]\n\nexport function isSignatureNotificationType(\n type: string | null | undefined\n): type is SignatureNotificationType {\n return (SIGNATURE_NOTIFICATION_TYPES as readonly string[]).includes(type ?? '')\n}\n\n/**\n * What a signature notification says, around the person's name and the document's:\n * `{lead} [person] {verb} [document]{tail}`. The recipient reads it about the sender\n * (\"Priya Shah asked you to sign NDA.pdf\"); the sender, in their own activity, about what they did\n * (\"You asked Sam Lee to sign NDA.pdf\"), with the person left out when the sentence needs none.\n */\nexport function signatureNotificationPhrase(\n type: SignatureNotificationType,\n incoming: boolean\n): { lead: string; showPerson: boolean; verb: string; tail: string } {\n if (incoming) {\n switch (type) {\n case 'signature_requested':\n return { lead: '', showPerson: true, verb: 'asked you to sign', tail: '' }\n case 'signature_completed':\n return { lead: '', showPerson: true, verb: 'signed', tail: ' \u2014 everyone has now signed' }\n case 'signature_declined':\n return { lead: '', showPerson: true, verb: 'declined to sign', tail: '' }\n }\n }\n switch (type) {\n case 'signature_requested':\n return { lead: 'You asked', showPerson: true, verb: 'to sign', tail: '' }\n case 'signature_completed':\n return { lead: 'You signed', showPerson: false, verb: '', tail: ' \u2014 everyone has now signed' }\n case 'signature_declined':\n return { lead: 'You declined to sign', showPerson: false, verb: '', tail: '' }\n }\n}\n\n/**\n * Plaintext routing metadata on call notifications (`call_missed`): `{call_ext_id}`. Never a\n * title \u2014 titles are encrypted under the call's key.\n */\nexport function callNotificationMeta(content: string | null | undefined): { callExtId?: string } {\n const meta = parse(content)\n return {\n callExtId:\n typeof meta?.call_ext_id === 'string' && /^call-[a-zA-Z0-9]{8}$/.test(meta.call_ext_id)\n ? meta.call_ext_id\n : undefined,\n }\n}\n\n/** A Box had no seat for a new internal user: the inviter's invitation was not sent. Central\n * emails the inviter and the Box admins; this is the inviter's own notice. */\nexport const BOX_SEAT_REFUSED = 'box_seat_refused'\nexport const BOX_SEAT_REFUSED_TITLE =\n 'Invitation not sent: your Box has no seat left. Your Box admins have been notified and can add users in the ARBI portal.'\nexport const BOX_SEAT_REFUSED_ACTION = 'Open the ARBI portal'\n\n/** A deployment admin's notice about the Box's users (`deployment_user_invited` / `_registered`):\n * an invitation sent (sender = the inviter) or an account created (sender = the new user). */\nexport function isDeploymentUserNotification(type: string | null | undefined): boolean {\n return type === 'deployment_user_invited' || type === 'deployment_user_registered'\n}\n\n/** The portal origins a \"Manage users\" link may open by default. Anything else gets no button. */\nexport const ALLOWED_PORTAL_ORIGINS: readonly string[] = ['https://portal.arbicity.com']\n\n/** The portal link, only when it is https on an allowed portal origin. */\nexport function safePortalUrl(\n value: unknown,\n origins: readonly string[] = ALLOWED_PORTAL_ORIGINS\n): string | undefined {\n if (typeof value !== 'string') return undefined\n try {\n const url = new URL(value)\n if (url.protocol !== 'https:' || !origins.includes(url.origin)) return undefined\n return url.href\n } catch {\n return undefined\n }\n}\n\n/** Plaintext content of a deployment-user notification: `{email, user_type, portal_url}`. */\nexport function deploymentUserMeta(\n content: string | null | undefined,\n origins: readonly string[] = ALLOWED_PORTAL_ORIGINS\n): { email?: string; external: boolean; portalUrl?: string } {\n const meta = parse(content)\n if (!meta) return { external: false }\n const email = typeof meta.email === 'string' && meta.email.trim() ? meta.email.trim() : undefined\n return {\n email,\n external: meta.user_type === 'external',\n portalUrl: safePortalUrl(meta.portal_url, origins),\n }\n}\n\n/** A document's display name, as a document list shows it (its title, else its file name). */\nexport function documentDisplayName(\n doc:\n | { file_name?: string | null; doc_metadata?: { title?: string | null } | null }\n | null\n | undefined\n): string | undefined {\n return doc?.doc_metadata?.title || doc?.file_name || undefined\n}\n\n/** What the work notifications say in a list, where the sender has a column of their own. */\nexport const WORK_NOTIFICATION_LABELS: Readonly<Record<string, string>> = {\n conversation_ready: 'A task is ready',\n conversation_done: 'A task was marked done',\n conversation_notified: 'You were notified in a thread',\n workflow_failed: 'A workflow failed to run',\n}\n\nfunction conversationTarget(n: NotificationResponse): NotificationTarget | undefined {\n if (!n.conversation_ext_id || !CONVERSATION_ID.test(n.conversation_ext_id)) return undefined\n return {\n kind: 'conversation',\n workspaceId: n.workspace_ext_id ?? undefined,\n conversationId: n.conversation_ext_id,\n ...(n.message_ext_id ? { messageId: n.message_ext_id } : {}),\n }\n}\n\n/** The workflows page on the notification's workflow (`{workflow_ext_id}` in its content). */\nfunction workflowTarget(n: NotificationResponse): NotificationTarget {\n const workflowId = parse(n.content)?.workflow_ext_id\n return {\n kind: 'workflows',\n ...(typeof workflowId === 'string' && WORKFLOW_ID.test(workflowId) ? { workflowId } : {}),\n ...(n.workspace_ext_id ? { workspaceId: n.workspace_ext_id } : {}),\n }\n}\n\nfunction signatureTitle(\n n: NotificationResponse,\n senderName: string,\n documentName: DescribeServerNotificationOptions['documentName']\n): string {\n const type = n.type as SignatureNotificationType\n const { documentId } = signatureRequestMeta(n.content)\n const name = documentId ? documentName?.(n.workspace_ext_id, documentId) : undefined\n const fallback = type === 'signature_requested' ? 'a document' : 'your document'\n const { verb, tail } = signatureNotificationPhrase(type, true)\n return `${senderName} ${verb} ${name ?? fallback}${tail}`\n}\n\nfunction quotaPercent(type: string): number | null {\n if (type === 'quota_threshold_100') return 100\n if (type === 'quota_threshold_90') return 90\n if (type === 'quota_threshold_50') return 50\n return null\n}\n\n/**\n * One server notification \u2192 what it says to its recipient and where it leads, or null for\n * types without a sentence here (calendar events, sync completions: they have their own\n * surfaces).\n */\nexport function describeServerNotification(\n n: NotificationResponse,\n options: DescribeServerNotificationOptions = {}\n): ServerNotificationDescription | null {\n const senderName = options.senderName ?? notificationUserName(n.sender)\n const workspace: NotificationTarget | undefined = n.workspace_ext_id\n ? { kind: 'workspace', workspaceId: n.workspace_ext_id }\n : undefined\n const type = n.type as string\n\n if (type === BOX_SEAT_REFUSED) {\n return {\n title: BOX_SEAT_REFUSED_TITLE,\n variant: 'warning',\n actionLabel: BOX_SEAT_REFUSED_ACTION,\n target: { kind: 'seats' },\n }\n }\n const pct = quotaPercent(type)\n if (pct !== null) {\n return {\n title: `You have used ${pct}% of your daily AI limit for this project.`,\n variant: pct === 100 ? 'error' : pct === 90 ? 'warning' : 'info',\n target: { kind: 'projects' },\n }\n }\n\n switch (type) {\n case 'support_ticket_received':\n case 'support_ticket_reviewed':\n case 'support_ticket_resolved': {\n const ticketId = parse(n.content)?.ticket_id\n if (typeof ticketId !== 'number' || !Number.isSafeInteger(ticketId) || ticketId < 1)\n return null\n const suppliedReference = parse(n.content)?.ticket_reference\n const reference =\n typeof suppliedReference === 'string' &&\n /^[a-z0-9-]+-[0-9]+$/.test(suppliedReference) &&\n suppliedReference.endsWith(`-${ticketId}`)\n ? suppliedReference\n : `#${ticketId}`\n return {\n title:\n type === 'support_ticket_received'\n ? `We received support request ${reference}`\n : type === 'support_ticket_reviewed'\n ? `We have reviewed support request ${reference}`\n : `Support request ${reference} is resolved`,\n variant: 'success',\n actionLabel: type === 'support_ticket_resolved' ? 'View outcome' : 'View request',\n target: { kind: 'support', ticketId },\n }\n }\n case 'file_shared': {\n const meta = parse(n.content)\n const id = meta?.file_share_id\n if (typeof id !== 'string' || !/^fsh-[0-9a-f]{32}$/.test(id)) return null\n return {\n title: meta?.declined\n ? `${senderName} declined to sign a file`\n : meta?.completed\n ? 'Everyone has signed. Your PDF is ready.'\n : meta?.signature\n ? `${senderName} asked you to sign a file`\n : `${senderName} shared a file with you`,\n variant: meta?.declined ? 'warning' : meta?.completed ? 'success' : 'info',\n actionLabel: meta?.signature && !meta?.completed ? 'Review and sign' : 'Open file',\n target: { kind: 'url', url: `/shared-files/${id}` },\n }\n }\n case 'call_missed':\n return {\n title: `Missed call from ${senderName}`,\n variant: 'warning',\n actionLabel: 'Call back',\n target: { kind: 'call-back', user: n.sender },\n }\n case 'native_mail_received':\n return {\n title: 'New email in your encrypted inbox',\n variant: 'info',\n target: { kind: 'mail' },\n }\n case 'mail_draft_ready': {\n const draftId = mailDraftIdFromContent(n.content)\n return {\n title: `${senderName} left a draft email for you to review`,\n variant: 'info',\n target: { kind: 'mail', ...(draftId ? { draftId } : {}) },\n }\n }\n case 'workspaceuser_added_owner':\n return { title: `${senderName} added you as owner`, variant: 'info', target: workspace }\n case 'workspaceuser_added_collaborator':\n return {\n title: `${senderName} added you as collaborator`,\n variant: 'info',\n target: workspace,\n }\n case 'workspaceuser_added_guest':\n return { title: `${senderName} added you as read only`, variant: 'info', target: workspace }\n case 'workspaceuser_removed':\n return { title: `${senderName} removed you from a workspace`, variant: 'warning' }\n case 'workspaceuser_updated_owner':\n return {\n title: `${senderName} changed your role to owner`,\n variant: 'info',\n target: workspace,\n }\n case 'workspaceuser_updated_collaborator':\n return {\n title: `${senderName} changed your role to collaborator`,\n variant: 'info',\n target: workspace,\n }\n case 'workspaceuser_updated_guest':\n return {\n title: `${senderName} changed your role to read only`,\n variant: 'info',\n target: workspace,\n }\n case 'signature_requested':\n case 'signature_completed':\n case 'signature_declined': {\n const { documentId, version } = signatureRequestMeta(n.content)\n return {\n title: signatureTitle(n, senderName, options.documentName),\n variant:\n type === 'signature_completed'\n ? 'success'\n : type === 'signature_declined'\n ? 'warning'\n : 'info',\n actionLabel: type === 'signature_requested' ? 'Review and sign' : 'Open',\n // A request opens the current version on its PDF, where the banner offers \"Review and\n // sign\"; a completed request opens the signed copy.\n target: documentId\n ? {\n kind: 'document',\n workspaceId: n.workspace_ext_id ?? undefined,\n documentId,\n ...(version ? { version } : {}),\n tab: 'pdf',\n }\n : undefined,\n }\n }\n case 'docx_mention': {\n const { documentId, commentId } = docxMentionMeta(n.content)\n return {\n title: `${senderName} mentioned you in a document comment`,\n variant: 'info',\n target: documentId\n ? {\n kind: 'document',\n workspaceId: n.workspace_ext_id ?? undefined,\n documentId,\n ...(commentId ? { commentId } : {}),\n }\n : undefined,\n }\n }\n case 'agent_input_requested':\n return { title: inputRequestTitle(n.content), variant: 'info', target: conversationTarget(n) }\n case 'mention':\n return {\n title: `${senderName} mentioned you in a conversation`,\n variant: 'info',\n target: conversationTarget(n),\n }\n case 'thread_reply':\n return {\n title: `${senderName} replied in a thread`,\n variant: 'info',\n target: conversationTarget(n),\n }\n case 'document_activity': {\n const { documentId, version } = documentActivityMeta(n.content)\n return {\n title: `${senderName} ${documentActivityPhrase(n.content)}`,\n variant: 'info',\n target: documentId\n ? {\n kind: 'document',\n workspaceId: n.workspace_ext_id ?? undefined,\n documentId,\n ...(version ? { version } : {}),\n }\n : undefined,\n }\n }\n // Each of these opens the thread, so the person it is for finds it. One about your own thread\n // (you started the work) says so.\n case 'conversation_ready':\n return {\n title:\n n.sender.external_id === n.recipient.external_id\n ? 'Your thread is ready'\n : `${senderName}\u2019s thread is ready`,\n variant: 'info',\n target: conversationTarget(n),\n }\n case 'conversation_notified':\n return {\n title: `${senderName} notified you in a thread`,\n variant: 'info',\n target: conversationTarget(n),\n }\n case 'conversation_done':\n return {\n title: `${senderName} marked a thread done`,\n variant: 'success',\n target: conversationTarget(n),\n }\n case 'workflow_completed':\n return { title: 'A workflow completed', variant: 'success', target: workflowTarget(n) }\n // The failed run's thread when it has one (its error is there), else the workflow.\n case 'workflow_failed':\n return {\n title: 'A workflow failed to start',\n variant: 'error',\n target: conversationTarget(n) ?? workflowTarget(n),\n }\n case 'deployment_user_invited':\n case 'deployment_user_registered': {\n const { email, external, portalUrl } = deploymentUserMeta(n.content, options.portalOrigins)\n const suffix = external ? ' \u00B7 External' : ''\n return {\n title:\n type === 'deployment_user_invited'\n ? `${senderName} invited ${email ?? 'a new user'}${suffix}`\n : `${email ?? senderName} joined${suffix}`,\n variant: 'info',\n ...(portalUrl && {\n actionLabel: 'Manage users',\n target: { kind: 'url' as const, url: portalUrl },\n }),\n }\n }\n case 'contact_accepted':\n return { title: `${senderName} joined the platform`, variant: 'success', target: workspace }\n case 'workspace_access_request':\n return {\n title: `${senderName} asked for workspace access`,\n variant: 'info',\n // Straight into the review \u2014 granting needs a workspace choice and a role, so a bare\n // \"grant\" action could never be right here.\n target: { kind: 'access-request', notification: n },\n }\n case 'project_quota_warning': {\n let resource = 'usage'\n let percentage: number | null = null\n let upgrade = ''\n let impending = false\n try {\n const data = JSON.parse(n.content ?? '{}')\n resource = data.resource === 'storage_gb' ? 'storage' : 'AI credits'\n if (data.limit > 0) percentage = Math.round((data.used / data.limit) * 100)\n if (data.stage === 'before_upgrade') {\n impending = true\n const charge = new Intl.NumberFormat('en-GB', {\n style: 'currency',\n currency: data.currency || 'GBP',\n }).format(data.charge_ex_vat_pence / 100)\n upgrade = `An automatic ${resource} upgrade will now be attempted: ${charge} ex VAT.`\n } else if (data.automatic_upgrade === true) {\n upgrade =\n ' An automatic upgrade is available within your limit and will be attempted when needed, subject to payment.'\n } else if (data.automatic_upgrade === false) {\n upgrade =\n data.upgrade_reason === 'limit'\n ? ' No automatic upgrade fits your remaining limit. Increase it or add allowances to keep working.'\n : data.upgrade_reason === 'payment'\n ? ' Automatic upgrades are paused. Resolve your payment issue to keep working.'\n : ' Automatic upgrades are unavailable. Upgrade your plan or reduce usage to keep working.'\n }\n } catch {\n /* An old or malformed notice still opens project usage. */\n }\n return {\n title: impending\n ? upgrade\n : `Your project is approaching its ${resource} limit${percentage != null ? ` (${percentage}% used)` : ''}.${upgrade}`,\n variant: 'warning',\n target: { kind: 'projects' },\n }\n }\n case 'project_retention': {\n let deadline = ''\n try {\n const data = JSON.parse(n.content ?? '{}')\n if (data.deletion_at) deadline = new Date(data.deletion_at).toLocaleDateString('en-GB')\n } catch {\n /* display the recovery notice without a date */\n }\n return {\n title: `Your project subscription has ended. Export or resubscribe${deadline ? ` before ${deadline}` : ''} to keep its data.`,\n variant: 'warning',\n target: { kind: 'projects' },\n }\n }\n case 'storage_quota_exceeded':\n return {\n title:\n 'Your storage is full. Mail still arrives, but new uploads and attachments are paused until you free space or add storage.',\n variant: 'error',\n target: { kind: 'storage' },\n }\n case 'signup_reward':\n return {\n title: n.content ? `\uD83C\uDF89 Signup bonus \u2014 ${n.content}` : '\uD83C\uDF89 You earned a signup bonus!',\n variant: 'success',\n target: { kind: 'projects' },\n }\n case 'referral_reward':\n return {\n title: n.content ? `\uD83C\uDF81 Reward \u2014 ${n.content}` : '\uD83C\uDF81 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3C,oBACE,KAAK,mBAAmB,UACpB,oGACA,KAAK,mBAAmB,YACtB,gFACA;AAAA,QACV;AAAA,MACF,QAAQ;AAAA,MAER;AACA,aAAO;AAAA,QACL,OAAO,YACH,UACA,mCAAmC,QAAQ,SAAS,cAAc,OAAO,KAAK,UAAU,YAAY,EAAE,IAAI,OAAO;AAAA,QACrH,SAAS;AAAA,QACT,QAAQ,EAAE,MAAM,WAAW;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,KAAK,qBAAqB;AACxB,UAAI,WAAW;AACf,UAAI;AACF,cAAM,OAAO,KAAK,MAAM,EAAE,WAAW,IAAI;AACzC,YAAI,KAAK,YAAa,YAAW,IAAI,KAAK,KAAK,WAAW,EAAE,mBAAmB,OAAO;AAAA,MACxF,QAAQ;AAAA,MAER;AACA,aAAO;AAAA,QACL,OAAO,6DAA6D,WAAW,WAAW,QAAQ,KAAK,EAAE;AAAA,QACzG,SAAS;AAAA,QACT,QAAQ,EAAE,MAAM,WAAW;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,KAAK;AACH,aAAO;AAAA,QACL,OACE;AAAA,QACF,SAAS;AAAA,QACT,QAAQ,EAAE,MAAM,UAAU;AAAA,MAC5B;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,OAAO,EAAE,UAAU,iCAAqB,EAAE,OAAO,KAAK;AAAA,QACtD,SAAS;AAAA,QACT,QAAQ,EAAE,MAAM,WAAW;AAAA,MAC7B;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,OAAO,EAAE,UAAU,2BAAe,EAAE,OAAO,KAAK;AAAA,QAChD,SAAS;AAAA,QACT,QAAQ,EAAE,MAAM,WAAW;AAAA,MAC7B;AAAA,IACF;AACE,aAAO;AAAA,EACX;AACF;",
4
+ "sourcesContent": ["/**\n * What a server-persisted notification (`NotificationResponse`) says and where it leads \u2014 the one\n * type\u2192presentation mapping every surface reads (the arrival toast, the bell entry, the\n * notification centre), so wording cannot drift between them or between hosts.\n *\n * Titles derive from `type`, the sender and plaintext routing metadata only: the E2E-encrypted\n * content is never needed. Where an entry leads is data ({@link NotificationTarget}); the host\n * owns navigation and turns a target into its own route.\n */\n\nimport type { components } from '@arbidocs/client'\nimport { mailDraftIdFromContent } from '../mail/client'\nimport type { NotifyVariant } from './notify-store'\n\ntype NotificationResponse = components['schemas']['NotificationResponse']\ntype NotificationUser = NotificationResponse['sender']\n\n/** Where a notification leads. The host maps each kind onto its routes. */\nexport type NotificationTarget =\n /** A workspace's own page (a membership change). */\n | { kind: 'workspace'; workspaceId: string }\n /** A thread, scrolled to a message when given. */\n | { kind: 'conversation'; workspaceId?: string; conversationId: string; messageId?: string }\n /** A document: at a version, on a comment, or on a viewer tab when given. */\n | {\n kind: 'document'\n workspaceId?: string\n documentId: string\n version?: number\n commentId?: string\n tab?: 'pdf'\n }\n /** The mailbox, on a draft when given. */\n | { kind: 'mail'; draftId?: string }\n /** The workflows page, on a workflow (in its workspace) when given. */\n | { kind: 'workflows'; workflowId?: string; workspaceId?: string }\n /** Projects and their AI usage. */\n | { kind: 'projects' }\n | { kind: 'support'; ticketId: number }\n /** Storage settings. */\n | { kind: 'storage' }\n /** Where seats are added (the Box's licence page). */\n | { kind: 'seats' }\n /** Review a workspace access request (choose a workspace and a role). */\n | { kind: 'access-request'; notification: NotificationResponse }\n /** Call the sender back. */\n | { kind: 'call-back'; user: NotificationUser }\n /** An external page, opened in a new tab. */\n | { kind: 'url'; url: string }\n /** The calendar, on an event when given; `join`: join the event's online meeting. */\n | { kind: 'calendar'; eventId?: string; recurrenceId?: string | null; join?: boolean }\n\n/** A server notification's presentation: its sentence, severity, and where it leads. */\nexport interface ServerNotificationDescription {\n title: string\n variant: NotifyVariant\n /** The label of the action that opens {@link target} (\"Review and sign\"); default \"View\". */\n actionLabel?: string\n target?: NotificationTarget\n}\n\nexport interface DescribeServerNotificationOptions {\n /** The sender's display name; default their given and family name, else their email. */\n senderName?: string\n /** The name of a document the notification is about, when the host knows it (names are\n * encrypted, so a notification carries only the id). */\n documentName?: (workspaceId: string | null | undefined, documentId: string) => string | undefined\n /** The portal origins a deployment-user notice may link to. */\n portalOrigins?: readonly string[]\n}\n\n/** A person's display name: given and family name, else their email. */\nexport function notificationUserName(user: NotificationUser): string {\n return [user.given_name, user.family_name].filter(Boolean).join(' ') || user.email\n}\n\nconst CONVERSATION_ID = /^con-[a-zA-Z0-9]+$/\nconst WORKFLOW_ID = /^wfl-[a-zA-Z0-9]+$/\nconst DOCUMENT_ID = /^doc-[a-zA-Z0-9]+$/\n\nfunction parse(content: string | null | undefined): Record<string, unknown> | null {\n try {\n const value = JSON.parse(content || '{}') as unknown\n return value && typeof value === 'object' ? (value as Record<string, unknown>) : null\n } catch {\n return null\n }\n}\n\n/** Deadline metadata is intentionally plaintext; the confidential question stays in the thread. */\nexport function inputRequestTitle(content: string | null | undefined): string {\n const metadata = parse(content)\n if (!metadata) return 'ARBI needs your input \u2014 open the thread to reply'\n const timeout = typeof metadata.timeout_seconds === 'number' ? metadata.timeout_seconds : 300\n const minutes = Math.ceil(timeout / 60)\n const deadline = typeof metadata.expires_at === 'string' ? new Date(metadata.expires_at) : null\n if (deadline && Number.isFinite(deadline.getTime())) {\n return `ARBI needs your input \u2014 ${minutes} min to reply (until ${deadline.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })})`\n }\n return `ARBI needs your input \u2014 ${minutes} min to reply`\n}\n\n/**\n * The plaintext routing content of a `document_activity` notification: `{doc_ext_id, event,\n * reason, version}`. Opaque ids and a closed vocabulary only; never the file name.\n */\nexport function documentActivityMeta(content: string | null | undefined): {\n documentId?: string\n reason?: string\n version?: number\n} {\n const meta = parse(content)\n if (!meta) return {}\n const documentId =\n typeof meta.doc_ext_id === 'string' && DOCUMENT_ID.test(meta.doc_ext_id)\n ? meta.doc_ext_id\n : undefined\n const version =\n typeof meta.version === 'number' && Number.isInteger(meta.version) && meta.version > 0\n ? meta.version\n : undefined\n const reason = typeof meta.reason === 'string' ? meta.reason : undefined\n return { documentId, reason, version }\n}\n\n/** What a `document_activity` says after its sender: \"signed a document\", \"saved version 3 of a document\". */\nexport function documentActivityPhrase(content: string | null | undefined): string {\n const { reason, version } = documentActivityMeta(content)\n if (reason === 'signed') return 'signed a document'\n return version ? `saved version ${version} of a document` : 'saved a new version of a document'\n}\n\n/** The document and comment a `docx_mention` points at (routing ids only). */\nexport function docxMentionMeta(content: string | null | undefined): {\n documentId?: string\n commentId?: string\n} {\n const meta = parse(content)\n if (!meta || typeof meta.document_id !== 'string' || !DOCUMENT_ID.test(meta.document_id))\n return {}\n return {\n documentId: meta.document_id,\n commentId: typeof meta.comment_id === 'string' && meta.comment_id ? meta.comment_id : undefined,\n }\n}\n\n/**\n * The plaintext routing content of a signature-request notification: `{request_id, document_id,\n * signed_version?}`. Opaque ids only: the document's name is encrypted, so it is never in a\n * notification.\n */\nexport function signatureRequestMeta(content: string | null | undefined): {\n documentId?: string\n version?: number\n} {\n const meta = parse(content)\n if (!meta) return {}\n const documentId =\n typeof meta.document_id === 'string' && DOCUMENT_ID.test(meta.document_id)\n ? meta.document_id\n : undefined\n const version =\n typeof meta.signed_version === 'number' && Number.isInteger(meta.signed_version)\n ? meta.signed_version\n : undefined\n return { documentId, version }\n}\n\n/** The notification types of a signature request. */\nexport const SIGNATURE_NOTIFICATION_TYPES = [\n 'signature_requested',\n 'signature_completed',\n 'signature_declined',\n] as const\nexport type SignatureNotificationType = (typeof SIGNATURE_NOTIFICATION_TYPES)[number]\n\nexport function isSignatureNotificationType(\n type: string | null | undefined\n): type is SignatureNotificationType {\n return (SIGNATURE_NOTIFICATION_TYPES as readonly string[]).includes(type ?? '')\n}\n\n/**\n * What a signature notification says, around the person's name and the document's:\n * `{lead} [person] {verb} [document]{tail}`. The recipient reads it about the sender\n * (\"Priya Shah asked you to sign NDA.pdf\"); the sender, in their own activity, about what they did\n * (\"You asked Sam Lee to sign NDA.pdf\"), with the person left out when the sentence needs none.\n */\nexport function signatureNotificationPhrase(\n type: SignatureNotificationType,\n incoming: boolean\n): { lead: string; showPerson: boolean; verb: string; tail: string } {\n if (incoming) {\n switch (type) {\n case 'signature_requested':\n return { lead: '', showPerson: true, verb: 'asked you to sign', tail: '' }\n case 'signature_completed':\n return { lead: '', showPerson: true, verb: 'signed', tail: ' \u2014 everyone has now signed' }\n case 'signature_declined':\n return { lead: '', showPerson: true, verb: 'declined to sign', tail: '' }\n }\n }\n switch (type) {\n case 'signature_requested':\n return { lead: 'You asked', showPerson: true, verb: 'to sign', tail: '' }\n case 'signature_completed':\n return { lead: 'You signed', showPerson: false, verb: '', tail: ' \u2014 everyone has now signed' }\n case 'signature_declined':\n return { lead: 'You declined to sign', showPerson: false, verb: '', tail: '' }\n }\n}\n\n/**\n * Plaintext routing metadata on call notifications (`call_missed`): `{call_ext_id}`. Never a\n * title \u2014 titles are encrypted under the call's key.\n */\nexport function callNotificationMeta(content: string | null | undefined): { callExtId?: string } {\n const meta = parse(content)\n return {\n callExtId:\n typeof meta?.call_ext_id === 'string' && /^call-[a-zA-Z0-9]{8}$/.test(meta.call_ext_id)\n ? meta.call_ext_id\n : undefined,\n }\n}\n\n/** A Box had no seat for a new internal user: the inviter's invitation was not sent. Central\n * emails the inviter and the Box admins; this is the inviter's own notice. */\nexport const BOX_SEAT_REFUSED = 'box_seat_refused'\nexport const BOX_SEAT_REFUSED_TITLE =\n 'Invitation not sent: your Box has no seat left. Your Box admins have been notified and can add users in the ARBI portal.'\nexport const BOX_SEAT_REFUSED_ACTION = 'Open the ARBI portal'\n\n/** A deployment admin's notice about the Box's users (`deployment_user_invited` / `_registered`):\n * an invitation sent (sender = the inviter) or an account created (sender = the new user). */\nexport function isDeploymentUserNotification(type: string | null | undefined): boolean {\n return type === 'deployment_user_invited' || type === 'deployment_user_registered'\n}\n\n/** The portal origins a \"Manage users\" link may open by default. Anything else gets no button. */\nexport const ALLOWED_PORTAL_ORIGINS: readonly string[] = ['https://portal.arbicity.com']\n\n/** The portal link, only when it is https on an allowed portal origin. */\nexport function safePortalUrl(\n value: unknown,\n origins: readonly string[] = ALLOWED_PORTAL_ORIGINS\n): string | undefined {\n if (typeof value !== 'string') return undefined\n try {\n const url = new URL(value)\n if (url.protocol !== 'https:' || !origins.includes(url.origin)) return undefined\n return url.href\n } catch {\n return undefined\n }\n}\n\n/** Plaintext content of a deployment-user notification: `{email, user_type, portal_url}`. */\nexport function deploymentUserMeta(\n content: string | null | undefined,\n origins: readonly string[] = ALLOWED_PORTAL_ORIGINS\n): { email?: string; external: boolean; portalUrl?: string } {\n const meta = parse(content)\n if (!meta) return { external: false }\n const email = typeof meta.email === 'string' && meta.email.trim() ? meta.email.trim() : undefined\n return {\n email,\n external: meta.user_type === 'external',\n portalUrl: safePortalUrl(meta.portal_url, origins),\n }\n}\n\n/** A document's display name, as a document list shows it (its title, else its file name). */\nexport function documentDisplayName(\n doc:\n | { file_name?: string | null; doc_metadata?: { title?: string | null } | null }\n | null\n | undefined\n): string | undefined {\n return doc?.doc_metadata?.title || doc?.file_name || undefined\n}\n\n/** What the work notifications say in a list, where the sender has a column of their own. */\nexport const WORK_NOTIFICATION_LABELS: Readonly<Record<string, string>> = {\n conversation_ready: 'A task is ready',\n conversation_done: 'A task was marked done',\n conversation_notified: 'You were notified in a thread',\n workflow_failed: 'A workflow failed to run',\n}\n\nfunction conversationTarget(n: NotificationResponse): NotificationTarget | undefined {\n if (!n.conversation_ext_id || !CONVERSATION_ID.test(n.conversation_ext_id)) return undefined\n return {\n kind: 'conversation',\n workspaceId: n.workspace_ext_id ?? undefined,\n conversationId: n.conversation_ext_id,\n ...(n.message_ext_id ? { messageId: n.message_ext_id } : {}),\n }\n}\n\n/** The workflows page on the notification's workflow (`{workflow_ext_id}` in its content). */\nfunction workflowTarget(n: NotificationResponse): NotificationTarget {\n const workflowId = parse(n.content)?.workflow_ext_id\n return {\n kind: 'workflows',\n ...(typeof workflowId === 'string' && WORKFLOW_ID.test(workflowId) ? { workflowId } : {}),\n ...(n.workspace_ext_id ? { workspaceId: n.workspace_ext_id } : {}),\n }\n}\n\nfunction signatureTitle(\n n: NotificationResponse,\n senderName: string,\n documentName: DescribeServerNotificationOptions['documentName']\n): string {\n const type = n.type as SignatureNotificationType\n const { documentId } = signatureRequestMeta(n.content)\n const name = documentId ? documentName?.(n.workspace_ext_id, documentId) : undefined\n const fallback = type === 'signature_requested' ? 'a document' : 'your document'\n const { verb, tail } = signatureNotificationPhrase(type, true)\n return `${senderName} ${verb} ${name ?? fallback}${tail}`\n}\n\nfunction quotaPercent(type: string): number | null {\n if (type === 'quota_threshold_100') return 100\n if (type === 'quota_threshold_90') return 90\n if (type === 'quota_threshold_50') return 50\n return null\n}\n\n/**\n * One server notification \u2192 what it says to its recipient and where it leads, or null for\n * types without a sentence here (calendar events, sync completions: they have their own\n * surfaces).\n */\nexport function describeServerNotification(\n n: NotificationResponse,\n options: DescribeServerNotificationOptions = {}\n): ServerNotificationDescription | null {\n const senderName = options.senderName ?? notificationUserName(n.sender)\n const workspace: NotificationTarget | undefined = n.workspace_ext_id\n ? { kind: 'workspace', workspaceId: n.workspace_ext_id }\n : undefined\n const type = n.type as string\n\n if (type === BOX_SEAT_REFUSED) {\n return {\n title: BOX_SEAT_REFUSED_TITLE,\n variant: 'warning',\n actionLabel: BOX_SEAT_REFUSED_ACTION,\n target: { kind: 'seats' },\n }\n }\n const pct = quotaPercent(type)\n if (pct !== null) {\n return {\n title: `You have used ${pct}% of your daily AI limit for this project.`,\n variant: pct === 100 ? 'error' : pct === 90 ? 'warning' : 'info',\n target: { kind: 'projects' },\n }\n }\n\n switch (type) {\n case 'support_ticket_received':\n case 'support_ticket_reviewed':\n case 'support_ticket_resolved': {\n const ticketId = parse(n.content)?.ticket_id\n if (typeof ticketId !== 'number' || !Number.isSafeInteger(ticketId) || ticketId < 1)\n return null\n const suppliedReference = parse(n.content)?.ticket_reference\n const reference =\n typeof suppliedReference === 'string' &&\n /^[a-z0-9-]+-[0-9]+$/.test(suppliedReference) &&\n suppliedReference.endsWith(`-${ticketId}`)\n ? suppliedReference\n : `#${ticketId}`\n return {\n title:\n type === 'support_ticket_received'\n ? `We received support request ${reference}`\n : type === 'support_ticket_reviewed'\n ? `We have reviewed support request ${reference}`\n : `Support request ${reference} is resolved`,\n variant: 'success',\n actionLabel: type === 'support_ticket_resolved' ? 'View outcome' : 'View request',\n target: { kind: 'support', ticketId },\n }\n }\n case 'file_shared': {\n const meta = parse(n.content)\n const id = meta?.file_share_id\n if (typeof id !== 'string' || !/^fsh-[0-9a-f]{32}$/.test(id)) return null\n return {\n title: meta?.declined\n ? `${senderName} declined to sign a file`\n : meta?.completed\n ? 'Everyone has signed. Your PDF is ready.'\n : meta?.signature\n ? `${senderName} asked you to sign a file`\n : `${senderName} shared a file with you`,\n variant: meta?.declined ? 'warning' : meta?.completed ? 'success' : 'info',\n actionLabel: meta?.signature && !meta?.completed ? 'Review and sign' : 'Open file',\n target: { kind: 'url', url: `/shared-files/${id}` },\n }\n }\n case 'call_missed':\n return {\n title: `Missed call from ${senderName}`,\n variant: 'warning',\n actionLabel: 'Call back',\n target: { kind: 'call-back', user: n.sender },\n }\n case 'native_mail_received':\n return {\n title: 'New email in your encrypted inbox',\n variant: 'info',\n target: { kind: 'mail' },\n }\n case 'mail_draft_ready': {\n const draftId = mailDraftIdFromContent(n.content)\n return {\n title: `${senderName} left a draft email for you to review`,\n variant: 'info',\n target: { kind: 'mail', ...(draftId ? { draftId } : {}) },\n }\n }\n case 'workspaceuser_added_owner':\n return { title: `${senderName} added you as owner`, variant: 'info', target: workspace }\n case 'workspaceuser_added_collaborator':\n return {\n title: `${senderName} added you as collaborator`,\n variant: 'info',\n target: workspace,\n }\n case 'workspaceuser_added_guest':\n return { title: `${senderName} added you as a viewer`, variant: 'info', target: workspace }\n case 'workspaceuser_removed':\n return { title: `${senderName} removed you from a workspace`, variant: 'warning' }\n case 'workspaceuser_updated_owner':\n return {\n title: `${senderName} changed your role to owner`,\n variant: 'info',\n target: workspace,\n }\n case 'workspaceuser_updated_collaborator':\n return {\n title: `${senderName} changed your role to collaborator`,\n variant: 'info',\n target: workspace,\n }\n case 'workspaceuser_updated_guest':\n return {\n title: `${senderName} changed your role to viewer`,\n variant: 'info',\n target: workspace,\n }\n case 'signature_requested':\n case 'signature_completed':\n case 'signature_declined': {\n const { documentId, version } = signatureRequestMeta(n.content)\n return {\n title: signatureTitle(n, senderName, options.documentName),\n variant:\n type === 'signature_completed'\n ? 'success'\n : type === 'signature_declined'\n ? 'warning'\n : 'info',\n actionLabel: type === 'signature_requested' ? 'Review and sign' : 'Open',\n // A request opens the current version on its PDF, where the banner offers \"Review and\n // sign\"; a completed request opens the signed copy.\n target: documentId\n ? {\n kind: 'document',\n workspaceId: n.workspace_ext_id ?? undefined,\n documentId,\n ...(version ? { version } : {}),\n tab: 'pdf',\n }\n : undefined,\n }\n }\n case 'docx_mention': {\n const { documentId, commentId } = docxMentionMeta(n.content)\n return {\n title: `${senderName} mentioned you in a document comment`,\n variant: 'info',\n target: documentId\n ? {\n kind: 'document',\n workspaceId: n.workspace_ext_id ?? undefined,\n documentId,\n ...(commentId ? { commentId } : {}),\n }\n : undefined,\n }\n }\n case 'agent_input_requested':\n return { title: inputRequestTitle(n.content), variant: 'info', target: conversationTarget(n) }\n case 'mention':\n return {\n title: `${senderName} mentioned you in a conversation`,\n variant: 'info',\n target: conversationTarget(n),\n }\n case 'thread_reply':\n return {\n title: `${senderName} replied in a thread`,\n variant: 'info',\n target: conversationTarget(n),\n }\n case 'document_activity': {\n const { documentId, version } = documentActivityMeta(n.content)\n return {\n title: `${senderName} ${documentActivityPhrase(n.content)}`,\n variant: 'info',\n target: documentId\n ? {\n kind: 'document',\n workspaceId: n.workspace_ext_id ?? undefined,\n documentId,\n ...(version ? { version } : {}),\n }\n : undefined,\n }\n }\n // Each of these opens the thread, so the person it is for finds it. One about your own thread\n // (you started the work) says so.\n case 'conversation_ready':\n return {\n title:\n n.sender.external_id === n.recipient.external_id\n ? 'Your thread is ready'\n : `${senderName}\u2019s thread is ready`,\n variant: 'info',\n target: conversationTarget(n),\n }\n case 'conversation_notified':\n return {\n title: `${senderName} notified you in a thread`,\n variant: 'info',\n target: conversationTarget(n),\n }\n case 'conversation_done':\n return {\n title: `${senderName} marked a thread done`,\n variant: 'success',\n target: conversationTarget(n),\n }\n case 'workflow_completed':\n return { title: 'A workflow completed', variant: 'success', target: workflowTarget(n) }\n // The failed run's thread when it has one (its error is there), else the workflow.\n case 'workflow_failed':\n return {\n title: 'A workflow failed to start',\n variant: 'error',\n target: conversationTarget(n) ?? workflowTarget(n),\n }\n case 'deployment_user_invited':\n case 'deployment_user_registered': {\n const { email, external, portalUrl } = deploymentUserMeta(n.content, options.portalOrigins)\n const suffix = external ? ' \u00B7 External' : ''\n return {\n title:\n type === 'deployment_user_invited'\n ? `${senderName} invited ${email ?? 'a new user'}${suffix}`\n : `${email ?? senderName} joined${suffix}`,\n variant: 'info',\n ...(portalUrl && {\n actionLabel: 'Manage users',\n target: { kind: 'url' as const, url: portalUrl },\n }),\n }\n }\n case 'contact_accepted':\n return { title: `${senderName} joined the platform`, variant: 'success', target: workspace }\n case 'workspace_access_request':\n return {\n title: `${senderName} asked for workspace access`,\n variant: 'info',\n // Straight into the review \u2014 granting needs a workspace choice and a role, so a bare\n // \"grant\" action could never be right here.\n target: { kind: 'access-request', notification: n },\n }\n case 'project_quota_warning': {\n let resource = 'usage'\n let percentage: number | null = null\n let upgrade = ''\n let impending = false\n try {\n const data = JSON.parse(n.content ?? '{}')\n resource = data.resource === 'storage_gb' ? 'storage' : 'AI credits'\n if (data.limit > 0) percentage = Math.round((data.used / data.limit) * 100)\n if (data.stage === 'before_upgrade') {\n impending = true\n const charge = new Intl.NumberFormat('en-GB', {\n style: 'currency',\n currency: data.currency || 'GBP',\n }).format(data.charge_ex_vat_pence / 100)\n upgrade = `An automatic ${resource} upgrade will now be attempted: ${charge} ex VAT.`\n } else if (data.automatic_upgrade === true) {\n upgrade =\n ' An automatic upgrade is available within your limit and will be attempted when needed, subject to payment.'\n } else if (data.automatic_upgrade === false) {\n upgrade =\n data.upgrade_reason === 'limit'\n ? ' No automatic upgrade fits your remaining limit. Increase it or add allowances to keep working.'\n : data.upgrade_reason === 'payment'\n ? ' Automatic upgrades are paused. Resolve your payment issue to keep working.'\n : ' Automatic upgrades are unavailable. Upgrade your plan or reduce usage to keep working.'\n }\n } catch {\n /* An old or malformed notice still opens project usage. */\n }\n return {\n title: impending\n ? upgrade\n : `Your project is approaching its ${resource} limit${percentage != null ? ` (${percentage}% used)` : ''}.${upgrade}`,\n variant: 'warning',\n target: { kind: 'projects' },\n }\n }\n case 'project_retention': {\n let deadline = ''\n try {\n const data = JSON.parse(n.content ?? '{}')\n if (data.deletion_at) deadline = new Date(data.deletion_at).toLocaleDateString('en-GB')\n } catch {\n /* display the recovery notice without a date */\n }\n return {\n title: `Your project subscription has ended. Export or resubscribe${deadline ? ` before ${deadline}` : ''} to keep its data.`,\n variant: 'warning',\n target: { kind: 'projects' },\n }\n }\n case 'storage_quota_exceeded':\n return {\n title:\n 'Your storage is full. Mail still arrives, but new uploads and attachments are paused until you free space or add storage.',\n variant: 'error',\n target: { kind: 'storage' },\n }\n case 'signup_reward':\n return {\n title: n.content ? `\uD83C\uDF89 Signup bonus \u2014 ${n.content}` : '\uD83C\uDF89 You earned a signup bonus!',\n variant: 'success',\n target: { kind: 'projects' },\n }\n case 'referral_reward':\n return {\n title: n.content ? `\uD83C\uDF81 Reward \u2014 ${n.content}` : '\uD83C\uDF81 You earned a reward!',\n variant: 'success',\n target: { kind: 'projects' },\n }\n default:\n return null\n }\n}\n"],
5
+ "mappings": "AAWA,SAAS,8BAA8B;AA6DhC,SAAS,qBAAqB,MAAgC;AACnE,SAAO,CAAC,KAAK,YAAY,KAAK,WAAW,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,KAAK,KAAK;AAC/E;AAEA,MAAM,kBAAkB;AACxB,MAAM,cAAc;AACpB,MAAM,cAAc;AAEpB,SAAS,MAAM,SAAoE;AACjF,MAAI;AACF,UAAM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AW;AACf,UAAI;AACF,cAAM,OAAO,KAAK,MAAM,EAAE,WAAW,IAAI;AACzC,YAAI,KAAK,YAAa,YAAW,IAAI,KAAK,KAAK,WAAW,EAAE,mBAAmB,OAAO;AAAA,MACxF,QAAQ;AAAA,MAER;AACA,aAAO;AAAA,QACL,OAAO,6DAA6D,WAAW,WAAW,QAAQ,KAAK,EAAE;AAAA,QACzG,SAAS;AAAA,QACT,QAAQ,EAAE,MAAM,WAAW;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,KAAK;AACH,aAAO;AAAA,QACL,OACE;AAAA,QACF,SAAS;AAAA,QACT,QAAQ,EAAE,MAAM,UAAU;AAAA,MAC5B;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,OAAO,EAAE,UAAU,iCAAqB,EAAE,OAAO,KAAK;AAAA,QACtD,SAAS;AAAA,QACT,QAAQ,EAAE,MAAM,WAAW;AAAA,MAC7B;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,OAAO,EAAE,UAAU,2BAAe,EAAE,OAAO,KAAK;AAAA,QAChD,SAAS;AAAA,QACT,QAAQ,EAAE,MAAM,WAAW;AAAA,MAC7B;AAAA,IACF;AACE,aAAO;AAAA,EACX;AACF;",
6
6
  "names": []
7
7
  }
@@ -4,13 +4,24 @@ import {
4
4
  isReplayableArbiMutation,
5
5
  isRestorableArbiQueryOnline
6
6
  } from "./offline.js";
7
+ let storageFailed = false;
8
+ async function withStorage(operation) {
9
+ if (storageFailed) return void 0;
10
+ try {
11
+ return await operation();
12
+ } catch {
13
+ storageFailed = true;
14
+ console.warn("[offline] Browser storage unavailable; offline persistence is disabled.");
15
+ return void 0;
16
+ }
17
+ }
7
18
  const IDB_KEY = "arbi-react-query-cache";
8
19
  const OWNER_KEY = "arbi-react-query-cache-owner";
9
20
  const CACHE_BUSTER = "arbi-rq-v2";
10
21
  const MAX_AGE = 1e3 * 60 * 60 * 24 * 7;
11
22
  function createIDBPersister() {
12
23
  return {
13
- persistClient: (client) => set(IDB_KEY, client),
24
+ persistClient: (client) => withStorage(() => set(IDB_KEY, client)),
14
25
  // The offline persister must be INERT when online. Because the documents
15
26
  // list never auto-refetches, a rehydrated copy would be trusted
16
27
  // indefinitely and surface stale statuses across a reload — e.g. a document
@@ -23,7 +34,7 @@ function createIDBPersister() {
23
34
  // Queued offline mutations and all other queries restore normally. When
24
35
  // offline we keep everything so the pages still have something to show.
25
36
  restoreClient: async () => {
26
- const persisted = await get(IDB_KEY);
37
+ const persisted = await withStorage(() => get(IDB_KEY));
27
38
  if (!persisted) return persisted;
28
39
  const isOffline = typeof navigator !== "undefined" && navigator.onLine === false;
29
40
  if (isOffline) return persisted;
@@ -32,13 +43,15 @@ function createIDBPersister() {
32
43
  );
33
44
  return persisted;
34
45
  },
35
- removeClient: () => del(IDB_KEY)
46
+ removeClient: () => withStorage(() => del(IDB_KEY))
36
47
  };
37
48
  }
38
49
  async function claimOfflineQueue(userExtId) {
39
- const owner = await get(OWNER_KEY);
40
- if (owner !== userExtId) await del(IDB_KEY);
41
- await set(OWNER_KEY, userExtId);
50
+ await withStorage(async () => {
51
+ const owner = await get(OWNER_KEY);
52
+ if (owner !== userExtId) await del(IDB_KEY);
53
+ await set(OWNER_KEY, userExtId);
54
+ });
42
55
  }
43
56
  function createArbiQueryPersistOptions() {
44
57
  return {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/query-persist.ts"],
4
- "sourcesContent": ["/**\n * The query cache kept for an offline start (`createArbiQueryClient({ persist: true })`).\n *\n * Persists a *metadata-only* slice of the query cache to IndexedDB so an already signed-in user\n * can cold-start offline and still see their workspaces and documents list (and open a pinned\n * document). Deliberately conservative about what is written to disk: only the families\n * {@link isOfflineReadableArbiQuery} names; NEVER conversations, messages or document bytes (the\n * pinned bytes live separately, encrypted: `offline-documents.ts`).\n *\n * An async IndexedDB persister (idb-keyval, structured clone) rather than the JSON sync persister:\n * the robust choice for binary-capable storage.\n */\n\nimport { get, set, del } from 'idb-keyval'\nimport type {\n PersistedClient,\n Persister,\n PersistQueryClientOptions,\n} from '@tanstack/react-query-persist-client'\nimport {\n isOfflineReadableArbiQuery,\n isReplayableArbiMutation,\n isRestorableArbiQueryOnline,\n} from './offline'\n\nconst IDB_KEY = 'arbi-react-query-cache'\n\n// Which account the persisted offline queue belongs to. The queue is one record\n// per browser, so it is only valid for the account that wrote it.\nconst OWNER_KEY = 'arbi-react-query-cache-owner'\n\n// Bump to invalidate everyone's persisted cache after an incompatible change.\n// v2: documents and their writes moved to the `@arbidocs/react` keys.\nconst CACHE_BUSTER = 'arbi-rq-v2'\n\nconst MAX_AGE = 1000 * 60 * 60 * 24 * 7 // 7 days\n\n/** What `<PersistQueryClientProvider persistOptions>` takes for the package's offline cache. */\nexport type ArbiQueryPersistOptions = Omit<PersistQueryClientOptions, 'queryClient'>\n\nfunction createIDBPersister(): Persister {\n return {\n persistClient: (client: PersistedClient) => set(IDB_KEY, client),\n // The offline persister must be INERT when online. Because the documents\n // list never auto-refetches, a rehydrated copy would be trusted\n // indefinitely and surface stale statuses across a reload \u2014 e.g. a document\n // that finished processing while the tab was closed (its one-shot\n // completion WS event is long gone) still renders as \"queued\". So when\n // online we strip that query from the restored cache; it then loads\n // fresh from the server exactly as it did before offline support existed.\n // A document caught mid-processing is stripped for the same reason, and the\n // entitlements are read fresh (isRestorableArbiQueryOnline).\n // Queued offline mutations and all other queries restore normally. When\n // offline we keep everything so the pages still have something to show.\n restoreClient: async () => {\n const persisted = await get<PersistedClient>(IDB_KEY)\n if (!persisted) return persisted\n const isOffline = typeof navigator !== 'undefined' && navigator.onLine === false\n if (isOffline) return persisted\n persisted.clientState.queries = persisted.clientState.queries.filter((q) =>\n isRestorableArbiQueryOnline(q.queryKey, q.state.data)\n )\n return persisted\n },\n removeClient: () => del(IDB_KEY),\n }\n}\n\n/**\n * Hand the offline write queue to the account that is signing in. Queued edits\n * are replayed under whoever is logged in on reload, so a queue left by a\n * different account (or one whose owner was never recorded) must be discarded\n * here \u2014 otherwise another person's edit syncs, and fails, as this user.\n * The same account keeps its queue across logins.\n */\nexport async function claimOfflineQueue(userExtId: string): Promise<void> {\n const owner = await get<string>(OWNER_KEY)\n if (owner !== userExtId) await del(IDB_KEY)\n await set(OWNER_KEY, userExtId)\n}\n\n/** The persistence of the offline cache (see the module comment). */\nexport function createArbiQueryPersistOptions(): ArbiQueryPersistOptions {\n return {\n persister: createIDBPersister(),\n maxAge: MAX_AGE,\n buster: CACHE_BUSTER,\n dehydrateOptions: {\n // Persist mutations that were paused offline so a queued write (apply tag,\n // edit field) survives a reload and replays on reconnect. Resuming them\n // after a reload requires the registered mutation defaults\n // (registerArbiMutationDefaults). Scope to real offline EDITS: an incidental\n // paused mutation (e.g. workspace-open) isn't a user change to queue/replay.\n shouldDehydrateMutation: (mutation) =>\n mutation.state.isPaused && isReplayableArbiMutation(mutation.options.mutationKey),\n shouldDehydrateQuery: (query) => {\n if (query.state.status !== 'success') return false\n // Every query key comes from the package factory: its offline families are the whole\n // list (document metadata, the workspace list, the settings, the projects, the\n // entitlements; never a document's content or bytes).\n return isOfflineReadableArbiQuery(query.queryKey)\n },\n },\n }\n}\n"],
5
- "mappings": "AAaA,SAAS,KAAK,KAAK,WAAW;AAM9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,UAAU;AAIhB,MAAM,YAAY;AAIlB,MAAM,eAAe;AAErB,MAAM,UAAU,MAAO,KAAK,KAAK,KAAK;AAKtC,SAAS,qBAAgC;AACvC,SAAO;AAAA,IACL,eAAe,CAAC,WAA4B,IAAI,SAAS,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAY/D,eAAe,YAAY;AACzB,YAAM,YAAY,MAAM,IAAqB,OAAO;AACpD,UAAI,CAAC,UAAW,QAAO;AACvB,YAAM,YAAY,OAAO,cAAc,eAAe,UAAU,WAAW;AAC3E,UAAI,UAAW,QAAO;AACtB,gBAAU,YAAY,UAAU,UAAU,YAAY,QAAQ;AAAA,QAAO,CAAC,MACpE,4BAA4B,EAAE,UAAU,EAAE,MAAM,IAAI;AAAA,MACtD;AACA,aAAO;AAAA,IACT;AAAA,IACA,cAAc,MAAM,IAAI,OAAO;AAAA,EACjC;AACF;AASA,eAAsB,kBAAkB,WAAkC;AACxE,QAAM,QAAQ,MAAM,IAAY,SAAS;AACzC,MAAI,UAAU,UAAW,OAAM,IAAI,OAAO;AAC1C,QAAM,IAAI,WAAW,SAAS;AAChC;AAGO,SAAS,gCAAyD;AACvE,SAAO;AAAA,IACL,WAAW,mBAAmB;AAAA,IAC9B,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMhB,yBAAyB,CAAC,aACxB,SAAS,MAAM,YAAY,yBAAyB,SAAS,QAAQ,WAAW;AAAA,MAClF,sBAAsB,CAAC,UAAU;AAC/B,YAAI,MAAM,MAAM,WAAW,UAAW,QAAO;AAI7C,eAAO,2BAA2B,MAAM,QAAQ;AAAA,MAClD;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["/**\n * The query cache kept for an offline start (`createArbiQueryClient({ persist: true })`).\n *\n * Persists a *metadata-only* slice of the query cache to IndexedDB so an already signed-in user\n * can cold-start offline and still see their workspaces and documents list (and open a pinned\n * document). Deliberately conservative about what is written to disk: only the families\n * {@link isOfflineReadableArbiQuery} names; NEVER conversations, messages or document bytes (the\n * pinned bytes live separately, encrypted: `offline-documents.ts`).\n *\n * An async IndexedDB persister (idb-keyval, structured clone) rather than the JSON sync persister:\n * the robust choice for binary-capable storage.\n */\n\nimport { get, set, del } from 'idb-keyval'\nimport type {\n PersistedClient,\n Persister,\n PersistQueryClientOptions,\n} from '@tanstack/react-query-persist-client'\nimport {\n isOfflineReadableArbiQuery,\n isReplayableArbiMutation,\n isRestorableArbiQueryOnline,\n} from './offline'\n\nlet storageFailed = false\n\n// Optional offline persistence must never prevent an online sign-in. Once storage fails,\n// keep it disabled for this page, including restoration, so another account's queue cannot replay.\nasync function withStorage<T>(operation: () => Promise<T>): Promise<T | undefined> {\n if (storageFailed) return undefined\n try {\n return await operation()\n } catch {\n storageFailed = true\n console.warn('[offline] Browser storage unavailable; offline persistence is disabled.')\n return undefined\n }\n}\n\nconst IDB_KEY = 'arbi-react-query-cache'\n\n// Which account the persisted offline queue belongs to. The queue is one record\n// per browser, so it is only valid for the account that wrote it.\nconst OWNER_KEY = 'arbi-react-query-cache-owner'\n\n// Bump to invalidate everyone's persisted cache after an incompatible change.\n// v2: documents and their writes moved to the `@arbidocs/react` keys.\nconst CACHE_BUSTER = 'arbi-rq-v2'\n\nconst MAX_AGE = 1000 * 60 * 60 * 24 * 7 // 7 days\n\n/** What `<PersistQueryClientProvider persistOptions>` takes for the package's offline cache. */\nexport type ArbiQueryPersistOptions = Omit<PersistQueryClientOptions, 'queryClient'>\n\nfunction createIDBPersister(): Persister {\n return {\n persistClient: (client: PersistedClient) => withStorage(() => set(IDB_KEY, client)),\n // The offline persister must be INERT when online. Because the documents\n // list never auto-refetches, a rehydrated copy would be trusted\n // indefinitely and surface stale statuses across a reload \u2014 e.g. a document\n // that finished processing while the tab was closed (its one-shot\n // completion WS event is long gone) still renders as \"queued\". So when\n // online we strip that query from the restored cache; it then loads\n // fresh from the server exactly as it did before offline support existed.\n // A document caught mid-processing is stripped for the same reason, and the\n // entitlements are read fresh (isRestorableArbiQueryOnline).\n // Queued offline mutations and all other queries restore normally. When\n // offline we keep everything so the pages still have something to show.\n restoreClient: async () => {\n const persisted = await withStorage(() => get<PersistedClient>(IDB_KEY))\n if (!persisted) return persisted\n const isOffline = typeof navigator !== 'undefined' && navigator.onLine === false\n if (isOffline) return persisted\n persisted.clientState.queries = persisted.clientState.queries.filter((q) =>\n isRestorableArbiQueryOnline(q.queryKey, q.state.data)\n )\n return persisted\n },\n removeClient: () => withStorage(() => del(IDB_KEY)),\n }\n}\n\n/**\n * Hand the offline write queue to the account that is signing in. Queued edits\n * are replayed under whoever is logged in on reload, so a queue left by a\n * different account (or one whose owner was never recorded) must be discarded\n * here \u2014 otherwise another person's edit syncs, and fails, as this user.\n * The same account keeps its queue across logins.\n */\nexport async function claimOfflineQueue(userExtId: string): Promise<void> {\n await withStorage(async () => {\n const owner = await get<string>(OWNER_KEY)\n if (owner !== userExtId) await del(IDB_KEY)\n await set(OWNER_KEY, userExtId)\n })\n}\n\n/** The persistence of the offline cache (see the module comment). */\nexport function createArbiQueryPersistOptions(): ArbiQueryPersistOptions {\n return {\n persister: createIDBPersister(),\n maxAge: MAX_AGE,\n buster: CACHE_BUSTER,\n dehydrateOptions: {\n // Persist mutations that were paused offline so a queued write (apply tag,\n // edit field) survives a reload and replays on reconnect. Resuming them\n // after a reload requires the registered mutation defaults\n // (registerArbiMutationDefaults). Scope to real offline EDITS: an incidental\n // paused mutation (e.g. workspace-open) isn't a user change to queue/replay.\n shouldDehydrateMutation: (mutation) =>\n mutation.state.isPaused && isReplayableArbiMutation(mutation.options.mutationKey),\n shouldDehydrateQuery: (query) => {\n if (query.state.status !== 'success') return false\n // Every query key comes from the package factory: its offline families are the whole\n // list (document metadata, the workspace list, the settings, the projects, the\n // entitlements; never a document's content or bytes).\n return isOfflineReadableArbiQuery(query.queryKey)\n },\n },\n }\n}\n"],
5
+ "mappings": "AAaA,SAAS,KAAK,KAAK,WAAW;AAM9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,IAAI,gBAAgB;AAIpB,eAAe,YAAe,WAAqD;AACjF,MAAI,cAAe,QAAO;AAC1B,MAAI;AACF,WAAO,MAAM,UAAU;AAAA,EACzB,QAAQ;AACN,oBAAgB;AAChB,YAAQ,KAAK,yEAAyE;AACtF,WAAO;AAAA,EACT;AACF;AAEA,MAAM,UAAU;AAIhB,MAAM,YAAY;AAIlB,MAAM,eAAe;AAErB,MAAM,UAAU,MAAO,KAAK,KAAK,KAAK;AAKtC,SAAS,qBAAgC;AACvC,SAAO;AAAA,IACL,eAAe,CAAC,WAA4B,YAAY,MAAM,IAAI,SAAS,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAYlF,eAAe,YAAY;AACzB,YAAM,YAAY,MAAM,YAAY,MAAM,IAAqB,OAAO,CAAC;AACvE,UAAI,CAAC,UAAW,QAAO;AACvB,YAAM,YAAY,OAAO,cAAc,eAAe,UAAU,WAAW;AAC3E,UAAI,UAAW,QAAO;AACtB,gBAAU,YAAY,UAAU,UAAU,YAAY,QAAQ;AAAA,QAAO,CAAC,MACpE,4BAA4B,EAAE,UAAU,EAAE,MAAM,IAAI;AAAA,MACtD;AACA,aAAO;AAAA,IACT;AAAA,IACA,cAAc,MAAM,YAAY,MAAM,IAAI,OAAO,CAAC;AAAA,EACpD;AACF;AASA,eAAsB,kBAAkB,WAAkC;AACxE,QAAM,YAAY,YAAY;AAC5B,UAAM,QAAQ,MAAM,IAAY,SAAS;AACzC,QAAI,UAAU,UAAW,OAAM,IAAI,OAAO;AAC1C,UAAM,IAAI,WAAW,SAAS;AAAA,EAChC,CAAC;AACH;AAGO,SAAS,gCAAyD;AACvE,SAAO;AAAA,IACL,WAAW,mBAAmB;AAAA,IAC9B,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMhB,yBAAyB,CAAC,aACxB,SAAS,MAAM,YAAY,yBAAyB,SAAS,QAAQ,WAAW;AAAA,MAClF,sBAAsB,CAAC,UAAU;AAC/B,YAAI,MAAM,MAAM,WAAW,UAAW,QAAO;AAI7C,eAAO,2BAA2B,MAAM,QAAQ;AAAA,MAClD;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,84 @@
1
+ function createBrowserStateStorage(databaseName, storeName) {
2
+ let dbInstance = null;
3
+ let storageFailed = false;
4
+ const memoryState = /* @__PURE__ */ new Map();
5
+ async function withAppStorage(operation) {
6
+ if (storageFailed) return void 0;
7
+ try {
8
+ return await operation();
9
+ } catch {
10
+ storageFailed = true;
11
+ dbInstance?.close();
12
+ dbInstance = null;
13
+ console.warn("[persist] Browser storage unavailable; keeping UI state in memory.");
14
+ return void 0;
15
+ }
16
+ }
17
+ function openDB() {
18
+ if (dbInstance) return Promise.resolve(dbInstance);
19
+ if (typeof indexedDB === "undefined") return Promise.resolve(null);
20
+ return new Promise((resolve, reject) => {
21
+ const request = indexedDB.open(databaseName, 1);
22
+ request.onerror = () => reject(request.error);
23
+ request.onsuccess = () => {
24
+ dbInstance = request.result;
25
+ resolve(request.result);
26
+ };
27
+ request.onupgradeneeded = (event) => {
28
+ const db = event.target.result;
29
+ if (!db.objectStoreNames.contains(storeName))
30
+ db.createObjectStore(storeName, { keyPath: "key" });
31
+ };
32
+ });
33
+ }
34
+ function promisify(request) {
35
+ return new Promise((resolve, reject) => {
36
+ request.onsuccess = () => resolve(request.result);
37
+ request.onerror = () => reject(request.error);
38
+ });
39
+ }
40
+ const storage = {
41
+ async get(key) {
42
+ const result = await withAppStorage(async () => {
43
+ const db = await openDB();
44
+ if (!db) return memoryState.get(key) ?? null;
45
+ const saved = await promisify(
46
+ db.transaction([storeName], "readonly").objectStore(storeName).get(key)
47
+ );
48
+ return saved?.value ?? null;
49
+ });
50
+ return result === void 0 ? memoryState.get(key) ?? null : result;
51
+ },
52
+ async set(key, value) {
53
+ memoryState.set(key, value);
54
+ await withAppStorage(async () => {
55
+ const db = await openDB();
56
+ if (!db) return;
57
+ await promisify(
58
+ db.transaction([storeName], "readwrite").objectStore(storeName).put({ key, value })
59
+ );
60
+ });
61
+ },
62
+ async remove(key) {
63
+ memoryState.delete(key);
64
+ await withAppStorage(async () => {
65
+ const db = await openDB();
66
+ if (!db) return;
67
+ await promisify(db.transaction([storeName], "readwrite").objectStore(storeName).delete(key));
68
+ });
69
+ },
70
+ async clear() {
71
+ memoryState.clear();
72
+ await withAppStorage(async () => {
73
+ const db = await openDB();
74
+ if (!db) return;
75
+ await promisify(db.transaction([storeName], "readwrite").objectStore(storeName).clear());
76
+ });
77
+ }
78
+ };
79
+ return storage;
80
+ }
81
+ export {
82
+ createBrowserStateStorage
83
+ };
84
+ //# sourceMappingURL=browser-storage.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/session/browser-storage.ts"],
4
+ "sourcesContent": ["import type { ArbiKeyValueStorage } from './persist'\n\n/** IndexedDB for nonsensitive UI state, with in-memory fallback when browser storage fails. */\nexport function createBrowserStateStorage(databaseName: string, storeName: string) {\n let dbInstance: IDBDatabase | null = null\n let storageFailed = false\n const memoryState = new Map<string, string>()\n\n async function withAppStorage<T>(operation: () => Promise<T>): Promise<T | undefined> {\n if (storageFailed) return undefined\n try {\n return await operation()\n } catch {\n storageFailed = true\n dbInstance?.close()\n dbInstance = null\n console.warn('[persist] Browser storage unavailable; keeping UI state in memory.')\n return undefined\n }\n }\n /** The app's database; null where there is no IndexedDB (unit tests): nothing is kept there. */\n function openDB(): Promise<IDBDatabase | null> {\n if (dbInstance) return Promise.resolve(dbInstance)\n if (typeof indexedDB === 'undefined') return Promise.resolve(null)\n return new Promise((resolve, reject) => {\n const request = indexedDB.open(databaseName, 1)\n request.onerror = () => reject(request.error)\n request.onsuccess = () => {\n dbInstance = request.result\n resolve(request.result)\n }\n request.onupgradeneeded = (event) => {\n const db = (event.target as IDBOpenDBRequest).result\n if (!db.objectStoreNames.contains(storeName))\n db.createObjectStore(storeName, { keyPath: 'key' })\n }\n })\n }\n\n function promisify<T>(request: IDBRequest<T>): Promise<T> {\n return new Promise((resolve, reject) => {\n request.onsuccess = () => resolve(request.result)\n request.onerror = () => reject(request.error)\n })\n }\n\n /** The app's IndexedDB as a key-value storage. */\n const storage: ArbiKeyValueStorage & { clear(): Promise<void> } = {\n async get(key) {\n const result = await withAppStorage(async () => {\n const db = await openDB()\n if (!db) return memoryState.get(key) ?? null\n const saved = await promisify(\n db.transaction([storeName], 'readonly').objectStore(storeName).get(key)\n )\n return (saved as { value?: string } | undefined)?.value ?? null\n })\n return result === undefined ? (memoryState.get(key) ?? null) : result\n },\n async set(key, value) {\n memoryState.set(key, value)\n await withAppStorage(async () => {\n const db = await openDB()\n if (!db) return\n await promisify(\n db.transaction([storeName], 'readwrite').objectStore(storeName).put({ key, value })\n )\n })\n },\n async remove(key) {\n memoryState.delete(key)\n await withAppStorage(async () => {\n const db = await openDB()\n if (!db) return\n await promisify(db.transaction([storeName], 'readwrite').objectStore(storeName).delete(key))\n })\n },\n async clear() {\n memoryState.clear()\n await withAppStorage(async () => {\n const db = await openDB()\n if (!db) return\n await promisify(db.transaction([storeName], 'readwrite').objectStore(storeName).clear())\n })\n },\n }\n\n return storage\n}\n"],
5
+ "mappings": "AAGO,SAAS,0BAA0B,cAAsB,WAAmB;AACjF,MAAI,aAAiC;AACrC,MAAI,gBAAgB;AACpB,QAAM,cAAc,oBAAI,IAAoB;AAE5C,iBAAe,eAAkB,WAAqD;AACpF,QAAI,cAAe,QAAO;AAC1B,QAAI;AACF,aAAO,MAAM,UAAU;AAAA,IACzB,QAAQ;AACN,sBAAgB;AAChB,kBAAY,MAAM;AAClB,mBAAa;AACb,cAAQ,KAAK,oEAAoE;AACjF,aAAO;AAAA,IACT;AAAA,EACF;AAEA,WAAS,SAAsC;AAC7C,QAAI,WAAY,QAAO,QAAQ,QAAQ,UAAU;AACjD,QAAI,OAAO,cAAc,YAAa,QAAO,QAAQ,QAAQ,IAAI;AACjE,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,YAAM,UAAU,UAAU,KAAK,cAAc,CAAC;AAC9C,cAAQ,UAAU,MAAM,OAAO,QAAQ,KAAK;AAC5C,cAAQ,YAAY,MAAM;AACxB,qBAAa,QAAQ;AACrB,gBAAQ,QAAQ,MAAM;AAAA,MACxB;AACA,cAAQ,kBAAkB,CAAC,UAAU;AACnC,cAAM,KAAM,MAAM,OAA4B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EAAE,OAAO,GAAG,CAAC;AAAA,MAC7F,CAAC;AAAA,IACH;AAAA,IACA,MAAM,QAAQ;AACZ,kBAAY,MAAM;AAClB,YAAM,eAAe,YAAY;AAC/B,cAAM,KAAK,MAAM,OAAO;AACxB,YAAI,CAAC,GAAI;AACT,cAAM,UAAU,GAAG,YAAY,CAAC,SAAS,GAAG,WAAW,EAAE,YAAY,SAAS,EAAE,MAAM,CAAC;AAAA,MACzF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -68,6 +68,7 @@ import {
68
68
  createSealedDraftStorage
69
69
  } from "./drafts.js";
70
70
  import { createUiStateStorage } from "./ui-state-storage.js";
71
+ import { createBrowserStateStorage } from "./browser-storage.js";
71
72
  export {
72
73
  DEFAULT_DOCUMENT_VIEWER_STATE,
73
74
  DOCUMENT_VIEWER_PANEL,
@@ -87,6 +88,7 @@ export {
87
88
  createArbiLayoutStore,
88
89
  createArbiSessionStore,
89
90
  createArbiWorkspaceStore,
91
+ createBrowserStateStorage,
90
92
  createDebouncedWriter,
91
93
  createSealedDraftStorage,
92
94
  createStoragePersist,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/session/index.ts"],
4
- "sourcesContent": ["export {\n useArbiSessionState,\n useArbiSessionStore,\n useSessionView,\n useSessionPageTab,\n useTransientView,\n} from './session-hooks'\nexport {\n useArbiSession,\n useSignedInSession,\n type ArbiSessionStatus,\n type ArbiSignedInSession,\n} from './signed-in'\nexport {\n createArbiSessionStore,\n composeArbiSessionStore,\n conversationKey,\n selectDraft,\n selectIsGenerating,\n selectViewingDocumentId,\n EMPTY_SESSION_STATE,\n type ArbiSessionParts,\n type ArbiSessionState,\n type ArbiSessionStore,\n type ArbiSessionStoreOptions,\n type ArbiWorkspaceStatus,\n layoutActionsOf,\n} from './store'\nexport {\n createArbiDocumentSessionStore,\n nextViewingDocument,\n parseSavedDocuments,\n restoreSavedDocuments,\n savedDocumentsOf,\n DEFAULT_DOCUMENT_VIEWER_STATE,\n EMPTY_DOCUMENT_STATE,\n type ArbiDocumentCommentTarget,\n type ArbiDocumentSessionActions,\n type ArbiDocumentSessionState,\n type ArbiDocumentSessionStore,\n type ArbiDocumentSessionStoreOptions,\n type ArbiDocumentsPersist,\n type ArbiDocumentViewerState,\n type ArbiDraftDocument,\n type ArbiDraftKind,\n type ArbiPassageCitationState,\n type ArbiPickedPassage,\n type ArbiSavedDocuments,\n type ArbiViewerTab,\n type ArbiViewingDocument,\n type ArbiViewingDocumentInput,\n} from './documents'\nexport {\n createArbiChatStore,\n parseSavedChat,\n savedChatOf,\n EMPTY_CHAT_STATE,\n type ArbiChatActions,\n type ArbiChatState,\n type ArbiChatStore,\n type ArbiChatStoreOptions,\n type ArbiConversationDocument,\n type ArbiConversationGeneration,\n type ArbiMessageTimer,\n type ArbiSavedChat,\n type TurnTools,\n} from './chat'\nexport {\n createArbiLayoutStore,\n closePanelIn,\n defaultLayoutState,\n DOCUMENT_VIEWER_PANEL,\n dmTabId,\n isPanelOpen,\n openPanelIn,\n panelPlace,\n parseSavedLayout,\n restoreLayout,\n savedLayoutOf,\n type ArbiDmTab,\n type ArbiGridLayoutState,\n type ArbiLayoutActions,\n type ArbiLayoutState,\n type ArbiLayoutStore,\n type ArbiLayoutStoreOptions,\n type ArbiPanelMode,\n type ArbiPanelsState,\n type ArbiSavedLayout,\n type ArbiShellState,\n type ArbiSidebarState,\n type ArbiTabsState,\n type ArbiThreadTabsController,\n type ArbiViewsState,\n} from './layout'\nexport {\n threadTabId,\n MAX_THREAD_TABS,\n type ArbiThreadComposer,\n type ArbiThreadTab,\n type ArbiThreadTabShow,\n type ArbiThreadTabView,\n type ArbiThreadTabsState,\n} from './thread-tabs'\nexport {\n createDebouncedWriter,\n createStoragePersist,\n flushOnPageExit,\n type ArbiKeyValueStorage,\n type ArbiSessionPersist,\n type DebouncedWriter,\n type DebouncedWriterOptions,\n type StoragePersistOptions,\n} from './persist'\nexport {\n createArbiWorkspaceStore,\n browserWorkspaceStorage,\n readWorkspaceLastOpened,\n WORKSPACE_STORAGE_KEY,\n WORKSPACE_LAST_OPENED_KEY,\n type ArbiWorkspaceState,\n type ArbiWorkspaceStorage,\n type ArbiWorkspaceStore,\n type ArbiWorkspaceStoreOptions,\n type BrowserWorkspaceStorageOptions,\n} from './workspace'\nexport {\n clearSealedDrafts,\n createSealedDraftStorage,\n type ArbiDraftStorage,\n type DraftKeyValueStore,\n type SealedDraftStorageOptions,\n} from './drafts'\n\nexport { createUiStateStorage, type UiStateStorage } from './ui-state-storage'\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAMA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAgBK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAUK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAeK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAMK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AAEP,SAAS,4BAAiD;",
4
+ "sourcesContent": ["export {\n useArbiSessionState,\n useArbiSessionStore,\n useSessionView,\n useSessionPageTab,\n useTransientView,\n} from './session-hooks'\nexport {\n useArbiSession,\n useSignedInSession,\n type ArbiSessionStatus,\n type ArbiSignedInSession,\n} from './signed-in'\nexport {\n createArbiSessionStore,\n composeArbiSessionStore,\n conversationKey,\n selectDraft,\n selectIsGenerating,\n selectViewingDocumentId,\n EMPTY_SESSION_STATE,\n type ArbiSessionParts,\n type ArbiSessionState,\n type ArbiSessionStore,\n type ArbiSessionStoreOptions,\n type ArbiWorkspaceStatus,\n layoutActionsOf,\n} from './store'\nexport {\n createArbiDocumentSessionStore,\n nextViewingDocument,\n parseSavedDocuments,\n restoreSavedDocuments,\n savedDocumentsOf,\n DEFAULT_DOCUMENT_VIEWER_STATE,\n EMPTY_DOCUMENT_STATE,\n type ArbiDocumentCommentTarget,\n type ArbiDocumentSessionActions,\n type ArbiDocumentSessionState,\n type ArbiDocumentSessionStore,\n type ArbiDocumentSessionStoreOptions,\n type ArbiDocumentsPersist,\n type ArbiDocumentViewerState,\n type ArbiDraftDocument,\n type ArbiDraftKind,\n type ArbiPassageCitationState,\n type ArbiPickedPassage,\n type ArbiSavedDocuments,\n type ArbiViewerTab,\n type ArbiViewingDocument,\n type ArbiViewingDocumentInput,\n} from './documents'\nexport {\n createArbiChatStore,\n parseSavedChat,\n savedChatOf,\n EMPTY_CHAT_STATE,\n type ArbiChatActions,\n type ArbiChatState,\n type ArbiChatStore,\n type ArbiChatStoreOptions,\n type ArbiConversationDocument,\n type ArbiConversationGeneration,\n type ArbiMessageTimer,\n type ArbiSavedChat,\n type TurnTools,\n} from './chat'\nexport {\n createArbiLayoutStore,\n closePanelIn,\n defaultLayoutState,\n DOCUMENT_VIEWER_PANEL,\n dmTabId,\n isPanelOpen,\n openPanelIn,\n panelPlace,\n parseSavedLayout,\n restoreLayout,\n savedLayoutOf,\n type ArbiDmTab,\n type ArbiGridLayoutState,\n type ArbiLayoutActions,\n type ArbiLayoutState,\n type ArbiLayoutStore,\n type ArbiLayoutStoreOptions,\n type ArbiPanelMode,\n type ArbiPanelsState,\n type ArbiSavedLayout,\n type ArbiShellState,\n type ArbiSidebarState,\n type ArbiTabsState,\n type ArbiThreadTabsController,\n type ArbiViewsState,\n} from './layout'\nexport {\n threadTabId,\n MAX_THREAD_TABS,\n type ArbiThreadComposer,\n type ArbiThreadTab,\n type ArbiThreadTabShow,\n type ArbiThreadTabView,\n type ArbiThreadTabsState,\n} from './thread-tabs'\nexport {\n createDebouncedWriter,\n createStoragePersist,\n flushOnPageExit,\n type ArbiKeyValueStorage,\n type ArbiSessionPersist,\n type DebouncedWriter,\n type DebouncedWriterOptions,\n type StoragePersistOptions,\n} from './persist'\nexport {\n createArbiWorkspaceStore,\n browserWorkspaceStorage,\n readWorkspaceLastOpened,\n WORKSPACE_STORAGE_KEY,\n WORKSPACE_LAST_OPENED_KEY,\n type ArbiWorkspaceState,\n type ArbiWorkspaceStorage,\n type ArbiWorkspaceStore,\n type ArbiWorkspaceStoreOptions,\n type BrowserWorkspaceStorageOptions,\n} from './workspace'\nexport {\n clearSealedDrafts,\n createSealedDraftStorage,\n type ArbiDraftStorage,\n type DraftKeyValueStore,\n type SealedDraftStorageOptions,\n} from './drafts'\n\nexport { createUiStateStorage, type UiStateStorage } from './ui-state-storage'\n\nexport { createBrowserStateStorage } from './browser-storage'\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAMA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAgBK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAUK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAeK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAMK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AAEP,SAAS,4BAAiD;AAE1D,SAAS,iCAAiC;",
6
6
  "names": []
7
7
  }
@@ -268,7 +268,7 @@ declare function applyChatEvent(arbi: Arbi, queryClient: QueryClient, event: {
268
268
 
269
269
  declare const CALL_CHAT_TOPIC = "arbi.chat";
270
270
  /** What a workspace guest sees instead of a composer in a thread call's meeting chat. */
271
- declare const READ_ONLY_MEETING_TEXT = "Read only: you can\u2019t post in this meeting chat";
271
+ declare const READ_ONLY_MEETING_TEXT = "Viewer: you can\u2019t post in this meeting chat";
272
272
  /** Longest message accepted over the data channel (well under LiveKit's reliable-packet limit). */
273
273
  declare const CALL_CHAT_MAX_CHARS = 4000;
274
274
  /** What one data packet carries, encrypted under K. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arbidocs/react",
3
- "version": "0.5.132",
3
+ "version": "0.5.134",
4
4
  "description": "React hooks and provider for the ARBI SDK",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -117,8 +117,8 @@
117
117
  "build-storybook": "storybook build"
118
118
  },
119
119
  "dependencies": {
120
- "@arbidocs/client": "0.5.132",
121
- "@arbidocs/sdk": "0.5.132",
120
+ "@arbidocs/client": "0.5.134",
121
+ "@arbidocs/sdk": "0.5.134",
122
122
  "@didit-protocol/sdk-web": "0.4.0",
123
123
  "@livekit/components-react": "2.9.24",
124
124
  "@radix-ui/react-avatar": "^1.2.0",