import type { Enum, Model, ModelProperty, Program, Type } from "@typespec/compiler"; import type { ResolvedRestOperation } from "./rest-operations.js"; /** * GraphQL SDL codegen for `@restResolver` operations (issue #134). GET * operations become `type Query` fields, the other verbs become * `type Mutation` fields. `@path` params are required args, `@query` params * follow their TypeSpec optionality, a `@body` model becomes a generated * GraphQL `input` type. Scalar mapping is shared with the OpenSearch SDL * path (graphql-types.ts). * * Operations are grouped per return model — both `getPet` and `createPet` * returning `Pet` land in `pet.graphql` together with the types they need. */ export interface EmittedRestSdlFile { fileName: string; content: string; } /** Manifest `sdlFile` for an operation — the file its group renders into. */ export declare function restSdlFileName(op: ResolvedRestOperation): string; export interface EmitRestSdlOptions { /** * When set, all operations collapse into one file with this name and a * shared type registry. Manifest entries all point at this file. Issue #142. */ sdlFileName?: string; } export declare function emitRestSdl(program: Program, operations: ResolvedRestOperation[], options?: EmitRestSdlOptions): EmittedRestSdlFile[]; /** Group key: the (unwrapped) return model name, falling back to the field name. */ declare function groupName(op: ResolvedRestOperation): string; /** * Distinct GraphQL type name for a model. Plain (non-template) models keep * their bare name, unchanged from before — this is what keeps default output * byte-identical. A template instantiation (e.g. `ResultList`) * shares its template's `.name` ("ResultList") across every instantiation, so * without this every `ResultList` collapsed onto one GraphQL type and * silently kept whichever `T` registered first (issue #148). When every * template argument is itself a named model, the instantiation is * disambiguated as `...` (`TaskDefinitionResultList`); * anything else (unresolvable/unnamed args) falls back to the bare name. */ declare function restModelName(model: Model): string; interface TypeRegistry { objects: Map; inputs: Map; enums: Map; } declare function renderGroup(program: Program, operations: ResolvedRestOperation[]): string; declare function renderField(program: Program, op: ResolvedRestOperation, registry: TypeRegistry): string; /** * Property-aware type reference: `@graphqlId` (issue #136) is an opt-in on * the ModelProperty, so it can only be honored where the property is known — * operation args and object/input fields. Undecorated properties defer to * restTypeRef unchanged, keeping default output byte-identical. */ declare function restPropertyRef(program: Program, property: ModelProperty, registry: TypeRegistry, position: "object" | "input"): string; /** * Type reference for REST SDL: named models and enums become named GraphQL * types registered for emission (object or input position); everything else * defers to the shared scalar mapping. */ declare function restTypeRef(program: Program, type: Type, registry: TypeRegistry, position: "object" | "input"): string; export declare const __test: { groupName: typeof groupName; renderGroup: typeof renderGroup; renderField: typeof renderField; restPropertyRef: typeof restPropertyRef; restTypeRef: typeof restTypeRef; restModelName: typeof restModelName; }; export {}; //# sourceMappingURL=emit-rest-sdl.d.ts.map