UNPKG

json-api-nestjs

Version:
20 lines (19 loc) 1.44 kB
import { z, ZodObject, ZodOptional } from 'zod'; import { ObjectLiteral } from '../../../../types'; import { ZodId, ZodType, ZodAttributes, ZodRelationships } from '../zod-share'; import { EntityProps, FieldWithType, PropsForField, RelationPrimaryColumnType, RelationPropsArray, RelationPropsTypeName, TypeForId } from '../../types'; type ZodInputPostShape<E extends ObjectLiteral, N extends string> = { id: ZodOptional<ZodId>; type: ZodType<N>; attributes: ZodAttributes<E>; relationships: ZodOptional<ZodRelationships<E>>; }; type ZodInputPostSchema<E extends ObjectLiteral, N extends string> = ZodObject<ZodInputPostShape<E, N>, 'strict'>; type ZodInputPostDataShape<E extends ObjectLiteral, N extends string> = { data: ZodInputPostSchema<E, N>; }; export declare function zodPost<E extends ObjectLiteral, N extends string>(typeId: TypeForId, typeName: N, fieldWithType: FieldWithType<E>, propsDb: PropsForField<E>, primaryColumn: EntityProps<E>, relationArrayProps: RelationPropsArray<E>, relationPopsName: RelationPropsTypeName<E>, primaryColumnType: RelationPrimaryColumnType<E>): ZodPost<E, N>; export type ZodPost<E extends ObjectLiteral, N extends string> = ZodObject<ZodInputPostDataShape<E, N>, 'strict'>; export type Post<E extends ObjectLiteral, N extends string = string> = z.infer<ZodPost<E, N>>; export type PostData<E extends ObjectLiteral, N extends string = string> = Post<E, N>['data']; export {};