@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,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The generated CLI (bit 17, E1): a pure-Go module building one static binary (`CGO_ENABLED=0`; the end user
|
|
3
|
+
* needs no Go and no Node). It holds `main.go`, the commands under `cmd/`, the vendored CLI runtime
|
|
4
|
+
* (`runtime/cli/*.go`, verbatim under `internal/cli/`), and the API's own Go SDK embedded under `internal/sdk/`, which
|
|
5
|
+
* every command calls through: the CLI projects the SDK, never re-implementing its HTTP. Its dependencies are cobra
|
|
6
|
+
* and pflag (the Go CLI standard, H9) and go-toml (its config file), each pinned with its checksum-database hashes in
|
|
7
|
+
* `go.sum`. The binary name,
|
|
8
|
+
* module path and environment prefix reach Go, goreleaser, the install scripts and variable names, so each is
|
|
9
|
+
* refused at generate unless it matches its own grammar; the document's words reach Go only as escaped literals.
|
|
10
|
+
*/
|
|
11
|
+
import { readFileSync } from "node:fs";
|
|
12
|
+
import { toIR } from "../../ir/build.js";
|
|
13
|
+
import { sdkModel } from "../../ir/sdk-model.js";
|
|
14
|
+
import { compareCodeUnits } from "../shared/lang.js";
|
|
15
|
+
import { packageOn } from "../shared/metadata.js";
|
|
16
|
+
import { goModulePath } from "../go/module-path.js";
|
|
17
|
+
import { generateGoSdk, goCallPlans, WEBSOCKET, WEBSOCKET_SUM } from "../go/sdk.js";
|
|
18
|
+
import { commandTree } from "./commands.js";
|
|
19
|
+
import { discoveryEntries } from "./discovery.js";
|
|
20
|
+
import { installFiles } from "./install.js";
|
|
21
|
+
import { cmdFiles } from "./layout.js";
|
|
22
|
+
import { goreleaserFile, releaseWorkflow, REPO, resolvedRelease } from "./release.js";
|
|
23
|
+
import { skillFile, skillPath } from "./skills.js";
|
|
24
|
+
/* the marker gopls and linters read, apart from the package doc by a blank line */
|
|
25
|
+
const MARKER = "// Code generated by honey. DO NOT EDIT.";
|
|
26
|
+
/** The runtime files a CLI ships, read from `runtime/cli/` and nowhere else; SOCKET only beside the WebSocket library. */
|
|
27
|
+
export const CLI_RUNTIME = [
|
|
28
|
+
"body.go",
|
|
29
|
+
"config.go",
|
|
30
|
+
"discovery.go",
|
|
31
|
+
"format.go",
|
|
32
|
+
"log.go",
|
|
33
|
+
"output.go",
|
|
34
|
+
"params.go",
|
|
35
|
+
"run.go",
|
|
36
|
+
"socket.go",
|
|
37
|
+
"stream.go",
|
|
38
|
+
"target.go",
|
|
39
|
+
];
|
|
40
|
+
/** The runtime file that names the WebSocket library: shipped only when the SDK requires it. */
|
|
41
|
+
const SOCKET = "socket.go";
|
|
42
|
+
/* the CLI's own requirements and their go.sum lines, exactly as `go mod tidy` writes them */
|
|
43
|
+
const DIRECT = [
|
|
44
|
+
"github.com/pelletier/go-toml/v2 v2.4.3",
|
|
45
|
+
"github.com/spf13/cobra v1.10.2",
|
|
46
|
+
"github.com/spf13/pflag v1.0.10",
|
|
47
|
+
];
|
|
48
|
+
const INDIRECT = ["github.com/inconshreveable/mousetrap v1.1.0"];
|
|
49
|
+
const SUM = [
|
|
50
|
+
"github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=",
|
|
51
|
+
"github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=",
|
|
52
|
+
"github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=",
|
|
53
|
+
"github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY=",
|
|
54
|
+
"github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=",
|
|
55
|
+
"github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=",
|
|
56
|
+
"github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=",
|
|
57
|
+
"github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=",
|
|
58
|
+
"github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=",
|
|
59
|
+
"github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=",
|
|
60
|
+
"github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=",
|
|
61
|
+
"go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=",
|
|
62
|
+
"gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=",
|
|
63
|
+
];
|
|
64
|
+
/* a binary: lowercase words joined by `-`, at most 64 characters (its agent skill's name is the binary's); an
|
|
65
|
+
* environment prefix: uppercase words joined by `_` */
|
|
66
|
+
const BINARY_NAME = /^(?=.{1,64}$)[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
67
|
+
const ENV_PREFIX = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
68
|
+
/* a base URL a CLI can call: a scheme and a host, never a path alone */
|
|
69
|
+
const ABSOLUTE_URL = /^https?:\/\/[^\s/]+/;
|
|
70
|
+
const refuse = (option, value) => {
|
|
71
|
+
throw new Error(`Invalid ${option}: ${JSON.stringify(value)}`);
|
|
72
|
+
};
|
|
73
|
+
/** The binary name a title gives: its letters and digits, lowercased, joined by `-`; `api` when it has none. */
|
|
74
|
+
export const binaryNameOf = (title) => (title ?? "")
|
|
75
|
+
.toLowerCase()
|
|
76
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
77
|
+
.replace(/^[^a-z]+|-+$/g, "") || "api";
|
|
78
|
+
/**
|
|
79
|
+
* The base URL the binary calls: the option, else the document's first server when that is absolute. A relative
|
|
80
|
+
* server is no base URL a CLI can call — a gateway's document says `servers: [{ url: "/api" }]` — so it is left
|
|
81
|
+
* out rather than baked in, and the generated client asks for one (`--base-url`, the env or the config) instead of
|
|
82
|
+
* calling a path (bit 22 a).
|
|
83
|
+
*/
|
|
84
|
+
function baseUrlOf(baseUrl, servers) {
|
|
85
|
+
if (baseUrl !== undefined)
|
|
86
|
+
return baseUrl;
|
|
87
|
+
const first = servers[0];
|
|
88
|
+
return first !== undefined && ABSOLUTE_URL.test(first) ? first : undefined;
|
|
89
|
+
}
|
|
90
|
+
/** The options with every default filled, each refused unless it matches its grammar. */
|
|
91
|
+
function resolved(options, title) {
|
|
92
|
+
const binaryName = options.binaryName ?? binaryNameOf(title);
|
|
93
|
+
if (!BINARY_NAME.test(binaryName))
|
|
94
|
+
refuse("binaryName", binaryName);
|
|
95
|
+
const modulePath = goModulePath(options.modulePath ?? `example.com/${binaryName}`, options.version);
|
|
96
|
+
const envPrefix = options.envPrefix ?? binaryName.toUpperCase().replaceAll("-", "_");
|
|
97
|
+
if (!ENV_PREFIX.test(envPrefix))
|
|
98
|
+
refuse("envPrefix", envPrefix);
|
|
99
|
+
if (options.repo !== undefined && !REPO.test(options.repo))
|
|
100
|
+
refuse("repo", options.repo);
|
|
101
|
+
if (options.baseUrl !== undefined && !ABSOLUTE_URL.test(options.baseUrl))
|
|
102
|
+
refuse("baseUrl", options.baseUrl);
|
|
103
|
+
return { baseUrl: options.baseUrl, binaryName, envPrefix, modulePath, repo: options.repo };
|
|
104
|
+
}
|
|
105
|
+
/** A go.sum line's order key: its module path, then its version with each number zero-padded, as Go sorts them. */
|
|
106
|
+
const sumKey = (line) => line.replace(/\d+/g, (digits) => digits.padStart(20, "0"));
|
|
107
|
+
/** A require directive as `go mod tidy` writes it: one requirement on its line, more in a block. */
|
|
108
|
+
const requireOf = (lines) => lines.length === 1 ? `require ${lines[0]}\n` : `require (\n${lines.map((line) => `\t${line}`).join("\n")}\n)\n`;
|
|
109
|
+
/** go.mod and go.sum: the CLI's requirements, and the WebSocket library's when the embedded SDK needs it. */
|
|
110
|
+
function moduleFiles(modulePath, websocket) {
|
|
111
|
+
const direct = requireOf((websocket ? [...DIRECT, WEBSOCKET] : DIRECT).sort(compareCodeUnits));
|
|
112
|
+
const indirect = requireOf(INDIRECT.map((line) => `${line} // indirect`));
|
|
113
|
+
const sum = (websocket ? [...SUM, ...WEBSOCKET_SUM] : SUM).sort((a, b) => compareCodeUnits(sumKey(a), sumKey(b)));
|
|
114
|
+
return {
|
|
115
|
+
"go.mod": `module ${modulePath}\n\ngo 1.24\n\n${direct}\n${indirect}`,
|
|
116
|
+
"go.sum": `${sum.join("\n")}\n`,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** main.go: the root command, its skill embedded, run with the process's arguments; its exit code the process's. */
|
|
120
|
+
const mainFile = (modulePath, binaryName) => `${MARKER}
|
|
121
|
+
|
|
122
|
+
package main
|
|
123
|
+
|
|
124
|
+
import (
|
|
125
|
+
\t_ "embed"
|
|
126
|
+
\t"os"
|
|
127
|
+
|
|
128
|
+
\t"${modulePath}/cmd"
|
|
129
|
+
\t"${modulePath}/internal/cli"
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
// skill is the agent skill the module ships, as \`${binaryName} skill\` prints it.
|
|
133
|
+
//
|
|
134
|
+
//go:embed ${skillPath(binaryName)}
|
|
135
|
+
var skill string
|
|
136
|
+
|
|
137
|
+
func main() {
|
|
138
|
+
\tos.Exit(cli.Run(cmd.Root(skill), os.Args[1:], os.Stdout, os.Stderr))
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
141
|
+
/** The vendored CLI runtime, by its path in the module: SOCKET only when `websocket`. */
|
|
142
|
+
const runtimeFiles = (websocket) => Object.fromEntries(CLI_RUNTIME.filter((name) => websocket || name !== SOCKET).map((name) => [
|
|
143
|
+
`internal/cli/${name}`,
|
|
144
|
+
readFileSync(new URL(`../../runtime/cli/${name}`, import.meta.url), "utf8"),
|
|
145
|
+
]));
|
|
146
|
+
/** The API's Go SDK under `internal/sdk/`, its module files left to the CLI's; whether it needs the WebSocket library. */
|
|
147
|
+
function embeddedSdk(document, modulePath) {
|
|
148
|
+
const { files } = generateGoSdk(document, { modulePath: `${modulePath}/internal/sdk` });
|
|
149
|
+
const embedded = Object.entries(files)
|
|
150
|
+
.filter(([name]) => name !== "go.mod" && name !== "go.sum")
|
|
151
|
+
.map(([name, text]) => [`internal/sdk/${name}`, text]);
|
|
152
|
+
return { files: Object.fromEntries(embedded), websocket: Object.hasOwn(files, "go.sum") };
|
|
153
|
+
}
|
|
154
|
+
/** The CLI module for `document`, by file name. */
|
|
155
|
+
export function generateGoCli(document, options = {}) {
|
|
156
|
+
const ir = toIR(document, { deriveOperationIds: true });
|
|
157
|
+
const { baseUrl, binaryName, envPrefix, modulePath, repo } = resolved(options, ir.info.title);
|
|
158
|
+
const server = baseUrlOf(baseUrl, ir.servers);
|
|
159
|
+
const release = resolvedRelease(options, repo);
|
|
160
|
+
const scripts = release === undefined
|
|
161
|
+
? {}
|
|
162
|
+
: installFiles({
|
|
163
|
+
bin: binaryName,
|
|
164
|
+
installUrl: release.installUrl,
|
|
165
|
+
prefix: envPrefix,
|
|
166
|
+
repo: `${release.owner}/${release.name}`,
|
|
167
|
+
});
|
|
168
|
+
const sdk = embeddedSdk(document, modulePath);
|
|
169
|
+
const model = sdkModel(ir);
|
|
170
|
+
const nodes = commandTree(model.ops, goCallPlans(document));
|
|
171
|
+
const app = { baseUrl: server, binaryName, envPrefix, modulePath, short: ir.info.title ?? binaryName };
|
|
172
|
+
return {
|
|
173
|
+
files: {
|
|
174
|
+
...moduleFiles(modulePath, sdk.websocket),
|
|
175
|
+
"main.go": mainFile(modulePath, binaryName),
|
|
176
|
+
[skillPath(binaryName)]: skillFile(binaryName, app.short, envPrefix, model.ops),
|
|
177
|
+
".goreleaser.yaml": goreleaserFile(binaryName, modulePath, release),
|
|
178
|
+
".github/workflows/release.yml": releaseWorkflow(binaryName, release),
|
|
179
|
+
...scripts,
|
|
180
|
+
...cmdFiles(app, ir, nodes, discoveryEntries(nodes, model)),
|
|
181
|
+
...runtimeFiles(sdk.websocket),
|
|
182
|
+
...sdk.files,
|
|
183
|
+
},
|
|
184
|
+
packages: [packageOn("go", modulePath, options.version)],
|
|
185
|
+
};
|
|
186
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's release (bit 17 phase g): `.goreleaser.yaml` builds six static binaries (linux, darwin, windows × amd64,
|
|
3
|
+
* arm64; CGO off, trimmed paths, stripped, the tag linked in as the version) into archives named without the
|
|
4
|
+
* version, `<bin>_<os>_<arch>` (.tar.gz, .zip for windows), so a release's `latest/download` resolves them, beside
|
|
5
|
+
* `checksums.txt`, which cosign signs keyless (`checksums.txt.sigstore.json`, one bundle vouching for every
|
|
6
|
+
* archive's digest). With a repository, each release also carries `version.txt` (its tag, which the install scripts
|
|
7
|
+
* read through `latest/download`) and, when the scripts are served from the release itself, `install.sh` and
|
|
8
|
+
* `install.ps1`. The channels the options name are added to it: a Homebrew cask, a Scoop manifest, a winget pull
|
|
9
|
+
* request from a fork, an AUR `-bin` package, and deb/rpm/apk packages, each from its own validated options.
|
|
10
|
+
* `.github/workflows/release.yml` runs it on a `v*` tag alone: contents read by default; the release job alone gets
|
|
11
|
+
* contents write and the OIDC token cosign and the build provenance attestation over every archive sign with;
|
|
12
|
+
* checkout keeps no credentials; every action is pinned by commit; each channel's secret reaches goreleaser's step
|
|
13
|
+
* env by name. With a repository, a semver prerelease tag is published as a GitHub prerelease (`prerelease: auto`),
|
|
14
|
+
* which never becomes `latest`, and once the release is attested the workflow proves the install scripts work against
|
|
15
|
+
* it: `installgen check` over the tag's files (installgen.config.mts, written beside the scripts from the same
|
|
16
|
+
* layout), then, for a tag GitHub made latest, that `latest/download/version.txt` reads the tag. Every value is a
|
|
17
|
+
* validated option (the binary, the module path, the repository, the channels), never spec text.
|
|
18
|
+
*/
|
|
19
|
+
import { type Release } from "./channels.ts";
|
|
20
|
+
export { REPO, type Release, type ReleaseOptions, resolvedRelease } from "./channels.ts";
|
|
21
|
+
/** The tools release.yml runs, each pinned by commit (its release in the comment beside it). */
|
|
22
|
+
export declare const RELEASE_ACTIONS: {
|
|
23
|
+
attest: string;
|
|
24
|
+
checkout: string;
|
|
25
|
+
cosign: string;
|
|
26
|
+
goreleaser: string;
|
|
27
|
+
setupGo: string;
|
|
28
|
+
setupNode: string;
|
|
29
|
+
};
|
|
30
|
+
/** A value as a YAML double-quoted scalar (a JSON string is one): a name like `true` or `1e3` stays a string. */
|
|
31
|
+
export declare const q: (value: string) => string;
|
|
32
|
+
/** The goreleaser release the action installs: the one the tests check the config with. */
|
|
33
|
+
export declare const GORELEASER_VERSION = "v2.18.3";
|
|
34
|
+
/** .goreleaser.yaml for the CLI `bin` in module `modulePath`, released per `release` when it names a repository. */
|
|
35
|
+
export declare function goreleaserFile(bin: string, modulePath: string, release: Release | undefined): string;
|
|
36
|
+
/**
|
|
37
|
+
* .github/workflows/release.yml: goreleaser on a `v*` tag, publishing the signed release, then attesting it, then,
|
|
38
|
+
* with a repository, checking the install scripts' files against it.
|
|
39
|
+
*/
|
|
40
|
+
export declare function releaseWorkflow(bin: string, release: Release | undefined): string;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's release (bit 17 phase g): `.goreleaser.yaml` builds six static binaries (linux, darwin, windows × amd64,
|
|
3
|
+
* arm64; CGO off, trimmed paths, stripped, the tag linked in as the version) into archives named without the
|
|
4
|
+
* version, `<bin>_<os>_<arch>` (.tar.gz, .zip for windows), so a release's `latest/download` resolves them, beside
|
|
5
|
+
* `checksums.txt`, which cosign signs keyless (`checksums.txt.sigstore.json`, one bundle vouching for every
|
|
6
|
+
* archive's digest). With a repository, each release also carries `version.txt` (its tag, which the install scripts
|
|
7
|
+
* read through `latest/download`) and, when the scripts are served from the release itself, `install.sh` and
|
|
8
|
+
* `install.ps1`. The channels the options name are added to it: a Homebrew cask, a Scoop manifest, a winget pull
|
|
9
|
+
* request from a fork, an AUR `-bin` package, and deb/rpm/apk packages, each from its own validated options.
|
|
10
|
+
* `.github/workflows/release.yml` runs it on a `v*` tag alone: contents read by default; the release job alone gets
|
|
11
|
+
* contents write and the OIDC token cosign and the build provenance attestation over every archive sign with;
|
|
12
|
+
* checkout keeps no credentials; every action is pinned by commit; each channel's secret reaches goreleaser's step
|
|
13
|
+
* env by name. With a repository, a semver prerelease tag is published as a GitHub prerelease (`prerelease: auto`),
|
|
14
|
+
* which never becomes `latest`, and once the release is attested the workflow proves the install scripts work against
|
|
15
|
+
* it: `installgen check` over the tag's files (installgen.config.mts, written beside the scripts from the same
|
|
16
|
+
* layout), then, for a tag GitHub made latest, that `latest/download/version.txt` reads the tag. Every value is a
|
|
17
|
+
* validated option (the binary, the module path, the repository, the channels), never spec text.
|
|
18
|
+
*/
|
|
19
|
+
import { channelBlock, SECRETS } from "./channels.js";
|
|
20
|
+
import { INSTALLGEN_VERSION } from "./install.js";
|
|
21
|
+
export { REPO, resolvedRelease } from "./channels.js";
|
|
22
|
+
/* the marker generated YAML carries on its first line */
|
|
23
|
+
const MARKER = "# Code generated by honey. DO NOT EDIT.";
|
|
24
|
+
/** The tools release.yml runs, each pinned by commit (its release in the comment beside it). */
|
|
25
|
+
export const RELEASE_ACTIONS = {
|
|
26
|
+
attest: "actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2",
|
|
27
|
+
checkout: "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1",
|
|
28
|
+
cosign: "sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2",
|
|
29
|
+
goreleaser: "goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3",
|
|
30
|
+
setupGo: "actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0",
|
|
31
|
+
setupNode: "actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0",
|
|
32
|
+
};
|
|
33
|
+
/** A value as a YAML double-quoted scalar (a JSON string is one): a name like `true` or `1e3` stays a string. */
|
|
34
|
+
export const q = (value) => JSON.stringify(value);
|
|
35
|
+
/** The goreleaser release the action installs: the one the tests check the config with. */
|
|
36
|
+
export const GORELEASER_VERSION = "v2.18.3";
|
|
37
|
+
/** .goreleaser.yaml for the CLI `bin` in module `modulePath`, released per `release` when it names a repository. */
|
|
38
|
+
export function goreleaserFile(bin, modulePath, release) {
|
|
39
|
+
/* without a repository, goreleaser releases to the git remote's, and there is no version file to serve */
|
|
40
|
+
const before = release === undefined
|
|
41
|
+
? ""
|
|
42
|
+
: `# the release's tag, which the install scripts read through releases/latest/download
|
|
43
|
+
before:
|
|
44
|
+
hooks:
|
|
45
|
+
- sh -c 'printf "%s\\n" "{{ .Tag }}" > version.txt'
|
|
46
|
+
`;
|
|
47
|
+
const extra = release === undefined ? [] : ["version.txt", ...(release.scriptsInRelease ? ["install.sh", "install.ps1"] : [])];
|
|
48
|
+
const github = release === undefined
|
|
49
|
+
? ""
|
|
50
|
+
: `release:
|
|
51
|
+
github:
|
|
52
|
+
owner: ${q(release.owner)}
|
|
53
|
+
name: ${q(release.name)}
|
|
54
|
+
# a semver prerelease tag (v1.2.0-rc.1) is a GitHub prerelease, which never moves latest: the install scripts' default
|
|
55
|
+
prerelease: auto
|
|
56
|
+
extra_files:
|
|
57
|
+
${extra.map((file) => ` - glob: ./${file}\n`).join("")}`;
|
|
58
|
+
return `${MARKER}
|
|
59
|
+
# ${bin}'s release: six static binaries, each archive named ${bin}_<os>_<arch>, and checksums.txt signed by cosign
|
|
60
|
+
# (release.yml).
|
|
61
|
+
version: 2
|
|
62
|
+
project_name: ${q(bin)}
|
|
63
|
+
${before}builds:
|
|
64
|
+
- id: ${q(bin)}
|
|
65
|
+
main: .
|
|
66
|
+
binary: ${q(bin)}
|
|
67
|
+
env:
|
|
68
|
+
- CGO_ENABLED=0
|
|
69
|
+
flags:
|
|
70
|
+
- -trimpath
|
|
71
|
+
ldflags:
|
|
72
|
+
- ${q(`-s -w -X ${modulePath}/internal/cli.Version={{ .Tag }}`)}
|
|
73
|
+
goos: [linux, darwin, windows]
|
|
74
|
+
goarch: [amd64, arm64]
|
|
75
|
+
archives:
|
|
76
|
+
- id: ${q(bin)}
|
|
77
|
+
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
|
|
78
|
+
formats: [tar.gz]
|
|
79
|
+
format_overrides:
|
|
80
|
+
- goos: windows
|
|
81
|
+
formats: [zip]
|
|
82
|
+
checksum:
|
|
83
|
+
name_template: checksums.txt
|
|
84
|
+
algorithm: sha256
|
|
85
|
+
# checksums.txt signed keyless by cosign as the release workflow, one bundle vouching for every archive's digest
|
|
86
|
+
signs:
|
|
87
|
+
- cmd: cosign
|
|
88
|
+
signature: "\${artifact}.sigstore.json"
|
|
89
|
+
args: [sign-blob, "--bundle=\${signature}", "\${artifact}", --yes]
|
|
90
|
+
artifacts: checksum
|
|
91
|
+
changelog:
|
|
92
|
+
disable: true
|
|
93
|
+
${github}${(release?.channels ?? []).map((channel) => channelBlock(bin, channel)).join("")}`;
|
|
94
|
+
}
|
|
95
|
+
/** The `npx` that runs the installgen the scripts were written by, on installgen.config.mts in the module's root. */
|
|
96
|
+
const INSTALLGEN = `npx --yes @lovrozagar/installgen@${INSTALLGEN_VERSION}`;
|
|
97
|
+
/**
|
|
98
|
+
* The steps that prove the install scripts work against the release just published, which a release with a repository
|
|
99
|
+
* runs after its attestation. The scripts install `<PREFIX>_VERSION` when it is set and otherwise the tag
|
|
100
|
+
* `latest/download/version.txt` reads, so a release must serve both paths:
|
|
101
|
+
* - every platform's archive under this tag, and its line in checksums.txt: `installgen check --default-version
|
|
102
|
+
* <tag>`. The tag, not latest, is what this run published; checking latest instead would pass a prerelease on the
|
|
103
|
+
* previous release's files and never look at this one's.
|
|
104
|
+
* - latest reads this tag, unless the tag is a prerelease. goreleaser publishes a semver prerelease as a GitHub
|
|
105
|
+
* prerelease (`prerelease: auto`), which never becomes latest; every other release is published with GitHub's
|
|
106
|
+
* `make_latest` default, true, so it is latest the moment it exists. Whether it is a prerelease is read back from
|
|
107
|
+
* the release goreleaser made, not re-derived from the tag, and latest's URL from `check --list`, the one the
|
|
108
|
+
* scripts read.
|
|
109
|
+
*/
|
|
110
|
+
const installerChecks = ` - uses: ${RELEASE_ACTIONS.setupNode}
|
|
111
|
+
with:
|
|
112
|
+
node-version: "24"
|
|
113
|
+
package-manager-cache: false
|
|
114
|
+
- name: Check every file the install scripts fetch for this tag
|
|
115
|
+
run: ${INSTALLGEN} check --default-version "$GITHUB_REF_NAME"
|
|
116
|
+
- name: Check latest reads this tag
|
|
117
|
+
shell: bash
|
|
118
|
+
env:
|
|
119
|
+
GH_TOKEN: \${{ github.token }}
|
|
120
|
+
run: |
|
|
121
|
+
prerelease="$(gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --json isPrerelease --jq .isPrerelease)"
|
|
122
|
+
if [ "$prerelease" = true ]; then
|
|
123
|
+
echo "$GITHUB_REF_NAME is a prerelease: latest stays on the last release"
|
|
124
|
+
exit 0
|
|
125
|
+
fi
|
|
126
|
+
url="$(${INSTALLGEN} check --list | awk '$1 == "latest" { print $2 }')"
|
|
127
|
+
latest="$(curl -fsSL --retry 3 "$url" | tr -d '[:space:]')"
|
|
128
|
+
if [ "$latest" != "$GITHUB_REF_NAME" ]; then
|
|
129
|
+
echo "::error::$url reads '$latest', not $GITHUB_REF_NAME"
|
|
130
|
+
exit 1
|
|
131
|
+
fi
|
|
132
|
+
`;
|
|
133
|
+
/**
|
|
134
|
+
* .github/workflows/release.yml: goreleaser on a `v*` tag, publishing the signed release, then attesting it, then,
|
|
135
|
+
* with a repository, checking the install scripts' files against it.
|
|
136
|
+
*/
|
|
137
|
+
export function releaseWorkflow(bin, release) {
|
|
138
|
+
const secrets = (release?.channels ?? []).flatMap((channel) => {
|
|
139
|
+
const secret = SECRETS[channel.kind];
|
|
140
|
+
return secret === undefined ? [] : [` ${secret}: \${{ secrets.${secret} }}\n`];
|
|
141
|
+
});
|
|
142
|
+
return `${MARKER}
|
|
143
|
+
# Releases ${bin} on a v* tag: goreleaser builds the six binaries and publishes them beside checksums.txt, which cosign
|
|
144
|
+
# signs keyless as this workflow; every archive gets a build provenance attestation.${release === undefined
|
|
145
|
+
? ""
|
|
146
|
+
: `
|
|
147
|
+
# installgen check then proves the install scripts' files are published, and that latest reads a non-prerelease tag.`}
|
|
148
|
+
name: release
|
|
149
|
+
on:
|
|
150
|
+
push:
|
|
151
|
+
tags:
|
|
152
|
+
- "v*"
|
|
153
|
+
permissions:
|
|
154
|
+
contents: read
|
|
155
|
+
jobs:
|
|
156
|
+
release:
|
|
157
|
+
runs-on: ubuntu-latest
|
|
158
|
+
permissions:
|
|
159
|
+
contents: write
|
|
160
|
+
id-token: write
|
|
161
|
+
attestations: write
|
|
162
|
+
steps:
|
|
163
|
+
- uses: ${RELEASE_ACTIONS.checkout}
|
|
164
|
+
with:
|
|
165
|
+
fetch-depth: 0
|
|
166
|
+
persist-credentials: false
|
|
167
|
+
- uses: ${RELEASE_ACTIONS.setupGo}
|
|
168
|
+
with:
|
|
169
|
+
go-version-file: go.mod
|
|
170
|
+
cache: false
|
|
171
|
+
- uses: ${RELEASE_ACTIONS.cosign}
|
|
172
|
+
- uses: ${RELEASE_ACTIONS.goreleaser}
|
|
173
|
+
with:
|
|
174
|
+
distribution: goreleaser
|
|
175
|
+
version: ${GORELEASER_VERSION}
|
|
176
|
+
args: release --clean
|
|
177
|
+
env:
|
|
178
|
+
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
|
|
179
|
+
${secrets.join("")} - uses: ${RELEASE_ACTIONS.attest}
|
|
180
|
+
with:
|
|
181
|
+
subject-checksums: dist/checksums.txt
|
|
182
|
+
${release === undefined ? "" : installerChecks}`;
|
|
183
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The agent skill (bit 17 phase e, E1): `skills/<bin>/SKILL.md` in the Agent Skills format, its frontmatter's name
|
|
3
|
+
* the binary's and its description one line. The body is what an agent needs to drive the CLI and nothing past it:
|
|
4
|
+
* discovery, the settings and their target, calling, output, streams when the API has any, errors and exit codes.
|
|
5
|
+
* The module ships the file, and main.go embeds it, so `<bin> skill` prints the same bytes.
|
|
6
|
+
*/
|
|
7
|
+
import type { SdkOp } from "../../ir/sdk-model.ts";
|
|
8
|
+
/** Where the skill lives in the module. */
|
|
9
|
+
export declare const skillPath: (binaryName: string) => string;
|
|
10
|
+
/** SKILL.md for the CLI `bin` over the API `title` and its operations, its env variables prefixed `prefix`. */
|
|
11
|
+
export declare function skillFile(bin: string, title: string, prefix: string, ops: readonly SdkOp[]): string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { helpText } from "./flags.js";
|
|
2
|
+
/** The longest API title the description carries, in characters, `…` included. */
|
|
3
|
+
const TITLE_MAX = 200;
|
|
4
|
+
/** Where the skill lives in the module. */
|
|
5
|
+
export const skillPath = (binaryName) => `skills/${binaryName}/SKILL.md`;
|
|
6
|
+
/** The streams an API's commands use, in a fixed order. */
|
|
7
|
+
const streamsOf = (ops) => ["sse", "ws", "realtime"].filter((kind) => ops.some((op) => op.stream === kind));
|
|
8
|
+
/** SKILL.md for the CLI `bin` over the API `title` and its operations, its env variables prefixed `prefix`. */
|
|
9
|
+
export function skillFile(bin, title, prefix, ops) {
|
|
10
|
+
const named = [...(helpText(title).replace(/\s+/g, " ").trim() || bin)];
|
|
11
|
+
/* the description stays within the format's 1024 characters whatever the title */
|
|
12
|
+
const api = named.length <= TITLE_MAX ? named.join("") : `${named.slice(0, TITLE_MAX - 1).join("")}…`;
|
|
13
|
+
const description = `Call the ${api} API from the shell with ${bin}: find a command, read its request and answer, call it, and branch on its JSON output and exit code.`;
|
|
14
|
+
const streams = streamsOf(ops);
|
|
15
|
+
const streaming = streams.length === 0
|
|
16
|
+
? []
|
|
17
|
+
: [
|
|
18
|
+
"",
|
|
19
|
+
"## Streams",
|
|
20
|
+
`A stream command (${streams.join(", ")}) prints one JSON line per event; \`--take N\` ends it after N.`,
|
|
21
|
+
...(streams.includes("ws") ? ["A ws command sends each stdin line as a text frame."] : []),
|
|
22
|
+
...(streams.includes("realtime")
|
|
23
|
+
? [
|
|
24
|
+
"A realtime feed writes its resume cursor to stderr when it ends; pass it back with `--reconnect-token` and `--last-event-id`.",
|
|
25
|
+
]
|
|
26
|
+
: []),
|
|
27
|
+
];
|
|
28
|
+
return [
|
|
29
|
+
"---",
|
|
30
|
+
`name: ${bin}`,
|
|
31
|
+
/* a JSON string is a YAML double-quoted scalar: a colon or quote in the title cannot end it */
|
|
32
|
+
`description: ${JSON.stringify(description)}`,
|
|
33
|
+
"---",
|
|
34
|
+
"",
|
|
35
|
+
`# ${bin}`,
|
|
36
|
+
"",
|
|
37
|
+
"## Find a command",
|
|
38
|
+
`- \`${bin} commands\` lists every command, one usage line each: \`<path> <arg> --flag kind [--optional a|b] [--data json] (stream) # summary\`.`,
|
|
39
|
+
`- \`${bin} commands search <words>\` prints the 5 best matches.`,
|
|
40
|
+
`- \`${bin} schema <command>\` prints its method and path, its \`--data\` body, its answer (\`returns\`) or \`events\`, and its error statuses with their keys.`,
|
|
41
|
+
"",
|
|
42
|
+
"## Before a call",
|
|
43
|
+
`Run \`${bin} config\` before a call that changes data: it prints each setting with its source and \`target local|remote <host>\`.`,
|
|
44
|
+
`Settings come from a flag, else \`$${prefix}_<NAME>\`, else \`~/.config/${bin}/config.toml\`: \`--base-url\`, \`--api-key\`, \`--timeout\`, \`--header "Name: value"\`.`,
|
|
45
|
+
"",
|
|
46
|
+
"## Call",
|
|
47
|
+
"- `<arg>` is positional; `--data` takes JSON, `@file`, or `-` for stdin.",
|
|
48
|
+
"- Piped output is one line of compact JSON; `--format yaml|table|ndjson`, `-o <file>`, `-i` adds the status and headers.",
|
|
49
|
+
'- An error is one JSON line on stderr: `{"error":{"kind","status","errorKey","message"}}`.',
|
|
50
|
+
...streaming,
|
|
51
|
+
"",
|
|
52
|
+
"## Exit codes",
|
|
53
|
+
"0 ok, 1 a 4xx or other failure, 2 a 5xx, 3 no answer (transport, timeout, a dropped stream), 4 a usage error, 5 a redirect not followed, 130 interrupted.",
|
|
54
|
+
"",
|
|
55
|
+
].join("\n");
|
|
56
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SdkModel } from "../../ir/sdk-model.ts";
|
|
2
|
+
import { type CsTypeContext } from "./types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* `ErrorKey` for `model`: its summary, a remark naming each key's body type, then a constant per key in code-unit
|
|
5
|
+
* order (a colliding name gets `…2`); each `<Key>Data` hoisted into `at.decls`. `null` when no key is declared.
|
|
6
|
+
*/
|
|
7
|
+
export declare function csharpErrorKeys(model: SdkModel, at: CsTypeContext): string | null;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { irErrorEnvelope, isJsonMedia } from "../../ir/sdk-model.js";
|
|
2
|
+
import { csString } from "../shared/escape.js";
|
|
3
|
+
import { compareCodeUnits, csTypeName, NameScope } from "../shared/lang.js";
|
|
4
|
+
import { docLines } from "./sdk-doc.js";
|
|
5
|
+
import { csTopLevel, declares } from "./types.js";
|
|
6
|
+
/* the class's own name (CS0542) and the members a static class would hide (CS0108 under warnings as errors) */
|
|
7
|
+
const RESERVED = ["ErrorKey", "Equals", "GetHashCode", "GetType", "MemberwiseClone", "ReferenceEquals", "ToString"];
|
|
8
|
+
/** The keys an error response's envelope names, over every operation's JSON error statuses. */
|
|
9
|
+
function envelopeKeys(model) {
|
|
10
|
+
return model.ops.flatMap((op) => op.errorStatuses.flatMap((status) => {
|
|
11
|
+
/* an error status is a declared response, and a schema comes with the content type it is under */
|
|
12
|
+
const { contentType, schema } = op.ir.responses[String(status)];
|
|
13
|
+
if (schema === undefined || !isJsonMedia(contentType))
|
|
14
|
+
return [];
|
|
15
|
+
return irErrorEnvelope(schema, model.resolve)?.keys ?? [];
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Every declared key in code-unit order with its schema: `x-honey-errors`' (the first operation by id to declare
|
|
20
|
+
* the key, so the document's path order never changes it), over an envelope's keys, which carry none.
|
|
21
|
+
*/
|
|
22
|
+
function declaredKeys(model) {
|
|
23
|
+
const byId = [...model.ops].sort((a, b) => compareCodeUnits(a.id, b.id));
|
|
24
|
+
const declared = byId.flatMap((op) => Object.entries(op.ir.extensions.errors ?? {}));
|
|
25
|
+
const keys = new Map([
|
|
26
|
+
...envelopeKeys(model).map((key) => [key, undefined]),
|
|
27
|
+
...declared.toReversed().map(([key, { schema }]) => [key, schema]),
|
|
28
|
+
]);
|
|
29
|
+
return [...keys].sort(([a], [b]) => compareCodeUnits(a, b));
|
|
30
|
+
}
|
|
31
|
+
/** What a body carrying `key` decodes into: a declared component, a new `<Key>Data`, or nothing to name. */
|
|
32
|
+
function bodyType(key, schema, model, at) {
|
|
33
|
+
if (schema === undefined)
|
|
34
|
+
return undefined;
|
|
35
|
+
if (schema.kind === "ref")
|
|
36
|
+
return at.names.alias(schema.name) === undefined ? at.names.ref(schema.name) : undefined;
|
|
37
|
+
if (!declares(schema) || irErrorEnvelope(schema, model.resolve) !== null)
|
|
38
|
+
return undefined;
|
|
39
|
+
const name = at.names.claim(`${csTypeName(key)}Data`);
|
|
40
|
+
/* claimed before its body: what the body hoists in turn comes after it */
|
|
41
|
+
at.decls.set(name, "");
|
|
42
|
+
at.decls.set(name, csTopLevel(name, schema, at));
|
|
43
|
+
return name;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* `ErrorKey` for `model`: its summary, a remark naming each key's body type, then a constant per key in code-unit
|
|
47
|
+
* order (a colliding name gets `…2`); each `<Key>Data` hoisted into `at.decls`. `null` when no key is declared.
|
|
48
|
+
*/
|
|
49
|
+
export function csharpErrorKeys(model, at) {
|
|
50
|
+
const declared = declaredKeys(model);
|
|
51
|
+
if (declared.length === 0)
|
|
52
|
+
return null;
|
|
53
|
+
const members = new NameScope(RESERVED);
|
|
54
|
+
const keys = declared.map(([wire, schema]) => ({
|
|
55
|
+
data: bodyType(wire, schema, model, at),
|
|
56
|
+
member: members.claim(csTypeName(wire)),
|
|
57
|
+
wire,
|
|
58
|
+
}));
|
|
59
|
+
const decoded = keys.flatMap(({ data, wire }) => (data === undefined ? [] : [`${wire}: its body decodes as ${data}`]));
|
|
60
|
+
const remark = decoded.map((line, i) => `${line}${i === 0 ? " (ApiStatusException.DecodeBody)" : ""}.`).join(" ");
|
|
61
|
+
return [
|
|
62
|
+
"/// <summary>The error keys the API declares: ApiStatusException.Key is one of these, else the server's own string.</summary>",
|
|
63
|
+
...docLines("remarks", remark),
|
|
64
|
+
"public static class ErrorKey",
|
|
65
|
+
"{",
|
|
66
|
+
...keys.map(({ member, wire }) => ` public const string ${member} = ${csString(wire)};`),
|
|
67
|
+
"}",
|
|
68
|
+
].join("\n");
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { csharpCallPlans, type CSharpSdkOptions, generateCSharpSdk, type GeneratedCSharpSdk } from "./sdk.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { csharpCallPlans, generateCSharpSdk } from "./sdk.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Reads C# type text as the runtime sees it, given which names are value types. */
|
|
2
|
+
export type Runtime = (type: string) => string;
|
|
3
|
+
/** The runtime type of a C# type: each nullable reference's `?` dropped at every depth, a nullable value type's kept. */
|
|
4
|
+
export declare function runtimeOf(enums: Iterable<string>): Runtime;
|
|
5
|
+
/** Each runtime type's `TypeInfoPropertyName`: the declared types first, then the rest by name, each unique. */
|
|
6
|
+
export declare function typeInfoNames(declared: readonly string[], others: readonly string[], context: string): Map<string, string>;
|
|
7
|
+
/**
|
|
8
|
+
* The strict converters for `collections` (each as written, item nullability kept): `NonNullList<T>` or
|
|
9
|
+
* `NonNullMap<T>` per runtime collection type of a reference item no use gives `?`, in code-unit order of the text.
|
|
10
|
+
*/
|
|
11
|
+
export declare function strictConverters(collections: Iterable<string>, runtime: Runtime): string[];
|
|
12
|
+
/** The context class `context`: its options, its converters, then one entry per runtime type, sorted by name. */
|
|
13
|
+
export declare function jsonContext(context: string, names: ReadonlyMap<string, string>, converters: readonly string[]): string;
|