@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,143 @@
|
|
|
1
|
+
// @generated by honey. DO NOT EDIT.
|
|
2
|
+
using System;
|
|
3
|
+
using System.Net.Http;
|
|
4
|
+
using System.Text;
|
|
5
|
+
using System.Text.Json;
|
|
6
|
+
using System.Text.Json.Serialization.Metadata;
|
|
7
|
+
using System.Threading;
|
|
8
|
+
using System.Threading.Tasks;
|
|
9
|
+
|
|
10
|
+
namespace Honey.Runtime;
|
|
11
|
+
|
|
12
|
+
internal sealed partial class Transport : IDisposable
|
|
13
|
+
{
|
|
14
|
+
public Transport(ClientConfig config, Defaults defaults)
|
|
15
|
+
{
|
|
16
|
+
Config = config;
|
|
17
|
+
Json = defaults.Json;
|
|
18
|
+
Base = BaseOf(config, defaults);
|
|
19
|
+
Auth = new Credential(config, defaults);
|
|
20
|
+
Stale = new StaleTracker(config.Invalidation);
|
|
21
|
+
var (root, owned) = Handler.Install(config);
|
|
22
|
+
Http = new HttpClient(root, disposeHandler: owned) { Timeout = Timeout.InfiniteTimeSpan };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public ClientConfig Config { get; }
|
|
26
|
+
|
|
27
|
+
public JsonSerializerOptions Json { get; }
|
|
28
|
+
|
|
29
|
+
public string Base { get; }
|
|
30
|
+
|
|
31
|
+
public Credential Auth { get; }
|
|
32
|
+
|
|
33
|
+
public StaleTracker Stale { get; }
|
|
34
|
+
|
|
35
|
+
public HttpClient Http { get; }
|
|
36
|
+
|
|
37
|
+
public void Dispose() => Http.Dispose();
|
|
38
|
+
|
|
39
|
+
public async Task<T> CallAsync<T>(Operation op, Call call, JsonTypeInfo<T> answer, CancellationToken cancellationToken) =>
|
|
40
|
+
Decode(op, await ThrowingAsync(op, call, cancellationToken).ConfigureAwait(false), answer) ?? throw Null(op);
|
|
41
|
+
|
|
42
|
+
public async Task<T?> NullableAsync<T>(Operation op, Call call, JsonTypeInfo<T> answer, CancellationToken cancellationToken) =>
|
|
43
|
+
Decode(op, await ThrowingAsync(op, call, cancellationToken).ConfigureAwait(false), answer);
|
|
44
|
+
|
|
45
|
+
public async Task CallAsync(Operation op, Call call, CancellationToken cancellationToken) =>
|
|
46
|
+
await ThrowingAsync(op, call, cancellationToken).ConfigureAwait(false);
|
|
47
|
+
|
|
48
|
+
public async Task<string> TextAsync(Operation op, Call call, CancellationToken cancellationToken) =>
|
|
49
|
+
Encoding.UTF8.GetString((await ThrowingAsync(op, call, cancellationToken).ConfigureAwait(false)).Body);
|
|
50
|
+
|
|
51
|
+
public async Task<byte[]> BytesAsync(Operation op, Call call, CancellationToken cancellationToken) =>
|
|
52
|
+
(await ThrowingAsync(op, call, cancellationToken).ConfigureAwait(false)).Body;
|
|
53
|
+
|
|
54
|
+
/* a client.Safe twin's one path: the normal method `call` sent with a response box, an answer its Err */
|
|
55
|
+
public static async Task<Result<T>> Safe<T>(RequestOptions? options, Func<RequestOptions, Task<T>> call)
|
|
56
|
+
{
|
|
57
|
+
var raw = options?.Raw ?? new RawResponse();
|
|
58
|
+
try
|
|
59
|
+
{
|
|
60
|
+
return new(await call((options ?? new()) with { Raw = raw }).ConfigureAwait(false), null, raw);
|
|
61
|
+
}
|
|
62
|
+
catch (SdkException e)
|
|
63
|
+
{
|
|
64
|
+
return new(default!, e, raw);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public static async Task<Result> Safe(RequestOptions? options, Func<RequestOptions, Task> call)
|
|
69
|
+
{
|
|
70
|
+
var raw = options?.Raw ?? new RawResponse();
|
|
71
|
+
try
|
|
72
|
+
{
|
|
73
|
+
await call((options ?? new()) with { Raw = raw }).ConfigureAwait(false);
|
|
74
|
+
return new(null, raw);
|
|
75
|
+
}
|
|
76
|
+
catch (SdkException e)
|
|
77
|
+
{
|
|
78
|
+
return new(e, raw);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private static T? Decode<T>(Operation op, RawResponse raw, JsonTypeInfo<T> answer)
|
|
83
|
+
{
|
|
84
|
+
try
|
|
85
|
+
{
|
|
86
|
+
return JsonSerializer.Deserialize(raw.Body, answer);
|
|
87
|
+
}
|
|
88
|
+
catch (JsonException e)
|
|
89
|
+
{
|
|
90
|
+
throw new DecodeException($"{op.Method} {op.Path}: the answer does not decode: {e.Message}", e);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private static DecodeException Null(Operation op) => new($"{op.Method} {op.Path}: the answer is null");
|
|
95
|
+
|
|
96
|
+
private async Task<RawResponse> ThrowingAsync(Operation op, Call call, CancellationToken cancellationToken)
|
|
97
|
+
{
|
|
98
|
+
var (raw, error) = await ExchangeAsync(op, call, cancellationToken).ConfigureAwait(false);
|
|
99
|
+
return error is null ? raw : throw error;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private async Task<(RawResponse Raw, SdkException? Error)> ExchangeAsync(Operation op, Call call, CancellationToken cancellationToken)
|
|
103
|
+
{
|
|
104
|
+
var (raw, error) = await new Exchange(this, op, call).RunAsync(cancellationToken).ConfigureAwait(false);
|
|
105
|
+
if (error is null)
|
|
106
|
+
{
|
|
107
|
+
call.Read?.Invoke(raw.Headers);
|
|
108
|
+
}
|
|
109
|
+
return (raw, error);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public static string Url(string origin, string path, string query)
|
|
113
|
+
{
|
|
114
|
+
var hash = origin.IndexOf('#');
|
|
115
|
+
var at = hash < 0 ? origin : origin[..hash];
|
|
116
|
+
var mark = at.IndexOf('?');
|
|
117
|
+
var own = mark < 0 ? "" : at[(mark + 1)..];
|
|
118
|
+
var joined = own.Length > 0 && query.Length > 0 ? $"{own}&{query}" : own + query;
|
|
119
|
+
return (mark < 0 ? at : at[..mark]).TrimEnd('/') + path + (joined.Length > 0 ? $"?{joined}" : "");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private static string BaseOf(ClientConfig config, Defaults defaults)
|
|
123
|
+
{
|
|
124
|
+
if (!string.IsNullOrEmpty(config.BaseUrl))
|
|
125
|
+
{
|
|
126
|
+
return Absolute(config.BaseUrl, "ClientConfig.BaseUrl");
|
|
127
|
+
}
|
|
128
|
+
const string Unset = "ClientConfig.BaseUrl is unset, and the API";
|
|
129
|
+
return defaults.BaseUrl switch
|
|
130
|
+
{
|
|
131
|
+
null => throw new ConfigException($"{Unset} declares no server: set ClientConfig.BaseUrl"),
|
|
132
|
+
var server when IsAbsolute(server) => server,
|
|
133
|
+
var server => throw new ConfigException($"{Unset}'s first server \"{server}\" is not an absolute http(s) URL: set ClientConfig.BaseUrl"),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public static string Absolute(string url, string what) =>
|
|
138
|
+
IsAbsolute(url) ? url : throw new ConfigException($"{what} is not an absolute http(s) URL");
|
|
139
|
+
|
|
140
|
+
private static bool IsAbsolute(string url) =>
|
|
141
|
+
Uri.TryCreate(url, UriKind.Absolute, out var uri) && uri.Host.Length > 0
|
|
142
|
+
&& (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps);
|
|
143
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// @generated by honey. DO NOT EDIT.
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Text;
|
|
4
|
+
using System.Threading;
|
|
5
|
+
using System.Threading.Tasks;
|
|
6
|
+
|
|
7
|
+
namespace Honey.Runtime;
|
|
8
|
+
|
|
9
|
+
/// <summary>A realtime call polled through its exchange: one GET per message with the cursor, held up to 60 s whatever the timeout (a 204 polls again); a send is a POST.</summary>
|
|
10
|
+
public sealed class LongPollAdapter : ITransportAdapter, IDialed
|
|
11
|
+
{
|
|
12
|
+
private readonly Dial _dial;
|
|
13
|
+
|
|
14
|
+
internal LongPollAdapter(Dial dial) => _dial = dial;
|
|
15
|
+
|
|
16
|
+
Dial IDialed.Dial => _dial;
|
|
17
|
+
|
|
18
|
+
/// <summary><c>longpoll</c>.</summary>
|
|
19
|
+
public string Name => "longpoll";
|
|
20
|
+
|
|
21
|
+
/// <summary><see cref="TransportKind.LongPoll"/>.</summary>
|
|
22
|
+
public TransportKind Kind => TransportKind.LongPoll;
|
|
23
|
+
|
|
24
|
+
/// <summary>The connection, which dials nothing: its first poll waits for its first read; <paramref name="url"/> is a caller's adapter's.</summary>
|
|
25
|
+
public Task<ITransportConnection> ConnectAsync(string url, TransportOptions options, CancellationToken cancellationToken)
|
|
26
|
+
{
|
|
27
|
+
var opened = new RawResponse();
|
|
28
|
+
opened.Fill(200, new Dictionary<string, string>(), [], _dial.Poll(options).Url());
|
|
29
|
+
_dial.Opened(opened);
|
|
30
|
+
return Task.FromResult<ITransportConnection>(new LongPollConnection(_dial, options));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* each poll reads the connection's own cursor as it stands, never a copy taken at connect */
|
|
35
|
+
internal sealed class LongPollConnection(Dial dial, TransportOptions cursor) : ITransportConnection
|
|
36
|
+
{
|
|
37
|
+
private bool _closed;
|
|
38
|
+
|
|
39
|
+
public async Task<TransportMessage?> ReceiveAsync(CancellationToken cancellationToken)
|
|
40
|
+
{
|
|
41
|
+
while (!_closed)
|
|
42
|
+
{
|
|
43
|
+
var (raw, error) = await dial.Poll(cursor).RunAsync(cancellationToken).ConfigureAwait(false);
|
|
44
|
+
if (error is not null)
|
|
45
|
+
{
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
if (raw.Status != 204)
|
|
49
|
+
{
|
|
50
|
+
return new TransportMessage(Encoding.UTF8.GetString(raw.Body));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public Task SendAsync(string text, CancellationToken cancellationToken) => dial.PostAsync(text, cancellationToken);
|
|
57
|
+
|
|
58
|
+
public ValueTask DisposeAsync()
|
|
59
|
+
{
|
|
60
|
+
_closed = true;
|
|
61
|
+
return ValueTask.CompletedTask;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// @generated by honey. DO NOT EDIT.
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading;
|
|
4
|
+
using System.Threading.Tasks;
|
|
5
|
+
|
|
6
|
+
namespace Honey.Runtime;
|
|
7
|
+
|
|
8
|
+
/// <summary>A realtime call's event stream through its exchange: the cursor's id as Last-Event-ID, its token as a query param; a send is a POST.</summary>
|
|
9
|
+
public sealed class SseAdapter : ITransportAdapter, IDialed
|
|
10
|
+
{
|
|
11
|
+
private readonly Dial _dial;
|
|
12
|
+
|
|
13
|
+
internal SseAdapter(Dial dial) => _dial = dial;
|
|
14
|
+
|
|
15
|
+
Dial IDialed.Dial => _dial;
|
|
16
|
+
|
|
17
|
+
/// <summary><c>sse</c>.</summary>
|
|
18
|
+
public string Name => "sse";
|
|
19
|
+
|
|
20
|
+
/// <summary><see cref="TransportKind.Sse"/>.</summary>
|
|
21
|
+
public TransportKind Kind => TransportKind.Sse;
|
|
22
|
+
|
|
23
|
+
/// <summary>Opens the call's event stream, which no read timeout bounds; <paramref name="url"/> is a caller's adapter's.</summary>
|
|
24
|
+
public async Task<ITransportConnection> ConnectAsync(string url, TransportOptions options, CancellationToken cancellationToken)
|
|
25
|
+
{
|
|
26
|
+
var x = _dial.Stream(options);
|
|
27
|
+
var live = await x.OpenAsync(cancellationToken).ConfigureAwait(false);
|
|
28
|
+
_dial.Opened(x.Raw!);
|
|
29
|
+
return new SseConnection(new EventStream<string>(live, data => data, CancellationToken.None), _dial);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
internal sealed class SseConnection(EventStream<string> stream, Dial dial) : ITransportConnection
|
|
34
|
+
{
|
|
35
|
+
private IAsyncEnumerator<SseEvent<string>>? _events;
|
|
36
|
+
|
|
37
|
+
/* a read's token ends the stream: the read then throws its cancel */
|
|
38
|
+
public async Task<TransportMessage?> ReceiveAsync(CancellationToken cancellationToken)
|
|
39
|
+
{
|
|
40
|
+
_events ??= stream.GetAsyncEnumerator();
|
|
41
|
+
using var ended = cancellationToken.Register(static stream => ((EventStream<string>)stream!).DisposeAsync(), stream);
|
|
42
|
+
if (!await _events.MoveNextAsync().ConfigureAwait(false))
|
|
43
|
+
{
|
|
44
|
+
cancellationToken.ThrowIfCancellationRequested();
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
var e = _events.Current;
|
|
48
|
+
return new TransportMessage(e.Data, e.Id, e.Retry);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public Task SendAsync(string text, CancellationToken cancellationToken) => dial.PostAsync(text, cancellationToken);
|
|
52
|
+
|
|
53
|
+
public ValueTask DisposeAsync() => stream.DisposeAsync();
|
|
54
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @generated by honey. DO NOT EDIT.
|
|
2
|
+
using System.Threading;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
|
|
5
|
+
namespace Honey.Runtime;
|
|
6
|
+
|
|
7
|
+
/// <summary>A realtime call's WebSocket: its own upgrade with the cursor as query params, no hook and no log on the dial.</summary>
|
|
8
|
+
public sealed class WsAdapter : ITransportAdapter, IDialed
|
|
9
|
+
{
|
|
10
|
+
private readonly Dial _dial;
|
|
11
|
+
|
|
12
|
+
internal WsAdapter(Dial dial) => _dial = dial;
|
|
13
|
+
|
|
14
|
+
Dial IDialed.Dial => _dial;
|
|
15
|
+
|
|
16
|
+
/// <summary><c>ws</c>.</summary>
|
|
17
|
+
public string Name => "ws";
|
|
18
|
+
|
|
19
|
+
/// <summary><see cref="TransportKind.Ws"/>.</summary>
|
|
20
|
+
public TransportKind Kind => TransportKind.Ws;
|
|
21
|
+
|
|
22
|
+
/// <summary>Dials the call's socket; <paramref name="url"/> is a caller's adapter's.</summary>
|
|
23
|
+
public async Task<ITransportConnection> ConnectAsync(string url, TransportOptions options, CancellationToken cancellationToken)
|
|
24
|
+
{
|
|
25
|
+
var x = _dial.Socket(options);
|
|
26
|
+
var socket = await WsDial.DialAsync(_dial.Client, x, options.Protocols, cancellationToken).ConfigureAwait(false);
|
|
27
|
+
_dial.Opened(x.Raw!);
|
|
28
|
+
return new WsConnection(socket);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
internal sealed class WsConnection(TypedWebSocket socket) : ITransportConnection
|
|
33
|
+
{
|
|
34
|
+
public async Task<TransportMessage?> ReceiveAsync(CancellationToken cancellationToken) =>
|
|
35
|
+
await socket.ReceiveAsync(cancellationToken).ConfigureAwait(false) is { } message ? new TransportMessage(message.Text) : null;
|
|
36
|
+
|
|
37
|
+
public Task SendAsync(string text, CancellationToken cancellationToken) => socket.SendAsync(text, cancellationToken);
|
|
38
|
+
|
|
39
|
+
public ValueTask DisposeAsync() => socket.DisposeAsync();
|
|
40
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// @generated by honey. DO NOT EDIT.
|
|
2
|
+
using System;
|
|
3
|
+
using System.Buffers;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using System.Globalization;
|
|
6
|
+
using System.Net.Http;
|
|
7
|
+
using System.Net.Http.Headers;
|
|
8
|
+
|
|
9
|
+
namespace Honey.Runtime;
|
|
10
|
+
|
|
11
|
+
internal static class Wire
|
|
12
|
+
{
|
|
13
|
+
/* RFC 9110's token: what a header name may hold */
|
|
14
|
+
private static readonly SearchValues<char> Tchar =
|
|
15
|
+
SearchValues.Create("!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
|
|
16
|
+
|
|
17
|
+
/* a non-token name, or a control but tab in a value, refused by the header's name, never its value */
|
|
18
|
+
public static void Check(IDictionary<string, string> headers)
|
|
19
|
+
{
|
|
20
|
+
foreach (var (name, value) in headers)
|
|
21
|
+
{
|
|
22
|
+
if (name.Length == 0 || name.AsSpan().ContainsAnyExcept(Tchar))
|
|
23
|
+
{
|
|
24
|
+
throw new ConfigException($"the {name} header cannot be sent");
|
|
25
|
+
}
|
|
26
|
+
foreach (var ch in value)
|
|
27
|
+
{
|
|
28
|
+
if ((ch < ' ' && ch != '\t') || ch == '\u007f')
|
|
29
|
+
{
|
|
30
|
+
throw new ConfigException($"the {name} header's value cannot be sent");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public static HttpRequestMessage Message(Hop hop)
|
|
37
|
+
{
|
|
38
|
+
/* not disposed: that would dispose the caller's stream */
|
|
39
|
+
var request = new HttpRequestMessage(new HttpMethod(hop.Method), hop.Url);
|
|
40
|
+
if (hop.Content is { } content)
|
|
41
|
+
{
|
|
42
|
+
request.Content = new ByteArrayContent(content);
|
|
43
|
+
}
|
|
44
|
+
else if (hop.Stream is { } stream)
|
|
45
|
+
{
|
|
46
|
+
request.Content = new StreamContent(stream);
|
|
47
|
+
request.Headers.TransferEncodingChunked = true;
|
|
48
|
+
}
|
|
49
|
+
foreach (var (name, value) in hop.Headers)
|
|
50
|
+
{
|
|
51
|
+
if (!request.Headers.TryAddWithoutValidation(name, value))
|
|
52
|
+
{
|
|
53
|
+
request.Content?.Headers.TryAddWithoutValidation(name, value);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (hop.Cross)
|
|
57
|
+
{
|
|
58
|
+
request.Options.Set(StripHandler.Cross, true);
|
|
59
|
+
}
|
|
60
|
+
return request;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public static Dictionary<string, string> HeadersOf(HttpResponseMessage response)
|
|
64
|
+
{
|
|
65
|
+
var headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
|
66
|
+
foreach (var group in new HttpHeaders[] { response.Headers, response.Content.Headers })
|
|
67
|
+
{
|
|
68
|
+
foreach (var (name, values) in group.NonValidated)
|
|
69
|
+
{
|
|
70
|
+
var lower = name.ToLowerInvariant();
|
|
71
|
+
var value = values.ToString();
|
|
72
|
+
headers[lower] = headers.TryGetValue(lower, out var seen) ? $"{seen}, {value}" : value;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return headers;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
internal static class ResponseHeaders
|
|
80
|
+
{
|
|
81
|
+
public static string? Text(IReadOnlyDictionary<string, string> headers, string name, bool required) =>
|
|
82
|
+
Value(headers, name, required);
|
|
83
|
+
|
|
84
|
+
public static long? Int64(IReadOnlyDictionary<string, string> headers, string name, bool required) =>
|
|
85
|
+
Value(headers, name, required) is { } text
|
|
86
|
+
? long.TryParse(text, NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var value) ? value : throw Invalid(name, "integer")
|
|
87
|
+
: null;
|
|
88
|
+
|
|
89
|
+
public static double? Double(IReadOnlyDictionary<string, string> headers, string name, bool required) =>
|
|
90
|
+
Value(headers, name, required) is { } text
|
|
91
|
+
? double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var value) ? value : throw Invalid(name, "number")
|
|
92
|
+
: null;
|
|
93
|
+
|
|
94
|
+
public static bool? Bool(IReadOnlyDictionary<string, string> headers, string name, bool required) =>
|
|
95
|
+
Value(headers, name, required) switch
|
|
96
|
+
{
|
|
97
|
+
null => null,
|
|
98
|
+
"true" => true,
|
|
99
|
+
"false" => false,
|
|
100
|
+
_ => throw Invalid(name, "boolean"),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
private static string? Value(IReadOnlyDictionary<string, string> headers, string name, bool required) =>
|
|
104
|
+
headers.TryGetValue(name.ToLowerInvariant(), out var value) ? value
|
|
105
|
+
: required ? throw new DecodeException($"the {name} header is missing")
|
|
106
|
+
: null;
|
|
107
|
+
|
|
108
|
+
private static DecodeException Invalid(string name, string kind) => new($"the {name} header is not a valid {kind}");
|
|
109
|
+
}
|