import type { Action, ActionIdentifier, GetActionOpts } from "@garden-io/grow-sdk/actions/action"; import type { ActionType } from "@garden-io/grow-sdk/declarations/action-type"; import type { ResolvedActionImpl } from "../actions/base"; import { BaseAction } from "../actions/base"; export type DependencyRelationFilterFn = (node: ConfigGraphNode) => boolean; export type RenderedActionGraph = { nodes: RenderedNode[]; relationships: RenderedEdge[]; }; export type RenderedEdge = { dependant: RenderedNode; dependency: RenderedNode; }; export interface RenderedNode { name: string; key: string; disabled: boolean; } export type GraphNodes = { [key: string]: ConfigGraphNode; }; export interface ConfigGraphParams { actions: (Action | BaseAction)[]; } /** * A graph data structure that facilitates querying (recursive or non-recursive) of the project's dependency and * dependant relationships. */ export declare abstract class BaseConfigGraph> { protected dependencyGraph: GraphNodes; protected readonly actions: Record["name"], A>; constructor({ actions }: ConfigGraphParams); toSanitizedValue(): string; validate(): void; clone(): ConfigGraph; getActions({ refs, includeDisabled, }?: { refs?: (ActionIdentifier | string)[]; includeDisabled?: GetActionOpts["includeDisabled"]; }): BaseAction[]; getActionByRef(refOrString: ActionIdentifier | string, opts?: GetActionOpts): A; getActionByName(name: string, opts?: GetActionOpts): A; getNames(): string[]; /** * Returns all dependencies of a node in the graph. * * If recursive = true, also includes those dependencies' dependencies, etc. */ getDependencies({ name, recursive, filter, }: { name: string; recursive: boolean; filter?: DependencyRelationFilterFn; }): (A | undefined)[]; /** * Returns all dependants of a node in the graph. * * If recursive = true, also includes those dependants' dependants, etc. */ getDependants({ name, recursive, filter, }: { name: string; recursive: boolean; filter?: DependencyRelationFilterFn; }): (A | undefined)[]; /** * Same as getDependencies above, but returns the set union of the dependencies of the nodes in the graph */ getDependenciesForMany({ refs, recursive, filter, }: { refs: ActionIdentifier[]; recursive: boolean; filter?: DependencyRelationFilterFn; }): (A | undefined)[]; /** * Same as getDependants above, but returns the set union of the dependants of the nodes in the graph * having name = name (computed recursively or shallowly for all). */ getDependantsForMany({ names, recursive, filter, }: { names: string[]; recursive: boolean; filter?: DependencyRelationFilterFn; }): (A | undefined)[]; private getDependencyNodes; private getDependantNodes; private nodesToActions; render(): RenderedActionGraph; toMutableGraph(): MutableConfigGraph; protected addActionInternal(action: BaseAction): void; protected getNode(name: string, disabled: boolean): ConfigGraphNode; protected addRelation({ dependant, dependencyName }: { dependant: ConfigGraphNode; dependencyName: string; }): void; } export declare class ConfigGraph extends BaseConfigGraph> { } export declare class ResolvedConfigGraph extends BaseConfigGraph> { } export declare class MutableConfigGraph extends ConfigGraph { addAction(action: BaseAction): void; toConfigGraph(): ConfigGraph; } export interface ConfigGraphEdge { dependant: ConfigGraphNode; dependency: ConfigGraphNode; } export declare class ConfigGraphNode { name: string; disabled: boolean; dependencies: ConfigGraphNode[]; dependants: ConfigGraphNode[]; constructor(name: string, disabled: boolean); render(): RenderedNode; addDependency(node: ConfigGraphNode): void; addDependant(node: ConfigGraphNode): void; /** * Returns the dependencies of this node, optionally recursively. * Omits disabled dependency nodes other than build dependencies, and does not recurse past them. * If filter is provided, ignores matching nodes and their dependencies. * Note: May return duplicate entries (deduplicated in DependencyGraph#toRelations). */ getDependencies(recursive: boolean, filter?: DependencyRelationFilterFn): ConfigGraphNode[]; /** * Returns the dependants of this node, optionally recursively. * Omits disabled dependant nodes other than build dependants, and does not recurse past them. * If filter is provided, ignores matching nodes and their dependants. * Note: May return duplicate entries (deduplicated in DependencyGraph#toRelations). */ getDependants(recursive: boolean, filter?: DependencyRelationFilterFn): ConfigGraphNode[]; private traverse; toSanitizedValue(): string; }