@gakr-gakr/feishu 0.1.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.
Files changed (133) hide show
  1. package/api.ts +32 -0
  2. package/autobot.plugin.json +180 -0
  3. package/channel-entry.ts +20 -0
  4. package/channel-plugin-api.ts +1 -0
  5. package/contract-api.ts +16 -0
  6. package/index.ts +82 -0
  7. package/package.json +62 -0
  8. package/runtime-api.ts +55 -0
  9. package/secret-contract-api.ts +5 -0
  10. package/security-contract-api.ts +1 -0
  11. package/session-key-api.ts +1 -0
  12. package/setup-api.ts +3 -0
  13. package/setup-entry.ts +13 -0
  14. package/skills/feishu-doc/SKILL.md +211 -0
  15. package/skills/feishu-doc/references/block-types.md +103 -0
  16. package/skills/feishu-drive/SKILL.md +97 -0
  17. package/skills/feishu-perm/SKILL.md +119 -0
  18. package/skills/feishu-wiki/SKILL.md +113 -0
  19. package/src/accounts.ts +333 -0
  20. package/src/agent-config.ts +21 -0
  21. package/src/app-registration.ts +331 -0
  22. package/src/approval-auth.ts +25 -0
  23. package/src/async.ts +104 -0
  24. package/src/audio-preflight.runtime.ts +9 -0
  25. package/src/bitable.ts +762 -0
  26. package/src/bot-content.ts +485 -0
  27. package/src/bot-runtime-api.ts +12 -0
  28. package/src/bot-sender-name.ts +125 -0
  29. package/src/bot.ts +1703 -0
  30. package/src/card-action.ts +447 -0
  31. package/src/card-interaction.ts +159 -0
  32. package/src/card-test-helpers.ts +54 -0
  33. package/src/card-ux-approval.ts +65 -0
  34. package/src/card-ux-launcher.ts +121 -0
  35. package/src/card-ux-shared.ts +33 -0
  36. package/src/channel-runtime-api.ts +16 -0
  37. package/src/channel.runtime.ts +47 -0
  38. package/src/channel.ts +1423 -0
  39. package/src/chat-schema.ts +25 -0
  40. package/src/chat.ts +188 -0
  41. package/src/client-timeout.ts +42 -0
  42. package/src/client.ts +262 -0
  43. package/src/comment-dispatcher-runtime-api.ts +6 -0
  44. package/src/comment-dispatcher.ts +107 -0
  45. package/src/comment-handler-runtime-api.ts +3 -0
  46. package/src/comment-handler.ts +303 -0
  47. package/src/comment-reaction.ts +259 -0
  48. package/src/comment-shared.ts +406 -0
  49. package/src/comment-target.ts +44 -0
  50. package/src/config-schema.ts +335 -0
  51. package/src/conversation-id.ts +199 -0
  52. package/src/dedup-runtime-api.ts +1 -0
  53. package/src/dedup.ts +141 -0
  54. package/src/dedupe-key.ts +72 -0
  55. package/src/directory.static.ts +61 -0
  56. package/src/directory.ts +124 -0
  57. package/src/doc-schema.ts +182 -0
  58. package/src/docx-batch-insert.ts +223 -0
  59. package/src/docx-color-text.ts +154 -0
  60. package/src/docx-table-ops.ts +316 -0
  61. package/src/docx-types.ts +38 -0
  62. package/src/docx.ts +1596 -0
  63. package/src/drive-schema.ts +92 -0
  64. package/src/drive.ts +829 -0
  65. package/src/dynamic-agent.ts +143 -0
  66. package/src/event-types.ts +45 -0
  67. package/src/external-keys.ts +19 -0
  68. package/src/lifecycle.test-support.ts +220 -0
  69. package/src/media.ts +1105 -0
  70. package/src/mention-target.types.ts +5 -0
  71. package/src/mention.ts +114 -0
  72. package/src/message-action-contract.ts +13 -0
  73. package/src/monitor-state-runtime-api.ts +7 -0
  74. package/src/monitor-transport-runtime-api.ts +10 -0
  75. package/src/monitor.account.ts +492 -0
  76. package/src/monitor.acp-init-failure.lifecycle.test-support.ts +219 -0
  77. package/src/monitor.bot-identity.ts +86 -0
  78. package/src/monitor.bot-menu-handler.ts +165 -0
  79. package/src/monitor.bot-menu.lifecycle.test-support.ts +224 -0
  80. package/src/monitor.broadcast.reply-once.lifecycle.test-support.ts +264 -0
  81. package/src/monitor.card-action.lifecycle.test-support.ts +421 -0
  82. package/src/monitor.comment-notice-handler.ts +105 -0
  83. package/src/monitor.comment.ts +1386 -0
  84. package/src/monitor.message-handler.ts +350 -0
  85. package/src/monitor.reaction.lifecycle.test-support.ts +68 -0
  86. package/src/monitor.startup.ts +74 -0
  87. package/src/monitor.state.ts +170 -0
  88. package/src/monitor.synthetic-error.ts +18 -0
  89. package/src/monitor.test-mocks.ts +46 -0
  90. package/src/monitor.transport.ts +451 -0
  91. package/src/monitor.ts +100 -0
  92. package/src/outbound-runtime-api.ts +1 -0
  93. package/src/outbound.ts +785 -0
  94. package/src/perm-schema.ts +52 -0
  95. package/src/perm.ts +170 -0
  96. package/src/pins.ts +108 -0
  97. package/src/policy.ts +321 -0
  98. package/src/post.ts +275 -0
  99. package/src/probe.ts +166 -0
  100. package/src/processing-claims.ts +59 -0
  101. package/src/qr-terminal.ts +1 -0
  102. package/src/reactions.ts +123 -0
  103. package/src/reasoning-preview.ts +28 -0
  104. package/src/reply-dispatcher-runtime-api.ts +7 -0
  105. package/src/reply-dispatcher.ts +748 -0
  106. package/src/runtime.ts +9 -0
  107. package/src/secret-contract.ts +145 -0
  108. package/src/secret-input.ts +1 -0
  109. package/src/security-audit-shared.ts +69 -0
  110. package/src/security-audit.ts +1 -0
  111. package/src/send-result.ts +80 -0
  112. package/src/send-target.ts +35 -0
  113. package/src/send.ts +861 -0
  114. package/src/sequential-key.ts +28 -0
  115. package/src/sequential-queue.ts +86 -0
  116. package/src/session-conversation.ts +42 -0
  117. package/src/session-route.ts +48 -0
  118. package/src/setup-core.ts +51 -0
  119. package/src/setup-surface.ts +618 -0
  120. package/src/streaming-card.ts +571 -0
  121. package/src/subagent-hooks.ts +413 -0
  122. package/src/targets.ts +97 -0
  123. package/src/thread-bindings.ts +331 -0
  124. package/src/tool-account.ts +93 -0
  125. package/src/tool-factory-test-harness.ts +79 -0
  126. package/src/tool-result.ts +16 -0
  127. package/src/tools-config.ts +22 -0
  128. package/src/types.ts +106 -0
  129. package/src/typing.ts +214 -0
  130. package/src/wiki-schema.ts +69 -0
  131. package/src/wiki.ts +270 -0
  132. package/subagent-hooks-api.ts +31 -0
  133. package/tsconfig.json +16 -0
