@fuzdev/fuz_app 0.167.0 → 0.168.0
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 +2 -2
|
@@ -26,6 +26,7 @@ import './assert_dev_env.js';
|
|
|
26
26
|
* @module
|
|
27
27
|
*/
|
|
28
28
|
import { describe, test, beforeAll, assert } from 'vitest';
|
|
29
|
+
import { is, parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
29
30
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
30
31
|
import { JSONRPC_INTERNAL_ERROR, JSONRPC_METHOD_NOT_FOUND, JsonrpcErrorResponse } from '../http/jsonrpc.js';
|
|
31
32
|
import { jsonrpc_error_code_to_http_status } from '../http/jsonrpc_errors.js';
|
|
@@ -64,13 +65,13 @@ export const pick_rpc_auth = (method, keeper, authed_account, admin_account) =>
|
|
|
64
65
|
export const assert_rpc_authenticated = (method, status, body, principal) => {
|
|
65
66
|
if (principal === 'public')
|
|
66
67
|
return;
|
|
67
|
-
const parsed = JsonrpcErrorResponse
|
|
68
|
-
const data = parsed.
|
|
68
|
+
const parsed = parse(JsonrpcErrorResponse, body);
|
|
69
|
+
const data = parsed.ok ? parsed.value.error.data : undefined;
|
|
69
70
|
const reason = data !== null && typeof data === 'object' ? data.reason : undefined;
|
|
70
71
|
if (!is_unauthenticated_refusal(status, reason))
|
|
71
72
|
return;
|
|
72
|
-
const detail = parsed.
|
|
73
|
-
? `code ${parsed.
|
|
73
|
+
const detail = parsed.ok
|
|
74
|
+
? `code ${parsed.value.error.code}, message ${JSON.stringify(parsed.value.error.message)}${data === undefined ? '' : `, data ${JSON.stringify(data)}`}`
|
|
74
75
|
: `body ${typeof body === 'string' ? body.slice(0, 500) : JSON.stringify(body).slice(0, 500)}`;
|
|
75
76
|
assert.fail(`method '${method}' answered 401 to the ${principal} principal's credential (${detail})` +
|
|
76
77
|
' — the call carried a credential its auth admits, so the backend owed an' +
|
|
@@ -90,8 +91,7 @@ export const assert_rpc_authenticated = (method, status, body, principal) => {
|
|
|
90
91
|
* round-trip outcome.
|
|
91
92
|
*/
|
|
92
93
|
const assert_method_implemented = (method, body) => {
|
|
93
|
-
|
|
94
|
-
if (parsed.success && parsed.data.error.code === JSONRPC_METHOD_NOT_FOUND) {
|
|
94
|
+
if (is(JsonrpcErrorResponse, body) && body.error.code === JSONRPC_METHOD_NOT_FOUND) {
|
|
95
95
|
assert.fail(`method '${method}' is registered on the local surface but the backend` +
|
|
96
96
|
` returned method-not-found — backend is missing this method (parity gap)`);
|
|
97
97
|
}
|
|
@@ -137,15 +137,15 @@ const INTERNAL_ERROR_HTTP_STATUS = jsonrpc_error_code_to_http_status(JSONRPC_INT
|
|
|
137
137
|
* or a success (a declared success fixture), for the failure message
|
|
138
138
|
*/
|
|
139
139
|
const assert_not_crash = (method, status, body, expected) => {
|
|
140
|
-
const parsed = JsonrpcErrorResponse
|
|
141
|
-
const code = parsed.
|
|
142
|
-
const crashed = parsed.
|
|
140
|
+
const parsed = parse(JsonrpcErrorResponse, body);
|
|
141
|
+
const code = parsed.ok ? parsed.value.error.code : null;
|
|
142
|
+
const crashed = parsed.ok
|
|
143
143
|
? status === INTERNAL_ERROR_HTTP_STATUS || code === JSONRPC_INTERNAL_ERROR
|
|
144
144
|
: status >= 500;
|
|
145
145
|
if (!crashed)
|
|
146
146
|
return;
|
|
147
|
-
const message = parsed.
|
|
148
|
-
? parsed.
|
|
147
|
+
const message = parsed.ok
|
|
148
|
+
? parsed.value.error.message
|
|
149
149
|
: typeof body === 'string'
|
|
150
150
|
? body.slice(0, 500)
|
|
151
151
|
: JSON.stringify(body).slice(0, 500);
|
|
@@ -87,7 +87,7 @@ const answer_request = async (request, on_request, reply) => {
|
|
|
87
87
|
return; // swallow — never-replying peer
|
|
88
88
|
reply('error' in outcome
|
|
89
89
|
? // Test wire-frames keep `code` a plain `number` (not the branded
|
|
90
|
-
//
|
|
90
|
+
// `JsonrpcServerErrorCode`), so cast at the builder boundary.
|
|
91
91
|
create_jsonrpc_error_response(request.id, outcome.error)
|
|
92
92
|
: create_jsonrpc_response(request.id, outcome.result));
|
|
93
93
|
};
|
|
@@ -394,7 +394,7 @@
|
|
|
394
394
|
{#if method.input_schema}
|
|
395
395
|
<pre>{JSON.stringify(method.input_schema, null, 2)}</pre>
|
|
396
396
|
{:else}
|
|
397
|
-
<span class="text_50">none (
|
|
397
|
+
<span class="text_50">none (void)</span>
|
|
398
398
|
{/if}
|
|
399
399
|
</div>
|
|
400
400
|
<div>
|
|
@@ -477,7 +477,7 @@
|
|
|
477
477
|
{#if method.input_schema}
|
|
478
478
|
<pre>{JSON.stringify(method.input_schema, null, 2)}</pre>
|
|
479
479
|
{:else}
|
|
480
|
-
<span class="text_50">none (
|
|
480
|
+
<span class="text_50">none (void)</span>
|
|
481
481
|
{/if}
|
|
482
482
|
</div>
|
|
483
483
|
<div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuzdev/fuz_app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.168.0",
|
|
4
4
|
"description": "fullstack app library",
|
|
5
5
|
"glyph": "🗝",
|
|
6
6
|
"logo": "logo.svg",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"@electric-sql/pglite": "^0.5.8",
|
|
96
96
|
"@fuzdev/blake3-wasm": "^0.2.0",
|
|
97
97
|
"@fuzdev/fuz_code": "^0.56.0",
|
|
98
|
-
"@fuzdev/fuz_css": "^0.
|
|
98
|
+
"@fuzdev/fuz_css": "^0.73.0",
|
|
99
99
|
"@fuzdev/fuz_schema": "^0.5.4",
|
|
100
100
|
"@fuzdev/fuz_ui": "^0.222.0",
|
|
101
101
|
"@fuzdev/fuz_util": "^0.79.1",
|