@workerstack/clients 0.0.0-stage → 1.0.0-rc.24
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 +135 -5
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { pyString } from "../shared/escape.js";
|
|
2
|
+
import { compareCodeUnits, NameScope, pyClassName, pyIdentifier } from "../shared/lang.js";
|
|
3
|
+
import { multipartBody } from "./sdk-body.js";
|
|
4
|
+
import { pyTypeOf } from "./types.js";
|
|
5
|
+
/** `schema`'s type at `<Op><field>`, written in the client module. */
|
|
6
|
+
export const typeAt = (op, field, schema, env) => pyTypeOf(schema, { ...env.at, fieldName: field, parentName: op.id });
|
|
7
|
+
/** The body parameter's type: its schema's for JSON and a form, `<Op>Body` for multipart, `str` for text, bytes or chunks for binary. */
|
|
8
|
+
export function bodyType(op, async, env) {
|
|
9
|
+
const body = op.body;
|
|
10
|
+
if (body === undefined)
|
|
11
|
+
return null;
|
|
12
|
+
if (body.kind === "text")
|
|
13
|
+
return "str";
|
|
14
|
+
if (body.kind === "binary") {
|
|
15
|
+
env.imports.add(async ? "AsyncIterable" : "Iterable");
|
|
16
|
+
return async ? "bytes | AsyncIterable[bytes]" : "bytes | Iterable[bytes]";
|
|
17
|
+
}
|
|
18
|
+
return body.kind === "multipart" ? multipartBody(op, body.parts, env) : typeAt(op, "Body", body.schema, env);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A streamed event's type: the operation's declared event schema, else `fallback`'s, spelled only then, so an
|
|
22
|
+
* undeclared event's `Any` is imported only where it is written (bit 21 i7a: a typed realtime op imported it unused).
|
|
23
|
+
*/
|
|
24
|
+
export const eventType = (op, env, fallback) => op.events === undefined ? fallback() : typeAt(op, "Event", op.events, env);
|
|
25
|
+
/** The answer of a plain operation `op`: its decoded success (`client.safe`'s twin wraps it in a `Result`). */
|
|
26
|
+
export function answerOf(op, env) {
|
|
27
|
+
const { kind, schema } = op.success;
|
|
28
|
+
const type = kind === "text"
|
|
29
|
+
? "str"
|
|
30
|
+
: kind === "binary"
|
|
31
|
+
? "bytes"
|
|
32
|
+
: schema === undefined
|
|
33
|
+
? "None"
|
|
34
|
+
: typeAt(op, "Response", schema, env);
|
|
35
|
+
return { returns: type, run: "call", type };
|
|
36
|
+
}
|
|
37
|
+
/** The JSON kind a success body, or a typed SSE or realtime event (Fd5), must have, when its schema pins one. */
|
|
38
|
+
export function shapeOf(op, env) {
|
|
39
|
+
if (op.stream === "sse" || op.stream === "realtime")
|
|
40
|
+
return op.events === undefined ? null : kindOf(op.events, env);
|
|
41
|
+
if (op.stream !== null || op.success.kind !== "json" || op.success.schema === undefined)
|
|
42
|
+
return null;
|
|
43
|
+
return kindOf(op.success.schema, env);
|
|
44
|
+
}
|
|
45
|
+
/** The JSON kind `declared` pins: an object, array or scalar type; none for any other schema. */
|
|
46
|
+
function kindOf(declared, env) {
|
|
47
|
+
const schema = env.at.names.resolve(declared);
|
|
48
|
+
if (schema.kind === "object" || schema.kind === "allOf")
|
|
49
|
+
return "object";
|
|
50
|
+
if (schema.kind === "array" || schema.kind === "tuple")
|
|
51
|
+
return "array";
|
|
52
|
+
if (schema.kind !== "scalar" || schema.type === "null")
|
|
53
|
+
return null;
|
|
54
|
+
return schema.type === "integer" ? "number" : schema.type;
|
|
55
|
+
}
|
|
56
|
+
/** The headers `op`'s 2xx responses declare, statuses ascending, a name's first spelling kept; by name. */
|
|
57
|
+
function declaredHeaders(op) {
|
|
58
|
+
if (op.stream === "ws" || op.stream === "realtime")
|
|
59
|
+
return [];
|
|
60
|
+
const all = Object.keys(op.ir.responses)
|
|
61
|
+
.filter((status) => /^2(?:\d\d|XX)$/i.test(status))
|
|
62
|
+
.sort(compareCodeUnits)
|
|
63
|
+
.flatMap((status) => op.ir.responses[status].headers ?? []);
|
|
64
|
+
const first = new Map(all.toReversed().map((header) => [header.name.toLowerCase(), header]));
|
|
65
|
+
return [...first.values()].sort((a, b) => compareCodeUnits(a.name, b.name));
|
|
66
|
+
}
|
|
67
|
+
/** `<Op>Headers` (total=False) hoisted beside the types, and how `Operation.headers` reads each; null without any. */
|
|
68
|
+
export function responseHeaders(op, env) {
|
|
69
|
+
const headers = declaredHeaders(op);
|
|
70
|
+
if (headers.length === 0)
|
|
71
|
+
return null;
|
|
72
|
+
const typing = env.at.declTyping;
|
|
73
|
+
const type = env.at.names.claim(`${pyClassName(op.id)}Headers`);
|
|
74
|
+
const scope = new NameScope();
|
|
75
|
+
const fields = headers.map((header) => {
|
|
76
|
+
const resolved = env.at.names.resolve(header.schema);
|
|
77
|
+
const at = { ...env.at, fieldName: header.name, parentName: type, typing };
|
|
78
|
+
/* a scalar is read as its kind; any other schema as the header's text, which is what arrives */
|
|
79
|
+
const read = resolved.kind === "scalar" && resolved.type !== "null"
|
|
80
|
+
? { kind: resolved.type, type: pyTypeOf(header.schema, at) }
|
|
81
|
+
: { kind: "string", type: "str" };
|
|
82
|
+
return { header: header.name, key: scope.claim(pyIdentifier(header.name)), required: header.required, ...read };
|
|
83
|
+
});
|
|
84
|
+
typing.add("TypedDict");
|
|
85
|
+
/* every key is an identifier (pyIdentifier), so the class form always spells it */
|
|
86
|
+
env.at.decls.set(type, [`class ${type}(TypedDict, total=False):`, ...fields.map((f) => ` ${f.key}: ${f.type}`)].join("\n"));
|
|
87
|
+
const read = fields.map(({ header, key, kind, required }) => `(${pyString(header)}, ${pyString(key)}, ${pyString(kind)}, ${required ? "True" : "False"})`);
|
|
88
|
+
return { plan: { fields: Object.fromEntries(fields.map((f) => [f.header, f.key])), type }, read };
|
|
89
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A multipart body as its method takes it (G4, Fc6): `<Op>Body`, a TypedDict hoisted beside the API's types with
|
|
3
|
+
* a key per part in code-unit order. A file part is the runtime's in-memory `FilePart` (`list[FilePart]` for an
|
|
4
|
+
* array), which types.py imports; a text part is its schema's type. A part the body schema requires is bare, any
|
|
5
|
+
* other `NotRequired[…]` (G8). Spec text reaches the source only through the shared escape layer.
|
|
6
|
+
*/
|
|
7
|
+
import type { IRMultipartPart } from "../../ir/model.ts";
|
|
8
|
+
import type { SdkOp } from "../../ir/sdk-model.ts";
|
|
9
|
+
import type { MethodEnv } from "./sdk-method.ts";
|
|
10
|
+
/** `<Op>Body` for `parts`, declared once into `env.at.decls` (each client's method asks for it); its name. */
|
|
11
|
+
export declare function multipartBody(op: SdkOp, parts: readonly IRMultipartPart[], env: MethodEnv): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { compareCodeUnits, pyClassName } from "../shared/lang.js";
|
|
2
|
+
import { dictDecl } from "./types-dict.js";
|
|
3
|
+
import { pyTypeOf } from "./types.js";
|
|
4
|
+
/** The parts the body schema of `op` requires: none unless it is an object. */
|
|
5
|
+
function requiredParts(op, env) {
|
|
6
|
+
/* a multipart body, with file parts or text parts alone, is declared with its form's schema */
|
|
7
|
+
const form = env.at.names.resolve(op.ir.body.schema);
|
|
8
|
+
return new Set(form.kind === "object" ? form.fields.flatMap((f) => (f.required ? [f.name] : [])) : []);
|
|
9
|
+
}
|
|
10
|
+
/** The type of `part` as a key of `parent`: `FilePart` or its list for a file, its schema's type for text. */
|
|
11
|
+
function partType(part, parent, env) {
|
|
12
|
+
/* the IR gives every part its schema (ir/slots.ts partsOf, ir/sdk-model.ts bodyOf) */
|
|
13
|
+
const schema = part.schema;
|
|
14
|
+
if (part.type === "text") {
|
|
15
|
+
return pyTypeOf(schema, { ...env.at, fieldName: part.name, parentName: parent, typing: env.at.declTyping });
|
|
16
|
+
}
|
|
17
|
+
env.typesImports.add("FilePart");
|
|
18
|
+
return env.at.names.resolve(schema).kind === "array" ? "list[FilePart]" : "FilePart";
|
|
19
|
+
}
|
|
20
|
+
/** `<Op>Body` for `parts`, declared once into `env.at.decls` (each client's method asks for it); its name. */
|
|
21
|
+
export function multipartBody(op, parts, env) {
|
|
22
|
+
const name = env.at.names.hoist(`${op.id}.Body`, `${pyClassName(op.id)}Body`);
|
|
23
|
+
if (env.at.decls.has(name))
|
|
24
|
+
return name;
|
|
25
|
+
/* claimed before its keys: what a text part hoists in turn comes after it */
|
|
26
|
+
env.at.decls.set(name, "");
|
|
27
|
+
const required = requiredParts(op, env);
|
|
28
|
+
const keys = [...parts]
|
|
29
|
+
.sort((a, b) => compareCodeUnits(a.name, b.name))
|
|
30
|
+
.map((part) => {
|
|
31
|
+
const type = partType(part, name, env);
|
|
32
|
+
if (required.has(part.name))
|
|
33
|
+
return { key: part.name, type };
|
|
34
|
+
env.at.declTyping.add("NotRequired");
|
|
35
|
+
return { key: part.name, type: `NotRequired[${type}]` };
|
|
36
|
+
});
|
|
37
|
+
env.at.declTyping.add("TypedDict");
|
|
38
|
+
env.at.decls.set(name, dictDecl(name, keys));
|
|
39
|
+
return name;
|
|
40
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* client.py's classes (G1, G2): a `<Path>Resource` per namespace of `IR.tree` for `SDK` and an
|
|
3
|
+
* `Async<Path>Resource` twin for `AsyncSDK`, each child namespace an attribute (snake_case) and each operation
|
|
4
|
+
* a method, then the two root clients. `SDK` has no stream method, and no attribute for a namespace that only
|
|
5
|
+
* holds streams (H44). Both roots reserve `close`, `aclose`, `is_stale` and `safe`, so their trees stay equal.
|
|
6
|
+
*
|
|
7
|
+
* `safe` (bit 21 i2) is each root's safe mirror: a `Safe<Path>Resource` (`AsyncSafe…`) per class, the same tree, each
|
|
8
|
+
* operation one line, `name = Safe.of(<Class>.name)` (`of_sync` on `SDK`'s side): the normal method itself, typed to
|
|
9
|
+
* answer a `Result`, its `self._t` the runtime's `Safe` view of the transport. A connection (WebSocket, realtime) is
|
|
10
|
+
* the same method on both, `Safe.keep` typing it for the twin's `self`. A root member spelled `safe` is emitted as
|
|
11
|
+
* `safe_`, and the generation says so.
|
|
12
|
+
*/
|
|
13
|
+
import type { IR } from "../../ir/model.ts";
|
|
14
|
+
import type { SdkOp } from "../../ir/sdk-model.ts";
|
|
15
|
+
import { type MethodEnv } from "./sdk-method.ts";
|
|
16
|
+
import type { PythonCallPlan } from "./sdk-plan.ts";
|
|
17
|
+
/**
|
|
18
|
+
* The client env, the operations by id, the async transport class the API needs, whether it declares an `ErrorKey`,
|
|
19
|
+
* and the notices the generation reports (a root member renamed for the mirror).
|
|
20
|
+
*/
|
|
21
|
+
export type ClientEnv = MethodEnv & {
|
|
22
|
+
readonly ops: ReadonlyMap<string, SdkOp>;
|
|
23
|
+
readonly transport: string;
|
|
24
|
+
readonly keyed: boolean;
|
|
25
|
+
readonly notices: string[];
|
|
26
|
+
};
|
|
27
|
+
/** The client's title line: the API's title, through the escape layer. */
|
|
28
|
+
export declare const clientTitle: (ir: IR) => string;
|
|
29
|
+
/**
|
|
30
|
+
* client.py's body for `ir`: the defaults (with the `ErrorKey` the runtime reads a key into), the operations'
|
|
31
|
+
* constants, the resource classes (sync, then async), `SDK` and `AsyncSDK`; and every method's call plan.
|
|
32
|
+
*/
|
|
33
|
+
export declare function clientDecls(ir: IR, env: ClientEnv): {
|
|
34
|
+
readonly lines: string[];
|
|
35
|
+
readonly plans: PythonCallPlan[];
|
|
36
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { methodsOf, namespacesOf } from "../../ir/resource-tree.js";
|
|
2
|
+
import { pyDocLines, pyString } from "../shared/escape.js";
|
|
3
|
+
import { compareCodeUnits, NameScope, pyClassName, pyIdentifier } from "../shared/lang.js";
|
|
4
|
+
import { MIRROR, mirrorNotice } from "../shared/mirror.js";
|
|
5
|
+
import { BUILTINS, pyMethod } from "./sdk-method.js";
|
|
6
|
+
/* the root clients' own members: no namespace or operation takes their names */
|
|
7
|
+
const ROOT_NAMES = ["close", "aclose", "is_stale", MIRROR];
|
|
8
|
+
/**
|
|
9
|
+
* `ns` at `path`: its children first, so a method never takes an attribute's name. A root member spelled `safe` is
|
|
10
|
+
* `safe_` (shared/mirror.ts), and noticed; no sibling is spelled `safe_` already, as `pyIdentifier` never ends one in
|
|
11
|
+
* `_` but a keyword's.
|
|
12
|
+
*/
|
|
13
|
+
function resourceOf(ns, path, env) {
|
|
14
|
+
const scope = new NameScope(path.length === 0 ? ROOT_NAMES : []);
|
|
15
|
+
const claim = (segment) => {
|
|
16
|
+
const ident = pyIdentifier(segment);
|
|
17
|
+
if (path.length > 0 || ident !== MIRROR)
|
|
18
|
+
return scope.claim(ident);
|
|
19
|
+
const name = scope.claim(`${MIRROR}_`);
|
|
20
|
+
env.notices.push(mirrorNotice("python", MIRROR, ident, name));
|
|
21
|
+
return name;
|
|
22
|
+
};
|
|
23
|
+
const children = namespacesOf(ns).map(([segment, child]) => ({
|
|
24
|
+
attribute: claim(segment),
|
|
25
|
+
node: resourceOf(child, [...path, segment], env),
|
|
26
|
+
}));
|
|
27
|
+
const methods = methodsOf(ns).map(([segment, op]) => pyMethod(env.ops.get(op.id), claim(segment), env));
|
|
28
|
+
return { children, methods, path };
|
|
29
|
+
}
|
|
30
|
+
/** Whether `SDK` has anything below `node`: a method that is no stream. */
|
|
31
|
+
const hasSync = (node) => node.methods.some((method) => method.sync !== null) || node.children.some(({ node: child }) => hasSync(child));
|
|
32
|
+
/** Every resource below the root, leaves first, children in code-unit order. */
|
|
33
|
+
const below = (node) => node.children.flatMap(({ node: child }) => [...below(child), child]);
|
|
34
|
+
/**
|
|
35
|
+
* The classes' names, each node's normal ones and its safe twins': a sync one where `SDK` reaches the namespace, an
|
|
36
|
+
* async one always; the roots are `SDK` and `AsyncSDK`, their twins `SafeSDK` and `AsyncSafeSDK` as claimed.
|
|
37
|
+
*/
|
|
38
|
+
function classNames(root, env) {
|
|
39
|
+
const base = (node) => (node === root ? "SDK" : `${node.path.map(pyClassName).join("")}Resource`);
|
|
40
|
+
/* the normal classes first, so a twin never moves the name one of them had */
|
|
41
|
+
const claimed = (nodes, prefix) => new Map(nodes.map((node) => {
|
|
42
|
+
const sync = node === root || hasSync(node) ? env.at.names.claim(`${prefix}${base(node)}`) : undefined;
|
|
43
|
+
const async = env.at.names.claim(`Async${prefix}${base(node)}`);
|
|
44
|
+
return [node, sync === undefined ? { async } : { async, sync }];
|
|
45
|
+
}));
|
|
46
|
+
const normal = claimed(below(root), "").set(root, { async: "AsyncSDK", sync: "SDK" });
|
|
47
|
+
return { normal, safe: claimed([...below(root), root], "Safe") };
|
|
48
|
+
}
|
|
49
|
+
/** A class's members, a blank line apart. */
|
|
50
|
+
const members = (blocks) => blocks.flatMap((lines, i) => [...(i > 0 ? [""] : []), ...lines]);
|
|
51
|
+
/** The attributes `node` has on `side`, each its child's class over `transport`. */
|
|
52
|
+
const attributes = (node, side, transport) => node.children.flatMap(({ attribute, node: child }) => {
|
|
53
|
+
const type = side.name(child);
|
|
54
|
+
return type === undefined ? [] : [` self.${attribute} = ${type}(${transport})`];
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* The methods `node` has on `side`, in order, each given the builtins the methods before it shadow; on a safe mirror
|
|
58
|
+
* each is one line, the twinned class's method typed to answer a `Result`, a connection as it is.
|
|
59
|
+
*/
|
|
60
|
+
function methodBlocks(node, side) {
|
|
61
|
+
const shadowed = new Set();
|
|
62
|
+
return node.methods.flatMap((method) => {
|
|
63
|
+
const lines = side.async ? method.async : method.sync;
|
|
64
|
+
if (lines === null)
|
|
65
|
+
return [];
|
|
66
|
+
if (side.twins !== undefined) {
|
|
67
|
+
const twinned = `${side.twins(node)}.${method.name}`;
|
|
68
|
+
const connection = method.plan.stream === "ws" || method.plan.stream === "realtime";
|
|
69
|
+
return [[` ${method.name} = Safe.${connection ? "keep" : side.async ? "of" : "of_sync"}(${twinned})`]];
|
|
70
|
+
}
|
|
71
|
+
const block = lines(shadowed);
|
|
72
|
+
if (BUILTINS.includes(method.name))
|
|
73
|
+
shadowed.add(method.name);
|
|
74
|
+
return [block];
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/** The class of `node` on `side`; a safe mirror's methods one line each, with no blank line between them. */
|
|
78
|
+
function resourceClass(node, side) {
|
|
79
|
+
const init = [" def __init__(self, transport: " + side.transport + ") -> None:", " self._t = transport"];
|
|
80
|
+
const methods = methodBlocks(node, side);
|
|
81
|
+
return [
|
|
82
|
+
`class ${side.name(node)}:`,
|
|
83
|
+
...members([
|
|
84
|
+
[...init, ...attributes(node, side, "transport")],
|
|
85
|
+
...(side.twins === undefined ? methods : methods.length > 0 ? [methods.flat()] : []),
|
|
86
|
+
]),
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
/** A root client: its constructor, attributes, safe mirror and methods, `is_stale`, closing, its context manager. */
|
|
90
|
+
function rootClass(root, side, safe, doc) {
|
|
91
|
+
const [aw, a] = side.async ? ["await ", "a"] : ["", ""];
|
|
92
|
+
const transport = side.async ? side.transport : "SyncTransport";
|
|
93
|
+
const own = [
|
|
94
|
+
[
|
|
95
|
+
" def __init__(self, config: ClientConfig | None = None) -> None:",
|
|
96
|
+
` self._t = ${transport}(config or ClientConfig(), _DEFAULTS)`,
|
|
97
|
+
...attributes(root, side, "self._t"),
|
|
98
|
+
` self.${MIRROR} = ${safe.name(root)}(Safe(self._t))`,
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
" def is_stale(self, method: str, path: str) -> bool:",
|
|
102
|
+
' """Whether a read of ``method path`` sees a stale window now (``invalidation``)."""',
|
|
103
|
+
" return self._t.stale.begin(method, path).is_stale",
|
|
104
|
+
],
|
|
105
|
+
[` ${a ? "async " : ""}def ${a}close(self) -> None:`, ` ${aw}self._t.${a}close()`],
|
|
106
|
+
[` ${a ? "async " : ""}def __${a}enter__(self) -> Self:`, " return self"],
|
|
107
|
+
[` ${a ? "async " : ""}def __${a}exit__(self, *exc: object) -> None:`, ` ${aw}self.${a}close()`],
|
|
108
|
+
/* after the client's own methods: an operation named like a builtin shadows only what follows it */
|
|
109
|
+
...methodBlocks(root, side),
|
|
110
|
+
];
|
|
111
|
+
return [`class ${side.async ? "AsyncSDK" : "SDK"}:`, ` """${doc}"""`, "", ...members(own)];
|
|
112
|
+
}
|
|
113
|
+
/** Every method's call plan below `node`, reached through `accessors`, depth first. */
|
|
114
|
+
const plansIn = (node, accessors) => [
|
|
115
|
+
...node.methods.map((method) => ({ ...method.plan, accessors })),
|
|
116
|
+
...node.children.flatMap(({ attribute, node: child }) => plansIn(child, [...accessors, attribute])),
|
|
117
|
+
];
|
|
118
|
+
/** The client's title line: the API's title, through the escape layer. */
|
|
119
|
+
export const clientTitle = (ir) => pyDocLines(ir.info.title === undefined
|
|
120
|
+
? "The API's client, generated by honey."
|
|
121
|
+
: `The ${ir.info.title} client, generated by honey.`)[0];
|
|
122
|
+
/**
|
|
123
|
+
* client.py's body for `ir`: the defaults (with the `ErrorKey` the runtime reads a key into), the operations'
|
|
124
|
+
* constants, the resource classes (sync, then async), `SDK` and `AsyncSDK`; and every method's call plan.
|
|
125
|
+
*/
|
|
126
|
+
export function clientDecls(ir, env) {
|
|
127
|
+
const root = resourceOf(ir.tree, [], env);
|
|
128
|
+
const { normal, safe } = classNames(root, env);
|
|
129
|
+
const sync = { async: false, name: (node) => normal.get(node)?.sync, transport: "SyncTransport" };
|
|
130
|
+
const async = { async: true, name: (node) => normal.get(node)?.async, transport: env.transport };
|
|
131
|
+
const twin = (side) => ({
|
|
132
|
+
async: side.async,
|
|
133
|
+
name: (node) => (side.async ? safe.get(node)?.async : safe.get(node)?.sync),
|
|
134
|
+
transport: "Safe",
|
|
135
|
+
twins: (node) => side.name(node),
|
|
136
|
+
});
|
|
137
|
+
const [safeSync, safeAsync] = [twin(sync), twin(async)];
|
|
138
|
+
const nodes = below(root);
|
|
139
|
+
const constants = [root, ...nodes]
|
|
140
|
+
.flatMap((node) => node.methods)
|
|
141
|
+
.map((method) => method.constant)
|
|
142
|
+
.sort(compareCodeUnits);
|
|
143
|
+
const server = ir.servers[0];
|
|
144
|
+
const defaults = [
|
|
145
|
+
server === undefined ? "None" : pyString(server),
|
|
146
|
+
pyString(ir.auth.headerName),
|
|
147
|
+
pyString(ir.auth.prefix),
|
|
148
|
+
...(env.keyed ? ["ErrorKey"] : []),
|
|
149
|
+
];
|
|
150
|
+
const blocks = [
|
|
151
|
+
[`_DEFAULTS = Defaults(${defaults.join(", ")})`, ...(constants.length > 0 ? ["", ...constants] : [])],
|
|
152
|
+
...nodes.filter((node) => sync.name(node) !== undefined).map((node) => resourceClass(node, sync)),
|
|
153
|
+
...nodes.map((node) => resourceClass(node, async)),
|
|
154
|
+
rootClass(root, sync, safeSync, clientTitle(ir)),
|
|
155
|
+
rootClass(root, async, safeAsync, clientTitle(ir)),
|
|
156
|
+
/* after the classes they twin: each method line reads its normal class */
|
|
157
|
+
...nodes.filter((node) => sync.name(node) !== undefined).map((node) => resourceClass(node, safeSync)),
|
|
158
|
+
...nodes.map((node) => resourceClass(node, safeAsync)),
|
|
159
|
+
resourceClass(root, safeSync),
|
|
160
|
+
resourceClass(root, safeAsync),
|
|
161
|
+
];
|
|
162
|
+
return { lines: blocks.flatMap((lines, i) => [...(i > 0 ? ["", ""] : []), ...lines]), plans: plansIn(root, []) };
|
|
163
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A method's docstring: the operation's summary, a blank line, its description, a stream's own lines (how it
|
|
3
|
+
* opens and ends), then a `Raises:` line per declared error status, ascending, naming the class the
|
|
4
|
+
* runtime raises for it. Spec text goes through `pyDocLines`, so a quote or backslash in it stays inert; a
|
|
5
|
+
* stream's lines are the emitter's own, as they are. No docstring without any of the four.
|
|
6
|
+
*/
|
|
7
|
+
import type { SdkOp } from "../../ir/sdk-model.ts";
|
|
8
|
+
/** The docstring of `op`'s method at 8 spaces, `stream` its stream's own lines, or none. */
|
|
9
|
+
export declare function methodDoc(op: SdkOp, stream: readonly string[]): string[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { pyDocLines } from "../shared/escape.js";
|
|
2
|
+
/* the runtime's STATUS_ERRORS (runtime/python/errors.py); any other status raises APIStatusError */
|
|
3
|
+
const STATUS_ERRORS = {
|
|
4
|
+
400: "BadRequestError",
|
|
5
|
+
401: "UnauthorizedError",
|
|
6
|
+
403: "ForbiddenError",
|
|
7
|
+
404: "NotFoundError",
|
|
8
|
+
409: "ConflictError",
|
|
9
|
+
422: "UnprocessableEntityError",
|
|
10
|
+
429: "RateLimitError",
|
|
11
|
+
500: "InternalServerError",
|
|
12
|
+
502: "BadGatewayError",
|
|
13
|
+
503: "ServiceUnavailableError",
|
|
14
|
+
504: "GatewayTimeoutError",
|
|
15
|
+
};
|
|
16
|
+
/** The docstring of `op`'s method at 8 spaces, `stream` its stream's own lines, or none. */
|
|
17
|
+
export function methodDoc(op, stream) {
|
|
18
|
+
const raises = op.errorStatuses.map((s) => ` ${STATUS_ERRORS[s] ?? "APIStatusError"}: HTTP ${s}`);
|
|
19
|
+
const spec = [op.summary.trim(), op.description.trim()].filter((part) => part !== "");
|
|
20
|
+
const parts = [
|
|
21
|
+
...spec.map(pyDocLines),
|
|
22
|
+
...(stream.length > 0 ? [[...stream]] : []),
|
|
23
|
+
...(raises.length > 0 ? [["Raises:", ...raises]] : []),
|
|
24
|
+
];
|
|
25
|
+
const lines = parts.flatMap((part, i) => (i === 0 ? part : ["", ...part]));
|
|
26
|
+
if (lines.length === 0)
|
|
27
|
+
return [];
|
|
28
|
+
/* a docstring that opens on its Raises: block opens on a line of its own, so the block keeps its shape */
|
|
29
|
+
const open = lines[0] === "Raises:" ? ['"""', ...lines] : [`"""${lines[0]}`, ...lines.slice(1)];
|
|
30
|
+
const body = lines.length === 1 ? [`"""${lines[0]}"""`] : [...open, '"""'];
|
|
31
|
+
return body.map((line) => (line === "" ? "" : ` ${line}`));
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The orders ruff checks (contract 28 §2.3), so the post-pass never has to reorder: `from x import (…)`
|
|
3
|
+
* members as I001 sorts them and `__all__` as RUF022 does. Both group constants (two or more characters, every
|
|
4
|
+
* cased one upper), then classes (a leading capital, a lone one too), then the rest, each group in natural order
|
|
5
|
+
* (a digit run by its number): case-insensitive for imports, case-sensitive for `__all__`.
|
|
6
|
+
*/
|
|
7
|
+
/** Import members as ruff's isort orders them. */
|
|
8
|
+
export declare const isortMembers: (names: readonly string[]) => string[];
|
|
9
|
+
/** `__all__` entries as RUF022 orders them. */
|
|
10
|
+
export declare const allOrder: (names: readonly string[]) => string[];
|
|
11
|
+
/** One `from <module> import …` line, its members in isort order; none without members. */
|
|
12
|
+
export declare function importLine(module: string, names: Iterable<string>): string[];
|
|
13
|
+
/** Import sections (each a list of lines) a blank line apart, the empty ones dropped. */
|
|
14
|
+
export declare const importBlock: (sections: readonly (readonly string[])[]) => string[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The orders ruff checks (contract 28 §2.3), so the post-pass never has to reorder: `from x import (…)`
|
|
3
|
+
* members as I001 sorts them and `__all__` as RUF022 does. Both group constants (two or more characters, every
|
|
4
|
+
* cased one upper), then classes (a leading capital, a lone one too), then the rest, each group in natural order
|
|
5
|
+
* (a digit run by its number): case-insensitive for imports, case-sensitive for `__all__`.
|
|
6
|
+
*/
|
|
7
|
+
/** `text` as natural order compares it: each digit run whole, every other character alone. */
|
|
8
|
+
const chunks = (text) => Array.from(text.matchAll(/\d+|\D/g), (match) => match[0]);
|
|
9
|
+
/** Natural order: a digit run against a digit run by its number, any other character by its code unit. */
|
|
10
|
+
function natural(a, b) {
|
|
11
|
+
const [left, right] = [chunks(a), chunks(b)];
|
|
12
|
+
for (let i = 0; i < Math.min(left.length, right.length); i++) {
|
|
13
|
+
const [x, y] = [left[i], right[i]];
|
|
14
|
+
const numeric = /^\d/.test(x) && /^\d/.test(y);
|
|
15
|
+
const order = numeric ? Number(BigInt(x) - BigInt(y)) : x < y ? -1 : x > y ? 1 : 0;
|
|
16
|
+
if (order !== 0)
|
|
17
|
+
return Math.sign(order);
|
|
18
|
+
}
|
|
19
|
+
return left.length - right.length;
|
|
20
|
+
}
|
|
21
|
+
/** A member's group: 0 a constant, 1 a class (a lone capital too, as ruff sorts it), 2 anything else. */
|
|
22
|
+
function group(name) {
|
|
23
|
+
if (name.length > 1 && name.toUpperCase() === name && name.toLowerCase() !== name)
|
|
24
|
+
return 0;
|
|
25
|
+
return /^[A-Z]/.test(name) ? 1 : 2;
|
|
26
|
+
}
|
|
27
|
+
const ordered = (names, fold) => [...new Set(names)].sort((a, b) => group(a) - group(b) || natural(fold(a), fold(b)) || natural(a, b));
|
|
28
|
+
/** Import members as ruff's isort orders them. */
|
|
29
|
+
export const isortMembers = (names) => ordered(names, (name) => name.toLowerCase());
|
|
30
|
+
/** `__all__` entries as RUF022 orders them. */
|
|
31
|
+
export const allOrder = (names) => ordered(names, (name) => name);
|
|
32
|
+
/** One `from <module> import …` line, its members in isort order; none without members. */
|
|
33
|
+
export function importLine(module, names) {
|
|
34
|
+
const members = isortMembers([...names]);
|
|
35
|
+
return members.length > 0 ? [`from ${module} import ${members.join(", ")}`] : [];
|
|
36
|
+
}
|
|
37
|
+
/** Import sections (each a list of lines) a blank line apart, the empty ones dropped. */
|
|
38
|
+
export const importBlock = (sections) => sections.filter((lines) => lines.length > 0).flatMap((lines, i) => [...(i > 0 ? [""] : []), ...lines]);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type SdkOp } from "../../ir/sdk-model.ts";
|
|
2
|
+
import { NameScope } from "../shared/lang.ts";
|
|
3
|
+
import type { PythonCallPlan } from "./sdk-plan.ts";
|
|
4
|
+
import type { PyTypeContext } from "./types.ts";
|
|
5
|
+
/** What every method of one SDK shares: the client module's type context, what it imports. */
|
|
6
|
+
export type MethodEnv = {
|
|
7
|
+
readonly at: PyTypeContext & {
|
|
8
|
+
readonly declTyping: Set<string>;
|
|
9
|
+
};
|
|
10
|
+
readonly constants: NameScope;
|
|
11
|
+
/** the `collections.abc` and runtime names client.py imports */
|
|
12
|
+
readonly imports: Set<string>;
|
|
13
|
+
/** the runtime names types.py imports (a multipart body's `FilePart`) */
|
|
14
|
+
readonly typesImports: Set<string>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* One operation's constant, its methods (no sync one for a stream) written given the builtins its class's
|
|
18
|
+
* earlier methods shadow, and its call plan less the accessors.
|
|
19
|
+
*/
|
|
20
|
+
export type PyMethod = {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly constant: string;
|
|
23
|
+
readonly sync: ((shadowed: ReadonlySet<string>) => string[]) | null;
|
|
24
|
+
readonly async: (shadowed: ReadonlySet<string>) => string[];
|
|
25
|
+
readonly plan: Omit<PythonCallPlan, "accessors">;
|
|
26
|
+
};
|
|
27
|
+
export declare const BUILTINS: readonly string[];
|
|
28
|
+
/** The method of `op` named `name`: its constant, its sync method (none for a stream), its async one, its plan. */
|
|
29
|
+
export declare function pyMethod(op: SdkOp, name: string, env: MethodEnv): PyMethod;
|