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