@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,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning a service map into query keys (bit 22): which entries are readable, how a route selector and a
|
|
3
|
+
* `{param}` path meet at one spelling, and what key a read is cached under. One body of knowledge — an
|
|
4
|
+
* `x-invalidate` target names a route and a key names a member path, and this is the only place that
|
|
5
|
+
* crosses between them. `query.ts` holds the surfaces that use it.
|
|
6
|
+
*/
|
|
7
|
+
import type { QueryKey } from "@tanstack/query-core"
|
|
8
|
+
import type { ServiceEntry, ServiceMap } from "../ts/sdk.ts"
|
|
9
|
+
|
|
10
|
+
/** The one method a cache reads from; every other method is a write. */
|
|
11
|
+
export const READ = "GET"
|
|
12
|
+
|
|
13
|
+
export function isEntry(node: unknown): node is ServiceEntry {
|
|
14
|
+
return (
|
|
15
|
+
typeof node === "object" &&
|
|
16
|
+
node !== null &&
|
|
17
|
+
Object.hasOwn(node, "method") &&
|
|
18
|
+
typeof (node as ServiceEntry).method === "string" &&
|
|
19
|
+
Object.hasOwn(node, "path")
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A stream or a connection is not a cache entry, so it is in no surface. */
|
|
24
|
+
export function isStream(entry: ServiceEntry): boolean {
|
|
25
|
+
return entry.sse !== undefined || entry.ws === true || entry.realtime === true
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Only an own key is an operation: never `toString`, `constructor` or `then`. */
|
|
29
|
+
export function childOf(node: ServiceMap | ServiceEntry, key: string): ServiceMap | ServiceEntry | undefined {
|
|
30
|
+
return Object.hasOwn(node, key) ? (node as Record<string, ServiceMap | ServiceEntry>)[key] : undefined
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** `/orgs/{id}` → `/orgs/:id`, so a `{param}` path and a `:param` selector meet at one spelling. */
|
|
34
|
+
function normalizePath(path: string): string {
|
|
35
|
+
return path
|
|
36
|
+
.split("/")
|
|
37
|
+
.map((segment) => {
|
|
38
|
+
const braced = /^\{([^{}/]+)\}$/.exec(segment)
|
|
39
|
+
return braced === null ? segment : `:${braced[1] as string}`
|
|
40
|
+
})
|
|
41
|
+
.join("/")
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** `GET /orgs/{id}` and `get /orgs/:id` normalize alike; a selector with no space has no method. */
|
|
45
|
+
function normalizeSelector(selector: string): string | undefined {
|
|
46
|
+
const space = selector.indexOf(" ")
|
|
47
|
+
if (space <= 0) return undefined
|
|
48
|
+
return `${selector.slice(0, space).toUpperCase()} ${normalizePath(selector.slice(space + 1))}`
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type Read = { member: string[]; params: readonly string[] }
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Every readable entry by its normalized selector. An `x-invalidate` target names a route, and a query key
|
|
55
|
+
* names a member path and its params, so this is the one table that turns one into the other. Built once
|
|
56
|
+
* per helper set: a map walk per mutation would be the O(n) cost this avoids.
|
|
57
|
+
*/
|
|
58
|
+
export function indexReads(map: ServiceMap): Map<string, Read> {
|
|
59
|
+
const reads = new Map<string, Read>()
|
|
60
|
+
const walk = (node: ServiceMap, member: string[]): void => {
|
|
61
|
+
for (const key of Object.keys(node)) {
|
|
62
|
+
const child = childOf(node, key)
|
|
63
|
+
if (child === undefined) continue
|
|
64
|
+
if (!isEntry(child)) {
|
|
65
|
+
walk(child as ServiceMap, [...member, key])
|
|
66
|
+
continue
|
|
67
|
+
}
|
|
68
|
+
if (child.method !== READ || isStream(child)) continue
|
|
69
|
+
reads.set(`${READ} ${normalizePath(child.path)}`, {
|
|
70
|
+
member: [...member, key],
|
|
71
|
+
params: child.params ?? [],
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
walk(map, [])
|
|
76
|
+
return reads
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The `params` of an SDK input, string values only: a key holds what addresses a resource. */
|
|
80
|
+
export function paramsOf(input: unknown): Record<string, string> {
|
|
81
|
+
if (typeof input !== "object" || input === null || !Object.hasOwn(input, "params")) return {}
|
|
82
|
+
const raw = (input as { params?: unknown }).params
|
|
83
|
+
if (typeof raw !== "object" || raw === null) return {}
|
|
84
|
+
const params: Record<string, string> = {}
|
|
85
|
+
for (const [key, value] of Object.entries(raw)) if (typeof value === "string" && value !== "") params[key] = value
|
|
86
|
+
return params
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* There are two kinds of key here and they are not the same job.
|
|
91
|
+
*
|
|
92
|
+
* `readKey` is an IDENTITY: the key one read is cached under. TanStack needs every input the `queryFn`
|
|
93
|
+
* sends to be in it, so it holds the request object whole — `params`, `search`, and anything else the SDK
|
|
94
|
+
* puts there. Only the request: `init` carries a signal and a timeout, which say nothing about the answer
|
|
95
|
+
* and would not hash. Two reads of one route that differ by search are two entries, which is the whole
|
|
96
|
+
* point.
|
|
97
|
+
*
|
|
98
|
+
* `keyOf` is a FILTER: the prefix an `x-invalidate` target makes stale. A mutation knows its own path
|
|
99
|
+
* params and nothing about what a reader searched for, so it names `{ params }` at most and TanStack's
|
|
100
|
+
* partial matching does the rest — `[sdk, …member, { params }]` matches a longer key that also carries
|
|
101
|
+
* `search`, and `[sdk, …member]` matches every search there is.
|
|
102
|
+
*
|
|
103
|
+
* Collapsing the two is what shipped in 1.0.0-rc.8 with `search` missing from read keys.
|
|
104
|
+
*/
|
|
105
|
+
export function readKey(sdkName: string, member: readonly string[], req: unknown): QueryKey {
|
|
106
|
+
const prefix = [sdkName, ...member]
|
|
107
|
+
return req === undefined ? prefix : [...prefix, req]
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The marker that keeps a paged read off the plain read's entry: their cached shapes differ, one being
|
|
112
|
+
* `InfiniteData`. It goes LAST so an invalidation filter still prefix-matches the paged key — a filter
|
|
113
|
+
* compares only its own positions, so a shorter one reaches the longer key.
|
|
114
|
+
*/
|
|
115
|
+
export const INFINITE = "infinite"
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The prefix an `x-invalidate` target makes stale: the read's member path, plus `{ params }` once every
|
|
119
|
+
* path param has a value. One missing value leaves the bare prefix, which invalidates every query of that
|
|
120
|
+
* read — the key-space answer to a partially resolved route, never a dropped target.
|
|
121
|
+
*/
|
|
122
|
+
export function keyOf(sdkName: string, read: Read, params: Record<string, string>): QueryKey {
|
|
123
|
+
const prefix = [sdkName, ...read.member]
|
|
124
|
+
if (read.params.length === 0) return prefix
|
|
125
|
+
const filled: Record<string, string> = {}
|
|
126
|
+
for (const name of read.params) {
|
|
127
|
+
const value = params[name]
|
|
128
|
+
if (value === undefined) return prefix
|
|
129
|
+
filled[name] = value
|
|
130
|
+
}
|
|
131
|
+
return [...prefix, { params: filled }]
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** The keys a successful `selector` write makes stale. */
|
|
135
|
+
export function invalidatedBy(
|
|
136
|
+
reads: Map<string, Read>,
|
|
137
|
+
sdkName: string,
|
|
138
|
+
entry: ServiceEntry,
|
|
139
|
+
input: unknown,
|
|
140
|
+
): QueryKey[] {
|
|
141
|
+
if (entry.invalidate === undefined || entry.invalidate.length === 0) return []
|
|
142
|
+
const params = paramsOf(input)
|
|
143
|
+
const keys: QueryKey[] = []
|
|
144
|
+
for (const target of entry.invalidate) {
|
|
145
|
+
const selector = normalizeSelector(target)
|
|
146
|
+
if (selector === undefined) continue
|
|
147
|
+
const read = reads.get(selector)
|
|
148
|
+
if (read === undefined) continue
|
|
149
|
+
keys.push(keyOf(sdkName, read, params))
|
|
150
|
+
}
|
|
151
|
+
return keys
|
|
152
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The TanStack Query adapter a TS SDK vendors (bit 22), emitted beside it as
|
|
3
|
+
* `<stem>.tanstack-query.gen.ts` under `--ts-tanstack-query`. Read as text by `emit/ts/tanstack-query.ts`
|
|
4
|
+
* and never imported by the generator, like every other `runtime/` module; its `../ts/*.ts` imports are
|
|
5
|
+
* rewritten to the emitted runtime on the way out, so this file type-checks here and resolves there.
|
|
6
|
+
*
|
|
7
|
+
* Three surfaces over the service map, which is the authority for every question: `query` for the `GET`
|
|
8
|
+
* entries, `mutation` for the rest, and `infiniteQuery` for a paged read. An entry that is an event stream,
|
|
9
|
+
* a websocket or a realtime connection belongs to neither — a stream is not a cache entry — and asking for
|
|
10
|
+
* one gives `undefined` rather than a factory that would key a stream as data.
|
|
11
|
+
*
|
|
12
|
+
* `@tanstack/query-core` is imported for types only: an emitted SDK is loaded from the consumer's own tree
|
|
13
|
+
* (and, in this repository's tests, from outside it), so a value import would have to resolve at run time.
|
|
14
|
+
* That is also why a read's options carry `initialData: undefined` — solid-query reads
|
|
15
|
+
* `initialData?: Data | undefined` as the seeded overload, and the consumer that drives this is Solid.
|
|
16
|
+
*/
|
|
17
|
+
import type {
|
|
18
|
+
DataTag,
|
|
19
|
+
DefaultError,
|
|
20
|
+
InfiniteData,
|
|
21
|
+
InfiniteQueryObserverOptions,
|
|
22
|
+
MutationObserverOptions,
|
|
23
|
+
QueryClient,
|
|
24
|
+
QueryKey,
|
|
25
|
+
QueryObserverOptions,
|
|
26
|
+
} from "@tanstack/query-core"
|
|
27
|
+
import type { ServiceEntry, ServiceMap } from "../ts/sdk.ts"
|
|
28
|
+
import {
|
|
29
|
+
childOf,
|
|
30
|
+
indexReads,
|
|
31
|
+
INFINITE,
|
|
32
|
+
invalidatedBy,
|
|
33
|
+
isEntry,
|
|
34
|
+
isStream,
|
|
35
|
+
READ,
|
|
36
|
+
type Read,
|
|
37
|
+
readKey,
|
|
38
|
+
} from "./invalidate.ts"
|
|
39
|
+
|
|
40
|
+
/** The SDK, or a thunk for one: an isomorphic app builds a client per request. */
|
|
41
|
+
export type SdkSource<T> = T | (() => T)
|
|
42
|
+
|
|
43
|
+
/** What the helpers need beyond the SDK: the client whose cache a write invalidates. */
|
|
44
|
+
export type QueryHelperOptions = {
|
|
45
|
+
getQueryClient?: (() => QueryClient) | undefined
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* an SDK method, whatever its shape: `unknown` collapses call signatures, which is what this must not do */
|
|
49
|
+
// oxlint-disable-next-line typescript/no-explicit-any
|
|
50
|
+
type AnyMethod = (...args: any[]) => any
|
|
51
|
+
|
|
52
|
+
type Req<M> = M extends (req: infer R, ...rest: never[]) => unknown ? R : never
|
|
53
|
+
type Init<M> = M extends (req: never, init: infer I, ...rest: never[]) => unknown ? I : never
|
|
54
|
+
type Data<M> = M extends (...args: never[]) => infer R ? Awaited<R> : never
|
|
55
|
+
|
|
56
|
+
/** `{ req }` is optional only when the request itself has no required field. */
|
|
57
|
+
type ReqOptions<M> = {} extends Req<M> ? { init?: Init<M>; req?: Req<M> } : { init?: Init<M>; req: Req<M> }
|
|
58
|
+
|
|
59
|
+
type ReadOptions<M> =
|
|
60
|
+
{} extends Req<M>
|
|
61
|
+
? { queryProps?: Omit<QueryObserverOptions<Data<M>>, "queryFn" | "queryKey">; reqOptions?: ReqOptions<M> }
|
|
62
|
+
: { queryProps?: Omit<QueryObserverOptions<Data<M>>, "queryFn" | "queryKey">; reqOptions: ReqOptions<M> }
|
|
63
|
+
|
|
64
|
+
/** A read's options, keyed and seeded: `queryKey` is tagged so a cache read infers the answer. */
|
|
65
|
+
export type QueryFactory<M> = (
|
|
66
|
+
...args: {} extends Req<M> ? [options?: ReadOptions<M>] : [options: ReadOptions<M>]
|
|
67
|
+
) => QueryObserverOptions<Data<M>, DefaultError, Data<M>, Data<M>, QueryKey> & {
|
|
68
|
+
initialData: undefined
|
|
69
|
+
queryKey: DataTag<QueryKey, Data<M>, DefaultError>
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** A write's options; `mutate` takes the SDK's own input, so a call site reads like the SDK call. */
|
|
73
|
+
export type MutationFactory<M> = (options?: {
|
|
74
|
+
mutationProps?: Omit<MutationObserverOptions<Data<M>, DefaultError, Req<M>>, "mutationFn" | "mutationKey">
|
|
75
|
+
}) => MutationObserverOptions<Data<M>, DefaultError, Req<M>> & {
|
|
76
|
+
mutationFn: (input: Req<M>) => Promise<Data<M>>
|
|
77
|
+
mutationKey: QueryKey
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** A paged read: the caller says how a page param becomes a request and where the next one comes from. */
|
|
81
|
+
export type InfiniteFactory<M> = <TPageParam = number>(options: {
|
|
82
|
+
buildReqOptions: (pageParam: TPageParam) => { init?: Init<M>; req: Req<M> }
|
|
83
|
+
getNextPageParam: (
|
|
84
|
+
lastPage: Data<M>,
|
|
85
|
+
allPages: Data<M>[],
|
|
86
|
+
lastPageParam: TPageParam,
|
|
87
|
+
allPageParams: TPageParam[],
|
|
88
|
+
) => TPageParam | null | undefined
|
|
89
|
+
getPreviousPageParam?: (
|
|
90
|
+
firstPage: Data<M>,
|
|
91
|
+
allPages: Data<M>[],
|
|
92
|
+
firstPageParam: TPageParam,
|
|
93
|
+
allPageParams: TPageParam[],
|
|
94
|
+
) => TPageParam | null | undefined
|
|
95
|
+
infiniteQueryProps?: Omit<
|
|
96
|
+
InfiniteQueryObserverOptions<Data<M>, DefaultError, InfiniteData<Data<M>>, QueryKey, TPageParam>,
|
|
97
|
+
"getNextPageParam" | "getPreviousPageParam" | "initialPageParam" | "queryFn" | "queryKey"
|
|
98
|
+
>
|
|
99
|
+
initialPageParam: TPageParam
|
|
100
|
+
}) => InfiniteQueryObserverOptions<Data<M>, DefaultError, InfiniteData<Data<M>>, QueryKey, TPageParam>
|
|
101
|
+
|
|
102
|
+
/** A key builder: the request in, the key the matching factory would use out. */
|
|
103
|
+
export type KeyFactory<M> = (req?: Req<M>) => QueryKey
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* One surface as this file can describe it: a tree of factories, indexable by name, callable at a leaf.
|
|
107
|
+
* It cannot be more precise here — the map arrives as `ServiceMap`, whose literal types are gone, so which
|
|
108
|
+
* names exist and what each one takes is not knowable at this layer. The emitted
|
|
109
|
+
* `<stem>.tanstack-query.gen.ts` declares the exact nested types over its own document and this shape
|
|
110
|
+
* disappears behind them; a consumer never sees it.
|
|
111
|
+
*/
|
|
112
|
+
export interface Surface {
|
|
113
|
+
// oxlint-disable-next-line typescript/no-explicit-any
|
|
114
|
+
(...args: any[]): any
|
|
115
|
+
readonly [key: string]: Surface
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function readSdk<T>(source: SdkSource<T>): T {
|
|
119
|
+
return typeof source === "function" ? (source as () => T)() : source
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** The member path's method on the SDK, read when the call is made so a thunk stays per-call. */
|
|
123
|
+
function methodAt(sdk: unknown, member: readonly string[]): AnyMethod {
|
|
124
|
+
let node: unknown = sdk
|
|
125
|
+
for (const key of member) node = (node as Record<string, unknown>)[key]
|
|
126
|
+
return node as AnyMethod
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
type Kind = "infiniteQuery" | "mutation" | "query" | "queryKey" | "mutationKey"
|
|
130
|
+
|
|
131
|
+
/** Which surface an entry belongs to; a stream belongs to none. */
|
|
132
|
+
function surfaceOf(entry: ServiceEntry, surface: Kind): boolean {
|
|
133
|
+
if (isStream(entry)) return false
|
|
134
|
+
const read = entry.method === READ
|
|
135
|
+
return surface === "mutation" || surface === "mutationKey" ? !read : read
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
type Context = {
|
|
139
|
+
getQueryClient?: (() => QueryClient) | undefined
|
|
140
|
+
map: ServiceMap
|
|
141
|
+
reads: Map<string, Read>
|
|
142
|
+
sdk: SdkSource<unknown>
|
|
143
|
+
sdkName: string
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function queryOptionsAt(ctx: Context, member: string[]) {
|
|
147
|
+
return (options?: { queryProps?: object; reqOptions?: { init?: unknown; req?: unknown } }) => {
|
|
148
|
+
const { init, req } = options?.reqOptions ?? {}
|
|
149
|
+
const args = init === undefined ? [req] : [req, init]
|
|
150
|
+
return {
|
|
151
|
+
queryFn: () => methodAt(readSdk(ctx.sdk), member)(...args),
|
|
152
|
+
queryKey: readKey(ctx.sdkName, member, req),
|
|
153
|
+
...options?.queryProps,
|
|
154
|
+
/* after the spread: a caller's queryProps cannot un-seed the Solid overload */
|
|
155
|
+
initialData: undefined,
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function mutationOptionsAt(ctx: Context, member: string[], entry: ServiceEntry) {
|
|
161
|
+
return (options?: { mutationProps?: object }) => ({
|
|
162
|
+
mutationFn: async (input: unknown) => {
|
|
163
|
+
const data = await methodAt(readSdk(ctx.sdk), member)(input)
|
|
164
|
+
const client = ctx.getQueryClient?.()
|
|
165
|
+
if (client !== undefined) {
|
|
166
|
+
const keys = invalidatedBy(ctx.reads, ctx.sdkName, entry, input)
|
|
167
|
+
await Promise.all(keys.map((queryKey) => client.invalidateQueries({ queryKey })))
|
|
168
|
+
}
|
|
169
|
+
return data
|
|
170
|
+
},
|
|
171
|
+
mutationKey: [ctx.sdkName, ...member],
|
|
172
|
+
...options?.mutationProps,
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function infiniteOptionsAt(ctx: Context, member: string[]) {
|
|
177
|
+
return (options: {
|
|
178
|
+
buildReqOptions: (pageParam: unknown) => { init?: unknown; req: unknown }
|
|
179
|
+
infiniteQueryProps?: object
|
|
180
|
+
initialPageParam: unknown
|
|
181
|
+
}) => {
|
|
182
|
+
const { buildReqOptions, infiniteQueryProps, initialPageParam, ...rest } = options
|
|
183
|
+
return {
|
|
184
|
+
...rest,
|
|
185
|
+
initialPageParam,
|
|
186
|
+
queryFn: (context: { pageParam: unknown }) => {
|
|
187
|
+
const { init, req } = buildReqOptions(context.pageParam)
|
|
188
|
+
const args = init === undefined ? [req] : [req, init]
|
|
189
|
+
return methodAt(readSdk(ctx.sdk), member)(...args)
|
|
190
|
+
},
|
|
191
|
+
queryKey: [...readKey(ctx.sdkName, member, buildReqOptions(initialPageParam).req), INFINITE],
|
|
192
|
+
...infiniteQueryProps,
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function keyFactoryAt(ctx: Context, member: string[]) {
|
|
198
|
+
return (req?: unknown) => readKey(ctx.sdkName, member, req)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function factoryFor(ctx: Context, surface: Kind, member: string[], entry: ServiceEntry): unknown {
|
|
202
|
+
if (surface === "query") return queryOptionsAt(ctx, member)
|
|
203
|
+
if (surface === "mutation") return mutationOptionsAt(ctx, member, entry)
|
|
204
|
+
if (surface === "infiniteQuery") return infiniteOptionsAt(ctx, member)
|
|
205
|
+
return keyFactoryAt(ctx, member)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* One surface as a proxy over the map: a branch gives a branch, an operation of that surface gives its
|
|
210
|
+
* factory, and anything else — a write on `query`, a read on `mutation`, a stream on either, a name the
|
|
211
|
+
* map does not hold — gives `undefined`, so the surface never invents an operation.
|
|
212
|
+
*/
|
|
213
|
+
function surfaceProxy(ctx: Context, surface: Kind, node: ServiceMap, member: string[]): unknown {
|
|
214
|
+
return new Proxy(Object.create(null) as object, {
|
|
215
|
+
get(_, key) {
|
|
216
|
+
if (typeof key !== "string") return undefined
|
|
217
|
+
const child = childOf(node, key)
|
|
218
|
+
if (child === undefined) return undefined
|
|
219
|
+
const at = [...member, key]
|
|
220
|
+
if (!isEntry(child)) return surfaceProxy(ctx, surface, child as ServiceMap, at)
|
|
221
|
+
return surfaceOf(child, surface) ? factoryFor(ctx, surface, at, child) : undefined
|
|
222
|
+
},
|
|
223
|
+
has(_, key) {
|
|
224
|
+
return typeof key === "string" && childOf(node, key) !== undefined
|
|
225
|
+
},
|
|
226
|
+
})
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The helper set for `sdk` over `map`. `sdkName` heads every key, so two SDKs in one cache never collide.
|
|
231
|
+
* The emitted wrapper passes its own map and name and types each surface from the document, the way the
|
|
232
|
+
* generated client passes its map to `SDKClient`.
|
|
233
|
+
*/
|
|
234
|
+
export function queryHelpers<TSDK>(
|
|
235
|
+
sdk: SdkSource<TSDK>,
|
|
236
|
+
map: ServiceMap,
|
|
237
|
+
sdkName: string,
|
|
238
|
+
options: QueryHelperOptions = {},
|
|
239
|
+
): {
|
|
240
|
+
infiniteQuery: Surface
|
|
241
|
+
mutation: Surface
|
|
242
|
+
mutationKey: Surface
|
|
243
|
+
query: Surface
|
|
244
|
+
queryKey: Surface
|
|
245
|
+
} {
|
|
246
|
+
const ctx: Context = {
|
|
247
|
+
getQueryClient: options.getQueryClient,
|
|
248
|
+
map,
|
|
249
|
+
reads: indexReads(map),
|
|
250
|
+
sdk,
|
|
251
|
+
sdkName,
|
|
252
|
+
}
|
|
253
|
+
const of = (surface: Kind) => surfaceProxy(ctx, surface, map, []) as Surface
|
|
254
|
+
return {
|
|
255
|
+
infiniteQuery: of("infiniteQuery"),
|
|
256
|
+
mutation: of("mutation"),
|
|
257
|
+
mutationKey: of("mutationKey"),
|
|
258
|
+
query: of("query"),
|
|
259
|
+
queryKey: of("queryKey"),
|
|
260
|
+
}
|
|
261
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,85 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@workerstack/clients",
|
|
3
|
+
"version": "1.0.0-rc.23",
|
|
4
|
+
"description": "Generates SDKs (TypeScript, Go, Rust, Python, C#, Java), a CLI and an MCP server from any OpenAPI 3.x document.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"codegen",
|
|
7
|
+
"mcp",
|
|
8
|
+
"openapi",
|
|
9
|
+
"sdk",
|
|
10
|
+
"workerstack"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/workerstack/backend#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/workerstack/backend/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "lovrozagar",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/workerstack/backend.git",
|
|
21
|
+
"directory": "packages/gen"
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"honey-clients": "bin/honey-clients.js"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"bin",
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"type": "module",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./cli": {
|
|
37
|
+
"types": "./dist/cli.d.ts",
|
|
38
|
+
"default": "./dist/cli.js"
|
|
39
|
+
},
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"provenance": true
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"prepack": "bun scripts/build.ts",
|
|
48
|
+
"test": "vitest run --coverage",
|
|
49
|
+
"test:harness": "vitest run --mode harness",
|
|
50
|
+
"type:check": "tsc --noEmit -p tsconfig.json"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@lovrozagar/installgen": "0.3.0",
|
|
54
|
+
"jiti": "2.7.0",
|
|
55
|
+
"oxc-transform": "0.155.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@tanstack/query-core": "5.104.5",
|
|
59
|
+
"@total-typescript/ts-reset": "0.6.1",
|
|
60
|
+
"@types/node": "26.1.1",
|
|
61
|
+
"@vitest/coverage-v8": "4.1.10",
|
|
62
|
+
"ajv": "8.20.0",
|
|
63
|
+
"ajv-formats": "3.0.1",
|
|
64
|
+
"oxfmt": "0.63.0",
|
|
65
|
+
"standardwebhooks": "1.1.1",
|
|
66
|
+
"ts-morph": "28.0.0",
|
|
67
|
+
"typescript": "7.0.2",
|
|
68
|
+
"vitest": "4.1.10"
|
|
69
|
+
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"oxfmt": ">=0.63.0",
|
|
72
|
+
"ts-morph": ">=28.0.0"
|
|
73
|
+
},
|
|
74
|
+
"peerDependenciesMeta": {
|
|
75
|
+
"oxfmt": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"ts-morph": {
|
|
79
|
+
"optional": true
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": ">=22.12.0"
|
|
84
|
+
}
|
|
85
|
+
}
|