@fuzdev/fuz_app 0.168.1 → 0.170.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 +17 -19
- package/dist/actions/action_codegen.d.ts +32 -23
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +101 -80
- 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 +18 -18
- package/dist/actions/action_rpc.d.ts +1 -1
- package/dist/actions/action_rpc.js +1 -1
- 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/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/auth/CLAUDE.md +11 -11
- package/dist/auth/account_action_specs.d.ts +11 -11
- package/dist/auth/account_action_specs.js +1 -1
- package/dist/auth/account_route_schema.d.ts +18 -18
- package/dist/auth/account_route_schema.js +1 -1
- package/dist/auth/account_routes.js +1 -1
- package/dist/auth/account_schema.d.ts +38 -40
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +7 -8
- package/dist/auth/actor_lookup_action_specs.d.ts +7 -7
- package/dist/auth/actor_lookup_action_specs.js +1 -1
- package/dist/auth/actor_search_action_specs.d.ts +6 -6
- package/dist/auth/actor_search_action_specs.js +1 -1
- package/dist/auth/admin_action_specs.d.ts +166 -166
- package/dist/auth/admin_action_specs.js +1 -1
- package/dist/auth/app_settings_schema.d.ts +3 -3
- package/dist/auth/app_settings_schema.d.ts.map +1 -1
- package/dist/auth/app_settings_schema.js +1 -1
- 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_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_route_schema.js +1 -1
- package/dist/auth/audit_log_schema.d.ts +69 -70
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +2 -2
- package/dist/auth/auth_ddl.d.ts +1 -1
- package/dist/auth/auth_ddl.js +1 -1
- package/dist/auth/bootstrap_route_schema.d.ts +4 -4
- package/dist/auth/bootstrap_route_schema.js +1 -1
- package/dist/auth/cell_action_specs.d.ts +466 -466
- package/dist/auth/cell_action_specs.js +1 -1
- package/dist/auth/cell_actions.d.ts +2 -2
- package/dist/auth/cell_actions.js +5 -5
- package/dist/auth/cell_audit_action_specs.d.ts +14 -14
- package/dist/auth/cell_audit_action_specs.js +1 -1
- package/dist/auth/cell_audit_metadata.d.ts +8 -8
- package/dist/auth/cell_audit_metadata.js +1 -1
- package/dist/auth/cell_field_action_specs.d.ts +55 -55
- package/dist/auth/cell_field_action_specs.js +1 -1
- package/dist/auth/cell_field_audit_metadata.d.ts +4 -4
- package/dist/auth/cell_field_audit_metadata.js +1 -1
- package/dist/auth/cell_grant_action_specs.d.ts +61 -61
- package/dist/auth/cell_grant_action_specs.js +1 -1
- package/dist/auth/cell_grant_audit_metadata.d.ts +10 -10
- package/dist/auth/cell_grant_audit_metadata.js +1 -1
- package/dist/auth/cell_item_action_specs.d.ts +76 -76
- package/dist/auth/cell_item_action_specs.js +1 -1
- package/dist/auth/cell_item_audit_metadata.d.ts +5 -5
- package/dist/auth/cell_item_audit_metadata.js +1 -1
- package/dist/auth/invite_schema.d.ts +11 -11
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/invite_schema.js +1 -1
- package/dist/auth/name_schema.js +1 -1
- package/dist/auth/password.js +1 -1
- package/dist/auth/request_context.js +2 -2
- package/dist/auth/role_grant_offer_action_specs.d.ts +182 -182
- package/dist/auth/role_grant_offer_action_specs.js +1 -1
- 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 +107 -107
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +3 -4
- package/dist/auth/role_grant_offer_schema.d.ts +9 -9
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_schema.js +1 -1
- package/dist/auth/self_service_role_action_specs.d.ts +2 -2
- package/dist/auth/self_service_role_action_specs.js +1 -1
- package/dist/auth/self_service_role_actions.d.ts +1 -1
- package/dist/auth/self_service_role_actions.js +1 -1
- package/dist/auth/signup_route_schema.d.ts +2 -2
- package/dist/auth/signup_route_schema.js +1 -1
- package/dist/auth/token_scope.d.ts +8 -8
- package/dist/db/file_fact_url.d.ts +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 -32
- package/dist/http/auth_shape.d.ts +17 -52
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +19 -61
- package/dist/http/db_routes.d.ts +1 -1
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +1 -1
- package/dist/http/error_schemas.d.ts +36 -36
- package/dist/http/jsonrpc.d.ts +11 -11
- 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_spec.d.ts +33 -36
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +21 -22
- package/dist/http/schema_helpers.d.ts +75 -67
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +54 -76
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +6 -8
- package/dist/primitive_schemas.d.ts +162 -112
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +129 -161
- 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 +41 -146
- package/dist/schema_issues.d.ts.map +1 -1
- package/dist/schema_issues.js +39 -322
- 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/server/serve_fact_route.js +1 -1
- package/dist/server/surface_route.js +1 -1
- package/dist/testing/CLAUDE.md +23 -25
- 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 +29 -42
- 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_case.d.ts +96 -114
- package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_case.js +0 -256
- 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/fact_serving.js +1 -1
- package/dist/testing/cross_backend/identity_parity.js +9 -9
- 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 +26 -4
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +7 -8
- package/dist/testing/cross_backend/sse_round_trip.js +2 -2
- package/dist/testing/cross_backend/testing_origin_check.d.ts +12 -12
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +608 -201
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +46 -55
- 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_outbound_overflow.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_outbound_overflow.js +35 -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 +3 -3
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +1 -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 -11
- 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 +144 -151
- package/dist/testing/schema_introspect.d.ts +438 -78
- package/dist/testing/schema_introspect.d.ts.map +1 -1
- package/dist/testing/schema_introspect.js +26 -26
- 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/testing/transports/bootstrap.d.ts +1 -1
- package/dist/testing/transports/bootstrap.d.ts.map +1 -1
- package/dist/testing/transports/bootstrap.js +1 -1
- package/dist/ui/BootstrapForm.svelte +1 -2
- package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
- package/dist/ui/SignupForm.svelte +1 -2
- package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.d.ts +5 -5
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_invites_state.svelte.d.ts +1 -1
- package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
- package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/form_state.svelte.d.ts +1 -1
- package/dist/ui/form_state.svelte.js +1 -1
- package/dist/ui/role_grant_offers_state.svelte.d.ts +1 -1
- package/package.json +7 -9
- package/dist/primitive_schemas_fuz.d.ts +0 -178
- package/dist/primitive_schemas_fuz.d.ts.map +0 -1
- package/dist/primitive_schemas_fuz.js +0 -149
- package/dist/zod.d.ts +0 -101
- package/dist/zod.d.ts.map +0 -1
- package/dist/zod.js +0 -195
package/dist/schema_meta.d.ts
CHANGED
|
@@ -1,35 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* fuz_app's `@fuzdev/fuz_schema` metadata conventions.
|
|
3
3
|
*
|
|
4
|
-
* Cross-cutting metadata
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* its schema is. It also adds JSON Schema's `readOnly` annotation, which
|
|
12
|
-
* `to_json_schema` writes onto the node.
|
|
4
|
+
* Cross-cutting metadata read by auth and action input schemas, surface
|
|
5
|
+
* generation, and test helpers. `sensitivity.ts` adds `sensitivity` to
|
|
6
|
+
* fuz_schema's `SchemaMeta` (read by `find_schema_sensitivity`); this module
|
|
7
|
+
* adds `invalid_reason` and `empty_input_handler_guarded` — the declared
|
|
8
|
+
* refusal reason of an action input's field and its handler-guarded marker —
|
|
9
|
+
* and JSON Schema's `readOnly` annotation, which `to_json_schema` writes onto
|
|
10
|
+
* the node.
|
|
13
11
|
*
|
|
14
12
|
* @module
|
|
15
13
|
*/
|
|
16
|
-
import type {
|
|
17
|
-
import type { Sensitivity } from './sensitivity.js';
|
|
18
|
-
import { type AnyIssue, type ValidationSchema } from './schema_issues.js';
|
|
14
|
+
import type { AnySchema, SchemaIssue } from '@fuzdev/fuz_schema/schema.ts';
|
|
19
15
|
declare module '@fuzdev/fuz_schema/meta.ts' {
|
|
20
16
|
interface SchemaMeta {
|
|
21
17
|
/**
|
|
22
|
-
* The `error.data.reason` an action input refuses this field with
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
18
|
+
* The `error.data.reason` an action input refuses this field with. On a
|
|
19
|
+
* field of an action's **input** schema, every `invalid_params` whose
|
|
20
|
+
* first issue lands on the field — missing, wrong type, `null`, out of
|
|
21
|
+
* range, malformed, or a fault anywhere inside it — carries this reason,
|
|
22
|
+
* where an undeclared field's refusal carries none. The message stays the
|
|
23
|
+
* generic `invalid params`. A body with faults on several fields answers
|
|
24
|
+
* the first issue's reason, which a twin checking in another order need
|
|
25
|
+
* not match, so the reason is defined for a single-fault body only —
|
|
26
|
+
* except that an issue on the input itself (an unknown key) anywhere among
|
|
27
|
+
* the issues means no reason, as the Rust twin refuses unknown keys first.
|
|
28
|
+
* Declared reasons are named `<field>_invalid`.
|
|
29
|
+
*
|
|
30
|
+
* The declaration is the one source of the reason: the dispatcher reads
|
|
31
|
+
* it (`perform_action`), the adversarial suites expect it, and the Rust
|
|
32
|
+
* twin owes the same reason on every refusal of the field. Read through
|
|
33
|
+
* the field's layers (`get_schema_meta`), the outermost declaration
|
|
34
|
+
* winning; a declaration on a nested field overrides its parent's for a
|
|
35
|
+
* fault inside it. See `resolve_issues_invalid_reason`.
|
|
26
36
|
*/
|
|
27
37
|
invalid_reason?: string;
|
|
28
38
|
/**
|
|
29
|
-
* Set on an action's input schema
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
39
|
+
* Set on an action's **input** schema that accepts `{}` by design while
|
|
40
|
+
* its handler refuses `{}` with a declared reason — an input taking one
|
|
41
|
+
* of several optional selectors, where the handler names the missing or
|
|
42
|
+
* conflicting one (a schema-level check would answer a reason-less
|
|
43
|
+
* `invalid_params` first). A call with no input is never valid for such
|
|
44
|
+
* an action, so the typed surface keeps its input required
|
|
45
|
+
* (`action_input_is_optional`), and the input-shape invariant ("an input
|
|
46
|
+
* accepting `{}` accepts `undefined` too") exempts it. Read from the
|
|
47
|
+
* input schema itself (`get_meta`), so a wrapper around it drops it.
|
|
33
48
|
*/
|
|
34
49
|
empty_input_handler_guarded?: boolean;
|
|
35
50
|
/**
|
|
@@ -40,108 +55,21 @@ declare module '@fuzdev/fuz_schema/meta.ts' {
|
|
|
40
55
|
readOnly?: boolean;
|
|
41
56
|
}
|
|
42
57
|
}
|
|
43
|
-
/** Zod `.meta()` shape for fuz_app schema metadata conventions. */
|
|
44
|
-
export interface SchemaFieldMeta {
|
|
45
|
-
description?: string;
|
|
46
|
-
/**
|
|
47
|
-
* Sensitivity level (`Sensitivity`): `'secret'` masks the value,
|
|
48
|
-
* `'personal'` only keeps it out of URLs. Read through every wrapping
|
|
49
|
-
* layer (`schema_sensitivity`), so `.meta({sensitivity: 'secret'}).optional()`
|
|
50
|
-
* masks too.
|
|
51
|
-
*/
|
|
52
|
-
sensitivity?: Sensitivity;
|
|
53
|
-
/**
|
|
54
|
-
* Set on an action's **input** schema that accepts `{}` by design while
|
|
55
|
-
* its handler refuses `{}` with a declared reason — an input taking one of
|
|
56
|
-
* several optional selectors, where the handler names the missing or
|
|
57
|
-
* conflicting one (a schema-level refine would answer a reason-less
|
|
58
|
-
* `invalid_params` first). A call with no input is never valid for such an
|
|
59
|
-
* action, so the typed surface keeps its input required
|
|
60
|
-
* (`action_input_is_optional`), and the input-shape invariant ("an input
|
|
61
|
-
* accepting `{}` accepts `undefined` too") exempts it. Read from the input
|
|
62
|
-
* schema itself, so a wrapper (`.optional()`, `.extend()`) drops it.
|
|
63
|
-
*/
|
|
64
|
-
empty_input_handler_guarded?: boolean;
|
|
65
|
-
/**
|
|
66
|
-
* The `error.data.reason` an action input refuses this field with. On a
|
|
67
|
-
* field of an action's **input** schema, every `invalid_params` whose first
|
|
68
|
-
* Zod issue lands on the field — missing, wrong type, `null`, out of range,
|
|
69
|
-
* malformed, or a fault anywhere inside it — carries this reason, where an
|
|
70
|
-
* undeclared field's refusal carries none. The message stays the generic
|
|
71
|
-
* `invalid params`. A body with faults on several fields answers the first
|
|
72
|
-
* issue's reason in Zod's order, which a twin checking in another order
|
|
73
|
-
* need not match, so the reason is defined for a single-fault body only —
|
|
74
|
-
* except that an issue on the input itself (an unknown key) anywhere among
|
|
75
|
-
* the issues means no reason, as the Rust twin refuses unknown keys first.
|
|
76
|
-
* Declared reasons are named `<field>_invalid`.
|
|
77
|
-
*
|
|
78
|
-
* The declaration is the one source of the reason: the dispatcher reads it
|
|
79
|
-
* (`perform_action`), the adversarial suites expect it, and the Rust twin
|
|
80
|
-
* owes the same reason on every refusal of the field. Read through the
|
|
81
|
-
* field's optional, nullable, default, prefault, transform and pipe layers
|
|
82
|
-
* (not `.readonly()`, `.catch()` or `z.lazy()`), so it may sit on any of
|
|
83
|
-
* them; a declaration on a nested field overrides its parent's for a fault
|
|
84
|
-
* inside it, and an object-level refine whose issue names the field takes
|
|
85
|
-
* its reason too. See `resolve_issues_invalid_reason`.
|
|
86
|
-
*/
|
|
87
|
-
invalid_reason?: string;
|
|
88
|
-
}
|
|
89
58
|
/**
|
|
90
|
-
* Whether `schema` carries `empty_input_handler_guarded: true` in its
|
|
91
|
-
*
|
|
92
|
-
* `meta` (`get_meta`), read from the schema itself in both.
|
|
59
|
+
* Whether `schema` carries `empty_input_handler_guarded: true` in its own
|
|
60
|
+
* `meta` (`get_meta`).
|
|
93
61
|
*
|
|
94
|
-
* @param schema - an action's input schema
|
|
62
|
+
* @param schema - an action's input schema
|
|
95
63
|
* @returns whether its handler refuses the `{}` the schema admits
|
|
96
|
-
* @throws Error when `schema` is
|
|
97
|
-
*/
|
|
98
|
-
export declare const is_empty_input_handler_guarded: (schema: ValidationSchema) => boolean;
|
|
99
|
-
/**
|
|
100
|
-
* A `SchemaFieldMeta` key's value as a schema declares it, read through its
|
|
101
|
-
* optional, nullable, default, prefault, transform and pipe layers — Zod
|
|
102
|
-
* keeps `.meta()` on the instance it was set on, so a wrapper added after it
|
|
103
|
-
* carries none — the outermost declaration winning.
|
|
104
|
-
*
|
|
105
|
-
* @param schema - a field schema, possibly wrapped
|
|
106
|
-
* @param key - the metadata key to read
|
|
107
|
-
* @returns the declared value, or `undefined` when no layer declares one
|
|
108
|
-
*/
|
|
109
|
-
export declare const schema_meta_value: <TKey extends keyof SchemaFieldMeta>(schema: z.ZodType, key: TKey) => SchemaFieldMeta[TKey] | undefined;
|
|
110
|
-
/**
|
|
111
|
-
* The `invalid_reason` a schema declares, read through its wrappers, the
|
|
112
|
-
* outermost declaration winning.
|
|
113
|
-
*
|
|
114
|
-
* @param schema - a field schema, possibly wrapped
|
|
115
|
-
* @returns the declared reason, or `undefined` when no layer declares one
|
|
116
|
-
*/
|
|
117
|
-
export declare const schema_invalid_reason: (schema: z.ZodType) => string | undefined;
|
|
118
|
-
/**
|
|
119
|
-
* The `sensitivity` a schema declares anywhere among its wrapping layers, so
|
|
120
|
-
* a secret stays masked however the field is wrapped. Fail-safe where
|
|
121
|
-
* `schema_meta_value` reads one chain: the walk follows the `innerType` of
|
|
122
|
-
* every wrapper that has one (optional, nullable, default, prefault,
|
|
123
|
-
* nonoptional, catch, readonly, promise), both sides of a pipe (so
|
|
124
|
-
* `.transform()`, `z.preprocess()` and `.pipe(secret)` all reach the
|
|
125
|
-
* secret), a `z.lazy()` getter, every member of a union (the value is one of
|
|
126
|
-
* them), both sides of an intersection (it is both), and a template
|
|
127
|
-
* literal's schema parts (the value contains them), visiting each schema
|
|
128
|
-
* once, and answers the strongest level any layer reached declares —
|
|
129
|
-
* `'secret'` over `'personal'`. It stops at structural schemas — an object's fields and an
|
|
130
|
-
* array's element carry their own.
|
|
131
|
-
*
|
|
132
|
-
* @param schema - a field schema, possibly wrapped
|
|
133
|
-
* @returns the strongest level any reachable layer declares, else `undefined`
|
|
64
|
+
* @throws Error when `schema` is no schema
|
|
134
65
|
*/
|
|
135
|
-
export declare const
|
|
66
|
+
export declare const is_empty_input_handler_guarded: (schema: AnySchema) => boolean;
|
|
136
67
|
/**
|
|
137
68
|
* Whether an input schema carries a sensitive value at any depth — `'secret'`
|
|
138
|
-
* or `'personal'` on the schema itself or anywhere inside it
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* is read with `find_schema_meta` and `structural`: every layer, every step
|
|
143
|
-
* of a pipe, every option of a union or variant, a `lazy`'s schema, and the
|
|
144
|
-
* entries, rest, items and values of its objects, arrays and records.
|
|
69
|
+
* or `'personal'` on the schema itself or anywhere inside it, read with
|
|
70
|
+
* `find_schema_meta` and `structural`: every layer, every step of a pipe,
|
|
71
|
+
* every option of a union or variant, a `lazy`'s schema, and the entries,
|
|
72
|
+
* rest, items and values of its objects, arrays and records.
|
|
145
73
|
*
|
|
146
74
|
* What keeps a read's input off the URL: `FrontendHttpTransport` sends a
|
|
147
75
|
* read (`side_effects: false`) as a `GET` with the params in the query string,
|
|
@@ -149,28 +77,28 @@ export declare const schema_sensitivity: (schema: z.ZodType) => Sensitivity | un
|
|
|
149
77
|
* value — that call goes as a `POST` (the transport walks each spec's input
|
|
150
78
|
* once).
|
|
151
79
|
*
|
|
152
|
-
* @param schema - an action input schema
|
|
80
|
+
* @param schema - an action input schema
|
|
153
81
|
* @returns `true` when any value the schema admits may hold a sensitive field
|
|
154
|
-
* @throws Error when `schema` is
|
|
82
|
+
* @throws Error when `schema` is no schema, which would otherwise read as holding none
|
|
155
83
|
*/
|
|
156
|
-
export declare const schema_has_sensitive_field: (schema:
|
|
84
|
+
export declare const schema_has_sensitive_field: (schema: AnySchema) => boolean;
|
|
157
85
|
/**
|
|
158
86
|
* The `error.data.reason` an input validation failure at `path` carries: the
|
|
159
87
|
* `invalid_reason` of the deepest field along `path` that declares one.
|
|
160
88
|
*
|
|
161
|
-
* Walks object fields only,
|
|
162
|
-
*
|
|
89
|
+
* Walks object fields only, through their entries (`get_schema_entries`), each
|
|
90
|
+
* read with `get_schema_meta` through its wrappers: a segment that is not a
|
|
91
|
+
* key of an object schema (an array index, a union member's key, an unknown
|
|
163
92
|
* key) ends the walk, so a fault inside a declared field still resolves to
|
|
164
|
-
* that field's reason. An empty path — a whole-input fault such as an
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* entries (`get_schema_entries`) and reads the reason with `get_schema_meta`.
|
|
93
|
+
* that field's reason. An empty path — a whole-input fault such as an unknown
|
|
94
|
+
* key on the input object — resolves to none, as does a schema that is not an
|
|
95
|
+
* object.
|
|
168
96
|
*
|
|
169
|
-
* @param input_schema - an action's input schema
|
|
97
|
+
* @param input_schema - an action's input schema
|
|
170
98
|
* @param path - the failing issue's path
|
|
171
99
|
* @returns the declared reason, or `undefined`
|
|
172
100
|
*/
|
|
173
|
-
export declare const resolve_invalid_reason: (input_schema:
|
|
101
|
+
export declare const resolve_invalid_reason: (input_schema: AnySchema, path: ReadonlyArray<PropertyKey>) => string | undefined;
|
|
174
102
|
/**
|
|
175
103
|
* The `error.data.reason` a failed input parse answers: the declared reason
|
|
176
104
|
* of the first issue's field (`resolve_invalid_reason`), or none when any
|
|
@@ -180,16 +108,15 @@ export declare const resolve_invalid_reason: (input_schema: ValidationSchema, pa
|
|
|
180
108
|
* key gets the same answer from both spines whatever else its body gets
|
|
181
109
|
* wrong.
|
|
182
110
|
*
|
|
183
|
-
* A
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* and `input` is not read.
|
|
111
|
+
* A parse reports at most a hundred issues, so faults on the fields can crowd
|
|
112
|
+
* an unknown key out of them. For a strict `object` input, `input` is
|
|
113
|
+
* checked for a key the schema doesn't name, as the Rust twin checks it,
|
|
114
|
+
* whatever the issues hold.
|
|
188
115
|
*
|
|
189
|
-
* @param input_schema - an action's input schema
|
|
190
|
-
* @param issues - the failed parse's issues, in the
|
|
116
|
+
* @param input_schema - an action's input schema
|
|
117
|
+
* @param issues - the failed parse's issues, in the parse's order
|
|
191
118
|
* @param input - the value that was parsed
|
|
192
119
|
* @returns the declared reason, or `undefined`
|
|
193
120
|
*/
|
|
194
|
-
export declare const resolve_issues_invalid_reason: (input_schema:
|
|
121
|
+
export declare const resolve_issues_invalid_reason: (input_schema: AnySchema, issues: ReadonlyArray<SchemaIssue>, input: unknown) => string | undefined;
|
|
195
122
|
//# sourceMappingURL=schema_meta.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema_meta.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/schema_meta.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"schema_meta.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/schema_meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAW3E,OAAO,QAAQ,4BAA4B,CAAC;IAC3C,UAAU,UAAU;QACnB;;;;;;;;;;;;;;;;;;;WAmBG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB;;;;;;;;;;WAUG;QACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;QACtC;;;;WAIG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC;KACnB;CACD;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,GAAI,QAAQ,SAAS,KAAG,OAGlE,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,0BAA0B,GAAI,QAAQ,SAAS,KAAG,OAG9D,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,GAClC,cAAc,SAAS,EACvB,MAAM,aAAa,CAAC,WAAW,CAAC,KAC9B,MAAM,GAAG,SAYX,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,6BAA6B,GACzC,cAAc,SAAS,EACvB,QAAQ,aAAa,CAAC,WAAW,CAAC,EAClC,OAAO,OAAO,KACZ,MAAM,GAAG,SAKX,CAAC"}
|
package/dist/schema_meta.js
CHANGED
|
@@ -1,162 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* fuz_app's `@fuzdev/fuz_schema` metadata conventions.
|
|
3
3
|
*
|
|
4
|
-
* Cross-cutting metadata
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* its schema is. It also adds JSON Schema's `readOnly` annotation, which
|
|
12
|
-
* `to_json_schema` writes onto the node.
|
|
4
|
+
* Cross-cutting metadata read by auth and action input schemas, surface
|
|
5
|
+
* generation, and test helpers. `sensitivity.ts` adds `sensitivity` to
|
|
6
|
+
* fuz_schema's `SchemaMeta` (read by `find_schema_sensitivity`); this module
|
|
7
|
+
* adds `invalid_reason` and `empty_input_handler_guarded` — the declared
|
|
8
|
+
* refusal reason of an action input's field and its handler-guarded marker —
|
|
9
|
+
* and JSON Schema's `readOnly` annotation, which `to_json_schema` writes onto
|
|
10
|
+
* the node.
|
|
13
11
|
*
|
|
14
12
|
* @module
|
|
15
13
|
*/
|
|
16
|
-
import { is_schema } from '@fuzdev/fuz_schema/schema.ts';
|
|
17
14
|
import { find_schema_meta, get_schema_entries, get_schema_meta, unwrap_schema } from '@fuzdev/fuz_schema/introspect.ts';
|
|
18
15
|
import { get_meta } from '@fuzdev/fuz_schema/meta.ts';
|
|
19
|
-
import {
|
|
20
|
-
import { assert_zod_schema, issue_is_on_input } from './schema_issues.js';
|
|
16
|
+
import { assert_validation_schema, issue_is_on_input } from './schema_issues.js';
|
|
21
17
|
/**
|
|
22
|
-
* Whether `schema` carries `empty_input_handler_guarded: true` in its
|
|
23
|
-
*
|
|
24
|
-
* `meta` (`get_meta`), read from the schema itself in both.
|
|
18
|
+
* Whether `schema` carries `empty_input_handler_guarded: true` in its own
|
|
19
|
+
* `meta` (`get_meta`).
|
|
25
20
|
*
|
|
26
|
-
* @param schema - an action's input schema
|
|
21
|
+
* @param schema - an action's input schema
|
|
27
22
|
* @returns whether its handler refuses the `{}` the schema admits
|
|
28
|
-
* @throws Error when `schema` is
|
|
23
|
+
* @throws Error when `schema` is no schema
|
|
29
24
|
*/
|
|
30
25
|
export const is_empty_input_handler_guarded = (schema) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
assert_zod_schema(schema, 'is_empty_input_handler_guarded: the input');
|
|
34
|
-
return schema.meta()?.empty_input_handler_guarded === true;
|
|
26
|
+
assert_validation_schema(schema, 'is_empty_input_handler_guarded: the input');
|
|
27
|
+
return get_meta(schema)?.empty_input_handler_guarded === true;
|
|
35
28
|
};
|
|
36
|
-
/**
|
|
37
|
-
* A `SchemaFieldMeta` key's value as a schema declares it, read through its
|
|
38
|
-
* optional, nullable, default, prefault, transform and pipe layers — Zod
|
|
39
|
-
* keeps `.meta()` on the instance it was set on, so a wrapper added after it
|
|
40
|
-
* carries none — the outermost declaration winning.
|
|
41
|
-
*
|
|
42
|
-
* @param schema - a field schema, possibly wrapped
|
|
43
|
-
* @param key - the metadata key to read
|
|
44
|
-
* @returns the declared value, or `undefined` when no layer declares one
|
|
45
|
-
*/
|
|
46
|
-
export const schema_meta_value = (schema, key) => {
|
|
47
|
-
for (const layer of zod_get_schema_layers(schema)) {
|
|
48
|
-
const value = layer.meta()?.[key];
|
|
49
|
-
if (value !== undefined)
|
|
50
|
-
return value;
|
|
51
|
-
}
|
|
52
|
-
return undefined;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* The `invalid_reason` a schema declares, read through its wrappers, the
|
|
56
|
-
* outermost declaration winning.
|
|
57
|
-
*
|
|
58
|
-
* @param schema - a field schema, possibly wrapped
|
|
59
|
-
* @returns the declared reason, or `undefined` when no layer declares one
|
|
60
|
-
*/
|
|
61
|
-
export const schema_invalid_reason = (schema) => schema_meta_value(schema, 'invalid_reason');
|
|
62
|
-
/**
|
|
63
|
-
* The strongest `sensitivity` declared on any schema `walk_sensitivity`
|
|
64
|
-
* reaches from `schema` — `'secret'` over `'personal'` — visiting each schema
|
|
65
|
-
* once, so a recursive `z.lazy()` terminates. It follows the `innerType` of
|
|
66
|
-
* every wrapper that has one (optional, nullable, default, prefault,
|
|
67
|
-
* nonoptional, catch, readonly, promise), both sides of a pipe and an
|
|
68
|
-
* intersection, every member of a union (discriminated or not), a
|
|
69
|
-
* template literal's schema parts, and a `z.lazy()` getter; with
|
|
70
|
-
* `structural`, also an object's fields and catchall, an array's element, a
|
|
71
|
-
* tuple's items and rest, and a record's, map's or set's keys and values.
|
|
72
|
-
*/
|
|
73
|
-
const walk_sensitivity = (schema, structural) => {
|
|
74
|
-
let found;
|
|
75
|
-
const seen = new Set();
|
|
76
|
-
const pending = [schema];
|
|
77
|
-
const push = (sub) => {
|
|
78
|
-
if (sub && typeof sub === 'object' && 'def' in sub)
|
|
79
|
-
pending.push(sub);
|
|
80
|
-
};
|
|
81
|
-
while (pending.length > 0) {
|
|
82
|
-
const layer = pending.pop();
|
|
83
|
-
if (seen.has(layer))
|
|
84
|
-
continue;
|
|
85
|
-
seen.add(layer);
|
|
86
|
-
const sensitivity = layer.meta()?.sensitivity;
|
|
87
|
-
if (sensitivity === 'secret')
|
|
88
|
-
return 'secret';
|
|
89
|
-
if (sensitivity === 'personal')
|
|
90
|
-
found = 'personal';
|
|
91
|
-
const def = layer.def;
|
|
92
|
-
if (def.type === 'lazy') {
|
|
93
|
-
push(layer._zod.innerType);
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
if (def.type === 'union' && Array.isArray(def.options)) {
|
|
97
|
-
for (const option of def.options)
|
|
98
|
-
push(option);
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
// the value is one string containing each part, so its schema parts count
|
|
102
|
-
// like a wrapper's; `push` skips the literal parts (strings, numbers, …)
|
|
103
|
-
if (def.type === 'template_literal' && Array.isArray(def.parts)) {
|
|
104
|
-
for (const part of def.parts)
|
|
105
|
-
push(part);
|
|
106
|
-
}
|
|
107
|
-
for (const key of ['innerType', 'in', 'out', 'left', 'right'])
|
|
108
|
-
push(def[key]);
|
|
109
|
-
if (!structural)
|
|
110
|
-
continue;
|
|
111
|
-
if (def.type === 'object') {
|
|
112
|
-
for (const field of Object.values(layer.shape))
|
|
113
|
-
push(field);
|
|
114
|
-
push(def.catchall);
|
|
115
|
-
}
|
|
116
|
-
else if (def.type === 'array' || def.type === 'set') {
|
|
117
|
-
push(def.element);
|
|
118
|
-
push(def.valueType);
|
|
119
|
-
}
|
|
120
|
-
else if (def.type === 'tuple') {
|
|
121
|
-
if (Array.isArray(def.items))
|
|
122
|
-
for (const item of def.items)
|
|
123
|
-
push(item);
|
|
124
|
-
push(def.rest);
|
|
125
|
-
}
|
|
126
|
-
else if (def.type === 'record' || def.type === 'map') {
|
|
127
|
-
push(def.keyType);
|
|
128
|
-
push(def.valueType);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return found;
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* The `sensitivity` a schema declares anywhere among its wrapping layers, so
|
|
135
|
-
* a secret stays masked however the field is wrapped. Fail-safe where
|
|
136
|
-
* `schema_meta_value` reads one chain: the walk follows the `innerType` of
|
|
137
|
-
* every wrapper that has one (optional, nullable, default, prefault,
|
|
138
|
-
* nonoptional, catch, readonly, promise), both sides of a pipe (so
|
|
139
|
-
* `.transform()`, `z.preprocess()` and `.pipe(secret)` all reach the
|
|
140
|
-
* secret), a `z.lazy()` getter, every member of a union (the value is one of
|
|
141
|
-
* them), both sides of an intersection (it is both), and a template
|
|
142
|
-
* literal's schema parts (the value contains them), visiting each schema
|
|
143
|
-
* once, and answers the strongest level any layer reached declares —
|
|
144
|
-
* `'secret'` over `'personal'`. It stops at structural schemas — an object's fields and an
|
|
145
|
-
* array's element carry their own.
|
|
146
|
-
*
|
|
147
|
-
* @param schema - a field schema, possibly wrapped
|
|
148
|
-
* @returns the strongest level any reachable layer declares, else `undefined`
|
|
149
|
-
*/
|
|
150
|
-
export const schema_sensitivity = (schema) => walk_sensitivity(schema, false);
|
|
151
29
|
/**
|
|
152
30
|
* Whether an input schema carries a sensitive value at any depth — `'secret'`
|
|
153
|
-
* or `'personal'` on the schema itself or anywhere inside it
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* is read with `find_schema_meta` and `structural`: every layer, every step
|
|
158
|
-
* of a pipe, every option of a union or variant, a `lazy`'s schema, and the
|
|
159
|
-
* entries, rest, items and values of its objects, arrays and records.
|
|
31
|
+
* or `'personal'` on the schema itself or anywhere inside it, read with
|
|
32
|
+
* `find_schema_meta` and `structural`: every layer, every step of a pipe,
|
|
33
|
+
* every option of a union or variant, a `lazy`'s schema, and the entries,
|
|
34
|
+
* rest, items and values of its objects, arrays and records.
|
|
160
35
|
*
|
|
161
36
|
* What keeps a read's input off the URL: `FrontendHttpTransport` sends a
|
|
162
37
|
* read (`side_effects: false`) as a `GET` with the params in the query string,
|
|
@@ -164,52 +39,31 @@ export const schema_sensitivity = (schema) => walk_sensitivity(schema, false);
|
|
|
164
39
|
* value — that call goes as a `POST` (the transport walks each spec's input
|
|
165
40
|
* once).
|
|
166
41
|
*
|
|
167
|
-
* @param schema - an action input schema
|
|
42
|
+
* @param schema - an action input schema
|
|
168
43
|
* @returns `true` when any value the schema admits may hold a sensitive field
|
|
169
|
-
* @throws Error when `schema` is
|
|
44
|
+
* @throws Error when `schema` is no schema, which would otherwise read as holding none
|
|
170
45
|
*/
|
|
171
46
|
export const schema_has_sensitive_field = (schema) => {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
assert_zod_schema(schema, 'schema_has_sensitive_field: the input');
|
|
176
|
-
return walk_sensitivity(schema, true) !== undefined;
|
|
47
|
+
assert_validation_schema(schema, 'schema_has_sensitive_field: the input');
|
|
48
|
+
return find_schema_meta(schema, 'sensitivity', { structural: true }).length > 0;
|
|
177
49
|
};
|
|
178
50
|
/**
|
|
179
51
|
* The `error.data.reason` an input validation failure at `path` carries: the
|
|
180
52
|
* `invalid_reason` of the deepest field along `path` that declares one.
|
|
181
53
|
*
|
|
182
|
-
* Walks object fields only,
|
|
183
|
-
*
|
|
54
|
+
* Walks object fields only, through their entries (`get_schema_entries`), each
|
|
55
|
+
* read with `get_schema_meta` through its wrappers: a segment that is not a
|
|
56
|
+
* key of an object schema (an array index, a union member's key, an unknown
|
|
184
57
|
* key) ends the walk, so a fault inside a declared field still resolves to
|
|
185
|
-
* that field's reason. An empty path — a whole-input fault such as an
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* entries (`get_schema_entries`) and reads the reason with `get_schema_meta`.
|
|
58
|
+
* that field's reason. An empty path — a whole-input fault such as an unknown
|
|
59
|
+
* key on the input object — resolves to none, as does a schema that is not an
|
|
60
|
+
* object.
|
|
189
61
|
*
|
|
190
|
-
* @param input_schema - an action's input schema
|
|
62
|
+
* @param input_schema - an action's input schema
|
|
191
63
|
* @param path - the failing issue's path
|
|
192
64
|
* @returns the declared reason, or `undefined`
|
|
193
65
|
*/
|
|
194
66
|
export const resolve_invalid_reason = (input_schema, path) => {
|
|
195
|
-
if (is_schema(input_schema))
|
|
196
|
-
return resolve_schema_invalid_reason(input_schema, path);
|
|
197
|
-
let reason;
|
|
198
|
-
let schema = input_schema;
|
|
199
|
-
for (const segment of path) {
|
|
200
|
-
if (typeof segment !== 'string')
|
|
201
|
-
break;
|
|
202
|
-
const shape = zod_unwrap_to_object(schema)?.shape;
|
|
203
|
-
if (!shape || !Object.hasOwn(shape, segment))
|
|
204
|
-
break;
|
|
205
|
-
const field = shape[segment];
|
|
206
|
-
reason = schema_invalid_reason(field) ?? reason;
|
|
207
|
-
schema = field;
|
|
208
|
-
}
|
|
209
|
-
return reason;
|
|
210
|
-
};
|
|
211
|
-
// the fuz_schema walk of `resolve_invalid_reason`
|
|
212
|
-
const resolve_schema_invalid_reason = (input_schema, path) => {
|
|
213
67
|
let reason;
|
|
214
68
|
let schema = input_schema;
|
|
215
69
|
for (const segment of path) {
|
|
@@ -233,14 +87,13 @@ const resolve_schema_invalid_reason = (input_schema, path) => {
|
|
|
233
87
|
* key gets the same answer from both spines whatever else its body gets
|
|
234
88
|
* wrong.
|
|
235
89
|
*
|
|
236
|
-
* A
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
* and `input` is not read.
|
|
90
|
+
* A parse reports at most a hundred issues, so faults on the fields can crowd
|
|
91
|
+
* an unknown key out of them. For a strict `object` input, `input` is
|
|
92
|
+
* checked for a key the schema doesn't name, as the Rust twin checks it,
|
|
93
|
+
* whatever the issues hold.
|
|
241
94
|
*
|
|
242
|
-
* @param input_schema - an action's input schema
|
|
243
|
-
* @param issues - the failed parse's issues, in the
|
|
95
|
+
* @param input_schema - an action's input schema
|
|
96
|
+
* @param issues - the failed parse's issues, in the parse's order
|
|
244
97
|
* @param input - the value that was parsed
|
|
245
98
|
* @returns the declared reason, or `undefined`
|
|
246
99
|
*/
|
|
@@ -248,7 +101,7 @@ export const resolve_issues_invalid_reason = (input_schema, issues, input) => {
|
|
|
248
101
|
const first = issues[0];
|
|
249
102
|
if (!first || issues.some(issue_is_on_input))
|
|
250
103
|
return undefined;
|
|
251
|
-
if (
|
|
104
|
+
if (has_unknown_root_key(input_schema, input))
|
|
252
105
|
return undefined;
|
|
253
106
|
return resolve_invalid_reason(input_schema, first.path);
|
|
254
107
|
};
|
package/dist/sensitivity.d.ts
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Used by env schemas and action input schemas to control masking/redaction
|
|
5
5
|
* in startup logs, surface explorers, and test output, and to keep values
|
|
6
|
-
* out of URLs. A
|
|
7
|
-
* (
|
|
8
|
-
* schema with `meta(schema, {sensitivity})`, the key this module adds to
|
|
6
|
+
* out of URLs. A `@fuzdev/fuz_schema` schema declares it with
|
|
7
|
+
* `meta(schema, {sensitivity})`, the key this module adds to
|
|
9
8
|
* fuz_schema's `SchemaMeta` by declaration merging, read by
|
|
10
9
|
* `find_schema_sensitivity`. `server/env.ts` and `env/env_schemas.ts` import
|
|
11
10
|
* this module for the declaration, so a consumer of either has the key; a
|
|
@@ -39,8 +38,7 @@ declare module '@fuzdev/fuz_schema/meta.ts' {
|
|
|
39
38
|
}
|
|
40
39
|
/**
|
|
41
40
|
* The strongest `sensitivity` declared on any schema a `@fuzdev/fuz_schema`
|
|
42
|
-
* field reaches — `'secret'` over `'personal'
|
|
43
|
-
* `schema_sensitivity`. Fail-safe: `find_schema_meta` reads every wrapper,
|
|
41
|
+
* field reaches — `'secret'` over `'personal'`. Fail-safe: `find_schema_meta` reads every wrapper,
|
|
44
42
|
* every schema and action of a `pipe` (not only its first), every option of a
|
|
45
43
|
* union, and a `lazy`'s schema, so a secret stays masked however the field is
|
|
46
44
|
* wrapped, `message` included, which carries the metadata of the schema it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sensitivity.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/sensitivity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sensitivity.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/sensitivity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAI9D;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEhD,OAAO,QAAQ,4BAA4B,CAAC;IAC3C,UAAU,UAAU;QACnB;;;;WAIG;QACH,WAAW,CAAC,EAAE,WAAW,CAAC;KAC1B;CACD;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,SAAS,KAAG,WAAW,GAAG,SAOzE,CAAC"}
|
package/dist/sensitivity.js
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Used by env schemas and action input schemas to control masking/redaction
|
|
5
5
|
* in startup logs, surface explorers, and test output, and to keep values
|
|
6
|
-
* out of URLs. A
|
|
7
|
-
* (
|
|
8
|
-
* schema with `meta(schema, {sensitivity})`, the key this module adds to
|
|
6
|
+
* out of URLs. A `@fuzdev/fuz_schema` schema declares it with
|
|
7
|
+
* `meta(schema, {sensitivity})`, the key this module adds to
|
|
9
8
|
* fuz_schema's `SchemaMeta` by declaration merging, read by
|
|
10
9
|
* `find_schema_sensitivity`. `server/env.ts` and `env/env_schemas.ts` import
|
|
11
10
|
* this module for the declaration, so a consumer of either has the key; a
|
|
@@ -18,8 +17,7 @@
|
|
|
18
17
|
import { find_schema_meta } from '@fuzdev/fuz_schema/introspect.ts';
|
|
19
18
|
/**
|
|
20
19
|
* The strongest `sensitivity` declared on any schema a `@fuzdev/fuz_schema`
|
|
21
|
-
* field reaches — `'secret'` over `'personal'
|
|
22
|
-
* `schema_sensitivity`. Fail-safe: `find_schema_meta` reads every wrapper,
|
|
20
|
+
* field reaches — `'secret'` over `'personal'`. Fail-safe: `find_schema_meta` reads every wrapper,
|
|
23
21
|
* every schema and action of a `pipe` (not only its first), every option of a
|
|
24
22
|
* union, and a `lazy`'s schema, so a secret stays masked however the field is
|
|
25
23
|
* wrapped, `message` included, which carries the metadata of the schema it
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
import { open } from 'node:fs/promises';
|
|
134
134
|
import { Readable } from 'node:stream';
|
|
135
135
|
import { join } from 'node:path';
|
|
136
|
-
import { ActingActor, FactHashSchema, Uuid } from '../
|
|
136
|
+
import { ActingActor, FactHashSchema, Uuid } from '../primitive_schemas.js';
|
|
137
137
|
import { literal, object } from '@fuzdev/fuz_schema/schema.ts';
|
|
138
138
|
import { build_request_context, get_public_account_id, get_request_context, has_scoped_role } from '../auth/request_context.js';
|
|
139
139
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { array, literal, loose_object, object } from '@fuzdev/fuz_schema/schema.ts';
|
|
11
11
|
import { define_route } from '../http/route_spec.js';
|
|
12
12
|
import { route_ok } from '../http/route_result.js';
|
|
13
|
-
import { ActingActor } from '../
|
|
13
|
+
import { ActingActor } from '../primitive_schemas.js';
|
|
14
14
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
15
15
|
/**
|
|
16
16
|
* Create the admin-only route spec that serves the `AppSurface` as JSON.
|