@openclaw/feishu 2026.5.2 → 2026.5.3-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accounts-Ba3-WP1z.js +423 -0
- package/dist/api.js +2280 -0
- package/dist/app-registration-B8qc1MCM.js +184 -0
- package/dist/audio-preflight.runtime-BPlzkO3l.js +7 -0
- package/dist/card-interaction-BfRLgvw_.js +96 -0
- package/dist/channel-CSD_Jt8I.js +1668 -0
- package/dist/channel-entry.js +22 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel.runtime-DYsXcD36.js +700 -0
- package/dist/client-DBVoQL5w.js +157 -0
- package/dist/contract-api.js +9 -0
- package/dist/conversation-id-DWS3Ep2A.js +139 -0
- package/dist/directory.static-f3EeoRJd.js +44 -0
- package/dist/drive-C5eJLJr7.js +883 -0
- package/dist/index.js +68 -0
- package/dist/monitor-CT189QfR.js +60 -0
- package/dist/monitor.account-dJV2jO8C.js +4990 -0
- package/dist/monitor.state-DYM02ipp.js +100 -0
- package/dist/policy-D6c-wMPl.js +118 -0
- package/dist/probe-BNzzU_uR.js +149 -0
- package/dist/rolldown-runtime-DUslC3ob.js +14 -0
- package/dist/runtime-CG0DuRCy.js +8 -0
- package/dist/runtime-api.js +14 -0
- package/dist/secret-contract-Dm4Z_zQN.js +119 -0
- package/dist/secret-contract-api.js +2 -0
- package/dist/security-audit-DqJdocrN.js +11 -0
- package/dist/security-audit-shared-ByuMx9cJ.js +38 -0
- package/dist/security-contract-api.js +2 -0
- package/dist/send-DowxxbpH.js +1218 -0
- package/dist/session-conversation-B4nrW-vo.js +27 -0
- package/dist/session-key-api.js +2 -0
- package/dist/setup-api.js +2 -0
- package/dist/setup-entry.js +15 -0
- package/dist/subagent-hooks-C3UhPVLV.js +227 -0
- package/dist/subagent-hooks-api.js +23 -0
- package/dist/targets-JMFJRKSe.js +48 -0
- package/dist/thread-bindings-BmS6TLes.js +222 -0
- package/package.json +15 -6
- package/api.ts +0 -31
- package/channel-entry.ts +0 -20
- package/channel-plugin-api.ts +0 -1
- package/contract-api.ts +0 -16
- package/index.ts +0 -82
- package/runtime-api.ts +0 -55
- package/secret-contract-api.ts +0 -5
- package/security-contract-api.ts +0 -1
- package/session-key-api.ts +0 -1
- package/setup-api.ts +0 -3
- package/setup-entry.test.ts +0 -14
- package/setup-entry.ts +0 -13
- package/src/accounts.test.ts +0 -459
- package/src/accounts.ts +0 -326
- package/src/app-registration.ts +0 -331
- package/src/approval-auth.test.ts +0 -24
- package/src/approval-auth.ts +0 -25
- package/src/async.test.ts +0 -35
- package/src/async.ts +0 -104
- package/src/audio-preflight.runtime.ts +0 -9
- package/src/bitable.test.ts +0 -131
- package/src/bitable.ts +0 -762
- package/src/bot-content.ts +0 -474
- package/src/bot-group-name.test.ts +0 -108
- package/src/bot-runtime-api.ts +0 -12
- package/src/bot-sender-name.ts +0 -125
- package/src/bot.broadcast.test.ts +0 -463
- package/src/bot.card-action.test.ts +0 -577
- package/src/bot.checkBotMentioned.test.ts +0 -265
- package/src/bot.helpers.test.ts +0 -118
- package/src/bot.stripBotMention.test.ts +0 -126
- package/src/bot.test.ts +0 -3040
- package/src/bot.ts +0 -1559
- package/src/card-action.ts +0 -447
- package/src/card-interaction.test.ts +0 -129
- package/src/card-interaction.ts +0 -159
- package/src/card-test-helpers.ts +0 -47
- package/src/card-ux-approval.ts +0 -65
- package/src/card-ux-launcher.test.ts +0 -99
- package/src/card-ux-launcher.ts +0 -121
- package/src/card-ux-shared.ts +0 -33
- package/src/channel-runtime-api.ts +0 -16
- package/src/channel.runtime.ts +0 -47
- package/src/channel.test.ts +0 -959
- package/src/channel.ts +0 -1313
- package/src/chat-schema.ts +0 -25
- package/src/chat.test.ts +0 -196
- package/src/chat.ts +0 -188
- package/src/client.test.ts +0 -433
- package/src/client.ts +0 -290
- package/src/comment-dispatcher-runtime-api.ts +0 -6
- package/src/comment-dispatcher.test.ts +0 -169
- package/src/comment-dispatcher.ts +0 -107
- package/src/comment-handler-runtime-api.ts +0 -3
- package/src/comment-handler.test.ts +0 -486
- package/src/comment-handler.ts +0 -309
- package/src/comment-reaction.test.ts +0 -166
- package/src/comment-reaction.ts +0 -259
- package/src/comment-shared.test.ts +0 -182
- package/src/comment-shared.ts +0 -406
- package/src/comment-target.ts +0 -44
- package/src/config-schema.test.ts +0 -309
- package/src/config-schema.ts +0 -333
- package/src/conversation-id.test.ts +0 -18
- package/src/conversation-id.ts +0 -199
- package/src/dedup-runtime-api.ts +0 -1
- package/src/dedup.ts +0 -141
- package/src/directory.static.ts +0 -61
- package/src/directory.test.ts +0 -136
- package/src/directory.ts +0 -124
- package/src/doc-schema.ts +0 -182
- package/src/docx-batch-insert.test.ts +0 -91
- package/src/docx-batch-insert.ts +0 -223
- package/src/docx-color-text.ts +0 -154
- package/src/docx-table-ops.test.ts +0 -53
- package/src/docx-table-ops.ts +0 -316
- package/src/docx-types.ts +0 -38
- package/src/docx.account-selection.test.ts +0 -79
- package/src/docx.test.ts +0 -685
- package/src/docx.ts +0 -1616
- package/src/drive-schema.ts +0 -92
- package/src/drive.test.ts +0 -1219
- package/src/drive.ts +0 -829
- package/src/dynamic-agent.ts +0 -137
- package/src/event-types.ts +0 -45
- package/src/external-keys.test.ts +0 -20
- package/src/external-keys.ts +0 -19
- package/src/lifecycle.test-support.ts +0 -220
- package/src/media.test.ts +0 -900
- package/src/media.ts +0 -861
- package/src/mention-target.types.ts +0 -5
- package/src/mention.ts +0 -114
- package/src/message-action-contract.ts +0 -13
- package/src/monitor-state-runtime-api.ts +0 -7
- package/src/monitor-transport-runtime-api.ts +0 -7
- package/src/monitor.account.ts +0 -468
- package/src/monitor.acp-init-failure.lifecycle.test-support.ts +0 -219
- package/src/monitor.bot-identity.ts +0 -86
- package/src/monitor.bot-menu-handler.ts +0 -165
- package/src/monitor.bot-menu.lifecycle.test-support.ts +0 -224
- package/src/monitor.bot-menu.test.ts +0 -178
- package/src/monitor.broadcast.reply-once.lifecycle.test-support.ts +0 -264
- package/src/monitor.card-action.lifecycle.test-support.ts +0 -373
- package/src/monitor.cleanup.test.ts +0 -376
- package/src/monitor.comment-notice-handler.ts +0 -105
- package/src/monitor.comment.test.ts +0 -937
- package/src/monitor.comment.ts +0 -1386
- package/src/monitor.lifecycle.test.ts +0 -4
- package/src/monitor.message-handler.ts +0 -339
- package/src/monitor.reaction.lifecycle.test-support.ts +0 -68
- package/src/monitor.reaction.test.ts +0 -713
- package/src/monitor.startup.test.ts +0 -192
- package/src/monitor.startup.ts +0 -74
- package/src/monitor.state.defaults.test.ts +0 -46
- package/src/monitor.state.ts +0 -170
- package/src/monitor.synthetic-error.ts +0 -18
- package/src/monitor.test-mocks.ts +0 -45
- package/src/monitor.transport.ts +0 -424
- package/src/monitor.ts +0 -100
- package/src/monitor.webhook-e2e.test.ts +0 -272
- package/src/monitor.webhook-security.test.ts +0 -264
- package/src/monitor.webhook.test-helpers.ts +0 -116
- package/src/outbound-runtime-api.ts +0 -1
- package/src/outbound.test.ts +0 -935
- package/src/outbound.ts +0 -718
- package/src/perm-schema.ts +0 -52
- package/src/perm.ts +0 -170
- package/src/pins.ts +0 -108
- package/src/policy.test.ts +0 -334
- package/src/policy.ts +0 -236
- package/src/post.test.ts +0 -105
- package/src/post.ts +0 -275
- package/src/probe.test.ts +0 -275
- package/src/probe.ts +0 -166
- package/src/processing-claims.ts +0 -59
- package/src/qr-terminal.ts +0 -1
- package/src/reactions.ts +0 -123
- package/src/reasoning-preview.test.ts +0 -59
- package/src/reasoning-preview.ts +0 -20
- package/src/reply-dispatcher-runtime-api.ts +0 -7
- package/src/reply-dispatcher.test.ts +0 -1144
- package/src/reply-dispatcher.ts +0 -650
- package/src/runtime.ts +0 -9
- package/src/secret-contract.ts +0 -145
- package/src/secret-input.ts +0 -1
- package/src/security-audit-shared.ts +0 -69
- package/src/security-audit.test.ts +0 -61
- package/src/security-audit.ts +0 -1
- package/src/send-result.ts +0 -29
- package/src/send-target.test.ts +0 -80
- package/src/send-target.ts +0 -35
- package/src/send.reply-fallback.test.ts +0 -292
- package/src/send.test.ts +0 -550
- package/src/send.ts +0 -800
- package/src/sequential-key.test.ts +0 -72
- package/src/sequential-key.ts +0 -28
- package/src/sequential-queue.test.ts +0 -92
- package/src/sequential-queue.ts +0 -16
- package/src/session-conversation.ts +0 -42
- package/src/session-route.ts +0 -48
- package/src/setup-core.ts +0 -51
- package/src/setup-surface.test.ts +0 -174
- package/src/setup-surface.ts +0 -581
- package/src/streaming-card.test.ts +0 -190
- package/src/streaming-card.ts +0 -490
- package/src/subagent-hooks.test.ts +0 -603
- package/src/subagent-hooks.ts +0 -397
- package/src/targets.ts +0 -97
- package/src/test-support/lifecycle-test-support.ts +0 -453
- package/src/thread-bindings.test.ts +0 -143
- package/src/thread-bindings.ts +0 -330
- package/src/tool-account-routing.test.ts +0 -187
- package/src/tool-account.test.ts +0 -44
- package/src/tool-account.ts +0 -93
- package/src/tool-factory-test-harness.ts +0 -79
- package/src/tool-result.test.ts +0 -32
- package/src/tool-result.ts +0 -16
- package/src/tools-config.test.ts +0 -21
- package/src/tools-config.ts +0 -22
- package/src/types.ts +0 -104
- package/src/typing.test.ts +0 -144
- package/src/typing.ts +0 -214
- package/src/wiki-schema.ts +0 -55
- package/src/wiki.ts +0 -227
- package/subagent-hooks-api.ts +0 -31
- package/tsconfig.json +0 -16
package/src/doc-schema.ts
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { Type, type Static } from "typebox";
|
|
2
|
-
|
|
3
|
-
const tableCreationProperties = {
|
|
4
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
5
|
-
parent_block_id: Type.Optional(
|
|
6
|
-
Type.String({ description: "Parent block ID (default: document root)" }),
|
|
7
|
-
),
|
|
8
|
-
row_size: Type.Integer({ description: "Table row count", minimum: 1 }),
|
|
9
|
-
column_size: Type.Integer({ description: "Table column count", minimum: 1 }),
|
|
10
|
-
column_width: Type.Optional(
|
|
11
|
-
Type.Array(Type.Number({ minimum: 1 }), {
|
|
12
|
-
description: "Column widths in px (length should match column_size)",
|
|
13
|
-
}),
|
|
14
|
-
),
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const FeishuDocSchema = Type.Union([
|
|
18
|
-
Type.Object({
|
|
19
|
-
action: Type.Literal("read"),
|
|
20
|
-
doc_token: Type.String({ description: "Document token (extract from URL /docx/XXX)" }),
|
|
21
|
-
}),
|
|
22
|
-
Type.Object({
|
|
23
|
-
action: Type.Literal("write"),
|
|
24
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
25
|
-
content: Type.String({
|
|
26
|
-
description: "Markdown content to write (replaces entire document content)",
|
|
27
|
-
}),
|
|
28
|
-
}),
|
|
29
|
-
Type.Object({
|
|
30
|
-
action: Type.Literal("append"),
|
|
31
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
32
|
-
content: Type.String({ description: "Markdown content to append to end of document" }),
|
|
33
|
-
}),
|
|
34
|
-
Type.Object({
|
|
35
|
-
action: Type.Literal("insert"),
|
|
36
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
37
|
-
content: Type.String({ description: "Markdown content to insert" }),
|
|
38
|
-
after_block_id: Type.String({
|
|
39
|
-
description: "Insert content after this block ID. Use list_blocks to find block IDs.",
|
|
40
|
-
}),
|
|
41
|
-
}),
|
|
42
|
-
Type.Object({
|
|
43
|
-
action: Type.Literal("create"),
|
|
44
|
-
title: Type.String({ description: "Document title" }),
|
|
45
|
-
folder_token: Type.Optional(Type.String({ description: "Target folder token (optional)" })),
|
|
46
|
-
grant_to_requester: Type.Optional(
|
|
47
|
-
Type.Boolean({
|
|
48
|
-
description:
|
|
49
|
-
"Grant edit permission to the trusted requesting Feishu user from runtime context (default: true).",
|
|
50
|
-
}),
|
|
51
|
-
),
|
|
52
|
-
}),
|
|
53
|
-
Type.Object({
|
|
54
|
-
action: Type.Literal("list_blocks"),
|
|
55
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
56
|
-
}),
|
|
57
|
-
Type.Object({
|
|
58
|
-
action: Type.Literal("get_block"),
|
|
59
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
60
|
-
block_id: Type.String({ description: "Block ID (from list_blocks)" }),
|
|
61
|
-
}),
|
|
62
|
-
Type.Object({
|
|
63
|
-
action: Type.Literal("update_block"),
|
|
64
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
65
|
-
block_id: Type.String({ description: "Block ID (from list_blocks)" }),
|
|
66
|
-
content: Type.String({ description: "New text content" }),
|
|
67
|
-
}),
|
|
68
|
-
Type.Object({
|
|
69
|
-
action: Type.Literal("delete_block"),
|
|
70
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
71
|
-
block_id: Type.String({ description: "Block ID" }),
|
|
72
|
-
}),
|
|
73
|
-
// Table creation (explicit structure)
|
|
74
|
-
Type.Object({
|
|
75
|
-
action: Type.Literal("create_table"),
|
|
76
|
-
...tableCreationProperties,
|
|
77
|
-
}),
|
|
78
|
-
Type.Object({
|
|
79
|
-
action: Type.Literal("write_table_cells"),
|
|
80
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
81
|
-
table_block_id: Type.String({ description: "Table block ID" }),
|
|
82
|
-
values: Type.Array(Type.Array(Type.String()), {
|
|
83
|
-
description: "2D matrix values[row][col] to write into table cells",
|
|
84
|
-
minItems: 1,
|
|
85
|
-
}),
|
|
86
|
-
}),
|
|
87
|
-
Type.Object({
|
|
88
|
-
action: Type.Literal("create_table_with_values"),
|
|
89
|
-
...tableCreationProperties,
|
|
90
|
-
values: Type.Array(Type.Array(Type.String()), {
|
|
91
|
-
description: "2D matrix values[row][col] to write into table cells",
|
|
92
|
-
minItems: 1,
|
|
93
|
-
}),
|
|
94
|
-
}),
|
|
95
|
-
// Table row/column manipulation
|
|
96
|
-
Type.Object({
|
|
97
|
-
action: Type.Literal("insert_table_row"),
|
|
98
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
99
|
-
block_id: Type.String({ description: "Table block ID" }),
|
|
100
|
-
row_index: Type.Optional(
|
|
101
|
-
Type.Number({ description: "Row index to insert at (-1 for end, default: -1)" }),
|
|
102
|
-
),
|
|
103
|
-
}),
|
|
104
|
-
Type.Object({
|
|
105
|
-
action: Type.Literal("insert_table_column"),
|
|
106
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
107
|
-
block_id: Type.String({ description: "Table block ID" }),
|
|
108
|
-
column_index: Type.Optional(
|
|
109
|
-
Type.Number({ description: "Column index to insert at (-1 for end, default: -1)" }),
|
|
110
|
-
),
|
|
111
|
-
}),
|
|
112
|
-
Type.Object({
|
|
113
|
-
action: Type.Literal("delete_table_rows"),
|
|
114
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
115
|
-
block_id: Type.String({ description: "Table block ID" }),
|
|
116
|
-
row_start: Type.Number({ description: "Start row index (0-based)" }),
|
|
117
|
-
row_count: Type.Optional(Type.Number({ description: "Number of rows to delete (default: 1)" })),
|
|
118
|
-
}),
|
|
119
|
-
Type.Object({
|
|
120
|
-
action: Type.Literal("delete_table_columns"),
|
|
121
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
122
|
-
block_id: Type.String({ description: "Table block ID" }),
|
|
123
|
-
column_start: Type.Number({ description: "Start column index (0-based)" }),
|
|
124
|
-
column_count: Type.Optional(
|
|
125
|
-
Type.Number({ description: "Number of columns to delete (default: 1)" }),
|
|
126
|
-
),
|
|
127
|
-
}),
|
|
128
|
-
Type.Object({
|
|
129
|
-
action: Type.Literal("merge_table_cells"),
|
|
130
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
131
|
-
block_id: Type.String({ description: "Table block ID" }),
|
|
132
|
-
row_start: Type.Number({ description: "Start row index" }),
|
|
133
|
-
row_end: Type.Number({ description: "End row index (exclusive)" }),
|
|
134
|
-
column_start: Type.Number({ description: "Start column index" }),
|
|
135
|
-
column_end: Type.Number({ description: "End column index (exclusive)" }),
|
|
136
|
-
}),
|
|
137
|
-
// Image / file upload
|
|
138
|
-
Type.Object({
|
|
139
|
-
action: Type.Literal("upload_image"),
|
|
140
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
141
|
-
url: Type.Optional(Type.String({ description: "Remote image URL (http/https)" })),
|
|
142
|
-
file_path: Type.Optional(Type.String({ description: "Local image file path" })),
|
|
143
|
-
image: Type.Optional(
|
|
144
|
-
Type.String({
|
|
145
|
-
description:
|
|
146
|
-
"Image as data URI (data:image/png;base64,...) or plain base64 string. Use instead of url/file_path for DALL-E outputs, canvas screenshots, etc.",
|
|
147
|
-
}),
|
|
148
|
-
),
|
|
149
|
-
parent_block_id: Type.Optional(
|
|
150
|
-
Type.String({ description: "Parent block ID (default: document root)" }),
|
|
151
|
-
),
|
|
152
|
-
filename: Type.Optional(Type.String({ description: "Optional filename override" })),
|
|
153
|
-
index: Type.Optional(
|
|
154
|
-
Type.Integer({
|
|
155
|
-
minimum: 0,
|
|
156
|
-
description: "Insert position (0-based index among siblings). Omit to append.",
|
|
157
|
-
}),
|
|
158
|
-
),
|
|
159
|
-
}),
|
|
160
|
-
Type.Object({
|
|
161
|
-
action: Type.Literal("upload_file"),
|
|
162
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
163
|
-
url: Type.Optional(Type.String({ description: "Remote file URL (http/https)" })),
|
|
164
|
-
file_path: Type.Optional(Type.String({ description: "Local file path" })),
|
|
165
|
-
parent_block_id: Type.Optional(
|
|
166
|
-
Type.String({ description: "Parent block ID (default: document root)" }),
|
|
167
|
-
),
|
|
168
|
-
filename: Type.Optional(Type.String({ description: "Optional filename override" })),
|
|
169
|
-
}),
|
|
170
|
-
// Text color / style
|
|
171
|
-
Type.Object({
|
|
172
|
-
action: Type.Literal("color_text"),
|
|
173
|
-
doc_token: Type.String({ description: "Document token" }),
|
|
174
|
-
block_id: Type.String({ description: "Text block ID to update" }),
|
|
175
|
-
content: Type.String({
|
|
176
|
-
description:
|
|
177
|
-
'Text with color markup. Tags: [red], [green], [blue], [orange], [yellow], [purple], [grey], [bold], [bg:yellow]. Example: "Revenue [green]+15%[/green] YoY"',
|
|
178
|
-
}),
|
|
179
|
-
}),
|
|
180
|
-
]);
|
|
181
|
-
|
|
182
|
-
export type FeishuDocParams = Static<typeof FeishuDocSchema>;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import type * as Lark from "@larksuiteoapi/node-sdk";
|
|
2
|
-
import { describe, expect, it, vi } from "vitest";
|
|
3
|
-
import { BATCH_SIZE, insertBlocksInBatches } from "./docx-batch-insert.js";
|
|
4
|
-
import type { FeishuDocxBlock } from "./docx-types.js";
|
|
5
|
-
|
|
6
|
-
type InsertBlocksClient = Parameters<typeof insertBlocksInBatches>[0];
|
|
7
|
-
type DocxDescendantCreate = Lark.Client["docx"]["documentBlockDescendant"]["create"];
|
|
8
|
-
type DocxDescendantCreateParams = Parameters<DocxDescendantCreate>[0];
|
|
9
|
-
type DocxDescendantCreateResponse = Awaited<ReturnType<DocxDescendantCreate>>;
|
|
10
|
-
|
|
11
|
-
function createDocxDescendantClient(create: DocxDescendantCreate): InsertBlocksClient {
|
|
12
|
-
return {
|
|
13
|
-
docx: {
|
|
14
|
-
documentBlockDescendant: {
|
|
15
|
-
create,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
} as InsertBlocksClient;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function createCountingIterable<T>(values: T[]) {
|
|
22
|
-
let iterations = 0;
|
|
23
|
-
return {
|
|
24
|
-
values: {
|
|
25
|
-
[Symbol.iterator]: function* () {
|
|
26
|
-
iterations += 1;
|
|
27
|
-
yield* values;
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
getIterations: () => iterations,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function createSuccessfulDocxDescendantCreateMock() {
|
|
35
|
-
return vi.fn(
|
|
36
|
-
async (params?: DocxDescendantCreateParams): Promise<DocxDescendantCreateResponse> => ({
|
|
37
|
-
code: 0,
|
|
38
|
-
data: {
|
|
39
|
-
children: (params?.data?.children_id ?? []).map((id) => ({
|
|
40
|
-
block_id: id,
|
|
41
|
-
block_type: 2,
|
|
42
|
-
})),
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
describe("insertBlocksInBatches", () => {
|
|
49
|
-
it("builds the source block map once for large flat trees", async () => {
|
|
50
|
-
const blockCount = BATCH_SIZE + 200;
|
|
51
|
-
const blocks = Array.from({ length: blockCount }, (_, index) => ({
|
|
52
|
-
block_id: `block_${index}`,
|
|
53
|
-
block_type: 2,
|
|
54
|
-
}));
|
|
55
|
-
const counting = createCountingIterable(blocks);
|
|
56
|
-
const createMock = createSuccessfulDocxDescendantCreateMock();
|
|
57
|
-
const client = createDocxDescendantClient((params) => createMock(params));
|
|
58
|
-
|
|
59
|
-
const result = await insertBlocksInBatches(
|
|
60
|
-
client,
|
|
61
|
-
"doc_1",
|
|
62
|
-
Array.from(counting.values),
|
|
63
|
-
blocks.map((block) => block.block_id),
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
expect(counting.getIterations()).toBe(1);
|
|
67
|
-
expect(createMock).toHaveBeenCalledTimes(2);
|
|
68
|
-
expect(createMock.mock.calls[0]?.[0]?.data.children_id).toHaveLength(BATCH_SIZE);
|
|
69
|
-
expect(createMock.mock.calls[1]?.[0]?.data.children_id).toHaveLength(200);
|
|
70
|
-
expect(result.children).toHaveLength(blockCount);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("keeps nested descendants grouped with their root blocks", async () => {
|
|
74
|
-
const createMock = createSuccessfulDocxDescendantCreateMock();
|
|
75
|
-
const client = createDocxDescendantClient((params) => createMock(params));
|
|
76
|
-
const blocks: FeishuDocxBlock[] = [
|
|
77
|
-
{ block_id: "root_a", block_type: 1, children: ["child_a"] },
|
|
78
|
-
{ block_id: "child_a", block_type: 2 },
|
|
79
|
-
{ block_id: "root_b", block_type: 1, children: ["child_b"] },
|
|
80
|
-
{ block_id: "child_b", block_type: 2 },
|
|
81
|
-
];
|
|
82
|
-
|
|
83
|
-
await insertBlocksInBatches(client, "doc_1", blocks, ["root_a", "root_b"]);
|
|
84
|
-
|
|
85
|
-
expect(createMock).toHaveBeenCalledTimes(1);
|
|
86
|
-
expect(createMock.mock.calls[0]?.[0]?.data.children_id).toEqual(["root_a", "root_b"]);
|
|
87
|
-
expect(
|
|
88
|
-
createMock.mock.calls[0]?.[0]?.data.descendants.map((block) => block.block_id ?? ""),
|
|
89
|
-
).toEqual(["root_a", "child_a", "root_b", "child_b"]);
|
|
90
|
-
});
|
|
91
|
-
});
|
package/src/docx-batch-insert.ts
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Batch insertion for large Feishu documents (>1000 blocks).
|
|
3
|
-
*
|
|
4
|
-
* The Feishu Descendant API has a limit of 1000 blocks per request.
|
|
5
|
-
* This module handles splitting large documents into batches while
|
|
6
|
-
* preserving parent-child relationships between blocks.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type * as Lark from "@larksuiteoapi/node-sdk";
|
|
10
|
-
import { readStringValue } from "openclaw/plugin-sdk/text-runtime";
|
|
11
|
-
import { cleanBlocksForDescendant } from "./docx-table-ops.js";
|
|
12
|
-
import type { FeishuDocxBlock, FeishuDocxBlockChild } from "./docx-types.js";
|
|
13
|
-
|
|
14
|
-
export const BATCH_SIZE = 1000; // Feishu API limit per request
|
|
15
|
-
|
|
16
|
-
type Logger = { info?: (msg: string) => void };
|
|
17
|
-
|
|
18
|
-
type DocxDescendantCreatePayload = NonNullable<
|
|
19
|
-
Parameters<Lark.Client["docx"]["documentBlockDescendant"]["create"]>[0]
|
|
20
|
-
>;
|
|
21
|
-
type DocxDescendantCreateBlock = NonNullable<
|
|
22
|
-
NonNullable<DocxDescendantCreatePayload["data"]>["descendants"]
|
|
23
|
-
>[number];
|
|
24
|
-
|
|
25
|
-
function normalizeChildIds(children: string[] | string | undefined): string[] | undefined {
|
|
26
|
-
if (Array.isArray(children)) {
|
|
27
|
-
return children;
|
|
28
|
-
}
|
|
29
|
-
const child = readStringValue(children);
|
|
30
|
-
return child ? [child] : undefined;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function toDescendantBlock(block: FeishuDocxBlock): DocxDescendantCreateBlock {
|
|
34
|
-
const children = normalizeChildIds(block.children);
|
|
35
|
-
return {
|
|
36
|
-
...block,
|
|
37
|
-
...(children ? { children } : {}),
|
|
38
|
-
} as DocxDescendantCreateBlock;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Collect all descendant blocks for a given first-level block ID.
|
|
43
|
-
* Recursively traverses the block tree to gather all children.
|
|
44
|
-
*/
|
|
45
|
-
function collectDescendants(
|
|
46
|
-
blockMap: Map<string, FeishuDocxBlock>,
|
|
47
|
-
rootId: string,
|
|
48
|
-
): FeishuDocxBlock[] {
|
|
49
|
-
const result: FeishuDocxBlock[] = [];
|
|
50
|
-
const visited = new Set<string>();
|
|
51
|
-
|
|
52
|
-
function collect(blockId: string) {
|
|
53
|
-
if (visited.has(blockId)) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
visited.add(blockId);
|
|
57
|
-
|
|
58
|
-
const block = blockMap.get(blockId);
|
|
59
|
-
if (!block) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
result.push(block);
|
|
64
|
-
|
|
65
|
-
// Recursively collect children
|
|
66
|
-
const children = block.children;
|
|
67
|
-
if (Array.isArray(children)) {
|
|
68
|
-
for (const childId of children) {
|
|
69
|
-
collect(childId);
|
|
70
|
-
}
|
|
71
|
-
} else if (typeof children === "string") {
|
|
72
|
-
collect(children);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
collect(rootId);
|
|
77
|
-
|
|
78
|
-
return result;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Insert a single batch of blocks using Descendant API.
|
|
83
|
-
*
|
|
84
|
-
* @param parentBlockId - Parent block to insert into (defaults to docToken)
|
|
85
|
-
* @param index - Position within parent's children (-1 = end)
|
|
86
|
-
*/
|
|
87
|
-
async function insertBatch(
|
|
88
|
-
client: Lark.Client,
|
|
89
|
-
docToken: string,
|
|
90
|
-
blocks: FeishuDocxBlock[],
|
|
91
|
-
firstLevelBlockIds: string[],
|
|
92
|
-
parentBlockId: string = docToken,
|
|
93
|
-
index: number = -1,
|
|
94
|
-
): Promise<FeishuDocxBlockChild[]> {
|
|
95
|
-
const descendants = cleanBlocksForDescendant(blocks);
|
|
96
|
-
|
|
97
|
-
if (descendants.length === 0) {
|
|
98
|
-
return [];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const res = await client.docx.documentBlockDescendant.create({
|
|
102
|
-
path: { document_id: docToken, block_id: parentBlockId },
|
|
103
|
-
data: {
|
|
104
|
-
children_id: firstLevelBlockIds,
|
|
105
|
-
descendants: descendants.map(toDescendantBlock),
|
|
106
|
-
index,
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
if (res.code !== 0) {
|
|
111
|
-
throw new Error(`${res.msg} (code: ${res.code})`);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return res.data?.children ?? [];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Insert blocks in batches for large documents (>1000 blocks).
|
|
119
|
-
*
|
|
120
|
-
* Batches are split to ensure BOTH children_id AND descendants
|
|
121
|
-
* arrays stay under the 1000 block API limit.
|
|
122
|
-
*
|
|
123
|
-
* @param client - Feishu API client
|
|
124
|
-
* @param docToken - Document ID
|
|
125
|
-
* @param blocks - All blocks from Convert API
|
|
126
|
-
* @param firstLevelBlockIds - IDs of top-level blocks to insert
|
|
127
|
-
* @param logger - Optional logger for progress updates
|
|
128
|
-
* @param parentBlockId - Parent block to insert into (defaults to docToken = document root)
|
|
129
|
-
* @param startIndex - Starting position within parent (-1 = end). For multi-batch inserts,
|
|
130
|
-
* each batch advances this by the number of first-level IDs inserted so far.
|
|
131
|
-
* @returns Inserted children blocks and any skipped block IDs
|
|
132
|
-
*/
|
|
133
|
-
export async function insertBlocksInBatches(
|
|
134
|
-
client: Lark.Client,
|
|
135
|
-
docToken: string,
|
|
136
|
-
blocks: FeishuDocxBlock[],
|
|
137
|
-
firstLevelBlockIds: string[],
|
|
138
|
-
logger?: Logger,
|
|
139
|
-
parentBlockId: string = docToken,
|
|
140
|
-
startIndex: number = -1,
|
|
141
|
-
): Promise<{ children: FeishuDocxBlockChild[]; skipped: string[] }> {
|
|
142
|
-
const allChildren: FeishuDocxBlockChild[] = [];
|
|
143
|
-
|
|
144
|
-
// Build batches ensuring each batch has ≤1000 total descendants
|
|
145
|
-
const batches: Array<{ firstLevelIds: string[]; blocks: FeishuDocxBlock[] }> = [];
|
|
146
|
-
let currentBatch: { firstLevelIds: string[]; blocks: FeishuDocxBlock[] } = {
|
|
147
|
-
firstLevelIds: [],
|
|
148
|
-
blocks: [],
|
|
149
|
-
};
|
|
150
|
-
const usedBlockIds = new Set<string>();
|
|
151
|
-
const blockMap = new Map<string, FeishuDocxBlock>();
|
|
152
|
-
for (const block of blocks) {
|
|
153
|
-
if (block.block_id) {
|
|
154
|
-
blockMap.set(block.block_id, block);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
for (const firstLevelId of firstLevelBlockIds) {
|
|
159
|
-
const descendants = collectDescendants(blockMap, firstLevelId);
|
|
160
|
-
const newBlocks = descendants.filter((b) => b.block_id && !usedBlockIds.has(b.block_id));
|
|
161
|
-
|
|
162
|
-
// A single block whose subtree exceeds the API limit cannot be split
|
|
163
|
-
// (a table or other compound block must be inserted atomically).
|
|
164
|
-
if (newBlocks.length > BATCH_SIZE) {
|
|
165
|
-
throw new Error(
|
|
166
|
-
`Block "${firstLevelId}" has ${newBlocks.length} descendants, which exceeds the ` +
|
|
167
|
-
`Feishu API limit of ${BATCH_SIZE} blocks per request. ` +
|
|
168
|
-
`Please split the content into smaller sections.`,
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// If adding this first-level block would exceed limit, start new batch
|
|
173
|
-
if (
|
|
174
|
-
currentBatch.blocks.length + newBlocks.length > BATCH_SIZE &&
|
|
175
|
-
currentBatch.blocks.length > 0
|
|
176
|
-
) {
|
|
177
|
-
batches.push(currentBatch);
|
|
178
|
-
currentBatch = { firstLevelIds: [], blocks: [] };
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Add to current batch
|
|
182
|
-
currentBatch.firstLevelIds.push(firstLevelId);
|
|
183
|
-
for (const block of newBlocks) {
|
|
184
|
-
currentBatch.blocks.push(block);
|
|
185
|
-
if (block.block_id) {
|
|
186
|
-
usedBlockIds.add(block.block_id);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Don't forget the last batch
|
|
192
|
-
if (currentBatch.blocks.length > 0) {
|
|
193
|
-
batches.push(currentBatch);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Insert each batch, advancing index for position-aware inserts.
|
|
197
|
-
// When startIndex == -1 (append to end), each batch appends after the previous.
|
|
198
|
-
// When startIndex >= 0, each batch starts at startIndex + count of first-level IDs already inserted.
|
|
199
|
-
let currentIndex = startIndex;
|
|
200
|
-
for (let i = 0; i < batches.length; i++) {
|
|
201
|
-
const batch = batches[i];
|
|
202
|
-
logger?.info?.(
|
|
203
|
-
`feishu_doc: Inserting batch ${i + 1}/${batches.length} (${batch.blocks.length} blocks)...`,
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
const children = await insertBatch(
|
|
207
|
-
client,
|
|
208
|
-
docToken,
|
|
209
|
-
batch.blocks,
|
|
210
|
-
batch.firstLevelIds,
|
|
211
|
-
parentBlockId,
|
|
212
|
-
currentIndex,
|
|
213
|
-
);
|
|
214
|
-
allChildren.push(...children);
|
|
215
|
-
|
|
216
|
-
// Advance index only for explicit positions; -1 always means "after last inserted"
|
|
217
|
-
if (currentIndex !== -1) {
|
|
218
|
-
currentIndex += batch.firstLevelIds.length;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return { children: allChildren, skipped: [] };
|
|
223
|
-
}
|
package/src/docx-color-text.ts
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Colored text support for Feishu documents.
|
|
3
|
-
*
|
|
4
|
-
* Parses a simple color markup syntax and updates a text block
|
|
5
|
-
* with native Feishu text_run color styles.
|
|
6
|
-
*
|
|
7
|
-
* Syntax: [color]text[/color]
|
|
8
|
-
* Supported colors: red, orange, yellow, green, blue, purple, grey
|
|
9
|
-
*
|
|
10
|
-
* Example:
|
|
11
|
-
* "Revenue [green]+15%[/green] YoY, Costs [red]-3%[/red]"
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import type * as Lark from "@larksuiteoapi/node-sdk";
|
|
15
|
-
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
|
|
16
|
-
|
|
17
|
-
// Feishu text_color values (1-7)
|
|
18
|
-
const TEXT_COLOR: Record<string, number> = {
|
|
19
|
-
red: 1, // Pink (closest to red in Feishu)
|
|
20
|
-
orange: 2,
|
|
21
|
-
yellow: 3,
|
|
22
|
-
green: 4,
|
|
23
|
-
blue: 5,
|
|
24
|
-
purple: 6,
|
|
25
|
-
grey: 7,
|
|
26
|
-
gray: 7,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// Feishu background_color values (1-15)
|
|
30
|
-
const BACKGROUND_COLOR: Record<string, number> = {
|
|
31
|
-
red: 1,
|
|
32
|
-
orange: 2,
|
|
33
|
-
yellow: 3,
|
|
34
|
-
green: 4,
|
|
35
|
-
blue: 5,
|
|
36
|
-
purple: 6,
|
|
37
|
-
grey: 7,
|
|
38
|
-
gray: 7,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
interface Segment {
|
|
42
|
-
text: string;
|
|
43
|
-
textColor?: number;
|
|
44
|
-
bgColor?: number;
|
|
45
|
-
bold?: boolean;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type DocxPatchPayload = NonNullable<Parameters<Lark.Client["docx"]["documentBlock"]["patch"]>[0]>;
|
|
49
|
-
type DocxTextElement = NonNullable<
|
|
50
|
-
NonNullable<NonNullable<DocxPatchPayload["data"]>["update_text_elements"]>["elements"]
|
|
51
|
-
>[number];
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Parse color markup into segments.
|
|
55
|
-
*
|
|
56
|
-
* Supports:
|
|
57
|
-
* [red]text[/red] → red text
|
|
58
|
-
* [bg:yellow]text[/bg] → yellow background
|
|
59
|
-
* [bold]text[/bold] → bold
|
|
60
|
-
* [green bold]text[/green] → green + bold
|
|
61
|
-
*/
|
|
62
|
-
function parseColorMarkup(content: string): Segment[] {
|
|
63
|
-
const segments: Segment[] = [];
|
|
64
|
-
// Only [known_tag]...[/...] pairs are treated as markup. Using an open
|
|
65
|
-
// pattern like \[([^\]]+)\] would match any bracket token — e.g. [Q1] —
|
|
66
|
-
// and cause it to consume a later real closing tag ([/red]), silently
|
|
67
|
-
// corrupting the surrounding styled spans. Restricting the opening tag to
|
|
68
|
-
// the set of recognised colour/style names prevents that: [Q1] does not
|
|
69
|
-
// match the tag alternative and each of its characters falls through to the
|
|
70
|
-
// plain-text alternatives instead.
|
|
71
|
-
//
|
|
72
|
-
// Closing tag name is still not validated against the opening tag:
|
|
73
|
-
// [red]text[/green] is treated as [red]text[/red] — opening style applies
|
|
74
|
-
// and the closing tag is consumed regardless of its name.
|
|
75
|
-
const KNOWN = "(?:bg:[a-z]+|bold|red|orange|yellow|green|blue|purple|gr[ae]y)";
|
|
76
|
-
const tagPattern = new RegExp(
|
|
77
|
-
`\\[(${KNOWN}(?:\\s+${KNOWN})*)\\](.*?)\\[\\/(?:[^\\]]+)\\]|([^[]+|\\[)`,
|
|
78
|
-
"gis",
|
|
79
|
-
);
|
|
80
|
-
let match;
|
|
81
|
-
|
|
82
|
-
while ((match = tagPattern.exec(content)) !== null) {
|
|
83
|
-
if (match[3] !== undefined) {
|
|
84
|
-
// Plain text segment
|
|
85
|
-
if (match[3]) {
|
|
86
|
-
segments.push({ text: match[3] });
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
// Tagged segment
|
|
90
|
-
const tagStr = normalizeLowercaseStringOrEmpty(match[1]);
|
|
91
|
-
const text = match[2];
|
|
92
|
-
const tags = tagStr.split(/\s+/);
|
|
93
|
-
|
|
94
|
-
const segment: Segment = { text };
|
|
95
|
-
|
|
96
|
-
for (const tag of tags) {
|
|
97
|
-
if (tag.startsWith("bg:")) {
|
|
98
|
-
const color = tag.slice(3);
|
|
99
|
-
if (BACKGROUND_COLOR[color]) {
|
|
100
|
-
segment.bgColor = BACKGROUND_COLOR[color];
|
|
101
|
-
}
|
|
102
|
-
} else if (tag === "bold") {
|
|
103
|
-
segment.bold = true;
|
|
104
|
-
} else if (TEXT_COLOR[tag]) {
|
|
105
|
-
segment.textColor = TEXT_COLOR[tag];
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (text) {
|
|
110
|
-
segments.push(segment);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return segments;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Update a text block with colored segments.
|
|
120
|
-
*/
|
|
121
|
-
export async function updateColorText(
|
|
122
|
-
client: Lark.Client,
|
|
123
|
-
docToken: string,
|
|
124
|
-
blockId: string,
|
|
125
|
-
content: string,
|
|
126
|
-
) {
|
|
127
|
-
const segments = parseColorMarkup(content);
|
|
128
|
-
|
|
129
|
-
const elements: DocxTextElement[] = segments.map((seg) => ({
|
|
130
|
-
text_run: {
|
|
131
|
-
content: seg.text,
|
|
132
|
-
text_element_style: {
|
|
133
|
-
...(seg.textColor && { text_color: seg.textColor }),
|
|
134
|
-
...(seg.bgColor && { background_color: seg.bgColor }),
|
|
135
|
-
...(seg.bold && { bold: true }),
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
}));
|
|
139
|
-
|
|
140
|
-
const res = await client.docx.documentBlock.patch({
|
|
141
|
-
path: { document_id: docToken, block_id: blockId },
|
|
142
|
-
data: { update_text_elements: { elements } },
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
if (res.code !== 0) {
|
|
146
|
-
throw new Error(res.msg);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return {
|
|
150
|
-
success: true,
|
|
151
|
-
segments: segments.length,
|
|
152
|
-
block: res.data?.block,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { cleanBlocksForDescendant } from "./docx-table-ops.js";
|
|
3
|
-
|
|
4
|
-
describe("cleanBlocksForDescendant", () => {
|
|
5
|
-
it("removes parent links and read-only table fields while normalizing table cells", () => {
|
|
6
|
-
const blocks = [
|
|
7
|
-
{
|
|
8
|
-
block_id: "table-1",
|
|
9
|
-
parent_id: "parent-1",
|
|
10
|
-
block_type: 31,
|
|
11
|
-
children: "cell-1",
|
|
12
|
-
table: {
|
|
13
|
-
property: {
|
|
14
|
-
row_size: 1,
|
|
15
|
-
column_size: 1,
|
|
16
|
-
column_width: [240],
|
|
17
|
-
},
|
|
18
|
-
cells: ["cell-1"],
|
|
19
|
-
merge_info: [{ row_span: 1, col_span: 1 }],
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
block_id: "cell-1",
|
|
24
|
-
parent_id: "table-1",
|
|
25
|
-
block_type: 32,
|
|
26
|
-
children: "text-1",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
block_id: "text-1",
|
|
30
|
-
parent_id: "cell-1",
|
|
31
|
-
block_type: 2,
|
|
32
|
-
text: {
|
|
33
|
-
elements: [{ text_run: { content: "hello" } }],
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
const cleaned = cleanBlocksForDescendant(blocks);
|
|
39
|
-
|
|
40
|
-
expect(cleaned[0]).not.toHaveProperty("parent_id");
|
|
41
|
-
expect(cleaned[1]).not.toHaveProperty("parent_id");
|
|
42
|
-
expect(cleaned[2]).not.toHaveProperty("parent_id");
|
|
43
|
-
|
|
44
|
-
expect(cleaned[0]?.table).toEqual({
|
|
45
|
-
property: {
|
|
46
|
-
row_size: 1,
|
|
47
|
-
column_size: 1,
|
|
48
|
-
column_width: [240],
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
expect(cleaned[1]?.children).toEqual(["text-1"]);
|
|
52
|
-
});
|
|
53
|
-
});
|