json-api-nestjs
Version:
JsonApi Plugin for NestJs
51 lines (50 loc) • 1.75 kB
TypeScript
import { z } from 'zod';
import { TypeForId } from '../../types';
export declare function zodRelData<T extends string>(typeName: T, typeId: TypeForId): z.ZodEffects<z.ZodObject<{
id: z.ZodString;
type: z.ZodLiteral<T>;
}, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
id: z.ZodString;
type: z.ZodLiteral<T>;
}>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
id: z.ZodString;
type: z.ZodLiteral<T>;
}>, any>[k]; } : never, z.baseObjectInputType<{
id: z.ZodString;
type: z.ZodLiteral<T>;
}> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<{
id: z.ZodString;
type: z.ZodLiteral<T>;
}>[k_1]; } : never>, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
id: z.ZodString;
type: z.ZodLiteral<T>;
}>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
id: z.ZodString;
type: z.ZodLiteral<T>;
}>, any>[k]; } : never, z.baseObjectInputType<{
id: z.ZodString;
type: z.ZodLiteral<T>;
}> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<{
id: z.ZodString;
type: z.ZodLiteral<T>;
}>[k_1]; } : never>;
export type ZodRelData<T extends string> = ReturnType<typeof zodRelData<T>>;
export type RelData<T extends string> = z.infer<ZodRelData<T>>;
export declare function zodData(): z.ZodEffects<z.ZodObject<{
type: z.ZodString;
id: z.ZodString;
}, "strict", z.ZodTypeAny, {
id: string;
type: string;
}, {
id: string;
type: string;
}>, {
id: string;
type: string;
}, {
id: string;
type: string;
}>;
export type ZodData = ReturnType<typeof zodData>;
export type Data = z.infer<ZodData>;