import { AnyEnumType } from "./EnumType.js"; import { AnyFieldType } from "./FieldType.js"; import { SchemaModelType } from "./SchemaModelType.js"; import * as z$1 from "zod"; import { Maybe } from "graphql/jsutils/Maybe"; //#region src/SchemaModel.d.ts /** * All types that can be used as field types in a SchemaModel. * Supports FieldType, EnumType, nested SchemaModel, or any SchemaType implementation. */ type FieldLike = AnyFieldType | AnyEnumType | AnySchemaModel | SchemaModelType; /** Field configuration for a SchemaModel property. */ interface SchemaFieldConfig { type: Type; isOptional: boolean; /** When present and true, the field is an array */ isArray?: true; } type SchemaModelFieldsAnyConfig = Record>; /** Model definition: name and fields. */ interface SchemaModelConfig { name: string; description?: Maybe; fields: Fields; } /** * Named object model built from FieldType/EnumType/SchemaModel fields. * Provides zod and GraphQL input helpers, and supports arrays/optional fields. */ declare class SchemaModel implements SchemaModelType { readonly config: SchemaModelConfig; constructor(config: SchemaModelConfig); /** * Build a typed ZodObject from the model fields, preserving each field's * Zod schema and optionality at the type level when possible. */ getZod(): TopLevelZodFromModel; /** Input object name for GraphQL builder adapters. */ getPothosInput(): string; } /** * Union of all types that can serve as a schema model. * This is the main type expected by OperationSpec, EventSpec, FormSpec, etc. * * Supports: * - SchemaModel instances (native ContractSpec types) * - Any SchemaType implementation (ZodSchemaType, JsonSchemaType, etc.) */ type AnySchemaModel = SchemaModel | SchemaModelType; /** * Type guard to check if a value is a SchemaModel (not just any SchemaType). * Use this when you need to access SchemaModel-specific properties like `config`. * * @param model - The model to check * @returns True if the model is a SchemaModel instance * * @example * ```typescript * if (isSchemaModel(model)) { * // TypeScript knows model.config is available * console.log(model.config.name); * } * ``` */ declare function isSchemaModel(model: AnySchemaModel | null | undefined): model is SchemaModel; type ZodSchemaModel = z$1.infer>; type InferZodFromType = T extends SchemaModel ? z$1.ZodObject : T extends AnyFieldType ? ReturnType : T extends AnyEnumType ? ReturnType : T extends SchemaModelType ? ReturnType : z$1.ZodUnknown; type MaybeArray = A extends true ? z$1.ZodArray : Z; type MaybeOptional = O extends true ? z$1.ZodOptional : Z; /** * Helper type: derive the Zod shape from the field config. * Supports nested SchemaModel and arrays, preserving optionality and list-ness. */ type FieldIsArray = FC extends { isArray: true; } ? true : false; type ZodShapeFromFields = { [K in keyof F]: MaybeOptional, FieldIsArray>, F[K]['isOptional']> }; /** * The top-level Zod schema returned by getZod(): * either ZodObject<...> or ZodArray> when config.isArray. */ type TopLevelZodFromModel = z$1.ZodObject>; /** * Helper to define a SchemaModel with type inference. * Equivalent to `new SchemaModel(config)` but with better ergonomics. */ declare const defineSchemaModel: (config: SchemaModelConfig) => SchemaModel; //#endregion export { AnySchemaModel, SchemaFieldConfig, SchemaModel, SchemaModelConfig, SchemaModelFieldsAnyConfig, TopLevelZodFromModel, ZodSchemaModel, ZodShapeFromFields, defineSchemaModel, isSchemaModel }; //# sourceMappingURL=SchemaModel.d.ts.map