@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
package/dist/ir/load.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* `honey-clients generate --app <module>[#export]` (bit 19 h2, carry-in #1): the app module loaded and its OpenAPI
|
|
11
|
+
* document generated by the app's own core, `@workerstack/backend/openapi`, resolved from the app as it would be at run
|
|
12
|
+
* time, so gen imports no core itself (H2). The named export, else `app`, else `default`, is the app; the module's
|
|
13
|
+
* `openApi` export, if any, is the document's options (core's GenerateOpenApiOptions), else a bare `info`. On Node
|
|
14
|
+
* the module loads through jiti, a core checkout read from its source by alias; on Bun through Bun's own import, a
|
|
15
|
+
* checkout read from its source by the honey-source condition, refused when this Bun resolves it elsewhere (bit 20).
|
|
16
|
+
* With no core installed where the app resolves it, the refusal names it.
|
|
17
|
+
*/
|
|
18
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
19
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
20
|
+
import { pathToFileURL } from "node:url";
|
|
21
|
+
const CORE = "@workerstack/backend";
|
|
22
|
+
const DEFAULT_OPTIONS = { info: { title: "API", version: "0.0.0" } };
|
|
23
|
+
/** `<module>[#export]` as its module path and the export it names, if any. */
|
|
24
|
+
export function appRef(ref) {
|
|
25
|
+
const at = ref.lastIndexOf("#");
|
|
26
|
+
return at < 0 ? { module: ref, name: undefined } : { module: ref.slice(0, at), name: ref.slice(at + 1) || undefined };
|
|
27
|
+
}
|
|
28
|
+
/** The core package root the module at `from` resolves, found the way Node looks: up each node_modules. */
|
|
29
|
+
function coreRoot(from) {
|
|
30
|
+
for (let dir = dirname(from);; dir = dirname(dir)) {
|
|
31
|
+
const root = join(dir, "node_modules", CORE);
|
|
32
|
+
if (existsSync(join(root, "package.json")))
|
|
33
|
+
return root;
|
|
34
|
+
if (dirname(dir) === dir)
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** A package.json map's entries with a `honey-source` target: each keyed by `key(subpath)`, at that file under `root`. */
|
|
39
|
+
function sourcesOf(root, map, key) {
|
|
40
|
+
const out = {};
|
|
41
|
+
for (const [subpath, target] of Object.entries(map)) {
|
|
42
|
+
const source = typeof target === "object" ? target["honey-source"] : undefined;
|
|
43
|
+
if (source !== undefined)
|
|
44
|
+
out[key(subpath)] = join(root, source);
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/** A core checkout's (it keeps tsconfig.json, which is never published) subpaths and imports mapped to their source. */
|
|
49
|
+
function sourceAliases(root) {
|
|
50
|
+
if (!existsSync(join(root, "tsconfig.json")))
|
|
51
|
+
return { exports: {}, imports: {} };
|
|
52
|
+
const { exports = {}, imports = {} } = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
53
|
+
return {
|
|
54
|
+
exports: sourcesOf(root, exports, (subpath) => CORE + subpath.slice(1)),
|
|
55
|
+
imports: sourcesOf(root, imports, (subpath) => subpath),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** The app `name` (else `app`, else `default`) of the loaded module `mod`, or why there is none. */
|
|
59
|
+
function appOf(mod, ref, name) {
|
|
60
|
+
const app = name === undefined ? (mod.app ?? mod.default) : mod[name];
|
|
61
|
+
if (typeof app?.fetch === "function")
|
|
62
|
+
return app;
|
|
63
|
+
const which = name === undefined ? "no `app` or `default` export" : `no export ${JSON.stringify(name)}`;
|
|
64
|
+
throw new Error(`--app ${ref}: ${which} that is a honey app (name one as <module>#<export>)`);
|
|
65
|
+
}
|
|
66
|
+
/* Node: jiti, its one module cache shared by the app and its document, so both see one core module (its GRAPH symbol) */
|
|
67
|
+
async function jitiImporter(path, alias) {
|
|
68
|
+
const { createJiti } = await import("jiti");
|
|
69
|
+
const jiti = createJiti(path, { alias, fsCache: false, interopDefault: true });
|
|
70
|
+
return (specifier) => jiti.import(specifier);
|
|
71
|
+
}
|
|
72
|
+
/*
|
|
73
|
+
* Bun: its own import, never jiti, which there retries a module that threw through its Babel (evaluating it twice),
|
|
74
|
+
* whose Error.prepareStackTrace hook then breaks Bun's captureStackTrace on a non-Error (Vite's follow-redirects), and
|
|
75
|
+
* whose native mode ignores the aliases (bit 20). A checkout's aliases hold by the honey-source condition instead:
|
|
76
|
+
* each must resolve to its source, never to an unbuilt or stale dist/.
|
|
77
|
+
*/
|
|
78
|
+
function bunImporter(bun, path, aliases, ref) {
|
|
79
|
+
const from = dirname(path);
|
|
80
|
+
for (const [specifier, source] of Object.entries(aliases)) {
|
|
81
|
+
let resolved;
|
|
82
|
+
try {
|
|
83
|
+
resolved = bun.resolveSync(specifier, from);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
/* unresolvable without the condition (a checkout has no dist/): refused below, as one resolved elsewhere */
|
|
87
|
+
}
|
|
88
|
+
if (resolved !== realpathSync(source))
|
|
89
|
+
throw new Error(`--app ${ref}: ${specifier} is a checkout, read from its source only under the honey-source condition: start Bun with --conditions=honey-source`);
|
|
90
|
+
}
|
|
91
|
+
return (specifier) => import(__rewriteRelativeImportExtension(pathToFileURL(bun.resolveSync(specifier, from)).href));
|
|
92
|
+
}
|
|
93
|
+
/** The OpenAPI document of the app `ref` names, by the app's own core; `cwd` resolves it. One load at a time per process. */
|
|
94
|
+
export async function loadAppDocument(ref, cwd) {
|
|
95
|
+
const { module, name } = appRef(ref);
|
|
96
|
+
const path = resolve(cwd, module);
|
|
97
|
+
if (!existsSync(path))
|
|
98
|
+
throw new Error(`--app ${ref}: ${relative(cwd, path)} does not exist`);
|
|
99
|
+
const root = coreRoot(path);
|
|
100
|
+
if (root === undefined)
|
|
101
|
+
throw new Error(`--app ${ref}: no ${CORE} is installed where ${relative(cwd, path)} resolves it`);
|
|
102
|
+
const bun = globalThis.Bun;
|
|
103
|
+
const aliases = sourceAliases(root);
|
|
104
|
+
/* Bun resolves core's own imports under the honey-source condition, through core's package.json */
|
|
105
|
+
const load = bun === undefined
|
|
106
|
+
? await jitiImporter(path, { ...aliases.exports, ...aliases.imports })
|
|
107
|
+
: bunImporter(bun, path, aliases.exports, ref);
|
|
108
|
+
const mod = await load(path);
|
|
109
|
+
const app = appOf(mod, ref, name);
|
|
110
|
+
const { generateOpenApi } = (await load(`${CORE}/openapi`));
|
|
111
|
+
return generateOpenApi(app, mod.openApi ?? DEFAULT_OPTIONS);
|
|
112
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The IR: what every emitter reads, built from an OpenAPI document and nothing else (H2). This
|
|
3
|
+
* file holds its types; `schema.ts` reads a JSON Schema into an IR schema and follows refs.
|
|
4
|
+
*/
|
|
5
|
+
export type IRScalarType = "boolean" | "integer" | "null" | "number" | "string";
|
|
6
|
+
/** A value's constraint keywords as the spec states them (bit 19 c): a string's, a number's, an array's. */
|
|
7
|
+
export type IRBounds = {
|
|
8
|
+
minLength?: number;
|
|
9
|
+
maxLength?: number;
|
|
10
|
+
pattern?: string;
|
|
11
|
+
minimum?: number;
|
|
12
|
+
maximum?: number;
|
|
13
|
+
exclusiveMinimum?: number;
|
|
14
|
+
exclusiveMaximum?: number;
|
|
15
|
+
};
|
|
16
|
+
export type IRSchema = ({
|
|
17
|
+
kind: "scalar";
|
|
18
|
+
type: IRScalarType;
|
|
19
|
+
format?: string;
|
|
20
|
+
enum?: (boolean | number | string)[];
|
|
21
|
+
} & IRBounds) | {
|
|
22
|
+
kind: "const";
|
|
23
|
+
value: boolean | number | string;
|
|
24
|
+
/** the declared `type`, when there is one */ type?: IRScalarType;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "object";
|
|
27
|
+
fields: IRField[];
|
|
28
|
+
additional?: IRSchema | false;
|
|
29
|
+
} | {
|
|
30
|
+
kind: "array";
|
|
31
|
+
items: IRSchema;
|
|
32
|
+
minItems?: number;
|
|
33
|
+
maxItems?: number;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "tuple";
|
|
36
|
+
items: IRSchema[];
|
|
37
|
+
/** what may follow the fixed items; none: nothing may */
|
|
38
|
+
rest?: IRSchema;
|
|
39
|
+
/** how many leading items must be there, when fewer than all: the rest is an optional tail */
|
|
40
|
+
required?: number;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "union";
|
|
43
|
+
variants: IRSchema[];
|
|
44
|
+
discriminator?: IRDiscriminator;
|
|
45
|
+
} | {
|
|
46
|
+
kind: "allOf";
|
|
47
|
+
parts: IRSchema[];
|
|
48
|
+
} | {
|
|
49
|
+
kind: "ref";
|
|
50
|
+
name: string;
|
|
51
|
+
} | {
|
|
52
|
+
kind: "nullable";
|
|
53
|
+
inner: IRSchema;
|
|
54
|
+
} | {
|
|
55
|
+
kind: "binary";
|
|
56
|
+
} | {
|
|
57
|
+
kind: "unknown";
|
|
58
|
+
};
|
|
59
|
+
export type IRField = {
|
|
60
|
+
/** the raw JSON key, never mangled */
|
|
61
|
+
name: string;
|
|
62
|
+
schema: IRSchema;
|
|
63
|
+
required: boolean;
|
|
64
|
+
description?: string;
|
|
65
|
+
};
|
|
66
|
+
/** `mapping` maps a discriminant value to a bare component name. */
|
|
67
|
+
export type IRDiscriminator = {
|
|
68
|
+
propertyName: string;
|
|
69
|
+
mapping?: Record<string, string>;
|
|
70
|
+
};
|
|
71
|
+
export type IRParam = {
|
|
72
|
+
name: string;
|
|
73
|
+
schema: IRSchema;
|
|
74
|
+
description?: string;
|
|
75
|
+
/** a path param is always required */
|
|
76
|
+
required?: boolean;
|
|
77
|
+
/** a path param spanning segments (`x-honey-wildcard`) */
|
|
78
|
+
wildcard?: true;
|
|
79
|
+
/** `schema.default`, as declared */
|
|
80
|
+
default?: unknown;
|
|
81
|
+
};
|
|
82
|
+
export type IRMultipartPart = {
|
|
83
|
+
name: string;
|
|
84
|
+
/** `file` for a binary schema or a list of them */
|
|
85
|
+
type: "file" | "text";
|
|
86
|
+
schema?: IRSchema;
|
|
87
|
+
};
|
|
88
|
+
export type IRBody = {
|
|
89
|
+
kind: "raw";
|
|
90
|
+
contentType: string;
|
|
91
|
+
schema: IRSchema;
|
|
92
|
+
required: boolean;
|
|
93
|
+
} | {
|
|
94
|
+
kind: "stream";
|
|
95
|
+
contentType: "application/octet-stream";
|
|
96
|
+
required: boolean;
|
|
97
|
+
} | {
|
|
98
|
+
kind: "multipart";
|
|
99
|
+
contentType: "multipart/form-data";
|
|
100
|
+
parts: IRMultipartPart[];
|
|
101
|
+
required: boolean;
|
|
102
|
+
/** the whole form, for emitters that type it as one value */
|
|
103
|
+
schema: IRSchema;
|
|
104
|
+
};
|
|
105
|
+
export type IRResponse = {
|
|
106
|
+
/** the status key as written: `200`, `4XX`, `default` */
|
|
107
|
+
status: string;
|
|
108
|
+
/** none for a response without a body */
|
|
109
|
+
contentType?: string;
|
|
110
|
+
schema?: IRSchema;
|
|
111
|
+
/** the declared headers (A2), names as written, in code-unit order; none when it declares none */
|
|
112
|
+
headers?: {
|
|
113
|
+
name: string;
|
|
114
|
+
required: boolean;
|
|
115
|
+
schema: IRSchema;
|
|
116
|
+
}[];
|
|
117
|
+
/** every media type it declares with its schema; `contentType`/`schema` are the preferred one */
|
|
118
|
+
contents?: {
|
|
119
|
+
contentType: string;
|
|
120
|
+
schema?: IRSchema;
|
|
121
|
+
}[];
|
|
122
|
+
/** a response a declared error produces (`x-honey-error`), never a declared output */
|
|
123
|
+
error?: true;
|
|
124
|
+
};
|
|
125
|
+
export type IROperationExtensions = {
|
|
126
|
+
deprecated?: true;
|
|
127
|
+
/** every declared error key (`x-honey-errors`): its status, null when it has none, and its own schema */
|
|
128
|
+
errors?: Record<string, {
|
|
129
|
+
schema?: IRSchema;
|
|
130
|
+
status: number | null;
|
|
131
|
+
}>;
|
|
132
|
+
idempotencyKey?: true;
|
|
133
|
+
invalidates?: string[];
|
|
134
|
+
mcp?: true;
|
|
135
|
+
realtime?: true;
|
|
136
|
+
/** the honey route id the operation came from (`x-honey-route`): what extracted ctx types are keyed by */
|
|
137
|
+
route?: string;
|
|
138
|
+
sse?: true;
|
|
139
|
+
websocket?: true;
|
|
140
|
+
};
|
|
141
|
+
export type IROperation = {
|
|
142
|
+
/** the operationId */
|
|
143
|
+
id: string;
|
|
144
|
+
/** upper case */
|
|
145
|
+
method: string;
|
|
146
|
+
/** the OpenAPI path template, `{param}` kept */
|
|
147
|
+
path: string;
|
|
148
|
+
description?: string;
|
|
149
|
+
summary?: string;
|
|
150
|
+
params: {
|
|
151
|
+
path: IRParam[];
|
|
152
|
+
query: IRParam[];
|
|
153
|
+
header: IRParam[];
|
|
154
|
+
cookie?: IRParam[];
|
|
155
|
+
};
|
|
156
|
+
/** the preferred request body: JSON first, then form, multipart, raw bytes */
|
|
157
|
+
body?: IRBody;
|
|
158
|
+
/** every declared body, in the same order, when there are several */
|
|
159
|
+
bodies?: IRBody[];
|
|
160
|
+
responses: Record<string, IRResponse>;
|
|
161
|
+
extensions: IROperationExtensions;
|
|
162
|
+
};
|
|
163
|
+
export type IRTreeEntry = {
|
|
164
|
+
kind: "method";
|
|
165
|
+
op: IROperation;
|
|
166
|
+
} | {
|
|
167
|
+
kind: "namespace";
|
|
168
|
+
ns: IRNamespace;
|
|
169
|
+
};
|
|
170
|
+
export type IRNamespace = {
|
|
171
|
+
entries: Map<string, IRTreeEntry>;
|
|
172
|
+
};
|
|
173
|
+
/** How a client authenticates: the header it sends and the prefix before the token. */
|
|
174
|
+
export type IRAuth = {
|
|
175
|
+
headerName: string;
|
|
176
|
+
prefix: string;
|
|
177
|
+
};
|
|
178
|
+
export type IRInfo = {
|
|
179
|
+
title?: string;
|
|
180
|
+
description?: string;
|
|
181
|
+
version?: string;
|
|
182
|
+
};
|
|
183
|
+
/** A Standard Webhooks event: its `type` and its `data`'s schema. */
|
|
184
|
+
export type IRWebhookEvent = {
|
|
185
|
+
type: string;
|
|
186
|
+
data: IRSchema;
|
|
187
|
+
};
|
|
188
|
+
/** A request the API sends a subscriber, `body` its JSON payload's schema, `event` when it is a Standard Webhooks one. */
|
|
189
|
+
export type IRWebhook = Pick<IROperation, "description" | "method" | "summary"> & {
|
|
190
|
+
name: string;
|
|
191
|
+
body?: IRSchema;
|
|
192
|
+
event?: IRWebhookEvent;
|
|
193
|
+
};
|
|
194
|
+
export type IR = {
|
|
195
|
+
auth: IRAuth;
|
|
196
|
+
info: IRInfo;
|
|
197
|
+
operations: IROperation[];
|
|
198
|
+
schemas: Record<string, IRSchema>;
|
|
199
|
+
/** the `description` of each component schema that has one */
|
|
200
|
+
schemaDescriptions: Record<string, string>;
|
|
201
|
+
/** each server URL the document declares, in order: the first is an SDK's default base URL */
|
|
202
|
+
servers: string[];
|
|
203
|
+
tree: IRNamespace;
|
|
204
|
+
/** every webhook, by name in code-unit order */
|
|
205
|
+
webhooks: IRWebhook[];
|
|
206
|
+
};
|
package/dist/ir/model.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inlining component schemas: every `$ref` under a request body or a response replaced by the
|
|
3
|
+
* schema it names, for the SDK emitters that type each call in place. A cycle is cut with `{}`
|
|
4
|
+
* (unknown), and the expansion is capped: shared refs can grow a document exponentially.
|
|
5
|
+
*/
|
|
6
|
+
import type { OpenApiDocument } from "./build.ts";
|
|
7
|
+
/**
|
|
8
|
+
* `doc` with every body and response schema inlined and its schema components dropped; a
|
|
9
|
+
* document without schema components comes back as it is. `doc` itself is never changed.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveRefs(doc: OpenApiDocument): OpenApiDocument;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const PREFIX = "#/components/schemas/";
|
|
2
|
+
/* past this many schema nodes, inlining fails loudly instead of eating the machine */
|
|
3
|
+
const MAX_NODES = 200_000;
|
|
4
|
+
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5
|
+
/** `schema` with its component ref, if it is one, replaced by a copy of the component, inlined. */
|
|
6
|
+
function inline(schema, run, visited) {
|
|
7
|
+
if (typeof schema.$ref !== "string" || !schema.$ref.startsWith(PREFIX))
|
|
8
|
+
return inlineChildren(schema, run, visited);
|
|
9
|
+
const name = schema.$ref.slice(PREFIX.length);
|
|
10
|
+
if (visited.has(name))
|
|
11
|
+
return {};
|
|
12
|
+
if (!Object.hasOwn(run.schemas, name))
|
|
13
|
+
throw new Error(`$ref points to nonexistent component: ${schema.$ref}`);
|
|
14
|
+
return inlineChildren(structuredClone(run.schemas[name]), run, new Set([...visited, name]));
|
|
15
|
+
}
|
|
16
|
+
/** `schema` with the schemas under its composition keywords, items, properties and additional properties inlined. */
|
|
17
|
+
function inlineChildren(schema, run, visited) {
|
|
18
|
+
if (++run.nodes > MAX_NODES) {
|
|
19
|
+
throw new Error(`SDK codegen: inlined schemas exceed ${MAX_NODES} nodes (deeply shared $refs); flatten the shared component chain`);
|
|
20
|
+
}
|
|
21
|
+
const child = (value) => (isRecord(value) ? inline(value, run, visited) : value);
|
|
22
|
+
for (const key of ["oneOf", "anyOf", "allOf"]) {
|
|
23
|
+
const list = schema[key];
|
|
24
|
+
if (Array.isArray(list))
|
|
25
|
+
schema[key] = list.map(child);
|
|
26
|
+
}
|
|
27
|
+
if (isRecord(schema.items))
|
|
28
|
+
schema.items = child(schema.items);
|
|
29
|
+
if (isRecord(schema.properties)) {
|
|
30
|
+
schema.properties = Object.fromEntries(Object.entries(schema.properties).map(([key, value]) => [key, child(value)]));
|
|
31
|
+
}
|
|
32
|
+
if (isRecord(schema.additionalProperties))
|
|
33
|
+
schema.additionalProperties = child(schema.additionalProperties);
|
|
34
|
+
return schema;
|
|
35
|
+
}
|
|
36
|
+
/** Each media type's schema in `holder.content` inlined, in place. */
|
|
37
|
+
function inlineContent(holder, run) {
|
|
38
|
+
if (!isRecord(holder) || !isRecord(holder.content))
|
|
39
|
+
return;
|
|
40
|
+
holder.content = Object.fromEntries(Object.entries(holder.content).map(([type, media]) => {
|
|
41
|
+
const inlined = isRecord(media) && isRecord(media.schema) ? inline(media.schema, run, new Set()) : undefined;
|
|
42
|
+
return [type, inlined === undefined ? media : { ...media, schema: inlined }];
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* `doc` with every body and response schema inlined and its schema components dropped; a
|
|
47
|
+
* document without schema components comes back as it is. `doc` itself is never changed.
|
|
48
|
+
*/
|
|
49
|
+
export function resolveRefs(doc) {
|
|
50
|
+
const { components } = doc;
|
|
51
|
+
const schemas = components?.schemas;
|
|
52
|
+
if (schemas === undefined || Object.keys(schemas).length === 0)
|
|
53
|
+
return doc;
|
|
54
|
+
const run = { nodes: 0, schemas };
|
|
55
|
+
const paths = structuredClone(doc.paths ?? {});
|
|
56
|
+
for (const item of Object.values(paths)) {
|
|
57
|
+
for (const op of Object.values(item)) {
|
|
58
|
+
inlineContent(op.requestBody, run);
|
|
59
|
+
for (const response of Object.values(isRecord(op.responses) ? op.responses : {}))
|
|
60
|
+
inlineContent(response, run);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/* schemas were there, so components are */
|
|
64
|
+
const { schemas: _inlined, ...rest } = components;
|
|
65
|
+
return { ...doc, components: Object.keys(rest).length > 0 ? rest : undefined, paths };
|
|
66
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IRNamespace, IROperation } from "./model.ts";
|
|
2
|
+
type Entries<T> = [string, T][];
|
|
3
|
+
/** A namespace's methods, in code-unit order. */
|
|
4
|
+
export declare function methodsOf(ns: IRNamespace): Entries<IROperation>;
|
|
5
|
+
/** A namespace's child namespaces, in code-unit order. */
|
|
6
|
+
export declare function namespacesOf(ns: IRNamespace): Entries<IRNamespace>;
|
|
7
|
+
/** The tree of `operations` by their dotted ids. */
|
|
8
|
+
export declare function buildResourceTree(operations: readonly IROperation[]): IRNamespace;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The resource tree: an operation's dotted id is its place, `checkout.sessions.create` the method
|
|
3
|
+
* `create` in the namespace `checkout.sessions`. An id that is also another's namespace is refused.
|
|
4
|
+
*/
|
|
5
|
+
import { compareCodeUnits } from "../emit/shared/lang.js";
|
|
6
|
+
function sortedOf(ns, kind) {
|
|
7
|
+
return [...ns.entries]
|
|
8
|
+
.filter((entry) => entry[1].kind === kind)
|
|
9
|
+
.sort(([a], [b]) => compareCodeUnits(a, b));
|
|
10
|
+
}
|
|
11
|
+
/** A namespace's methods, in code-unit order. */
|
|
12
|
+
export function methodsOf(ns) {
|
|
13
|
+
return sortedOf(ns, "method").map(([key, entry]) => [key, entry.op]);
|
|
14
|
+
}
|
|
15
|
+
/** A namespace's child namespaces, in code-unit order. */
|
|
16
|
+
export function namespacesOf(ns) {
|
|
17
|
+
return sortedOf(ns, "namespace").map(([key, entry]) => [key, entry.ns]);
|
|
18
|
+
}
|
|
19
|
+
/** The id of the first operation under `ns` (a namespace is never empty), to name it in a conflict. */
|
|
20
|
+
function firstId(ns) {
|
|
21
|
+
const first = ns.entries.values().next().value;
|
|
22
|
+
return first.kind === "method" ? first.op.id : firstId(first.ns);
|
|
23
|
+
}
|
|
24
|
+
function conflict(callable, nested) {
|
|
25
|
+
return new Error(`operationId conflict: "${callable}" is callable but also a namespace prefix of "${nested}".\n` +
|
|
26
|
+
`Rename one. Suggested: "${callable}" → "${callable}One" or drop "${nested}".`);
|
|
27
|
+
}
|
|
28
|
+
/** The tree of `operations` by their dotted ids. */
|
|
29
|
+
export function buildResourceTree(operations) {
|
|
30
|
+
const root = { entries: new Map() };
|
|
31
|
+
for (const op of operations) {
|
|
32
|
+
const segments = op.id.split(".");
|
|
33
|
+
const leaf = segments.pop();
|
|
34
|
+
let at = root;
|
|
35
|
+
for (const segment of segments) {
|
|
36
|
+
const entry = at.entries.get(segment);
|
|
37
|
+
if (entry?.kind === "method")
|
|
38
|
+
throw conflict(entry.op.id, op.id);
|
|
39
|
+
if (entry === undefined) {
|
|
40
|
+
const ns = { entries: new Map() };
|
|
41
|
+
at.entries.set(segment, { kind: "namespace", ns });
|
|
42
|
+
at = ns;
|
|
43
|
+
}
|
|
44
|
+
else
|
|
45
|
+
at = entry.ns;
|
|
46
|
+
}
|
|
47
|
+
const existing = at.entries.get(leaf);
|
|
48
|
+
if (existing?.kind === "namespace")
|
|
49
|
+
throw conflict(op.id, firstId(existing.ns));
|
|
50
|
+
at.entries.set(leaf, { kind: "method", op });
|
|
51
|
+
}
|
|
52
|
+
return root;
|
|
53
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The name prefix a caller forces on a value: `M` for meta, `P` for a route id. */
|
|
2
|
+
export type ForcedPrefix = "M" | "P";
|
|
3
|
+
/** Collects route data, decides what repeats, then prints each value: by name when shared, else in full. */
|
|
4
|
+
export declare class InternPool {
|
|
5
|
+
#private;
|
|
6
|
+
/** Count one appearance of `value` and of every long string, number and object inside it. */
|
|
7
|
+
count(value: unknown): void;
|
|
8
|
+
/** Name `value` whatever its count, with `prefix` (the first one forced wins). */
|
|
9
|
+
force(value: unknown, prefix: ForcedPrefix): void;
|
|
10
|
+
/** Fix the names: each value worth sharing, in first-seen order, numbered per prefix. Idempotent. */
|
|
11
|
+
seal(): void;
|
|
12
|
+
/** The name `value` is declared under, if it is shared. */
|
|
13
|
+
id(value: unknown): string | undefined;
|
|
14
|
+
/** `value` as an expression: its name when shared, else its literal with shared parts by name. */
|
|
15
|
+
expr(value: unknown): string;
|
|
16
|
+
/** The `const` declarations, shallowest first, so each is declared before anything using it. */
|
|
17
|
+
emitConstLines(): string[];
|
|
18
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interning for generated route-tree modules: route data (meta objects, route ids, error-key
|
|
3
|
+
* lists) whose JSON is equal is declared once as a `const` and shared by name. Callers refuse
|
|
4
|
+
* values JSON cannot carry first, so equal JSON always means equal values.
|
|
5
|
+
*/
|
|
6
|
+
import { tsString } from "../emit/shared/escape.js";
|
|
7
|
+
/* shorter strings and numbers cost less inline than a name */
|
|
8
|
+
const STRING_MIN = 8;
|
|
9
|
+
const NUMBER_MIN = 8;
|
|
10
|
+
/** How deeply `value` nests: 0 for a primitive. */
|
|
11
|
+
function depthOf(value) {
|
|
12
|
+
if (value === null || typeof value !== "object")
|
|
13
|
+
return 0;
|
|
14
|
+
const children = (Array.isArray(value) ? value : Object.values(value)).filter((child) => child !== undefined);
|
|
15
|
+
return Math.max(0, ...children.map(depthOf)) + 1;
|
|
16
|
+
}
|
|
17
|
+
/** Whether a primitive is worth naming: a long string or a long finite number. */
|
|
18
|
+
function worthNaming(value) {
|
|
19
|
+
if (typeof value === "string")
|
|
20
|
+
return value.length >= STRING_MIN;
|
|
21
|
+
return typeof value === "number" && Number.isFinite(value) && String(value).length >= NUMBER_MIN;
|
|
22
|
+
}
|
|
23
|
+
/** A key in an object literal; a quoted "__proto__" would set the prototype, a computed one defines a property. */
|
|
24
|
+
function keyName(key) {
|
|
25
|
+
return key === "__proto__" ? '["__proto__"]' : tsString(key);
|
|
26
|
+
}
|
|
27
|
+
/** A primitive as source: strings through the one escape layer (F2), the rest as JSON writes them. */
|
|
28
|
+
const primitive = (value) => (typeof value === "string" ? tsString(value) : JSON.stringify(value));
|
|
29
|
+
/** Collects route data, decides what repeats, then prints each value: by name when shared, else in full. */
|
|
30
|
+
export class InternPool {
|
|
31
|
+
#counts = new Map();
|
|
32
|
+
/** each canonical key in first-seen order, and its position */
|
|
33
|
+
#order = [];
|
|
34
|
+
#seenAt = new Map();
|
|
35
|
+
/** an object's canonical key, computed once; its children appear in it by their own short keys */
|
|
36
|
+
#objectKeys = new WeakMap();
|
|
37
|
+
/** a short key per distinct structure, so a parent's key never repeats a whole subtree */
|
|
38
|
+
#structures = new Map();
|
|
39
|
+
#forced = new Map();
|
|
40
|
+
#ids = new Map();
|
|
41
|
+
#values = new Map();
|
|
42
|
+
#sealed = false;
|
|
43
|
+
/** Count one appearance of `value` and of every long string, number and object inside it. */
|
|
44
|
+
count(value) {
|
|
45
|
+
if (value === null || typeof value === "boolean" || value === undefined)
|
|
46
|
+
return;
|
|
47
|
+
if (typeof value !== "object") {
|
|
48
|
+
if (worthNaming(value))
|
|
49
|
+
this.#bump(value);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.#bump(value);
|
|
53
|
+
for (const child of Array.isArray(value) ? value : Object.values(value))
|
|
54
|
+
if (child !== undefined)
|
|
55
|
+
this.count(child);
|
|
56
|
+
}
|
|
57
|
+
/** Name `value` whatever its count, with `prefix` (the first one forced wins). */
|
|
58
|
+
force(value, prefix) {
|
|
59
|
+
if (value === null || value === undefined)
|
|
60
|
+
return;
|
|
61
|
+
const key = this.#canonical(value);
|
|
62
|
+
if (!this.#values.has(key))
|
|
63
|
+
this.#remember(key, value);
|
|
64
|
+
if (!this.#forced.has(key))
|
|
65
|
+
this.#forced.set(key, prefix);
|
|
66
|
+
}
|
|
67
|
+
/** Fix the names: each value worth sharing, in first-seen order, numbered per prefix. Idempotent. */
|
|
68
|
+
seal() {
|
|
69
|
+
if (this.#sealed)
|
|
70
|
+
return;
|
|
71
|
+
this.#sealed = true;
|
|
72
|
+
const counters = new Map();
|
|
73
|
+
for (const key of this.#order) {
|
|
74
|
+
const value = this.#values.get(key);
|
|
75
|
+
if (!this.#shared(key, value))
|
|
76
|
+
continue;
|
|
77
|
+
const prefix = this.#forced.get(key) ??
|
|
78
|
+
(typeof value === "string" ? "T" : typeof value === "number" ? "U" : Array.isArray(value) ? "A" : "J");
|
|
79
|
+
const n = counters.get(prefix) ?? 0;
|
|
80
|
+
counters.set(prefix, n + 1);
|
|
81
|
+
this.#ids.set(key, `${prefix}${n}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** The name `value` is declared under, if it is shared. */
|
|
85
|
+
id(value) {
|
|
86
|
+
return value === undefined ? undefined : this.#ids.get(this.#canonical(value));
|
|
87
|
+
}
|
|
88
|
+
/** `value` as an expression: its name when shared, else its literal with shared parts by name. */
|
|
89
|
+
expr(value) {
|
|
90
|
+
return this.id(value) ?? this.#literal(value);
|
|
91
|
+
}
|
|
92
|
+
/** The `const` declarations, shallowest first, so each is declared before anything using it. */
|
|
93
|
+
emitConstLines() {
|
|
94
|
+
return [...this.#ids]
|
|
95
|
+
.map(([key, id]) => ({ depth: depthOf(this.#values.get(key)), id, key, seen: this.#seenAt.get(key) }))
|
|
96
|
+
.sort((a, b) => a.depth - b.depth || a.seen - b.seen)
|
|
97
|
+
.map(({ id, key }) => `const ${id} = ${this.#literal(this.#values.get(key))}`);
|
|
98
|
+
}
|
|
99
|
+
#shared(key, value) {
|
|
100
|
+
if (this.#forced.has(key))
|
|
101
|
+
return true;
|
|
102
|
+
if (this.#counts.get(key) < 2)
|
|
103
|
+
return false;
|
|
104
|
+
return typeof value === "object" ? !(Array.isArray(value) && value.length === 0) : true;
|
|
105
|
+
}
|
|
106
|
+
#remember(key, value) {
|
|
107
|
+
this.#values.set(key, value);
|
|
108
|
+
this.#seenAt.set(key, this.#order.length);
|
|
109
|
+
this.#order.push(key);
|
|
110
|
+
}
|
|
111
|
+
#bump(value) {
|
|
112
|
+
const key = this.#canonical(value);
|
|
113
|
+
const n = (this.#counts.get(key) ?? 0) + 1;
|
|
114
|
+
this.#counts.set(key, n);
|
|
115
|
+
if (n === 1 && !this.#values.has(key))
|
|
116
|
+
this.#remember(key, value);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Equal JSON, equal key: an object's key names its children by their keys, so it is computed once
|
|
120
|
+
* per object. Children are keyed first without recursion: a value nested 1500 deep keeps the stack.
|
|
121
|
+
*/
|
|
122
|
+
#canonical(value) {
|
|
123
|
+
if (value === null || typeof value !== "object")
|
|
124
|
+
return JSON.stringify(value);
|
|
125
|
+
const stack = [value];
|
|
126
|
+
const open = new Set();
|
|
127
|
+
while (stack.length > 0) {
|
|
128
|
+
const top = stack.at(-1);
|
|
129
|
+
if (this.#objectKeys.has(top)) {
|
|
130
|
+
stack.pop();
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const pending = (Array.isArray(top) ? top : Object.values(top)).filter((child) => child !== null && typeof child === "object" && !this.#objectKeys.has(child));
|
|
134
|
+
if (pending.length > 0 && !open.has(top)) {
|
|
135
|
+
open.add(top);
|
|
136
|
+
for (const child of pending)
|
|
137
|
+
if (open.has(child))
|
|
138
|
+
throw new TypeError("route data refers to itself");
|
|
139
|
+
stack.push(...pending);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
stack.pop();
|
|
143
|
+
this.#objectKeys.set(top, this.#structureOf(top));
|
|
144
|
+
}
|
|
145
|
+
return this.#objectKeys.get(value);
|
|
146
|
+
}
|
|
147
|
+
/** The short key of `value`'s structure, its children already keyed. */
|
|
148
|
+
#structureOf(value) {
|
|
149
|
+
const key = (child) => child === undefined
|
|
150
|
+
? "null"
|
|
151
|
+
: child === null || typeof child !== "object"
|
|
152
|
+
? JSON.stringify(child)
|
|
153
|
+
: this.#objectKeys.get(child);
|
|
154
|
+
const structure = Array.isArray(value)
|
|
155
|
+
? `[${value.map(key).join(",")}]`
|
|
156
|
+
: `{${Object.entries(value)
|
|
157
|
+
.filter(([, child]) => child !== undefined)
|
|
158
|
+
.map(([name, child]) => `${JSON.stringify(name)}:${key(child)}`)
|
|
159
|
+
.join(",")}}`;
|
|
160
|
+
const id = this.#structures.get(structure) ?? `#${this.#structures.size}`;
|
|
161
|
+
this.#structures.set(structure, id);
|
|
162
|
+
return id;
|
|
163
|
+
}
|
|
164
|
+
#literal(value) {
|
|
165
|
+
if (value === undefined)
|
|
166
|
+
return "undefined";
|
|
167
|
+
if (value === null || typeof value !== "object")
|
|
168
|
+
return primitive(value);
|
|
169
|
+
if (Array.isArray(value))
|
|
170
|
+
return `[${value.map((child) => this.expr(child)).join(",")}]`;
|
|
171
|
+
const entries = Object.entries(value).filter(([, child]) => child !== undefined);
|
|
172
|
+
return `{${entries.map(([key, child]) => `${keyName(key)}:${this.expr(child)}`).join(",")}}`;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a JSON Schema into an IR schema, and following an IR schema's refs to the component
|
|
3
|
+
* they name. The IR types themselves are in `model.ts`.
|
|
4
|
+
*/
|
|
5
|
+
import type { IRSchema } from "./model.ts";
|
|
6
|
+
type Json = Record<string, unknown>;
|
|
7
|
+
/** What a typed value of `schema` is in the IR, read in a fixed order; anything unreadable is `unknown`. */
|
|
8
|
+
export declare function schemaToIR(schema: Json | undefined): IRSchema;
|
|
9
|
+
/** Follows `ref` nodes to their component; an unknown or endless one is `unknown`. */
|
|
10
|
+
export declare function irResolver(schemas: Record<string, IRSchema>): (schema: IRSchema) => IRSchema;
|
|
11
|
+
export {};
|