@@ -8,7 +8,9 @@ import { QuerySchema } from '../data/query.zod';
88export const ApiErrorSchema = z . object ( {
99 code : z . string ( ) . describe ( 'Error code (e.g. validation_error)' ) ,
1010 message : z . string ( ) . describe ( 'Readable error message' ) ,
11+ category : z . string ( ) . optional ( ) . describe ( 'Error category (e.g. validation, authorization)' ) ,
1112 details : z . any ( ) . optional ( ) . describe ( 'Additional error context (e.g. field validation errors)' ) ,
13+ requestId : z . string ( ) . optional ( ) . describe ( 'Request ID for tracking' ) ,
1214} ) ;
1315
1416export const BaseResponseSchema = z . object ( {
@@ -74,20 +76,31 @@ export const SingleRecordResponseSchema = BaseResponseSchema.extend({
7476export const ListRecordResponseSchema = BaseResponseSchema . extend ( {
7577 data : z . array ( RecordDataSchema ) . describe ( 'Array of matching records' ) ,
7678 pagination : z . object ( {
77- total : z . number ( ) . describe ( 'Total matching records count' ) ,
78- limit : z . number ( ) . describe ( 'Page size' ) ,
79- offset : z . number ( ) . describe ( 'Page offset' ) ,
79+ total : z . number ( ) . optional ( ) . describe ( 'Total matching records count' ) ,
80+ limit : z . number ( ) . optional ( ) . describe ( 'Page size' ) ,
81+ offset : z . number ( ) . optional ( ) . describe ( 'Page offset' ) ,
82+ cursor : z . string ( ) . optional ( ) . describe ( 'Cursor for next page' ) ,
83+ nextCursor : z . string ( ) . optional ( ) . describe ( 'Next cursor for pagination' ) ,
8084 hasMore : z . boolean ( ) . describe ( 'Are there more pages?' ) ,
8185 } ) . describe ( 'Pagination info' ) ,
8286} ) ;
8387
88+ /**
89+ * ID Request (Get/Delete)
90+ */
91+ export const IdRequestSchema = z . object ( {
92+ id : z . string ( ) . describe ( 'Record ID' ) ,
93+ } ) ;
94+
8495/**
8596 * Modification Result (for Batch/Bulk operations)
8697 */
8798export const ModificationResultSchema = z . object ( {
8899 id : z . string ( ) . optional ( ) . describe ( 'Record ID if processed' ) ,
89100 success : z . boolean ( ) ,
90101 errors : z . array ( ApiErrorSchema ) . optional ( ) ,
102+ index : z . number ( ) . optional ( ) . describe ( 'Index in original request' ) ,
103+ data : z . any ( ) . optional ( ) . describe ( 'Result data (e.g. created record)' ) ,
91104} ) ;
92105
93106/**
@@ -111,11 +124,11 @@ export const DeleteResponseSchema = BaseResponseSchema.extend({
111124/**
112125 * Standard API Contracts map
113126 * Used for generating SDKs and Documentation
114- */
115- export const ApiContracts = {
116- create : {
117- input : CreateRequestSchema ,
118- output : SingleRecordResponseSchema
127+ */ IdRequestSchema ,
128+ output : DeleteResponseSchema
129+ } ,
130+ get: {
131+ input : IdRequestSchema ,
119132 } ,
120133 update : {
121134 input : UpdateRequestSchema ,
0 commit comments