@intentius/chant-lexicon-terraform 0.124.54 → 0.124.56

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 (351) hide show
  1. package/README.md +7 -4
  2. package/dist/ci-setup.d.ts +11 -0
  3. package/dist/ci-setup.d.ts.map +1 -0
  4. package/dist/ci-setup.js +41 -0
  5. package/dist/components/capability-plugin.d.ts +40 -6
  6. package/dist/components/capability-plugin.d.ts.map +1 -1
  7. package/dist/components/capability-plugin.js +174 -30
  8. package/dist/components/compose-group.d.ts +1 -1
  9. package/dist/components/compose-group.d.ts.map +1 -1
  10. package/dist/components/compose-group.js +1 -1
  11. package/dist/components/release-inputs.d.ts +29 -0
  12. package/dist/components/release-inputs.d.ts.map +1 -0
  13. package/dist/components/release-inputs.js +57 -0
  14. package/dist/components/trace-facts.d.ts +16 -0
  15. package/dist/components/trace-facts.d.ts.map +1 -0
  16. package/dist/components/trace-facts.js +19 -0
  17. package/dist/cone.d.ts +53 -0
  18. package/dist/cone.d.ts.map +1 -0
  19. package/dist/cone.js +119 -0
  20. package/dist/cost-hold.d.ts +27 -0
  21. package/dist/cost-hold.d.ts.map +1 -0
  22. package/dist/cost-hold.js +21 -0
  23. package/dist/drift-rows.d.ts +61 -0
  24. package/dist/drift-rows.d.ts.map +1 -0
  25. package/dist/drift-rows.js +108 -0
  26. package/dist/exit-codes.d.ts +55 -0
  27. package/dist/exit-codes.d.ts.map +1 -0
  28. package/dist/exit-codes.js +48 -0
  29. package/dist/index.d.ts +2 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +3 -0
  32. package/dist/integrity.json +7 -4
  33. package/dist/lint/audit-catalog.d.ts.map +1 -1
  34. package/dist/lint/audit-catalog.js +27 -3
  35. package/dist/lint/audit-lineage.d.ts +14 -2
  36. package/dist/lint/audit-lineage.d.ts.map +1 -1
  37. package/dist/lint/post-synth/index.d.ts.map +1 -1
  38. package/dist/lint/post-synth/index.js +4 -0
  39. package/dist/lint/post-synth/record-store.d.ts +54 -0
  40. package/dist/lint/post-synth/record-store.d.ts.map +1 -0
  41. package/dist/lint/post-synth/record-store.js +104 -0
  42. package/dist/lint/post-synth/tf001.d.ts +2 -2
  43. package/dist/lint/post-synth/tf001.js +2 -2
  44. package/dist/lint/post-synth/tf024.d.ts +35 -11
  45. package/dist/lint/post-synth/tf024.d.ts.map +1 -1
  46. package/dist/lint/post-synth/tf024.js +92 -20
  47. package/dist/lint/post-synth/tf046.d.ts +64 -0
  48. package/dist/lint/post-synth/tf046.d.ts.map +1 -0
  49. package/dist/lint/post-synth/tf046.js +175 -0
  50. package/dist/lint/post-synth/tf047.d.ts +36 -0
  51. package/dist/lint/post-synth/tf047.d.ts.map +1 -0
  52. package/dist/lint/post-synth/tf047.js +94 -0
  53. package/dist/lock-rows.d.ts +36 -0
  54. package/dist/lock-rows.d.ts.map +1 -0
  55. package/dist/lock-rows.js +60 -0
  56. package/dist/lock-timeout.d.ts +22 -0
  57. package/dist/lock-timeout.d.ts.map +1 -0
  58. package/dist/lock-timeout.js +32 -0
  59. package/dist/manifest.json +1 -1
  60. package/dist/module-catalog/index.d.ts +69 -0
  61. package/dist/module-catalog/index.d.ts.map +1 -0
  62. package/dist/module-catalog/index.js +110 -0
  63. package/dist/module-catalog/refresh-cli.d.ts +4 -0
  64. package/dist/module-catalog/refresh-cli.d.ts.map +1 -0
  65. package/dist/module-catalog/refresh-cli.js +64 -0
  66. package/dist/module-catalog/static-tier.d.ts +6 -0
  67. package/dist/module-catalog/static-tier.d.ts.map +1 -0
  68. package/dist/module-catalog/static-tier.js +1650 -0
  69. package/dist/module-catalog/types.d.ts +65 -0
  70. package/dist/module-catalog/types.d.ts.map +1 -0
  71. package/dist/module-catalog/types.js +33 -0
  72. package/dist/okf/index.md +3 -1
  73. package/dist/okf/rules/TF024.md +2 -2
  74. package/dist/okf/rules/TF046.md +11 -0
  75. package/dist/okf/rules/TF047.md +11 -0
  76. package/dist/op/activities/terraform.d.ts +29 -0
  77. package/dist/op/activities/terraform.d.ts.map +1 -1
  78. package/dist/op/activities/terraform.js +19 -4
  79. package/dist/pin/consumers.d.ts +35 -0
  80. package/dist/pin/consumers.d.ts.map +1 -0
  81. package/dist/pin/consumers.js +70 -0
  82. package/dist/plugin.d.ts.map +1 -1
  83. package/dist/plugin.js +5 -0
  84. package/dist/registry/address.d.ts +63 -0
  85. package/dist/registry/address.d.ts.map +1 -0
  86. package/dist/registry/address.js +65 -0
  87. package/dist/registry/catalog-read.d.ts +14 -0
  88. package/dist/registry/catalog-read.d.ts.map +1 -0
  89. package/dist/registry/catalog-read.js +58 -0
  90. package/dist/registry/deprecated.d.ts +37 -0
  91. package/dist/registry/deprecated.d.ts.map +1 -0
  92. package/dist/registry/deprecated.js +43 -0
  93. package/dist/registry/docs.d.ts +96 -0
  94. package/dist/registry/docs.d.ts.map +1 -0
  95. package/dist/registry/docs.js +210 -0
  96. package/dist/registry/edge/edge.d.ts +46 -0
  97. package/dist/registry/edge/edge.d.ts.map +1 -0
  98. package/dist/registry/edge/edge.js +194 -0
  99. package/dist/registry/edge/index.d.ts +11 -0
  100. package/dist/registry/edge/index.d.ts.map +1 -0
  101. package/dist/registry/edge/index.js +10 -0
  102. package/dist/registry/edge/lambda-edge.d.ts +76 -0
  103. package/dist/registry/edge/lambda-edge.d.ts.map +1 -0
  104. package/dist/registry/edge/lambda-edge.js +95 -0
  105. package/dist/registry/edge/sigv4-web.d.ts +33 -0
  106. package/dist/registry/edge/sigv4-web.d.ts.map +1 -0
  107. package/dist/registry/edge/sigv4-web.js +56 -0
  108. package/dist/registry/edge/token-source.d.ts +73 -0
  109. package/dist/registry/edge/token-source.d.ts.map +1 -0
  110. package/dist/registry/edge/token-source.js +115 -0
  111. package/dist/registry/edge/worker.d.ts +45 -0
  112. package/dist/registry/edge/worker.d.ts.map +1 -0
  113. package/dist/registry/edge/worker.js +26 -0
  114. package/dist/registry/handler.d.ts +25 -0
  115. package/dist/registry/handler.d.ts.map +1 -0
  116. package/dist/registry/handler.js +75 -0
  117. package/dist/registry/headers-file.d.ts +21 -0
  118. package/dist/registry/headers-file.d.ts.map +1 -0
  119. package/dist/registry/headers-file.js +57 -0
  120. package/dist/registry/index.d.ts +31 -0
  121. package/dist/registry/index.d.ts.map +1 -0
  122. package/dist/registry/index.js +30 -0
  123. package/dist/registry/mirror-paths.d.ts +9 -0
  124. package/dist/registry/mirror-paths.d.ts.map +1 -0
  125. package/dist/registry/mirror-paths.js +8 -0
  126. package/dist/registry/mirror.d.ts +130 -0
  127. package/dist/registry/mirror.d.ts.map +1 -0
  128. package/dist/registry/mirror.js +319 -0
  129. package/dist/registry/proxies.d.ts +73 -0
  130. package/dist/registry/proxies.d.ts.map +1 -0
  131. package/dist/registry/proxies.js +111 -0
  132. package/dist/registry/reader.d.ts +57 -0
  133. package/dist/registry/reader.d.ts.map +1 -0
  134. package/dist/registry/reader.js +198 -0
  135. package/dist/registry/semver.d.ts +16 -0
  136. package/dist/registry/semver.d.ts.map +1 -0
  137. package/dist/registry/semver.js +24 -0
  138. package/dist/registry/serve.d.ts +24 -0
  139. package/dist/registry/serve.d.ts.map +1 -0
  140. package/dist/registry/serve.js +64 -0
  141. package/dist/registry/source-forms.d.ts +79 -0
  142. package/dist/registry/source-forms.d.ts.map +1 -0
  143. package/dist/registry/source-forms.js +202 -0
  144. package/dist/registry/targets/artifactory.d.ts +28 -0
  145. package/dist/registry/targets/artifactory.d.ts.map +1 -0
  146. package/dist/registry/targets/artifactory.js +206 -0
  147. package/dist/registry/targets/fake-artifactory.d.ts +30 -0
  148. package/dist/registry/targets/fake-artifactory.d.ts.map +1 -0
  149. package/dist/registry/targets/fake-artifactory.js +142 -0
  150. package/dist/registry/targets/fake-gitlab.d.ts +39 -0
  151. package/dist/registry/targets/fake-gitlab.d.ts.map +1 -0
  152. package/dist/registry/targets/fake-gitlab.js +136 -0
  153. package/dist/registry/targets/fake-hcp.d.ts +50 -0
  154. package/dist/registry/targets/fake-hcp.d.ts.map +1 -0
  155. package/dist/registry/targets/fake-hcp.js +202 -0
  156. package/dist/registry/targets/fake-http.d.ts +31 -0
  157. package/dist/registry/targets/fake-http.d.ts.map +1 -0
  158. package/dist/registry/targets/fake-http.js +87 -0
  159. package/dist/registry/targets/fake-nexus.d.ts +27 -0
  160. package/dist/registry/targets/fake-nexus.d.ts.map +1 -0
  161. package/dist/registry/targets/fake-nexus.js +137 -0
  162. package/dist/registry/targets/gitlab.d.ts +53 -0
  163. package/dist/registry/targets/gitlab.d.ts.map +1 -0
  164. package/dist/registry/targets/gitlab.js +187 -0
  165. package/dist/registry/targets/hcp.d.ts +29 -0
  166. package/dist/registry/targets/hcp.d.ts.map +1 -0
  167. package/dist/registry/targets/hcp.js +310 -0
  168. package/dist/registry/targets/hosted.d.ts +62 -0
  169. package/dist/registry/targets/hosted.d.ts.map +1 -0
  170. package/dist/registry/targets/hosted.js +74 -0
  171. package/dist/registry/targets/index.d.ts +18 -0
  172. package/dist/registry/targets/index.d.ts.map +1 -0
  173. package/dist/registry/targets/index.js +17 -0
  174. package/dist/registry/targets/module-target.d.ts +68 -0
  175. package/dist/registry/targets/module-target.d.ts.map +1 -0
  176. package/dist/registry/targets/module-target.js +63 -0
  177. package/dist/registry/targets/nexus.d.ts +43 -0
  178. package/dist/registry/targets/nexus.d.ts.map +1 -0
  179. package/dist/registry/targets/nexus.js +250 -0
  180. package/dist/registry/targets/zip.d.ts +55 -0
  181. package/dist/registry/targets/zip.d.ts.map +1 -0
  182. package/dist/registry/targets/zip.js +278 -0
  183. package/dist/registry/writer.d.ts +101 -0
  184. package/dist/registry/writer.d.ts.map +1 -0
  185. package/dist/registry/writer.js +109 -0
  186. package/dist/rules/record-store.ts +122 -0
  187. package/dist/rules/tf001.ts +2 -2
  188. package/dist/rules/tf024.ts +105 -22
  189. package/dist/rules/tf046.ts +204 -0
  190. package/dist/rules/tf047.ts +114 -0
  191. package/dist/state/azure-blob.d.ts +8 -67
  192. package/dist/state/azure-blob.d.ts.map +1 -1
  193. package/dist/state/azure-blob.js +6 -199
  194. package/dist/state/gcs.d.ts +7 -61
  195. package/dist/state/gcs.d.ts.map +1 -1
  196. package/dist/state/gcs.js +5 -222
  197. package/dist/state/object-store.d.ts +4 -33
  198. package/dist/state/object-store.d.ts.map +1 -1
  199. package/dist/state/object-store.js +4 -17
  200. package/dist/state/s3.d.ts +11 -58
  201. package/dist/state/s3.d.ts.map +1 -1
  202. package/dist/state/s3.js +10 -161
  203. package/dist/state/store.js +2 -2
  204. package/dist/state-ops.d.ts +255 -0
  205. package/dist/state-ops.d.ts.map +1 -0
  206. package/dist/state-ops.js +305 -0
  207. package/dist/state-reads.d.ts +57 -0
  208. package/dist/state-reads.d.ts.map +1 -0
  209. package/dist/state-reads.js +104 -0
  210. package/dist/used-sources.d.ts +54 -0
  211. package/dist/used-sources.d.ts.map +1 -0
  212. package/dist/used-sources.js +157 -0
  213. package/package.json +19 -3
  214. package/src/__fixtures__/drift-record/README.md +5 -0
  215. package/src/__fixtures__/drift-rows/live-root-plan.json +70 -0
  216. package/src/__fixtures__/drift-rows/refresh-plan.json +61 -0
  217. package/src/__fixtures__/used-sources/root/extra.tofu +1 -0
  218. package/src/__fixtures__/used-sources/root/main.tf +31 -0
  219. package/src/__fixtures__/used-sources/root/modules/net/main.tf +14 -0
  220. package/src/__fixtures__/used-sources/root/modules/net/versions.tf.json +7 -0
  221. package/src/__fixtures__/used-sources/unit/terragrunt.hcl +3 -0
  222. package/src/ci-setup.ts +42 -0
  223. package/src/components/capability-plugin.test.ts +26 -14
  224. package/src/components/capability-plugin.ts +185 -31
  225. package/src/components/compose-group.ts +1 -1
  226. package/src/components/pr-loop-compose.tofu.e2e.test.ts +1 -1
  227. package/src/components/pr-loop.tofu.test.ts +1 -1
  228. package/src/components/release-inputs.ts +69 -0
  229. package/src/components/trace-facts.test.ts +21 -0
  230. package/src/components/trace-facts.ts +27 -0
  231. package/src/cone.ts +138 -0
  232. package/src/cost-hold.ts +29 -0
  233. package/src/describe-resources.engine-facts.test.ts +2 -3
  234. package/src/drift-rows.test.ts +135 -0
  235. package/src/drift-rows.ts +137 -0
  236. package/src/exit-codes.test.ts +23 -0
  237. package/src/exit-codes.ts +59 -0
  238. package/src/index.ts +3 -0
  239. package/src/lint/audit-catalog.ts +29 -3
  240. package/src/lint/audit-lineage.ts +14 -2
  241. package/src/lint/post-synth/fixtures/TF024/live-with-record-store/main.tf +18 -0
  242. package/src/lint/post-synth/fixtures/TF024/sidecar-with-backend/estate.chdf.hcl +1 -0
  243. package/src/lint/post-synth/fixtures/TF024/sidecar-with-backend/main.tf +10 -0
  244. package/src/lint/post-synth/fixtures/TF046/azurerm-no-resource-group/main.tf +15 -0
  245. package/src/lint/post-synth/fixtures/TF046/backend-config-only/main.tf +14 -0
  246. package/src/lint/post-synth/fixtures/TF046/derived-s3/backend.tf +7 -0
  247. package/src/lint/post-synth/fixtures/TF046/derived-s3/main.tf +9 -0
  248. package/src/lint/post-synth/fixtures/TF046/explicit-local/main.tf +16 -0
  249. package/src/lint/post-synth/fixtures/TF046/explicit-s3-beside-local-backend/main.tf +15 -0
  250. package/src/lint/post-synth/fixtures/TF046/implied-local/main.tf +9 -0
  251. package/src/lint/post-synth/fixtures/TF046/sidecar-implied/estate.chdf.hcl +1 -0
  252. package/src/lint/post-synth/fixtures/TF046/sidecar-implied/main.tf +5 -0
  253. package/src/lint/post-synth/fixtures/TF047/clear/main.tf +12 -0
  254. package/src/lint/post-synth/fixtures/TF047/refused/main.tf +12 -0
  255. package/src/lint/post-synth/fixtures/TF047/unknown-module/main.tf +12 -0
  256. package/src/lint/post-synth/fixtures/TF047/unknown-version/main.tf +12 -0
  257. package/src/lint/post-synth/index.ts +4 -0
  258. package/src/lint/post-synth/record-store.ts +122 -0
  259. package/src/lint/post-synth/tf001.ts +2 -2
  260. package/src/lint/post-synth/tf024.test.ts +26 -5
  261. package/src/lint/post-synth/tf024.ts +105 -22
  262. package/src/lint/post-synth/tf046.test.ts +137 -0
  263. package/src/lint/post-synth/tf046.ts +204 -0
  264. package/src/lint/post-synth/tf047.test.ts +56 -0
  265. package/src/lint/post-synth/tf047.ts +114 -0
  266. package/src/lock-rows.test.ts +70 -0
  267. package/src/lock-rows.ts +82 -0
  268. package/src/lock-timeout.ts +34 -0
  269. package/src/module-catalog/index.test.ts +93 -0
  270. package/src/module-catalog/index.ts +159 -0
  271. package/src/module-catalog/refresh-cli.ts +68 -0
  272. package/src/module-catalog/static-tier.ts +1659 -0
  273. package/src/module-catalog/types.ts +88 -0
  274. package/src/op/activities/terraform.ts +46 -5
  275. package/src/op-wave-step.test.ts +109 -0
  276. package/src/pin/__fixtures__/consumers/live/dev/main.tf +4 -0
  277. package/src/pin/__fixtures__/consumers/live/prod/main.tf +21 -0
  278. package/src/pin/__fixtures__/consumers/units/vpc/terragrunt.hcl +7 -0
  279. package/src/pin/consumers.test.ts +57 -0
  280. package/src/pin/consumers.ts +95 -0
  281. package/src/plugin.ts +6 -0
  282. package/src/registry/__fixtures__/docs/documented/.terraform-docs.yml +3 -0
  283. package/src/registry/__fixtures__/docs/documented/README.md +1 -0
  284. package/src/registry/__fixtures__/docs/documented/main.tf +8 -0
  285. package/src/registry/__fixtures__/docs/json/main.tf.json +14 -0
  286. package/src/registry/__fixtures__/docs/vpc/README.md +3 -0
  287. package/src/registry/__fixtures__/docs/vpc/examples/complete/main.tf +5 -0
  288. package/src/registry/__fixtures__/docs/vpc/examples/simple/README.md +1 -0
  289. package/src/registry/__fixtures__/docs/vpc/examples/simple/main.tf +4 -0
  290. package/src/registry/__fixtures__/docs/vpc/main.tf +14 -0
  291. package/src/registry/__fixtures__/docs/vpc/outputs.tf +9 -0
  292. package/src/registry/__fixtures__/docs/vpc/variables.tf +16 -0
  293. package/src/registry/__fixtures__/proxied-root/main.tf +12 -0
  294. package/src/registry/address.ts +100 -0
  295. package/src/registry/catalog-read.ts +56 -0
  296. package/src/registry/deprecated.test.ts +139 -0
  297. package/src/registry/deprecated.ts +76 -0
  298. package/src/registry/docs.test.ts +140 -0
  299. package/src/registry/docs.ts +299 -0
  300. package/src/registry/edge/bundle.test.ts +50 -0
  301. package/src/registry/edge/edge.test.ts +176 -0
  302. package/src/registry/edge/edge.ts +211 -0
  303. package/src/registry/edge/index.ts +10 -0
  304. package/src/registry/edge/lambda-edge.ts +127 -0
  305. package/src/registry/edge/sigv4-web.ts +79 -0
  306. package/src/registry/edge/token-source.test.ts +258 -0
  307. package/src/registry/edge/token-source.ts +169 -0
  308. package/src/registry/edge/worker.ts +61 -0
  309. package/src/registry/handler.ts +89 -0
  310. package/src/registry/headers-file.ts +61 -0
  311. package/src/registry/index.ts +31 -0
  312. package/src/registry/mirror-paths.ts +10 -0
  313. package/src/registry/mirror.test.ts +198 -0
  314. package/src/registry/mirror.ts +395 -0
  315. package/src/registry/proxies.test.ts +153 -0
  316. package/src/registry/proxies.ts +132 -0
  317. package/src/registry/reader.ts +225 -0
  318. package/src/registry/registry.test.ts +262 -0
  319. package/src/registry/semver.ts +34 -0
  320. package/src/registry/serve.ts +82 -0
  321. package/src/registry/source-forms.test.ts +87 -0
  322. package/src/registry/source-forms.ts +216 -0
  323. package/src/registry/targets/artifactory.test.ts +248 -0
  324. package/src/registry/targets/artifactory.ts +257 -0
  325. package/src/registry/targets/fake-artifactory.ts +158 -0
  326. package/src/registry/targets/fake-gitlab.ts +161 -0
  327. package/src/registry/targets/fake-hcp.ts +233 -0
  328. package/src/registry/targets/fake-http.ts +97 -0
  329. package/src/registry/targets/fake-nexus.ts +152 -0
  330. package/src/registry/targets/gitlab.test.ts +208 -0
  331. package/src/registry/targets/gitlab.ts +223 -0
  332. package/src/registry/targets/hcp.test.ts +230 -0
  333. package/src/registry/targets/hcp.ts +360 -0
  334. package/src/registry/targets/hosted.ts +117 -0
  335. package/src/registry/targets/index.ts +17 -0
  336. package/src/registry/targets/module-target.ts +131 -0
  337. package/src/registry/targets/nexus.test.ts +220 -0
  338. package/src/registry/targets/nexus.ts +314 -0
  339. package/src/registry/targets/zip.test.ts +65 -0
  340. package/src/registry/targets/zip.ts +287 -0
  341. package/src/registry/writer.ts +155 -0
  342. package/src/state/azure-blob.ts +6 -221
  343. package/src/state/gcs.ts +5 -252
  344. package/src/state/object-store.ts +4 -32
  345. package/src/state/s3.ts +10 -182
  346. package/src/state/store.ts +2 -2
  347. package/src/state-ops.test.ts +182 -0
  348. package/src/state-ops.ts +462 -0
  349. package/src/state-reads.ts +116 -0
  350. package/src/used-sources.test.ts +75 -0
  351. package/src/used-sources.ts +204 -0
