export interface GraphNodeProps { readonly displayName?: string; readonly data?: A; } export declare class GraphNode { readonly id: string; static of(id: string, data: A, displayName?: string): GraphNode; readonly dependencies: GraphNode[]; readonly data?: A; readonly displayName?: string; private _parentGraph?; constructor(id: string, props?: GraphNodeProps); /** * A graph-wide unique identifier for this node. Rendered by joining the IDs * of all ancestors with hyphens. */ get uniqueId(): string; /** * The union of all dependencies of this node and the dependencies of all * parent graphs. */ get allDeps(): GraphNode[]; dependOn(...dependencies: Array | undefined>): void; ancestorPath(upTo: GraphNode): GraphNode[]; rootPath(): GraphNode[]; get root(): GraphNode; get rootGraph(): Graph; get parentGraph(): Graph | undefined; /** * @internal */ _setParentGraph(parentGraph: Graph): void; toString(): string; } /** * A dependency set that is constructed over time * * It doesn't matter in what order sources and targets for the dependency * relationship(s) get added. This class can serve as a synchronization * point if the order in which graph nodes get added to the graph is not * well-defined. * * You can think of a DependencyBuilder as a vertex that doesn't actually exist in the tree: * * ┌────┐ ┌────┐ * │ P1 │◀─┐ ┌──│ S1 │ * └────┘ │ .─. │ └────┘ * ├──( B )◀─┤ * ┌────┐ │ `─' │ ┌────┐ * │ P2 │◀─┘ └──│ S2 │ * └────┘ └────┘ * * Ultimately leads to: { S1 -> P1, S1 -> P2, S2 -> P1, S2 -> P2 }. */ export declare class DependencyBuilder { private readonly _producers; private readonly _consumers; /** * Add a producer: make all nodes added by 'dependBy' depend on these */ dependOn(...targets: GraphNode[]): this; /** * Add a consumer: make these nodes depend on all nodes added by 'dependOn'. */ dependBy(...sources: GraphNode[]): this; /** * Whether there are any consumers (nodes added by 'dependBy') but no producers (nodes added by 'dependOn') */ get hasUnsatisfiedConsumers(): boolean; get consumers(): ReadonlyArray>; consumersAsString(): string; } /** * A set of dependency builders identified by a given key. */ export declare class DependencyBuilders { private readonly builders; for(key: K): DependencyBuilder; /** * @deprecated Use 'for' */ get(key: K): DependencyBuilder; unsatisfiedBuilders(): [K, DependencyBuilder][]; } export interface GraphProps extends GraphNodeProps { /** * Initial nodes in the workflow */ readonly nodes?: GraphNode[]; } export declare class Graph extends GraphNode { /** * The 3rd parameter looks weird because it has to be structurally compatible with `GraphNode.of()`, * but we want to add `displayName` at the end, really. */ static of(id: string, data: A, displayNameOrNodes?: string | GraphNode[], displayName?: string): Graph; private readonly children; constructor(name: string, props?: GraphProps); get nodes(): Set>; tryGetChild(name: string): GraphNode | undefined; containsId(id: string): boolean; contains(node: GraphNode): boolean; add(...nodes: Array>): void; absorb(other: Graph): void; /** * Return topologically sorted tranches of nodes at this graph level */ sortedChildren(fail?: boolean): GraphNode[][]; /** * Return a topologically sorted list of non-Graph nodes in the entire subgraph */ sortedLeaves(): GraphNode[][]; render(): string; renderDot(): string; consoleLog(_indent?: number): void; /** * Return the union of all dependencies of the descendants of this graph */ private deepDependencies; /** * Return all non-Graph nodes */ allLeaves(): GraphNodeCollection; } /** * A collection of graph nodes */ export declare class GraphNodeCollection { readonly nodes: GraphNode[]; constructor(nodes: Iterable>); /** * Add one or more dependencies to all nodes in the collection */ dependOn(...dependencies: Array | undefined>): void; /** * Return the topographically first node in the collection */ first(): GraphNode; /** * Returns the graph node that's shared between these nodes */ commonAncestor(): GraphNode; toString(): string; } export declare function isGraph(x: GraphNode): x is Graph;