@znight/graphql 0.2.0 → 0.2.2

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.
Files changed (42) hide show
  1. package/README.md +307 -11
  2. package/dist/compiler.d.mts +24 -3
  3. package/dist/compiler.mjs +1876 -109
  4. package/dist/compiler.mjs.map +1 -1
  5. package/dist/index.d.mts +49 -8
  6. package/dist/index.mjs +10 -4
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/names-BlzDM5cF.mjs.map +1 -1
  9. package/dist/{plugin-BdBxr5NQ.mjs → plugin-CR_wVfRU.mjs} +247 -24
  10. package/dist/plugin-CR_wVfRU.mjs.map +1 -0
  11. package/dist/testing.d.mts +1 -1
  12. package/dist/testing.mjs +1 -1
  13. package/dist/{types-CgbV9LjD.d.mts → types-DQ713UgI.d.mts} +34 -2
  14. package/package.json +14 -9
  15. package/src/compiler/analyze.ts +129 -10
  16. package/src/compiler/builder.ts +6 -85
  17. package/src/compiler/checks.ts +105 -0
  18. package/src/compiler/conformance.ts +1068 -0
  19. package/src/compiler/constants.ts +6 -0
  20. package/src/compiler/data.ts +10 -0
  21. package/src/compiler/generate.ts +41 -27
  22. package/src/compiler/graphql-js.ts +42 -0
  23. package/src/compiler/index.ts +8 -3
  24. package/src/compiler/locate.ts +39 -1
  25. package/src/compiler/model.ts +16 -1
  26. package/src/compiler/options.ts +39 -8
  27. package/src/compiler/schema-first.ts +595 -0
  28. package/src/compiler/sdl-source.ts +529 -0
  29. package/src/compiler/sdl-view.ts +3 -1
  30. package/src/compiler/suggest.ts +39 -0
  31. package/src/decorators.ts +9 -3
  32. package/src/index.ts +5 -0
  33. package/src/metadata.ts +28 -1
  34. package/src/options.ts +23 -1
  35. package/src/pipeline.ts +66 -5
  36. package/src/plugin.ts +27 -5
  37. package/src/results.ts +206 -0
  38. package/src/scalars.ts +10 -3
  39. package/src/schema.ts +90 -12
  40. package/src/sdl.ts +17 -2
  41. package/src/types.ts +35 -0
  42. package/dist/plugin-BdBxr5NQ.mjs.map +0 -1
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as GraphQLErrorCode, a as GraphQLContext, b as GraphQLExceptionOptions, c as GraphQLGuard, d as GraphQLTransport, f as LoaderKey, g as ScalarDefinition, h as ResolverContext, i as GraphQLArgs, l as GraphQLGuardClass, m as LoaderValue, n as BatchLoadClass, o as GraphQLErrorMapper, p as LoaderOptions, r as BatchLoader, s as GraphQLErrorMapperClass, t as BatchLoad, u as GraphQLOperationKind, v as GraphQLErrorCodeValue, y as GraphQLException } from "./types-CgbV9LjD.mjs";
1
+ import { C as GraphQLExceptionOptions, S as GraphQLException, _ as LoaderValue, a as GraphQLContext, b as GraphQLErrorCode, c as GraphQLGuard, d as GraphQLResultMapper, f as GraphQLResultMapperClass, g as LoaderOptions, h as LoaderKey, i as GraphQLArgs, l as GraphQLGuardClass, m as GraphQLTransport, n as BatchLoadClass, o as GraphQLErrorMapper, p as GraphQLResultTypes, r as BatchLoader, s as GraphQLErrorMapperClass, t as BatchLoad, u as GraphQLOperationKind, v as ResolverContext, x as GraphQLErrorCodeValue, y as ScalarDefinition } from "./types-DQ713UgI.mjs";
2
2
  import { ClassMarker, MethodMarker, ParameterMarker, Plugin, PluginContext, PluginOptions, PluginRootsContext, ProviderKey, Scope, Token, TypedToken, ZnightError } from "@znight/core";