@@ -1,68 +1,21 @@
1
- import { type StoreFetch } from "./object-store.js";
2
- export interface S3Credentials {
3
- accessKeyId: string;
4
- secretAccessKey: string;
5
- sessionToken?: string;
6
- }
7
- /** A role to assume with the job's OIDC token, the way the AWS SDKs read `AWS_ROLE_ARN` and `AWS_WEB_IDENTITY_TOKEN_FILE`. */
8
- export interface S3WebIdentity {
9
- roleArn: string;
10
- tokenFile: string;
11
- sessionName: string;
12
- /** STS's address, https://host[:port], no path. */
13
- endpoint: string;
14
- }
15
- export interface S3Location {
16
- bucket: string;
17
- /** https://host[:port], no path. Default: AWS's regional endpoint. */
18
- endpoint?: string;
19
- region: string;
20
- }
21
- export type S3Target = S3Location & (S3Credentials | {
22
- webIdentity: S3WebIdentity;
23
- });
1
+ /**
2
+ * The S3 client a state's lock and write use: chant core's (#4554,
3
+ * `@intentius/chant/object-store`), which signs with chant's one AWS
4
+ * signer. Get, put, put only when absent, head and delete one object; with
5
+ * no static keys, a role is assumed with the job's OIDC token through STS
6
+ * AssumeRoleWithWebIdentity.
7
+ */
8
+ import { type S3Target } from "@intentius/chant/object-store";
9
+ export { assumeRoleWithWebIdentity, S3Client, sign, type S3Credentials, type S3Location, type S3Target, type S3WebIdentity } from "@intentius/chant/object-store";
24
10
  /**
25
11
  * The target for `bucket` from the AWS environment variables. Credentials,
26
12
  * first match wins: static keys in `AWS_ACCESS_KEY_ID` and
27
13
  * `AWS_SECRET_ACCESS_KEY`; `AWS_ROLE_ARN` assumed with the token in
28
- * `AWS_WEB_IDENTITY_TOKEN_FILE`.
14
+ * `AWS_WEB_IDENTITY_TOKEN_FILE`, in a session named `chant-state` unless
15
+ * AWS_ROLE_SESSION_NAME names one.
29
16
  */
