@burdenoff/microfe-integrations 2026.1107.1 → 2026.1107.2
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/generated/global-types.d.ts +208 -168
- package/dist/generated/global-types.d.ts.map +1 -1
- package/dist/generated/wspace-operations.d.ts +235 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +206 -103
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +8724 -352
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/dist/generated/wspace-types.js +5 -1
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/integrations/components/MailMessageBody.d.ts +7 -0
- package/dist/integrations/components/MailMessageBody.d.ts.map +1 -0
- package/dist/integrations/components/MailMessageBody.js +175 -0
- package/dist/integrations/components/MailMessageBody.js.map +1 -0
- package/dist/integrations/hooks/useMailbox.d.ts +65 -4
- package/dist/integrations/hooks/useMailbox.d.ts.map +1 -1
- package/dist/integrations/hooks/useMailbox.js +108 -29
- package/dist/integrations/hooks/useMailbox.js.map +1 -1
- package/dist/integrations/pages/MailboxInbox.d.ts.map +1 -1
- package/dist/integrations/pages/MailboxInbox.js +418 -251
- package/dist/integrations/pages/MailboxInbox.js.map +1 -1
- package/dist/integrations/store/mailboxStore.d.ts +3 -0
- package/dist/integrations/store/mailboxStore.d.ts.map +1 -1
- package/dist/integrations/store/mailboxStore.js +7 -0
- package/dist/integrations/store/mailboxStore.js.map +1 -1
- package/dist/integrations/utils/mailHtml.d.ts +33 -0
- package/dist/integrations/utils/mailHtml.d.ts.map +1 -0
- package/dist/integrations/utils/mailHtml.js +127 -0
- package/dist/integrations/utils/mailHtml.js.map +1 -0
- package/dist/node_modules/dompurify/dist/purify.es.js +894 -0
- package/dist/node_modules/dompurify/dist/purify.es.js.map +1 -0
- package/package.json +5 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MailMessageBody.d.ts","sourceRoot":"","sources":["../../../src/integrations/components/MailMessageBody.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAqB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAyGnF,wBAAgB,eAAe,CAAC,KAAK,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,oBAAoB,CAAA;CAAE,+BAqI7F"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { useTr as e } from "../hooks/useTr.js";
|
|
2
|
+
import { useMailboxAttachmentContent as t } from "../hooks/useMailbox.js";
|
|
3
|
+
import { base64ToBlob as n, formatBytes as r, mailFrameDocument as i, sanitizeMailHtml as a } from "../utils/mailHtml.js";
|
|
4
|
+
import { useMemo as o, useRef as s, useState as c } from "react";
|
|
5
|
+
import { Download as l, FileText as u, ImageOff as d, Images as f, Loader2 as p, Paperclip as m, Type as h } from "lucide-react";
|
|
6
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
7
|
+
import { Button as y } from "@burdenoff/fe-libs/ui";
|
|
8
|
+
//#region src/integrations/components/MailMessageBody.tsx
|
|
9
|
+
var b = 10, x = 2 * 1024 * 1024, S = 80;
|
|
10
|
+
function C(e, t) {
|
|
11
|
+
let n = URL.createObjectURL(e), r = document.createElement("a");
|
|
12
|
+
r.href = n, r.download = t || "attachment", r.rel = "noopener", document.body.appendChild(r), r.click(), r.remove(), window.setTimeout(() => URL.revokeObjectURL(n), 3e4);
|
|
13
|
+
}
|
|
14
|
+
function w(e) {
|
|
15
|
+
let { html: t, allowRemoteImages: n, title: r } = e, a = s(null), [l, u] = c(S);
|
|
16
|
+
return /* @__PURE__ */ _("iframe", {
|
|
17
|
+
ref: a,
|
|
18
|
+
title: r,
|
|
19
|
+
srcDoc: o(() => i(t, n), [t, n]),
|
|
20
|
+
sandbox: "allow-same-origin allow-popups allow-popups-to-escape-sandbox",
|
|
21
|
+
referrerPolicy: "no-referrer",
|
|
22
|
+
onLoad: () => {
|
|
23
|
+
let e = (a.current?.contentDocument)?.documentElement?.scrollHeight ?? 0;
|
|
24
|
+
e > 0 && u(Math.max(S, e));
|
|
25
|
+
},
|
|
26
|
+
style: { height: l },
|
|
27
|
+
className: "w-full rounded-lg border border-border-subtle bg-bg-surface",
|
|
28
|
+
"data-testid": "mailbox-html-frame"
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function T(t) {
|
|
32
|
+
let { attachment: n, onDownload: i } = t, a = e(), [o, s] = c(!1), [d, f] = c(null), m = n.filename || a("integrations.mailbox.attachment.unnamed", "Attachment");
|
|
33
|
+
return /* @__PURE__ */ v("li", {
|
|
34
|
+
className: "flex flex-wrap items-center gap-2 rounded-lg border border-border-subtle px-3 py-2",
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ _(u, {
|
|
37
|
+
size: 16,
|
|
38
|
+
className: "shrink-0 text-text-secondary"
|
|
39
|
+
}),
|
|
40
|
+
/* @__PURE__ */ _("span", {
|
|
41
|
+
className: "min-w-0 flex-1 truncate text-sm text-text-primary",
|
|
42
|
+
title: m,
|
|
43
|
+
children: m
|
|
44
|
+
}),
|
|
45
|
+
/* @__PURE__ */ _("span", {
|
|
46
|
+
className: "text-xs text-text-tertiary",
|
|
47
|
+
children: r(n.size)
|
|
48
|
+
}),
|
|
49
|
+
/* @__PURE__ */ v(y, {
|
|
50
|
+
type: "button",
|
|
51
|
+
variant: "ghost",
|
|
52
|
+
size: "sm",
|
|
53
|
+
disabled: o,
|
|
54
|
+
"aria-label": a("integrations.mailbox.attachment.download", "Download {{name}}", { name: m }),
|
|
55
|
+
onClick: async () => {
|
|
56
|
+
s(!0), f(null);
|
|
57
|
+
try {
|
|
58
|
+
await i(n);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
f(e instanceof Error ? e.message : a("integrations.mailbox.attachment.failed", "Download failed"));
|
|
61
|
+
} finally {
|
|
62
|
+
s(!1);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
children: [o ? /* @__PURE__ */ _(p, {
|
|
66
|
+
size: 14,
|
|
67
|
+
className: "animate-spin"
|
|
68
|
+
}) : /* @__PURE__ */ _(l, { size: 14 }), a("integrations.mailbox.attachment.downloadShort", "Download")]
|
|
69
|
+
}),
|
|
70
|
+
d && /* @__PURE__ */ _("p", {
|
|
71
|
+
role: "alert",
|
|
72
|
+
className: "w-full text-xs text-status-error-text",
|
|
73
|
+
children: d
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function E(r) {
|
|
79
|
+
let { connectionId: i, message: s } = r, l = e(), u = t(), [p, S] = c(!1), [E, D] = c(!1), [O, k] = c(/* @__PURE__ */ new Map()), [A, j] = c(!1), M = o(() => s.bodyHtml ? a(s.bodyHtml, {
|
|
80
|
+
allowRemoteImages: E,
|
|
81
|
+
inlineImages: O
|
|
82
|
+
}) : null, [
|
|
83
|
+
s.bodyHtml,
|
|
84
|
+
E,
|
|
85
|
+
O
|
|
86
|
+
]), N = o(() => {
|
|
87
|
+
let e = new Set(M?.unresolvedInlineImages ?? []);
|
|
88
|
+
return s.attachments.filter((t) => t.contentId && t.mimeType.startsWith("image/") && t.size <= x && e.has(t.contentId));
|
|
89
|
+
}, [s.attachments, M]), P = (M?.remoteImageCount ?? 0) + (M?.unresolvedInlineImages.length ?? 0), F = s.attachments.filter((e) => !(e.isInline && e.mimeType.startsWith("image/") && s.bodyHtml)), I = async () => {
|
|
90
|
+
if (D(!0), N.length !== 0) {
|
|
91
|
+
j(!0);
|
|
92
|
+
try {
|
|
93
|
+
let e = new Map(O), t = await Promise.allSettled(N.slice(0, b).map(async (e) => ({
|
|
94
|
+
contentId: e.contentId,
|
|
95
|
+
content: await u(i, s.id, e.id)
|
|
96
|
+
})));
|
|
97
|
+
for (let n of t) {
|
|
98
|
+
if (n.status !== "fulfilled" || !n.value.contentId) continue;
|
|
99
|
+
let { contentId: t, content: r } = n.value;
|
|
100
|
+
e.set(t, `data:${r.mimeType};base64,${r.contentBase64}`);
|
|
101
|
+
}
|
|
102
|
+
k(e);
|
|
103
|
+
} finally {
|
|
104
|
+
j(!1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}, L = async (e) => {
|
|
108
|
+
let t = await u(i, s.id, e.id);
|
|
109
|
+
C(n(t.contentBase64, t.mimeType), t.filename);
|
|
110
|
+
};
|
|
111
|
+
return /* @__PURE__ */ v("div", {
|
|
112
|
+
className: "space-y-3",
|
|
113
|
+
children: [
|
|
114
|
+
M && !p ? /* @__PURE__ */ v(g, { children: [
|
|
115
|
+
P > 0 && !E && /* @__PURE__ */ v("div", {
|
|
116
|
+
className: "flex flex-wrap items-center justify-between gap-2 rounded-lg bg-accent px-3 py-2 text-xs text-text-secondary",
|
|
117
|
+
children: [/* @__PURE__ */ v("span", {
|
|
118
|
+
className: "flex items-center gap-2",
|
|
119
|
+
children: [/* @__PURE__ */ _(d, { size: 14 }), l("integrations.mailbox.body.imagesBlocked", "Images are hidden to protect your privacy.")]
|
|
120
|
+
}), /* @__PURE__ */ v(y, {
|
|
121
|
+
type: "button",
|
|
122
|
+
variant: "outline",
|
|
123
|
+
size: "sm",
|
|
124
|
+
onClick: () => void I(),
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ _(f, { size: 14 }),
|
|
127
|
+
" ",
|
|
128
|
+
l("integrations.mailbox.body.showImages", "Show images")
|
|
129
|
+
]
|
|
130
|
+
})]
|
|
131
|
+
}),
|
|
132
|
+
A && /* @__PURE__ */ _("p", {
|
|
133
|
+
role: "status",
|
|
134
|
+
className: "text-xs text-text-secondary",
|
|
135
|
+
children: l("integrations.mailbox.body.loadingImages", "Loading images…")
|
|
136
|
+
}),
|
|
137
|
+
/* @__PURE__ */ _(w, {
|
|
138
|
+
html: M.html,
|
|
139
|
+
allowRemoteImages: E,
|
|
140
|
+
title: s.subject || l("integrations.mailbox.noSubject", "(no subject)")
|
|
141
|
+
})
|
|
142
|
+
] }) : /* @__PURE__ */ _("div", {
|
|
143
|
+
className: "whitespace-pre-wrap break-words text-sm text-text-primary",
|
|
144
|
+
"data-testid": "mailbox-plain-body",
|
|
145
|
+
children: s.bodyText
|
|
146
|
+
}),
|
|
147
|
+
M && /* @__PURE__ */ v(y, {
|
|
148
|
+
type: "button",
|
|
149
|
+
variant: "ghost",
|
|
150
|
+
size: "sm",
|
|
151
|
+
"aria-pressed": p,
|
|
152
|
+
onClick: () => S((e) => !e),
|
|
153
|
+
children: [/* @__PURE__ */ _(h, { size: 14 }), p ? l("integrations.mailbox.body.showFormatted", "Show formatted") : l("integrations.mailbox.body.showPlain", "Show plain text")]
|
|
154
|
+
}),
|
|
155
|
+
F.length > 0 && /* @__PURE__ */ v("section", {
|
|
156
|
+
"aria-label": l("integrations.mailbox.attachments", "Attachments"),
|
|
157
|
+
children: [/* @__PURE__ */ v("p", {
|
|
158
|
+
className: "mb-2 flex items-center gap-1 text-xs font-medium text-text-secondary",
|
|
159
|
+
children: [/* @__PURE__ */ _(m, { size: 12 }), l("integrations.mailbox.attachment.count", "{{count}} attachments", { count: F.length })]
|
|
160
|
+
}), /* @__PURE__ */ _("ul", {
|
|
161
|
+
className: "space-y-2",
|
|
162
|
+
"data-testid": "mailbox-attachments",
|
|
163
|
+
children: F.map((e) => /* @__PURE__ */ _(T, {
|
|
164
|
+
attachment: e,
|
|
165
|
+
onDownload: L
|
|
166
|
+
}, e.id))
|
|
167
|
+
})]
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
export { E as MailMessageBody };
|
|
174
|
+
|
|
175
|
+
//# sourceMappingURL=MailMessageBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MailMessageBody.js","names":[],"sources":["../../../src/integrations/components/MailMessageBody.tsx"],"sourcesContent":["/**\n * A received message's body and attachments (BOFF-10808).\n *\n * HTML mail is sanitised and shown in a sandboxed frame (see utils/mailHtml)\n * with remote images blocked until the reader asks for them; plain text stays\n * one click away and is the fallback whenever there is no HTML body.\n * Attachments download through the service, so no provider URL or token ever\n * reaches the browser.\n */\nimport { useMemo, useRef, useState } from 'react';\nimport { Download, FileText, ImageOff, Images, Loader2, Paperclip, Type } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\n\nimport { useTr } from '../hooks/useTr';\nimport { useMailboxAttachmentContent } from '../hooks/useMailbox';\nimport type { MailboxAttachment, MailboxThreadMessage } from '../hooks/useMailbox';\nimport { base64ToBlob, formatBytes, mailFrameDocument, sanitizeMailHtml } from '../utils/mailHtml';\n\n/** At most this many inline (cid:) images are fetched when images are shown. */\nconst MAX_INLINE_IMAGES = 10;\n/** Inline images larger than this stay hidden rather than being inlined as data URLs. */\nconst MAX_INLINE_IMAGE_BYTES = 2 * 1024 * 1024;\nconst MIN_FRAME_HEIGHT = 80;\n\nfunction saveBlob(blob: Blob, filename: string): void {\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = filename || 'attachment';\n link.rel = 'noopener';\n document.body.appendChild(link);\n link.click();\n link.remove();\n // Give the browser time to start the download before the URL goes away.\n window.setTimeout(() => URL.revokeObjectURL(url), 30_000);\n}\n\n/** The sandboxed frame showing sanitised HTML. */\nfunction MailHtmlFrame(props: { html: string; allowRemoteImages: boolean; title: string }) {\n const { html, allowRemoteImages, title } = props;\n const frameRef = useRef<HTMLIFrameElement | null>(null);\n const [height, setHeight] = useState(MIN_FRAME_HEIGHT);\n const srcDoc = useMemo(\n () => mailFrameDocument(html, allowRemoteImages),\n [html, allowRemoteImages]\n );\n\n const measure = () => {\n // allow-same-origin (without allow-scripts) lets the parent read the\n // frame's height; nothing inside the frame can run.\n const doc = frameRef.current?.contentDocument;\n const next = doc?.documentElement?.scrollHeight ?? 0;\n if (next > 0) setHeight(Math.max(MIN_FRAME_HEIGHT, next));\n };\n\n return (\n <iframe\n ref={frameRef}\n title={title}\n srcDoc={srcDoc}\n sandbox=\"allow-same-origin allow-popups allow-popups-to-escape-sandbox\"\n referrerPolicy=\"no-referrer\"\n onLoad={measure}\n style={{ height }}\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface\"\n data-testid=\"mailbox-html-frame\"\n />\n );\n}\n\nfunction AttachmentRow(props: {\n attachment: MailboxAttachment;\n onDownload: (attachment: MailboxAttachment) => Promise<void>;\n}) {\n const { attachment, onDownload } = props;\n const tr = useTr();\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const name = attachment.filename || tr('integrations.mailbox.attachment.unnamed', 'Attachment');\n return (\n <li className=\"flex flex-wrap items-center gap-2 rounded-lg border border-border-subtle px-3 py-2\">\n <FileText size={16} className=\"shrink-0 text-text-secondary\" />\n <span className=\"min-w-0 flex-1 truncate text-sm text-text-primary\" title={name}>\n {name}\n </span>\n <span className=\"text-xs text-text-tertiary\">{formatBytes(attachment.size)}</span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n disabled={busy}\n aria-label={tr('integrations.mailbox.attachment.download', 'Download {{name}}', { name })}\n onClick={async () => {\n setBusy(true);\n setError(null);\n try {\n await onDownload(attachment);\n } catch (err) {\n setError(\n err instanceof Error\n ? err.message\n : tr('integrations.mailbox.attachment.failed', 'Download failed')\n );\n } finally {\n setBusy(false);\n }\n }}\n >\n {busy ? <Loader2 size={14} className=\"animate-spin\" /> : <Download size={14} />}\n {tr('integrations.mailbox.attachment.downloadShort', 'Download')}\n </Button>\n {error && (\n <p role=\"alert\" className=\"w-full text-xs text-status-error-text\">\n {error}\n </p>\n )}\n </li>\n );\n}\n\nexport function MailMessageBody(props: { connectionId: string; message: MailboxThreadMessage }) {\n const { connectionId, message } = props;\n const tr = useTr();\n const loadAttachment = useMailboxAttachmentContent();\n const [showPlain, setShowPlain] = useState(false);\n const [allowImages, setAllowImages] = useState(false);\n const [inlineImages, setInlineImages] = useState<ReadonlyMap<string, string>>(new Map());\n const [loadingImages, setLoadingImages] = useState(false);\n\n const sanitized = useMemo(\n () =>\n message.bodyHtml\n ? sanitizeMailHtml(message.bodyHtml, { allowRemoteImages: allowImages, inlineImages })\n : null,\n [message.bodyHtml, allowImages, inlineImages]\n );\n\n const inlineCandidates = useMemo(() => {\n const unresolved = new Set(sanitized?.unresolvedInlineImages ?? []);\n return message.attachments.filter(\n (a) =>\n a.contentId &&\n a.mimeType.startsWith('image/') &&\n a.size <= MAX_INLINE_IMAGE_BYTES &&\n unresolved.has(a.contentId)\n );\n }, [message.attachments, sanitized]);\n const blockedCount =\n (sanitized?.remoteImageCount ?? 0) + (sanitized?.unresolvedInlineImages.length ?? 0);\n\n // Inline images that are part of the HTML are not listed again as files.\n const files = message.attachments.filter(\n (a) => !(a.isInline && a.mimeType.startsWith('image/') && message.bodyHtml)\n );\n\n const showImages = async () => {\n setAllowImages(true);\n if (inlineCandidates.length === 0) return;\n setLoadingImages(true);\n try {\n const next = new Map(inlineImages);\n // At most MAX_INLINE_IMAGES requests, so they can run together.\n const loaded = await Promise.allSettled(\n inlineCandidates.slice(0, MAX_INLINE_IMAGES).map(async (attachment) => ({\n contentId: attachment.contentId,\n content: await loadAttachment(connectionId, message.id, attachment.id),\n }))\n );\n for (const result of loaded) {\n // An image that cannot be fetched stays hidden; the message still reads.\n if (result.status !== 'fulfilled' || !result.value.contentId) continue;\n const { contentId, content } = result.value;\n next.set(contentId, `data:${content.mimeType};base64,${content.contentBase64}`);\n }\n setInlineImages(next);\n } finally {\n setLoadingImages(false);\n }\n };\n\n const download = async (attachment: MailboxAttachment) => {\n const content = await loadAttachment(connectionId, message.id, attachment.id);\n saveBlob(base64ToBlob(content.contentBase64, content.mimeType), content.filename);\n };\n\n return (\n <div className=\"space-y-3\">\n {sanitized && !showPlain ? (\n <>\n {blockedCount > 0 && !allowImages && (\n <div className=\"flex flex-wrap items-center justify-between gap-2 rounded-lg bg-accent px-3 py-2 text-xs text-text-secondary\">\n <span className=\"flex items-center gap-2\">\n <ImageOff size={14} />\n {tr(\n 'integrations.mailbox.body.imagesBlocked',\n 'Images are hidden to protect your privacy.'\n )}\n </span>\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => void showImages()}>\n <Images size={14} /> {tr('integrations.mailbox.body.showImages', 'Show images')}\n </Button>\n </div>\n )}\n {loadingImages && (\n <p role=\"status\" className=\"text-xs text-text-secondary\">\n {tr('integrations.mailbox.body.loadingImages', 'Loading images…')}\n </p>\n )}\n <MailHtmlFrame\n html={sanitized.html}\n allowRemoteImages={allowImages}\n title={message.subject || tr('integrations.mailbox.noSubject', '(no subject)')}\n />\n </>\n ) : (\n <div\n className=\"whitespace-pre-wrap break-words text-sm text-text-primary\"\n data-testid=\"mailbox-plain-body\"\n >\n {message.bodyText}\n </div>\n )}\n {sanitized && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-pressed={showPlain}\n onClick={() => setShowPlain((value) => !value)}\n >\n <Type size={14} />\n {showPlain\n ? tr('integrations.mailbox.body.showFormatted', 'Show formatted')\n : tr('integrations.mailbox.body.showPlain', 'Show plain text')}\n </Button>\n )}\n {files.length > 0 && (\n <section aria-label={tr('integrations.mailbox.attachments', 'Attachments')}>\n <p className=\"mb-2 flex items-center gap-1 text-xs font-medium text-text-secondary\">\n <Paperclip size={12} />\n {tr('integrations.mailbox.attachment.count', '{{count}} attachments', {\n count: files.length,\n })}\n </p>\n <ul className=\"space-y-2\" data-testid=\"mailbox-attachments\">\n {files.map((attachment) => (\n <AttachmentRow key={attachment.id} attachment={attachment} onDownload={download} />\n ))}\n </ul>\n </section>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAmBA,IAAM,IAAoB,IAEpB,IAAyB,IAAI,OAAO,MACpC,IAAmB;AAEzB,SAAS,EAAS,GAAY,GAAwB;CACpD,IAAM,IAAM,IAAI,gBAAgB,EAAK,EAC/B,IAAO,SAAS,cAAc,IAAI;AAQxC,CAPA,EAAK,OAAO,GACZ,EAAK,WAAW,KAAY,cAC5B,EAAK,M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U;IACV,eAAY;cAEX,EAAQ;IACL,CAAA;GAEP,KACC,kBAAC,GAAD;IACE,MAAK;IACL,SAAQ;IACR,MAAK;IACL,gBAAc;IACd,eAAe,GAAc,MAAU,CAAC,EAAM;cALhD,CAOE,kBAAC,GAAD,EAAM,MAAM,IAAM,CAAA,EACjB,IACG,EAAG,2CAA2C,iBAAiB,GAC/D,EAAG,uCAAuC,kBAAkB,CACzD;;GAEV,EAAM,SAAS,KACd,kBAAC,WAAD;IAAS,cAAY,EAAG,oCAAoC,cAAc;cAA1E,CACE,kBAAC,KAAD;KAAG,WAAU;eAAb,CACE,kBAAC,GAAD,EAAW,MAAM,IAAM,CAAA,EACtB,EAAG,yCAAyC,yBAAyB,EACpE,OAAO,EAAM,QACd,CAAC,CACA;QACJ,kBAAC,MAAD;KAAI,WAAU;KAAY,eAAY;eACnC,EAAM,KAAK,MACV,kBAAC,GAAD;MAA+C;MAAY,YAAY;MAAY,EAA/D,EAAW,GAAoD,CACnF;KACC,CAAA,CACG;;GAER"}
|
|
@@ -1,19 +1,30 @@
|
|
|
1
|
-
import { MailboxFolder } from '../../generated/wspace-types';
|
|
2
|
-
import { MailboxAccountsQuery, MailboxMessagesQuery, MailboxThreadQuery, SendMailboxMessageMutation } from '../../generated/wspace-operations';
|
|
1
|
+
import { MailboxFolder, MailboxKind, MailboxLabelKind } from '../../generated/wspace-types';
|
|
2
|
+
import { MailboxAccountsQuery, MailboxAttachmentQuery, MailboxLabelsQuery, MailboxMessagesQuery, MailboxThreadQuery, SendMailboxMessageMutation } from '../../generated/wspace-operations';
|
|
3
3
|
|
|
4
|
-
export { MailboxFolder };
|
|
4
|
+
export { MailboxFolder, MailboxKind, MailboxLabelKind };
|
|
5
|
+
/** Files on one outgoing message; matches the service limit. */
|
|
6
|
+
export declare const MAILBOX_MAX_ATTACHMENTS = 10;
|
|
7
|
+
/**
|
|
8
|
+
* Total attachment bytes per outgoing message, matching the service caps:
|
|
9
|
+
* Gmail takes a 25 MB message, Microsoft Graph 4 MB per request.
|
|
10
|
+
*/
|
|
11
|
+
export declare const MAILBOX_SEND_ATTACHMENT_BYTES: Readonly<Record<MailboxKind, number>>;
|
|
5
12
|
export declare const MAILBOX_PAGE_SIZE = 25;
|
|
6
13
|
export type MailboxAccount = MailboxAccountsQuery['mailboxAccounts'][number];
|
|
7
14
|
export type MailboxMessageSummary = MailboxMessagesQuery['mailboxMessages']['messages'][number];
|
|
8
15
|
export type MailboxThread = NonNullable<MailboxThreadQuery['mailboxThread']>;
|
|
9
16
|
export type MailboxSendResult = SendMailboxMessageMutation['sendMailboxMessage'];
|
|
17
|
+
export type MailboxLabel = MailboxLabelsQuery['mailboxLabels'][number];
|
|
18
|
+
export type MailboxThreadMessage = MailboxThread['messages'][number];
|
|
19
|
+
export type MailboxAttachment = MailboxThreadMessage['attachments'][number];
|
|
20
|
+
export type MailboxAttachmentContent = MailboxAttachmentQuery['mailboxAttachment'];
|
|
10
21
|
export declare function useMailboxAccounts(): {
|
|
11
22
|
accounts: {
|
|
12
23
|
__typename?: "MailboxAccount";
|
|
13
24
|
connectionId: string;
|
|
14
25
|
name: string;
|
|
15
26
|
providerKey: string;
|
|
16
|
-
kind:
|
|
27
|
+
kind: MailboxKind;
|
|
17
28
|
emailAddress?: string | null;
|
|
18
29
|
status: import('../../generated/wspace-types').ConnectionStatus;
|
|
19
30
|
}[];
|
|
@@ -28,6 +39,8 @@ export declare function useMailboxAccounts(): {
|
|
|
28
39
|
export declare function useMailboxMessages(options: {
|
|
29
40
|
connectionId: string | null;
|
|
30
41
|
folder: MailboxFolder;
|
|
42
|
+
/** A label or folder from useMailboxLabels; replaces `folder` when set. */
|
|
43
|
+
folderId: string | null;
|
|
31
44
|
query: string;
|
|
32
45
|
pageToken: string | null;
|
|
33
46
|
}): {
|
|
@@ -73,6 +86,16 @@ export declare function useMailboxThread(connectionId: string | null, threadId:
|
|
|
73
86
|
isUnread: boolean;
|
|
74
87
|
hasAttachments: boolean;
|
|
75
88
|
bodyText: string;
|
|
89
|
+
bodyHtml?: string | null;
|
|
90
|
+
attachments: Array<{
|
|
91
|
+
__typename?: "MailboxAttachment";
|
|
92
|
+
id: string;
|
|
93
|
+
filename: string;
|
|
94
|
+
mimeType: string;
|
|
95
|
+
size: number;
|
|
96
|
+
isInline: boolean;
|
|
97
|
+
contentId?: string | null;
|
|
98
|
+
}>;
|
|
76
99
|
from?: {
|
|
77
100
|
__typename?: "MailboxAddress";
|
|
78
101
|
name?: string | null;
|
|
@@ -97,6 +120,43 @@ export declare function useMailboxThread(connectionId: string | null, threadId:
|
|
|
97
120
|
error?: import('@apollo/client').ErrorLike;
|
|
98
121
|
}>;
|
|
99
122
|
};
|
|
123
|
+
export declare function useMailboxLabels(connectionId: string | null): {
|
|
124
|
+
labels: {
|
|
125
|
+
__typename?: "MailboxLabel";
|
|
126
|
+
id: string;
|
|
127
|
+
name: string;
|
|
128
|
+
kind: MailboxLabelKind;
|
|
129
|
+
unreadCount?: number | null;
|
|
130
|
+
totalCount?: number | null;
|
|
131
|
+
}[];
|
|
132
|
+
loading: boolean;
|
|
133
|
+
error: import('@apollo/client').ErrorLike | undefined;
|
|
134
|
+
};
|
|
135
|
+
/** Fetches one received attachment's bytes. Never cached: files can be large. */
|
|
136
|
+
export declare function useMailboxAttachmentContent(): (connectionId: string, messageId: string, attachmentId: string) => Promise<{
|
|
137
|
+
__typename?: "MailboxAttachmentContent";
|
|
138
|
+
filename: string;
|
|
139
|
+
mimeType: string;
|
|
140
|
+
size: number;
|
|
141
|
+
contentBase64: string;
|
|
142
|
+
}>;
|
|
143
|
+
export declare function useMailboxThreadActions(): {
|
|
144
|
+
archiveThread: (connectionId: string, threadId: string) => Promise<void>;
|
|
145
|
+
trashThread: (connectionId: string, threadId: string) => Promise<void>;
|
|
146
|
+
busy: boolean;
|
|
147
|
+
};
|
|
148
|
+
/** A file uploaded to Files for an outgoing message. */
|
|
149
|
+
export interface PendingMailAttachment {
|
|
150
|
+
fileId: string;
|
|
151
|
+
name: string;
|
|
152
|
+
size: number;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Uploads a file to wspace-files-svc (initiateUpload, PUT to the presigned
|
|
156
|
+
* URL, completeUpload) so sendMailboxMessage can attach it by id. The service
|
|
157
|
+
* reads it back as the caller; the bytes never pass through the gateway.
|
|
158
|
+
*/
|
|
159
|
+
export declare function useUploadMailAttachment(): (file: File) => Promise<PendingMailAttachment>;
|
|
100
160
|
export interface SendMailInput {
|
|
101
161
|
connectionId: string;
|
|
102
162
|
to: string[];
|
|
@@ -104,6 +164,7 @@ export interface SendMailInput {
|
|
|
104
164
|
subject?: string;
|
|
105
165
|
bodyText: string;
|
|
106
166
|
replyToMessageId?: string;
|
|
167
|
+
attachmentFileIds?: string[];
|
|
107
168
|
}
|
|
108
169
|
export declare function useSendMail(): {
|
|
109
170
|
send: (input: SendMailInput) => Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMailbox.d.ts","sourceRoot":"","sources":["../../../src/integrations/hooks/useMailbox.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"useMailbox.d.ts","sourceRoot":"","sources":["../../../src/integrations/hooks/useMailbox.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAC5F,OAAO,KAAK,EACV,oBAAoB,EAGpB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,mCAAmC,CAAC;AAgB3C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;AAExD,gEAAgE;AAChE,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAG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-
import {
|
|
3
|
-
import "../../generated/wspace-types.js";
|
|
4
|
-
import { useCallback as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { useArchiveMailboxThreadMutation as t, useMailboxAccountsQuery as n, useMailboxAttachmentCompleteUploadMutation as r, useMailboxAttachmentInitiateUploadMutation as i, useMailboxAttachmentLazyQuery as a, useMailboxLabelsQuery as o, useMailboxMessagesQuery as s, useMailboxThreadQuery as c, useSendMailboxMessageMutation as l, useSetMailboxMessageReadMutation as u, useTrashMailboxThreadMutation as d } from "../../generated/wspace-operations.js";
|
|
3
|
+
import { MailboxKind as f } from "../../generated/wspace-types.js";
|
|
4
|
+
import { useCallback as p } from "react";
|
|
5
|
+
//#region src/integrations/hooks/useMailbox.ts
|
|
6
|
+
var m = {
|
|
7
|
+
[f.Gmail]: 17 * 1024 * 1024,
|
|
8
|
+
[f.Outlook]: 2621440
|
|
9
|
+
};
|
|
10
|
+
function h() {
|
|
11
|
+
let { workspaceId: t } = e(), { data: r, loading: i, error: a, refetch: o } = n({
|
|
12
|
+
skip: !t,
|
|
8
13
|
errorPolicy: "all",
|
|
9
14
|
fetchPolicy: "cache-and-network"
|
|
10
15
|
}), s = r;
|
|
@@ -16,11 +21,12 @@ function s() {
|
|
|
16
21
|
refetch: o
|
|
17
22
|
};
|
|
18
23
|
}
|
|
19
|
-
function
|
|
20
|
-
let { connectionId: t, folder: r, query: i, pageToken: a } = e, { data: o, loading:
|
|
24
|
+
function g(e) {
|
|
25
|
+
let { connectionId: t, folder: n, folderId: r, query: i, pageToken: a } = e, { data: o, loading: c, error: l, refetch: u } = s({
|
|
21
26
|
variables: { input: {
|
|
22
27
|
connectionId: t ?? "",
|
|
23
|
-
folder:
|
|
28
|
+
folder: n,
|
|
29
|
+
folderId: r,
|
|
24
30
|
query: i || null,
|
|
25
31
|
pageToken: a,
|
|
26
32
|
limit: 25
|
|
@@ -28,17 +34,17 @@ function c(e) {
|
|
|
28
34
|
skip: !t,
|
|
29
35
|
errorPolicy: "none",
|
|
30
36
|
fetchPolicy: "network-only"
|
|
31
|
-
}),
|
|
37
|
+
}), d = o;
|
|
32
38
|
return {
|
|
33
|
-
messages:
|
|
34
|
-
nextPageToken:
|
|
35
|
-
loading:
|
|
36
|
-
error:
|
|
37
|
-
refetch:
|
|
39
|
+
messages: d?.mailboxMessages.messages ?? [],
|
|
40
|
+
nextPageToken: d?.mailboxMessages.nextPageToken ?? null,
|
|
41
|
+
loading: c,
|
|
42
|
+
error: l,
|
|
43
|
+
refetch: u
|
|
38
44
|
};
|
|
39
45
|
}
|
|
40
|
-
function
|
|
41
|
-
let { data: n, loading:
|
|
46
|
+
function _(e, t) {
|
|
47
|
+
let { data: n, loading: r, error: i, refetch: a } = c({
|
|
42
48
|
variables: {
|
|
43
49
|
connectionId: e ?? "",
|
|
44
50
|
threadId: t ?? ""
|
|
@@ -49,28 +55,101 @@ function l(e, t) {
|
|
|
49
55
|
});
|
|
50
56
|
return {
|
|
51
57
|
thread: n?.mailboxThread ?? null,
|
|
52
|
-
loading:
|
|
53
|
-
error:
|
|
54
|
-
refetch:
|
|
58
|
+
loading: r,
|
|
59
|
+
error: i,
|
|
60
|
+
refetch: a
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function v(e) {
|
|
64
|
+
let { data: t, loading: n, error: r } = o({
|
|
65
|
+
variables: { connectionId: e ?? "" },
|
|
66
|
+
skip: !e,
|
|
67
|
+
errorPolicy: "none",
|
|
68
|
+
fetchPolicy: "cache-and-network"
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
labels: t?.mailboxLabels ?? [],
|
|
72
|
+
loading: n,
|
|
73
|
+
error: r
|
|
55
74
|
};
|
|
56
75
|
}
|
|
57
|
-
function
|
|
58
|
-
let [e
|
|
76
|
+
function y() {
|
|
77
|
+
let [e] = a({ fetchPolicy: "no-cache" });
|
|
78
|
+
return p(async (t, n, r) => {
|
|
79
|
+
let i = await e({ variables: {
|
|
80
|
+
connectionId: t,
|
|
81
|
+
messageId: n,
|
|
82
|
+
attachmentId: r
|
|
83
|
+
} });
|
|
84
|
+
if (i.error) throw i.error;
|
|
85
|
+
let a = i.data?.mailboxAttachment ?? null;
|
|
86
|
+
if (!a) throw Error("Attachment not found");
|
|
87
|
+
return a;
|
|
88
|
+
}, [e]);
|
|
89
|
+
}
|
|
90
|
+
function b() {
|
|
91
|
+
let [e, n] = t(), [r, i] = d();
|
|
92
|
+
return {
|
|
93
|
+
archiveThread: p(async (t, n) => {
|
|
94
|
+
await e({ variables: {
|
|
95
|
+
connectionId: t,
|
|
96
|
+
threadId: n
|
|
97
|
+
} });
|
|
98
|
+
}, [e]),
|
|
99
|
+
trashThread: p(async (e, t) => {
|
|
100
|
+
await r({ variables: {
|
|
101
|
+
connectionId: e,
|
|
102
|
+
threadId: t
|
|
103
|
+
} });
|
|
104
|
+
}, [r]),
|
|
105
|
+
busy: n.loading || i.loading
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function x() {
|
|
109
|
+
let [e] = i(), [t] = r();
|
|
110
|
+
return p(async (n) => {
|
|
111
|
+
let r = n.type || "application/octet-stream", i = n.name.lastIndexOf("."), a = i > 0 ? n.name.slice(i + 1).toLowerCase() : "bin", o = String(n.size), s = (await e({ variables: { input: {
|
|
112
|
+
fileName: n.name,
|
|
113
|
+
fileSize: o,
|
|
114
|
+
mimeType: r,
|
|
115
|
+
extension: a
|
|
116
|
+
} } })).data?.initiateUpload;
|
|
117
|
+
if (!s?.uploadUrl || !s.session.id) throw Error(`Could not start uploading ${n.name}`);
|
|
118
|
+
if (!(await fetch(s.uploadUrl, {
|
|
119
|
+
method: "PUT",
|
|
120
|
+
body: n,
|
|
121
|
+
headers: { "Content-Type": r }
|
|
122
|
+
})).ok) throw Error(`Uploading ${n.name} failed`);
|
|
123
|
+
let c = (await t({ variables: { input: {
|
|
124
|
+
sessionId: s.session.id,
|
|
125
|
+
fileSize: o
|
|
126
|
+
} } })).data?.completeUpload.fileId;
|
|
127
|
+
if (!c) throw Error(`Could not finish uploading ${n.name}`);
|
|
128
|
+
return {
|
|
129
|
+
fileId: c,
|
|
130
|
+
name: n.name,
|
|
131
|
+
size: n.size
|
|
132
|
+
};
|
|
133
|
+
}, [e, t]);
|
|
134
|
+
}
|
|
135
|
+
function S() {
|
|
136
|
+
let [e, { loading: t }] = l();
|
|
59
137
|
return {
|
|
60
|
-
send:
|
|
138
|
+
send: p(async (t) => (await e({ variables: { input: {
|
|
61
139
|
connectionId: t.connectionId,
|
|
62
140
|
to: t.to,
|
|
63
141
|
cc: t.cc ?? null,
|
|
64
142
|
subject: t.subject ?? null,
|
|
65
143
|
bodyText: t.bodyText,
|
|
66
|
-
replyToMessageId: t.replyToMessageId ?? null
|
|
144
|
+
replyToMessageId: t.replyToMessageId ?? null,
|
|
145
|
+
attachmentFileIds: t.attachmentFileIds?.length ? t.attachmentFileIds : null
|
|
67
146
|
} } })).data?.sendMailboxMessage ?? null, [e]),
|
|
68
147
|
sending: t
|
|
69
148
|
};
|
|
70
149
|
}
|
|
71
|
-
function
|
|
72
|
-
let [e] =
|
|
73
|
-
return
|
|
150
|
+
function C() {
|
|
151
|
+
let [e] = u();
|
|
152
|
+
return p(async (t, n, r) => {
|
|
74
153
|
await e({ variables: {
|
|
75
154
|
connectionId: t,
|
|
76
155
|
messageId: n,
|
|
@@ -78,10 +157,10 @@ function d() {
|
|
|
78
157
|
} });
|
|
79
158
|
}, [e]);
|
|
80
159
|
}
|
|
81
|
-
function
|
|
160
|
+
function w(e) {
|
|
82
161
|
return e.split(/[,;\r\n]+/).map((e) => e.trim()).filter(Boolean);
|
|
83
162
|
}
|
|
84
163
|
//#endregion
|
|
85
|
-
export {
|
|
164
|
+
export { m as MAILBOX_SEND_ATTACHMENT_BYTES, w as splitRecipients, h as useMailboxAccounts, y as useMailboxAttachmentContent, v as useMailboxLabels, g as useMailboxMessages, _ as useMailboxThread, b as useMailboxThreadActions, S as useSendMail, C as useSetMailRead, x as useUploadMailAttachment };
|
|
86
165
|
|
|
87
166
|
//# sourceMappingURL=useMailbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMailbox.js","names":[],"sources":["../../../src/integrations/hooks/useMailbox.ts"],"sourcesContent":["/**\n * Connected mailbox hooks (BOFF-4422): the caller's own Gmail / Outlook\n * connections, a page of messages, one conversation, and send / mark read.\n */\nimport { useCallback } from 'react';\n\nimport { MailboxFolder } from '../../generated/wspace-types';\nimport type {\n MailboxAccountsQuery,\n MailboxMessagesQuery,\n MailboxThreadQuery,\n SendMailboxMessageMutation,\n} from '../../generated/wspace-operations';\nimport {\n useMailboxAccountsQuery,\n useMailboxMessagesQuery,\n useMailboxThreadQuery,\n useSendMailboxMessageMutation,\n useSetMailboxMessageReadMutation,\n} from '../../generated/wspace-operations';\nimport { useIntegrations } from '../providers/IntegrationsProvider';\n\nexport { MailboxFolder };\n\nexport const MAILBOX_PAGE_SIZE = 25;\n\n/*\n * The generated hooks reference result types through `Types.*`, which the\n * import-types preset does not emit into wspace-types.ts, so their `data` is\n * untyped. The operation result types below are generated in\n * wspace-operations.ts and pin the shapes this module hands to the page.\n */\nexport type MailboxAccount = MailboxAccountsQuery['mailboxAccounts'][number];\nexport type MailboxMessageSummary = MailboxMessagesQuery['mailboxMessages']['messages'][number];\nexport type MailboxThread = NonNullable<MailboxThreadQuery['mailboxThread']>;\nexport type MailboxSendResult = SendMailboxMessageMutation['sendMailboxMessage'];\n\nexport function useMailboxAccounts() {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useMailboxAccountsQuery({\n skip: !workspaceId,\n errorPolicy: 'all',\n fetchPolicy: 'cache-and-network',\n });\n const typed = data as MailboxAccountsQuery | undefined;\n const accounts: MailboxAccount[] = typed?.mailboxAccounts ?? [];\n // True once the gateway has answered; a skipped query (no workspace yet)\n // must not read as \"no mailboxes connected\".\n const answered = typed?.mailboxAccounts !== undefined;\n return { accounts, answered, loading, error, refetch };\n}\n\nexport function useMailboxMessages(options: {\n connectionId: string | null;\n folder: MailboxFolder;\n query: string;\n pageToken: string | null;\n}) {\n const { connectionId, folder, query, pageToken } = options;\n const { data, loading, error, refetch } = useMailboxMessagesQuery({\n variables: {\n input: {\n connectionId: connectionId ?? '',\n folder,\n query: query || null,\n pageToken,\n limit: MAILBOX_PAGE_SIZE,\n },\n },\n skip: !connectionId,\n errorPolicy: 'none',\n fetchPolicy: 'network-only',\n });\n const typed = data as MailboxMessagesQuery | undefined;\n const messages: MailboxMessageSummary[] = typed?.mailboxMessages.messages ?? [];\n const nextPageToken: string | null = typed?.mailboxMessages.nextPageToken ?? null;\n return {\n messages,\n nextPageToken,\n loading,\n error,\n refetch,\n };\n}\n\nexport function useMailboxThread(connectionId: string | null, threadId: string | null) {\n const { data, loading, error, refetch } = useMailboxThreadQuery({\n variables: { connectionId: connectionId ?? '', threadId: threadId ?? '' },\n skip: !connectionId || !threadId,\n errorPolicy: 'none',\n fetchPolicy: 'network-only',\n });\n const thread: MailboxThread | null =\n (data as MailboxThreadQuery | undefined)?.mailboxThread ?? null;\n return { thread, loading, error, refetch };\n}\n\nexport interface SendMailInput {\n connectionId: string;\n to: string[];\n cc?: string[];\n subject?: string;\n bodyText: string;\n replyToMessageId?: string;\n}\n\nexport function useSendMail() {\n const [mutate, { loading }] = useSendMailboxMessageMutation();\n const send = useCallback(\n async (input: SendMailInput) => {\n const result = await mutate({\n variables: {\n input: {\n connectionId: input.connectionId,\n to: input.to,\n cc: input.cc ?? null,\n subject: input.subject ?? null,\n bodyText: input.bodyText,\n replyToMessageId: input.replyToMessageId ?? null,\n },\n },\n });\n const sent: MailboxSendResult | null =\n (result.data as SendMailboxMessageMutation | null | undefined)?.sendMailboxMessage ?? null;\n return sent;\n },\n [mutate]\n );\n return { send, sending: loading };\n}\n\nexport function useSetMailRead() {\n const [mutate] = useSetMailboxMessageReadMutation();\n return useCallback(\n async (connectionId: string, messageId: string, read: boolean) => {\n await mutate({ variables: { connectionId, messageId, read } });\n },\n [mutate]\n );\n}\n\n/**\n * Splits a recipient field on commas, semicolons and line breaks. Spaces are\n * not separators, so a pasted entry stays whole and the service validates it\n * as one address instead of receiving fragments of it.\n */\nexport function splitRecipients(value: string): string[] {\n return value\n .split(/[,;\\r\\n]+/)\n .map((part) => part.trim())\n .filter(Boolean);\n}\n"],"mappings":";;;;AAqCA,SAAgB,IAAqB;CACnC,IAAM,EAAE,mBAAgB,GAAiB,EACnC,EAAE,SAAM,YAAS,UAAO,eAAY,EAAwB;EAChE,MAAM,CAAC;EACP,aAAa;EACb,aAAa;EACd,CAAC,EACI,IAAQ;AAKd,QAAO;EAAE,UAJ0B,GAAO,mBAAmB,EAAE;EAI5C,UADF,GAAO,oBAAoB,KAAA;EACf;EAAS;EAAO;EAAS;;AAGxD,SAAgB,EAAmB,GAKhC;CACD,IAAM,EAAE,iBAAc,WAAQ,UAAO,iBAAc,GAC7C,EAAE,SAAM,YAAS,UAAO,eAAY,EAAwB;EAChE,WAAW,EACT,OAAO;GACL,cAAc,KAAgB;GAC9B;GACA,OAAO,KAAS;GAChB;GACA,OAAA;GACD,EACF;EACD,MAAM,CAAC;EACP,aAAa;EACb,aAAa;EACd,CAAC,EACI,IAAQ;AAGd,QAAO;EACL,UAHwC,GAAO,gBAAgB,YAAY,EAAE;EAI7E,eAHmC,GAAO,gBAAgB,iBAAiB;EAI3E;EACA;EACA;EACD;;AAGH,SAAgB,EAAiB,GAA6B,GAAyB;CACrF,IAAM,EAAE,SAAM,YAAS,UAAO,eAAY,EAAsB;EAC9D,WAAW;GAAE,cAAc,KAAgB;GAAI,UAAU,KAAY;GAAI;EACzE,MAAM,CAAC,KAAgB,CAAC;EACxB,aAAa;EACb,aAAa;EACd,CAAC;AAGF,QAAO;EAAE,QADN,GAAyC,iBAAiB;EAC5C;EAAS;EAAO;EAAS;;AAY5C,SAAgB,IAAc;CAC5B,IAAM,CAAC,GAAQ,EAAE,gBAAa,GAA+B;AAqB7D,QAAO;EAAE,MApBI,EACX,OAAO,OACU,MAAM,EAAO,EAC1B,WAAW,EACT,OAAO;GACL,cAAc,EAAM;GACpB,IAAI,EAAM;GACV,IAAI,EAAM,MAAM;GAChB,SAAS,EAAM,WAAW;GAC1B,UAAU,EAAM;GAChB,kBAAkB,EAAM,oBAAoB;GAC7C,EACF,EACF,CAAC,EAEQ,MAAwD,sBAAsB,MAG1F,CAAC,EAAO,CACT;EACc,SAAS;EAAS;;AAGnC,SAAgB,IAAiB;CAC/B,IAAM,CAAC,KAAU,GAAkC;AACnD,QAAO,EACL,OAAO,GAAsB,GAAmB,MAAkB;AAChE,QAAM,EAAO,EAAE,WAAW;GAAE;GAAc;GAAW;GAAM,EAAE,CAAC;IAEhE,CAAC,EAAO,CACT;;AAQH,SAAgB,EAAgB,GAAyB;AACvD,QAAO,EACJ,MAAM,YAAY,CAClB,KAAK,MAAS,EAAK,MAAM,CAAC,CAC1B,OAAO,QAAQ"}
|
|
1
|
+
{"version":3,"file":"useMailbox.js","names":[],"sources":["../../../src/integrations/hooks/useMailbox.ts"],"sourcesContent":["/**\n * Connected mailbox hooks (BOFF-4422): the caller's own Gmail / Outlook\n * connections, a page of messages, one conversation, and send / mark read.\n */\nimport { useCallback } from 'react';\n\nimport { MailboxFolder, MailboxKind, MailboxLabelKind } from '../../generated/wspace-types';\nimport type {\n MailboxAccountsQuery,\n MailboxAttachmentCompleteUploadMutation,\n MailboxAttachmentInitiateUploadMutation,\n MailboxAttachmentQuery,\n MailboxLabelsQuery,\n MailboxMessagesQuery,\n MailboxThreadQuery,\n SendMailboxMessageMutation,\n} from '../../generated/wspace-operations';\nimport {\n useArchiveMailboxThreadMutation,\n useMailboxAccountsQuery,\n useMailboxAttachmentCompleteUploadMutation,\n useMailboxAttachmentInitiateUploadMutation,\n useMailboxAttachmentLazyQuery,\n useMailboxLabelsQuery,\n useMailboxMessagesQuery,\n useMailboxThreadQuery,\n useSendMailboxMessageMutation,\n useSetMailboxMessageReadMutation,\n useTrashMailboxThreadMutation,\n} from '../../generated/wspace-operations';\nimport { useIntegrations } from '../providers/IntegrationsProvider';\n\nexport { MailboxFolder, MailboxKind, MailboxLabelKind };\n\n/** Files on one outgoing message; matches the service limit. */\nexport const MAILBOX_MAX_ATTACHMENTS = 10;\n\n/**\n * Total attachment bytes per outgoing message, matching the service caps:\n * Gmail takes a 25 MB message, Microsoft Graph 4 MB per request.\n */\nexport const MAILBOX_SEND_ATTACHMENT_BYTES: Readonly<Record<MailboxKind, number>> = {\n [MailboxKind.Gmail]: 17 * 1024 * 1024,\n [MailboxKind.Outlook]: Math.floor(2.5 * 1024 * 1024),\n};\n\nexport const MAILBOX_PAGE_SIZE = 25;\n\n/*\n * The generated hooks reference result types through `Types.*`, which the\n * import-types preset does not emit into wspace-types.ts, so their `data` is\n * untyped. The operation result types below are generated in\n * wspace-operations.ts and pin the shapes this module hands to the page.\n */\nexport type MailboxAccount = MailboxAccountsQuery['mailboxAccounts'][number];\nexport type MailboxMessageSummary = MailboxMessagesQuery['mailboxMessages']['messages'][number];\nexport type MailboxThread = NonNullable<MailboxThreadQuery['mailboxThread']>;\nexport type MailboxSendResult = SendMailboxMessageMutation['sendMailboxMessage'];\nexport type MailboxLabel = MailboxLabelsQuery['mailboxLabels'][number];\nexport type MailboxThreadMessage = MailboxThread['messages'][number];\nexport type MailboxAttachment = MailboxThreadMessage['attachments'][number];\nexport type MailboxAttachmentContent = MailboxAttachmentQuery['mailboxAttachment'];\n\nexport function useMailboxAccounts() {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useMailboxAccountsQuery({\n skip: !workspaceId,\n errorPolicy: 'all',\n fetchPolicy: 'cache-and-network',\n });\n const typed = data as MailboxAccountsQuery | undefined;\n const accounts: MailboxAccount[] = typed?.mailboxAccounts ?? [];\n // True once the gateway has answered; a skipped query (no workspace yet)\n // must not read as \"no mailboxes connected\".\n const answered = typed?.mailboxAccounts !== undefined;\n return { accounts, answered, loading, error, refetch };\n}\n\nexport function useMailboxMessages(options: {\n connectionId: string | null;\n folder: MailboxFolder;\n /** A label or folder from useMailboxLabels; replaces `folder` when set. */\n folderId: string | null;\n query: string;\n pageToken: string | null;\n}) {\n const { connectionId, folder, folderId, query, pageToken } = options;\n const { data, loading, error, refetch } = useMailboxMessagesQuery({\n variables: {\n input: {\n connectionId: connectionId ?? '',\n folder,\n folderId,\n query: query || null,\n pageToken,\n limit: MAILBOX_PAGE_SIZE,\n },\n },\n skip: !connectionId,\n errorPolicy: 'none',\n fetchPolicy: 'network-only',\n });\n const typed = data as MailboxMessagesQuery | undefined;\n const messages: MailboxMessageSummary[] = typed?.mailboxMessages.messages ?? [];\n const nextPageToken: string | null = typed?.mailboxMessages.nextPageToken ?? null;\n return {\n messages,\n nextPageToken,\n loading,\n error,\n refetch,\n };\n}\n\nexport function useMailboxThread(connectionId: string | null, threadId: string | null) {\n const { data, loading, error, refetch } = useMailboxThreadQuery({\n variables: { connectionId: connectionId ?? '', threadId: threadId ?? '' },\n skip: !connectionId || !threadId,\n errorPolicy: 'none',\n fetchPolicy: 'network-only',\n });\n const thread: MailboxThread | null =\n (data as MailboxThreadQuery | undefined)?.mailboxThread ?? null;\n return { thread, loading, error, refetch };\n}\n\nexport function useMailboxLabels(connectionId: string | null) {\n const { data, loading, error } = useMailboxLabelsQuery({\n variables: { connectionId: connectionId ?? '' },\n skip: !connectionId,\n errorPolicy: 'none',\n fetchPolicy: 'cache-and-network',\n });\n const labels: MailboxLabel[] = (data as MailboxLabelsQuery | undefined)?.mailboxLabels ?? [];\n return { labels, loading, error };\n}\n\n/** Fetches one received attachment's bytes. Never cached: files can be large. */\nexport function useMailboxAttachmentContent() {\n const [load] = useMailboxAttachmentLazyQuery({ fetchPolicy: 'no-cache' });\n return useCallback(\n async (connectionId: string, messageId: string, attachmentId: string) => {\n const result = await load({ variables: { connectionId, messageId, attachmentId } });\n if (result.error) throw result.error;\n const content: MailboxAttachmentContent | null =\n (result.data as MailboxAttachmentQuery | undefined)?.mailboxAttachment ?? null;\n if (!content) throw new Error('Attachment not found');\n return content;\n },\n [load]\n );\n}\n\nexport function useMailboxThreadActions() {\n const [archive, archiveState] = useArchiveMailboxThreadMutation();\n const [trash, trashState] = useTrashMailboxThreadMutation();\n const archiveThread = useCallback(\n async (connectionId: string, threadId: string) => {\n await archive({ variables: { connectionId, threadId } });\n },\n [archive]\n );\n const trashThread = useCallback(\n async (connectionId: string, threadId: string) => {\n await trash({ variables: { connectionId, threadId } });\n },\n [trash]\n );\n return { archiveThread, trashThread, busy: archiveState.loading || trashState.loading };\n}\n\n/** A file uploaded to Files for an outgoing message. */\nexport interface PendingMailAttachment {\n fileId: string;\n name: string;\n size: number;\n}\n\n/**\n * Uploads a file to wspace-files-svc (initiateUpload, PUT to the presigned\n * URL, completeUpload) so sendMailboxMessage can attach it by id. The service\n * reads it back as the caller; the bytes never pass through the gateway.\n */\nexport function useUploadMailAttachment() {\n const [initiate] = useMailboxAttachmentInitiateUploadMutation();\n const [complete] = useMailboxAttachmentCompleteUploadMutation();\n return useCallback(\n async (file: File): Promise<PendingMailAttachment> => {\n const mimeType = file.type || 'application/octet-stream';\n const dot = file.name.lastIndexOf('.');\n const extension = dot > 0 ? file.name.slice(dot + 1).toLowerCase() : 'bin';\n const fileSize = String(file.size);\n const started = await initiate({\n variables: { input: { fileName: file.name, fileSize, mimeType, extension } },\n });\n const session = (started.data as MailboxAttachmentInitiateUploadMutation | null | undefined)\n ?.initiateUpload;\n if (!session?.uploadUrl || !session.session.id) {\n throw new Error(`Could not start uploading ${file.name}`);\n }\n const put = await fetch(session.uploadUrl, {\n method: 'PUT',\n body: file,\n headers: { 'Content-Type': mimeType },\n });\n if (!put.ok) throw new Error(`Uploading ${file.name} failed`);\n const done = await complete({\n variables: { input: { sessionId: session.session.id, fileSize } },\n });\n const fileId = (done.data as MailboxAttachmentCompleteUploadMutation | null | undefined)\n ?.completeUpload.fileId;\n if (!fileId) throw new Error(`Could not finish uploading ${file.name}`);\n return { fileId, name: file.name, size: file.size };\n },\n [initiate, complete]\n );\n}\n\nexport interface SendMailInput {\n connectionId: string;\n to: string[];\n cc?: string[];\n subject?: string;\n bodyText: string;\n replyToMessageId?: string;\n attachmentFileIds?: string[];\n}\n\nexport function useSendMail() {\n const [mutate, { loading }] = useSendMailboxMessageMutation();\n const send = useCallback(\n async (input: SendMailInput) => {\n const result = await mutate({\n variables: {\n input: {\n connectionId: input.connectionId,\n to: input.to,\n cc: input.cc ?? null,\n subject: input.subject ?? null,\n bodyText: input.bodyText,\n replyToMessageId: input.replyToMessageId ?? null,\n attachmentFileIds: input.attachmentFileIds?.length ? input.attachmentFileIds : null,\n },\n },\n });\n const sent: MailboxSendResult | null =\n (result.data as SendMailboxMessageMutation | null | undefined)?.sendMailboxMessage ?? null;\n return sent;\n },\n [mutate]\n );\n return { send, sending: loading };\n}\n\nexport function useSetMailRead() {\n const [mutate] = useSetMailboxMessageReadMutation();\n return useCallback(\n async (connectionId: string, messageId: string, read: boolean) => {\n await mutate({ variables: { connectionId, messageId, read } });\n },\n [mutate]\n );\n}\n\n/**\n * Splits a recipient field on commas, semicolons and line breaks. Spaces are\n * not separators, so a pasted entry stays whole and the service validates it\n * as one address instead of receiving fragments of it.\n */\nexport function splitRecipients(value: string): string[] {\n return value\n .split(/[,;\\r\\n]+/)\n .map((part) => part.trim())\n .filter(Boolean);\n}\n"],"mappings":";;;;;AAyCA,IAAa,IAAuE;EACjF,EAAY,QAAQ,KAAK,OAAO;EAChC,EAAY,UAAU;CACxB;AAmBD,SAAgB,IAAqB;CACnC,IAAM,EAAE,mBAAgB,GAAiB,EACnC,EAAE,SAAM,YAAS,UAAO,eAAY,EAAwB;EAChE,MAAM,CAAC;EACP,aAAa;EACb,aAAa;EACd,CAAC,EACI,IAAQ;AAKd,QAAO;EAAE,UAJ0B,GAAO,mBAAmB,EAAE;EAI5C,UADF,GAAO,oBAAoB,KAAA;EACf;EAAS;EAAO;EAAS;;AAGxD,SAAgB,EAAmB,GAOhC;CACD,IAAM,EAAE,iBAAc,WAAQ,aAAU,UAAO,iBAAc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AErD,CAAC,GAAU,EAAS,CACrB;;AAaH,SAAgB,IAAc;CAC5B,IAAM,CAAC,GAAQ,EAAE,gBAAa,GAA+B;AAsB7D,QAAO;EAAE,MArBI,EACX,OAAO,OACU,MAAM,EAAO,EAC1B,WAAW,EACT,OAAO;GACL,cAAc,EAAM;GACpB,IAAI,EAAM;GACV,IAAI,EAAM,MAAM;GAChB,SAAS,EAAM,WAAW;GAC1B,UAAU,EAAM;GAChB,kBAAkB,EAAM,oBAAoB;GAC5C,mBAAmB,EAAM,mBAAmB,SAAS,EAAM,oBAAoB;GAChF,EACF,EACF,CAAC,EAEQ,MAAwD,sBAAsB,MAG1F,CAAC,EAAO,CACT;EACc,SAAS;EAAS;;AAGnC,SAAgB,IAAiB;CAC/B,IAAM,CAAC,KAAU,GAAkC;AACnD,QAAO,EACL,OAAO,GAAsB,GAAmB,MAAkB;AAChE,QAAM,EAAO,EAAE,WAAW;GAAE;GAAc;GAAW;GAAM,EAAE,CAAC;IAEhE,CAAC,EAAO,CACT;;AAQH,SAAgB,EAAgB,GAAyB;AACvD,QAAO,EACJ,MAAM,YAAY,CAClB,KAAK,MAAS,EAAK,MAAM,CAAC,CAC1B,OAAO,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MailboxInbox.d.ts","sourceRoot":"","sources":["../../../src/integrations/pages/MailboxInbox.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MailboxInbox.d.ts","sourceRoot":"","sources":["../../../src/integrations/pages/MailboxInbox.tsx"],"names":[],"mappings":"AAu8BA;;;;GAIG;AACH,wBAAgB,YAAY,gCAgB3B"}
|