schema_meta.ts

fuz_app's @fuzdev/fuz_schema metadata conventions.

Cross-cutting metadata read by auth and action input schemas, surface generation, and test helpers. sensitivity.ts adds sensitivity to fuz_schema's SchemaMeta (read by find_schema_sensitivity); this module adds invalid_reason and empty_input_handler_guarded — the declared refusal reason of an action input's field and its handler-guarded marker — and JSON Schema's readOnly annotation, which to_json_schema writes onto the node.

view source

Declarations
#

4 declarations

is_empty_input_handler_guarded
#

schema_meta.ts view source

(schema: AnySchema): boolean import {is_empty_input_handler_guarded} from '@fuzdev/fuz_app/schema_meta.js';

Whether schema carries empty_input_handler_guarded: true in its own meta (get_meta).

schema

an action's input schema

type AnySchema

returns

boolean

whether its handler refuses the {} the schema admits

throws

  • Error - when `schema` is no schema

resolve_invalid_reason
#

schema_meta.ts view source

(input_schema: AnySchema, path: readonly PropertyKey[]): string | undefined import {resolve_invalid_reason} from '@fuzdev/fuz_app/schema_meta.js';

The error.data.reason an input validation failure at path carries: the invalid_reason of the deepest field along path that declares one.

Walks object fields only, through their entries (get_schema_entries), each read with get_schema_meta through its wrappers: a segment that is not a key of an object schema (an array index, a union member's key, an unknown key) ends the walk, so a fault inside a declared field still resolves to that field's reason. An empty path — a whole-input fault such as an unknown key on the input object — resolves to none, as does a schema that is not an object.

input_schema

an action's input schema

type AnySchema

path

the failing issue's path

type readonly PropertyKey[]

returns

string | undefined

the declared reason, or undefined

resolve_issues_invalid_reason
#

schema_meta.ts view source

(input_schema: AnySchema, issues: readonly SchemaIssue[], input: unknown): string | undefined import {resolve_issues_invalid_reason} from '@fuzdev/fuz_app/schema_meta.js';

The error.data.reason a failed input parse answers: the declared reason of the first issue's field (resolve_invalid_reason), or none when any issue sits on the input itself (issue_is_on_input). Such an issue is an unknown key on the input object (or a non-object input), which the Rust twin refuses before reading any field, so a stale client sending an extra key gets the same answer from both spines whatever else its body gets wrong.

A parse reports at most a hundred issues, so faults on the fields can crowd an unknown key out of them. For a strict object input, input is checked for a key the schema doesn't name, as the Rust twin checks it, whatever the issues hold.

input_schema

an action's input schema

type AnySchema

issues

the failed parse's issues, in the parse's order

type readonly SchemaIssue[]

input

the value that was parsed

type unknown

returns

string | undefined

the declared reason, or undefined

schema_has_sensitive_field
#

schema_meta.ts view source

(schema: AnySchema): boolean import {schema_has_sensitive_field} from '@fuzdev/fuz_app/schema_meta.js';

Whether an input schema carries a sensitive value at any depth — 'secret' or 'personal' on the schema itself or anywhere inside it, read with find_schema_meta and structural: every layer, every step of a pipe, every option of a union or variant, a lazy's schema, and the entries, rest, items and values of its objects, arrays and records.

What keeps a read's input off the URL: FrontendHttpTransport sends a read (side_effects: false) as a GET with the params in the query string, which proxies and server logs record, unless its input carries a sensitive value — that call goes as a POST (the transport walks each spec's input once).

schema

an action input schema

type AnySchema

returns

boolean

true when any value the schema admits may hold a sensitive field

throws

  • Error - when `schema` is no schema, which would otherwise read as holding none

Depends on
#

Imported by
#