@workerstack/clients 0.0.0-stage → 1.0.0-rc.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +619 -2
- package/bin/honey-clients.js +94 -0
- package/dist/cli.d.ts +102 -0
- package/dist/cli.js +190 -0
- package/dist/emit/cli/channels.d.ts +73 -0
- package/dist/emit/cli/channels.js +197 -0
- package/dist/emit/cli/commands.d.ts +27 -0
- package/dist/emit/cli/commands.js +187 -0
- package/dist/emit/cli/discovery.d.ts +35 -0
- package/dist/emit/cli/discovery.js +202 -0
- package/dist/emit/cli/flags.d.ts +59 -0
- package/dist/emit/cli/flags.js +186 -0
- package/dist/emit/cli/index.d.ts +1 -0
- package/dist/emit/cli/index.js +1 -0
- package/dist/emit/cli/install.d.ts +37 -0
- package/dist/emit/cli/install.js +88 -0
- package/dist/emit/cli/layout.d.ts +23 -0
- package/dist/emit/cli/layout.js +118 -0
- package/dist/emit/cli/module.d.ts +30 -0
- package/dist/emit/cli/module.js +186 -0
- package/dist/emit/cli/release.d.ts +40 -0
- package/dist/emit/cli/release.js +183 -0
- package/dist/emit/cli/skills.d.ts +11 -0
- package/dist/emit/cli/skills.js +56 -0
- package/dist/emit/csharp/errors.d.ts +7 -0
- package/dist/emit/csharp/errors.js +69 -0
- package/dist/emit/csharp/index.d.ts +1 -0
- package/dist/emit/csharp/index.js +1 -0
- package/dist/emit/csharp/json.d.ts +13 -0
- package/dist/emit/csharp/json.js +113 -0
- package/dist/emit/csharp/realtime.d.ts +10 -0
- package/dist/emit/csharp/realtime.js +33 -0
- package/dist/emit/csharp/sdk-answer.d.ts +48 -0
- package/dist/emit/csharp/sdk-answer.js +85 -0
- package/dist/emit/csharp/sdk-body.d.ts +10 -0
- package/dist/emit/csharp/sdk-body.js +87 -0
- package/dist/emit/csharp/sdk-client.d.ts +32 -0
- package/dist/emit/csharp/sdk-client.js +177 -0
- package/dist/emit/csharp/sdk-csproj.d.ts +36 -0
- package/dist/emit/csharp/sdk-csproj.js +136 -0
- package/dist/emit/csharp/sdk-doc.d.ts +12 -0
- package/dist/emit/csharp/sdk-doc.js +35 -0
- package/dist/emit/csharp/sdk-method.d.ts +26 -0
- package/dist/emit/csharp/sdk-method.js +187 -0
- package/dist/emit/csharp/sdk-plan.d.ts +38 -0
- package/dist/emit/csharp/sdk-plan.js +1 -0
- package/dist/emit/csharp/sdk.d.ts +40 -0
- package/dist/emit/csharp/sdk.js +105 -0
- package/dist/emit/csharp/sse.d.ts +18 -0
- package/dist/emit/csharp/sse.js +29 -0
- package/dist/emit/csharp/transport.d.ts +11 -0
- package/dist/emit/csharp/transport.js +67 -0
- package/dist/emit/csharp/types-enum.d.ts +19 -0
- package/dist/emit/csharp/types-enum.js +63 -0
- package/dist/emit/csharp/types-names.d.ts +33 -0
- package/dist/emit/csharp/types-names.js +182 -0
- package/dist/emit/csharp/types-record.d.ts +25 -0
- package/dist/emit/csharp/types-record.js +65 -0
- package/dist/emit/csharp/types-union.d.ts +27 -0
- package/dist/emit/csharp/types-union.js +113 -0
- package/dist/emit/csharp/types.d.ts +36 -0
- package/dist/emit/csharp/types.js +126 -0
- package/dist/emit/csharp/ws.d.ts +20 -0
- package/dist/emit/csharp/ws.js +14 -0
- package/dist/emit/go/errors.d.ts +7 -0
- package/dist/emit/go/errors.js +44 -0
- package/dist/emit/go/http.d.ts +11 -0
- package/dist/emit/go/http.js +50 -0
- package/dist/emit/go/index.d.ts +1 -0
- package/dist/emit/go/index.js +1 -0
- package/dist/emit/go/module-path.d.ts +2 -0
- package/dist/emit/go/module-path.js +27 -0
- package/dist/emit/go/sdk-answer.d.ts +28 -0
- package/dist/emit/go/sdk-answer.js +41 -0
- package/dist/emit/go/sdk-body.d.ts +24 -0
- package/dist/emit/go/sdk-body.js +76 -0
- package/dist/emit/go/sdk-client.d.ts +29 -0
- package/dist/emit/go/sdk-client.js +141 -0
- package/dist/emit/go/sdk-method.d.ts +68 -0
- package/dist/emit/go/sdk-method.js +172 -0
- package/dist/emit/go/sdk-mirror.d.ts +23 -0
- package/dist/emit/go/sdk-mirror.js +97 -0
- package/dist/emit/go/sdk-opts.d.ts +55 -0
- package/dist/emit/go/sdk-opts.js +100 -0
- package/dist/emit/go/sdk.d.ts +26 -0
- package/dist/emit/go/sdk.js +111 -0
- package/dist/emit/go/sse.d.ts +16 -0
- package/dist/emit/go/sse.js +26 -0
- package/dist/emit/go/types-codec.d.ts +15 -0
- package/dist/emit/go/types-codec.js +171 -0
- package/dist/emit/go/types-names.d.ts +14 -0
- package/dist/emit/go/types-names.js +64 -0
- package/dist/emit/go/types-struct.d.ts +29 -0
- package/dist/emit/go/types-struct.js +65 -0
- package/dist/emit/go/types-union.d.ts +17 -0
- package/dist/emit/go/types-union.js +84 -0
- package/dist/emit/go/types.d.ts +32 -0
- package/dist/emit/go/types.js +177 -0
- package/dist/emit/go/ws.d.ts +12 -0
- package/dist/emit/go/ws.js +70 -0
- package/dist/emit/java/gradle.d.ts +57 -0
- package/dist/emit/java/gradle.js +221 -0
- package/dist/emit/java/index.d.ts +2 -0
- package/dist/emit/java/index.js +2 -0
- package/dist/emit/java/json.d.ts +13 -0
- package/dist/emit/java/json.js +84 -0
- package/dist/emit/java/layout-ast.d.ts +146 -0
- package/dist/emit/java/layout-ast.js +102 -0
- package/dist/emit/java/layout-decl.d.ts +20 -0
- package/dist/emit/java/layout-decl.js +155 -0
- package/dist/emit/java/layout-doc.d.ts +55 -0
- package/dist/emit/java/layout-doc.js +166 -0
- package/dist/emit/java/layout-dot.d.ts +18 -0
- package/dist/emit/java/layout-dot.js +127 -0
- package/dist/emit/java/layout-strings.d.ts +8 -0
- package/dist/emit/java/layout-strings.js +76 -0
- package/dist/emit/java/layout-types.d.ts +11 -0
- package/dist/emit/java/layout-types.js +95 -0
- package/dist/emit/java/layout-visitor.d.ts +38 -0
- package/dist/emit/java/layout-visitor.js +232 -0
- package/dist/emit/java/layout.d.ts +61 -0
- package/dist/emit/java/layout.js +121 -0
- package/dist/emit/java/models-enum.d.ts +17 -0
- package/dist/emit/java/models-enum.js +51 -0
- package/dist/emit/java/models-names.d.ts +29 -0
- package/dist/emit/java/models-names.js +97 -0
- package/dist/emit/java/models-record.d.ts +24 -0
- package/dist/emit/java/models-record.js +79 -0
- package/dist/emit/java/models-union.d.ts +27 -0
- package/dist/emit/java/models-union.js +86 -0
- package/dist/emit/java/models.d.ts +28 -0
- package/dist/emit/java/models.js +118 -0
- package/dist/emit/java/realtime.d.ts +50 -0
- package/dist/emit/java/realtime.js +69 -0
- package/dist/emit/java/sdk-client.d.ts +66 -0
- package/dist/emit/java/sdk-client.js +207 -0
- package/dist/emit/java/sdk-decl.d.ts +11 -0
- package/dist/emit/java/sdk-decl.js +63 -0
- package/dist/emit/java/sdk-errors.d.ts +13 -0
- package/dist/emit/java/sdk-errors.js +141 -0
- package/dist/emit/java/sdk-headers.d.ts +12 -0
- package/dist/emit/java/sdk-headers.js +74 -0
- package/dist/emit/java/sdk-mirror.d.ts +14 -0
- package/dist/emit/java/sdk-mirror.js +107 -0
- package/dist/emit/java/sdk-models.d.ts +16 -0
- package/dist/emit/java/sdk-models.js +68 -0
- package/dist/emit/java/sdk-op.d.ts +57 -0
- package/dist/emit/java/sdk-op.js +216 -0
- package/dist/emit/java/sdk-params.d.ts +38 -0
- package/dist/emit/java/sdk-params.js +133 -0
- package/dist/emit/java/sdk-plan.d.ts +52 -0
- package/dist/emit/java/sdk-plan.js +1 -0
- package/dist/emit/java/sdk-record.d.ts +16 -0
- package/dist/emit/java/sdk-record.js +99 -0
- package/dist/emit/java/sdk.d.ts +49 -0
- package/dist/emit/java/sdk.js +216 -0
- package/dist/emit/java/sse.d.ts +35 -0
- package/dist/emit/java/sse.js +57 -0
- package/dist/emit/java/ws.d.ts +27 -0
- package/dist/emit/java/ws.js +31 -0
- package/dist/emit/mcp/annotations.d.ts +15 -0
- package/dist/emit/mcp/annotations.js +15 -0
- package/dist/emit/mcp/files.d.ts +18 -0
- package/dist/emit/mcp/files.js +42 -0
- package/dist/emit/mcp/index.d.ts +3 -0
- package/dist/emit/mcp/index.js +3 -0
- package/dist/emit/mcp/literal.d.ts +2 -0
- package/dist/emit/mcp/literal.js +33 -0
- package/dist/emit/mcp/mounted.d.ts +21 -0
- package/dist/emit/mcp/mounted.js +89 -0
- package/dist/emit/mcp/output-schema.d.ts +18 -0
- package/dist/emit/mcp/output-schema.js +38 -0
- package/dist/emit/mcp/registry.d.ts +23 -0
- package/dist/emit/mcp/registry.js +83 -0
- package/dist/emit/mcp/runtime.d.ts +10 -0
- package/dist/emit/mcp/runtime.js +47 -0
- package/dist/emit/mcp/schema.d.ts +19 -0
- package/dist/emit/mcp/schema.js +88 -0
- package/dist/emit/mcp/server.d.ts +30 -0
- package/dist/emit/mcp/server.js +246 -0
- package/dist/emit/mcp/tools.d.ts +51 -0
- package/dist/emit/mcp/tools.js +153 -0
- package/dist/emit/python/errors.d.ts +8 -0
- package/dist/emit/python/errors.js +68 -0
- package/dist/emit/python/index.d.ts +1 -0
- package/dist/emit/python/index.js +1 -0
- package/dist/emit/python/realtime.d.ts +10 -0
- package/dist/emit/python/realtime.js +33 -0
- package/dist/emit/python/sdk-answer.d.ts +49 -0
- package/dist/emit/python/sdk-answer.js +89 -0
- package/dist/emit/python/sdk-body.d.ts +11 -0
- package/dist/emit/python/sdk-body.js +40 -0
- package/dist/emit/python/sdk-client.d.ts +36 -0
- package/dist/emit/python/sdk-client.js +163 -0
- package/dist/emit/python/sdk-doc.d.ts +9 -0
- package/dist/emit/python/sdk-doc.js +32 -0
- package/dist/emit/python/sdk-imports.d.ts +14 -0
- package/dist/emit/python/sdk-imports.js +38 -0
- package/dist/emit/python/sdk-method.d.ts +29 -0
- package/dist/emit/python/sdk-method.js +183 -0
- package/dist/emit/python/sdk-plan.d.ts +33 -0
- package/dist/emit/python/sdk-plan.js +1 -0
- package/dist/emit/python/sdk-pyproject.d.ts +27 -0
- package/dist/emit/python/sdk-pyproject.js +103 -0
- package/dist/emit/python/sdk.d.ts +22 -0
- package/dist/emit/python/sdk.js +154 -0
- package/dist/emit/python/sse.d.ts +12 -0
- package/dist/emit/python/sse.js +23 -0
- package/dist/emit/python/transport.d.ts +15 -0
- package/dist/emit/python/transport.js +60 -0
- package/dist/emit/python/types-dict.d.ts +31 -0
- package/dist/emit/python/types-dict.js +45 -0
- package/dist/emit/python/types-names.d.ts +16 -0
- package/dist/emit/python/types-names.js +52 -0
- package/dist/emit/python/types-union.d.ts +32 -0
- package/dist/emit/python/types-union.js +46 -0
- package/dist/emit/python/types.d.ts +36 -0
- package/dist/emit/python/types.js +128 -0
- package/dist/emit/python/ws.d.ts +14 -0
- package/dist/emit/python/ws.js +16 -0
- package/dist/emit/rust/errors.d.ts +7 -0
- package/dist/emit/rust/errors.js +107 -0
- package/dist/emit/rust/http.d.ts +13 -0
- package/dist/emit/rust/http.js +67 -0
- package/dist/emit/rust/index.d.ts +1 -0
- package/dist/emit/rust/index.js +1 -0
- package/dist/emit/rust/realtime.d.ts +11 -0
- package/dist/emit/rust/realtime.js +29 -0
- package/dist/emit/rust/sdk-body.d.ts +19 -0
- package/dist/emit/rust/sdk-body.js +53 -0
- package/dist/emit/rust/sdk-cargo.d.ts +43 -0
- package/dist/emit/rust/sdk-cargo.js +178 -0
- package/dist/emit/rust/sdk-client.d.ts +25 -0
- package/dist/emit/rust/sdk-client.js +108 -0
- package/dist/emit/rust/sdk-method.d.ts +15 -0
- package/dist/emit/rust/sdk-method.js +119 -0
- package/dist/emit/rust/sdk-opts.d.ts +58 -0
- package/dist/emit/rust/sdk-opts.js +117 -0
- package/dist/emit/rust/sdk-plan.d.ts +33 -0
- package/dist/emit/rust/sdk-plan.js +1 -0
- package/dist/emit/rust/sdk.d.ts +23 -0
- package/dist/emit/rust/sdk.js +111 -0
- package/dist/emit/rust/sse.d.ts +19 -0
- package/dist/emit/rust/sse.js +20 -0
- package/dist/emit/rust/types-enum.d.ts +13 -0
- package/dist/emit/rust/types-enum.js +62 -0
- package/dist/emit/rust/types-names.d.ts +19 -0
- package/dist/emit/rust/types-names.js +66 -0
- package/dist/emit/rust/types-struct.d.ts +21 -0
- package/dist/emit/rust/types-struct.js +59 -0
- package/dist/emit/rust/types-union.d.ts +24 -0
- package/dist/emit/rust/types-union.js +97 -0
- package/dist/emit/rust/types.d.ts +34 -0
- package/dist/emit/rust/types.js +105 -0
- package/dist/emit/rust/ws.d.ts +21 -0
- package/dist/emit/rust/ws.js +20 -0
- package/dist/emit/shared/escape.d.ts +55 -0
- package/dist/emit/shared/escape.js +144 -0
- package/dist/emit/shared/format.d.ts +24 -0
- package/dist/emit/shared/format.js +23 -0
- package/dist/emit/shared/gofmt.d.ts +3 -0
- package/dist/emit/shared/gofmt.js +26 -0
- package/dist/emit/shared/lang.d.ts +60 -0
- package/dist/emit/shared/lang.js +233 -0
- package/dist/emit/shared/literals.d.ts +4 -0
- package/dist/emit/shared/literals.js +31 -0
- package/dist/emit/shared/metadata.d.ts +106 -0
- package/dist/emit/shared/metadata.js +130 -0
- package/dist/emit/shared/mirror.d.ts +22 -0
- package/dist/emit/shared/mirror.js +26 -0
- package/dist/emit/shared/ruff.d.ts +3 -0
- package/dist/emit/shared/ruff.js +31 -0
- package/dist/emit/shared/rustfmt.d.ts +3 -0
- package/dist/emit/shared/rustfmt.js +32 -0
- package/dist/emit/shared/status-keys.d.ts +7 -0
- package/dist/emit/shared/status-keys.js +67 -0
- package/dist/emit/shared/type-emitter.d.ts +19 -0
- package/dist/emit/shared/type-emitter.js +100 -0
- package/dist/emit/ts/app-client.d.ts +4 -0
- package/dist/emit/ts/app-client.js +68 -0
- package/dist/emit/ts/http.d.ts +20 -0
- package/dist/emit/ts/http.js +74 -0
- package/dist/emit/ts/package.d.ts +36 -0
- package/dist/emit/ts/package.js +126 -0
- package/dist/emit/ts/route-tree.d.ts +68 -0
- package/dist/emit/ts/route-tree.js +240 -0
- package/dist/emit/ts/sdk-types-preamble.d.ts +14 -0
- package/dist/emit/ts/sdk-types-preamble.js +123 -0
- package/dist/emit/ts/sdk-types.d.ts +13 -0
- package/dist/emit/ts/sdk-types.js +213 -0
- package/dist/emit/ts/sdk.d.ts +21 -0
- package/dist/emit/ts/sdk.js +173 -0
- package/dist/emit/ts/service-map.d.ts +40 -0
- package/dist/emit/ts/service-map.js +171 -0
- package/dist/emit/ts/tanstack-query.d.ts +12 -0
- package/dist/emit/ts/tanstack-query.js +156 -0
- package/dist/emit/ts/type-gen.d.ts +26 -0
- package/dist/emit/ts/type-gen.js +255 -0
- package/dist/emit/ts/webhooks.d.ts +19 -0
- package/dist/emit/ts/webhooks.js +81 -0
- package/dist/extract/chain.d.ts +34 -0
- package/dist/extract/chain.js +84 -0
- package/dist/extract/extract.d.ts +41 -0
- package/dist/extract/extract.js +191 -0
- package/dist/extract/serialize.d.ts +34 -0
- package/dist/extract/serialize.js +295 -0
- package/dist/extract/walk.d.ts +47 -0
- package/dist/extract/walk.js +109 -0
- package/dist/gen/args.d.ts +28 -0
- package/dist/gen/args.js +133 -0
- package/dist/gen/formatters.d.ts +62 -0
- package/dist/gen/formatters.js +146 -0
- package/dist/gen/process.d.ts +13 -0
- package/dist/gen/process.js +35 -0
- package/dist/gen/shipped.d.ts +17 -0
- package/dist/gen/shipped.js +55 -0
- package/dist/gen/targets.d.ts +93 -0
- package/dist/gen/targets.js +171 -0
- package/dist/gen/write.d.ts +33 -0
- package/dist/gen/write.js +118 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +15 -0
- package/dist/ir/build.d.ts +37 -0
- package/dist/ir/build.js +152 -0
- package/dist/ir/load.d.ts +11 -0
- package/dist/ir/load.js +112 -0
- package/dist/ir/model.d.ts +206 -0
- package/dist/ir/model.js +5 -0
- package/dist/ir/resolve-refs.d.ts +11 -0
- package/dist/ir/resolve-refs.js +66 -0
- package/dist/ir/resource-tree.d.ts +9 -0
- package/dist/ir/resource-tree.js +53 -0
- package/dist/ir/route-tree-intern.d.ts +18 -0
- package/dist/ir/route-tree-intern.js +174 -0
- package/dist/ir/schema.d.ts +11 -0
- package/dist/ir/schema.js +192 -0
- package/dist/ir/sdk-model.d.ts +86 -0
- package/dist/ir/sdk-model.js +204 -0
- package/dist/ir/slots.d.ts +42 -0
- package/dist/ir/slots.js +245 -0
- package/dist/runtime/cli/body.go +176 -0
- package/dist/runtime/cli/config.go +243 -0
- package/dist/runtime/cli/discovery.go +147 -0
- package/dist/runtime/cli/format.go +174 -0
- package/dist/runtime/cli/log.go +117 -0
- package/dist/runtime/cli/output.go +247 -0
- package/dist/runtime/cli/params.go +197 -0
- package/dist/runtime/cli/run.go +226 -0
- package/dist/runtime/cli/socket.go +60 -0
- package/dist/runtime/cli/stream.go +217 -0
- package/dist/runtime/cli/target.go +117 -0
- package/dist/runtime/csharp/Adapters.cs +183 -0
- package/dist/runtime/csharp/Auth.cs +56 -0
- package/dist/runtime/csharp/Body.cs +135 -0
- package/dist/runtime/csharp/Config.cs +161 -0
- package/dist/runtime/csharp/Envelope.cs +149 -0
- package/dist/runtime/csharp/Errors.cs +194 -0
- package/dist/runtime/csharp/Events.cs +155 -0
- package/dist/runtime/csharp/Exchange.cs +247 -0
- package/dist/runtime/csharp/Handler.cs +103 -0
- package/dist/runtime/csharp/Hooks.cs +128 -0
- package/dist/runtime/csharp/Invalidation.cs +102 -0
- package/dist/runtime/csharp/Json.cs +144 -0
- package/dist/runtime/csharp/Log.cs +48 -0
- package/dist/runtime/csharp/Operation.cs +33 -0
- package/dist/runtime/csharp/Path.cs +65 -0
- package/dist/runtime/csharp/Query.cs +72 -0
- package/dist/runtime/csharp/Realtime.cs +118 -0
- package/dist/runtime/csharp/RealtimeLoop.cs +236 -0
- package/dist/runtime/csharp/Redirect.cs +53 -0
- package/dist/runtime/csharp/Result.cs +57 -0
- package/dist/runtime/csharp/Sse.cs +122 -0
- package/dist/runtime/csharp/Stale.cs +151 -0
- package/dist/runtime/csharp/Transport.cs +143 -0
- package/dist/runtime/csharp/TransportLongPoll.cs +63 -0
- package/dist/runtime/csharp/TransportSse.cs +54 -0
- package/dist/runtime/csharp/TransportWs.cs +40 -0
- package/dist/runtime/csharp/Wire.cs +109 -0
- package/dist/runtime/csharp/Ws.cs +300 -0
- package/dist/runtime/csharp/WsDial.cs +127 -0
- package/dist/runtime/go/auth.go +127 -0
- package/dist/runtime/go/body.go +129 -0
- package/dist/runtime/go/config.go +75 -0
- package/dist/runtime/go/errors.go +185 -0
- package/dist/runtime/go/export.go +37 -0
- package/dist/runtime/go/hooks.go +53 -0
- package/dist/runtime/go/invalidation.go +112 -0
- package/dist/runtime/go/log.go +92 -0
- package/dist/runtime/go/nullable.go +64 -0
- package/dist/runtime/go/options.go +118 -0
- package/dist/runtime/go/path.go +156 -0
- package/dist/runtime/go/query.go +147 -0
- package/dist/runtime/go/realtime.go +239 -0
- package/dist/runtime/go/realtime_loop.go +208 -0
- package/dist/runtime/go/redirect.go +124 -0
- package/dist/runtime/go/request.go +222 -0
- package/dist/runtime/go/result.go +86 -0
- package/dist/runtime/go/sse.go +186 -0
- package/dist/runtime/go/stale.go +229 -0
- package/dist/runtime/go/stream.go +105 -0
- package/dist/runtime/go/transport.go +242 -0
- package/dist/runtime/go/transport_longpoll.go +121 -0
- package/dist/runtime/go/transport_sse.go +175 -0
- package/dist/runtime/go/ws.go +205 -0
- package/dist/runtime/java/Answer.java +107 -0
- package/dist/runtime/java/ApiException.java +110 -0
- package/dist/runtime/java/BinaryBody.java +36 -0
- package/dist/runtime/java/Body.java +105 -0
- package/dist/runtime/java/Call.java +23 -0
- package/dist/runtime/java/CallLog.java +51 -0
- package/dist/runtime/java/ClientConfig.java +233 -0
- package/dist/runtime/java/ConnectionState.java +12 -0
- package/dist/runtime/java/Credential.java +58 -0
- package/dist/runtime/java/Deadline.java +38 -0
- package/dist/runtime/java/Decode.java +181 -0
- package/dist/runtime/java/Envelope.java +141 -0
- package/dist/runtime/java/ErrorEnvelope.java +23 -0
- package/dist/runtime/java/EventStream.java +129 -0
- package/dist/runtime/java/Exchange.java +62 -0
- package/dist/runtime/java/FilePart.java +5 -0
- package/dist/runtime/java/Flight.java +306 -0
- package/dist/runtime/java/HoneyException.java +14 -0
- package/dist/runtime/java/Hooks.java +47 -0
- package/dist/runtime/java/Hops.java +133 -0
- package/dist/runtime/java/InvalidationConfig.java +73 -0
- package/dist/runtime/java/Json.java +23 -0
- package/dist/runtime/java/Keepalive.java +60 -0
- package/dist/runtime/java/LogEntry.java +14 -0
- package/dist/runtime/java/LongPollAdapter.java +68 -0
- package/dist/runtime/java/Operation.java +21 -0
- package/dist/runtime/java/Opt.java +121 -0
- package/dist/runtime/java/Pump.java +160 -0
- package/dist/runtime/java/RawResponse.java +48 -0
- package/dist/runtime/java/Realtime.java +152 -0
- package/dist/runtime/java/RealtimeLoop.java +371 -0
- package/dist/runtime/java/RedirectPolicy.java +13 -0
- package/dist/runtime/java/Redirects.java +126 -0
- package/dist/runtime/java/RequestContext.java +78 -0
- package/dist/runtime/java/RequestHook.java +9 -0
- package/dist/runtime/java/RequestOptions.java +91 -0
- package/dist/runtime/java/ResponseContext.java +70 -0
- package/dist/runtime/java/ResponseHook.java +12 -0
- package/dist/runtime/java/Result.java +32 -0
- package/dist/runtime/java/ResumableConnection.java +165 -0
- package/dist/runtime/java/SdkException.java +11 -0
- package/dist/runtime/java/Socket.java +301 -0
- package/dist/runtime/java/Sse.java +171 -0
- package/dist/runtime/java/SseAdapter.java +61 -0
- package/dist/runtime/java/SseEvent.java +10 -0
- package/dist/runtime/java/StaleMeta.java +16 -0
- package/dist/runtime/java/StaleTracker.java +287 -0
- package/dist/runtime/java/Transport.java +16 -0
- package/dist/runtime/java/TransportAdapter.java +14 -0
- package/dist/runtime/java/TransportConnection.java +15 -0
- package/dist/runtime/java/TransportKind.java +12 -0
- package/dist/runtime/java/TransportMessage.java +9 -0
- package/dist/runtime/java/TransportOptions.java +138 -0
- package/dist/runtime/java/TypedWebSocket.java +83 -0
- package/dist/runtime/java/UrlPath.java +49 -0
- package/dist/runtime/java/UrlQuery.java +99 -0
- package/dist/runtime/java/WsAdapter.java +52 -0
- package/dist/runtime/java/WsClose.java +47 -0
- package/dist/runtime/java/WsDial.java +148 -0
- package/dist/runtime/java/WsMessage.java +18 -0
- package/dist/runtime/mcp/call.ts +167 -0
- package/dist/runtime/mcp/files.ts +183 -0
- package/dist/runtime/mcp/guard.ts +176 -0
- package/dist/runtime/mcp/http.ts +159 -0
- package/dist/runtime/mcp/jsonrpc.ts +50 -0
- package/dist/runtime/mcp/listen.ts +76 -0
- package/dist/runtime/mcp/mount.ts +123 -0
- package/dist/runtime/mcp/protocol.ts +219 -0
- package/dist/runtime/mcp/reader.ts +57 -0
- package/dist/runtime/mcp/result.ts +85 -0
- package/dist/runtime/mcp/stdio.ts +79 -0
- package/dist/runtime/mcp/stream.ts +62 -0
- package/dist/runtime/python/__init__.py +2 -0
- package/dist/runtime/python/auth.py +67 -0
- package/dist/runtime/python/body.py +83 -0
- package/dist/runtime/python/config.py +139 -0
- package/dist/runtime/python/errors.py +213 -0
- package/dist/runtime/python/events.py +152 -0
- package/dist/runtime/python/exchange.py +298 -0
- package/dist/runtime/python/hooks.py +86 -0
- package/dist/runtime/python/invalidation.py +57 -0
- package/dist/runtime/python/log.py +60 -0
- package/dist/runtime/python/operation.py +25 -0
- package/dist/runtime/python/path.py +41 -0
- package/dist/runtime/python/query.py +48 -0
- package/dist/runtime/python/realtime.py +244 -0
- package/dist/runtime/python/redirect.py +93 -0
- package/dist/runtime/python/result.py +58 -0
- package/dist/runtime/python/send_async.py +189 -0
- package/dist/runtime/python/send_sync.py +105 -0
- package/dist/runtime/python/sse.py +81 -0
- package/dist/runtime/python/stale.py +94 -0
- package/dist/runtime/python/transport.py +157 -0
- package/dist/runtime/python/transport_longpoll.py +60 -0
- package/dist/runtime/python/transport_sse.py +60 -0
- package/dist/runtime/python/transport_ws.py +57 -0
- package/dist/runtime/python/ws.py +276 -0
- package/dist/runtime/rust/Cargo.lock +1763 -0
- package/dist/runtime/rust/answer.rs +120 -0
- package/dist/runtime/rust/auth.rs +80 -0
- package/dist/runtime/rust/body.rs +150 -0
- package/dist/runtime/rust/call.rs +200 -0
- package/dist/runtime/rust/config.rs +254 -0
- package/dist/runtime/rust/envelope.rs +84 -0
- package/dist/runtime/rust/errors.rs +235 -0
- package/dist/runtime/rust/events.rs +177 -0
- package/dist/runtime/rust/exchange.rs +287 -0
- package/dist/runtime/rust/hooks.rs +63 -0
- package/dist/runtime/rust/invalidation.rs +84 -0
- package/dist/runtime/rust/log.rs +88 -0
- package/dist/runtime/rust/nullable.rs +13 -0
- package/dist/runtime/rust/path.rs +83 -0
- package/dist/runtime/rust/query.rs +84 -0
- package/dist/runtime/rust/realtime.rs +182 -0
- package/dist/runtime/rust/realtime_loop.rs +177 -0
- package/dist/runtime/rust/redirect.rs +121 -0
- package/dist/runtime/rust/request.rs +178 -0
- package/dist/runtime/rust/result.rs +101 -0
- package/dist/runtime/rust/sse.rs +104 -0
- package/dist/runtime/rust/stale.rs +209 -0
- package/dist/runtime/rust/transport.rs +221 -0
- package/dist/runtime/rust/transport_longpoll.rs +108 -0
- package/dist/runtime/rust/transport_sse.rs +91 -0
- package/dist/runtime/rust/transport_ws.rs +75 -0
- package/dist/runtime/rust/ws.rs +322 -0
- package/dist/runtime/ts/app-types.ts +200 -0
- package/dist/runtime/ts/app.ts +104 -0
- package/dist/runtime/ts/config.ts +124 -0
- package/dist/runtime/ts/defaults.ts +48 -0
- package/dist/runtime/ts/error.ts +113 -0
- package/dist/runtime/ts/hooks.ts +92 -0
- package/dist/runtime/ts/http.ts +228 -0
- package/dist/runtime/ts/media-type.ts +36 -0
- package/dist/runtime/ts/path.ts +152 -0
- package/dist/runtime/ts/realtime-connection.ts +296 -0
- package/dist/runtime/ts/realtime-transports.ts +149 -0
- package/dist/runtime/ts/realtime.ts +293 -0
- package/dist/runtime/ts/redirect-policy.ts +17 -0
- package/dist/runtime/ts/redirects.ts +74 -0
- package/dist/runtime/ts/request.ts +239 -0
- package/dist/runtime/ts/response.ts +219 -0
- package/dist/runtime/ts/sdk-realtime.ts +10 -0
- package/dist/runtime/ts/sdk-sse.ts +55 -0
- package/dist/runtime/ts/sdk-ws.ts +21 -0
- package/dist/runtime/ts/sdk.ts +242 -0
- package/dist/runtime/ts/sse.ts +175 -0
- package/dist/runtime/ts/stale.ts +137 -0
- package/dist/runtime/ts/stream.ts +87 -0
- package/dist/runtime/ts/webhook.ts +116 -0
- package/dist/runtime/ts/ws.ts +155 -0
- package/dist/runtime/ts-tanstack-query/invalidate.ts +152 -0
- package/dist/runtime/ts-tanstack-query/query.ts +261 -0
- package/package.json +135 -5
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Jackson binding text the Java models emit (bit 16 phase b, B4): a union's nested `Deserializer`, which reads the
|
|
3
|
+
* discriminator and dispatches each value to its wrapper, and an integer enum's `@JsonValue` and `@JsonCreator`. The
|
|
4
|
+
* mapper config is the runtime's (Json.java); this file holds no mapper.
|
|
5
|
+
*/
|
|
6
|
+
import { javaString } from "../shared/escape.js";
|
|
7
|
+
import { bin, call, classOf, forOpen, ifOpen, lit, local, methodHeader, newOf, param, returnStmt, rule, statement, throwStmt, typeHeader, } from "./layout.js";
|
|
8
|
+
/* a payload's erasure: `Class` takes no type arguments */
|
|
9
|
+
const erased = (type) => type.replace(/<.*$/, "");
|
|
10
|
+
/** One switch arm, `case label -> value;` (`default` for no label), in the switch's body. */
|
|
11
|
+
const arm = (label, value) => statement(8, rule(label === null ? null : lit(label), value));
|
|
12
|
+
/** One `case` arm per selecting value, in dispatch order. */
|
|
13
|
+
const cases = (dispatch) => dispatch.flatMap(({ values, wrapper, payload }) => values.flatMap((value) => arm(javaString(value), newOf(wrapper, [call("ctxt", "readTreeAsValue", ["node", classOf(erased(payload))])]))));
|
|
14
|
+
/** A union's nested `Deserializer`, two spaces in: from its `final class` line to its closing brace. */
|
|
15
|
+
export function deserializerLines(name, property, dispatch, unknown) {
|
|
16
|
+
return [
|
|
17
|
+
...typeHeader(2, {
|
|
18
|
+
end: "{",
|
|
19
|
+
extends: `StdDeserializer<${name}>`,
|
|
20
|
+
kind: "class",
|
|
21
|
+
modifiers: ["final"],
|
|
22
|
+
name: "Deserializer",
|
|
23
|
+
}),
|
|
24
|
+
" public Deserializer() {",
|
|
25
|
+
...statement(6, { expr: call(null, "super", [classOf(name)]), k: "expr" }),
|
|
26
|
+
" }",
|
|
27
|
+
"",
|
|
28
|
+
" @Override",
|
|
29
|
+
...methodHeader(4, {
|
|
30
|
+
modifiers: ["public"],
|
|
31
|
+
name: "deserialize",
|
|
32
|
+
params: [param("JsonParser", "p"), param("DeserializationContext", "ctxt")],
|
|
33
|
+
returns: name,
|
|
34
|
+
}),
|
|
35
|
+
" JsonNode node = ctxt.readTree(p);",
|
|
36
|
+
...statement(6, local({ init: call("node", "get", [javaString(property)]), name: "kind", type: "JsonNode" })),
|
|
37
|
+
" String value = kind != null && kind.isString() ? kind.asString() : null;",
|
|
38
|
+
" if (value == null) {",
|
|
39
|
+
...statement(8, returnStmt(newOf(unknown, ["node"]))),
|
|
40
|
+
" }",
|
|
41
|
+
" return switch (value) {",
|
|
42
|
+
...cases(dispatch),
|
|
43
|
+
...arm(null, newOf(unknown, ["node"])),
|
|
44
|
+
" };",
|
|
45
|
+
" }",
|
|
46
|
+
" }",
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The members an integer enum adds after its constants: the `long` value, `@JsonValue` and `@JsonCreator fromValue`,
|
|
51
|
+
* which takes only a JSON integer. The caller writes the closing brace.
|
|
52
|
+
*/
|
|
53
|
+
export function intEnumJsonLines(name) {
|
|
54
|
+
return [
|
|
55
|
+
"",
|
|
56
|
+
" private final long value;",
|
|
57
|
+
"",
|
|
58
|
+
...methodHeader(2, { name, params: [param("long", "value")] }),
|
|
59
|
+
" this.value = value;",
|
|
60
|
+
" }",
|
|
61
|
+
"",
|
|
62
|
+
" @JsonValue",
|
|
63
|
+
" public long value() {",
|
|
64
|
+
" return value;",
|
|
65
|
+
" }",
|
|
66
|
+
"",
|
|
67
|
+
" @JsonCreator",
|
|
68
|
+
...methodHeader(2, {
|
|
69
|
+
modifiers: ["public", "static"],
|
|
70
|
+
name: "fromValue",
|
|
71
|
+
params: [param("JsonNode", "node")],
|
|
72
|
+
returns: name,
|
|
73
|
+
}),
|
|
74
|
+
...statement(4, ifOpen(call("node", "isIntegralNumber"))),
|
|
75
|
+
...statement(6, forOpen(name, "level", call(null, "values"))),
|
|
76
|
+
" if (level.value == node.longValue()) {",
|
|
77
|
+
" return level;",
|
|
78
|
+
" }",
|
|
79
|
+
" }",
|
|
80
|
+
" }",
|
|
81
|
+
...statement(4, throwStmt(newOf("IllegalArgumentException", [bin("+", "node", javaString(` is no ${name}`))]))),
|
|
82
|
+
" }",
|
|
83
|
+
];
|
|
84
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Java nodes the emitter builds and layout.ts lays out (bit 21 i7a): types, expressions, declarations and the
|
|
3
|
+
* headers' parts, with the constructors the emitter writes them through. A string where an expression goes is an
|
|
4
|
+
* identifier path (`params.body`) or, when it is not one, a token kept whole (`"GET"`, `16L`). The nodes hold only
|
|
5
|
+
* what the emitter writes: a construct GJF lays out that the emitter never does has no node, and a shape the nodes
|
|
6
|
+
* can still spell but the layout does not lay out is refused by name (`refuse`), never laid out some other way.
|
|
7
|
+
*/
|
|
8
|
+
/** A Java type: a (possibly dotted) name, its type arguments, its array dimensions. */
|
|
9
|
+
export type Type = {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly args: readonly Type[];
|
|
12
|
+
readonly dims: number;
|
|
13
|
+
};
|
|
14
|
+
/** A chain of names and calls: a dot chain's receiver. */
|
|
15
|
+
export type Path = Of<"id"> | Of<"sel"> | Of<"call">;
|
|
16
|
+
/** A Java expression the emitter writes. */
|
|
17
|
+
export type Expr = {
|
|
18
|
+
readonly k: "id";
|
|
19
|
+
readonly name: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly k: "lit";
|
|
22
|
+
readonly text: string;
|
|
23
|
+
} | {
|
|
24
|
+
readonly k: "sel";
|
|
25
|
+
readonly of: Path;
|
|
26
|
+
readonly name: string;
|
|
27
|
+
} | {
|
|
28
|
+
readonly k: "call";
|
|
29
|
+
readonly of: Path | null;
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly args: readonly Expr[];
|
|
32
|
+
} | {
|
|
33
|
+
readonly k: "new";
|
|
34
|
+
readonly type: Type;
|
|
35
|
+
readonly args: readonly Expr[];
|
|
36
|
+
readonly body: boolean;
|
|
37
|
+
} | {
|
|
38
|
+
readonly k: "array";
|
|
39
|
+
readonly type: Type | null;
|
|
40
|
+
readonly items: readonly Expr[];
|
|
41
|
+
} | {
|
|
42
|
+
readonly k: "lambda";
|
|
43
|
+
readonly param: string;
|
|
44
|
+
readonly body: Expr;
|
|
45
|
+
} | {
|
|
46
|
+
readonly k: "bin";
|
|
47
|
+
readonly op: string;
|
|
48
|
+
readonly operands: readonly Expr[];
|
|
49
|
+
} | {
|
|
50
|
+
readonly k: "assign";
|
|
51
|
+
readonly to: Expr;
|
|
52
|
+
readonly value: Expr;
|
|
53
|
+
} | {
|
|
54
|
+
readonly k: "ref";
|
|
55
|
+
readonly of: Expr;
|
|
56
|
+
readonly name: string;
|
|
57
|
+
} | {
|
|
58
|
+
readonly k: "cond";
|
|
59
|
+
readonly test: Expr;
|
|
60
|
+
readonly yes: Expr;
|
|
61
|
+
readonly no: Expr;
|
|
62
|
+
};
|
|
63
|
+
/** One kind of expression. */
|
|
64
|
+
export type Of<K extends Expr["k"]> = Extract<Expr, {
|
|
65
|
+
k: K;
|
|
66
|
+
}>;
|
|
67
|
+
/** A shape the layout does not lay out: an error naming it, so the emitter's output is never laid out off GJF's. */
|
|
68
|
+
export declare function refuse(what: string): never;
|
|
69
|
+
/** `text` as a type: `Map<String, List<X>>`, `String[]`, `JsonInclude.Include`. */
|
|
70
|
+
export declare function type(text: string): Type;
|
|
71
|
+
/** An identifier path `a.b.c` (each dot a field access), or `name` alone. */
|
|
72
|
+
export declare const id: (path: string) => Of<"id"> | Of<"sel">;
|
|
73
|
+
/** A literal or any token kept whole: `"GET"`, `null`, `true`, `16L`. */
|
|
74
|
+
export declare const lit: (text: string) => Expr;
|
|
75
|
+
/** A string as an expression: an identifier path, else a token kept whole. */
|
|
76
|
+
export declare const expr: (e: Expr | string) => Expr;
|
|
77
|
+
/** `of.name(args)`, or `name(args)` with no receiver; a string receiver is an identifier path. */
|
|
78
|
+
export declare const call: (of: Path | string | null, name: string, args?: readonly (Expr | string)[]) => Of<"call">;
|
|
79
|
+
/** `new T(args)`, `{}` after it when `body`. */
|
|
80
|
+
export declare const newOf: (of: string, args?: readonly (Expr | string)[], body?: boolean) => Expr;
|
|
81
|
+
/** `new T[] {items}`, or the bare `{items}` with no type. */
|
|
82
|
+
export declare const array: (of: string | null, items: readonly (Expr | string)[]) => Expr;
|
|
83
|
+
/** `param -> body`. */
|
|
84
|
+
export declare const lambda: (param: string, body: Expr) => Expr;
|
|
85
|
+
/** The operands joined by `op` (one precedence). */
|
|
86
|
+
export declare const bin: (op: string, ...operands: readonly (Expr | string)[]) => Expr;
|
|
87
|
+
/** `to = value`. */
|
|
88
|
+
export declare const assign: (to: Expr | string, value: Expr | string) => Expr;
|
|
89
|
+
/** `of::name`. */
|
|
90
|
+
export declare const ref: (of: Expr | string, name: string) => Expr;
|
|
91
|
+
/** `test ? yes : no`. */
|
|
92
|
+
export declare const cond: (test: Expr | string, yes: Expr | string, no: Expr | string) => Expr;
|
|
93
|
+
/** `Name.class`, of a class's (possibly dotted) name. */
|
|
94
|
+
export declare const classOf: (of: string) => Of<"sel">;
|
|
95
|
+
/** An annotation argument: an expression, never an array initializer. */
|
|
96
|
+
type Value = Exclude<Expr, Of<"array">> | string;
|
|
97
|
+
/** An annotation: `@Name`, `@Name(value)` or `@Name(key = value)`. */
|
|
98
|
+
export type Annotation = {
|
|
99
|
+
readonly name: string;
|
|
100
|
+
readonly args?: readonly [Value] | readonly [readonly [string, Value]];
|
|
101
|
+
};
|
|
102
|
+
/** One declaration's parts: its modifiers, type, name and initializer. */
|
|
103
|
+
export type Declaration = {
|
|
104
|
+
readonly modifiers?: readonly string[];
|
|
105
|
+
readonly type: string;
|
|
106
|
+
readonly name: string;
|
|
107
|
+
readonly init?: Expr | string;
|
|
108
|
+
};
|
|
109
|
+
/** A record's component: its annotations, type and name. */
|
|
110
|
+
export type Component = {
|
|
111
|
+
readonly annotations?: readonly Annotation[];
|
|
112
|
+
readonly type: string;
|
|
113
|
+
readonly name: string;
|
|
114
|
+
};
|
|
115
|
+
/** A parameter: `Type name`. */
|
|
116
|
+
export declare const param: (of: string, name: string) => Declaration;
|
|
117
|
+
/** A method's or constructor's header, through its ` {`. */
|
|
118
|
+
export type MethodHeader = {
|
|
119
|
+
readonly modifiers?: readonly string[];
|
|
120
|
+
/** the return type; none for a constructor */
|
|
121
|
+
readonly returns?: string;
|
|
122
|
+
readonly name: string;
|
|
123
|
+
readonly params: readonly Declaration[];
|
|
124
|
+
};
|
|
125
|
+
/** What every type declaration's header holds: its annotations, modifiers and name, and `{` (or `{}` when empty). */
|
|
126
|
+
type Header = {
|
|
127
|
+
readonly annotations?: readonly Annotation[];
|
|
128
|
+
readonly modifiers: readonly [string, ...string[]];
|
|
129
|
+
readonly name: string;
|
|
130
|
+
readonly end: "{" | "{}";
|
|
131
|
+
};
|
|
132
|
+
/** A type declaration's header: a record's components and interface, a class's superclass, an interface's permits. */
|
|
133
|
+
export type TypeHeader = Header & ({
|
|
134
|
+
readonly kind: "enum";
|
|
135
|
+
} | {
|
|
136
|
+
readonly kind: "record";
|
|
137
|
+
readonly components: readonly Component[];
|
|
138
|
+
readonly implements?: string;
|
|
139
|
+
} | {
|
|
140
|
+
readonly kind: "class";
|
|
141
|
+
readonly extends?: string;
|
|
142
|
+
} | {
|
|
143
|
+
readonly kind: "interface";
|
|
144
|
+
readonly permits: readonly string[];
|
|
145
|
+
});
|
|
146
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Java nodes the emitter builds and layout.ts lays out (bit 21 i7a): types, expressions, declarations and the
|
|
3
|
+
* headers' parts, with the constructors the emitter writes them through. A string where an expression goes is an
|
|
4
|
+
* identifier path (`params.body`) or, when it is not one, a token kept whole (`"GET"`, `16L`). The nodes hold only
|
|
5
|
+
* what the emitter writes: a construct GJF lays out that the emitter never does has no node, and a shape the nodes
|
|
6
|
+
* can still spell but the layout does not lay out is refused by name (`refuse`), never laid out some other way.
|
|
7
|
+
*/
|
|
8
|
+
/** A shape the layout does not lay out: an error naming it, so the emitter's output is never laid out off GJF's. */
|
|
9
|
+
export function refuse(what) {
|
|
10
|
+
throw new Error(`no Java layout for ${what}`);
|
|
11
|
+
}
|
|
12
|
+
/** `text` as a type: `Map<String, List<X>>`, `String[]`, `JsonInclude.Include`. */
|
|
13
|
+
export function type(text) {
|
|
14
|
+
let at = 0;
|
|
15
|
+
const parse = () => {
|
|
16
|
+
const start = at;
|
|
17
|
+
while (at < text.length && !"<>,[".includes(text[at]))
|
|
18
|
+
at += 1;
|
|
19
|
+
const name = text.slice(start, at).trim();
|
|
20
|
+
const args = [];
|
|
21
|
+
if (text[at] === "<") {
|
|
22
|
+
at += 1;
|
|
23
|
+
while (text[at] !== ">") {
|
|
24
|
+
args.push(parse());
|
|
25
|
+
if (text[at] === ",")
|
|
26
|
+
at += 1;
|
|
27
|
+
while (text[at] === " ")
|
|
28
|
+
at += 1;
|
|
29
|
+
}
|
|
30
|
+
at += 1;
|
|
31
|
+
}
|
|
32
|
+
let dims = 0;
|
|
33
|
+
while (text.startsWith("[]", at)) {
|
|
34
|
+
dims += 1;
|
|
35
|
+
at += 2;
|
|
36
|
+
}
|
|
37
|
+
return { args, dims, name };
|
|
38
|
+
};
|
|
39
|
+
const parsed = parse();
|
|
40
|
+
if (at !== text.length || parsed.name === "")
|
|
41
|
+
refuse(`the type \`${text}\``);
|
|
42
|
+
return parsed;
|
|
43
|
+
}
|
|
44
|
+
/** An identifier path `a.b.c` (each dot a field access), or `name` alone. */
|
|
45
|
+
export const id = (path) => path
|
|
46
|
+
.split(".")
|
|
47
|
+
.slice(1)
|
|
48
|
+
.reduce((of, name) => ({ k: "sel", name, of }), {
|
|
49
|
+
k: "id",
|
|
50
|
+
name: path.split(".")[0],
|
|
51
|
+
});
|
|
52
|
+
/** A literal or any token kept whole: `"GET"`, `null`, `true`, `16L`. */
|
|
53
|
+
export const lit = (text) => ({ k: "lit", text });
|
|
54
|
+
/** A string as an expression: an identifier path, else a token kept whole. */
|
|
55
|
+
export const expr = (e) => typeof e !== "string" ? e : /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*)*$/.test(e) ? id(e) : lit(e);
|
|
56
|
+
/** `of.name(args)`, or `name(args)` with no receiver; a string receiver is an identifier path. */
|
|
57
|
+
export const call = (of, name, args = []) => ({
|
|
58
|
+
args: args.map(expr),
|
|
59
|
+
k: "call",
|
|
60
|
+
name,
|
|
61
|
+
of: typeof of === "string" ? id(of) : of,
|
|
62
|
+
});
|
|
63
|
+
/** `new T(args)`, `{}` after it when `body`. */
|
|
64
|
+
export const newOf = (of, args = [], body = false) => ({
|
|
65
|
+
args: args.map(expr),
|
|
66
|
+
body,
|
|
67
|
+
k: "new",
|
|
68
|
+
type: type(of),
|
|
69
|
+
});
|
|
70
|
+
/** `new T[] {items}`, or the bare `{items}` with no type. */
|
|
71
|
+
export const array = (of, items) => ({
|
|
72
|
+
items: items.map(expr),
|
|
73
|
+
k: "array",
|
|
74
|
+
type: of === null ? null : type(of),
|
|
75
|
+
});
|
|
76
|
+
/** `param -> body`. */
|
|
77
|
+
export const lambda = (param, body) => ({ body, k: "lambda", param });
|
|
78
|
+
/** The operands joined by `op` (one precedence). */
|
|
79
|
+
export const bin = (op, ...operands) => ({
|
|
80
|
+
k: "bin",
|
|
81
|
+
op,
|
|
82
|
+
operands: operands.map(expr),
|
|
83
|
+
});
|
|
84
|
+
/** `to = value`. */
|
|
85
|
+
export const assign = (to, value) => ({
|
|
86
|
+
k: "assign",
|
|
87
|
+
to: expr(to),
|
|
88
|
+
value: expr(value),
|
|
89
|
+
});
|
|
90
|
+
/** `of::name`. */
|
|
91
|
+
export const ref = (of, name) => ({ k: "ref", name, of: expr(of) });
|
|
92
|
+
/** `test ? yes : no`. */
|
|
93
|
+
export const cond = (test, yes, no) => ({
|
|
94
|
+
k: "cond",
|
|
95
|
+
no: expr(no),
|
|
96
|
+
test: expr(test),
|
|
97
|
+
yes: expr(yes),
|
|
98
|
+
});
|
|
99
|
+
/** `Name.class`, of a class's (possibly dotted) name. */
|
|
100
|
+
export const classOf = (of) => ({ k: "sel", name: "class", of: id(of) });
|
|
101
|
+
/** A parameter: `Type name`. */
|
|
102
|
+
export const param = (of, name) => ({ name, type: of });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* google-java-format's declarations, ported (bit 21 i7a; JavaInputAstVisitor): an annotation (visitAnnotation,
|
|
3
|
+
* visitSingleMemberAnnotation), the modifiers (visitModifiers), one declaration (declareOne: an independent break
|
|
4
|
+
* before the name, the initializer after `=` at +4 or +8 by whether the type broke) and a method's header (visitMethod,
|
|
5
|
+
* visitFormals: the type and name scope, then the formals indented by whether the name broke).
|
|
6
|
+
*/
|
|
7
|
+
import { type Annotation, type Component, type Declaration, type MethodHeader } from "./layout-ast.ts";
|
|
8
|
+
import type { Visitor } from "./layout-visitor.ts";
|
|
9
|
+
/** visitAnnotation and visitSingleMemberAnnotation: `@Name`, `@Name(value)`, or `@Name(key = value)`. */
|
|
10
|
+
export declare function annotation(v: Visitor, a: Annotation): void;
|
|
11
|
+
/** A declaration's place: a parameter (a component's annotations at +4) or a variable; the tokens closing it and before its initializer. */
|
|
12
|
+
export type Place = {
|
|
13
|
+
readonly kind: "parameter" | "variable";
|
|
14
|
+
readonly trailing?: string;
|
|
15
|
+
readonly equals?: string;
|
|
16
|
+
};
|
|
17
|
+
/** declareOne: modifiers, the type, an independent break before the name, `equals` and the initializer. */
|
|
18
|
+
export declare function declareOne(v: Visitor, d: Declaration & Component, { equals, kind, trailing }: Place): void;
|
|
19
|
+
/** visitMethod: the modifiers, the type and name scope, then the formals, ` {`. */
|
|
20
|
+
export declare function method(v: Visitor, m: MethodHeader): void;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* google-java-format's declarations, ported (bit 21 i7a; JavaInputAstVisitor): an annotation (visitAnnotation,
|
|
3
|
+
* visitSingleMemberAnnotation), the modifiers (visitModifiers), one declaration (declareOne: an independent break
|
|
4
|
+
* before the name, the initializer after `=` at +4 or +8 by whether the type broke) and a method's header (visitMethod,
|
|
5
|
+
* visitFormals: the type and name scope, then the formals indented by whether the name broke).
|
|
6
|
+
*/
|
|
7
|
+
import { expr, type, } from "./layout-ast.js";
|
|
8
|
+
import { ifTaken } from "./layout-doc.js";
|
|
9
|
+
/** visitAnnotation and visitSingleMemberAnnotation: `@Name`, `@Name(value)`, or `@Name(key = value)`. */
|
|
10
|
+
export function annotation(v, a) {
|
|
11
|
+
const [arg] = a.args ?? [];
|
|
12
|
+
if (arg !== undefined && !Array.isArray(arg)) {
|
|
13
|
+
v.b.open(4);
|
|
14
|
+
v.b.token("@");
|
|
15
|
+
v.typeName(a.name);
|
|
16
|
+
v.b.token("(");
|
|
17
|
+
v.b.breakOp();
|
|
18
|
+
v.expr(expr(arg));
|
|
19
|
+
v.b.close();
|
|
20
|
+
v.b.token(")");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
v.b.open(0);
|
|
24
|
+
v.b.token("@");
|
|
25
|
+
v.typeName(a.name);
|
|
26
|
+
if (arg !== undefined) {
|
|
27
|
+
const [key, value] = arg;
|
|
28
|
+
v.b.open(4);
|
|
29
|
+
v.b.token("(");
|
|
30
|
+
v.b.breakOp();
|
|
31
|
+
v.b.open(4);
|
|
32
|
+
v.b.token(key);
|
|
33
|
+
v.b.space();
|
|
34
|
+
v.b.token("=");
|
|
35
|
+
v.b.breakOp(" ");
|
|
36
|
+
v.expr(expr(value));
|
|
37
|
+
v.b.close();
|
|
38
|
+
v.b.token(")");
|
|
39
|
+
v.b.close();
|
|
40
|
+
}
|
|
41
|
+
v.b.close();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* visitModifiers: a component's annotations, unified breaks between and after them; or a declaration's modifiers,
|
|
45
|
+
* each pair and the last one followed by an independent break of its own.
|
|
46
|
+
*/
|
|
47
|
+
function modifiers(v, annotations, words) {
|
|
48
|
+
if (annotations.length > 0) {
|
|
49
|
+
v.b.open(0);
|
|
50
|
+
annotations.forEach((a, i) => {
|
|
51
|
+
if (i > 0)
|
|
52
|
+
v.b.breakOp(" ");
|
|
53
|
+
annotation(v, a);
|
|
54
|
+
});
|
|
55
|
+
v.b.close();
|
|
56
|
+
v.b.breakOp(" ");
|
|
57
|
+
}
|
|
58
|
+
else if (words.length > 0) {
|
|
59
|
+
v.b.open(0);
|
|
60
|
+
words.forEach((word, i) => {
|
|
61
|
+
if (i > 0)
|
|
62
|
+
v.b.breakFill();
|
|
63
|
+
v.b.token(word);
|
|
64
|
+
});
|
|
65
|
+
v.b.close();
|
|
66
|
+
v.b.breakFill();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** declareOne: modifiers, the type, an independent break before the name, `equals` and the initializer. */
|
|
70
|
+
export function declareOne(v, d, { equals = "=", kind, trailing = "" }) {
|
|
71
|
+
const annotations = d.annotations ?? [];
|
|
72
|
+
const typeBreak = { taken: false };
|
|
73
|
+
v.b.open(kind === "parameter" && annotations.length > 0 ? 4 : 0);
|
|
74
|
+
modifiers(v, annotations, d.modifiers ?? []);
|
|
75
|
+
v.b.open(4);
|
|
76
|
+
v.b.open(0);
|
|
77
|
+
v.b.open(0);
|
|
78
|
+
v.type(type(d.type));
|
|
79
|
+
v.b.close();
|
|
80
|
+
v.b.brk("independent", " ", 0, typeBreak);
|
|
81
|
+
v.b.open(ifTaken(typeBreak, 4));
|
|
82
|
+
v.b.token(d.name);
|
|
83
|
+
v.b.close();
|
|
84
|
+
v.b.close();
|
|
85
|
+
if (d.init !== undefined)
|
|
86
|
+
initializer(v, expr(d.init), equals, typeBreak);
|
|
87
|
+
if (trailing !== "")
|
|
88
|
+
v.b.token(trailing);
|
|
89
|
+
v.b.close();
|
|
90
|
+
v.b.close();
|
|
91
|
+
}
|
|
92
|
+
/** ` = init`: a bare array initializer on the `=`'s line, anything else after an independent break. */
|
|
93
|
+
function initializer(v, init, equals, typeBreak) {
|
|
94
|
+
v.b.space();
|
|
95
|
+
v.b.token(equals);
|
|
96
|
+
if (init.k === "array" && init.type === null) {
|
|
97
|
+
v.b.open(-4);
|
|
98
|
+
v.b.space();
|
|
99
|
+
v.expr(init);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
v.b.open(ifTaken(typeBreak, 4));
|
|
103
|
+
v.b.breakToFill(" ");
|
|
104
|
+
v.expr(init);
|
|
105
|
+
}
|
|
106
|
+
v.b.close();
|
|
107
|
+
}
|
|
108
|
+
/** visitMethod: the modifiers, the type and name scope, then the formals, ` {`. */
|
|
109
|
+
export function method(v, m) {
|
|
110
|
+
modifiers(v, [], m.modifiers ?? []);
|
|
111
|
+
v.b.open(4);
|
|
112
|
+
const beforeName = { taken: false };
|
|
113
|
+
nameScope(v, m, beforeName);
|
|
114
|
+
v.b.open(ifTaken(beforeName, 4));
|
|
115
|
+
v.b.open(0);
|
|
116
|
+
v.b.open(0);
|
|
117
|
+
formals(v, m);
|
|
118
|
+
v.b.close();
|
|
119
|
+
v.b.close();
|
|
120
|
+
v.b.close();
|
|
121
|
+
v.b.space();
|
|
122
|
+
v.b.token("{");
|
|
123
|
+
v.b.close();
|
|
124
|
+
}
|
|
125
|
+
/** The return type and the name with its `(`, the break before the name tagged. */
|
|
126
|
+
function nameScope(v, m, beforeName) {
|
|
127
|
+
v.b.open(0);
|
|
128
|
+
if (m.returns !== undefined) {
|
|
129
|
+
v.b.open(0);
|
|
130
|
+
v.b.open(0);
|
|
131
|
+
v.type(type(m.returns));
|
|
132
|
+
v.b.close();
|
|
133
|
+
v.b.brk("independent", " ", 0, beforeName);
|
|
134
|
+
}
|
|
135
|
+
else
|
|
136
|
+
v.b.open(0); /* a constructor's name scope opens with its name */
|
|
137
|
+
v.b.token(m.name);
|
|
138
|
+
v.b.token("(");
|
|
139
|
+
v.b.close();
|
|
140
|
+
v.b.close();
|
|
141
|
+
}
|
|
142
|
+
/** visitFormals: the parameters after a fill break, then `)`. */
|
|
143
|
+
function formals(v, m) {
|
|
144
|
+
if (m.params.length > 0) {
|
|
145
|
+
v.b.breakToFill("");
|
|
146
|
+
v.b.open(0);
|
|
147
|
+
m.params.forEach((p, i) => {
|
|
148
|
+
if (i > 0)
|
|
149
|
+
v.b.breakOp(" ");
|
|
150
|
+
declareOne(v, p, { kind: "parameter", trailing: i < m.params.length - 1 ? "," : "" });
|
|
151
|
+
});
|
|
152
|
+
v.b.close();
|
|
153
|
+
}
|
|
154
|
+
v.b.token(")");
|
|
155
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* google-java-format 1.37's layout engine, ported (bit 21 i7a): its `Doc`, `OpsBuilder` and `DocBuilder`. Ops (open a
|
|
3
|
+
* level, close it, a token, a space, a break) become a tree of levels. A token joins the level of the latest break,
|
|
4
|
+
* not the innermost open one (DocBuilder's `appendLevel`), so text after a level counts toward that level's last
|
|
5
|
+
* split. A level that fits in 100 columns stays on one line; else each of its own breaks is taken: a unified one
|
|
6
|
+
* always, an independent one when the text up to its next break does not fit, or after a split that did not fit. A
|
|
7
|
+
* break indents to its level's indent plus its own, and an `If` indent reads whether a tagged break was taken.
|
|
8
|
+
*/
|
|
9
|
+
/** google-java-format's line width. */
|
|
10
|
+
export declare const WIDTH = 100;
|
|
11
|
+
/** A break that an `If` indent reads: taken or not, recorded as the layout runs. */
|
|
12
|
+
export type Tag = {
|
|
13
|
+
taken: boolean;
|
|
14
|
+
};
|
|
15
|
+
/** An indent: a constant, or one that depends on whether a tagged break was taken (Indent.If). */
|
|
16
|
+
export type Indent = number | {
|
|
17
|
+
readonly tag: Tag;
|
|
18
|
+
readonly onBreak: number;
|
|
19
|
+
readonly onFlat: number;
|
|
20
|
+
};
|
|
21
|
+
export type Fill = "unified" | "independent" | "forced";
|
|
22
|
+
/** Indent.If: `onBreak` when `tag`'s break was taken, else `onFlat`. */
|
|
23
|
+
export declare const ifTaken: (tag: Tag, onBreak: number, onFlat?: number) => Indent;
|
|
24
|
+
/** The text written so far, and where each string literal starts in it. */
|
|
25
|
+
export type Sink = {
|
|
26
|
+
text: string;
|
|
27
|
+
readonly strings: {
|
|
28
|
+
readonly at: number;
|
|
29
|
+
readonly first: boolean;
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
/** The op builder: GJF's OpsBuilder and DocBuilder in one, building the doc as the ops arrive. */
|
|
33
|
+
export declare class Builder {
|
|
34
|
+
private readonly base;
|
|
35
|
+
private readonly stack;
|
|
36
|
+
private append;
|
|
37
|
+
open(indent: Indent): void;
|
|
38
|
+
close(): void;
|
|
39
|
+
token(text: string): void;
|
|
40
|
+
/** a literal token, marked when it is a string, so StringWrapper may reflow it */
|
|
41
|
+
literal(text: string, chained?: boolean): void;
|
|
42
|
+
space(): void;
|
|
43
|
+
brk(fill: Fill, flat: string, indent?: Indent, tag?: Tag): void;
|
|
44
|
+
/** breakOp: a unified break */
|
|
45
|
+
breakOp(flat?: string, indent?: Indent): void;
|
|
46
|
+
/** breakToFill: an independent break */
|
|
47
|
+
breakToFill(flat?: string): void;
|
|
48
|
+
forced(): void;
|
|
49
|
+
/** breakFillList: an independent break in a level of its own */
|
|
50
|
+
breakFill(): void;
|
|
51
|
+
/** The doc on one line: every level flat, every break its flat text. */
|
|
52
|
+
flat(): string;
|
|
53
|
+
/** The doc laid out from `indent` columns, as GJF's block level lays out one statement: its text and literals. */
|
|
54
|
+
laid(indent: number): Sink;
|
|
55
|
+
}
|