@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.
Files changed (61) hide show
  1. package/dist/actions/CLAUDE.md +9 -8
  2. package/dist/actions/action_dispatcher.d.ts +1 -1
  3. package/dist/actions/action_dispatcher.d.ts.map +1 -1
  4. package/dist/actions/action_dispatcher.js +1 -1
  5. package/dist/actions/action_event.d.ts.map +1 -1
  6. package/dist/actions/action_event.js +1 -1
  7. package/dist/actions/action_event_data.d.ts +260 -65
  8. package/dist/actions/action_event_data.d.ts.map +1 -1
  9. package/dist/actions/action_event_data.js +11 -11
  10. package/dist/actions/action_event_types.d.ts +5 -14
  11. package/dist/actions/action_event_types.d.ts.map +1 -1
  12. package/dist/actions/action_event_types.js +3 -3
  13. package/dist/actions/action_rpc.js +5 -5
  14. package/dist/actions/action_spec.d.ts +8 -26
  15. package/dist/actions/action_spec.d.ts.map +1 -1
  16. package/dist/actions/action_spec.js +4 -4
  17. package/dist/actions/broadcast_api.d.ts +1 -1
  18. package/dist/actions/broadcast_api.js +1 -1
  19. package/dist/actions/cancel.d.ts +17 -9
  20. package/dist/actions/cancel.d.ts.map +1 -1
  21. package/dist/actions/cancel.js +3 -3
  22. package/dist/actions/heartbeat.d.ts +3 -4
  23. package/dist/actions/heartbeat.d.ts.map +1 -1
  24. package/dist/actions/heartbeat.js +4 -4
  25. package/dist/actions/peer_ping.d.ts +63 -23
  26. package/dist/actions/peer_ping.d.ts.map +1 -1
  27. package/dist/actions/peer_ping.js +20 -19
  28. package/dist/actions/peer_request.d.ts +6 -3
  29. package/dist/actions/peer_request.d.ts.map +1 -1
  30. package/dist/actions/peer_request.js +8 -2
  31. package/dist/actions/perform_action.d.ts +1 -1
  32. package/dist/actions/perform_action.d.ts.map +1 -1
  33. package/dist/actions/transports.d.ts +2 -3
  34. package/dist/actions/transports.d.ts.map +1 -1
  35. package/dist/actions/transports.js +0 -4
  36. package/dist/actions/transports_http.d.ts.map +1 -1
  37. package/dist/actions/transports_http.js +4 -3
  38. package/dist/actions/transports_ws.d.ts.map +1 -1
  39. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  40. package/dist/actions/ws_socket_session.js +6 -5
  41. package/dist/http/CLAUDE.md +9 -8
  42. package/dist/http/jsonrpc.d.ts +231 -152
  43. package/dist/http/jsonrpc.d.ts.map +1 -1
  44. package/dist/http/jsonrpc.js +55 -85
  45. package/dist/http/jsonrpc_errors.d.ts +22 -4
  46. package/dist/http/jsonrpc_errors.d.ts.map +1 -1
  47. package/dist/http/jsonrpc_errors.js +37 -4
  48. package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
  49. package/dist/http/jsonrpc_helpers.js +13 -12
  50. package/dist/testing/CLAUDE.md +6 -3
  51. package/dist/testing/cross_backend/peer_ping_ws.d.ts +3 -2
  52. package/dist/testing/cross_backend/peer_ping_ws.d.ts.map +1 -1
  53. package/dist/testing/cross_backend/peer_ping_ws.js +49 -2
  54. package/dist/testing/rpc_helpers.d.ts +1 -1
  55. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  56. package/dist/testing/rpc_helpers.js +13 -14
  57. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  58. package/dist/testing/rpc_round_trip.js +11 -11
  59. package/dist/testing/transports/ws_client.js +1 -1
  60. package/dist/ui/SurfaceExplorer.svelte +2 -2
  61. package/package.json +4 -4
@@ -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.safeParse(body);
68
- const data = parsed.success ? parsed.data.error.data : undefined;
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.success
73
- ? `code ${parsed.data.error.code}, message ${JSON.stringify(parsed.data.error.message)}${data === undefined ? '' : `, data ${JSON.stringify(data)}`}`
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
- const parsed = JsonrpcErrorResponse.safeParse(body);
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.safeParse(body);
141
- const code = parsed.success ? parsed.data.error.code : null;
142
- const crashed = parsed.success
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.success
148
- ? parsed.data.error.message
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
- // Zod `JsonrpcServerErrorCode`), so cast at the builder boundary.
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 (z.void)</span>
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 (z.void)</span>
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.167.0",
3
+ "version": "0.168.1",
4
4
  "description": "fullstack app library",
5
5
  "glyph": "🗝",
6
6
  "logo": "logo.svg",
@@ -37,7 +37,7 @@
37
37
  "@electric-sql/pglite": ">=0.4",
38
38
  "@fuzdev/blake3-wasm": ">=0.2.0",
39
39
  "@fuzdev/fuz_css": ">=0.72.0",
40
- "@fuzdev/fuz_schema": "^0.5.4",
40
+ "@fuzdev/fuz_schema": "^0.5.5",
41
41
  "@fuzdev/fuz_util": ">=0.79.0",
42
42
  "@fuzdev/pglet-wasm": ">=0.1.2",
43
43
  "@hono/bun": ">=1",
@@ -95,8 +95,8 @@
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.72.0",
99
- "@fuzdev/fuz_schema": "^0.5.4",
98
+ "@fuzdev/fuz_css": "^0.73.0",
99
+ "@fuzdev/fuz_schema": "^0.5.5",
100
100
  "@fuzdev/fuz_ui": "^0.222.0",
101
101
  "@fuzdev/fuz_util": "^0.79.1",
102
102
  "@fuzdev/gro": "^0.224.0",