30
17
  export declare function s3FromEnv(where: {
31
18
  bucket: string;
32
19
  endpoint?: string;
33
20
  }, env?: NodeJS.ProcessEnv): S3Target;
34
- /** STS AssumeRoleWithWebIdentity. The request carries the token and is not signed. */
35
- export declare function assumeRoleWithWebIdentity(w: S3WebIdentity, fetchFn: StoreFetch, readToken?: (file: string) => string): Promise<S3Credentials & {
36
- expiration?: Date;
37
- }>;
38
- /** Signature Version 4 headers for a request; its query string, if any, is signed in canonical order. `extra` headers are signed too. */
39
- export declare function sign(t: Pick<S3Location, "region"> & S3Credentials, method: string, rawUrl: string, extra: Record<string, string>, payload: string, now: Date, service?: string): Record<string, string>;
40
- export declare class S3Client {
41
- readonly target: S3Target;
42
- private readonly fetchFn;
43
- private creds?;
44
- constructor(target: S3Target, fetchFn?: StoreFetch);
45
- private where;
46
- /** Static keys as given; a web identity's keys once per client, again a minute before they expire. */
47
- private signer;
48
- private request;
49
- /** Write an object, unconditionally. */
50
- put(key: string, body: string, contentType: string): Promise<void>;
51
- /** The object's text, or undefined when there is none. */
52
- get(key: string): Promise<string | undefined>;
53
- /** The object's metadata and never its body: whether it exists, its ETag and its version id. */
54
- head(key: string): Promise<{
55
- exists: boolean;
56
- etag?: string;
57
- versionId?: string;
58
- }>;
59
- /**
60
- * Write an object only when there is none (If-None-Match: *): true when
61
- * this write made it, false when one was there. A store that refuses the
62
- * condition fails the write: a lock is never taken unconditionally.
63
- */
64
- putIfAbsent(key: string, body: string, contentType: string): Promise<boolean>;
65
- /** Delete an object. One that is not there is deleted already. */
66
- remove(key: string): Promise<void>;
67
- }
68
21
  //# sourceMappingURL=s3.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../src/state/s3.ts"],"names":[],"mappings":"AAaA,OAAO,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KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAElK;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,QAAQ,CAEtH"}
