@mastra/schema-compat 1.3.6-alpha.2 → 1.3.6
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/CHANGELOG.md +20 -0
- package/dist/esm-WUB3nKhz.js +1095 -0
- package/dist/esm-WUB3nKhz.js.map +1 -0
- package/dist/esm-pT0d13Vi.cjs +1106 -0
- package/dist/esm-pT0d13Vi.cjs.map +1 -0
- package/dist/index.cjs +132 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +131 -1
- package/dist/index.js.map +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 +2 -2
- package/dist/standard-schema/adapters/zod-v3.js.map +1 -1
- package/dist/zod-to-json.cjs +2 -4
- package/dist/zod-to-json.cjs.map +1 -1
- package/dist/zod-to-json.js +2 -2
- package/dist/zod-to-json.js.map +1 -1
- package/package.json +11 -11
|
@@ -0,0 +1,1106 @@
|
|
|
1
|
+
let zod_v3 = require("zod/v3");
|
|
2
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
3
|
+
const ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
4
|
+
const defaultOptions = {
|
|
5
|
+
name: void 0,
|
|
6
|
+
$refStrategy: "root",
|
|
7
|
+
basePath: ["#"],
|
|
8
|
+
effectStrategy: "input",
|
|
9
|
+
pipeStrategy: "all",
|
|
10
|
+
dateStrategy: "format:date-time",
|
|
11
|
+
mapStrategy: "entries",
|
|
12
|
+
removeAdditionalStrategy: "passthrough",
|
|
13
|
+
allowedAdditionalProperties: true,
|
|
14
|
+
rejectedAdditionalProperties: false,
|
|
15
|
+
definitionPath: "definitions",
|
|
16
|
+
target: "jsonSchema7",
|
|
17
|
+
strictUnions: false,
|
|
18
|
+
definitions: {},
|
|
19
|
+
errorMessages: false,
|
|
20
|
+
markdownDescription: false,
|
|
21
|
+
patternStrategy: "escape",
|
|
22
|
+
applyRegexFlags: false,
|
|
23
|
+
emailStrategy: "format:email",
|
|
24
|
+
base64Strategy: "contentEncoding:base64",
|
|
25
|
+
nameStrategy: "ref",
|
|
26
|
+
openAiAnyTypeName: "OpenAiAnyType"
|
|
27
|
+
};
|
|
28
|
+
const getDefaultOptions = (options) => typeof options === "string" ? {
|
|
29
|
+
...defaultOptions,
|
|
30
|
+
name: options
|
|
31
|
+
} : {
|
|
32
|
+
...defaultOptions,
|
|
33
|
+
...options
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/Refs.js
|
|
37
|
+
const getRefs = (options) => {
|
|
38
|
+
const _options = getDefaultOptions(options);
|
|
39
|
+
const currentPath = _options.name !== void 0 ? [
|
|
40
|
+
..._options.basePath,
|
|
41
|
+
_options.definitionPath,
|
|
42
|
+
_options.name
|
|
43
|
+
] : _options.basePath;
|
|
44
|
+
return {
|
|
45
|
+
..._options,
|
|
46
|
+
flags: { hasReferencedOpenAiAnyType: false },
|
|
47
|
+
currentPath,
|
|
48
|
+
propertyPath: void 0,
|
|
49
|
+
seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [def._def, {
|
|
50
|
+
def: def._def,
|
|
51
|
+
path: [
|
|
52
|
+
..._options.basePath,
|
|
53
|
+
_options.definitionPath,
|
|
54
|
+
name
|
|
55
|
+
],
|
|
56
|
+
jsonSchema: void 0
|
|
57
|
+
}]))
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
|
|
62
|
+
function addErrorMessage(res, key, errorMessage, refs) {
|
|
63
|
+
if (!refs?.errorMessages) return;
|
|
64
|
+
if (errorMessage) res.errorMessage = {
|
|
65
|
+
...res.errorMessage,
|
|
66
|
+
[key]: errorMessage
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
70
|
+
res[key] = value;
|
|
71
|
+
addErrorMessage(res, key, errorMessage, refs);
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
|
|
75
|
+
const getRelativePath = (pathA, pathB) => {
|
|
76
|
+
let i = 0;
|
|
77
|
+
for (; i < pathA.length && i < pathB.length; i++) if (pathA[i] !== pathB[i]) break;
|
|
78
|
+
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
|
|
82
|
+
function parseAnyDef(refs) {
|
|
83
|
+
if (refs.target !== "openAi") return {};
|
|
84
|
+
const anyDefinitionPath = [
|
|
85
|
+
...refs.basePath,
|
|
86
|
+
refs.definitionPath,
|
|
87
|
+
refs.openAiAnyTypeName
|
|
88
|
+
];
|
|
89
|
+
refs.flags.hasReferencedOpenAiAnyType = true;
|
|
90
|
+
return { $ref: refs.$refStrategy === "relative" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/") };
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
94
|
+
function parseArrayDef(def, refs) {
|
|
95
|
+
const res = { type: "array" };
|
|
96
|
+
if (def.type?._def && def.type?._def?.typeName !== zod_v3.ZodFirstPartyTypeKind.ZodAny) res.items = parseDef(def.type._def, {
|
|
97
|
+
...refs,
|
|
98
|
+
currentPath: [...refs.currentPath, "items"]
|
|
99
|
+
});
|
|
100
|
+
if (def.minLength) setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
|
|
101
|
+
if (def.maxLength) setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
|
|
102
|
+
if (def.exactLength) {
|
|
103
|
+
setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
|
|
104
|
+
setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
|
|
105
|
+
}
|
|
106
|
+
return res;
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
|
|
110
|
+
function parseBigintDef(def, refs) {
|
|
111
|
+
const res = {
|
|
112
|
+
type: "integer",
|
|
113
|
+
format: "int64"
|
|
114
|
+
};
|
|
115
|
+
if (!def.checks) return res;
|
|
116
|
+
for (const check of def.checks) switch (check.kind) {
|
|
117
|
+
case "min":
|
|
118
|
+
if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
119
|
+
else setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
120
|
+
else {
|
|
121
|
+
if (!check.inclusive) res.exclusiveMinimum = true;
|
|
122
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
case "max":
|
|
126
|
+
if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
127
|
+
else setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
128
|
+
else {
|
|
129
|
+
if (!check.inclusive) res.exclusiveMaximum = true;
|
|
130
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
case "multipleOf":
|
|
134
|
+
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
return res;
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
|
|
141
|
+
function parseBooleanDef() {
|
|
142
|
+
return { type: "boolean" };
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
|
|
146
|
+
function parseBrandedDef(_def, refs) {
|
|
147
|
+
return parseDef(_def.type._def, refs);
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
|
|
151
|
+
const parseCatchDef = (def, refs) => {
|
|
152
|
+
return parseDef(def.innerType._def, refs);
|
|
153
|
+
};
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
|
|
156
|
+
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
157
|
+
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
158
|
+
if (Array.isArray(strategy)) return { anyOf: strategy.map((item, i) => parseDateDef(def, refs, item)) };
|
|
159
|
+
switch (strategy) {
|
|
160
|
+
case "string":
|
|
161
|
+
case "format:date-time": return {
|
|
162
|
+
type: "string",
|
|
163
|
+
format: "date-time"
|
|
164
|
+
};
|
|
165
|
+
case "format:date": return {
|
|
166
|
+
type: "string",
|
|
167
|
+
format: "date"
|
|
168
|
+
};
|
|
169
|
+
case "integer": return integerDateParser(def, refs);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const integerDateParser = (def, refs) => {
|
|
173
|
+
const res = {
|
|
174
|
+
type: "integer",
|
|
175
|
+
format: "unix-time"
|
|
176
|
+
};
|
|
177
|
+
if (refs.target === "openApi3") return res;
|
|
178
|
+
for (const check of def.checks) switch (check.kind) {
|
|
179
|
+
case "min":
|
|
180
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
181
|
+
break;
|
|
182
|
+
case "max":
|
|
183
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
return res;
|
|
187
|
+
};
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
|
|
190
|
+
function parseDefaultDef(_def, refs) {
|
|
191
|
+
return {
|
|
192
|
+
...parseDef(_def.innerType._def, refs),
|
|
193
|
+
default: _def.defaultValue()
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
|
|
198
|
+
function parseEffectsDef(_def, refs) {
|
|
199
|
+
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
|
|
203
|
+
function parseEnumDef(def) {
|
|
204
|
+
return {
|
|
205
|
+
type: "string",
|
|
206
|
+
enum: Array.from(def.values)
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
|
|
211
|
+
const isJsonSchema7AllOfType = (type) => {
|
|
212
|
+
if ("type" in type && type.type === "string") return false;
|
|
213
|
+
return "allOf" in type;
|
|
214
|
+
};
|
|
215
|
+
function parseIntersectionDef(def, refs) {
|
|
216
|
+
const allOf = [parseDef(def.left._def, {
|
|
217
|
+
...refs,
|
|
218
|
+
currentPath: [
|
|
219
|
+
...refs.currentPath,
|
|
220
|
+
"allOf",
|
|
221
|
+
"0"
|
|
222
|
+
]
|
|
223
|
+
}), parseDef(def.right._def, {
|
|
224
|
+
...refs,
|
|
225
|
+
currentPath: [
|
|
226
|
+
...refs.currentPath,
|
|
227
|
+
"allOf",
|
|
228
|
+
"1"
|
|
229
|
+
]
|
|
230
|
+
})].filter((x) => !!x);
|
|
231
|
+
let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : void 0;
|
|
232
|
+
const mergedAllOf = [];
|
|
233
|
+
allOf.forEach((schema) => {
|
|
234
|
+
if (isJsonSchema7AllOfType(schema)) {
|
|
235
|
+
mergedAllOf.push(...schema.allOf);
|
|
236
|
+
if (schema.unevaluatedProperties === void 0) unevaluatedProperties = void 0;
|
|
237
|
+
} else {
|
|
238
|
+
let nestedSchema = schema;
|
|
239
|
+
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
240
|
+
const { additionalProperties, ...rest } = schema;
|
|
241
|
+
nestedSchema = rest;
|
|
242
|
+
} else unevaluatedProperties = void 0;
|
|
243
|
+
mergedAllOf.push(nestedSchema);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
return mergedAllOf.length ? {
|
|
247
|
+
allOf: mergedAllOf,
|
|
248
|
+
...unevaluatedProperties
|
|
249
|
+
} : void 0;
|
|
250
|
+
}
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
|
|
253
|
+
function parseLiteralDef(def, refs) {
|
|
254
|
+
const parsedType = typeof def.value;
|
|
255
|
+
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") return { type: Array.isArray(def.value) ? "array" : "object" };
|
|
256
|
+
if (refs.target === "openApi3") return {
|
|
257
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
258
|
+
enum: [def.value]
|
|
259
|
+
};
|
|
260
|
+
return {
|
|
261
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
262
|
+
const: def.value
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
267
|
+
let emojiRegex = void 0;
|
|
268
|
+
/**
|
|
269
|
+
* Generated from the regular expressions found here as of 2024-05-22:
|
|
270
|
+
* https://github.com/colinhacks/zod/blob/master/src/types.ts.
|
|
271
|
+
*
|
|
272
|
+
* Expressions with /i flag have been changed accordingly.
|
|
273
|
+
*/
|
|
274
|
+
const zodPatterns = {
|
|
275
|
+
/**
|
|
276
|
+
* `c` was changed to `[cC]` to replicate /i flag
|
|
277
|
+
*/
|
|
278
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
279
|
+
cuid2: /^[0-9a-z]+$/,
|
|
280
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
281
|
+
/**
|
|
282
|
+
* `a-z` was added to replicate /i flag
|
|
283
|
+
*/
|
|
284
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
285
|
+
/**
|
|
286
|
+
* Constructed a valid Unicode RegExp
|
|
287
|
+
*
|
|
288
|
+
* Lazily instantiate since this type of regex isn't supported
|
|
289
|
+
* in all envs (e.g. React Native).
|
|
290
|
+
*
|
|
291
|
+
* See:
|
|
292
|
+
* https://github.com/colinhacks/zod/issues/2433
|
|
293
|
+
* Fix in Zod:
|
|
294
|
+
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
295
|
+
*/
|
|
296
|
+
emoji: () => {
|
|
297
|
+
if (emojiRegex === void 0) emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
298
|
+
return emojiRegex;
|
|
299
|
+
},
|
|
300
|
+
/**
|
|
301
|
+
* Unused
|
|
302
|
+
*/
|
|
303
|
+
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
304
|
+
/**
|
|
305
|
+
* Unused
|
|
306
|
+
*/
|
|
307
|
+
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
308
|
+
ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
|
|
309
|
+
/**
|
|
310
|
+
* Unused
|
|
311
|
+
*/
|
|
312
|
+
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
313
|
+
ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
314
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
315
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
316
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
317
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
318
|
+
};
|
|
319
|
+
function parseStringDef(def, refs) {
|
|
320
|
+
const res = { type: "string" };
|
|
321
|
+
if (def.checks) for (const check of def.checks) switch (check.kind) {
|
|
322
|
+
case "min":
|
|
323
|
+
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
324
|
+
break;
|
|
325
|
+
case "max":
|
|
326
|
+
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
327
|
+
break;
|
|
328
|
+
case "email":
|
|
329
|
+
switch (refs.emailStrategy) {
|
|
330
|
+
case "format:email":
|
|
331
|
+
addFormat(res, "email", check.message, refs);
|
|
332
|
+
break;
|
|
333
|
+
case "format:idn-email":
|
|
334
|
+
addFormat(res, "idn-email", check.message, refs);
|
|
335
|
+
break;
|
|
336
|
+
case "pattern:zod":
|
|
337
|
+
addPattern(res, zodPatterns.email, check.message, refs);
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
break;
|
|
341
|
+
case "url":
|
|
342
|
+
addFormat(res, "uri", check.message, refs);
|
|
343
|
+
break;
|
|
344
|
+
case "uuid":
|
|
345
|
+
addFormat(res, "uuid", check.message, refs);
|
|
346
|
+
break;
|
|
347
|
+
case "regex":
|
|
348
|
+
addPattern(res, check.regex, check.message, refs);
|
|
349
|
+
break;
|
|
350
|
+
case "cuid":
|
|
351
|
+
addPattern(res, zodPatterns.cuid, check.message, refs);
|
|
352
|
+
break;
|
|
353
|
+
case "cuid2":
|
|
354
|
+
addPattern(res, zodPatterns.cuid2, check.message, refs);
|
|
355
|
+
break;
|
|
356
|
+
case "startsWith":
|
|
357
|
+
addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
|
|
358
|
+
break;
|
|
359
|
+
case "endsWith":
|
|
360
|
+
addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
|
|
361
|
+
break;
|
|
362
|
+
case "datetime":
|
|
363
|
+
addFormat(res, "date-time", check.message, refs);
|
|
364
|
+
break;
|
|
365
|
+
case "date":
|
|
366
|
+
addFormat(res, "date", check.message, refs);
|
|
367
|
+
break;
|
|
368
|
+
case "time":
|
|
369
|
+
addFormat(res, "time", check.message, refs);
|
|
370
|
+
break;
|
|
371
|
+
case "duration":
|
|
372
|
+
addFormat(res, "duration", check.message, refs);
|
|
373
|
+
break;
|
|
374
|
+
case "length":
|
|
375
|
+
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
376
|
+
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
377
|
+
break;
|
|
378
|
+
case "includes":
|
|
379
|
+
addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
|
|
380
|
+
break;
|
|
381
|
+
case "ip":
|
|
382
|
+
if (check.version !== "v6") addFormat(res, "ipv4", check.message, refs);
|
|
383
|
+
if (check.version !== "v4") addFormat(res, "ipv6", check.message, refs);
|
|
384
|
+
break;
|
|
385
|
+
case "base64url":
|
|
386
|
+
addPattern(res, zodPatterns.base64url, check.message, refs);
|
|
387
|
+
break;
|
|
388
|
+
case "jwt":
|
|
389
|
+
addPattern(res, zodPatterns.jwt, check.message, refs);
|
|
390
|
+
break;
|
|
391
|
+
case "cidr":
|
|
392
|
+
if (check.version !== "v6") addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
|
|
393
|
+
if (check.version !== "v4") addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
|
|
394
|
+
break;
|
|
395
|
+
case "emoji":
|
|
396
|
+
addPattern(res, zodPatterns.emoji(), check.message, refs);
|
|
397
|
+
break;
|
|
398
|
+
case "ulid":
|
|
399
|
+
addPattern(res, zodPatterns.ulid, check.message, refs);
|
|
400
|
+
break;
|
|
401
|
+
case "base64":
|
|
402
|
+
switch (refs.base64Strategy) {
|
|
403
|
+
case "format:binary":
|
|
404
|
+
addFormat(res, "binary", check.message, refs);
|
|
405
|
+
break;
|
|
406
|
+
case "contentEncoding:base64":
|
|
407
|
+
setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
|
|
408
|
+
break;
|
|
409
|
+
case "pattern:zod":
|
|
410
|
+
addPattern(res, zodPatterns.base64, check.message, refs);
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
break;
|
|
414
|
+
case "nanoid": addPattern(res, zodPatterns.nanoid, check.message, refs);
|
|
415
|
+
case "toLowerCase":
|
|
416
|
+
case "toUpperCase":
|
|
417
|
+
case "trim": break;
|
|
418
|
+
default:
|
|
419
|
+
}
|
|
420
|
+
return res;
|
|
421
|
+
}
|
|
422
|
+
function escapeLiteralCheckValue(literal, refs) {
|
|
423
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
|
|
424
|
+
}
|
|
425
|
+
const ALPHA_NUMERIC = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
426
|
+
function escapeNonAlphaNumeric(source) {
|
|
427
|
+
let result = "";
|
|
428
|
+
for (let i = 0; i < source.length; i++) {
|
|
429
|
+
if (!ALPHA_NUMERIC.has(source[i])) result += "\\";
|
|
430
|
+
result += source[i];
|
|
431
|
+
}
|
|
432
|
+
return result;
|
|
433
|
+
}
|
|
434
|
+
function addFormat(schema, value, message, refs) {
|
|
435
|
+
if (schema.format || schema.anyOf?.some((x) => x.format)) {
|
|
436
|
+
if (!schema.anyOf) schema.anyOf = [];
|
|
437
|
+
if (schema.format) {
|
|
438
|
+
schema.anyOf.push({
|
|
439
|
+
format: schema.format,
|
|
440
|
+
...schema.errorMessage && refs.errorMessages && { errorMessage: { format: schema.errorMessage.format } }
|
|
441
|
+
});
|
|
442
|
+
delete schema.format;
|
|
443
|
+
if (schema.errorMessage) {
|
|
444
|
+
delete schema.errorMessage.format;
|
|
445
|
+
if (Object.keys(schema.errorMessage).length === 0) delete schema.errorMessage;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
schema.anyOf.push({
|
|
449
|
+
format: value,
|
|
450
|
+
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
451
|
+
});
|
|
452
|
+
} else setResponseValueAndErrors(schema, "format", value, message, refs);
|
|
453
|
+
}
|
|
454
|
+
function addPattern(schema, regex, message, refs) {
|
|
455
|
+
if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
|
|
456
|
+
if (!schema.allOf) schema.allOf = [];
|
|
457
|
+
if (schema.pattern) {
|
|
458
|
+
schema.allOf.push({
|
|
459
|
+
pattern: schema.pattern,
|
|
460
|
+
...schema.errorMessage && refs.errorMessages && { errorMessage: { pattern: schema.errorMessage.pattern } }
|
|
461
|
+
});
|
|
462
|
+
delete schema.pattern;
|
|
463
|
+
if (schema.errorMessage) {
|
|
464
|
+
delete schema.errorMessage.pattern;
|
|
465
|
+
if (Object.keys(schema.errorMessage).length === 0) delete schema.errorMessage;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
schema.allOf.push({
|
|
469
|
+
pattern: stringifyRegExpWithFlags(regex, refs),
|
|
470
|
+
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
471
|
+
});
|
|
472
|
+
} else setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
|
|
473
|
+
}
|
|
474
|
+
function stringifyRegExpWithFlags(regex, refs) {
|
|
475
|
+
if (!refs.applyRegexFlags || !regex.flags) return regex.source;
|
|
476
|
+
const flags = {
|
|
477
|
+
i: regex.flags.includes("i"),
|
|
478
|
+
m: regex.flags.includes("m"),
|
|
479
|
+
s: regex.flags.includes("s")
|
|
480
|
+
};
|
|
481
|
+
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
482
|
+
let pattern = "";
|
|
483
|
+
let isEscaped = false;
|
|
484
|
+
let inCharGroup = false;
|
|
485
|
+
let inCharRange = false;
|
|
486
|
+
for (let i = 0; i < source.length; i++) {
|
|
487
|
+
if (isEscaped) {
|
|
488
|
+
pattern += source[i];
|
|
489
|
+
isEscaped = false;
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
if (flags.i) {
|
|
493
|
+
if (inCharGroup) {
|
|
494
|
+
if (source[i].match(/[a-z]/)) {
|
|
495
|
+
if (inCharRange) {
|
|
496
|
+
pattern += source[i];
|
|
497
|
+
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
498
|
+
inCharRange = false;
|
|
499
|
+
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
500
|
+
pattern += source[i];
|
|
501
|
+
inCharRange = true;
|
|
502
|
+
} else pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
} else if (source[i].match(/[a-z]/)) {
|
|
506
|
+
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (flags.m) {
|
|
511
|
+
if (source[i] === "^") {
|
|
512
|
+
pattern += `(^|(?<=[\r\n]))`;
|
|
513
|
+
continue;
|
|
514
|
+
} else if (source[i] === "$") {
|
|
515
|
+
pattern += `($|(?=[\r\n]))`;
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
if (flags.s && source[i] === ".") {
|
|
520
|
+
pattern += inCharGroup ? `${source[i]}\r\n` : `[${source[i]}\r\n]`;
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
pattern += source[i];
|
|
524
|
+
if (source[i] === "\\") isEscaped = true;
|
|
525
|
+
else if (inCharGroup && source[i] === "]") inCharGroup = false;
|
|
526
|
+
else if (!inCharGroup && source[i] === "[") inCharGroup = true;
|
|
527
|
+
}
|
|
528
|
+
try {
|
|
529
|
+
new RegExp(pattern);
|
|
530
|
+
} catch {
|
|
531
|
+
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
532
|
+
return regex.source;
|
|
533
|
+
}
|
|
534
|
+
return pattern;
|
|
535
|
+
}
|
|
536
|
+
//#endregion
|
|
537
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
538
|
+
function parseRecordDef(def, refs) {
|
|
539
|
+
if (refs.target === "openAi") console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
540
|
+
if (refs.target === "openApi3" && def.keyType?._def.typeName === zod_v3.ZodFirstPartyTypeKind.ZodEnum) return {
|
|
541
|
+
type: "object",
|
|
542
|
+
required: def.keyType._def.values,
|
|
543
|
+
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
544
|
+
...acc,
|
|
545
|
+
[key]: parseDef(def.valueType._def, {
|
|
546
|
+
...refs,
|
|
547
|
+
currentPath: [
|
|
548
|
+
...refs.currentPath,
|
|
549
|
+
"properties",
|
|
550
|
+
key
|
|
551
|
+
]
|
|
552
|
+
}) ?? parseAnyDef(refs)
|
|
553
|
+
}), {}),
|
|
554
|
+
additionalProperties: refs.rejectedAdditionalProperties
|
|
555
|
+
};
|
|
556
|
+
const schema = {
|
|
557
|
+
type: "object",
|
|
558
|
+
additionalProperties: parseDef(def.valueType._def, {
|
|
559
|
+
...refs,
|
|
560
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
561
|
+
}) ?? refs.allowedAdditionalProperties
|
|
562
|
+
};
|
|
563
|
+
if (refs.target === "openApi3") return schema;
|
|
564
|
+
if (def.keyType?._def.typeName === zod_v3.ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
565
|
+
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
566
|
+
return {
|
|
567
|
+
...schema,
|
|
568
|
+
propertyNames: keyType
|
|
569
|
+
};
|
|
570
|
+
} else if (def.keyType?._def.typeName === zod_v3.ZodFirstPartyTypeKind.ZodEnum) return {
|
|
571
|
+
...schema,
|
|
572
|
+
propertyNames: { enum: def.keyType._def.values }
|
|
573
|
+
};
|
|
574
|
+
else if (def.keyType?._def.typeName === zod_v3.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === zod_v3.ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
575
|
+
const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
576
|
+
return {
|
|
577
|
+
...schema,
|
|
578
|
+
propertyNames: keyType
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
return schema;
|
|
582
|
+
}
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
|
|
585
|
+
function parseMapDef(def, refs) {
|
|
586
|
+
if (refs.mapStrategy === "record") return parseRecordDef(def, refs);
|
|
587
|
+
return {
|
|
588
|
+
type: "array",
|
|
589
|
+
maxItems: 125,
|
|
590
|
+
items: {
|
|
591
|
+
type: "array",
|
|
592
|
+
items: [parseDef(def.keyType._def, {
|
|
593
|
+
...refs,
|
|
594
|
+
currentPath: [
|
|
595
|
+
...refs.currentPath,
|
|
596
|
+
"items",
|
|
597
|
+
"items",
|
|
598
|
+
"0"
|
|
599
|
+
]
|
|
600
|
+
}) || parseAnyDef(refs), parseDef(def.valueType._def, {
|
|
601
|
+
...refs,
|
|
602
|
+
currentPath: [
|
|
603
|
+
...refs.currentPath,
|
|
604
|
+
"items",
|
|
605
|
+
"items",
|
|
606
|
+
"1"
|
|
607
|
+
]
|
|
608
|
+
}) || parseAnyDef(refs)],
|
|
609
|
+
minItems: 2,
|
|
610
|
+
maxItems: 2
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
//#endregion
|
|
615
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
616
|
+
function parseNativeEnumDef(def) {
|
|
617
|
+
const object = def.values;
|
|
618
|
+
const actualValues = Object.keys(def.values).filter((key) => {
|
|
619
|
+
return typeof object[object[key]] !== "number";
|
|
620
|
+
}).map((key) => object[key]);
|
|
621
|
+
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
622
|
+
return {
|
|
623
|
+
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
624
|
+
enum: actualValues
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
//#endregion
|
|
628
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
|
|
629
|
+
function parseNeverDef(refs) {
|
|
630
|
+
return refs.target === "openAi" ? void 0 : { not: parseAnyDef({
|
|
631
|
+
...refs,
|
|
632
|
+
currentPath: [...refs.currentPath, "not"]
|
|
633
|
+
}) };
|
|
634
|
+
}
|
|
635
|
+
//#endregion
|
|
636
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
|
|
637
|
+
function parseNullDef(refs) {
|
|
638
|
+
return refs.target === "openApi3" ? {
|
|
639
|
+
enum: ["null"],
|
|
640
|
+
nullable: true
|
|
641
|
+
} : { type: "null" };
|
|
642
|
+
}
|
|
643
|
+
//#endregion
|
|
644
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
|
|
645
|
+
const primitiveMappings = {
|
|
646
|
+
ZodString: "string",
|
|
647
|
+
ZodNumber: "number",
|
|
648
|
+
ZodBigInt: "integer",
|
|
649
|
+
ZodBoolean: "boolean",
|
|
650
|
+
ZodNull: "null"
|
|
651
|
+
};
|
|
652
|
+
function parseUnionDef(def, refs) {
|
|
653
|
+
if (refs.target === "openApi3") return asAnyOf(def, refs);
|
|
654
|
+
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
655
|
+
if (options.every((x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))) {
|
|
656
|
+
const types = options.reduce((types, x) => {
|
|
657
|
+
const type = primitiveMappings[x._def.typeName];
|
|
658
|
+
return type && !types.includes(type) ? [...types, type] : types;
|
|
659
|
+
}, []);
|
|
660
|
+
return { type: types.length > 1 ? types : types[0] };
|
|
661
|
+
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
662
|
+
const types = options.reduce((acc, x) => {
|
|
663
|
+
const type = typeof x._def.value;
|
|
664
|
+
switch (type) {
|
|
665
|
+
case "string":
|
|
666
|
+
case "number":
|
|
667
|
+
case "boolean": return [...acc, type];
|
|
668
|
+
case "bigint": return [...acc, "integer"];
|
|
669
|
+
case "object": if (x._def.value === null) return [...acc, "null"];
|
|
670
|
+
default: return acc;
|
|
671
|
+
}
|
|
672
|
+
}, []);
|
|
673
|
+
if (types.length === options.length) {
|
|
674
|
+
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
675
|
+
return {
|
|
676
|
+
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
677
|
+
enum: options.reduce((acc, x) => {
|
|
678
|
+
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
679
|
+
}, [])
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
} else if (options.every((x) => x._def.typeName === "ZodEnum")) return {
|
|
683
|
+
type: "string",
|
|
684
|
+
enum: options.reduce((acc, x) => [...acc, ...x._def.values.filter((x) => !acc.includes(x))], [])
|
|
685
|
+
};
|
|
686
|
+
return asAnyOf(def, refs);
|
|
687
|
+
}
|
|
688
|
+
const asAnyOf = (def, refs) => {
|
|
689
|
+
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
|
|
690
|
+
...refs,
|
|
691
|
+
currentPath: [
|
|
692
|
+
...refs.currentPath,
|
|
693
|
+
"anyOf",
|
|
694
|
+
`${i}`
|
|
695
|
+
]
|
|
696
|
+
})).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
|
|
697
|
+
return anyOf.length ? { anyOf } : void 0;
|
|
698
|
+
};
|
|
699
|
+
//#endregion
|
|
700
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
|
|
701
|
+
function parseNullableDef(def, refs) {
|
|
702
|
+
if ([
|
|
703
|
+
"ZodString",
|
|
704
|
+
"ZodNumber",
|
|
705
|
+
"ZodBigInt",
|
|
706
|
+
"ZodBoolean",
|
|
707
|
+
"ZodNull"
|
|
708
|
+
].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
709
|
+
if (refs.target === "openApi3") return {
|
|
710
|
+
type: primitiveMappings[def.innerType._def.typeName],
|
|
711
|
+
nullable: true
|
|
712
|
+
};
|
|
713
|
+
return { type: [primitiveMappings[def.innerType._def.typeName], "null"] };
|
|
714
|
+
}
|
|
715
|
+
if (refs.target === "openApi3") {
|
|
716
|
+
const base = parseDef(def.innerType._def, {
|
|
717
|
+
...refs,
|
|
718
|
+
currentPath: [...refs.currentPath]
|
|
719
|
+
});
|
|
720
|
+
if (base && "$ref" in base) return {
|
|
721
|
+
allOf: [base],
|
|
722
|
+
nullable: true
|
|
723
|
+
};
|
|
724
|
+
return base && {
|
|
725
|
+
...base,
|
|
726
|
+
nullable: true
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
const base = parseDef(def.innerType._def, {
|
|
730
|
+
...refs,
|
|
731
|
+
currentPath: [
|
|
732
|
+
...refs.currentPath,
|
|
733
|
+
"anyOf",
|
|
734
|
+
"0"
|
|
735
|
+
]
|
|
736
|
+
});
|
|
737
|
+
return base && { anyOf: [base, { type: "null" }] };
|
|
738
|
+
}
|
|
739
|
+
//#endregion
|
|
740
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
|
|
741
|
+
function parseNumberDef(def, refs) {
|
|
742
|
+
const res = { type: "number" };
|
|
743
|
+
if (!def.checks) return res;
|
|
744
|
+
for (const check of def.checks) switch (check.kind) {
|
|
745
|
+
case "int":
|
|
746
|
+
res.type = "integer";
|
|
747
|
+
addErrorMessage(res, "type", check.message, refs);
|
|
748
|
+
break;
|
|
749
|
+
case "min":
|
|
750
|
+
if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
751
|
+
else setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
752
|
+
else {
|
|
753
|
+
if (!check.inclusive) res.exclusiveMinimum = true;
|
|
754
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
755
|
+
}
|
|
756
|
+
break;
|
|
757
|
+
case "max":
|
|
758
|
+
if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
759
|
+
else setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
760
|
+
else {
|
|
761
|
+
if (!check.inclusive) res.exclusiveMaximum = true;
|
|
762
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
763
|
+
}
|
|
764
|
+
break;
|
|
765
|
+
case "multipleOf":
|
|
766
|
+
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
767
|
+
break;
|
|
768
|
+
}
|
|
769
|
+
return res;
|
|
770
|
+
}
|
|
771
|
+
//#endregion
|
|
772
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
|
|
773
|
+
function parseObjectDef(def, refs) {
|
|
774
|
+
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
775
|
+
const result = {
|
|
776
|
+
type: "object",
|
|
777
|
+
properties: {}
|
|
778
|
+
};
|
|
779
|
+
const required = [];
|
|
780
|
+
const shape = def.shape();
|
|
781
|
+
for (const propName in shape) {
|
|
782
|
+
let propDef = shape[propName];
|
|
783
|
+
if (propDef === void 0 || propDef._def === void 0) continue;
|
|
784
|
+
let propOptional = safeIsOptional(propDef);
|
|
785
|
+
if (propOptional && forceOptionalIntoNullable) {
|
|
786
|
+
if (propDef._def.typeName === "ZodOptional") propDef = propDef._def.innerType;
|
|
787
|
+
if (!propDef.isNullable()) propDef = propDef.nullable();
|
|
788
|
+
propOptional = false;
|
|
789
|
+
}
|
|
790
|
+
const parsedDef = parseDef(propDef._def, {
|
|
791
|
+
...refs,
|
|
792
|
+
currentPath: [
|
|
793
|
+
...refs.currentPath,
|
|
794
|
+
"properties",
|
|
795
|
+
propName
|
|
796
|
+
],
|
|
797
|
+
propertyPath: [
|
|
798
|
+
...refs.currentPath,
|
|
799
|
+
"properties",
|
|
800
|
+
propName
|
|
801
|
+
]
|
|
802
|
+
});
|
|
803
|
+
if (parsedDef === void 0) continue;
|
|
804
|
+
result.properties[propName] = parsedDef;
|
|
805
|
+
if (!propOptional) required.push(propName);
|
|
806
|
+
}
|
|
807
|
+
if (required.length) result.required = required;
|
|
808
|
+
const additionalProperties = decideAdditionalProperties(def, refs);
|
|
809
|
+
if (additionalProperties !== void 0) result.additionalProperties = additionalProperties;
|
|
810
|
+
return result;
|
|
811
|
+
}
|
|
812
|
+
function decideAdditionalProperties(def, refs) {
|
|
813
|
+
if (def.catchall._def.typeName !== "ZodNever") return parseDef(def.catchall._def, {
|
|
814
|
+
...refs,
|
|
815
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
816
|
+
});
|
|
817
|
+
switch (def.unknownKeys) {
|
|
818
|
+
case "passthrough": return refs.allowedAdditionalProperties;
|
|
819
|
+
case "strict": return refs.rejectedAdditionalProperties;
|
|
820
|
+
case "strip": return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
function safeIsOptional(schema) {
|
|
824
|
+
try {
|
|
825
|
+
return schema.isOptional();
|
|
826
|
+
} catch {
|
|
827
|
+
return true;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
//#endregion
|
|
831
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
|
|
832
|
+
const parseOptionalDef = (def, refs) => {
|
|
833
|
+
if (refs.currentPath.toString() === refs.propertyPath?.toString()) return parseDef(def.innerType._def, refs);
|
|
834
|
+
const innerSchema = parseDef(def.innerType._def, {
|
|
835
|
+
...refs,
|
|
836
|
+
currentPath: [
|
|
837
|
+
...refs.currentPath,
|
|
838
|
+
"anyOf",
|
|
839
|
+
"1"
|
|
840
|
+
]
|
|
841
|
+
});
|
|
842
|
+
return innerSchema ? { anyOf: [{ not: parseAnyDef(refs) }, innerSchema] } : parseAnyDef(refs);
|
|
843
|
+
};
|
|
844
|
+
//#endregion
|
|
845
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
|
|
846
|
+
const parsePipelineDef = (def, refs) => {
|
|
847
|
+
if (refs.pipeStrategy === "input") return parseDef(def.in._def, refs);
|
|
848
|
+
else if (refs.pipeStrategy === "output") return parseDef(def.out._def, refs);
|
|
849
|
+
const a = parseDef(def.in._def, {
|
|
850
|
+
...refs,
|
|
851
|
+
currentPath: [
|
|
852
|
+
...refs.currentPath,
|
|
853
|
+
"allOf",
|
|
854
|
+
"0"
|
|
855
|
+
]
|
|
856
|
+
});
|
|
857
|
+
return { allOf: [a, parseDef(def.out._def, {
|
|
858
|
+
...refs,
|
|
859
|
+
currentPath: [
|
|
860
|
+
...refs.currentPath,
|
|
861
|
+
"allOf",
|
|
862
|
+
a ? "1" : "0"
|
|
863
|
+
]
|
|
864
|
+
})].filter((x) => x !== void 0) };
|
|
865
|
+
};
|
|
866
|
+
//#endregion
|
|
867
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
|
|
868
|
+
function parsePromiseDef(def, refs) {
|
|
869
|
+
return parseDef(def.type._def, refs);
|
|
870
|
+
}
|
|
871
|
+
//#endregion
|
|
872
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
|
|
873
|
+
function parseSetDef(def, refs) {
|
|
874
|
+
const schema = {
|
|
875
|
+
type: "array",
|
|
876
|
+
uniqueItems: true,
|
|
877
|
+
items: parseDef(def.valueType._def, {
|
|
878
|
+
...refs,
|
|
879
|
+
currentPath: [...refs.currentPath, "items"]
|
|
880
|
+
})
|
|
881
|
+
};
|
|
882
|
+
if (def.minSize) setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
883
|
+
if (def.maxSize) setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
884
|
+
return schema;
|
|
885
|
+
}
|
|
886
|
+
//#endregion
|
|
887
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
|
|
888
|
+
function parseTupleDef(def, refs) {
|
|
889
|
+
if (def.rest) return {
|
|
890
|
+
type: "array",
|
|
891
|
+
minItems: def.items.length,
|
|
892
|
+
items: def.items.map((x, i) => parseDef(x._def, {
|
|
893
|
+
...refs,
|
|
894
|
+
currentPath: [
|
|
895
|
+
...refs.currentPath,
|
|
896
|
+
"items",
|
|
897
|
+
`${i}`
|
|
898
|
+
]
|
|
899
|
+
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),
|
|
900
|
+
additionalItems: parseDef(def.rest._def, {
|
|
901
|
+
...refs,
|
|
902
|
+
currentPath: [...refs.currentPath, "additionalItems"]
|
|
903
|
+
})
|
|
904
|
+
};
|
|
905
|
+
else return {
|
|
906
|
+
type: "array",
|
|
907
|
+
minItems: def.items.length,
|
|
908
|
+
maxItems: def.items.length,
|
|
909
|
+
items: def.items.map((x, i) => parseDef(x._def, {
|
|
910
|
+
...refs,
|
|
911
|
+
currentPath: [
|
|
912
|
+
...refs.currentPath,
|
|
913
|
+
"items",
|
|
914
|
+
`${i}`
|
|
915
|
+
]
|
|
916
|
+
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
//#endregion
|
|
920
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
|
|
921
|
+
function parseUndefinedDef(refs) {
|
|
922
|
+
return { not: parseAnyDef(refs) };
|
|
923
|
+
}
|
|
924
|
+
//#endregion
|
|
925
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
|
|
926
|
+
function parseUnknownDef(refs) {
|
|
927
|
+
return parseAnyDef(refs);
|
|
928
|
+
}
|
|
929
|
+
//#endregion
|
|
930
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
|
|
931
|
+
const parseReadonlyDef = (def, refs) => {
|
|
932
|
+
return parseDef(def.innerType._def, refs);
|
|
933
|
+
};
|
|
934
|
+
//#endregion
|
|
935
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/selectParser.js
|
|
936
|
+
const selectParser = (def, typeName, refs) => {
|
|
937
|
+
switch (typeName) {
|
|
938
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodString: return parseStringDef(def, refs);
|
|
939
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodNumber: return parseNumberDef(def, refs);
|
|
940
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodObject: return parseObjectDef(def, refs);
|
|
941
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodBigInt: return parseBigintDef(def, refs);
|
|
942
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodBoolean: return parseBooleanDef();
|
|
943
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodDate: return parseDateDef(def, refs);
|
|
944
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodUndefined: return parseUndefinedDef(refs);
|
|
945
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodNull: return parseNullDef(refs);
|
|
946
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodArray: return parseArrayDef(def, refs);
|
|
947
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodUnion:
|
|
948
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodDiscriminatedUnion: return parseUnionDef(def, refs);
|
|
949
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodIntersection: return parseIntersectionDef(def, refs);
|
|
950
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodTuple: return parseTupleDef(def, refs);
|
|
951
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodRecord: return parseRecordDef(def, refs);
|
|
952
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodLiteral: return parseLiteralDef(def, refs);
|
|
953
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodEnum: return parseEnumDef(def);
|
|
954
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodNativeEnum: return parseNativeEnumDef(def);
|
|
955
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodNullable: return parseNullableDef(def, refs);
|
|
956
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodOptional: return parseOptionalDef(def, refs);
|
|
957
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodMap: return parseMapDef(def, refs);
|
|
958
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodSet: return parseSetDef(def, refs);
|
|
959
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodLazy: return () => def.getter()._def;
|
|
960
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodPromise: return parsePromiseDef(def, refs);
|
|
961
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodNaN:
|
|
962
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodNever: return parseNeverDef(refs);
|
|
963
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodEffects: return parseEffectsDef(def, refs);
|
|
964
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodAny: return parseAnyDef(refs);
|
|
965
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodUnknown: return parseUnknownDef(refs);
|
|
966
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodDefault: return parseDefaultDef(def, refs);
|
|
967
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodBranded: return parseBrandedDef(def, refs);
|
|
968
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodReadonly: return parseReadonlyDef(def, refs);
|
|
969
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodCatch: return parseCatchDef(def, refs);
|
|
970
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodPipeline: return parsePipelineDef(def, refs);
|
|
971
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodFunction:
|
|
972
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodVoid:
|
|
973
|
+
case zod_v3.ZodFirstPartyTypeKind.ZodSymbol: return;
|
|
974
|
+
default: return ((_) => void 0)(typeName);
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
//#endregion
|
|
978
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/parseDef.js
|
|
979
|
+
function parseDef(def, refs, forceResolution = false) {
|
|
980
|
+
const seenItem = refs.seen.get(def);
|
|
981
|
+
if (refs.override) {
|
|
982
|
+
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
983
|
+
if (overrideResult !== ignoreOverride) return overrideResult;
|
|
984
|
+
}
|
|
985
|
+
if (seenItem && !forceResolution) {
|
|
986
|
+
const seenSchema = get$ref(seenItem, refs);
|
|
987
|
+
if (seenSchema !== void 0) return seenSchema;
|
|
988
|
+
}
|
|
989
|
+
const newItem = {
|
|
990
|
+
def,
|
|
991
|
+
path: refs.currentPath,
|
|
992
|
+
jsonSchema: void 0
|
|
993
|
+
};
|
|
994
|
+
refs.seen.set(def, newItem);
|
|
995
|
+
const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
|
|
996
|
+
const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
997
|
+
if (jsonSchema) addMeta(def, refs, jsonSchema);
|
|
998
|
+
if (refs.postProcess) {
|
|
999
|
+
const postProcessResult = refs.postProcess(jsonSchema, def, refs);
|
|
1000
|
+
newItem.jsonSchema = jsonSchema;
|
|
1001
|
+
return postProcessResult;
|
|
1002
|
+
}
|
|
1003
|
+
newItem.jsonSchema = jsonSchema;
|
|
1004
|
+
return jsonSchema;
|
|
1005
|
+
}
|
|
1006
|
+
const get$ref = (item, refs) => {
|
|
1007
|
+
switch (refs.$refStrategy) {
|
|
1008
|
+
case "root": return { $ref: item.path.join("/") };
|
|
1009
|
+
case "relative": return { $ref: getRelativePath(refs.currentPath, item.path) };
|
|
1010
|
+
case "none":
|
|
1011
|
+
case "seen":
|
|
1012
|
+
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
1013
|
+
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
1014
|
+
return parseAnyDef(refs);
|
|
1015
|
+
}
|
|
1016
|
+
return refs.$refStrategy === "seen" ? parseAnyDef(refs) : void 0;
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
const addMeta = (def, refs, jsonSchema) => {
|
|
1020
|
+
if (def.description) {
|
|
1021
|
+
jsonSchema.description = def.description;
|
|
1022
|
+
if (refs.markdownDescription) jsonSchema.markdownDescription = def.description;
|
|
1023
|
+
}
|
|
1024
|
+
return jsonSchema;
|
|
1025
|
+
};
|
|
1026
|
+
//#endregion
|
|
1027
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
|
|
1028
|
+
const zodToJsonSchema = (schema, options) => {
|
|
1029
|
+
const refs = getRefs(options);
|
|
1030
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name, schema]) => ({
|
|
1031
|
+
...acc,
|
|
1032
|
+
[name]: parseDef(schema._def, {
|
|
1033
|
+
...refs,
|
|
1034
|
+
currentPath: [
|
|
1035
|
+
...refs.basePath,
|
|
1036
|
+
refs.definitionPath,
|
|
1037
|
+
name
|
|
1038
|
+
]
|
|
1039
|
+
}, true) ?? parseAnyDef(refs)
|
|
1040
|
+
}), {}) : void 0;
|
|
1041
|
+
const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
|
|
1042
|
+
const main = parseDef(schema._def, name === void 0 ? refs : {
|
|
1043
|
+
...refs,
|
|
1044
|
+
currentPath: [
|
|
1045
|
+
...refs.basePath,
|
|
1046
|
+
refs.definitionPath,
|
|
1047
|
+
name
|
|
1048
|
+
]
|
|
1049
|
+
}, false) ?? parseAnyDef(refs);
|
|
1050
|
+
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
1051
|
+
if (title !== void 0) main.title = title;
|
|
1052
|
+
if (refs.flags.hasReferencedOpenAiAnyType) {
|
|
1053
|
+
if (!definitions) definitions = {};
|
|
1054
|
+
if (!definitions[refs.openAiAnyTypeName]) definitions[refs.openAiAnyTypeName] = {
|
|
1055
|
+
type: [
|
|
1056
|
+
"string",
|
|
1057
|
+
"number",
|
|
1058
|
+
"integer",
|
|
1059
|
+
"boolean",
|
|
1060
|
+
"array",
|
|
1061
|
+
"null"
|
|
1062
|
+
],
|
|
1063
|
+
items: { $ref: refs.$refStrategy === "relative" ? "1" : [
|
|
1064
|
+
...refs.basePath,
|
|
1065
|
+
refs.definitionPath,
|
|
1066
|
+
refs.openAiAnyTypeName
|
|
1067
|
+
].join("/") }
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
const combined = name === void 0 ? definitions ? {
|
|
1071
|
+
...main,
|
|
1072
|
+
[refs.definitionPath]: definitions
|
|
1073
|
+
} : main : {
|
|
1074
|
+
$ref: [
|
|
1075
|
+
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
1076
|
+
refs.definitionPath,
|
|
1077
|
+
name
|
|
1078
|
+
].join("/"),
|
|
1079
|
+
[refs.definitionPath]: {
|
|
1080
|
+
...definitions,
|
|
1081
|
+
[name]: main
|
|
1082
|
+
}
|
|
1083
|
+
};
|
|
1084
|
+
if (refs.target === "jsonSchema7") combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
1085
|
+
else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
|
|
1086
|
+
if (refs.target === "openAi" && ("anyOf" in combined || "oneOf" in combined || "allOf" in combined || "type" in combined && Array.isArray(combined.type))) console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
|
|
1087
|
+
return combined;
|
|
1088
|
+
};
|
|
1089
|
+
//#endregion
|
|
1090
|
+
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/e44095b6546ec71c6bc64e08880b3fed52703321484b7225302b788f83667662/node_modules/zod-to-json-schema/dist/esm/index.js
|
|
1091
|
+
var esm_default = zodToJsonSchema;
|
|
1092
|
+
//#endregion
|
|
1093
|
+
Object.defineProperty(exports, "esm_default", {
|
|
1094
|
+
enumerable: true,
|
|
1095
|
+
get: function() {
|
|
1096
|
+
return esm_default;
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
Object.defineProperty(exports, "ignoreOverride", {
|
|
1100
|
+
enumerable: true,
|
|
1101
|
+
get: function() {
|
|
1102
|
+
return ignoreOverride;
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
|
|
1106
|
+
//# sourceMappingURL=esm-pT0d13Vi.cjs.map
|