@huaweidevtools/aishell-dsh-deploy 0.0.15 → 0.0.17

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.
Files changed (60) hide show
  1. package/README.md +28 -9
  2. package/cordis.patch.yml +12 -3
  3. package/lib/data/permission-registry.json +1 -1
  4. package/lib/index.js +6163 -1474
  5. package/lib/types/auth-http.d.ts +36 -4
  6. package/lib/types/auth-obs-signer.d.ts +8 -5
  7. package/lib/types/auth-signer.d.ts +6 -1
  8. package/lib/types/bridge.d.ts +20 -5
  9. package/lib/types/bss.d.ts +159 -0
  10. package/lib/types/catalog.d.ts +118 -0
  11. package/lib/types/credentials.d.ts +64 -18
  12. package/lib/types/d2-design.d.ts +60 -0
  13. package/lib/types/d2-engine.d.ts +111 -0
  14. package/lib/types/d2-inventory.d.ts +54 -0
  15. package/lib/types/data-paths.d.ts +10 -0
  16. package/lib/types/deployment-state.d.ts +90 -13
  17. package/lib/types/existing-topology.d.ts +154 -0
  18. package/lib/types/existing.d.ts +100 -0
  19. package/lib/types/gates/cost_gate.d.ts +38 -16
  20. package/lib/types/gates/credential_gate.d.ts +29 -3
  21. package/lib/types/gates/design_gate.d.ts +72 -0
  22. package/lib/types/gates/mirror.d.ts +1 -1
  23. package/lib/types/gates/plan_gate.d.ts +116 -0
  24. package/lib/types/gates/provider_installed.d.ts +32 -0
  25. package/lib/types/gates/terraform_env.d.ts +16 -3
  26. package/lib/types/hcl.d.ts +176 -0
  27. package/lib/types/index.d.ts +18 -4
  28. package/lib/types/inventory-subnets.d.ts +78 -0
  29. package/lib/types/network-checks.d.ts +67 -0
  30. package/lib/types/paths.d.ts +51 -0
  31. package/lib/types/permission/gate.d.ts +6 -6
  32. package/lib/types/permission/registry.d.ts +11 -0
  33. package/lib/types/plan.d.ts +68 -0
  34. package/lib/types/projects.d.ts +40 -0
  35. package/lib/types/prompt.d.ts +5 -4
  36. package/lib/types/rating-map.d.ts +132 -0
  37. package/lib/types/security-groups.d.ts +16 -23
  38. package/lib/types/terraform-run.d.ts +32 -0
  39. package/lib/types/tools/annotations.d.ts +1 -1
  40. package/lib/types/tools/balance_summary.d.ts +1 -1
  41. package/lib/types/tools/deployment.d.ts +3 -3
  42. package/lib/types/tools/design.d.ts +54 -0
  43. package/lib/types/tools/errors.d.ts +22 -4
  44. package/lib/types/tools/examples.d.ts +1 -1
  45. package/lib/types/tools/existing_resources.d.ts +1 -1
  46. package/lib/types/tools/index.d.ts +26 -12
  47. package/lib/types/tools/openapi.d.ts +19 -9
  48. package/lib/types/tools/pricing.d.ts +213 -0
  49. package/lib/types/tools/provider_schema.d.ts +1 -1
  50. package/lib/types/tools/specs.d.ts +41 -0
  51. package/lib/types/tools/terraform.d.ts +27 -25
  52. package/lib/types/topology.d.ts +232 -0
  53. package/lib/types/types.d.ts +29 -4
  54. package/lib/types/utils/hash.d.ts +15 -5
  55. package/package.json +4 -2
  56. package/lib/types/gates/networking_gate.d.ts +0 -9
  57. package/lib/types/schemas/cost.d.ts +0 -108
  58. package/lib/types/schemas/networking.d.ts +0 -115
  59. package/lib/types/tools/cost.d.ts +0 -16
  60. package/lib/types/tools/networking.d.ts +0 -13
@@ -1,5 +1,5 @@
1
1
  /**
2
- * credential_gate.ts — plaintext credential scanner (§6.2).
2
+ * Plaintext credential scanner for configuration files.
3
3
  *
4
4
  * Deterministic grep for access_key/secret_key/security_token/password
5
5
  * assignments in .tf files. Catches the most severe leak: credentials
@@ -7,14 +7,40 @@
7
7
  * not plaintext values, though instructions still say don't define cred
8
8
  * variables — the gate only catches the plaintext case).
9
9
  *
10
- * Mounted at terraform_init (early exposure) and terraform_apply (§6.3 门 4).
10
+ * Runs at terraform_init — early, before a provider is fetched — and again at
11
+ * terraform_apply, where it is the last gate before resources are created.
11
12
  */
