/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Sort direction. */ export const Dir = { Asc: "asc", Desc: "desc", } as const; /** * Sort direction. */ export type Dir = ClosedEnum; /** * Cursor-based pagination metadata for list responses. */ export type SeekPagination = { /** * The field being sorted on. */ orderBy?: string | undefined; /** * Sort direction. */ dir?: Dir | undefined; /** * Page size limit. */ limit?: number | undefined; /** * Cursor for the next page of results. Null if no more results. */ next?: string | null | undefined; /** * Cursor for the previous page of results. Null if on first page. */ prev?: string | null | undefined; }; /** @internal */ export const Dir$inboundSchema: z.ZodNativeEnum = z.nativeEnum(Dir); /** @internal */ export const Dir$outboundSchema: z.ZodNativeEnum = Dir$inboundSchema; /** @internal */ export const SeekPagination$inboundSchema: z.ZodType< SeekPagination, z.ZodTypeDef, unknown > = z.object({ order_by: z.string().optional(), dir: Dir$inboundSchema.optional(), limit: z.number().int().optional(), next: z.nullable(z.string()).optional(), prev: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "order_by": "orderBy", }); }); /** @internal */ export type SeekPagination$Outbound = { order_by?: string | undefined; dir?: string | undefined; limit?: number | undefined; next?: string | null | undefined; prev?: string | null | undefined; }; /** @internal */ export const SeekPagination$outboundSchema: z.ZodType< SeekPagination$Outbound, z.ZodTypeDef, SeekPagination > = z.object({ orderBy: z.string().optional(), dir: Dir$outboundSchema.optional(), limit: z.number().int().optional(), next: z.nullable(z.string()).optional(), prev: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { orderBy: "order_by", }); }); export function seekPaginationToJSON(seekPagination: SeekPagination): string { return JSON.stringify(SeekPagination$outboundSchema.parse(seekPagination)); } export function seekPaginationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SeekPagination$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SeekPagination' from JSON`, ); }