package/dist/state/s3.js CHANGED
@@ -1,170 +1,19 @@
1
1
  /**
2
- * The little of S3 a state's lock and write need: get, put, put only when
3
- * absent, head and delete one object, signed with AWS Signature Version 4
4
- * from `node:crypto`. Any S3-compatible store answers it (S3, MinIO, floci).
5
- * With no static keys, a role is assumed with the job's OIDC token through
6
- * STS AssumeRoleWithWebIdentity. `fetch` is injectable so the signing is
7
- * tested against recorded requests.
8
- *
9
- * Lifted from terragucci's `report/s3.ts` (c493e0e), without presigning,
10
- * version listing and the re-plan's traded credentials.
2
+ * The S3 client a state's lock and write use: chant core's (#4554,
3
+ * `@intentius/chant/object-store`), which signs with chant's one AWS
4
+ * signer. Get, put, put only when absent, head and delete one object; with
5
+ * no static keys, a role is assumed with the job's OIDC token through STS
6
+ * AssumeRoleWithWebIdentity.
11
7
  */
12
- import { createHash, createHmac } from "node:crypto";
13
- import { readFileSync } from "node:fs";
14
- import { defaultFetch, encodePath, encodeStrict, StoreError, xmlText } from "./object-store.js";
8
+ import { s3FromEnv as coreS3FromEnv } from "@intentius/chant/object-store";
9
+ export { assumeRoleWithWebIdentity, S3Client, sign } from "@intentius/chant/object-store";
15
10
  /**
16
11
  * The target for `bucket` from the AWS environment variables. Credentials,
17
12
  * first match wins: static keys in `AWS_ACCESS_KEY_ID` and
18
13
  * `AWS_SECRET_ACCESS_KEY`; `AWS_ROLE_ARN` assumed with the token in
19
- * `AWS_WEB_IDENTITY_TOKEN_FILE`.
14
+ * `AWS_WEB_IDENTITY_TOKEN_FILE`, in a session named `chant-state` unless
15
+ * AWS_ROLE_SESSION_NAME names one.
20
16
  */
