@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,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The targets honey-clients generates and each target's options (plan 39 8.1): the table the CLI reads
|
|
3
|
+
* `--<target>-<option>` from, and what a caller holding a run as data (a release manifest) checks it with, so a new
|
|
4
|
+
* target or option reaches that caller with no change of its own. The schemas are Standard Schemas (v1), the kind
|
|
5
|
+
* honey takes everywhere, so any validator that reads one checks a run before it reaches `generated`.
|
|
6
|
+
*/
|
|
7
|
+
import { type Metadata } from "../emit/shared/metadata.ts";
|
|
8
|
+
/**
|
|
9
|
+
* What `generate` can produce: an SDK per language (`csharp`, `go`, `java`, `python`, `rust`, `ts`), a Go `cli`, or an
|
|
10
|
+
* `mcp` server.
|
|
11
|
+
*/
|
|
12
|
+
export declare const TARGETS: readonly ["cli", "csharp", "go", "java", "mcp", "python", "rust", "ts"];
|
|
13
|
+
/** One of `TARGETS`. */
|
|
14
|
+
export type Target = (typeof TARGETS)[number];
|
|
15
|
+
/**
|
|
16
|
+
* Each target and the names of its generate function's options, which `--<target>-<option>` carries as strings.
|
|
17
|
+
* `--ts-tanstack-query` is the one switch that takes no value: it turns the TanStack Query adapter on.
|
|
18
|
+
*/
|
|
19
|
+
export declare const TARGET_OPTIONS: {
|
|
20
|
+
readonly cli: readonly ["aur", "baseUrl", "binaryName", "description", "envPrefix", "homebrewTap", "homepage", "installUrl", "license", "maintainer", "modulePath", "packages", "repo", "scoopBucket", "version", "wingetFork", "wingetPublisher"];
|
|
21
|
+
readonly csharp: readonly ["authors", "clientName", "copyright", "description", "homepage", "license", "packageId", "repository", "rootNamespace", "tags", "version"];
|
|
22
|
+
readonly go: readonly ["modulePath", "version"];
|
|
23
|
+
readonly java: readonly ["artifactId", "clientName", "description", "developers", "groupId", "homepage", "license", "packageName", "repository", "version"];
|
|
24
|
+
readonly mcp: readonly ["envPrefix", "mcpName", "name", "packageName", "version"];
|
|
25
|
+
readonly python: readonly ["packageName", "version"];
|
|
26
|
+
readonly rust: readonly ["categories", "crateName", "description", "documentation", "homepage", "keywords", "license", "repository", "version"];
|
|
27
|
+
readonly ts: readonly ["name", "packageName", "stem", "tanstackQuery", "version"];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The target options that take no value, since their name already says what they turn on
|
|
31
|
+
* (`--ts-tanstack-query`, not `--ts-query tanstack`). They stay listed in `TARGET_OPTIONS` above, which is what
|
|
32
|
+
* the repo's README test (`tests/docs/readmes.test.ts`) reads to hold every flag to its README row; this table only
|
|
33
|
+
* says how one is read. Bare is `true` and an inline `true`/`false` is read, exactly as `--watch` is.
|
|
34
|
+
*/
|
|
35
|
+
declare const BOOLEAN_OPTIONS: {
|
|
36
|
+
readonly cli: readonly ["aur"];
|
|
37
|
+
readonly ts: readonly ["tanstackQuery"];
|
|
38
|
+
};
|
|
39
|
+
/** The switches among `T`'s options: the ones `TargetOptions<T>` types as `"true"` or `"false"`. */
|
|
40
|
+
type BooleanOption<T extends Target> = T extends keyof typeof BOOLEAN_OPTIONS ? (typeof BOOLEAN_OPTIONS)[T][number] : never;
|
|
41
|
+
/** One target's options by camelCase name, each a string; a switch (`aur`, `tanstackQuery`) is `"true"` or `"false"`. */
|
|
42
|
+
export type TargetOptions<T extends Target> = {
|
|
43
|
+
readonly [K in (typeof TARGET_OPTIONS)[T][number]]?: K extends BooleanOption<T> ? "true" | "false" : string;
|
|
44
|
+
};
|
|
45
|
+
/** Any target's options by name, as the CLI parses and each generator reads them. */
|
|
46
|
+
export type Options = Readonly<Record<string, string>>;
|
|
47
|
+
/** One problem a schema found: what is wrong, and the option it is about. */
|
|
48
|
+
export type OptionsIssue = {
|
|
49
|
+
/** What is wrong, naming the target and the option. */
|
|
50
|
+
readonly message: string;
|
|
51
|
+
/** The option's name, as the only segment; absent when the value is not an object at all. */
|
|
52
|
+
readonly path?: readonly PropertyKey[];
|
|
53
|
+
};
|
|
54
|
+
/** What `validate` answers: the options it accepted, or every issue it found. */
|
|
55
|
+
export type OptionsResult<T extends Target> = {
|
|
56
|
+
/** The options, as given. */
|
|
57
|
+
readonly value: TargetOptions<T>;
|
|
58
|
+
/** Absent: no issue was found. */
|
|
59
|
+
readonly issues?: undefined;
|
|
60
|
+
} | {
|
|
61
|
+
/** Each problem found, one per option. */
|
|
62
|
+
readonly issues: readonly OptionsIssue[];
|
|
63
|
+
};
|
|
64
|
+
/** A Standard Schema (standardschema.dev, v1) for one target's options; it validates synchronously. */
|
|
65
|
+
export type TargetOptionsSchema<T extends Target> = {
|
|
66
|
+
/** The Standard Schema interface any validator that reads one calls. */
|
|
67
|
+
readonly "~standard": {
|
|
68
|
+
/** The Standard Schema version. */
|
|
69
|
+
readonly version: 1;
|
|
70
|
+
/** Who made the schema. */
|
|
71
|
+
readonly vendor: "honey-clients";
|
|
72
|
+
/** Checks `value` as `T`'s options: its option names only, each a non-empty string, a switch true or false. */
|
|
73
|
+
readonly validate: (value: unknown) => OptionsResult<T>;
|
|
74
|
+
/** The types the schema reads and answers, for a caller to infer from; never set at runtime. */
|
|
75
|
+
readonly types?: {
|
|
76
|
+
/** What `validate` takes: anything. */
|
|
77
|
+
readonly input: unknown;
|
|
78
|
+
/** What `validate` answers when it finds no issue. */
|
|
79
|
+
readonly output: TargetOptions<T>;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/** Whether `target`'s option `key` takes no value. */
|
|
84
|
+
export declare function isBooleanOption(target: Target, key: string): boolean;
|
|
85
|
+
/** Each target's options schema: its option names only, each a non-empty string, a switch `"true"` or `"false"`. */
|
|
86
|
+
export declare const targetOptionSchemas: {
|
|
87
|
+
readonly [T in Target]: TargetOptionsSchema<T>;
|
|
88
|
+
};
|
|
89
|
+
/** `value` as `target`'s options, or an error naming every problem its schema found. */
|
|
90
|
+
export declare function checkedOptions(target: Target, value: unknown): Options;
|
|
91
|
+
/** `target`'s options: those `metadata` fills, under the ones the run gives the target itself, checked. */
|
|
92
|
+
export declare function optionsFor(target: Target, metadata: Metadata, options: unknown): Options;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The targets honey-clients generates and each target's options (plan 39 8.1): the table the CLI reads
|
|
3
|
+
* `--<target>-<option>` from, and what a caller holding a run as data (a release manifest) checks it with, so a new
|
|
4
|
+
* target or option reaches that caller with no change of its own. The schemas are Standard Schemas (v1), the kind
|
|
5
|
+
* honey takes everywhere, so any validator that reads one checks a run before it reaches `generated`.
|
|
6
|
+
*/
|
|
7
|
+
import { authorName } from "../emit/shared/metadata.js";
|
|
8
|
+
/**
|
|
9
|
+
* What `generate` can produce: an SDK per language (`csharp`, `go`, `java`, `python`, `rust`, `ts`), a Go `cli`, or an
|
|
10
|
+
* `mcp` server.
|
|
11
|
+
*/
|
|
12
|
+
export const TARGETS = ["cli", "csharp", "go", "java", "mcp", "python", "rust", "ts"];
|
|
13
|
+
/**
|
|
14
|
+
* Each target and the names of its generate function's options, which `--<target>-<option>` carries as strings.
|
|
15
|
+
* `--ts-tanstack-query` is the one switch that takes no value: it turns the TanStack Query adapter on.
|
|
16
|
+
*/
|
|
17
|
+
export const TARGET_OPTIONS = {
|
|
18
|
+
cli: [
|
|
19
|
+
"aur",
|
|
20
|
+
"baseUrl",
|
|
21
|
+
"binaryName",
|
|
22
|
+
"description",
|
|
23
|
+
"envPrefix",
|
|
24
|
+
"homebrewTap",
|
|
25
|
+
"homepage",
|
|
26
|
+
"installUrl",
|
|
27
|
+
"license",
|
|
28
|
+
"maintainer",
|
|
29
|
+
"modulePath",
|
|
30
|
+
"packages",
|
|
31
|
+
"repo",
|
|
32
|
+
"scoopBucket",
|
|
33
|
+
"version",
|
|
34
|
+
"wingetFork",
|
|
35
|
+
"wingetPublisher",
|
|
36
|
+
],
|
|
37
|
+
csharp: [
|
|
38
|
+
"authors",
|
|
39
|
+
"clientName",
|
|
40
|
+
"copyright",
|
|
41
|
+
"description",
|
|
42
|
+
"homepage",
|
|
43
|
+
"license",
|
|
44
|
+
"packageId",
|
|
45
|
+
"repository",
|
|
46
|
+
"rootNamespace",
|
|
47
|
+
"tags",
|
|
48
|
+
"version",
|
|
49
|
+
],
|
|
50
|
+
go: ["modulePath", "version"],
|
|
51
|
+
java: [
|
|
52
|
+
"artifactId",
|
|
53
|
+
"clientName",
|
|
54
|
+
"description",
|
|
55
|
+
"developers",
|
|
56
|
+
"groupId",
|
|
57
|
+
"homepage",
|
|
58
|
+
"license",
|
|
59
|
+
"packageName",
|
|
60
|
+
"repository",
|
|
61
|
+
"version",
|
|
62
|
+
],
|
|
63
|
+
mcp: ["envPrefix", "mcpName", "name", "packageName", "version"],
|
|
64
|
+
python: ["packageName", "version"],
|
|
65
|
+
rust: [
|
|
66
|
+
"categories",
|
|
67
|
+
"crateName",
|
|
68
|
+
"description",
|
|
69
|
+
"documentation",
|
|
70
|
+
"homepage",
|
|
71
|
+
"keywords",
|
|
72
|
+
"license",
|
|
73
|
+
"repository",
|
|
74
|
+
"version",
|
|
75
|
+
],
|
|
76
|
+
ts: ["name", "packageName", "stem", "tanstackQuery", "version"],
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* The target options that take no value, since their name already says what they turn on
|
|
80
|
+
* (`--ts-tanstack-query`, not `--ts-query tanstack`). They stay listed in `TARGET_OPTIONS` above, which is what
|
|
81
|
+
* the repo's README test (`tests/docs/readmes.test.ts`) reads to hold every flag to its README row; this table only
|
|
82
|
+
* says how one is read. Bare is `true` and an inline `true`/`false` is read, exactly as `--watch` is.
|
|
83
|
+
*/
|
|
84
|
+
const BOOLEAN_OPTIONS = { cli: ["aur"], ts: ["tanstackQuery"] };
|
|
85
|
+
/** Whether `target`'s option `key` takes no value. */
|
|
86
|
+
export function isBooleanOption(target, key) {
|
|
87
|
+
const keys = BOOLEAN_OPTIONS[target] ?? [];
|
|
88
|
+
return keys.includes(key);
|
|
89
|
+
}
|
|
90
|
+
/** What is wrong with `target`'s option `key` set to `value`, if anything. */
|
|
91
|
+
function issueOf(target, key, value) {
|
|
92
|
+
const keys = TARGET_OPTIONS[target];
|
|
93
|
+
if (!keys.includes(key))
|
|
94
|
+
return { message: `unknown ${target} option ${JSON.stringify(key)}: want one of ${keys.join(", ")}`, path: [key] };
|
|
95
|
+
if (isBooleanOption(target, key))
|
|
96
|
+
return value === "true" || value === "false"
|
|
97
|
+
? undefined
|
|
98
|
+
: { message: `${target} option ${key}: want "true" or "false"`, path: [key] };
|
|
99
|
+
return typeof value === "string" && value !== ""
|
|
100
|
+
? undefined
|
|
101
|
+
: { message: `${target} option ${key}: want a non-empty string`, path: [key] };
|
|
102
|
+
}
|
|
103
|
+
function schemaOf(target) {
|
|
104
|
+
return {
|
|
105
|
+
"~standard": {
|
|
106
|
+
validate(value) {
|
|
107
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
108
|
+
return { issues: [{ message: `${target} options: want an object of option names to strings` }] };
|
|
109
|
+
/* an option given as undefined is not given: a caller's optional field, never a value */
|
|
110
|
+
const given = Object.entries(value).filter(([, option]) => option !== undefined);
|
|
111
|
+
const issues = given.flatMap(([key, option]) => issueOf(target, key, option) ?? []);
|
|
112
|
+
return issues.length > 0 ? { issues } : { value: Object.fromEntries(given) };
|
|
113
|
+
},
|
|
114
|
+
vendor: "honey-clients",
|
|
115
|
+
version: 1,
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** Each target's options schema: its option names only, each a non-empty string, a switch `"true"` or `"false"`. */
|
|
120
|
+
export const targetOptionSchemas = /* @__PURE__ */ schemasOf();
|
|
121
|
+
function schemasOf() {
|
|
122
|
+
return Object.fromEntries(TARGETS.map((target) => [target, schemaOf(target)]));
|
|
123
|
+
}
|
|
124
|
+
/** `value` as `target`'s options, or an error naming every problem its schema found. */
|
|
125
|
+
export function checkedOptions(target, value) {
|
|
126
|
+
const result = targetOptionSchemas[target]["~standard"].validate(value);
|
|
127
|
+
if (result.issues !== undefined)
|
|
128
|
+
throw new Error(result.issues.map((issue) => issue.message).join("; "));
|
|
129
|
+
return result.value;
|
|
130
|
+
}
|
|
131
|
+
const description = (metadata) => metadata.description;
|
|
132
|
+
const homepage = (metadata) => metadata.homepage;
|
|
133
|
+
const documentation = (metadata) => metadata.documentation;
|
|
134
|
+
const license = (metadata) => metadata.license;
|
|
135
|
+
const repository = (metadata) => metadata.repository;
|
|
136
|
+
const firstAuthor = (metadata) => metadata.authors?.[0];
|
|
137
|
+
/**
|
|
138
|
+
* The options each target fills from the run's metadata block (plan 39 8.2), each read from the field of the same
|
|
139
|
+
* meaning: NuGet's authors are names, the Linux packages' maintainer the first author whole, a POM's developers every
|
|
140
|
+
* author, and crates.io's keywords and NuGet's tags the CLI's comma-separated list. A target's own option wins over its metadata.
|
|
141
|
+
*/
|
|
142
|
+
const FROM_METADATA = {
|
|
143
|
+
cli: { description, homepage, license, maintainer: firstAuthor },
|
|
144
|
+
csharp: {
|
|
145
|
+
authors: (metadata) => metadata.authors?.map(authorName).join(", "),
|
|
146
|
+
copyright: (metadata) => metadata.copyright,
|
|
147
|
+
description,
|
|
148
|
+
homepage,
|
|
149
|
+
license,
|
|
150
|
+
repository,
|
|
151
|
+
tags: (metadata) => metadata.keywords?.join(","),
|
|
152
|
+
},
|
|
153
|
+
java: { description, developers: (metadata) => metadata.authors?.join(","), homepage, license, repository },
|
|
154
|
+
rust: {
|
|
155
|
+
description,
|
|
156
|
+
documentation,
|
|
157
|
+
homepage,
|
|
158
|
+
keywords: (metadata) => metadata.keywords?.join(","),
|
|
159
|
+
license,
|
|
160
|
+
repository,
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
/** `target`'s options: those `metadata` fills, under the ones the run gives the target itself, checked. */
|
|
164
|
+
export function optionsFor(target, metadata, options) {
|
|
165
|
+
const filled = Object.entries(FROM_METADATA[target] ?? {}).flatMap(([key, read]) => {
|
|
166
|
+
const value = read(metadata);
|
|
167
|
+
return value === undefined ? [] : [[key, value]];
|
|
168
|
+
});
|
|
169
|
+
const given = checkedOptions(target, options);
|
|
170
|
+
return { ...Object.fromEntries(filled), ...given };
|
|
171
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PackageIdentity } from "../emit/shared/metadata.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The manifest a target's directory keeps: `files`, each file it wrote by its path with its sha256, and `packages`,
|
|
4
|
+
* the package as each registry lists it (`registry`, `name`, `version`), when the writer names it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const MANIFEST = ".honey-generated.json";
|
|
7
|
+
/** What a write did: the files rewritten, the stale ones deleted, and the edited stale ones kept. */
|
|
8
|
+
export type Written = {
|
|
9
|
+
/** each stale file removed, its path relative to the directory */
|
|
10
|
+
readonly deleted: string[];
|
|
11
|
+
/** each stale file left in place because it was edited since, not a regular file, or outside the directory */
|
|
12
|
+
readonly kept: string[];
|
|
13
|
+
/** each file whose bytes changed, so it was rewritten; an unchanged one is left untouched */
|
|
14
|
+
readonly written: string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Whether `name` is a temp file a write is still renaming into place: `.<pid>.<base-36 random>.tmp`, never a file a
|
|
18
|
+
* target generates. A reader that lists a directory while it is written skips these, for the rename takes them away.
|
|
19
|
+
*/
|
|
20
|
+
export declare const isWriteTemp: (name: string) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Write `content` (text, as UTF-8, or bytes) to `path` only when its bytes differ, through a temp file renamed over it;
|
|
23
|
+
* whether it was written.
|
|
24
|
+
*/
|
|
25
|
+
export declare function writeFileIfChanged(path: string, content: string | Uint8Array): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* `files` written under `dir`, the manifest updated, and the previous run's stale, unedited files deleted. A file the
|
|
28
|
+
* previous manifest lists that `files` leaves out is stale: deleted when its bytes still hash as listed, kept and named
|
|
29
|
+
* when edited since, and dropped from the manifest either way, so a file the caller takes over is kept once and never
|
|
30
|
+
* touched again. A file the manifest never listed is never touched. `packages`, `generated`'s for the target, is
|
|
31
|
+
* recorded beside the files.
|
|
32
|
+
*/
|
|
33
|
+
export declare function writeTarget(dir: string, files: Readonly<Record<string, string | Uint8Array>>, packages?: readonly PackageIdentity[]): Written;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A target's files written under its directory (bit 19 h1, carry-in #2): each written only when its bytes differ,
|
|
3
|
+
* through a temp file renamed over it, and listed with its sha256 in the directory's manifest. A regeneration deletes
|
|
4
|
+
* a file only when the previous manifest lists it, this run does not emit it, and its bytes still hash as listed: a
|
|
5
|
+
* hand-edited one is kept and named. Every path stays under the directory and no symlink is followed; without a
|
|
6
|
+
* manifest nothing is deleted. The hash lives in the manifest, so the emitted bytes carry no header (Q6). The manifest
|
|
7
|
+
* also records the package the files make, as each registry it publishes to lists it (plan 39 8.7), so a release
|
|
8
|
+
* reads its name and version there instead of parsing each registry's manifest.
|
|
9
|
+
*/
|
|
10
|
+
import { createHash } from "node:crypto";
|
|
11
|
+
import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, rmdirSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
12
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
13
|
+
/**
|
|
14
|
+
* The manifest a target's directory keeps: `files`, each file it wrote by its path with its sha256, and `packages`,
|
|
15
|
+
* the package as each registry lists it (`registry`, `name`, `version`), when the writer names it.
|
|
16
|
+
*/
|
|
17
|
+
export const MANIFEST = ".honey-generated.json";
|
|
18
|
+
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
19
|
+
/** Whether `path` is a symlink, a dangling one included. */
|
|
20
|
+
function isLink(path) {
|
|
21
|
+
try {
|
|
22
|
+
return lstatSync(path).isSymbolicLink();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** `rel` under `dir`, refused when it escapes it or passes through a symlink (the directory's own included). */
|
|
29
|
+
function confined(dir, rel) {
|
|
30
|
+
const path = resolve(dir, rel);
|
|
31
|
+
const inside = relative(dir, path);
|
|
32
|
+
if (isAbsolute(rel) || inside === "" || inside.startsWith("..") || isAbsolute(inside))
|
|
33
|
+
throw new Error(`${rel}: the path escapes ${dir}`);
|
|
34
|
+
let at = dir;
|
|
35
|
+
for (const part of ["", ...inside.split(sep)]) {
|
|
36
|
+
at = join(at, part);
|
|
37
|
+
if (isLink(at))
|
|
38
|
+
throw new Error(`${rel}: a symlink in its path is refused`);
|
|
39
|
+
}
|
|
40
|
+
return path;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether `name` is a temp file a write is still renaming into place: `.<pid>.<base-36 random>.tmp`, never a file a
|
|
44
|
+
* target generates. A reader that lists a directory while it is written skips these, for the rename takes them away.
|
|
45
|
+
*/
|
|
46
|
+
export const isWriteTemp = (name) => /^\.\d+\.[0-9a-z]*\.tmp$/.test(name);
|
|
47
|
+
/**
|
|
48
|
+
* Write `content` (text, as UTF-8, or bytes) to `path` only when its bytes differ, through a temp file renamed over it;
|
|
49
|
+
* whether it was written.
|
|
50
|
+
*/
|
|
51
|
+
export function writeFileIfChanged(path, content) {
|
|
52
|
+
if (existsSync(path) && readFileSync(path).equals(typeof content === "string" ? Buffer.from(content) : content))
|
|
53
|
+
return false;
|
|
54
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
55
|
+
const temp = join(dirname(path), `.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`);
|
|
56
|
+
writeFileSync(temp, content);
|
|
57
|
+
renameSync(temp, path);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
/** The previous run's listing, or none when there is no readable manifest. */
|
|
61
|
+
function listed(dir) {
|
|
62
|
+
try {
|
|
63
|
+
const files = JSON.parse(readFileSync(join(dir, MANIFEST), "utf8")).files;
|
|
64
|
+
return typeof files === "object" && files !== null && !Array.isArray(files) ? files : {};
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** Remove the directories under `dir` that deleting `path` left empty. */
|
|
71
|
+
function prune(dir, path) {
|
|
72
|
+
for (let at = dirname(path); at !== dir && at.startsWith(dir + sep) && readdirSync(at).length === 0; at = dirname(at))
|
|
73
|
+
rmdirSync(at);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* `files` written under `dir`, the manifest updated, and the previous run's stale, unedited files deleted. A file the
|
|
77
|
+
* previous manifest lists that `files` leaves out is stale: deleted when its bytes still hash as listed, kept and named
|
|
78
|
+
* when edited since, and dropped from the manifest either way, so a file the caller takes over is kept once and never
|
|
79
|
+
* touched again. A file the manifest never listed is never touched. `packages`, `generated`'s for the target, is
|
|
80
|
+
* recorded beside the files.
|
|
81
|
+
*/
|
|
82
|
+
export function writeTarget(dir, files, packages) {
|
|
83
|
+
const root = resolve(dir);
|
|
84
|
+
const paths = Object.keys(files).map((rel) => [rel, confined(root, rel)]);
|
|
85
|
+
const previous = listed(root);
|
|
86
|
+
const written = paths
|
|
87
|
+
.filter(([rel, path]) => writeFileIfChanged(path, files[rel]))
|
|
88
|
+
.map(([rel]) => rel);
|
|
89
|
+
const [deleted, kept] = [[], []];
|
|
90
|
+
for (const [rel, hash] of Object.entries(previous)) {
|
|
91
|
+
if (Object.hasOwn(files, rel))
|
|
92
|
+
continue;
|
|
93
|
+
let path;
|
|
94
|
+
try {
|
|
95
|
+
path = confined(root, rel);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
kept.push(rel);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
/* a deleted file or directory is already gone (R7) */
|
|
102
|
+
if (!existsSync(path))
|
|
103
|
+
continue;
|
|
104
|
+
if (!lstatSync(path).isFile() || sha256(readFileSync(path)) !== hash) {
|
|
105
|
+
kept.push(rel);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
unlinkSync(path);
|
|
109
|
+
prune(root, path);
|
|
110
|
+
deleted.push(rel);
|
|
111
|
+
}
|
|
112
|
+
const manifest = Object.fromEntries(Object.keys(files)
|
|
113
|
+
.sort()
|
|
114
|
+
.map((rel) => [rel, sha256(files[rel])]));
|
|
115
|
+
const record = packages === undefined ? { files: manifest } : { packages, files: manifest };
|
|
116
|
+
writeFileIfChanged(join(root, MANIFEST), `${JSON.stringify(record, null, "\t")}\n`);
|
|
117
|
+
return { deleted, kept, written };
|
|
118
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@workerstack/clients`'s module entry (bit 19 h2): what core's build plugin imports, dynamically, to write an
|
|
3
|
+
* app's artifacts (the route tree, the types, each file only when it changed). The SDK, CLI and MCP server generators
|
|
4
|
+
* stay behind the `honey-clients` bin. Bit 21 e: the MCP handler an app mounts is the plugin's `codegen.mcp` output.
|
|
5
|
+
*/
|
|
6
|
+
export { type Metadata, METADATA_FIELDS, type MetadataField, type PackageIdentity, type Registry, } from "./emit/shared/metadata.ts";
|
|
7
|
+
export { type ExtractedTypes, type ExtractOptions, extractTypes, loadTsMorph } from "./extract/extract.ts";
|
|
8
|
+
export { type GeneratedMcpHandler, generateMcpHandler } from "./emit/mcp/mounted.ts";
|
|
9
|
+
export { generateRouteTree, type RouteTree } from "./emit/ts/route-tree.ts";
|
|
10
|
+
export { type GenerateTypesOptions, generateTypes } from "./emit/ts/type-gen.ts";
|
|
11
|
+
export { type Generated, generated, type GenerateContext, type GeneratedTarget, type GenerateRun, type Io, writeGenerated, } from "./cli.ts";
|
|
12
|
+
export { type Options, type Target, TARGETS, type TargetOptions, type TargetOptionsSchema, targetOptionSchemas, } from "./gen/targets.ts";
|
|
13
|
+
export { MANIFEST, writeFileIfChanged, type Written, writeTarget } from "./gen/write.ts";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@workerstack/clients`'s module entry (bit 19 h2): what core's build plugin imports, dynamically, to write an
|
|
3
|
+
* app's artifacts (the route tree, the types, each file only when it changed). The SDK, CLI and MCP server generators
|
|
4
|
+
* stay behind the `honey-clients` bin. Bit 21 e: the MCP handler an app mounts is the plugin's `codegen.mcp` output.
|
|
5
|
+
*/
|
|
6
|
+
export { METADATA_FIELDS, } from "./emit/shared/metadata.js";
|
|
7
|
+
export { extractTypes, loadTsMorph } from "./extract/extract.js";
|
|
8
|
+
export { generateMcpHandler } from "./emit/mcp/mounted.js";
|
|
9
|
+
export { generateRouteTree } from "./emit/ts/route-tree.js";
|
|
10
|
+
export { generateTypes } from "./emit/ts/type-gen.js";
|
|
11
|
+
export { generated, writeGenerated, } from "./cli.js";
|
|
12
|
+
export { TARGETS, targetOptionSchemas, } from "./gen/targets.js";
|
|
13
|
+
/* `writeTarget` writes one target's files into a directory the caller picks, keeping `MANIFEST` there: for a caller
|
|
14
|
+
that lays out `generated`'s files itself rather than as `writeGenerated`'s `<out>/<target>` */
|
|
15
|
+
export { MANIFEST, writeFileIfChanged, writeTarget } from "./gen/write.js";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type IR, type IRAuth } from "./model.ts";
|
|
2
|
+
type Json = Record<string, unknown>;
|
|
3
|
+
/** An OpenAPI document as gen reads it: plain JSON. */
|
|
4
|
+
/** A server: its URL template and the defaults of its variables. */
|
|
5
|
+
export type OpenApiServer = {
|
|
6
|
+
readonly url: string;
|
|
7
|
+
readonly variables?: Readonly<Record<string, {
|
|
8
|
+
readonly default?: string;
|
|
9
|
+
}>>;
|
|
10
|
+
};
|
|
11
|
+
export type OpenApiDocument = {
|
|
12
|
+
readonly components?: Readonly<Record<string, Readonly<Record<string, unknown>>>> & {
|
|
13
|
+
readonly schemas?: Readonly<Record<string, Json>>;
|
|
14
|
+
};
|
|
15
|
+
readonly info?: Readonly<Record<string, unknown>>;
|
|
16
|
+
readonly openapi: string;
|
|
17
|
+
readonly paths?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
18
|
+
readonly servers?: readonly OpenApiServer[];
|
|
19
|
+
readonly webhooks?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
20
|
+
};
|
|
21
|
+
export type ToIROptions = {
|
|
22
|
+
/** give an operation without an `operationId` a derived one instead of leaving it out (the non-TS emitters) */
|
|
23
|
+
readonly deriveOperationIds?: boolean;
|
|
24
|
+
/** a shared id: `"suffix"` adds the method (the default when deriving), `"throw"` refuses the document */
|
|
25
|
+
readonly duplicateOperationIds?: "suffix" | "throw";
|
|
26
|
+
};
|
|
27
|
+
/** A stable id for an operation without one: `GET /users/{id}` → `getUsersById`, `GET /` → `getRoot`. */
|
|
28
|
+
export declare function deriveOperationId(method: string, path: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* How a client authenticates, from the first security scheme in code-unit order: http basic is
|
|
31
|
+
* `Basic `, other http `Bearer `, a header apiKey its header with the prefix its description gives
|
|
32
|
+
* (`Format: <prefix> {token}`). Anything else, or no scheme, is `Authorization: Bearer`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function specAuth(doc: OpenApiDocument): IRAuth;
|
|
35
|
+
/** The IR of `doc`; an explicit id always keeps its name, a derived one takes what is left. */
|
|
36
|
+
export declare function toIR(doc: OpenApiDocument, options?: ToIROptions): IR;
|
|
37
|
+
export {};
|
package/dist/ir/build.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The IR from an OpenAPI 3.x document: its component schemas, its operations (each with an id,
|
|
3
|
+
* explicit or derived), the resource tree over them, how a client authenticates, the
|
|
4
|
+
* document's info, and the webhooks it sends. Reads the document alone; gen never reaches into core (H2).
|
|
5
|
+
*/
|
|
6
|
+
import { compareCodeUnits, pascalWords } from "../emit/shared/lang.js";
|
|
7
|
+
import { schemaToIR } from "./schema.js";
|
|
8
|
+
import { buildResourceTree } from "./resource-tree.js";
|
|
9
|
+
import { eventOf, extensionsOf, paramsOf, parseOpenApiPath, requestBodies, responsesOf, } from "./slots.js";
|
|
10
|
+
const METHODS = ["get", "post", "put", "patch", "delete", "head", "options"];
|
|
11
|
+
/** A stable id for an operation without one: `GET /users/{id}` → `getUsersById`, `GET /` → `getRoot`. */
|
|
12
|
+
export function deriveOperationId(method, path) {
|
|
13
|
+
const segments = parseOpenApiPath(path);
|
|
14
|
+
const literal = segments.flatMap((seg) => (seg.kind === "literal" ? [pascalWords(seg.text)] : []));
|
|
15
|
+
const params = segments.flatMap((seg) => (seg.kind === "param" ? [pascalWords(seg.name)] : []));
|
|
16
|
+
const base = `${method.toLowerCase()}${literal.join("")}${params.length > 0 ? `By${params.join("And")}` : ""}`;
|
|
17
|
+
return base === method.toLowerCase() ? `${base}Root` : base;
|
|
18
|
+
}
|
|
19
|
+
/** The first `name`, `name2`, `name3`… nothing in `taken` holds. */
|
|
20
|
+
function free(name, taken) {
|
|
21
|
+
let candidate = name;
|
|
22
|
+
for (let n = 2; taken(candidate); n++)
|
|
23
|
+
candidate = `${name}${n}`;
|
|
24
|
+
return candidate;
|
|
25
|
+
}
|
|
26
|
+
function operationOf(id, op, { components, item, method, path }) {
|
|
27
|
+
const bodies = requestBodies(op, components);
|
|
28
|
+
const { responses, sse } = responsesOf(op, components);
|
|
29
|
+
const operation = {
|
|
30
|
+
extensions: extensionsOf(op, sse),
|
|
31
|
+
id,
|
|
32
|
+
method: method.toUpperCase(),
|
|
33
|
+
params: paramsOf(path, op, item, components),
|
|
34
|
+
path,
|
|
35
|
+
responses,
|
|
36
|
+
};
|
|
37
|
+
if (bodies[0] !== undefined)
|
|
38
|
+
operation.body = bodies[0];
|
|
39
|
+
if (bodies.length > 1)
|
|
40
|
+
operation.bodies = bodies;
|
|
41
|
+
if (typeof op.description === "string")
|
|
42
|
+
operation.description = op.description;
|
|
43
|
+
if (typeof op.summary === "string")
|
|
44
|
+
operation.summary = op.summary;
|
|
45
|
+
return operation;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* How a client authenticates, from the first security scheme in code-unit order: http basic is
|
|
49
|
+
* `Basic `, other http `Bearer `, a header apiKey its header with the prefix its description gives
|
|
50
|
+
* (`Format: <prefix> {token}`). Anything else, or no scheme, is `Authorization: Bearer`.
|
|
51
|
+
*/
|
|
52
|
+
export function specAuth(doc) {
|
|
53
|
+
const schemes = (doc.components?.securitySchemes ?? {});
|
|
54
|
+
const first = Object.keys(schemes).sort(compareCodeUnits)[0];
|
|
55
|
+
const scheme = first === undefined ? undefined : schemes[first];
|
|
56
|
+
if (scheme?.type === "http") {
|
|
57
|
+
return {
|
|
58
|
+
headerName: "Authorization",
|
|
59
|
+
prefix: String(scheme.scheme).toLowerCase() === "basic" ? "Basic " : "Bearer ",
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (scheme?.type === "apiKey" && scheme.in === "header") {
|
|
63
|
+
const prefix = /Format:\s*(\S+)\s+\{/i.exec(String(scheme.description ?? ""));
|
|
64
|
+
return { headerName: String(scheme.name ?? "Authorization"), prefix: prefix === null ? "" : `${prefix[1]} ` };
|
|
65
|
+
}
|
|
66
|
+
return { headerName: "Authorization", prefix: "Bearer " };
|
|
67
|
+
}
|
|
68
|
+
function infoOf(doc) {
|
|
69
|
+
const info = doc.info ?? {};
|
|
70
|
+
return Object.fromEntries(["title", "description", "version"].flatMap((key) => typeof info[key] === "string" ? [[key, info[key]]] : []));
|
|
71
|
+
}
|
|
72
|
+
/** Each webhook by name, in code-unit order: its method, JSON payload, text and Standard Webhooks event. */
|
|
73
|
+
function webhooksOf(doc) {
|
|
74
|
+
const components = (doc.components ?? {});
|
|
75
|
+
return Object.keys(doc.webhooks ?? {})
|
|
76
|
+
.sort(compareCodeUnits)
|
|
77
|
+
.flatMap((name) => {
|
|
78
|
+
const item = doc.webhooks?.[name];
|
|
79
|
+
return METHODS.filter((method) => typeof item[method] === "object" && item[method] !== null).map((method) => {
|
|
80
|
+
const op = item[method];
|
|
81
|
+
const json = requestBodies(op, components).find((b) => b.kind === "raw" && b.contentType === "application/json");
|
|
82
|
+
const webhook = { method: method.toUpperCase(), name };
|
|
83
|
+
const event = eventOf(name, op, components);
|
|
84
|
+
if (json?.kind === "raw")
|
|
85
|
+
webhook.body = json.schema;
|
|
86
|
+
if (event !== undefined)
|
|
87
|
+
webhook.event = event;
|
|
88
|
+
if (typeof op.description === "string")
|
|
89
|
+
webhook.description = op.description;
|
|
90
|
+
if (typeof op.summary === "string")
|
|
91
|
+
webhook.summary = op.summary;
|
|
92
|
+
return webhook;
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/** The operations with an explicit id, a shared one suffixed by method or refused; and those without one. */
|
|
97
|
+
function explicitOperations(doc, options, seen) {
|
|
98
|
+
const components = (doc.components ?? {});
|
|
99
|
+
const onDuplicate = options.duplicateOperationIds ?? (options.deriveOperationIds === true ? "suffix" : "throw");
|
|
100
|
+
const operations = [];
|
|
101
|
+
const unnamed = [];
|
|
102
|
+
for (const [path, item] of Object.entries(doc.paths ?? {})) {
|
|
103
|
+
for (const method of METHODS.filter((m) => item[m] !== undefined)) {
|
|
104
|
+
const op = item[method];
|
|
105
|
+
const id = op.operationId;
|
|
106
|
+
const site = { components, item, method, path };
|
|
107
|
+
if (id === undefined)
|
|
108
|
+
unnamed.push([op, site]);
|
|
109
|
+
else if (seen.has(id) && onDuplicate === "throw")
|
|
110
|
+
throw new Error(`Duplicate operationId: "${id}"`);
|
|
111
|
+
else {
|
|
112
|
+
const final = seen.has(id) ? free(`${id}${pascalWords(method)}`, (c) => seen.has(c)) : id;
|
|
113
|
+
seen.add(final);
|
|
114
|
+
operations.push(operationOf(final, op, site));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return { operations, unnamed };
|
|
119
|
+
}
|
|
120
|
+
/** A server URL with each declared `{variable}` replaced by its default; an undeclared one is left as written. */
|
|
121
|
+
function serverUrl({ url, variables = {} }) {
|
|
122
|
+
return url.replace(/\{([^{}]*)\}/g, (whole, name) => variables[name]?.default ?? whole);
|
|
123
|
+
}
|
|
124
|
+
/** The IR of `doc`; an explicit id always keeps its name, a derived one takes what is left. */
|
|
125
|
+
export function toIR(doc, options = {}) {
|
|
126
|
+
const schemas = {};
|
|
127
|
+
const schemaDescriptions = {};
|
|
128
|
+
for (const [name, schema] of Object.entries(doc.components?.schemas ?? {})) {
|
|
129
|
+
schemas[name] = schemaToIR(schema);
|
|
130
|
+
if (typeof schema.description === "string")
|
|
131
|
+
schemaDescriptions[name] = schema.description;
|
|
132
|
+
}
|
|
133
|
+
const seen = new Set();
|
|
134
|
+
const { operations, unnamed } = explicitOperations(doc, options, seen);
|
|
135
|
+
/* derived ids after explicit ones, clear of explicit ids and of their namespaces */
|
|
136
|
+
const roots = new Set(operations.map(({ id }) => id.split(".")[0]));
|
|
137
|
+
for (const [op, site] of options.deriveOperationIds === true ? unnamed : []) {
|
|
138
|
+
const id = free(deriveOperationId(site.method, site.path), (c) => seen.has(c) || roots.has(c));
|
|
139
|
+
seen.add(id);
|
|
140
|
+
operations.push(operationOf(id, op, site));
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
auth: specAuth(doc),
|
|
144
|
+
info: infoOf(doc),
|
|
145
|
+
operations,
|
|
146
|
+
schemaDescriptions,
|
|
147
|
+
schemas,
|
|
148
|
+
servers: (doc.servers ?? []).map(serverUrl),
|
|
149
|
+
tree: buildResourceTree(operations),
|
|
150
|
+
webhooks: webhooksOf(doc),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Bun's resolver, as the loader uses it: `specifier` resolved from `from` under this process's conditions. */
|
|
2
|
+
export type BunResolver = {
|
|
3
|
+
resolveSync(specifier: string, from: string): string;
|
|
4
|
+
};
|
|
5
|
+
/** `<module>[#export]` as its module path and the export it names, if any. */
|
|
6
|
+
export declare function appRef(ref: string): {
|
|
7
|
+
module: string;
|
|
8
|
+
name: string | undefined;
|
|
9
|
+
};
|
|
10
|
+
/** The OpenAPI document of the app `ref` names, by the app's own core; `cwd` resolves it. One load at a time per process. */
|
|
11
|
+
export declare function loadAppDocument(ref: string, cwd: string): Promise<Record<string, unknown>>;
|