import type { Model, ModelProperty, Namespace, Operation, Program, Type } from "@typespec/compiler"; import { type ResolvableByManifestEntry } from "./joins.js"; /** * Discovery + resolution for `@restResolver` operations (issue #134). This is * the REST counterpart of the model walk in emitter.ts: it collects every * operation carrying `@restResolver` and resolves its HTTP metadata (verb, * route, path/query params, body, return type) via `@typespec/http`. * Deliberately a separate module — the OpenSearch path stays untouched. */ export type RestGraphQLTypeName = "Query" | "Mutation"; export interface RestPathParam { name: string; /** Source ModelProperty — used by the SDL emitter for arg typing. */ property?: ModelProperty; } export interface RestQueryParam { name: string; optional: boolean; /** The parameter is array-typed, so it serializes to more than one value. */ array: boolean; /** * RFC-6570 explode, as resolved by `@typespec/http`. An exploded array * repeats the key (`?s=a&s=b`); a non-exploded one joins on a comma. */ explode: boolean; /** Source ModelProperty — used by the SDL emitter for arg typing. */ property?: ModelProperty; } /** * The renderer-facing shape: plain data, no compiler types. Everything * emit-rest-resolver.ts needs to render a request/response template. */ export interface RestOperationShape { /** Operation name verbatim — becomes the GraphQL field name. */ fieldName: string; /** "Query" for GET, "Mutation" for POST/PUT/PATCH/DELETE. */ typeName: RestGraphQLTypeName; /** Upper-cased HTTP verb, e.g. "GET". */ httpMethod: string; /** Resolved route path with `{param}` placeholders, e.g. "/pets/{petId}". */ path: string; pathParams: RestPathParam[]; queryParams: RestQueryParam[]; /** Name of the `@body` parameter (the GraphQL `input` arg), if present. */ bodyParamName?: string; } export interface ResolvedRestOperation extends RestOperationShape { operation: Operation; /** The `@body` model, when the operation declares one. */ bodyModel?: Model; /** The operation's declared return type. */ returnType: Type; /** * Set when the operation reads a model carrying `@resolvableBy` — the read * a cross-domain join runs against (issue #194). */ resolvableBy?: ResolvableByManifestEntry; } export declare function collectRestOperations(program: Program, namespace: Namespace): Operation[]; export declare function toRestGraphQLTypeName(verb: string): RestGraphQLTypeName; export declare function resolveRestOperation(program: Program, operation: Operation): ResolvedRestOperation; //# sourceMappingURL=rest-operations.d.ts.map