@wildo-ai/zod-decorators 1.0.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/esm/__mocks__/mime.d.ts +12 -0
- package/dist/esm/__mocks__/mime.d.ts.map +1 -0
- package/dist/esm/__mocks__/mime.js +75 -0
- package/dist/esm/__mocks__/mime.js.map +1 -0
- package/dist/esm/commons.d.ts +26 -0
- package/dist/esm/commons.d.ts.map +1 -0
- package/dist/esm/commons.js +41 -0
- package/dist/esm/commons.js.map +1 -0
- package/dist/esm/currencies.shared.schemas.d.ts +208 -0
- package/dist/esm/currencies.shared.schemas.d.ts.map +1 -0
- package/dist/esm/currencies.shared.schemas.js +228 -0
- package/dist/esm/currencies.shared.schemas.js.map +1 -0
- package/dist/esm/files/agent-file-formats.d.ts +99 -0
- package/dist/esm/files/agent-file-formats.d.ts.map +1 -0
- package/dist/esm/files/agent-file-formats.js +163 -0
- package/dist/esm/files/agent-file-formats.js.map +1 -0
- package/dist/esm/files/extension-nature-map.d.ts +12 -0
- package/dist/esm/files/extension-nature-map.d.ts.map +1 -0
- package/dist/esm/files/extension-nature-map.js +63 -0
- package/dist/esm/files/extension-nature-map.js.map +1 -0
- package/dist/esm/files/file-extensions.enum.d.ts +58 -0
- package/dist/esm/files/file-extensions.enum.d.ts.map +1 -0
- package/dist/esm/files/file-extensions.enum.js +65 -0
- package/dist/esm/files/file-extensions.enum.js.map +1 -0
- package/dist/esm/files/mime-registry.d.ts +72 -0
- package/dist/esm/files/mime-registry.d.ts.map +1 -0
- package/dist/esm/files/mime-registry.js +174 -0
- package/dist/esm/files/mime-registry.js.map +1 -0
- package/dist/esm/files/unified-registry.d.ts +112 -0
- package/dist/esm/files/unified-registry.d.ts.map +1 -0
- package/dist/esm/files/unified-registry.js +190 -0
- package/dist/esm/files/unified-registry.js.map +1 -0
- package/dist/esm/index.d.ts +29 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +36 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/testing/decorated-test-schemas.d.ts +27 -0
- package/dist/esm/testing/decorated-test-schemas.d.ts.map +1 -0
- package/dist/esm/testing/decorated-test-schemas.js +26 -0
- package/dist/esm/testing/decorated-test-schemas.js.map +1 -0
- package/dist/esm/testing.d.ts +6 -0
- package/dist/esm/testing.d.ts.map +1 -0
- package/dist/esm/testing.js +6 -0
- package/dist/esm/testing.js.map +1 -0
- package/dist/esm/zod-bigdecimal.d.ts +193 -0
- package/dist/esm/zod-bigdecimal.d.ts.map +1 -0
- package/dist/esm/zod-bigdecimal.js +274 -0
- package/dist/esm/zod-bigdecimal.js.map +1 -0
- package/dist/esm/zod-code.d.ts +95 -0
- package/dist/esm/zod-code.d.ts.map +1 -0
- package/dist/esm/zod-code.js +160 -0
- package/dist/esm/zod-code.js.map +1 -0
- package/dist/esm/zod-color.d.ts +8 -0
- package/dist/esm/zod-color.d.ts.map +1 -0
- package/dist/esm/zod-color.js +88 -0
- package/dist/esm/zod-color.js.map +1 -0
- package/dist/esm/zod-decorators.types.d.ts +2207 -0
- package/dist/esm/zod-decorators.types.d.ts.map +1 -0
- package/dist/esm/zod-decorators.types.js +771 -0
- package/dist/esm/zod-decorators.types.js.map +1 -0
- package/dist/esm/zod-duration.d.ts +128 -0
- package/dist/esm/zod-duration.d.ts.map +1 -0
- package/dist/esm/zod-duration.js +174 -0
- package/dist/esm/zod-duration.js.map +1 -0
- package/dist/esm/zod-file.d.ts +219 -0
- package/dist/esm/zod-file.d.ts.map +1 -0
- package/dist/esm/zod-file.js +469 -0
- package/dist/esm/zod-file.js.map +1 -0
- package/dist/esm/zod-money.d.ts +223 -0
- package/dist/esm/zod-money.d.ts.map +1 -0
- package/dist/esm/zod-money.js +293 -0
- package/dist/esm/zod-money.js.map +1 -0
- package/dist/esm/zod-phone.d.ts +75 -0
- package/dist/esm/zod-phone.d.ts.map +1 -0
- package/dist/esm/zod-phone.js +116 -0
- package/dist/esm/zod-phone.js.map +1 -0
- package/dist/esm/zod-range.d.ts +87 -0
- package/dist/esm/zod-range.d.ts.map +1 -0
- package/dist/esm/zod-range.js +138 -0
- package/dist/esm/zod-range.js.map +1 -0
- package/dist/esm/zod-utils.shared.d.ts +783 -0
- package/dist/esm/zod-utils.shared.d.ts.map +1 -0
- package/dist/esm/zod-utils.shared.js +2647 -0
- package/dist/esm/zod-utils.shared.js.map +1 -0
- package/dist/esm/zod-versioned.d.ts +150 -0
- package/dist/esm/zod-versioned.d.ts.map +1 -0
- package/dist/esm/zod-versioned.js +172 -0
- package/dist/esm/zod-versioned.js.map +1 -0
- package/dist/esm/zod.module-override.d.ts +413 -0
- package/dist/esm/zod.module-override.d.ts.map +1 -0
- package/dist/esm/zod.module-override.js +1093 -0
- package/dist/esm/zod.module-override.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,783 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ArrayUIParams, BigDecimalUIParams, BooleanUIParams, CodeUIParams, DateUIParams, DateTimeUIParams, DurationUIParams, EnumUIParams, FileUIParams, ForeignKeyUIParams, MoneyUIParams, NumberUIParams, ObjectUIParams, PhoneUIParams, StringUIParams, TimeUIParams, PrimitiveUIBaseEditParams, PrimitiveUIBaseDisplayParams } from './zod-decorators.types.js';
|
|
3
|
+
import { BackendOnlyFieldParams, BigDecimalSchemaMetadata, DurationSchemaMetadata, CodeSchemaMetadata, DiscriminatorFieldParams, FileSchemaMetadata, ForeignKeyStructuralParams, ForeignKeyUIDisplayParams, MoneySchemaMetadata, CustomFieldMetadata, FieldSchemaType, FormFieldComponent, HiddenFieldParams, NotEditableFieldParams, OtpFieldParams, PhoneSchemaMetadata, PolymorphicFkVariant, RangeConstraintValue, RangeSchemaMetadata, RangeType, SerializableZodSchema, SummaryFieldParams, VersionedForeignKeySchemaMetadata, VersionedSchemaMetadata, ZodDecorator, UniqueFieldParams, VirtualFieldParams, TtlFieldParams, ShowWhenParams } from './zod-decorators.types.js';
|
|
4
|
+
export declare function hasZodInternals(schema: unknown): schema is {
|
|
5
|
+
def: {
|
|
6
|
+
type: string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
type?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Check if a schema has a specific decorator.
|
|
13
|
+
* Note: getCustomFieldMetadata already handles recursive unwrapping for all wrapper types
|
|
14
|
+
* including pipe (from refine/superRefine), optional, nullable, default, etc.
|
|
15
|
+
*/
|
|
16
|
+
export declare function hasDecorator(schema: z.ZodTypeAny, decorator: ZodDecorator): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Unwrap optional, nullable, default, and other wrapper schemas
|
|
19
|
+
* to get the underlying base schema
|
|
20
|
+
*/
|
|
21
|
+
export declare function unwrapSchema(schema: z.ZodTypeAny): z.ZodTypeAny;
|
|
22
|
+
export declare function getZodType(schema: z.ZodTypeAny): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Type guard to check if a schema has a specific type
|
|
25
|
+
* Uses Zod v4's type system where types are lowercase strings
|
|
26
|
+
*/
|
|
27
|
+
export declare function hasZodType(schema: z.ZodTypeAny, type: string): boolean;
|
|
28
|
+
export declare function isZodObject(schema: z.ZodTypeAny): schema is z.ZodObject<any>;
|
|
29
|
+
export declare function isZodArray(schema: z.ZodTypeAny): boolean;
|
|
30
|
+
export declare function isZodOptional(schema: z.ZodTypeAny): boolean;
|
|
31
|
+
export declare function isZodNullable(schema: z.ZodTypeAny): boolean;
|
|
32
|
+
export declare function isZodDefault(schema: z.ZodTypeAny): boolean;
|
|
33
|
+
export declare function isZodUnion(schema: z.ZodTypeAny): boolean;
|
|
34
|
+
export declare function isZodIntersection(schema: z.ZodTypeAny): boolean;
|
|
35
|
+
export declare function isZodLiteral(schema: z.ZodTypeAny): boolean;
|
|
36
|
+
export declare function isZodLazy(schema: z.ZodTypeAny): boolean;
|
|
37
|
+
export declare function isZodTuple(schema: z.ZodTypeAny): boolean;
|
|
38
|
+
export declare function isZodRecord(schema: z.ZodTypeAny): boolean;
|
|
39
|
+
export declare function isZodSet(schema: z.ZodTypeAny): boolean;
|
|
40
|
+
export declare function isZodPipe(schema: z.ZodTypeAny): boolean;
|
|
41
|
+
export declare function isZodTransform(schema: z.ZodTypeAny): boolean;
|
|
42
|
+
export declare function isZodCustom(schema: z.ZodTypeAny): boolean;
|
|
43
|
+
export declare function isArray(value: unknown): value is unknown[];
|
|
44
|
+
export declare function isZodTypeAny(value: unknown): value is z.ZodTypeAny;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a union is discriminated (has discriminator property)
|
|
47
|
+
* In Zod v4, discriminated unions have type: "union" with a discriminator property
|
|
48
|
+
*/
|
|
49
|
+
export declare function isDiscriminatedUnion(schema: z.ZodTypeAny): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Check if a schema is optional (can be undefined)
|
|
52
|
+
*/
|
|
53
|
+
export declare function isOptional(schema: z.ZodTypeAny): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Check if a schema has refine/superRefine transformations
|
|
56
|
+
* This triggers onChange validation mode
|
|
57
|
+
*/
|
|
58
|
+
export declare function hasRefine(schema: z.ZodTypeAny): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Get the schema type category for component selection.
|
|
61
|
+
*
|
|
62
|
+
* Important: RANGE schemas (created by z_range()) are detected by their
|
|
63
|
+
* SCHEMA_METADATA.rangeConfig before checking for object type. This allows range schemas
|
|
64
|
+
* to be rendered with appropriate range components instead of as composite objects.
|
|
65
|
+
*/
|
|
66
|
+
export declare function getSchemaType(schema: z.ZodTypeAny): FieldSchemaType;
|
|
67
|
+
/**
|
|
68
|
+
* Get the shape of a Zod object schema.
|
|
69
|
+
*
|
|
70
|
+
* IMPORTANT: This function only returns valid Zod schema instances, not definitions.
|
|
71
|
+
* In Zod 4, `def.shape` contains JSON-serializable definitions, not schema instances
|
|
72
|
+
* with methods like safeParse.
|
|
73
|
+
*
|
|
74
|
+
* Prefer using getObjectShape() which handles unwrapping and validation.
|
|
75
|
+
*/
|
|
76
|
+
export declare function getZodObjectShape(schema: z.ZodTypeAny): Record<string, z.ZodTypeAny>;
|
|
77
|
+
export declare function getZodDef(schema: z.ZodTypeAny): {
|
|
78
|
+
type: string;
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
} | undefined;
|
|
81
|
+
export declare function getZodDefSchemaProperty(schema: z.ZodTypeAny, property: string): z.ZodTypeAny | undefined;
|
|
82
|
+
export declare function getZodDefArrayProperty(schema: z.ZodTypeAny, property: string): unknown[] | undefined;
|
|
83
|
+
export declare function getZodDefStringProperty(schema: z.ZodTypeAny, property: string): string | undefined;
|
|
84
|
+
export declare function getZodDefFunctionProperty(schema: z.ZodTypeAny, property: string): (() => z.ZodTypeAny) | undefined;
|
|
85
|
+
export declare function getZodDefProperty(schema: z.ZodTypeAny, property: string): unknown;
|
|
86
|
+
/**
|
|
87
|
+
* Get the inner schema from a pipe type (for transforms/refinements)
|
|
88
|
+
* In Zod v4, pipe types have def.in and def.out
|
|
89
|
+
* For most cases, we want def.in (the input schema before transformation)
|
|
90
|
+
*/
|
|
91
|
+
export declare function getPipeInputSchema(schema: z.ZodTypeAny): z.ZodTypeAny | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Get all custom field metadata from a schema, traversing through wrapper types
|
|
94
|
+
* (optional, nullable, default, pipe, readonly, catch, array, effects).
|
|
95
|
+
* Always returns an object (never undefined) — empty `{}` if no metadata found.
|
|
96
|
+
*
|
|
97
|
+
* Delegates to the unified getMetadataRecursive from zod.module-override.ts.
|
|
98
|
+
*/
|
|
99
|
+
export declare function getCustomFieldMetadata(schema: z.ZodTypeAny): CustomFieldMetadata;
|
|
100
|
+
/**
|
|
101
|
+
* Extract the edit-context base params from whichever `{primitive}UI` decorator
|
|
102
|
+
* is present on the schema. Works generically because all `*UIEditParams`
|
|
103
|
+
* extend `PrimitiveUIBaseEditParams`.
|
|
104
|
+
*
|
|
105
|
+
* Use this for cross-cutting concerns (validationMode, autosave, tooltip, etc.)
|
|
106
|
+
* where the consumer doesn't know the concrete primitive type.
|
|
107
|
+
*/
|
|
108
|
+
export declare function getFieldUIEditConfig(schema: z.ZodTypeAny): PrimitiveUIBaseEditParams | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Extract the display-context base params from whichever `{primitive}UI` decorator
|
|
111
|
+
* is present on the schema. Works generically because all `*UIDisplayParams`
|
|
112
|
+
* extend `PrimitiveUIBaseDisplayParams`.
|
|
113
|
+
*
|
|
114
|
+
* Use this for cross-cutting concerns (tooltip, inlineEditable, etc.)
|
|
115
|
+
* where the consumer doesn't know the concrete primitive type.
|
|
116
|
+
*/
|
|
117
|
+
export declare function getFieldUIDisplayConfig(schema: z.ZodTypeAny): PrimitiveUIBaseDisplayParams | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Check if a field should show a tooltip in display mode.
|
|
120
|
+
* Reads from `{primitive}UI.display.tooltip` (boolean flag).
|
|
121
|
+
* The actual tooltip text comes from the i18n label system, NOT from the decorator.
|
|
122
|
+
*/
|
|
123
|
+
export declare function hasTooltipForDisplay(schema: z.ZodTypeAny): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Check if a field should show a tooltip in edit mode.
|
|
126
|
+
* Reads from `{primitive}UI.edit.tooltip` (boolean flag).
|
|
127
|
+
* The actual tooltip text comes from the i18n label system, NOT from the decorator.
|
|
128
|
+
*/
|
|
129
|
+
export declare function hasTooltipForEdit(schema: z.ZodTypeAny): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Check if a field is marked as draft-relaxed (validation is relaxed in draft mode).
|
|
132
|
+
*
|
|
133
|
+
* @param schema - Zod schema to check
|
|
134
|
+
* @returns true if the field is draft-relaxed
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* if (isDraftRelaxed(schema) && isDraftMode) {
|
|
138
|
+
* // Skip strict validation for this field
|
|
139
|
+
* }
|
|
140
|
+
*/
|
|
141
|
+
export declare function isDraftRelaxed(schema: z.ZodTypeAny): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* FIX-P5-H1: Get showWhen parameters from a field schema.
|
|
144
|
+
* Returns the conditional visibility configuration if present.
|
|
145
|
+
*
|
|
146
|
+
* @param schema - The field schema to get showWhen params from
|
|
147
|
+
* @returns ShowWhenParams if decorator was applied, undefined otherwise
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* const showWhenParams = getShowWhenParams(fieldSchema);
|
|
151
|
+
* if (showWhenParams) {
|
|
152
|
+
* // Evaluate visibility based on conditions
|
|
153
|
+
* const isVisible = evaluateShowWhenConditions(showWhenParams, formValues);
|
|
154
|
+
* }
|
|
155
|
+
*/
|
|
156
|
+
export declare function getShowWhenParams(schema: z.ZodTypeAny): ShowWhenParams | undefined;
|
|
157
|
+
/**
|
|
158
|
+
* String format types detected from schema
|
|
159
|
+
*/
|
|
160
|
+
export type StringFormat = 'email' | 'url' | 'uuid' | 'cuid' | 'cuid2' | 'ulid' | 'regex' | 'datetime' | 'time' | 'ip' | null;
|
|
161
|
+
/**
|
|
162
|
+
* Get string format from schema checks (email, url, etc.)
|
|
163
|
+
*/
|
|
164
|
+
export declare function getStringFormat(schema: z.ZodTypeAny): StringFormat;
|
|
165
|
+
/**
|
|
166
|
+
* Get min/max length constraints from string schema
|
|
167
|
+
*/
|
|
168
|
+
export declare function getStringConstraints(schema: z.ZodTypeAny): {
|
|
169
|
+
minLength?: number;
|
|
170
|
+
maxLength?: number;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Get min/max value constraints from number schema
|
|
174
|
+
*/
|
|
175
|
+
export declare function getNumberConstraints(schema: z.ZodTypeAny): {
|
|
176
|
+
min?: number;
|
|
177
|
+
max?: number;
|
|
178
|
+
step?: number;
|
|
179
|
+
isInt?: boolean;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Extract enum values from z.enum (Zod 4)
|
|
183
|
+
* In Zod 4, both z.enum() and z.enum() create schemas with type 'enum'
|
|
184
|
+
* - z.enum(['a', 'b', 'c']) - def.entries is an object map (e.g. { a: 'a', b: 'b' })
|
|
185
|
+
* - z.enum(TypeScriptEnum) / z.enum(TypeScriptEnum) - def.entries is the enum object map
|
|
186
|
+
*/
|
|
187
|
+
export declare function getEnumValues(schema: z.ZodTypeAny): string[];
|
|
188
|
+
/**
|
|
189
|
+
* Get the shape of an object schema.
|
|
190
|
+
*
|
|
191
|
+
* IMPORTANT: In Zod 4, `def.shape` contains schema DEFINITIONS (JSON-serializable),
|
|
192
|
+
* NOT schema instances with methods. This function validates that returned shapes
|
|
193
|
+
* contain actual Zod schema instances.
|
|
194
|
+
*
|
|
195
|
+
* If the schema is wrapped (e.g., with .default()), it will be unwrapped first.
|
|
196
|
+
*/
|
|
197
|
+
export declare function getObjectShape(schema: z.ZodTypeAny): Record<string, z.ZodTypeAny> | null;
|
|
198
|
+
/**
|
|
199
|
+
* Get the keys of an object schema shape
|
|
200
|
+
*/
|
|
201
|
+
export declare function getObjectKeys(schema: z.ZodTypeAny): string[];
|
|
202
|
+
/**
|
|
203
|
+
* Extract all flattened paths from a Zod schema.
|
|
204
|
+
* Recursively traverses object schemas to build dot-notation paths (e.g., 'field.nestedField').
|
|
205
|
+
* Handles optional, nullable, array, and union types.
|
|
206
|
+
*
|
|
207
|
+
* @param zodSchema - The Zod schema to extract paths from
|
|
208
|
+
* @param prefix - Current path prefix (used for recursion)
|
|
209
|
+
* @param schemaDepthCounters - Map to track depth per schema instance (prevents infinite recursion)
|
|
210
|
+
* @param maxDepthPerSchema - Maximum depth to traverse per schema instance (default: 3)
|
|
211
|
+
* @returns Array of flattened dot-notation paths
|
|
212
|
+
*/
|
|
213
|
+
export declare function extractFlattenedPathsFromZodSchema(zodSchema: z.ZodTypeAny, prefix?: string, schemaDepthCounters?: Map<any, number>, maxDepthPerSchema?: number): string[];
|
|
214
|
+
/**
|
|
215
|
+
* Get the item schema from an array schema
|
|
216
|
+
*/
|
|
217
|
+
export declare function getArrayItemSchema(schema: z.ZodTypeAny): z.ZodTypeAny | null;
|
|
218
|
+
/**
|
|
219
|
+
* Get min/max constraints for array
|
|
220
|
+
*/
|
|
221
|
+
export declare function getArrayConstraints(schema: z.ZodTypeAny): {
|
|
222
|
+
minLength?: number;
|
|
223
|
+
maxLength?: number;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Get the value schema from a record schema
|
|
227
|
+
*/
|
|
228
|
+
export declare function getRecordValueSchema(schema: z.ZodTypeAny): z.ZodTypeAny | null;
|
|
229
|
+
/**
|
|
230
|
+
* Get the key and value schemas from a map schema
|
|
231
|
+
*/
|
|
232
|
+
export declare function getMapSchemas(schema: z.ZodTypeAny): {
|
|
233
|
+
keySchema: z.ZodTypeAny;
|
|
234
|
+
valueSchema: z.ZodTypeAny;
|
|
235
|
+
} | null;
|
|
236
|
+
/**
|
|
237
|
+
* Get the default value from a schema if it has one
|
|
238
|
+
*/
|
|
239
|
+
export declare function getDefaultValue(schema: z.ZodTypeAny): unknown | undefined;
|
|
240
|
+
export declare function isDBIndexed(schema: z.ZodTypeAny): boolean;
|
|
241
|
+
/** @see isForeignKeyField — alias for backward compatibility */
|
|
242
|
+
export declare function isForeignKey(schema: z.ZodTypeAny): boolean;
|
|
243
|
+
/** @see isUniqueField — alias for backward compatibility */
|
|
244
|
+
export declare function isUnique(schema: z.ZodTypeAny): boolean;
|
|
245
|
+
/** @see getUniqueFieldParams — alias for backward compatibility */
|
|
246
|
+
export declare function getUniqueParams(schema: z.ZodTypeAny): UniqueFieldParams | undefined;
|
|
247
|
+
/**
|
|
248
|
+
* Check if a field is a primary key.
|
|
249
|
+
* Primary keys are automatically: excludeFromCreate, isHidden, isUnique, isDBIndexed
|
|
250
|
+
* @see isPrimaryKeyField — alias for backward compatibility
|
|
251
|
+
*/
|
|
252
|
+
export declare function isPrimaryKey(schema: z.ZodTypeAny): boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Check if a field has a TTL (Time To Live) decorator.
|
|
255
|
+
* TTL fields are used for MongoDB document expiration.
|
|
256
|
+
*/
|
|
257
|
+
export declare function hasTtl(schema: z.ZodTypeAny): boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Get TTL field params from a schema.
|
|
260
|
+
* Returns undefined if the schema is not a TTL field.
|
|
261
|
+
*/
|
|
262
|
+
export declare function getTtlParams(schema: z.ZodTypeAny): TtlFieldParams | undefined;
|
|
263
|
+
/**
|
|
264
|
+
* Get the structural FK params (polymorphicVariants) from `IS_FOREIGN_KEY`.
|
|
265
|
+
* Returns undefined if the schema is not a foreign key.
|
|
266
|
+
*/
|
|
267
|
+
export declare function getForeignKeyParams(schema: z.ZodTypeAny): ForeignKeyStructuralParams | undefined;
|
|
268
|
+
/**
|
|
269
|
+
* Get FK UI display params from `FOREIGN_KEY_UI.display`. Returns mode, linkable, displayPresetOverride.
|
|
270
|
+
* Falls back to default `mode: LABEL` if the FK exists but has no explicit UI config.
|
|
271
|
+
*/
|
|
272
|
+
export declare function getForeignKeyUIDisplay(schema: z.ZodTypeAny): ForeignKeyUIDisplayParams | undefined;
|
|
273
|
+
/**
|
|
274
|
+
* Get the polymorphic variants from a foreign key field.
|
|
275
|
+
* Returns the array of PolymorphicFkVariant if the FK is polymorphic, or undefined.
|
|
276
|
+
*/
|
|
277
|
+
export declare function getPolymorphicFkVariants(schema: z.ZodTypeAny): PolymorphicFkVariant[] | undefined;
|
|
278
|
+
/**
|
|
279
|
+
* Check if a schema field is a foreign key (recursive traversal through wrappers).
|
|
280
|
+
*/
|
|
281
|
+
export declare function isForeignKeyField(schema: z.ZodTypeAny): boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Check if a schema field has the isSummaryField decorator.
|
|
284
|
+
*/
|
|
285
|
+
export declare function isSummaryField(schema: z.ZodTypeAny): boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Get the isSummaryField decorator parameters.
|
|
288
|
+
* @returns SummaryFieldParams or default empty object if decorator is used without params
|
|
289
|
+
*/
|
|
290
|
+
export declare function getSummaryFieldParams(schema: z.ZodTypeAny): SummaryFieldParams | undefined;
|
|
291
|
+
/**
|
|
292
|
+
* Check if a schema field has the isBackendOnly decorator.
|
|
293
|
+
*/
|
|
294
|
+
export declare function isBackendOnlyField(schema: z.ZodTypeAny): boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Get the isBackendOnly decorator parameters.
|
|
297
|
+
*/
|
|
298
|
+
export declare function getBackendOnlyParams(schema: z.ZodTypeAny): BackendOnlyFieldParams | undefined;
|
|
299
|
+
/**
|
|
300
|
+
* Check if a field has auditAccess enabled via `.isBackendOnly({ auditAccess: true })`.
|
|
301
|
+
* Fields with this flag generate FIELD_ACCESS audit events when included in API responses.
|
|
302
|
+
*/
|
|
303
|
+
export declare function isAuditAccessField(schema: z.ZodTypeAny): boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Check if a schema field has the isDiscriminator decorator.
|
|
306
|
+
*/
|
|
307
|
+
export declare function isDiscriminatorField(schema: z.ZodTypeAny): boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Get the isDiscriminator decorator parameters.
|
|
310
|
+
*/
|
|
311
|
+
export declare function getDiscriminatorParams(schema: z.ZodTypeAny): DiscriminatorFieldParams | undefined;
|
|
312
|
+
/**
|
|
313
|
+
* Check if a schema field has the excludeFromCreate decorator.
|
|
314
|
+
*/
|
|
315
|
+
export declare function isExcludedFromCreate(schema: z.ZodTypeAny): boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Check if a schema field has the excludeFromUpdate decorator.
|
|
318
|
+
*/
|
|
319
|
+
export declare function isExcludedFromUpdate(schema: z.ZodTypeAny): boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Check if a schema field is hidden (recursive traversal through wrappers).
|
|
322
|
+
*/
|
|
323
|
+
export declare function isHiddenField(schema: z.ZodTypeAny): boolean;
|
|
324
|
+
/**
|
|
325
|
+
* Get the isHidden decorator parameters.
|
|
326
|
+
* Returns default params (hidden in both display and edit) when decorator is used without params.
|
|
327
|
+
*/
|
|
328
|
+
export declare function getHiddenFieldParams(schema: z.ZodTypeAny): HiddenFieldParams | undefined;
|
|
329
|
+
/**
|
|
330
|
+
* Check if a schema field is not editable (recursive traversal through wrappers).
|
|
331
|
+
*/
|
|
332
|
+
export declare function isNotEditableField(schema: z.ZodTypeAny): boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Get the isNotEditable decorator parameters.
|
|
335
|
+
*/
|
|
336
|
+
export declare function getNotEditableFieldParams(schema: z.ZodTypeAny): NotEditableFieldParams | undefined;
|
|
337
|
+
/**
|
|
338
|
+
* Check if a schema field has the isUnique decorator (recursive traversal through wrappers).
|
|
339
|
+
*/
|
|
340
|
+
export declare function isUniqueField(schema: z.ZodTypeAny): boolean;
|
|
341
|
+
/**
|
|
342
|
+
* Get the isUnique decorator parameters (recursive traversal through wrappers).
|
|
343
|
+
* Returns default params { scope: 'global', sparse: true } when decorator is used without params.
|
|
344
|
+
*/
|
|
345
|
+
export declare function getUniqueFieldParams(schema: z.ZodTypeAny): UniqueFieldParams | undefined;
|
|
346
|
+
/**
|
|
347
|
+
* Check if a schema field has the isPrimaryKey decorator (recursive traversal through wrappers).
|
|
348
|
+
*/
|
|
349
|
+
export declare function isPrimaryKeyField(schema: z.ZodTypeAny): boolean;
|
|
350
|
+
/**
|
|
351
|
+
* Get all metadata for a schema field (non-recursive, direct access only).
|
|
352
|
+
*/
|
|
353
|
+
export declare function getFieldMetadata(schema: z.ZodTypeAny): CustomFieldMetadata | undefined;
|
|
354
|
+
/**
|
|
355
|
+
* Get all metadata for a schema field, traversing through wrapper types.
|
|
356
|
+
*/
|
|
357
|
+
export declare function getFieldMetadataRecursive(schema: z.ZodTypeAny): CustomFieldMetadata | undefined;
|
|
358
|
+
/**
|
|
359
|
+
* Check if a schema is a range schema (created by z_range()).
|
|
360
|
+
* Detects by the presence of rangeConfig in SCHEMA_METADATA.
|
|
361
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
362
|
+
*/
|
|
363
|
+
export declare function isRangeSchema(schema: z.ZodTypeAny): boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Get the range metadata from a schema.
|
|
366
|
+
* Returns undefined if not a range schema.
|
|
367
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
368
|
+
*/
|
|
369
|
+
export declare function getRangeMetadata(schema: z.ZodTypeAny): RangeSchemaMetadata | undefined;
|
|
370
|
+
/**
|
|
371
|
+
* Get the range type from a schema.
|
|
372
|
+
* Returns undefined if not a range schema.
|
|
373
|
+
*/
|
|
374
|
+
export declare function getRangeType(schema: z.ZodTypeAny): RangeType | undefined;
|
|
375
|
+
/**
|
|
376
|
+
* Check if a schema is a money schema (created by z_money()).
|
|
377
|
+
* Detects by the presence of moneyConfig in SCHEMA_METADATA.
|
|
378
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
379
|
+
*/
|
|
380
|
+
export declare function isMoneySchema(schema: z.ZodTypeAny): boolean;
|
|
381
|
+
/**
|
|
382
|
+
* Get the money metadata from a schema.
|
|
383
|
+
* Returns undefined if not a money schema.
|
|
384
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
385
|
+
*/
|
|
386
|
+
export declare function getMoneyMetadata(schema: z.ZodTypeAny): MoneySchemaMetadata | undefined;
|
|
387
|
+
/**
|
|
388
|
+
* Check if a schema is a bigdecimal schema (created by z_bigdecimal()).
|
|
389
|
+
* Detects by the presence of bigDecimalConfig in SCHEMA_METADATA.
|
|
390
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
391
|
+
*/
|
|
392
|
+
export declare function isBigDecimalSchema(schema: z.ZodTypeAny): boolean;
|
|
393
|
+
/**
|
|
394
|
+
* Get the bigdecimal metadata from a schema.
|
|
395
|
+
* Returns undefined if not a bigdecimal schema.
|
|
396
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
397
|
+
*/
|
|
398
|
+
export declare function getBigDecimalMetadata(schema: z.ZodTypeAny): BigDecimalSchemaMetadata | undefined;
|
|
399
|
+
/**
|
|
400
|
+
* Get bigdecimal constraints from schema metadata.
|
|
401
|
+
* Returns min, max, precision from the bigdecimal schema configuration.
|
|
402
|
+
*/
|
|
403
|
+
export declare function getBigDecimalConstraints(schema: z.ZodTypeAny): {
|
|
404
|
+
min?: string;
|
|
405
|
+
max?: string;
|
|
406
|
+
precision?: number;
|
|
407
|
+
};
|
|
408
|
+
/**
|
|
409
|
+
* Check if a schema is a duration schema (created by z_duration()).
|
|
410
|
+
* Detects by the presence of durationConfig in SCHEMA_METADATA.
|
|
411
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
412
|
+
*/
|
|
413
|
+
export declare function isDurationSchema(schema: z.ZodTypeAny): boolean;
|
|
414
|
+
/**
|
|
415
|
+
* Get the duration metadata from a schema.
|
|
416
|
+
* Returns undefined if not a duration schema.
|
|
417
|
+
*/
|
|
418
|
+
export declare function getDurationMetadata(schema: z.ZodTypeAny): DurationSchemaMetadata | undefined;
|
|
419
|
+
/**
|
|
420
|
+
* Get duration constraints from schema metadata.
|
|
421
|
+
*/
|
|
422
|
+
export declare function getDurationConstraints(schema: z.ZodTypeAny): {
|
|
423
|
+
minValue?: number;
|
|
424
|
+
maxValue?: number;
|
|
425
|
+
allowedUnits?: string[];
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* Check if a schema is a phone schema (created by z_phone()).
|
|
429
|
+
* Detects by the presence of phoneConfig in SCHEMA_METADATA.
|
|
430
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
431
|
+
*/
|
|
432
|
+
export declare function isPhoneSchema(schema: z.ZodTypeAny): boolean;
|
|
433
|
+
/**
|
|
434
|
+
* Get the phone metadata from a schema.
|
|
435
|
+
* Returns undefined if not a phone schema.
|
|
436
|
+
*/
|
|
437
|
+
export declare function getPhoneMetadata(schema: z.ZodTypeAny): PhoneSchemaMetadata | undefined;
|
|
438
|
+
/**
|
|
439
|
+
* Check if a schema is a code schema created by z_code().
|
|
440
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
441
|
+
*/
|
|
442
|
+
export declare function isCodeSchema(schema: z.ZodTypeAny): boolean;
|
|
443
|
+
/**
|
|
444
|
+
* Get code schema metadata if this is a code schema.
|
|
445
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
446
|
+
*/
|
|
447
|
+
export declare function getCodeMetadata(schema: z.ZodTypeAny): CodeSchemaMetadata | undefined;
|
|
448
|
+
/**
|
|
449
|
+
* Check if a schema is a file schema created by z_file().
|
|
450
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
451
|
+
*/
|
|
452
|
+
export declare function isFileSchema(schema: z.ZodTypeAny): boolean;
|
|
453
|
+
/**
|
|
454
|
+
* Get file schema metadata if this is a file schema.
|
|
455
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
456
|
+
*/
|
|
457
|
+
export declare function getFileMetadata(schema: z.ZodTypeAny): FileSchemaMetadata | undefined;
|
|
458
|
+
/**
|
|
459
|
+
* Check if a schema is a versioned foreign key schema created by z_foreignKeyVersioned().
|
|
460
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
461
|
+
*/
|
|
462
|
+
export declare function isVersionedForeignKeySchema(schema: z.ZodTypeAny): boolean;
|
|
463
|
+
/**
|
|
464
|
+
* Get versioned foreign key schema metadata if this is a versioned foreign key schema.
|
|
465
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
466
|
+
*/
|
|
467
|
+
export declare function getVersionedForeignKeyMetadata(schema: z.ZodTypeAny): VersionedForeignKeySchemaMetadata | undefined;
|
|
468
|
+
/**
|
|
469
|
+
* Check if a schema is a versioned object schema created by versioned().
|
|
470
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
471
|
+
*/
|
|
472
|
+
export declare function isVersionedObjectSchema(schema: z.ZodTypeAny): boolean;
|
|
473
|
+
/**
|
|
474
|
+
* Get versioned schema metadata if this is a versioned object schema.
|
|
475
|
+
* Checks both the schema directly and the unwrapped inner schema.
|
|
476
|
+
*/
|
|
477
|
+
export declare function getVersionedObjectMetadata(schema: z.ZodTypeAny): VersionedSchemaMetadata | undefined;
|
|
478
|
+
/**
|
|
479
|
+
* Check if the 'from' field is optional in a range schema.
|
|
480
|
+
*/
|
|
481
|
+
export declare function isRangeFromOptional(schema: z.ZodTypeAny): boolean | undefined;
|
|
482
|
+
/**
|
|
483
|
+
* Check if the 'to' field is optional in a range schema.
|
|
484
|
+
*/
|
|
485
|
+
export declare function isRangeToOptional(schema: z.ZodTypeAny): boolean | undefined;
|
|
486
|
+
/**
|
|
487
|
+
* Get the min constraint from a range schema.
|
|
488
|
+
*/
|
|
489
|
+
export declare function getRangeMin(schema: z.ZodTypeAny): RangeConstraintValue | undefined;
|
|
490
|
+
/**
|
|
491
|
+
* Get the max constraint from a range schema.
|
|
492
|
+
*/
|
|
493
|
+
export declare function getRangeMax(schema: z.ZodTypeAny): RangeConstraintValue | undefined;
|
|
494
|
+
/**
|
|
495
|
+
* Get the form component from `{primitive}UI.edit.component`.
|
|
496
|
+
* Returns undefined if no form component is specified.
|
|
497
|
+
*/
|
|
498
|
+
export declare function getFormFieldComponent(schema: z.ZodTypeAny): FormFieldComponent | undefined;
|
|
499
|
+
/**
|
|
500
|
+
* Check if a field should be hidden based on the current context.
|
|
501
|
+
* @param schema - The Zod schema to check
|
|
502
|
+
* @param context - Optional context with mode ('display' | 'edit') and operation name
|
|
503
|
+
*/
|
|
504
|
+
export declare function shouldHideField(schema: z.ZodTypeAny, context?: {
|
|
505
|
+
mode?: 'display' | 'edit';
|
|
506
|
+
operation?: string;
|
|
507
|
+
}): boolean;
|
|
508
|
+
export declare function isFormInput(schema: z.ZodTypeAny): boolean;
|
|
509
|
+
export declare function isFormTextarea(schema: z.ZodTypeAny): boolean;
|
|
510
|
+
export declare function isFormSelect(schema: z.ZodTypeAny): boolean;
|
|
511
|
+
export declare function isFormRadioGroup(schema: z.ZodTypeAny): boolean;
|
|
512
|
+
export declare function isFormCheckbox(schema: z.ZodTypeAny): boolean;
|
|
513
|
+
export declare function isFormCheckboxGroup(schema: z.ZodTypeAny): boolean;
|
|
514
|
+
export declare function isFormSwitch(schema: z.ZodTypeAny): boolean;
|
|
515
|
+
export declare function isFormSlider(schema: z.ZodTypeAny): boolean;
|
|
516
|
+
export declare function isFormDate(schema: z.ZodTypeAny): boolean;
|
|
517
|
+
/**
|
|
518
|
+
* Get the hidden field metadata from schema decorator.
|
|
519
|
+
* Returns undefined if no hidden decorator is set.
|
|
520
|
+
* Returns true if field is hidden in all cases.
|
|
521
|
+
* Returns HiddenFieldParams if conditional hiding is configured.
|
|
522
|
+
* Note: getCustomFieldMetadata already handles recursive unwrapping for all wrapper types
|
|
523
|
+
* including pipe (from refine/superRefine), optional, nullable, default, etc.
|
|
524
|
+
*/
|
|
525
|
+
export declare function getHiddenFieldMetadata(schema: z.ZodTypeAny): HiddenFieldParams | true | undefined;
|
|
526
|
+
/**
|
|
527
|
+
* Check if a schema has a hidden decorator.
|
|
528
|
+
*/
|
|
529
|
+
export declare function hasHiddenDecorator(schema: z.ZodTypeAny): boolean;
|
|
530
|
+
/**
|
|
531
|
+
* Check if a field should be hidden for display mode.
|
|
532
|
+
* @param schema - The Zod schema to check
|
|
533
|
+
* @returns true if the field should be hidden in display mode
|
|
534
|
+
*/
|
|
535
|
+
export declare function isHiddenForDisplay(schema: z.ZodTypeAny): boolean;
|
|
536
|
+
/**
|
|
537
|
+
* Check if a field should be hidden for edit mode.
|
|
538
|
+
* @param schema - The Zod schema to check
|
|
539
|
+
* @returns true if the field should be hidden in edit mode
|
|
540
|
+
*/
|
|
541
|
+
export declare function isHiddenForEdit(schema: z.ZodTypeAny): boolean;
|
|
542
|
+
/**
|
|
543
|
+
* Check if a field should be hidden for a specific operation.
|
|
544
|
+
* @param schema - The Zod schema to check
|
|
545
|
+
* @param operation - The operation identifier (e.g., 'create', 'update')
|
|
546
|
+
* @returns true if the field should be hidden for the given operation
|
|
547
|
+
*/
|
|
548
|
+
export declare function isHiddenForOperation(schema: z.ZodTypeAny, operation: string): boolean;
|
|
549
|
+
/**
|
|
550
|
+
* Get the not editable field metadata from schema decorator.
|
|
551
|
+
* Returns undefined if no isNotEditable decorator is set.
|
|
552
|
+
* Returns true if field is not editable for all operations.
|
|
553
|
+
* Returns NotEditableFieldParams if operation-specific.
|
|
554
|
+
* Note: getCustomFieldMetadata already handles recursive unwrapping for all wrapper types
|
|
555
|
+
* including pipe (from refine/superRefine), optional, nullable, default, etc.
|
|
556
|
+
*/
|
|
557
|
+
export declare function getNotEditableFieldMetadata(schema: z.ZodTypeAny): NotEditableFieldParams | true | undefined;
|
|
558
|
+
/**
|
|
559
|
+
* Check if a schema has a isNotEditable decorator.
|
|
560
|
+
*/
|
|
561
|
+
export declare function hasNotEditableDecorator(schema: z.ZodTypeAny): boolean;
|
|
562
|
+
/**
|
|
563
|
+
* Check if a field is not editable for a specific operation (or all operations).
|
|
564
|
+
* @param schema - The Zod schema to check
|
|
565
|
+
* @param operation - Optional operation identifier. If not provided, checks if not editable for all operations.
|
|
566
|
+
* @returns true if the field is not editable
|
|
567
|
+
*/
|
|
568
|
+
export declare function isNotEditableForOperation(schema: z.ZodTypeAny, operation?: string): boolean;
|
|
569
|
+
/**
|
|
570
|
+
* Resolved inline editable params with all defaults applied.
|
|
571
|
+
*/
|
|
572
|
+
export interface ResolvedInlineEditableParams {
|
|
573
|
+
mode: 'direct' | 'button';
|
|
574
|
+
saveOn: 'blur' | 'explicit';
|
|
575
|
+
showSaveButton: boolean;
|
|
576
|
+
showCancelButton: boolean;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Check if a schema has inline editable configuration.
|
|
580
|
+
* Reads from `{primitive}UI.display.inlineEditable`.
|
|
581
|
+
*/
|
|
582
|
+
export declare function hasInlineEditableDecorator(schema: z.ZodTypeAny): boolean;
|
|
583
|
+
/**
|
|
584
|
+
* Get the resolved inline editable params from `{primitive}UI.display.inlineEditable`.
|
|
585
|
+
* Handles both `true` shorthand and full object config.
|
|
586
|
+
*/
|
|
587
|
+
export declare function getInlineEditableParams(schema: z.ZodTypeAny): ResolvedInlineEditableParams | undefined;
|
|
588
|
+
/**
|
|
589
|
+
* Extract the `.describe()` text from a Zod schema, unwrapping optional/nullable/default wrappers.
|
|
590
|
+
* Returns undefined if no `.describe("...")` is set.
|
|
591
|
+
*
|
|
592
|
+
* **IMPORTANT**: Zod `.describe("...")` is for developer documentation, AI prompting systems,
|
|
593
|
+
* and API documentation generation. It is NOT used for UI field descriptions — those are
|
|
594
|
+
* managed through `{primitive}UI.display.showDescription` + i18n system.
|
|
595
|
+
*
|
|
596
|
+
* In Zod 4, `.describe("...")` sets the `.description` property on the schema.
|
|
597
|
+
* When `.optional()`, `.nullable()`, or `.default()` wrap the schema, the description
|
|
598
|
+
* may live on the inner schema. We check both levels.
|
|
599
|
+
*/
|
|
600
|
+
export declare function getZodDescription(schema: z.ZodTypeAny): string | undefined;
|
|
601
|
+
/**
|
|
602
|
+
* Check if a field should have a description i18n key generated for **display** mode.
|
|
603
|
+
*
|
|
604
|
+
* Reads from `{primitive}UI.display.showDescription` (boolean flag).
|
|
605
|
+
* This follows the same opt-in pattern as tooltips: only generate i18n keys for
|
|
606
|
+
* fields that explicitly declare intent via a decorator.
|
|
607
|
+
*
|
|
608
|
+
* **NOTE**: Zod `.describe("...")` is NOT an opt-in signal for UI descriptions.
|
|
609
|
+
* `.describe()` serves a different purpose (developer docs, AI prompting, API docs).
|
|
610
|
+
* UI field descriptions are purely decorator-driven + i18n-resolved.
|
|
611
|
+
*
|
|
612
|
+
* @param schema - The Zod schema to check
|
|
613
|
+
* @returns true if a description i18n key should be generated for display mode
|
|
614
|
+
*/
|
|
615
|
+
export declare function hasDescriptionForDisplay(schema: z.ZodTypeAny): boolean;
|
|
616
|
+
/**
|
|
617
|
+
* Check if a field should have a description i18n key generated for **edit** mode.
|
|
618
|
+
*
|
|
619
|
+
* Reads from `{primitive}UI.edit.showDescription` (boolean flag).
|
|
620
|
+
* If a field declares it wants a description, both display AND edit i18n keys are generated
|
|
621
|
+
* so translators can provide mode-appropriate text.
|
|
622
|
+
*
|
|
623
|
+
* @param schema - The Zod schema to check
|
|
624
|
+
* @returns true if a description i18n key should be generated for edit mode
|
|
625
|
+
*/
|
|
626
|
+
export declare function hasDescriptionForEdit(schema: z.ZodTypeAny): boolean;
|
|
627
|
+
/**
|
|
628
|
+
* Check if a string schema should render as a password input.
|
|
629
|
+
* Checks IS_PASSWORD structural marker first, then STRING_UI editMode fallback.
|
|
630
|
+
*/
|
|
631
|
+
export declare function isPasswordField(schema: z.ZodTypeAny): boolean;
|
|
632
|
+
/**
|
|
633
|
+
* Check if a string schema should render as an OTP input.
|
|
634
|
+
* Checks IS_OTP structural marker first, then STRING_UI editMode fallback.
|
|
635
|
+
*/
|
|
636
|
+
export declare function isOtpField(schema: z.ZodTypeAny): boolean;
|
|
637
|
+
/**
|
|
638
|
+
* Check if a string schema should render as a color input.
|
|
639
|
+
* Checks IS_COLOR structural marker first, then STRING_UI editMode fallback.
|
|
640
|
+
*/
|
|
641
|
+
export declare function isColorField(schema: z.ZodTypeAny): boolean;
|
|
642
|
+
/**
|
|
643
|
+
* Get OTP field params from a schema.
|
|
644
|
+
* Returns the OTP params with defaults merged in if the decorator is present.
|
|
645
|
+
* Defaults: maxLength=6
|
|
646
|
+
*/
|
|
647
|
+
export declare function getOtpFieldParams(schema: z.ZodTypeAny): OtpFieldParams | undefined;
|
|
648
|
+
/**
|
|
649
|
+
* Get the system enum name from a schema's metadata.
|
|
650
|
+
* Returns the name string (e.g. 'AvailableCurrency') if the .systemEnum() decorator is set,
|
|
651
|
+
* or undefined if the field is not a system enum.
|
|
652
|
+
*/
|
|
653
|
+
export declare function getSystemEnumName(schema: z.ZodTypeAny): string | undefined;
|
|
654
|
+
/**
|
|
655
|
+
* Serialize a Zod schema to a JSON-serializable format.
|
|
656
|
+
* Uses Zod 4 internal structure (_zod.def.type).
|
|
657
|
+
*/
|
|
658
|
+
export declare function serializeZodSchema(schema: z.ZodTypeAny | undefined, seen?: Set<z.ZodTypeAny>): SerializableZodSchema | null;
|
|
659
|
+
/**
|
|
660
|
+
* Deserialize a SerializableZodSchema back into a Zod schema.
|
|
661
|
+
* - Reconstructs approximate Zod types from the descriptor
|
|
662
|
+
* - Re-applies optional/nullable wrappers
|
|
663
|
+
* - Re-applies SCHEMA_METADATA as decorators when possible
|
|
664
|
+
*/
|
|
665
|
+
export declare function deserializeZodSchema(desc: SerializableZodSchema | null | undefined): any;
|
|
666
|
+
/**
|
|
667
|
+
* Check if a schema is marked as a virtual field.
|
|
668
|
+
* Virtual fields are computed at runtime and not stored in the database.
|
|
669
|
+
*/
|
|
670
|
+
export declare function isVirtualField(schema: z.ZodTypeAny): boolean;
|
|
671
|
+
/**
|
|
672
|
+
* Get the virtual field parameters from a schema.
|
|
673
|
+
* Returns undefined if the field is not virtual.
|
|
674
|
+
*/
|
|
675
|
+
export declare function getVirtualFieldParams(schema: z.ZodTypeAny): VirtualFieldParams | undefined;
|
|
676
|
+
/**
|
|
677
|
+
* Get the dependencies declared for a virtual field.
|
|
678
|
+
* Returns an empty array if no dependencies are declared or the field is not virtual.
|
|
679
|
+
*/
|
|
680
|
+
export declare function getVirtualFieldDependencies(schema: z.ZodTypeAny): string[];
|
|
681
|
+
/**
|
|
682
|
+
* Check if a virtual field needs object context (parents/children) for computation.
|
|
683
|
+
*/
|
|
684
|
+
export declare function virtualFieldNeedsObjectContext(schema: z.ZodTypeAny): boolean;
|
|
685
|
+
/**
|
|
686
|
+
* Check if a virtual field needs user context for computation.
|
|
687
|
+
*/
|
|
688
|
+
export declare function virtualFieldNeedsUserContext(schema: z.ZodTypeAny): boolean;
|
|
689
|
+
/**
|
|
690
|
+
* Operation type for schema preparation.
|
|
691
|
+
*/
|
|
692
|
+
export type FormSchemaOperationType = 'CREATE' | 'UPDATE' | 'READ';
|
|
693
|
+
/**
|
|
694
|
+
* Options for prepareFormSchema utility.
|
|
695
|
+
*/
|
|
696
|
+
export interface PrepareFormSchemaOptions {
|
|
697
|
+
/**
|
|
698
|
+
* The operation type (CREATE, UPDATE, or READ).
|
|
699
|
+
* Used to filter excludeFromCreate/excludeFromUpdate fields.
|
|
700
|
+
*/
|
|
701
|
+
operationType: FormSchemaOperationType;
|
|
702
|
+
/**
|
|
703
|
+
* Whether the form is in draft mode.
|
|
704
|
+
* When true, fields with isDraftRelaxed() become optional.
|
|
705
|
+
* @default false
|
|
706
|
+
*/
|
|
707
|
+
isDraftMode?: boolean;
|
|
708
|
+
/**
|
|
709
|
+
* Optional operation that behaves like a core operation.
|
|
710
|
+
* For example, 'DUPLICATE' might behave like 'CREATE'.
|
|
711
|
+
*/
|
|
712
|
+
operationLike?: FormSchemaOperationType;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Check if a field should be excluded from form validation based on its decorators.
|
|
716
|
+
*/
|
|
717
|
+
export declare function shouldExcludeFieldFromForm(fieldSchema: z.ZodTypeAny, operationType: FormSchemaOperationType): boolean;
|
|
718
|
+
/**
|
|
719
|
+
* Check if a field has isDraftRelaxed decorator.
|
|
720
|
+
*/
|
|
721
|
+
export declare function isDraftRelaxedField(fieldSchema: z.ZodTypeAny): boolean;
|
|
722
|
+
/**
|
|
723
|
+
* Prepare a schema for form validation by filtering out fields that shouldn't be validated
|
|
724
|
+
* and adjusting optionality based on draft mode.
|
|
725
|
+
*
|
|
726
|
+
* This function:
|
|
727
|
+
* - Removes virtual fields
|
|
728
|
+
* - Removes backend-only fields
|
|
729
|
+
* - Removes hidden fields
|
|
730
|
+
* - Removes excludeFromCreate fields (for CREATE operations)
|
|
731
|
+
* - Removes excludeFromUpdate fields (for UPDATE operations)
|
|
732
|
+
* - Makes isDraftRelaxed fields optional when in draft mode
|
|
733
|
+
*
|
|
734
|
+
* **WARNING: Schema-level refinements (.refine(), .superRefine()) are NOT carried over.**
|
|
735
|
+
* The returned schema is a new z.object() with the filtered shape — any cross-field
|
|
736
|
+
* validation defined via refinements on the original schema will be silently lost.
|
|
737
|
+
* This is intentional for draft mode (draft = relaxed validation), but callers using
|
|
738
|
+
* this outside of draft mode should be aware that cross-field rules won't apply.
|
|
739
|
+
* For non-draft form validation, use the original schema (e.g., operation.requestDto) directly.
|
|
740
|
+
*
|
|
741
|
+
* @param schema - The original object schema
|
|
742
|
+
* @param options - Preparation options
|
|
743
|
+
* @returns A new schema suitable for form validation (without schema-level refinements)
|
|
744
|
+
*/
|
|
745
|
+
export declare function prepareFormSchema<T extends z.ZodObject<z.ZodRawShape>>(schema: T, options: PrepareFormSchemaOptions): z.ZodObject<z.ZodRawShape>;
|
|
746
|
+
/**
|
|
747
|
+
* Check if a schema field is marked as ephemeral (transient response-only data).
|
|
748
|
+
* Ephemeral fields are shown once (e.g., API keys upon creation) and not persisted in the UI.
|
|
749
|
+
*/
|
|
750
|
+
export declare function isEphemeralField(schema: z.ZodTypeAny): boolean;
|
|
751
|
+
export declare function getBooleanUI(schema: z.ZodTypeAny): BooleanUIParams | undefined;
|
|
752
|
+
export declare function hasBooleanUI(schema: z.ZodTypeAny): boolean;
|
|
753
|
+
export declare function getStringUI(schema: z.ZodTypeAny): StringUIParams | undefined;
|
|
754
|
+
export declare function hasStringUI(schema: z.ZodTypeAny): boolean;
|
|
755
|
+
export declare function getNumberUI(schema: z.ZodTypeAny): NumberUIParams | undefined;
|
|
756
|
+
export declare function hasNumberUI(schema: z.ZodTypeAny): boolean;
|
|
757
|
+
export declare function getEnumUI(schema: z.ZodTypeAny): EnumUIParams | undefined;
|
|
758
|
+
export declare function hasEnumUI(schema: z.ZodTypeAny): boolean;
|
|
759
|
+
export declare function getDateUI(schema: z.ZodTypeAny): DateUIParams | undefined;
|
|
760
|
+
export declare function hasDateUI(schema: z.ZodTypeAny): boolean;
|
|
761
|
+
export declare function getDateTimeUI(schema: z.ZodTypeAny): DateTimeUIParams | undefined;
|
|
762
|
+
export declare function hasDateTimeUI(schema: z.ZodTypeAny): boolean;
|
|
763
|
+
export declare function getTimeUI(schema: z.ZodTypeAny): TimeUIParams | undefined;
|
|
764
|
+
export declare function hasTimeUI(schema: z.ZodTypeAny): boolean;
|
|
765
|
+
export declare function getMoneyUI(schema: z.ZodTypeAny): MoneyUIParams | undefined;
|
|
766
|
+
export declare function hasMoneyUI(schema: z.ZodTypeAny): boolean;
|
|
767
|
+
export declare function getCodeUI(schema: z.ZodTypeAny): CodeUIParams | undefined;
|
|
768
|
+
export declare function hasCodeUI(schema: z.ZodTypeAny): boolean;
|
|
769
|
+
export declare function getFileUI(schema: z.ZodTypeAny): FileUIParams | undefined;
|
|
770
|
+
export declare function hasFileUI(schema: z.ZodTypeAny): boolean;
|
|
771
|
+
export declare function getDurationUI(schema: z.ZodTypeAny): DurationUIParams | undefined;
|
|
772
|
+
export declare function hasDurationUI(schema: z.ZodTypeAny): boolean;
|
|
773
|
+
export declare function getPhoneUI(schema: z.ZodTypeAny): PhoneUIParams | undefined;
|
|
774
|
+
export declare function hasPhoneUI(schema: z.ZodTypeAny): boolean;
|
|
775
|
+
export declare function getBigDecimalUI(schema: z.ZodTypeAny): BigDecimalUIParams | undefined;
|
|
776
|
+
export declare function hasBigDecimalUI(schema: z.ZodTypeAny): boolean;
|
|
777
|
+
export declare function getForeignKeyUI(schema: z.ZodTypeAny): ForeignKeyUIParams | undefined;
|
|
778
|
+
export declare function hasForeignKeyUI(schema: z.ZodTypeAny): boolean;
|
|
779
|
+
export declare function getArrayUI(schema: z.ZodTypeAny): ArrayUIParams | undefined;
|
|
780
|
+
export declare function hasArrayUI(schema: z.ZodTypeAny): boolean;
|
|
781
|
+
export declare function getObjectUI(schema: z.ZodTypeAny): ObjectUIParams | undefined;
|
|
782
|
+
export declare function hasObjectUI(schema: z.ZodTypeAny): boolean;
|
|
783
|
+
//# sourceMappingURL=zod-utils.shared.d.ts.map
|