3
3
  import { ByteSize, GuardRef, HttpContext, HttpRouteGroupDefinition, InferSchemaOutput, PluginHttpRoutes, PluginHttpRoutesContext, PluginRoute, RouteMetaEntry, StandardSchemaV1, StandardSchemaV1 as StandardSchemaV1$1 } from "@znight/http";
4
4
  import { DocumentNode, FormattedExecutionResult, GraphQLError, GraphQLFormattedError, GraphQLResolveInfo, GraphQLScalarType, GraphQLSchema } from "graphql";
@@ -34,6 +34,10 @@ interface ResolverOptions {
34
34
  * `@Subscription` and `@ResolveField` methods are fields of the schema. Route decorators of
35
35
  * `@znight/http` (`createRouteDecorator`) on the class are the default decisions of its fields.
36
36
  *
37
+ * Schema-first (RFC 0007): `@Resolver('Event')` names the SDL object type its `@ResolveField`
38
+ * methods resolve fields of (`@Resolver('Event', { scope })` with options). Code-first rejects a
39
+ * type name (ZNIGHT005): the type is the one of the `@Parent()` parameter.
40
+ *
37
41
  * ```ts
38
42
  * @Resolver()
39
43
  * export class BookResolver {
@@ -46,9 +50,10 @@ interface ResolverOptions {
46
50
  * }
47
51
  * ```
48
52
  *
49
- * @param options static: `{ scope? }`.
53
+ * @param typeOrOptions static: the SDL type name (schema-first), or `{ scope? }`.
54
+ * @param options static: `{ scope? }`, after a type name.
50
55
  */
51
- export declare function Resolver(_options?: ResolverOptions): ClassMarker;
56
+ export declare function Resolver(_typeOrOptions?: string | ResolverOptions, _options?: ResolverOptions): ClassMarker;
52
57
  /**
53
58
  * A field of the `Query` root type. The method's declared return type is the field type
54
59
  * (`Promise<T>` unwrapped), its `@Args` the arguments, its JSDoc the description.
@@ -71,7 +76,8 @@ export declare function Mutation(_name?: string): MethodMarker;
71
76
  export declare function Subscription(_name?: string): MethodMarker;
72
77
  /**
73
78
  * A field resolver: adds a field to the type of the `@Parent()` parameter (mandatory), or replaces
74
- * the property field of the same name.
79
+ * the property field of the same name. Schema-first (RFC 0007): resolves the field of the type named
80
+ * by `@Resolver('Type')`, `@Parent()` optional.
75
81
  *
76
82
  * @param name static: field name. Default: the method name.
77
83
  */
@@ -207,6 +213,11 @@ interface AnyPubSub {
207
213
  type GraphQLGuardRef = GraphQLGuardClass | GraphQLGuard;
208
214
  /** An error mapper: a provider class or an instance. */
209
215
  type GraphQLErrorMapperRef = GraphQLErrorMapperClass | GraphQLErrorMapper;
216
+ /**
217
+ * A result mapper: a provider class with `static types`, or an instance (its `types` property, or the
218
+ * `static types` of its class).
219
+ */
220
+ type GraphQLResultMapperRef = GraphQLResultMapperClass | (GraphQLResultMapper & Partial<GraphQLResultTypes>);
210
221
  /** Options of the GraphQL-over-HTTP endpoint. */
211
222
  interface GraphQLHttpOptions {
212
223
  /** Route metadata of the endpoint (`[Public.meta()]`), seen by HTTP guards and the route decision check. */
@@ -253,6 +264,11 @@ interface GraphQLPluginOptions {
253
264
  readonly guards?: readonly GraphQLGuardRef[];
254
265
  /** Error mappers (classes or instances), tried in order. */
255
266
  readonly errorMappers?: readonly GraphQLErrorMapperRef[];
267
+ /**
268
+ * Result mappers (classes or instances), tried in order: errors as data (RFC 0008), on the fields
269
+ * whose union holds one of their `types`.
270
+ */
271
+ readonly resultMappers?: readonly GraphQLResultMapperRef[];
256
272
  /** Unmasked messages for unexpected errors (development). Default `false`. */
257
273
  readonly exposeErrors?: boolean;
258
274
  /** Introspection; off, suggestions are hidden too. Default `NODE_ENV !== 'production'`. */
@@ -322,15 +338,31 @@ interface GraphQLRootTypes {
322
338
  readonly subscription?: string;
323
339
  }
324
340
  /** A named type of the schema. */
325
- type GraphQLTypeDefinition = GraphQLObjectTypeDefinition | GraphQLInputTypeDefinition | GraphQLEnumTypeDefinition | GraphQLUnionTypeDefinition | GraphQLBuiltinScalarDefinition | GraphQLCustomScalarDefinition;
341
+ type GraphQLTypeDefinition = GraphQLObjectTypeDefinition | GraphQLInterfaceTypeDefinition | GraphQLInputTypeDefinition | GraphQLEnumTypeDefinition | GraphQLUnionTypeDefinition | GraphQLBuiltinScalarDefinition | GraphQLCustomScalarDefinition;
326
342
  /** An object type: resolver return types, their fields, the root types. */
327
343
  interface GraphQLObjectTypeDefinition {
328
344
  readonly kind: "object";
329
345
  readonly name: string;
330
346
  readonly description?: string;
347
+ /** Interfaces the type implements (schema-first, RFC 0007), in declaration order. Absent: none. */
348
+ readonly interfaces?: readonly string[];
331
349
  /** Declaration order (base members first), then field resolvers by resolver token and source order. */
332
350
  readonly fields: readonly GraphQLFieldDefinition[];
333
351
  }
352
+ /**
353
+ * An interface type (schema-first, RFC 0007; code-first emits none). Its fields have no
354
+ * `resolver`: graphql-js resolves the fields of the concrete object type.
355
+ */
356
+ interface GraphQLInterfaceTypeDefinition {
357
+ readonly kind: "interface";
358
+ readonly name: string;
359
+ readonly description?: string;
360
+ /** Interfaces the interface implements, in declaration order. Absent: none. */
361
+ readonly interfaces?: readonly string[];
362
+ readonly fields: readonly GraphQLFieldDefinition[];
363
+ /** How the runtime tells the implementing object types apart (`resolveType`). */
364
+ readonly discriminator: GraphQLDiscriminator;
365
+ }
334
366
  /** An input object type. */
335
367
  interface GraphQLInputTypeDefinition {
336
368
  readonly kind: "input";
@@ -366,6 +398,15 @@ interface GraphQLBuiltinScalarDefinition {
366
398
  interface GraphQLCustomScalarDefinition {
367
399
  readonly kind: "scalar";
368
400
  readonly name: string;
401
+ /** Wins over the description of the definition (schema-first: the SDL's). */
402
+ readonly description?: string;
403
+ /** Wins over the `specifiedByURL` of the definition (schema-first: the SDL's `@specifiedBy`). */
404
+ readonly specifiedByURL?: string;
405
+ /**
406
+ * Schema-first (RFC 0007): `description` and `specifiedByURL` are the SDL's and replace the
407
+ * definition's, also when absent, so that the served schema is the SDL.
408
+ */
409
+ readonly sdl?: true;
369
410
  /** `ScalarDefinition<T>` of any `T` (its methods are bivariant), or a graphql-js scalar named `name`. */
370
411
  readonly scalar: ScalarDefinition<unknown> | GraphQLScalarType;
371
412
  }
@@ -405,7 +446,7 @@ interface GraphQLEnumValueDefinition {
405
446
  readonly description?: string;
406
447
  readonly deprecationReason?: string;
407
448
  }
408
- /** How the runtime tells the members of a union apart (`resolveType`). */
449
+ /** How the runtime tells the members of a union or the implementations of an interface apart (`resolveType`). */
409
450
  type GraphQLDiscriminator = {
410
451
  readonly by: "property";
411
452
  readonly property: string;
@@ -475,7 +516,7 @@ export declare class GraphQLPlugin implements Plugin, PluginHttpRoutes {
475
516
  */
476
517
  static configure(options?: PluginOptions<GraphQLPluginOptions>): GraphQLPlugin;
477
518
  /**
478
- * Providers `TestApp` creates at boot: the classes of the `guards` and `errorMappers` options, and
519
+ * Providers `TestApp` creates at boot: the classes of the `guards`, `errorMappers` and `resultMappers` options, and
479
520
  * the resolvers, guards and loaders of the metadata.
480
521
  */
481
522
  initRoots(context?: PluginRootsContext): readonly ProviderKey[];
@@ -538,5 +579,5 @@ export declare const GraphQLTokens: {
538
579
  * @throws TypeError when `schema` is not a Standard Schema v1 (a programming error, masked).
539
580
  */
540
581
  export declare function validateArgs<S extends StandardSchemaV1$1>(schema: S, value: unknown, label: string): InferSchemaOutput<S> | Promise<InferSchemaOutput<S>>;
541
- export { type AnyPubSub, type BatchLoad, type BatchLoadClass, type BatchLoader, type DirectExecuteOptions, type Float, type GraphQLArgs, type GraphQLArgumentDefinition, type GraphQLBuiltinScalarDefinition, type GraphQLContext, type GraphQLCustomScalarDefinition, type GraphQLDiscriminator, type GraphQLEnumTypeDefinition, type GraphQLEnumValueDefinition, GraphQLErrorCode, type GraphQLErrorCodeValue, type GraphQLErrorMapper, type GraphQLErrorMapperClass, type GraphQLErrorMapperRef, GraphQLException, type GraphQLExceptionOptions, type GraphQLFieldDefinition, type GraphQLGuard, type GraphQLGuardClass, type GraphQLGuardRef, type GraphQLHttpOptions, type GraphQLInputFieldDefinition, type GraphQLInputTypeDefinition, type GraphQLLimits, type GraphQLMetadata, type GraphQLObjectTypeDefinition, type GraphQLOperationKind, type GraphQLPluginOptions, type GraphQLRequest, type GraphQLResolverBinding, type GraphQLResolverOperation, type GraphQLResultStream, type GraphQLRootTypes, type GraphQLSubscriptionOptions, type GraphQLTransport, type GraphQLTypeDefinition, type GraphQLUnionTypeDefinition, type ID, type Int, type JSONValue, type LoaderKey, type LoaderOptions, type LoaderValue, type MaybePromise, type MemoryPubSubOptions, type OrderByKeysOptions, type ResolverContext, type ResolverOptions, type ScalarDefinition, type StandardSchemaV1, type SubscribeOptions };
582
+ export { type AnyPubSub, type BatchLoad, type BatchLoadClass, type BatchLoader, type DirectExecuteOptions, type Float, type GraphQLArgs, type GraphQLArgumentDefinition, type GraphQLBuiltinScalarDefinition, type GraphQLContext, type GraphQLCustomScalarDefinition, type GraphQLDiscriminator, type GraphQLEnumTypeDefinition, type GraphQLEnumValueDefinition, GraphQLErrorCode, type GraphQLErrorCodeValue, type GraphQLErrorMapper, type GraphQLErrorMapperClass, type GraphQLErrorMapperRef, GraphQLException, type GraphQLExceptionOptions, type GraphQLFieldDefinition, type GraphQLGuard, type GraphQLGuardClass, type GraphQLGuardRef, type GraphQLHttpOptions, type GraphQLInputFieldDefinition, type GraphQLInputTypeDefinition, type GraphQLInterfaceTypeDefinition, type GraphQLLimits, type GraphQLMetadata, type GraphQLObjectTypeDefinition, type GraphQLOperationKind, type GraphQLPluginOptions, type GraphQLRequest, type GraphQLResolverBinding, type GraphQLResolverOperation, type GraphQLResultMapper, type GraphQLResultMapperClass, type GraphQLResultMapperRef, type GraphQLResultStream, type GraphQLResultTypes, type GraphQLRootTypes, type GraphQLSubscriptionOptions, type GraphQLTransport, type GraphQLTypeDefinition, type GraphQLUnionTypeDefinition, type ID, type Int, type JSONValue, type LoaderKey, type LoaderOptions, type LoaderValue, type MaybePromise, type MemoryPubSubOptions, type OrderByKeysOptions, type ResolverContext, type ResolverOptions, type ScalarDefinition, type StandardSchemaV1, type SubscribeOptions };
542
583
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as MemoryPubSub, c as GraphQLErrorCode, i as GraphQLTokens, l as GraphQLException, o as PubSub, s as orderByKeys, t as GraphQLPlugin } from "./plugin-BdBxr5NQ.mjs";
1
+ import { a as MemoryPubSub, c as GraphQLErrorCode, i as GraphQLTokens, l as GraphQLException, o as PubSub, s as orderByKeys, t as GraphQLPlugin } from "./plugin-CR_wVfRU.mjs";
2
2
  import { l as GRAPHQL_METADATA_VERSION } from "./names-BlzDM5cF.mjs";
3
3
  import { isThenable, toIssueDetail } from "@znight/http";
4
4
  // src/decorators.ts
@@ -12,6 +12,10 @@ const classOrMethodMarker = marker;
12
12
  * `@Subscription` and `@ResolveField` methods are fields of the schema. Route decorators of
13
13
  * `@znight/http` (`createRouteDecorator`) on the class are the default decisions of its fields.
14
14
  *
15
+ * Schema-first (RFC 0007): `@Resolver('Event')` names the SDL object type its `@ResolveField`
16
+ * methods resolve fields of (`@Resolver('Event', { scope })` with options). Code-first rejects a
17
+ * type name (ZNIGHT005): the type is the one of the `@Parent()` parameter.
18
+ *
15
19
  * ```ts
16
20
  * @Resolver()
17
21
  * export class BookResolver {
@@ -24,9 +28,10 @@ const classOrMethodMarker = marker;
24
28
  * }
25
29
  * ```
26
30
  *
27
- * @param options static: `{ scope? }`.
31
+ * @param typeOrOptions static: the SDL type name (schema-first), or `{ scope? }`.
32
+ * @param options static: `{ scope? }`, after a type name.
28
33
  */
29
- function Resolver(_options) {
34
+ function Resolver(_typeOrOptions, _options) {
30
35
  return classMarker;
31
36
  }
32
37
  /**
@@ -57,7 +62,8 @@ function Subscription(_name) {
57
62
  }
58
63
  /**
59
64
  * A field resolver: adds a field to the type of the `@Parent()` parameter (mandatory), or replaces
60
- * the property field of the same name.
65
+ * the property field of the same name. Schema-first (RFC 0007): resolves the field of the type named
66
+ * by `@Resolver('Type')`, `@Parent()` optional.
61
67
  *
62
68
  * @param name static: field name. Default: the method name.
63
69
  */
@@ -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 * ```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 options static: `{ scope? }`.\n */\nexport function Resolver(_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.\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;;;;;;;;;;;;;;;;;;;;AAoDxD,SAAgB,SAAS,UAAyC;CAChE,OAAO;AACT;;;;;;;AAQA,SAAgB,MAAM,OAA8B;CAClD,OAAO;AACT;;;;;;AAOA,SAAgB,SAAS,OAA8B;CACrD,OAAO;AACT;;;;;;;AAQA,SAAgB,aAAa,OAA8B;CACzD,OAAO;AACT;;;;;;;AAQA,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;;;;;;;;;;;;;;;AC5KA,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 | 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 /** Declaration order (base members first), then field resolvers by resolver token and source order. */\n readonly fields: readonly GraphQLFieldDefinition[]\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 /** `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 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, 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"}