@mastra/schema-compat 1.3.16 → 1.3.17-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/_types/@internal_ai-sdk-v5/dist/index.d.ts +65 -13
- package/dist/_types/@internal_ai-v6/dist/index.d.ts +110 -35
- package/dist/{esm-DA8owk0L.js → esm-BG70JlG8.js} +39 -77
- package/dist/{esm-DA8owk0L.js.map → esm-BG70JlG8.js.map} +1 -1
- package/dist/{esm-zrVJTTxY.cjs → esm-BQeGF7AD.cjs} +39 -77
- package/dist/{esm-zrVJTTxY.cjs.map → esm-BQeGF7AD.cjs.map} +1 -1
- package/dist/index.cjs +18 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -34
- package/dist/index.js.map +1 -1
- package/dist/{json-schema-Dh7B27IP.cjs → json-schema-7oyknwMS.cjs} +189 -204
- package/dist/json-schema-7oyknwMS.cjs.map +1 -0
- package/dist/{json-schema-DcMkkbbI.js → json-schema-BdCwqjfN.js} +189 -204
- package/dist/json-schema-BdCwqjfN.js.map +1 -0
- package/dist/{json-schema-traverse-Jrimn_T_.js → json-schema-traverse-D0CId4oM.js} +3 -5
- package/dist/{json-schema-traverse-Jrimn_T_.js.map → json-schema-traverse-D0CId4oM.js.map} +1 -1
- package/dist/{json-schema-traverse-CKLDTw5l.cjs → json-schema-traverse-evfp8uQX.cjs} +3 -5
- package/dist/{json-schema-traverse-CKLDTw5l.cjs.map → json-schema-traverse-evfp8uQX.cjs.map} +1 -1
- package/dist/json-to-zod.cjs +70 -71
- 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 +70 -71
- package/dist/json-to-zod.js.map +1 -1
- package/dist/{schema-CzbEIyhE.js → schema-Bf12g7KC.js} +4 -6
- package/dist/{schema-CzbEIyhE.js.map → schema-Bf12g7KC.js.map} +1 -1
- package/dist/{schema-BXSe2bgB.cjs → schema-D2ab1-Dc.cjs} +5 -7
- package/dist/{schema-BXSe2bgB.cjs.map → schema-D2ab1-Dc.cjs.map} +1 -1
- package/dist/schema.cjs +1 -1
- package/dist/schema.js +1 -1
- package/dist/standard-schema/adapters/ai-sdk.cjs +1 -2
- package/dist/standard-schema/adapters/ai-sdk.js +1 -2
- package/dist/standard-schema/adapters/json-schema.cjs +1 -1
- package/dist/standard-schema/adapters/json-schema.js +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 +3 -4
- package/dist/standard-schema/adapters/zod-v3.js.map +1 -1
- package/dist/zod-to-json.cjs +2 -3
- package/dist/zod-to-json.js +2 -3
- package/package.json +18 -18
- package/dist/json-schema-DcMkkbbI.js.map +0 -1
- package/dist/json-schema-Dh7B27IP.cjs.map +0 -1
package/dist/json-to-zod.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseAnyOf.js
|
|
2
2
|
const parseAnyOf = (schema, refs) => {
|
|
3
3
|
return schema.anyOf.length ? schema.anyOf.length === 1 ? parseSchema(schema.anyOf[0], {
|
|
4
4
|
...refs,
|
|
@@ -16,18 +16,15 @@ const parseAnyOf = (schema, refs) => {
|
|
|
16
16
|
]
|
|
17
17
|
})).join(", ")}])` : `z.any()`;
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
//#region ../../../../../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
|
|
19
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseBoolean.js
|
|
21
20
|
const parseBoolean = (_schema) => {
|
|
22
21
|
return "z.boolean()";
|
|
23
22
|
};
|
|
24
|
-
|
|
25
|
-
//#region ../../../../../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
|
|
23
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseDefault.js
|
|
26
24
|
const parseDefault = (_schema) => {
|
|
27
25
|
return "z.any()";
|
|
28
26
|
};
|
|
29
|
-
|
|
30
|
-
//#region ../../../../../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
|
|
27
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseMultipleType.js
|
|
31
28
|
const parseMultipleType = (schema, refs) => {
|
|
32
29
|
return `z.union([${schema.type.map((type) => parseSchema({
|
|
33
30
|
...schema,
|
|
@@ -37,26 +34,22 @@ const parseMultipleType = (schema, refs) => {
|
|
|
37
34
|
withoutDefaults: true
|
|
38
35
|
})).join(", ")}])`;
|
|
39
36
|
};
|
|
40
|
-
|
|
41
|
-
//#region ../../../../../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
|
|
37
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseNot.js
|
|
42
38
|
const parseNot = (schema, refs) => {
|
|
43
39
|
return `z.any().refine((value) => !${parseSchema(schema.not, {
|
|
44
40
|
...refs,
|
|
45
41
|
path: [...refs.path, "not"]
|
|
46
42
|
})}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`;
|
|
47
43
|
};
|
|
48
|
-
|
|
49
|
-
//#region ../../../../../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
|
|
44
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseNull.js
|
|
50
45
|
const parseNull = (_schema) => {
|
|
51
46
|
return "z.null()";
|
|
52
47
|
};
|
|
53
|
-
|
|
54
|
-
//#region ../../../../../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
|
|
48
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/utils/half.js
|
|
55
49
|
const half = (arr) => {
|
|
56
50
|
return [arr.slice(0, arr.length / 2), arr.slice(arr.length / 2)];
|
|
57
51
|
};
|
|
58
|
-
|
|
59
|
-
//#region ../../../../../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
|
|
52
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseAllOf.js
|
|
60
53
|
const originalIndex = Symbol("Original index");
|
|
61
54
|
const ensureOriginalIndex = (arr) => {
|
|
62
55
|
let newArr = [];
|
|
@@ -91,9 +84,8 @@ function parseAllOf(schema, refs) {
|
|
|
91
84
|
return `z.intersection(${parseAllOf({ allOf: left }, refs)}, ${parseAllOf({ allOf: right }, refs)})`;
|
|
92
85
|
}
|
|
93
86
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
function withMessage(schema, key, get) {
|
|
87
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/utils/withMessage.js
|
|
88
|
+
function withMessage(schema, key, get, fallbackMessage) {
|
|
97
89
|
const value = schema[key];
|
|
98
90
|
let r = "";
|
|
99
91
|
if (value !== void 0) {
|
|
@@ -106,14 +98,14 @@ function withMessage(schema, key, get) {
|
|
|
106
98
|
const prefix = got.length === 3 ? got[1] : "";
|
|
107
99
|
const closer = got.length === 3 ? got[2] : got[1];
|
|
108
100
|
r += opener;
|
|
109
|
-
|
|
101
|
+
const message = schema.errorMessage?.[key] ?? fallbackMessage;
|
|
102
|
+
if (message !== void 0) r += prefix + JSON.stringify(message);
|
|
110
103
|
r += closer;
|
|
111
104
|
}
|
|
112
105
|
}
|
|
113
106
|
return r;
|
|
114
107
|
}
|
|
115
|
-
|
|
116
|
-
//#region ../../../../../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
|
|
108
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseArray.js
|
|
117
109
|
const parseArray = (schema, refs) => {
|
|
118
110
|
if (Array.isArray(schema.items)) return `z.tuple([${schema.items.map((v, i) => parseSchema(v, {
|
|
119
111
|
...refs,
|
|
@@ -138,27 +130,24 @@ const parseArray = (schema, refs) => {
|
|
|
138
130
|
")"
|
|
139
131
|
]);
|
|
140
132
|
if (schema.uniqueItems === true) r += withMessage(schema, "uniqueItems", () => [
|
|
141
|
-
".
|
|
142
|
-
"",
|
|
133
|
+
".refine((arr) => arr.every((item, i) => arr.indexOf(item) == i)",
|
|
134
|
+
", ",
|
|
143
135
|
")"
|
|
144
|
-
]);
|
|
136
|
+
], "All items must be unique!");
|
|
145
137
|
return r;
|
|
146
138
|
};
|
|
147
|
-
|
|
148
|
-
//#region ../../../../../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
|
|
139
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseConst.js
|
|
149
140
|
const parseConst = (schema) => {
|
|
150
141
|
return `z.literal(${JSON.stringify(schema.const)})`;
|
|
151
142
|
};
|
|
152
|
-
|
|
153
|
-
//#region ../../../../../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
|
|
143
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseEnum.js
|
|
154
144
|
const parseEnum = (schema) => {
|
|
155
145
|
if (schema.enum.length === 0) return "z.never()";
|
|
156
146
|
else if (schema.enum.length === 1) return `z.literal(${JSON.stringify(schema.enum[0])})`;
|
|
157
147
|
else if (schema.enum.every((x) => typeof x === "string")) return `z.enum([${schema.enum.map((x) => JSON.stringify(x))}])`;
|
|
158
148
|
else return `z.union([${schema.enum.map((x) => `z.literal(${JSON.stringify(x)})`).join(", ")}])`;
|
|
159
149
|
};
|
|
160
|
-
|
|
161
|
-
//#region ../../../../../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
|
|
150
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseIfThenElse.js
|
|
162
151
|
const parseIfThenElse = (schema, refs) => {
|
|
163
152
|
const $if = parseSchema(schema.if, {
|
|
164
153
|
...refs,
|
|
@@ -181,8 +170,7 @@ const parseIfThenElse = (schema, refs) => {
|
|
|
181
170
|
}
|
|
182
171
|
})`;
|
|
183
172
|
};
|
|
184
|
-
|
|
185
|
-
//#region ../../../../../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
|
|
173
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseNumber.js
|
|
186
174
|
const parseNumber = (schema) => {
|
|
187
175
|
let r = "z.number()";
|
|
188
176
|
if (schema.type === "integer") r += withMessage(schema, "type", () => [".int(", ")"]);
|
|
@@ -234,9 +222,9 @@ const parseNumber = (schema) => {
|
|
|
234
222
|
]);
|
|
235
223
|
return r;
|
|
236
224
|
};
|
|
237
|
-
|
|
238
|
-
//#region ../../../../../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
|
|
225
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseOneOf.js
|
|
239
226
|
const parseOneOf = (schema, refs) => {
|
|
227
|
+
let is3 = refs.zodVersion === 3;
|
|
240
228
|
return schema.oneOf.length ? schema.oneOf.length === 1 ? parseSchema(schema.oneOf[0], {
|
|
241
229
|
...refs,
|
|
242
230
|
path: [
|
|
@@ -253,26 +241,38 @@ const parseOneOf = (schema, refs) => {
|
|
|
253
241
|
i
|
|
254
242
|
]
|
|
255
243
|
})).join(", ")}];
|
|
256
|
-
const errors = schemas.reduce<
|
|
257
|
-
|
|
244
|
+
const { errors, failed } = schemas.reduce<{
|
|
245
|
+
errors: z.${is3 ? "ZodError" : "core.$ZodIssue"}[];
|
|
246
|
+
failed: number;
|
|
247
|
+
}>(
|
|
248
|
+
({ errors, failed }, schema) =>
|
|
258
249
|
((result) =>
|
|
259
|
-
result.error
|
|
250
|
+
result.error
|
|
251
|
+
? {
|
|
252
|
+
errors: [...errors, ${is3 ? "result.error" : "...result.error.issues"}],
|
|
253
|
+
failed: failed + 1,
|
|
254
|
+
}
|
|
255
|
+
: { errors, failed })(
|
|
260
256
|
schema.safeParse(x),
|
|
261
257
|
),
|
|
262
|
-
[],
|
|
258
|
+
{ errors: [], failed: 0 },
|
|
263
259
|
);
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
260
|
+
const passed = schemas.length - failed;
|
|
261
|
+
if (passed !== 1) {
|
|
262
|
+
ctx.addIssue(errors.length ? {
|
|
263
|
+
path: ${is3 ? "ctx.path" : "[]"},
|
|
267
264
|
code: "invalid_union",
|
|
268
|
-
unionErrors: errors,
|
|
269
|
-
message: "Invalid input: Should pass single schema",
|
|
265
|
+
${is3 ? "unionErrors: errors" : "errors: [errors]"},
|
|
266
|
+
message: "Invalid input: Should pass single schema. Passed " + passed,
|
|
267
|
+
} : {
|
|
268
|
+
path: ${is3 ? "ctx.path" : "[]"},
|
|
269
|
+
code: "custom",${is3 ? "" : "\n errors: [errors],"}
|
|
270
|
+
message: "Invalid input: Should pass single schema. Passed " + passed,
|
|
270
271
|
});
|
|
271
272
|
}
|
|
272
273
|
})` : "z.any()";
|
|
273
274
|
};
|
|
274
|
-
|
|
275
|
-
//#region ../../../../../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
|
|
275
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/utils/jsdocs.js
|
|
276
276
|
const expandJsdocs = (jsdocs) => {
|
|
277
277
|
const lines = jsdocs.split("\n");
|
|
278
278
|
return `/**${lines.length === 1 ? lines[0] : `\n${lines.map((x) => `* ${x}`).join("\n")}\n`}*/\n`;
|
|
@@ -282,8 +282,15 @@ const addJsdocs = (schema, parsed) => {
|
|
|
282
282
|
if (!description) return parsed;
|
|
283
283
|
return `\n${expandJsdocs(description)}${parsed}`;
|
|
284
284
|
};
|
|
285
|
-
|
|
286
|
-
|
|
285
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseObject.js
|
|
286
|
+
function emitRecord(valueSchema, refs) {
|
|
287
|
+
if (refs.zodVersion === 3) return `z.record(${valueSchema})`;
|
|
288
|
+
return `z.record(z.string(), ${valueSchema})`;
|
|
289
|
+
}
|
|
290
|
+
function emitErrorPath(refs) {
|
|
291
|
+
if (refs.zodVersion === 3) return `path: [...ctx.path, key]`;
|
|
292
|
+
return `path: [key]`;
|
|
293
|
+
}
|
|
287
294
|
function parseObject(objectSchema, refs) {
|
|
288
295
|
let properties = void 0;
|
|
289
296
|
if (objectSchema.properties) {
|
|
@@ -329,9 +336,9 @@ function parseObject(objectSchema, refs) {
|
|
|
329
336
|
if (additionalProperties) patternProperties += `.catchall(z.union([${[...Object.values(parsedPatternProperties), additionalProperties].join(", ")}]))`;
|
|
330
337
|
else if (Object.keys(parsedPatternProperties).length > 1) patternProperties += `.catchall(z.union([${Object.values(parsedPatternProperties).join(", ")}]))`;
|
|
331
338
|
else patternProperties += `.catchall(${Object.values(parsedPatternProperties)})`;
|
|
332
|
-
} else if (additionalProperties) patternProperties += `z.
|
|
333
|
-
else if (Object.keys(parsedPatternProperties).length > 1) patternProperties += `z.
|
|
334
|
-
else patternProperties +=
|
|
339
|
+
} else if (additionalProperties) patternProperties += emitRecord(`z.union([${[...Object.values(parsedPatternProperties), additionalProperties].join(", ")}])`, refs);
|
|
340
|
+
else if (Object.keys(parsedPatternProperties).length > 1) patternProperties += emitRecord(`z.union([${Object.values(parsedPatternProperties).join(", ")}])`, refs);
|
|
341
|
+
else patternProperties += emitRecord(`${Object.values(parsedPatternProperties)}`, refs);
|
|
335
342
|
patternProperties += ".superRefine((value, ctx) => {\n";
|
|
336
343
|
patternProperties += "for (const key in value) {\n";
|
|
337
344
|
if (additionalProperties) {
|
|
@@ -344,7 +351,7 @@ function parseObject(objectSchema, refs) {
|
|
|
344
351
|
patternProperties += "const result = " + parsedPatternProperties[key] + ".safeParse(value[key])\n";
|
|
345
352
|
patternProperties += "if (!result.success) {\n";
|
|
346
353
|
patternProperties += `ctx.addIssue({
|
|
347
|
-
|
|
354
|
+
${emitErrorPath(refs)},
|
|
348
355
|
code: 'custom',
|
|
349
356
|
message: \`Invalid input: Key matching regex /\${key}/ must match schema\`,
|
|
350
357
|
params: {
|
|
@@ -359,7 +366,7 @@ function parseObject(objectSchema, refs) {
|
|
|
359
366
|
patternProperties += "const result = " + additionalProperties + ".safeParse(value[key])\n";
|
|
360
367
|
patternProperties += "if (!result.success) {\n";
|
|
361
368
|
patternProperties += `ctx.addIssue({
|
|
362
|
-
|
|
369
|
+
${emitErrorPath(refs)},
|
|
363
370
|
code: 'custom',
|
|
364
371
|
message: \`Invalid input: must match catchall schema\`,
|
|
365
372
|
params: {
|
|
@@ -372,7 +379,7 @@ function parseObject(objectSchema, refs) {
|
|
|
372
379
|
patternProperties += "}\n";
|
|
373
380
|
patternProperties += "})";
|
|
374
381
|
}
|
|
375
|
-
let output = properties ? patternProperties ? properties + patternProperties : additionalProperties ? additionalProperties === "z.never()" ? properties + ".strict()" : properties + `.catchall(${additionalProperties})` : properties : patternProperties ? patternProperties : additionalProperties ?
|
|
382
|
+
let output = properties ? patternProperties ? properties + patternProperties : additionalProperties ? additionalProperties === "z.never()" ? properties + ".strict()" : properties + `.catchall(${additionalProperties})` : properties : patternProperties ? patternProperties : additionalProperties ? emitRecord(additionalProperties, refs) : emitRecord("z.any()", refs);
|
|
376
383
|
if (its.an.anyOf(objectSchema)) output += `.and(${parseAnyOf({
|
|
377
384
|
...objectSchema,
|
|
378
385
|
anyOf: objectSchema.anyOf.map((x) => typeof x === "object" && !x.type && (x.properties || x.additionalProperties || x.patternProperties) ? {
|
|
@@ -396,8 +403,7 @@ function parseObject(objectSchema, refs) {
|
|
|
396
403
|
}, refs)})`;
|
|
397
404
|
return output;
|
|
398
405
|
}
|
|
399
|
-
|
|
400
|
-
//#region ../../../../../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
|
|
406
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseString.js
|
|
401
407
|
const parseString = (schema) => {
|
|
402
408
|
let r = "z.string()";
|
|
403
409
|
r += withMessage(schema, "format", ({ value }) => {
|
|
@@ -464,8 +470,7 @@ const parseString = (schema) => {
|
|
|
464
470
|
}
|
|
465
471
|
return r;
|
|
466
472
|
};
|
|
467
|
-
|
|
468
|
-
//#region ../../../../../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
|
|
473
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseSimpleDiscriminatedOneOf.js
|
|
469
474
|
const parseSimpleDiscriminatedOneOf = (schema, refs) => {
|
|
470
475
|
return schema.oneOf.length ? schema.oneOf.length === 1 ? parseSchema(schema.oneOf[0], {
|
|
471
476
|
...refs,
|
|
@@ -483,22 +488,19 @@ const parseSimpleDiscriminatedOneOf = (schema, refs) => {
|
|
|
483
488
|
]
|
|
484
489
|
})).join(", ")}])` : "z.any()";
|
|
485
490
|
};
|
|
486
|
-
|
|
487
|
-
//#region ../../../../../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
|
|
491
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/utils/omit.js
|
|
488
492
|
const omit = (obj, ...keys) => Object.keys(obj).reduce((acc, key) => {
|
|
489
493
|
if (!keys.includes(key)) acc[key] = obj[key];
|
|
490
494
|
return acc;
|
|
491
495
|
}, {});
|
|
492
|
-
|
|
493
|
-
//#region ../../../../../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
|
|
496
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseNullable.js
|
|
494
497
|
/**
|
|
495
498
|
* For compatibility with open api 3.0 nullable
|
|
496
499
|
*/
|
|
497
500
|
const parseNullable = (schema, refs) => {
|
|
498
501
|
return `${parseSchema(omit(schema, "nullable"), refs, true)}.nullable()`;
|
|
499
502
|
};
|
|
500
|
-
|
|
501
|
-
//#region ../../../../../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
|
|
503
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/parsers/parseSchema.js
|
|
502
504
|
const parseSchema = (schema, refs = {
|
|
503
505
|
seen: /* @__PURE__ */ new Map(),
|
|
504
506
|
path: []
|
|
@@ -587,15 +589,15 @@ const its = {
|
|
|
587
589
|
oneOf: (x) => x.oneOf !== void 0
|
|
588
590
|
}
|
|
589
591
|
};
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
const jsonSchemaToZod$1 = (schema, { module, name, type, noImport, ...rest } = {}) => {
|
|
592
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/jsonSchemaToZod.js
|
|
593
|
+
const jsonSchemaToZod$1 = (schema, { module, name, type, noImport, zodVersion = 4, ...rest } = {}) => {
|
|
593
594
|
if (type && (!name || module !== "esm")) throw new Error("Option `type` requires `name` to be set and `module` to be `esm`");
|
|
594
595
|
let result = parseSchema(schema, {
|
|
595
596
|
module,
|
|
596
597
|
name,
|
|
597
598
|
path: [],
|
|
598
599
|
seen: /* @__PURE__ */ new Map(),
|
|
600
|
+
zodVersion,
|
|
599
601
|
...rest
|
|
600
602
|
});
|
|
601
603
|
const jsdocs = rest.withJsdocs && typeof schema !== "boolean" && schema.description ? expandJsdocs(schema.description) : "";
|
|
@@ -619,11 +621,9 @@ ${result}`;
|
|
|
619
621
|
}
|
|
620
622
|
return result;
|
|
621
623
|
};
|
|
622
|
-
|
|
623
|
-
//#region ../../../../../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
|
|
624
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/json-schema-to-zod/2.8.1/c100d4d307044bc24116b6230c3615807364a7e5d169923ae0cf63fb170f8f2b/node_modules/json-schema-to-zod/dist/esm/index.js
|
|
624
625
|
var esm_default = jsonSchemaToZod$1;
|
|
625
|
-
|
|
626
|
-
//#region src/json-to-zod.ts
|
|
626
|
+
// src/json-to-zod.ts
|
|
627
627
|
function parseObject$1(objectSchema, refs) {
|
|
628
628
|
let properties = void 0;
|
|
629
629
|
if (objectSchema.properties) {
|
|
@@ -820,7 +820,6 @@ function jsonSchemaToZod(schema, options = {}) {
|
|
|
820
820
|
parserOverride
|
|
821
821
|
}).replace(/\.reduce<[^>]+>/g, ".reduce");
|
|
822
822
|
}
|
|
823
|
-
//#endregion
|
|
824
823
|
export { addJsdocs, expandJsdocs, half, its, jsonSchemaToZod, omit, parseAllOf, parseAnyOf, parseArray, parseBoolean, parseConst, parseDefault, parseEnum, parseIfThenElse, parseMultipleType, parseNot, parseNull, parseNullable, parseNumber, parseObject, parseOneOf, parseSchema, parseSimpleDiscriminatedOneOf, parseString, withMessage };
|
|
825
824
|
|
|
826
825
|
//# sourceMappingURL=json-to-zod.js.map
|