/// import Router from '@koa/router'; import { Telemetry } from '@opvious/stl-telemetry'; import { OpenapiDocument } from 'yasdk-openapi'; import { JSON_MIME_TYPE, MimeType, OperationTypes } from 'yasdk-runtime'; import { KoaDecodersFor, KoaEncodersFor } from './codecs.js'; import { DefaultOperationContext, DefaultOperationTypes, KoaHandlersFor } from './handlers.js'; export { KoaDecoder, KoaEncoder } from './codecs.js'; export { KoaContextsFor, KoaHandlerFor, KoaHandlersFor, KoaValuesFor, } from './handlers.js'; /** Creates a type-safe router for operations defined in the document */ export declare function createOperationsRouter = DefaultOperationTypes, S = {}, M extends MimeType = typeof JSON_MIME_TYPE>(args: { /** Fully resolved OpenAPI document or its YAML representation. */ readonly document: OpenapiDocument | string; /** Handler implementations. */ readonly handlers: KoaHandlersFor; /** Telemetry reporter. */ readonly telemetry?: Telemetry; /** * Defaults to `handlers` if `handlers`'s constructor has a defined name * different from `Object` and `undefined` otherwise. */ readonly handlerContext?: unknown; /** * Fallback route handler used when no handler exists for a given operation. * By default no route will be added in this case. */ readonly fallback?: (ctx: DefaultOperationContext) => Promise; /** Default response data content-type. Defaults to `application/json`. */ readonly defaultType?: M; /** * Additional request decoders. The default supports uncompressed `text/*` and * `application/json` content-types. */ readonly decoders?: KoaDecodersFor; /** * Additional response encoders. The default supports uncompressed `text/*` * and `application/json` content-types. */ readonly encoders?: KoaEncodersFor; /** * Handle invalid request errors by returning plain text responses with * appropriate status. By default these errors are rethrown with status * `INVALID_ARGUMENT` and code `InvalidRequest`. */ readonly handleInvalidRequests?: boolean; }): Router;