21
17
  export function s3FromEnv(where, env = process.env) {
22
- const endpoint = where.endpoint ?? env.AWS_ENDPOINT_URL_S3 ?? env.AWS_ENDPOINT_URL;
23
- const region = env.AWS_REGION || env.AWS_DEFAULT_REGION || "us-east-1";
24
- const at = { bucket: where.bucket, ...(endpoint ? { endpoint: endpoint.replace(/\/+$/, "") } : {}), region };
25
- const accessKeyId = env.AWS_ACCESS_KEY_ID;
26
- const secretAccessKey = env.AWS_SECRET_ACCESS_KEY;
27
- if (accessKeyId && secretAccessKey)
28
- return { ...at, accessKeyId, secretAccessKey, ...(env.AWS_SESSION_TOKEN ? { sessionToken: env.AWS_SESSION_TOKEN } : {}) };
29
- const tokenFile = env.AWS_WEB_IDENTITY_TOKEN_FILE;
30
- if (env.AWS_ROLE_ARN && tokenFile) {
31
- return {
32
- ...at,
33
- webIdentity: {
34
- roleArn: env.AWS_ROLE_ARN,
35
- tokenFile,
36
- sessionName: env.AWS_ROLE_SESSION_NAME || "chant-state",
37
- endpoint: (env.AWS_ENDPOINT_URL_STS || env.AWS_ENDPOINT_URL || `https://sts.${region}.amazonaws.com`).replace(/\/+$/, ""),
38
- },
39
- };
40
- }
41
- throw new StoreError("set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, or AWS_ROLE_ARN and AWS_WEB_IDENTITY_TOKEN_FILE");
42
- }
43
- /** STS AssumeRoleWithWebIdentity. The request carries the token and is not signed. */
44
- export async function assumeRoleWithWebIdentity(w, fetchFn, readToken = (f) => readFileSync(f, "utf-8")) {
45
- let token;
46
- try {
47
- token = readToken(w.tokenFile).trim();
48
- }
49
- catch (e) {
50
- throw new StoreError(`cannot read the OIDC token in ${w.tokenFile}: ${e.message}`);
51
- }
52
- if (!token)
53
- throw new StoreError(`the OIDC token file ${w.tokenFile} is empty`);
54
- const body = new URLSearchParams({ Action: "AssumeRoleWithWebIdentity", Version: "2011-06-15", RoleArn: w.roleArn, RoleSessionName: w.sessionName, WebIdentityToken: token }).toString();
55
- const res = await fetchFn(`${w.endpoint}/`, { method: "POST", headers: { "content-type": "application/x-www-form-urlencoded; charset=utf-8", accept: "application/xml" }, body });
56
- const xml = await res.text();
57
- if (!res.ok) {
58
- const why = [xmlText(xml, "Code"), xmlText(xml, "Message")].filter(Boolean).join(": ") || xml.slice(0, 300);
59
- throw new StoreError(`AssumeRoleWithWebIdentity for ${w.roleArn}: ${res.status} ${why}`);
60
- }
61
- const accessKeyId = xmlText(xml, "AccessKeyId");
62
- const secretAccessKey = xmlText(xml, "SecretAccessKey");
63
- const sessionToken = xmlText(xml, "SessionToken");
64
- if (!accessKeyId || !secretAccessKey || !sessionToken)
65
- throw new StoreError(`AssumeRoleWithWebIdentity for ${w.roleArn} answered without credentials`);
66
- const expires = xmlText(xml, "Expiration");
67
- return { accessKeyId, secretAccessKey, sessionToken, ...(expires && !Number.isNaN(Date.parse(expires)) ? { expiration: new Date(expires) } : {}) };
68
- }
69
- const sha256 = (b) => createHash("sha256").update(b).digest("hex");
70
- const hmac = (key, s) => createHmac("sha256", key).update(s).digest();
71
- /** Signature Version 4 headers for a request; its query string, if any, is signed in canonical order. `extra` headers are signed too. */
72
- export function sign(t, method, rawUrl, extra, payload, now, service = "s3") {
73
- const url = new URL(rawUrl);
74
- const amzDate = now.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}/, "");
75
- const day = amzDate.slice(0, 8);
76
- const headers = {
77
- host: url.host,
78
- "x-amz-content-sha256": payload,
79
- "x-amz-date": amzDate,
80
- ...Object.fromEntries(Object.entries(extra).map(([k, v]) => [k.toLowerCase(), v])),
81
- ...(t.sessionToken ? { "x-amz-security-token": t.sessionToken } : {}),
82
- };
83
- const names = Object.keys(headers).sort();
84
- const query = [...url.searchParams].map(([k, v]) => `${encodeStrict(k)}=${encodeStrict(v)}`).sort().join("&");
85
- const canonical = [method, url.pathname, query, ...names.map((n) => `${n}:${headers[n].trim()}`), "", names.join(";"), payload].join("\n");
86
- const scope = `${day}/${t.region}/${service}/aws4_request`;
87
- const toSign = ["AWS4-HMAC-SHA256", amzDate, scope, sha256(canonical)].join("\n");
88
- const key4 = hmac(hmac(hmac(hmac(`AWS4${t.secretAccessKey}`, day), t.region), service), "aws4_request");
89
- const signature = createHmac("sha256", key4).update(toSign).digest("hex");
90
- const { host: _host, ...sent } = headers;
91
- return { ...sent, authorization: `AWS4-HMAC-SHA256 Credential=${t.accessKeyId}/${scope}, SignedHeaders=${names.join(";")}, Signature=${signature}` };
92
- }
93
- /** The address of `key` in the bucket: path-style on a custom endpoint, virtual-hosted on AWS. */
94
- const objectUrl = (t, key) => `${t.endpoint ? `${t.endpoint}/${t.bucket}` : `https://${t.bucket}.s3.${t.region}.amazonaws.com`}/${encodePath(key)}`;
95
- export class S3Client {
96
- constructor(target, fetchFn = defaultFetch) {
97
- this.target = target;
98
- this.fetchFn = fetchFn;
99
- }
100
- where(key) {
101
- return `s3://${this.target.bucket}/${key}`;
102
- }
103
- /** Static keys as given; a web identity's keys once per client, again a minute before they expire. */
104
- async signer() {
105
- const t = this.target;
106
- if (!("webIdentity" in t))
107
- return t;
108
- const assume = () => (this.creds = assumeRoleWithWebIdentity(t.webIdentity, this.fetchFn).catch((e) => {
109
- this.creds = undefined;
110
- throw e;
111
- }));
112
- let held = await (this.creds ?? assume());
113
- if (held.expiration && held.expiration.getTime() - Date.now() < 60000)
114
- held = await assume();
115
- const { accessKeyId, secretAccessKey, sessionToken } = held;
116
- return { bucket: t.bucket, ...(t.endpoint ? { endpoint: t.endpoint } : {}), region: t.region, accessKeyId, secretAccessKey, ...(sessionToken ? { sessionToken } : {}) };
117
- }
118
- async request(method, key, body, extra = {}) {
119
- const t = await this.signer();
120
- const url = objectUrl(t, key);
121
- return this.fetchFn(url, { method, headers: sign(t, method, url, extra, sha256(body), new Date()), ...(method === "PUT" ? { body } : {}) });
122
- }
123
- /** Write an object, unconditionally. */
124
- async put(key, body, contentType) {
125
- const res = await this.request("PUT", key, body, { "content-type": contentType });
126
- if (!res.ok)
127
- throw new StoreError(`PUT ${this.where(key)}: ${res.status} ${(await res.text()).slice(0, 300)}`);
128
- }
129
- /** The object's text, or undefined when there is none. */
130
- async get(key) {
131
- const res = await this.request("GET", key, "");
132
- if (res.status === 404)
133
- return undefined;
134
- if (!res.ok)
135
- throw new StoreError(`GET ${this.where(key)}: ${res.status} ${(await res.text()).slice(0, 300)}`);
136
- return res.text();
137
- }
138
- /** The object's metadata and never its body: whether it exists, its ETag and its version id. */
139
- async head(key) {
140
- const res = await this.request("HEAD", key, "");
141
- if (res.status === 404)
142
- return { exists: false };
143
- if (!res.ok)
144
- throw new StoreError(`HEAD ${this.where(key)}: ${res.status}`);
145
- const etag = res.headers?.get("etag") ?? undefined;
146
- const version = res.headers?.get("x-amz-version-id") ?? undefined;
147
- return { exists: true, ...(etag ? { etag } : {}), ...(version && version !== "null" ? { versionId: version } : {}) };
148
- }
149
- /**
150
- * Write an object only when there is none (If-None-Match: *): true when
151
- * this write made it, false when one was there. A store that refuses the
152
- * condition fails the write: a lock is never taken unconditionally.
153
- */
154
- async putIfAbsent(key, body, contentType) {
155
- const res = await this.request("PUT", key, body, { "content-type": contentType, "if-none-match": "*" });
156
- if (res.status === 412 || res.status === 409)
157
- return false;
158
- if (res.status === 501)
159
- throw new StoreError(`PUT ${this.where(key)}: the store does not take a conditional write (501)`);
160
- if (!res.ok)
161
- throw new StoreError(`PUT ${this.where(key)}: ${res.status} ${(await res.text()).slice(0, 300)}`);
162
- return true;
163
- }
164
- /** Delete an object. One that is not there is deleted already. */
165
- async remove(key) {
166
- const res = await this.request("DELETE", key, "");
167
- if (!res.ok && res.status !== 404)
168
- throw new StoreError(`DELETE ${this.where(key)}: ${res.status} ${(await res.text()).slice(0, 300)}`);
169
- }
18
+ return coreS3FromEnv({ ...where, sessionName: "chant-state", setting: "the state bucket" }, env);
170
19
  }
