@znight/graphql 0.0.0 → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +1063 -0
- package/dist/compiler.d.mts +93 -0
- package/dist/compiler.mjs +2832 -0
- package/dist/compiler.mjs.map +1 -0
- package/dist/index.d.mts +542 -0
- package/dist/index.mjs +128 -0
- package/dist/index.mjs.map +1 -0
- package/dist/names-BlzDM5cF.mjs +111 -0
- package/dist/names-BlzDM5cF.mjs.map +1 -0
- package/dist/plugin-BdBxr5NQ.mjs +3222 -0
- package/dist/plugin-BdBxr5NQ.mjs.map +1 -0
- package/dist/testing.d.mts +101 -0
- package/dist/testing.mjs +306 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/types-CgbV9LjD.d.mts +234 -0
- package/package.json +97 -1
- package/src/compiler/analyze.ts +608 -0
- package/src/compiler/builder.ts +1640 -0
- package/src/compiler/constants.ts +74 -0
- package/src/compiler/data.ts +73 -0
- package/src/compiler/defaults.ts +92 -0
- package/src/compiler/discriminators.ts +53 -0
- package/src/compiler/docs.ts +55 -0
- package/src/compiler/generate.ts +405 -0
- package/src/compiler/ids.ts +128 -0
- package/src/compiler/index.ts +93 -0
- package/src/compiler/locate.ts +44 -0
- package/src/compiler/model.ts +122 -0
- package/src/compiler/options.ts +54 -0
- package/src/compiler/scalars.ts +138 -0
- package/src/compiler/sdl-view.ts +59 -0
- package/src/context.ts +181 -0
- package/src/decisions.ts +169 -0
- package/src/decorators.ts +196 -0
- package/src/errors.ts +89 -0
- package/src/execution.ts +1064 -0
- package/src/format.ts +285 -0
- package/src/index.ts +84 -0
- package/src/limits.ts +177 -0
- package/src/loaders.ts +149 -0
- package/src/memory-pubsub.ts +133 -0
- package/src/metadata.ts +195 -0
- package/src/names.ts +47 -0
- package/src/options.ts +309 -0
- package/src/pipeline.ts +277 -0
- package/src/plugin.ts +557 -0
- package/src/pubsub.ts +36 -0
- package/src/scalars.ts +131 -0
- package/src/schema-hash.ts +18 -0
- package/src/schema.ts +557 -0
- package/src/sdl.ts +515 -0
- package/src/testing.ts +454 -0
- package/src/tokens.ts +22 -0
- package/src/transport/abort.ts +80 -0
- package/src/transport/accept.ts +155 -0
- package/src/transport/graphiql.ts +106 -0
- package/src/transport/http.ts +373 -0
- package/src/transport/sse.ts +45 -0
- package/src/type-ref.ts +89 -0
- package/src/types.ts +190 -0
- package/src/validate-args.ts +48 -0
|
@@ -0,0 +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/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/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} = 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})\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 } from './data.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/** Analyses a class carrying at least one graphql decorator (class, method or parameter). */\nexport function analyzeGraphQLClass(cls: ClassInfo, ctx: Context): 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 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 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 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 return\n }\n\n const scope = resolverScope(ctx, resolver)\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))\n }\n ctx.store({ kind: 'resolver', host: cls, scope, location: resolver.location, guards: classGuards, fields })\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({ scope })`. */\nfunction resolverScope(ctx: Context, decorator: DecoratorInfo): Scope {\n const arg = decorator.args[0]\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): 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 if (operation === 'field' && parents.length === 0) {\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 | 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 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 return `${head}type ${type.name}${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/** 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 * 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, 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 * `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 return {\n kind: 'object',\n name: model.name,\n ...base,\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 { requiredRouteGroups } from '@znight/http/compiler'\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 { 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 { GraphQLIds, 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 this.#checkLoaders(resolvers)\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 this.#checkDecisions(resolvers)\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 }\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 /** `Loader<L>`: `L` must be a loader provider, implementing `BatchLoad<K, V>` (ZNIGHT065). */\n #checkLoaders(resolvers: readonly ResolverData[]): 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 = this.#ctx.binding(param.binding)\n const token = tokenOfRef(ref)\n const provider = token === undefined ? undefined : this.#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(this.#ctx, provider.classIdentity)) continue\n this.#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 // ------------------------------------------------------------------------------ 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 }\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 /** RFC 0001: every root field decides every required route decorator group (ZNIGHT023). */\n #checkDecisions(resolvers: readonly ResolverData[]): 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(this.#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 = ROOT_TYPE_NAMES[field.operation]\n this.#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 // ------------------------------------------------------------------------------------ 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/** 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/** 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\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\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, 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 return ctx.obj([...head, ['fields', ctx.arr(type.fields.map(field => fieldNode(ctx, imports, field)))]])\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 const discriminator = type.discriminator\n let node: GenNode\n if (discriminator === undefined || discriminator.by === 'typename') node = ctx.obj([['by', 'typename']])\n else if (discriminator.by === 'property') {\n node = ctx.obj([\n ['by', 'property'],\n ['property', discriminator.property],\n ['values', ctx.obj(Object.entries(discriminator.values))],\n ])\n } else {\n node = ctx.obj([\n ['by', 'class'],\n [\n 'classes',\n ctx.arr(discriminator.classes.map(entry => ctx.arr([ctx.importValue(entry.identity), entry.name]))),\n ],\n ])\n }\n return ctx.obj([...head, ['members', ctx.lit([...type.members])], ['discriminator', node]])\n }\n case 'scalar':\n // built-in scalars carry no description (the runtime builds them, sdl.ts prints them alike);\n // user scalars bring theirs with the imported definition\n return type.definition === undefined\n ? ctx.obj([...head, ['builtin', ctx.lit(true)]])\n : ctx.obj([...head, ['scalar', ctx.importValue(type.definition)]])\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), given with `graphql.configure({ ... })` in\n * `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. */\n readonly number?: 'Float' | 'Int'\n}\n\n/** {@link GraphQLCompilerOptions} with their defaults. */\nexport interface ResolvedGraphQLCompilerOptions {\n readonly sdl: string | false\n readonly number: 'Float' | 'Int'\n}\n\n/** The defaults. */\nexport const DEFAULT_OPTIONS: ResolvedGraphQLCompilerOptions = Object.freeze({ sdl: false, number: 'Float' })\n\nconst KNOWN = new Set(['sdl', 'number'])\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? }')\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)`)\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 })\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'\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'] },\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: analyzeGraphQLClass,\n validate(ctx) {\n models.set(ctx.graph.extensions, buildModel(ctx, options))\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,KAA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