@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,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* google-java-format's expression layouts, ported (bit 21 i7a; JavaInputAstVisitor): each expression the emitter
|
|
3
|
+
* writes emits the ops GJF's visitor emits for it. Arguments (addArguments, argList, a format string's first argument
|
|
4
|
+
* apart), `new`, array initializers, a lambda, a binary (its operands filled when all are short), an assignment, a
|
|
5
|
+
* method reference, a conditional and a parameterized type; a dot chain is layout-dot.ts's.
|
|
6
|
+
*/
|
|
7
|
+
import { id, refuse } from "./layout-ast.js";
|
|
8
|
+
import { Builder } from "./layout-doc.js";
|
|
9
|
+
import { dot } from "./layout-dot.js";
|
|
10
|
+
const isString = (e) => e.k === "lit" && e.text.startsWith('"');
|
|
11
|
+
/** The ops of each expression, as GJF's visitor emits them. */
|
|
12
|
+
export class Visitor {
|
|
13
|
+
b;
|
|
14
|
+
constructor(b) {
|
|
15
|
+
this.b = b;
|
|
16
|
+
}
|
|
17
|
+
kinds = {
|
|
18
|
+
array: (e) => this.newArray(e),
|
|
19
|
+
assign: (e) => this.infix(e.to, "=", e.value),
|
|
20
|
+
bin: (e) => this.binary(e),
|
|
21
|
+
call: (e) => dot(this, e),
|
|
22
|
+
cond: (e) => {
|
|
23
|
+
this.b.open(4);
|
|
24
|
+
this.expr(e.test);
|
|
25
|
+
for (const [mark, arm] of [
|
|
26
|
+
["?", e.yes],
|
|
27
|
+
[":", e.no],
|
|
28
|
+
]) {
|
|
29
|
+
this.b.breakOp(" ");
|
|
30
|
+
this.b.token(mark);
|
|
31
|
+
this.b.space();
|
|
32
|
+
this.expr(arm);
|
|
33
|
+
}
|
|
34
|
+
this.b.close();
|
|
35
|
+
},
|
|
36
|
+
id: (e) => this.b.token(e.name),
|
|
37
|
+
lambda: (e) => this.lambda(e),
|
|
38
|
+
lit: (e) => this.b.literal(e.text),
|
|
39
|
+
new: (e) => this.newClass(e),
|
|
40
|
+
ref: (e) => {
|
|
41
|
+
this.b.open(4);
|
|
42
|
+
this.expr(e.of);
|
|
43
|
+
this.b.breakOp();
|
|
44
|
+
this.b.token("::");
|
|
45
|
+
this.b.token(e.name);
|
|
46
|
+
this.b.close();
|
|
47
|
+
},
|
|
48
|
+
sel: (e) => dot(this, e),
|
|
49
|
+
};
|
|
50
|
+
expr(e) {
|
|
51
|
+
const lay = this.kinds[e.k];
|
|
52
|
+
if (lay === undefined)
|
|
53
|
+
refuse(`a ${e.k} expression`);
|
|
54
|
+
lay(e);
|
|
55
|
+
}
|
|
56
|
+
/** `e` on one line, as its source reads: GJF's measure of an item's length. */
|
|
57
|
+
flat(e) {
|
|
58
|
+
const b = new Builder();
|
|
59
|
+
new Visitor(b).expr(e);
|
|
60
|
+
return b.flat();
|
|
61
|
+
}
|
|
62
|
+
/* hasOnlyShortItems: every item under MAX_ITEM_LENGTH_FOR_FILLING (10) characters */
|
|
63
|
+
shortItems(items) {
|
|
64
|
+
return items.every((item) => this.flat(item).length < 10);
|
|
65
|
+
}
|
|
66
|
+
/** visitAssignment: `to =`, a unified break, the value. */
|
|
67
|
+
infix(to, op, value) {
|
|
68
|
+
this.b.open(4);
|
|
69
|
+
this.expr(to);
|
|
70
|
+
this.b.space();
|
|
71
|
+
this.b.token(op);
|
|
72
|
+
this.b.breakOp(" ");
|
|
73
|
+
this.expr(value);
|
|
74
|
+
this.b.close();
|
|
75
|
+
}
|
|
76
|
+
/** visitParameterizedType, visitArrayType; a dotted name is a member select (visitDot). */
|
|
77
|
+
type(t) {
|
|
78
|
+
const dims = t.dims > 0;
|
|
79
|
+
if (dims)
|
|
80
|
+
this.b.open(4);
|
|
81
|
+
if (t.args.length === 0)
|
|
82
|
+
this.typeName(t.name);
|
|
83
|
+
else {
|
|
84
|
+
this.b.open(4);
|
|
85
|
+
this.typeName(t.name);
|
|
86
|
+
this.b.token("<");
|
|
87
|
+
this.b.breakOp();
|
|
88
|
+
this.b.open(0);
|
|
89
|
+
t.args.forEach((arg, i) => {
|
|
90
|
+
if (i > 0) {
|
|
91
|
+
this.b.token(",");
|
|
92
|
+
this.b.breakOp(" ");
|
|
93
|
+
}
|
|
94
|
+
this.type(arg);
|
|
95
|
+
});
|
|
96
|
+
this.b.close();
|
|
97
|
+
this.b.close();
|
|
98
|
+
this.b.token(">");
|
|
99
|
+
}
|
|
100
|
+
if (dims) {
|
|
101
|
+
for (let i = 0; i < t.dims; i += 1)
|
|
102
|
+
this.b.token("[]");
|
|
103
|
+
this.b.close();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** A type's or an annotation's name: a dotted one is a member select. */
|
|
107
|
+
typeName(name) {
|
|
108
|
+
const path = id(name);
|
|
109
|
+
if (path.k === "sel")
|
|
110
|
+
dot(this, path);
|
|
111
|
+
else
|
|
112
|
+
this.b.token(name);
|
|
113
|
+
}
|
|
114
|
+
/** addArguments: `(`, a break, the argument list; a format string's first argument apart (isFormatMethod). */
|
|
115
|
+
args(args, indent) {
|
|
116
|
+
this.b.open(indent);
|
|
117
|
+
this.b.token("(");
|
|
118
|
+
const first = args[0];
|
|
119
|
+
if (first !== undefined && args.length >= 2 && isString(first) && /%|\{[0-9]\}/.test(this.flat(first))) {
|
|
120
|
+
this.b.breakOp();
|
|
121
|
+
this.b.open(0);
|
|
122
|
+
this.expr(first);
|
|
123
|
+
this.b.token(",");
|
|
124
|
+
this.b.breakOp(" ");
|
|
125
|
+
this.b.open(0);
|
|
126
|
+
this.argList(args.slice(1));
|
|
127
|
+
this.b.close();
|
|
128
|
+
this.b.close();
|
|
129
|
+
}
|
|
130
|
+
else if (first !== undefined) {
|
|
131
|
+
this.b.breakOp();
|
|
132
|
+
this.argList(args);
|
|
133
|
+
}
|
|
134
|
+
this.b.token(")");
|
|
135
|
+
this.b.close();
|
|
136
|
+
}
|
|
137
|
+
argList(args) {
|
|
138
|
+
this.b.open(0);
|
|
139
|
+
const fill = this.shortItems(args) ? "independent" : "unified";
|
|
140
|
+
args.forEach((arg, i) => {
|
|
141
|
+
if (i > 0) {
|
|
142
|
+
this.b.token(",");
|
|
143
|
+
this.b.brk(fill, " ");
|
|
144
|
+
}
|
|
145
|
+
this.expr(arg);
|
|
146
|
+
});
|
|
147
|
+
this.b.close();
|
|
148
|
+
}
|
|
149
|
+
/** visitNewClass: `new T(args)`, an empty anonymous body after it. */
|
|
150
|
+
newClass(e) {
|
|
151
|
+
this.b.open(0);
|
|
152
|
+
this.b.token("new");
|
|
153
|
+
this.b.space();
|
|
154
|
+
this.type(e.type);
|
|
155
|
+
this.args(e.args, 4);
|
|
156
|
+
this.b.close();
|
|
157
|
+
if (e.body) {
|
|
158
|
+
this.b.space();
|
|
159
|
+
this.b.token("{}");
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** visitNewArray: `new T[]` and the initializer, or the bare initializer. */
|
|
163
|
+
newArray(e) {
|
|
164
|
+
if (e.type !== null) {
|
|
165
|
+
this.b.open(4);
|
|
166
|
+
this.b.token("new");
|
|
167
|
+
this.b.space();
|
|
168
|
+
this.type({ ...e.type, dims: 0 });
|
|
169
|
+
this.b.open(0);
|
|
170
|
+
for (let i = 0; i < e.type.dims; i += 1)
|
|
171
|
+
this.b.token("[]");
|
|
172
|
+
this.b.close();
|
|
173
|
+
this.b.close();
|
|
174
|
+
this.b.space();
|
|
175
|
+
}
|
|
176
|
+
this.arrayInit(e.items);
|
|
177
|
+
}
|
|
178
|
+
/** visitArrayInitializer, its plain form: `{`, the items (filled when all are short), `}`. */
|
|
179
|
+
arrayInit(items) {
|
|
180
|
+
if (items.length === 0) {
|
|
181
|
+
this.b.token("{");
|
|
182
|
+
this.b.token("}");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const fill = this.shortItems(items) ? "independent" : "unified";
|
|
186
|
+
this.b.open(2);
|
|
187
|
+
this.b.token("{");
|
|
188
|
+
this.b.breakOp();
|
|
189
|
+
this.b.open(0);
|
|
190
|
+
items.forEach((item, i) => {
|
|
191
|
+
if (i > 0) {
|
|
192
|
+
this.b.token(",");
|
|
193
|
+
this.b.brk(fill, " ");
|
|
194
|
+
}
|
|
195
|
+
this.expr(item);
|
|
196
|
+
});
|
|
197
|
+
this.b.close();
|
|
198
|
+
this.b.breakOp("", -2);
|
|
199
|
+
this.b.close();
|
|
200
|
+
this.b.token("}");
|
|
201
|
+
}
|
|
202
|
+
/** visitLambdaExpression with one parameter and an expression body: `param ->`, a unified break, the body at +4. */
|
|
203
|
+
lambda(e) {
|
|
204
|
+
this.b.open(0);
|
|
205
|
+
this.b.token(e.param);
|
|
206
|
+
this.b.close();
|
|
207
|
+
this.b.space();
|
|
208
|
+
this.b.token("->");
|
|
209
|
+
this.b.open(4);
|
|
210
|
+
this.b.breakOp(" ");
|
|
211
|
+
this.expr(e.body);
|
|
212
|
+
this.b.close();
|
|
213
|
+
}
|
|
214
|
+
/** visitBinary: one precedence's operands, a break before each operator; StringWrapper's chain marked. */
|
|
215
|
+
binary(e) {
|
|
216
|
+
const fill = this.shortItems(e.operands) ? "independent" : "unified";
|
|
217
|
+
this.b.open(4);
|
|
218
|
+
this.expr(e.operands[0]);
|
|
219
|
+
e.operands.slice(1).forEach((operand, i) => {
|
|
220
|
+
this.b.brk(fill, " ");
|
|
221
|
+
this.b.token(e.op);
|
|
222
|
+
this.b.space();
|
|
223
|
+
/* a literal in a `+` after a non-literal operand reflows under its own quote */
|
|
224
|
+
const later = e.op === "+" && isString(operand) && !e.operands.slice(0, i + 1).every(isString);
|
|
225
|
+
if (later)
|
|
226
|
+
this.b.literal(this.flat(operand), true);
|
|
227
|
+
else
|
|
228
|
+
this.expr(operand);
|
|
229
|
+
});
|
|
230
|
+
this.b.close();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Java line breaking (bit 21 i7a): google-java-format 1.37's layout, ported, so every emitted statement and header is
|
|
3
|
+
* GJF's canonical form at any name length, a name past the width included. The emitter builds nodes (layout-ast.ts),
|
|
4
|
+
* never text it then re-lays: each function here takes nodes and gives the lines. The engine is layout-doc.ts
|
|
5
|
+
* (GJF's Doc and DocBuilder), the visitor layout-visitor.ts, layout-dot.ts and layout-decl.ts (JavaInputAstVisitor),
|
|
6
|
+
* and a long string literal is reflowed as StringWrapper reflows it (layout-strings.ts).
|
|
7
|
+
*/
|
|
8
|
+
import { type Annotation, type Declaration, type Expr, type MethodHeader, type TypeHeader } from "./layout-ast.ts";
|
|
9
|
+
export { type Annotation, array, assign, bin, call, classOf, type Component, cond, type Declaration, type Expr, id, lambda, lit, type MethodHeader, newOf, param, ref, type TypeHeader, } from "./layout-ast.ts";
|
|
10
|
+
/** A statement the emitter writes; an `if` or a `for` ends at its `{`, a switch rule at its `;`. */
|
|
11
|
+
export type Statement = {
|
|
12
|
+
readonly k: "expr";
|
|
13
|
+
readonly expr: Expr;
|
|
14
|
+
} | {
|
|
15
|
+
readonly k: "return";
|
|
16
|
+
readonly expr: Expr;
|
|
17
|
+
} | {
|
|
18
|
+
readonly k: "throw";
|
|
19
|
+
readonly expr: Expr;
|
|
20
|
+
} | {
|
|
21
|
+
readonly k: "local";
|
|
22
|
+
readonly decl: Declaration;
|
|
23
|
+
} | {
|
|
24
|
+
readonly k: "if";
|
|
25
|
+
readonly cond: Expr;
|
|
26
|
+
} | {
|
|
27
|
+
readonly k: "for";
|
|
28
|
+
readonly type: string;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly of: Expr;
|
|
31
|
+
} | {
|
|
32
|
+
readonly k: "rule";
|
|
33
|
+
readonly label: Expr | null;
|
|
34
|
+
readonly value: Expr;
|
|
35
|
+
};
|
|
36
|
+
/** `s`'s lines at `indent` columns, as google-java-format lays them out. */
|
|
37
|
+
export declare const statement: (indent: number, s: Statement) => string[];
|
|
38
|
+
/** Shorthands for the statements. */
|
|
39
|
+
export declare const exprStmt: (e: Expr) => Statement;
|
|
40
|
+
export declare const returnStmt: (e: Expr | string) => Statement;
|
|
41
|
+
export declare const throwStmt: (e: Expr) => Statement;
|
|
42
|
+
export declare const local: (decl: Declaration) => Statement;
|
|
43
|
+
export declare const ifOpen: (test: Expr) => Statement;
|
|
44
|
+
export declare const forOpen: (of: string, name: string, iterable: Expr) => Statement;
|
|
45
|
+
export declare const rule: (label: Expr | null, value: Expr) => Statement;
|
|
46
|
+
/** A field declaration at `indent`. */
|
|
47
|
+
export declare const field: (indent: number, d: Declaration) => string[];
|
|
48
|
+
/** A method's or constructor's header at `indent`, through its ` {`. */
|
|
49
|
+
export declare const methodHeader: (indent: number, m: MethodHeader) => string[];
|
|
50
|
+
/** A single annotation on its own line at `indent`. */
|
|
51
|
+
export declare const annotationLine: (indent: number, a: Annotation) => string[];
|
|
52
|
+
/** An enum constant at `indent`: its name, and its argument as addArguments lays it; `trailing` closes it. */
|
|
53
|
+
export declare const enumConstant: (indent: number, name: string, arg: Expr | string, trailing: string) => string[];
|
|
54
|
+
/** A type declaration's header at `indent`, through its `{` (or `{}`). */
|
|
55
|
+
export declare const typeHeader: (indent: number, h: TypeHeader) => string[];
|
|
56
|
+
/** A class's header: `public final class Name {`. */
|
|
57
|
+
export declare const classHeader: (name: string) => string[];
|
|
58
|
+
/** `private final Type name;`. */
|
|
59
|
+
export declare const finalField: (of: string, name: string) => string[];
|
|
60
|
+
/** An accessor: `public Type name() { return name; }`. */
|
|
61
|
+
export declare const accessor: (of: string, name: string) => string[];
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Java line breaking (bit 21 i7a): google-java-format 1.37's layout, ported, so every emitted statement and header is
|
|
3
|
+
* GJF's canonical form at any name length, a name past the width included. The emitter builds nodes (layout-ast.ts),
|
|
4
|
+
* never text it then re-lays: each function here takes nodes and gives the lines. The engine is layout-doc.ts
|
|
5
|
+
* (GJF's Doc and DocBuilder), the visitor layout-visitor.ts, layout-dot.ts and layout-decl.ts (JavaInputAstVisitor),
|
|
6
|
+
* and a long string literal is reflowed as StringWrapper reflows it (layout-strings.ts).
|
|
7
|
+
*/
|
|
8
|
+
import { expr } from "./layout-ast.js";
|
|
9
|
+
import { annotation, declareOne, method } from "./layout-decl.js";
|
|
10
|
+
import { Builder } from "./layout-doc.js";
|
|
11
|
+
import { wrapStrings } from "./layout-strings.js";
|
|
12
|
+
import { typeDeclaration } from "./layout-types.js";
|
|
13
|
+
import { Visitor } from "./layout-visitor.js";
|
|
14
|
+
export { array, assign, bin, call, classOf, cond, id, lambda, lit, newOf, param, ref, } from "./layout-ast.js";
|
|
15
|
+
/** The doc `build` writes, laid out at `indent` columns, its long literals reflowed, as its lines. */
|
|
16
|
+
function laid(indent, build) {
|
|
17
|
+
const b = new Builder();
|
|
18
|
+
build(new Visitor(b));
|
|
19
|
+
return wrapStrings(b.laid(indent))
|
|
20
|
+
.split("\n")
|
|
21
|
+
.map((line) => line.trimEnd());
|
|
22
|
+
}
|
|
23
|
+
const STATEMENTS = {
|
|
24
|
+
expr: (v, s) => {
|
|
25
|
+
v.expr(s.expr);
|
|
26
|
+
v.b.token(";");
|
|
27
|
+
},
|
|
28
|
+
for: (v, s) => {
|
|
29
|
+
/* visitEnhancedForLoop: the variable declared with `:` before its iterable */
|
|
30
|
+
v.b.open(0);
|
|
31
|
+
v.b.token("for");
|
|
32
|
+
v.b.space();
|
|
33
|
+
v.b.token("(");
|
|
34
|
+
v.b.open(0);
|
|
35
|
+
declareOne(v, { init: s.of, name: s.name, type: s.type }, { equals: ":", kind: "variable" });
|
|
36
|
+
v.b.close();
|
|
37
|
+
v.b.token(")");
|
|
38
|
+
v.b.close();
|
|
39
|
+
v.b.space();
|
|
40
|
+
v.b.token("{");
|
|
41
|
+
},
|
|
42
|
+
if: (v, s) => {
|
|
43
|
+
v.b.open(0);
|
|
44
|
+
v.b.token("if");
|
|
45
|
+
v.b.space();
|
|
46
|
+
v.b.token("(");
|
|
47
|
+
v.expr(s.cond);
|
|
48
|
+
v.b.token(")");
|
|
49
|
+
v.b.space();
|
|
50
|
+
v.b.token("{");
|
|
51
|
+
v.b.close();
|
|
52
|
+
},
|
|
53
|
+
local: (v, s) => declareOne(v, s.decl, { kind: "variable", trailing: ";" }),
|
|
54
|
+
return: (v, s) => keyword(v, "return", s.expr),
|
|
55
|
+
rule: (v, s) => {
|
|
56
|
+
/* visitCase, a rule: `case label ->` or `default ->`, a unified break, the value at +4 */
|
|
57
|
+
v.b.open(4);
|
|
58
|
+
if (s.label === null)
|
|
59
|
+
v.b.token("default");
|
|
60
|
+
else {
|
|
61
|
+
v.b.token("case");
|
|
62
|
+
v.b.open(0);
|
|
63
|
+
v.b.space();
|
|
64
|
+
v.expr(s.label);
|
|
65
|
+
v.b.close();
|
|
66
|
+
}
|
|
67
|
+
v.b.space();
|
|
68
|
+
v.b.token("->");
|
|
69
|
+
v.b.breakOp(" ");
|
|
70
|
+
v.expr(s.value);
|
|
71
|
+
v.b.close();
|
|
72
|
+
v.b.token(";");
|
|
73
|
+
},
|
|
74
|
+
throw: (v, s) => keyword(v, "throw", s.expr),
|
|
75
|
+
};
|
|
76
|
+
/** visitReturn and visitThrow: the word, the expression after a space, `;`. */
|
|
77
|
+
function keyword(v, word, e) {
|
|
78
|
+
v.b.token(word);
|
|
79
|
+
v.b.space();
|
|
80
|
+
v.expr(e);
|
|
81
|
+
v.b.token(";");
|
|
82
|
+
}
|
|
83
|
+
/** `s`'s lines at `indent` columns, as google-java-format lays them out. */
|
|
84
|
+
export const statement = (indent, s) => laid(indent, (v) => STATEMENTS[s.k](v, s));
|
|
85
|
+
/** Shorthands for the statements. */
|
|
86
|
+
export const exprStmt = (e) => ({ expr: e, k: "expr" });
|
|
87
|
+
export const returnStmt = (e) => ({ expr: expr(e), k: "return" });
|
|
88
|
+
export const throwStmt = (e) => ({ expr: e, k: "throw" });
|
|
89
|
+
export const local = (decl) => ({ decl, k: "local" });
|
|
90
|
+
export const ifOpen = (test) => ({ cond: test, k: "if" });
|
|
91
|
+
export const forOpen = (of, name, iterable) => ({
|
|
92
|
+
k: "for",
|
|
93
|
+
name,
|
|
94
|
+
of: iterable,
|
|
95
|
+
type: of,
|
|
96
|
+
});
|
|
97
|
+
export const rule = (label, value) => ({ k: "rule", label, value });
|
|
98
|
+
/** A field declaration at `indent`. */
|
|
99
|
+
export const field = (indent, d) => laid(indent, (v) => declareOne(v, d, { kind: "variable", trailing: ";" }));
|
|
100
|
+
/** A method's or constructor's header at `indent`, through its ` {`. */
|
|
101
|
+
export const methodHeader = (indent, m) => laid(indent, (v) => method(v, m));
|
|
102
|
+
/** A single annotation on its own line at `indent`. */
|
|
103
|
+
export const annotationLine = (indent, a) => laid(indent, (v) => annotation(v, a));
|
|
104
|
+
/** An enum constant at `indent`: its name, and its argument as addArguments lays it; `trailing` closes it. */
|
|
105
|
+
export const enumConstant = (indent, name, arg, trailing) => laid(indent, (v) => {
|
|
106
|
+
v.b.token(name);
|
|
107
|
+
v.args([expr(arg)], 4);
|
|
108
|
+
v.b.token(trailing);
|
|
109
|
+
});
|
|
110
|
+
/** A type declaration's header at `indent`, through its `{` (or `{}`). */
|
|
111
|
+
export const typeHeader = (indent, h) => laid(indent, (v) => typeDeclaration(v, h));
|
|
112
|
+
/** A class's header: `public final class Name {`. */
|
|
113
|
+
export const classHeader = (name) => typeHeader(0, { end: "{", kind: "class", modifiers: ["public", "final"], name });
|
|
114
|
+
/** `private final Type name;`. */
|
|
115
|
+
export const finalField = (of, name) => field(2, { modifiers: ["private", "final"], name, type: of });
|
|
116
|
+
/** An accessor: `public Type name() { return name; }`. */
|
|
117
|
+
export const accessor = (of, name) => [
|
|
118
|
+
...methodHeader(2, { modifiers: ["public"], name, params: [], returns: of }),
|
|
119
|
+
...statement(4, returnStmt(name)),
|
|
120
|
+
" }",
|
|
121
|
+
];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Java enums (bit 16 phase b, B2): a string `enum` is a Java `enum` with `@JsonProperty` on each constant, the constant
|
|
3
|
+
* named by a sanitized wire value (words in UPPER_SNAKE, `""` is EMPTY, a digit first is N, a repeat takes `…2`). An
|
|
4
|
+
* integer `enum` has an `L<n>` or `Neg<n>` constant per value, read by `@JsonCreator` and written by `@JsonValue`
|
|
5
|
+
* (json.ts). A value past the int range takes an `L` suffix, as a Java long literal must.
|
|
6
|
+
*/
|
|
7
|
+
import type { IRSchema } from "../../ir/model.ts";
|
|
8
|
+
type Scalar = Extract<IRSchema, {
|
|
9
|
+
kind: "scalar";
|
|
10
|
+
}>;
|
|
11
|
+
/** The values a string or integer enum declares, each once: a value of another kind has no member. */
|
|
12
|
+
export declare function enumValues(ir: Scalar): (number | string)[];
|
|
13
|
+
/** `public enum <name>` of a string enum: one `@JsonProperty` constant per value, in order. */
|
|
14
|
+
export declare function stringEnumDecl(name: string, values: readonly string[]): string;
|
|
15
|
+
/** The enum `name` of the string or integer enum `ir`. */
|
|
16
|
+
export declare function enumDecl(name: string, ir: Scalar): string;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { javaString } from "../shared/escape.js";
|
|
2
|
+
import { NameScope, words } from "../shared/lang.js";
|
|
3
|
+
import { intEnumJsonLines } from "./json.js";
|
|
4
|
+
import { annotationLine, enumConstant, typeHeader } from "./layout.js";
|
|
5
|
+
const INT_MIN = -2147483648;
|
|
6
|
+
const INT_MAX = 2147483647;
|
|
7
|
+
/** The values a string or integer enum declares, each once: a value of another kind has no member. */
|
|
8
|
+
export function enumValues(ir) {
|
|
9
|
+
const values = ir.enum ?? [];
|
|
10
|
+
const kept = ir.type === "string"
|
|
11
|
+
? values.filter((value) => typeof value === "string")
|
|
12
|
+
: values.filter((value) => ir.type === "integer" && Number.isSafeInteger(value));
|
|
13
|
+
return [...new Set(kept)];
|
|
14
|
+
}
|
|
15
|
+
/** A string enum constant's base name: `""` is EMPTY, a value with no letter or digit VALUE, a digit first N. */
|
|
16
|
+
function constantOf(value) {
|
|
17
|
+
if (value === "")
|
|
18
|
+
return "EMPTY";
|
|
19
|
+
const word = words(value)
|
|
20
|
+
.map((part) => part.toUpperCase())
|
|
21
|
+
.join("_");
|
|
22
|
+
if (word === "")
|
|
23
|
+
return "VALUE";
|
|
24
|
+
return /^[0-9]/.test(word) ? `N${word}` : word;
|
|
25
|
+
}
|
|
26
|
+
/** `public enum <name>` of a string enum: one `@JsonProperty` constant per value, in order. */
|
|
27
|
+
export function stringEnumDecl(name, values) {
|
|
28
|
+
const scope = new NameScope();
|
|
29
|
+
const members = values.map((value) => [javaString(value), scope.claim(constantOf(value))]);
|
|
30
|
+
const constants = members.flatMap(([wire, constant], i) => [
|
|
31
|
+
...annotationLine(2, { args: [wire], name: "JsonProperty" }),
|
|
32
|
+
` ${constant}${i < members.length - 1 ? "," : ""}`,
|
|
33
|
+
]);
|
|
34
|
+
return [...enumHeader(name), ...constants, "}"].join("\n");
|
|
35
|
+
}
|
|
36
|
+
/** An integer value's constant: `L<n>`, or `Neg<n>` below zero. */
|
|
37
|
+
/** `public enum Name {`. */
|
|
38
|
+
const enumHeader = (name) => typeHeader(0, { end: "{", kind: "enum", modifiers: ["public"], name });
|
|
39
|
+
const label = (value) => `${value < 0 ? "Neg" : "L"}${String(Math.abs(value))}`;
|
|
40
|
+
/** An integer value as a Java `long` literal: a `L` suffix past the int range. */
|
|
41
|
+
const literal = (value) => (value >= INT_MIN && value <= INT_MAX ? String(value) : `${value}L`);
|
|
42
|
+
/** `public enum <name>` of an integer enum: one constant per value, then the `long` value and its JSON creator. */
|
|
43
|
+
function intEnumDecl(name, values) {
|
|
44
|
+
const constants = values.flatMap((value, i) => enumConstant(2, label(value), literal(value), i < values.length - 1 ? "," : ";"));
|
|
45
|
+
return [...enumHeader(name), ...constants, ...intEnumJsonLines(name), "}"].join("\n");
|
|
46
|
+
}
|
|
47
|
+
/** The enum `name` of the string or integer enum `ir`. */
|
|
48
|
+
export function enumDecl(name, ir) {
|
|
49
|
+
const values = enumValues(ir);
|
|
50
|
+
return ir.type === "string" ? stringEnumDecl(name, values) : intEnumDecl(name, values);
|
|
51
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { IR, IRSchema } from "../../ir/model.ts";
|
|
2
|
+
import type { Rename } from "../shared/mirror.ts";
|
|
3
|
+
/** The type a value without a schema is, and the one a nullable open value is. */
|
|
4
|
+
export declare const JSON_NODE = "JsonNode";
|
|
5
|
+
/** How component, hoisted and other declared names are claimed, and which schema a ref to a non-declaring component is. */
|
|
6
|
+
export type JavaTypeNames = {
|
|
7
|
+
/** the Java name of the component `name` */
|
|
8
|
+
ref(name: string): string;
|
|
9
|
+
/** a unique name for a hoisted declaration; one key always gets the same name */
|
|
10
|
+
hoist(key: string, base: string): string;
|
|
11
|
+
/** the schema of the component `name` when Java declares nothing for it, so a ref to it is its use type */
|
|
12
|
+
alias(name: string): IRSchema | undefined;
|
|
13
|
+
resolve(schema: IRSchema): IRSchema;
|
|
14
|
+
/** each component emitted under another name than its own (`<Name>Model`), for the generation's notices */
|
|
15
|
+
readonly renamed: readonly Rename[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The code text a scan reads: comments dropped and string and char literals emptied, in one left-to-right pass, so a
|
|
19
|
+
* `//` inside a string opens no comment and a quote inside a comment opens no string.
|
|
20
|
+
*/
|
|
21
|
+
export declare const codeOf: (code: string) => string;
|
|
22
|
+
/** The type names `code` spells: each imported type by its simple name, and each capitalized identifier that is not a member access. */
|
|
23
|
+
export declare function spelledIn(code: string): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Names for an SDK of the components `schemas` with `taken` reserved besides (its client): each component Java declares
|
|
26
|
+
* claims its name in code-unit order, as `<Name>Model` when it is taken; hoists and other declarations claim after
|
|
27
|
+
* them. A component `declares` nothing for is an alias, and one `schemas` lacks is any JSON value.
|
|
28
|
+
*/
|
|
29
|
+
export declare function javaNames(schemas: IR["schemas"], taken: readonly string[], declares: (ir: IRSchema) => boolean): JavaTypeNames;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Java names types are declared under (bit 16 phase b, B3): one scope that components and hoisted types claim from,
|
|
3
|
+
* clear of the runtime's own types (scanned from every file of src/runtime/java, as C#'s runtime names are), the types
|
|
4
|
+
* the emitted models and client spell (listed in SPELLED: no runtime file holds them), and `taken`. A component whose
|
|
5
|
+
* name is taken is `<Name>Model`; a later claim of a taken name is `…2`. An unspelled java.lang name is kept.
|
|
6
|
+
*/
|
|
7
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
8
|
+
import { irResolver } from "../../ir/schema.js";
|
|
9
|
+
import { compareCodeUnits, javaTypeName, NameScope } from "../shared/lang.js";
|
|
10
|
+
/** The type a value without a schema is, and the one a nullable open value is. */
|
|
11
|
+
export const JSON_NODE = "JsonNode";
|
|
12
|
+
/* the type names the emitted models and the client spell, which no runtime file holds: each is reserved */
|
|
13
|
+
const SPELLED = [
|
|
14
|
+
"Boolean",
|
|
15
|
+
"Builder",
|
|
16
|
+
"DeserializationContext",
|
|
17
|
+
"Deserializer",
|
|
18
|
+
"Double",
|
|
19
|
+
"IllegalArgumentException",
|
|
20
|
+
"IllegalStateException",
|
|
21
|
+
"JsonAnyGetter",
|
|
22
|
+
"JsonAnySetter",
|
|
23
|
+
"JsonCreator",
|
|
24
|
+
"JsonDeserialize",
|
|
25
|
+
"JsonInclude",
|
|
26
|
+
"JsonNode",
|
|
27
|
+
"JsonParser",
|
|
28
|
+
"JsonProperty",
|
|
29
|
+
"JsonValue",
|
|
30
|
+
"List",
|
|
31
|
+
"Long",
|
|
32
|
+
"Map",
|
|
33
|
+
"Override",
|
|
34
|
+
"StdDeserializer",
|
|
35
|
+
"String",
|
|
36
|
+
"URI",
|
|
37
|
+
];
|
|
38
|
+
/**
|
|
39
|
+
* The code text a scan reads: comments dropped and string and char literals emptied, in one left-to-right pass, so a
|
|
40
|
+
* `//` inside a string opens no comment and a quote inside a comment opens no string.
|
|
41
|
+
*/
|
|
42
|
+
export const codeOf = (code) => code.replace(/\/\*[\s\S]*?\*\/|\/\/.*$|"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)'/gm, (token) => token.startsWith("/") ? "" : token[0] === '"' ? '""' : "''");
|
|
43
|
+
/** The type names `code` spells: each imported type by its simple name, and each capitalized identifier that is not a member access. */
|
|
44
|
+
export function spelledIn(code) {
|
|
45
|
+
const text = codeOf(code);
|
|
46
|
+
const imported = [...text.matchAll(/^import [\w.]*\.(\w+);/gm)].map((match) => match[1]);
|
|
47
|
+
const bare = [...text.matchAll(/(?<![.\w])[A-Z][A-Za-z0-9]*\b/g)].map((match) => match[0]);
|
|
48
|
+
return [...imported, ...bare];
|
|
49
|
+
}
|
|
50
|
+
/** The names every file of the vendored runtime spells, read on every call. */
|
|
51
|
+
const runtimeSpelled = () => {
|
|
52
|
+
const dir = new URL("../../runtime/java/", import.meta.url);
|
|
53
|
+
return readdirSync(dir)
|
|
54
|
+
.filter((file) => file.endsWith(".java"))
|
|
55
|
+
.flatMap((file) => spelledIn(readFileSync(new URL(file, dir), "utf8")));
|
|
56
|
+
};
|
|
57
|
+
const UNKNOWN = { kind: "unknown" };
|
|
58
|
+
/**
|
|
59
|
+
* Names for an SDK of the components `schemas` with `taken` reserved besides (its client): each component Java declares
|
|
60
|
+
* claims its name in code-unit order, as `<Name>Model` when it is taken; hoists and other declarations claim after
|
|
61
|
+
* them. A component `declares` nothing for is an alias, and one `schemas` lacks is any JSON value.
|
|
62
|
+
*/
|
|
63
|
+
export function javaNames(schemas, taken, declares) {
|
|
64
|
+
const scope = new NameScope([...runtimeSpelled(), ...SPELLED, ...taken]);
|
|
65
|
+
const components = new Map();
|
|
66
|
+
const renamed = [];
|
|
67
|
+
for (const name of Object.keys(schemas)
|
|
68
|
+
.sort(compareCodeUnits)
|
|
69
|
+
.filter((n) => declares(schemas[n]))) {
|
|
70
|
+
const base = javaTypeName(name);
|
|
71
|
+
const taken = scope.has(base);
|
|
72
|
+
components.set(name, scope.claim(taken ? `${base}Model` : base));
|
|
73
|
+
if (taken)
|
|
74
|
+
renamed.push({
|
|
75
|
+
because: `"${base}" is a name the SDK's runtime, the JDK or another declaration holds`,
|
|
76
|
+
name,
|
|
77
|
+
renamed: components.get(name),
|
|
78
|
+
what: "component",
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const hoisted = new Map();
|
|
82
|
+
return {
|
|
83
|
+
alias: (name) => {
|
|
84
|
+
const schema = schemas[name] ?? UNKNOWN;
|
|
85
|
+
return declares(schema) ? undefined : schema;
|
|
86
|
+
},
|
|
87
|
+
hoist: (key, base) => {
|
|
88
|
+
const name = hoisted.get(key) ?? scope.claim(base);
|
|
89
|
+
hoisted.set(key, name);
|
|
90
|
+
return name;
|
|
91
|
+
},
|
|
92
|
+
/* a ref reaches here only for a declared component: `alias` answers for every other one */
|
|
93
|
+
ref: (name) => components.get(name),
|
|
94
|
+
renamed,
|
|
95
|
+
resolve: irResolver(schemas),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Java records (bit 16 phase b, B2): a `public record` of components in code-unit order of the JSON key, each under
|
|
3
|
+
* `@JsonProperty("<wire>")`. A required field is its type, primitive for an integer, number or boolean that is not
|
|
4
|
+
* nullable; an optional one is `@JsonInclude(NON_NULL) T`; an optional and nullable one is `@JsonInclude(NON_EMPTY)
|
|
5
|
+
* Opt<T>`, three states; an open value is JsonNode, already tri-state beside NON_NULL. A component named like an Object
|
|
6
|
+
* or Record member, a keyword or a literal claims `…2`. An allOf is one record of its parts' fields, a key once, its
|
|
7
|
+
* first part's. An object that declares `additionalProperties` beside its fields keeps every other member in
|
|
8
|
+
* `@JsonAnySetter @JsonAnyGetter Map<String, JsonNode>`, claimed after the fields. The header is laid out as
|
|
9
|
+
* google-java-format lays a record's (layout.ts).
|
|
10
|
+
*/
|
|
11
|
+
import type { IRField, IRSchema } from "../../ir/model.ts";
|
|
12
|
+
import type { JavaTypeContext, Member } from "./models.ts";
|
|
13
|
+
export declare const RECORD_MEMBERS: readonly string[];
|
|
14
|
+
/** A record's members: its fields, and whether it keeps every other member (it declares `additionalProperties`). */
|
|
15
|
+
export type RecordShape = {
|
|
16
|
+
readonly fields: readonly IRField[];
|
|
17
|
+
readonly open: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** Whether an object, or any object part of an allOf (refs followed), declares `additionalProperties`. */
|
|
20
|
+
export declare function isOpen(schema: IRSchema, resolve: (schema: IRSchema) => IRSchema): boolean;
|
|
21
|
+
/** A schema's fields: an object's own, an allOf's merged (each ref followed, a key once, its first part's), else none. */
|
|
22
|
+
export declare function fieldsOf(schema: IRSchema, resolve: (schema: IRSchema) => IRSchema): IRField[];
|
|
23
|
+
/** `public record <name>` of its fields in key order, then any map of the other members. */
|
|
24
|
+
export declare function recordDecl(name: string, { fields, open }: RecordShape, member: Member, at: JavaTypeContext): string;
|