@@ -52,7 +52,7 @@ function s3Store(o, fetchFn) {
52
52
  lock: (info) => client.putIfAbsent(lockKey, info, JSON_TYPE),
53
53
  unlock: () => client.remove(lockKey),
54
54
  readBeside: (suffix) => client.get(`${o.key}${suffix}`),
55
- writeBeside: (suffix, body) => client.put(`${o.key}${suffix}`, body, JSON_TYPE),
55
+ writeBeside: async (suffix, body) => void (await client.put(`${o.key}${suffix}`, body, JSON_TYPE)),
56
56
  removeBeside: (suffix) => client.remove(`${o.key}${suffix}`),
57
57
  besideLocation: (suffix) => `s3://${o.bucket}/${o.key}${suffix}`,
58
58
  adopt: () => { },
@@ -75,7 +75,7 @@ function gcsStore(o, fetchFn) {
75
75
  lock: (info) => client.putIfAbsent(o.lock, info, JSON_TYPE),
76
76
  unlock: () => client.remove(o.lock),
77
77
  readBeside: (suffix) => client.get(`${o.key}${suffix}`),
78
- writeBeside: (suffix, body) => client.put(`${o.key}${suffix}`, body, JSON_TYPE),
78
+ writeBeside: async (suffix, body) => void (await client.put(`${o.key}${suffix}`, body, JSON_TYPE)),
79
79
  removeBeside: (suffix) => client.remove(`${o.key}${suffix}`),
80
80
  besideLocation: (suffix) => `gs://${o.bucket}/${o.key}${suffix}`,
81
81
  adopt: () => { },
@@ -0,0 +1,255 @@
1
+ import type { Capability } from "@intentius/chant/components/capability";
2
+ import type { ChangeSetPart } from "@intentius/chant/change-set";
3
+ import { finishGatedRequest, readGatedRequests, requestGate, spendGatedRequest, type GatedRequest, type GatedRequestRules, type RequestGateInput, type RequestGateResult } from "@intentius/chant/lifecycle/gated-request";
4
+ import { type BinaryExec } from "./state/exec.js";
5
+ /** The ops the gated requests of this module wait at, one per kind, as terragucci named them. */
6
+ export declare const STATE_OPS: {
7
+ readonly unlock: "tf-unlock";
8
+ readonly migrate: "tf-migrate";
9
+ readonly export: "tf-state-export";
10
+ };
11
+ /** The request kinds of #4551's design. */
12
+ export declare const STATE_OP_KINDS: {
13
+ readonly unlock: "unlock";
14
+ readonly migrate: "migrate";
15
+ readonly export: "state-export";
16
+ };
17
+ /** A binary run that exited non-zero, with the tail of its output. */
18
+ export declare class StateOpError extends Error {
19
+ readonly root: string;
20
+ readonly command: string;
21
+ readonly code: number;
22
+ readonly tail: string;
23
+ constructor(root: string, command: string, code: number, tail: string);
24
+ }
25
+ /** A gated operation stopped for a person: its request waits for an approval. The command that ran it exits 3. */
26
+ export declare class StateOpWaitingError extends Error {
27
+ readonly op: string;
28
+ readonly subject: string;
29
+ readonly digest: string;
30
+ readonly command: string;
31
+ readonly exitCode: 3;
32
+ constructor(op: string, subject: string, digest: string, command: string);
33
+ }
34
+ /** Where and how the binary runs for one root. */
35
+ export interface RootRun {
36
+ /** The root's name, as messages and records name it. */
37
+ root: string;
38
+ binary: string;
39
+ /** The root's directory. */
40
+ dir: string;
41
+ env?: NodeJS.ProcessEnv;
42
+ exec?: BinaryExec;
43
+ }
44
+ /** `init -input=false -no-color`, with `-reconfigure` and `-backend-config` pairs when given. */
45
+ export declare function initRoot(r: RootRun & {
46
+ backendConfig?: Record<string, string>;
47
+ reconfigure?: boolean;
48
+ }): Promise<void>;
49
+ /**
50
+ * Release the state lock with this ID: `force-unlock -force -no-color <id>`.
51
+ * Run it under {@link gatedStateOp}; the binary releases whichever lock has
52
+ * the ID, so the approval binds the ID and the lock's location.
53
+ */
54
+ export declare function forceUnlockState(r: RootRun & {
55
+ id: string;
56
+ }): Promise<void>;
57
+ /**
58
+ * Write a state file with `state push`. `lock: false` passes `-lock=false`,
59
+ * for a caller that holds the state's lock itself; `force` passes `-force`,
60
+ * for a push over an empty state of another lineage the caller checked.
61
+ */
62
+ export declare function pushStateFile(r: RootRun & {
63
+ file: string;
64
+ lock?: boolean;
65
+ force?: boolean;
66
+ }): Promise<void>;
67
+ /** A plan read back: its JSON, and the binary's summary line. */
68
+ export interface PlanRead {
69
+ planFile: string;
70
+ json: unknown;
71
+ summary: string;
72
+ }
73
+ /**
74
+ * Plan a root against its state and read the plan: the check a migration
75
+ * makes before and after it writes. `lock: false` passes `-lock=false`, for a
76
+ * caller that holds the lock itself.
77
+ */
78
+ export declare function planStateCheck(r: RootRun & {
79
+ planFile: string;
80
+ lock?: boolean;
81
+ }): Promise<PlanRead>;
82
+ /** A copy's plan: the plan read back, and its change-set part with the member's plan digest. */
83
+ export interface CopyPlanRead extends PlanRead {
84
+ part: ChangeSetPart;
85
+ planDigest: string;
86
+ }
87
+ /**
88
+ * Initialise a root under its copy's backend settings and plan it, a destroy
89
+ * with `destroy`. `backendConfig` is what makes it the copy (a state key with
90
+ * the copy's suffix), so it is required and never empty: without it the plan
91
+ * would be of the root's own state. Pass `init: false` for a root another
92
+ * tool initialised (a Terragrunt unit prepared with the suffix set).
93
+ */
94
+ export declare function planCopy(r: RootRun & {
95
+ backendConfig: Record<string, string>;
96
+ planFile: string;
97
+ destroy?: boolean;
98
+ lockTimeout?: string | false;
99
+ init?: boolean;
100
+ }): Promise<CopyPlanRead>;
101
+ /** Apply a saved plan, and nothing else: `apply -input=false -no-color <plan>`. */
102
+ export declare function applyPlanFile(r: RootRun & {
103
+ planFile: string;
104
+ lockTimeout?: string | false;
105
+ }): Promise<void>;
106
+ /** The gated-request ledger, injectable for tests. Default chant's on `chant/lifecycle`. */
107
+ export interface GatedRequestLedger {
108
+ requestGate: typeof requestGate;
109
+ spendGatedRequest: typeof spendGatedRequest;
110
+ finishGatedRequest: typeof finishGatedRequest;
111
+ readGatedRequests: typeof readGatedRequests;
112
+ }
113
+ /**
114
+ * The time a request was first asked, so asking again binds the same
115
+ * digest: chant's digest covers `at`, and a run that asked anew each time
116
+ * would never meet the approval of the last one. The newest standing,
117
+ * unspent request with the same kind, subject, requester and fields gives
118
+ * its `at`; with none, `now`.
119
+ */
120
+ export declare function requestedAt(op: string, request: Omit<GatedRequest, "at">, options?: {
121
+ now?: string;
122
+ cwd?: string;
123
+ ledger?: Pick<GatedRequestLedger, "readGatedRequests">;
124
+ }): Promise<string>;
125
+ /** The digest `requestGate` puts in `fields.proof` for an attachment. */
126
+ export declare const attachmentDigest: (attachment: string) => string;
127
+ export interface GatedStateOpInput {
128
+ op: string;
129
+ /** The request, less `at`, which {@link requestedAt} fills. */
130
+ request: Omit<GatedRequest, "at"> & {
131
+ at?: string;
132
+ };
133
+ rules: GatedRequestRules;
134
+ description?: string;
135
+ expiry?: string;
136
+ base?: string;
137
+ /** A document the request carries, such as a migration's proof; its digest joins the request. */
138
+ attachment?: string;
139
+ cwd?: string;
140
+ now?: string;
141
+ runId?: string;
142
+ commit?: string;
143
+ ledger?: GatedRequestLedger;
144
+ gates?: RequestGateInput["gates"];
145
+ /**
146
+ * A last check just before the spend, for a fact that can change while the
147
+ * request waited (a run that may hold the lock came back). A string refuses
148
+ * the operation with that reason, and the approval is not spent.
149
+ */
150
+ beforeSpend?: () => Promise<string | undefined>;
151
+ }
152
+ /** How a gated operation ended. */
153
+ export type GatedStateOpResult<T> = Exclude<RequestGateResult, {
154
+ status: "approved";
155
+ }> | {
156
+ status: "held";
157
+ digest: string;
158
+ request: GatedRequest;
159
+ reason: string;
160
+ } | {
161
+ status: "done";
162
+ digest: string;
163
+ request: GatedRequest;
164
+ approvedBy: string;
165
+ output: T;
166
+ recorded: boolean;
167
+ } | {
168
+ status: "failed";
169
+ digest: string;
170
+ request: GatedRequest;
171
+ approvedBy: string;
172
+ error: Error;
173
+ recorded: boolean;
174
+ };
175
+ /**
176
+ * Run `act` once its request is approved: ask (or read) the request, spend
177
+ * the approval, act, and record how it ended. `act` returns its output and
178
+ * the flat facts that go on the finished line. A spend that cannot be pushed
179
+ * throws before `act` runs, so no approval acts twice. A finished line that
180
+ * cannot be written is reported as `recorded: false`; the act already ran.
181
+ */
182
+ export declare function gatedStateOp<T>(input: GatedStateOpInput, act: (approved: {
183
+ digest: string;
184
+ request: GatedRequest;
185
+ approvedBy: string;
186
+ }) => Promise<{
187
+ output: T;
188
+ detail?: Record<string, string | number | boolean>;
189
+ }>): Promise<GatedStateOpResult<T>>;
190
+ /** The digest a request binds, for a caller that prints it before it asks. */
191
+ export declare const stateOpDigest: (op: string, request: GatedRequest) => string;
192
+ /** The step input the gated capabilities share: the root and the request's rules. */
193
+ interface GatedRootInput {
194
+ root: string;
195
+ /** The project's directory, where the ledger is and roots are found. Default the process's. */
196
+ cwd?: string;
197
+ /** The root's directory. Default `root` under the project. */
198
+ dir?: string;
199
+ binary?: string;
200
+ /** Who asks. Default the CI actor, else the user. */
201
+ by?: string;
202
+ /** Which approvals count. Default the ledger's. */
203
+ approval?: GatedRequestRules["mode"];
204
+ }
205
+ /** `terraform-state-unlock`: release one lock, by ID, under a gated request. */
206
+ export interface StateUnlockStepInput extends GatedRootInput {
207
+ id: string;
208
+ /** Where the lock is, as the record names it: the lock file, the lock object, the lease's blob. */
209
+ location: string;
210
+ }
211
+ /** `terraform-state-push`: write state files to their roots under one gated request whose attachment is the proof. */
212
+ export interface StatePushStepInput extends GatedRootInput {
213
+ files: Array<{
214
+ root: string;
215
+ dir?: string;
216
+ file: string;
217
+ lock?: boolean;
218
+ force?: boolean;
219
+ }>;
220
+ /** The proof the approval binds: what the push writes and why it is safe. */
221
+ proof: string;
222
+ }
223
+ /** `terraform-copy`: plan and apply a root's copy under its own backend settings. */
224
+ export interface CopyStepInput {
225
+ root: string;
226
+ cwd?: string;
227
+ dir?: string;
228
+ binary?: string;
229
+ backendConfig: Record<string, string>;
230
+ destroy?: boolean;
231
+ lockTimeout?: string | false;
232
+ }
233
+ export declare const terraformStateUnlockCapability: Capability<StateUnlockStepInput, {
234
+ root: string;
235
+ id: string;
236
+ }>;
237
+ export declare const terraformStatePushCapability: Capability<StatePushStepInput, {
238
+ roots: string[];
239
+ }>;
240
+ export declare const terraformCopyCapability: Capability<CopyStepInput, {
241
+ root: string;
242
+ planDigest: string;
243
+ }>;
244
+ /** The state operations' capabilities, for the plugin's registry. */
245
+ export declare const terraformStateOpCapabilities: readonly [Capability<StateUnlockStepInput, {
246
+ root: string;
247
+ id: string;
248
+ }>, Capability<StatePushStepInput, {
249
+ roots: string[];
250
+ }>, Capability<CopyStepInput, {
251
+ root: string;
252
+ planDigest: string;
253
+ }>];
254
+ export {};
255
+ //# source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