π₯ Make videos programmatically with React
formatting
Jonny Burger5373f2b203f4
diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.tsx b/packages/studio/src/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.tsxindex 9c4b239c9b..2e2c744d0d 100644--- a/packages/studio/src/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.tsx+++ b/packages/studio/src/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.tsx@@ -20,7 +20,6 @@ import {} from './zod-schema-type';import type {JSONPath} from './zod-types';-// eslint-disable-next-line @typescript-eslint/no-explicit-anyexport const ZodDiscriminatedUnionEditor: React.FC<{schema: any;setValue: UpdaterFunction<Record<string, unknown>>;@@ -80,6 +79,12 @@ export const ZodDiscriminatedUnionEditor: React.FC<{leftItem: option === value[discriminator] ? <Checkmark /> : null,onClick: () => {const optionSchema = getDiscriminatedOption(schema, option);+ if (!optionSchema) {+ throw new Error(+ `No schema found for discriminator value: ${option}`,+ );+ }+const val = createZodValues(optionSchema, z, zodTypes) as Record<string,unknowndiff --git a/packages/studio/src/components/RenderModal/SchemaEditor/create-zod-values.ts b/packages/studio/src/components/RenderModal/SchemaEditor/create-zod-values.tsindex eb270bb011..08d85c4e54 100644--- a/packages/studio/src/components/RenderModal/SchemaEditor/create-zod-values.ts+++ b/packages/studio/src/components/RenderModal/SchemaEditor/create-zod-values.ts@@ -1,23 +1,29 @@import type {ZodTypesType} from '../../get-zod-if-possible';import {+ type AnyZodSchema,getArrayElement,+ getBrandedInner,getDefaultValue,getEffectsInner,- getEnumValues,+ getFirstEnumValue,getInnerType,+ getIntersectionSchemas,getLiteralValue,getObjectShape,+ getPipelineInput,+ getPipelineOutput,+ getRecordKeyType,+ getRecordValueType,+ getTupleItems,getUnionOptions,+ getZodDef,getZodSchemaDescription,getZodSchemaType,isZodV3Schema,} from './zod-schema-type';-// eslint-disable-next-line @typescript-eslint/no-explicit-any-type AnySchema = any;-export const createZodValues = (- schema: AnySchema,+ schema: AnyZodSchema,zodRuntime: unknown,zodTypes: ZodTypesType | null,): unknown => {@@ -25,14 +31,35 @@ export const createZodValues = (throw new Error('Invalid zod schema');}- const def = schema._def;+ // In v4, .refine()/.describe() don't wrap in effects β the description+ // lives directly on the schema. Check for branded descriptions early+ // so they are detected regardless of the underlying type.+ const description = getZodSchemaDescription(schema);+ if (zodTypes) {+ if (description === zodTypes.ZodZypesInternals.REMOTION_COLOR_BRAND) {+ return '#ffffff';+ }++ if (description === zodTypes.ZodZypesInternals.REMOTION_TEXTAREA_BRAND) {+ return '';+ }++ if (description === zodTypes.ZodZypesInternals.REMOTION_MATRIX_BRAND) {+ return [+ [1, 0, 0],+ [0, 1, 0],+ [0, 0, 1],+ ];+ }+ }+const typeName = getZodSchemaType(schema);switch (typeName) {case 'string':return '';case 'number': {- const {checks} = def;+ const {checks} = getZodDef(schema);if (checks) {if (isZodV3Schema(schema)) {for (const check of checks) {@@ -67,6 +94,7 @@ export const createZodValues = (case 'null':return null;case 'any':+ case 'custom':throw new Error('Cannot create a value for type z.any()');case 'unknown':throw new Error('Cannot create a value for type z.unknown()');@@ -97,8 +125,8 @@ export const createZodValues = (}case 'discriminatedUnion': {- const options = getUnionOptions(schema)[0];- return createZodValues(options, zodRuntime, zodTypes);+ const firstOption = getUnionOptions(schema)[0];+ return createZodValues(firstOption, zodRuntime, zodTypes);}case 'literal': {@@ -106,37 +134,11 @@ export const createZodValues = (}case 'effects': {- const description = getZodSchemaDescription(schema);- if (- zodTypes &&- description === zodTypes.ZodZypesInternals.REMOTION_COLOR_BRAND- ) {- return '#ffffff';- }-- if (- zodTypes &&- description === zodTypes.ZodZypesInternals.REMOTION_TEXTAREA_BRAND- ) {- return '';- }-- if (- zodTypes &&- description === zodTypes.ZodZypesInternals.REMOTION_MATRIX_BRAND- ) {- return [- [1, 0, 0],- [0, 1, 0],- [0, 0, 1],- ];- }-return createZodValues(getEffectsInner(schema), zodRuntime, zodTypes);}case 'intersection': {- const {left, right} = def;+ const {left, right} = getIntersectionSchemas(schema);const leftValue = createZodValues(left, zodRuntime, zodTypes);if (typeof leftValue !== 'object') {throw new Error(@@ -156,30 +158,45 @@ export const createZodValues = (}case 'tuple': {- const items = def.items.map((item: AnySchema) =>+ return getTupleItems(schema).map((item) =>createZodValues(item, zodRuntime, zodTypes),);- return items;}case 'record': {- const values = createZodValues(def.valueType, zodRuntime, zodTypes);+ const values = createZodValues(+ getRecordValueType(schema),+ zodRuntime,+ zodTypes,+ );return {key: values};}case 'map': {- const values = createZodValues(def.valueType, zodRuntime, zodTypes);- const key = createZodValues(def.keyType, zodRuntime, zodTypes);+ const values = createZodValues(+ getRecordValueType(schema),+ zodRuntime,+ zodTypes,+ );+ const key = createZodValues(+ getRecordKeyType(schema),+ zodRuntime,+ zodTypes,+ );return new Map([[key, values]]);}case 'lazy': {- const type = def.getter();+ const type = getZodDef(schema).getter();return createZodValues(type, zodRuntime, zodTypes);}case 'set': {- const values = createZodValues(def.valueType, zodRuntime, zodTypes);+ const values = createZodValues(+ getZodDef(schema).valueType,+ zodRuntime,+ zodTypes,+ );return new Set([values]);}@@ -188,7 +205,7 @@ export const createZodValues = (}case 'enum': {- return getEnumValues(schema)[0];+ return getFirstEnumValue(schema);}case 'nativeEnum': {@@ -206,6 +223,7 @@ export const createZodValues = (}case 'promise': {+ const def = getZodDef(schema);// v3: _def.type, v4: _def.innerTypeconst inner = isZodV3Schema(schema) ? def.type : def.innerType;const value = createZodValues(inner, zodRuntime, zodTypes);@@ -213,14 +231,19 @@ export const createZodValues = (}case 'branded': {- // v3: _def.type, v4: schema is the base type (branded doesn't wrap in v4)- const inner = isZodV3Schema(schema) ? def.type : schema;- return createZodValues(inner, zodRuntime, zodTypes);+ return createZodValues(getBrandedInner(schema), zodRuntime, zodTypes);}- case 'pipeline': {- // v3: _def.out, v4: _def.out- return createZodValues(def.out, zodRuntime, zodTypes);+ case 'pipeline':+ case 'pipe': {+ const out = getPipelineOutput(schema);+ // In v4, .transform() creates pipe { in, out: transform }.+ // Since we don't apply transforms, use the input side.+ if (getZodSchemaType(out) === 'transform') {+ return createZodValues(getPipelineInput(schema), zodRuntime, zodTypes);+ }++ return createZodValues(out, zodRuntime, zodTypes);}default:diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/extract-enum-json-paths.ts b/packages/studio/src/components/RenderModal/SchemaEditor/extract-enum-json-paths.tsindex 74999f6e76..817d183b1a 100644--- a/packages/studio/src/components/RenderModal/SchemaEditor/extract-enum-json-paths.ts+++ b/packages/studio/src/components/RenderModal/SchemaEditor/extract-enum-json-paths.ts@@ -1,30 +1,43 @@import type {ZodTypesType} from '../../get-zod-if-possible';import {+ type AnyZodSchema,getArrayElement,+ getBrandedInner,getEffectsInner,getInnerType,+ getIntersectionSchemas,getObjectShape,+ getPipelineOutput,+ getRecordKeyType,+ getRecordValueType,+ getTupleItems,getUnionOptions,getZodSchemaDescription,getZodSchemaType,- isZodV3Schema,} from './zod-schema-type';-// eslint-disable-next-line @typescript-eslint/no-explicit-any-type AnySchema = any;-export const extractEnumJsonPaths = ({schema,zodRuntime,currentPath,zodTypes,}: {- schema: AnySchema;+ schema: AnyZodSchema;zodRuntime: unknown;zodTypes: ZodTypesType | null;currentPath: (string | number)[];}): (string | number)[][] => {- const def = schema._def;+ // In v4, .refine()/.describe() don't wrap in effects β the description+ // lives directly on the schema. Check for branded descriptions early+ // so they are detected regardless of the underlying type.+ const description = getZodSchemaDescription(schema);+ if (+ zodTypes &&+ description === zodTypes.ZodZypesInternals.REMOTION_MATRIX_BRAND+ ) {+ return [currentPath];+ }+const typeName = getZodSchemaType(schema);switch (typeName) {@@ -54,7 +67,7 @@ export const extractEnumJsonPaths = ({case 'union': {return getUnionOptions(schema)- .map((option: AnySchema) => {+ .map((option) => {return extractEnumJsonPaths({schema: option,zodRuntime,@@ -67,7 +80,7 @@ export const extractEnumJsonPaths = ({case 'discriminatedUnion': {return getUnionOptions(schema)- .map((op: AnySchema) => {+ .map((op) => {return extractEnumJsonPaths({schema: op,zodRuntime,@@ -83,14 +96,6 @@ export const extractEnumJsonPaths = ({}case 'effects': {- const description = getZodSchemaDescription(schema);- if (- zodTypes &&- description === zodTypes.ZodZypesInternals.REMOTION_MATRIX_BRAND- ) {- return [currentPath];- }-return extractEnumJsonPaths({schema: getEffectsInner(schema),zodRuntime,@@ -100,7 +105,7 @@ export const extractEnumJsonPaths = ({}case 'intersection': {- const {left, right} = def;+ const {left, right} = getIntersectionSchemas(schema);const leftValue = extractEnumJsonPaths({schema: left,zodRuntime,@@ -119,8 +124,8 @@ export const extractEnumJsonPaths = ({}case 'tuple': {- return def.items- .map((item: AnySchema, i: number) =>+ return getTupleItems(schema)+ .map((item, i) =>extractEnumJsonPaths({schema: item,zodRuntime,@@ -132,12 +137,20 @@ export const extractEnumJsonPaths = ({}case 'record': {- return extractEnumJsonPaths({- schema: def.valueType,+ const recordPath = [...currentPath, '{}'];+ const keyResults = extractEnumJsonPaths({+ schema: getRecordKeyType(schema),+ zodRuntime,+ currentPath: recordPath,+ zodTypes,+ });+ const valueResults = extractEnumJsonPaths({+ schema: getRecordValueType(schema),zodRuntime,- currentPath: [...currentPath, '{}'],+ currentPath: recordPath,zodTypes,});+ return [...keyResults, ...valueResults];}case 'function': {@@ -177,18 +190,18 @@ export const extractEnumJsonPaths = ({}case 'branded': {- const inner = isZodV3Schema(schema) ? def.type : schema;return extractEnumJsonPaths({- schema: inner,+ schema: getBrandedInner(schema),zodRuntime,currentPath,zodTypes,});}- case 'pipeline': {+ case 'pipeline':+ case 'pipe': {return extractEnumJsonPaths({- schema: def.out,+ schema: getPipelineOutput(schema),zodRuntime,currentPath,zodTypes,@@ -210,7 +223,8 @@ export const extractEnumJsonPaths = ({case 'void':case 'map':case 'lazy':- case 'set': {+ case 'set':+ case 'custom': {return [];}diff --git a/packages/studio/src/components/RenderModal/SchemaEditor/zod-schema-type.ts b/packages/studio/src/components/RenderModal/SchemaEditor/zod-schema-type.tsindex 3cea7c5989..e374482ae8 100644--- a/packages/studio/src/components/RenderModal/SchemaEditor/zod-schema-type.ts+++ b/packages/studio/src/components/RenderModal/SchemaEditor/zod-schema-type.ts@@ -8,8 +8,28 @@* and accessor helpers that abstract v3/v4 `_def` property differences.*/+/**+ * Structural type for any Zod schema (v3 or v4).+ *+ * v3 schemas have `_def` with `typeName` property.+ * v4 classic schemas have `_def` with `type` property.+ * v4 core schemas have `_zod.def` with `type` property.+ * At runtime, all zod schemas have `_def` (classic layer adds it for v4).+ */+export interface AnyZodSchema {+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ readonly _def?: Record<string, any>;+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ readonly _zod?: {def: Record<string, any>; [key: string]: any};+ readonly description?: string;+}+// eslint-disable-next-line @typescript-eslint/no-explicit-any-type AnySchema = any;+export const getZodDef = (schema: AnyZodSchema): Record<string, any> => {+ if (schema._def) return schema._def;+ if (schema._zod) return schema._zod.def;+ throw new Error('Invalid zod schema: missing _def and _zod');+};export type ZodSchemaType =| 'string'@@ -74,8 +94,9 @@ const v3TypeNameMap: Record<string, ZodSchemaType> = {ZodPipeline: 'pipeline',};-export const isZodV3Schema = (schema: AnySchema): boolean => {- return '_def' in schema && 'typeName' in schema._def;+export const isZodV3Schema = (schema: AnyZodSchema): boolean => {+ const def = getZodDef(schema);+ return 'typeName' in def;};/**@@ -84,17 +105,19 @@ export const isZodV3Schema = (schema: AnySchema): boolean => {* In v4, discriminatedUnion is a union with a `discriminator` property on `_def`.* This function returns 'discriminatedUnion' for that case.*/-export const getZodSchemaType = (schema: AnySchema): ZodSchemaType => {- if (isZodV3Schema(schema)) {- const {typeName} = schema._def;+export const getZodSchemaType = (schema: AnyZodSchema): ZodSchemaType => {+ const def = getZodDef(schema);++ if ('typeName' in def) {+ const {typeName} = def;return v3TypeNameMap[typeName] ?? typeName;}- // v4 schema: _def.type is a string like "string", "number", etc.- const {type} = schema._def;+ // v4 schema: def.type is a string like "string", "number", etc.+ const {type} = def;- // In v4, discriminatedUnion has _def.type === "union" with _def.discriminator- if (type === 'union' && schema._def.discriminator !== undefined) {+ // In v4, discriminatedUnion has def.type === "union" with def.discriminator+ if (type === 'union' && def.discriminator !== undefined) {return 'discriminatedUnion';}@@ -104,14 +127,14 @@ export const getZodSchemaType = (schema: AnySchema): ZodSchemaType => {/*** Get the description of a schema, handling v3 vs v4 differences.*- * v3: schema._def.description+ * v3: _def.description* v4: schema.description*/export const getZodSchemaDescription = (- schema: AnySchema,+ schema: AnyZodSchema,): string | undefined => {if (isZodV3Schema(schema)) {- return schema._def.description;+ return getZodDef(schema).description;}return schema.description;@@ -122,8 +145,10 @@ export const getZodSchemaDescription = (* v3: _def.shape() (function)* v4: _def.shape (plain object)*/-export const getObjectShape = (schema: AnySchema): Record<string, unknown> => {- const {shape} = schema._def;+export const getObjectShape = (+ schema: AnyZodSchema,+): Record<string, AnyZodSchema> => {+ const {shape} = getZodDef(schema);return typeof shape === 'function' ? shape() : shape;};@@ -132,24 +157,25 @@ export const getObjectShape = (schema: AnySchema): Record<string, unknown> => {* v3: _def.type* v4: _def.element*/-export const getArrayElement = (schema: AnySchema): AnySchema => {- return isZodV3Schema(schema) ? schema._def.type : schema._def.element;+export const getArrayElement = (schema: AnyZodSchema): AnyZodSchema => {+ const def = getZodDef(schema);+ return isZodV3Schema(schema) ? def.type : def.element;};/*** Get the inner type for wrappers like optional, nullable, default, catch.* Both v3 and v4 use _def.innerType.*/-export const getInnerType = (schema: AnySchema): AnySchema => {- return schema._def.innerType;+export const getInnerType = (schema: AnyZodSchema): AnyZodSchema => {+ return getZodDef(schema).innerType;};/*** Get the inner schema for effects (v3 only - v4 doesn't wrap).* v3: _def.schema*/-export const getEffectsInner = (schema: AnySchema): AnySchema => {- return schema._def.schema;+export const getEffectsInner = (schema: AnyZodSchema): AnyZodSchema => {+ return getZodDef(schema).schema;};/**@@ -157,12 +183,13 @@ export const getEffectsInner = (schema: AnySchema): AnySchema => {* v3: _def.value (single value)* v4: _def.values (array of values) - take the first*/-export const getLiteralValue = (schema: AnySchema): unknown => {+export const getLiteralValue = (schema: AnyZodSchema): unknown => {+ const def = getZodDef(schema);if (isZodV3Schema(schema)) {- return schema._def.value;+ return def.value;}- return schema._def.values?.[0];+ return def.values?.[0];};/**@@ -170,21 +197,58 @@ export const getLiteralValue = (schema: AnySchema): unknown => {* v3: _def.values (string[])* v4: _def.entries (Record<string,string>) - convert to values array*/-export const getEnumValues = (schema: AnySchema): string[] => {+export const getEnumValues = (schema: AnyZodSchema): string[] => {+ const def = getZodDef(schema);if (isZodV3Schema(schema)) {- return schema._def.values;+ return def.values;}- const {entries} = schema._def;+ const {entries} = def;return Object.values(entries);};+/**+ * Get the first valid value from an enum schema.+ * Handles both regular enums and nativeEnums.+ *+ * In v4, nativeEnums are represented as regular enums with bidirectional+ * entries (e.g. { Apple: 0, "0": "Apple" }). This function filters out+ * the reverse mappings to return actual enum values.+ */+export const getFirstEnumValue = (schema: AnyZodSchema): unknown => {+ const def = getZodDef(schema);++ if (isZodV3Schema(schema)) {+ if (def.typeName === 'ZodNativeEnum') {+ const vals = Object.values(def.values);+ return vals[0];+ }++ return def.values[0];+ }++ const {entries} = def;+ const pairs = Object.entries(entries);++ // Check for native enum with bidirectional mapping+ const hasReverseMapping = pairs.some(([key, value]) => key !== String(value));+ if (hasReverseMapping) {+ // For numeric native enums, filter out the numeric-key reverse mappings+ const forwardPairs = pairs.filter(([key]) => Number.isNaN(Number(key)));+ if (forwardPairs.length > 0) {+ return forwardPairs[0][1];+ }+ }++ return Object.values(entries)[0];+};+/*** Get the union/discriminatedUnion options array.* Both v3 and v4 use _def.options.*/-export const getUnionOptions = (schema: AnySchema): AnySchema[] => {- return schema._def.options;+export const getUnionOptions = (schema: AnyZodSchema): AnyZodSchema[] => {+ return getZodDef(schema).options;};/**@@ -192,8 +256,8 @@ export const getUnionOptions = (schema: AnySchema): AnySchema[] => {* v3: _def.defaultValue() (function)* v4: _def.defaultValue (plain value)*/-export const getDefaultValue = (schema: AnySchema): unknown => {- const dv = schema._def.defaultValue;+export const getDefaultValue = (schema: AnyZodSchema): unknown => {+ const dv = getZodDef(schema).defaultValue;return typeof dv === 'function' ? dv() : dv;};@@ -202,8 +266,8 @@ export const getDefaultValue = (schema: AnySchema): unknown => {* v3: _def.discriminator* v4: _def.discriminator*/-export const getDiscriminator = (schema: AnySchema): string => {- return schema._def.discriminator;+export const getDiscriminator = (schema: AnyZodSchema): string => {+ return getZodDef(schema).discriminator;};/**@@ -211,19 +275,20 @@ export const getDiscriminator = (schema: AnySchema): string => {* v3: [..._def.optionsMap.keys()]* v4: iterate options and extract literal values from discriminator field*/-export const getDiscriminatedOptionKeys = (schema: AnySchema): string[] => {+export const getDiscriminatedOptionKeys = (schema: AnyZodSchema): string[] => {+ const def = getZodDef(schema);const discriminator = getDiscriminator(schema);// v3 has optionsMap- if (isZodV3Schema(schema) && schema._def.optionsMap) {- return [...schema._def.optionsMap.keys()];+ if (isZodV3Schema(schema) && def.optionsMap) {+ return [...def.optionsMap.keys()];}// v4: iterate optionsconst options = getUnionOptions(schema);- return options.map((option: AnySchema) => {+ return options.map((option) => {const shape = getObjectShape(option);- const discriminatorSchema = shape[discriminator] as AnySchema;+ const discriminatorSchema = shape[discriminator];return getLiteralValue(discriminatorSchema) as string;});};@@ -234,21 +299,82 @@ export const getDiscriminatedOptionKeys = (schema: AnySchema): string[] => {* v4: find matching option by inspecting literal values*/export const getDiscriminatedOption = (- schema: AnySchema,+ schema: AnyZodSchema,discriminatorValue: string,-): AnySchema => {+): AnyZodSchema | undefined => {+ const def = getZodDef(schema);const discriminator = getDiscriminator(schema);// v3 has optionsMap- if (isZodV3Schema(schema) && schema._def.optionsMap) {- return schema._def.optionsMap.get(discriminatorValue);+ if (isZodV3Schema(schema) && def.optionsMap) {+ return def.optionsMap.get(discriminatorValue);}// v4: iterate optionsconst options = getUnionOptions(schema);- return options.find((option: AnySchema) => {+ return options.find((option) => {const shape = getObjectShape(option);- const discriminatorSchema = shape[discriminator] as AnySchema;+ const discriminatorSchema = shape[discriminator];return getLiteralValue(discriminatorSchema) === discriminatorValue;});};++/**+ * Get the left and right schemas from an intersection.+ * Both v3 and v4 use _def.left and _def.right.+ */+export const getIntersectionSchemas = (+ schema: AnyZodSchema,+): {left: AnyZodSchema; right: AnyZodSchema} => {+ const def = getZodDef(schema);+ return {left: def.left, right: def.right};+};++/**+ * Get the items array from a tuple schema.+ * Both v3 and v4 use _def.items.+ */+export const getTupleItems = (schema: AnyZodSchema): AnyZodSchema[] => {+ return getZodDef(schema).items;+};++/**+ * Get the value type schema from a record.+ * Both v3 and v4 use _def.valueType.+ */+export const getRecordValueType = (schema: AnyZodSchema): AnyZodSchema => {+ return getZodDef(schema).valueType;+};++/**+ * Get the key type schema from a record.+ * Both v3 and v4 use _def.keyType.+ */+export const getRecordKeyType = (schema: AnyZodSchema): AnyZodSchema => {+ return getZodDef(schema).keyType;+};++/**+ * Get the output schema from a pipeline/pipe.+ * Both v3 and v4 use _def.out.+ */+export const getPipelineOutput = (schema: AnyZodSchema): AnyZodSchema => {+ return getZodDef(schema).out;+};++/**+ * Get the input schema from a pipeline/pipe.+ * Both v3 and v4 use _def.in.+ */+export const getPipelineInput = (schema: AnyZodSchema): AnyZodSchema => {+ return getZodDef(schema).in;+};++/**+ * Get the inner schema from a branded type.+ * v3: _def.type+ * v4: branded is the schema itself (branding is type-level only)+ */+export const getBrandedInner = (schema: AnyZodSchema): AnyZodSchema => {+ return isZodV3Schema(schema) ? getZodDef(schema).type : schema;+};diff --git a/packages/studio/src/test/create-zod-values.test.ts b/packages/studio/src/test/create-zod-values.test.tsindex b680cf7889..461c9a7f12 100644--- a/packages/studio/src/test/create-zod-values.test.ts+++ b/packages/studio/src/test/create-zod-values.test.ts@@ -72,7 +72,8 @@ test('Should be able to create a union', async () => {expect(createZodValues(z.union([z.number(), z.string()]), z, zodTypes)).toBe(0,);- expect(createZodValues(z.union([]) as never, z, zodTypes)).toBe(undefined);+ // In v4, z.union([]) throws during schema creation+ expect(() => createZodValues(z.union([]) as never, z, zodTypes)).toThrow();});test('Zod literal', async () => {@@ -108,10 +109,11 @@ test('Should be able to create a discriminated union', async () => {),).toEqual({status: 'failed', error: 0});+ // In v4, z.discriminatedUnion('status', []) throws during schema creationexpect(() =>// @ts-expect-error invalid zod typecreateZodValues(z.discriminatedUnion('status', []), z, zodTypes),- ).toThrow(/Invalid zod schema/);+ ).toThrow();});test('Zod instanceof', async () => {