/** * Pure Terraform dependency-graph builder for the carve-out advisor (#214 T1). * * Input is the JSON tree `@cdktf/hcl2json` produces (`Hcl2JsonTree`) plus the * traversal accessors its expression AST found per interpolated string * (`ExpressionRefs`, resolved in `parse.ts` — #998). Tokenizing `${...}` * expression bodies is the AST's job — a quoted address inside an expression * (`var.m["aws_s3_bucket.assets.arn"]`) or an escaped `$${...}` literal is not * a reference, which the regex scan this replaced could not tell. This module * only classifies the accessors the AST produced: no wasm, no filesystem, so * graph building stays unit-testable on hand-written fixtures. */ import type { Hcl2JsonTree, TfEdge, TfGraph } from "./types.js"; /** * Traversal accessors per interpolated string, as the hcl2json expression AST * reports them (`getReferencesInExpression`): `"${aws_s3_bucket.assets.arn}"` * maps to `["aws_s3_bucket.assets.arn"]`. Keys are the raw hcl2json string * values; a missing key means the expression yielded no references. */ export type ExpressionRefs = ReadonlyMap; interface RawRef { address: string; attr?: string; /** The referring block's top-level attribute the reference sits in (#998). */ via?: string; } /** * Classify one AST traversal accessor into a resource/module/data reference. * `var.*`/`local.*`/`each.*`-headed accessors are not references; quoted map * keys and numeric indexes never become the attribute. */ export declare function refFromAccessor(accessor: string): RawRef | null; /** * Every string value carrying an interpolation across the tree's resource, * module and output blocks — exactly the expressions `parse.ts` must resolve * through the AST before `buildGraph` can classify them. */ export declare function collectExpressions(tree: Hcl2JsonTree): string[]; /** * Build the dependency graph from a merged hcl2json tree. * * `resource` and `module` blocks become nodes. `data` sources are NOT nodes * (they are not carvable infrastructure), but a reference *to* a data source * marks the referring node dynamic. An edge is recorded only when its target * resolves to a known resource/module node — references to `var`/`local`/data * are dropped. * * `output` blocks are not nodes either — nothing carves an output — but they * do reference, and a reference to a carved resource breaks the surviving plan * exactly like a resource's does. So an output contributes an edge tagged * `fromKind: "output"` from the pseudo-address `output.` (#1638), * which the scorer weights lower and `carve bridge` patches. */ export declare function buildGraph(tree: Hcl2JsonTree, exprRefs: ExpressionRefs): TfGraph; /** Edges where something in the surviving Terraform depends on `address`. */ export declare function inboundEdges(graph: TfGraph, address: string): TfEdge[]; /** Edges where `address` depends on other nodes (each → a deferred deploy-time input). */ export declare function outboundEdges(graph: TfGraph, address: string): TfEdge[]; export {}; //# sourceMappingURL=graph.d.ts.map