import type { SandboxSession } from '../sandbox/session'; type AnyFunction = (...args: any[]) => any; export type ScriptedSandboxMethod = { [TKey in keyof SandboxSession]-?: NonNullable extends AnyFunction ? TKey : never; }[keyof SandboxSession]; type SandboxMethodFunction = Extract, AnyFunction>; type SandboxMethodArgs = Parameters>; type SandboxMethodResult = Awaited>>; type ScriptedSandboxResponderResult = ReturnType> extends PromiseLike ? SandboxMethodResult | PromiseLike> : ReturnType>; export type RecordedSandboxCall = Readonly<{ /** The zero-based position of this call in `calls`. */ index: number; /** The invoked method. New SDK versions may add method names. */ method: string; /** Detached invocation-time arguments in parameter order. */ args: readonly unknown[]; }>; export type ScriptedSandboxCallFor = Readonly<{ index: number; method: TMethod; args: Readonly>; }>; type ScriptedSandboxMatcher = (...args: SandboxMethodArgs) => boolean | void; type ScriptedSandboxResponder = (call: ScriptedSandboxCallFor) => ScriptedSandboxResponderResult; type ScriptedSandboxStepBase = { method: TMethod; match?: ScriptedSandboxMatcher; }; type ScriptedSandboxResultStep = ScriptedSandboxStepBase & { result: SandboxMethodResult; respond?: never; error?: never; }; type ScriptedSandboxResponderStep = ScriptedSandboxStepBase & { respond: ScriptedSandboxResponder; result?: never; error?: never; }; type ScriptedSandboxErrorStep = ScriptedSandboxStepBase & { error: unknown; result?: never; respond?: never; }; type ScriptedSandboxStep = ScriptedSandboxResultStep | ScriptedSandboxResponderStep | ScriptedSandboxErrorStep; export type ScriptedSandboxInput = { [TCurrentMethod in TMethod]: ScriptedSandboxStep; }[TMethod]; export type ScriptedSandboxSession = SandboxSession & Required> & { /** All calls recorded by this session in invocation order. */ readonly calls: readonly RecordedSandboxCall[]; /** The number of scripted steps that have not been consumed. */ readonly remainingSteps: number; /** Throws when the script still contains unconsumed steps. */ assertComplete(): void; }; export type InvalidScriptedSandboxStepReason = 'invalid_input' | 'unknown_method' | 'invalid_matcher' | 'invalid_outcome'; export declare class InvalidScriptedSandboxStepError extends Error { readonly reason: InvalidScriptedSandboxStepReason; /** The zero-based position of the invalid factory input. */ readonly inputIndex: number; readonly method?: string; constructor(options: { reason: InvalidScriptedSandboxStepReason; inputIndex: number; message: string; method?: string; }); } export declare class UnexpectedSandboxCallError extends Error { /** The zero-based position of the call in `calls`. */ readonly callIndex: number; readonly actualMethod: string; readonly expectedMethod?: string; readonly remainingSteps: number; constructor(options: { callIndex: number; actualMethod: string; expectedMethod?: string; remainingSteps: number; }); } export declare class SandboxCallMatcherError extends Error { /** The zero-based position of the call in `calls`. */ readonly callIndex: number; readonly method: string; constructor(call: RecordedSandboxCall); } export declare class UnconsumedSandboxStepsError extends Error { readonly remainingSteps: number; readonly pendingMethods: readonly string[]; constructor(pendingMethods: readonly string[]); } /** * Creates a deterministic sandbox session with only the scripted optional * methods installed on the returned object. */ export declare function scriptedSandboxSession(inputs: TInputs): ScriptedSandboxSession; export declare function scriptedSandboxSession(inputs: Iterable>): ScriptedSandboxSession; export declare function scriptedSandboxSession(): ScriptedSandboxSession; export {};