import type { PostProcessor } from './di'; import { type MetaBag } from './metadata'; /** The context of an advised method call. */ export interface JoinPoint { /** The (unwrapped) instance the method belongs to. */ readonly target: object; /** The method name. */ readonly method: string; /** The arguments the call was invoked with; read-only (replace them via `proceed(args)` in around advice). */ readonly args: readonly unknown[]; } /** A {@link JoinPoint} that can run the wrapped method via `proceed()`. */ export interface ProceedingJoinPoint extends JoinPoint { /** * Invoke the method (optionally with different args); returns its result. * * @param args - Replacement call arguments; defaults to the original arguments when omitted. * @returns The method's result (a `Promise` for async methods). */ proceed(args?: unknown[]): unknown; } /** Advice that runs just before the method body — for sync side effects; its return value is ignored. */ export type BeforeAdvice = (joinPoint: JoinPoint) => void; /** Advice that runs after the method finishes (in a `finally`, awaiting async methods); its return value is ignored. */ export type AfterAdvice = (joinPoint: JoinPoint) => void; /** Advice that wraps the method: it receives a {@link ProceedingJoinPoint}, must call `proceed()` to run the method, and returns the (possibly transformed) result. */ export type AroundAdvice = (joinPoint: ProceedingJoinPoint) => unknown; /** * Register `around` advice for a named method directly on a metadata bag — the * programmatic form of `@around`, for applying advice to many methods at once * (e.g. a class-level `@traced()` that wraps every public method). * * @param meta - The class's shared metadata bag to record the advice on. * @param method - Name of the method to wrap. * @param advice - wrapping advice run around each call to `method`; it must call `proceed()` to invoke the method and returns the (possibly transformed) result. Stacks with other advice on the same method. See {@link AroundAdvice}. */ export declare function addAround(meta: MetaBag, method: PropertyKey, advice: AroundAdvice): void; /** * Method decorator: run `advice` before the method (sync side effects). * * @param advice - receives the call's {@link JoinPoint}; its return value is ignored — use for logging, validation, or arg inspection. * @returns A method decorator that records the before advice. */ export declare function before(advice: BeforeAdvice): (_v: unknown, context: ClassMethodDecoratorContext) => void; /** * Method decorator: run `advice` after the method (finally; awaits async methods). * * @param advice - receives the call's {@link JoinPoint}; runs in a `finally` (awaiting async results) so it fires even when the method throws; its return value is ignored. * @returns A method decorator that records the after advice. */ export declare function after(advice: AfterAdvice): (_v: unknown, context: ClassMethodDecoratorContext) => void; /** * Method decorator: wrap the method — call `joinPoint.proceed()` to run it. * * @param advice - receives a {@link ProceedingJoinPoint}; must call `proceed()` to run the method, and its return value becomes the call's result. * @returns A method decorator that records the around advice. */ export declare function around(advice: AroundAdvice): (_v: unknown, context: ClassMethodDecoratorContext) => void; /** * A container post-processor that proxies instances whose methods carry * `@before`/`@after`/`@around` advice. Registered automatically by `createApp`. * Self-invocation inside a method reaches the raw object, so a method's calls * to its own other methods are not advised. */ export declare const aspectProcessor: PostProcessor; //# sourceMappingURL=aop.d.ts.map