@@ -0,0 +1,154 @@
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 "autobot/plugin-sdk/string-coerce-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
+ }
@@ -0,0 +1,316 @@
1
+ /**
2
+ * Table utilities and row/column manipulation operations for Feishu documents.
3
+ *
4
+ * Combines:
5
+ * - Adaptive column width calculation (content-proportional, CJK-aware)
6
+ * - Block cleaning for Descendant API (removes read-only fields)
7
+ * - Table row/column insert, delete, and merge operations
8
+ */
9
+
10
+ import type * as Lark from "@larksuiteoapi/node-sdk";
11
+ import type { FeishuBlockTable, FeishuDocxBlock } from "./docx-types.js";
12
+
13
+ // ============ Table Utilities ============
14
+
15
+ // Feishu table constraints
16
+ const MIN_COLUMN_WIDTH = 50; // Feishu API minimum
17
+ const MAX_COLUMN_WIDTH = 400; // Reasonable maximum for readability
18
+ const DEFAULT_TABLE_WIDTH = 730; // Approximate Feishu page content width
19
+
20
+ /**
21
+ * Calculate adaptive column widths based on cell content length.
22
+ *
23
+ * Algorithm:
24
+ * 1. For each column, find the max content length across all rows
25
+ * 2. Weight CJK characters as 2x width (they render wider)
26
+ * 3. Calculate proportional widths based on content length
27
+ * 4. Apply min/max constraints
28
+ * 5. Redistribute remaining space to fill total table width
29
+ *
30
+ * Total width is derived from the original column_width values returned
31
+ * by the Convert API, ensuring tables match Feishu's expected dimensions.
32
+ *
33
+ * @param blocks - Array of blocks from Convert API
34
+ * @param tableBlockId - The block_id of the table block
35
+ * @returns Array of column widths in pixels
36
+ */
37
+ function normalizeChildBlockIds(children: string[] | string | undefined): string[] {
38
+ if (Array.isArray(children)) {
39
+ return children;
40
+ }
41
+ return typeof children === "string" ? [children] : [];
42
+ }
43
+
44
+ function omitParentId(block: FeishuDocxBlock): FeishuDocxBlock {
45
+ const cleanBlock = { ...block };
46
+ delete cleanBlock.parent_id;
47
+ return cleanBlock;
48
+ }
49
+
50
+ function createDescendantTable(
51
+ table: FeishuBlockTable,
52
+ adaptiveWidths: number[] | undefined,
53
+ ): FeishuBlockTable {
54
+ const { row_size, column_size } = table.property || {};
55
+ return {
56
+ property: {
57
+ row_size,
58
+ column_size,
59
+ ...(adaptiveWidths?.length ? { column_width: adaptiveWidths } : {}),
60
+ },
61
+ };
62
+ }
63
+
64
+ function calculateAdaptiveColumnWidths(blocks: FeishuDocxBlock[], tableBlockId: string): number[] {
65
+ // Find the table block
66
+ const tableBlock = blocks.find((b) => b.block_id === tableBlockId && b.block_type === 31);
67
+
68
+ if (!tableBlock?.table?.property) {
69
+ return [];
70
+ }
71
+
72
+ const { row_size, column_size, column_width: originalWidths } = tableBlock.table.property;
73
+ if (!row_size || !column_size) {
74
+ return [];
75
+ }
76
+
77
+ // Use original total width from Convert API, or fall back to default
78
+ const totalWidth =
79
+ originalWidths && originalWidths.length > 0
80
+ ? originalWidths.reduce((a: number, b: number) => a + b, 0)
81
+ : DEFAULT_TABLE_WIDTH;
82
+ const cellIds = normalizeChildBlockIds(tableBlock.children);
83
+
84
+ // Build block lookup map
85
+ const blockMap = new Map<string, FeishuDocxBlock>();
86
+ for (const block of blocks) {
87
+ if (block.block_id) {
88
+ blockMap.set(block.block_id, block);
89
+ }
90
+ }
91
+
92
+ // Extract text content from a table cell
93
+ function getCellText(cellId: string): string {
94
+ const cell = blockMap.get(cellId);
95
+ let text = "";
96
+ const childIds = normalizeChildBlockIds(cell?.children);
97
+
98
+ for (const childId of childIds) {
99
+ const child = blockMap.get(childId);
100
+ if (child?.text?.elements) {
101
+ for (const elem of child.text.elements) {
102
+ if (elem.text_run?.content) {
103
+ text += elem.text_run.content;
104
+ }
105
+ }
106
+ }
107
+ }
108
+ return text;
109
+ }
110
+
111
+ // Calculate weighted length (CJK chars count as 2)
112
+ // CJK (Chinese/Japanese/Korean) characters render ~2x wider than ASCII
113
+ function getWeightedLength(text: string): number {
114
+ return Array.from(text).reduce((sum, char) => {
115
+ return sum + (char.charCodeAt(0) > 255 ? 2 : 1);
116
+ }, 0);
117
+ }
118
+
119
+ // Find max content length per column
120
+ const maxLengths = Array.from({ length: column_size }, () => 0);
121
+
122
+ for (let row = 0; row < row_size; row++) {
123
+ for (let col = 0; col < column_size; col++) {
124
+ const cellIndex = row * column_size + col;
125
+ const cellId = cellIds[cellIndex];
126
+ if (cellId) {
127
+ const content = getCellText(cellId);
128
+ const length = getWeightedLength(content);
129
+ maxLengths[col] = Math.max(maxLengths[col], length);
130
+ }
131
+ }
132
+ }
133
+
134
+ // Handle empty table: distribute width equally, clamped to [MIN, MAX] so
135
+ // wide tables (e.g. 15+ columns) don't produce sub-50 widths that Feishu
136
+ // rejects as invalid column_width values.
137
+ const totalLength = maxLengths.reduce((a, b) => a + b, 0);
138
+ if (totalLength === 0) {
139
+ const equalWidth = Math.max(
140
+ MIN_COLUMN_WIDTH,
141
+ Math.min(MAX_COLUMN_WIDTH, Math.floor(totalWidth / column_size)),
142
+ );
143
+ return Array.from({ length: column_size }, () => equalWidth);
144
+ }
145
+
146
+ // Calculate proportional widths
147
+ let widths = maxLengths.map((len) => {
148
+ const proportion = len / totalLength;
149
+ return Math.round(proportion * totalWidth);
150
+ });
151
+
152
+ // Apply min/max constraints
153
+ widths = widths.map((w) => Math.max(MIN_COLUMN_WIDTH, Math.min(MAX_COLUMN_WIDTH, w)));
154
+
155
+ // Redistribute remaining space to fill total width
156
+ let remaining = totalWidth - widths.reduce((a, b) => a + b, 0);
157
+ while (remaining > 0) {
158
+ // Find columns that can still grow (not at max)
159
+ const growable = widths.map((w, i) => (w < MAX_COLUMN_WIDTH ? i : -1)).filter((i) => i >= 0);
160
+ if (growable.length === 0) {
161
+ break;
162
+ }
163
+
164
+ // Distribute evenly among growable columns
165
+ const perColumn = Math.floor(remaining / growable.length);
166
+ if (perColumn === 0) {
167
+ break;
168
+ }
169
+
170
+ for (const i of growable) {
171
+ const add = Math.min(perColumn, MAX_COLUMN_WIDTH - widths[i]);
172
+ widths[i] += add;
173
+ remaining -= add;
174
+ }
175
+ }
176
+
177
+ return widths;
178
+ }
179
+
180
+ /**
181
+ * Clean blocks for Descendant API with adaptive column widths.
182
+ *
183
+ * - Removes parent_id from all blocks
184
+ * - Fixes children type (string → array) for TableCell blocks
185
+ * - Removes merge_info (read-only, causes API error)
186
+ * - Calculates and applies adaptive column_width for tables
187
+ *
188
+ * @param blocks - Array of blocks from Convert API
189
+ * @returns Cleaned blocks ready for Descendant API
190
+ */
191
+ export function cleanBlocksForDescendant(blocks: FeishuDocxBlock[]): FeishuDocxBlock[] {
192
+ // Pre-calculate adaptive widths for all tables
193
+ const tableWidths = new Map<string, number[]>();
194
+ for (const block of blocks) {
195
+ if (block.block_type === 31 && block.block_id) {
196
+ const widths = calculateAdaptiveColumnWidths(blocks, block.block_id);
197
+ tableWidths.set(block.block_id, widths);
198
+ }
199
+ }
200
+
201
+ return blocks.map((block) => {
202
+ const cleanBlock = omitParentId(block);
203
+
204
+ // Fix: Convert API sometimes returns children as string for TableCell
205
+ if (cleanBlock.block_type === 32 && typeof cleanBlock.children === "string") {
206
+ cleanBlock.children = [cleanBlock.children];
207
+ }
208
+
209
+ // Clean table blocks
210
+ if (cleanBlock.block_type === 31 && cleanBlock.table) {
211
+ const adaptiveWidths = block.block_id ? tableWidths.get(block.block_id) : undefined;
212
+ cleanBlock.table = createDescendantTable(cleanBlock.table, adaptiveWidths);
213
+ }
214
+
215
+ return cleanBlock;
216
+ });
217
+ }
218
+
219
+ // ============ Table Row/Column Operations ============
220
+
221
+ export async function insertTableRow(
222
+ client: Lark.Client,
223
+ docToken: string,
224
+ blockId: string,
225
+ rowIndex: number = -1,
226
+ ) {
227
+ const res = await client.docx.documentBlock.patch({
228
+ path: { document_id: docToken, block_id: blockId },
229
+ data: { insert_table_row: { row_index: rowIndex } },
230
+ });
231
+ if (res.code !== 0) {
232
+ throw new Error(res.msg);
233
+ }
234
+ return { success: true, block: res.data?.block };
235
+ }
236
+
237
+ export async function insertTableColumn(
238
+ client: Lark.Client,
239
+ docToken: string,
240
+ blockId: string,
241
+ columnIndex: number = -1,
242
+ ) {
243
+ const res = await client.docx.documentBlock.patch({
244
+ path: { document_id: docToken, block_id: blockId },
245
+ data: { insert_table_column: { column_index: columnIndex } },
246
+ });
247
+ if (res.code !== 0) {
248
+ throw new Error(res.msg);
249
+ }
250
+ return { success: true, block: res.data?.block };
251
+ }
252
+
253
+ export async function deleteTableRows(
254
+ client: Lark.Client,
255
+ docToken: string,
256
+ blockId: string,
257
+ rowStart: number,
258
+ rowCount: number = 1,
259
+ ) {
260
+ const res = await client.docx.documentBlock.patch({
261
+ path: { document_id: docToken, block_id: blockId },
262
+ data: { delete_table_rows: { row_start_index: rowStart, row_end_index: rowStart + rowCount } },
263
+ });
264
+ if (res.code !== 0) {
265
+ throw new Error(res.msg);
266
+ }
267
+ return { success: true, rows_deleted: rowCount, block: res.data?.block };
268
+ }
269
+
270
+ export async function deleteTableColumns(
271
+ client: Lark.Client,
272
+ docToken: string,
273
+ blockId: string,
274
+ columnStart: number,
275
+ columnCount: number = 1,
276
+ ) {
277
+ const res = await client.docx.documentBlock.patch({
278
+ path: { document_id: docToken, block_id: blockId },
279
+ data: {
280
+ delete_table_columns: {
281
+ column_start_index: columnStart,
282
+ column_end_index: columnStart + columnCount,
283
+ },
284
+ },
285
+ });
286
+ if (res.code !== 0) {
287
+ throw new Error(res.msg);
288
+ }
289
+ return { success: true, columns_deleted: columnCount, block: res.data?.block };
290
+ }
291
+
292
+ export async function mergeTableCells(
293
+ client: Lark.Client,
294
+ docToken: string,
295
+ blockId: string,
296
+ rowStart: number,
297
+ rowEnd: number,
298
+ columnStart: number,
299
+ columnEnd: number,
300
+ ) {
301
+ const res = await client.docx.documentBlock.patch({
302
+ path: { document_id: docToken, block_id: blockId },
303
+ data: {
304
+ merge_table_cells: {
305
+ row_start_index: rowStart,
306
+ row_end_index: rowEnd,
307
+ column_start_index: columnStart,
308
+ column_end_index: columnEnd,
309
+ },
310
+ },
311
+ });
312
+ if (res.code !== 0) {
313
+ throw new Error(res.msg);
314
+ }
315
+ return { success: true, block: res.data?.block };
316
+ }
@@ -0,0 +1,38 @@
1
+ type FeishuBlockText = {
2
+ elements?: Array<{
3
+ text_run?: {
4
+ content?: string;
5
+ };
6
+ }>;
7
+ };
8
+
9
+ type FeishuBlockTableProperty = {
10
+ row_size?: number;
11
+ column_size?: number;
12
+ column_width?: number[];
13
+ };
14
+
15
+ export type FeishuBlockTable = {
16
+ property?: FeishuBlockTableProperty;
17
+ merge_info?: Array<{ row_span?: number; col_span?: number }>;
18
+ cells?: string[];
19
+ };
20
+
21
+ export type FeishuDocxBlock = {
22
+ block_id?: string;
23
+ parent_id?: string;
24
+ children?: string[] | string;
25
+ block_type: number;
26
+ text?: FeishuBlockText;
27
+ table?: FeishuBlockTable;
28
+ image?: object;
29
+ [key: string]: object | string | number | boolean | string[] | undefined;
30
+ };
31
+
32
+ export type FeishuDocxBlockChild = {
33
+ block_id?: string;
34
+ parent_id?: string;
35
+ block_type?: number;
36
+ children?: string[] | FeishuDocxBlockChild[];
37
+ table?: FeishuBlockTable;
38
+ };