rag-kb-system / scripts /test-notes-pagination.ts
duqing2026's picture
同步 hf
9ed89c8
import * as dotenv from "dotenv";
import { SimpleYuqueLoader } from "../src/lib/yuque-service";
dotenv.config({ path: ".env.local" });
dotenv.config();
async function test() {
const token = process.env.YUQUE_TOKEN;
if (!token) {
console.error("缺少环境变量 YUQUE_TOKEN");
process.exit(1);
}
const loader = new SimpleYuqueLoader(token, "NOTES");
const limits = [30, 50];
for (const limit of limits) {
try {
const res = await loader.fetchAPI(`/notes?offset=0&limit=${limit}`);
const list = Array.isArray(res?.data?.notes) ? res.data.notes : [];
console.log(`请求 limit=${limit} -> 返回 ${list.length} 条`);
if (list.length > 0) {
console.log(`示例ID范围: ${list[0]?.id} ... ${list[list.length - 1]?.id}`);
}
} catch (e) {
console.error(`请求 limit=${limit} 失败:`, e instanceof Error ? e.message : String(e));
}
}
}
test().catch((e) => {
console.error("测试失败:", e);
process.exit(1);
});