fantsec-docmost-cli 2.2.0
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/LICENSE +21 -0
- package/README.md +137 -0
- package/build/__tests__/cli-utils.test.js +287 -0
- package/build/__tests__/client-pagination.test.js +103 -0
- package/build/__tests__/discovery.test.js +40 -0
- package/build/__tests__/envelope.test.js +91 -0
- package/build/__tests__/filters.test.js +235 -0
- package/build/__tests__/integration/comment.test.js +48 -0
- package/build/__tests__/integration/discovery.test.js +24 -0
- package/build/__tests__/integration/file.test.js +33 -0
- package/build/__tests__/integration/group.test.js +48 -0
- package/build/__tests__/integration/helpers/global-setup.js +80 -0
- package/build/__tests__/integration/helpers/run-cli.js +163 -0
- package/build/__tests__/integration/invite.test.js +34 -0
- package/build/__tests__/integration/page.test.js +69 -0
- package/build/__tests__/integration/search.test.js +45 -0
- package/build/__tests__/integration/share.test.js +49 -0
- package/build/__tests__/integration/space.test.js +56 -0
- package/build/__tests__/integration/user.test.js +15 -0
- package/build/__tests__/integration/workspace.test.js +42 -0
- package/build/__tests__/markdown-converter.test.js +445 -0
- package/build/__tests__/mcp-tooling.test.js +58 -0
- package/build/__tests__/page-mentions.test.js +65 -0
- package/build/__tests__/tiptap-extensions.test.js +135 -0
- package/build/client.js +715 -0
- package/build/commands/comment.js +54 -0
- package/build/commands/discovery.js +21 -0
- package/build/commands/file.js +36 -0
- package/build/commands/group.js +91 -0
- package/build/commands/invite.js +67 -0
- package/build/commands/page.js +227 -0
- package/build/commands/search.js +33 -0
- package/build/commands/share.js +65 -0
- package/build/commands/space.js +154 -0
- package/build/commands/user.js +38 -0
- package/build/commands/workspace.js +77 -0
- package/build/index.js +19 -0
- package/build/lib/auth-utils.js +53 -0
- package/build/lib/cli-utils.js +293 -0
- package/build/lib/collaboration.js +126 -0
- package/build/lib/filters.js +137 -0
- package/build/lib/markdown-converter.js +187 -0
- package/build/lib/mcp-tooling.js +295 -0
- package/build/lib/page-mentions.js +162 -0
- package/build/lib/tiptap-extensions.js +86 -0
- package/build/mcp.js +186 -0
- package/build/program.js +60 -0
- package/package.json +64 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { generateJSON } from "@tiptap/html";
|
|
3
|
+
import { tiptapExtensions } from "../lib/tiptap-extensions.js";
|
|
4
|
+
const parse = (html) => generateJSON(html, tiptapExtensions);
|
|
5
|
+
describe("tiptapExtensions with generateJSON", () => {
|
|
6
|
+
it("parses basic paragraph", () => {
|
|
7
|
+
const doc = parse("<p>hello world</p>");
|
|
8
|
+
expect(doc.type).toBe("doc");
|
|
9
|
+
expect(doc.content).toHaveLength(1);
|
|
10
|
+
expect(doc.content[0].type).toBe("paragraph");
|
|
11
|
+
expect(doc.content[0].content[0].text).toBe("hello world");
|
|
12
|
+
});
|
|
13
|
+
it("parses h1 heading", () => {
|
|
14
|
+
const doc = parse("<h1>Title</h1>");
|
|
15
|
+
const heading = doc.content[0];
|
|
16
|
+
expect(heading.type).toBe("heading");
|
|
17
|
+
expect(heading.attrs.level).toBe(1);
|
|
18
|
+
expect(heading.content[0].text).toBe("Title");
|
|
19
|
+
});
|
|
20
|
+
it("parses h2 heading", () => {
|
|
21
|
+
const doc = parse("<h2>Subtitle</h2>");
|
|
22
|
+
const heading = doc.content[0];
|
|
23
|
+
expect(heading.type).toBe("heading");
|
|
24
|
+
expect(heading.attrs.level).toBe(2);
|
|
25
|
+
});
|
|
26
|
+
it("parses bold text", () => {
|
|
27
|
+
const doc = parse("<p><strong>bold</strong></p>");
|
|
28
|
+
const textNode = doc.content[0].content[0];
|
|
29
|
+
expect(textNode.text).toBe("bold");
|
|
30
|
+
expect(textNode.marks).toEqual(expect.arrayContaining([expect.objectContaining({ type: "bold" })]));
|
|
31
|
+
});
|
|
32
|
+
it("parses italic text", () => {
|
|
33
|
+
const doc = parse("<p><em>italic</em></p>");
|
|
34
|
+
const textNode = doc.content[0].content[0];
|
|
35
|
+
expect(textNode.text).toBe("italic");
|
|
36
|
+
expect(textNode.marks).toEqual(expect.arrayContaining([expect.objectContaining({ type: "italic" })]));
|
|
37
|
+
});
|
|
38
|
+
it("parses link", () => {
|
|
39
|
+
const doc = parse('<p><a href="https://example.com">click</a></p>');
|
|
40
|
+
const textNode = doc.content[0].content[0];
|
|
41
|
+
expect(textNode.text).toBe("click");
|
|
42
|
+
const linkMark = textNode.marks.find((m) => m.type === "link");
|
|
43
|
+
expect(linkMark).toBeDefined();
|
|
44
|
+
expect(linkMark.attrs.href).toBe("https://example.com");
|
|
45
|
+
});
|
|
46
|
+
it("parses page mention span", () => {
|
|
47
|
+
const doc = parse('<p><span data-type="mention" data-id="mention-1" data-entity-type="page" data-entity-id="page-1" data-label="通信合同文档" data-slug-id="slug-1">通信合同文档</span></p>');
|
|
48
|
+
const mention = doc.content[0].content[0];
|
|
49
|
+
expect(mention).toEqual({
|
|
50
|
+
type: "mention",
|
|
51
|
+
attrs: {
|
|
52
|
+
id: "mention-1",
|
|
53
|
+
label: "通信合同文档",
|
|
54
|
+
entityType: "page",
|
|
55
|
+
entityId: "page-1",
|
|
56
|
+
slugId: "slug-1",
|
|
57
|
+
creatorId: null,
|
|
58
|
+
anchorId: null,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
it("parses image", () => {
|
|
63
|
+
const doc = parse('<p><img src="https://example.com/img.png" alt="photo"></p>');
|
|
64
|
+
const img = doc.content[0].content.find((n) => n.type === "image");
|
|
65
|
+
expect(img).toBeDefined();
|
|
66
|
+
expect(img.attrs.src).toBe("https://example.com/img.png");
|
|
67
|
+
expect(img.attrs.alt).toBe("photo");
|
|
68
|
+
});
|
|
69
|
+
it("parses code block with language", () => {
|
|
70
|
+
const doc = parse('<pre><code class="language-js">const x = 1;</code></pre>');
|
|
71
|
+
const codeBlock = doc.content[0];
|
|
72
|
+
expect(codeBlock.type).toBe("codeBlock");
|
|
73
|
+
expect(codeBlock.attrs.language).toBe("js");
|
|
74
|
+
expect(codeBlock.content[0].text).toBe("const x = 1;");
|
|
75
|
+
});
|
|
76
|
+
it("parses bullet list", () => {
|
|
77
|
+
const doc = parse("<ul><li>a</li><li>b</li></ul>");
|
|
78
|
+
const list = doc.content[0];
|
|
79
|
+
expect(list.type).toBe("bulletList");
|
|
80
|
+
expect(list.content).toHaveLength(2);
|
|
81
|
+
expect(list.content[0].type).toBe("listItem");
|
|
82
|
+
});
|
|
83
|
+
it("parses ordered list", () => {
|
|
84
|
+
const doc = parse("<ol><li>first</li><li>second</li></ol>");
|
|
85
|
+
const list = doc.content[0];
|
|
86
|
+
expect(list.type).toBe("orderedList");
|
|
87
|
+
expect(list.content).toHaveLength(2);
|
|
88
|
+
expect(list.content[0].type).toBe("listItem");
|
|
89
|
+
});
|
|
90
|
+
describe("tables", () => {
|
|
91
|
+
it("parses table with headers", () => {
|
|
92
|
+
const html = "<table><tr><th>A</th><th>B</th></tr><tr><td>1</td><td>2</td></tr></table>";
|
|
93
|
+
const doc = parse(html);
|
|
94
|
+
const table = doc.content[0];
|
|
95
|
+
expect(table.type).toBe("table");
|
|
96
|
+
expect(table.content).toHaveLength(2);
|
|
97
|
+
const headerRow = table.content[0];
|
|
98
|
+
expect(headerRow.type).toBe("tableRow");
|
|
99
|
+
expect(headerRow.content[0].type).toBe("tableHeader");
|
|
100
|
+
expect(headerRow.content[1].type).toBe("tableHeader");
|
|
101
|
+
const dataRow = table.content[1];
|
|
102
|
+
expect(dataRow.type).toBe("tableRow");
|
|
103
|
+
expect(dataRow.content[0].type).toBe("tableCell");
|
|
104
|
+
expect(dataRow.content[1].type).toBe("tableCell");
|
|
105
|
+
// Verify cell content
|
|
106
|
+
const cellText = dataRow.content[0].content[0].content[0].text;
|
|
107
|
+
expect(cellText).toBe("1");
|
|
108
|
+
});
|
|
109
|
+
it("parses table without headers (all td)", () => {
|
|
110
|
+
const html = "<table><tr><td>x</td><td>y</td></tr><tr><td>z</td><td>w</td></tr></table>";
|
|
111
|
+
const doc = parse(html);
|
|
112
|
+
const table = doc.content[0];
|
|
113
|
+
expect(table.type).toBe("table");
|
|
114
|
+
expect(table.content).toHaveLength(2);
|
|
115
|
+
for (const row of table.content) {
|
|
116
|
+
expect(row.type).toBe("tableRow");
|
|
117
|
+
for (const cell of row.content) {
|
|
118
|
+
expect(cell.type).toBe("tableCell");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
it("parses table with multiple rows", () => {
|
|
123
|
+
const html = "<table>" +
|
|
124
|
+
"<tr><th>Name</th><th>Value</th></tr>" +
|
|
125
|
+
"<tr><td>a</td><td>1</td></tr>" +
|
|
126
|
+
"<tr><td>b</td><td>2</td></tr>" +
|
|
127
|
+
"<tr><td>c</td><td>3</td></tr>" +
|
|
128
|
+
"</table>";
|
|
129
|
+
const doc = parse(html);
|
|
130
|
+
const table = doc.content[0];
|
|
131
|
+
expect(table.type).toBe("table");
|
|
132
|
+
expect(table.content).toHaveLength(4); // 1 header + 3 data rows
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|