@workerstack/clients 0.0.0-stage → 1.0.0-rc.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +619 -2
- package/bin/honey-clients.js +94 -0
- package/dist/cli.d.ts +102 -0
- package/dist/cli.js +190 -0
- package/dist/emit/cli/channels.d.ts +73 -0
- package/dist/emit/cli/channels.js +197 -0
- package/dist/emit/cli/commands.d.ts +27 -0
- package/dist/emit/cli/commands.js +187 -0
- package/dist/emit/cli/discovery.d.ts +35 -0
- package/dist/emit/cli/discovery.js +202 -0
- package/dist/emit/cli/flags.d.ts +59 -0
- package/dist/emit/cli/flags.js +186 -0
- package/dist/emit/cli/index.d.ts +1 -0
- package/dist/emit/cli/index.js +1 -0
- package/dist/emit/cli/install.d.ts +37 -0
- package/dist/emit/cli/install.js +88 -0
- package/dist/emit/cli/layout.d.ts +23 -0
- package/dist/emit/cli/layout.js +118 -0
- package/dist/emit/cli/module.d.ts +30 -0
- package/dist/emit/cli/module.js +186 -0
- package/dist/emit/cli/release.d.ts +40 -0
- package/dist/emit/cli/release.js +183 -0
- package/dist/emit/cli/skills.d.ts +11 -0
- package/dist/emit/cli/skills.js +56 -0
- package/dist/emit/csharp/errors.d.ts +7 -0
- package/dist/emit/csharp/errors.js +69 -0
- package/dist/emit/csharp/index.d.ts +1 -0
- package/dist/emit/csharp/index.js +1 -0
- package/dist/emit/csharp/json.d.ts +13 -0
- package/dist/emit/csharp/json.js +113 -0
- package/dist/emit/csharp/realtime.d.ts +10 -0
- package/dist/emit/csharp/realtime.js +33 -0
- package/dist/emit/csharp/sdk-answer.d.ts +48 -0
- package/dist/emit/csharp/sdk-answer.js +85 -0
- package/dist/emit/csharp/sdk-body.d.ts +10 -0
- package/dist/emit/csharp/sdk-body.js +87 -0
- package/dist/emit/csharp/sdk-client.d.ts +32 -0
- package/dist/emit/csharp/sdk-client.js +177 -0
- package/dist/emit/csharp/sdk-csproj.d.ts +36 -0
- package/dist/emit/csharp/sdk-csproj.js +136 -0
- package/dist/emit/csharp/sdk-doc.d.ts +12 -0
- package/dist/emit/csharp/sdk-doc.js +35 -0
- package/dist/emit/csharp/sdk-method.d.ts +26 -0
- package/dist/emit/csharp/sdk-method.js +187 -0
- package/dist/emit/csharp/sdk-plan.d.ts +38 -0
- package/dist/emit/csharp/sdk-plan.js +1 -0
- package/dist/emit/csharp/sdk.d.ts +40 -0
- package/dist/emit/csharp/sdk.js +105 -0
- package/dist/emit/csharp/sse.d.ts +18 -0
- package/dist/emit/csharp/sse.js +29 -0
- package/dist/emit/csharp/transport.d.ts +11 -0
- package/dist/emit/csharp/transport.js +67 -0
- package/dist/emit/csharp/types-enum.d.ts +19 -0
- package/dist/emit/csharp/types-enum.js +63 -0
- package/dist/emit/csharp/types-names.d.ts +33 -0
- package/dist/emit/csharp/types-names.js +182 -0
- package/dist/emit/csharp/types-record.d.ts +25 -0
- package/dist/emit/csharp/types-record.js +65 -0
- package/dist/emit/csharp/types-union.d.ts +27 -0
- package/dist/emit/csharp/types-union.js +113 -0
- package/dist/emit/csharp/types.d.ts +36 -0
- package/dist/emit/csharp/types.js +126 -0
- package/dist/emit/csharp/ws.d.ts +20 -0
- package/dist/emit/csharp/ws.js +14 -0
- package/dist/emit/go/errors.d.ts +7 -0
- package/dist/emit/go/errors.js +44 -0
- package/dist/emit/go/http.d.ts +11 -0
- package/dist/emit/go/http.js +50 -0
- package/dist/emit/go/index.d.ts +1 -0
- package/dist/emit/go/index.js +1 -0
- package/dist/emit/go/module-path.d.ts +2 -0
- package/dist/emit/go/module-path.js +27 -0
- package/dist/emit/go/sdk-answer.d.ts +28 -0
- package/dist/emit/go/sdk-answer.js +41 -0
- package/dist/emit/go/sdk-body.d.ts +24 -0
- package/dist/emit/go/sdk-body.js +76 -0
- package/dist/emit/go/sdk-client.d.ts +29 -0
- package/dist/emit/go/sdk-client.js +141 -0
- package/dist/emit/go/sdk-method.d.ts +68 -0
- package/dist/emit/go/sdk-method.js +172 -0
- package/dist/emit/go/sdk-mirror.d.ts +23 -0
- package/dist/emit/go/sdk-mirror.js +97 -0
- package/dist/emit/go/sdk-opts.d.ts +55 -0
- package/dist/emit/go/sdk-opts.js +100 -0
- package/dist/emit/go/sdk.d.ts +26 -0
- package/dist/emit/go/sdk.js +111 -0
- package/dist/emit/go/sse.d.ts +16 -0
- package/dist/emit/go/sse.js +26 -0
- package/dist/emit/go/types-codec.d.ts +15 -0
- package/dist/emit/go/types-codec.js +171 -0
- package/dist/emit/go/types-names.d.ts +14 -0
- package/dist/emit/go/types-names.js +64 -0
- package/dist/emit/go/types-struct.d.ts +29 -0
- package/dist/emit/go/types-struct.js +65 -0
- package/dist/emit/go/types-union.d.ts +17 -0
- package/dist/emit/go/types-union.js +84 -0
- package/dist/emit/go/types.d.ts +32 -0
- package/dist/emit/go/types.js +177 -0
- package/dist/emit/go/ws.d.ts +12 -0
- package/dist/emit/go/ws.js +70 -0
- package/dist/emit/java/gradle.d.ts +57 -0
- package/dist/emit/java/gradle.js +221 -0
- package/dist/emit/java/index.d.ts +2 -0
- package/dist/emit/java/index.js +2 -0
- package/dist/emit/java/json.d.ts +13 -0
- package/dist/emit/java/json.js +84 -0
- package/dist/emit/java/layout-ast.d.ts +146 -0
- package/dist/emit/java/layout-ast.js +102 -0
- package/dist/emit/java/layout-decl.d.ts +20 -0
- package/dist/emit/java/layout-decl.js +155 -0
- package/dist/emit/java/layout-doc.d.ts +55 -0
- package/dist/emit/java/layout-doc.js +166 -0
- package/dist/emit/java/layout-dot.d.ts +18 -0
- package/dist/emit/java/layout-dot.js +127 -0
- package/dist/emit/java/layout-strings.d.ts +8 -0
- package/dist/emit/java/layout-strings.js +76 -0
- package/dist/emit/java/layout-types.d.ts +11 -0
- package/dist/emit/java/layout-types.js +95 -0
- package/dist/emit/java/layout-visitor.d.ts +38 -0
- package/dist/emit/java/layout-visitor.js +232 -0
- package/dist/emit/java/layout.d.ts +61 -0
- package/dist/emit/java/layout.js +121 -0
- package/dist/emit/java/models-enum.d.ts +17 -0
- package/dist/emit/java/models-enum.js +51 -0
- package/dist/emit/java/models-names.d.ts +29 -0
- package/dist/emit/java/models-names.js +97 -0
- package/dist/emit/java/models-record.d.ts +24 -0
- package/dist/emit/java/models-record.js +79 -0
- package/dist/emit/java/models-union.d.ts +27 -0
- package/dist/emit/java/models-union.js +86 -0
- package/dist/emit/java/models.d.ts +28 -0
- package/dist/emit/java/models.js +118 -0
- package/dist/emit/java/realtime.d.ts +50 -0
- package/dist/emit/java/realtime.js +69 -0
- package/dist/emit/java/sdk-client.d.ts +66 -0
- package/dist/emit/java/sdk-client.js +207 -0
- package/dist/emit/java/sdk-decl.d.ts +11 -0
- package/dist/emit/java/sdk-decl.js +63 -0
- package/dist/emit/java/sdk-errors.d.ts +13 -0
- package/dist/emit/java/sdk-errors.js +141 -0
- package/dist/emit/java/sdk-headers.d.ts +12 -0
- package/dist/emit/java/sdk-headers.js +74 -0
- package/dist/emit/java/sdk-mirror.d.ts +14 -0
- package/dist/emit/java/sdk-mirror.js +107 -0
- package/dist/emit/java/sdk-models.d.ts +16 -0
- package/dist/emit/java/sdk-models.js +68 -0
- package/dist/emit/java/sdk-op.d.ts +57 -0
- package/dist/emit/java/sdk-op.js +216 -0
- package/dist/emit/java/sdk-params.d.ts +38 -0
- package/dist/emit/java/sdk-params.js +133 -0
- package/dist/emit/java/sdk-plan.d.ts +52 -0
- package/dist/emit/java/sdk-plan.js +1 -0
- package/dist/emit/java/sdk-record.d.ts +16 -0
- package/dist/emit/java/sdk-record.js +99 -0
- package/dist/emit/java/sdk.d.ts +49 -0
- package/dist/emit/java/sdk.js +216 -0
- package/dist/emit/java/sse.d.ts +35 -0
- package/dist/emit/java/sse.js +57 -0
- package/dist/emit/java/ws.d.ts +27 -0
- package/dist/emit/java/ws.js +31 -0
- package/dist/emit/mcp/annotations.d.ts +15 -0
- package/dist/emit/mcp/annotations.js +15 -0
- package/dist/emit/mcp/files.d.ts +18 -0
- package/dist/emit/mcp/files.js +42 -0
- package/dist/emit/mcp/index.d.ts +3 -0
- package/dist/emit/mcp/index.js +3 -0
- package/dist/emit/mcp/literal.d.ts +2 -0
- package/dist/emit/mcp/literal.js +33 -0
- package/dist/emit/mcp/mounted.d.ts +21 -0
- package/dist/emit/mcp/mounted.js +89 -0
- package/dist/emit/mcp/output-schema.d.ts +18 -0
- package/dist/emit/mcp/output-schema.js +38 -0
- package/dist/emit/mcp/registry.d.ts +23 -0
- package/dist/emit/mcp/registry.js +83 -0
- package/dist/emit/mcp/runtime.d.ts +10 -0
- package/dist/emit/mcp/runtime.js +47 -0
- package/dist/emit/mcp/schema.d.ts +19 -0
- package/dist/emit/mcp/schema.js +88 -0
- package/dist/emit/mcp/server.d.ts +30 -0
- package/dist/emit/mcp/server.js +246 -0
- package/dist/emit/mcp/tools.d.ts +51 -0
- package/dist/emit/mcp/tools.js +153 -0
- package/dist/emit/python/errors.d.ts +8 -0
- package/dist/emit/python/errors.js +68 -0
- package/dist/emit/python/index.d.ts +1 -0
- package/dist/emit/python/index.js +1 -0
- package/dist/emit/python/realtime.d.ts +10 -0
- package/dist/emit/python/realtime.js +33 -0
- package/dist/emit/python/sdk-answer.d.ts +49 -0
- package/dist/emit/python/sdk-answer.js +89 -0
- package/dist/emit/python/sdk-body.d.ts +11 -0
- package/dist/emit/python/sdk-body.js +40 -0
- package/dist/emit/python/sdk-client.d.ts +36 -0
- package/dist/emit/python/sdk-client.js +163 -0
- package/dist/emit/python/sdk-doc.d.ts +9 -0
- package/dist/emit/python/sdk-doc.js +32 -0
- package/dist/emit/python/sdk-imports.d.ts +14 -0
- package/dist/emit/python/sdk-imports.js +38 -0
- package/dist/emit/python/sdk-method.d.ts +29 -0
- package/dist/emit/python/sdk-method.js +183 -0
- package/dist/emit/python/sdk-plan.d.ts +33 -0
- package/dist/emit/python/sdk-plan.js +1 -0
- package/dist/emit/python/sdk-pyproject.d.ts +27 -0
- package/dist/emit/python/sdk-pyproject.js +103 -0
- package/dist/emit/python/sdk.d.ts +22 -0
- package/dist/emit/python/sdk.js +154 -0
- package/dist/emit/python/sse.d.ts +12 -0
- package/dist/emit/python/sse.js +23 -0
- package/dist/emit/python/transport.d.ts +15 -0
- package/dist/emit/python/transport.js +60 -0
- package/dist/emit/python/types-dict.d.ts +31 -0
- package/dist/emit/python/types-dict.js +45 -0
- package/dist/emit/python/types-names.d.ts +16 -0
- package/dist/emit/python/types-names.js +52 -0
- package/dist/emit/python/types-union.d.ts +32 -0
- package/dist/emit/python/types-union.js +46 -0
- package/dist/emit/python/types.d.ts +36 -0
- package/dist/emit/python/types.js +128 -0
- package/dist/emit/python/ws.d.ts +14 -0
- package/dist/emit/python/ws.js +16 -0
- package/dist/emit/rust/errors.d.ts +7 -0
- package/dist/emit/rust/errors.js +107 -0
- package/dist/emit/rust/http.d.ts +13 -0
- package/dist/emit/rust/http.js +67 -0
- package/dist/emit/rust/index.d.ts +1 -0
- package/dist/emit/rust/index.js +1 -0
- package/dist/emit/rust/realtime.d.ts +11 -0
- package/dist/emit/rust/realtime.js +29 -0
- package/dist/emit/rust/sdk-body.d.ts +19 -0
- package/dist/emit/rust/sdk-body.js +53 -0
- package/dist/emit/rust/sdk-cargo.d.ts +43 -0
- package/dist/emit/rust/sdk-cargo.js +178 -0
- package/dist/emit/rust/sdk-client.d.ts +25 -0
- package/dist/emit/rust/sdk-client.js +108 -0
- package/dist/emit/rust/sdk-method.d.ts +15 -0
- package/dist/emit/rust/sdk-method.js +119 -0
- package/dist/emit/rust/sdk-opts.d.ts +58 -0
- package/dist/emit/rust/sdk-opts.js +117 -0
- package/dist/emit/rust/sdk-plan.d.ts +33 -0
- package/dist/emit/rust/sdk-plan.js +1 -0
- package/dist/emit/rust/sdk.d.ts +23 -0
- package/dist/emit/rust/sdk.js +111 -0
- package/dist/emit/rust/sse.d.ts +19 -0
- package/dist/emit/rust/sse.js +20 -0
- package/dist/emit/rust/types-enum.d.ts +13 -0
- package/dist/emit/rust/types-enum.js +62 -0
- package/dist/emit/rust/types-names.d.ts +19 -0
- package/dist/emit/rust/types-names.js +66 -0
- package/dist/emit/rust/types-struct.d.ts +21 -0
- package/dist/emit/rust/types-struct.js +59 -0
- package/dist/emit/rust/types-union.d.ts +24 -0
- package/dist/emit/rust/types-union.js +97 -0
- package/dist/emit/rust/types.d.ts +34 -0
- package/dist/emit/rust/types.js +105 -0
- package/dist/emit/rust/ws.d.ts +21 -0
- package/dist/emit/rust/ws.js +20 -0
- package/dist/emit/shared/escape.d.ts +55 -0
- package/dist/emit/shared/escape.js +144 -0
- package/dist/emit/shared/format.d.ts +24 -0
- package/dist/emit/shared/format.js +23 -0
- package/dist/emit/shared/gofmt.d.ts +3 -0
- package/dist/emit/shared/gofmt.js +26 -0
- package/dist/emit/shared/lang.d.ts +60 -0
- package/dist/emit/shared/lang.js +233 -0
- package/dist/emit/shared/literals.d.ts +4 -0
- package/dist/emit/shared/literals.js +31 -0
- package/dist/emit/shared/metadata.d.ts +106 -0
- package/dist/emit/shared/metadata.js +130 -0
- package/dist/emit/shared/mirror.d.ts +22 -0
- package/dist/emit/shared/mirror.js +26 -0
- package/dist/emit/shared/ruff.d.ts +3 -0
- package/dist/emit/shared/ruff.js +31 -0
- package/dist/emit/shared/rustfmt.d.ts +3 -0
- package/dist/emit/shared/rustfmt.js +32 -0
- package/dist/emit/shared/status-keys.d.ts +7 -0
- package/dist/emit/shared/status-keys.js +67 -0
- package/dist/emit/shared/type-emitter.d.ts +19 -0
- package/dist/emit/shared/type-emitter.js +100 -0
- package/dist/emit/ts/app-client.d.ts +4 -0
- package/dist/emit/ts/app-client.js +68 -0
- package/dist/emit/ts/http.d.ts +20 -0
- package/dist/emit/ts/http.js +74 -0
- package/dist/emit/ts/package.d.ts +36 -0
- package/dist/emit/ts/package.js +126 -0
- package/dist/emit/ts/route-tree.d.ts +68 -0
- package/dist/emit/ts/route-tree.js +240 -0
- package/dist/emit/ts/sdk-types-preamble.d.ts +14 -0
- package/dist/emit/ts/sdk-types-preamble.js +123 -0
- package/dist/emit/ts/sdk-types.d.ts +13 -0
- package/dist/emit/ts/sdk-types.js +213 -0
- package/dist/emit/ts/sdk.d.ts +21 -0
- package/dist/emit/ts/sdk.js +173 -0
- package/dist/emit/ts/service-map.d.ts +40 -0
- package/dist/emit/ts/service-map.js +171 -0
- package/dist/emit/ts/tanstack-query.d.ts +12 -0
- package/dist/emit/ts/tanstack-query.js +156 -0
- package/dist/emit/ts/type-gen.d.ts +26 -0
- package/dist/emit/ts/type-gen.js +255 -0
- package/dist/emit/ts/webhooks.d.ts +19 -0
- package/dist/emit/ts/webhooks.js +81 -0
- package/dist/extract/chain.d.ts +34 -0
- package/dist/extract/chain.js +84 -0
- package/dist/extract/extract.d.ts +41 -0
- package/dist/extract/extract.js +191 -0
- package/dist/extract/serialize.d.ts +34 -0
- package/dist/extract/serialize.js +295 -0
- package/dist/extract/walk.d.ts +47 -0
- package/dist/extract/walk.js +109 -0
- package/dist/gen/args.d.ts +28 -0
- package/dist/gen/args.js +133 -0
- package/dist/gen/formatters.d.ts +62 -0
- package/dist/gen/formatters.js +146 -0
- package/dist/gen/process.d.ts +13 -0
- package/dist/gen/process.js +35 -0
- package/dist/gen/shipped.d.ts +17 -0
- package/dist/gen/shipped.js +55 -0
- package/dist/gen/targets.d.ts +93 -0
- package/dist/gen/targets.js +171 -0
- package/dist/gen/write.d.ts +33 -0
- package/dist/gen/write.js +118 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +15 -0
- package/dist/ir/build.d.ts +37 -0
- package/dist/ir/build.js +152 -0
- package/dist/ir/load.d.ts +11 -0
- package/dist/ir/load.js +112 -0
- package/dist/ir/model.d.ts +206 -0
- package/dist/ir/model.js +5 -0
- package/dist/ir/resolve-refs.d.ts +11 -0
- package/dist/ir/resolve-refs.js +66 -0
- package/dist/ir/resource-tree.d.ts +9 -0
- package/dist/ir/resource-tree.js +53 -0
- package/dist/ir/route-tree-intern.d.ts +18 -0
- package/dist/ir/route-tree-intern.js +174 -0
- package/dist/ir/schema.d.ts +11 -0
- package/dist/ir/schema.js +192 -0
- package/dist/ir/sdk-model.d.ts +86 -0
- package/dist/ir/sdk-model.js +204 -0
- package/dist/ir/slots.d.ts +42 -0
- package/dist/ir/slots.js +245 -0
- package/dist/runtime/cli/body.go +176 -0
- package/dist/runtime/cli/config.go +243 -0
- package/dist/runtime/cli/discovery.go +147 -0
- package/dist/runtime/cli/format.go +174 -0
- package/dist/runtime/cli/log.go +117 -0
- package/dist/runtime/cli/output.go +247 -0
- package/dist/runtime/cli/params.go +197 -0
- package/dist/runtime/cli/run.go +226 -0
- package/dist/runtime/cli/socket.go +60 -0
- package/dist/runtime/cli/stream.go +217 -0
- package/dist/runtime/cli/target.go +117 -0
- package/dist/runtime/csharp/Adapters.cs +183 -0
- package/dist/runtime/csharp/Auth.cs +56 -0
- package/dist/runtime/csharp/Body.cs +135 -0
- package/dist/runtime/csharp/Config.cs +161 -0
- package/dist/runtime/csharp/Envelope.cs +149 -0
- package/dist/runtime/csharp/Errors.cs +194 -0
- package/dist/runtime/csharp/Events.cs +155 -0
- package/dist/runtime/csharp/Exchange.cs +247 -0
- package/dist/runtime/csharp/Handler.cs +103 -0
- package/dist/runtime/csharp/Hooks.cs +128 -0
- package/dist/runtime/csharp/Invalidation.cs +102 -0
- package/dist/runtime/csharp/Json.cs +144 -0
- package/dist/runtime/csharp/Log.cs +48 -0
- package/dist/runtime/csharp/Operation.cs +33 -0
- package/dist/runtime/csharp/Path.cs +65 -0
- package/dist/runtime/csharp/Query.cs +72 -0
- package/dist/runtime/csharp/Realtime.cs +118 -0
- package/dist/runtime/csharp/RealtimeLoop.cs +236 -0
- package/dist/runtime/csharp/Redirect.cs +53 -0
- package/dist/runtime/csharp/Result.cs +57 -0
- package/dist/runtime/csharp/Sse.cs +122 -0
- package/dist/runtime/csharp/Stale.cs +151 -0
- package/dist/runtime/csharp/Transport.cs +143 -0
- package/dist/runtime/csharp/TransportLongPoll.cs +63 -0
- package/dist/runtime/csharp/TransportSse.cs +54 -0
- package/dist/runtime/csharp/TransportWs.cs +40 -0
- package/dist/runtime/csharp/Wire.cs +109 -0
- package/dist/runtime/csharp/Ws.cs +300 -0
- package/dist/runtime/csharp/WsDial.cs +127 -0
- package/dist/runtime/go/auth.go +127 -0
- package/dist/runtime/go/body.go +129 -0
- package/dist/runtime/go/config.go +75 -0
- package/dist/runtime/go/errors.go +185 -0
- package/dist/runtime/go/export.go +37 -0
- package/dist/runtime/go/hooks.go +53 -0
- package/dist/runtime/go/invalidation.go +112 -0
- package/dist/runtime/go/log.go +92 -0
- package/dist/runtime/go/nullable.go +64 -0
- package/dist/runtime/go/options.go +118 -0
- package/dist/runtime/go/path.go +156 -0
- package/dist/runtime/go/query.go +147 -0
- package/dist/runtime/go/realtime.go +239 -0
- package/dist/runtime/go/realtime_loop.go +208 -0
- package/dist/runtime/go/redirect.go +124 -0
- package/dist/runtime/go/request.go +222 -0
- package/dist/runtime/go/result.go +86 -0
- package/dist/runtime/go/sse.go +186 -0
- package/dist/runtime/go/stale.go +229 -0
- package/dist/runtime/go/stream.go +105 -0
- package/dist/runtime/go/transport.go +242 -0
- package/dist/runtime/go/transport_longpoll.go +121 -0
- package/dist/runtime/go/transport_sse.go +175 -0
- package/dist/runtime/go/ws.go +205 -0
- package/dist/runtime/java/Answer.java +107 -0
- package/dist/runtime/java/ApiException.java +110 -0
- package/dist/runtime/java/BinaryBody.java +36 -0
- package/dist/runtime/java/Body.java +105 -0
- package/dist/runtime/java/Call.java +23 -0
- package/dist/runtime/java/CallLog.java +51 -0
- package/dist/runtime/java/ClientConfig.java +233 -0
- package/dist/runtime/java/ConnectionState.java +12 -0
- package/dist/runtime/java/Credential.java +58 -0
- package/dist/runtime/java/Deadline.java +38 -0
- package/dist/runtime/java/Decode.java +181 -0
- package/dist/runtime/java/Envelope.java +141 -0
- package/dist/runtime/java/ErrorEnvelope.java +23 -0
- package/dist/runtime/java/EventStream.java +129 -0
- package/dist/runtime/java/Exchange.java +62 -0
- package/dist/runtime/java/FilePart.java +5 -0
- package/dist/runtime/java/Flight.java +306 -0
- package/dist/runtime/java/HoneyException.java +14 -0
- package/dist/runtime/java/Hooks.java +47 -0
- package/dist/runtime/java/Hops.java +133 -0
- package/dist/runtime/java/InvalidationConfig.java +73 -0
- package/dist/runtime/java/Json.java +23 -0
- package/dist/runtime/java/Keepalive.java +60 -0
- package/dist/runtime/java/LogEntry.java +14 -0
- package/dist/runtime/java/LongPollAdapter.java +68 -0
- package/dist/runtime/java/Operation.java +21 -0
- package/dist/runtime/java/Opt.java +121 -0
- package/dist/runtime/java/Pump.java +160 -0
- package/dist/runtime/java/RawResponse.java +48 -0
- package/dist/runtime/java/Realtime.java +152 -0
- package/dist/runtime/java/RealtimeLoop.java +371 -0
- package/dist/runtime/java/RedirectPolicy.java +13 -0
- package/dist/runtime/java/Redirects.java +126 -0
- package/dist/runtime/java/RequestContext.java +78 -0
- package/dist/runtime/java/RequestHook.java +9 -0
- package/dist/runtime/java/RequestOptions.java +91 -0
- package/dist/runtime/java/ResponseContext.java +70 -0
- package/dist/runtime/java/ResponseHook.java +12 -0
- package/dist/runtime/java/Result.java +32 -0
- package/dist/runtime/java/ResumableConnection.java +165 -0
- package/dist/runtime/java/SdkException.java +11 -0
- package/dist/runtime/java/Socket.java +301 -0
- package/dist/runtime/java/Sse.java +171 -0
- package/dist/runtime/java/SseAdapter.java +61 -0
- package/dist/runtime/java/SseEvent.java +10 -0
- package/dist/runtime/java/StaleMeta.java +16 -0
- package/dist/runtime/java/StaleTracker.java +287 -0
- package/dist/runtime/java/Transport.java +16 -0
- package/dist/runtime/java/TransportAdapter.java +14 -0
- package/dist/runtime/java/TransportConnection.java +15 -0
- package/dist/runtime/java/TransportKind.java +12 -0
- package/dist/runtime/java/TransportMessage.java +9 -0
- package/dist/runtime/java/TransportOptions.java +138 -0
- package/dist/runtime/java/TypedWebSocket.java +83 -0
- package/dist/runtime/java/UrlPath.java +49 -0
- package/dist/runtime/java/UrlQuery.java +99 -0
- package/dist/runtime/java/WsAdapter.java +52 -0
- package/dist/runtime/java/WsClose.java +47 -0
- package/dist/runtime/java/WsDial.java +148 -0
- package/dist/runtime/java/WsMessage.java +18 -0
- package/dist/runtime/mcp/call.ts +167 -0
- package/dist/runtime/mcp/files.ts +183 -0
- package/dist/runtime/mcp/guard.ts +176 -0
- package/dist/runtime/mcp/http.ts +159 -0
- package/dist/runtime/mcp/jsonrpc.ts +50 -0
- package/dist/runtime/mcp/listen.ts +76 -0
- package/dist/runtime/mcp/mount.ts +123 -0
- package/dist/runtime/mcp/protocol.ts +219 -0
- package/dist/runtime/mcp/reader.ts +57 -0
- package/dist/runtime/mcp/result.ts +85 -0
- package/dist/runtime/mcp/stdio.ts +79 -0
- package/dist/runtime/mcp/stream.ts +62 -0
- package/dist/runtime/python/__init__.py +2 -0
- package/dist/runtime/python/auth.py +67 -0
- package/dist/runtime/python/body.py +83 -0
- package/dist/runtime/python/config.py +139 -0
- package/dist/runtime/python/errors.py +213 -0
- package/dist/runtime/python/events.py +152 -0
- package/dist/runtime/python/exchange.py +298 -0
- package/dist/runtime/python/hooks.py +86 -0
- package/dist/runtime/python/invalidation.py +57 -0
- package/dist/runtime/python/log.py +60 -0
- package/dist/runtime/python/operation.py +25 -0
- package/dist/runtime/python/path.py +41 -0
- package/dist/runtime/python/query.py +48 -0
- package/dist/runtime/python/realtime.py +244 -0
- package/dist/runtime/python/redirect.py +93 -0
- package/dist/runtime/python/result.py +58 -0
- package/dist/runtime/python/send_async.py +189 -0
- package/dist/runtime/python/send_sync.py +105 -0
- package/dist/runtime/python/sse.py +81 -0
- package/dist/runtime/python/stale.py +94 -0
- package/dist/runtime/python/transport.py +157 -0
- package/dist/runtime/python/transport_longpoll.py +60 -0
- package/dist/runtime/python/transport_sse.py +60 -0
- package/dist/runtime/python/transport_ws.py +57 -0
- package/dist/runtime/python/ws.py +276 -0
- package/dist/runtime/rust/Cargo.lock +1763 -0
- package/dist/runtime/rust/answer.rs +120 -0
- package/dist/runtime/rust/auth.rs +80 -0
- package/dist/runtime/rust/body.rs +150 -0
- package/dist/runtime/rust/call.rs +200 -0
- package/dist/runtime/rust/config.rs +254 -0
- package/dist/runtime/rust/envelope.rs +84 -0
- package/dist/runtime/rust/errors.rs +235 -0
- package/dist/runtime/rust/events.rs +177 -0
- package/dist/runtime/rust/exchange.rs +287 -0
- package/dist/runtime/rust/hooks.rs +63 -0
- package/dist/runtime/rust/invalidation.rs +84 -0
- package/dist/runtime/rust/log.rs +88 -0
- package/dist/runtime/rust/nullable.rs +13 -0
- package/dist/runtime/rust/path.rs +83 -0
- package/dist/runtime/rust/query.rs +84 -0
- package/dist/runtime/rust/realtime.rs +182 -0
- package/dist/runtime/rust/realtime_loop.rs +177 -0
- package/dist/runtime/rust/redirect.rs +121 -0
- package/dist/runtime/rust/request.rs +178 -0
- package/dist/runtime/rust/result.rs +101 -0
- package/dist/runtime/rust/sse.rs +104 -0
- package/dist/runtime/rust/stale.rs +209 -0
- package/dist/runtime/rust/transport.rs +221 -0
- package/dist/runtime/rust/transport_longpoll.rs +108 -0
- package/dist/runtime/rust/transport_sse.rs +91 -0
- package/dist/runtime/rust/transport_ws.rs +75 -0
- package/dist/runtime/rust/ws.rs +322 -0
- package/dist/runtime/ts/app-types.ts +200 -0
- package/dist/runtime/ts/app.ts +104 -0
- package/dist/runtime/ts/config.ts +124 -0
- package/dist/runtime/ts/defaults.ts +48 -0
- package/dist/runtime/ts/error.ts +113 -0
- package/dist/runtime/ts/hooks.ts +92 -0
- package/dist/runtime/ts/http.ts +228 -0
- package/dist/runtime/ts/media-type.ts +36 -0
- package/dist/runtime/ts/path.ts +152 -0
- package/dist/runtime/ts/realtime-connection.ts +296 -0
- package/dist/runtime/ts/realtime-transports.ts +149 -0
- package/dist/runtime/ts/realtime.ts +293 -0
- package/dist/runtime/ts/redirect-policy.ts +17 -0
- package/dist/runtime/ts/redirects.ts +74 -0
- package/dist/runtime/ts/request.ts +239 -0
- package/dist/runtime/ts/response.ts +219 -0
- package/dist/runtime/ts/sdk-realtime.ts +10 -0
- package/dist/runtime/ts/sdk-sse.ts +55 -0
- package/dist/runtime/ts/sdk-ws.ts +21 -0
- package/dist/runtime/ts/sdk.ts +242 -0
- package/dist/runtime/ts/sse.ts +175 -0
- package/dist/runtime/ts/stale.ts +137 -0
- package/dist/runtime/ts/stream.ts +87 -0
- package/dist/runtime/ts/webhook.ts +116 -0
- package/dist/runtime/ts/ws.ts +155 -0
- package/dist/runtime/ts-tanstack-query/invalidate.ts +152 -0
- package/dist/runtime/ts-tanstack-query/query.ts +261 -0
- package/package.json +84 -5
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { lineComment, rustString } from "../shared/escape.js";
|
|
2
|
+
import { NameScope, rustTypeIdent } from "../shared/lang.js";
|
|
3
|
+
import { stringEnumDecl, stringValues, variantOf } from "./types-enum.js";
|
|
4
|
+
import { DERIVE } from "./types-struct.js";
|
|
5
|
+
const isLiteral = (variant) => variant.kind === "const" && typeof variant.value === "string";
|
|
6
|
+
/** An untagged enum: the const strings as one `Literal` variant tried first, then each other variant. */
|
|
7
|
+
function untaggedDecl(name, union, { member, declare }) {
|
|
8
|
+
const values = stringValues(union.variants.filter(isLiteral).map((variant) => variant.value));
|
|
9
|
+
if (union.variants.every(isLiteral))
|
|
10
|
+
return stringEnumDecl(name, values);
|
|
11
|
+
const literal = { enum: values, kind: "scalar", type: "string" };
|
|
12
|
+
const variants = [
|
|
13
|
+
...(values.length > 0 ? [`Literal(${declare(literal, `${name}.literal`, `${name}Literal`)})`] : []),
|
|
14
|
+
...union.variants.flatMap((variant, i) => isLiteral(variant) ? [] : [`Variant${i}(${member(variant, `variant${i}`)})`]),
|
|
15
|
+
];
|
|
16
|
+
return [DERIVE, "#[serde(untagged)]", `pub enum ${name} {`, ...variants.map((v) => ` ${v},`), "}"].join("\n");
|
|
17
|
+
}
|
|
18
|
+
/** The discriminator values that select `variant`: its mapping keys, else its property's const or enum, else its name. */
|
|
19
|
+
function selectors(variant, { mapping, propertyName }, names) {
|
|
20
|
+
const mapped = variant.kind === "ref" && mapping ? Object.keys(mapping).filter((v) => mapping[v] === variant.name) : [];
|
|
21
|
+
if (mapped.length > 0)
|
|
22
|
+
return mapped;
|
|
23
|
+
const resolved = names.resolve(variant);
|
|
24
|
+
const property = resolved.kind === "object" ? resolved.fields.find((field) => field.name === propertyName)?.schema : undefined;
|
|
25
|
+
if (property?.kind === "const")
|
|
26
|
+
return [String(property.value)];
|
|
27
|
+
if (property?.kind === "scalar" && property.enum)
|
|
28
|
+
return stringValues(property.enum);
|
|
29
|
+
return variant.kind === "ref" ? [variant.name] : [];
|
|
30
|
+
}
|
|
31
|
+
/** One variant per ref or inline-object variant, named after its first value; any other variant has none. */
|
|
32
|
+
function variantsOf(name, union, scope) {
|
|
33
|
+
const variantNames = new NameScope(["Unknown"]);
|
|
34
|
+
const seen = new Set();
|
|
35
|
+
const fresh = (value) => {
|
|
36
|
+
const unseen = !seen.has(value);
|
|
37
|
+
seen.add(value);
|
|
38
|
+
return unseen;
|
|
39
|
+
};
|
|
40
|
+
return union.variants.flatMap((schema, i) => {
|
|
41
|
+
if (schema.kind !== "ref" && schema.kind !== "object")
|
|
42
|
+
return [];
|
|
43
|
+
const values = selectors(schema, union.discriminator, scope.names);
|
|
44
|
+
const type = schema.kind === "ref"
|
|
45
|
+
? scope.member(schema, `variant${i}`)
|
|
46
|
+
: scope.declare(schema, `${name}.variant${i}`, `${name}${rustTypeIdent(values[0] ?? `Variant${i}`)}`);
|
|
47
|
+
return [{ type, values: values.filter(fresh), variant: variantOf(values[0] ?? type, variantNames) }];
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** `Serialize` as the payload of whichever variant holds it. */
|
|
51
|
+
const serializeImpl = (name, variants) => [
|
|
52
|
+
`impl serde::Serialize for ${name} {`,
|
|
53
|
+
" fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {",
|
|
54
|
+
" match self {",
|
|
55
|
+
...[...variants.map((v) => v.variant), "Unknown"].map((variant) => ` Self::${variant}(value) => serde::Serialize::serialize(value, serializer),`),
|
|
56
|
+
" }",
|
|
57
|
+
" }",
|
|
58
|
+
"}",
|
|
59
|
+
];
|
|
60
|
+
/** `Deserialize` by the discriminator's value, the payload kept whole; any other value is `Unknown`. */
|
|
61
|
+
const deserializeImpl = (name, property, variants) => [
|
|
62
|
+
`impl<'de> serde::Deserialize<'de> for ${name} {`,
|
|
63
|
+
" fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {",
|
|
64
|
+
" let value = <serde_json::Value as serde::Deserialize>::deserialize(deserializer)?;",
|
|
65
|
+
` let decoded = match value.get(${rustString(property)}).and_then(serde_json::Value::as_str) {`,
|
|
66
|
+
...variants
|
|
67
|
+
.filter((v) => v.values.length > 0)
|
|
68
|
+
.map((v) => ` Some(${v.values.map(rustString).join(" | ")}) => serde_json::from_value(value).map(Self::${v.variant}),`),
|
|
69
|
+
" _ => Ok(Self::Unknown(value)),",
|
|
70
|
+
" };",
|
|
71
|
+
" decoded.map_err(serde::de::Error::custom)",
|
|
72
|
+
" }",
|
|
73
|
+
"}",
|
|
74
|
+
];
|
|
75
|
+
/** A discriminated enum and its hand-written serde impls; inline object variants are declared through `declare`. */
|
|
76
|
+
function discriminatedDecl(name, union, scope) {
|
|
77
|
+
const property = union.discriminator.propertyName;
|
|
78
|
+
const variants = variantsOf(name, union, scope);
|
|
79
|
+
return [
|
|
80
|
+
...lineComment(`${name} holds exactly one variant, selected by the "${property}" property.`, "///"),
|
|
81
|
+
"/// A value no variant declares deserializes to `Unknown`, the payload kept whole.",
|
|
82
|
+
"#[derive(Debug, Clone, PartialEq)]",
|
|
83
|
+
`pub enum ${name} {`,
|
|
84
|
+
...variants.map((v) => ` ${v.variant}(${v.type}),`),
|
|
85
|
+
" Unknown(serde_json::Value),",
|
|
86
|
+
"}",
|
|
87
|
+
"",
|
|
88
|
+
...serializeImpl(name, variants),
|
|
89
|
+
"",
|
|
90
|
+
...deserializeImpl(name, property, variants),
|
|
91
|
+
].join("\n");
|
|
92
|
+
}
|
|
93
|
+
/** The declaration of a union with at least one variant. */
|
|
94
|
+
export function unionDecl(name, union, scope) {
|
|
95
|
+
const { discriminator } = union;
|
|
96
|
+
return discriminator ? discriminatedDecl(name, { ...union, discriminator }, scope) : untaggedDecl(name, union, scope);
|
|
97
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust types from the IR alone (H2): the type at a use position, a component's top-level
|
|
3
|
+
* declaration, and the declarations both hoist into the context — a string or integer enum, a struct
|
|
4
|
+
* for every inline object, a string enum for a union's const strings. Spec text reaches the source
|
|
5
|
+
* only through the shared escape layer.
|
|
6
|
+
*/
|
|
7
|
+
import type { IR, IRSchema } from "../../ir/model.ts";
|
|
8
|
+
/** How component and hoisted names are claimed, and which components sit on a value cycle. */
|
|
9
|
+
export type RustTypeNames = {
|
|
10
|
+
/** the Rust type name of the component `name` */
|
|
11
|
+
ref(name: string): string;
|
|
12
|
+
/** a unique crate-level name for a hoisted declaration; one key always gets the same name */
|
|
13
|
+
hoist(key: string, base: string): string;
|
|
14
|
+
/** a unique crate-level name for any other declaration (a resource, an op's options) */
|
|
15
|
+
claim(base: string): string;
|
|
16
|
+
/** the components that reach themselves by value: a reference to one is a `Box` */
|
|
17
|
+
cyclic: ReadonlySet<string>;
|
|
18
|
+
/** each component emitted under another name than its own (`<Name>Model`), to its emitted name */
|
|
19
|
+
renamed: ReadonlyMap<string, string>;
|
|
20
|
+
resolve(schema: IRSchema): IRSchema;
|
|
21
|
+
};
|
|
22
|
+
/** Where a type is being written: its parent and field, the declarations it hoists, and the names. */
|
|
23
|
+
export type RustTypeContext = {
|
|
24
|
+
parentName: string;
|
|
25
|
+
fieldName: string;
|
|
26
|
+
decls: Map<string, string>;
|
|
27
|
+
names: RustTypeNames;
|
|
28
|
+
};
|
|
29
|
+
/** A context over `ir`'s components, or plain names without one. */
|
|
30
|
+
export declare function rustTypeContext(ir?: IR): RustTypeContext;
|
|
31
|
+
/** The Rust type of `ir` in use position; what it hoists lands in `at.decls`. */
|
|
32
|
+
export declare function rustTypeOf(ir: IRSchema, at: RustTypeContext): string;
|
|
33
|
+
/** The top-level declaration of the type `name` (a Rust identifier already) for `ir`. */
|
|
34
|
+
export declare function rustTopLevel(name: string, ir: IRSchema, at: RustTypeContext): string;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { pascalWords, rustTypeIdent } from "../shared/lang.js";
|
|
2
|
+
import { integerValues, intEnumDecl, stringEnumDecl, stringValues } from "./types-enum.js";
|
|
3
|
+
import { irNames, plainNames } from "./types-names.js";
|
|
4
|
+
import { allOfDecl, DERIVE, objectDecl, unboxed } from "./types-struct.js";
|
|
5
|
+
import { unionDecl } from "./types-union.js";
|
|
6
|
+
const VALUE = "serde_json::Value";
|
|
7
|
+
const MAP = "std::collections::HashMap";
|
|
8
|
+
/* deeper than this, a schema is any JSON value */
|
|
9
|
+
const MAX_DEPTH = 12;
|
|
10
|
+
const SCALARS = {
|
|
11
|
+
boolean: "bool",
|
|
12
|
+
integer: "i64",
|
|
13
|
+
null: VALUE,
|
|
14
|
+
number: "f64",
|
|
15
|
+
string: "String",
|
|
16
|
+
};
|
|
17
|
+
/** A context over `ir`'s components, or plain names without one. */
|
|
18
|
+
export function rustTypeContext(ir) {
|
|
19
|
+
return { decls: new Map(), fieldName: "", names: ir ? irNames(ir) : plainNames(), parentName: "" };
|
|
20
|
+
}
|
|
21
|
+
/** `ir` declared once as `names.hoist(key, base)` into `at.decls`; its name. */
|
|
22
|
+
function declare(ir, at, key, base) {
|
|
23
|
+
const name = at.names.hoist(key, base);
|
|
24
|
+
if (!at.decls.has(name)) {
|
|
25
|
+
/* claimed before its body: what the body hoists in turn comes after it */
|
|
26
|
+
at.decls.set(name, "");
|
|
27
|
+
at.decls.set(name, rustTopLevel(name, ir, at));
|
|
28
|
+
}
|
|
29
|
+
return name;
|
|
30
|
+
}
|
|
31
|
+
/** `ir` hoisted as `<Parent><Field>`. */
|
|
32
|
+
const hoist = (ir, at) => declare(ir, at, `${at.parentName}.${at.fieldName}`, `${rustTypeIdent(at.parentName)}${pascalWords(at.fieldName)}`);
|
|
33
|
+
const deeper = (at, fieldName = at.fieldName) => ({ ...at, depth: at.depth + 1, fieldName });
|
|
34
|
+
/** Whether a scalar is a string or integer enum with a value of its kind: a declared enum. */
|
|
35
|
+
const isEnum = (ir) => ir.enum !== undefined &&
|
|
36
|
+
(ir.type === "string" ? stringValues(ir.enum).length > 0 : ir.type === "integer" && integerValues(ir.enum).length > 0);
|
|
37
|
+
/** A const's Rust type: its value's, a declared `number` making an integral value f64. */
|
|
38
|
+
function constType({ type, value }) {
|
|
39
|
+
if (typeof value === "number")
|
|
40
|
+
return type === "number" || !Number.isInteger(value) ? "f64" : "i64";
|
|
41
|
+
return typeof value === "boolean" ? "bool" : "String";
|
|
42
|
+
}
|
|
43
|
+
function objectUse(ir, at) {
|
|
44
|
+
if (ir.fields.length > 0)
|
|
45
|
+
return hoist(ir, at);
|
|
46
|
+
if (ir.additional)
|
|
47
|
+
return `${MAP}<String, ${unboxed(ir.additional, use(ir.additional, deeper(at)))}>`;
|
|
48
|
+
return ir.additional === false ? VALUE : `${MAP}<String, ${VALUE}>`;
|
|
49
|
+
}
|
|
50
|
+
/** An allOf of one part is that part; of more, its first ref (the rest is not typed here), else any JSON value. */
|
|
51
|
+
function allOfUse(ir, at) {
|
|
52
|
+
const part = ir.parts.length === 1 ? ir.parts[0] : ir.parts.find((p) => p.kind === "ref");
|
|
53
|
+
return part === undefined ? VALUE : use(part, at);
|
|
54
|
+
}
|
|
55
|
+
function nullableUse(ir, at) {
|
|
56
|
+
const inner = use(ir.inner, deeper(at));
|
|
57
|
+
return inner === VALUE ? VALUE : `Option<${inner}>`;
|
|
58
|
+
}
|
|
59
|
+
function refUse(ir, at) {
|
|
60
|
+
const name = at.names.ref(ir.name);
|
|
61
|
+
return name === at.self || at.names.cyclic.has(ir.name) ? `Box<${name}>` : name;
|
|
62
|
+
}
|
|
63
|
+
const USES = {
|
|
64
|
+
allOf: allOfUse,
|
|
65
|
+
array: (ir, at) => `Vec<${unboxed(ir.items, use(ir.items, deeper(at, `${at.fieldName}Item`)))}>`,
|
|
66
|
+
binary: () => "String",
|
|
67
|
+
const: constType,
|
|
68
|
+
nullable: nullableUse,
|
|
69
|
+
object: objectUse,
|
|
70
|
+
ref: refUse,
|
|
71
|
+
scalar: (ir, at) => (isEnum(ir) ? hoist(ir, at) : SCALARS[ir.type]),
|
|
72
|
+
tuple: () => `Vec<${VALUE}>`,
|
|
73
|
+
/* a union in use position is any JSON value; a component union is declared as an enum */
|
|
74
|
+
union: () => VALUE,
|
|
75
|
+
unknown: () => VALUE,
|
|
76
|
+
};
|
|
77
|
+
function use(ir, at) {
|
|
78
|
+
return at.depth > MAX_DEPTH ? VALUE : USES[ir.kind](ir, at);
|
|
79
|
+
}
|
|
80
|
+
/** The Rust type of `ir` in use position; what it hoists lands in `at.decls`. */
|
|
81
|
+
export function rustTypeOf(ir, at) {
|
|
82
|
+
return use(ir, { ...at, depth: 0 });
|
|
83
|
+
}
|
|
84
|
+
/** The use positions inside the declaration of `name`. */
|
|
85
|
+
const memberOf = (name, at) => (schema, fieldName) => use(schema, { ...at, depth: 0, fieldName, parentName: name, self: name });
|
|
86
|
+
/** The top-level declaration of the type `name` (a Rust identifier already) for `ir`. */
|
|
87
|
+
export function rustTopLevel(name, ir, at) {
|
|
88
|
+
const member = memberOf(name, at);
|
|
89
|
+
if (ir.kind === "scalar" && isEnum(ir)) {
|
|
90
|
+
const values = ir.enum;
|
|
91
|
+
return ir.type === "string" ? stringEnumDecl(name, stringValues(values)) : intEnumDecl(name, integerValues(values));
|
|
92
|
+
}
|
|
93
|
+
if (ir.kind === "const")
|
|
94
|
+
return [DERIVE, `pub struct ${name}(pub ${constType(ir)});`].join("\n");
|
|
95
|
+
if (ir.kind === "allOf")
|
|
96
|
+
return allOfDecl(name, ir, member, at.names.ref);
|
|
97
|
+
/* a closed object without fields is a struct too: `{}` on the wire, where a map alias would admit any key */
|
|
98
|
+
if (ir.kind === "object" && (ir.fields.length > 0 || ir.additional === false))
|
|
99
|
+
return objectDecl(name, ir, member);
|
|
100
|
+
if (ir.kind === "union" && ir.variants.length > 0) {
|
|
101
|
+
const variant = (schema, key, base) => declare(schema, at, key, base);
|
|
102
|
+
return unionDecl(name, ir, { declare: variant, member, names: at.names });
|
|
103
|
+
}
|
|
104
|
+
return `pub type ${name} = ${member(ir, "Value")};`;
|
|
105
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A WebSocket operation's answer (contract 20 §2.0, §2.2): `TypedWebSocket`, dialed offering the Opts'
|
|
3
|
+
* `protocols`, its Opts' `reconnect_token` sent as one query param only when set and non-empty; a declared
|
|
4
|
+
* `reconnect_token` query param is folded into that field (Fd3).
|
|
5
|
+
*/
|
|
6
|
+
import type { OptsField, StreamAnswer } from "./sdk-opts.ts";
|
|
7
|
+
/** The resume cursor's token, which the WebSocket and realtime Opts carry. */
|
|
8
|
+
export declare const RECONNECT_TOKEN: {
|
|
9
|
+
ident: string;
|
|
10
|
+
type: string;
|
|
11
|
+
};
|
|
12
|
+
/** The subprotocols a WebSocket or realtime dial offers. */
|
|
13
|
+
export declare const PROTOCOLS: {
|
|
14
|
+
doc: string;
|
|
15
|
+
ident: string;
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
/** Whether a declared param is the `reconnect_token` query param, the resume channel a socket dial sends. */
|
|
19
|
+
export declare const isReconnectToken: (param: string, where: OptsField["in"]) => boolean;
|
|
20
|
+
/** A WebSocket operation's answer. */
|
|
21
|
+
export declare const wsAnswer: () => StreamAnswer;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** The resume cursor's token, which the WebSocket and realtime Opts carry. */
|
|
2
|
+
export const RECONNECT_TOKEN = { ident: "reconnect_token", type: "Option<String>" };
|
|
3
|
+
/** The subprotocols a WebSocket or realtime dial offers. */
|
|
4
|
+
export const PROTOCOLS = { doc: "The subprotocols the dial offers.", ident: "protocols", type: "Vec<String>" };
|
|
5
|
+
/** Whether a declared param is the `reconnect_token` query param, the resume channel a socket dial sends. */
|
|
6
|
+
export const isReconnectToken = (param, where) => where === "query" && param === "reconnect_token";
|
|
7
|
+
/* reconnect_token, sent only when set: an empty cursor names no position */
|
|
8
|
+
const WS = {
|
|
9
|
+
carries: isReconnectToken,
|
|
10
|
+
fields: [RECONNECT_TOKEN, PROTOCOLS],
|
|
11
|
+
sends: ['spec.query("reconnect_token", &crate::request::cursor(&opts.reconnect_token));'],
|
|
12
|
+
};
|
|
13
|
+
const DOC = "Resolves once the socket is open: a refused handshake with an error status is `Err(Error::Api)`. `cancel_on` ends its reads quietly; dropping it closes it.";
|
|
14
|
+
/** A WebSocket operation's answer. */
|
|
15
|
+
export const wsAnswer = () => ({
|
|
16
|
+
doc: DOC,
|
|
17
|
+
run: "crate::ws::dial(opts.protocols.clone())",
|
|
18
|
+
stream: WS,
|
|
19
|
+
type: "TypedWebSocket",
|
|
20
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one string-escape layer (F2): the only way spec text becomes source in any emitted SDK.
|
|
3
|
+
* Every target's string literal comes from one escaper with a per-target policy, and every
|
|
4
|
+
* comment from one comment-text filter; both are fuzzed against readers written from each
|
|
5
|
+
* language's grammar and cross-checked with the real compilers.
|
|
6
|
+
*/
|
|
7
|
+
export type Target = "csharp" | "go" | "java" | "python" | "rust" | "ts";
|
|
8
|
+
/** `text` with each unpaired UTF-16 surrogate as U+FFFD: no target can carry a lone surrogate to the wire. */
|
|
9
|
+
export declare function wellFormed(text: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* C1 and the bidi controls: unseen, or reordering what an editor shows (Trojan Source, CVE-2021-42574). Every
|
|
12
|
+
* literal writes them as an escape and every comment shows them as `\uXXXX`, so spec text reads as it runs.
|
|
13
|
+
*/
|
|
14
|
+
export declare const invisible: (cp: number) => boolean;
|
|
15
|
+
/** The body of a `"…"` literal of `text` for `target`: the single escaper every writer goes through. */
|
|
16
|
+
export declare function escapeText(text: string, target: Target): string;
|
|
17
|
+
/** A double-quoted string literal of `text` in `target`'s syntax. */
|
|
18
|
+
export declare function stringLiteral(text: string, target: Target): string;
|
|
19
|
+
export declare const tsString: (text: string) => string;
|
|
20
|
+
export declare const goString: (text: string) => string;
|
|
21
|
+
export declare const rustString: (text: string) => string;
|
|
22
|
+
export declare const pyString: (text: string) => string;
|
|
23
|
+
export declare const csString: (text: string) => string;
|
|
24
|
+
export declare const javaString: (text: string) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Text for a comment or docstring: well-formed, with each character a compiler refuses even in a
|
|
27
|
+
* comment (Go and Python refuse NUL, Go a BOM), and each C1 or bidi control, shown as visible
|
|
28
|
+
* `\uXXXX`. Tab and line breaks stay; the comment writers split lines themselves.
|
|
29
|
+
*/
|
|
30
|
+
export declare function commentText(text: string): string;
|
|
31
|
+
/** Comment lines of `text` behind `marker` (`//`, `///`, `#`): each line break in it starts a new comment line. */
|
|
32
|
+
export declare function lineComment(text: string, marker: string, indent?: string): string[];
|
|
33
|
+
/** Text that stays inside a `/* … *\/` comment. */
|
|
34
|
+
export declare function blockCommentText(text: string): string;
|
|
35
|
+
/** Docstring body lines: backslashes and quotes escaped, so `"""`, a trailing `"` and `C:\users` are inert. */
|
|
36
|
+
export declare function pyDocLines(text: string): string[];
|
|
37
|
+
/**
|
|
38
|
+
* XML doc text lines (C#'s `///`): split at every line break, `&`, `<` and `>` as entities, and U+FFFE and U+FFFF,
|
|
39
|
+
* which XML forbids, shown as `\uXXXX` (CS1570 otherwise).
|
|
40
|
+
*/
|
|
41
|
+
export declare function csDocLines(text: string): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Comment text for Java: javac turns an eligible `\uXXXX` into its character in ANY source text before it lexes
|
|
44
|
+
* (JLS 3.3), comments included, so `\u000a` in a comment would end it and a bare `\u` would not compile. Each run of
|
|
45
|
+
* backslashes before a `u` is doubled, which leaves none of them eligible; `commentText` then shows the hidden
|
|
46
|
+
* characters as escapes it means javac to read.
|
|
47
|
+
*/
|
|
48
|
+
export declare const javaCommentText: (text: string) => string;
|
|
49
|
+
/** Java `//` lines of `text`: each line break starts a new line, the `\u` rule kept. */
|
|
50
|
+
export declare function javaLineComment(text: string, indent?: string): string[];
|
|
51
|
+
/**
|
|
52
|
+
* Javadoc body lines, unprefixed: split at every line break, `*\/` and `/*` broken so the comment never closes or
|
|
53
|
+
* nests, and an `@` that would open a tag (at a line's start, or as `{@`) written `@`, the `\u` rule kept.
|
|
54
|
+
*/
|
|
55
|
+
export declare function javaDocLines(text: string): string[];
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one string-escape layer (F2): the only way spec text becomes source in any emitted SDK.
|
|
3
|
+
* Every target's string literal comes from one escaper with a per-target policy, and every
|
|
4
|
+
* comment from one comment-text filter; both are fuzzed against readers written from each
|
|
5
|
+
* language's grammar and cross-checked with the real compilers.
|
|
6
|
+
*/
|
|
7
|
+
/** `text` with each unpaired UTF-16 surrogate as U+FFFD: no target can carry a lone surrogate to the wire. */
|
|
8
|
+
export function wellFormed(text) {
|
|
9
|
+
return text.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "\uFFFD");
|
|
10
|
+
}
|
|
11
|
+
const hex = (cp, width) => cp.toString(16).padStart(width, "0");
|
|
12
|
+
/**
|
|
13
|
+
* C1 and the bidi controls: unseen, or reordering what an editor shows (Trojan Source, CVE-2021-42574). Every
|
|
14
|
+
* literal writes them as an escape and every comment shows them as `\uXXXX`, so spec text reads as it runs.
|
|
15
|
+
*/
|
|
16
|
+
export const invisible = (cp) => (cp >= 0x80 && cp <= 0x9f) ||
|
|
17
|
+
cp === 0x061c ||
|
|
18
|
+
cp === 0x200e ||
|
|
19
|
+
cp === 0x200f ||
|
|
20
|
+
(cp >= 0x202a && cp <= 0x202e) ||
|
|
21
|
+
(cp >= 0x2066 && cp <= 0x2069);
|
|
22
|
+
/* the escapes every target spells alike */
|
|
23
|
+
const NAMED = { 0x09: "\\t", 0x0a: "\\n", 0x0d: "\\r", 0x22: '\\"', 0x5c: "\\\\" };
|
|
24
|
+
const POLICIES = {
|
|
25
|
+
/* C#'s \x takes one to four hex digits, so it is never written: \uHHHH, fixed width, for every escape */
|
|
26
|
+
csharp: (cp) => cp < 0x20 || cp === 0x7f || cp === 0x2028 || cp === 0x2029 || cp === 0xfeff || invisible(cp)
|
|
27
|
+
? `\\u${hex(cp, 4)}`
|
|
28
|
+
: null,
|
|
29
|
+
go: (cp) => {
|
|
30
|
+
if (cp < 0x20 || cp === 0x7f)
|
|
31
|
+
return `\\x${hex(cp, 2)}`;
|
|
32
|
+
return cp === 0xfeff || invisible(cp) ? `\\u${hex(cp, 4)}` : null;
|
|
33
|
+
},
|
|
34
|
+
/* Java has no \x: \uHHHH for every other control, DEL and the BOM. The apostrophe stays raw: javac takes it in
|
|
35
|
+
* "…", and the backslash's own escape keeps every \u in the text from becoming one (JLS 3.3) */
|
|
36
|
+
java: (cp) => (cp < 0x20 || cp === 0x7f || cp === 0xfeff || invisible(cp) ? `\\u${hex(cp, 4)}` : null),
|
|
37
|
+
python: (cp) => {
|
|
38
|
+
if (cp < 0x20 || cp === 0x7f)
|
|
39
|
+
return `\\x${hex(cp, 2)}`;
|
|
40
|
+
/* line separators and the BOM read as line ends or vanish in some tools: never raw */
|
|
41
|
+
return cp === 0x2028 || cp === 0x2029 || cp === 0xfeff || invisible(cp) ? `\\u${hex(cp, 4)}` : null;
|
|
42
|
+
},
|
|
43
|
+
rust: (cp) => {
|
|
44
|
+
if (cp === 0)
|
|
45
|
+
return "\\0";
|
|
46
|
+
return cp < 0x20 || cp === 0x7f || cp === 0xfeff || invisible(cp) ? `\\u{${hex(cp, 2)}}` : null;
|
|
47
|
+
},
|
|
48
|
+
ts: (cp) => {
|
|
49
|
+
if (cp === 0x08)
|
|
50
|
+
return "\\b";
|
|
51
|
+
if (cp === 0x0c)
|
|
52
|
+
return "\\f";
|
|
53
|
+
return cp < 0x20 || cp === 0x7f || cp === 0x2028 || cp === 0x2029 || cp === 0xfeff || invisible(cp)
|
|
54
|
+
? `\\u${hex(cp, 4)}`
|
|
55
|
+
: null;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
/** The body of a `"…"` literal of `text` for `target`: the single escaper every writer goes through. */
|
|
59
|
+
export function escapeText(text, target) {
|
|
60
|
+
const policy = POLICIES[target];
|
|
61
|
+
let out = "";
|
|
62
|
+
for (const ch of wellFormed(text)) {
|
|
63
|
+
const cp = ch.codePointAt(0);
|
|
64
|
+
out += NAMED[cp] ?? policy(cp) ?? ch;
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
/** A double-quoted string literal of `text` in `target`'s syntax. */
|
|
69
|
+
export function stringLiteral(text, target) {
|
|
70
|
+
return `"${escapeText(text, target)}"`;
|
|
71
|
+
}
|
|
72
|
+
export const tsString = (text) => stringLiteral(text, "ts");
|
|
73
|
+
export const goString = (text) => stringLiteral(text, "go");
|
|
74
|
+
export const rustString = (text) => stringLiteral(text, "rust");
|
|
75
|
+
export const pyString = (text) => stringLiteral(text, "python");
|
|
76
|
+
export const csString = (text) => stringLiteral(text, "csharp");
|
|
77
|
+
export const javaString = (text) => stringLiteral(text, "java");
|
|
78
|
+
/**
|
|
79
|
+
* Text for a comment or docstring: well-formed, with each character a compiler refuses even in a
|
|
80
|
+
* comment (Go and Python refuse NUL, Go a BOM), and each C1 or bidi control, shown as visible
|
|
81
|
+
* `\uXXXX`. Tab and line breaks stay; the comment writers split lines themselves.
|
|
82
|
+
*/
|
|
83
|
+
export function commentText(text) {
|
|
84
|
+
let out = "";
|
|
85
|
+
for (const ch of wellFormed(text)) {
|
|
86
|
+
const cp = ch.codePointAt(0);
|
|
87
|
+
const hidden = (cp < 0x20 && cp !== 0x09 && cp !== 0x0a && cp !== 0x0d) || cp === 0x7f || cp === 0xfeff || invisible(cp);
|
|
88
|
+
out += hidden ? `\\u${hex(cp, 4)}` : ch;
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
/* every line break a comment writer splits at: a C# or JS lexer ends a line at U+2028 and U+2029 too (U+0085, C1,
|
|
93
|
+
never reaches a writer raw: commentText shows it) */
|
|
94
|
+
const LINE_BREAKS = /\r\n|\r|\n|\u2028|\u2029/;
|
|
95
|
+
/** Comment lines of `text` behind `marker` (`//`, `///`, `#`): each line break in it starts a new comment line. */
|
|
96
|
+
export function lineComment(text, marker, indent = "") {
|
|
97
|
+
return commentText(text)
|
|
98
|
+
.split(LINE_BREAKS)
|
|
99
|
+
.map((line) => (line.trim() === "" ? `${indent}${marker}` : `${indent}${marker} ${line}`));
|
|
100
|
+
}
|
|
101
|
+
/** Text that stays inside a `/* … *\/` comment. */
|
|
102
|
+
export function blockCommentText(text) {
|
|
103
|
+
return commentText(text).replace(/\*\//g, "* /").replace(/\/\*/g, "/ *");
|
|
104
|
+
}
|
|
105
|
+
/** Docstring body lines: backslashes and quotes escaped, so `"""`, a trailing `"` and `C:\users` are inert. */
|
|
106
|
+
export function pyDocLines(text) {
|
|
107
|
+
return commentText(text)
|
|
108
|
+
.split(LINE_BREAKS)
|
|
109
|
+
.map((line) => line.replace(/\\/g, "\\\\").replace(/"/g, '\\"'));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* XML doc text lines (C#'s `///`): split at every line break, `&`, `<` and `>` as entities, and U+FFFE and U+FFFF,
|
|
113
|
+
* which XML forbids, shown as `\uXXXX` (CS1570 otherwise).
|
|
114
|
+
*/
|
|
115
|
+
export function csDocLines(text) {
|
|
116
|
+
return commentText(text)
|
|
117
|
+
.replace(/[\uFFFE\uFFFF]/g, (ch) => `\\u${hex(ch.codePointAt(0), 4)}`)
|
|
118
|
+
.split(LINE_BREAKS)
|
|
119
|
+
.map((line) => line.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Comment text for Java: javac turns an eligible `\uXXXX` into its character in ANY source text before it lexes
|
|
123
|
+
* (JLS 3.3), comments included, so `\u000a` in a comment would end it and a bare `\u` would not compile. Each run of
|
|
124
|
+
* backslashes before a `u` is doubled, which leaves none of them eligible; `commentText` then shows the hidden
|
|
125
|
+
* characters as escapes it means javac to read.
|
|
126
|
+
*/
|
|
127
|
+
export const javaCommentText = (text) => commentText(wellFormed(text).replace(/\\+(?=u)/g, (run) => run + run));
|
|
128
|
+
/** Java `//` lines of `text`: each line break starts a new line, the `\u` rule kept. */
|
|
129
|
+
export function javaLineComment(text, indent = "") {
|
|
130
|
+
return javaCommentText(text)
|
|
131
|
+
.split(LINE_BREAKS)
|
|
132
|
+
.map((line) => (line.trim() === "" ? `${indent}//` : `${indent}// ${line}`));
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Javadoc body lines, unprefixed: split at every line break, `*\/` and `/*` broken so the comment never closes or
|
|
136
|
+
* nests, and an `@` that would open a tag (at a line's start, or as `{@`) written `@`, the `\u` rule kept.
|
|
137
|
+
*/
|
|
138
|
+
export function javaDocLines(text) {
|
|
139
|
+
return javaCommentText(text)
|
|
140
|
+
.replace(/\*\//g, "* /")
|
|
141
|
+
.replace(/\/\*/g, "/ *")
|
|
142
|
+
.split(LINE_BREAKS)
|
|
143
|
+
.map((line) => line.replace(/^(\s*)@/, "$1@").replace(/\{@/g, "{@"));
|
|
144
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The post-pass over emitted files (F4), dispatched by file extension: oxfmt for TypeScript, each
|
|
3
|
+
* later target's formatter beside it. gen never imports a formatter; the caller passes the ones that
|
|
4
|
+
* resolve (optional peers, like ts-morph for extract). Without one a file goes out as emitted, which
|
|
5
|
+
* is already valid source.
|
|
6
|
+
*/
|
|
7
|
+
/** The oxfmt options emitted code is formatted with: honey's own style. */
|
|
8
|
+
export type FormatOptions = {
|
|
9
|
+
readonly printWidth: number;
|
|
10
|
+
readonly semi: boolean;
|
|
11
|
+
readonly useTabs: boolean;
|
|
12
|
+
};
|
|
13
|
+
/** A formatter as the post-pass calls it: oxfmt's `format`, or another target's adapted to it. */
|
|
14
|
+
export type Formatter = (fileName: string, source: string, options: FormatOptions) => Promise<{
|
|
15
|
+
code: string;
|
|
16
|
+
errors: readonly unknown[];
|
|
17
|
+
}>;
|
|
18
|
+
export declare const EMIT_STYLE: FormatOptions;
|
|
19
|
+
/** The formatters that resolved, by the file extension they format (`ts`). */
|
|
20
|
+
export type Formatters = {
|
|
21
|
+
readonly [extension: string]: Formatter;
|
|
22
|
+
};
|
|
23
|
+
/** `files`, each run through the formatter for its extension; a file without one as it is. */
|
|
24
|
+
export declare function formatFiles(files: Readonly<Record<string, string>>, formatters: Formatters): Promise<Record<string, string>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The post-pass over emitted files (F4), dispatched by file extension: oxfmt for TypeScript, each
|
|
3
|
+
* later target's formatter beside it. gen never imports a formatter; the caller passes the ones that
|
|
4
|
+
* resolve (optional peers, like ts-morph for extract). Without one a file goes out as emitted, which
|
|
5
|
+
* is already valid source.
|
|
6
|
+
*/
|
|
7
|
+
export const EMIT_STYLE = { printWidth: 120, semi: false, useTabs: true };
|
|
8
|
+
/** `files`, each run through the formatter for its extension; a file without one as it is. */
|
|
9
|
+
export async function formatFiles(files, formatters) {
|
|
10
|
+
const out = { ...files };
|
|
11
|
+
for (const [name, text] of Object.entries(files)) {
|
|
12
|
+
const extension = name.slice(name.lastIndexOf(".") + 1);
|
|
13
|
+
const formatter = Object.hasOwn(formatters, extension) ? formatters[extension] : undefined;
|
|
14
|
+
if (formatter === undefined)
|
|
15
|
+
continue;
|
|
16
|
+
const { code, errors } = await formatter(name, text, EMIT_STYLE);
|
|
17
|
+
/* an emitter wrote text that does not parse: a bug to surface, never a file to write */
|
|
18
|
+
if (errors.length > 0)
|
|
19
|
+
throw new Error(`could not format ${name}: ${JSON.stringify(errors[0])}`);
|
|
20
|
+
out[name] = code;
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Go post-pass (R2): gofmt as a `Formatter` for `formatFiles`. gen never chooses a Go — the
|
|
3
|
+
* caller passes the gofmt binary of the toolchain it pins (in tests, go-env's `gofmtPath()`), so the
|
|
4
|
+
* format is the same wherever it runs. gofmt ignores `options`: Go has one canonical layout.
|
|
5
|
+
*/
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
/** A formatter that pipes a file through `gofmt`; a parse error or a gofmt that cannot run is an error. */
|
|
8
|
+
export function gofmtFormatter(gofmt) {
|
|
9
|
+
return (_fileName, source) => new Promise((resolve) => {
|
|
10
|
+
const child = spawn(gofmt, [], { stdio: ["pipe", "pipe", "pipe"] });
|
|
11
|
+
let stdout = "";
|
|
12
|
+
let stderr = "";
|
|
13
|
+
child.stdout.setEncoding("utf8").on("data", (chunk) => {
|
|
14
|
+
stdout += chunk;
|
|
15
|
+
});
|
|
16
|
+
child.stderr.setEncoding("utf8").on("data", (chunk) => {
|
|
17
|
+
stderr += chunk;
|
|
18
|
+
});
|
|
19
|
+
child.on("error", (error) => resolve({ code: source, errors: [error.message] }));
|
|
20
|
+
child.on("close", (status) => resolve(status === 0 ? { code: stdout, errors: [] } : { code: source, errors: [stderr.trim()] }));
|
|
21
|
+
child.stdin.on("error", () => {
|
|
22
|
+
/* a gofmt that never started: its spawn error answers */
|
|
23
|
+
});
|
|
24
|
+
child.stdin.end(source);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 declare function compareCodeUnits(a: string, b: string): number;
|
|
7
|
+
/** The ASCII alphanumeric words of `raw`: `user-id`, `user_id` and `userId` are all [user, id]. */
|
|
8
|
+
export declare function words(raw: string): string[];
|
|
9
|
+
/** The words joined PascalCase, each keeping its inner case: `user-id` → `UserId`, `getHTTP` → `GetHTTP`. */
|
|
10
|
+
export declare function pascalWords(raw: string): string;
|
|
11
|
+
/** The words joined snake_case, lower case: `userId` → `user_id`. */
|
|
12
|
+
export declare function snakeWords(raw: string): string;
|
|
13
|
+
/** The words joined camelCase: `user-id` → `userId`. */
|
|
14
|
+
export declare function camelWords(raw: string): string;
|
|
15
|
+
/** A record's entries in code-unit order by key: the same on every machine. */
|
|
16
|
+
export declare function sortedEntries<V>(record: Readonly<Record<string, V>>): [string, V][];
|
|
17
|
+
/** Hands out unique names in one scope; a taken name gets the next numeric suffix, in claim order. */
|
|
18
|
+
export declare class NameScope {
|
|
19
|
+
#private;
|
|
20
|
+
/** `fold` maps names that would clash in the target (a case-insensitive file system, say) to one key. */
|
|
21
|
+
constructor(reserved?: Iterable<string>, fold?: (name: string) => string);
|
|
22
|
+
has(name: string): boolean;
|
|
23
|
+
reserve(name: string): void;
|
|
24
|
+
/** `base`, else `base2`, `base3`… whichever is free first; it is taken from then on. */
|
|
25
|
+
claim(base: string): string;
|
|
26
|
+
}
|
|
27
|
+
/** A `NameScope` that remembers: one raw key always gets the name it was first given. */
|
|
28
|
+
export declare class NameTable {
|
|
29
|
+
#private;
|
|
30
|
+
constructor(reserved?: Iterable<string>, fold?: (name: string) => string);
|
|
31
|
+
get(key: string, base: string): string;
|
|
32
|
+
}
|
|
33
|
+
/** An exported Go identifier: `user-id` → `UserId`, `2fa` → `N2fa`, nothing → `X`. */
|
|
34
|
+
export declare function goExported(raw: string): string;
|
|
35
|
+
/** An unexported Go identifier (a local, a parameter); a keyword, predeclared or imported name gets `_`. */
|
|
36
|
+
export declare function goLocal(raw: string): string;
|
|
37
|
+
/** A snake_case Rust value identifier: a keyword becomes a raw identifier, or gets `_` where it cannot be one. */
|
|
38
|
+
export declare function rustValueIdent(raw: string): string;
|
|
39
|
+
/** Like `rustValueIdent`, never a raw identifier: for names joined into other names. */
|
|
40
|
+
export declare function rustPlainSnake(raw: string): string;
|
|
41
|
+
/** A PascalCase Rust type or variant identifier. */
|
|
42
|
+
export declare function rustTypeIdent(raw: string): string;
|
|
43
|
+
/** Whether a generated Rust type named `name` would shadow a prelude or std name. */
|
|
44
|
+
export declare function isRustPreludeType(name: string): boolean;
|
|
45
|
+
/** A snake_case Python identifier; a keyword or reserved name gets `_` (PEP 8). */
|
|
46
|
+
export declare function pyIdentifier(raw: string): string;
|
|
47
|
+
/** A PascalCase Python class name. */
|
|
48
|
+
export declare function pyClassName(raw: string): string;
|
|
49
|
+
/** Whether `name` is one of Java's keywords, literals or restricted type identifiers: no bare identifier may be one. */
|
|
50
|
+
export declare const isJavaReserved: (name: string) => boolean;
|
|
51
|
+
/** A camelCase Java identifier (a parameter, a local): a keyword suffixed `_`, a digit first `_`, nothing `value`. */
|
|
52
|
+
export declare function javaIdentifier(raw: string): string;
|
|
53
|
+
/** A PascalCase Java type name: a digit first `N`, nothing `Value`; no keyword is PascalCase. */
|
|
54
|
+
export declare function javaTypeName(raw: string): string;
|
|
55
|
+
/** A camelCase C# identifier (a parameter, a local): a keyword `@`-escaped, a digit first `_`, nothing `value`. */
|
|
56
|
+
export declare function csIdentifier(raw: string): string;
|
|
57
|
+
/** Whether `name` is one of C#'s reserved keywords: no namespace segment or bare identifier may be one. */
|
|
58
|
+
export declare function isCsReserved(name: string): boolean;
|
|
59
|
+
/** A PascalCase C# type or member name: a digit first `N`, nothing `Value`; no keyword is PascalCase. */
|
|
60
|
+
export declare function csTypeName(raw: string): string;
|