@mastra/schema-compat 1.3.10 → 1.3.11-alpha.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-WUB3nKhz.js → esm-CWlHuVIx.js} +39 -39
- package/dist/{esm-WUB3nKhz.js.map → esm-CWlHuVIx.js.map} +1 -1
- package/dist/{esm-pT0d13Vi.cjs → esm-CkNCkZSB.cjs} +39 -39
- package/dist/{esm-pT0d13Vi.cjs.map → esm-CkNCkZSB.cjs.map} +1 -1
- package/dist/index.cjs +3 -4
- package/dist/index.cjs.map +1 -1
- package/dist/{json-schema-CEVTdogs.cjs → json-schema-C7Uhaeop.cjs} +95 -96
- package/dist/{json-schema-CEVTdogs.cjs.map → json-schema-C7Uhaeop.cjs.map} +1 -1
- package/dist/{json-schema-traverse-CSNSaf0y.cjs → json-schema-traverse-DbuWNYgg.cjs} +37 -2
- package/dist/{json-schema-traverse-CSNSaf0y.cjs.map → json-schema-traverse-DbuWNYgg.cjs.map} +1 -1
- package/dist/json-to-zod.cjs +657 -26
- package/dist/json-to-zod.cjs.map +1 -1
- package/dist/json-to-zod.d.ts.map +1 -1
- package/dist/json-to-zod.js +623 -7
- package/dist/json-to-zod.js.map +1 -1
- package/dist/{schema-Bw7nQdgA.cjs → schema-5p36X0wR.cjs} +4 -4
- package/dist/{schema-Bw7nQdgA.cjs.map → schema-5p36X0wR.cjs.map} +1 -1
- package/dist/schema.cjs +1 -1
- package/dist/standard-schema/adapters/json-schema.cjs +1 -1
- package/dist/standard-schema/adapters/zod-v3.cjs +3 -4
- package/dist/standard-schema/adapters/zod-v3.cjs.map +1 -1
- package/dist/standard-schema/adapters/zod-v3.js +1 -1
- package/dist/zod-to-json.cjs +1 -1
- package/dist/zod-to-json.js +1 -1
- package/package.json +9 -9
- package/dist/rolldown-runtime-emK7D4bc.cjs +0 -35
package/dist/json-to-zod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-to-zod.js","names":[],"sources":["../src/json-to-zod.ts"],"sourcesContent":["import type { JsonSchema, JsonSchemaObject, Options, Refs } from 'json-schema-to-zod';\nimport jsonSchemaToZodOriginal, {\n addJsdocs,\n its,\n parseAllOf,\n parseAnyOf,\n parseOneOf,\n parseSchema,\n} from 'json-schema-to-zod';\n\nfunction parseObject(objectSchema: JsonSchemaObject & { type: 'object' }, refs: Refs): string {\n let properties: string | undefined = undefined;\n\n if (objectSchema.properties) {\n if (!Object.keys(objectSchema.properties).length) {\n properties = 'z.object({})';\n } else {\n properties = 'z.object({ ';\n\n properties += Object.keys(objectSchema.properties)\n .map(key => {\n const propSchema = objectSchema.properties![key];\n\n let result = `${JSON.stringify(key)}: ${parseSchema(propSchema!, {\n ...refs,\n path: [...refs.path, 'properties', key],\n })}`;\n\n if (refs.withJsdocs && typeof propSchema === 'object') {\n result = addJsdocs(propSchema, result);\n }\n\n const hasDefault = typeof propSchema === 'object' && propSchema.default !== undefined;\n\n const required = Array.isArray(objectSchema.required)\n ? objectSchema.required.includes(key)\n : typeof propSchema === 'object' && propSchema.required === true;\n\n const optional = !hasDefault && !required;\n\n return optional ? `${result}.optional()` : result;\n })\n .join(', ');\n\n properties += ' })';\n }\n }\n\n const additionalProperties =\n objectSchema.additionalProperties !== undefined && objectSchema.additionalProperties !== false\n ? parseSchema(objectSchema.additionalProperties, {\n ...refs,\n path: [...refs.path, 'additionalProperties'],\n })\n : undefined;\n\n let patternProperties: string | undefined = undefined;\n\n if (objectSchema.patternProperties) {\n const parsedPatternProperties = Object.fromEntries(\n Object.entries(objectSchema.patternProperties).map(([key, value]) => {\n return [\n key,\n parseSchema(value, {\n ...refs,\n path: [...refs.path, 'patternProperties', key],\n }),\n ];\n }, {}),\n );\n\n patternProperties = '';\n\n if (properties) {\n if (additionalProperties) {\n patternProperties += `.catchall(z.union([${[\n ...Object.values(parsedPatternProperties),\n additionalProperties,\n ].join(', ')}]))`;\n } else if (Object.keys(parsedPatternProperties).length > 1) {\n patternProperties += `.catchall(z.union([${Object.values(parsedPatternProperties).join(', ')}]))`;\n } else {\n patternProperties += `.catchall(${Object.values(parsedPatternProperties)})`;\n }\n } else {\n if (additionalProperties) {\n patternProperties += `z.record(z.union([${[\n ...Object.values(parsedPatternProperties),\n additionalProperties,\n ].join(', ')}]))`;\n } else if (Object.keys(parsedPatternProperties).length > 1) {\n patternProperties += `z.record(z.union([${Object.values(parsedPatternProperties).join(', ')}]))`;\n } else {\n patternProperties += `z.record(${Object.values(parsedPatternProperties)})`;\n }\n }\n\n patternProperties += '.superRefine((value, ctx) => {\\n';\n\n patternProperties += 'for (const key in value) {\\n';\n\n if (additionalProperties) {\n if (objectSchema.properties) {\n patternProperties += `let evaluated = [${Object.keys(objectSchema.properties)\n .map(key => JSON.stringify(key))\n .join(', ')}].includes(key)\\n`;\n } else {\n patternProperties += `let evaluated = false\\n`;\n }\n }\n\n for (const key in objectSchema.patternProperties) {\n patternProperties += 'if (key.match(new RegExp(' + JSON.stringify(key) + '))) {\\n';\n if (additionalProperties) {\n patternProperties += 'evaluated = true\\n';\n }\n patternProperties += 'const result = ' + parsedPatternProperties[key] + '.safeParse(value[key])\\n';\n patternProperties += 'if (!result.success) {\\n';\n\n patternProperties += `ctx.addIssue({\n path: [...ctx.path, key],\n code: 'custom',\n message: \\`Invalid input: Key matching regex /\\${key}/ must match schema\\`,\n params: {\n issues: result.error.issues\n }\n })\\n`;\n\n patternProperties += '}\\n';\n patternProperties += '}\\n';\n }\n\n if (additionalProperties) {\n patternProperties += 'if (!evaluated) {\\n';\n patternProperties += 'const result = ' + additionalProperties + '.safeParse(value[key])\\n';\n patternProperties += 'if (!result.success) {\\n';\n\n patternProperties += `ctx.addIssue({\n path: [...ctx.path, key],\n code: 'custom',\n message: \\`Invalid input: must match catchall schema\\`,\n params: {\n issues: result.error.issues\n }\n })\\n`;\n\n patternProperties += '}\\n';\n patternProperties += '}\\n';\n }\n patternProperties += '}\\n';\n patternProperties += '})';\n }\n\n let output = properties\n ? patternProperties\n ? properties + patternProperties\n : additionalProperties\n ? additionalProperties === 'z.never()'\n ? properties + '.strict()'\n : properties + `.catchall(${additionalProperties})`\n : properties\n : patternProperties\n ? patternProperties\n : additionalProperties\n ? `z.record(${additionalProperties})`\n : 'z.record(z.any())';\n\n if (its.an.anyOf(objectSchema)) {\n output += `.and(${parseAnyOf(\n {\n ...objectSchema,\n anyOf: objectSchema.anyOf.map(x =>\n typeof x === 'object' && !x.type && (x.properties || x.additionalProperties || x.patternProperties)\n ? { ...x, type: 'object' }\n : x,\n ) as any,\n },\n refs,\n )})`;\n }\n\n if (its.a.oneOf(objectSchema)) {\n output += `.and(${parseOneOf(\n {\n ...objectSchema,\n oneOf: objectSchema.oneOf.map(x =>\n typeof x === 'object' && !x.type && (x.properties || x.additionalProperties || x.patternProperties)\n ? { ...x, type: 'object' }\n : x,\n ) as any,\n },\n refs,\n )})`;\n }\n\n if (its.an.allOf(objectSchema)) {\n output += `.and(${parseAllOf(\n {\n ...objectSchema,\n allOf: objectSchema.allOf.map(x =>\n typeof x === 'object' && !x.type && (x.properties || x.additionalProperties || x.patternProperties)\n ? { ...x, type: 'object' }\n : x,\n ) as any,\n },\n refs,\n )})`;\n }\n\n return output;\n}\n\nconst parserOverride = (schema: JsonSchemaObject, refs: Refs) => {\n let parsed = '';\n let seen = refs.seen.get(schema);\n if (its.an.anyOf(schema)) {\n const allObjects = schema.anyOf.every(\n item => typeof item === 'object' && its.an.object(item) && item.properties !== undefined,\n );\n if (schema.anyOf.length > 1 && allObjects) {\n const propertiesWithConst: string[][] = schema.anyOf.reduce((acc, item) => {\n if (typeof item === 'object' && its.an.object(item)) {\n const propertyWithConst = Object.entries(item.properties ?? {}).filter(\n ([_, value]) => typeof value === 'object' && (value as any)?.const !== undefined,\n );\n if (propertyWithConst?.length) {\n const ppties = propertyWithConst.map(([key, _]) => key);\n acc.push(ppties);\n }\n }\n return acc;\n }, [] as string[][]);\n\n if (propertiesWithConst.length === schema.anyOf.length) {\n if (seen) {\n if (seen.r !== undefined) {\n return seen.r;\n }\n\n if (refs.depth === undefined || seen.n >= refs.depth) {\n return 'z.any()';\n }\n\n seen.n += 1;\n } else {\n seen = { r: undefined, n: 0 };\n refs.seen.set(schema, seen);\n }\n\n const discriminators =\n propertiesWithConst.length > 0 && propertiesWithConst[0]\n ? propertiesWithConst.reduce((common, properties) => {\n return common.filter(prop => properties.includes(prop));\n }, propertiesWithConst[0])\n : [];\n\n if (discriminators.length > 0) {\n const discriminator = discriminators[0];\n if (discriminator) {\n parsed = `z.discriminatedUnion(\"${discriminator}\", [${schema.anyOf\n .map((schema, i) =>\n parseSchema(schema, {\n ...refs,\n path: [...refs.path, 'anyOf', i],\n }),\n )\n .join(', ')}])`;\n }\n }\n }\n }\n } else if (its.an.object(schema)) {\n if (seen) {\n if (seen.r !== undefined) {\n return seen.r;\n }\n\n if (refs.depth === undefined || seen.n >= refs.depth) {\n return 'z.any()';\n }\n\n seen.n += 1;\n } else {\n seen = { r: undefined, n: 0 };\n refs.seen.set(schema, seen);\n }\n\n parsed = parseObject(schema, refs);\n }\n if (parsed) {\n if (!refs.withoutDescribes) {\n parsed = addDescribes(schema, parsed);\n }\n\n if (!refs.withoutDefaults) {\n parsed = addDefaults(schema, parsed);\n }\n\n parsed = addAnnotations(schema, parsed);\n\n if (seen) {\n seen.r = parsed;\n }\n\n return parsed;\n }\n};\n\nconst addDescribes = (schema: JsonSchemaObject, parsed: string): string => {\n if (schema.description) {\n parsed += `.describe(${JSON.stringify(schema.description)})`;\n }\n\n return parsed;\n};\n\nconst addDefaults = (schema: JsonSchemaObject, parsed: string): string => {\n if (schema.default !== undefined) {\n parsed += `.default(${JSON.stringify(schema.default)})`;\n }\n\n return parsed;\n};\n\nconst addAnnotations = (schema: JsonSchemaObject, parsed: string): string => {\n if (schema.readOnly) {\n parsed += '.readonly()';\n }\n\n return parsed;\n};\n\nexport function jsonSchemaToZod(schema: JsonSchema, options: Options = {}): string {\n const result = jsonSchemaToZodOriginal(schema, { ...options, parserOverride });\n\n // Fix: The upstream json-schema-to-zod generates TypeScript syntax `reduce<z.ZodError[]>`\n // in parseOneOf which fails when evaluated at runtime with Function().\n // This catches any oneOf usage that bypasses our parserOverride (e.g., non-object contexts).\n // See: https://github.com/mastra-ai/mastra/issues/11610\n return result.replace(/\\.reduce<[^>]+>/g, '.reduce');\n}\n\n// Re-export all named exports from json-schema-to-zod (excluding the default export)\nexport * from 'json-schema-to-zod';\n"],"mappings":";;;AAUA,SAAS,YAAY,cAAqD,MAAoB;CAC5F,IAAI,aAAiC,KAAA;CAErC,IAAI,aAAa,YACf,IAAI,CAAC,OAAO,KAAK,aAAa,UAAU,CAAC,CAAC,QACxC,aAAa;MACR;EACL,aAAa;EAEb,cAAc,OAAO,KAAK,aAAa,UAAU,CAAC,CAC/C,KAAI,QAAO;GACV,MAAM,aAAa,aAAa,WAAY;GAE5C,IAAI,SAAS,GAAG,KAAK,UAAU,GAAG,EAAE,IAAI,YAAY,YAAa;IAC/D,GAAG;IACH,MAAM;KAAC,GAAG,KAAK;KAAM;KAAc;IAAG;GACxC,CAAC;GAED,IAAI,KAAK,cAAc,OAAO,eAAe,UAC3C,SAAS,UAAU,YAAY,MAAM;GAGvC,MAAM,aAAa,OAAO,eAAe,YAAY,WAAW,YAAY,KAAA;GAE5E,MAAM,WAAW,MAAM,QAAQ,aAAa,QAAQ,IAChD,aAAa,SAAS,SAAS,GAAG,IAClC,OAAO,eAAe,YAAY,WAAW,aAAa;GAI9D,OAFiB,CAAC,cAAc,CAAC,WAEf,GAAG,OAAO,eAAe;EAC7C,CAAC,CAAC,CACD,KAAK,IAAI;EAEZ,cAAc;CAChB;CAGF,MAAM,uBACJ,aAAa,yBAAyB,KAAA,KAAa,aAAa,yBAAyB,QACrF,YAAY,aAAa,sBAAsB;EAC7C,GAAG;EACH,MAAM,CAAC,GAAG,KAAK,MAAM,sBAAsB;CAC7C,CAAC,IACD,KAAA;CAEN,IAAI,oBAAwC,KAAA;CAE5C,IA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AAG,KAAK;OAAM;OAAS;MAAC;KACjC,CAAC,CACH,CAAC,CACA,KAAK,IAAI,EAAE;IAElB;GACF;EACF;CACF,OAAO,IAAI,IAAI,GAAG,OAAO,MAAM,GAAG;EAChC,IAAI,MAAM;GACR,IAAI,KAAK,MAAM,KAAA,GACb,OAAO,KAAK;GAGd,IAAI,KAAK,UAAU,KAAA,KAAa,KAAK,KAAK,KAAK,OAC7C,OAAO;GAGT,KAAK,KAAK;EACZ,OAAO;GACL,OAAO;IAAE,GAAG,KAAA;IAAW,GAAG;GAAE;GAC5B,KAAK,KAAK,IAAI,QAAQ,IAAI;EAC5B;EAEA,SAAS,YAAY,QAAQ,IAAI;CACnC;CACA,IAAI,QAAQ;EACV,IAAI,CAAC,KAAK,kBACR,SAAS,aAAa,QAAQ,MAAM;EAGtC,IAAI,CAAC,KAAK,iBACR,SAAS,YAAY,QAAQ,MAAM;EAGrC,SAAS,eAAe,QAAQ,MAAM;EAEtC,IAAI,MACF,KAAK,IAAI;EAGX,OAAO;CACT;AACF;AAEA,MAAM,gBAAgB,QAA0B,WAA2B;CACzE,IAAI,OAAO,aACT,UAAU,aAAa,KAAK,UAAU,OAAO,WAAW,EAAE;CAG5D,OAAO;AACT;AAEA,MAAM,eAAe,QAA0B,WAA2B;CACxE,IAAI,OAAO,YAAY,KAAA,GACrB,UAAU,YAAY,KAAK,UAAU,OAAO,OAAO,EAAE;CAGvD,OAAO;AACT;AAEA,MAAM,kBAAkB,QAA0B,WAA2B;CAC3E,IAAI,OAAO,UACT,UAAU;CAGZ,OAAO;AACT;AAEA,SAAgB,gBAAgB,QAAoB,UAAmB,CAAC,GAAW;CAOjF,OANe,wBAAwB,QAAQ;EAAE,GAAG;EAAS;CAAe,CAMhE,CAAC,CAAC,QAAQ,oBAAoB,SAAS;AACrD"}
|
|
1
|
+
{"version":3,"file":"json-to-zod.js","names":["addDescribes","addDefaults","addAnnotations","jsonSchemaToZod","jsonSchemaToZod","parseObject","jsonSchemaToZodOriginal"],"sources":["../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseAnyOf.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseBoolean.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseDefault.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseMultipleType.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseNot.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseNull.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/utils/half.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseAllOf.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/utils/withMessage.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseArray.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseConst.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseEnum.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseIfThenElse.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseNumber.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseOneOf.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/utils/jsdocs.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseObject.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseString.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseSimpleDiscriminatedOneOf.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/utils/omit.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseNullable.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/parsers/parseSchema.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/jsonSchemaToZod.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.7.0/a13e04d716ba0ad807c80424b9ecc2fa744903d957ce250899a6422d8d845e4a/node_modules/json-schema-to-zod/dist/esm/index.js","../src/json-to-zod.ts"],"sourcesContent":["import { parseSchema } from \"./parseSchema.js\";\nexport const parseAnyOf = (schema, refs) => {\n return schema.anyOf.length\n ? schema.anyOf.length === 1\n ? parseSchema(schema.anyOf[0], {\n ...refs,\n path: [...refs.path, \"anyOf\", 0],\n })\n : `z.union([${schema.anyOf\n .map((schema, i) => parseSchema(schema, { ...refs, path: [...refs.path, \"anyOf\", i] }))\n .join(\", \")}])`\n : `z.any()`;\n};\n","export const parseBoolean = (_schema) => {\n return \"z.boolean()\";\n};\n","export const parseDefault = (_schema) => {\n return \"z.any()\";\n};\n","import { parseSchema } from \"./parseSchema.js\";\nexport const parseMultipleType = (schema, refs) => {\n return `z.union([${schema.type\n .map((type) => parseSchema({ ...schema, type }, { ...refs, withoutDefaults: true }))\n .join(\", \")}])`;\n};\n","import { parseSchema } from \"./parseSchema.js\";\nexport const parseNot = (schema, refs) => {\n return `z.any().refine((value) => !${parseSchema(schema.not, {\n ...refs,\n path: [...refs.path, \"not\"],\n })}.safeParse(value).success, \"Invalid input: Should NOT be valid against schema\")`;\n};\n","export const parseNull = (_schema) => {\n return \"z.null()\";\n};\n","export const half = (arr) => {\n return [arr.slice(0, arr.length / 2), arr.slice(arr.length / 2)];\n};\n","import { parseSchema } from \"./parseSchema.js\";\nimport { half } from \"../utils/half.js\";\nconst originalIndex = Symbol(\"Original index\");\nconst ensureOriginalIndex = (arr) => {\n let newArr = [];\n for (let i = 0; i < arr.length; i++) {\n const item = arr[i];\n if (typeof item === \"boolean\") {\n newArr.push(item ? { [originalIndex]: i } : { [originalIndex]: i, not: {} });\n }\n else if (originalIndex in item) {\n return arr;\n }\n else {\n newArr.push({ ...item, [originalIndex]: i });\n }\n }\n return newArr;\n};\nexport function parseAllOf(schema, refs) {\n if (schema.allOf.length === 0) {\n return \"z.never()\";\n }\n else if (schema.allOf.length === 1) {\n const item = schema.allOf[0];\n return parseSchema(item, {\n ...refs,\n path: [...refs.path, \"allOf\", item[originalIndex]],\n });\n }\n else {\n const [left, right] = half(ensureOriginalIndex(schema.allOf));\n return `z.intersection(${parseAllOf({ allOf: left }, refs)}, ${parseAllOf({\n allOf: right,\n }, refs)})`;\n }\n}\n","export function withMessage(schema, key, get) {\n const value = schema[key];\n let r = \"\";\n if (value !== undefined) {\n const got = get({ value, json: JSON.stringify(value) });\n if (got) {\n const opener = got[0];\n const prefix = got.length === 3 ? got[1] : \"\";\n const closer = got.length === 3 ? got[2] : got[1];\n r += opener;\n if (schema.errorMessage?.[key] !== undefined) {\n r += prefix + JSON.stringify(schema.errorMessage[key]);\n }\n r;\n r += closer;\n }\n }\n return r;\n}\n","import { withMessage } from \"../utils/withMessage.js\";\nimport { parseSchema } from \"./parseSchema.js\";\nexport const parseArray = (schema, refs) => {\n if (Array.isArray(schema.items)) {\n return `z.tuple([${schema.items.map((v, i) => parseSchema(v, { ...refs, path: [...refs.path, \"items\", i] }))}])`;\n }\n let r = !schema.items\n ? \"z.array(z.any())\"\n : `z.array(${parseSchema(schema.items, {\n ...refs,\n path: [...refs.path, \"items\"],\n })})`;\n r += withMessage(schema, \"minItems\", ({ json }) => [\n `.min(${json}`,\n \", \",\n \")\",\n ]);\n r += withMessage(schema, \"maxItems\", ({ json }) => [\n `.max(${json}`,\n \", \",\n \")\",\n ]);\n if (schema.uniqueItems === true) {\n r += withMessage(schema, \"uniqueItems\", () => [\n \".unique(\",\n \"\",\n \")\",\n ]);\n }\n return r;\n};\n","export const parseConst = (schema) => {\n return `z.literal(${JSON.stringify(schema.const)})`;\n};\n","export const parseEnum = (schema) => {\n if (schema.enum.length === 0) {\n return \"z.never()\";\n }\n else if (schema.enum.length === 1) {\n // union does not work when there is only one element\n return `z.literal(${JSON.stringify(schema.enum[0])})`;\n }\n else if (schema.enum.every((x) => typeof x === \"string\")) {\n return `z.enum([${schema.enum.map((x) => JSON.stringify(x))}])`;\n }\n else {\n return `z.union([${schema.enum\n .map((x) => `z.literal(${JSON.stringify(x)})`)\n .join(\", \")}])`;\n }\n};\n","import { parseSchema } from \"./parseSchema.js\";\nexport const parseIfThenElse = (schema, refs) => {\n const $if = parseSchema(schema.if, { ...refs, path: [...refs.path, \"if\"] });\n const $then = parseSchema(schema.then, {\n ...refs,\n path: [...refs.path, \"then\"],\n });\n const $else = parseSchema(schema.else, {\n ...refs,\n path: [...refs.path, \"else\"],\n });\n return `z.union([${$then}, ${$else}]).superRefine((value,ctx) => {\n const result = ${$if}.safeParse(value).success\n ? ${$then}.safeParse(value)\n : ${$else}.safeParse(value);\n if (!result.success) {\n result.error.errors.forEach((error) => ctx.addIssue(error))\n }\n})`;\n};\n","import { withMessage } from \"../utils/withMessage.js\";\nexport const parseNumber = (schema) => {\n let r = \"z.number()\";\n if (schema.type === \"integer\") {\n r += withMessage(schema, \"type\", () => [\".int(\", \")\"]);\n }\n else {\n r += withMessage(schema, \"format\", ({ value }) => {\n if (value === \"int64\") {\n return [\".int(\", \")\"];\n }\n });\n }\n r += withMessage(schema, \"multipleOf\", ({ value, json }) => {\n if (value === 1) {\n if (r.startsWith(\"z.number().int(\")) {\n return;\n }\n return [\".int(\", \")\"];\n }\n return [`.multipleOf(${json}`, \", \", \")\"];\n });\n if (typeof schema.minimum === \"number\") {\n if (schema.exclusiveMinimum === true) {\n r += withMessage(schema, \"minimum\", ({ json }) => [\n `.gt(${json}`,\n \", \",\n \")\",\n ]);\n }\n else {\n r += withMessage(schema, \"minimum\", ({ json }) => [\n `.gte(${json}`,\n \", \",\n \")\",\n ]);\n }\n }\n else if (typeof schema.exclusiveMinimum === \"number\") {\n r += withMessage(schema, \"exclusiveMinimum\", ({ json }) => [\n `.gt(${json}`,\n \", \",\n \")\",\n ]);\n }\n if (typeof schema.maximum === \"number\") {\n if (schema.exclusiveMaximum === true) {\n r += withMessage(schema, \"maximum\", ({ json }) => [\n `.lt(${json}`,\n \", \",\n \")\",\n ]);\n }\n else {\n r += withMessage(schema, \"maximum\", ({ json }) => [\n `.lte(${json}`,\n \", \",\n \")\",\n ]);\n }\n }\n else if (typeof schema.exclusiveMaximum === \"number\") {\n r += withMessage(schema, \"exclusiveMaximum\", ({ json }) => [\n `.lt(${json}`,\n \", \",\n \")\",\n ]);\n }\n return r;\n};\n","import { parseSchema } from \"./parseSchema.js\";\nexport const parseOneOf = (schema, refs) => {\n return schema.oneOf.length\n ? schema.oneOf.length === 1\n ? parseSchema(schema.oneOf[0], {\n ...refs,\n path: [...refs.path, \"oneOf\", 0],\n })\n : `z.any().superRefine((x, ctx) => {\n const schemas = [${schema.oneOf\n .map((schema, i) => parseSchema(schema, {\n ...refs,\n path: [...refs.path, \"oneOf\", i],\n }))\n .join(\", \")}];\n const errors = schemas.reduce<z.ZodError[]>(\n (errors, schema) =>\n ((result) =>\n result.error ? [...errors, result.error] : errors)(\n schema.safeParse(x),\n ),\n [],\n );\n if (schemas.length - errors.length !== 1) {\n ctx.addIssue({\n path: ctx.path,\n code: \"invalid_union\",\n unionErrors: errors,\n message: \"Invalid input: Should pass single schema\",\n });\n }\n })`\n : \"z.any()\";\n};\n","export const expandJsdocs = (jsdocs) => {\n const lines = jsdocs.split(\"\\n\");\n const result = lines.length === 1\n ? lines[0]\n : `\\n${lines.map(x => `* ${x}`)\n .join(\"\\n\")}\\n`;\n return `/**${result}*/\\n`;\n};\nexport const addJsdocs = (schema, parsed) => {\n const description = schema.description;\n if (!description) {\n return parsed;\n }\n return `\\n${expandJsdocs(description)}${parsed}`;\n};\n","import { parseAnyOf } from \"./parseAnyOf.js\";\nimport { parseOneOf } from \"./parseOneOf.js\";\nimport { its, parseSchema } from \"./parseSchema.js\";\nimport { parseAllOf } from \"./parseAllOf.js\";\nimport { addJsdocs } from \"../utils/jsdocs.js\";\nexport function parseObject(objectSchema, refs) {\n let properties = undefined;\n if (objectSchema.properties) {\n if (!Object.keys(objectSchema.properties).length) {\n properties = \"z.object({})\";\n }\n else {\n properties = \"z.object({ \";\n properties += Object.keys(objectSchema.properties)\n .map((key) => {\n const propSchema = objectSchema.properties[key];\n let result = `${JSON.stringify(key)}: ${parseSchema(propSchema, {\n ...refs,\n path: [...refs.path, \"properties\", key],\n })}`;\n if (refs.withJsdocs && typeof propSchema === \"object\") {\n result = addJsdocs(propSchema, result);\n }\n const hasDefault = typeof propSchema === \"object\" && propSchema.default !== undefined;\n const required = Array.isArray(objectSchema.required)\n ? objectSchema.required.includes(key)\n : typeof propSchema === \"object\" && propSchema.required === true;\n const optional = !hasDefault && !required;\n return optional ? `${result}.optional()` : result;\n })\n .join(\", \");\n properties += \" })\";\n }\n }\n const additionalProperties = objectSchema.additionalProperties !== undefined\n ? parseSchema(objectSchema.additionalProperties, {\n ...refs,\n path: [...refs.path, \"additionalProperties\"],\n })\n : undefined;\n let patternProperties = undefined;\n if (objectSchema.patternProperties) {\n const parsedPatternProperties = Object.fromEntries(Object.entries(objectSchema.patternProperties).map(([key, value]) => {\n return [\n key,\n parseSchema(value, {\n ...refs,\n path: [...refs.path, \"patternProperties\", key],\n }),\n ];\n }, {}));\n patternProperties = \"\";\n if (properties) {\n if (additionalProperties) {\n patternProperties += `.catchall(z.union([${[\n ...Object.values(parsedPatternProperties),\n additionalProperties,\n ].join(\", \")}]))`;\n }\n else if (Object.keys(parsedPatternProperties).length > 1) {\n patternProperties += `.catchall(z.union([${Object.values(parsedPatternProperties).join(\", \")}]))`;\n }\n else {\n patternProperties += `.catchall(${Object.values(parsedPatternProperties)})`;\n }\n }\n else {\n if (additionalProperties) {\n patternProperties += `z.record(z.union([${[\n ...Object.values(parsedPatternProperties),\n additionalProperties,\n ].join(\", \")}]))`;\n }\n else if (Object.keys(parsedPatternProperties).length > 1) {\n patternProperties += `z.record(z.union([${Object.values(parsedPatternProperties).join(\", \")}]))`;\n }\n else {\n patternProperties += `z.record(${Object.values(parsedPatternProperties)})`;\n }\n }\n patternProperties += \".superRefine((value, ctx) => {\\n\";\n patternProperties += \"for (const key in value) {\\n\";\n if (additionalProperties) {\n if (objectSchema.properties) {\n patternProperties += `let evaluated = [${Object.keys(objectSchema.properties)\n .map((key) => JSON.stringify(key))\n .join(\", \")}].includes(key)\\n`;\n }\n else {\n patternProperties += `let evaluated = false\\n`;\n }\n }\n for (const key in objectSchema.patternProperties) {\n patternProperties +=\n \"if (key.match(new RegExp(\" + JSON.stringify(key) + \"))) {\\n\";\n if (additionalProperties) {\n patternProperties += \"evaluated = true\\n\";\n }\n patternProperties +=\n \"const result = \" +\n parsedPatternProperties[key] +\n \".safeParse(value[key])\\n\";\n patternProperties += \"if (!result.success) {\\n\";\n patternProperties += `ctx.addIssue({\n path: [...ctx.path, key],\n code: 'custom',\n message: \\`Invalid input: Key matching regex /\\${key}/ must match schema\\`,\n params: {\n issues: result.error.issues\n }\n })\\n`;\n patternProperties += \"}\\n\";\n patternProperties += \"}\\n\";\n }\n if (additionalProperties) {\n patternProperties += \"if (!evaluated) {\\n\";\n patternProperties +=\n \"const result = \" + additionalProperties + \".safeParse(value[key])\\n\";\n patternProperties += \"if (!result.success) {\\n\";\n patternProperties += `ctx.addIssue({\n path: [...ctx.path, key],\n code: 'custom',\n message: \\`Invalid input: must match catchall schema\\`,\n params: {\n issues: result.error.issues\n }\n })\\n`;\n patternProperties += \"}\\n\";\n patternProperties += \"}\\n\";\n }\n patternProperties += \"}\\n\";\n patternProperties += \"})\";\n }\n let output = properties\n ? patternProperties\n ? properties + patternProperties\n : additionalProperties\n ? additionalProperties === \"z.never()\"\n ? properties + \".strict()\"\n : properties + `.catchall(${additionalProperties})`\n : properties\n : patternProperties\n ? patternProperties\n : additionalProperties\n ? `z.record(${additionalProperties})`\n : \"z.record(z.any())\";\n if (its.an.anyOf(objectSchema)) {\n output += `.and(${parseAnyOf({\n ...objectSchema,\n anyOf: objectSchema.anyOf.map((x) => typeof x === \"object\" &&\n !x.type &&\n (x.properties || x.additionalProperties || x.patternProperties)\n ? { ...x, type: \"object\" }\n : x),\n }, refs)})`;\n }\n if (its.a.oneOf(objectSchema)) {\n output += `.and(${parseOneOf({\n ...objectSchema,\n oneOf: objectSchema.oneOf.map((x) => typeof x === \"object\" &&\n !x.type &&\n (x.properties || x.additionalProperties || x.patternProperties)\n ? { ...x, type: \"object\" }\n : x),\n }, refs)})`;\n }\n if (its.an.allOf(objectSchema)) {\n output += `.and(${parseAllOf({\n ...objectSchema,\n allOf: objectSchema.allOf.map((x) => typeof x === \"object\" &&\n !x.type &&\n (x.properties || x.additionalProperties || x.patternProperties)\n ? { ...x, type: \"object\" }\n : x),\n }, refs)})`;\n }\n return output;\n}\n","import { withMessage } from \"../utils/withMessage.js\";\nimport { parseSchema } from \"./parseSchema.js\";\nexport const parseString = (schema) => {\n let r = \"z.string()\";\n r += withMessage(schema, \"format\", ({ value }) => {\n switch (value) {\n case \"email\":\n return [\".email(\", \")\"];\n case \"ip\":\n return [\".ip(\", \")\"];\n case \"ipv4\":\n return ['.ip({ version: \"v4\"', \", message: \", \" })\"];\n case \"ipv6\":\n return ['.ip({ version: \"v6\"', \", message: \", \" })\"];\n case \"uri\":\n return [\".url(\", \")\"];\n case \"uuid\":\n return [\".uuid(\", \")\"];\n case \"date-time\":\n return [\".datetime({ offset: true\", \", message: \", \" })\"];\n case \"time\":\n return [\".time(\", \")\"];\n case \"date\":\n return [\".date(\", \")\"];\n case \"binary\":\n return [\".base64(\", \")\"];\n case \"duration\":\n return [\".duration(\", \")\"];\n }\n });\n r += withMessage(schema, \"pattern\", ({ json }) => [\n `.regex(new RegExp(${json})`,\n \", \",\n \")\",\n ]);\n r += withMessage(schema, \"minLength\", ({ json }) => [\n `.min(${json}`,\n \", \",\n \")\",\n ]);\n r += withMessage(schema, \"maxLength\", ({ json }) => [\n `.max(${json}`,\n \", \",\n \")\",\n ]);\n r += withMessage(schema, \"contentEncoding\", ({ value }) => {\n if (value === \"base64\") {\n return [\".base64(\", \")\"];\n }\n });\n const contentMediaType = withMessage(schema, \"contentMediaType\", ({ value }) => {\n if (value === \"application/json\") {\n return [\n \".transform((str, ctx) => { try { return JSON.parse(str); } catch (err) { ctx.addIssue({ code: \\\"custom\\\", message: \\\"Invalid JSON\\\" }); }}\",\n \", \",\n \")\"\n ];\n }\n });\n if (contentMediaType != \"\") {\n r += contentMediaType;\n r += withMessage(schema, \"contentSchema\", ({ value }) => {\n if (value && value instanceof Object) {\n return [\n `.pipe(${parseSchema(value)}`,\n \", \",\n \")\"\n ];\n }\n });\n }\n return r;\n};\n","import { parseSchema } from \"./parseSchema.js\";\nexport const parseSimpleDiscriminatedOneOf = (schema, refs) => {\n return schema.oneOf.length\n ? schema.oneOf.length === 1\n ? parseSchema(schema.oneOf[0], {\n ...refs,\n path: [...refs.path, \"oneOf\", 0],\n })\n : `z.discriminatedUnion(\"${schema.discriminator.propertyName}\", [${schema.oneOf\n .map((schema, i) => parseSchema(schema, {\n ...refs,\n path: [...refs.path, \"oneOf\", i],\n }))\n .join(\", \")}])`\n : \"z.any()\";\n};\n","export const omit = (obj, ...keys) => Object.keys(obj).reduce((acc, key) => {\n if (!keys.includes(key)) {\n acc[key] = obj[key];\n }\n return acc;\n}, {});\n","import { omit } from \"../utils/omit.js\";\nimport { parseSchema } from \"./parseSchema.js\";\n/**\n * For compatibility with open api 3.0 nullable\n */\nexport const parseNullable = (schema, refs) => {\n return `${parseSchema(omit(schema, \"nullable\"), refs, true)}.nullable()`;\n};\n","import { parseAnyOf } from \"./parseAnyOf.js\";\nimport { parseBoolean } from \"./parseBoolean.js\";\nimport { parseDefault } from \"./parseDefault.js\";\nimport { parseMultipleType } from \"./parseMultipleType.js\";\nimport { parseNot } from \"./parseNot.js\";\nimport { parseNull } from \"./parseNull.js\";\nimport { parseAllOf } from \"./parseAllOf.js\";\nimport { parseArray } from \"./parseArray.js\";\nimport { parseConst } from \"./parseConst.js\";\nimport { parseEnum } from \"./parseEnum.js\";\nimport { parseIfThenElse } from \"./parseIfThenElse.js\";\nimport { parseNumber } from \"./parseNumber.js\";\nimport { parseObject } from \"./parseObject.js\";\nimport { parseString } from \"./parseString.js\";\nimport { parseOneOf } from \"./parseOneOf.js\";\nimport { parseSimpleDiscriminatedOneOf } from \"./parseSimpleDiscriminatedOneOf.js\";\nimport { parseNullable } from \"./parseNullable.js\";\nexport const parseSchema = (schema, refs = { seen: new Map(), path: [] }, blockMeta) => {\n if (typeof schema !== \"object\")\n return schema ? \"z.any()\" : \"z.never()\";\n if (refs.parserOverride) {\n const custom = refs.parserOverride(schema, refs);\n if (typeof custom === \"string\") {\n return custom;\n }\n }\n let seen = refs.seen.get(schema);\n if (seen) {\n if (seen.r !== undefined) {\n return seen.r;\n }\n if (refs.depth === undefined || seen.n >= refs.depth) {\n return \"z.any()\";\n }\n seen.n += 1;\n }\n else {\n seen = { r: undefined, n: 0 };\n refs.seen.set(schema, seen);\n }\n let parsed = selectParser(schema, refs);\n if (!blockMeta) {\n if (!refs.withoutDescribes) {\n parsed = addDescribes(schema, parsed);\n }\n if (!refs.withoutDefaults) {\n parsed = addDefaults(schema, parsed);\n }\n parsed = addAnnotations(schema, parsed);\n }\n seen.r = parsed;\n return parsed;\n};\nconst addDescribes = (schema, parsed) => {\n if (schema.description) {\n parsed += `.describe(${JSON.stringify(schema.description)})`;\n }\n return parsed;\n};\nconst addDefaults = (schema, parsed) => {\n if (schema.default !== undefined) {\n parsed += `.default(${JSON.stringify(schema.default)})`;\n }\n return parsed;\n};\nconst addAnnotations = (schema, parsed) => {\n if (schema.readOnly) {\n parsed += \".readonly()\";\n }\n return parsed;\n};\nconst selectParser = (schema, refs) => {\n if (its.a.nullable(schema)) {\n return parseNullable(schema, refs);\n }\n else if (its.an.object(schema)) {\n return parseObject(schema, refs);\n }\n else if (its.an.array(schema)) {\n return parseArray(schema, refs);\n }\n else if (its.an.anyOf(schema)) {\n return parseAnyOf(schema, refs);\n }\n else if (its.an.allOf(schema)) {\n return parseAllOf(schema, refs);\n }\n else if (its.a.simpleDiscriminatedOneOf(schema)) {\n return parseSimpleDiscriminatedOneOf(schema, refs);\n }\n else if (its.a.oneOf(schema)) {\n return parseOneOf(schema, refs);\n }\n else if (its.a.not(schema)) {\n return parseNot(schema, refs);\n }\n else if (its.an.enum(schema)) {\n return parseEnum(schema); //<-- needs to come before primitives\n }\n else if (its.a.const(schema)) {\n return parseConst(schema);\n }\n else if (its.a.multipleType(schema)) {\n return parseMultipleType(schema, refs);\n }\n else if (its.a.primitive(schema, \"string\")) {\n return parseString(schema);\n }\n else if (its.a.primitive(schema, \"number\") ||\n its.a.primitive(schema, \"integer\")) {\n return parseNumber(schema);\n }\n else if (its.a.primitive(schema, \"boolean\")) {\n return parseBoolean(schema);\n }\n else if (its.a.primitive(schema, \"null\")) {\n return parseNull(schema);\n }\n else if (its.a.conditional(schema)) {\n return parseIfThenElse(schema, refs);\n }\n else {\n return parseDefault(schema);\n }\n};\nexport const its = {\n an: {\n object: (x) => x.type === \"object\",\n array: (x) => x.type === \"array\",\n anyOf: (x) => x.anyOf !== undefined,\n allOf: (x) => x.allOf !== undefined,\n enum: (x) => x.enum !== undefined,\n },\n a: {\n nullable: (x) => x.nullable === true,\n multipleType: (x) => Array.isArray(x.type),\n not: (x) => x.not !== undefined,\n const: (x) => x.const !== undefined,\n primitive: (x, p) => x.type === p,\n conditional: (x) => Boolean(\"if\" in x && x.if && \"then\" in x && \"else\" in x && x.then && x.else),\n simpleDiscriminatedOneOf: (x) => {\n if (!x.oneOf ||\n !Array.isArray(x.oneOf) ||\n x.oneOf.length === 0 ||\n !x.discriminator ||\n typeof x.discriminator !== \"object\" ||\n !(\"propertyName\" in x.discriminator) ||\n typeof x.discriminator.propertyName !== \"string\") {\n return false;\n }\n const discriminatorProp = x.discriminator.propertyName;\n return x.oneOf.every((schema) => {\n if (!schema ||\n typeof schema !== \"object\" ||\n schema.type !== \"object\" ||\n !schema.properties ||\n typeof schema.properties !== \"object\" ||\n !(discriminatorProp in schema.properties)) {\n return false;\n }\n const property = schema.properties[discriminatorProp];\n return (property &&\n typeof property === \"object\" &&\n property.type === \"string\" &&\n // Ensure discriminator has a constant value (const or single-value enum)\n (property.const !== undefined ||\n (property.enum && Array.isArray(property.enum) && property.enum.length === 1)) &&\n // Ensure discriminator property is required\n Array.isArray(schema.required) &&\n schema.required.includes(discriminatorProp));\n });\n },\n oneOf: (x) => x.oneOf !== undefined,\n },\n};\n","import { parseSchema } from \"./parsers/parseSchema.js\";\nimport { expandJsdocs } from \"./utils/jsdocs.js\";\nexport const jsonSchemaToZod = (schema, { module, name, type, noImport, ...rest } = {}) => {\n if (type && (!name || module !== \"esm\")) {\n throw new Error(\"Option `type` requires `name` to be set and `module` to be `esm`\");\n }\n let result = parseSchema(schema, {\n module,\n name,\n path: [],\n seen: new Map(),\n ...rest,\n });\n const jsdocs = rest.withJsdocs && typeof schema !== \"boolean\" && schema.description\n ? expandJsdocs(schema.description)\n : \"\";\n if (module === \"cjs\") {\n result = `${jsdocs}module.exports = ${name ? `{ ${JSON.stringify(name)}: ${result} }` : result}\n`;\n if (!noImport) {\n result = `${jsdocs}const { z } = require(\"zod\")\n\n${result}`;\n }\n }\n else if (module === \"esm\") {\n result = `${jsdocs}export ${name ? `const ${name} =` : `default`} ${result}\n`;\n if (!noImport) {\n result = `import { z } from \"zod\"\n\n${result}`;\n }\n }\n else if (name) {\n result = `${jsdocs}const ${name} = ${result}`;\n }\n if (type && name) {\n let typeName = typeof type === \"string\"\n ? type\n : `${name[0].toUpperCase()}${name.substring(1)}`;\n result += `export type ${typeName} = z.infer<typeof ${name}>\n`;\n }\n return result;\n};\n","export * from \"./Types.js\";\nexport * from \"./jsonSchemaToZod.js\";\nexport * from \"./parsers/parseAllOf.js\";\nexport * from \"./parsers/parseAnyOf.js\";\nexport * from \"./parsers/parseArray.js\";\nexport * from \"./parsers/parseBoolean.js\";\nexport * from \"./parsers/parseConst.js\";\nexport * from \"./parsers/parseDefault.js\";\nexport * from \"./parsers/parseEnum.js\";\nexport * from \"./parsers/parseIfThenElse.js\";\nexport * from \"./parsers/parseMultipleType.js\";\nexport * from \"./parsers/parseNot.js\";\nexport * from \"./parsers/parseNull.js\";\nexport * from \"./parsers/parseNullable.js\";\nexport * from \"./parsers/parseNumber.js\";\nexport * from \"./parsers/parseObject.js\";\nexport * from \"./parsers/parseOneOf.js\";\nexport * from \"./parsers/parseSchema.js\";\nexport * from \"./parsers/parseSimpleDiscriminatedOneOf.js\";\nexport * from \"./parsers/parseString.js\";\nexport * from \"./utils/half.js\";\nexport * from \"./utils/jsdocs.js\";\nexport * from \"./utils/omit.js\";\nexport * from \"./utils/withMessage.js\";\nimport { jsonSchemaToZod } from \"./jsonSchemaToZod.js\";\nexport default jsonSchemaToZod;\n","import type { JsonSchema, JsonSchemaObject, Options, Refs } from 'json-schema-to-zod';\nimport jsonSchemaToZodOriginal, {\n addJsdocs,\n its,\n parseAllOf,\n parseAnyOf,\n parseOneOf,\n parseSchema,\n} from 'json-schema-to-zod';\n\n// Records are always emitted as `z.record(z.string(), value)`. On Zod v4 < 4.4.0 (including\n// zod@3.25.x's `zod/v4` layer), the single-arg form `z.record(value)` stores the argument as\n// `keyType` and leaves `valueType` undefined, which throws when the generated code is evaluated.\nfunction parseObject(objectSchema: JsonSchemaObject & { type: 'object' }, refs: Refs): string {\n let properties: string | undefined = undefined;\n\n if (objectSchema.properties) {\n if (!Object.keys(objectSchema.properties).length) {\n properties = 'z.object({})';\n } else {\n properties = 'z.object({ ';\n\n properties += Object.keys(objectSchema.properties)\n .map(key => {\n const propSchema = objectSchema.properties![key];\n\n let result = `${JSON.stringify(key)}: ${parseSchema(propSchema!, {\n ...refs,\n path: [...refs.path, 'properties', key],\n })}`;\n\n if (refs.withJsdocs && typeof propSchema === 'object') {\n result = addJsdocs(propSchema, result);\n }\n\n const hasDefault = typeof propSchema === 'object' && propSchema.default !== undefined;\n\n const required = Array.isArray(objectSchema.required)\n ? objectSchema.required.includes(key)\n : typeof propSchema === 'object' && propSchema.required === true;\n\n const optional = !hasDefault && !required;\n\n return optional ? `${result}.optional()` : result;\n })\n .join(', ');\n\n properties += ' })';\n }\n }\n\n const additionalProperties =\n objectSchema.additionalProperties !== undefined && objectSchema.additionalProperties !== false\n ? parseSchema(objectSchema.additionalProperties, {\n ...refs,\n path: [...refs.path, 'additionalProperties'],\n })\n : undefined;\n\n let patternProperties: string | undefined = undefined;\n\n if (objectSchema.patternProperties) {\n const parsedPatternProperties = Object.fromEntries(\n Object.entries(objectSchema.patternProperties).map(([key, value]) => {\n return [\n key,\n parseSchema(value, {\n ...refs,\n path: [...refs.path, 'patternProperties', key],\n }),\n ];\n }, {}),\n );\n\n patternProperties = '';\n\n if (properties) {\n if (additionalProperties) {\n patternProperties += `.catchall(z.union([${[\n ...Object.values(parsedPatternProperties),\n additionalProperties,\n ].join(', ')}]))`;\n } else if (Object.keys(parsedPatternProperties).length > 1) {\n patternProperties += `.catchall(z.union([${Object.values(parsedPatternProperties).join(', ')}]))`;\n } else {\n patternProperties += `.catchall(${Object.values(parsedPatternProperties)})`;\n }\n } else {\n if (additionalProperties) {\n patternProperties += `z.record(z.string(), z.union([${[\n ...Object.values(parsedPatternProperties),\n additionalProperties,\n ].join(', ')}]))`;\n } else if (Object.keys(parsedPatternProperties).length > 1) {\n patternProperties += `z.record(z.string(), z.union([${Object.values(parsedPatternProperties).join(', ')}]))`;\n } else {\n patternProperties += `z.record(z.string(), ${Object.values(parsedPatternProperties)})`;\n }\n }\n\n patternProperties += '.superRefine((value, ctx) => {\\n';\n\n patternProperties += 'for (const key in value) {\\n';\n\n if (additionalProperties) {\n if (objectSchema.properties) {\n patternProperties += `let evaluated = [${Object.keys(objectSchema.properties)\n .map(key => JSON.stringify(key))\n .join(', ')}].includes(key)\\n`;\n } else {\n patternProperties += `let evaluated = false\\n`;\n }\n }\n\n for (const key in objectSchema.patternProperties) {\n patternProperties += 'if (key.match(new RegExp(' + JSON.stringify(key) + '))) {\\n';\n if (additionalProperties) {\n patternProperties += 'evaluated = true\\n';\n }\n patternProperties += 'const result = ' + parsedPatternProperties[key] + '.safeParse(value[key])\\n';\n patternProperties += 'if (!result.success) {\\n';\n\n patternProperties += `ctx.addIssue({\n path: [...ctx.path, key],\n code: 'custom',\n message: \\`Invalid input: Key matching regex /\\${key}/ must match schema\\`,\n params: {\n issues: result.error.issues\n }\n })\\n`;\n\n patternProperties += '}\\n';\n patternProperties += '}\\n';\n }\n\n if (additionalProperties) {\n patternProperties += 'if (!evaluated) {\\n';\n patternProperties += 'const result = ' + additionalProperties + '.safeParse(value[key])\\n';\n patternProperties += 'if (!result.success) {\\n';\n\n patternProperties += `ctx.addIssue({\n path: [...ctx.path, key],\n code: 'custom',\n message: \\`Invalid input: must match catchall schema\\`,\n params: {\n issues: result.error.issues\n }\n })\\n`;\n\n patternProperties += '}\\n';\n patternProperties += '}\\n';\n }\n patternProperties += '}\\n';\n patternProperties += '})';\n }\n\n let output = properties\n ? patternProperties\n ? properties + patternProperties\n : additionalProperties\n ? additionalProperties === 'z.never()'\n ? properties + '.strict()'\n : properties + `.catchall(${additionalProperties})`\n : properties\n : patternProperties\n ? patternProperties\n : additionalProperties\n ? `z.record(z.string(), ${additionalProperties})`\n : 'z.record(z.string(), z.any())';\n\n if (its.an.anyOf(objectSchema)) {\n output += `.and(${parseAnyOf(\n {\n ...objectSchema,\n anyOf: objectSchema.anyOf.map(x =>\n typeof x === 'object' && !x.type && (x.properties || x.additionalProperties || x.patternProperties)\n ? { ...x, type: 'object' }\n : x,\n ) as any,\n },\n refs,\n )})`;\n }\n\n if (its.a.oneOf(objectSchema)) {\n output += `.and(${parseOneOf(\n {\n ...objectSchema,\n oneOf: objectSchema.oneOf.map(x =>\n typeof x === 'object' && !x.type && (x.properties || x.additionalProperties || x.patternProperties)\n ? { ...x, type: 'object' }\n : x,\n ) as any,\n },\n refs,\n )})`;\n }\n\n if (its.an.allOf(objectSchema)) {\n output += `.and(${parseAllOf(\n {\n ...objectSchema,\n allOf: objectSchema.allOf.map(x =>\n typeof x === 'object' && !x.type && (x.properties || x.additionalProperties || x.patternProperties)\n ? { ...x, type: 'object' }\n : x,\n ) as any,\n },\n refs,\n )})`;\n }\n\n return output;\n}\n\nconst parserOverride = (schema: JsonSchemaObject, refs: Refs) => {\n let parsed = '';\n let seen = refs.seen.get(schema);\n if (its.an.anyOf(schema)) {\n const allObjects = schema.anyOf.every(\n item => typeof item === 'object' && its.an.object(item) && item.properties !== undefined,\n );\n if (schema.anyOf.length > 1 && allObjects) {\n const propertiesWithConst: string[][] = schema.anyOf.reduce((acc, item) => {\n if (typeof item === 'object' && its.an.object(item)) {\n const propertyWithConst = Object.entries(item.properties ?? {}).filter(\n ([_, value]) => typeof value === 'object' && (value as any)?.const !== undefined,\n );\n if (propertyWithConst?.length) {\n const ppties = propertyWithConst.map(([key, _]) => key);\n acc.push(ppties);\n }\n }\n return acc;\n }, [] as string[][]);\n\n if (propertiesWithConst.length === schema.anyOf.length) {\n if (seen) {\n if (seen.r !== undefined) {\n return seen.r;\n }\n\n if (refs.depth === undefined || seen.n >= refs.depth) {\n return 'z.any()';\n }\n\n seen.n += 1;\n } else {\n seen = { r: undefined, n: 0 };\n refs.seen.set(schema, seen);\n }\n\n const discriminators =\n propertiesWithConst.length > 0 && propertiesWithConst[0]\n ? propertiesWithConst.reduce((common, properties) => {\n return common.filter(prop => properties.includes(prop));\n }, propertiesWithConst[0])\n : [];\n\n if (discriminators.length > 0) {\n const discriminator = discriminators[0];\n if (discriminator) {\n parsed = `z.discriminatedUnion(\"${discriminator}\", [${schema.anyOf\n .map((schema, i) =>\n parseSchema(schema, {\n ...refs,\n path: [...refs.path, 'anyOf', i],\n }),\n )\n .join(', ')}])`;\n }\n }\n }\n }\n } else if (its.an.object(schema)) {\n if (seen) {\n if (seen.r !== undefined) {\n return seen.r;\n }\n\n if (refs.depth === undefined || seen.n >= refs.depth) {\n return 'z.any()';\n }\n\n seen.n += 1;\n } else {\n seen = { r: undefined, n: 0 };\n refs.seen.set(schema, seen);\n }\n\n parsed = parseObject(schema, refs);\n }\n if (parsed) {\n if (!refs.withoutDescribes) {\n parsed = addDescribes(schema, parsed);\n }\n\n if (!refs.withoutDefaults) {\n parsed = addDefaults(schema, parsed);\n }\n\n parsed = addAnnotations(schema, parsed);\n\n if (seen) {\n seen.r = parsed;\n }\n\n return parsed;\n }\n};\n\nconst addDescribes = (schema: JsonSchemaObject, parsed: string): string => {\n if (schema.description) {\n parsed += `.describe(${JSON.stringify(schema.description)})`;\n }\n\n return parsed;\n};\n\nconst addDefaults = (schema: JsonSchemaObject, parsed: string): string => {\n if (schema.default !== undefined) {\n parsed += `.default(${JSON.stringify(schema.default)})`;\n }\n\n return parsed;\n};\n\nconst addAnnotations = (schema: JsonSchemaObject, parsed: string): string => {\n if (schema.readOnly) {\n parsed += '.readonly()';\n }\n\n return parsed;\n};\n\nexport function jsonSchemaToZod(schema: JsonSchema, options: Options = {}): string {\n const result = jsonSchemaToZodOriginal(schema, { ...options, parserOverride });\n\n // Fix: The upstream json-schema-to-zod generates TypeScript syntax `reduce<z.ZodError[]>`\n // in parseOneOf which fails when evaluated at runtime with Function().\n // This catches any oneOf usage that bypasses our parserOverride (e.g., non-object contexts).\n // See: https://github.com/mastra-ai/mastra/issues/11610\n return result.replace(/\\.reduce<[^>]+>/g, '.reduce');\n}\n\n// Re-export all named exports from json-schema-to-zod (excluding the default export)\nexport * from 'json-schema-to-zod';\n"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23],"mappings":";AACA,MAAa,cAAc,QAAQ,SAAS;CACxC,OAAO,OAAO,MAAM,SACd,OAAO,MAAM,WAAW,IACpB,YAAY,OAAO,MAAM,IAAI;EAC3B,GAAG;EACH,MAAM;GAAC,GAAG,KAAK;GAAM;GAAS;EAAC;CACnC,CAAC,IACC,YAAY,OAAO,MAChB,KAAK,QAAQ,MAAM,YAAY,QAAQ;EAAE,GAAG;EAAM,MAAM;GAAC,GAAG,KAAK;GAAM;GAAS;EAAC;CAAE,CAAC,CAAC,CAAC,CACtF,KAAK,IAAI,EAAE,MAClB;AACV;;;ACZA,MAAa,gBAAgB,YAAY;CACrC,OAAO;AACX;;;ACFA,MAAa,gBAAgB,YAAY;CACrC,OAAO;AACX;;;ACDA,MAAa,qBAAqB,QAAQ,SAAS;CAC/C,OAAO,YAAY,OAAO,KACrB,KAAK,SAAS,YAAY;EAAE,GAAG;EAAQ;CAAK,GAAG;EAAE,GAAG;EAAM,iBAAiB;CAAK,C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AC5B;EAEA,SAASA,cAAY,QAAQ,IAAI;CACnC;CACA,IAAI,QAAQ;EACV,IAAI,CAAC,KAAK,kBACR,SAAS,aAAa,QAAQ,MAAM;EAGtC,IAAI,CAAC,KAAK,iBACR,SAAS,YAAY,QAAQ,MAAM;EAGrC,SAAS,eAAe,QAAQ,MAAM;EAEtC,IAAI,MACF,KAAK,IAAI;EAGX,OAAO;CACT;AACF;AAEA,MAAM,gBAAgB,QAA0B,WAA2B;CACzE,IAAI,OAAO,aACT,UAAU,aAAa,KAAK,UAAU,OAAO,WAAW,EAAE;CAG5D,OAAO;AACT;AAEA,MAAM,eAAe,QAA0B,WAA2B;CACxE,IAAI,OAAO,YAAY,KAAA,GACrB,UAAU,YAAY,KAAK,UAAU,OAAO,OAAO,EAAE;CAGvD,OAAO;AACT;AAEA,MAAM,kBAAkB,QAA0B,WAA2B;CAC3E,IAAI,OAAO,UACT,UAAU;CAGZ,OAAO;AACT;AAEA,SAAgB,gBAAgB,QAAoB,UAAmB,CAAC,GAAW;CAOjF,OANeC,YAAwB,QAAQ;EAAE,GAAG;EAAS;CAAe,CAMhE,CAAC,CAAC,QAAQ,oBAAoB,SAAS;AACrD"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_json_schema_traverse = require("./json-schema-traverse-DbuWNYgg.cjs");
|
|
2
2
|
const require_zod_to_json = require("./zod-to-json.cjs");
|
|
3
3
|
const require_standard_schema_adapters_ai_sdk = require("./standard-schema/adapters/ai-sdk.cjs");
|
|
4
|
-
const require_json_schema = require("./json-schema-
|
|
4
|
+
const require_json_schema = require("./json-schema-C7Uhaeop.cjs");
|
|
5
5
|
const require_standard_schema_adapters_zod_v3 = require("./standard-schema/adapters/zod-v3.cjs");
|
|
6
6
|
let zod_v3 = require("zod/v3");
|
|
7
|
-
zod_v3 =
|
|
7
|
+
zod_v3 = require_json_schema_traverse.__toESM(zod_v3, 1);
|
|
8
8
|
let zod_v4 = require("zod/v4");
|
|
9
9
|
//#region src/standard-schema/adapters/zod-v4.ts
|
|
10
10
|
/**
|
|
@@ -292,4 +292,4 @@ Object.defineProperty(exports, "toStandardSchema", {
|
|
|
292
292
|
}
|
|
293
293
|
});
|
|
294
294
|
|
|
295
|
-
//# sourceMappingURL=schema-
|
|
295
|
+
//# sourceMappingURL=schema-5p36X0wR.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-Bw7nQdgA.cjs","names":["toStandardSchema","z3","toStandardSchemaZodV4","toStandardSchemaZodV3","toStandardSchemaAiSdk","toStandardSchemaJsonSchema"],"sources":["../src/standard-schema/adapters/zod-v4.ts","../src/standard-schema/standard-schema.ts"],"sourcesContent":["import type { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';\nimport { toJSONSchema } from 'zod/v4';\nimport { patchRecordSchemas } from '../../zod-to-json';\nimport type { StandardSchemaWithJSON, StandardSchemaWithJSONProps } from '../standard-schema.types';\n\n/**\n * Supported JSON Schema targets for z.toJSONSchema().\n * Works with both real Zod v4 and Zod 3.25's v4 compat layer.\n */\nconst SUPPORTED_TARGETS = new Set(['draft-07', 'draft-04', 'draft-2020-12']);\n\n/**\n * Maps Mastra's target names to Zod v4's expected format.\n * Zod v4's z.toJSONSchema() expects \"draft-7\" instead of \"draft-07\",\n * and \"draft-4\" instead of \"draft-04\".\n */\nconst ZOD_V4_TARGET_MAP: Record<string, string> = {\n 'draft-07': 'draft-7',\n 'draft-04': 'draft-4',\n};\n\n/**\n * Options for the Zod v4 adapter's JSON Schema conversion.\n */\nexport interface ZodV4AdapterOptions {\n unrepresentable?: 'any' | 'error';\n override?: (ctx: { zodSchema: unknown; jsonSchema: Record<string, unknown> }) => undefined;\n}\n\n/**\n * Converts a Zod v4 schema to JSON Schema using z.toJSONSchema().\n *\n * Works with both real Zod v4 and Zod 3.25's v4 compat layer.\n *\n * @internal\n */\nfunction convertToJsonSchema(\n zodSchema: unknown,\n options: StandardJSONSchemaV1.Options,\n adapterOptions: ZodV4AdapterOptions,\n): Record<string, unknown> {\n // Work around a Zod v4 bug where `z.record(valueSchema)` puts the value\n // in `def.keyType` instead of `def.valueType`, which crashes\n // `toJSONSchema`'s `recordProcessor`. The legacy `zodToJsonSchema` entry\n // applies the same patch; this keeps the `applyCompatLayer` path in sync.\n // Idempotent — safe to call repeatedly.\n patchRecordSchemas(zodSchema);\n\n const target = SUPPORTED_TARGETS.has(options.target) ? options.target : 'draft-07';\n\n const jsonSchemaOptions: Record<string, unknown> = {\n target: ZOD_V4_TARGET_MAP[target] ?? target,\n };\n\n if (adapterOptions.unrepresentable) {\n jsonSchemaOptions.unrepresentable = adapterOptions.unrepresentable;\n }\n\n // The override option works in real Zod v4 but is a no-op in 3.25 compat.\n if (adapterOptions.override) {\n jsonSchemaOptions.override = adapterOptions.override;\n }\n\n return toJSONSchema(zodSchema as Parameters<typeof toJSONSchema>[0], jsonSchemaOptions) as Record<string, unknown>;\n}\n\n/**\n * Wraps a Zod v4 schema to implement the full @standard-schema/spec interface.\n *\n * Zod v4 schemas (and Zod 3.25's v4 compat layer) implement `StandardSchemaV1`\n * (validation) but may not implement `StandardJSONSchemaV1` (JSON Schema conversion)\n * on the `~standard` property. This adapter adds the `jsonSchema` property using\n * `z.toJSONSchema()` to provide JSON Schema conversion capabilities.\n *\n * @param zodSchema - A Zod v4 schema (has `_zod` property)\n * @param adapterOptions - Options passed to z.toJSONSchema()\n * @returns The schema wrapped with StandardSchemaWithJSON support\n */\nexport function toStandardSchema<T>(\n zodSchema: T & { _zod: unknown; '~standard': StandardSchemaV1.Props },\n adapterOptions: ZodV4AdapterOptions = {},\n): T & StandardSchemaWithJSON {\n // Create a wrapper object that preserves the original schema's prototype chain\n const wrapper = Object.create(zodSchema) as T & StandardSchemaWithJSON;\n\n // Get the existing ~standard property from Zod\n const existingStandard = (zodSchema as any)['~standard'] as StandardSchemaV1.Props;\n\n // Create the JSON Schema converter using z.toJSONSchema()\n const jsonSchemaConverter: StandardJSONSchemaV1.Converter = {\n input: (options: StandardJSONSchemaV1.Options): Record<string, unknown> => {\n return convertToJsonSchema(zodSchema, options, adapterOptions);\n },\n output: (options: StandardJSONSchemaV1.Options): Record<string, unknown> => {\n return convertToJsonSchema(zodSchema, options, adapterOptions);\n },\n };\n\n // Define the enhanced ~standard property\n Object.defineProperty(wrapper, '~standard', {\n value: {\n ...existingStandard,\n jsonSchema: jsonSchemaConverter,\n } satisfies StandardSchemaWithJSONProps,\n writable: false,\n enumerable: true,\n configurable: false,\n });\n\n return wrapper;\n}\n","import type { Schema } from '@internal/ai-v6';\nimport type { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/spec';\nimport type { JSONSchema7 } from 'json-schema';\nimport z3 from 'zod/v3';\nimport type { ZodType } from 'zod/v3';\nimport type { PublicSchema } from '../schema.types';\nimport { patchRecordSchemas } from '../zod-to-json';\nimport { toStandardSchema as toStandardSchemaAiSdk } from './adapters/ai-sdk';\nimport { toStandardSchema as toStandardSchemaJsonSchema } from './adapters/json-schema';\nimport { toStandardSchema as toStandardSchemaZodV3 } from './adapters/zod-v3';\nimport { toStandardSchema as toStandardSchemaZodV4 } from './adapters/zod-v4';\nimport type { StandardSchemaWithJSON } from './standard-schema.types';\n\n/**\n * Override function for JSON Schema conversion.\n * Handles types that Zod v4 cannot natively represent in JSON Schema:\n * - z.date() -> { type: 'string', format: 'date-time' }\n */\nfunction jsonSchemaOverride(ctx: { zodSchema: unknown; jsonSchema: Record<string, unknown> }): undefined {\n const zodSchema = ctx.zodSchema as {\n type?: string;\n _def?: { typeName?: string };\n _zod?: { def?: { type?: string; coerce?: boolean } };\n optional?: () => unknown;\n };\n\n if (\n ctx.jsonSchema.type === 'object' &&\n ctx.jsonSchema.properties !== undefined &&\n !ctx.jsonSchema.additionalProperties\n ) {\n ctx.jsonSchema.additionalProperties = false;\n }\n\n if (zodSchema) {\n // Zod v4: zodSchema.type === 'date'\n // Zod v3: zodSchema._def.typeName === 'ZodDate'\n const isDateType = zodSchema?.type === 'date' || zodSchema?._def?.typeName === 'ZodDate';\n\n if (isDateType) {\n // Zod v4 dates need explicit JSON schema conversion (zod-to-json-schema doesn't handle them)\n if (zodSchema?.type === 'date') {\n ctx.jsonSchema.type = 'string';\n ctx.jsonSchema.format = 'date-time';\n }\n // Mark dates for #traverse: x-date=true means string→Date conversion needed.\n // z.coerce.date() handles its own coercion, so mark as false to prevent conversion.\n // Zod v3 has no coerce, so all v3 dates are strict (handled by preProcessJSONNode fallback).\n ctx.jsonSchema['x-date'] = !zodSchema._zod?.def?.coerce;\n // @ts-expect-error - catchall is a valid property for zod\n } else if (zodSchema?.type === 'object' && zodSchema._zod?.def?.catchall?.type === 'unknown') {\n ctx.jsonSchema.additionalProperties = true;\n }\n }\n\n return undefined;\n}\n/**\n * Library options for JSON Schema conversion.\n * - unrepresentable: 'any' allows z.custom() and other unrepresentable types to be converted to {}\n * instead of throwing \"Custom types cannot be represented in JSON Schema\"\n * - override: converts z.date() to { type: 'string', format: 'date-time' }\n */\nexport const JSON_SCHEMA_LIBRARY_OPTIONS = {\n unrepresentable: 'any' as const,\n override: jsonSchemaOverride,\n};\n\nexport type {\n StandardSchemaWithJSON,\n StandardSchemaWithJSONProps,\n InferInput,\n InferOutput,\n StandardSchemaIssue,\n} from './standard-schema.types';\n\nfunction isVercelSchema(schema: unknown): schema is Schema {\n return (\n typeof schema === 'object' &&\n schema !== null &&\n '_type' in schema &&\n 'jsonSchema' in schema &&\n typeof (schema as Schema).jsonSchema === 'object'\n );\n}\n\n/**\n * Check if a schema is Zod v4 (has _zod property which is v4-only)\n */\nfunction isZodV4(schema: unknown): boolean {\n return typeof schema === 'object' && schema !== null && '_zod' in schema;\n}\n\n/**\n * Check if a schema is Zod v3.\n *\n * Zod v3 can come from:\n * 1. The old standalone 'zod-v3' package\n * 2. The 'zod/v3' compat export from modern zod\n *\n * We detect Zod v3 by checking:\n * - Has ~standard.vendor === 'zod' (both v3 and v4 have this)\n * - Does NOT have ~standard.jsonSchema (only Zod v4 has native JSON Schema support)\n * - Does NOT have _zod property (only Zod v4 has this)\n *\n * Note: We can't use instanceof z3.ZodType because the old 'zod-v3' package\n * has a different prototype chain than 'zod/v3'.\n */\nfunction isZodV3(schema: unknown): schema is ZodType {\n if (schema === null || typeof schema !== 'object') {\n return false;\n }\n\n // Must not be Zod v4\n if (isZodV4(schema)) {\n return false;\n }\n\n // Check for ~standard with vendor 'zod' but no jsonSchema\n if ('~standard' in schema) {\n const std = (schema as any)['~standard'];\n if (typeof std === 'object' && std !== null && std.vendor === 'zod' && !('jsonSchema' in std)) {\n return true;\n }\n }\n\n // Fallback: check instanceof for zod/v3 compat export\n return schema instanceof z3.ZodType;\n}\n\nexport function toStandardSchema<T = unknown>(schema: PublicSchema<T>): StandardSchemaWithJSON<T> {\n // Work around a Zod v4 (< 4.4.0) bug where single-arg `z.record(valueSchema)`\n // puts the value in `def.keyType` and leaves `def.valueType` undefined, which\n // crashes `toJSONSchema`'s recordProcessor. This must run BEFORE the\n // StandardSchemaWithJSON short-circuit below: Zod >= 4.2 natively exposes\n // `~standard.jsonSchema`, so those schemas are returned as-is and never go\n // through our Zod v4 adapter. Patching mutates the defs in place, so Zod's\n // native converter picks up the fix too. Idempotent — safe to call repeatedly.\n if (isZodV4(schema)) {\n patchRecordSchemas(schema);\n }\n\n // First check: if already StandardSchemaWithJSON, return as-is\n // This handles ArkType, Zod v4 (when it has jsonSchema), and pre-wrapped schemas\n if (isStandardSchemaWithJSON(schema)) {\n return schema;\n }\n\n // Check for Zod v4 schemas without ~standard.jsonSchema\n // This handles both real Zod v4 and Zod 3.25's v4 compat layer where\n // ~standard.jsonSchema is not present on the schema object\n if (isZodV4(schema)) {\n return toStandardSchemaZodV4(schema as any, {\n unrepresentable: JSON_SCHEMA_LIBRARY_OPTIONS.unrepresentable,\n override: JSON_SCHEMA_LIBRARY_OPTIONS.override,\n });\n }\n\n // Check for Zod v3 schemas (need wrapping to add JSON Schema support)\n // Important: Must use isZodV3() not instanceof z3.ZodType because\n // Zod v4 schemas are also instanceof z3.ZodType due to prototype compatibility\n if (isZodV3(schema)) {\n return toStandardSchemaZodV3(schema as ZodType);\n }\n\n // Check for AI SDK Schema objects (Vercel's jsonSchema wrapper)\n if (isVercelSchema(schema)) {\n return toStandardSchemaAiSdk(schema);\n }\n\n // At this point, assume it's a plain JSON Schema object\n // JSON Schema objects are plain objects with properties like 'type', 'properties', etc.\n if (schema === null || (typeof schema !== 'object' && typeof schema !== 'function')) {\n throw new Error(`Unsupported schema type: ${typeof schema}`);\n }\n\n // If it's a function that's not StandardSchemaWithJSON, it's not supported\n if (typeof schema === 'function') {\n throw new Error(`Unsupported schema type: function (schema libraries should implement StandardSchemaWithJSON)`);\n }\n\n return toStandardSchemaJsonSchema(schema as JSONSchema7);\n}\n\n/**\n * Type guard to check if a value implements the StandardSchemaV1 interface.\n *\n * @param value - The value to check\n * @returns True if the value implements StandardSchemaV1\n *\n * @example\n * ```typescript\n * import { isStandardSchema } from '@mastra/schema-compat';\n *\n * if (isStandardSchema(someValue)) {\n * const result = someValue['~standard'].validate(input);\n * }\n * ```\n */\nexport function isStandardSchema(value: unknown): value is StandardSchemaV1 {\n // Check for object or function (some libraries like ArkType use callable schemas)\n if (value === null || (typeof value !== 'object' && typeof value !== 'function')) {\n return false;\n }\n if (!('~standard' in value)) {\n return false;\n }\n const std = (value as any)['~standard'];\n return (\n typeof std === 'object' &&\n std !== null &&\n 'version' in std &&\n std.version === 1 &&\n 'vendor' in std &&\n 'validate' in std &&\n typeof std.validate === 'function'\n );\n}\n\n/**\n * Type guard to check if a value implements the StandardJSONSchemaV1 interface.\n *\n * @param value - The value to check\n * @returns True if the value implements StandardJSONSchemaV1\n *\n * @example\n * ```typescript\n * import { isStandardJSONSchema } from '@mastra/schema-compat';\n *\n * if (isStandardJSONSchema(someValue)) {\n * const jsonSchema = someValue['~standard'].jsonSchema.output({ target: 'draft-07' });\n * }\n * ```\n */\nexport function isStandardJSONSchema(value: unknown): value is StandardJSONSchemaV1 {\n // Check for object or function (some libraries like ArkType use callable schemas)\n if (value === null || (typeof value !== 'object' && typeof value !== 'function')) {\n return false;\n }\n if (!('~standard' in value)) {\n return false;\n }\n const std = (value as any)['~standard'];\n if (typeof std !== 'object' || std === null) {\n return false;\n }\n if (!('version' in std) || std.version !== 1 || !('vendor' in std)) {\n return false;\n }\n if (!('jsonSchema' in std) || typeof std.jsonSchema !== 'object') {\n return false;\n }\n return typeof std.jsonSchema.input === 'function' && typeof std.jsonSchema.output === 'function';\n}\n\n/**\n * Type guard to check if a value implements both StandardSchemaV1 and StandardJSONSchemaV1.\n *\n * @param value - The value to check\n * @returns True if the value implements both interfaces\n *\n * @example\n * ```typescript\n * import { isStandardSchemaWithJSON } from '@mastra/schema-compat';\n *\n * if (isStandardSchemaWithJSON(someValue)) {\n * // Can use both validation and JSON Schema conversion\n * const result = someValue['~standard'].validate(input);\n * const jsonSchema = someValue['~standard'].jsonSchema.output({ target: 'draft-07' });\n * }\n * ```\n */\nexport function isStandardSchemaWithJSON(value: unknown): value is StandardSchemaWithJSON {\n return isStandardSchema(value) && isStandardJSONSchema(value);\n}\n\n/**\n * Converts a StandardSchemaWithJSON to a JSON Schema.\n *\n * @param schema - The StandardSchemaWithJSON schema to convert\n * @param options - Conversion options\n * @param options.target - The JSON Schema target version (default: 'draft-07')\n * @param options.io - Whether to use input or output schema (default: 'output')\n * - 'input': Use for tool parameters, function arguments, request bodies\n * - 'output': Use for return types, response bodies\n * @returns The JSON Schema representation\n *\n * @example\n * ```typescript\n * import { standardSchemaToJSONSchema, toStandardSchema } from '@mastra/schema-compat';\n * import { z } from 'zod';\n *\n * const zodSchema = z.object({ name: z.string() });\n * const standardSchema = toStandardSchema(zodSchema);\n *\n * // For output types (default)\n * const outputSchema = standardSchemaToJSONSchema(standardSchema);\n *\n * // For input types (tool parameters)\n * const inputSchema = standardSchemaToJSONSchema(standardSchema, { io: 'input' });\n * ```\n */\nexport function standardSchemaToJSONSchema(\n schema: StandardSchemaWithJSON,\n options: {\n target?: StandardJSONSchemaV1.Target;\n io?: 'input' | 'output';\n override?: (typeof JSON_SCHEMA_LIBRARY_OPTIONS)['override'];\n } = {},\n): JSONSchema7 {\n const { target = 'draft-07', io = 'output', override = JSON_SCHEMA_LIBRARY_OPTIONS.override } = options;\n const jsonSchemaFn = schema['~standard'].jsonSchema[io];\n let jsonSchema = jsonSchemaFn({\n target,\n libraryOptions: {\n ...JSON_SCHEMA_LIBRARY_OPTIONS,\n override,\n },\n }) as JSONSchema7;\n\n // make sure only jsonSchema is left, no standard schema metadata\n jsonSchema = JSON.parse(JSON.stringify(jsonSchema));\n\n return jsonSchema;\n}\n"],"mappings":";;;;;;;;;;;;;AASA,MAAM,oCAAoB,IAAI,IAAI;CAAC;CAAY;CAAY;AAAe,CAAC;;;;;;AAO3E,MAAM,oBAA4C;CAChD,YAAY;CACZ,YAAY;AACd;;;;;;;;AAiBA,SAAS,oBACP,WACA,SACA,gBACyB;CAMzB,oBAAA,mBAAmB,SAAS;CAE5B,MAAM,SAAS,kBAAkB,IAAI,QAAQ,MAAM,IAAI,QAAQ,SAAS;CAExE,MAAM,oBAA6C,EACjD,QAAQ,kBAAkB,WAAW,OACvC;CAEA,IAAI,eAAe,iBACjB,kBAAkB,kBAAkB,eAAe;CAIrD,IAAI,eAAe,UACjB,kBAAkB,WAAW,eAAe;CAG9C,QAAA,GAAA,OAAA,aAAA,CAAoB,WAAiD,iBAAiB;AACxF;;;;;;;;;;;;;AAcA,SAAgBA,mBACd,WACA,iBAAsC,CAAC,GACX;CAE5B,MAAM,UAAU,OAAO,OAAO,SAAS;CAGvC,MAAM,mBAAoB,UAAkB;CAG5C,MAAM,sBAAsD;EAC1D,QAAQ,YAAmE;GACzE,OAAO,oBAAoB,WAAW,SAAS,cAAc;EAC/D;EACA,SAAS,YAAmE;GAC1E,OAAO,oBAAoB,WAAW,SAAS,cAAc;EAC/D;CACF;CAGA,OAAO,eAAe,SAAS,aAAa;EAC1C,OAAO;GACL,GAAG;G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gB,yBAAyB,OAAiD;CACxF,OAAO,iBAAiB,KAAK,KAAK,qBAAqB,KAAK;AAC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,2BACd,QACA,UAII,CAAC,GACQ;CACb,MAAM,EAAE,SAAS,YAAY,KAAK,UAAU,WAAW,4BAA4B,aAAa;CAChG,MAAM,eAAe,OAAO,YAAY,CAAC,WAAW;CACpD,IAAI,aAAa,aAAa;EAC5B;EACA,gBAAgB;GACd,GAAG;GACH;EACF;CACF,CAAC;CAGD,aAAa,KAAK,MAAM,KAAK,UAAU,UAAU,CAAC;CAElD,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"schema-5p36X0wR.cjs","names":["toStandardSchema","z3","toStandardSchemaZodV4","toStandardSchemaZodV3","toStandardSchemaAiSdk","toStandardSchemaJsonSchema"],"sources":["../src/standard-schema/adapters/zod-v4.ts","../src/standard-schema/standard-schema.ts"],"sourcesContent":["import type { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';\nimport { toJSONSchema } from 'zod/v4';\nimport { patchRecordSchemas } from '../../zod-to-json';\nimport type { StandardSchemaWithJSON, StandardSchemaWithJSONProps } from '../standard-schema.types';\n\n/**\n * Supported JSON Schema targets for z.toJSONSchema().\n * Works with both real Zod v4 and Zod 3.25's v4 compat layer.\n */\nconst SUPPORTED_TARGETS = new Set(['draft-07', 'draft-04', 'draft-2020-12']);\n\n/**\n * Maps Mastra's target names to Zod v4's expected format.\n * Zod v4's z.toJSONSchema() expects \"draft-7\" instead of \"draft-07\",\n * and \"draft-4\" instead of \"draft-04\".\n */\nconst ZOD_V4_TARGET_MAP: Record<string, string> = {\n 'draft-07': 'draft-7',\n 'draft-04': 'draft-4',\n};\n\n/**\n * Options for the Zod v4 adapter's JSON Schema conversion.\n */\nexport interface ZodV4AdapterOptions {\n unrepresentable?: 'any' | 'error';\n override?: (ctx: { zodSchema: unknown; jsonSchema: Record<string, unknown> }) => undefined;\n}\n\n/**\n * Converts a Zod v4 schema to JSON Schema using z.toJSONSchema().\n *\n * Works with both real Zod v4 and Zod 3.25's v4 compat layer.\n *\n * @internal\n */\nfunction convertToJsonSchema(\n zodSchema: unknown,\n options: StandardJSONSchemaV1.Options,\n adapterOptions: ZodV4AdapterOptions,\n): Record<string, unknown> {\n // Work around a Zod v4 bug where `z.record(valueSchema)` puts the value\n // in `def.keyType` instead of `def.valueType`, which crashes\n // `toJSONSchema`'s `recordProcessor`. The legacy `zodToJsonSchema` entry\n // applies the same patch; this keeps the `applyCompatLayer` path in sync.\n // Idempotent — safe to call repeatedly.\n patchRecordSchemas(zodSchema);\n\n const target = SUPPORTED_TARGETS.has(options.target) ? options.target : 'draft-07';\n\n const jsonSchemaOptions: Record<string, unknown> = {\n target: ZOD_V4_TARGET_MAP[target] ?? target,\n };\n\n if (adapterOptions.unrepresentable) {\n jsonSchemaOptions.unrepresentable = adapterOptions.unrepresentable;\n }\n\n // The override option works in real Zod v4 but is a no-op in 3.25 compat.\n if (adapterOptions.override) {\n jsonSchemaOptions.override = adapterOptions.override;\n }\n\n return toJSONSchema(zodSchema as Parameters<typeof toJSONSchema>[0], jsonSchemaOptions) as Record<string, unknown>;\n}\n\n/**\n * Wraps a Zod v4 schema to implement the full @standard-schema/spec interface.\n *\n * Zod v4 schemas (and Zod 3.25's v4 compat layer) implement `StandardSchemaV1`\n * (validation) but may not implement `StandardJSONSchemaV1` (JSON Schema conversion)\n * on the `~standard` property. This adapter adds the `jsonSchema` property using\n * `z.toJSONSchema()` to provide JSON Schema conversion capabilities.\n *\n * @param zodSchema - A Zod v4 schema (has `_zod` property)\n * @param adapterOptions - Options passed to z.toJSONSchema()\n * @returns The schema wrapped with StandardSchemaWithJSON support\n */\nexport function toStandardSchema<T>(\n zodSchema: T & { _zod: unknown; '~standard': StandardSchemaV1.Props },\n adapterOptions: ZodV4AdapterOptions = {},\n): T & StandardSchemaWithJSON {\n // Create a wrapper object that preserves the original schema's prototype chain\n const wrapper = Object.create(zodSchema) as T & StandardSchemaWithJSON;\n\n // Get the existing ~standard property from Zod\n const existingStandard = (zodSchema as any)['~standard'] as StandardSchemaV1.Props;\n\n // Create the JSON Schema converter using z.toJSONSchema()\n const jsonSchemaConverter: StandardJSONSchemaV1.Converter = {\n input: (options: StandardJSONSchemaV1.Options): Record<string, unknown> => {\n return convertToJsonSchema(zodSchema, options, adapterOptions);\n },\n output: (options: StandardJSONSchemaV1.Options): Record<string, unknown> => {\n return convertToJsonSchema(zodSchema, options, adapterOptions);\n },\n };\n\n // Define the enhanced ~standard property\n Object.defineProperty(wrapper, '~standard', {\n value: {\n ...existingStandard,\n jsonSchema: jsonSchemaConverter,\n } satisfies StandardSchemaWithJSONProps,\n writable: false,\n enumerable: true,\n configurable: false,\n });\n\n return wrapper;\n}\n","import type { Schema } from '@internal/ai-v6';\nimport type { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/spec';\nimport type { JSONSchema7 } from 'json-schema';\nimport z3 from 'zod/v3';\nimport type { ZodType } from 'zod/v3';\nimport type { PublicSchema } from '../schema.types';\nimport { patchRecordSchemas } from '../zod-to-json';\nimport { toStandardSchema as toStandardSchemaAiSdk } from './adapters/ai-sdk';\nimport { toStandardSchema as toStandardSchemaJsonSchema } from './adapters/json-schema';\nimport { toStandardSchema as toStandardSchemaZodV3 } from './adapters/zod-v3';\nimport { toStandardSchema as toStandardSchemaZodV4 } from './adapters/zod-v4';\nimport type { StandardSchemaWithJSON } from './standard-schema.types';\n\n/**\n * Override function for JSON Schema conversion.\n * Handles types that Zod v4 cannot natively represent in JSON Schema:\n * - z.date() -> { type: 'string', format: 'date-time' }\n */\nfunction jsonSchemaOverride(ctx: { zodSchema: unknown; jsonSchema: Record<string, unknown> }): undefined {\n const zodSchema = ctx.zodSchema as {\n type?: string;\n _def?: { typeName?: string };\n _zod?: { def?: { type?: string; coerce?: boolean } };\n optional?: () => unknown;\n };\n\n if (\n ctx.jsonSchema.type === 'object' &&\n ctx.jsonSchema.properties !== undefined &&\n !ctx.jsonSchema.additionalProperties\n ) {\n ctx.jsonSchema.additionalProperties = false;\n }\n\n if (zodSchema) {\n // Zod v4: zodSchema.type === 'date'\n // Zod v3: zodSchema._def.typeName === 'ZodDate'\n const isDateType = zodSchema?.type === 'date' || zodSchema?._def?.typeName === 'ZodDate';\n\n if (isDateType) {\n // Zod v4 dates need explicit JSON schema conversion (zod-to-json-schema doesn't handle them)\n if (zodSchema?.type === 'date') {\n ctx.jsonSchema.type = 'string';\n ctx.jsonSchema.format = 'date-time';\n }\n // Mark dates for #traverse: x-date=true means string→Date conversion needed.\n // z.coerce.date() handles its own coercion, so mark as false to prevent conversion.\n // Zod v3 has no coerce, so all v3 dates are strict (handled by preProcessJSONNode fallback).\n ctx.jsonSchema['x-date'] = !zodSchema._zod?.def?.coerce;\n // @ts-expect-error - catchall is a valid property for zod\n } else if (zodSchema?.type === 'object' && zodSchema._zod?.def?.catchall?.type === 'unknown') {\n ctx.jsonSchema.additionalProperties = true;\n }\n }\n\n return undefined;\n}\n/**\n * Library options for JSON Schema conversion.\n * - unrepresentable: 'any' allows z.custom() and other unrepresentable types to be converted to {}\n * instead of throwing \"Custom types cannot be represented in JSON Schema\"\n * - override: converts z.date() to { type: 'string', format: 'date-time' }\n */\nexport const JSON_SCHEMA_LIBRARY_OPTIONS = {\n unrepresentable: 'any' as const,\n override: jsonSchemaOverride,\n};\n\nexport type {\n StandardSchemaWithJSON,\n StandardSchemaWithJSONProps,\n InferInput,\n InferOutput,\n StandardSchemaIssue,\n} from './standard-schema.types';\n\nfunction isVercelSchema(schema: unknown): schema is Schema {\n return (\n typeof schema === 'object' &&\n schema !== null &&\n '_type' in schema &&\n 'jsonSchema' in schema &&\n typeof (schema as Schema).jsonSchema === 'object'\n );\n}\n\n/**\n * Check if a schema is Zod v4 (has _zod property which is v4-only)\n */\nfunction isZodV4(schema: unknown): boolean {\n return typeof schema === 'object' && schema !== null && '_zod' in schema;\n}\n\n/**\n * Check if a schema is Zod v3.\n *\n * Zod v3 can come from:\n * 1. The old standalone 'zod-v3' package\n * 2. The 'zod/v3' compat export from modern zod\n *\n * We detect Zod v3 by checking:\n * - Has ~standard.vendor === 'zod' (both v3 and v4 have this)\n * - Does NOT have ~standard.jsonSchema (only Zod v4 has native JSON Schema support)\n * - Does NOT have _zod property (only Zod v4 has this)\n *\n * Note: We can't use instanceof z3.ZodType because the old 'zod-v3' package\n * has a different prototype chain than 'zod/v3'.\n */\nfunction isZodV3(schema: unknown): schema is ZodType {\n if (schema === null || typeof schema !== 'object') {\n return false;\n }\n\n // Must not be Zod v4\n if (isZodV4(schema)) {\n return false;\n }\n\n // Check for ~standard with vendor 'zod' but no jsonSchema\n if ('~standard' in schema) {\n const std = (schema as any)['~standard'];\n if (typeof std === 'object' && std !== null && std.vendor === 'zod' && !('jsonSchema' in std)) {\n return true;\n }\n }\n\n // Fallback: check instanceof for zod/v3 compat export\n return schema instanceof z3.ZodType;\n}\n\nexport function toStandardSchema<T = unknown>(schema: PublicSchema<T>): StandardSchemaWithJSON<T> {\n // Work around a Zod v4 (< 4.4.0) bug where single-arg `z.record(valueSchema)`\n // puts the value in `def.keyType` and leaves `def.valueType` undefined, which\n // crashes `toJSONSchema`'s recordProcessor. This must run BEFORE the\n // StandardSchemaWithJSON short-circuit below: Zod >= 4.2 natively exposes\n // `~standard.jsonSchema`, so those schemas are returned as-is and never go\n // through our Zod v4 adapter. Patching mutates the defs in place, so Zod's\n // native converter picks up the fix too. Idempotent — safe to call repeatedly.\n if (isZodV4(schema)) {\n patchRecordSchemas(schema);\n }\n\n // First check: if already StandardSchemaWithJSON, return as-is\n // This handles ArkType, Zod v4 (when it has jsonSchema), and pre-wrapped schemas\n if (isStandardSchemaWithJSON(schema)) {\n return schema;\n }\n\n // Check for Zod v4 schemas without ~standard.jsonSchema\n // This handles both real Zod v4 and Zod 3.25's v4 compat layer where\n // ~standard.jsonSchema is not present on the schema object\n if (isZodV4(schema)) {\n return toStandardSchemaZodV4(schema as any, {\n unrepresentable: JSON_SCHEMA_LIBRARY_OPTIONS.unrepresentable,\n override: JSON_SCHEMA_LIBRARY_OPTIONS.override,\n });\n }\n\n // Check for Zod v3 schemas (need wrapping to add JSON Schema support)\n // Important: Must use isZodV3() not instanceof z3.ZodType because\n // Zod v4 schemas are also instanceof z3.ZodType due to prototype compatibility\n if (isZodV3(schema)) {\n return toStandardSchemaZodV3(schema as ZodType);\n }\n\n // Check for AI SDK Schema objects (Vercel's jsonSchema wrapper)\n if (isVercelSchema(schema)) {\n return toStandardSchemaAiSdk(schema);\n }\n\n // At this point, assume it's a plain JSON Schema object\n // JSON Schema objects are plain objects with properties like 'type', 'properties', etc.\n if (schema === null || (typeof schema !== 'object' && typeof schema !== 'function')) {\n throw new Error(`Unsupported schema type: ${typeof schema}`);\n }\n\n // If it's a function that's not StandardSchemaWithJSON, it's not supported\n if (typeof schema === 'function') {\n throw new Error(`Unsupported schema type: function (schema libraries should implement StandardSchemaWithJSON)`);\n }\n\n return toStandardSchemaJsonSchema(schema as JSONSchema7);\n}\n\n/**\n * Type guard to check if a value implements the StandardSchemaV1 interface.\n *\n * @param value - The value to check\n * @returns True if the value implements StandardSchemaV1\n *\n * @example\n * ```typescript\n * import { isStandardSchema } from '@mastra/schema-compat';\n *\n * if (isStandardSchema(someValue)) {\n * const result = someValue['~standard'].validate(input);\n * }\n * ```\n */\nexport function isStandardSchema(value: unknown): value is StandardSchemaV1 {\n // Check for object or function (some libraries like ArkType use callable schemas)\n if (value === null || (typeof value !== 'object' && typeof value !== 'function')) {\n return false;\n }\n if (!('~standard' in value)) {\n return false;\n }\n const std = (value as any)['~standard'];\n return (\n typeof std === 'object' &&\n std !== null &&\n 'version' in std &&\n std.version === 1 &&\n 'vendor' in std &&\n 'validate' in std &&\n typeof std.validate === 'function'\n );\n}\n\n/**\n * Type guard to check if a value implements the StandardJSONSchemaV1 interface.\n *\n * @param value - The value to check\n * @returns True if the value implements StandardJSONSchemaV1\n *\n * @example\n * ```typescript\n * import { isStandardJSONSchema } from '@mastra/schema-compat';\n *\n * if (isStandardJSONSchema(someValue)) {\n * const jsonSchema = someValue['~standard'].jsonSchema.output({ target: 'draft-07' });\n * }\n * ```\n */\nexport function isStandardJSONSchema(value: unknown): value is StandardJSONSchemaV1 {\n // Check for object or function (some libraries like ArkType use callable schemas)\n if (value === null || (typeof value !== 'object' && typeof value !== 'function')) {\n return false;\n }\n if (!('~standard' in value)) {\n return false;\n }\n const std = (value as any)['~standard'];\n if (typeof std !== 'object' || std === null) {\n return false;\n }\n if (!('version' in std) || std.version !== 1 || !('vendor' in std)) {\n return false;\n }\n if (!('jsonSchema' in std) || typeof std.jsonSchema !== 'object') {\n return false;\n }\n return typeof std.jsonSchema.input === 'function' && typeof std.jsonSchema.output === 'function';\n}\n\n/**\n * Type guard to check if a value implements both StandardSchemaV1 and StandardJSONSchemaV1.\n *\n * @param value - The value to check\n * @returns True if the value implements both interfaces\n *\n * @example\n * ```typescript\n * import { isStandardSchemaWithJSON } from '@mastra/schema-compat';\n *\n * if (isStandardSchemaWithJSON(someValue)) {\n * // Can use both validation and JSON Schema conversion\n * const result = someValue['~standard'].validate(input);\n * const jsonSchema = someValue['~standard'].jsonSchema.output({ target: 'draft-07' });\n * }\n * ```\n */\nexport function isStandardSchemaWithJSON(value: unknown): value is StandardSchemaWithJSON {\n return isStandardSchema(value) && isStandardJSONSchema(value);\n}\n\n/**\n * Converts a StandardSchemaWithJSON to a JSON Schema.\n *\n * @param schema - The StandardSchemaWithJSON schema to convert\n * @param options - Conversion options\n * @param options.target - The JSON Schema target version (default: 'draft-07')\n * @param options.io - Whether to use input or output schema (default: 'output')\n * - 'input': Use for tool parameters, function arguments, request bodies\n * - 'output': Use for return types, response bodies\n * @returns The JSON Schema representation\n *\n * @example\n * ```typescript\n * import { standardSchemaToJSONSchema, toStandardSchema } from '@mastra/schema-compat';\n * import { z } from 'zod';\n *\n * const zodSchema = z.object({ name: z.string() });\n * const standardSchema = toStandardSchema(zodSchema);\n *\n * // For output types (default)\n * const outputSchema = standardSchemaToJSONSchema(standardSchema);\n *\n * // For input types (tool parameters)\n * const inputSchema = standardSchemaToJSONSchema(standardSchema, { io: 'input' });\n * ```\n */\nexport function standardSchemaToJSONSchema(\n schema: StandardSchemaWithJSON,\n options: {\n target?: StandardJSONSchemaV1.Target;\n io?: 'input' | 'output';\n override?: (typeof JSON_SCHEMA_LIBRARY_OPTIONS)['override'];\n } = {},\n): JSONSchema7 {\n const { target = 'draft-07', io = 'output', override = JSON_SCHEMA_LIBRARY_OPTIONS.override } = options;\n const jsonSchemaFn = schema['~standard'].jsonSchema[io];\n let jsonSchema = jsonSchemaFn({\n target,\n libraryOptions: {\n ...JSON_SCHEMA_LIBRARY_OPTIONS,\n override,\n },\n }) as JSONSchema7;\n\n // make sure only jsonSchema is left, no standard schema metadata\n jsonSchema = JSON.parse(JSON.stringify(jsonSchema));\n\n return jsonSchema;\n}\n"],"mappings":";;;;;;;;;;;;;AASA,MAAM,oCAAoB,IAAI,IAAI;CAAC;CAAY;CAAY;AAAe,CAAC;;;;;;AAO3E,MAAM,oBAA4C;CAChD,YAAY;CACZ,YAAY;AACd;;;;;;;;AAiBA,SAAS,oBACP,WACA,SACA,gBACyB;CAMzB,oBAAA,mBAAmB,SAAS;CAE5B,MAAM,SAAS,kBAAkB,IAAI,QAAQ,MAAM,IAAI,QAAQ,SAAS;CAExE,MAAM,oBAA6C,EACjD,QAAQ,kBAAkB,WAAW,OACvC;CAEA,IAAI,eAAe,iBACjB,kBAAkB,kBAAkB,eAAe;CAIrD,IAAI,eAAe,UACjB,kBAAkB,WAAW,eAAe;CAG9C,QAAA,GAAA,OAAA,aAAA,CAAoB,WAAiD,iBAAiB;AACxF;;;;;;;;;;;;;AAcA,SAAgBA,mBACd,WACA,iBAAsC,CAAC,GACX;CAE5B,MAAM,UAAU,OAAO,OAAO,SAAS;CAGvC,MAAM,mBAAoB,UAAkB;CAG5C,MAAM,sBAAsD;EAC1D,QAAQ,YAAmE;GACzE,OAAO,oBAAoB,WA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gBAAgB,QAAQ,OAAO,IAAI,eAAe,UACtD,OAAO;CAET,OAAO,OAAO,IAAI,WAAW,UAAU,cAAc,OAAO,IAAI,WAAW,WAAW;AACxF;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,yBAAyB,OAAiD;CACxF,OAAO,iBAAiB,KAAK,KAAK,qBAAqB,KAAK;AAC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,2BACd,QACA,UAII,CAAC,GACQ;CACb,MAAM,EAAE,SAAS,YAAY,KAAK,UAAU,WAAW,4BAA4B,aAAa;CAChG,MAAM,eAAe,OAAO,YAAY,CAAC,WAAW;CACpD,IAAI,aAAa,aAAa;EAC5B;EACA,gBAAgB;GACd,GAAG;GACH;EACF;CACF,CAAC;CAGD,aAAa,KAAK,MAAM,KAAK,UAAU,UAAU,CAAC;CAElD,OAAO;AACT"}
|
package/dist/schema.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_schema = require("./schema-
|
|
2
|
+
const require_schema = require("./schema-5p36X0wR.cjs");
|
|
3
3
|
exports.JSON_SCHEMA_LIBRARY_OPTIONS = require_schema.JSON_SCHEMA_LIBRARY_OPTIONS;
|
|
4
4
|
exports.isStandardJSONSchema = require_schema.isStandardJSONSchema;
|
|
5
5
|
exports.isStandardSchema = require_schema.isStandardSchema;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_json_schema = require("../../json-schema-
|
|
2
|
+
const require_json_schema = require("../../json-schema-C7Uhaeop.cjs");
|
|
3
3
|
exports.JsonSchemaWrapper = require_json_schema.JsonSchemaWrapper;
|
|
4
4
|
exports.toStandardSchema = require_json_schema.toStandardSchema;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_esm = require("../../esm-
|
|
4
|
-
const require_json_schema_traverse$1 = require("../../json-schema-traverse-CSNSaf0y.cjs");
|
|
2
|
+
const require_json_schema_traverse$1 = require("../../json-schema-traverse-DbuWNYgg.cjs");
|
|
3
|
+
const require_esm = require("../../esm-CkNCkZSB.cjs");
|
|
5
4
|
//#region src/standard-schema/adapters/zod-v3.ts
|
|
6
|
-
var import_json_schema_traverse = /* @__PURE__ */
|
|
5
|
+
var import_json_schema_traverse = /* @__PURE__ */ require_json_schema_traverse$1.__toESM(require_json_schema_traverse$1.require_json_schema_traverse(), 1);
|
|
7
6
|
/**
|
|
8
7
|
* Target mapping from Standard Schema targets to zod-to-json-schema targets.
|
|
9
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-v3.cjs","names":["zodToJsonSchemaOriginal","ignoreOverride"],"sources":["../../../src/standard-schema/adapters/zod-v3.ts"],"sourcesContent":["import type { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';\nimport traverse from 'json-schema-traverse';\n// Use zod/v3 types for v3 compatibility (v4's v3-compat layer)\nimport type { ZodType, ZodTypeDef } from 'zod/v3';\nimport zodToJsonSchemaOriginal, { ignoreOverride } from 'zod-to-json-schema';\nimport type {\n StandardSchemaWithJSON,\n StandardSchemaWithJSONProps,\n ZodToJsonSchemaTarget,\n} from '../standard-schema.types';\n/**\n * Target mapping from Standard Schema targets to zod-to-json-schema targets.\n */\nconst TARGET_MAP: Record<string, ZodToJsonSchemaTarget> = {\n 'draft-04': 'jsonSchema7',\n 'draft-07': 'jsonSchema7',\n 'draft-2020-12': 'jsonSchema2019-09',\n 'openapi-3.0': 'openApi3',\n};\n\n/**\n * Converts a Zod schema to JSON Schema using the specified target format.\n *\n * @param zodSchema - The Zod schema to convert\n * @param options - Standard Schema JSON options including the target format\n * @returns The JSON Schema representation\n * @throws Error if the target format is not supported\n *\n * @internal\n */\nfunction convertToJsonSchema<T extends ZodType<any, ZodTypeDef, any>>(\n zodSchema: T,\n options: StandardJSONSchemaV1.Options,\n): Record<string, unknown> {\n const target = TARGET_MAP[options.target];\n\n if (!target) {\n // For unknown targets, try to use jsonSchema7 as fallback or throw\n const supportedTargets = Object.keys(TARGET_MAP);\n throw new Error(\n `Unsupported JSON Schema target: \"${options.target}\". ` + `Supported targets are: ${supportedTargets.join(', ')}`,\n );\n }\n\n const jsonSchema = zodToJsonSchemaOriginal(zodSchema, {\n $refStrategy: 'none',\n target,\n override: (def: any) => {\n // Mark z.date() with x-date for downstream string→Date conversion.\n // Zod v3 has no z.coerce.date(), so all dates are strict.\n if (def.typeName === 'ZodDate') {\n return { type: 'string', format: 'date-time', 'x-date': true };\n }\n return ignoreOverride;\n },\n });\n\n traverse(jsonSchema, {\n cb: {\n pre: schema => {\n if (schema.type === 'string' && schema.format === 'email') {\n schema.pattern = `^(?!\\\\.)(?!.*\\\\.\\\\.)([A-Za-z0-9_'+\\\\-\\\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\\\-]*\\\\.)+[A-Za-z]{2,}$`;\n }\n },\n // post: (schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema) => {\n // this.postProcessJSONNode(schema, parentSchema);\n // },\n },\n });\n\n return jsonSchema as Record<string, unknown>;\n}\n\n/**\n * Wraps a Zod v3 schema to implement the full @standard-schema/spec interface.\n *\n * While Zod v3 natively implements `StandardSchemaV1` (validation), it does not\n * implement `StandardJSONSchemaV1` (JSON Schema conversion). This adapter adds\n * the `jsonSchema` property to provide JSON Schema conversion capabilities.\n *\n * @typeParam T - The Zod schema type\n *\n * @example\n * ```typescript\n * import { z } from 'zod';\n * import { toStandardSchema } from '@mastra/schema-compat/adapters/zod-v3';\n *\n * const userSchema = z.object({\n * name: z.string(),\n * age: z.number().min(0),\n * });\n *\n * const standardSchema = toStandardSchema(userSchema);\n *\n * // Use validation (from StandardSchemaV1)\n * const result = standardSchema['~standard'].validate({ name: 'John', age: 30 });\n *\n * // Get JSON Schema (from StandardJSONSchemaV1)\n * const jsonSchema = standardSchema['~standard'].jsonSchema.output({ target: 'draft-07' });\n * ```\n */\nexport function toStandardSchema<T>(zodSchema: ZodType<T, ZodTypeDef, T>): T & StandardSchemaWithJSON<T, T> {\n // Create a wrapper object that includes the jsonSchema converter\n const wrapper = Object.create(zodSchema) as T & StandardSchemaWithJSON<T, T>;\n\n // Get the existing ~standard property from Zod\n const existingStandard = zodSchema['~standard'] as StandardSchemaV1.Props<T, T>;\n\n // Create the JSON Schema converter\n const jsonSchemaConverter: StandardJSONSchemaV1.Converter = {\n input: (options: StandardJSONSchemaV1.Options): Record<string, unknown> => {\n return convertToJsonSchema(zodSchema, options);\n },\n output: (options: StandardJSONSchemaV1.Options): Record<string, unknown> => {\n // For Zod schemas, input and output JSON Schema are typically the same\n // unless using transforms, which would need special handling\n return convertToJsonSchema(zodSchema, options);\n },\n };\n\n // Define the enhanced ~standard property\n Object.defineProperty(wrapper, '~standard', {\n value: {\n ...existingStandard,\n jsonSchema: jsonSchemaConverter,\n } satisfies StandardSchemaWithJSONProps<T, T>,\n writable: false,\n enumerable: true,\n configurable: false,\n });\n\n return wrapper;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"zod-v3.cjs","names":["zodToJsonSchemaOriginal","ignoreOverride"],"sources":["../../../src/standard-schema/adapters/zod-v3.ts"],"sourcesContent":["import type { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';\nimport traverse from 'json-schema-traverse';\n// Use zod/v3 types for v3 compatibility (v4's v3-compat layer)\nimport type { ZodType, ZodTypeDef } from 'zod/v3';\nimport zodToJsonSchemaOriginal, { ignoreOverride } from 'zod-to-json-schema';\nimport type {\n StandardSchemaWithJSON,\n StandardSchemaWithJSONProps,\n ZodToJsonSchemaTarget,\n} from '../standard-schema.types';\n/**\n * Target mapping from Standard Schema targets to zod-to-json-schema targets.\n */\nconst TARGET_MAP: Record<string, ZodToJsonSchemaTarget> = {\n 'draft-04': 'jsonSchema7',\n 'draft-07': 'jsonSchema7',\n 'draft-2020-12': 'jsonSchema2019-09',\n 'openapi-3.0': 'openApi3',\n};\n\n/**\n * Converts a Zod schema to JSON Schema using the specified target format.\n *\n * @param zodSchema - The Zod schema to convert\n * @param options - Standard Schema JSON options including the target format\n * @returns The JSON Schema representation\n * @throws Error if the target format is not supported\n *\n * @internal\n */\nfunction convertToJsonSchema<T extends ZodType<any, ZodTypeDef, any>>(\n zodSchema: T,\n options: StandardJSONSchemaV1.Options,\n): Record<string, unknown> {\n const target = TARGET_MAP[options.target];\n\n if (!target) {\n // For unknown targets, try to use jsonSchema7 as fallback or throw\n const supportedTargets = Object.keys(TARGET_MAP);\n throw new Error(\n `Unsupported JSON Schema target: \"${options.target}\". ` + `Supported targets are: ${supportedTargets.join(', ')}`,\n );\n }\n\n const jsonSchema = zodToJsonSchemaOriginal(zodSchema, {\n $refStrategy: 'none',\n target,\n override: (def: any) => {\n // Mark z.date() with x-date for downstream string→Date conversion.\n // Zod v3 has no z.coerce.date(), so all dates are strict.\n if (def.typeName === 'ZodDate') {\n return { type: 'string', format: 'date-time', 'x-date': true };\n }\n return ignoreOverride;\n },\n });\n\n traverse(jsonSchema, {\n cb: {\n pre: schema => {\n if (schema.type === 'string' && schema.format === 'email') {\n schema.pattern = `^(?!\\\\.)(?!.*\\\\.\\\\.)([A-Za-z0-9_'+\\\\-\\\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\\\-]*\\\\.)+[A-Za-z]{2,}$`;\n }\n },\n // post: (schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema) => {\n // this.postProcessJSONNode(schema, parentSchema);\n // },\n },\n });\n\n return jsonSchema as Record<string, unknown>;\n}\n\n/**\n * Wraps a Zod v3 schema to implement the full @standard-schema/spec interface.\n *\n * While Zod v3 natively implements `StandardSchemaV1` (validation), it does not\n * implement `StandardJSONSchemaV1` (JSON Schema conversion). This adapter adds\n * the `jsonSchema` property to provide JSON Schema conversion capabilities.\n *\n * @typeParam T - The Zod schema type\n *\n * @example\n * ```typescript\n * import { z } from 'zod';\n * import { toStandardSchema } from '@mastra/schema-compat/adapters/zod-v3';\n *\n * const userSchema = z.object({\n * name: z.string(),\n * age: z.number().min(0),\n * });\n *\n * const standardSchema = toStandardSchema(userSchema);\n *\n * // Use validation (from StandardSchemaV1)\n * const result = standardSchema['~standard'].validate({ name: 'John', age: 30 });\n *\n * // Get JSON Schema (from StandardJSONSchemaV1)\n * const jsonSchema = standardSchema['~standard'].jsonSchema.output({ target: 'draft-07' });\n * ```\n */\nexport function toStandardSchema<T>(zodSchema: ZodType<T, ZodTypeDef, T>): T & StandardSchemaWithJSON<T, T> {\n // Create a wrapper object that includes the jsonSchema converter\n const wrapper = Object.create(zodSchema) as T & StandardSchemaWithJSON<T, T>;\n\n // Get the existing ~standard property from Zod\n const existingStandard = zodSchema['~standard'] as StandardSchemaV1.Props<T, T>;\n\n // Create the JSON Schema converter\n const jsonSchemaConverter: StandardJSONSchemaV1.Converter = {\n input: (options: StandardJSONSchemaV1.Options): Record<string, unknown> => {\n return convertToJsonSchema(zodSchema, options);\n },\n output: (options: StandardJSONSchemaV1.Options): Record<string, unknown> => {\n // For Zod schemas, input and output JSON Schema are typically the same\n // unless using transforms, which would need special handling\n return convertToJsonSchema(zodSchema, options);\n },\n };\n\n // Define the enhanced ~standard property\n Object.defineProperty(wrapper, '~standard', {\n value: {\n ...existingStandard,\n jsonSchema: jsonSchemaConverter,\n } satisfies StandardSchemaWithJSONProps<T, T>,\n writable: false,\n enumerable: true,\n configurable: false,\n });\n\n return wrapper;\n}\n"],"mappings":";;;;;;;;AAaA,MAAM,aAAoD;CACxD,YAAY;CACZ,YAAY;CACZ,iBAAiB;CACjB,eAAe;AACjB;;;;;;;;;;;AAYA,SAAS,oBACP,WACA,SACyB;CACzB,MAAM,SAAS,WAAW,QAAQ;CAElC,IAAI,CAAC,QAAQ;EAEX,MAAM,mBAAmB,OAAO,KAAK,UAAU;EAC/C,MAAM,IAAI,MACR,oCAAoC,QAAQ,OAAO,4BAAiC,iBAAiB,KAAK,IAAI,GAChH;CACF;CAEA,MAAM,aAAaA,YAAAA,YAAwB,WAAW;EACpD,cAAc;EACd;EACA,WAAW,QAAa;GAGtB,IAAI,IAAI,aAAa,WACnB,OAAO;IAAE,MAAM;IAAU,QAAQ;IAAa,UAAU;GAAK;GAE/D,OAAOC,YAAAA;EACT;CACF,CAAC;CAED,CAAA,GAAA,4BAAA,QAAA,CAAS,YAAY,EACnB,IAAI,EACF,MAAK,WAAU;EACb,IAAI,OAAO,SAAS,YAAY,OAAO,WAAW,SAChD,OAAO,UAAU;CAErB,EAIF,EACF,CAAC;CAED,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,iBAAoB,WAAwE;CAE1G,MAAM,UAAU,OAAO,OAAO,SAAS;CAGvC,MAAM,mBAAmB,UAAU;CAGnC,MAAM,sBAAsD;EAC1D,QAAQ,YAAmE;GACzE,OAAO,oBAAoB,WAAW,OAAO;EAC/C;EACA,SAAS,YAAmE;GAG1E,OAAO,oBAAoB,WAAW,OAAO;EAC/C;CACF;CAGA,OAAO,eAAe,SAAS,aAAa;EAC1C,OAAO;GACL,GAAG;GACH,YAAY;EACd;EACA,UAAU;EACV,YAAY;EACZ,cAAc;CAChB,CAAC;CAED,OAAO;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as __toESM, t as require_json_schema_traverse } from "../../json-schema-traverse-B35mHRM8.js";
|
|
2
|
-
import { n as ignoreOverride, t as esm_default } from "../../esm-
|
|
2
|
+
import { n as ignoreOverride, t as esm_default } from "../../esm-CWlHuVIx.js";
|
|
3
3
|
//#region src/standard-schema/adapters/zod-v3.ts
|
|
4
4
|
var import_json_schema_traverse = /* @__PURE__ */ __toESM(require_json_schema_traverse(), 1);
|
|
5
5
|
/**
|
package/dist/zod-to-json.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_esm = require("./esm-
|
|
2
|
+
const require_esm = require("./esm-CkNCkZSB.cjs");
|
|
3
3
|
let zod_v4 = require("zod/v4");
|
|
4
4
|
//#region src/zod-to-json.ts
|
|
5
5
|
const PATCHED = Symbol("__mastra_patched__");
|
package/dist/zod-to-json.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/schema-compat",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.11-alpha.0",
|
|
4
4
|
"description": "Tool schema compatibility layer for Mastra.ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -104,26 +104,26 @@
|
|
|
104
104
|
"@standard-schema/spec": "^1.1.0",
|
|
105
105
|
"@types/json-schema": "^7.0.15",
|
|
106
106
|
"@types/node": "22.20.1",
|
|
107
|
-
"@vitest/coverage-v8": "4.1.
|
|
108
|
-
"@vitest/ui": "4.1.
|
|
107
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
108
|
+
"@vitest/ui": "4.1.11",
|
|
109
109
|
"ajv": "^8.20.0",
|
|
110
110
|
"arktype": "^2.2.0",
|
|
111
111
|
"eslint": "^10.7.0",
|
|
112
112
|
"json-schema-traverse": "^1.0.0",
|
|
113
113
|
"tsdown": "0.22.9",
|
|
114
114
|
"typescript": "^7.0.2",
|
|
115
|
-
"vitest": "4.1.
|
|
116
|
-
"zod": "^4.4
|
|
115
|
+
"vitest": "4.1.11",
|
|
116
|
+
"zod": "^4.6.4",
|
|
117
117
|
"zod-v3": "npm:zod@^3.25.76",
|
|
118
118
|
"zod-to-json-schema": "^3.25.2",
|
|
119
119
|
"zod-from-json-schema-v3": "npm:zod-from-json-schema@^0.0.5",
|
|
120
|
-
"@internal/ai-sdk-v5": "0.0.80",
|
|
121
|
-
"@internal/ai-v6": "0.0.80",
|
|
122
120
|
"@internal/ai-sdk-v4": "0.0.80",
|
|
123
|
-
"@internal/
|
|
121
|
+
"@internal/ai-sdk-v5": "0.0.80",
|
|
124
122
|
"@internal/llm-recorder": "0.0.69",
|
|
123
|
+
"@internal/types-builder": "0.0.108",
|
|
125
124
|
"@internal/test-utils": "0.0.69",
|
|
126
|
-
"@internal/
|
|
125
|
+
"@internal/lint": "0.0.133",
|
|
126
|
+
"@internal/ai-v6": "0.0.80"
|
|
127
127
|
},
|
|
128
128
|
"homepage": "https://mastra.ai",
|
|
129
129
|
"repository": {
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
-
get: ((k) => from[k]).bind(null, key),
|
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
-
value: mod,
|
|
21
|
-
enumerable: true
|
|
22
|
-
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
|
-
Object.defineProperty(exports, "__commonJSMin", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function() {
|
|
27
|
-
return __commonJSMin;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "__toESM", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function() {
|
|
33
|
-
return __toESM;
|
|
34
|
-
}
|
|
35
|
-
});
|