@ai-matrx/office 0.8.3 → 0.8.5
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/CHANGELOG.md +14 -0
- package/dist/{chunk-6Z3Y6DUI.cjs → chunk-556EUPET.cjs} +6 -1
- package/dist/chunk-556EUPET.cjs.map +1 -0
- package/dist/{chunk-XMM62UAT.js → chunk-5JAZ32SX.js} +6 -1
- package/dist/{chunk-XMM62UAT.js.map → chunk-5JAZ32SX.js.map} +1 -1
- package/dist/docs-io.cjs +6 -6
- package/dist/docs-io.js +1 -1
- package/dist/docs.cjs +2 -2
- package/dist/docs.js +1 -1
- package/dist/sheets.cjs +4 -4
- package/dist/sheets.cjs.map +1 -1
- package/dist/sheets.d.cts +3 -3
- package/dist/sheets.d.ts +3 -3
- package/dist/sheets.js +5 -5
- package/dist/sheets.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-6Z3Y6DUI.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.5
|
|
4
|
+
|
|
5
|
+
UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
|
|
6
|
+
Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/office/src`.
|
|
7
|
+
|
|
8
|
+
## 0.8.4
|
|
9
|
+
|
|
10
|
+
- Bold, italic, code and strike of markdown written into a document were dropped (live: `**notes**` pasted into a blank document stayed plain; the same for the agent body write and building blocks). Cause: Univer's text insert returns early when the target body has no `textRuns` array, and a blank document has none. `sanitizeUniverDocSnapshot` now gives every body an empty `textRuns`. Test: `a-document-keeps-the-styles-of-text-written-into-it.test.ts` (red on 0.8.3).
|
|
11
|
+
|
|
12
|
+
### Consumer action
|
|
13
|
+
|
|
14
|
+
None (the editor already sanitizes every snapshot it opens).
|
|
15
|
+
|
|
3
16
|
## 0.8.3
|
|
4
17
|
|
|
5
18
|
- A table in an uploaded Word file now imports as one markdown table block (its rows were split by blank lines, so no table was drawn), and an HTML `<table>` imports as a table too (its cells were loose paragraphs). Both go through THE one converter into a real Univer table. Test: `a-word-or-html-table-imports-as-a-real-table.test.ts` (red on 0.8.2).
|
|
@@ -165,3 +178,4 @@ First release (W1-G1a). `/core`: editor menu model, ribbon model, Google parity
|
|
|
165
178
|
|
|
166
179
|
Call `configureOfficeHosts(map)` at start-up before using `officeHref`. Register Coming-soon rows and the announcer through `@ai-matrx/kit/coming-soon`.
|
|
167
180
|
|
|
181
|
+
|
|
@@ -200,6 +200,7 @@ var NAMED_STYLE_STRING_TO_NUMBER = Object.fromEntries(
|
|
|
200
200
|
);
|
|
201
201
|
function sanitizeUniverDocSnapshot(snapshot, docId) {
|
|
202
202
|
restorePageStyle(snapshot, docId);
|
|
203
|
+
ensureTextRuns(snapshot);
|
|
203
204
|
const paragraphs = _optionalChain([snapshot, 'optionalAccess', _5 => _5.body, 'optionalAccess', _6 => _6.paragraphs]);
|
|
204
205
|
if (!Array.isArray(paragraphs)) return snapshot;
|
|
205
206
|
let fixed = 0;
|
|
@@ -249,6 +250,10 @@ function restorePageStyle(snapshot, docId) {
|
|
|
249
250
|
`[data-tables] RECOVERY: document snapshot${docId ? ` ${docId}` : ""} had no documentStyle.pageSize \u2014 restored the default Letter page geometry. Without a page box Univer lays the body out unbounded: text does not wrap and the viewport has no scrollable extent, so the document appears frozen. Fix the snapshot writer (agent/markdown converters must stamp DEFAULT_DOCUMENT_PAGE_STYLE).`
|
|
250
251
|
);
|
|
251
252
|
}
|
|
253
|
+
function ensureTextRuns(snapshot) {
|
|
254
|
+
const body = _optionalChain([snapshot, 'optionalAccess', _13 => _13.body]);
|
|
255
|
+
if (body && typeof body === "object" && !Array.isArray(body.textRuns)) body.textRuns = [];
|
|
256
|
+
}
|
|
252
257
|
|
|
253
258
|
|
|
254
259
|
|
|
@@ -269,4 +274,4 @@ function restorePageStyle(snapshot, docId) {
|
|
|
269
274
|
|
|
270
275
|
|
|
271
276
|
exports.configureDocsHost = configureDocsHost; exports.getDocsHost = getDocsHost; exports.createDocument = createDocument; exports.listAccessibleDocuments = listAccessibleDocuments; exports.getDocument = getDocument; exports.renameDocument = renameDocument; exports.moveDocument = moveDocument; exports.updateDocumentDescription = updateDocumentDescription; exports.restoreDocument = restoreDocument; exports.discardFailedDocument = discardFailedDocument; exports.deleteDocument = deleteDocument; exports.getLatestDocumentSnapshot = getLatestDocumentSnapshot; exports.saveDocumentSnapshot = saveDocumentSnapshot; exports.copyDocument = copyDocument; exports.listTrashedDocuments = listTrashedDocuments; exports.listDocumentSnapshots = listDocumentSnapshots; exports.sanitizeUniverDocSnapshot = sanitizeUniverDocSnapshot;
|
|
272
|
-
//# sourceMappingURL=chunk-
|
|
277
|
+
//# sourceMappingURL=chunk-556EUPET.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/aidream/aidream/apps/shared/office/dist/chunk-556EUPET.cjs","../src/docs/ports.ts","../src/docs/document-service.ts","../src/docs/sanitize-univer-doc-snapshot.ts"],"names":["error"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACiBA,IAAM,KAAA,kBAAO,MAAA,CAAO,GAAA,CAAI,2BAA2B,CAAA;AAEnD,IAAM,KAAA,EAAO,CAAA,EAAA,GAAY;AACvB,EAAA,MAAM,EAAA,EAAI,UAAA;AACV,EAAA,OAAQ,CAAA,CAAE,IAAI,EAAA,IAAM,CAAC,CAAA;AACvB,CAAA;AAEO,SAAS,iBAAA,CAAkB,KAAA,EAA4B;AAC5D,EAAA,IAAA,CAAK,CAAA,CAAE,MAAA,EAAQ,KAAA;AACjB;AAEO,SAAS,WAAA,CAAA,EAA6B;AAC3C,EAAA,MAAM,MAAA,EAAQ,IAAA,CAAK,CAAA,CAAE,KAAA;AACrB,EAAA,GAAA,CAAI,CAAC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,MAAM,QAAA,EAAU,4BAAA,CAA6B,KAAK,CAAA;AAClD,MAAA,GAAA,CAAI,QAAA,IAAY,KAAA,CAAA,EAAW;AACzB,QAAC,KAAA,CAAsC,eAAA,EAAiB,OAAA;AACxD,QAAA,MAAA,GAAS,CAAA;AAAA,MACX,EAAA,KAAO;AAGL,QAAA,OAAQ,KAAA,CAAuC,cAAA;AAC/C,QAAA,MAAA,GAAS,CAAA;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAEA,EAAA,GAAA,CAAI,MAAA,EAAQ,CAAA,EAAG;AACb,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN,CAAA,kCAAA,EAAqC,KAAK,CAAA,8EAAA,EACS,MAAA,EAAQ,CAAA,CAAA,EAAI,KAAK,CAAA,EAAA;AAItE,IAAA;AACF,EAAA;AAEO,EAAA;AACT;AAU4E;AAC3B,EAAA;AAKxB,EAAA;AACyC,EAAA;AACxB,IAAA;AACyF,IAAA;AAC/H,IAAA;AACF,EAAA;AAC4B,EAAA;AACC,IAAA;AACa,MAAA;AACsB,MAAA;AACS,MAAA;AACvE,IAAA;AACA,IAAA;AACF,EAAA;AAEyB,EAAA;AACK,IAAA;AACG,IAAA;AACM,IAAA;AACvC,EAAA;AAEQ,EAAA;AAC8D,IAAA;AAMtE,EAAA;AACF;AAQ0D;AACjC,EAAA;AACiE,EAAA;AAC1F;AH0GmJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/aidream/aidream/apps/shared/office/dist/chunk-556EUPET.cjs","sourcesContent":[null,"/**\n * The host ports of the Docs model and io.\n *\n * The package owns the document service, the open-document model and the converters, but two things\n * belong to the app that mounts them: the database client (a package owns no client) and the server\n * request that converts a .docx to .odt / .rtf (the app owns the server URL, auth and error capture).\n * The host states them once at start-up with `configureDocsHost`. State sits on a `globalThis` slot\n * so a dual-bundled copy of the package still sees one host. An unconfigured port THROWS naming\n * itself (nothing fails silently).\n */\nimport type { SupabaseClient } from \"@supabase/supabase-js\";\n\n/** A Supabase client over any schema: the package cannot import the app's generated database types. */\nexport type DocsSupabase = SupabaseClient<any, any, any>;\n\nexport interface DocsHostPorts {\n /** The app's database client (signed in as the person). */\n getSupabase(): DocsSupabase;\n /** An authenticated request to the Matrx server returning the raw `Response` (the open-format converter). */\n requestRaw(path: string, init: { method: \"POST\"; body: FormData }): Promise<Response>;\n}\n\nconst SLOT = Symbol.for(\"ai-matrx.office.docs-host\");\ntype Slot = { ports?: DocsHostPorts };\nconst slot = (): Slot => {\n const g = globalThis as Record<symbol, Slot | undefined>;\n return (g[SLOT] ??= {});\n};\n\nexport function configureDocsHost(ports: DocsHostPorts): void {\n slot().ports = ports;\n}\n\nexport function getDocsHost(): DocsHostPorts {\n const ports = slot().ports;\n if (!ports) throw new Error(\"@ai-matrx/office/docs: configureDocsHost(ports) was not called before the document service ran.\");\n return ports;\n}\n","/**\n * Document service — typed wrappers for `udt_documents` + `udt_document_snapshots`.\n *\n * Cloud document editor backed by Univer's preset-docs-core. Same shape as\n * `workbook-service.ts` — metadata in `udt_documents`, content state in\n * append-only `udt_document_snapshots`. The editor hydrates from the LATEST\n * snapshot and writes a new snapshot per save (debounced on the client —\n * see DocumentEditor).\n *\n * What lives elsewhere:\n * - Sharing / permissions: features/sharing/ + `has_permission(...)` RLS\n * - The open document (one model per id per tab: load, one save, realtime,\n * collab): features/documents/document-model/\n * - Component (a view of that model): features/documents/components/DocumentEditor\n *\n * Mirrors `workbook-service.ts`. If you're changing the shape of one, change\n * the other at the same time — see `features/data-tables/FEATURE.md`.\n */\nimport { requireOrganizationContext } from \"@ai-matrx/api\";\nimport { getClaimsUser } from \"@ai-matrx/auth\";\nimport { readAllRows, tryWriteOne, writeOneRow } from \"@ai-matrx/data/db\";\nimport type { ServiceResult } from \"@ai-matrx/records/core\";\n\nimport type { DocumentRow, DocumentSnapshot, DocumentSnapshotOrigin } from \"../core\";\nimport { getDocsHost } from \"./ports\";\n\n/** The app's database client, read through the host port at call time. */\nconst db = () => getDocsHost().getSupabase();\n// ─── documents ───────────────────────────────────────────────────────────────\n\nexport type CreateDocumentArgs = {\n name: string;\n description?: string | null;\n /** Origin label for the document itself, mirrors `udt_documents.source`. */\n source?: \"created\" | \"imported_docx\" | \"imported_md\" | \"imported_txt\" | \"linked_gdoc\";\n organizationId: string;\n projectId?: string | null;\n taskId?: string | null;\n isPublic?: boolean;\n /**\n * cld_files.id of the source upload (DOCX / MD / TXT blob). Set on the\n * import flow so the lossless original is recoverable; FK is ON DELETE SET\n * NULL, so deleting the file just nulls the link — the document survives.\n */\n originalFileId?: string | null;\n};\n\nexport async function createDocument(\n args: CreateDocumentArgs,\n): Promise<ServiceResult<DocumentRow>> {\n let organizationId: string;\n try {\n organizationId = requireOrganizationContext(undefined, args.organizationId);\n } catch (error) {\n return {\n success: false,\n error:\n error instanceof Error\n ? error.message\n : \"Select an organization before creating a document.\",\n };\n }\n\n const { data: userData, error: userErr } = await getClaimsUser(db());\n if (userErr || !userData?.user) {\n return {\n success: false,\n error: userErr?.message ?? \"not authenticated\",\n };\n }\n\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .insert({\n document_name: args.name,\n description: args.description ?? null,\n source: args.source ?? \"created\",\n organization_id: organizationId,\n project_id: args.projectId ?? null,\n task_id: args.taskId ?? null,\n original_file_id: args.originalFileId ?? null,\n // CANONICAL columns (workbench_udt_canonical_step1). `visibility` is the\n // source of truth; the legacy `is_public` boolean is derived from it by\n // the workbench._bridge_legacy_owner trigger, so writing both here would\n // be two authorities for one fact. A new document defaults to `internal`\n // — it is org work product, not an individual person's private thing\n // (db-rules §6) — unless the caller explicitly asked for public.\n created_by: userData.user.id,\n visibility: args.isPublic ? \"public\" : \"internal\",\n })\n .select(\"*\")\n .single();\n if (error) return { success: false, error: error.message };\n return { success: true, data: data as DocumentRow };\n}\n\nexport async function listAccessibleDocuments(): Promise<\n ServiceResult<DocumentRow[]>\n> {\n // RLS handles owner / published-to-the-web / shared access. The library and\n // the pickers treat this list as COMPLETE (\"you have no such document\"), so\n // it pages past PostgREST's silent 1000-row cap (D190).\n try {\n const rows = await readAllRows<DocumentRow>(\n ({ from, to }) =>\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .select(\"*\", { count: \"exact\" })\n .is(\"deleted_at\", null)\n .order(\"updated_at\", { ascending: false })\n .order(\"id\", { ascending: true })\n .range(from, to)\n .returns<DocumentRow[]>(),\n { label: \"workbench.udt_documents accessible documents\" },\n );\n return { success: true, data: rows };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n}\n\nexport async function getDocument(\n documentId: string,\n): Promise<ServiceResult<DocumentRow>> {\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .select(\"*\")\n .eq(\"id\", documentId)\n .is(\"deleted_at\", null)\n .maybeSingle();\n if (error) return { success: false, error: error.message };\n if (!data) {\n // A trashed or unreachable document is a state the person can act on,\n // never PostgREST's \"Cannot coerce the result to a single JSON object\".\n return {\n success: false,\n error:\n \"This document is in the trash or you no longer have access to it. Restore it from Trash, or ask its owner to share it again.\",\n };\n }\n return { success: true, data: data as DocumentRow };\n}\n\nexport async function renameDocument(\n documentId: string,\n name: string,\n): Promise<ServiceResult<DocumentRow>> {\n const { data, error } = await writeOneRow(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ document_name: name, updated_at: new Date().toISOString() })\n .eq(\"id\", documentId)\n .select(\"*\"),\n { action: \"update\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: data as DocumentRow };\n}\n\n/**\n * Move the document into a project (or out of one with `null`). Sibling of\n * `renameDocument`: the one named setter for `project_id`.\n */\nexport async function moveDocument(\n documentId: string,\n projectId: string | null,\n): Promise<ServiceResult<DocumentRow>> {\n const { data, error } = await writeOneRow(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ project_id: projectId, updated_at: new Date().toISOString() })\n .eq(\"id\", documentId)\n .select(\"*\"),\n { action: \"update\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: data as DocumentRow };\n}\n\n/**\n * Rewrite the document's description. Sibling of `renameDocument` — the two\n * human-authored fields on `udt_documents` each get a named setter so callers\n * never hand-roll a `.from(\"udt_documents\").update(...)`. Pass `null` (or an\n * empty string) to clear it.\n *\n * Added when the documents surface became agent-writable: the\n * `document_description` write target on `/documents/[id]` is its caller, the\n * same way `updateWorkbookDescription` serves `workbook_description`. Keeping\n * the pair symmetric is this file's standing contract with `workbook-service`\n * (see the module header).\n */\nexport async function updateDocumentDescription(\n documentId: string,\n description: string | null,\n): Promise<ServiceResult<DocumentRow>> {\n const { data, error } = await writeOneRow(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({\n description: description && description.length > 0 ? description : null,\n updated_at: new Date().toISOString(),\n })\n .eq(\"id\", documentId)\n .select(\"*\"),\n { action: \"update\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: data as DocumentRow };\n}\n\n/**\n * Soft delete — the document is tombstoned, not destroyed, and its snapshots stay\n * with it. Every read path filters `deleted_at is null`. Pair with\n * restoreDocument for undo. (aidream migration 0458.)\n */\nexport async function restoreDocument(\n documentId: string,\n): Promise<ServiceResult<true>> {\n const { error } = await tryWriteOne(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ deleted_at: null })\n .eq(\"id\", documentId)\n .select(\"id\"),\n { action: \"restore\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: true };\n}\n\n/**\n * Archive (delete means archive: never a hard delete) — only for rolling back a document this very flow just created and\n * failed to populate. Never use for a user-initiated delete: that is\n * deleteDocument, which tombstones and stays recoverable.\n */\nexport async function discardFailedDocument(\n documentId: string,\n): Promise<ServiceResult<true>> {\n const { error } = await tryWriteOne(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ deleted_at: new Date().toISOString() })\n .eq(\"id\", documentId)\n .select(\"id\"),\n { action: \"archive\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: true };\n}\n\nexport async function deleteDocument(\n documentId: string,\n): Promise<ServiceResult<true>> {\n const { error } = await tryWriteOne(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ deleted_at: new Date().toISOString() })\n .eq(\"id\", documentId)\n .select(\"id\"),\n { action: \"delete\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: true };\n}\n\n// ─── snapshots (document content) ────────────────────────────────────────────\n\n/**\n * Latest-snapshot fetch — what an opened document hydrates from. Returns\n * `data: null` (success path) when the document has no snapshots yet (newly\n * created, never saved). Distinguish \"no snapshot\" from \"load error\" by\n * checking `result.data === null`.\n */\nexport async function getLatestDocumentSnapshot(\n documentId: string,\n): Promise<ServiceResult<DocumentSnapshot | null>> {\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_document_snapshots\")\n .select(\"*\")\n .eq(\"document_id\", documentId)\n .order(\"created_at\", { ascending: false })\n .limit(1)\n .maybeSingle();\n if (error) return { success: false, error: error.message };\n return { success: true, data: (data ?? null) as DocumentSnapshot | null };\n}\n\nexport type SaveDocumentSnapshotArgs = {\n documentId: string;\n snapshot: unknown; // opaque to us — Univer IDocumentData decides the shape\n label?: string | null;\n origin?: DocumentSnapshotOrigin;\n};\n\nexport async function saveDocumentSnapshot(\n args: SaveDocumentSnapshotArgs,\n): Promise<ServiceResult<DocumentSnapshot>> {\n const { data: userData } = await getClaimsUser(db());\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_document_snapshots\")\n .insert({\n document_id: args.documentId,\n snapshot: args.snapshot as never,\n label: args.label ?? null,\n origin: args.origin ?? \"autosave\",\n created_by: userData?.user?.id ?? null,\n })\n .select(\"*\")\n .single();\n if (error) return { success: false, error: error.message };\n\n // Touch the parent document's updated_at so list views can sort by recency\n // without scanning snapshots. Best-effort — failure here is harmless.\n // write-lands-exempt: best-effort recency stamp on the parent document; the snapshot insert above is the real write\n await db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ updated_at: new Date().toISOString() })\n .eq(\"id\", args.documentId);\n\n return { success: true, data: data as DocumentSnapshot };\n}\n\n/**\n * An independent copy of a document: its own row, with the latest snapshot copied over, so editing the copy never\n * touches the original. The copy lives in the original's organization and project. Used by a board-template use.\n */\nexport async function copyDocument(\n documentId: string,\n name?: string,\n): Promise<ServiceResult<DocumentRow>> {\n const original = await getDocument(documentId);\n if (!original.success) return original;\n const row = original.data;\n if (!row.organization_id) {\n return { success: false, error: \"This document has no organization and cannot be copied.\" };\n }\n const created = await createDocument({\n name: name ?? row.document_name,\n description: row.description ?? null,\n organizationId: row.organization_id,\n projectId: row.project_id ?? null,\n isPublic: row.visibility === \"public\",\n });\n if (!created.success) return created;\n const latest = await getLatestDocumentSnapshot(documentId);\n if (!latest.success) return latest;\n if (latest.data) {\n const saved = await saveDocumentSnapshot({\n documentId: created.data.id,\n snapshot: latest.data.snapshot,\n label: latest.data.label,\n origin: \"autosave\",\n });\n if (!saved.success) return saved;\n }\n return created;\n}\n\n/** Trash view: the caller's own archived documents (RLS decides what is readable). */\nexport async function listTrashedDocuments(): Promise<\n ServiceResult<DocumentRow[]>\n> {\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .select(\"*\")\n .not(\"deleted_at\", \"is\", null)\n .order(\"deleted_at\", { ascending: false });\n if (error) return { success: false, error: error.message };\n return { success: true, data: (data ?? []) as DocumentRow[] };\n}\n\nexport async function listDocumentSnapshots(\n documentId: string,\n limit = 50,\n): Promise<ServiceResult<DocumentSnapshot[]>> {\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_document_snapshots\")\n // component-created-by-ok: append-only snapshot with NO updated_by column and NO parent-rewrite trigger — created_by is the author the client wrote at insert (the only person field this table has)\n .select(\"id, document_id, label, origin, created_by, created_at\")\n .eq(\"document_id\", documentId)\n .order(\"created_at\", { ascending: false })\n .limit(limit);\n if (error) return { success: false, error: error.message };\n return { success: true, data: (data ?? []) as DocumentSnapshot[] };\n}\n","/**\n * sanitizeUniverDocSnapshot — defensive normalizer for Univer document\n * snapshots loaded from storage.\n *\n * WHY THIS EXISTS (loud recovery layer):\n * Univer's `NamedStyleType` is a NUMERIC enum (`HEADING_1 = 4`, `HEADING_2 = 5`,\n * …). Some snapshots in storage were produced by an external markdown→Univer\n * converter that wrote the *string* name (`\"HEADING_1\"`) into\n * `paragraphStyle.namedStyleType` instead of the numeric value. At render time\n * Univer does `HEADING_ICON_MAP[namedStyleType]` → `undefined` →\n * `icon.key` throws `Cannot read properties of undefined (reading 'key')` inside\n * the `<ParagraphMenu>` component the moment the cursor lands in a heading. That\n * uncaught error tears down Univer's React root, so the document loads and then\n * vanishes. See `features/data-tables/FEATURE.md`.\n *\n * This normalizer converts those string enum values back to numbers BEFORE the\n * snapshot reaches `createUniverDoc`. It is a recovery layer: when it fires it\n * means malformed data slipped past the writer, so it SCREAMS (console.warn)\n * with a count and the document id. The proper long-term fix is to make the\n * writer emit numeric enum values; until then this keeps the editor alive.\n *\n * Returns the SAME object (mutated in place) for ergonomic call sites, plus a\n * `fixed` count via the second return slot is intentionally avoided — callers\n * only need the sanitized snapshot; the warning is the signal.\n */\nimport { NamedStyleType } from \"@univerjs/core\";\nimport type { IDocumentData } from \"@univerjs/core\";\n\nimport {\n defaultDocumentPageStyle,\n isLegacySqueezedPageStyle,\n} from \"../core\";\n\n/**\n * Map of every string name that could appear in a legacy snapshot to its\n * canonical numeric `NamedStyleType`. Built from the enum itself so it stays in\n * lockstep with Univer (numeric enums expose name→value on string keys).\n */\nconst NAMED_STYLE_STRING_TO_NUMBER: Record<string, number> = Object.fromEntries(\n Object.entries(NamedStyleType)\n .filter(([key, val]) => typeof val === \"number\" && isNaN(Number(key)))\n .map(([key, val]) => [key, val as number]),\n);\n\n/**\n * Normalize a Univer document snapshot in place. Currently fixes string-valued\n * `paragraphStyle.namedStyleType` (the confirmed `<ParagraphMenu>` crash). New\n * classes of string-vs-enum corruption should be added here, not patched at the\n * call site.\n *\n * @param snapshot The snapshot about to be passed to `createUniverDoc`.\n * @param docId Document id, for the loud warning only.\n * @returns the same snapshot reference (mutated).\n */\nexport function sanitizeUniverDocSnapshot(\n snapshot: Partial<IDocumentData>,\n docId?: string,\n): Partial<IDocumentData> {\n restorePageStyle(snapshot, docId);\n ensureTextRuns(snapshot);\n\n const paragraphs = snapshot?.body?.paragraphs;\n if (!Array.isArray(paragraphs)) return snapshot;\n\n let fixed = 0;\n for (const paragraph of paragraphs) {\n const style = paragraph?.paragraphStyle as\n { namedStyleType?: unknown } | undefined;\n const value = style?.namedStyleType;\n if (typeof value === \"string\") {\n const numeric = NAMED_STYLE_STRING_TO_NUMBER[value];\n if (numeric !== undefined) {\n (style as { namedStyleType?: number }).namedStyleType = numeric;\n fixed += 1;\n } else {\n // Unknown string we can't map — drop it so Univer falls back to\n // NORMAL_TEXT rather than crashing on the lookup.\n delete (style as { namedStyleType?: unknown }).namedStyleType;\n fixed += 1;\n }\n }\n }\n\n if (fixed > 0) {\n console.warn(\n `[data-tables] RECOVERY: sanitized ${fixed} string namedStyleType value(s) ` +\n `to numeric NamedStyleType in document snapshot${docId ? ` ${docId}` : \"\"}. ` +\n `The snapshot was written with the wrong enum encoding (string instead of ` +\n `number) and would have crashed Univer's <ParagraphMenu>. Fix the snapshot ` +\n `writer to emit numeric NamedStyleType values.`,\n );\n }\n\n return snapshot;\n}\n\n/**\n * Second recovery: a snapshot with no `documentStyle.pageSize` has no page box,\n * so Univer lays the body out unbounded — text never wraps and the docs\n * viewport reports no scrollable extent, which reads to the user as \"the\n * document won't scroll\". Snapshots written by agents (`origin='agent'`) and by\n * older converters reach storage with `documentStyle: {}`. Stamp the canonical\n * page geometry back on and SCREAM: the writer is the real bug.\n */\nfunction restorePageStyle(snapshot: Partial<IDocumentData>, docId?: string) {\n if (!snapshot || typeof snapshot !== \"object\") return;\n\n // THE SQUEEZED PAGE (2026-10-15): documents carried A4-at-72dpi geometry in Univer's pageless\n // flavour — a 415px text column with no paper. Move them to a real Letter page, unchanged text.\n // A document with no flavour at all is a paginated page too (Univer would otherwise pick pageless).\n const style = snapshot.documentStyle;\n if (style?.pageSize?.width && isLegacySqueezedPageStyle(style)) {\n const page = defaultDocumentPageStyle();\n snapshot.documentStyle = { ...style, ...page, defaultParagraphStyle: style.defaultParagraphStyle ?? page.defaultParagraphStyle } as typeof style;\n return;\n }\n if (style?.pageSize?.width) {\n if (!style.documentFlavor) {\n const page = defaultDocumentPageStyle();\n Object.assign(style, { documentFlavor: page.documentFlavor });\n if (page.defaultParagraphStyle) style.defaultParagraphStyle ??= page.defaultParagraphStyle;\n }\n return;\n }\n\n snapshot.documentStyle = {\n ...defaultDocumentPageStyle(),\n ...(snapshot.documentStyle ?? {}),\n pageSize: defaultDocumentPageStyle().pageSize,\n } as NonNullable<typeof snapshot.documentStyle>;\n\n console.warn(\n `[data-tables] RECOVERY: document snapshot${docId ? ` ${docId}` : \"\"} had no ` +\n `documentStyle.pageSize — restored the default Letter page geometry. Without a ` +\n `page box Univer lays the body out unbounded: text does not wrap and the ` +\n `viewport has no scrollable extent, so the document appears frozen. Fix the ` +\n `snapshot writer (agent/markdown converters must stamp ` +\n `DEFAULT_DOCUMENT_PAGE_STYLE).`,\n );\n}\n\n/**\n * A body with no `textRuns` array is a body Univer silently refuses styled text for: its text\n * insert (`insertTextRuns`) returns early when the target has none, so every bold, italic, code\n * and size run of pasted or agent-written markdown vanished (found 2026-10-16: `**notes**` pasted\n * into a blank document stayed plain). An empty array is the same document and accepts the runs.\n */\nfunction ensureTextRuns(snapshot: Partial<IDocumentData>) {\n const body = snapshot?.body;\n if (body && typeof body === \"object\" && !Array.isArray(body.textRuns)) body.textRuns = [];\n}\n"]}
|
|
@@ -200,6 +200,7 @@ var NAMED_STYLE_STRING_TO_NUMBER = Object.fromEntries(
|
|
|
200
200
|
);
|
|
201
201
|
function sanitizeUniverDocSnapshot(snapshot, docId) {
|
|
202
202
|
restorePageStyle(snapshot, docId);
|
|
203
|
+
ensureTextRuns(snapshot);
|
|
203
204
|
const paragraphs = snapshot?.body?.paragraphs;
|
|
204
205
|
if (!Array.isArray(paragraphs)) return snapshot;
|
|
205
206
|
let fixed = 0;
|
|
@@ -249,6 +250,10 @@ function restorePageStyle(snapshot, docId) {
|
|
|
249
250
|
`[data-tables] RECOVERY: document snapshot${docId ? ` ${docId}` : ""} had no documentStyle.pageSize \u2014 restored the default Letter page geometry. Without a page box Univer lays the body out unbounded: text does not wrap and the viewport has no scrollable extent, so the document appears frozen. Fix the snapshot writer (agent/markdown converters must stamp DEFAULT_DOCUMENT_PAGE_STYLE).`
|
|
250
251
|
);
|
|
251
252
|
}
|
|
253
|
+
function ensureTextRuns(snapshot) {
|
|
254
|
+
const body = snapshot?.body;
|
|
255
|
+
if (body && typeof body === "object" && !Array.isArray(body.textRuns)) body.textRuns = [];
|
|
256
|
+
}
|
|
252
257
|
|
|
253
258
|
export {
|
|
254
259
|
configureDocsHost,
|
|
@@ -269,4 +274,4 @@ export {
|
|
|
269
274
|
listDocumentSnapshots,
|
|
270
275
|
sanitizeUniverDocSnapshot
|
|
271
276
|
};
|
|
272
|
-
//# sourceMappingURL=chunk-
|
|
277
|
+
//# sourceMappingURL=chunk-5JAZ32SX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/docs/ports.ts","../src/docs/document-service.ts","../src/docs/sanitize-univer-doc-snapshot.ts"],"sourcesContent":["/**\n * The host ports of the Docs model and io.\n *\n * The package owns the document service, the open-document model and the converters, but two things\n * belong to the app that mounts them: the database client (a package owns no client) and the server\n * request that converts a .docx to .odt / .rtf (the app owns the server URL, auth and error capture).\n * The host states them once at start-up with `configureDocsHost`. State sits on a `globalThis` slot\n * so a dual-bundled copy of the package still sees one host. An unconfigured port THROWS naming\n * itself (nothing fails silently).\n */\nimport type { SupabaseClient } from \"@supabase/supabase-js\";\n\n/** A Supabase client over any schema: the package cannot import the app's generated database types. */\nexport type DocsSupabase = SupabaseClient<any, any, any>;\n\nexport interface DocsHostPorts {\n /** The app's database client (signed in as the person). */\n getSupabase(): DocsSupabase;\n /** An authenticated request to the Matrx server returning the raw `Response` (the open-format converter). */\n requestRaw(path: string, init: { method: \"POST\"; body: FormData }): Promise<Response>;\n}\n\nconst SLOT = Symbol.for(\"ai-matrx.office.docs-host\");\ntype Slot = { ports?: DocsHostPorts };\nconst slot = (): Slot => {\n const g = globalThis as Record<symbol, Slot | undefined>;\n return (g[SLOT] ??= {});\n};\n\nexport function configureDocsHost(ports: DocsHostPorts): void {\n slot().ports = ports;\n}\n\nexport function getDocsHost(): DocsHostPorts {\n const ports = slot().ports;\n if (!ports) throw new Error(\"@ai-matrx/office/docs: configureDocsHost(ports) was not called before the document service ran.\");\n return ports;\n}\n","/**\n * Document service — typed wrappers for `udt_documents` + `udt_document_snapshots`.\n *\n * Cloud document editor backed by Univer's preset-docs-core. Same shape as\n * `workbook-service.ts` — metadata in `udt_documents`, content state in\n * append-only `udt_document_snapshots`. The editor hydrates from the LATEST\n * snapshot and writes a new snapshot per save (debounced on the client —\n * see DocumentEditor).\n *\n * What lives elsewhere:\n * - Sharing / permissions: features/sharing/ + `has_permission(...)` RLS\n * - The open document (one model per id per tab: load, one save, realtime,\n * collab): features/documents/document-model/\n * - Component (a view of that model): features/documents/components/DocumentEditor\n *\n * Mirrors `workbook-service.ts`. If you're changing the shape of one, change\n * the other at the same time — see `features/data-tables/FEATURE.md`.\n */\nimport { requireOrganizationContext } from \"@ai-matrx/api\";\nimport { getClaimsUser } from \"@ai-matrx/auth\";\nimport { readAllRows, tryWriteOne, writeOneRow } from \"@ai-matrx/data/db\";\nimport type { ServiceResult } from \"@ai-matrx/records/core\";\n\nimport type { DocumentRow, DocumentSnapshot, DocumentSnapshotOrigin } from \"../core\";\nimport { getDocsHost } from \"./ports\";\n\n/** The app's database client, read through the host port at call time. */\nconst db = () => getDocsHost().getSupabase();\n// ─── documents ───────────────────────────────────────────────────────────────\n\nexport type CreateDocumentArgs = {\n name: string;\n description?: string | null;\n /** Origin label for the document itself, mirrors `udt_documents.source`. */\n source?: \"created\" | \"imported_docx\" | \"imported_md\" | \"imported_txt\" | \"linked_gdoc\";\n organizationId: string;\n projectId?: string | null;\n taskId?: string | null;\n isPublic?: boolean;\n /**\n * cld_files.id of the source upload (DOCX / MD / TXT blob). Set on the\n * import flow so the lossless original is recoverable; FK is ON DELETE SET\n * NULL, so deleting the file just nulls the link — the document survives.\n */\n originalFileId?: string | null;\n};\n\nexport async function createDocument(\n args: CreateDocumentArgs,\n): Promise<ServiceResult<DocumentRow>> {\n let organizationId: string;\n try {\n organizationId = requireOrganizationContext(undefined, args.organizationId);\n } catch (error) {\n return {\n success: false,\n error:\n error instanceof Error\n ? error.message\n : \"Select an organization before creating a document.\",\n };\n }\n\n const { data: userData, error: userErr } = await getClaimsUser(db());\n if (userErr || !userData?.user) {\n return {\n success: false,\n error: userErr?.message ?? \"not authenticated\",\n };\n }\n\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .insert({\n document_name: args.name,\n description: args.description ?? null,\n source: args.source ?? \"created\",\n organization_id: organizationId,\n project_id: args.projectId ?? null,\n task_id: args.taskId ?? null,\n original_file_id: args.originalFileId ?? null,\n // CANONICAL columns (workbench_udt_canonical_step1). `visibility` is the\n // source of truth; the legacy `is_public` boolean is derived from it by\n // the workbench._bridge_legacy_owner trigger, so writing both here would\n // be two authorities for one fact. A new document defaults to `internal`\n // — it is org work product, not an individual person's private thing\n // (db-rules §6) — unless the caller explicitly asked for public.\n created_by: userData.user.id,\n visibility: args.isPublic ? \"public\" : \"internal\",\n })\n .select(\"*\")\n .single();\n if (error) return { success: false, error: error.message };\n return { success: true, data: data as DocumentRow };\n}\n\nexport async function listAccessibleDocuments(): Promise<\n ServiceResult<DocumentRow[]>\n> {\n // RLS handles owner / published-to-the-web / shared access. The library and\n // the pickers treat this list as COMPLETE (\"you have no such document\"), so\n // it pages past PostgREST's silent 1000-row cap (D190).\n try {\n const rows = await readAllRows<DocumentRow>(\n ({ from, to }) =>\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .select(\"*\", { count: \"exact\" })\n .is(\"deleted_at\", null)\n .order(\"updated_at\", { ascending: false })\n .order(\"id\", { ascending: true })\n .range(from, to)\n .returns<DocumentRow[]>(),\n { label: \"workbench.udt_documents accessible documents\" },\n );\n return { success: true, data: rows };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n}\n\nexport async function getDocument(\n documentId: string,\n): Promise<ServiceResult<DocumentRow>> {\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .select(\"*\")\n .eq(\"id\", documentId)\n .is(\"deleted_at\", null)\n .maybeSingle();\n if (error) return { success: false, error: error.message };\n if (!data) {\n // A trashed or unreachable document is a state the person can act on,\n // never PostgREST's \"Cannot coerce the result to a single JSON object\".\n return {\n success: false,\n error:\n \"This document is in the trash or you no longer have access to it. Restore it from Trash, or ask its owner to share it again.\",\n };\n }\n return { success: true, data: data as DocumentRow };\n}\n\nexport async function renameDocument(\n documentId: string,\n name: string,\n): Promise<ServiceResult<DocumentRow>> {\n const { data, error } = await writeOneRow(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ document_name: name, updated_at: new Date().toISOString() })\n .eq(\"id\", documentId)\n .select(\"*\"),\n { action: \"update\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: data as DocumentRow };\n}\n\n/**\n * Move the document into a project (or out of one with `null`). Sibling of\n * `renameDocument`: the one named setter for `project_id`.\n */\nexport async function moveDocument(\n documentId: string,\n projectId: string | null,\n): Promise<ServiceResult<DocumentRow>> {\n const { data, error } = await writeOneRow(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ project_id: projectId, updated_at: new Date().toISOString() })\n .eq(\"id\", documentId)\n .select(\"*\"),\n { action: \"update\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: data as DocumentRow };\n}\n\n/**\n * Rewrite the document's description. Sibling of `renameDocument` — the two\n * human-authored fields on `udt_documents` each get a named setter so callers\n * never hand-roll a `.from(\"udt_documents\").update(...)`. Pass `null` (or an\n * empty string) to clear it.\n *\n * Added when the documents surface became agent-writable: the\n * `document_description` write target on `/documents/[id]` is its caller, the\n * same way `updateWorkbookDescription` serves `workbook_description`. Keeping\n * the pair symmetric is this file's standing contract with `workbook-service`\n * (see the module header).\n */\nexport async function updateDocumentDescription(\n documentId: string,\n description: string | null,\n): Promise<ServiceResult<DocumentRow>> {\n const { data, error } = await writeOneRow(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({\n description: description && description.length > 0 ? description : null,\n updated_at: new Date().toISOString(),\n })\n .eq(\"id\", documentId)\n .select(\"*\"),\n { action: \"update\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: data as DocumentRow };\n}\n\n/**\n * Soft delete — the document is tombstoned, not destroyed, and its snapshots stay\n * with it. Every read path filters `deleted_at is null`. Pair with\n * restoreDocument for undo. (aidream migration 0458.)\n */\nexport async function restoreDocument(\n documentId: string,\n): Promise<ServiceResult<true>> {\n const { error } = await tryWriteOne(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ deleted_at: null })\n .eq(\"id\", documentId)\n .select(\"id\"),\n { action: \"restore\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: true };\n}\n\n/**\n * Archive (delete means archive: never a hard delete) — only for rolling back a document this very flow just created and\n * failed to populate. Never use for a user-initiated delete: that is\n * deleteDocument, which tombstones and stays recoverable.\n */\nexport async function discardFailedDocument(\n documentId: string,\n): Promise<ServiceResult<true>> {\n const { error } = await tryWriteOne(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ deleted_at: new Date().toISOString() })\n .eq(\"id\", documentId)\n .select(\"id\"),\n { action: \"archive\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: true };\n}\n\nexport async function deleteDocument(\n documentId: string,\n): Promise<ServiceResult<true>> {\n const { error } = await tryWriteOne(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ deleted_at: new Date().toISOString() })\n .eq(\"id\", documentId)\n .select(\"id\"),\n { action: \"delete\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: true };\n}\n\n// ─── snapshots (document content) ────────────────────────────────────────────\n\n/**\n * Latest-snapshot fetch — what an opened document hydrates from. Returns\n * `data: null` (success path) when the document has no snapshots yet (newly\n * created, never saved). Distinguish \"no snapshot\" from \"load error\" by\n * checking `result.data === null`.\n */\nexport async function getLatestDocumentSnapshot(\n documentId: string,\n): Promise<ServiceResult<DocumentSnapshot | null>> {\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_document_snapshots\")\n .select(\"*\")\n .eq(\"document_id\", documentId)\n .order(\"created_at\", { ascending: false })\n .limit(1)\n .maybeSingle();\n if (error) return { success: false, error: error.message };\n return { success: true, data: (data ?? null) as DocumentSnapshot | null };\n}\n\nexport type SaveDocumentSnapshotArgs = {\n documentId: string;\n snapshot: unknown; // opaque to us — Univer IDocumentData decides the shape\n label?: string | null;\n origin?: DocumentSnapshotOrigin;\n};\n\nexport async function saveDocumentSnapshot(\n args: SaveDocumentSnapshotArgs,\n): Promise<ServiceResult<DocumentSnapshot>> {\n const { data: userData } = await getClaimsUser(db());\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_document_snapshots\")\n .insert({\n document_id: args.documentId,\n snapshot: args.snapshot as never,\n label: args.label ?? null,\n origin: args.origin ?? \"autosave\",\n created_by: userData?.user?.id ?? null,\n })\n .select(\"*\")\n .single();\n if (error) return { success: false, error: error.message };\n\n // Touch the parent document's updated_at so list views can sort by recency\n // without scanning snapshots. Best-effort — failure here is harmless.\n // write-lands-exempt: best-effort recency stamp on the parent document; the snapshot insert above is the real write\n await db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ updated_at: new Date().toISOString() })\n .eq(\"id\", args.documentId);\n\n return { success: true, data: data as DocumentSnapshot };\n}\n\n/**\n * An independent copy of a document: its own row, with the latest snapshot copied over, so editing the copy never\n * touches the original. The copy lives in the original's organization and project. Used by a board-template use.\n */\nexport async function copyDocument(\n documentId: string,\n name?: string,\n): Promise<ServiceResult<DocumentRow>> {\n const original = await getDocument(documentId);\n if (!original.success) return original;\n const row = original.data;\n if (!row.organization_id) {\n return { success: false, error: \"This document has no organization and cannot be copied.\" };\n }\n const created = await createDocument({\n name: name ?? row.document_name,\n description: row.description ?? null,\n organizationId: row.organization_id,\n projectId: row.project_id ?? null,\n isPublic: row.visibility === \"public\",\n });\n if (!created.success) return created;\n const latest = await getLatestDocumentSnapshot(documentId);\n if (!latest.success) return latest;\n if (latest.data) {\n const saved = await saveDocumentSnapshot({\n documentId: created.data.id,\n snapshot: latest.data.snapshot,\n label: latest.data.label,\n origin: \"autosave\",\n });\n if (!saved.success) return saved;\n }\n return created;\n}\n\n/** Trash view: the caller's own archived documents (RLS decides what is readable). */\nexport async function listTrashedDocuments(): Promise<\n ServiceResult<DocumentRow[]>\n> {\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .select(\"*\")\n .not(\"deleted_at\", \"is\", null)\n .order(\"deleted_at\", { ascending: false });\n if (error) return { success: false, error: error.message };\n return { success: true, data: (data ?? []) as DocumentRow[] };\n}\n\nexport async function listDocumentSnapshots(\n documentId: string,\n limit = 50,\n): Promise<ServiceResult<DocumentSnapshot[]>> {\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_document_snapshots\")\n // component-created-by-ok: append-only snapshot with NO updated_by column and NO parent-rewrite trigger — created_by is the author the client wrote at insert (the only person field this table has)\n .select(\"id, document_id, label, origin, created_by, created_at\")\n .eq(\"document_id\", documentId)\n .order(\"created_at\", { ascending: false })\n .limit(limit);\n if (error) return { success: false, error: error.message };\n return { success: true, data: (data ?? []) as DocumentSnapshot[] };\n}\n","/**\n * sanitizeUniverDocSnapshot — defensive normalizer for Univer document\n * snapshots loaded from storage.\n *\n * WHY THIS EXISTS (loud recovery layer):\n * Univer's `NamedStyleType` is a NUMERIC enum (`HEADING_1 = 4`, `HEADING_2 = 5`,\n * …). Some snapshots in storage were produced by an external markdown→Univer\n * converter that wrote the *string* name (`\"HEADING_1\"`) into\n * `paragraphStyle.namedStyleType` instead of the numeric value. At render time\n * Univer does `HEADING_ICON_MAP[namedStyleType]` → `undefined` →\n * `icon.key` throws `Cannot read properties of undefined (reading 'key')` inside\n * the `<ParagraphMenu>` component the moment the cursor lands in a heading. That\n * uncaught error tears down Univer's React root, so the document loads and then\n * vanishes. See `features/data-tables/FEATURE.md`.\n *\n * This normalizer converts those string enum values back to numbers BEFORE the\n * snapshot reaches `createUniverDoc`. It is a recovery layer: when it fires it\n * means malformed data slipped past the writer, so it SCREAMS (console.warn)\n * with a count and the document id. The proper long-term fix is to make the\n * writer emit numeric enum values; until then this keeps the editor alive.\n *\n * Returns the SAME object (mutated in place) for ergonomic call sites, plus a\n * `fixed` count via the second return slot is intentionally avoided — callers\n * only need the sanitized snapshot; the warning is the signal.\n */\nimport { NamedStyleType } from \"@univerjs/core\";\nimport type { IDocumentData } from \"@univerjs/core\";\n\nimport {\n defaultDocumentPageStyle,\n isLegacySqueezedPageStyle,\n} from \"../core\";\n\n/**\n * Map of every string name that could appear in a legacy snapshot to its\n * canonical numeric `NamedStyleType`. Built from the enum itself so it stays in\n * lockstep with Univer (numeric enums expose name→value on string keys).\n */\nconst NAMED_STYLE_STRING_TO_NUMBER: Record<string, number> = Object.fromEntries(\n Object.entries(NamedStyleType)\n .filter(([key, val]) => typeof val === \"number\" && isNaN(Number(key)))\n .map(([key, val]) => [key, val as number]),\n);\n\n/**\n * Normalize a Univer document snapshot in place. Currently fixes string-valued\n * `paragraphStyle.namedStyleType` (the confirmed `<ParagraphMenu>` crash). New\n * classes of string-vs-enum corruption should be added here, not patched at the\n * call site.\n *\n * @param snapshot The snapshot about to be passed to `createUniverDoc`.\n * @param docId Document id, for the loud warning only.\n * @returns the same snapshot reference (mutated).\n */\nexport function sanitizeUniverDocSnapshot(\n snapshot: Partial<IDocumentData>,\n docId?: string,\n): Partial<IDocumentData> {\n restorePageStyle(snapshot, docId);\n\n const paragraphs = snapshot?.body?.paragraphs;\n if (!Array.isArray(paragraphs)) return snapshot;\n\n let fixed = 0;\n for (const paragraph of paragraphs) {\n const style = paragraph?.paragraphStyle as\n { namedStyleType?: unknown } | undefined;\n const value = style?.namedStyleType;\n if (typeof value === \"string\") {\n const numeric = NAMED_STYLE_STRING_TO_NUMBER[value];\n if (numeric !== undefined) {\n (style as { namedStyleType?: number }).namedStyleType = numeric;\n fixed += 1;\n } else {\n // Unknown string we can't map — drop it so Univer falls back to\n // NORMAL_TEXT rather than crashing on the lookup.\n delete (style as { namedStyleType?: unknown }).namedStyleType;\n fixed += 1;\n }\n }\n }\n\n if (fixed > 0) {\n console.warn(\n `[data-tables] RECOVERY: sanitized ${fixed} string namedStyleType value(s) ` +\n `to numeric NamedStyleType in document snapshot${docId ? ` ${docId}` : \"\"}. ` +\n `The snapshot was written with the wrong enum encoding (string instead of ` +\n `number) and would have crashed Univer's <ParagraphMenu>. Fix the snapshot ` +\n `writer to emit numeric NamedStyleType values.`,\n );\n }\n\n return snapshot;\n}\n\n/**\n * Second recovery: a snapshot with no `documentStyle.pageSize` has no page box,\n * so Univer lays the body out unbounded — text never wraps and the docs\n * viewport reports no scrollable extent, which reads to the user as \"the\n * document won't scroll\". Snapshots written by agents (`origin='agent'`) and by\n * older converters reach storage with `documentStyle: {}`. Stamp the canonical\n * page geometry back on and SCREAM: the writer is the real bug.\n */\nfunction restorePageStyle(snapshot: Partial<IDocumentData>, docId?: string) {\n if (!snapshot || typeof snapshot !== \"object\") return;\n\n // THE SQUEEZED PAGE (2026-10-15): documents carried A4-at-72dpi geometry in Univer's pageless\n // flavour — a 415px text column with no paper. Move them to a real Letter page, unchanged text.\n // A document with no flavour at all is a paginated page too (Univer would otherwise pick pageless).\n const style = snapshot.documentStyle;\n if (style?.pageSize?.width && isLegacySqueezedPageStyle(style)) {\n const page = defaultDocumentPageStyle();\n snapshot.documentStyle = { ...style, ...page, defaultParagraphStyle: style.defaultParagraphStyle ?? page.defaultParagraphStyle } as typeof style;\n return;\n }\n if (style?.pageSize?.width) {\n if (!style.documentFlavor) {\n const page = defaultDocumentPageStyle();\n Object.assign(style, { documentFlavor: page.documentFlavor });\n if (page.defaultParagraphStyle) style.defaultParagraphStyle ??= page.defaultParagraphStyle;\n }\n return;\n }\n\n snapshot.documentStyle = {\n ...defaultDocumentPageStyle(),\n ...(snapshot.documentStyle ?? {}),\n pageSize: defaultDocumentPageStyle().pageSize,\n } as NonNullable<typeof snapshot.documentStyle>;\n\n console.warn(\n `[data-tables] RECOVERY: document snapshot${docId ? ` ${docId}` : \"\"} had no ` +\n `documentStyle.pageSize — restored the default Letter page geometry. Without a ` +\n `page box Univer lays the body out unbounded: text does not wrap and the ` +\n `viewport has no scrollable extent, so the document appears frozen. Fix the ` +\n `snapshot writer (agent/markdown converters must stamp ` +\n `DEFAULT_DOCUMENT_PAGE_STYLE).`,\n );\n}\n"],"mappings":";;;;;;AAsBA,IAAM,OAAO,uBAAO,IAAI,2BAA2B;AAEnD,IAAM,OAAO,MAAY;AACvB,QAAM,IAAI;AACV,SAAQ,EAAE,IAAI,MAAM,CAAC;AACvB;AAEO,SAAS,kBAAkB,OAA4B;AAC5D,OAAK,EAAE,QAAQ;AACjB;AAEO,SAAS,cAA6B;AAC3C,QAAM,QAAQ,KAAK,EAAE;AACrB,MAAI,CAAC,MAAO,OAAM,IAAI,MAAM,iGAAiG;AAC7H,SAAO;AACT;;;ACnBA,SAAS,kCAAkC;AAC3C,SAAS,qBAAqB;AAC9B,SAAS,aAAa,aAAa,mBAAmB;AAOtD,IAAM,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,MACX;AAAA,IACF;AAAA,EACF;AAEA,MAAI,QAAQ,GAAG;AACb,YAAQ;AAAA,MACN,qCAAqC,KAAK,iFACS,QAAQ,IAAI,KAAK,KAAK,EAAE;AAAA,IAI7E;AAAA,EACF;AAEA,SAAO;AACT;AAUA,SAAS,iBAAiB,UAAkC,OAAgB;AAC1E,MAAI,CAAC,YAAY,OAAO,aAAa,SAAU;AAK/C,QAAM,QAAQ,SAAS;AACvB,MAAI,OAAO,UAAU,SAAS,0BAA0B,KAAK,GAAG;AAC9D,UAAM,OAAO,yBAAyB;AACtC,aAAS,gBAAgB,EAAE,GAAG,OAAO,GAAG,MAAM,uBAAuB,MAAM,yBAAyB,KAAK,sBAAsB;AAC/H;AAAA,EACF;AACA,MAAI,OAAO,UAAU,OAAO;AAC1B,QAAI,CAAC,MAAM,gBAAgB;AACzB,YAAM,OAAO,yBAAyB;AACtC,aAAO,OAAO,OAAO,EAAE,gBAAgB,KAAK,eAAe,CAAC;AAC5D,UAAI,KAAK,sBAAuB,OAAM,0BAA0B,KAAK;AAAA,IACvE;AACA;AAAA,EACF;AAEA,WAAS,gBAAgB;AAAA,IACvB,GAAG,yBAAyB;AAAA,IAC5B,GAAI,SAAS,iBAAiB,CAAC;AAAA,IAC/B,UAAU,yBAAyB,EAAE;AAAA,EACvC;AAEA,UAAQ;AAAA,IACN,4CAA4C,QAAQ,IAAI,KAAK,KAAK,EAAE;AAAA,EAMtE;AACF;","names":["error"]}
|
|
1
|
+
{"version":3,"sources":["../src/docs/ports.ts","../src/docs/document-service.ts","../src/docs/sanitize-univer-doc-snapshot.ts"],"sourcesContent":["/**\n * The host ports of the Docs model and io.\n *\n * The package owns the document service, the open-document model and the converters, but two things\n * belong to the app that mounts them: the database client (a package owns no client) and the server\n * request that converts a .docx to .odt / .rtf (the app owns the server URL, auth and error capture).\n * The host states them once at start-up with `configureDocsHost`. State sits on a `globalThis` slot\n * so a dual-bundled copy of the package still sees one host. An unconfigured port THROWS naming\n * itself (nothing fails silently).\n */\nimport type { SupabaseClient } from \"@supabase/supabase-js\";\n\n/** A Supabase client over any schema: the package cannot import the app's generated database types. */\nexport type DocsSupabase = SupabaseClient<any, any, any>;\n\nexport interface DocsHostPorts {\n /** The app's database client (signed in as the person). */\n getSupabase(): DocsSupabase;\n /** An authenticated request to the Matrx server returning the raw `Response` (the open-format converter). */\n requestRaw(path: string, init: { method: \"POST\"; body: FormData }): Promise<Response>;\n}\n\nconst SLOT = Symbol.for(\"ai-matrx.office.docs-host\");\ntype Slot = { ports?: DocsHostPorts };\nconst slot = (): Slot => {\n const g = globalThis as Record<symbol, Slot | undefined>;\n return (g[SLOT] ??= {});\n};\n\nexport function configureDocsHost(ports: DocsHostPorts): void {\n slot().ports = ports;\n}\n\nexport function getDocsHost(): DocsHostPorts {\n const ports = slot().ports;\n if (!ports) throw new Error(\"@ai-matrx/office/docs: configureDocsHost(ports) was not called before the document service ran.\");\n return ports;\n}\n","/**\n * Document service — typed wrappers for `udt_documents` + `udt_document_snapshots`.\n *\n * Cloud document editor backed by Univer's preset-docs-core. Same shape as\n * `workbook-service.ts` — metadata in `udt_documents`, content state in\n * append-only `udt_document_snapshots`. The editor hydrates from the LATEST\n * snapshot and writes a new snapshot per save (debounced on the client —\n * see DocumentEditor).\n *\n * What lives elsewhere:\n * - Sharing / permissions: features/sharing/ + `has_permission(...)` RLS\n * - The open document (one model per id per tab: load, one save, realtime,\n * collab): features/documents/document-model/\n * - Component (a view of that model): features/documents/components/DocumentEditor\n *\n * Mirrors `workbook-service.ts`. If you're changing the shape of one, change\n * the other at the same time — see `features/data-tables/FEATURE.md`.\n */\nimport { requireOrganizationContext } from \"@ai-matrx/api\";\nimport { getClaimsUser } from \"@ai-matrx/auth\";\nimport { readAllRows, tryWriteOne, writeOneRow } from \"@ai-matrx/data/db\";\nimport type { ServiceResult } from \"@ai-matrx/records/core\";\n\nimport type { DocumentRow, DocumentSnapshot, DocumentSnapshotOrigin } from \"../core\";\nimport { getDocsHost } from \"./ports\";\n\n/** The app's database client, read through the host port at call time. */\nconst db = () => getDocsHost().getSupabase();\n// ─── documents ───────────────────────────────────────────────────────────────\n\nexport type CreateDocumentArgs = {\n name: string;\n description?: string | null;\n /** Origin label for the document itself, mirrors `udt_documents.source`. */\n source?: \"created\" | \"imported_docx\" | \"imported_md\" | \"imported_txt\" | \"linked_gdoc\";\n organizationId: string;\n projectId?: string | null;\n taskId?: string | null;\n isPublic?: boolean;\n /**\n * cld_files.id of the source upload (DOCX / MD / TXT blob). Set on the\n * import flow so the lossless original is recoverable; FK is ON DELETE SET\n * NULL, so deleting the file just nulls the link — the document survives.\n */\n originalFileId?: string | null;\n};\n\nexport async function createDocument(\n args: CreateDocumentArgs,\n): Promise<ServiceResult<DocumentRow>> {\n let organizationId: string;\n try {\n organizationId = requireOrganizationContext(undefined, args.organizationId);\n } catch (error) {\n return {\n success: false,\n error:\n error instanceof Error\n ? error.message\n : \"Select an organization before creating a document.\",\n };\n }\n\n const { data: userData, error: userErr } = await getClaimsUser(db());\n if (userErr || !userData?.user) {\n return {\n success: false,\n error: userErr?.message ?? \"not authenticated\",\n };\n }\n\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .insert({\n document_name: args.name,\n description: args.description ?? null,\n source: args.source ?? \"created\",\n organization_id: organizationId,\n project_id: args.projectId ?? null,\n task_id: args.taskId ?? null,\n original_file_id: args.originalFileId ?? null,\n // CANONICAL columns (workbench_udt_canonical_step1). `visibility` is the\n // source of truth; the legacy `is_public` boolean is derived from it by\n // the workbench._bridge_legacy_owner trigger, so writing both here would\n // be two authorities for one fact. A new document defaults to `internal`\n // — it is org work product, not an individual person's private thing\n // (db-rules §6) — unless the caller explicitly asked for public.\n created_by: userData.user.id,\n visibility: args.isPublic ? \"public\" : \"internal\",\n })\n .select(\"*\")\n .single();\n if (error) return { success: false, error: error.message };\n return { success: true, data: data as DocumentRow };\n}\n\nexport async function listAccessibleDocuments(): Promise<\n ServiceResult<DocumentRow[]>\n> {\n // RLS handles owner / published-to-the-web / shared access. The library and\n // the pickers treat this list as COMPLETE (\"you have no such document\"), so\n // it pages past PostgREST's silent 1000-row cap (D190).\n try {\n const rows = await readAllRows<DocumentRow>(\n ({ from, to }) =>\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .select(\"*\", { count: \"exact\" })\n .is(\"deleted_at\", null)\n .order(\"updated_at\", { ascending: false })\n .order(\"id\", { ascending: true })\n .range(from, to)\n .returns<DocumentRow[]>(),\n { label: \"workbench.udt_documents accessible documents\" },\n );\n return { success: true, data: rows };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n}\n\nexport async function getDocument(\n documentId: string,\n): Promise<ServiceResult<DocumentRow>> {\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .select(\"*\")\n .eq(\"id\", documentId)\n .is(\"deleted_at\", null)\n .maybeSingle();\n if (error) return { success: false, error: error.message };\n if (!data) {\n // A trashed or unreachable document is a state the person can act on,\n // never PostgREST's \"Cannot coerce the result to a single JSON object\".\n return {\n success: false,\n error:\n \"This document is in the trash or you no longer have access to it. Restore it from Trash, or ask its owner to share it again.\",\n };\n }\n return { success: true, data: data as DocumentRow };\n}\n\nexport async function renameDocument(\n documentId: string,\n name: string,\n): Promise<ServiceResult<DocumentRow>> {\n const { data, error } = await writeOneRow(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ document_name: name, updated_at: new Date().toISOString() })\n .eq(\"id\", documentId)\n .select(\"*\"),\n { action: \"update\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: data as DocumentRow };\n}\n\n/**\n * Move the document into a project (or out of one with `null`). Sibling of\n * `renameDocument`: the one named setter for `project_id`.\n */\nexport async function moveDocument(\n documentId: string,\n projectId: string | null,\n): Promise<ServiceResult<DocumentRow>> {\n const { data, error } = await writeOneRow(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ project_id: projectId, updated_at: new Date().toISOString() })\n .eq(\"id\", documentId)\n .select(\"*\"),\n { action: \"update\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: data as DocumentRow };\n}\n\n/**\n * Rewrite the document's description. Sibling of `renameDocument` — the two\n * human-authored fields on `udt_documents` each get a named setter so callers\n * never hand-roll a `.from(\"udt_documents\").update(...)`. Pass `null` (or an\n * empty string) to clear it.\n *\n * Added when the documents surface became agent-writable: the\n * `document_description` write target on `/documents/[id]` is its caller, the\n * same way `updateWorkbookDescription` serves `workbook_description`. Keeping\n * the pair symmetric is this file's standing contract with `workbook-service`\n * (see the module header).\n */\nexport async function updateDocumentDescription(\n documentId: string,\n description: string | null,\n): Promise<ServiceResult<DocumentRow>> {\n const { data, error } = await writeOneRow(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({\n description: description && description.length > 0 ? description : null,\n updated_at: new Date().toISOString(),\n })\n .eq(\"id\", documentId)\n .select(\"*\"),\n { action: \"update\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: data as DocumentRow };\n}\n\n/**\n * Soft delete — the document is tombstoned, not destroyed, and its snapshots stay\n * with it. Every read path filters `deleted_at is null`. Pair with\n * restoreDocument for undo. (aidream migration 0458.)\n */\nexport async function restoreDocument(\n documentId: string,\n): Promise<ServiceResult<true>> {\n const { error } = await tryWriteOne(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ deleted_at: null })\n .eq(\"id\", documentId)\n .select(\"id\"),\n { action: \"restore\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: true };\n}\n\n/**\n * Archive (delete means archive: never a hard delete) — only for rolling back a document this very flow just created and\n * failed to populate. Never use for a user-initiated delete: that is\n * deleteDocument, which tombstones and stays recoverable.\n */\nexport async function discardFailedDocument(\n documentId: string,\n): Promise<ServiceResult<true>> {\n const { error } = await tryWriteOne(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ deleted_at: new Date().toISOString() })\n .eq(\"id\", documentId)\n .select(\"id\"),\n { action: \"archive\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: true };\n}\n\nexport async function deleteDocument(\n documentId: string,\n): Promise<ServiceResult<true>> {\n const { error } = await tryWriteOne(\n db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ deleted_at: new Date().toISOString() })\n .eq(\"id\", documentId)\n .select(\"id\"),\n { action: \"delete\", noun: \"document\" },\n );\n if (error) return { success: false, error: error.message };\n return { success: true, data: true };\n}\n\n// ─── snapshots (document content) ────────────────────────────────────────────\n\n/**\n * Latest-snapshot fetch — what an opened document hydrates from. Returns\n * `data: null` (success path) when the document has no snapshots yet (newly\n * created, never saved). Distinguish \"no snapshot\" from \"load error\" by\n * checking `result.data === null`.\n */\nexport async function getLatestDocumentSnapshot(\n documentId: string,\n): Promise<ServiceResult<DocumentSnapshot | null>> {\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_document_snapshots\")\n .select(\"*\")\n .eq(\"document_id\", documentId)\n .order(\"created_at\", { ascending: false })\n .limit(1)\n .maybeSingle();\n if (error) return { success: false, error: error.message };\n return { success: true, data: (data ?? null) as DocumentSnapshot | null };\n}\n\nexport type SaveDocumentSnapshotArgs = {\n documentId: string;\n snapshot: unknown; // opaque to us — Univer IDocumentData decides the shape\n label?: string | null;\n origin?: DocumentSnapshotOrigin;\n};\n\nexport async function saveDocumentSnapshot(\n args: SaveDocumentSnapshotArgs,\n): Promise<ServiceResult<DocumentSnapshot>> {\n const { data: userData } = await getClaimsUser(db());\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_document_snapshots\")\n .insert({\n document_id: args.documentId,\n snapshot: args.snapshot as never,\n label: args.label ?? null,\n origin: args.origin ?? \"autosave\",\n created_by: userData?.user?.id ?? null,\n })\n .select(\"*\")\n .single();\n if (error) return { success: false, error: error.message };\n\n // Touch the parent document's updated_at so list views can sort by recency\n // without scanning snapshots. Best-effort — failure here is harmless.\n // write-lands-exempt: best-effort recency stamp on the parent document; the snapshot insert above is the real write\n await db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .update({ updated_at: new Date().toISOString() })\n .eq(\"id\", args.documentId);\n\n return { success: true, data: data as DocumentSnapshot };\n}\n\n/**\n * An independent copy of a document: its own row, with the latest snapshot copied over, so editing the copy never\n * touches the original. The copy lives in the original's organization and project. Used by a board-template use.\n */\nexport async function copyDocument(\n documentId: string,\n name?: string,\n): Promise<ServiceResult<DocumentRow>> {\n const original = await getDocument(documentId);\n if (!original.success) return original;\n const row = original.data;\n if (!row.organization_id) {\n return { success: false, error: \"This document has no organization and cannot be copied.\" };\n }\n const created = await createDocument({\n name: name ?? row.document_name,\n description: row.description ?? null,\n organizationId: row.organization_id,\n projectId: row.project_id ?? null,\n isPublic: row.visibility === \"public\",\n });\n if (!created.success) return created;\n const latest = await getLatestDocumentSnapshot(documentId);\n if (!latest.success) return latest;\n if (latest.data) {\n const saved = await saveDocumentSnapshot({\n documentId: created.data.id,\n snapshot: latest.data.snapshot,\n label: latest.data.label,\n origin: \"autosave\",\n });\n if (!saved.success) return saved;\n }\n return created;\n}\n\n/** Trash view: the caller's own archived documents (RLS decides what is readable). */\nexport async function listTrashedDocuments(): Promise<\n ServiceResult<DocumentRow[]>\n> {\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_documents\")\n .select(\"*\")\n .not(\"deleted_at\", \"is\", null)\n .order(\"deleted_at\", { ascending: false });\n if (error) return { success: false, error: error.message };\n return { success: true, data: (data ?? []) as DocumentRow[] };\n}\n\nexport async function listDocumentSnapshots(\n documentId: string,\n limit = 50,\n): Promise<ServiceResult<DocumentSnapshot[]>> {\n const { data, error } = await db()\n .schema(\"workbench\")\n .from(\"udt_document_snapshots\")\n // component-created-by-ok: append-only snapshot with NO updated_by column and NO parent-rewrite trigger — created_by is the author the client wrote at insert (the only person field this table has)\n .select(\"id, document_id, label, origin, created_by, created_at\")\n .eq(\"document_id\", documentId)\n .order(\"created_at\", { ascending: false })\n .limit(limit);\n if (error) return { success: false, error: error.message };\n return { success: true, data: (data ?? []) as DocumentSnapshot[] };\n}\n","/**\n * sanitizeUniverDocSnapshot — defensive normalizer for Univer document\n * snapshots loaded from storage.\n *\n * WHY THIS EXISTS (loud recovery layer):\n * Univer's `NamedStyleType` is a NUMERIC enum (`HEADING_1 = 4`, `HEADING_2 = 5`,\n * …). Some snapshots in storage were produced by an external markdown→Univer\n * converter that wrote the *string* name (`\"HEADING_1\"`) into\n * `paragraphStyle.namedStyleType` instead of the numeric value. At render time\n * Univer does `HEADING_ICON_MAP[namedStyleType]` → `undefined` →\n * `icon.key` throws `Cannot read properties of undefined (reading 'key')` inside\n * the `<ParagraphMenu>` component the moment the cursor lands in a heading. That\n * uncaught error tears down Univer's React root, so the document loads and then\n * vanishes. See `features/data-tables/FEATURE.md`.\n *\n * This normalizer converts those string enum values back to numbers BEFORE the\n * snapshot reaches `createUniverDoc`. It is a recovery layer: when it fires it\n * means malformed data slipped past the writer, so it SCREAMS (console.warn)\n * with a count and the document id. The proper long-term fix is to make the\n * writer emit numeric enum values; until then this keeps the editor alive.\n *\n * Returns the SAME object (mutated in place) for ergonomic call sites, plus a\n * `fixed` count via the second return slot is intentionally avoided — callers\n * only need the sanitized snapshot; the warning is the signal.\n */\nimport { NamedStyleType } from \"@univerjs/core\";\nimport type { IDocumentData } from \"@univerjs/core\";\n\nimport {\n defaultDocumentPageStyle,\n isLegacySqueezedPageStyle,\n} from \"../core\";\n\n/**\n * Map of every string name that could appear in a legacy snapshot to its\n * canonical numeric `NamedStyleType`. Built from the enum itself so it stays in\n * lockstep with Univer (numeric enums expose name→value on string keys).\n */\nconst NAMED_STYLE_STRING_TO_NUMBER: Record<string, number> = Object.fromEntries(\n Object.entries(NamedStyleType)\n .filter(([key, val]) => typeof val === \"number\" && isNaN(Number(key)))\n .map(([key, val]) => [key, val as number]),\n);\n\n/**\n * Normalize a Univer document snapshot in place. Currently fixes string-valued\n * `paragraphStyle.namedStyleType` (the confirmed `<ParagraphMenu>` crash). New\n * classes of string-vs-enum corruption should be added here, not patched at the\n * call site.\n *\n * @param snapshot The snapshot about to be passed to `createUniverDoc`.\n * @param docId Document id, for the loud warning only.\n * @returns the same snapshot reference (mutated).\n */\nexport function sanitizeUniverDocSnapshot(\n snapshot: Partial<IDocumentData>,\n docId?: string,\n): Partial<IDocumentData> {\n restorePageStyle(snapshot, docId);\n ensureTextRuns(snapshot);\n\n const paragraphs = snapshot?.body?.paragraphs;\n if (!Array.isArray(paragraphs)) return snapshot;\n\n let fixed = 0;\n for (const paragraph of paragraphs) {\n const style = paragraph?.paragraphStyle as\n { namedStyleType?: unknown } | undefined;\n const value = style?.namedStyleType;\n if (typeof value === \"string\") {\n const numeric = NAMED_STYLE_STRING_TO_NUMBER[value];\n if (numeric !== undefined) {\n (style as { namedStyleType?: number }).namedStyleType = numeric;\n fixed += 1;\n } else {\n // Unknown string we can't map — drop it so Univer falls back to\n // NORMAL_TEXT rather than crashing on the lookup.\n delete (style as { namedStyleType?: unknown }).namedStyleType;\n fixed += 1;\n }\n }\n }\n\n if (fixed > 0) {\n console.warn(\n `[data-tables] RECOVERY: sanitized ${fixed} string namedStyleType value(s) ` +\n `to numeric NamedStyleType in document snapshot${docId ? ` ${docId}` : \"\"}. ` +\n `The snapshot was written with the wrong enum encoding (string instead of ` +\n `number) and would have crashed Univer's <ParagraphMenu>. Fix the snapshot ` +\n `writer to emit numeric NamedStyleType values.`,\n );\n }\n\n return snapshot;\n}\n\n/**\n * Second recovery: a snapshot with no `documentStyle.pageSize` has no page box,\n * so Univer lays the body out unbounded — text never wraps and the docs\n * viewport reports no scrollable extent, which reads to the user as \"the\n * document won't scroll\". Snapshots written by agents (`origin='agent'`) and by\n * older converters reach storage with `documentStyle: {}`. Stamp the canonical\n * page geometry back on and SCREAM: the writer is the real bug.\n */\nfunction restorePageStyle(snapshot: Partial<IDocumentData>, docId?: string) {\n if (!snapshot || typeof snapshot !== \"object\") return;\n\n // THE SQUEEZED PAGE (2026-10-15): documents carried A4-at-72dpi geometry in Univer's pageless\n // flavour — a 415px text column with no paper. Move them to a real Letter page, unchanged text.\n // A document with no flavour at all is a paginated page too (Univer would otherwise pick pageless).\n const style = snapshot.documentStyle;\n if (style?.pageSize?.width && isLegacySqueezedPageStyle(style)) {\n const page = defaultDocumentPageStyle();\n snapshot.documentStyle = { ...style, ...page, defaultParagraphStyle: style.defaultParagraphStyle ?? page.defaultParagraphStyle } as typeof style;\n return;\n }\n if (style?.pageSize?.width) {\n if (!style.documentFlavor) {\n const page = defaultDocumentPageStyle();\n Object.assign(style, { documentFlavor: page.documentFlavor });\n if (page.defaultParagraphStyle) style.defaultParagraphStyle ??= page.defaultParagraphStyle;\n }\n return;\n }\n\n snapshot.documentStyle = {\n ...defaultDocumentPageStyle(),\n ...(snapshot.documentStyle ?? {}),\n pageSize: defaultDocumentPageStyle().pageSize,\n } as NonNullable<typeof snapshot.documentStyle>;\n\n console.warn(\n `[data-tables] RECOVERY: document snapshot${docId ? ` ${docId}` : \"\"} had no ` +\n `documentStyle.pageSize — restored the default Letter page geometry. Without a ` +\n `page box Univer lays the body out unbounded: text does not wrap and the ` +\n `viewport has no scrollable extent, so the document appears frozen. Fix the ` +\n `snapshot writer (agent/markdown converters must stamp ` +\n `DEFAULT_DOCUMENT_PAGE_STYLE).`,\n );\n}\n\n/**\n * A body with no `textRuns` array is a body Univer silently refuses styled text for: its text\n * insert (`insertTextRuns`) returns early when the target has none, so every bold, italic, code\n * and size run of pasted or agent-written markdown vanished (found 2026-10-16: `**notes**` pasted\n * into a blank document stayed plain). An empty array is the same document and accepts the runs.\n */\nfunction ensureTextRuns(snapshot: Partial<IDocumentData>) {\n const body = snapshot?.body;\n if (body && typeof body === \"object\" && !Array.isArray(body.textRuns)) body.textRuns = [];\n}\n"],"mappings":";;;;;;AAsBA,IAAM,OAAO,uBAAO,IAAI,2BAA2B;AAEnD,IAAM,OAAO,MAAY;AACvB,QAAM,IA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AAQA,SAAS,eAAe,UAAkC;AACxD,QAAM,OAAO,UAAU;AACvB,MAAI,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,KAAK,QAAQ,EAAG,MAAK,WAAW,CAAC;AAC1F;","names":["error"]}
|
package/dist/docs-io.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk556EUPETcjs = require('./chunk-556EUPET.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -419,13 +419,13 @@ async function documentFileToMarkdown(file) {
|
|
|
419
419
|
async function importDocumentFile(file, organizationId) {
|
|
420
420
|
const { markdown, source } = await documentFileToMarkdown(file);
|
|
421
421
|
const name = file.name.replace(/\.[^.]+$/, "").trim() || _chunkUBLEFLEScjs.deriveDocumentName.call(void 0, markdown);
|
|
422
|
-
const created = await
|
|
422
|
+
const created = await _chunk556EUPETcjs.createDocument.call(void 0, { name, source, organizationId, description: `Imported from ${file.name}` });
|
|
423
423
|
if (!created.success) throw new Error(`Could not create the document: ${created.error}`);
|
|
424
424
|
const id = created.data.id;
|
|
425
|
-
const snapshot =
|
|
426
|
-
const saved = await
|
|
425
|
+
const snapshot = _chunk556EUPETcjs.sanitizeUniverDocSnapshot.call(void 0, _chunkUBLEFLEScjs.markdownToUniverDoc.call(void 0, markdown, name), id);
|
|
426
|
+
const saved = await _chunk556EUPETcjs.saveDocumentSnapshot.call(void 0, { documentId: id, snapshot, origin: "imported", label: `Imported from ${file.name}` });
|
|
427
427
|
if (!saved.success) {
|
|
428
|
-
await
|
|
428
|
+
await _chunk556EUPETcjs.deleteDocument.call(void 0, id);
|
|
429
429
|
throw new Error(`Could not save the imported content: ${saved.error}`);
|
|
430
430
|
}
|
|
431
431
|
return { id, name };
|
|
@@ -467,7 +467,7 @@ async function downloadOpenFormat(markdown, format, title) {
|
|
|
467
467
|
const form = new FormData();
|
|
468
468
|
form.append("file", new Blob([docx]), fileName.endsWith(".docx") ? fileName : `${fileName}.docx`);
|
|
469
469
|
form.append("target", target);
|
|
470
|
-
const res = await
|
|
470
|
+
const res = await _chunk556EUPETcjs.getDocsHost.call(void 0, ).requestRaw("/office/convert-document", { method: "POST", body: form });
|
|
471
471
|
return new Uint8Array(await res.arrayBuffer());
|
|
472
472
|
},
|
|
473
473
|
save: (fileName, bytes, mime) => {
|
package/dist/docs-io.js
CHANGED
package/dist/docs.cjs
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunk556EUPETcjs = require('./chunk-556EUPET.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
var _chunkMQB2ZK2Fcjs = require('./chunk-MQB2ZK2F.cjs');
|
|
@@ -860,5 +860,5 @@ function documentBodyWriteHandler(deps) {
|
|
|
860
860
|
|
|
861
861
|
|
|
862
862
|
|
|
863
|
-
exports.DOCUMENT_BODY_MAX_LENGTH = DOCUMENT_BODY_MAX_LENGTH; exports.DOCUMENT_DESCRIPTION_MAX_LENGTH = DOCUMENT_DESCRIPTION_MAX_LENGTH; exports.DOCUMENT_NAME_MAX_LENGTH = DOCUMENT_NAME_MAX_LENGTH; exports.DOCUMENT_SAVE_DELAY_MS = DOCUMENT_SAVE_DELAY_MS; exports.DocumentModel = DocumentModel; exports.EMOJI_GROUPS = EMOJI_GROUPS; exports.MIN_FIT_ZOOM = MIN_FIT_ZOOM; exports.SPECIAL_GROUPS = SPECIAL_GROUPS; exports.bodyTextOf = bodyTextOf; exports.configureDocsHost =
|
|
863
|
+
exports.DOCUMENT_BODY_MAX_LENGTH = DOCUMENT_BODY_MAX_LENGTH; exports.DOCUMENT_DESCRIPTION_MAX_LENGTH = DOCUMENT_DESCRIPTION_MAX_LENGTH; exports.DOCUMENT_NAME_MAX_LENGTH = DOCUMENT_NAME_MAX_LENGTH; exports.DOCUMENT_SAVE_DELAY_MS = DOCUMENT_SAVE_DELAY_MS; exports.DocumentModel = DocumentModel; exports.EMOJI_GROUPS = EMOJI_GROUPS; exports.MIN_FIT_ZOOM = MIN_FIT_ZOOM; exports.SPECIAL_GROUPS = SPECIAL_GROUPS; exports.bodyTextOf = bodyTextOf; exports.configureDocsHost = _chunk556EUPETcjs.configureDocsHost; exports.copyDocument = _chunk556EUPETcjs.copyDocument; exports.createDocument = _chunk556EUPETcjs.createDocument; exports.deleteDocument = _chunk556EUPETcjs.deleteDocument; exports.discardFailedDocument = _chunk556EUPETcjs.discardFailedDocument; exports.documentBodyWriteHandler = documentBodyWriteHandler; exports.documentSourceLabel = documentSourceLabel; exports.fitZoomRatio = fitZoomRatio; exports.getDocsHost = _chunk556EUPETcjs.getDocsHost; exports.getDocument = _chunk556EUPETcjs.getDocument; exports.getLatestDocumentSnapshot = _chunk556EUPETcjs.getLatestDocumentSnapshot; exports.listAccessibleDocuments = _chunk556EUPETcjs.listAccessibleDocuments; exports.listDocumentSnapshots = _chunk556EUPETcjs.listDocumentSnapshots; exports.listTrashedDocuments = _chunk556EUPETcjs.listTrashedDocuments; exports.moveDocument = _chunk556EUPETcjs.moveDocument; exports.planBodyEdit = planBodyEdit; exports.renameDocument = _chunk556EUPETcjs.renameDocument; exports.restoreDocument = _chunk556EUPETcjs.restoreDocument; exports.sanitizeUniverDocSnapshot = _chunk556EUPETcjs.sanitizeUniverDocSnapshot; exports.saveDocumentSnapshot = _chunk556EUPETcjs.saveDocumentSnapshot; exports.searchSymbols = searchSymbols; exports.updateDocumentDescription = _chunk556EUPETcjs.updateDocumentDescription; exports.validateDocumentBody = validateDocumentBody; exports.validateDocumentDescription = validateDocumentDescription; exports.validateDocumentName = validateDocumentName; exports.writeBodyText = writeBodyText;
|
|
864
864
|
//# sourceMappingURL=docs.cjs.map
|
package/dist/docs.js
CHANGED
package/dist/sheets.cjs
CHANGED
|
@@ -744,7 +744,7 @@ function printDocumentHtml(doc, title) {
|
|
|
744
744
|
// src/sheets/sheet-output.ts
|
|
745
745
|
var _download = require('@ai-matrx/kit/download');
|
|
746
746
|
var _read = require('@ai-matrx/alchemy/operate/read');
|
|
747
|
-
function
|
|
747
|
+
function sheetGridToCsv(rows) {
|
|
748
748
|
const [header, ...body] = rows;
|
|
749
749
|
if (!header) return "";
|
|
750
750
|
return _read.toDelimitedText.call(void 0, header, body, { spreadsheetSafe: false });
|
|
@@ -753,7 +753,7 @@ function downloadSheetAsCsv(snapshot, options) {
|
|
|
753
753
|
const grid = univerSnapshotToRows(snapshot, { skipHidden: true, ...options.sheetId ? { sheetId: options.sheetId } : {} });
|
|
754
754
|
if (!grid || grid.rows.length === 0) return false;
|
|
755
755
|
const name = `${options.filename.replace(/\.csv$/i, "")}.csv`;
|
|
756
|
-
const blob = new Blob(["\uFEFF",
|
|
756
|
+
const blob = new Blob(["\uFEFF", sheetGridToCsv(grid.rows)], { type: "text/csv;charset=utf-8" });
|
|
757
757
|
_download.downloadFile.call(void 0, name, blob, blob.type);
|
|
758
758
|
return true;
|
|
759
759
|
}
|
|
@@ -810,7 +810,7 @@ function printSheet(snapshot, options) {
|
|
|
810
810
|
win.print();
|
|
811
811
|
return true;
|
|
812
812
|
}
|
|
813
|
-
function
|
|
813
|
+
function sheetGridToMarkdownTable(rows) {
|
|
814
814
|
if (rows.length === 0) return "";
|
|
815
815
|
const width = Math.max(...rows.map((r) => r.length));
|
|
816
816
|
const cell = (v) => (_nullishCoalesce(v, () => ( ""))).replace(/\|/g, "\\|").replace(/\r?\n/g, " ");
|
|
@@ -917,5 +917,5 @@ function readWorkbookScopeSource(workbookId) {
|
|
|
917
917
|
|
|
918
918
|
|
|
919
919
|
|
|
920
|
-
exports.DEFAULT_SHEET_PAGE_SETUP = DEFAULT_SHEET_PAGE_SETUP; exports.GRID_MAX_COLUMNS = GRID_MAX_COLUMNS; exports.GRID_MAX_ROWS = GRID_MAX_ROWS; exports.MARGIN_PRESET_INCHES = MARGIN_PRESET_INCHES; exports.PRINT_ROW_HEIGHT = PRINT_ROW_HEIGHT; exports.SHEET_MARGIN_PRESETS = SHEET_MARGIN_PRESETS; exports.SHEET_PRINT_SCOPES = SHEET_PRINT_SCOPES; exports.SHEET_SCALES = SHEET_SCALES; exports.THUMB_HEIGHT = THUMB_HEIGHT; exports.THUMB_WIDTH = THUMB_WIDTH; exports.buildPrintDocument = buildPrintDocument; exports.cfMatch = cfMatch; exports.collectPrintSheets = collectPrintSheets; exports.configureSheetsHost = _chunkZDZCCOUBcjs.configureSheetsHost; exports.copyWorkbook = _chunkZDZCCOUBcjs.copyWorkbook; exports.createWorkbook = _chunkZDZCCOUBcjs.createWorkbook; exports.deleteWorkbook = _chunkZDZCCOUBcjs.deleteWorkbook; exports.discardFailedWorkbook = _chunkZDZCCOUBcjs.discardFailedWorkbook; exports.documentPreviewSvg = documentPreviewSvg; exports.downloadSheetAsCsv = downloadSheetAsCsv; exports.downloadSheetAsHtml = downloadSheetAsHtml; exports.downloadSheetAsPdf = downloadSheetAsPdf; exports.downloadSheetAsTsv = downloadSheetAsTsv; exports.formatCellValue = formatCellValue; exports.getLatestSnapshot = _chunkZDZCCOUBcjs.getLatestSnapshot; exports.getSheetsHost = _chunkZDZCCOUBcjs.getSheetsHost; exports.getWorkbook = _chunkZDZCCOUBcjs.getWorkbook; exports.listAccessibleWorkbooks = _chunkZDZCCOUBcjs.listAccessibleWorkbooks; exports.listSnapshots = _chunkZDZCCOUBcjs.listSnapshots; exports.listTrashedWorkbooks = _chunkZDZCCOUBcjs.listTrashedWorkbooks; exports.moveWorkbook = _chunkZDZCCOUBcjs.moveWorkbook; exports.normalizeSheetPageSetup = normalizeSheetPageSetup; exports.pageSetupFromMetadata = pageSetupFromMetadata; exports.parseResource = parseResource; exports.planSheetPrint = planSheetPrint; exports.printColumnWidths = printColumnWidths; exports.printDocumentHtml = printDocumentHtml; exports.printGeometry = printGeometry; exports.printSheet = printSheet; exports.readSheetPageSetup = readSheetPageSetup; exports.readWorkbookScopeSource = readWorkbookScopeSource; exports.registerWorkbookScopeSource = registerWorkbookScopeSource; exports.renameWorkbook = _chunkZDZCCOUBcjs.renameWorkbook; exports.restoreWorkbook = _chunkZDZCCOUBcjs.restoreWorkbook; exports.
|
|
920
|
+
exports.DEFAULT_SHEET_PAGE_SETUP = DEFAULT_SHEET_PAGE_SETUP; exports.GRID_MAX_COLUMNS = GRID_MAX_COLUMNS; exports.GRID_MAX_ROWS = GRID_MAX_ROWS; exports.MARGIN_PRESET_INCHES = MARGIN_PRESET_INCHES; exports.PRINT_ROW_HEIGHT = PRINT_ROW_HEIGHT; exports.SHEET_MARGIN_PRESETS = SHEET_MARGIN_PRESETS; exports.SHEET_PRINT_SCOPES = SHEET_PRINT_SCOPES; exports.SHEET_SCALES = SHEET_SCALES; exports.THUMB_HEIGHT = THUMB_HEIGHT; exports.THUMB_WIDTH = THUMB_WIDTH; exports.buildPrintDocument = buildPrintDocument; exports.cfMatch = cfMatch; exports.collectPrintSheets = collectPrintSheets; exports.configureSheetsHost = _chunkZDZCCOUBcjs.configureSheetsHost; exports.copyWorkbook = _chunkZDZCCOUBcjs.copyWorkbook; exports.createWorkbook = _chunkZDZCCOUBcjs.createWorkbook; exports.deleteWorkbook = _chunkZDZCCOUBcjs.deleteWorkbook; exports.discardFailedWorkbook = _chunkZDZCCOUBcjs.discardFailedWorkbook; exports.documentPreviewSvg = documentPreviewSvg; exports.downloadSheetAsCsv = downloadSheetAsCsv; exports.downloadSheetAsHtml = downloadSheetAsHtml; exports.downloadSheetAsPdf = downloadSheetAsPdf; exports.downloadSheetAsTsv = downloadSheetAsTsv; exports.formatCellValue = formatCellValue; exports.getLatestSnapshot = _chunkZDZCCOUBcjs.getLatestSnapshot; exports.getSheetsHost = _chunkZDZCCOUBcjs.getSheetsHost; exports.getWorkbook = _chunkZDZCCOUBcjs.getWorkbook; exports.listAccessibleWorkbooks = _chunkZDZCCOUBcjs.listAccessibleWorkbooks; exports.listSnapshots = _chunkZDZCCOUBcjs.listSnapshots; exports.listTrashedWorkbooks = _chunkZDZCCOUBcjs.listTrashedWorkbooks; exports.moveWorkbook = _chunkZDZCCOUBcjs.moveWorkbook; exports.normalizeSheetPageSetup = normalizeSheetPageSetup; exports.pageSetupFromMetadata = pageSetupFromMetadata; exports.parseResource = parseResource; exports.planSheetPrint = planSheetPrint; exports.printColumnWidths = printColumnWidths; exports.printDocumentHtml = printDocumentHtml; exports.printGeometry = printGeometry; exports.printSheet = printSheet; exports.readSheetPageSetup = readSheetPageSetup; exports.readWorkbookScopeSource = readWorkbookScopeSource; exports.registerWorkbookScopeSource = registerWorkbookScopeSource; exports.renameWorkbook = _chunkZDZCCOUBcjs.renameWorkbook; exports.restoreWorkbook = _chunkZDZCCOUBcjs.restoreWorkbook; exports.saveSnapshot = _chunkZDZCCOUBcjs.saveSnapshot; exports.sheetGridToCsv = sheetGridToCsv; exports.sheetGridToMarkdownTable = sheetGridToMarkdownTable; exports.snapshotPreviewSvg = snapshotPreviewSvg; exports.snapshotToGridSheets = snapshotToGridSheets; exports.univerSheetIds = univerSheetIds; exports.univerSnapshotToRows = univerSnapshotToRows; exports.updateWorkbookDescription = _chunkZDZCCOUBcjs.updateWorkbookDescription; exports.workbookPreviewSvg = workbookPreviewSvg; exports.workbookSourceLabel = _chunkZDZCCOUBcjs.workbookSourceLabel; exports.writeSheetPageSetup = writeSheetPageSetup;
|
|
921
921
|
//# sourceMappingURL=sheets.cjs.map
|