okengine 0.2.6 → 0.2.8
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/AGENTS.md +24 -23
- package/README.md +52 -346
- package/docs/spec/console.md +165 -142
- package/docs/spec/example.md +490 -312
- package/docs/spec/four-applications.md +495 -314
- package/docs/spec/unified-theory.md +184 -175
- package/package.json +45 -37
- package/spec/manifest.v1.schema.json +40 -9
- package/src/auth/api-keys.ts +2 -5
- package/src/auth/attenuation.ts +2 -6
- package/src/auth/auth.test.ts +53 -31
- package/src/auth/invoke-as.ts +1 -3
- package/src/auth/operator.ts +8 -26
- package/src/auth/planes.ts +2 -7
- package/src/auth/plugin.ts +4 -7
- package/src/auth/roles.ts +1 -5
- package/src/auth/sessions.ts +10 -39
- package/src/cli/args.ts +1 -5
- package/src/cli/ask-dev-mode.ts +40 -0
- package/src/cli/build.ts +1 -2
- package/src/cli/client-add.test.ts +8 -15
- package/src/cli/client-add.ts +5 -14
- package/src/cli/completion.test.ts +1 -5
- package/src/cli/completion.ts +4 -17
- package/src/cli/db-auto-push.test.ts +64 -0
- package/src/cli/db-auto-push.ts +72 -0
- package/src/cli/db.test.ts +189 -0
- package/src/cli/db.ts +386 -0
- package/src/cli/dev-app-runner.ts +2 -8
- package/src/cli/dev-db-push.test.ts +163 -0
- package/src/cli/dev-mode.test.ts +45 -0
- package/src/cli/dev-mode.ts +78 -0
- package/src/cli/dev.test.ts +148 -21
- package/src/cli/dev.ts +208 -134
- package/src/cli/doc-drift.test.ts +3 -2
- package/src/cli/doc-drift.ts +21 -50
- package/src/cli/doc-staleness.test.ts +69 -0
- package/src/cli/docker-cli.test.ts +7 -8
- package/src/cli/docker.ts +1 -3
- package/src/cli/doctor-diff-examples.ts +1 -3
- package/src/cli/doctor-diff.test.ts +1 -5
- package/src/cli/doctor-diff.ts +17 -46
- package/src/cli/doctor-pii.ts +2 -7
- package/src/cli/doctor.test.ts +26 -4
- package/src/cli/doctor.ts +35 -11
- package/src/cli/eval.ts +4 -14
- package/src/cli/gates-list.ts +1 -4
- package/src/cli/hero-meta.test.ts +17 -19
- package/src/cli/hero-meta.ts +20 -30
- package/src/cli/images.ts +3 -8
- package/src/cli/index.ts +11 -2
- package/src/cli/load-config.images.test.ts +14 -14
- package/src/cli/load-config.ts +41 -47
- package/src/cli/mcp-from-console.ts +1 -4
- package/src/cli/mode.ts +45 -0
- package/src/cli/ports.test.ts +4 -13
- package/src/cli/ports.ts +1 -3
- package/src/cli/privacy-erase.ts +1 -3
- package/src/cli/registry.ts +75 -25
- package/src/cli/schema.ts +3 -10
- package/src/cli/stack.ts +2 -7
- package/src/cli/start.ts +4 -15
- package/src/cli/upgrade.ts +1 -4
- package/src/client/budget-entry.ts +1 -6
- package/src/client/create.test.ts +6 -12
- package/src/client/create.ts +2 -8
- package/src/client/errors.ts +1 -4
- package/src/client/index.ts +1 -6
- package/src/client/notes-contract.test.ts +4 -13
- package/src/client/transport.ts +9 -30
- package/src/client/types.ts +8 -29
- package/src/compiler/aot.test.ts +2 -9
- package/src/compiler/aot.ts +1 -4
- package/src/compiler/differential.test.ts +3 -11
- package/src/compiler/dynamic.ts +1 -4
- package/src/compiler/effects-infer.ts +8 -34
- package/src/compiler/emit.ts +1 -3
- package/src/compiler/extract.test.ts +96 -30
- package/src/compiler/extract.ts +362 -156
- package/src/compiler/fixtures/skyport/oke.config.ts +1 -1
- package/src/compiler/fixtures/skyport/src/flows/bookings/index.ts +7 -3
- package/src/compiler/fixtures/skyport/src/flows/payments/index.ts +1 -3
- package/src/compiler/fixtures/skyport/src/flows/support/index.ts +4 -1
- package/src/compiler/fixtures/skyport.expected.json +24 -83
- package/src/compiler/fixtures/triggers/five-triggers.ts +1 -2
- package/src/compiler/http-parse.ts +2 -9
- package/src/compiler/index.ts +1 -5
- package/src/compiler/response.ts +4 -7
- package/src/compiler/sucrose.ts +11 -31
- package/src/config/define-config.test.ts +57 -34
- package/src/config/index.ts +181 -37
- package/src/config/resolve-driver.test.ts +28 -17
- package/src/console/budget.test.ts +1 -4
- package/src/console/index.ts +1 -4
- package/src/console/server/access.test.ts +15 -43
- package/src/console/server/access.ts +19 -49
- package/src/console/server/ai.test.ts +3 -11
- package/src/console/server/ai.ts +23 -46
- package/src/console/server/app.ts +14 -45
- package/src/console/server/auth-rate.test.ts +4 -12
- package/src/console/server/bind.ts +1 -5
- package/src/console/server/channels.test.ts +2 -6
- package/src/console/server/channels.ts +10 -35
- package/src/console/server/claim.ts +2 -8
- package/src/console/server/clock.test.ts +2 -6
- package/src/console/server/clock.ts +8 -26
- package/src/console/server/console.test.ts +1 -3
- package/src/console/server/diff.test.ts +5 -17
- package/src/console/server/diff.ts +10 -31
- package/src/console/server/dry-run.audit.test.ts +2 -8
- package/src/console/server/flows.ts +64 -233
- package/src/console/server/gates.test.ts +14 -50
- package/src/console/server/gates.ts +13 -48
- package/src/console/server/index.ts +2 -9
- package/src/console/server/live.ts +3 -12
- package/src/console/server/operator-db.test.ts +4 -15
- package/src/console/server/operator-db.ts +13 -32
- package/src/console/server/plugin.ts +50 -53
- package/src/console/server/plugins.test.ts +2 -6
- package/src/console/server/plugins.ts +17 -56
- package/src/console/server/runs-pii.ts +2 -7
- package/src/console/server/security.gate.test.ts +18 -40
- package/src/console/server/serve.ts +10 -25
- package/src/console/server/signals.test.ts +1 -3
- package/src/console/server/signals.ts +17 -40
- package/src/console/server/state.ts +21 -59
- package/src/console/server/store.test.ts +20 -22
- package/src/console/server/store.ts +31 -76
- package/src/console/server/vault.test.ts +12 -29
- package/src/console/server/vault.ts +23 -60
- package/src/console/ui/access/AccessA11yView.tsx +6 -21
- package/src/console/ui/access/a11y.test.tsx +3 -12
- package/src/console/ui/access/acknowledgement.test.ts +1 -4
- package/src/console/ui/access/acknowledgement.ts +1 -3
- package/src/console/ui/access/blast-radius.ts +1 -3
- package/src/console/ui/access/confirmation.test.ts +1 -5
- package/src/console/ui/access/confirmation.ts +1 -4
- package/src/console/ui/access/fixture.ts +1 -5
- package/src/console/ui/access/grantable.test.ts +1 -3
- package/src/console/ui/access/grantable.ts +2 -7
- package/src/console/ui/access/index.ts +2 -9
- package/src/console/ui/access/provenance.test.ts +1 -3
- package/src/console/ui/access/provenance.ts +2 -6
- package/src/console/ui/access/search.test.ts +1 -5
- package/src/console/ui/access/search.ts +2 -6
- package/src/console/ui/ai/AiA11yView.tsx +6 -17
- package/src/console/ui/ai/a11y.test.tsx +2 -5
- package/src/console/ui/ai/fixture.ts +2 -7
- package/src/console/ui/ai/format.ts +1 -3
- package/src/console/ui/ai/group.test.ts +1 -3
- package/src/console/ui/ai/group.ts +4 -12
- package/src/console/ui/ai/index.ts +2 -9
- package/src/console/ui/ai/promotion.test.ts +2 -7
- package/src/console/ui/ai/promotion.ts +4 -13
- package/src/console/ui/ai/search.test.ts +2 -11
- package/src/console/ui/ai/search.ts +3 -13
- package/src/console/ui/ai/types.ts +1 -8
- package/src/console/ui/architecture/ArchitectureA11yView.tsx +8 -29
- package/src/console/ui/architecture/a11y.test.tsx +1 -2
- package/src/console/ui/architecture/declared.ts +1 -5
- package/src/console/ui/architecture/index.ts +7 -35
- package/src/console/ui/architecture/layout.ts +1 -3
- package/src/console/ui/architecture/pathologies.ts +10 -19
- package/src/console/ui/architecture/search.ts +6 -15
- package/src/console/ui/architecture/traffic.ts +4 -14
- package/src/console/ui/architecture/types.ts +2 -10
- package/src/console/ui/architecture/view.test.ts +7 -19
- package/src/console/ui/architecture/view.ts +9 -36
- package/src/console/ui/channels/ChannelsA11yView.tsx +4 -13
- package/src/console/ui/channels/a11y.test.tsx +1 -2
- package/src/console/ui/channels/confirmation.test.ts +1 -4
- package/src/console/ui/channels/confirmation.ts +1 -4
- package/src/console/ui/channels/findings.ts +1 -5
- package/src/console/ui/channels/index.ts +2 -8
- package/src/console/ui/channels/locale.test.ts +1 -3
- package/src/console/ui/channels/locale.ts +2 -8
- package/src/console/ui/channels/search.ts +4 -13
- package/src/console/ui/channels/taxonomy.ts +1 -3
- package/src/console/ui/clock/ClockA11yView.tsx +9 -26
- package/src/console/ui/clock/a11y.test.tsx +2 -5
- package/src/console/ui/clock/confirmation.test.ts +1 -3
- package/src/console/ui/clock/confirmation.ts +1 -4
- package/src/console/ui/clock/findings.ts +1 -4
- package/src/console/ui/clock/health.ts +2 -7
- package/src/console/ui/clock/index.ts +2 -10
- package/src/console/ui/clock/search.test.ts +1 -3
- package/src/console/ui/clock/search.ts +2 -6
- package/src/console/ui/clock/timeline.test.ts +1 -3
- package/src/console/ui/clock/waiting-on.test.ts +1 -5
- package/src/console/ui/clock/waiting-on.ts +2 -7
- package/src/console/ui/diff/DiffA11yView.tsx +8 -17
- package/src/console/ui/diff/a11y.test.tsx +2 -5
- package/src/console/ui/diff/group.test.ts +3 -13
- package/src/console/ui/diff/group.ts +2 -8
- package/src/console/ui/diff/index.ts +2 -8
- package/src/console/ui/diff/search.test.ts +1 -5
- package/src/console/ui/diff/search.ts +4 -16
- package/src/console/ui/diff/summary.ts +1 -2
- package/src/console/ui/dist/assets/{index-Dy4jht9P.js → index-BWo8R7NR.js} +2 -2
- package/src/console/ui/dist/assets/{panel-access-Dd37LU2c.js → panel-access-C0J2D-a2.js} +1 -1
- package/src/console/ui/dist/assets/{panel-ai-CC7LR6-J.js → panel-ai-D_m6WQI8.js} +1 -1
- package/src/console/ui/dist/assets/{panel-architecture-B5b3iKCz.js → panel-architecture-CKnXFyUx.js} +1 -1
- package/src/console/ui/dist/assets/{panel-channels-CeNjTKXp.js → panel-channels-BOmQ-onL.js} +1 -1
- package/src/console/ui/dist/assets/{panel-clock-DgFTLoHV.js → panel-clock-giAq0Ccv.js} +1 -1
- package/src/console/ui/dist/assets/{panel-diff-DxehccqB.js → panel-diff-cdonmH8c.js} +1 -1
- package/src/console/ui/dist/assets/{panel-flows-BtrVn-Eg.js → panel-flows-DlCU5zjA.js} +2 -2
- package/src/console/ui/dist/assets/{panel-gates-Z9MKRGdH.js → panel-gates-XclZxWD5.js} +1 -1
- package/src/console/ui/dist/assets/{panel-overview-Dt_AeXgd.js → panel-overview-BznEOTnb.js} +1 -1
- package/src/console/ui/dist/assets/{panel-plugins-DWd0TowH.js → panel-plugins-CcGM1g64.js} +1 -1
- package/src/console/ui/dist/assets/{panel-runs-DGstFHeq.js → panel-runs-CGWNHLR4.js} +1 -1
- package/src/console/ui/dist/assets/{panel-signals-DzEa2Fnt.js → panel-signals-CNywkdak.js} +1 -1
- package/src/console/ui/dist/assets/{panel-store-BJkbNgxx.js → panel-store-KmTbFHMH.js} +1 -1
- package/src/console/ui/dist/assets/{panel-traces-BaRVO3gM.js → panel-traces-DBLx2ilD.js} +1 -1
- package/src/console/ui/dist/assets/panel-vault-CEnFc0dk.js +1 -0
- package/src/console/ui/dist/index.html +1 -1
- package/src/console/ui/flows/FlowsA11yView.tsx +7 -22
- package/src/console/ui/flows/a11y.test.tsx +2 -8
- package/src/console/ui/flows/buffer.test.ts +3 -11
- package/src/console/ui/flows/buffer.ts +4 -11
- package/src/console/ui/flows/confirmation.ts +1 -3
- package/src/console/ui/flows/contract.test.ts +3 -7
- package/src/console/ui/flows/contract.ts +12 -36
- package/src/console/ui/flows/graph.test.ts +3 -11
- package/src/console/ui/flows/graph.ts +5 -15
- package/src/console/ui/flows/index.ts +1 -6
- package/src/console/ui/flows/save-as-test.ts +1 -3
- package/src/console/ui/flows/search.ts +8 -25
- package/src/console/ui/flows/tiers.ts +2 -9
- package/src/console/ui/gates/GatesA11yView.tsx +4 -13
- package/src/console/ui/gates/a11y.test.tsx +2 -5
- package/src/console/ui/gates/audit.ts +1 -3
- package/src/console/ui/gates/denial.test.ts +1 -3
- package/src/console/ui/gates/denial.ts +4 -12
- package/src/console/ui/gates/findings.ts +1 -3
- package/src/console/ui/gates/group.test.ts +3 -3
- package/src/console/ui/gates/group.ts +3 -11
- package/src/console/ui/gates/index.ts +2 -10
- package/src/console/ui/gates/search.ts +3 -10
- package/src/console/ui/overview/OverviewA11yView.tsx +9 -27
- package/src/console/ui/overview/a11y.test.tsx +1 -2
- package/src/console/ui/overview/busiest.ts +1 -3
- package/src/console/ui/overview/compose.ts +1 -13
- package/src/console/ui/overview/cost.ts +34 -38
- package/src/console/ui/overview/fixture.ts +21 -26
- package/src/console/ui/overview/golden.ts +4 -14
- package/src/console/ui/overview/index.ts +2 -9
- package/src/console/ui/overview/rank.test.ts +3 -10
- package/src/console/ui/overview/rank.ts +2 -7
- package/src/console/ui/overview/slo.test.ts +5 -9
- package/src/console/ui/overview/slo.ts +6 -23
- package/src/console/ui/overview/verdict.ts +3 -10
- package/src/console/ui/plugins/PluginsA11yView.tsx +8 -18
- package/src/console/ui/plugins/a11y.test.tsx +1 -2
- package/src/console/ui/plugins/fixture.ts +2 -4
- package/src/console/ui/plugins/group.test.ts +1 -3
- package/src/console/ui/plugins/group.ts +1 -6
- package/src/console/ui/plugins/index.ts +3 -13
- package/src/console/ui/plugins/search.ts +7 -19
- package/src/console/ui/runs/RunsA11yView.tsx +5 -20
- package/src/console/ui/runs/a11y.test.tsx +2 -5
- package/src/console/ui/runs/explain.ts +2 -6
- package/src/console/ui/runs/group.ts +3 -12
- package/src/console/ui/runs/histogram.test.ts +2 -11
- package/src/console/ui/runs/histogram.ts +1 -4
- package/src/console/ui/runs/index.ts +4 -18
- package/src/console/ui/runs/project.ts +2 -6
- package/src/console/ui/runs/query.test.ts +1 -3
- package/src/console/ui/runs/query.ts +12 -35
- package/src/console/ui/runs/search.ts +5 -19
- package/src/console/ui/runs/trace-link.test.ts +2 -6
- package/src/console/ui/runs/trace-link.ts +4 -16
- package/src/console/ui/runs/types.ts +1 -3
- package/src/console/ui/shell/App.tsx +2 -10
- package/src/console/ui/shell/client.ts +22 -115
- package/src/console/ui/shell/components/ui.tsx +1 -4
- package/src/console/ui/shell/layout/Shell.tsx +2 -4
- package/src/console/ui/shell/main.tsx +31 -96
- package/src/console/ui/shell/panels/access/AccessPanel.tsx +34 -98
- package/src/console/ui/shell/panels/ai/AiPanel.tsx +35 -106
- package/src/console/ui/shell/panels/architecture/ArchitecturePanel.tsx +18 -66
- package/src/console/ui/shell/panels/channels/ChannelsPanel.tsx +20 -57
- package/src/console/ui/shell/panels/clock/ClockPanel.tsx +22 -54
- package/src/console/ui/shell/panels/diff/DiffPanel.tsx +20 -61
- package/src/console/ui/shell/panels/flows/ContractEditor.tsx +6 -23
- package/src/console/ui/shell/panels/flows/FlowDrawer.tsx +13 -28
- package/src/console/ui/shell/panels/flows/FlowsPanel.tsx +9 -29
- package/src/console/ui/shell/panels/gates/GatesPanel.tsx +24 -80
- package/src/console/ui/shell/panels/overview/OverviewPanel.tsx +20 -58
- package/src/console/ui/shell/panels/plugins/PluginsPanel.tsx +16 -41
- package/src/console/ui/shell/panels/runs/RunsPanel.tsx +31 -99
- package/src/console/ui/shell/panels/signals/SignalsPanel.tsx +38 -101
- package/src/console/ui/shell/panels/store/StorePanel.tsx +27 -66
- package/src/console/ui/shell/panels/traces/TracesPanel.tsx +28 -89
- package/src/console/ui/shell/panels/vault/VaultPanel.tsx +22 -53
- package/src/console/ui/shell/setup/Wizard.tsx +3 -5
- package/src/console/ui/shell/styles.css +1 -2
- package/src/console/ui/signals/SignalsA11yView.tsx +9 -33
- package/src/console/ui/signals/a11y.test.tsx +2 -5
- package/src/console/ui/signals/confirmation.test.ts +1 -5
- package/src/console/ui/signals/confirmation.ts +2 -6
- package/src/console/ui/signals/dry-run.ts +1 -3
- package/src/console/ui/signals/durable.ts +1 -3
- package/src/console/ui/signals/findings.ts +1 -3
- package/src/console/ui/signals/group.test.ts +2 -8
- package/src/console/ui/signals/group.ts +2 -10
- package/src/console/ui/signals/index.ts +1 -4
- package/src/console/ui/signals/monitor.ts +2 -7
- package/src/console/ui/signals/schema-form.test.ts +3 -14
- package/src/console/ui/signals/schema-form.ts +1 -4
- package/src/console/ui/signals/search.ts +4 -13
- package/src/console/ui/store/StoreA11yView.tsx +3 -9
- package/src/console/ui/store/a11y.test.tsx +2 -5
- package/src/console/ui/store/confirmation.test.ts +1 -3
- package/src/console/ui/store/confirmation.ts +1 -4
- package/src/console/ui/store/dry-run.ts +2 -5
- package/src/console/ui/store/fixture.ts +1 -2
- package/src/console/ui/store/group.test.ts +1 -6
- package/src/console/ui/store/group.ts +1 -4
- package/src/console/ui/store/index.ts +1 -5
- package/src/console/ui/store/search.ts +2 -6
- package/src/console/ui/store/will-not-fire.ts +1 -2
- package/src/console/ui/traces/TracesA11yView.tsx +10 -29
- package/src/console/ui/traces/a11y.test.tsx +1 -2
- package/src/console/ui/traces/chain.test.ts +5 -19
- package/src/console/ui/traces/chain.ts +1 -3
- package/src/console/ui/traces/critical-path.test.ts +1 -3
- package/src/console/ui/traces/critical-path.ts +2 -6
- package/src/console/ui/traces/filter.test.ts +2 -6
- package/src/console/ui/traces/filter.ts +5 -13
- package/src/console/ui/traces/fold.test.ts +4 -12
- package/src/console/ui/traces/fold.ts +1 -3
- package/src/console/ui/traces/mini.ts +1 -3
- package/src/console/ui/traces/replay.test.ts +1 -3
- package/src/console/ui/traces/replay.ts +1 -3
- package/src/console/ui/traces/sampling.ts +1 -4
- package/src/console/ui/traces/search.ts +4 -17
- package/src/console/ui/traces/tier.ts +1 -3
- package/src/console/ui/vault/VaultA11yView.tsx +5 -17
- package/src/console/ui/vault/a11y.test.tsx +1 -2
- package/src/console/ui/vault/blast-radius.ts +1 -3
- package/src/console/ui/vault/confirmation.test.ts +1 -5
- package/src/console/ui/vault/confirmation.ts +1 -4
- package/src/console/ui/vault/dormant.test.ts +1 -4
- package/src/console/ui/vault/export-safe.test.ts +1 -5
- package/src/console/ui/vault/export-safe.ts +1 -4
- package/src/console/ui/vault/fixture.ts +3 -3
- package/src/console/ui/vault/group.ts +1 -2
- package/src/console/ui/vault/index.ts +2 -10
- package/src/console/ui/vault/search.ts +2 -6
- package/src/console/ui/vault/types.ts +1 -1
- package/src/console/xss.gate.test.ts +1 -3
- package/src/docker/compose.ts +112 -20
- package/src/docker/derive.ts +5 -19
- package/src/docker/docker.test.ts +15 -15
- package/src/docker/dockerfile.integration.test.ts +12 -21
- package/src/docker/helpers.ts +5 -4
- package/src/docker/index.ts +4 -11
- package/src/docker/pin.ts +1 -9
- package/src/docker/recipes/index.ts +5 -6
- package/src/docker/recipes/mailpit.ts +22 -0
- package/src/docker/recipes/postgres.ts +17 -6
- package/src/docker/recipes/redis.ts +6 -1
- package/src/docker/recipes/rustfs.ts +33 -0
- package/src/docker/stack-id.test.ts +33 -0
- package/src/docker/stack-id.ts +25 -13
- package/src/docker/stack.integration.test.ts +6 -21
- package/src/docker/types.ts +13 -4
- package/src/drivers/ai-anthropic.ts +5 -14
- package/src/drivers/ai-mock.ts +2 -5
- package/src/drivers/ai-openai-compatible.ts +4 -10
- package/src/drivers/ai-providers.test.ts +6 -13
- package/src/drivers/bun-native-completeness.test.ts +6 -15
- package/src/drivers/channel-console.ts +6 -7
- package/src/drivers/channel-fcm.ts +20 -30
- package/src/drivers/channel-resend.ts +1 -3
- package/src/drivers/channel-smtp.ts +2 -6
- package/src/drivers/channel-types.ts +2 -12
- package/src/drivers/channel-unifonic.ts +2 -6
- package/src/drivers/channel-wa-cloud.ts +2 -6
- package/src/drivers/channel-webpush.ts +21 -60
- package/src/drivers/conformance.test.ts +2 -10
- package/src/drivers/conformance.ts +8 -21
- package/src/drivers/fs.ts +2 -8
- package/src/drivers/index.ts +12 -56
- package/src/drivers/memory.ts +14 -41
- package/src/drivers/pgvector.ts +7 -11
- package/src/drivers/postgres.ts +7 -13
- package/src/drivers/redis.ts +13 -37
- package/src/drivers/s3.ts +5 -17
- package/src/drivers/signal-engine.ts +12 -49
- package/src/drivers/signal-memory.ts +2 -8
- package/src/drivers/signal-nats.ts +4 -9
- package/src/drivers/signal-postgres.ts +62 -129
- package/src/drivers/signal-redis.ts +7 -21
- package/src/drivers/signal-types.ts +1 -4
- package/src/drivers/sqlite.ts +3 -12
- package/src/drivers/types.ts +4 -23
- package/src/drivers/vault-env.ts +2 -6
- package/src/drivers/vault-infisical.ts +1 -5
- package/src/drivers/vault-managed.ts +1 -5
- package/src/drivers/vault-memory.ts +1 -5
- package/src/drivers/vault-openbao.ts +1 -5
- package/src/drivers/vault-sops.ts +10 -35
- package/src/drivers/vault-types.ts +1 -7
- package/src/elements/ai/declare.ts +4 -14
- package/src/elements/ai/eval.ts +2 -6
- package/src/elements/ai/pii.ts +1 -3
- package/src/elements/ai/runtime.ts +12 -50
- package/src/elements/ai/schema.ts +4 -15
- package/src/elements/ai.test.ts +13 -24
- package/src/elements/ai.ts +1 -5
- package/src/elements/channel/consent.ts +3 -12
- package/src/elements/channel/costs.ts +4 -15
- package/src/elements/channel/declare.ts +1 -4
- package/src/elements/channel/email-auth.ts +1 -4
- package/src/elements/channel/locale.ts +2 -10
- package/src/elements/channel/mask.ts +1 -3
- package/src/elements/channel/mime.ts +2 -12
- package/src/elements/channel/outcomes.test.ts +1 -5
- package/src/elements/channel/outcomes.ts +5 -15
- package/src/elements/channel/receipts.ts +2 -7
- package/src/elements/channel/runtime.ts +28 -74
- package/src/elements/channel/suppression.ts +8 -14
- package/src/elements/channel.test.ts +8 -31
- package/src/elements/channel.ts +3 -14
- package/src/elements/clock/actions.ts +6 -18
- package/src/elements/clock/declare.ts +1 -3
- package/src/elements/clock/dst.ts +1 -5
- package/src/elements/clock/durable.ts +4 -16
- package/src/elements/clock/health.ts +2 -7
- package/src/elements/clock/leader.ts +2 -9
- package/src/elements/clock/reconcile.ts +4 -15
- package/src/elements/clock/runtime.ts +2 -5
- package/src/elements/clock/schedule.ts +4 -20
- package/src/elements/clock.test.ts +2 -7
- package/src/elements/clock.ts +5 -23
- package/src/elements/gate/permissions.ts +1 -4
- package/src/elements/gate/runtime.ts +7 -28
- package/src/elements/gate.ts +1 -5
- package/src/elements/index.ts +9 -7
- package/src/elements/signal/declare.ts +2 -7
- package/src/elements/signal/reconcile.test.ts +1 -4
- package/src/elements/signal/runtime.ts +1 -3
- package/src/elements/signal.test.ts +3 -15
- package/src/elements/signal.ts +2 -8
- package/src/elements/store/cache.test.ts +46 -0
- package/src/elements/store/cache.ts +3 -11
- package/src/elements/store/classify.ts +5 -22
- package/src/elements/store/declare.ts +8 -17
- package/src/elements/store/domain-ddl.test.ts +86 -0
- package/src/elements/store/emit-drizzle.ts +363 -0
- package/src/elements/store/files-policy.test.ts +1 -5
- package/src/elements/store/files-policy.ts +4 -12
- package/src/elements/store/load-plugin-tables.ts +103 -0
- package/src/elements/store/missing-relation.test.ts +83 -0
- package/src/elements/store/missing-relation.ts +38 -0
- package/src/elements/store/replica.ts +1 -4
- package/src/elements/store/runtime.ts +25 -28
- package/src/elements/store/schema-decl.test.ts +227 -0
- package/src/elements/store/schema-decl.ts +516 -0
- package/src/elements/store/sql-condition.ts +11 -21
- package/src/elements/store/sql-session.test.ts +50 -0
- package/src/elements/store/sql-session.ts +60 -63
- package/src/elements/store/table.ts +35 -19
- package/src/elements/store.test.ts +17 -39
- package/src/elements/store.ts +37 -31
- package/src/elements/vault/chain.ts +34 -0
- package/src/elements/vault/declare.ts +22 -32
- package/src/elements/vault/fingerprint.ts +2 -7
- package/src/elements/vault/redact.ts +2 -6
- package/src/elements/vault/runtime.ts +18 -32
- package/src/elements/vault.test.ts +12 -28
- package/src/elements/vault.ts +8 -12
- package/src/index.ts +5 -2
- package/src/kernel/adopt-routes.ts +15 -29
- package/src/kernel/app.ts +34 -94
- package/src/kernel/auth-resolve.ts +2 -9
- package/src/kernel/boot-bind/ai.ts +1 -4
- package/src/kernel/boot-bind/channel.ts +2 -8
- package/src/kernel/boot-bind/clock.ts +2 -6
- package/src/kernel/boot-bind/gate.ts +2 -8
- package/src/kernel/boot-bind/runs.ts +1 -3
- package/src/kernel/boot-bind/signal.ts +3 -10
- package/src/kernel/boot-bind/store.test.ts +17 -17
- package/src/kernel/boot-bind/store.ts +44 -50
- package/src/kernel/boot-bind/vault.ts +2 -8
- package/src/kernel/boot.test.ts +4 -9
- package/src/kernel/boot.ts +29 -76
- package/src/kernel/budget.test.ts +1 -3
- package/src/kernel/capability.ts +3 -10
- package/src/kernel/dry-run.test.ts +1 -4
- package/src/kernel/dry-run.ts +3 -11
- package/src/kernel/effects.test.ts +1 -5
- package/src/kernel/effects.ts +4 -11
- package/src/kernel/errors.registry.test.ts +2 -8
- package/src/kernel/errors.ts +23 -32
- package/src/kernel/flow.test.ts +12 -25
- package/src/kernel/flow.ts +5 -25
- package/src/kernel/fx.test.ts +15 -44
- package/src/kernel/fx.ts +27 -79
- package/src/kernel/hook-timing.test.ts +3 -6
- package/src/kernel/hook-timing.ts +5 -14
- package/src/kernel/hooks.test.ts +10 -10
- package/src/kernel/hooks.ts +3 -12
- package/src/kernel/index.ts +4 -17
- package/src/kernel/journal.ts +7 -31
- package/src/kernel/on.ts +1 -6
- package/src/kernel/pipeline.test.ts +10 -19
- package/src/kernel/pipeline.ts +5 -17
- package/src/kernel/plug.ts +4 -11
- package/src/kernel/plugin/conflicts.test.ts +13 -25
- package/src/kernel/plugin/decorate.test.ts +8 -13
- package/src/kernel/plugin/scoping.test.ts +4 -11
- package/src/kernel/plugin.ts +48 -24
- package/src/kernel/registry.ts +80 -29
- package/src/kernel/router.test.ts +15 -13
- package/src/kernel/router.ts +9 -29
- package/src/kernel/routing-budget.test.ts +1 -3
- package/src/kernel/run-telemetry.ts +1 -3
- package/src/kernel/triggers.ts +4 -21
- package/src/manifest/diff.test.ts +26 -91
- package/src/manifest/diff.ts +95 -225
- package/src/manifest/index.ts +2 -9
- package/src/manifest/types.ts +29 -5
- package/src/manifest/undeclared.test.ts +4 -12
- package/src/manifest/undeclared.ts +1 -2
- package/src/manifest/validate.test.ts +2 -6
- package/src/manifest/validate.ts +4 -14
- package/src/mcp/authorization.ts +8 -27
- package/src/mcp/confirmation.ts +3 -10
- package/src/mcp/data.ts +2 -6
- package/src/mcp/docs-index.ts +4 -7
- package/src/mcp/docs-mcp.test.ts +3 -12
- package/src/mcp/docs-server.ts +7 -27
- package/src/mcp/docs-tools.ts +2 -6
- package/src/mcp/index.ts +1 -6
- package/src/mcp/injection.gate.test.ts +4 -18
- package/src/mcp/mcp.test.ts +18 -49
- package/src/mcp/protocol.ts +3 -10
- package/src/mcp/server.ts +11 -52
- package/src/mcp/session.ts +4 -14
- package/src/mcp/tools.ts +14 -50
- package/src/plugins/catalogue.test.ts +3 -7
- package/src/plugins/catalogue.ts +1 -3
- package/src/plugins/node-import-scan.ts +2 -5
- package/src/plugins/supply-chain.ts +5 -17
- package/src/release/exports.ts +3 -8
- package/src/release/measure.exports.test.ts +1 -3
- package/src/release/measure.ts +15 -43
- package/src/runs/bench.test.ts +1 -3
- package/src/runs/collect.ts +8 -25
- package/src/runs/drivers/clickhouse.ts +2 -9
- package/src/runs/drivers/files.ts +9 -31
- package/src/runs/drivers/memory.ts +5 -22
- package/src/runs/drivers/postgres.ts +8 -20
- package/src/runs/duckdb.ts +2 -8
- package/src/runs/index.ts +3 -14
- package/src/runs/outlier.ts +3 -10
- package/src/runs/parquet.ts +8 -26
- package/src/runs/privacy.ts +2 -8
- package/src/runs/runs.test.ts +3 -9
- package/src/runs/runtime.ts +7 -32
- package/src/runs/shred.ts +10 -29
- package/src/runs/types.ts +1 -4
- package/src/runtime/bun.ts +4 -15
- package/src/runtime/cold-start.bench.ts +1 -3
- package/src/runtime/dev-request-log.test.ts +1 -4
- package/src/runtime/dev-request-log.ts +1 -4
- package/src/runtime/index.ts +1 -6
- package/src/runtime/primitives.ts +5 -4
- package/src/runtime/security.ts +3 -13
- package/src/runtime/serve.test.ts +4 -7
- package/src/runtime/types.ts +1 -4
- package/src/runtime/web-standard.ts +3 -15
- package/src/term.test.ts +4 -6
- package/src/term.ts +49 -98
- package/src/test/create-test-app.test.ts +4 -14
- package/src/test/create-test-app.ts +13 -31
- package/src/test/provisions.integration.test.ts +3 -11
- package/src/upgrade/codemods.test.ts +25 -6
- package/src/upgrade/codemods.ts +116 -3
- package/src/validation/standard-schema.test.ts +2 -5
- package/src/validation/standard-schema.ts +13 -33
- package/src/console/ui/dist/assets/panel-vault-BbfWdox0.js +0 -1
package/src/cli/ports.test.ts
CHANGED
|
@@ -13,20 +13,12 @@ describe("findFreePort", () => {
|
|
|
13
13
|
|
|
14
14
|
test("increments until free", async () => {
|
|
15
15
|
const busy = new Set([6530, 6531]);
|
|
16
|
-
const port = await findFreePort(
|
|
17
|
-
6530,
|
|
18
|
-
new Set(),
|
|
19
|
-
async (p) => busy.has(p),
|
|
20
|
-
);
|
|
16
|
+
const port = await findFreePort(6530, new Set(), async (p) => busy.has(p));
|
|
21
17
|
expect(port).toBe(6532);
|
|
22
18
|
});
|
|
23
19
|
|
|
24
20
|
test("skips occupied set even when probe says free", async () => {
|
|
25
|
-
const port = await findFreePort(
|
|
26
|
-
6530,
|
|
27
|
-
new Set([6530, 6531]),
|
|
28
|
-
async () => false,
|
|
29
|
-
);
|
|
21
|
+
const port = await findFreePort(6530, new Set([6530, 6531]), async () => false);
|
|
30
22
|
expect(port).toBe(6532);
|
|
31
23
|
});
|
|
32
24
|
|
|
@@ -39,9 +31,8 @@ describe("resolveDevPorts", () => {
|
|
|
39
31
|
test("keeps app · console · mcp distinct when preferred collide", async () => {
|
|
40
32
|
// Everything busy except 6531, 6534, 6536 — force increments.
|
|
41
33
|
const busy = new Set([6530, 6533, 6535]);
|
|
42
|
-
const ports = await resolveDevPorts(
|
|
43
|
-
|
|
44
|
-
async (p) => busy.has(p),
|
|
34
|
+
const ports = await resolveDevPorts({ app: 6530, console: 6533, mcp: 6535 }, async (p) =>
|
|
35
|
+
busy.has(p),
|
|
45
36
|
);
|
|
46
37
|
expect(ports.app).toBe(6531);
|
|
47
38
|
expect(ports.console).toBe(6534);
|
package/src/cli/ports.ts
CHANGED
|
@@ -48,9 +48,7 @@ export async function findFreePort(
|
|
|
48
48
|
if (occupied.has(port)) continue;
|
|
49
49
|
if (!(await probe(port))) return port;
|
|
50
50
|
}
|
|
51
|
-
throw new Error(
|
|
52
|
-
`oke: no free port near ${preferred} after ${MAX_PORT_ATTEMPTS} attempts`,
|
|
53
|
-
);
|
|
51
|
+
throw new Error(`oke: no free port near ${preferred} after ${MAX_PORT_ATTEMPTS} attempts`);
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
/**
|
package/src/cli/privacy-erase.ts
CHANGED
|
@@ -24,9 +24,7 @@ export interface RunPrivacyEraseOptions {
|
|
|
24
24
|
*
|
|
25
25
|
* @param options - Subject + vault
|
|
26
26
|
*/
|
|
27
|
-
export function runPrivacyErase(
|
|
28
|
-
options: RunPrivacyEraseOptions,
|
|
29
|
-
): PrivacyEraseResult {
|
|
27
|
+
export function runPrivacyErase(options: RunPrivacyEraseOptions): PrivacyEraseResult {
|
|
30
28
|
const keys = options.subjectKeys ?? createMemorySubjectKeys();
|
|
31
29
|
return privacyErase({
|
|
32
30
|
subjectId: options.subjectId,
|
package/src/cli/registry.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
/** One CLI flag (long form is canonical; short is convenience only). */
|
|
8
8
|
export interface CliFlag {
|
|
9
|
-
/** Canonical long form including leading dashes (e.g. `--
|
|
9
|
+
/** Canonical long form including leading dashes (e.g. `--docker`). */
|
|
10
10
|
readonly long: string;
|
|
11
11
|
/** Optional short form including leading dash (e.g. `-s`). */
|
|
12
12
|
readonly short?: string;
|
|
@@ -97,16 +97,31 @@ export const OKE_COMMANDS: readonly CliCommand[] = [
|
|
|
97
97
|
leaf: true,
|
|
98
98
|
flags: [
|
|
99
99
|
{
|
|
100
|
-
long: "--
|
|
101
|
-
short: "-
|
|
100
|
+
long: "--local",
|
|
101
|
+
short: "-l",
|
|
102
|
+
summary: "Session-only local mode (in-memory; no compose)",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
long: "--docker",
|
|
106
|
+
short: "-d",
|
|
102
107
|
takesValue: true,
|
|
103
108
|
valueName: "roles",
|
|
104
|
-
summary: "
|
|
109
|
+
summary: "Session-only docker compose (optional role list)",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
long: "--no-db-push",
|
|
113
|
+
summary: "Disable auto `oke db push` on schema change (local)",
|
|
105
114
|
},
|
|
106
115
|
ENTRY,
|
|
107
116
|
HELP,
|
|
108
117
|
],
|
|
109
118
|
},
|
|
119
|
+
{
|
|
120
|
+
name: "mode",
|
|
121
|
+
summary: "get/set default oke dev mode (local|docker)",
|
|
122
|
+
leaf: true,
|
|
123
|
+
flags: [HELP],
|
|
124
|
+
},
|
|
110
125
|
{
|
|
111
126
|
name: "start",
|
|
112
127
|
summary: "production entry (Docker CMD)",
|
|
@@ -125,7 +140,7 @@ export const OKE_COMMANDS: readonly CliCommand[] = [
|
|
|
125
140
|
},
|
|
126
141
|
{
|
|
127
142
|
name: "doctor",
|
|
128
|
-
summary: "secrets · ports · schema drift",
|
|
143
|
+
summary: "secrets · ports · stub/domain schema drift",
|
|
129
144
|
leaf: true,
|
|
130
145
|
flags: [
|
|
131
146
|
MANIFEST,
|
|
@@ -185,6 +200,54 @@ export const OKE_COMMANDS: readonly CliCommand[] = [
|
|
|
185
200
|
},
|
|
186
201
|
],
|
|
187
202
|
},
|
|
203
|
+
{
|
|
204
|
+
name: "db",
|
|
205
|
+
summary: "domain schema — push · generate · migrate",
|
|
206
|
+
subcommands: [
|
|
207
|
+
{
|
|
208
|
+
name: "push",
|
|
209
|
+
summary: "Sync schema.ts to the live local DB (dev)",
|
|
210
|
+
flags: [
|
|
211
|
+
{
|
|
212
|
+
long: "--config",
|
|
213
|
+
short: "-c",
|
|
214
|
+
takesValue: true,
|
|
215
|
+
valueName: "path",
|
|
216
|
+
summary: "drizzle.config.ts path",
|
|
217
|
+
},
|
|
218
|
+
HELP,
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: "generate",
|
|
223
|
+
summary: "Write versioned SQL under drizzle/",
|
|
224
|
+
flags: [
|
|
225
|
+
{
|
|
226
|
+
long: "--config",
|
|
227
|
+
short: "-c",
|
|
228
|
+
takesValue: true,
|
|
229
|
+
valueName: "path",
|
|
230
|
+
summary: "drizzle.config.ts path",
|
|
231
|
+
},
|
|
232
|
+
HELP,
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: "migrate",
|
|
237
|
+
summary: "Apply generated migrations (explicit)",
|
|
238
|
+
flags: [
|
|
239
|
+
{
|
|
240
|
+
long: "--config",
|
|
241
|
+
short: "-c",
|
|
242
|
+
takesValue: true,
|
|
243
|
+
valueName: "path",
|
|
244
|
+
summary: "drizzle.config.ts path",
|
|
245
|
+
},
|
|
246
|
+
HELP,
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
},
|
|
188
251
|
{
|
|
189
252
|
name: "client",
|
|
190
253
|
summary: "ambient types for a separate frontend repo",
|
|
@@ -358,18 +421,12 @@ export const OKE_COMMANDS: readonly CliCommand[] = [
|
|
|
358
421
|
* @returns Help text (no trailing exit-code block)
|
|
359
422
|
*/
|
|
360
423
|
export function formatOkeHelp(): string {
|
|
361
|
-
const lines = [
|
|
362
|
-
"oke — okengine CLI",
|
|
363
|
-
"",
|
|
364
|
-
"Commands:",
|
|
365
|
-
];
|
|
424
|
+
const lines = ["oke — okengine CLI", "", "Commands:"];
|
|
366
425
|
for (const cmd of OKE_COMMANDS) {
|
|
367
426
|
const usage = formatCommandUsage(cmd);
|
|
368
427
|
lines.push(` ${pad(usage, 34)} ${cmd.summary}`);
|
|
369
428
|
if (cmd.name === "doctor") {
|
|
370
|
-
lines.push(
|
|
371
|
-
` ${pad("oke doctor --diff|-d", 34)} CI gate: undeclared contract breaks`,
|
|
372
|
-
);
|
|
429
|
+
lines.push(` ${pad("oke doctor --diff|-d", 34)} CI gate: undeclared contract breaks`);
|
|
373
430
|
}
|
|
374
431
|
}
|
|
375
432
|
lines.push("");
|
|
@@ -379,9 +436,7 @@ export function formatOkeHelp(): string {
|
|
|
379
436
|
/**
|
|
380
437
|
* Collect every top-level command name (for completion / tests).
|
|
381
438
|
*/
|
|
382
|
-
export function commandNames(
|
|
383
|
-
commands: readonly CliCommand[] = OKE_COMMANDS,
|
|
384
|
-
): readonly string[] {
|
|
439
|
+
export function commandNames(commands: readonly CliCommand[] = OKE_COMMANDS): readonly string[] {
|
|
385
440
|
return commands.map((c) => c.name);
|
|
386
441
|
}
|
|
387
442
|
|
|
@@ -391,10 +446,7 @@ export function commandNames(
|
|
|
391
446
|
* @param command - Top-level command
|
|
392
447
|
* @param sub - Optional subcommand name
|
|
393
448
|
*/
|
|
394
|
-
export function flagTokensFor(
|
|
395
|
-
command: CliCommand,
|
|
396
|
-
sub?: string,
|
|
397
|
-
): readonly string[] {
|
|
449
|
+
export function flagTokensFor(command: CliCommand, sub?: string): readonly string[] {
|
|
398
450
|
const flags = sub
|
|
399
451
|
? (command.subcommands?.find((s) => s.name === sub)?.flags ?? [])
|
|
400
452
|
: (command.flags ?? []);
|
|
@@ -420,9 +472,7 @@ function formatCommandUsage(cmd: CliCommand): string {
|
|
|
420
472
|
if (cmd.subcommands && cmd.subcommands.length > 1) {
|
|
421
473
|
const subs = cmd.subcommands.map((s) => s.name).join("|");
|
|
422
474
|
// Prefer shared JSON flag hint when every list-like sub supports it.
|
|
423
|
-
const jsonHint = cmd.subcommands.some((s) =>
|
|
424
|
-
s.flags?.some((f) => f.long === "--json"),
|
|
425
|
-
)
|
|
475
|
+
const jsonHint = cmd.subcommands.some((s) => s.flags?.some((f) => f.long === "--json"))
|
|
426
476
|
? " [--json|-j]"
|
|
427
477
|
: "";
|
|
428
478
|
return `oke ${cmd.name} ${subs}${jsonHint}`;
|
|
@@ -439,8 +489,8 @@ function formatCommandUsage(cmd: CliCommand): string {
|
|
|
439
489
|
function formatFlagHint(f: CliFlag): string {
|
|
440
490
|
const name = f.short ? `${f.long}|${f.short}` : f.long;
|
|
441
491
|
if (f.takesValue) {
|
|
442
|
-
// Optional value (e.g. --
|
|
443
|
-
if (f.long === "--
|
|
492
|
+
// Optional value (e.g. --docker [roles]) when valueName is roles-like.
|
|
493
|
+
if (f.long === "--docker") return `[${name} [${f.valueName}]]`;
|
|
444
494
|
return `[${name} ${f.valueName}]`;
|
|
445
495
|
}
|
|
446
496
|
return `[${name}]`;
|
package/src/cli/schema.ts
CHANGED
|
@@ -32,9 +32,7 @@ export interface SchemaGenerateOptions {
|
|
|
32
32
|
*
|
|
33
33
|
* @param options - Manifest / check flag
|
|
34
34
|
*/
|
|
35
|
-
export async function runSchemaGenerate(
|
|
36
|
-
options: SchemaGenerateOptions = {},
|
|
37
|
-
): Promise<number> {
|
|
35
|
+
export async function runSchemaGenerate(options: SchemaGenerateOptions = {}): Promise<number> {
|
|
38
36
|
const write = options.write ?? ((t) => process.stdout.write(t));
|
|
39
37
|
const cwd = options.cwd ?? process.cwd();
|
|
40
38
|
let manifest = options.manifest;
|
|
@@ -92,10 +90,7 @@ export async function runSchemaGenerate(
|
|
|
92
90
|
* @param cwd - Project root
|
|
93
91
|
* @param manifest - Optional manifest
|
|
94
92
|
*/
|
|
95
|
-
export async function schemaFingerprint(
|
|
96
|
-
cwd: string,
|
|
97
|
-
manifest?: Manifest,
|
|
98
|
-
): Promise<string> {
|
|
93
|
+
export async function schemaFingerprint(cwd: string, manifest?: Manifest): Promise<string> {
|
|
99
94
|
const tables = new Set<string>([
|
|
100
95
|
"oke_roles",
|
|
101
96
|
"oke_role_grants",
|
|
@@ -123,9 +118,7 @@ export async function schemaFingerprint(
|
|
|
123
118
|
*
|
|
124
119
|
* @param cwd - Project root
|
|
125
120
|
*/
|
|
126
|
-
export async function readSchemaFingerprint(
|
|
127
|
-
cwd: string,
|
|
128
|
-
): Promise<string | null> {
|
|
121
|
+
export async function readSchemaFingerprint(cwd: string): Promise<string | null> {
|
|
129
122
|
const fpFile = Bun.file(resolve(cwd, SCHEMA_FINGERPRINT_FILE));
|
|
130
123
|
if (await fpFile.exists()) {
|
|
131
124
|
return (await fpFile.text()).trim();
|
package/src/cli/stack.ts
CHANGED
|
@@ -22,19 +22,14 @@ export interface StackCliOptions {
|
|
|
22
22
|
*
|
|
23
23
|
* @param options - Config / images
|
|
24
24
|
*/
|
|
25
|
-
export async function runStackPreview(
|
|
26
|
-
options: StackCliOptions = {},
|
|
27
|
-
): Promise<number> {
|
|
25
|
+
export async function runStackPreview(options: StackCliOptions = {}): Promise<number> {
|
|
28
26
|
const write = options.write ?? ((t) => process.stdout.write(t));
|
|
29
27
|
const writeErr = options.writeErr ?? ((t) => process.stderr.write(t));
|
|
30
28
|
const json = options.json ?? false;
|
|
31
29
|
let images = options.images;
|
|
32
30
|
if (!images) {
|
|
33
31
|
try {
|
|
34
|
-
const loaded = await loadOkeConfig(
|
|
35
|
-
options.cwd ?? process.cwd(),
|
|
36
|
-
options.configPath,
|
|
37
|
-
);
|
|
32
|
+
const loaded = await loadOkeConfig(options.cwd ?? process.cwd(), options.configPath);
|
|
38
33
|
images = resolveImages(loaded.config);
|
|
39
34
|
} catch (err) {
|
|
40
35
|
const msg = err instanceof Error ? err.message : String(err);
|
package/src/cli/start.ts
CHANGED
|
@@ -17,10 +17,7 @@ export interface StartOptions {
|
|
|
17
17
|
* @param entry - Absolute entry path
|
|
18
18
|
* @param env - Process env overlay
|
|
19
19
|
*/
|
|
20
|
-
readonly runEntry?: (
|
|
21
|
-
entry: string,
|
|
22
|
-
env: Record<string, string>,
|
|
23
|
-
) => Promise<void>;
|
|
20
|
+
readonly runEntry?: (entry: string, env: Record<string, string>) => Promise<void>;
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
/**
|
|
@@ -29,10 +26,7 @@ export interface StartOptions {
|
|
|
29
26
|
* @param cwd - Project root
|
|
30
27
|
* @param explicit - Optional `--entry`
|
|
31
28
|
*/
|
|
32
|
-
export async function resolveStartEntry(
|
|
33
|
-
cwd: string,
|
|
34
|
-
explicit?: string,
|
|
35
|
-
): Promise<string> {
|
|
29
|
+
export async function resolveStartEntry(cwd: string, explicit?: string): Promise<string> {
|
|
36
30
|
if (explicit) return resolve(cwd, explicit);
|
|
37
31
|
const pkgPath = resolve(cwd, "package.json");
|
|
38
32
|
if (await Bun.file(pkgPath).exists()) {
|
|
@@ -47,9 +41,7 @@ export async function resolveStartEntry(
|
|
|
47
41
|
const path = resolve(cwd, candidate);
|
|
48
42
|
if (await Bun.file(path).exists()) return path;
|
|
49
43
|
}
|
|
50
|
-
throw new Error(
|
|
51
|
-
"oke start: no entry found — set package.json okengine.entry or pass --entry",
|
|
52
|
-
);
|
|
44
|
+
throw new Error("oke start: no entry found — set package.json okengine.entry or pass --entry");
|
|
53
45
|
}
|
|
54
46
|
|
|
55
47
|
/**
|
|
@@ -63,10 +55,7 @@ export async function runStart(options: StartOptions = {}): Promise<number> {
|
|
|
63
55
|
try {
|
|
64
56
|
const entry = await resolveStartEntry(cwd, options.entry);
|
|
65
57
|
const port = String(options.port ?? Number(Bun.env.PORT ?? APP_PORT));
|
|
66
|
-
const env = { ...process.env, NODE_ENV: "production", PORT: port } as Record<
|
|
67
|
-
string,
|
|
68
|
-
string
|
|
69
|
-
>;
|
|
58
|
+
const env = { ...process.env, NODE_ENV: "production", PORT: port } as Record<string, string>;
|
|
70
59
|
write(`oke start: ${entry} (port ${port})\n`);
|
|
71
60
|
if (options.runEntry) {
|
|
72
61
|
await options.runEntry(entry, env);
|
package/src/cli/upgrade.ts
CHANGED
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
* `oke upgrade` — run codemods for a breaking change, print the diff.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
runCodemods,
|
|
7
|
-
type CodemodChange,
|
|
8
|
-
} from "../upgrade/codemods.ts";
|
|
5
|
+
import { runCodemods, type CodemodChange } from "../upgrade/codemods.ts";
|
|
9
6
|
|
|
10
7
|
/** One file rewrite produced by a codemod. */
|
|
11
8
|
export type UpgradeChange = CodemodChange;
|
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { createClient } from "./create.ts";
|
|
7
|
-
import {
|
|
8
|
-
isErrorCode,
|
|
9
|
-
isFail,
|
|
10
|
-
isOk,
|
|
11
|
-
isTransportError,
|
|
12
|
-
} from "./errors.ts";
|
|
7
|
+
import { isErrorCode, isFail, isOk, isTransportError } from "./errors.ts";
|
|
13
8
|
import { createTransport } from "./transport.ts";
|
|
14
9
|
|
|
15
10
|
/**
|
|
@@ -26,10 +26,7 @@ type BookingsApp = AppOf<{
|
|
|
26
26
|
}>;
|
|
27
27
|
|
|
28
28
|
/** Compile-time equality. */
|
|
29
|
-
type Eq<A, B> =
|
|
30
|
-
(<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2
|
|
31
|
-
? true
|
|
32
|
-
: false;
|
|
29
|
+
type Eq<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? true : false;
|
|
33
30
|
type Assert<T extends true> = T;
|
|
34
31
|
|
|
35
32
|
describe("createClient — same-repo <App>", () => {
|
|
@@ -73,9 +70,7 @@ describe("createClient — same-repo <App>", () => {
|
|
|
73
70
|
if (error?.code === "FlightFull") {
|
|
74
71
|
// Runtime + type-level: seatsLeft is number, not unknown.
|
|
75
72
|
expect(error.data.seatsLeft).toBe(2);
|
|
76
|
-
type _Narrow = Assert<
|
|
77
|
-
Eq<typeof error.data, { seatsLeft: number }>
|
|
78
|
-
>;
|
|
73
|
+
type _Narrow = Assert<Eq<typeof error.data, { seatsLeft: number }>>;
|
|
79
74
|
const _keep: _Narrow = true;
|
|
80
75
|
expect(_keep).toBe(true);
|
|
81
76
|
} else {
|
|
@@ -135,11 +130,10 @@ describe("createClient — type helpers", () => {
|
|
|
135
130
|
const ok: _Codes = true;
|
|
136
131
|
expect(ok).toBe(true);
|
|
137
132
|
|
|
138
|
-
const sample: ClientResult<{ id: string }, { FlightFull: { seatsLeft: number } }> =
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
};
|
|
133
|
+
const sample: ClientResult<{ id: string }, { FlightFull: { seatsLeft: number } }> = {
|
|
134
|
+
data: null,
|
|
135
|
+
error: { code: "FlightFull", data: { seatsLeft: 0 } },
|
|
136
|
+
};
|
|
143
137
|
if (sample.error?.code === "FlightFull") {
|
|
144
138
|
type _D = Assert<Eq<typeof sample.error.data, { seatsLeft: number }>>;
|
|
145
139
|
const d: _D = true;
|
package/src/client/create.ts
CHANGED
|
@@ -13,12 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { createTransport, type Transport } from "./transport.ts";
|
|
16
|
-
import type {
|
|
17
|
-
Client,
|
|
18
|
-
ClientOptions,
|
|
19
|
-
ClientRouteMap,
|
|
20
|
-
ResolveApp,
|
|
21
|
-
} from "./types.ts";
|
|
16
|
+
import type { Client, ClientOptions, ClientRouteMap, ResolveApp } from "./types.ts";
|
|
22
17
|
|
|
23
18
|
/** App-shaped value that carries a runtime `$routes` table from typed adopt. */
|
|
24
19
|
export interface AppWithRoutes {
|
|
@@ -98,8 +93,7 @@ export function flattenRoutes(
|
|
|
98
93
|
$routes: ClientRouteMap | undefined,
|
|
99
94
|
): ClientOptions["routes"] | undefined {
|
|
100
95
|
if (!$routes) return undefined;
|
|
101
|
-
const out: Record<string, { readonly method: string; readonly path: string }> =
|
|
102
|
-
{};
|
|
96
|
+
const out: Record<string, { readonly method: string; readonly path: string }> = {};
|
|
103
97
|
for (const [unit, flows] of Object.entries($routes)) {
|
|
104
98
|
if (!flows || typeof flows !== "object") continue;
|
|
105
99
|
for (const [flow, contract] of Object.entries(flows)) {
|
package/src/client/errors.ts
CHANGED
|
@@ -30,10 +30,7 @@ export function isTransportError(
|
|
|
30
30
|
export function isErrorCode<
|
|
31
31
|
Err extends { readonly code: string; readonly data: unknown },
|
|
32
32
|
C extends Err["code"],
|
|
33
|
-
>(
|
|
34
|
-
error: Err | null | undefined,
|
|
35
|
-
code: C,
|
|
36
|
-
): error is Extract<Err, { readonly code: C }> {
|
|
33
|
+
>(error: Err | null | undefined, code: C): error is Extract<Err, { readonly code: C }> {
|
|
37
34
|
return error != null && error.code === code;
|
|
38
35
|
}
|
|
39
36
|
|
package/src/client/index.ts
CHANGED
|
@@ -7,12 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
export { createClient, flattenRoutes } from "./create.ts";
|
|
9
9
|
export type { AppWithRoutes } from "./create.ts";
|
|
10
|
-
export {
|
|
11
|
-
isErrorCode,
|
|
12
|
-
isFail,
|
|
13
|
-
isOk,
|
|
14
|
-
isTransportError,
|
|
15
|
-
} from "./errors.ts";
|
|
10
|
+
export { isErrorCode, isFail, isOk, isTransportError } from "./errors.ts";
|
|
16
11
|
export { createTransport } from "./transport.ts";
|
|
17
12
|
export type { Transport } from "./transport.ts";
|
|
18
13
|
export type {
|
|
@@ -20,10 +20,7 @@ beforeEach(() => {
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
/** Compile-time equality. */
|
|
23
|
-
type Eq<A, B> =
|
|
24
|
-
(<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2
|
|
25
|
-
? true
|
|
26
|
-
: false;
|
|
23
|
+
type Eq<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? true : false;
|
|
27
24
|
type Assert<T extends true> = T;
|
|
28
25
|
|
|
29
26
|
const NoteId = z.object({ id: z.string() });
|
|
@@ -54,9 +51,7 @@ const get = on(
|
|
|
54
51
|
out: Note,
|
|
55
52
|
errors: { NotFound },
|
|
56
53
|
do: ({ id }, fx) =>
|
|
57
|
-
id === "missing"
|
|
58
|
-
? fx.fail("NotFound", {})
|
|
59
|
-
: { id, title: "First", body: "Hello" },
|
|
54
|
+
id === "missing" ? fx.fail("NotFound", {}) : { id, title: "First", body: "Hello" },
|
|
60
55
|
}),
|
|
61
56
|
);
|
|
62
57
|
|
|
@@ -121,9 +116,7 @@ describe("Notes — typeof app carries contracts", () => {
|
|
|
121
116
|
{
|
|
122
117
|
const { data, error } = await api.notes.get({ id: "n_1" });
|
|
123
118
|
if (error?.code === "NotFound") {
|
|
124
|
-
type _Empty = Assert<
|
|
125
|
-
Eq<typeof error.data, Record<string, never>>
|
|
126
|
-
>;
|
|
119
|
+
type _Empty = Assert<Eq<typeof error.data, Record<string, never>>>;
|
|
127
120
|
const keep: _Empty = true;
|
|
128
121
|
expect(keep).toBe(true);
|
|
129
122
|
throw new Error("unexpected NotFound");
|
|
@@ -244,9 +237,7 @@ describe("Notes — typeof app carries contracts", () => {
|
|
|
244
237
|
type PartialClient = Client<typeof createOnly>;
|
|
245
238
|
|
|
246
239
|
type FullHasGet = "get" extends keyof FullClient["notes"] ? true : false;
|
|
247
|
-
type PartialHasGet = "get" extends keyof PartialClient["notes"]
|
|
248
|
-
? true
|
|
249
|
-
: false;
|
|
240
|
+
type PartialHasGet = "get" extends keyof PartialClient["notes"] ? true : false;
|
|
250
241
|
|
|
251
242
|
type _Full = Assert<Eq<FullHasGet, true>>;
|
|
252
243
|
type _Part = Assert<Eq<PartialHasGet, false>>;
|
package/src/client/transport.ts
CHANGED
|
@@ -24,12 +24,8 @@ export interface Transport {
|
|
|
24
24
|
* @param base - Absolute origin (no trailing slash)
|
|
25
25
|
* @param opts - Client options
|
|
26
26
|
*/
|
|
27
|
-
export function createTransport(
|
|
28
|
-
|
|
29
|
-
opts: ClientOptions = {},
|
|
30
|
-
): Transport {
|
|
31
|
-
const fetchFn: ClientFetch =
|
|
32
|
-
opts.fetch ?? globalThis.fetch.bind(globalThis);
|
|
27
|
+
export function createTransport(base: string, opts: ClientOptions = {}): Transport {
|
|
28
|
+
const fetchFn: ClientFetch = opts.fetch ?? globalThis.fetch.bind(globalThis);
|
|
33
29
|
const retries = opts.retry?.retries ?? 0;
|
|
34
30
|
const delay0 = opts.retry?.delay ?? 50;
|
|
35
31
|
const backoff = opts.retry?.backoff ?? 2;
|
|
@@ -94,10 +90,7 @@ async function once(
|
|
|
94
90
|
: rpcRequest(base, key, input);
|
|
95
91
|
|
|
96
92
|
const headers = new Headers();
|
|
97
|
-
const extra =
|
|
98
|
-
typeof opts.headers === "function"
|
|
99
|
-
? await opts.headers()
|
|
100
|
-
: opts.headers;
|
|
93
|
+
const extra = typeof opts.headers === "function" ? await opts.headers() : opts.headers;
|
|
101
94
|
if (Array.isArray(extra)) {
|
|
102
95
|
for (const [k, v] of extra) headers.set(k, v);
|
|
103
96
|
} else if (extra) {
|
|
@@ -114,9 +107,7 @@ async function once(
|
|
|
114
107
|
|
|
115
108
|
const ctrl = opts.timeout !== undefined ? new AbortController() : undefined;
|
|
116
109
|
const timer =
|
|
117
|
-
ctrl && opts.timeout !== undefined
|
|
118
|
-
? setTimeout(() => ctrl.abort(), opts.timeout)
|
|
119
|
-
: undefined;
|
|
110
|
+
ctrl && opts.timeout !== undefined ? setTimeout(() => ctrl.abort(), opts.timeout) : undefined;
|
|
120
111
|
|
|
121
112
|
try {
|
|
122
113
|
const res = await fetchFn(url, {
|
|
@@ -140,8 +131,7 @@ function rpcRequest(
|
|
|
140
131
|
input: unknown,
|
|
141
132
|
): { url: string; method: string; body: string | undefined } {
|
|
142
133
|
const url = `${base}/_oke/${key}`;
|
|
143
|
-
const body =
|
|
144
|
-
input === undefined ? undefined : JSON.stringify(input ?? {});
|
|
134
|
+
const body = input === undefined ? undefined : JSON.stringify(input ?? {});
|
|
145
135
|
return { url, method: "POST", body };
|
|
146
136
|
}
|
|
147
137
|
|
|
@@ -152,9 +142,7 @@ function restRequest(
|
|
|
152
142
|
input: unknown,
|
|
153
143
|
): { url: string; method: string; body: string | undefined } {
|
|
154
144
|
const params =
|
|
155
|
-
input !== null && typeof input === "object"
|
|
156
|
-
? (input as Record<string, unknown>)
|
|
157
|
-
: {};
|
|
145
|
+
input !== null && typeof input === "object" ? (input as Record<string, unknown>) : {};
|
|
158
146
|
let pathOut = path;
|
|
159
147
|
const query: string[] = [];
|
|
160
148
|
const rest: Record<string, unknown> = {};
|
|
@@ -173,15 +161,11 @@ function restRequest(
|
|
|
173
161
|
if (upper === "GET" || upper === "HEAD") {
|
|
174
162
|
for (const [k, v] of Object.entries(rest)) {
|
|
175
163
|
if (v !== undefined) {
|
|
176
|
-
query.push(
|
|
177
|
-
`${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`,
|
|
178
|
-
);
|
|
164
|
+
query.push(`${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`);
|
|
179
165
|
}
|
|
180
166
|
}
|
|
181
167
|
} else if (Object.keys(rest).length > 0 || path === pathOut) {
|
|
182
|
-
body = JSON.stringify(
|
|
183
|
-
Object.keys(rest).length > 0 ? rest : (input ?? {}),
|
|
184
|
-
);
|
|
168
|
+
body = JSON.stringify(Object.keys(rest).length > 0 ? rest : (input ?? {}));
|
|
185
169
|
}
|
|
186
170
|
|
|
187
171
|
const qs = query.length ? `?${query.join("&")}` : "";
|
|
@@ -221,12 +205,7 @@ async function decode(res: Response): Promise<ClientResult> {
|
|
|
221
205
|
};
|
|
222
206
|
}
|
|
223
207
|
|
|
224
|
-
if (
|
|
225
|
-
json !== null &&
|
|
226
|
-
typeof json === "object" &&
|
|
227
|
-
"data" in json &&
|
|
228
|
-
"error" in json
|
|
229
|
-
) {
|
|
208
|
+
if (json !== null && typeof json === "object" && "data" in json && "error" in json) {
|
|
230
209
|
return json as ClientResult;
|
|
231
210
|
}
|
|
232
211
|
|
package/src/client/types.ts
CHANGED
|
@@ -88,9 +88,7 @@ export type RoutesOf<App> = App extends { readonly $routes: infer R }
|
|
|
88
88
|
? R
|
|
89
89
|
: {
|
|
90
90
|
[U in keyof R]: {
|
|
91
|
-
[F in keyof R[U]]: R[U][F] extends FlowContract
|
|
92
|
-
? R[U][F]
|
|
93
|
-
: FlowContract;
|
|
91
|
+
[F in keyof R[U]]: R[U][F] extends FlowContract ? R[U][F] : FlowContract;
|
|
94
92
|
};
|
|
95
93
|
}
|
|
96
94
|
: App extends ClientRouteMap
|
|
@@ -102,9 +100,7 @@ export type RoutesOf<App> = App extends { readonly $routes: infer R }
|
|
|
102
100
|
*
|
|
103
101
|
* @typeParam E - Error code → data map
|
|
104
102
|
*/
|
|
105
|
-
export type ClientError<
|
|
106
|
-
E extends Record<string, unknown> = Record<string, unknown>,
|
|
107
|
-
> = {
|
|
103
|
+
export type ClientError<E extends Record<string, unknown> = Record<string, unknown>> = {
|
|
108
104
|
[K in keyof E & string]: {
|
|
109
105
|
readonly code: K;
|
|
110
106
|
readonly data: E[K];
|
|
@@ -138,10 +134,7 @@ export type ClientResult<
|
|
|
138
134
|
| { readonly data: null; readonly error: ClientError<E> | TransportError };
|
|
139
135
|
|
|
140
136
|
/** Minimal fetch signature (avoids DOM `HeadersInit` / `preconnect` coupling). */
|
|
141
|
-
export type ClientFetch = (
|
|
142
|
-
input: string | URL | Request,
|
|
143
|
-
init?: RequestInit,
|
|
144
|
-
) => Promise<Response>;
|
|
137
|
+
export type ClientFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
145
138
|
|
|
146
139
|
/** Header bag accepted by the client. */
|
|
147
140
|
export type ClientHeaders = Record<string, string> | [string, string][];
|
|
@@ -153,9 +146,7 @@ export interface ClientOptions {
|
|
|
153
146
|
/** Override `globalThis.fetch`. */
|
|
154
147
|
readonly fetch?: ClientFetch;
|
|
155
148
|
/** Static headers, or a getter invoked per request. */
|
|
156
|
-
readonly headers?:
|
|
157
|
-
| ClientHeaders
|
|
158
|
-
| (() => ClientHeaders | Promise<ClientHeaders>);
|
|
149
|
+
readonly headers?: ClientHeaders | (() => ClientHeaders | Promise<ClientHeaders>);
|
|
159
150
|
/** Abort the request after this many milliseconds. */
|
|
160
151
|
readonly timeout?: number;
|
|
161
152
|
/** Retry transient failures (network / 5xx). */
|
|
@@ -173,11 +164,7 @@ export interface ClientOptions {
|
|
|
173
164
|
*/
|
|
174
165
|
readonly auth?: {
|
|
175
166
|
/** Current access token (Bearer), or null. */
|
|
176
|
-
readonly getToken: () =>
|
|
177
|
-
| string
|
|
178
|
-
| null
|
|
179
|
-
| undefined
|
|
180
|
-
| Promise<string | null | undefined>;
|
|
167
|
+
readonly getToken: () => string | null | undefined | Promise<string | null | undefined>;
|
|
181
168
|
/** Obtain a new access token after 401. */
|
|
182
169
|
readonly refresh: () => Promise<string | null | undefined>;
|
|
183
170
|
};
|
|
@@ -186,9 +173,7 @@ export interface ClientOptions {
|
|
|
186
173
|
* When absent, the client uses `POST /_oke/{unit}/{flow}` unless
|
|
187
174
|
* {@link ClientOptions.$routes} supplies HTTP method/path from adopt.
|
|
188
175
|
*/
|
|
189
|
-
readonly routes?: Readonly<
|
|
190
|
-
Record<string, { readonly method: string; readonly path: string }>
|
|
191
|
-
>;
|
|
176
|
+
readonly routes?: Readonly<Record<string, { readonly method: string; readonly path: string }>>;
|
|
192
177
|
/**
|
|
193
178
|
* Runtime route map from `app.$routes` (typed adopt). HTTP triggers become
|
|
194
179
|
* REST; flows without method/path fall back to RPC.
|
|
@@ -203,11 +188,7 @@ export interface ClientOptions {
|
|
|
203
188
|
* @typeParam O - Output
|
|
204
189
|
* @typeParam E - Errors
|
|
205
190
|
*/
|
|
206
|
-
export type ClientCall<
|
|
207
|
-
I,
|
|
208
|
-
O,
|
|
209
|
-
E extends Record<string, unknown>,
|
|
210
|
-
> = [I] extends [void]
|
|
191
|
+
export type ClientCall<I, O, E extends Record<string, unknown>> = [I] extends [void]
|
|
211
192
|
? () => Promise<ClientResult<O, E>>
|
|
212
193
|
: Partial<I> extends I
|
|
213
194
|
? (input?: I) => Promise<ClientResult<O, E>>
|
|
@@ -223,9 +204,7 @@ type ContractIn<C> = "in" extends keyof C
|
|
|
223
204
|
: void;
|
|
224
205
|
|
|
225
206
|
/** Pull output from a contract shape. */
|
|
226
|
-
type ContractOut<C> = "out" extends keyof C
|
|
227
|
-
? NonNullable<C["out"]>
|
|
228
|
-
: unknown;
|
|
207
|
+
type ContractOut<C> = "out" extends keyof C ? NonNullable<C["out"]> : unknown;
|
|
229
208
|
|
|
230
209
|
/** Pull error map from a contract shape. */
|
|
231
210
|
type ContractErrors<C> = "errors" extends keyof C
|