@znight/graphql 0.3.0 → 0.4.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.
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.mjs","names":["describe"],"sources":["../src/compiler/ids.ts","../src/compiler/constants.ts","../src/compiler/analyze.ts","../src/schema-hash.ts","../src/sdl.ts","../src/compiler/checks.ts","../src/compiler/defaults.ts","../src/compiler/discriminators.ts","../src/compiler/docs.ts","../src/compiler/locate.ts","../src/compiler/scalars.ts","../src/compiler/sdl-view.ts","../src/compiler/builder.ts","../src/compiler/generate.ts","../src/compiler/options.ts","../src/compiler/graphql-js.ts","../src/compiler/conformance.ts","../src/compiler/suggest.ts","../src/compiler/sdl-source.ts","../src/compiler/schema-first.ts","../src/compiler/index.ts"],"sourcesContent":["/**\n * Canonical identities the `@znight/graphql` compiler extension recognises (RFC 0005 §5.14,\n * §6.2, §6.5): its decorators, `scalar<T>()`, the scalar aliases, the loader and context types, and\n * the look-alike decorators of `@znight/http` it reports (ZNIGHT005).\n *\n * Constants only: this module must stay free of runtime imports (the compiler loads the extension\n * entry, which must never load the GraphQL runtime, graphql-js or dataloader).\n */\n\n/** Package name: the prefix of every identity below. */\nexport const GRAPHQL_PACKAGE = '@znight/graphql'\n\n/** Name of the extension, also the key of `metadata.extensions.graphql`. */\nexport const EXTENSION_NAME = 'graphql'\n\n/** Module the generated code imports its runtime helpers and types from. */\nexport const RUNTIME_MODULE = '@znight/graphql'\n\n/** Canonical identities of the exports of `@znight/graphql` the compiler reads. */\nexport const GraphQLIds: {\n /** `@Resolver(options?)`, class decorator. */\n readonly Resolver: string\n /** `@Query(name?)`, method decorator. */\n readonly Query: string\n /** `@Mutation(name?)`, method decorator. */\n readonly Mutation: string\n /** `@Subscription(name?)`, method decorator. */\n readonly Subscription: string\n /** `@ResolveField(name?)`, method decorator. */\n readonly ResolveField: string\n /** `@Args(nameOrSchema?, schema?)`, parameter decorator. */\n readonly Args: string\n /** `@Parent()`, parameter decorator. */\n readonly Parent: string\n /** `@Ctx()`, parameter decorator (`GraphQLContext`). */\n readonly Ctx: string\n /** `@Info()`, parameter decorator (graphql-js `GraphQLResolveInfo`). */\n readonly Info: string\n /** `@Loader()` parameter decorator **and** the `Loader<L>` parameter type (same export name). */\n readonly Loader: string\n /** `@UseGuard(...guards)`, class or method decorator. */\n readonly UseGuard: string\n /** `scalar<T>(name, definition)`. */\n readonly scalar: string\n /** `type ID = string` → `ID`. */\n readonly ID: string\n /** `type Int = number` → `Int`. */\n readonly Int: string\n /** `type Float = number` → `Float`. */\n readonly Float: string\n /** `type JSONValue` → `JSON`. */\n readonly JSONValue: string\n /** `interface BatchLoad<K, V>`: what loader providers implement (ZNIGHT065). */\n readonly BatchLoad: string\n /** `interface GraphQLContext`: the request-scoped external (manifest `provides`). */\n readonly GraphQLContext: string\n /** `interface ResolverContext`: what guards receive. */\n readonly ResolverContext: string\n /** `abstract class PubSub`: the singleton external (manifest `provides`). */\n readonly PubSub: string\n /** `GraphQLPlugin`: the singleton external (manifest `provides`). */\n readonly GraphQLPlugin: string\n} = Object.freeze({\n Resolver: '@znight/graphql#Resolver',\n Query: '@znight/graphql#Query',\n Mutation: '@znight/graphql#Mutation',\n Subscription: '@znight/graphql#Subscription',\n ResolveField: '@znight/graphql#ResolveField',\n Args: '@znight/graphql#Args',\n Parent: '@znight/graphql#Parent',\n Ctx: '@znight/graphql#Ctx',\n Info: '@znight/graphql#Info',\n Loader: '@znight/graphql#Loader',\n UseGuard: '@znight/graphql#UseGuard',\n scalar: '@znight/graphql#scalar',\n ID: '@znight/graphql#ID',\n Int: '@znight/graphql#Int',\n Float: '@znight/graphql#Float',\n JSONValue: '@znight/graphql#JSONValue',\n BatchLoad: '@znight/graphql#BatchLoad',\n GraphQLContext: '@znight/graphql#GraphQLContext',\n ResolverContext: '@znight/graphql#ResolverContext',\n PubSub: '@znight/graphql#PubSub',\n GraphQLPlugin: '@znight/graphql#GraphQLPlugin',\n})\n\n/** Field decorators → the kind of field they declare (`GraphQLResolverBinding.operation`). */\nexport const FIELD_DECORATORS: ReadonlyMap<string, 'query' | 'mutation' | 'subscription' | 'field'> = new Map([\n [GraphQLIds.Query, 'query'],\n [GraphQLIds.Mutation, 'mutation'],\n [GraphQLIds.Subscription, 'subscription'],\n [GraphQLIds.ResolveField, 'field'],\n])\n\n/** Parameter decorators → what the generated `invoke` passes (§7.3). */\nexport const PARAMETER_DECORATORS: ReadonlyMap<string, 'args' | 'parent' | 'ctx' | 'info' | 'loader'> = new Map([\n [GraphQLIds.Args, 'args'],\n [GraphQLIds.Parent, 'parent'],\n [GraphQLIds.Ctx, 'ctx'],\n [GraphQLIds.Info, 'info'],\n [GraphQLIds.Loader, 'loader'],\n])\n\n/** Scalar aliases of `@znight/graphql` → their GraphQL scalar (§6.2). */\nexport const SCALAR_ALIASES: ReadonlyMap<string, 'ID' | 'Int' | 'Float' | 'JSON'> = new Map([\n [GraphQLIds.ID, 'ID'],\n [GraphQLIds.Int, 'Int'],\n [GraphQLIds.Float, 'Float'],\n [GraphQLIds.JSONValue, 'JSON'],\n])\n\n/**\n * Decorators of `@znight/http` that look like GraphQL ones, on a resolver: ZNIGHT005 with the\n * `@znight/graphql` decorator to import instead (§6.5).\n */\nexport const HTTP_LOOK_ALIKES: ReadonlyMap<string, string> = new Map([\n ['@znight/http#Ctx', GraphQLIds.Ctx],\n ['@znight/http#Query', GraphQLIds.Args],\n ['@znight/http#Param', GraphQLIds.Args],\n ['@znight/http#Body', GraphQLIds.Args],\n ['@znight/http#UseGuard', GraphQLIds.UseGuard],\n])\n\n/** `@Controller` of `@znight/http`: a class cannot be both a controller and a resolver (ZNIGHT005). */\nexport const HTTP_CONTROLLER = '@znight/http#Controller'\n\n/** graphql-js `GraphQLResolveInfo`, the type of `@Info()` parameters. */\nexport const GRAPHQL_RESOLVE_INFO = 'graphql#GraphQLResolveInfo'\n","/**\n * Constants of the compiler extension modules: diagnostic codes, shape options, ordering. This\n * module must stay free of runtime imports (the compiler loads the extension entry, which must\n * never load the GraphQL runtime, graphql-js nor dataloader).\n */\nimport type { ErrorCode } from '@znight/core'\n\nimport { GraphQLIds } from './ids.ts'\n\n/** Diagnostic codes the extension reports (RFC 0005 §6.6 and the reused framework codes). */\nexport const Codes: {\n /** ZNIGHT005: decorator target, arguments, method shape, look-alikes, `@Resolver` + `@Controller`. */\n readonly InvalidDecorator: ErrorCode\n /** ZNIGHT023: a root field without a decision of a required route decorator group (RFC 0001). */\n readonly MissingRouteDecision: ErrorCode\n /** ZNIGHT060: a TypeScript type with no GraphQL mapping, a missing annotation. */\n readonly InvalidType: ErrorCode\n /** ZNIGHT061: name conflicts, invalid or reserved names, field resolver type mismatches. */\n readonly NameConflict: ErrorCode\n /** ZNIGHT062: resolver structure (parent, subscriptions, no query, inheritance, libraries). */\n readonly InvalidResolver: ErrorCode\n /** ZNIGHT063: input position problems (dual use, getters, unions, cycles, defaults). */\n readonly InvalidInput: ErrorCode\n /** ZNIGHT064: union members that cannot be told apart at runtime. */\n readonly UnresolvableAbstractType: ErrorCode\n /** ZNIGHT065: `@Loader()` parameters and loader providers. */\n readonly InvalidLoader: ErrorCode\n /** ZNIGHT067: schema-first SDL files (RFC 0007): reading, syntax, validation, unsupported constructs. */\n readonly InvalidSdl: ErrorCode\n /** ZNIGHT068: schema-first resolvers against the SDL (RFC 0007): coverage and type conformance. */\n readonly SchemaMismatch: ErrorCode\n} = Object.freeze({\n InvalidDecorator: 'ZNIGHT005',\n MissingRouteDecision: 'ZNIGHT023',\n InvalidType: 'ZNIGHT060',\n NameConflict: 'ZNIGHT061',\n InvalidResolver: 'ZNIGHT062',\n InvalidInput: 'ZNIGHT063',\n UnresolvableAbstractType: 'ZNIGHT064',\n InvalidLoader: 'ZNIGHT065',\n InvalidSdl: 'ZNIGHT067',\n SchemaMismatch: 'ZNIGHT068',\n})\n\n/** Root reason given to `AnalyzeContext.addRoot()`. */\nexport const ROOT_REASON = 'GraphQL resolver'\n\n/** Async iterables: the return type of `@Subscription` methods (§6.2). */\nexport const ASYNC_ITERABLES: ReadonlySet<string> = new Set([\n 'globalThis#AsyncIterable',\n 'globalThis#AsyncIterableIterator',\n 'globalThis#AsyncGenerator',\n])\n\n/** Iterables mapped to lists in output position (§6.2). */\nexport const OUTPUT_ITERABLES: ReadonlySet<string> = new Set([\n 'globalThis#Set',\n 'globalThis#ReadonlySet',\n 'globalThis#Iterable',\n])\n\n/**\n * Identities the shapes keep as references (`ShapeOptions.keep`), before the identities of the\n * `scalar<T>()` declarations of the application.\n */\nexport const BASE_KEEP: readonly string[] = Object.freeze([\n ...ASYNC_ITERABLES,\n ...OUTPUT_ITERABLES,\n GraphQLIds.ID,\n GraphQLIds.Int,\n GraphQLIds.Float,\n GraphQLIds.JSONValue,\n GraphQLIds.Loader,\n])\n\n/** Deterministic string comparison (code-unit order, never `localeCompare`). */\nexport function compareStrings(a: string, b: string): number {\n if (a === b) return 0\n return a < b ? -1 : 1\n}\n","/**\n * `analyzeClass` of the graphql extension (RFC 0005 §6.1, §6.5): registers `@Resolver` classes as\n * providers (and roots), checks their field methods and parameters, binds `@UseGuard` guards and\n * `Loader<L>` parameters with lazy edges (resolved per call, in the current scope), reads route\n * decorators with the readers of `@znight/http/compiler`, and stores one {@link ResolverData} per\n * resolver. Types are not read here: `validate` builds the schema model from the method signatures.\n */\n\nimport type {\n AnalyzeContext,\n ClassInfo,\n ClassRef,\n DecoratorInfo,\n Location,\n MethodInfo,\n ParameterInfo,\n StaticValue,\n} from '@znight/compiler'\nimport type { Scope } from '@znight/core'\nimport type { MetaEntry } from '@znight/http/compiler'\nimport type { FieldData, FieldOperation, GraphQLData, ParamData, ResolverData } from './data.ts'\nimport type { ResolvedGraphQLCompilerOptions } from './options.ts'\n\nimport { effectiveRouteMeta, readRouteMeta } from '@znight/http/compiler'\n\nimport { isGraphQLName } from '../names.ts'\nimport { Codes, ROOT_REASON } from './constants.ts'\nimport {\n EXTENSION_NAME,\n FIELD_DECORATORS,\n GraphQLIds,\n HTTP_CONTROLLER,\n HTTP_LOOK_ALIKES,\n PARAMETER_DECORATORS,\n RUNTIME_MODULE,\n} from './ids.ts'\n\ntype Context = AnalyzeContext<GraphQLData>\n\nconst SCOPES: readonly Scope[] = ['singleton', 'request', 'transient']\n\n/** Shape options reading `Loader<L>` parameters: the alias is kept, `L` stays a named shape. */\nconst LOADER_SHAPE = Object.freeze({ keep: Object.freeze([GraphQLIds.Loader]), jsdoc: false })\n\n/**\n * Analyses a class carrying at least one graphql decorator (class, method or parameter). In\n * schema-first mode (RFC 0007), `@Resolver('Type')` names the SDL type of the field resolvers and\n * `@Parent()` is optional.\n */\nexport function analyzeGraphQLClass(cls: ClassInfo, ctx: Context, options: ResolvedGraphQLCompilerOptions): void {\n const resolvers = cls.decorators.filter(decorator => decorator.identity === GraphQLIds.Resolver)\n const resolver = resolvers[0]\n if (resolver === undefined) {\n reportOutsideResolver(cls, ctx)\n storeClaims(ctx, cls, undefined, options)\n return\n }\n for (const extra of resolvers.slice(1)) {\n error(ctx, Codes.InvalidDecorator, extra.location, `@Resolver is applied twice to ${cls.displayName}`, [\n 'Apply it once',\n ])\n }\n const controller = cls.decorators.find(decorator => decorator.identity === HTTP_CONTROLLER)\n if (controller !== undefined) {\n error(\n ctx,\n Codes.InvalidDecorator,\n resolver.location,\n `${cls.displayName} cannot be both a @Resolver and a @Controller`,\n [\n 'A class is the provider of one extension: move the GraphQL fields to their own @Resolver() class (both may call the same service)',\n ],\n [{ message: '@Controller is applied here', location: controller.location }],\n )\n storeClaims(ctx, cls, resolver, options)\n return\n }\n if (ctx.options.library) {\n error(\n ctx,\n Codes.InvalidResolver,\n resolver.location,\n `${cls.displayName} is a @Resolver in a compiled provider library: the schema is derived from the sources`,\n ['Publish the package as a source library (without library: true), so that applications compile its resolvers'],\n )\n storeClaims(ctx, cls, resolver, options)\n return\n }\n if (cls.abstract || cls.typeParameters.length > 0) {\n error(\n ctx,\n Codes.InvalidDecorator,\n resolver.location,\n cls.abstract\n ? `@Resolver cannot be applied to the abstract class ${cls.displayName}`\n : `@Resolver cannot be applied to the generic class ${cls.displayName}<${cls.typeParameters.join(', ')}>`,\n [cls.abstract ? 'Resolvers are instantiated: remove `abstract`' : 'Remove the type parameters of the resolver'],\n )\n storeClaims(ctx, cls, resolver, options)\n return\n }\n\n const { scope, typeName } = resolverArguments(ctx, resolver, options.schema !== false)\n ctx.registerProvider(cls, { scope })\n // resolvers are entry points of the plugin: roots of ZNIGHT019 and prune\n ctx.addRoot(cls, { reason: ROOT_REASON, location: resolver.location })\n\n const classGuards = guardsOf(ctx, cls, cls.decorators)\n const classMeta = readRouteMeta(ctx, cls)\n const fields: FieldData[] = []\n for (const method of cls.methods) {\n const decorators = method.decorators.filter(isFieldDecorator)\n if (decorators.length === 0) {\n reportStrayMethodDecorators(cls, method, ctx)\n continue\n }\n fields.push(...analyzeMethod(ctx, cls, method, decorators, classMeta, options.schema !== false))\n }\n const data: ResolverData = {\n kind: 'resolver',\n host: cls,\n scope,\n location: resolver.location,\n guards: classGuards,\n fields,\n ...(typeName === undefined ? {} : { typeName }),\n }\n if (options.schema !== false && typeName === undefined) {\n for (const field of fields) {\n if (field.operation !== 'field') continue\n error(\n ctx,\n Codes.InvalidResolver,\n field.location,\n `@ResolveField ${cls.displayName}.${field.method} needs the type it resolves a field of: name it in @Resolver (schema-first)`,\n [\n `@Resolver('Event') on ${cls.displayName}, where Event is the object type of the SDL declaring '${field.name}'`,\n ],\n )\n }\n }\n ctx.store(data)\n}\n\n/**\n * Schema-first: a class rejected above (no `@Resolver`, abstract, a controller...) still names the\n * fields its methods resolve, stored as an `invalid` resolver, so that these fields are not also\n * reported as missing a resolver (one diagnostic per mistake).\n */\nfunction storeClaims(\n ctx: Context,\n cls: ClassInfo,\n resolver: DecoratorInfo | undefined,\n options: ResolvedGraphQLCompilerOptions,\n): void {\n if (options.schema === false) return\n const typeArg = resolver?.args[0]\n const typeName =\n typeArg?.evaluated === true && typeof typeArg.value === 'string'\n ? { name: typeArg.value, location: typeArg.location }\n : undefined\n const fields: FieldData[] = []\n for (const method of cls.methods) {\n for (const decorator of method.decorators.filter(isFieldDecorator)) {\n const arg = decorator.args[0]\n fields.push({\n method: method.name,\n operation: FIELD_DECORATORS.get(decorator.identity as string) as FieldOperation,\n name: arg?.evaluated === true && typeof arg.value === 'string' ? arg.value : method.name,\n location: decorator.location,\n methodLocation: method.location,\n guards: [],\n meta: [],\n params: [],\n complete: false,\n })\n }\n }\n if (fields.length === 0) return\n ctx.store({\n kind: 'resolver',\n host: cls,\n scope: 'singleton',\n location: resolver?.location ?? cls.location,\n guards: [],\n fields,\n invalid: true,\n ...(typeName === undefined ? {} : { typeName }),\n })\n}\n\nfunction isFieldDecorator(decorator: DecoratorInfo): boolean {\n return decorator.identity !== undefined && FIELD_DECORATORS.has(decorator.identity)\n}\n\nfunction isParameterDecorator(decorator: DecoratorInfo): boolean {\n return decorator.identity !== undefined && PARAMETER_DECORATORS.has(decorator.identity)\n}\n\n/** `@Resolver()`, `@Resolver({ scope })`, `@Resolver('Event')`, `@Resolver('Event', { scope })` (schema-first). */\nfunction resolverArguments(\n ctx: Context,\n decorator: DecoratorInfo,\n schemaFirst: boolean,\n): { scope: Scope; typeName?: { readonly name: string; readonly location: Location } } {\n const [first, second] = decorator.args\n if (first?.evaluated !== true || typeof first.value !== 'string') {\n if (second !== undefined) {\n error(ctx, Codes.InvalidDecorator, second.location, '@Resolver takes the options as its only argument here', [\n \"@Resolver({ scope: 'request' }), or @Resolver('Event', { scope: 'request' }) in schema-first mode\",\n ])\n }\n return { scope: resolverScope(ctx, first) }\n }\n const scope = resolverScope(ctx, second)\n const name = first.value\n if (!schemaFirst) {\n error(\n ctx,\n Codes.InvalidDecorator,\n first.location,\n `@Resolver('${name}'): naming the type is schema-first only, the code-first schema is derived from the types`,\n [\n 'Remove the type name: @ResolveField methods add fields to the type of their @Parent() parameter',\n \"Or switch to schema-first: graphql.configure({ schema: 'src/**/*.graphql' }) in znight.config.ts\",\n ],\n )\n return { scope }\n }\n if (!isGraphQLName(name)) {\n error(ctx, Codes.NameConflict, first.location, `'${name}' is not a valid GraphQL type name (@Resolver)`, [\n 'GraphQL names match /^[_A-Za-z][_0-9A-Za-z]*$/ and do not start with __',\n ])\n return { scope }\n }\n return { scope, typeName: { name, location: first.location } }\n}\n\n/** The `{ scope }` options of `@Resolver`. */\nfunction resolverScope(ctx: Context, arg: DecoratorInfo['args'][number] | undefined): Scope {\n if (arg === undefined || !arg.evaluated || arg.value === undefined) return 'singleton'\n const value = arg.value\n if (!isRecord(value)) {\n error(ctx, Codes.InvalidDecorator, arg.location, `@Resolver expects { scope? }, got ${describe(value)}`, [\n \"@Resolver() or @Resolver({ scope: 'request' })\",\n ])\n return 'singleton'\n }\n let scope: Scope = 'singleton'\n for (const [key, option] of Object.entries(value)) {\n if (key !== 'scope') {\n error(ctx, Codes.InvalidDecorator, arg.location, `@Resolver: unknown option \"${key}\"`, ['Options: { scope? }'])\n } else if (SCOPES.includes(option as Scope)) {\n scope = option as Scope\n } else if (option !== undefined) {\n error(ctx, Codes.InvalidDecorator, arg.location, `@Resolver: invalid scope ${describe(option)}`, [\n `Use one of ${SCOPES.map(candidate => `'${candidate}'`).join(', ')}`,\n ])\n }\n }\n return scope\n}\n\n/** `@UseGuard(A, B)` decorators of a target: guard classes bound with lazy edges (C3). */\nfunction guardsOf(ctx: Context, cls: ClassInfo, decorators: readonly DecoratorInfo[]): ClassRef[] {\n const guards: ClassRef[] = []\n for (const decorator of decorators) {\n if (decorator.identity !== GraphQLIds.UseGuard) continue\n if (decorator.args.length === 0) {\n error(ctx, Codes.InvalidDecorator, decorator.location, '@UseGuard needs at least one guard class', [\n '@UseGuard(AccessGuard)',\n ])\n }\n for (const arg of decorator.args) {\n // resolved per resolver call in the current scope: a singleton resolver may use a request-scoped guard\n const ref = ctx.resolveClassRef(arg, { from: cls, role: 'guard', lazy: true })\n if (ref !== undefined) guards.push(ref)\n }\n }\n return guards\n}\n\n// ------------------------------------------------------------------------------------------ methods\n\nfunction analyzeMethod(\n ctx: Context,\n cls: ClassInfo,\n method: MethodInfo,\n decorators: readonly DecoratorInfo[],\n classMeta: readonly MetaEntry[],\n schemaFirst: boolean,\n): FieldData[] {\n const where = `${cls.displayName}.${method.name}`\n const primary = decorators[0] as DecoratorInfo\n let complete = checkMethodShape(ctx, method, primary, where)\n complete = checkForeignHandler(ctx, method, primary, where) && complete\n const params: (ParamData | undefined)[] = []\n for (const param of method.params) {\n const data = analyzeParameter(ctx, cls, param, where)\n params.push(data)\n if (data === undefined) complete = false\n }\n const parents = params.filter(param => param?.kind === 'parent')\n for (const extra of parents.slice(1)) {\n error(\n ctx,\n Codes.InvalidResolver,\n (extra as { location: Location }).location,\n `${where} has several @Parent() parameters`,\n ['Declare the parent object once'],\n )\n complete = false\n }\n const guards = guardsOf(ctx, cls, method.decorators)\n const meta = effectiveRouteMeta(classMeta, readRouteMeta(ctx, cls, method))\n\n const fields: FieldData[] = []\n const seen = new Set<string>()\n for (const decorator of decorators) {\n const operation = FIELD_DECORATORS.get(decorator.identity as string) as FieldOperation\n const explicit = fieldName(ctx, decorator, method, where)\n // an invalid name is reported: the field stays known (incomplete), so no \"no @Query\" cascade\n const name = explicit ?? method.name\n const key = `${operation}\\0${name}`\n if (seen.has(key)) {\n error(\n ctx,\n Codes.InvalidDecorator,\n decorator.location,\n `@${decorator.name}('${name}') is applied twice to ${where}`,\n ['Apply each field decorator once'],\n )\n continue\n }\n seen.add(key)\n let fieldComplete = complete && explicit !== undefined\n // schema-first: the type is named by @Resolver('Type'), the parent is optional (NestJS)\n if (operation === 'field' && parents.length === 0 && !schemaFirst) {\n error(ctx, Codes.InvalidResolver, decorator.location, `@ResolveField ${where} has no @Parent() parameter`, [\n `Declare the parent object first: ${method.name}(@Parent() parent: ParentType, ...)`,\n ])\n fieldComplete = false\n } else if (operation !== 'field' && parents.length > 0) {\n error(\n ctx,\n Codes.InvalidResolver,\n (parents[0] as { location: Location }).location,\n `@Parent() is only available in @ResolveField methods, not in the @${decorator.name} ${where}`,\n ['Root fields have no parent object: remove the parameter'],\n )\n fieldComplete = false\n }\n fields.push({\n method: method.name,\n operation,\n name,\n location: decorator.location,\n methodLocation: method.location,\n guards,\n meta,\n params,\n complete: fieldComplete,\n })\n }\n return fields\n}\n\n/** The field name: the static decorator argument, or the method name. */\nfunction fieldName(ctx: Context, decorator: DecoratorInfo, method: MethodInfo, where: string): string | undefined {\n const arg = decorator.args[0]\n if (arg === undefined || (arg.evaluated && arg.value === undefined)) {\n if (isGraphQLName(method.name)) return method.name\n error(\n ctx,\n Codes.NameConflict,\n decorator.location,\n `'${method.name}' is not a valid GraphQL field name (${where}): name the field in the decorator`,\n ['GraphQL names match /^[_A-Za-z][_0-9A-Za-z]*$/ and do not start with __', `@${decorator.name}('validName')`],\n )\n return undefined\n }\n if (!arg.evaluated) return undefined // not statically evaluable: reported by the compiler\n const value = arg.value\n if (typeof value !== 'string') {\n error(\n ctx,\n Codes.InvalidDecorator,\n arg.location,\n `@${decorator.name} on ${where} expects a field name, got ${describe(value)}`,\n [`@${decorator.name}('${method.name}') or @${decorator.name}()`],\n )\n return undefined\n }\n if (!isGraphQLName(value)) {\n error(ctx, Codes.NameConflict, arg.location, `'${value}' is not a valid GraphQL field name (${where})`, [\n 'GraphQL names match /^[_A-Za-z][_0-9A-Za-z]*$/ and do not start with __',\n ])\n return undefined\n }\n return value\n}\n\n/** Resolver methods are called by the generated code: `resolver.method(...)`. */\nfunction checkMethodShape(ctx: Context, method: MethodInfo, decorator: DecoratorInfo, where: string): boolean {\n const name = `@${decorator.name}`\n let problem: { message: string; hint: string } | undefined\n if (method.kind !== 'method') {\n problem = { message: `${name} cannot be applied to the accessor ${where}`, hint: 'Use a regular method' }\n } else if (method.static) {\n problem = {\n message: `${name} cannot be applied to the static method ${where}`,\n hint: 'Fields are resolved on the resolver instance: remove `static`',\n }\n } else if (method.privateName) {\n problem = {\n message: `${name} cannot be applied to the #private method ${where}`,\n hint: 'Use a public method: the generated code calls it',\n }\n } else if (method.visibility !== 'public') {\n problem = {\n message: `${where} must be public: ${name} methods are called by the generated code`,\n hint: `Remove the '${method.visibility}' modifier`,\n }\n } else if (method.computed) {\n problem = {\n message: `${name} cannot be applied to ${where}: computed method names are not supported`,\n hint: 'Use a plain method name',\n }\n } else if (method.typeParameters.length > 0) {\n problem = {\n message: `${name} cannot be applied to the generic method ${where}<${method.typeParameters.join(', ')}>`,\n hint: 'The schema is derived from the signature: remove the type parameters',\n }\n }\n if (problem === undefined) return true\n error(ctx, Codes.InvalidDecorator, decorator.location, problem.message, [problem.hint])\n return false\n}\n\n/** A resolver method cannot also be handled by another extension (`@Get`, `@OnMessage`, `@Cron`). */\nfunction checkForeignHandler(ctx: Context, method: MethodInfo, decorator: DecoratorInfo, where: string): boolean {\n for (const other of method.decorators) {\n const owner = other.owner\n if (owner === undefined || owner === EXTENSION_NAME || owner === 'core' || owner === 'manifest') continue\n error(\n ctx,\n Codes.InvalidDecorator,\n other.location,\n `${where} cannot be both a GraphQL field (@${decorator.name}) and a @${other.name} handler`,\n ['A class is the provider of one extension: let both handlers call a shared service'],\n )\n return false\n }\n return true\n}\n\n// --------------------------------------------------------------------------------------- parameters\n\n/**\n * Graphql parameter decorators of a parameter, de-duplicated by position (the compiler reports the\n * decorators of a parameter with a default value twice).\n */\nfunction parameterDecorators(param: ParameterInfo): DecoratorInfo[] {\n const seen = new Set<number>()\n return param.decorators.filter(decorator => {\n if (!isParameterDecorator(decorator) || seen.has(decorator.location.start)) return false\n seen.add(decorator.location.start)\n return true\n })\n}\n\nfunction analyzeParameter(ctx: Context, cls: ClassInfo, param: ParameterInfo, where: string): ParamData | undefined {\n const decorators = parameterDecorators(param)\n const decorator = decorators[0]\n if (decorator === undefined) {\n const lookAlike = param.decorators.find(\n found => found.identity !== undefined && HTTP_LOOK_ALIKES.has(found.identity),\n )\n if (lookAlike !== undefined) {\n const replacement = (HTTP_LOOK_ALIKES.get(lookAlike.identity as string) as string).split('#')[1] as string\n error(\n ctx,\n Codes.InvalidDecorator,\n lookAlike.location,\n `@${lookAlike.name} on parameter '${param.name}' of ${where} is imported from '@znight/http': resolver parameters use @${replacement}() from '${RUNTIME_MODULE}'`,\n [`Import it from '${RUNTIME_MODULE}': import { ${replacement} } from '${RUNTIME_MODULE}'`],\n )\n return undefined\n }\n error(\n ctx,\n Codes.InvalidDecorator,\n param.location,\n `Parameter '${param.name}' of ${where} has no @Args(), @Parent(), @Ctx(), @Info() or @Loader() decorator`,\n [\n 'Every resolver parameter is filled by GraphQL: @Args(name?, schema?) for arguments, @Parent() for the parent object, @Ctx() for the GraphQLContext, @Info() for the GraphQLResolveInfo, @Loader() for a DataLoader',\n ],\n )\n return undefined\n }\n if (decorators.length > 1) {\n error(\n ctx,\n Codes.InvalidDecorator,\n (decorators[1] as DecoratorInfo).location,\n `Parameter '${param.name}' of ${where} has several GraphQL decorators (${decorators.map(found => `@${found.name}`).join(', ')})`,\n ['Keep a single one'],\n )\n return undefined\n }\n if (param.rest) {\n error(\n ctx,\n Codes.InvalidDecorator,\n decorator.location,\n `@${decorator.name} cannot be applied to the rest parameter '...${param.name}' of ${where}`,\n )\n return undefined\n }\n switch (PARAMETER_DECORATORS.get(decorator.identity as string)) {\n case 'args':\n return argsParameter(ctx, decorator, param, where)\n case 'parent':\n return { kind: 'parent', location: decorator.location }\n case 'ctx':\n return { kind: 'ctx' }\n case 'info':\n return { kind: 'info' }\n default:\n return loaderParameter(ctx, cls, param, where)\n }\n}\n\n/** `@Args()`, `@Args('name')`, `@Args('name', Schema)`, `@Args(Schema)`. */\nfunction argsParameter(\n ctx: Context,\n decorator: DecoratorInfo,\n param: ParameterInfo,\n where: string,\n): ParamData | undefined {\n const [first, second, ...extra] = decorator.args\n if (extra.length > 0) {\n error(ctx, Codes.InvalidDecorator, decorator.location, `@Args takes at most two arguments (${where})`, [\n \"@Args(), @Args('name'), @Args('name', Schema) or @Args(Schema)\",\n ])\n return undefined\n }\n let name: string | undefined\n let schemaArg = second\n if (first !== undefined) {\n if (!first.evaluated && first.ref === undefined) return undefined // reported by the compiler\n if (typeof first.value === 'string') {\n if (!isGraphQLName(first.value)) {\n error(\n ctx,\n Codes.NameConflict,\n first.location,\n `'${first.value}' is not a valid GraphQL argument name (parameter '${param.name}' of ${where})`,\n ['GraphQL names match /^[_A-Za-z][_0-9A-Za-z]*$/ and do not start with __'],\n )\n return undefined\n }\n name = first.value\n } else if (first.ref !== undefined) {\n if (second !== undefined) {\n error(ctx, Codes.InvalidDecorator, second.location, `@Args(Schema) takes no second argument (${where})`, [\n \"@Args('name', Schema) validates one argument, @Args(Schema) every argument\",\n ])\n return undefined\n }\n schemaArg = first\n } else if (first.value !== undefined) {\n error(\n ctx,\n Codes.InvalidDecorator,\n first.location,\n `@Args on parameter '${param.name}' of ${where} expects an argument name or a schema, got ${describe(first.value)}`,\n [\"@Args('id'), @Args() or @Args('input', Schema)\"],\n )\n return undefined\n }\n }\n if (schemaArg !== undefined && !(schemaArg.evaluated && schemaArg.value === undefined)) {\n if (schemaArg.ref === undefined) {\n if (schemaArg.evaluated) {\n error(\n ctx,\n Codes.InvalidDecorator,\n schemaArg.location,\n `The schema of @Args on parameter '${param.name}' of ${where} must be a reference to an exported schema`,\n ['Declare it with `export const Schema = z.object(...)` and pass Schema: the generated module imports it'],\n )\n }\n return undefined\n }\n return { kind: 'args', name, schema: schemaArg.ref, location: decorator.location }\n }\n return { kind: 'args', name, schema: undefined, location: decorator.location }\n}\n\n/** `@Loader() authors: Loader<AuthorsById>`: binds `AuthorsById` with a lazy edge. */\nfunction loaderParameter(ctx: Context, cls: ClassInfo, param: ParameterInfo, where: string): ParamData | undefined {\n const root = ctx.types.shape({ parameter: param }, LOADER_SHAPE)\n const shape = root.root\n const argument = shape.kind === 'reference' && shape.identity === GraphQLIds.Loader ? shape.typeArgs[0] : undefined\n const identity = argument?.kind === 'named' ? root.named.get(argument.key)?.identity : undefined\n if (identity === undefined) {\n error(\n ctx,\n Codes.InvalidLoader,\n param.typeLocation,\n `@Loader() parameter '${param.name}' of ${where} must be typed Loader<L>, with L a loader class`,\n [\n `${param.name}: Loader<AuthorsById>, where AuthorsById is a provider implementing BatchLoad<K, V> (import type { Loader } from '${RUNTIME_MODULE}')`,\n ],\n )\n return undefined\n }\n // the DataLoader is created per execution, in the current scope: a lazy edge (no ZNIGHT003)\n const binding = ctx.bindInjection(\n { type: identity, location: param.typeLocation, label: `loader '${param.name}' of ${where}()` },\n { from: cls, lazy: true },\n )\n return { kind: 'loader', binding, identity, location: param.typeLocation }\n}\n\n// ------------------------------------------------------------------------------------ outside resolvers\n\n/**\n * Graphql decorators on a class without `@Resolver`: field methods are not inherited (a base\n * class), and parameter or guard decorators have no effect.\n */\nfunction reportOutsideResolver(cls: ClassInfo, ctx: Context): void {\n for (const decorator of cls.decorators) {\n if (decorator.identity === GraphQLIds.UseGuard) {\n error(\n ctx,\n Codes.InvalidDecorator,\n decorator.location,\n `@UseGuard has no effect: ${cls.displayName} is not a @Resolver`,\n [`Add @Resolver() to ${cls.displayName}`],\n )\n }\n }\n for (const method of cls.methods) {\n const fields = method.decorators.filter(isFieldDecorator)\n for (const field of fields) {\n error(\n ctx,\n Codes.InvalidResolver,\n field.location,\n `@${field.name} ${cls.displayName}.${method.name} is declared on a class that is not a @Resolver`,\n [\n cls.abstract\n ? `Resolver methods are not inherited: declare the field on the concrete @Resolver() class (it may call ${method.name} of the base class)`\n : `Add @Resolver() to ${cls.displayName} (resolver methods are not inherited from base classes)`,\n ],\n )\n }\n if (fields.length === 0) reportStrayMethodDecorators(cls, method, ctx)\n }\n}\n\n/** `@UseGuard` or parameter decorators on a method that is not a field. */\nfunction reportStrayMethodDecorators(cls: ClassInfo, method: MethodInfo, ctx: Context): void {\n const where = `${cls.displayName}.${method.name}`\n for (const decorator of method.decorators) {\n if (decorator.identity === GraphQLIds.UseGuard) {\n error(\n ctx,\n Codes.InvalidDecorator,\n decorator.location,\n `@UseGuard has no effect: ${where} is not a GraphQL field`,\n ['Add @Query(), @Mutation(), @Subscription() or @ResolveField() to the method'],\n )\n }\n }\n for (const param of method.params) {\n for (const decorator of parameterDecorators(param)) {\n error(\n ctx,\n Codes.InvalidDecorator,\n decorator.location,\n `@${decorator.name} has no effect: ${where} is not a GraphQL field`,\n ['Add @Query(), @Mutation(), @Subscription() or @ResolveField() to the method'],\n )\n }\n }\n}\n\n// ------------------------------------------------------------------------------------------ helpers\n\nfunction error(\n ctx: Context,\n code: (typeof Codes)[keyof typeof Codes],\n location: Location,\n message: string,\n hints: readonly string[] = [],\n related: readonly { readonly message: string; readonly location: Location }[] = [],\n): void {\n ctx.report({\n code,\n severity: 'error',\n message,\n location,\n ...(hints.length === 0 ? {} : { hints }),\n ...(related.length === 0 ? {} : { related }),\n })\n}\n\n/** An evaluated object literal (not an array, not a reference). */\nfunction isRecord(value: StaticValue): value is Readonly<Record<string, StaticValue>> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false\n const prototype: unknown = Object.getPrototypeOf(value)\n return prototype === Object.prototype || prototype === null\n}\n\n/** Short description of a value for messages. */\nexport function describe(value: StaticValue): string {\n if (value === undefined) return 'undefined'\n if (value === null) return 'null'\n if (typeof value === 'string') return JSON.stringify(value)\n if (typeof value === 'bigint') return `${value}n`\n if (typeof value !== 'object') return String(value)\n if (Array.isArray(value)) return 'an array'\n return isRecord(value) ? 'an object' : 'a reference'\n}\n","/**\n * `schemaHash` of `metadata.extensions.graphql` (RFC 0005 §7.1): the first 16 hexadecimal\n * characters of the SHA-256 of the SDL printed by `printSdl()`.\n *\n * Separate from the import-free `sdl.ts` because it needs `node:crypto`. That is fine on both sides:\n * the compiler extension runs at build time on Node.js or Bun, and the runtime targets Node.js >= 24\n * and Bun >= 1.3, which both provide `node:crypto`. The module reaches nothing else, so the\n * `./compiler` boundaries hold (tests/boundaries.test.ts).\n */\nimport { createHash } from 'node:crypto'\n\n/** Length of a schema hash, in hexadecimal characters. */\nexport const SCHEMA_HASH_LENGTH = 16\n\n/** First 16 hexadecimal characters of the SHA-256 of `sdl` (UTF-8). */\nexport function schemaHash(sdl: string): string {\n return createHash('sha256').update(sdl, 'utf8').digest('hex').slice(0, SCHEMA_HASH_LENGTH)\n}\n","/**\n * Deterministic SDL printer (RFC 0005 §6.7, §7.3).\n *\n * Prints a schema model (the data of `metadata.extensions.graphql`, without its functions) exactly\n * like graphql-js 17 `printSchema()` prints the `GraphQLSchema` the runtime builds from it: same\n * order, same block strings, same default value literals, byte for byte. The compiler hashes this\n * output (`schemaHash`) and writes it as the optional SDL artifact; the runtime can print without\n * graphql-js.\n *\n * Import-free (types and constants of import-free modules only): shared by the compiler extension\n * and the runtime. Equivalence holds when the runtime builds the schema the way this module\n * assumes:\n *\n * - every type of the model passed to `new GraphQLSchema({ types })` in model order (metadata types\n * are sorted by name), so the type map, hence `printSchema`, follows that order;\n * - default values passed as `default: { value }` (external values: enum values by name), printed\n * by graphql-js through `valueToLiteral`;\n * - built-in scalars (`names.ts`) without description, with their `specifiedByURL`, and no scalar\n * with a custom `valueToLiteral` used in a default value.\n */\nimport { BUILTIN_SCALARS, DEFAULT_DEPRECATION_REASON, ROOT_TYPE_NAMES, SPECIFIED_SCALARS } from './names.ts'\nimport { type GraphQLTypeRef, parseTypeRef } from './type-ref.ts'\n\n/** The schema to print: the shape of `GraphQLMetadata` without resolvers nor scalar implementations. */\nexport interface SdlSchema {\n readonly roots: SdlRoots\n /** Printed in this order (graphql-js specified scalars are skipped). */\n readonly types: readonly SdlType[]\n}\n\n/** Names of the root operation types. */\nexport interface SdlRoots {\n readonly query: string\n readonly mutation?: string\n readonly subscription?: string\n}\n\n/** A named type of the schema. */\nexport type SdlType = SdlObjectType | SdlInterfaceType | SdlInputType | SdlEnumType | SdlUnionType | SdlScalarType\n\n/** What every named type has. */\nexport interface SdlNamedType {\n readonly name: string\n readonly description?: string\n}\n\n/** An object type (`type Book { ... }`). */\nexport interface SdlObjectType extends SdlNamedType {\n readonly kind: 'object'\n /** Implemented interfaces, in declaration order. */\n readonly interfaces?: readonly string[]\n readonly fields: readonly SdlField[]\n}\n\n/** An interface type (`interface Node { ... }`). */\nexport interface SdlInterfaceType extends SdlNamedType {\n readonly kind: 'interface'\n readonly interfaces?: readonly string[]\n readonly fields: readonly SdlField[]\n}\n\n/** A field of an object type. */\nexport interface SdlField {\n readonly name: string\n /** Type reference (`'[Book!]!'`). */\n readonly type: string\n readonly description?: string\n readonly deprecationReason?: string\n readonly args?: readonly SdlInputValue[]\n}\n\n/** An argument or an input field. */\nexport interface SdlInputValue {\n readonly name: string\n readonly type: string\n readonly description?: string\n readonly deprecationReason?: string\n /** External value (JSON-compatible, enum values by name); `undefined`: no default. */\n readonly defaultValue?: unknown\n}\n\n/** An input object type (`input NewBookInput { ... }`). */\nexport interface SdlInputType extends SdlNamedType {\n readonly kind: 'input'\n readonly fields: readonly SdlInputValue[]\n}\n\n/** An enum type. */\nexport interface SdlEnumType extends SdlNamedType {\n readonly kind: 'enum'\n readonly values: readonly SdlEnumValue[]\n}\n\n/** A value of an enum type. */\nexport interface SdlEnumValue {\n readonly name: string\n readonly description?: string\n readonly deprecationReason?: string\n}\n\n/** A union type. */\nexport interface SdlUnionType extends SdlNamedType {\n readonly kind: 'union'\n readonly members: readonly string[]\n}\n\n/** A scalar type: a built-in one of `@znight/graphql` (`builtin: true`) or a user scalar. */\nexport interface SdlScalarType extends SdlNamedType {\n readonly kind: 'scalar'\n readonly builtin?: boolean\n /** `@specifiedBy(url:)`. Built-in scalars default to the URL of `BUILTIN_SCALARS`. */\n readonly specifiedByURL?: string\n}\n\n/**\n * Prints the SDL of a schema, without a trailing newline (like `printSchema`). Throws an `Error` on\n * a malformed type reference or a default value that does not match its type (the compiler reports\n * these as diagnostics before printing).\n */\nexport function printSdl(schema: SdlSchema): string {\n const types = new Map<string, SdlType>()\n for (const type of schema.types) types.set(type.name, type)\n const printer = new SdlPrinter(types)\n const parts: string[] = []\n const definition = printSchemaDefinition(schema.roots, types)\n if (definition !== undefined) parts.push(definition)\n for (const type of schema.types) {\n if (!SPECIFIED_SCALARS.has(type.name)) parts.push(printer.type(type))\n }\n return parts.join('\\n\\n')\n}\n\n/** `schema { ... }`, only when the root types do not have their default names (as graphql-js). */\nfunction printSchemaDefinition(roots: SdlRoots, types: ReadonlyMap<string, SdlType>): string | undefined {\n // graphql-js compares `getQueryType() == getType('Query')` (and so on): a missing root equals a\n // missing type of the default name.\n const isDefault = (root: string | undefined, name: string): boolean =>\n root === undefined ? !types.has(name) : root === name\n if (\n isDefault(roots.query, ROOT_TYPE_NAMES.query) &&\n isDefault(roots.mutation, ROOT_TYPE_NAMES.mutation) &&\n isDefault(roots.subscription, ROOT_TYPE_NAMES.subscription)\n ) {\n return undefined\n }\n return (\n 'schema {\\n' +\n ` query: ${roots.query}\\n` +\n (roots.mutation === undefined ? '' : ` mutation: ${roots.mutation}\\n`) +\n (roots.subscription === undefined ? '' : ` subscription: ${roots.subscription}\\n`) +\n '}'\n )\n}\n\n/** A GraphQL value literal (the subset of graphql-js `ConstValueNode` defaults can produce). */\ntype Literal =\n | { readonly kind: 'IntValue' | 'FloatValue' | 'StringValue' | 'EnumValue'; readonly value: string }\n | { readonly kind: 'BooleanValue'; readonly value: boolean }\n | { readonly kind: 'NullValue' }\n | { readonly kind: 'ListValue'; readonly values: readonly Literal[] }\n | { readonly kind: 'ObjectValue'; readonly fields: readonly (readonly [name: string, value: Literal])[] }\n\nconst GRAPHQL_MAX_INT = 2_147_483_647\nconst GRAPHQL_MIN_INT = -2_147_483_648\nconst INTEGER_STRING = /^-?(?:0|[1-9][0-9]*)$/\n/** graphql-js `print()` breaks lists and objects longer than this. */\nconst MAX_LINE_LENGTH = 80\n\nclass SdlPrinter {\n readonly #types: ReadonlyMap<string, SdlType>\n\n constructor(types: ReadonlyMap<string, SdlType>) {\n this.#types = types\n }\n\n type(type: SdlType): string {\n const head = printDescription(type.description, '', true)\n switch (type.kind) {\n case 'object':\n case 'interface':\n return `${head}${type.kind === 'object' ? 'type' : 'interface'} ${type.name}${printImplements(type.interfaces)}${printBlock(type.fields.map((field, i) => this.#field(type.name, field, i)))}`\n case 'input':\n return `${head}input ${type.name}${printBlock(\n type.fields.map(\n (field, i) =>\n `${printDescription(field.description, ' ', i === 0)} ${this.#inputValue(field, `${type.name}.${field.name}`)}`,\n ),\n )}`\n case 'enum':\n return `${head}enum ${type.name}${printBlock(\n type.values.map(\n (value, i) =>\n `${printDescription(value.description, ' ', i === 0)} ${value.name}${printDeprecated(value.deprecationReason)}`,\n ),\n )}`\n case 'union':\n return `${head}union ${type.name}${type.members.length === 0 ? '' : ` = ${type.members.join(' | ')}`}`\n case 'scalar': {\n const url =\n type.specifiedByURL ?? (type.builtin === true ? BUILTIN_SCALARS.get(type.name)?.specifiedByURL : undefined)\n return `${head}scalar ${type.name}${url === undefined ? '' : ` @specifiedBy(url: ${printString(url)})`}`\n }\n }\n }\n\n #field(typeName: string, field: SdlField, index: number): string {\n const coordinate = `${typeName}.${field.name}`\n return (\n `${printDescription(field.description, ' ', index === 0)} ${field.name}` +\n this.#args(coordinate, field.args ?? []) +\n `: ${checkedTypeRef(field.type, coordinate)}${printDeprecated(field.deprecationReason)}`\n )\n }\n\n #args(coordinate: string, args: readonly SdlInputValue[]): string {\n if (args.length === 0) return ''\n if (args.every(arg => arg.description === undefined)) {\n return `(${args.map(arg => this.#inputValue(arg, `${coordinate}(${arg.name}:)`)).join(', ')})`\n }\n const lines = args.map(\n (arg, i) =>\n `${printDescription(arg.description, ' ', i === 0)} ${this.#inputValue(arg, `${coordinate}(${arg.name}:)`)}`,\n )\n return `(\\n${lines.join('\\n')}\\n )`\n }\n\n #inputValue(value: SdlInputValue, coordinate: string): string {\n const ref = parseTypeRef(value.type)\n if (ref === undefined) throw new Error(`Invalid type reference '${value.type}' (${coordinate})`)\n let declaration = `${value.name}: ${value.type}`\n if (value.defaultValue !== undefined) {\n const literal = this.#literal(value.defaultValue, ref)\n if (literal === undefined) {\n throw new Error(`Invalid default value for ${coordinate}: ${describe(value.defaultValue)}`)\n }\n declaration += ` = ${printLiteral(literal)}`\n }\n return declaration + printDeprecated(value.deprecationReason)\n }\n\n /** graphql-js `valueToLiteral(value, type)`: `undefined` when the value does not fit the type. */\n #literal(value: unknown, ref: GraphQLTypeRef): Literal | undefined {\n if (ref.nonNull && value == null) return undefined\n if (value == null) return { kind: 'NullValue' }\n if (ref.kind === 'list') {\n const item: GraphQLTypeRef = ref.of\n if (!isIterableObject(value)) return this.#literal(value, item)\n const values: Literal[] = []\n for (const entry of value) {\n const literal = this.#literal(entry, item)\n if (literal === undefined) return undefined\n values.push(literal)\n }\n return { kind: 'ListValue', values }\n }\n const type = this.#types.get(ref.name)\n if (type?.kind === 'input') return this.#inputLiteral(value, type)\n if (type?.kind === 'enum') {\n return typeof value === 'string' && type.values.some(entry => entry.name === value)\n ? { kind: 'EnumValue', value }\n : undefined\n }\n return scalarLiteral(value, ref.name)\n }\n\n #inputLiteral(value: unknown, type: SdlInputType): Literal | undefined {\n if (typeof value !== 'object' || value === null) return undefined\n const record = value as Readonly<Record<string, unknown>>\n for (const key of Object.keys(record)) {\n if (record[key] !== undefined && !type.fields.some(field => field.name === key)) return undefined\n }\n const fields: (readonly [string, Literal])[] = []\n for (const field of type.fields) {\n const fieldValue = Object.hasOwn(record, field.name) ? record[field.name] : undefined\n const ref = parseTypeRef(field.type)\n if (ref === undefined) return undefined\n if (fieldValue === undefined) {\n // required input field: non-null without default\n if (ref.nonNull && field.defaultValue === undefined) return undefined\n continue\n }\n const literal = this.#literal(fieldValue, ref)\n if (literal === undefined) return undefined\n fields.push([field.name, literal])\n }\n return { kind: 'ObjectValue', fields }\n }\n}\n\n/** graphql-js `printImplementedInterfaces`. */\nfunction printImplements(interfaces: readonly string[] | undefined): string {\n return interfaces === undefined || interfaces.length === 0 ? '' : ` implements ${interfaces.join(' & ')}`\n}\n\n/** The `valueToLiteral` of the specified scalars, and graphql-js' default one for the others. */\nfunction scalarLiteral(value: unknown, name: string): Literal | undefined {\n switch (name) {\n case 'Int': {\n const integer = (typeof value === 'number' && Number.isInteger(value)) || typeof value === 'bigint'\n return integer && value <= GRAPHQL_MAX_INT && value >= GRAPHQL_MIN_INT\n ? { kind: 'IntValue', value: String(value) }\n : undefined\n }\n case 'Float': {\n // graphql-js wraps the `valueToLiteral` of a scalar in a try/catch: a value it cannot convert\n // (a function) is a mismatch, not a crash\n try {\n const literal = defaultScalarLiteral(value)\n return literal.kind === 'FloatValue' || literal.kind === 'IntValue' ? literal : undefined\n } catch {\n return undefined\n }\n }\n case 'String':\n return typeof value === 'string' ? { kind: 'StringValue', value } : undefined\n case 'Boolean':\n return typeof value === 'boolean' ? { kind: 'BooleanValue', value } : undefined\n case 'ID':\n if (typeof value === 'string') {\n return INTEGER_STRING.test(value) ? { kind: 'IntValue', value } : { kind: 'StringValue', value }\n }\n if (typeof value === 'number')\n return Number.isInteger(value) ? { kind: 'IntValue', value: String(value) } : undefined\n return typeof value === 'bigint' ? { kind: 'IntValue', value: String(value) } : undefined\n default:\n return defaultScalarLiteral(value)\n }\n}\n\n/** graphql-js `defaultScalarValueToLiteral`. */\nfunction defaultScalarLiteral(value: unknown): Literal {\n if (value == null) return { kind: 'NullValue' }\n switch (typeof value) {\n case 'boolean':\n return { kind: 'BooleanValue', value }\n case 'string':\n return { kind: 'StringValue', value }\n case 'bigint':\n return { kind: 'IntValue', value: value.toString() }\n case 'number': {\n if (!Number.isFinite(value)) return { kind: 'NullValue' }\n const text = String(value)\n return INTEGER_STRING.test(text) ? { kind: 'IntValue', value: text } : { kind: 'FloatValue', value: text }\n }\n case 'object': {\n if (isIterableObject(value)) return { kind: 'ListValue', values: Array.from(value, defaultScalarLiteral) }\n const record = value as Readonly<Record<string, unknown>>\n const fields: (readonly [string, Literal])[] = []\n for (const key of Object.keys(record)) {\n if (record[key] !== undefined) fields.push([key, defaultScalarLiteral(record[key])])\n }\n return { kind: 'ObjectValue', fields }\n }\n default:\n throw new TypeError(`Cannot convert value to AST: ${describe(value)}.`)\n }\n}\n\nfunction isIterableObject(value: unknown): value is Iterable<unknown> {\n return (\n typeof value === 'object' && value !== null && typeof (value as Iterable<unknown>)[Symbol.iterator] === 'function'\n )\n}\n\n/** graphql-js `print()` of a value literal. */\nfunction printLiteral(literal: Literal): string {\n switch (literal.kind) {\n case 'IntValue':\n case 'FloatValue':\n case 'EnumValue':\n return literal.value\n case 'StringValue':\n return printString(literal.value)\n case 'BooleanValue':\n return literal.value ? 'true' : 'false'\n case 'NullValue':\n return 'null'\n case 'ListValue': {\n const values = literal.values.map(printLiteral)\n const line = `[${values.join(', ')}]`\n return line.length > MAX_LINE_LENGTH ? `[\\n${indent(values.join('\\n'))}\\n]` : line\n }\n case 'ObjectValue': {\n const fields = literal.fields.map(([name, value]) => `${name}: ${printLiteral(value)}`)\n const line = `{ ${fields.join(', ')} }`\n if (line.length <= MAX_LINE_LENGTH) return line\n const body = indent(fields.join('\\n'))\n return body === '' ? '' : `{\\n${body}\\n}`\n }\n }\n}\n\n/** graphql-js `indent()` of the printer. */\nfunction indent(text: string): string {\n return text === '' ? '' : ` ${text.replaceAll('\\n', '\\n ')}`\n}\n\nfunction printBlock(items: readonly string[]): string {\n return items.length === 0 ? '' : ` {\\n${items.join('\\n')}\\n}`\n}\n\nfunction printDeprecated(reason: string | undefined): string {\n if (reason === undefined) return ''\n return reason === DEFAULT_DEPRECATION_REASON ? ' @deprecated' : ` @deprecated(reason: ${printString(reason)})`\n}\n\n/** graphql-js `printDescription()` of `printSchema`. */\nfunction printDescription(description: string | undefined, indentation: string, firstInBlock: boolean): string {\n if (description === undefined) return ''\n const text = isPrintableAsBlockString(description) ? printBlockString(description) : printString(description)\n const prefix = indentation !== '' && !firstInBlock ? `\\n${indentation}` : indentation\n return `${prefix}${text.replaceAll('\\n', `\\n${indentation}`)}\\n`\n}\n\nfunction checkedTypeRef(type: string, coordinate: string): string {\n if (parseTypeRef(type) === undefined) throw new Error(`Invalid type reference '${type}' (${coordinate})`)\n return type\n}\n\nfunction describe(value: unknown): string {\n if (value === undefined) return 'undefined'\n if (typeof value === 'bigint') return `${value}n`\n if (typeof value === 'number' && !Number.isFinite(value)) return String(value)\n try {\n return JSON.stringify(value) ?? String(value)\n } catch {\n return String(value)\n }\n}\n\n// --- graphql-js string printers (language/printString.ts, language/blockString.ts) ---\n\n/** `\\t` and space: the GraphQL `WhiteSpace` characters. */\nfunction isWhiteSpace(code: number): boolean {\n return code === 0x09 || code === 0x20\n}\n\n/** Escape sequence of each code unit graphql-js escapes in a string value. */\nconst ESCAPES: readonly string[] = Array.from({ length: 0xa0 }, (_, code) => {\n switch (code) {\n case 0x08:\n return '\\\\b'\n case 0x09:\n return '\\\\t'\n case 0x0a:\n return '\\\\n'\n case 0x0c:\n return '\\\\f'\n case 0x0d:\n return '\\\\r'\n case 0x22:\n return '\\\\\"'\n case 0x5c:\n return '\\\\\\\\'\n default:\n return code < 0x20 || code >= 0x7f ? `\\\\u${code.toString(16).toUpperCase().padStart(4, '0')}` : ''\n }\n})\n// biome-ignore lint/suspicious/noControlCharactersInRegex: graphql-js escapes exactly these code units\nconst ESCAPED = /[\\x00-\\x1f\\x22\\x5c\\x7f-\\x9f]/g\n\n/** A GraphQL string value (`\"...\"`), escaped like graphql-js `printString`. */\nexport function printString(value: string): string {\n return `\"${value.replace(ESCAPED, char => ESCAPES[char.charCodeAt(0)] ?? char)}\"`\n}\n\n/** graphql-js `isPrintableAsBlockString`. */\nfunction isPrintableAsBlockString(value: string): boolean {\n if (value === '') return true\n let isEmptyLine = true\n let hasIndent = false\n let hasCommonIndent = true\n let seenNonEmptyLine = false\n for (let i = 0; i < value.length; ++i) {\n switch (value.codePointAt(i)) {\n case 0x0000:\n case 0x0001:\n case 0x0002:\n case 0x0003:\n case 0x0004:\n case 0x0005:\n case 0x0006:\n case 0x0007:\n case 0x0008:\n case 0x000b:\n case 0x000c:\n case 0x000e:\n case 0x000f:\n case 0x000d:\n return false\n case 0x000a:\n if (isEmptyLine && !seenNonEmptyLine) return false\n seenNonEmptyLine = true\n isEmptyLine = true\n hasIndent = false\n break\n case 0x0009:\n case 0x0020:\n hasIndent ||= isEmptyLine\n break\n default:\n hasCommonIndent &&= hasIndent\n isEmptyLine = false\n }\n }\n if (isEmptyLine) return false\n if (hasCommonIndent && seenNonEmptyLine) return false\n return true\n}\n\n/** A GraphQL block string (`\"\"\"...\"\"\"`), laid out like graphql-js `printBlockString`. */\nexport function printBlockString(value: string): string {\n const escaped = value.replaceAll('\"\"\"', '\\\\\"\"\"')\n const lines = escaped.split(/\\r\\n|[\\n\\r]/g)\n const isSingleLine = lines.length === 1\n const forceLeadingNewLine =\n lines.length > 1 && lines.slice(1).every(line => line.length === 0 || isWhiteSpace(line.charCodeAt(0)))\n const hasTrailingTripleQuotes = escaped.endsWith('\\\\\"\"\"')\n const hasTrailingQuote = value.endsWith('\"') && !hasTrailingTripleQuotes\n const hasTrailingSlash = value.endsWith('\\\\')\n const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash\n const printAsMultipleLines =\n !isSingleLine || value.length > 70 || forceTrailingNewline || forceLeadingNewLine || hasTrailingTripleQuotes\n let result = ''\n const skipLeadingNewLine = isSingleLine && isWhiteSpace(value.charCodeAt(0))\n if ((printAsMultipleLines && !skipLeadingNewLine) || forceLeadingNewLine) result += '\\n'\n result += escaped\n if (printAsMultipleLines || forceTrailingNewline) result += '\\n'\n return `\"\"\"${result}\"\"\"`\n}\n","/**\n * Checks shared by the code-first schema builder (`builder.ts`) and the schema-first one\n * (`schema-first.ts`): loader providers (ZNIGHT065) and the route decisions of root fields\n * (ZNIGHT023, RFC 0001).\n */\nimport type { ClassInfo, Diagnostic, Location, ValidateContext } from '@znight/compiler'\nimport type { MetaEntry } from '@znight/http/compiler'\nimport type { GraphQLData, ResolverData } from './data.ts'\n\nimport { requiredRouteGroups } from '@znight/http/compiler'\n\nimport { ROOT_TYPE_NAMES } from '../names.ts'\nimport { Codes } from './constants.ts'\nimport { GraphQLIds } from './ids.ts'\n\ntype Context = ValidateContext<GraphQLData>\ntype Report = (diagnostic: Diagnostic) => void\n\n/** `Loader<L>`: `L` must be a loader provider, implementing `BatchLoad<K, V>` (ZNIGHT065). */\nexport function checkLoaders(ctx: Context, resolvers: readonly ResolverData[], report: Report): void {\n const seen = new Set<number>()\n for (const resolver of resolvers) {\n for (const field of resolver.fields) {\n for (const param of field.params) {\n if (param?.kind !== 'loader' || seen.has(param.binding.id)) continue\n seen.add(param.binding.id)\n const ref = ctx.binding(param.binding)\n const token = tokenOfRef(ref)\n const provider = token === undefined ? undefined : ctx.provider(token)\n // an unbound loader is ZNIGHT001 (reported by the binding)\n if (provider === undefined || provider.heritage.some(type => type.identity === GraphQLIds.BatchLoad)) continue\n if (provider.kind !== 'class' || hasLoadMethod(ctx, provider.classIdentity)) continue\n report({\n code: Codes.InvalidLoader,\n severity: 'error',\n message: `${provider.displayName} is not a loader: Loader<${provider.displayName}> needs a provider implementing BatchLoad<K, V> (${resolver.host.displayName}.${field.method})`,\n location: param.location,\n hints: [\n `export class ${provider.displayName} implements BatchLoad<ID, Value> { async load(keys: readonly ID[]): Promise<readonly (Value | Error)[]> { ... } }`,\n ],\n })\n }\n }\n }\n}\n\n/**\n * RFC 0001: every root field decides every required route decorator group (ZNIGHT023). `roots`\n * names the root types (`schema { query: RootQuery }` in schema-first).\n */\nexport function checkDecisions(\n ctx: Context,\n resolvers: readonly ResolverData[],\n report: Report,\n roots: { readonly query: string; readonly mutation?: string; readonly subscription?: string } = ROOT_TYPE_NAMES,\n): void {\n const applied: MetaEntry[] = []\n for (const resolver of resolvers) for (const field of resolver.fields) applied.push(...field.meta)\n const required = requiredRouteGroups(ctx, applied)\n if (required.length === 0) return\n for (const resolver of resolvers) {\n for (const field of resolver.fields) {\n if (field.operation === 'field') continue\n const decided = new Set(field.meta.map(entry => entry.group))\n for (const group of required) {\n if (decided.has(group.group)) continue\n const root = roots[field.operation] ?? ROOT_TYPE_NAMES[field.operation]\n report({\n code: Codes.MissingRouteDecision,\n severity: 'error',\n message: `Root field ${root}.${field.name} (${resolver.host.displayName}.${field.method}) has no \"${group.group}\" decision`,\n location: field.methodLocation,\n hints: [`Add ${group.suggestion} to the method or to ${resolver.host.displayName}`],\n related: [\n {\n message: `The \"${group.group}\" group is required`,\n location: (group.decorators[0] as { definition: Location }).definition,\n },\n ],\n })\n }\n }\n }\n}\n\n/** The class (or one of its base classes) declares an instance `load` method. */\nfunction hasLoadMethod(ctx: Context, identity: string): boolean {\n const seen = new Set<string>()\n let current: string | undefined = identity\n while (current !== undefined && !seen.has(current)) {\n seen.add(current)\n const cls: ClassInfo | undefined = ctx.classInfo(current)\n if (cls === undefined) return true // not analysable (a compiled class): trust the type checker\n if (cls.methods.some(method => method.name === 'load' && method.kind === 'method' && !method.static)) return true\n if (cls.properties.some(property => property.name === 'load' && !property.static)) return true\n current = cls.superClass?.identity\n }\n return false\n}\n\n/** The token of a binding result (`undefined` when binding failed). */\nfunction tokenOfRef(ref: ReturnType<Context['binding']>): string | undefined {\n if (typeof ref === 'string') return ref\n return ref !== undefined && 'token' in ref ? ref.token : undefined\n}\n","/**\n * Default values of arguments and input fields (RFC 0005 §6.3): an internal value (a `@default`\n * JSON value, a statically evaluated parameter default) checked against its GraphQL type and turned\n * into the external value graphql-js expects (`default: { value }`, enum values by name).\n */\nimport type { GraphQLTypeRef } from '../type-ref.ts'\nimport type { TypeModel } from './model.ts'\n\nconst GRAPHQL_INT_MAX = 2_147_483_647\nconst GRAPHQL_INT_MIN = -2_147_483_648\n\n/** The external value, or why the value does not fit the type. */\nexport type ExternalValue = { readonly value: unknown } | { readonly error: string }\n\n/** `value` (an internal value) as a GraphQL external value of `ref`; `types` resolves enums and inputs. */\nexport function externalValue(\n value: unknown,\n ref: GraphQLTypeRef,\n types: ReadonlyMap<string, TypeModel>,\n): ExternalValue {\n if (value === null) return ref.nonNull ? { error: 'null for a non-null type' } : { value: null }\n if (value === undefined) return { error: 'undefined' }\n if (ref.kind === 'list') {\n if (!Array.isArray(value)) return externalValue(value, ref.of, types)\n const items: unknown[] = []\n for (const item of value) {\n const converted = externalValue(item, ref.of, types)\n if ('error' in converted) return converted\n items.push(converted.value)\n }\n return { value: items }\n }\n switch (ref.name) {\n case 'String':\n return typeof value === 'string' ? { value } : { error: 'expected a string' }\n case 'ID':\n return typeof value === 'string' || (typeof value === 'number' && Number.isInteger(value))\n ? { value }\n : { error: 'expected a string or an integer' }\n case 'Int':\n return typeof value === 'number' &&\n Number.isInteger(value) &&\n value <= GRAPHQL_INT_MAX &&\n value >= GRAPHQL_INT_MIN\n ? { value }\n : { error: 'expected a 32-bit integer' }\n case 'Float':\n return typeof value === 'number' && Number.isFinite(value) ? { value } : { error: 'expected a finite number' }\n case 'Boolean':\n return typeof value === 'boolean' ? { value } : { error: 'expected a boolean' }\n case 'JSON':\n return isJson(value) ? { value } : { error: 'expected a JSON value' }\n }\n const type = types.get(ref.name)\n if (type?.kind === 'enum') {\n const found =\n type.values.find(entry => entry.value === value) ??\n (typeof value === 'string' ? type.values.find(entry => entry.name === value) : undefined)\n return found === undefined\n ? { error: `expected one of ${type.values.map(entry => entry.name).join(', ')}` }\n : { value: found.name }\n }\n if (type?.kind === 'input') {\n if (typeof value !== 'object' || Array.isArray(value)) return { error: `expected an object of type ${type.name}` }\n const record = value as Readonly<Record<string, unknown>>\n for (const key of Object.keys(record)) {\n if (!type.fields.some(field => field.name === key)) return { error: `${type.name} has no field '${key}'` }\n }\n const result: Record<string, unknown> = {}\n for (const field of type.fields) {\n if (!Object.hasOwn(record, field.name) || record[field.name] === undefined) {\n if (field.ref.nonNull && field.defaultValue === undefined)\n return { error: `${type.name}.${field.name} is required` }\n continue\n }\n const converted = externalValue(record[field.name], field.ref, types)\n if ('error' in converted) return { error: `${type.name}.${field.name}: ${converted.error}` }\n result[field.name] = converted.value\n }\n return { value: result }\n }\n return { error: `defaults of the scalar ${ref.name} are not supported` }\n}\n\n/** A JSON-compatible value (the `JSON` scalar). */\nfunction isJson(value: unknown): boolean {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return true\n if (typeof value === 'number') return Number.isFinite(value)\n if (Array.isArray(value)) return value.every(isJson)\n if (typeof value !== 'object') return false\n return Object.values(value).every(isJson)\n}\n","/**\n * Union discriminators (RFC 0005 §5.7): how the runtime tells the members of a union apart, decided\n * at build time so that `resolveType` is a lookup.\n */\nimport type { ClassInfo } from '@znight/compiler'\nimport type { DiscriminatorModel, ObjectModel } from './model.ts'\n\nimport { compareStrings } from './constants.ts'\n\n/**\n * `instanceof` when every member is an exported class (subclasses first), `__typename` when every\n * member declares it, else the first property of the first member whose literal value differs in\n * every member; `undefined` when none applies (ZNIGHT064).\n */\nexport function discriminatorOf(\n members: readonly ObjectModel[],\n classInfo: (identity: string) => ClassInfo | undefined,\n): DiscriminatorModel | undefined {\n if (members.every(member => member.classIdentity !== undefined && classInfo(member.classIdentity)?.exported)) {\n const depth = (identity: string): number => classInfo(identity)?.heritage.length ?? 0\n return {\n by: 'class',\n classes: members\n .map(member => ({ identity: member.classIdentity as string, name: member.name }))\n // subclasses first: `instanceof` of a base class also matches its subclasses\n .sort((a, b) => depth(b.identity) - depth(a.identity) || compareStrings(a.name, b.name)),\n }\n }\n if (members.every(member => member.properties.some(property => property.name === '__typename'))) {\n return { by: 'typename' }\n }\n for (const candidate of members[0]?.properties ?? []) {\n if (candidate.optional || candidate.literal === undefined) continue\n const values = literalValues(members, candidate.name)\n if (values !== undefined) return { by: 'property', property: candidate.name, values }\n }\n return undefined\n}\n\n/** Literal value → member name when `property` is a required literal with a distinct value in every member. */\nfunction literalValues(members: readonly ObjectModel[], property: string): Record<string, string> | undefined {\n const values = new Map<string, string>()\n for (const member of members) {\n const found = member.properties.find(entry => entry.name === property)\n if (found === undefined || found.optional || found.literal === undefined) return undefined\n const key = String(found.literal)\n if (values.has(key)) return undefined\n values.set(key, member.name)\n }\n const sorted: Record<string, string> = {}\n for (const key of [...values.keys()].sort(compareStrings)) sorted[key] = values.get(key) as string\n return sorted\n}\n","/**\n * The JSDoc vocabulary of the extension (RFC 0005 §5.14): descriptions, `@param`, `@deprecated`,\n * `@default`, `@gqlHidden` and `@gqlName`.\n */\nimport type { DocComment, DocTag } from '@znight/compiler'\n\nimport { DEFAULT_DEPRECATION_REASON } from '../names.ts'\n\n/** The comment text (before the first tag), `undefined` when empty. */\nexport function descriptionOf(doc: DocComment | undefined): string | undefined {\n return doc === undefined || doc.text === '' ? undefined : doc.text\n}\n\n/** The first tag named `name`. */\nexport function tagOf(doc: DocComment | undefined, name: string): DocTag | undefined {\n return doc?.tags.find(tag => tag.name === name)\n}\n\n/** `@deprecated reason`: the reason (graphql-js' default one without text), `undefined` without the tag. */\nexport function deprecationOf(doc: DocComment | undefined): string | undefined {\n const tag = tagOf(doc, 'deprecated')\n if (tag === undefined) return undefined\n const reason = tag.text.trim()\n return reason === '' ? DEFAULT_DEPRECATION_REASON : reason\n}\n\n/** `true` with a `@gqlHidden` tag. */\nexport function isHidden(doc: DocComment | undefined): boolean {\n return tagOf(doc, 'gqlHidden') !== undefined\n}\n\n/**\n * The text of `@param name text` (also `@param {Type} name - text`), `undefined` when there is no\n * such tag or it has no text.\n */\nexport function paramDescription(doc: DocComment | undefined, name: string): string | undefined {\n for (const tag of doc?.tags ?? []) {\n if (tag.name !== 'param') continue\n const match = /^(?:\\{[^}]*\\}\\s*)?\\[?([\\w$]+)(?:=[^\\]]*)?\\]?(?:\\s+-)?(?:\\s+([\\s\\S]*))?$/.exec(tag.text.trim())\n if (match?.[1] !== name) continue\n const text = match[2]?.trim()\n return text === undefined || text === '' ? undefined : text\n }\n return undefined\n}\n\n/** A `@default` value: JSON when it parses, the text otherwise (`@default title`). */\nexport function defaultTagValue(tag: DocTag): unknown {\n const text = tag.text.trim()\n try {\n return JSON.parse(text) as unknown\n } catch {\n return text\n }\n}\n","/**\n * Source locations of diagnostics. Computed only when a diagnostic is reported: the happy path\n * never reads source text.\n */\nimport type { Location, MethodInfo, Project } from '@znight/compiler'\n\n/** From the member name: `name?: ` or `name(): ` (a getter), up to the annotation. */\nconst MEMBER_HEAD = /^(?:[\\w$]+|'[^']*'|\"[^\"]*\")\\s*\\??\\s*(?:\\(\\s*\\))?\\s*:\\s*/\n\nconst OPENING = new Set(['(', '[', '{', '<'])\nconst CLOSING = new Set([')', ']', '}', '>'])\n\n/**\n * The type annotation of a property, a property signature or a getter (`get x(): T`), from the\n * location of the member (its name); the member itself when the annotation cannot be found.\n */\nexport function annotationLocation(project: Project, member: Location | undefined): Location | undefined {\n if (member === undefined) return undefined\n const file = project.getFile(member.file)\n if (file === undefined) return member\n const text = file.text\n const head = MEMBER_HEAD.exec(text.slice(member.start, member.start + 256))\n if (head === null) return member\n const start = member.start + head[0].length\n let depth = 0\n let end = start\n for (let index = start; index < text.length; index++) {\n const char = text[index] as string\n if (char === '=' && text[index + 1] === '>') {\n index++\n continue\n }\n // a getter body or an initializer after the annotation\n if (depth === 0 && end > start && (char === '{' || char === '=')) break\n if (OPENING.has(char)) depth++\n else if (CLOSING.has(char)) {\n if (depth === 0) break\n depth--\n } else if (depth === 0 && (char === ';' || char === ',')) break\n else if (depth === 0 && char === '\\n' && !/^\\s*[|&]/.test(text.slice(index + 1, index + 64))) break\n if (!/\\s/.test(char)) end = index + 1\n }\n return end > start ? file.location({ start, end }) : member\n}\n\n/**\n * The return type annotation of a method, from the location of its name: after the parameter list\n * (balanced brackets), `: T` up to the body; `undefined` when it cannot be found.\n */\nexport function returnTypeLocation(project: Project, method: MethodInfo): Location | undefined {\n const file = project.getFile(method.location.file)\n if (file === undefined) return undefined\n const text = file.text\n let index = text.indexOf('(', method.location.end)\n if (index === -1) return undefined\n let depth = 0\n for (; index < text.length; index++) {\n const char = text[index] as string\n if (OPENING.has(char)) depth++\n else if (CLOSING.has(char) && --depth === 0) break\n }\n const head = /^\\s*:\\s*/.exec(text.slice(index + 1, index + 64))\n if (head === null) return undefined\n const start = index + 1 + head[0].length\n let end = start\n depth = 0\n for (let cursor = start; cursor < text.length; cursor++) {\n const char = text[cursor] as string\n if (char === '=' && text[cursor + 1] === '>') {\n cursor++\n continue\n }\n if (depth === 0 && (char === '{' || char === ';') && end > start) break\n if (OPENING.has(char)) depth++\n else if (CLOSING.has(char)) {\n if (depth === 0) break\n depth--\n }\n if (!/\\s/.test(char)) end = cursor + 1\n }\n return end > start ? file.location({ start, end }) : undefined\n}\n","/**\n * `scalar<T>(name, definition)` declarations of the application (RFC 0005 §5.7): `T` (a plain type\n * reference, by identity) maps to the scalar `name` wherever it appears. The definition is an\n * exported value the generated module imports; its `description` and `specifiedByURL` are read\n * for the SDL when they are statically evaluable.\n */\nimport type { ArgInfo, Diagnostic, Location, ValidateContext } from '@znight/compiler'\nimport type { GraphQLData } from './data.ts'\n\nimport { isGraphQLName, SPECIFIED_SCALARS } from '../names.ts'\nimport { Codes } from './constants.ts'\nimport { GraphQLIds, SCALAR_ALIASES } from './ids.ts'\n\n/** A valid `scalar<T>()` declaration. */\nexport interface ScalarDeclaration {\n /** GraphQL name. */\n readonly name: string\n /** Identity of the exported constant (imported by the generated module). */\n readonly identity: string\n /** Identity of `T`. */\n readonly type: string\n readonly description: string | undefined\n readonly specifiedByURL: string | undefined\n /** Location of the constant's name. */\n readonly location: Location\n}\n\n/** Valid declarations by the identity of their type; invalid ones are reported. */\nexport function readScalars(\n ctx: ValidateContext<GraphQLData>,\n report: (diagnostic: Diagnostic) => void,\n): ReadonlyMap<string, ScalarDeclaration> {\n const byType = new Map<string, ScalarDeclaration>()\n const byName = new Map<string, ScalarDeclaration>()\n for (const definition of ctx.definitionsOf(GraphQLIds.scalar)) {\n const fail = (message: string, hints: readonly string[], related: Diagnostic['related'] = []): void =>\n report({ code: Codes.InvalidDecorator, severity: 'error', message, location: definition.call, hints, related })\n const [nameArg, definitionArg] = definition.args\n const name = nameArg?.evaluated === true ? nameArg.value : undefined\n if (typeof name !== 'string') {\n fail(`scalar() of ${definition.name} needs a static name`, [`scalar<T>('Name', { ... })`])\n continue\n }\n if (!isGraphQLName(name) || SPECIFIED_SCALARS.has(name)) {\n report({\n code: Codes.NameConflict,\n severity: 'error',\n message: SPECIFIED_SCALARS.has(name)\n ? `'${name}' is a specified GraphQL scalar: scalar() cannot redefine it (${definition.name})`\n : `'${name}' is not a valid GraphQL scalar name (${definition.name})`,\n location: nameArg?.location ?? definition.call,\n hints: ['GraphQL names match /^[_A-Za-z][_0-9A-Za-z]*$/ and do not start with __'],\n })\n continue\n }\n const type = definition.typeArgIdentities?.[0]\n if (type === undefined) {\n report({\n code: Codes.InvalidType,\n severity: 'error',\n message: `scalar('${name}') of ${definition.name} needs a named type argument: scalar<T>('${name}', ...)`,\n location: definition.call,\n hints: [\n `Name the TypeScript type of the scalar: export type ${name} = string & { readonly __brand: '${name}' }, then scalar<${name}>('${name}', ...)`,\n ],\n })\n continue\n }\n if (SCALAR_ALIASES.has(type)) {\n fail(\n `scalar('${name}') of ${definition.name} cannot map ${type.slice(type.indexOf('#') + 1)}: it is a built-in scalar alias`,\n ['Declare a branded type for the scalar: export type Name = string & { readonly __brand: \"Name\" }'],\n )\n continue\n }\n if (!definition.exported) {\n fail(`The scalar ${definition.name} must be exported: the generated module imports it`, [\n `export const ${definition.name} = scalar<...>('${name}', ...)`,\n ])\n continue\n }\n const declaration: ScalarDeclaration = {\n name,\n identity: definition.identity,\n type,\n description: staticProperty(ctx, definitionArg, 'description'),\n specifiedByURL: staticProperty(ctx, definitionArg, 'specifiedByURL'),\n location: definition.location,\n }\n const sameType = byType.get(type)\n if (sameType !== undefined) {\n report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `${definition.name} and ${sameType.identity} both map ${type.slice(type.indexOf('#') + 1)} to a scalar`,\n location: definition.location,\n related: [{ message: 'the other scalar', location: sameType.location }],\n hints: ['Keep one scalar per TypeScript type'],\n })\n continue\n }\n // a user scalar named like a built-in one (DateTime) only conflicts when both are used: the model reports it\n const sameName = byName.get(name)\n if (sameName !== undefined) {\n report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `Two scalars are named '${name}': ${definition.identity} and ${sameName.identity}`,\n location: definition.location,\n related: [{ message: 'the other scalar', location: sameName.location }],\n hints: ['Rename one of them'],\n })\n continue\n }\n byType.set(type, declaration)\n byName.set(name, declaration)\n }\n return byType\n}\n\n/** A string property of an object literal argument, when statically evaluable. */\nfunction staticProperty(ctx: ValidateContext<GraphQLData>, arg: ArgInfo | undefined, key: string): string | undefined {\n if (arg === undefined) return undefined\n if (arg.evaluated && typeof arg.value === 'object' && arg.value !== null && !Array.isArray(arg.value)) {\n const value = (arg.value as Readonly<Record<string, unknown>>)[key]\n return typeof value === 'string' ? value : undefined\n }\n const node = arg.node\n if (node.type !== 'ObjectExpression') return undefined\n for (const property of node.properties) {\n if (property.type !== 'Property' || property.computed) continue\n const name = property.key.type === 'Identifier' ? property.key.name : undefined\n if (name !== key) continue\n const result = ctx.project.evaluate(arg.location.file, property.value, { refs: 'none' })\n return result.kind === 'value' && typeof result.value === 'string' ? result.value : undefined\n }\n return undefined\n}\n","/**\n * The SDL view of the model (`sdl.ts` prints it), from which `schemaHash` and the SDL artifact\n * derive.\n */\nimport type { SdlInputValue, SdlType } from '../sdl.ts'\nimport type { ArgModel, TypeModel } from './model.ts'\n\n/** The SDL view of a model type. */\nexport function sdlType(model: TypeModel): SdlType {\n const base = model.description === undefined ? {} : { description: model.description }\n switch (model.kind) {\n case 'object':\n case 'interface':\n return {\n kind: model.kind,\n name: model.name,\n ...base,\n ...(model.interfaces.length === 0 ? {} : { interfaces: model.interfaces }),\n fields: model.fields.map(field => ({\n name: field.name,\n type: field.type,\n ...(field.description === undefined ? {} : { description: field.description }),\n ...(field.deprecationReason === undefined ? {} : { deprecationReason: field.deprecationReason }),\n ...(field.args.length === 0 ? {} : { args: field.args.map(sdlInputValue) }),\n })),\n }\n case 'input':\n return { kind: 'input', name: model.name, ...base, fields: model.fields.map(sdlInputValue) }\n case 'enum':\n return {\n kind: 'enum',\n name: model.name,\n ...base,\n values: model.values.map(value => ({\n name: value.name,\n ...(value.description === undefined ? {} : { description: value.description }),\n ...(value.deprecationReason === undefined ? {} : { deprecationReason: value.deprecationReason }),\n })),\n }\n case 'union':\n return { kind: 'union', name: model.name, ...base, members: model.members }\n case 'scalar':\n return {\n kind: 'scalar',\n name: model.name,\n ...base,\n ...(model.definition === undefined ? { builtin: true } : {}),\n ...(model.specifiedByURL === undefined ? {} : { specifiedByURL: model.specifiedByURL }),\n }\n }\n}\n\nfunction sdlInputValue(arg: ArgModel): SdlInputValue {\n return {\n name: arg.name,\n type: arg.type,\n ...(arg.description === undefined ? {} : { description: arg.description }),\n ...(arg.deprecationReason === undefined ? {} : { deprecationReason: arg.deprecationReason }),\n ...(arg.defaultValue === undefined ? {} : { defaultValue: arg.defaultValue }),\n }\n}\n","/**\n * The schema model (RFC 0005 §6.2–§6.6): starting from the root fields, every reachable TypeScript\n * type is read through the type shapes API (`ctx.types.shape()`, members `'instance'`, aliases kept\n * as named shapes) and mapped to a GraphQL type, row by row of the §6.2 table. Names follow §6.4,\n * objects, inputs and arguments §6.3; every problem is a diagnostic with a location, a hint and the\n * path from the root field (\"reached from Query.book → Book\").\n *\n * Built once per compile (`validate`), read by `generate`. Shapes are cached by the compiler per\n * options for the whole compile, so the walk only pays for what it visits once.\n */\nimport type {\n ClassInfo,\n Diagnostic,\n Location,\n MethodInfo,\n NamedShape,\n ParameterInfo,\n Shape,\n ShapeOptions,\n ShapeProperty,\n ShapeResult,\n ValidateContext,\n} from '@znight/compiler'\nimport type { MetaEntry } from '@znight/http/compiler'\nimport type { GraphQLTypeRef } from '../type-ref.ts'\nimport type { FieldData, GraphQLData, ResolverData } from './data.ts'\nimport type {\n ArgModel,\n DiscriminantProperty,\n DiscriminatorModel,\n EnumValueModel,\n FieldModel,\n GraphQLModel,\n InputModel,\n ObjectModel,\n ScalarModel,\n TypeModel,\n UnionModel,\n} from './model.ts'\nimport type { ResolvedGraphQLCompilerOptions } from './options.ts'\n\nimport { isGraphQLName, RESERVED_ENUM_VALUES, ROOT_TYPE_NAMES, SPECIFIED_SCALARS } from '../names.ts'\nimport { schemaHash } from '../schema-hash.ts'\nimport { printSdl } from '../sdl.ts'\nimport { printTypeRef } from '../type-ref.ts'\nimport { checkDecisions, checkLoaders } from './checks.ts'\nimport { ASYNC_ITERABLES, BASE_KEEP, Codes, compareStrings, OUTPUT_ITERABLES } from './constants.ts'\nimport { externalValue } from './defaults.ts'\nimport { discriminatorOf } from './discriminators.ts'\nimport { defaultTagValue, deprecationOf, descriptionOf, isHidden, paramDescription, tagOf } from './docs.ts'\nimport { SCALAR_ALIASES } from './ids.ts'\nimport { annotationLocation } from './locate.ts'\nimport { readScalars, type ScalarDeclaration } from './scalars.ts'\nimport { sdlType } from './sdl-view.ts'\n\ntype Context = ValidateContext<GraphQLData>\ntype Position = 'input' | 'output'\ntype Operation = 'query' | 'mutation' | 'subscription'\n\n/** Where a type is used: what diagnostics say and where they point. */\ninterface Use {\n readonly position: Position\n /** `Book.cover`, `Query.book`, `Query.books(limit:)`. */\n readonly coordinate: string\n /** Prefix of the trail of the types reached from here (`Query.book → Book.cover`). */\n readonly trail: string\n /** The trail of the owner of the coordinate (`Query.book → Book`), for \"reached from\". */\n readonly reached: string | undefined\n /** Location of the root field the walk started from. */\n readonly root: Location | undefined\n /** Where the type is written; called only when a diagnostic is reported. */\n readonly locate: () => Location | undefined\n}\n\n/** A converted type: the reference (non-null when nothing made it nullable) and whether TS accepts `null`. */\ninterface Converted {\n readonly ref: GraphQLTypeRef\n readonly acceptsNull: boolean\n}\n\n/** A converted inner type: its reference and whether the type itself admits `null` (`JSONValue`). */\ninterface Inner {\n readonly ref: GraphQLTypeRef\n readonly nullable: boolean\n}\n\n/** A `@ResolveField` waiting for its parent type to be reached. */\ninterface PendingFieldResolver {\n readonly resolver: ResolverData\n readonly field: FieldData\n readonly method: MethodInfo\n attached: boolean\n}\n\n/** A default value to check once every type is complete. */\ninterface PendingDefault {\n readonly target: ArgModel\n readonly value: unknown\n readonly use: Use\n readonly location: Location | undefined\n}\n\n/** The first use of a declaration in a position (ZNIGHT063 \"input and output\"). */\ninterface PositionUse {\n readonly coordinate: string\n readonly location: Location | undefined\n}\n\nconst NAME_HINT = 'GraphQL names match /^[_A-Za-z][_0-9A-Za-z]*$/ and do not start with __'\nconst RECORD_HINT =\n \"GraphQL objects have fixed fields: declare an interface, or use JSONValue (import type { JSONValue } from '@znight/graphql')\"\nconst ROOT_NAMES: ReadonlySet<string> = new Set(Object.values(ROOT_TYPE_NAMES))\n\n/** Builds the model; `undefined` when the application has no resolver. */\nexport function buildModel(ctx: Context, options: ResolvedGraphQLCompilerOptions): GraphQLModel | undefined {\n const resolvers = [...ctx.stored].sort((a, b) => compareStrings(a.host.identity, b.host.identity))\n if (resolvers.length === 0) return undefined\n return new SchemaBuilder(ctx, options).build(resolvers)\n}\n\nclass SchemaBuilder {\n readonly #ctx: Context\n readonly #number: 'Float' | 'Int'\n readonly #shapeOptions: ShapeOptions\n /** `scalar<T>()` declarations by the identity of `T`. */\n readonly #scalars: ReadonlyMap<string, ScalarDeclaration>\n /** Every named shape seen, by key. */\n readonly #named = new Map<string, NamedShape>()\n /** Models by GraphQL name (the first claimant). */\n readonly #types = new Map<string, TypeModel>()\n /** Models by declaration key. */\n readonly #models = new Map<string, TypeModel>()\n /** GraphQL names by declaration key. */\n readonly #names = new Map<string, string | undefined>()\n readonly #positions = new Map<string, { output?: PositionUse; input?: PositionUse }>()\n readonly #reported = new Set<string>()\n readonly #fieldResolvers = new Map<string, PendingFieldResolver[]>()\n readonly #defaults: PendingDefault[] = []\n readonly #methods = new Map<string, MethodInfo | undefined>()\n #errors = 0\n\n constructor(ctx: Context, options: ResolvedGraphQLCompilerOptions) {\n this.#ctx = ctx\n this.#number = options.number\n const declarations = readScalars(ctx, diagnostic => this.#report(diagnostic))\n this.#scalars = declarations\n // shapes keep the scalar types as references: `T` of `scalar<T>()` maps to its scalar wherever it appears\n const keep = [...new Set([...BASE_KEEP, ...declarations.keys()])].sort(compareStrings)\n this.#shapeOptions = Object.freeze({ keep: Object.freeze(keep), members: 'instance', jsdoc: true })\n }\n\n build(resolvers: readonly ResolverData[]): GraphQLModel | undefined {\n checkLoaders(this.#ctx, resolvers, diagnostic => this.#report(diagnostic))\n this.#indexFieldResolvers(resolvers)\n const roots = new Map<Operation, ObjectModel>()\n const rootFields = new Map<string, { readonly field: FieldData; readonly resolver: ResolverData }>()\n let hasQuery = false\n for (const resolver of resolvers) {\n for (const field of resolver.fields) {\n if (field.operation === 'field') continue\n if (field.operation === 'query') hasQuery = true\n if (!field.complete) continue\n const method = this.#method(resolver, field)\n if (method === undefined) continue\n const root = this.#rootModel(roots, field.operation)\n const coordinate = `${root.name}.${field.name}`\n const previous = rootFields.get(coordinate)\n if (previous !== undefined) {\n this.#report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `Two root fields are named ${coordinate}: ${resolver.host.displayName}.${field.method} and ${previous.resolver.host.displayName}.${previous.field.method}`,\n location: field.location,\n related: [{ message: 'the other field', location: previous.field.location }],\n hints: [`Rename one of them: @${decoratorName(field.operation)}('otherName')`],\n })\n continue\n }\n rootFields.set(coordinate, { field, resolver })\n root.fields.push(this.#resolverField(root, resolver, field, method))\n }\n }\n if (!hasQuery) {\n const first = resolvers[0] as ResolverData\n this.#report({\n code: Codes.InvalidResolver,\n severity: 'error',\n message: 'The application has GraphQL resolvers but no @Query field: GraphQL requires a query root type',\n location: first.location,\n hints: [`Add a @Query() method to a resolver (${first.host.displayName}, for instance)`],\n })\n }\n this.#reportUnreachableFieldResolvers()\n this.#checkDefaults()\n this.#checkInputCycles()\n checkDecisions(this.#ctx, resolvers, diagnostic => this.#report(diagnostic))\n if (this.#errors > 0 || !hasQuery) return undefined\n return this.#assemble(roots, resolvers)\n }\n\n // ------------------------------------------------------------------------------------- reporting\n\n #report(diagnostic: Diagnostic): void {\n if (diagnostic.severity === 'error') this.#errors++\n this.#ctx.report(diagnostic)\n }\n\n /** Reports once per `key`. */\n #reportOnce(key: string, diagnostic: Diagnostic): void {\n if (this.#reported.has(key)) return\n this.#reported.add(key)\n this.#report(diagnostic)\n }\n\n #fail(code: Diagnostic['code'], use: Use, message: string, hints: readonly string[]): undefined {\n const location = use.locate()\n this.#report({\n code,\n severity: 'error',\n message,\n ...(location === undefined ? {} : { location }),\n ...(hints.length === 0 ? {} : { hints }),\n related: reachedFrom(use),\n })\n return undefined\n }\n\n // ------------------------------------------------------------------------------------ resolvers\n\n #method(resolver: ResolverData, field: FieldData): MethodInfo | undefined {\n const key = `${resolver.host.identity}#${field.method}`\n if (!this.#methods.has(key)) {\n const cls: ClassInfo | undefined = this.#ctx.classInfo(resolver.host.identity)\n this.#methods.set(\n key,\n cls?.methods.find(method => method.name === field.method && method.kind === 'method'),\n )\n }\n return this.#methods.get(key)\n }\n\n #shape(target: { readonly parameter: ParameterInfo } | { readonly returnOf: MethodInfo }): ShapeResult {\n const result = this.#ctx.types.shape(target, this.#shapeOptions)\n for (const named of result.named.values()) this.#named.set(named.key, named)\n return result\n }\n\n #rootModel(roots: Map<Operation, ObjectModel>, operation: Operation): ObjectModel {\n let root = roots.get(operation)\n if (root === undefined) {\n const name = ROOT_TYPE_NAMES[operation]\n root = {\n kind: 'object',\n name,\n key: `#root:${operation}`,\n description: undefined,\n location: undefined,\n fields: [],\n trail: name,\n root: undefined,\n classIdentity: undefined,\n properties: [],\n interfaces: [],\n }\n roots.set(operation, root)\n this.#claim(root, undefined)\n }\n return root\n }\n\n /** A field backed by a resolver method (root field or field resolver). */\n #resolverField(owner: ObjectModel, resolver: ResolverData, field: FieldData, method: MethodInfo): FieldModel {\n const coordinate = `${owner.name}.${field.name}`\n const isRoot = field.operation !== 'field'\n const use: Use = {\n position: 'output',\n coordinate,\n trail: isRoot ? coordinate : `${owner.trail}.${field.name}`,\n reached: isRoot ? undefined : owner.trail,\n root: isRoot ? method.location : owner.root,\n locate: () => method.location,\n }\n const type = this.#returnType(resolver, field, method, use)\n return {\n name: field.name,\n type: type === undefined ? 'String' : printTypeRef(type.ref),\n description: descriptionOf(method.doc),\n deprecationReason: deprecationOf(method.doc),\n args: this.#arguments(field, method, use),\n binding: { resolver, field },\n location: field.location,\n }\n }\n\n #returnType(resolver: ResolverData, field: FieldData, method: MethodInfo, use: Use): Converted | undefined {\n const where = `${resolver.host.displayName}.${field.method}`\n if (method.returnType === undefined) {\n return this.#fail(Codes.InvalidType, use, `${where} has no return type annotation (${use.coordinate})`, [\n `Annotate the return type: the schema is derived from it (${field.method}(...): Promise<Book>)`,\n ])\n }\n const result = this.#shape({ returnOf: method })\n const rootIssue = result.issues.find(issue => issue.named === undefined)\n const located: Use = { ...use, locate: () => rootIssue?.location ?? method.location }\n const root = result.root\n const iterable = root.kind === 'reference' && ASYNC_ITERABLES.has(root.identity) ? root : undefined\n if (field.operation === 'subscription') {\n if (iterable === undefined) {\n this.#report({\n code: Codes.InvalidResolver,\n severity: 'error',\n message: `@Subscription ${where} must return an async iterable, not ${describeShape(root)}`,\n location: method.location,\n hints: [\n `Declare it as an async generator (async *${field.method}(): AsyncGenerator<Event>) or return pubsub.subscribe(...) (AsyncIterable<Event>)`,\n ],\n })\n return undefined\n }\n const item = iterable.typeArgs[0]\n if (item === undefined) {\n return this.#fail(\n Codes.InvalidType,\n located,\n `${where} must declare the type of its events (${use.coordinate})`,\n ['AsyncIterable<Event>'],\n )\n }\n return this.#convert(item, false, located)\n }\n if (iterable !== undefined) {\n return this.#fail(\n Codes.InvalidType,\n located,\n `${where} returns an async iterable: only @Subscription fields stream values (${use.coordinate})`,\n ['Use @Subscription() for a stream of events, or return a list (Promise<readonly Book[]>)'],\n )\n }\n if (root.kind === 'undefined') {\n return this.#fail(\n Codes.InvalidType,\n located,\n `${where} returns void: GraphQL fields must return a value (${use.coordinate})`,\n ['Return a payload type (the changed object) or a boolean'],\n )\n }\n return this.#convert(root, false, located)\n }\n\n /** Arguments of a resolver field: `@Args('name')` parameters and the properties of `@Args()` types. */\n #arguments(field: FieldData, method: MethodInfo, owner: Use): ArgModel[] {\n const args: ArgModel[] = []\n const seen = new Map<string, Location | undefined>()\n const add = (arg: ArgModel, location: Location | undefined): void => {\n if (seen.has(arg.name)) {\n const first = seen.get(arg.name)\n this.#report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `Argument '${arg.name}' of ${owner.coordinate} is declared twice`,\n ...(location === undefined ? {} : { location }),\n ...(first === undefined ? {} : { related: [{ message: 'first declared here', location: first }] }),\n hints: ['Argument names must be unique: rename one of them'],\n })\n return\n }\n seen.set(arg.name, location)\n args.push(arg)\n }\n field.params.forEach((data, index) => {\n if (data?.kind !== 'args') return\n const param = method.params[index] as ParameterInfo\n const result = this.#shape({ parameter: param })\n if (data.name !== undefined) {\n const coordinate = `${owner.coordinate}(${data.name}:)`\n const use: Use = {\n position: 'input',\n coordinate,\n trail: `${owner.trail}(${data.name})`,\n reached: owner.reached,\n root: owner.root,\n locate: () => param.typeLocation,\n }\n const arg = this.#parameterArgument(data.name, param, method, result, use)\n if (arg !== undefined) add(arg, param.location)\n return\n }\n const properties = this.#propertiesOf(result.root)\n if (properties === 'record') {\n this.#fail(\n Codes.InvalidType,\n { ...owner, locate: () => param.typeLocation },\n `@Args() parameter '${param.name}' of ${owner.coordinate} cannot be a record or an index signature: GraphQL arguments are fixed`,\n [RECORD_HINT, `@Args('${param.name}') declares one argument named '${param.name}'`],\n )\n return\n }\n if (properties === undefined) {\n this.#fail(\n Codes.InvalidType,\n { ...owner, locate: () => param.typeLocation },\n `@Args() parameter '${param.name}' of ${owner.coordinate} must have an object type: its properties are the arguments`,\n [`@Args('${param.name}') declares one argument named '${param.name}'`],\n )\n return\n }\n for (const property of properties) {\n if (isHidden(property.doc)) continue\n const coordinate = `${owner.coordinate}(${property.name}:)`\n const use: Use = {\n position: 'input',\n coordinate,\n trail: `${owner.trail}(${property.name})`,\n reached: owner.reached,\n root: owner.root,\n locate: () => annotationLocation(this.#ctx.project, property.location) ?? param.typeLocation,\n }\n const arg = this.#inputValue(property, use)\n if (arg !== undefined) add(arg, property.location ?? param.location)\n }\n })\n return args\n }\n\n /** `@Args('limit') limit: Int = 20`. */\n #parameterArgument(\n name: string,\n param: ParameterInfo,\n method: MethodInfo,\n result: ShapeResult,\n use: Use,\n ): ArgModel | undefined {\n if (!isGraphQLName(name)) {\n this.#fail(Codes.NameConflict, use, `'${name}' is not a valid GraphQL argument name (${use.coordinate})`, [\n NAME_HINT,\n ])\n return undefined\n }\n const converted = this.#convert(result.root, param.optional, use)\n if (converted === undefined) return undefined\n let ref = converted.ref\n const arg: ArgModel = {\n name,\n type: '',\n ref,\n description: descriptionOf(param.doc) ?? paramDescription(method.doc, param.name),\n deprecationReason: deprecationOf(param.doc),\n defaultValue: undefined,\n nullAsUndefined: false,\n location: param.location,\n }\n const initializer = param.initializer\n let hasDefault = false\n if (param.hasDefault) {\n if (initializer?.evaluated === true && initializer.ref === undefined && !containsRef(initializer.value)) {\n this.#defaults.push({ target: arg, value: initializer.value, use, location: initializer.location })\n hasDefault = true\n } else {\n // a default the compiler cannot read: the argument becomes optional, the TypeScript default applies\n ref = { ...ref, nonNull: false }\n }\n }\n arg.ref = ref\n arg.type = printTypeRef(ref)\n arg.nullAsUndefined = !ref.nonNull && !converted.acceptsNull\n this.#checkDeprecatedInput(arg, hasDefault, use)\n return arg\n }\n\n /** A property as an argument or an input field (§6.3): `@default`, `@deprecated`, null handling. */\n #inputValue(property: ShapeProperty, use: Use): ArgModel | undefined {\n if (!isGraphQLName(property.name)) {\n this.#fail(\n Codes.NameConflict,\n { ...use, locate: () => property.location },\n `'${property.name}' is not a valid GraphQL name (${use.coordinate})`,\n [NAME_HINT, 'Hide the property with /** @gqlHidden */'],\n )\n return undefined\n }\n if (property.kind === 'getter') {\n this.#fail(Codes.InvalidInput, use, `${use.coordinate} is a getter: input values are plain data`, [\n 'Declare a property instead, or hide the getter with /** @gqlHidden */',\n ])\n return undefined\n }\n const converted = this.#convert(property.shape, property.optional, use)\n if (converted === undefined) return undefined\n const arg: ArgModel = {\n name: property.name,\n type: printTypeRef(converted.ref),\n ref: converted.ref,\n description: descriptionOf(property.doc),\n deprecationReason: deprecationOf(property.doc),\n defaultValue: undefined,\n nullAsUndefined: !converted.ref.nonNull && !converted.acceptsNull,\n location: property.location,\n }\n const tag = tagOf(property.doc, 'default')\n if (tag !== undefined)\n this.#defaults.push({ target: arg, value: defaultTagValue(tag), use, location: tag.location })\n this.#checkDeprecatedInput(arg, tag !== undefined, use)\n return arg\n }\n\n /** graphql-js rejects a deprecated argument or input field that is required. */\n #checkDeprecatedInput(arg: ArgModel, hasDefault: boolean, use: Use): void {\n if (arg.deprecationReason === undefined || !arg.ref.nonNull || hasDefault) return\n this.#fail(Codes.InvalidInput, use, `${use.coordinate} is required and cannot be deprecated`, [\n 'Make it optional (?: T or T | undefined) or give it a default value before deprecating it',\n ])\n }\n\n // ------------------------------------------------------------------------------ field resolvers\n\n #indexFieldResolvers(resolvers: readonly ResolverData[]): void {\n for (const resolver of resolvers) {\n for (const field of resolver.fields) {\n if (field.operation !== 'field' || !field.complete) continue\n const method = this.#method(resolver, field)\n if (method === undefined) continue\n const index = field.params.findIndex(param => param?.kind === 'parent')\n const param = method.params[index]\n if (param === undefined) continue\n const result = this.#shape({ parameter: param })\n const key = this.#objectKeyOf(result.root)\n if (key === undefined) {\n this.#report({\n code: Codes.InvalidResolver,\n severity: 'error',\n message: `The @Parent() parameter '${param.name}' of ${resolver.host.displayName}.${field.method} must have an object type, not ${describeShape(result.root)}`,\n location: param.typeLocation,\n hints: [\n 'The parent type is the object type the field is added to: an interface, a class or a named alias of an object type',\n ],\n })\n continue\n }\n let list = this.#fieldResolvers.get(key)\n if (list === undefined) {\n list = []\n this.#fieldResolvers.set(key, list)\n }\n list.push({ resolver, field, method, attached: false })\n }\n }\n // field resolvers are appended by resolver token, then source order (§7.3)\n for (const list of this.#fieldResolvers.values()) {\n list.sort(\n (a, b) =>\n compareStrings(a.resolver.host.identity, b.resolver.host.identity) ||\n a.field.location.start - b.field.location.start,\n )\n }\n }\n\n #attachFieldResolvers(model: ObjectModel): void {\n const pending = this.#fieldResolvers.get(model.key)\n if (pending === undefined) return\n for (const entry of pending) {\n entry.attached = true\n const field = this.#resolverField(model, entry.resolver, entry.field, entry.method)\n const index = model.fields.findIndex(existing => existing.name === field.name)\n if (index === -1) {\n model.fields.push(field)\n continue\n }\n const existing = model.fields[index] as FieldModel\n const where = `${entry.resolver.host.displayName}.${entry.field.method}`\n if (existing.binding !== undefined) {\n this.#report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `Two field resolvers add ${model.name}.${field.name}: ${where} and ${existing.binding.resolver.host.displayName}.${existing.binding.field.method}`,\n location: entry.field.location,\n related: [{ message: 'the other field resolver', location: existing.binding.field.location }],\n hints: [\"Keep one of them, or rename one: @ResolveField('otherName')\"],\n })\n continue\n }\n if (existing.type !== field.type) {\n this.#report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `@ResolveField ${where} returns ${field.type}, but the property ${model.name}.${field.name} is ${existing.type}`,\n location: entry.field.location,\n ...(existing.location === undefined\n ? {}\n : { related: [{ message: 'the property', location: existing.location }] }),\n hints: [\n 'A field resolver replacing a property must resolve the same GraphQL type: change its return type, or rename the field',\n ],\n })\n continue\n }\n // replaces the property field in place: same position, the method's documentation first\n model.fields[index] = {\n ...field,\n description: field.description ?? existing.description,\n deprecationReason: field.deprecationReason ?? existing.deprecationReason,\n }\n }\n }\n\n #reportUnreachableFieldResolvers(): void {\n for (const [key, list] of this.#fieldResolvers) {\n for (const entry of list) {\n if (entry.attached) continue\n const name = this.#named.get(key)?.name ?? key\n this.#report({\n code: Codes.InvalidResolver,\n severity: 'warning',\n message: `@ResolveField ${entry.resolver.host.displayName}.${entry.field.method} adds a field to ${name}, which no root field reaches as an output type: it is not part of the schema`,\n location: entry.field.location,\n hints: [`Return ${name} from a @Query (or another reachable field), or remove the field resolver`],\n })\n }\n }\n }\n\n // ----------------------------------------------------------------------------------- conversion\n\n /**\n * The GraphQL type of a shape: `null`, `undefined` and `optional` make it nullable, everything\n * else is non-null (§6.2).\n */\n #convert(shape: Shape, optional: boolean, use: Use): Converted | undefined {\n let nullable = optional\n let acceptsNull = false\n let inner = shape\n if (shape.kind === 'union') {\n const rest = shape.members.filter(member => member.kind !== 'null' && member.kind !== 'undefined')\n if (rest.length !== shape.members.length) {\n nullable = true\n acceptsNull = shape.members.some(member => member.kind === 'null')\n }\n if (rest.length === 0) {\n return this.#fail(Codes.InvalidType, use, `${use.coordinate} is always null or undefined`, [\n 'Declare the type of the value',\n ])\n }\n inner = rest.length === 1 ? (rest[0] as Shape) : { kind: 'union', members: rest }\n }\n const converted = this.#inner(inner, use)\n if (converted === undefined) return undefined\n const isNullable = nullable || converted.nullable\n return { ref: { ...converted.ref, nonNull: !isNullable }, acceptsNull: acceptsNull || converted.nullable }\n }\n\n #inner(shape: Shape, use: Use): Inner | undefined {\n switch (shape.kind) {\n case 'string':\n return refTo('String')\n case 'number':\n return refTo(this.#number)\n case 'boolean':\n return refTo('Boolean')\n case 'literal':\n if (typeof shape.value === 'string') return refTo('String')\n return refTo(typeof shape.value === 'number' ? this.#number : 'Boolean')\n case 'date':\n return this.#builtin('DateTime', use)\n case 'bigint':\n return this.#builtin('BigInt', use)\n case 'array': {\n const item = this.#convert(shape.items, false, use)\n return item === undefined ? undefined : { ref: { kind: 'list', of: item.ref, nonNull: false }, nullable: false }\n }\n case 'named':\n return this.#namedType(shape.key, use)\n case 'reference':\n return this.#reference(shape, use)\n case 'url':\n return this.#fail(Codes.InvalidType, use, `Cannot map 'URL' to a GraphQL type (${use.coordinate})`, [\n \"Expose a string (url.href), or declare a scalar: export const UrlScalar = scalar<URL>('URL', { ... })\",\n ])\n case 'binary':\n return this.#fail(Codes.InvalidType, use, `Cannot map binary data to a GraphQL type (${use.coordinate})`, [\n \"Expose a URL (coverUrl: string), hide the property with /** @gqlHidden */, or declare a scalar: export const Base64 = scalar<Uint8Array>('Base64', { ... })\",\n ])\n case 'unknown':\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map 'unknown' or 'any' to a GraphQL type (${use.coordinate})`,\n [\"Declare the type, or use JSONValue (import type { JSONValue } from '@znight/graphql') for arbitrary JSON\"],\n )\n case 'never':\n case 'null':\n case 'undefined':\n return this.#fail(Codes.InvalidType, use, `Cannot map '${shape.kind}' to a GraphQL type (${use.coordinate})`, [\n 'Declare the type of the value',\n ])\n case 'tuple':\n return this.#fail(Codes.InvalidType, use, `Cannot map a tuple to a GraphQL type (${use.coordinate})`, [\n 'Use an array (readonly T[]) or a named object type',\n ])\n case 'object':\n if (shape.additional !== undefined) {\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map a record or an index signature to a GraphQL type (${use.coordinate})`,\n [RECORD_HINT],\n )\n }\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map an anonymous object type to a GraphQL type (${use.coordinate})`,\n ['GraphQL types have names: declare it (export interface BookStats { ... }) and use it'],\n )\n case 'intersection':\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map an anonymous intersection to a GraphQL type (${use.coordinate})`,\n ['Name it: export type BookWithAuthor = Book & { readonly author: Author }'],\n )\n case 'union':\n return this.#anonymousUnion(shape.members, use)\n case 'schema':\n return this.#fail(Codes.InvalidType, use, `Cannot map a schema type to a GraphQL type (${use.coordinate})`, [\n 'Declare the TypeScript type: the annotation is the GraphQL type',\n ])\n case 'opaque':\n return this.#opaque(shape, use)\n }\n }\n\n #anonymousUnion(members: readonly Shape[], use: Use): undefined {\n if (members.every(member => member.kind === 'literal' && typeof member.value === 'string')) {\n const values = members.map(member => `'${(member as { value: string }).value}'`).join(' | ')\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map the anonymous union ${values} to a GraphQL type (${use.coordinate})`,\n [`Name it to make it an enum: export type Sort = ${values}`],\n )\n }\n if (members.every(member => member.kind === 'named')) {\n return this.#fail(Codes.InvalidType, use, `Cannot map an anonymous union to a GraphQL type (${use.coordinate})`, [\n `GraphQL unions have names: export type SearchResult = ${members.map(member => this.#named.get((member as { key: string }).key)?.name ?? '?').join(' | ')}`,\n ])\n }\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map the union ${members.map(describeShape).join(' | ')} to a GraphQL type (${use.coordinate})`,\n ['GraphQL unions only contain object types: declare one type, or an object type per case'],\n )\n }\n\n #opaque(shape: Extract<Shape, { kind: 'opaque' }>, use: Use): undefined {\n const text = shape.text\n let hints: string[]\n switch (shape.reason) {\n case 'non-json':\n if (text.startsWith('Promise')) {\n hints = ['A Promise is only unwrapped at the top of a resolver return type: declare the resolved type']\n } else if (text.startsWith('Map') || text.startsWith('WeakMap')) {\n hints = [\n \"Use an array of entries, a named object type, or JSONValue (import type { JSONValue } from '@znight/graphql')\",\n ]\n } else {\n hints = ['Declare a plain data type (an interface, an array, a scalar)']\n }\n break\n case 'missing-annotation':\n hints = ['Annotate the type: the compiler reads annotations only']\n break\n case 'function':\n hints = ['Functions are not data: return the value, or hide the member with /** @gqlHidden */']\n break\n case 'type-parameter':\n hints = ['Give the type arguments explicitly']\n break\n default:\n hints = ['Declare the structure with an interface or a named alias']\n }\n return this.#fail(Codes.InvalidType, use, `Cannot map '${text}' to a GraphQL type (${use.coordinate})`, hints)\n }\n\n #reference(shape: Extract<Shape, { kind: 'reference' }>, use: Use): Inner | undefined {\n const alias = SCALAR_ALIASES.get(shape.identity)\n if (alias === 'JSON') {\n // JSONValue includes null: the field is nullable\n const json = this.#builtin('JSON', use)\n return json === undefined ? undefined : { ref: json.ref, nullable: true }\n }\n if (alias !== undefined) return refTo(alias === 'Float' ? 'Float' : alias)\n const scalar = this.#scalars.get(shape.identity)\n if (scalar !== undefined) return this.#customScalar(scalar, use)\n if (OUTPUT_ITERABLES.has(shape.identity)) {\n if (use.position === 'input') {\n return this.#fail(Codes.InvalidInput, use, `${use.coordinate} is a ${shape.name}: input lists are arrays`, [\n 'Declare an array (readonly T[]) for input values',\n ])\n }\n const item = shape.typeArgs[0]\n if (item === undefined)\n return this.#fail(Codes.InvalidType, use, `${use.coordinate}: ${shape.name} needs a type argument`, [])\n const converted = this.#convert(item, false, use)\n return converted === undefined\n ? undefined\n : { ref: { kind: 'list', of: converted.ref, nonNull: false }, nullable: false }\n }\n if (ASYNC_ITERABLES.has(shape.identity)) {\n return this.#fail(Codes.InvalidType, use, `Cannot map '${shape.name}' to a GraphQL type (${use.coordinate})`, [\n 'Async iterables are only the return type of @Subscription methods',\n ])\n }\n return this.#fail(Codes.InvalidType, use, `Cannot map '${shape.name}' to a GraphQL type (${use.coordinate})`, [\n 'Declare a plain data type (an interface, an array, a scalar)',\n ])\n }\n\n // ------------------------------------------------------------------------------------- scalars\n\n #builtin(name: 'DateTime' | 'BigInt' | 'JSON', use: Use): Inner | undefined {\n const key = `#builtin:${name}`\n if (!this.#models.has(key)) {\n const model: ScalarModel = {\n kind: 'scalar',\n name,\n key,\n description: undefined,\n location: undefined,\n definition: undefined,\n specifiedByURL: undefined,\n }\n this.#models.set(key, model)\n if (!this.#claim(model, use)) return undefined\n }\n return refTo(name)\n }\n\n #customScalar(scalar: ScalarDeclaration, use: Use): Inner | undefined {\n const key = `#scalar:${scalar.identity}`\n if (!this.#models.has(key)) {\n const model: ScalarModel = {\n kind: 'scalar',\n name: scalar.name,\n key,\n description: scalar.description,\n location: scalar.location,\n definition: scalar.identity,\n specifiedByURL: scalar.specifiedByURL,\n }\n this.#models.set(key, model)\n if (!this.#claim(model, use)) return undefined\n }\n return refTo(scalar.name)\n }\n\n // ------------------------------------------------------------------------------- named types\n\n #namedType(key: string, use: Use): Inner | undefined {\n const named = this.#named.get(key)\n if (named === undefined)\n return this.#fail(Codes.InvalidType, use, `Cannot resolve the type of ${use.coordinate}`, [])\n switch (named.declaration) {\n case 'enum':\n return this.#enum(named, use)\n case 'alias':\n return this.#alias(named, use)\n default:\n return this.#object(named, named, use)\n }\n }\n\n /**\n * A named alias: an object type (object literal, intersection, utility type, generic instance),\n * an enum (string literals), a union (object types), or transparent (`type Email = string`,\n * `type Books = Book[]`, `type Author = Person`).\n */\n #alias(alias: NamedShape, use: Use): Inner | undefined {\n const shape = alias.shape\n switch (shape.kind) {\n case 'object':\n case 'intersection':\n return this.#object(alias, alias, use)\n case 'named': {\n const target = this.#named.get(shape.key)\n if (\n target !== undefined &&\n target.declaration !== 'alias' &&\n target.declaration !== 'enum' &&\n target.typeArgs.length > 0\n ) {\n // `type BookList = Page<Book>`: the alias names the instance\n return this.#object(alias, target, use)\n }\n return this.#namedType(shape.key, use)\n }\n case 'union': {\n const rest = shape.members.filter(member => member.kind !== 'null' && member.kind !== 'undefined')\n const nullable = rest.length !== shape.members.length\n if (rest.length === 1) {\n const inner = this.#inner(rest[0] as Shape, use)\n return inner === undefined ? undefined : { ref: inner.ref, nullable: inner.nullable || nullable }\n }\n let converted: Inner | undefined\n if (rest.every(member => member.kind === 'literal')) converted = this.#literalEnum(alias, rest, use)\n else if (rest.length > 0 && rest.every(member => member.kind === 'named'))\n converted = this.#union(alias, rest, use)\n else converted = this.#anonymousUnion(rest, use)\n return converted === undefined ? undefined : { ref: converted.ref, nullable }\n }\n default:\n return this.#inner(shape, use)\n }\n }\n\n /**\n * The declaration key of the object type a shape maps to in output position (the parent of a\n * field resolver), `undefined` when it is not an object type. Mirrors {@link #alias}.\n */\n #objectKeyOf(shape: Shape): string | undefined {\n if (shape.kind === 'union') {\n const rest = shape.members.filter(member => member.kind !== 'null' && member.kind !== 'undefined')\n return rest.length === 1 ? this.#objectKeyOf(rest[0] as Shape) : undefined\n }\n if (shape.kind !== 'named') return undefined\n const named = this.#named.get(shape.key)\n if (named === undefined || named.declaration === 'enum') return undefined\n if (named.declaration !== 'alias') return named.key\n const target = named.shape\n if (target.kind === 'object' || target.kind === 'intersection') return named.key\n if (target.kind === 'named') {\n const instance = this.#named.get(target.key)\n if (\n instance !== undefined &&\n instance.declaration !== 'alias' &&\n instance.declaration !== 'enum' &&\n instance.typeArgs.length > 0\n ) {\n return named.key\n }\n }\n return this.#objectKeyOf(target)\n }\n\n /** An object type (output) or an input object type (input) for `named`, structured as `structure`. */\n #object(named: NamedShape, structure: NamedShape, use: Use): Inner | undefined {\n const key = named.key\n if (!this.#checkPosition(named, use)) return undefined\n const existing = this.#models.get(key)\n if (existing !== undefined) return this.#known(existing)\n const name = this.#typeName(named, use)\n if (name === undefined) return undefined\n const properties = this.#propertiesOf(structure.shape)\n if (properties === 'record') {\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map ${named.name}, a record or an index signature, to a GraphQL type (${use.coordinate})`,\n [RECORD_HINT],\n )\n }\n if (properties === undefined) {\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map ${named.name} to a GraphQL object type (${use.coordinate})`,\n ['Declare an interface, a class or a named object type'],\n )\n }\n const description = descriptionOf(named.doc) ?? (structure === named ? undefined : descriptionOf(structure.doc))\n const trail = `${use.trail} → ${name}`\n if (use.position === 'input') {\n const model: InputModel = { kind: 'input', name, key, description, location: named.location, fields: [] }\n this.#models.set(key, model)\n if (!this.#claim(model, use)) return undefined\n for (const property of properties) {\n if (isHidden(property.doc)) continue\n const fieldUse: Use = {\n position: 'input',\n coordinate: `${name}.${property.name}`,\n trail: `${trail}.${property.name}`,\n reached: trail,\n root: use.root,\n locate: () => annotationLocation(this.#ctx.project, property.location),\n }\n const field = this.#inputValue(property, fieldUse)\n if (field !== undefined) model.fields.push(field)\n }\n return refTo(name)\n }\n const model: ObjectModel = {\n kind: 'object',\n name,\n key,\n description,\n location: named.location,\n fields: [],\n trail,\n root: use.root,\n classIdentity:\n structure.declaration === 'class' && structure.typeArgs.length === 0 && structure === named\n ? structure.identity\n : undefined,\n properties: properties.map(property => this.#discriminant(property)),\n interfaces: [],\n }\n this.#models.set(key, model)\n if (!this.#claim(model, use)) return undefined\n for (const property of properties) {\n const field = this.#outputField(model, property)\n if (field !== undefined) model.fields.push(field)\n }\n this.#attachFieldResolvers(model)\n return refTo(name)\n }\n\n /** A property as a union discriminator candidate: its literal value, through aliases (`kind: BookKind`). */\n #discriminant(property: ShapeProperty): DiscriminantProperty {\n let shape = property.shape\n // `type BookKind = 'book'`, `type Kind = BookKind`; the bound only guards against alias cycles\n for (let depth = 0; shape.kind === 'named' && depth < 32; depth++) {\n const named = this.#named.get(shape.key)\n if (named?.declaration !== 'alias') break\n shape = named.shape\n }\n return {\n name: property.name,\n optional: property.optional,\n literal: shape.kind === 'literal' ? shape.value : undefined,\n }\n }\n\n #outputField(model: ObjectModel, property: ShapeProperty): FieldModel | undefined {\n // hidden members, functions (methods stored as properties) and the union discriminator `__typename`\n if (isHidden(property.doc) || property.name === '__typename') return undefined\n if (property.shape.kind === 'opaque' && property.shape.reason === 'function') return undefined\n const use: Use = {\n position: 'output',\n coordinate: `${model.name}.${property.name}`,\n trail: `${model.trail}.${property.name}`,\n reached: model.trail,\n root: model.root,\n locate: () => annotationLocation(this.#ctx.project, property.location),\n }\n if (!isGraphQLName(property.name)) {\n return this.#fail(\n Codes.NameConflict,\n { ...use, locate: () => property.location },\n `'${property.name}' is not a valid GraphQL field name (${use.coordinate})`,\n [NAME_HINT, 'Hide the property with /** @gqlHidden */'],\n )\n }\n const converted = this.#convert(property.shape, property.optional, use)\n if (converted === undefined) return undefined\n return {\n name: property.name,\n type: printTypeRef(converted.ref),\n description: descriptionOf(property.doc),\n deprecationReason: deprecationOf(property.doc),\n args: [],\n binding: undefined,\n location: property.location,\n }\n }\n\n /**\n * The properties of an object structure (intersections merged, later members win), `'record'` for\n * a record or an index signature (ZNIGHT060: GraphQL objects have fixed fields).\n */\n #propertiesOf(shape: Shape): readonly ShapeProperty[] | 'record' | undefined {\n switch (shape.kind) {\n case 'object':\n return shape.additional === undefined ? shape.properties : 'record'\n case 'named': {\n const named = this.#named.get(shape.key)\n return named === undefined || named.declaration === 'enum' ? undefined : this.#propertiesOf(named.shape)\n }\n case 'intersection': {\n const merged = new Map<string, ShapeProperty>()\n for (const member of shape.members) {\n const properties = this.#propertiesOf(member)\n if (properties === undefined || properties === 'record') return properties\n for (const property of properties) {\n merged.delete(property.name)\n merged.set(property.name, property)\n }\n }\n return [...merged.values()]\n }\n default:\n return undefined\n }\n }\n\n /** A declaration is used in one position: input or output (ZNIGHT063 otherwise). */\n #checkPosition(named: NamedShape, use: Use): boolean {\n let uses = this.#positions.get(named.key)\n if (uses === undefined) {\n uses = {}\n this.#positions.set(named.key, uses)\n }\n const other = use.position === 'input' ? uses.output : uses.input\n if (uses[use.position] === undefined) uses[use.position] = { coordinate: use.coordinate, location: use.locate() }\n if (other === undefined) return true\n const output = use.position === 'output' ? use.coordinate : other.coordinate\n const input = use.position === 'input' ? use.coordinate : other.coordinate\n const inputOwner = input.includes('(') ? input.slice(0, input.indexOf('(')) : input.split('.')[0]\n this.#reportOnce(`position\\0${named.key}`, {\n code: Codes.InvalidInput,\n severity: 'error',\n message: `'${named.name}' is used as an output type (${output}) and as an input type (${input})`,\n location: named.location,\n hints: [\n `GraphQL needs two types: declare \\`export interface ${named.name}Input extends ${named.name} {}\\` and use it in ${inputOwner}`,\n ],\n related: [\n ...(uses.output?.location === undefined\n ? []\n : [{ message: `used as output: ${output}`, location: uses.output.location }]),\n ...(uses.input?.location === undefined\n ? []\n : [{ message: `used as input: ${input}`, location: uses.input.location }]),\n ],\n })\n return false\n }\n\n /**\n * The GraphQL name of a declaration (§6.4): `@gqlName`, the declaration name, or for a generic\n * instance the names of its type arguments followed by the declaration name (`BookPage`).\n */\n #typeName(named: NamedShape, use: Use): string | undefined {\n if (this.#names.has(named.key)) return this.#names.get(named.key)\n let name: string | undefined\n const explicit = tagOf(named.doc, 'gqlName')?.text.trim()\n if (explicit !== undefined && explicit !== '') name = explicit\n else if (named.typeArgs.length === 0) name = named.name\n else {\n const args = named.typeArgs.map(arg => this.#argumentName(arg))\n const missing = args.findIndex(arg => arg === undefined)\n if (missing === -1) name = `${args.join('')}${named.name}`\n else {\n this.#reportOnce(`argument\\0${named.key}`, {\n code: Codes.InvalidType,\n severity: 'error',\n message: `Cannot name the GraphQL type of ${named.name}<...> (${use.coordinate}): its type argument ${describeShape(named.typeArgs[missing] as Shape)} has no GraphQL name`,\n location: named.location,\n related: reachedFrom(use),\n hints: [\n `Name the instance with an alias (export type BookPages = ${named.name}<...>) or with /** @gqlName Name */`,\n ],\n })\n }\n }\n this.#names.set(named.key, name)\n return name\n }\n\n /** The GraphQL name a type argument contributes to a generic instance name. */\n #argumentName(shape: Shape): string | undefined {\n switch (shape.kind) {\n case 'string':\n return 'String'\n case 'number':\n return this.#number\n case 'boolean':\n return 'Boolean'\n case 'date':\n return 'DateTime'\n case 'bigint':\n return 'BigInt'\n case 'reference': {\n const alias = SCALAR_ALIASES.get(shape.identity)\n if (alias !== undefined) return alias\n return this.#scalars.get(shape.identity)?.name\n }\n case 'union': {\n const rest = shape.members.filter(member => member.kind !== 'null' && member.kind !== 'undefined')\n return rest.length === 1 ? this.#argumentName(rest[0] as Shape) : undefined\n }\n case 'named': {\n const named = this.#named.get(shape.key)\n if (named === undefined) return undefined\n if (named.declaration === 'alias') {\n const target = named.shape\n const instance = target.kind === 'named' ? this.#named.get(target.key) : undefined\n const isObject =\n target.kind === 'object' ||\n target.kind === 'intersection' ||\n (instance !== undefined &&\n instance.declaration !== 'alias' &&\n instance.declaration !== 'enum' &&\n instance.typeArgs.length > 0)\n const isEnum = target.kind === 'union' && target.members.every(member => member.kind === 'literal')\n const isUnion = target.kind === 'union' && target.members.filter(member => member.kind === 'named').length > 1\n if (!isObject && !isEnum && !isUnion) return this.#argumentName(target)\n }\n return this.#typeName(named, {\n position: 'output',\n coordinate: named.name,\n trail: named.name,\n reached: undefined,\n root: undefined,\n locate: () => named.location,\n })\n }\n default:\n return undefined\n }\n }\n\n /**\n * Registers a model under its GraphQL name: the name must be valid, not reserved, and not taken\n * by another declaration (ZNIGHT061).\n */\n #claim(model: TypeModel, use: Use | undefined): boolean {\n const name = model.name\n const isRoot = model.key.startsWith('#root:')\n const location = model.location ?? use?.locate()\n let problem: string | undefined\n if (!isGraphQLName(name)) problem = `'${name}' is not a valid GraphQL type name`\n else if (!isRoot && ROOT_NAMES.has(name)) problem = `'${name}' is the name of a root operation type`\n else if (SPECIFIED_SCALARS.has(name)) problem = `'${name}' is the name of a specified GraphQL scalar`\n if (problem !== undefined) {\n this.#reportOnce(`name\\0${model.key}`, {\n code: Codes.NameConflict,\n severity: 'error',\n message: `${problem} (${model.key.startsWith('#') ? name : model.key})`,\n ...(location === undefined ? {} : { location }),\n related: use === undefined ? [] : reachedFrom(use),\n hints: [isGraphQLName(name) ? 'Rename the declaration, or name it with /** @gqlName OtherName */' : NAME_HINT],\n })\n return false\n }\n const existing = this.#types.get(name)\n if (existing === undefined) {\n this.#types.set(name, model)\n return true\n }\n if (existing === model) return true\n const pair = [existing.key, model.key].sort(compareStrings).join('\\0')\n this.#reportOnce(`conflict\\0${pair}`, {\n code: Codes.NameConflict,\n severity: 'error',\n message: `Two types are named '${name}' in the GraphQL schema: ${describeKey(model)} and ${describeKey(existing)}`,\n ...(location === undefined ? {} : { location }),\n related: [\n ...(existing.location === undefined ? [] : [{ message: 'the other declaration', location: existing.location }]),\n ...(use === undefined ? [] : reachedFrom(use)),\n ],\n hints: ['Rename one of them, or name one with /** @gqlName OtherName */'],\n })\n return false\n }\n\n // -------------------------------------------------------------------------------------- enums\n\n /** A model met again: its reference, unless its name was refused (already reported). */\n #known(model: TypeModel): Inner | undefined {\n return this.#types.get(model.name) === model ? refTo(model.name) : undefined\n }\n\n /** A TypeScript `enum`: names = member names, internal values = member values. */\n #enum(named: NamedShape, use: Use): Inner | undefined {\n const existing = this.#models.get(named.key)\n if (existing !== undefined) return this.#known(existing)\n const name = this.#typeName(named, use)\n if (name === undefined) return undefined\n const members = named.enumMembers\n if (members === undefined || members.length === 0) {\n return this.#fail(\n Codes.InvalidType,\n use,\n `The values of the enum ${named.name} cannot be evaluated (${use.coordinate})`,\n ['Use literal member values (A = \"a\", B = 1)'],\n )\n }\n const values: EnumValueModel[] = []\n for (const member of members) {\n if (!this.#checkEnumValueName(member.name, named, member.location, use)) continue\n values.push({\n name: member.name,\n value: member.value,\n description: descriptionOf(member.doc),\n deprecationReason: deprecationOf(member.doc),\n })\n }\n return this.#registerEnum(named, name, values, use)\n }\n\n /** A named alias of a union of string literals: names = values = the literals, in source order. */\n #literalEnum(named: NamedShape, members: readonly Shape[], use: Use): Inner | undefined {\n const existing = this.#models.get(named.key)\n if (existing !== undefined) return this.#known(existing)\n const literals = named.literals ?? members.map(member => (member as Extract<Shape, { kind: 'literal' }>).value)\n if (!literals.every(value => typeof value === 'string')) {\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map ${named.name} (${literals.map(value => JSON.stringify(value)).join(' | ')}) to a GraphQL type (${use.coordinate}): only unions of string literals are enums`,\n ['Declare a TypeScript enum (enum Level { Low = 1, High = 2 }), or use Int'],\n )\n }\n const name = this.#typeName(named, use)\n if (name === undefined) return undefined\n const values: EnumValueModel[] = []\n for (const literal of literals as readonly string[]) {\n if (!this.#checkEnumValueName(literal, named, named.location, use)) continue\n values.push({ name: literal, value: literal, description: undefined, deprecationReason: undefined })\n }\n return this.#registerEnum(named, name, values, use)\n }\n\n #checkEnumValueName(value: string, named: NamedShape, location: Location, use: Use): boolean {\n if (isGraphQLName(value) && !RESERVED_ENUM_VALUES.has(value)) return true\n this.#reportOnce(`enum\\0${named.key}\\0${value}`, {\n code: Codes.NameConflict,\n severity: 'error',\n message: `'${value}' of ${named.name} is not a valid GraphQL enum value`,\n location,\n related: reachedFrom(use),\n hints: [`${NAME_HINT}; true, false and null are reserved`],\n })\n return false\n }\n\n #registerEnum(named: NamedShape, name: string, values: readonly EnumValueModel[], use: Use): Inner | undefined {\n const model: TypeModel = {\n kind: 'enum',\n name,\n key: named.key,\n description: descriptionOf(named.doc),\n location: named.location,\n values,\n }\n this.#models.set(named.key, model)\n if (!this.#claim(model, use)) return undefined\n return refTo(name)\n }\n\n // ------------------------------------------------------------------------------------- unions\n\n /** A named alias of a union of object types (output only), with its runtime discriminator. */\n #union(alias: NamedShape, members: readonly Shape[], use: Use): Inner | undefined {\n if (use.position === 'input') {\n return this.#fail(\n Codes.InvalidInput,\n use,\n `${use.coordinate} is the union ${alias.name}: unions cannot be input values`,\n ['Declare one input type with optional fields, or one argument per case'],\n )\n }\n const existing = this.#models.get(alias.key)\n if (existing !== undefined) return this.#known(existing)\n const name = this.#typeName(alias, use)\n if (name === undefined) return undefined\n const model: UnionModel = {\n kind: 'union',\n name,\n key: alias.key,\n description: descriptionOf(alias.doc),\n location: alias.location,\n members: [],\n discriminator: undefined,\n }\n this.#models.set(alias.key, model)\n if (!this.#claim(model, use)) return undefined\n const trail = `${use.trail} → ${name}`\n const objects: ObjectModel[] = []\n // a failed member is reported: no discriminator then (members that collapse into one object, as\n // `Book | BookAlias`, are not failures)\n let failed = false\n for (const member of members) {\n const memberUse: Use = { ...use, coordinate: name, trail, reached: trail, locate: () => alias.location }\n const converted = this.#inner(member, memberUse)\n if (converted === undefined) {\n failed = true\n continue\n }\n const target = converted.ref.kind === 'named' ? this.#types.get(converted.ref.name) : undefined\n if (target?.kind !== 'object') {\n failed = true\n this.#fail(\n Codes.InvalidType,\n memberUse,\n `The union ${name} contains ${describeShape(member)}, which is not an object type`,\n ['GraphQL unions only contain object types'],\n )\n continue\n }\n if (!objects.includes(target)) objects.push(target)\n }\n objects.sort((a, b) => compareStrings(a.name, b.name))\n model.members = objects.map(object => object.name)\n if (!failed) model.discriminator = this.#discriminator(model, objects)\n return refTo(name)\n }\n\n /**\n * How the runtime tells the members apart (§5.7): `instanceof` when every member is an exported\n * class, a `__typename` property, a literal property with a distinct value per member, else\n * ZNIGHT064.\n */\n #discriminator(union: UnionModel, members: readonly ObjectModel[]): DiscriminatorModel | undefined {\n const found = discriminatorOf(members, identity => this.#ctx.classInfo(identity))\n if (found !== undefined) return found\n const names = members.map(member => member.name)\n const one = names.length === 1\n const listed = one ? (names[0] as string) : `${names.slice(0, -1).join(', ')} and ${names.at(-1) as string}`\n const allClasses = members.every(member => member.classIdentity !== undefined)\n let why: string\n if (allClasses) why = one ? 'is a class that is not exported' : 'are classes that are not all exported'\n else why = one ? 'has no literal property' : 'have no common literal property'\n this.#report({\n code: Codes.UnresolvableAbstractType,\n severity: 'error',\n message: `The members of union ${union.name} cannot be told apart at runtime: ${listed} ${why}`,\n ...(union.location === undefined ? {} : { location: union.location }),\n hints: [\n allClasses\n ? 'Export the member classes: the generated module imports them for instanceof'\n : `Add a literal property to each member (${members.map(member => `readonly kind: '${lowerFirst(member.name)}'`).join(' / ')}), or make the members classes`,\n ],\n })\n return undefined\n }\n\n // --------------------------------------------------------------------------------- final checks\n\n /** Defaults (`@default`, parameter defaults) against their types (ZNIGHT063), as external values. */\n #checkDefaults(): void {\n for (const pending of this.#defaults) {\n const result = externalValue(pending.value, pending.target.ref, this.#types)\n if ('error' in result) {\n const location = pending.location ?? pending.use.locate()\n this.#report({\n code: Codes.InvalidInput,\n severity: 'error',\n message: `Invalid default value ${describeValue(pending.value)} for ${pending.use.coordinate} (${pending.target.type}): ${result.error}`,\n ...(location === undefined ? {} : { location }),\n related: reachedFrom(pending.use),\n hints: ['Defaults are JSON values of the argument type (enum values as their member value or name)'],\n })\n continue\n }\n pending.target.defaultValue = result.value\n if (pending.target.ref.nonNull) pending.target.nullAsUndefined = false\n }\n }\n\n /** GraphQL forbids a cycle of non-null input fields (ZNIGHT063). */\n #checkInputCycles(): void {\n const inputs = [...this.#models.values()]\n .filter((model): model is InputModel => model.kind === 'input')\n .sort((a, b) => compareStrings(a.name, b.name))\n const state = new Map<string, 'visiting' | 'done'>()\n const stack: string[] = []\n const visit = (model: InputModel): void => {\n state.set(model.name, 'visiting')\n stack.push(model.name)\n for (const field of model.fields) {\n if (field.ref.kind !== 'named' || !field.ref.nonNull) continue\n const target = this.#types.get(field.ref.name)\n if (target?.kind !== 'input') continue\n const status = state.get(target.name)\n if (status === 'visiting') {\n const cycle = [...stack.slice(stack.indexOf(target.name)), target.name]\n this.#report({\n code: Codes.InvalidInput,\n severity: 'error',\n message: `The input types ${cycle.join(' → ')} reference each other through non-null fields: no value can be written`,\n ...(target.location === undefined ? {} : { location: target.location }),\n hints: ['Make one of the fields of the cycle optional (?: T) or a list'],\n })\n } else if (status === undefined) {\n visit(target)\n }\n }\n stack.pop()\n state.set(model.name, 'done')\n }\n for (const model of inputs) if (!state.has(model.name)) visit(model)\n }\n\n // ------------------------------------------------------------------------------------ assembly\n\n #assemble(roots: ReadonlyMap<Operation, ObjectModel>, resolvers: readonly ResolverData[]): GraphQLModel {\n const types = [...this.#types.values()].sort((a, b) => compareStrings(a.name, b.name))\n const meta: MetaEntry[] = []\n for (const resolver of resolvers) for (const field of resolver.fields) meta.push(...field.meta)\n const rootNames = {\n query: ROOT_TYPE_NAMES.query,\n ...(roots.has('mutation') ? { mutation: ROOT_TYPE_NAMES.mutation } : {}),\n ...(roots.has('subscription') ? { subscription: ROOT_TYPE_NAMES.subscription } : {}),\n }\n const sdl = printSdl({ roots: rootNames, types: types.map(sdlType) })\n return { roots: rootNames, types, meta, sdl, schemaHash: schemaHash(sdl) }\n }\n}\n\n// ------------------------------------------------------------------------------------------ helpers\n\n/** A (nullable, until `#convert` decides) reference to a named type. */\nfunction refTo(name: string): Inner {\n return { ref: { kind: 'named', name, nonNull: false }, nullable: false }\n}\n\nfunction reachedFrom(use: Use): { readonly message: string; readonly location: Location }[] {\n return use.reached === undefined || use.root === undefined\n ? []\n : [{ message: `reached from ${use.reached}`, location: use.root }]\n}\n\nfunction decoratorName(operation: Operation): string {\n return ROOT_TYPE_NAMES[operation]\n}\n\nfunction describeKey(model: TypeModel): string {\n return model.key.startsWith('#') ? `the ${model.kind} ${model.name}` : model.key\n}\n\n/** Short description of a shape for messages (`string`, `Book`, `Map<string, number>`). */\nfunction describeShape(shape: Shape): string {\n switch (shape.kind) {\n case 'literal':\n return JSON.stringify(shape.value)\n case 'named':\n return shape.key.slice(shape.key.indexOf('#') + 1)\n case 'reference':\n return shape.name\n case 'opaque':\n return shape.text\n case 'array':\n return `${describeShape(shape.items)}[]`\n case 'union':\n return shape.members.map(describeShape).join(' | ')\n case 'object':\n return 'an object literal type'\n default:\n return shape.kind\n }\n}\n\nfunction describeValue(value: unknown): string {\n try {\n return JSON.stringify(value) ?? String(value)\n } catch {\n return String(value)\n }\n}\n\nfunction containsRef(value: unknown): boolean {\n if (typeof value !== 'object' || value === null) return false\n if (Array.isArray(value)) return value.some(containsRef)\n const prototype: unknown = Object.getPrototypeOf(value)\n if (prototype !== Object.prototype && prototype !== null) return true\n return Object.values(value).some(containsRef)\n}\n\nfunction lowerFirst(text: string): string {\n return `${text.charAt(0).toLowerCase()}${text.slice(1)}`\n}\n","/**\n * `generate` of the graphql extension (RFC 0005 §7.1, §7.3): `metadata.extensions.graphql` from the\n * model `validate` built, and the SDL artifact when the extension is configured with `{ sdl }`.\n *\n * Data, not code, except `invoke`: one arrow per resolver field mapping the graphql-js arguments to\n * the method parameters. It is synchronous unless an argument is validated with a Standard Schema\n * whose validation turns out asynchronous: like the `invoke` of `@znight/http` routes, a\n * synchronous validation (Zod, Valibot, ArkType without async refinements) costs no promise.\n *\n * ```ts\n * ['invoke']: (r: BookResolver, p: unknown, _a: GraphQLArgs, c: GraphQLContext) =>\n * r.author(p as never, c.loader('src/authors-by-id.loader.ts#AuthorsById') as never),\n * ```\n */\n\nimport type { GenerateContext, GenInput, GenNode, GenParam } from '@znight/compiler'\nimport type { Token } from '@znight/core'\nimport type { MetaEntry } from '@znight/http/compiler'\nimport type { FieldData, GraphQLData, ParamData, ResolverData } from './data.ts'\nimport type { ArgModel, DiscriminatorModel, FieldModel, GraphQLModel, TypeModel } from './model.ts'\nimport type { ResolvedGraphQLCompilerOptions } from './options.ts'\n\nimport { GRAPHQL_METADATA_VERSION } from '../metadata.ts'\nimport { compareStrings } from './constants.ts'\nimport { RUNTIME_MODULE } from './ids.ts'\n\ntype Context = GenerateContext<GraphQLData>\n\n/** Module of `isThenable` (a required peer of `@znight/graphql`). */\nconst HTTP_MODULE = '@znight/http'\n\n/** Imports created on first use: an unused import would break `noUnusedLocals`. */\ninterface Imports {\n argsType(): GenNode\n contextType(): GenNode\n infoType(): GenNode\n validateArgs(): GenNode\n isThenable(): GenNode\n hostType(identity: string): GenNode\n}\n\n/** Builds the graphql section; `undefined` (no section) when the application has no resolver. */\nexport function generateGraphQL(\n ctx: Context,\n model: GraphQLModel | undefined,\n options: ResolvedGraphQLCompilerOptions,\n): GenNode | undefined {\n if (model === undefined) return undefined\n if (options.sdl !== false) ctx.emitFile(options.sdl, `${model.sdl}\\n`)\n const imports = createImports(ctx)\n const entries: [string, GenInput][] = [\n ['version', ctx.lit(GRAPHQL_METADATA_VERSION)],\n ['schemaHash', model.schemaHash],\n ['roots', ctx.obj(Object.entries(model.roots))],\n ['types', ctx.arr(model.types.map(type => typeNode(ctx, imports, type)))],\n ]\n const groups = groupsNode(ctx, model.meta)\n if (groups !== undefined) entries.push(['groups', groups])\n return ctx.obj(entries)\n}\n\nfunction createImports(ctx: Context): Imports {\n let args: GenNode | undefined\n let context: GenNode | undefined\n let info: GenNode | undefined\n let validateArgs: GenNode | undefined\n let isThenable: GenNode | undefined\n const hosts = new Map<string, GenNode>()\n return {\n argsType: () => {\n args ??= ctx.importFrom(RUNTIME_MODULE, 'GraphQLArgs', { type: true })\n return args\n },\n contextType: () => {\n context ??= ctx.importFrom(RUNTIME_MODULE, 'GraphQLContext', { type: true })\n return context\n },\n infoType: () => {\n info ??= ctx.importFrom('graphql', 'GraphQLResolveInfo', { type: true })\n return info\n },\n validateArgs: () => {\n validateArgs ??= ctx.importFrom(RUNTIME_MODULE, 'validateArgs')\n return validateArgs\n },\n isThenable: () => {\n isThenable ??= ctx.importFrom(HTTP_MODULE, 'isThenable')\n return isThenable\n },\n hostType: identity => {\n let node = hosts.get(identity)\n if (node === undefined) {\n node = ctx.importType(identity)\n hosts.set(identity, node)\n }\n return node\n },\n }\n}\n\nfunction typeNode(ctx: Context, imports: Imports, type: TypeModel): GenNode {\n const head: [string, GenInput][] = [\n ['kind', type.kind],\n ['name', type.name],\n ]\n if (type.description !== undefined && type.kind !== 'scalar') head.push(['description', type.description])\n switch (type.kind) {\n case 'object':\n case 'interface': {\n const entries: [string, GenInput][] = [...head]\n if (type.interfaces.length > 0) entries.push(['interfaces', ctx.lit([...type.interfaces])])\n entries.push(['fields', ctx.arr(type.fields.map(field => fieldNode(ctx, imports, field)))])\n if (type.kind === 'interface') entries.push(['discriminator', discriminatorNode(ctx, type.discriminator)])\n return ctx.obj(entries)\n }\n case 'input':\n return ctx.obj([...head, ['fields', ctx.arr(type.fields.map(field => inputValueNode(ctx, field)))]])\n case 'enum':\n return ctx.obj([\n ...head,\n [\n 'values',\n ctx.arr(\n type.values.map(value => {\n const entries: [string, GenInput][] = [\n ['name', value.name],\n ['value', value.value],\n ]\n if (value.description !== undefined) entries.push(['description', value.description])\n if (value.deprecationReason !== undefined) entries.push(['deprecationReason', value.deprecationReason])\n return ctx.obj(entries)\n }),\n ),\n ],\n ])\n case 'union':\n return ctx.obj([\n ...head,\n ['members', ctx.lit([...type.members])],\n ['discriminator', discriminatorNode(ctx, type.discriminator)],\n ])\n case 'scalar': {\n // built-in scalars carry no description (the runtime builds them, sdl.ts prints them alike);\n // code-first user scalars bring theirs with the imported definition, schema-first ones take\n // the SDL's (they win over the definition's)\n if (type.definition === undefined) return ctx.obj([...head, ['builtin', ctx.lit(true)]])\n const entries: [string, GenInput][] = [...head, ['scalar', ctx.importValue(type.definition)]]\n if (type.fromSdl === true) {\n if (type.description !== undefined) entries.push(['description', type.description])\n if (type.specifiedByURL !== undefined) entries.push(['specifiedByURL', type.specifiedByURL])\n entries.push(['sdl', ctx.lit(true)])\n }\n return ctx.obj(entries)\n }\n }\n}\n\n/** How the runtime tells the members of a union or the implementations of an interface apart. */\nfunction discriminatorNode(ctx: Context, discriminator: DiscriminatorModel | undefined): GenNode {\n if (discriminator === undefined || discriminator.by === 'typename') return ctx.obj([['by', 'typename']])\n if (discriminator.by === 'property') {\n return ctx.obj([\n ['by', 'property'],\n ['property', discriminator.property],\n ['values', ctx.obj(Object.entries(discriminator.values))],\n ])\n }\n return ctx.obj([\n ['by', 'class'],\n ['classes', ctx.arr(discriminator.classes.map(entry => ctx.arr([ctx.importValue(entry.identity), entry.name])))],\n ])\n}\n\nfunction fieldNode(ctx: Context, imports: Imports, field: FieldModel): GenNode {\n const entries: [string, GenInput][] = [\n ['name', field.name],\n ['type', field.type],\n ]\n if (field.description !== undefined) entries.push(['description', field.description])\n if (field.deprecationReason !== undefined) entries.push(['deprecationReason', field.deprecationReason])\n if (field.args.length > 0) entries.push(['args', ctx.arr(field.args.map(arg => inputValueNode(ctx, arg)))])\n if (field.binding !== undefined) {\n entries.push(['resolver', resolverNode(ctx, imports, field.binding.resolver, field.binding.field)])\n }\n return ctx.obj(entries)\n}\n\nfunction inputValueNode(ctx: Context, arg: ArgModel): GenNode {\n const entries: [string, GenInput][] = [\n ['name', arg.name],\n ['type', arg.type],\n ]\n if (arg.description !== undefined) entries.push(['description', arg.description])\n if (arg.deprecationReason !== undefined) entries.push(['deprecationReason', arg.deprecationReason])\n if (arg.defaultValue !== undefined) entries.push(['defaultValue', ctx.lit(arg.defaultValue as never)])\n if (arg.nullAsUndefined) entries.push(['nullAsUndefined', ctx.lit(true)])\n return ctx.obj(entries)\n}\n\nfunction resolverNode(ctx: Context, imports: Imports, resolver: ResolverData, field: FieldData): GenNode {\n const guards = [...resolver.guards, ...field.guards].map(ref => ctx.tokenOf(ref) ?? ref.token)\n const entries: [string, GenInput][] = [\n ['token', ctx.tokenOf(resolver.host) ?? resolver.host.identity],\n ['method', field.method],\n ['operation', field.operation],\n ['guards', ctx.lit(guards)],\n ['meta', ctx.obj(field.meta.map(entry => [entry.key, ctx.lit(entry.value as never)] as const))],\n ]\n const loaders = field.params.flatMap(param => (param?.kind === 'loader' ? [loaderToken(ctx, param)] : []))\n if (loaders.length > 0) entries.push(['loaders', ctx.lit(loaders)])\n entries.push(['invoke', invokeNode(ctx, imports, resolver, field)])\n return ctx.obj(entries)\n}\n\n/** The provider token a loader parameter is bound to. */\nfunction loaderToken(ctx: Context, param: Extract<ParamData, { kind: 'loader' }>): Token {\n const ref = ctx.binding(param.binding)\n if (typeof ref === 'string') return ref\n if (ref !== undefined && 'token' in ref) return ref.token\n return param.identity\n}\n\n// ------------------------------------------------------------------------------------------- invoke\n\n/** Which `invoke` parameters a field uses: `(r, p, a, c, i)`. */\nfunction usedParameters(field: FieldData): readonly [p: boolean, a: boolean, c: boolean, i: boolean] {\n let p = false\n let a = false\n let c = false\n let i = false\n for (const param of field.params) {\n switch (param?.kind) {\n case 'parent':\n p = true\n break\n case 'args':\n a = true\n break\n case 'ctx':\n case 'loader':\n c = true\n break\n case 'info':\n i = true\n break\n }\n }\n return [p, a, c, i]\n}\n\n/**\n * `(r: Resolver, p: unknown, a: GraphQLArgs, c: GraphQLContext, i: GraphQLResolveInfo) => r.m(...)`:\n * unused middle parameters are `_`-prefixed, trailing ones omitted (`noUnusedParameters`).\n */\nfunction invokeNode(ctx: Context, imports: Imports, resolver: ResolverData, field: FieldData): GenNode {\n const used = usedParameters(field)\n const last = used.lastIndexOf(true)\n const types = [() => ctx.code`unknown`, imports.argsType, imports.contextType, imports.infoType]\n const names = ['p', 'a', 'c', 'i']\n const params: [string, GenNode][] = [['r', imports.hostType(resolver.host.identity)]]\n for (let index = 0; index <= last; index++) {\n params.push([`${used[index] ? '' : '_'}${names[index] as string}`, (types[index] as () => GenNode)()])\n }\n const validated = field.params.flatMap((param, index) =>\n param?.kind === 'args' && param.schema !== undefined ? [index] : [],\n )\n return ctx.arrow(params, (r, ...rest) => {\n const [p, a, c, i] = rest as (GenParam | undefined)[]\n const scope: Scope = { p, a, c, i }\n if (validated.length === 0) return call(ctx, r, field, index => argument(ctx, scope, field, index))\n return validatingBlock(ctx, imports, r, scope, field, validated)\n })\n}\n\n/** The parameters of the `invoke` arrow (absent when not declared). */\ninterface Scope {\n readonly p: GenNode | undefined\n readonly a: GenNode | undefined\n readonly c: GenNode | undefined\n readonly i: GenNode | undefined\n}\n\n/** `r.method(args)`. */\nfunction call(ctx: Context, r: GenNode, field: FieldData, argumentOf: (index: number) => GenNode): GenNode {\n return ctx.call(\n ctx.member(r, field.method),\n field.params.map((_, index) => argumentOf(index)),\n )\n}\n\n/** The expression passed for the parameter `index` (validation not applied). */\nfunction argument(ctx: Context, scope: Scope, field: FieldData, index: number): GenNode {\n const param = field.params[index]\n switch (param?.kind) {\n case 'parent':\n return ctx.code`${scope.p as GenNode} as never`\n case 'ctx':\n return scope.c as GenNode\n case 'info':\n return scope.i as GenNode\n case 'loader':\n return ctx.code`${ctx.call(ctx.member(scope.c as GenNode, 'loader'), [loaderToken(ctx, param)])} as never`\n case 'args':\n return ctx.code`${argsValue(ctx, scope, param.name)} as never`\n default:\n return ctx.lit(undefined)\n }\n}\n\n/** `a['name']`, or `a` for `@Args()`. */\nfunction argsValue(ctx: Context, scope: Scope, name: string | undefined): GenNode {\n const a = scope.a as GenNode\n return name === undefined ? a : ctx.code`${a}[${name}]`\n}\n\n/** `validateArgs(Schema, a['input'], 'input')`. */\nfunction validation(\n ctx: Context,\n imports: Imports,\n scope: Scope,\n param: Extract<ParamData, { kind: 'args' }>,\n): GenNode {\n return ctx.call(imports.validateArgs(), [\n ctx.ref(param.schema as NonNullable<typeof param.schema>),\n argsValue(ctx, scope, param.name),\n param.name ?? 'args',\n ])\n}\n\n/**\n * The body of the `invoke` of a field validating arguments: each validation is evaluated in order\n * into a `const`; while they return values the method is called synchronously, the first thenable\n * resumes in an `async` arrow that awaits it and the later validations (the order of evaluation and\n * the error reported first are those of an `async` invoke awaiting every validation).\n *\n * ```ts\n * (r: BookResolver, _p: unknown, a: GraphQLArgs) => {\n * const v0 = validateArgs(NewBookInput, a['input'], 'input')\n * if (isThenable(v0)) return (async () => r.addBook(await v0 as never))()\n * return r.addBook(v0 as never)\n * }\n * ```\n */\nfunction validatingBlock(\n ctx: Context,\n imports: Imports,\n r: GenNode,\n scope: Scope,\n field: FieldData,\n validated: readonly number[],\n): GenNode {\n return ctx.block(\n validated.map(index => `v${index}`),\n (...locals) => {\n const local = new Map(validated.map((index, position) => [index, locals[position] as GenNode]))\n const statements: GenNode[] = []\n for (const index of validated) {\n const name = local.get(index) as GenNode\n const param = field.params[index] as Extract<ParamData, { kind: 'args' }>\n statements.push(ctx.code`const ${name} = ${validation(ctx, imports, scope, param)}`)\n const resume = ctx.arrow(\n [],\n () =>\n call(ctx, r, field, position => {\n const value = local.get(position)\n if (value === undefined) return argument(ctx, scope, field, position)\n if (position < index) return ctx.code`${value} as never`\n if (position === index) return ctx.code`await ${value} as never`\n const later = field.params[position] as Extract<ParamData, { kind: 'args' }>\n return ctx.code`await ${validation(ctx, imports, scope, later)} as never`\n }),\n { async: true },\n )\n statements.push(ctx.code`if (${ctx.call(imports.isThenable(), [name])}) return (${resume})()`)\n }\n statements.push(\n ctx.code`return ${call(ctx, r, field, position => {\n const value = local.get(position)\n return value === undefined ? argument(ctx, scope, field, position) : ctx.code`${value} as never`\n })}`,\n )\n return statements\n },\n )\n}\n\n// ------------------------------------------------------------------------------------------- groups\n\n/**\n * `groups`: the route decorator groups the runtime needs (required, holding several keys, or named\n * differently from their key), sorted; `undefined` when there is none (RFC 0001, as `extensions.http`).\n */\nfunction groupsNode(ctx: Context, meta: readonly MetaEntry[]): GenNode | undefined {\n const groups = new Map<string, { readonly keys: Set<string>; required: boolean }>()\n for (const entry of meta) {\n const group = groups.get(entry.group)\n if (group === undefined) groups.set(entry.group, { keys: new Set([entry.key]), required: entry.required })\n else {\n group.keys.add(entry.key)\n group.required ||= entry.required\n }\n }\n const needed = [...groups]\n .filter(([name, group]) => group.required || group.keys.size > 1 || !group.keys.has(name))\n .sort(([a], [b]) => compareStrings(a, b))\n if (needed.length === 0) return undefined\n return ctx.obj(\n needed.map(\n ([name, group]) =>\n [\n name,\n ctx.obj([\n ['keys', ctx.lit([...group.keys].sort(compareStrings))],\n ['required', group.required],\n ]),\n ] as const,\n ),\n )\n}\n","/**\n * Options of the compiler extension (RFC 0005 §6.7, RFC 0007 §4.1), given with\n * `graphql.configure({ ... })` in `znight.config.ts`. Import-free.\n */\n\n/** Options of `graphql.configure()`. */\nexport interface GraphQLCompilerOptions {\n /**\n * Path of the SDL artifact, relative to the project root (`'schema.graphql'`), written next to the\n * generated module and checked by `znight generate --check`. Default `false`: no file.\n */\n readonly sdl?: string | false\n /** GraphQL type of `number`. Default `'Float'`; `'Int'` suits counts and identifiers. Code-first only. */\n readonly number?: 'Float' | 'Int'\n /**\n * Schema-first mode (RFC 0007): globs of the `.graphql` files that define the schema, relative to\n * the project root (`'src/**\\/*.graphql'`, `!` negations allowed). Resolvers are bound to their\n * fields by name and checked against the SDL. Default `false`: code-first.\n */\n readonly schema?: string | readonly string[] | false\n}\n\n/** {@link GraphQLCompilerOptions} with their defaults. */\nexport interface ResolvedGraphQLCompilerOptions {\n readonly sdl: string | false\n readonly number: 'Float' | 'Int'\n /** The schema-first globs; `false`: code-first. */\n readonly schema: readonly string[] | false\n}\n\n/** The defaults. */\nexport const DEFAULT_OPTIONS: ResolvedGraphQLCompilerOptions = Object.freeze({\n sdl: false,\n number: 'Float',\n schema: false,\n})\n\nconst KNOWN = new Set(['sdl', 'number', 'schema'])\n\n/**\n * Merges `options` onto `base`. Throws a `TypeError` naming the option on an invalid value: options\n * are written in `znight.config.ts`, the error surfaces when the configuration is loaded.\n */\nexport function resolveOptions(\n base: ResolvedGraphQLCompilerOptions,\n options: GraphQLCompilerOptions,\n): ResolvedGraphQLCompilerOptions {\n if (typeof options !== 'object' || options === null || Array.isArray(options)) {\n throw new TypeError('[znight] graphql.configure() expects an options object: { sdl?, number?, schema? }')\n }\n for (const key of Object.keys(options)) {\n if (!KNOWN.has(key))\n throw new TypeError(`[znight] graphql.configure(): unknown option \"${key}\" (options: sdl, number, schema)`)\n }\n const sdl = options.sdl === undefined ? base.sdl : options.sdl\n if (sdl !== false && (typeof sdl !== 'string' || sdl.trim() === '')) {\n throw new TypeError(\n '[znight] graphql.configure(): \"sdl\" must be a path relative to the project root (\\'schema.graphql\\') or false',\n )\n }\n const number = options.number === undefined ? base.number : options.number\n if (number !== 'Float' && number !== 'Int') {\n throw new TypeError(`[znight] graphql.configure(): \"number\" must be 'Float' or 'Int'`)\n }\n return Object.freeze({ sdl, number, schema: resolveSchema(base.schema, options.schema) })\n}\n\nfunction resolveSchema(\n base: readonly string[] | false,\n schema: GraphQLCompilerOptions['schema'],\n): readonly string[] | false {\n if (schema === undefined) return base\n if (schema === false) return false\n const globs = typeof schema === 'string' ? [schema] : schema\n if (\n !Array.isArray(globs) ||\n globs.length === 0 ||\n globs.some(glob => typeof glob !== 'string' || glob.trim() === '')\n ) {\n throw new TypeError(\n '[znight] graphql.configure(): \"schema\" must be a glob or a non-empty list of globs relative to the project root (\\'src/**/*.graphql\\'), or false',\n )\n }\n return Object.freeze([...globs])\n}\n","/**\n * The graphql-js modules schema-first compiles use (RFC 0007 §7): the language (parser, AST), the\n * type system (`validateSchema`, type predicates) and the utilities (`buildASTSchema`,\n * `concatAST`, `valueFromASTUntyped`). Loaded lazily, on the first schema-first compile, with\n * `createRequire`: code-first compiles never load graphql-js, and the execution engine\n * (`graphql/execution`, the `graphql` root entry) and dataloader are never loaded at build time\n * (tests/boundaries.test.ts). graphql is a required peer of `@znight/graphql`.\n */\nimport type * as Language from 'graphql/language'\nimport type * as Type from 'graphql/type'\nimport type * as Utilities from 'graphql/utilities'\n\nimport { createRequire } from 'node:module'\n\n/** The build-time graphql-js modules. */\nexport interface GraphQLBuildModules {\n readonly language: typeof Language\n readonly type: typeof Type\n readonly utilities: typeof Utilities\n}\n\n/** The only graphql-js modules the compiler extension may load (checked by tests/boundaries.test.ts). */\nexport const GRAPHQL_BUILD_MODULES: readonly string[] = Object.freeze([\n 'graphql/language',\n 'graphql/type',\n 'graphql/utilities',\n])\n\nlet loaded: GraphQLBuildModules | undefined\n\n/** The graphql-js modules, loaded on first use. */\nexport function graphqlModules(): GraphQLBuildModules {\n if (loaded === undefined) {\n const load = createRequire(import.meta.url)\n loaded = Object.freeze({\n language: load('graphql/language') as typeof Language,\n type: load('graphql/type') as typeof Type,\n utilities: load('graphql/utilities') as typeof Utilities,\n })\n }\n return loaded\n}\n","/**\n * Type conformance of schema-first resolvers (RFC 0007 §5.4): the TypeScript signatures of the\n * resolver methods, read through the type shapes API, against the SDL types. Output positions\n * (return types, parent types, the properties of the returned objects) must be assignable to the\n * SDL type; input positions (`@Args` parameters, input objects) must accept every value graphql-js\n * passes. The walk follows the object fields without resolver through the properties of the\n * TypeScript types (each SDL type and TypeScript declaration pair once), which is also where an\n * object field that nothing provides is found (coverage, §5.3).\n *\n * Every mismatch is a ZNIGHT068 located on the TypeScript annotation, the SDL definition related.\n * `any`, `unknown`, opaque types and missing annotations are not checked. The walk also decides\n * `nullAsUndefined` of arguments and input fields and the discriminators of abstract types.\n */\nimport type {\n Diagnostic,\n Location,\n MethodInfo,\n NamedShape,\n ParameterInfo,\n Shape,\n ShapeOptions,\n ShapeProperty,\n ShapeResult,\n ValidateContext,\n} from '@znight/compiler'\nimport type {\n ASTNode,\n GraphQLAbstractType,\n GraphQLField,\n GraphQLInputObjectType,\n GraphQLInputType,\n GraphQLObjectType,\n GraphQLOutputType,\n GraphQLSchema,\n} from 'graphql'\nimport type { FieldData, GraphQLData, ResolverData } from './data.ts'\nimport type { DiscriminatorModel } from './model.ts'\nimport type { ScalarDeclaration } from './scalars.ts'\n\nimport { ASYNC_ITERABLES, BASE_KEEP, Codes, compareStrings, OUTPUT_ITERABLES } from './constants.ts'\nimport { graphqlModules } from './graphql-js.ts'\nimport { GraphQLIds } from './ids.ts'\nimport { annotationLocation, returnTypeLocation } from './locate.ts'\n\ntype Context = ValidateContext<GraphQLData>\n\n/** A resolver method bound to an SDL field. */\nexport interface Binding {\n readonly resolver: ResolverData\n readonly field: FieldData\n readonly method: MethodInfo\n /** The type declaring the field (a root type for root fields). */\n readonly type: GraphQLObjectType\n readonly sdlField: GraphQLField<unknown, unknown>\n}\n\n/** Inputs of {@link checkConformance}. */\nexport interface ConformanceInput {\n readonly ctx: Context\n readonly schema: GraphQLSchema\n readonly locate: (node: ASTNode | null | undefined) => Location | undefined\n /** `scalar<T>()` declarations by GraphQL name. */\n readonly scalars: ReadonlyMap<string, ScalarDeclaration>\n /** Sorted by resolver identity, then source order. */\n readonly bindings: readonly Binding[]\n /** Coordinates (`Event.owner`) bound to a resolver. */\n readonly bound: ReadonlySet<string>\n readonly report: (diagnostic: Diagnostic) => void\n}\n\n/** What the walk decides for the model. */\nexport interface ConformanceResult {\n /** Coordinates of the arguments (`Query.books(limit:)`) and input fields (`BookFilter.genre`) whose `null` becomes `undefined`. */\n readonly nullAsUndefined: ReadonlySet<string>\n /** Discriminators of the abstract types; absent: `typename`. */\n readonly discriminators: ReadonlyMap<string, DiscriminatorModel>\n}\n\n/** Where a TypeScript type is checked. */\ninterface Site {\n /** What the type is, in messages: `EventResolver.event returns`, `User.email is`. */\n readonly label: string\n /** Where the TypeScript type comes from, in messages: `returned by EventResolver.event`. */\n readonly origin: string\n /** The SDL coordinate, in messages: `Query.event`, `Event.owner`, `Query.events(limit:)`. */\n readonly coordinate: string\n /** The TypeScript annotation (called only when a diagnostic is reported). */\n readonly locate: () => Location | undefined\n /** The SDL definition. */\n readonly sdl: Location | undefined\n /** An optional property (output: may be `undefined`). */\n readonly optional: boolean\n /** The type of the field or argument, when `type` is the type of its list items. */\n readonly list?: string\n}\n\n/** Options of an input position. */\ninterface InputPosition {\n /** The TypeScript value may be `undefined`: optional parameter or property, parameter default. */\n readonly optional: boolean\n /** The SDL argument or input field has a default value: never absent. */\n readonly sdlDefault: boolean\n /** Coordinate whose `nullAsUndefined` this position votes for. */\n readonly vote?: string\n /** A list item: never absent, and a `null` item stays `null` (no `nullAsUndefined`). */\n readonly item?: true\n}\n\n/** A shape split into its non-nullish members. */\ninterface Parts {\n readonly members: Shape[]\n hasNull: boolean\n hasUndefined: boolean\n /** `unknown`, `any` or an opaque part: not checked. */\n unchecked: boolean\n}\n\nconst MAX_DEPTH = 64\n\n/** Walks every binding; reports the mismatches. */\nexport function checkConformance(input: ConformanceInput): ConformanceResult {\n return new Conformance(input).run()\n}\n\nclass Conformance {\n readonly #config: ConformanceInput\n readonly #ctx: Context\n readonly #options: ShapeOptions\n readonly #named = new Map<string, NamedShape>()\n readonly #visited = new Set<string>()\n readonly #anonymous = new WeakMap<object, Set<string>>()\n readonly #reported = new Set<string>()\n readonly #votes = new Map<string, { accepts: number; rejects: Site[] }>()\n /** Abstract type → member object type → class identities (`''`: not an exported class) returned for it. */\n readonly #members = new Map<string, Map<string, Set<string>>>()\n /** TypeScript members of abstract types that cannot be told apart (ZNIGHT064 unless every member is a class). */\n readonly #untellable = new Map<\n string,\n { readonly name: string; readonly site: Site; readonly location?: Location }[]\n >()\n readonly #predicates = graphqlModules().type\n /** Identities of the `T` of the `scalar<T>()` declarations. */\n readonly #scalarTypes: ReadonlySet<string>\n\n constructor(input: ConformanceInput) {\n this.#config = input\n this.#ctx = input.ctx\n const keep = new Set<string>(BASE_KEEP)\n for (const scalar of input.scalars.values()) keep.add(scalar.type)\n this.#scalarTypes = new Set([...input.scalars.values()].map(scalar => scalar.type))\n this.#options = Object.freeze({\n keep: Object.freeze([...keep].sort(compareStrings)),\n members: 'instance',\n jsdoc: false,\n })\n }\n\n run(): ConformanceResult {\n for (const binding of this.#config.bindings) this.#binding(binding)\n const nullAsUndefined = new Set<string>()\n for (const [coordinate, vote] of [...this.#votes].sort(([a], [b]) => compareStrings(a, b))) {\n if (vote.rejects.length === 0) continue\n if (vote.accepts === 0) {\n nullAsUndefined.add(coordinate)\n continue\n }\n for (const site of vote.rejects) {\n this.#mismatch(\n site,\n `${site.label} does not accept null, but another use of ${coordinate} does: null is passed as is`,\n ['Accept null (| null) in every TypeScript type of the value, or none of them'],\n )\n }\n }\n return { nullAsUndefined, discriminators: this.#discriminators() }\n }\n\n // ------------------------------------------------------------------------------------ bindings\n\n #binding(binding: Binding): void {\n const { resolver, field, method, type, sdlField } = binding\n const where = `${resolver.host.displayName}.${method.name}`\n const coordinate = `${type.name}.${sdlField.name}`\n const sdl = this.#config.locate(sdlField.astNode)\n if (method.returnType !== undefined) {\n const result = this.#shape({ returnOf: method })\n const site: Site = {\n label: `${where} returns`,\n origin: `returned by ${where}`,\n coordinate,\n locate: () => returnTypeLocation(this.#ctx.project, method) ?? method.location,\n sdl,\n optional: false,\n }\n const root = result.root\n const iterable = root.kind === 'reference' && ASYNC_ITERABLES.has(root.identity) ? root : undefined\n if (field.operation === 'subscription') {\n if (iterable !== undefined) {\n this.#output(sdlField.type, iterable.typeArgs[0] ?? { kind: 'unknown' }, site)\n } else if (!this.#parts(root).unchecked) {\n this.#report({\n code: Codes.InvalidResolver,\n severity: 'error',\n message: `@Subscription ${where} must return an async iterable (${coordinate})`,\n location: site.locate() ?? method.location,\n hints: [\n `Declare it as an async generator (async *${method.name}(): AsyncGenerator<Event>) or return pubsub.subscribe(...) (AsyncIterable<Event>)`,\n ],\n })\n }\n } else if (iterable === undefined) {\n this.#output(sdlField.type, root, site)\n } else {\n this.#mismatch(site, `${where} returns an async iterable: only Subscription fields stream values`, [\n `Use @Subscription() for a stream of events, or return the value of ${coordinate}`,\n ])\n }\n }\n field.params.forEach((data, index) => {\n const param = method.params[index] as ParameterInfo | undefined\n if (param === undefined) return\n if (data?.kind === 'args' && data.schema === undefined) this.#arguments(binding, data.name, param, where)\n else if (data?.kind === 'parent') this.#parent(type, param, where)\n })\n }\n\n /** `@Args('name')` (one argument) or `@Args()` (every argument, an object type). */\n #arguments(binding: Binding, name: string | undefined, param: ParameterInfo, where: string): void {\n const { type, sdlField } = binding\n const coordinate = `${type.name}.${sdlField.name}`\n const result = this.#shape({ parameter: param })\n if (name !== undefined) {\n const arg = sdlField.args.find(candidate => candidate.name === name)\n if (arg === undefined) return // coverage (schema-first.ts)\n this.#input(\n arg.type,\n result.root,\n {\n optional: param.optional || param.hasDefault,\n sdlDefault: arg.default !== undefined,\n vote: `${coordinate}(${name}:)`,\n },\n {\n label: `parameter '${param.name}' of ${where}`,\n origin: `parameter '${param.name}' of ${where}`,\n coordinate: `${coordinate}(${name}:)`,\n locate: () => param.typeLocation,\n sdl: this.#config.locate(arg.astNode),\n optional: false,\n },\n )\n return\n }\n const site: Site = {\n label: `@Args() parameter '${param.name}' of ${where}`,\n origin: `@Args() parameter '${param.name}' of ${where}`,\n coordinate,\n locate: () => param.typeLocation,\n sdl: this.#config.locate(sdlField.astNode),\n optional: false,\n }\n const parts = this.#parts(result.root)\n if (parts.unchecked) return\n const object = parts.members.length === 1 ? (parts.members[0] as Shape) : undefined\n const properties = object === undefined ? undefined : this.#propertiesOf(object)\n if (properties === 'record') return\n if (properties === undefined) {\n this.#mismatch(site, `${site.label} must be an object type: it receives every argument of ${coordinate}`, [\n `@Args('name') receives one argument`,\n ])\n return\n }\n for (const property of properties) {\n const arg = sdlField.args.find(candidate => candidate.name === property.name)\n const propertySite: Site = {\n label: `property '${property.name}' of the @Args() parameter of ${where}`,\n origin: site.origin,\n coordinate: `${coordinate}(${property.name}:)`,\n locate: () => annotationLocation(this.#ctx.project, property.location) ?? param.typeLocation,\n sdl: this.#config.locate(arg?.astNode ?? sdlField.astNode),\n optional: false,\n }\n if (arg === undefined) {\n const names = sdlField.args.map(candidate => candidate.name)\n this.#mismatch(\n { ...propertySite, locate: () => property.location ?? param.typeLocation },\n `${coordinate} has no argument '${property.name}' (${propertySite.label})`,\n [names.length === 0 ? `${coordinate} takes no argument` : `Its arguments: ${names.join(', ')}`],\n )\n continue\n }\n this.#input(\n arg.type,\n property.shape,\n { optional: property.optional, sdlDefault: arg.default !== undefined, vote: propertySite.coordinate },\n propertySite,\n )\n }\n }\n\n /** `@Parent()`: its properties named like the unbound fields of the type conform to them. */\n #parent(type: GraphQLObjectType, param: ParameterInfo, where: string): void {\n const result = this.#shape({ parameter: param })\n const site: Site = {\n label: `@Parent() parameter '${param.name}' of ${where}`,\n origin: `@Parent() parameter of ${where}`,\n coordinate: type.name,\n locate: () => param.typeLocation,\n sdl: this.#config.locate(type.astNode),\n optional: false,\n }\n const parts = this.#parts(result.root)\n if (parts.unchecked) return\n for (const member of parts.members) {\n const properties = this.#propertiesOf(member)\n if (properties === 'record') continue\n if (properties === undefined) {\n this.#mismatch(site, `${site.label} is ${this.#describe(member)}, not an object type (${type.name})`, [\n `Type it with the TypeScript type of ${type.name}`,\n ])\n continue\n }\n const fields = type.getFields()\n for (const property of properties) {\n const field = fields[property.name]\n if (field === undefined || this.#config.bound.has(`${type.name}.${field.name}`)) continue\n this.#output(field.type, property.shape, this.#propertySite(site, type, field, property, member))\n }\n }\n }\n\n // -------------------------------------------------------------------------------------- output\n\n #output(type: GraphQLOutputType, shape: Shape, site: Site, depth = 0): void {\n if (depth > MAX_DEPTH) return\n const parts = this.#parts(shape)\n if (parts.unchecked) return\n const { isNonNullType, isListType, isScalarType, isEnumType, isObjectType } = this.#predicates\n let inner = type\n if (isNonNullType(inner)) {\n if (parts.hasNull || parts.hasUndefined || site.optional) {\n const what = parts.hasNull ? 'null' : 'undefined'\n const described = `${site.label} ${this.#describeParts(parts, site.optional)}, which may be ${what}`\n if (site.list === undefined) {\n this.#mismatch(site, `${described}, but ${site.coordinate} is ${String(type)} (non-null)`, [\n `Return a value in every case, or make ${site.coordinate} nullable in the SDL (${String(inner.ofType)})`,\n ])\n } else {\n this.#mismatch(\n site,\n `${described}, but the items of ${site.coordinate} (${site.list}) are ${String(type)} (non-null)`,\n [`Return non-null items, or make the items of ${site.coordinate} nullable in the SDL`],\n )\n }\n }\n inner = inner.ofType\n }\n if (parts.members.length === 0) return\n if (isListType(inner)) {\n for (const member of parts.members) {\n const item = this.#listItem(member, 'output')\n if (item === undefined) {\n this.#mismatch(\n site,\n `${site.label} ${this.#describe(member)}, not a list, but ${site.coordinate} is ${String(type)}`,\n ['Return an array (readonly T[]), a Set or an Iterable'],\n )\n continue\n }\n for (const shape of item) {\n this.#output(\n inner.ofType,\n shape,\n { ...site, label: `${site.label} a list of`, optional: false, list: site.list ?? String(type) },\n depth + 1,\n )\n }\n }\n return\n }\n if (isScalarType(inner)) {\n for (const member of parts.members) {\n if (this.#scalarAccepts(inner.name, member, 'output')) continue\n this.#mismatch(\n site,\n `${site.label} ${this.#describe(member)}, which does not conform to ${inner.name} (${site.coordinate})`,\n [this.#scalarHint(inner.name)],\n )\n }\n return\n }\n if (isEnumType(inner)) {\n const values = new Set(inner.getValues().map(value => value.name))\n for (const member of parts.members) {\n const literals = this.#literals(member)\n if (literals === undefined) {\n this.#mismatch(\n site,\n `${site.label} ${this.#describe(member)}, wider than the enum ${inner.name} (${site.coordinate})`,\n [\n `Return the values of ${inner.name}: ${[...values].join(', ')} (a TypeScript enum or a union of literals)`,\n ],\n )\n continue\n }\n const unknown = literals.filter(literal => !values.has(String(literal)))\n if (unknown.length > 0) {\n this.#mismatch(\n site,\n `${site.label} ${unknown.map(literal => JSON.stringify(literal)).join(', ')}, not ${unknown.length === 1 ? 'a value' : 'values'} of the enum ${inner.name} (${site.coordinate})`,\n [`Enum values are compared by value: ${[...values].join(', ')}`],\n )\n }\n }\n return\n }\n if (isObjectType(inner)) {\n for (const member of parts.members) this.#object(inner, member, site, depth)\n return\n }\n this.#abstract(inner, parts.members, site, depth)\n }\n\n /** An object type returned as `shape`: every field without resolver is a conforming property. */\n #object(type: GraphQLObjectType, shape: Shape, site: Site, depth: number): void {\n const properties = this.#propertiesOf(shape)\n if (properties === 'record') return\n if (properties === undefined) {\n this.#mismatch(\n site,\n `${site.label} ${this.#describe(shape)}, not an object type, but ${site.coordinate} is ${type.name}`,\n [`Return the TypeScript type of ${type.name} (an interface, a class or an object type)`],\n )\n return\n }\n if (!this.#visit(`output\\0${type.name}`, shape)) return\n const named = shape.kind === 'named' ? this.#named.get(shape.key) : undefined\n const tsName = named?.name ?? 'the returned object type'\n const byName = new Map(properties.map(property => [property.name, property]))\n for (const field of Object.values(type.getFields())) {\n const coordinate = `${type.name}.${field.name}`\n if (this.#config.bound.has(coordinate)) continue\n const property = byName.get(field.name)\n if (property === undefined) {\n const location = this.#config.locate(field.astNode)\n const declaration = named?.location ?? site.locate()\n this.#reportOnce(`provide\\0${coordinate}\\0${named?.key ?? site.label}`, {\n code: Codes.SchemaMismatch,\n severity: 'error',\n message: `${coordinate} has no resolver, and ${tsName} (${site.origin}) has no property '${field.name}'`,\n ...(location === undefined ? {} : { location }),\n hints: [\n `Add a field resolver: @ResolveField('${field.name}') in a @Resolver('${type.name}') class`,\n `Or add '${field.name}' to ${tsName}`,\n ],\n ...(declaration === undefined\n ? {}\n : { related: [{ message: `${tsName} is declared here`, location: declaration }] }),\n })\n continue\n }\n this.#output(field.type, property.shape, this.#propertySite(site, type, field, property, shape), depth + 1)\n }\n }\n\n /** A union or an interface: each TypeScript member is matched to a possible type. */\n #abstract(type: GraphQLAbstractType, members: readonly Shape[], site: Site, depth: number): void {\n const possible = this.#config.schema.getPossibleTypes(type)\n const names = possible.map(object => object.name)\n for (const member of members) {\n const named = member.kind === 'named' ? this.#named.get(member.key) : undefined\n const properties = this.#propertiesOf(member)\n if (properties === undefined) {\n this.#mismatch(\n site,\n `${site.label} ${this.#describe(member)}, not an object type, but ${site.coordinate} is ${type.name}`,\n [`Return one of ${names.join(', ')}`],\n )\n continue\n }\n if (properties === 'record') continue\n // graphql-codegen's interface types (`Node`): checked against the fields of the interface\n if (named?.name === type.name && this.#predicates.isInterfaceType(type)) {\n if (!this.#visit(`interface\\0${type.name}`, member)) continue\n const byName = new Map(properties.map(property => [property.name, property]))\n for (const field of Object.values(type.getFields())) {\n const property = byName.get(field.name)\n if (property !== undefined) {\n this.#output(field.type, property.shape, this.#propertySite(site, type, field, property, member), depth + 1)\n }\n }\n continue\n }\n const typename = properties.find(property => property.name === '__typename')\n const literal = typename?.shape.kind === 'literal' ? typename.shape.value : undefined\n // a member is recognised by its `__typename` literal, else by its name\n let target = typeof literal === 'string' ? literal : undefined\n if (target === undefined && named !== undefined && names.includes(named.name)) target = named.name\n if (target === undefined || !names.includes(target)) {\n const what = named?.name ?? this.#describe(member)\n if (names.length === 0) {\n this.#mismatch(site, `${site.label} ${what}, but no object type implements ${type.name} in the SDL`, [\n `Declare an implementation: type ${what} implements ${type.name} { ... }`,\n ])\n continue\n }\n this.#mismatch(\n site,\n `${site.label} ${what}, which is not ${names.length === 1 ? 'the member' : 'a member'} of ${type.name} (${names.join(', ')})`,\n [\n `Return ${names.join(' | ')}: a member is recognised by its __typename literal (__typename: '${names[0] ?? 'Member'}'), else by its name`,\n ],\n )\n continue\n }\n const object = this.#config.schema.getType(target) as GraphQLObjectType\n this.#object(object, member, site, depth + 1)\n const identity =\n named?.declaration === 'class' &&\n named.typeArgs.length === 0 &&\n this.#ctx.classInfo(named.identity)?.exported === true\n ? named.identity\n : ''\n let byMember = this.#members.get(type.name)\n if (byMember === undefined) {\n byMember = new Map()\n this.#members.set(type.name, byMember)\n }\n let identities = byMember.get(target)\n if (identities === undefined) {\n identities = new Set()\n byMember.set(target, identities)\n }\n identities.add(identity)\n if (typename === undefined && identity === '') {\n let list = this.#untellable.get(type.name)\n if (list === undefined) {\n list = []\n this.#untellable.set(type.name, list)\n }\n list.push({ name: named?.name ?? target, site, ...(named === undefined ? {} : { location: named.location }) })\n }\n }\n }\n\n // --------------------------------------------------------------------------------------- input\n\n #input(type: GraphQLInputType, shape: Shape, position: InputPosition, site: Site, depth = 0): void {\n if (depth > MAX_DEPTH) return\n const parts = this.#parts(shape)\n const { isNonNullType, isListType, isScalarType, isEnumType } = this.#predicates\n let inner = type\n if (isNonNullType(inner)) inner = inner.ofType\n else {\n const acceptsNull = parts.hasNull || parts.unchecked\n // a list item is never absent, and a null item is never turned into undefined\n const acceptsUndefined = position.item !== true && (parts.hasUndefined || position.optional || parts.unchecked)\n if (position.item === true) {\n if (!acceptsNull) {\n this.#mismatch(\n site,\n `${site.label} does not accept null, but the items of ${site.coordinate} (${site.list ?? String(type)}) may be null`,\n [`Accept null items ((T | null)[]), or make the items non-null in the SDL (${String(type)}!)`],\n )\n }\n } else if (!position.sdlDefault && !acceptsUndefined) {\n this.#mismatch(\n site,\n `${site.label} does not accept undefined, but ${site.coordinate} (${String(type)}) may be omitted`,\n ['Make it optional (?: or | undefined), or make the SDL argument non-null or give it a default value'],\n )\n } else if (!acceptsNull && !acceptsUndefined) {\n this.#mismatch(\n site,\n `${site.label} does not accept null, but ${site.coordinate} (${String(type)}) may be null`,\n [`Accept null (| null) or undefined, or make it non-null in the SDL (${String(type)}!)`],\n )\n }\n if (position.vote !== undefined && !parts.unchecked) {\n let vote = this.#votes.get(position.vote)\n if (vote === undefined) {\n vote = { accepts: 0, rejects: [] }\n this.#votes.set(position.vote, vote)\n }\n if (acceptsNull) vote.accepts++\n else if (acceptsUndefined) vote.rejects.push(site)\n }\n }\n if (parts.unchecked) return\n if (parts.members.length === 0) {\n this.#mismatch(site, `${site.label} accepts no ${String(inner)} value (${site.coordinate})`, [\n `Type it with the TypeScript type of ${String(inner)}`,\n ])\n return\n }\n if (isListType(inner)) {\n const lists = parts.members.map(member => this.#listItem(member, 'input')).filter(item => item !== undefined)\n if (lists.length === 0) {\n this.#mismatch(\n site,\n `${site.label} is ${this.#describeParts(parts, false)}, not an array, but ${site.coordinate} is ${String(type)}`,\n ['Accept an array (readonly T[]): graphql-js always passes lists as arrays'],\n )\n return\n }\n for (const items of lists) {\n for (const item of items) {\n this.#input(\n inner.ofType,\n item,\n { optional: false, sdlDefault: true, item: true },\n { ...site, label: `${site.label} (items)`, list: site.list ?? String(type) },\n depth + 1,\n )\n }\n }\n return\n }\n if (isScalarType(inner)) {\n if (parts.members.some(member => this.#scalarAccepts(inner.name, member, 'input'))) return\n this.#mismatch(\n site,\n `${site.label} is ${this.#describeParts(parts, false)}, which does not accept every ${inner.name} (${site.coordinate})`,\n [this.#scalarHint(inner.name)],\n )\n return\n }\n if (isEnumType(inner)) {\n const accepted = new Set<string>()\n for (const member of parts.members) {\n if (member.kind === 'string') return\n for (const literal of this.#literals(member) ?? []) accepted.add(String(literal))\n }\n const missing = inner.getValues().filter(value => !accepted.has(value.name))\n if (missing.length > 0) {\n this.#mismatch(\n site,\n `${site.label} is ${this.#describeParts(parts, false)}, which does not accept ${missing.map(value => value.name).join(', ')} of the enum ${inner.name} (${site.coordinate})`,\n [`Accept every value of ${inner.name} (graphql-codegen's enum type, or a union of every value)`],\n )\n }\n return\n }\n const objects = parts.members.filter(member => this.#propertiesOf(member) !== undefined)\n if (objects.length === 0) {\n this.#mismatch(\n site,\n `${site.label} is ${this.#describeParts(parts, false)}, not an object type, but ${site.coordinate} is ${inner.name}`,\n [`Type it with the TypeScript type of the input ${inner.name}`],\n )\n return\n }\n for (const object of objects) this.#inputObject(inner as GraphQLInputObjectType, object, site, depth)\n }\n\n /** An input object received as `shape`: each property is a field of the input, accepting its values. */\n #inputObject(type: GraphQLInputObjectType, shape: Shape, site: Site, depth: number): void {\n const properties = this.#propertiesOf(shape)\n if (properties === undefined || properties === 'record') return\n if (!this.#visit(`input\\0${type.name}`, shape)) return\n const fields = type.getFields()\n for (const property of properties) {\n if (property.name === '__typename') continue\n const field = fields[property.name]\n const propertySite: Site = {\n label:\n this.#tsName(shape) === undefined ? `property '${property.name}'` : `${this.#tsName(shape)}.${property.name}`,\n origin: site.origin,\n coordinate: `${type.name}.${property.name}`,\n locate: () => annotationLocation(this.#ctx.project, property.location) ?? site.locate(),\n sdl: this.#config.locate(field?.astNode ?? type.astNode),\n optional: false,\n }\n if (field === undefined) {\n this.#mismatch(\n { ...propertySite, locate: () => property.location ?? site.locate() },\n `${propertySite.label} is not a field of the input ${type.name}: it is always undefined`,\n [`Remove it, or declare it in the SDL (input ${type.name} { ${property.name}: ... })`],\n )\n continue\n }\n this.#input(\n field.type,\n property.shape,\n { optional: property.optional, sdlDefault: field.default !== undefined, vote: propertySite.coordinate },\n propertySite,\n depth + 1,\n )\n }\n }\n\n // ------------------------------------------------------------------------------------- scalars\n\n /** A member (not nullish, not a union) conforms to a scalar: output, or accepts every value: input. */\n #scalarAccepts(name: string, shape: Shape, position: 'input' | 'output'): boolean {\n const custom = this.#config.scalars.get(name)\n if (custom !== undefined) return this.#hasReference(shape, custom.type)\n // the type of another scalar<T>() declaration (a branded id for an ID or a String): its\n // representation is not known, string-like scalars only\n if ((name === 'String' || name === 'ID') && shape.kind === 'reference' && this.#scalarTypes.has(shape.identity)) {\n return true\n }\n const output = position === 'output'\n switch (name) {\n case 'String':\n return this.#isString(shape, output)\n case 'ID':\n return this.#isString(shape, output) || (output && this.#isNumber(shape, true))\n case 'Int':\n case 'Float':\n return this.#isNumber(shape, output)\n case 'Boolean':\n return shape.kind === 'boolean' || (output && shape.kind === 'literal' && typeof shape.value === 'boolean')\n case 'DateTime':\n return shape.kind === 'date'\n case 'BigInt':\n return shape.kind === 'bigint' || (output && this.#isNumber(shape, true))\n default:\n // JSON and the built-in scalars without TypeScript counterpart\n return true\n }\n }\n\n #scalarHint(name: string): string {\n const custom = this.#config.scalars.get(name)\n if (custom !== undefined) {\n return `${name} is declared with scalar<${custom.type.slice(custom.type.indexOf('#') + 1)}>(): use that type (graphql-codegen: scalars: { ${name}: '...' })`\n }\n switch (name) {\n case 'Int':\n case 'Float':\n return 'Use number (or the Int / Float aliases of @znight/graphql)'\n case 'Boolean':\n return 'Use boolean'\n case 'DateTime':\n return 'The built-in DateTime scalar is a Date'\n case 'BigInt':\n return 'The built-in BigInt scalar is a bigint'\n default:\n return 'Use string (string literals, string enums and branded strings conform in output positions)'\n }\n }\n\n /** `string`, a branded string, the `ID` alias; output: also string literals and string enums. */\n #isString(shape: Shape, output: boolean): boolean {\n switch (shape.kind) {\n case 'string':\n return true\n case 'literal':\n return output && typeof shape.value === 'string'\n case 'reference':\n return shape.identity === GraphQLIds.ID\n case 'intersection':\n return shape.members.some(\n member => member.kind === 'string' || (member.kind === 'reference' && member.identity === GraphQLIds.ID),\n )\n case 'named': {\n const named = this.#named.get(shape.key)\n return (\n output &&\n named?.declaration === 'enum' &&\n (this.#literals(shape) ?? []).every(value => typeof value === 'string')\n )\n }\n default:\n return false\n }\n }\n\n /** `number`, a branded number, the `Int` / `Float` aliases; output: also number literals and numeric enums. */\n #isNumber(shape: Shape, output: boolean): boolean {\n const alias = (candidate: Shape): boolean =>\n candidate.kind === 'reference' &&\n (candidate.identity === GraphQLIds.Int || candidate.identity === GraphQLIds.Float)\n switch (shape.kind) {\n case 'number':\n return true\n case 'literal':\n return output && typeof shape.value === 'number'\n case 'reference':\n return alias(shape)\n case 'intersection':\n return shape.members.some(member => member.kind === 'number' || alias(member))\n case 'named': {\n const named = this.#named.get(shape.key)\n return (\n output &&\n named?.declaration === 'enum' &&\n (this.#literals(shape) ?? []).every(value => typeof value === 'number')\n )\n }\n default:\n return false\n }\n }\n\n #hasReference(shape: Shape, identity: string): boolean {\n if (shape.kind === 'reference') return shape.identity === identity\n if (shape.kind === 'intersection') return shape.members.some(member => this.#hasReference(member, identity))\n return false\n }\n\n // -------------------------------------------------------------------------------------- shapes\n\n #shape(target: { readonly parameter: ParameterInfo } | { readonly returnOf: MethodInfo }): ShapeResult {\n const result = this.#ctx.types.shape(target, this.#options)\n for (const named of result.named.values()) this.#named.set(named.key, named)\n return result\n }\n\n /** The non-nullish members of a shape, through unions and aliases (object aliases stay named). */\n #parts(shape: Shape): Parts {\n const parts: Parts = { members: [], hasNull: false, hasUndefined: false, unchecked: false }\n const visit = (current: Shape, depth: number): void => {\n if (depth > MAX_DEPTH) return\n switch (current.kind) {\n case 'null':\n parts.hasNull = true\n return\n case 'undefined':\n parts.hasUndefined = true\n return\n case 'unknown':\n case 'opaque':\n case 'schema':\n parts.unchecked = true\n return\n case 'never':\n return\n case 'union':\n for (const member of current.members) visit(member, depth + 1)\n return\n case 'named': {\n const named = this.#named.get(current.key)\n if (named === undefined) {\n parts.unchecked = true\n return\n }\n const target = named.shape\n const isObject =\n target.kind === 'object' ||\n (target.kind === 'intersection' && this.#propertiesOf(target) !== undefined) ||\n (target.kind === 'named' && this.#named.get(target.key)?.declaration !== 'alias')\n if (named.declaration !== 'alias' || isObject) parts.members.push(current)\n else visit(target, depth + 1)\n return\n }\n default:\n parts.members.push(current)\n }\n }\n visit(shape, 0)\n return parts\n }\n\n /** The item shapes of a list member (array, tuple, iterable); `undefined`: not a list. */\n #listItem(shape: Shape, position: 'input' | 'output'): readonly Shape[] | undefined {\n if (shape.kind === 'array') return [shape.items]\n if (shape.kind === 'tuple')\n return position === 'output' ? [...shape.items, ...(shape.rest === undefined ? [] : [shape.rest])] : undefined\n if (shape.kind === 'reference' && position === 'output' && OUTPUT_ITERABLES.has(shape.identity)) {\n return [shape.typeArgs[0] ?? { kind: 'unknown' }]\n }\n return undefined\n }\n\n /** The literal values of a member: a literal, an enum; `undefined`: not literals. */\n #literals(shape: Shape): readonly (string | number | boolean)[] | undefined {\n if (shape.kind === 'literal') return [shape.value]\n if (shape.kind !== 'named') return undefined\n const named = this.#named.get(shape.key)\n if (named?.declaration !== 'enum') return undefined\n if (named.enumMembers !== undefined) return named.enumMembers.map(member => member.value)\n const target = named.shape\n if (target.kind === 'literal') return [target.value]\n if (target.kind === 'union' && target.members.every(member => member.kind === 'literal')) {\n return target.members.map(member => (member as { value: string | number | boolean }).value)\n }\n return undefined\n }\n\n /** The properties of an object structure (intersections merged, later members win), `'record'` for index signatures. */\n #propertiesOf(shape: Shape, depth = 0): readonly ShapeProperty[] | 'record' | undefined {\n if (depth > MAX_DEPTH) return undefined\n switch (shape.kind) {\n case 'object':\n return shape.additional === undefined ? shape.properties : 'record'\n case 'named': {\n const named = this.#named.get(shape.key)\n return named === undefined || named.declaration === 'enum'\n ? undefined\n : this.#propertiesOf(named.shape, depth + 1)\n }\n case 'intersection': {\n const merged = new Map<string, ShapeProperty>()\n for (const member of shape.members) {\n const properties = this.#propertiesOf(member, depth + 1)\n if (properties === undefined || properties === 'record') return properties\n for (const property of properties) {\n merged.delete(property.name)\n merged.set(property.name, property)\n }\n }\n return [...merged.values()]\n }\n default:\n return undefined\n }\n }\n\n /** `true` the first time `(namespace, shape)` is visited: named shapes by key, anonymous ones by identity. */\n #visit(namespace: string, shape: Shape): boolean {\n if (shape.kind === 'named') {\n const key = `${namespace}\\0${shape.key}`\n if (this.#visited.has(key)) return false\n this.#visited.add(key)\n return true\n }\n let seen = this.#anonymous.get(shape)\n if (seen === undefined) {\n seen = new Set()\n this.#anonymous.set(shape, seen)\n }\n if (seen.has(namespace)) return false\n seen.add(namespace)\n return true\n }\n\n #propertySite(\n site: Site,\n type: GraphQLObjectType | GraphQLAbstractType,\n field: GraphQLField<unknown, unknown>,\n property: ShapeProperty,\n owner: Shape,\n ): Site {\n const name = this.#tsName(owner)\n return {\n label: `${name === undefined ? `property '${property.name}'` : `${name}.${property.name}`} is`,\n origin: `type of ${name === undefined ? `property '${property.name}'` : `${name}.${property.name}`}, ${site.origin}`,\n coordinate: `${type.name}.${field.name}`,\n locate: () => annotationLocation(this.#ctx.project, property.location) ?? site.locate(),\n sdl: this.#config.locate(field.astNode),\n optional: property.optional,\n }\n }\n\n #tsName(shape: Shape): string | undefined {\n return shape.kind === 'named' ? this.#named.get(shape.key)?.name : undefined\n }\n\n // ---------------------------------------------------------------------------------- discriminators\n\n /**\n * `instanceof` when every TypeScript member returned for an abstract type is an exported class\n * (one per member), else `__typename`; members that are neither are ZNIGHT064.\n */\n #discriminators(): ReadonlyMap<string, DiscriminatorModel> {\n const result = new Map<string, DiscriminatorModel>()\n for (const [name, byMember] of [...this.#members].sort(([a], [b]) => compareStrings(a, b))) {\n // every exported class returned for a member: instanceof first, __typename as the fallback\n const classes: { identity: string; name: string; depth: number }[] = []\n for (const [member, identities] of byMember) {\n for (const identity of identities) {\n if (identity !== '') classes.push({ identity, name: member, depth: this.#classDepth(identity) })\n }\n }\n if (classes.length > 0) {\n // subclasses first: `instanceof` matches the most derived class\n classes.sort(\n (a, b) => b.depth - a.depth || compareStrings(a.name, b.name) || compareStrings(a.identity, b.identity),\n )\n result.set(name, {\n by: 'class',\n classes: classes.map(({ identity, name: member }) => ({ identity, name: member })),\n })\n }\n for (const entry of this.#untellable.get(name) ?? []) {\n const location = entry.site.locate()\n this.#reportOnce(`untellable\\0${name}\\0${entry.name}`, {\n code: Codes.UnresolvableAbstractType,\n severity: 'error',\n message: `${entry.name} cannot be told apart among the members of ${name} at runtime: it declares no __typename and is not an exported class`,\n ...(location === undefined ? {} : { location }),\n hints: [\n `Return objects carrying __typename (declare __typename: '${entry.name}' in the TypeScript type; graphql-codegen declares it), or return exported class instances`,\n ],\n ...(entry.location === undefined\n ? {}\n : { related: [{ message: `${entry.name} is declared here`, location: entry.location }] }),\n })\n }\n }\n return result\n }\n\n #classDepth(identity: string): number {\n let depth = 0\n let current = this.#ctx.classInfo(identity)?.superClass?.identity\n const seen = new Set<string>()\n while (current !== undefined && !seen.has(current) && depth < MAX_DEPTH) {\n seen.add(current)\n depth++\n current = this.#ctx.classInfo(current)?.superClass?.identity\n }\n return depth\n }\n\n // ------------------------------------------------------------------------------------ reporting\n\n #report(diagnostic: Diagnostic): void {\n this.#config.report(diagnostic)\n }\n\n #reportOnce(key: string, diagnostic: Diagnostic): void {\n if (this.#reported.has(key)) return\n this.#reported.add(key)\n this.#report(diagnostic)\n }\n\n #mismatch(site: Site, message: string, hints: readonly string[]): void {\n const location = site.locate()\n const key = `${location?.file}:${location?.start}\\0${message}`\n this.#reportOnce(key, {\n code: Codes.SchemaMismatch,\n severity: 'error',\n message,\n ...(location === undefined ? {} : { location }),\n ...(hints.length === 0 ? {} : { hints }),\n ...(site.sdl === undefined\n ? {}\n : { related: [{ message: `${site.coordinate} is declared here`, location: site.sdl }] }),\n })\n }\n\n // ----------------------------------------------------------------------------------- messages\n\n #describeParts(parts: Parts, optional: boolean): string {\n const members = parts.members.map(member => this.#describe(member))\n if (parts.hasNull) members.push('null')\n if (parts.hasUndefined || optional) members.push('undefined')\n return members.join(' | ')\n }\n\n /** Short description of a shape for messages (`string`, `Book`, `'a'`, `Book[]`). */\n #describe(shape: Shape): string {\n switch (shape.kind) {\n case 'literal':\n return JSON.stringify(shape.value)\n case 'named':\n return this.#named.get(shape.key)?.name ?? shape.key.slice(shape.key.indexOf('#') + 1)\n case 'reference':\n return shape.name\n case 'opaque':\n return shape.text\n case 'array':\n return `${this.#describe(shape.items)}[]`\n case 'union':\n case 'intersection':\n return shape.members.map(member => this.#describe(member)).join(shape.kind === 'union' ? ' | ' : ' & ')\n case 'object':\n return 'an object literal type'\n case 'tuple':\n return 'a tuple'\n default:\n return shape.kind\n }\n }\n}\n","/**\n * \"Did you mean\" suggestions of the schema-first diagnostics (RFC 0007 §5.3). Import-free.\n */\n\n/**\n * The candidate closest to `name` (Levenshtein distance, case differences counting half), when it\n * is close enough to be a typo: at most a third of the name's length, at least 1. Ties keep the\n * first candidate, so callers pass them sorted.\n */\nexport function closest(name: string, candidates: readonly string[]): string | undefined {\n const limit = Math.max(1, Math.floor(name.length / 3))\n let best: string | undefined\n let bestDistance = Number.POSITIVE_INFINITY\n for (const candidate of candidates) {\n if (candidate === name) continue\n const distance = candidate.toLowerCase() === name.toLowerCase() ? 0.5 : levenshtein(name, candidate)\n if (distance <= limit && distance < bestDistance) {\n best = candidate\n bestDistance = distance\n }\n }\n return best\n}\n\nfunction levenshtein(a: string, b: string): number {\n if (Math.abs(a.length - b.length) > Math.max(a.length, b.length) / 2) return Number.POSITIVE_INFINITY\n let previous = Array.from({ length: b.length + 1 }, (_, index) => index)\n for (let i = 1; i <= a.length; i++) {\n const current = [i]\n for (let j = 1; j <= b.length; j++) {\n const cost = a.charCodeAt(i - 1) === b.charCodeAt(j - 1) ? 0 : 1\n current.push(\n Math.min((previous[j] as number) + 1, (current[j - 1] as number) + 1, (previous[j - 1] as number) + cost),\n )\n }\n previous = current\n }\n return previous[b.length] as number\n}\n","/**\n * The SDL of a schema-first application (RFC 0007 §5.1): the `.graphql` files matching the\n * `schema` globs, parsed with `graphql/language`, checked structurally (duplicates, unknown types\n * and directives, extensions of missing types: located diagnostics with suggestions), then built\n * with `buildASTSchema` and validated with `validateSchema`, so that the build and the runtime agree\n * on what a valid schema is. Every problem is a ZNIGHT067 located in the `.graphql` file.\n */\nimport type { Diagnostic, Location, ValidateContext } from '@znight/compiler'\nimport type {\n ASTNode,\n DefinitionNode,\n DirectiveNode,\n DocumentNode,\n FieldDefinitionNode,\n GraphQLSchema,\n InputValueDefinitionNode,\n NamedTypeNode,\n NameNode,\n TypeNode,\n} from 'graphql'\nimport type { GraphQLData } from './data.ts'\n\nimport { Codes, compareStrings } from './constants.ts'\nimport { graphqlModules } from './graphql-js.ts'\nimport { closest } from './suggest.ts'\n\n/** Directives graphql-js knows (specified, or `@defer`/`@stream` of graphql 17). */\nconst KNOWN_DIRECTIVES: ReadonlySet<string> = new Set([\n 'deprecated',\n 'specifiedBy',\n 'oneOf',\n 'include',\n 'skip',\n 'defer',\n 'stream',\n])\n\n/** A directive as the SDL checks see it: where it applies, its arguments, repeatable or not. */\ninterface DirectiveSpec {\n readonly locations: ReadonlySet<string>\n /** Argument name → required (non-null without default). */\n readonly args: ReadonlyMap<string, boolean>\n readonly repeatable: boolean\n}\n\n/** The built-in directives allowed in an SDL (the others are executable directives). */\nconst SDL_DIRECTIVES: ReadonlyMap<string, DirectiveSpec> = new Map([\n [\n 'deprecated',\n {\n locations: new Set(['FIELD_DEFINITION', 'ARGUMENT_DEFINITION', 'INPUT_FIELD_DEFINITION', 'ENUM_VALUE']),\n args: new Map([['reason', false]]),\n repeatable: false,\n },\n ],\n ['specifiedBy', { locations: new Set(['SCALAR']), args: new Map([['url', true]]), repeatable: false }],\n ['oneOf', { locations: new Set(['INPUT_OBJECT']), args: new Map(), repeatable: false }],\n])\n\n/** The directive location of each kind of type definition and extension. */\nconst TYPE_LOCATIONS: Readonly<Record<string, string>> = {\n type: 'OBJECT',\n interface: 'INTERFACE',\n union: 'UNION',\n enum: 'ENUM',\n input: 'INPUT_OBJECT',\n scalar: 'SCALAR',\n}\n\n/** Names of the types graphql-js always provides. */\nconst PROVIDED_TYPES: ReadonlySet<string> = new Set(['String', 'Int', 'Float', 'Boolean', 'ID'])\n\n/** The parsed and validated SDL. */\nexport interface SdlSource {\n readonly schema: GraphQLSchema\n /** Names of the custom directives (left out of the served schema). */\n readonly customDirectives: ReadonlySet<string>\n /** The location of an AST node (its name when it has one); `undefined` for nodes without location. */\n locate(node: ASTNode | null | undefined): Location | undefined\n}\n\n/** Directive locations in messages. */\nconst LOCATION_NAMES: Readonly<Record<string, string>> = {\n SCHEMA: 'the schema',\n SCALAR: 'scalars',\n OBJECT: 'object types',\n FIELD_DEFINITION: 'fields',\n ARGUMENT_DEFINITION: 'arguments',\n INTERFACE: 'interfaces',\n UNION: 'unions',\n ENUM: 'enums',\n ENUM_VALUE: 'enum values',\n INPUT_OBJECT: 'input objects',\n INPUT_FIELD_DEFINITION: 'input fields',\n}\n\nconst TYPE_KINDS: Readonly<Record<string, string>> = {\n ObjectTypeDefinition: 'type',\n ObjectTypeExtension: 'type',\n InterfaceTypeDefinition: 'interface',\n InterfaceTypeExtension: 'interface',\n UnionTypeDefinition: 'union',\n UnionTypeExtension: 'union',\n EnumTypeDefinition: 'enum',\n EnumTypeExtension: 'enum',\n InputObjectTypeDefinition: 'input',\n InputObjectTypeExtension: 'input',\n ScalarTypeDefinition: 'scalar',\n ScalarTypeExtension: 'scalar',\n}\n\n/** A type definition or extension. */\ntype TypeNodeLike = Extract<DefinitionNode, { readonly name: NameNode }> & { readonly kind: string }\n\n/**\n * Reads, parses and validates the SDL; `undefined` after an error (reported). Warnings (custom\n * directives) do not stop the build.\n */\nexport function loadSdl(\n ctx: ValidateContext<GraphQLData>,\n patterns: readonly string[],\n report: (diagnostic: Diagnostic) => void,\n): SdlSource | undefined {\n const files = ctx.inputFiles(patterns)\n if (files.length === 0) {\n report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message: `No GraphQL schema file matches ${patterns.map(pattern => `'${pattern}'`).join(', ')} (schema-first)`,\n hints: [\n \"The globs of graphql.configure({ schema }) are relative to the project root: 'src/**/*.graphql'\",\n 'Remove the schema option to derive the schema from the TypeScript types (code-first)',\n ],\n })\n return undefined\n }\n const { language, type, utilities } = graphqlModules()\n const locator = new Locator(new Map(files.map(file => [file.file, file.text])))\n let errors = 0\n const fail = (\n message: string,\n node: ASTNode | null | undefined,\n hints: readonly string[] = [],\n related?: ASTNode,\n ) => {\n errors++\n const location = locator.locate(node)\n const other = related === undefined ? undefined : locator.locate(related)\n report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message,\n ...(location === undefined ? {} : { location }),\n ...(hints.length === 0 ? {} : { hints }),\n ...(other === undefined ? {} : { related: [{ message: 'first declared here', location: other }] }),\n })\n }\n\n const documents: DocumentNode[] = []\n for (const file of files) {\n // a file with comments only (a placeholder) defines nothing: graphql-js would reject it\n if (/^(?:\\s|,|#[^\\n\\r]*)*$/.test(file.text.replace(/^\\uFEFF/, ''))) continue\n try {\n documents.push(language.parse(new language.Source(file.text, file.file)))\n } catch (error) {\n const position = (error as { positions?: readonly number[] }).positions?.[0]\n errors++\n const location = position === undefined ? undefined : locator.at(file.file, position, position + 1)\n report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message: `${(error as Error).message} (${file.relativeFile})`,\n ...(location === undefined ? {} : { location }),\n })\n }\n }\n if (errors > 0) return undefined\n if (documents.length === 0) {\n report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message: `The GraphQL schema files matching ${patterns.map(pattern => `'${pattern}'`).join(', ')} define nothing (schema-first)`,\n hints: ['Declare the types of the schema, starting with type Query { ... }'],\n })\n return undefined\n }\n const document = utilities.concatAST(documents)\n const customDirectives = checkStructure(document, fail, (message, node) => {\n const location = locator.locate(node)\n report({\n code: Codes.InvalidSdl,\n severity: 'warning',\n message,\n ...(location === undefined ? {} : { location }),\n hints: [\n 'Znight serves the schema without custom directives (and so does the SDL artifact): remove it, or keep it for other tools',\n ],\n })\n })\n if (errors > 0) return undefined\n\n let schema: GraphQLSchema\n try {\n schema = utilities.buildASTSchema(document, { assumeValidSDL: true })\n } catch (error) {\n fail(`Invalid schema: ${(error as Error).message}`, (error as { nodes?: readonly ASTNode[] }).nodes?.[0])\n return undefined\n }\n for (const problem of type.validateSchema(schema)) {\n const [node, ...others] = (problem.nodes ?? []).filter(candidate => candidate.loc !== undefined)\n errors++\n const location = locator.locate(node)\n const related = others.flatMap(other => {\n const at = locator.locate(other)\n return at === undefined ? [] : [{ message: 'see also', location: at }]\n })\n report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message: `Invalid schema: ${problem.message}`,\n ...(location === undefined ? {} : { location }),\n ...(related.length === 0 ? {} : { related }),\n // the one schema-wide error without node: no query type\n ...(node === undefined && schema.getQueryType() == null\n ? { hints: ['Declare the query root type in one of the files: type Query { ... }'] }\n : {}),\n })\n }\n if (errors > 0) return undefined\n return { schema, customDirectives, locate: node => locator.locate(node) }\n}\n\n/**\n * The checks graphql-js leaves to its SDL validation (not exported): unique type, field, value and\n * argument names, known types and directives, extensions of existing types of the same kind, one\n * schema definition. Returns the names of the custom directives (each reported as a warning).\n */\nfunction checkStructure(\n document: DocumentNode,\n fail: (message: string, node: ASTNode, hints?: readonly string[], related?: ASTNode) => void,\n warn: (message: string, node: ASTNode) => void,\n): ReadonlySet<string> {\n const definitions = new Map<string, TypeNodeLike>()\n const directives = new Map<string, ASTNode>()\n const specs = new Map<string, DirectiveSpec>(SDL_DIRECTIVES)\n let schemaDefinition: ASTNode | undefined\n for (const definition of document.definitions) {\n if (definition.kind === 'SchemaDefinition') {\n if (schemaDefinition === undefined) schemaDefinition = definition\n else\n fail(\n 'The schema is defined twice (schema { ... })',\n definition,\n ['Keep one schema definition'],\n schemaDefinition,\n )\n continue\n }\n if (definition.kind === 'DirectiveDefinition') {\n const name = definition.name.value\n const previous = directives.get(name)\n if (previous !== undefined) fail(`The directive @${name} is defined twice`, definition.name, [], previous)\n else if (KNOWN_DIRECTIVES.has(name))\n fail(`@${name} is a built-in directive: it cannot be redefined`, definition.name)\n else {\n directives.set(name, definition.name)\n specs.set(name, {\n locations: new Set(definition.locations.map(location => location.value)),\n args: new Map(\n (definition.arguments ?? []).map(arg => [\n arg.name.value,\n arg.type.kind === 'NonNullType' && arg.defaultValue === undefined,\n ]),\n ),\n repeatable: definition.repeatable,\n })\n warn(`The custom directive @${name} is ignored`, definition.name)\n }\n continue\n }\n const kind = TYPE_KINDS[definition.kind]\n if (kind === undefined || definition.kind.endsWith('Extension')) continue\n const node = definition as TypeNodeLike\n const previous = definitions.get(node.name.value)\n if (previous !== undefined) {\n fail(\n `The type ${node.name.value} is defined twice`,\n node.name,\n [\n kind === 'scalar'\n ? 'Keep one of them, or rename one'\n : `Extend it instead (${declaration(`extend ${kind}`, kind, node.name.value)}), or rename one of them`,\n ],\n previous.name,\n )\n continue\n }\n definitions.set(node.name.value, node)\n }\n const typeNames = [...definitions.keys(), ...PROVIDED_TYPES].sort(compareStrings)\n const known = (name: NamedTypeNode, where: string): void => {\n const value = name.name.value\n if (definitions.has(value) || PROVIDED_TYPES.has(value)) return\n const suggestion = closest(value, typeNames)\n fail(\n `Unknown type ${value} (${where})`,\n name,\n suggestion === undefined ? ['Define it, or fix the name'] : [`Did you mean ${suggestion}?`],\n )\n }\n /** The directives applied at `location`: known, allowed there, once unless repeatable, valid arguments. */\n const directivesOf = (nodes: readonly DirectiveNode[] | undefined, location: string): void => {\n const seen = new Map<string, ASTNode>()\n for (const directive of nodes ?? []) {\n const name = directive.name.value\n const spec = specs.get(name)\n if (spec === undefined) {\n fail(\n KNOWN_DIRECTIVES.has(name)\n ? `@${name} is an executable directive: it cannot be used in a schema`\n : `Unknown directive @${name}`,\n directive.name,\n KNOWN_DIRECTIVES.has(name) ? ['Remove it'] : [`Define it (directive @${name} on ${location}), or remove it`],\n )\n continue\n }\n if (!spec.locations.has(location)) {\n fail(`@${name} cannot be used on ${LOCATION_NAMES[location] ?? location}`, directive.name, [\n `@${name} applies to ${[...spec.locations].map(where => LOCATION_NAMES[where] ?? where).join(', ')}`,\n ])\n }\n const previous = seen.get(name)\n if (previous !== undefined && !spec.repeatable) {\n fail(`@${name} is applied twice`, directive.name, ['Apply it once'], previous)\n }\n seen.set(name, directive.name)\n const given = new Set<string>()\n for (const arg of directive.arguments ?? []) {\n given.add(arg.name.value)\n if (!spec.args.has(arg.name.value)) {\n const names = [...spec.args.keys()]\n fail(`@${name} has no argument '${arg.name.value}'`, arg.name, [\n names.length === 0 ? `@${name} takes no argument` : `Its arguments: ${names.join(', ')}`,\n ])\n }\n }\n for (const [arg, required] of spec.args) {\n if (required && !given.has(arg))\n fail(`@${name} needs its argument '${arg}'`, directive.name, [`@${name}(${arg}: ...)`])\n }\n }\n }\n /** Members of a type: its definition and extensions, by name (fields, values, input fields). */\n const members = new Map<string, Map<string, ASTNode>>()\n const member = (typeName: string, kind: string, name: NameNode): void => {\n let seen = members.get(typeName)\n if (seen === undefined) {\n seen = new Map()\n members.set(typeName, seen)\n }\n const previous = seen.get(name.value)\n if (previous !== undefined) {\n fail(`${typeName}.${name.value} is declared twice`, name, [`Keep one ${kind} named ${name.value}`], previous)\n return\n }\n seen.set(name.value, name)\n }\n const inputValues = (owner: string, values: readonly InputValueDefinitionNode[] | undefined): void => {\n const seen = new Map<string, ASTNode>()\n for (const value of values ?? []) {\n const previous = seen.get(value.name.value)\n if (previous !== undefined) {\n fail(`Argument ${owner}(${value.name.value}:) is declared twice`, value.name, [], previous)\n }\n seen.set(value.name.value, value.name)\n known(namedType(value.type), `${owner}(${value.name.value}:)`)\n directivesOf(value.directives, 'ARGUMENT_DEFINITION')\n }\n }\n const fields = (owner: string, list: readonly FieldDefinitionNode[] | undefined): void => {\n for (const field of list ?? []) {\n member(owner, 'field', field.name)\n known(namedType(field.type), `${owner}.${field.name.value}`)\n inputValues(`${owner}.${field.name.value}`, field.arguments)\n directivesOf(field.directives, 'FIELD_DEFINITION')\n }\n }\n const operations = new Map<string, ASTNode>()\n for (const definition of document.definitions) {\n if (definition.kind === 'SchemaDefinition' || definition.kind === 'SchemaExtension') {\n for (const operation of definition.operationTypes ?? []) {\n known(operation.type, `schema ${operation.operation}`)\n const previous = operations.get(operation.operation)\n if (previous !== undefined) {\n fail(`The ${operation.operation} root type is declared twice`, operation, ['Keep one'], previous)\n }\n operations.set(operation.operation, operation)\n }\n directivesOf(definition.directives, 'SCHEMA')\n continue\n }\n if (definition.kind === 'DirectiveDefinition') {\n inputValues(`@${definition.name.value}`, definition.arguments)\n continue\n }\n const kind = TYPE_KINDS[definition.kind]\n if (kind === undefined) continue\n const node = definition as TypeNodeLike & {\n readonly fields?: readonly (FieldDefinitionNode | InputValueDefinitionNode)[]\n readonly interfaces?: readonly NamedTypeNode[]\n readonly types?: readonly NamedTypeNode[]\n readonly values?: readonly { readonly name: NameNode; readonly directives?: readonly DirectiveNode[] }[]\n readonly directives?: readonly DirectiveNode[]\n }\n const name = node.name.value\n if (definition.kind.endsWith('Extension')) {\n const base = definitions.get(name)\n if (base === undefined) {\n if (!PROVIDED_TYPES.has(name)) {\n const suggestion = closest(name, typeNames)\n fail(`Cannot extend ${kind} ${name}: it is not defined`, node.name, [\n suggestion === undefined ? `Define it: ${declaration(kind, kind, name)}` : `Did you mean ${suggestion}?`,\n ])\n }\n continue\n }\n if (TYPE_KINDS[base.kind] !== kind) {\n const actual = TYPE_KINDS[base.kind] as string\n fail(\n `Cannot extend ${name} as ${article(kind)} ${kind}: it is ${article(actual)} ${actual}`,\n node.name,\n [`Use ${declaration(`extend ${actual}`, actual, name)}`],\n base.name,\n )\n continue\n }\n }\n directivesOf(node.directives, TYPE_LOCATIONS[kind] as string)\n for (const implemented of node.interfaces ?? []) known(implemented, `${name} implements`)\n for (const target of node.types ?? []) known(target, `union ${name}`)\n for (const value of node.values ?? []) {\n member(name, 'value', value.name)\n directivesOf(value.directives, 'ENUM_VALUE')\n }\n if (kind === 'input') {\n for (const field of (node.fields ?? []) as readonly InputValueDefinitionNode[]) {\n member(name, 'field', field.name)\n known(namedType(field.type), `${name}.${field.name.value}`)\n directivesOf(field.directives, 'INPUT_FIELD_DEFINITION')\n }\n } else {\n fields(name, node.fields as readonly FieldDefinitionNode[] | undefined)\n }\n }\n return new Set(directives.keys())\n}\n\n/** `extend type Book { ... }`, `union Hit = ...`, `scalar Url`: valid SDL for a hint. */\nfunction declaration(keyword: string, kind: string, name: string): string {\n if (kind === 'scalar') return `${keyword} ${name}`\n if (kind === 'union') return `${keyword} ${name} = ...`\n return `${keyword} ${name} { ... }`\n}\n\nfunction article(word: string): string {\n return /^[aeiou]/.test(word) ? 'an' : 'a'\n}\n\nfunction namedType(type: TypeNode): NamedTypeNode {\n let current = type\n while (current.kind !== 'NamedType') current = current.type\n return current\n}\n\n/** Source locations of AST nodes (graphql-js `Source.name` is the absolute path of the file). */\nclass Locator {\n readonly #texts: ReadonlyMap<string, string>\n readonly #lines = new Map<string, number[]>()\n\n constructor(texts: ReadonlyMap<string, string>) {\n this.#texts = texts\n }\n\n locate(node: ASTNode | null | undefined): Location | undefined {\n if (node === null || node === undefined) return undefined\n const named = 'name' in node && node.name !== undefined && typeof node.name === 'object' ? node.name : node\n const loc = (named as ASTNode).loc ?? node.loc\n if (loc === undefined) return undefined\n return this.at(loc.source.name, loc.start, loc.end)\n }\n\n at(file: string, start: number, end: number): Location | undefined {\n const text = this.#texts.get(file)\n if (text === undefined) return undefined\n const lines = this.#lineStarts(file, text)\n const first = position(lines, start)\n const last = position(lines, Math.min(end, text.length))\n return { file, line: first.line, column: first.column, endLine: last.line, endColumn: last.column, start, end }\n }\n\n #lineStarts(file: string, text: string): number[] {\n let lines = this.#lines.get(file)\n if (lines === undefined) {\n lines = [0]\n for (let index = 0; index < text.length; index++) {\n const code = text.charCodeAt(index)\n if (code === 0x0a) lines.push(index + 1)\n else if (code === 0x0d) {\n if (text.charCodeAt(index + 1) === 0x0a) index++\n lines.push(index + 1)\n }\n }\n this.#lines.set(file, lines)\n }\n return lines\n }\n}\n\n/** 1-based line and column (UTF-16 code units) of an offset. */\nfunction position(lines: readonly number[], offset: number): { line: number; column: number } {\n let low = 0\n let high = lines.length - 1\n while (low < high) {\n const middle = (low + high + 1) >> 1\n if ((lines[middle] as number) <= offset) low = middle\n else high = middle - 1\n }\n return { line: low + 1, column: offset - (lines[low] as number) + 1 }\n}\n","/**\n * The schema-first model (RFC 0007): the SDL is the schema. `validate` loads and validates the\n * `.graphql` files (`sdl-source.ts`), binds every resolver method to its field by name (coverage,\n * §5.3), checks the resolver signatures against the SDL (`conformance.ts`, §5.4) and turns the\n * validated graphql-js schema into the same {@link GraphQLModel} as code-first, so that `generate`,\n * the SDL artifact, `schemaHash` and the runtime are shared.\n */\nimport type { ClassInfo, Diagnostic, Location, MethodInfo, ValidateContext } from '@znight/compiler'\nimport type {\n GraphQLArgument,\n GraphQLEnumType,\n GraphQLField,\n GraphQLInputField,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLNamedType,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLSchema,\n GraphQLUnionType,\n} from 'graphql'\nimport type { Binding } from './conformance.ts'\nimport type { FieldData, GraphQLData, ResolverData } from './data.ts'\nimport type {\n ArgModel,\n FieldModel,\n GraphQLModel,\n InputModel,\n InterfaceModel,\n ObjectModel,\n ScalarModel,\n TypeModel,\n UnionModel,\n} from './model.ts'\nimport type { ScalarDeclaration } from './scalars.ts'\nimport type { SdlSource } from './sdl-source.ts'\n\nimport { BUILTIN_SCALARS, SPECIFIED_SCALARS } from '../names.ts'\nimport { schemaHash } from '../schema-hash.ts'\nimport { printSdl } from '../sdl.ts'\nimport { parseTypeRef } from '../type-ref.ts'\nimport { checkDecisions, checkLoaders } from './checks.ts'\nimport { checkConformance } from './conformance.ts'\nimport { Codes, compareStrings } from './constants.ts'\nimport { graphqlModules } from './graphql-js.ts'\nimport { readScalars } from './scalars.ts'\nimport { loadSdl } from './sdl-source.ts'\nimport { sdlType } from './sdl-view.ts'\nimport { closest } from './suggest.ts'\n\ntype Context = ValidateContext<GraphQLData>\ntype Operation = 'query' | 'mutation' | 'subscription'\n\nconst DECORATORS: Readonly<Record<FieldData['operation'], string>> = {\n query: '@Query',\n mutation: '@Mutation',\n subscription: '@Subscription',\n field: '@ResolveField',\n}\n\n/**\n * Builds the model from the SDL files matching `patterns`; `undefined` after an error. `artifact`:\n * the path of the SDL artifact (option `sdl`), never read back as an input.\n */\nexport function buildSchemaFirstModel(\n ctx: Context,\n patterns: readonly string[],\n artifact: string | false,\n): GraphQLModel | undefined {\n // the artifact is the output: matched by the globs, it would define every type a second time\n return new SchemaFirstBuilder(ctx).build(artifact === false ? patterns : [...patterns, `!${artifact}`])\n}\n\nclass SchemaFirstBuilder {\n readonly #ctx: Context\n #errors = 0\n readonly #methods = new Map<string, MethodInfo | undefined>()\n\n constructor(ctx: Context) {\n this.#ctx = ctx\n }\n\n build(patterns: readonly string[]): GraphQLModel | undefined {\n const report = (diagnostic: Diagnostic): void => this.#report(diagnostic)\n const stored = [...this.#ctx.stored].sort((a, b) => compareStrings(a.host.identity, b.host.identity))\n const resolvers = stored.filter(resolver => resolver.invalid !== true)\n const rejected = stored.filter(resolver => resolver.invalid === true)\n checkLoaders(this.#ctx, resolvers, report)\n const scalarDeclarations = readScalars(this.#ctx, report)\n const sdl = loadSdl(this.#ctx, patterns, report)\n if (sdl === undefined) {\n checkDecisions(this.#ctx, resolvers, report)\n return undefined\n }\n const schema = sdl.schema\n const roots = {\n query: (schema.getQueryType() as GraphQLObjectType).name,\n ...(schema.getMutationType() ? { mutation: (schema.getMutationType() as GraphQLObjectType).name } : {}),\n ...(schema.getSubscriptionType()\n ? { subscription: (schema.getSubscriptionType() as GraphQLObjectType).name }\n : {}),\n }\n checkDecisions(this.#ctx, resolvers, report, roots)\n const types = Object.values(schema.getTypeMap())\n .filter(type => !type.name.startsWith('__') && !SPECIFIED_SCALARS.has(type.name))\n .sort((a, b) => compareStrings(a.name, b.name))\n this.#checkUnsupported(sdl, types)\n const scalars = this.#scalars(sdl, types, scalarDeclarations)\n const { bindings, claimed: bound } = this.#bind(sdl, resolvers, rejected)\n const conformance = checkConformance({\n ctx: this.#ctx,\n schema,\n locate: node => sdl.locate(node),\n scalars: new Map([...scalarDeclarations.values()].map(declaration => [declaration.name, declaration])),\n bindings,\n bound,\n report,\n })\n if (this.#errors > 0) return undefined\n const byCoordinate = new Map(bindings.map(binding => [`${binding.type.name}.${binding.sdlField.name}`, binding]))\n const models: TypeModel[] = []\n for (const type of types) {\n const model = this.#model(sdl, type, byCoordinate, scalars, conformance)\n if (model !== undefined) models.push(model)\n }\n const meta = resolvers.flatMap(resolver => resolver.fields.flatMap(field => field.meta))\n const printed = printSdl({ roots, types: models.map(sdlType) })\n return { roots, types: models, meta, sdl: printed, schemaHash: schemaHash(printed) }\n }\n\n #report(diagnostic: Diagnostic): void {\n if (diagnostic.severity === 'error') this.#errors++\n this.#ctx.report(diagnostic)\n }\n\n #mismatch(\n location: Location | undefined,\n message: string,\n hints: readonly string[],\n related?: Diagnostic['related'],\n ): void {\n this.#report({\n code: Codes.SchemaMismatch,\n severity: 'error',\n message,\n ...(location === undefined ? {} : { location }),\n ...(hints.length === 0 ? {} : { hints }),\n ...(related === undefined || related.length === 0 ? {} : { related }),\n })\n }\n\n // ------------------------------------------------------------------------------- unsupported\n\n /** `@oneOf` input objects (the runtime does not model them). */\n #checkUnsupported(sdl: SdlSource, types: readonly GraphQLNamedType[]): void {\n const { isInputObjectType } = graphqlModules().type\n for (const type of types) {\n if (!isInputObjectType(type) || !type.isOneOf) continue\n const location = sdl.locate(type.astNode)\n this.#report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message: `@oneOf input objects are not supported yet (${type.name})`,\n ...(location === undefined ? {} : { location }),\n hints: ['Declare one optional field per case and check that exactly one is set in the resolver'],\n })\n }\n }\n\n // ------------------------------------------------------------------------------------- scalars\n\n /** The scalar models: `scalar<T>()` declarations by name, the built-in scalars, else ZNIGHT067. */\n #scalars(\n sdl: SdlSource,\n types: readonly GraphQLNamedType[],\n declarations: ReadonlyMap<string, ScalarDeclaration>,\n ): ReadonlyMap<string, ScalarModel> {\n const { isScalarType } = graphqlModules().type\n const byName = new Map([...declarations.values()].map(declaration => [declaration.name, declaration]))\n const models = new Map<string, ScalarModel>()\n for (const type of types) {\n if (!isScalarType(type)) continue\n const location = sdl.locate(type.astNode)\n const declaration = byName.get(type.name)\n const description = type.description ?? undefined\n const specifiedByURL = type.specifiedByURL ?? undefined\n if (declaration !== undefined) {\n models.set(type.name, {\n kind: 'scalar',\n name: type.name,\n key: `#scalar:${declaration.identity}`,\n description,\n location,\n definition: declaration.identity,\n specifiedByURL,\n fromSdl: true,\n })\n continue\n }\n const builtin = BUILTIN_SCALARS.get(type.name)\n if (builtin !== undefined) {\n if (description !== undefined || (specifiedByURL !== undefined && specifiedByURL !== builtin.specifiedByURL)) {\n this.#report({\n code: Codes.InvalidSdl,\n severity: 'warning',\n message: `scalar ${type.name} is the built-in scalar of @znight/graphql: its description and @specifiedBy in the SDL are ignored`,\n ...(location === undefined ? {} : { location }),\n hints: [\n `Remove them, or implement the scalar yourself: export const ${type.name}Scalar = scalar<T>('${type.name}', { ... })`,\n ],\n })\n }\n models.set(type.name, {\n kind: 'scalar',\n name: type.name,\n key: `#builtin:${type.name}`,\n description: undefined,\n location,\n definition: undefined,\n specifiedByURL: undefined,\n })\n continue\n }\n this.#report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message: `scalar ${type.name} has no implementation: declare it with scalar<T>('${type.name}', ...)`,\n ...(location === undefined ? {} : { location }),\n hints: [\n `export const ${type.name}Scalar = scalar<${type.name}>('${type.name}', { serialize: value => value as ${type.name}, parseValue: value => value as ${type.name} }), with ${type.name} the TypeScript type of its values (the one graphql-codegen maps it to)`,\n ],\n })\n }\n return models\n }\n\n // ------------------------------------------------------------------------------------- binding\n\n /**\n * Binds every resolver method to its SDL field (coverage, RFC 0007 §5.3). `claimed`: the\n * coordinates a resolver method names, bound or not (a method with an analysis error already\n * reported), so that their fields are never also reported as missing a resolver.\n */\n #bind(\n sdl: SdlSource,\n resolvers: readonly ResolverData[],\n rejected: readonly ResolverData[],\n ): { bindings: Binding[]; claimed: Set<string> } {\n const schema = sdl.schema\n const bindings: Binding[] = []\n const claimed = new Set<string>()\n for (const resolver of rejected) {\n for (const field of resolver.fields) {\n const owner = field.operation === 'field' ? resolver.typeName?.name : rootType(schema, field.operation)?.name\n if (owner !== undefined) claimed.add(`${owner}.${field.name}`)\n }\n }\n const byCoordinate = new Map<string, Binding>()\n for (const resolver of resolvers) {\n const target = this.#resolverType(sdl, resolver)\n for (const field of resolver.fields) {\n const owner = field.operation === 'field' ? resolver.typeName?.name : rootType(schema, field.operation)?.name\n if (owner !== undefined) claimed.add(`${owner}.${field.name}`)\n if (!field.complete) continue\n const method = this.#method(resolver, field)\n if (method === undefined) continue\n const where = `${resolver.host.displayName}.${field.method}`\n let type: GraphQLObjectType | undefined\n if (field.operation === 'field') {\n type = target\n if (type === undefined) continue\n } else {\n type = rootType(schema, field.operation)\n if (type === undefined) {\n const name = ROOTS[field.operation]\n this.#mismatch(field.location, `${DECORATORS[field.operation]} ${where}: the schema has no ${name} type`, [\n `Declare it in the SDL: type ${name} { ${field.name}: ... }`,\n ])\n continue\n }\n }\n const sdlField = type.getFields()[field.name]\n if (sdlField === undefined) {\n this.#unknownField(schema, type, field, where)\n continue\n }\n const coordinate = `${type.name}.${field.name}`\n const previous = byCoordinate.get(coordinate)\n if (previous !== undefined) {\n this.#report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `Two resolvers bind ${coordinate}: ${where} and ${previous.resolver.host.displayName}.${previous.field.method}`,\n location: field.location,\n related: [{ message: 'the other resolver', location: previous.field.location }],\n hints: ['Keep one of them'],\n })\n continue\n }\n this.#checkArguments(sdl, field, method, sdlField, coordinate, where)\n const binding: Binding = { resolver, field, method, type, sdlField }\n byCoordinate.set(coordinate, binding)\n bindings.push(binding)\n }\n }\n for (const operation of ['query', 'mutation', 'subscription'] as const) {\n const root = rootType(schema, operation)\n if (root === undefined) continue\n for (const field of Object.values(root.getFields())) {\n if (claimed.has(`${root.name}.${field.name}`)) continue\n this.#mismatch(sdl.locate(field.astNode), `Root field ${root.name}.${field.name} has no resolver`, [\n `Add a method to a @Resolver() class: ${DECORATORS[operation]}() ${field.name}(...) (or ${DECORATORS[operation]}('${field.name}') on another method)`,\n ])\n }\n }\n return { bindings, claimed }\n }\n\n /** The object type of `@Resolver('Type')`, reported when it is not one. */\n #resolverType(sdl: SdlSource, resolver: ResolverData): GraphQLObjectType | undefined {\n const typeName = resolver.typeName\n if (typeName === undefined) return undefined\n const { isObjectType, isInterfaceType } = graphqlModules().type\n const schema = sdl.schema\n const type = schema.getType(typeName.name)\n const owner = resolver.host.displayName\n if (type === undefined) {\n const objects = Object.values(schema.getTypeMap())\n .filter(candidate => isObjectType(candidate) && !candidate.name.startsWith('__'))\n .map(candidate => candidate.name)\n .sort(compareStrings)\n const suggestion = closest(typeName.name, objects)\n this.#mismatch(\n typeName.location,\n `@Resolver('${typeName.name}') of ${owner}: the schema has no type ${typeName.name}`,\n [\n suggestion === undefined\n ? `Declare it in the SDL: type ${typeName.name} { ... }`\n : `Did you mean '${suggestion}'?`,\n ],\n )\n return undefined\n }\n const declared = sdl.locate(type.astNode)\n const related = declared === undefined ? [] : [{ message: `${type.name} is declared here`, location: declared }]\n if (isInterfaceType(type)) {\n const implementations = schema.getPossibleTypes(type).map(object => object.name)\n this.#mismatch(\n typeName.location,\n `@Resolver('${type.name}') of ${owner}: ${type.name} is an interface, field resolvers bind the fields of object types`,\n [\n implementations.length === 0\n ? `Declare an object type implementing ${type.name} and bind the field on it`\n : `Bind the field on each implementation: @Resolver('${implementations[0]}')${implementations.length > 1 ? ` (and ${implementations.slice(1).join(', ')})` : ''}`,\n ],\n related,\n )\n return undefined\n }\n if (!isObjectType(type)) {\n this.#mismatch(\n typeName.location,\n `@Resolver('${type.name}') of ${owner}: ${type.name} is not an object type, it has no field to resolve`,\n ['Name an object type of the SDL (type ... { ... })'],\n related,\n )\n return undefined\n }\n const operation = (['query', 'mutation', 'subscription'] as const).find(\n candidate => rootType(sdl.schema, candidate) === type,\n )\n if (operation !== undefined && resolver.fields.some(field => field.operation === 'field')) {\n this.#mismatch(\n typeName.location,\n `@Resolver('${type.name}') of ${owner}: ${type.name} is the ${operation} root type, its fields are bound with ${DECORATORS[operation]}()`,\n [`Replace @ResolveField() with ${DECORATORS[operation]}() and use @Resolver()`],\n related,\n )\n return undefined\n }\n return type\n }\n\n #unknownField(schema: GraphQLSchema, type: GraphQLObjectType, field: FieldData, where: string): void {\n const hints: string[] = []\n if (field.operation !== 'field') {\n const elsewhere = (['query', 'mutation', 'subscription'] as const).find(\n operation =>\n operation !== field.operation && rootType(schema, operation)?.getFields()[field.name] !== undefined,\n )\n if (elsewhere !== undefined) {\n hints.push(`${ROOTS[elsewhere]}.${field.name} exists: use ${DECORATORS[elsewhere]}()`)\n }\n }\n if (hints.length === 0) {\n const suggestion = closest(field.name, Object.keys(type.getFields()).sort(compareStrings))\n if (suggestion !== undefined) {\n hints.push(`Did you mean '${suggestion}'? ${DECORATORS[field.operation]}('${suggestion}')`)\n }\n }\n hints.push(\n `Declare it in the SDL (${field.operation === 'field' ? `extend type ${type.name}` : `extend type ${type.name}`} { ${field.name}: ... }), or remove the method`,\n )\n this.#mismatch(\n field.location,\n `${DECORATORS[field.operation]} ${where}: ${type.name} has no field '${field.name}'`,\n hints,\n )\n }\n\n /** `@Args('name')`: the argument must exist. */\n #checkArguments(\n sdl: SdlSource,\n field: FieldData,\n method: MethodInfo,\n sdlField: GraphQLField<unknown, unknown>,\n coordinate: string,\n where: string,\n ): void {\n const names = sdlField.args.map(arg => arg.name)\n field.params.forEach((param, index) => {\n if (param?.kind !== 'args' || param.name === undefined || names.includes(param.name)) return\n const suggestion = closest(param.name, [...names].sort(compareStrings))\n const declared = sdl.locate(sdlField.astNode)\n let hint = `Its arguments: ${names.join(', ')}`\n if (suggestion !== undefined) hint = `Did you mean '${suggestion}'?`\n else if (names.length === 0)\n hint = `${coordinate} takes no argument: declare it in the SDL, or remove the parameter`\n this.#mismatch(\n param.location,\n `@Args('${param.name}') on parameter '${method.params[index]?.name ?? param.name}' of ${where}: ${coordinate} has no argument '${param.name}'`,\n [hint],\n declared === undefined ? [] : [{ message: `${coordinate} is declared here`, location: declared }],\n )\n })\n }\n\n #method(resolver: ResolverData, field: FieldData): MethodInfo | undefined {\n const key = `${resolver.host.identity}#${field.method}`\n if (!this.#methods.has(key)) {\n const cls: ClassInfo | undefined = this.#ctx.classInfo(resolver.host.identity)\n this.#methods.set(\n key,\n cls?.methods.find(method => method.name === field.method && method.kind === 'method'),\n )\n }\n return this.#methods.get(key)\n }\n\n // --------------------------------------------------------------------------------------- model\n\n #model(\n sdl: SdlSource,\n type: GraphQLNamedType,\n bindings: ReadonlyMap<string, Binding>,\n scalars: ReadonlyMap<string, ScalarModel>,\n conformance: ReturnType<typeof checkConformance>,\n ): TypeModel | undefined {\n const { isObjectType, isInterfaceType, isInputObjectType, isEnumType, isUnionType } = graphqlModules().type\n const base = {\n name: type.name,\n key: `#sdl:${type.name}`,\n description: type.description ?? undefined,\n location: sdl.locate(type.astNode),\n }\n const nulls = conformance.nullAsUndefined\n if (isObjectType(type) || isInterfaceType(type)) {\n const fields = Object.values(type.getFields()).map(field =>\n this.#field(sdl, type, field, bindings.get(`${type.name}.${field.name}`), nulls),\n )\n const interfaces = type.getInterfaces().map(implemented => implemented.name)\n if (isInterfaceType(type)) {\n const model: InterfaceModel = {\n ...base,\n kind: 'interface',\n fields,\n interfaces,\n discriminator: conformance.discriminators.get(type.name),\n }\n return model\n }\n const model: ObjectModel = {\n ...base,\n kind: 'object',\n fields,\n trail: type.name,\n root: undefined,\n classIdentity: undefined,\n properties: [],\n interfaces,\n }\n return model\n }\n if (isInputObjectType(type)) {\n const model: InputModel = {\n ...base,\n kind: 'input',\n fields: Object.values((type as GraphQLInputObjectType).getFields()).map(field =>\n inputValue(sdl, field, `${type.name}.${field.name}`, nulls),\n ),\n }\n return model\n }\n if (isEnumType(type)) {\n return {\n ...base,\n kind: 'enum',\n values: (type as GraphQLEnumType).getValues().map(value => ({\n name: value.name,\n value: value.name,\n description: value.description ?? undefined,\n deprecationReason: value.deprecationReason ?? undefined,\n })),\n }\n }\n if (isUnionType(type)) {\n const model: UnionModel = {\n ...base,\n kind: 'union',\n members: (type as GraphQLUnionType)\n .getTypes()\n .map(member => member.name)\n .sort(compareStrings),\n discriminator: conformance.discriminators.get(type.name),\n }\n return model\n }\n return scalars.get((type as GraphQLScalarType).name)\n }\n\n #field(\n sdl: SdlSource,\n type: GraphQLObjectType | GraphQLInterfaceType,\n field: GraphQLField<unknown, unknown>,\n binding: Binding | undefined,\n nulls: ReadonlySet<string>,\n ): FieldModel {\n const coordinate = `${type.name}.${field.name}`\n return {\n name: field.name,\n type: String(field.type),\n description: field.description ?? undefined,\n deprecationReason: field.deprecationReason ?? undefined,\n args: field.args.map(arg => inputValue(sdl, arg, `${coordinate}(${arg.name}:)`, nulls)),\n binding: binding === undefined ? undefined : { resolver: binding.resolver, field: binding.field },\n location: sdl.locate(field.astNode),\n }\n }\n}\n\nconst ROOTS: Readonly<Record<Operation, string>> = {\n query: 'Query',\n mutation: 'Mutation',\n subscription: 'Subscription',\n}\n\nfunction rootType(schema: GraphQLSchema, operation: Operation): GraphQLObjectType | undefined {\n switch (operation) {\n case 'query':\n return schema.getQueryType() ?? undefined\n case 'mutation':\n return schema.getMutationType() ?? undefined\n default:\n return schema.getSubscriptionType() ?? undefined\n }\n}\n\n/** An argument or an input field: its default as an external value (enum values by name). */\nfunction inputValue(\n sdl: SdlSource,\n value: GraphQLArgument | GraphQLInputField,\n coordinate: string,\n nulls: ReadonlySet<string>,\n): ArgModel {\n const type = String(value.type)\n const ref = parseTypeRef(type) as NonNullable<ReturnType<typeof parseTypeRef>>\n const defaultInput = value.default\n let defaultValue: unknown\n if (defaultInput !== undefined) {\n defaultValue =\n defaultInput.literal === undefined\n ? defaultInput.value\n : graphqlModules().utilities.valueFromASTUntyped(defaultInput.literal)\n }\n return {\n name: value.name,\n type,\n ref,\n description: value.description ?? undefined,\n deprecationReason: value.deprecationReason ?? undefined,\n defaultValue,\n nullAsUndefined: !ref.nonNull && nulls.has(coordinate),\n location: sdl.locate(value.astNode),\n }\n}\n","/**\n * `@znight/graphql/compiler`: the compiler extension of `@znight/graphql` (RFC 0005 §6).\n *\n * Loaded by `@znight/compiler` through the package manifest (`package.json#znight.compiler`):\n *\n * - `analyzeClass`: `@Resolver` classes become providers (and roots), their field methods and\n * parameters are checked, guards and loaders bound with lazy edges, route decorators read;\n * - `validate`: the schema model, derived from the TypeScript types reachable from the root fields\n * (§6.2–§6.6), with every ZNIGHT060–065 diagnostic and the access decisions (ZNIGHT023);\n * - `generate`: `metadata.extensions.graphql` (§7), and the SDL artifact when configured.\n *\n * The default export is the extension with its default options; `configure(options)` returns a\n * configured copy, declared in `znight.config.ts` (it replaces the discovered extension):\n *\n * ```ts\n * import graphql from '@znight/graphql/compiler'\n * export default { extensions: [graphql.configure({ sdl: 'schema.graphql' })] } satisfies ZnightOptions\n * ```\n *\n * This entry only `import type`s from `@znight/compiler`, imports the runtime-free\n * `@znight/http/compiler`, and never loads the GraphQL runtime, graphql-js nor dataloader: it\n * reaches the import-free modules `src/type-ref.ts`, `src/sdl.ts`, `src/names.ts`,\n * `src/metadata.ts` and `src/schema-hash.ts` (`node:crypto`) only (tests/boundaries.test.ts).\n */\nimport type { ApplicationGraph, CompilerExtension, DecoratorSpec } from '@znight/compiler'\nimport type { GraphQLData } from './data.ts'\nimport type { GraphQLModel } from './model.ts'\nimport type { GraphQLCompilerOptions, ResolvedGraphQLCompilerOptions } from './options.ts'\n\nimport { analyzeGraphQLClass } from './analyze.ts'\nimport { buildModel } from './builder.ts'\nimport { generateGraphQL } from './generate.ts'\nimport { EXTENSION_NAME, GraphQLIds } from './ids.ts'\nimport { DEFAULT_OPTIONS, resolveOptions } from './options.ts'\nimport { buildSchemaFirstModel } from './schema-first.ts'\n\nexport type { FieldData, FieldOperation, GraphQLData, ParamData, ResolverData } from './data.ts'\nexport type { GraphQLCompilerOptions, ResolvedGraphQLCompilerOptions } from './options.ts'\n\nconst FIELD: DecoratorSpec = { targets: ['method'], params: ['static'] }\nconst NO_ARGUMENT: DecoratorSpec = { targets: ['parameter'], params: [] }\n\n/** Decorators owned by the extension, by canonical identity (static / value arguments, §4.6). */\nconst decorators: Readonly<Record<string, DecoratorSpec>> = Object.freeze({\n [GraphQLIds.Resolver]: { targets: ['class'], params: ['static', 'static'] },\n [GraphQLIds.Query]: FIELD,\n [GraphQLIds.Mutation]: FIELD,\n [GraphQLIds.Subscription]: FIELD,\n [GraphQLIds.ResolveField]: FIELD,\n [GraphQLIds.Args]: { targets: ['parameter'], params: ['value', 'value'] },\n [GraphQLIds.Parent]: NO_ARGUMENT,\n [GraphQLIds.Ctx]: NO_ARGUMENT,\n [GraphQLIds.Info]: NO_ARGUMENT,\n [GraphQLIds.Loader]: NO_ARGUMENT,\n [GraphQLIds.UseGuard]: { targets: ['class', 'method'], params: [], rest: 'value' },\n} satisfies Record<string, DecoratorSpec>)\n\n/** The `@znight/graphql` compiler extension, with its options and `configure()`. */\nexport interface GraphQLCompilerExtension extends CompilerExtension<GraphQLData> {\n /** The options of this copy (defaults filled in). */\n readonly options: ResolvedGraphQLCompilerOptions\n /** A copy of the extension with `options` merged onto the options of this one. */\n configure(options: GraphQLCompilerOptions): GraphQLCompilerExtension\n}\n\nfunction createExtension(options: ResolvedGraphQLCompilerOptions): GraphQLCompilerExtension {\n /**\n * Models by compile, built by `validate`, read by `generate`. The key is `graph.extensions`: the\n * validate and generate contexts of one compile get different graph objects sharing this array.\n */\n const models = new WeakMap<object, GraphQLModel | undefined>()\n const modelOf = (graph: ApplicationGraph): GraphQLModel | undefined => models.get(graph.extensions)\n return Object.freeze({\n apiVersion: 1,\n name: EXTENSION_NAME,\n decorators,\n options,\n analyzeClass: (cls, ctx) => analyzeGraphQLClass(cls, ctx, options),\n validate(ctx) {\n const schema = options.schema\n models.set(\n ctx.graph.extensions,\n schema === false ? buildModel(ctx, options) : buildSchemaFirstModel(ctx, schema, options.sdl),\n )\n },\n generate(ctx) {\n return generateGraphQL(ctx, modelOf(ctx.graph), options)\n },\n configure(next: GraphQLCompilerOptions): GraphQLCompilerExtension {\n return createExtension(resolveOptions(options, next))\n },\n } satisfies GraphQLCompilerExtension)\n}\n\n/** The `@znight/graphql` compiler extension with its default options. */\nexport const graphqlCompilerExtension: GraphQLCompilerExtension = createExtension(DEFAULT_OPTIONS)\n\nexport default graphqlCompilerExtension\n"],"mappings":";;;;;;AAaA,MAAa,iBAAiB;;AAG9B,MAAa,iBAAiB;;AAG9B,MAAa,aA2CT,OAAO,OAAO;CAChB,UAAU;CACV,OAAO;CACP,UAAU;CACV,cAAc;CACd,cAAc;CACd,MAAM;CACN,QAAQ;CACR,KAAK;CACL,MAAM;CACN,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,IAAI;CACJ,KAAK;CACL,OAAO;CACP,WAAW;CACX,WAAW;CACX,gBAAgB;CAChB,iBAAiB;CACjB,QAAQ;CACR,eAAe;AACjB,CAAC;;AAGD,MAAa,mCAAyF,IAAI,IAAI;CAC5G,CAAC,WAAW,OAAO,OAAO;CAC1B,CAAC,WAAW,UAAU,UAAU;CAChC,CAAC,WAAW,cAAc,cAAc;CACxC,CAAC,WAAW,cAAc,OAAO;AACnC,CAAC;;AAGD,MAAa,uCAA2F,IAAI,IAAI;CAC9G,CAAC,WAAW,MAAM,MAAM;CACxB,CAAC,WAAW,QAAQ,QAAQ;CAC5B,CAAC,WAAW,KAAK,KAAK;CACtB,CAAC,WAAW,MAAM,MAAM;CACxB,CAAC,WAAW,QAAQ,QAAQ;AAC9B,CAAC;;AAGD,MAAa,iCAAuE,IAAI,IAAI;CAC1F,CAAC,WAAW,IAAI,IAAI;CACpB,CAAC,WAAW,KAAK,KAAK;CACtB,CAAC,WAAW,OAAO,OAAO;CAC1B,CAAC,WAAW,WAAW,MAAM;AAC/B,CAAC;;;;;AAMD,MAAa,mCAAgD,IAAI,IAAI;CACnE,CAAC,oBAAoB,WAAW,GAAG;CACnC,CAAC,sBAAsB,WAAW,IAAI;CACtC,CAAC,sBAAsB,WAAW,IAAI;CACtC,CAAC,qBAAqB,WAAW,IAAI;CACrC,CAAC,yBAA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AAS;EACpB,WAAW,MAAM;EACjB,WAAW,OAAO;EAClB,WAAW,SAAS;EACpB,WAAW,WAAW;EAAE,SAAS,CAAC,SAAS,QAAQ;EAAG,QAAQ,CAAC;EAAG,MAAM;CAAQ;AACnF,CAAyC;AAUzC,SAAS,gBAAgB,SAAmE;;;;;CAK1F,MAAM,yBAAS,IAAI,QAA0C;CAC7D,MAAM,WAAW,UAAsD,OAAO,IAAI,MAAM,UAAU;CAClG,OAAO,OAAO,OAAO;EACnB,YAAY;EACZ,MAAM;EACN;EACA;EACA,eAAe,KAAK,QAAQ,oBAAoB,KAAK,KAAK,OAAO;EACjE,SAAS,KAAK;GACZ,MAAM,SAAS,QAAQ;GACvB,OAAO,IACL,IAAI,MAAM,YACV,WAAW,QAAQ,WAAW,KAAK,OAAO,IAAI,sBAAsB,KAAK,QAAQ,QAAQ,GAAG,CAC9F;EACF;EACA,SAAS,KAAK;GACZ,OAAO,gBAAgB,KAAK,QAAQ,IAAI,KAAK,GAAG,OAAO;EACzD;EACA,UAAU,MAAwD;GAChE,OAAO,gBAAgB,eAAe,SAAS,IAAI,CAAC;EACtD;CACF,CAAoC;AACtC;;AAGA,MAAa,2BAAqD,gBAAgB,eAAe"}
1
+ {"version":3,"file":"compiler.mjs","names":["describe"],"sources":["../src/compiler/ids.ts","../src/compiler/constants.ts","../src/compiler/analyze.ts","../src/schema-hash.ts","../src/sdl.ts","../src/compiler/checks.ts","../src/compiler/defaults.ts","../src/compiler/discriminators.ts","../src/compiler/docs.ts","../src/compiler/locate.ts","../src/compiler/scalars.ts","../src/compiler/sdl-view.ts","../src/compiler/builder.ts","../src/compiler/generate.ts","../src/compiler/options.ts","../src/compiler/graphql-js.ts","../src/compiler/conformance.ts","../src/compiler/suggest.ts","../src/compiler/sdl-source.ts","../src/compiler/schema-first.ts","../src/compiler/index.ts"],"sourcesContent":["/**\n * Canonical identities the `@znight/graphql` compiler extension recognises (RFC 0005 §5.14,\n * §6.2, §6.5): its decorators, `scalar<T>()`, the scalar aliases, the loader and context types, and\n * the look-alike decorators of `@znight/http` it reports (ZNIGHT005).\n *\n * Constants only: this module must stay free of runtime imports (the compiler loads the extension\n * entry, which must never load the GraphQL runtime, graphql-js or dataloader).\n */\n\n/** Package name: the prefix of every identity below. */\nexport const GRAPHQL_PACKAGE = '@znight/graphql'\n\n/** Name of the extension, also the key of `metadata.extensions.graphql`. */\nexport const EXTENSION_NAME = 'graphql'\n\n/** Module the generated code imports its runtime helpers and types from. */\nexport const RUNTIME_MODULE = '@znight/graphql'\n\n/** Canonical identities of the exports of `@znight/graphql` the compiler reads. */\nexport const GraphQLIds: {\n /** `@Resolver(options?)`, class decorator. */\n readonly Resolver: string\n /** `@Query(name?)`, method decorator. */\n readonly Query: string\n /** `@Mutation(name?)`, method decorator. */\n readonly Mutation: string\n /** `@Subscription(name?)`, method decorator. */\n readonly Subscription: string\n /** `@ResolveField(name?)`, method decorator. */\n readonly ResolveField: string\n /** `@Args(nameOrSchema?, schema?)`, parameter decorator. */\n readonly Args: string\n /** `@Parent()`, parameter decorator. */\n readonly Parent: string\n /** `@Ctx()`, parameter decorator (`GraphQLContext`). */\n readonly Ctx: string\n /** `@Info()`, parameter decorator (graphql-js `GraphQLResolveInfo`). */\n readonly Info: string\n /** `@Loader()` parameter decorator **and** the `Loader<L>` parameter type (same export name). */\n readonly Loader: string\n /** `@UseGuard(...guards)`, class or method decorator. */\n readonly UseGuard: string\n /** `scalar<T>(name, definition)`. */\n readonly scalar: string\n /** `type ID = string` → `ID`. */\n readonly ID: string\n /** `type Int = number` → `Int`. */\n readonly Int: string\n /** `type Float = number` → `Float`. */\n readonly Float: string\n /** `type JSONValue` → `JSON`. */\n readonly JSONValue: string\n /** `interface BatchLoad<K, V>`: what loader providers implement (ZNIGHT065). */\n readonly BatchLoad: string\n /** `interface GraphQLContext`: the request-scoped external (manifest `provides`). */\n readonly GraphQLContext: string\n /** `interface ResolverContext`: what guards receive. */\n readonly ResolverContext: string\n /** `abstract class PubSub`: the singleton external (manifest `provides`). */\n readonly PubSub: string\n /** `GraphQLPlugin`: the singleton external (manifest `provides`). */\n readonly GraphQLPlugin: string\n} = Object.freeze({\n Resolver: '@znight/graphql#Resolver',\n Query: '@znight/graphql#Query',\n Mutation: '@znight/graphql#Mutation',\n Subscription: '@znight/graphql#Subscription',\n ResolveField: '@znight/graphql#ResolveField',\n Args: '@znight/graphql#Args',\n Parent: '@znight/graphql#Parent',\n Ctx: '@znight/graphql#Ctx',\n Info: '@znight/graphql#Info',\n Loader: '@znight/graphql#Loader',\n UseGuard: '@znight/graphql#UseGuard',\n scalar: '@znight/graphql#scalar',\n ID: '@znight/graphql#ID',\n Int: '@znight/graphql#Int',\n Float: '@znight/graphql#Float',\n JSONValue: '@znight/graphql#JSONValue',\n BatchLoad: '@znight/graphql#BatchLoad',\n GraphQLContext: '@znight/graphql#GraphQLContext',\n ResolverContext: '@znight/graphql#ResolverContext',\n PubSub: '@znight/graphql#PubSub',\n GraphQLPlugin: '@znight/graphql#GraphQLPlugin',\n})\n\n/** Field decorators → the kind of field they declare (`GraphQLResolverBinding.operation`). */\nexport const FIELD_DECORATORS: ReadonlyMap<string, 'query' | 'mutation' | 'subscription' | 'field'> = new Map([\n [GraphQLIds.Query, 'query'],\n [GraphQLIds.Mutation, 'mutation'],\n [GraphQLIds.Subscription, 'subscription'],\n [GraphQLIds.ResolveField, 'field'],\n])\n\n/** Parameter decorators → what the generated `invoke` passes (§7.3). */\nexport const PARAMETER_DECORATORS: ReadonlyMap<string, 'args' | 'parent' | 'ctx' | 'info' | 'loader'> = new Map([\n [GraphQLIds.Args, 'args'],\n [GraphQLIds.Parent, 'parent'],\n [GraphQLIds.Ctx, 'ctx'],\n [GraphQLIds.Info, 'info'],\n [GraphQLIds.Loader, 'loader'],\n])\n\n/** Scalar aliases of `@znight/graphql` → their GraphQL scalar (§6.2). */\nexport const SCALAR_ALIASES: ReadonlyMap<string, 'ID' | 'Int' | 'Float' | 'JSON'> = new Map([\n [GraphQLIds.ID, 'ID'],\n [GraphQLIds.Int, 'Int'],\n [GraphQLIds.Float, 'Float'],\n [GraphQLIds.JSONValue, 'JSON'],\n])\n\n/**\n * Decorators of `@znight/http` that look like GraphQL ones, on a resolver: ZNIGHT005 with the\n * `@znight/graphql` decorator to import instead (§6.5).\n */\nexport const HTTP_LOOK_ALIKES: ReadonlyMap<string, string> = new Map([\n ['@znight/http#Ctx', GraphQLIds.Ctx],\n ['@znight/http#Query', GraphQLIds.Args],\n ['@znight/http#Param', GraphQLIds.Args],\n ['@znight/http#Body', GraphQLIds.Args],\n ['@znight/http#UseGuard', GraphQLIds.UseGuard],\n])\n\n/** `@Controller` of `@znight/http`: a class cannot be both a controller and a resolver (ZNIGHT005). */\nexport const HTTP_CONTROLLER = '@znight/http#Controller'\n\n/** graphql-js `GraphQLResolveInfo`, the type of `@Info()` parameters. */\nexport const GRAPHQL_RESOLVE_INFO = 'graphql#GraphQLResolveInfo'\n","/**\n * Constants of the compiler extension modules: diagnostic codes, shape options, ordering. This\n * module must stay free of runtime imports (the compiler loads the extension entry, which must\n * never load the GraphQL runtime, graphql-js nor dataloader).\n */\nimport type { ErrorCode } from '@znight/core'\n\nimport { GraphQLIds } from './ids.ts'\n\n/** Diagnostic codes the extension reports (RFC 0005 §6.6 and the reused framework codes). */\nexport const Codes: {\n /** ZNIGHT005: decorator target, arguments, method shape, look-alikes, `@Resolver` + `@Controller`. */\n readonly InvalidDecorator: ErrorCode\n /** ZNIGHT023: a root field without a decision of a required route decorator group (RFC 0001). */\n readonly MissingRouteDecision: ErrorCode\n /** ZNIGHT060: a TypeScript type with no GraphQL mapping, a missing annotation. */\n readonly InvalidType: ErrorCode\n /** ZNIGHT061: name conflicts, invalid or reserved names, field resolver type mismatches. */\n readonly NameConflict: ErrorCode\n /** ZNIGHT062: resolver structure (parent, subscriptions, no query, inheritance, libraries). */\n readonly InvalidResolver: ErrorCode\n /** ZNIGHT063: input position problems (dual use, getters, unions, cycles, defaults). */\n readonly InvalidInput: ErrorCode\n /** ZNIGHT064: union members that cannot be told apart at runtime. */\n readonly UnresolvableAbstractType: ErrorCode\n /** ZNIGHT065: `@Loader()` parameters and loader providers. */\n readonly InvalidLoader: ErrorCode\n /** ZNIGHT067: schema-first SDL files (RFC 0007): reading, syntax, validation, unsupported constructs. */\n readonly InvalidSdl: ErrorCode\n /** ZNIGHT068: schema-first resolvers against the SDL (RFC 0007): coverage and type conformance. */\n readonly SchemaMismatch: ErrorCode\n} = Object.freeze({\n InvalidDecorator: 'ZNIGHT005',\n MissingRouteDecision: 'ZNIGHT023',\n InvalidType: 'ZNIGHT060',\n NameConflict: 'ZNIGHT061',\n InvalidResolver: 'ZNIGHT062',\n InvalidInput: 'ZNIGHT063',\n UnresolvableAbstractType: 'ZNIGHT064',\n InvalidLoader: 'ZNIGHT065',\n InvalidSdl: 'ZNIGHT067',\n SchemaMismatch: 'ZNIGHT068',\n})\n\n/** Root reason given to `AnalyzeContext.addRoot()`. */\nexport const ROOT_REASON = 'GraphQL resolver'\n\n/** Async iterables: the return type of `@Subscription` methods (§6.2). */\nexport const ASYNC_ITERABLES: ReadonlySet<string> = new Set([\n 'globalThis#AsyncIterable',\n 'globalThis#AsyncIterableIterator',\n 'globalThis#AsyncGenerator',\n])\n\n/** Iterables mapped to lists in output position (§6.2). */\nexport const OUTPUT_ITERABLES: ReadonlySet<string> = new Set([\n 'globalThis#Set',\n 'globalThis#ReadonlySet',\n 'globalThis#Iterable',\n])\n\n/**\n * Identities the shapes keep as references (`ShapeOptions.keep`), before the identities of the\n * `scalar<T>()` declarations of the application.\n */\nexport const BASE_KEEP: readonly string[] = Object.freeze([\n ...ASYNC_ITERABLES,\n ...OUTPUT_ITERABLES,\n GraphQLIds.ID,\n GraphQLIds.Int,\n GraphQLIds.Float,\n GraphQLIds.JSONValue,\n GraphQLIds.Loader,\n])\n\n/** Deterministic string comparison (code-unit order, never `localeCompare`). */\nexport function compareStrings(a: string, b: string): number {\n if (a === b) return 0\n return a < b ? -1 : 1\n}\n","/**\n * `analyzeClass` of the graphql extension (RFC 0005 §6.1, §6.5): registers `@Resolver` classes as\n * providers (and roots), checks their field methods and parameters, binds `@UseGuard` guards and\n * `Loader<L>` parameters with lazy edges (resolved per call, in the current scope), reads route\n * decorators with the readers of `@znight/http/compiler`, and stores one {@link ResolverData} per\n * resolver. Types are not read here: `validate` builds the schema model from the method signatures.\n */\n\nimport type {\n AnalyzeContext,\n ClassInfo,\n ClassRef,\n DecoratorInfo,\n Location,\n MethodInfo,\n ParameterInfo,\n StaticValue,\n} from '@znight/compiler'\nimport type { Scope } from '@znight/core'\nimport type { MetaEntry } from '@znight/http/compiler'\nimport type { FieldData, FieldOperation, GraphQLData, ParamData, ResolverData } from './data.ts'\nimport type { ResolvedGraphQLCompilerOptions } from './options.ts'\n\nimport { effectiveRouteMeta, readRouteMeta } from '@znight/http/compiler'\n\nimport { isGraphQLName } from '../names.ts'\nimport { Codes, ROOT_REASON } from './constants.ts'\nimport {\n EXTENSION_NAME,\n FIELD_DECORATORS,\n GraphQLIds,\n HTTP_CONTROLLER,\n HTTP_LOOK_ALIKES,\n PARAMETER_DECORATORS,\n RUNTIME_MODULE,\n} from './ids.ts'\n\ntype Context = AnalyzeContext<GraphQLData>\n\nconst SCOPES: readonly Scope[] = ['singleton', 'request', 'transient']\n\n/** Shape options reading `Loader<L>` parameters: the alias is kept, `L` stays a named shape. */\nconst LOADER_SHAPE = Object.freeze({ keep: Object.freeze([GraphQLIds.Loader]), jsdoc: false })\n\n/**\n * Analyses a class carrying at least one graphql decorator (class, method or parameter). In\n * schema-first mode (RFC 0007), `@Resolver('Type')` names the SDL type of the field resolvers and\n * `@Parent()` is optional.\n */\nexport function analyzeGraphQLClass(cls: ClassInfo, ctx: Context, options: ResolvedGraphQLCompilerOptions): void {\n const resolvers = cls.decorators.filter(decorator => decorator.identity === GraphQLIds.Resolver)\n const resolver = resolvers[0]\n if (resolver === undefined) {\n reportOutsideResolver(cls, ctx)\n storeClaims(ctx, cls, undefined, options)\n return\n }\n for (const extra of resolvers.slice(1)) {\n error(ctx, Codes.InvalidDecorator, extra.location, `@Resolver is applied twice to ${cls.displayName}`, [\n 'Apply it once',\n ])\n }\n const controller = cls.decorators.find(decorator => decorator.identity === HTTP_CONTROLLER)\n if (controller !== undefined) {\n error(\n ctx,\n Codes.InvalidDecorator,\n resolver.location,\n `${cls.displayName} cannot be both a @Resolver and a @Controller`,\n [\n 'A class is the provider of one extension: move the GraphQL fields to their own @Resolver() class (both may call the same service)',\n ],\n [{ message: '@Controller is applied here', location: controller.location }],\n )\n storeClaims(ctx, cls, resolver, options)\n return\n }\n if (ctx.options.library) {\n error(\n ctx,\n Codes.InvalidResolver,\n resolver.location,\n `${cls.displayName} is a @Resolver in a compiled provider library: the schema is derived from the sources`,\n ['Publish the package as a source library (without library: true), so that applications compile its resolvers'],\n )\n storeClaims(ctx, cls, resolver, options)\n return\n }\n if (cls.abstract || cls.typeParameters.length > 0) {\n error(\n ctx,\n Codes.InvalidDecorator,\n resolver.location,\n cls.abstract\n ? `@Resolver cannot be applied to the abstract class ${cls.displayName}`\n : `@Resolver cannot be applied to the generic class ${cls.displayName}<${cls.typeParameters.join(', ')}>`,\n [cls.abstract ? 'Resolvers are instantiated: remove `abstract`' : 'Remove the type parameters of the resolver'],\n )\n storeClaims(ctx, cls, resolver, options)\n return\n }\n\n const { scope, typeName } = resolverArguments(ctx, resolver, options.schema !== false)\n ctx.registerProvider(cls, { scope })\n // resolvers are entry points of the plugin: roots of ZNIGHT019 and prune\n ctx.addRoot(cls, { reason: ROOT_REASON, location: resolver.location })\n\n const classGuards = guardsOf(ctx, cls, cls.decorators)\n const classMeta = readRouteMeta(ctx, cls)\n const fields: FieldData[] = []\n for (const method of cls.methods) {\n const decorators = method.decorators.filter(isFieldDecorator)\n if (decorators.length === 0) {\n reportStrayMethodDecorators(cls, method, ctx)\n continue\n }\n fields.push(...analyzeMethod(ctx, cls, method, decorators, classMeta, options.schema !== false))\n }\n const data: ResolverData = {\n kind: 'resolver',\n host: cls,\n scope,\n location: resolver.location,\n guards: classGuards,\n fields,\n ...(typeName === undefined ? {} : { typeName }),\n }\n if (options.schema !== false && typeName === undefined) {\n for (const field of fields) {\n if (field.operation !== 'field') continue\n error(\n ctx,\n Codes.InvalidResolver,\n field.location,\n `@ResolveField ${cls.displayName}.${field.method} needs the type it resolves a field of: name it in @Resolver (schema-first)`,\n [\n `@Resolver('Event') on ${cls.displayName}, where Event is the object type of the SDL declaring '${field.name}'`,\n ],\n )\n }\n }\n ctx.store(data)\n}\n\n/**\n * Schema-first: a class rejected above (no `@Resolver`, abstract, a controller...) still names the\n * fields its methods resolve, stored as an `invalid` resolver, so that these fields are not also\n * reported as missing a resolver (one diagnostic per mistake).\n */\nfunction storeClaims(\n ctx: Context,\n cls: ClassInfo,\n resolver: DecoratorInfo | undefined,\n options: ResolvedGraphQLCompilerOptions,\n): void {\n if (options.schema === false) return\n const typeArg = resolver?.args[0]\n const typeName =\n typeArg?.evaluated === true && typeof typeArg.value === 'string'\n ? { name: typeArg.value, location: typeArg.location }\n : undefined\n const fields: FieldData[] = []\n for (const method of cls.methods) {\n for (const decorator of method.decorators.filter(isFieldDecorator)) {\n const arg = decorator.args[0]\n fields.push({\n method: method.name,\n operation: FIELD_DECORATORS.get(decorator.identity as string) as FieldOperation,\n name: arg?.evaluated === true && typeof arg.value === 'string' ? arg.value : method.name,\n location: decorator.location,\n methodLocation: method.location,\n guards: [],\n meta: [],\n params: [],\n complete: false,\n })\n }\n }\n if (fields.length === 0) return\n ctx.store({\n kind: 'resolver',\n host: cls,\n scope: 'singleton',\n location: resolver?.location ?? cls.location,\n guards: [],\n fields,\n invalid: true,\n ...(typeName === undefined ? {} : { typeName }),\n })\n}\n\nfunction isFieldDecorator(decorator: DecoratorInfo): boolean {\n return decorator.identity !== undefined && FIELD_DECORATORS.has(decorator.identity)\n}\n\nfunction isParameterDecorator(decorator: DecoratorInfo): boolean {\n return decorator.identity !== undefined && PARAMETER_DECORATORS.has(decorator.identity)\n}\n\n/** `@Resolver()`, `@Resolver({ scope })`, `@Resolver('Event')`, `@Resolver('Event', { scope })` (schema-first). */\nfunction resolverArguments(\n ctx: Context,\n decorator: DecoratorInfo,\n schemaFirst: boolean,\n): { scope: Scope; typeName?: { readonly name: string; readonly location: Location } } {\n const [first, second] = decorator.args\n if (first?.evaluated !== true || typeof first.value !== 'string') {\n if (second !== undefined) {\n error(ctx, Codes.InvalidDecorator, second.location, '@Resolver takes the options as its only argument here', [\n \"@Resolver({ scope: 'request' }), or @Resolver('Event', { scope: 'request' }) in schema-first mode\",\n ])\n }\n return { scope: resolverScope(ctx, first) }\n }\n const scope = resolverScope(ctx, second)\n const name = first.value\n if (!schemaFirst) {\n error(\n ctx,\n Codes.InvalidDecorator,\n first.location,\n `@Resolver('${name}'): naming the type is schema-first only, the code-first schema is derived from the types`,\n [\n 'Remove the type name: @ResolveField methods add fields to the type of their @Parent() parameter',\n \"Or switch to schema-first: graphql.configure({ schema: 'src/**/*.graphql' }) in znight.config.ts\",\n ],\n )\n return { scope }\n }\n if (!isGraphQLName(name)) {\n error(ctx, Codes.NameConflict, first.location, `'${name}' is not a valid GraphQL type name (@Resolver)`, [\n 'GraphQL names match /^[_A-Za-z][_0-9A-Za-z]*$/ and do not start with __',\n ])\n return { scope }\n }\n return { scope, typeName: { name, location: first.location } }\n}\n\n/** The `{ scope }` options of `@Resolver`. */\nfunction resolverScope(ctx: Context, arg: DecoratorInfo['args'][number] | undefined): Scope {\n if (arg === undefined || !arg.evaluated || arg.value === undefined) return 'singleton'\n const value = arg.value\n if (!isRecord(value)) {\n error(ctx, Codes.InvalidDecorator, arg.location, `@Resolver expects { scope? }, got ${describe(value)}`, [\n \"@Resolver() or @Resolver({ scope: 'request' })\",\n ])\n return 'singleton'\n }\n let scope: Scope = 'singleton'\n for (const [key, option] of Object.entries(value)) {\n if (key !== 'scope') {\n error(ctx, Codes.InvalidDecorator, arg.location, `@Resolver: unknown option \"${key}\"`, ['Options: { scope? }'])\n } else if (SCOPES.includes(option as Scope)) {\n scope = option as Scope\n } else if (option !== undefined) {\n error(ctx, Codes.InvalidDecorator, arg.location, `@Resolver: invalid scope ${describe(option)}`, [\n `Use one of ${SCOPES.map(candidate => `'${candidate}'`).join(', ')}`,\n ])\n }\n }\n return scope\n}\n\n/** `@UseGuard(A, B)` decorators of a target: guard classes bound with lazy edges (C3). */\nfunction guardsOf(ctx: Context, cls: ClassInfo, decorators: readonly DecoratorInfo[]): ClassRef[] {\n const guards: ClassRef[] = []\n for (const decorator of decorators) {\n if (decorator.identity !== GraphQLIds.UseGuard) continue\n if (decorator.args.length === 0) {\n error(ctx, Codes.InvalidDecorator, decorator.location, '@UseGuard needs at least one guard class', [\n '@UseGuard(AccessGuard)',\n ])\n }\n for (const arg of decorator.args) {\n // resolved per resolver call in the current scope: a singleton resolver may use a request-scoped guard\n const ref = ctx.resolveClassRef(arg, { from: cls, role: 'guard', lazy: true })\n if (ref !== undefined) guards.push(ref)\n }\n }\n return guards\n}\n\n// ------------------------------------------------------------------------------------------ methods\n\nfunction analyzeMethod(\n ctx: Context,\n cls: ClassInfo,\n method: MethodInfo,\n decorators: readonly DecoratorInfo[],\n classMeta: readonly MetaEntry[],\n schemaFirst: boolean,\n): FieldData[] {\n const where = `${cls.displayName}.${method.name}`\n const primary = decorators[0] as DecoratorInfo\n let complete = checkMethodShape(ctx, method, primary, where)\n complete = checkForeignHandler(ctx, method, primary, where) && complete\n const params: (ParamData | undefined)[] = []\n for (const param of method.params) {\n const data = analyzeParameter(ctx, cls, param, where)\n params.push(data)\n if (data === undefined) complete = false\n }\n const parents = params.filter(param => param?.kind === 'parent')\n for (const extra of parents.slice(1)) {\n error(\n ctx,\n Codes.InvalidResolver,\n (extra as { location: Location }).location,\n `${where} has several @Parent() parameters`,\n ['Declare the parent object once'],\n )\n complete = false\n }\n const guards = guardsOf(ctx, cls, method.decorators)\n const meta = effectiveRouteMeta(classMeta, readRouteMeta(ctx, cls, method))\n\n const fields: FieldData[] = []\n const seen = new Set<string>()\n for (const decorator of decorators) {\n const operation = FIELD_DECORATORS.get(decorator.identity as string) as FieldOperation\n const explicit = fieldName(ctx, decorator, method, where)\n // an invalid name is reported: the field stays known (incomplete), so no \"no @Query\" cascade\n const name = explicit ?? method.name\n const key = `${operation}\\0${name}`\n if (seen.has(key)) {\n error(\n ctx,\n Codes.InvalidDecorator,\n decorator.location,\n `@${decorator.name}('${name}') is applied twice to ${where}`,\n ['Apply each field decorator once'],\n )\n continue\n }\n seen.add(key)\n let fieldComplete = complete && explicit !== undefined\n // schema-first: the type is named by @Resolver('Type'), the parent is optional (NestJS)\n if (operation === 'field' && parents.length === 0 && !schemaFirst) {\n error(ctx, Codes.InvalidResolver, decorator.location, `@ResolveField ${where} has no @Parent() parameter`, [\n `Declare the parent object first: ${method.name}(@Parent() parent: ParentType, ...)`,\n ])\n fieldComplete = false\n } else if (operation !== 'field' && parents.length > 0) {\n error(\n ctx,\n Codes.InvalidResolver,\n (parents[0] as { location: Location }).location,\n `@Parent() is only available in @ResolveField methods, not in the @${decorator.name} ${where}`,\n ['Root fields have no parent object: remove the parameter'],\n )\n fieldComplete = false\n }\n fields.push({\n method: method.name,\n operation,\n name,\n location: decorator.location,\n methodLocation: method.location,\n guards,\n meta,\n params,\n complete: fieldComplete,\n })\n }\n return fields\n}\n\n/** The field name: the static decorator argument, or the method name. */\nfunction fieldName(ctx: Context, decorator: DecoratorInfo, method: MethodInfo, where: string): string | undefined {\n const arg = decorator.args[0]\n if (arg === undefined || (arg.evaluated && arg.value === undefined)) {\n if (isGraphQLName(method.name)) return method.name\n error(\n ctx,\n Codes.NameConflict,\n decorator.location,\n `'${method.name}' is not a valid GraphQL field name (${where}): name the field in the decorator`,\n ['GraphQL names match /^[_A-Za-z][_0-9A-Za-z]*$/ and do not start with __', `@${decorator.name}('validName')`],\n )\n return undefined\n }\n if (!arg.evaluated) return undefined // not statically evaluable: reported by the compiler\n const value = arg.value\n if (typeof value !== 'string') {\n error(\n ctx,\n Codes.InvalidDecorator,\n arg.location,\n `@${decorator.name} on ${where} expects a field name, got ${describe(value)}`,\n [`@${decorator.name}('${method.name}') or @${decorator.name}()`],\n )\n return undefined\n }\n if (!isGraphQLName(value)) {\n error(ctx, Codes.NameConflict, arg.location, `'${value}' is not a valid GraphQL field name (${where})`, [\n 'GraphQL names match /^[_A-Za-z][_0-9A-Za-z]*$/ and do not start with __',\n ])\n return undefined\n }\n return value\n}\n\n/** Resolver methods are called by the generated code: `resolver.method(...)`. */\nfunction checkMethodShape(ctx: Context, method: MethodInfo, decorator: DecoratorInfo, where: string): boolean {\n const name = `@${decorator.name}`\n let problem: { message: string; hint: string } | undefined\n if (method.kind !== 'method') {\n problem = { message: `${name} cannot be applied to the accessor ${where}`, hint: 'Use a regular method' }\n } else if (method.static) {\n problem = {\n message: `${name} cannot be applied to the static method ${where}`,\n hint: 'Fields are resolved on the resolver instance: remove `static`',\n }\n } else if (method.privateName) {\n problem = {\n message: `${name} cannot be applied to the #private method ${where}`,\n hint: 'Use a public method: the generated code calls it',\n }\n } else if (method.visibility !== 'public') {\n problem = {\n message: `${where} must be public: ${name} methods are called by the generated code`,\n hint: `Remove the '${method.visibility}' modifier`,\n }\n } else if (method.computed) {\n problem = {\n message: `${name} cannot be applied to ${where}: computed method names are not supported`,\n hint: 'Use a plain method name',\n }\n } else if (method.typeParameters.length > 0) {\n problem = {\n message: `${name} cannot be applied to the generic method ${where}<${method.typeParameters.join(', ')}>`,\n hint: 'The schema is derived from the signature: remove the type parameters',\n }\n }\n if (problem === undefined) return true\n error(ctx, Codes.InvalidDecorator, decorator.location, problem.message, [problem.hint])\n return false\n}\n\n/** A resolver method cannot also be handled by another extension (`@Get`, `@OnMessage`, `@Cron`). */\nfunction checkForeignHandler(ctx: Context, method: MethodInfo, decorator: DecoratorInfo, where: string): boolean {\n for (const other of method.decorators) {\n const owner = other.owner\n if (owner === undefined || owner === EXTENSION_NAME || owner === 'core' || owner === 'manifest') continue\n error(\n ctx,\n Codes.InvalidDecorator,\n other.location,\n `${where} cannot be both a GraphQL field (@${decorator.name}) and a @${other.name} handler`,\n ['A class is the provider of one extension: let both handlers call a shared service'],\n )\n return false\n }\n return true\n}\n\n// --------------------------------------------------------------------------------------- parameters\n\n/**\n * Graphql parameter decorators of a parameter, de-duplicated by position (the compiler reports the\n * decorators of a parameter with a default value twice).\n */\nfunction parameterDecorators(param: ParameterInfo): DecoratorInfo[] {\n const seen = new Set<number>()\n return param.decorators.filter(decorator => {\n if (!isParameterDecorator(decorator) || seen.has(decorator.location.start)) return false\n seen.add(decorator.location.start)\n return true\n })\n}\n\nfunction analyzeParameter(ctx: Context, cls: ClassInfo, param: ParameterInfo, where: string): ParamData | undefined {\n const decorators = parameterDecorators(param)\n // custom parameter decorators (RFC 0010); compilers before it have no paramDecorator\n const custom = typeof ctx.paramDecorator === 'function' ? ctx.paramDecorator(param, 'graphql', cls) : undefined\n if (custom !== undefined) {\n for (const other of decorators) {\n error(\n ctx,\n Codes.InvalidDecorator,\n other.location,\n `Parameter '${param.name}' of ${where} has several parameter decorators (@${custom.decorator.name} and @${other.name})`,\n ['Keep a single parameter decorator'],\n )\n }\n if (!custom.ok || decorators.length > 0) return undefined\n const data = custom.data\n return {\n kind: 'custom',\n identity: custom.identity,\n name: custom.name,\n data: data === undefined ? undefined : { value: data.ref ?? (data.value as StaticValue) },\n resolver: custom.resolver.kind === 'class' ? custom.resolver.ref : undefined,\n ...(custom.resolver.kind === 'class' && custom.resolver.arity !== undefined\n ? { arity: custom.resolver.arity }\n : {}),\n cast: custom.cast,\n location: custom.location,\n }\n }\n const decorator = decorators[0]\n if (decorator === undefined) {\n const lookAlike = param.decorators.find(\n found => found.identity !== undefined && HTTP_LOOK_ALIKES.has(found.identity),\n )\n if (lookAlike !== undefined) {\n const replacement = (HTTP_LOOK_ALIKES.get(lookAlike.identity as string) as string).split('#')[1] as string\n error(\n ctx,\n Codes.InvalidDecorator,\n lookAlike.location,\n `@${lookAlike.name} on parameter '${param.name}' of ${where} is imported from '@znight/http': resolver parameters use @${replacement}() from '${RUNTIME_MODULE}'`,\n [`Import it from '${RUNTIME_MODULE}': import { ${replacement} } from '${RUNTIME_MODULE}'`],\n )\n return undefined\n }\n error(\n ctx,\n Codes.InvalidDecorator,\n param.location,\n `Parameter '${param.name}' of ${where} has no @Args(), @Parent(), @Ctx(), @Info() or @Loader() decorator`,\n [\n 'Every resolver parameter is filled by GraphQL: @Args(name?, schema?) for arguments, @Parent() for the parent object, @Ctx() for the GraphQLContext, @Info() for the GraphQLResolveInfo, @Loader() for a DataLoader',\n ],\n )\n return undefined\n }\n if (decorators.length > 1) {\n error(\n ctx,\n Codes.InvalidDecorator,\n (decorators[1] as DecoratorInfo).location,\n `Parameter '${param.name}' of ${where} has several GraphQL decorators (${decorators.map(found => `@${found.name}`).join(', ')})`,\n ['Keep a single one'],\n )\n return undefined\n }\n if (param.rest) {\n error(\n ctx,\n Codes.InvalidDecorator,\n decorator.location,\n `@${decorator.name} cannot be applied to the rest parameter '...${param.name}' of ${where}`,\n )\n return undefined\n }\n switch (PARAMETER_DECORATORS.get(decorator.identity as string)) {\n case 'args':\n return argsParameter(ctx, decorator, param, where)\n case 'parent':\n return { kind: 'parent', location: decorator.location }\n case 'ctx':\n return { kind: 'ctx' }\n case 'info':\n return { kind: 'info' }\n default:\n return loaderParameter(ctx, cls, param, where)\n }\n}\n\n/** `@Args()`, `@Args('name')`, `@Args('name', Schema)`, `@Args(Schema)`. */\nfunction argsParameter(\n ctx: Context,\n decorator: DecoratorInfo,\n param: ParameterInfo,\n where: string,\n): ParamData | undefined {\n const [first, second, ...extra] = decorator.args\n if (extra.length > 0) {\n error(ctx, Codes.InvalidDecorator, decorator.location, `@Args takes at most two arguments (${where})`, [\n \"@Args(), @Args('name'), @Args('name', Schema) or @Args(Schema)\",\n ])\n return undefined\n }\n let name: string | undefined\n let schemaArg = second\n if (first !== undefined) {\n if (!first.evaluated && first.ref === undefined) return undefined // reported by the compiler\n if (typeof first.value === 'string') {\n if (!isGraphQLName(first.value)) {\n error(\n ctx,\n Codes.NameConflict,\n first.location,\n `'${first.value}' is not a valid GraphQL argument name (parameter '${param.name}' of ${where})`,\n ['GraphQL names match /^[_A-Za-z][_0-9A-Za-z]*$/ and do not start with __'],\n )\n return undefined\n }\n name = first.value\n } else if (first.ref !== undefined) {\n if (second !== undefined) {\n error(ctx, Codes.InvalidDecorator, second.location, `@Args(Schema) takes no second argument (${where})`, [\n \"@Args('name', Schema) validates one argument, @Args(Schema) every argument\",\n ])\n return undefined\n }\n schemaArg = first\n } else if (first.value !== undefined) {\n error(\n ctx,\n Codes.InvalidDecorator,\n first.location,\n `@Args on parameter '${param.name}' of ${where} expects an argument name or a schema, got ${describe(first.value)}`,\n [\"@Args('id'), @Args() or @Args('input', Schema)\"],\n )\n return undefined\n }\n }\n if (schemaArg !== undefined && !(schemaArg.evaluated && schemaArg.value === undefined)) {\n if (schemaArg.ref === undefined) {\n if (schemaArg.evaluated) {\n error(\n ctx,\n Codes.InvalidDecorator,\n schemaArg.location,\n `The schema of @Args on parameter '${param.name}' of ${where} must be a reference to an exported schema`,\n ['Declare it with `export const Schema = z.object(...)` and pass Schema: the generated module imports it'],\n )\n }\n return undefined\n }\n return { kind: 'args', name, schema: schemaArg.ref, location: decorator.location }\n }\n return { kind: 'args', name, schema: undefined, location: decorator.location }\n}\n\n/** `@Loader() authors: Loader<AuthorsById>`: binds `AuthorsById` with a lazy edge. */\nfunction loaderParameter(ctx: Context, cls: ClassInfo, param: ParameterInfo, where: string): ParamData | undefined {\n const root = ctx.types.shape({ parameter: param }, LOADER_SHAPE)\n const shape = root.root\n const argument = shape.kind === 'reference' && shape.identity === GraphQLIds.Loader ? shape.typeArgs[0] : undefined\n const identity = argument?.kind === 'named' ? root.named.get(argument.key)?.identity : undefined\n if (identity === undefined) {\n error(\n ctx,\n Codes.InvalidLoader,\n param.typeLocation,\n `@Loader() parameter '${param.name}' of ${where} must be typed Loader<L>, with L a loader class`,\n [\n `${param.name}: Loader<AuthorsById>, where AuthorsById is a provider implementing BatchLoad<K, V> (import type { Loader } from '${RUNTIME_MODULE}')`,\n ],\n )\n return undefined\n }\n // the DataLoader is created per execution, in the current scope: a lazy edge (no ZNIGHT003)\n const binding = ctx.bindInjection(\n { type: identity, location: param.typeLocation, label: `loader '${param.name}' of ${where}()` },\n { from: cls, lazy: true },\n )\n return { kind: 'loader', binding, identity, location: param.typeLocation }\n}\n\n// ------------------------------------------------------------------------------------ outside resolvers\n\n/**\n * Graphql decorators on a class without `@Resolver`: field methods are not inherited (a base\n * class), and parameter or guard decorators have no effect.\n */\nfunction reportOutsideResolver(cls: ClassInfo, ctx: Context): void {\n for (const decorator of cls.decorators) {\n if (decorator.identity === GraphQLIds.UseGuard) {\n error(\n ctx,\n Codes.InvalidDecorator,\n decorator.location,\n `@UseGuard has no effect: ${cls.displayName} is not a @Resolver`,\n [`Add @Resolver() to ${cls.displayName}`],\n )\n }\n }\n for (const method of cls.methods) {\n const fields = method.decorators.filter(isFieldDecorator)\n for (const field of fields) {\n error(\n ctx,\n Codes.InvalidResolver,\n field.location,\n `@${field.name} ${cls.displayName}.${method.name} is declared on a class that is not a @Resolver`,\n [\n cls.abstract\n ? `Resolver methods are not inherited: declare the field on the concrete @Resolver() class (it may call ${method.name} of the base class)`\n : `Add @Resolver() to ${cls.displayName} (resolver methods are not inherited from base classes)`,\n ],\n )\n }\n if (fields.length === 0) reportStrayMethodDecorators(cls, method, ctx)\n }\n}\n\n/** `@UseGuard` or parameter decorators on a method that is not a field. */\nfunction reportStrayMethodDecorators(cls: ClassInfo, method: MethodInfo, ctx: Context): void {\n const where = `${cls.displayName}.${method.name}`\n for (const decorator of method.decorators) {\n if (decorator.identity === GraphQLIds.UseGuard) {\n error(\n ctx,\n Codes.InvalidDecorator,\n decorator.location,\n `@UseGuard has no effect: ${where} is not a GraphQL field`,\n ['Add @Query(), @Mutation(), @Subscription() or @ResolveField() to the method'],\n )\n }\n }\n for (const param of method.params) {\n for (const decorator of parameterDecorators(param)) {\n error(\n ctx,\n Codes.InvalidDecorator,\n decorator.location,\n `@${decorator.name} has no effect: ${where} is not a GraphQL field`,\n ['Add @Query(), @Mutation(), @Subscription() or @ResolveField() to the method'],\n )\n }\n }\n}\n\n// ------------------------------------------------------------------------------------------ helpers\n\nfunction error(\n ctx: Context,\n code: (typeof Codes)[keyof typeof Codes],\n location: Location,\n message: string,\n hints: readonly string[] = [],\n related: readonly { readonly message: string; readonly location: Location }[] = [],\n): void {\n ctx.report({\n code,\n severity: 'error',\n message,\n location,\n ...(hints.length === 0 ? {} : { hints }),\n ...(related.length === 0 ? {} : { related }),\n })\n}\n\n/** An evaluated object literal (not an array, not a reference). */\nfunction isRecord(value: StaticValue): value is Readonly<Record<string, StaticValue>> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false\n const prototype: unknown = Object.getPrototypeOf(value)\n return prototype === Object.prototype || prototype === null\n}\n\n/** Short description of a value for messages. */\nexport function describe(value: StaticValue): string {\n if (value === undefined) return 'undefined'\n if (value === null) return 'null'\n if (typeof value === 'string') return JSON.stringify(value)\n if (typeof value === 'bigint') return `${value}n`\n if (typeof value !== 'object') return String(value)\n if (Array.isArray(value)) return 'an array'\n return isRecord(value) ? 'an object' : 'a reference'\n}\n","/**\n * `schemaHash` of `metadata.extensions.graphql` (RFC 0005 §7.1): the first 16 hexadecimal\n * characters of the SHA-256 of the SDL printed by `printSdl()`.\n *\n * Separate from the import-free `sdl.ts` because it needs `node:crypto`. That is fine on both sides:\n * the compiler extension runs at build time on Node.js or Bun, and the runtime targets Node.js >= 24\n * and Bun >= 1.3, which both provide `node:crypto`. The module reaches nothing else, so the\n * `./compiler` boundaries hold (tests/boundaries.test.ts).\n */\nimport { createHash } from 'node:crypto'\n\n/** Length of a schema hash, in hexadecimal characters. */\nexport const SCHEMA_HASH_LENGTH = 16\n\n/** First 16 hexadecimal characters of the SHA-256 of `sdl` (UTF-8). */\nexport function schemaHash(sdl: string): string {\n return createHash('sha256').update(sdl, 'utf8').digest('hex').slice(0, SCHEMA_HASH_LENGTH)\n}\n","/**\n * Deterministic SDL printer (RFC 0005 §6.7, §7.3).\n *\n * Prints a schema model (the data of `metadata.extensions.graphql`, without its functions) exactly\n * like graphql-js 17 `printSchema()` prints the `GraphQLSchema` the runtime builds from it: same\n * order, same block strings, same default value literals, byte for byte. The compiler hashes this\n * output (`schemaHash`) and writes it as the optional SDL artifact; the runtime can print without\n * graphql-js.\n *\n * Import-free (types and constants of import-free modules only): shared by the compiler extension\n * and the runtime. Equivalence holds when the runtime builds the schema the way this module\n * assumes:\n *\n * - every type of the model passed to `new GraphQLSchema({ types })` in model order (metadata types\n * are sorted by name), so the type map, hence `printSchema`, follows that order;\n * - default values passed as `default: { value }` (external values: enum values by name), printed\n * by graphql-js through `valueToLiteral`;\n * - built-in scalars (`names.ts`) without description, with their `specifiedByURL`, and no scalar\n * with a custom `valueToLiteral` used in a default value.\n */\nimport { BUILTIN_SCALARS, DEFAULT_DEPRECATION_REASON, ROOT_TYPE_NAMES, SPECIFIED_SCALARS } from './names.ts'\nimport { type GraphQLTypeRef, parseTypeRef } from './type-ref.ts'\n\n/** The schema to print: the shape of `GraphQLMetadata` without resolvers nor scalar implementations. */\nexport interface SdlSchema {\n readonly roots: SdlRoots\n /** Printed in this order (graphql-js specified scalars are skipped). */\n readonly types: readonly SdlType[]\n}\n\n/** Names of the root operation types. */\nexport interface SdlRoots {\n readonly query: string\n readonly mutation?: string\n readonly subscription?: string\n}\n\n/** A named type of the schema. */\nexport type SdlType = SdlObjectType | SdlInterfaceType | SdlInputType | SdlEnumType | SdlUnionType | SdlScalarType\n\n/** What every named type has. */\nexport interface SdlNamedType {\n readonly name: string\n readonly description?: string\n}\n\n/** An object type (`type Book { ... }`). */\nexport interface SdlObjectType extends SdlNamedType {\n readonly kind: 'object'\n /** Implemented interfaces, in declaration order. */\n readonly interfaces?: readonly string[]\n readonly fields: readonly SdlField[]\n}\n\n/** An interface type (`interface Node { ... }`). */\nexport interface SdlInterfaceType extends SdlNamedType {\n readonly kind: 'interface'\n readonly interfaces?: readonly string[]\n readonly fields: readonly SdlField[]\n}\n\n/** A field of an object type. */\nexport interface SdlField {\n readonly name: string\n /** Type reference (`'[Book!]!'`). */\n readonly type: string\n readonly description?: string\n readonly deprecationReason?: string\n readonly args?: readonly SdlInputValue[]\n}\n\n/** An argument or an input field. */\nexport interface SdlInputValue {\n readonly name: string\n readonly type: string\n readonly description?: string\n readonly deprecationReason?: string\n /** External value (JSON-compatible, enum values by name); `undefined`: no default. */\n readonly defaultValue?: unknown\n}\n\n/** An input object type (`input NewBookInput { ... }`). */\nexport interface SdlInputType extends SdlNamedType {\n readonly kind: 'input'\n readonly fields: readonly SdlInputValue[]\n}\n\n/** An enum type. */\nexport interface SdlEnumType extends SdlNamedType {\n readonly kind: 'enum'\n readonly values: readonly SdlEnumValue[]\n}\n\n/** A value of an enum type. */\nexport interface SdlEnumValue {\n readonly name: string\n readonly description?: string\n readonly deprecationReason?: string\n}\n\n/** A union type. */\nexport interface SdlUnionType extends SdlNamedType {\n readonly kind: 'union'\n readonly members: readonly string[]\n}\n\n/** A scalar type: a built-in one of `@znight/graphql` (`builtin: true`) or a user scalar. */\nexport interface SdlScalarType extends SdlNamedType {\n readonly kind: 'scalar'\n readonly builtin?: boolean\n /** `@specifiedBy(url:)`. Built-in scalars default to the URL of `BUILTIN_SCALARS`. */\n readonly specifiedByURL?: string\n}\n\n/**\n * Prints the SDL of a schema, without a trailing newline (like `printSchema`). Throws an `Error` on\n * a malformed type reference or a default value that does not match its type (the compiler reports\n * these as diagnostics before printing).\n */\nexport function printSdl(schema: SdlSchema): string {\n const types = new Map<string, SdlType>()\n for (const type of schema.types) types.set(type.name, type)\n const printer = new SdlPrinter(types)\n const parts: string[] = []\n const definition = printSchemaDefinition(schema.roots, types)\n if (definition !== undefined) parts.push(definition)\n for (const type of schema.types) {\n if (!SPECIFIED_SCALARS.has(type.name)) parts.push(printer.type(type))\n }\n return parts.join('\\n\\n')\n}\n\n/** `schema { ... }`, only when the root types do not have their default names (as graphql-js). */\nfunction printSchemaDefinition(roots: SdlRoots, types: ReadonlyMap<string, SdlType>): string | undefined {\n // graphql-js compares `getQueryType() == getType('Query')` (and so on): a missing root equals a\n // missing type of the default name.\n const isDefault = (root: string | undefined, name: string): boolean =>\n root === undefined ? !types.has(name) : root === name\n if (\n isDefault(roots.query, ROOT_TYPE_NAMES.query) &&\n isDefault(roots.mutation, ROOT_TYPE_NAMES.mutation) &&\n isDefault(roots.subscription, ROOT_TYPE_NAMES.subscription)\n ) {\n return undefined\n }\n return (\n 'schema {\\n' +\n ` query: ${roots.query}\\n` +\n (roots.mutation === undefined ? '' : ` mutation: ${roots.mutation}\\n`) +\n (roots.subscription === undefined ? '' : ` subscription: ${roots.subscription}\\n`) +\n '}'\n )\n}\n\n/** A GraphQL value literal (the subset of graphql-js `ConstValueNode` defaults can produce). */\ntype Literal =\n | { readonly kind: 'IntValue' | 'FloatValue' | 'StringValue' | 'EnumValue'; readonly value: string }\n | { readonly kind: 'BooleanValue'; readonly value: boolean }\n | { readonly kind: 'NullValue' }\n | { readonly kind: 'ListValue'; readonly values: readonly Literal[] }\n | { readonly kind: 'ObjectValue'; readonly fields: readonly (readonly [name: string, value: Literal])[] }\n\nconst GRAPHQL_MAX_INT = 2_147_483_647\nconst GRAPHQL_MIN_INT = -2_147_483_648\nconst INTEGER_STRING = /^-?(?:0|[1-9][0-9]*)$/\n/** graphql-js `print()` breaks lists and objects longer than this. */\nconst MAX_LINE_LENGTH = 80\n\nclass SdlPrinter {\n readonly #types: ReadonlyMap<string, SdlType>\n\n constructor(types: ReadonlyMap<string, SdlType>) {\n this.#types = types\n }\n\n type(type: SdlType): string {\n const head = printDescription(type.description, '', true)\n switch (type.kind) {\n case 'object':\n case 'interface':\n return `${head}${type.kind === 'object' ? 'type' : 'interface'} ${type.name}${printImplements(type.interfaces)}${printBlock(type.fields.map((field, i) => this.#field(type.name, field, i)))}`\n case 'input':\n return `${head}input ${type.name}${printBlock(\n type.fields.map(\n (field, i) =>\n `${printDescription(field.description, ' ', i === 0)} ${this.#inputValue(field, `${type.name}.${field.name}`)}`,\n ),\n )}`\n case 'enum':\n return `${head}enum ${type.name}${printBlock(\n type.values.map(\n (value, i) =>\n `${printDescription(value.description, ' ', i === 0)} ${value.name}${printDeprecated(value.deprecationReason)}`,\n ),\n )}`\n case 'union':\n return `${head}union ${type.name}${type.members.length === 0 ? '' : ` = ${type.members.join(' | ')}`}`\n case 'scalar': {\n const url =\n type.specifiedByURL ?? (type.builtin === true ? BUILTIN_SCALARS.get(type.name)?.specifiedByURL : undefined)\n return `${head}scalar ${type.name}${url === undefined ? '' : ` @specifiedBy(url: ${printString(url)})`}`\n }\n }\n }\n\n #field(typeName: string, field: SdlField, index: number): string {\n const coordinate = `${typeName}.${field.name}`\n return (\n `${printDescription(field.description, ' ', index === 0)} ${field.name}` +\n this.#args(coordinate, field.args ?? []) +\n `: ${checkedTypeRef(field.type, coordinate)}${printDeprecated(field.deprecationReason)}`\n )\n }\n\n #args(coordinate: string, args: readonly SdlInputValue[]): string {\n if (args.length === 0) return ''\n if (args.every(arg => arg.description === undefined)) {\n return `(${args.map(arg => this.#inputValue(arg, `${coordinate}(${arg.name}:)`)).join(', ')})`\n }\n const lines = args.map(\n (arg, i) =>\n `${printDescription(arg.description, ' ', i === 0)} ${this.#inputValue(arg, `${coordinate}(${arg.name}:)`)}`,\n )\n return `(\\n${lines.join('\\n')}\\n )`\n }\n\n #inputValue(value: SdlInputValue, coordinate: string): string {\n const ref = parseTypeRef(value.type)\n if (ref === undefined) throw new Error(`Invalid type reference '${value.type}' (${coordinate})`)\n let declaration = `${value.name}: ${value.type}`\n if (value.defaultValue !== undefined) {\n const literal = this.#literal(value.defaultValue, ref)\n if (literal === undefined) {\n throw new Error(`Invalid default value for ${coordinate}: ${describe(value.defaultValue)}`)\n }\n declaration += ` = ${printLiteral(literal)}`\n }\n return declaration + printDeprecated(value.deprecationReason)\n }\n\n /** graphql-js `valueToLiteral(value, type)`: `undefined` when the value does not fit the type. */\n #literal(value: unknown, ref: GraphQLTypeRef): Literal | undefined {\n if (ref.nonNull && value == null) return undefined\n if (value == null) return { kind: 'NullValue' }\n if (ref.kind === 'list') {\n const item: GraphQLTypeRef = ref.of\n if (!isIterableObject(value)) return this.#literal(value, item)\n const values: Literal[] = []\n for (const entry of value) {\n const literal = this.#literal(entry, item)\n if (literal === undefined) return undefined\n values.push(literal)\n }\n return { kind: 'ListValue', values }\n }\n const type = this.#types.get(ref.name)\n if (type?.kind === 'input') return this.#inputLiteral(value, type)\n if (type?.kind === 'enum') {\n return typeof value === 'string' && type.values.some(entry => entry.name === value)\n ? { kind: 'EnumValue', value }\n : undefined\n }\n return scalarLiteral(value, ref.name)\n }\n\n #inputLiteral(value: unknown, type: SdlInputType): Literal | undefined {\n if (typeof value !== 'object' || value === null) return undefined\n const record = value as Readonly<Record<string, unknown>>\n for (const key of Object.keys(record)) {\n if (record[key] !== undefined && !type.fields.some(field => field.name === key)) return undefined\n }\n const fields: (readonly [string, Literal])[] = []\n for (const field of type.fields) {\n const fieldValue = Object.hasOwn(record, field.name) ? record[field.name] : undefined\n const ref = parseTypeRef(field.type)\n if (ref === undefined) return undefined\n if (fieldValue === undefined) {\n // required input field: non-null without default\n if (ref.nonNull && field.defaultValue === undefined) return undefined\n continue\n }\n const literal = this.#literal(fieldValue, ref)\n if (literal === undefined) return undefined\n fields.push([field.name, literal])\n }\n return { kind: 'ObjectValue', fields }\n }\n}\n\n/** graphql-js `printImplementedInterfaces`. */\nfunction printImplements(interfaces: readonly string[] | undefined): string {\n return interfaces === undefined || interfaces.length === 0 ? '' : ` implements ${interfaces.join(' & ')}`\n}\n\n/** The `valueToLiteral` of the specified scalars, and graphql-js' default one for the others. */\nfunction scalarLiteral(value: unknown, name: string): Literal | undefined {\n switch (name) {\n case 'Int': {\n const integer = (typeof value === 'number' && Number.isInteger(value)) || typeof value === 'bigint'\n return integer && value <= GRAPHQL_MAX_INT && value >= GRAPHQL_MIN_INT\n ? { kind: 'IntValue', value: String(value) }\n : undefined\n }\n case 'Float': {\n // graphql-js wraps the `valueToLiteral` of a scalar in a try/catch: a value it cannot convert\n // (a function) is a mismatch, not a crash\n try {\n const literal = defaultScalarLiteral(value)\n return literal.kind === 'FloatValue' || literal.kind === 'IntValue' ? literal : undefined\n } catch {\n return undefined\n }\n }\n case 'String':\n return typeof value === 'string' ? { kind: 'StringValue', value } : undefined\n case 'Boolean':\n return typeof value === 'boolean' ? { kind: 'BooleanValue', value } : undefined\n case 'ID':\n if (typeof value === 'string') {\n return INTEGER_STRING.test(value) ? { kind: 'IntValue', value } : { kind: 'StringValue', value }\n }\n if (typeof value === 'number')\n return Number.isInteger(value) ? { kind: 'IntValue', value: String(value) } : undefined\n return typeof value === 'bigint' ? { kind: 'IntValue', value: String(value) } : undefined\n default:\n return defaultScalarLiteral(value)\n }\n}\n\n/** graphql-js `defaultScalarValueToLiteral`. */\nfunction defaultScalarLiteral(value: unknown): Literal {\n if (value == null) return { kind: 'NullValue' }\n switch (typeof value) {\n case 'boolean':\n return { kind: 'BooleanValue', value }\n case 'string':\n return { kind: 'StringValue', value }\n case 'bigint':\n return { kind: 'IntValue', value: value.toString() }\n case 'number': {\n if (!Number.isFinite(value)) return { kind: 'NullValue' }\n const text = String(value)\n return INTEGER_STRING.test(text) ? { kind: 'IntValue', value: text } : { kind: 'FloatValue', value: text }\n }\n case 'object': {\n if (isIterableObject(value)) return { kind: 'ListValue', values: Array.from(value, defaultScalarLiteral) }\n const record = value as Readonly<Record<string, unknown>>\n const fields: (readonly [string, Literal])[] = []\n for (const key of Object.keys(record)) {\n if (record[key] !== undefined) fields.push([key, defaultScalarLiteral(record[key])])\n }\n return { kind: 'ObjectValue', fields }\n }\n default:\n throw new TypeError(`Cannot convert value to AST: ${describe(value)}.`)\n }\n}\n\nfunction isIterableObject(value: unknown): value is Iterable<unknown> {\n return (\n typeof value === 'object' && value !== null && typeof (value as Iterable<unknown>)[Symbol.iterator] === 'function'\n )\n}\n\n/** graphql-js `print()` of a value literal. */\nfunction printLiteral(literal: Literal): string {\n switch (literal.kind) {\n case 'IntValue':\n case 'FloatValue':\n case 'EnumValue':\n return literal.value\n case 'StringValue':\n return printString(literal.value)\n case 'BooleanValue':\n return literal.value ? 'true' : 'false'\n case 'NullValue':\n return 'null'\n case 'ListValue': {\n const values = literal.values.map(printLiteral)\n const line = `[${values.join(', ')}]`\n return line.length > MAX_LINE_LENGTH ? `[\\n${indent(values.join('\\n'))}\\n]` : line\n }\n case 'ObjectValue': {\n const fields = literal.fields.map(([name, value]) => `${name}: ${printLiteral(value)}`)\n const line = `{ ${fields.join(', ')} }`\n if (line.length <= MAX_LINE_LENGTH) return line\n const body = indent(fields.join('\\n'))\n return body === '' ? '' : `{\\n${body}\\n}`\n }\n }\n}\n\n/** graphql-js `indent()` of the printer. */\nfunction indent(text: string): string {\n return text === '' ? '' : ` ${text.replaceAll('\\n', '\\n ')}`\n}\n\nfunction printBlock(items: readonly string[]): string {\n return items.length === 0 ? '' : ` {\\n${items.join('\\n')}\\n}`\n}\n\nfunction printDeprecated(reason: string | undefined): string {\n if (reason === undefined) return ''\n return reason === DEFAULT_DEPRECATION_REASON ? ' @deprecated' : ` @deprecated(reason: ${printString(reason)})`\n}\n\n/** graphql-js `printDescription()` of `printSchema`. */\nfunction printDescription(description: string | undefined, indentation: string, firstInBlock: boolean): string {\n if (description === undefined) return ''\n const text = isPrintableAsBlockString(description) ? printBlockString(description) : printString(description)\n const prefix = indentation !== '' && !firstInBlock ? `\\n${indentation}` : indentation\n return `${prefix}${text.replaceAll('\\n', `\\n${indentation}`)}\\n`\n}\n\nfunction checkedTypeRef(type: string, coordinate: string): string {\n if (parseTypeRef(type) === undefined) throw new Error(`Invalid type reference '${type}' (${coordinate})`)\n return type\n}\n\nfunction describe(value: unknown): string {\n if (value === undefined) return 'undefined'\n if (typeof value === 'bigint') return `${value}n`\n if (typeof value === 'number' && !Number.isFinite(value)) return String(value)\n try {\n return JSON.stringify(value) ?? String(value)\n } catch {\n return String(value)\n }\n}\n\n// --- graphql-js string printers (language/printString.ts, language/blockString.ts) ---\n\n/** `\\t` and space: the GraphQL `WhiteSpace` characters. */\nfunction isWhiteSpace(code: number): boolean {\n return code === 0x09 || code === 0x20\n}\n\n/** Escape sequence of each code unit graphql-js escapes in a string value. */\nconst ESCAPES: readonly string[] = Array.from({ length: 0xa0 }, (_, code) => {\n switch (code) {\n case 0x08:\n return '\\\\b'\n case 0x09:\n return '\\\\t'\n case 0x0a:\n return '\\\\n'\n case 0x0c:\n return '\\\\f'\n case 0x0d:\n return '\\\\r'\n case 0x22:\n return '\\\\\"'\n case 0x5c:\n return '\\\\\\\\'\n default:\n return code < 0x20 || code >= 0x7f ? `\\\\u${code.toString(16).toUpperCase().padStart(4, '0')}` : ''\n }\n})\n// biome-ignore lint/suspicious/noControlCharactersInRegex: graphql-js escapes exactly these code units\nconst ESCAPED = /[\\x00-\\x1f\\x22\\x5c\\x7f-\\x9f]/g\n\n/** A GraphQL string value (`\"...\"`), escaped like graphql-js `printString`. */\nexport function printString(value: string): string {\n return `\"${value.replace(ESCAPED, char => ESCAPES[char.charCodeAt(0)] ?? char)}\"`\n}\n\n/** graphql-js `isPrintableAsBlockString`. */\nfunction isPrintableAsBlockString(value: string): boolean {\n if (value === '') return true\n let isEmptyLine = true\n let hasIndent = false\n let hasCommonIndent = true\n let seenNonEmptyLine = false\n for (let i = 0; i < value.length; ++i) {\n switch (value.codePointAt(i)) {\n case 0x0000:\n case 0x0001:\n case 0x0002:\n case 0x0003:\n case 0x0004:\n case 0x0005:\n case 0x0006:\n case 0x0007:\n case 0x0008:\n case 0x000b:\n case 0x000c:\n case 0x000e:\n case 0x000f:\n case 0x000d:\n return false\n case 0x000a:\n if (isEmptyLine && !seenNonEmptyLine) return false\n seenNonEmptyLine = true\n isEmptyLine = true\n hasIndent = false\n break\n case 0x0009:\n case 0x0020:\n hasIndent ||= isEmptyLine\n break\n default:\n hasCommonIndent &&= hasIndent\n isEmptyLine = false\n }\n }\n if (isEmptyLine) return false\n if (hasCommonIndent && seenNonEmptyLine) return false\n return true\n}\n\n/** A GraphQL block string (`\"\"\"...\"\"\"`), laid out like graphql-js `printBlockString`. */\nexport function printBlockString(value: string): string {\n const escaped = value.replaceAll('\"\"\"', '\\\\\"\"\"')\n const lines = escaped.split(/\\r\\n|[\\n\\r]/g)\n const isSingleLine = lines.length === 1\n const forceLeadingNewLine =\n lines.length > 1 && lines.slice(1).every(line => line.length === 0 || isWhiteSpace(line.charCodeAt(0)))\n const hasTrailingTripleQuotes = escaped.endsWith('\\\\\"\"\"')\n const hasTrailingQuote = value.endsWith('\"') && !hasTrailingTripleQuotes\n const hasTrailingSlash = value.endsWith('\\\\')\n const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash\n const printAsMultipleLines =\n !isSingleLine || value.length > 70 || forceTrailingNewline || forceLeadingNewLine || hasTrailingTripleQuotes\n let result = ''\n const skipLeadingNewLine = isSingleLine && isWhiteSpace(value.charCodeAt(0))\n if ((printAsMultipleLines && !skipLeadingNewLine) || forceLeadingNewLine) result += '\\n'\n result += escaped\n if (printAsMultipleLines || forceTrailingNewline) result += '\\n'\n return `\"\"\"${result}\"\"\"`\n}\n","/**\n * Checks shared by the code-first schema builder (`builder.ts`) and the schema-first one\n * (`schema-first.ts`): loader providers (ZNIGHT065) and the route decisions of root fields\n * (ZNIGHT023, RFC 0001).\n */\nimport type { ClassInfo, Diagnostic, Location, ValidateContext } from '@znight/compiler'\nimport type { MetaEntry } from '@znight/http/compiler'\nimport type { GraphQLData, ResolverData } from './data.ts'\n\nimport { requiredRouteGroups } from '@znight/http/compiler'\n\nimport { ROOT_TYPE_NAMES } from '../names.ts'\nimport { Codes } from './constants.ts'\nimport { GraphQLIds } from './ids.ts'\n\ntype Context = ValidateContext<GraphQLData>\ntype Report = (diagnostic: Diagnostic) => void\n\n/** `Loader<L>`: `L` must be a loader provider, implementing `BatchLoad<K, V>` (ZNIGHT065). */\nexport function checkLoaders(ctx: Context, resolvers: readonly ResolverData[], report: Report): void {\n const seen = new Set<number>()\n for (const resolver of resolvers) {\n for (const field of resolver.fields) {\n for (const param of field.params) {\n if (param?.kind !== 'loader' || seen.has(param.binding.id)) continue\n seen.add(param.binding.id)\n const ref = ctx.binding(param.binding)\n const token = tokenOfRef(ref)\n const provider = token === undefined ? undefined : ctx.provider(token)\n // an unbound loader is ZNIGHT001 (reported by the binding)\n if (provider === undefined || provider.heritage.some(type => type.identity === GraphQLIds.BatchLoad)) continue\n if (provider.kind !== 'class' || hasLoadMethod(ctx, provider.classIdentity)) continue\n report({\n code: Codes.InvalidLoader,\n severity: 'error',\n message: `${provider.displayName} is not a loader: Loader<${provider.displayName}> needs a provider implementing BatchLoad<K, V> (${resolver.host.displayName}.${field.method})`,\n location: param.location,\n hints: [\n `export class ${provider.displayName} implements BatchLoad<ID, Value> { async load(keys: readonly ID[]): Promise<readonly (Value | Error)[]> { ... } }`,\n ],\n })\n }\n }\n }\n}\n\n/**\n * RFC 0001: every root field decides every required route decorator group (ZNIGHT023). `roots`\n * names the root types (`schema { query: RootQuery }` in schema-first).\n */\nexport function checkDecisions(\n ctx: Context,\n resolvers: readonly ResolverData[],\n report: Report,\n roots: { readonly query: string; readonly mutation?: string; readonly subscription?: string } = ROOT_TYPE_NAMES,\n): void {\n const applied: MetaEntry[] = []\n for (const resolver of resolvers) for (const field of resolver.fields) applied.push(...field.meta)\n const required = requiredRouteGroups(ctx, applied)\n if (required.length === 0) return\n for (const resolver of resolvers) {\n for (const field of resolver.fields) {\n if (field.operation === 'field') continue\n const decided = new Set(field.meta.map(entry => entry.group))\n for (const group of required) {\n if (decided.has(group.group)) continue\n const root = roots[field.operation] ?? ROOT_TYPE_NAMES[field.operation]\n report({\n code: Codes.MissingRouteDecision,\n severity: 'error',\n message: `Root field ${root}.${field.name} (${resolver.host.displayName}.${field.method}) has no \"${group.group}\" decision`,\n location: field.methodLocation,\n hints: [`Add ${group.suggestion} to the method or to ${resolver.host.displayName}`],\n related: [\n {\n message: `The \"${group.group}\" group is required`,\n location: (group.decorators[0] as { definition: Location }).definition,\n },\n ],\n })\n }\n }\n }\n}\n\n/** The class (or one of its base classes) declares an instance `load` method. */\nfunction hasLoadMethod(ctx: Context, identity: string): boolean {\n const seen = new Set<string>()\n let current: string | undefined = identity\n while (current !== undefined && !seen.has(current)) {\n seen.add(current)\n const cls: ClassInfo | undefined = ctx.classInfo(current)\n if (cls === undefined) return true // not analysable (a compiled class): trust the type checker\n if (cls.methods.some(method => method.name === 'load' && method.kind === 'method' && !method.static)) return true\n if (cls.properties.some(property => property.name === 'load' && !property.static)) return true\n current = cls.superClass?.identity\n }\n return false\n}\n\n/** The token of a binding result (`undefined` when binding failed). */\nfunction tokenOfRef(ref: ReturnType<Context['binding']>): string | undefined {\n if (typeof ref === 'string') return ref\n return ref !== undefined && 'token' in ref ? ref.token : undefined\n}\n","/**\n * Default values of arguments and input fields (RFC 0005 §6.3): an internal value (a `@default`\n * JSON value, a statically evaluated parameter default) checked against its GraphQL type and turned\n * into the external value graphql-js expects (`default: { value }`, enum values by name).\n */\nimport type { GraphQLTypeRef } from '../type-ref.ts'\nimport type { TypeModel } from './model.ts'\n\nconst GRAPHQL_INT_MAX = 2_147_483_647\nconst GRAPHQL_INT_MIN = -2_147_483_648\n\n/** The external value, or why the value does not fit the type. */\nexport type ExternalValue = { readonly value: unknown } | { readonly error: string }\n\n/** `value` (an internal value) as a GraphQL external value of `ref`; `types` resolves enums and inputs. */\nexport function externalValue(\n value: unknown,\n ref: GraphQLTypeRef,\n types: ReadonlyMap<string, TypeModel>,\n): ExternalValue {\n if (value === null) return ref.nonNull ? { error: 'null for a non-null type' } : { value: null }\n if (value === undefined) return { error: 'undefined' }\n if (ref.kind === 'list') {\n if (!Array.isArray(value)) return externalValue(value, ref.of, types)\n const items: unknown[] = []\n for (const item of value) {\n const converted = externalValue(item, ref.of, types)\n if ('error' in converted) return converted\n items.push(converted.value)\n }\n return { value: items }\n }\n switch (ref.name) {\n case 'String':\n return typeof value === 'string' ? { value } : { error: 'expected a string' }\n case 'ID':\n return typeof value === 'string' || (typeof value === 'number' && Number.isInteger(value))\n ? { value }\n : { error: 'expected a string or an integer' }\n case 'Int':\n return typeof value === 'number' &&\n Number.isInteger(value) &&\n value <= GRAPHQL_INT_MAX &&\n value >= GRAPHQL_INT_MIN\n ? { value }\n : { error: 'expected a 32-bit integer' }\n case 'Float':\n return typeof value === 'number' && Number.isFinite(value) ? { value } : { error: 'expected a finite number' }\n case 'Boolean':\n return typeof value === 'boolean' ? { value } : { error: 'expected a boolean' }\n case 'JSON':\n return isJson(value) ? { value } : { error: 'expected a JSON value' }\n }\n const type = types.get(ref.name)\n if (type?.kind === 'enum') {\n const found =\n type.values.find(entry => entry.value === value) ??\n (typeof value === 'string' ? type.values.find(entry => entry.name === value) : undefined)\n return found === undefined\n ? { error: `expected one of ${type.values.map(entry => entry.name).join(', ')}` }\n : { value: found.name }\n }\n if (type?.kind === 'input') {\n if (typeof value !== 'object' || Array.isArray(value)) return { error: `expected an object of type ${type.name}` }\n const record = value as Readonly<Record<string, unknown>>\n for (const key of Object.keys(record)) {\n if (!type.fields.some(field => field.name === key)) return { error: `${type.name} has no field '${key}'` }\n }\n const result: Record<string, unknown> = {}\n for (const field of type.fields) {\n if (!Object.hasOwn(record, field.name) || record[field.name] === undefined) {\n if (field.ref.nonNull && field.defaultValue === undefined)\n return { error: `${type.name}.${field.name} is required` }\n continue\n }\n const converted = externalValue(record[field.name], field.ref, types)\n if ('error' in converted) return { error: `${type.name}.${field.name}: ${converted.error}` }\n result[field.name] = converted.value\n }\n return { value: result }\n }\n return { error: `defaults of the scalar ${ref.name} are not supported` }\n}\n\n/** A JSON-compatible value (the `JSON` scalar). */\nfunction isJson(value: unknown): boolean {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return true\n if (typeof value === 'number') return Number.isFinite(value)\n if (Array.isArray(value)) return value.every(isJson)\n if (typeof value !== 'object') return false\n return Object.values(value).every(isJson)\n}\n","/**\n * Union discriminators (RFC 0005 §5.7): how the runtime tells the members of a union apart, decided\n * at build time so that `resolveType` is a lookup.\n */\nimport type { ClassInfo } from '@znight/compiler'\nimport type { DiscriminatorModel, ObjectModel } from './model.ts'\n\nimport { compareStrings } from './constants.ts'\n\n/**\n * `instanceof` when every member is an exported class (subclasses first), `__typename` when every\n * member declares it, else the first property of the first member whose literal value differs in\n * every member; `undefined` when none applies (ZNIGHT064).\n */\nexport function discriminatorOf(\n members: readonly ObjectModel[],\n classInfo: (identity: string) => ClassInfo | undefined,\n): DiscriminatorModel | undefined {\n if (members.every(member => member.classIdentity !== undefined && classInfo(member.classIdentity)?.exported)) {\n const depth = (identity: string): number => classInfo(identity)?.heritage.length ?? 0\n return {\n by: 'class',\n classes: members\n .map(member => ({ identity: member.classIdentity as string, name: member.name }))\n // subclasses first: `instanceof` of a base class also matches its subclasses\n .sort((a, b) => depth(b.identity) - depth(a.identity) || compareStrings(a.name, b.name)),\n }\n }\n if (members.every(member => member.properties.some(property => property.name === '__typename'))) {\n return { by: 'typename' }\n }\n for (const candidate of members[0]?.properties ?? []) {\n if (candidate.optional || candidate.literal === undefined) continue\n const values = literalValues(members, candidate.name)\n if (values !== undefined) return { by: 'property', property: candidate.name, values }\n }\n return undefined\n}\n\n/** Literal value → member name when `property` is a required literal with a distinct value in every member. */\nfunction literalValues(members: readonly ObjectModel[], property: string): Record<string, string> | undefined {\n const values = new Map<string, string>()\n for (const member of members) {\n const found = member.properties.find(entry => entry.name === property)\n if (found === undefined || found.optional || found.literal === undefined) return undefined\n const key = String(found.literal)\n if (values.has(key)) return undefined\n values.set(key, member.name)\n }\n const sorted: Record<string, string> = {}\n for (const key of [...values.keys()].sort(compareStrings)) sorted[key] = values.get(key) as string\n return sorted\n}\n","/**\n * The JSDoc vocabulary of the extension (RFC 0005 §5.14): descriptions, `@param`, `@deprecated`,\n * `@default`, `@gqlHidden` and `@gqlName`.\n */\nimport type { DocComment, DocTag } from '@znight/compiler'\n\nimport { DEFAULT_DEPRECATION_REASON } from '../names.ts'\n\n/** The comment text (before the first tag), `undefined` when empty. */\nexport function descriptionOf(doc: DocComment | undefined): string | undefined {\n return doc === undefined || doc.text === '' ? undefined : doc.text\n}\n\n/** The first tag named `name`. */\nexport function tagOf(doc: DocComment | undefined, name: string): DocTag | undefined {\n return doc?.tags.find(tag => tag.name === name)\n}\n\n/** `@deprecated reason`: the reason (graphql-js' default one without text), `undefined` without the tag. */\nexport function deprecationOf(doc: DocComment | undefined): string | undefined {\n const tag = tagOf(doc, 'deprecated')\n if (tag === undefined) return undefined\n const reason = tag.text.trim()\n return reason === '' ? DEFAULT_DEPRECATION_REASON : reason\n}\n\n/** `true` with a `@gqlHidden` tag. */\nexport function isHidden(doc: DocComment | undefined): boolean {\n return tagOf(doc, 'gqlHidden') !== undefined\n}\n\n/**\n * The text of `@param name text` (also `@param {Type} name - text`), `undefined` when there is no\n * such tag or it has no text.\n */\nexport function paramDescription(doc: DocComment | undefined, name: string): string | undefined {\n for (const tag of doc?.tags ?? []) {\n if (tag.name !== 'param') continue\n const match = /^(?:\\{[^}]*\\}\\s*)?\\[?([\\w$]+)(?:=[^\\]]*)?\\]?(?:\\s+-)?(?:\\s+([\\s\\S]*))?$/.exec(tag.text.trim())\n if (match?.[1] !== name) continue\n const text = match[2]?.trim()\n return text === undefined || text === '' ? undefined : text\n }\n return undefined\n}\n\n/** A `@default` value: JSON when it parses, the text otherwise (`@default title`). */\nexport function defaultTagValue(tag: DocTag): unknown {\n const text = tag.text.trim()\n try {\n return JSON.parse(text) as unknown\n } catch {\n return text\n }\n}\n","/**\n * Source locations of diagnostics. Computed only when a diagnostic is reported: the happy path\n * never reads source text.\n */\nimport type { Location, MethodInfo, Project } from '@znight/compiler'\n\n/** From the member name: `name?: ` or `name(): ` (a getter), up to the annotation. */\nconst MEMBER_HEAD = /^(?:[\\w$]+|'[^']*'|\"[^\"]*\")\\s*\\??\\s*(?:\\(\\s*\\))?\\s*:\\s*/\n\nconst OPENING = new Set(['(', '[', '{', '<'])\nconst CLOSING = new Set([')', ']', '}', '>'])\n\n/**\n * The type annotation of a property, a property signature or a getter (`get x(): T`), from the\n * location of the member (its name); the member itself when the annotation cannot be found.\n */\nexport function annotationLocation(project: Project, member: Location | undefined): Location | undefined {\n if (member === undefined) return undefined\n const file = project.getFile(member.file)\n if (file === undefined) return member\n const text = file.text\n const head = MEMBER_HEAD.exec(text.slice(member.start, member.start + 256))\n if (head === null) return member\n const start = member.start + head[0].length\n let depth = 0\n let end = start\n for (let index = start; index < text.length; index++) {\n const char = text[index] as string\n if (char === '=' && text[index + 1] === '>') {\n index++\n continue\n }\n // a getter body or an initializer after the annotation\n if (depth === 0 && end > start && (char === '{' || char === '=')) break\n if (OPENING.has(char)) depth++\n else if (CLOSING.has(char)) {\n if (depth === 0) break\n depth--\n } else if (depth === 0 && (char === ';' || char === ',')) break\n else if (depth === 0 && char === '\\n' && !/^\\s*[|&]/.test(text.slice(index + 1, index + 64))) break\n if (!/\\s/.test(char)) end = index + 1\n }\n return end > start ? file.location({ start, end }) : member\n}\n\n/**\n * The return type annotation of a method, from the location of its name: after the parameter list\n * (balanced brackets), `: T` up to the body; `undefined` when it cannot be found.\n */\nexport function returnTypeLocation(project: Project, method: MethodInfo): Location | undefined {\n const file = project.getFile(method.location.file)\n if (file === undefined) return undefined\n const text = file.text\n let index = text.indexOf('(', method.location.end)\n if (index === -1) return undefined\n let depth = 0\n for (; index < text.length; index++) {\n const char = text[index] as string\n if (OPENING.has(char)) depth++\n else if (CLOSING.has(char) && --depth === 0) break\n }\n const head = /^\\s*:\\s*/.exec(text.slice(index + 1, index + 64))\n if (head === null) return undefined\n const start = index + 1 + head[0].length\n let end = start\n depth = 0\n for (let cursor = start; cursor < text.length; cursor++) {\n const char = text[cursor] as string\n if (char === '=' && text[cursor + 1] === '>') {\n cursor++\n continue\n }\n if (depth === 0 && (char === '{' || char === ';') && end > start) break\n if (OPENING.has(char)) depth++\n else if (CLOSING.has(char)) {\n if (depth === 0) break\n depth--\n }\n if (!/\\s/.test(char)) end = cursor + 1\n }\n return end > start ? file.location({ start, end }) : undefined\n}\n","/**\n * `scalar<T>(name, definition)` declarations of the application (RFC 0005 §5.7): `T` (a plain type\n * reference, by identity) maps to the scalar `name` wherever it appears. The definition is an\n * exported value the generated module imports; its `description` and `specifiedByURL` are read\n * for the SDL when they are statically evaluable.\n */\nimport type { ArgInfo, Diagnostic, Location, ValidateContext } from '@znight/compiler'\nimport type { GraphQLData } from './data.ts'\n\nimport { isGraphQLName, SPECIFIED_SCALARS } from '../names.ts'\nimport { Codes } from './constants.ts'\nimport { GraphQLIds, SCALAR_ALIASES } from './ids.ts'\n\n/** A valid `scalar<T>()` declaration. */\nexport interface ScalarDeclaration {\n /** GraphQL name. */\n readonly name: string\n /** Identity of the exported constant (imported by the generated module). */\n readonly identity: string\n /** Identity of `T`. */\n readonly type: string\n readonly description: string | undefined\n readonly specifiedByURL: string | undefined\n /** Location of the constant's name. */\n readonly location: Location\n}\n\n/** Valid declarations by the identity of their type; invalid ones are reported. */\nexport function readScalars(\n ctx: ValidateContext<GraphQLData>,\n report: (diagnostic: Diagnostic) => void,\n): ReadonlyMap<string, ScalarDeclaration> {\n const byType = new Map<string, ScalarDeclaration>()\n const byName = new Map<string, ScalarDeclaration>()\n for (const definition of ctx.definitionsOf(GraphQLIds.scalar)) {\n const fail = (message: string, hints: readonly string[], related: Diagnostic['related'] = []): void =>\n report({ code: Codes.InvalidDecorator, severity: 'error', message, location: definition.call, hints, related })\n const [nameArg, definitionArg] = definition.args\n const name = nameArg?.evaluated === true ? nameArg.value : undefined\n if (typeof name !== 'string') {\n fail(`scalar() of ${definition.name} needs a static name`, [`scalar<T>('Name', { ... })`])\n continue\n }\n if (!isGraphQLName(name) || SPECIFIED_SCALARS.has(name)) {\n report({\n code: Codes.NameConflict,\n severity: 'error',\n message: SPECIFIED_SCALARS.has(name)\n ? `'${name}' is a specified GraphQL scalar: scalar() cannot redefine it (${definition.name})`\n : `'${name}' is not a valid GraphQL scalar name (${definition.name})`,\n location: nameArg?.location ?? definition.call,\n hints: ['GraphQL names match /^[_A-Za-z][_0-9A-Za-z]*$/ and do not start with __'],\n })\n continue\n }\n const type = definition.typeArgIdentities?.[0]\n if (type === undefined) {\n report({\n code: Codes.InvalidType,\n severity: 'error',\n message: `scalar('${name}') of ${definition.name} needs a named type argument: scalar<T>('${name}', ...)`,\n location: definition.call,\n hints: [\n `Name the TypeScript type of the scalar: export type ${name} = string & { readonly __brand: '${name}' }, then scalar<${name}>('${name}', ...)`,\n ],\n })\n continue\n }\n if (SCALAR_ALIASES.has(type)) {\n fail(\n `scalar('${name}') of ${definition.name} cannot map ${type.slice(type.indexOf('#') + 1)}: it is a built-in scalar alias`,\n ['Declare a branded type for the scalar: export type Name = string & { readonly __brand: \"Name\" }'],\n )\n continue\n }\n if (!definition.exported) {\n fail(`The scalar ${definition.name} must be exported: the generated module imports it`, [\n `export const ${definition.name} = scalar<...>('${name}', ...)`,\n ])\n continue\n }\n const declaration: ScalarDeclaration = {\n name,\n identity: definition.identity,\n type,\n description: staticProperty(ctx, definitionArg, 'description'),\n specifiedByURL: staticProperty(ctx, definitionArg, 'specifiedByURL'),\n location: definition.location,\n }\n const sameType = byType.get(type)\n if (sameType !== undefined) {\n report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `${definition.name} and ${sameType.identity} both map ${type.slice(type.indexOf('#') + 1)} to a scalar`,\n location: definition.location,\n related: [{ message: 'the other scalar', location: sameType.location }],\n hints: ['Keep one scalar per TypeScript type'],\n })\n continue\n }\n // a user scalar named like a built-in one (DateTime) only conflicts when both are used: the model reports it\n const sameName = byName.get(name)\n if (sameName !== undefined) {\n report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `Two scalars are named '${name}': ${definition.identity} and ${sameName.identity}`,\n location: definition.location,\n related: [{ message: 'the other scalar', location: sameName.location }],\n hints: ['Rename one of them'],\n })\n continue\n }\n byType.set(type, declaration)\n byName.set(name, declaration)\n }\n return byType\n}\n\n/** A string property of an object literal argument, when statically evaluable. */\nfunction staticProperty(ctx: ValidateContext<GraphQLData>, arg: ArgInfo | undefined, key: string): string | undefined {\n if (arg === undefined) return undefined\n if (arg.evaluated && typeof arg.value === 'object' && arg.value !== null && !Array.isArray(arg.value)) {\n const value = (arg.value as Readonly<Record<string, unknown>>)[key]\n return typeof value === 'string' ? value : undefined\n }\n const node = arg.node\n if (node.type !== 'ObjectExpression') return undefined\n for (const property of node.properties) {\n if (property.type !== 'Property' || property.computed) continue\n const name = property.key.type === 'Identifier' ? property.key.name : undefined\n if (name !== key) continue\n const result = ctx.project.evaluate(arg.location.file, property.value, { refs: 'none' })\n return result.kind === 'value' && typeof result.value === 'string' ? result.value : undefined\n }\n return undefined\n}\n","/**\n * The SDL view of the model (`sdl.ts` prints it), from which `schemaHash` and the SDL artifact\n * derive.\n */\nimport type { SdlInputValue, SdlType } from '../sdl.ts'\nimport type { ArgModel, TypeModel } from './model.ts'\n\n/** The SDL view of a model type. */\nexport function sdlType(model: TypeModel): SdlType {\n const base = model.description === undefined ? {} : { description: model.description }\n switch (model.kind) {\n case 'object':\n case 'interface':\n return {\n kind: model.kind,\n name: model.name,\n ...base,\n ...(model.interfaces.length === 0 ? {} : { interfaces: model.interfaces }),\n fields: model.fields.map(field => ({\n name: field.name,\n type: field.type,\n ...(field.description === undefined ? {} : { description: field.description }),\n ...(field.deprecationReason === undefined ? {} : { deprecationReason: field.deprecationReason }),\n ...(field.args.length === 0 ? {} : { args: field.args.map(sdlInputValue) }),\n })),\n }\n case 'input':\n return { kind: 'input', name: model.name, ...base, fields: model.fields.map(sdlInputValue) }\n case 'enum':\n return {\n kind: 'enum',\n name: model.name,\n ...base,\n values: model.values.map(value => ({\n name: value.name,\n ...(value.description === undefined ? {} : { description: value.description }),\n ...(value.deprecationReason === undefined ? {} : { deprecationReason: value.deprecationReason }),\n })),\n }\n case 'union':\n return { kind: 'union', name: model.name, ...base, members: model.members }\n case 'scalar':\n return {\n kind: 'scalar',\n name: model.name,\n ...base,\n ...(model.definition === undefined ? { builtin: true } : {}),\n ...(model.specifiedByURL === undefined ? {} : { specifiedByURL: model.specifiedByURL }),\n }\n }\n}\n\nfunction sdlInputValue(arg: ArgModel): SdlInputValue {\n return {\n name: arg.name,\n type: arg.type,\n ...(arg.description === undefined ? {} : { description: arg.description }),\n ...(arg.deprecationReason === undefined ? {} : { deprecationReason: arg.deprecationReason }),\n ...(arg.defaultValue === undefined ? {} : { defaultValue: arg.defaultValue }),\n }\n}\n","/**\n * The schema model (RFC 0005 §6.2–§6.6): starting from the root fields, every reachable TypeScript\n * type is read through the type shapes API (`ctx.types.shape()`, members `'instance'`, aliases kept\n * as named shapes) and mapped to a GraphQL type, row by row of the §6.2 table. Names follow §6.4,\n * objects, inputs and arguments §6.3; every problem is a diagnostic with a location, a hint and the\n * path from the root field (\"reached from Query.book → Book\").\n *\n * Built once per compile (`validate`), read by `generate`. Shapes are cached by the compiler per\n * options for the whole compile, so the walk only pays for what it visits once.\n */\nimport type {\n ClassInfo,\n Diagnostic,\n Location,\n MethodInfo,\n NamedShape,\n ParameterInfo,\n Shape,\n ShapeOptions,\n ShapeProperty,\n ShapeResult,\n ValidateContext,\n} from '@znight/compiler'\nimport type { MetaEntry } from '@znight/http/compiler'\nimport type { GraphQLTypeRef } from '../type-ref.ts'\nimport type { FieldData, GraphQLData, ResolverData } from './data.ts'\nimport type {\n ArgModel,\n DiscriminantProperty,\n DiscriminatorModel,\n EnumValueModel,\n FieldModel,\n GraphQLModel,\n InputModel,\n ObjectModel,\n ScalarModel,\n TypeModel,\n UnionModel,\n} from './model.ts'\nimport type { ResolvedGraphQLCompilerOptions } from './options.ts'\n\nimport { isGraphQLName, RESERVED_ENUM_VALUES, ROOT_TYPE_NAMES, SPECIFIED_SCALARS } from '../names.ts'\nimport { schemaHash } from '../schema-hash.ts'\nimport { printSdl } from '../sdl.ts'\nimport { printTypeRef } from '../type-ref.ts'\nimport { checkDecisions, checkLoaders } from './checks.ts'\nimport { ASYNC_ITERABLES, BASE_KEEP, Codes, compareStrings, OUTPUT_ITERABLES } from './constants.ts'\nimport { externalValue } from './defaults.ts'\nimport { discriminatorOf } from './discriminators.ts'\nimport { defaultTagValue, deprecationOf, descriptionOf, isHidden, paramDescription, tagOf } from './docs.ts'\nimport { SCALAR_ALIASES } from './ids.ts'\nimport { annotationLocation } from './locate.ts'\nimport { readScalars, type ScalarDeclaration } from './scalars.ts'\nimport { sdlType } from './sdl-view.ts'\n\ntype Context = ValidateContext<GraphQLData>\ntype Position = 'input' | 'output'\ntype Operation = 'query' | 'mutation' | 'subscription'\n\n/** Where a type is used: what diagnostics say and where they point. */\ninterface Use {\n readonly position: Position\n /** `Book.cover`, `Query.book`, `Query.books(limit:)`. */\n readonly coordinate: string\n /** Prefix of the trail of the types reached from here (`Query.book → Book.cover`). */\n readonly trail: string\n /** The trail of the owner of the coordinate (`Query.book → Book`), for \"reached from\". */\n readonly reached: string | undefined\n /** Location of the root field the walk started from. */\n readonly root: Location | undefined\n /** Where the type is written; called only when a diagnostic is reported. */\n readonly locate: () => Location | undefined\n}\n\n/** A converted type: the reference (non-null when nothing made it nullable) and whether TS accepts `null`. */\ninterface Converted {\n readonly ref: GraphQLTypeRef\n readonly acceptsNull: boolean\n}\n\n/** A converted inner type: its reference and whether the type itself admits `null` (`JSONValue`). */\ninterface Inner {\n readonly ref: GraphQLTypeRef\n readonly nullable: boolean\n}\n\n/** A `@ResolveField` waiting for its parent type to be reached. */\ninterface PendingFieldResolver {\n readonly resolver: ResolverData\n readonly field: FieldData\n readonly method: MethodInfo\n attached: boolean\n}\n\n/** A default value to check once every type is complete. */\ninterface PendingDefault {\n readonly target: ArgModel\n readonly value: unknown\n readonly use: Use\n readonly location: Location | undefined\n}\n\n/** The first use of a declaration in a position (ZNIGHT063 \"input and output\"). */\ninterface PositionUse {\n readonly coordinate: string\n readonly location: Location | undefined\n}\n\nconst NAME_HINT = 'GraphQL names match /^[_A-Za-z][_0-9A-Za-z]*$/ and do not start with __'\nconst RECORD_HINT =\n \"GraphQL objects have fixed fields: declare an interface, or use JSONValue (import type { JSONValue } from '@znight/graphql')\"\nconst ROOT_NAMES: ReadonlySet<string> = new Set(Object.values(ROOT_TYPE_NAMES))\n\n/** Builds the model; `undefined` when the application has no resolver. */\nexport function buildModel(ctx: Context, options: ResolvedGraphQLCompilerOptions): GraphQLModel | undefined {\n const resolvers = [...ctx.stored].sort((a, b) => compareStrings(a.host.identity, b.host.identity))\n if (resolvers.length === 0) return undefined\n return new SchemaBuilder(ctx, options).build(resolvers)\n}\n\nclass SchemaBuilder {\n readonly #ctx: Context\n readonly #number: 'Float' | 'Int'\n readonly #shapeOptions: ShapeOptions\n /** `scalar<T>()` declarations by the identity of `T`. */\n readonly #scalars: ReadonlyMap<string, ScalarDeclaration>\n /** Every named shape seen, by key. */\n readonly #named = new Map<string, NamedShape>()\n /** Models by GraphQL name (the first claimant). */\n readonly #types = new Map<string, TypeModel>()\n /** Models by declaration key. */\n readonly #models = new Map<string, TypeModel>()\n /** GraphQL names by declaration key. */\n readonly #names = new Map<string, string | undefined>()\n readonly #positions = new Map<string, { output?: PositionUse; input?: PositionUse }>()\n readonly #reported = new Set<string>()\n readonly #fieldResolvers = new Map<string, PendingFieldResolver[]>()\n readonly #defaults: PendingDefault[] = []\n readonly #methods = new Map<string, MethodInfo | undefined>()\n #errors = 0\n\n constructor(ctx: Context, options: ResolvedGraphQLCompilerOptions) {\n this.#ctx = ctx\n this.#number = options.number\n const declarations = readScalars(ctx, diagnostic => this.#report(diagnostic))\n this.#scalars = declarations\n // shapes keep the scalar types as references: `T` of `scalar<T>()` maps to its scalar wherever it appears\n const keep = [...new Set([...BASE_KEEP, ...declarations.keys()])].sort(compareStrings)\n this.#shapeOptions = Object.freeze({ keep: Object.freeze(keep), members: 'instance', jsdoc: true })\n }\n\n build(resolvers: readonly ResolverData[]): GraphQLModel | undefined {\n checkLoaders(this.#ctx, resolvers, diagnostic => this.#report(diagnostic))\n this.#indexFieldResolvers(resolvers)\n const roots = new Map<Operation, ObjectModel>()\n const rootFields = new Map<string, { readonly field: FieldData; readonly resolver: ResolverData }>()\n let hasQuery = false\n for (const resolver of resolvers) {\n for (const field of resolver.fields) {\n if (field.operation === 'field') continue\n if (field.operation === 'query') hasQuery = true\n if (!field.complete) continue\n const method = this.#method(resolver, field)\n if (method === undefined) continue\n const root = this.#rootModel(roots, field.operation)\n const coordinate = `${root.name}.${field.name}`\n const previous = rootFields.get(coordinate)\n if (previous !== undefined) {\n this.#report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `Two root fields are named ${coordinate}: ${resolver.host.displayName}.${field.method} and ${previous.resolver.host.displayName}.${previous.field.method}`,\n location: field.location,\n related: [{ message: 'the other field', location: previous.field.location }],\n hints: [`Rename one of them: @${decoratorName(field.operation)}('otherName')`],\n })\n continue\n }\n rootFields.set(coordinate, { field, resolver })\n root.fields.push(this.#resolverField(root, resolver, field, method))\n }\n }\n if (!hasQuery) {\n const first = resolvers[0] as ResolverData\n this.#report({\n code: Codes.InvalidResolver,\n severity: 'error',\n message: 'The application has GraphQL resolvers but no @Query field: GraphQL requires a query root type',\n location: first.location,\n hints: [`Add a @Query() method to a resolver (${first.host.displayName}, for instance)`],\n })\n }\n this.#reportUnreachableFieldResolvers()\n this.#checkDefaults()\n this.#checkInputCycles()\n checkDecisions(this.#ctx, resolvers, diagnostic => this.#report(diagnostic))\n if (this.#errors > 0 || !hasQuery) return undefined\n return this.#assemble(roots, resolvers)\n }\n\n // ------------------------------------------------------------------------------------- reporting\n\n #report(diagnostic: Diagnostic): void {\n if (diagnostic.severity === 'error') this.#errors++\n this.#ctx.report(diagnostic)\n }\n\n /** Reports once per `key`. */\n #reportOnce(key: string, diagnostic: Diagnostic): void {\n if (this.#reported.has(key)) return\n this.#reported.add(key)\n this.#report(diagnostic)\n }\n\n #fail(code: Diagnostic['code'], use: Use, message: string, hints: readonly string[]): undefined {\n const location = use.locate()\n this.#report({\n code,\n severity: 'error',\n message,\n ...(location === undefined ? {} : { location }),\n ...(hints.length === 0 ? {} : { hints }),\n related: reachedFrom(use),\n })\n return undefined\n }\n\n // ------------------------------------------------------------------------------------ resolvers\n\n #method(resolver: ResolverData, field: FieldData): MethodInfo | undefined {\n const key = `${resolver.host.identity}#${field.method}`\n if (!this.#methods.has(key)) {\n const cls: ClassInfo | undefined = this.#ctx.classInfo(resolver.host.identity)\n this.#methods.set(\n key,\n cls?.methods.find(method => method.name === field.method && method.kind === 'method'),\n )\n }\n return this.#methods.get(key)\n }\n\n #shape(target: { readonly parameter: ParameterInfo } | { readonly returnOf: MethodInfo }): ShapeResult {\n const result = this.#ctx.types.shape(target, this.#shapeOptions)\n for (const named of result.named.values()) this.#named.set(named.key, named)\n return result\n }\n\n #rootModel(roots: Map<Operation, ObjectModel>, operation: Operation): ObjectModel {\n let root = roots.get(operation)\n if (root === undefined) {\n const name = ROOT_TYPE_NAMES[operation]\n root = {\n kind: 'object',\n name,\n key: `#root:${operation}`,\n description: undefined,\n location: undefined,\n fields: [],\n trail: name,\n root: undefined,\n classIdentity: undefined,\n properties: [],\n interfaces: [],\n }\n roots.set(operation, root)\n this.#claim(root, undefined)\n }\n return root\n }\n\n /** A field backed by a resolver method (root field or field resolver). */\n #resolverField(owner: ObjectModel, resolver: ResolverData, field: FieldData, method: MethodInfo): FieldModel {\n const coordinate = `${owner.name}.${field.name}`\n const isRoot = field.operation !== 'field'\n const use: Use = {\n position: 'output',\n coordinate,\n trail: isRoot ? coordinate : `${owner.trail}.${field.name}`,\n reached: isRoot ? undefined : owner.trail,\n root: isRoot ? method.location : owner.root,\n locate: () => method.location,\n }\n const type = this.#returnType(resolver, field, method, use)\n return {\n name: field.name,\n type: type === undefined ? 'String' : printTypeRef(type.ref),\n description: descriptionOf(method.doc),\n deprecationReason: deprecationOf(method.doc),\n args: this.#arguments(field, method, use),\n binding: { resolver, field },\n location: field.location,\n }\n }\n\n #returnType(resolver: ResolverData, field: FieldData, method: MethodInfo, use: Use): Converted | undefined {\n const where = `${resolver.host.displayName}.${field.method}`\n if (method.returnType === undefined) {\n return this.#fail(Codes.InvalidType, use, `${where} has no return type annotation (${use.coordinate})`, [\n `Annotate the return type: the schema is derived from it (${field.method}(...): Promise<Book>)`,\n ])\n }\n const result = this.#shape({ returnOf: method })\n const rootIssue = result.issues.find(issue => issue.named === undefined)\n const located: Use = { ...use, locate: () => rootIssue?.location ?? method.location }\n const root = result.root\n const iterable = root.kind === 'reference' && ASYNC_ITERABLES.has(root.identity) ? root : undefined\n if (field.operation === 'subscription') {\n if (iterable === undefined) {\n this.#report({\n code: Codes.InvalidResolver,\n severity: 'error',\n message: `@Subscription ${where} must return an async iterable, not ${describeShape(root)}`,\n location: method.location,\n hints: [\n `Declare it as an async generator (async *${field.method}(): AsyncGenerator<Event>) or return pubsub.subscribe(...) (AsyncIterable<Event>)`,\n ],\n })\n return undefined\n }\n const item = iterable.typeArgs[0]\n if (item === undefined) {\n return this.#fail(\n Codes.InvalidType,\n located,\n `${where} must declare the type of its events (${use.coordinate})`,\n ['AsyncIterable<Event>'],\n )\n }\n return this.#convert(item, false, located)\n }\n if (iterable !== undefined) {\n return this.#fail(\n Codes.InvalidType,\n located,\n `${where} returns an async iterable: only @Subscription fields stream values (${use.coordinate})`,\n ['Use @Subscription() for a stream of events, or return a list (Promise<readonly Book[]>)'],\n )\n }\n if (root.kind === 'undefined') {\n return this.#fail(\n Codes.InvalidType,\n located,\n `${where} returns void: GraphQL fields must return a value (${use.coordinate})`,\n ['Return a payload type (the changed object) or a boolean'],\n )\n }\n return this.#convert(root, false, located)\n }\n\n /** Arguments of a resolver field: `@Args('name')` parameters and the properties of `@Args()` types. */\n #arguments(field: FieldData, method: MethodInfo, owner: Use): ArgModel[] {\n const args: ArgModel[] = []\n const seen = new Map<string, Location | undefined>()\n const add = (arg: ArgModel, location: Location | undefined): void => {\n if (seen.has(arg.name)) {\n const first = seen.get(arg.name)\n this.#report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `Argument '${arg.name}' of ${owner.coordinate} is declared twice`,\n ...(location === undefined ? {} : { location }),\n ...(first === undefined ? {} : { related: [{ message: 'first declared here', location: first }] }),\n hints: ['Argument names must be unique: rename one of them'],\n })\n return\n }\n seen.set(arg.name, location)\n args.push(arg)\n }\n field.params.forEach((data, index) => {\n if (data?.kind !== 'args') return\n const param = method.params[index] as ParameterInfo\n const result = this.#shape({ parameter: param })\n if (data.name !== undefined) {\n const coordinate = `${owner.coordinate}(${data.name}:)`\n const use: Use = {\n position: 'input',\n coordinate,\n trail: `${owner.trail}(${data.name})`,\n reached: owner.reached,\n root: owner.root,\n locate: () => param.typeLocation,\n }\n const arg = this.#parameterArgument(data.name, param, method, result, use)\n if (arg !== undefined) add(arg, param.location)\n return\n }\n const properties = this.#propertiesOf(result.root)\n if (properties === 'record') {\n this.#fail(\n Codes.InvalidType,\n { ...owner, locate: () => param.typeLocation },\n `@Args() parameter '${param.name}' of ${owner.coordinate} cannot be a record or an index signature: GraphQL arguments are fixed`,\n [RECORD_HINT, `@Args('${param.name}') declares one argument named '${param.name}'`],\n )\n return\n }\n if (properties === undefined) {\n this.#fail(\n Codes.InvalidType,\n { ...owner, locate: () => param.typeLocation },\n `@Args() parameter '${param.name}' of ${owner.coordinate} must have an object type: its properties are the arguments`,\n [`@Args('${param.name}') declares one argument named '${param.name}'`],\n )\n return\n }\n for (const property of properties) {\n if (isHidden(property.doc)) continue\n const coordinate = `${owner.coordinate}(${property.name}:)`\n const use: Use = {\n position: 'input',\n coordinate,\n trail: `${owner.trail}(${property.name})`,\n reached: owner.reached,\n root: owner.root,\n locate: () => annotationLocation(this.#ctx.project, property.location) ?? param.typeLocation,\n }\n const arg = this.#inputValue(property, use)\n if (arg !== undefined) add(arg, property.location ?? param.location)\n }\n })\n return args\n }\n\n /** `@Args('limit') limit: Int = 20`. */\n #parameterArgument(\n name: string,\n param: ParameterInfo,\n method: MethodInfo,\n result: ShapeResult,\n use: Use,\n ): ArgModel | undefined {\n if (!isGraphQLName(name)) {\n this.#fail(Codes.NameConflict, use, `'${name}' is not a valid GraphQL argument name (${use.coordinate})`, [\n NAME_HINT,\n ])\n return undefined\n }\n const converted = this.#convert(result.root, param.optional, use)\n if (converted === undefined) return undefined\n let ref = converted.ref\n const arg: ArgModel = {\n name,\n type: '',\n ref,\n description: descriptionOf(param.doc) ?? paramDescription(method.doc, param.name),\n deprecationReason: deprecationOf(param.doc),\n defaultValue: undefined,\n nullAsUndefined: false,\n location: param.location,\n }\n const initializer = param.initializer\n let hasDefault = false\n if (param.hasDefault) {\n if (initializer?.evaluated === true && initializer.ref === undefined && !containsRef(initializer.value)) {\n this.#defaults.push({ target: arg, value: initializer.value, use, location: initializer.location })\n hasDefault = true\n } else {\n // a default the compiler cannot read: the argument becomes optional, the TypeScript default applies\n ref = { ...ref, nonNull: false }\n }\n }\n arg.ref = ref\n arg.type = printTypeRef(ref)\n arg.nullAsUndefined = !ref.nonNull && !converted.acceptsNull\n this.#checkDeprecatedInput(arg, hasDefault, use)\n return arg\n }\n\n /** A property as an argument or an input field (§6.3): `@default`, `@deprecated`, null handling. */\n #inputValue(property: ShapeProperty, use: Use): ArgModel | undefined {\n if (!isGraphQLName(property.name)) {\n this.#fail(\n Codes.NameConflict,\n { ...use, locate: () => property.location },\n `'${property.name}' is not a valid GraphQL name (${use.coordinate})`,\n [NAME_HINT, 'Hide the property with /** @gqlHidden */'],\n )\n return undefined\n }\n if (property.kind === 'getter') {\n this.#fail(Codes.InvalidInput, use, `${use.coordinate} is a getter: input values are plain data`, [\n 'Declare a property instead, or hide the getter with /** @gqlHidden */',\n ])\n return undefined\n }\n const converted = this.#convert(property.shape, property.optional, use)\n if (converted === undefined) return undefined\n const arg: ArgModel = {\n name: property.name,\n type: printTypeRef(converted.ref),\n ref: converted.ref,\n description: descriptionOf(property.doc),\n deprecationReason: deprecationOf(property.doc),\n defaultValue: undefined,\n nullAsUndefined: !converted.ref.nonNull && !converted.acceptsNull,\n location: property.location,\n }\n const tag = tagOf(property.doc, 'default')\n if (tag !== undefined)\n this.#defaults.push({ target: arg, value: defaultTagValue(tag), use, location: tag.location })\n this.#checkDeprecatedInput(arg, tag !== undefined, use)\n return arg\n }\n\n /** graphql-js rejects a deprecated argument or input field that is required. */\n #checkDeprecatedInput(arg: ArgModel, hasDefault: boolean, use: Use): void {\n if (arg.deprecationReason === undefined || !arg.ref.nonNull || hasDefault) return\n this.#fail(Codes.InvalidInput, use, `${use.coordinate} is required and cannot be deprecated`, [\n 'Make it optional (?: T or T | undefined) or give it a default value before deprecating it',\n ])\n }\n\n // ------------------------------------------------------------------------------ field resolvers\n\n #indexFieldResolvers(resolvers: readonly ResolverData[]): void {\n for (const resolver of resolvers) {\n for (const field of resolver.fields) {\n if (field.operation !== 'field' || !field.complete) continue\n const method = this.#method(resolver, field)\n if (method === undefined) continue\n const index = field.params.findIndex(param => param?.kind === 'parent')\n const param = method.params[index]\n if (param === undefined) continue\n const result = this.#shape({ parameter: param })\n const key = this.#objectKeyOf(result.root)\n if (key === undefined) {\n this.#report({\n code: Codes.InvalidResolver,\n severity: 'error',\n message: `The @Parent() parameter '${param.name}' of ${resolver.host.displayName}.${field.method} must have an object type, not ${describeShape(result.root)}`,\n location: param.typeLocation,\n hints: [\n 'The parent type is the object type the field is added to: an interface, a class or a named alias of an object type',\n ],\n })\n continue\n }\n let list = this.#fieldResolvers.get(key)\n if (list === undefined) {\n list = []\n this.#fieldResolvers.set(key, list)\n }\n list.push({ resolver, field, method, attached: false })\n }\n }\n // field resolvers are appended by resolver token, then source order (§7.3)\n for (const list of this.#fieldResolvers.values()) {\n list.sort(\n (a, b) =>\n compareStrings(a.resolver.host.identity, b.resolver.host.identity) ||\n a.field.location.start - b.field.location.start,\n )\n }\n }\n\n #attachFieldResolvers(model: ObjectModel): void {\n const pending = this.#fieldResolvers.get(model.key)\n if (pending === undefined) return\n for (const entry of pending) {\n entry.attached = true\n const field = this.#resolverField(model, entry.resolver, entry.field, entry.method)\n const index = model.fields.findIndex(existing => existing.name === field.name)\n if (index === -1) {\n model.fields.push(field)\n continue\n }\n const existing = model.fields[index] as FieldModel\n const where = `${entry.resolver.host.displayName}.${entry.field.method}`\n if (existing.binding !== undefined) {\n this.#report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `Two field resolvers add ${model.name}.${field.name}: ${where} and ${existing.binding.resolver.host.displayName}.${existing.binding.field.method}`,\n location: entry.field.location,\n related: [{ message: 'the other field resolver', location: existing.binding.field.location }],\n hints: [\"Keep one of them, or rename one: @ResolveField('otherName')\"],\n })\n continue\n }\n if (existing.type !== field.type) {\n this.#report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `@ResolveField ${where} returns ${field.type}, but the property ${model.name}.${field.name} is ${existing.type}`,\n location: entry.field.location,\n ...(existing.location === undefined\n ? {}\n : { related: [{ message: 'the property', location: existing.location }] }),\n hints: [\n 'A field resolver replacing a property must resolve the same GraphQL type: change its return type, or rename the field',\n ],\n })\n continue\n }\n // replaces the property field in place: same position, the method's documentation first\n model.fields[index] = {\n ...field,\n description: field.description ?? existing.description,\n deprecationReason: field.deprecationReason ?? existing.deprecationReason,\n }\n }\n }\n\n #reportUnreachableFieldResolvers(): void {\n for (const [key, list] of this.#fieldResolvers) {\n for (const entry of list) {\n if (entry.attached) continue\n const name = this.#named.get(key)?.name ?? key\n this.#report({\n code: Codes.InvalidResolver,\n severity: 'warning',\n message: `@ResolveField ${entry.resolver.host.displayName}.${entry.field.method} adds a field to ${name}, which no root field reaches as an output type: it is not part of the schema`,\n location: entry.field.location,\n hints: [`Return ${name} from a @Query (or another reachable field), or remove the field resolver`],\n })\n }\n }\n }\n\n // ----------------------------------------------------------------------------------- conversion\n\n /**\n * The GraphQL type of a shape: `null`, `undefined` and `optional` make it nullable, everything\n * else is non-null (§6.2).\n */\n #convert(shape: Shape, optional: boolean, use: Use): Converted | undefined {\n let nullable = optional\n let acceptsNull = false\n let inner = shape\n if (shape.kind === 'union') {\n const rest = shape.members.filter(member => member.kind !== 'null' && member.kind !== 'undefined')\n if (rest.length !== shape.members.length) {\n nullable = true\n acceptsNull = shape.members.some(member => member.kind === 'null')\n }\n if (rest.length === 0) {\n return this.#fail(Codes.InvalidType, use, `${use.coordinate} is always null or undefined`, [\n 'Declare the type of the value',\n ])\n }\n inner = rest.length === 1 ? (rest[0] as Shape) : { kind: 'union', members: rest }\n }\n const converted = this.#inner(inner, use)\n if (converted === undefined) return undefined\n const isNullable = nullable || converted.nullable\n return { ref: { ...converted.ref, nonNull: !isNullable }, acceptsNull: acceptsNull || converted.nullable }\n }\n\n #inner(shape: Shape, use: Use): Inner | undefined {\n switch (shape.kind) {\n case 'string':\n return refTo('String')\n case 'number':\n return refTo(this.#number)\n case 'boolean':\n return refTo('Boolean')\n case 'literal':\n if (typeof shape.value === 'string') return refTo('String')\n return refTo(typeof shape.value === 'number' ? this.#number : 'Boolean')\n case 'date':\n return this.#builtin('DateTime', use)\n case 'bigint':\n return this.#builtin('BigInt', use)\n case 'array': {\n const item = this.#convert(shape.items, false, use)\n return item === undefined ? undefined : { ref: { kind: 'list', of: item.ref, nonNull: false }, nullable: false }\n }\n case 'named':\n return this.#namedType(shape.key, use)\n case 'reference':\n return this.#reference(shape, use)\n case 'url':\n return this.#fail(Codes.InvalidType, use, `Cannot map 'URL' to a GraphQL type (${use.coordinate})`, [\n \"Expose a string (url.href), or declare a scalar: export const UrlScalar = scalar<URL>('URL', { ... })\",\n ])\n case 'binary':\n return this.#fail(Codes.InvalidType, use, `Cannot map binary data to a GraphQL type (${use.coordinate})`, [\n \"Expose a URL (coverUrl: string), hide the property with /** @gqlHidden */, or declare a scalar: export const Base64 = scalar<Uint8Array>('Base64', { ... })\",\n ])\n case 'unknown':\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map 'unknown' or 'any' to a GraphQL type (${use.coordinate})`,\n [\"Declare the type, or use JSONValue (import type { JSONValue } from '@znight/graphql') for arbitrary JSON\"],\n )\n case 'never':\n case 'null':\n case 'undefined':\n return this.#fail(Codes.InvalidType, use, `Cannot map '${shape.kind}' to a GraphQL type (${use.coordinate})`, [\n 'Declare the type of the value',\n ])\n case 'tuple':\n return this.#fail(Codes.InvalidType, use, `Cannot map a tuple to a GraphQL type (${use.coordinate})`, [\n 'Use an array (readonly T[]) or a named object type',\n ])\n case 'object':\n if (shape.additional !== undefined) {\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map a record or an index signature to a GraphQL type (${use.coordinate})`,\n [RECORD_HINT],\n )\n }\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map an anonymous object type to a GraphQL type (${use.coordinate})`,\n ['GraphQL types have names: declare it (export interface BookStats { ... }) and use it'],\n )\n case 'intersection':\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map an anonymous intersection to a GraphQL type (${use.coordinate})`,\n ['Name it: export type BookWithAuthor = Book & { readonly author: Author }'],\n )\n case 'union':\n return this.#anonymousUnion(shape.members, use)\n case 'schema':\n return this.#fail(Codes.InvalidType, use, `Cannot map a schema type to a GraphQL type (${use.coordinate})`, [\n 'Declare the TypeScript type: the annotation is the GraphQL type',\n ])\n case 'opaque':\n return this.#opaque(shape, use)\n }\n }\n\n #anonymousUnion(members: readonly Shape[], use: Use): undefined {\n if (members.every(member => member.kind === 'literal' && typeof member.value === 'string')) {\n const values = members.map(member => `'${(member as { value: string }).value}'`).join(' | ')\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map the anonymous union ${values} to a GraphQL type (${use.coordinate})`,\n [`Name it to make it an enum: export type Sort = ${values}`],\n )\n }\n if (members.every(member => member.kind === 'named')) {\n return this.#fail(Codes.InvalidType, use, `Cannot map an anonymous union to a GraphQL type (${use.coordinate})`, [\n `GraphQL unions have names: export type SearchResult = ${members.map(member => this.#named.get((member as { key: string }).key)?.name ?? '?').join(' | ')}`,\n ])\n }\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map the union ${members.map(describeShape).join(' | ')} to a GraphQL type (${use.coordinate})`,\n ['GraphQL unions only contain object types: declare one type, or an object type per case'],\n )\n }\n\n #opaque(shape: Extract<Shape, { kind: 'opaque' }>, use: Use): undefined {\n const text = shape.text\n let hints: string[]\n switch (shape.reason) {\n case 'non-json':\n if (text.startsWith('Promise')) {\n hints = ['A Promise is only unwrapped at the top of a resolver return type: declare the resolved type']\n } else if (text.startsWith('Map') || text.startsWith('WeakMap')) {\n hints = [\n \"Use an array of entries, a named object type, or JSONValue (import type { JSONValue } from '@znight/graphql')\",\n ]\n } else {\n hints = ['Declare a plain data type (an interface, an array, a scalar)']\n }\n break\n case 'missing-annotation':\n hints = ['Annotate the type: the compiler reads annotations only']\n break\n case 'function':\n hints = ['Functions are not data: return the value, or hide the member with /** @gqlHidden */']\n break\n case 'type-parameter':\n hints = ['Give the type arguments explicitly']\n break\n default:\n hints = ['Declare the structure with an interface or a named alias']\n }\n return this.#fail(Codes.InvalidType, use, `Cannot map '${text}' to a GraphQL type (${use.coordinate})`, hints)\n }\n\n #reference(shape: Extract<Shape, { kind: 'reference' }>, use: Use): Inner | undefined {\n const alias = SCALAR_ALIASES.get(shape.identity)\n if (alias === 'JSON') {\n // JSONValue includes null: the field is nullable\n const json = this.#builtin('JSON', use)\n return json === undefined ? undefined : { ref: json.ref, nullable: true }\n }\n if (alias !== undefined) return refTo(alias === 'Float' ? 'Float' : alias)\n const scalar = this.#scalars.get(shape.identity)\n if (scalar !== undefined) return this.#customScalar(scalar, use)\n if (OUTPUT_ITERABLES.has(shape.identity)) {\n if (use.position === 'input') {\n return this.#fail(Codes.InvalidInput, use, `${use.coordinate} is a ${shape.name}: input lists are arrays`, [\n 'Declare an array (readonly T[]) for input values',\n ])\n }\n const item = shape.typeArgs[0]\n if (item === undefined)\n return this.#fail(Codes.InvalidType, use, `${use.coordinate}: ${shape.name} needs a type argument`, [])\n const converted = this.#convert(item, false, use)\n return converted === undefined\n ? undefined\n : { ref: { kind: 'list', of: converted.ref, nonNull: false }, nullable: false }\n }\n if (ASYNC_ITERABLES.has(shape.identity)) {\n return this.#fail(Codes.InvalidType, use, `Cannot map '${shape.name}' to a GraphQL type (${use.coordinate})`, [\n 'Async iterables are only the return type of @Subscription methods',\n ])\n }\n return this.#fail(Codes.InvalidType, use, `Cannot map '${shape.name}' to a GraphQL type (${use.coordinate})`, [\n 'Declare a plain data type (an interface, an array, a scalar)',\n ])\n }\n\n // ------------------------------------------------------------------------------------- scalars\n\n #builtin(name: 'DateTime' | 'BigInt' | 'JSON', use: Use): Inner | undefined {\n const key = `#builtin:${name}`\n if (!this.#models.has(key)) {\n const model: ScalarModel = {\n kind: 'scalar',\n name,\n key,\n description: undefined,\n location: undefined,\n definition: undefined,\n specifiedByURL: undefined,\n }\n this.#models.set(key, model)\n if (!this.#claim(model, use)) return undefined\n }\n return refTo(name)\n }\n\n #customScalar(scalar: ScalarDeclaration, use: Use): Inner | undefined {\n const key = `#scalar:${scalar.identity}`\n if (!this.#models.has(key)) {\n const model: ScalarModel = {\n kind: 'scalar',\n name: scalar.name,\n key,\n description: scalar.description,\n location: scalar.location,\n definition: scalar.identity,\n specifiedByURL: scalar.specifiedByURL,\n }\n this.#models.set(key, model)\n if (!this.#claim(model, use)) return undefined\n }\n return refTo(scalar.name)\n }\n\n // ------------------------------------------------------------------------------- named types\n\n #namedType(key: string, use: Use): Inner | undefined {\n const named = this.#named.get(key)\n if (named === undefined)\n return this.#fail(Codes.InvalidType, use, `Cannot resolve the type of ${use.coordinate}`, [])\n switch (named.declaration) {\n case 'enum':\n return this.#enum(named, use)\n case 'alias':\n return this.#alias(named, use)\n default:\n return this.#object(named, named, use)\n }\n }\n\n /**\n * A named alias: an object type (object literal, intersection, utility type, generic instance),\n * an enum (string literals), a union (object types), or transparent (`type Email = string`,\n * `type Books = Book[]`, `type Author = Person`).\n */\n #alias(alias: NamedShape, use: Use): Inner | undefined {\n const shape = alias.shape\n switch (shape.kind) {\n case 'object':\n case 'intersection':\n return this.#object(alias, alias, use)\n case 'named': {\n const target = this.#named.get(shape.key)\n if (\n target !== undefined &&\n target.declaration !== 'alias' &&\n target.declaration !== 'enum' &&\n target.typeArgs.length > 0\n ) {\n // `type BookList = Page<Book>`: the alias names the instance\n return this.#object(alias, target, use)\n }\n return this.#namedType(shape.key, use)\n }\n case 'union': {\n const rest = shape.members.filter(member => member.kind !== 'null' && member.kind !== 'undefined')\n const nullable = rest.length !== shape.members.length\n if (rest.length === 1) {\n const inner = this.#inner(rest[0] as Shape, use)\n return inner === undefined ? undefined : { ref: inner.ref, nullable: inner.nullable || nullable }\n }\n let converted: Inner | undefined\n if (rest.every(member => member.kind === 'literal')) converted = this.#literalEnum(alias, rest, use)\n else if (rest.length > 0 && rest.every(member => member.kind === 'named'))\n converted = this.#union(alias, rest, use)\n else converted = this.#anonymousUnion(rest, use)\n return converted === undefined ? undefined : { ref: converted.ref, nullable }\n }\n default:\n return this.#inner(shape, use)\n }\n }\n\n /**\n * The declaration key of the object type a shape maps to in output position (the parent of a\n * field resolver), `undefined` when it is not an object type. Mirrors {@link #alias}.\n */\n #objectKeyOf(shape: Shape): string | undefined {\n if (shape.kind === 'union') {\n const rest = shape.members.filter(member => member.kind !== 'null' && member.kind !== 'undefined')\n return rest.length === 1 ? this.#objectKeyOf(rest[0] as Shape) : undefined\n }\n if (shape.kind !== 'named') return undefined\n const named = this.#named.get(shape.key)\n if (named === undefined || named.declaration === 'enum') return undefined\n if (named.declaration !== 'alias') return named.key\n const target = named.shape\n if (target.kind === 'object' || target.kind === 'intersection') return named.key\n if (target.kind === 'named') {\n const instance = this.#named.get(target.key)\n if (\n instance !== undefined &&\n instance.declaration !== 'alias' &&\n instance.declaration !== 'enum' &&\n instance.typeArgs.length > 0\n ) {\n return named.key\n }\n }\n return this.#objectKeyOf(target)\n }\n\n /** An object type (output) or an input object type (input) for `named`, structured as `structure`. */\n #object(named: NamedShape, structure: NamedShape, use: Use): Inner | undefined {\n const key = named.key\n if (!this.#checkPosition(named, use)) return undefined\n const existing = this.#models.get(key)\n if (existing !== undefined) return this.#known(existing)\n const name = this.#typeName(named, use)\n if (name === undefined) return undefined\n const properties = this.#propertiesOf(structure.shape)\n if (properties === 'record') {\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map ${named.name}, a record or an index signature, to a GraphQL type (${use.coordinate})`,\n [RECORD_HINT],\n )\n }\n if (properties === undefined) {\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map ${named.name} to a GraphQL object type (${use.coordinate})`,\n ['Declare an interface, a class or a named object type'],\n )\n }\n const description = descriptionOf(named.doc) ?? (structure === named ? undefined : descriptionOf(structure.doc))\n const trail = `${use.trail} → ${name}`\n if (use.position === 'input') {\n const model: InputModel = { kind: 'input', name, key, description, location: named.location, fields: [] }\n this.#models.set(key, model)\n if (!this.#claim(model, use)) return undefined\n for (const property of properties) {\n if (isHidden(property.doc)) continue\n const fieldUse: Use = {\n position: 'input',\n coordinate: `${name}.${property.name}`,\n trail: `${trail}.${property.name}`,\n reached: trail,\n root: use.root,\n locate: () => annotationLocation(this.#ctx.project, property.location),\n }\n const field = this.#inputValue(property, fieldUse)\n if (field !== undefined) model.fields.push(field)\n }\n return refTo(name)\n }\n const model: ObjectModel = {\n kind: 'object',\n name,\n key,\n description,\n location: named.location,\n fields: [],\n trail,\n root: use.root,\n classIdentity:\n structure.declaration === 'class' && structure.typeArgs.length === 0 && structure === named\n ? structure.identity\n : undefined,\n properties: properties.map(property => this.#discriminant(property)),\n interfaces: [],\n }\n this.#models.set(key, model)\n if (!this.#claim(model, use)) return undefined\n for (const property of properties) {\n const field = this.#outputField(model, property)\n if (field !== undefined) model.fields.push(field)\n }\n this.#attachFieldResolvers(model)\n return refTo(name)\n }\n\n /** A property as a union discriminator candidate: its literal value, through aliases (`kind: BookKind`). */\n #discriminant(property: ShapeProperty): DiscriminantProperty {\n let shape = property.shape\n // `type BookKind = 'book'`, `type Kind = BookKind`; the bound only guards against alias cycles\n for (let depth = 0; shape.kind === 'named' && depth < 32; depth++) {\n const named = this.#named.get(shape.key)\n if (named?.declaration !== 'alias') break\n shape = named.shape\n }\n return {\n name: property.name,\n optional: property.optional,\n literal: shape.kind === 'literal' ? shape.value : undefined,\n }\n }\n\n #outputField(model: ObjectModel, property: ShapeProperty): FieldModel | undefined {\n // hidden members, functions (methods stored as properties) and the union discriminator `__typename`\n if (isHidden(property.doc) || property.name === '__typename') return undefined\n if (property.shape.kind === 'opaque' && property.shape.reason === 'function') return undefined\n const use: Use = {\n position: 'output',\n coordinate: `${model.name}.${property.name}`,\n trail: `${model.trail}.${property.name}`,\n reached: model.trail,\n root: model.root,\n locate: () => annotationLocation(this.#ctx.project, property.location),\n }\n if (!isGraphQLName(property.name)) {\n return this.#fail(\n Codes.NameConflict,\n { ...use, locate: () => property.location },\n `'${property.name}' is not a valid GraphQL field name (${use.coordinate})`,\n [NAME_HINT, 'Hide the property with /** @gqlHidden */'],\n )\n }\n const converted = this.#convert(property.shape, property.optional, use)\n if (converted === undefined) return undefined\n return {\n name: property.name,\n type: printTypeRef(converted.ref),\n description: descriptionOf(property.doc),\n deprecationReason: deprecationOf(property.doc),\n args: [],\n binding: undefined,\n location: property.location,\n }\n }\n\n /**\n * The properties of an object structure (intersections merged, later members win), `'record'` for\n * a record or an index signature (ZNIGHT060: GraphQL objects have fixed fields).\n */\n #propertiesOf(shape: Shape): readonly ShapeProperty[] | 'record' | undefined {\n switch (shape.kind) {\n case 'object':\n return shape.additional === undefined ? shape.properties : 'record'\n case 'named': {\n const named = this.#named.get(shape.key)\n return named === undefined || named.declaration === 'enum' ? undefined : this.#propertiesOf(named.shape)\n }\n case 'intersection': {\n const merged = new Map<string, ShapeProperty>()\n for (const member of shape.members) {\n const properties = this.#propertiesOf(member)\n if (properties === undefined || properties === 'record') return properties\n for (const property of properties) {\n merged.delete(property.name)\n merged.set(property.name, property)\n }\n }\n return [...merged.values()]\n }\n default:\n return undefined\n }\n }\n\n /** A declaration is used in one position: input or output (ZNIGHT063 otherwise). */\n #checkPosition(named: NamedShape, use: Use): boolean {\n let uses = this.#positions.get(named.key)\n if (uses === undefined) {\n uses = {}\n this.#positions.set(named.key, uses)\n }\n const other = use.position === 'input' ? uses.output : uses.input\n if (uses[use.position] === undefined) uses[use.position] = { coordinate: use.coordinate, location: use.locate() }\n if (other === undefined) return true\n const output = use.position === 'output' ? use.coordinate : other.coordinate\n const input = use.position === 'input' ? use.coordinate : other.coordinate\n const inputOwner = input.includes('(') ? input.slice(0, input.indexOf('(')) : input.split('.')[0]\n this.#reportOnce(`position\\0${named.key}`, {\n code: Codes.InvalidInput,\n severity: 'error',\n message: `'${named.name}' is used as an output type (${output}) and as an input type (${input})`,\n location: named.location,\n hints: [\n `GraphQL needs two types: declare \\`export interface ${named.name}Input extends ${named.name} {}\\` and use it in ${inputOwner}`,\n ],\n related: [\n ...(uses.output?.location === undefined\n ? []\n : [{ message: `used as output: ${output}`, location: uses.output.location }]),\n ...(uses.input?.location === undefined\n ? []\n : [{ message: `used as input: ${input}`, location: uses.input.location }]),\n ],\n })\n return false\n }\n\n /**\n * The GraphQL name of a declaration (§6.4): `@gqlName`, the declaration name, or for a generic\n * instance the names of its type arguments followed by the declaration name (`BookPage`).\n */\n #typeName(named: NamedShape, use: Use): string | undefined {\n if (this.#names.has(named.key)) return this.#names.get(named.key)\n let name: string | undefined\n const explicit = tagOf(named.doc, 'gqlName')?.text.trim()\n if (explicit !== undefined && explicit !== '') name = explicit\n else if (named.typeArgs.length === 0) name = named.name\n else {\n const args = named.typeArgs.map(arg => this.#argumentName(arg))\n const missing = args.findIndex(arg => arg === undefined)\n if (missing === -1) name = `${args.join('')}${named.name}`\n else {\n this.#reportOnce(`argument\\0${named.key}`, {\n code: Codes.InvalidType,\n severity: 'error',\n message: `Cannot name the GraphQL type of ${named.name}<...> (${use.coordinate}): its type argument ${describeShape(named.typeArgs[missing] as Shape)} has no GraphQL name`,\n location: named.location,\n related: reachedFrom(use),\n hints: [\n `Name the instance with an alias (export type BookPages = ${named.name}<...>) or with /** @gqlName Name */`,\n ],\n })\n }\n }\n this.#names.set(named.key, name)\n return name\n }\n\n /** The GraphQL name a type argument contributes to a generic instance name. */\n #argumentName(shape: Shape): string | undefined {\n switch (shape.kind) {\n case 'string':\n return 'String'\n case 'number':\n return this.#number\n case 'boolean':\n return 'Boolean'\n case 'date':\n return 'DateTime'\n case 'bigint':\n return 'BigInt'\n case 'reference': {\n const alias = SCALAR_ALIASES.get(shape.identity)\n if (alias !== undefined) return alias\n return this.#scalars.get(shape.identity)?.name\n }\n case 'union': {\n const rest = shape.members.filter(member => member.kind !== 'null' && member.kind !== 'undefined')\n return rest.length === 1 ? this.#argumentName(rest[0] as Shape) : undefined\n }\n case 'named': {\n const named = this.#named.get(shape.key)\n if (named === undefined) return undefined\n if (named.declaration === 'alias') {\n const target = named.shape\n const instance = target.kind === 'named' ? this.#named.get(target.key) : undefined\n const isObject =\n target.kind === 'object' ||\n target.kind === 'intersection' ||\n (instance !== undefined &&\n instance.declaration !== 'alias' &&\n instance.declaration !== 'enum' &&\n instance.typeArgs.length > 0)\n const isEnum = target.kind === 'union' && target.members.every(member => member.kind === 'literal')\n const isUnion = target.kind === 'union' && target.members.filter(member => member.kind === 'named').length > 1\n if (!isObject && !isEnum && !isUnion) return this.#argumentName(target)\n }\n return this.#typeName(named, {\n position: 'output',\n coordinate: named.name,\n trail: named.name,\n reached: undefined,\n root: undefined,\n locate: () => named.location,\n })\n }\n default:\n return undefined\n }\n }\n\n /**\n * Registers a model under its GraphQL name: the name must be valid, not reserved, and not taken\n * by another declaration (ZNIGHT061).\n */\n #claim(model: TypeModel, use: Use | undefined): boolean {\n const name = model.name\n const isRoot = model.key.startsWith('#root:')\n const location = model.location ?? use?.locate()\n let problem: string | undefined\n if (!isGraphQLName(name)) problem = `'${name}' is not a valid GraphQL type name`\n else if (!isRoot && ROOT_NAMES.has(name)) problem = `'${name}' is the name of a root operation type`\n else if (SPECIFIED_SCALARS.has(name)) problem = `'${name}' is the name of a specified GraphQL scalar`\n if (problem !== undefined) {\n this.#reportOnce(`name\\0${model.key}`, {\n code: Codes.NameConflict,\n severity: 'error',\n message: `${problem} (${model.key.startsWith('#') ? name : model.key})`,\n ...(location === undefined ? {} : { location }),\n related: use === undefined ? [] : reachedFrom(use),\n hints: [isGraphQLName(name) ? 'Rename the declaration, or name it with /** @gqlName OtherName */' : NAME_HINT],\n })\n return false\n }\n const existing = this.#types.get(name)\n if (existing === undefined) {\n this.#types.set(name, model)\n return true\n }\n if (existing === model) return true\n const pair = [existing.key, model.key].sort(compareStrings).join('\\0')\n this.#reportOnce(`conflict\\0${pair}`, {\n code: Codes.NameConflict,\n severity: 'error',\n message: `Two types are named '${name}' in the GraphQL schema: ${describeKey(model)} and ${describeKey(existing)}`,\n ...(location === undefined ? {} : { location }),\n related: [\n ...(existing.location === undefined ? [] : [{ message: 'the other declaration', location: existing.location }]),\n ...(use === undefined ? [] : reachedFrom(use)),\n ],\n hints: ['Rename one of them, or name one with /** @gqlName OtherName */'],\n })\n return false\n }\n\n // -------------------------------------------------------------------------------------- enums\n\n /** A model met again: its reference, unless its name was refused (already reported). */\n #known(model: TypeModel): Inner | undefined {\n return this.#types.get(model.name) === model ? refTo(model.name) : undefined\n }\n\n /** A TypeScript `enum`: names = member names, internal values = member values. */\n #enum(named: NamedShape, use: Use): Inner | undefined {\n const existing = this.#models.get(named.key)\n if (existing !== undefined) return this.#known(existing)\n const name = this.#typeName(named, use)\n if (name === undefined) return undefined\n const members = named.enumMembers\n if (members === undefined || members.length === 0) {\n return this.#fail(\n Codes.InvalidType,\n use,\n `The values of the enum ${named.name} cannot be evaluated (${use.coordinate})`,\n ['Use literal member values (A = \"a\", B = 1)'],\n )\n }\n const values: EnumValueModel[] = []\n for (const member of members) {\n if (!this.#checkEnumValueName(member.name, named, member.location, use)) continue\n values.push({\n name: member.name,\n value: member.value,\n description: descriptionOf(member.doc),\n deprecationReason: deprecationOf(member.doc),\n })\n }\n return this.#registerEnum(named, name, values, use)\n }\n\n /** A named alias of a union of string literals: names = values = the literals, in source order. */\n #literalEnum(named: NamedShape, members: readonly Shape[], use: Use): Inner | undefined {\n const existing = this.#models.get(named.key)\n if (existing !== undefined) return this.#known(existing)\n const literals = named.literals ?? members.map(member => (member as Extract<Shape, { kind: 'literal' }>).value)\n if (!literals.every(value => typeof value === 'string')) {\n return this.#fail(\n Codes.InvalidType,\n use,\n `Cannot map ${named.name} (${literals.map(value => JSON.stringify(value)).join(' | ')}) to a GraphQL type (${use.coordinate}): only unions of string literals are enums`,\n ['Declare a TypeScript enum (enum Level { Low = 1, High = 2 }), or use Int'],\n )\n }\n const name = this.#typeName(named, use)\n if (name === undefined) return undefined\n const values: EnumValueModel[] = []\n for (const literal of literals as readonly string[]) {\n if (!this.#checkEnumValueName(literal, named, named.location, use)) continue\n values.push({ name: literal, value: literal, description: undefined, deprecationReason: undefined })\n }\n return this.#registerEnum(named, name, values, use)\n }\n\n #checkEnumValueName(value: string, named: NamedShape, location: Location, use: Use): boolean {\n if (isGraphQLName(value) && !RESERVED_ENUM_VALUES.has(value)) return true\n this.#reportOnce(`enum\\0${named.key}\\0${value}`, {\n code: Codes.NameConflict,\n severity: 'error',\n message: `'${value}' of ${named.name} is not a valid GraphQL enum value`,\n location,\n related: reachedFrom(use),\n hints: [`${NAME_HINT}; true, false and null are reserved`],\n })\n return false\n }\n\n #registerEnum(named: NamedShape, name: string, values: readonly EnumValueModel[], use: Use): Inner | undefined {\n const model: TypeModel = {\n kind: 'enum',\n name,\n key: named.key,\n description: descriptionOf(named.doc),\n location: named.location,\n values,\n }\n this.#models.set(named.key, model)\n if (!this.#claim(model, use)) return undefined\n return refTo(name)\n }\n\n // ------------------------------------------------------------------------------------- unions\n\n /** A named alias of a union of object types (output only), with its runtime discriminator. */\n #union(alias: NamedShape, members: readonly Shape[], use: Use): Inner | undefined {\n if (use.position === 'input') {\n return this.#fail(\n Codes.InvalidInput,\n use,\n `${use.coordinate} is the union ${alias.name}: unions cannot be input values`,\n ['Declare one input type with optional fields, or one argument per case'],\n )\n }\n const existing = this.#models.get(alias.key)\n if (existing !== undefined) return this.#known(existing)\n const name = this.#typeName(alias, use)\n if (name === undefined) return undefined\n const model: UnionModel = {\n kind: 'union',\n name,\n key: alias.key,\n description: descriptionOf(alias.doc),\n location: alias.location,\n members: [],\n discriminator: undefined,\n }\n this.#models.set(alias.key, model)\n if (!this.#claim(model, use)) return undefined\n const trail = `${use.trail} → ${name}`\n const objects: ObjectModel[] = []\n // a failed member is reported: no discriminator then (members that collapse into one object, as\n // `Book | BookAlias`, are not failures)\n let failed = false\n for (const member of members) {\n const memberUse: Use = { ...use, coordinate: name, trail, reached: trail, locate: () => alias.location }\n const converted = this.#inner(member, memberUse)\n if (converted === undefined) {\n failed = true\n continue\n }\n const target = converted.ref.kind === 'named' ? this.#types.get(converted.ref.name) : undefined\n if (target?.kind !== 'object') {\n failed = true\n this.#fail(\n Codes.InvalidType,\n memberUse,\n `The union ${name} contains ${describeShape(member)}, which is not an object type`,\n ['GraphQL unions only contain object types'],\n )\n continue\n }\n if (!objects.includes(target)) objects.push(target)\n }\n objects.sort((a, b) => compareStrings(a.name, b.name))\n model.members = objects.map(object => object.name)\n if (!failed) model.discriminator = this.#discriminator(model, objects)\n return refTo(name)\n }\n\n /**\n * How the runtime tells the members apart (§5.7): `instanceof` when every member is an exported\n * class, a `__typename` property, a literal property with a distinct value per member, else\n * ZNIGHT064.\n */\n #discriminator(union: UnionModel, members: readonly ObjectModel[]): DiscriminatorModel | undefined {\n const found = discriminatorOf(members, identity => this.#ctx.classInfo(identity))\n if (found !== undefined) return found\n const names = members.map(member => member.name)\n const one = names.length === 1\n const listed = one ? (names[0] as string) : `${names.slice(0, -1).join(', ')} and ${names.at(-1) as string}`\n const allClasses = members.every(member => member.classIdentity !== undefined)\n let why: string\n if (allClasses) why = one ? 'is a class that is not exported' : 'are classes that are not all exported'\n else why = one ? 'has no literal property' : 'have no common literal property'\n this.#report({\n code: Codes.UnresolvableAbstractType,\n severity: 'error',\n message: `The members of union ${union.name} cannot be told apart at runtime: ${listed} ${why}`,\n ...(union.location === undefined ? {} : { location: union.location }),\n hints: [\n allClasses\n ? 'Export the member classes: the generated module imports them for instanceof'\n : `Add a literal property to each member (${members.map(member => `readonly kind: '${lowerFirst(member.name)}'`).join(' / ')}), or make the members classes`,\n ],\n })\n return undefined\n }\n\n // --------------------------------------------------------------------------------- final checks\n\n /** Defaults (`@default`, parameter defaults) against their types (ZNIGHT063), as external values. */\n #checkDefaults(): void {\n for (const pending of this.#defaults) {\n const result = externalValue(pending.value, pending.target.ref, this.#types)\n if ('error' in result) {\n const location = pending.location ?? pending.use.locate()\n this.#report({\n code: Codes.InvalidInput,\n severity: 'error',\n message: `Invalid default value ${describeValue(pending.value)} for ${pending.use.coordinate} (${pending.target.type}): ${result.error}`,\n ...(location === undefined ? {} : { location }),\n related: reachedFrom(pending.use),\n hints: ['Defaults are JSON values of the argument type (enum values as their member value or name)'],\n })\n continue\n }\n pending.target.defaultValue = result.value\n if (pending.target.ref.nonNull) pending.target.nullAsUndefined = false\n }\n }\n\n /** GraphQL forbids a cycle of non-null input fields (ZNIGHT063). */\n #checkInputCycles(): void {\n const inputs = [...this.#models.values()]\n .filter((model): model is InputModel => model.kind === 'input')\n .sort((a, b) => compareStrings(a.name, b.name))\n const state = new Map<string, 'visiting' | 'done'>()\n const stack: string[] = []\n const visit = (model: InputModel): void => {\n state.set(model.name, 'visiting')\n stack.push(model.name)\n for (const field of model.fields) {\n if (field.ref.kind !== 'named' || !field.ref.nonNull) continue\n const target = this.#types.get(field.ref.name)\n if (target?.kind !== 'input') continue\n const status = state.get(target.name)\n if (status === 'visiting') {\n const cycle = [...stack.slice(stack.indexOf(target.name)), target.name]\n this.#report({\n code: Codes.InvalidInput,\n severity: 'error',\n message: `The input types ${cycle.join(' → ')} reference each other through non-null fields: no value can be written`,\n ...(target.location === undefined ? {} : { location: target.location }),\n hints: ['Make one of the fields of the cycle optional (?: T) or a list'],\n })\n } else if (status === undefined) {\n visit(target)\n }\n }\n stack.pop()\n state.set(model.name, 'done')\n }\n for (const model of inputs) if (!state.has(model.name)) visit(model)\n }\n\n // ------------------------------------------------------------------------------------ assembly\n\n #assemble(roots: ReadonlyMap<Operation, ObjectModel>, resolvers: readonly ResolverData[]): GraphQLModel {\n const types = [...this.#types.values()].sort((a, b) => compareStrings(a.name, b.name))\n const meta: MetaEntry[] = []\n for (const resolver of resolvers) for (const field of resolver.fields) meta.push(...field.meta)\n const rootNames = {\n query: ROOT_TYPE_NAMES.query,\n ...(roots.has('mutation') ? { mutation: ROOT_TYPE_NAMES.mutation } : {}),\n ...(roots.has('subscription') ? { subscription: ROOT_TYPE_NAMES.subscription } : {}),\n }\n const sdl = printSdl({ roots: rootNames, types: types.map(sdlType) })\n return { roots: rootNames, types, meta, sdl, schemaHash: schemaHash(sdl) }\n }\n}\n\n// ------------------------------------------------------------------------------------------ helpers\n\n/** A (nullable, until `#convert` decides) reference to a named type. */\nfunction refTo(name: string): Inner {\n return { ref: { kind: 'named', name, nonNull: false }, nullable: false }\n}\n\nfunction reachedFrom(use: Use): { readonly message: string; readonly location: Location }[] {\n return use.reached === undefined || use.root === undefined\n ? []\n : [{ message: `reached from ${use.reached}`, location: use.root }]\n}\n\nfunction decoratorName(operation: Operation): string {\n return ROOT_TYPE_NAMES[operation]\n}\n\nfunction describeKey(model: TypeModel): string {\n return model.key.startsWith('#') ? `the ${model.kind} ${model.name}` : model.key\n}\n\n/** Short description of a shape for messages (`string`, `Book`, `Map<string, number>`). */\nfunction describeShape(shape: Shape): string {\n switch (shape.kind) {\n case 'literal':\n return JSON.stringify(shape.value)\n case 'named':\n return shape.key.slice(shape.key.indexOf('#') + 1)\n case 'reference':\n return shape.name\n case 'opaque':\n return shape.text\n case 'array':\n return `${describeShape(shape.items)}[]`\n case 'union':\n return shape.members.map(describeShape).join(' | ')\n case 'object':\n return 'an object literal type'\n default:\n return shape.kind\n }\n}\n\nfunction describeValue(value: unknown): string {\n try {\n return JSON.stringify(value) ?? String(value)\n } catch {\n return String(value)\n }\n}\n\nfunction containsRef(value: unknown): boolean {\n if (typeof value !== 'object' || value === null) return false\n if (Array.isArray(value)) return value.some(containsRef)\n const prototype: unknown = Object.getPrototypeOf(value)\n if (prototype !== Object.prototype && prototype !== null) return true\n return Object.values(value).some(containsRef)\n}\n\nfunction lowerFirst(text: string): string {\n return `${text.charAt(0).toLowerCase()}${text.slice(1)}`\n}\n","/**\n * `generate` of the graphql extension (RFC 0005 §7.1, §7.3): `metadata.extensions.graphql` from the\n * model `validate` built, and the SDL artifact when the extension is configured with `{ sdl }`.\n *\n * Data, not code, except `invoke`: one arrow per resolver field mapping the graphql-js arguments to\n * the method parameters. It is synchronous unless an argument is validated with a Standard Schema\n * whose validation turns out asynchronous: like the `invoke` of `@znight/http` routes, a\n * synchronous validation (Zod, Valibot, ArkType without async refinements) costs no promise.\n *\n * ```ts\n * ['invoke']: (r: BookResolver, p: unknown, _a: GraphQLArgs, c: GraphQLContext) =>\n * r.author(p as never, c.loader('src/authors-by-id.loader.ts#AuthorsById') as never),\n * ```\n */\n\nimport type { ClassRef, GenerateContext, GenInput, GenNode, GenParam, StaticValue, ValueRef } from '@znight/compiler'\nimport type { Token } from '@znight/core'\nimport type { MetaEntry } from '@znight/http/compiler'\nimport type { FieldData, GraphQLData, ParamData, ResolverData } from './data.ts'\nimport type { ArgModel, DiscriminatorModel, FieldModel, GraphQLModel, TypeModel } from './model.ts'\nimport type { ResolvedGraphQLCompilerOptions } from './options.ts'\n\nimport { GRAPHQL_METADATA_VERSION } from '../metadata.ts'\nimport { compareStrings } from './constants.ts'\nimport { RUNTIME_MODULE } from './ids.ts'\n\ntype Context = GenerateContext<GraphQLData>\n\n/** Module of `isThenable` (a required peer of `@znight/graphql`). */\nconst HTTP_MODULE = '@znight/http'\n\n/** Imports created on first use: an unused import would break `noUnusedLocals`. */\ninterface Imports {\n argsType(): GenNode\n contextType(): GenNode\n infoType(): GenNode\n resolverContextType(): GenNode\n paramFunctionOf(): GenNode\n validateArgs(): GenNode\n isThenable(): GenNode\n hostType(identity: string): GenNode\n}\n\n/** Builds the graphql section; `undefined` (no section) when the application has no resolver. */\nexport function generateGraphQL(\n ctx: Context,\n model: GraphQLModel | undefined,\n options: ResolvedGraphQLCompilerOptions,\n): GenNode | undefined {\n if (model === undefined) return undefined\n if (options.sdl !== false) ctx.emitFile(options.sdl, `${model.sdl}\\n`)\n const imports = createImports(ctx)\n const entries: [string, GenInput][] = [\n ['version', ctx.lit(GRAPHQL_METADATA_VERSION)],\n ['schemaHash', model.schemaHash],\n ['roots', ctx.obj(Object.entries(model.roots))],\n ['types', ctx.arr(model.types.map(type => typeNode(ctx, imports, type)))],\n ]\n const groups = groupsNode(ctx, model.meta)\n if (groups !== undefined) entries.push(['groups', groups])\n return ctx.obj(entries)\n}\n\nfunction createImports(ctx: Context): Imports {\n let args: GenNode | undefined\n let context: GenNode | undefined\n let info: GenNode | undefined\n let resolverContext: GenNode | undefined\n let paramFunctionOf: GenNode | undefined\n let validateArgs: GenNode | undefined\n let isThenable: GenNode | undefined\n const hosts = new Map<string, GenNode>()\n return {\n argsType: () => {\n args ??= ctx.importFrom(RUNTIME_MODULE, 'GraphQLArgs', { type: true })\n return args\n },\n contextType: () => {\n context ??= ctx.importFrom(RUNTIME_MODULE, 'GraphQLContext', { type: true })\n return context\n },\n infoType: () => {\n info ??= ctx.importFrom('graphql', 'GraphQLResolveInfo', { type: true })\n return info\n },\n resolverContextType: () => {\n resolverContext ??= ctx.importFrom(RUNTIME_MODULE, 'ResolverContext', { type: true })\n return resolverContext\n },\n paramFunctionOf: () => {\n paramFunctionOf ??= ctx.importFrom('@znight/core', 'ParamFunctionOf', { type: true })\n return paramFunctionOf\n },\n validateArgs: () => {\n validateArgs ??= ctx.importFrom(RUNTIME_MODULE, 'validateArgs')\n return validateArgs\n },\n isThenable: () => {\n isThenable ??= ctx.importFrom(HTTP_MODULE, 'isThenable')\n return isThenable\n },\n hostType: identity => {\n let node = hosts.get(identity)\n if (node === undefined) {\n node = ctx.importType(identity)\n hosts.set(identity, node)\n }\n return node\n },\n }\n}\n\nfunction typeNode(ctx: Context, imports: Imports, type: TypeModel): GenNode {\n const head: [string, GenInput][] = [\n ['kind', type.kind],\n ['name', type.name],\n ]\n if (type.description !== undefined && type.kind !== 'scalar') head.push(['description', type.description])\n switch (type.kind) {\n case 'object':\n case 'interface': {\n const entries: [string, GenInput][] = [...head]\n if (type.interfaces.length > 0) entries.push(['interfaces', ctx.lit([...type.interfaces])])\n entries.push(['fields', ctx.arr(type.fields.map(field => fieldNode(ctx, imports, field)))])\n if (type.kind === 'interface') entries.push(['discriminator', discriminatorNode(ctx, type.discriminator)])\n return ctx.obj(entries)\n }\n case 'input':\n return ctx.obj([...head, ['fields', ctx.arr(type.fields.map(field => inputValueNode(ctx, field)))]])\n case 'enum':\n return ctx.obj([\n ...head,\n [\n 'values',\n ctx.arr(\n type.values.map(value => {\n const entries: [string, GenInput][] = [\n ['name', value.name],\n ['value', value.value],\n ]\n if (value.description !== undefined) entries.push(['description', value.description])\n if (value.deprecationReason !== undefined) entries.push(['deprecationReason', value.deprecationReason])\n return ctx.obj(entries)\n }),\n ),\n ],\n ])\n case 'union':\n return ctx.obj([\n ...head,\n ['members', ctx.lit([...type.members])],\n ['discriminator', discriminatorNode(ctx, type.discriminator)],\n ])\n case 'scalar': {\n // built-in scalars carry no description (the runtime builds them, sdl.ts prints them alike);\n // code-first user scalars bring theirs with the imported definition, schema-first ones take\n // the SDL's (they win over the definition's)\n if (type.definition === undefined) return ctx.obj([...head, ['builtin', ctx.lit(true)]])\n const entries: [string, GenInput][] = [...head, ['scalar', ctx.importValue(type.definition)]]\n if (type.fromSdl === true) {\n if (type.description !== undefined) entries.push(['description', type.description])\n if (type.specifiedByURL !== undefined) entries.push(['specifiedByURL', type.specifiedByURL])\n entries.push(['sdl', ctx.lit(true)])\n }\n return ctx.obj(entries)\n }\n }\n}\n\n/** How the runtime tells the members of a union or the implementations of an interface apart. */\nfunction discriminatorNode(ctx: Context, discriminator: DiscriminatorModel | undefined): GenNode {\n if (discriminator === undefined || discriminator.by === 'typename') return ctx.obj([['by', 'typename']])\n if (discriminator.by === 'property') {\n return ctx.obj([\n ['by', 'property'],\n ['property', discriminator.property],\n ['values', ctx.obj(Object.entries(discriminator.values))],\n ])\n }\n return ctx.obj([\n ['by', 'class'],\n ['classes', ctx.arr(discriminator.classes.map(entry => ctx.arr([ctx.importValue(entry.identity), entry.name])))],\n ])\n}\n\nfunction fieldNode(ctx: Context, imports: Imports, field: FieldModel): GenNode {\n const entries: [string, GenInput][] = [\n ['name', field.name],\n ['type', field.type],\n ]\n if (field.description !== undefined) entries.push(['description', field.description])\n if (field.deprecationReason !== undefined) entries.push(['deprecationReason', field.deprecationReason])\n if (field.args.length > 0) entries.push(['args', ctx.arr(field.args.map(arg => inputValueNode(ctx, arg)))])\n if (field.binding !== undefined) {\n entries.push(['resolver', resolverNode(ctx, imports, field.binding.resolver, field.binding.field)])\n }\n return ctx.obj(entries)\n}\n\nfunction inputValueNode(ctx: Context, arg: ArgModel): GenNode {\n const entries: [string, GenInput][] = [\n ['name', arg.name],\n ['type', arg.type],\n ]\n if (arg.description !== undefined) entries.push(['description', arg.description])\n if (arg.deprecationReason !== undefined) entries.push(['deprecationReason', arg.deprecationReason])\n if (arg.defaultValue !== undefined) entries.push(['defaultValue', ctx.lit(arg.defaultValue as never)])\n if (arg.nullAsUndefined) entries.push(['nullAsUndefined', ctx.lit(true)])\n return ctx.obj(entries)\n}\n\nfunction resolverNode(ctx: Context, imports: Imports, resolver: ResolverData, field: FieldData): GenNode {\n const guards = [...resolver.guards, ...field.guards].map(ref => ctx.tokenOf(ref) ?? ref.token)\n const entries: [string, GenInput][] = [\n ['token', ctx.tokenOf(resolver.host) ?? resolver.host.identity],\n ['method', field.method],\n ['operation', field.operation],\n ['guards', ctx.lit(guards)],\n ['meta', ctx.obj(field.meta.map(entry => [entry.key, ctx.lit(entry.value as never)] as const))],\n ]\n const loaders = field.params.flatMap(param => (param?.kind === 'loader' ? [loaderToken(ctx, param)] : []))\n if (loaders.length > 0) entries.push(['loaders', ctx.lit(loaders)])\n // custom parameters (RFC 0010): the pipeline builds the ResolverContext and resolves the class resolvers\n const resolvers = paramResolvers(field)\n if (field.params.some(param => param?.kind === 'custom')) entries.push(['context', ctx.lit(true)])\n if (resolvers.length > 0) {\n entries.push(['paramResolvers', ctx.lit(resolvers.map(ref => ctx.tokenOf(ref) ?? ref.token))])\n }\n entries.push(['invoke', invokeNode(ctx, imports, resolver, field, resolvers)])\n return ctx.obj(entries)\n}\n\n/** The provider token a loader parameter is bound to. */\nfunction loaderToken(ctx: Context, param: Extract<ParamData, { kind: 'loader' }>): Token {\n const ref = ctx.binding(param.binding)\n if (typeof ref === 'string') return ref\n if (ref !== undefined && 'token' in ref) return ref.token\n return param.identity\n}\n\n// ------------------------------------------------------------------------------------------- invoke\n\n/** The provider classes resolving custom parameters, in order of first use (`x[i]`). */\nfunction paramResolvers(field: FieldData): ClassRef[] {\n const found = new Map<string, ClassRef>()\n for (const param of field.params) {\n const resolver = param?.kind === 'custom' ? param.resolver : undefined\n if (resolver !== undefined && !found.has(resolver.token)) found.set(resolver.token, resolver)\n }\n return [...found.values()]\n}\n\n/** Which `invoke` parameters a field uses: `(r, p, a, c, i, f, x)`. */\nfunction usedParameters(field: FieldData): readonly boolean[] {\n let p = false\n let a = false\n let c = false\n let i = false\n let f = false\n let x = false\n for (const param of field.params) {\n switch (param?.kind) {\n case 'custom':\n // a class resolver whose `resolve()` takes no parameter does not read `f`\n f ||= param.resolver === undefined || param.arity !== 0\n x ||= param.resolver !== undefined\n break\n case 'parent':\n p = true\n break\n case 'args':\n a = true\n break\n case 'ctx':\n case 'loader':\n c = true\n break\n case 'info':\n i = true\n break\n }\n }\n return [p, a, c, i, f, x]\n}\n\n/**\n * `(r: Resolver, p: unknown, a: GraphQLArgs, c: GraphQLContext, i: GraphQLResolveInfo) => r.m(...)`:\n * unused middle parameters are `_`-prefixed, trailing ones omitted (`noUnusedParameters`).\n */\nfunction invokeNode(\n ctx: Context,\n imports: Imports,\n resolver: ResolverData,\n field: FieldData,\n resolvers: readonly ClassRef[],\n): GenNode {\n const used = usedParameters(field)\n const last = used.lastIndexOf(true)\n const types = [\n () => ctx.code`unknown`,\n imports.argsType,\n imports.contextType,\n imports.infoType,\n imports.resolverContextType,\n () =>\n tupleType(\n ctx,\n resolvers.map(ref => ctx.importType(ref)),\n ),\n ]\n const names = ['p', 'a', 'c', 'i', 'f', 'x']\n const params: [string, GenNode][] = [['r', imports.hostType(resolver.host.identity)]]\n for (let index = 0; index <= last; index++) {\n params.push([`${used[index] ? '' : '_'}${names[index] as string}`, (types[index] as () => GenNode)()])\n }\n const deferred = field.params.flatMap((param, index) => (param !== undefined && isDeferred(param) ? [index] : []))\n const positions = new Map(resolvers.map((ref, position) => [ref.token, position]))\n return ctx.arrow(params, (r, ...rest) => {\n const [p, a, c, i, f, x] = rest as (GenParam | undefined)[]\n const scope: Scope = { p, a, c, i, f, x, resolvers: positions, imports }\n if (deferred.length === 0) return call(ctx, r, field, index => argument(ctx, scope, field, index))\n return validatingBlock(ctx, imports, r, scope, field, deferred)\n })\n}\n\n/** `readonly [A, B]`. */\nfunction tupleType(ctx: Context, nodes: readonly GenNode[]): GenNode {\n const joined = nodes.slice(1).reduce((all, node) => ctx.code`${all}, ${node}`, nodes[0] as GenNode)\n return ctx.code`readonly [${joined}]`\n}\n\n/** An argument whose expression may return a thenable: a validated `@Args`, or a custom parameter. */\nfunction isDeferred(param: ParamData): boolean {\n return (param.kind === 'args' && param.schema !== undefined) || param.kind === 'custom'\n}\n\n/** The parameters of the `invoke` arrow (absent when not declared). */\ninterface Scope {\n readonly p: GenNode | undefined\n readonly a: GenNode | undefined\n readonly c: GenNode | undefined\n readonly i: GenNode | undefined\n /** The `ResolverContext` of custom parameters. */\n readonly f: GenNode | undefined\n /** The class resolver instances (`x[i]`). */\n readonly x: GenNode | undefined\n /** Position of each class resolver token in `x`. */\n readonly resolvers: ReadonlyMap<string, number>\n readonly imports: Imports\n}\n\n/** `r.method(args)`. */\nfunction call(ctx: Context, r: GenNode, field: FieldData, argumentOf: (index: number) => GenNode): GenNode {\n return ctx.call(\n ctx.member(r, field.method),\n field.params.map((_, index) => argumentOf(index)),\n )\n}\n\n/** The expression passed for the parameter `index` (validation not applied). */\nfunction argument(ctx: Context, scope: Scope, field: FieldData, index: number): GenNode {\n const param = field.params[index]\n switch (param?.kind) {\n case 'parent':\n return ctx.code`${scope.p as GenNode} as never`\n case 'ctx':\n return scope.c as GenNode\n case 'info':\n return scope.i as GenNode\n case 'loader':\n return ctx.code`${ctx.call(ctx.member(scope.c as GenNode, 'loader'), [loaderToken(ctx, param)])} as never`\n case 'args':\n return ctx.code`${argsValue(ctx, scope, param.name)} as never`\n case 'custom':\n return customArgument(ctx, scope, param)\n default:\n return ctx.lit(undefined)\n }\n}\n\n/**\n * A custom parameter (RFC 0010): `(D.resolvers.graphql as ParamFunctionOf<typeof D, 'graphql'>)(f, data)`\n * or `x[i].resolve(f, data)`, cast with `as never` when the value type could not be checked.\n */\nfunction customArgument(ctx: Context, scope: Scope, param: Extract<ParamData, { kind: 'custom' }>): GenNode {\n const f = scope.f as GenNode\n const data = param.data === undefined ? ctx.lit(undefined) : dataNode(ctx, param.data.value)\n let node: GenNode\n if (param.resolver === undefined) {\n const decorator = ctx.importValue(param.identity)\n const type = ctx.code`${scope.imports.paramFunctionOf()}<typeof ${decorator}, 'graphql'>`\n node = ctx.call(ctx.code`${ctx.member(decorator, 'resolvers', 'graphql')} as ${type}`, [f, data])\n } else {\n const position = scope.resolvers.get(param.resolver.token) as number\n if (param.arity === undefined) {\n // a `resolve` the compiler cannot read (inherited from a mixin...): the instance is cast to a\n // method taking both arguments (method parameters are bivariant), the value with `as never`\n return ctx.code`(${scope.x as GenNode}[${position}] as { resolve(ctx: unknown, data: unknown): unknown }).resolve(${f}, ${data}) as never`\n }\n // a `resolve(ctx)` that ignores the data gets no data argument (TypeScript checks the arity)\n const arity = Math.min(param.arity, 2)\n let args = ctx.code``\n if (arity === 1) args = f\n else if (arity === 2) args = ctx.code`${f}, ${data}`\n node = ctx.code`${scope.x as GenNode}[${position}].resolve(${args})`\n }\n return param.cast ? ctx.code`${node} as never` : node\n}\n\n/** The data argument of a custom parameter: a literal (references imported) or a reference. */\nfunction dataNode(ctx: Context, value: StaticValue): GenNode {\n return isValueRef(value) ? ctx.ref(value as ValueRef) : ctx.lit(value as never)\n}\n\n/** `true` for a {@link ValueRef} (the only non-plain object a static value can hold). */\nfunction isValueRef(value: unknown): boolean {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false\n const prototype = Object.getPrototypeOf(value)\n return prototype !== Object.prototype && prototype !== null && (value as { kind?: unknown }).kind === 'ref'\n}\n\n/** The expression of a deferred parameter (validation or custom resolver), before any `await`. */\nfunction deferredValue(ctx: Context, imports: Imports, scope: Scope, field: FieldData, index: number): GenNode {\n const param = field.params[index] as ParamData\n return param.kind === 'custom'\n ? customArgument(ctx, scope, param)\n : validation(ctx, imports, scope, param as Extract<ParamData, { kind: 'args' }>)\n}\n\n/** `a['name']`, or `a` for `@Args()`. */\nfunction argsValue(ctx: Context, scope: Scope, name: string | undefined): GenNode {\n const a = scope.a as GenNode\n return name === undefined ? a : ctx.code`${a}[${name}]`\n}\n\n/** `validateArgs(Schema, a['input'], 'input')`. */\nfunction validation(\n ctx: Context,\n imports: Imports,\n scope: Scope,\n param: Extract<ParamData, { kind: 'args' }>,\n): GenNode {\n return ctx.call(imports.validateArgs(), [\n ctx.ref(param.schema as NonNullable<typeof param.schema>),\n argsValue(ctx, scope, param.name),\n param.name ?? 'args',\n ])\n}\n\n/**\n * The body of the `invoke` of a field validating arguments: each validation is evaluated in order\n * into a `const`; while they return values the method is called synchronously, the first thenable\n * resumes in an `async` arrow that awaits it and the later validations (the order of evaluation and\n * the error reported first are those of an `async` invoke awaiting every validation).\n *\n * ```ts\n * (r: BookResolver, _p: unknown, a: GraphQLArgs) => {\n * const v0 = validateArgs(NewBookInput, a['input'], 'input')\n * if (isThenable(v0)) return (async () => r.addBook(await v0 as never))()\n * return r.addBook(v0 as never)\n * }\n * ```\n */\nfunction validatingBlock(\n ctx: Context,\n imports: Imports,\n r: GenNode,\n scope: Scope,\n field: FieldData,\n validated: readonly number[],\n): GenNode {\n return ctx.block(\n validated.map(index => `v${index}`),\n (...locals) => {\n const local = new Map(validated.map((index, position) => [index, locals[position] as GenNode]))\n const statements: GenNode[] = []\n for (const index of validated) {\n const name = local.get(index) as GenNode\n statements.push(ctx.code`const ${name} = ${deferredValue(ctx, imports, scope, field, index)}`)\n const resume = ctx.arrow(\n [],\n () =>\n call(ctx, r, field, position => {\n const value = local.get(position)\n if (value === undefined) return argument(ctx, scope, field, position)\n if (position < index) return ctx.code`${value} as never`\n if (position === index) return ctx.code`await ${value} as never`\n return ctx.code`await ${deferredValue(ctx, imports, scope, field, position)} as never`\n }),\n { async: true },\n )\n statements.push(ctx.code`if (${ctx.call(imports.isThenable(), [name])}) return (${resume})()`)\n }\n statements.push(\n ctx.code`return ${call(ctx, r, field, position => {\n const value = local.get(position)\n return value === undefined ? argument(ctx, scope, field, position) : ctx.code`${value} as never`\n })}`,\n )\n return statements\n },\n )\n}\n\n// ------------------------------------------------------------------------------------------- groups\n\n/**\n * `groups`: the route decorator groups the runtime needs (required, holding several keys, or named\n * differently from their key), sorted; `undefined` when there is none (RFC 0001, as `extensions.http`).\n */\nfunction groupsNode(ctx: Context, meta: readonly MetaEntry[]): GenNode | undefined {\n const groups = new Map<string, { readonly keys: Set<string>; required: boolean }>()\n for (const entry of meta) {\n const group = groups.get(entry.group)\n if (group === undefined) groups.set(entry.group, { keys: new Set([entry.key]), required: entry.required })\n else {\n group.keys.add(entry.key)\n group.required ||= entry.required\n }\n }\n const needed = [...groups]\n .filter(([name, group]) => group.required || group.keys.size > 1 || !group.keys.has(name))\n .sort(([a], [b]) => compareStrings(a, b))\n if (needed.length === 0) return undefined\n return ctx.obj(\n needed.map(\n ([name, group]) =>\n [\n name,\n ctx.obj([\n ['keys', ctx.lit([...group.keys].sort(compareStrings))],\n ['required', group.required],\n ]),\n ] as const,\n ),\n )\n}\n","/**\n * Options of the compiler extension (RFC 0005 §6.7, RFC 0007 §4.1), given with\n * `graphql.configure({ ... })` in `znight.config.ts`. Import-free.\n */\n\n/** Options of `graphql.configure()`. */\nexport interface GraphQLCompilerOptions {\n /**\n * Path of the SDL artifact, relative to the project root (`'schema.graphql'`), written next to the\n * generated module and checked by `znight generate --check`. Default `false`: no file.\n */\n readonly sdl?: string | false\n /** GraphQL type of `number`. Default `'Float'`; `'Int'` suits counts and identifiers. Code-first only. */\n readonly number?: 'Float' | 'Int'\n /**\n * Schema-first mode (RFC 0007): globs of the `.graphql` files that define the schema, relative to\n * the project root (`'src/**\\/*.graphql'`, `!` negations allowed). Resolvers are bound to their\n * fields by name and checked against the SDL. Default `false`: code-first.\n */\n readonly schema?: string | readonly string[] | false\n}\n\n/** {@link GraphQLCompilerOptions} with their defaults. */\nexport interface ResolvedGraphQLCompilerOptions {\n readonly sdl: string | false\n readonly number: 'Float' | 'Int'\n /** The schema-first globs; `false`: code-first. */\n readonly schema: readonly string[] | false\n}\n\n/** The defaults. */\nexport const DEFAULT_OPTIONS: ResolvedGraphQLCompilerOptions = Object.freeze({\n sdl: false,\n number: 'Float',\n schema: false,\n})\n\nconst KNOWN = new Set(['sdl', 'number', 'schema'])\n\n/**\n * Merges `options` onto `base`. Throws a `TypeError` naming the option on an invalid value: options\n * are written in `znight.config.ts`, the error surfaces when the configuration is loaded.\n */\nexport function resolveOptions(\n base: ResolvedGraphQLCompilerOptions,\n options: GraphQLCompilerOptions,\n): ResolvedGraphQLCompilerOptions {\n if (typeof options !== 'object' || options === null || Array.isArray(options)) {\n throw new TypeError('[znight] graphql.configure() expects an options object: { sdl?, number?, schema? }')\n }\n for (const key of Object.keys(options)) {\n if (!KNOWN.has(key))\n throw new TypeError(`[znight] graphql.configure(): unknown option \"${key}\" (options: sdl, number, schema)`)\n }\n const sdl = options.sdl === undefined ? base.sdl : options.sdl\n if (sdl !== false && (typeof sdl !== 'string' || sdl.trim() === '')) {\n throw new TypeError(\n '[znight] graphql.configure(): \"sdl\" must be a path relative to the project root (\\'schema.graphql\\') or false',\n )\n }\n const number = options.number === undefined ? base.number : options.number\n if (number !== 'Float' && number !== 'Int') {\n throw new TypeError(`[znight] graphql.configure(): \"number\" must be 'Float' or 'Int'`)\n }\n return Object.freeze({ sdl, number, schema: resolveSchema(base.schema, options.schema) })\n}\n\nfunction resolveSchema(\n base: readonly string[] | false,\n schema: GraphQLCompilerOptions['schema'],\n): readonly string[] | false {\n if (schema === undefined) return base\n if (schema === false) return false\n const globs = typeof schema === 'string' ? [schema] : schema\n if (\n !Array.isArray(globs) ||\n globs.length === 0 ||\n globs.some(glob => typeof glob !== 'string' || glob.trim() === '')\n ) {\n throw new TypeError(\n '[znight] graphql.configure(): \"schema\" must be a glob or a non-empty list of globs relative to the project root (\\'src/**/*.graphql\\'), or false',\n )\n }\n return Object.freeze([...globs])\n}\n","/**\n * The graphql-js modules schema-first compiles use (RFC 0007 §7): the language (parser, AST), the\n * type system (`validateSchema`, type predicates) and the utilities (`buildASTSchema`,\n * `concatAST`, `valueFromASTUntyped`). Loaded lazily, on the first schema-first compile, with\n * `createRequire`: code-first compiles never load graphql-js, and the execution engine\n * (`graphql/execution`, the `graphql` root entry) and dataloader are never loaded at build time\n * (tests/boundaries.test.ts). graphql is a required peer of `@znight/graphql`.\n */\nimport type * as Language from 'graphql/language'\nimport type * as Type from 'graphql/type'\nimport type * as Utilities from 'graphql/utilities'\n\nimport { createRequire } from 'node:module'\n\n/** The build-time graphql-js modules. */\nexport interface GraphQLBuildModules {\n readonly language: typeof Language\n readonly type: typeof Type\n readonly utilities: typeof Utilities\n}\n\n/** The only graphql-js modules the compiler extension may load (checked by tests/boundaries.test.ts). */\nexport const GRAPHQL_BUILD_MODULES: readonly string[] = Object.freeze([\n 'graphql/language',\n 'graphql/type',\n 'graphql/utilities',\n])\n\nlet loaded: GraphQLBuildModules | undefined\n\n/** The graphql-js modules, loaded on first use. */\nexport function graphqlModules(): GraphQLBuildModules {\n if (loaded === undefined) {\n const load = createRequire(import.meta.url)\n loaded = Object.freeze({\n language: load('graphql/language') as typeof Language,\n type: load('graphql/type') as typeof Type,\n utilities: load('graphql/utilities') as typeof Utilities,\n })\n }\n return loaded\n}\n","/**\n * Type conformance of schema-first resolvers (RFC 0007 §5.4): the TypeScript signatures of the\n * resolver methods, read through the type shapes API, against the SDL types. Output positions\n * (return types, parent types, the properties of the returned objects) must be assignable to the\n * SDL type; input positions (`@Args` parameters, input objects) must accept every value graphql-js\n * passes. The walk follows the object fields without resolver through the properties of the\n * TypeScript types (each SDL type and TypeScript declaration pair once), which is also where an\n * object field that nothing provides is found (coverage, §5.3).\n *\n * Every mismatch is a ZNIGHT068 located on the TypeScript annotation, the SDL definition related.\n * `any`, `unknown`, opaque types and missing annotations are not checked. The walk also decides\n * `nullAsUndefined` of arguments and input fields and the discriminators of abstract types.\n */\nimport type {\n Diagnostic,\n Location,\n MethodInfo,\n NamedShape,\n ParameterInfo,\n Shape,\n ShapeOptions,\n ShapeProperty,\n ShapeResult,\n ValidateContext,\n} from '@znight/compiler'\nimport type {\n ASTNode,\n GraphQLAbstractType,\n GraphQLField,\n GraphQLInputObjectType,\n GraphQLInputType,\n GraphQLObjectType,\n GraphQLOutputType,\n GraphQLSchema,\n} from 'graphql'\nimport type { FieldData, GraphQLData, ResolverData } from './data.ts'\nimport type { DiscriminatorModel } from './model.ts'\nimport type { ScalarDeclaration } from './scalars.ts'\n\nimport { ASYNC_ITERABLES, BASE_KEEP, Codes, compareStrings, OUTPUT_ITERABLES } from './constants.ts'\nimport { graphqlModules } from './graphql-js.ts'\nimport { GraphQLIds } from './ids.ts'\nimport { annotationLocation, returnTypeLocation } from './locate.ts'\n\ntype Context = ValidateContext<GraphQLData>\n\n/** A resolver method bound to an SDL field. */\nexport interface Binding {\n readonly resolver: ResolverData\n readonly field: FieldData\n readonly method: MethodInfo\n /** The type declaring the field (a root type for root fields). */\n readonly type: GraphQLObjectType\n readonly sdlField: GraphQLField<unknown, unknown>\n}\n\n/** Inputs of {@link checkConformance}. */\nexport interface ConformanceInput {\n readonly ctx: Context\n readonly schema: GraphQLSchema\n readonly locate: (node: ASTNode | null | undefined) => Location | undefined\n /** `scalar<T>()` declarations by GraphQL name. */\n readonly scalars: ReadonlyMap<string, ScalarDeclaration>\n /** Sorted by resolver identity, then source order. */\n readonly bindings: readonly Binding[]\n /** Coordinates (`Event.owner`) bound to a resolver. */\n readonly bound: ReadonlySet<string>\n readonly report: (diagnostic: Diagnostic) => void\n}\n\n/** What the walk decides for the model. */\nexport interface ConformanceResult {\n /** Coordinates of the arguments (`Query.books(limit:)`) and input fields (`BookFilter.genre`) whose `null` becomes `undefined`. */\n readonly nullAsUndefined: ReadonlySet<string>\n /** Discriminators of the abstract types; absent: `typename`. */\n readonly discriminators: ReadonlyMap<string, DiscriminatorModel>\n}\n\n/** Where a TypeScript type is checked. */\ninterface Site {\n /** What the type is, in messages: `EventResolver.event returns`, `User.email is`. */\n readonly label: string\n /** Where the TypeScript type comes from, in messages: `returned by EventResolver.event`. */\n readonly origin: string\n /** The SDL coordinate, in messages: `Query.event`, `Event.owner`, `Query.events(limit:)`. */\n readonly coordinate: string\n /** The TypeScript annotation (called only when a diagnostic is reported). */\n readonly locate: () => Location | undefined\n /** The SDL definition. */\n readonly sdl: Location | undefined\n /** An optional property (output: may be `undefined`). */\n readonly optional: boolean\n /** The type of the field or argument, when `type` is the type of its list items. */\n readonly list?: string\n}\n\n/** Options of an input position. */\ninterface InputPosition {\n /** The TypeScript value may be `undefined`: optional parameter or property, parameter default. */\n readonly optional: boolean\n /** The SDL argument or input field has a default value: never absent. */\n readonly sdlDefault: boolean\n /** Coordinate whose `nullAsUndefined` this position votes for. */\n readonly vote?: string\n /** A list item: never absent, and a `null` item stays `null` (no `nullAsUndefined`). */\n readonly item?: true\n}\n\n/** A shape split into its non-nullish members. */\ninterface Parts {\n readonly members: Shape[]\n hasNull: boolean\n hasUndefined: boolean\n /** `unknown`, `any` or an opaque part: not checked. */\n unchecked: boolean\n}\n\nconst MAX_DEPTH = 64\n\n/** Walks every binding; reports the mismatches. */\nexport function checkConformance(input: ConformanceInput): ConformanceResult {\n return new Conformance(input).run()\n}\n\nclass Conformance {\n readonly #config: ConformanceInput\n readonly #ctx: Context\n readonly #options: ShapeOptions\n readonly #named = new Map<string, NamedShape>()\n readonly #visited = new Set<string>()\n readonly #anonymous = new WeakMap<object, Set<string>>()\n readonly #reported = new Set<string>()\n readonly #votes = new Map<string, { accepts: number; rejects: Site[] }>()\n /** Abstract type → member object type → class identities (`''`: not an exported class) returned for it. */\n readonly #members = new Map<string, Map<string, Set<string>>>()\n /** TypeScript members of abstract types that cannot be told apart (ZNIGHT064 unless every member is a class). */\n readonly #untellable = new Map<\n string,\n { readonly name: string; readonly site: Site; readonly location?: Location }[]\n >()\n readonly #predicates = graphqlModules().type\n /** Identities of the `T` of the `scalar<T>()` declarations. */\n readonly #scalarTypes: ReadonlySet<string>\n\n constructor(input: ConformanceInput) {\n this.#config = input\n this.#ctx = input.ctx\n const keep = new Set<string>(BASE_KEEP)\n for (const scalar of input.scalars.values()) keep.add(scalar.type)\n this.#scalarTypes = new Set([...input.scalars.values()].map(scalar => scalar.type))\n this.#options = Object.freeze({\n keep: Object.freeze([...keep].sort(compareStrings)),\n members: 'instance',\n jsdoc: false,\n })\n }\n\n run(): ConformanceResult {\n for (const binding of this.#config.bindings) this.#binding(binding)\n const nullAsUndefined = new Set<string>()\n for (const [coordinate, vote] of [...this.#votes].sort(([a], [b]) => compareStrings(a, b))) {\n if (vote.rejects.length === 0) continue\n if (vote.accepts === 0) {\n nullAsUndefined.add(coordinate)\n continue\n }\n for (const site of vote.rejects) {\n this.#mismatch(\n site,\n `${site.label} does not accept null, but another use of ${coordinate} does: null is passed as is`,\n ['Accept null (| null) in every TypeScript type of the value, or none of them'],\n )\n }\n }\n return { nullAsUndefined, discriminators: this.#discriminators() }\n }\n\n // ------------------------------------------------------------------------------------ bindings\n\n #binding(binding: Binding): void {\n const { resolver, field, method, type, sdlField } = binding\n const where = `${resolver.host.displayName}.${method.name}`\n const coordinate = `${type.name}.${sdlField.name}`\n const sdl = this.#config.locate(sdlField.astNode)\n if (method.returnType !== undefined) {\n const result = this.#shape({ returnOf: method })\n const site: Site = {\n label: `${where} returns`,\n origin: `returned by ${where}`,\n coordinate,\n locate: () => returnTypeLocation(this.#ctx.project, method) ?? method.location,\n sdl,\n optional: false,\n }\n const root = result.root\n const iterable = root.kind === 'reference' && ASYNC_ITERABLES.has(root.identity) ? root : undefined\n if (field.operation === 'subscription') {\n if (iterable !== undefined) {\n this.#output(sdlField.type, iterable.typeArgs[0] ?? { kind: 'unknown' }, site)\n } else if (!this.#parts(root).unchecked) {\n this.#report({\n code: Codes.InvalidResolver,\n severity: 'error',\n message: `@Subscription ${where} must return an async iterable (${coordinate})`,\n location: site.locate() ?? method.location,\n hints: [\n `Declare it as an async generator (async *${method.name}(): AsyncGenerator<Event>) or return pubsub.subscribe(...) (AsyncIterable<Event>)`,\n ],\n })\n }\n } else if (iterable === undefined) {\n this.#output(sdlField.type, root, site)\n } else {\n this.#mismatch(site, `${where} returns an async iterable: only Subscription fields stream values`, [\n `Use @Subscription() for a stream of events, or return the value of ${coordinate}`,\n ])\n }\n }\n field.params.forEach((data, index) => {\n const param = method.params[index] as ParameterInfo | undefined\n if (param === undefined) return\n if (data?.kind === 'args' && data.schema === undefined) this.#arguments(binding, data.name, param, where)\n else if (data?.kind === 'parent') this.#parent(type, param, where)\n })\n }\n\n /** `@Args('name')` (one argument) or `@Args()` (every argument, an object type). */\n #arguments(binding: Binding, name: string | undefined, param: ParameterInfo, where: string): void {\n const { type, sdlField } = binding\n const coordinate = `${type.name}.${sdlField.name}`\n const result = this.#shape({ parameter: param })\n if (name !== undefined) {\n const arg = sdlField.args.find(candidate => candidate.name === name)\n if (arg === undefined) return // coverage (schema-first.ts)\n this.#input(\n arg.type,\n result.root,\n {\n optional: param.optional || param.hasDefault,\n sdlDefault: arg.default !== undefined,\n vote: `${coordinate}(${name}:)`,\n },\n {\n label: `parameter '${param.name}' of ${where}`,\n origin: `parameter '${param.name}' of ${where}`,\n coordinate: `${coordinate}(${name}:)`,\n locate: () => param.typeLocation,\n sdl: this.#config.locate(arg.astNode),\n optional: false,\n },\n )\n return\n }\n const site: Site = {\n label: `@Args() parameter '${param.name}' of ${where}`,\n origin: `@Args() parameter '${param.name}' of ${where}`,\n coordinate,\n locate: () => param.typeLocation,\n sdl: this.#config.locate(sdlField.astNode),\n optional: false,\n }\n const parts = this.#parts(result.root)\n if (parts.unchecked) return\n const object = parts.members.length === 1 ? (parts.members[0] as Shape) : undefined\n const properties = object === undefined ? undefined : this.#propertiesOf(object)\n if (properties === 'record') return\n if (properties === undefined) {\n this.#mismatch(site, `${site.label} must be an object type: it receives every argument of ${coordinate}`, [\n `@Args('name') receives one argument`,\n ])\n return\n }\n for (const property of properties) {\n const arg = sdlField.args.find(candidate => candidate.name === property.name)\n const propertySite: Site = {\n label: `property '${property.name}' of the @Args() parameter of ${where}`,\n origin: site.origin,\n coordinate: `${coordinate}(${property.name}:)`,\n locate: () => annotationLocation(this.#ctx.project, property.location) ?? param.typeLocation,\n sdl: this.#config.locate(arg?.astNode ?? sdlField.astNode),\n optional: false,\n }\n if (arg === undefined) {\n const names = sdlField.args.map(candidate => candidate.name)\n this.#mismatch(\n { ...propertySite, locate: () => property.location ?? param.typeLocation },\n `${coordinate} has no argument '${property.name}' (${propertySite.label})`,\n [names.length === 0 ? `${coordinate} takes no argument` : `Its arguments: ${names.join(', ')}`],\n )\n continue\n }\n this.#input(\n arg.type,\n property.shape,\n { optional: property.optional, sdlDefault: arg.default !== undefined, vote: propertySite.coordinate },\n propertySite,\n )\n }\n }\n\n /** `@Parent()`: its properties named like the unbound fields of the type conform to them. */\n #parent(type: GraphQLObjectType, param: ParameterInfo, where: string): void {\n const result = this.#shape({ parameter: param })\n const site: Site = {\n label: `@Parent() parameter '${param.name}' of ${where}`,\n origin: `@Parent() parameter of ${where}`,\n coordinate: type.name,\n locate: () => param.typeLocation,\n sdl: this.#config.locate(type.astNode),\n optional: false,\n }\n const parts = this.#parts(result.root)\n if (parts.unchecked) return\n for (const member of parts.members) {\n const properties = this.#propertiesOf(member)\n if (properties === 'record') continue\n if (properties === undefined) {\n this.#mismatch(site, `${site.label} is ${this.#describe(member)}, not an object type (${type.name})`, [\n `Type it with the TypeScript type of ${type.name}`,\n ])\n continue\n }\n const fields = type.getFields()\n for (const property of properties) {\n const field = fields[property.name]\n if (field === undefined || this.#config.bound.has(`${type.name}.${field.name}`)) continue\n this.#output(field.type, property.shape, this.#propertySite(site, type, field, property, member))\n }\n }\n }\n\n // -------------------------------------------------------------------------------------- output\n\n #output(type: GraphQLOutputType, shape: Shape, site: Site, depth = 0): void {\n if (depth > MAX_DEPTH) return\n const parts = this.#parts(shape)\n if (parts.unchecked) return\n const { isNonNullType, isListType, isScalarType, isEnumType, isObjectType } = this.#predicates\n let inner = type\n if (isNonNullType(inner)) {\n if (parts.hasNull || parts.hasUndefined || site.optional) {\n const what = parts.hasNull ? 'null' : 'undefined'\n const described = `${site.label} ${this.#describeParts(parts, site.optional)}, which may be ${what}`\n if (site.list === undefined) {\n this.#mismatch(site, `${described}, but ${site.coordinate} is ${String(type)} (non-null)`, [\n `Return a value in every case, or make ${site.coordinate} nullable in the SDL (${String(inner.ofType)})`,\n ])\n } else {\n this.#mismatch(\n site,\n `${described}, but the items of ${site.coordinate} (${site.list}) are ${String(type)} (non-null)`,\n [`Return non-null items, or make the items of ${site.coordinate} nullable in the SDL`],\n )\n }\n }\n inner = inner.ofType\n }\n if (parts.members.length === 0) return\n if (isListType(inner)) {\n for (const member of parts.members) {\n const item = this.#listItem(member, 'output')\n if (item === undefined) {\n this.#mismatch(\n site,\n `${site.label} ${this.#describe(member)}, not a list, but ${site.coordinate} is ${String(type)}`,\n ['Return an array (readonly T[]), a Set or an Iterable'],\n )\n continue\n }\n for (const shape of item) {\n this.#output(\n inner.ofType,\n shape,\n { ...site, label: `${site.label} a list of`, optional: false, list: site.list ?? String(type) },\n depth + 1,\n )\n }\n }\n return\n }\n if (isScalarType(inner)) {\n for (const member of parts.members) {\n if (this.#scalarAccepts(inner.name, member, 'output')) continue\n this.#mismatch(\n site,\n `${site.label} ${this.#describe(member)}, which does not conform to ${inner.name} (${site.coordinate})`,\n [this.#scalarHint(inner.name)],\n )\n }\n return\n }\n if (isEnumType(inner)) {\n const values = new Set(inner.getValues().map(value => value.name))\n for (const member of parts.members) {\n const literals = this.#literals(member)\n if (literals === undefined) {\n this.#mismatch(\n site,\n `${site.label} ${this.#describe(member)}, wider than the enum ${inner.name} (${site.coordinate})`,\n [\n `Return the values of ${inner.name}: ${[...values].join(', ')} (a TypeScript enum or a union of literals)`,\n ],\n )\n continue\n }\n const unknown = literals.filter(literal => !values.has(String(literal)))\n if (unknown.length > 0) {\n this.#mismatch(\n site,\n `${site.label} ${unknown.map(literal => JSON.stringify(literal)).join(', ')}, not ${unknown.length === 1 ? 'a value' : 'values'} of the enum ${inner.name} (${site.coordinate})`,\n [`Enum values are compared by value: ${[...values].join(', ')}`],\n )\n }\n }\n return\n }\n if (isObjectType(inner)) {\n for (const member of parts.members) this.#object(inner, member, site, depth)\n return\n }\n this.#abstract(inner, parts.members, site, depth)\n }\n\n /** An object type returned as `shape`: every field without resolver is a conforming property. */\n #object(type: GraphQLObjectType, shape: Shape, site: Site, depth: number): void {\n const properties = this.#propertiesOf(shape)\n if (properties === 'record') return\n if (properties === undefined) {\n this.#mismatch(\n site,\n `${site.label} ${this.#describe(shape)}, not an object type, but ${site.coordinate} is ${type.name}`,\n [`Return the TypeScript type of ${type.name} (an interface, a class or an object type)`],\n )\n return\n }\n if (!this.#visit(`output\\0${type.name}`, shape)) return\n const named = shape.kind === 'named' ? this.#named.get(shape.key) : undefined\n const tsName = named?.name ?? 'the returned object type'\n const byName = new Map(properties.map(property => [property.name, property]))\n for (const field of Object.values(type.getFields())) {\n const coordinate = `${type.name}.${field.name}`\n if (this.#config.bound.has(coordinate)) continue\n const property = byName.get(field.name)\n if (property === undefined) {\n const location = this.#config.locate(field.astNode)\n const declaration = named?.location ?? site.locate()\n this.#reportOnce(`provide\\0${coordinate}\\0${named?.key ?? site.label}`, {\n code: Codes.SchemaMismatch,\n severity: 'error',\n message: `${coordinate} has no resolver, and ${tsName} (${site.origin}) has no property '${field.name}'`,\n ...(location === undefined ? {} : { location }),\n hints: [\n `Add a field resolver: @ResolveField('${field.name}') in a @Resolver('${type.name}') class`,\n `Or add '${field.name}' to ${tsName}`,\n ],\n ...(declaration === undefined\n ? {}\n : { related: [{ message: `${tsName} is declared here`, location: declaration }] }),\n })\n continue\n }\n this.#output(field.type, property.shape, this.#propertySite(site, type, field, property, shape), depth + 1)\n }\n }\n\n /** A union or an interface: each TypeScript member is matched to a possible type. */\n #abstract(type: GraphQLAbstractType, members: readonly Shape[], site: Site, depth: number): void {\n const possible = this.#config.schema.getPossibleTypes(type)\n const names = possible.map(object => object.name)\n for (const member of members) {\n const named = member.kind === 'named' ? this.#named.get(member.key) : undefined\n const properties = this.#propertiesOf(member)\n if (properties === undefined) {\n this.#mismatch(\n site,\n `${site.label} ${this.#describe(member)}, not an object type, but ${site.coordinate} is ${type.name}`,\n [`Return one of ${names.join(', ')}`],\n )\n continue\n }\n if (properties === 'record') continue\n // graphql-codegen's interface types (`Node`): checked against the fields of the interface\n if (named?.name === type.name && this.#predicates.isInterfaceType(type)) {\n if (!this.#visit(`interface\\0${type.name}`, member)) continue\n const byName = new Map(properties.map(property => [property.name, property]))\n for (const field of Object.values(type.getFields())) {\n const property = byName.get(field.name)\n if (property !== undefined) {\n this.#output(field.type, property.shape, this.#propertySite(site, type, field, property, member), depth + 1)\n }\n }\n continue\n }\n const typename = properties.find(property => property.name === '__typename')\n const literal = typename?.shape.kind === 'literal' ? typename.shape.value : undefined\n // a member is recognised by its `__typename` literal, else by its name\n let target = typeof literal === 'string' ? literal : undefined\n if (target === undefined && named !== undefined && names.includes(named.name)) target = named.name\n if (target === undefined || !names.includes(target)) {\n const what = named?.name ?? this.#describe(member)\n if (names.length === 0) {\n this.#mismatch(site, `${site.label} ${what}, but no object type implements ${type.name} in the SDL`, [\n `Declare an implementation: type ${what} implements ${type.name} { ... }`,\n ])\n continue\n }\n this.#mismatch(\n site,\n `${site.label} ${what}, which is not ${names.length === 1 ? 'the member' : 'a member'} of ${type.name} (${names.join(', ')})`,\n [\n `Return ${names.join(' | ')}: a member is recognised by its __typename literal (__typename: '${names[0] ?? 'Member'}'), else by its name`,\n ],\n )\n continue\n }\n const object = this.#config.schema.getType(target) as GraphQLObjectType\n this.#object(object, member, site, depth + 1)\n const identity =\n named?.declaration === 'class' &&\n named.typeArgs.length === 0 &&\n this.#ctx.classInfo(named.identity)?.exported === true\n ? named.identity\n : ''\n let byMember = this.#members.get(type.name)\n if (byMember === undefined) {\n byMember = new Map()\n this.#members.set(type.name, byMember)\n }\n let identities = byMember.get(target)\n if (identities === undefined) {\n identities = new Set()\n byMember.set(target, identities)\n }\n identities.add(identity)\n if (typename === undefined && identity === '') {\n let list = this.#untellable.get(type.name)\n if (list === undefined) {\n list = []\n this.#untellable.set(type.name, list)\n }\n list.push({ name: named?.name ?? target, site, ...(named === undefined ? {} : { location: named.location }) })\n }\n }\n }\n\n // --------------------------------------------------------------------------------------- input\n\n #input(type: GraphQLInputType, shape: Shape, position: InputPosition, site: Site, depth = 0): void {\n if (depth > MAX_DEPTH) return\n const parts = this.#parts(shape)\n const { isNonNullType, isListType, isScalarType, isEnumType } = this.#predicates\n let inner = type\n if (isNonNullType(inner)) inner = inner.ofType\n else {\n const acceptsNull = parts.hasNull || parts.unchecked\n // a list item is never absent, and a null item is never turned into undefined\n const acceptsUndefined = position.item !== true && (parts.hasUndefined || position.optional || parts.unchecked)\n if (position.item === true) {\n if (!acceptsNull) {\n this.#mismatch(\n site,\n `${site.label} does not accept null, but the items of ${site.coordinate} (${site.list ?? String(type)}) may be null`,\n [`Accept null items ((T | null)[]), or make the items non-null in the SDL (${String(type)}!)`],\n )\n }\n } else if (!position.sdlDefault && !acceptsUndefined) {\n this.#mismatch(\n site,\n `${site.label} does not accept undefined, but ${site.coordinate} (${String(type)}) may be omitted`,\n ['Make it optional (?: or | undefined), or make the SDL argument non-null or give it a default value'],\n )\n } else if (!acceptsNull && !acceptsUndefined) {\n this.#mismatch(\n site,\n `${site.label} does not accept null, but ${site.coordinate} (${String(type)}) may be null`,\n [`Accept null (| null) or undefined, or make it non-null in the SDL (${String(type)}!)`],\n )\n }\n if (position.vote !== undefined && !parts.unchecked) {\n let vote = this.#votes.get(position.vote)\n if (vote === undefined) {\n vote = { accepts: 0, rejects: [] }\n this.#votes.set(position.vote, vote)\n }\n if (acceptsNull) vote.accepts++\n else if (acceptsUndefined) vote.rejects.push(site)\n }\n }\n if (parts.unchecked) return\n if (parts.members.length === 0) {\n this.#mismatch(site, `${site.label} accepts no ${String(inner)} value (${site.coordinate})`, [\n `Type it with the TypeScript type of ${String(inner)}`,\n ])\n return\n }\n if (isListType(inner)) {\n const lists = parts.members.map(member => this.#listItem(member, 'input')).filter(item => item !== undefined)\n if (lists.length === 0) {\n this.#mismatch(\n site,\n `${site.label} is ${this.#describeParts(parts, false)}, not an array, but ${site.coordinate} is ${String(type)}`,\n ['Accept an array (readonly T[]): graphql-js always passes lists as arrays'],\n )\n return\n }\n for (const items of lists) {\n for (const item of items) {\n this.#input(\n inner.ofType,\n item,\n { optional: false, sdlDefault: true, item: true },\n { ...site, label: `${site.label} (items)`, list: site.list ?? String(type) },\n depth + 1,\n )\n }\n }\n return\n }\n if (isScalarType(inner)) {\n if (parts.members.some(member => this.#scalarAccepts(inner.name, member, 'input'))) return\n this.#mismatch(\n site,\n `${site.label} is ${this.#describeParts(parts, false)}, which does not accept every ${inner.name} (${site.coordinate})`,\n [this.#scalarHint(inner.name)],\n )\n return\n }\n if (isEnumType(inner)) {\n const accepted = new Set<string>()\n for (const member of parts.members) {\n if (member.kind === 'string') return\n for (const literal of this.#literals(member) ?? []) accepted.add(String(literal))\n }\n const missing = inner.getValues().filter(value => !accepted.has(value.name))\n if (missing.length > 0) {\n this.#mismatch(\n site,\n `${site.label} is ${this.#describeParts(parts, false)}, which does not accept ${missing.map(value => value.name).join(', ')} of the enum ${inner.name} (${site.coordinate})`,\n [`Accept every value of ${inner.name} (graphql-codegen's enum type, or a union of every value)`],\n )\n }\n return\n }\n const objects = parts.members.filter(member => this.#propertiesOf(member) !== undefined)\n if (objects.length === 0) {\n this.#mismatch(\n site,\n `${site.label} is ${this.#describeParts(parts, false)}, not an object type, but ${site.coordinate} is ${inner.name}`,\n [`Type it with the TypeScript type of the input ${inner.name}`],\n )\n return\n }\n for (const object of objects) this.#inputObject(inner as GraphQLInputObjectType, object, site, depth)\n }\n\n /** An input object received as `shape`: each property is a field of the input, accepting its values. */\n #inputObject(type: GraphQLInputObjectType, shape: Shape, site: Site, depth: number): void {\n const properties = this.#propertiesOf(shape)\n if (properties === undefined || properties === 'record') return\n if (!this.#visit(`input\\0${type.name}`, shape)) return\n const fields = type.getFields()\n for (const property of properties) {\n if (property.name === '__typename') continue\n const field = fields[property.name]\n const propertySite: Site = {\n label:\n this.#tsName(shape) === undefined ? `property '${property.name}'` : `${this.#tsName(shape)}.${property.name}`,\n origin: site.origin,\n coordinate: `${type.name}.${property.name}`,\n locate: () => annotationLocation(this.#ctx.project, property.location) ?? site.locate(),\n sdl: this.#config.locate(field?.astNode ?? type.astNode),\n optional: false,\n }\n if (field === undefined) {\n this.#mismatch(\n { ...propertySite, locate: () => property.location ?? site.locate() },\n `${propertySite.label} is not a field of the input ${type.name}: it is always undefined`,\n [`Remove it, or declare it in the SDL (input ${type.name} { ${property.name}: ... })`],\n )\n continue\n }\n this.#input(\n field.type,\n property.shape,\n { optional: property.optional, sdlDefault: field.default !== undefined, vote: propertySite.coordinate },\n propertySite,\n depth + 1,\n )\n }\n }\n\n // ------------------------------------------------------------------------------------- scalars\n\n /** A member (not nullish, not a union) conforms to a scalar: output, or accepts every value: input. */\n #scalarAccepts(name: string, shape: Shape, position: 'input' | 'output'): boolean {\n const custom = this.#config.scalars.get(name)\n if (custom !== undefined) return this.#hasReference(shape, custom.type)\n // the type of another scalar<T>() declaration (a branded id for an ID or a String): its\n // representation is not known, string-like scalars only\n if ((name === 'String' || name === 'ID') && shape.kind === 'reference' && this.#scalarTypes.has(shape.identity)) {\n return true\n }\n const output = position === 'output'\n switch (name) {\n case 'String':\n return this.#isString(shape, output)\n case 'ID':\n return this.#isString(shape, output) || (output && this.#isNumber(shape, true))\n case 'Int':\n case 'Float':\n return this.#isNumber(shape, output)\n case 'Boolean':\n return shape.kind === 'boolean' || (output && shape.kind === 'literal' && typeof shape.value === 'boolean')\n case 'DateTime':\n return shape.kind === 'date'\n case 'BigInt':\n return shape.kind === 'bigint' || (output && this.#isNumber(shape, true))\n default:\n // JSON and the built-in scalars without TypeScript counterpart\n return true\n }\n }\n\n #scalarHint(name: string): string {\n const custom = this.#config.scalars.get(name)\n if (custom !== undefined) {\n return `${name} is declared with scalar<${custom.type.slice(custom.type.indexOf('#') + 1)}>(): use that type (graphql-codegen: scalars: { ${name}: '...' })`\n }\n switch (name) {\n case 'Int':\n case 'Float':\n return 'Use number (or the Int / Float aliases of @znight/graphql)'\n case 'Boolean':\n return 'Use boolean'\n case 'DateTime':\n return 'The built-in DateTime scalar is a Date'\n case 'BigInt':\n return 'The built-in BigInt scalar is a bigint'\n default:\n return 'Use string (string literals, string enums and branded strings conform in output positions)'\n }\n }\n\n /** `string`, a branded string, the `ID` alias; output: also string literals and string enums. */\n #isString(shape: Shape, output: boolean): boolean {\n switch (shape.kind) {\n case 'string':\n return true\n case 'literal':\n return output && typeof shape.value === 'string'\n case 'reference':\n return shape.identity === GraphQLIds.ID\n case 'intersection':\n return shape.members.some(\n member => member.kind === 'string' || (member.kind === 'reference' && member.identity === GraphQLIds.ID),\n )\n case 'named': {\n const named = this.#named.get(shape.key)\n return (\n output &&\n named?.declaration === 'enum' &&\n (this.#literals(shape) ?? []).every(value => typeof value === 'string')\n )\n }\n default:\n return false\n }\n }\n\n /** `number`, a branded number, the `Int` / `Float` aliases; output: also number literals and numeric enums. */\n #isNumber(shape: Shape, output: boolean): boolean {\n const alias = (candidate: Shape): boolean =>\n candidate.kind === 'reference' &&\n (candidate.identity === GraphQLIds.Int || candidate.identity === GraphQLIds.Float)\n switch (shape.kind) {\n case 'number':\n return true\n case 'literal':\n return output && typeof shape.value === 'number'\n case 'reference':\n return alias(shape)\n case 'intersection':\n return shape.members.some(member => member.kind === 'number' || alias(member))\n case 'named': {\n const named = this.#named.get(shape.key)\n return (\n output &&\n named?.declaration === 'enum' &&\n (this.#literals(shape) ?? []).every(value => typeof value === 'number')\n )\n }\n default:\n return false\n }\n }\n\n #hasReference(shape: Shape, identity: string): boolean {\n if (shape.kind === 'reference') return shape.identity === identity\n if (shape.kind === 'intersection') return shape.members.some(member => this.#hasReference(member, identity))\n return false\n }\n\n // -------------------------------------------------------------------------------------- shapes\n\n #shape(target: { readonly parameter: ParameterInfo } | { readonly returnOf: MethodInfo }): ShapeResult {\n const result = this.#ctx.types.shape(target, this.#options)\n for (const named of result.named.values()) this.#named.set(named.key, named)\n return result\n }\n\n /** The non-nullish members of a shape, through unions and aliases (object aliases stay named). */\n #parts(shape: Shape): Parts {\n const parts: Parts = { members: [], hasNull: false, hasUndefined: false, unchecked: false }\n const visit = (current: Shape, depth: number): void => {\n if (depth > MAX_DEPTH) return\n switch (current.kind) {\n case 'null':\n parts.hasNull = true\n return\n case 'undefined':\n parts.hasUndefined = true\n return\n case 'unknown':\n case 'opaque':\n case 'schema':\n parts.unchecked = true\n return\n case 'never':\n return\n case 'union':\n for (const member of current.members) visit(member, depth + 1)\n return\n case 'named': {\n const named = this.#named.get(current.key)\n if (named === undefined) {\n parts.unchecked = true\n return\n }\n const target = named.shape\n const isObject =\n target.kind === 'object' ||\n (target.kind === 'intersection' && this.#propertiesOf(target) !== undefined) ||\n (target.kind === 'named' && this.#named.get(target.key)?.declaration !== 'alias')\n if (named.declaration !== 'alias' || isObject) parts.members.push(current)\n else visit(target, depth + 1)\n return\n }\n default:\n parts.members.push(current)\n }\n }\n visit(shape, 0)\n return parts\n }\n\n /** The item shapes of a list member (array, tuple, iterable); `undefined`: not a list. */\n #listItem(shape: Shape, position: 'input' | 'output'): readonly Shape[] | undefined {\n if (shape.kind === 'array') return [shape.items]\n if (shape.kind === 'tuple')\n return position === 'output' ? [...shape.items, ...(shape.rest === undefined ? [] : [shape.rest])] : undefined\n if (shape.kind === 'reference' && position === 'output' && OUTPUT_ITERABLES.has(shape.identity)) {\n return [shape.typeArgs[0] ?? { kind: 'unknown' }]\n }\n return undefined\n }\n\n /** The literal values of a member: a literal, an enum; `undefined`: not literals. */\n #literals(shape: Shape): readonly (string | number | boolean)[] | undefined {\n if (shape.kind === 'literal') return [shape.value]\n if (shape.kind !== 'named') return undefined\n const named = this.#named.get(shape.key)\n if (named?.declaration !== 'enum') return undefined\n if (named.enumMembers !== undefined) return named.enumMembers.map(member => member.value)\n const target = named.shape\n if (target.kind === 'literal') return [target.value]\n if (target.kind === 'union' && target.members.every(member => member.kind === 'literal')) {\n return target.members.map(member => (member as { value: string | number | boolean }).value)\n }\n return undefined\n }\n\n /** The properties of an object structure (intersections merged, later members win), `'record'` for index signatures. */\n #propertiesOf(shape: Shape, depth = 0): readonly ShapeProperty[] | 'record' | undefined {\n if (depth > MAX_DEPTH) return undefined\n switch (shape.kind) {\n case 'object':\n return shape.additional === undefined ? shape.properties : 'record'\n case 'named': {\n const named = this.#named.get(shape.key)\n return named === undefined || named.declaration === 'enum'\n ? undefined\n : this.#propertiesOf(named.shape, depth + 1)\n }\n case 'intersection': {\n const merged = new Map<string, ShapeProperty>()\n for (const member of shape.members) {\n const properties = this.#propertiesOf(member, depth + 1)\n if (properties === undefined || properties === 'record') return properties\n for (const property of properties) {\n merged.delete(property.name)\n merged.set(property.name, property)\n }\n }\n return [...merged.values()]\n }\n default:\n return undefined\n }\n }\n\n /** `true` the first time `(namespace, shape)` is visited: named shapes by key, anonymous ones by identity. */\n #visit(namespace: string, shape: Shape): boolean {\n if (shape.kind === 'named') {\n const key = `${namespace}\\0${shape.key}`\n if (this.#visited.has(key)) return false\n this.#visited.add(key)\n return true\n }\n let seen = this.#anonymous.get(shape)\n if (seen === undefined) {\n seen = new Set()\n this.#anonymous.set(shape, seen)\n }\n if (seen.has(namespace)) return false\n seen.add(namespace)\n return true\n }\n\n #propertySite(\n site: Site,\n type: GraphQLObjectType | GraphQLAbstractType,\n field: GraphQLField<unknown, unknown>,\n property: ShapeProperty,\n owner: Shape,\n ): Site {\n const name = this.#tsName(owner)\n return {\n label: `${name === undefined ? `property '${property.name}'` : `${name}.${property.name}`} is`,\n origin: `type of ${name === undefined ? `property '${property.name}'` : `${name}.${property.name}`}, ${site.origin}`,\n coordinate: `${type.name}.${field.name}`,\n locate: () => annotationLocation(this.#ctx.project, property.location) ?? site.locate(),\n sdl: this.#config.locate(field.astNode),\n optional: property.optional,\n }\n }\n\n #tsName(shape: Shape): string | undefined {\n return shape.kind === 'named' ? this.#named.get(shape.key)?.name : undefined\n }\n\n // ---------------------------------------------------------------------------------- discriminators\n\n /**\n * `instanceof` when every TypeScript member returned for an abstract type is an exported class\n * (one per member), else `__typename`; members that are neither are ZNIGHT064.\n */\n #discriminators(): ReadonlyMap<string, DiscriminatorModel> {\n const result = new Map<string, DiscriminatorModel>()\n for (const [name, byMember] of [...this.#members].sort(([a], [b]) => compareStrings(a, b))) {\n // every exported class returned for a member: instanceof first, __typename as the fallback\n const classes: { identity: string; name: string; depth: number }[] = []\n for (const [member, identities] of byMember) {\n for (const identity of identities) {\n if (identity !== '') classes.push({ identity, name: member, depth: this.#classDepth(identity) })\n }\n }\n if (classes.length > 0) {\n // subclasses first: `instanceof` matches the most derived class\n classes.sort(\n (a, b) => b.depth - a.depth || compareStrings(a.name, b.name) || compareStrings(a.identity, b.identity),\n )\n result.set(name, {\n by: 'class',\n classes: classes.map(({ identity, name: member }) => ({ identity, name: member })),\n })\n }\n for (const entry of this.#untellable.get(name) ?? []) {\n const location = entry.site.locate()\n this.#reportOnce(`untellable\\0${name}\\0${entry.name}`, {\n code: Codes.UnresolvableAbstractType,\n severity: 'error',\n message: `${entry.name} cannot be told apart among the members of ${name} at runtime: it declares no __typename and is not an exported class`,\n ...(location === undefined ? {} : { location }),\n hints: [\n `Return objects carrying __typename (declare __typename: '${entry.name}' in the TypeScript type; graphql-codegen declares it), or return exported class instances`,\n ],\n ...(entry.location === undefined\n ? {}\n : { related: [{ message: `${entry.name} is declared here`, location: entry.location }] }),\n })\n }\n }\n return result\n }\n\n #classDepth(identity: string): number {\n let depth = 0\n let current = this.#ctx.classInfo(identity)?.superClass?.identity\n const seen = new Set<string>()\n while (current !== undefined && !seen.has(current) && depth < MAX_DEPTH) {\n seen.add(current)\n depth++\n current = this.#ctx.classInfo(current)?.superClass?.identity\n }\n return depth\n }\n\n // ------------------------------------------------------------------------------------ reporting\n\n #report(diagnostic: Diagnostic): void {\n this.#config.report(diagnostic)\n }\n\n #reportOnce(key: string, diagnostic: Diagnostic): void {\n if (this.#reported.has(key)) return\n this.#reported.add(key)\n this.#report(diagnostic)\n }\n\n #mismatch(site: Site, message: string, hints: readonly string[]): void {\n const location = site.locate()\n const key = `${location?.file}:${location?.start}\\0${message}`\n this.#reportOnce(key, {\n code: Codes.SchemaMismatch,\n severity: 'error',\n message,\n ...(location === undefined ? {} : { location }),\n ...(hints.length === 0 ? {} : { hints }),\n ...(site.sdl === undefined\n ? {}\n : { related: [{ message: `${site.coordinate} is declared here`, location: site.sdl }] }),\n })\n }\n\n // ----------------------------------------------------------------------------------- messages\n\n #describeParts(parts: Parts, optional: boolean): string {\n const members = parts.members.map(member => this.#describe(member))\n if (parts.hasNull) members.push('null')\n if (parts.hasUndefined || optional) members.push('undefined')\n return members.join(' | ')\n }\n\n /** Short description of a shape for messages (`string`, `Book`, `'a'`, `Book[]`). */\n #describe(shape: Shape): string {\n switch (shape.kind) {\n case 'literal':\n return JSON.stringify(shape.value)\n case 'named':\n return this.#named.get(shape.key)?.name ?? shape.key.slice(shape.key.indexOf('#') + 1)\n case 'reference':\n return shape.name\n case 'opaque':\n return shape.text\n case 'array':\n return `${this.#describe(shape.items)}[]`\n case 'union':\n case 'intersection':\n return shape.members.map(member => this.#describe(member)).join(shape.kind === 'union' ? ' | ' : ' & ')\n case 'object':\n return 'an object literal type'\n case 'tuple':\n return 'a tuple'\n default:\n return shape.kind\n }\n }\n}\n","/**\n * \"Did you mean\" suggestions of the schema-first diagnostics (RFC 0007 §5.3). Import-free.\n */\n\n/**\n * The candidate closest to `name` (Levenshtein distance, case differences counting half), when it\n * is close enough to be a typo: at most a third of the name's length, at least 1. Ties keep the\n * first candidate, so callers pass them sorted.\n */\nexport function closest(name: string, candidates: readonly string[]): string | undefined {\n const limit = Math.max(1, Math.floor(name.length / 3))\n let best: string | undefined\n let bestDistance = Number.POSITIVE_INFINITY\n for (const candidate of candidates) {\n if (candidate === name) continue\n const distance = candidate.toLowerCase() === name.toLowerCase() ? 0.5 : levenshtein(name, candidate)\n if (distance <= limit && distance < bestDistance) {\n best = candidate\n bestDistance = distance\n }\n }\n return best\n}\n\nfunction levenshtein(a: string, b: string): number {\n if (Math.abs(a.length - b.length) > Math.max(a.length, b.length) / 2) return Number.POSITIVE_INFINITY\n let previous = Array.from({ length: b.length + 1 }, (_, index) => index)\n for (let i = 1; i <= a.length; i++) {\n const current = [i]\n for (let j = 1; j <= b.length; j++) {\n const cost = a.charCodeAt(i - 1) === b.charCodeAt(j - 1) ? 0 : 1\n current.push(\n Math.min((previous[j] as number) + 1, (current[j - 1] as number) + 1, (previous[j - 1] as number) + cost),\n )\n }\n previous = current\n }\n return previous[b.length] as number\n}\n","/**\n * The SDL of a schema-first application (RFC 0007 §5.1): the `.graphql` files matching the\n * `schema` globs, parsed with `graphql/language`, checked structurally (duplicates, unknown types\n * and directives, extensions of missing types: located diagnostics with suggestions), then built\n * with `buildASTSchema` and validated with `validateSchema`, so that the build and the runtime agree\n * on what a valid schema is. Every problem is a ZNIGHT067 located in the `.graphql` file.\n */\nimport type { Diagnostic, Location, ValidateContext } from '@znight/compiler'\nimport type {\n ASTNode,\n DefinitionNode,\n DirectiveNode,\n DocumentNode,\n FieldDefinitionNode,\n GraphQLSchema,\n InputValueDefinitionNode,\n NamedTypeNode,\n NameNode,\n TypeNode,\n} from 'graphql'\nimport type { GraphQLData } from './data.ts'\n\nimport { Codes, compareStrings } from './constants.ts'\nimport { graphqlModules } from './graphql-js.ts'\nimport { closest } from './suggest.ts'\n\n/** Directives graphql-js knows (specified, or `@defer`/`@stream` of graphql 17). */\nconst KNOWN_DIRECTIVES: ReadonlySet<string> = new Set([\n 'deprecated',\n 'specifiedBy',\n 'oneOf',\n 'include',\n 'skip',\n 'defer',\n 'stream',\n])\n\n/** A directive as the SDL checks see it: where it applies, its arguments, repeatable or not. */\ninterface DirectiveSpec {\n readonly locations: ReadonlySet<string>\n /** Argument name → required (non-null without default). */\n readonly args: ReadonlyMap<string, boolean>\n readonly repeatable: boolean\n}\n\n/** The built-in directives allowed in an SDL (the others are executable directives). */\nconst SDL_DIRECTIVES: ReadonlyMap<string, DirectiveSpec> = new Map([\n [\n 'deprecated',\n {\n locations: new Set(['FIELD_DEFINITION', 'ARGUMENT_DEFINITION', 'INPUT_FIELD_DEFINITION', 'ENUM_VALUE']),\n args: new Map([['reason', false]]),\n repeatable: false,\n },\n ],\n ['specifiedBy', { locations: new Set(['SCALAR']), args: new Map([['url', true]]), repeatable: false }],\n ['oneOf', { locations: new Set(['INPUT_OBJECT']), args: new Map(), repeatable: false }],\n])\n\n/** The directive location of each kind of type definition and extension. */\nconst TYPE_LOCATIONS: Readonly<Record<string, string>> = {\n type: 'OBJECT',\n interface: 'INTERFACE',\n union: 'UNION',\n enum: 'ENUM',\n input: 'INPUT_OBJECT',\n scalar: 'SCALAR',\n}\n\n/** Names of the types graphql-js always provides. */\nconst PROVIDED_TYPES: ReadonlySet<string> = new Set(['String', 'Int', 'Float', 'Boolean', 'ID'])\n\n/** The parsed and validated SDL. */\nexport interface SdlSource {\n readonly schema: GraphQLSchema\n /** Names of the custom directives (left out of the served schema). */\n readonly customDirectives: ReadonlySet<string>\n /** The location of an AST node (its name when it has one); `undefined` for nodes without location. */\n locate(node: ASTNode | null | undefined): Location | undefined\n}\n\n/** Directive locations in messages. */\nconst LOCATION_NAMES: Readonly<Record<string, string>> = {\n SCHEMA: 'the schema',\n SCALAR: 'scalars',\n OBJECT: 'object types',\n FIELD_DEFINITION: 'fields',\n ARGUMENT_DEFINITION: 'arguments',\n INTERFACE: 'interfaces',\n UNION: 'unions',\n ENUM: 'enums',\n ENUM_VALUE: 'enum values',\n INPUT_OBJECT: 'input objects',\n INPUT_FIELD_DEFINITION: 'input fields',\n}\n\nconst TYPE_KINDS: Readonly<Record<string, string>> = {\n ObjectTypeDefinition: 'type',\n ObjectTypeExtension: 'type',\n InterfaceTypeDefinition: 'interface',\n InterfaceTypeExtension: 'interface',\n UnionTypeDefinition: 'union',\n UnionTypeExtension: 'union',\n EnumTypeDefinition: 'enum',\n EnumTypeExtension: 'enum',\n InputObjectTypeDefinition: 'input',\n InputObjectTypeExtension: 'input',\n ScalarTypeDefinition: 'scalar',\n ScalarTypeExtension: 'scalar',\n}\n\n/** A type definition or extension. */\ntype TypeNodeLike = Extract<DefinitionNode, { readonly name: NameNode }> & { readonly kind: string }\n\n/**\n * Reads, parses and validates the SDL; `undefined` after an error (reported). Warnings (custom\n * directives) do not stop the build.\n */\nexport function loadSdl(\n ctx: ValidateContext<GraphQLData>,\n patterns: readonly string[],\n report: (diagnostic: Diagnostic) => void,\n): SdlSource | undefined {\n const files = ctx.inputFiles(patterns)\n if (files.length === 0) {\n report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message: `No GraphQL schema file matches ${patterns.map(pattern => `'${pattern}'`).join(', ')} (schema-first)`,\n hints: [\n \"The globs of graphql.configure({ schema }) are relative to the project root: 'src/**/*.graphql'\",\n 'Remove the schema option to derive the schema from the TypeScript types (code-first)',\n ],\n })\n return undefined\n }\n const { language, type, utilities } = graphqlModules()\n const locator = new Locator(new Map(files.map(file => [file.file, file.text])))\n let errors = 0\n const fail = (\n message: string,\n node: ASTNode | null | undefined,\n hints: readonly string[] = [],\n related?: ASTNode,\n ) => {\n errors++\n const location = locator.locate(node)\n const other = related === undefined ? undefined : locator.locate(related)\n report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message,\n ...(location === undefined ? {} : { location }),\n ...(hints.length === 0 ? {} : { hints }),\n ...(other === undefined ? {} : { related: [{ message: 'first declared here', location: other }] }),\n })\n }\n\n const documents: DocumentNode[] = []\n for (const file of files) {\n // a file with comments only (a placeholder) defines nothing: graphql-js would reject it\n if (/^(?:\\s|,|#[^\\n\\r]*)*$/.test(file.text.replace(/^\\uFEFF/, ''))) continue\n try {\n documents.push(language.parse(new language.Source(file.text, file.file)))\n } catch (error) {\n const position = (error as { positions?: readonly number[] }).positions?.[0]\n errors++\n const location = position === undefined ? undefined : locator.at(file.file, position, position + 1)\n report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message: `${(error as Error).message} (${file.relativeFile})`,\n ...(location === undefined ? {} : { location }),\n })\n }\n }\n if (errors > 0) return undefined\n if (documents.length === 0) {\n report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message: `The GraphQL schema files matching ${patterns.map(pattern => `'${pattern}'`).join(', ')} define nothing (schema-first)`,\n hints: ['Declare the types of the schema, starting with type Query { ... }'],\n })\n return undefined\n }\n const document = utilities.concatAST(documents)\n const customDirectives = checkStructure(document, fail, (message, node) => {\n const location = locator.locate(node)\n report({\n code: Codes.InvalidSdl,\n severity: 'warning',\n message,\n ...(location === undefined ? {} : { location }),\n hints: [\n 'Znight serves the schema without custom directives (and so does the SDL artifact): remove it, or keep it for other tools',\n ],\n })\n })\n if (errors > 0) return undefined\n\n let schema: GraphQLSchema\n try {\n schema = utilities.buildASTSchema(document, { assumeValidSDL: true })\n } catch (error) {\n fail(`Invalid schema: ${(error as Error).message}`, (error as { nodes?: readonly ASTNode[] }).nodes?.[0])\n return undefined\n }\n for (const problem of type.validateSchema(schema)) {\n const [node, ...others] = (problem.nodes ?? []).filter(candidate => candidate.loc !== undefined)\n errors++\n const location = locator.locate(node)\n const related = others.flatMap(other => {\n const at = locator.locate(other)\n return at === undefined ? [] : [{ message: 'see also', location: at }]\n })\n report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message: `Invalid schema: ${problem.message}`,\n ...(location === undefined ? {} : { location }),\n ...(related.length === 0 ? {} : { related }),\n // the one schema-wide error without node: no query type\n ...(node === undefined && schema.getQueryType() == null\n ? { hints: ['Declare the query root type in one of the files: type Query { ... }'] }\n : {}),\n })\n }\n if (errors > 0) return undefined\n return { schema, customDirectives, locate: node => locator.locate(node) }\n}\n\n/**\n * The checks graphql-js leaves to its SDL validation (not exported): unique type, field, value and\n * argument names, known types and directives, extensions of existing types of the same kind, one\n * schema definition. Returns the names of the custom directives (each reported as a warning).\n */\nfunction checkStructure(\n document: DocumentNode,\n fail: (message: string, node: ASTNode, hints?: readonly string[], related?: ASTNode) => void,\n warn: (message: string, node: ASTNode) => void,\n): ReadonlySet<string> {\n const definitions = new Map<string, TypeNodeLike>()\n const directives = new Map<string, ASTNode>()\n const specs = new Map<string, DirectiveSpec>(SDL_DIRECTIVES)\n let schemaDefinition: ASTNode | undefined\n for (const definition of document.definitions) {\n if (definition.kind === 'SchemaDefinition') {\n if (schemaDefinition === undefined) schemaDefinition = definition\n else\n fail(\n 'The schema is defined twice (schema { ... })',\n definition,\n ['Keep one schema definition'],\n schemaDefinition,\n )\n continue\n }\n if (definition.kind === 'DirectiveDefinition') {\n const name = definition.name.value\n const previous = directives.get(name)\n if (previous !== undefined) fail(`The directive @${name} is defined twice`, definition.name, [], previous)\n else if (KNOWN_DIRECTIVES.has(name))\n fail(`@${name} is a built-in directive: it cannot be redefined`, definition.name)\n else {\n directives.set(name, definition.name)\n specs.set(name, {\n locations: new Set(definition.locations.map(location => location.value)),\n args: new Map(\n (definition.arguments ?? []).map(arg => [\n arg.name.value,\n arg.type.kind === 'NonNullType' && arg.defaultValue === undefined,\n ]),\n ),\n repeatable: definition.repeatable,\n })\n warn(`The custom directive @${name} is ignored`, definition.name)\n }\n continue\n }\n const kind = TYPE_KINDS[definition.kind]\n if (kind === undefined || definition.kind.endsWith('Extension')) continue\n const node = definition as TypeNodeLike\n const previous = definitions.get(node.name.value)\n if (previous !== undefined) {\n fail(\n `The type ${node.name.value} is defined twice`,\n node.name,\n [\n kind === 'scalar'\n ? 'Keep one of them, or rename one'\n : `Extend it instead (${declaration(`extend ${kind}`, kind, node.name.value)}), or rename one of them`,\n ],\n previous.name,\n )\n continue\n }\n definitions.set(node.name.value, node)\n }\n const typeNames = [...definitions.keys(), ...PROVIDED_TYPES].sort(compareStrings)\n const known = (name: NamedTypeNode, where: string): void => {\n const value = name.name.value\n if (definitions.has(value) || PROVIDED_TYPES.has(value)) return\n const suggestion = closest(value, typeNames)\n fail(\n `Unknown type ${value} (${where})`,\n name,\n suggestion === undefined ? ['Define it, or fix the name'] : [`Did you mean ${suggestion}?`],\n )\n }\n /** The directives applied at `location`: known, allowed there, once unless repeatable, valid arguments. */\n const directivesOf = (nodes: readonly DirectiveNode[] | undefined, location: string): void => {\n const seen = new Map<string, ASTNode>()\n for (const directive of nodes ?? []) {\n const name = directive.name.value\n const spec = specs.get(name)\n if (spec === undefined) {\n fail(\n KNOWN_DIRECTIVES.has(name)\n ? `@${name} is an executable directive: it cannot be used in a schema`\n : `Unknown directive @${name}`,\n directive.name,\n KNOWN_DIRECTIVES.has(name) ? ['Remove it'] : [`Define it (directive @${name} on ${location}), or remove it`],\n )\n continue\n }\n if (!spec.locations.has(location)) {\n fail(`@${name} cannot be used on ${LOCATION_NAMES[location] ?? location}`, directive.name, [\n `@${name} applies to ${[...spec.locations].map(where => LOCATION_NAMES[where] ?? where).join(', ')}`,\n ])\n }\n const previous = seen.get(name)\n if (previous !== undefined && !spec.repeatable) {\n fail(`@${name} is applied twice`, directive.name, ['Apply it once'], previous)\n }\n seen.set(name, directive.name)\n const given = new Set<string>()\n for (const arg of directive.arguments ?? []) {\n given.add(arg.name.value)\n if (!spec.args.has(arg.name.value)) {\n const names = [...spec.args.keys()]\n fail(`@${name} has no argument '${arg.name.value}'`, arg.name, [\n names.length === 0 ? `@${name} takes no argument` : `Its arguments: ${names.join(', ')}`,\n ])\n }\n }\n for (const [arg, required] of spec.args) {\n if (required && !given.has(arg))\n fail(`@${name} needs its argument '${arg}'`, directive.name, [`@${name}(${arg}: ...)`])\n }\n }\n }\n /** Members of a type: its definition and extensions, by name (fields, values, input fields). */\n const members = new Map<string, Map<string, ASTNode>>()\n const member = (typeName: string, kind: string, name: NameNode): void => {\n let seen = members.get(typeName)\n if (seen === undefined) {\n seen = new Map()\n members.set(typeName, seen)\n }\n const previous = seen.get(name.value)\n if (previous !== undefined) {\n fail(`${typeName}.${name.value} is declared twice`, name, [`Keep one ${kind} named ${name.value}`], previous)\n return\n }\n seen.set(name.value, name)\n }\n const inputValues = (owner: string, values: readonly InputValueDefinitionNode[] | undefined): void => {\n const seen = new Map<string, ASTNode>()\n for (const value of values ?? []) {\n const previous = seen.get(value.name.value)\n if (previous !== undefined) {\n fail(`Argument ${owner}(${value.name.value}:) is declared twice`, value.name, [], previous)\n }\n seen.set(value.name.value, value.name)\n known(namedType(value.type), `${owner}(${value.name.value}:)`)\n directivesOf(value.directives, 'ARGUMENT_DEFINITION')\n }\n }\n const fields = (owner: string, list: readonly FieldDefinitionNode[] | undefined): void => {\n for (const field of list ?? []) {\n member(owner, 'field', field.name)\n known(namedType(field.type), `${owner}.${field.name.value}`)\n inputValues(`${owner}.${field.name.value}`, field.arguments)\n directivesOf(field.directives, 'FIELD_DEFINITION')\n }\n }\n const operations = new Map<string, ASTNode>()\n for (const definition of document.definitions) {\n if (definition.kind === 'SchemaDefinition' || definition.kind === 'SchemaExtension') {\n for (const operation of definition.operationTypes ?? []) {\n known(operation.type, `schema ${operation.operation}`)\n const previous = operations.get(operation.operation)\n if (previous !== undefined) {\n fail(`The ${operation.operation} root type is declared twice`, operation, ['Keep one'], previous)\n }\n operations.set(operation.operation, operation)\n }\n directivesOf(definition.directives, 'SCHEMA')\n continue\n }\n if (definition.kind === 'DirectiveDefinition') {\n inputValues(`@${definition.name.value}`, definition.arguments)\n continue\n }\n const kind = TYPE_KINDS[definition.kind]\n if (kind === undefined) continue\n const node = definition as TypeNodeLike & {\n readonly fields?: readonly (FieldDefinitionNode | InputValueDefinitionNode)[]\n readonly interfaces?: readonly NamedTypeNode[]\n readonly types?: readonly NamedTypeNode[]\n readonly values?: readonly { readonly name: NameNode; readonly directives?: readonly DirectiveNode[] }[]\n readonly directives?: readonly DirectiveNode[]\n }\n const name = node.name.value\n if (definition.kind.endsWith('Extension')) {\n const base = definitions.get(name)\n if (base === undefined) {\n if (!PROVIDED_TYPES.has(name)) {\n const suggestion = closest(name, typeNames)\n fail(`Cannot extend ${kind} ${name}: it is not defined`, node.name, [\n suggestion === undefined ? `Define it: ${declaration(kind, kind, name)}` : `Did you mean ${suggestion}?`,\n ])\n }\n continue\n }\n if (TYPE_KINDS[base.kind] !== kind) {\n const actual = TYPE_KINDS[base.kind] as string\n fail(\n `Cannot extend ${name} as ${article(kind)} ${kind}: it is ${article(actual)} ${actual}`,\n node.name,\n [`Use ${declaration(`extend ${actual}`, actual, name)}`],\n base.name,\n )\n continue\n }\n }\n directivesOf(node.directives, TYPE_LOCATIONS[kind] as string)\n for (const implemented of node.interfaces ?? []) known(implemented, `${name} implements`)\n for (const target of node.types ?? []) known(target, `union ${name}`)\n for (const value of node.values ?? []) {\n member(name, 'value', value.name)\n directivesOf(value.directives, 'ENUM_VALUE')\n }\n if (kind === 'input') {\n for (const field of (node.fields ?? []) as readonly InputValueDefinitionNode[]) {\n member(name, 'field', field.name)\n known(namedType(field.type), `${name}.${field.name.value}`)\n directivesOf(field.directives, 'INPUT_FIELD_DEFINITION')\n }\n } else {\n fields(name, node.fields as readonly FieldDefinitionNode[] | undefined)\n }\n }\n return new Set(directives.keys())\n}\n\n/** `extend type Book { ... }`, `union Hit = ...`, `scalar Url`: valid SDL for a hint. */\nfunction declaration(keyword: string, kind: string, name: string): string {\n if (kind === 'scalar') return `${keyword} ${name}`\n if (kind === 'union') return `${keyword} ${name} = ...`\n return `${keyword} ${name} { ... }`\n}\n\nfunction article(word: string): string {\n return /^[aeiou]/.test(word) ? 'an' : 'a'\n}\n\nfunction namedType(type: TypeNode): NamedTypeNode {\n let current = type\n while (current.kind !== 'NamedType') current = current.type\n return current\n}\n\n/** Source locations of AST nodes (graphql-js `Source.name` is the absolute path of the file). */\nclass Locator {\n readonly #texts: ReadonlyMap<string, string>\n readonly #lines = new Map<string, number[]>()\n\n constructor(texts: ReadonlyMap<string, string>) {\n this.#texts = texts\n }\n\n locate(node: ASTNode | null | undefined): Location | undefined {\n if (node === null || node === undefined) return undefined\n const named = 'name' in node && node.name !== undefined && typeof node.name === 'object' ? node.name : node\n const loc = (named as ASTNode).loc ?? node.loc\n if (loc === undefined) return undefined\n return this.at(loc.source.name, loc.start, loc.end)\n }\n\n at(file: string, start: number, end: number): Location | undefined {\n const text = this.#texts.get(file)\n if (text === undefined) return undefined\n const lines = this.#lineStarts(file, text)\n const first = position(lines, start)\n const last = position(lines, Math.min(end, text.length))\n return { file, line: first.line, column: first.column, endLine: last.line, endColumn: last.column, start, end }\n }\n\n #lineStarts(file: string, text: string): number[] {\n let lines = this.#lines.get(file)\n if (lines === undefined) {\n lines = [0]\n for (let index = 0; index < text.length; index++) {\n const code = text.charCodeAt(index)\n if (code === 0x0a) lines.push(index + 1)\n else if (code === 0x0d) {\n if (text.charCodeAt(index + 1) === 0x0a) index++\n lines.push(index + 1)\n }\n }\n this.#lines.set(file, lines)\n }\n return lines\n }\n}\n\n/** 1-based line and column (UTF-16 code units) of an offset. */\nfunction position(lines: readonly number[], offset: number): { line: number; column: number } {\n let low = 0\n let high = lines.length - 1\n while (low < high) {\n const middle = (low + high + 1) >> 1\n if ((lines[middle] as number) <= offset) low = middle\n else high = middle - 1\n }\n return { line: low + 1, column: offset - (lines[low] as number) + 1 }\n}\n","/**\n * The schema-first model (RFC 0007): the SDL is the schema. `validate` loads and validates the\n * `.graphql` files (`sdl-source.ts`), binds every resolver method to its field by name (coverage,\n * §5.3), checks the resolver signatures against the SDL (`conformance.ts`, §5.4) and turns the\n * validated graphql-js schema into the same {@link GraphQLModel} as code-first, so that `generate`,\n * the SDL artifact, `schemaHash` and the runtime are shared.\n */\nimport type { ClassInfo, Diagnostic, Location, MethodInfo, ValidateContext } from '@znight/compiler'\nimport type {\n GraphQLArgument,\n GraphQLEnumType,\n GraphQLField,\n GraphQLInputField,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLNamedType,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLSchema,\n GraphQLUnionType,\n} from 'graphql'\nimport type { Binding } from './conformance.ts'\nimport type { FieldData, GraphQLData, ResolverData } from './data.ts'\nimport type {\n ArgModel,\n FieldModel,\n GraphQLModel,\n InputModel,\n InterfaceModel,\n ObjectModel,\n ScalarModel,\n TypeModel,\n UnionModel,\n} from './model.ts'\nimport type { ScalarDeclaration } from './scalars.ts'\nimport type { SdlSource } from './sdl-source.ts'\n\nimport { BUILTIN_SCALARS, SPECIFIED_SCALARS } from '../names.ts'\nimport { schemaHash } from '../schema-hash.ts'\nimport { printSdl } from '../sdl.ts'\nimport { parseTypeRef } from '../type-ref.ts'\nimport { checkDecisions, checkLoaders } from './checks.ts'\nimport { checkConformance } from './conformance.ts'\nimport { Codes, compareStrings } from './constants.ts'\nimport { graphqlModules } from './graphql-js.ts'\nimport { readScalars } from './scalars.ts'\nimport { loadSdl } from './sdl-source.ts'\nimport { sdlType } from './sdl-view.ts'\nimport { closest } from './suggest.ts'\n\ntype Context = ValidateContext<GraphQLData>\ntype Operation = 'query' | 'mutation' | 'subscription'\n\nconst DECORATORS: Readonly<Record<FieldData['operation'], string>> = {\n query: '@Query',\n mutation: '@Mutation',\n subscription: '@Subscription',\n field: '@ResolveField',\n}\n\n/**\n * Builds the model from the SDL files matching `patterns`; `undefined` after an error. `artifact`:\n * the path of the SDL artifact (option `sdl`), never read back as an input.\n */\nexport function buildSchemaFirstModel(\n ctx: Context,\n patterns: readonly string[],\n artifact: string | false,\n): GraphQLModel | undefined {\n // the artifact is the output: matched by the globs, it would define every type a second time\n return new SchemaFirstBuilder(ctx).build(artifact === false ? patterns : [...patterns, `!${artifact}`])\n}\n\nclass SchemaFirstBuilder {\n readonly #ctx: Context\n #errors = 0\n readonly #methods = new Map<string, MethodInfo | undefined>()\n\n constructor(ctx: Context) {\n this.#ctx = ctx\n }\n\n build(patterns: readonly string[]): GraphQLModel | undefined {\n const report = (diagnostic: Diagnostic): void => this.#report(diagnostic)\n const stored = [...this.#ctx.stored].sort((a, b) => compareStrings(a.host.identity, b.host.identity))\n const resolvers = stored.filter(resolver => resolver.invalid !== true)\n const rejected = stored.filter(resolver => resolver.invalid === true)\n checkLoaders(this.#ctx, resolvers, report)\n const scalarDeclarations = readScalars(this.#ctx, report)\n const sdl = loadSdl(this.#ctx, patterns, report)\n if (sdl === undefined) {\n checkDecisions(this.#ctx, resolvers, report)\n return undefined\n }\n const schema = sdl.schema\n const roots = {\n query: (schema.getQueryType() as GraphQLObjectType).name,\n ...(schema.getMutationType() ? { mutation: (schema.getMutationType() as GraphQLObjectType).name } : {}),\n ...(schema.getSubscriptionType()\n ? { subscription: (schema.getSubscriptionType() as GraphQLObjectType).name }\n : {}),\n }\n checkDecisions(this.#ctx, resolvers, report, roots)\n const types = Object.values(schema.getTypeMap())\n .filter(type => !type.name.startsWith('__') && !SPECIFIED_SCALARS.has(type.name))\n .sort((a, b) => compareStrings(a.name, b.name))\n this.#checkUnsupported(sdl, types)\n const scalars = this.#scalars(sdl, types, scalarDeclarations)\n const { bindings, claimed: bound } = this.#bind(sdl, resolvers, rejected)\n const conformance = checkConformance({\n ctx: this.#ctx,\n schema,\n locate: node => sdl.locate(node),\n scalars: new Map([...scalarDeclarations.values()].map(declaration => [declaration.name, declaration])),\n bindings,\n bound,\n report,\n })\n if (this.#errors > 0) return undefined\n const byCoordinate = new Map(bindings.map(binding => [`${binding.type.name}.${binding.sdlField.name}`, binding]))\n const models: TypeModel[] = []\n for (const type of types) {\n const model = this.#model(sdl, type, byCoordinate, scalars, conformance)\n if (model !== undefined) models.push(model)\n }\n const meta = resolvers.flatMap(resolver => resolver.fields.flatMap(field => field.meta))\n const printed = printSdl({ roots, types: models.map(sdlType) })\n return { roots, types: models, meta, sdl: printed, schemaHash: schemaHash(printed) }\n }\n\n #report(diagnostic: Diagnostic): void {\n if (diagnostic.severity === 'error') this.#errors++\n this.#ctx.report(diagnostic)\n }\n\n #mismatch(\n location: Location | undefined,\n message: string,\n hints: readonly string[],\n related?: Diagnostic['related'],\n ): void {\n this.#report({\n code: Codes.SchemaMismatch,\n severity: 'error',\n message,\n ...(location === undefined ? {} : { location }),\n ...(hints.length === 0 ? {} : { hints }),\n ...(related === undefined || related.length === 0 ? {} : { related }),\n })\n }\n\n // ------------------------------------------------------------------------------- unsupported\n\n /** `@oneOf` input objects (the runtime does not model them). */\n #checkUnsupported(sdl: SdlSource, types: readonly GraphQLNamedType[]): void {\n const { isInputObjectType } = graphqlModules().type\n for (const type of types) {\n if (!isInputObjectType(type) || !type.isOneOf) continue\n const location = sdl.locate(type.astNode)\n this.#report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message: `@oneOf input objects are not supported yet (${type.name})`,\n ...(location === undefined ? {} : { location }),\n hints: ['Declare one optional field per case and check that exactly one is set in the resolver'],\n })\n }\n }\n\n // ------------------------------------------------------------------------------------- scalars\n\n /** The scalar models: `scalar<T>()` declarations by name, the built-in scalars, else ZNIGHT067. */\n #scalars(\n sdl: SdlSource,\n types: readonly GraphQLNamedType[],\n declarations: ReadonlyMap<string, ScalarDeclaration>,\n ): ReadonlyMap<string, ScalarModel> {\n const { isScalarType } = graphqlModules().type\n const byName = new Map([...declarations.values()].map(declaration => [declaration.name, declaration]))\n const models = new Map<string, ScalarModel>()\n for (const type of types) {\n if (!isScalarType(type)) continue\n const location = sdl.locate(type.astNode)\n const declaration = byName.get(type.name)\n const description = type.description ?? undefined\n const specifiedByURL = type.specifiedByURL ?? undefined\n if (declaration !== undefined) {\n models.set(type.name, {\n kind: 'scalar',\n name: type.name,\n key: `#scalar:${declaration.identity}`,\n description,\n location,\n definition: declaration.identity,\n specifiedByURL,\n fromSdl: true,\n })\n continue\n }\n const builtin = BUILTIN_SCALARS.get(type.name)\n if (builtin !== undefined) {\n if (description !== undefined || (specifiedByURL !== undefined && specifiedByURL !== builtin.specifiedByURL)) {\n this.#report({\n code: Codes.InvalidSdl,\n severity: 'warning',\n message: `scalar ${type.name} is the built-in scalar of @znight/graphql: its description and @specifiedBy in the SDL are ignored`,\n ...(location === undefined ? {} : { location }),\n hints: [\n `Remove them, or implement the scalar yourself: export const ${type.name}Scalar = scalar<T>('${type.name}', { ... })`,\n ],\n })\n }\n models.set(type.name, {\n kind: 'scalar',\n name: type.name,\n key: `#builtin:${type.name}`,\n description: undefined,\n location,\n definition: undefined,\n specifiedByURL: undefined,\n })\n continue\n }\n this.#report({\n code: Codes.InvalidSdl,\n severity: 'error',\n message: `scalar ${type.name} has no implementation: declare it with scalar<T>('${type.name}', ...)`,\n ...(location === undefined ? {} : { location }),\n hints: [\n `export const ${type.name}Scalar = scalar<${type.name}>('${type.name}', { serialize: value => value as ${type.name}, parseValue: value => value as ${type.name} }), with ${type.name} the TypeScript type of its values (the one graphql-codegen maps it to)`,\n ],\n })\n }\n return models\n }\n\n // ------------------------------------------------------------------------------------- binding\n\n /**\n * Binds every resolver method to its SDL field (coverage, RFC 0007 §5.3). `claimed`: the\n * coordinates a resolver method names, bound or not (a method with an analysis error already\n * reported), so that their fields are never also reported as missing a resolver.\n */\n #bind(\n sdl: SdlSource,\n resolvers: readonly ResolverData[],\n rejected: readonly ResolverData[],\n ): { bindings: Binding[]; claimed: Set<string> } {\n const schema = sdl.schema\n const bindings: Binding[] = []\n const claimed = new Set<string>()\n for (const resolver of rejected) {\n for (const field of resolver.fields) {\n const owner = field.operation === 'field' ? resolver.typeName?.name : rootType(schema, field.operation)?.name\n if (owner !== undefined) claimed.add(`${owner}.${field.name}`)\n }\n }\n const byCoordinate = new Map<string, Binding>()\n for (const resolver of resolvers) {\n const target = this.#resolverType(sdl, resolver)\n for (const field of resolver.fields) {\n const owner = field.operation === 'field' ? resolver.typeName?.name : rootType(schema, field.operation)?.name\n if (owner !== undefined) claimed.add(`${owner}.${field.name}`)\n if (!field.complete) continue\n const method = this.#method(resolver, field)\n if (method === undefined) continue\n const where = `${resolver.host.displayName}.${field.method}`\n let type: GraphQLObjectType | undefined\n if (field.operation === 'field') {\n type = target\n if (type === undefined) continue\n } else {\n type = rootType(schema, field.operation)\n if (type === undefined) {\n const name = ROOTS[field.operation]\n this.#mismatch(field.location, `${DECORATORS[field.operation]} ${where}: the schema has no ${name} type`, [\n `Declare it in the SDL: type ${name} { ${field.name}: ... }`,\n ])\n continue\n }\n }\n const sdlField = type.getFields()[field.name]\n if (sdlField === undefined) {\n this.#unknownField(schema, type, field, where)\n continue\n }\n const coordinate = `${type.name}.${field.name}`\n const previous = byCoordinate.get(coordinate)\n if (previous !== undefined) {\n this.#report({\n code: Codes.NameConflict,\n severity: 'error',\n message: `Two resolvers bind ${coordinate}: ${where} and ${previous.resolver.host.displayName}.${previous.field.method}`,\n location: field.location,\n related: [{ message: 'the other resolver', location: previous.field.location }],\n hints: ['Keep one of them'],\n })\n continue\n }\n this.#checkArguments(sdl, field, method, sdlField, coordinate, where)\n const binding: Binding = { resolver, field, method, type, sdlField }\n byCoordinate.set(coordinate, binding)\n bindings.push(binding)\n }\n }\n for (const operation of ['query', 'mutation', 'subscription'] as const) {\n const root = rootType(schema, operation)\n if (root === undefined) continue\n for (const field of Object.values(root.getFields())) {\n if (claimed.has(`${root.name}.${field.name}`)) continue\n this.#mismatch(sdl.locate(field.astNode), `Root field ${root.name}.${field.name} has no resolver`, [\n `Add a method to a @Resolver() class: ${DECORATORS[operation]}() ${field.name}(...) (or ${DECORATORS[operation]}('${field.name}') on another method)`,\n ])\n }\n }\n return { bindings, claimed }\n }\n\n /** The object type of `@Resolver('Type')`, reported when it is not one. */\n #resolverType(sdl: SdlSource, resolver: ResolverData): GraphQLObjectType | undefined {\n const typeName = resolver.typeName\n if (typeName === undefined) return undefined\n const { isObjectType, isInterfaceType } = graphqlModules().type\n const schema = sdl.schema\n const type = schema.getType(typeName.name)\n const owner = resolver.host.displayName\n if (type === undefined) {\n const objects = Object.values(schema.getTypeMap())\n .filter(candidate => isObjectType(candidate) && !candidate.name.startsWith('__'))\n .map(candidate => candidate.name)\n .sort(compareStrings)\n const suggestion = closest(typeName.name, objects)\n this.#mismatch(\n typeName.location,\n `@Resolver('${typeName.name}') of ${owner}: the schema has no type ${typeName.name}`,\n [\n suggestion === undefined\n ? `Declare it in the SDL: type ${typeName.name} { ... }`\n : `Did you mean '${suggestion}'?`,\n ],\n )\n return undefined\n }\n const declared = sdl.locate(type.astNode)\n const related = declared === undefined ? [] : [{ message: `${type.name} is declared here`, location: declared }]\n if (isInterfaceType(type)) {\n const implementations = schema.getPossibleTypes(type).map(object => object.name)\n this.#mismatch(\n typeName.location,\n `@Resolver('${type.name}') of ${owner}: ${type.name} is an interface, field resolvers bind the fields of object types`,\n [\n implementations.length === 0\n ? `Declare an object type implementing ${type.name} and bind the field on it`\n : `Bind the field on each implementation: @Resolver('${implementations[0]}')${implementations.length > 1 ? ` (and ${implementations.slice(1).join(', ')})` : ''}`,\n ],\n related,\n )\n return undefined\n }\n if (!isObjectType(type)) {\n this.#mismatch(\n typeName.location,\n `@Resolver('${type.name}') of ${owner}: ${type.name} is not an object type, it has no field to resolve`,\n ['Name an object type of the SDL (type ... { ... })'],\n related,\n )\n return undefined\n }\n const operation = (['query', 'mutation', 'subscription'] as const).find(\n candidate => rootType(sdl.schema, candidate) === type,\n )\n if (operation !== undefined && resolver.fields.some(field => field.operation === 'field')) {\n this.#mismatch(\n typeName.location,\n `@Resolver('${type.name}') of ${owner}: ${type.name} is the ${operation} root type, its fields are bound with ${DECORATORS[operation]}()`,\n [`Replace @ResolveField() with ${DECORATORS[operation]}() and use @Resolver()`],\n related,\n )\n return undefined\n }\n return type\n }\n\n #unknownField(schema: GraphQLSchema, type: GraphQLObjectType, field: FieldData, where: string): void {\n const hints: string[] = []\n if (field.operation !== 'field') {\n const elsewhere = (['query', 'mutation', 'subscription'] as const).find(\n operation =>\n operation !== field.operation && rootType(schema, operation)?.getFields()[field.name] !== undefined,\n )\n if (elsewhere !== undefined) {\n hints.push(`${ROOTS[elsewhere]}.${field.name} exists: use ${DECORATORS[elsewhere]}()`)\n }\n }\n if (hints.length === 0) {\n const suggestion = closest(field.name, Object.keys(type.getFields()).sort(compareStrings))\n if (suggestion !== undefined) {\n hints.push(`Did you mean '${suggestion}'? ${DECORATORS[field.operation]}('${suggestion}')`)\n }\n }\n hints.push(\n `Declare it in the SDL (${field.operation === 'field' ? `extend type ${type.name}` : `extend type ${type.name}`} { ${field.name}: ... }), or remove the method`,\n )\n this.#mismatch(\n field.location,\n `${DECORATORS[field.operation]} ${where}: ${type.name} has no field '${field.name}'`,\n hints,\n )\n }\n\n /** `@Args('name')`: the argument must exist. */\n #checkArguments(\n sdl: SdlSource,\n field: FieldData,\n method: MethodInfo,\n sdlField: GraphQLField<unknown, unknown>,\n coordinate: string,\n where: string,\n ): void {\n const names = sdlField.args.map(arg => arg.name)\n field.params.forEach((param, index) => {\n if (param?.kind !== 'args' || param.name === undefined || names.includes(param.name)) return\n const suggestion = closest(param.name, [...names].sort(compareStrings))\n const declared = sdl.locate(sdlField.astNode)\n let hint = `Its arguments: ${names.join(', ')}`\n if (suggestion !== undefined) hint = `Did you mean '${suggestion}'?`\n else if (names.length === 0)\n hint = `${coordinate} takes no argument: declare it in the SDL, or remove the parameter`\n this.#mismatch(\n param.location,\n `@Args('${param.name}') on parameter '${method.params[index]?.name ?? param.name}' of ${where}: ${coordinate} has no argument '${param.name}'`,\n [hint],\n declared === undefined ? [] : [{ message: `${coordinate} is declared here`, location: declared }],\n )\n })\n }\n\n #method(resolver: ResolverData, field: FieldData): MethodInfo | undefined {\n const key = `${resolver.host.identity}#${field.method}`\n if (!this.#methods.has(key)) {\n const cls: ClassInfo | undefined = this.#ctx.classInfo(resolver.host.identity)\n this.#methods.set(\n key,\n cls?.methods.find(method => method.name === field.method && method.kind === 'method'),\n )\n }\n return this.#methods.get(key)\n }\n\n // --------------------------------------------------------------------------------------- model\n\n #model(\n sdl: SdlSource,\n type: GraphQLNamedType,\n bindings: ReadonlyMap<string, Binding>,\n scalars: ReadonlyMap<string, ScalarModel>,\n conformance: ReturnType<typeof checkConformance>,\n ): TypeModel | undefined {\n const { isObjectType, isInterfaceType, isInputObjectType, isEnumType, isUnionType } = graphqlModules().type\n const base = {\n name: type.name,\n key: `#sdl:${type.name}`,\n description: type.description ?? undefined,\n location: sdl.locate(type.astNode),\n }\n const nulls = conformance.nullAsUndefined\n if (isObjectType(type) || isInterfaceType(type)) {\n const fields = Object.values(type.getFields()).map(field =>\n this.#field(sdl, type, field, bindings.get(`${type.name}.${field.name}`), nulls),\n )\n const interfaces = type.getInterfaces().map(implemented => implemented.name)\n if (isInterfaceType(type)) {\n const model: InterfaceModel = {\n ...base,\n kind: 'interface',\n fields,\n interfaces,\n discriminator: conformance.discriminators.get(type.name),\n }\n return model\n }\n const model: ObjectModel = {\n ...base,\n kind: 'object',\n fields,\n trail: type.name,\n root: undefined,\n classIdentity: undefined,\n properties: [],\n interfaces,\n }\n return model\n }\n if (isInputObjectType(type)) {\n const model: InputModel = {\n ...base,\n kind: 'input',\n fields: Object.values((type as GraphQLInputObjectType).getFields()).map(field =>\n inputValue(sdl, field, `${type.name}.${field.name}`, nulls),\n ),\n }\n return model\n }\n if (isEnumType(type)) {\n return {\n ...base,\n kind: 'enum',\n values: (type as GraphQLEnumType).getValues().map(value => ({\n name: value.name,\n value: value.name,\n description: value.description ?? undefined,\n deprecationReason: value.deprecationReason ?? undefined,\n })),\n }\n }\n if (isUnionType(type)) {\n const model: UnionModel = {\n ...base,\n kind: 'union',\n members: (type as GraphQLUnionType)\n .getTypes()\n .map(member => member.name)\n .sort(compareStrings),\n discriminator: conformance.discriminators.get(type.name),\n }\n return model\n }\n return scalars.get((type as GraphQLScalarType).name)\n }\n\n #field(\n sdl: SdlSource,\n type: GraphQLObjectType | GraphQLInterfaceType,\n field: GraphQLField<unknown, unknown>,\n binding: Binding | undefined,\n nulls: ReadonlySet<string>,\n ): FieldModel {\n const coordinate = `${type.name}.${field.name}`\n return {\n name: field.name,\n type: String(field.type),\n description: field.description ?? undefined,\n deprecationReason: field.deprecationReason ?? undefined,\n args: field.args.map(arg => inputValue(sdl, arg, `${coordinate}(${arg.name}:)`, nulls)),\n binding: binding === undefined ? undefined : { resolver: binding.resolver, field: binding.field },\n location: sdl.locate(field.astNode),\n }\n }\n}\n\nconst ROOTS: Readonly<Record<Operation, string>> = {\n query: 'Query',\n mutation: 'Mutation',\n subscription: 'Subscription',\n}\n\nfunction rootType(schema: GraphQLSchema, operation: Operation): GraphQLObjectType | undefined {\n switch (operation) {\n case 'query':\n return schema.getQueryType() ?? undefined\n case 'mutation':\n return schema.getMutationType() ?? undefined\n default:\n return schema.getSubscriptionType() ?? undefined\n }\n}\n\n/** An argument or an input field: its default as an external value (enum values by name). */\nfunction inputValue(\n sdl: SdlSource,\n value: GraphQLArgument | GraphQLInputField,\n coordinate: string,\n nulls: ReadonlySet<string>,\n): ArgModel {\n const type = String(value.type)\n const ref = parseTypeRef(type) as NonNullable<ReturnType<typeof parseTypeRef>>\n const defaultInput = value.default\n let defaultValue: unknown\n if (defaultInput !== undefined) {\n defaultValue =\n defaultInput.literal === undefined\n ? defaultInput.value\n : graphqlModules().utilities.valueFromASTUntyped(defaultInput.literal)\n }\n return {\n name: value.name,\n type,\n ref,\n description: value.description ?? undefined,\n deprecationReason: value.deprecationReason ?? undefined,\n defaultValue,\n nullAsUndefined: !ref.nonNull && nulls.has(coordinate),\n location: sdl.locate(value.astNode),\n }\n}\n","/**\n * `@znight/graphql/compiler`: the compiler extension of `@znight/graphql` (RFC 0005 §6).\n *\n * Loaded by `@znight/compiler` through the package manifest (`package.json#znight.compiler`):\n *\n * - `analyzeClass`: `@Resolver` classes become providers (and roots), their field methods and\n * parameters are checked, guards and loaders bound with lazy edges, route decorators read;\n * - `validate`: the schema model, derived from the TypeScript types reachable from the root fields\n * (§6.2–§6.6), with every ZNIGHT060–065 diagnostic and the access decisions (ZNIGHT023);\n * - `generate`: `metadata.extensions.graphql` (§7), and the SDL artifact when configured.\n *\n * The default export is the extension with its default options; `configure(options)` returns a\n * configured copy, declared in `znight.config.ts` (it replaces the discovered extension):\n *\n * ```ts\n * import graphql from '@znight/graphql/compiler'\n * export default { extensions: [graphql.configure({ sdl: 'schema.graphql' })] } satisfies ZnightOptions\n * ```\n *\n * This entry only `import type`s from `@znight/compiler`, imports the runtime-free\n * `@znight/http/compiler`, and never loads the GraphQL runtime, graphql-js nor dataloader: it\n * reaches the import-free modules `src/type-ref.ts`, `src/sdl.ts`, `src/names.ts`,\n * `src/metadata.ts` and `src/schema-hash.ts` (`node:crypto`) only (tests/boundaries.test.ts).\n */\nimport type { ApplicationGraph, CompilerExtension, DecoratorSpec } from '@znight/compiler'\nimport type { GraphQLData } from './data.ts'\nimport type { GraphQLModel } from './model.ts'\nimport type { GraphQLCompilerOptions, ResolvedGraphQLCompilerOptions } from './options.ts'\n\nimport { analyzeGraphQLClass } from './analyze.ts'\nimport { buildModel } from './builder.ts'\nimport { generateGraphQL } from './generate.ts'\nimport { EXTENSION_NAME, GraphQLIds } from './ids.ts'\nimport { DEFAULT_OPTIONS, resolveOptions } from './options.ts'\nimport { buildSchemaFirstModel } from './schema-first.ts'\n\nexport type { FieldData, FieldOperation, GraphQLData, ParamData, ResolverData } from './data.ts'\nexport type { GraphQLCompilerOptions, ResolvedGraphQLCompilerOptions } from './options.ts'\n\nconst FIELD: DecoratorSpec = { targets: ['method'], params: ['static'] }\nconst NO_ARGUMENT: DecoratorSpec = { targets: ['parameter'], params: [] }\n\n/** Decorators owned by the extension, by canonical identity (static / value arguments, §4.6). */\nconst decorators: Readonly<Record<string, DecoratorSpec>> = Object.freeze({\n [GraphQLIds.Resolver]: { targets: ['class'], params: ['static', 'static'] },\n [GraphQLIds.Query]: FIELD,\n [GraphQLIds.Mutation]: FIELD,\n [GraphQLIds.Subscription]: FIELD,\n [GraphQLIds.ResolveField]: FIELD,\n [GraphQLIds.Args]: { targets: ['parameter'], params: ['value', 'value'] },\n [GraphQLIds.Parent]: NO_ARGUMENT,\n [GraphQLIds.Ctx]: NO_ARGUMENT,\n [GraphQLIds.Info]: NO_ARGUMENT,\n [GraphQLIds.Loader]: NO_ARGUMENT,\n [GraphQLIds.UseGuard]: { targets: ['class', 'method'], params: [], rest: 'value' },\n} satisfies Record<string, DecoratorSpec>)\n\n/** The `@znight/graphql` compiler extension, with its options and `configure()`. */\nexport interface GraphQLCompilerExtension extends CompilerExtension<GraphQLData> {\n /** The options of this copy (defaults filled in). */\n readonly options: ResolvedGraphQLCompilerOptions\n /** A copy of the extension with `options` merged onto the options of this one. */\n configure(options: GraphQLCompilerOptions): GraphQLCompilerExtension\n}\n\nfunction createExtension(options: ResolvedGraphQLCompilerOptions): GraphQLCompilerExtension {\n /**\n * Models by compile, built by `validate`, read by `generate`. The key is `graph.extensions`: the\n * validate and generate contexts of one compile get different graph objects sharing this array.\n */\n const models = new WeakMap<object, GraphQLModel | undefined>()\n const modelOf = (graph: ApplicationGraph): GraphQLModel | undefined => models.get(graph.extensions)\n return Object.freeze({\n apiVersion: 1,\n name: EXTENSION_NAME,\n decorators,\n options,\n analyzeClass: (cls, ctx) => analyzeGraphQLClass(cls, ctx, options),\n validate(ctx) {\n const schema = options.schema\n models.set(\n ctx.graph.extensions,\n schema === false ? buildModel(ctx, options) : buildSchemaFirstModel(ctx, schema, options.sdl),\n )\n },\n generate(ctx) {\n return generateGraphQL(ctx, modelOf(ctx.graph), options)\n },\n configure(next: GraphQLCompilerOptions): GraphQLCompilerExtension {\n return createExtension(resolveOptions(options, next))\n },\n } satisfies GraphQLCompilerExtension)\n}\n\n/** The `@znight/graphql` compiler extension with its default options. */\nexport const graphqlCompilerExtension: GraphQLCompilerExtension = createExtension(DEFAULT_OPTIONS)\n\nexport default graphqlCompilerExtension\n"],"mappings":";;;;;;AAaA,MAAa,iBAAiB;;AAG9B,MAAa,iBAAiB;;AAG9B,MAAa,aA2CT,OAAO,OAAO;CAChB,UAAU;CACV,OAAO;CACP,UAAU;CACV,cAAc;CACd,cAAc;CACd,MAAM;CACN,QAAQ;CACR,KAAK;CACL,MAAM;CACN,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,IAAI;CACJ,KAAK;CACL,OAAO;CACP,WAAW;CACX,WAAW;CACX,gBAAgB;CAChB,iBAAiB;CACjB,QAAQ;CACR,eAAe;AACjB,CAAC;;AAGD,MAAa,mCAAyF,IAAI,IAAI;CAC5G,CAAC,WAAW,OAAO,OAAO;CAC1B,CAAC,WAAW,UAAU,UAAU;CAChC,CAAC,WAAW,cAAc,cAAc;CACxC,CAAC,WAAW,cAAc,OAAO;AACnC,CAAC;;AAGD,MAAa,uCAA2F,IAAI,IAAI;CAC9G,CAAC,WAAW,MAAM,MAAM;CACxB,CAAC,WAAW,QAAQ,QAAQ;CAC5B,CAAC,WAAW,KAAK,KAAK;CACtB,CAAC,WAAW,MAAM,MAAM;CACxB,CAAC,WAAW,QAAQ,QAAQ;AAC9B,CAAC;;AAGD,MAAa,iCAAuE,IAAI,IAAI;CAC1F,CAAC,WAAW,IAAI,IAAI;CACpB,CAAC,WAAW,KAAK,KAAK;CACtB,CAAC,WAAW,OAAO,OAAO;CAC1B,CAAC,WAAW,WAAW,MAAM;AAC/B,CAAC;;;;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