okengine 0.1.4
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 +91 -0
- package/README.md +327 -0
- package/docs/spec/complete-example.md +1188 -0
- package/docs/spec/console.md +739 -0
- package/docs/spec/four-applications.md +1188 -0
- package/docs/spec/unified-theory.md +489 -0
- package/package.json +152 -0
- package/spec/manifest.v1.schema.json +624 -0
- package/src/auth/api-keys.ts +168 -0
- package/src/auth/attenuation.ts +116 -0
- package/src/auth/auth.test.ts +273 -0
- package/src/auth/cross-plane.ts +98 -0
- package/src/auth/index.ts +112 -0
- package/src/auth/invites.ts +66 -0
- package/src/auth/invoke-as.ts +49 -0
- package/src/auth/operator.ts +178 -0
- package/src/auth/planes.ts +102 -0
- package/src/auth/plugin.ts +44 -0
- package/src/auth/roles.ts +84 -0
- package/src/auth/sessions.ts +418 -0
- package/src/auth/tables.ts +131 -0
- package/src/cli/args.ts +50 -0
- package/src/cli/branch.ts +75 -0
- package/src/cli/build.ts +86 -0
- package/src/cli/client-add.test.ts +140 -0
- package/src/cli/client-add.ts +164 -0
- package/src/cli/completion.test.ts +58 -0
- package/src/cli/completion.ts +296 -0
- package/src/cli/dev-app-runner.ts +77 -0
- package/src/cli/dev.test.ts +435 -0
- package/src/cli/dev.ts +594 -0
- package/src/cli/doc-drift.test.ts +146 -0
- package/src/cli/doc-drift.ts +397 -0
- package/src/cli/docker-cli.test.ts +221 -0
- package/src/cli/docker.ts +127 -0
- package/src/cli/doctor-diff-examples.ts +92 -0
- package/src/cli/doctor-diff.test.ts +91 -0
- package/src/cli/doctor-diff.ts +274 -0
- package/src/cli/doctor-pii.test.ts +98 -0
- package/src/cli/doctor-pii.ts +151 -0
- package/src/cli/doctor.test.ts +150 -0
- package/src/cli/doctor.ts +223 -0
- package/src/cli/eval.ts +122 -0
- package/src/cli/exit.ts +19 -0
- package/src/cli/gates-list.test.ts +47 -0
- package/src/cli/gates-list.ts +84 -0
- package/src/cli/images.ts +277 -0
- package/src/cli/index.ts +99 -0
- package/src/cli/json-out.test.ts +129 -0
- package/src/cli/load-config.ts +71 -0
- package/src/cli/mcp-from-console.ts +50 -0
- package/src/cli/privacy-erase.ts +73 -0
- package/src/cli/registry.ts +455 -0
- package/src/cli/safe-defaults.test.ts +92 -0
- package/src/cli/schema.ts +196 -0
- package/src/cli/stack.ts +82 -0
- package/src/cli/start.ts +106 -0
- package/src/cli/upgrade.ts +105 -0
- package/src/cli/vault-cmd.ts +140 -0
- package/src/client/budget-entry.ts +34 -0
- package/src/client/budget.test.ts +17 -0
- package/src/client/create.test.ts +159 -0
- package/src/client/create.ts +152 -0
- package/src/client/errors.ts +60 -0
- package/src/client/index.ts +35 -0
- package/src/client/notes-contract.test.ts +289 -0
- package/src/client/transport.test.ts +123 -0
- package/src/client/transport.ts +254 -0
- package/src/client/types.ts +282 -0
- package/src/compiler/aot.test.ts +248 -0
- package/src/compiler/aot.ts +182 -0
- package/src/compiler/differential.test.ts +241 -0
- package/src/compiler/dynamic.ts +54 -0
- package/src/compiler/effects-infer.ts +541 -0
- package/src/compiler/emit.ts +40 -0
- package/src/compiler/extract.test.ts +177 -0
- package/src/compiler/extract.ts +1368 -0
- package/src/compiler/fixtures/raw/raw-unannotated.ts +28 -0
- package/src/compiler/fixtures/skyport/oke.config.ts +24 -0
- package/src/compiler/fixtures/skyport/src/ai.ts +15 -0
- package/src/compiler/fixtures/skyport/src/app.ts +10 -0
- package/src/compiler/fixtures/skyport/src/channels.ts +6 -0
- package/src/compiler/fixtures/skyport/src/core.ts +3 -0
- package/src/compiler/fixtures/skyport/src/flows/bookings/index.ts +57 -0
- package/src/compiler/fixtures/skyport/src/flows/bookings/signals.ts +11 -0
- package/src/compiler/fixtures/skyport/src/flows/payments/index.ts +14 -0
- package/src/compiler/fixtures/skyport/src/flows/support/index.ts +20 -0
- package/src/compiler/fixtures/skyport/src/gates.ts +14 -0
- package/src/compiler/fixtures/skyport/src/journeys.ts +9 -0
- package/src/compiler/fixtures/skyport/src/schema.ts +3 -0
- package/src/compiler/fixtures/skyport/src/vault.ts +6 -0
- package/src/compiler/fixtures/skyport.expected.json +241 -0
- package/src/compiler/fixtures/triggers/five-triggers.ts +69 -0
- package/src/compiler/http-parse.ts +214 -0
- package/src/compiler/index.ts +67 -0
- package/src/compiler/response.ts +89 -0
- package/src/compiler/sucrose.ts +238 -0
- package/src/config/index.ts +167 -0
- package/src/console/budget.test.ts +73 -0
- package/src/console/index.ts +30 -0
- package/src/console/server/access.test.ts +370 -0
- package/src/console/server/access.ts +777 -0
- package/src/console/server/ai.test.ts +172 -0
- package/src/console/server/ai.ts +632 -0
- package/src/console/server/app.ts +294 -0
- package/src/console/server/auth-rate.test.ts +81 -0
- package/src/console/server/auth-rate.ts +72 -0
- package/src/console/server/bind.ts +25 -0
- package/src/console/server/channels.test.ts +179 -0
- package/src/console/server/channels.ts +469 -0
- package/src/console/server/claim.test.ts +66 -0
- package/src/console/server/claim.ts +134 -0
- package/src/console/server/clock.test.ts +239 -0
- package/src/console/server/clock.ts +390 -0
- package/src/console/server/console.test.ts +338 -0
- package/src/console/server/diff.test.ts +299 -0
- package/src/console/server/diff.ts +352 -0
- package/src/console/server/dry-run.audit.test.ts +118 -0
- package/src/console/server/flows-invoke.test.ts +148 -0
- package/src/console/server/flows.ts +3633 -0
- package/src/console/server/gates.test.ts +360 -0
- package/src/console/server/gates.ts +869 -0
- package/src/console/server/index.ts +141 -0
- package/src/console/server/live.test.ts +30 -0
- package/src/console/server/live.ts +109 -0
- package/src/console/server/plugin.ts +50 -0
- package/src/console/server/plugins.test.ts +131 -0
- package/src/console/server/plugins.ts +429 -0
- package/src/console/server/runs-pii.ts +98 -0
- package/src/console/server/security-headers.ts +97 -0
- package/src/console/server/security.gate.test.ts +286 -0
- package/src/console/server/serve.ts +319 -0
- package/src/console/server/signals.test.ts +88 -0
- package/src/console/server/signals.ts +282 -0
- package/src/console/server/state.ts +982 -0
- package/src/console/server/store.test.ts +233 -0
- package/src/console/server/store.ts +861 -0
- package/src/console/server/structural.ts +95 -0
- package/src/console/server/vault.test.ts +251 -0
- package/src/console/server/vault.ts +430 -0
- package/src/console/ui/access/AccessA11yView.tsx +237 -0
- package/src/console/ui/access/a11y.test.tsx +122 -0
- package/src/console/ui/access/acknowledgement.test.ts +13 -0
- package/src/console/ui/access/acknowledgement.ts +35 -0
- package/src/console/ui/access/blast-radius.test.ts +26 -0
- package/src/console/ui/access/blast-radius.ts +40 -0
- package/src/console/ui/access/confirmation.test.ts +38 -0
- package/src/console/ui/access/confirmation.ts +36 -0
- package/src/console/ui/access/fixture.ts +203 -0
- package/src/console/ui/access/grantable.test.ts +17 -0
- package/src/console/ui/access/grantable.ts +36 -0
- package/src/console/ui/access/hygiene.test.ts +12 -0
- package/src/console/ui/access/hygiene.ts +39 -0
- package/src/console/ui/access/index.ts +54 -0
- package/src/console/ui/access/provenance.test.ts +12 -0
- package/src/console/ui/access/provenance.ts +29 -0
- package/src/console/ui/access/search.test.ts +17 -0
- package/src/console/ui/access/search.ts +72 -0
- package/src/console/ui/access/types.ts +111 -0
- package/src/console/ui/ai/AiA11yView.tsx +265 -0
- package/src/console/ui/ai/a11y.test.tsx +99 -0
- package/src/console/ui/ai/findings.ts +41 -0
- package/src/console/ui/ai/fixture.ts +182 -0
- package/src/console/ui/ai/format.ts +90 -0
- package/src/console/ui/ai/group.test.ts +37 -0
- package/src/console/ui/ai/group.ts +88 -0
- package/src/console/ui/ai/index.ts +66 -0
- package/src/console/ui/ai/promotion.test.ts +77 -0
- package/src/console/ui/ai/promotion.ts +150 -0
- package/src/console/ui/ai/search.test.ts +40 -0
- package/src/console/ui/ai/search.ts +89 -0
- package/src/console/ui/ai/types.ts +139 -0
- package/src/console/ui/architecture/ArchitectureA11yView.tsx +163 -0
- package/src/console/ui/architecture/a11y.test.tsx +97 -0
- package/src/console/ui/architecture/boundary.ts +42 -0
- package/src/console/ui/architecture/declared.ts +165 -0
- package/src/console/ui/architecture/fixture.ts +74 -0
- package/src/console/ui/architecture/index.ts +84 -0
- package/src/console/ui/architecture/layers.ts +64 -0
- package/src/console/ui/architecture/layout.ts +68 -0
- package/src/console/ui/architecture/pathologies.ts +260 -0
- package/src/console/ui/architecture/search.ts +145 -0
- package/src/console/ui/architecture/traffic.ts +102 -0
- package/src/console/ui/architecture/types.ts +144 -0
- package/src/console/ui/architecture/view.test.ts +165 -0
- package/src/console/ui/architecture/view.ts +516 -0
- package/src/console/ui/channels/ChannelsA11yView.tsx +180 -0
- package/src/console/ui/channels/a11y.test.tsx +96 -0
- package/src/console/ui/channels/confirmation.test.ts +37 -0
- package/src/console/ui/channels/confirmation.ts +27 -0
- package/src/console/ui/channels/fallback.test.ts +15 -0
- package/src/console/ui/channels/fallback.ts +20 -0
- package/src/console/ui/channels/findings.ts +38 -0
- package/src/console/ui/channels/fixture.ts +134 -0
- package/src/console/ui/channels/group.ts +25 -0
- package/src/console/ui/channels/index.ts +57 -0
- package/src/console/ui/channels/locale.test.ts +17 -0
- package/src/console/ui/channels/locale.ts +31 -0
- package/src/console/ui/channels/mask.test.ts +14 -0
- package/src/console/ui/channels/mask.ts +12 -0
- package/src/console/ui/channels/search.ts +58 -0
- package/src/console/ui/channels/taxonomy.test.ts +17 -0
- package/src/console/ui/channels/taxonomy.ts +49 -0
- package/src/console/ui/channels/types.ts +117 -0
- package/src/console/ui/clock/ClockA11yView.tsx +182 -0
- package/src/console/ui/clock/a11y.test.tsx +99 -0
- package/src/console/ui/clock/confirmation.test.ts +32 -0
- package/src/console/ui/clock/confirmation.ts +34 -0
- package/src/console/ui/clock/findings.ts +40 -0
- package/src/console/ui/clock/fixture.ts +111 -0
- package/src/console/ui/clock/health.test.ts +25 -0
- package/src/console/ui/clock/health.ts +61 -0
- package/src/console/ui/clock/index.ts +49 -0
- package/src/console/ui/clock/search.test.ts +39 -0
- package/src/console/ui/clock/search.ts +76 -0
- package/src/console/ui/clock/timeline.test.ts +44 -0
- package/src/console/ui/clock/timeline.ts +41 -0
- package/src/console/ui/clock/types.ts +78 -0
- package/src/console/ui/clock/waiting-on.test.ts +34 -0
- package/src/console/ui/clock/waiting-on.ts +83 -0
- package/src/console/ui/confirmation.unify.test.ts +92 -0
- package/src/console/ui/diff/DiffA11yView.tsx +85 -0
- package/src/console/ui/diff/a11y.test.tsx +99 -0
- package/src/console/ui/diff/fixture.ts +85 -0
- package/src/console/ui/diff/group.test.ts +58 -0
- package/src/console/ui/diff/group.ts +97 -0
- package/src/console/ui/diff/index.ts +38 -0
- package/src/console/ui/diff/search.test.ts +32 -0
- package/src/console/ui/diff/search.ts +75 -0
- package/src/console/ui/diff/summary.ts +74 -0
- package/src/console/ui/diff/types.ts +48 -0
- package/src/console/ui/dist/assets/index-B71Yl_SS.js +10 -0
- package/src/console/ui/dist/assets/panel-access-Dd37LU2c.js +64 -0
- package/src/console/ui/dist/assets/panel-ai-CC7LR6-J.js +1 -0
- package/src/console/ui/dist/assets/panel-architecture-B5b3iKCz.js +1 -0
- package/src/console/ui/dist/assets/panel-channels-CeNjTKXp.js +1 -0
- package/src/console/ui/dist/assets/panel-clock-DgFTLoHV.js +1 -0
- package/src/console/ui/dist/assets/panel-diff-DxehccqB.js +1 -0
- package/src/console/ui/dist/assets/panel-flows-BtrVn-Eg.js +45 -0
- package/src/console/ui/dist/assets/panel-gates-Z9MKRGdH.js +1 -0
- package/src/console/ui/dist/assets/panel-overview-Bd48d9km.js +1 -0
- package/src/console/ui/dist/assets/panel-plugins-DWd0TowH.js +1 -0
- package/src/console/ui/dist/assets/panel-runs-BwsWqKeB.js +1 -0
- package/src/console/ui/dist/assets/panel-signals-9najbZY2.js +1 -0
- package/src/console/ui/dist/assets/panel-store-OHkP2pDp.js +1 -0
- package/src/console/ui/dist/assets/panel-traces-tn2JoY8U.js +1 -0
- package/src/console/ui/dist/assets/panel-vault-BbfWdox0.js +1 -0
- package/src/console/ui/dist/assets/rolldown-runtime-CNC7AqOf.js +1 -0
- package/src/console/ui/dist/assets/style-Cnl7WLya.css +3 -0
- package/src/console/ui/dist/index.html +14 -0
- package/src/console/ui/flows/FlowsA11yView.tsx +155 -0
- package/src/console/ui/flows/a11y.test.tsx +105 -0
- package/src/console/ui/flows/buffer.test.ts +91 -0
- package/src/console/ui/flows/buffer.ts +118 -0
- package/src/console/ui/flows/confirmation.ts +131 -0
- package/src/console/ui/flows/contract.test.ts +89 -0
- package/src/console/ui/flows/contract.ts +353 -0
- package/src/console/ui/flows/fixture.ts +81 -0
- package/src/console/ui/flows/graph.test.ts +101 -0
- package/src/console/ui/flows/graph.ts +549 -0
- package/src/console/ui/flows/index.ts +87 -0
- package/src/console/ui/flows/save-as-test.test.ts +47 -0
- package/src/console/ui/flows/save-as-test.ts +99 -0
- package/src/console/ui/flows/search.ts +255 -0
- package/src/console/ui/flows/tiers.ts +140 -0
- package/src/console/ui/gates/GatesA11yView.tsx +192 -0
- package/src/console/ui/gates/a11y.test.tsx +116 -0
- package/src/console/ui/gates/audit.test.ts +40 -0
- package/src/console/ui/gates/audit.ts +63 -0
- package/src/console/ui/gates/denial.test.ts +36 -0
- package/src/console/ui/gates/denial.ts +51 -0
- package/src/console/ui/gates/findings.ts +19 -0
- package/src/console/ui/gates/fixture.ts +189 -0
- package/src/console/ui/gates/group.test.ts +30 -0
- package/src/console/ui/gates/group.ts +102 -0
- package/src/console/ui/gates/index.ts +47 -0
- package/src/console/ui/gates/search.test.ts +49 -0
- package/src/console/ui/gates/search.ts +115 -0
- package/src/console/ui/gates/types.ts +121 -0
- package/src/console/ui/overview/OverviewA11yView.tsx +152 -0
- package/src/console/ui/overview/a11y.test.tsx +113 -0
- package/src/console/ui/overview/busiest.ts +26 -0
- package/src/console/ui/overview/compose.ts +133 -0
- package/src/console/ui/overview/cost.test.ts +39 -0
- package/src/console/ui/overview/cost.ts +138 -0
- package/src/console/ui/overview/fixture.ts +161 -0
- package/src/console/ui/overview/golden.ts +57 -0
- package/src/console/ui/overview/index.ts +59 -0
- package/src/console/ui/overview/rank.test.ts +136 -0
- package/src/console/ui/overview/rank.ts +210 -0
- package/src/console/ui/overview/slo.test.ts +73 -0
- package/src/console/ui/overview/slo.ts +229 -0
- package/src/console/ui/overview/types.ts +121 -0
- package/src/console/ui/overview/verdict.ts +131 -0
- package/src/console/ui/plugins/PluginsA11yView.tsx +227 -0
- package/src/console/ui/plugins/a11y.test.tsx +97 -0
- package/src/console/ui/plugins/command.test.ts +22 -0
- package/src/console/ui/plugins/command.ts +27 -0
- package/src/console/ui/plugins/findings.ts +39 -0
- package/src/console/ui/plugins/fixture.ts +233 -0
- package/src/console/ui/plugins/group.test.ts +38 -0
- package/src/console/ui/plugins/group.ts +67 -0
- package/src/console/ui/plugins/index.ts +40 -0
- package/src/console/ui/plugins/search.ts +67 -0
- package/src/console/ui/plugins/types.ts +115 -0
- package/src/console/ui/runs/RunsA11yView.tsx +267 -0
- package/src/console/ui/runs/a11y.test.tsx +99 -0
- package/src/console/ui/runs/explain.test.ts +23 -0
- package/src/console/ui/runs/explain.ts +32 -0
- package/src/console/ui/runs/fixture.ts +189 -0
- package/src/console/ui/runs/group.test.ts +24 -0
- package/src/console/ui/runs/group.ts +85 -0
- package/src/console/ui/runs/histogram.test.ts +31 -0
- package/src/console/ui/runs/histogram.ts +85 -0
- package/src/console/ui/runs/index.ts +75 -0
- package/src/console/ui/runs/project.ts +122 -0
- package/src/console/ui/runs/query.test.ts +50 -0
- package/src/console/ui/runs/query.ts +283 -0
- package/src/console/ui/runs/search.test.ts +45 -0
- package/src/console/ui/runs/search.ts +141 -0
- package/src/console/ui/runs/trace-link.test.ts +30 -0
- package/src/console/ui/runs/trace-link.ts +99 -0
- package/src/console/ui/runs/types.ts +137 -0
- package/src/console/ui/shell/App.tsx +56 -0
- package/src/console/ui/shell/client.ts +1715 -0
- package/src/console/ui/shell/components/ui.tsx +110 -0
- package/src/console/ui/shell/index.html +12 -0
- package/src/console/ui/shell/layout/Shell.tsx +95 -0
- package/src/console/ui/shell/main.tsx +281 -0
- package/src/console/ui/shell/panels/Access.tsx +5 -0
- package/src/console/ui/shell/panels/Ai.tsx +5 -0
- package/src/console/ui/shell/panels/Architecture.tsx +5 -0
- package/src/console/ui/shell/panels/Channels.tsx +5 -0
- package/src/console/ui/shell/panels/Clock.tsx +5 -0
- package/src/console/ui/shell/panels/Diff.tsx +5 -0
- package/src/console/ui/shell/panels/Flows.tsx +5 -0
- package/src/console/ui/shell/panels/Gates.tsx +5 -0
- package/src/console/ui/shell/panels/Overview.tsx +6 -0
- package/src/console/ui/shell/panels/Plugins.tsx +5 -0
- package/src/console/ui/shell/panels/Runs.tsx +5 -0
- package/src/console/ui/shell/panels/Signals.tsx +5 -0
- package/src/console/ui/shell/panels/Store.tsx +5 -0
- package/src/console/ui/shell/panels/Traces.tsx +5 -0
- package/src/console/ui/shell/panels/Vault.tsx +5 -0
- package/src/console/ui/shell/panels/access/AccessPanel.tsx +813 -0
- package/src/console/ui/shell/panels/ai/AiPanel.tsx +563 -0
- package/src/console/ui/shell/panels/architecture/ArchitecturePanel.tsx +377 -0
- package/src/console/ui/shell/panels/channels/ChannelsPanel.tsx +454 -0
- package/src/console/ui/shell/panels/clock/ClockPanel.tsx +479 -0
- package/src/console/ui/shell/panels/diff/DiffPanel.tsx +275 -0
- package/src/console/ui/shell/panels/flows/ContractEditor.tsx +301 -0
- package/src/console/ui/shell/panels/flows/FlowDrawer.tsx +350 -0
- package/src/console/ui/shell/panels/flows/FlowsPanel.tsx +502 -0
- package/src/console/ui/shell/panels/gates/GatesPanel.tsx +482 -0
- package/src/console/ui/shell/panels/overview/OverviewPanel.tsx +428 -0
- package/src/console/ui/shell/panels/plugins/PluginsPanel.tsx +413 -0
- package/src/console/ui/shell/panels/runs/RunsPanel.tsx +649 -0
- package/src/console/ui/shell/panels/signals/SignalsPanel.tsx +840 -0
- package/src/console/ui/shell/panels/store/StorePanel.tsx +787 -0
- package/src/console/ui/shell/panels/traces/TracesPanel.tsx +539 -0
- package/src/console/ui/shell/panels/vault/VaultPanel.tsx +449 -0
- package/src/console/ui/shell/plugin/Sandbox.tsx +29 -0
- package/src/console/ui/shell/setup/Wizard.tsx +189 -0
- package/src/console/ui/shell/styles.css +75 -0
- package/src/console/ui/signals/SignalsA11yView.tsx +276 -0
- package/src/console/ui/signals/a11y.test.tsx +99 -0
- package/src/console/ui/signals/confirmation.test.ts +39 -0
- package/src/console/ui/signals/confirmation.ts +63 -0
- package/src/console/ui/signals/dry-run.test.ts +18 -0
- package/src/console/ui/signals/dry-run.ts +36 -0
- package/src/console/ui/signals/durable.test.ts +22 -0
- package/src/console/ui/signals/durable.ts +41 -0
- package/src/console/ui/signals/findings.ts +33 -0
- package/src/console/ui/signals/fixture.ts +242 -0
- package/src/console/ui/signals/group.test.ts +32 -0
- package/src/console/ui/signals/group.ts +49 -0
- package/src/console/ui/signals/index.ts +52 -0
- package/src/console/ui/signals/monitor.test.ts +30 -0
- package/src/console/ui/signals/monitor.ts +79 -0
- package/src/console/ui/signals/schema-form.test.ts +34 -0
- package/src/console/ui/signals/schema-form.ts +112 -0
- package/src/console/ui/signals/search.ts +102 -0
- package/src/console/ui/signals/types.ts +71 -0
- package/src/console/ui/store/StoreA11yView.tsx +199 -0
- package/src/console/ui/store/a11y.test.tsx +99 -0
- package/src/console/ui/store/cache-view.test.ts +13 -0
- package/src/console/ui/store/cache-view.ts +36 -0
- package/src/console/ui/store/confirmation.test.ts +38 -0
- package/src/console/ui/store/confirmation.ts +55 -0
- package/src/console/ui/store/dry-run.test.ts +15 -0
- package/src/console/ui/store/dry-run.ts +29 -0
- package/src/console/ui/store/fixture.ts +163 -0
- package/src/console/ui/store/group.test.ts +21 -0
- package/src/console/ui/store/group.ts +41 -0
- package/src/console/ui/store/index.ts +40 -0
- package/src/console/ui/store/search.ts +78 -0
- package/src/console/ui/store/types.ts +65 -0
- package/src/console/ui/store/will-not-fire.test.ts +19 -0
- package/src/console/ui/store/will-not-fire.ts +40 -0
- package/src/console/ui/traces/TracesA11yView.tsx +200 -0
- package/src/console/ui/traces/a11y.test.tsx +97 -0
- package/src/console/ui/traces/chain.test.ts +61 -0
- package/src/console/ui/traces/chain.ts +144 -0
- package/src/console/ui/traces/critical-path.test.ts +24 -0
- package/src/console/ui/traces/critical-path.ts +59 -0
- package/src/console/ui/traces/filter.test.ts +78 -0
- package/src/console/ui/traces/filter.ts +112 -0
- package/src/console/ui/traces/fixture.ts +126 -0
- package/src/console/ui/traces/fold.test.ts +67 -0
- package/src/console/ui/traces/fold.ts +170 -0
- package/src/console/ui/traces/index.ts +64 -0
- package/src/console/ui/traces/mini.ts +65 -0
- package/src/console/ui/traces/replay.test.ts +24 -0
- package/src/console/ui/traces/replay.ts +35 -0
- package/src/console/ui/traces/sampling.test.ts +26 -0
- package/src/console/ui/traces/sampling.ts +66 -0
- package/src/console/ui/traces/search.ts +148 -0
- package/src/console/ui/traces/tier.ts +72 -0
- package/src/console/ui/traces/types.ts +125 -0
- package/src/console/ui/tsconfig.json +20 -0
- package/src/console/ui/vault/VaultA11yView.tsx +177 -0
- package/src/console/ui/vault/a11y.test.tsx +97 -0
- package/src/console/ui/vault/blast-radius.test.ts +35 -0
- package/src/console/ui/vault/blast-radius.ts +55 -0
- package/src/console/ui/vault/confirmation.test.ts +41 -0
- package/src/console/ui/vault/confirmation.ts +39 -0
- package/src/console/ui/vault/dormant.test.ts +37 -0
- package/src/console/ui/vault/dormant.ts +28 -0
- package/src/console/ui/vault/export-safe.test.ts +30 -0
- package/src/console/ui/vault/export-safe.ts +65 -0
- package/src/console/ui/vault/fixture.ts +75 -0
- package/src/console/ui/vault/group.test.ts +25 -0
- package/src/console/ui/vault/group.ts +50 -0
- package/src/console/ui/vault/index.ts +45 -0
- package/src/console/ui/vault/search.ts +62 -0
- package/src/console/ui/vault/types.ts +57 -0
- package/src/console/ui/vite.config.ts +84 -0
- package/src/console/xss.gate.test.ts +118 -0
- package/src/docker/compose.ts +226 -0
- package/src/docker/credentials.ts +25 -0
- package/src/docker/derive.ts +83 -0
- package/src/docker/docker.test.ts +185 -0
- package/src/docker/dockerfile.integration.test.ts +170 -0
- package/src/docker/dockerfile.ts +39 -0
- package/src/docker/helpers.ts +103 -0
- package/src/docker/index.ts +52 -0
- package/src/docker/pin.ts +90 -0
- package/src/docker/recipes/index.ts +33 -0
- package/src/docker/recipes/postgres.ts +18 -0
- package/src/docker/recipes/redis.ts +18 -0
- package/src/docker/stack.integration.test.ts +140 -0
- package/src/docker/stack.ts +62 -0
- package/src/docker/types.ts +134 -0
- package/src/drivers/ai-anthropic.ts +128 -0
- package/src/drivers/ai-mock.ts +82 -0
- package/src/drivers/ai-openai-compatible.ts +139 -0
- package/src/drivers/ai-providers.test.ts +163 -0
- package/src/drivers/ai-types.ts +83 -0
- package/src/drivers/bun-native-completeness.test.ts +155 -0
- package/src/drivers/channel-console.ts +118 -0
- package/src/drivers/channel-fcm.ts +96 -0
- package/src/drivers/channel-resend.ts +27 -0
- package/src/drivers/channel-smtp.ts +33 -0
- package/src/drivers/channel-types.ts +160 -0
- package/src/drivers/channel-unifonic.ts +79 -0
- package/src/drivers/channel-wa-cloud.ts +84 -0
- package/src/drivers/channel-webpush.ts +317 -0
- package/src/drivers/conformance.test.ts +89 -0
- package/src/drivers/conformance.ts +162 -0
- package/src/drivers/fs.ts +73 -0
- package/src/drivers/index.ts +194 -0
- package/src/drivers/kv-lua.ts +222 -0
- package/src/drivers/memory.ts +472 -0
- package/src/drivers/pgvector.ts +130 -0
- package/src/drivers/postgres.ts +221 -0
- package/src/drivers/redis.ts +254 -0
- package/src/drivers/s3.ts +129 -0
- package/src/drivers/signal-engine.ts +690 -0
- package/src/drivers/signal-memory.ts +27 -0
- package/src/drivers/signal-nats.ts +131 -0
- package/src/drivers/signal-postgres.ts +1089 -0
- package/src/drivers/signal-redis.ts +275 -0
- package/src/drivers/signal-types.ts +328 -0
- package/src/drivers/sqlite.ts +53 -0
- package/src/drivers/types.ts +334 -0
- package/src/drivers/vault-dotenv-parse.ts +56 -0
- package/src/drivers/vault-env.ts +101 -0
- package/src/drivers/vault-infisical.ts +61 -0
- package/src/drivers/vault-managed.ts +42 -0
- package/src/drivers/vault-memory.ts +38 -0
- package/src/drivers/vault-openbao.ts +80 -0
- package/src/drivers/vault-sops.ts +252 -0
- package/src/drivers/vault-types.ts +84 -0
- package/src/elements/ai/declare.ts +206 -0
- package/src/elements/ai/eval.ts +113 -0
- package/src/elements/ai/pii.ts +108 -0
- package/src/elements/ai/runtime.ts +540 -0
- package/src/elements/ai/schema.ts +194 -0
- package/src/elements/ai.test.ts +393 -0
- package/src/elements/ai.ts +56 -0
- package/src/elements/channel/consent.ts +81 -0
- package/src/elements/channel/costs.test.ts +62 -0
- package/src/elements/channel/costs.ts +130 -0
- package/src/elements/channel/declare.ts +141 -0
- package/src/elements/channel/email-auth.test.ts +47 -0
- package/src/elements/channel/email-auth.ts +109 -0
- package/src/elements/channel/locale.ts +97 -0
- package/src/elements/channel/mask.test.ts +19 -0
- package/src/elements/channel/mask.ts +60 -0
- package/src/elements/channel/mime.ts +23 -0
- package/src/elements/channel/outcomes.test.ts +40 -0
- package/src/elements/channel/outcomes.ts +126 -0
- package/src/elements/channel/receipts.ts +121 -0
- package/src/elements/channel/runtime.ts +500 -0
- package/src/elements/channel/suppression.ts +136 -0
- package/src/elements/channel.test.ts +232 -0
- package/src/elements/channel.ts +109 -0
- package/src/elements/clock/actions.ts +170 -0
- package/src/elements/clock/declare.ts +58 -0
- package/src/elements/clock/dst.ts +197 -0
- package/src/elements/clock/durable.ts +140 -0
- package/src/elements/clock/duration.ts +29 -0
- package/src/elements/clock/health.test.ts +103 -0
- package/src/elements/clock/health.ts +112 -0
- package/src/elements/clock/leader.ts +127 -0
- package/src/elements/clock/reconcile.ts +241 -0
- package/src/elements/clock/runtime.ts +243 -0
- package/src/elements/clock/schedule.ts +262 -0
- package/src/elements/clock/time-travel.ts +53 -0
- package/src/elements/clock.test.ts +365 -0
- package/src/elements/clock.ts +80 -0
- package/src/elements/gate/declare.ts +134 -0
- package/src/elements/gate/permissions.ts +104 -0
- package/src/elements/gate/runtime.ts +177 -0
- package/src/elements/gate/strategies.ts +388 -0
- package/src/elements/gate.test.ts +145 -0
- package/src/elements/gate.ts +41 -0
- package/src/elements/index.ts +169 -0
- package/src/elements/signal/chaos-child.ts +47 -0
- package/src/elements/signal/declare.ts +77 -0
- package/src/elements/signal/dry-run-replay.test.ts +95 -0
- package/src/elements/signal/dry-run-write-isolation.test.ts +94 -0
- package/src/elements/signal/reconcile.test.ts +23 -0
- package/src/elements/signal/reconcile.ts +122 -0
- package/src/elements/signal/runtime.ts +94 -0
- package/src/elements/signal.test.ts +457 -0
- package/src/elements/signal.ts +26 -0
- package/src/elements/store/cache.ts +197 -0
- package/src/elements/store/classify.ts +125 -0
- package/src/elements/store/declare.ts +200 -0
- package/src/elements/store/files-policy.test.ts +31 -0
- package/src/elements/store/files-policy.ts +70 -0
- package/src/elements/store/replica.ts +68 -0
- package/src/elements/store/runtime.ts +393 -0
- package/src/elements/store/sql-condition.ts +205 -0
- package/src/elements/store/sql-session.ts +579 -0
- package/src/elements/store/table.ts +282 -0
- package/src/elements/store.test.ts +370 -0
- package/src/elements/store.ts +99 -0
- package/src/elements/vault/declare.ts +143 -0
- package/src/elements/vault/fingerprint.ts +30 -0
- package/src/elements/vault/redact.ts +52 -0
- package/src/elements/vault/runtime.ts +461 -0
- package/src/elements/vault.test.ts +296 -0
- package/src/elements/vault.ts +44 -0
- package/src/index.ts +183 -0
- package/src/kernel/adopt-routes.ts +194 -0
- package/src/kernel/app.ts +1068 -0
- package/src/kernel/auth-resolve.ts +93 -0
- package/src/kernel/boot.test.ts +173 -0
- package/src/kernel/boot.ts +439 -0
- package/src/kernel/budget-entry.ts +55 -0
- package/src/kernel/budget.test.ts +19 -0
- package/src/kernel/call.test.ts +83 -0
- package/src/kernel/capability.ts +113 -0
- package/src/kernel/dry-run.test.ts +64 -0
- package/src/kernel/dry-run.ts +171 -0
- package/src/kernel/effects.test.ts +89 -0
- package/src/kernel/effects.ts +140 -0
- package/src/kernel/errors.registry.test.ts +39 -0
- package/src/kernel/errors.ts +225 -0
- package/src/kernel/flow.test.ts +154 -0
- package/src/kernel/flow.ts +290 -0
- package/src/kernel/fx.test.ts +245 -0
- package/src/kernel/fx.ts +996 -0
- package/src/kernel/hook-timing.test.ts +72 -0
- package/src/kernel/hook-timing.ts +190 -0
- package/src/kernel/hooks.test.ts +181 -0
- package/src/kernel/hooks.ts +275 -0
- package/src/kernel/index.ts +278 -0
- package/src/kernel/journal.ts +405 -0
- package/src/kernel/journey.ts +75 -0
- package/src/kernel/on.ts +74 -0
- package/src/kernel/pipeline.test.ts +349 -0
- package/src/kernel/pipeline.ts +245 -0
- package/src/kernel/plug.ts +82 -0
- package/src/kernel/plugin/capabilities.test.ts +84 -0
- package/src/kernel/plugin/conflicts.test.ts +106 -0
- package/src/kernel/plugin/decorate.test.ts +111 -0
- package/src/kernel/plugin/scoping.test.ts +138 -0
- package/src/kernel/plugin.ts +485 -0
- package/src/kernel/rate-limit.ts +25 -0
- package/src/kernel/registry.ts +398 -0
- package/src/kernel/router.test.ts +114 -0
- package/src/kernel/router.ts +556 -0
- package/src/kernel/routing-budget.test.ts +19 -0
- package/src/kernel/run-telemetry.ts +70 -0
- package/src/kernel/triggers.ts +324 -0
- package/src/kernel/unit.ts +88 -0
- package/src/manifest/diff.test.ts +866 -0
- package/src/manifest/diff.ts +1670 -0
- package/src/manifest/fixtures/base.manifest.json +112 -0
- package/src/manifest/fixtures/skyport.excerpt.json +51 -0
- package/src/manifest/fixtures/skyport.manifest.json +153 -0
- package/src/manifest/index.ts +27 -0
- package/src/manifest/types.ts +358 -0
- package/src/manifest/undeclared.test.ts +82 -0
- package/src/manifest/undeclared.ts +65 -0
- package/src/manifest/validate.test.ts +105 -0
- package/src/manifest/validate.ts +174 -0
- package/src/mcp/authorization.ts +340 -0
- package/src/mcp/confirmation.ts +174 -0
- package/src/mcp/data.ts +90 -0
- package/src/mcp/index.ts +80 -0
- package/src/mcp/injection.gate.test.ts +176 -0
- package/src/mcp/mcp.test.ts +348 -0
- package/src/mcp/protocol.ts +172 -0
- package/src/mcp/server.ts +283 -0
- package/src/mcp/session.ts +139 -0
- package/src/mcp/tools.ts +391 -0
- package/src/plugins/catalogue.test.ts +48 -0
- package/src/plugins/catalogue.ts +113 -0
- package/src/plugins/node-import-scan.test.ts +28 -0
- package/src/plugins/node-import-scan.ts +98 -0
- package/src/plugins/supply-chain.test.ts +48 -0
- package/src/plugins/supply-chain.ts +460 -0
- package/src/release/index.ts +30 -0
- package/src/release/limits.ts +20 -0
- package/src/release/measure.ts +443 -0
- package/src/release/publish.ts +56 -0
- package/src/runs/bench.test.ts +93 -0
- package/src/runs/collect.ts +144 -0
- package/src/runs/drivers/clickhouse.ts +108 -0
- package/src/runs/drivers/files.ts +201 -0
- package/src/runs/drivers/memory.ts +94 -0
- package/src/runs/drivers/postgres.ts +110 -0
- package/src/runs/duckdb.ts +99 -0
- package/src/runs/index.ts +82 -0
- package/src/runs/outlier.ts +180 -0
- package/src/runs/parquet.ts +210 -0
- package/src/runs/privacy.ts +49 -0
- package/src/runs/runs.test.ts +324 -0
- package/src/runs/runtime.ts +229 -0
- package/src/runs/shred.ts +243 -0
- package/src/runs/telemetry.ts +10 -0
- package/src/runs/types.ts +179 -0
- package/src/runtime/bun.ts +140 -0
- package/src/runtime/cold-start.bench.ts +20 -0
- package/src/runtime/index.ts +46 -0
- package/src/runtime/primitives.ts +242 -0
- package/src/runtime/security.test.ts +170 -0
- package/src/runtime/security.ts +168 -0
- package/src/runtime/serve.test.ts +223 -0
- package/src/runtime/types.ts +217 -0
- package/src/runtime/web-standard.ts +77 -0
- package/src/test/create-test-app.test.ts +161 -0
- package/src/test/create-test-app.ts +533 -0
- package/src/test/index.ts +21 -0
- package/src/test/provisions.integration.test.ts +174 -0
- package/src/upgrade/codemods.test.ts +58 -0
- package/src/upgrade/codemods.ts +83 -0
- package/src/validation/index.ts +23 -0
- package/src/validation/standard-schema.test.ts +96 -0
- package/src/validation/standard-schema.ts +316 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed client — same-repo `<App>`, narrowing, transport behaviours.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "bun:test";
|
|
6
|
+
import { createClient } from "./create.ts";
|
|
7
|
+
import { isErrorCode, isOk, isTransportError } from "./errors.ts";
|
|
8
|
+
import type { AppOf, ClientError, ClientResult } from "./types.ts";
|
|
9
|
+
|
|
10
|
+
/** Fixture App matching Notes / bookings (`FlightFull`). */
|
|
11
|
+
type BookingsApp = AppOf<{
|
|
12
|
+
bookings: {
|
|
13
|
+
create: {
|
|
14
|
+
in: { flightId: string; seats: number };
|
|
15
|
+
out: { id: string; flightId: string; seats: number };
|
|
16
|
+
errors: { FlightFull: { seatsLeft: number } };
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
notes: {
|
|
20
|
+
get: {
|
|
21
|
+
in: { id: string };
|
|
22
|
+
out: { id: string; title: string };
|
|
23
|
+
errors: { NotFound: Record<string, never> };
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
|
|
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;
|
|
33
|
+
type Assert<T extends true> = T;
|
|
34
|
+
|
|
35
|
+
describe("createClient — same-repo <App>", () => {
|
|
36
|
+
test("success envelope is typed", async () => {
|
|
37
|
+
const api = createClient<BookingsApp>("http://app.test", {
|
|
38
|
+
fetch: async () =>
|
|
39
|
+
Response.json({
|
|
40
|
+
data: { id: "b_1", flightId: "SK1", seats: 1 },
|
|
41
|
+
error: null,
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const result = await api.bookings.create({
|
|
46
|
+
flightId: "SK1",
|
|
47
|
+
seats: 1,
|
|
48
|
+
});
|
|
49
|
+
expect(result.error).toBeNull();
|
|
50
|
+
expect(result.data?.id).toBe("b_1");
|
|
51
|
+
expect(isOk(result)).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('error.code === "FlightFull" narrows error.data', async () => {
|
|
55
|
+
const api = createClient<BookingsApp>("http://app.test", {
|
|
56
|
+
fetch: async () =>
|
|
57
|
+
Response.json(
|
|
58
|
+
{
|
|
59
|
+
data: null,
|
|
60
|
+
error: { code: "FlightFull", data: { seatsLeft: 2 } },
|
|
61
|
+
},
|
|
62
|
+
{ status: 400 },
|
|
63
|
+
),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const { data, error } = await api.bookings.create({
|
|
67
|
+
flightId: "SK1",
|
|
68
|
+
seats: 9,
|
|
69
|
+
});
|
|
70
|
+
expect(data).toBeNull();
|
|
71
|
+
expect(error?.code).toBe("FlightFull");
|
|
72
|
+
|
|
73
|
+
if (error?.code === "FlightFull") {
|
|
74
|
+
// Runtime + type-level: seatsLeft is number, not unknown.
|
|
75
|
+
expect(error.data.seatsLeft).toBe(2);
|
|
76
|
+
type _Narrow = Assert<
|
|
77
|
+
Eq<typeof error.data, { seatsLeft: number }>
|
|
78
|
+
>;
|
|
79
|
+
const _keep: _Narrow = true;
|
|
80
|
+
expect(_keep).toBe(true);
|
|
81
|
+
} else {
|
|
82
|
+
throw new Error("expected FlightFull");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
expect(isErrorCode(error, "FlightFull")).toBe(true);
|
|
86
|
+
if (isErrorCode(error, "FlightFull")) {
|
|
87
|
+
expect(error.data.seatsLeft).toBe(2);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("RPC path is POST /_oke/{unit}/{flow}", async () => {
|
|
92
|
+
let seen = "";
|
|
93
|
+
const api = createClient<BookingsApp>("http://app.test/", {
|
|
94
|
+
fetch: async (input) => {
|
|
95
|
+
seen = String(input);
|
|
96
|
+
return Response.json({
|
|
97
|
+
data: { id: "n_1", title: "Hi" },
|
|
98
|
+
error: null,
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
await api.notes.get({ id: "n_1" });
|
|
103
|
+
expect(seen).toBe("http://app.test/_oke/notes/get");
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("REST routes map substitutes path params", async () => {
|
|
107
|
+
let method = "";
|
|
108
|
+
let url = "";
|
|
109
|
+
const api = createClient<BookingsApp>("http://app.test", {
|
|
110
|
+
routes: {
|
|
111
|
+
"notes.get": { method: "GET", path: "/notes/:id" },
|
|
112
|
+
},
|
|
113
|
+
fetch: async (input, init) => {
|
|
114
|
+
url = String(input);
|
|
115
|
+
method = String(init?.method ?? "GET");
|
|
116
|
+
return Response.json({
|
|
117
|
+
data: { id: "n_1", title: "Hi" },
|
|
118
|
+
error: null,
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
await api.notes.get({ id: "n_1" });
|
|
123
|
+
expect(method).toBe("GET");
|
|
124
|
+
expect(url).toBe("http://app.test/notes/n_1");
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe("createClient — type helpers", () => {
|
|
129
|
+
test("ClientError discriminated union is exhaustive on code", () => {
|
|
130
|
+
type E = ClientError<{
|
|
131
|
+
FlightFull: { seatsLeft: number };
|
|
132
|
+
NotFound: Record<string, never>;
|
|
133
|
+
}>;
|
|
134
|
+
type _Codes = Assert<Eq<E["code"], "FlightFull" | "NotFound">>;
|
|
135
|
+
const ok: _Codes = true;
|
|
136
|
+
expect(ok).toBe(true);
|
|
137
|
+
|
|
138
|
+
const sample: ClientResult<{ id: string }, { FlightFull: { seatsLeft: number } }> =
|
|
139
|
+
{
|
|
140
|
+
data: null,
|
|
141
|
+
error: { code: "FlightFull", data: { seatsLeft: 0 } },
|
|
142
|
+
};
|
|
143
|
+
if (sample.error?.code === "FlightFull") {
|
|
144
|
+
type _D = Assert<Eq<typeof sample.error.data, { seatsLeft: number }>>;
|
|
145
|
+
const d: _D = true;
|
|
146
|
+
expect(d).toBe(true);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test("isTransportError", () => {
|
|
151
|
+
expect(
|
|
152
|
+
isTransportError({
|
|
153
|
+
code: "TransportError",
|
|
154
|
+
data: { message: "boom" },
|
|
155
|
+
}),
|
|
156
|
+
).toBe(true);
|
|
157
|
+
expect(isTransportError({ code: "FlightFull", data: {} })).toBe(false);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createClient<App>(url, opts)` — typed client, zero runtime codegen.
|
|
3
|
+
*
|
|
4
|
+
* Modes:
|
|
5
|
+
* 1. Same-repo: `createClient<App>(url)` with `typeof app` after
|
|
6
|
+
* `.adopt({ notes })`, or `createClient(app, url)` to also wire REST from
|
|
7
|
+
* `app.$routes` at runtime
|
|
8
|
+
* 2. Local dev: `createClient(url)` — types from ambient {@link Register}
|
|
9
|
+
* 3. Separate repo: same as (2) after `oke client add <url>`
|
|
10
|
+
*
|
|
11
|
+
* Wire: HTTP triggers use REST (`method` + `path` from the bound trigger).
|
|
12
|
+
* Untriggered flows fall back to `POST /_oke/{unit}/{flow}` RPC.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { createTransport, type Transport } from "./transport.ts";
|
|
16
|
+
import type {
|
|
17
|
+
Client,
|
|
18
|
+
ClientOptions,
|
|
19
|
+
ClientRouteMap,
|
|
20
|
+
ResolveApp,
|
|
21
|
+
} from "./types.ts";
|
|
22
|
+
|
|
23
|
+
/** App-shaped value that carries a runtime `$routes` table from typed adopt. */
|
|
24
|
+
export interface AppWithRoutes {
|
|
25
|
+
readonly $routes: ClientRouteMap;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Create a fully typed client from an adopted app value (types + REST).
|
|
30
|
+
*
|
|
31
|
+
* @typeParam App - `typeof app` after `.adopt({ notes })`
|
|
32
|
+
* @param app - Application instance with `$routes`
|
|
33
|
+
* @param url - App base URL (port 6530 in dev)
|
|
34
|
+
* @param opts - Transport options (retry, timeout, auth)
|
|
35
|
+
*/
|
|
36
|
+
export function createClient<App extends AppWithRoutes>(
|
|
37
|
+
app: App,
|
|
38
|
+
url: string,
|
|
39
|
+
opts?: ClientOptions,
|
|
40
|
+
): Client<App>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create a fully typed client from an App type argument / ambient Register.
|
|
44
|
+
*
|
|
45
|
+
* Pass `opts.$routes` (usually `app.$routes`) so HTTP triggers issue REST
|
|
46
|
+
* instead of RPC.
|
|
47
|
+
*
|
|
48
|
+
* @typeParam App - `typeof app`, {@link AppOf} route map, or omit for {@link Register}
|
|
49
|
+
* @param url - App base URL (port 6530 in dev)
|
|
50
|
+
* @param opts - Transport options (retry, timeout, auth, `$routes`)
|
|
51
|
+
*/
|
|
52
|
+
export function createClient<App = never>(
|
|
53
|
+
url: string,
|
|
54
|
+
opts?: ClientOptions,
|
|
55
|
+
): Client<ResolveApp<App>>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param appOrUrl - App instance or base URL
|
|
59
|
+
* @param urlOrOpts - Base URL (when app given) or options
|
|
60
|
+
* @param maybeOpts - Options when app + url form is used
|
|
61
|
+
*/
|
|
62
|
+
export function createClient(
|
|
63
|
+
appOrUrl: AppWithRoutes | string,
|
|
64
|
+
urlOrOpts?: string | ClientOptions,
|
|
65
|
+
maybeOpts?: ClientOptions,
|
|
66
|
+
): Client {
|
|
67
|
+
if (typeof appOrUrl === "string") {
|
|
68
|
+
return buildClient(appOrUrl, urlOrOpts as ClientOptions | undefined);
|
|
69
|
+
}
|
|
70
|
+
const url = typeof urlOrOpts === "string" ? urlOrOpts : "";
|
|
71
|
+
const opts = typeof urlOrOpts === "string" ? maybeOpts : urlOrOpts;
|
|
72
|
+
return buildClient(url, {
|
|
73
|
+
...opts,
|
|
74
|
+
$routes: opts?.$routes ?? appOrUrl.$routes,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Shared constructor — flattens `$routes` into the transport REST table.
|
|
80
|
+
*
|
|
81
|
+
* @param url - Base URL
|
|
82
|
+
* @param opts - Client options
|
|
83
|
+
*/
|
|
84
|
+
function buildClient(url: string, opts: ClientOptions = {}): Client {
|
|
85
|
+
const base = url.replace(/\/+$/, "");
|
|
86
|
+
const routes = opts.routes ?? flattenRoutes(opts.$routes);
|
|
87
|
+
const transport = createTransport(base, { ...opts, routes });
|
|
88
|
+
return proxy(transport, []) as Client;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Flatten `app.$routes` into the transport REST table (`unit.flow` → method/path).
|
|
93
|
+
* Entries without both method and path are omitted (RPC fallback).
|
|
94
|
+
*
|
|
95
|
+
* @param $routes - Runtime route map from typed adopt
|
|
96
|
+
*/
|
|
97
|
+
export function flattenRoutes(
|
|
98
|
+
$routes: ClientRouteMap | undefined,
|
|
99
|
+
): ClientOptions["routes"] | undefined {
|
|
100
|
+
if (!$routes) return undefined;
|
|
101
|
+
const out: Record<string, { readonly method: string; readonly path: string }> =
|
|
102
|
+
{};
|
|
103
|
+
for (const [unit, flows] of Object.entries($routes)) {
|
|
104
|
+
if (!flows || typeof flows !== "object") continue;
|
|
105
|
+
for (const [flow, contract] of Object.entries(flows)) {
|
|
106
|
+
if (!contract || typeof contract !== "object") continue;
|
|
107
|
+
const method = "method" in contract ? contract.method : undefined;
|
|
108
|
+
const path = "path" in contract ? contract.path : undefined;
|
|
109
|
+
if (typeof method === "string" && typeof path === "string") {
|
|
110
|
+
out[`${unit}.${flow}`] = { method, path };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Build a nested Proxy: `api.notes.get(input)` → REST or RPC from routes.
|
|
119
|
+
*
|
|
120
|
+
* @param transport - HTTP transport
|
|
121
|
+
* @param path - Accumulated property path
|
|
122
|
+
*/
|
|
123
|
+
function proxy(transport: Transport, path: readonly string[]): unknown {
|
|
124
|
+
const call = (input?: unknown) => {
|
|
125
|
+
if (path.length < 2) {
|
|
126
|
+
return Promise.resolve({
|
|
127
|
+
data: null,
|
|
128
|
+
error: {
|
|
129
|
+
code: "TransportError" as const,
|
|
130
|
+
data: {
|
|
131
|
+
message: `Incomplete path: api.${path.join(".") || "?"}(…)`,
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
// `api.bookings.create` → unit `bookings`, flow `create`
|
|
137
|
+
const unit = path[0]!;
|
|
138
|
+
const flow = path.slice(1).join(".");
|
|
139
|
+
return transport.call(`${unit}/${flow}`, input);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
return new Proxy(call, {
|
|
143
|
+
get(_target, prop, receiver) {
|
|
144
|
+
if (typeof prop === "symbol") {
|
|
145
|
+
return Reflect.get(_target, prop, receiver);
|
|
146
|
+
}
|
|
147
|
+
// Prevent `await api.notes` from treating the proxy as a Thenable.
|
|
148
|
+
if (prop === "then") return undefined;
|
|
149
|
+
return proxy(transport, [...path, prop]);
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed error narrowing for the client result envelope.
|
|
3
|
+
*
|
|
4
|
+
* Flow failures are values (`{ data: null, error }`). Narrow with
|
|
5
|
+
* `error.code === "FlightFull"` — TypeScript then knows `error.data`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ClientResult, TransportError } from "./types.ts";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* True when `error` is a transport / protocol failure.
|
|
12
|
+
*
|
|
13
|
+
* @param error - Client error value
|
|
14
|
+
*/
|
|
15
|
+
export function isTransportError(
|
|
16
|
+
error: { readonly code: string; readonly data?: unknown } | null | undefined,
|
|
17
|
+
): error is TransportError {
|
|
18
|
+
return error?.code === "TransportError";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Narrow a client error to one declared code.
|
|
23
|
+
*
|
|
24
|
+
* Prefer `error?.code === "FlightFull"` for inference; use this when
|
|
25
|
+
* you need a type predicate in a helper.
|
|
26
|
+
*
|
|
27
|
+
* @param error - Error value from a {@link ClientResult}
|
|
28
|
+
* @param code - Declared error code
|
|
29
|
+
*/
|
|
30
|
+
export function isErrorCode<
|
|
31
|
+
Err extends { readonly code: string; readonly data: unknown },
|
|
32
|
+
C extends Err["code"],
|
|
33
|
+
>(
|
|
34
|
+
error: Err | null | undefined,
|
|
35
|
+
code: C,
|
|
36
|
+
): error is Extract<Err, { readonly code: C }> {
|
|
37
|
+
return error != null && error.code === code;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* True when the result is a failure (flow or transport).
|
|
42
|
+
*
|
|
43
|
+
* @param result - Client call result
|
|
44
|
+
*/
|
|
45
|
+
export function isFail<O, E extends Record<string, unknown>>(
|
|
46
|
+
result: ClientResult<O, E>,
|
|
47
|
+
): result is Extract<ClientResult<O, E>, { readonly data: null }> {
|
|
48
|
+
return result.error !== null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* True when the result is a success.
|
|
53
|
+
*
|
|
54
|
+
* @param result - Client call result
|
|
55
|
+
*/
|
|
56
|
+
export function isOk<O, E extends Record<string, unknown>>(
|
|
57
|
+
result: ClientResult<O, E>,
|
|
58
|
+
): result is Extract<ClientResult<O, E>, { readonly error: null }> {
|
|
59
|
+
return result.error === null;
|
|
60
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed client (+ live). Subpath: `okengine/client`.
|
|
3
|
+
*
|
|
4
|
+
* First Manifest derivation: `type App` → fully typed client, zero codegen.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { createClient, flattenRoutes } from "./create.ts";
|
|
8
|
+
export type { AppWithRoutes } from "./create.ts";
|
|
9
|
+
export {
|
|
10
|
+
isErrorCode,
|
|
11
|
+
isFail,
|
|
12
|
+
isOk,
|
|
13
|
+
isTransportError,
|
|
14
|
+
} from "./errors.ts";
|
|
15
|
+
export { createTransport } from "./transport.ts";
|
|
16
|
+
export type { Transport } from "./transport.ts";
|
|
17
|
+
export type {
|
|
18
|
+
AppOf,
|
|
19
|
+
Client,
|
|
20
|
+
ClientApp,
|
|
21
|
+
ClientCall,
|
|
22
|
+
ClientDescriptor,
|
|
23
|
+
ClientError,
|
|
24
|
+
ClientFetch,
|
|
25
|
+
ClientFromRoutes,
|
|
26
|
+
ClientHeaders,
|
|
27
|
+
ClientOptions,
|
|
28
|
+
ClientResult,
|
|
29
|
+
ClientRouteMap,
|
|
30
|
+
FlowContract,
|
|
31
|
+
Register,
|
|
32
|
+
ResolveApp,
|
|
33
|
+
RoutesOf,
|
|
34
|
+
TransportError,
|
|
35
|
+
} from "./types.ts";
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notes contract — `typeof app` → typed client (Prompt 8.1).
|
|
3
|
+
*
|
|
4
|
+
* Proves: adopt accumulates routes · REST from trigger · error narrowing ·
|
|
5
|
+
* removing a flow from adopt removes it from the client type.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { beforeEach, describe, expect, test } from "bun:test";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { oke } from "../kernel/app.ts";
|
|
11
|
+
import { flow, resetFlowSeq } from "../kernel/flow.ts";
|
|
12
|
+
import { on, resetBindings } from "../kernel/on.ts";
|
|
13
|
+
import { http } from "../kernel/triggers.ts";
|
|
14
|
+
import { createClient } from "./create.ts";
|
|
15
|
+
import type { Client } from "./types.ts";
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
resetBindings();
|
|
19
|
+
resetFlowSeq();
|
|
20
|
+
});
|
|
21
|
+
|
|
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;
|
|
27
|
+
type Assert<T extends true> = T;
|
|
28
|
+
|
|
29
|
+
const NoteId = z.object({ id: z.string() });
|
|
30
|
+
const Note = z.object({
|
|
31
|
+
id: z.string(),
|
|
32
|
+
title: z.string(),
|
|
33
|
+
body: z.string(),
|
|
34
|
+
});
|
|
35
|
+
const NewNote = z.object({
|
|
36
|
+
title: z.string(),
|
|
37
|
+
body: z.string(),
|
|
38
|
+
});
|
|
39
|
+
const NotFound = z.object({});
|
|
40
|
+
|
|
41
|
+
const create = on(
|
|
42
|
+
http.post("/notes"),
|
|
43
|
+
flow({
|
|
44
|
+
in: NewNote,
|
|
45
|
+
out: NoteId,
|
|
46
|
+
do: (input) => ({ id: `n_${input.title}` }),
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const get = on(
|
|
51
|
+
http.get("/notes/:id"),
|
|
52
|
+
flow({
|
|
53
|
+
in: NoteId,
|
|
54
|
+
out: Note,
|
|
55
|
+
errors: { NotFound },
|
|
56
|
+
do: ({ id }, fx) =>
|
|
57
|
+
id === "missing"
|
|
58
|
+
? fx.fail("NotFound", {})
|
|
59
|
+
: { id, title: "First", body: "Hello" },
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const notes = { create, get } as const;
|
|
64
|
+
|
|
65
|
+
describe("Notes — typeof app carries contracts", () => {
|
|
66
|
+
test("four-applications client block typechecks without AppOf<>", () => {
|
|
67
|
+
const app = oke({ name: "notes" }).adopt({ notes });
|
|
68
|
+
type App = typeof app;
|
|
69
|
+
|
|
70
|
+
// Exactly the Notes client shape — types from App alone, no AppOf.
|
|
71
|
+
const api = createClient<App>("http://localhost:6530");
|
|
72
|
+
|
|
73
|
+
type GetResult = Awaited<ReturnType<typeof api.notes.get>>;
|
|
74
|
+
type GetError = NonNullable<GetResult["error"]>;
|
|
75
|
+
type NotFoundData = Extract<GetError, { code: "NotFound" }>["data"];
|
|
76
|
+
type SuccessTitle = Extract<GetResult, { error: null }>["data"]["title"];
|
|
77
|
+
|
|
78
|
+
type _Err = Assert<Eq<NotFoundData, Record<string, never>>>;
|
|
79
|
+
type _Title = Assert<Eq<SuccessTitle, string>>;
|
|
80
|
+
const ok: [_Err, _Title] = [true, true];
|
|
81
|
+
expect(ok).toEqual([true, true]);
|
|
82
|
+
expect(typeof api.notes.get).toBe("function");
|
|
83
|
+
expect(typeof api.notes.create).toBe("function");
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("Notes client block: createClient<App> narrows data and NotFound", async () => {
|
|
87
|
+
const app = oke({ name: "notes" }).adopt({ notes });
|
|
88
|
+
type App = typeof app;
|
|
89
|
+
|
|
90
|
+
// four-applications client shape — App from typeof app, no AppOf<>.
|
|
91
|
+
const api = createClient<App>("http://localhost:6530", {
|
|
92
|
+
$routes: app.$routes,
|
|
93
|
+
fetch: async (input, init) => {
|
|
94
|
+
const url = String(input);
|
|
95
|
+
const method = String(init?.method ?? "GET");
|
|
96
|
+
if (method === "GET" && url.endsWith("/notes/n_1")) {
|
|
97
|
+
return Response.json({
|
|
98
|
+
data: { id: "n_1", title: "First", body: "Hello" },
|
|
99
|
+
error: null,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (method === "GET" && url.endsWith("/notes/missing")) {
|
|
103
|
+
return Response.json(
|
|
104
|
+
{ data: null, error: { code: "NotFound", data: {} } },
|
|
105
|
+
{ status: 404 },
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
return Response.json(
|
|
109
|
+
{
|
|
110
|
+
data: null,
|
|
111
|
+
error: {
|
|
112
|
+
code: "TransportError",
|
|
113
|
+
data: { message: `${method} ${url}` },
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{ status: 500 },
|
|
117
|
+
);
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
{
|
|
122
|
+
const { data, error } = await api.notes.get({ id: "n_1" });
|
|
123
|
+
if (error?.code === "NotFound") {
|
|
124
|
+
type _Empty = Assert<
|
|
125
|
+
Eq<typeof error.data, Record<string, never>>
|
|
126
|
+
>;
|
|
127
|
+
const keep: _Empty = true;
|
|
128
|
+
expect(keep).toBe(true);
|
|
129
|
+
throw new Error("unexpected NotFound");
|
|
130
|
+
} else if (error) {
|
|
131
|
+
throw new Error(`unexpected ${error.code}`);
|
|
132
|
+
} else {
|
|
133
|
+
// Notes: else data.title — narrowed success
|
|
134
|
+
expect(data.title).toBe("First");
|
|
135
|
+
type _Title = Assert<Eq<typeof data.title, string>>;
|
|
136
|
+
const t: _Title = true;
|
|
137
|
+
expect(t).toBe(true);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
{
|
|
142
|
+
const { error } = await api.notes.get({ id: "missing" });
|
|
143
|
+
if (error?.code === "NotFound") {
|
|
144
|
+
type _D = Assert<Eq<typeof error.data, Record<string, never>>>;
|
|
145
|
+
const d: _D = true;
|
|
146
|
+
expect(d).toBe(true);
|
|
147
|
+
} else {
|
|
148
|
+
throw new Error("expected NotFound");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test("api.notes.get issues GET /notes/n_1, not RPC POST", async () => {
|
|
154
|
+
const app = oke({ name: "notes" }).adopt({ notes });
|
|
155
|
+
type App = typeof app;
|
|
156
|
+
|
|
157
|
+
let method = "";
|
|
158
|
+
let url = "";
|
|
159
|
+
const api = createClient<App>("http://app.test", {
|
|
160
|
+
$routes: app.$routes,
|
|
161
|
+
fetch: async (input, init) => {
|
|
162
|
+
url = String(input);
|
|
163
|
+
method = String(init?.method ?? "GET");
|
|
164
|
+
return Response.json({
|
|
165
|
+
data: { id: "n_1", title: "First", body: "Hello" },
|
|
166
|
+
error: null,
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
await api.notes.get({ id: "n_1" });
|
|
172
|
+
expect(method).toBe("GET");
|
|
173
|
+
expect(url).toBe("http://app.test/notes/n_1");
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test("createClient(app, url) wires REST from app.$routes", async () => {
|
|
177
|
+
const app = oke({ name: "notes" }).adopt({ notes });
|
|
178
|
+
|
|
179
|
+
let method = "";
|
|
180
|
+
let url = "";
|
|
181
|
+
const api = createClient(app, "http://app.test", {
|
|
182
|
+
fetch: async (input, init) => {
|
|
183
|
+
url = String(input);
|
|
184
|
+
method = String(init?.method ?? "GET");
|
|
185
|
+
return Response.json({
|
|
186
|
+
data: { id: "n_1", title: "Hi", body: "" },
|
|
187
|
+
error: null,
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
await api.notes.get({ id: "n_1" });
|
|
193
|
+
expect(method).toBe("GET");
|
|
194
|
+
expect(url).toBe("http://app.test/notes/n_1");
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test("POST create uses REST /notes from trigger", async () => {
|
|
198
|
+
const app = oke({ name: "notes" }).adopt({ notes });
|
|
199
|
+
let method = "";
|
|
200
|
+
let url = "";
|
|
201
|
+
let body = "";
|
|
202
|
+
const api = createClient(app, "http://app.test", {
|
|
203
|
+
fetch: async (input, init) => {
|
|
204
|
+
url = String(input);
|
|
205
|
+
method = String(init?.method ?? "GET");
|
|
206
|
+
body = String(init?.body ?? "");
|
|
207
|
+
return Response.json({ data: { id: "n_1" }, error: null });
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
await api.notes.create({ title: "First", body: "Hello" });
|
|
212
|
+
expect(method).toBe("POST");
|
|
213
|
+
expect(url).toBe("http://app.test/notes");
|
|
214
|
+
expect(JSON.parse(body)).toEqual({ title: "First", body: "Hello" });
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test("runtime $routes carries method/path literals from triggers", () => {
|
|
218
|
+
const app = oke({ name: "notes" }).adopt({ notes });
|
|
219
|
+
expect(app.$routes.notes.get).toEqual({
|
|
220
|
+
method: "GET",
|
|
221
|
+
path: "/notes/:id",
|
|
222
|
+
});
|
|
223
|
+
expect(app.$routes.notes.create).toEqual({
|
|
224
|
+
method: "POST",
|
|
225
|
+
path: "/notes",
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
type App = typeof app;
|
|
229
|
+
type GetMethod = App["$routes"]["notes"]["get"]["method"];
|
|
230
|
+
type GetPath = App["$routes"]["notes"]["get"]["path"];
|
|
231
|
+
type _M = Assert<Eq<GetMethod, "GET">>;
|
|
232
|
+
type _P = Assert<Eq<GetPath, "/notes/:id">>;
|
|
233
|
+
const ok: [_M, _P] = [true, true];
|
|
234
|
+
expect(ok).toEqual([true, true]);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
test("removing a flow from adopt removes it from the client type", () => {
|
|
238
|
+
const full = oke({ name: "notes" }).adopt({ notes });
|
|
239
|
+
const createOnly = oke({ name: "notes" }).adopt({
|
|
240
|
+
notes: { create: notes.create },
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
type FullClient = Client<typeof full>;
|
|
244
|
+
type PartialClient = Client<typeof createOnly>;
|
|
245
|
+
|
|
246
|
+
type FullHasGet = "get" extends keyof FullClient["notes"] ? true : false;
|
|
247
|
+
type PartialHasGet = "get" extends keyof PartialClient["notes"]
|
|
248
|
+
? true
|
|
249
|
+
: false;
|
|
250
|
+
|
|
251
|
+
type _Full = Assert<Eq<FullHasGet, true>>;
|
|
252
|
+
type _Part = Assert<Eq<PartialHasGet, false>>;
|
|
253
|
+
const checks: [_Full, _Part] = [true, true];
|
|
254
|
+
expect(checks).toEqual([true, true]);
|
|
255
|
+
|
|
256
|
+
// Runtime table matches.
|
|
257
|
+
expect("get" in full.$routes.notes).toBe(true);
|
|
258
|
+
expect("get" in createOnly.$routes.notes).toBe(false);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
test("untriggered adopted flow is RPC-only on the client", async () => {
|
|
262
|
+
const stats = flow({
|
|
263
|
+
name: "notes.stats",
|
|
264
|
+
in: NoteId,
|
|
265
|
+
out: z.object({ clicks: z.number() }),
|
|
266
|
+
do: () => ({ clicks: 7 }),
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
const app = oke({ name: "notes" }).adopt({
|
|
270
|
+
notes: { create, get, stats },
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
expect(app.$routes.notes.stats).toEqual({});
|
|
274
|
+
|
|
275
|
+
let url = "";
|
|
276
|
+
let method = "";
|
|
277
|
+
const api = createClient(app, "http://app.test", {
|
|
278
|
+
fetch: async (input, init) => {
|
|
279
|
+
url = String(input);
|
|
280
|
+
method = String(init?.method ?? "GET");
|
|
281
|
+
return Response.json({ data: { clicks: 7 }, error: null });
|
|
282
|
+
},
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
await api.notes.stats({ id: "n_1" });
|
|
286
|
+
expect(method).toBe("POST");
|
|
287
|
+
expect(url).toBe("http://app.test/_oke/notes/stats");
|
|
288
|
+
});
|
|
289
|
+
});
|