@znight/graphql 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/decorators.ts","../src/validate-args.ts"],"sourcesContent":["/**\n * Marker decorators of `@znight/graphql` (RFC 0005 §5.14). Like every Znight decorator they do\n * nothing at runtime: the compiler extension (`@znight/graphql/compiler`) reads them from the source\n * code, derives the schema from the TypeScript types they reach and generates\n * `metadata.extensions.graphql`. Arguments marked _static_ must be statically evaluable (literals,\n * `const` references); _value_ arguments may also be references to exported bindings (schemas,\n * guard classes). See docs/internals/architecture.md §4.6.\n *\n * Also here: `scalar<T>()`, the scalar aliases (`ID`, `Int`, `Float`, `JSONValue`) and `Loader<L>`,\n * which shares its name with the `@Loader()` decorator (one identity, `@znight/graphql#Loader`, for\n * the parameter decorator and the parameter type).\n */\nimport type { ClassMarker, MethodMarker, ParameterMarker, Scope } from '@znight/core'\nimport type { StandardSchemaV1 } from '@znight/http'\nimport type { GraphQLScalarType } from 'graphql'\nimport type { BatchLoad, BatchLoader, GraphQLGuardClass, LoaderKey, LoaderValue, ScalarDefinition } from './types.ts'\n\nfunction marker(): void {\n // intentionally empty: decorators are compile-time markers\n}\n\nconst classMarker: ClassMarker = marker\nconst methodMarker: MethodMarker = marker\nconst parameterMarker: ParameterMarker = marker\nconst classOrMethodMarker: ClassMarker & MethodMarker = marker\n\n/** GraphQL `ID`: a string on the wire and in TypeScript. Recognised by the compiler through the alias. */\nexport type ID = string\n\n/** GraphQL `Int` (32-bit signed integer). A `number` in TypeScript; plain `number` maps to `Float`. */\nexport type Int = number\n\n/** GraphQL `Float`. Same as `number`, for symmetry with {@link Int}. */\nexport type Float = number\n\n/** Any JSON value: the `JSON` scalar. */\nexport type JSONValue = string | number | boolean | null | readonly JSONValue[] | { readonly [key: string]: JSONValue }\n\n/**\n * The DataLoader of the current execution for the loader provider `L`, injected with `@Loader()`:\n * created on first use, cached for the operation (or for one subscription event), then dropped.\n *\n * ```ts\n * @ResolveField()\n * author(@Parent() book: Book, @Loader() authors: Loader<AuthorsById>): Promise<Author> {\n * return authors.load(book.authorId)\n * }\n * ```\n */\nexport type Loader<L extends BatchLoad<unknown, unknown>> = BatchLoader<LoaderKey<L>, LoaderValue<L>>\n\n/** Options of {@link Resolver} (static). */\nexport interface ResolverOptions {\n /** Provider scope. Default: `singleton`; `request` creates one resolver per operation. */\n readonly scope?: Scope\n}\n\n/**\n * Declares a resolver: a provider (singleton by default) whose `@Query`, `@Mutation`,\n * `@Subscription` and `@ResolveField` methods are fields of the schema. Route decorators of\n * `@znight/http` (`createRouteDecorator`) on the class are the default decisions of its fields.\n *\n * Schema-first (RFC 0007): `@Resolver('Event')` names the SDL object type its `@ResolveField`\n * methods resolve fields of (`@Resolver('Event', { scope })` with options). Code-first rejects a\n * type name (ZNIGHT005): the type is the one of the `@Parent()` parameter.\n *\n * ```ts\n * @Resolver()\n * export class BookResolver {\n * constructor(private readonly catalog: CatalogService) {}\n *\n * @Query()\n * book(@Args('id') id: ID): Promise<Book | null> {\n * return this.catalog.find(id)\n * }\n * }\n * ```\n *\n * @param typeOrOptions static: the SDL type name (schema-first), or `{ scope? }`.\n * @param options static: `{ scope? }`, after a type name.\n */\nexport function Resolver(_typeOrOptions?: string | ResolverOptions, _options?: ResolverOptions): ClassMarker {\n return classMarker\n}\n\n/**\n * A field of the `Query` root type. The method's declared return type is the field type\n * (`Promise<T>` unwrapped), its `@Args` the arguments, its JSDoc the description.\n *\n * @param name static: field name. Default: the method name.\n */\nexport function Query(_name?: string): MethodMarker {\n return methodMarker\n}\n\n/**\n * A field of the `Mutation` root type.\n *\n * @param name static: field name. Default: the method name.\n */\nexport function Mutation(_name?: string): MethodMarker {\n return methodMarker\n}\n\n/**\n * A field of the `Subscription` root type. The method returns an `AsyncIterable<T>` (an async\n * generator, or `pubsub.subscribe(...)`), each value being the field value of one event.\n *\n * @param name static: field name. Default: the method name.\n */\nexport function Subscription(_name?: string): MethodMarker {\n return methodMarker\n}\n\n/**\n * A field resolver: adds a field to the type of the `@Parent()` parameter (mandatory), or replaces\n * the property field of the same name. Schema-first (RFC 0007): resolves the field of the type named\n * by `@Resolver('Type')`, `@Parent()` optional.\n *\n * @param name static: field name. Default: the method name.\n */\nexport function ResolveField(_name?: string): MethodMarker {\n return methodMarker\n}\n\n/**\n * Field arguments. Without a name, the properties of the parameter type become arguments\n * (`@Args() filter: BookFilter`); with a name, one argument (`@Args('id') id: ID`). With a Standard\n * Schema, the value is validated (and transformed) after GraphQL coerced it; a failure is a\n * `BAD_USER_INPUT` error listing the issues.\n *\n * @param name static: argument name.\n * @param schema value: a Standard Schema validating the value (its output is injected).\n */\nexport function Args(): ParameterMarker\nexport function Args(name: string, schema?: StandardSchemaV1): ParameterMarker\nexport function Args(schema: StandardSchemaV1): ParameterMarker\nexport function Args(_nameOrSchema?: string | StandardSchemaV1, _schema?: StandardSchemaV1): ParameterMarker {\n return parameterMarker\n}\n\n/** The parent object of a field resolver (`@ResolveField` only; its type is the parent type). */\nexport function Parent(): ParameterMarker {\n return parameterMarker\n}\n\n/** The `GraphQLContext` of the operation. */\nexport function Ctx(): ParameterMarker {\n return parameterMarker\n}\n\n/** The graphql-js `GraphQLResolveInfo` of the call (escape hatch). */\nexport function Info(): ParameterMarker {\n return parameterMarker\n}\n\n/** The DataLoader of the current execution for the `Loader<L>` parameter type (see {@link Loader}). */\nexport function Loader(): ParameterMarker {\n return parameterMarker\n}\n\n/**\n * Guards of the fields of a resolver class or of one field, run after the global guards (class\n * guards, then method guards). Guards are providers implementing `GraphQLGuard`.\n *\n * @param guards value: guard classes.\n */\nexport function UseGuard(..._guards: [GraphQLGuardClass, ...GraphQLGuardClass[]]): ClassMarker & MethodMarker {\n return classOrMethodMarker\n}\n\n/**\n * Maps the TypeScript type `T` to the GraphQL scalar `name` wherever it appears. `name` is static;\n * the returned definition must be exported (`export const`): the generated module imports it.\n * Returns `definition` unchanged.\n *\n * ```ts\n * export type EmailAddress = string & { readonly __brand: 'EmailAddress' }\n *\n * export const EmailAddressScalar = scalar<EmailAddress>('EmailAddress', {\n * serialize: value => value,\n * parseValue: value => {\n * if (typeof value !== 'string' || !value.includes('@')) throw new TypeError('Expected an e-mail address')\n * return value.toLowerCase() as EmailAddress\n * },\n * })\n *\n * export const UrlScalar = scalar<URL>('URL', GraphQLURL) // a graphql-js GraphQLScalarType\n * ```\n *\n * @param name static: the GraphQL name of the scalar.\n * @param definition value: a {@link ScalarDefinition} or a graphql-js `GraphQLScalarType` (whose\n * name must be `name`, ZNIGHT066 at boot otherwise).\n */\nexport function scalar<T>(name: string, definition: ScalarDefinition<T>): ScalarDefinition<T>\nexport function scalar<T>(name: string, definition: GraphQLScalarType): GraphQLScalarType<T>\nexport function scalar<T>(\n _name: string,\n definition: ScalarDefinition<T> | GraphQLScalarType,\n): ScalarDefinition<T> | GraphQLScalarType {\n return definition\n}\n","/**\n * `validateArgs()`: Standard Schema validation of resolver arguments (RFC 0005 §5.4, §7.3), called\n * by the generated `invoke` functions (README, \"Compiler contract\").\n */\nimport type { InferSchemaOutput, StandardSchemaV1, StandardSchemaV1Result } from '@znight/http'\n\nimport { isThenable, toIssueDetail } from '@znight/http'\n\nimport { GraphQLErrorCode, GraphQLException } from './errors.ts'\n\n/**\n * Validates an argument value (after GraphQL coercion) with a [Standard Schema](https://standardschema.dev)\n * (Zod, Valibot, ArkType...) and returns the schema **output** (transforms run, defaults applied).\n *\n * Synchronous when the schema validates synchronously (no promise, no microtask), a promise\n * otherwise: generated code `await`s the result, which is free for a plain value.\n *\n * @param label what is validated, for the message: the argument name (`'input'`), or `'arguments'`\n * for `@Args(Schema)` without name.\n * @throws GraphQLException `BAD_USER_INPUT`, `extensions.issues: [{ path, message }]`, when the\n * value is invalid.\n * @throws TypeError when `schema` is not a Standard Schema v1 (a programming error, masked).\n */\nexport function validateArgs<S extends StandardSchemaV1>(\n schema: S,\n value: unknown,\n label: string,\n): InferSchemaOutput<S> | Promise<InferSchemaOutput<S>> {\n const props =\n schema !== null && (typeof schema === 'object' || typeof schema === 'function')\n ? (schema as { readonly '~standard'?: { readonly version?: unknown; readonly validate?: unknown } })['~standard']\n : undefined\n if (props === null || typeof props !== 'object' || props.version !== 1 || typeof props.validate !== 'function') {\n throw new TypeError(`The schema of ${label} is not a Standard Schema v1 (missing \"~standard.validate\")`)\n }\n const result = (props.validate as (value: unknown) => StandardSchemaV1Result<InferSchemaOutput<S>>)(value)\n // sync fast path: most schemas validate synchronously\n if (isThenable(result)) return Promise.resolve(result).then(settled => unwrap(settled, label))\n return unwrap(result, label)\n}\n\nfunction unwrap<T>(result: StandardSchemaV1Result<T>, label: string): T {\n if (result.issues === undefined) return result.value\n throw new GraphQLException(`Invalid ${label}`, {\n code: GraphQLErrorCode.BadUserInput,\n extensions: { issues: result.issues.map(toIssueDetail) },\n })\n}\n"],"mappings":";;;;AAiBA,SAAS,SAAe,CAExB;AAEA,MAAM,cAA2B;AACjC,MAAM,eAA6B;AACnC,MAAM,kBAAmC;AACzC,MAAM,sBAAkD;;;;;;;;;;;;;;;;;;;;;;;;;AAyDxD,SAAgB,SAAS,gBAA2C,UAAyC;CAC3G,OAAO;AACT;;;;;;;AAQA,SAAgB,MAAM,OAA8B;CAClD,OAAO;AACT;;;;;;AAOA,SAAgB,SAAS,OAA8B;CACrD,OAAO;AACT;;;;;;;AAQA,SAAgB,aAAa,OAA8B;CACzD,OAAO;AACT;;;;;;;;AASA,SAAgB,aAAa,OAA8B;CACzD,OAAO;AACT;AAcA,SAAgB,KAAK,eAA2C,SAA6C;CAC3G,OAAO;AACT;;AAGA,SAAgB,SAA0B;CACxC,OAAO;AACT;;AAGA,SAAgB,MAAuB;CACrC,OAAO;AACT;;AAGA,SAAgB,OAAwB;CACtC,OAAO;AACT;;AAGA,SAAgB,SAA0B;CACxC,OAAO;AACT;;;;;;;AAQA,SAAgB,SAAS,GAAG,SAAkF;CAC5G,OAAO;AACT;AA2BA,SAAgB,OACd,OACA,YACyC;CACzC,OAAO;AACT;;;;;;;;;;;;;;;AClLA,SAAgB,aACd,QACA,OACA,OACsD;CACtD,MAAM,QACJ,WAAW,SAAS,OAAO,WAAW,YAAY,OAAO,WAAW,cAC/D,OAAkG,eACnG,KAAA;CACN,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,YAAY,KAAK,OAAO,MAAM,aAAa,YAClG,MAAM,IAAI,UAAU,iBAAiB,MAAM,4DAA4D;CAEzG,MAAM,SAAU,MAAM,SAA8E,KAAK;CAEzG,IAAI,WAAW,MAAM,GAAG,OAAO,QAAQ,QAAQ,MAAM,CAAC,CAAC,MAAK,YAAW,OAAO,SAAS,KAAK,CAAC;CAC7F,OAAO,OAAO,QAAQ,KAAK;AAC7B;AAEA,SAAS,OAAU,QAAmC,OAAkB;CACtE,IAAI,OAAO,WAAW,KAAA,GAAW,OAAO,OAAO;CAC/C,MAAM,IAAI,iBAAiB,WAAW,SAAS;EAC7C,MAAM,iBAAiB;EACvB,YAAY,EAAE,QAAQ,OAAO,OAAO,IAAI,aAAa,EAAE;CACzD,CAAC;AACH"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/decorators.ts","../src/validate-args.ts"],"sourcesContent":["/**\n * Marker decorators of `@znight/graphql` (RFC 0005 §5.14). Like every Znight decorator they do\n * nothing at runtime: the compiler extension (`@znight/graphql/compiler`) reads them from the source\n * code, derives the schema from the TypeScript types they reach and generates\n * `metadata.extensions.graphql`. Arguments marked _static_ must be statically evaluable (literals,\n * `const` references); _value_ arguments may also be references to exported bindings (schemas,\n * guard classes). See docs/internals/architecture.md §4.6.\n *\n * Also here: `scalar<T>()`, the scalar aliases (`ID`, `Int`, `Float`, `JSONValue`) and `Loader<L>`,\n * which shares its name with the `@Loader()` decorator (one identity, `@znight/graphql#Loader`, for\n * the parameter decorator and the parameter type).\n */\nimport type { ClassMarker, MethodMarker, ParameterMarker, Scope } from '@znight/core'\nimport type { StandardSchemaV1 } from '@znight/http'\nimport type { GraphQLScalarType } from 'graphql'\nimport type { BatchLoad, BatchLoader, GraphQLGuardClass, LoaderKey, LoaderValue, ScalarDefinition } from './types.ts'\n\nfunction marker(): void {\n // intentionally empty: decorators are compile-time markers\n}\n\nconst classMarker: ClassMarker = marker\nconst methodMarker: MethodMarker = marker\nconst parameterMarker: ParameterMarker = marker\nconst classOrMethodMarker: ClassMarker & MethodMarker = marker\n\n/** GraphQL `ID`: a string on the wire and in TypeScript. Recognised by the compiler through the alias. */\nexport type ID = string\n\n/** GraphQL `Int` (32-bit signed integer). A `number` in TypeScript; plain `number` maps to `Float`. */\nexport type Int = number\n\n/** GraphQL `Float`. Same as `number`, for symmetry with {@link Int}. */\nexport type Float = number\n\n/** Any JSON value: the `JSON` scalar. */\nexport type JSONValue = string | number | boolean | null | readonly JSONValue[] | { readonly [key: string]: JSONValue }\n\n/**\n * The DataLoader of the current execution for the loader provider `L`, injected with `@Loader()`:\n * created on first use, cached for the operation (or for one subscription event), then dropped.\n *\n * ```ts\n * @ResolveField()\n * author(@Parent() book: Book, @Loader() authors: Loader<AuthorsById>): Promise<Author> {\n * return authors.load(book.authorId)\n * }\n * ```\n */\nexport type Loader<L extends BatchLoad<unknown, unknown>> = BatchLoader<LoaderKey<L>, LoaderValue<L>>\n\n/** Options of {@link Resolver} (static). */\nexport interface ResolverOptions {\n /** Provider scope. Default: `singleton`; `request` creates one resolver per operation. */\n readonly scope?: Scope\n}\n\n/**\n * Declares a resolver: a provider (singleton by default) whose `@Query`, `@Mutation`,\n * `@Subscription` and `@ResolveField` methods are fields of the schema. Route decorators of\n * `@znight/http` (`createRouteDecorator`) on the class are the default decisions of its fields.\n *\n * Schema-first (RFC 0007): `@Resolver('Event')` names the SDL object type its `@ResolveField`\n * methods resolve fields of (`@Resolver('Event', { scope })` with options). Code-first rejects a\n * type name (ZNIGHT005): the type is the one of the `@Parent()` parameter.\n *\n * ```ts\n * @Resolver()\n * export class BookResolver {\n * constructor(private readonly catalog: CatalogService) {}\n *\n * @Query()\n * book(@Args('id') id: ID): Promise<Book | null> {\n * return this.catalog.find(id)\n * }\n * }\n * ```\n *\n * @param typeOrOptions static: the SDL type name (schema-first), or `{ scope? }`.\n * @param options static: `{ scope? }`, after a type name.\n */\nexport function Resolver(_typeOrOptions?: string | ResolverOptions, _options?: ResolverOptions): ClassMarker {\n return classMarker\n}\n\n/**\n * A field of the `Query` root type. The method's declared return type is the field type\n * (`Promise<T>` unwrapped), its `@Args` the arguments, its JSDoc the description.\n *\n * @param name static: field name. Default: the method name.\n */\nexport function Query(_name?: string): MethodMarker {\n return methodMarker\n}\n\n/**\n * A field of the `Mutation` root type.\n *\n * @param name static: field name. Default: the method name.\n */\nexport function Mutation(_name?: string): MethodMarker {\n return methodMarker\n}\n\n/**\n * A field of the `Subscription` root type. The method returns an `AsyncIterable<T>` (an async\n * generator, or `pubsub.subscribe(...)`), each value being the field value of one event.\n *\n * @param name static: field name. Default: the method name.\n */\nexport function Subscription(_name?: string): MethodMarker {\n return methodMarker\n}\n\n/**\n * A field resolver: adds a field to the type of the `@Parent()` parameter (mandatory), or replaces\n * the property field of the same name. Schema-first (RFC 0007): resolves the field of the type named\n * by `@Resolver('Type')`, `@Parent()` optional.\n *\n * @param name static: field name. Default: the method name.\n */\nexport function ResolveField(_name?: string): MethodMarker {\n return methodMarker\n}\n\n/**\n * Field arguments. Without a name, the properties of the parameter type become arguments\n * (`@Args() filter: BookFilter`); with a name, one argument (`@Args('id') id: ID`). With a Standard\n * Schema, the value is validated (and transformed) after GraphQL coerced it; a failure is a\n * `BAD_USER_INPUT` error listing the issues.\n *\n * @param name static: argument name.\n * @param schema value: a Standard Schema validating the value (its output is injected).\n */\nexport function Args(): ParameterMarker\nexport function Args(name: string, schema?: StandardSchemaV1): ParameterMarker\nexport function Args(schema: StandardSchemaV1): ParameterMarker\nexport function Args(_nameOrSchema?: string | StandardSchemaV1, _schema?: StandardSchemaV1): ParameterMarker {\n return parameterMarker\n}\n\n/** The parent object of a field resolver (`@ResolveField` only; its type is the parent type). */\nexport function Parent(): ParameterMarker {\n return parameterMarker\n}\n\n/** The `GraphQLContext` of the operation. */\nexport function Ctx(): ParameterMarker {\n return parameterMarker\n}\n\n/** The graphql-js `GraphQLResolveInfo` of the call (escape hatch). */\nexport function Info(): ParameterMarker {\n return parameterMarker\n}\n\n/** The DataLoader of the current execution for the `Loader<L>` parameter type (see {@link Loader}). */\nexport function Loader(): ParameterMarker {\n return parameterMarker\n}\n\n/**\n * Guards of the fields of a resolver class or of one field, run after the global guards (class\n * guards, then method guards). Guards are providers implementing `GraphQLGuard`.\n *\n * @param guards value: guard classes.\n */\nexport function UseGuard(..._guards: [GraphQLGuardClass, ...GraphQLGuardClass[]]): ClassMarker & MethodMarker {\n return classOrMethodMarker\n}\n\n/**\n * Maps the TypeScript type `T` to the GraphQL scalar `name` wherever it appears. `name` is static;\n * the returned definition must be exported (`export const`): the generated module imports it.\n * Returns `definition` unchanged.\n *\n * ```ts\n * export type EmailAddress = string & { readonly __brand: 'EmailAddress' }\n *\n * export const EmailAddressScalar = scalar<EmailAddress>('EmailAddress', {\n * serialize: value => value,\n * parseValue: value => {\n * if (typeof value !== 'string' || !value.includes('@')) throw new TypeError('Expected an e-mail address')\n * return value.toLowerCase() as EmailAddress\n * },\n * })\n *\n * export const UrlScalar = scalar<URL>('URL', GraphQLURL) // a graphql-js GraphQLScalarType\n * ```\n *\n * @param name static: the GraphQL name of the scalar.\n * @param definition value: a {@link ScalarDefinition} or a graphql-js `GraphQLScalarType` (whose\n * name must be `name`, ZNIGHT066 at boot otherwise).\n */\nexport function scalar<T>(name: string, definition: ScalarDefinition<T>): ScalarDefinition<T>\nexport function scalar<T>(name: string, definition: GraphQLScalarType): GraphQLScalarType<T>\nexport function scalar<T>(\n _name: string,\n definition: ScalarDefinition<T> | GraphQLScalarType,\n): ScalarDefinition<T> | GraphQLScalarType {\n return definition\n}\n","/**\n * `validateArgs()`: Standard Schema validation of resolver arguments (RFC 0005 §5.4, §7.3), called\n * by the generated `invoke` functions (README, \"Compiler contract\").\n */\nimport type { InferSchemaOutput, StandardSchemaV1, StandardSchemaV1Result } from '@znight/http'\n\nimport { isThenable, toIssueDetail } from '@znight/http'\n\nimport { GraphQLErrorCode, GraphQLException } from './errors.ts'\n\n/**\n * Validates an argument value (after GraphQL coercion) with a [Standard Schema](https://standardschema.dev)\n * (Zod, Valibot, ArkType...) and returns the schema **output** (transforms run, defaults applied).\n *\n * Synchronous when the schema validates synchronously (no promise, no microtask), a promise\n * otherwise: generated code `await`s the result, which is free for a plain value.\n *\n * @param label what is validated, for the message: the argument name (`'input'`), or `'arguments'`\n * for `@Args(Schema)` without name.\n * @throws GraphQLException `BAD_USER_INPUT`, `extensions.issues: [{ path, message }]`, when the\n * value is invalid.\n * @throws TypeError when `schema` is not a Standard Schema v1 (a programming error, masked).\n */\nexport function validateArgs<S extends StandardSchemaV1>(\n schema: S,\n value: unknown,\n label: string,\n): InferSchemaOutput<S> | Promise<InferSchemaOutput<S>> {\n const props =\n schema !== null && (typeof schema === 'object' || typeof schema === 'function')\n ? (schema as { readonly '~standard'?: { readonly version?: unknown; readonly validate?: unknown } })['~standard']\n : undefined\n if (props === null || typeof props !== 'object' || props.version !== 1 || typeof props.validate !== 'function') {\n throw new TypeError(`The schema of ${label} is not a Standard Schema v1 (missing \"~standard.validate\")`)\n }\n const result = (props.validate as (value: unknown) => StandardSchemaV1Result<InferSchemaOutput<S>>)(value)\n // sync fast path: most schemas validate synchronously\n if (isThenable(result)) return Promise.resolve(result).then(settled => unwrap(settled, label))\n return unwrap(result, label)\n}\n\nfunction unwrap<T>(result: StandardSchemaV1Result<T>, label: string): T {\n if (result.issues === undefined) return result.value\n throw new GraphQLException(`Invalid ${label}`, {\n code: GraphQLErrorCode.BadUserInput,\n extensions: { issues: result.issues.map(toIssueDetail) },\n })\n}\n"],"mappings":";;;;;AAiBA,SAAS,SAAe,CAExB;AAEA,MAAM,cAA2B;AACjC,MAAM,eAA6B;AACnC,MAAM,kBAAmC;AACzC,MAAM,sBAAkD;;;;;;;;;;;;;;;;;;;;;;;;;AAyDxD,SAAgB,SAAS,gBAA2C,UAAyC;CAC3G,OAAO;AACT;;;;;;;AAQA,SAAgB,MAAM,OAA8B;CAClD,OAAO;AACT;;;;;;AAOA,SAAgB,SAAS,OAA8B;CACrD,OAAO;AACT;;;;;;;AAQA,SAAgB,aAAa,OAA8B;CACzD,OAAO;AACT;;;;;;;;AASA,SAAgB,aAAa,OAA8B;CACzD,OAAO;AACT;AAcA,SAAgB,KAAK,eAA2C,SAA6C;CAC3G,OAAO;AACT;;AAGA,SAAgB,SAA0B;CACxC,OAAO;AACT;;AAGA,SAAgB,MAAuB;CACrC,OAAO;AACT;;AAGA,SAAgB,OAAwB;CACtC,OAAO;AACT;;AAGA,SAAgB,SAA0B;CACxC,OAAO;AACT;;;;;;;AAQA,SAAgB,SAAS,GAAG,SAAkF;CAC5G,OAAO;AACT;AA2BA,SAAgB,OACd,OACA,YACyC;CACzC,OAAO;AACT;;;;;;;;;;;;;;;AClLA,SAAgB,aACd,QACA,OACA,OACsD;CACtD,MAAM,QACJ,WAAW,SAAS,OAAO,WAAW,YAAY,OAAO,WAAW,cAC/D,OAAkG,eACnG,KAAA;CACN,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,YAAY,KAAK,OAAO,MAAM,aAAa,YAClG,MAAM,IAAI,UAAU,iBAAiB,MAAM,4DAA4D;CAEzG,MAAM,SAAU,MAAM,SAA8E,KAAK;CAEzG,IAAI,WAAW,MAAM,GAAG,OAAO,QAAQ,QAAQ,MAAM,CAAC,CAAC,MAAK,YAAW,OAAO,SAAS,KAAK,CAAC;CAC7F,OAAO,OAAO,QAAQ,KAAK;AAC7B;AAEA,SAAS,OAAU,QAAmC,OAAkB;CACtE,IAAI,OAAO,WAAW,KAAA,GAAW,OAAO,OAAO;CAC/C,MAAM,IAAI,iBAAiB,WAAW,SAAS;EAC7C,MAAM,iBAAiB;EACvB,YAAY,EAAE,QAAQ,OAAO,OAAO,IAAI,aAAa,EAAE;CACzD,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"names-BlzDM5cF.mjs","names":[],"sources":["../src/metadata.ts","../src/type-ref.ts","../src/names.ts"],"sourcesContent":["/**\n * GraphQL section of the generated metadata (`__ZNIGHT_METADATA__.extensions.graphql`, RFC 0005\n * §7), produced by the `@znight/graphql/compiler` extension and consumed by `GraphQLPlugin`, which\n * validates it at boot (ZNIGHT066), because metadata can be hand-written.\n *\n * Data, not code, except `invoke` (one arrow per resolver) and the scalar implementations imported\n * from user code. The SDL printer (`sdl.ts`) reads the same shape without its functions.\n *\n * Import-free: types, type-only imports and one constant, shared by the compiler extension and the\n * runtime.\n */\nimport type { Token } from '@znight/core'\nimport type { HttpRouteGroupDefinition } from '@znight/http'\nimport type { GraphQLResolveInfo, GraphQLScalarType } from 'graphql'\nimport type { GraphQLArgs, GraphQLContext, ScalarDefinition } from './types.ts'\n\n/** Format version of `metadata.extensions.graphql` (another version is ZNIGHT066 at boot). */\nexport const GRAPHQL_METADATA_VERSION = 1\n\n/** The schema of the application. The section is omitted when the application has no resolver. */\nexport interface GraphQLMetadata {\n /** {@link GRAPHQL_METADATA_VERSION}. */\n readonly version: number\n /** First 16 hexadecimal characters of the SHA-256 of the SDL (`printSdl`): logs, caches. */\n readonly schemaHash: string\n readonly roots: GraphQLRootTypes\n /** Every named type except the graphql-js specified scalars, sorted by name (code-unit order). */\n readonly types: readonly GraphQLTypeDefinition[]\n /**\n * Route decorator groups used on resolvers that must be known at runtime (required, or holding\n * several keys), by group name: the shape of `extensions.http.groups` (RFC 0001).\n */\n readonly groups?: Readonly<Record<string, HttpRouteGroupDefinition>>\n}\n\n/** Names of the root operation types (`Query`, `Mutation`, `Subscription`). */\nexport interface GraphQLRootTypes {\n readonly query: string\n readonly mutation?: string\n readonly subscription?: string\n}\n\n/** A named type of the schema. */\nexport type GraphQLTypeDefinition =\n | GraphQLObjectTypeDefinition\n | GraphQLInterfaceTypeDefinition\n | GraphQLInputTypeDefinition\n | GraphQLEnumTypeDefinition\n | GraphQLUnionTypeDefinition\n | GraphQLBuiltinScalarDefinition\n | GraphQLCustomScalarDefinition\n\n/** An object type: resolver return types, their fields, the root types. */\nexport interface GraphQLObjectTypeDefinition {\n readonly kind: 'object'\n readonly name: string\n readonly description?: string\n /** Interfaces the type implements (schema-first, RFC 0007), in declaration order. Absent: none. */\n readonly interfaces?: readonly string[]\n /** Declaration order (base members first), then field resolvers by resolver token and source order. */\n readonly fields: readonly GraphQLFieldDefinition[]\n}\n\n/**\n * An interface type (schema-first, RFC 0007; code-first emits none). Its fields have no\n * `resolver`: graphql-js resolves the fields of the concrete object type.\n */\nexport interface GraphQLInterfaceTypeDefinition {\n readonly kind: 'interface'\n readonly name: string\n readonly description?: string\n /** Interfaces the interface implements, in declaration order. Absent: none. */\n readonly interfaces?: readonly string[]\n readonly fields: readonly GraphQLFieldDefinition[]\n /** How the runtime tells the implementing object types apart (`resolveType`). */\n readonly discriminator: GraphQLDiscriminator\n}\n\n/** An input object type. */\nexport interface GraphQLInputTypeDefinition {\n readonly kind: 'input'\n readonly name: string\n readonly description?: string\n readonly fields: readonly GraphQLInputFieldDefinition[]\n}\n\n/** An enum: a TypeScript `enum`, or a named alias of a union of string literals. */\nexport interface GraphQLEnumTypeDefinition {\n readonly kind: 'enum'\n readonly name: string\n readonly description?: string\n /** Declaration order. */\n readonly values: readonly GraphQLEnumValueDefinition[]\n}\n\n/** A union of object types. */\nexport interface GraphQLUnionTypeDefinition {\n readonly kind: 'union'\n readonly name: string\n readonly description?: string\n /** Member type names, sorted. */\n readonly members: readonly string[]\n readonly discriminator: GraphQLDiscriminator\n}\n\n/** A scalar implemented by `@znight/graphql`: `DateTime`, `BigInt` or `JSON` (`names.ts`). */\nexport interface GraphQLBuiltinScalarDefinition {\n readonly kind: 'scalar'\n readonly name: string\n readonly description?: string\n readonly builtin: true\n}\n\n/** A scalar declared with `scalar<T>(name, definition)`: the definition is imported from user code. */\nexport interface GraphQLCustomScalarDefinition {\n readonly kind: 'scalar'\n readonly name: string\n /** Wins over the description of the definition (schema-first: the SDL's). */\n readonly description?: string\n /** Wins over the `specifiedByURL` of the definition (schema-first: the SDL's `@specifiedBy`). */\n readonly specifiedByURL?: string\n /**\n * Schema-first (RFC 0007): `description` and `specifiedByURL` are the SDL's and replace the\n * definition's, also when absent, so that the served schema is the SDL.\n */\n readonly sdl?: true\n /** `ScalarDefinition<T>` of any `T` (its methods are bivariant), or a graphql-js scalar named `name`. */\n readonly scalar: ScalarDefinition<unknown> | GraphQLScalarType\n}\n\n/** A field of an object type. */\nexport interface GraphQLFieldDefinition {\n readonly name: string\n /** Type reference (`'Book!'`, `'[Book!]!'`, `'Int'`), parsed by `type-ref.ts`. */\n readonly type: string\n readonly description?: string\n readonly deprecationReason?: string\n readonly args?: readonly GraphQLArgumentDefinition[]\n /** Absent: the graphql-js default resolver (`parent[name]`). */\n readonly resolver?: GraphQLResolverBinding\n}\n\n/** An argument of a field. */\nexport interface GraphQLArgumentDefinition {\n readonly name: string\n readonly type: string\n readonly description?: string\n readonly deprecationReason?: string\n /**\n * Default value, as an external value: JSON-compatible, enum values by GraphQL name (passed to\n * graphql-js as `default: { value }`). Absent: no default.\n */\n readonly defaultValue?: unknown\n /** The TypeScript type does not accept `null`: a `null` sent by the client becomes `undefined` (§5.4). */\n readonly nullAsUndefined?: true\n}\n\n/** A field of an input object type. */\nexport interface GraphQLInputFieldDefinition extends GraphQLArgumentDefinition {}\n\n/** A value of an enum. */\nexport interface GraphQLEnumValueDefinition {\n /** GraphQL name (the member name, or the literal). */\n readonly name: string\n /** Internal value (the member value, or the literal), what resolvers receive and return. */\n readonly value: string | number\n readonly description?: string\n readonly deprecationReason?: string\n}\n\n/** How the runtime tells the members of a union or the implementations of an interface apart (`resolveType`). */\nexport type GraphQLDiscriminator =\n | {\n readonly by: 'property'\n readonly property: string\n /** Literal value of the property (as a string) → member type name. */\n readonly values: Readonly<Record<string, string>>\n }\n | {\n readonly by: 'class'\n /** Member classes and their type names, subclasses first (`instanceof` order). */\n readonly classes: readonly (readonly [cls: abstract new (...args: never[]) => unknown, name: string])[]\n }\n | { readonly by: 'typename' }\n\n/** Kind of field a resolver method provides. */\nexport type GraphQLResolverOperation = 'query' | 'mutation' | 'subscription' | 'field'\n\n/** The resolver method behind a field. */\nexport interface GraphQLResolverBinding {\n /** Provider token of the resolver class. */\n readonly token: Token\n readonly method: string\n readonly operation: GraphQLResolverOperation\n /** Guard provider tokens: class `@UseGuard` guards, then method ones. */\n readonly guards: readonly Token[]\n /**\n * Effective field metadata (`createRouteDecorator` values, method decisions over class ones, one\n * decision per group). Empty: no metadata, so global guards skip a field resolver (§5.9).\n */\n readonly meta: Readonly<Record<string, unknown>>\n /** Informational: loader provider tokens the method injects. */\n readonly loaders?: readonly Token[]\n /**\n * Calls the method: maps the graphql-js arguments to the method parameters (§7.3). Synchronous\n * unless an argument is validated with a Standard Schema.\n */\n readonly invoke: (\n // biome-ignore lint/suspicious/noExplicitAny: generated invokers receive the concrete resolver class\n resolver: any,\n parent: unknown,\n args: GraphQLArgs,\n context: GraphQLContext,\n info: GraphQLResolveInfo,\n ) => unknown\n}\n\ndeclare module '@znight/core' {\n interface ZnightExtensionsMetadata {\n readonly graphql?: GraphQLMetadata\n }\n}\n","/**\n * GraphQL type references as written in `metadata.extensions.graphql` (`'Book!'`, `'[Book!]!'`,\n * `'[[Int]]'`): parsing and printing.\n *\n * Import-free: shared by the compiler extension (which prints them) and the runtime (which parses\n * them once, at boot, to build the schema). The grammar is the canonical form graphql-js prints\n * (`String(type)`): no whitespace, no comments, names matching `/^[_A-Za-z][_0-9A-Za-z]*$/`.\n */\n\n/** A parsed type reference. */\nexport type GraphQLTypeRef = NamedTypeRef | ListTypeRef\n\n/** A named type (`Book`, `Book!`). */\nexport interface NamedTypeRef {\n readonly kind: 'named'\n readonly name: string\n readonly nonNull: boolean\n}\n\n/** A list type (`[Book]`, `[Book!]!`). */\nexport interface ListTypeRef {\n readonly kind: 'list'\n /** The item type. */\n readonly of: GraphQLTypeRef\n readonly nonNull: boolean\n}\n\n/** Result of one parsing step: the reference and the index after it. */\ninterface Step {\n readonly ref: GraphQLTypeRef\n readonly end: number\n}\n\n/**\n * Parses a type reference. Returns `undefined` when `text` is not a canonical reference, so that\n * callers validating hand-written metadata can collect every problem before failing.\n */\nexport function parseTypeRef(text: string): GraphQLTypeRef | undefined {\n const step = parseAt(text, 0)\n return step !== undefined && step.end === text.length ? step.ref : undefined\n}\n\n/** Prints a type reference in its canonical form (the form graphql-js prints). */\nexport function printTypeRef(ref: GraphQLTypeRef): string {\n const inner = ref.kind === 'named' ? ref.name : `[${printTypeRef(ref.of)}]`\n return ref.nonNull ? `${inner}!` : inner\n}\n\n/** The innermost type name of a reference (`'[Book!]!'` → `'Book'`), `undefined` when malformed. */\nexport function namedTypeOf(ref: string | GraphQLTypeRef): string | undefined {\n let current = typeof ref === 'string' ? parseTypeRef(ref) : ref\n while (current !== undefined && current.kind === 'list') current = current.of\n return current?.name\n}\n\nconst OPEN_BRACKET = 0x5b // [\nconst CLOSE_BRACKET = 0x5d // ]\nconst BANG = 0x21 // !\n\nfunction parseAt(text: string, start: number): Step | undefined {\n let ref: GraphQLTypeRef\n let index: number\n if (text.charCodeAt(start) === OPEN_BRACKET) {\n const item = parseAt(text, start + 1)\n if (item === undefined || text.charCodeAt(item.end) !== CLOSE_BRACKET) return undefined\n index = item.end + 1\n ref = { kind: 'list', of: item.ref, nonNull: false }\n } else {\n index = start\n if (!isNameStart(text.charCodeAt(index))) return undefined\n index++\n while (isNameContinue(text.charCodeAt(index))) index++\n ref = { kind: 'named', name: text.slice(start, index), nonNull: false }\n }\n if (text.charCodeAt(index) === BANG) {\n return { ref: { ...ref, nonNull: true }, end: index + 1 }\n }\n return { ref, end: index }\n}\n\n/** `[_A-Za-z]`. `NaN` (past the end) is never a name character. */\nfunction isNameStart(code: number): boolean {\n return code === 0x5f || (code >= 0x41 && code <= 0x5a) || (code >= 0x61 && code <= 0x7a)\n}\n\n/** `[_0-9A-Za-z]`. */\nfunction isNameContinue(code: number): boolean {\n return isNameStart(code) || (code >= 0x30 && code <= 0x39)\n}\n","/**\n * GraphQL naming rules and built-in types (RFC 0005 §5.7, §6.4).\n *\n * Import-free: shared by the compiler extension (naming diagnostics, ZNIGHT061) and the runtime\n * (structural validation of `metadata.extensions.graphql` and the built-in scalars, ZNIGHT066).\n */\n\n/** Grammar of a GraphQL name (types, fields, arguments, enum values). */\nexport const GRAPHQL_NAME: RegExp = /^[_A-Za-z][_0-9A-Za-z]*$/\n\n/** `true` when `name` is a GraphQL name that user types may take (not reserved with `__`). */\nexport function isGraphQLName(name: string): boolean {\n return GRAPHQL_NAME.test(name) && !name.startsWith('__')\n}\n\n/** Names an enum value may not take (GraphQL spec §3.9). */\nexport const RESERVED_ENUM_VALUES: ReadonlySet<string> = new Set(['true', 'false', 'null'])\n\n/** Names of the root operation types; user types may not take them (ZNIGHT061). */\nexport const ROOT_TYPE_NAMES: {\n readonly query: 'Query'\n readonly mutation: 'Mutation'\n readonly subscription: 'Subscription'\n} = Object.freeze({ query: 'Query', mutation: 'Mutation', subscription: 'Subscription' })\n\n/** Scalars of the GraphQL specification: always present, never declared in the metadata nor printed. */\nexport const SPECIFIED_SCALARS: ReadonlySet<string> = new Set(['String', 'Int', 'Float', 'Boolean', 'ID'])\n\n/** A scalar `@znight/graphql` implements itself (`kind: 'scalar', builtin: true` in the metadata). */\nexport interface BuiltinScalarInfo {\n /** `@specifiedBy(url:)`. Absent: none. */\n readonly specifiedByURL?: string\n}\n\n/**\n * The scalars `@znight/graphql` implements (§5.7): `DateTime` (`Date`), `BigInt` (`bigint`) and\n * `JSON` (`JSONValue`). They have no description. The runtime builds them with exactly these\n * properties and without `valueToLiteral`, so that graphql-js `printSchema` and `printSdl()` agree.\n */\nexport const BUILTIN_SCALARS: ReadonlyMap<string, BuiltinScalarInfo> = new Map<string, BuiltinScalarInfo>([\n ['BigInt', {}],\n ['DateTime', { specifiedByURL: 'https://datatracker.ietf.org/doc/html/rfc3339' }],\n ['JSON', {}],\n])\n\n/** The default `@deprecated` reason of graphql-js: printed as a bare `@deprecated`. */\nexport const DEFAULT_DEPRECATION_REASON = 'No longer supported'\n"],"mappings":";;AAiBA,MAAa,2BAA2B;;;;;;ACoBxC,SAAgB,aAAa,MAA0C;CACrE,MAAM,OAAO,QAAQ,MAAM,CAAC;CAC5B,OAAO,SAAS,KAAA,KAAa,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,KAAA;AACrE;;AAGA,SAAgB,aAAa,KAA6B;CACxD,MAAM,QAAQ,IAAI,SAAS,UAAU,IAAI,OAAO,IAAI,aAAa,IAAI,EAAE,EAAE;CACzE,OAAO,IAAI,UAAU,GAAG,MAAM,KAAK;AACrC;AASA,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,OAAO;AAEb,SAAS,QAAQ,MAAc,OAAiC;CAC9D,IAAI;CACJ,IAAI;CACJ,IAAI,KAAK,WAAW,KAAK,MAAM,cAAc;EAC3C,MAAM,OAAO,QAAQ,MAAM,QAAQ,CAAC;EACpC,IAAI,SAAS,KAAA,KAAa,KAAK,WAAW,KAAK,GAAG,MAAM,eAAe,OAAO,KAAA;EAC9E,QAAQ,KAAK,MAAM;EACnB,MAAM;GAAE,MAAM;GAAQ,IAAI,KAAK;GAAK,SAAS;EAAM;CACrD,OAAO;EACL,QAAQ;EACR,IAAI,CAAC,YAAY,KAAK,WAAW,KAAK,CAAC,GAAG,OAAO,KAAA;EACjD;EACA,OAAO,eAAe,KAAK,WAAW,KAAK,CAAC,GAAG;EAC/C,MAAM;GAAE,MAAM;GAAS,MAAM,KAAK,MAAM,OAAO,KAAK;GAAG,SAAS;EAAM;CACxE;CACA,IAAI,KAAK,WAAW,KAAK,MAAM,MAC7B,OAAO;EAAE,KAAK;GAAE,GAAG;GAAK,SAAS;EAAK;EAAG,KAAK,QAAQ;CAAE;CAE1D,OAAO;EAAE;EAAK,KAAK;CAAM;AAC3B;;AAGA,SAAS,YAAY,MAAuB;CAC1C,OAAO,SAAS,MAAS,QAAQ,MAAQ,QAAQ,MAAU,QAAQ,MAAQ,QAAQ;AACrF;;AAGA,SAAS,eAAe,MAAuB;CAC7C,OAAO,YAAY,IAAI,KAAM,QAAQ,MAAQ,QAAQ;AACvD;;;;;;;;;AChFA,MAAa,eAAuB;;AAGpC,SAAgB,cAAc,MAAuB;CACnD,OAAO,aAAa,KAAK,IAAI,KAAK,CAAC,KAAK,WAAW,IAAI;AACzD;;AAGA,MAAa,uCAA4C,IAAI,IAAI;CAAC;CAAQ;CAAS;AAAM,CAAC;;AAG1F,MAAa,kBAIT,OAAO,OAAO;CAAE,OAAO;CAAS,UAAU;CAAY,cAAc;AAAe,CAAC;;AAGxF,MAAa,oCAAyC,IAAI,IAAI;CAAC;CAAU;CAAO;CAAS;CAAW;AAAI,CAAC;;;;;;AAazG,MAAa,kCAA0D,IAAI,IAA+B;CACxG,CAAC,UAAU,CAAC,CAAC;CACb,CAAC,YAAY,EAAE,gBAAgB,gDAAgD,CAAC;CAChF,CAAC,QAAQ,CAAC,CAAC;AACb,CAAC;;AAGD,MAAa,6BAA6B"}
1
+ {"version":3,"file":"names-BlzDM5cF.mjs","names":[],"sources":["../src/metadata.ts","../src/type-ref.ts","../src/names.ts"],"sourcesContent":["/**\n * GraphQL section of the generated metadata (`__ZNIGHT_METADATA__.extensions.graphql`, RFC 0005\n * §7), produced by the `@znight/graphql/compiler` extension and consumed by `GraphQLPlugin`, which\n * validates it at boot (ZNIGHT066), because metadata can be hand-written.\n *\n * Data, not code, except `invoke` (one arrow per resolver) and the scalar implementations imported\n * from user code. The SDL printer (`sdl.ts`) reads the same shape without its functions.\n *\n * Import-free: types, type-only imports and one constant, shared by the compiler extension and the\n * runtime.\n */\nimport type { Token } from '@znight/core'\nimport type { HttpRouteGroupDefinition } from '@znight/http'\nimport type { GraphQLResolveInfo, GraphQLScalarType } from 'graphql'\nimport type { GraphQLArgs, GraphQLContext, ResolverContext, ScalarDefinition } from './types.ts'\n\n/** Format version of `metadata.extensions.graphql` (another version is ZNIGHT066 at boot). */\nexport const GRAPHQL_METADATA_VERSION = 1\n\n/** The schema of the application. The section is omitted when the application has no resolver. */\nexport interface GraphQLMetadata {\n /** {@link GRAPHQL_METADATA_VERSION}. */\n readonly version: number\n /** First 16 hexadecimal characters of the SHA-256 of the SDL (`printSdl`): logs, caches. */\n readonly schemaHash: string\n readonly roots: GraphQLRootTypes\n /** Every named type except the graphql-js specified scalars, sorted by name (code-unit order). */\n readonly types: readonly GraphQLTypeDefinition[]\n /**\n * Route decorator groups used on resolvers that must be known at runtime (required, or holding\n * several keys), by group name: the shape of `extensions.http.groups` (RFC 0001).\n */\n readonly groups?: Readonly<Record<string, HttpRouteGroupDefinition>>\n}\n\n/** Names of the root operation types (`Query`, `Mutation`, `Subscription`). */\nexport interface GraphQLRootTypes {\n readonly query: string\n readonly mutation?: string\n readonly subscription?: string\n}\n\n/** A named type of the schema. */\nexport type GraphQLTypeDefinition =\n | GraphQLObjectTypeDefinition\n | GraphQLInterfaceTypeDefinition\n | GraphQLInputTypeDefinition\n | GraphQLEnumTypeDefinition\n | GraphQLUnionTypeDefinition\n | GraphQLBuiltinScalarDefinition\n | GraphQLCustomScalarDefinition\n\n/** An object type: resolver return types, their fields, the root types. */\nexport interface GraphQLObjectTypeDefinition {\n readonly kind: 'object'\n readonly name: string\n readonly description?: string\n /** Interfaces the type implements (schema-first, RFC 0007), in declaration order. Absent: none. */\n readonly interfaces?: readonly string[]\n /** Declaration order (base members first), then field resolvers by resolver token and source order. */\n readonly fields: readonly GraphQLFieldDefinition[]\n}\n\n/**\n * An interface type (schema-first, RFC 0007; code-first emits none). Its fields have no\n * `resolver`: graphql-js resolves the fields of the concrete object type.\n */\nexport interface GraphQLInterfaceTypeDefinition {\n readonly kind: 'interface'\n readonly name: string\n readonly description?: string\n /** Interfaces the interface implements, in declaration order. Absent: none. */\n readonly interfaces?: readonly string[]\n readonly fields: readonly GraphQLFieldDefinition[]\n /** How the runtime tells the implementing object types apart (`resolveType`). */\n readonly discriminator: GraphQLDiscriminator\n}\n\n/** An input object type. */\nexport interface GraphQLInputTypeDefinition {\n readonly kind: 'input'\n readonly name: string\n readonly description?: string\n readonly fields: readonly GraphQLInputFieldDefinition[]\n}\n\n/** An enum: a TypeScript `enum`, or a named alias of a union of string literals. */\nexport interface GraphQLEnumTypeDefinition {\n readonly kind: 'enum'\n readonly name: string\n readonly description?: string\n /** Declaration order. */\n readonly values: readonly GraphQLEnumValueDefinition[]\n}\n\n/** A union of object types. */\nexport interface GraphQLUnionTypeDefinition {\n readonly kind: 'union'\n readonly name: string\n readonly description?: string\n /** Member type names, sorted. */\n readonly members: readonly string[]\n readonly discriminator: GraphQLDiscriminator\n}\n\n/** A scalar implemented by `@znight/graphql`: `DateTime`, `BigInt` or `JSON` (`names.ts`). */\nexport interface GraphQLBuiltinScalarDefinition {\n readonly kind: 'scalar'\n readonly name: string\n readonly description?: string\n readonly builtin: true\n}\n\n/** A scalar declared with `scalar<T>(name, definition)`: the definition is imported from user code. */\nexport interface GraphQLCustomScalarDefinition {\n readonly kind: 'scalar'\n readonly name: string\n /** Wins over the description of the definition (schema-first: the SDL's). */\n readonly description?: string\n /** Wins over the `specifiedByURL` of the definition (schema-first: the SDL's `@specifiedBy`). */\n readonly specifiedByURL?: string\n /**\n * Schema-first (RFC 0007): `description` and `specifiedByURL` are the SDL's and replace the\n * definition's, also when absent, so that the served schema is the SDL.\n */\n readonly sdl?: true\n /** `ScalarDefinition<T>` of any `T` (its methods are bivariant), or a graphql-js scalar named `name`. */\n readonly scalar: ScalarDefinition<unknown> | GraphQLScalarType\n}\n\n/** A field of an object type. */\nexport interface GraphQLFieldDefinition {\n readonly name: string\n /** Type reference (`'Book!'`, `'[Book!]!'`, `'Int'`), parsed by `type-ref.ts`. */\n readonly type: string\n readonly description?: string\n readonly deprecationReason?: string\n readonly args?: readonly GraphQLArgumentDefinition[]\n /** Absent: the graphql-js default resolver (`parent[name]`). */\n readonly resolver?: GraphQLResolverBinding\n}\n\n/** An argument of a field. */\nexport interface GraphQLArgumentDefinition {\n readonly name: string\n readonly type: string\n readonly description?: string\n readonly deprecationReason?: string\n /**\n * Default value, as an external value: JSON-compatible, enum values by GraphQL name (passed to\n * graphql-js as `default: { value }`). Absent: no default.\n */\n readonly defaultValue?: unknown\n /** The TypeScript type does not accept `null`: a `null` sent by the client becomes `undefined` (§5.4). */\n readonly nullAsUndefined?: true\n}\n\n/** A field of an input object type. */\nexport interface GraphQLInputFieldDefinition extends GraphQLArgumentDefinition {}\n\n/** A value of an enum. */\nexport interface GraphQLEnumValueDefinition {\n /** GraphQL name (the member name, or the literal). */\n readonly name: string\n /** Internal value (the member value, or the literal), what resolvers receive and return. */\n readonly value: string | number\n readonly description?: string\n readonly deprecationReason?: string\n}\n\n/** How the runtime tells the members of a union or the implementations of an interface apart (`resolveType`). */\nexport type GraphQLDiscriminator =\n | {\n readonly by: 'property'\n readonly property: string\n /** Literal value of the property (as a string) → member type name. */\n readonly values: Readonly<Record<string, string>>\n }\n | {\n readonly by: 'class'\n /** Member classes and their type names, subclasses first (`instanceof` order). */\n readonly classes: readonly (readonly [cls: abstract new (...args: never[]) => unknown, name: string])[]\n }\n | { readonly by: 'typename' }\n\n/** Kind of field a resolver method provides. */\nexport type GraphQLResolverOperation = 'query' | 'mutation' | 'subscription' | 'field'\n\n/** The resolver method behind a field. */\nexport interface GraphQLResolverBinding {\n /** Provider token of the resolver class. */\n readonly token: Token\n readonly method: string\n readonly operation: GraphQLResolverOperation\n /** Guard provider tokens: class `@UseGuard` guards, then method ones. */\n readonly guards: readonly Token[]\n /**\n * Effective field metadata (`createRouteDecorator` values, method decisions over class ones, one\n * decision per group). Empty: no metadata, so global guards skip a field resolver (§5.9).\n */\n readonly meta: Readonly<Record<string, unknown>>\n /** Informational: loader provider tokens the method injects. */\n readonly loaders?: readonly Token[]\n /**\n * The method has custom parameters (`createParamDecorator`, RFC 0010): the pipeline passes the\n * field's `ResolverContext` to `invoke` (`f`). Absent otherwise.\n */\n readonly context?: true\n /**\n * Provider classes resolving custom parameters (`ParamResolver`), in order of first use: the\n * pipeline resolves them in the operation scope and passes the instances to `invoke` (`x`).\n * Absent when there is none.\n */\n readonly paramResolvers?: readonly Token[]\n /**\n * Calls the method: maps the graphql-js arguments to the method parameters (§7.3). Synchronous\n * unless an argument is validated with a Standard Schema or a custom parameter resolver returns a\n * promise. `field` and `resolvers` are passed only to methods with custom parameters (declared as\n * a method so that a generated invoke requiring them is accepted).\n */\n invoke(\n // biome-ignore lint/suspicious/noExplicitAny: generated invokers receive the concrete resolver class\n resolver: any,\n parent: unknown,\n args: GraphQLArgs,\n context: GraphQLContext,\n info: GraphQLResolveInfo,\n field?: ResolverContext,\n // biome-ignore lint/suspicious/noExplicitAny: generated invokers receive the tuple of resolver classes\n resolvers?: any,\n ): unknown\n}\n\ndeclare module '@znight/core' {\n interface ZnightExtensionsMetadata {\n readonly graphql?: GraphQLMetadata\n }\n}\n","/**\n * GraphQL type references as written in `metadata.extensions.graphql` (`'Book!'`, `'[Book!]!'`,\n * `'[[Int]]'`): parsing and printing.\n *\n * Import-free: shared by the compiler extension (which prints them) and the runtime (which parses\n * them once, at boot, to build the schema). The grammar is the canonical form graphql-js prints\n * (`String(type)`): no whitespace, no comments, names matching `/^[_A-Za-z][_0-9A-Za-z]*$/`.\n */\n\n/** A parsed type reference. */\nexport type GraphQLTypeRef = NamedTypeRef | ListTypeRef\n\n/** A named type (`Book`, `Book!`). */\nexport interface NamedTypeRef {\n readonly kind: 'named'\n readonly name: string\n readonly nonNull: boolean\n}\n\n/** A list type (`[Book]`, `[Book!]!`). */\nexport interface ListTypeRef {\n readonly kind: 'list'\n /** The item type. */\n readonly of: GraphQLTypeRef\n readonly nonNull: boolean\n}\n\n/** Result of one parsing step: the reference and the index after it. */\ninterface Step {\n readonly ref: GraphQLTypeRef\n readonly end: number\n}\n\n/**\n * Parses a type reference. Returns `undefined` when `text` is not a canonical reference, so that\n * callers validating hand-written metadata can collect every problem before failing.\n */\nexport function parseTypeRef(text: string): GraphQLTypeRef | undefined {\n const step = parseAt(text, 0)\n return step !== undefined && step.end === text.length ? step.ref : undefined\n}\n\n/** Prints a type reference in its canonical form (the form graphql-js prints). */\nexport function printTypeRef(ref: GraphQLTypeRef): string {\n const inner = ref.kind === 'named' ? ref.name : `[${printTypeRef(ref.of)}]`\n return ref.nonNull ? `${inner}!` : inner\n}\n\n/** The innermost type name of a reference (`'[Book!]!'` → `'Book'`), `undefined` when malformed. */\nexport function namedTypeOf(ref: string | GraphQLTypeRef): string | undefined {\n let current = typeof ref === 'string' ? parseTypeRef(ref) : ref\n while (current !== undefined && current.kind === 'list') current = current.of\n return current?.name\n}\n\nconst OPEN_BRACKET = 0x5b // [\nconst CLOSE_BRACKET = 0x5d // ]\nconst BANG = 0x21 // !\n\nfunction parseAt(text: string, start: number): Step | undefined {\n let ref: GraphQLTypeRef\n let index: number\n if (text.charCodeAt(start) === OPEN_BRACKET) {\n const item = parseAt(text, start + 1)\n if (item === undefined || text.charCodeAt(item.end) !== CLOSE_BRACKET) return undefined\n index = item.end + 1\n ref = { kind: 'list', of: item.ref, nonNull: false }\n } else {\n index = start\n if (!isNameStart(text.charCodeAt(index))) return undefined\n index++\n while (isNameContinue(text.charCodeAt(index))) index++\n ref = { kind: 'named', name: text.slice(start, index), nonNull: false }\n }\n if (text.charCodeAt(index) === BANG) {\n return { ref: { ...ref, nonNull: true }, end: index + 1 }\n }\n return { ref, end: index }\n}\n\n/** `[_A-Za-z]`. `NaN` (past the end) is never a name character. */\nfunction isNameStart(code: number): boolean {\n return code === 0x5f || (code >= 0x41 && code <= 0x5a) || (code >= 0x61 && code <= 0x7a)\n}\n\n/** `[_0-9A-Za-z]`. */\nfunction isNameContinue(code: number): boolean {\n return isNameStart(code) || (code >= 0x30 && code <= 0x39)\n}\n","/**\n * GraphQL naming rules and built-in types (RFC 0005 §5.7, §6.4).\n *\n * Import-free: shared by the compiler extension (naming diagnostics, ZNIGHT061) and the runtime\n * (structural validation of `metadata.extensions.graphql` and the built-in scalars, ZNIGHT066).\n */\n\n/** Grammar of a GraphQL name (types, fields, arguments, enum values). */\nexport const GRAPHQL_NAME: RegExp = /^[_A-Za-z][_0-9A-Za-z]*$/\n\n/** `true` when `name` is a GraphQL name that user types may take (not reserved with `__`). */\nexport function isGraphQLName(name: string): boolean {\n return GRAPHQL_NAME.test(name) && !name.startsWith('__')\n}\n\n/** Names an enum value may not take (GraphQL spec §3.9). */\nexport const RESERVED_ENUM_VALUES: ReadonlySet<string> = new Set(['true', 'false', 'null'])\n\n/** Names of the root operation types; user types may not take them (ZNIGHT061). */\nexport const ROOT_TYPE_NAMES: {\n readonly query: 'Query'\n readonly mutation: 'Mutation'\n readonly subscription: 'Subscription'\n} = Object.freeze({ query: 'Query', mutation: 'Mutation', subscription: 'Subscription' })\n\n/** Scalars of the GraphQL specification: always present, never declared in the metadata nor printed. */\nexport const SPECIFIED_SCALARS: ReadonlySet<string> = new Set(['String', 'Int', 'Float', 'Boolean', 'ID'])\n\n/** A scalar `@znight/graphql` implements itself (`kind: 'scalar', builtin: true` in the metadata). */\nexport interface BuiltinScalarInfo {\n /** `@specifiedBy(url:)`. Absent: none. */\n readonly specifiedByURL?: string\n}\n\n/**\n * The scalars `@znight/graphql` implements (§5.7): `DateTime` (`Date`), `BigInt` (`bigint`) and\n * `JSON` (`JSONValue`). They have no description. The runtime builds them with exactly these\n * properties and without `valueToLiteral`, so that graphql-js `printSchema` and `printSdl()` agree.\n */\nexport const BUILTIN_SCALARS: ReadonlyMap<string, BuiltinScalarInfo> = new Map<string, BuiltinScalarInfo>([\n ['BigInt', {}],\n ['DateTime', { specifiedByURL: 'https://datatracker.ietf.org/doc/html/rfc3339' }],\n ['JSON', {}],\n])\n\n/** The default `@deprecated` reason of graphql-js: printed as a bare `@deprecated`. */\nexport const DEFAULT_DEPRECATION_REASON = 'No longer supported'\n"],"mappings":";;AAiBA,MAAa,2BAA2B;;;;;;ACoBxC,SAAgB,aAAa,MAA0C;CACrE,MAAM,OAAO,QAAQ,MAAM,CAAC;CAC5B,OAAO,SAAS,KAAA,KAAa,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,KAAA;AACrE;;AAGA,SAAgB,aAAa,KAA6B;CACxD,MAAM,QAAQ,IAAI,SAAS,UAAU,IAAI,OAAO,IAAI,aAAa,IAAI,EAAE,EAAE;CACzE,OAAO,IAAI,UAAU,GAAG,MAAM,KAAK;AACrC;AASA,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,OAAO;AAEb,SAAS,QAAQ,MAAc,OAAiC;CAC9D,IAAI;CACJ,IAAI;CACJ,IAAI,KAAK,WAAW,KAAK,MAAM,cAAc;EAC3C,MAAM,OAAO,QAAQ,MAAM,QAAQ,CAAC;EACpC,IAAI,SAAS,KAAA,KAAa,KAAK,WAAW,KAAK,GAAG,MAAM,eAAe,OAAO,KAAA;EAC9E,QAAQ,KAAK,MAAM;EACnB,MAAM;GAAE,MAAM;GAAQ,IAAI,KAAK;GAAK,SAAS;EAAM;CACrD,OAAO;EACL,QAAQ;EACR,IAAI,CAAC,YAAY,KAAK,WAAW,KAAK,CAAC,GAAG,OAAO,KAAA;EACjD;EACA,OAAO,eAAe,KAAK,WAAW,KAAK,CAAC,GAAG;EAC/C,MAAM;GAAE,MAAM;GAAS,MAAM,KAAK,MAAM,OAAO,KAAK;GAAG,SAAS;EAAM;CACxE;CACA,IAAI,KAAK,WAAW,KAAK,MAAM,MAC7B,OAAO;EAAE,KAAK;GAAE,GAAG;GAAK,SAAS;EAAK;EAAG,KAAK,QAAQ;CAAE;CAE1D,OAAO;EAAE;EAAK,KAAK;CAAM;AAC3B;;AAGA,SAAS,YAAY,MAAuB;CAC1C,OAAO,SAAS,MAAS,QAAQ,MAAQ,QAAQ,MAAU,QAAQ,MAAQ,QAAQ;AACrF;;AAGA,SAAS,eAAe,MAAuB;CAC7C,OAAO,YAAY,IAAI,KAAM,QAAQ,MAAQ,QAAQ;AACvD;;;;;;;;;AChFA,MAAa,eAAuB;;AAGpC,SAAgB,cAAc,MAAuB;CACnD,OAAO,aAAa,KAAK,IAAI,KAAK,CAAC,KAAK,WAAW,IAAI;AACzD;;AAGA,MAAa,uCAA4C,IAAI,IAAI;CAAC;CAAQ;CAAS;AAAM,CAAC;;AAG1F,MAAa,kBAIT,OAAO,OAAO;CAAE,OAAO;CAAS,UAAU;CAAY,cAAc;AAAe,CAAC;;AAGxF,MAAa,oCAAyC,IAAI,IAAI;CAAC;CAAU;CAAO;CAAS;CAAW;AAAI,CAAC;;;;;;AAazG,MAAa,kCAA0D,IAAI,IAA+B;CACxG,CAAC,UAAU,CAAC,CAAC;CACb,CAAC,YAAY,EAAE,gBAAgB,gDAAgD,CAAC;CAChF,CAAC,QAAQ,CAAC,CAAC;AACb,CAAC;;AAGD,MAAa,6BAA6B"}