import { ScenarioApi } from "./api"; import * as T from "./types"; interface ApiPlayers { players: (config: Config, data?: any) => Promise; } declare type ApiMachineConfigs = ApiPlayers; declare type ApiPlayerConfigs = ApiPlayers; /** * A Runner is provided by the [Orchestrator], but it is exposed to the middleware * author so that it can be called in the appropriate context */ export declare type Runner = (f: A) => Promise; /** RunnerS assumes a normal Scenario */ export declare type RunnerS = (f: Scenario) => Promise; /** The default Scenario function type which takes a single argument */ export declare type Scenario = (s: S) => Promise; /** A scenario function which takes two arguments */ export declare type Scenario2 = (s: S, t: T) => Promise; /** A scenario function which takes three arguments */ export declare type Scenario3 = (s: S, t: T, u: U) => Promise; /** A scenario function which takes four arguments */ export declare type Scenario4 = (s: S, t: T, u: U, v: V) => Promise; /** * Middleware is a composable decorator for scenario functions. A MiddlewareS takes two functions: * - the function which will run the scenario * - the scenario function itself * * With these, as a middleware author, you are free to create a new scenario function * that wraps the original one, and then use the `run` function to eventually execute * that scenario. The purpose of exposing the `run` function is to allow the middleware * to set up extra context outside of the running of the scenario, e.g. for integrating * with test harnesses. */ export declare type Middleware = (run: Runner, original: A) => Promise; /** Middleware assumes mapping from a normal Scenario to another */ export declare type MiddlewareS = (run: RunnerS, original: Scenario) => Promise; /** The no-op middleware */ export declare const unit: (run: RunnerS, f: Scenario) => Promise; /** Compose two middlewares, typesafe */ export declare const compose: (x: Middleware, y: Middleware) => Middleware; /** Compose 2 middlewares, typesafe. Same as `compose` */ export declare const compose2: (x: Middleware, y: Middleware) => Middleware; /** Compose 3 middlewares, typesafe */ export declare const compose3: (a: Middleware, b: Middleware, c: Middleware) => Middleware; /** Compose 4 middlewares, typesafe */ export declare const compose4: (a: Middleware, b: Middleware, c: Middleware, d: Middleware) => Middleware; /** Compose 5 middlewares, typesafe */ export declare const compose5: (a: Middleware, b: Middleware, c: Middleware, d: Middleware, e: Middleware) => Middleware; /** * Combine multiple middlewares into a single middleware. * NOT typesafe, i.e. type info is lost, but convenient. * The middlewares are applied in the *reverse order* that they're provided. * i.e. the middleware at the end of the chain is the one to act directly on the user-supplied scenario, * and the first middleware is the one to provide the clean vanilla scenario that the orchestrator knows how to run * So, if using something fancy like `tapeExecutor`, put it at the beginning of the chain. */ export declare const combine: (...ms: any[]) => any; /** * Given the `tape` module, tapeExecutor produces a middleware * that combines a scenario with a tape test. * It registers a tape test with the same description as the scenario itself. * Rather than the usual single ScenarioApi parameter, it expands the scenario function * signature to also accept tape's `t` object for making assertions * If the test throws an error, it registers the error with tape and does not abort * the entire test suite. * * NB: This has had intermittent problems that seemed to fix themselves magically. * Tape is a bit brittle when it comes to dynamically specifying tests. * Beware... * * If problems persist, it may be necessary to resolve this promise immediately so that * all tape tests can be registered synchronously. Then it is a matter of getting the * entire test suite to await the end of all tape tests. It could be done by specifying * a parallel vs. serial mode for test running. */ export declare const tapeExecutor: (tape: any) => Middleware, Scenario>; /** * Run tests in series rather than in parallel. * Needs to be invoked as a function so types can be inferred at moment of creation. */ export declare const runSeries: () => Middleware; /** * Take all configs defined for all machines and all players, * merge the configs into one big TOML file, * and create a single player on the local machine to run it. */ export declare const singleConductor: MiddlewareS; export declare const callSync: (run: any, f: any) => any; /** * Allow a test to skip the level of machine configuration * This middleware wraps the player configs in the "local" machine */ export declare const localOnly: MiddlewareS; /** * Allow a test to skip the level of machine configuration * This middleware finds a new machine for each player, and returns the * properly wrapped config specifying the acquired machine endpoints */ export declare const machinePerPlayer: (trycpEndpoints: string[]) => MiddlewareS>, ApiPlayers>>>; export {};