api-invoke 0.1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/types.ts","../src/core/errors.ts","../src/adapters/graphql/introspection.ts","../src/adapters/graphql/query-builder.ts","../src/adapters/graphql/parser.ts"],"names":[],"mappings":";AAWO,IAAM,UAAA,GAAa;AAAA,EACxB,GAAA,EAAK,KAAA;AAAA,EACL,IAAA,EAAM,MAAA;AAAA,EACN,GAAA,EAAK,KAAA;AAAA,EACL,KAAA,EAAO,OAAA;AAAA,EACP,MAAA,EAAQ,QAAA;AAAA,EACR,IAAA,EAAM,MAAA;AAAA,EACN,OAAA,EAAS;AACX;AAIO,IAAM,aAAA,GAAgB;AAAA,EAC3B,IAAA,EAAM,MAAA;AAAA,EACN,KAAA,EAAO,OAAA;AAAA,EACP,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ;AACV;AAIO,IAAM,QAAA,GAAW;AAAA,EACtB,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,OAAA;AAAA,EACP,OAAA,EAAS,QAAA;AAAA,EACT,WAAA,EAAa,YAAA;AAAA,EACb,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ;AACV;AAIO,IAAM,UAAA,GAAa;AAAA,EACxB,SAAA,EAAW,WAAA;AAAA,EACX,SAAA,EAAW,WAAA;AAAA,EACX,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,OAAA,EAAS;AACX;AAIO,IAAM,UAAA,GAAa;AAAA,EACxB,MAAA,EAAQ,QAAA;AAAA,EACR,aAAA,EAAe,eAAA;AAAA,EACf,YAAA,EAAc,cAAA;AAAA,EACd,MAAA,EAAQ;AACV;AAwGO,IAAM,WAAA,GAAc;AAAA,EACzB,IAAA,EAAM,kBAAA;AAAA,EACN,eAAA,EAAiB,mCAAA;AAAA,EACjB,SAAA,EAAW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\n * All enums use `as const` objects for autocomplete + extensibility.\n */\n\nimport { ErrorKind } from './errors'\n\n// === Constants ===\n\n/** Standard HTTP methods supported by api-invoke. */\nexport const HttpMethod = {\n GET: 'GET',\n POST: 'POST',\n PUT: 'PUT',\n PATCH: 'PATCH',\n DELETE: 'DELETE',\n HEAD: 'HEAD',\n OPTIONS: 'OPTIONS',\n} as const\nexport type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod]\n\n/** Where a parameter is located in the HTTP request. */\nexport const ParamLocation = {\n PATH: 'path',\n QUERY: 'query',\n HEADER: 'header',\n COOKIE: 'cookie',\n} as const\nexport type ParamLocation = (typeof ParamLocation)[keyof typeof ParamLocation]\n\n/** Supported authentication types. */\nexport const AuthType = {\n BEARER: 'bearer',\n BASIC: 'basic',\n API_KEY: 'apiKey',\n QUERY_PARAM: 'queryParam',\n OAUTH2: 'oauth2',\n COOKIE: 'cookie',\n} as const\nexport type AuthType = (typeof AuthType)[keyof typeof AuthType]\n\n/** Detected API specification format. */\nexport const SpecFormat = {\n OPENAPI_3: 'openapi-3',\n OPENAPI_2: 'openapi-2',\n RAW_URL: 'raw-url',\n MANUAL: 'manual',\n GRAPHQL: 'graphql',\n} as const\nexport type SpecFormat = (typeof SpecFormat)[keyof typeof SpecFormat]\n\n/** Well-known HTTP header names used internally. */\nexport const HeaderName = {\n ACCEPT: 'Accept',\n AUTHORIZATION: 'Authorization',\n CONTENT_TYPE: 'Content-Type',\n COOKIE: 'Cookie',\n} as const\nexport type HeaderName = (typeof HeaderName)[keyof typeof HeaderName]\n\n// === Parsed API (spec-agnostic) ===\n\n/**\n * A parsed API specification, normalized into a spec-agnostic format.\n * This is the central data model — all adapters (OpenAPI, GraphQL, raw URL, manual builder) produce this shape.\n */\nexport interface ParsedAPI {\n /** Human-readable API title (e.g. 'Petstore API'). */\n title: string\n /** API version string from the spec (e.g. '1.0.0'). */\n version: string\n /** Base URL for all operations (e.g. 'https://api.example.com/v1'). */\n baseUrl: string\n /** All available API operations extracted from the spec. */\n operations: Operation[]\n /** Authentication schemes declared in the spec. */\n authSchemes: AuthScheme[]\n /** Which adapter produced this ParsedAPI. */\n specFormat: SpecFormat | string\n /** Raw spec version string from the spec (e.g. '3.0.3', '2.0'). Only set for OpenAPI specs. */\n rawSpecVersion?: string\n}\n\n/**\n * A single API operation (endpoint + method).\n * Produced by parsing a spec or using the manual builder.\n */\nexport interface Operation {\n /** Unique identifier for this operation (e.g. 'listUsers', 'get_users'). */\n id: string\n /** URL path template with placeholders (e.g. '/users/{userId}'). */\n path: string\n /** HTTP method (e.g. 'GET', 'POST'). */\n method: HttpMethod | string\n /** Short summary of what this operation does. */\n summary?: string\n /** Longer description of the operation's behavior. */\n description?: string\n /** Parameters accepted by this operation (path, query, header, cookie). */\n parameters: Parameter[]\n /** Request body definition, if the operation accepts one. */\n requestBody?: RequestBody\n /** Primary response schema for the operation's success case. For OpenAPI specs, this is the first 2xx schema found (see parser for priority). Useful for code generation or validation. */\n responseSchema?: unknown\n /** Success and default response schemas keyed by HTTP status code (e.g. '200', '201', 'default'). Codes without schemas (e.g. 204 No Content) are omitted. Error codes (4xx/5xx) are not extracted. */\n responseSchemas?: Record<string, unknown>\n /** Primary response content type (e.g. 'application/json', 'application/xml'). Used as the default Accept header. */\n responseContentType?: ContentType | string\n /** Error response descriptions keyed by HTTP status code (e.g. '404' → 'User not found'). Extracted from 4xx/5xx responses in the spec. */\n errorHints?: Record<string, string>\n /** Tags for grouping operations (e.g. ['users', 'admin']). */\n tags: string[]\n /**\n * Custom body builder for protocol adapters (e.g., GraphQL).\n * When set and no explicit 'body' key is in args, the executor calls this instead of flat-arg assembly to construct the request body.\n * Receives the full args map and returns the body data to be serialized.\n */\n buildBody?: (args: Record<string, unknown>) => unknown\n}\n\n/**\n * A parameter accepted by an API operation.\n */\nexport interface Parameter {\n /** Parameter name as used in the request (e.g. 'userId', 'page'). */\n name: string\n /** Where this parameter appears in the request. */\n in: ParamLocation\n /** Whether this parameter must be provided. Path parameters are always required. */\n required: boolean\n /** Human-readable description of the parameter. */\n description: string\n /** Type and constraint information for this parameter. */\n schema: ParameterSchema\n}\n\n/**\n * Type and constraint information for a parameter.\n */\nexport interface ParameterSchema {\n /** Data type (e.g. 'string', 'integer', 'boolean', 'array'). */\n type: string\n /** Format hint (e.g. 'int32', 'date-time', 'email', 'uuid'). */\n format?: string\n /** Allowed values for this parameter. */\n enum?: unknown[]\n /** Default value used when the parameter is not provided. */\n default?: unknown\n /** Example value for documentation and testing. */\n example?: unknown\n /** Minimum value for numeric parameters. */\n minimum?: number\n /** Maximum value for numeric parameters. */\n maximum?: number\n /** Maximum length for string parameters. */\n maxLength?: number\n /** Element schema for array parameters. */\n items?: ParameterSchema\n}\n\n/** Well-known MIME content types. */\nexport const ContentType = {\n JSON: 'application/json',\n FORM_URLENCODED: 'application/x-www-form-urlencoded',\n MULTIPART: 'multipart/form-data',\n XML: 'application/xml',\n OCTET_STREAM: 'application/octet-stream',\n TEXT: 'text/plain',\n SSE: 'text/event-stream',\n} as const\nexport type ContentType = (typeof ContentType)[keyof typeof ContentType]\n\n/**\n * Request body definition for an operation.\n */\nexport interface RequestBody {\n /** Whether the request body is required for this operation. */\n required: boolean\n /** Human-readable description of the request body. */\n description?: string\n /** Content type for the request body (e.g. 'application/json'). */\n contentType: ContentType | string\n /** Schema describing the request body structure. */\n schema: RequestBodySchema\n}\n\n/**\n * Schema for a request body, with flattened top-level properties for easy access.\n */\nexport interface RequestBodySchema {\n /** Top-level type (usually 'object'). */\n type: string\n /** Original unprocessed schema from the spec. Useful for advanced use cases like code generation. */\n raw: unknown\n /** Flattened top-level properties, keyed by property name. Only present when type is 'object'. */\n properties?: Record<string, RequestBodyProperty>\n /** Names of required properties. */\n required?: string[]\n}\n\n/**\n * A single property within a request body schema.\n */\nexport interface RequestBodyProperty {\n /** Data type (e.g. 'string', 'integer', 'boolean'). */\n type: string\n /** Format hint (e.g. 'date-time', 'email'). */\n format?: string\n /** Human-readable description of this property. */\n description?: string\n /** Allowed values for this property. */\n enum?: unknown[]\n /** Default value for this property. */\n default?: unknown\n /** Example value for documentation and testing. */\n example?: unknown\n /** True when this property is an object or array with nested structure. Useful for UI rendering decisions. */\n nested?: boolean\n}\n\n// === Authentication ===\n\n/**\n * An authentication scheme declared in the API spec.\n * Describes how the API expects credentials to be provided, but does not contain actual credentials.\n */\nexport interface AuthScheme {\n /** Scheme name from the spec (e.g. 'bearerAuth', 'api_key'). */\n name: string\n /** Mapped auth type, or null if the scheme is unsupported. */\n authType: AuthType | null\n /** Additional scheme-specific metadata (e.g. header name for API keys, OAuth2 URLs). */\n metadata: Record<string, string>\n /** Human-readable description of the auth scheme. */\n description: string\n}\n\n/**\n * Credentials for authenticating API requests.\n * Discriminated union on `type` — use the `AuthType` constants to construct.\n *\n * @example\n * // Bearer token\n * const auth: Auth = { type: AuthType.BEARER, token: 'sk-...' }\n *\n * @example\n * // API key in a header\n * const auth: Auth = { type: AuthType.API_KEY, location: ParamLocation.HEADER, name: 'X-API-Key', value: 'my-key' }\n */\nexport type Auth =\n | { type: typeof AuthType.BEARER; token: string }\n | { type: typeof AuthType.BASIC; username: string; password: string }\n | { type: typeof AuthType.API_KEY; location: typeof ParamLocation.HEADER | typeof ParamLocation.QUERY; name: string; value: string }\n | { type: typeof AuthType.OAUTH2; accessToken: string; refreshToken?: string; tokenUrl?: string; clientId?: string; clientSecret?: string }\n | { type: typeof AuthType.COOKIE; name: string; value: string }\n\n// === Execution ===\n\n/**\n * A fully constructed HTTP request ready to be sent (or previewed).\n * Produced by {@link buildRequest} and included in execution results for debugging.\n */\nexport interface BuiltRequest {\n /** HTTP method (e.g. 'GET', 'POST'). */\n method: HttpMethod | string\n /** Fully resolved URL with path and query parameters substituted. */\n url: string\n /** Request headers including auth, content-type, and accept. */\n headers: Record<string, string>\n /** Serialized request body, if present. String for JSON/form-urlencoded, FormData for multipart. */\n body?: string | FormData\n}\n\n/**\n * Subset of {@link ErrorKind} that can appear on {@link ExecutionResult.errorKind}.\n * Only HTTP-response errors — client-side errors (CORS, NETWORK, TIMEOUT) always throw regardless of `throwOnHttpError`.\n */\nexport type ResultErrorKind = typeof ErrorKind.AUTH | typeof ErrorKind.RATE_LIMIT | typeof ErrorKind.HTTP\n\n/**\n * Result of executing an API operation.\n * Contains the parsed response data, status, headers, timing, and the original request for debugging.\n */\nexport interface ExecutionResult {\n /** HTTP status code (e.g. 200, 404, 500). */\n status: number\n /** Parsed response body. JSON responses are parsed to objects; binary responses are ArrayBuffers; others attempt JSON parsing before falling back to strings. */\n data: unknown\n /** Response content type from the Content-Type header (e.g. 'application/json', 'text/xml'). */\n contentType: string\n /** Response headers as a flat key-value map. */\n headers: Record<string, string>\n /** The request that was sent, useful for debugging and logging. */\n request: BuiltRequest\n /** Request duration in milliseconds (from send to response headers received, before body parsing). */\n elapsedMs: number\n /** Set when `throwOnHttpError` is false and the response is an error. Allows programmatic error classification without throwing. */\n errorKind?: ResultErrorKind\n}\n\n// === Streaming ===\n\n/**\n * A parsed Server-Sent Event.\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events\n */\nexport interface SSEEvent {\n /** Event type (e.g. 'message', 'error'). Absent when no `event:` field was set in the stream. */\n event?: string\n /** Event payload. For JSON-encoded events, this is the raw string — parse it with `JSON.parse()`. */\n data: string\n /** Last event ID. Per spec, values containing U+0000 NULL are ignored by the parser. */\n id?: string\n /** Reconnection time in milliseconds. Must be a non-negative integer per spec. */\n retry?: number\n}\n\n/**\n * Result of a streaming API call. Errors always throw before this object is constructed,\n * so `status` is guaranteed to be 2xx. The `stream` is single-use — iterating it twice\n * will fail since the underlying ReadableStream reader can only be consumed once.\n * Unlike `ExecutionResult`, `elapsedMs` measures time to receive the response headers (not total stream consumption time)\n * and `errorKind` is absent (errors throw, no non-throwing mode for streams).\n */\nexport interface StreamingExecutionResult {\n /** HTTP status code (guaranteed 2xx). */\n status: number\n /** Async iterable of SSE events. Single-use — can only be iterated once. */\n stream: AsyncIterable<SSEEvent>\n /** Response content type (expected: 'text/event-stream'). */\n contentType: string\n /** Response headers as a flat key-value map. */\n headers: Record<string, string>\n /** The request that was sent. */\n request: BuiltRequest\n /** Time-to-first-byte in milliseconds (not total stream consumption time). */\n elapsedMs: number\n}\n\n// === Enricher ===\n\n/**\n * Post-processing hook that transforms a ParsedAPI after parsing.\n * Useful for adding custom operations, modifying base URLs, or injecting metadata.\n */\nexport interface Enricher {\n /** Enricher name for identification in logs and debugging. */\n readonly name: string\n /**\n * Transform the parsed API. May return a new object or modify in place.\n * Can be async for enrichers that need to fetch external data.\n */\n enrichAPI(api: ParsedAPI): ParsedAPI | Promise<ParsedAPI>\n}\n\n// === Client Options ===\n\n/**\n * Configuration options for {@link ApiInvokeClient} and {@link createClient}.\n */\nexport interface ClientOptions {\n /** Original spec URL, used for base URL fallback when the spec has no servers/host field. */\n specUrl?: string\n /** Default authentication credentials for all operations. Can be overridden per-call. */\n auth?: Auth | Auth[]\n /** Middleware pipeline applied to every request/response (e.g. logging, CORS proxy). */\n middleware?: Middleware[]\n /** Custom fetch implementation. Defaults to `globalThis.fetch`. Useful for testing or wrapping with {@link withRetry}. */\n fetch?: typeof globalThis.fetch\n /** Post-parse enricher that transforms the ParsedAPI before client construction. */\n enricher?: Enricher\n /** Default timeout in milliseconds for all operations. 0 = no timeout (default). */\n timeoutMs?: number\n}\n\n// === Middleware ===\n\n/**\n * Middleware hook for intercepting requests and responses.\n * All hooks are optional — implement only the ones you need.\n */\nexport interface Middleware {\n /** Middleware name for identification in logs and debugging. */\n name?: string\n /**\n * Called before each request is sent. Can modify the URL and request init.\n * Middleware runs in order — later middleware sees changes from earlier ones.\n */\n onRequest?(url: string, init: RequestInit): { url: string; init: RequestInit } | Promise<{ url: string; init: RequestInit }>\n /**\n * Called after receiving a response. Can transform or replace the response.\n * Runs in order — later middleware sees the response from earlier ones.\n */\n onResponse?(response: Response): Response | Promise<Response>\n /**\n * Called when a fetch error occurs (network failure, CORS, timeout).\n * For logging/monitoring only — cannot recover from the error.\n * Exceptions thrown by this handler are suppressed (logged as warnings).\n */\n onError?(error: Error): void\n}\n","/**\n * Classified API errors with human/agent-readable suggestions.\n * Each error has a `kind` for programmatic handling and `retryable` for retry logic.\n */\n\n/**\n * Error classification constants. Use with {@link ApiInvokeError.kind} for programmatic error handling.\n *\n * @example\n * ```ts\n * if (error.kind === ErrorKind.RATE_LIMIT) {\n * // Wait and retry\n * }\n * ```\n */\nexport const ErrorKind = {\n CORS: 'cors',\n NETWORK: 'network',\n AUTH: 'auth',\n HTTP: 'http',\n PARSE: 'parse',\n RATE_LIMIT: 'rate-limit',\n TIMEOUT: 'timeout',\n GRAPHQL: 'graphql',\n} as const\nexport type ErrorKind = (typeof ErrorKind)[keyof typeof ErrorKind]\n\n/** Error name constant used on all ApiInvokeError instances. Useful for cross-realm `instanceof` checks. */\nexport const API_INVOKE_ERROR_NAME = 'ApiInvokeError' as const\n\n/**\n * Structured error thrown by api-invoke for all API failures.\n * Includes a machine-readable `kind`, a human-readable `suggestion`, and a `retryable` flag.\n *\n * @example\n * ```ts\n * try {\n * await client.execute('getUser', { userId: 123 })\n * } catch (error) {\n * if (error instanceof ApiInvokeError) {\n * console.log(error.kind) // 'auth', 'network', 'rate-limit', etc.\n * console.log(error.suggestion) // Human-readable recovery advice\n * console.log(error.retryable) // Whether retrying might succeed\n * }\n * }\n * ```\n */\nexport class ApiInvokeError extends Error {\n /** Error classification for programmatic handling. */\n readonly kind: ErrorKind | string\n /** HTTP status code, if the error originated from an HTTP response. */\n readonly status?: number\n /** Human-readable suggestion for how to resolve this error. */\n readonly suggestion: string\n /** Whether retrying the request might succeed (e.g. true for rate limits, network errors). */\n readonly retryable: boolean\n /** Response body from the API (when available). May be parsed JSON, a string, or binary data depending on the response content type. */\n readonly responseBody?: unknown\n\n constructor(opts: {\n kind: ErrorKind | string\n message: string\n suggestion: string\n retryable?: boolean\n status?: number\n responseBody?: unknown\n }) {\n super(opts.message)\n this.name = API_INVOKE_ERROR_NAME\n this.kind = opts.kind\n this.suggestion = opts.suggestion\n this.retryable = opts.retryable ?? false\n this.status = opts.status\n this.responseBody = opts.responseBody\n }\n}\n\n/**\n * Create a CORS error for when a browser request is blocked by the same-origin policy.\n * @param url - The URL that was blocked\n * @returns An `ApiInvokeError` with `kind: 'cors'` and `retryable: false`\n */\nexport function corsError(url: string): ApiInvokeError {\n return new ApiInvokeError({\n kind: ErrorKind.CORS,\n message: `Cannot access ${url} — blocked by CORS policy.`,\n suggestion: 'This API does not allow browser requests. Use a CORS proxy or server-side execution.',\n retryable: false,\n })\n}\n\n/**\n * Create a network error for connection failures.\n * @param url - The URL that failed to connect\n * @returns An `ApiInvokeError` with `kind: 'network'` and `retryable: true`\n */\nexport function networkError(url: string): ApiInvokeError {\n return new ApiInvokeError({\n kind: ErrorKind.NETWORK,\n message: `Network error while fetching ${url}.`,\n suggestion: 'Check your internet connection and verify the URL is correct.',\n retryable: true,\n })\n}\n\n/**\n * Create an authentication/authorization error (401 or 403).\n * @param url - The URL that returned the error\n * @param status - HTTP status code (401 or 403)\n * @param responseBody - Parsed response body, if available\n * @returns An `ApiInvokeError` with `kind: 'auth'` and `retryable: false`\n */\nexport function authError(url: string, status: 401 | 403, responseBody?: unknown): ApiInvokeError {\n return new ApiInvokeError({\n kind: ErrorKind.AUTH,\n message: status === 401\n ? `Authentication failed for ${url} (401)`\n : `Authorization denied for ${url} (403)`,\n suggestion: status === 401\n ? 'Check your credentials. The server rejected your authentication.'\n : 'Your credentials are valid but you lack permission for this resource.',\n retryable: false,\n status,\n responseBody,\n })\n}\n\n/**\n * Create an HTTP error for non-2xx responses (excluding 401/403 which use {@link authError}).\n * Status 429 is classified as `kind: 'rate-limit'`; all others as `kind: 'http'`.\n * @param url - The URL that returned the error\n * @param status - HTTP status code\n * @param statusText - HTTP status text (e.g. 'Not Found')\n * @param responseBody - Parsed response body, if available\n * @returns An `ApiInvokeError` with `retryable: true` for 429 and 5xx status codes\n */\nexport function httpError(url: string, status: number, statusText: string, responseBody?: unknown): ApiInvokeError {\n const retryable = status === 429 || status >= 500\n const kind = status === 429 ? ErrorKind.RATE_LIMIT : ErrorKind.HTTP\n\n let suggestion: string\n if (status === 404) {\n suggestion = 'The endpoint was not found. Check the URL path.'\n } else if (status === 429) {\n suggestion = 'Rate limited. Wait and retry.'\n } else if (status >= 500) {\n suggestion = 'The API server is having issues. Try again later.'\n } else {\n suggestion = `The API returned an error (${status}). Verify the request.`\n }\n\n return new ApiInvokeError({\n kind,\n message: `API returned ${status} ${statusText} for ${url}.`,\n suggestion,\n retryable,\n status,\n responseBody,\n })\n}\n\n/**\n * Create a parse error for when the response body cannot be read as the expected format.\n * @param url - The URL that returned the unparseable response\n * @param expectedType - The expected format (default: 'JSON')\n * @returns An `ApiInvokeError` with `kind: 'parse'` and `retryable: false`\n */\nexport function parseError(url: string, expectedType = 'JSON'): ApiInvokeError {\n return new ApiInvokeError({\n kind: ErrorKind.PARSE,\n message: `Failed to parse response from ${url} as ${expectedType}.`,\n suggestion: `The API response body could not be read as ${expectedType}. Verify the endpoint returns the expected content type.`,\n retryable: false,\n })\n}\n\n/**\n * Create a GraphQL error for when the response contains errors and no data (total failure).\n * @param messages - Joined error messages from the GraphQL response\n * @param status - HTTP status code (usually 200 for GraphQL)\n * @param responseBody - Full GraphQL response body\n * @returns An `ApiInvokeError` with `kind: 'graphql'` and `retryable: false`\n */\nexport function graphqlError(messages: string, status?: number, responseBody?: unknown): ApiInvokeError {\n return new ApiInvokeError({\n kind: ErrorKind.GRAPHQL,\n message: `GraphQL errors: ${messages}`,\n suggestion: 'Check the query and variables for correctness.',\n retryable: false,\n status,\n responseBody,\n })\n}\n\n/**\n * Create a timeout error for when a request exceeds the configured `timeoutMs`.\n * @param url - The URL that timed out\n * @returns An `ApiInvokeError` with `kind: 'timeout'` and `retryable: true`\n */\nexport function timeoutError(url: string): ApiInvokeError {\n return new ApiInvokeError({\n kind: ErrorKind.TIMEOUT,\n message: `Request to ${url} timed out.`,\n suggestion: 'The server took too long to respond. Try again or increase the timeout.',\n retryable: true,\n })\n}\n","/**\n * GraphQL introspection query and types for parsing introspection results.\n * Based on the GraphQL specification's introspection system.\n */\n\n/** GraphQL type kinds from the introspection system. */\nexport const TypeKind = {\n SCALAR: 'SCALAR',\n OBJECT: 'OBJECT',\n ENUM: 'ENUM',\n INPUT_OBJECT: 'INPUT_OBJECT',\n NON_NULL: 'NON_NULL',\n LIST: 'LIST',\n UNION: 'UNION',\n INTERFACE: 'INTERFACE',\n} as const\nexport type TypeKind = (typeof TypeKind)[keyof typeof TypeKind]\n\n/** Introspection query covering types, fields, args, and enums. Omits possibleTypes and directives for simplicity. */\nexport const INTROSPECTION_QUERY = `query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n subscriptionType { name }\n types {\n kind name description\n fields(includeDeprecated: false) {\n name description\n args { name description type { ...TypeRef } defaultValue }\n type { ...TypeRef }\n }\n inputFields { name description type { ...TypeRef } defaultValue }\n enumValues(includeDeprecated: false) { name description }\n }\n }\n}\nfragment TypeRef on __Type {\n kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } }\n}`\n\nexport interface IntrospectionResult {\n data: { __schema: IntrospectionSchema }\n}\n\nexport interface IntrospectionSchema {\n queryType: { name: string } | null\n mutationType: { name: string } | null\n subscriptionType: { name: string } | null\n types: IntrospectionType[]\n}\n\nexport interface IntrospectionType {\n kind: TypeKind | string\n name: string\n description?: string | null\n fields?: IntrospectionField[] | null\n inputFields?: IntrospectionInputValue[] | null\n enumValues?: Array<{ name: string; description?: string | null }> | null\n}\n\nexport interface IntrospectionField {\n name: string\n description?: string | null\n args: IntrospectionInputValue[]\n type: IntrospectionTypeRef\n}\n\nexport interface IntrospectionInputValue {\n name: string\n description?: string | null\n type: IntrospectionTypeRef\n defaultValue?: string | null\n}\n\nexport interface IntrospectionTypeRef {\n kind: TypeKind | string\n name: string | null\n ofType?: IntrospectionTypeRef | null\n}\n","/**\n * Generates GraphQL query strings from introspection type information.\n * Produces depth-limited selection sets that cover scalar fields and nested objects.\n */\n\nimport { TypeKind } from './introspection'\nimport type { IntrospectionField, IntrospectionInputValue, IntrospectionType, IntrospectionTypeRef } from './introspection'\n\nconst DEFAULT_MAX_DEPTH = 2\n\n/**\n * Format a GraphQL type reference as a human-readable string.\n *\n * @example\n * formatTypeRef({ kind: 'NON_NULL', name: null, ofType: { kind: 'SCALAR', name: 'String', ofType: null } })\n * // => 'String!'\n */\nexport function formatTypeRef(ref: IntrospectionTypeRef): string {\n if (ref.kind === TypeKind.NON_NULL) {\n return ref.ofType ? `${formatTypeRef(ref.ofType)}!` : 'unknown!'\n }\n if (ref.kind === TypeKind.LIST) {\n return ref.ofType ? `[${formatTypeRef(ref.ofType)}]` : '[unknown]'\n }\n return ref.name ?? 'unknown'\n}\n\n/**\n * Unwrap NON_NULL and LIST wrappers to find the base (named) type.\n */\nexport function unwrapType(ref: IntrospectionTypeRef): IntrospectionTypeRef {\n let current = ref\n while ((current.kind === TypeKind.NON_NULL || current.kind === TypeKind.LIST) && current.ofType) {\n current = current.ofType\n }\n return current\n}\n\n/**\n * Check if a type reference is non-null (required).\n */\nexport function isNonNull(ref: IntrospectionTypeRef): boolean {\n return ref.kind === TypeKind.NON_NULL\n}\n\n/**\n * Build a GraphQL query/mutation string from introspection field data.\n *\n * @param operationType - 'query' or 'mutation'\n * @param field - The root field from the Query/Mutation type\n * @param typeMap - Map of type names to their introspection definitions\n * @param maxDepth - Maximum depth for nested field selection (default: 2)\n * @returns A complete GraphQL query string\n */\nexport function buildQueryString(\n operationType: 'query' | 'mutation',\n field: IntrospectionField,\n typeMap: Map<string, IntrospectionType>,\n maxDepth: number = DEFAULT_MAX_DEPTH,\n): string {\n const varDefs = buildVariableDefinitions(field.args)\n const fieldArgs = buildFieldArguments(field.args)\n const selection = buildSelectionSet(field.type, typeMap, maxDepth, new Set())\n\n const varPart = varDefs ? `(${varDefs})` : ''\n const argPart = fieldArgs ? `(${fieldArgs})` : ''\n const selPart = selection ? ` ${selection}` : ''\n\n return `${operationType} ${field.name}${varPart} { ${field.name}${argPart}${selPart} }`\n}\n\nfunction buildVariableDefinitions(args: IntrospectionInputValue[]): string {\n if (args.length === 0) return ''\n return args.map(a => `$${a.name}: ${formatTypeRef(a.type)}`).join(', ')\n}\n\nfunction buildFieldArguments(args: IntrospectionInputValue[]): string {\n if (args.length === 0) return ''\n return args.map(a => `${a.name}: $${a.name}`).join(', ')\n}\n\nfunction buildSelectionSet(\n typeRef: IntrospectionTypeRef,\n typeMap: Map<string, IntrospectionType>,\n depth: number,\n visited: Set<string>,\n): string {\n const base = unwrapType(typeRef)\n if (!base.name) return ''\n\n const type = typeMap.get(base.name)\n if (!type || !type.fields) return ''\n\n if (base.kind === TypeKind.UNION || base.kind === TypeKind.INTERFACE) {\n return buildUnionSelection(type, typeMap, depth, visited)\n }\n\n if (base.kind !== TypeKind.OBJECT) return ''\n\n // Prevent circular references\n if (visited.has(base.name)) return ''\n visited.add(base.name)\n\n const fields: string[] = []\n for (const f of type.fields) {\n const fieldBase = unwrapType(f.type)\n if (fieldBase.kind === TypeKind.SCALAR || fieldBase.kind === TypeKind.ENUM) {\n fields.push(f.name)\n } else if (depth > 0 && (fieldBase.kind === TypeKind.OBJECT || fieldBase.kind === TypeKind.UNION || fieldBase.kind === TypeKind.INTERFACE)) {\n const nested = buildSelectionSet(f.type, typeMap, depth - 1, new Set(visited))\n if (nested) {\n fields.push(`${f.name} ${nested}`)\n }\n }\n }\n\n visited.delete(base.name)\n\n if (fields.length === 0) return ''\n return `{ ${fields.join(' ')} }`\n}\n\nfunction buildUnionSelection(\n type: IntrospectionType,\n typeMap: Map<string, IntrospectionType>,\n depth: number,\n visited: Set<string>,\n): string {\n // For unions/interfaces, we need the possibleTypes — but introspection query\n // doesn't include them by default. Fall back to __typename only.\n // A more complete introspection query could include possibleTypes.\n return '{ __typename }'\n}\n","/**\n * GraphQL adapter — parses introspection schemas into ParsedAPI.\n * Accepts a live endpoint URL (runs introspection) or an introspection JSON object.\n */\n\nimport type { ParsedAPI, Operation, RequestBody, RequestBodyProperty } from '../../core/types'\nimport { HttpMethod, ContentType, SpecFormat } from '../../core/types'\nimport { ApiInvokeError, ErrorKind } from '../../core/errors'\nimport { INTROSPECTION_QUERY, TypeKind } from './introspection'\nimport type { IntrospectionSchema, IntrospectionType, IntrospectionField, IntrospectionInputValue, IntrospectionTypeRef } from './introspection'\nimport { buildQueryString, unwrapType, isNonNull, formatTypeRef } from './query-builder'\n\n/** Options for parsing a GraphQL schema. */\nexport interface GraphQLParseOptions {\n /** GraphQL endpoint URL. Strongly recommended when input is introspection JSON — without it, baseUrl defaults to '/graphql' (a relative path). Inferred automatically when input is a URL string. */\n endpoint?: string\n /** Custom fetch implementation for introspection queries. Defaults to `globalThis.fetch`. */\n fetch?: typeof globalThis.fetch\n /** Maximum depth for auto-generated query selection sets. Default: 2. */\n maxDepth?: number\n}\n\n/**\n * Parse a GraphQL schema into a ParsedAPI.\n *\n * @param input - Either an endpoint URL (string starting with http) or an introspection result object.\n * URL: runs introspection query against the endpoint.\n * Object: expects `{ data: { __schema: ... } }` or `{ __schema: ... }` shape.\n * @param options - Configuration options.\n * @returns A ParsedAPI with one operation per query/mutation/subscription field.\n */\nexport async function parseGraphQLSchema(\n input: string | object,\n options?: GraphQLParseOptions,\n): Promise<ParsedAPI> {\n const maxDepth = options?.maxDepth ?? 2\n\n let schema: IntrospectionSchema\n let endpoint: string\n\n if (typeof input === 'string') {\n if (!input.startsWith('http')) {\n throw new ApiInvokeError({\n kind: ErrorKind.PARSE,\n message: 'GraphQL input must be an endpoint URL (starting with http) or an introspection JSON object. SDL parsing is not yet supported.',\n suggestion: 'Pass a URL like \"https://api.example.com/graphql\" or an introspection result object.',\n retryable: false,\n })\n }\n endpoint = options?.endpoint ?? input\n schema = await fetchIntrospection(input, options?.fetch)\n } else {\n schema = extractSchema(input)\n endpoint = options?.endpoint ?? '/graphql'\n }\n\n const path = extractPath(endpoint)\n const typeMap = buildTypeMap(schema.types)\n const operations: Operation[] = []\n\n // Parse query fields\n if (schema.queryType?.name) {\n const queryType = typeMap.get(schema.queryType.name)\n if (queryType?.fields) {\n for (const field of queryType.fields) {\n operations.push(buildOperation(field, 'query', path, typeMap, maxDepth))\n }\n }\n }\n\n // Parse mutation fields\n if (schema.mutationType?.name) {\n const mutationType = typeMap.get(schema.mutationType.name)\n if (mutationType?.fields) {\n for (const field of mutationType.fields) {\n operations.push(buildOperation(field, 'mutation', path, typeMap, maxDepth))\n }\n }\n }\n\n // Parse subscription fields — tagged for discovery but not executable via HTTP (subscriptions require WebSocket). No buildBody hook is set.\n if (schema.subscriptionType?.name) {\n const subType = typeMap.get(schema.subscriptionType.name)\n if (subType?.fields) {\n for (const field of subType.fields) {\n operations.push(buildOperation(field, 'subscription', path, typeMap, maxDepth))\n }\n }\n }\n\n const title = extractTitle(endpoint, schema)\n\n return {\n title,\n version: '1.0.0',\n baseUrl: extractBaseUrl(endpoint),\n operations,\n authSchemes: [],\n specFormat: SpecFormat.GRAPHQL,\n }\n}\n\n/** Run an introspection query against a live GraphQL endpoint. */\nasync function fetchIntrospection(\n url: string,\n fetchFn?: typeof globalThis.fetch,\n): Promise<IntrospectionSchema> {\n const doFetch = fetchFn ?? globalThis.fetch\n let response: Response\n try {\n response = await doFetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ query: INTROSPECTION_QUERY }),\n })\n } catch (err) {\n throw new ApiInvokeError({\n kind: ErrorKind.NETWORK,\n message: `Failed to fetch GraphQL introspection from ${url}: ${err instanceof Error ? err.message : String(err)}`,\n suggestion: 'Check the endpoint URL and your network connection.',\n retryable: true,\n })\n }\n\n if (!response.ok) {\n throw new ApiInvokeError({\n kind: ErrorKind.HTTP,\n message: `GraphQL introspection failed with HTTP ${response.status} from ${url}.`,\n suggestion: 'Verify the endpoint supports introspection and is accessible.',\n retryable: response.status >= 500,\n status: response.status,\n })\n }\n\n let json: Record<string, unknown>\n const cloned = response.clone()\n try {\n json = await response.json() as Record<string, unknown>\n } catch (err) {\n let body: string | undefined\n try { body = (await cloned.text()).slice(0, 200) } catch { /* ignore */ }\n throw new ApiInvokeError({\n kind: ErrorKind.PARSE,\n message: `GraphQL introspection response from ${url} is not valid JSON${err instanceof Error ? `: ${err.message}` : ''}.`,\n suggestion: `The endpoint returned a non-JSON response${body ? ` (starts with: \"${body}\")` : ''}. Verify it is a GraphQL endpoint.`,\n retryable: false,\n })\n }\n return extractSchema(json)\n}\n\n/** Extract __schema from an introspection result object. */\nfunction extractSchema(obj: object): IntrospectionSchema {\n const record = obj as Record<string, unknown>\n\n // Shape: { __schema: ... }\n if (record.__schema && typeof record.__schema === 'object') {\n return record.__schema as IntrospectionSchema\n }\n\n // Shape: { data: { __schema: ... } }\n if (record.data && typeof record.data === 'object') {\n const data = record.data as Record<string, unknown>\n if (data.__schema && typeof data.__schema === 'object') {\n return data.__schema as IntrospectionSchema\n }\n }\n\n throw new ApiInvokeError({\n kind: ErrorKind.PARSE,\n message: 'Invalid GraphQL introspection result: expected { __schema: ... } or { data: { __schema: ... } }.',\n suggestion: 'Pass a valid introspection result object or a URL to a GraphQL endpoint.',\n retryable: false,\n })\n}\n\n/** Build a type lookup map from introspection types. */\nfunction buildTypeMap(types: IntrospectionType[]): Map<string, IntrospectionType> {\n const map = new Map<string, IntrospectionType>()\n for (const type of types) {\n map.set(type.name, type)\n }\n return map\n}\n\n/** Extract URL path from an endpoint URL. */\nfunction extractPath(endpoint: string): string {\n try {\n return new URL(endpoint).pathname\n } catch {\n return '/graphql'\n }\n}\n\n/** Extract base URL (origin) from an endpoint URL. */\nfunction extractBaseUrl(endpoint: string): string {\n try {\n const url = new URL(endpoint)\n return url.origin\n } catch {\n return ''\n }\n}\n\n/** Generate a title from the endpoint URL or schema info. */\nfunction extractTitle(endpoint: string, _schema: IntrospectionSchema): string {\n try {\n const url = new URL(endpoint)\n return `GraphQL API (${url.hostname})`\n } catch {\n return 'GraphQL API'\n }\n}\n\n/** Build an Operation from an introspection field. */\nfunction buildOperation(\n field: IntrospectionField,\n operationType: 'query' | 'mutation' | 'subscription',\n path: string,\n typeMap: Map<string, IntrospectionType>,\n maxDepth: number,\n): Operation {\n const id = operationType === 'mutation' ? `mutation_${field.name}`\n : operationType === 'subscription' ? `subscription_${field.name}`\n : field.name\n const tags = [operationType]\n\n const queryString = operationType !== 'subscription'\n ? buildQueryString(operationType as 'query' | 'mutation', field, typeMap, maxDepth)\n : undefined\n\n const requestBody = buildRequestBody(field.args, typeMap)\n const responseSchema = buildResponseSchema(field.type, typeMap)\n\n const operation: Operation = {\n id,\n path,\n method: HttpMethod.POST,\n summary: field.description ?? `GraphQL ${operationType}: ${field.name}`,\n parameters: [],\n requestBody,\n responseSchema,\n tags,\n }\n\n if (queryString) {\n const argNames = new Set(field.args.map(a => a.name))\n operation.buildBody = (args: Record<string, unknown>) => {\n const variables: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(args)) {\n if (argNames.has(k)) variables[k] = v\n }\n return { query: queryString, variables }\n }\n }\n\n return operation\n}\n\n/** Build a RequestBody from GraphQL field arguments. */\nfunction buildRequestBody(\n args: IntrospectionInputValue[],\n typeMap: Map<string, IntrospectionType>,\n): RequestBody | undefined {\n if (args.length === 0) return undefined\n\n const properties: Record<string, RequestBodyProperty> = {}\n const required: string[] = []\n\n for (const arg of args) {\n properties[arg.name] = mapInputValueToProperty(arg, typeMap)\n if (isNonNull(arg.type)) {\n required.push(arg.name)\n }\n }\n\n return {\n required: required.length > 0,\n contentType: ContentType.JSON,\n schema: {\n type: 'object',\n raw: { type: 'object', properties },\n properties,\n required: required.length > 0 ? required : undefined,\n },\n }\n}\n\n/** Map a GraphQL input value to a RequestBodyProperty. */\nfunction mapInputValueToProperty(\n input: IntrospectionInputValue,\n typeMap: Map<string, IntrospectionType>,\n): RequestBodyProperty {\n const base = unwrapType(input.type)\n const description = input.description\n ? `${input.description} (${formatTypeRef(input.type)})`\n : formatTypeRef(input.type)\n\n // Check if the type ref has a LIST wrapper in its chain\n const isList = isListType(input.type)\n\n if (base.kind === TypeKind.SCALAR) {\n const mapped = mapScalarType(base.name ?? 'String')\n const prop: RequestBodyProperty = {\n type: isList ? 'array' : mapped.type,\n description,\n }\n if (mapped.format) prop.format = mapped.format\n if (input.defaultValue != null) prop.default = input.defaultValue\n return prop\n }\n\n if (base.kind === TypeKind.ENUM) {\n const enumType = typeMap.get(base.name ?? '')\n const enumValues = enumType?.enumValues?.map(e => e.name)\n return {\n type: isList ? 'array' : 'string',\n description,\n enum: enumValues,\n }\n }\n\n if (base.kind === TypeKind.INPUT_OBJECT) {\n return {\n type: isList ? 'array' : 'object',\n description,\n nested: true,\n }\n }\n\n // Fallback for unknown types\n return { type: 'string', description }\n}\n\n/** Check if a type ref contains a LIST wrapper. */\nfunction isListType(ref: IntrospectionTypeRef): boolean {\n let current: IntrospectionTypeRef | null | undefined = ref\n while (current) {\n if (current.kind === TypeKind.LIST) return true\n current = current.ofType\n }\n return false\n}\n\n/** Map a GraphQL scalar type name to a JSON Schema type. */\nfunction mapScalarType(name: string): { type: string; format?: string } {\n switch (name) {\n case 'String':\n case 'ID':\n return { type: 'string' }\n case 'Int':\n return { type: 'integer' }\n case 'Float':\n return { type: 'number' }\n case 'Boolean':\n return { type: 'boolean' }\n default:\n // Custom scalars (DateTime, JSON, etc.) → string\n return { type: 'string', format: name.toLowerCase() }\n }\n}\n\n/** Build a response schema from the field's return type. */\nfunction buildResponseSchema(\n typeRef: IntrospectionTypeRef,\n typeMap: Map<string, IntrospectionType>,\n): unknown {\n const base = unwrapType(typeRef)\n if (!base.name) return undefined\n\n if (base.kind === TypeKind.SCALAR) {\n const mapped = mapScalarType(base.name)\n return { type: mapped.type, format: mapped.format }\n }\n\n if (base.kind === TypeKind.ENUM) {\n const enumType = typeMap.get(base.name)\n return { type: 'string', enum: enumType?.enumValues?.map(e => e.name) }\n }\n\n if (base.kind === TypeKind.OBJECT) {\n const objType = typeMap.get(base.name)\n if (!objType?.fields) return { type: 'object' }\n\n const properties: Record<string, unknown> = {}\n for (const f of objType.fields) {\n const fieldBase = unwrapType(f.type)\n if (fieldBase.kind === TypeKind.SCALAR) {\n properties[f.name] = mapScalarType(fieldBase.name ?? 'String')\n } else if (fieldBase.kind === TypeKind.ENUM) {\n properties[f.name] = { type: 'string' }\n } else {\n properties[f.name] = { type: 'object' }\n }\n }\n return { type: 'object', properties }\n }\n\n return { type: 'object' }\n}\n"]}