UNPKG

@opra/common

Version:
83 lines (82 loc) 2.59 kB
import type { Combine, ThunkAsync, Type } from 'ts-gems'; import { OpraSchema } from '../../schema/index.js'; import { DataTypeMap } from '../common/data-type-map.js'; import { DocumentElement } from '../common/document-element.js'; import { DataType } from '../data-type/data-type.js'; import type { EnumType } from '../data-type/enum-type.js'; import { WSOperationDecorator } from '../decorators/ws-operation.decorator.js'; import { WSController } from './ws-controller.js'; /** * @namespace WSOperation */ export declare namespace WSOperation { interface Metadata extends Pick<OpraSchema.WSOperation, 'description' | 'event'> { arguments?: { type: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray> | string; parameterIndex: number; required?: boolean; }[]; types?: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>[]; response?: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>[]; } interface Options extends Partial<Pick<Metadata, 'description'>> { event?: string | RegExp; response?: string | ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>; } interface InitArguments extends Combine<{ name: string; types?: DataType[]; arguments?: { type: DataType | string | Type; parameterIndex: number; required?: boolean; }[]; }, Pick<Metadata, 'description'>> { event?: string | RegExp; response?: DataType | string | Type; } } /** * Type definition for WSOperation * @class WSOperation */ export interface WSOperationStatic { /** * Class constructor of WSOperation * @param controller * @param args */ new (controller: WSController, args: WSOperation.InitArguments): WSOperation; /** * Property decorator * @param options */ <T extends WSOperation.Options>(options?: T): WSOperationDecorator; prototype: WSOperation; } /** * @class WSOperation */ export interface WSOperation extends WSOperationClass { } /** * WSOperation */ export declare const WSOperation: WSOperationStatic; /** * @class WSOperation */ declare class WSOperationClass extends DocumentElement { readonly owner: WSController; readonly name: string; description?: string; event: string | RegExp; arguments: { type: DataType; parameterIndex: number; required?: boolean; }[]; types: DataTypeMap; response?: DataType; toJSON(): OpraSchema.WSOperation; } export {};