@workerstack/clients 0.0.0-stage → 1.0.0-rc.23
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/LICENSE +21 -0
- package/README.md +619 -2
- package/bin/honey-clients.js +94 -0
- package/dist/cli.d.ts +102 -0
- package/dist/cli.js +190 -0
- package/dist/emit/cli/channels.d.ts +73 -0
- package/dist/emit/cli/channels.js +197 -0
- package/dist/emit/cli/commands.d.ts +27 -0
- package/dist/emit/cli/commands.js +187 -0
- package/dist/emit/cli/discovery.d.ts +35 -0
- package/dist/emit/cli/discovery.js +202 -0
- package/dist/emit/cli/flags.d.ts +59 -0
- package/dist/emit/cli/flags.js +186 -0
- package/dist/emit/cli/index.d.ts +1 -0
- package/dist/emit/cli/index.js +1 -0
- package/dist/emit/cli/install.d.ts +37 -0
- package/dist/emit/cli/install.js +88 -0
- package/dist/emit/cli/layout.d.ts +23 -0
- package/dist/emit/cli/layout.js +118 -0
- package/dist/emit/cli/module.d.ts +30 -0
- package/dist/emit/cli/module.js +186 -0
- package/dist/emit/cli/release.d.ts +40 -0
- package/dist/emit/cli/release.js +183 -0
- package/dist/emit/cli/skills.d.ts +11 -0
- package/dist/emit/cli/skills.js +56 -0
- package/dist/emit/csharp/errors.d.ts +7 -0
- package/dist/emit/csharp/errors.js +69 -0
- package/dist/emit/csharp/index.d.ts +1 -0
- package/dist/emit/csharp/index.js +1 -0
- package/dist/emit/csharp/json.d.ts +13 -0
- package/dist/emit/csharp/json.js +113 -0
- package/dist/emit/csharp/realtime.d.ts +10 -0
- package/dist/emit/csharp/realtime.js +33 -0
- package/dist/emit/csharp/sdk-answer.d.ts +48 -0
- package/dist/emit/csharp/sdk-answer.js +85 -0
- package/dist/emit/csharp/sdk-body.d.ts +10 -0
- package/dist/emit/csharp/sdk-body.js +87 -0
- package/dist/emit/csharp/sdk-client.d.ts +32 -0
- package/dist/emit/csharp/sdk-client.js +177 -0
- package/dist/emit/csharp/sdk-csproj.d.ts +36 -0
- package/dist/emit/csharp/sdk-csproj.js +136 -0
- package/dist/emit/csharp/sdk-doc.d.ts +12 -0
- package/dist/emit/csharp/sdk-doc.js +35 -0
- package/dist/emit/csharp/sdk-method.d.ts +26 -0
- package/dist/emit/csharp/sdk-method.js +187 -0
- package/dist/emit/csharp/sdk-plan.d.ts +38 -0
- package/dist/emit/csharp/sdk-plan.js +1 -0
- package/dist/emit/csharp/sdk.d.ts +40 -0
- package/dist/emit/csharp/sdk.js +105 -0
- package/dist/emit/csharp/sse.d.ts +18 -0
- package/dist/emit/csharp/sse.js +29 -0
- package/dist/emit/csharp/transport.d.ts +11 -0
- package/dist/emit/csharp/transport.js +67 -0
- package/dist/emit/csharp/types-enum.d.ts +19 -0
- package/dist/emit/csharp/types-enum.js +63 -0
- package/dist/emit/csharp/types-names.d.ts +33 -0
- package/dist/emit/csharp/types-names.js +182 -0
- package/dist/emit/csharp/types-record.d.ts +25 -0
- package/dist/emit/csharp/types-record.js +65 -0
- package/dist/emit/csharp/types-union.d.ts +27 -0
- package/dist/emit/csharp/types-union.js +113 -0
- package/dist/emit/csharp/types.d.ts +36 -0
- package/dist/emit/csharp/types.js +126 -0
- package/dist/emit/csharp/ws.d.ts +20 -0
- package/dist/emit/csharp/ws.js +14 -0
- package/dist/emit/go/errors.d.ts +7 -0
- package/dist/emit/go/errors.js +44 -0
- package/dist/emit/go/http.d.ts +11 -0
- package/dist/emit/go/http.js +50 -0
- package/dist/emit/go/index.d.ts +1 -0
- package/dist/emit/go/index.js +1 -0
- package/dist/emit/go/module-path.d.ts +2 -0
- package/dist/emit/go/module-path.js +27 -0
- package/dist/emit/go/sdk-answer.d.ts +28 -0
- package/dist/emit/go/sdk-answer.js +41 -0
- package/dist/emit/go/sdk-body.d.ts +24 -0
- package/dist/emit/go/sdk-body.js +76 -0
- package/dist/emit/go/sdk-client.d.ts +29 -0
- package/dist/emit/go/sdk-client.js +141 -0
- package/dist/emit/go/sdk-method.d.ts +68 -0
- package/dist/emit/go/sdk-method.js +172 -0
- package/dist/emit/go/sdk-mirror.d.ts +23 -0
- package/dist/emit/go/sdk-mirror.js +97 -0
- package/dist/emit/go/sdk-opts.d.ts +55 -0
- package/dist/emit/go/sdk-opts.js +100 -0
- package/dist/emit/go/sdk.d.ts +26 -0
- package/dist/emit/go/sdk.js +111 -0
- package/dist/emit/go/sse.d.ts +16 -0
- package/dist/emit/go/sse.js +26 -0
- package/dist/emit/go/types-codec.d.ts +15 -0
- package/dist/emit/go/types-codec.js +171 -0
- package/dist/emit/go/types-names.d.ts +14 -0
- package/dist/emit/go/types-names.js +64 -0
- package/dist/emit/go/types-struct.d.ts +29 -0
- package/dist/emit/go/types-struct.js +65 -0
- package/dist/emit/go/types-union.d.ts +17 -0
- package/dist/emit/go/types-union.js +84 -0
- package/dist/emit/go/types.d.ts +32 -0
- package/dist/emit/go/types.js +177 -0
- package/dist/emit/go/ws.d.ts +12 -0
- package/dist/emit/go/ws.js +70 -0
- package/dist/emit/java/gradle.d.ts +57 -0
- package/dist/emit/java/gradle.js +221 -0
- package/dist/emit/java/index.d.ts +2 -0
- package/dist/emit/java/index.js +2 -0
- package/dist/emit/java/json.d.ts +13 -0
- package/dist/emit/java/json.js +84 -0
- package/dist/emit/java/layout-ast.d.ts +146 -0
- package/dist/emit/java/layout-ast.js +102 -0
- package/dist/emit/java/layout-decl.d.ts +20 -0
- package/dist/emit/java/layout-decl.js +155 -0
- package/dist/emit/java/layout-doc.d.ts +55 -0
- package/dist/emit/java/layout-doc.js +166 -0
- package/dist/emit/java/layout-dot.d.ts +18 -0
- package/dist/emit/java/layout-dot.js +127 -0
- package/dist/emit/java/layout-strings.d.ts +8 -0
- package/dist/emit/java/layout-strings.js +76 -0
- package/dist/emit/java/layout-types.d.ts +11 -0
- package/dist/emit/java/layout-types.js +95 -0
- package/dist/emit/java/layout-visitor.d.ts +38 -0
- package/dist/emit/java/layout-visitor.js +232 -0
- package/dist/emit/java/layout.d.ts +61 -0
- package/dist/emit/java/layout.js +121 -0
- package/dist/emit/java/models-enum.d.ts +17 -0
- package/dist/emit/java/models-enum.js +51 -0
- package/dist/emit/java/models-names.d.ts +29 -0
- package/dist/emit/java/models-names.js +97 -0
- package/dist/emit/java/models-record.d.ts +24 -0
- package/dist/emit/java/models-record.js +79 -0
- package/dist/emit/java/models-union.d.ts +27 -0
- package/dist/emit/java/models-union.js +86 -0
- package/dist/emit/java/models.d.ts +28 -0
- package/dist/emit/java/models.js +118 -0
- package/dist/emit/java/realtime.d.ts +50 -0
- package/dist/emit/java/realtime.js +69 -0
- package/dist/emit/java/sdk-client.d.ts +66 -0
- package/dist/emit/java/sdk-client.js +207 -0
- package/dist/emit/java/sdk-decl.d.ts +11 -0
- package/dist/emit/java/sdk-decl.js +63 -0
- package/dist/emit/java/sdk-errors.d.ts +13 -0
- package/dist/emit/java/sdk-errors.js +141 -0
- package/dist/emit/java/sdk-headers.d.ts +12 -0
- package/dist/emit/java/sdk-headers.js +74 -0
- package/dist/emit/java/sdk-mirror.d.ts +14 -0
- package/dist/emit/java/sdk-mirror.js +107 -0
- package/dist/emit/java/sdk-models.d.ts +16 -0
- package/dist/emit/java/sdk-models.js +68 -0
- package/dist/emit/java/sdk-op.d.ts +57 -0
- package/dist/emit/java/sdk-op.js +216 -0
- package/dist/emit/java/sdk-params.d.ts +38 -0
- package/dist/emit/java/sdk-params.js +133 -0
- package/dist/emit/java/sdk-plan.d.ts +52 -0
- package/dist/emit/java/sdk-plan.js +1 -0
- package/dist/emit/java/sdk-record.d.ts +16 -0
- package/dist/emit/java/sdk-record.js +99 -0
- package/dist/emit/java/sdk.d.ts +49 -0
- package/dist/emit/java/sdk.js +216 -0
- package/dist/emit/java/sse.d.ts +35 -0
- package/dist/emit/java/sse.js +57 -0
- package/dist/emit/java/ws.d.ts +27 -0
- package/dist/emit/java/ws.js +31 -0
- package/dist/emit/mcp/annotations.d.ts +15 -0
- package/dist/emit/mcp/annotations.js +15 -0
- package/dist/emit/mcp/files.d.ts +18 -0
- package/dist/emit/mcp/files.js +42 -0
- package/dist/emit/mcp/index.d.ts +3 -0
- package/dist/emit/mcp/index.js +3 -0
- package/dist/emit/mcp/literal.d.ts +2 -0
- package/dist/emit/mcp/literal.js +33 -0
- package/dist/emit/mcp/mounted.d.ts +21 -0
- package/dist/emit/mcp/mounted.js +89 -0
- package/dist/emit/mcp/output-schema.d.ts +18 -0
- package/dist/emit/mcp/output-schema.js +38 -0
- package/dist/emit/mcp/registry.d.ts +23 -0
- package/dist/emit/mcp/registry.js +83 -0
- package/dist/emit/mcp/runtime.d.ts +10 -0
- package/dist/emit/mcp/runtime.js +47 -0
- package/dist/emit/mcp/schema.d.ts +19 -0
- package/dist/emit/mcp/schema.js +88 -0
- package/dist/emit/mcp/server.d.ts +30 -0
- package/dist/emit/mcp/server.js +246 -0
- package/dist/emit/mcp/tools.d.ts +51 -0
- package/dist/emit/mcp/tools.js +153 -0
- package/dist/emit/python/errors.d.ts +8 -0
- package/dist/emit/python/errors.js +68 -0
- package/dist/emit/python/index.d.ts +1 -0
- package/dist/emit/python/index.js +1 -0
- package/dist/emit/python/realtime.d.ts +10 -0
- package/dist/emit/python/realtime.js +33 -0
- package/dist/emit/python/sdk-answer.d.ts +49 -0
- package/dist/emit/python/sdk-answer.js +89 -0
- package/dist/emit/python/sdk-body.d.ts +11 -0
- package/dist/emit/python/sdk-body.js +40 -0
- package/dist/emit/python/sdk-client.d.ts +36 -0
- package/dist/emit/python/sdk-client.js +163 -0
- package/dist/emit/python/sdk-doc.d.ts +9 -0
- package/dist/emit/python/sdk-doc.js +32 -0
- package/dist/emit/python/sdk-imports.d.ts +14 -0
- package/dist/emit/python/sdk-imports.js +38 -0
- package/dist/emit/python/sdk-method.d.ts +29 -0
- package/dist/emit/python/sdk-method.js +183 -0
- package/dist/emit/python/sdk-plan.d.ts +33 -0
- package/dist/emit/python/sdk-plan.js +1 -0
- package/dist/emit/python/sdk-pyproject.d.ts +27 -0
- package/dist/emit/python/sdk-pyproject.js +103 -0
- package/dist/emit/python/sdk.d.ts +22 -0
- package/dist/emit/python/sdk.js +154 -0
- package/dist/emit/python/sse.d.ts +12 -0
- package/dist/emit/python/sse.js +23 -0
- package/dist/emit/python/transport.d.ts +15 -0
- package/dist/emit/python/transport.js +60 -0
- package/dist/emit/python/types-dict.d.ts +31 -0
- package/dist/emit/python/types-dict.js +45 -0
- package/dist/emit/python/types-names.d.ts +16 -0
- package/dist/emit/python/types-names.js +52 -0
- package/dist/emit/python/types-union.d.ts +32 -0
- package/dist/emit/python/types-union.js +46 -0
- package/dist/emit/python/types.d.ts +36 -0
- package/dist/emit/python/types.js +128 -0
- package/dist/emit/python/ws.d.ts +14 -0
- package/dist/emit/python/ws.js +16 -0
- package/dist/emit/rust/errors.d.ts +7 -0
- package/dist/emit/rust/errors.js +107 -0
- package/dist/emit/rust/http.d.ts +13 -0
- package/dist/emit/rust/http.js +67 -0
- package/dist/emit/rust/index.d.ts +1 -0
- package/dist/emit/rust/index.js +1 -0
- package/dist/emit/rust/realtime.d.ts +11 -0
- package/dist/emit/rust/realtime.js +29 -0
- package/dist/emit/rust/sdk-body.d.ts +19 -0
- package/dist/emit/rust/sdk-body.js +53 -0
- package/dist/emit/rust/sdk-cargo.d.ts +43 -0
- package/dist/emit/rust/sdk-cargo.js +178 -0
- package/dist/emit/rust/sdk-client.d.ts +25 -0
- package/dist/emit/rust/sdk-client.js +108 -0
- package/dist/emit/rust/sdk-method.d.ts +15 -0
- package/dist/emit/rust/sdk-method.js +119 -0
- package/dist/emit/rust/sdk-opts.d.ts +58 -0
- package/dist/emit/rust/sdk-opts.js +117 -0
- package/dist/emit/rust/sdk-plan.d.ts +33 -0
- package/dist/emit/rust/sdk-plan.js +1 -0
- package/dist/emit/rust/sdk.d.ts +23 -0
- package/dist/emit/rust/sdk.js +111 -0
- package/dist/emit/rust/sse.d.ts +19 -0
- package/dist/emit/rust/sse.js +20 -0
- package/dist/emit/rust/types-enum.d.ts +13 -0
- package/dist/emit/rust/types-enum.js +62 -0
- package/dist/emit/rust/types-names.d.ts +19 -0
- package/dist/emit/rust/types-names.js +66 -0
- package/dist/emit/rust/types-struct.d.ts +21 -0
- package/dist/emit/rust/types-struct.js +59 -0
- package/dist/emit/rust/types-union.d.ts +24 -0
- package/dist/emit/rust/types-union.js +97 -0
- package/dist/emit/rust/types.d.ts +34 -0
- package/dist/emit/rust/types.js +105 -0
- package/dist/emit/rust/ws.d.ts +21 -0
- package/dist/emit/rust/ws.js +20 -0
- package/dist/emit/shared/escape.d.ts +55 -0
- package/dist/emit/shared/escape.js +144 -0
- package/dist/emit/shared/format.d.ts +24 -0
- package/dist/emit/shared/format.js +23 -0
- package/dist/emit/shared/gofmt.d.ts +3 -0
- package/dist/emit/shared/gofmt.js +26 -0
- package/dist/emit/shared/lang.d.ts +60 -0
- package/dist/emit/shared/lang.js +233 -0
- package/dist/emit/shared/literals.d.ts +4 -0
- package/dist/emit/shared/literals.js +31 -0
- package/dist/emit/shared/metadata.d.ts +106 -0
- package/dist/emit/shared/metadata.js +130 -0
- package/dist/emit/shared/mirror.d.ts +22 -0
- package/dist/emit/shared/mirror.js +26 -0
- package/dist/emit/shared/ruff.d.ts +3 -0
- package/dist/emit/shared/ruff.js +31 -0
- package/dist/emit/shared/rustfmt.d.ts +3 -0
- package/dist/emit/shared/rustfmt.js +32 -0
- package/dist/emit/shared/status-keys.d.ts +7 -0
- package/dist/emit/shared/status-keys.js +67 -0
- package/dist/emit/shared/type-emitter.d.ts +19 -0
- package/dist/emit/shared/type-emitter.js +100 -0
- package/dist/emit/ts/app-client.d.ts +4 -0
- package/dist/emit/ts/app-client.js +68 -0
- package/dist/emit/ts/http.d.ts +20 -0
- package/dist/emit/ts/http.js +74 -0
- package/dist/emit/ts/package.d.ts +36 -0
- package/dist/emit/ts/package.js +126 -0
- package/dist/emit/ts/route-tree.d.ts +68 -0
- package/dist/emit/ts/route-tree.js +240 -0
- package/dist/emit/ts/sdk-types-preamble.d.ts +14 -0
- package/dist/emit/ts/sdk-types-preamble.js +123 -0
- package/dist/emit/ts/sdk-types.d.ts +13 -0
- package/dist/emit/ts/sdk-types.js +213 -0
- package/dist/emit/ts/sdk.d.ts +21 -0
- package/dist/emit/ts/sdk.js +173 -0
- package/dist/emit/ts/service-map.d.ts +40 -0
- package/dist/emit/ts/service-map.js +171 -0
- package/dist/emit/ts/tanstack-query.d.ts +12 -0
- package/dist/emit/ts/tanstack-query.js +156 -0
- package/dist/emit/ts/type-gen.d.ts +26 -0
- package/dist/emit/ts/type-gen.js +255 -0
- package/dist/emit/ts/webhooks.d.ts +19 -0
- package/dist/emit/ts/webhooks.js +81 -0
- package/dist/extract/chain.d.ts +34 -0
- package/dist/extract/chain.js +84 -0
- package/dist/extract/extract.d.ts +41 -0
- package/dist/extract/extract.js +191 -0
- package/dist/extract/serialize.d.ts +34 -0
- package/dist/extract/serialize.js +295 -0
- package/dist/extract/walk.d.ts +47 -0
- package/dist/extract/walk.js +109 -0
- package/dist/gen/args.d.ts +28 -0
- package/dist/gen/args.js +133 -0
- package/dist/gen/formatters.d.ts +62 -0
- package/dist/gen/formatters.js +146 -0
- package/dist/gen/process.d.ts +13 -0
- package/dist/gen/process.js +35 -0
- package/dist/gen/shipped.d.ts +17 -0
- package/dist/gen/shipped.js +55 -0
- package/dist/gen/targets.d.ts +93 -0
- package/dist/gen/targets.js +171 -0
- package/dist/gen/write.d.ts +33 -0
- package/dist/gen/write.js +118 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +15 -0
- package/dist/ir/build.d.ts +37 -0
- package/dist/ir/build.js +152 -0
- package/dist/ir/load.d.ts +11 -0
- package/dist/ir/load.js +112 -0
- package/dist/ir/model.d.ts +206 -0
- package/dist/ir/model.js +5 -0
- package/dist/ir/resolve-refs.d.ts +11 -0
- package/dist/ir/resolve-refs.js +66 -0
- package/dist/ir/resource-tree.d.ts +9 -0
- package/dist/ir/resource-tree.js +53 -0
- package/dist/ir/route-tree-intern.d.ts +18 -0
- package/dist/ir/route-tree-intern.js +174 -0
- package/dist/ir/schema.d.ts +11 -0
- package/dist/ir/schema.js +192 -0
- package/dist/ir/sdk-model.d.ts +86 -0
- package/dist/ir/sdk-model.js +204 -0
- package/dist/ir/slots.d.ts +42 -0
- package/dist/ir/slots.js +245 -0
- package/dist/runtime/cli/body.go +176 -0
- package/dist/runtime/cli/config.go +243 -0
- package/dist/runtime/cli/discovery.go +147 -0
- package/dist/runtime/cli/format.go +174 -0
- package/dist/runtime/cli/log.go +117 -0
- package/dist/runtime/cli/output.go +247 -0
- package/dist/runtime/cli/params.go +197 -0
- package/dist/runtime/cli/run.go +226 -0
- package/dist/runtime/cli/socket.go +60 -0
- package/dist/runtime/cli/stream.go +217 -0
- package/dist/runtime/cli/target.go +117 -0
- package/dist/runtime/csharp/Adapters.cs +183 -0
- package/dist/runtime/csharp/Auth.cs +56 -0
- package/dist/runtime/csharp/Body.cs +135 -0
- package/dist/runtime/csharp/Config.cs +161 -0
- package/dist/runtime/csharp/Envelope.cs +149 -0
- package/dist/runtime/csharp/Errors.cs +194 -0
- package/dist/runtime/csharp/Events.cs +155 -0
- package/dist/runtime/csharp/Exchange.cs +247 -0
- package/dist/runtime/csharp/Handler.cs +103 -0
- package/dist/runtime/csharp/Hooks.cs +128 -0
- package/dist/runtime/csharp/Invalidation.cs +102 -0
- package/dist/runtime/csharp/Json.cs +144 -0
- package/dist/runtime/csharp/Log.cs +48 -0
- package/dist/runtime/csharp/Operation.cs +33 -0
- package/dist/runtime/csharp/Path.cs +65 -0
- package/dist/runtime/csharp/Query.cs +72 -0
- package/dist/runtime/csharp/Realtime.cs +118 -0
- package/dist/runtime/csharp/RealtimeLoop.cs +236 -0
- package/dist/runtime/csharp/Redirect.cs +53 -0
- package/dist/runtime/csharp/Result.cs +57 -0
- package/dist/runtime/csharp/Sse.cs +122 -0
- package/dist/runtime/csharp/Stale.cs +151 -0
- package/dist/runtime/csharp/Transport.cs +143 -0
- package/dist/runtime/csharp/TransportLongPoll.cs +63 -0
- package/dist/runtime/csharp/TransportSse.cs +54 -0
- package/dist/runtime/csharp/TransportWs.cs +40 -0
- package/dist/runtime/csharp/Wire.cs +109 -0
- package/dist/runtime/csharp/Ws.cs +300 -0
- package/dist/runtime/csharp/WsDial.cs +127 -0
- package/dist/runtime/go/auth.go +127 -0
- package/dist/runtime/go/body.go +129 -0
- package/dist/runtime/go/config.go +75 -0
- package/dist/runtime/go/errors.go +185 -0
- package/dist/runtime/go/export.go +37 -0
- package/dist/runtime/go/hooks.go +53 -0
- package/dist/runtime/go/invalidation.go +112 -0
- package/dist/runtime/go/log.go +92 -0
- package/dist/runtime/go/nullable.go +64 -0
- package/dist/runtime/go/options.go +118 -0
- package/dist/runtime/go/path.go +156 -0
- package/dist/runtime/go/query.go +147 -0
- package/dist/runtime/go/realtime.go +239 -0
- package/dist/runtime/go/realtime_loop.go +208 -0
- package/dist/runtime/go/redirect.go +124 -0
- package/dist/runtime/go/request.go +222 -0
- package/dist/runtime/go/result.go +86 -0
- package/dist/runtime/go/sse.go +186 -0
- package/dist/runtime/go/stale.go +229 -0
- package/dist/runtime/go/stream.go +105 -0
- package/dist/runtime/go/transport.go +242 -0
- package/dist/runtime/go/transport_longpoll.go +121 -0
- package/dist/runtime/go/transport_sse.go +175 -0
- package/dist/runtime/go/ws.go +205 -0
- package/dist/runtime/java/Answer.java +107 -0
- package/dist/runtime/java/ApiException.java +110 -0
- package/dist/runtime/java/BinaryBody.java +36 -0
- package/dist/runtime/java/Body.java +105 -0
- package/dist/runtime/java/Call.java +23 -0
- package/dist/runtime/java/CallLog.java +51 -0
- package/dist/runtime/java/ClientConfig.java +233 -0
- package/dist/runtime/java/ConnectionState.java +12 -0
- package/dist/runtime/java/Credential.java +58 -0
- package/dist/runtime/java/Deadline.java +38 -0
- package/dist/runtime/java/Decode.java +181 -0
- package/dist/runtime/java/Envelope.java +141 -0
- package/dist/runtime/java/ErrorEnvelope.java +23 -0
- package/dist/runtime/java/EventStream.java +129 -0
- package/dist/runtime/java/Exchange.java +62 -0
- package/dist/runtime/java/FilePart.java +5 -0
- package/dist/runtime/java/Flight.java +306 -0
- package/dist/runtime/java/HoneyException.java +14 -0
- package/dist/runtime/java/Hooks.java +47 -0
- package/dist/runtime/java/Hops.java +133 -0
- package/dist/runtime/java/InvalidationConfig.java +73 -0
- package/dist/runtime/java/Json.java +23 -0
- package/dist/runtime/java/Keepalive.java +60 -0
- package/dist/runtime/java/LogEntry.java +14 -0
- package/dist/runtime/java/LongPollAdapter.java +68 -0
- package/dist/runtime/java/Operation.java +21 -0
- package/dist/runtime/java/Opt.java +121 -0
- package/dist/runtime/java/Pump.java +160 -0
- package/dist/runtime/java/RawResponse.java +48 -0
- package/dist/runtime/java/Realtime.java +152 -0
- package/dist/runtime/java/RealtimeLoop.java +371 -0
- package/dist/runtime/java/RedirectPolicy.java +13 -0
- package/dist/runtime/java/Redirects.java +126 -0
- package/dist/runtime/java/RequestContext.java +78 -0
- package/dist/runtime/java/RequestHook.java +9 -0
- package/dist/runtime/java/RequestOptions.java +91 -0
- package/dist/runtime/java/ResponseContext.java +70 -0
- package/dist/runtime/java/ResponseHook.java +12 -0
- package/dist/runtime/java/Result.java +32 -0
- package/dist/runtime/java/ResumableConnection.java +165 -0
- package/dist/runtime/java/SdkException.java +11 -0
- package/dist/runtime/java/Socket.java +301 -0
- package/dist/runtime/java/Sse.java +171 -0
- package/dist/runtime/java/SseAdapter.java +61 -0
- package/dist/runtime/java/SseEvent.java +10 -0
- package/dist/runtime/java/StaleMeta.java +16 -0
- package/dist/runtime/java/StaleTracker.java +287 -0
- package/dist/runtime/java/Transport.java +16 -0
- package/dist/runtime/java/TransportAdapter.java +14 -0
- package/dist/runtime/java/TransportConnection.java +15 -0
- package/dist/runtime/java/TransportKind.java +12 -0
- package/dist/runtime/java/TransportMessage.java +9 -0
- package/dist/runtime/java/TransportOptions.java +138 -0
- package/dist/runtime/java/TypedWebSocket.java +83 -0
- package/dist/runtime/java/UrlPath.java +49 -0
- package/dist/runtime/java/UrlQuery.java +99 -0
- package/dist/runtime/java/WsAdapter.java +52 -0
- package/dist/runtime/java/WsClose.java +47 -0
- package/dist/runtime/java/WsDial.java +148 -0
- package/dist/runtime/java/WsMessage.java +18 -0
- package/dist/runtime/mcp/call.ts +167 -0
- package/dist/runtime/mcp/files.ts +183 -0
- package/dist/runtime/mcp/guard.ts +176 -0
- package/dist/runtime/mcp/http.ts +159 -0
- package/dist/runtime/mcp/jsonrpc.ts +50 -0
- package/dist/runtime/mcp/listen.ts +76 -0
- package/dist/runtime/mcp/mount.ts +123 -0
- package/dist/runtime/mcp/protocol.ts +219 -0
- package/dist/runtime/mcp/reader.ts +57 -0
- package/dist/runtime/mcp/result.ts +85 -0
- package/dist/runtime/mcp/stdio.ts +79 -0
- package/dist/runtime/mcp/stream.ts +62 -0
- package/dist/runtime/python/__init__.py +2 -0
- package/dist/runtime/python/auth.py +67 -0
- package/dist/runtime/python/body.py +83 -0
- package/dist/runtime/python/config.py +139 -0
- package/dist/runtime/python/errors.py +213 -0
- package/dist/runtime/python/events.py +152 -0
- package/dist/runtime/python/exchange.py +298 -0
- package/dist/runtime/python/hooks.py +86 -0
- package/dist/runtime/python/invalidation.py +57 -0
- package/dist/runtime/python/log.py +60 -0
- package/dist/runtime/python/operation.py +25 -0
- package/dist/runtime/python/path.py +41 -0
- package/dist/runtime/python/query.py +48 -0
- package/dist/runtime/python/realtime.py +244 -0
- package/dist/runtime/python/redirect.py +93 -0
- package/dist/runtime/python/result.py +58 -0
- package/dist/runtime/python/send_async.py +189 -0
- package/dist/runtime/python/send_sync.py +105 -0
- package/dist/runtime/python/sse.py +81 -0
- package/dist/runtime/python/stale.py +94 -0
- package/dist/runtime/python/transport.py +157 -0
- package/dist/runtime/python/transport_longpoll.py +60 -0
- package/dist/runtime/python/transport_sse.py +60 -0
- package/dist/runtime/python/transport_ws.py +57 -0
- package/dist/runtime/python/ws.py +276 -0
- package/dist/runtime/rust/Cargo.lock +1763 -0
- package/dist/runtime/rust/answer.rs +120 -0
- package/dist/runtime/rust/auth.rs +80 -0
- package/dist/runtime/rust/body.rs +150 -0
- package/dist/runtime/rust/call.rs +200 -0
- package/dist/runtime/rust/config.rs +254 -0
- package/dist/runtime/rust/envelope.rs +84 -0
- package/dist/runtime/rust/errors.rs +235 -0
- package/dist/runtime/rust/events.rs +177 -0
- package/dist/runtime/rust/exchange.rs +287 -0
- package/dist/runtime/rust/hooks.rs +63 -0
- package/dist/runtime/rust/invalidation.rs +84 -0
- package/dist/runtime/rust/log.rs +88 -0
- package/dist/runtime/rust/nullable.rs +13 -0
- package/dist/runtime/rust/path.rs +83 -0
- package/dist/runtime/rust/query.rs +84 -0
- package/dist/runtime/rust/realtime.rs +182 -0
- package/dist/runtime/rust/realtime_loop.rs +177 -0
- package/dist/runtime/rust/redirect.rs +121 -0
- package/dist/runtime/rust/request.rs +178 -0
- package/dist/runtime/rust/result.rs +101 -0
- package/dist/runtime/rust/sse.rs +104 -0
- package/dist/runtime/rust/stale.rs +209 -0
- package/dist/runtime/rust/transport.rs +221 -0
- package/dist/runtime/rust/transport_longpoll.rs +108 -0
- package/dist/runtime/rust/transport_sse.rs +91 -0
- package/dist/runtime/rust/transport_ws.rs +75 -0
- package/dist/runtime/rust/ws.rs +322 -0
- package/dist/runtime/ts/app-types.ts +200 -0
- package/dist/runtime/ts/app.ts +104 -0
- package/dist/runtime/ts/config.ts +124 -0
- package/dist/runtime/ts/defaults.ts +48 -0
- package/dist/runtime/ts/error.ts +113 -0
- package/dist/runtime/ts/hooks.ts +92 -0
- package/dist/runtime/ts/http.ts +228 -0
- package/dist/runtime/ts/media-type.ts +36 -0
- package/dist/runtime/ts/path.ts +152 -0
- package/dist/runtime/ts/realtime-connection.ts +296 -0
- package/dist/runtime/ts/realtime-transports.ts +149 -0
- package/dist/runtime/ts/realtime.ts +293 -0
- package/dist/runtime/ts/redirect-policy.ts +17 -0
- package/dist/runtime/ts/redirects.ts +74 -0
- package/dist/runtime/ts/request.ts +239 -0
- package/dist/runtime/ts/response.ts +219 -0
- package/dist/runtime/ts/sdk-realtime.ts +10 -0
- package/dist/runtime/ts/sdk-sse.ts +55 -0
- package/dist/runtime/ts/sdk-ws.ts +21 -0
- package/dist/runtime/ts/sdk.ts +242 -0
- package/dist/runtime/ts/sse.ts +175 -0
- package/dist/runtime/ts/stale.ts +137 -0
- package/dist/runtime/ts/stream.ts +87 -0
- package/dist/runtime/ts/webhook.ts +116 -0
- package/dist/runtime/ts/ws.ts +155 -0
- package/dist/runtime/ts-tanstack-query/invalidate.ts +152 -0
- package/dist/runtime/ts-tanstack-query/query.ts +261 -0
- package/package.json +84 -5
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP status code → honey's status key (`201` → `created`), as core's response vocabulary names
|
|
3
|
+
* them (gen never imports core, H2). A core test compares this table to core's, so the two cannot drift.
|
|
4
|
+
*/
|
|
5
|
+
export const STATUS_KEYS = {
|
|
6
|
+
200: "ok",
|
|
7
|
+
201: "created",
|
|
8
|
+
202: "accepted",
|
|
9
|
+
203: "non_authoritative_information",
|
|
10
|
+
204: "no_content",
|
|
11
|
+
205: "reset_content",
|
|
12
|
+
206: "partial_content",
|
|
13
|
+
207: "multi_status",
|
|
14
|
+
208: "already_reported",
|
|
15
|
+
226: "im_used",
|
|
16
|
+
300: "multiple_choices",
|
|
17
|
+
301: "moved_permanently",
|
|
18
|
+
302: "found",
|
|
19
|
+
303: "see_other",
|
|
20
|
+
304: "not_modified",
|
|
21
|
+
307: "temporary_redirect",
|
|
22
|
+
308: "permanent_redirect",
|
|
23
|
+
400: "bad_request",
|
|
24
|
+
401: "unauthorized",
|
|
25
|
+
402: "payment_required",
|
|
26
|
+
403: "forbidden",
|
|
27
|
+
404: "not_found",
|
|
28
|
+
405: "method_not_allowed",
|
|
29
|
+
406: "not_acceptable",
|
|
30
|
+
407: "proxy_authentication_required",
|
|
31
|
+
408: "request_timeout",
|
|
32
|
+
409: "conflict",
|
|
33
|
+
410: "gone",
|
|
34
|
+
411: "length_required",
|
|
35
|
+
412: "precondition_failed",
|
|
36
|
+
413: "content_too_large",
|
|
37
|
+
414: "uri_too_long",
|
|
38
|
+
415: "unsupported_media_type",
|
|
39
|
+
416: "range_not_satisfiable",
|
|
40
|
+
417: "expectation_failed",
|
|
41
|
+
418: "im_a_teapot",
|
|
42
|
+
421: "misdirected_request",
|
|
43
|
+
422: "unprocessable_entity",
|
|
44
|
+
423: "locked",
|
|
45
|
+
424: "failed_dependency",
|
|
46
|
+
425: "too_early",
|
|
47
|
+
426: "upgrade_required",
|
|
48
|
+
428: "precondition_required",
|
|
49
|
+
429: "too_many_requests",
|
|
50
|
+
431: "request_header_fields_too_large",
|
|
51
|
+
451: "unavailable_for_legal_reasons",
|
|
52
|
+
500: "internal_server_error",
|
|
53
|
+
501: "not_implemented",
|
|
54
|
+
502: "bad_gateway",
|
|
55
|
+
503: "service_unavailable",
|
|
56
|
+
504: "gateway_timeout",
|
|
57
|
+
505: "http_version_not_supported",
|
|
58
|
+
506: "variant_also_negotiates",
|
|
59
|
+
507: "insufficient_storage",
|
|
60
|
+
508: "loop_detected",
|
|
61
|
+
510: "not_extended",
|
|
62
|
+
511: "network_authentication_required",
|
|
63
|
+
};
|
|
64
|
+
/** The status key of `code`; undefined for a code outside the vocabulary (1xx, a range like `4XX`). */
|
|
65
|
+
export function statusKeyOf(code) {
|
|
66
|
+
return Object.hasOwn(STATUS_KEYS, code) ? STATUS_KEYS[code] : undefined;
|
|
67
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IR → TypeScript type text: the type every TS emitter writes for a schema. Keys and literals go
|
|
3
|
+
* through the one escape layer (F2); a ref is named by the caller, which owns the declarations.
|
|
4
|
+
*/
|
|
5
|
+
import type { IRSchema } from "../../ir/model.ts";
|
|
6
|
+
export type TypeOptions = {
|
|
7
|
+
/** the type of a binary string: `string` in JSON (the default), `Blob` in a multipart form */
|
|
8
|
+
readonly binary?: string;
|
|
9
|
+
/** the name a component ref is declared under; without it a ref is `unknown` */
|
|
10
|
+
readonly refName?: (name: string) => string;
|
|
11
|
+
};
|
|
12
|
+
/** `el[]`, parenthesised when a union, intersection, function or `readonly` array binds looser than `[]`. */
|
|
13
|
+
export declare function arrayOf(el: string): string;
|
|
14
|
+
/** `A | B`, each part once; `never` for none. */
|
|
15
|
+
export declare function unionOf(parts: readonly string[]): string;
|
|
16
|
+
/** `(A | B) & C`, never `A | B & C`: `&` binds tighter than `|`. */
|
|
17
|
+
export declare function intersectionOf(parts: readonly string[]): string;
|
|
18
|
+
/** The TypeScript type of `ir`. */
|
|
19
|
+
export declare function irToTs(ir: IRSchema, options?: TypeOptions): string;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { compareCodeUnits } from "./lang.js";
|
|
2
|
+
import { literalType, quoteKey } from "./literals.js";
|
|
3
|
+
/* a cycle guard only: resolved documents carry no cycles, so legitimately deep nesting is kept */
|
|
4
|
+
const MAX_DEPTH = 64;
|
|
5
|
+
/** Whether `type` holds `token` outside every bracket and string: `A | B` does, `{ a: A | B }` does not. */
|
|
6
|
+
function topLevel(type, token) {
|
|
7
|
+
let depth = 0;
|
|
8
|
+
let quote = null;
|
|
9
|
+
for (let at = 0; at < type.length; at++) {
|
|
10
|
+
const c = type[at];
|
|
11
|
+
if (quote !== null) {
|
|
12
|
+
if (c === "\\")
|
|
13
|
+
at++;
|
|
14
|
+
else if (c === quote)
|
|
15
|
+
quote = null;
|
|
16
|
+
}
|
|
17
|
+
else if (c === '"' || c === "'" || c === "`")
|
|
18
|
+
quote = c;
|
|
19
|
+
else if ("({[<".includes(c))
|
|
20
|
+
depth++;
|
|
21
|
+
else if (")}]".includes(c) || (c === ">" && type[at - 1] !== "="))
|
|
22
|
+
depth--;
|
|
23
|
+
else if (depth === 0 && type.startsWith(token, at))
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
/** `el[]`, parenthesised when a union, intersection, function or `readonly` array binds looser than `[]`. */
|
|
29
|
+
export function arrayOf(el) {
|
|
30
|
+
const looser = topLevel(el, "|") || topLevel(el, "&") || topLevel(el, "=>") || el.startsWith("readonly ");
|
|
31
|
+
return looser ? `(${el})[]` : `${el}[]`;
|
|
32
|
+
}
|
|
33
|
+
/** `A | B`, each part once; `never` for none. */
|
|
34
|
+
export function unionOf(parts) {
|
|
35
|
+
const unique = [...new Set(parts)];
|
|
36
|
+
if (unique.length === 0)
|
|
37
|
+
return "never";
|
|
38
|
+
return unique.map((part) => (topLevel(part, "=>") ? `(${part})` : part)).join(" | ");
|
|
39
|
+
}
|
|
40
|
+
/** `(A | B) & C`, never `A | B & C`: `&` binds tighter than `|`. */
|
|
41
|
+
export function intersectionOf(parts) {
|
|
42
|
+
return parts.map((part) => (topLevel(part, "|") || topLevel(part, "=>") ? `(${part})` : part)).join(" & ");
|
|
43
|
+
}
|
|
44
|
+
function scalarOf(ir) {
|
|
45
|
+
if (ir.enum !== undefined)
|
|
46
|
+
return unionOf(ir.enum.map(literalType));
|
|
47
|
+
return ir.type === "integer" ? "number" : ir.type;
|
|
48
|
+
}
|
|
49
|
+
function objectOf(ir, emit) {
|
|
50
|
+
const extra = ir.additional === undefined || ir.additional === false ? null : emit(ir.additional);
|
|
51
|
+
/* closed with nothing in it (z.object({})): the empty object, never an open record */
|
|
52
|
+
if (ir.fields.length === 0)
|
|
53
|
+
return ir.additional === false ? "{}" : `Record<string, ${extra ?? "unknown"}>`;
|
|
54
|
+
const fields = [...ir.fields]
|
|
55
|
+
.sort((a, b) => compareCodeUnits(a.name, b.name))
|
|
56
|
+
.map((field) => `${quoteKey(field.name)}${field.required ? "" : "?"}: ${emit(field.schema)}`);
|
|
57
|
+
const shape = `{ ${fields.join("; ")} }`;
|
|
58
|
+
/* an index signature beside fields of other types is TS2411; an intersection says the same */
|
|
59
|
+
return extra === null ? shape : `${shape} & { [k: string]: ${extra} }`;
|
|
60
|
+
}
|
|
61
|
+
function tupleOf(ir, emit) {
|
|
62
|
+
const required = ir.required ?? ir.items.length;
|
|
63
|
+
const items = ir.items.map((item, at) => `${emit(item)}${at < required ? "" : "?"}`);
|
|
64
|
+
if (ir.rest !== undefined)
|
|
65
|
+
items.push(`...${arrayOf(emit(ir.rest))}`);
|
|
66
|
+
return `[${items.join(", ")}]`;
|
|
67
|
+
}
|
|
68
|
+
function emitAt(ir, options, depth) {
|
|
69
|
+
if (depth > MAX_DEPTH)
|
|
70
|
+
return "unknown";
|
|
71
|
+
const emit = (child) => emitAt(child, options, depth + 1);
|
|
72
|
+
switch (ir.kind) {
|
|
73
|
+
case "scalar":
|
|
74
|
+
return scalarOf(ir);
|
|
75
|
+
case "const":
|
|
76
|
+
return literalType(ir.value);
|
|
77
|
+
case "object":
|
|
78
|
+
return objectOf(ir, emit);
|
|
79
|
+
case "array":
|
|
80
|
+
return arrayOf(emit(ir.items));
|
|
81
|
+
case "tuple":
|
|
82
|
+
return tupleOf(ir, emit);
|
|
83
|
+
case "union":
|
|
84
|
+
return unionOf(ir.variants.map(emit));
|
|
85
|
+
case "allOf":
|
|
86
|
+
return intersectionOf(ir.parts.map(emit));
|
|
87
|
+
case "nullable":
|
|
88
|
+
return unionOf([emit(ir.inner), "null"]);
|
|
89
|
+
case "ref":
|
|
90
|
+
return options.refName?.(ir.name) ?? "unknown";
|
|
91
|
+
case "binary":
|
|
92
|
+
return options.binary ?? "string";
|
|
93
|
+
default:
|
|
94
|
+
return "unknown";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** The TypeScript type of `ir`. */
|
|
98
|
+
export function irToTs(ir, options = {}) {
|
|
99
|
+
return emitAt(ir, options, 0);
|
|
100
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app-typed front (F1): `createClient<typeof app>(config)`, vendored into an app's `_gen/`. It
|
|
3
|
+
* reads the app's `$routes` phantom structurally (D3), so the files import nothing from honey.
|
|
4
|
+
*/
|
|
5
|
+
import { FULL_RUNTIME, runtimeSource } from "./http.js";
|
|
6
|
+
const VALUES = [
|
|
7
|
+
"APIConnectionError",
|
|
8
|
+
"BadGatewayError",
|
|
9
|
+
"BadRequestError",
|
|
10
|
+
"ClientError",
|
|
11
|
+
"ConflictError",
|
|
12
|
+
"createClient",
|
|
13
|
+
"createFallbackChain",
|
|
14
|
+
"createKeepaliveLoop",
|
|
15
|
+
"createResumableConnection",
|
|
16
|
+
"createTypedWebSocket",
|
|
17
|
+
"DecodeError",
|
|
18
|
+
"ForbiddenError",
|
|
19
|
+
"GatewayTimeoutError",
|
|
20
|
+
"HTTPClient",
|
|
21
|
+
"InternalServerError",
|
|
22
|
+
"interpolatePath",
|
|
23
|
+
"isClientError",
|
|
24
|
+
"newClientRequestId",
|
|
25
|
+
"NotFoundError",
|
|
26
|
+
"parseSSEStream",
|
|
27
|
+
"PathParamError",
|
|
28
|
+
"RateLimitError",
|
|
29
|
+
"RealtimeAbortError",
|
|
30
|
+
"RealtimeConnectError",
|
|
31
|
+
"RealtimeError",
|
|
32
|
+
"RealtimeKickedError",
|
|
33
|
+
"ServiceUnavailableError",
|
|
34
|
+
"UnauthorizedError",
|
|
35
|
+
"UnprocessableEntityError",
|
|
36
|
+
];
|
|
37
|
+
const TYPES = [
|
|
38
|
+
"AuthExpiredContext",
|
|
39
|
+
"ClientConfig",
|
|
40
|
+
"ConnectionState",
|
|
41
|
+
"ErrorEnvelope",
|
|
42
|
+
"FieldError",
|
|
43
|
+
"HoneyClient",
|
|
44
|
+
"InferRoutes",
|
|
45
|
+
"LogEntry",
|
|
46
|
+
"OnRequestContext",
|
|
47
|
+
"OnResponseContext",
|
|
48
|
+
"RealtimeOptions",
|
|
49
|
+
"RedirectPolicy",
|
|
50
|
+
"RequestOptions",
|
|
51
|
+
"Result",
|
|
52
|
+
"ResumableConnection",
|
|
53
|
+
"ResumableConnectionOpts",
|
|
54
|
+
"ServerFrame",
|
|
55
|
+
"SSEEvent",
|
|
56
|
+
"Transport",
|
|
57
|
+
"TransportAdapter",
|
|
58
|
+
"TransportConnection",
|
|
59
|
+
"TransportOpts",
|
|
60
|
+
"TypedWebSocket",
|
|
61
|
+
];
|
|
62
|
+
/** `client.gen.ts` (what an app imports) and `client.runtime.gen.ts` (the runtime verbatim). */
|
|
63
|
+
export function generateAppClient() {
|
|
64
|
+
const client = `export { ${VALUES.join(", ")} } from "./client.runtime.gen"
|
|
65
|
+
export type { ${TYPES.join(", ")} } from "./client.runtime.gen"
|
|
66
|
+
`;
|
|
67
|
+
return { files: { "client.gen.ts": client, "client.runtime.gen.ts": runtimeSource(FULL_RUNTIME) } };
|
|
68
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IR } from "../../ir/model.ts";
|
|
2
|
+
/** What a client needs from the runtime beyond plain HTTP; `app` is the app client's own `createClient`. */
|
|
3
|
+
export type TsRuntimeFeatures = {
|
|
4
|
+
readonly app: boolean;
|
|
5
|
+
readonly realtime: boolean;
|
|
6
|
+
readonly sse: boolean;
|
|
7
|
+
readonly ws: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** The app client's runtime: `createClient` and every transport, since it cannot know its routes'. */
|
|
10
|
+
export declare const FULL_RUNTIME: TsRuntimeFeatures;
|
|
11
|
+
/** The runtime modules under `runtime/ts`, each after the ones it imports. */
|
|
12
|
+
export declare const RUNTIME_MODULES: readonly string[];
|
|
13
|
+
/** The runtime modules an SDK with `features` ships, in `RUNTIME_MODULES` order. */
|
|
14
|
+
export declare function runtimeModules(features: TsRuntimeFeatures): string[];
|
|
15
|
+
/** What the SDK of `ir` needs from the runtime: its operations' transports, never the app client. */
|
|
16
|
+
export declare function runtimeFeatures(ir: IR): TsRuntimeFeatures;
|
|
17
|
+
/** The Standard Webhooks verifier: it imports nothing, so the webhook file that carries it stands alone. */
|
|
18
|
+
export declare function webhookSource(): string;
|
|
19
|
+
/** The runtime as one module, with `features`' transports: what `runtime.gen.ts` holds. */
|
|
20
|
+
export declare function runtimeSource(features: TsRuntimeFeatures): string;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The vendored TS runtime, as the text an SDK ships (H9/F5): the modules under `runtime/ts`, read
|
|
3
|
+
* here and nowhere else, joined into one module in dependency order with their imports of each
|
|
4
|
+
* other dropped. An SDK ships only the transports its operations use: the event-stream modules for an
|
|
5
|
+
* SSE or realtime API, the WebSocket ones for a WebSocket or realtime API, the realtime ones for a
|
|
6
|
+
* realtime API, and only the app client ships its own `createClient`. The webhook verifier is no part of it: it ships
|
|
7
|
+
* in its own file (`webhookSource`), so a receiver bundles nothing else. Both fronts emit it verbatim, so a test that runs the emitted client runs this text.
|
|
8
|
+
*/
|
|
9
|
+
import { readFileSync } from "node:fs";
|
|
10
|
+
import { sdkModel } from "../../ir/sdk-model.js";
|
|
11
|
+
/** The app client's runtime: `createClient` and every transport, since it cannot know its routes'. */
|
|
12
|
+
export const FULL_RUNTIME = { app: true, realtime: true, sse: true, ws: true };
|
|
13
|
+
/** The runtime modules under `runtime/ts`, each after the ones it imports. */
|
|
14
|
+
export const RUNTIME_MODULES = [
|
|
15
|
+
"media-type",
|
|
16
|
+
"defaults",
|
|
17
|
+
"redirect-policy",
|
|
18
|
+
"error",
|
|
19
|
+
"path",
|
|
20
|
+
"request",
|
|
21
|
+
"response",
|
|
22
|
+
"config",
|
|
23
|
+
"redirects",
|
|
24
|
+
"hooks",
|
|
25
|
+
"sse",
|
|
26
|
+
"realtime",
|
|
27
|
+
"realtime-connection",
|
|
28
|
+
"http",
|
|
29
|
+
"stream",
|
|
30
|
+
"ws",
|
|
31
|
+
"realtime-transports",
|
|
32
|
+
"stale",
|
|
33
|
+
"app-types",
|
|
34
|
+
"app",
|
|
35
|
+
"sdk",
|
|
36
|
+
"sdk-sse",
|
|
37
|
+
"sdk-ws",
|
|
38
|
+
"sdk-realtime",
|
|
39
|
+
];
|
|
40
|
+
/* the modules each transport adds; realtime dials over an event stream and a WebSocket, so it ships both */
|
|
41
|
+
const SSE = ["sse", "stream", "sdk-sse"];
|
|
42
|
+
const WS = ["ws", "sdk-ws"];
|
|
43
|
+
const REALTIME = ["realtime", "realtime-connection", "realtime-transports", "sdk-realtime"];
|
|
44
|
+
const APP = ["app-types", "app"];
|
|
45
|
+
/** The runtime modules an SDK with `features` ships, in `RUNTIME_MODULES` order. */
|
|
46
|
+
export function runtimeModules(features) {
|
|
47
|
+
const left = new Set([
|
|
48
|
+
...(features.sse || features.realtime ? [] : SSE),
|
|
49
|
+
...(features.ws || features.realtime ? [] : WS),
|
|
50
|
+
...(features.realtime ? [] : REALTIME),
|
|
51
|
+
...(features.app ? [] : APP),
|
|
52
|
+
]);
|
|
53
|
+
return RUNTIME_MODULES.filter((name) => !left.has(name));
|
|
54
|
+
}
|
|
55
|
+
/** What the SDK of `ir` needs from the runtime: its operations' transports, never the app client. */
|
|
56
|
+
export function runtimeFeatures(ir) {
|
|
57
|
+
const streams = new Set(sdkModel(ir).ops.map((op) => op.stream));
|
|
58
|
+
return { app: false, realtime: streams.has("realtime"), sse: streams.has("sse"), ws: streams.has("ws") };
|
|
59
|
+
}
|
|
60
|
+
/* an import of a sibling runtime module, on one line or several */
|
|
61
|
+
const SIBLING_IMPORT = /^import\s+(?:type\s+)?\{[^}]*\}\s+from\s+"\.\/[\w-]+\.ts"\n/gm;
|
|
62
|
+
/** One runtime module's source, without its imports of its siblings. */
|
|
63
|
+
function moduleSource(name) {
|
|
64
|
+
const text = readFileSync(new URL(`../../runtime/ts/${name}.ts`, import.meta.url), "utf8");
|
|
65
|
+
return text.replace(SIBLING_IMPORT, "").trim();
|
|
66
|
+
}
|
|
67
|
+
/** The Standard Webhooks verifier: it imports nothing, so the webhook file that carries it stands alone. */
|
|
68
|
+
export function webhookSource() {
|
|
69
|
+
return moduleSource("webhook");
|
|
70
|
+
}
|
|
71
|
+
/** The runtime as one module, with `features`' transports: what `runtime.gen.ts` holds. */
|
|
72
|
+
export function runtimeSource(features) {
|
|
73
|
+
return `${runtimeModules(features).map(moduleSource).join("\n\n")}\n`;
|
|
74
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Metadata, type PackageIdentity } from "../shared/metadata.ts";
|
|
2
|
+
import { type GeneratedSdk, type SdkOptions } from "./sdk.ts";
|
|
3
|
+
/** The SDK's options and the package's own. */
|
|
4
|
+
export type SdkPackageOptions = SdkOptions & {
|
|
5
|
+
/** the npm name, and the JSR name when scoped; the stem by default */
|
|
6
|
+
readonly packageName?: string;
|
|
7
|
+
/** the version both registries carry; the document's by default, `0.0.0` when that is not one npm accepts */
|
|
8
|
+
readonly version?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* `source` compiled by oxc: ES module JavaScript, and with `declaration` its isolated declarations, `@internal` members
|
|
12
|
+
* left out ("" without). What does not compile is refused, naming `path`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function compiled(path: string, source: string, declaration: boolean): {
|
|
15
|
+
code: string;
|
|
16
|
+
declaration: string;
|
|
17
|
+
};
|
|
18
|
+
/** The package.json fields the metadata fills, each only when given: the TS SDK's and the MCP server's. */
|
|
19
|
+
export declare function npmFields(metadata: Metadata): {
|
|
20
|
+
description?: string | undefined;
|
|
21
|
+
keywords?: readonly string[] | undefined;
|
|
22
|
+
homepage?: string | undefined;
|
|
23
|
+
bugs?: string | undefined;
|
|
24
|
+
license?: string | undefined;
|
|
25
|
+
author?: string | undefined;
|
|
26
|
+
repository?: {
|
|
27
|
+
type: string;
|
|
28
|
+
url: string;
|
|
29
|
+
} | undefined;
|
|
30
|
+
};
|
|
31
|
+
/** The SDK with its package files, and the package as npm lists it, and JSR too when its name is scoped. */
|
|
32
|
+
export type GeneratedSdkPackage = GeneratedSdk & {
|
|
33
|
+
readonly packages: readonly PackageIdentity[];
|
|
34
|
+
};
|
|
35
|
+
/** The SDK for `document` with its package files: the sources, `dist/`, package.json, and jsr.json when scoped. */
|
|
36
|
+
export declare function generateSdkPackage(document: Record<string, unknown>, options: SdkPackageOptions, metadata: Metadata): GeneratedSdkPackage;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The TypeScript SDK as a package (plan 39 8.3). Its sources stay where a workspace imports them, and the files each
|
|
3
|
+
* registry takes go beside them. npm gets `dist/`: each source compiled to ES module JavaScript plus its declarations,
|
|
4
|
+
* since node refuses to strip types under node_modules. JSR takes the sources themselves through `jsr.json`, written
|
|
5
|
+
* when the name is scoped, as JSR names are. The sources import each other as `.js`, which every TypeScript
|
|
6
|
+
* resolution and bundler maps to the `.ts` file and a consumer compiles under any flags; JSR is told to map them the
|
|
7
|
+
* same way (sloppy imports). oxc's transform compiles both in one in-process pass that is the same
|
|
8
|
+
* whichever runtime generates; no type checker runs, since the sources declare every exported type (isolated
|
|
9
|
+
* declarations). The MCP server's `dist/` goes through the same pass, and its package.json takes the same metadata.
|
|
10
|
+
*/
|
|
11
|
+
import { transformSync } from "oxc-transform";
|
|
12
|
+
import { checked, issuesUrl, LICENSE, NPM_NAME, packageOn, README, SEMVER, shippedOf, } from "../shared/metadata.js";
|
|
13
|
+
import { generateSdk } from "./sdk.js";
|
|
14
|
+
/* the optional peer the TanStack adapter's types import, as npm and JSR range it */
|
|
15
|
+
const QUERY_CORE = "@tanstack/query-core";
|
|
16
|
+
const QUERY_CORE_RANGE = "^5.0.0";
|
|
17
|
+
/* each importable file's kind and the subpath it is exported at; the others are reached through the index */
|
|
18
|
+
const SUBPATHS = {
|
|
19
|
+
index: ".",
|
|
20
|
+
"tanstack-query": "./tanstack-query",
|
|
21
|
+
webhook: "./webhook",
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* `source` compiled by oxc: ES module JavaScript, and with `declaration` its isolated declarations, `@internal` members
|
|
25
|
+
* left out ("" without). What does not compile is refused, naming `path`.
|
|
26
|
+
*/
|
|
27
|
+
export function compiled(path, source, declaration) {
|
|
28
|
+
const result = transformSync(path, source, {
|
|
29
|
+
sourceType: "module",
|
|
30
|
+
...(declaration ? { typescript: { declaration: { stripInternal: true } } } : {}),
|
|
31
|
+
});
|
|
32
|
+
if (result.errors.length > 0)
|
|
33
|
+
throw new Error(`${path} does not compile: ${result.errors.map((error) => error.message).join("; ")}`);
|
|
34
|
+
return { code: result.code, declaration: result.declaration ?? "" };
|
|
35
|
+
}
|
|
36
|
+
/** The subpaths `files` exports, each to what `target` makes of its source. */
|
|
37
|
+
function exportsOf(files, stem, target) {
|
|
38
|
+
const kinds = Object.entries(SUBPATHS).filter(([kind]) => files[`${stem}.${kind}.gen.ts`] !== undefined);
|
|
39
|
+
return Object.fromEntries(kinds.map(([kind, subpath]) => [subpath, target(`${stem}.${kind}.gen`)]));
|
|
40
|
+
}
|
|
41
|
+
/** The package.json fields the metadata fills, each only when given: the TS SDK's and the MCP server's. */
|
|
42
|
+
export function npmFields(metadata) {
|
|
43
|
+
const { authors, description, homepage, keywords, license, repository } = metadata;
|
|
44
|
+
return {
|
|
45
|
+
...(description === undefined ? {} : { description }),
|
|
46
|
+
...(keywords === undefined ? {} : { keywords }),
|
|
47
|
+
...(homepage === undefined ? {} : { homepage }),
|
|
48
|
+
...(repository === undefined ? {} : { bugs: issuesUrl(repository) }),
|
|
49
|
+
...(license === undefined ? {} : { license }),
|
|
50
|
+
...(authors === undefined ? {} : { author: authors[0] }),
|
|
51
|
+
...(repository === undefined
|
|
52
|
+
? {}
|
|
53
|
+
: { repository: { type: "git", url: `git+${repository.replace(/\.git$/, "")}.git` } }),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** The package.json npm installs: its exports the compiled JavaScript and declarations, nothing else shipped. */
|
|
57
|
+
function packageJson(sdk, name, version, metadata) {
|
|
58
|
+
const tanstack = sdk.files[`${sdk.stem}.tanstack-query.gen.ts`] !== undefined;
|
|
59
|
+
const manifest = {
|
|
60
|
+
name,
|
|
61
|
+
version,
|
|
62
|
+
...npmFields(metadata),
|
|
63
|
+
type: "module",
|
|
64
|
+
exports: exportsOf(sdk.files, sdk.stem, (file) => ({ types: `./dist/${file}.d.ts`, default: `./dist/${file}.js` })),
|
|
65
|
+
files: ["dist"],
|
|
66
|
+
sideEffects: false,
|
|
67
|
+
engines: { node: ">=22" },
|
|
68
|
+
...(tanstack
|
|
69
|
+
? {
|
|
70
|
+
peerDependencies: { [QUERY_CORE]: QUERY_CORE_RANGE },
|
|
71
|
+
peerDependenciesMeta: { [QUERY_CORE]: { optional: true } },
|
|
72
|
+
}
|
|
73
|
+
: {}),
|
|
74
|
+
};
|
|
75
|
+
return `${JSON.stringify(manifest, null, "\t")}\n`;
|
|
76
|
+
}
|
|
77
|
+
/** The jsr.json JSR publishes the sources by, for a scoped name. */
|
|
78
|
+
function jsrJson(sdk, name, version, metadata) {
|
|
79
|
+
const tanstack = sdk.files[`${sdk.stem}.tanstack-query.gen.ts`] !== undefined;
|
|
80
|
+
const config = {
|
|
81
|
+
name,
|
|
82
|
+
version,
|
|
83
|
+
...(metadata.license === undefined ? {} : { license: metadata.license }),
|
|
84
|
+
exports: exportsOf(sdk.files, sdk.stem, (file) => `./${file}.ts`),
|
|
85
|
+
...(tanstack ? { imports: { [QUERY_CORE]: `npm:${QUERY_CORE}@${QUERY_CORE_RANGE}` } } : {}),
|
|
86
|
+
/* the runtime reads browser globals (FileList, WebSocket) where they exist: JSR checks it with them declared */
|
|
87
|
+
compilerOptions: { lib: ["esnext", "dom", "dom.iterable"] },
|
|
88
|
+
/* the sources' `.js` imports name their `.ts` files */
|
|
89
|
+
unstable: ["sloppy-imports"],
|
|
90
|
+
/* the README JSR shows and the license file beside the sources, each when the run ships it; npm packs both
|
|
91
|
+
* whatever `files` says */
|
|
92
|
+
publish: { include: ["*.gen.ts", ...shippedNames(metadata)] },
|
|
93
|
+
};
|
|
94
|
+
return `${JSON.stringify(config, null, "\t")}\n`;
|
|
95
|
+
}
|
|
96
|
+
/** The names of the files `metadata` ships beside the code. */
|
|
97
|
+
const shippedNames = (metadata) => {
|
|
98
|
+
const shipped = shippedOf(metadata);
|
|
99
|
+
return [...(shipped.readme ? [README] : []), ...(shipped.licenseFile ? [LICENSE] : [])];
|
|
100
|
+
};
|
|
101
|
+
/** The SDK for `document` with its package files: the sources, `dist/`, package.json, and jsr.json when scoped. */
|
|
102
|
+
export function generateSdkPackage(document, options, metadata) {
|
|
103
|
+
checked("version", options.version, SEMVER);
|
|
104
|
+
const sdk = generateSdk(document, options);
|
|
105
|
+
const name = checked("packageName", options.packageName ?? sdk.stem.toLowerCase(), NPM_NAME);
|
|
106
|
+
const stated = sdk.version !== undefined && SEMVER.test(sdk.version) ? sdk.version : "0.0.0";
|
|
107
|
+
const version = options.version ?? stated;
|
|
108
|
+
const dist = Object.entries(sdk.files).flatMap(([path, source]) => {
|
|
109
|
+
const { code, declaration } = compiled(path, source, true);
|
|
110
|
+
const stem = `dist/${path.replace(/\.ts$/, "")}`;
|
|
111
|
+
return [
|
|
112
|
+
[`${stem}.d.ts`, declaration],
|
|
113
|
+
[`${stem}.js`, code],
|
|
114
|
+
];
|
|
115
|
+
});
|
|
116
|
+
const files = {
|
|
117
|
+
...sdk.files,
|
|
118
|
+
...Object.fromEntries(dist),
|
|
119
|
+
"package.json": packageJson(sdk, name, version, metadata),
|
|
120
|
+
};
|
|
121
|
+
const scoped = name.startsWith("@");
|
|
122
|
+
if (scoped)
|
|
123
|
+
files["jsr.json"] = jsrJson(sdk, name, version, metadata);
|
|
124
|
+
const packages = [packageOn("npm", name, version), ...(scoped ? [packageOn("jsr", name, version)] : [])];
|
|
125
|
+
return { ...sdk, files, packages };
|
|
126
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** core's route-tree node (routing/tree.ts), field by field. */
|
|
2
|
+
export type TreeNode = {
|
|
3
|
+
/** The dynamic parameter child: the parameter's name `n` and its subtree `c`; null when the node has none. */
|
|
4
|
+
d: {
|
|
5
|
+
/** The subtree under the parameter. */
|
|
6
|
+
c: TreeNode;
|
|
7
|
+
/** The parameter's name. */
|
|
8
|
+
n: string;
|
|
9
|
+
} | null;
|
|
10
|
+
/** The route id for each HTTP method at exactly this path; null when no HTTP route ends here. */
|
|
11
|
+
m: Readonly<Record<string, string>> | null;
|
|
12
|
+
/** The static children, by literal path segment. */
|
|
13
|
+
s: Readonly<Record<string, TreeNode>>;
|
|
14
|
+
/** The wildcard: its name `n` and the route id for each method `m`; null when the node has none. */
|
|
15
|
+
w: {
|
|
16
|
+
/** The route id for each HTTP method on the wildcard. */
|
|
17
|
+
m: Readonly<Record<string, string>>;
|
|
18
|
+
/** The wildcard's name. */
|
|
19
|
+
n: string;
|
|
20
|
+
} | null;
|
|
21
|
+
/** The WebSocket route id at this path; null when there is none. */
|
|
22
|
+
ws: string | null;
|
|
23
|
+
};
|
|
24
|
+
/** One route's data in a snapshot; `h`, `iv` and `out` are live values, never emitted. */
|
|
25
|
+
export type RouteEntry = {
|
|
26
|
+
/** The declared body as data: `"json"`, `"form"`, or the binary media types. */
|
|
27
|
+
bd?: string | readonly string[];
|
|
28
|
+
/**
|
|
29
|
+
* The error key an undeclared throw from this route is answered with; null when it has none, which answers an
|
|
30
|
+
* internal error.
|
|
31
|
+
*/
|
|
32
|
+
bek?: string | null;
|
|
33
|
+
/** The error keys the route declares. */
|
|
34
|
+
ek?: readonly string[];
|
|
35
|
+
/** Each declared error key's status name, such as `conflict` or `bad_gateway`. */
|
|
36
|
+
es?: Readonly<Record<string, string>>;
|
|
37
|
+
/** The live handler record; present in a snapshot of a running app, never written. */
|
|
38
|
+
h?: unknown;
|
|
39
|
+
/** Set on an internal route (spec, docs, manifest): it is left out of the route selectors. */
|
|
40
|
+
i?: 1 | true;
|
|
41
|
+
/** What the route's `.input()` declares; a live value, never written. */
|
|
42
|
+
iv?: unknown;
|
|
43
|
+
/**
|
|
44
|
+
* The route's meta. `generateRouteTree` throws on a value JSON cannot carry, such as a function, a class instance
|
|
45
|
+
* or a cycle.
|
|
46
|
+
*/
|
|
47
|
+
mt?: Readonly<Record<string, unknown>> | null;
|
|
48
|
+
/** What the route's `.output()` declares; a live value, never written. */
|
|
49
|
+
out?: unknown;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* A route tree in core's format (`app.toRouteTree()` makes one) as `generateRouteTree` reads it: the topology and each
|
|
53
|
+
* route's data.
|
|
54
|
+
*/
|
|
55
|
+
export type RouteTree = {
|
|
56
|
+
/** Not read by the generators: each route's meta comes from its entry's `mt`. */
|
|
57
|
+
meta?: Readonly<Record<string, unknown>>;
|
|
58
|
+
/** The topology's root node; its leaves are route ids. */
|
|
59
|
+
root: TreeNode;
|
|
60
|
+
/**
|
|
61
|
+
* Each route's data by route id. A route no leaf of `root` names is not emitted; a leaf with no entry here throws.
|
|
62
|
+
*/
|
|
63
|
+
routes: Readonly<Record<string, RouteEntry>>;
|
|
64
|
+
/** The format version. `generateRouteTree` throws unless it is 2, so leaving it out throws too. */
|
|
65
|
+
v?: number;
|
|
66
|
+
};
|
|
67
|
+
/** The route-tree module for `tree` (a snapshot or a merged tree); throws on anything it cannot carry. */
|
|
68
|
+
export declare function generateRouteTree(tree: RouteTree): string;
|