12
13
  export interface CredentialFinding {
13
14
  file: string;
14
15
  line: number;
15
16
  pattern: string;
16
17
  }
17
- /** Scan all .tf files (recursively, including modules/) for plaintext credentials. */
18
+ /**
19
+ * Scan every configuration file this deployment owns for plaintext credentials.
20
+ *
21
+ * The file set comes from {@link configurationFiles}, so it is the same one the
22
+ * design tool reads and the digest hashes. That alignment is the point: a
23
+ * module's `.tf` is compiled into the plan, so a credential written there is
24
+ * exactly as exposed as one in the workspace root — and a scan that skipped it
25
+ * while the digest counted it would be two readers disagreeing about what the
26
+ * deployment is.
27
+ *
28
+ * ## Why the two syntaxes are scanned differently
29
+ *
30
+ * HCL writes an assignment as `key = "value"`, so a line pattern finds it. JSON
31
+ * writes `"key": "value"`, where the same pattern matches nothing — the
32
+ * separator and the quoting both differ, so a leak written in JSON is invisible
33
+ * to a scan built for HCL. Verified: a line scan over a `.tf.json` holding an
34
+ * `access_key` returned no findings.
35
+ *
36
+ * So a `.tf.json` is parsed and its string leaves inspected, comparing the KEY
37
+ * rather than the line. That comparison is exact, which is also why it does not
38
+ * need the HCL scan's `var.` exemption: a JSON value is either a string or a
39
+ * reference object, never an expression that reads like one.
40
+ *
41
+ * @param dir - the deployment workspace directory.
42
+ * @returns the findings, empty when the configuration is clean.
43
+ */
18
44
  export declare function scanTfCredentials(dir: string): Promise<CredentialFinding[]>;
19
45
  /** Throw if any plaintext credential is found. */
20
46
  export declare function assertNoCredentials(dir: string): Promise<void>;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * The gate `terraform_apply` runs on the network design.
3
+ *
4
+ * ## What it checks, and what it deliberately does not
5
+ *
6
+ * The design IS the `.tf`: there is no separate description of the network, so
7
+ * "has the design been checked" can only be asked of the configuration itself.
8
+ * This gate asks two questions, both answerable without a cloud credential:
9
+ *
10
+ * 1. Do the `.tf` files declare any network resources at all? A deployment
11
+ * that plans to create compute in a subnet it never wrote is a plan that
12
+ * will fail on an unresolved reference — the error terraform gives points
13
+ * at the compute block, several steps from the omission that caused it.
14
+ *
15
+ * 2. Did `validate_design` run over THIS configuration?
16
+ *
17
+ * The second is a hash, not a timestamp or a boolean. `validate_design`
18
+ * records the digest of the configuration it checked; this gate recomputes the
19
+ * digest from the files on disk and refuses when they differ. A design edited
20
+ * after it was checked is not a checked design — and a boolean would have said
21
+ * it was.
22
+ *
23
+ * ## Why the evidence is a digest of the configuration
24
+ *
25
+ * The design IS the `.tf`. Any separate statement of the network — a file the
26
+ * model fills in beside it — is a second description that nothing reconciles
27
+ * with the first, so passing a gate on it would prove only that somebody wrote
28
+ * something down. A digest of the configuration is evidence about the thing
29
+ * that will be built, which is the only thing worth approving.
30
+ *
31
+ * ## What it still does not do
32
+ *
33
+ * It does not re-run `terraform validate`. That is `validate_design`'s job, and
34
+ * it is the check whose result is recorded — a design that failed validation
35
+ * is recorded as failed and this gate refuses it.
36
+ *
37
+ * @module @huaweidevtools/aishell-dsh-deploy/gates/design_gate
38
+ */
39
+ import type { DeploymentSnapshot } from '../deployment-state.ts';
40
+ import { computeTfHash } from '../utils/hash.ts';
41
+ /**
42
+ * Whether one resource type is part of the network design.
43
+ *
44
+ * @param type - the resource type.
45
+ * @returns whether it counts as network.
46
+ */
47
+ export declare function isNetworkType(type: string): boolean;
48
+ /**
49
+ * The state a deployment records about its design check.
50
+ *
51
+ * Written by `validate_design`. `tf_hash` is the digest of the configuration
52
+ * that was checked; `ok` is whether it passed, so a recorded failure cannot be
53
+ * read as a pass.
54
+ */
55
+ export interface DesignCheck {
56
+ readonly tf_hash: string;
57
+ readonly ok: boolean;
58
+ readonly checked_at: string;
59
+ }
60
+ /**
61
+ * Refuse an apply whose network design was never checked, or changed since.
62
+ *
63
+ * @param directory - the deployment workspace directory.
64
+ * @param readState - reader for the deployment snapshot, injected so the check
65
+ * is testable without a filesystem.
66
+ * @param hashConfiguration - digest of the configuration on disk.
67
+ * @throws when the design is absent, unchecked, failed, or stale.
68
+ */
69
+ export declare function assertDesignChecked(directory: string, readState: (dir: string) => Promise<DeploymentSnapshot | undefined>, hashConfiguration: (dir: string) => Promise<string>): Promise<void>;
70
+ /** The digest function the gate uses; re-exported so a caller cannot pass a different one by accident. */
71
+ export { computeTfHash };
72
+ //# sourceMappingURL=design_gate.d.ts.map
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Provider mirror config generator (§6.6 / mirror.go 思路).
2
+ * Provider mirror config generator.
3
3
  *
