import { EventEmitter } from 'eventemitter3' export class Primitive { name?: string function: Function functionIndex: number items: Array type: 'parallel' | 'sequence' _functionTreePrimitive: boolean outputs?: { [name: string]: Primitive } } export type TFunctionTreeExecutable = | Primitive | Function | TPath | TSequenceArray type TPath = { [key: string]: TSequenceArray | Function } type TSequenceArray = Array interface IPayload { [key: string]: any [key: number]: any } export interface IPath { path: string payload: IPayload } type TContextProviders = { [key: string]: Provider } export class FunctionTree extends EventEmitter { constructor(contextProviders?: TContextProviders) run(sequence: TSequenceArray, payload?: IPayload): Promise } export interface IBaseContext { path: any resolve: IResolve } export interface IContext extends IBaseContext { props: T } type TTagFactory = ( path: TemplateStringsArray | string[], ...values: any[] ) => Tag export function createTemplateTag( tagName: string, getValue: (path: string, context: IBaseContext) => T ): TTagFactory export function extractValueWithPath(obj: any, path: string): T export function resolveObject(obj: any): ResolveValue type ProviderCb = (context: IContext) => { [key: string]: Function } export class Provider { constructor( definition: | { [key: string]: (this: { context: IContext }, ...args: any[]) => void } | ProviderCb ) } export class Path implements IPath { path: string payload: IPayload constructor(path: string, payload: IPayload) toJS(): IPath } export function sequence(items: Function | TSequenceArray): () => void export function sequence( items: Function | TSequenceArray ): (props: Props) => void export function sequence( name: string, items: Function | TSequenceArray ): () => void export function sequence( name: string, items: Function | TSequenceArray ): (props: Props) => void export function parallel(items: Array): () => void export function parallel( items: Array ): (props: Props) => void export function parallel( name: string, items: Array ): () => void export function parallel( name: string, items: Array ): (props: Props) => void export class ResolveValue {} export class Tag extends ResolveValue { constructor() getPath(getters: any): string getValue(getters: any): T type: string } export interface IResolve { isTag(arg: any, ...types: string[]): arg is Tag isResolveValue(arg: any): arg is ResolveValue path(tag: Tag): string value(value: Tag, overrideContext?: any): T value(value: ResolveValue, overrideContext?: any): T value(value: Tag | T, overrideContext?: any): T value(value: ResolveValue | T, overrideContext?: any): T }