UNPKG

vulcain-corejs

Version:
121 lines (120 loc) 2.95 kB
import { IContainer } from '../di/resolvers'; import { LifeTime } from '../di/annotations'; import { Domain } from '../schemas/schema'; import { UserContext } from '../servers/requestContext'; /** * This class provide a way to customize the http response. * * @export * @class HttpResponse */ export declare class HttpResponse { /** * Http code (default is 200) * * @type {number} * @memberOf HttpResponse */ statusCode: number; /** * List of response headers * * @type {Map<string, string>} * @memberOf HttpResponse */ headers: Map<string, string>; /** * Define a specific ContentType * * @type {string} * @memberOf HttpResponse */ contentType: string; /** * Response content * * @type {*} * @memberOf HttpResponse */ content: any; /** * Content encoding (like binary, hex,...) * * @type {string} * @memberOf HttpResponse */ encoding: string; constructor(); /** * Add a custom header value to the response * * @param {string} name * @param {string} value */ addHeader(name: string, value: string): void; } export declare class HttpRedirectResponse extends HttpResponse { constructor(url: string); } export interface ValidationError { id?: string; field?: string; message: string; } export interface ErrorResponse { message: string; errors?: Array<ValidationError>; } export interface CommonRequestData { correlationId: string; correlationPath: string; action: string; domain: string; schema: string; inputSchema?: string; userContext?: UserContext; params: any; } export interface CommonRequestResponse<T> { tenant: string; userContext: UserContext; source: string; domain: string; action: string; schema: string; error?: ErrorResponse; value?: T; inputSchema?: string; } export interface CommonActionMetadata { description: string; action?: string; scope?: string; schema?: string | Function; inputSchema?: string | Function; } export interface CommonMetadata { description?: string; schema?: string | Function; } export interface CommonHandlerMetadata extends CommonMetadata { scope: string; } export interface ServiceHandlerMetadata extends CommonHandlerMetadata { serviceName?: string; serviceLifeTime?: LifeTime; enableOnTestOnly?: boolean; } export interface IManager { container: IContainer; getInfoHandler<T>(command: CommonRequestData, container?: IContainer): { handler: Function; metadata: T; method: string; kind: "query" | "action" | "event"; }; runAsync(command: CommonRequestData, ctx: any): Promise<CommonRequestResponse<any>>; } export declare class HandlerFactory { static obfuscateSensibleData(domain: Domain, container: IContainer, result: any): any; }