UNPKG

dynamodb-toolbox

Version:

Lightweight and type-safe query builder for DynamoDB and TypeScript.

19 lines (18 loc) 2.2 kB
import type { z } from 'zod'; import type { AnyOfSchema, AnySchema, BinarySchema, BooleanSchema, ItemSchema, ListSchema, MapSchema, NullSchema, NumberSchema, RecordSchema, Schema, SetSchema, StringSchema } from '../../../../schema/index.js'; import type { AnyZodParser } from './any.js'; import type { AnyOfZodParser } from './anyOf.js'; import type { BinaryZodParser } from './binary.js'; import type { BooleanZodParser } from './boolean.js'; import type { ItemZodParser } from './item.js'; import type { ListZodParser } from './list.js'; import type { MapZodParser } from './map.js'; import type { NullZodParser } from './null.js'; import type { NumberZodParser } from './number.js'; import type { RecordZodParser } from './record.js'; import type { SetZodParser } from './set.js'; import type { StringZodParser } from './string.js'; import type { ZodParserOptions } from './types.js'; export type ZodParser<SCHEMA extends Schema, OPTIONS extends ZodParserOptions = {}> = SCHEMA extends ItemSchema ? ItemZodParser<SCHEMA, OPTIONS> : SCHEMA extends Schema ? SchemaZodParser<SCHEMA, OPTIONS> : never; export type SchemaZodParser<SCHEMA extends Schema, OPTIONS extends ZodParserOptions = {}> = Schema extends SCHEMA ? z.ZodTypeAny : (SCHEMA extends AnySchema ? AnyZodParser<SCHEMA, OPTIONS> : never) | (SCHEMA extends NullSchema ? NullZodParser<SCHEMA, OPTIONS> : never) | (SCHEMA extends BooleanSchema ? BooleanZodParser<SCHEMA, OPTIONS> : never) | (SCHEMA extends NumberSchema ? NumberZodParser<SCHEMA, OPTIONS> : never) | (SCHEMA extends StringSchema ? StringZodParser<SCHEMA, OPTIONS> : never) | (SCHEMA extends BinarySchema ? BinaryZodParser<SCHEMA, OPTIONS> : never) | (SCHEMA extends SetSchema ? SetZodParser<SCHEMA, OPTIONS> : never) | (SCHEMA extends ListSchema ? ListZodParser<SCHEMA, OPTIONS> : never) | (SCHEMA extends MapSchema ? MapZodParser<SCHEMA, OPTIONS> : never) | (SCHEMA extends RecordSchema ? RecordZodParser<SCHEMA, OPTIONS> : never) | (SCHEMA extends AnyOfSchema ? AnyOfZodParser<SCHEMA, OPTIONS> : never); export declare const schemaZodParser: <SCHEMA extends Schema, OPTIONS extends ZodParserOptions = {}>(schema: SCHEMA, options?: OPTIONS) => SchemaZodParser<SCHEMA, OPTIONS>;