import { OutgoingHttpHeaders } from "node:http"; import { RetrySettings } from "@sebspark/retry"; import { Request, RequestHandler } from "express"; //#region src/common.d.ts export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD'; export type SchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object'; export type SchemaEnum = string[] | number[] | boolean[]; export type DefaultValue = string | number | boolean | any[] | any; export type Example = any; export type ExampleObject = { summary?: string; description?: string; value?: Example; externalValue?: string; }; export type SchemaObject = { title?: string; multipleOf?: number; maximum?: number; exclusiveMaximum?: boolean; minimum?: number; exclusiveMinimum?: boolean; maxLength?: number; minLength?: number; pattern?: string; maxItems?: number; minItems?: number; uniqueItems?: boolean; maxProperties?: number; minProperties?: number; required?: string[]; enum?: SchemaEnum; type?: SchemaType | SchemaType[]; allOf?: (SchemaObject | ReferenceObject)[]; oneOf?: (SchemaObject | ReferenceObject)[]; anyOf?: (SchemaObject | ReferenceObject)[]; not?: SchemaObject | ReferenceObject; items?: SchemaObject | ReferenceObject; properties?: Record; additionalProperties?: boolean | SchemaObject | ReferenceObject; description?: string; format?: string; default?: DefaultValue; nullable?: boolean; discriminator?: DiscriminatorObject; readOnly?: boolean; writeOnly?: boolean; xml?: XMLObject; externalDocs?: ExternalDocumentationObject; example?: Example; deprecated?: boolean; }; export type XMLObject = { name?: string; namespace?: string; prefix?: string; attribute?: boolean; wrapped?: boolean; }; export type ParameterIn = 'query' | 'header' | 'path' | 'cookie'; export type ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject'; export type ParameterObject = { name: string; in: ParameterIn; description?: string; required?: boolean; deprecated?: boolean; allowEmptyValue?: boolean; style?: ParameterStyle; explode?: boolean; allowReserved?: boolean; schema?: SchemaObject | ReferenceObject; example?: Example; examples?: Record; content?: Record; }; export type MediaTypeObject = { schema?: SchemaObject | ReferenceObject; example?: Example; examples?: Record; encoding?: Record; }; export type EncodingObject = { contentType?: string; headers?: Record; style?: string; explode?: boolean; allowReserved?: boolean; }; export type HeaderStyle = 'simple'; export type HeaderObject = { description?: string; required?: boolean; deprecated?: boolean; allowEmptyValue?: boolean; style?: HeaderStyle; explode?: boolean; allowReserved?: boolean; schema?: SchemaObject | ReferenceObject; example?: Example; examples?: Record; content?: Record; }; export type DiscriminatorObject = { propertyName: string; mapping?: Record; }; export type ReferenceObject = { $ref: string; }; export type InfoObject = { title: string; summary?: string; description?: string; termsOfService?: string; contact?: ContactObject; license?: LicenseObject; version: string; }; export type ContactObject = { name?: string; url?: string; email?: string; }; export type LicenseObject = { name: string; url?: string; }; export type ServerObject = { url: string; description?: string; variables?: Record; }; export type ServerVariableObject = { default: string; enum?: string[]; description?: string; }; export type TagObject = { name: string; description?: string; externalDocs?: ExternalDocumentationObject; }; export type ExternalDocumentationObject = { description?: string; url: string; }; export type SecuritySchemeType = 'apiKey' | 'http' | 'oauth2' | 'openIdConnect'; export type SecuritySchemeObject = { type: SecuritySchemeType; description?: string; name?: string; in?: ParameterIn; scheme?: string; bearerFormat?: string; flows?: OAuthFlowsObject; openIdConnectUrl?: string; }; export type OAuthFlowsObject = { implicit?: OAuthFlowObject; password?: OAuthFlowObject; clientCredentials?: OAuthFlowObject; authorizationCode?: OAuthFlowObject; }; export type OAuthFlowObject = { authorizationUrl?: string; tokenUrl?: string; refreshUrl?: string; scopes: Record; }; //#endregion //#region src/bindings.d.ts type ChannelBindingsObject = { http?: HttpChannelBindingObject; ws?: WebSocketChannelBindingObject; kafka?: KafkaChannelBindingObject; redis?: RedisChannelBindingObject; rabbitmq?: RabbitMQChannelBindingObject; googlepubsub?: GooglePubSubChannelBindingObject; }; type HttpChannelBindingObject = { type: string; method: string; query: SchemaObject | ReferenceObject; bindingVersion?: string; }; type WebSocketChannelBindingObject = { type: string; method: string; query: SchemaObject | ReferenceObject; headers: SchemaObject | ReferenceObject; bindingVersion?: string; }; type KafkaChannelBindingObject = { groupId?: SchemaObject | ReferenceObject; clientId?: SchemaObject | ReferenceObject; bindingVersion?: string; }; type RedisChannelBindingObject = { type: string; method: string; query: SchemaObject | ReferenceObject; bindingVersion?: string; }; type RabbitMQChannelBindingObject = { is: string; exchange: { name: string; type: string; durable: boolean; autoDelete: boolean; vhost: string; }; queue: { name: string; durable: boolean; exclusive: boolean; autoDelete: boolean; vhost: string; }; bindingVersion?: string; }; type GooglePubSubChannelBindingObject = { topic: { name: string; }; subscription: { name: string; }; bindingVersion?: string; }; type OperationBindingsObject = { ws?: WebSocketOperationBindingObject; http?: HttpOperationBindingObject; kafka?: KafkaOperationBindingObject; redis?: RedisOperationBindingObject; rabbitmq?: RabbitMQOperationBindingObject; googlepubsub?: GooglePubSubOperationBindingObject; }; type OperationType = 'publish' | 'subscribe'; type MessageFormat = 'json' | 'xml' | 'text' | 'binary'; type WebSocketOperationBindingObject = { type?: OperationType; method?: 'GET'; query?: SchemaObject | ReferenceObject; headers?: SchemaObject | ReferenceObject; messageFormat?: MessageFormat; persistent?: boolean; bindingVersion?: string; }; type HttpOperationBindingObject = { type: 'request' | 'response'; method: HttpMethod; query?: SchemaObject | ReferenceObject; bindingVersion?: string; }; type KafkaOperationBindingObject = { groupId?: { type: 'string'; description?: string; }; clientId?: { type: 'string'; description?: string; }; bindingVersion?: string; }; type RedisOperationBindingObject = { command?: 'PUBLISH' | 'SUBSCRIBE'; channel?: string; bindingVersion?: string; }; type RabbitMQOperationBindingObject = { exchangeType?: 'direct' | 'fanout' | 'topic' | 'headers'; exchangeName?: string; durable?: boolean; autoDelete?: boolean; vhost?: string; bindingVersion?: string; }; type GooglePubSubOperationBindingObject = { ackDeadlineSeconds?: number; retryPolicy?: GooglePubSubRetryPolicy; deadLetterPolicy?: GooglePubSubDeadLetterPolicy; detachSubscription?: boolean; messageRetentionDuration?: string; filter?: string; bindingVersion?: string; }; type GooglePubSubRetryPolicy = { minimumBackoff?: string; maximumBackoff?: string; }; type GooglePubSubDeadLetterPolicy = { deadLetterTopic?: string; maxDeliveryAttempts?: number; }; type MessageBindingsObject = { http?: HttpMessageBindingObject; ws?: WebSocketMessageBindingObject; kafka?: KafkaMessageBindingObject; redis?: RedisMessageBindingObject; rabbitmq?: RabbitMQMessageBindingObject; googlepubsub?: GooglePubSubMessageBindingObject; }; type MessageBindingObject = { headers?: SchemaObject | ReferenceObject; bindingVersion?: string; }; type HttpMessageBindingObject = MessageBindingObject & {}; type WebSocketMessageBindingObject = MessageBindingObject & {}; type KafkaMessageBindingObject = MessageBindingObject & {}; type RedisMessageBindingObject = MessageBindingObject & {}; type RabbitMQMessageBindingObject = MessageBindingObject & {}; type GooglePubSubMessageBindingObject = MessageBindingObject & {}; type ServerBindingsObject = { http?: HttpServerBindingObject; ws?: WebSocketServerBindingObject; kafka?: KafkaServerBindingObject; mqtt?: MqttServerBindingObject; amqp?: AmqpServerBindingObject; }; type BaseServerBindingObject = { bindingVersion?: string; }; type HttpServerBindingObject = BaseServerBindingObject & {}; type WebSocketServerBindingObject = BaseServerBindingObject & {}; type KafkaServerBindingObject = BaseServerBindingObject & {}; type MqttServerBindingObject = BaseServerBindingObject & {}; type AmqpServerBindingObject = BaseServerBindingObject & {}; //#endregion //#region src/asyncapi.d.ts export type AsyncApiDocument = { asyncapi: string; id?: string; info: InfoObject; servers?: Record; defaultContentType?: string; channels: Record; components?: AsyncApiComponentsObject; tags?: TagObject[]; externalDocs?: ExternalDocumentationObject; }; export type ChannelItemObject = { $ref?: string; description?: string; subscribe?: AsyncOperationObject; publish?: AsyncOperationObject; parameters?: Record; bindings?: ChannelBindingsObject; }; export type AsyncOperationObject = { tags?: TagObject[]; summary?: string; description?: string; externalDocs?: ExternalDocumentationObject; operationId?: string; traits?: OperationTraitObject[]; message?: MessageObject | ReferenceObject; }; export type MessageObject = { headers?: SchemaObject | ReferenceObject; payload?: SchemaObject | ReferenceObject; correlationId?: CorrelationIdObject | ReferenceObject; schemaFormat?: string; contentType?: string; name?: string; title?: string; summary?: string; description?: string; tags?: TagObject[]; externalDocs?: ExternalDocumentationObject; bindings?: MessageBindingsObject; examples?: Example[]; traits?: MessageTraitObject[]; }; export type AsyncApiComponentsObject = { schemas?: Record; messages?: Record; securitySchemes?: Record; parameters?: Record; correlationIds?: Record; operationTraits?: Record; messageTraits?: Record; serverBindings?: Record; channelBindings?: Record; messageBindings?: Record; }; export type OperationTraitObject = { operationId?: string; summary?: string; description?: string; tags?: TagObject[]; externalDocs?: ExternalDocumentationObject; bindings?: OperationBindingsObject; message?: MessageTraitObject | ReferenceObject; }; export type MessageTraitObject = { headers?: SchemaObject | ReferenceObject; correlationId?: CorrelationIdObject | ReferenceObject; schemaFormat?: string; contentType?: string; name?: string; title?: string; summary?: string; description?: string; tags?: TagObject[]; externalDocs?: ExternalDocumentationObject; examples?: Example[]; bindings?: MessageBindingsObject; }; export type CorrelationIdObject = { description?: string; location: string; }; //#endregion //#region src/avsc.d.ts export type AvroSchema = AvroRecord | AvroEnum | AvroArray | AvroMap | AvroPrimitive | AvroUnion; export type AvroRecord = { type: 'record'; name: string; namespace?: string; doc?: string; fields: AvroField[]; }; export type AvroField = { name: string; type: AvroSchema; doc?: string; default?: any; order?: 'ascending' | 'descending' | 'ignore'; }; export type AvroEnum = { type: 'enum'; name: string; symbols: string[]; doc?: string; }; export type AvroArray = { type: 'array'; items: AvroSchema; doc?: string; }; export type AvroMap = { type: 'map'; values: AvroSchema; doc?: string; }; export type AvroUnion = AvroSchema[]; export type AvroPrimitive = 'null' | 'boolean' | 'int' | 'long' | 'float' | 'double' | 'bytes' | 'string'; //#endregion //#region src/errors.d.ts export type ClientErrorCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451; export type ServerErrorCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511; export type ErrorCode = ClientErrorCode | ServerErrorCode; type SerializedError = { message: string; stack?: string; }; export declare class HttpError extends Error { statusCode: number; constructor(statusCode: number, message: string, cause?: Error); toJSON(showStack?: boolean): SerializedError; } export declare class BadRequestError extends HttpError { constructor(message?: string, cause?: Error); } export declare class UnauthorizedError extends HttpError { constructor(message?: string, cause?: Error); } export declare class PaymentRequiredError extends HttpError { constructor(message?: string, cause?: Error); } export declare class ForbiddenError extends HttpError { constructor(message?: string, cause?: Error); } export declare class NotFoundError extends HttpError { constructor(message?: string, cause?: Error); } export declare class MethodNotAllowedError extends HttpError { constructor(message?: string, cause?: Error); } export declare class NotAcceptableError extends HttpError { constructor(message?: string, cause?: Error); } export declare class ProxyAuthenticationRequiredError extends HttpError { constructor(message?: string, cause?: Error); } export declare class RequestTimeoutError extends HttpError { constructor(message?: string, cause?: Error); } export declare class ConflictError extends HttpError { constructor(message?: string, cause?: Error); } export declare class GoneError extends HttpError { constructor(message?: string, cause?: Error); } export declare class LengthRequiredError extends HttpError { constructor(message?: string, cause?: Error); } export declare class PreconditionFailedError extends HttpError { constructor(message?: string, cause?: Error); } export declare class PayloadTooLargeError extends HttpError { constructor(message?: string, cause?: Error); } export declare class URITooLongError extends HttpError { constructor(message?: string, cause?: Error); } export declare class UnsupportedMediaTypeError extends HttpError { constructor(message?: string, cause?: Error); } export declare class RangeNotSatisfiableError extends HttpError { constructor(message?: string, cause?: Error); } export declare class ExpectationFailedError extends HttpError { constructor(message?: string, cause?: Error); } export declare class IMATeapotError extends HttpError { constructor(message?: string, cause?: Error); } export declare class MisdirectedRequestError extends HttpError { constructor(message?: string, cause?: Error); } export declare class UnprocessableEntityError extends HttpError { constructor(message?: string, cause?: Error); } export declare class LockedError extends HttpError { constructor(message?: string, cause?: Error); } export declare class FailedDependencyError extends HttpError { constructor(message?: string, cause?: Error); } export declare class TooEarlyError extends HttpError { constructor(message?: string, cause?: Error); } export declare class UpgradeRequiredError extends HttpError { constructor(message?: string, cause?: Error); } export declare class PreconditionRequiredError extends HttpError { constructor(message?: string, cause?: Error); } export declare class TooManyRequestsError extends HttpError { constructor(message?: string, cause?: Error); } export declare class RequestHeaderFieldsTooLargeError extends HttpError { constructor(message?: string, cause?: Error); } export declare class UnavailableForLegalReasonsError extends HttpError { constructor(message?: string, cause?: Error); } export declare class InternalServerError extends HttpError { constructor(message?: string, cause?: Error); } export declare class NotImplementedError extends HttpError { constructor(message?: string, cause?: Error); } export declare class BadGatewayError extends HttpError { constructor(message?: string, cause?: Error); } export declare class ServiceUnavailableError extends HttpError { constructor(message?: string, cause?: Error); } export declare class GatewayTimeoutError extends HttpError { constructor(message?: string, cause?: Error); } export declare class HTTPVersionNotSupportedError extends HttpError { constructor(message?: string, cause?: Error); } export declare class VariantAlsoNegotiatesError extends HttpError { constructor(message?: string, cause?: Error); } export declare class InsufficientStorageError extends HttpError { constructor(message?: string, cause?: Error); } export declare class LoopDetectedError extends HttpError { constructor(message?: string, cause?: Error); } export declare class NotExtendedError extends HttpError { constructor(message?: string, cause?: Error); } export declare class NetworkAuthenticationRequiredError extends HttpError { constructor(message?: string, cause?: Error); } export declare const createHttpError: (statusCode: ErrorCode, message?: string, cause?: Error) => HttpError; export declare const fromAxiosError: (error: unknown) => HttpError; //#endregion //#region src/openapi.d.ts export type OpenApiDocument = { openapi: string; info: InfoObject; jsonSchemaDialect?: string; servers?: ServerObject[]; paths: Record; webhooks?: Record; components?: ComponentsObject; security?: SecurityRequirementObject[]; tags?: TagObject[]; externalDocs?: ExternalDocumentationObject; }; export type PathItemObject = { summary?: string; description?: string; get?: OperationObject; put?: OperationObject; post?: OperationObject; delete?: OperationObject; options?: OperationObject; head?: OperationObject; patch?: OperationObject; trace?: OperationObject; servers?: ServerObject[]; parameters?: (ParameterObject | ReferenceObject)[]; }; export type OperationObject = { tags?: string[]; summary?: string; description?: string; externalDocs?: ExternalDocumentationObject; operationId?: string; parameters?: (ParameterObject | ReferenceObject)[]; requestBody?: RequestBodyObject | ReferenceObject; responses: ResponsesObject; callbacks?: Record; deprecated?: boolean; security?: SecurityRequirementObject[]; servers?: ServerObject[]; }; export type RequestBodyObject = { description?: string; content: Record<'application/json' | (string & {}), MediaTypeObject>; required?: boolean; }; export type ResponsesObject = Record; export type ResponseObject = { description: string; headers?: Record; content?: Record<'application/json' | (string & {}), MediaTypeObject>; links?: Record; }; export type ComponentsObject = { schemas?: Record; responses?: Record; parameters?: Record; examples?: Record; requestBodies?: Record; headers?: Record; securitySchemes?: Record; links?: Record; callbacks?: Record; pathItems?: Record; }; type RequestBody = any; export type LinkObject = { operationRef?: string; operationId?: string; parameters?: Record; requestBody?: RequestBody; description?: string; server?: ServerObject; }; export type CallbackObject = Record; export type SecurityRequirementObject = Record; //#endregion //#region src/ts-extensions.d.ts type Empty = Record; type Serialized = T extends Date ? string : T extends bigint ? string : T extends Map ? Array<[Serialized, Serialized]> : T extends Set ? Array> : T extends (infer U)[] ? Array> : T extends object ? { [K in keyof T]: Serialized; } : T; type PartiallySerialized = { [K in keyof T]: T[K] | Serialized; }; type ConvertToQueryParam = T extends number ? string : T extends boolean ? string : T extends Date ? string : T extends string ? T : T extends Array ? Array> : T extends object ? { [K in keyof T]: ConvertToQueryParam; } : T; type QueryParams = { [K in keyof T]: ConvertToQueryParam; }; type LowerCaseHeaders = { [P in keyof T as Lowercase

]: T[P]; }; //#endregion //#region src/types.d.ts export type ExpressRequest = Request; export type Verb = 'get' | 'post' | 'put' | 'patch' | 'delete'; export type APIResponse = Data extends undefined ? Headers extends undefined ? Empty : { headers: Headers; } : Headers extends undefined ? { data: Data; } : { data: Data; headers: Headers; }; export type GenericRouteHandler = RequestHandler; export type RouteHandler = { pre?: RequestHandler | RequestHandler[]; handler: (args: any) => Promise<[number, APIResponse | undefined>]>; }; export type Route = Record; export type APIServerDefinition = Record>; export type APIServerOptions = { pre?: RequestHandler | RequestHandler[]; }; export type RequestArgs = Request & { params?: Record; query?: Record; headers?: Record; }; export type PayloadRequestArgs = RequestArgs & { body?: Record; }; export type RequestOptions = { retry?: RetrySettings; headers?: OutgoingHttpHeaders & Record; httpsAgent?: any; httpAgent?: any; timeout?: number; }; export type ArrayFormat = 'indices' | 'brackets' | 'repeat' | 'comma'; export type ClientOptions = RequestOptions & { arrayFormat?: ArrayFormat; authorizationTokenGenerator?: (url: string) => Promise> | undefined; authorizationTokenRefresh?: (url: string) => Promise | undefined; }; export type BaseClient = { get: | undefined>>(url: U, args?: A, opts?: RequestOptions) => Promise; post: | undefined>>(url: U, args?: A, opts?: RequestOptions) => Promise; put: | undefined>>(url: U, args?: A, opts?: RequestOptions) => Promise; patch: | undefined>>(url: U, args?: A, opts?: RequestOptions) => Promise; delete: >(url: U, args?: A, opts?: RequestOptions) => Promise; }; //#endregion //#region src/schema.d.ts /** * Marks unimplemented paths as deprecated and tags them with 'not-implemented'. * Use to hide or visually separate endpoints not yet available on the given server. * * @param document - The OpenAPI document to modify * @param server - The server definition to check against for implemented paths * @returns A cloned document with unimplemented paths marked as deprecated */ export declare const disableUnimplementedPaths: (document: T, server: S) => T; /** * Appends the API version segment to all server URLs. * * @param document - The OpenAPI document to modify * @param version - The version string to append * @returns A cloned document with updated server URLs */ export declare const appendVersionToServers: (document: T, version: string) => T; /** * Resolves a $ref string to its schema definition within the document. * * @param ref - A JSON pointer ref string e.g. `#/components/schemas/Foo` * @param doc - The OpenAPI document to resolve against * @returns The resolved schema, or undefined if the ref cannot be resolved */ export declare const resolveRef: (ref: string, doc: OpenApiDocument) => SchemaObject | undefined; /** * Flattens all schemas typed as oneOf[$ref, $ref, ...] where all refs resolve to enums * into a single merged enum. Enables API UI tools to render a dropdown instead of a text input. * * @param document - The OpenAPI document to modify * @returns A cloned document with flattened enum schemas */ export declare const flattenEnums: (document: T) => T; //#endregion export type { LowerCaseHeaders, PartiallySerialized, QueryParams, Serialized }; //# sourceMappingURL=index.d.mts.map