@intentius/chant 0.124.51 → 0.124.54
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/audit/discover.d.ts.map +1 -1
- package/dist/audit/discover.js +3 -1
- package/dist/behaviour.d.ts +1 -1
- package/dist/behaviour.d.ts.map +1 -1
- package/dist/capabilities/templates.d.ts +65 -0
- package/dist/capabilities/templates.d.ts.map +1 -0
- package/dist/capabilities/templates.js +193 -0
- package/dist/capabilities/templates.json +145 -0
- package/dist/change-set-graph.d.ts +35 -3
- package/dist/change-set-graph.d.ts.map +1 -1
- package/dist/change-set-graph.js +60 -9
- package/dist/change-set.d.ts +65 -7
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +23 -12
- package/dist/ci-identity.d.ts +7 -2
- package/dist/ci-identity.d.ts.map +1 -1
- package/dist/ci-identity.js +4 -1
- package/dist/cli/commands/import-index.d.ts +52 -0
- package/dist/cli/commands/import-index.d.ts.map +1 -0
- package/dist/cli/commands/import-index.js +226 -0
- package/dist/cli/commands/lint.d.ts.map +1 -1
- package/dist/cli/commands/lint.js +4 -2
- package/dist/cli/handlers/components.d.ts.map +1 -1
- package/dist/cli/handlers/components.js +11 -2
- package/dist/cli/handlers/fan-out.d.ts.map +1 -1
- package/dist/cli/handlers/fan-out.js +16 -3
- package/dist/cli/handlers/graph.d.ts.map +1 -1
- package/dist/cli/handlers/graph.js +22 -4
- package/dist/cli/handlers/index-cloud.d.ts +14 -0
- package/dist/cli/handlers/index-cloud.d.ts.map +1 -0
- package/dist/cli/handlers/index-cloud.js +22 -0
- package/dist/cli/handlers/index-diff.d.ts +18 -0
- package/dist/cli/handlers/index-diff.d.ts.map +1 -0
- package/dist/cli/handlers/index-diff.js +142 -0
- package/dist/cli/handlers/lifecycle-drift.d.ts +25 -0
- package/dist/cli/handlers/lifecycle-drift.d.ts.map +1 -0
- package/dist/cli/handlers/lifecycle-drift.js +64 -0
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +188 -28
- package/dist/cli/handlers/misc.d.ts +9 -0
- package/dist/cli/handlers/misc.d.ts.map +1 -1
- package/dist/cli/handlers/misc.js +77 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +17 -3
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +89 -15
- package/dist/cli/handlers/query.d.ts.map +1 -1
- package/dist/cli/handlers/query.js +28 -4
- package/dist/cli/handlers/scenario.d.ts.map +1 -1
- package/dist/cli/handlers/scenario.js +8 -7
- package/dist/cli/handlers/search.d.ts +34 -4
- package/dist/cli/handlers/search.d.ts.map +1 -1
- package/dist/cli/handlers/search.js +216 -36
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +55 -1
- package/dist/cli/mcp/lifecycle-tools.d.ts.map +1 -1
- package/dist/cli/mcp/lifecycle-tools.js +3 -2
- package/dist/cli/mcp/resource-handlers.d.ts.map +1 -1
- package/dist/cli/mcp/resource-handlers.js +4 -3
- package/dist/cli/mcp/workspace-tools.js +1 -1
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +55 -2
- package/dist/cli/registry.d.ts +19 -1
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/cloud-lister/aws.d.ts +35 -0
- package/dist/cloud-lister/aws.d.ts.map +1 -0
- package/dist/cloud-lister/aws.js +203 -0
- package/dist/cloud-lister/azure.d.ts +34 -0
- package/dist/cloud-lister/azure.d.ts.map +1 -0
- package/dist/cloud-lister/azure.js +129 -0
- package/dist/cloud-lister/common.d.ts +40 -0
- package/dist/cloud-lister/common.d.ts.map +1 -0
- package/dist/cloud-lister/common.js +83 -0
- package/dist/cloud-lister/credentials.d.ts +50 -0
- package/dist/cloud-lister/credentials.d.ts.map +1 -0
- package/dist/cloud-lister/credentials.js +86 -0
- package/dist/cloud-lister/fakes.d.ts +27 -0
- package/dist/cloud-lister/fakes.d.ts.map +1 -0
- package/dist/cloud-lister/fakes.js +50 -0
- package/dist/cloud-lister/gcp.d.ts +42 -0
- package/dist/cloud-lister/gcp.d.ts.map +1 -0
- package/dist/cloud-lister/gcp.js +143 -0
- package/dist/cloud-lister/guard.d.ts +49 -0
- package/dist/cloud-lister/guard.d.ts.map +1 -0
- package/dist/cloud-lister/guard.js +103 -0
- package/dist/cloud-lister/ids.d.ts +23 -0
- package/dist/cloud-lister/ids.d.ts.map +1 -0
- package/dist/cloud-lister/ids.js +42 -0
- package/dist/cloud-lister/index.d.ts +67 -0
- package/dist/cloud-lister/index.d.ts.map +1 -0
- package/dist/cloud-lister/index.js +102 -0
- package/dist/cloud-lister/kubernetes.d.ts +64 -0
- package/dist/cloud-lister/kubernetes.d.ts.map +1 -0
- package/dist/cloud-lister/kubernetes.js +276 -0
- package/dist/cloud-lister/markers.d.ts +31 -0
- package/dist/cloud-lister/markers.d.ts.map +1 -0
- package/dist/cloud-lister/markers.js +73 -0
- package/dist/cloud-lister/mask.d.ts +31 -0
- package/dist/cloud-lister/mask.d.ts.map +1 -0
- package/dist/cloud-lister/mask.js +74 -0
- package/dist/cloud-lister/sigv4.d.ts +29 -0
- package/dist/cloud-lister/sigv4.d.ts.map +1 -0
- package/dist/cloud-lister/sigv4.js +54 -0
- package/dist/cloud-lister/transport.d.ts +55 -0
- package/dist/cloud-lister/transport.d.ts.map +1 -0
- package/dist/cloud-lister/transport.js +86 -0
- package/dist/cloud-lister/types.d.ts +121 -0
- package/dist/cloud-lister/types.d.ts.map +1 -0
- package/dist/cloud-lister/types.js +24 -0
- package/dist/components/capability-plugin-loader.d.ts.map +1 -1
- package/dist/components/capability-plugin-loader.js +6 -0
- package/dist/components/capability-plugin.d.ts +9 -0
- package/dist/components/capability-plugin.d.ts.map +1 -1
- package/dist/components/capability.d.ts +224 -0
- package/dist/components/capability.d.ts.map +1 -1
- package/dist/components/cli-support.d.ts +21 -0
- package/dist/components/cli-support.d.ts.map +1 -1
- package/dist/components/cli-support.js +58 -14
- package/dist/components/covered-round.d.ts +173 -0
- package/dist/components/covered-round.d.ts.map +1 -0
- package/dist/components/covered-round.js +200 -0
- package/dist/components/declared-reads.d.ts +38 -0
- package/dist/components/declared-reads.d.ts.map +1 -0
- package/dist/components/declared-reads.js +131 -0
- package/dist/components/deploy-units.d.ts.map +1 -1
- package/dist/components/deploy-units.js +4 -0
- package/dist/components/driver.d.ts +42 -1
- package/dist/components/driver.d.ts.map +1 -1
- package/dist/components/driver.js +74 -3
- package/dist/components/fan-out-run.d.ts +23 -1
- package/dist/components/fan-out-run.d.ts.map +1 -1
- package/dist/components/fan-out-run.js +82 -14
- package/dist/components/fan-out-support.d.ts +6 -0
- package/dist/components/fan-out-support.d.ts.map +1 -1
- package/dist/components/fan-out-support.js +4 -1
- package/dist/components/fan-out.d.ts +28 -0
- package/dist/components/fan-out.d.ts.map +1 -1
- package/dist/components/groups.d.ts +229 -0
- package/dist/components/groups.d.ts.map +1 -0
- package/dist/components/groups.js +760 -0
- package/dist/components/index.d.ts +7 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -0
- package/dist/components/plan-shape-conformance.d.ts +48 -0
- package/dist/components/plan-shape-conformance.d.ts.map +1 -0
- package/dist/components/plan-shape-conformance.js +122 -0
- package/dist/components/pr-run.d.ts +62 -7
- package/dist/components/pr-run.d.ts.map +1 -1
- package/dist/components/pr-run.js +354 -53
- package/dist/components/promote-rounds.d.ts +9 -0
- package/dist/components/promote-rounds.d.ts.map +1 -1
- package/dist/components/promote-rounds.js +23 -2
- package/dist/components/promote.d.ts +17 -0
- package/dist/components/promote.d.ts.map +1 -1
- package/dist/components/promote.js +36 -6
- package/dist/components/release-gate.d.ts +23 -1
- package/dist/components/release-gate.d.ts.map +1 -1
- package/dist/components/release-gate.js +97 -33
- package/dist/components/run-groups.d.ts +58 -0
- package/dist/components/run-groups.d.ts.map +1 -0
- package/dist/components/run-groups.js +78 -0
- package/dist/components/starter-plugin.d.ts +1 -0
- package/dist/components/starter-plugin.d.ts.map +1 -1
- package/dist/components/starter-plugin.js +6 -1
- package/dist/components/verbs/index.d.ts +1 -0
- package/dist/components/verbs/index.d.ts.map +1 -1
- package/dist/components/verbs/index.js +1 -0
- package/dist/components/verbs/member-outputs.d.ts +187 -0
- package/dist/components/verbs/member-outputs.d.ts.map +1 -0
- package/dist/components/verbs/member-outputs.js +218 -0
- package/dist/components/wave-plan.d.ts +2 -0
- package/dist/components/wave-plan.d.ts.map +1 -1
- package/dist/components/wave-plan.js +4 -1
- package/dist/config.d.ts +60 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +27 -0
- package/dist/deep-observation.d.ts +1 -13
- package/dist/deep-observation.d.ts.map +1 -1
- package/dist/deep-observation.js +5 -22
- package/dist/drift-record.d.ts +542 -0
- package/dist/drift-record.d.ts.map +1 -0
- package/dist/drift-record.js +886 -0
- package/dist/engine-facts.d.ts +144 -0
- package/dist/engine-facts.d.ts.map +1 -0
- package/dist/engine-facts.js +14 -0
- package/dist/graph-ir.d.ts +153 -2
- package/dist/graph-ir.d.ts.map +1 -1
- package/dist/graph-ir.js +224 -6
- package/dist/graph-refs.d.ts +145 -0
- package/dist/graph-refs.d.ts.map +1 -1
- package/dist/graph-refs.js +305 -0
- package/dist/graph-schema/fixtures/adopt.json +15 -0
- package/dist/graph-schema/fixtures/choudoufu.engine-graph.json +169 -0
- package/dist/graph-schema/fixtures/index.json +68 -0
- package/dist/graph-schema/fixtures/plunge.engine-graph.json +158 -0
- package/dist/graph-schema/fixtures.d.ts +23 -0
- package/dist/graph-schema/fixtures.d.ts.map +1 -0
- package/dist/graph-schema/fixtures.js +246 -0
- package/dist/graph-schema/generate.d.ts +15 -0
- package/dist/graph-schema/generate.d.ts.map +1 -0
- package/dist/graph-schema/generate.js +267 -0
- package/dist/graph-schema/graph.schema.json +1387 -0
- package/dist/health.schema.json +2 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/instance-nodes.d.ts +159 -0
- package/dist/instance-nodes.d.ts.map +1 -0
- package/dist/instance-nodes.js +231 -0
- package/dist/lexicon.d.ts +72 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/adoption-file.d.ts +56 -0
- package/dist/lifecycle/adoption-file.d.ts.map +1 -0
- package/dist/lifecycle/adoption-file.js +123 -0
- package/dist/lifecycle/cloud-index.d.ts +186 -0
- package/dist/lifecycle/cloud-index.d.ts.map +1 -0
- package/dist/lifecycle/cloud-index.js +618 -0
- package/dist/lifecycle/derive-edges.d.ts +59 -0
- package/dist/lifecycle/derive-edges.d.ts.map +1 -0
- package/dist/lifecycle/derive-edges.js +126 -0
- package/dist/lifecycle/git.d.ts +10 -9
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +7 -1
- package/dist/lifecycle/identity-match.d.ts +133 -0
- package/dist/lifecycle/identity-match.d.ts.map +1 -0
- package/dist/lifecycle/identity-match.js +147 -0
- package/dist/lifecycle/index-diff.d.ts +224 -0
- package/dist/lifecycle/index-diff.d.ts.map +1 -0
- package/dist/lifecycle/index-diff.js +327 -0
- package/dist/lifecycle/index-document.d.ts +130 -0
- package/dist/lifecycle/index-document.d.ts.map +1 -0
- package/dist/lifecycle/index-document.js +189 -0
- package/dist/lifecycle/index-drift.d.ts +121 -0
- package/dist/lifecycle/index-drift.d.ts.map +1 -0
- package/dist/lifecycle/index-drift.js +178 -0
- package/dist/lifecycle/index-import.d.ts +168 -0
- package/dist/lifecycle/index-import.d.ts.map +1 -0
- package/dist/lifecycle/index-import.js +515 -0
- package/dist/lifecycle/index-join.d.ts +129 -0
- package/dist/lifecycle/index-join.d.ts.map +1 -0
- package/dist/lifecycle/index-join.js +248 -0
- package/dist/lifecycle/index.d.ts +4 -0
- package/dist/lifecycle/index.d.ts.map +1 -1
- package/dist/lifecycle/index.js +4 -0
- package/dist/lifecycle/observation-baseline.d.ts +61 -21
- package/dist/lifecycle/observation-baseline.d.ts.map +1 -1
- package/dist/lifecycle/observation-baseline.js +144 -19
- package/dist/lifecycle/observe.d.ts.map +1 -1
- package/dist/lifecycle/observe.js +6 -1
- package/dist/lifecycle/query.d.ts +45 -4
- package/dist/lifecycle/query.d.ts.map +1 -1
- package/dist/lifecycle/query.js +89 -7
- package/dist/lifecycle/replay.d.ts +10 -3
- package/dist/lifecycle/replay.d.ts.map +1 -1
- package/dist/lifecycle/replay.js +10 -6
- package/dist/lifecycle/scenario.d.ts +4 -3
- package/dist/lifecycle/scenario.d.ts.map +1 -1
- package/dist/lifecycle/snapshot-store-fake.d.ts +9 -0
- package/dist/lifecycle/snapshot-store-fake.d.ts.map +1 -0
- package/dist/lifecycle/snapshot-store-fake.js +21 -0
- package/dist/lifecycle/snapshot-store-s3.d.ts +102 -0
- package/dist/lifecycle/snapshot-store-s3.d.ts.map +1 -0
- package/dist/lifecycle/snapshot-store-s3.js +254 -0
- package/dist/lifecycle/snapshot-store.d.ts +170 -0
- package/dist/lifecycle/snapshot-store.d.ts.map +1 -0
- package/dist/lifecycle/snapshot-store.js +832 -0
- package/dist/lifecycle/snapshot.d.ts +11 -0
- package/dist/lifecycle/snapshot.d.ts.map +1 -1
- package/dist/lifecycle/snapshot.js +18 -5
- package/dist/lifecycle/type-listing.d.ts +148 -0
- package/dist/lifecycle/type-listing.d.ts.map +1 -0
- package/dist/lifecycle/type-listing.js +166 -0
- package/dist/lint/component-checks.d.ts +15 -1
- package/dist/lint/component-checks.d.ts.map +1 -1
- package/dist/lint/component-checks.js +1 -0
- package/dist/lint/presets/relaxed.json +2 -1
- package/dist/lint/presets/strict.json +2 -1
- package/dist/lint/rules/__fixtures__/comp/comp008/fail/dns.component.d.ts +4 -0
- package/dist/lint/rules/__fixtures__/comp/comp008/fail/dns.component.d.ts.map +1 -0
- package/dist/lint/rules/__fixtures__/comp/comp008/fail/dns.component.js +13 -0
- package/dist/lint/rules/__fixtures__/comp/comp008/pass/dns.component.d.ts +4 -0
- package/dist/lint/rules/__fixtures__/comp/comp008/pass/dns.component.d.ts.map +1 -0
- package/dist/lint/rules/__fixtures__/comp/comp008/pass/dns.component.js +8 -0
- package/dist/lint/rules/comp/comp008-applies-signal-only-root.d.ts +33 -0
- package/dist/lint/rules/comp/comp008-applies-signal-only-root.d.ts.map +1 -0
- package/dist/lint/rules/comp/comp008-applies-signal-only-root.js +123 -0
- package/dist/lint/rules/comp/index.d.ts +2 -1
- package/dist/lint/rules/comp/index.d.ts.map +1 -1
- package/dist/lint/rules/comp/index.js +4 -1
- package/dist/observation.d.ts +19 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +18 -1
- package/dist/op/activities/activity-contracts.d.ts +1 -1
- package/dist/op/activities/activity-contracts.js +1 -1
- package/dist/op/activities/change-set.d.ts +6 -4
- package/dist/op/activities/change-set.d.ts.map +1 -1
- package/dist/op/activities/change-set.js +4 -2
- package/dist/op/activity-failure.d.ts +27 -0
- package/dist/op/activity-failure.d.ts.map +1 -1
- package/dist/op/activity-failure.js +31 -0
- package/dist/op/index.d.ts +2 -1
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +1 -1
- package/dist/op/local-executor.d.ts +5 -1
- package/dist/op/local-executor.d.ts.map +1 -1
- package/dist/op/local-executor.js +22 -8
- package/dist/pr-loop.d.ts +92 -3
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +62 -3
- package/dist/pulumi-urn.d.ts +101 -0
- package/dist/pulumi-urn.d.ts.map +1 -0
- package/dist/pulumi-urn.js +131 -0
- package/dist/release-floors.d.ts +23 -0
- package/dist/release-floors.d.ts.map +1 -0
- package/dist/release-floors.js +22 -0
- package/dist/sensitive-key.d.ts +23 -0
- package/dist/sensitive-key.d.ts.map +1 -0
- package/dist/sensitive-key.js +31 -0
- package/dist/wave-runtime.mjs +234 -234
- package/dist/workspace/adoption-report.d.ts +53 -0
- package/dist/workspace/adoption-report.d.ts.map +1 -0
- package/dist/workspace/adoption-report.js +76 -0
- package/dist/workspace/capabilities-contract.d.ts +7 -0
- package/dist/workspace/capabilities-contract.d.ts.map +1 -1
- package/dist/workspace/capabilities-contract.js +2 -1
- package/dist/workspace/capabilities.schema.json +98 -0
- package/dist/workspace/change-set.schema.json +42 -3
- package/dist/workspace/ci-cloud-identity.d.ts +13 -1
- package/dist/workspace/ci-cloud-identity.d.ts.map +1 -1
- package/dist/workspace/ci-cloud-identity.js +30 -1
- package/dist/workspace/compose-graph.d.ts +10 -1
- package/dist/workspace/compose-graph.d.ts.map +1 -1
- package/dist/workspace/compose-graph.js +6 -1
- package/dist/workspace/conformance/index.d.ts +1 -1
- package/dist/workspace/conformance/index.d.ts.map +1 -1
- package/dist/workspace/conformance/index.js +6 -1
- package/dist/workspace/drift-cli.d.ts +81 -0
- package/dist/workspace/drift-cli.d.ts.map +1 -0
- package/dist/workspace/drift-cli.js +317 -0
- package/dist/workspace/drift.schema.json +672 -0
- package/dist/workspace/graph-cli.d.ts +2 -0
- package/dist/workspace/graph-cli.d.ts.map +1 -1
- package/dist/workspace/graph-cli.js +3 -0
- package/dist/workspace/graph.schema.json +72 -0
- package/dist/workspace/init.d.ts +5 -1
- package/dist/workspace/init.d.ts.map +1 -1
- package/dist/workspace/init.js +55 -9
- package/dist/workspace/ledger.schema.json +1 -1
- package/dist/workspace/nested-graph.d.ts.map +1 -1
- package/dist/workspace/nested-graph.js +2 -0
- package/dist/workspace/pr-report.schema.json +76 -3
- package/dist/workspace/promote-waves.d.ts +112 -0
- package/dist/workspace/promote-waves.d.ts.map +1 -0
- package/dist/workspace/promote-waves.js +290 -0
- package/dist/workspace/promote.d.ts +84 -2
- package/dist/workspace/promote.d.ts.map +1 -1
- package/dist/workspace/promote.js +347 -61
- package/dist/workspace/reason-codes.d.ts +12 -0
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/reason-codes.js +14 -0
- package/dist/workspace/search-contract.d.ts +3 -3
- package/dist/workspace/search-contract.d.ts.map +1 -1
- package/dist/workspace/search-contract.js +2 -0
- package/dist/workspace/search.schema.json +103 -5
- package/package.json +14 -1
- package/src/__fixtures__/drift-record/README.md +58 -0
- package/src/__fixtures__/drift-record/choudoufu-cone.ndjson +4 -0
- package/src/__fixtures__/drift-record/choudoufu-resource.ndjson +3 -0
- package/src/__fixtures__/drift-record/component-status-ledger.json +65 -0
- package/src/__fixtures__/drift-record/component-status.json +91 -0
- package/src/__fixtures__/drift-record/deep-diff.json +259 -0
- package/src/__fixtures__/drift-record/lifecycle-diff-live.json +825 -0
- package/src/__fixtures__/drift-record/live-diff.json +125 -0
- package/src/audit/discover.e2e.test.ts +14 -0
- package/src/audit/discover.ts +3 -1
- package/src/behaviour.ts +1 -1
- package/src/capabilities/templates.json +145 -0
- package/src/capabilities/templates.test.ts +212 -0
- package/src/capabilities/templates.ts +204 -0
- package/src/change-set-bundle.test.ts +83 -0
- package/src/change-set-graph.ts +80 -9
- package/src/change-set.test.ts +24 -0
- package/src/change-set.ts +77 -14
- package/src/ci-identity-targets.test.ts +23 -0
- package/src/ci-identity.ts +10 -4
- package/src/cli/commands/import-index.test.ts +117 -0
- package/src/cli/commands/import-index.ts +265 -0
- package/src/cli/commands/lint.ts +4 -2
- package/src/cli/handlers/components.test.ts +9 -0
- package/src/cli/handlers/components.ts +12 -2
- package/src/cli/handlers/fan-out.ts +17 -3
- package/src/cli/handlers/graph.test.ts +42 -0
- package/src/cli/handlers/graph.ts +26 -4
- package/src/cli/handlers/index-cloud.ts +32 -0
- package/src/cli/handlers/index-diff.test.ts +68 -0
- package/src/cli/handlers/index-diff.ts +146 -0
- package/src/cli/handlers/ledger-root-member.test.ts +161 -0
- package/src/cli/handlers/lifecycle-drift.ts +68 -0
- package/src/cli/handlers/lifecycle.test.ts +33 -11
- package/src/cli/handlers/lifecycle.ts +205 -30
- package/src/cli/handlers/misc.ts +73 -0
- package/src/cli/handlers/pr-waves-blocked.test.ts +37 -2
- package/src/cli/handlers/pr.ts +16 -3
- package/src/cli/handlers/promote.test.ts +64 -0
- package/src/cli/handlers/promote.ts +81 -6
- package/src/cli/handlers/query.ts +27 -4
- package/src/cli/handlers/run-declared-reads-cli.test.ts +187 -0
- package/src/cli/handlers/run-groups-cli.test.ts +229 -0
- package/src/cli/handlers/scenario.test.ts +13 -0
- package/src/cli/handlers/scenario.ts +8 -7
- package/src/cli/handlers/search-index.test.ts +255 -0
- package/src/cli/handlers/search-json.test.ts +1 -1
- package/src/cli/handlers/search-ownership.test.ts +194 -0
- package/src/cli/handlers/search.ts +271 -38
- package/src/cli/main.test.ts +7 -0
- package/src/cli/main.ts +56 -1
- package/src/cli/mcp/lifecycle-tools.ts +3 -2
- package/src/cli/mcp/resource-handlers.ts +4 -3
- package/src/cli/mcp/workspace-tools.ts +1 -1
- package/src/cli/parse-args.ts +40 -2
- package/src/cli/registry.ts +19 -1
- package/src/cloud-lister/aws.test.ts +202 -0
- package/src/cloud-lister/aws.ts +226 -0
- package/src/cloud-lister/azure.test.ts +132 -0
- package/src/cloud-lister/azure.ts +142 -0
- package/src/cloud-lister/common.ts +115 -0
- package/src/cloud-lister/credentials.ts +110 -0
- package/src/cloud-lister/fakes.ts +66 -0
- package/src/cloud-lister/gcp.test.ts +121 -0
- package/src/cloud-lister/gcp.ts +159 -0
- package/src/cloud-lister/guard.test.ts +198 -0
- package/src/cloud-lister/guard.ts +111 -0
- package/src/cloud-lister/ids.ts +54 -0
- package/src/cloud-lister/index.ts +134 -0
- package/src/cloud-lister/kubernetes.test.ts +160 -0
- package/src/cloud-lister/kubernetes.ts +284 -0
- package/src/cloud-lister/markers.ts +74 -0
- package/src/cloud-lister/mask.ts +77 -0
- package/src/cloud-lister/shape.test.ts +81 -0
- package/src/cloud-lister/sigv4.ts +70 -0
- package/src/cloud-lister/transport.ts +118 -0
- package/src/cloud-lister/types.ts +135 -0
- package/src/components/capability-plugin-loader.ts +4 -0
- package/src/components/capability-plugin.ts +10 -0
- package/src/components/capability.ts +238 -0
- package/src/components/cli-support.ts +70 -14
- package/src/components/covered-round.test.ts +166 -0
- package/src/components/covered-round.ts +293 -0
- package/src/components/declared-reads.test.ts +103 -0
- package/src/components/declared-reads.ts +134 -0
- package/src/components/deploy-units.ts +4 -0
- package/src/components/driver.ts +101 -4
- package/src/components/fan-out-run.ts +95 -15
- package/src/components/fan-out-support.ts +10 -1
- package/src/components/fan-out.ts +30 -0
- package/src/components/groups.test.ts +320 -0
- package/src/components/groups.ts +880 -0
- package/src/components/index.ts +59 -0
- package/src/components/plan-shape-conformance.ts +130 -0
- package/src/components/pr-env-run-bundle.test.ts +2 -0
- package/src/components/pr-run.test.ts +728 -4
- package/src/components/pr-run.ts +395 -55
- package/src/components/promote-rounds.ts +25 -2
- package/src/components/promote.ts +55 -5
- package/src/components/registry.test.ts +1 -1
- package/src/components/release-gate.ts +115 -30
- package/src/components/release-groups.test.ts +362 -0
- package/src/components/run-groups.ts +113 -0
- package/src/components/starter-plugin.ts +6 -0
- package/src/components/verbs/index.ts +1 -0
- package/src/components/verbs/member-outputs.test.ts +205 -0
- package/src/components/verbs/member-outputs.ts +308 -0
- package/src/components/wave-plan.ts +5 -2
- package/src/config.ts +44 -0
- package/src/deep-observation.ts +5 -23
- package/src/drift-record.test.ts +596 -0
- package/src/drift-record.ts +1206 -0
- package/src/engine-facts.guard.test.ts +111 -0
- package/src/engine-facts.test.ts +178 -0
- package/src/engine-facts.ts +154 -0
- package/src/gated-waves-bundle.test.ts +2 -0
- package/src/graph-ir-live.test.ts +92 -0
- package/src/graph-ir.ts +317 -7
- package/src/graph-refs.ts +416 -0
- package/src/graph-schema/fixtures/adopt.json +15 -0
- package/src/graph-schema/fixtures/choudoufu.engine-graph.json +169 -0
- package/src/graph-schema/fixtures/index.json +68 -0
- package/src/graph-schema/fixtures/plunge.engine-graph.json +158 -0
- package/src/graph-schema/fixtures.ts +267 -0
- package/src/graph-schema/generate.ts +263 -0
- package/src/graph-schema/graph-schema.test.ts +153 -0
- package/src/graph-schema/graph.schema.json +1387 -0
- package/src/health.schema.json +2 -1
- package/src/identity.ts +2 -0
- package/src/index.ts +2 -0
- package/src/instance-nodes.ts +288 -0
- package/src/lexicon.ts +76 -0
- package/src/lifecycle/__fixtures__/index-diff/20261026T120000Z-aaaaaaaaaaaa.json +149 -0
- package/src/lifecycle/__fixtures__/index-diff/20261026T130000Z-bbbbbbbbbbbb.json +127 -0
- package/src/lifecycle/adoption-file.test.ts +100 -0
- package/src/lifecycle/adoption-file.ts +154 -0
- package/src/lifecycle/cloud-index.test.ts +517 -0
- package/src/lifecycle/cloud-index.ts +736 -0
- package/src/lifecycle/derive-edges.test.ts +193 -0
- package/src/lifecycle/derive-edges.ts +182 -0
- package/src/lifecycle/git.ts +10 -4
- package/src/lifecycle/identity-match.test.ts +308 -0
- package/src/lifecycle/identity-match.ts +257 -0
- package/src/lifecycle/index-diff.test.ts +198 -0
- package/src/lifecycle/index-diff.ts +476 -0
- package/src/lifecycle/index-document.test.ts +64 -0
- package/src/lifecycle/index-document.ts +299 -0
- package/src/lifecycle/index-drift.test.ts +191 -0
- package/src/lifecycle/index-drift.ts +304 -0
- package/src/lifecycle/index-import.test.ts +255 -0
- package/src/lifecycle/index-import.ts +634 -0
- package/src/lifecycle/index-join.test.ts +250 -0
- package/src/lifecycle/index-join.ts +304 -0
- package/src/lifecycle/index-store-load-bearing.test.ts +187 -0
- package/src/lifecycle/index.ts +4 -0
- package/src/lifecycle/member-ledger.test.ts +25 -7
- package/src/lifecycle/observation-baseline.test.ts +72 -1
- package/src/lifecycle/observation-baseline.ts +190 -27
- package/src/lifecycle/observe.ts +6 -1
- package/src/lifecycle/query.test.ts +69 -1
- package/src/lifecycle/query.ts +103 -10
- package/src/lifecycle/replay.test.ts +9 -5
- package/src/lifecycle/replay.ts +9 -5
- package/src/lifecycle/scenario.ts +4 -3
- package/src/lifecycle/snapshot-store-fake.ts +29 -0
- package/src/lifecycle/snapshot-store-s3.ts +316 -0
- package/src/lifecycle/snapshot-store.test.ts +385 -0
- package/src/lifecycle/snapshot-store.ts +981 -0
- package/src/lifecycle/snapshot.test.ts +13 -0
- package/src/lifecycle/snapshot.ts +23 -6
- package/src/lifecycle/type-listing.test.ts +166 -0
- package/src/lifecycle/type-listing.ts +309 -0
- package/src/lint/component-checks.ts +17 -1
- package/src/lint/config.test.ts +3 -0
- package/src/lint/presets/relaxed.json +2 -1
- package/src/lint/presets/strict.json +2 -1
- package/src/lint/rules/__fixtures__/comp/comp008/fail/dns.component.ts +15 -0
- package/src/lint/rules/__fixtures__/comp/comp008/pass/dns.component.ts +10 -0
- package/src/lint/rules/comp/comp.test.ts +2 -1
- package/src/lint/rules/comp/comp008-applies-signal-only-root.ts +121 -0
- package/src/lint/rules/comp/comp008.test.ts +77 -0
- package/src/lint/rules/comp/index.ts +4 -1
- package/src/observation-edges.test.ts +33 -0
- package/src/observation.ts +36 -1
- package/src/op/activities/activity-contracts.ts +1 -1
- package/src/op/activities/change-set.ts +8 -5
- package/src/op/activity-failure.ts +36 -0
- package/src/op/index.ts +2 -1
- package/src/op/local-executor.test.ts +80 -0
- package/src/op/local-executor.ts +27 -9
- package/src/pr-loop-bundle.test.ts +5 -2
- package/src/pr-loop.test.ts +57 -1
- package/src/pr-loop.ts +154 -6
- package/src/pulumi-urn.ts +151 -0
- package/src/release-floors.ts +22 -0
- package/src/sensitive-key.ts +34 -0
- package/src/workspace/adoption-report.test.ts +61 -0
- package/src/workspace/adoption-report.ts +103 -0
- package/src/workspace/capabilities-contract.test.ts +4 -0
- package/src/workspace/capabilities-contract.ts +9 -1
- package/src/workspace/capabilities.schema.json +98 -0
- package/src/workspace/change-set.schema.json +42 -3
- package/src/workspace/ci-cloud-identity.ts +31 -1
- package/src/workspace/compose-graph.test.ts +12 -0
- package/src/workspace/compose-graph.ts +12 -1
- package/src/workspace/conformance/conformance.e2e.test.ts +2 -1
- package/src/workspace/conformance/index.ts +6 -1
- package/src/workspace/drift-cli.test.ts +65 -0
- package/src/workspace/drift-cli.ts +365 -0
- package/src/workspace/drift.schema.json +672 -0
- package/src/workspace/graph-cli.ts +5 -0
- package/src/workspace/graph.schema.json +72 -0
- package/src/workspace/init.test.ts +38 -1
- package/src/workspace/init.ts +50 -8
- package/src/workspace/intent-gaps.test.ts +18 -2
- package/src/workspace/ledger.schema.json +1 -1
- package/src/workspace/nested-graph.ts +1 -0
- package/src/workspace/pr-report.schema.json +76 -3
- package/src/workspace/promote-waves.test.ts +296 -0
- package/src/workspace/promote-waves.ts +340 -0
- package/src/workspace/promote.test.ts +158 -4
- package/src/workspace/promote.ts +398 -57
- package/src/workspace/reason-codes.test.ts +4 -1
- package/src/workspace/reason-codes.ts +14 -0
- package/src/workspace/search-contract.ts +2 -0
- package/src/workspace/search.schema.json +103 -5
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `s3` medium of the index store (#4519): objects in a bucket under a
|
|
3
|
+
* prefix of their own, never a record store's prefix.
|
|
4
|
+
*
|
|
5
|
+
* Transport is `fetch` with a SigV4 header signature, hand-written as the aws
|
|
6
|
+
* lexicon's read client is (lexicons/aws/src/api/sigv4.ts), so core takes no
|
|
7
|
+
* `@aws-sdk/*` dependency. `fetch` is injectable: the conformance test runs
|
|
8
|
+
* against an in-process fake and nothing leaves the process.
|
|
9
|
+
*
|
|
10
|
+
* ## Credentials
|
|
11
|
+
*
|
|
12
|
+
* The rule is the one round 2 of the engine work set for every emulator run:
|
|
13
|
+
* a store pointed at an endpoint never reaches for the default AWS credential
|
|
14
|
+
* chain.
|
|
15
|
+
*
|
|
16
|
+
* - Explicit credentials (`credentials` in chant.config.ts, or
|
|
17
|
+
* `CHANT_SNAPSHOT_S3_ACCESS_KEY_ID` / `_SECRET_ACCESS_KEY` /
|
|
18
|
+
* `_SESSION_TOKEN`) are used as given.
|
|
19
|
+
* - With an `endpoint` and no explicit credentials the store refuses. It does
|
|
20
|
+
* not read `AWS_ACCESS_KEY_ID`, a profile file, or an instance role, so an
|
|
21
|
+
* emulator run can never sign with, or leak, a real account's keys.
|
|
22
|
+
* - With no endpoint (real S3), `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY`
|
|
23
|
+
* / `AWS_SESSION_TOKEN` answer. Profiles and instance roles are not read.
|
|
24
|
+
*
|
|
25
|
+
* ## History
|
|
26
|
+
*
|
|
27
|
+
* A snapshot keeps one key, so its history is the bucket's object versions:
|
|
28
|
+
* turn versioning on. An index version is a new key per read, so it needs no
|
|
29
|
+
* versioning. A write of an index version sends `If-None-Match: *`, and a 412
|
|
30
|
+
* means the version already exists.
|
|
31
|
+
*/
|
|
32
|
+
import { createHash, createHmac } from "node:crypto";
|
|
33
|
+
|
|
34
|
+
/** Explicit credentials. */
|
|
35
|
+
export interface S3StoreCredentials {
|
|
36
|
+
accessKeyId: string;
|
|
37
|
+
secretAccessKey: string;
|
|
38
|
+
sessionToken?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Where an s3 store keeps its objects. */
|
|
42
|
+
export interface S3StoreSettings {
|
|
43
|
+
bucket: string;
|
|
44
|
+
/** Key prefix, without leading or trailing `/`. Default `chant`. */
|
|
45
|
+
prefix?: string;
|
|
46
|
+
/** Signing region. Default `us-east-1`. */
|
|
47
|
+
region?: string;
|
|
48
|
+
/** An S3-compatible endpoint (an emulator, MinIO). With one, credentials must be explicit. */
|
|
49
|
+
endpoint?: string;
|
|
50
|
+
/** Path-style addressing. Default: on with an endpoint, off without. */
|
|
51
|
+
forcePathStyle?: boolean;
|
|
52
|
+
credentials?: S3StoreCredentials;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The `fetch` the medium calls. Tests pass a fake. */
|
|
56
|
+
export type S3Fetch = (url: string, init: { method: string; headers: Record<string, string>; body?: string }) => Promise<{
|
|
57
|
+
status: number;
|
|
58
|
+
headers: { get(name: string): string | null };
|
|
59
|
+
text(): Promise<string>;
|
|
60
|
+
}>;
|
|
61
|
+
|
|
62
|
+
export class S3StoreError extends Error {
|
|
63
|
+
constructor(message: string, readonly status?: number) {
|
|
64
|
+
super(message);
|
|
65
|
+
this.name = "S3StoreError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** One object version, newest first in {@link S3Medium.versions}. */
|
|
70
|
+
export interface S3ObjectVersion {
|
|
71
|
+
key: string;
|
|
72
|
+
versionId: string;
|
|
73
|
+
lastModified: string;
|
|
74
|
+
isLatest: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Resolve the credentials the medium signs with, by the rule in the module
|
|
79
|
+
* header. Exported for the test that pins it.
|
|
80
|
+
*/
|
|
81
|
+
export function resolveS3Credentials(
|
|
82
|
+
settings: S3StoreSettings,
|
|
83
|
+
env: Record<string, string | undefined> = process.env,
|
|
84
|
+
): S3StoreCredentials {
|
|
85
|
+
if (settings.credentials) return settings.credentials;
|
|
86
|
+
const explicitId = env.CHANT_SNAPSHOT_S3_ACCESS_KEY_ID;
|
|
87
|
+
const explicitSecret = env.CHANT_SNAPSHOT_S3_SECRET_ACCESS_KEY;
|
|
88
|
+
if (explicitId && explicitSecret) {
|
|
89
|
+
return {
|
|
90
|
+
accessKeyId: explicitId,
|
|
91
|
+
secretAccessKey: explicitSecret,
|
|
92
|
+
...(env.CHANT_SNAPSHOT_S3_SESSION_TOKEN ? { sessionToken: env.CHANT_SNAPSHOT_S3_SESSION_TOKEN } : {}),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (settings.endpoint) {
|
|
96
|
+
throw new S3StoreError(
|
|
97
|
+
`the s3 store at ${settings.endpoint} needs explicit credentials (snapshots.credentials in chant.config.ts, or CHANT_SNAPSHOT_S3_ACCESS_KEY_ID and CHANT_SNAPSHOT_S3_SECRET_ACCESS_KEY); against an endpoint it never reads the default AWS credential chain`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
const id = env.AWS_ACCESS_KEY_ID;
|
|
101
|
+
const secret = env.AWS_SECRET_ACCESS_KEY;
|
|
102
|
+
if (!id || !secret) {
|
|
103
|
+
throw new S3StoreError(
|
|
104
|
+
"the s3 store has no credentials: set snapshots.credentials, CHANT_SNAPSHOT_S3_ACCESS_KEY_ID and CHANT_SNAPSHOT_S3_SECRET_ACCESS_KEY, or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (profiles and instance roles are not read)",
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
return { accessKeyId: id, secretAccessKey: secret, ...(env.AWS_SESSION_TOKEN ? { sessionToken: env.AWS_SESSION_TOKEN } : {}) };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const EMPTY_SHA256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
|
111
|
+
const sha256Hex = (s: string): string => createHash("sha256").update(s, "utf8").digest("hex");
|
|
112
|
+
const hmac = (key: Buffer | string, data: string): Buffer => createHmac("sha256", key).update(data, "utf8").digest();
|
|
113
|
+
|
|
114
|
+
/** RFC 3986 percent-encoding, as S3 signs it. */
|
|
115
|
+
export function encodeRfc3986(value: string): string {
|
|
116
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* SigV4 headers for one S3 request. S3 signs the path encoded once, which is
|
|
121
|
+
* how {@link S3Medium} builds it, so the URL's pathname is the canonical URI
|
|
122
|
+
* as it stands.
|
|
123
|
+
*/
|
|
124
|
+
export function signS3Request(req: {
|
|
125
|
+
method: string;
|
|
126
|
+
url: string;
|
|
127
|
+
headers: Record<string, string>;
|
|
128
|
+
body: string;
|
|
129
|
+
region: string;
|
|
130
|
+
credentials: S3StoreCredentials;
|
|
131
|
+
now?: Date;
|
|
132
|
+
}): Record<string, string> {
|
|
133
|
+
const url = new URL(req.url);
|
|
134
|
+
const timestamp = (req.now ?? new Date()).toISOString().replace(/[:-]|\.\d{3}/g, "");
|
|
135
|
+
const day = timestamp.slice(0, 8);
|
|
136
|
+
const payloadHash = req.body.length === 0 ? EMPTY_SHA256 : sha256Hex(req.body);
|
|
137
|
+
const signable: Record<string, string> = {
|
|
138
|
+
...Object.fromEntries(Object.entries(req.headers).map(([k, v]) => [k.toLowerCase(), v.trim()])),
|
|
139
|
+
host: url.host,
|
|
140
|
+
"x-amz-date": timestamp,
|
|
141
|
+
"x-amz-content-sha256": payloadHash,
|
|
142
|
+
...(req.credentials.sessionToken ? { "x-amz-security-token": req.credentials.sessionToken } : {}),
|
|
143
|
+
};
|
|
144
|
+
const names = Object.keys(signable).sort();
|
|
145
|
+
const pairs: Array<[string, string]> = [];
|
|
146
|
+
url.searchParams.forEach((v, k) => pairs.push([encodeRfc3986(k), encodeRfc3986(v)]));
|
|
147
|
+
pairs.sort((a, b) => (a[0] === b[0] ? (a[1] < b[1] ? -1 : 1) : a[0] < b[0] ? -1 : 1));
|
|
148
|
+
const canonical = [
|
|
149
|
+
req.method.toUpperCase(),
|
|
150
|
+
url.pathname || "/",
|
|
151
|
+
pairs.map(([k, v]) => `${k}=${v}`).join("&"),
|
|
152
|
+
names.map((n) => `${n}:${signable[n].replace(/\s+/g, " ")}\n`).join(""),
|
|
153
|
+
names.join(";"),
|
|
154
|
+
payloadHash,
|
|
155
|
+
].join("\n");
|
|
156
|
+
const scope = `${day}/${req.region}/s3/aws4_request`;
|
|
157
|
+
const toSign = ["AWS4-HMAC-SHA256", timestamp, scope, sha256Hex(canonical)].join("\n");
|
|
158
|
+
const key = hmac(hmac(hmac(hmac(`AWS4${req.credentials.secretAccessKey}`, day), req.region), "s3"), "aws4_request");
|
|
159
|
+
const signature = hmac(key, toSign).toString("hex");
|
|
160
|
+
const { host: _host, ...emitted } = signable;
|
|
161
|
+
return {
|
|
162
|
+
...emitted,
|
|
163
|
+
authorization: `AWS4-HMAC-SHA256 Credential=${req.credentials.accessKeyId}/${scope}, SignedHeaders=${names.join(";")}, Signature=${signature}`,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const XML_ENTITIES: Record<string, string> = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" };
|
|
168
|
+
const decodeXml = (s: string): string =>
|
|
169
|
+
s.replace(/&(#x[0-9a-fA-F]+|#\d+|amp|lt|gt|quot|apos);/g, (_m, e: string) =>
|
|
170
|
+
e.startsWith("#x") ? String.fromCodePoint(parseInt(e.slice(2), 16)) : e.startsWith("#") ? String.fromCodePoint(parseInt(e.slice(1), 10)) : XML_ENTITIES[e],
|
|
171
|
+
);
|
|
172
|
+
const tagAll = (xml: string, tag: string): string[] =>
|
|
173
|
+
[...xml.matchAll(new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`, "g"))].map((m) => m[1]);
|
|
174
|
+
const tagOne = (xml: string, tag: string): string | undefined => {
|
|
175
|
+
const v = tagAll(xml, tag)[0];
|
|
176
|
+
return v === undefined ? undefined : decodeXml(v);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Get, put and list over one bucket. Keys passed in are relative to the
|
|
181
|
+
* store's prefix.
|
|
182
|
+
*/
|
|
183
|
+
export class S3Medium {
|
|
184
|
+
private readonly prefix: string;
|
|
185
|
+
private readonly region: string;
|
|
186
|
+
private readonly fetchImpl: S3Fetch;
|
|
187
|
+
private credentials?: S3StoreCredentials;
|
|
188
|
+
|
|
189
|
+
constructor(
|
|
190
|
+
readonly settings: S3StoreSettings,
|
|
191
|
+
opts?: { fetch?: S3Fetch; env?: Record<string, string | undefined> },
|
|
192
|
+
) {
|
|
193
|
+
if (!settings.bucket) throw new S3StoreError("the s3 store needs a bucket");
|
|
194
|
+
this.prefix = (settings.prefix ?? "chant").replace(/^\/+|\/+$/g, "");
|
|
195
|
+
this.region = settings.region ?? "us-east-1";
|
|
196
|
+
this.fetchImpl = opts?.fetch ?? ((url, init) => fetch(url, init));
|
|
197
|
+
// Resolved at once, so a missing credential is an error before any request.
|
|
198
|
+
this.credentials = resolveS3Credentials(settings, opts?.env);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** `s3://bucket/prefix`, for messages. */
|
|
202
|
+
get where(): string {
|
|
203
|
+
return `s3://${this.settings.bucket}/${this.prefix}`;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private fullKey(key: string): string {
|
|
207
|
+
return this.prefix === "" ? key : `${this.prefix}/${key}`;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
private stripPrefix(key: string): string {
|
|
211
|
+
return this.prefix === "" ? key : key.slice(this.prefix.length + 1);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private url(key: string | null, query: Record<string, string>): string {
|
|
215
|
+
const pathStyle = this.settings.forcePathStyle ?? this.settings.endpoint !== undefined;
|
|
216
|
+
const base = this.settings.endpoint
|
|
217
|
+
? this.settings.endpoint.replace(/\/+$/, "")
|
|
218
|
+
: pathStyle
|
|
219
|
+
? `https://s3.${this.region}.amazonaws.com`
|
|
220
|
+
: `https://${this.settings.bucket}.s3.${this.region}.amazonaws.com`;
|
|
221
|
+
const encodedKey = key === null ? "" : key.split("/").map(encodeRfc3986).join("/");
|
|
222
|
+
const path = pathStyle ? `/${encodeRfc3986(this.settings.bucket)}${key === null ? "" : `/${encodedKey}`}` : `/${encodedKey}`;
|
|
223
|
+
const qs = Object.entries(query)
|
|
224
|
+
.map(([k, v]) => `${encodeRfc3986(k)}=${encodeRfc3986(v)}`)
|
|
225
|
+
.join("&");
|
|
226
|
+
return `${base}${path}${qs ? `?${qs}` : ""}`;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
private async request(method: string, key: string | null, query: Record<string, string>, body = "", headers: Record<string, string> = {}) {
|
|
230
|
+
const url = this.url(key, query);
|
|
231
|
+
const signed = signS3Request({ method, url, headers, body, region: this.region, credentials: this.credentials! });
|
|
232
|
+
return this.fetchImpl(url, { method, headers: signed, ...(body !== "" || method === "PUT" ? { body } : {}) });
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** The object's content, or null when absent. `versionId` reads an older version. */
|
|
236
|
+
async get(key: string, versionId?: string): Promise<string | null> {
|
|
237
|
+
const res = await this.request("GET", this.fullKey(key), versionId ? { versionId } : {});
|
|
238
|
+
if (res.status === 404) return null;
|
|
239
|
+
if (res.status === 400 && versionId) return null;
|
|
240
|
+
if (res.status !== 200) throw new S3StoreError(`s3 GET ${key} returned ${res.status}: ${(await res.text()).slice(0, 200)}`, res.status);
|
|
241
|
+
return res.text();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Put an object. With `ifAbsent`, an existing key is not overwritten and
|
|
246
|
+
* the result says `exists`. Returns the version id when the bucket keeps
|
|
247
|
+
* versions.
|
|
248
|
+
*/
|
|
249
|
+
async put(key: string, content: string, opts?: { ifAbsent?: boolean }): Promise<{ exists: boolean; versionId?: string }> {
|
|
250
|
+
const headers: Record<string, string> = { "content-type": "application/json" };
|
|
251
|
+
if (opts?.ifAbsent) headers["if-none-match"] = "*";
|
|
252
|
+
const res = await this.request("PUT", this.fullKey(key), {}, content, headers);
|
|
253
|
+
if (res.status === 412 || res.status === 409) return { exists: true };
|
|
254
|
+
if (res.status !== 200) throw new S3StoreError(`s3 PUT ${key} returned ${res.status}: ${(await res.text()).slice(0, 200)}`, res.status);
|
|
255
|
+
const versionId = res.headers.get("x-amz-version-id");
|
|
256
|
+
return { exists: false, ...(versionId && versionId !== "null" ? { versionId } : {}) };
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** The names directly under `dir/`: files, and directories with a trailing `/`. */
|
|
260
|
+
async list(dir: string): Promise<string[]> {
|
|
261
|
+
const prefix = `${this.fullKey(dir)}/`;
|
|
262
|
+
const names: string[] = [];
|
|
263
|
+
let token: string | undefined;
|
|
264
|
+
do {
|
|
265
|
+
const res = await this.request("GET", null, {
|
|
266
|
+
"list-type": "2",
|
|
267
|
+
prefix,
|
|
268
|
+
delimiter: "/",
|
|
269
|
+
...(token ? { "continuation-token": token } : {}),
|
|
270
|
+
});
|
|
271
|
+
if (res.status === 404) return [];
|
|
272
|
+
if (res.status !== 200) throw new S3StoreError(`s3 list ${dir} returned ${res.status}`, res.status);
|
|
273
|
+
const xml = await res.text();
|
|
274
|
+
for (const c of tagAll(xml, "Contents")) {
|
|
275
|
+
const k = tagOne(c, "Key");
|
|
276
|
+
if (k !== undefined && k.length > prefix.length) names.push(k.slice(prefix.length));
|
|
277
|
+
}
|
|
278
|
+
for (const p of tagAll(xml, "CommonPrefixes")) {
|
|
279
|
+
const k = tagOne(p, "Prefix");
|
|
280
|
+
if (k !== undefined && k.length > prefix.length) names.push(k.slice(prefix.length));
|
|
281
|
+
}
|
|
282
|
+
token = tagOne(xml, "IsTruncated") === "true" ? tagOne(xml, "NextContinuationToken") : undefined;
|
|
283
|
+
} while (token);
|
|
284
|
+
return [...new Set(names)].sort();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** Every version of every key under `dir/` (recursively), newest first. */
|
|
288
|
+
async versions(dir: string): Promise<S3ObjectVersion[]> {
|
|
289
|
+
const prefix = `${this.fullKey(dir)}/`;
|
|
290
|
+
const out: S3ObjectVersion[] = [];
|
|
291
|
+
let keyMarker: string | undefined;
|
|
292
|
+
let versionMarker: string | undefined;
|
|
293
|
+
do {
|
|
294
|
+
const res = await this.request("GET", null, {
|
|
295
|
+
versions: "",
|
|
296
|
+
prefix,
|
|
297
|
+
...(keyMarker ? { "key-marker": keyMarker } : {}),
|
|
298
|
+
...(versionMarker ? { "version-id-marker": versionMarker } : {}),
|
|
299
|
+
});
|
|
300
|
+
if (res.status === 404) return [];
|
|
301
|
+
if (res.status !== 200) throw new S3StoreError(`s3 list versions ${dir} returned ${res.status}`, res.status);
|
|
302
|
+
const xml = await res.text();
|
|
303
|
+
for (const v of tagAll(xml, "Version")) {
|
|
304
|
+
const key = tagOne(v, "Key");
|
|
305
|
+
const versionId = tagOne(v, "VersionId");
|
|
306
|
+
const lastModified = tagOne(v, "LastModified");
|
|
307
|
+
if (key === undefined || versionId === undefined || lastModified === undefined) continue;
|
|
308
|
+
out.push({ key: this.stripPrefix(key), versionId, lastModified, isLatest: tagOne(v, "IsLatest") === "true" });
|
|
309
|
+
}
|
|
310
|
+
const truncated = tagOne(xml, "IsTruncated") === "true";
|
|
311
|
+
keyMarker = truncated ? tagOne(xml, "NextKeyMarker") : undefined;
|
|
312
|
+
versionMarker = truncated ? tagOne(xml, "NextVersionIdMarker") : undefined;
|
|
313
|
+
} while (keyMarker);
|
|
314
|
+
return out.sort((a, b) => (a.lastModified < b.lastModified ? 1 : a.lastModified > b.lastModified ? -1 : 0));
|
|
315
|
+
}
|
|
316
|
+
}
|