@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,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Naming shared by every emitter and the IR: words out of any identifier-ish text, joined per
|
|
3
|
+
* language convention, and the one locale-free string order.
|
|
4
|
+
*/
|
|
5
|
+
/** Order by UTF-16 code unit, never by locale: the same on every machine. */
|
|
6
|
+
export function compareCodeUnits(a, b) {
|
|
7
|
+
if (a === b)
|
|
8
|
+
return 0;
|
|
9
|
+
return a < b ? -1 : 1;
|
|
10
|
+
}
|
|
11
|
+
/** The ASCII alphanumeric words of `raw`: `user-id`, `user_id` and `userId` are all [user, id]. */
|
|
12
|
+
export function words(raw) {
|
|
13
|
+
return raw
|
|
14
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
15
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2")
|
|
16
|
+
.split(/[^A-Za-z0-9]+/)
|
|
17
|
+
.filter((word) => word.length > 0);
|
|
18
|
+
}
|
|
19
|
+
/** The words joined PascalCase, each keeping its inner case: `user-id` → `UserId`, `getHTTP` → `GetHTTP`. */
|
|
20
|
+
export function pascalWords(raw) {
|
|
21
|
+
return words(raw)
|
|
22
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
23
|
+
.join("");
|
|
24
|
+
}
|
|
25
|
+
/** The words joined snake_case, lower case: `userId` → `user_id`. */
|
|
26
|
+
export function snakeWords(raw) {
|
|
27
|
+
return words(raw)
|
|
28
|
+
.map((word) => word.toLowerCase())
|
|
29
|
+
.join("_");
|
|
30
|
+
}
|
|
31
|
+
/** The words joined camelCase: `user-id` → `userId`. */
|
|
32
|
+
export function camelWords(raw) {
|
|
33
|
+
const pascal = pascalWords(raw);
|
|
34
|
+
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
35
|
+
}
|
|
36
|
+
/** A record's entries in code-unit order by key: the same on every machine. */
|
|
37
|
+
export function sortedEntries(record) {
|
|
38
|
+
return Object.entries(record).sort(([a], [b]) => compareCodeUnits(a, b));
|
|
39
|
+
}
|
|
40
|
+
/** Hands out unique names in one scope; a taken name gets the next numeric suffix, in claim order. */
|
|
41
|
+
export class NameScope {
|
|
42
|
+
#taken = new Set();
|
|
43
|
+
#fold;
|
|
44
|
+
/** `fold` maps names that would clash in the target (a case-insensitive file system, say) to one key. */
|
|
45
|
+
constructor(reserved = [], fold = (name) => name) {
|
|
46
|
+
this.#fold = fold;
|
|
47
|
+
for (const name of reserved)
|
|
48
|
+
this.#taken.add(fold(name));
|
|
49
|
+
}
|
|
50
|
+
has(name) {
|
|
51
|
+
return this.#taken.has(this.#fold(name));
|
|
52
|
+
}
|
|
53
|
+
reserve(name) {
|
|
54
|
+
this.#taken.add(this.#fold(name));
|
|
55
|
+
}
|
|
56
|
+
/** `base`, else `base2`, `base3`… whichever is free first; it is taken from then on. */
|
|
57
|
+
claim(base) {
|
|
58
|
+
let name = base;
|
|
59
|
+
for (let n = 2; this.has(name); n++)
|
|
60
|
+
name = `${base}${n}`;
|
|
61
|
+
this.reserve(name);
|
|
62
|
+
return name;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** A `NameScope` that remembers: one raw key always gets the name it was first given. */
|
|
66
|
+
export class NameTable {
|
|
67
|
+
#scope;
|
|
68
|
+
#byKey = new Map();
|
|
69
|
+
constructor(reserved = [], fold) {
|
|
70
|
+
this.#scope = new NameScope(reserved, fold);
|
|
71
|
+
}
|
|
72
|
+
get(key, base) {
|
|
73
|
+
const named = this.#byKey.get(key) ?? this.#scope.claim(base);
|
|
74
|
+
this.#byKey.set(key, named);
|
|
75
|
+
return named;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** Whether `word` is one of the space-separated `list`. */
|
|
79
|
+
const listed = (list, word) => ` ${list} `.includes(` ${word} `);
|
|
80
|
+
const GO_RESERVED =
|
|
81
|
+
/* keywords */
|
|
82
|
+
"break case chan const continue default defer else fallthrough for func go goto if import interface map package range return select struct switch type var " +
|
|
83
|
+
/* predeclared identifiers */
|
|
84
|
+
"any append bool byte cap clear close comparable complex complex128 complex64 copy delete error false float32 float64 imag int int16 int32 int64 int8 iota len make max min new nil panic print println real recover rune string true uint uint16 uint32 uint64 uint8 uintptr " +
|
|
85
|
+
/* the packages generated Go imports */
|
|
86
|
+
"bytes context errors fmt http io iter json multipart os slices strconv strings sync textproto time url websocket cobra cli sdk";
|
|
87
|
+
const RUST_KEYWORDS = "as break const continue crate else enum extern false fn for if impl in let loop match mod move mut pub ref return self Self static struct super trait true type unsafe use where while async await dyn abstract become box do final macro override priv typeof unsized virtual yield try gen";
|
|
88
|
+
/* keywords that cannot be raw identifiers: `r#self` is invalid */
|
|
89
|
+
const RUST_NON_RAW = "crate self Self super extern _";
|
|
90
|
+
const RUST_PRELUDE = "Box Clone Copy Default Drop Eq Err Fn From HashMap Into Iterator None Ok Option Ord PartialEq PartialOrd Result Send Sized Some String Sync ToOwned ToString Vec Deserialize Serialize Deserialize_repr Serialize_repr Stream Arc";
|
|
91
|
+
const PY_RESERVED = "False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield " +
|
|
92
|
+
/* soft keywords and names generated code relies on */
|
|
93
|
+
"match case type _ self cls";
|
|
94
|
+
/* C#'s 77 reserved keywords (contract 45 §4.1): no identifier may be one unless `@`-escaped */
|
|
95
|
+
const CS_RESERVED = "abstract as base bool break byte case catch char checked class const continue decimal default delegate do double else enum event explicit extern false finally fixed float for foreach goto if implicit in int interface internal is lock long namespace new null object operator out override params private protected public readonly ref return sbyte sealed short sizeof stackalloc static string struct switch this throw true try typeof uint ulong unchecked unsafe ushort using virtual void volatile while";
|
|
96
|
+
/* C#'s contextual keywords: legal identifiers, `@`-escaped all the same so none reads as a keyword where it is one */
|
|
97
|
+
const CS_CONTEXTUAL = "add allows and args async await by descending dynamic equals extension field file from get global group init into join let managed nameof nint not notnull nuint on or orderby partial record remove required scoped select set unmanaged value var when where with yield";
|
|
98
|
+
/** `name` unless empty (then `empty`), prefixed by `digitPrefix` when it starts with a digit. */
|
|
99
|
+
function guarded(name, empty, digitPrefix) {
|
|
100
|
+
if (name === "")
|
|
101
|
+
return empty;
|
|
102
|
+
return /^[0-9]/.test(name) ? `${digitPrefix}${name}` : name;
|
|
103
|
+
}
|
|
104
|
+
/** An exported Go identifier: `user-id` → `UserId`, `2fa` → `N2fa`, nothing → `X`. */
|
|
105
|
+
export function goExported(raw) {
|
|
106
|
+
return guarded(pascalWords(raw), "X", "N");
|
|
107
|
+
}
|
|
108
|
+
/** An unexported Go identifier (a local, a parameter); a keyword, predeclared or imported name gets `_`. */
|
|
109
|
+
export function goLocal(raw) {
|
|
110
|
+
const name = guarded(camelWords(raw), "v", "n");
|
|
111
|
+
return listed(GO_RESERVED, name) ? `${name}_` : name;
|
|
112
|
+
}
|
|
113
|
+
/** A snake_case Rust value identifier: a keyword becomes a raw identifier, or gets `_` where it cannot be one. */
|
|
114
|
+
export function rustValueIdent(raw) {
|
|
115
|
+
const name = guarded(snakeWords(raw), "value", "_");
|
|
116
|
+
if (!listed(RUST_KEYWORDS, name))
|
|
117
|
+
return name;
|
|
118
|
+
return listed(RUST_NON_RAW, name) ? `${name}_` : `r#${name}`;
|
|
119
|
+
}
|
|
120
|
+
/** Like `rustValueIdent`, never a raw identifier: for names joined into other names. */
|
|
121
|
+
export function rustPlainSnake(raw) {
|
|
122
|
+
const name = guarded(snakeWords(raw), "value", "_");
|
|
123
|
+
return listed(RUST_KEYWORDS, name) ? `${name}_` : name;
|
|
124
|
+
}
|
|
125
|
+
/** A PascalCase Rust type or variant identifier. */
|
|
126
|
+
export function rustTypeIdent(raw) {
|
|
127
|
+
const name = guarded(pascalWords(raw), "Value", "N");
|
|
128
|
+
return name === "Self" ? "Self_" : name;
|
|
129
|
+
}
|
|
130
|
+
/** Whether a generated Rust type named `name` would shadow a prelude or std name. */
|
|
131
|
+
export function isRustPreludeType(name) {
|
|
132
|
+
return listed(RUST_PRELUDE, name);
|
|
133
|
+
}
|
|
134
|
+
/** A snake_case Python identifier; a keyword or reserved name gets `_` (PEP 8). */
|
|
135
|
+
export function pyIdentifier(raw) {
|
|
136
|
+
const name = guarded(snakeWords(raw), "value", "_");
|
|
137
|
+
return listed(PY_RESERVED, name) ? `${name}_` : name;
|
|
138
|
+
}
|
|
139
|
+
/** A PascalCase Python class name. */
|
|
140
|
+
export function pyClassName(raw) {
|
|
141
|
+
const name = guarded(pascalWords(raw), "Model", "N");
|
|
142
|
+
return listed(PY_RESERVED, name) ? `${name}_` : name;
|
|
143
|
+
}
|
|
144
|
+
/* Java's keywords (JLS 3.9), its literals, `_`, and the restricted identifiers that cannot name a type */
|
|
145
|
+
const JAVA_RESERVED = [
|
|
146
|
+
"abstract",
|
|
147
|
+
"assert",
|
|
148
|
+
"boolean",
|
|
149
|
+
"break",
|
|
150
|
+
"byte",
|
|
151
|
+
"case",
|
|
152
|
+
"catch",
|
|
153
|
+
"char",
|
|
154
|
+
"class",
|
|
155
|
+
"const",
|
|
156
|
+
"continue",
|
|
157
|
+
"default",
|
|
158
|
+
"do",
|
|
159
|
+
"double",
|
|
160
|
+
"else",
|
|
161
|
+
"enum",
|
|
162
|
+
"extends",
|
|
163
|
+
"final",
|
|
164
|
+
"finally",
|
|
165
|
+
"float",
|
|
166
|
+
"for",
|
|
167
|
+
"goto",
|
|
168
|
+
"if",
|
|
169
|
+
"implements",
|
|
170
|
+
"import",
|
|
171
|
+
"instanceof",
|
|
172
|
+
"int",
|
|
173
|
+
"interface",
|
|
174
|
+
"long",
|
|
175
|
+
"native",
|
|
176
|
+
"new",
|
|
177
|
+
"package",
|
|
178
|
+
"private",
|
|
179
|
+
"protected",
|
|
180
|
+
"public",
|
|
181
|
+
"return",
|
|
182
|
+
"short",
|
|
183
|
+
"static",
|
|
184
|
+
"strictfp",
|
|
185
|
+
"super",
|
|
186
|
+
"switch",
|
|
187
|
+
"synchronized",
|
|
188
|
+
"this",
|
|
189
|
+
"throw",
|
|
190
|
+
"throws",
|
|
191
|
+
"transient",
|
|
192
|
+
"try",
|
|
193
|
+
"void",
|
|
194
|
+
"volatile",
|
|
195
|
+
"while",
|
|
196
|
+
"true",
|
|
197
|
+
"false",
|
|
198
|
+
"null",
|
|
199
|
+
"_",
|
|
200
|
+
"var",
|
|
201
|
+
"yield",
|
|
202
|
+
"record",
|
|
203
|
+
"sealed",
|
|
204
|
+
"permits",
|
|
205
|
+
];
|
|
206
|
+
/** Whether `name` is one of Java's keywords, literals or restricted type identifiers: no bare identifier may be one. */
|
|
207
|
+
export const isJavaReserved = (name) => JAVA_RESERVED.includes(name);
|
|
208
|
+
/** A camelCase Java identifier (a parameter, a local): a keyword suffixed `_`, a digit first `_`, nothing `value`. */
|
|
209
|
+
export function javaIdentifier(raw) {
|
|
210
|
+
const name = camelWords(raw);
|
|
211
|
+
if (name === "" || name === "_")
|
|
212
|
+
return "value";
|
|
213
|
+
return /^[0-9]/.test(name) ? `_${name}` : isJavaReserved(name) ? `${name}_` : name;
|
|
214
|
+
}
|
|
215
|
+
/** A PascalCase Java type name: a digit first `N`, nothing `Value`; no keyword is PascalCase. */
|
|
216
|
+
export function javaTypeName(raw) {
|
|
217
|
+
return guarded(pascalWords(raw), "Value", "N");
|
|
218
|
+
}
|
|
219
|
+
/** A camelCase C# identifier (a parameter, a local): a keyword `@`-escaped, a digit first `_`, nothing `value`. */
|
|
220
|
+
export function csIdentifier(raw) {
|
|
221
|
+
const name = camelWords(raw);
|
|
222
|
+
if (name === "")
|
|
223
|
+
return "value";
|
|
224
|
+
return /^[0-9]/.test(name) ? `_${name}` : isCsReserved(name) || listed(CS_CONTEXTUAL, name) ? `@${name}` : name;
|
|
225
|
+
}
|
|
226
|
+
/** Whether `name` is one of C#'s reserved keywords: no namespace segment or bare identifier may be one. */
|
|
227
|
+
export function isCsReserved(name) {
|
|
228
|
+
return listed(CS_RESERVED, name);
|
|
229
|
+
}
|
|
230
|
+
/** A PascalCase C# type or member name: a digit first `N`, nothing `Value`; no keyword is PascalCase. */
|
|
231
|
+
export function csTypeName(raw) {
|
|
232
|
+
return guarded(pascalWords(raw), "Value", "N");
|
|
233
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** A property key in a type or object literal: bare when it is an identifier, a string literal otherwise. */
|
|
2
|
+
export declare function quoteKey(key: string): string;
|
|
3
|
+
/** The TypeScript literal type of a JSON `value` (an array as a tuple, an object field by field); else its type, or `unknown`. */
|
|
4
|
+
export declare function literalType(value: unknown): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript text for JSON values: property keys and literal types. Strings go through the one
|
|
3
|
+
* escape layer (F2), never `JSON.stringify` alone.
|
|
4
|
+
*/
|
|
5
|
+
import { tsString } from "./escape.js";
|
|
6
|
+
const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
7
|
+
/** A property key in a type or object literal: bare when it is an identifier, a string literal otherwise. */
|
|
8
|
+
export function quoteKey(key) {
|
|
9
|
+
return IDENTIFIER.test(key) ? key : tsString(key);
|
|
10
|
+
}
|
|
11
|
+
/** The TypeScript literal type of a JSON `value` (an array as a tuple, an object field by field); else its type, or `unknown`. */
|
|
12
|
+
export function literalType(value) {
|
|
13
|
+
if (value === null)
|
|
14
|
+
return "null";
|
|
15
|
+
if (value === undefined)
|
|
16
|
+
return "undefined";
|
|
17
|
+
if (typeof value === "string")
|
|
18
|
+
return tsString(value);
|
|
19
|
+
if (typeof value === "boolean")
|
|
20
|
+
return String(value);
|
|
21
|
+
if (typeof value === "bigint")
|
|
22
|
+
return `${value}n`;
|
|
23
|
+
if (typeof value === "number")
|
|
24
|
+
return Number.isFinite(value) ? String(value) : "number";
|
|
25
|
+
if (Array.isArray(value))
|
|
26
|
+
return `[${value.map(literalType).join(", ")}]`;
|
|
27
|
+
if (typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype)
|
|
28
|
+
return "unknown";
|
|
29
|
+
const fields = Object.entries(value).map(([key, child]) => `${quoteKey(key)}: ${literalType(child)}`);
|
|
30
|
+
return fields.length === 0 ? "{}" : `{ ${fields.join("; ")} }`;
|
|
31
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package metadata registries show, taken as options: the grammars every target checks a value against before it
|
|
3
|
+
* reaches a manifest (a goreleaser YAML string, a `.csproj` element, a Groovy string), and the one refusal they share,
|
|
4
|
+
* `Invalid <option>: "<value>"`. Each value is the caller's, never spec text, and is still escaped where it lands.
|
|
5
|
+
*/
|
|
6
|
+
/** One line of printable text, at most 4000 characters (nuget.org's description and authors limit); no lone surrogate. */
|
|
7
|
+
export declare const TEXT: RegExp;
|
|
8
|
+
/** An https URL with a host. */
|
|
9
|
+
export declare const HTTPS_URL: RegExp;
|
|
10
|
+
/** An SPDX license expression: ids joined by AND, OR or WITH. */
|
|
11
|
+
export declare const SPDX_EXPRESSION: RegExp;
|
|
12
|
+
/** One SPDX license list id, which spdx.org has a page for: not an expression, not a `LicenseRef-`. */
|
|
13
|
+
export declare const SPDX_ID: RegExp;
|
|
14
|
+
/** A version npm and JSR accept: `major.minor.patch`, then an optional prerelease. */
|
|
15
|
+
export declare const SEMVER: RegExp;
|
|
16
|
+
/** An npm package name: lowercase and URL-safe, `@scope/` optional, at most 214 characters. */
|
|
17
|
+
export declare const NPM_NAME: RegExp;
|
|
18
|
+
/** A person: `Name <email>`. */
|
|
19
|
+
export declare const PERSON: RegExp;
|
|
20
|
+
/** The refusal of an option's value. */
|
|
21
|
+
export declare const refuse: (option: string, value: string) => never;
|
|
22
|
+
/** `value` when it matches `grammar`, undefined when not given, else a refusal naming `option`. */
|
|
23
|
+
export declare function checked(option: string, value: string | undefined, grammar: RegExp): string | undefined;
|
|
24
|
+
/** A `Name <email>` that PERSON accepted, split. */
|
|
25
|
+
export declare function personOf(value: string): {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly email: string;
|
|
28
|
+
};
|
|
29
|
+
/** One author: a name with no comma, angle bracket or control character, or that name then ` <email>`. */
|
|
30
|
+
export declare const AUTHOR: RegExp;
|
|
31
|
+
/** A path to a Markdown file: the README every registry renders, NuGet only in Markdown. */
|
|
32
|
+
export declare const MARKDOWN_PATH: RegExp;
|
|
33
|
+
/** A path to a PNG or JPEG image: the package icon, in the formats NuGet takes. */
|
|
34
|
+
export declare const IMAGE_PATH: RegExp;
|
|
35
|
+
/** One keyword: no space, comma or control character, at most 50 characters; a registry may hold it to less. */
|
|
36
|
+
export declare const KEYWORD: RegExp;
|
|
37
|
+
/**
|
|
38
|
+
* The fields of the package metadata block a run gives once (plan 39 8.2), which every target that publishes reads
|
|
39
|
+
* where its registry has a place for it; a target's own option of the same meaning wins. `--metadata-<field>` sets one
|
|
40
|
+
* on the command line, `authors` and `keywords` comma separated.
|
|
41
|
+
*/
|
|
42
|
+
export declare const METADATA_FIELDS: readonly ["authors", "changelog", "copyright", "description", "documentation", "homepage", "icon", "keywords", "license", "licenseFile", "readme", "repository"];
|
|
43
|
+
/** One of `METADATA_FIELDS`. */
|
|
44
|
+
export type MetadataField = (typeof METADATA_FIELDS)[number];
|
|
45
|
+
/** The fields that hold a list. */
|
|
46
|
+
declare const LISTS: readonly ["authors", "keywords"];
|
|
47
|
+
/**
|
|
48
|
+
* The package metadata: `description` and `copyright` one line of text; `homepage`, `repository`, `documentation` and
|
|
49
|
+
* `changelog` https URLs; `license` an SPDX expression; `authors` each a name or `Name <email>`; `keywords` single
|
|
50
|
+
* words; `licenseFile`, `readme` and `icon` paths of files to ship in the package.
|
|
51
|
+
*/
|
|
52
|
+
export type Metadata = {
|
|
53
|
+
readonly [K in MetadataField]?: K extends (typeof LISTS)[number] ? readonly string[] : string;
|
|
54
|
+
};
|
|
55
|
+
/** Whether `field` holds a list. */
|
|
56
|
+
export declare const isListField: (field: string) => boolean;
|
|
57
|
+
/**
|
|
58
|
+
* `metadata` with every field checked against its grammar, or a refusal naming `metadata.<field>` and the value: a
|
|
59
|
+
* list field wants a non-empty list, each entry checked on its own. A field outside `METADATA_FIELDS` is refused; one
|
|
60
|
+
* given as `undefined` is left out, as not given.
|
|
61
|
+
*/
|
|
62
|
+
export declare function checkedMetadata(metadata: unknown): Metadata;
|
|
63
|
+
export declare const README = "README.md";
|
|
64
|
+
export declare const LICENSE = "LICENSE";
|
|
65
|
+
/**
|
|
66
|
+
* Which of them a package ships, as the block names them: its manifest points at each one it has. The icon ships only
|
|
67
|
+
* where the registry shows one (NuGet), by the name `iconName` gives it.
|
|
68
|
+
*/
|
|
69
|
+
export type Shipped = {
|
|
70
|
+
readonly readme: boolean;
|
|
71
|
+
readonly licenseFile: boolean;
|
|
72
|
+
readonly icon: string | undefined;
|
|
73
|
+
};
|
|
74
|
+
/** The name the icon at `path` ships under: `icon`, then its own extension in lower case. */
|
|
75
|
+
export declare const iconName: (path: string) => string;
|
|
76
|
+
/** What `metadata` ships beside the code. */
|
|
77
|
+
export declare const shippedOf: (metadata: Metadata) => Shipped;
|
|
78
|
+
/**
|
|
79
|
+
* A registry a generated package publishes to, by the id honey's manifest records it under: `go` is the module proxy
|
|
80
|
+
* (`go install <module>@<version>`), `mcp-registry` the MCP registry.
|
|
81
|
+
*/
|
|
82
|
+
export type Registry = "crates.io" | "go" | "jsr" | "maven-central" | "mcp-registry" | "npm" | "nuget" | "pypi";
|
|
83
|
+
/**
|
|
84
|
+
* A package as one registry lists it (plan 39 8.7): its name there and the version it publishes at, none for a Go
|
|
85
|
+
* module given no version, whose git tag is its version.
|
|
86
|
+
*/
|
|
87
|
+
export type PackageIdentity = {
|
|
88
|
+
/** the registry that lists it */
|
|
89
|
+
readonly registry: Registry;
|
|
90
|
+
/** its name there: npm's, `<groupId>:<artifactId>` on Maven Central, the module path (with its `/vN`) for Go */
|
|
91
|
+
readonly name: string;
|
|
92
|
+
/** the version it publishes at; none for a Go module given no version */
|
|
93
|
+
readonly version?: string;
|
|
94
|
+
};
|
|
95
|
+
/** The package `name` at `version` on `registry`. */
|
|
96
|
+
export declare const packageOn: (registry: Registry, name: string, version: string | undefined) => PackageIdentity;
|
|
97
|
+
/** The issue tracker of a repository URL: `<repository>/issues`, as GitHub, GitLab and Codeberg serve it. */
|
|
98
|
+
export declare const issuesUrl: (repository: string) => string;
|
|
99
|
+
/** An author's name: what is left of it without ` <email>`. */
|
|
100
|
+
export declare const authorName: (author: string) => string;
|
|
101
|
+
/** One author AUTHOR accepted, split: its name, and its email when it gives one. */
|
|
102
|
+
export declare const authorOf: (author: string) => {
|
|
103
|
+
readonly name: string;
|
|
104
|
+
readonly email?: string;
|
|
105
|
+
};
|
|
106
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package metadata registries show, taken as options: the grammars every target checks a value against before it
|
|
3
|
+
* reaches a manifest (a goreleaser YAML string, a `.csproj` element, a Groovy string), and the one refusal they share,
|
|
4
|
+
* `Invalid <option>: "<value>"`. Each value is the caller's, never spec text, and is still escaped where it lands.
|
|
5
|
+
*/
|
|
6
|
+
/** One line of printable text, at most 4000 characters (nuget.org's description and authors limit); no lone surrogate. */
|
|
7
|
+
export const TEXT = /^[^\p{Cc}\p{Cs}]{1,4000}$/u;
|
|
8
|
+
/** An https URL with a host. */
|
|
9
|
+
export const HTTPS_URL = /^https:\/\/[A-Za-z0-9.-]+(?::\d+)?(?:\/[A-Za-z0-9._~%!$&'()*+,;=:@/-]*)?$/;
|
|
10
|
+
/** An SPDX license expression: ids joined by AND, OR or WITH. */
|
|
11
|
+
export const SPDX_EXPRESSION = /^[A-Za-z0-9.+-]+(?: (?:AND|OR|WITH) [A-Za-z0-9.+-]+)*$/;
|
|
12
|
+
/** One SPDX license list id, which spdx.org has a page for: not an expression, not a `LicenseRef-`. */
|
|
13
|
+
export const SPDX_ID = /^(?!LicenseRef-)[A-Za-z0-9][A-Za-z0-9.+-]*$/;
|
|
14
|
+
/** A version npm and JSR accept: `major.minor.patch`, then an optional prerelease. */
|
|
15
|
+
export const SEMVER = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
16
|
+
/** An npm package name: lowercase and URL-safe, `@scope/` optional, at most 214 characters. */
|
|
17
|
+
export const NPM_NAME = /^(?=.{1,214}$)(?:@[a-z0-9-][a-z0-9._-]*\/)?[a-z0-9-][a-z0-9._-]*$/;
|
|
18
|
+
/** A person: `Name <email>`. */
|
|
19
|
+
export const PERSON = /^[^<>\p{Cc}]+ <[^\s<>@]+@[^\s<>@]+\.[^\s<>@]+>$/u;
|
|
20
|
+
/** The refusal of an option's value. */
|
|
21
|
+
export const refuse = (option, value) => {
|
|
22
|
+
throw new Error(`Invalid ${option}: ${JSON.stringify(value)}`);
|
|
23
|
+
};
|
|
24
|
+
/** `value` when it matches `grammar`, undefined when not given, else a refusal naming `option`. */
|
|
25
|
+
export function checked(option, value, grammar) {
|
|
26
|
+
if (value !== undefined && !grammar.test(value))
|
|
27
|
+
refuse(option, value);
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
/** A `Name <email>` that PERSON accepted, split. */
|
|
31
|
+
export function personOf(value) {
|
|
32
|
+
const open = value.lastIndexOf(" <");
|
|
33
|
+
return { email: value.slice(open + 2, -1), name: value.slice(0, open) };
|
|
34
|
+
}
|
|
35
|
+
/** One author: a name with no comma, angle bracket or control character, or that name then ` <email>`. */
|
|
36
|
+
export const AUTHOR = /^(?=[^\p{Cc}\p{Cs}]{1,4000}$)[^<>,]*[^<>,\s][^<>,]*?(?: <[^\s<>@]+@[^\s<>@]+\.[^\s<>@]+>)?$/u;
|
|
37
|
+
/** A path to a Markdown file: the README every registry renders, NuGet only in Markdown. */
|
|
38
|
+
export const MARKDOWN_PATH = /^(?=[^\p{Cc}\p{Cs}]{1,4000}$).*\.md$/iu;
|
|
39
|
+
/** A path to a PNG or JPEG image: the package icon, in the formats NuGet takes. */
|
|
40
|
+
export const IMAGE_PATH = /^(?=[^\p{Cc}\p{Cs}]{1,4000}$).*\.(?:png|jpe?g)$/iu;
|
|
41
|
+
/** One keyword: no space, comma or control character, at most 50 characters; a registry may hold it to less. */
|
|
42
|
+
export const KEYWORD = /^[^\s,\p{Cc}\p{Cs}]{1,50}$/u;
|
|
43
|
+
/**
|
|
44
|
+
* The fields of the package metadata block a run gives once (plan 39 8.2), which every target that publishes reads
|
|
45
|
+
* where its registry has a place for it; a target's own option of the same meaning wins. `--metadata-<field>` sets one
|
|
46
|
+
* on the command line, `authors` and `keywords` comma separated.
|
|
47
|
+
*/
|
|
48
|
+
export const METADATA_FIELDS = [
|
|
49
|
+
"authors",
|
|
50
|
+
"changelog",
|
|
51
|
+
"copyright",
|
|
52
|
+
"description",
|
|
53
|
+
"documentation",
|
|
54
|
+
"homepage",
|
|
55
|
+
"icon",
|
|
56
|
+
"keywords",
|
|
57
|
+
"license",
|
|
58
|
+
"licenseFile",
|
|
59
|
+
"readme",
|
|
60
|
+
"repository",
|
|
61
|
+
];
|
|
62
|
+
/** The fields that hold a list. */
|
|
63
|
+
const LISTS = ["authors", "keywords"];
|
|
64
|
+
const GRAMMARS = {
|
|
65
|
+
authors: AUTHOR,
|
|
66
|
+
changelog: HTTPS_URL,
|
|
67
|
+
copyright: TEXT,
|
|
68
|
+
description: TEXT,
|
|
69
|
+
documentation: HTTPS_URL,
|
|
70
|
+
homepage: HTTPS_URL,
|
|
71
|
+
icon: IMAGE_PATH,
|
|
72
|
+
keywords: KEYWORD,
|
|
73
|
+
license: SPDX_EXPRESSION,
|
|
74
|
+
licenseFile: TEXT,
|
|
75
|
+
readme: MARKDOWN_PATH,
|
|
76
|
+
repository: HTTPS_URL,
|
|
77
|
+
};
|
|
78
|
+
/** Whether `field` holds a list. */
|
|
79
|
+
export const isListField = (field) => LISTS.includes(field);
|
|
80
|
+
/** The refusal of a metadata field's value, shown as given. */
|
|
81
|
+
const refuseField = (field, value) => {
|
|
82
|
+
throw new Error(`Invalid metadata.${field}: ${JSON.stringify(value)}`);
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* `metadata` with every field checked against its grammar, or a refusal naming `metadata.<field>` and the value: a
|
|
86
|
+
* list field wants a non-empty list, each entry checked on its own. A field outside `METADATA_FIELDS` is refused; one
|
|
87
|
+
* given as `undefined` is left out, as not given.
|
|
88
|
+
*/
|
|
89
|
+
export function checkedMetadata(metadata) {
|
|
90
|
+
if (typeof metadata !== "object" || metadata === null || Array.isArray(metadata))
|
|
91
|
+
throw new Error("Invalid metadata: want an object of fields");
|
|
92
|
+
const entries = Object.entries(metadata).filter(([, value]) => value !== undefined);
|
|
93
|
+
for (const [field, value] of entries) {
|
|
94
|
+
if (!Object.hasOwn(GRAMMARS, field))
|
|
95
|
+
throw new Error(`Invalid metadata: unknown field ${JSON.stringify(field)}, want one of ${METADATA_FIELDS.join(", ")}`);
|
|
96
|
+
const grammar = GRAMMARS[field];
|
|
97
|
+
if (!isListField(field)) {
|
|
98
|
+
if (typeof value !== "string" || !grammar.test(value))
|
|
99
|
+
refuseField(field, value);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
103
|
+
refuseField(field, value);
|
|
104
|
+
for (const entry of value)
|
|
105
|
+
if (typeof entry !== "string" || !grammar.test(entry))
|
|
106
|
+
refuseField(field, entry);
|
|
107
|
+
}
|
|
108
|
+
return Object.fromEntries(entries);
|
|
109
|
+
}
|
|
110
|
+
/* the names the README and the license file the block names take in every package's root: those each registry and
|
|
111
|
+
* forge reads (plan 39 8.7) */
|
|
112
|
+
export const README = "README.md";
|
|
113
|
+
export const LICENSE = "LICENSE";
|
|
114
|
+
/** The name the icon at `path` ships under: `icon`, then its own extension in lower case. */
|
|
115
|
+
/* IMAGE_PATH holds every icon path to an extension, so the last dot starts it */
|
|
116
|
+
export const iconName = (path) => `icon${path.slice(path.lastIndexOf(".")).toLowerCase()}`;
|
|
117
|
+
/** What `metadata` ships beside the code. */
|
|
118
|
+
export const shippedOf = (metadata) => ({
|
|
119
|
+
icon: metadata.icon === undefined ? undefined : iconName(metadata.icon),
|
|
120
|
+
licenseFile: metadata.licenseFile !== undefined,
|
|
121
|
+
readme: metadata.readme !== undefined,
|
|
122
|
+
});
|
|
123
|
+
/** The package `name` at `version` on `registry`. */
|
|
124
|
+
export const packageOn = (registry, name, version) => version === undefined ? { name, registry } : { name, registry, version };
|
|
125
|
+
/** The issue tracker of a repository URL: `<repository>/issues`, as GitHub, GitLab and Codeberg serve it. */
|
|
126
|
+
export const issuesUrl = (repository) => `${repository.replace(/\.git$/, "")}/issues`;
|
|
127
|
+
/** An author's name: what is left of it without ` <email>`. */
|
|
128
|
+
export const authorName = (author) => author.replace(/ <[^<>]*>$/, "");
|
|
129
|
+
/** One author AUTHOR accepted, split: its name, and its email when it gives one. */
|
|
130
|
+
export const authorOf = (author) => author.endsWith(">") ? personOf(author) : { name: author };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The safe mirror's name on every SDK's client (bit 21 i), and its one rule for a root group spelled the same: the
|
|
3
|
+
* group is renamed so the mirror keeps its name, and the generation says so, never silently. Each language spells the
|
|
4
|
+
* mirror its own way (TS and Python `safe`, Go and C# `Safe`, Rust and Java `safe()`) and calls `mirrorNotice` with
|
|
5
|
+
* that spelling and the name its group is emitted as.
|
|
6
|
+
*/
|
|
7
|
+
/** The mirror's name before a language spells it. */
|
|
8
|
+
export declare const MIRROR = "safe";
|
|
9
|
+
/** A name a generation emits other than the spec's: what it names (`root group`, `component`), both names, and why. */
|
|
10
|
+
export type Rename = {
|
|
11
|
+
readonly what: string;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly renamed: string;
|
|
14
|
+
readonly because: string;
|
|
15
|
+
};
|
|
16
|
+
/** The one notice `target`'s generation reports for `rename`: never a silent rename. */
|
|
17
|
+
export declare function renameNotice(target: string, { because, name, renamed, what }: Rename): string;
|
|
18
|
+
/**
|
|
19
|
+
* The notice `target`'s generation reports when its root group `group` is spelled like the mirror (`spelled`, the
|
|
20
|
+
* language's spelling) and is emitted as `renamed` instead; null for any other group.
|
|
21
|
+
*/
|
|
22
|
+
export declare function mirrorNotice(target: string, spelled: string, group: string, renamed: string): string | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The safe mirror's name on every SDK's client (bit 21 i), and its one rule for a root group spelled the same: the
|
|
3
|
+
* group is renamed so the mirror keeps its name, and the generation says so, never silently. Each language spells the
|
|
4
|
+
* mirror its own way (TS and Python `safe`, Go and C# `Safe`, Rust and Java `safe()`) and calls `mirrorNotice` with
|
|
5
|
+
* that spelling and the name its group is emitted as.
|
|
6
|
+
*/
|
|
7
|
+
/** The mirror's name before a language spells it. */
|
|
8
|
+
export const MIRROR = "safe";
|
|
9
|
+
/** The one notice `target`'s generation reports for `rename`: never a silent rename. */
|
|
10
|
+
export function renameNotice(target, { because, name, renamed, what }) {
|
|
11
|
+
return `${target}: the ${what} "${name}" is emitted as "${renamed}": ${because}`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The notice `target`'s generation reports when its root group `group` is spelled like the mirror (`spelled`, the
|
|
15
|
+
* language's spelling) and is emitted as `renamed` instead; null for any other group.
|
|
16
|
+
*/
|
|
17
|
+
export function mirrorNotice(target, spelled, group, renamed) {
|
|
18
|
+
if (group !== spelled)
|
|
19
|
+
return null;
|
|
20
|
+
return renameNotice(target, {
|
|
21
|
+
because: `"${spelled}" is the client's safe mirror`,
|
|
22
|
+
name: group,
|
|
23
|
+
renamed,
|
|
24
|
+
what: "root group",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Python post-pass (R2, Fb9): `ruff format` as a `Formatter` for `formatFiles`, under the extension key
|
|
3
|
+
* `py`. gen never chooses a ruff: the caller passes the binary it pins (in tests, python-env's `ruffPath`).
|
|
4
|
+
* ruff ignores `options` (88 columns, four spaces), and `--isolated` keeps it from reading any configuration:
|
|
5
|
+
* a consumer's `[tool.ruff]` above the cwd never changes the output.
|
|
6
|
+
*/
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
/** A formatter that pipes a file through `ruff format`; a parse error or a ruff that cannot run is an error. */
|
|
9
|
+
export function ruffFormatter(ruff) {
|
|
10
|
+
return (fileName, source) => new Promise((resolve) => {
|
|
11
|
+
const args = ["format", "--isolated", "--target-version", "py311", "--stdin-filename", fileName, "-"];
|
|
12
|
+
const child = spawn(ruff, args, { stdio: ["pipe", "pipe", "pipe"] });
|
|
13
|
+
let stdout = "";
|
|
14
|
+
let stderr = "";
|
|
15
|
+
child.stdout.setEncoding("utf8").on("data", (chunk) => {
|
|
16
|
+
stdout += chunk;
|
|
17
|
+
});
|
|
18
|
+
child.stderr.setEncoding("utf8").on("data", (chunk) => {
|
|
19
|
+
stderr += chunk;
|
|
20
|
+
});
|
|
21
|
+
child.on("error", (error) => resolve({ code: source, errors: [error.message] }));
|
|
22
|
+
child.on("close", (status) => {
|
|
23
|
+
const failure = stderr.trim() || `${ruff} exited with status ${String(status)}`;
|
|
24
|
+
resolve(status === 0 ? { code: stdout, errors: [] } : { code: source, errors: [failure] });
|
|
25
|
+
});
|
|
26
|
+
child.stdin.on("error", () => {
|
|
27
|
+
/* a ruff that never started or stopped reading: its spawn error or exit status answers */
|
|
28
|
+
});
|
|
29
|
+
child.stdin.end(source);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Rust post-pass (R2): rustfmt as a `Formatter` for `formatFiles`, under the extension key `rs`.
|
|
3
|
+
* gen never chooses a Rust: the caller passes the rustfmt binary of the toolchain it pins (in tests,
|
|
4
|
+
* rust-env's `rustfmtPath`). rustfmt ignores `options`, and it reads no configuration but the empty
|
|
5
|
+
* one: on stdin it would otherwise take a `rustfmt.toml` from the cwd's ancestors or the user's config.
|
|
6
|
+
*/
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
import { devNull } from "node:os";
|
|
9
|
+
/** A formatter that pipes a file through `rustfmt` for `edition`; a parse error or a rustfmt that cannot run is an error. */
|
|
10
|
+
export function rustfmtFormatter(rustfmt, edition = "2024") {
|
|
11
|
+
const args = ["--edition", edition, "--config-path", devNull, "--emit", "stdout"];
|
|
12
|
+
return (_fileName, source) => new Promise((resolve) => {
|
|
13
|
+
const child = spawn(rustfmt, args, { stdio: ["pipe", "pipe", "pipe"] });
|
|
14
|
+
let stdout = "";
|
|
15
|
+
let stderr = "";
|
|
16
|
+
child.stdout.setEncoding("utf8").on("data", (chunk) => {
|
|
17
|
+
stdout += chunk;
|
|
18
|
+
});
|
|
19
|
+
child.stderr.setEncoding("utf8").on("data", (chunk) => {
|
|
20
|
+
stderr += chunk;
|
|
21
|
+
});
|
|
22
|
+
child.on("error", (error) => resolve({ code: source, errors: [error.message] }));
|
|
23
|
+
child.on("close", (status) => {
|
|
24
|
+
const failure = stderr.trim() || `${rustfmt} exited with status ${String(status)}`;
|
|
25
|
+
resolve(status === 0 ? { code: stdout, errors: [] } : { code: source, errors: [failure] });
|
|
26
|
+
});
|
|
27
|
+
child.stdin.on("error", () => {
|
|
28
|
+
/* a rustfmt that never started or stopped reading: its spawn error or exit status answers */
|
|
29
|
+
});
|
|
30
|
+
child.stdin.end(source);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP status code → honey's status key (`201` → `created`), as backend's response vocabulary names
|
|
3
|
+
* them (gen never imports backend, H2). tests/integration/codegen-tables.test.ts answers each key through a real app, so the two cannot drift.
|
|
4
|
+
*/
|
|
5
|
+
export declare const STATUS_KEYS: Readonly<Record<number, string>>;
|
|
6
|
+
/** The status key of `code`; undefined for a code outside the vocabulary (1xx, a range like `4XX`). */
|
|
7
|
+
export declare function statusKeyOf(code: number): string | undefined;
|