@fuzdev/fuz_app 0.136.0 → 0.138.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/action_codegen.js +1 -1
- package/dist/actions/action_event.js +1 -1
- package/dist/actions/action_rpc.d.ts +1 -1
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_spec.d.ts +0 -48
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/connection_closer.d.ts +1 -1
- package/dist/actions/connection_closer.d.ts.map +1 -1
- package/dist/actions/peer_request.d.ts +1 -1
- package/dist/actions/peer_request.d.ts.map +1 -1
- package/dist/actions/perform_action.d.ts +1 -1
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/register_action_ws.d.ts +1 -1
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/transports_ws_backend.d.ts +1 -1
- package/dist/actions/transports_ws_backend.d.ts.map +1 -1
- package/dist/actions/transports_ws_backend.js +1 -1
- package/dist/auth/account_action_specs.d.ts +1 -1
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +3 -4
- package/dist/auth/account_schema.d.ts +3 -9
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +3 -4
- package/dist/auth/actor_lookup_action_specs.js +1 -1
- package/dist/auth/actor_lookup_queries.d.ts +1 -1
- package/dist/auth/actor_lookup_queries.d.ts.map +1 -1
- package/dist/auth/actor_search_action_specs.d.ts +1 -1
- package/dist/auth/actor_search_action_specs.d.ts.map +1 -1
- package/dist/auth/actor_search_action_specs.js +3 -7
- package/dist/auth/actor_search_queries.d.ts +1 -1
- package/dist/auth/actor_search_queries.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +1 -2
- package/dist/auth/app_settings_schema.d.ts +1 -1
- 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 +1 -1
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.d.ts +1 -1
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +1 -2
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +1 -2
- package/dist/auth/cell_action_specs.d.ts +25 -25
- package/dist/auth/cell_action_specs.d.ts.map +1 -1
- package/dist/auth/cell_action_specs.js +7 -10
- package/dist/auth/cell_actions.d.ts +1 -1
- package/dist/auth/cell_actions.d.ts.map +1 -1
- package/dist/auth/cell_audit_action_specs.js +1 -1
- package/dist/auth/cell_audit_metadata.js +1 -1
- package/dist/auth/cell_field_action_specs.js +1 -1
- package/dist/auth/cell_field_audit_metadata.js +1 -1
- package/dist/auth/cell_grant_action_specs.js +1 -1
- package/dist/auth/cell_grant_audit_metadata.js +1 -1
- package/dist/auth/cell_item_action_specs.d.ts.map +1 -1
- package/dist/auth/cell_item_action_specs.js +2 -5
- package/dist/auth/cell_item_audit_metadata.js +1 -1
- package/dist/auth/cell_relation_visibility.d.ts +1 -1
- package/dist/auth/cell_relation_visibility.d.ts.map +1 -1
- package/dist/auth/invite_schema.d.ts +1 -2
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/invite_schema.js +1 -2
- package/dist/auth/password.d.ts +2 -2
- package/dist/auth/password.d.ts.map +1 -1
- package/dist/auth/password.js +10 -12
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +5 -11
- package/dist/auth/role_grant_offer_notifications.d.ts +1 -1
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +2 -2
- package/dist/auth/role_grant_offer_queries.d.ts +1 -1
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_schema.d.ts +2 -2
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_schema.js +4 -8
- package/dist/auth/role_grant_queries.d.ts +1 -1
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +5 -4
- package/dist/auth/scope_kind_schema.d.ts +1 -1
- package/dist/auth/scope_kind_schema.d.ts.map +1 -1
- package/dist/auth/scope_kind_schema.js +6 -5
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +1 -2
- package/dist/cli/args.d.ts +21 -15
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +40 -16
- package/dist/cli/daemon.d.ts +0 -5
- package/dist/cli/daemon.d.ts.map +1 -1
- package/dist/cli/help.d.ts +45 -6
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +81 -4
- package/dist/db/cell_audit_queries.d.ts +1 -1
- package/dist/db/cell_audit_queries.d.ts.map +1 -1
- package/dist/db/cell_field_queries.d.ts +1 -1
- package/dist/db/cell_field_queries.d.ts.map +1 -1
- package/dist/db/cell_grant_queries.d.ts +1 -1
- package/dist/db/cell_grant_queries.d.ts.map +1 -1
- package/dist/db/cell_item_queries.d.ts +1 -1
- package/dist/db/cell_item_queries.d.ts.map +1 -1
- package/dist/db/cell_queries.d.ts +1 -1
- package/dist/db/cell_queries.d.ts.map +1 -1
- package/dist/http/auth_shape.d.ts +0 -27
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +2 -2
- package/dist/http/db_routes.d.ts +1 -1
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/primitive_schemas.d.ts +82 -8
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +120 -17
- package/dist/server/serve_fact_route.js +1 -2
- package/dist/server/x_accel.d.ts +0 -1
- package/dist/server/x_accel.d.ts.map +1 -1
- package/dist/testing/adversarial_input.js +1 -1
- package/dist/testing/app_server.d.ts +1 -1
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.d.ts +0 -14
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/fact_serving.js +1 -1
- package/dist/testing/cross_backend/setup.d.ts +1 -1
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +1 -2
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +1 -10
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +1 -2
- package/dist/testing/role_grant_helpers.d.ts +1 -1
- package/dist/testing/role_grant_helpers.d.ts.map +1 -1
- package/dist/testing/schema_generators.d.ts +1 -1
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.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/testing/ws_round_trip.d.ts +1 -1
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +1 -1
- package/dist/ui/admin_accounts_state.svelte.d.ts +1 -1
- 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 +1 -1
- package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -1
- package/dist/zod.d.ts +64 -0
- package/dist/zod.d.ts.map +1 -0
- package/dist/zod.js +171 -0
- package/package.json +7 -5
package/dist/zod.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema introspection utilities.
|
|
3
|
+
*
|
|
4
|
+
* Generic helpers for walking, unwrapping, and extracting field info from Zod schemas.
|
|
5
|
+
* Used by adversarial input testing, test-data generation, action codegen, and
|
|
6
|
+
* auth-shape checks.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
//
|
|
11
|
+
// Schema Introspection
|
|
12
|
+
//
|
|
13
|
+
/**
|
|
14
|
+
* Unwrap nested schema types (optional, default, nullable, etc).
|
|
15
|
+
*
|
|
16
|
+
* @returns inner schema if wrapped, undefined otherwise
|
|
17
|
+
*/
|
|
18
|
+
const zod_to_subschema = (def) => {
|
|
19
|
+
if ('innerType' in def) {
|
|
20
|
+
return def.innerType;
|
|
21
|
+
}
|
|
22
|
+
else if ('in' in def) {
|
|
23
|
+
return def.in;
|
|
24
|
+
}
|
|
25
|
+
else if ('schema' in def) {
|
|
26
|
+
return def.schema;
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
};
|
|
30
|
+
/** Zod wrapper type names that `zod_unwrap_def` traverses through. */
|
|
31
|
+
const ZOD_WRAPPER_TYPES = new Set([
|
|
32
|
+
'optional',
|
|
33
|
+
'nullable',
|
|
34
|
+
'default',
|
|
35
|
+
'transform',
|
|
36
|
+
'pipe',
|
|
37
|
+
'prefault'
|
|
38
|
+
]);
|
|
39
|
+
/**
|
|
40
|
+
* Unwrap Zod wrappers (optional, default, nullable, pipe, transform)
|
|
41
|
+
* to get the base type definition.
|
|
42
|
+
*
|
|
43
|
+
* @returns the innermost non-wrapper type definition
|
|
44
|
+
*/
|
|
45
|
+
export const zod_unwrap_def = (schema) => {
|
|
46
|
+
const { def } = schema;
|
|
47
|
+
if (ZOD_WRAPPER_TYPES.has(def.type)) {
|
|
48
|
+
const sub = zod_to_subschema(def);
|
|
49
|
+
if (sub)
|
|
50
|
+
return zod_unwrap_def(sub);
|
|
51
|
+
}
|
|
52
|
+
return def;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Get the base type name for a Zod schema, unwrapping all wrappers.
|
|
56
|
+
*
|
|
57
|
+
* @returns base type name (e.g. `'string'`, `'object'`, `'uuid'`)
|
|
58
|
+
*/
|
|
59
|
+
export const zod_get_base_type = (schema) => zod_unwrap_def(schema).type;
|
|
60
|
+
/**
|
|
61
|
+
* Check if a schema is optional at the outermost level.
|
|
62
|
+
*/
|
|
63
|
+
const zod_is_optional = (schema) => schema.def.type === 'optional';
|
|
64
|
+
/**
|
|
65
|
+
* Check if a schema accepts null at any wrapping level.
|
|
66
|
+
*/
|
|
67
|
+
const zod_is_nullable = (schema) => {
|
|
68
|
+
const { def } = schema;
|
|
69
|
+
if (def.type === 'nullable')
|
|
70
|
+
return true;
|
|
71
|
+
if (ZOD_WRAPPER_TYPES.has(def.type)) {
|
|
72
|
+
const sub = zod_to_subschema(def);
|
|
73
|
+
if (sub)
|
|
74
|
+
return zod_is_nullable(sub);
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Check if a schema has a default value at any wrapping level.
|
|
80
|
+
* Distinguishes "no default" from "default is undefined".
|
|
81
|
+
*/
|
|
82
|
+
const zod_has_default = (schema) => {
|
|
83
|
+
const { def } = schema;
|
|
84
|
+
if ('defaultValue' in def)
|
|
85
|
+
return true;
|
|
86
|
+
const sub = zod_to_subschema(def);
|
|
87
|
+
if (sub)
|
|
88
|
+
return zod_has_default(sub);
|
|
89
|
+
return false;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Unwrap a schema through every wrapper type (optional, nullable, default,
|
|
93
|
+
* transform, pipe, prefault) to reach the innermost schema. Like `zod_unwrap_def`
|
|
94
|
+
* but returns the schema (so callers can `.shape`, `instanceof`-check, etc.)
|
|
95
|
+
* instead of the def.
|
|
96
|
+
*
|
|
97
|
+
* @returns the innermost non-wrapper schema
|
|
98
|
+
*/
|
|
99
|
+
export const zod_get_innermost_type = (schema) => {
|
|
100
|
+
if (ZOD_WRAPPER_TYPES.has(schema.def.type)) {
|
|
101
|
+
const sub = zod_to_subschema(schema.def);
|
|
102
|
+
if (sub)
|
|
103
|
+
return zod_get_innermost_type(sub);
|
|
104
|
+
}
|
|
105
|
+
return schema;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Get all property keys from an object schema, unwrapping wrappers.
|
|
109
|
+
* Returns an empty array if the innermost type is not an object.
|
|
110
|
+
*
|
|
111
|
+
* @param schema - Zod schema (typically a `ZodObject` with possible wrappers)
|
|
112
|
+
*/
|
|
113
|
+
export const zod_get_schema_keys = (schema) => {
|
|
114
|
+
const obj = zod_unwrap_to_object(schema);
|
|
115
|
+
return obj ? Object.keys(obj.shape) : [];
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Get the field schema for a key in an object schema, returning `undefined` if
|
|
119
|
+
* the schema is not an object or the key is missing.
|
|
120
|
+
*
|
|
121
|
+
* @param schema - Zod schema (typically a `ZodObject` with possible wrappers)
|
|
122
|
+
* @param key - the property name
|
|
123
|
+
* @returns the field's schema, or `undefined`
|
|
124
|
+
*/
|
|
125
|
+
const zod_maybe_get_field_schema = (schema, key) => zod_unwrap_to_object(schema)?.shape[key];
|
|
126
|
+
/**
|
|
127
|
+
* Get the field schema for a key in an object schema.
|
|
128
|
+
*
|
|
129
|
+
* @param schema - Zod schema (typically a `ZodObject` with possible wrappers)
|
|
130
|
+
* @throws Error if the schema is not an object or the key is missing
|
|
131
|
+
*/
|
|
132
|
+
export const zod_get_field_schema = (schema, key) => {
|
|
133
|
+
const field = zod_maybe_get_field_schema(schema, key);
|
|
134
|
+
if (!field)
|
|
135
|
+
throw new Error(`Field "${key}" not found in schema`);
|
|
136
|
+
return field;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Unwrap a schema to find the inner `ZodObject`, or `null` if not an object schema.
|
|
140
|
+
* Handles wrappers like `z.strictObject({...}).default({...})`.
|
|
141
|
+
*/
|
|
142
|
+
export const zod_unwrap_to_object = (schema) => {
|
|
143
|
+
const def = zod_unwrap_def(schema);
|
|
144
|
+
if (def.type !== 'object')
|
|
145
|
+
return null;
|
|
146
|
+
let s = schema;
|
|
147
|
+
while (s.def.type !== 'object') {
|
|
148
|
+
const sub = zod_to_subschema(s.def);
|
|
149
|
+
if (!sub)
|
|
150
|
+
return null;
|
|
151
|
+
s = sub;
|
|
152
|
+
}
|
|
153
|
+
return s;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Extract field metadata from a Zod object schema.
|
|
157
|
+
*/
|
|
158
|
+
export const zod_extract_fields = (schema) => {
|
|
159
|
+
const fields = [];
|
|
160
|
+
for (const [name, field_schema] of Object.entries(schema.shape)) {
|
|
161
|
+
const field = field_schema;
|
|
162
|
+
fields.push({
|
|
163
|
+
name,
|
|
164
|
+
base_type: zod_get_base_type(field),
|
|
165
|
+
required: !zod_is_optional(field),
|
|
166
|
+
has_default: zod_has_default(field),
|
|
167
|
+
nullable: zod_is_nullable(field)
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return fields;
|
|
171
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuzdev/fuz_app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.138.0",
|
|
4
4
|
"description": "fullstack app library",
|
|
5
5
|
"glyph": "🗝",
|
|
6
6
|
"logo": "logo.svg",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"@electric-sql/pglite": ">=0.4",
|
|
35
35
|
"@fuzdev/blake3-wasm": ">=0.2.0",
|
|
36
36
|
"@fuzdev/fuz_css": ">=0.65.0",
|
|
37
|
-
"@fuzdev/
|
|
37
|
+
"@fuzdev/fuz_schema": "^0.2.2",
|
|
38
|
+
"@fuzdev/fuz_util": ">=0.75.0",
|
|
38
39
|
"@fuzdev/pglet-wasm": ">=0.1.1",
|
|
39
40
|
"@hono/bun": ">=1",
|
|
40
41
|
"@hono/deno": ">=1",
|
|
@@ -92,9 +93,10 @@
|
|
|
92
93
|
"@fuzdev/blake3-wasm": "^0.2.0",
|
|
93
94
|
"@fuzdev/fuz_code": "^0.52.1",
|
|
94
95
|
"@fuzdev/fuz_css": "^0.66.1",
|
|
96
|
+
"@fuzdev/fuz_schema": "^0.2.2",
|
|
95
97
|
"@fuzdev/fuz_ui": "^0.213.0",
|
|
96
|
-
"@fuzdev/fuz_util": "^0.
|
|
97
|
-
"@fuzdev/gro": "^0.
|
|
98
|
+
"@fuzdev/fuz_util": "^0.75.0",
|
|
99
|
+
"@fuzdev/gro": "^0.218.0",
|
|
98
100
|
"@fuzdev/mdz": "^0.4.0",
|
|
99
101
|
"@fuzdev/pglet-wasm": "^0.1.1",
|
|
100
102
|
"@hono/bun": "^1.0.1",
|
|
@@ -130,7 +132,7 @@
|
|
|
130
132
|
"vitest": "^5.0.0",
|
|
131
133
|
"ws": "^8.20.1",
|
|
132
134
|
"zimmerframe": "^1.1.4",
|
|
133
|
-
"zod": "^4.
|
|
135
|
+
"zod": "^4.6.7"
|
|
134
136
|
},
|
|
135
137
|
"sideEffects": [
|
|
136
138
|
"**/*.css"
|