@fuzdev/fuz_app 0.137.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/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_schema.d.ts +2 -3
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +2 -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.map +1 -1
- package/dist/auth/actor_search_action_specs.js +1 -2
- 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 +22 -22
- package/dist/auth/cell_action_specs.d.ts.map +1 -1
- package/dist/auth/cell_action_specs.js +1 -3
- 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 +1 -2
- 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/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +1 -2
- 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 +1 -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 +1 -1
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_schema.js +1 -2
- package/dist/auth/role_grant_queries.d.ts +1 -1
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +1 -2
- 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.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 +45 -5
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +44 -5
- package/dist/server/serve_fact_route.js +1 -2
- 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/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 -1
- 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 +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin_invites_state.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/admin_invites_state.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"admin_invites_state.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/admin_invites_state.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,KAAK,EACX,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,MAAM,+BAA+B,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACtC,MAAM,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACnE,MAAM,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACnE;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB;2CAAwB,eAAe;4BAAf,eAAe;uBAAf,eAAe,WAAf,eAAe;CAAG,CAAC;AAEjF,MAAM,WAAW,wBAAwB;IACxC,6CAA6C;IAC7C,OAAO,EAAE,MAAM,eAAe,CAAC;CAC/B;AAED,qBAAa,iBAAiB;;IAG7B,QAAQ,CAAC,IAAI,0BAAyB;IACtC,QAAQ,CAAC,MAAM,0BAAyB;IACxC,QAAQ,CAAC,MAAM,sEAAoC;IAEnD,OAAO,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAkB;IAEzD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAiC;IAC9D,QAAQ,CAAC,eAAe,EAAE,MAAM,CAA8D;gBAElF,OAAO,EAAE,wBAAwB;IAIvC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtB,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASlE,aAAa,CAAC,EAAE,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAM5C"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* @module
|
|
16
16
|
*/
|
|
17
|
-
import type { Uuid } from '
|
|
17
|
+
import type { Uuid } from '../primitive_schemas.js';
|
|
18
18
|
import { AsyncSlot } from './async_slot.svelte.js';
|
|
19
19
|
import { KeyedAsyncSlot } from './keyed_async_slot.svelte.js';
|
|
20
20
|
import type { AdminAccountsRpc } from './admin_accounts_state.svelte.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin_sessions_state.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/admin_sessions_state.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"admin_sessions_state.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/admin_sessions_state.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,OAAO,EAAE,MAAM,gBAAgB,CAAC;CAChC;AAED,qBAAa,kBAAkB;;IAG9B,QAAQ,CAAC,IAAI,0BAAyB;IACtC,QAAQ,CAAC,eAAe,sEAAoC;IAC5D,QAAQ,CAAC,aAAa,sEAAoC;IAE1D,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAkB;IAEnD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAkC;gBAEnD,OAAO,EAAE,yBAAyB;IAIxC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtB,sBAAsB,CAAC,UAAU,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAOvD,oBAAoB,CAAC,UAAU,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAM3D"}
|
package/dist/zod.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
import type { z } from 'zod';
|
|
11
|
+
/**
|
|
12
|
+
* Unwrap Zod wrappers (optional, default, nullable, pipe, transform)
|
|
13
|
+
* to get the base type definition.
|
|
14
|
+
*
|
|
15
|
+
* @returns the innermost non-wrapper type definition
|
|
16
|
+
*/
|
|
17
|
+
export declare const zod_unwrap_def: (schema: z.ZodType) => z.core.$ZodTypeDef;
|
|
18
|
+
/**
|
|
19
|
+
* Get the base type name for a Zod schema, unwrapping all wrappers.
|
|
20
|
+
*
|
|
21
|
+
* @returns base type name (e.g. `'string'`, `'object'`, `'uuid'`)
|
|
22
|
+
*/
|
|
23
|
+
export declare const zod_get_base_type: (schema: z.ZodType) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Unwrap a schema through every wrapper type (optional, nullable, default,
|
|
26
|
+
* transform, pipe, prefault) to reach the innermost schema. Like `zod_unwrap_def`
|
|
27
|
+
* but returns the schema (so callers can `.shape`, `instanceof`-check, etc.)
|
|
28
|
+
* instead of the def.
|
|
29
|
+
*
|
|
30
|
+
* @returns the innermost non-wrapper schema
|
|
31
|
+
*/
|
|
32
|
+
export declare const zod_get_innermost_type: (schema: z.ZodType) => z.ZodType;
|
|
33
|
+
/**
|
|
34
|
+
* Get all property keys from an object schema, unwrapping wrappers.
|
|
35
|
+
* Returns an empty array if the innermost type is not an object.
|
|
36
|
+
*
|
|
37
|
+
* @param schema - Zod schema (typically a `ZodObject` with possible wrappers)
|
|
38
|
+
*/
|
|
39
|
+
export declare const zod_get_schema_keys: <T extends z.ZodType>(schema: T) => Array<keyof z.infer<T> & string>;
|
|
40
|
+
/**
|
|
41
|
+
* Get the field schema for a key in an object schema.
|
|
42
|
+
*
|
|
43
|
+
* @param schema - Zod schema (typically a `ZodObject` with possible wrappers)
|
|
44
|
+
* @throws Error if the schema is not an object or the key is missing
|
|
45
|
+
*/
|
|
46
|
+
export declare const zod_get_field_schema: (schema: z.ZodType, key: string) => z.ZodType;
|
|
47
|
+
/**
|
|
48
|
+
* Unwrap a schema to find the inner `ZodObject`, or `null` if not an object schema.
|
|
49
|
+
* Handles wrappers like `z.strictObject({...}).default({...})`.
|
|
50
|
+
*/
|
|
51
|
+
export declare const zod_unwrap_to_object: (schema: z.ZodType) => z.ZodObject | null;
|
|
52
|
+
/** Metadata extracted from a single field of a Zod object schema. */
|
|
53
|
+
export interface ZodFieldInfo {
|
|
54
|
+
name: string;
|
|
55
|
+
base_type: string;
|
|
56
|
+
required: boolean;
|
|
57
|
+
has_default: boolean;
|
|
58
|
+
nullable: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Extract field metadata from a Zod object schema.
|
|
62
|
+
*/
|
|
63
|
+
export declare const zod_extract_fields: (schema: z.ZodObject) => Array<ZodFieldInfo>;
|
|
64
|
+
//# sourceMappingURL=zod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/zod.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgC7B;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,CAAC,CAAC,IAAI,CAAC,WAOzD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,MAAqC,CAAC;AAgC5F;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,CAAC,CAAC,OAM5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EACtD,QAAQ,CAAC,KACP,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAGjC,CAAC;AAaF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,CAAC,CAAC,OAAO,EAAE,KAAK,MAAM,KAAG,CAAC,CAAC,OAIvE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,CAAC,CAAC,SAAS,GAAG,IAUtE,CAAC;AAIF,qEAAqE;AACrE,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,CAAC,CAAC,SAAS,KAAG,KAAK,CAAC,YAAY,CAa1E,CAAC"}
|
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,8 +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/fuz_schema": "^0.2.
|
|
38
|
-
"@fuzdev/fuz_util": ">=0.
|
|
37
|
+
"@fuzdev/fuz_schema": "^0.2.2",
|
|
38
|
+
"@fuzdev/fuz_util": ">=0.75.0",
|
|
39
39
|
"@fuzdev/pglet-wasm": ">=0.1.1",
|
|
40
40
|
"@hono/bun": ">=1",
|
|
41
41
|
"@hono/deno": ">=1",
|
|
@@ -93,10 +93,10 @@
|
|
|
93
93
|
"@fuzdev/blake3-wasm": "^0.2.0",
|
|
94
94
|
"@fuzdev/fuz_code": "^0.52.1",
|
|
95
95
|
"@fuzdev/fuz_css": "^0.66.1",
|
|
96
|
-
"@fuzdev/fuz_schema": "^0.2.
|
|
96
|
+
"@fuzdev/fuz_schema": "^0.2.2",
|
|
97
97
|
"@fuzdev/fuz_ui": "^0.213.0",
|
|
98
|
-
"@fuzdev/fuz_util": "^0.
|
|
99
|
-
"@fuzdev/gro": "^0.
|
|
98
|
+
"@fuzdev/fuz_util": "^0.75.0",
|
|
99
|
+
"@fuzdev/gro": "^0.218.0",
|
|
100
100
|
"@fuzdev/mdz": "^0.4.0",
|
|
101
101
|
"@fuzdev/pglet-wasm": "^0.1.1",
|
|
102
102
|
"@hono/bun": "^1.0.1",
|