4
4
  * Generates <deployment>/.terraformrc with network_mirror / filesystem_mirror
5
5
  * entries from a list of mirror URLs or paths. Terraform tries mirrors in
@@ -0,0 +1,116 @@
1
+ /**
2
+ * The gate that makes `terraform_apply` run the plan the user approved.
3
+ *
4
+ * ## The gap it closes
5
+ *
6
+ * `terraform apply` re-plans by default. That means the changes it makes are
7
+ * computed at apply time, from whatever the configuration says THEN — not the
8
+ * ones the user looked at in `terraform_plan`. Verified: `terraform apply
9
+ * <saved-plan>` executes the saved plan and does NOT check that the `.tf` still
10
+ * matches it, so terraform itself offers no protection either way.
11
+ *
12
+ * So the approval step has to be enforced here, and it is enforcement of two
13
+ * facts:
14
+ *
15
+ * 1. A plan exists, produced by `terraform_plan` for THIS configuration
16
+ * (its digest matches the `.tf` on disk).
17
+ * 2. Apply runs THAT plan file, not a fresh computation.
18
+ *
19
+ * ## Why the digest and not the plan file's timestamp
20
+ *
21
+ * A plan file has no intrinsic link to the configuration it came from —
22
+ * terraform will happily apply one whose `.tf` has since changed, as the test
23
+ * above shows. So the record of "which configuration this plan describes" has
24
+ * to be kept beside it, and the digest is that record. A timestamp would only
25
+ * say when someone ran the command.
26
+ *
27
+ * ## What this gate does NOT check
28
+ *
29
+ * Whether the user actually looked. That is not observable from here, and the
30
+ * prompt says to show the plan and get agreement. What IS observable is that a
31
+ * specific set of changes was computed and approved as a unit, and that apply
32
+ * executes exactly it — which is the property that matters when the answer to
33
+ * "was this reviewed" is "reviewed for a different plan".
34
+ *
35
+ * @module @huaweidevtools/aishell-dsh-deploy/gates/plan_gate
36
+ */
37
+ import { computeTfHash } from '../utils/hash.ts';
38
+ import type { DeploymentSnapshot } from '../deployment-state.ts';
39
+ /** Where `terraform_plan` writes the plan it computes. */
40
+ export declare const PLAN_FILE = "plan.tfplan";
41
+ /**
42
+ * The record `terraform_plan` writes about the plan it produced.
43
+ *
44
+ * Stored in the deployment snapshot rather than beside the plan file: the file
45
+ * is a terraform artifact and a second file next to it would be one more thing
46
+ * to keep in step. The snapshot is already the place this plugin records what
47
+ * it has done.
48
+ */
49
+ export interface PlanRecord {
50
+ /** Digest of the configuration the plan was computed from. */
51
+ readonly tf_hash: string;
52
+ /** When the plan ran. */
53
+ readonly planned_at: string;
54
+ /**
55
+ * What the plan would do, as counts — absent when the plan produced no
56
+ * readable change list, which is different from "changes nothing".
57
+ */
58
+ readonly actions?: {
59
+ readonly create: number;
60
+ readonly change: number;
61
+ readonly destroy: number;
62
+ };
63
+ }
64
+ /**
65
+ * Refuse an apply that has no approved plan, or whose plan is for a
66
+ * configuration that has since changed.
67
+ *
68
+ * @param directory - the deployment workspace directory.
69
+ * @param readState - reader for the deployment snapshot.
70
+ * @param hashConfiguration - digest of the configuration on disk.
71
+ * @throws when there is no plan, no record of it, or the record is stale.
72
+ */
73
+ export declare function assertPlanApproved(directory: string, readState: (dir: string) => Promise<DeploymentSnapshot | undefined>, hashConfiguration: (dir: string) => Promise<string>): Promise<void>;
74
+ /** The digest function the gate uses, re-exported so a caller cannot pass another by accident. */
75
+ export { computeTfHash };
76
+ /** Where `terraform_plan({ destroy: true })` writes the destruction it previewed. */
77
+ export declare const DESTROY_PLAN_FILE = "destroy.plan.tfplan";
78
+ /**
79
+ * The record `terraform_plan({ destroy: true })` writes about what it previewed.
80
+ *
81
+ * `targets` is empty for a full teardown and the addresses otherwise. It is
82
+ * stored because the preview and the destruction must name the same resources:
83
+ * applying a whole-deployment teardown because someone asked to remove one
84
+ * instance is the worst outcome available here, and the two lists are the only
85
+ * thing that can tell them apart.
86
+ */
87
+ export interface DestroyRecord {
88
+ /** Digest of the configuration the preview was computed from. */
89
+ readonly tf_hash: string;
90
+ readonly previewed_at: string;
91
+ /** The addresses previewed, or empty for the whole deployment. */
92
+ readonly targets: readonly string[];
93
+ }
94
+ /**
95
+ * Refuse a destroy with no preview, or one that passes for a different teardown.
96
+ *
97
+ * `terraform destroy -auto-approve` computes its own plan, so the list the user
98
+ * approved and the resources that disappear are two separate computations —
99
+ * and anything can change between them: a refresh, a console edit, a failed
100
+ * apply. Applying the previewed plan file instead makes the destruction
101
+ * exactly what was shown, and terraform refuses a plan whose state has moved
102
+ * on since. Verified: `plan -destroy -target=A -out=f` followed by `apply f`
103
+ * removes A and leaves B.
104
+ *
105
+ * Three questions, each one a way the preview and the request can disagree:
106
+ * does a preview exist, does it cover the same targets, and was it computed
107
+ * from the configuration still on disk.
108
+ *
109
+ * @param directory - the deployment workspace directory.
110
+ * @param readState - reader for the deployment snapshot.
111
+ * @param hashConfiguration - digest of the configuration on disk.
112
+ * @param targets - the addresses this call intends to destroy; empty for all.
113
+ * @throws when there is no preview, it covers a different set, or it is stale.
114
+ */
115
+ export declare function assertDestroyPreviewed(directory: string, readState: (dir: string) => Promise<DeploymentSnapshot | undefined>, hashConfiguration: (dir: string) => Promise<string>, targets: readonly string[]): Promise<void>;
116
+ //# sourceMappingURL=plan_gate.d.ts.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Whether this deployment has the huaweicloud provider installed.
3
+ *
4
+ * ## Why this is a question about files, not about terraform
5
+ *
6
+ * `terraform validate` refuses a configuration whose provider is absent — it
7
+ * answers "requires provider registry.terraform.io/huaweicloud/huaweicloud,
8
+ * but that provider isn't available" (verified against terraform 1.x with no
9
+ * `.terraform` directory). That message describes the install state, not the
10
+ * configuration, but a caller that only reads terraform's exit code cannot
11
+ * tell those apart.
12
+ *
13
+ * So the install state is decided here, from the directory terraform itself
14
+ * writes: `terraform init` unpacks providers into
15
+ * `<deployment>/.terraform/providers/<registry-address>/`. The directory is the
16
+ * signal, and it needs no subprocess, no credentials, and no network.
17
+ *
18
+ * `validate` also needs `.terraform.lock.hcl` to agree. A lock file naming the
19
+ * provider without the matching directory is the state `init` did not finish,
20
+ * and validate refuses it as an inconsistent lock — a different message for
21
+ * the same cause, so both halves are required here.
22
+ *
23
+ * @module @huaweidevtools/aishell-dsh-deploy/gates/provider_installed
24
+ */
25
+ /**
26
+ * Whether the huaweicloud provider is installed and locked in this deployment.
27
+ *
28
+ * @param deployment - the deployment workspace directory.
29
+ * @returns `true` when `terraform validate` can run against the provider.
30
+ */
31
+ export declare function providerInstalled(deployment: string): Promise<boolean>;
32
+ //# sourceMappingURL=provider_installed.d.ts.map
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Stateless terraform execution environment resolver (§6.6).
2
+ * Stateless terraform execution environment resolver.
3
3
  *
