@cnc-tools/storm 0.9.1 → 0.10.0
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/bin/storm.js +11 -2
- package/dist/application.d.ts +5 -5
- package/dist/application.js +11 -9
- package/dist/bin/storm.js +24 -20
- package/dist/build-info.js +1 -1
- package/dist/chunks/chunk-AGWW3HDT.js +2559 -0
- package/dist/chunks/{chunk-RRQ2ZGSE.js → chunk-AKKNF3WZ.js} +847 -336
- package/dist/chunks/chunk-H2VCSNVU.js +351 -0
- package/dist/chunks/chunk-J6ZNYUDV.js +21 -0
- package/dist/chunks/{chunk-WV6WQFC6.js → chunk-JQ2HK4RN.js} +15 -26
- package/dist/chunks/chunk-OVXD7GES.js +841 -0
- package/dist/chunks/chunk-VJQLMGOH.js +4716 -0
- package/dist/chunks/chunk-WF4KJ7YG.js +431 -0
- package/dist/chunks/chunk-XHJGHJBW.js +1509 -0
- package/dist/chunks/chunk-YF3ICDBY.js +10 -0
- package/dist/chunks/chunk-ZJ2USLAT.js +4420 -0
- package/dist/chunks/{live-app-X3PW2W42.js → live-app-RIJM3QFD.js} +30 -22
- package/dist/command-tree.d.ts +3 -0
- package/dist/command-tree.js +3 -0
- package/dist/commands/dashboard.d.ts +1 -1
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/exec/cleanup.d.ts +27 -43
- package/dist/commands/exec/cleanup.js +20 -54
- package/dist/commands/exec/command.d.ts +72 -544
- package/dist/commands/exec/command.js +58 -25
- package/dist/commands/exec/job-summary.d.ts +2 -2
- package/dist/commands/exec/job-summary.js +3 -3
- package/dist/commands/exec/live-view.d.ts +9 -9
- package/dist/commands/exec/live-view.js +48 -41
- package/dist/commands/exec/metadata.d.ts +0 -65
- package/dist/commands/exec/metadata.js +2 -61
- package/dist/commands/exec/mint-failed.d.ts +1 -1
- package/dist/commands/exec/mint-failed.js +8 -8
- package/dist/commands/exec/outcomes.d.ts +63 -468
- package/dist/commands/exec/outcomes.js +42 -69
- package/dist/commands/exec/plan-run.d.ts +150 -0
- package/dist/commands/exec/plan-run.js +121 -0
- package/dist/commands/exec/progress.d.ts +25 -15
- package/dist/commands/exec/progress.js +61 -40
- package/dist/commands/exec/redaction.d.ts +3 -3
- package/dist/commands/exec/redaction.js +4 -4
- package/dist/commands/exec/resource-flags.d.ts +50 -0
- package/dist/commands/exec/resource-flags.js +125 -0
- package/dist/commands/exec/resource-refusals.d.ts +64 -0
- package/dist/commands/exec/resource-refusals.js +58 -0
- package/dist/commands/exec/run-collector.d.ts +15 -10
- package/dist/commands/exec/run-collector.js +5 -5
- package/dist/commands/exec/run-command.d.ts +80 -165
- package/dist/commands/exec/run-command.js +264 -275
- package/dist/commands/exec/run-metadata.d.ts +20 -43
- package/dist/commands/exec/run-metadata.js +18 -37
- package/dist/commands/exec/run-record.d.ts +67 -58
- package/dist/commands/exec/run-record.js +15 -32
- package/dist/commands/exec/test-plan.d.ts +45 -0
- package/dist/commands/exec/test-plan.js +59 -0
- package/dist/commands/exec/tests-summary.d.ts +5 -5
- package/dist/commands/exec/tests-summary.js +2 -2
- package/dist/commands/exec/text.d.ts +8 -2
- package/dist/commands/exec/text.js +8 -0
- package/dist/commands/exec/timeline-facts.d.ts +57 -0
- package/dist/commands/exec/timeline-facts.js +92 -0
- package/dist/commands/exec/view.d.ts +5 -7
- package/dist/commands/exec/view.js +21 -13
- package/dist/commands/exec/waterfall.d.ts +2 -9
- package/dist/commands/exec/waterfall.js +9 -30
- package/dist/commands/exec/worker-chart.d.ts +1 -1
- package/dist/commands/ext/metadata.d.ts +4 -0
- package/dist/commands/ext/metadata.js +8 -0
- package/dist/commands/runs/facts.d.ts +9 -5
- package/dist/commands/runs/facts.js +26 -14
- package/dist/commands/runs/list/command.d.ts +15 -8
- package/dist/commands/runs/list/command.js +38 -32
- package/dist/commands/runs/list/metadata.d.ts +16 -14
- package/dist/commands/runs/list/metadata.js +17 -15
- package/dist/commands/runs/list/outcomes.d.ts +6 -2
- package/dist/commands/runs/logs/command.d.ts +3 -4
- package/dist/commands/runs/logs/command.js +44 -41
- package/dist/commands/runs/logs/metadata.d.ts +17 -15
- package/dist/commands/runs/logs/metadata.js +20 -18
- package/dist/commands/runs/past-run.d.ts +3 -9
- package/dist/commands/runs/past-run.js +2 -17
- package/dist/commands/runs/show/command.d.ts +57 -42
- package/dist/commands/runs/show/command.js +87 -79
- package/dist/commands/runs/show/metadata.d.ts +20 -18
- package/dist/commands/runs/show/metadata.js +20 -18
- package/dist/commands/runs/show/outcomes.d.ts +27 -19
- package/dist/commands/runs/show/outcomes.js +8 -6
- package/dist/commands/vitest/command.d.ts +94 -559
- package/dist/commands/vitest/command.js +71 -94
- package/dist/commands/vitest/metadata.d.ts +0 -65
- package/dist/commands/vitest/metadata.js +2 -41
- package/dist/commands/vitest/outcomes.d.ts +44 -274
- package/dist/commands/vitest/outcomes.js +7 -14
- package/dist/config/credential-resolver.d.ts +131 -0
- package/dist/config/credential-resolver.js +69 -0
- package/dist/{credential/settle.d.ts → config/credential-settle.d.ts} +1 -2
- package/dist/config/errors.d.ts +1 -1
- package/dist/config/errors.js +5 -5
- package/dist/config/index.d.ts +7 -6
- package/dist/config/index.js +13 -9
- package/dist/config/load.d.ts +16 -13
- package/dist/config/load.js +55 -40
- package/dist/config/recipe-run.d.ts +26 -0
- package/dist/config/recipe-run.js +27 -0
- package/dist/config/resolve.d.ts +103 -15
- package/dist/config/resolve.js +137 -47
- package/dist/config/resolver.d.ts +40 -0
- package/dist/config/resolver.js +31 -0
- package/dist/config/schema.d.ts +13 -17
- package/dist/config/schema.js +14 -35
- package/dist/config/settings-file.d.ts +28 -16
- package/dist/config/settings-file.js +39 -24
- package/dist/config/typed-options.d.ts +21 -0
- package/dist/config/typed-options.js +28 -0
- package/dist/config-file/define.d.ts +33 -31
- package/dist/config-file/define.js +14 -4
- package/dist/config-file/toolchain.d.ts +1 -1
- package/dist/context.d.ts +37 -24
- package/dist/context.js +16 -8
- package/dist/core/before-run.d.ts +37 -0
- package/dist/core/before-run.js +44 -0
- package/dist/core/events.d.ts +55 -46
- package/dist/core/gateways.d.ts +17 -18
- package/dist/core/index.d.ts +12 -12
- package/dist/core/index.js +12 -8
- package/dist/core/launcher-supplies.d.ts +11 -0
- package/dist/core/launcher-supplies.js +28 -0
- package/dist/core/mint.js +2 -2
- package/dist/core/payload.d.ts +13 -14
- package/dist/core/payload.js +9 -8
- package/dist/core/presentations.d.ts +37 -37
- package/dist/core/presentations.js +49 -56
- package/dist/core/reports.d.ts +5 -0
- package/dist/core/reports.js +13 -0
- package/dist/core/resource-registry.d.ts +54 -0
- package/dist/core/resource-registry.js +57 -0
- package/dist/core/resource-reports.d.ts +36 -0
- package/dist/core/resource-reports.js +38 -0
- package/dist/core/resource.d.ts +135 -243
- package/dist/core/resource.js +7 -5
- package/dist/core/resources-of.d.ts +16 -0
- package/dist/core/resources-of.js +8 -0
- package/dist/core/resources.d.ts +96 -84
- package/dist/core/resources.js +168 -165
- package/dist/core/run-directory.d.ts +10 -11
- package/dist/core/run-directory.js +9 -9
- package/dist/core/run-state.d.ts +29 -41
- package/dist/core/run-state.js +56 -60
- package/dist/core/run.d.ts +77 -66
- package/dist/core/run.js +83 -74
- package/dist/core/state-directory.js +4 -3
- package/dist/core/timeline.d.ts +42 -24
- package/dist/core/timeline.js +45 -27
- package/dist/core/timing.d.ts +3 -3
- package/dist/core/timing.js +1 -1
- package/dist/credential/gateways.d.ts +1 -80
- package/dist/credential/index.d.ts +3 -5
- package/dist/credential/index.js +7 -5
- package/dist/credential/live/github-actions-token-response.js +1 -1
- package/dist/credential/live/vercel-cli-gateway.d.ts +2 -1
- package/dist/credential/live/vercel-cli-gateway.js +1 -1
- package/dist/credential/live/vercel-output.d.ts +1 -1
- package/dist/credential/source.d.ts +16 -59
- package/dist/credential/source.js +21 -7
- package/dist/credential/target.d.ts +1 -1
- package/dist/extension-commands.d.ts +14 -0
- package/dist/extension-commands.js +20 -0
- package/dist/extensions/github/definition.d.ts +26 -0
- package/dist/extensions/github/definition.js +29 -0
- package/dist/extensions/github/extension.d.ts +18 -0
- package/dist/extensions/github/extension.js +6 -0
- package/dist/{resources → extensions}/github/fixture-repo.d.ts +11 -8
- package/dist/{resources → extensions}/github/fixture-repo.js +8 -4
- package/dist/extensions/github/index.d.ts +13 -0
- package/dist/extensions/github/index.js +17 -0
- package/dist/extensions/github/lifecycle.d.ts +30 -0
- package/dist/extensions/github/lifecycle.js +69 -0
- package/dist/extensions/github/live/world.d.ts +6 -0
- package/dist/extensions/github/live/world.js +16 -0
- package/dist/extensions/github/options.d.ts +36 -0
- package/dist/extensions/github/options.js +36 -0
- package/dist/extensions/github/refusals.d.ts +32 -0
- package/dist/extensions/github/refusals.js +43 -0
- package/dist/extensions/github/release.d.ts +17 -0
- package/dist/extensions/github/release.js +34 -0
- package/dist/extensions/github/resource.d.ts +36 -0
- package/dist/extensions/github/resource.js +21 -0
- package/dist/extensions/github/run/payload.d.ts +27 -0
- package/dist/extensions/github/run/payload.js +42 -0
- package/dist/extensions/github/world.d.ts +15 -0
- package/dist/extensions/github/world.js +3 -0
- package/dist/extensions/testserver/canceled.d.ts +7 -0
- package/dist/extensions/testserver/canceled.js +27 -0
- package/dist/extensions/testserver/command-tree.d.ts +6 -0
- package/dist/extensions/testserver/command-tree.js +21 -0
- package/dist/extensions/testserver/commands/app.d.ts +22 -0
- package/dist/extensions/testserver/commands/app.js +5 -0
- package/dist/{resources/testserver/commands → extensions/testserver/commands/pool}/create/command.d.ts +277 -237
- package/dist/{resources/testserver/commands → extensions/testserver/commands/pool}/create/command.js +105 -140
- package/dist/extensions/testserver/commands/pool/create/metadata.d.ts +33 -0
- package/dist/extensions/testserver/commands/pool/create/metadata.js +55 -0
- package/dist/{resources/testserver/commands → extensions/testserver/commands/pool}/create/outcomes.d.ts +132 -112
- package/dist/{resources/testserver/commands → extensions/testserver/commands/pool}/create/outcomes.js +6 -24
- package/dist/{resources/testserver/commands → extensions/testserver/commands/pool}/list/command.d.ts +3 -4
- package/dist/{resources/testserver/commands → extensions/testserver/commands/pool}/list/command.js +30 -28
- package/dist/extensions/testserver/commands/pool/list/metadata.d.ts +11 -0
- package/dist/{resources/testserver/commands → extensions/testserver/commands/pool}/list/metadata.js +7 -5
- package/dist/{resources/testserver/commands → extensions/testserver/commands/pool}/list/outcomes.js +1 -1
- package/dist/extensions/testserver/commands/pool/metadata.d.ts +3 -0
- package/dist/extensions/testserver/commands/pool/metadata.js +7 -0
- package/dist/extensions/testserver/commands/tree.d.ts +2 -0
- package/dist/extensions/testserver/commands/tree.js +6 -0
- package/dist/{resources → extensions}/testserver/credential-facts.d.ts +6 -40
- package/dist/{resources → extensions}/testserver/credential-facts.js +13 -35
- package/dist/extensions/testserver/definition.d.ts +57 -0
- package/dist/extensions/testserver/definition.js +71 -0
- package/dist/{resources → extensions}/testserver/events.d.ts +5 -4
- package/dist/extensions/testserver/events.js +4 -0
- package/dist/extensions/testserver/extension.d.ts +46 -0
- package/dist/extensions/testserver/extension.js +68 -0
- package/dist/extensions/testserver/index.d.ts +20 -0
- package/dist/extensions/testserver/index.js +31 -0
- package/dist/extensions/testserver/lifecycle.d.ts +24 -0
- package/dist/extensions/testserver/lifecycle.js +116 -0
- package/dist/{core → extensions/testserver}/limit.js +1 -0
- package/dist/extensions/testserver/live/world.d.ts +8 -0
- package/dist/extensions/testserver/live/world.js +38 -0
- package/dist/{resources/testserver/sandbox → extensions/testserver/options}/channels.d.ts +1 -1
- package/dist/extensions/testserver/options/index.d.ts +5 -0
- package/dist/extensions/testserver/options/index.js +11 -0
- package/dist/extensions/testserver/options/rules.d.ts +69 -0
- package/dist/extensions/testserver/options/rules.js +92 -0
- package/dist/extensions/testserver/options/sandboxes.d.ts +29 -0
- package/dist/extensions/testserver/options/sandboxes.js +33 -0
- package/dist/extensions/testserver/options/ttl.d.ts +23 -0
- package/dist/extensions/testserver/options/ttl.js +42 -0
- package/dist/{resources → extensions}/testserver/pool/channels.d.ts +3 -3
- package/dist/{resources → extensions}/testserver/pool/channels.js +2 -2
- package/dist/{resources → extensions}/testserver/pool/create.d.ts +1 -2
- package/dist/{resources → extensions}/testserver/pool/create.js +2 -1
- package/dist/{resources → extensions}/testserver/pool/index.d.ts +0 -1
- package/dist/{resources → extensions}/testserver/pool/index.js +2 -3
- package/dist/{resources → extensions}/testserver/pool/inspect.d.ts +1 -1
- package/dist/{resources → extensions}/testserver/pool/lease.d.ts +1 -1
- package/dist/extensions/testserver/pool/live/pool-store-gateway.d.ts +12 -0
- package/dist/{resources → extensions}/testserver/pool/live/pool-store-gateway.js +4 -4
- package/dist/{resources → extensions}/testserver/pool/pull-request.d.ts +8 -5
- package/dist/{resources → extensions}/testserver/pool/pull-request.js +2 -2
- package/dist/extensions/testserver/pr-build-facts.d.ts +156 -0
- package/dist/extensions/testserver/pr-build-facts.js +309 -0
- package/dist/extensions/testserver/presentation.d.ts +11 -0
- package/dist/{resources → extensions}/testserver/presentation.js +35 -56
- package/dist/{resources/testserver/lane.d.ts → extensions/testserver/progress.d.ts} +10 -6
- package/dist/{resources/testserver/lane.js → extensions/testserver/progress.js} +21 -16
- package/dist/extensions/testserver/provision.d.ts +160 -0
- package/dist/{resources/testserver/provider.js → extensions/testserver/provision.js} +80 -108
- package/dist/{resources → extensions}/testserver/pull-request/gateways.d.ts +1 -1
- package/dist/extensions/testserver/pull-request/gateways.js +5 -0
- package/dist/{resources → extensions}/testserver/pull-request/index.js +2 -2
- package/dist/{resources → extensions}/testserver/pull-request/live/github-token-gateway.d.ts +4 -4
- package/dist/{resources → extensions}/testserver/pull-request/live/github-token-gateway.js +4 -4
- package/dist/extensions/testserver/refusals.d.ts +72 -0
- package/dist/extensions/testserver/refusals.js +117 -0
- package/dist/extensions/testserver/release.d.ts +14 -0
- package/dist/extensions/testserver/release.js +26 -0
- package/dist/extensions/testserver/resource.d.ts +57 -0
- package/dist/extensions/testserver/resource.js +19 -0
- package/dist/extensions/testserver/result.d.ts +55 -0
- package/dist/extensions/testserver/result.js +98 -0
- package/dist/extensions/testserver/run/connection.d.ts +21 -0
- package/dist/extensions/testserver/run/connection.js +39 -0
- package/dist/extensions/testserver/run-sandbox.d.ts +16 -0
- package/dist/extensions/testserver/run-sandbox.js +11 -0
- package/dist/{resources → extensions}/testserver/sandbox/create.d.ts +1 -11
- package/dist/{resources → extensions}/testserver/sandbox/create.js +0 -15
- package/dist/{resources → extensions}/testserver/sandbox/gateways.d.ts +1 -1
- package/dist/{resources → extensions}/testserver/sandbox/index.d.ts +1 -3
- package/dist/extensions/testserver/sandbox/index.js +6 -0
- package/dist/extensions/testserver/testserver-sdk.d.ts +1 -0
- package/dist/extensions/testserver/testserver-sdk.js +4 -0
- package/dist/{vercel-cli → extensions/testserver/vercel-cli}/arguments.js +1 -1
- package/dist/{vercel-cli → extensions/testserver/vercel-cli}/context.js +1 -1
- package/dist/{vercel-cli → extensions/testserver/vercel-cli}/driver.d.ts +1 -1
- package/dist/{vercel-cli → extensions/testserver/vercel-cli}/gateways.js +1 -1
- package/dist/{vercel-cli → extensions/testserver/vercel-cli}/index.js +4 -4
- package/dist/{vercel-cli → extensions/testserver/vercel-cli}/invocation.d.ts +1 -1
- package/dist/{vercel-cli → extensions/testserver/vercel-cli}/invocation.js +1 -1
- package/dist/{vercel-cli → extensions/testserver/vercel-cli}/redaction.js +1 -1
- package/dist/{vercel-cli → extensions/testserver/vercel-cli}/report.d.ts +1 -1
- package/dist/{vercel-cli → extensions/testserver/vercel-cli}/report.js +1 -1
- package/dist/{vercel-cli → extensions/testserver/vercel-cli}/verbose.js +1 -1
- package/dist/extensions/testserver/vitest/config.d.ts +28 -0
- package/dist/extensions/testserver/vitest/config.js +39 -0
- package/dist/{vitest → extensions/testserver/vitest}/container-scope.d.ts +25 -14
- package/dist/{vitest → extensions/testserver/vitest}/container-scope.js +55 -17
- package/dist/extensions/testserver/vitest/container-start.d.ts +19 -0
- package/dist/extensions/testserver/vitest/container-start.js +31 -0
- package/dist/{vitest → extensions/testserver/vitest}/diagnostics.d.ts +66 -29
- package/dist/{vitest → extensions/testserver/vitest}/diagnostics.js +146 -50
- package/dist/{vitest → extensions/testserver/vitest}/fixtures.d.ts +5 -5
- package/dist/{vitest → extensions/testserver/vitest}/fixtures.js +33 -21
- package/dist/extensions/testserver/vitest/index.d.ts +3 -0
- package/dist/extensions/testserver/vitest/index.js +10 -0
- package/dist/extensions/testserver/vitest/sandbox.d.ts +25 -0
- package/dist/extensions/testserver/vitest/sandbox.js +43 -0
- package/dist/{vitest → extensions/testserver/vitest}/types.d.ts +1 -1
- package/dist/extensions/testserver/world.d.ts +25 -0
- package/dist/extensions/testserver/world.js +4 -0
- package/dist/extensions.d.ts +153 -0
- package/dist/extensions.js +53 -0
- package/dist/help-logo.js +5 -5
- package/dist/launch.js +46 -0
- package/dist/launcher-resolvers/index.d.ts +1 -0
- package/dist/launcher-resolvers/index.js +7 -0
- package/dist/live-app.js +11 -7
- package/dist/presentation.js +2 -2
- package/dist/runner/base.js +1 -1
- package/dist/runner/context.js +1 -1
- package/dist/runner/events.js +1 -1
- package/dist/runner/gateways.d.ts +11 -11
- package/dist/runner/gateways.js +1 -1
- package/dist/runner/index.d.ts +4 -4
- package/dist/runner/index.js +1 -1
- package/dist/runner/live/sandbox-gateway.js +4 -4
- package/dist/runner/live/terminal.d.ts +1 -1
- package/dist/runner/live/terminal.js +1 -1
- package/dist/runner/prepare.d.ts +13 -12
- package/dist/runner/prepare.js +3 -3
- package/dist/runner/ready.js +2 -2
- package/dist/runner/recipe.d.ts +24 -20
- package/dist/runner/recipe.js +19 -17
- package/dist/runner/{remote-command.d.ts → sandboxed-command.d.ts} +18 -19
- package/dist/runner/{remote-command.js → sandboxed-command.js} +21 -22
- package/dist/runner/scope.d.ts +3 -3
- package/dist/runner/secrets.js +1 -1
- package/dist/runner/snapshot-key.d.ts +1 -1
- package/dist/runner/snapshot-key.js +4 -4
- package/dist/runner/snapshot-save.js +3 -3
- package/dist/sdk/extension/commands.d.ts +71 -0
- package/dist/sdk/extension/commands.js +31 -0
- package/dist/{credential/diagnosis.d.ts → sdk/extension/credential-diagnosis.d.ts} +1 -7
- package/dist/{credential/diagnosis.js → sdk/extension/credential-diagnosis.js} +2 -11
- package/dist/sdk/extension/credential-source.d.ts +132 -0
- package/dist/sdk/extension/credential-source.js +5 -0
- package/dist/{credential → sdk/extension}/credential.d.ts +8 -7
- package/dist/{credential → sdk/extension}/credential.js +9 -6
- package/dist/sdk/extension/index.d.ts +15 -0
- package/dist/sdk/extension/index.js +39 -0
- package/dist/sdk/extension/launcher-supplies.d.ts +24 -0
- package/dist/sdk/extension/launcher-supplies.js +3 -0
- package/dist/sdk/extension/lifecycle.d.ts +211 -0
- package/dist/sdk/extension/lifecycle.js +9 -0
- package/dist/sdk/extension/presentation.d.ts +31 -0
- package/dist/sdk/extension/presentation.js +7 -0
- package/dist/sdk/extension/progress.d.ts +75 -0
- package/dist/sdk/extension/progress.js +8 -0
- package/dist/sdk/extension/reports.d.ts +15 -0
- package/dist/sdk/extension/reports.js +5 -0
- package/dist/sdk/extension/resource-definition.d.ts +204 -0
- package/dist/sdk/extension/resource-definition.js +24 -0
- package/dist/sdk/extension/resource-factory.d.ts +10 -0
- package/dist/sdk/extension/resource-factory.js +15 -0
- package/dist/sdk/extension/resource.d.ts +60 -0
- package/dist/sdk/extension/resource.js +42 -0
- package/dist/sdk/extension/rules.d.ts +16 -0
- package/dist/sdk/extension/rules.js +30 -0
- package/dist/sdk/extension/span.d.ts +8 -0
- package/dist/sdk/extension/span.js +4 -0
- package/dist/sdk/extension/time.d.ts +11 -0
- package/dist/sdk/extension/time.js +4 -0
- package/dist/sdk/extension/token-request-facts.d.ts +39 -0
- package/dist/sdk/extension/token-request-facts.js +35 -0
- package/dist/sdk/index.d.ts +4 -7
- package/dist/sdk/index.js +7 -15
- package/dist/sdk/run/contract.d.ts +32 -0
- package/dist/sdk/run/contract.js +12 -0
- package/dist/sdk/run/launcher.d.ts +5 -0
- package/dist/sdk/run/launcher.js +6 -0
- package/dist/sdk/run/payload.d.ts +58 -0
- package/dist/sdk/run/payload.js +73 -0
- package/dist/sdk/run/present.d.ts +11 -0
- package/dist/sdk/run/present.js +4 -0
- package/dist/sdk/run/redact.d.ts +5 -0
- package/dist/sdk/run/redact.js +12 -0
- package/dist/time/duration.js +2 -2
- package/dist/time/index.js +2 -1
- package/dist/time/time.d.ts +2 -11
- package/dist/time/time.js +2 -2
- package/dist/{sdk → vendor/testserver-sdk}/container/api-request.d.ts +14 -2
- package/dist/vendor/testserver-sdk/container/api-request.js +68 -0
- package/dist/{sdk → vendor/testserver-sdk}/container/container.d.ts +74 -24
- package/dist/{sdk → vendor/testserver-sdk}/container/container.js +180 -90
- package/dist/vendor/testserver-sdk/container/external.d.ts +111 -0
- package/dist/vendor/testserver-sdk/container/external.js +76 -0
- package/dist/vendor/testserver-sdk/container/gateways.d.ts +156 -0
- package/dist/{sdk → vendor/testserver-sdk}/container/index.d.ts +2 -1
- package/dist/{sdk → vendor/testserver-sdk}/container/index.js +2 -1
- package/dist/vendor/testserver-sdk/container/live/container-gateway.d.ts +22 -0
- package/dist/vendor/testserver-sdk/container/live/container-gateway.js +165 -0
- package/dist/vendor/testserver-sdk/container/recorder.d.ts +69 -0
- package/dist/vendor/testserver-sdk/container/recorder.js +121 -0
- package/dist/{sdk → vendor/testserver-sdk}/factories/build.d.ts +33 -12
- package/dist/{sdk → vendor/testserver-sdk}/factories/build.js +36 -14
- package/dist/vendor/testserver-sdk/factories/definition.d.ts +39 -0
- package/dist/{sdk → vendor/testserver-sdk}/factories/definition.js +1 -1
- package/dist/{sdk → vendor/testserver-sdk}/factories/definitions.d.ts +7 -4
- package/dist/{sdk → vendor/testserver-sdk}/factories/definitions.js +10 -0
- package/dist/vendor/testserver-sdk/factories/gateways.d.ts +31 -0
- package/dist/vendor/testserver-sdk/factories/index.d.ts +4 -0
- package/dist/{sdk → vendor/testserver-sdk}/factories/index.js +3 -3
- package/dist/vendor/testserver-sdk/index.d.ts +6 -0
- package/dist/vendor/testserver-sdk/index.js +11 -0
- package/dist/{sdk → vendor/testserver-sdk}/proxy/exchange.d.ts +2 -1
- package/dist/{sdk → vendor/testserver-sdk}/proxy/exchange.js +8 -4
- package/dist/{sdk → vendor/testserver-sdk}/proxy/faulted-exchange.js +7 -2
- package/dist/{sdk → vendor/testserver-sdk}/proxy/faults.d.ts +2 -1
- package/dist/{sdk → vendor/testserver-sdk}/proxy/records.d.ts +10 -1
- package/dist/{sdk → vendor/testserver-sdk}/proxy/records.js +13 -0
- package/dist/{sdk → vendor/testserver-sdk}/records/index.d.ts +1 -1
- package/dist/{sdk → vendor/testserver-sdk}/records/records.d.ts +17 -1
- package/dist/vendor/testserver-sdk/testserver/external-ids.d.ts +38 -0
- package/dist/vendor/testserver-sdk/testserver/external-ids.js +46 -0
- package/dist/vendor/testserver-sdk/testserver/failure.d.ts +101 -0
- package/dist/vendor/testserver-sdk/testserver/failure.js +108 -0
- package/dist/vendor/testserver-sdk/testserver/index.d.ts +7 -0
- package/dist/vendor/testserver-sdk/testserver/index.js +11 -0
- package/dist/{sdk → vendor/testserver-sdk}/testserver/live/request.d.ts +8 -10
- package/dist/{sdk → vendor/testserver-sdk}/testserver/live/request.js +8 -6
- package/dist/vendor/testserver-sdk/testserver/routes.d.ts +60 -0
- package/dist/vendor/testserver-sdk/testserver/routes.js +84 -0
- package/dist/vendor/testserver-sdk/testserver/service-ids.d.ts +31 -0
- package/dist/{sdk → vendor/testserver-sdk}/testserver/service-ids.js +27 -4
- package/dist/vitest/config.d.ts +2 -28
- package/dist/vitest/config.js +6 -36
- package/dist/vitest/gateways.js +1 -1
- package/dist/vitest/index.d.ts +2 -3
- package/dist/vitest/index.js +5 -9
- package/dist/vitest/plan.d.ts +1 -16
- package/dist/vitest/plan.js +4 -36
- package/dist/vitest/test-events.d.ts +1 -18
- package/dist/vitest/test-events.js +2 -31
- package/package.json +52 -23
- package/skills/overview.md +9 -9
- package/skills/read-run-output.md +25 -2
- package/skills/testserver-builds.md +8 -8
- package/dist/chunks/chunk-5CQCRX2L.js +0 -5768
- package/dist/chunks/chunk-5U5Q6VZR.js +0 -556
- package/dist/chunks/chunk-7O6UN63H.js +0 -63
- package/dist/chunks/chunk-NX55IJ5S.js +0 -1842
- package/dist/chunks/chunk-OCZJE5XV.js +0 -910
- package/dist/chunks/chunk-S5NAIZYS.js +0 -13
- package/dist/chunks/chunk-UHO5OCEX.js +0 -360
- package/dist/chunks/chunk-WBIHJM7D.js +0 -188
- package/dist/combine-errors.d.ts +0 -11
- package/dist/combine-errors.js +0 -19
- package/dist/commands/exec/testserver-flags.d.ts +0 -48
- package/dist/commands/exec/testserver-flags.js +0 -80
- package/dist/config/by-name.d.ts +0 -24
- package/dist/config/by-name.js +0 -26
- package/dist/config/resource-config.d.ts +0 -132
- package/dist/config/resource-config.js +0 -19
- package/dist/config/set.d.ts +0 -27
- package/dist/config/set.js +0 -71
- package/dist/core/command-provider.d.ts +0 -126
- package/dist/core/command-provider.js +0 -13
- package/dist/core/command-slots.d.ts +0 -73
- package/dist/core/command-slots.js +0 -140
- package/dist/core/keyed.d.ts +0 -12
- package/dist/core/keyed.js +0 -24
- package/dist/core/lane.d.ts +0 -46
- package/dist/core/lane.js +0 -5
- package/dist/core/presentation.d.ts +0 -87
- package/dist/core/presentation.js +0 -5
- package/dist/core/provider.d.ts +0 -79
- package/dist/core/provider.js +0 -5
- package/dist/resource-commands.d.ts +0 -13
- package/dist/resource-commands.js +0 -22
- package/dist/resources/github/cleanup.d.ts +0 -23
- package/dist/resources/github/cleanup.js +0 -39
- package/dist/resources/github/command.d.ts +0 -126
- package/dist/resources/github/command.js +0 -117
- package/dist/resources/github/config.d.ts +0 -16
- package/dist/resources/github/config.js +0 -37
- package/dist/resources/github/events.d.ts +0 -26
- package/dist/resources/github/events.js +0 -2
- package/dist/resources/github/index.d.ts +0 -12
- package/dist/resources/github/index.js +0 -15
- package/dist/resources/github/live/gateways.d.ts +0 -6
- package/dist/resources/github/live/gateways.js +0 -13
- package/dist/resources/github/presentation.d.ts +0 -13
- package/dist/resources/github/presentation.js +0 -43
- package/dist/resources/github/provider.d.ts +0 -66
- package/dist/resources/github/provider.js +0 -58
- package/dist/resources/github/resource-provider.d.ts +0 -6
- package/dist/resources/github/resource-provider.js +0 -20
- package/dist/resources/github/resource.d.ts +0 -33
- package/dist/resources/github/resource.js +0 -12
- package/dist/resources/testserver/cleanup.d.ts +0 -14
- package/dist/resources/testserver/cleanup.js +0 -22
- package/dist/resources/testserver/command-tree.d.ts +0 -4
- package/dist/resources/testserver/command-tree.js +0 -12
- package/dist/resources/testserver/command.d.ts +0 -520
- package/dist/resources/testserver/command.js +0 -252
- package/dist/resources/testserver/commands/app.d.ts +0 -18
- package/dist/resources/testserver/commands/app.js +0 -3
- package/dist/resources/testserver/commands/create/metadata.d.ts +0 -31
- package/dist/resources/testserver/commands/create/metadata.js +0 -53
- package/dist/resources/testserver/commands/list/metadata.d.ts +0 -9
- package/dist/resources/testserver/config.d.ts +0 -18
- package/dist/resources/testserver/config.js +0 -88
- package/dist/resources/testserver/events.js +0 -4
- package/dist/resources/testserver/index.d.ts +0 -16
- package/dist/resources/testserver/index.js +0 -25
- package/dist/resources/testserver/live/gateways.d.ts +0 -8
- package/dist/resources/testserver/live/gateways.js +0 -39
- package/dist/resources/testserver/options.d.ts +0 -5
- package/dist/resources/testserver/options.js +0 -5
- package/dist/resources/testserver/pool/directory.d.ts +0 -4
- package/dist/resources/testserver/pool/directory.js +0 -5
- package/dist/resources/testserver/pool/live/pool-store-gateway.d.ts +0 -12
- package/dist/resources/testserver/pr-build-facts.d.ts +0 -130
- package/dist/resources/testserver/pr-build-facts.js +0 -261
- package/dist/resources/testserver/presentation.d.ts +0 -9
- package/dist/resources/testserver/provider.d.ts +0 -187
- package/dist/resources/testserver/pull-request/gateways.js +0 -5
- package/dist/resources/testserver/ran.d.ts +0 -92
- package/dist/resources/testserver/ran.js +0 -156
- package/dist/resources/testserver/resource-provider.d.ts +0 -12
- package/dist/resources/testserver/resource-provider.js +0 -32
- package/dist/resources/testserver/resource.d.ts +0 -36
- package/dist/resources/testserver/resource.js +0 -10
- package/dist/resources/testserver/run-sandbox.d.ts +0 -13
- package/dist/resources/testserver/run-sandbox.js +0 -6
- package/dist/resources/testserver/sandbox/index.js +0 -8
- package/dist/resources.d.ts +0 -702
- package/dist/resources.js +0 -83
- package/dist/sdk/container/api-request.js +0 -46
- package/dist/sdk/container/gateways.d.ts +0 -108
- package/dist/sdk/container/live/container-gateway.d.ts +0 -17
- package/dist/sdk/container/live/container-gateway.js +0 -114
- package/dist/sdk/factories/definition.d.ts +0 -28
- package/dist/sdk/factories/gateways.d.ts +0 -25
- package/dist/sdk/factories/index.d.ts +0 -5
- package/dist/sdk/factories/live/factory-gateway.d.ts +0 -10
- package/dist/sdk/factories/live/factory-gateway.js +0 -29
- package/dist/sdk/host.d.ts +0 -2
- package/dist/sdk/host.js +0 -7
- package/dist/sdk/payload/index.d.ts +0 -2
- package/dist/sdk/payload/index.js +0 -4
- package/dist/sdk/payload/payload.d.ts +0 -47
- package/dist/sdk/payload/payload.js +0 -74
- package/dist/sdk/testserver/failure.d.ts +0 -73
- package/dist/sdk/testserver/failure.js +0 -61
- package/dist/sdk/testserver/index.d.ts +0 -5
- package/dist/sdk/testserver/index.js +0 -8
- package/dist/sdk/testserver/service-ids.d.ts +0 -19
- package/dist/vitest/sandbox.d.ts +0 -22
- package/dist/vitest/sandbox.js +0 -41
- /package/dist/{credential/settle.js → config/credential-settle.js} +0 -0
- /package/dist/{resources → extensions}/github/gateways.d.ts +0 -0
- /package/dist/{resources → extensions}/github/gateways.js +0 -0
- /package/dist/{resources → extensions}/github/live/fixture-repo-gateway.d.ts +0 -0
- /package/dist/{resources → extensions}/github/live/fixture-repo-gateway.js +0 -0
- /package/dist/{resources/testserver/commands → extensions/testserver/commands/pool}/list/outcomes.d.ts +0 -0
- /package/dist/{core → extensions/testserver}/limit.d.ts +0 -0
- /package/dist/{resources/testserver/sandbox → extensions/testserver/options}/build-reference.d.ts +0 -0
- /package/dist/{resources/testserver/sandbox → extensions/testserver/options}/build-reference.js +0 -0
- /package/dist/{resources/testserver/sandbox → extensions/testserver/options}/channels.js +0 -0
- /package/dist/{resources → extensions}/testserver/pool/gateways.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/pool/gateways.js +0 -0
- /package/dist/{resources → extensions}/testserver/pool/host.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/pool/host.js +0 -0
- /package/dist/{resources → extensions}/testserver/pool/inspect.js +0 -0
- /package/dist/{resources → extensions}/testserver/pool/lease.js +0 -0
- /package/dist/{resources → extensions}/testserver/pool/live/pool-records.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/pool/live/pool-records.js +0 -0
- /package/dist/{resources → extensions}/testserver/pool/staleness.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/pool/staleness.js +0 -0
- /package/dist/{resources → extensions}/testserver/pull-request/index.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/pull-request/live/github-rest.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/pull-request/live/github-rest.js +0 -0
- /package/dist/{resources → extensions}/testserver/pull-request/live/pull-request-gateway.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/pull-request/live/pull-request-gateway.js +0 -0
- /package/dist/{resources → extensions}/testserver/pull-request/live/testserver-workflow-gateway.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/pull-request/live/testserver-workflow-gateway.js +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/create-failure.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/create-failure.js +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/gateways.js +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/live/builds-response.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/live/builds-response.js +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/live/control-plane-gateway.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/live/control-plane-gateway.js +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/live/create-response.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/live/create-response.js +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/live/fetch-failure.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/live/fetch-failure.js +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/live/health-check-gateway.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/live/health-check-gateway.js +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/live/sse.d.ts +0 -0
- /package/dist/{resources → extensions}/testserver/sandbox/live/sse.js +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/ansi.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/ansi.js +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/arguments.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/auth-config.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/auth-config.js +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/clock.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/clock.js +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/config-files.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/config-files.js +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/context.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/driver.js +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/entry.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/entry.js +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/environment.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/environment.js +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/errors.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/errors.js +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/gateways.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/index.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/keys.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/keys.js +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/live/config-files.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/live/config-files.js +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/live/process-gateway.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/live/process-gateway.js +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/redaction.d.ts +0 -0
- /package/dist/{vercel-cli → extensions/testserver/vercel-cli}/verbose.d.ts +0 -0
- /package/dist/{vitest → extensions/testserver/vitest}/types.js +0 -0
- /package/dist/sdk/{payload → run}/test-events.d.ts +0 -0
- /package/dist/sdk/{payload → run}/test-events.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/container/feature-flags.d.ts +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/container/feature-flags.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/container/gateways.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/factories/gateways.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/proxy/faulted-exchange.d.ts +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/proxy/faults.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/proxy/index.d.ts +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/proxy/index.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/proxy/proxy.d.ts +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/proxy/proxy.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/records/body.d.ts +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/records/body.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/records/index.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/records/records.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/seed/index.d.ts +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/seed/index.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/seed/seed.d.ts +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/seed/seed.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/testserver/clock.d.ts +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/testserver/clock.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/testserver/live/connect-failure.d.ts +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/testserver/live/connect-failure.js +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/testserver/test-id.d.ts +0 -0
- /package/dist/{sdk → vendor/testserver-sdk}/testserver/test-id.js +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { FactoryGateway } from "../factories/index.ts";
|
|
2
|
+
import type { RawTestserverAnswer, RawTestserverOutcome, RawTestserverRequest, TestserverCallFailed } from "../testserver/index.ts";
|
|
3
|
+
import type { FeatureFlagClient, FeatureFlagValue } from "./feature-flags.ts";
|
|
4
|
+
/**
|
|
5
|
+
* A container as Testserver describes it, in its answer to `PUT /_/test` and to `GET /_/test`: its `id` (the test id)
|
|
6
|
+
* and the label it was started with, `name` and `meta`, each only when the start gave it.
|
|
7
|
+
*/
|
|
8
|
+
export interface ContainerInfo {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly name?: string;
|
|
11
|
+
readonly meta?: Readonly<Record<string, unknown>>;
|
|
12
|
+
}
|
|
13
|
+
/** One container start: the container `testId` selects, labeled with `name` and `meta`. */
|
|
14
|
+
export interface StartContainerRequest {
|
|
15
|
+
readonly testserverUrl: string;
|
|
16
|
+
readonly testId: string;
|
|
17
|
+
readonly name?: string;
|
|
18
|
+
readonly meta?: Readonly<Record<string, unknown>>;
|
|
19
|
+
}
|
|
20
|
+
export type StartContainerOutcome = {
|
|
21
|
+
readonly ok: true;
|
|
22
|
+
readonly info: ContainerInfo;
|
|
23
|
+
} | TestserverCallFailed;
|
|
24
|
+
export type EndContainerOutcome = {
|
|
25
|
+
readonly ok: true;
|
|
26
|
+
} | TestserverCallFailed;
|
|
27
|
+
/**
|
|
28
|
+
* How Testserver describes a running container. A test id with no running container is an `http-error` 404
|
|
29
|
+
* (`Container Not Found`), and one whose container has stopped is `container-stopped`.
|
|
30
|
+
*/
|
|
31
|
+
export type ReadContainerOutcome = {
|
|
32
|
+
readonly ok: true;
|
|
33
|
+
readonly info: ContainerInfo;
|
|
34
|
+
} | TestserverCallFailed;
|
|
35
|
+
/** The container `testId` selects on the Testserver sandbox at `testserverUrl`. */
|
|
36
|
+
export interface ContainerAddress {
|
|
37
|
+
readonly testserverUrl: string;
|
|
38
|
+
readonly testId: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* One record of a container log, as Testserver keeps it: one for each request or event a container's services
|
|
42
|
+
* logged. `id`, `timestamp`, `serviceId` and `message` are checked; anything else, such as `protocol`,
|
|
43
|
+
* `statusCode` or `stack`, passes through unchecked.
|
|
44
|
+
*/
|
|
45
|
+
export interface ContainerLogRecord {
|
|
46
|
+
/** Such as `L1001`, counting up within the container. */
|
|
47
|
+
readonly id: string;
|
|
48
|
+
/** An ISO 8601 time. */
|
|
49
|
+
readonly timestamp: string;
|
|
50
|
+
readonly serviceId: string;
|
|
51
|
+
readonly message: string;
|
|
52
|
+
readonly [key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Which of a container log's records a read returns. Every read includes the unfinished records with the finished.
|
|
56
|
+
*
|
|
57
|
+
* - `internal`: include the records of Testserver's own services, those whose `serviceId` starts with `@testserver/`,
|
|
58
|
+
* such as `@testserver/factories` for a factory call; left out by default.
|
|
59
|
+
* - `after`: only the records after the record with this id, among those the read includes; none when no such record
|
|
60
|
+
* is among them, because Testserver dropped it or because it is an `@testserver/` record and `internal` is unset.
|
|
61
|
+
* Testserver keeps the records in this order: a record joins the end when it starts and moves to the end when it
|
|
62
|
+
* finishes. So name a finished record: the records after it are those that started or finished since. Once an
|
|
63
|
+
* unfinished record finishes, it moves past the records that finished before it.
|
|
64
|
+
*/
|
|
65
|
+
export interface ContainerLogOptions {
|
|
66
|
+
readonly internal?: boolean;
|
|
67
|
+
readonly after?: string;
|
|
68
|
+
}
|
|
69
|
+
/** One read of the container log of the container `testId` selects. */
|
|
70
|
+
export type ReadLogRequest = ContainerAddress & ContainerLogOptions;
|
|
71
|
+
/** One service to start in the container `testId` selects: `serviceId`, one of Testserver's service ids. */
|
|
72
|
+
export interface WarmServiceRequest extends ContainerAddress {
|
|
73
|
+
readonly serviceId: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Whether a service has started: it answered its `readyz`, which Testserver forwards to it only once it has started,
|
|
77
|
+
* with a 2xx, or, for an app service (`APP_SERVICE_IDS`), which has no `readyz` route, with its own 404 (any status
|
|
78
|
+
* below 500 but 410). Any other answer is a failure: an `http-error`, such as Testserver's 500 for a service that
|
|
79
|
+
* failed to start, or `container-stopped`.
|
|
80
|
+
*/
|
|
81
|
+
export type WarmServiceOutcome = {
|
|
82
|
+
readonly ok: true;
|
|
83
|
+
} | TestserverCallFailed;
|
|
84
|
+
/**
|
|
85
|
+
* One flag client's feature flags for the container `testId` selects: Testserver merges `flags` into the client's
|
|
86
|
+
* map and rewrites the flags datafile its services read once, when each starts.
|
|
87
|
+
*/
|
|
88
|
+
export interface SetFeatureFlagsRequest extends ContainerAddress {
|
|
89
|
+
readonly client: FeatureFlagClient;
|
|
90
|
+
readonly flags: Readonly<Record<string, FeatureFlagValue>>;
|
|
91
|
+
}
|
|
92
|
+
export type SetFeatureFlagsOutcome = {
|
|
93
|
+
readonly ok: true;
|
|
94
|
+
} | TestserverCallFailed;
|
|
95
|
+
export type ReadLogOutcome = {
|
|
96
|
+
readonly ok: true;
|
|
97
|
+
readonly records: readonly ContainerLogRecord[];
|
|
98
|
+
} | TestserverCallFailed;
|
|
99
|
+
/**
|
|
100
|
+
* One request to a container, an API request or an external call: a raw data-plane request, sent as given with the
|
|
101
|
+
* test id added, under the gateway's call timeout. `path` is the whole path under the Testserver URL, with any query:
|
|
102
|
+
* an API request's as the caller gave it, or an external call's under `/_/external/<id>` (`routes.external`).
|
|
103
|
+
*/
|
|
104
|
+
export type ContainerRequest = Omit<RawTestserverRequest, "timeoutMs">;
|
|
105
|
+
/** What Testserver answered a request to a container, whatever its status, the body read whole and decompressed. */
|
|
106
|
+
export type ContainerAnswer = RawTestserverAnswer;
|
|
107
|
+
export type ContainerRequestOutcome = RawTestserverOutcome;
|
|
108
|
+
/** One run of the setup script `scriptId` in the container `testId` selects. */
|
|
109
|
+
export interface SetupScriptRequest extends ContainerAddress {
|
|
110
|
+
readonly scriptId: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* What a setup script returned: its JSON value, the text Testserver sent for a value that isn't JSON (a string), or
|
|
114
|
+
* `undefined` for none. A script that failed, or that Testserver doesn't bundle, is an `http-error` 500
|
|
115
|
+
* (`Failed to execute setup script <id>: …`).
|
|
116
|
+
*/
|
|
117
|
+
export type SetupScriptOutcome = {
|
|
118
|
+
readonly ok: true;
|
|
119
|
+
readonly value: unknown;
|
|
120
|
+
} | TestserverCallFailed;
|
|
121
|
+
/**
|
|
122
|
+
* Testserver's containers, one per test id, and everything the SDK sends them, factory calls (`build`, the
|
|
123
|
+
* `factories` module's `FactoryGateway`) included. Ending is idempotent: ending a container that is gone succeeds.
|
|
124
|
+
* Any status answers an API request; what a status means is the caller's to decide. It never rejects: every failure
|
|
125
|
+
* is in the outcome, and each failed call's outcome carries the call it sent (`TestserverCallFailed`), which the
|
|
126
|
+
* caller's error names.
|
|
127
|
+
*/
|
|
128
|
+
export interface ContainerGateway extends FactoryGateway {
|
|
129
|
+
start(request: StartContainerRequest): Promise<StartContainerOutcome>;
|
|
130
|
+
end(request: ContainerAddress): Promise<EndContainerOutcome>;
|
|
131
|
+
/** How Testserver describes the running container: its id and the label it was started with. */
|
|
132
|
+
readContainer(request: ContainerAddress): Promise<ReadContainerOutcome>;
|
|
133
|
+
/**
|
|
134
|
+
* The records of the container's log Testserver keeps, finished or not, in its order, which `request`'s
|
|
135
|
+
* `internal` and `after` filter (`ContainerLogOptions`).
|
|
136
|
+
*/
|
|
137
|
+
readLog(request: ReadLogRequest): Promise<ReadLogOutcome>;
|
|
138
|
+
/**
|
|
139
|
+
* Sends one request to the container, an API request or, under `/_/external/<id>/`, an external call, and reads its
|
|
140
|
+
* whole answer whatever its status. What records it is the caller's.
|
|
141
|
+
*/
|
|
142
|
+
send(request: ContainerRequest): Promise<ContainerRequestOutcome>;
|
|
143
|
+
/** Runs one of Testserver's bundled setup scripts in the container (`POST /_/setup/<id>`). */
|
|
144
|
+
runSetupScript(request: SetupScriptRequest): Promise<SetupScriptOutcome>;
|
|
145
|
+
/**
|
|
146
|
+
* Starts one of the container's services, if it hasn't started, by asking its `readyz`, and says whether it has
|
|
147
|
+
* started (`WarmServiceOutcome`): an app service that started answers its own 404, which is `ok`, and a service that
|
|
148
|
+
* fails to start answers 500. It isn't an API request: nothing records it.
|
|
149
|
+
*/
|
|
150
|
+
warmService(request: WarmServiceRequest): Promise<WarmServiceOutcome>;
|
|
151
|
+
/**
|
|
152
|
+
* Merges one flag client's feature flags into the container's, which a service reads once, when it starts. A
|
|
153
|
+
* Testserver control-plane call, not an API request: nothing records it.
|
|
154
|
+
*/
|
|
155
|
+
setFeatureFlags(request: SetFeatureFlagsRequest): Promise<SetFeatureFlagsOutcome>;
|
|
156
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { type Container, type ContainerOptions, DEFAULT_START_TIMEOUT_MS, DEFAULT_TIMEOUT_MS, liveSdkContext, type SdkContext, type ServiceWarmup, type ServiceWarmupOutcome, START_ATTEMPTS, START_RETRY_DELAY_MS, startContainer, withContainer, } from "./container.ts";
|
|
2
2
|
export { checkFeatureFlags, FEATURE_FLAG_CLIENTS, type FeatureFlagClient, type FeatureFlags, featureFlagsKey, type FeatureFlagValue, normalizeFeatureFlags, } from "./feature-flags.ts";
|
|
3
3
|
export type { ContainerRequestBody, ContainerRequestInit } from "./api-request.ts";
|
|
4
|
-
export type {
|
|
4
|
+
export type { ExternalService, GitProvider, GitProviderRequestLog, GitProviderScenario, SetupCall, } from "./external.ts";
|
|
5
|
+
export type { ContainerAddress, ContainerAnswer, ContainerGateway, ContainerInfo, ContainerLogOptions, ContainerLogRecord, ContainerRequest, ContainerRequestOutcome, EndContainerOutcome, ReadContainerOutcome, ReadLogOutcome, ReadLogRequest, SetFeatureFlagsOutcome, SetFeatureFlagsRequest, SetupScriptOutcome, SetupScriptRequest, StartContainerOutcome, StartContainerRequest, WarmServiceOutcome, WarmServiceRequest, } from "./gateways.ts";
|
|
5
6
|
export { liveContainerGateway, type LiveContainerOptions } from "./live/container-gateway.ts";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// The SDK's `container` module: starting and ending containers, with their feature flags, and the container handle
|
|
2
|
-
// that seeds them, sends API requests to them and reads
|
|
2
|
+
// that seeds them, sends API requests to them, reaches their external services, runs setup scripts in them and reads
|
|
3
|
+
// their logs.
|
|
3
4
|
export { DEFAULT_START_TIMEOUT_MS, DEFAULT_TIMEOUT_MS, liveSdkContext, START_ATTEMPTS, START_RETRY_DELAY_MS, startContainer, withContainer, } from "./container.js";
|
|
4
5
|
export { checkFeatureFlags, FEATURE_FLAG_CLIENTS, featureFlagsKey, normalizeFeatureFlags, } from "./feature-flags.js";
|
|
5
6
|
export { liveContainerGateway } from "./live/container-gateway.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ContainerGateway } from "../gateways.ts";
|
|
2
|
+
export interface LiveContainerOptions {
|
|
3
|
+
/**
|
|
4
|
+
* How long one call, response body included, may take: an end, a container read, a log read, a factory call, an
|
|
5
|
+
* API request, an external call, a setup script, a warmup or a flag client's feature flags.
|
|
6
|
+
*/
|
|
7
|
+
readonly timeoutMs: number;
|
|
8
|
+
/** How long one container start attempt, response body included, may take. */
|
|
9
|
+
readonly startTimeoutMs: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Containers over `fetch`: `PUT /_/test` (answering 201 with `{ id, name, meta }`) starts one, `DELETE /_/test`
|
|
13
|
+
* (answering 204) ends one, `GET /_/test` (answering 200 with the same) reads how Testserver describes it,
|
|
14
|
+
* `GET /_/log` reads its log, `POST /_/factories/<path>` builds through a factory (under `/_/external/<id>` for an
|
|
15
|
+
* external service's, answering with JSON), `GET /_/service/<id>/readyz` starts one of its services (a 2xx, or an app
|
|
16
|
+
* service's own 404, says it has started),
|
|
17
|
+
* `PATCH /_/external/flags/<client>` merges a flag client's feature flags into its flags datafile, any other path
|
|
18
|
+
* under `/_/external/<id>/` is a request to one of its external services, `POST /_/setup/<id>` runs a setup script
|
|
19
|
+
* in it (answering 200 with the script's return value), and any other path is an API request to it, each with the
|
|
20
|
+
* `test-id` header.
|
|
21
|
+
*/
|
|
22
|
+
export declare function liveContainerGateway(options: LiveContainerOptions): ContainerGateway;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { APP_SERVICE_IDS, requestTestserver, routes, sendTestserverRequest, } from "../../testserver/index.js";
|
|
3
|
+
/** A container as `PUT /_/test` and `GET /_/test` describe it (`getInfo()`): its id, and its label when it has one. */
|
|
4
|
+
const containerInfoSchema = z.looseObject({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
name: z.string().optional(),
|
|
7
|
+
meta: z.record(z.string(), z.unknown()).optional(),
|
|
8
|
+
});
|
|
9
|
+
/** A container log as `GET /_/log` answers it: the checked fields typed, the rest passed through. */
|
|
10
|
+
const containerLogSchema = z.array(z.looseObject({ id: z.string(), timestamp: z.string(), serviceId: z.string(), message: z.string() }));
|
|
11
|
+
/**
|
|
12
|
+
* Containers over `fetch`: `PUT /_/test` (answering 201 with `{ id, name, meta }`) starts one, `DELETE /_/test`
|
|
13
|
+
* (answering 204) ends one, `GET /_/test` (answering 200 with the same) reads how Testserver describes it,
|
|
14
|
+
* `GET /_/log` reads its log, `POST /_/factories/<path>` builds through a factory (under `/_/external/<id>` for an
|
|
15
|
+
* external service's, answering with JSON), `GET /_/service/<id>/readyz` starts one of its services (a 2xx, or an app
|
|
16
|
+
* service's own 404, says it has started),
|
|
17
|
+
* `PATCH /_/external/flags/<client>` merges a flag client's feature flags into its flags datafile, any other path
|
|
18
|
+
* under `/_/external/<id>/` is a request to one of its external services, `POST /_/setup/<id>` runs a setup script
|
|
19
|
+
* in it (answering 200 with the script's return value), and any other path is an API request to it, each with the
|
|
20
|
+
* `test-id` header.
|
|
21
|
+
*/
|
|
22
|
+
export function liveContainerGateway(options) {
|
|
23
|
+
const { timeoutMs } = options;
|
|
24
|
+
return {
|
|
25
|
+
start: (request) => start(options, request),
|
|
26
|
+
build: (request) => build(options, request),
|
|
27
|
+
end: async (request) => {
|
|
28
|
+
const response = await requestTestserver({ ...request, call: routes.end(), timeoutMs });
|
|
29
|
+
return response.ok ? { ok: true } : response;
|
|
30
|
+
},
|
|
31
|
+
readContainer: async (request) => {
|
|
32
|
+
const call = routes.readContainer();
|
|
33
|
+
const response = await requestTestserver({ ...request, call, timeoutMs });
|
|
34
|
+
if (!response.ok)
|
|
35
|
+
return response;
|
|
36
|
+
return parseContainerInfo(call, response.text);
|
|
37
|
+
},
|
|
38
|
+
readLog: async ({ testserverUrl, testId, ...logOptions }) => {
|
|
39
|
+
const call = routes.readLog(logOptions);
|
|
40
|
+
const response = await requestTestserver({ testserverUrl, testId, call, timeoutMs });
|
|
41
|
+
if (!response.ok)
|
|
42
|
+
return response;
|
|
43
|
+
return parseLog(call, response.text);
|
|
44
|
+
},
|
|
45
|
+
send: (request) => sendTestserverRequest({ ...request, timeoutMs }),
|
|
46
|
+
runSetupScript: async ({ scriptId, ...address }) => {
|
|
47
|
+
// `container.setup` refuses an id Testserver couldn't route.
|
|
48
|
+
const response = await requestTestserver({ ...address, call: routes.setupScript(scriptId), timeoutMs });
|
|
49
|
+
if (!response.ok)
|
|
50
|
+
return response;
|
|
51
|
+
return { ok: true, value: parseSetupValue(response.text) };
|
|
52
|
+
},
|
|
53
|
+
warmService: async ({ serviceId, ...address }) => {
|
|
54
|
+
// `container.warmup` refuses an id Testserver couldn't route.
|
|
55
|
+
const response = await requestTestserver({ ...address, call: routes.warmService(serviceId), timeoutMs });
|
|
56
|
+
return response.ok || appAnswered(serviceId, response.failure) ? { ok: true } : response;
|
|
57
|
+
},
|
|
58
|
+
setFeatureFlags: async ({ client, flags, ...address }) => {
|
|
59
|
+
// Testserver answers with the client's merged map, which nothing reads.
|
|
60
|
+
const call = routes.featureFlags(client);
|
|
61
|
+
const response = await requestTestserver({ ...address, call, body: flags, timeoutMs });
|
|
62
|
+
return response.ok ? { ok: true } : response;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async function start(options, request) {
|
|
67
|
+
const label = {
|
|
68
|
+
...(request.name === undefined ? {} : { name: request.name }),
|
|
69
|
+
...(request.meta === undefined ? {} : { meta: request.meta }),
|
|
70
|
+
};
|
|
71
|
+
const call = routes.start();
|
|
72
|
+
const response = await requestTestserver({
|
|
73
|
+
testserverUrl: request.testserverUrl,
|
|
74
|
+
testId: request.testId,
|
|
75
|
+
call,
|
|
76
|
+
...(Object.keys(label).length === 0 ? {} : { body: label }),
|
|
77
|
+
timeoutMs: options.startTimeoutMs,
|
|
78
|
+
});
|
|
79
|
+
if (!response.ok)
|
|
80
|
+
return response;
|
|
81
|
+
return parseContainerInfo(call, response.text);
|
|
82
|
+
}
|
|
83
|
+
const APP_SERVICES = new Set(APP_SERVICE_IDS);
|
|
84
|
+
/**
|
|
85
|
+
* Whether `failure` is an app service's own answer to its `readyz`, which it gives only once it has started: an app
|
|
86
|
+
* (`APP_SERVICE_IDS`) has no `readyz` route, and Testserver forwards `readyz` to it only once the app's own readiness
|
|
87
|
+
* route answers, so it answers with its own 404 page (checked live). Any status below 500 counts, but a 410, which the
|
|
88
|
+
* Testserver sandbox answers once it has expired. A 5xx may be Testserver's own failure, such as a 500 for a service
|
|
89
|
+
* that failed to start or a 502, so it never counts, and nor does any other service's non-2xx. Testserver's 503 for a
|
|
90
|
+
* stopped container is no `http-error` but `container-stopped`, which never counts either.
|
|
91
|
+
*/
|
|
92
|
+
function appAnswered(serviceId, failure) {
|
|
93
|
+
return APP_SERVICES.has(serviceId) && failure.kind === "http-error" && failure.status < 500 && failure.status !== 410;
|
|
94
|
+
}
|
|
95
|
+
/** One factory call: the JSON body `[data, options]`, or `[data]` without options, answered with JSON. */
|
|
96
|
+
async function build(options, request) {
|
|
97
|
+
const call = routes.factory(request.path, request.externalId);
|
|
98
|
+
const response = await requestTestserver({
|
|
99
|
+
testserverUrl: request.testserverUrl,
|
|
100
|
+
testId: request.testId,
|
|
101
|
+
call,
|
|
102
|
+
body: request.options === undefined ? [request.data] : [request.data, request.options],
|
|
103
|
+
timeoutMs: options.timeoutMs,
|
|
104
|
+
});
|
|
105
|
+
if (!response.ok)
|
|
106
|
+
return response;
|
|
107
|
+
try {
|
|
108
|
+
return { ok: true, body: JSON.parse(response.text) };
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return malformed(call, `not JSON: ${response.text}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/** A container's description, as `PUT /_/test` and `GET /_/test` answer it, with only the fields `ContainerInfo` has. */
|
|
115
|
+
function parseContainerInfo(call, text) {
|
|
116
|
+
let json;
|
|
117
|
+
try {
|
|
118
|
+
json = JSON.parse(text);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return malformed(call, `not JSON: ${text}`);
|
|
122
|
+
}
|
|
123
|
+
const info = containerInfoSchema.safeParse(json);
|
|
124
|
+
if (!info.success)
|
|
125
|
+
return malformed(call, "no container id");
|
|
126
|
+
const { id, name, meta } = info.data;
|
|
127
|
+
return { ok: true, info: { id, ...(name === undefined ? {} : { name }), ...(meta === undefined ? {} : { meta }) } };
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A setup script's return value as Testserver sends it (micro's `send`): nothing for `undefined` or `null`, which
|
|
131
|
+
* reads `undefined`; text for a string; JSON for anything else.
|
|
132
|
+
*/
|
|
133
|
+
function parseSetupValue(text) {
|
|
134
|
+
if (text === "")
|
|
135
|
+
return undefined;
|
|
136
|
+
try {
|
|
137
|
+
return JSON.parse(text);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return text;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** A container log answer's records. An ending container answers with an empty body. */
|
|
144
|
+
function parseLog(call, text) {
|
|
145
|
+
if (text === "")
|
|
146
|
+
return malformed(call, "empty answer: the container is ending");
|
|
147
|
+
let json;
|
|
148
|
+
try {
|
|
149
|
+
json = JSON.parse(text);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return malformed(call, `not JSON: ${text}`);
|
|
153
|
+
}
|
|
154
|
+
const records = containerLogSchema.safeParse(json);
|
|
155
|
+
if (!records.success) {
|
|
156
|
+
const issue = records.error.issues[0];
|
|
157
|
+
const where = issue === undefined || issue.path.length === 0 ? "" : ` at ${issue.path.map(String).join(".")}`;
|
|
158
|
+
return malformed(call, `not a container log${where}`);
|
|
159
|
+
}
|
|
160
|
+
return { ok: true, records: records.data };
|
|
161
|
+
}
|
|
162
|
+
/** `call` failed with an answer the SDK couldn't read. */
|
|
163
|
+
function malformed(call, detail) {
|
|
164
|
+
return { ok: false, failure: { kind: "malformed", detail }, call };
|
|
165
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { FactoryCall } from "../factories/index.ts";
|
|
2
|
+
import { type ApiRequestRecord, type ExternalCallRecord, type RequestOutcome } from "../records/index.ts";
|
|
3
|
+
import { type TestserverFailure } from "../testserver/index.ts";
|
|
4
|
+
import type { ServiceWarmup } from "./container.ts";
|
|
5
|
+
import type { SetupCall } from "./external.ts";
|
|
6
|
+
import type { ContainerAnswer } from "./gateways.ts";
|
|
7
|
+
/** Which record list an exchange with the container goes to: its API requests, or one external service's calls. */
|
|
8
|
+
export type Channel = {
|
|
9
|
+
readonly kind: "api";
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: "external";
|
|
12
|
+
readonly externalId: string;
|
|
13
|
+
};
|
|
14
|
+
/** What an exchange sent, as its record keeps it: `target` is the path the caller gave, with any query. */
|
|
15
|
+
export interface SentExchange {
|
|
16
|
+
readonly method: string;
|
|
17
|
+
readonly target: string;
|
|
18
|
+
readonly headers: readonly (readonly [string, string])[];
|
|
19
|
+
readonly body: Uint8Array;
|
|
20
|
+
readonly startedAt: number;
|
|
21
|
+
}
|
|
22
|
+
/** One exchange the recorder has begun: what it was answered, then how it ended, which records it once. */
|
|
23
|
+
export interface RecordedExchange {
|
|
24
|
+
/** Keeps the answer's body, and learns the token fields of a JSON one, before anything reads the answer. */
|
|
25
|
+
answered(answer: ContainerAnswer): void;
|
|
26
|
+
/** Records the exchange, ended at `now` on the SDK clock. Only the first call records. */
|
|
27
|
+
end(outcome: RequestOutcome, now: number): void;
|
|
28
|
+
}
|
|
29
|
+
/** One setup script run, as the container sent it: the script's raw return value, or why it failed. */
|
|
30
|
+
export interface SetupRun {
|
|
31
|
+
readonly scriptId: string;
|
|
32
|
+
readonly outcome: {
|
|
33
|
+
readonly ok: true;
|
|
34
|
+
readonly value: unknown;
|
|
35
|
+
} | {
|
|
36
|
+
readonly ok: false;
|
|
37
|
+
readonly failure: TestserverFailure;
|
|
38
|
+
};
|
|
39
|
+
readonly startedAt: number;
|
|
40
|
+
readonly durationMs: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* What a container has done, and every token secret it has seen. Each write collects its secrets before it keeps
|
|
44
|
+
* its record, so `redact` replaces a secret as soon as anything holds it. Its reads return copies.
|
|
45
|
+
*/
|
|
46
|
+
export declare class ContainerRecorder {
|
|
47
|
+
#private;
|
|
48
|
+
get factoryCalls(): readonly FactoryCall[];
|
|
49
|
+
get apiRequests(): readonly ApiRequestRecord[];
|
|
50
|
+
get externalCalls(): readonly ExternalCallRecord[];
|
|
51
|
+
get setupCalls(): readonly SetupCall[];
|
|
52
|
+
get warmups(): readonly ServiceWarmup[];
|
|
53
|
+
/**
|
|
54
|
+
* Keeps a factory call's record as it came, but a failure redacted, and learns every token secret in its input,
|
|
55
|
+
* options and response first.
|
|
56
|
+
*/
|
|
57
|
+
factoryCall(call: FactoryCall): void;
|
|
58
|
+
/** Keeps a setup call's record, its return value with every token field reading `<token>`, once it has learned them. */
|
|
59
|
+
setupCall(run: SetupRun): void;
|
|
60
|
+
/**
|
|
61
|
+
* Begins the record of one exchange on `channel`: learns the bearer token it sends and keeps its request body, before
|
|
62
|
+
* it is sent, so `redact` covers a refused answer's excerpt.
|
|
63
|
+
*/
|
|
64
|
+
begin(channel: Channel, sent: SentExchange): RecordedExchange;
|
|
65
|
+
/** Keeps a warmup's record, each failed service's error redacted, and returns it. */
|
|
66
|
+
warmup(warmup: ServiceWarmup): ServiceWarmup;
|
|
67
|
+
/** `text` with every token secret the container has seen replaced by `<token>`. */
|
|
68
|
+
redact(text: string): string;
|
|
69
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { bearerToken, decodeBody, incomingHeaders, RECORDED_BODY_CAP_BYTES, redactBody, redactSecrets, redactTokenFields, tokenSecrets, } from "../records/index.js";
|
|
2
|
+
import { redactFailure } from "../testserver/index.js";
|
|
3
|
+
import { apiRequestRecord } from "./api-request.js";
|
|
4
|
+
/**
|
|
5
|
+
* What a container has done, and every token secret it has seen. Each write collects its secrets before it keeps
|
|
6
|
+
* its record, so `redact` replaces a secret as soon as anything holds it. Its reads return copies.
|
|
7
|
+
*/
|
|
8
|
+
export class ContainerRecorder {
|
|
9
|
+
#factoryCalls = [];
|
|
10
|
+
#apiRequests = [];
|
|
11
|
+
#externalCalls = [];
|
|
12
|
+
#setupCalls = [];
|
|
13
|
+
#warmups = [];
|
|
14
|
+
#secrets = new Set();
|
|
15
|
+
get factoryCalls() {
|
|
16
|
+
return [...this.#factoryCalls];
|
|
17
|
+
}
|
|
18
|
+
get apiRequests() {
|
|
19
|
+
return [...this.#apiRequests];
|
|
20
|
+
}
|
|
21
|
+
get externalCalls() {
|
|
22
|
+
return [...this.#externalCalls];
|
|
23
|
+
}
|
|
24
|
+
get setupCalls() {
|
|
25
|
+
return [...this.#setupCalls];
|
|
26
|
+
}
|
|
27
|
+
get warmups() {
|
|
28
|
+
return [...this.#warmups];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Keeps a factory call's record as it came, but a failure redacted, and learns every token secret in its input,
|
|
32
|
+
* options and response first.
|
|
33
|
+
*/
|
|
34
|
+
factoryCall(call) {
|
|
35
|
+
const seen = [call.input, call.options, call.outcome.ok ? call.outcome.response : undefined];
|
|
36
|
+
for (const value of seen)
|
|
37
|
+
this.#learn(value);
|
|
38
|
+
const { outcome } = call;
|
|
39
|
+
this.#factoryCalls.push(outcome.ok ? call : { ...call, outcome: { ok: false, failure: this.#redactFailure(outcome.failure) } });
|
|
40
|
+
}
|
|
41
|
+
/** Keeps a setup call's record, its return value with every token field reading `<token>`, once it has learned them. */
|
|
42
|
+
setupCall(run) {
|
|
43
|
+
const { scriptId, startedAt, durationMs } = run;
|
|
44
|
+
if (!run.outcome.ok) {
|
|
45
|
+
const failure = this.#redactFailure(run.outcome.failure);
|
|
46
|
+
this.#setupCalls.push({ scriptId, outcome: { ok: false, failure }, startedAt, durationMs });
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this.#learn(run.outcome.value);
|
|
50
|
+
const response = redactTokenFields(run.outcome.value);
|
|
51
|
+
this.#setupCalls.push({ scriptId, outcome: { ok: true, response }, startedAt, durationMs });
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Begins the record of one exchange on `channel`: learns the bearer token it sends and keeps its request body, before
|
|
55
|
+
* it is sent, so `redact` covers a refused answer's excerpt.
|
|
56
|
+
*/
|
|
57
|
+
begin(channel, sent) {
|
|
58
|
+
const authorization = sent.headers.find(([name]) => name.toLowerCase() === "authorization")?.[1];
|
|
59
|
+
const bearer = bearerToken(authorization);
|
|
60
|
+
if (bearer !== undefined && bearer !== "")
|
|
61
|
+
this.#secrets.add(bearer);
|
|
62
|
+
const requestBody = this.#kept(sent.body, sent.headers, bearer);
|
|
63
|
+
let responseBody;
|
|
64
|
+
let ended = false;
|
|
65
|
+
return {
|
|
66
|
+
answered: (answer) => {
|
|
67
|
+
responseBody = this.#kept(answer.body, answer.headers, bearer);
|
|
68
|
+
},
|
|
69
|
+
end: (outcome, now) => {
|
|
70
|
+
if (ended)
|
|
71
|
+
return;
|
|
72
|
+
ended = true;
|
|
73
|
+
const fields = apiRequestRecord({
|
|
74
|
+
method: sent.method,
|
|
75
|
+
target: sent.target,
|
|
76
|
+
authorization: authorization !== undefined,
|
|
77
|
+
requestBody,
|
|
78
|
+
responseBody,
|
|
79
|
+
startedAt: sent.startedAt,
|
|
80
|
+
durationMs: now - sent.startedAt,
|
|
81
|
+
outcome,
|
|
82
|
+
});
|
|
83
|
+
if (channel.kind === "api")
|
|
84
|
+
this.#apiRequests.push(fields);
|
|
85
|
+
else
|
|
86
|
+
this.#externalCalls.push({ externalId: channel.externalId, ...fields });
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Keeps a warmup's record, each failed service's error redacted, and returns it. */
|
|
91
|
+
warmup(warmup) {
|
|
92
|
+
const kept = {
|
|
93
|
+
...warmup,
|
|
94
|
+
services: warmup.services.map((service) => service.ok ? service : { ...service, error: this.redact(service.error) }),
|
|
95
|
+
};
|
|
96
|
+
this.#warmups.push(kept);
|
|
97
|
+
return kept;
|
|
98
|
+
}
|
|
99
|
+
/** `text` with every token secret the container has seen replaced by `<token>`. */
|
|
100
|
+
redact(text) {
|
|
101
|
+
return redactSecrets(text, this.#secrets);
|
|
102
|
+
}
|
|
103
|
+
/** `failure` with every text it quotes of an answer redacted (`redactFailure`). */
|
|
104
|
+
#redactFailure(failure) {
|
|
105
|
+
return redactFailure(failure, (text) => this.redact(text));
|
|
106
|
+
}
|
|
107
|
+
/** A body as its record keeps it: decoded, capped and redacted, the strings under its JSON token fields learned. */
|
|
108
|
+
#kept(bytes, headers, bearer) {
|
|
109
|
+
if (bytes.byteLength === 0)
|
|
110
|
+
return undefined;
|
|
111
|
+
const raw = bytes.byteLength > RECORDED_BODY_CAP_BYTES ? undefined : bytes;
|
|
112
|
+
const decoded = decodeBody(raw, bytes.byteLength, incomingHeaders(headers));
|
|
113
|
+
if (decoded.kind === "json")
|
|
114
|
+
this.#learn(decoded.value);
|
|
115
|
+
return redactBody(decoded, bearer);
|
|
116
|
+
}
|
|
117
|
+
#learn(value) {
|
|
118
|
+
for (const secret of tokenSecrets(value))
|
|
119
|
+
this.#secrets.add(secret);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import { type Clock, type TestserverFailure } from "../testserver/index.ts";
|
|
3
|
-
import { type AnyFactoryDefinition, type FactoryInput, type FactoryOutput } from "./definition.ts";
|
|
3
|
+
import { type AnyFactoryDefinition, type FactoryInput, type FactoryOptionsOf, type FactoryOutput } from "./definition.ts";
|
|
4
4
|
import type { FactoryGateway, FactoryOptions } from "./gateways.ts";
|
|
5
5
|
/**
|
|
6
|
-
* One factory call a container made, typed or untyped,
|
|
7
|
-
*
|
|
6
|
+
* One factory call a container made, typed or untyped, through one of Testserver's factories or, with `externalId`,
|
|
7
|
+
* one of that external service's, for failure output. `input` is the data sent. A call whose input its definition
|
|
8
|
+
* rejected was never sent and has no record.
|
|
8
9
|
*/
|
|
9
10
|
export interface FactoryCall {
|
|
11
|
+
/** The external service whose factory built it, such as `stripe`; absent for Testserver's own factories. */
|
|
12
|
+
readonly externalId?: string;
|
|
10
13
|
readonly path: string;
|
|
11
14
|
readonly input: unknown;
|
|
12
15
|
readonly options?: FactoryOptions;
|
|
@@ -26,19 +29,34 @@ export interface FactoryContext {
|
|
|
26
29
|
readonly factories: FactoryGateway;
|
|
27
30
|
readonly clock: Clock;
|
|
28
31
|
}
|
|
29
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* The container a factory call seeds, and what keeps its call records. With `externalId`, the call goes to that
|
|
34
|
+
* external service's factories.
|
|
35
|
+
*/
|
|
30
36
|
export interface FactoryTarget {
|
|
31
37
|
readonly testserverUrl: string;
|
|
32
38
|
readonly testId: string;
|
|
39
|
+
readonly externalId?: string;
|
|
33
40
|
/** Keeps the record of a call once it has ended, before the call resolves or rejects. */
|
|
34
41
|
readonly record: (call: FactoryCall) => void;
|
|
42
|
+
/** Hides every secret the target has learned, those in the call's record among them, in a failed call's error. */
|
|
43
|
+
readonly redact: (text: string) => string;
|
|
35
44
|
}
|
|
36
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* What part of a factory call the SDK refused before sending it: the data, which the definition's `input` schema
|
|
47
|
+
* rejected; the options, which its `options` schema rejected; or the path of an untyped call, which is no factory path.
|
|
48
|
+
*/
|
|
49
|
+
export type FactoryInputPart = "input" | "options" | "path";
|
|
50
|
+
/**
|
|
51
|
+
* A factory call was refused before anything was sent: its definition rejected the data or the options passed to it,
|
|
52
|
+
* or an untyped call's path is no factory path. `part` says which; a refused call has no record.
|
|
53
|
+
*/
|
|
37
54
|
export declare class FactoryInputError extends Error {
|
|
38
55
|
readonly name = "FactoryInputError";
|
|
39
56
|
readonly path: string;
|
|
57
|
+
readonly part: FactoryInputPart;
|
|
40
58
|
readonly issues: readonly z.core.$ZodIssue[];
|
|
41
|
-
constructor(path: string, message: string, issues?: readonly z.core.$ZodIssue[]);
|
|
59
|
+
constructor(path: string, part: FactoryInputPart, message: string, issues?: readonly z.core.$ZodIssue[]);
|
|
42
60
|
}
|
|
43
61
|
/**
|
|
44
62
|
* A factory answered with a response its definition's output schema rejects: the definition has drifted from
|
|
@@ -53,14 +71,17 @@ export declare class FactoryOutputError extends Error {
|
|
|
53
71
|
constructor(definition: AnyFactoryDefinition, issues: readonly z.core.$ZodIssue[], response: unknown);
|
|
54
72
|
}
|
|
55
73
|
/**
|
|
56
|
-
* Builds one entity through `definition`: checks `data` against its input schema
|
|
57
|
-
*
|
|
58
|
-
*
|
|
74
|
+
* Builds one entity through `definition`: checks `data` against its input schema and `options`, when given, against
|
|
75
|
+
* its options schema, when it has one, sends the parsed values, and returns the response parsed by its output
|
|
76
|
+
* schema. A definition with no options schema sends `options` unchecked. Throws a `FactoryInputError` before sending
|
|
77
|
+
* (`part` `input` or `options`), a `TestserverCallError` when the call fails, and a `FactoryOutputError` when the
|
|
78
|
+
* response doesn't match the definition.
|
|
59
79
|
*/
|
|
60
|
-
export declare function buildFactory<D extends AnyFactoryDefinition>(context: FactoryContext, target: FactoryTarget, definition: D, data: FactoryInput<D>, options?:
|
|
80
|
+
export declare function buildFactory<D extends AnyFactoryDefinition>(context: FactoryContext, target: FactoryTarget, definition: D, data: FactoryInput<D>, options?: FactoryOptionsOf<D>): Promise<FactoryOutput<D>>;
|
|
61
81
|
/**
|
|
62
82
|
* Builds one entity through the factory at `path` (such as `tokens/tokens`) with no definition, returning the
|
|
63
|
-
* response unchecked: for reaching a factory before its definition exists
|
|
64
|
-
*
|
|
83
|
+
* response unchecked: for reaching a factory before its definition exists, or one of an external service's factories
|
|
84
|
+
* (a target with an `externalId`). Throws a `FactoryInputError` (`part` `path`) for a malformed path before sending,
|
|
85
|
+
* and a `TestserverCallError` when the call fails or its answer isn't JSON.
|
|
65
86
|
*/
|
|
66
87
|
export declare function buildUntypedFactory(context: FactoryContext, target: FactoryTarget, path: string, data: unknown, options?: FactoryOptions): Promise<unknown>;
|