UNPKG

alepha

Version:

Alepha is a convention-driven TypeScript framework for building robust, end-to-end type-safe applications, from serverless APIs to full-stack React apps.

148 lines (147 loc) 4.81 kB
import "alepha/server/security"; import * as _alepha_core1 from "alepha"; import { Alepha, Descriptor, KIND, TObject } from "alepha"; import { ActionDescriptor, RequestConfigSchema, ServerProvider, ServerRouterProvider } from "alepha/server"; import * as _alepha_logger0 from "alepha/logger"; import { ServerStaticProvider } from "alepha/server/static"; import { OpenAPIV3 } from "openapi-types"; //#region src/descriptors/$swagger.d.ts /** * Create a new OpenAPI. */ declare const $swagger: { (options: SwaggerDescriptorOptions): SwaggerDescriptor; [KIND]: typeof SwaggerDescriptor; }; interface SwaggerDescriptorOptions { info: OpenAPIV3.InfoObject; /** * @default: "/docs" */ prefix?: string; /** * If true, docs will be disabled. */ disabled?: boolean; /** * Tags to exclude from the documentation. */ excludeTags?: string[]; /** * Enable Swagger UI. * * @default true */ ui?: boolean | SwaggerUiOptions; /** * Function to rewrite the OpenAPI document before serving it. */ rewrite?: (doc: OpenAPIV3.Document) => void; } interface SwaggerUiOptions { root?: string; initOAuth?: { /** * Default clientId. */ clientId?: string; /** * realm query parameter (for oauth1) added to authorizationUrl and tokenUrl. */ realm?: string; /** * application name, displayed in authorization popup. */ appName?: string; /** * scope separator for passing scopes, encoded before calling, default * value is a space (encoded value %20). * * @default ' ' */ scopeSeparator?: string; /** * string array or scope separator (i.e. space) separated string of * initially selected oauth scopes * * @default [] */ scopes?: string | string[]; /** * Additional query parameters added to authorizationUrl and tokenUrl. * MUST be an object */ additionalQueryStringParams?: { [key: string]: any; }; /** * Only activated for the accessCode flow. During the authorization_code * request to the tokenUrl, pass the Client Password using the HTTP Basic * Authentication scheme (Authorization header with Basic * base64encode(client_id + client_secret)). * * @default false */ useBasicAuthenticationWithAccessCodeGrant?: boolean; /** * Only applies to Authorization Code flows. Proof Key for Code Exchange * brings enhanced security for OAuth public clients. * * @default false */ usePkceWithAuthorizationCodeGrant?: boolean; }; } declare class SwaggerDescriptor extends Descriptor<SwaggerDescriptorOptions> {} //#endregion //#region src/ServerSwaggerProvider.d.ts declare class ServerSwaggerProvider { protected readonly serverStaticProvider: ServerStaticProvider; protected readonly serverRouterProvider: ServerRouterProvider; protected readonly serverProvider: ServerProvider; protected readonly alepha: Alepha; protected readonly log: _alepha_logger0.Logger; json?: OpenAPIV3.Document; options: { excludeKeys: string[]; }; protected readonly configure: _alepha_core1.HookDescriptor<"configure">; createSwagger(options: SwaggerDescriptorOptions): Promise<OpenAPIV3.Document | undefined>; protected configureOpenApi(actions: ActionDescriptor<RequestConfigSchema>[], doc: SwaggerDescriptorOptions): OpenAPIV3.Document; isBodyMultipart(schema: TObject): boolean; replacePathParams(url: string): string; getResponseSchema(route: ActionDescriptor<RequestConfigSchema>): { type?: string; schema?: any; status: number; } | undefined; protected configureSwaggerApi(prefix: string, json: OpenAPIV3.Document): void; protected configureSwaggerUi(prefix: string, options: SwaggerDescriptorOptions): Promise<void>; removePrivateFields<T extends Record<string, any>>(obj: T, excludeList: string[]): T; } //#endregion //#region src/index.d.ts declare module "alepha/server" { interface ActionDescriptorOptions<TConfig extends RequestConfigSchema> { /** * Short description of the route. */ summary?: string; /** * Don't include this action in the Swagger documentation. */ hide?: boolean; } } /** * Plugin for Alepha Server that provides Swagger documentation capabilities. * It generates OpenAPI v3 documentation for the server's endpoints ($action). * It also provides a Swagger UI for interactive API documentation. * * @see {@link ServerSwaggerProvider} * @module alepha.server.swagger */ declare const AlephaServerSwagger: _alepha_core1.Service<_alepha_core1.Module<{}>>; //#endregion export { $swagger, AlephaServerSwagger, ServerSwaggerProvider, SwaggerDescriptor, SwaggerDescriptorOptions, SwaggerUiOptions }; //# sourceMappingURL=index.d.ts.map