//#region src/parameter/Fetcher.d.ts interface NextCallback { (error?: Error, value?: PipeResult): void; disable: () => void; } interface NextCallbacks { wrappers: NextCallback[]; holding: boolean; held: { error?: Error; value?: PipeResult; }[]; onConsumed?: () => void; onError?: (err: Error) => boolean; pipeIndex?: number; } declare class Fetcher { private keys; private _fetch; private raw; hasNext: boolean; constructor(parameter: PipeParameter | undefined, flag?: string); fetch(container: PipeResult, args?: PipeResult[], functions?: FunctionContainer, nextCallbacks?: NextCallbacks): PipeOutput; private lookup; private value; hasUnresolved(container: PipeResult, functions?: FunctionContainer): boolean; fetchNothing(_container: PipeResult, args: PipeResult[], _functions?: FunctionContainer, _nextCallbacks?: NextCallbacks): PipeOutput; fetchSingle(container: PipeResult, _args: PipeResult[], functions?: FunctionContainer, _nextCallbacks?: NextCallbacks): PipeOutput; fetchAsArray(container: PipeResult, _args: PipeResult[], functions?: FunctionContainer, nextCallbacks?: NextCallbacks): PipeOutput; fetchAsObject(container: PipeResult, _args: PipeResult[], functions?: FunctionContainer, nextCallbacks?: NextCallbacks): PipeOutput; } //#endregion //#region src/parameter/Producer.d.ts interface ResultOutput { output: PipeOutput; terminal: boolean; } declare class Producer { private keys; private _produce; private inputMode; private form; private resultName?; constructor(parameter: PipeParameter | undefined, flag?: string); produce(result: PipeResult, errorPath?: boolean): PipeOutput; get isResult(): boolean; produceResult(result: PipeResult): ResultOutput; expectValue(): void; private specLabel; produceOutput(result: PipeResult, errorPath?: boolean): PipeOutput; produceSingle(result: PipeResult): PipeOutput; produceFromArray(result: PipeResult): PipeOutput; produceFromObject(result: PipeResult): PipeOutput; private inputSource; } //#endregion //#region src/pipeline/Pipe.d.ts interface Pipe$1 { fn?: PipeFunction | null; not?: boolean; fnName: string; optional?: boolean; fetcher: Fetcher; producer: Producer; injected: boolean; } interface InputPipe { fnName: string; producer: Producer; } type PipeDefinition = [PipeFunction, PipeParameter?, PipeParameter?]; //#endregion //#region src/common.d.ts declare class NextCalledTwiceError extends Error { constructor(); } declare class OutputNameError extends Error { constructor(message: string); } declare class OutputKeyError extends Error { constructor(message: string); } declare class AmbiguousContinuationError extends Error { constructor(message: string); } declare class PipelineAbortedError extends Error { readonly reason: unknown; constructor(reason?: unknown); } interface AbortSignalLike { readonly aborted: boolean; readonly reason?: unknown; addEventListener(type: string, listener: () => void): void; removeEventListener(type: string, listener: () => void): void; } interface AsyncPipelineRunner { (...args: unknown[]): Promise; withSignal(signal: AbortSignalLike, ...args: unknown[]): Promise; } type AnyFunction = (...args: never[]) => unknown; type PipeResult = unknown; type PipeOutput = PipeResult | PipeResult[] | { [key: string]: PipeResult; }; type ResultValue = { value: T; reason?: never; }; type ResultReason = { reason: R; value?: never; }; type Result = ResultValue | ResultReason; type PipelineExitVia = 'value' | 'reason' | 'halt' | 'error' | 'abort'; interface PipelineExit { via: PipelineExitVia; step: number | null; name: string | null; reason?: PipeResult; error: unknown; } type ExitHandler = (exit: PipelineExit, container: ResultContainer) => void; type ReasonHandler = (reason: PipeResult, exit: PipelineExit, container: ResultContainer) => void; interface ResultContainer { [key: string]: PipeResult; } type PipeFunction = string | AnyFunction | Function; type PipeName = string; type PipeRename = `${string}:${string}`; type PipeParameter = PipeName | PipeRename | string[]; interface FunctionContainer { [key: string]: unknown; } interface PipelineBase { readonly name: string; readonly pipes: Pipe$1[]; readonly inputPipes?: InputPipe[]; readonly functions: FunctionContainer; readonly errorHandler?: AnyFunction; readonly exitHandlers?: ExitHandler[]; readonly reasonHandler?: ReasonHandler; } //#endregion //#region src/typed.d.ts interface TypedState { deps: object; args: readonly unknown[]; ctx: object; gates: object; skipped: string; late: string; stopped: boolean; async: boolean; started: boolean; handled: boolean; observed: boolean; } interface TypedError { readonly problem: Message; } type Empty = Record; type Flat = { [K in keyof T]: T[K]; }; type Merge = Flat & B>; type Keys = keyof T & string; type Either = A extends true ? true : B; type IsAny = 0 extends 1 & T ? true : false; type IsAsync = IsAny extends true ? false : [Extract>] extends [never] ? false : true; type RequiredKeys = { [K in keyof V]-?: Record extends Pick ? never : K; }[keyof V]; type IsOpen = string extends Keys ? true : false; type ReservedOutput = 'next' | (IsOpen extends true ? never : Keys); type Checked = [Problem] extends [never] ? Ok : TypedError; type TypedNext = (error?: unknown, value?: unknown) => void; type KnownName = Keys | Keys; type InputName = KnownName | 'next'; type InputValue = K extends 'next' ? TypedNext : K extends Keys ? S['ctx'][K] | (K extends S['skipped'] ? undefined : never) : K extends Keys ? S['deps'][K] : never; type InputSpec = InputName | readonly InputName[] | null | undefined; type InputTuple = K extends readonly string[] ? [...{ [I in keyof K]: InputValue; }] : K extends string ? [InputValue] : [...S['args']]; type UsesNext = K extends readonly string[] ? 'next' extends K[number] ? true : false : K extends 'next' ? true : false; type Produced = UsesNext extends true ? unknown : R; type OutputSpec = string | readonly string[] | undefined; type ValueArm = Extract['value']; type ReasonArm = Extract['reason']; type Positional = { [I in keyof O as I extends `${number}` ? O[I] extends string ? O[I] : never : never]: I extends keyof V ? V[I] : V[number]; }; type FitsTuple = number extends V['length'] ? true : O['length'] extends Partial['length'] ? true : false; type BuiltIn = Date | RegExp | Error | Promise | Map | Set | WeakMap | WeakSet | ArrayBuffer; type AllMethods = [Keys] extends [never] ? true : V[Keys] extends AnyCallable ? true : false; type IsPlainObject = V extends AnyCallable ? false : V extends readonly unknown[] ? false : V extends BuiltIn ? false : V extends object ? AllMethods extends true ? false : true : false; type IsEmptyArray = K extends readonly [] ? true : false; type Picked = { [K in O[number]]: K extends keyof V ? V[K] : never; }; type Destructured = V extends readonly unknown[] ? Positional : Picked; type Bound = O extends `result:${infer N}` ? { [P in N]: ValueArm>; } : O extends '{...}' ? Awaited : O extends readonly string[] ? Destructured> : O extends string ? { [P in O]: Awaited; } : Empty; type GateBindings = O extends `result:${infer N}` ? Merge ? S['gates'][N] : never) | ReasonArm>; }> : S['gates']; type IsGate = O extends `result:${string}` ? true : false; interface Change { add: unknown; optional: boolean; stop: boolean; async: boolean; gates: object; start: boolean; } type Bind = { deps: S['deps']; args: S['args']; ctx: Merge; gates: C['gates']; skipped: Exclude> | (C['optional'] extends true ? Keys : never); late: S['late'] | (S['stopped'] extends true ? Keys : never); stopped: Either; async: Either; started: Either; handled: S['handled']; observed: S['observed']; }; type SetFlag = Flat & { [P in F]: true; }>; type GateNeedsResult = 'A "result:" output requires the pipe to return { value } | { reason }'; type SpreadNeedsObject = 'A "{...}" output requires the pipe to return a plain object'; type NotTypedYet = 'Brace picks and src:dst renames are not typed yet; use an array output or a single name'; type ReservedName = 'This output name is reserved or shadows a configured dependency'; type DestructureMismatch = 'An array output requires the pipe to return an array or an object with every named key'; type DestructureTooLong = 'An array output names more positions than the returned tuple has'; type EmptyNames = 'An input, output, or end spec cannot be an empty array'; type EmptyName = 'A name cannot be an empty string'; type BraceInArray = 'A brace spec is not allowed inside an array'; type MalformedResultName = 'A "result:" output needs a non-empty name without ":"'; type HandlerNotCallable = 'This error handler dependency is not a function'; type InterceptedName = 'The names "input" and "error" are dispatched to .input() and .error() by the runtime; rename the dependency'; type OptionalKey = 'An array output names an optional property; the runtime throws when it is absent'; type OutputProblem = O extends undefined ? never : O extends '' ? EmptyName : O extends `result:${infer N}` ? N extends '' | `${string}:${string}` ? MalformedResultName : N extends ReservedOutput ? ReservedName : IsAny> extends true ? never : Awaited extends Result ? never : GateNeedsResult : O extends '{...}' ? IsAny> extends true ? never : IsPlainObject> extends true ? [Keys> & ReservedOutput] extends [never] ? never : ReservedName : SpreadNeedsObject : O extends `{${string}}` | `${string}:${string}` ? NotTypedYet : O extends readonly string[] ? IsEmptyArray extends true ? EmptyNames : '' extends O[number] ? EmptyName : [Extract] extends [never] ? [Extract] extends [never] ? [O[number] & ReservedOutput] extends [never] ? IsAny> extends true ? never : Awaited extends readonly unknown[] ? FitsTuple> extends true ? never : DestructureTooLong : O[number] extends keyof Awaited ? O[number] extends RequiredKeys> ? never : OptionalKey : DestructureMismatch : ReservedName : NotTypedYet : BraceInArray : O extends ReservedOutput ? ReservedName : never; type AfterFunctionPipe = Bind>; optional: false; stop: IsGate; async: Either, UsesNext>; gates: GateBindings>; start: true; }>; type Sigils = N extends `!${infer Rest}` ? Rest extends `?${infer Base}` ? { base: Base; not: true; optional: true; } : { base: Rest; not: true; optional: false; } : N extends `?${infer Base}` ? { base: Base; not: false; optional: true; } : { base: N; not: false; optional: false; }; type InjectedSpec = KnownName | `!${KnownName}` | `?${string}` | `!?${string}`; type Resolved = InputValue['base']>; type AnyCallable = (...args: never[]) => unknown; type Callable = [F] extends [never] ? (...args: unknown[]) => unknown : F extends AnyCallable ? F : never; type IsFlowControl = Not extends true ? true : [F] extends [never] ? false : [F] extends [boolean] ? true : false; type InjectedReturn = ReturnType>>; type InjectedResult = Produced>; type InjectedInputMismatch = 'The declared inputs do not match the parameters of the injected function'; type InjectedNotCallable = 'This dependency is neither a function nor a boolean'; type InjectedKindProblem = N extends 'input' | 'error' ? InterceptedName : [Resolved] extends [never] ? never : [Resolved] extends [boolean] ? never : Resolved extends AnyCallable ? never : InjectedNotCallable; type EmptyNamesProblem = IsEmptyArray extends true ? EmptyNames : never; type AmbiguousContinuation = 'A pipe that declares "next" must not return a thenable; use one continuation channel'; type ContinuationProblem = UsesNext extends true ? (IsAsync extends true ? AmbiguousContinuation : never) : never; type InjectedInputProblem = IsFlowControl, Sigils['not']> extends true ? never : [InputTuple] extends [Parameters>>] ? never : InjectedInputMismatch; type AfterInjectedPipe = IsFlowControl, Sigils['not']> extends true ? Bind>; gates: S['gates']; start: true; }> : Bind>; optional: Sigils['optional']; stop: IsGate; async: Either>, UsesNext>; gates: GateBindings>; start: true; }>; type ArgAt = I extends keyof Args ? Args[I] : number extends Args['length'] ? Args[number] | undefined : undefined; type InputBindings = K extends readonly string[] ? { [I in keyof K as I extends `${number}` ? (K[I] extends string ? K[I] : never) : never]: ArgAt; } : K extends string ? { [P in K]: ArgAt; } : Empty; type InputNamesProblem = K extends '' ? EmptyName : K extends `{${string}}` ? NotTypedYet : K extends 'next' ? ReservedName : K extends readonly string[] ? IsEmptyArray extends true ? EmptyNames : '' extends K[number] ? EmptyName : [Extract] extends [never] ? 'next' extends K[number] ? ReservedName : never : BraceInArray : never; type AfterInput = Bind; optional: false; stop: false; async: false; gates: S['gates']; start: false; }>; type ErrorInputName = 'error' | KnownName; type ErrorValue = K extends 'error' ? unknown : K extends Keys ? S['ctx'][K] | undefined : K extends Keys ? S['deps'][K] : never; type ErrorTuple = K extends readonly string[] ? [...{ [I in keyof K]: ErrorValue; }] : K extends string ? [ErrorValue] : [unknown]; type Reasons = S['gates'][Keys]; type EndSpec = KnownName | readonly KnownName[]; type EndSingle = N extends Keys ? S['ctx'][N] | (N extends Keys ? S['gates'][N] : never) | (N extends S['skipped'] | S['late'] ? undefined : never) : N extends Keys ? S['deps'][N] : never; type EndValue = O extends readonly string[] ? [...{ [I in keyof O]: EndSingle; }] : EndSingle; type SyncRunner = (...args: [...S['args']]) => Out; type SyncEndUnavailable = 'This pipeline has an async pipe; use endAsync()'; interface SyncEnd { (): SyncRunner; >(output: O): Checked, SyncRunner>>; } interface SyncEndWhenAsync { (): SyncRunner; (output: SyncEndUnavailable): never; } interface TypedAsyncRunner { (...args: [...Args]): Promise; withSignal(signal: AbortSignalLike, ...args: [...Args]): Promise; } type InputAfterPipe = 'An input pipe must come before the first pipe'; type PipeAfterError = 'Adding a pipe after the error handler is not allowed'; type SecondErrorHandler = 'Each pipeline can have only one error handler'; type SecondReasonHandler = 'Each pipeline can have only one reason handler'; type InputMethod = (names: K) => Checked, TypedPipeline>>; interface PipeMethod { , const K extends InputSpec = undefined, const O extends OutputSpec = undefined>(name: N, input?: K, output?: O): Checked | EmptyNamesProblem | ContinuationProblem> | InjectedInputProblem | OutputProblem>, TypedPipeline>>; = undefined, const O extends OutputSpec = undefined>(fn: (...args: InputTuple) => R, input?: K, output?: O): Checked | ContinuationProblem | OutputProblem>, TypedPipeline>>; } type ErrorHandlerProblem = H extends string ? InputValue extends AnyCallable ? [ErrorTuple] extends [Parameters>] ? never : InjectedInputMismatch : HandlerNotCallable : never; type ErrorMethod = ) => unknown) | KnownName, const K extends ErrorInputName | readonly ErrorInputName[] = 'error'>(handler: H, input?: K) => Checked | ErrorHandlerProblem, TypedPipeline>>; type ReasonMethod = (handler: (reason: Reasons, exit: PipelineExit, container: ResultContainer) => unknown) => TypedPipeline>; interface TypedPipeline { readonly input: S['started'] extends true ? (names: InputAfterPipe) => never : InputMethod; readonly pipe: S['handled'] extends true ? (fn: PipeAfterError) => never : PipeMethod; readonly error: S['handled'] extends true ? (handler: SecondErrorHandler) => never : ErrorMethod; readonly reason: S['observed'] extends true ? (handler: SecondReasonHandler) => never : ReasonMethod; onExit(handler: ExitHandler): TypedPipeline; readonly end: S['async'] extends true ? SyncEndWhenAsync : SyncEnd; endAsync(): TypedAsyncRunner; endAsync>(output: O): Checked, TypedAsyncRunner>>; } type InitialState = { deps: D; args: Args; ctx: Empty; gates: Empty; skipped: never; late: never; stopped: false; async: false; started: false; handled: false; observed: false; }; type TypedFactory = (name: string) => TypedPipeline>; declare function typed(deps?: D): TypedFactory; //#endregion //#region src/index.d.ts declare function superpipe(functions?: T): SuperPipeFactory; interface Pipeline { name: string; pipes: Pipe[]; errorHandler?: Pipe; deps: FunctionContainer; } interface Pipe { fn: ((...args: unknown[]) => unknown) | null; fnName: string | undefined; input: string[]; output?: string[]; not?: boolean; optional?: boolean; } interface PipelineAPI { input: (input?: PipeParameter) => PipelineAPI; pipe: (fn: PipeFunction, input?: PipeParameter, output?: PipeParameter) => PipelineAPI; error: (fn: PipeFunction, input?: PipeParameter) => PipelineAPI; onExit: (handler: ExitHandler) => PipelineAPI; reason: (handler: ReasonHandler) => PipelineAPI; end: (output?: PipeParameter) => Function; endAsync: (output?: PipeParameter) => AsyncPipelineRunner; } interface SuperPipeFactory { (name: string): PipelineAPI; (name: string, defs: PipeDefinition[]): (...args: unknown[]) => void; (name: string, defs?: PipeDefinition[]): PipelineAPI | ((...args: unknown[]) => void); } type Store = { next: (error?: unknown, value?: unknown) => void; error?: unknown; [key: string]: unknown; }; interface PipeState { fn: ((...args: unknown[]) => unknown) | null; not?: boolean; deps: FunctionContainer; input: string[]; output?: string[]; fnName: string | undefined; autoNext: boolean | 0; optional?: boolean; name: string; error?: unknown; result?: unknown; fnReturned?: boolean; } //#endregion export { type AbortSignalLike, AmbiguousContinuationError, type AnyFunction, type AsyncPipelineRunner, type FunctionContainer as Dependencies, type FunctionContainer, type ExitHandler, type InputSpec, NextCalledTwiceError, OutputKeyError, OutputNameError, type OutputSpec, Pipe, type PipeDefinition, type PipeDefinition as PipelineDefinition, type PipeFunction, type PipeName, type PipeOutput, type PipeParameter, type PipeRename, type PipeResult, PipeState, Pipeline, PipelineAPI, PipelineAbortedError, type PipelineBase, type PipelineExit, type PipelineExitVia, type ReasonHandler, type Result, type ResultContainer, type ResultReason, type ResultValue, Store, SuperPipeFactory, type TypedAsyncRunner, type TypedError, type TypedFactory, type TypedNext, type TypedPipeline, type TypedState, superpipe as default, typed }; //# sourceMappingURL=index.d.mts.map