@intentius/chant 0.41.20 → 0.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/carve-apply.d.ts +9 -0
- package/dist/cli/commands/carve-apply.d.ts.map +1 -1
- package/dist/cli/commands/carve-bridge.d.ts +7 -0
- package/dist/cli/commands/carve-bridge.d.ts.map +1 -1
- package/dist/cli/commands/carve-emit.d.ts +7 -0
- package/dist/cli/commands/carve-emit.d.ts.map +1 -1
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/handlers/carve-apply.d.ts.map +1 -1
- package/dist/cli/handlers/components.d.ts.map +1 -1
- package/dist/cli/handlers/explain.d.ts +11 -0
- package/dist/cli/handlers/explain.d.ts.map +1 -0
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/mcp/tools/explain.d.ts.map +1 -1
- package/dist/cli/registry.d.ts +2 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/codegen/docs-rule-scanning.d.ts +11 -0
- package/dist/codegen/docs-rule-scanning.d.ts.map +1 -1
- package/dist/codegen/okf-lexicon.d.ts +36 -0
- package/dist/codegen/okf-lexicon.d.ts.map +1 -0
- package/dist/codegen/package.d.ts +2 -1
- package/dist/codegen/package.d.ts.map +1 -1
- package/dist/components/verbs/sbom.d.ts +1 -1
- package/dist/components/verbs/sbom.d.ts.map +1 -1
- package/dist/components/verbs/vuln-gate.d.ts +15 -4
- package/dist/components/verbs/vuln-gate.d.ts.map +1 -1
- package/dist/components/verbs/vuln-scan.d.ts +18 -6
- package/dist/components/verbs/vuln-scan.d.ts.map +1 -1
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/deep-observation.d.ts +13 -0
- package/dist/deep-observation.d.ts.map +1 -1
- package/dist/lexicon.d.ts +3 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/observe.d.ts.map +1 -1
- package/dist/lifecycle/snapshot.d.ts.map +1 -1
- package/dist/okf.d.ts +57 -0
- package/dist/okf.d.ts.map +1 -0
- package/dist/terraform/__fixtures__/build-graph.d.ts +13 -0
- package/dist/terraform/__fixtures__/build-graph.d.ts.map +1 -0
- package/dist/terraform/adopt-state.d.ts +33 -1
- package/dist/terraform/adopt-state.d.ts.map +1 -1
- package/dist/terraform/bridge.d.ts +7 -1
- package/dist/terraform/bridge.d.ts.map +1 -1
- package/dist/terraform/carve.d.ts +12 -0
- package/dist/terraform/carve.d.ts.map +1 -1
- package/dist/terraform/excise.d.ts +31 -0
- package/dist/terraform/excise.d.ts.map +1 -0
- package/dist/terraform/graduate.d.ts +12 -0
- package/dist/terraform/graduate.d.ts.map +1 -1
- package/dist/terraform/graph.d.ts +35 -5
- package/dist/terraform/graph.d.ts.map +1 -1
- package/dist/terraform/manifest.d.ts +89 -0
- package/dist/terraform/manifest.d.ts.map +1 -0
- package/dist/terraform/parse.d.ts +9 -4
- package/dist/terraform/parse.d.ts.map +1 -1
- package/dist/terraform/types.d.ts +7 -0
- package/dist/terraform/types.d.ts.map +1 -1
- package/dist/terraform/unified-diff.d.ts +11 -0
- package/dist/terraform/unified-diff.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/__snapshots__/okf.test.ts.snap +381 -0
- package/src/cli/commands/carve-apply.test.ts +94 -2
- package/src/cli/commands/carve-apply.ts +62 -11
- package/src/cli/commands/carve-bridge.test.ts +82 -4
- package/src/cli/commands/carve-bridge.ts +79 -11
- package/src/cli/commands/carve-emit-state.test.ts +110 -1
- package/src/cli/commands/carve-emit.ts +184 -8
- package/src/cli/commands/init.ts +1 -1
- package/src/cli/handlers/carve-apply.ts +1 -0
- package/src/cli/handlers/components.ts +4 -2
- package/src/cli/handlers/explain.test.ts +93 -0
- package/src/cli/handlers/explain.ts +60 -0
- package/src/cli/handlers/lifecycle.ts +9 -7
- package/src/cli/main.ts +21 -5
- package/src/cli/mcp/server.test.ts +17 -0
- package/src/cli/mcp/tools/explain.ts +15 -3
- package/src/cli/registry.ts +2 -0
- package/src/codegen/__snapshots__/okf-lexicon.test.ts.snap +170 -0
- package/src/codegen/docs-rule-scanning.ts +35 -14
- package/src/codegen/okf-lexicon.test.ts +248 -0
- package/src/codegen/okf-lexicon.ts +303 -0
- package/src/codegen/package.ts +29 -4
- package/src/components/config-defaults.test.ts +30 -0
- package/src/components/verbs/__fixtures__/grype-with-kev-epss.json +1 -0
- package/src/components/verbs/__fixtures__/trivy-with-kev-epss.json +631 -0
- package/src/components/verbs/exploitability-roundtrip.test.ts +190 -0
- package/src/components/verbs/sbom.ts +1 -1
- package/src/components/verbs/vuln-gate.test.ts +144 -1
- package/src/components/verbs/vuln-gate.ts +61 -10
- package/src/components/verbs/vuln-scan.test.ts +94 -0
- package/src/components/verbs/vuln-scan.ts +44 -9
- package/src/config.test.ts +21 -0
- package/src/config.ts +18 -0
- package/src/deep-observation.test.ts +19 -0
- package/src/deep-observation.ts +32 -13
- package/src/lexicon.ts +3 -0
- package/src/lifecycle/observe.test.ts +18 -0
- package/src/lifecycle/observe.ts +10 -3
- package/src/lifecycle/snapshot.ts +5 -4
- package/src/okf.test.ts +169 -0
- package/src/okf.ts +308 -0
- package/src/terraform/__fixtures__/build-graph.ts +25 -0
- package/src/terraform/adopt-state.test.ts +34 -1
- package/src/terraform/adopt-state.ts +69 -2
- package/src/terraform/bridge.test.ts +38 -14
- package/src/terraform/bridge.ts +48 -14
- package/src/terraform/carve.test.ts +9 -7
- package/src/terraform/carve.ts +0 -0
- package/src/terraform/excise.test.ts +92 -0
- package/src/terraform/excise.ts +139 -0
- package/src/terraform/graduate.test.ts +73 -6
- package/src/terraform/graduate.ts +49 -0
- package/src/terraform/graph.test.ts +56 -10
- package/src/terraform/graph.ts +112 -45
- package/src/terraform/manifest.test.ts +105 -0
- package/src/terraform/manifest.ts +162 -0
- package/src/terraform/parse.test.ts +39 -1
- package/src/terraform/parse.ts +36 -9
- package/src/terraform/score.test.ts +8 -8
- package/src/terraform/state.test.ts +4 -4
- package/src/terraform/types.ts +7 -0
- package/src/terraform/unified-diff.test.ts +77 -0
- package/src/terraform/unified-diff.ts +146 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/lifecycle/snapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAsC,MAAM,YAAY,CAAC;AACzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/lifecycle/snapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAsC,MAAM,YAAY,CAAC;AACzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,SAAS,CAAC;AAiEnE,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,kBAAkB,EAAE,EAC7B,WAAW,EAAE,WAAW,EACxB,IAAI,CAAC,EAAE;IACL,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;qEACiE;IACjE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,GACA,OAAO,CAAC,kBAAkB,CAAC,CAmN7B"}
|
package/dist/okf.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Declarable } from "./declarable.js";
|
|
2
|
+
/**
|
|
3
|
+
* OKF bundle emitter (#1058, epic #1057) — projects a discovered entity graph
|
|
4
|
+
* into an Open Knowledge Format v0.2 bundle: a directory of markdown files
|
|
5
|
+
* with YAML frontmatter, per the spec at
|
|
6
|
+
* https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md
|
|
7
|
+
*
|
|
8
|
+
* One concept document per entity, `type` carrying the entity's resource type
|
|
9
|
+
* string, dependency edges as bundle-relative markdown links (the form the
|
|
10
|
+
* spec recommends for stability), and a root `index.md` grouping concepts into
|
|
11
|
+
* per-lexicon sections. Emit-only: OKF as project *input* is #1059.
|
|
12
|
+
*/
|
|
13
|
+
export declare const OKF_VERSION = "0.2";
|
|
14
|
+
/** One file of an OKF bundle: a bundle-relative path and its full content. */
|
|
15
|
+
export interface OkfFile {
|
|
16
|
+
/** Bundle-relative path, e.g. "aws/myBucket.md" or "index.md". */
|
|
17
|
+
path: string;
|
|
18
|
+
content: string;
|
|
19
|
+
}
|
|
20
|
+
/** The subset of a discovery result the emitter reads. */
|
|
21
|
+
export interface OkfBundleInput {
|
|
22
|
+
entities: Map<string, Declarable>;
|
|
23
|
+
dependencies: Map<string, Set<string>>;
|
|
24
|
+
}
|
|
25
|
+
/** Make an entity or lexicon name safe as a single path segment. */
|
|
26
|
+
export declare function slug(name: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Render a flat frontmatter mapping as a YAML block. Keys with undefined
|
|
29
|
+
* values are dropped; scalar quoting is `emitYAML`'s.
|
|
30
|
+
*/
|
|
31
|
+
export declare function frontmatter(fields: Record<string, string | undefined>): string;
|
|
32
|
+
/**
|
|
33
|
+
* Split a concept document into its frontmatter block and body. Returns
|
|
34
|
+
* undefined when the document does not start with a `---` delimited block.
|
|
35
|
+
* Exported for the conformance tests (and any future OKF consumer, #1059).
|
|
36
|
+
*/
|
|
37
|
+
export declare function splitFrontmatter(content: string): {
|
|
38
|
+
frontmatter: string;
|
|
39
|
+
body: string;
|
|
40
|
+
} | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Check a bundle against the OKF v0.2 conformance criteria (spec §11) and
|
|
43
|
+
* return every violation found: parseable frontmatter on every non-reserved
|
|
44
|
+
* `.md`, a non-empty `type` everywhere, a well-formed root `index.md`, and
|
|
45
|
+
* generated cross-link entries that are bundle-absolute (or external URLs).
|
|
46
|
+
* Empty result means conformant. Shared by the project-bundle tests (#1058)
|
|
47
|
+
* and every lexicon's bundle tests (#1060).
|
|
48
|
+
*/
|
|
49
|
+
export declare function okfConformanceProblems(files: OkfFile[]): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Build the OKF bundle for a discovered graph. Pure and deterministic: the
|
|
52
|
+
* same entities yield byte-identical files, so bundles are diffable and
|
|
53
|
+
* snapshot-testable. `projectPath` relativizes source-file paths so the
|
|
54
|
+
* bundle is portable.
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildOkfBundle(input: OkfBundleInput, projectPath?: string): OkfFile[];
|
|
57
|
+
//# sourceMappingURL=okf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"okf.d.ts","sourceRoot":"","sources":["../src/okf.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM/C;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,WAAW,QAAQ,CAAC;AAEjC,8EAA8E;AAC9E,MAAM,WAAW,OAAO;IACtB,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACxC;AAED,oEAAoE;AACpE,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGzC;AAWD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAQ9E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CASnG;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAoEjE;AA+BD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,CAwFrF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ExpressionRefs } from "../graph.js";
|
|
2
|
+
import type { Hcl2JsonTree, TfGraph } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Test-only stand-in for the hcl2json expression AST (`parse.ts`'s
|
|
5
|
+
* `resolveExpressionRefs`). Fixture expressions are simple `${<accessor>}`
|
|
6
|
+
* templates, so each one's accessor list is just its interpolation bodies.
|
|
7
|
+
* Production never takes this path — `parseTerraformDir` resolves every
|
|
8
|
+
* expression through `getReferencesInExpression`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function fixtureExprRefs(tree: Hcl2JsonTree): ExpressionRefs;
|
|
11
|
+
/** `buildGraph` over a hand-written fixture tree, accessors derived per {@link fixtureExprRefs}. */
|
|
12
|
+
export declare function buildFixtureGraph(tree: Hcl2JsonTree): TfGraph;
|
|
13
|
+
//# sourceMappingURL=build-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-graph.d.ts","sourceRoot":"","sources":["../../../src/terraform/__fixtures__/build-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEtD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,cAAc,CASlE;AAED,oGAAoG;AACpG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAE7D"}
|
|
@@ -10,14 +10,42 @@
|
|
|
10
10
|
* AWS carve-out table (`aws-resources.ts`) — the same table the advisor's tier
|
|
11
11
|
* map derives from, so every AWS type advise ranks can be emitted. Attributes
|
|
12
12
|
* without a mapping are preserved in a reference comment, never dropped.
|
|
13
|
+
*
|
|
14
|
+
* Deferred outbound inputs (#998): an attribute whose value the Terraform
|
|
15
|
+
* source read from a survivor (`vpc_id = aws_vpc.main.id`) is not a fact of
|
|
16
|
+
* the carved resource — it is a deploy-time input. Those props are emitted as
|
|
17
|
+
* `params.<name>` references instead of frozen literals, with the state's
|
|
18
|
+
* resolved value as the declared default (see `carve-emit.ts`'s scaffold).
|
|
13
19
|
*/
|
|
14
20
|
import type { StateResource } from "./state.js";
|
|
21
|
+
/** The core subpath the emitted source reads build parameters from. */
|
|
22
|
+
export declare const PARAMS_IMPORT = "@intentius/chant/params";
|
|
23
|
+
/**
|
|
24
|
+
* One deferred outbound input turned into a build parameter (#998). Derived
|
|
25
|
+
* from the boundary report's outbound edges + the state's resolved attributes
|
|
26
|
+
* in `carve-emit.ts`; consumed here (source substitution) and by the scaffold
|
|
27
|
+
* (`chant.config.ts` `buildParams` declaration).
|
|
28
|
+
*/
|
|
29
|
+
export interface DeferredParam {
|
|
30
|
+
/** Build-parameter name, source-referenceable (`params.<name>`). */
|
|
31
|
+
name: string;
|
|
32
|
+
/** The carved resource's own Terraform attribute the value enters through. */
|
|
33
|
+
tfAttr: string;
|
|
34
|
+
/** The survivor the Terraform source read, e.g. `aws_vpc.main`. */
|
|
35
|
+
survivor: string;
|
|
36
|
+
/** Survivor attribute(s) read, e.g. `["id"]`. */
|
|
37
|
+
attrs: string[];
|
|
38
|
+
/** The state-resolved value — the parameter's declared default. */
|
|
39
|
+
default?: string | number | boolean;
|
|
40
|
+
}
|
|
15
41
|
export interface AdoptedSource {
|
|
16
42
|
fileName: string;
|
|
17
43
|
content: string;
|
|
18
44
|
/** True when at least one attribute was mapped to a native prop. */
|
|
19
45
|
mapped: boolean;
|
|
20
46
|
nativeType: string;
|
|
47
|
+
/** Deferred params actually substituted into the emitted props (#998). */
|
|
48
|
+
parameterized: string[];
|
|
21
49
|
}
|
|
22
50
|
/** Is this Terraform type adoptable from state (has a native constructor)? */
|
|
23
51
|
export declare function canAdoptFromState(tfType: string): boolean;
|
|
@@ -27,6 +55,10 @@ export declare function supportedStateAdoptionTypes(): string[];
|
|
|
27
55
|
* Render chant source for a state-adopted resource. Emits the native
|
|
28
56
|
* constructor with mapped properties, plus a reference comment listing the
|
|
29
57
|
* Terraform attributes that were not mapped so nothing is silently dropped.
|
|
58
|
+
*
|
|
59
|
+
* A mapped attribute named by a `DeferredParam` renders as a `params.<name>`
|
|
60
|
+
* reference (a real chant build parameter) instead of the state literal —
|
|
61
|
+
* the value came from a survivor, so it stays overridable per build.
|
|
30
62
|
*/
|
|
31
|
-
export declare function adoptFromState(resource: StateResource): AdoptedSource | null;
|
|
63
|
+
export declare function adoptFromState(resource: StateResource, params?: DeferredParam[]): AdoptedSource | null;
|
|
32
64
|
//# sourceMappingURL=adopt-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adopt-state.d.ts","sourceRoot":"","sources":["../../src/terraform/adopt-state.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"adopt-state.d.ts","sourceRoot":"","sources":["../../src/terraform/adopt-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,uEAAuE;AACvE,eAAO,MAAM,aAAa,4BAA4B,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,uFAAuF;AACvF,wBAAgB,2BAA2B,IAAI,MAAM,EAAE,CAEtD;AAUD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,GAAE,aAAa,EAAO,GAAG,aAAa,GAAG,IAAI,CA+C1G"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* into a git-applyable patch. A carve never destroys or recreates; the runbook
|
|
19
19
|
* is reversible via `terraform import`.
|
|
20
20
|
*/
|
|
21
|
-
import type
|
|
21
|
+
import { type CarveReport } from "./carve.js";
|
|
22
22
|
export interface CarvedIdentity {
|
|
23
23
|
/** The HCL identity attribute, e.g. `bucket` or `name`. */
|
|
24
24
|
attr?: string;
|
|
@@ -37,11 +37,15 @@ export interface FileRewrite {
|
|
|
37
37
|
original: string;
|
|
38
38
|
rewritten: string;
|
|
39
39
|
changed: boolean;
|
|
40
|
+
/** Carved addresses whose own `resource` block was removed from this file (#998). */
|
|
41
|
+
excised: string[];
|
|
40
42
|
}
|
|
41
43
|
export interface DeferredInput {
|
|
42
44
|
survivor: string;
|
|
43
45
|
carved: string;
|
|
44
46
|
attrs: string[];
|
|
47
|
+
/** Build-parameter name(s) the input becomes in the emitted project (#998). */
|
|
48
|
+
params: string[];
|
|
45
49
|
note: string;
|
|
46
50
|
}
|
|
47
51
|
export interface BridgePlan {
|
|
@@ -49,6 +53,8 @@ export interface BridgePlan {
|
|
|
49
53
|
dataSources: DataSourceBlock[];
|
|
50
54
|
rewrites: FileRewrite[];
|
|
51
55
|
deferredInputs: DeferredInput[];
|
|
56
|
+
/** Every carved address whose own block the rewrites remove, across files. */
|
|
57
|
+
excised: string[];
|
|
52
58
|
runbook: string;
|
|
53
59
|
}
|
|
54
60
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/terraform/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/terraform/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAG9D,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,qFAAqF;IACrF,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,+EAA+E;IAC/E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,8EAA8E;IAC9E,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAiBD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,EAC/C,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GACtC,UAAU,CAwDZ"}
|
|
@@ -35,6 +35,13 @@ export interface BoundaryEdge {
|
|
|
35
35
|
/** The carve-set side of the edge. */
|
|
36
36
|
carved: string;
|
|
37
37
|
attrs: string[];
|
|
38
|
+
/**
|
|
39
|
+
* The referring block's own top-level attribute(s) the reference sits in
|
|
40
|
+
* (#998). For an outbound edge this names the carved resource's attribute
|
|
41
|
+
* that reads the survivor — what the deferred input's build parameter is
|
|
42
|
+
* named after on emit.
|
|
43
|
+
*/
|
|
44
|
+
via: string[];
|
|
38
45
|
bridge: "tf-data-source" | "deferred-input";
|
|
39
46
|
required: "immediately" | "at-apply";
|
|
40
47
|
}
|
|
@@ -63,4 +70,9 @@ export declare function resolveCarveSet(graph: TfGraph, target: string): CarveMe
|
|
|
63
70
|
* sub-resource pointing at its parent) are not boundary work.
|
|
64
71
|
*/
|
|
65
72
|
export declare function boundaryReport(graph: TfGraph, target: string): CarveReport | null;
|
|
73
|
+
/**
|
|
74
|
+
* The build-parameter name a deferred input's carrying attribute becomes on
|
|
75
|
+
* emit (#998) — shared so bridge notes and emitted `buildParams` agree.
|
|
76
|
+
*/
|
|
77
|
+
export declare function deferredParamName(tfAttr: string): string;
|
|
66
78
|
//# sourceMappingURL=carve.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carve.d.ts","sourceRoot":"","sources":["../../src/terraform/carve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,uFAAuF;AACvF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,UAAU,CAAC;AAEvD;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IAC5C,QAAQ,EAAE,aAAa,GAAG,UAAU,CAAC;CACtC;AAED,MAAM,WAAW,WAAW;IAC1B,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EA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AM,CAAC;IACf,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,iFAAiF;IACjF,UAAU,EAAE,IAAI,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAgB7E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAkDjF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAExD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Excision of a carved resource's own `resource "<type>" "<name>"` block from
|
|
3
|
+
* the surviving Terraform source (#998 — closes the "auto-excise" limitation).
|
|
4
|
+
*
|
|
5
|
+
* After `terraform state rm`, the block left behind would re-CREATE the
|
|
6
|
+
* resource on the next apply — the one edit the bridge previously left to
|
|
7
|
+
* hand-work. This removes the carve set's own blocks as part of the survivor
|
|
8
|
+
* rewrite, so the one bridge `.patch` (#1589) carries the whole handoff edit.
|
|
9
|
+
*
|
|
10
|
+
* Pure text transform. The scanner tracks brace depth outside of strings,
|
|
11
|
+
* comments, template interpolations, and heredocs — enough for real `.tf`
|
|
12
|
+
* files without pulling in the wasm parser for what is a subtractive edit.
|
|
13
|
+
*/
|
|
14
|
+
export interface ExciseTarget {
|
|
15
|
+
/** Terraform address, e.g. `aws_s3_bucket.assets`. */
|
|
16
|
+
address: string;
|
|
17
|
+
type: string;
|
|
18
|
+
name: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ExciseResult {
|
|
21
|
+
content: string;
|
|
22
|
+
/** Addresses whose block was found and removed, in file order. */
|
|
23
|
+
excised: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Remove the targets' own `resource` blocks from one `.tf` file's text. A
|
|
27
|
+
* comment line directly above a removed block stays (it may describe more
|
|
28
|
+
* than the block); the blank line the removal leaves behind is collapsed.
|
|
29
|
+
*/
|
|
30
|
+
export declare function exciseResourceBlocks(content: string, targets: ExciseTarget[]): ExciseResult;
|
|
31
|
+
//# sourceMappingURL=excise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"excise.d.ts","sourceRoot":"","sources":["../../src/terraform/excise.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,YAAY;IAC3B,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAID;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,YAAY,CA+B3F"}
|
|
@@ -40,4 +40,16 @@ export interface GraduationOptions {
|
|
|
40
40
|
channel?: ChannelKeys;
|
|
41
41
|
}
|
|
42
42
|
export declare function graduationPlan(report: CarveReport, opts?: GraduationOptions): GraduationPlan;
|
|
43
|
+
/**
|
|
44
|
+
* Stamp the ownership tags into an emitted chant source file (`carve apply
|
|
45
|
+
* --write-source`). The emitted source is machine-generated (`adoptFromState`),
|
|
46
|
+
* so its shape is known: one prop per line, `Tags` as a single-line JSON array.
|
|
47
|
+
* Merges into an existing `Tags` prop (replacing stale chant keys) or inserts
|
|
48
|
+
* one into the constructor's props object. Returns null when the file has no
|
|
49
|
+
* recognizable constructor to stamp.
|
|
50
|
+
*/
|
|
51
|
+
export declare function stampOwnershipIntoSource(content: string, tags: Record<string, string>): {
|
|
52
|
+
content: string;
|
|
53
|
+
changed: boolean;
|
|
54
|
+
} | null;
|
|
43
55
|
//# sourceMappingURL=graduate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graduate.d.ts","sourceRoot":"","sources":["../../src/terraform/graduate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAIxC,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,4EAA4E;IAC5E,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,GAAE,iBAAsB,GAAG,cAAc,CA2BhG"}
|
|
1
|
+
{"version":3,"file":"graduate.d.ts","sourceRoot":"","sources":["../../src/terraform/graduate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAIxC,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,4EAA4E;IAC5E,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,GAAE,iBAAsB,GAAG,cAAc,CA2BhG;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAoC9C"}
|
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pure Terraform dependency-graph builder for the carve-out advisor (#214 T1).
|
|
3
3
|
*
|
|
4
|
-
* Input is the JSON tree `@cdktf/hcl2json` produces (`Hcl2JsonTree`)
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Input is the JSON tree `@cdktf/hcl2json` produces (`Hcl2JsonTree`) plus the
|
|
5
|
+
* traversal accessors its expression AST found per interpolated string
|
|
6
|
+
* (`ExpressionRefs`, resolved in `parse.ts` — #998). Tokenizing `${...}`
|
|
7
|
+
* expression bodies is the AST's job — a quoted address inside an expression
|
|
8
|
+
* (`var.m["aws_s3_bucket.assets.arn"]`) or an escaped `$${...}` literal is not
|
|
9
|
+
* a reference, which the regex scan this replaced could not tell. This module
|
|
10
|
+
* only classifies the accessors the AST produced: no wasm, no filesystem, so
|
|
11
|
+
* graph building stays unit-testable on hand-written fixtures.
|
|
8
12
|
*/
|
|
9
13
|
import type { Hcl2JsonTree, TfEdge, TfGraph } from "./types.js";
|
|
14
|
+
/**
|
|
15
|
+
* Traversal accessors per interpolated string, as the hcl2json expression AST
|
|
16
|
+
* reports them (`getReferencesInExpression`): `"${aws_s3_bucket.assets.arn}"`
|
|
17
|
+
* maps to `["aws_s3_bucket.assets.arn"]`. Keys are the raw hcl2json string
|
|
18
|
+
* values; a missing key means the expression yielded no references.
|
|
19
|
+
*/
|
|
20
|
+
export type ExpressionRefs = ReadonlyMap<string, readonly string[]>;
|
|
21
|
+
interface RawRef {
|
|
22
|
+
address: string;
|
|
23
|
+
attr?: string;
|
|
24
|
+
/** The referring block's top-level attribute the reference sits in (#998). */
|
|
25
|
+
via?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Classify one AST traversal accessor into a resource/module/data reference.
|
|
29
|
+
* `var.*`/`local.*`/`each.*`-headed accessors are not references; quoted map
|
|
30
|
+
* keys and numeric indexes never become the attribute.
|
|
31
|
+
*/
|
|
32
|
+
export declare function refFromAccessor(accessor: string): RawRef | null;
|
|
33
|
+
/**
|
|
34
|
+
* Every string value carrying an interpolation across the tree's resource and
|
|
35
|
+
* module blocks — exactly the expressions `parse.ts` must resolve through the
|
|
36
|
+
* AST before `buildGraph` can classify them.
|
|
37
|
+
*/
|
|
38
|
+
export declare function collectExpressions(tree: Hcl2JsonTree): string[];
|
|
10
39
|
/**
|
|
11
40
|
* Build the dependency graph from a merged hcl2json tree.
|
|
12
41
|
*
|
|
@@ -16,9 +45,10 @@ import type { Hcl2JsonTree, TfEdge, TfGraph } from "./types.js";
|
|
|
16
45
|
* resolves to a known resource/module node — references to `var`/`local`/data
|
|
17
46
|
* are dropped.
|
|
18
47
|
*/
|
|
19
|
-
export declare function buildGraph(tree: Hcl2JsonTree): TfGraph;
|
|
48
|
+
export declare function buildGraph(tree: Hcl2JsonTree, exprRefs: ExpressionRefs): TfGraph;
|
|
20
49
|
/** Edges where other nodes depend on `address` (each → a surviving-TF data-source patch). */
|
|
21
50
|
export declare function inboundEdges(graph: TfGraph, address: string): TfEdge[];
|
|
22
51
|
/** Edges where `address` depends on other nodes (each → a deferred deploy-time input). */
|
|
23
52
|
export declare function outboundEdges(graph: TfGraph, address: string): TfEdge[];
|
|
53
|
+
export {};
|
|
24
54
|
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/terraform/graph.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/terraform/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAU,MAAM,SAAS,CAAC;AAErE;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;AAKpE,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA4BD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAe/D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,EAAE,CAc/D;AAkDD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAwEhF;AAED,6FAA6F;AAC7F,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAEtE;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAEvE"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The carve state manifest (#998) — what makes emit → bridge → apply compose.
|
|
3
|
+
*
|
|
4
|
+
* `carve emit` persists the boundary report and adoption selector next to the
|
|
5
|
+
* emitted source as `<target>.carve.json`. The later steps read it back from
|
|
6
|
+
* their output dir, so `carve bridge` and `carve apply` no longer need the
|
|
7
|
+
* target re-specified by hand, and each step records what it did for the next.
|
|
8
|
+
* Plain JSON on disk — reviewable, diffable, nothing proprietary.
|
|
9
|
+
*/
|
|
10
|
+
import type { CarveReport } from "./carve.js";
|
|
11
|
+
import type { OwnershipMarker } from "../ownership.js";
|
|
12
|
+
export declare const CARVE_MANIFEST_SUFFIX = ".carve.json";
|
|
13
|
+
export interface CarveManifest {
|
|
14
|
+
version: 1;
|
|
15
|
+
/** Terraform address of the carved resource, e.g. `aws_s3_bucket.assets`. */
|
|
16
|
+
target: string;
|
|
17
|
+
/** Terraform resource type, when known. */
|
|
18
|
+
tfType?: string;
|
|
19
|
+
/** Absolute path of the Terraform estate the carve came from. */
|
|
20
|
+
from: string;
|
|
21
|
+
/** Absolute path of the tfstate used for adoption (offline path). */
|
|
22
|
+
statePath?: string;
|
|
23
|
+
/** Boundary classification persisted when the manifest was written. */
|
|
24
|
+
boundary: CarveReport;
|
|
25
|
+
/** Recorded by `carve emit`. */
|
|
26
|
+
emit?: {
|
|
27
|
+
source: "tfstate" | "live";
|
|
28
|
+
/** Emitted chant source file path(s). */
|
|
29
|
+
files: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Deferred outbound inputs declared as build parameters in the emitted
|
|
32
|
+
* project (#998), keyed by parameter name.
|
|
33
|
+
*/
|
|
34
|
+
params?: Record<string, {
|
|
35
|
+
/** The carved resource's own Terraform attribute the value enters through. */
|
|
36
|
+
tfAttr: string;
|
|
37
|
+
/** The survivor the Terraform source read, e.g. `aws_vpc.main`. */
|
|
38
|
+
survivor: string;
|
|
39
|
+
/** Survivor attribute(s) read. */
|
|
40
|
+
attrs: string[];
|
|
41
|
+
/** State-resolved default, when scalar. */
|
|
42
|
+
default?: string | number | boolean;
|
|
43
|
+
}>;
|
|
44
|
+
at: string;
|
|
45
|
+
};
|
|
46
|
+
/** Recorded by `carve bridge`. */
|
|
47
|
+
bridge?: {
|
|
48
|
+
written: string[];
|
|
49
|
+
appliedInPlace: boolean;
|
|
50
|
+
/** The git-applyable `.patch` carrying the whole survivor edit. */
|
|
51
|
+
patch?: string;
|
|
52
|
+
/** Carved addresses whose own `.tf` block the rewrites remove (#998). */
|
|
53
|
+
excised?: string[];
|
|
54
|
+
at: string;
|
|
55
|
+
};
|
|
56
|
+
/** Recorded by `carve apply`. */
|
|
57
|
+
apply?: {
|
|
58
|
+
marker: OwnershipMarker;
|
|
59
|
+
ownershipTags: Record<string, string>;
|
|
60
|
+
/** Emitted files the marker was stamped into (`--write-source`). */
|
|
61
|
+
stampedFiles?: string[];
|
|
62
|
+
at: string;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** Filesystem-safe slug for a Terraform address (shared file-naming convention). */
|
|
66
|
+
export declare function carveSlug(target: string): string;
|
|
67
|
+
/** Where the manifest for `target` lives inside an output dir. */
|
|
68
|
+
export declare function carveManifestPath(outDir: string, target: string): string;
|
|
69
|
+
/** Write (or overwrite) a manifest into the output dir. Returns the path. */
|
|
70
|
+
export declare function writeCarveManifest(outDir: string, manifest: CarveManifest): string;
|
|
71
|
+
/** Read a manifest, or null when absent/unreadable/not a v1 manifest. */
|
|
72
|
+
export declare function readCarveManifest(path: string): CarveManifest | null;
|
|
73
|
+
/** All carve manifest paths in an output dir. */
|
|
74
|
+
export declare function listCarveManifests(outDir: string): string[];
|
|
75
|
+
export interface ResolvedManifest {
|
|
76
|
+
manifest?: CarveManifest;
|
|
77
|
+
path?: string;
|
|
78
|
+
error?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Resolve the manifest a later carve step composes with. With a selected
|
|
82
|
+
* target, that target's manifest (absent is fine — the step just runs
|
|
83
|
+
* standalone). Without one, the single manifest in the output dir; none or
|
|
84
|
+
* several is an error naming what is (or is not) there.
|
|
85
|
+
*/
|
|
86
|
+
export declare function resolveCarveManifest(outDir: string, select?: string): ResolvedManifest;
|
|
87
|
+
/** Read-modify-write a section of an existing manifest. No-op when absent. */
|
|
88
|
+
export declare function updateCarveManifest(outDir: string, target: string, patch: Partial<Pick<CarveManifest, "boundary" | "emit" | "bridge" | "apply">>): string | undefined;
|
|
89
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/terraform/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,CAAC,CAAC;IACX,6EAA6E;IAC7E,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,QAAQ,EAAE,WAAW,CAAC;IACtB,gCAAgC;IAChC,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC;QAC3B,yCAAyC;QACzC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;AACjD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAM3D;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAsBtF;AAED,8EAA8E;AAC9E,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAC,GAC5E,MAAM,GAAG,SAAS,CAOpB"}
|
|
@@ -8,8 +8,14 @@
|
|
|
8
8
|
* advisor fails with a one-line install hint.
|
|
9
9
|
*/
|
|
10
10
|
import type { Hcl2JsonTree, TfGraph } from "./types.js";
|
|
11
|
-
/** Minimal shape of the parser
|
|
12
|
-
|
|
11
|
+
/** Minimal shape of the parser exports we depend on. */
|
|
12
|
+
export interface Hcl2Json {
|
|
13
|
+
parse: (filename: string, hcl: string) => Promise<Hcl2JsonTree>;
|
|
14
|
+
/** Expression-AST reference extraction (#998) — one traversal accessor per reference. */
|
|
15
|
+
getReferencesInExpression: (filename: string, expression: string) => Promise<Array<{
|
|
16
|
+
value: string;
|
|
17
|
+
}>>;
|
|
18
|
+
}
|
|
13
19
|
export declare class Hcl2JsonNotInstalled extends Error {
|
|
14
20
|
constructor(cause: unknown);
|
|
15
21
|
}
|
|
@@ -17,7 +23,7 @@ export declare class Hcl2JsonNotInstalled extends Error {
|
|
|
17
23
|
* Lazy-load the optional HCL parser. Throws `Hcl2JsonNotInstalled` with an
|
|
18
24
|
* install hint when the package is missing, rather than a raw MODULE_NOT_FOUND.
|
|
19
25
|
*/
|
|
20
|
-
export declare function loadHcl2json(): Promise<
|
|
26
|
+
export declare function loadHcl2json(): Promise<Hcl2Json>;
|
|
21
27
|
export interface ParseTerraformOptions {
|
|
22
28
|
/** Opt-in `.tfstate` path (#214 T2): overlays state-expanded instance counts. */
|
|
23
29
|
statePath?: string;
|
|
@@ -29,5 +35,4 @@ export interface ParseTerraformOptions {
|
|
|
29
35
|
* instance counts become accurate (see `state.ts`).
|
|
30
36
|
*/
|
|
31
37
|
export declare function parseTerraformDir(dir: string, opts?: ParseTerraformOptions): Promise<TfGraph>;
|
|
32
|
-
export {};
|
|
33
38
|
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/terraform/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAErD,
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/terraform/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAErD,wDAAwD;AACxD,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAChE,yFAAyF;IACzF,yBAAyB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;CACxG;AAED,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,KAAK,EAAE,OAAO;CAQ3B;AAED;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,QAAQ,CAAC,CAMtD;AA+CD,MAAM,WAAW,qBAAqB;IACpC,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,qBAA0B,GAAG,OAAO,CAAC,OAAO,CAAC,CAWvG"}
|
|
@@ -46,6 +46,13 @@ export interface TfEdge {
|
|
|
46
46
|
to: string;
|
|
47
47
|
/** The attribute path(s) referenced, e.g. `["id", "arn"]`. */
|
|
48
48
|
attrs: string[];
|
|
49
|
+
/**
|
|
50
|
+
* The referring block's own top-level attribute(s) the reference sits in,
|
|
51
|
+
* e.g. `["vpc_id"]` for a subnet reading its VPC (#998). This is what a
|
|
52
|
+
* deferred outbound input is named after when emit turns it into a build
|
|
53
|
+
* parameter. Empty when the reference came from a non-object block shape.
|
|
54
|
+
*/
|
|
55
|
+
via: string[];
|
|
49
56
|
}
|
|
50
57
|
export interface TfGraph {
|
|
51
58
|
nodes: TfNode[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/terraform/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,+EAA+E;AAC/E,MAAM,WAAW,MAAM;IACrB,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC5B,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,uFAAuF;IACvF,UAAU,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,8DAA8D;IAC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|
2
|
+
* Minimal unified-diff generator for the carve bridge patch (#998). Emits
|
|
3
|
+
* git-applyable hunks (`git apply`, or plain `patch -p1`) so the whole survivor
|
|
4
|
+
* edit — data sources plus rewired references — lands in one reviewable file.
|
|
5
|
+
* LCS-based; bridge inputs are hand-sized `.tf` files, so O(n·m) is fine.
|
|
6
|
+
*/
|
|
7
|
+
/** One file's diff, `a/<path>` → `b/<path>`, with git headers. Empty when unchanged. */
|
|
8
|
+
export declare function unifiedDiff(path: string, oldText: string, newText: string, context?: number): string;
|
|
9
|
+
/** A new-file diff (`/dev/null` → `b/<path>`), git-applyable. */
|
|
10
|
+
export declare function newFileDiff(path: string, text: string): string;
|
|
11
|
+
//# sourceMappingURL=unified-diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified-diff.d.ts","sourceRoot":"","sources":["../../src/terraform/unified-diff.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,SAAI,GAAG,MAAM,CA0B/F;AAED,iEAAiE;AACjE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAa9D"}
|