@adobe/data-rpc 0.10.11

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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +159 -0
  3. package/dist/arg-async.test.d.ts +1 -0
  4. package/dist/arg-async.test.js +147 -0
  5. package/dist/arg-async.test.js.map +1 -0
  6. package/dist/arg-marshal.d.ts +34 -0
  7. package/dist/arg-marshal.js +90 -0
  8. package/dist/arg-marshal.js.map +1 -0
  9. package/dist/arg-observe.test.d.ts +1 -0
  10. package/dist/arg-observe.test.js +114 -0
  11. package/dist/arg-observe.test.js.map +1 -0
  12. package/dist/consume/caller-context.d.ts +47 -0
  13. package/dist/consume/caller-context.js +3 -0
  14. package/dist/consume/caller-context.js.map +1 -0
  15. package/dist/consume/make-generator.d.ts +16 -0
  16. package/dist/consume/make-generator.js +75 -0
  17. package/dist/consume/make-generator.js.map +1 -0
  18. package/dist/consume/make-observe.d.ts +16 -0
  19. package/dist/consume/make-observe.js +29 -0
  20. package/dist/consume/make-observe.js.map +1 -0
  21. package/dist/consume/make-promise.d.ts +12 -0
  22. package/dist/consume/make-promise.js +32 -0
  23. package/dist/consume/make-promise.js.map +1 -0
  24. package/dist/consume/make-void.d.ts +12 -0
  25. package/dist/consume/make-void.js +17 -0
  26. package/dist/consume/make-void.js.map +1 -0
  27. package/dist/consume/reconstruct-error.d.ts +7 -0
  28. package/dist/consume/reconstruct-error.js +14 -0
  29. package/dist/consume/reconstruct-error.js.map +1 -0
  30. package/dist/consume/synthesize-service.d.ts +10 -0
  31. package/dist/consume/synthesize-service.js +77 -0
  32. package/dist/consume/synthesize-service.js.map +1 -0
  33. package/dist/create-endpoint.d.ts +8 -0
  34. package/dist/create-endpoint.js +462 -0
  35. package/dist/create-endpoint.js.map +1 -0
  36. package/dist/endpoint.d.ts +64 -0
  37. package/dist/endpoint.js +3 -0
  38. package/dist/endpoint.js.map +1 -0
  39. package/dist/host/host-context.d.ts +28 -0
  40. package/dist/host/host-context.js +3 -0
  41. package/dist/host/host-context.js.map +1 -0
  42. package/dist/host/marshal-error.d.ts +8 -0
  43. package/dist/host/marshal-error.js +15 -0
  44. package/dist/host/marshal-error.js.map +1 -0
  45. package/dist/host/register-service.d.ts +10 -0
  46. package/dist/host/register-service.js +169 -0
  47. package/dist/host/register-service.js.map +1 -0
  48. package/dist/id.d.ts +7 -0
  49. package/dist/id.js +12 -0
  50. package/dist/id.js.map +1 -0
  51. package/dist/index.d.ts +7 -0
  52. package/dist/index.js +7 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/nested.test.d.ts +1 -0
  55. package/dist/nested.test.js +128 -0
  56. package/dist/nested.test.js.map +1 -0
  57. package/dist/protocol.d.ts +157 -0
  58. package/dist/protocol.js +18 -0
  59. package/dist/protocol.js.map +1 -0
  60. package/dist/review-fixes.test.d.ts +1 -0
  61. package/dist/review-fixes.test.js +200 -0
  62. package/dist/review-fixes.test.js.map +1 -0
  63. package/dist/rpc.test.d.ts +1 -0
  64. package/dist/rpc.test.js +250 -0
  65. package/dist/rpc.test.js.map +1 -0
  66. package/dist/transport.d.ts +32 -0
  67. package/dist/transport.js +3 -0
  68. package/dist/transport.js.map +1 -0
  69. package/dist/transports/loopback-transport.d.ts +13 -0
  70. package/dist/transports/loopback-transport.js +102 -0
  71. package/dist/transports/loopback-transport.js.map +1 -0
  72. package/dist/transports/loopback-transport.test.d.ts +1 -0
  73. package/dist/transports/loopback-transport.test.js +42 -0
  74. package/dist/transports/loopback-transport.test.js.map +1 -0
  75. package/dist/transports/message-port-transport.d.ts +14 -0
  76. package/dist/transports/message-port-transport.js +63 -0
  77. package/dist/transports/message-port-transport.js.map +1 -0
  78. package/dist/transports/message-port-transport.test.d.ts +1 -0
  79. package/dist/transports/message-port-transport.test.js +49 -0
  80. package/dist/transports/message-port-transport.test.js.map +1 -0
  81. package/dist/transports/window-transport.d.ts +20 -0
  82. package/dist/transports/window-transport.js +69 -0
  83. package/dist/transports/window-transport.js.map +1 -0
  84. package/dist/transports/window-transport.test.d.ts +1 -0
  85. package/dist/transports/window-transport.test.js +47 -0
  86. package/dist/transports/window-transport.test.js.map +1 -0
  87. package/package.json +38 -0
