import type { GqlRegistry } from '../registry/GqlRegistry.js'; import type { GqlOperation } from '../operation/GqlOperation.js'; import type { GqlRootTypes } from '../rootType/GqlRootTypes.js'; import type { OasInfo } from '../../oas/info/Info.js'; import type { StackTrail } from '../../context/StackTrail.js'; /** * Fields used to construct (or populate) a {@link GqlDocument}. */ export type GqlDocumentFields = { /** Type registry containing all named GraphQL types as OAS schema objects. */ registry: GqlRegistry; /** Root-level fields exposed as Query, Mutation, or Subscription. */ operations: GqlOperation[]; /** Names of the root operation types (Query, Mutation, Subscription). */ rootTypes: GqlRootTypes; /** Schema-level metadata (title, version, description). Optional. */ info?: OasInfo; }; /** * Top-level container for a parsed GraphQL schema. * * `GqlDocument` is the GraphQL counterpart to {@link OasDocument}. It owns * a {@link GqlRegistry} (the named-type registry, parallel to * `OasComponents.schemas`), the list of root-level fields exposed as * {@link GqlOperation} entries, and pointers to the schema's root operation * types. * * Both documents are wrapped by {@link SkmtcParsedDocument} so the pipeline * can carry either through the same generate phase. * * ## Empty-at-construction * * Like {@link OasDocument}, `GqlDocument` is intentionally constructable * without fields — the parser creates an empty instance up front, hands * out `OasRef`s that resolve through it, then populates * `gqlDocument.fields = { ... }` at the end of parsing. See the * "forward-declared refs" section on {@link OasDocument} for the full * rationale; the short version is that refs need a stable resolution * target *before* every target has been parsed, so the document and the * refs that point at it must both be constructable up front and tied to * the same instance. */ export declare class GqlDocument { #private; readonly oasType: "gqlDocument"; /** * Creates a new GqlDocument instance. * * The document is typically created without fields and populated later * during parsing. See the class-level docstring for why. */ constructor(fields?: GqlDocumentFields); /** * Populates the document's fields after parsing. */ set fields(fields: GqlDocumentFields); /** Named-type registry. */ get registry(): GqlRegistry; /** Root-field operations. */ get operations(): GqlOperation[]; /** Pointers to the schema's root operation types. */ get rootTypes(): GqlRootTypes; /** Optional schema-level metadata. */ get info(): OasInfo | undefined; /** * Removes the consumer addressed by `stackTrail`. Parallel to * {@link OasDocument.removeItem}; used by * `ParseContext.removeErroredItems` to prune references whose target * type failed to parse. * * Two consumer shapes are handled today: * * - `[, , …]` where `` matches one of * `rootTypes.{query,mutation,subscription}` → the matching * {@link GqlOperation} is removed from `operations`. * - `[, , …]` where `` is a * registered object/input/interface → the named field is deleted * from the parent's properties (and from its `required` list if * present). The deeper segments of the stack trail are ignored, * matching `OasDocument.removeItem`'s coarse-grained behavior. * - `[, members, ]` where `` is a * registered union or interface union → the indexed member is * removed. * * Returns the removed entity (`GqlOperation`, the removed property * schema, or the removed union member) when removal happened, or * `undefined` if no matching consumer was found. The return value * acts as the truthy signal `removeErroredItems` uses to decide * whether to emit an `INVALID_DEPENDENCY_REF` issue. */ removeItem(stackTrail: StackTrail): unknown; }