UNPKG

@opra/common

Version:
78 lines (77 loc) 2.65 kB
import type { Combine, ThunkAsync, Type } from 'ts-gems'; import { TypeThunkAsync } from 'ts-gems/lib/types'; 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 { RpcOperationDecorator } from '../decorators/rpc-operation.decorator.js'; import type { RpcController } from './rpc-controller'; import type { RpcHeader } from './rpc-header'; import type { RpcOperationResponse } from './rpc-operation-response'; /** * @namespace RpcOperation */ export declare namespace RpcOperation { interface Metadata extends Pick<OpraSchema.RpcOperation, 'description' | 'channel'> { payloadType: TypeThunkAsync | string; keyType?: TypeThunkAsync | string; types?: ThunkAsync<Type | EnumType.EnumObject | EnumType.EnumArray>[]; headers?: RpcHeader.Metadata[]; response?: RpcOperationResponse.Metadata; } interface Options extends Partial<Pick<Metadata, 'description' | 'keyType'>> { channel?: (string | RegExp) | (string | RegExp)[]; } interface InitArguments extends Combine<{ name: string; types?: DataType[]; payloadType?: DataType | string | Type; keyType?: DataType | string | Type; }, Pick<Metadata, 'description' | 'channel'>> { } } /** * Type definition for RpcOperation * @class RpcOperation */ export interface RpcOperationStatic { /** * Class constructor of RpcOperation * @param controller * @param args */ new (controller: RpcController, args: RpcOperation.InitArguments): RpcOperation; /** * Property decorator * @param payloadType * @param options */ <T extends RpcOperation.Options>(payloadType: ThunkAsync<Type> | string, options?: T): RpcOperationDecorator; prototype: RpcOperation; } /** * @class RpcOperation */ export interface RpcOperation extends RpcOperationClass { } /** * RpcOperation */ export declare const RpcOperation: RpcOperationStatic; /** * @class RpcOperation */ declare class RpcOperationClass extends DocumentElement { readonly owner: RpcController; readonly name: string; channel: string | RegExp | (string | RegExp)[]; description?: string; payloadType: DataType; keyType?: DataType; types: DataTypeMap; headers: RpcHeader[]; response: RpcOperationResponse; findHeader(paramName: string): RpcHeader | undefined; toJSON(): OpraSchema.RpcOperation; } export {};