@remotion/studio 4.0.424 → 4.0.426
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/api/create-composition.d.ts +1 -2
- package/dist/api/helpers/calc-new-props.d.ts +1 -2
- package/dist/components/AssetSelector.js +1 -1
- package/dist/components/AssetSelectorItem.d.ts +1 -0
- package/dist/components/AssetSelectorItem.js +9 -8
- package/dist/components/InitialCompositionLoader.js +13 -1
- package/dist/components/NewComposition/CodemodFooter.d.ts +1 -0
- package/dist/components/NewComposition/CodemodFooter.js +3 -1
- package/dist/components/NewComposition/DeleteComposition.js +1 -1
- package/dist/components/NewComposition/DuplicateComposition.js +5 -1
- package/dist/components/NewComposition/RenameComposition.js +1 -1
- package/dist/components/RenderModal/DataEditor.d.ts +2 -1
- package/dist/components/RenderModal/DataEditor.js +6 -6
- package/dist/components/RenderModal/RenderModalJSONPropsEditor.d.ts +2 -2
- package/dist/components/RenderModal/RenderModalJSONPropsEditor.js +3 -2
- package/dist/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +3 -3
- package/dist/components/RenderModal/SchemaEditor/SchemaEditor.js +4 -5
- package/dist/components/RenderModal/SchemaEditor/SchemaErrorMessages.d.ts +3 -3
- package/dist/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +1 -0
- package/dist/components/RenderModal/SchemaEditor/SchemaSeparationLine.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/SchemaSeparationLine.js +4 -3
- package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.js +3 -6
- package/dist/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +2 -1
- package/dist/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodDefaultEditor.d.ts +3 -3
- package/dist/components/RenderModal/SchemaEditor/ZodDefaultEditor.js +2 -1
- package/dist/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.js +18 -18
- package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.js +6 -10
- package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.js +4 -12
- package/dist/components/RenderModal/SchemaEditor/ZodErrorMessages.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodErrorMessages.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodFieldValidation.js +4 -3
- package/dist/components/RenderModal/SchemaEditor/ZodMatrixEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodMatrixEditor.js +3 -2
- package/dist/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodNullableEditor.js +2 -1
- package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.js +49 -21
- package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.js +4 -9
- package/dist/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +2 -1
- package/dist/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +3 -3
- package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +0 -10
- package/dist/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodSwitch.js +38 -33
- package/dist/components/RenderModal/SchemaEditor/ZodTextareaEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodTupleEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodTupleEditor.js +3 -6
- package/dist/components/RenderModal/SchemaEditor/ZodTupleItemEditor.d.ts +2 -1
- package/dist/components/RenderModal/SchemaEditor/ZodTupleItemEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodUnionEditor.js +11 -15
- package/dist/components/RenderModal/SchemaEditor/create-zod-values.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/create-zod-values.js +108 -110
- package/dist/components/RenderModal/SchemaEditor/extract-enum-json-paths.d.ts +3 -3
- package/dist/components/RenderModal/SchemaEditor/extract-enum-json-paths.js +72 -87
- package/dist/components/RenderModal/SchemaEditor/local-state.d.ts +3 -3
- package/dist/components/RenderModal/SchemaEditor/local-state.js +5 -4
- package/dist/components/RenderModal/SchemaEditor/zod-schema-type.d.ts +176 -0
- package/dist/components/RenderModal/SchemaEditor/zod-schema-type.js +330 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Tabs/vertical.js +2 -0
- package/dist/components/TimeValue.js +0 -2
- package/dist/components/Timeline/TimelineDragHandler.js +6 -0
- package/dist/components/get-zod-if-possible.d.ts +3 -0
- package/dist/components/get-zod-if-possible.js +23 -2
- package/dist/esm/{chunk-3g77e2p9.js → chunk-kde77jse.js} +589 -373
- package/dist/esm/index.mjs +170 -81
- package/dist/esm/internals.mjs +589 -373
- package/dist/esm/previewEntry.mjs +598 -375
- package/dist/esm/renderEntry.mjs +1 -1
- package/dist/helpers/inject-css.js +2 -1
- package/dist/index.d.ts +2 -2
- package/dist/previewEntry.d.ts +5 -0
- package/dist/previewEntry.js +11 -2
- package/dist/visual-controls/VisualControls.d.ts +4 -4
- package/dist/visual-controls/VisualControls.js +1 -1
- package/package.json +11 -11
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractEnumJsonPaths = void 0;
|
|
4
|
+
const zod_schema_type_1 = require("./zod-schema-type");
|
|
4
5
|
const extractEnumJsonPaths = ({ schema, zodRuntime, currentPath, zodTypes, }) => {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
// In v4, .refine()/.describe() don't wrap in effects — the description
|
|
7
|
+
// lives directly on the schema. Check for branded descriptions early
|
|
8
|
+
// so they are detected regardless of the underlying type.
|
|
9
|
+
const description = (0, zod_schema_type_1.getZodSchemaDescription)(schema);
|
|
10
|
+
if (zodTypes &&
|
|
11
|
+
description === zodTypes.ZodZypesInternals.REMOTION_MATRIX_BRAND) {
|
|
12
|
+
return [currentPath];
|
|
13
|
+
}
|
|
14
|
+
const typeName = (0, zod_schema_type_1.getZodSchemaType)(schema);
|
|
7
15
|
switch (typeName) {
|
|
8
|
-
case
|
|
9
|
-
const shape =
|
|
16
|
+
case 'object': {
|
|
17
|
+
const shape = (0, zod_schema_type_1.getObjectShape)(schema);
|
|
10
18
|
const keys = Object.keys(shape);
|
|
11
19
|
return keys
|
|
12
20
|
.map((key) => {
|
|
@@ -19,16 +27,16 @@ const extractEnumJsonPaths = ({ schema, zodRuntime, currentPath, zodTypes, }) =>
|
|
|
19
27
|
})
|
|
20
28
|
.flat(1);
|
|
21
29
|
}
|
|
22
|
-
case
|
|
30
|
+
case 'array': {
|
|
23
31
|
return (0, exports.extractEnumJsonPaths)({
|
|
24
|
-
schema:
|
|
32
|
+
schema: (0, zod_schema_type_1.getArrayElement)(schema),
|
|
25
33
|
zodRuntime,
|
|
26
34
|
currentPath: [...currentPath, '[]'],
|
|
27
35
|
zodTypes,
|
|
28
36
|
});
|
|
29
37
|
}
|
|
30
|
-
case
|
|
31
|
-
return
|
|
38
|
+
case 'union': {
|
|
39
|
+
return (0, zod_schema_type_1.getUnionOptions)(schema)
|
|
32
40
|
.map((option) => {
|
|
33
41
|
return (0, exports.extractEnumJsonPaths)({
|
|
34
42
|
schema: option,
|
|
@@ -39,8 +47,8 @@ const extractEnumJsonPaths = ({ schema, zodRuntime, currentPath, zodTypes, }) =>
|
|
|
39
47
|
})
|
|
40
48
|
.flat(1);
|
|
41
49
|
}
|
|
42
|
-
case
|
|
43
|
-
return
|
|
50
|
+
case 'discriminatedUnion': {
|
|
51
|
+
return (0, zod_schema_type_1.getUnionOptions)(schema)
|
|
44
52
|
.map((op) => {
|
|
45
53
|
return (0, exports.extractEnumJsonPaths)({
|
|
46
54
|
schema: op,
|
|
@@ -51,24 +59,19 @@ const extractEnumJsonPaths = ({ schema, zodRuntime, currentPath, zodTypes, }) =>
|
|
|
51
59
|
})
|
|
52
60
|
.flat(1);
|
|
53
61
|
}
|
|
54
|
-
case
|
|
62
|
+
case 'literal': {
|
|
55
63
|
return [currentPath];
|
|
56
64
|
}
|
|
57
|
-
case
|
|
58
|
-
if (zodTypes &&
|
|
59
|
-
schema._def.description ===
|
|
60
|
-
zodTypes.ZodZypesInternals.REMOTION_MATRIX_BRAND) {
|
|
61
|
-
return [currentPath];
|
|
62
|
-
}
|
|
65
|
+
case 'effects': {
|
|
63
66
|
return (0, exports.extractEnumJsonPaths)({
|
|
64
|
-
schema:
|
|
67
|
+
schema: (0, zod_schema_type_1.getEffectsInner)(schema),
|
|
65
68
|
zodRuntime,
|
|
66
69
|
currentPath,
|
|
67
70
|
zodTypes,
|
|
68
71
|
});
|
|
69
72
|
}
|
|
70
|
-
case
|
|
71
|
-
const { left, right } =
|
|
73
|
+
case 'intersection': {
|
|
74
|
+
const { left, right } = (0, zod_schema_type_1.getIntersectionSchemas)(schema);
|
|
72
75
|
const leftValue = (0, exports.extractEnumJsonPaths)({
|
|
73
76
|
schema: left,
|
|
74
77
|
zodRuntime,
|
|
@@ -83,8 +86,8 @@ const extractEnumJsonPaths = ({ schema, zodRuntime, currentPath, zodTypes, }) =>
|
|
|
83
86
|
});
|
|
84
87
|
return [...leftValue, ...rightValue];
|
|
85
88
|
}
|
|
86
|
-
case
|
|
87
|
-
return
|
|
89
|
+
case 'tuple': {
|
|
90
|
+
return (0, zod_schema_type_1.getTupleItems)(schema)
|
|
88
91
|
.map((item, i) => (0, exports.extractEnumJsonPaths)({
|
|
89
92
|
schema: item,
|
|
90
93
|
zodRuntime,
|
|
@@ -93,104 +96,86 @@ const extractEnumJsonPaths = ({ schema, zodRuntime, currentPath, zodTypes, }) =>
|
|
|
93
96
|
}))
|
|
94
97
|
.flat(1);
|
|
95
98
|
}
|
|
96
|
-
case
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
+
case 'record': {
|
|
100
|
+
const recordPath = [...currentPath, '{}'];
|
|
101
|
+
const keyResults = (0, exports.extractEnumJsonPaths)({
|
|
102
|
+
schema: (0, zod_schema_type_1.getRecordKeyType)(schema),
|
|
99
103
|
zodRuntime,
|
|
100
|
-
currentPath:
|
|
104
|
+
currentPath: recordPath,
|
|
101
105
|
zodTypes,
|
|
102
106
|
});
|
|
103
|
-
|
|
107
|
+
const valueResults = (0, exports.extractEnumJsonPaths)({
|
|
108
|
+
schema: (0, zod_schema_type_1.getRecordValueType)(schema),
|
|
109
|
+
zodRuntime,
|
|
110
|
+
currentPath: recordPath,
|
|
111
|
+
zodTypes,
|
|
112
|
+
});
|
|
113
|
+
return [...keyResults, ...valueResults];
|
|
104
114
|
}
|
|
105
|
-
case
|
|
115
|
+
case 'function': {
|
|
106
116
|
throw new Error('Cannot create a value for type function');
|
|
107
117
|
}
|
|
108
|
-
case
|
|
118
|
+
case 'enum': {
|
|
109
119
|
return [currentPath];
|
|
110
120
|
}
|
|
111
|
-
case
|
|
121
|
+
case 'nativeEnum': {
|
|
112
122
|
return [];
|
|
113
123
|
}
|
|
114
|
-
case
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
schema: defType.innerType,
|
|
118
|
-
zodRuntime,
|
|
119
|
-
currentPath,
|
|
120
|
-
zodTypes,
|
|
121
|
-
});
|
|
122
|
-
return value;
|
|
123
|
-
}
|
|
124
|
-
case zodRuntime.ZodFirstPartyTypeKind.ZodNullable: {
|
|
125
|
-
const defType = def;
|
|
126
|
-
const value = (0, exports.extractEnumJsonPaths)({
|
|
127
|
-
schema: defType.innerType,
|
|
128
|
-
zodRuntime,
|
|
129
|
-
currentPath,
|
|
130
|
-
zodTypes,
|
|
131
|
-
});
|
|
132
|
-
return value;
|
|
133
|
-
}
|
|
134
|
-
case zodRuntime.ZodFirstPartyTypeKind.ZodDefault: {
|
|
135
|
-
const defType = def;
|
|
124
|
+
case 'optional':
|
|
125
|
+
case 'nullable':
|
|
126
|
+
case 'catch': {
|
|
136
127
|
return (0, exports.extractEnumJsonPaths)({
|
|
137
|
-
schema:
|
|
128
|
+
schema: (0, zod_schema_type_1.getInnerType)(schema),
|
|
138
129
|
zodRuntime,
|
|
139
130
|
currentPath,
|
|
140
131
|
zodTypes,
|
|
141
132
|
});
|
|
142
133
|
}
|
|
143
|
-
case
|
|
144
|
-
const defType = def;
|
|
134
|
+
case 'default': {
|
|
145
135
|
return (0, exports.extractEnumJsonPaths)({
|
|
146
|
-
schema:
|
|
136
|
+
schema: (0, zod_schema_type_1.getInnerType)(schema),
|
|
147
137
|
zodRuntime,
|
|
148
138
|
currentPath,
|
|
149
139
|
zodTypes,
|
|
150
140
|
});
|
|
151
141
|
}
|
|
152
|
-
case
|
|
142
|
+
case 'promise': {
|
|
153
143
|
return [];
|
|
154
144
|
}
|
|
155
|
-
case
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const value = (0, exports.extractEnumJsonPaths)({
|
|
159
|
-
schema: defType.type,
|
|
145
|
+
case 'branded': {
|
|
146
|
+
return (0, exports.extractEnumJsonPaths)({
|
|
147
|
+
schema: (0, zod_schema_type_1.getBrandedInner)(schema),
|
|
160
148
|
zodRuntime,
|
|
161
149
|
currentPath,
|
|
162
150
|
zodTypes,
|
|
163
151
|
});
|
|
164
|
-
return value;
|
|
165
152
|
}
|
|
166
|
-
case
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
schema: defType.out,
|
|
153
|
+
case 'pipeline':
|
|
154
|
+
case 'pipe': {
|
|
155
|
+
return (0, exports.extractEnumJsonPaths)({
|
|
156
|
+
schema: (0, zod_schema_type_1.getPipelineOutput)(schema),
|
|
171
157
|
zodRuntime,
|
|
172
158
|
currentPath,
|
|
173
159
|
zodTypes,
|
|
174
160
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
case
|
|
178
|
-
case
|
|
179
|
-
case
|
|
180
|
-
case
|
|
181
|
-
case
|
|
182
|
-
case
|
|
183
|
-
case
|
|
184
|
-
case
|
|
185
|
-
case
|
|
186
|
-
case
|
|
187
|
-
case
|
|
188
|
-
case
|
|
189
|
-
case
|
|
190
|
-
case
|
|
191
|
-
case
|
|
192
|
-
case
|
|
193
|
-
// Sets are not serializable
|
|
161
|
+
}
|
|
162
|
+
case 'string':
|
|
163
|
+
case 'number':
|
|
164
|
+
case 'bigint':
|
|
165
|
+
case 'boolean':
|
|
166
|
+
case 'nan':
|
|
167
|
+
case 'date':
|
|
168
|
+
case 'symbol':
|
|
169
|
+
case 'undefined':
|
|
170
|
+
case 'null':
|
|
171
|
+
case 'any':
|
|
172
|
+
case 'unknown':
|
|
173
|
+
case 'never':
|
|
174
|
+
case 'void':
|
|
175
|
+
case 'map':
|
|
176
|
+
case 'lazy':
|
|
177
|
+
case 'set':
|
|
178
|
+
case 'custom': {
|
|
194
179
|
return [];
|
|
195
180
|
}
|
|
196
181
|
default:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { z } from 'zod';
|
|
3
2
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
3
|
+
import type { AnyZodSchema, ZodSafeParseResult } from './zod-schema-type';
|
|
4
4
|
export type LocalState<T> = {
|
|
5
5
|
value: T;
|
|
6
|
-
zodValidation:
|
|
6
|
+
zodValidation: ZodSafeParseResult;
|
|
7
7
|
keyStabilityRevision: number;
|
|
8
8
|
};
|
|
9
9
|
export type RevisionContextType = {
|
|
@@ -12,7 +12,7 @@ export type RevisionContextType = {
|
|
|
12
12
|
export declare const RevisionContext: React.Context<RevisionContextType>;
|
|
13
13
|
export declare const useLocalState: <T>({ unsavedValue, schema, setValue, savedValue, }: {
|
|
14
14
|
unsavedValue: T;
|
|
15
|
-
schema:
|
|
15
|
+
schema: AnyZodSchema;
|
|
16
16
|
setValue: UpdaterFunction<T>;
|
|
17
17
|
savedValue: T;
|
|
18
18
|
}) => {
|
|
@@ -5,6 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const remotion_1 = require("remotion");
|
|
7
7
|
const deep_equal_1 = require("./deep-equal");
|
|
8
|
+
const zod_schema_type_1 = require("./zod-schema-type");
|
|
8
9
|
exports.RevisionContext = (0, react_1.createContext)({
|
|
9
10
|
childResetRevision: 0,
|
|
10
11
|
});
|
|
@@ -16,7 +17,7 @@ const useLocalState = ({ unsavedValue, schema, setValue, savedValue, }) => {
|
|
|
16
17
|
[parentRevision]: {
|
|
17
18
|
value: unsavedValue,
|
|
18
19
|
keyStabilityRevision: 0,
|
|
19
|
-
zodValidation:
|
|
20
|
+
zodValidation: (0, zod_schema_type_1.zodSafeParse)(schema, unsavedValue),
|
|
20
21
|
},
|
|
21
22
|
};
|
|
22
23
|
});
|
|
@@ -26,7 +27,7 @@ const useLocalState = ({ unsavedValue, schema, setValue, savedValue, }) => {
|
|
|
26
27
|
return {
|
|
27
28
|
value: unsavedValue,
|
|
28
29
|
keyStabilityRevision: 0,
|
|
29
|
-
zodValidation:
|
|
30
|
+
zodValidation: (0, zod_schema_type_1.zodSafeParse)(schema, unsavedValue),
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
return localValueOrNull[parentRevision];
|
|
@@ -45,7 +46,7 @@ const useLocalState = ({ unsavedValue, schema, setValue, savedValue, }) => {
|
|
|
45
46
|
return (localUnsavedValue !== null && localUnsavedValue !== void 0 ? localUnsavedValue : {
|
|
46
47
|
value: savedValue,
|
|
47
48
|
keyStabilityRevision: 0,
|
|
48
|
-
zodValidation:
|
|
49
|
+
zodValidation: (0, zod_schema_type_1.zodSafeParse)(schema, savedValue),
|
|
49
50
|
});
|
|
50
51
|
}, [localUnsavedValue, savedValue, schema]);
|
|
51
52
|
const stateRef = (0, react_1.useRef)(currentLocalValue);
|
|
@@ -59,7 +60,7 @@ const useLocalState = ({ unsavedValue, schema, setValue, savedValue, }) => {
|
|
|
59
60
|
if (isSame) {
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
|
-
const safeParse =
|
|
63
|
+
const safeParse = (0, zod_schema_type_1.zodSafeParse)(schema, newValue);
|
|
63
64
|
if (safeParse.success || forceApply) {
|
|
64
65
|
setValue(updater, forceApply, increment);
|
|
65
66
|
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes zod schema type detection across v3 and v4.
|
|
3
|
+
*
|
|
4
|
+
* v3 schemas have `_def.typeName` (e.g. "ZodString")
|
|
5
|
+
* v4 schemas have `_def.type` (e.g. "string") and `_zod` property
|
|
6
|
+
*
|
|
7
|
+
* This module provides a unified type name using v4-style lowercase strings,
|
|
8
|
+
* and accessor helpers that abstract v3/v4 `_def` property differences.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Structural type for any Zod schema (v3 or v4).
|
|
12
|
+
*
|
|
13
|
+
* v3 schemas have `_def` with `typeName` property.
|
|
14
|
+
* v4 classic schemas have `_def` with `type` property.
|
|
15
|
+
* v4 core schemas have `_zod.def` with `type` property.
|
|
16
|
+
* At runtime, all zod schemas have `_def` (classic layer adds it for v4).
|
|
17
|
+
*/
|
|
18
|
+
export interface ZodValidationError {
|
|
19
|
+
format(): {
|
|
20
|
+
_errors: string[];
|
|
21
|
+
};
|
|
22
|
+
issues: readonly {
|
|
23
|
+
code: string;
|
|
24
|
+
message: string;
|
|
25
|
+
path: readonly PropertyKey[];
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
export type ZodSafeParseResult = {
|
|
29
|
+
success: true;
|
|
30
|
+
data: unknown;
|
|
31
|
+
} | {
|
|
32
|
+
success: false;
|
|
33
|
+
error: ZodValidationError;
|
|
34
|
+
};
|
|
35
|
+
export interface AnyZodSchema {
|
|
36
|
+
readonly _def?: Record<string, any>;
|
|
37
|
+
readonly _zod?: {
|
|
38
|
+
def: Record<string, any>;
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
};
|
|
41
|
+
readonly description?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Call safeParse on any Zod schema (v3 or v4).
|
|
45
|
+
* All Zod schemas have safeParse at runtime, but some v4 internal types
|
|
46
|
+
* (like $ZodObject) don't declare it in their type definition.
|
|
47
|
+
*/
|
|
48
|
+
export declare const zodSafeParse: (schema: AnyZodSchema, data: unknown) => ZodSafeParseResult;
|
|
49
|
+
export declare const getZodDef: (schema: AnyZodSchema) => Record<string, any>;
|
|
50
|
+
export type ZodSchemaType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'enum' | 'union' | 'discriminatedUnion' | 'optional' | 'nullable' | 'default' | 'tuple' | 'date' | 'any' | 'unknown' | 'bigint' | 'null' | 'undefined' | 'effects' | 'literal' | 'record' | 'never' | (string & {});
|
|
51
|
+
export declare const isZodV3Schema: (schema: AnyZodSchema) => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Get the normalized type name for a zod schema (v3 or v4).
|
|
54
|
+
*
|
|
55
|
+
* In v4, discriminatedUnion is a union with a `discriminator` property on `_def`.
|
|
56
|
+
* This function returns 'discriminatedUnion' for that case.
|
|
57
|
+
*/
|
|
58
|
+
export declare const getZodSchemaType: (schema: AnyZodSchema) => ZodSchemaType;
|
|
59
|
+
/**
|
|
60
|
+
* Get the description of a schema, handling v3 vs v4 differences.
|
|
61
|
+
*
|
|
62
|
+
* v3: _def.description
|
|
63
|
+
* v4: schema.description
|
|
64
|
+
*/
|
|
65
|
+
export declare const getZodSchemaDescription: (schema: AnyZodSchema) => string | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Get the shape of an object schema.
|
|
68
|
+
* v3: _def.shape() (function)
|
|
69
|
+
* v4: _def.shape (plain object)
|
|
70
|
+
*/
|
|
71
|
+
export declare const getObjectShape: (schema: AnyZodSchema) => Record<string, AnyZodSchema>;
|
|
72
|
+
/**
|
|
73
|
+
* Get the element schema of an array.
|
|
74
|
+
* v3: _def.type
|
|
75
|
+
* v4: _def.element
|
|
76
|
+
*/
|
|
77
|
+
export declare const getArrayElement: (schema: AnyZodSchema) => AnyZodSchema;
|
|
78
|
+
/**
|
|
79
|
+
* Get the inner type for wrappers like optional, nullable, default, catch.
|
|
80
|
+
* Both v3 and v4 use _def.innerType.
|
|
81
|
+
*/
|
|
82
|
+
export declare const getInnerType: (schema: AnyZodSchema) => AnyZodSchema;
|
|
83
|
+
/**
|
|
84
|
+
* Get the inner schema for effects (v3 only - v4 doesn't wrap).
|
|
85
|
+
* v3: _def.schema
|
|
86
|
+
*/
|
|
87
|
+
export declare const getEffectsInner: (schema: AnyZodSchema) => AnyZodSchema;
|
|
88
|
+
/**
|
|
89
|
+
* Get the literal value.
|
|
90
|
+
* v3: _def.value (single value)
|
|
91
|
+
* v4: _def.values (array of values) - take the first
|
|
92
|
+
*/
|
|
93
|
+
export declare const getLiteralValue: (schema: AnyZodSchema) => unknown;
|
|
94
|
+
/**
|
|
95
|
+
* Get enum values as an array of strings.
|
|
96
|
+
* v3: _def.values (string[])
|
|
97
|
+
* v4: _def.entries (Record<string,string>) - convert to values array
|
|
98
|
+
*/
|
|
99
|
+
export declare const getEnumValues: (schema: AnyZodSchema) => string[];
|
|
100
|
+
/**
|
|
101
|
+
* Get the first valid value from an enum schema.
|
|
102
|
+
* Handles both regular enums and nativeEnums.
|
|
103
|
+
*
|
|
104
|
+
* In v4, nativeEnums are represented as regular enums with bidirectional
|
|
105
|
+
* entries (e.g. { Apple: 0, "0": "Apple" }). This function filters out
|
|
106
|
+
* the reverse mappings to return actual enum values.
|
|
107
|
+
*/
|
|
108
|
+
export declare const getFirstEnumValue: (schema: AnyZodSchema) => unknown;
|
|
109
|
+
/**
|
|
110
|
+
* Get the union/discriminatedUnion options array.
|
|
111
|
+
* Both v3 and v4 use _def.options.
|
|
112
|
+
*/
|
|
113
|
+
export declare const getUnionOptions: (schema: AnyZodSchema) => AnyZodSchema[];
|
|
114
|
+
/**
|
|
115
|
+
* Get the default value from a ZodDefault.
|
|
116
|
+
* v3: _def.defaultValue() (function)
|
|
117
|
+
* v4: _def.defaultValue (plain value)
|
|
118
|
+
*/
|
|
119
|
+
export declare const getDefaultValue: (schema: AnyZodSchema) => unknown;
|
|
120
|
+
/**
|
|
121
|
+
* Get the discriminator key from a discriminated union.
|
|
122
|
+
* v3: _def.discriminator
|
|
123
|
+
* v4: _def.discriminator
|
|
124
|
+
*/
|
|
125
|
+
export declare const getDiscriminator: (schema: AnyZodSchema) => string;
|
|
126
|
+
/**
|
|
127
|
+
* Get all discriminator option keys from a discriminated union.
|
|
128
|
+
* v3: [..._def.optionsMap.keys()]
|
|
129
|
+
* v4: iterate options and extract literal values from discriminator field
|
|
130
|
+
*/
|
|
131
|
+
export declare const getDiscriminatedOptionKeys: (schema: AnyZodSchema) => string[];
|
|
132
|
+
/**
|
|
133
|
+
* Get the option schema matching a discriminator value.
|
|
134
|
+
* v3: _def.optionsMap.get(value)
|
|
135
|
+
* v4: find matching option by inspecting literal values
|
|
136
|
+
*/
|
|
137
|
+
export declare const getDiscriminatedOption: (schema: AnyZodSchema, discriminatorValue: string) => AnyZodSchema | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Get the left and right schemas from an intersection.
|
|
140
|
+
* Both v3 and v4 use _def.left and _def.right.
|
|
141
|
+
*/
|
|
142
|
+
export declare const getIntersectionSchemas: (schema: AnyZodSchema) => {
|
|
143
|
+
left: AnyZodSchema;
|
|
144
|
+
right: AnyZodSchema;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Get the items array from a tuple schema.
|
|
148
|
+
* Both v3 and v4 use _def.items.
|
|
149
|
+
*/
|
|
150
|
+
export declare const getTupleItems: (schema: AnyZodSchema) => AnyZodSchema[];
|
|
151
|
+
/**
|
|
152
|
+
* Get the value type schema from a record.
|
|
153
|
+
* Both v3 and v4 use _def.valueType.
|
|
154
|
+
*/
|
|
155
|
+
export declare const getRecordValueType: (schema: AnyZodSchema) => AnyZodSchema;
|
|
156
|
+
/**
|
|
157
|
+
* Get the key type schema from a record.
|
|
158
|
+
* Both v3 and v4 use _def.keyType.
|
|
159
|
+
*/
|
|
160
|
+
export declare const getRecordKeyType: (schema: AnyZodSchema) => AnyZodSchema;
|
|
161
|
+
/**
|
|
162
|
+
* Get the output schema from a pipeline/pipe.
|
|
163
|
+
* Both v3 and v4 use _def.out.
|
|
164
|
+
*/
|
|
165
|
+
export declare const getPipelineOutput: (schema: AnyZodSchema) => AnyZodSchema;
|
|
166
|
+
/**
|
|
167
|
+
* Get the input schema from a pipeline/pipe.
|
|
168
|
+
* Both v3 and v4 use _def.in.
|
|
169
|
+
*/
|
|
170
|
+
export declare const getPipelineInput: (schema: AnyZodSchema) => AnyZodSchema;
|
|
171
|
+
/**
|
|
172
|
+
* Get the inner schema from a branded type.
|
|
173
|
+
* v3: _def.type
|
|
174
|
+
* v4: branded is the schema itself (branding is type-level only)
|
|
175
|
+
*/
|
|
176
|
+
export declare const getBrandedInner: (schema: AnyZodSchema) => AnyZodSchema;
|