feat: 收口文档桥接与 OnlyOffice/Sidebar 回归

- 为 documents.save/meta/content、blocks.patch 与 sidebar.dataset.list 补齐 Rust 协议映射、共享契约与桥接执行器

- 对齐 BlockNote、Mindmap、OnlyOffice 的保存/路由元信息,并补真实浏览器回归脚本与 OnlyOffice 部署基线

- 忽略 Rust 本地构建产物与 Harness 调试状态文件,避免临时产物进入仓库历史
This commit is contained in:
lix-2026
2026-04-15 03:06:29 +08:00
parent 84a8454fa9
commit b33ffb99e7
51 changed files with 3260 additions and 379 deletions
+119 -1
View File
@@ -2,7 +2,13 @@ import { describe, expect, it } from "vitest";
import type { DocumentRecord } from "@/lib/documents";
import type { WorkspaceSummary } from "@/lib/workspaces";
import type { SidebarInitialData } from "@/components/sidebar/types";
import { buildSidebarInitialData, extractMindmapImageAssetIdsFromData } from "@/lib/sidebar-data";
import {
buildSidebarDatasetListQueryPayload,
buildSidebarDatasetListQueryResult,
buildSidebarInitialData,
extractMindmapImageAssetIdsFromData,
mapSidebarDatasetListQueryResultToInitialData,
} from "@/lib/sidebar-data";
describe("extractMindmapImageAssetIdsFromData", () => {
it("提取导图节点里的 asset 图片引用并去重", () => {
@@ -140,4 +146,116 @@ describe("buildSidebarInitialData", () => {
expect(payload.trashedTableAssets?.map((item) => item.id)).toEqual(["table_2"]);
expect(payload.mediaAssets?.map((item) => item.id)).toEqual(["asset_file_1"]);
});
it("冻结 sidebar.dataset.list 的 Rust query 契约字段", () => {
const queryPayload = buildSidebarDatasetListQueryPayload(" ws_1 ");
expect(queryPayload).toEqual({ workspace_id: "ws_1" });
const queryResult = buildSidebarDatasetListQueryResult({
activeWorkspaceId: "ws_1",
workspaces: [
{
id: "ws_1",
name: "工作区",
type: "personal",
iconUrl: null,
memberCount: 1,
isDefault: true,
},
],
documents: [
{
id: "doc_1",
workspace_id: "ws_1",
title: "页面 1",
parent_id: null,
sort_order: 1,
is_starred: false,
access_scope: "private",
is_template: false,
created_at: "2026-04-14T00:00:00Z",
updated_at: null,
},
],
trashedDocuments: [],
mindmaps: [],
mediaAssets: [],
trashedMediaAssets: [],
tables: [],
});
expect(queryResult).toEqual({
active_workspace_id: "ws_1",
workspaces: [
{
id: "ws_1",
name: "工作区",
type: "personal",
iconUrl: null,
memberCount: 1,
isDefault: true,
},
],
documents: [
{
id: "doc_1",
workspace_id: "ws_1",
title: "页面 1",
parent_id: null,
sort_order: 1,
is_starred: false,
access_scope: "private",
is_template: false,
created_at: "2026-04-14T00:00:00Z",
updated_at: null,
},
],
trashed_documents: [],
media_assets: [],
trashed_media_assets: [],
mindmap_assets: [],
trashed_mindmap_assets: [],
table_assets: [],
trashed_table_assets: [],
mindmap_docs: [],
mindmap_asset_children: {},
});
expect(mapSidebarDatasetListQueryResultToInitialData(queryResult)).toEqual({
activeWorkspaceId: "ws_1",
workspaces: [
{
id: "ws_1",
name: "工作区",
type: "personal",
iconUrl: null,
memberCount: 1,
isDefault: true,
},
],
documents: [
{
id: "doc_1",
workspace_id: "ws_1",
title: "页面 1",
parent_id: null,
sort_order: 1,
is_starred: false,
access_scope: "private",
is_template: false,
created_at: "2026-04-14T00:00:00Z",
updated_at: null,
},
],
trashedDocuments: [],
trashedMediaAssets: [],
trashedMindmapAssets: [],
trashedTableAssets: [],
mindmapDocs: [],
mindmapAssets: [],
mindmapAssetChildren: {},
tableAssets: [],
mediaAssets: [],
});
});
});