@fuzdev/fuz_app 0.167.0 → 0.168.1
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/dist/actions/CLAUDE.md +9 -8
- package/dist/actions/action_dispatcher.d.ts +1 -1
- package/dist/actions/action_dispatcher.d.ts.map +1 -1
- package/dist/actions/action_dispatcher.js +1 -1
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +1 -1
- package/dist/actions/action_event_data.d.ts +260 -65
- package/dist/actions/action_event_data.d.ts.map +1 -1
- package/dist/actions/action_event_data.js +11 -11
- package/dist/actions/action_event_types.d.ts +5 -14
- package/dist/actions/action_event_types.d.ts.map +1 -1
- package/dist/actions/action_event_types.js +3 -3
- package/dist/actions/action_rpc.js +5 -5
- package/dist/actions/action_spec.d.ts +8 -26
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +4 -4
- package/dist/actions/broadcast_api.d.ts +1 -1
- package/dist/actions/broadcast_api.js +1 -1
- package/dist/actions/cancel.d.ts +17 -9
- package/dist/actions/cancel.d.ts.map +1 -1
- package/dist/actions/cancel.js +3 -3
- package/dist/actions/heartbeat.d.ts +3 -4
- package/dist/actions/heartbeat.d.ts.map +1 -1
- package/dist/actions/heartbeat.js +4 -4
- package/dist/actions/peer_ping.d.ts +63 -23
- package/dist/actions/peer_ping.d.ts.map +1 -1
- package/dist/actions/peer_ping.js +20 -19
- package/dist/actions/peer_request.d.ts +6 -3
- package/dist/actions/peer_request.d.ts.map +1 -1
- package/dist/actions/peer_request.js +8 -2
- package/dist/actions/perform_action.d.ts +1 -1
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/transports.d.ts +2 -3
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +0 -4
- package/dist/actions/transports_http.d.ts.map +1 -1
- package/dist/actions/transports_http.js +4 -3
- package/dist/actions/transports_ws.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +6 -5
- package/dist/http/CLAUDE.md +9 -8
- package/dist/http/jsonrpc.d.ts +231 -152
- package/dist/http/jsonrpc.d.ts.map +1 -1
- package/dist/http/jsonrpc.js +55 -85
- package/dist/http/jsonrpc_errors.d.ts +22 -4
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +37 -4
- package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
- package/dist/http/jsonrpc_helpers.js +13 -12
- package/dist/testing/CLAUDE.md +6 -3
- package/dist/testing/cross_backend/peer_ping_ws.d.ts +3 -2
- package/dist/testing/cross_backend/peer_ping_ws.d.ts.map +1 -1
- package/dist/testing/cross_backend/peer_ping_ws.js +49 -2
- package/dist/testing/rpc_helpers.d.ts +1 -1
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +13 -14
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +11 -11
- package/dist/testing/transports/ws_client.js +1 -1
- package/dist/ui/SurfaceExplorer.svelte +2 -2
- package/package.json +4 -4
|
@@ -3,22 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
7
7
|
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
8
8
|
import type { ActionEventPhase, ActionKind, ActionSpecUnion } from './action_spec.js';
|
|
9
|
-
export declare const ActionExecutor:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export type ActionExecutor = z.infer<typeof ActionExecutor>;
|
|
14
|
-
export declare const ActionEventStep: z.ZodEnum<{
|
|
15
|
-
initial: "initial";
|
|
16
|
-
parsed: "parsed";
|
|
17
|
-
handling: "handling";
|
|
18
|
-
handled: "handled";
|
|
19
|
-
failed: "failed";
|
|
20
|
-
}>;
|
|
21
|
-
export type ActionEventStep = z.infer<typeof ActionEventStep>;
|
|
9
|
+
export declare const ActionExecutor: import("@fuzdev/fuz_schema/schema.ts").Schema<"frontend" | "backend", "frontend" | "backend", "one_of", readonly ["frontend", "backend"]>;
|
|
10
|
+
export type ActionExecutor = Infer<typeof ActionExecutor>;
|
|
11
|
+
export declare const ActionEventStep: import("@fuzdev/fuz_schema/schema.ts").Schema<"initial" | "parsed" | "handling" | "handled" | "failed", "initial" | "parsed" | "handling" | "handled" | "failed", "one_of", readonly ["initial", "parsed", "handling", "handled", "failed"]>;
|
|
12
|
+
export type ActionEventStep = Infer<typeof ActionEventStep>;
|
|
22
13
|
export declare const action_event_step_transitions: Record<ActionEventStep, ReadonlyArray<ActionEventStep>>;
|
|
23
14
|
export declare const action_event_phase_by_kind: Record<ActionKind, ReadonlyArray<ActionEventPhase>>;
|
|
24
15
|
export declare const action_event_phase_transitions: Record<ActionEventPhase, ActionEventPhase | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_event_types.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_event_types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"action_event_types.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_event_types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEtF,eAAO,MAAM,cAAc,2IAAkC,CAAC;AAC9D,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE1D,eAAO,MAAM,eAAe,8OAAiE,CAAC;AAC9F,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAS5D,eAAO,MAAM,6BAA6B,EAAE,MAAM,CACjD,eAAe,EACf,aAAa,CAAC,eAAe,CAAC,CAO9B,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAW1F,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAU5F,CAAC;AAEF,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,qBAAqB,EAAE,CACtB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,gBAAgB,KACnB,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,GAAG,SAAS,CAAC;IACvC,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,eAAe,GAAG,SAAS,CAAC;IACpE;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;CAChC;AAED,yDAAyD;AACzD,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAEjE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAIhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,aAAa,sBAAsB,KAAG,SAAS,GAAG,IAChB,CAAC"}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
export const ActionExecutor =
|
|
8
|
-
export const ActionEventStep =
|
|
6
|
+
import { one_of } from '@fuzdev/fuz_schema/schema.ts';
|
|
7
|
+
export const ActionExecutor = one_of(['frontend', 'backend']);
|
|
8
|
+
export const ActionEventStep = one_of(['initial', 'parsed', 'handling', 'handled', 'failed']);
|
|
9
9
|
// The constants below use `Record<K, V> = {...}` rather than
|
|
10
10
|
// `as const satisfies Record<K, V>`. The typed annotation gives full
|
|
11
11
|
// completeness checking (TS rejects missing keys, excess keys, and wrong
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @module
|
|
14
14
|
*/
|
|
15
|
-
import { z } from 'zod';
|
|
16
15
|
import { DEV } from 'esm-env';
|
|
16
|
+
import { literal, unknown } from '@fuzdev/fuz_schema/schema.ts';
|
|
17
17
|
import { UnreachableError } from '@fuzdev/fuz_util/error.ts';
|
|
18
18
|
import { define_route } from '../http/route_spec.js';
|
|
19
19
|
import { route_raw } from '../http/route_result.js';
|
|
@@ -226,8 +226,8 @@ export const create_rpc_endpoint = (options) => {
|
|
|
226
226
|
jsonrpc: true,
|
|
227
227
|
handler: post_handler,
|
|
228
228
|
description: `JSON-RPC 2.0 endpoint — ${actions.length} method${actions.length === 1 ? '' : 's'}`,
|
|
229
|
-
input:
|
|
230
|
-
output:
|
|
229
|
+
input: literal(null), // dispatcher owns body parsing; rpc_endpoints surface has the real schemas
|
|
230
|
+
output: unknown, // varies by method
|
|
231
231
|
transaction: false // per-action inside dispatcher
|
|
232
232
|
}),
|
|
233
233
|
define_route({
|
|
@@ -239,8 +239,8 @@ export const create_rpc_endpoint = (options) => {
|
|
|
239
239
|
jsonrpc: true,
|
|
240
240
|
handler: get_handler,
|
|
241
241
|
description: `JSON-RPC 2.0 endpoint (side-effect-free reads) — ${actions.length} method${actions.length === 1 ? '' : 's'}`,
|
|
242
|
-
input:
|
|
243
|
-
output:
|
|
242
|
+
input: literal(null), // params from query string, validated by dispatcher
|
|
243
|
+
output: unknown, // varies by method
|
|
244
244
|
transaction: false // per-action inside dispatcher
|
|
245
245
|
})
|
|
246
246
|
];
|
|
@@ -16,27 +16,19 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @module
|
|
18
18
|
*/
|
|
19
|
-
import { z } from 'zod';
|
|
20
|
-
import type
|
|
19
|
+
import type { z } from 'zod';
|
|
20
|
+
import { type Infer, type void as fuz_void } from '@fuzdev/fuz_schema/schema.ts';
|
|
21
21
|
import type { RateLimitKey } from '../rate_limiter.js';
|
|
22
22
|
import type { RouteAuth } from '../http/auth_shape.js';
|
|
23
23
|
import type { ValidationSchema } from '../schema_issues.js';
|
|
24
24
|
/** The action kinds, in declaration order — what `ActionKind` and `is_action_spec` read. */
|
|
25
25
|
export declare const ACTION_KINDS: readonly ["request_response", "remote_notification", "local_call"];
|
|
26
|
-
export declare const ActionKind:
|
|
27
|
-
|
|
28
|
-
remote_notification: "remote_notification";
|
|
29
|
-
local_call: "local_call";
|
|
30
|
-
}>;
|
|
31
|
-
export type ActionKind = z.infer<typeof ActionKind>;
|
|
26
|
+
export declare const ActionKind: import("@fuzdev/fuz_schema/schema.ts").Schema<"request_response" | "remote_notification" | "local_call", "request_response" | "remote_notification" | "local_call", "one_of", readonly ["request_response", "remote_notification", "local_call"]>;
|
|
27
|
+
export type ActionKind = Infer<typeof ActionKind>;
|
|
32
28
|
/** Which side initiates an action — what `ActionInitiator` reads. */
|
|
33
29
|
export declare const ACTION_INITIATORS: readonly ["frontend", "backend", "both"];
|
|
34
|
-
export declare const ActionInitiator:
|
|
35
|
-
|
|
36
|
-
frontend: "frontend";
|
|
37
|
-
backend: "backend";
|
|
38
|
-
}>;
|
|
39
|
-
export type ActionInitiator = z.infer<typeof ActionInitiator>;
|
|
30
|
+
export declare const ActionInitiator: import("@fuzdev/fuz_schema/schema.ts").Schema<"both" | "frontend" | "backend", "both" | "frontend" | "backend", "one_of", readonly ["frontend", "backend", "both"]>;
|
|
31
|
+
export type ActionInitiator = Infer<typeof ActionInitiator>;
|
|
40
32
|
/** The fields every action spec carries; each kind narrows some of them. */
|
|
41
33
|
export interface ActionSpec {
|
|
42
34
|
method: string;
|
|
@@ -130,16 +122,6 @@ export type ActionSpecUnion = RequestResponseActionSpec | RemoteNotificationActi
|
|
|
130
122
|
export declare const is_action_spec: (value: unknown) => value is ActionSpecUnion;
|
|
131
123
|
/** The action event phases — what `ActionEventPhase` reads. */
|
|
132
124
|
export declare const ACTION_EVENT_PHASES: readonly ["send_request", "receive_request", "send_response", "receive_response", "send_error", "receive_error", "send", "receive", "execute"];
|
|
133
|
-
export declare const ActionEventPhase:
|
|
134
|
-
|
|
135
|
-
receive_request: "receive_request";
|
|
136
|
-
send_response: "send_response";
|
|
137
|
-
receive_response: "receive_response";
|
|
138
|
-
send_error: "send_error";
|
|
139
|
-
receive_error: "receive_error";
|
|
140
|
-
send: "send";
|
|
141
|
-
receive: "receive";
|
|
142
|
-
execute: "execute";
|
|
143
|
-
}>;
|
|
144
|
-
export type ActionEventPhase = z.infer<typeof ActionEventPhase>;
|
|
125
|
+
export declare const ActionEventPhase: import("@fuzdev/fuz_schema/schema.ts").Schema<"send_request" | "receive_request" | "send_response" | "receive_response" | "send_error" | "receive_error" | "send" | "receive" | "execute", "send_request" | "receive_request" | "send_response" | "receive_response" | "send_error" | "receive_error" | "send" | "receive" | "execute", "one_of", readonly ["send_request", "receive_request", "send_response", "receive_response", "send_error", "receive_error", "send", "receive", "execute"]>;
|
|
126
|
+
export type ActionEventPhase = Infer<typeof ActionEventPhase>;
|
|
145
127
|
//# sourceMappingURL=action_spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_spec.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"action_spec.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAU,KAAK,KAAK,EAAE,KAAK,IAAI,IAAI,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAEzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,4FAA4F;AAC5F,eAAO,MAAM,YAAY,oEAAqE,CAAC;AAC/F,eAAO,MAAM,UAAU,mPAAuB,CAAC;AAC/C,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAElD,qEAAqE;AACrE,eAAO,MAAM,iBAAiB,0CAA2C,CAAC;AAC1E,eAAO,MAAM,eAAe,qKAA4B,CAAC;AACzD,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE5D,4EAA4E;AAC5E,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,EAAE,eAAe,CAAC;IAC3B;;;;;;;;;;;OAWG;IACH,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,qDAAqD;IACrD,KAAK,EAAE,gBAAgB,CAAC;IACxB,sDAAsD;IACtD,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,CAAC,EAAE,YAAY,CAAC;CAC1B;AAED,iEAAiE;AACjE,MAAM,WAAW,yBAA0B,SAAQ,UAAU;IAC5D,IAAI,EAAE,kBAAkB,CAAC;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;CACZ;AAED,iGAAiG;AACjG,MAAM,WAAW,4BAA6B,SAAQ,UAAU;IAC/D,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,IAAI,CAAC;IACnB,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC;IACpC,KAAK,EAAE,IAAI,CAAC;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACtD,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;CACX;AAED,gDAAgD;AAChD,MAAM,MAAM,eAAe,GAC1B,yBAAyB,GAAG,4BAA4B,GAAG,mBAAmB,CAAC;AAEhF,wGAAwG;AACxG,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,eAKK,CAAC;AAE/D,+DAA+D;AAC/D,eAAO,MAAM,mBAAmB,gJAUtB,CAAC;AACX,eAAO,MAAM,gBAAgB,meAA8B,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @module
|
|
18
18
|
*/
|
|
19
|
-
import {
|
|
19
|
+
import { one_of } from '@fuzdev/fuz_schema/schema.ts';
|
|
20
20
|
/** The action kinds, in declaration order — what `ActionKind` and `is_action_spec` read. */
|
|
21
21
|
export const ACTION_KINDS = ['request_response', 'remote_notification', 'local_call'];
|
|
22
|
-
export const ActionKind =
|
|
22
|
+
export const ActionKind = one_of(ACTION_KINDS);
|
|
23
23
|
/** Which side initiates an action — what `ActionInitiator` reads. */
|
|
24
24
|
export const ACTION_INITIATORS = ['frontend', 'backend', 'both'];
|
|
25
|
-
export const ActionInitiator =
|
|
25
|
+
export const ActionInitiator = one_of(ACTION_INITIATORS);
|
|
26
26
|
/** Structural type guard for any `ActionSpecUnion` variant — checks `kind` is one of `ACTION_KINDS`. */
|
|
27
27
|
export const is_action_spec = (value) => value !== null &&
|
|
28
28
|
typeof value === 'object' &&
|
|
@@ -41,4 +41,4 @@ export const ACTION_EVENT_PHASES = [
|
|
|
41
41
|
'receive',
|
|
42
42
|
'execute'
|
|
43
43
|
];
|
|
44
|
-
export const ActionEventPhase =
|
|
44
|
+
export const ActionEventPhase = one_of(ACTION_EVENT_PHASES);
|
|
@@ -65,7 +65,7 @@ export interface CreateBroadcastApiOptions {
|
|
|
65
65
|
* Builds a typed broadcast API from a set of action specs.
|
|
66
66
|
*
|
|
67
67
|
* For each spec, adds a method keyed by `spec.method` that:
|
|
68
|
-
* - Validates `input` against the spec's
|
|
68
|
+
* - Validates `input` against the spec's input schema (logs and returns on failure)
|
|
69
69
|
* - Creates a JSON-RPC notification from the validated input
|
|
70
70
|
* - Broadcasts on the registry (filtered by `should_deliver` when supplied)
|
|
71
71
|
*
|
|
@@ -24,7 +24,7 @@ import { parse_any } from '../schema_issues.js';
|
|
|
24
24
|
* Builds a typed broadcast API from a set of action specs.
|
|
25
25
|
*
|
|
26
26
|
* For each spec, adds a method keyed by `spec.method` that:
|
|
27
|
-
* - Validates `input` against the spec's
|
|
27
|
+
* - Validates `input` against the spec's input schema (logs and returns on failure)
|
|
28
28
|
* - Creates a JSON-RPC notification from the validated input
|
|
29
29
|
* - Broadcasts on the registry (filtered by `should_deliver` when supplied)
|
|
30
30
|
*
|
package/dist/actions/cancel.d.ts
CHANGED
|
@@ -26,17 +26,21 @@
|
|
|
26
26
|
*
|
|
27
27
|
* @module
|
|
28
28
|
*/
|
|
29
|
-
import {
|
|
29
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
30
30
|
import type { Action } from './action_types.js';
|
|
31
31
|
/**
|
|
32
32
|
* Params for the `cancel` notification. `request_id` is the id of the
|
|
33
33
|
* pending request to abort. Must match the id of a request sent on the
|
|
34
34
|
* same socket; cancels from other sockets (or for unknown ids) are ignored.
|
|
35
35
|
*/
|
|
36
|
-
export declare const CancelNotificationParams:
|
|
37
|
-
request_id:
|
|
38
|
-
},
|
|
39
|
-
|
|
36
|
+
export declare const CancelNotificationParams: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
37
|
+
request_id: string | number;
|
|
38
|
+
}, {
|
|
39
|
+
request_id: string | number;
|
|
40
|
+
}, "object", {
|
|
41
|
+
request_id: import("@fuzdev/fuz_schema/schema.ts").Schema<string | number, string | number, "union", readonly [import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>, import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>]>;
|
|
42
|
+
}>;
|
|
43
|
+
export type CancelNotificationParams = Infer<typeof CancelNotificationParams>;
|
|
40
44
|
/**
|
|
41
45
|
* `ActionSpec` for the shared cancel. `auth: null` matches every other
|
|
42
46
|
* remote-notification spec — upgrade-time auth has already admitted the
|
|
@@ -51,10 +55,14 @@ export declare const cancel_action_spec: {
|
|
|
51
55
|
initiator: "frontend";
|
|
52
56
|
auth: null;
|
|
53
57
|
side_effects: true;
|
|
54
|
-
input:
|
|
55
|
-
request_id:
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
+
input: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
59
|
+
request_id: string | number;
|
|
60
|
+
}, {
|
|
61
|
+
request_id: string | number;
|
|
62
|
+
}, "object", {
|
|
63
|
+
request_id: import("@fuzdev/fuz_schema/schema.ts").Schema<string | number, string | number, "union", readonly [import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>, import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>]>;
|
|
64
|
+
}>;
|
|
65
|
+
output: import("@fuzdev/fuz_schema/schema.ts").Schema<void, void, "literal", undefined>;
|
|
58
66
|
async: true;
|
|
59
67
|
description: string;
|
|
60
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/cancel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"cancel.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/cancel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAA4B,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAIpF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;;;EAEnC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE9E;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;CAWS,CAAC;AAEzC;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,MAAqC,CAAC"}
|
package/dist/actions/cancel.js
CHANGED
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
*
|
|
27
27
|
* @module
|
|
28
28
|
*/
|
|
29
|
-
import {
|
|
29
|
+
import { object, void as fuz_void } from '@fuzdev/fuz_schema/schema.ts';
|
|
30
30
|
import { JsonrpcRequestId } from '../http/jsonrpc.js';
|
|
31
31
|
/**
|
|
32
32
|
* Params for the `cancel` notification. `request_id` is the id of the
|
|
33
33
|
* pending request to abort. Must match the id of a request sent on the
|
|
34
34
|
* same socket; cancels from other sockets (or for unknown ids) are ignored.
|
|
35
35
|
*/
|
|
36
|
-
export const CancelNotificationParams =
|
|
36
|
+
export const CancelNotificationParams = object({
|
|
37
37
|
request_id: JsonrpcRequestId
|
|
38
38
|
});
|
|
39
39
|
/**
|
|
@@ -51,7 +51,7 @@ export const cancel_action_spec = {
|
|
|
51
51
|
auth: null,
|
|
52
52
|
side_effects: true,
|
|
53
53
|
input: CancelNotificationParams,
|
|
54
|
-
output:
|
|
54
|
+
output: fuz_void,
|
|
55
55
|
async: true,
|
|
56
56
|
description: 'Client-initiated cancellation of an in-flight request by id. Dispatcher-handled: aborts the ctx.signal of the matching pending request on the same socket. Unknown or completed ids no-op.'
|
|
57
57
|
};
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* dispatcher tracks receive time, so incoming heartbeats keep the socket
|
|
12
12
|
* alive without any handler-level state.
|
|
13
13
|
*
|
|
14
|
-
* Parameterless: the input is `
|
|
14
|
+
* Parameterless: the input is `void`, so absent, `null`, and `{}` params
|
|
15
15
|
* are all the no-arg call (`to_void_params`) and anything else is refused —
|
|
16
16
|
* the same shapes the Rust spine's heartbeat admits via
|
|
17
17
|
* `require_void_params`. The output is an empty object. `{client_ts,
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
*
|
|
22
22
|
* @module
|
|
23
23
|
*/
|
|
24
|
-
import { z } from 'zod';
|
|
25
24
|
import type { Action } from './action_types.js';
|
|
26
25
|
/**
|
|
27
26
|
* `ActionSpec` for the shared heartbeat. Account-required, actor-none —
|
|
@@ -38,8 +37,8 @@ export declare const heartbeat_action_spec: {
|
|
|
38
37
|
actor: "none";
|
|
39
38
|
};
|
|
40
39
|
side_effects: false;
|
|
41
|
-
input:
|
|
42
|
-
output:
|
|
40
|
+
input: import("@fuzdev/fuz_schema/schema.ts").Schema<void, void, "literal", undefined>;
|
|
41
|
+
output: import("@fuzdev/fuz_schema/schema.ts").Schema<Record<string, never>, Record<string, never>, "object", {}>;
|
|
43
42
|
async: true;
|
|
44
43
|
description: string;
|
|
45
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heartbeat.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/heartbeat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;
|
|
1
|
+
{"version":3,"file":"heartbeat.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/heartbeat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;CAUG,CAAC;AAEtC,4EAA4E;AAC5E,eAAO,MAAM,iBAAiB,QAAO,MAAM,CAAC,MAAM,EAAE,KAAK,CAAS,CAAC;AAEnE;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAG9B,CAAC"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* dispatcher tracks receive time, so incoming heartbeats keep the socket
|
|
12
12
|
* alive without any handler-level state.
|
|
13
13
|
*
|
|
14
|
-
* Parameterless: the input is `
|
|
14
|
+
* Parameterless: the input is `void`, so absent, `null`, and `{}` params
|
|
15
15
|
* are all the no-arg call (`to_void_params`) and anything else is refused —
|
|
16
16
|
* the same shapes the Rust spine's heartbeat admits via
|
|
17
17
|
* `require_void_params`. The output is an empty object. `{client_ts,
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*
|
|
22
22
|
* @module
|
|
23
23
|
*/
|
|
24
|
-
import {
|
|
24
|
+
import { object, void as fuz_void } from '@fuzdev/fuz_schema/schema.ts';
|
|
25
25
|
/**
|
|
26
26
|
* `ActionSpec` for the shared heartbeat. Account-required, actor-none —
|
|
27
27
|
* upgrade-time auth has already admitted the socket; heartbeats don't
|
|
@@ -34,8 +34,8 @@ export const heartbeat_action_spec = {
|
|
|
34
34
|
initiator: 'frontend',
|
|
35
35
|
auth: { account: 'required', actor: 'none' },
|
|
36
36
|
side_effects: false,
|
|
37
|
-
input:
|
|
38
|
-
output:
|
|
37
|
+
input: fuz_void,
|
|
38
|
+
output: object({}),
|
|
39
39
|
async: true,
|
|
40
40
|
description: 'Shared activity ping — keeps the socket alive and exercises the dispatch path.'
|
|
41
41
|
};
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
*
|
|
35
35
|
* @module
|
|
36
36
|
*/
|
|
37
|
-
import {
|
|
37
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
38
38
|
import type { ActionContext, RpcAction } from './action_types.js';
|
|
39
39
|
/** Wire method name (both directions). Twin of the Rust `PEER_PING_METHOD`. */
|
|
40
40
|
export declare const PEER_PING_METHOD = "peer/ping";
|
|
@@ -63,25 +63,47 @@ export declare const REASON_PEER_PING_NONCE_MISMATCH = "peer_ping_nonce_mismatch
|
|
|
63
63
|
* (mirrors the Rust `PingActionInput`): `nonce` defaults to a server-issued
|
|
64
64
|
* value, `timeout_ms` to `DEFAULT_PEER_REQUEST_TIMEOUT` (clamped shorten-only).
|
|
65
65
|
*/
|
|
66
|
-
export declare const PingActionInput:
|
|
67
|
-
nonce
|
|
68
|
-
timeout_ms
|
|
69
|
-
},
|
|
70
|
-
|
|
66
|
+
export declare const PingActionInput: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
67
|
+
nonce?: number | undefined;
|
|
68
|
+
timeout_ms?: number | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
nonce?: number | undefined;
|
|
71
|
+
timeout_ms?: number | undefined;
|
|
72
|
+
} | undefined, "with_default", import("@fuzdev/fuz_schema/schema.ts").SchemaDefaultDef<import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
73
|
+
nonce?: number | undefined;
|
|
74
|
+
timeout_ms?: number | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
nonce?: number | undefined;
|
|
77
|
+
timeout_ms?: number | undefined;
|
|
78
|
+
}, "object", {
|
|
79
|
+
nonce: import("@fuzdev/fuz_schema/schema.ts").Schema<number | undefined, number | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>>>>;
|
|
80
|
+
timeout_ms: import("@fuzdev/fuz_schema/schema.ts").Schema<number | undefined, number | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>>>>;
|
|
81
|
+
}>>>;
|
|
82
|
+
export type PingActionInput = Infer<typeof PingActionInput>;
|
|
71
83
|
/** Params of the server→client `peer/ping` request frame. Twin of the Rust `PingRequest`. */
|
|
72
|
-
export declare const PingRequestParams:
|
|
73
|
-
nonce:
|
|
74
|
-
},
|
|
75
|
-
|
|
84
|
+
export declare const PingRequestParams: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
85
|
+
nonce: number;
|
|
86
|
+
}, {
|
|
87
|
+
nonce: number;
|
|
88
|
+
}, "object", {
|
|
89
|
+
nonce: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>>;
|
|
90
|
+
}>;
|
|
91
|
+
export type PingRequestParams = Infer<typeof PingRequestParams>;
|
|
76
92
|
/**
|
|
77
93
|
* The client's reply shape — also the action's output (the handler returns the
|
|
78
94
|
* validated echo). Twin of the Rust `PingResponse`.
|
|
79
95
|
*/
|
|
80
|
-
export declare const PingResponse:
|
|
81
|
-
nonce:
|
|
82
|
-
protocol_version:
|
|
83
|
-
},
|
|
84
|
-
|
|
96
|
+
export declare const PingResponse: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
97
|
+
nonce: number;
|
|
98
|
+
protocol_version: number;
|
|
99
|
+
}, {
|
|
100
|
+
nonce: number;
|
|
101
|
+
protocol_version: number;
|
|
102
|
+
}, "object", {
|
|
103
|
+
nonce: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>>;
|
|
104
|
+
protocol_version: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>>;
|
|
105
|
+
}>;
|
|
106
|
+
export type PingResponse = Infer<typeof PingResponse>;
|
|
85
107
|
/**
|
|
86
108
|
* `ActionSpec` for the shared `peer/ping`. `initiator: 'both'` (the
|
|
87
109
|
* client→server invocation drives a server→client request); `auth: public`
|
|
@@ -104,14 +126,32 @@ export declare const peer_ping_action_spec: {
|
|
|
104
126
|
actor: "none";
|
|
105
127
|
};
|
|
106
128
|
side_effects: false;
|
|
107
|
-
input:
|
|
108
|
-
nonce
|
|
109
|
-
timeout_ms
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
129
|
+
input: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
130
|
+
nonce?: number | undefined;
|
|
131
|
+
timeout_ms?: number | undefined;
|
|
132
|
+
}, {
|
|
133
|
+
nonce?: number | undefined;
|
|
134
|
+
timeout_ms?: number | undefined;
|
|
135
|
+
} | undefined, "with_default", import("@fuzdev/fuz_schema/schema.ts").SchemaDefaultDef<import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
136
|
+
nonce?: number | undefined;
|
|
137
|
+
timeout_ms?: number | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
nonce?: number | undefined;
|
|
140
|
+
timeout_ms?: number | undefined;
|
|
141
|
+
}, "object", {
|
|
142
|
+
nonce: import("@fuzdev/fuz_schema/schema.ts").Schema<number | undefined, number | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>>>>;
|
|
143
|
+
timeout_ms: import("@fuzdev/fuz_schema/schema.ts").Schema<number | undefined, number | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>>>>;
|
|
144
|
+
}>>>;
|
|
145
|
+
output: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
146
|
+
nonce: number;
|
|
147
|
+
protocol_version: number;
|
|
148
|
+
}, {
|
|
149
|
+
nonce: number;
|
|
150
|
+
protocol_version: number;
|
|
151
|
+
}, "object", {
|
|
152
|
+
nonce: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>>;
|
|
153
|
+
protocol_version: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>>;
|
|
154
|
+
}>;
|
|
115
155
|
async: true;
|
|
116
156
|
rate_limit: "ip";
|
|
117
157
|
description: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer_ping.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/peer_ping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"peer_ping.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/peer_ping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EASN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAKtC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGlE,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAIvC,kDAAkD;AAClD,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,iDAAiD;AACjD,eAAO,MAAM,2BAA2B,yBAAyB,CAAC;AAClE,iHAAiH;AACjH,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAC5D,sEAAsE;AACtE,eAAO,MAAM,8BAA8B,4BAA4B,CAAC;AACxE,0EAA0E;AAC1E,eAAO,MAAM,8BAA8B,4BAA4B,CAAC;AACxE,qFAAqF;AACrF,eAAO,MAAM,+BAA+B,6BAA6B,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;IAW3B,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE5D,6FAA6F;AAC7F,eAAO,MAAM,iBAAiB;;;;;;EAE5B,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;EAGvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAaG,CAAC;AA+BtC;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC7B,OAAO,eAAe,EACtB,KAAK,aAAa,KAChB,OAAO,CAAC,YAAY,CAsCtB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,OAAO,KAAG,YAGrD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAG9B,CAAC"}
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
*
|
|
35
35
|
* @module
|
|
36
36
|
*/
|
|
37
|
-
import {
|
|
37
|
+
import { min_value, number, object, optional, parse, pipe, safe_integer, with_default } from '@fuzdev/fuz_schema/schema.ts';
|
|
38
38
|
import { ThrownJsonrpcError, JSONRPC_ERROR_CODES } from '../http/jsonrpc_errors.js';
|
|
39
39
|
import { safe_parse_dropping_unknown_keys } from '../http/schema_helpers.js';
|
|
40
40
|
import { DEFAULT_PEER_REQUEST_TIMEOUT } from './peer_request.js';
|
|
@@ -66,26 +66,27 @@ export const REASON_PEER_PING_NONCE_MISMATCH = 'peer_ping_nonce_mismatch';
|
|
|
66
66
|
* (mirrors the Rust `PingActionInput`): `nonce` defaults to a server-issued
|
|
67
67
|
* value, `timeout_ms` to `DEFAULT_PEER_REQUEST_TIMEOUT` (clamped shorten-only).
|
|
68
68
|
*/
|
|
69
|
-
export const PingActionInput =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
export const PingActionInput = with_default(object({
|
|
70
|
+
nonce: optional(pipe(number, safe_integer)),
|
|
71
|
+
timeout_ms: optional(pipe(number, safe_integer, min_value(1)))
|
|
72
|
+
}),
|
|
73
|
+
// the default reads an omitted input (`undefined`) as `{}`: both fields are
|
|
74
|
+
// optional, so an empty invocation is valid (server-issued nonce, default
|
|
75
|
+
// timeout). The server reads absent `params` as `{}` before the schema; the
|
|
76
|
+
// client's pre-send parse of `app.api['peer/ping']()` reaches the default.
|
|
77
|
+
// One shared `{}`, which nothing writes to
|
|
78
|
+
{});
|
|
78
79
|
/** Params of the server→client `peer/ping` request frame. Twin of the Rust `PingRequest`. */
|
|
79
|
-
export const PingRequestParams =
|
|
80
|
-
nonce:
|
|
80
|
+
export const PingRequestParams = object({
|
|
81
|
+
nonce: pipe(number, safe_integer)
|
|
81
82
|
});
|
|
82
83
|
/**
|
|
83
84
|
* The client's reply shape — also the action's output (the handler returns the
|
|
84
85
|
* validated echo). Twin of the Rust `PingResponse`.
|
|
85
86
|
*/
|
|
86
|
-
export const PingResponse =
|
|
87
|
-
nonce:
|
|
88
|
-
protocol_version:
|
|
87
|
+
export const PingResponse = object({
|
|
88
|
+
nonce: pipe(number, safe_integer),
|
|
89
|
+
protocol_version: pipe(number, safe_integer)
|
|
89
90
|
});
|
|
90
91
|
/**
|
|
91
92
|
* `ActionSpec` for the shared `peer/ping`. `initiator: 'both'` (the
|
|
@@ -127,8 +128,8 @@ const peer_request_error_to_jsonrpc = (error) => {
|
|
|
127
128
|
case 'too_many_in_flight':
|
|
128
129
|
return new ThrownJsonrpcError(JSONRPC_ERROR_CODES.queue_overflow, 'too many in-flight peer requests', { reason: REASON_PEER_TOO_MANY_IN_FLIGHT });
|
|
129
130
|
case 'client_error':
|
|
130
|
-
//
|
|
131
|
-
//
|
|
131
|
+
// the client's error, already read to a base-set code and a string
|
|
132
|
+
// message (`parse_inbound_jsonrpc_error`), reaches the caller as is
|
|
132
133
|
return new ThrownJsonrpcError(error.error.code, error.error.message, error.error.data);
|
|
133
134
|
}
|
|
134
135
|
};
|
|
@@ -179,8 +180,8 @@ export const peer_ping_handler = async (input, ctx) => {
|
|
|
179
180
|
* @returns the `PingResponse` echo to send back as the reply's `result`
|
|
180
181
|
*/
|
|
181
182
|
export const peer_ping_responder = (params) => {
|
|
182
|
-
const parsed = PingRequestParams
|
|
183
|
-
return { nonce: parsed.
|
|
183
|
+
const parsed = parse(PingRequestParams, params);
|
|
184
|
+
return { nonce: parsed.ok ? parsed.value.nonce : 0, protocol_version: PEER_PROTOCOL_VERSION };
|
|
184
185
|
};
|
|
185
186
|
/**
|
|
186
187
|
* Protocol-action tuple — spread into the server's `actions` array (via
|
|
@@ -36,8 +36,9 @@ export declare const DEFAULT_MAX_IN_FLIGHT_PEER_REQUESTS_PER_CONNECTION = 256;
|
|
|
36
36
|
* - `connection_gone` — the socket closed (or was never registered) before a reply.
|
|
37
37
|
* - `too_many_in_flight` — the per-connection in-flight cap was hit.
|
|
38
38
|
* - `client_error` — the client answered with a JSON-RPC error; `error` is
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* its envelope read by `parse_inbound_jsonrpc_error` (a base-set code, a
|
|
40
|
+
* string message, its `data` as sent), so the initiating handler can surface
|
|
41
|
+
* the client's own message and data.
|
|
41
42
|
*/
|
|
42
43
|
export type PeerRequestError = {
|
|
43
44
|
kind: 'timeout';
|
|
@@ -113,7 +114,9 @@ export declare class PendingPeerRequests {
|
|
|
113
114
|
/**
|
|
114
115
|
* Settle the pending request matching an inbound reply. A success response
|
|
115
116
|
* resolves `{ok: true, value: result}`; an error response resolves
|
|
116
|
-
* `{ok: false, error: {kind: 'client_error', error}}`
|
|
117
|
+
* `{ok: false, error: {kind: 'client_error', error}}`, its `error` read by
|
|
118
|
+
* `parse_inbound_jsonrpc_error`, as the Rust twin reads it — the reply is
|
|
119
|
+
* remote-authored and unvalidated.
|
|
117
120
|
*
|
|
118
121
|
* Returns `false` when no entry matches — an unsolicited, cross-connection,
|
|
119
122
|
* or already-settled reply — so the caller drops it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer_request.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/peer_request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EACX,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"peer_request.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/peer_request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EACX,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,MAAM,oBAAoB,CAAC;AAI5B;;;GAGG;AACH,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,kDAAkD,MAAM,CAAC;AAEtE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GACzB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,GAC3B;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAEvD,uGAAuG;AACvG,MAAM,MAAM,kBAAkB,GAC7B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,aAAa,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAE7E,yDAAyD;AACzD,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,CAC3B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,oBAAoB,GAAG,SAAS,EACxC,OAAO,CAAC,EAAE,kBAAkB,KACxB,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAUjC,yCAAyC;AACzC,MAAM,WAAW,0BAA0B;IAC1C,sGAAsG;IACtG,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,qFAAqF;IACrF,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,mBAAmB;;gBAUnB,OAAO,CAAC,EAAE,0BAA0B;IAMhD;;;;;;;;;OASG;IACH,QAAQ,CACP,aAAa,EAAE,IAAI,EACnB,UAAU,CAAC,EAAE,MAAM,GACjB;QAAE,EAAE,EAAE,gBAAgB,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAA;KAAE,GAAG,IAAI;IAkBxE;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,GAAG,oBAAoB,GAAG,OAAO;IAcvF;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAUpF;;;;;OAKG;IACH,KAAK,CAAC,aAAa,EAAE,IAAI,GAAG,IAAI;IAUhC;;;OAGG;IACH,IAAI,CAAC,aAAa,CAAC,EAAE,IAAI,GAAG,MAAM;CAMlC;AAKD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,6BAA6B,GACzC,KAAK,MAAM,EACX,eAAe,IAAI,EACnB,IAAI,gBAAgB,GAAG,IAAI,KACzB,IAQF,CAAC"}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* @module
|
|
16
16
|
*/
|
|
17
17
|
import { is_jsonrpc_error_response } from '../http/jsonrpc_helpers.js';
|
|
18
|
+
import { parse_inbound_jsonrpc_error } from '../http/jsonrpc_errors.js';
|
|
18
19
|
/**
|
|
19
20
|
* Default deadline (ms) for a server→client peer request before it resolves
|
|
20
21
|
* `timeout`. Twin of the Rust spine's `DEFAULT_PEER_REQUEST_TIMEOUT`.
|
|
@@ -79,7 +80,9 @@ export class PendingPeerRequests {
|
|
|
79
80
|
/**
|
|
80
81
|
* Settle the pending request matching an inbound reply. A success response
|
|
81
82
|
* resolves `{ok: true, value: result}`; an error response resolves
|
|
82
|
-
* `{ok: false, error: {kind: 'client_error', error}}`
|
|
83
|
+
* `{ok: false, error: {kind: 'client_error', error}}`, its `error` read by
|
|
84
|
+
* `parse_inbound_jsonrpc_error`, as the Rust twin reads it — the reply is
|
|
85
|
+
* remote-authored and unvalidated.
|
|
83
86
|
*
|
|
84
87
|
* Returns `false` when no entry matches — an unsolicited, cross-connection,
|
|
85
88
|
* or already-settled reply — so the caller drops it.
|
|
@@ -94,7 +97,10 @@ export class PendingPeerRequests {
|
|
|
94
97
|
if (!this.#pending.get(connection_id)?.has(id))
|
|
95
98
|
return false;
|
|
96
99
|
const outcome = is_jsonrpc_error_response(response)
|
|
97
|
-
? {
|
|
100
|
+
? {
|
|
101
|
+
ok: false,
|
|
102
|
+
error: { kind: 'client_error', error: parse_inbound_jsonrpc_error(response.error) }
|
|
103
|
+
}
|
|
98
104
|
: { ok: true, value: response.result };
|
|
99
105
|
this.settle(connection_id, id, outcome);
|
|
100
106
|
return true;
|
|
@@ -77,7 +77,7 @@ import type { RequestClient } from './peer_request.js';
|
|
|
77
77
|
export interface PerformActionInput {
|
|
78
78
|
/** The resolved spec + handler (transport does method lookup). */
|
|
79
79
|
action: RpcAction;
|
|
80
|
-
/** Raw params from the wire envelope (
|
|
80
|
+
/** Raw params from the wire envelope (validated by `JsonrpcRequest`, pre-`parse_any(spec.input, …)`). */
|
|
81
81
|
raw_params: unknown;
|
|
82
82
|
/** JSON-RPC request id — echoed onto the response. */
|
|
83
83
|
request_id: JsonrpcRequestId;
|