import { z } from "zod";

/**
 * Reusable Zod schema for cursor-based pagination response metadata.
 * Use in any contract response that returns a cursor-paginated list.
 */
const createContractCursorPaginationResponseMetadataSchema = z
    .object({
        cursor: z.string().optional().meta({
            description: "Cursor used for this page (echoed back).",
        }),
        nextCursor: z.string().optional().meta({
            description: "Cursor for the next page. Omit when there is no next page.",
        }),
        dataCount: z.number().int().nonnegative().meta({
            description: "Number of items in this response.",
        }),
    })
    .meta({
        id: "CursorPaginationResponseMetadata",
        description: "Cursor-based pagination metadata for list responses.",
    });

type CursorPaginationResponseMetadata = z.infer<typeof createContractCursorPaginationResponseMetadataSchema>;

export { createContractCursorPaginationResponseMetadataSchema, type CursorPaginationResponseMetadata };
