@fuzdev/fuz_app 0.169.0 → 0.171.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 +19 -21
- package/dist/actions/action_codegen.d.ts +27 -18
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +90 -90
- package/dist/actions/action_event.d.ts +0 -8
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +7 -6
- package/dist/actions/action_event_data.d.ts +4 -4
- package/dist/actions/action_rpc.d.ts +1 -1
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +6 -7
- package/dist/actions/action_spec.d.ts +8 -10
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +1 -1
- package/dist/actions/action_types.d.ts +4 -4
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +2 -2
- package/dist/actions/broadcast_api.d.ts +2 -2
- package/dist/actions/broadcast_api.js +4 -4
- package/dist/actions/compile_action_registry.d.ts +6 -7
- package/dist/actions/compile_action_registry.d.ts.map +1 -1
- package/dist/actions/compile_action_registry.js +8 -9
- package/dist/actions/peer_ping.d.ts.map +1 -1
- package/dist/actions/peer_ping.js +3 -2
- package/dist/actions/perform_action.d.ts +6 -6
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +11 -10
- package/dist/actions/socket.svelte.d.ts +1 -1
- package/dist/actions/socket.svelte.js +2 -2
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +2 -1
- package/dist/auth/CLAUDE.md +11 -11
- package/dist/auth/admin_action_specs.d.ts +24 -24
- package/dist/auth/audit_emitter.d.ts +6 -7
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +11 -22
- package/dist/auth/audit_log_ddl.d.ts +1 -1
- package/dist/auth/audit_log_ddl.js +1 -1
- package/dist/auth/audit_log_queries.d.ts +0 -13
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +3 -3
- package/dist/auth/audit_log_schema.d.ts +14 -15
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +1 -1
- package/dist/auth/auth_ddl.d.ts +1 -1
- package/dist/auth/auth_ddl.js +1 -1
- package/dist/auth/cell_action_specs.d.ts +54 -54
- package/dist/auth/cell_actions.d.ts +2 -2
- package/dist/auth/cell_actions.js +5 -5
- package/dist/auth/middleware.d.ts +6 -2
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +14 -2
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +7 -9
- package/dist/auth/role_grant_offer_action_specs.d.ts +6 -6
- package/dist/auth/role_grant_offer_ddl.d.ts +1 -1
- package/dist/auth/role_grant_offer_ddl.js +1 -1
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +2 -3
- package/dist/auth/self_service_role_actions.d.ts +1 -1
- package/dist/auth/self_service_role_actions.js +1 -1
- package/dist/env/env_schemas.d.ts +1 -2
- package/dist/env/env_schemas.d.ts.map +1 -1
- package/dist/env/env_schemas.js +3 -4
- package/dist/http/CLAUDE.md +30 -31
- package/dist/http/auth_shape.d.ts +14 -32
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +14 -49
- package/dist/http/error_schemas.d.ts +18 -18
- package/dist/http/json_text.d.ts +53 -0
- package/dist/http/json_text.d.ts.map +1 -0
- package/dist/http/json_text.js +152 -0
- package/dist/http/jsonrpc_helpers.js +1 -1
- package/dist/http/route_error_check.d.ts +2 -2
- package/dist/http/route_error_check.d.ts.map +1 -1
- package/dist/http/route_error_check.js +2 -3
- package/dist/http/route_errors.d.ts +4 -4
- package/dist/http/route_errors.d.ts.map +1 -1
- package/dist/http/route_errors.js +0 -13
- package/dist/http/route_result.d.ts +2 -1
- package/dist/http/route_result.d.ts.map +1 -1
- package/dist/http/route_spec.d.ts +34 -37
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +31 -31
- package/dist/http/schema_helpers.d.ts +77 -68
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +54 -77
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +6 -8
- package/dist/primitive_schemas.d.ts +9 -17
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +9 -17
- package/dist/realtime/sse.d.ts +3 -3
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +2 -2
- package/dist/schema_issues.d.ts +39 -147
- package/dist/schema_issues.d.ts.map +1 -1
- package/dist/schema_issues.js +39 -352
- package/dist/schema_meta.d.ts +63 -136
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +37 -184
- package/dist/sensitivity.d.ts +3 -5
- package/dist/sensitivity.d.ts.map +1 -1
- package/dist/sensitivity.js +3 -5
- package/dist/testing/CLAUDE.md +20 -22
- package/dist/testing/adversarial_headers.js +2 -2
- package/dist/testing/adversarial_input_cases.d.ts +19 -18
- package/dist/testing/adversarial_input_cases.d.ts.map +1 -1
- package/dist/testing/adversarial_input_cases.js +31 -46
- package/dist/testing/assertions.d.ts +2 -2
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +3 -3
- package/dist/testing/cross_backend/account_lifecycle.js +2 -2
- package/dist/testing/cross_backend/action_manifest.d.ts +10 -9
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +4 -3
- package/dist/testing/cross_backend/cell_crud.js +1 -1
- package/dist/testing/cross_backend/conformance_rpc_auth.d.ts +0 -62
- package/dist/testing/cross_backend/conformance_rpc_auth.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +3 -3
- package/dist/testing/cross_backend/cross_rpc.d.ts +3 -4
- package/dist/testing/cross_backend/cross_rpc.d.ts.map +1 -1
- package/dist/testing/cross_backend/cross_rpc.js +4 -4
- package/dist/testing/cross_backend/differential.js +2 -2
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +16 -11
- package/dist/testing/cross_backend/origin_conformance.d.ts +9 -9
- package/dist/testing/cross_backend/query_shape.js +1 -1
- package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
- package/dist/testing/cross_backend/setup.d.ts +25 -3
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +4 -4
- package/dist/testing/cross_backend/sse_round_trip.js +2 -2
- package/dist/testing/cross_backend/testing_origin_check.d.ts +4 -4
- package/dist/testing/cross_backend/token_lifetime.js +3 -3
- package/dist/testing/cross_backend/wire_shapes.js +1 -1
- package/dist/testing/cross_backend/ws_envelope.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_envelope.js +8 -0
- package/dist/testing/cross_backend/ws_round_trip.js +1 -1
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +1 -1
- package/dist/testing/integration.js +2 -2
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +2 -2
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +2 -2
- package/dist/testing/rpc_attack_surface.js +1 -1
- package/dist/testing/rpc_envelope_cases.d.ts +10 -3
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +22 -1
- package/dist/testing/rpc_helpers.d.ts +12 -14
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +9 -10
- package/dist/testing/schema_generators.d.ts +67 -60
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +154 -159
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +2 -2
- package/dist/testing/surface_invariants.d.ts +1 -1
- package/dist/testing/surface_invariants.js +1 -1
- package/dist/ui/form_state.svelte.d.ts +1 -1
- package/dist/ui/form_state.svelte.js +1 -1
- package/package.json +5 -7
- package/dist/zod.d.ts +0 -116
- package/dist/zod.d.ts.map +0 -1
- package/dist/zod.js +0 -218
- package/dist/zod_schemas.d.ts +0 -100
- package/dist/zod_schemas.d.ts.map +0 -1
- package/dist/zod_schemas.js +0 -157
|
@@ -1,48 +1,57 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Schema-driven value generation helpers for testing.
|
|
4
|
+
*
|
|
5
|
+
* Walks `@fuzdev/fuz_schema` schemas to generate valid values for route
|
|
6
|
+
* params, request bodies, and URL paths. Used by adversarial input,
|
|
7
|
+
* adversarial 404, and round-trip validation test suites. A value that is no
|
|
8
|
+
* schema throws, and so does an input no body can be generated for, rather
|
|
9
|
+
* than yielding no body.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
3
14
|
import { get_schema_entries, get_schema_fields, unwrap_schema } from '@fuzdev/fuz_schema/introspect.ts';
|
|
4
15
|
import { to_json_schema } from '@fuzdev/fuz_schema/json_schema.ts';
|
|
5
|
-
import { zod_unwrap_def, zod_get_base_type, zod_unwrap_to_object, zod_extract_fields } from '../zod.js';
|
|
6
16
|
import { is_null_schema, is_void_schema } from '../http/schema_helpers.js';
|
|
7
17
|
import { compile_route_param_pattern, decode_route_path, parse_route_param, split_route_template } from '../http/route_error_check.js';
|
|
8
|
-
import {
|
|
18
|
+
import { assert_validation_schema, format_issues } from '../schema_issues.js';
|
|
9
19
|
/**
|
|
10
20
|
* The JSON Schema of a field's input side — where its format, pattern and
|
|
11
|
-
* bounds live.
|
|
21
|
+
* bounds live.
|
|
12
22
|
*
|
|
13
|
-
* Rendered with `io: 'input'`, so a field carrying a
|
|
23
|
+
* Rendered with `io: 'input'`, so a field carrying a `transform` in a pipe
|
|
14
24
|
* (`Username`) still yields the constraints its input is checked against;
|
|
15
25
|
* the default output side throws on a transform. A pipe yields its input
|
|
16
26
|
* side only, so constraints of the stage after it are not here. A
|
|
17
|
-
*
|
|
18
|
-
*
|
|
27
|
+
* `nullable` field renders as `anyOf: [{…}, {type: 'null'}]`, or a bare
|
|
28
|
+
* type as `type: [type, 'null']`;
|
|
19
29
|
* its one non-null branch or type is returned, so the bounds, pattern and
|
|
20
30
|
* `type` read the same as on the bare field. A union of two or more non-null
|
|
21
31
|
* branches returns the whole schema — its branches' bounds are no single
|
|
22
32
|
* field's bounds.
|
|
23
33
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* generators build from it is checked against the field itself before it's
|
|
30
|
-
* used. What an emitter refuses even then (a fuz_schema entry named like a
|
|
34
|
+
* It renders with `unrepresentable: 'any'`: a part JSON Schema can't say (a
|
|
35
|
+
* `check` or a `bigint`) is left out or `{}`, and the bounds around it still
|
|
36
|
+
* read, so a `pipe(string, max_length(n), check(…))` keeps its `maxLength` —
|
|
37
|
+
* every case the generators build from it is checked against the field itself
|
|
38
|
+
* before it's used. What the emitter refuses even then (an entry named like a
|
|
31
39
|
* member of `Object.prototype`, metadata that isn't JSON) throws: a mistake in
|
|
32
40
|
* the schema, not a gap in JSON Schema.
|
|
33
41
|
*
|
|
34
|
-
* A
|
|
35
|
-
*
|
|
36
|
-
*
|
|
42
|
+
* A `check` is never here: JSON Schema can't express one, so a bound a check
|
|
43
|
+
* enforces (a code-point length, a cross-field rule) generates no boundary
|
|
44
|
+
* case.
|
|
37
45
|
*
|
|
38
46
|
* @param field_schema - the field to read
|
|
39
47
|
* @returns the field's input-side JSON Schema
|
|
40
48
|
* @throws Error when the emitter refuses `field_schema` with `unrepresentable: 'any'`
|
|
41
49
|
*/
|
|
42
50
|
export const to_field_json_schema = (field_schema) => {
|
|
43
|
-
const json =
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
const json = to_json_schema(field_schema, {
|
|
52
|
+
io: 'input',
|
|
53
|
+
unrepresentable: 'any'
|
|
54
|
+
});
|
|
46
55
|
if (Array.isArray(json.anyOf)) {
|
|
47
56
|
const branches = json.anyOf.filter((branch) => branch.type !== 'null');
|
|
48
57
|
if (branches.length === 1)
|
|
@@ -99,8 +108,8 @@ export const detect_format = (field_schema) => detect_json_schema_format(to_fiel
|
|
|
99
108
|
* - Optional prefix: alphanumeric, starting with a letter, ending in `:`
|
|
100
109
|
* (`blake3:`, `sha256:`). A `_`-joined prefix over a base64url class is
|
|
101
110
|
* the sibling shape — see `generate_prefix_slug_pattern_value`.
|
|
102
|
-
* - Character class must be exactly `[0-9a-f]` or `[0-9a-fA-F]` (
|
|
103
|
-
* the regex source
|
|
111
|
+
* - Character class must be exactly `[0-9a-f]` or `[0-9a-fA-F]` (the JSON
|
|
112
|
+
* Schema carries the regex source verbatim — no character-class reordering).
|
|
104
113
|
* - Fixed-length quantifier `{N}`.
|
|
105
114
|
*
|
|
106
115
|
* Returns `null` when the pattern doesn't match the expected shape; the
|
|
@@ -128,8 +137,8 @@ const generate_hex_pattern_value = (pattern) => {
|
|
|
128
137
|
*
|
|
129
138
|
* Coverage today:
|
|
130
139
|
* - Prefix must start with a letter and be alphanumeric (e.g. `tok_`, `ses_`).
|
|
131
|
-
* - Character class must be exactly `[A-Za-z0-9_-]` (
|
|
132
|
-
* source
|
|
140
|
+
* - Character class must be exactly `[A-Za-z0-9_-]` (the JSON Schema carries
|
|
141
|
+
* the regex source verbatim — no character-class reordering).
|
|
133
142
|
* - Fixed-length quantifier `{N}`.
|
|
134
143
|
*
|
|
135
144
|
* Known gaps (will fall through to the absolute-path / URL candidates or
|
|
@@ -153,16 +162,16 @@ const generate_prefix_slug_pattern_value = (pattern) => {
|
|
|
153
162
|
return null;
|
|
154
163
|
return `${prefix}_${'x'.repeat(n)}`;
|
|
155
164
|
};
|
|
156
|
-
// --- reading a schema
|
|
157
|
-
/** Whether `schema` accepts `value
|
|
158
|
-
const accepts = (schema, value) =>
|
|
165
|
+
// --- reading a schema ---
|
|
166
|
+
/** Whether `schema` accepts `value`. */
|
|
167
|
+
const accepts = (schema, value) => parse(schema, value).ok;
|
|
159
168
|
/**
|
|
160
|
-
* Every layer of a
|
|
169
|
+
* Every layer of a schema, from the schema itself through
|
|
161
170
|
* each `optional`, `nullable`, `with_default`, `with_default_fn`, the first
|
|
162
171
|
* schema of a `pipe`, and a `lazy`'s schema, to what the value is — the
|
|
163
172
|
* layers `unwrap_schema` walks.
|
|
164
173
|
*/
|
|
165
|
-
const
|
|
174
|
+
const schema_layers = (schema) => {
|
|
166
175
|
const layers = [];
|
|
167
176
|
const seen = new Set();
|
|
168
177
|
let s = schema;
|
|
@@ -188,13 +197,12 @@ const fuz_schema_layers = (schema) => {
|
|
|
188
197
|
return layers;
|
|
189
198
|
};
|
|
190
199
|
/**
|
|
191
|
-
* The
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* `variant` `'union'`.
|
|
200
|
+
* The kind the generators switch on (`SchemaFieldInfo.base_type`,
|
|
201
|
+
* `SchemaFieldBaseType`): the schema's innermost layer's kind, with an object
|
|
202
|
+
* schema of any strictness `'object'`, and a `literal(null)` and a
|
|
203
|
+
* `literal(undefined)` (`s.void`) `'null'` and `'void'`.
|
|
196
204
|
*/
|
|
197
|
-
const
|
|
205
|
+
const to_base_type = (schema) => {
|
|
198
206
|
const base = unwrap_schema(schema);
|
|
199
207
|
switch (base.kind) {
|
|
200
208
|
case 'object':
|
|
@@ -204,57 +212,39 @@ const fuz_schema_base_type = (schema) => {
|
|
|
204
212
|
return 'object';
|
|
205
213
|
case 'literal':
|
|
206
214
|
return base.def === null ? 'null' : base.def === undefined ? 'void' : 'literal';
|
|
207
|
-
case 'one_of':
|
|
208
|
-
return 'enum';
|
|
209
|
-
case 'variant':
|
|
210
|
-
return 'union';
|
|
211
215
|
default:
|
|
212
216
|
return base.kind;
|
|
213
217
|
}
|
|
214
218
|
};
|
|
215
|
-
// the
|
|
216
|
-
|
|
217
|
-
// the fields of `schema` when its innermost layer is an object schema, else `null`;
|
|
218
|
-
// throws for a schema of neither library
|
|
219
|
+
// the fields of `schema` when its innermost layer is an object schema, else
|
|
220
|
+
// `null`; throws for a value that is no schema
|
|
219
221
|
const to_object_view = (schema, label) => {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return null;
|
|
224
|
-
return {
|
|
225
|
-
fields: get_schema_fields(schema).map((field) => {
|
|
226
|
-
const layers = fuz_schema_layers(field.schema);
|
|
227
|
-
return {
|
|
228
|
-
name: field.name,
|
|
229
|
-
base_type: fuz_schema_base_type(field.schema),
|
|
230
|
-
required: !layers.some((l) => l.kind === 'optional'),
|
|
231
|
-
has_default: field.has_default,
|
|
232
|
-
nullable: layers.some((l) => l.kind === 'nullable')
|
|
233
|
-
};
|
|
234
|
-
}),
|
|
235
|
-
field_schema: (name) => (Object.hasOwn(entries, name) ? entries[name] : undefined)
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
assert_zod_schema(schema, label);
|
|
239
|
-
const object_schema = zod_unwrap_to_object(schema);
|
|
240
|
-
if (!object_schema)
|
|
222
|
+
assert_validation_schema(schema, label);
|
|
223
|
+
const entries = get_schema_entries(schema);
|
|
224
|
+
if (!entries)
|
|
241
225
|
return null;
|
|
242
|
-
const shape = object_schema.shape;
|
|
243
226
|
return {
|
|
244
|
-
fields:
|
|
245
|
-
|
|
227
|
+
fields: get_schema_fields(schema).map((field) => {
|
|
228
|
+
const layers = schema_layers(field.schema);
|
|
229
|
+
return {
|
|
230
|
+
name: field.name,
|
|
231
|
+
base_type: to_base_type(field.schema),
|
|
232
|
+
required: !layers.some((l) => l.kind === 'optional'),
|
|
233
|
+
has_default: field.has_default,
|
|
234
|
+
nullable: layers.some((l) => l.kind === 'nullable')
|
|
235
|
+
};
|
|
236
|
+
}),
|
|
237
|
+
field_schema: (name) => (Object.hasOwn(entries, name) ? entries[name] : undefined)
|
|
246
238
|
};
|
|
247
239
|
};
|
|
248
240
|
/**
|
|
249
|
-
* The fields of an object schema
|
|
250
|
-
*
|
|
251
|
-
* (`
|
|
252
|
-
* schema whose innermost layer is an object schema (`get_schema_entries`,
|
|
253
|
-
* `get_schema_fields`).
|
|
241
|
+
* The fields of an object schema and the schema of each, through its
|
|
242
|
+
* wrappers: a schema whose innermost layer is an object schema
|
|
243
|
+
* (`get_schema_entries`, `get_schema_fields`).
|
|
254
244
|
*
|
|
255
|
-
* @param schema - an object schema, possibly wrapped
|
|
245
|
+
* @param schema - an object schema, possibly wrapped
|
|
256
246
|
* @param label - names the schema in the error
|
|
257
|
-
* @throws Error naming `label` when `schema` is no object schema, or
|
|
247
|
+
* @throws Error naming `label` when `schema` is no object schema, or no schema
|
|
258
248
|
*/
|
|
259
249
|
export const to_object_schema_view = (schema, label) => {
|
|
260
250
|
const view = to_object_view(schema, label);
|
|
@@ -296,8 +286,8 @@ const generate_valid_string = (field_schema) => {
|
|
|
296
286
|
}
|
|
297
287
|
// Email-shaped refinement (the `Email` primitive: loose `local@domain.tld`).
|
|
298
288
|
// The base `x`-fill has no `@`, so an email-pattern field needs a shaped
|
|
299
|
-
// candidate — the
|
|
300
|
-
//
|
|
289
|
+
// candidate — the regex form exposes a `pattern`, not the `format: 'email'`
|
|
290
|
+
// the `case 'email'` switch arm keys on.
|
|
301
291
|
const as_email = 'test@example.com';
|
|
302
292
|
if (accepts(field_schema, as_email))
|
|
303
293
|
return as_email;
|
|
@@ -315,65 +305,39 @@ const generate_valid_string = (field_schema) => {
|
|
|
315
305
|
return segments;
|
|
316
306
|
return base; // fall through — generate_valid_body will report the failure
|
|
317
307
|
};
|
|
318
|
-
// the element schema of an array field
|
|
308
|
+
// the element schema of an array field
|
|
319
309
|
const to_array_element = (field_schema) => {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
return base.kind === 'array' ? base.def : undefined;
|
|
323
|
-
}
|
|
324
|
-
return zod_unwrap_def(field_schema).element;
|
|
310
|
+
const base = unwrap_schema(field_schema);
|
|
311
|
+
return base.kind === 'array' ? base.def : undefined;
|
|
325
312
|
};
|
|
326
|
-
// the first option of a union field
|
|
313
|
+
// the first option of a union field
|
|
327
314
|
const to_first_union_option = (field_schema) => {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
return undefined;
|
|
335
|
-
}
|
|
336
|
-
// Zod 4 represents `z.union` and `z.discriminatedUnion` alike, `def.type ===
|
|
337
|
-
// 'union'` with a `def.options` array
|
|
338
|
-
return zod_unwrap_def(field_schema).options?.[0];
|
|
315
|
+
const base = unwrap_schema(field_schema);
|
|
316
|
+
if (base.kind === 'union')
|
|
317
|
+
return base.def[0];
|
|
318
|
+
if (base.kind === 'variant')
|
|
319
|
+
return base.def.options[0];
|
|
320
|
+
return undefined;
|
|
339
321
|
};
|
|
340
|
-
// the values a literal or enum field accepts,
|
|
322
|
+
// the values a literal or enum field accepts, in declared order
|
|
341
323
|
const to_literal_values = (field_schema) => {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
return base.def;
|
|
348
|
-
return [];
|
|
349
|
-
}
|
|
350
|
-
const def = zod_unwrap_def(field_schema);
|
|
351
|
-
// Zod 4 stores literal values on `def.values` (always an array, even for
|
|
352
|
-
// single-valued literals), and enum entries as an object `{key: value}`
|
|
353
|
-
if ('values' in def && Array.isArray(def.values))
|
|
354
|
-
return def.values;
|
|
355
|
-
if ('entries' in def) {
|
|
356
|
-
const entries = def.entries;
|
|
357
|
-
if (entries && typeof entries === 'object') {
|
|
358
|
-
return Object.values(entries);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
324
|
+
const base = unwrap_schema(field_schema);
|
|
325
|
+
if (base.kind === 'literal')
|
|
326
|
+
return [base.def];
|
|
327
|
+
if (base.kind === 'one_of')
|
|
328
|
+
return base.def;
|
|
361
329
|
return [];
|
|
362
330
|
};
|
|
363
331
|
/**
|
|
364
332
|
* Generate a valid-ish value for a field based on its base type.
|
|
365
333
|
*
|
|
366
|
-
* @param field - the field's info, from `to_object_schema_view`
|
|
367
|
-
* @param field_schema - the field's schema
|
|
334
|
+
* @param field - the field's info, from `to_object_schema_view`
|
|
335
|
+
* @param field_schema - the field's schema
|
|
368
336
|
* @returns the value, checked by the caller against the whole schema
|
|
369
337
|
*/
|
|
370
338
|
export const generate_valid_value = (field, field_schema) => {
|
|
371
339
|
const format = detect_format(field_schema);
|
|
372
340
|
switch (field.base_type) {
|
|
373
|
-
case 'uuid':
|
|
374
|
-
return '00000000-0000-0000-0000-000000000000';
|
|
375
|
-
case 'email':
|
|
376
|
-
return 'test@example.com';
|
|
377
341
|
case 'string':
|
|
378
342
|
if (format === 'uuid')
|
|
379
343
|
return '00000000-0000-0000-0000-000000000000';
|
|
@@ -382,8 +346,7 @@ export const generate_valid_value = (field, field_schema) => {
|
|
|
382
346
|
if (format === 'date-time')
|
|
383
347
|
return '2020-01-01T00:00:00.000Z';
|
|
384
348
|
return generate_valid_string(field_schema);
|
|
385
|
-
case 'number':
|
|
386
|
-
case 'int': {
|
|
349
|
+
case 'number': {
|
|
387
350
|
// 1, unless the schema's bounds rule it out (`.negative()`, `.min(10)`)
|
|
388
351
|
for (const candidate of [1, -1, 0]) {
|
|
389
352
|
if (accepts(field_schema, candidate))
|
|
@@ -392,12 +355,8 @@ export const generate_valid_value = (field, field_schema) => {
|
|
|
392
355
|
const json = to_field_json_schema(field_schema);
|
|
393
356
|
if (typeof json.minimum === 'number')
|
|
394
357
|
return Math.ceil(json.minimum);
|
|
395
|
-
if (typeof json.exclusiveMinimum === 'number')
|
|
396
|
-
return Math.floor(json.exclusiveMinimum) + 1;
|
|
397
358
|
if (typeof json.maximum === 'number')
|
|
398
359
|
return Math.floor(json.maximum);
|
|
399
|
-
if (typeof json.exclusiveMaximum === 'number')
|
|
400
|
-
return Math.ceil(json.exclusiveMaximum) - 1;
|
|
401
360
|
return 1; // fall through — generate_valid_body will report the failure
|
|
402
361
|
}
|
|
403
362
|
case 'boolean':
|
|
@@ -427,11 +386,11 @@ export const generate_valid_value = (field, field_schema) => {
|
|
|
427
386
|
case 'null':
|
|
428
387
|
return null;
|
|
429
388
|
case 'void':
|
|
430
|
-
case 'undefined':
|
|
431
389
|
return undefined;
|
|
432
390
|
case 'record':
|
|
433
391
|
return {};
|
|
434
|
-
case 'union':
|
|
392
|
+
case 'union':
|
|
393
|
+
case 'variant': {
|
|
435
394
|
// Pick the first variant and recurse. Picking the first option is a
|
|
436
395
|
// pragmatic default; consumers needing a specific branch can pass
|
|
437
396
|
// an override via the relevant test helper.
|
|
@@ -448,7 +407,7 @@ export const generate_valid_value = (field, field_schema) => {
|
|
|
448
407
|
const values = to_literal_values(field_schema);
|
|
449
408
|
return values.length > 0 ? values[0] : 'test_value';
|
|
450
409
|
}
|
|
451
|
-
case '
|
|
410
|
+
case 'one_of': {
|
|
452
411
|
const values = to_literal_values(field_schema);
|
|
453
412
|
return values.length > 0 ? values[0] : 'test';
|
|
454
413
|
}
|
|
@@ -469,14 +428,13 @@ export const generate_valid_value = (field, field_schema) => {
|
|
|
469
428
|
* Shared by the top-level body generators and `generate_valid_value`'s
|
|
470
429
|
* nested-object case, so a refined object validates the same way at any depth.
|
|
471
430
|
*
|
|
472
|
-
* @param object_schema - the object whose fields are generated:
|
|
473
|
-
*
|
|
431
|
+
* @param object_schema - the object whose fields are generated: an object
|
|
432
|
+
* schema, possibly wrapped
|
|
474
433
|
* @param schema - the schema the object must satisfy, refinements included
|
|
475
434
|
* (`object_schema` or a schema wrapping it)
|
|
476
|
-
* @returns the generated object and its last `
|
|
435
|
+
* @returns the generated object and its last `parse` result — the caller
|
|
477
436
|
* decides whether a failure throws
|
|
478
|
-
* @throws Error when `object_schema` is no object schema, or
|
|
479
|
-
* of neither library
|
|
437
|
+
* @throws Error when `object_schema` is no object schema, or no schema
|
|
480
438
|
*/
|
|
481
439
|
export const generate_valid_object = (object_schema, schema) => generate_valid_object_from_view(to_object_schema_view(object_schema, 'generate_valid_object: the object schema'), schema);
|
|
482
440
|
const generate_valid_object_from_view = (view, schema) => {
|
|
@@ -504,13 +462,13 @@ const is_optional_field = (field) => !field.required && !field.has_default;
|
|
|
504
462
|
* @returns the object and its last parse
|
|
505
463
|
*/
|
|
506
464
|
const fill_optional_fields = (schema, start, candidates) => {
|
|
507
|
-
let result =
|
|
465
|
+
let result = parse(schema, start);
|
|
508
466
|
if (result.ok)
|
|
509
467
|
return { value: start, result };
|
|
510
468
|
// each optional field alone, so one the refinement doesn't need stays out
|
|
511
469
|
for (const [name, field_value] of candidates) {
|
|
512
470
|
const value = { ...start, [name]: field_value };
|
|
513
|
-
const single_result =
|
|
471
|
+
const single_result = parse(schema, value);
|
|
514
472
|
if (single_result.ok)
|
|
515
473
|
return { value, result: single_result };
|
|
516
474
|
}
|
|
@@ -518,7 +476,7 @@ const fill_optional_fields = (schema, start, candidates) => {
|
|
|
518
476
|
const value = { ...start };
|
|
519
477
|
for (const [name, field_value] of candidates) {
|
|
520
478
|
value[name] = field_value;
|
|
521
|
-
result =
|
|
479
|
+
result = parse(schema, value);
|
|
522
480
|
if (result.ok)
|
|
523
481
|
break;
|
|
524
482
|
}
|
|
@@ -534,15 +492,14 @@ const fill_optional_fields = (schema, start, candidates) => {
|
|
|
534
492
|
* replaces `base`'s optional fields, refilled the same way around it (an
|
|
535
493
|
* exactly-one-of rule: adding `slug` means dropping `id`).
|
|
536
494
|
*
|
|
537
|
-
* @param object_schema - the object schema `base` is an instance of,
|
|
538
|
-
*
|
|
495
|
+
* @param object_schema - the object schema `base` is an instance of,
|
|
496
|
+
* possibly wrapped
|
|
539
497
|
* @param schema - the schema the object must satisfy, refinements included
|
|
540
498
|
* @param base - a valid object, the generated or seeded base
|
|
541
499
|
* @param field - the field the object must carry
|
|
542
500
|
* @returns the object, or `null` when no object the generator can build
|
|
543
501
|
* carries the field and passes `schema`
|
|
544
|
-
* @throws Error when `object_schema` is no object schema, or
|
|
545
|
-
* of neither library
|
|
502
|
+
* @throws Error when `object_schema` is no object schema, or no schema
|
|
546
503
|
*/
|
|
547
504
|
export const generate_valid_object_with_field = (object_schema, schema, base, field) => {
|
|
548
505
|
if (Object.hasOwn(base, field.name))
|
|
@@ -575,22 +532,60 @@ export const generate_valid_object_with_field = (object_schema, schema, base, fi
|
|
|
575
532
|
return replaced.result.ok ? replaced.value : null;
|
|
576
533
|
};
|
|
577
534
|
const NIL_UUID = '00000000-0000-0000-0000-000000000000';
|
|
535
|
+
/**
|
|
536
|
+
* The bounds of every `min_value` and `max_value` a schema holds, in every
|
|
537
|
+
* stage of every `pipe` and through its wrappers — including the stages after
|
|
538
|
+
* a `transform`, which its JSON Schema can't say: a URL string parsed into a
|
|
539
|
+
* number is bounded only there (`db_routes`' `query_int`).
|
|
540
|
+
*/
|
|
541
|
+
const to_numeric_bounds = (schema) => {
|
|
542
|
+
const bounds = { min: [], max: [] };
|
|
543
|
+
const seen = new Set();
|
|
544
|
+
const pending = [schema];
|
|
545
|
+
while (pending.length > 0) {
|
|
546
|
+
const s = pending.pop();
|
|
547
|
+
if (seen.has(s))
|
|
548
|
+
continue;
|
|
549
|
+
seen.add(s);
|
|
550
|
+
if (s.kind === 'optional' ||
|
|
551
|
+
s.kind === 'nullable' ||
|
|
552
|
+
s.kind === 'with_default' ||
|
|
553
|
+
s.kind === 'with_default_fn') {
|
|
554
|
+
pending.push(s.def.schema);
|
|
555
|
+
}
|
|
556
|
+
else if (s.kind === 'pipe') {
|
|
557
|
+
pending.push(...s.def);
|
|
558
|
+
}
|
|
559
|
+
else if (s.kind === 'lazy') {
|
|
560
|
+
pending.push(s.def());
|
|
561
|
+
}
|
|
562
|
+
else if (s.kind === 'min_value' && typeof s.def === 'number') {
|
|
563
|
+
bounds.min.push(s.def);
|
|
564
|
+
}
|
|
565
|
+
else if (s.kind === 'max_value' && typeof s.def === 'number') {
|
|
566
|
+
bounds.max.push(s.def);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
return bounds;
|
|
570
|
+
};
|
|
578
571
|
/**
|
|
579
572
|
* A string a URL-sourced field accepts — a route param or a query value, which
|
|
580
573
|
* arrive as strings whatever the schema parses them into. The nil UUID for a
|
|
581
574
|
* UUID field; else the first the field accepts of `test_value`, the generated
|
|
582
575
|
* valid value written as a string, `1`, `0`, `true` and `false`, the field's
|
|
583
|
-
* JSON Schema `default` or lower bound written as a string
|
|
584
|
-
*
|
|
585
|
-
*
|
|
576
|
+
* JSON Schema `default` or lower bound written as a string, each
|
|
577
|
+
* `min_value` and `max_value` bound anywhere in the schema written as an
|
|
578
|
+
* integer (a string parsed into an integer whose range excludes the small
|
|
579
|
+
* candidates, `to_numeric_bounds`), and a string synthesized from the field's
|
|
580
|
+
* constraints.
|
|
586
581
|
*
|
|
587
|
-
* @param field - the field's info, from `to_object_schema_view`
|
|
588
|
-
* @param field_schema - the field's schema
|
|
582
|
+
* @param field - the field's info, from `to_object_schema_view`
|
|
583
|
+
* @param field_schema - the field's schema
|
|
589
584
|
* @returns the string, or `null` when no candidate passes
|
|
590
585
|
*/
|
|
591
586
|
export const generate_valid_string_param = (field, field_schema) => {
|
|
592
587
|
const candidates = [];
|
|
593
|
-
if (
|
|
588
|
+
if (detect_format(field_schema) === 'uuid') {
|
|
594
589
|
candidates.push(NIL_UUID);
|
|
595
590
|
}
|
|
596
591
|
candidates.push('test_value');
|
|
@@ -609,9 +604,11 @@ export const generate_valid_string_param = (field, field_schema) => {
|
|
|
609
604
|
}
|
|
610
605
|
if (typeof json.minimum === 'number')
|
|
611
606
|
candidates.push(String(Math.ceil(json.minimum)));
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
607
|
+
const bounds = to_numeric_bounds(field_schema);
|
|
608
|
+
for (const min of bounds.min)
|
|
609
|
+
candidates.push(String(Math.ceil(min)));
|
|
610
|
+
for (const max of bounds.max)
|
|
611
|
+
candidates.push(String(Math.floor(max)));
|
|
615
612
|
candidates.push(generate_valid_string(field_schema));
|
|
616
613
|
return candidates.find((c) => accepts(field_schema, c)) ?? null;
|
|
617
614
|
};
|
|
@@ -620,9 +617,9 @@ export const generate_valid_string_param = (field, field_schema) => {
|
|
|
620
617
|
* (`is_void_schema`, `is_null_schema`), which takes no body, else its object
|
|
621
618
|
* view (`to_object_schema_view`).
|
|
622
619
|
*
|
|
623
|
-
* @param input_schema - a route's or action's input schema
|
|
620
|
+
* @param input_schema - a route's or action's input schema
|
|
624
621
|
* @param label - names the input in the error
|
|
625
|
-
* @throws Error naming `label` when the input is
|
|
622
|
+
* @throws Error naming `label` when the input is no schema, or is
|
|
626
623
|
* neither void, null, nor an object schema — no body can be generated for
|
|
627
624
|
* it, and no body is not the same as one the generator can't build
|
|
628
625
|
*/
|
|
@@ -632,7 +629,7 @@ export const to_body_input = (input_schema, label) => {
|
|
|
632
629
|
const view = to_object_view(input_schema, label);
|
|
633
630
|
if (!view) {
|
|
634
631
|
if (to_base_type(input_schema) === 'void') {
|
|
635
|
-
throw new Error(`${label} is a void under wrappers, which dispatch does not read as void (\`is_void_schema\` is exact): absent params reach it as \`{}\`, which it refuses — declare the input as a bare \`
|
|
632
|
+
throw new Error(`${label} is a void under wrappers, which dispatch does not read as void (\`is_void_schema\` is exact): absent params reach it as \`{}\`, which it refuses — declare the input as a bare \`s.void\``);
|
|
636
633
|
}
|
|
637
634
|
throw new Error(`${label} is no object, void or null schema (its innermost type is '${to_base_type(input_schema)}'), so no body can be generated for it`);
|
|
638
635
|
}
|
|
@@ -681,9 +678,9 @@ export const to_route_content_type = (route) => route.raw_body ? 'application/oc
|
|
|
681
678
|
* (`''`, `.`, `..`) is refused by name.
|
|
682
679
|
*
|
|
683
680
|
* @param path - the route's path template
|
|
684
|
-
* @param params_schema - the route's params schema,
|
|
681
|
+
* @param params_schema - the route's params schema, an object schema
|
|
685
682
|
* @param param_values - the route's supplied param values by name, its entry of `RouteParamValues`
|
|
686
|
-
* @throws Error when `params_schema` is no object schema, or
|
|
683
|
+
* @throws Error when `params_schema` is no object schema, or no schema;
|
|
687
684
|
* when `param_values` names no param of the path; when a supplied value is
|
|
688
685
|
* `''`, `.` or `..`, or holds a lone surrogate, which can't be encoded; and
|
|
689
686
|
* when a `{re}` param's value is one its pattern refuses, naming the route
|
|
@@ -700,8 +697,6 @@ export const resolve_valid_path = (path, params_schema, param_values) => {
|
|
|
700
697
|
return fallback;
|
|
701
698
|
if (accepts(field_schema, `test_${name}`))
|
|
702
699
|
return fallback;
|
|
703
|
-
if (to_base_type(field_schema) === 'uuid')
|
|
704
|
-
return NIL_UUID;
|
|
705
700
|
const format = detect_format(field_schema);
|
|
706
701
|
if (format === 'uuid')
|
|
707
702
|
return NIL_UUID;
|
|
@@ -750,10 +745,10 @@ export const resolve_valid_path = (path, params_schema, param_values) => {
|
|
|
750
745
|
/**
|
|
751
746
|
* Generate a valid request body for a route's or action's input schema.
|
|
752
747
|
*
|
|
753
|
-
* @param input_schema - the input schema
|
|
748
|
+
* @param input_schema - the input schema
|
|
754
749
|
* @returns a generated body that passes the schema, or `undefined` for a void
|
|
755
750
|
* or null input, which takes no body
|
|
756
|
-
* @throws Error if the input is
|
|
751
|
+
* @throws Error if the input is no schema, or is neither void, null,
|
|
757
752
|
* nor an object schema, or if the generated body fails the input — catching
|
|
758
753
|
* broken `generate_valid_value` logic early with the parse's issues instead
|
|
759
754
|
* of a confusing 400 in downstream tests
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse_round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/sse_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"sse_round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/sse_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAoB7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,oBAAoB,CAAC;AAGrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAGjE,OAAO,EAEN,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpE,OAAO,EAIN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAO1B,gDAAgD;AAChD,MAAM,WAAW,gBAAgB;IAChC,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,OAAO,EAAE,CAAC,GAAG,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,WAAW,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E;;;OAGG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC/B;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,8CAA8C;AAC9C,MAAM,WAAW,mBAAmB;IACnC,4CAA4C;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,qDAAqD;IACrD,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,iDAAiD;IACjD,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,gHAAgH;IAChH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAChC;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAChD;;;;;;;;;;;;OAYG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC,8BAA8B;IAC9B,MAAM,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;CAChC;AAmDD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GAAI,SAAS,mBAAmB,KAAG,IAkIvE,CAAC"}
|
|
@@ -14,6 +14,7 @@ import './assert_dev_env.js';
|
|
|
14
14
|
* @module
|
|
15
15
|
*/
|
|
16
16
|
import { describe, test, beforeAll, afterAll, assert } from 'vitest';
|
|
17
|
+
import { parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
17
18
|
import { SSE_CONNECTED_COMMENT } from '../realtime/sse_constants.js';
|
|
18
19
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
19
20
|
import { create_audit_emitter } from '../auth/audit_emitter.js';
|
|
@@ -25,7 +26,6 @@ import { run_migrations } from '../db/migrate.js';
|
|
|
25
26
|
import { AUTH_MIGRATION_NS } from '../auth/migrations.js';
|
|
26
27
|
import { account_session_revoke_all_action_spec } from '../auth/account_action_specs.js';
|
|
27
28
|
import { create_sse_frame_reader } from './transports/sse_frame_reader.js';
|
|
28
|
-
import { parse_any } from '../schema_issues.js';
|
|
29
29
|
/**
|
|
30
30
|
* Validate a decoded SSE `data:` frame as a JSON-RPC-style `{method, params}` payload.
|
|
31
31
|
*/
|
|
@@ -47,7 +47,7 @@ const parse_and_validate_sse_payload = (frame, event_specs, route_path) => {
|
|
|
47
47
|
if (event_specs) {
|
|
48
48
|
const spec = event_specs.find((s) => s.method === notification.method);
|
|
49
49
|
assert.ok(spec, `${route_path}: no EventSpec declared for method '${notification.method}' (declared: ${event_specs.map((s) => s.method).join(', ')})`);
|
|
50
|
-
const result =
|
|
50
|
+
const result = parse(spec.params, notification.params);
|
|
51
51
|
if (!result.ok) {
|
|
52
52
|
throw new Error(`${route_path}: params mismatch for method '${notification.method}': ${JSON.stringify(result.issues)}`);
|
|
53
53
|
}
|
|
@@ -203,7 +203,7 @@ export declare const assert_no_unexpected_public_mutations: (surface: AppSurface
|
|
|
203
203
|
* Query-string-driven filtering (audit log, list endpoints) should use params schemas
|
|
204
204
|
* or query string parsing, not input schemas.
|
|
205
205
|
*
|
|
206
|
-
* Note: RPC endpoints (`create_rpc_endpoint`) use `input:
|
|
206
|
+
* Note: RPC endpoints (`create_rpc_endpoint`) use `input: literal(null)` on their
|
|
207
207
|
* route specs — the dispatcher handles body/query parsing internally. Real input
|
|
208
208
|
* schemas live in `rpc_endpoints` surface, not on routes; see
|
|
209
209
|
* `assert_rpc_ws_surface_invariants` for the parallel checks over RPC/WS
|
|
@@ -462,7 +462,7 @@ export const assert_no_unexpected_public_mutations = (surface, allowlist = []) =
|
|
|
462
462
|
* Query-string-driven filtering (audit log, list endpoints) should use params schemas
|
|
463
463
|
* or query string parsing, not input schemas.
|
|
464
464
|
*
|
|
465
|
-
* Note: RPC endpoints (`create_rpc_endpoint`) use `input:
|
|
465
|
+
* Note: RPC endpoints (`create_rpc_endpoint`) use `input: literal(null)` on their
|
|
466
466
|
* route specs — the dispatcher handles body/query parsing internally. Real input
|
|
467
467
|
* schemas live in `rpc_endpoints` surface, not on routes; see
|
|
468
468
|
* `assert_rpc_ws_surface_invariants` for the parallel checks over RPC/WS
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* <script lang="ts">
|
|
29
29
|
* const form_state = new FormState<'username'>();
|
|
30
30
|
* let username = $state.raw('');
|
|
31
|
-
* const username_valid = $derived(Username
|
|
31
|
+
* const username_valid = $derived(is(Username, username));
|
|
32
32
|
* const can_submit = $derived(username.trim() && username_valid);
|
|
33
33
|
*
|
|
34
34
|
* const handle_submit = async () => {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* <script lang="ts">
|
|
29
29
|
* const form_state = new FormState<'username'>();
|
|
30
30
|
* let username = $state.raw('');
|
|
31
|
-
* const username_valid = $derived(Username
|
|
31
|
+
* const username_valid = $derived(is(Username, username));
|
|
32
32
|
* const can_submit = $derived(username.trim() && username_valid);
|
|
33
33
|
*
|
|
34
34
|
* const handle_submit = async () => {
|