@workerstack/clients 1.0.0-rc.29 → 1.0.0-rc.31
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 +548 -35
- 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 +88 -68
- package/bin/installgen.js +18 -13
- package/dist/cli.d.ts +4 -4
- package/dist/cli.js +20 -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 +14 -8
- 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 +11 -5
- 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 +3 -3
- package/dist/emit/csharp/errors.js +4 -4
- package/dist/emit/csharp/json.js +8 -8
- package/dist/emit/csharp/realtime.js +3 -3
- 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 +18 -2
- package/dist/emit/csharp/sdk-method.js +24 -9
- package/dist/emit/csharp/sdk-plan.js +0 -1
- package/dist/emit/csharp/sdk.js +7 -4
- package/dist/emit/csharp/sse.d.ts +0 -2
- package/dist/emit/csharp/sse.js +7 -7
- package/dist/emit/csharp/transport.js +7 -7
- package/dist/emit/csharp/types-enum.js +3 -1
- package/dist/emit/csharp/types-messages.js +3 -3
- package/dist/emit/csharp/types-names.js +10 -12
- 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.js +2 -2
- 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.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 +9 -0
- package/dist/emit/go/sdk-method.js +12 -3
- 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 +12 -11
- package/dist/emit/go/sse.js +1 -1
- 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.js +9 -9
- package/dist/emit/go/ws.js +6 -6
- package/dist/emit/java/gradle.d.ts +7 -9
- package/dist/emit/java/gradle.js +8 -8
- package/dist/emit/java/json.js +1 -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.js +5 -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 +1 -1
- package/dist/emit/java/models-union.js +1 -1
- package/dist/emit/java/models.d.ts +1 -2
- package/dist/emit/java/models.js +25 -16
- package/dist/emit/java/realtime.d.ts +5 -17
- package/dist/emit/java/realtime.js +1 -1
- package/dist/emit/java/sdk-client.d.ts +6 -6
- package/dist/emit/java/sdk-client.js +2 -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 +2 -2
- 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 +7 -11
- package/dist/emit/java/sdk-op.js +22 -10
- 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 +21 -14
- package/dist/emit/java/sse.d.ts +2 -4
- package/dist/emit/java/sse.js +6 -6
- package/dist/emit/java/ws.d.ts +2 -2
- package/dist/emit/java/ws.js +3 -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.js +3 -3
- 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.js +2 -2
- package/dist/emit/python/sdk-answer.d.ts +3 -7
- 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 +11 -0
- package/dist/emit/python/sdk-method.js +20 -5
- 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 +12 -8
- package/dist/emit/python/sse.d.ts +0 -2
- package/dist/emit/python/sse.js +2 -2
- 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.js +3 -3
- package/dist/emit/python/ws.d.ts +2 -5
- package/dist/emit/python/ws.js +4 -4
- package/dist/emit/rust/errors.js +3 -3
- package/dist/emit/rust/http.js +4 -4
- package/dist/emit/rust/realtime.js +2 -2
- 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.d.ts +12 -1
- package/dist/emit/rust/sdk-method.js +12 -4
- 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 +9 -6
- package/dist/emit/rust/sse.d.ts +0 -5
- package/dist/emit/rust/sse.js +2 -2
- 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 +1 -1
- package/dist/emit/rust/types.js +7 -5
- package/dist/emit/rust/ws.d.ts +0 -11
- package/dist/emit/rust/ws.js +5 -5
- 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 +8 -2
- package/dist/emit/ts/http.js +51 -6
- package/dist/emit/ts/package.d.ts +14 -12
- package/dist/emit/ts/package.js +10 -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 +12 -4
- package/dist/emit/ts/sdk-types.d.ts +0 -5
- package/dist/emit/ts/sdk-types.js +63 -19
- package/dist/emit/ts/sdk.d.ts +3 -1
- package/dist/emit/ts/sdk.js +44 -12
- package/dist/emit/ts/service-map.d.ts +7 -1
- package/dist/emit/ts/service-map.js +10 -1
- package/dist/emit/ts/single-flight-text.d.ts +3 -0
- package/dist/emit/ts/single-flight-text.js +38 -0
- package/dist/emit/ts/tanstack-query.d.ts +3 -2
- package/dist/emit/ts/tanstack-query.js +60 -35
- package/dist/emit/ts/type-gen.js +31 -18
- 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/process.js +2 -1
- package/dist/gen/shipped.js +2 -2
- package/dist/gen/switch-on.constants.d.ts +2 -0
- package/dist/gen/switch-on.constants.js +2 -0
- package/dist/gen/targets.d.ts +6 -7
- package/dist/gen/targets.js +11 -6
- 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 +8 -5
- package/dist/ir/invalidate-reads.d.ts +17 -0
- package/dist/ir/invalidate-reads.js +104 -0
- package/dist/ir/load.d.ts +10 -0
- package/dist/ir/load.js +65 -18
- package/dist/ir/model.d.ts +2 -1
- package/dist/ir/model.js +0 -1
- package/dist/ir/read-method.constants.d.ts +2 -0
- package/dist/ir/read-method.constants.js +2 -0
- 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.js +3 -3
- package/dist/ir/slots.js +13 -8
- package/dist/ir/streams.js +1 -1
- 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 +4 -4
- 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/csharp/Config.cs +9 -1
- package/dist/runtime/csharp/Exchange.cs +56 -4
- package/dist/runtime/csharp/Hooks.cs +9 -0
- package/dist/runtime/csharp/Operation.cs +6 -1
- package/dist/runtime/csharp/WsDial.cs +3 -1
- package/dist/runtime/go/config.go +5 -0
- package/dist/runtime/go/hooks.go +70 -0
- package/dist/runtime/go/request.go +6 -2
- package/dist/runtime/go/stream.go +4 -1
- package/dist/runtime/go/ws.go +3 -1
- package/dist/runtime/java/ClientConfig.java +11 -0
- package/dist/runtime/java/Flight.java +2 -12
- package/dist/runtime/java/Hooks.java +45 -0
- package/dist/runtime/java/InvalidateEvent.java +10 -0
- package/dist/runtime/java/InvalidateHook.java +12 -0
- package/dist/runtime/java/InvalidateTarget.java +7 -0
- package/dist/runtime/java/Operation.java +23 -3
- package/dist/runtime/java/Realtime.java +3 -1
- package/dist/runtime/java/WsDial.java +3 -0
- 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/config.py +8 -2
- package/dist/runtime/python/exchange.py +3 -1
- package/dist/runtime/python/hooks.py +110 -5
- package/dist/runtime/python/operation.py +2 -0
- package/dist/runtime/python/send_async.py +14 -2
- package/dist/runtime/python/send_sync.py +4 -2
- package/dist/runtime/python/ws.py +5 -1
- package/dist/runtime/rust/config.rs +6 -1
- package/dist/runtime/rust/exchange.rs +15 -3
- package/dist/runtime/rust/hooks.rs +127 -2
- package/dist/runtime/rust/log.rs +11 -3
- package/dist/runtime/rust/request.rs +17 -0
- package/dist/runtime/rust/ws.rs +9 -1
- package/dist/runtime/ts/config.ts +69 -0
- package/dist/runtime/ts/http.ts +12 -10
- package/dist/runtime/ts/request.ts +2 -0
- package/dist/runtime/ts/response.ts +7 -0
- package/dist/runtime/ts/sdk-invalidate.ts +82 -0
- package/dist/runtime/ts/sdk-single-flight.constants.ts +25 -0
- package/dist/runtime/ts/sdk-single-flight.ts +203 -0
- package/dist/runtime/ts/sdk-sse.ts +5 -1
- package/dist/runtime/ts/sdk-ws.ts +9 -3
- package/dist/runtime/ts/sdk.ts +55 -31
- package/dist/runtime/ts/single-flight-batch.ts +184 -0
- package/dist/runtime/ts/single-flight-body.ts +59 -0
- package/dist/runtime/ts/single-flight-run.ts +160 -0
- package/dist/runtime/ts/single-flight.constants.ts +31 -0
- package/dist/runtime/ts/single-flight.ts +158 -0
- package/dist/runtime/ts-tanstack-query/invalidate.ts +96 -92
- package/dist/runtime/ts-tanstack-query/query.ts +140 -170
- package/package.json +12 -17
- package/references/INDEX.md +31 -0
- package/references/cli.md +33 -0
- package/references/configuring.md +29 -0
- package/references/documentation.md +15 -0
- package/references/errors.md +23 -0
- package/references/flags.md +104 -0
- package/references/gates.md +46 -0
- package/references/generate.md +29 -0
- package/references/install-scripts.md +28 -0
- package/references/install.md +38 -0
- package/references/license.md +8 -0
- package/references/mcp.md +76 -0
- package/references/output.md +45 -0
- package/references/overview.md +14 -0
- package/references/release-tooling.md +34 -0
- package/references/release.md +305 -0
- package/references/sdks.md +393 -0
- package/references/start.md +22 -0
- package/references/tdd.md +16 -0
- 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
|
@@ -31,8 +31,9 @@ function typeList(v, word, types) {
|
|
|
31
31
|
v.b.open(4);
|
|
32
32
|
v.b.token(word);
|
|
33
33
|
types.forEach((t, i) => {
|
|
34
|
-
if (i === 0)
|
|
34
|
+
if (i === 0) {
|
|
35
35
|
v.b.space();
|
|
36
|
+
}
|
|
36
37
|
else {
|
|
37
38
|
v.b.token(",");
|
|
38
39
|
v.b.breakOp(" ");
|
|
@@ -44,7 +45,7 @@ function typeList(v, word, types) {
|
|
|
44
45
|
/** A type declaration's header, through its `{` (or `{}`). */
|
|
45
46
|
export function typeDeclaration(v, h) {
|
|
46
47
|
if (h.kind === "enum") {
|
|
47
|
-
|
|
48
|
+
// visitEnumDeclaration's header: a level of its own, `enum` and a unified break before the name at +4
|
|
48
49
|
v.b.open(0);
|
|
49
50
|
typeModifiers(v, h);
|
|
50
51
|
v.b.open(4);
|
|
@@ -61,7 +62,7 @@ export function typeDeclaration(v, h) {
|
|
|
61
62
|
v.b.token(h.name);
|
|
62
63
|
v.b.open(4);
|
|
63
64
|
if (h.kind === "record") {
|
|
64
|
-
|
|
65
|
+
// visitRecordDeclaration's components as formals, then its interface
|
|
65
66
|
v.b.token("(");
|
|
66
67
|
if (h.components.length > 0) {
|
|
67
68
|
v.b.breakToFill("");
|
|
@@ -79,15 +80,16 @@ export function typeDeclaration(v, h) {
|
|
|
79
80
|
}
|
|
80
81
|
else if (h.kind === "class") {
|
|
81
82
|
if (h.extends !== undefined) {
|
|
82
|
-
|
|
83
|
+
// classDeclarationTypeList of one superclass, in no level of its own
|
|
83
84
|
v.b.breakToFill(" ");
|
|
84
85
|
v.b.token("extends");
|
|
85
86
|
v.b.space();
|
|
86
87
|
v.type(type(h.extends));
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
|
-
else if (h.permits.length > 0)
|
|
90
|
+
else if (h.permits.length > 0) {
|
|
90
91
|
typeList(v, "permits", h.permits);
|
|
92
|
+
}
|
|
91
93
|
v.b.close();
|
|
92
94
|
}
|
|
93
95
|
v.b.space();
|
|
@@ -59,7 +59,7 @@ export class Visitor {
|
|
|
59
59
|
new Visitor(b).expr(e);
|
|
60
60
|
return b.flat();
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
// hasOnlyShortItems: every item under MAX_ITEM_LENGTH_FOR_FILLING (10) characters
|
|
63
63
|
shortItems(items) {
|
|
64
64
|
return items.every((item) => this.flat(item).length < 10);
|
|
65
65
|
}
|
|
@@ -78,8 +78,9 @@ export class Visitor {
|
|
|
78
78
|
const dims = t.dims > 0;
|
|
79
79
|
if (dims)
|
|
80
80
|
this.b.open(4);
|
|
81
|
-
if (t.args.length === 0)
|
|
81
|
+
if (t.args.length === 0) {
|
|
82
82
|
this.typeName(t.name);
|
|
83
|
+
}
|
|
83
84
|
else {
|
|
84
85
|
this.b.open(4);
|
|
85
86
|
this.typeName(t.name);
|
|
@@ -220,7 +221,7 @@ export class Visitor {
|
|
|
220
221
|
this.b.brk(fill, " ");
|
|
221
222
|
this.b.token(e.op);
|
|
222
223
|
this.b.space();
|
|
223
|
-
|
|
224
|
+
// a literal in a `+` after a non-literal operand reflows under its own quote
|
|
224
225
|
const later = e.op === "+" && isString(operand) && !e.operands.slice(0, i + 1).every(isString);
|
|
225
226
|
if (later)
|
|
226
227
|
this.b.literal(this.flat(operand), true);
|
package/dist/emit/java/layout.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* (GJF's Doc and DocBuilder), the visitor layout-visitor.ts, layout-dot.ts and layout-decl.ts (JavaInputAstVisitor),
|
|
6
6
|
* and a long string literal is reflowed as StringWrapper reflows it (layout-strings.ts).
|
|
7
7
|
*/
|
|
8
|
-
import { expr } from "./layout-ast.js";
|
|
8
|
+
import { expr, } from "./layout-ast.js";
|
|
9
9
|
import { annotation, declareOne, method } from "./layout-decl.js";
|
|
10
10
|
import { Builder } from "./layout-doc.js";
|
|
11
11
|
import { wrapStrings } from "./layout-strings.js";
|
|
@@ -26,7 +26,7 @@ const STATEMENTS = {
|
|
|
26
26
|
v.b.token(";");
|
|
27
27
|
},
|
|
28
28
|
for: (v, s) => {
|
|
29
|
-
|
|
29
|
+
// visitEnhancedForLoop: the variable declared with `:` before its iterable
|
|
30
30
|
v.b.open(0);
|
|
31
31
|
v.b.token("for");
|
|
32
32
|
v.b.space();
|
|
@@ -53,10 +53,11 @@ const STATEMENTS = {
|
|
|
53
53
|
local: (v, s) => declareOne(v, s.decl, { kind: "variable", trailing: ";" }),
|
|
54
54
|
return: (v, s) => keyword(v, "return", s.expr),
|
|
55
55
|
rule: (v, s) => {
|
|
56
|
-
|
|
56
|
+
// visitCase, a rule: `case label ->` or `default ->`, a unified break, the value at +4
|
|
57
57
|
v.b.open(4);
|
|
58
|
-
if (s.label === null)
|
|
58
|
+
if (s.label === null) {
|
|
59
59
|
v.b.token("default");
|
|
60
|
+
}
|
|
60
61
|
else {
|
|
61
62
|
v.b.token("case");
|
|
62
63
|
v.b.open(0);
|
|
@@ -9,7 +9,7 @@ import { irResolver } from "../../ir/schema.js";
|
|
|
9
9
|
import { compareCodeUnits, javaTypeName, NameScope } from "../shared/lang.js";
|
|
10
10
|
/** The type a value without a schema is, and the one a nullable open value is. */
|
|
11
11
|
export const JSON_NODE = "JsonNode";
|
|
12
|
-
|
|
12
|
+
// the type names the emitted models and the client spell, which no runtime file holds: each is reserved
|
|
13
13
|
const SPELLED = [
|
|
14
14
|
"Boolean",
|
|
15
15
|
"Builder",
|
|
@@ -39,7 +39,7 @@ const SPELLED = [
|
|
|
39
39
|
* The code text a scan reads: comments dropped and string and char literals emptied, in one left-to-right pass, so a
|
|
40
40
|
* `//` inside a string opens no comment and a quote inside a comment opens no string.
|
|
41
41
|
*/
|
|
42
|
-
export const codeOf = (code) => code.
|
|
42
|
+
export const codeOf = (code) => code.replaceAll(/\/\*[\s\S]*?\*\/|\/\/.*$|"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)'/gm, (token) => token.startsWith("/") ? "" : token[0] === '"' ? '""' : "''");
|
|
43
43
|
/** The type names `code` spells: each imported type by its simple name, and each capitalized identifier that is not a member access. */
|
|
44
44
|
export function spelledIn(code) {
|
|
45
45
|
const text = codeOf(code);
|
|
@@ -70,13 +70,14 @@ export function javaNames(schemas, taken, declares) {
|
|
|
70
70
|
const base = javaTypeName(name);
|
|
71
71
|
const taken = scope.has(base);
|
|
72
72
|
components.set(name, scope.claim(taken ? `${base}Model` : base));
|
|
73
|
-
if (taken)
|
|
73
|
+
if (taken) {
|
|
74
74
|
renamed.push({
|
|
75
75
|
because: `"${base}" is a name the SDK's runtime, the JDK or another declaration holds`,
|
|
76
76
|
name,
|
|
77
77
|
renamed: components.get(name),
|
|
78
78
|
what: "component",
|
|
79
79
|
});
|
|
80
|
+
}
|
|
80
81
|
}
|
|
81
82
|
const hoisted = new Map();
|
|
82
83
|
return {
|
|
@@ -90,7 +91,7 @@ export function javaNames(schemas, taken, declares) {
|
|
|
90
91
|
hoisted.set(key, name);
|
|
91
92
|
return name;
|
|
92
93
|
},
|
|
93
|
-
|
|
94
|
+
// a ref reaches here only for a declared component: `alias` answers for every other one
|
|
94
95
|
ref: (name) => components.get(name),
|
|
95
96
|
renamed,
|
|
96
97
|
resolve: irResolver(schemas),
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { IRField, IRSchema } from "../../ir/model.ts";
|
|
12
12
|
import type { JavaTypeContext, Member } from "./models.ts";
|
|
13
|
-
export declare const RECORD_MEMBERS: readonly string[];
|
|
14
13
|
/** A record's members: its fields, and whether it keeps every other member (it declares `additionalProperties`). */
|
|
15
14
|
export type RecordShape = {
|
|
16
15
|
readonly fields: readonly IRField[];
|
|
@@ -2,8 +2,8 @@ import { javaString } from "../shared/escape.js";
|
|
|
2
2
|
import { camelWords, compareCodeUnits, isJavaReserved, NameScope } from "../shared/lang.js";
|
|
3
3
|
import { typeHeader } from "./layout.js";
|
|
4
4
|
import { JSON_NODE } from "./models-names.js";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// every member name a record component collides with: java.lang.Record's and Object's synthesized and final methods
|
|
6
|
+
const RECORD_MEMBERS = [
|
|
7
7
|
"clone",
|
|
8
8
|
"equals",
|
|
9
9
|
"finalize",
|
|
@@ -16,7 +16,7 @@ export const RECORD_MEMBERS = [
|
|
|
16
16
|
];
|
|
17
17
|
const NON_NULL = { args: ["JsonInclude.Include.NON_NULL"], name: "JsonInclude" };
|
|
18
18
|
const NON_EMPTY = { args: ["JsonInclude.Include.NON_EMPTY"], name: "JsonInclude" };
|
|
19
|
-
|
|
19
|
+
// a required, non-nullable use of these is written primitive
|
|
20
20
|
const PRIMITIVE = { Boolean: "boolean", Double: "double", Long: "long" };
|
|
21
21
|
/** Whether an object, or any object part of an allOf (refs followed), declares `additionalProperties`. */
|
|
22
22
|
export function isOpen(schema, resolve) {
|
|
@@ -15,7 +15,7 @@ type Discriminated = Of<"union"> & {
|
|
|
15
15
|
discriminator: IRDiscriminator;
|
|
16
16
|
};
|
|
17
17
|
/** Declares `schema` once under `key` and `base`; its name. */
|
|
18
|
-
|
|
18
|
+
type Declare = (schema: IRSchema, key: string, base: string) => string;
|
|
19
19
|
/** What a union's declaration reaches: the context, its members' types, and the hoist. */
|
|
20
20
|
export type UnionScope = {
|
|
21
21
|
at: JavaTypeContext;
|
|
@@ -2,8 +2,8 @@ import { compareCodeUnits, javaTypeName } from "../shared/lang.js";
|
|
|
2
2
|
import { deserializerLines } from "./json.js";
|
|
3
3
|
import { classOf, typeHeader } from "./layout.js";
|
|
4
4
|
import { enumValues, stringEnumDecl } from "./models-enum.js";
|
|
5
|
-
import { fieldsOf } from "./models-record.js";
|
|
6
5
|
import { JSON_NODE } from "./models-names.js";
|
|
6
|
+
import { fieldsOf } from "./models-record.js";
|
|
7
7
|
/** Whether a variant is a const string: a union of these alone is a string enum. */
|
|
8
8
|
export const isLiteral = (variant) => variant.kind === "const" && typeof variant.value === "string";
|
|
9
9
|
/** The values that select `variant`: its mapping keys, else its property's const or enum, else its ref's name. */
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* type name is reserved where it collides (models-names.ts).
|
|
6
6
|
*/
|
|
7
7
|
import type { IR, IRSchema } from "../../ir/model.ts";
|
|
8
|
-
import { type JavaTypeNames } from "./models-names.ts";
|
|
9
8
|
import type { Dispatch } from "./json.ts";
|
|
10
|
-
|
|
9
|
+
import { type JavaTypeNames } from "./models-names.ts";
|
|
11
10
|
/** Where a type is being written, the declarations it hoists, and the names. */
|
|
12
11
|
export type JavaTypeContext = {
|
|
13
12
|
parentName: string;
|
package/dist/emit/java/models.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { pascalWords, javaTypeName } from "../shared/lang.js";
|
|
2
2
|
import { enumDecl, enumValues } from "./models-enum.js";
|
|
3
|
-
import { fieldsOf, isOpen, recordDecl } from "./models-record.js";
|
|
4
3
|
import { javaNames, JSON_NODE } from "./models-names.js";
|
|
4
|
+
import { fieldsOf, isOpen, recordDecl } from "./models-record.js";
|
|
5
5
|
import { dispatchOf, isKeyed, isLiteral, unionDecl } from "./models-union.js";
|
|
6
|
-
|
|
6
|
+
// deeper than this, a schema is any JSON value
|
|
7
7
|
const MAX_DEPTH = 12;
|
|
8
8
|
const SCALARS = {
|
|
9
9
|
boolean: "Boolean",
|
|
@@ -32,7 +32,7 @@ export function declares(ir) {
|
|
|
32
32
|
function declare(ir, at, key, base) {
|
|
33
33
|
const name = at.names.hoist(key, base);
|
|
34
34
|
if (!at.decls.has(name)) {
|
|
35
|
-
|
|
35
|
+
// claimed before its body: what the body hoists in turn comes after it
|
|
36
36
|
at.decls.set(name, "");
|
|
37
37
|
at.decls.set(name, javaTopLevel(name, ir, at));
|
|
38
38
|
}
|
|
@@ -75,28 +75,38 @@ function use(ir, at) {
|
|
|
75
75
|
if (at.depth > MAX_DEPTH)
|
|
76
76
|
return JSON_NODE;
|
|
77
77
|
switch (ir.kind) {
|
|
78
|
-
case "allOf":
|
|
78
|
+
case "allOf": {
|
|
79
79
|
return allOfUse(ir, at);
|
|
80
|
-
|
|
80
|
+
}
|
|
81
|
+
case "array": {
|
|
81
82
|
return `List<${use(ir.items, deeper(at, `${at.fieldName}Item`, "[]"))}>`;
|
|
82
|
-
|
|
83
|
+
}
|
|
84
|
+
case "binary": {
|
|
83
85
|
return "String";
|
|
84
|
-
|
|
86
|
+
}
|
|
87
|
+
case "const": {
|
|
85
88
|
return constType(ir);
|
|
86
|
-
|
|
89
|
+
}
|
|
90
|
+
case "nullable": {
|
|
87
91
|
return use(ir.inner, deeper(at));
|
|
88
|
-
|
|
92
|
+
}
|
|
93
|
+
case "object": {
|
|
89
94
|
return objectUse(ir, at);
|
|
90
|
-
|
|
95
|
+
}
|
|
96
|
+
case "ref": {
|
|
91
97
|
return refUse(ir, at);
|
|
92
|
-
|
|
98
|
+
}
|
|
99
|
+
case "scalar": {
|
|
93
100
|
return enumValues(ir).length > 0 ? hoist(ir, at) : SCALARS[ir.type];
|
|
94
|
-
|
|
101
|
+
}
|
|
102
|
+
case "tuple": {
|
|
95
103
|
return `List<${JSON_NODE}>`;
|
|
96
|
-
|
|
104
|
+
}
|
|
105
|
+
// a union in use position is any JSON value; a component union is declared
|
|
97
106
|
case "union":
|
|
98
|
-
case "unknown":
|
|
107
|
+
case "unknown": {
|
|
99
108
|
return JSON_NODE;
|
|
109
|
+
}
|
|
100
110
|
}
|
|
101
111
|
}
|
|
102
112
|
/** The Java type of `ir` at a use position of `at`. */
|
|
@@ -126,8 +136,7 @@ export function javaTopLevel(name, ir, ctx) {
|
|
|
126
136
|
const open = isOpen(ir, ctx.names.resolve);
|
|
127
137
|
if (ir.kind === "object")
|
|
128
138
|
return recordDecl(name, { fields: ir.fields, open }, scope.member, ctx);
|
|
129
|
-
if (ir.kind === "allOf")
|
|
139
|
+
if (ir.kind === "allOf")
|
|
130
140
|
return recordDecl(name, { fields: fieldsOf(ir, ctx.names.resolve), open }, scope.member, ctx);
|
|
131
|
-
}
|
|
132
141
|
return unionDecl(name, ir, scope);
|
|
133
142
|
}
|
|
@@ -19,22 +19,10 @@ import { type JavaTypeContext } from "./models.ts";
|
|
|
19
19
|
export declare const MAX_RECONNECT_ATTEMPTS = "maxReconnectAttempts";
|
|
20
20
|
export declare const RECONNECT_DELAY = "reconnectDelay";
|
|
21
21
|
/** A realtime op's own fields in `TransportOptions.of`'s order, each with its Java type. */
|
|
22
|
-
export declare const REALTIME_FIELDS: readonly
|
|
23
|
-
readonly field:
|
|
24
|
-
readonly type:
|
|
25
|
-
}
|
|
26
|
-
readonly field: "reconnectToken";
|
|
27
|
-
readonly type: "String";
|
|
28
|
-
}, {
|
|
29
|
-
readonly field: "protocols";
|
|
30
|
-
readonly type: "List<String>";
|
|
31
|
-
}, {
|
|
32
|
-
readonly field: "maxReconnectAttempts";
|
|
33
|
-
readonly type: "java.lang.Integer";
|
|
34
|
-
}, {
|
|
35
|
-
readonly field: "reconnectDelay";
|
|
36
|
-
readonly type: "Duration";
|
|
37
|
-
}];
|
|
22
|
+
export declare const REALTIME_FIELDS: readonly {
|
|
23
|
+
readonly field: string;
|
|
24
|
+
readonly type: string;
|
|
25
|
+
}[];
|
|
38
26
|
/** Whether a declared param is on a realtime resume channel the cursor fields carry (C#'s `carries`). */
|
|
39
27
|
export declare const carriesRealtime: (name: string, where: "query" | "header") => boolean;
|
|
40
28
|
/**
|
|
@@ -42,7 +30,7 @@ export declare const carriesRealtime: (name: string, where: "query" | "header")
|
|
|
42
30
|
* adapters; only an SDK with a realtime operation ships them (with the WebSocket files, which its WebSocket adapter dials
|
|
43
31
|
* through).
|
|
44
32
|
*/
|
|
45
|
-
export declare const REALTIME_FILES: string[];
|
|
33
|
+
export declare const REALTIME_FILES: readonly string[];
|
|
46
34
|
/**
|
|
47
35
|
* What a realtime method answers: its type, the type its messages decode to, whether they must be JSON (the op
|
|
48
36
|
* declares its messages), and the wrap of the opened connection.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { call as callOf, local, methodHeader, newOf, param, returnStmt, statement, } from "./layout.js";
|
|
2
|
-
import { declaredTypeOf, javaTypeOf, keyedArms } from "./models.js";
|
|
3
2
|
import { JSON_NODE } from "./models-names.js";
|
|
3
|
+
import { declaredTypeOf, javaTypeOf, keyedArms } from "./models.js";
|
|
4
4
|
import { docOf } from "./sdk-decl.js";
|
|
5
5
|
import { CURSOR, isLastEventIdHeader } from "./sse.js";
|
|
6
6
|
import { handledArms, isReconnectTokenQuery, keyedReader, PROTOCOLS, TOKEN } from "./ws.js";
|
|
@@ -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. */
|
|
@@ -110,6 +110,7 @@ const SETTERS = [
|
|
|
110
110
|
["onRequest", "RequestHook"],
|
|
111
111
|
["onResponse", "ResponseHook"],
|
|
112
112
|
["onAuthExpired", "Supplier<String>"],
|
|
113
|
+
["onInvalidate", "InvalidateHook"],
|
|
113
114
|
["onLog", "Consumer<LogEntry>"],
|
|
114
115
|
["redirect", "RedirectPolicy"],
|
|
115
116
|
["maxResponseBytes", "long"],
|
|
@@ -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,10 +1,10 @@
|
|
|
1
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";
|
|
2
4
|
import { docOf, docParagraphs } from "./sdk-decl.js";
|
|
3
5
|
import { putFile } from "./sdk-models.js";
|
|
4
6
|
import { answerOf, paragraphsOf } from "./sdk-op.js";
|
|
5
|
-
import { connectionOf } from "./realtime.js";
|
|
6
7
|
import { paramsName } from "./sdk-params.js";
|
|
7
|
-
import { blocks, clientLines, membersOf, nodeOf, recordSource, resourceName, } from "./sdk-client.js";
|
|
8
8
|
import { sseEventOf } from "./sse.js";
|
|
9
9
|
import { wsSocketOf } from "./ws.js";
|
|
10
10
|
/** The type the normal method answers: a stream's, a connection's, or the answer's (`void` for none). */
|
|
@@ -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;
|
|
@@ -6,17 +6,21 @@
|
|
|
6
6
|
* JSON as the mapper writes it, a form urlencoded, text as its raw bytes, binary as sized bytes or a one-shot stream,
|
|
7
7
|
* multipart as hand-built parts under a `clients-<uuid>` boundary.
|
|
8
8
|
*/
|
|
9
|
+
import type { InvalidatedRead } from "../../ir/invalidate-reads.ts";
|
|
9
10
|
import type { IRSchema } from "../../ir/model.ts";
|
|
10
11
|
import type { SdkOp } from "../../ir/sdk-model.ts";
|
|
11
|
-
import { type JavaTypeContext } from "./models.ts";
|
|
12
12
|
import { type Expr } from "./layout.ts";
|
|
13
|
+
import { type JavaTypeContext } from "./models.ts";
|
|
13
14
|
import { type JavaHeaders } from "./sdk-headers.ts";
|
|
14
15
|
import type { JavaCallPlan } from "./sdk-plan.ts";
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* What an operation's text needs: the type context its types hoist into, the array test, and each write's reads by
|
|
18
|
+
* operationId (`invalidateReads`): what its `onInvalidate` event names.
|
|
19
|
+
*/
|
|
17
20
|
export type OpEnv = {
|
|
18
21
|
readonly ctx: JavaTypeContext;
|
|
19
22
|
readonly isArray: (schema: IRSchema) => boolean;
|
|
23
|
+
readonly reads: ReadonlyMap<string, readonly InvalidatedRead[]>;
|
|
20
24
|
};
|
|
21
25
|
/** One operation's text and plan, before its accessors are known. */
|
|
22
26
|
export type JavaOp = {
|
|
@@ -40,18 +44,10 @@ export type JavaOp = {
|
|
|
40
44
|
};
|
|
41
45
|
/** A method's javadoc paragraphs: the operation's id, then its summary and description, as the other SDKs carry them. */
|
|
42
46
|
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
47
|
/** The answer's Java type and its reader on `answer`, for each response kind. */
|
|
46
48
|
export declare function answerOf(op: SdkOp, env: OpEnv): {
|
|
47
49
|
readonly reader: Expr;
|
|
48
50
|
readonly type: string;
|
|
49
51
|
};
|
|
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
52
|
/** One operation's text and plan, with its accessors left to the resource tree. */
|
|
57
53
|
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;
|
|
@@ -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
|
|
@@ -141,8 +141,19 @@ function methodLines(op, site, env) {
|
|
|
141
141
|
]),
|
|
142
142
|
];
|
|
143
143
|
}
|
|
144
|
-
/**
|
|
145
|
-
function
|
|
144
|
+
/** A write's `onInvalidate` members: its operationId and the reads it makes stale; `null` and none without reads. */
|
|
145
|
+
function readItems(op, reads) {
|
|
146
|
+
const each = (reads ?? []).map((read) => newOf("Operation.Read", [
|
|
147
|
+
javaString(read.operationId),
|
|
148
|
+
array("String[]", read.params.map((name) => javaString(name))),
|
|
149
|
+
]));
|
|
150
|
+
return [lit(each.length === 0 ? "null" : javaString(op.id)), array("Operation.Read[]", each)];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The `Operation` constant: the method, the path template, the path params in path order, accept and idempotence,
|
|
154
|
+
* then a write's targets, operationId and reads.
|
|
155
|
+
*/
|
|
156
|
+
function constantLines(op, constant, reads) {
|
|
146
157
|
const names = op.pathSegments.flatMap((segment) => (segment.kind === "param" ? [segment.name] : []));
|
|
147
158
|
const accept = acceptOf(op);
|
|
148
159
|
const items = [
|
|
@@ -155,6 +166,7 @@ function constantLines(op, constant) {
|
|
|
155
166
|
? []
|
|
156
167
|
: [
|
|
157
168
|
array("String[]", op.invalidates.map((target) => javaString(target))),
|
|
169
|
+
...readItems(op, reads),
|
|
158
170
|
]),
|
|
159
171
|
];
|
|
160
172
|
return field(2, {
|
|
@@ -205,10 +217,10 @@ export function javaOp(op, name, env) {
|
|
|
205
217
|
body: multipart === null
|
|
206
218
|
? null
|
|
207
219
|
: { lines: multipartRecordLines(multipart.name, op.id, multipart.components), name: multipart.name },
|
|
220
|
+
constant,
|
|
221
|
+
constantLines: constantLines(op, constant, env.reads.get(op.id)),
|
|
208
222
|
headers,
|
|
209
223
|
helper: multipartHelper(op, env),
|
|
210
|
-
constant,
|
|
211
|
-
constantLines: constantLines(op, constant),
|
|
212
224
|
lines: methodLines(op, { fields, headers, name }, env),
|
|
213
225
|
params: paramsRecord(paramsName(op, env.ctx), op.id, fields),
|
|
214
226
|
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
|
};
|