4
4
  * Each tool call is independent — nothing here remembers what terraform_install
5
5
  * or terraform_init did. But the terraform subprocess needs to know: binary
@@ -9,7 +9,7 @@
9
9
  * before spawning. It re-derives from filesystem state — a few stat calls,
10
10
  * no cross-call memory.
11
11
  *
12
- * Credential env is injected from the keychain (§5.5) — NEVER passed via
12
+ * Credential env is injected from the keychain — NEVER passed via
13
13
  * tool parameters. The tool-param-controlled env is `extraEnv` — an array
14
14
  * of KEY=VALUE strings merged onto the subprocess env (e.g. TF_LOG=DEBUG,
15
15
  * TF_LOG_PROVIDER=OFF, TF_CLI_ARGS_plan=-refresh=false).
@@ -22,5 +22,18 @@ export interface ResolvedEnv {
22
22
  * Resolve the terraform binary path + env for a deployment.
23
23
  * Throws if no binary can be found.
24
24
  */
25
- export declare function resolveTerraformEnv(deployment: string, extraEnv?: string[]): Promise<ResolvedEnv>;
25
+ export declare function resolveTerraformEnv(deployment: string | undefined, extraEnv?: string[]): Promise<ResolvedEnv>;
26
+ /**
27
+ * Record the binary path `terraform_install` was given.
28
+ *
29
+ * Without this, the path is validated, reported in the tool result, and
30
+ * forgotten — and the very next `terraform_plan` fails with "terraform not
31
+ * found", which is the least useful answer to a call that just succeeded.
32
+ *
33
+ * A failure to write is swallowed by the caller: the install itself worked, and
34
+ * losing the record only means the next call falls back to the search order.
35
+ *
36
+ * @param path - an absolute path to a terraform binary the user supplied.
37
+ */
38
+ export declare function recordBinaryPath(path: string): Promise<void>;
26
39
  //# sourceMappingURL=terraform_env.d.ts.map
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Reading HCL: resource blocks out of source text, and the values inside them.
3
+ *
4
+ * ## Why this is its own module
5
+ *
6
+ * Two readers need these: the topology derivation (which needs containment and
7
+ * display facts) and the network checks (which need CIDRs and port lists).
8
+ * Owning them in `topology` would make `network-checks` import back from the
9
+ * module that imports it — a cycle, and a cycle in this pair is easy to
10
+ * introduce and hard to notice, because both halves keep working until one of
11
+ * them is loaded first.
12
+ *
13
+ * ## What the parser is
14
+ *
15
+ * `hcl2-parser` — Terraform's own HCL grammar compiled from Go. It is used
16
+ * rather than a hand-written pattern because the alternative is a partial
17
+ * parser whose gaps appear as missing boxes in a diagram, which reads as a
18
+ * design decision rather than a bug. Measured against all 900 `.tf` files of
19
+ * the provider's shipped examples: zero failures.
20
+ *
21
+ * Expressions are NOT evaluated. `${...}` is left exactly as written, because
22
+ * terraform has not run and there is no value to report. What an expression
23
+ * does carry is its references — `huaweicloud_vpc.prod.id` names a resource
24
+ * that will exist — and those are what a diagram is built from.
25
+ *
26
+ * @module @huaweidevtools/aishell-dsh-deploy/hcl
27
+ */
28
+ /** One resource block, as the HCL parser reports it. */
29
+ export interface ResourceBlock {
30
+ /** `type` from `resource "<type>" "<name>"`. */
31
+ readonly type: string;
32
+ /** `name` from `resource "<type>" "<name>"`. */
33
+ readonly name: string;
34
+ /** The block body, HCL-expression strings left as written (`${...}`). */
35
+ readonly body: Record<string, unknown>;
36
+ }
37
+ /**
38
+ * Pull every resource block out of one configuration file.
39
+ *
40
+ * Two syntaxes, both of which terraform reads:
41
+ *
42
+ * - **HCL** (`.tf`) — parsed by the Go grammar.
43
+ * - **JSON** (`.tf.json`) — the same configuration in JSON form, which
44
+ * terraform validates and plans identically (verified: a `.tf.json` with a
45
+ * resource and a `.tf` with the provider block plan together).
46
+ *
47
+ * The JSON form uses the same shape the HCL parser produces, which is why one
48
+ * extractor handles both: a resource is `{resource: {<type>: {<name>: <body>}}}`
49
+ * with the body possibly wrapped in an array.
50
+ *
51
+ * Both syntaxes must be read, because terraform treats them as the same
52
+ * configuration: it validates and plans a `.tf.json` identically, so a
53
+ * deployment written that way is a design like any other and has to reach the
54
+ * same readers. A reader that accepted only HCL would answer "nothing declared"
55
+ * about a file terraform has just planned successfully.
56
+ *
57
+ * @param source - the text of one `.tf` or `.tf.json` file.
58
+ * @returns the resource blocks it declares, in file order.
59
+ * @throws when the text is not parseable, with a message about the
60
+ * configuration's syntax rather than about a byte offset in a string.
61
+ */
62
+ export declare function parseResources(source: string): ResourceBlock[];
63
+ /**
64
+ * Pull every resource block out of JSON configuration text.
65
+ *
66
+ * Separate from {@link parseResources} because the failure mode differs: JSON
67
+ * says where it broke, and a reader fixing it needs the file and the offset,
68
+ * which the HCL parser cannot give.
69
+ *
70
+ * @param source - the text of one `.tf.json` file.
71
+ * @returns the resource blocks it declares.
72
+ * @throws when the text is not valid JSON.
73
+ */
74
+ export declare function parseJsonResources(source: string): ResourceBlock[];
75
+ /**
76
+ * Every reference one body makes to another resource.
77
+ *
78
+ * @param body - one resource block's body.
79
+ * @returns referenced `type.name` addresses, deduplicated, in first-seen order.
80
+ */
81
+ export declare function referencesOf(body: Record<string, unknown>): string[];
82
+ /**
83
+ * The first `type.name` written in a string, if any.
84
+ *
85
+ * @param text - one attribute value.
86
+ * @returns the referenced address, or `undefined`.
87
+ */
88
+ export declare function firstReference(text: string): string | undefined;
89
+ /**
90
+ * The value of one body attribute, if it is a plain string.
91
+ *
92
+ * Only plain strings are returned. An expression (`${...}`, `var.x`,
93
+ * `local.y`) has no value this module can know — terraform has not run — so it
94
+ * is reported as `undefined` rather than rendered as the expression text, which
95
+ * a reader would mistake for the deployed value.
96
+ *
97
+ * @param body - one resource block's body.
98
+ * @param key - the attribute name.
99
+ * @returns the literal value, or `undefined`.
100
+ */
101
+ export declare function literalOf(body: Record<string, unknown>, key: string): string | undefined;
102
+ /**
103
+ * Every string contained anywhere in a value, including nested collections.
104
+ *
105
+ * @param value - any parsed body value.
106
+ * @returns the strings it contains, in traversal order.
107
+ */
108
+ export declare function stringsIn(value: unknown): string[];
109
+ /**
110
+ * Every resource block a directory's `.tf` files declare, including its modules.
111
+ *
112
+ * ## What counts as this deployment's configuration
113
+ *
114
+ * A `.tf` file directly in the workspace, and any file under a **local module
115
+ * directory** that the configuration calls. Nothing else.
116
+ *
117
+ * That boundary is not a guess: terraform records its own resolution in
118
+ * `<dir>/.terraform/modules/modules.json`, which names each module's `Source`
119
+ * and the `Dir` it was unpacked into. A local module (`source = "./modules/net"`)
120
+ * unpacks to a directory that is part of the workspace — editing it changes the
121
+ * plan, verified — so its resources belong to the design. A remote module
122
+ * unpacks under `.terraform/modules/`, which is where terraform keeps
123
+ * downloaded artifacts, and its content is a dependency rather than part of
124
+ * what this deployment wrote.
125
+ *
126
+ * Reading only `modules.json`'s local entries also settles the case a recursive
127
+ * directory walk gets wrong: a `modules/` folder holding something nothing
128
+ * references is not part of the configuration, and neither is a vendored copy
129
+ * of an unrelated module.
130
+ *
131
+ * ## Why all callers share it
132
+ *
133
+ * The design tool, the design gate, the spec check, the configuration digest and
134
+ * the plaintext-credential scan each ask "what does this deployment declare",
135
+ * for their own reasons. When they answer differently the disagreement is
136
+ * silent: a design gate that sees no network in a configuration whose resources
137
+ * live in a module refuses an apply that `terraform validate` has already
138
+ * passed. So the boundary is decided once, here.
139
+ *
140
+ * ## What it does NOT recurse into
141
+ *
142
+ * `.terraform/` is skipped wholesale. That is where providers, downloaded
143
+ * modules and the state live — none of it is authored configuration, and the
144
+ * digest already excludes it.
145
+ *
146
+ * @param directory - the deployment workspace directory.
147
+ * @returns every parsed block, and the files that could not be parsed.
148
+ */
149
+ export declare function parseConfiguration(directory: string): Promise<{
150
+ readonly blocks: readonly ResourceBlock[];
151
+ readonly unparsed: readonly string[];
152
+ }>;
153
+ /**
154
+ * Every `.tf` file that belongs to a deployment, as paths relative to it.
155
+ *
156
+ * Sorted, so two runs agree on order. A directory that does not exist yields an
157
+ * empty list rather than throwing: callers treat "nothing declared" as a normal
158
+ * answer, and an absent directory is the state before `create_deployment`.
159
+ *
160
+ * @param directory - the deployment workspace directory.
161
+ * @returns the relative paths, workspace files first, then local modules'.
162
+ */
163
+ export declare function configurationFiles(directory: string): Promise<string[]>;
164
+ /**
165
+ * Whether a file name is terraform configuration.
166
+ *
167
+ * Both syntaxes terraform reads: `.tf` (HCL) and `.tf.json` (the JSON form). A
168
+ * `.tfvars` or `.tfvars.json` is NOT — those carry values for variables, not
169
+ * resources, and reading them as configuration would put their contents into
170
+ * the digest and the credential scan as if they were authored resources.
171
+ *
172
+ * @param name - a file's base name.
173
+ * @returns whether it declares configuration.
174
+ */
175
+ export declare function isConfigurationFile(name: string): boolean;
176
+ //# sourceMappingURL=hcl.d.ts.map
@@ -40,8 +40,16 @@ import type { Context, Volatile } from '@deepseek-ai/cordis';
40
40
  import z from '@deepseek-ai/schemastery';
41
41
  /** Plugin config. */
42
42
  export interface Config {
43
- /** Region every signed request and terraform run uses; defaults to `'cn-north-4'`. */
44
- readonly defaultRegion: Volatile<string>;
43
+ /**
44
+ * A region to fall back on when a plan does not name one.
45
+ *
46
+ * Undefined unless an operator sets it. Region is a property of each resource,
47
+ * not of the account or the plugin: a deployment may span several, and a
48
+ * default applied to all of them would silently price and provision the wrong
49
+ * one. So there is no built-in value — a deployment that wants one says so
50
+ * here, and the same value is what terraform is given as `HW_REGION_NAME`.
51
+ */
52
+ readonly defaultRegion: Volatile<string | undefined>;
45
53
  /**
46
54
  * Per-call timeout in milliseconds.
47
55
  *
@@ -57,12 +65,18 @@ export interface Config {
57
65
  * Every field is Volatile: each is a deployment fact that may differ between
58
66
  * profiles, and a change should apply to the next call rather than require a
59
67
  * restart. The bridge reads them through thunks for that reason.
68
+ *
69
+ * `defaultRegion` has no `.default()`. A built-in region would be a guess
70
+ * dressed as configuration — the one thing this plugin must not do, because the
71
+ * two places it is used (terraform's `HW_REGION_NAME` and the fallback price
72
+ * region) must agree, and a wrong pair quotes one region while deploying to
73
+ * another.
60
74
  */
61
75
  export declare const Config: z<Schemastery.ObjectS<NoInfer<{
62
- defaultRegion: z<string, string, "volatile-defined">;
76
+ defaultRegion: z<string, string, "volatile">;
63
77
  toolCallTimeoutMs: z<number, number, "volatile-defined">;
64
78
  }>>, Schemastery.ObjectT<NoInfer<{
65
- defaultRegion: z<string, string, "volatile-defined">;
79
+ defaultRegion: z<string, string, "volatile">;
66
80
  toolCallTimeoutMs: z<number, number, "volatile-defined">;
67
81
  }>>, "plain">;
68
82
  export declare const name = "aishell-deploy";
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Subnets, which RMS does not report.
3
+ *
4
+ * ## Why this module exists
5
+ *
6
+ * A network picture is a network and its subdivisions. RMS reports one of those
7
+ * two levels: a `service: "vpc"` query comes back with `vpcs`,
8
+ * `securityGroups`, `publicips` and `bandwidths` and no subnets at all —
9
+ * confirmed against a live 49-resource account. So an inventory built only from
10
+ * RMS cannot place a server in its subnet, because the subnet is not in the
11
+ * data to place it in.
12
+ *
13
+ * The VPC API does list them, per region and with the `vpc_id` that puts each
14
+ * one inside its VPC. This module reads that, in the vocabulary the inventory
15
+ * already speaks (`provider: "vpc"`, `type: "subnets"`), so the derivation
16
+ * places them and everything that names them without knowing where they came
17
+ * from.
18
+ *
19
+ * ## Why only subnets
20
+ *
21
+ * The same reasoning would justify reaching for any resource RMS misses, and
22
+ * that is exactly the trap. Subnets are asked for because the picture's own
23
+ * structure has a second level and RMS omits it; a resource RMS omits that the
24
+ * picture has no place for is not a gap, it is something the picture is not
25
+ * about. Adding a service here because it is missing would turn this module
26
+ * into a per-service compatibility list.
27
+ *
28
+ * @module @huaweidevtools/aishell-dsh-deploy/inventory-subnets
29
+ */
30
+ /** One subnet, in the shape the inventory's other resources arrive in. */
31
+ export interface InventorySubnet {
32
+ readonly id: string;
33
+ readonly name: string;
34
+ readonly provider: 'vpc';
35
+ readonly type: 'subnets';
36
+ readonly region: string;
37
+ readonly properties: Readonly<Record<string, unknown>>;
38
+ }
39
+ /** The VPC API's subnet record: only the fields this module reads. */
40
+ interface VpcSubnet {
41
+ readonly id?: unknown;
42
+ readonly name?: unknown;
43
+ readonly cidr?: unknown;
44
+ readonly vpc_id?: unknown;
45
+ readonly gateway_ip?: unknown;
46
+ readonly status?: unknown;
47
+ }
48
+ /**
49
+ * Every subnet the account has in one region.
50
+ *
51
+ * Best-effort by contract: a caller completes an inventory, and a region whose
52
+ * subnets could not be read is worse off without its other resources, not
53
+ * better. So a failure is reported rather than thrown, and the caller decides
54
+ * what to say about it.
55
+ *
56
+ * @param region - the region to list.
57
+ * @returns the subnets, or the reason they could not be read.
58
+ */
59
+ export declare function subnetsInRegion(region: string): Promise<{
60
+ readonly subnets: InventorySubnet[];
61
+ readonly failure?: string;
62
+ }>;
63
+ /**
64
+ * One VPC API subnet as an inventory resource.
65
+ *
66
+ * `properties.vpc_id` is what places it: `locationRank` reads the attribute's
67
+ * noun, so a subnet with this field lands inside its VPC by the same rule that
68
+ * puts anything else where it lives. The CIDR and gateway go along because a
69
+ * reader comparing subnets needs to see the ranges.
70
+ *
71
+ * @param subnet - one record from the API.
72
+ * @param region - the region it came from.
73
+ * @returns the resource, or `undefined` when it is missing the id every node
74
+ * needs.
75
+ */
76
+ export declare function asInventorySubnet(subnet: VpcSubnet, region: string): InventorySubnet | undefined;
77
+ export {};
78
+ //# sourceMappingURL=inventory-subnets.d.ts.map