@@ -0,0 +1,3 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ export {};
3
+ //# sourceMappingURL=caller-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"caller-context.js","sourceRoot":"","sources":["../../src/consume/caller-context.ts"],"names":[],"mappings":"AAAA,uDAAuD"}
@@ -0,0 +1,16 @@
1
+ import type { Data } from "@adobe/data";
2
+ import type { Schema } from "@adobe/data/schema";
3
+ import type { CallerContext } from "./caller-context.js";
4
+ /**
5
+ * Projects a remote async-generator member, strictly pull-based: the host does
6
+ * not advance until this side asks. The first `next()` sends `iterate` (once),
7
+ * then every `next()` sends one `pull` and awaits the matching
8
+ * `yield`/`done`/`throw`. Early `return()` / `await using` disposal sends
9
+ * `return`; a thrown `throw(e)` injects `raise` so the host generator's `finally`
10
+ * runs. Once terminated it never resurrects (mirrors the local lazy generator).
11
+ *
12
+ * If the endpoint closes mid-stream the pending pull resolves `done` and further
13
+ * `next()` calls return `done` — a graceful end (an `Observe`/generator has no
14
+ * error channel guaranteed across a dropped transport).
15
+ */
16
+ export declare function makeGenerator(ctx: CallerContext, service: string, path: readonly string[], args: readonly unknown[], params?: readonly Schema[]): AsyncGenerator<Data>;
@@ -0,0 +1,75 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { marshalError } from "../host/marshal-error.js";
3
+ /**
4
+ * Projects a remote async-generator member, strictly pull-based: the host does
5
+ * not advance until this side asks. The first `next()` sends `iterate` (once),
6
+ * then every `next()` sends one `pull` and awaits the matching
7
+ * `yield`/`done`/`throw`. Early `return()` / `await using` disposal sends
8
+ * `return`; a thrown `throw(e)` injects `raise` so the host generator's `finally`
9
+ * runs. Once terminated it never resurrects (mirrors the local lazy generator).
10
+ *
11
+ * If the endpoint closes mid-stream the pending pull resolves `done` and further
12
+ * `next()` calls return `done` — a graceful end (an `Observe`/generator has no
13
+ * error channel guaranteed across a dropped transport).
14
+ */
15
+ export function makeGenerator(ctx, service, path, args, params) {
16
+ const id = ctx.nextId();
17
+ const slot = { pulls: [] };
18
+ ctx.callerGens.set(id, slot);
19
+ let started = false;
20
+ let finished = false;
21
+ const finish = () => {
22
+ finished = true;
23
+ ctx.callerGens.delete(id);
24
+ ctx.releaseArgRefs(id);
25
+ };
26
+ const gen = {
27
+ async next() {
28
+ if (finished || ctx.isClosed()) {
29
+ finish();
30
+ return { done: true, value: undefined };
31
+ }
32
+ if (!started) {
33
+ started = true;
34
+ ctx.send({ kind: "iterate", id, service, path, args: ctx.marshalArgs(args, params, id) });
35
+ }
36
+ ctx.send({ kind: "pull", id });
37
+ const result = await new Promise((res) => slot.pulls.push(res));
38
+ if ("error" in result) {
39
+ finish();
40
+ throw result.error;
41
+ }
42
+ if (result.done) {
43
+ finish();
44
+ return { done: true, value: result.value };
45
+ }
46
+ return { done: false, value: result.value };
47
+ },
48
+ async return(value) {
49
+ if (!finished) {
50
+ const wasStarted = started;
51
+ finish();
52
+ if (wasStarted)
53
+ ctx.send({ kind: "return", id });
54
+ }
55
+ return { done: true, value: value };
56
+ },
57
+ async throw(error) {
58
+ if (!finished) {
59
+ const wasStarted = started;
60
+ finish();
61
+ if (wasStarted)
62
+ ctx.send({ kind: "raise", id, error: marshalError(error) });
63
+ }
64
+ throw error;
65
+ },
66
+ [Symbol.asyncIterator]() {
67
+ return this;
68
+ },
69
+ async [Symbol.asyncDispose]() {
70
+ await gen.return(undefined);
71
+ },
72
+ };
73
+ return gen;
74
+ }
75
+ //# sourceMappingURL=make-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-generator.js","sourceRoot":"","sources":["../../src/consume/make-generator.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAIvD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxD;;;;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,SAAS,CAAC,CAAC;QAChC,CAAC;KACJ,CAAC;IAEF,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Data } from "@adobe/data";
2
+ import type { Observe } from "@adobe/data/observe";
3
+ import type { Schema } from "@adobe/data/schema";
4
+ import type { CallerContext } from "./caller-context.js";
5
+ /**
6
+ * A local `Observe<Data>` that projects a remote observe member. On subscribe it
7
+ * allocates an id, marshals any observe-bearing args, registers the `notify`, and
8
+ * sends `subscribe`; each remote `next` for that id is routed back to `notify` by
9
+ * the endpoint. Unsubscribing deletes the id (so any `next` still in flight is
10
+ * dropped), sends `unsubscribe`, and releases any arg-observe providers.
11
+ *
12
+ * Unlike a local `Observe` (e.g. `Observe.fromConstant`, which notifies
13
+ * synchronously on subscribe), the FIRST value here necessarily arrives
14
+ * asynchronously — it is a round-trip over the transport.
15
+ */
16
+ export declare function makeObserve(ctx: CallerContext, service: string, path: readonly string[], args: readonly unknown[], params?: readonly Schema[]): Observe<Data>;
@@ -0,0 +1,29 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ /**
3
+ * A local `Observe<Data>` that projects a remote observe member. On subscribe it
4
+ * allocates an id, marshals any observe-bearing args, registers the `notify`, and
5
+ * sends `subscribe`; each remote `next` for that id is routed back to `notify` by
6
+ * the endpoint. Unsubscribing deletes the id (so any `next` still in flight is
7
+ * dropped), sends `unsubscribe`, and releases any arg-observe providers.
8
+ *
9
+ * Unlike a local `Observe` (e.g. `Observe.fromConstant`, which notifies
10
+ * synchronously on subscribe), the FIRST value here necessarily arrives
11
+ * asynchronously — it is a round-trip over the transport.
12
+ */
13
+ export function makeObserve(ctx, service, path, args, params) {
14
+ return (notify) => {
15
+ if (ctx.isClosed())
16
+ return () => undefined;
17
+ const id = ctx.nextId();
18
+ const wireArgs = ctx.marshalArgs(args, params, id);
19
+ ctx.callerSubs.set(id, notify);
20
+ ctx.send({ kind: "subscribe", id, service, path, args: wireArgs });
21
+ return () => {
22
+ if (ctx.callerSubs.delete(id)) {
23
+ ctx.send({ kind: "unsubscribe", id });
24
+ }
25
+ ctx.releaseArgRefs(id);
26
+ };
27
+ };
28
+ }
29
+ //# sourceMappingURL=make-observe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-observe.js","sourceRoot":"","sources":["../../src/consume/make-observe.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAOvD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CACvB,GAAkB,EAClB,OAAe,EACf,IAAuB,EACvB,IAAwB,EACxB,MAA0B;IAE1B,OAAO,CAAC,MAAM,EAAE,EAAE;QACd,IAAI,GAAG,CAAC,QAAQ,EAAE;YAAE,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;QAC3C,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QACnD,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAC/B,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QACnE,OAAO,GAAG,EAAE;YACR,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC5B,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1C,CAAC;YACD,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QAC3B,CAAC,CAAC;IACN,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Data } from "@adobe/data";
2
+ import type { Schema } from "@adobe/data/schema";
3
+ import type { CallerContext } from "./caller-context.js";
4
+ /**
5
+ * Projects a remote promise member: allocates an id, marshals any observe-bearing
6
+ * args, registers a pending slot, and sends `call`; the endpoint settles the slot
7
+ * from the matching `resolve`/`reject` and releases the arg-observe providers.
8
+ * When `defaultTimeoutMs` is set, a timer rejects the call (and releases providers)
9
+ * if no reply arrives — the host still runs to completion, but a wedged transport
10
+ * no longer hangs forever.
11
+ */
12
+ export declare function makePromise(ctx: CallerContext, service: string, path: readonly string[], args: readonly unknown[], params?: readonly Schema[]): Promise<Data>;
@@ -0,0 +1,32 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ /**
3
+ * Projects a remote promise member: allocates an id, marshals any observe-bearing
4
+ * args, registers a pending slot, and sends `call`; the endpoint settles the slot
5
+ * from the matching `resolve`/`reject` and releases the arg-observe providers.
6
+ * When `defaultTimeoutMs` is set, a timer rejects the call (and releases providers)
7
+ * if no reply arrives — the host still runs to completion, but a wedged transport
8
+ * no longer hangs forever.
9
+ */
10
+ export function makePromise(ctx, service, path, args, params) {
11
+ const label = `${service}.${path.join(".")}`;
12
+ return new Promise((resolve, reject) => {
13
+ if (ctx.isClosed()) {
14
+ reject(new Error(`rpc endpoint is closed (${label})`));
15
+ return;
16
+ }
17
+ const id = ctx.nextId();
18
+ const wireArgs = ctx.marshalArgs(args, params, id);
19
+ const slot = { resolve, reject };
20
+ if (ctx.defaultTimeoutMs !== undefined) {
21
+ slot.timer = setTimeout(() => {
22
+ if (ctx.callPending.delete(id)) {
23
+ ctx.releaseArgRefs(id);
24
+ reject(new Error(`rpc call ${label} timed out after ${ctx.defaultTimeoutMs}ms`));
25
+ }
26
+ }, ctx.defaultTimeoutMs);
27
+ }
28
+ ctx.callPending.set(id, slot);
29
+ ctx.send({ kind: "call", id, service, path, args: wireArgs });
30
+ });
31
+ }
32
+ //# sourceMappingURL=make-promise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-promise.js","sourceRoot":"","sources":["../../src/consume/make-promise.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAMv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IAClE,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Schema } from "@adobe/data/schema";
2
+ import type { CallerContext } from "./caller-context.js";
3
+ /**
4
+ * Projects a remote void member: fire-and-forget `send`, no reply. A throw inside
5
+ * the host handler has no wire channel back here — it is routed to the host
6
+ * endpoint's `onError`.
7
+ *
8
+ * NOTE: observe-bearing arguments to a void member cannot be released (there is
9
+ * no completion signal), so their providers live until the endpoint closes.
10
+ * Prefer a promise/observe/generator member when passing observe arguments.
11
+ */
12
+ export declare function makeVoid(ctx: CallerContext, service: string, path: readonly string[], args: readonly unknown[], params?: readonly Schema[]): void;
@@ -0,0 +1,17 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ /**
3
+ * Projects a remote void member: fire-and-forget `send`, no reply. A throw inside
4
+ * the host handler has no wire channel back here — it is routed to the host
5
+ * endpoint's `onError`.
6
+ *
7
+ * NOTE: observe-bearing arguments to a void member cannot be released (there is
8
+ * no completion signal), so their providers live until the endpoint closes.
9
+ * Prefer a promise/observe/generator member when passing observe arguments.
10
+ */
11
+ export function makeVoid(ctx, service, path, args, params) {
12
+ if (ctx.isClosed())
13
+ return;
14
+ const id = ctx.nextId();
15
+ ctx.send({ kind: "send", id, service, path, args: ctx.marshalArgs(args, params, id) });
16
+ }
17
+ //# sourceMappingURL=make-void.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-void.js","sourceRoot":"","sources":["../../src/consume/make-void.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAKvD;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CACpB,GAAkB,EAClB,OAAe,EACf,IAAuB,EACvB,IAAwB,EACxB,MAA0B;IAE1B,IAAI,GAAG,CAAC,QAAQ,EAAE;QAAE,OAAO;IAC3B,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;IACxB,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;AAC3F,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { RpcError } from "../protocol.js";
2
+ /**
3
+ * Rebuild a local `Error` from a wire {@link RpcError}. The result is always a
4
+ * plain `Error` (the remote subclass is not reconstructable); `name` and the
5
+ * remote `stack` are preserved so logs point back at the true origin.
6
+ */
7
+ export declare function reconstructError(error: RpcError): Error;
@@ -0,0 +1,14 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ /**
3
+ * Rebuild a local `Error` from a wire {@link RpcError}. The result is always a
4
+ * plain `Error` (the remote subclass is not reconstructable); `name` and the
5
+ * remote `stack` are preserved so logs point back at the true origin.
6
+ */
7
+ export function reconstructError(error) {
8
+ const e = new Error(error.message);
9
+ e.name = error.name;
10
+ if (error.stack !== undefined)
11
+ e.stack = error.stack;
12
+ return e;
13
+ }
14
+ //# sourceMappingURL=reconstruct-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconstruct-error.js","sourceRoot":"","sources":["../../src/consume/reconstruct-error.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAIvD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAe;IAC5C,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACpB,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;QAAE,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACrD,OAAO,CAAC,CAAC;AACb,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Schema } from "@adobe/data/schema";
2
+ import { type Service } from "@adobe/data/service";
3
+ import type { CallerContext } from "./caller-context.js";
4
+ /**
5
+ * Builds an equivalent-shaped local service from a peer service's schema. The
6
+ * `schema` slot republishes the schema as a constant observable, so the projected
7
+ * service is introspectable exactly like any other. Nested services are shimmed
8
+ * on both sides so their members are reachable transparently.
9
+ */
10
+ export declare function synthesizeService(ctx: CallerContext, name: string, schema: Schema): Service;
@@ -0,0 +1,77 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { Observe } from "@adobe/data/observe";
3
+ import { AsyncDataService } from "@adobe/data/service";
4
+ import { isPureDataSchema } from "../arg-marshal.js";
5
+ import { makeObserve } from "./make-observe.js";
6
+ import { makePromise } from "./make-promise.js";
7
+ import { makeGenerator } from "./make-generator.js";
8
+ import { makeVoid } from "./make-void.js";
9
+ /**
10
+ * Recursively shim a service's members from its schema. Each described member is
11
+ * either a LEAF (`observe`/`function`, classified with the same `memberKind` the
12
+ * local lazy wrapper uses and wrapped to forward over the transport) or a NESTED
13
+ * service (a child `object` schema with its own `properties`), which is shimmed
14
+ * as a matching nested object. Every leaf is addressed by its full `path` from
15
+ * the service root, so nested members round-trip exactly like top-level ones.
16
+ */
17
+ function buildMembers(ctx, service, properties, path) {
18
+ const out = {};
19
+ for (const [key, member] of Object.entries(properties)) {
20
+ const memberPath = [...path, key];
21
+ if (member.type === "observe" || member.type === "function") {
22
+ const kind = AsyncDataService.memberKind(member);
23
+ const params = member.signature?.parameters;
24
+ switch (kind) {
25
+ case "observe":
26
+ out[key] = makeObserve(ctx, service, memberPath, []);
27
+ break;
28
+ case "fn:observe":
29
+ out[key] = (...args) => makeObserve(ctx, service, memberPath, args, params);
30
+ break;
31
+ case "fn:promise":
32
+ out[key] = (...args) => makePromise(ctx, service, memberPath, args, params);
33
+ break;
34
+ case "fn:generator":
35
+ out[key] = (...args) => makeGenerator(ctx, service, memberPath, args, params);
36
+ break;
37
+ case "fn:void":
38
+ // A void member has no completion signal, so it can't release
39
+ // arg-constructor providers — reject them rather than leak.
40
+ if ((params ?? []).some((p) => !isPureDataSchema(p))) {
41
+ const label = memberPath.join(".");
42
+ out[key] = () => {
43
+ throw new Error(`data-rpc: void member "${label}" cannot take Observe/Promise/AsyncGenerator arguments — use a promise/observe/generator member`);
44
+ };
45
+ }
46
+ else {
47
+ out[key] = (...args) => makeVoid(ctx, service, memberPath, args, params);
48
+ }
49
+ break;
50
+ }
51
+ }
52
+ else if (member.type === "object" || member.properties !== undefined) {
53
+ // Nested service — shim its members recursively under the extended path.
54
+ out[key] = buildMembers(ctx, service, member.properties ?? {}, memberPath);
55
+ }
56
+ else {
57
+ // Not a leaf and not a container — let memberKind raise the precise error.
58
+ AsyncDataService.memberKind(member);
59
+ }
60
+ }
61
+ return out;
62
+ }
63
+ /**
64
+ * Builds an equivalent-shaped local service from a peer service's schema. The
65
+ * `schema` slot republishes the schema as a constant observable, so the projected
66
+ * service is introspectable exactly like any other. Nested services are shimmed
67
+ * on both sides so their members are reachable transparently.
68
+ */
69
+ export function synthesizeService(ctx, name, schema) {
70
+ const service = {
71
+ serviceName: `rpc:${name}`,
72
+ schema: Observe.fromConstant(schema),
73
+ ...buildMembers(ctx, name, schema.properties ?? {}, []),
74
+ };
75
+ return service;
76
+ }
77
+ //# sourceMappingURL=synthesize-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"synthesize-service.js","sourceRoot":"","sources":["../../src/consume/synthesize-service.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAgB,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;;;;GAOG;AACH,SAAS,YAAY,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,EAAE,EAAE,CAAC;KAC1D,CAAC;IACF,OAAO,OAAkB,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { RpcEndpoint, RpcEndpointOptions } from "./endpoint.js";
2
+ import type { RpcTransport } from "./transport.js";
3
+ /**
4
+ * Create a bidirectional RPC endpoint over `transport`. Sends a `hello`
5
+ * handshake immediately; re-announces exposed services whenever the peer says
6
+ * `hello`, so services exposed before the peer connected are still discovered.
7
+ */
8
+ export declare function createRpcEndpoint(transport: RpcTransport, options?: RpcEndpointOptions): RpcEndpoint;