|
1 | 1 | import type * as Lark from "@larksuiteoapi/node-sdk"; |
| 2 | +import { optionalPositiveIntegerSchema } from "openclaw/plugin-sdk/channel-actions"; |
2 | 3 | import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; |
| 4 | +import { readPositiveIntegerParam } from "openclaw/plugin-sdk/param-readers"; |
3 | 5 | import { Type, type TSchema } from "typebox"; |
4 | 6 | import type { OpenClawPluginApi } from "../runtime-api.js"; |
5 | 7 | import { listEnabledFeishuAccounts } from "./accounts.js"; |
@@ -208,6 +210,13 @@ async function listRecords(
|
208 | 210 | }; |
209 | 211 | } |
210 | 212 | |
| 213 | +function readBitableListRecordsPageSize(params: Record<string, unknown>): number | undefined { |
| 214 | +return readPositiveIntegerParam(params, "page_size", { |
| 215 | +max: 500, |
| 216 | +message: "page_size must be a positive integer between 1 and 500", |
| 217 | +}); |
| 218 | +} |
| 219 | + |
211 | 220 | async function getRecord(client: Lark.Client, appToken: string, tableId: string, recordId: string) { |
212 | 221 | const res = await client.bitable.appTableRecord.get({ |
213 | 222 | path: { app_token: appToken, table_id: tableId, record_id: recordId }, |
@@ -496,13 +505,10 @@ const ListRecordsSchema = Type.Object({
|
496 | 505 | description: "Bitable app token (use feishu_bitable_get_meta to get from URL)", |
497 | 506 | }), |
498 | 507 | table_id: Type.String({ description: "Table ID (from URL: ?table=YYY)" }), |
499 | | -page_size: Type.Optional( |
500 | | -Type.Number({ |
501 | | -description: "Number of records per page (1-500, default 100)", |
502 | | -minimum: 1, |
503 | | -maximum: 500, |
504 | | -}), |
505 | | -), |
| 508 | +page_size: optionalPositiveIntegerSchema({ |
| 509 | +description: "Number of records per page (1-500, default 100)", |
| 510 | +maximum: 500, |
| 511 | +}), |
506 | 512 | page_token: Type.Optional( |
507 | 513 | Type.String({ description: "Pagination token from previous response" }), |
508 | 514 | ), |
@@ -655,7 +661,7 @@ export function registerFeishuBitableTools(api: OpenClawPluginApi) {
|
655 | 661 | getClient(params, defaultAccountId), |
656 | 662 | params.app_token, |
657 | 663 | params.table_id, |
658 | | -params.page_size, |
| 664 | +readBitableListRecordsPageSize(params as Record<string, unknown>), |
659 | 665 | params.page_token, |
660 | 666 | ); |
661 | 667 | }, |
|