@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,118 @@
|
|
|
1
|
+
// Code generated by honey. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
package sdk
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"bytes"
|
|
7
|
+
"encoding/json"
|
|
8
|
+
"io"
|
|
9
|
+
"net/http"
|
|
10
|
+
"reflect"
|
|
11
|
+
"strings"
|
|
12
|
+
"time"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
// RequestOption overrides a client setting for one call. Options apply to a per-call copy, so the
|
|
16
|
+
// client itself never changes.
|
|
17
|
+
type RequestOption func(*requestConfig)
|
|
18
|
+
|
|
19
|
+
// requestConfig is one call's view of the client settings.
|
|
20
|
+
type requestConfig struct {
|
|
21
|
+
baseURL string
|
|
22
|
+
timeout time.Duration
|
|
23
|
+
headers map[string]string
|
|
24
|
+
response **http.Response
|
|
25
|
+
target headerTarget
|
|
26
|
+
safe *safeCall
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// headerTarget is implemented by the generated <Operation>Headers structs.
|
|
30
|
+
type headerTarget interface {
|
|
31
|
+
setFrom(http.Header)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// WithBaseURL sends this call to baseURL instead of Config.BaseURL.
|
|
35
|
+
func WithBaseURL(baseURL string) RequestOption {
|
|
36
|
+
return func(rc *requestConfig) { rc.baseURL = baseURL }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// WithTimeout bounds this call by d instead of Config.Timeout; d <= 0 removes the bound. A
|
|
40
|
+
// deadline already on ctx still applies when it is earlier. Streams ignore it.
|
|
41
|
+
func WithTimeout(d time.Duration) RequestOption {
|
|
42
|
+
return func(rc *requestConfig) { rc.timeout = d }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// WithHeader sets a header on this call, over Config.Headers and the operation's own headers.
|
|
46
|
+
func WithHeader(name, value string) RequestOption {
|
|
47
|
+
return func(rc *requestConfig) {
|
|
48
|
+
if rc.headers == nil {
|
|
49
|
+
rc.headers = map[string]string{}
|
|
50
|
+
}
|
|
51
|
+
rc.headers[http.CanonicalHeaderKey(name)] = value
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// WithResponseInto stores the raw response in *dst, on success and on an error status alike. Its
|
|
56
|
+
// Body is the buffered body and stays readable after the SDK decoded it; for a stream it is empty.
|
|
57
|
+
func WithResponseInto(dst **http.Response) RequestOption {
|
|
58
|
+
return func(rc *requestConfig) { rc.response = dst }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// WithHeadersInto fills h, an operation's generated Headers struct, from a successful response.
|
|
62
|
+
func WithHeadersInto(h headerTarget) RequestOption {
|
|
63
|
+
return func(rc *requestConfig) { rc.target = h }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
func newRequestConfig(cfg Config, opts []RequestOption) requestConfig {
|
|
67
|
+
rc := requestConfig{baseURL: cfg.BaseURL, timeout: cfg.Timeout}
|
|
68
|
+
for _, opt := range opts {
|
|
69
|
+
if opt != nil {
|
|
70
|
+
opt(&rc)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return rc
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// deliver hands the response to WithResponseInto and a safe call, a 2xx to WithHeadersInto.
|
|
77
|
+
func (rc *requestConfig) deliver(resp *http.Response, body []byte) {
|
|
78
|
+
if rc.response != nil {
|
|
79
|
+
*rc.response = withBody(resp, body)
|
|
80
|
+
}
|
|
81
|
+
if rc.safe != nil {
|
|
82
|
+
rc.safe.resp = withBody(resp, body)
|
|
83
|
+
}
|
|
84
|
+
if rc.target != nil && resp.StatusCode >= 200 && resp.StatusCode < 300 {
|
|
85
|
+
rc.target.setFrom(resp.Header)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// withBody is a copy of resp whose Body reads body, so every holder can read it in full.
|
|
90
|
+
func withBody(resp *http.Response, body []byte) *http.Response {
|
|
91
|
+
out := *resp
|
|
92
|
+
out.Body = io.NopCloser(bytes.NewReader(body))
|
|
93
|
+
return &out
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// setHeaderField decodes the named header into dst, a pointer to a generated Headers field: a
|
|
97
|
+
// string kind as sent, any other type from its JSON literal (numbers, booleans). An absent or
|
|
98
|
+
// undecodable header leaves the field unchanged; a pointer field is allocated only on success.
|
|
99
|
+
func setHeaderField(h http.Header, name string, dst any) {
|
|
100
|
+
values := h.Values(name)
|
|
101
|
+
if len(values) == 0 {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
raw := strings.Join(values, ", ")
|
|
105
|
+
field := reflect.ValueOf(dst).Elem()
|
|
106
|
+
target := field
|
|
107
|
+
if field.Kind() == reflect.Pointer {
|
|
108
|
+
target = reflect.New(field.Type().Elem()).Elem()
|
|
109
|
+
}
|
|
110
|
+
if target.Kind() == reflect.String {
|
|
111
|
+
target.SetString(raw)
|
|
112
|
+
} else if json.Unmarshal([]byte(raw), target.Addr().Interface()) != nil {
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
if field.Kind() == reflect.Pointer {
|
|
116
|
+
field.Set(target.Addr())
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Code generated by honey. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
package sdk
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"fmt"
|
|
7
|
+
"strings"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// PathParamError reports a path parameter that is missing, or that would change the request path
|
|
11
|
+
// once a URL parser normalizes it ("", "." and "..").
|
|
12
|
+
type PathParamError struct {
|
|
13
|
+
Name string
|
|
14
|
+
Value string
|
|
15
|
+
Missing bool
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
func (e *PathParamError) Error() string {
|
|
19
|
+
if e.Missing {
|
|
20
|
+
return "Missing path param: " + e.Name
|
|
21
|
+
}
|
|
22
|
+
return fmt.Sprintf("Invalid path param %q: %q is not a path segment", e.Name, e.Value)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
func percentEncode(s string, keep string, spaceAsPlus bool) string {
|
|
26
|
+
const hex = "0123456789ABCDEF"
|
|
27
|
+
var b strings.Builder
|
|
28
|
+
for i := 0; i < len(s); i++ {
|
|
29
|
+
c := s[i]
|
|
30
|
+
switch {
|
|
31
|
+
case (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || strings.IndexByte(keep, c) >= 0:
|
|
32
|
+
b.WriteByte(c)
|
|
33
|
+
case c == ' ' && spaceAsPlus:
|
|
34
|
+
b.WriteByte('+')
|
|
35
|
+
default:
|
|
36
|
+
b.WriteByte('%')
|
|
37
|
+
b.WriteByte(hex[c>>4])
|
|
38
|
+
b.WriteByte(hex[c&0x0f])
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return b.String()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// escapePathSegment encodes like JavaScript's encodeURIComponent, so every SDK sends the same
|
|
45
|
+
// path bytes.
|
|
46
|
+
func escapePathSegment(s string) string { return percentEncode(s, "-_.!~*'()", false) }
|
|
47
|
+
|
|
48
|
+
// escapeQueryComponent encodes like URLSearchParams (a space becomes '+').
|
|
49
|
+
func escapeQueryComponent(s string) string { return percentEncode(s, "*-._", true) }
|
|
50
|
+
|
|
51
|
+
// encodeSegmentValue escapes one segment value, refusing the values a URL parser collapses.
|
|
52
|
+
func encodeSegmentValue(name, value string) (string, error) {
|
|
53
|
+
if value == "" || value == "." || value == ".." {
|
|
54
|
+
return "", &PathParamError{Name: name, Value: value}
|
|
55
|
+
}
|
|
56
|
+
return escapePathSegment(value), nil
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// expandPath fills a path template segment by segment, with the TypeScript client's grammar:
|
|
60
|
+
// `:name` (or `:name?`) takes a whole segment, `*name` (or `*`) as the last segment takes the rest
|
|
61
|
+
// of the path, and `{name}` may appear anywhere inside a segment. Values are escaped, and values a
|
|
62
|
+
// URL parser would collapse ("", ".", "..") are refused.
|
|
63
|
+
func expandPath(template string, params map[string]string) (string, error) {
|
|
64
|
+
segments := strings.Split(template, "/")
|
|
65
|
+
out := make([]string, 0, len(segments))
|
|
66
|
+
for i, seg := range segments {
|
|
67
|
+
var (
|
|
68
|
+
enc string
|
|
69
|
+
keep = true
|
|
70
|
+
err error
|
|
71
|
+
)
|
|
72
|
+
switch {
|
|
73
|
+
case len(seg) > 1 && seg[0] == ':':
|
|
74
|
+
enc, keep, err = expandColon(seg, params)
|
|
75
|
+
case len(seg) > 0 && seg[0] == '*' && i == len(segments)-1:
|
|
76
|
+
enc, err = expandWildcard(seg, params)
|
|
77
|
+
default:
|
|
78
|
+
enc, err = expandBraces(seg, params)
|
|
79
|
+
}
|
|
80
|
+
if err != nil {
|
|
81
|
+
return "", err
|
|
82
|
+
}
|
|
83
|
+
if keep {
|
|
84
|
+
out = append(out, enc)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return strings.Join(out, "/"), nil
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// expandColon fills a `:name` segment; an absent optional `:name?` drops the segment.
|
|
91
|
+
func expandColon(seg string, params map[string]string) (string, bool, error) {
|
|
92
|
+
name, optional := strings.CutSuffix(seg[1:], "?")
|
|
93
|
+
value, ok := params[name]
|
|
94
|
+
if !ok {
|
|
95
|
+
if optional {
|
|
96
|
+
return "", false, nil
|
|
97
|
+
}
|
|
98
|
+
return "", false, &PathParamError{Name: name, Missing: true}
|
|
99
|
+
}
|
|
100
|
+
enc, err := encodeSegmentValue(name, value)
|
|
101
|
+
return enc, true, err
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// expandWildcard fills a trailing `*name` (or bare `*`) with the rest of the path, each of its
|
|
105
|
+
// segments escaped and checked.
|
|
106
|
+
func expandWildcard(seg string, params map[string]string) (string, error) {
|
|
107
|
+
name := "*"
|
|
108
|
+
if len(seg) > 1 {
|
|
109
|
+
name = seg[1:]
|
|
110
|
+
}
|
|
111
|
+
value, ok := params[name]
|
|
112
|
+
if !ok && len(seg) > 1 {
|
|
113
|
+
return "", &PathParamError{Name: name, Missing: true}
|
|
114
|
+
}
|
|
115
|
+
if value == "" {
|
|
116
|
+
return "", nil
|
|
117
|
+
}
|
|
118
|
+
parts := strings.Split(value, "/")
|
|
119
|
+
for j, part := range parts {
|
|
120
|
+
enc, err := encodeSegmentValue(name, part)
|
|
121
|
+
if err != nil {
|
|
122
|
+
return "", err
|
|
123
|
+
}
|
|
124
|
+
parts[j] = enc
|
|
125
|
+
}
|
|
126
|
+
return strings.Join(parts, "/"), nil
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// expandBraces fills each `{name}` inside a segment; text around them is kept as written.
|
|
130
|
+
func expandBraces(seg string, params map[string]string) (string, error) {
|
|
131
|
+
var b strings.Builder
|
|
132
|
+
rest := seg
|
|
133
|
+
for {
|
|
134
|
+
open := strings.IndexByte(rest, '{')
|
|
135
|
+
end := -1
|
|
136
|
+
if open >= 0 {
|
|
137
|
+
end = strings.IndexByte(rest[open:], '}')
|
|
138
|
+
}
|
|
139
|
+
if open < 0 || end < 0 || strings.ContainsRune(rest[open+1:open+end], '{') {
|
|
140
|
+
b.WriteString(rest)
|
|
141
|
+
return b.String(), nil
|
|
142
|
+
}
|
|
143
|
+
name := rest[open+1 : open+end]
|
|
144
|
+
value, ok := params[name]
|
|
145
|
+
if !ok {
|
|
146
|
+
return "", &PathParamError{Name: name, Missing: true}
|
|
147
|
+
}
|
|
148
|
+
enc, err := encodeSegmentValue(name, value)
|
|
149
|
+
if err != nil {
|
|
150
|
+
return "", err
|
|
151
|
+
}
|
|
152
|
+
b.WriteString(rest[:open])
|
|
153
|
+
b.WriteString(enc)
|
|
154
|
+
rest = rest[open+end+1:]
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// Code generated by honey. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
package sdk
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"fmt"
|
|
8
|
+
"math"
|
|
9
|
+
"net/url"
|
|
10
|
+
"reflect"
|
|
11
|
+
"strconv"
|
|
12
|
+
"strings"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
// queryPair is one key=value in send order.
|
|
16
|
+
type queryPair struct {
|
|
17
|
+
key string
|
|
18
|
+
value string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type queryList []queryPair
|
|
22
|
+
|
|
23
|
+
// set appends v under key: nil, nil pointers and empty maps are skipped, slices repeat the key.
|
|
24
|
+
func (q *queryList) set(key string, v any) {
|
|
25
|
+
rv := reflect.ValueOf(v)
|
|
26
|
+
for rv.IsValid() && (rv.Kind() == reflect.Pointer || rv.Kind() == reflect.Interface) {
|
|
27
|
+
if rv.IsNil() {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
rv = rv.Elem()
|
|
31
|
+
}
|
|
32
|
+
if !rv.IsValid() || rv.Kind() == reflect.Map && rv.Len() == 0 {
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
if (rv.Kind() == reflect.Slice || rv.Kind() == reflect.Array) && rv.Type().Elem().Kind() != reflect.Uint8 {
|
|
36
|
+
for i := 0; i < rv.Len(); i++ {
|
|
37
|
+
q.set(key, rv.Index(i).Interface())
|
|
38
|
+
}
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
*q = append(*q, queryPair{key: key, value: formatQueryValue(rv.Interface())})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
func (q queryList) encode() string {
|
|
45
|
+
parts := make([]string, 0, len(q))
|
|
46
|
+
for _, p := range q {
|
|
47
|
+
parts = append(parts, escapeQueryComponent(p.key)+"="+escapeQueryComponent(p.value))
|
|
48
|
+
}
|
|
49
|
+
return strings.Join(parts, "&")
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// setHeaderValue sets a header parameter: nil and nil pointers are skipped, slices are joined with
|
|
53
|
+
// commas.
|
|
54
|
+
func setHeaderValue(h map[string]string, name string, v any) {
|
|
55
|
+
var q queryList
|
|
56
|
+
q.set(name, v)
|
|
57
|
+
if len(q) == 0 {
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
values := make([]string, 0, len(q))
|
|
61
|
+
for _, p := range q {
|
|
62
|
+
values = append(values, p.value)
|
|
63
|
+
}
|
|
64
|
+
h[name] = strings.Join(values, ",")
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// formatQueryValue renders a scalar the way every SDK language does: strings as is, booleans as
|
|
68
|
+
// true/false, numbers in shortest decimal form, anything else as JSON.
|
|
69
|
+
func formatQueryValue(v any) string {
|
|
70
|
+
rv := reflect.ValueOf(v)
|
|
71
|
+
switch rv.Kind() {
|
|
72
|
+
case reflect.String:
|
|
73
|
+
return rv.String()
|
|
74
|
+
case reflect.Bool:
|
|
75
|
+
return strconv.FormatBool(rv.Bool())
|
|
76
|
+
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
|
77
|
+
return strconv.FormatInt(rv.Int(), 10)
|
|
78
|
+
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
|
79
|
+
return strconv.FormatUint(rv.Uint(), 10)
|
|
80
|
+
case reflect.Float32, reflect.Float64:
|
|
81
|
+
return formatFloatJS(rv.Float())
|
|
82
|
+
}
|
|
83
|
+
encoded, err := json.Marshal(v)
|
|
84
|
+
if err != nil {
|
|
85
|
+
return fmt.Sprint(v)
|
|
86
|
+
}
|
|
87
|
+
return string(encoded)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// formatFloatJS renders a float like JavaScript's Number#toString.
|
|
91
|
+
func formatFloatJS(f float64) string {
|
|
92
|
+
switch {
|
|
93
|
+
case math.IsNaN(f):
|
|
94
|
+
return "NaN"
|
|
95
|
+
case math.IsInf(f, 1):
|
|
96
|
+
return "Infinity"
|
|
97
|
+
case math.IsInf(f, -1):
|
|
98
|
+
return "-Infinity"
|
|
99
|
+
case f == 0:
|
|
100
|
+
return "0"
|
|
101
|
+
}
|
|
102
|
+
abs := math.Abs(f)
|
|
103
|
+
if abs >= 1e-6 && abs < 1e21 {
|
|
104
|
+
return strconv.FormatFloat(f, 'f', -1, 64)
|
|
105
|
+
}
|
|
106
|
+
mantissa, exp, _ := strings.Cut(strconv.FormatFloat(f, 'e', -1, 64), "e")
|
|
107
|
+
n, _ := strconv.Atoi(exp)
|
|
108
|
+
sign := "+"
|
|
109
|
+
if n < 0 {
|
|
110
|
+
sign = "-"
|
|
111
|
+
n = -n
|
|
112
|
+
}
|
|
113
|
+
return mantissa + "e" + sign + strconv.Itoa(n)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// buildURL joins base and an already escaped path, keeping the base path and base query, then
|
|
117
|
+
// appends the query pairs.
|
|
118
|
+
func buildURL(baseURL, path string, query queryList) (string, error) {
|
|
119
|
+
base, err := url.Parse(baseURL)
|
|
120
|
+
if err != nil {
|
|
121
|
+
return "", err
|
|
122
|
+
}
|
|
123
|
+
if base.Scheme == "" || base.Host == "" {
|
|
124
|
+
return "", fmt.Errorf("honey: base URL %q needs a scheme and host", baseURL)
|
|
125
|
+
}
|
|
126
|
+
if !strings.HasPrefix(path, "/") {
|
|
127
|
+
path = "/" + path
|
|
128
|
+
}
|
|
129
|
+
out := *base
|
|
130
|
+
out.Fragment = ""
|
|
131
|
+
out.RawFragment = ""
|
|
132
|
+
joined := strings.TrimRight(base.EscapedPath(), "/") + path
|
|
133
|
+
unescaped, err := url.PathUnescape(joined)
|
|
134
|
+
if err != nil {
|
|
135
|
+
return "", err
|
|
136
|
+
}
|
|
137
|
+
out.Path = unescaped
|
|
138
|
+
out.RawPath = joined
|
|
139
|
+
extra := query.encode()
|
|
140
|
+
switch {
|
|
141
|
+
case out.RawQuery == "":
|
|
142
|
+
out.RawQuery = extra
|
|
143
|
+
case extra != "":
|
|
144
|
+
out.RawQuery += "&" + extra
|
|
145
|
+
}
|
|
146
|
+
return out.String(), nil
|
|
147
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// Code generated by honey. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
package sdk
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"context"
|
|
7
|
+
"errors"
|
|
8
|
+
"net/http"
|
|
9
|
+
"strings"
|
|
10
|
+
"sync"
|
|
11
|
+
"time"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
// ConnectionState is the realtime lifecycle state.
|
|
15
|
+
type ConnectionState int
|
|
16
|
+
|
|
17
|
+
// Connection lifecycle states: Connecting, Connected, Reconnecting, Disconnected.
|
|
18
|
+
const (
|
|
19
|
+
StateConnecting ConnectionState = iota
|
|
20
|
+
StateConnected
|
|
21
|
+
StateReconnecting
|
|
22
|
+
StateDisconnected
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
// String returns the lower-case name every SDK uses.
|
|
26
|
+
func (s ConnectionState) String() string {
|
|
27
|
+
switch s {
|
|
28
|
+
case StateConnecting:
|
|
29
|
+
return "connecting"
|
|
30
|
+
case StateConnected:
|
|
31
|
+
return "connected"
|
|
32
|
+
case StateReconnecting:
|
|
33
|
+
return "reconnecting"
|
|
34
|
+
case StateDisconnected:
|
|
35
|
+
return "disconnected"
|
|
36
|
+
}
|
|
37
|
+
return "unknown"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const (
|
|
41
|
+
defaultReconnectAttempts = 5
|
|
42
|
+
defaultReconnectDelay = time.Second
|
|
43
|
+
maxReconnectDelay = 30 * time.Second
|
|
44
|
+
openTimeout = 30 * time.Second
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
// ErrConnectionClosed is returned by Connect after Close.
|
|
48
|
+
var ErrConnectionClosed = errors.New("honey: ResumableConnection closed")
|
|
49
|
+
|
|
50
|
+
// ResumableConnection runs a chain of Transports: the last one that worked is tried first, then
|
|
51
|
+
// the whole chain in order. Events arrive on Events() and a terminal error on Errors(); Close stops
|
|
52
|
+
// the read goroutine and then closes both channels.
|
|
53
|
+
//
|
|
54
|
+
// Each delivered event advances the resume cursor (LastEventID and ReconnectToken), so a reconnect
|
|
55
|
+
// resumes after the last event delivered. Reconnects back off exponentially from ReconnectDelayMs
|
|
56
|
+
// (default 1s, capped at 30s, with jitter) for up to MaxReconnectAttempts (default 5; negative
|
|
57
|
+
// means unlimited); exhaustion is reported on Errors().
|
|
58
|
+
type ResumableConnection struct {
|
|
59
|
+
url string
|
|
60
|
+
transports []Transport
|
|
61
|
+
|
|
62
|
+
events chan any
|
|
63
|
+
errs chan error
|
|
64
|
+
/* ctx is canceled by Close; every wait in the read loop selects on it */
|
|
65
|
+
ctx context.Context
|
|
66
|
+
cancel context.CancelFunc
|
|
67
|
+
|
|
68
|
+
mu sync.Mutex
|
|
69
|
+
opts TransportOpts /* guarded: the cursor fields advance */
|
|
70
|
+
state ConnectionState
|
|
71
|
+
conn TransportConn
|
|
72
|
+
provenIdx int /* -1 = none yet */
|
|
73
|
+
closed bool
|
|
74
|
+
running bool
|
|
75
|
+
loopDone chan struct{}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// NewResumableConnection builds a connection over transports; opts is copied (nil means
|
|
79
|
+
// defaults). It panics when transports is empty, a programming error.
|
|
80
|
+
func NewResumableConnection(baseURL string, transports []Transport, opts *TransportOpts) *ResumableConnection {
|
|
81
|
+
if len(transports) == 0 {
|
|
82
|
+
panic("honey: NewResumableConnection requires at least one transport")
|
|
83
|
+
}
|
|
84
|
+
var o TransportOpts
|
|
85
|
+
if opts != nil {
|
|
86
|
+
o = *opts
|
|
87
|
+
}
|
|
88
|
+
ctx, cancel := context.WithCancel(context.Background())
|
|
89
|
+
return &ResumableConnection{
|
|
90
|
+
url: baseURL, transports: transports, opts: o,
|
|
91
|
+
events: make(chan any, 16), errs: make(chan error, 4),
|
|
92
|
+
ctx: ctx, cancel: cancel, state: StateDisconnected, provenIdx: -1,
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// newRealtime connects the call's connection over the default WebSocket, SSE and long-poll chain,
|
|
97
|
+
// with the client's auth (its current token at each dial), headers and redirect policy; ctx bounds
|
|
98
|
+
// the open. The headers hold no X-Request-Id unless the caller set one: each dial mints its own.
|
|
99
|
+
func newRealtime(ctx context.Context, cfg Config, c *call, topts TransportOpts, opts []RequestOption) (*ResumableConnection, error) {
|
|
100
|
+
rc := newRequestConfig(cfg, opts)
|
|
101
|
+
u, err := buildURL(rc.baseURL, c.path, c.query)
|
|
102
|
+
if err != nil {
|
|
103
|
+
return nil, err
|
|
104
|
+
}
|
|
105
|
+
topts.HTTPClient = streamClient(cfg)
|
|
106
|
+
if topts.KeepAlive == 0 {
|
|
107
|
+
topts.KeepAlive = cfg.WSKeepalive
|
|
108
|
+
}
|
|
109
|
+
topts.headersOf = func() http.Header { return mergeHeaders(cfg, cfg.auth.current(cfg), "", c.headers, rc.headers) }
|
|
110
|
+
topts.onRequest, topts.onResponse = cfg.OnRequest, cfg.OnResponse
|
|
111
|
+
topts.send = func(ctx context.Context, data any) error {
|
|
112
|
+
_, err := doRequest(ctx, cfg, c.sent(data), opts)
|
|
113
|
+
return err
|
|
114
|
+
}
|
|
115
|
+
if cfg.OnAuthExpired != nil {
|
|
116
|
+
topts.refresh = func(ctx context.Context) bool {
|
|
117
|
+
_, err := cfg.auth.refresh(ctx, cfg, cfg.auth.current(cfg))
|
|
118
|
+
return err == nil
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
r := NewResumableConnection(u, []Transport{&WsTransport{}, &SseTransport{}, &LongpollTransport{}}, &topts)
|
|
122
|
+
if err := r.Connect(ctx); err != nil {
|
|
123
|
+
return nil, err
|
|
124
|
+
}
|
|
125
|
+
return r, nil
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Events returns the decoded payloads.
|
|
129
|
+
func (r *ResumableConnection) Events() <-chan any { return r.events }
|
|
130
|
+
|
|
131
|
+
// Errors returns the terminal transport errors.
|
|
132
|
+
func (r *ResumableConnection) Errors() <-chan error { return r.errs }
|
|
133
|
+
|
|
134
|
+
// State reports the lifecycle state.
|
|
135
|
+
func (r *ResumableConnection) State() ConnectionState {
|
|
136
|
+
r.mu.Lock()
|
|
137
|
+
defer r.mu.Unlock()
|
|
138
|
+
return r.state
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Cursor reports the resume cursor: the last delivered event ID and reconnect token.
|
|
142
|
+
func (r *ResumableConnection) Cursor() (lastEventID, reconnectToken string) {
|
|
143
|
+
r.mu.Lock()
|
|
144
|
+
defer r.mu.Unlock()
|
|
145
|
+
return r.opts.LastEventID, r.opts.ReconnectToken
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ProvenTransport reports the kind of the last transport that opened, if any.
|
|
149
|
+
func (r *ResumableConnection) ProvenTransport() (TransportKind, bool) {
|
|
150
|
+
r.mu.Lock()
|
|
151
|
+
defer r.mu.Unlock()
|
|
152
|
+
if r.provenIdx < 0 || r.provenIdx >= len(r.transports) {
|
|
153
|
+
return "", false
|
|
154
|
+
}
|
|
155
|
+
return r.transports[r.provenIdx].Kind(), true
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Connect opens the chain and starts the read goroutine. ctx bounds the open only; the stream
|
|
159
|
+
// lives until Close. It returns once a transport opened, or the last transport error. It is a
|
|
160
|
+
// no-op while connected or connecting; after the read goroutine gave up, it starts over.
|
|
161
|
+
func (r *ResumableConnection) Connect(ctx context.Context) error {
|
|
162
|
+
r.mu.Lock()
|
|
163
|
+
if r.closed {
|
|
164
|
+
r.mu.Unlock()
|
|
165
|
+
return ErrConnectionClosed
|
|
166
|
+
}
|
|
167
|
+
if r.running {
|
|
168
|
+
r.mu.Unlock()
|
|
169
|
+
return nil
|
|
170
|
+
}
|
|
171
|
+
r.running = true
|
|
172
|
+
r.state = StateConnecting
|
|
173
|
+
if r.provenIdx >= 0 {
|
|
174
|
+
r.state = StateReconnecting
|
|
175
|
+
}
|
|
176
|
+
r.mu.Unlock()
|
|
177
|
+
if err := r.openChain(ctx); err != nil {
|
|
178
|
+
r.mu.Lock()
|
|
179
|
+
r.running = false
|
|
180
|
+
r.state = StateDisconnected
|
|
181
|
+
r.mu.Unlock()
|
|
182
|
+
return err
|
|
183
|
+
}
|
|
184
|
+
done := make(chan struct{})
|
|
185
|
+
r.mu.Lock()
|
|
186
|
+
r.loopDone = done
|
|
187
|
+
r.mu.Unlock()
|
|
188
|
+
go r.readLoop(done)
|
|
189
|
+
return nil
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Close stops the read goroutine, closes the active transport, then closes Events and Errors. It
|
|
193
|
+
// is safe to call more than once and concurrently with reads; Connect afterwards fails.
|
|
194
|
+
func (r *ResumableConnection) Close() error {
|
|
195
|
+
r.mu.Lock()
|
|
196
|
+
if r.closed {
|
|
197
|
+
r.mu.Unlock()
|
|
198
|
+
return nil
|
|
199
|
+
}
|
|
200
|
+
r.closed = true
|
|
201
|
+
conn := r.conn
|
|
202
|
+
r.conn = nil
|
|
203
|
+
r.state = StateDisconnected
|
|
204
|
+
done := r.loopDone
|
|
205
|
+
r.mu.Unlock()
|
|
206
|
+
/* the transport closes first: a WebSocket read whose ctx ends drops the connection without the close frame */
|
|
207
|
+
if conn != nil {
|
|
208
|
+
_ = conn.Close()
|
|
209
|
+
}
|
|
210
|
+
r.cancel()
|
|
211
|
+
if done != nil {
|
|
212
|
+
<-done
|
|
213
|
+
}
|
|
214
|
+
close(r.events)
|
|
215
|
+
close(r.errs)
|
|
216
|
+
return nil
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Send writes data on the active transport: a WebSocket frame, else a POST answered as a call is
|
|
220
|
+
// (a 2xx past MaxResponseBytes a *DecodeError).
|
|
221
|
+
func (r *ResumableConnection) Send(ctx context.Context, data any) error {
|
|
222
|
+
r.mu.Lock()
|
|
223
|
+
conn := r.conn
|
|
224
|
+
r.mu.Unlock()
|
|
225
|
+
if conn == nil {
|
|
226
|
+
return errors.New("honey: ResumableConnection not connected")
|
|
227
|
+
}
|
|
228
|
+
return conn.Send(ctx, data)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// sent is a send's POST over SSE or long-poll: a string as text, any other value as JSON.
|
|
232
|
+
func (c *call) sent(data any) *call {
|
|
233
|
+
body := jsonBody(data)
|
|
234
|
+
if text, ok := data.(string); ok {
|
|
235
|
+
body = rawBody([]byte(text), "text/plain")
|
|
236
|
+
}
|
|
237
|
+
op := http.MethodPost + strings.TrimPrefix(c.operation, c.method)
|
|
238
|
+
return &call{method: http.MethodPost, path: c.path, operation: op, query: c.query, headers: c.headers, body: body, stale: c.stale}
|
|
239
|
+
}
|