@nxgt/graphql-codegen-zod 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/imports.ts", "../src/naming.ts", "../src/scalars.ts", "../src/schema-output.ts", "../src/cycles.ts", "../src/defaults.ts", "../src/source.ts", "../src/type-code.ts", "../src/variables-output.ts", "../src/writer.ts"],
4
+ "sourcesContent": [
5
+ "import { checkConstraints } from '@nxgt/graphql-validation/codegen';\nimport {\n\ttype GraphQLSchema,\n\tisInputObjectType,\n\tisInterfaceType,\n\tisObjectType,\n} from 'graphql';\nimport type { CodegenZodConfig, DocumentFile } from './config';\nimport { Imports } from './imports';\nimport { Naming } from './naming';\nimport { ScalarSources } from './scalars';\nimport { schemaBlocks } from './schema-output';\nimport { variablesBlocks } from './variables-output';\nimport { Writer } from './writer';\n\nexport type { CodegenZodConfig, DocumentFile } from './config';\n\n/**\n * The graphql-codegen plugin: Zod schemas, and their types, for the\n * schema's enums, input types and field arguments, and for the variables of\n * each operation in `documents`, with every `@constraint` of\n * `@nxgt/graphql-validation`. It refuses a schema `withValidation` would\n * refuse, with the same message.\n */\nexport async function plugin(\n\tschema: GraphQLSchema,\n\tdocuments: readonly DocumentFile[],\n\tconfig: CodegenZodConfig = {},\n\tinfo?: { readonly outputFile?: string | undefined },\n): Promise<string> {\n\tconst directive = checkConstraints(schema);\n\tif (directive) assertSdl(schema);\n\tconst naming = new Naming(config);\n\tconst write = async (imports: Imports) => {\n\t\tconst scalars = await ScalarSources.load(config, imports, info?.outputFile);\n\t\tconst writer = new Writer(directive, naming, scalars);\n\t\treturn [\n\t\t\t...schemaBlocks(schema, writer, naming),\n\t\t\t...variablesBlocks(schema, documents, writer, naming),\n\t\t];\n\t};\n\t// Written twice: the first pass names what the file declares, so the\n\t// second gives no import one of those names.\n\tconst declarations = (await write(new Imports())).flatMap((block) =>\n\t\t[...block.matchAll(/^export (const|type) (\\w+)/gm)].map(\n\t\t\t(m) => `${m[1]} ${m[2]}`,\n\t\t),\n\t);\n\t// A value and a type may share a name; two of one kind may not.\n\tconst twice = declarations.find(\n\t\t(declaration, index) => declarations.indexOf(declaration) !== index,\n\t);\n\tif (twice)\n\t\tthrow new Error(\n\t\t\t`@nxgt/graphql-codegen-zod: the file would declare ${twice.split(' ')[1]} twice: two GraphQL names, or an input type in a cycle and its Input type, give the same name. Rename one of the GraphQL types, or set typesSuffix.`,\n\t\t);\n\tconst declared = declarations.map(\n\t\t(declaration) => declaration.split(' ')[1] ?? '',\n\t);\n\tconst imports = new Imports(declared);\n\tconst blocks = await write(imports);\n\treturn `${imports.lines().join('\\n')}\\n\\n${blocks.join('\\n\\n')}\\n`;\n}\n\n/**\n * Fails on a schema that declares `@constraint` but was built without its\n * SDL (introspected, loaded from a URL): its arguments carry no directives\n * to read, and every constraint would be dropped in silence.\n */\nfunction assertSdl(schema: GraphQLSchema): void {\n\tfor (const type of Object.values(schema.getTypeMap())) {\n\t\tif (type.name.startsWith('__')) continue;\n\t\tconst inputs = isInputObjectType(type)\n\t\t\t? Object.values(type.getFields())\n\t\t\t: isObjectType(type) || isInterfaceType(type)\n\t\t\t\t? Object.values(type.getFields()).flatMap((field) => field.args)\n\t\t\t\t: [];\n\t\tconst bare = inputs.find((input) => !input.astNode);\n\t\tif (bare) {\n\t\t\tthrow new Error(\n\t\t\t\t`@nxgt/graphql-codegen-zod: the schema declares @constraint, but ${type.name} has no SDL to read it from (an introspected schema?). Point codegen's schema at the SDL files.`,\n\t\t\t);\n\t\t}\n\t}\n}\n",
6
+ "/**\n * The named imports of the generated file, one line per module, an alias\n * when two modules export the same name.\n */\nexport class Imports {\n\treadonly #byModule = new Map<string, Map<string, string>>([\n\t\t['zod', new Map([['z', 'z']])],\n\t]);\n\treadonly #taken: Set<string>;\n\n\t/** `reserved`: the names the file declares, which no import may take. */\n\tconstructor(reserved: Iterable<string> = []) {\n\t\tthis.#taken = new Set(['z', ...reserved]);\n\t}\n\n\t/** The local name `exported` from `module` is reached by. */\n\tadd(module: string, exported: string): string {\n\t\tconst names = this.#byModule.get(module) ?? new Map<string, string>();\n\t\tthis.#byModule.set(module, names);\n\t\tconst known = names.get(exported);\n\t\tif (known) return known;\n\t\tlet local = exported;\n\t\tfor (let n = 2; this.#taken.has(local); n++) local = `${exported}${n}`;\n\t\tthis.#taken.add(local);\n\t\tnames.set(exported, local);\n\t\treturn local;\n\t}\n\n\t/** The import lines, `zod` first, double-quoted as every string the file holds. */\n\tlines(): string[] {\n\t\treturn [...this.#byModule].map(\n\t\t\t([module, names]) =>\n\t\t\t\t`import { ${[...names]\n\t\t\t\t\t.map(([exported, local]) =>\n\t\t\t\t\t\texported === local ? local : `${exported} as ${local}`,\n\t\t\t\t\t)\n\t\t\t\t\t.join(', ')} } from ${JSON.stringify(module)};`,\n\t\t);\n\t}\n}\n",
7
+ "import * as changeCase from 'change-case';\nimport type { OperationTypeNode } from 'graphql';\nimport type { CodegenZodConfig } from './config';\n\n/**\n * The names of what the plugin writes: each type as\n * `@graphql-codegen/typescript` and `typescript-operations` name it, each\n * schema the same name behind `schemaPrefix`.\n */\nexport class Naming {\n\treadonly #config: CodegenZodConfig;\n\treadonly #convert: (name: string) => string;\n\n\tconstructor(config: CodegenZodConfig) {\n\t\tthis.#config = config;\n\t\tthis.#convert = converter(config.namingConvention);\n\t}\n\n\t/** An input type's or an enum's type name: `SignUpInput`. */\n\ttype(name: string): string {\n\t\treturn this.#wrap(this.#convert(name));\n\t}\n\n\t/** A field's arguments type name: `MutationSignUpArgs`. */\n\targs(parent: string, field: string): string {\n\t\tconst underscore = this.#config.addUnderscoreToArgsType ? '_' : '';\n\t\treturn this.#wrap(\n\t\t\tthis.#convert(`${parent}${underscore}${this.#convert(field)}Args`),\n\t\t);\n\t}\n\n\t/** An operation's variables type name: `SignUpMutationVariables`. */\n\tvariables(operation: string, kind: OperationTypeNode): string {\n\t\tconst type = changeCase.pascalCase(kind);\n\t\tconst { omitOperationSuffix, dedupeOperationSuffix } = this.#config;\n\t\tconst suffix =\n\t\t\tomitOperationSuffix ||\n\t\t\t(dedupeOperationSuffix &&\n\t\t\t\toperation.toLowerCase().endsWith(type.toLowerCase()))\n\t\t\t\t? ''\n\t\t\t\t: type;\n\t\treturn this.#wrap(this.#convert(`${operation}${suffix}Variables`));\n\t}\n\n\t/** The schema of the type named `type`: `zSignUpInput`. */\n\tschema(type: string): string {\n\t\treturn `${this.#config.schemaPrefix ?? 'z'}${type}`;\n\t}\n\n\t#wrap(name: string): string {\n\t\treturn `${this.#config.typesPrefix ?? ''}${name}${this.#config.typesSuffix ?? ''}`;\n\t}\n}\n\ntype Convention = NonNullable<CodegenZodConfig['namingConvention']>;\ntype Case = (name: string) => string;\n\nconst lowerCaseFirst: Case = (name) =>\n\tname.charAt(0).toLowerCase() + name.slice(1);\nconst upperCaseFirst: Case = (name) =>\n\tname.charAt(0).toUpperCase() + name.slice(1);\n\n/**\n * The cases a `namingConvention` string can name, by module: change-case-all\n * 2's names (what the typescript plugins resolve), and change-case 5's.\n */\nconst cases: Readonly<Record<string, Readonly<Record<string, Case>>>> = {\n\t'change-case-all': {\n\t\tcamelCase: changeCase.camelCase,\n\t\tcapitalCase: changeCase.capitalCase,\n\t\tconstantCase: changeCase.constantCase,\n\t\tdotCase: changeCase.dotCase,\n\t\theaderCase: changeCase.trainCase,\n\t\tnoCase: changeCase.noCase,\n\t\tparamCase: changeCase.kebabCase,\n\t\tpascalCase: changeCase.pascalCase,\n\t\tpathCase: changeCase.pathCase,\n\t\tsentenceCase: changeCase.sentenceCase,\n\t\tsnakeCase: changeCase.snakeCase,\n\t\tlowerCase: (name) => name.toLowerCase(),\n\t\tupperCase: (name) => name.toUpperCase(),\n\t\tlowerCaseFirst,\n\t\tupperCaseFirst,\n\t},\n\t'change-case': {\n\t\tcamelCase: changeCase.camelCase,\n\t\tcapitalCase: changeCase.capitalCase,\n\t\tconstantCase: changeCase.constantCase,\n\t\tdotCase: changeCase.dotCase,\n\t\tkebabCase: changeCase.kebabCase,\n\t\tnoCase: changeCase.noCase,\n\t\tpascalCase: changeCase.pascalCase,\n\t\tpascalSnakeCase: changeCase.pascalSnakeCase,\n\t\tpathCase: changeCase.pathCase,\n\t\tsentenceCase: changeCase.sentenceCase,\n\t\tsnakeCase: changeCase.snakeCase,\n\t\ttrainCase: changeCase.trainCase,\n\t},\n};\n\n/** Applies `fn` to each part between underscores, or to the whole name. */\nconst byPart =\n\t(fn: Case, transformUnderscore: boolean): Case =>\n\t(name) =>\n\t\ttransformUnderscore ? fn(name) : name.split('_').map(fn).join('_');\n\n/**\n * A `namingConvention` as `@graphql-codegen/visitor-plugin-common`'s\n * `convertFactory` reads it for type names: undefined is PascalCase per\n * part; `'keep'`; a `'change-case-all#<case>'` string or a function, per\n * part; an object's `typeNames`, on the whole name (upstream reads no\n * `transformUnderscore` there), or, without `typeNames`, PascalCase per\n * part unless `transformUnderscore` is true.\n * Enum values are written as they are, so `enumValues` is not read.\n */\nfunction converter(convention: Convention | undefined): Case {\n\tif (convention === undefined) return byPart(changeCase.pascalCase, false);\n\tif (convention === 'keep') return (name) => name;\n\tif (typeof convention === 'function') return byPart(convention, false);\n\tif (typeof convention === 'string')\n\t\treturn byPart(caseNamed(convention), false);\n\tconst { typeNames, transformUnderscore } = convention;\n\tif (typeNames === 'keep') return (name) => name;\n\tif (typeNames === undefined)\n\t\treturn byPart(changeCase.pascalCase, transformUnderscore ?? false);\n\tconst fn = typeof typeNames === 'function' ? typeNames : caseNamed(typeNames);\n\treturn byPart(fn, true);\n}\n\nfunction caseNamed(spec: string): Case {\n\tconst [module = '', name = ''] = spec.split('#');\n\tconst fn = cases[module]?.[name];\n\tif (fn) return fn;\n\tthrow new Error(\n\t\t`@nxgt/graphql-codegen-zod: namingConvention \"${spec}\" is not one this plugin reads. Use 'keep', a function, or 'change-case-all#<case>' with one of ${Object.keys(cases['change-case-all'] ?? {}).join(', ')}.`,\n\t);\n}\n",
8
+ "import { createRequire } from 'node:module';\nimport { dirname, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { GraphQLScalarType } from 'graphql';\nimport type { CodegenZodConfig } from './config';\nimport type { Imports } from './imports';\n\n/**\n * Where each custom scalar's schema comes from: `zodScalars` first, then the\n * `scalarSchemas` record. A scalar in neither fails generation, naming it:\n * a scalar written as `z.unknown()` would check nothing, in silence.\n */\nexport class ScalarSources {\n\treadonly #config: CodegenZodConfig;\n\treadonly #imports: Imports;\n\t/** The record's keys, when its module could be loaded to read them. */\n\treadonly #recordKeys: ReadonlySet<string> | undefined;\n\n\tprivate constructor(\n\t\tconfig: CodegenZodConfig,\n\t\timports: Imports,\n\t\trecordKeys: ReadonlySet<string> | undefined,\n\t) {\n\t\tthis.#config = config;\n\t\tthis.#imports = imports;\n\t\tthis.#recordKeys = recordKeys;\n\t}\n\n\t/**\n\t * Loads the `scalarSchemas` module, if any, to know its keys. One that\n\t * cannot be loaded here (a `.ts` file under Node) is trusted: the\n\t * generated file then fails to typecheck on a missing key instead.\n\t */\n\tstatic async load(\n\t\tconfig: CodegenZodConfig,\n\t\timports: Imports,\n\t\toutputFile: string | undefined,\n\t): Promise<ScalarSources> {\n\t\tif (!config.scalarSchemas)\n\t\t\treturn new ScalarSources(config, imports, undefined);\n\t\tconst keys = await recordKeys(config.scalarSchemas, outputFile);\n\t\treturn new ScalarSources(config, imports, keys);\n\t}\n\n\t/** The source of `type`'s schema, its import added. */\n\tcode(type: GraphQLScalarType): string {\n\t\tconst own = this.#config.zodScalars?.[type.name];\n\t\tif (own !== undefined) {\n\t\t\tconst at = own.lastIndexOf('#');\n\t\t\tif (at <= 0 || at === own.length - 1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`@nxgt/graphql-codegen-zod: zodScalars.${type.name} is \"${own}\"; write it '<module>#<export>', e.g. './money#moneySchema'.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn this.#imports.add(own.slice(0, at), own.slice(at + 1));\n\t\t}\n\t\tconst record = this.#config.scalarSchemas;\n\t\tif (record && (!this.#recordKeys || this.#recordKeys.has(type.name))) {\n\t\t\treturn `${this.#imports.add(record, 'scalarSchemas')}.${type.name}`;\n\t\t}\n\t\tconst where = record\n\t\t\t? `neither in zodScalars nor in ${record}'s scalarSchemas`\n\t\t\t: 'not in zodScalars, and no scalarSchemas is set';\n\t\tthrow new Error(\n\t\t\t`@nxgt/graphql-codegen-zod: the scalar ${type.name} is ${where}. Map it: zodScalars: { ${type.name}: './module#export' }, or set scalarSchemas: '@nxgt/graphql-scalars'.`,\n\t\t);\n\t}\n}\n\nasync function recordKeys(\n\tmodule: string,\n\toutputFile: string | undefined,\n): Promise<ReadonlySet<string> | undefined> {\n\ttry {\n\t\tconst base = module.startsWith('.')\n\t\t\t? resolve(dirname(resolve(outputFile ?? 'index.ts')), module)\n\t\t\t: createRequire(resolve('package.json')).resolve(module);\n\t\tconst loaded: { scalarSchemas?: unknown } = await import(\n\t\t\tpathToFileURL(base).href\n\t\t);\n\t\tconst record = loaded.scalarSchemas;\n\t\tif (typeof record !== 'object' || record === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`@nxgt/graphql-codegen-zod: ${module} exports no scalarSchemas record.`,\n\t\t\t);\n\t\t}\n\t\treturn new Set(Object.keys(record));\n\t} catch (error) {\n\t\tif (\n\t\t\terror instanceof Error &&\n\t\t\terror.message.startsWith('@nxgt/graphql-codegen-zod:')\n\t\t)\n\t\t\tthrow error;\n\t\treturn undefined;\n\t}\n}\n",
9
+ "import { constraintsOn } from '@nxgt/graphql-validation/codegen';\nimport {\n\ttype GraphQLEnumType,\n\ttype GraphQLInputObjectType,\n\ttype GraphQLSchema,\n\tisEnumType,\n\tisInputObjectType,\n\tisInterfaceType,\n\tisObjectType,\n} from 'graphql';\nimport { inputCycles } from './cycles';\nimport { defaultLiteral } from './defaults';\nimport type { Naming } from './naming';\nimport { declare, objectMembers } from './source';\nimport { declareCyclic } from './type-code';\nimport type { Writer } from './writer';\n\n/**\n * The SDL's part of the file: every enum, then every input type, then the\n * arguments of every object and interface field that takes any. Types are\n * `z.output`: what a resolver receives once `withValidation` parsed them.\n */\nexport function schemaBlocks(\n\tschema: GraphQLSchema,\n\twriter: Writer,\n\tnaming: Naming,\n): string[] {\n\tconst types = Object.values(schema.getTypeMap()).filter(\n\t\t(type) => !type.name.startsWith('__'),\n\t);\n\tconst cyclic = inputCycles(schema);\n\treturn [\n\t\t...types.filter(isEnumType).map((type) => enumBlock(type, naming)),\n\t\t...types\n\t\t\t.filter(isInputObjectType)\n\t\t\t.map((type) => inputBlock(type, writer, naming, cyclic)),\n\t\t...types.flatMap((type) => {\n\t\t\tif (!isObjectType(type) && !isInterfaceType(type)) return [];\n\t\t\treturn Object.values(type.getFields())\n\t\t\t\t.filter((field) => field.args.length > 0)\n\t\t\t\t.map((field) => {\n\t\t\t\t\tconst name = naming.args(type.name, field.name);\n\t\t\t\t\tconst members = field.args.map(\n\t\t\t\t\t\t(arg) =>\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\targ.name,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...writer.value(\n\t\t\t\t\t\t\t\t\t\targ.type,\n\t\t\t\t\t\t\t\t\t\tconstraintsOn(writer.directive, arg.astNode),\n\t\t\t\t\t\t\t\t\t\t`${type.name}.${field.name}(${arg.name}:)`,\n\t\t\t\t\t\t\t\t\t\tdefaultLiteral(arg),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tdescription: arg.description,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] as const,\n\t\t\t\t\t);\n\t\t\t\t\treturn declare(\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tnaming,\n\t\t\t\t\t\t`z.object({\\n${objectMembers(members)}\\n})`,\n\t\t\t\t\t\t'output',\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t}),\n\t];\n}\n\nfunction enumBlock(type: GraphQLEnumType, naming: Naming): string {\n\tconst values = type.getValues().map((value) => JSON.stringify(value.name));\n\treturn declare(\n\t\tnaming.type(type.name),\n\t\tnaming,\n\t\t`z.enum([${values.join(', ')}])`,\n\t\t'output',\n\t\ttype.description,\n\t);\n}\n\nfunction inputBlock(\n\ttype: GraphQLInputObjectType,\n\twriter: Writer,\n\tnaming: Naming,\n\tcyclic: ReadonlySet<string>,\n): string {\n\tconst code = inputCode(type, writer);\n\treturn cyclic.has(type.name)\n\t\t? declareCyclic(type, code, writer, naming, cyclic)\n\t\t: declare(naming.type(type.name), naming, code, 'output', type.description);\n}\n\n/**\n * An input type's schema: strict, as graphql refuses a field the type does\n * not define; for `@oneOf`, a union of one set member each.\n */\nfunction inputCode(type: GraphQLInputObjectType, writer: Writer): string {\n\tconst fields = Object.values(type.getFields());\n\tconst constraints = (field: (typeof fields)[number]) =>\n\t\tconstraintsOn(writer.directive, field.astNode);\n\tconst where = (field: (typeof fields)[number]) =>\n\t\t`${type.name}.${field.name}`;\n\t// @oneOf: exactly one member, set.\n\tif (type.isOneOf) {\n\t\tconst members = fields.map((field) => {\n\t\t\tconst member = {\n\t\t\t\t...writer.required(field.type, constraints(field), where(field)),\n\t\t\t\tdescription: field.description,\n\t\t\t};\n\t\t\treturn `\\tz.strictObject({\\n${indent(objectMembers([[field.name, member]]))}\\n\\t})`;\n\t\t});\n\t\treturn `z.union([\\n${members.join(',\\n')},\\n])`;\n\t}\n\tconst members = fields.map(\n\t\t(field) =>\n\t\t\t[\n\t\t\t\tfield.name,\n\t\t\t\t{\n\t\t\t\t\t...writer.value(\n\t\t\t\t\t\tfield.type,\n\t\t\t\t\t\tconstraints(field),\n\t\t\t\t\t\twhere(field),\n\t\t\t\t\t\tdefaultLiteral(field),\n\t\t\t\t\t),\n\t\t\t\t\tdescription: field.description,\n\t\t\t\t},\n\t\t\t] as const,\n\t);\n\treturn `z.strictObject({\\n${objectMembers(members)}\\n})`;\n}\n\n/** Indents each line of `code` by one tab. */\nfunction indent(code: string): string {\n\treturn code\n\t\t.split('\\n')\n\t\t.map((line) => `\\t${line}`)\n\t\t.join('\\n');\n}\n",
10
+ "import {\n\ttype GraphQLInputObjectType,\n\ttype GraphQLSchema,\n\tgetNamedType,\n\tisInputObjectType,\n} from 'graphql';\n\n/**\n * The input types that reach themselves through their fields, directly\n * (`Filter.and: [Filter]`) or through others: TypeScript cannot infer the\n * schema of such a type once a field wraps it, so the plugin writes their\n * types out.\n */\nexport function inputCycles(schema: GraphQLSchema): ReadonlySet<string> {\n\tconst inputs = Object.values(schema.getTypeMap()).filter(isInputObjectType);\n\tconst cyclic = new Set<string>();\n\tfor (const start of inputs) {\n\t\tif (reaches(start, start.name, new Set())) cyclic.add(start.name);\n\t}\n\treturn cyclic;\n}\n\nfunction reaches(\n\tfrom: GraphQLInputObjectType,\n\ttarget: string,\n\tseen: Set<string>,\n): boolean {\n\tfor (const field of Object.values(from.getFields())) {\n\t\tconst named = getNamedType(field.type);\n\t\tif (!isInputObjectType(named)) continue;\n\t\tif (named.name === target) return true;\n\t\tif (seen.has(named.name)) continue;\n\t\tseen.add(named.name);\n\t\tif (reaches(named, target, seen)) return true;\n\t}\n\treturn false;\n}\n",
11
+ "import * as graphql from 'graphql';\nimport {\n\tastFromValue,\n\ttype ConstValueNode,\n\ttype GraphQLArgument,\n\tGraphQLID,\n\ttype GraphQLInputField,\n\ttype GraphQLInputType,\n\tgetNamedType,\n\tgetNullableType,\n\tisInputObjectType,\n\tisListType,\n\tisNonNullType,\n\tisScalarType,\n\tisSpecifiedScalarType,\n\tKind,\n\tvalueFromASTUntyped,\n} from 'graphql';\n\n/**\n * A default's value as the client parses it: its literal coerced as\n * graphql coerces it. An integer a JavaScript number cannot keep exact,\n * given to an ID or a custom scalar, fails, naming `where`: the server\n * would hand the scalar every digit. An Int or a Float rounds on both sides.\n */\nexport function parsedDefault(\n\tliteral: ConstValueNode,\n\ttype: GraphQLInputType,\n\twhere: string,\n): unknown {\n\tassertExact(literal, type, where);\n\treturn coerced(valueFromASTUntyped(literal), type);\n}\n\nfunction assertExact(\n\tliteral: ConstValueNode,\n\ttype: GraphQLInputType,\n\twhere: string,\n): void {\n\tconst nullable = getNullableType(type);\n\tif (isListType(nullable)) {\n\t\tconst items = literal.kind === Kind.LIST ? literal.values : [literal];\n\t\tfor (const item of items) assertExact(item, nullable.ofType, where);\n\t\treturn;\n\t}\n\tif (isInputObjectType(nullable)) {\n\t\tif (literal.kind !== Kind.OBJECT) return;\n\t\tconst fields = nullable.getFields();\n\t\tfor (const field of literal.fields) {\n\t\t\tconst definition = fields[field.name.value];\n\t\t\tif (definition) assertExact(field.value, definition.type, where);\n\t\t}\n\t\treturn;\n\t}\n\tconst keeps =\n\t\tnullable === GraphQLID ||\n\t\t(isScalarType(nullable) && !isSpecifiedScalarType(nullable));\n\tif (\n\t\tkeeps &&\n\t\tliteral.kind === Kind.INT &&\n\t\t!Number.isSafeInteger(Number(literal.value))\n\t)\n\t\tthrow new Error(\n\t\t\t`@nxgt/graphql-codegen-zod: the default of ${where} holds ${literal.value}, which a JavaScript number cannot keep exact. Write it as a string, if its scalar takes one.`,\n\t\t);\n}\n\n/**\n * The default of an argument or input field as a literal: its SDL's, or,\n * for a schema built without SDL (introspected), its value written back.\n * graphql 16 holds that value in `defaultValue`, graphql 17 in `default`.\n */\nexport function defaultLiteral(\n\tinput: GraphQLArgument | GraphQLInputField,\n): ConstValueNode | undefined {\n\tif (input.astNode) return input.astNode.defaultValue;\n\tconst loose = input as {\n\t\tdefaultValue?: unknown;\n\t\tdefault?: { value?: unknown; literal?: ConstValueNode };\n\t};\n\tif (loose.default?.literal) return loose.default.literal;\n\tif (loose.default) {\n\t\t// graphql 17: an external value, written back by valueToLiteral.\n\t\tconst toLiteral = (\n\t\t\tgraphql as {\n\t\t\t\tvalueToLiteral?: (\n\t\t\t\t\tvalue: unknown,\n\t\t\t\t\ttype: GraphQLInputType,\n\t\t\t\t) => ConstValueNode | undefined;\n\t\t\t}\n\t\t).valueToLiteral;\n\t\tif (loose.default.value === undefined || !toLiteral) return undefined;\n\t\treturn toLiteral(loose.default.value, input.type);\n\t}\n\t// graphql 16: an internal value, written back by astFromValue.\n\tif (loose.defaultValue === undefined) return undefined;\n\treturn (astFromValue(loose.defaultValue, input.type) ?? undefined) as\n\t\t| ConstValueNode\n\t\t| undefined;\n}\n\n/**\n * A default as graphql coerces it, through lists and input objects: a\n * single value given for a list is a list of it (`[String!] = \"a\"` is\n * `[\"a\"]`, `[[Int]] = 1` is `[[1]]`), at any depth.\n */\nexport function coerced(value: unknown, type: GraphQLInputType): unknown {\n\tconst nullable = isNonNullType(type) ? type.ofType : type;\n\tif (value === null || value === undefined) return value;\n\tif (isListType(nullable)) {\n\t\tconst items = Array.isArray(value) ? value : [value];\n\t\treturn items.map((item) => coerced(item, nullable.ofType));\n\t}\n\tif (isInputObjectType(nullable) && typeof value === 'object') {\n\t\tconst fields = nullable.getFields();\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value as Record<string, unknown>).map(([key, field]) => {\n\t\t\t\tconst definition = fields[key];\n\t\t\t\treturn [key, definition ? coerced(field, definition.type) : field];\n\t\t\t}),\n\t\t);\n\t}\n\t// graphql takes an Int for an ID, and the resolver gets its string.\n\tif (getNamedType(nullable) === GraphQLID && typeof value === 'number')\n\t\treturn String(value);\n\treturn value;\n}\n",
12
+ "import type { Naming } from './naming';\nimport type { ValueCode } from './writer';\n\n/** A GraphQL description as a doc comment, or nothing. */\nexport function docComment(\n\tdescription: string | null | undefined,\n\tindent = '',\n): string {\n\tif (!description) return '';\n\tconst lines = description\n\t\t.replaceAll('\\r\\n', '\\n')\n\t\t.replaceAll('*/', '*\\\\/')\n\t\t.split('\\n');\n\tif (lines.length === 1) return `${indent}/** ${lines[0]} */\\n`;\n\treturn `${indent}/**\\n${lines.map((line) => `${indent} * ${line}`.trimEnd()).join('\\n')}\\n${indent} */\\n`;\n}\n\n/** The members of a `z.object({...})`, a getter for each lazy one. */\nexport function objectMembers(\n\tmembers: readonly (readonly [string, ValueCode])[],\n): string {\n\treturn members\n\t\t.map(([name, { code, lazy, description }]) => {\n\t\t\tconst doc = docComment(description, '\\t');\n\t\t\treturn lazy\n\t\t\t\t? `${doc}\\tget ${name}() {\\n\\t\\treturn ${code};\\n\\t},`\n\t\t\t\t: `${doc}\\t${name}: ${code},`;\n\t\t})\n\t\t.join('\\n');\n}\n\n/** `export const zX = …; export type X = z.output<typeof zX>;` */\nexport function declare(\n\ttypeName: string,\n\tnaming: Naming,\n\tcode: string,\n\tside: 'input' | 'output',\n\tdescription?: string | null,\n): string {\n\tconst schemaName = naming.schema(typeName);\n\tconst doc = docComment(description);\n\treturn `${doc}export const ${schemaName} = ${code};\\n${doc}export type ${typeName} = z.${side}<typeof ${schemaName}>;`;\n}\n",
13
+ "import {\n\tGraphQLBoolean,\n\tGraphQLFloat,\n\tGraphQLID,\n\ttype GraphQLInputField,\n\ttype GraphQLInputObjectType,\n\ttype GraphQLInputType,\n\tGraphQLInt,\n\ttype GraphQLNamedInputType,\n\tGraphQLString,\n\tgetNamedType,\n\tisEnumType,\n\tisInputObjectType,\n\tisListType,\n\tisNonNullType,\n} from 'graphql';\nimport { defaultLiteral } from './defaults';\nimport type { Naming } from './naming';\nimport { docComment } from './source';\nimport type { Writer } from './writer';\n\ntype Side = 'input' | 'output';\n\nconst builtIns: Readonly<Record<string, string>> = {\n\t[GraphQLString.name]: 'string',\n\t[GraphQLID.name]: 'string',\n\t[GraphQLInt.name]: 'number',\n\t[GraphQLFloat.name]: 'number',\n\t[GraphQLBoolean.name]: 'boolean',\n};\n\n/**\n * An input type in a cycle, declared with its types written out, since\n * TypeScript cannot infer them: `Filter` (what the resolver receives),\n * `FilterInput` (what a client sends), and `zFilter` typed by both. The\n * schema's types must fit inside them, a type error otherwise; a type\n * written wider than the schema would compile, so test/types.ts pins them.\n */\nexport function declareCyclic(\n\ttype: GraphQLInputObjectType,\n\tcode: string,\n\twriter: Writer,\n\tnaming: Naming,\n\tcyclic: ReadonlySet<string>,\n): string {\n\tconst types = new TypeCode(writer, naming, cyclic);\n\tconst output = naming.type(type.name);\n\tconst input = `${output}Input`;\n\tconst doc = docComment(type.description);\n\treturn [\n\t\t`${doc}export type ${output} = ${types.object(type, 'output')};`,\n\t\t`${doc}export type ${input} = ${types.object(type, 'input')};`,\n\t\t`${doc}export const ${naming.schema(output)}: z.ZodType<${output}, ${input}> = ${code};`,\n\t].join('\\n');\n}\n\n/** The TypeScript type of a value, on the way in or on the way out. */\nclass TypeCode {\n\treadonly #writer: Writer;\n\treadonly #naming: Naming;\n\treadonly #cyclic: ReadonlySet<string>;\n\n\tconstructor(writer: Writer, naming: Naming, cyclic: ReadonlySet<string>) {\n\t\tthis.#writer = writer;\n\t\tthis.#naming = naming;\n\t\tthis.#cyclic = cyclic;\n\t}\n\n\t/** An input object's fields, or, for `@oneOf`, one member set. */\n\tobject(type: GraphQLInputObjectType, side: Side): string {\n\t\tconst fields = Object.values(type.getFields());\n\t\tif (type.isOneOf)\n\t\t\treturn fields\n\t\t\t\t.map(\n\t\t\t\t\t(field) => `{ ${field.name}: ${this.#required(field.type, side)} }`,\n\t\t\t\t)\n\t\t\t\t.join(' | ');\n\t\tconst members = fields.map(\n\t\t\t(field) =>\n\t\t\t\t`${docComment(field.description, '\\t')}\\t${this.#member(field, side)};`,\n\t\t);\n\t\treturn `{\\n${members.join('\\n')}\\n}`;\n\t}\n\n\t/**\n\t * A field as `Writer.value` writes it: optional on the way in when it\n\t * is nullable or has a default; on the way out, present when it has a\n\t * default, else optional when nullable.\n\t */\n\t#member(field: GraphQLInputField, side: Side): string {\n\t\tconst nullable = !isNonNullType(field.type);\n\t\tconst filled = defaultLiteral(field) !== undefined;\n\t\tconst type = this.#required(field.type, side);\n\t\tif (!nullable)\n\t\t\treturn side === 'input' && filled\n\t\t\t\t? `${field.name}?: ${type} | undefined`\n\t\t\t\t: `${field.name}: ${type}`;\n\t\tif (side === 'output' && filled) return `${field.name}: ${type} | null`;\n\t\treturn `${field.name}?: ${type} | null | undefined`;\n\t}\n\n\t/** `type` without its null: a list, a named type. */\n\t#required(type: GraphQLInputType, side: Side): string {\n\t\tif (isNonNullType(type)) return this.#required(type.ofType, side);\n\t\tif (!isListType(type)) return this.#named(type, side);\n\t\tconst item = isNonNullType(type.ofType)\n\t\t\t? this.#required(type.ofType, side)\n\t\t\t: `${this.#required(type.ofType, side)} | null | undefined`;\n\t\tconst list = `Array<${item}>`;\n\t\t// A single value for a list, as `Writer` takes it.\n\t\treturn side === 'input'\n\t\t\t? `${this.#named(getNamedType(type), side)} | ${list}`\n\t\t\t: list;\n\t}\n\n\t#named(type: GraphQLNamedInputType, side: Side): string {\n\t\tconst builtIn = builtIns[type.name];\n\t\tif (builtIn) return builtIn;\n\t\tif (isEnumType(type))\n\t\t\treturn `z.output<typeof ${this.#writer.schemaName(type)}>`;\n\t\tif (isInputObjectType(type)) {\n\t\t\tconst name = this.#naming.type(type.name);\n\t\t\tif (this.#cyclic.has(type.name))\n\t\t\t\treturn side === 'output' ? name : `${name}Input`;\n\t\t\treturn `z.${side}<typeof ${this.#writer.schemaName(type)}>`;\n\t\t}\n\t\treturn `z.${side}<typeof ${this.#writer.scalarCode(type)}>`;\n\t}\n}\n",
14
+ "import {\n\ttype Constraint,\n\tconstraintsOn,\n} from '@nxgt/graphql-validation/codegen';\nimport {\n\ttype ASTNode,\n\ttype FragmentDefinitionNode,\n\ttype GraphQLDirective,\n\ttype GraphQLInputType,\n\ttype GraphQLSchema,\n\tgetNamedType,\n\tisInputObjectType,\n\tisListType,\n\tisNonNullType,\n\tKind,\n\ttype OperationDefinitionNode,\n\tTypeInfo,\n\ttypeFromAST,\n\ttype ValueNode,\n\tvisit,\n\tvisitWithTypeInfo,\n} from 'graphql';\nimport type { DocumentFile } from './config';\nimport type { Naming } from './naming';\nimport { declare, objectMembers } from './source';\nimport type { Writer } from './writer';\n\n/**\n * One schema per named operation in `documents`, for its variables as a\n * client sends them (`z.input`). A variable gets the constraints of every\n * argument or input field it is passed to, in the operation and in the\n * fragments it spreads: the client refuses what the server would.\n * An anonymous operation has no name to give its schema, and gets none.\n */\nexport function variablesBlocks(\n\tschema: GraphQLSchema,\n\tdocuments: readonly DocumentFile[],\n\twriter: Writer,\n\tnaming: Naming,\n): string[] {\n\tconst definitions = documents.flatMap(\n\t\t(file) => file.document?.definitions ?? [],\n\t);\n\tconst fragments = new Map(\n\t\tdefinitions\n\t\t\t.filter(\n\t\t\t\t(node): node is FragmentDefinitionNode =>\n\t\t\t\t\tnode.kind === Kind.FRAGMENT_DEFINITION,\n\t\t\t)\n\t\t\t.map((node) => [node.name.value, node]),\n\t);\n\treturn definitions\n\t\t.filter(\n\t\t\t(node): node is OperationDefinitionNode =>\n\t\t\t\tnode.kind === Kind.OPERATION_DEFINITION,\n\t\t)\n\t\t.flatMap((operation) => {\n\t\t\tconst operationName = operation.name?.value;\n\t\t\tif (!operationName) return [];\n\t\t\tconst used = usages(schema, writer.directive, operation, fragments);\n\t\t\tconst members = (operation.variableDefinitions ?? []).map(\n\t\t\t\t(definition) => {\n\t\t\t\t\tconst variable = definition.variable.name.value;\n\t\t\t\t\tconst type = typeFromAST(schema, definition.type) as\n\t\t\t\t\t\t| GraphQLInputType\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\tif (!type) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`@nxgt/graphql-codegen-zod: ${operationName}'s $${variable} has a type the schema does not define.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst where = `${operationName}($${variable}:)`;\n\t\t\t\t\tconst constraints = merged(used.get(variable) ?? [], where);\n\t\t\t\t\treturn [\n\t\t\t\t\t\tvariable,\n\t\t\t\t\t\twriter.value(type, constraints, where, definition.defaultValue),\n\t\t\t\t\t] as const;\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn [\n\t\t\t\tdeclare(\n\t\t\t\t\tnaming.variables(operationName, operation.operation),\n\t\t\t\t\tnaming,\n\t\t\t\t\t`z.object({\\n${objectMembers(members)}\\n})`,\n\t\t\t\t\t'input',\n\t\t\t\t),\n\t\t\t];\n\t\t});\n}\n\n/** One place a variable is passed to, and the constraints written there. */\ninterface Usage {\n\treadonly where: string;\n\treadonly constraints: readonly Constraint[];\n}\n\n/** Where a walk of an operation stands: what it found, what it reads. */\ninterface Walk {\n\treadonly found: Map<string, Usage[]>;\n\treadonly variables: ReadonlySet<string>;\n\treadonly directive: GraphQLDirective | undefined;\n}\n\n/** Each variable's usages, in the operation and the fragments it spreads. */\nfunction usages(\n\tschema: GraphQLSchema,\n\tdirective: GraphQLDirective | undefined,\n\toperation: OperationDefinitionNode,\n\tfragments: ReadonlyMap<string, FragmentDefinitionNode>,\n): Map<string, Usage[]> {\n\tconst walk: Walk = {\n\t\tfound: new Map(),\n\t\tvariables: new Set(\n\t\t\t(operation.variableDefinitions ?? []).map((d) => d.variable.name.value),\n\t\t),\n\t\tdirective,\n\t};\n\tconst seen = new Set<string>();\n\tconst visitNode = (node: ASTNode): void => {\n\t\tconst typeInfo = new TypeInfo(schema);\n\t\tvisit(\n\t\t\tnode,\n\t\t\tvisitWithTypeInfo(typeInfo, {\n\t\t\t\tArgument(argument) {\n\t\t\t\t\tconst definition = typeInfo.getArgument();\n\t\t\t\t\tconst field = typeInfo.getFieldDef();\n\t\t\t\t\t// A directive's argument carries no constraint (withValidation refuses one).\n\t\t\t\t\tif (!definition || !field || typeInfo.getDirective() !== null) return;\n\t\t\t\t\tconst where = `${typeInfo.getParentType()?.name}.${field.name}(${definition.name}:)`;\n\t\t\t\t\twalkValue(\n\t\t\t\t\t\twalk,\n\t\t\t\t\t\targument.value,\n\t\t\t\t\t\tdefinition.type,\n\t\t\t\t\t\tconstraintsOn(directive, definition.astNode),\n\t\t\t\t\t\twhere,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tFragmentSpread(spread) {\n\t\t\t\t\tconst fragment = fragments.get(spread.name.value);\n\t\t\t\t\tif (fragment && !seen.has(fragment.name.value)) {\n\t\t\t\t\t\tseen.add(fragment.name.value);\n\t\t\t\t\t\tvisitNode(fragment);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\t};\n\tvisitNode(operation);\n\treturn walk.found;\n}\n\n/**\n * Records the variables inside a value passed where `type` is expected:\n * the value itself, the items of a list literal (which take the items'\n * rules), the fields of an object literal (which take their own).\n */\nfunction walkValue(\n\twalk: Walk,\n\tvalue: ValueNode,\n\ttype: GraphQLInputType,\n\tconstraints: readonly Constraint[],\n\twhere: string,\n): void {\n\tif (value.kind === Kind.VARIABLE) {\n\t\tif (!walk.variables.has(value.name.value)) return;\n\t\tconst list = walk.found.get(value.name.value) ?? [];\n\t\tlist.push({ where, constraints });\n\t\twalk.found.set(value.name.value, list);\n\t\treturn;\n\t}\n\tconst nullable = isNonNullType(type) ? type.ofType : type;\n\tif (value.kind === Kind.LIST && isListType(nullable)) {\n\t\tconst items = constraints.filter(({ rule }) => rule.target !== 'list');\n\t\tfor (const item of value.values)\n\t\t\twalkValue(walk, item, nullable.ofType, items, where);\n\t\treturn;\n\t}\n\tconst named = getNamedType(type);\n\tif (value.kind === Kind.OBJECT && isInputObjectType(named)) {\n\t\tfor (const field of value.fields) {\n\t\t\tconst definition = named.getFields()[field.name.value];\n\t\t\tif (definition) {\n\t\t\t\twalkValue(\n\t\t\t\t\twalk,\n\t\t\t\t\tfield.value,\n\t\t\t\t\tdefinition.type,\n\t\t\t\t\tconstraintsOn(walk.directive, definition.astNode),\n\t\t\t\t\t`${named.name}.${definition.name}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Every constraint of every usage, once each, `format` first. Two\n * different formats cannot both be written (each replaces the schema), so\n * they fail generation, naming both places.\n */\nfunction merged(usages: readonly Usage[], where: string): Constraint[] {\n\tconst all: (Constraint & { readonly at: string })[] = [];\n\tfor (const usage of usages) {\n\t\tfor (const constraint of usage.constraints) {\n\t\t\tconst same = all.some(\n\t\t\t\t(known) =>\n\t\t\t\t\tknown.rule === constraint.rule && known.value === constraint.value,\n\t\t\t);\n\t\t\tif (!same) all.push({ ...constraint, at: usage.where });\n\t\t}\n\t}\n\tconst bases = all.filter(({ rule }) => rule.base);\n\tconst [first, second] = bases;\n\tif (first && second) {\n\t\tthrow new Error(\n\t\t\t`@nxgt/graphql-codegen-zod: ${where} is passed to ${first.at} (${first.rule.argument}: ${JSON.stringify(first.value)}) and to ${second.at} (${second.rule.argument}: ${JSON.stringify(second.value)}), whose schemas cannot both apply. Use one variable for each.`,\n\t\t);\n\t}\n\treturn [...bases, ...all.filter(({ rule }) => !rule.base)].map(\n\t\t({ rule, value }) => ({ rule, value }),\n\t);\n}\n",
15
+ "import {\n\ttype Constraint,\n\ttype InputCodeOptions,\n\tinputCode,\n} from '@nxgt/graphql-validation/codegen';\nimport {\n\ttype ConstValueNode,\n\ttype GraphQLDirective,\n\ttype GraphQLInputType,\n\ttype GraphQLNamedInputType,\n\tGraphQLNonNull,\n\ttype GraphQLScalarType,\n\tgetNamedType,\n\tisEnumType,\n\tisInputObjectType,\n\tisNonNullType,\n\tisScalarType,\n\tisSpecifiedScalarType,\n} from 'graphql';\nimport { parsedDefault } from './defaults';\nimport type { Naming } from './naming';\nimport type { ScalarSources } from './scalars';\n\n/** One value's schema as source, and whether it names an input object. */\nexport interface ValueCode {\n\treadonly code: string;\n\t/** Written behind a getter: the input object may not be declared yet. */\n\treadonly lazy: boolean;\n\t/** The member's doc comment, from its GraphQL description. */\n\treadonly description?: string | null | undefined;\n}\n\n/**\n * Writes the schema of a value of a GraphQL input type: an argument, an\n * input field, an operation variable. Enums and input objects are named by\n * their schema, custom scalars come from their mapping, and the rest is\n * `@nxgt/graphql-validation`'s `inputCode`, constraints included.\n */\nexport class Writer {\n\treadonly directive: GraphQLDirective | undefined;\n\treadonly #naming: Naming;\n\treadonly #scalars: ScalarSources;\n\n\tconstructor(\n\t\tdirective: GraphQLDirective | undefined,\n\t\tnaming: Naming,\n\t\tscalars: ScalarSources,\n\t) {\n\t\tthis.directive = directive;\n\t\tthis.#naming = naming;\n\t\tthis.#scalars = scalars;\n\t}\n\n\t/** The source of a custom scalar's schema, from its mapping. */\n\tscalarCode(type: GraphQLScalarType): string {\n\t\treturn this.#scalars.code(type);\n\t}\n\n\t/** The schema's name of an enum or an input object. */\n\tschemaName(type: GraphQLNamedInputType): string {\n\t\treturn this.#naming.schema(this.#naming.type(type.name));\n\t}\n\n\t/**\n\t * `type`'s schema with `constraints`, `where` naming it in errors. A\n\t * default makes the value optional on the way in and present on the way\n\t * out, as graphql fills it: `.prefault(<default>)`, then `.nullable()`.\n\t */\n\tvalue(\n\t\ttype: GraphQLInputType,\n\t\tconstraints: readonly Constraint[],\n\t\twhere: string,\n\t\tdefaultValue?: ConstValueNode,\n\t): ValueCode {\n\t\tlet lazy = false;\n\t\tconst named = (named: GraphQLNamedInputType): string => {\n\t\t\tif (isInputObjectType(named)) {\n\t\t\t\tlazy = true;\n\t\t\t\treturn this.schemaName(named);\n\t\t\t}\n\t\t\tif (isEnumType(named)) return this.schemaName(named);\n\t\t\treturn this.#scalars.code(named);\n\t\t};\n\t\tif (!defaultValue)\n\t\t\treturn {\n\t\t\t\tcode: inputCode(type, constraints, where, named, {\n\t\t\t\t\tlist: singleOrList,\n\t\t\t\t}),\n\t\t\t\tlazy,\n\t\t\t};\n\t\t// The default parsed as the client's value would be, then null allowed\n\t\t// after it: the key is optional on the way in, present on the way out.\n\t\tconst nullable = !isNonNullType(type);\n\t\tconst required = inputCode(\n\t\t\tnullable ? new GraphQLNonNull(type) : type,\n\t\t\tconstraints,\n\t\t\twhere,\n\t\t\tnamed,\n\t\t\t{ list: singleOrList },\n\t\t);\n\t\tconst value = JSON.stringify(parsedDefault(defaultValue, type, where));\n\t\treturn {\n\t\t\tcode: `${required}.prefault(${value})${nullable ? '.nullable()' : ''}`,\n\t\t\tlazy,\n\t\t};\n\t}\n\n\t/** `value` for a type made non-null: a `@oneOf` member, which is set. */\n\trequired(\n\t\ttype: GraphQLInputType,\n\t\tconstraints: readonly Constraint[],\n\t\twhere: string,\n\t): ValueCode {\n\t\treturn this.value(\n\t\t\tisNonNullType(type) ? type : new GraphQLNonNull(type),\n\t\t\tconstraints,\n\t\t\twhere,\n\t\t);\n\t}\n}\n\n/**\n * A list that also takes a single value, as graphql coerces it (`\"a\"` for\n * `[String]` is `[\"a\"]`, for `[[String]]` `[[\"a\"]]`): the value is wrapped,\n * then checked as the list, so a rule refuses it with the message, and at\n * the path, the server gives. An input object's or a custom scalar's schema\n * may transform (a codec decodes): its single value goes to the pipe as it\n * was sent, and is parsed once there. Never `null`: a nullable list says\n * so with its own `.nullish()`, and graphql never wraps a null.\n */\nconst singleOrList: NonNullable<InputCodeOptions['list']> = ({\n\ttype,\n\tcode,\n\tsingle,\n}) => {\n\tconst named = getNamedType(type);\n\tconst transforms =\n\t\tisInputObjectType(named) ||\n\t\t(isScalarType(named) && !isSpecifiedScalarType(named));\n\tconst first = transforms\n\t\t? `z.custom<z.input<typeof ${single}>>((value) => value != null && !Array.isArray(value))`\n\t\t: single;\n\t// `unknown[]`: the pipe needs what it hands on to fit what the list\n\t// takes, nullable items too.\n\treturn `z.union([${code}, ${first}.transform((value): unknown[] => [value]).pipe(${code})])`;\n};\n"
16
+ ],
17
+ "mappings": ";AAAA;AACA;AAAA,uBAEC;AAAA,qBACA;AAAA,kBACA;AAAA;;;ACDM,MAAM,QAAQ;AAAA,EACX,YAAY,IAAI,IAAiC;AAAA,IACzD,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AAAA,EAC9B,CAAC;AAAA,EACQ;AAAA,EAGT,WAAW,CAAC,WAA6B,CAAC,GAAG;AAAA,IAC5C,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;AAAA;AAAA,EAIzC,GAAG,CAAC,QAAgB,UAA0B;AAAA,IAC7C,MAAM,QAAQ,KAAK,UAAU,IAAI,MAAM,KA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,QAAQ;AAAA,EACpC,MAAM,SAAS,MAAM,MAAM,OAAO;AAAA,EAClC,OAAO,GAAG,QAAQ,MAAM,EAAE,KAAK;AAAA,CAAI;AAAA;AAAA,EAAQ,OAAO,KAAK;AAAA;AAAA,CAAM;AAAA;AAAA;AAQ9D,SAAS,SAAS,CAAC,QAA6B;AAAA,EAC/C,WAAW,QAAQ,OAAO,OAAO,OAAO,WAAW,CAAC,GAAG;AAAA,IACtD,IAAI,KAAK,KAAK,WAAW,IAAI;AAAA,MAAG;AAAA,IAChC,MAAM,SAAS,mBAAkB,IAAI,IAClC,OAAO,OAAO,KAAK,UAAU,CAAC,IAC9B,cAAa,IAAI,KAAK,iBAAgB,IAAI,IACzC,OAAO,OAAO,KAAK,UAAU,CAAC,EAAE,QAAQ,CAAC,UAAU,MAAM,IAAI,IAC7D,CAAC;AAAA,IACL,MAAM,OAAO,OAAO,KAAK,CAAC,UAAU,CAAC,MAAM,OAAO;AAAA,IAClD,IAAI,MAAM;AAAA,MACT,MAAM,IAAI,MACT,mEAAmE,KAAK,qGACzE;AAAA,IACD;AAAA,EACD;AAAA;",
18
+ "debugId": "AA4EFD5F1FAF8A9864756E2164756E21",
19
+ "names": []
20
+ }
@@ -0,0 +1,20 @@
1
+ import type { OperationTypeNode } from 'graphql';
2
+ import type { CodegenZodConfig } from './config';
3
+ /**
4
+ * The names of what the plugin writes: each type as
5
+ * `@graphql-codegen/typescript` and `typescript-operations` name it, each
6
+ * schema the same name behind `schemaPrefix`.
7
+ */
8
+ export declare class Naming {
9
+ #private;
10
+ constructor(config: CodegenZodConfig);
11
+ /** An input type's or an enum's type name: `SignUpInput`. */
12
+ type(name: string): string;
13
+ /** A field's arguments type name: `MutationSignUpArgs`. */
14
+ args(parent: string, field: string): string;
15
+ /** An operation's variables type name: `SignUpMutationVariables`. */
16
+ variables(operation: string, kind: OperationTypeNode): string;
17
+ /** The schema of the type named `type`: `zSignUpInput`. */
18
+ schema(type: string): string;
19
+ }
20
+ //# sourceMappingURL=naming.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../src/naming.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;GAIG;AACH,qBAAa,MAAM;;gBAIN,MAAM,EAAE,gBAAgB;IAKpC,6DAA6D;IAC7D,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI1B,2DAA2D;IAC3D,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAO3C,qEAAqE;IACrE,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,MAAM;IAY7D,2DAA2D;IAC3D,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAO5B"}
@@ -0,0 +1,21 @@
1
+ import type { GraphQLScalarType } from 'graphql';
2
+ import type { CodegenZodConfig } from './config';
3
+ import type { Imports } from './imports';
4
+ /**
5
+ * Where each custom scalar's schema comes from: `zodScalars` first, then the
6
+ * `scalarSchemas` record. A scalar in neither fails generation, naming it:
7
+ * a scalar written as `z.unknown()` would check nothing, in silence.
8
+ */
9
+ export declare class ScalarSources {
10
+ #private;
11
+ private constructor();
12
+ /**
13
+ * Loads the `scalarSchemas` module, if any, to know its keys. One that
14
+ * cannot be loaded here (a `.ts` file under Node) is trusted: the
15
+ * generated file then fails to typecheck on a missing key instead.
16
+ */
17
+ static load(config: CodegenZodConfig, imports: Imports, outputFile: string | undefined): Promise<ScalarSources>;
18
+ /** The source of `type`'s schema, its import added. */
19
+ code(type: GraphQLScalarType): string;
20
+ }
21
+ //# sourceMappingURL=scalars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scalars.d.ts","sourceRoot":"","sources":["../src/scalars.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;GAIG;AACH,qBAAa,aAAa;;IAMzB,OAAO;IAUP;;;;OAIG;WACU,IAAI,CAChB,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,GAAG,SAAS,GAC5B,OAAO,CAAC,aAAa,CAAC;IAOzB,uDAAuD;IACvD,IAAI,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM;CAsBrC"}
@@ -0,0 +1,10 @@
1
+ import { type GraphQLSchema } from 'graphql';
2
+ import type { Naming } from './naming';
3
+ import type { Writer } from './writer';
4
+ /**
5
+ * The SDL's part of the file: every enum, then every input type, then the
6
+ * arguments of every object and interface field that takes any. Types are
7
+ * `z.output`: what a resolver receives once `withValidation` parsed them.
8
+ */
9
+ export declare function schemaBlocks(schema: GraphQLSchema, writer: Writer, naming: Naming): string[];
10
+ //# sourceMappingURL=schema-output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-output.d.ts","sourceRoot":"","sources":["../src/schema-output.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,KAAK,aAAa,EAKlB,MAAM,SAAS,CAAC;AAGjB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;GAIG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACZ,MAAM,EAAE,CAwCV"}
@@ -0,0 +1,9 @@
1
+ import type { Naming } from './naming';
2
+ import type { ValueCode } from './writer';
3
+ /** A GraphQL description as a doc comment, or nothing. */
4
+ export declare function docComment(description: string | null | undefined, indent?: string): string;
5
+ /** The members of a `z.object({...})`, a getter for each lazy one. */
6
+ export declare function objectMembers(members: readonly (readonly [string, ValueCode])[]): string;
7
+ /** `export const zX = …; export type X = z.output<typeof zX>;` */
8
+ export declare function declare(typeName: string, naming: Naming, code: string, side: 'input' | 'output', description?: string | null): string;
9
+ //# sourceMappingURL=source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,0DAA0D;AAC1D,wBAAgB,UAAU,CACzB,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,MAAM,SAAK,GACT,MAAM,CAQR;AAED,sEAAsE;AACtE,wBAAgB,aAAa,CAC5B,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,EAAE,GAChD,MAAM,CASR;AAED,kEAAkE;AAClE,wBAAgB,OAAO,CACtB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,GAAG,QAAQ,EACxB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GACzB,MAAM,CAIR"}
@@ -0,0 +1,12 @@
1
+ import { type GraphQLInputObjectType } from 'graphql';
2
+ import type { Naming } from './naming';
3
+ import type { Writer } from './writer';
4
+ /**
5
+ * An input type in a cycle, declared with its types written out, since
6
+ * TypeScript cannot infer them: `Filter` (what the resolver receives),
7
+ * `FilterInput` (what a client sends), and `zFilter` typed by both. The
8
+ * schema's types must fit inside them, a type error otherwise; a type
9
+ * written wider than the schema would compile, so test/types.ts pins them.
10
+ */
11
+ export declare function declareCyclic(type: GraphQLInputObjectType, code: string, writer: Writer, naming: Naming, cyclic: ReadonlySet<string>): string;
12
+ //# sourceMappingURL=type-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-code.d.ts","sourceRoot":"","sources":["../src/type-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,sBAAsB,EAU3B,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAYvC;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC5B,IAAI,EAAE,sBAAsB,EAC5B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,GACzB,MAAM,CAUR"}
@@ -0,0 +1,13 @@
1
+ import { type GraphQLSchema } from 'graphql';
2
+ import type { DocumentFile } from './config';
3
+ import type { Naming } from './naming';
4
+ import type { Writer } from './writer';
5
+ /**
6
+ * One schema per named operation in `documents`, for its variables as a
7
+ * client sends them (`z.input`). A variable gets the constraints of every
8
+ * argument or input field it is passed to, in the operation and in the
9
+ * fragments it spreads: the client refuses what the server would.
10
+ * An anonymous operation has no name to give its schema, and gets none.
11
+ */
12
+ export declare function variablesBlocks(schema: GraphQLSchema, documents: readonly DocumentFile[], writer: Writer, naming: Naming): string[];
13
+ //# sourceMappingURL=variables-output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variables-output.d.ts","sourceRoot":"","sources":["../src/variables-output.ts"],"names":[],"mappings":"AAIA,OAAO,EAKN,KAAK,aAAa,EAYlB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,SAAS,YAAY,EAAE,EAClC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACZ,MAAM,EAAE,CAiDV"}
@@ -0,0 +1,36 @@
1
+ import { type Constraint } from '@nxgt/graphql-validation/codegen';
2
+ import { type ConstValueNode, type GraphQLDirective, type GraphQLInputType, type GraphQLNamedInputType, type GraphQLScalarType } from 'graphql';
3
+ import type { Naming } from './naming';
4
+ import type { ScalarSources } from './scalars';
5
+ /** One value's schema as source, and whether it names an input object. */
6
+ export interface ValueCode {
7
+ readonly code: string;
8
+ /** Written behind a getter: the input object may not be declared yet. */
9
+ readonly lazy: boolean;
10
+ /** The member's doc comment, from its GraphQL description. */
11
+ readonly description?: string | null | undefined;
12
+ }
13
+ /**
14
+ * Writes the schema of a value of a GraphQL input type: an argument, an
15
+ * input field, an operation variable. Enums and input objects are named by
16
+ * their schema, custom scalars come from their mapping, and the rest is
17
+ * `@nxgt/graphql-validation`'s `inputCode`, constraints included.
18
+ */
19
+ export declare class Writer {
20
+ #private;
21
+ readonly directive: GraphQLDirective | undefined;
22
+ constructor(directive: GraphQLDirective | undefined, naming: Naming, scalars: ScalarSources);
23
+ /** The source of a custom scalar's schema, from its mapping. */
24
+ scalarCode(type: GraphQLScalarType): string;
25
+ /** The schema's name of an enum or an input object. */
26
+ schemaName(type: GraphQLNamedInputType): string;
27
+ /**
28
+ * `type`'s schema with `constraints`, `where` naming it in errors. A
29
+ * default makes the value optional on the way in and present on the way
30
+ * out, as graphql fills it: `.prefault(<default>)`, then `.nullable()`.
31
+ */
32
+ value(type: GraphQLInputType, constraints: readonly Constraint[], where: string, defaultValue?: ConstValueNode): ValueCode;
33
+ /** `value` for a type made non-null: a `@oneOf` member, which is set. */
34
+ required(type: GraphQLInputType, constraints: readonly Constraint[], where: string): ValueCode;
35
+ }
36
+ //# sourceMappingURL=writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer.d.ts","sourceRoot":"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en-zod documentation
2
+
3
+ ## Guides
4
+
5
+ | Page | Read it when |
6
+ | --- | --- |
7
+ | [Output](guide/output.md) | you want to know what the plugin writes: the schemas and types, their names and options, defaults, recursion, `@oneOf`, variables, and how custom scalars are mapped |
8
+
9
+ ## Reference
10
+
11
+ | Page | Read it when |
12
+ | --- | --- |
13
+ | [Troubleshooting](troubleshooting.md) | you have an error message and want its cause |
14
+ | [Roadmap](roadmap.md) | you want to know what is coming, and what is not |