UNPKG

@servemate/dto

Version:

Type-safe DTO package for ServeMate types and Zod validation. Shared across server and client.

86 lines 3.05 kB
import { z } from 'zod'; declare const sortOrders: { readonly ASC: "asc"; readonly DESC: "desc"; }; export declare const parseQueryArray: (query: string | string[] | undefined) => string[]; export declare const arrayQueryParamSchema: z.ZodUnion<[z.ZodEffects<z.ZodString, string[], string>, z.ZodArray<z.ZodString, "many">]>; /** * Schema for list properties using Zod library. * * This schema validates the structure of pagination-related properties. * * @constant * @type {ZodObject} * * @property {ZodNumber} page - The current page number. Must be a positive integer. Defaults to 1. * @property {ZodNumber} pageSize - The number of items per page. Must be a positive integer between 1 and 100. Defaults to 10. * @property {ZodNumber} totalPages - The total number of pages. Must be a number. * @property {ZodNumber} totalCount - The total count of items. Must be a positive integer. */ export declare const listPropsSchema: z.ZodObject<{ page: z.ZodDefault<z.ZodNumber>; pageSize: z.ZodDefault<z.ZodNumber>; totalPages: z.ZodNumber; totalCount: z.ZodNumber; }, "strip", z.ZodTypeAny, { page: number; pageSize: number; totalPages: number; totalCount: number; }, { totalPages: number; totalCount: number; page?: number | undefined; pageSize?: number | undefined; }>; export type ListPropsSchema = z.infer<typeof listPropsSchema>; export type ListReturnType<T> = { list: T[]; } & ListPropsSchema; /** * Schema for search criteria used in the application. * * This schema is based on `listPropsSchema` and includes the following properties: * * - `page`: Indicates the current page number. * - `pageSize`: Specifies the number of items per page. * - `sortOrder`: Defines the order in which items are sorted. It is an optional property and defaults to `sortOrders.ASC`. * * The `sortOrder` property uses a native enum `sortOrders` which should be defined elsewhere in the codebase. * * @constant * @type {ZodSchema} */ export declare const searchCriteriaSchema: z.ZodObject<Pick<{ page: z.ZodDefault<z.ZodNumber>; pageSize: z.ZodDefault<z.ZodNumber>; totalPages: z.ZodNumber; totalCount: z.ZodNumber; }, "page" | "pageSize"> & { sortOrder: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<{ readonly ASC: "asc"; readonly DESC: "desc"; }>>>; }, "strip", z.ZodTypeAny, { page: number; pageSize: number; sortOrder: "asc" | "desc"; }, { page?: number | undefined; pageSize?: number | undefined; sortOrder?: "asc" | "desc" | undefined; }>; /** * Represents the possible sort orders. * * This type is derived from the keys of the `sortOrders` object. * It allows for type-safe usage of sort order values throughout the application. */ export type SortOrders = (typeof sortOrders)[keyof typeof sortOrders]; /** * Type definition for the properties of a list, inferred from the `listPropsSchema` schema. */ export type ListProps = z.infer<typeof listPropsSchema>; export {}; //# sourceMappingURL=global.d.ts.map