Download packages/kap-server/src/protocol/pagination.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 873 Bytes
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/kap-server/src/protocol/pagination.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/kap-server/src/protocol/pagination.ts
-
curl -L -o pagination.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/kap-server/src/protocol/pagination.ts
873 Bytes
| import { z } from 'zod'; | |
| import { ErrorCode } from './error-codes'; | |
| export const cursorQuerySchema = z | |
| .object({ | |
| before_id: z.string().min(1).optional(), | |
| after_id: z.string().min(1).optional(), | |
| page_size: z.number().int().min(1).max(100).optional(), | |
| }) | |
| .superRefine((value, ctx) => { | |
| if (value.before_id !== undefined && value.after_id !== undefined) { | |
| ctx.addIssue({ | |
| code: 'custom', | |
| message: 'before_id and after_id are mutually exclusive', | |
| path: ['before_id'], | |
| params: { code: ErrorCode.VALIDATION_FAILED }, | |
| }); | |
| } | |
| }); | |
| export type CursorQuery = z.infer<typeof cursorQuerySchema>; | |
| export const pageResponseSchema = <T extends z.ZodTypeAny>(item: T) => | |
| z.object({ | |
| items: z.array(item), | |
| has_more: z.boolean(), | |
| }); | |
| export interface PageResponse<T> { | |
| items: T[]; | |
| has_more: boolean; | |
| } | |