@opra/common
Version:
Opra common package
95 lines (94 loc) • 3.15 kB
TypeScript
import type { Combine, ThunkAsync, Type } from 'ts-gems';
import { ResponsiveMap } from '../../helpers/index.js';
import { OpraSchema } from '../../schema/index.js';
import type { ApiDocument } from '../api-document.js';
import { DataTypeMap } from '../common/data-type-map.js';
import { DocumentElement } from '../common/document-element.js';
import type { EnumType } from '../data-type/enum-type.js';
import { HttpControllerDecoratorFactory } from '../decorators/http-controller.decorator.js';
import { nodeInspectCustom } from '../utils/inspect.util.js';
import type { HttpApi } from './http-api.js';
import type { HttpOperation } from './http-operation';
import { HttpParameter } from './http-parameter.js';
/**
* @namespace HttpController
*/
export declare namespace HttpController {
interface Metadata extends Pick<OpraSchema.HttpController, 'description' | 'path'> {
name: string;
controllers?: (Type | ((parent: any) => any))[];
types?: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>[];
operations?: Record<string, HttpOperation.Metadata>;
parameters?: HttpParameter.Metadata[];
}
interface Options extends Partial<Pick<OpraSchema.HttpController, 'description' | 'path'>> {
name?: string;
controllers?: (Type | ((parent: any) => any))[];
}
interface InitArguments extends Combine<{
instance?: object;
ctor?: Type;
}, Pick<Metadata, 'name' | 'description' | 'path'>> {
}
}
/**
* Type definition for HttpController
* @class HttpController
*/
export interface HttpControllerStatic extends HttpControllerDecoratorFactory {
/**
* Class constructor of HttpController
* @param owner
* @param args
*/
new (owner: HttpApi | HttpController, args: HttpController.InitArguments): HttpController;
prototype: HttpController;
}
/**
* Type definition of HttpController prototype
* @interface HttpController
*/
export interface HttpController extends HttpControllerClass {
}
/**
* HttpController
*/
export declare const HttpController: HttpControllerStatic;
/**
*
* @class HttpController
*/
declare class HttpControllerClass extends DocumentElement {
protected _controllerReverseMap: WeakMap<Type, HttpController | null>;
readonly kind: OpraSchema.HttpController.Kind;
readonly name: string;
description?: string;
path: string;
instance?: any;
ctor?: Type;
parameters: HttpParameter[];
operations: ResponsiveMap<HttpOperation>;
controllers: ResponsiveMap<HttpController>;
types: DataTypeMap;
/**
* @property isRoot
*/
get isRoot(): boolean;
findController(controller: Type): HttpController | undefined;
findController(resourcePath: string): HttpController | undefined;
findParameter(paramName: string, location?: OpraSchema.HttpParameterLocation): HttpParameter | undefined;
getFullUrl(): string;
/**
*
*/
toString(): string;
/**
*
*/
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpController;
/**
*
*/
protected [nodeInspectCustom](): string;
}
export {};