import { GenericMethodDecorator } from './GenericMethodDecorator'; import { OperationDuration } from './OperationDuration'; import { OperationErrorHandler } from './OperationErrorHandler'; import { OperationFinallyHooks } from './OperationFinallyHooks'; import { OperationTree } from './OperationTree'; import { FuncFromTryCatchFinallyContext, TryCatchFinallyContext, TryCatchFinallyHook } from './wrapTryCatchFinallyPromisable'; export interface DecoratorArgs { operation?: string; [key: string]: any; } export type OperationHookContext = TContext & { decoratorArgs?: TDecoratorArgs; }; export interface OperationHookProvider { getTryCatchFinallyHook(ctx: TContext): TryCatchFinallyHook; getDecoratorUtils?(): TDecoratorUtils; } export type UnionToIntersection = (TUnion extends any ? (k: TUnion) => void : never) extends (k: infer I) => void ? I : never; export type ContextFromHookProviders = TProviders extends OperationHookProvider[] ? UnionToIntersection : TryCatchFinallyContext; export type DecoratorArgsFromContext = TContext extends { decoratorArgs?: infer TDecoratorArgs; } ? TDecoratorArgs : DecoratorArgs; export type DecoratorArgsFromHookProviders = DecoratorArgsFromContext>; export type DecoratorUtilsFromHookProviders = TProviders extends OperationHookProvider[] ? UnionToIntersection : {}; export type FuncFromHookProviders = FuncFromTryCatchFinallyContext>; export declare class OperationDecorator { static createDecoratorFactory(...hookProviders: TOperationHookProviders): ((decoratorArgs?: DecoratorArgsFromHookProviders) => GenericMethodDecorator>) & DecoratorUtilsFromHookProviders & { _contextType: ContextFromHookProviders; }; static createDecoratorFactoryWithDefault(...customHookProviders: TOperationHookProviders): ((decoratorArgs?: DecoratorArgsFromContext> | undefined) => GenericMethodDecorator>>) & DecoratorUtilsFromHookProviders<[typeof OperationErrorHandler, typeof OperationTree, typeof OperationDuration, typeof OperationFinallyHooks, ...TOperationHookProviders]> & { _contextType: ContextFromHookProviders<[typeof OperationErrorHandler, typeof OperationTree, typeof OperationDuration, typeof OperationFinallyHooks, ...TOperationHookProviders]>; }; static getOperationName(ctx: TContext): string | undefined; } export type OperationDecoratorContext = TContext & { decoratorOf?: { classProto: any; methodName: string; descriptor: TypedPropertyDescriptor; originalMethod: FuncFromTryCatchFinallyContext; }; decoratorArgs?: DecoratorArgsFromContext & DecoratorArgs; }; export type ContextFromDecorator = TDecorator extends { _contextType: infer TContext; } ? TContext : never;