Skip to content

Commit 7321f6b

Browse files
committed
feat: 更新批量操作请求和响应模式,添加删除和更新选项描述
1 parent f6ed8d8 commit 7321f6b

6 files changed

Lines changed: 50 additions & 20 deletions

File tree

content/docs/references/api/protocol.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const result = BatchDataRequestSchema.parse(data);
126126
| :--- | :--- | :--- | :--- |
127127
| **object** | `string` || Object name |
128128
| **ids** | `string[]` || Array of record IDs to delete |
129-
| **options** | `object` | optional | |
129+
| **options** | `object` | optional | Delete options |
130130

131131
---
132132

@@ -412,7 +412,7 @@ const result = BatchDataRequestSchema.parse(data);
412412
| :--- | :--- | :--- | :--- |
413413
| **object** | `string` || Object name |
414414
| **records** | `object[]` || Array of updates |
415-
| **options** | `object` | optional | |
415+
| **options** | `object` | optional | Update options |
416416

417417
---
418418

packages/spec/json-schema/api/DeleteManyDataRequest.json

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,29 @@
1818
"options": {
1919
"type": "object",
2020
"properties": {
21-
"allOrNone": {
21+
"atomic": {
2222
"type": "boolean",
23-
"description": "Atomic transaction mode"
23+
"default": true,
24+
"description": "If true, rollback entire batch on any failure (transaction mode)"
25+
},
26+
"returnRecords": {
27+
"type": "boolean",
28+
"default": false,
29+
"description": "If true, return full record data in response"
30+
},
31+
"continueOnError": {
32+
"type": "boolean",
33+
"default": false,
34+
"description": "If true (and atomic=false), continue processing remaining records after errors"
35+
},
36+
"validateOnly": {
37+
"type": "boolean",
38+
"default": false,
39+
"description": "If true, validate records without persisting changes (dry-run mode)"
2440
}
2541
},
26-
"additionalProperties": false
42+
"additionalProperties": false,
43+
"description": "Delete options"
2744
}
2845
},
2946
"required": [

packages/spec/json-schema/api/UpdateManyDataRequest.json

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,29 @@
3434
"options": {
3535
"type": "object",
3636
"properties": {
37-
"allOrNone": {
37+
"atomic": {
3838
"type": "boolean",
39-
"description": "Atomic transaction mode"
39+
"default": true,
40+
"description": "If true, rollback entire batch on any failure (transaction mode)"
41+
},
42+
"returnRecords": {
43+
"type": "boolean",
44+
"default": false,
45+
"description": "If true, return full record data in response"
46+
},
47+
"continueOnError": {
48+
"type": "boolean",
49+
"default": false,
50+
"description": "If true (and atomic=false), continue processing remaining records after errors"
51+
},
52+
"validateOnly": {
53+
"type": "boolean",
54+
"default": false,
55+
"description": "If true, validate records without persisting changes (dry-run mode)"
4056
}
4157
},
42-
"additionalProperties": false
58+
"additionalProperties": false,
59+
"description": "Update options"
4360
}
4461
},
4562
"required": [

packages/spec/src/api/batch.zod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const BatchUpdateRequestSchema = z.object({
8686
options: BatchOptionsSchema.optional().describe('Batch operation options'),
8787
});
8888

89-
export type BatchUpdateRequest = z.infer<typeof BatchUpdateRequestSchema>;
89+
export type BatchUpdateRequest = z.input<typeof BatchUpdateRequestSchema>;
9090

9191
/**
9292
* Simplified Batch Update Request (for updateMany API)
@@ -107,7 +107,7 @@ export const UpdateManyRequestSchema = z.object({
107107
options: BatchOptionsSchema.optional().describe('Update options'),
108108
});
109109

110-
export type UpdateManyRequest = z.infer<typeof UpdateManyRequestSchema>;
110+
export type UpdateManyRequest = z.input<typeof UpdateManyRequestSchema>;
111111

112112
// ==========================================
113113
// Batch Response Schemas

packages/spec/src/api/protocol.zod.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { z } from 'zod';
2-
import { BatchUpdateRequestSchema, BatchUpdateResponseSchema } from './batch.zod';
2+
import { BatchUpdateRequestSchema, BatchUpdateResponseSchema, BatchOptionsSchema } from './batch.zod';
33
import { MetadataCacheRequestSchema, MetadataCacheResponseSchema } from './http-cache.zod';
44
import {
55
CreateViewRequestSchema,
@@ -266,9 +266,7 @@ export const UpdateManyDataRequestSchema = z.object({
266266
id: z.string().describe('Record ID'),
267267
data: z.record(z.any()).describe('Fields to update'),
268268
})).describe('Array of updates'),
269-
options: z.object({
270-
allOrNone: z.boolean().optional().describe('Atomic transaction mode'),
271-
}).optional(),
269+
options: BatchOptionsSchema.optional().describe('Update options'),
272270
});
273271

274272
/**
@@ -283,9 +281,7 @@ export const UpdateManyDataResponseSchema = BatchUpdateResponseSchema;
283281
export const DeleteManyDataRequestSchema = z.object({
284282
object: z.string().describe('Object name'),
285283
ids: z.array(z.string()).describe('Array of record IDs to delete'),
286-
options: z.object({
287-
allOrNone: z.boolean().optional().describe('Atomic transaction mode'),
288-
}).optional(),
284+
options: BatchOptionsSchema.optional().describe('Delete options'),
289285
});
290286

291287
/**

packages/spec/src/api/view-storage.zod.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export const CreateViewRequestSchema = z.object({
187187
settings: z.record(z.any()).optional(),
188188
});
189189

190-
export type CreateViewRequest = z.infer<typeof CreateViewRequestSchema>;
190+
export type CreateViewRequest = z.input<typeof CreateViewRequestSchema>;
191191

192192
/**
193193
* Update View Request Schema
@@ -196,7 +196,7 @@ export const UpdateViewRequestSchema = CreateViewRequestSchema.partial().extend(
196196
id: z.string().describe('View ID to update'),
197197
});
198198

199-
export type UpdateViewRequest = z.infer<typeof UpdateViewRequestSchema>;
199+
export type UpdateViewRequest = z.input<typeof UpdateViewRequestSchema>;
200200

201201
/**
202202
* List Views Request Schema
@@ -211,7 +211,7 @@ export const ListViewsRequestSchema = z.object({
211211
offset: z.number().optional().default(0).describe('Offset for pagination'),
212212
});
213213

214-
export type ListViewsRequest = z.infer<typeof ListViewsRequestSchema>;
214+
export type ListViewsRequest = z.input<typeof ListViewsRequestSchema>;
215215

216216
/**
217217
* View Response Schema

0 commit comments

Comments
 (0)