UNPKG

json-api-nestjs

Version:
20 lines (19 loc) 1.43 kB
import { z, ZodObject, ZodOptional } from 'zod'; import { ZodAttributes, ZodId, ZodRelationships, ZodType } from '../zod-share'; import { ObjectLiteral } from '../../../../types'; import { EntityProps, FieldWithType, PropsForField, RelationPrimaryColumnType, RelationPropsArray, RelationPropsTypeName, TypeForId } from '../../types'; import { ZodPost } from '../zod-input-post-schema'; type ZodPatchPatchShape<E extends ObjectLiteral, N extends string> = { id: ZodId; type: ZodType<N>; attributes: ZodOptional<ZodAttributes<E, true>>; relationships: ZodOptional<ZodRelationships<E, true>>; }; type ZodInputPatchSchema<E extends ObjectLiteral, N extends string> = ZodObject<ZodPatchPatchShape<E, N>, 'strict'>; type ZodInputPatchDataShape<E extends ObjectLiteral, N extends string> = { data: ZodInputPatchSchema<E, N>; }; export declare function zodPatch<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>): ZodPatch<E, N>; export type ZodPatch<E extends ObjectLiteral, N extends string> = ZodObject<ZodInputPatchDataShape<E, N>, 'strict'>; export type PatchData<E extends ObjectLiteral, N extends string = string> = z.infer<ZodPost<E, N>>['data']; export {};