|
1 | 1 | import CloudBase from "@cloudbase/manager-node"; |
2 | 2 | import { z } from "zod"; |
3 | | -import { getCloudBaseManager, logCloudBaseResult } from "../cloudbase-manager.js"; |
| 3 | +import { |
| 4 | + getCloudBaseManager, |
| 5 | + logCloudBaseResult, |
| 6 | +} from "../cloudbase-manager.js"; |
4 | 7 | import { ExtendedMcpServer } from "../server.js"; |
5 | 8 | import { Logger } from "../types.js"; |
6 | 9 |
|
@@ -217,8 +220,11 @@ checkIndex: 检查索引是否存在`), |
217 | 220 | title: "修改 NoSQL 数据库结构", |
218 | 221 | description: "修改 NoSQL 数据库结构", |
219 | 222 | inputSchema: { |
220 | | - action: z.enum(["createCollection", "updateCollection", "deleteCollection"]) |
221 | | - .describe(`createCollection: 创建集合 |
| 223 | + action: z.enum([ |
| 224 | + "createCollection", |
| 225 | + "updateCollection", |
| 226 | + "deleteCollection", |
| 227 | + ]).describe(`createCollection: 创建集合 |
222 | 228 | updateCollection: 更新集合 |
223 | 229 | deleteCollection: 删除集合`), |
224 | 230 | collectionName: z.string().describe("集合名称"), |
@@ -320,9 +326,8 @@ deleteCollection: 删除集合`), |
320 | 326 | success: true, |
321 | 327 | requestId: result.RequestId, |
322 | 328 | action, |
323 | | - message: result.Exists === false |
324 | | - ? "集合不存在" |
325 | | - : "云开发数据库集合删除成功", |
| 329 | + message: |
| 330 | + result.Exists === false ? "集合不存在" : "云开发数据库集合删除成功", |
326 | 331 | }; |
327 | 332 | if (result.Exists === false) { |
328 | 333 | body.exists = false; |
@@ -358,9 +363,21 @@ deleteCollection: 删除集合`), |
358 | 363 | .optional() |
359 | 364 | .describe("返回字段投影(对象或字符串,推荐对象)"), |
360 | 365 | sort: z |
361 | | - .union([z.object({}).passthrough(), z.string()]) |
| 366 | + .union([ |
| 367 | + z.array( |
| 368 | + z |
| 369 | + .object({ |
| 370 | + key: z.string().describe("sort 字段名"), |
| 371 | + direction: z.number().describe("排序方向,1:升序,-1:降序"), |
| 372 | + }) |
| 373 | + .passthrough(), |
| 374 | + ), |
| 375 | + z.string(), |
| 376 | + ]) |
362 | 377 | .optional() |
363 | | - .describe("排序条件(对象或字符串,推荐对象)"), |
| 378 | + .describe( |
| 379 | + "排序条件,使用对象或字符串。", |
| 380 | + ), |
364 | 381 | limit: z.number().optional().describe("返回数量限制"), |
365 | 382 | offset: z.number().optional().describe("跳过的记录数"), |
366 | 383 | }, |
@@ -416,8 +433,11 @@ deleteCollection: 删除集合`), |
416 | 433 | title: "修改 NoSQL 数据库数据记录", |
417 | 434 | description: "修改 NoSQL 数据库数据记录", |
418 | 435 | inputSchema: { |
419 | | - action: z.enum(["insert", "update", "delete"]) |
420 | | - .describe(`insert: 插入数据(新增文档)\nupdate: 更新数据\ndelete: 删除数据`), |
| 436 | + action: z |
| 437 | + .enum(["insert", "update", "delete"]) |
| 438 | + .describe( |
| 439 | + `insert: 插入数据(新增文档)\nupdate: 更新数据\ndelete: 删除数据`, |
| 440 | + ), |
421 | 441 | collectionName: z.string().describe("集合名称"), |
422 | 442 | documents: z |
423 | 443 | .array(z.object({}).passthrough()) |
|
0 commit comments