UNPKG

@vulog/aima-core

Version:

Shared types and Zod schema helpers for pagination and patch actions.

42 lines (41 loc) 1.03 kB
import { z } from "zod"; //#region src/index.d.ts type PaginableOptions<T = void, S = string> = T extends void ? { page?: number; pageSize?: number; sort?: S; sortDirection?: 'ASC' | 'DESC'; } : { page?: number; pageSize?: number; sort?: S; sortDirection?: 'ASC' | 'DESC'; filters?: T; }; declare const createPaginableOptionsSchema: <T extends z.ZodTypeAny, S extends z.ZodTypeAny>(optionsSchema?: T, sortSchema?: S) => z.ZodObject<{ filters?: T | undefined; page: z.ZodDefault<z.ZodNumber>; pageSize: z.ZodDefault<z.ZodNumber>; sort: S; sortDirection: z.ZodDefault<z.ZodOptional<z.ZodEnum<{ ASC: "ASC"; DESC: "DESC"; }>>>; }, z.core.$strip>; type PaginableResponse<T> = { data: T[]; page: number; pageSize: number; total: number; totalPages: number; }; type PatchAction<T extends string> = { op: 'add' | 'replace'; path: T; value: string; } | { op: 'remove'; path: T; }; //#endregion export { PaginableOptions, PaginableResponse, PatchAction, createPaginableOptionsSchema };