@workerstack/clients 1.0.0-rc.28 → 1.0.0-rc.30
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/README.md +403 -21
- package/assets/installers/examples/github.config.ts +17 -19
- package/assets/installers/examples/goreleaser.config.ts +16 -18
- package/assets/installers/examples/raw.config.ts +13 -15
- package/bin/clients.js +87 -66
- package/bin/installgen.js +19 -10
- package/dist/cli.d.ts +4 -4
- package/dist/cli.js +18 -12
- package/dist/emit/cli/channels.d.ts +2 -2
- package/dist/emit/cli/channels.js +18 -13
- package/dist/emit/cli/commands.d.ts +1 -1
- package/dist/emit/cli/commands.js +39 -13
- package/dist/emit/cli/discovery.d.ts +0 -6
- package/dist/emit/cli/discovery.js +9 -7
- package/dist/emit/cli/flags.d.ts +1 -3
- package/dist/emit/cli/flags.js +18 -8
- package/dist/emit/cli/install.d.ts +0 -8
- package/dist/emit/cli/install.js +3 -3
- package/dist/emit/cli/layout.d.ts +1 -1
- package/dist/emit/cli/layout.js +13 -10
- package/dist/emit/cli/module.d.ts +6 -6
- package/dist/emit/cli/module.js +10 -10
- package/dist/emit/cli/release.d.ts +0 -11
- package/dist/emit/cli/release.js +4 -4
- package/dist/emit/cli/skills.js +8 -4
- package/dist/emit/csharp/errors.js +4 -4
- package/dist/emit/csharp/json.js +8 -8
- package/dist/emit/csharp/realtime.d.ts +1 -8
- package/dist/emit/csharp/realtime.js +26 -26
- package/dist/emit/csharp/sdk-answer.d.ts +10 -2
- package/dist/emit/csharp/sdk-answer.js +4 -4
- package/dist/emit/csharp/sdk-body.js +8 -6
- package/dist/emit/csharp/sdk-client.d.ts +3 -3
- package/dist/emit/csharp/sdk-client.js +2 -2
- package/dist/emit/csharp/sdk-csproj.d.ts +7 -9
- package/dist/emit/csharp/sdk-csproj.js +10 -10
- package/dist/emit/csharp/sdk-doc.js +1 -1
- package/dist/emit/csharp/sdk-method.d.ts +0 -1
- package/dist/emit/csharp/sdk-method.js +19 -8
- package/dist/emit/csharp/sdk-plan.js +0 -1
- package/dist/emit/csharp/sdk.js +3 -3
- package/dist/emit/csharp/sse.d.ts +0 -13
- package/dist/emit/csharp/sse.js +92 -11
- package/dist/emit/csharp/transport.js +9 -9
- package/dist/emit/csharp/types-enum.js +3 -1
- package/dist/emit/csharp/types-messages.d.ts +47 -0
- package/dist/emit/csharp/types-messages.js +172 -0
- package/dist/emit/csharp/types-names.js +13 -14
- package/dist/emit/csharp/types-record.js +3 -3
- package/dist/emit/csharp/types-union.d.ts +1 -1
- package/dist/emit/csharp/types.d.ts +0 -1
- package/dist/emit/csharp/types.js +3 -3
- package/dist/emit/csharp/ws.d.ts +0 -15
- package/dist/emit/csharp/ws.js +26 -5
- package/dist/emit/go/errors.js +1 -1
- package/dist/emit/go/http.js +2 -2
- package/dist/emit/go/module-path.js +2 -2
- package/dist/emit/go/sdk-answer.d.ts +24 -1
- package/dist/emit/go/sdk-answer.js +1 -1
- package/dist/emit/go/sdk-body.js +11 -7
- package/dist/emit/go/sdk-client.js +1 -1
- package/dist/emit/go/sdk-method.d.ts +3 -0
- package/dist/emit/go/sdk-method.js +18 -12
- package/dist/emit/go/sdk-mirror.js +2 -2
- package/dist/emit/go/sdk-opts.d.ts +0 -2
- package/dist/emit/go/sdk-opts.js +3 -3
- package/dist/emit/go/sdk.d.ts +1 -1
- package/dist/emit/go/sdk.js +9 -9
- package/dist/emit/go/sse.d.ts +2 -10
- package/dist/emit/go/sse.js +88 -13
- package/dist/emit/go/types-names.js +5 -0
- package/dist/emit/go/types-struct.d.ts +2 -1
- package/dist/emit/go/types-struct.js +1 -1
- package/dist/emit/go/types-union.d.ts +3 -2
- package/dist/emit/go/types-union.js +2 -0
- package/dist/emit/go/types.d.ts +6 -0
- package/dist/emit/go/types.js +20 -9
- package/dist/emit/go/ws.d.ts +4 -11
- package/dist/emit/go/ws.js +215 -59
- package/dist/emit/java/gradle.d.ts +7 -9
- package/dist/emit/java/gradle.js +8 -8
- package/dist/emit/java/json.d.ts +3 -0
- package/dist/emit/java/json.js +1 -1
- package/dist/emit/java/layout-ast.d.ts +4 -1
- package/dist/emit/java/layout-ast.js +1 -1
- package/dist/emit/java/layout-decl.js +5 -4
- package/dist/emit/java/layout-doc.js +13 -7
- package/dist/emit/java/layout-dot.js +1 -1
- package/dist/emit/java/layout-strings.js +4 -5
- package/dist/emit/java/layout-types.js +7 -5
- package/dist/emit/java/layout-visitor.js +4 -3
- package/dist/emit/java/layout.js +5 -4
- package/dist/emit/java/models-names.d.ts +2 -0
- package/dist/emit/java/models-names.js +6 -4
- package/dist/emit/java/models-record.d.ts +0 -1
- package/dist/emit/java/models-record.js +3 -3
- package/dist/emit/java/models-union.d.ts +13 -2
- package/dist/emit/java/models-union.js +12 -6
- package/dist/emit/java/models.d.ts +5 -1
- package/dist/emit/java/models.js +44 -20
- package/dist/emit/java/realtime.d.ts +34 -26
- package/dist/emit/java/realtime.js +45 -10
- package/dist/emit/java/sdk-client.d.ts +6 -6
- package/dist/emit/java/sdk-client.js +1 -1
- package/dist/emit/java/sdk-decl.js +2 -2
- package/dist/emit/java/sdk-errors.js +1 -1
- package/dist/emit/java/sdk-headers.js +2 -2
- package/dist/emit/java/sdk-mirror.js +7 -6
- package/dist/emit/java/sdk-models.d.ts +1 -1
- package/dist/emit/java/sdk-models.js +7 -7
- package/dist/emit/java/sdk-op.d.ts +1 -10
- package/dist/emit/java/sdk-op.js +9 -9
- package/dist/emit/java/sdk-params.d.ts +5 -5
- package/dist/emit/java/sdk-params.js +3 -2
- package/dist/emit/java/sdk-plan.js +0 -1
- package/dist/emit/java/sdk.d.ts +1 -1
- package/dist/emit/java/sdk.js +14 -13
- package/dist/emit/java/sse.d.ts +12 -13
- package/dist/emit/java/sse.js +105 -6
- package/dist/emit/java/ws.d.ts +48 -9
- package/dist/emit/java/ws.js +88 -4
- package/dist/emit/mcp/annotations.js +8 -4
- package/dist/emit/mcp/files.js +9 -9
- package/dist/emit/mcp/mounted.js +2 -2
- package/dist/emit/mcp/output-schema.d.ts +4 -2
- package/dist/emit/mcp/output-schema.js +58 -14
- package/dist/emit/mcp/registry.d.ts +0 -2
- package/dist/emit/mcp/registry.js +5 -4
- package/dist/emit/mcp/runtime.js +2 -2
- package/dist/emit/mcp/schema.js +22 -11
- package/dist/emit/mcp/server.d.ts +7 -7
- package/dist/emit/mcp/server.js +7 -6
- package/dist/emit/mcp/tools.js +7 -6
- package/dist/emit/python/errors.js +3 -3
- package/dist/emit/python/realtime.d.ts +9 -6
- package/dist/emit/python/realtime.js +22 -20
- package/dist/emit/python/sdk-answer.d.ts +8 -8
- package/dist/emit/python/sdk-answer.js +2 -2
- package/dist/emit/python/sdk-body.js +4 -5
- package/dist/emit/python/sdk-client.js +5 -5
- package/dist/emit/python/sdk-doc.js +2 -2
- package/dist/emit/python/sdk-method.d.ts +1 -1
- package/dist/emit/python/sdk-method.js +38 -11
- package/dist/emit/python/sdk-plan.js +0 -1
- package/dist/emit/python/sdk-pyproject.d.ts +0 -2
- package/dist/emit/python/sdk-pyproject.js +8 -8
- package/dist/emit/python/sdk.d.ts +1 -1
- package/dist/emit/python/sdk.js +28 -8
- package/dist/emit/python/sse.d.ts +0 -7
- package/dist/emit/python/sse.js +36 -6
- package/dist/emit/python/transport.js +4 -4
- package/dist/emit/python/types-dict.d.ts +2 -2
- package/dist/emit/python/types-dict.js +1 -1
- package/dist/emit/python/types-names.js +2 -2
- package/dist/emit/python/types-union.js +1 -1
- package/dist/emit/python/types.d.ts +7 -0
- package/dist/emit/python/types.js +23 -6
- package/dist/emit/python/ws.d.ts +21 -10
- package/dist/emit/python/ws.js +69 -3
- package/dist/emit/rust/errors.js +3 -3
- package/dist/emit/rust/http.js +4 -4
- package/dist/emit/rust/realtime.d.ts +7 -5
- package/dist/emit/rust/realtime.js +15 -18
- package/dist/emit/rust/sdk-body.js +8 -5
- package/dist/emit/rust/sdk-cargo.d.ts +16 -18
- package/dist/emit/rust/sdk-cargo.js +12 -12
- package/dist/emit/rust/sdk-client.d.ts +1 -1
- package/dist/emit/rust/sdk-client.js +3 -3
- package/dist/emit/rust/sdk-method.js +3 -3
- package/dist/emit/rust/sdk-opts.d.ts +2 -1
- package/dist/emit/rust/sdk-opts.js +2 -2
- package/dist/emit/rust/sdk-plan.js +0 -1
- package/dist/emit/rust/sdk.d.ts +1 -1
- package/dist/emit/rust/sdk.js +5 -5
- package/dist/emit/rust/sse.d.ts +11 -12
- package/dist/emit/rust/sse.js +54 -8
- package/dist/emit/rust/types-names.js +3 -3
- package/dist/emit/rust/types-struct.js +1 -1
- package/dist/emit/rust/types-union.d.ts +10 -2
- package/dist/emit/rust/types-union.js +4 -0
- package/dist/emit/rust/types.d.ts +9 -0
- package/dist/emit/rust/types.js +20 -12
- package/dist/emit/rust/ws.d.ts +22 -15
- package/dist/emit/rust/ws.js +60 -10
- package/dist/emit/shared/escape.js +17 -17
- package/dist/emit/shared/format.js +1 -1
- package/dist/emit/shared/gofmt.js +1 -1
- package/dist/emit/shared/lang.js +10 -10
- package/dist/emit/shared/literals.d.ts +5 -0
- package/dist/emit/shared/literals.js +8 -0
- package/dist/emit/shared/metadata.d.ts +0 -6
- package/dist/emit/shared/metadata.js +8 -7
- package/dist/emit/shared/ruff.js +1 -1
- package/dist/emit/shared/rustfmt.js +1 -1
- package/dist/emit/shared/type-emitter.js +37 -20
- package/dist/emit/shared/unknown-type.constants.d.ts +2 -0
- package/dist/emit/shared/unknown-type.constants.js +2 -0
- package/dist/emit/ts/http.d.ts +0 -2
- package/dist/emit/ts/http.js +4 -4
- package/dist/emit/ts/package.d.ts +14 -12
- package/dist/emit/ts/package.js +9 -8
- package/dist/emit/ts/route-tree.js +2 -2
- package/dist/emit/ts/sdk-types-preamble.d.ts +1 -1
- package/dist/emit/ts/sdk-types-preamble.js +6 -2
- package/dist/emit/ts/sdk-types.js +59 -20
- package/dist/emit/ts/sdk.js +6 -6
- package/dist/emit/ts/service-map.d.ts +10 -3
- package/dist/emit/ts/service-map.js +30 -2
- package/dist/emit/ts/tanstack-query.js +6 -6
- package/dist/emit/ts/type-gen.js +36 -21
- package/dist/emit/ts/webhooks.d.ts +0 -2
- package/dist/emit/ts/webhooks.js +3 -3
- package/dist/extract/chain.js +5 -4
- package/dist/extract/extract.js +5 -5
- package/dist/extract/serialize.d.ts +0 -2
- package/dist/extract/serialize.js +14 -15
- package/dist/extract/walk.js +15 -12
- package/dist/gen/args.js +9 -5
- package/dist/gen/formatters.js +5 -3
- package/dist/gen/shipped.js +2 -2
- package/dist/gen/targets.d.ts +2 -4
- package/dist/gen/targets.js +8 -4
- package/dist/gen/write.js +4 -2
- package/dist/index.js +2 -2
- package/dist/installers/cli.d.ts +4 -4
- package/dist/installers/cli.js +24 -24
- package/dist/installers/commands/build.d.ts +4 -4
- package/dist/installers/commands/build.js +2 -3
- package/dist/installers/commands/check.d.ts +2 -2
- package/dist/installers/commands/check.js +11 -10
- package/dist/installers/commands/init.d.ts +2 -2
- package/dist/installers/commands/init.js +1 -2
- package/dist/installers/config/define-config.d.ts +16 -16
- package/dist/installers/config/define-config.js +1 -1
- package/dist/installers/config/hooks/bun.d.ts +6 -6
- package/dist/installers/config/hooks/node.js +1 -1
- package/dist/installers/config/load.d.ts +6 -8
- package/dist/installers/config/load.js +7 -8
- package/dist/installers/config/resolve.d.ts +1 -2
- package/dist/installers/config/resolve.js +28 -33
- package/dist/installers/config/types.d.ts +6 -6
- package/dist/installers/config/types.js +0 -1
- package/dist/installers/render/quote.js +3 -5
- package/dist/installers/render/render.d.ts +6 -6
- package/dist/installers/render/render.js +26 -26
- package/dist/installers/ui.d.ts +4 -4
- package/dist/installers/ui.js +3 -3
- package/dist/ir/build.d.ts +3 -3
- package/dist/ir/build.js +12 -5
- package/dist/ir/load.js +9 -10
- package/dist/ir/model.d.ts +16 -1
- package/dist/ir/model.js +0 -1
- package/dist/ir/resolve-refs.js +2 -2
- package/dist/ir/resource-tree.js +2 -1
- package/dist/ir/route-tree-intern.js +1 -1
- package/dist/ir/schema.js +3 -3
- package/dist/ir/sdk-model.d.ts +25 -1
- package/dist/ir/sdk-model.js +38 -8
- package/dist/ir/slots.d.ts +1 -1
- package/dist/ir/slots.js +22 -11
- package/dist/ir/streams.d.ts +16 -0
- package/dist/ir/streams.js +40 -0
- package/dist/release/bootstrap.d.ts +3 -3
- package/dist/release/bootstrap.js +7 -7
- package/dist/release/bump-args.js +4 -4
- package/dist/release/bump-command.d.ts +1 -1
- package/dist/release/bump-command.js +9 -10
- package/dist/release/bump.d.ts +5 -4
- package/dist/release/bump.js +2 -2
- package/dist/release/cli.d.ts +4 -4
- package/dist/release/cli.js +4 -4
- package/dist/release/codegen.js +1 -1
- package/dist/release/digest.js +5 -7
- package/dist/release/git.js +5 -8
- package/dist/release/load.js +3 -3
- package/dist/release/manifest.js +9 -10
- package/dist/release/oasdiff.d.ts +10 -15
- package/dist/release/oasdiff.js +5 -6
- package/dist/release/registries.d.ts +0 -11
- package/dist/release/registries.js +17 -17
- package/dist/release/release-state.d.ts +16 -13
- package/dist/release/release-workflow.js +5 -7
- package/dist/release/repo-settings.d.ts +2 -1
- package/dist/release/spec-gate.d.ts +0 -2
- package/dist/release/spec-gate.js +6 -10
- package/dist/release/sync-command.d.ts +2 -2
- package/dist/release/sync-command.js +1 -1
- package/dist/release/sync-tree.js +9 -13
- package/dist/release/sync.d.ts +6 -6
- package/dist/release/sync.js +12 -13
- package/dist/release/types.d.ts +22 -22
- package/dist/release/types.js +0 -1
- package/dist/release/version-files.d.ts +3 -4
- package/dist/release/version-files.js +4 -5
- package/dist/runtime/.oxfmtrc.jsonc +8 -0
- package/dist/runtime/cli/socket.go +107 -13
- package/dist/runtime/cli/stream.go +18 -11
- package/dist/runtime/csharp/Adapters.cs +12 -11
- package/dist/runtime/csharp/Events.cs +22 -17
- package/dist/runtime/csharp/Realtime.cs +50 -23
- package/dist/runtime/csharp/RealtimeLoop.cs +1 -1
- package/dist/runtime/csharp/TransportSse.cs +3 -3
- package/dist/runtime/csharp/Ws.cs +1 -1
- package/dist/runtime/csharp/WsDial.cs +19 -1
- package/dist/runtime/csharp/WsTyped.cs +109 -0
- package/dist/runtime/go/realtime.go +125 -41
- package/dist/runtime/go/realtime_loop.go +21 -18
- package/dist/runtime/go/result.go +2 -1
- package/dist/runtime/go/sse.go +11 -0
- package/dist/runtime/go/stream.go +29 -13
- package/dist/runtime/go/transport.go +15 -21
- package/dist/runtime/go/transport_longpoll.go +3 -4
- package/dist/runtime/go/transport_sse.go +6 -6
- package/dist/runtime/go/ws.go +157 -61
- package/dist/runtime/java/EventStream.java +47 -29
- package/dist/runtime/java/Exchange.java +5 -5
- package/dist/runtime/java/Flight.java +3 -3
- package/dist/runtime/java/Realtime.java +45 -11
- package/dist/runtime/java/ResumableConnection.java +77 -32
- package/dist/runtime/java/Socket.java +8 -4
- package/dist/runtime/java/SseAdapter.java +1 -1
- package/dist/runtime/java/TypedWebSocket.java +81 -24
- package/dist/runtime/java/WsAdapter.java +4 -2
- package/dist/runtime/java/WsDial.java +12 -5
- package/dist/runtime/mcp/files.ts +1 -1
- package/dist/runtime/mcp/http.ts +6 -2
- package/dist/runtime/mcp/listen.ts +1 -1
- package/dist/runtime/mcp/mount.ts +2 -2
- package/dist/runtime/mcp/protocol.ts +1 -1
- package/dist/runtime/python/events.py +25 -11
- package/dist/runtime/python/operation.py +6 -1
- package/dist/runtime/python/realtime.py +47 -33
- package/dist/runtime/python/send_async.py +1 -0
- package/dist/runtime/python/transport_sse.py +2 -2
- package/dist/runtime/python/transport_ws.py +1 -1
- package/dist/runtime/python/ws.py +100 -39
- package/dist/runtime/rust/events.rs +64 -41
- package/dist/runtime/rust/realtime.rs +80 -34
- package/dist/runtime/rust/realtime_loop.rs +37 -12
- package/dist/runtime/rust/sse.rs +3 -2
- package/dist/runtime/rust/transport_sse.rs +1 -1
- package/dist/runtime/rust/transport_ws.rs +3 -2
- package/dist/runtime/rust/ws.rs +122 -50
- package/dist/runtime/ts/realtime-connection.ts +22 -0
- package/dist/runtime/ts/realtime-transports.ts +13 -4
- package/dist/runtime/ts/realtime.ts +27 -3
- package/dist/runtime/ts/sdk-realtime.ts +1 -1
- package/dist/runtime/ts/sdk-sse.ts +31 -14
- package/dist/runtime/ts/sdk-ws.ts +2 -1
- package/dist/runtime/ts/sdk.ts +9 -2
- package/dist/runtime/ts/sse.ts +8 -0
- package/dist/runtime/ts/ws.ts +88 -50
- package/dist/runtime/ts-tanstack-query/query.ts +0 -2
- package/package.json +12 -40
- package/dist/emit/cli/index.d.ts +0 -1
- package/dist/emit/cli/index.js +0 -1
- package/dist/emit/csharp/index.d.ts +0 -1
- package/dist/emit/csharp/index.js +0 -1
- package/dist/emit/go/index.d.ts +0 -1
- package/dist/emit/go/index.js +0 -1
- package/dist/emit/java/index.d.ts +0 -2
- package/dist/emit/java/index.js +0 -2
- package/dist/emit/mcp/index.d.ts +0 -3
- package/dist/emit/mcp/index.js +0 -3
- package/dist/emit/python/index.d.ts +0 -1
- package/dist/emit/python/index.js +0 -1
- package/dist/emit/rust/index.d.ts +0 -1
- package/dist/emit/rust/index.js +0 -1
|
@@ -1,34 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A realtime operation's method (bit 16 phase d2b, R1/R8; C#'s `realtime.ts`, Fd6/Fd7):
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
2
|
+
* A realtime operation's method (bit 16 phase d2b, R1/R8, D9; C#'s `realtime.ts`, Fd6/Fd7):
|
|
3
|
+
* `ResumableConnection<TIn, TOut>`, `TIn` what the server sends (`send`), else the declared event schema's type, else
|
|
4
|
+
* `JsonNode`, and `TOut` what it receives (`receive`), else `JsonNode`; an inline side is hoisted as `<Op>Send` or
|
|
5
|
+
* `<Op>Receive`. A keyed read side (the sealed interface models-union.ts declares) with a member to handle answers
|
|
6
|
+
* `<Read>Connection<TOut>`, whose `on<Value>` per member matches inside `onMessage`, none for a `message` member; its
|
|
7
|
+
* name is claimed after the union's wrappers, as ws.ts claims a socket's. An op that declares its messages connects
|
|
8
|
+
* through `Realtime.typed`, which refuses a message that is no JSON; any other through `Realtime.open`, which reads it
|
|
9
|
+
* as a JSON string; either before the method returns, over WebSocket, else SSE, else long-poll. Its five fields are
|
|
10
|
+
* `TransportOptions.of`'s: the resume cursor (`lastEventId`, `reconnectToken`), the offered `protocols` and the
|
|
11
|
+
* reconnect policy (`maxReconnectAttempts`, `reconnectDelay`). The runtime puts the cursor on each dial, so none of
|
|
12
|
+
* them is a Call arg; a declared `last_event_id` or `reconnect_token` query, or a Last-Event-ID header, folds in, and a
|
|
13
|
+
* param spelled like a field claims `…2`. A realtime method is the same text in either mode: it answers no Result.
|
|
9
14
|
*/
|
|
10
15
|
import type { SdkOp } from "../../ir/sdk-model.ts";
|
|
16
|
+
import { type Expr } from "./layout.ts";
|
|
11
17
|
import { type JavaTypeContext } from "./models.ts";
|
|
12
18
|
/** The reconnect policy's Params fields. */
|
|
13
19
|
export declare const MAX_RECONNECT_ATTEMPTS = "maxReconnectAttempts";
|
|
14
20
|
export declare const RECONNECT_DELAY = "reconnectDelay";
|
|
15
21
|
/** A realtime op's own fields in `TransportOptions.of`'s order, each with its Java type. */
|
|
16
|
-
export declare const REALTIME_FIELDS: readonly
|
|
17
|
-
readonly field:
|
|
18
|
-
readonly type:
|
|
19
|
-
}
|
|
20
|
-
readonly field: "reconnectToken";
|
|
21
|
-
readonly type: "String";
|
|
22
|
-
}, {
|
|
23
|
-
readonly field: "protocols";
|
|
24
|
-
readonly type: "List<String>";
|
|
25
|
-
}, {
|
|
26
|
-
readonly field: "maxReconnectAttempts";
|
|
27
|
-
readonly type: "java.lang.Integer";
|
|
28
|
-
}, {
|
|
29
|
-
readonly field: "reconnectDelay";
|
|
30
|
-
readonly type: "Duration";
|
|
31
|
-
}];
|
|
22
|
+
export declare const REALTIME_FIELDS: readonly {
|
|
23
|
+
readonly field: string;
|
|
24
|
+
readonly type: string;
|
|
25
|
+
}[];
|
|
32
26
|
/** Whether a declared param is on a realtime resume channel the cursor fields carry (C#'s `carries`). */
|
|
33
27
|
export declare const carriesRealtime: (name: string, where: "query" | "header") => boolean;
|
|
34
28
|
/**
|
|
@@ -36,9 +30,23 @@ export declare const carriesRealtime: (name: string, where: "query" | "header")
|
|
|
36
30
|
* adapters; only an SDK with a realtime operation ships them (with the WebSocket files, which its WebSocket adapter dials
|
|
37
31
|
* through).
|
|
38
32
|
*/
|
|
39
|
-
export declare const REALTIME_FILES: string[];
|
|
40
|
-
/**
|
|
41
|
-
|
|
33
|
+
export declare const REALTIME_FILES: readonly string[];
|
|
34
|
+
/**
|
|
35
|
+
* What a realtime method answers: its type, the type its messages decode to, whether they must be JSON (the op
|
|
36
|
+
* declares its messages), and the wrap of the opened connection.
|
|
37
|
+
*/
|
|
38
|
+
export type RealtimeConnection = {
|
|
39
|
+
readonly type: string;
|
|
40
|
+
readonly read: string;
|
|
41
|
+
readonly strict: boolean;
|
|
42
|
+
readonly wrap: (opened: Expr) => Expr;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* What `op`'s realtime method answers: `ResumableConnection<TIn, TOut>`, `TIn` the declared read side's type, else
|
|
46
|
+
* the event schema's, else `JsonNode`, `TOut` the declared write side's, else `JsonNode`; a keyed read side with a
|
|
47
|
+
* member to handle answers its `<Read>Connection<TOut>`, wrapping the opened one.
|
|
48
|
+
*/
|
|
49
|
+
export declare function connectionOf(op: SdkOp, ctx: JavaTypeContext): RealtimeConnection;
|
|
42
50
|
/** What a realtime method's lines need: its name and constant, its Params, and its Call's lines. */
|
|
43
51
|
export type RealtimeSite = {
|
|
44
52
|
readonly name: string;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { call as callOf, local, methodHeader, newOf, param, returnStmt, statement, } from "./layout.js";
|
|
2
|
+
import { JSON_NODE } from "./models-names.js";
|
|
3
|
+
import { declaredTypeOf, javaTypeOf, keyedArms } from "./models.js";
|
|
3
4
|
import { docOf } from "./sdk-decl.js";
|
|
4
5
|
import { CURSOR, isLastEventIdHeader } from "./sse.js";
|
|
5
|
-
import { isReconnectTokenQuery, PROTOCOLS, TOKEN } from "./ws.js";
|
|
6
|
+
import { handledArms, isReconnectTokenQuery, keyedReader, PROTOCOLS, TOKEN } from "./ws.js";
|
|
6
7
|
/** The reconnect policy's Params fields. */
|
|
7
8
|
export const MAX_RECONNECT_ATTEMPTS = "maxReconnectAttempts";
|
|
8
9
|
export const RECONNECT_DELAY = "reconnectDelay";
|
|
@@ -35,22 +36,56 @@ export const REALTIME_FILES = [
|
|
|
35
36
|
"TransportOptions",
|
|
36
37
|
"WsAdapter",
|
|
37
38
|
];
|
|
38
|
-
/** The
|
|
39
|
-
|
|
39
|
+
/** The connection's reader: its own handler is onMessage. */
|
|
40
|
+
const CONNECTION = {
|
|
41
|
+
base: "ResumableConnection",
|
|
42
|
+
handlers: ["onMessage"],
|
|
43
|
+
noun: "connection",
|
|
44
|
+
suffix: "Connection",
|
|
45
|
+
};
|
|
46
|
+
/** The opened connection as it is: one whose read side has no member to handle. */
|
|
47
|
+
const AS_OPENED = (opened) => opened;
|
|
48
|
+
/**
|
|
49
|
+
* What `op`'s realtime method answers: `ResumableConnection<TIn, TOut>`, `TIn` the declared read side's type, else
|
|
50
|
+
* the event schema's, else `JsonNode`, `TOut` the declared write side's, else `JsonNode`; a keyed read side with a
|
|
51
|
+
* member to handle answers its `<Read>Connection<TOut>`, wrapping the opened one.
|
|
52
|
+
*/
|
|
53
|
+
export function connectionOf(op, ctx) {
|
|
54
|
+
const messages = op.ir.messages;
|
|
55
|
+
const at = (fieldName) => ({ ...ctx, fieldName, parentName: op.id, path: "" });
|
|
56
|
+
const strict = messages !== undefined;
|
|
57
|
+
const write = messages?.receive === undefined ? JSON_NODE : declaredTypeOf(messages.receive, at("Receive"));
|
|
58
|
+
const plain = (read) => ({
|
|
59
|
+
read,
|
|
60
|
+
strict,
|
|
61
|
+
type: `ResumableConnection<${read}, ${write}>`,
|
|
62
|
+
wrap: AS_OPENED,
|
|
63
|
+
});
|
|
64
|
+
if (messages?.send === undefined) {
|
|
65
|
+
const events = { ...ctx, fieldName: "Event", parentName: op.id };
|
|
66
|
+
return plain(op.events === undefined ? JSON_NODE : javaTypeOf(op.events, events));
|
|
67
|
+
}
|
|
68
|
+
const read = declaredTypeOf(messages.send, at("Send"));
|
|
69
|
+
const arms = keyedArms(read, messages.send, ctx);
|
|
70
|
+
if (handledArms(CONNECTION, arms).length === 0)
|
|
71
|
+
return plain(read);
|
|
72
|
+
const sub = keyedReader(CONNECTION, read, arms, ctx);
|
|
73
|
+
return { read, strict, type: `${sub}<${write}>`, wrap: (opened) => newOf(`${sub}<${write}>`, [opened]) };
|
|
74
|
+
}
|
|
40
75
|
/** A realtime method's lines: `op(params)`, delegating to `op(params, options)`, which connects. */
|
|
41
76
|
export function realtimeMethodLines(op, site, ctx) {
|
|
42
77
|
const { call, constant, name, params } = site;
|
|
43
|
-
const
|
|
78
|
+
const connection = connectionOf(op, ctx);
|
|
44
79
|
const doc = docOf(`${op.id}: the connection over WebSocket, else SSE, else long-poll. It reconnects after a drop and resumes after the last message it delivered; close() ends it.`);
|
|
45
|
-
const signature = (args) => methodHeader(2, { modifiers: ["public"], name, params: args, returns:
|
|
80
|
+
const signature = (args) => methodHeader(2, { modifiers: ["public"], name, params: args, returns: connection.type });
|
|
46
81
|
const transport = callOf("TransportOptions", "of", REALTIME_FIELDS.map((f) => callOf("params", f.field)));
|
|
47
|
-
const open = callOf("Realtime", "open", [
|
|
82
|
+
const open = callOf("Realtime", connection.strict ? "typed" : "open", [
|
|
48
83
|
"exchange",
|
|
49
84
|
constant,
|
|
50
85
|
"call",
|
|
51
86
|
"options",
|
|
52
87
|
"transport",
|
|
53
|
-
newOf(`TypeReference<${
|
|
88
|
+
newOf(`TypeReference<${connection.read}>`, [], true),
|
|
54
89
|
]);
|
|
55
90
|
return [
|
|
56
91
|
doc,
|
|
@@ -62,7 +97,7 @@ export function realtimeMethodLines(op, site, ctx) {
|
|
|
62
97
|
...signature([param(params, "params"), param("RequestOptions", "options")]),
|
|
63
98
|
...call,
|
|
64
99
|
...statement(4, local({ init: transport, name: "transport", type: "TransportOptions" })),
|
|
65
|
-
...statement(4, returnStmt(open)),
|
|
100
|
+
...statement(4, returnStmt(connection.wrap(open))),
|
|
66
101
|
" }",
|
|
67
102
|
"",
|
|
68
103
|
];
|
|
@@ -44,13 +44,13 @@ export declare function nodeOf(ns: IRNamespace, path: readonly string[]): Node;
|
|
|
44
44
|
* mirror's `safe` is held, so a member spelled `safe` is `safe_` instead, and noticed (shared/mirror.ts's one rule).
|
|
45
45
|
*/
|
|
46
46
|
export declare function membersOf(node: Node, env: SurfaceEnv): {
|
|
47
|
-
children: {
|
|
48
|
-
child: Node;
|
|
49
|
-
name: string;
|
|
47
|
+
readonly children: {
|
|
48
|
+
readonly child: Node;
|
|
49
|
+
readonly name: string;
|
|
50
50
|
}[];
|
|
51
|
-
ops: {
|
|
52
|
-
name: string;
|
|
53
|
-
op: JavaOp;
|
|
51
|
+
readonly ops: {
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly op: JavaOp;
|
|
54
54
|
}[];
|
|
55
55
|
};
|
|
56
56
|
/** A list of blocks, each set apart by one blank line; a block's own trailing blank lines are dropped. */
|
|
@@ -60,7 +60,7 @@ export const blocks = (parts) => parts
|
|
|
60
60
|
.flatMap((part, i) => (i === 0 ? part : ["", ...part]));
|
|
61
61
|
/** The lines without their leading and trailing blank lines. */
|
|
62
62
|
function trimmed(lines) {
|
|
63
|
-
const text = lines.join("\n").
|
|
63
|
+
const text = lines.join("\n").replaceAll(/^(?:\n)+|(?:\n)+$/g, "");
|
|
64
64
|
return text === "" ? [] : text.split("\n");
|
|
65
65
|
}
|
|
66
66
|
/** The operations' constants and methods of a class, each block set apart. */
|
|
@@ -15,8 +15,8 @@ const control = (cp) => cp < 0x20 || cp === 0x7f || cp === 0xfeff || cp === 0x20
|
|
|
15
15
|
const docText = (text) => [...text.toWellFormed()]
|
|
16
16
|
.map((ch) => (control(ch.codePointAt(0)) ? " " : ch))
|
|
17
17
|
.join("")
|
|
18
|
-
.
|
|
19
|
-
.
|
|
18
|
+
.replaceAll("\\", "\")
|
|
19
|
+
.replaceAll("*/", "*/");
|
|
20
20
|
/**
|
|
21
21
|
* A `/** … *\/` doc comment at `indent`, its text made safe (docText): one line when it fits in 100 columns, else
|
|
22
22
|
* google-java-format's filled lines, each word on the first line it fits, after ` * `.
|
|
@@ -60,7 +60,7 @@ function classLines({ name, doc, base, cause, param }) {
|
|
|
60
60
|
`public final class ${name} extends ${base} {`,
|
|
61
61
|
" private static final long serialVersionUID = 1L;",
|
|
62
62
|
"",
|
|
63
|
-
` ${name}(${param === "failure" ? "Failure failure" :
|
|
63
|
+
` ${name}(${param === "failure" ? "Failure failure" : `String message${cause ? ", Throwable cause" : ""}`}) {`,
|
|
64
64
|
` super(${args});`,
|
|
65
65
|
" }",
|
|
66
66
|
"}",
|
|
@@ -23,7 +23,7 @@ function declaredHeaders(op) {
|
|
|
23
23
|
.filter((status) => /^2(?:\d\d|XX)$/i.test(status))
|
|
24
24
|
.sort(compareCodeUnits)
|
|
25
25
|
.flatMap((status) => op.ir.responses[status].headers ?? []);
|
|
26
|
-
|
|
26
|
+
// reversed, so the first spelling of a name is the one its key ends on
|
|
27
27
|
const first = new Map(all.toReversed().map((header) => [header.name.toLowerCase(), header]));
|
|
28
28
|
return [...first.values()].sort((a, b) => compareCodeUnits(a.name, b.name));
|
|
29
29
|
}
|
|
@@ -59,7 +59,7 @@ export function javaResponseHeaders(op, env) {
|
|
|
59
59
|
...fields.flatMap(({ accessor, header, parse, word }) => statement(4, exprStmt(assign(accessor, call("Answer", "header", [
|
|
60
60
|
"headers",
|
|
61
61
|
javaString(header.name),
|
|
62
|
-
String(header.required
|
|
62
|
+
String(header.required),
|
|
63
63
|
javaString(word),
|
|
64
64
|
parse,
|
|
65
65
|
]))))),
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { messageTypeOf } from "./realtime.js";
|
|
2
1
|
import { accessor, assign, call, classHeader, exprStmt, finalField, lambda, methodHeader, newOf, param, returnStmt, statement, } from "./layout.js";
|
|
2
|
+
import { connectionOf } from "./realtime.js";
|
|
3
|
+
import { blocks, clientLines, membersOf, nodeOf, recordSource, resourceName, } from "./sdk-client.js";
|
|
3
4
|
import { docOf, docParagraphs } from "./sdk-decl.js";
|
|
4
5
|
import { putFile } from "./sdk-models.js";
|
|
5
6
|
import { answerOf, paragraphsOf } from "./sdk-op.js";
|
|
6
7
|
import { paramsName } from "./sdk-params.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
8
|
+
import { sseEventOf } from "./sse.js";
|
|
9
|
+
import { wsSocketOf } from "./ws.js";
|
|
9
10
|
/** The type the normal method answers: a stream's, a connection's, or the answer's (`void` for none). */
|
|
10
11
|
function returnsOf(op, env) {
|
|
11
12
|
if (op.stream === "sse")
|
|
12
|
-
return `EventStream<${
|
|
13
|
+
return `EventStream<${sseEventOf(op, env.ctx).type}>`;
|
|
13
14
|
if (op.stream === "ws")
|
|
14
|
-
return
|
|
15
|
+
return wsSocketOf(op, env.ctx).type;
|
|
15
16
|
if (op.stream === "realtime")
|
|
16
|
-
return
|
|
17
|
+
return connectionOf(op, env.ctx).type;
|
|
17
18
|
return answerOf(op, env).type;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type JavaTypeContext } from "./models.ts";
|
|
2
1
|
import type { IR } from "../../ir/model.ts";
|
|
2
|
+
import { type JavaTypeContext } from "./models.ts";
|
|
3
3
|
/** The import lines `decl` needs, sorted as google-java-format sorts them. */
|
|
4
4
|
export declare function importsOf(decl: string): string[];
|
|
5
5
|
/** One model file's text: the marker, the package, its imports, its declaration. */
|
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
* needs its own. A file imports exactly the types its text spells, in google-java-format's order: one block, sorted.
|
|
5
5
|
*/
|
|
6
6
|
import { compareCodeUnits } from "../shared/lang.js";
|
|
7
|
-
import { declares, javaTopLevel } from "./models.js";
|
|
8
7
|
import { codeOf } from "./models-names.js";
|
|
9
|
-
|
|
8
|
+
import { declares, javaTopLevel } from "./models.js";
|
|
9
|
+
// every type a model declaration may spell that java.lang does not hold, by its simple name
|
|
10
10
|
const IMPORTS = {
|
|
11
|
+
Consumer: "java.util.function.Consumer",
|
|
11
12
|
DeserializationContext: "tools.jackson.databind.DeserializationContext",
|
|
13
|
+
Duration: "java.time.Duration",
|
|
14
|
+
InputStream: "java.io.InputStream",
|
|
12
15
|
JsonAnyGetter: "com.fasterxml.jackson.annotation.JsonAnyGetter",
|
|
13
16
|
JsonAnySetter: "com.fasterxml.jackson.annotation.JsonAnySetter",
|
|
14
17
|
JsonCreator: "com.fasterxml.jackson.annotation.JsonCreator",
|
|
@@ -19,12 +22,9 @@ const IMPORTS = {
|
|
|
19
22
|
JsonProperty: "com.fasterxml.jackson.annotation.JsonProperty",
|
|
20
23
|
JsonValue: "com.fasterxml.jackson.annotation.JsonValue",
|
|
21
24
|
LinkedHashMap: "java.util.LinkedHashMap",
|
|
25
|
+
List: "java.util.List",
|
|
22
26
|
Map: "java.util.Map",
|
|
23
27
|
StdDeserializer: "tools.jackson.databind.deser.std.StdDeserializer",
|
|
24
|
-
Consumer: "java.util.function.Consumer",
|
|
25
|
-
Duration: "java.time.Duration",
|
|
26
|
-
InputStream: "java.io.InputStream",
|
|
27
|
-
List: "java.util.List",
|
|
28
28
|
Supplier: "java.util.function.Supplier",
|
|
29
29
|
TypeReference: "tools.jackson.core.type.TypeReference",
|
|
30
30
|
};
|
|
@@ -51,7 +51,7 @@ export function componentDecls(ir, ctx) {
|
|
|
51
51
|
const name = ctx.names.ref(key);
|
|
52
52
|
decls.set(name, javaTopLevel(name, schema, ctx));
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
// a hoist claims its name from the same scope as the components, so it never repeats one
|
|
55
55
|
for (const [name, decl] of ctx.decls)
|
|
56
56
|
decls.set(name, decl);
|
|
57
57
|
return decls;
|
|
@@ -8,11 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { IRSchema } from "../../ir/model.ts";
|
|
10
10
|
import type { SdkOp } from "../../ir/sdk-model.ts";
|
|
11
|
-
import { type JavaTypeContext } from "./models.ts";
|
|
12
11
|
import { type Expr } from "./layout.ts";
|
|
12
|
+
import { type JavaTypeContext } from "./models.ts";
|
|
13
13
|
import { type JavaHeaders } from "./sdk-headers.ts";
|
|
14
14
|
import type { JavaCallPlan } from "./sdk-plan.ts";
|
|
15
|
-
import { type Field } from "./sdk-params.ts";
|
|
16
15
|
/** What an operation's text needs: the type context its types hoist into, and the array test. */
|
|
17
16
|
export type OpEnv = {
|
|
18
17
|
readonly ctx: JavaTypeContext;
|
|
@@ -40,18 +39,10 @@ export type JavaOp = {
|
|
|
40
39
|
};
|
|
41
40
|
/** A method's javadoc paragraphs: the operation's id, then its summary and description, as the other SDKs carry them. */
|
|
42
41
|
export declare const paragraphsOf: (op: SdkOp) => string[];
|
|
43
|
-
/** The constant's name for a method: its words upper-cased, `_OPERATION` after them. */
|
|
44
|
-
export declare const constantOf: (method: string) => string;
|
|
45
42
|
/** The answer's Java type and its reader on `answer`, for each response kind. */
|
|
46
43
|
export declare function answerOf(op: SdkOp, env: OpEnv): {
|
|
47
44
|
readonly reader: Expr;
|
|
48
45
|
readonly type: string;
|
|
49
46
|
};
|
|
50
|
-
/** One method's name, its fields, and the holder of its response headers when it declares any. */
|
|
51
|
-
export type MethodSite = {
|
|
52
|
-
readonly name: string;
|
|
53
|
-
readonly fields: readonly Field[];
|
|
54
|
-
readonly headers: JavaHeaders | null;
|
|
55
|
-
};
|
|
56
47
|
/** One operation's text and plan, with its accessors left to the resource tree. */
|
|
57
48
|
export declare function javaOp(op: SdkOp, name: string, env: OpEnv): JavaOp;
|
package/dist/emit/java/sdk-op.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { javaString } from "../shared/escape.js";
|
|
2
2
|
import { snakeWords } from "../shared/lang.js";
|
|
3
|
-
import { javaTypeOf } from "./models.js";
|
|
4
3
|
import { array, call, exprStmt, field, lit, local, methodHeader, param, newOf, returnStmt, statement, } from "./layout.js";
|
|
4
|
+
import { javaTypeOf } from "./models.js";
|
|
5
|
+
import { MAX_RECONNECT_ATTEMPTS, RECONNECT_DELAY, realtimeMethodLines } from "./realtime.js";
|
|
5
6
|
import { docParagraphs } from "./sdk-decl.js";
|
|
6
7
|
import { javaResponseHeaders } from "./sdk-headers.js";
|
|
7
|
-
import {
|
|
8
|
+
import { fieldsOf, multipartRecord, paramsName } from "./sdk-params.js";
|
|
9
|
+
import { multipartHelper, multipartRecordLines, paramsRecord } from "./sdk-record.js";
|
|
8
10
|
import { CURSOR, sseMethodLines } from "./sse.js";
|
|
9
11
|
import { PROTOCOLS, TOKEN, wsMethodLines } from "./ws.js";
|
|
10
|
-
import { multipartHelper, multipartRecordLines, paramsRecord } from "./sdk-record.js";
|
|
11
|
-
import { fieldsOf, multipartRecord, paramsName } from "./sdk-params.js";
|
|
12
12
|
const UNKNOWN = { kind: "unknown" };
|
|
13
13
|
/** A method's javadoc paragraphs: the operation's id, then its summary and description, as the other SDKs carry them. */
|
|
14
14
|
export const paragraphsOf = (op) => [op.id, op.summary, op.description].filter((text) => text !== "");
|
|
15
15
|
/** The constant's name for a method: its words upper-cased, `_OPERATION` after them. */
|
|
16
|
-
|
|
16
|
+
const constantOf = (method) => `${snakeWords(method).toUpperCase()}_OPERATION`;
|
|
17
17
|
/** The answer's Java type and its reader on `answer`, for each response kind. */
|
|
18
18
|
export function answerOf(op, env) {
|
|
19
19
|
const kind = op.success.kind;
|
|
@@ -80,7 +80,7 @@ function streamMethodLines(op, site, env) {
|
|
|
80
80
|
if (op.stream === "sse")
|
|
81
81
|
return sseMethodLines(op, { call: lines, constant, headers, name, params }, env.ctx);
|
|
82
82
|
if (op.stream === "ws")
|
|
83
|
-
return wsMethodLines(op, { call: lines, constant, name, params });
|
|
83
|
+
return wsMethodLines(op, { call: lines, constant, name, params }, env.ctx);
|
|
84
84
|
return realtimeMethodLines(op, { call: lines, constant, name, params }, env.ctx);
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
@@ -97,7 +97,7 @@ function methodLines(op, site, env) {
|
|
|
97
97
|
const answer = answerOf(op, env);
|
|
98
98
|
const returns = answer.type;
|
|
99
99
|
const params = paramsName(op, env.ctx);
|
|
100
|
-
|
|
100
|
+
// `return value;`, or the statement alone for no answer
|
|
101
101
|
const ret = (value) => statement(4, returns === "void" ? exprStmt(value) : returnStmt(value));
|
|
102
102
|
const delegate = (args) => ret(call(null, name, args));
|
|
103
103
|
const fill = headers === null
|
|
@@ -205,10 +205,10 @@ export function javaOp(op, name, env) {
|
|
|
205
205
|
body: multipart === null
|
|
206
206
|
? null
|
|
207
207
|
: { lines: multipartRecordLines(multipart.name, op.id, multipart.components), name: multipart.name },
|
|
208
|
-
headers,
|
|
209
|
-
helper: multipartHelper(op, env),
|
|
210
208
|
constant,
|
|
211
209
|
constantLines: constantLines(op, constant),
|
|
210
|
+
headers,
|
|
211
|
+
helper: multipartHelper(op, env),
|
|
212
212
|
lines: methodLines(op, { fields, headers, name }, env),
|
|
213
213
|
params: paramsRecord(paramsName(op, env.ctx), op.id, fields),
|
|
214
214
|
plan,
|
|
@@ -29,10 +29,10 @@ export declare const opTypeName: (op: SdkOp, kind: "Body" | "Headers" | "Params"
|
|
|
29
29
|
export declare const paramsName: (op: SdkOp, ctx: JavaTypeContext) => string;
|
|
30
30
|
/** Each multipart part as a record component: a file's `FilePart` or a list of them, a text part's type. */
|
|
31
31
|
export declare function multipartRecord(op: SdkOp, parts: readonly IRMultipartPart[], ctx: JavaTypeContext, isArray: (s: IRSchema) => boolean): {
|
|
32
|
-
components: {
|
|
33
|
-
field: string;
|
|
34
|
-
name: string;
|
|
35
|
-
type: string;
|
|
32
|
+
readonly components: {
|
|
33
|
+
readonly field: string;
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly type: string;
|
|
36
36
|
}[];
|
|
37
|
-
name: string;
|
|
37
|
+
readonly name: string;
|
|
38
38
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { compareCodeUnits, javaIdentifier, javaTypeName, NameScope } from "../shared/lang.js";
|
|
2
2
|
import { javaTypeOf } from "./models.js";
|
|
3
|
-
import { CURSOR, isLastEventIdHeader, LAST_EVENT_ID } from "./sse.js";
|
|
4
3
|
import { carriesRealtime, REALTIME_FIELDS } from "./realtime.js";
|
|
4
|
+
import { CURSOR, isLastEventIdHeader, LAST_EVENT_ID } from "./sse.js";
|
|
5
5
|
import { isReconnectTokenQuery, PROTOCOLS, RECONNECT_TOKEN, TOKEN } from "./ws.js";
|
|
6
6
|
/** The record's own members, which a component may not take (`builder()` is static). */
|
|
7
7
|
const RECORD_RESERVED = ["builder", "equals", "hashCode", "toString"];
|
|
@@ -88,7 +88,7 @@ export function fieldsOf(op, ctx) {
|
|
|
88
88
|
function streamFields(op) {
|
|
89
89
|
if (op.stream === "sse")
|
|
90
90
|
return [{ field: CURSOR, name: LAST_EVENT_ID, required: false, type: "String", where: "cursor" }];
|
|
91
|
-
if (op.stream === "realtime")
|
|
91
|
+
if (op.stream === "realtime") {
|
|
92
92
|
return REALTIME_FIELDS.map((f) => ({
|
|
93
93
|
field: f.field,
|
|
94
94
|
name: f.field,
|
|
@@ -96,6 +96,7 @@ function streamFields(op) {
|
|
|
96
96
|
type: f.type,
|
|
97
97
|
where: "realtime",
|
|
98
98
|
}));
|
|
99
|
+
}
|
|
99
100
|
if (op.stream !== "ws")
|
|
100
101
|
return [];
|
|
101
102
|
return [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/emit/java/sdk.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { type PackageIdentity } from "../shared/metadata.ts";
|
|
1
2
|
import { type JavaPomMetadata } from "./gradle.ts";
|
|
2
3
|
import { type JavaCallPlan } from "./sdk-plan.ts";
|
|
3
|
-
import { type PackageIdentity } from "../shared/metadata.ts";
|
|
4
4
|
/** The package's options, each defaulted and validated. */
|
|
5
5
|
export type JavaSdkOptions = {
|
|
6
6
|
/** the Maven group id; `com.example` by default, the reserved example domain as the Go SDK's `example.com/sdk`: Maven
|
package/dist/emit/java/sdk.js
CHANGED
|
@@ -5,23 +5,24 @@
|
|
|
5
5
|
* no `HttpClient.close`). The emitted Java is google-java-format's canonical form by construction (format.test.ts).
|
|
6
6
|
*/
|
|
7
7
|
import { readFileSync } from "node:fs";
|
|
8
|
+
import { toIR } from "../../ir/build.js";
|
|
9
|
+
import { sdkModel } from "../../ir/sdk-model.js";
|
|
8
10
|
import { compareCodeUnits } from "../shared/lang.js";
|
|
11
|
+
import { packageOn } from "../shared/metadata.js";
|
|
12
|
+
import { renameNotice } from "../shared/mirror.js";
|
|
9
13
|
import { buildGradle, pomOf, settingsGradle, validateArtifactId, validateClientName, validateGroupId, validatePackageName, validateVersion, } from "./gradle.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
14
|
+
import { javaTypeContext } from "./models.js";
|
|
15
|
+
import { REALTIME_FILES } from "./realtime.js";
|
|
12
16
|
import { surfaceOf } from "./sdk-client.js";
|
|
17
|
+
import { errorClassFiles, errorKeyFiles } from "./sdk-errors.js";
|
|
13
18
|
import { mirrorOf } from "./sdk-mirror.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { javaTypeContext } from "./models.js";
|
|
19
|
+
import { componentDecls, modelFiles, putFile } from "./sdk-models.js";
|
|
20
|
+
import {} from "./sdk-plan.js";
|
|
17
21
|
import { SSE_FILES } from "./sse.js";
|
|
18
|
-
import { REALTIME_FILES } from "./realtime.js";
|
|
19
22
|
import { WS_FILES } from "./ws.js";
|
|
20
|
-
import { sdkModel } from "../../ir/sdk-model.js";
|
|
21
|
-
import { toIR } from "../../ir/build.js";
|
|
22
23
|
/** The marker on line 1 of every emitted file. */
|
|
23
24
|
const MARKER = "// @generated by clients. DO NOT EDIT.";
|
|
24
|
-
|
|
25
|
+
// the package line of every vendored runtime file
|
|
25
26
|
const RUNTIME_PACKAGE = /^package http\.runtime;$/m;
|
|
26
27
|
/** The validated package for `options`. */
|
|
27
28
|
function packageOf(options) {
|
|
@@ -114,8 +115,8 @@ const OPERATION_FILES = [
|
|
|
114
115
|
/** The vendored runtime's files by class name, read from disk on every call, in `packageName`; every file by default. */
|
|
115
116
|
export function runtimeFiles(packageName, features = {
|
|
116
117
|
json: true,
|
|
117
|
-
opt: true,
|
|
118
118
|
operations: true,
|
|
119
|
+
opt: true,
|
|
119
120
|
realtime: true,
|
|
120
121
|
transport: true,
|
|
121
122
|
ws: true,
|
|
@@ -164,7 +165,7 @@ function featuresOf(ops, decls) {
|
|
|
164
165
|
function emitJava(document, options) {
|
|
165
166
|
const pkg = packageOf(options);
|
|
166
167
|
const dir = `src/main/java/${pkg.packageName.replaceAll(".", "/")}`;
|
|
167
|
-
|
|
168
|
+
// an operation without an operationId is named by the IR's derivation, as every sibling emitter asks
|
|
168
169
|
const ir = toIR(document, { deriveOperationIds: true });
|
|
169
170
|
const pom = pomOf(options, ir.info);
|
|
170
171
|
const model = sdkModel(ir);
|
|
@@ -188,7 +189,7 @@ function emitJava(document, options) {
|
|
|
188
189
|
}
|
|
189
190
|
: {};
|
|
190
191
|
const decls = componentDecls(ir, ctx);
|
|
191
|
-
|
|
192
|
+
// the mirror's names are claimed last, after every normal one (the components' own hoists included)
|
|
192
193
|
const mirror = operations ? mirrorOf(ir, env) : {};
|
|
193
194
|
const runtime = Object.entries(runtimeFiles(pkg.packageName, featuresOf(model.ops, decls))).map(([name, text]) => [`${dir}/${name}.java`, text]);
|
|
194
195
|
const client = operations ? mirror[`${pkg.clientName}.java`] : `${MARKER}\n${clientJava(pkg)}`;
|
|
@@ -203,7 +204,7 @@ function emitJava(document, options) {
|
|
|
203
204
|
.filter(([name]) => name !== `${pkg.clientName}.java`)
|
|
204
205
|
.map(([name, text]) => [`${dir}/${name}`, text]),
|
|
205
206
|
];
|
|
206
|
-
|
|
207
|
+
// one declaration per file: a second claim of a path throws, never overwrites
|
|
207
208
|
const files = {};
|
|
208
209
|
for (const [path, text] of entries)
|
|
209
210
|
putFile(files, path, text);
|
package/dist/emit/java/sse.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* schema's type, or `EventStream<String>` for untyped events, opened by the call through the exchange's `events`, so an
|
|
4
|
-
* error status throws before any event. Its cursor field, `lastEventId`, is sent as Last-Event-ID only when set and
|
|
5
|
-
* non-empty; a declared Last-Event-ID header param folds into it. A stream method is the same text in either mode: it
|
|
6
|
-
* answers no Result. Its javadoc says how a stream lets its connection go (F1: a for-each `break` has no close hook).
|
|
7
|
-
*/
|
|
8
|
-
import type { SdkOp } from "../../ir/sdk-model.ts";
|
|
1
|
+
import { type SdkOp } from "../../ir/sdk-model.ts";
|
|
2
|
+
import { type Expr } from "./layout.ts";
|
|
9
3
|
import { type JavaTypeContext } from "./models.ts";
|
|
10
4
|
import type { JavaHeaders } from "./sdk-headers.ts";
|
|
11
5
|
/** The header an SSE open resumes an event stream with. */
|
|
@@ -14,12 +8,17 @@ export declare const LAST_EVENT_ID = "Last-Event-ID";
|
|
|
14
8
|
export declare const CURSOR = "lastEventId";
|
|
15
9
|
/** Whether a declared header param is Last-Event-ID (any casing), the resume channel the cursor field carries. */
|
|
16
10
|
export declare const isLastEventIdHeader: (name: string) => boolean;
|
|
17
|
-
/** F1's doc obligation: how a stream lets its connection go. */
|
|
18
|
-
export declare const RELEASE = "Open it in try-with-resources: a for-each break without one keeps the connection.";
|
|
19
11
|
/** The SSE runtime's files: the stream, its event, the parser and the body's pump; core, with every exchange. */
|
|
20
|
-
export declare const SSE_FILES: string[];
|
|
21
|
-
/**
|
|
22
|
-
|
|
12
|
+
export declare const SSE_FILES: readonly string[];
|
|
13
|
+
/**
|
|
14
|
+
* What an SSE op's stream yields and the decode the method hands the runtime: a named-event op's `<Op>Event` through
|
|
15
|
+
* its `of`; else `SseEvent<T>` through `EventStream.typed`, `T` the declared event schema's type, or `SseEvent<String>`
|
|
16
|
+
* as parsed for untyped or string events.
|
|
17
|
+
*/
|
|
18
|
+
export declare function sseEventOf(op: SdkOp, ctx: JavaTypeContext): {
|
|
19
|
+
readonly type: string;
|
|
20
|
+
readonly decode: Expr;
|
|
21
|
+
};
|
|
23
22
|
/** What an SSE method's lines need: its name and constant, its Params, its headers holder, and its Call's lines. */
|
|
24
23
|
export type SseSite = {
|
|
25
24
|
readonly name: string;
|