@pyreon/mcp 0.5.6 → 0.5.7
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/lib/index.js +1 -1
- package/lib/types/index.d.ts +1 -3225
- package/package.json +2 -2
- package/lib/types/index.d.ts.map +0 -1
package/lib/types/index.d.ts
CHANGED
|
@@ -1,3225 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { ZodOptional, z } from "zod";
|
|
3
|
-
import process$1 from "node:process";
|
|
4
|
-
import { detectReactPatterns, diagnoseError, generateContext, migrateReactCode } from "@pyreon/compiler";
|
|
5
|
-
|
|
6
|
-
//#region \0rolldown/runtime.js
|
|
7
|
-
|
|
8
|
-
function getErrorMap() {
|
|
9
|
-
return overrideErrorMap;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v3/helpers/parseUtil.js
|
|
14
|
-
|
|
15
|
-
function addIssueToContext(ctx, issueData) {
|
|
16
|
-
const overrideMap = getErrorMap();
|
|
17
|
-
const issue = makeIssue({
|
|
18
|
-
issueData,
|
|
19
|
-
data: ctx.data,
|
|
20
|
-
path: ctx.path,
|
|
21
|
-
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, overrideMap, overrideMap === errorMap ? void 0 : errorMap].filter(x => !!x)
|
|
22
|
-
});
|
|
23
|
-
ctx.common.issues.push(issue);
|
|
24
|
-
}
|
|
25
|
-
function processCreateParams(params) {
|
|
26
|
-
if (!params) return {};
|
|
27
|
-
const {
|
|
28
|
-
errorMap,
|
|
29
|
-
invalid_type_error,
|
|
30
|
-
required_error,
|
|
31
|
-
description
|
|
32
|
-
} = params;
|
|
33
|
-
if (errorMap && (invalid_type_error || required_error)) throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
34
|
-
if (errorMap) return {
|
|
35
|
-
errorMap,
|
|
36
|
-
description
|
|
37
|
-
};
|
|
38
|
-
const customMap = (iss, ctx) => {
|
|
39
|
-
const {
|
|
40
|
-
message
|
|
41
|
-
} = params;
|
|
42
|
-
if (iss.code === "invalid_enum_value") return {
|
|
43
|
-
message: message ?? ctx.defaultError
|
|
44
|
-
};
|
|
45
|
-
if (typeof ctx.data === "undefined") return {
|
|
46
|
-
message: message ?? required_error ?? ctx.defaultError
|
|
47
|
-
};
|
|
48
|
-
if (iss.code !== "invalid_type") return {
|
|
49
|
-
message: ctx.defaultError
|
|
50
|
-
};
|
|
51
|
-
return {
|
|
52
|
-
message: message ?? invalid_type_error ?? ctx.defaultError
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
return {
|
|
56
|
-
errorMap: customMap,
|
|
57
|
-
description
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function timeRegexSource(args) {
|
|
61
|
-
let secondsRegexSource = `[0-5]\\d`;
|
|
62
|
-
if (args.precision) secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;else if (args.precision == null) secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
|
|
63
|
-
const secondsQuantifier = args.precision ? "+" : "?";
|
|
64
|
-
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
|
65
|
-
}
|
|
66
|
-
function timeRegex(args) {
|
|
67
|
-
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
68
|
-
}
|
|
69
|
-
function datetimeRegex(args) {
|
|
70
|
-
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
71
|
-
const opts = [];
|
|
72
|
-
opts.push(args.local ? `Z?` : `Z`);
|
|
73
|
-
if (args.offset) opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
74
|
-
regex = `${regex}(${opts.join("|")})`;
|
|
75
|
-
return new RegExp(`^${regex}$`);
|
|
76
|
-
}
|
|
77
|
-
function isValidIP(ip, version) {
|
|
78
|
-
if ((version === "v4" || !version) && ipv4Regex.test(ip)) return true;
|
|
79
|
-
if ((version === "v6" || !version) && ipv6Regex.test(ip)) return true;
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
function isValidJWT$1(jwt, alg) {
|
|
83
|
-
if (!jwtRegex.test(jwt)) return false;
|
|
84
|
-
try {
|
|
85
|
-
const [header] = jwt.split(".");
|
|
86
|
-
if (!header) return false;
|
|
87
|
-
const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
|
88
|
-
const decoded = JSON.parse(atob(base64));
|
|
89
|
-
if (typeof decoded !== "object" || decoded === null) return false;
|
|
90
|
-
if ("typ" in decoded && decoded?.typ !== "JWT") return false;
|
|
91
|
-
if (!decoded.alg) return false;
|
|
92
|
-
if (alg && decoded.alg !== alg) return false;
|
|
93
|
-
return true;
|
|
94
|
-
} catch {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function isValidCidr(ip, version) {
|
|
99
|
-
if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) return true;
|
|
100
|
-
if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) return true;
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
function floatSafeRemainder$1(val, step) {
|
|
104
|
-
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
105
|
-
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
106
|
-
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
107
|
-
return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
|
|
108
|
-
}
|
|
109
|
-
function deepPartialify(schema) {
|
|
110
|
-
if (schema instanceof ZodObject$1) {
|
|
111
|
-
const newShape = {};
|
|
112
|
-
for (const key in schema.shape) {
|
|
113
|
-
const fieldSchema = schema.shape[key];
|
|
114
|
-
newShape[key] = ZodOptional$2.create(deepPartialify(fieldSchema));
|
|
115
|
-
}
|
|
116
|
-
return new ZodObject$1({
|
|
117
|
-
...schema._def,
|
|
118
|
-
shape: () => newShape
|
|
119
|
-
});
|
|
120
|
-
} else if (schema instanceof ZodArray$1) return new ZodArray$1({
|
|
121
|
-
...schema._def,
|
|
122
|
-
type: deepPartialify(schema.element)
|
|
123
|
-
});else if (schema instanceof ZodOptional$2) return ZodOptional$2.create(deepPartialify(schema.unwrap()));else if (schema instanceof ZodNullable$1) return ZodNullable$1.create(deepPartialify(schema.unwrap()));else if (schema instanceof ZodTuple) return ZodTuple.create(schema.items.map(item => deepPartialify(item)));else return schema;
|
|
124
|
-
}
|
|
125
|
-
function mergeValues$1(a, b) {
|
|
126
|
-
const aType = getParsedType(a);
|
|
127
|
-
const bType = getParsedType(b);
|
|
128
|
-
if (a === b) return {
|
|
129
|
-
valid: true,
|
|
130
|
-
data: a
|
|
131
|
-
};else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
|
|
132
|
-
const bKeys = util.objectKeys(b);
|
|
133
|
-
const sharedKeys = util.objectKeys(a).filter(key => bKeys.indexOf(key) !== -1);
|
|
134
|
-
const newObj = {
|
|
135
|
-
...a,
|
|
136
|
-
...b
|
|
137
|
-
};
|
|
138
|
-
for (const key of sharedKeys) {
|
|
139
|
-
const sharedValue = mergeValues$1(a[key], b[key]);
|
|
140
|
-
if (!sharedValue.valid) return {
|
|
141
|
-
valid: false
|
|
142
|
-
};
|
|
143
|
-
newObj[key] = sharedValue.data;
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
146
|
-
valid: true,
|
|
147
|
-
data: newObj
|
|
148
|
-
};
|
|
149
|
-
} else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
|
|
150
|
-
if (a.length !== b.length) return {
|
|
151
|
-
valid: false
|
|
152
|
-
};
|
|
153
|
-
const newArray = [];
|
|
154
|
-
for (let index = 0; index < a.length; index++) {
|
|
155
|
-
const itemA = a[index];
|
|
156
|
-
const itemB = b[index];
|
|
157
|
-
const sharedValue = mergeValues$1(itemA, itemB);
|
|
158
|
-
if (!sharedValue.valid) return {
|
|
159
|
-
valid: false
|
|
160
|
-
};
|
|
161
|
-
newArray.push(sharedValue.data);
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
valid: true,
|
|
165
|
-
data: newArray
|
|
166
|
-
};
|
|
167
|
-
} else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) return {
|
|
168
|
-
valid: true,
|
|
169
|
-
data: a
|
|
170
|
-
};else return {
|
|
171
|
-
valid: false
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
function createZodEnum(values, params) {
|
|
175
|
-
return new ZodEnum$1({
|
|
176
|
-
values,
|
|
177
|
-
typeName: ZodFirstPartyTypeKind.ZodEnum,
|
|
178
|
-
...processCreateParams(params)
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
function $constructor(name, initializer, params) {
|
|
182
|
-
function init(inst, def) {
|
|
183
|
-
if (!inst._zod) Object.defineProperty(inst, "_zod", {
|
|
184
|
-
value: {
|
|
185
|
-
def,
|
|
186
|
-
constr: _,
|
|
187
|
-
traits: /* @__PURE__ */new Set()
|
|
188
|
-
},
|
|
189
|
-
enumerable: false
|
|
190
|
-
});
|
|
191
|
-
if (inst._zod.traits.has(name)) return;
|
|
192
|
-
inst._zod.traits.add(name);
|
|
193
|
-
initializer(inst, def);
|
|
194
|
-
const proto = _.prototype;
|
|
195
|
-
const keys = Object.keys(proto);
|
|
196
|
-
for (let i = 0; i < keys.length; i++) {
|
|
197
|
-
const k = keys[i];
|
|
198
|
-
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
const Parent = params?.Parent ?? Object;
|
|
202
|
-
class Definition extends Parent {}
|
|
203
|
-
Object.defineProperty(Definition, "name", {
|
|
204
|
-
value: name
|
|
205
|
-
});
|
|
206
|
-
function _(def) {
|
|
207
|
-
var _a;
|
|
208
|
-
const inst = params?.Parent ? new Definition() : this;
|
|
209
|
-
init(inst, def);
|
|
210
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
211
|
-
for (const fn of inst._zod.deferred) fn();
|
|
212
|
-
return inst;
|
|
213
|
-
}
|
|
214
|
-
Object.defineProperty(_, "init", {
|
|
215
|
-
value: init
|
|
216
|
-
});
|
|
217
|
-
Object.defineProperty(_, Symbol.hasInstance, {
|
|
218
|
-
value: inst => {
|
|
219
|
-
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
220
|
-
return inst?._zod?.traits?.has(name);
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
Object.defineProperty(_, "name", {
|
|
224
|
-
value: name
|
|
225
|
-
});
|
|
226
|
-
return _;
|
|
227
|
-
}
|
|
228
|
-
function config(newConfig) {
|
|
229
|
-
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
230
|
-
return globalConfig;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
//#endregion
|
|
234
|
-
//#region ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/util.js
|
|
235
|
-
function getEnumValues(entries) {
|
|
236
|
-
const numericValues = Object.values(entries).filter(v => typeof v === "number");
|
|
237
|
-
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
238
|
-
}
|
|
239
|
-
function jsonStringifyReplacer(_, value) {
|
|
240
|
-
if (typeof value === "bigint") return value.toString();
|
|
241
|
-
return value;
|
|
242
|
-
}
|
|
243
|
-
function cached(getter) {
|
|
244
|
-
return {
|
|
245
|
-
get value() {
|
|
246
|
-
{
|
|
247
|
-
const value = getter();
|
|
248
|
-
Object.defineProperty(this, "value", {
|
|
249
|
-
value
|
|
250
|
-
});
|
|
251
|
-
return value;
|
|
252
|
-
}
|
|
253
|
-
throw new Error("cached value already set");
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
function nullish(input) {
|
|
258
|
-
return input === null || input === void 0;
|
|
259
|
-
}
|
|
260
|
-
function cleanRegex(source) {
|
|
261
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
262
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
263
|
-
return source.slice(start, end);
|
|
264
|
-
}
|
|
265
|
-
function floatSafeRemainder(val, step) {
|
|
266
|
-
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
267
|
-
const stepString = step.toString();
|
|
268
|
-
let stepDecCount = (stepString.split(".")[1] || "").length;
|
|
269
|
-
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
|
|
270
|
-
const match = stepString.match(/\d?e-(\d?)/);
|
|
271
|
-
if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
|
|
272
|
-
}
|
|
273
|
-
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
274
|
-
return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
|
|
275
|
-
}
|
|
276
|
-
function defineLazy(object, key, getter) {
|
|
277
|
-
let value = void 0;
|
|
278
|
-
Object.defineProperty(object, key, {
|
|
279
|
-
get() {
|
|
280
|
-
if (value === EVALUATING) return;
|
|
281
|
-
if (value === void 0) {
|
|
282
|
-
value = EVALUATING;
|
|
283
|
-
value = getter();
|
|
284
|
-
}
|
|
285
|
-
return value;
|
|
286
|
-
},
|
|
287
|
-
set(v) {
|
|
288
|
-
Object.defineProperty(object, key, {
|
|
289
|
-
value: v
|
|
290
|
-
});
|
|
291
|
-
},
|
|
292
|
-
configurable: true
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
function assignProp(target, prop, value) {
|
|
296
|
-
Object.defineProperty(target, prop, {
|
|
297
|
-
value,
|
|
298
|
-
writable: true,
|
|
299
|
-
enumerable: true,
|
|
300
|
-
configurable: true
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
function mergeDefs(...defs) {
|
|
304
|
-
const mergedDescriptors = {};
|
|
305
|
-
for (const def of defs) Object.assign(mergedDescriptors, Object.getOwnPropertyDescriptors(def));
|
|
306
|
-
return Object.defineProperties({}, mergedDescriptors);
|
|
307
|
-
}
|
|
308
|
-
function esc(str) {
|
|
309
|
-
return JSON.stringify(str);
|
|
310
|
-
}
|
|
311
|
-
function slugify(input) {
|
|
312
|
-
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
313
|
-
}
|
|
314
|
-
function isObject(data) {
|
|
315
|
-
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
316
|
-
}
|
|
317
|
-
function isPlainObject$1(o) {
|
|
318
|
-
if (isObject(o) === false) return false;
|
|
319
|
-
const ctor = o.constructor;
|
|
320
|
-
if (ctor === void 0) return true;
|
|
321
|
-
if (typeof ctor !== "function") return true;
|
|
322
|
-
const prot = ctor.prototype;
|
|
323
|
-
if (isObject(prot) === false) return false;
|
|
324
|
-
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
325
|
-
return true;
|
|
326
|
-
}
|
|
327
|
-
function shallowClone(o) {
|
|
328
|
-
if (isPlainObject$1(o)) return {
|
|
329
|
-
...o
|
|
330
|
-
};
|
|
331
|
-
if (Array.isArray(o)) return [...o];
|
|
332
|
-
return o;
|
|
333
|
-
}
|
|
334
|
-
function escapeRegex(str) {
|
|
335
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
336
|
-
}
|
|
337
|
-
function clone(inst, def, params) {
|
|
338
|
-
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
339
|
-
if (!def || params?.parent) cl._zod.parent = inst;
|
|
340
|
-
return cl;
|
|
341
|
-
}
|
|
342
|
-
function normalizeParams(_params) {
|
|
343
|
-
const params = _params;
|
|
344
|
-
if (!params) return {};
|
|
345
|
-
if (typeof params === "string") return {
|
|
346
|
-
error: () => params
|
|
347
|
-
};
|
|
348
|
-
if (params?.message !== void 0) {
|
|
349
|
-
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
|
350
|
-
params.error = params.message;
|
|
351
|
-
}
|
|
352
|
-
delete params.message;
|
|
353
|
-
if (typeof params.error === "string") return {
|
|
354
|
-
...params,
|
|
355
|
-
error: () => params.error
|
|
356
|
-
};
|
|
357
|
-
return params;
|
|
358
|
-
}
|
|
359
|
-
function optionalKeys(shape) {
|
|
360
|
-
return Object.keys(shape).filter(k => {
|
|
361
|
-
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
function pick(schema, mask) {
|
|
365
|
-
const currDef = schema._zod.def;
|
|
366
|
-
const checks = currDef.checks;
|
|
367
|
-
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
368
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
369
|
-
get shape() {
|
|
370
|
-
const newShape = {};
|
|
371
|
-
for (const key in mask) {
|
|
372
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
373
|
-
if (!mask[key]) continue;
|
|
374
|
-
newShape[key] = currDef.shape[key];
|
|
375
|
-
}
|
|
376
|
-
assignProp(this, "shape", newShape);
|
|
377
|
-
return newShape;
|
|
378
|
-
},
|
|
379
|
-
checks: []
|
|
380
|
-
}));
|
|
381
|
-
}
|
|
382
|
-
function omit(schema, mask) {
|
|
383
|
-
const currDef = schema._zod.def;
|
|
384
|
-
const checks = currDef.checks;
|
|
385
|
-
if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
386
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
387
|
-
get shape() {
|
|
388
|
-
const newShape = {
|
|
389
|
-
...schema._zod.def.shape
|
|
390
|
-
};
|
|
391
|
-
for (const key in mask) {
|
|
392
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
393
|
-
if (!mask[key]) continue;
|
|
394
|
-
delete newShape[key];
|
|
395
|
-
}
|
|
396
|
-
assignProp(this, "shape", newShape);
|
|
397
|
-
return newShape;
|
|
398
|
-
},
|
|
399
|
-
checks: []
|
|
400
|
-
}));
|
|
401
|
-
}
|
|
402
|
-
function extend(schema, shape) {
|
|
403
|
-
if (!isPlainObject$1(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
404
|
-
const checks = schema._zod.def.checks;
|
|
405
|
-
if (checks && checks.length > 0) {
|
|
406
|
-
const existingShape = schema._zod.def.shape;
|
|
407
|
-
for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
408
|
-
}
|
|
409
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
410
|
-
get shape() {
|
|
411
|
-
const _shape = {
|
|
412
|
-
...schema._zod.def.shape,
|
|
413
|
-
...shape
|
|
414
|
-
};
|
|
415
|
-
assignProp(this, "shape", _shape);
|
|
416
|
-
return _shape;
|
|
417
|
-
}
|
|
418
|
-
}));
|
|
419
|
-
}
|
|
420
|
-
function safeExtend(schema, shape) {
|
|
421
|
-
if (!isPlainObject$1(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
422
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
423
|
-
get shape() {
|
|
424
|
-
const _shape = {
|
|
425
|
-
...schema._zod.def.shape,
|
|
426
|
-
...shape
|
|
427
|
-
};
|
|
428
|
-
assignProp(this, "shape", _shape);
|
|
429
|
-
return _shape;
|
|
430
|
-
}
|
|
431
|
-
}));
|
|
432
|
-
}
|
|
433
|
-
function merge(a, b) {
|
|
434
|
-
return clone(a, mergeDefs(a._zod.def, {
|
|
435
|
-
get shape() {
|
|
436
|
-
const _shape = {
|
|
437
|
-
...a._zod.def.shape,
|
|
438
|
-
...b._zod.def.shape
|
|
439
|
-
};
|
|
440
|
-
assignProp(this, "shape", _shape);
|
|
441
|
-
return _shape;
|
|
442
|
-
},
|
|
443
|
-
get catchall() {
|
|
444
|
-
return b._zod.def.catchall;
|
|
445
|
-
},
|
|
446
|
-
checks: []
|
|
447
|
-
}));
|
|
448
|
-
}
|
|
449
|
-
function partial(Class, schema, mask) {
|
|
450
|
-
const checks = schema._zod.def.checks;
|
|
451
|
-
if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
452
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
453
|
-
get shape() {
|
|
454
|
-
const oldShape = schema._zod.def.shape;
|
|
455
|
-
const shape = {
|
|
456
|
-
...oldShape
|
|
457
|
-
};
|
|
458
|
-
if (mask) for (const key in mask) {
|
|
459
|
-
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
460
|
-
if (!mask[key]) continue;
|
|
461
|
-
shape[key] = Class ? new Class({
|
|
462
|
-
type: "optional",
|
|
463
|
-
innerType: oldShape[key]
|
|
464
|
-
}) : oldShape[key];
|
|
465
|
-
} else for (const key in oldShape) shape[key] = Class ? new Class({
|
|
466
|
-
type: "optional",
|
|
467
|
-
innerType: oldShape[key]
|
|
468
|
-
}) : oldShape[key];
|
|
469
|
-
assignProp(this, "shape", shape);
|
|
470
|
-
return shape;
|
|
471
|
-
},
|
|
472
|
-
checks: []
|
|
473
|
-
}));
|
|
474
|
-
}
|
|
475
|
-
function required(Class, schema, mask) {
|
|
476
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
477
|
-
get shape() {
|
|
478
|
-
const oldShape = schema._zod.def.shape;
|
|
479
|
-
const shape = {
|
|
480
|
-
...oldShape
|
|
481
|
-
};
|
|
482
|
-
if (mask) for (const key in mask) {
|
|
483
|
-
if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
484
|
-
if (!mask[key]) continue;
|
|
485
|
-
shape[key] = new Class({
|
|
486
|
-
type: "nonoptional",
|
|
487
|
-
innerType: oldShape[key]
|
|
488
|
-
});
|
|
489
|
-
} else for (const key in oldShape) shape[key] = new Class({
|
|
490
|
-
type: "nonoptional",
|
|
491
|
-
innerType: oldShape[key]
|
|
492
|
-
});
|
|
493
|
-
assignProp(this, "shape", shape);
|
|
494
|
-
return shape;
|
|
495
|
-
}
|
|
496
|
-
}));
|
|
497
|
-
}
|
|
498
|
-
function aborted(x, startIndex = 0) {
|
|
499
|
-
if (x.aborted === true) return true;
|
|
500
|
-
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
|
|
501
|
-
return false;
|
|
502
|
-
}
|
|
503
|
-
function prefixIssues(path, issues) {
|
|
504
|
-
return issues.map(iss => {
|
|
505
|
-
var _a;
|
|
506
|
-
(_a = iss).path ?? (_a.path = []);
|
|
507
|
-
iss.path.unshift(path);
|
|
508
|
-
return iss;
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
function unwrapMessage(message) {
|
|
512
|
-
return typeof message === "string" ? message : message?.message;
|
|
513
|
-
}
|
|
514
|
-
function finalizeIssue(iss, ctx, config) {
|
|
515
|
-
const full = {
|
|
516
|
-
...iss,
|
|
517
|
-
path: iss.path ?? []
|
|
518
|
-
};
|
|
519
|
-
if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
|
520
|
-
delete full.inst;
|
|
521
|
-
delete full.continue;
|
|
522
|
-
if (!ctx?.reportInput) delete full.input;
|
|
523
|
-
return full;
|
|
524
|
-
}
|
|
525
|
-
function getLengthableOrigin(input) {
|
|
526
|
-
if (Array.isArray(input)) return "array";
|
|
527
|
-
if (typeof input === "string") return "string";
|
|
528
|
-
return "unknown";
|
|
529
|
-
}
|
|
530
|
-
function issue(...args) {
|
|
531
|
-
const [iss, input, inst] = args;
|
|
532
|
-
if (typeof iss === "string") return {
|
|
533
|
-
message: iss,
|
|
534
|
-
code: "custom",
|
|
535
|
-
input,
|
|
536
|
-
inst
|
|
537
|
-
};
|
|
538
|
-
return {
|
|
539
|
-
...iss
|
|
540
|
-
};
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
//#endregion
|
|
544
|
-
//#region ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/errors.js
|
|
545
|
-
|
|
546
|
-
function flattenError(error, mapper = issue => issue.message) {
|
|
547
|
-
const fieldErrors = {};
|
|
548
|
-
const formErrors = [];
|
|
549
|
-
for (const sub of error.issues) if (sub.path.length > 0) {
|
|
550
|
-
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
551
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
552
|
-
} else formErrors.push(mapper(sub));
|
|
553
|
-
return {
|
|
554
|
-
formErrors,
|
|
555
|
-
fieldErrors
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
function formatError(error, mapper = issue => issue.message) {
|
|
559
|
-
const fieldErrors = {
|
|
560
|
-
_errors: []
|
|
561
|
-
};
|
|
562
|
-
const processError = error => {
|
|
563
|
-
for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map(issues => processError({
|
|
564
|
-
issues
|
|
565
|
-
}));else if (issue.code === "invalid_key") processError({
|
|
566
|
-
issues: issue.issues
|
|
567
|
-
});else if (issue.code === "invalid_element") processError({
|
|
568
|
-
issues: issue.issues
|
|
569
|
-
});else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));else {
|
|
570
|
-
let curr = fieldErrors;
|
|
571
|
-
let i = 0;
|
|
572
|
-
while (i < issue.path.length) {
|
|
573
|
-
const el = issue.path[i];
|
|
574
|
-
if (!(i === issue.path.length - 1)) curr[el] = curr[el] || {
|
|
575
|
-
_errors: []
|
|
576
|
-
};else {
|
|
577
|
-
curr[el] = curr[el] || {
|
|
578
|
-
_errors: []
|
|
579
|
-
};
|
|
580
|
-
curr[el]._errors.push(mapper(issue));
|
|
581
|
-
}
|
|
582
|
-
curr = curr[el];
|
|
583
|
-
i++;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
};
|
|
587
|
-
processError(error);
|
|
588
|
-
return fieldErrors;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
//#endregion
|
|
592
|
-
//#region ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/parse.js
|
|
593
|
-
|
|
594
|
-
function emoji() {
|
|
595
|
-
return new RegExp(_emoji$1, "u");
|
|
596
|
-
}
|
|
597
|
-
function timeSource(args) {
|
|
598
|
-
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
599
|
-
return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
600
|
-
}
|
|
601
|
-
function time$1(args) {
|
|
602
|
-
return new RegExp(`^${timeSource(args)}$`);
|
|
603
|
-
}
|
|
604
|
-
function datetime$1(args) {
|
|
605
|
-
const time = timeSource({
|
|
606
|
-
precision: args.precision
|
|
607
|
-
});
|
|
608
|
-
const opts = ["Z"];
|
|
609
|
-
if (args.local) opts.push("");
|
|
610
|
-
if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
611
|
-
const timeRegex = `${time}(?:${opts.join("|")})`;
|
|
612
|
-
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
613
|
-
}
|
|
614
|
-
function isValidBase64(data) {
|
|
615
|
-
if (data === "") return true;
|
|
616
|
-
if (data.length % 4 !== 0) return false;
|
|
617
|
-
try {
|
|
618
|
-
atob(data);
|
|
619
|
-
return true;
|
|
620
|
-
} catch {
|
|
621
|
-
return false;
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
function isValidBase64URL(data) {
|
|
625
|
-
if (!base64url.test(data)) return false;
|
|
626
|
-
const base64 = data.replace(/[-_]/g, c => c === "-" ? "+" : "/");
|
|
627
|
-
return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
|
|
628
|
-
}
|
|
629
|
-
function isValidJWT(token, algorithm = null) {
|
|
630
|
-
try {
|
|
631
|
-
const tokensParts = token.split(".");
|
|
632
|
-
if (tokensParts.length !== 3) return false;
|
|
633
|
-
const [header] = tokensParts;
|
|
634
|
-
if (!header) return false;
|
|
635
|
-
const parsedHeader = JSON.parse(atob(header));
|
|
636
|
-
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
|
|
637
|
-
if (!parsedHeader.alg) return false;
|
|
638
|
-
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
|
|
639
|
-
return true;
|
|
640
|
-
} catch {
|
|
641
|
-
return false;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
function handleArrayResult(result, final, index) {
|
|
645
|
-
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
646
|
-
final.value[index] = result.value;
|
|
647
|
-
}
|
|
648
|
-
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
649
|
-
if (result.issues.length) {
|
|
650
|
-
if (isOptionalOut && !(key in input)) return;
|
|
651
|
-
final.issues.push(...prefixIssues(key, result.issues));
|
|
652
|
-
}
|
|
653
|
-
if (result.value === void 0) {
|
|
654
|
-
if (key in input) final.value[key] = void 0;
|
|
655
|
-
} else final.value[key] = result.value;
|
|
656
|
-
}
|
|
657
|
-
function normalizeDef(def) {
|
|
658
|
-
const keys = Object.keys(def.shape);
|
|
659
|
-
for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
660
|
-
const okeys = optionalKeys(def.shape);
|
|
661
|
-
return {
|
|
662
|
-
...def,
|
|
663
|
-
keys,
|
|
664
|
-
keySet: new Set(keys),
|
|
665
|
-
numKeys: keys.length,
|
|
666
|
-
optionalKeys: new Set(okeys)
|
|
667
|
-
};
|
|
668
|
-
}
|
|
669
|
-
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
670
|
-
const unrecognized = [];
|
|
671
|
-
const keySet = def.keySet;
|
|
672
|
-
const _catchall = def.catchall._zod;
|
|
673
|
-
const t = _catchall.def.type;
|
|
674
|
-
const isOptionalOut = _catchall.optout === "optional";
|
|
675
|
-
for (const key in input) {
|
|
676
|
-
if (keySet.has(key)) continue;
|
|
677
|
-
if (t === "never") {
|
|
678
|
-
unrecognized.push(key);
|
|
679
|
-
continue;
|
|
680
|
-
}
|
|
681
|
-
const r = _catchall.run({
|
|
682
|
-
value: input[key],
|
|
683
|
-
issues: []
|
|
684
|
-
}, ctx);
|
|
685
|
-
if (r instanceof Promise) proms.push(r.then(r => handlePropertyResult(r, payload, key, input, isOptionalOut)));else handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
686
|
-
}
|
|
687
|
-
if (unrecognized.length) payload.issues.push({
|
|
688
|
-
code: "unrecognized_keys",
|
|
689
|
-
keys: unrecognized,
|
|
690
|
-
input,
|
|
691
|
-
inst
|
|
692
|
-
});
|
|
693
|
-
if (!proms.length) return payload;
|
|
694
|
-
return Promise.all(proms).then(() => {
|
|
695
|
-
return payload;
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
|
-
function handleUnionResults(results, final, inst, ctx) {
|
|
699
|
-
for (const result of results) if (result.issues.length === 0) {
|
|
700
|
-
final.value = result.value;
|
|
701
|
-
return final;
|
|
702
|
-
}
|
|
703
|
-
const nonaborted = results.filter(r => !aborted(r));
|
|
704
|
-
if (nonaborted.length === 1) {
|
|
705
|
-
final.value = nonaborted[0].value;
|
|
706
|
-
return nonaborted[0];
|
|
707
|
-
}
|
|
708
|
-
final.issues.push({
|
|
709
|
-
code: "invalid_union",
|
|
710
|
-
input: final.value,
|
|
711
|
-
inst,
|
|
712
|
-
errors: results.map(result => result.issues.map(iss => finalizeIssue(iss, ctx, config())))
|
|
713
|
-
});
|
|
714
|
-
return final;
|
|
715
|
-
}
|
|
716
|
-
function mergeValues(a, b) {
|
|
717
|
-
if (a === b) return {
|
|
718
|
-
valid: true,
|
|
719
|
-
data: a
|
|
720
|
-
};
|
|
721
|
-
if (a instanceof Date && b instanceof Date && +a === +b) return {
|
|
722
|
-
valid: true,
|
|
723
|
-
data: a
|
|
724
|
-
};
|
|
725
|
-
if (isPlainObject$1(a) && isPlainObject$1(b)) {
|
|
726
|
-
const bKeys = Object.keys(b);
|
|
727
|
-
const sharedKeys = Object.keys(a).filter(key => bKeys.indexOf(key) !== -1);
|
|
728
|
-
const newObj = {
|
|
729
|
-
...a,
|
|
730
|
-
...b
|
|
731
|
-
};
|
|
732
|
-
for (const key of sharedKeys) {
|
|
733
|
-
const sharedValue = mergeValues(a[key], b[key]);
|
|
734
|
-
if (!sharedValue.valid) return {
|
|
735
|
-
valid: false,
|
|
736
|
-
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
|
|
737
|
-
};
|
|
738
|
-
newObj[key] = sharedValue.data;
|
|
739
|
-
}
|
|
740
|
-
return {
|
|
741
|
-
valid: true,
|
|
742
|
-
data: newObj
|
|
743
|
-
};
|
|
744
|
-
}
|
|
745
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
746
|
-
if (a.length !== b.length) return {
|
|
747
|
-
valid: false,
|
|
748
|
-
mergeErrorPath: []
|
|
749
|
-
};
|
|
750
|
-
const newArray = [];
|
|
751
|
-
for (let index = 0; index < a.length; index++) {
|
|
752
|
-
const itemA = a[index];
|
|
753
|
-
const itemB = b[index];
|
|
754
|
-
const sharedValue = mergeValues(itemA, itemB);
|
|
755
|
-
if (!sharedValue.valid) return {
|
|
756
|
-
valid: false,
|
|
757
|
-
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
758
|
-
};
|
|
759
|
-
newArray.push(sharedValue.data);
|
|
760
|
-
}
|
|
761
|
-
return {
|
|
762
|
-
valid: true,
|
|
763
|
-
data: newArray
|
|
764
|
-
};
|
|
765
|
-
}
|
|
766
|
-
return {
|
|
767
|
-
valid: false,
|
|
768
|
-
mergeErrorPath: []
|
|
769
|
-
};
|
|
770
|
-
}
|
|
771
|
-
function handleIntersectionResults(result, left, right) {
|
|
772
|
-
const unrecKeys = /* @__PURE__ */new Map();
|
|
773
|
-
let unrecIssue;
|
|
774
|
-
for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
|
|
775
|
-
unrecIssue ?? (unrecIssue = iss);
|
|
776
|
-
for (const k of iss.keys) {
|
|
777
|
-
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
778
|
-
unrecKeys.get(k).l = true;
|
|
779
|
-
}
|
|
780
|
-
} else result.issues.push(iss);
|
|
781
|
-
for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
|
|
782
|
-
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
783
|
-
unrecKeys.get(k).r = true;
|
|
784
|
-
} else result.issues.push(iss);
|
|
785
|
-
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
786
|
-
if (bothKeys.length && unrecIssue) result.issues.push({
|
|
787
|
-
...unrecIssue,
|
|
788
|
-
keys: bothKeys
|
|
789
|
-
});
|
|
790
|
-
if (aborted(result)) return result;
|
|
791
|
-
const merged = mergeValues(left.value, right.value);
|
|
792
|
-
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
793
|
-
result.value = merged.data;
|
|
794
|
-
return result;
|
|
795
|
-
}
|
|
796
|
-
function handleOptionalResult(result, input) {
|
|
797
|
-
if (result.issues.length && input === void 0) return {
|
|
798
|
-
issues: [],
|
|
799
|
-
value: void 0
|
|
800
|
-
};
|
|
801
|
-
return result;
|
|
802
|
-
}
|
|
803
|
-
function handleDefaultResult(payload, def) {
|
|
804
|
-
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
805
|
-
return payload;
|
|
806
|
-
}
|
|
807
|
-
function handleNonOptionalResult(payload, inst) {
|
|
808
|
-
if (!payload.issues.length && payload.value === void 0) payload.issues.push({
|
|
809
|
-
code: "invalid_type",
|
|
810
|
-
expected: "nonoptional",
|
|
811
|
-
input: payload.value,
|
|
812
|
-
inst
|
|
813
|
-
});
|
|
814
|
-
return payload;
|
|
815
|
-
}
|
|
816
|
-
function handlePipeResult(left, next, ctx) {
|
|
817
|
-
if (left.issues.length) {
|
|
818
|
-
left.aborted = true;
|
|
819
|
-
return left;
|
|
820
|
-
}
|
|
821
|
-
return next._zod.run({
|
|
822
|
-
value: left.value,
|
|
823
|
-
issues: left.issues
|
|
824
|
-
}, ctx);
|
|
825
|
-
}
|
|
826
|
-
function handleReadonlyResult(payload) {
|
|
827
|
-
payload.value = Object.freeze(payload.value);
|
|
828
|
-
return payload;
|
|
829
|
-
}
|
|
830
|
-
function handleRefineResult(result, payload, input, inst) {
|
|
831
|
-
if (!result) {
|
|
832
|
-
const _iss = {
|
|
833
|
-
code: "custom",
|
|
834
|
-
input,
|
|
835
|
-
inst,
|
|
836
|
-
path: [...(inst._zod.def.path ?? [])],
|
|
837
|
-
continue: !inst._zod.def.abort
|
|
838
|
-
};
|
|
839
|
-
if (inst._zod.def.params) _iss.params = inst._zod.def.params;
|
|
840
|
-
payload.issues.push(issue(_iss));
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
//#endregion
|
|
845
|
-
//#region ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/registries.js
|
|
846
|
-
|
|
847
|
-
function registry() {
|
|
848
|
-
return new $ZodRegistry();
|
|
849
|
-
}
|
|
850
|
-
//#endregion
|
|
851
|
-
//#region ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/api.js
|
|
852
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
853
|
-
function _string(Class, params) {
|
|
854
|
-
return new Class({
|
|
855
|
-
type: "string",
|
|
856
|
-
...normalizeParams(params)
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
860
|
-
function _email(Class, params) {
|
|
861
|
-
return new Class({
|
|
862
|
-
type: "string",
|
|
863
|
-
format: "email",
|
|
864
|
-
check: "string_format",
|
|
865
|
-
abort: false,
|
|
866
|
-
...normalizeParams(params)
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
870
|
-
function _guid(Class, params) {
|
|
871
|
-
return new Class({
|
|
872
|
-
type: "string",
|
|
873
|
-
format: "guid",
|
|
874
|
-
check: "string_format",
|
|
875
|
-
abort: false,
|
|
876
|
-
...normalizeParams(params)
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
880
|
-
function _uuid(Class, params) {
|
|
881
|
-
return new Class({
|
|
882
|
-
type: "string",
|
|
883
|
-
format: "uuid",
|
|
884
|
-
check: "string_format",
|
|
885
|
-
abort: false,
|
|
886
|
-
...normalizeParams(params)
|
|
887
|
-
});
|
|
888
|
-
}
|
|
889
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
890
|
-
function _uuidv4(Class, params) {
|
|
891
|
-
return new Class({
|
|
892
|
-
type: "string",
|
|
893
|
-
format: "uuid",
|
|
894
|
-
check: "string_format",
|
|
895
|
-
abort: false,
|
|
896
|
-
version: "v4",
|
|
897
|
-
...normalizeParams(params)
|
|
898
|
-
});
|
|
899
|
-
}
|
|
900
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
901
|
-
function _uuidv6(Class, params) {
|
|
902
|
-
return new Class({
|
|
903
|
-
type: "string",
|
|
904
|
-
format: "uuid",
|
|
905
|
-
check: "string_format",
|
|
906
|
-
abort: false,
|
|
907
|
-
version: "v6",
|
|
908
|
-
...normalizeParams(params)
|
|
909
|
-
});
|
|
910
|
-
}
|
|
911
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
912
|
-
function _uuidv7(Class, params) {
|
|
913
|
-
return new Class({
|
|
914
|
-
type: "string",
|
|
915
|
-
format: "uuid",
|
|
916
|
-
check: "string_format",
|
|
917
|
-
abort: false,
|
|
918
|
-
version: "v7",
|
|
919
|
-
...normalizeParams(params)
|
|
920
|
-
});
|
|
921
|
-
}
|
|
922
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
923
|
-
function _url(Class, params) {
|
|
924
|
-
return new Class({
|
|
925
|
-
type: "string",
|
|
926
|
-
format: "url",
|
|
927
|
-
check: "string_format",
|
|
928
|
-
abort: false,
|
|
929
|
-
...normalizeParams(params)
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
933
|
-
function _emoji(Class, params) {
|
|
934
|
-
return new Class({
|
|
935
|
-
type: "string",
|
|
936
|
-
format: "emoji",
|
|
937
|
-
check: "string_format",
|
|
938
|
-
abort: false,
|
|
939
|
-
...normalizeParams(params)
|
|
940
|
-
});
|
|
941
|
-
}
|
|
942
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
943
|
-
function _nanoid(Class, params) {
|
|
944
|
-
return new Class({
|
|
945
|
-
type: "string",
|
|
946
|
-
format: "nanoid",
|
|
947
|
-
check: "string_format",
|
|
948
|
-
abort: false,
|
|
949
|
-
...normalizeParams(params)
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
953
|
-
function _cuid(Class, params) {
|
|
954
|
-
return new Class({
|
|
955
|
-
type: "string",
|
|
956
|
-
format: "cuid",
|
|
957
|
-
check: "string_format",
|
|
958
|
-
abort: false,
|
|
959
|
-
...normalizeParams(params)
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
963
|
-
function _cuid2(Class, params) {
|
|
964
|
-
return new Class({
|
|
965
|
-
type: "string",
|
|
966
|
-
format: "cuid2",
|
|
967
|
-
check: "string_format",
|
|
968
|
-
abort: false,
|
|
969
|
-
...normalizeParams(params)
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
973
|
-
function _ulid(Class, params) {
|
|
974
|
-
return new Class({
|
|
975
|
-
type: "string",
|
|
976
|
-
format: "ulid",
|
|
977
|
-
check: "string_format",
|
|
978
|
-
abort: false,
|
|
979
|
-
...normalizeParams(params)
|
|
980
|
-
});
|
|
981
|
-
}
|
|
982
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
983
|
-
function _xid(Class, params) {
|
|
984
|
-
return new Class({
|
|
985
|
-
type: "string",
|
|
986
|
-
format: "xid",
|
|
987
|
-
check: "string_format",
|
|
988
|
-
abort: false,
|
|
989
|
-
...normalizeParams(params)
|
|
990
|
-
});
|
|
991
|
-
}
|
|
992
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
993
|
-
function _ksuid(Class, params) {
|
|
994
|
-
return new Class({
|
|
995
|
-
type: "string",
|
|
996
|
-
format: "ksuid",
|
|
997
|
-
check: "string_format",
|
|
998
|
-
abort: false,
|
|
999
|
-
...normalizeParams(params)
|
|
1000
|
-
});
|
|
1001
|
-
}
|
|
1002
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1003
|
-
function _ipv4(Class, params) {
|
|
1004
|
-
return new Class({
|
|
1005
|
-
type: "string",
|
|
1006
|
-
format: "ipv4",
|
|
1007
|
-
check: "string_format",
|
|
1008
|
-
abort: false,
|
|
1009
|
-
...normalizeParams(params)
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1013
|
-
function _ipv6(Class, params) {
|
|
1014
|
-
return new Class({
|
|
1015
|
-
type: "string",
|
|
1016
|
-
format: "ipv6",
|
|
1017
|
-
check: "string_format",
|
|
1018
|
-
abort: false,
|
|
1019
|
-
...normalizeParams(params)
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1023
|
-
function _cidrv4(Class, params) {
|
|
1024
|
-
return new Class({
|
|
1025
|
-
type: "string",
|
|
1026
|
-
format: "cidrv4",
|
|
1027
|
-
check: "string_format",
|
|
1028
|
-
abort: false,
|
|
1029
|
-
...normalizeParams(params)
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1033
|
-
function _cidrv6(Class, params) {
|
|
1034
|
-
return new Class({
|
|
1035
|
-
type: "string",
|
|
1036
|
-
format: "cidrv6",
|
|
1037
|
-
check: "string_format",
|
|
1038
|
-
abort: false,
|
|
1039
|
-
...normalizeParams(params)
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1043
|
-
function _base64(Class, params) {
|
|
1044
|
-
return new Class({
|
|
1045
|
-
type: "string",
|
|
1046
|
-
format: "base64",
|
|
1047
|
-
check: "string_format",
|
|
1048
|
-
abort: false,
|
|
1049
|
-
...normalizeParams(params)
|
|
1050
|
-
});
|
|
1051
|
-
}
|
|
1052
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1053
|
-
function _base64url(Class, params) {
|
|
1054
|
-
return new Class({
|
|
1055
|
-
type: "string",
|
|
1056
|
-
format: "base64url",
|
|
1057
|
-
check: "string_format",
|
|
1058
|
-
abort: false,
|
|
1059
|
-
...normalizeParams(params)
|
|
1060
|
-
});
|
|
1061
|
-
}
|
|
1062
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1063
|
-
function _e164(Class, params) {
|
|
1064
|
-
return new Class({
|
|
1065
|
-
type: "string",
|
|
1066
|
-
format: "e164",
|
|
1067
|
-
check: "string_format",
|
|
1068
|
-
abort: false,
|
|
1069
|
-
...normalizeParams(params)
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1073
|
-
function _jwt(Class, params) {
|
|
1074
|
-
return new Class({
|
|
1075
|
-
type: "string",
|
|
1076
|
-
format: "jwt",
|
|
1077
|
-
check: "string_format",
|
|
1078
|
-
abort: false,
|
|
1079
|
-
...normalizeParams(params)
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1083
|
-
function _isoDateTime(Class, params) {
|
|
1084
|
-
return new Class({
|
|
1085
|
-
type: "string",
|
|
1086
|
-
format: "datetime",
|
|
1087
|
-
check: "string_format",
|
|
1088
|
-
offset: false,
|
|
1089
|
-
local: false,
|
|
1090
|
-
precision: null,
|
|
1091
|
-
...normalizeParams(params)
|
|
1092
|
-
});
|
|
1093
|
-
}
|
|
1094
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1095
|
-
function _isoDate(Class, params) {
|
|
1096
|
-
return new Class({
|
|
1097
|
-
type: "string",
|
|
1098
|
-
format: "date",
|
|
1099
|
-
check: "string_format",
|
|
1100
|
-
...normalizeParams(params)
|
|
1101
|
-
});
|
|
1102
|
-
}
|
|
1103
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1104
|
-
function _isoTime(Class, params) {
|
|
1105
|
-
return new Class({
|
|
1106
|
-
type: "string",
|
|
1107
|
-
format: "time",
|
|
1108
|
-
check: "string_format",
|
|
1109
|
-
precision: null,
|
|
1110
|
-
...normalizeParams(params)
|
|
1111
|
-
});
|
|
1112
|
-
}
|
|
1113
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1114
|
-
function _isoDuration(Class, params) {
|
|
1115
|
-
return new Class({
|
|
1116
|
-
type: "string",
|
|
1117
|
-
format: "duration",
|
|
1118
|
-
check: "string_format",
|
|
1119
|
-
...normalizeParams(params)
|
|
1120
|
-
});
|
|
1121
|
-
}
|
|
1122
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1123
|
-
function _number(Class, params) {
|
|
1124
|
-
return new Class({
|
|
1125
|
-
type: "number",
|
|
1126
|
-
checks: [],
|
|
1127
|
-
...normalizeParams(params)
|
|
1128
|
-
});
|
|
1129
|
-
}
|
|
1130
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1131
|
-
function _int(Class, params) {
|
|
1132
|
-
return new Class({
|
|
1133
|
-
type: "number",
|
|
1134
|
-
check: "number_format",
|
|
1135
|
-
abort: false,
|
|
1136
|
-
format: "safeint",
|
|
1137
|
-
...normalizeParams(params)
|
|
1138
|
-
});
|
|
1139
|
-
}
|
|
1140
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1141
|
-
function _boolean(Class, params) {
|
|
1142
|
-
return new Class({
|
|
1143
|
-
type: "boolean",
|
|
1144
|
-
...normalizeParams(params)
|
|
1145
|
-
});
|
|
1146
|
-
}
|
|
1147
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1148
|
-
function _null$1(Class, params) {
|
|
1149
|
-
return new Class({
|
|
1150
|
-
type: "null",
|
|
1151
|
-
...normalizeParams(params)
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
1154
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1155
|
-
function _unknown(Class) {
|
|
1156
|
-
return new Class({
|
|
1157
|
-
type: "unknown"
|
|
1158
|
-
});
|
|
1159
|
-
}
|
|
1160
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1161
|
-
function _never(Class, params) {
|
|
1162
|
-
return new Class({
|
|
1163
|
-
type: "never",
|
|
1164
|
-
...normalizeParams(params)
|
|
1165
|
-
});
|
|
1166
|
-
}
|
|
1167
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1168
|
-
function _lt(value, params) {
|
|
1169
|
-
return new $ZodCheckLessThan({
|
|
1170
|
-
check: "less_than",
|
|
1171
|
-
...normalizeParams(params),
|
|
1172
|
-
value,
|
|
1173
|
-
inclusive: false
|
|
1174
|
-
});
|
|
1175
|
-
}
|
|
1176
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1177
|
-
function _lte(value, params) {
|
|
1178
|
-
return new $ZodCheckLessThan({
|
|
1179
|
-
check: "less_than",
|
|
1180
|
-
...normalizeParams(params),
|
|
1181
|
-
value,
|
|
1182
|
-
inclusive: true
|
|
1183
|
-
});
|
|
1184
|
-
}
|
|
1185
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1186
|
-
function _gt(value, params) {
|
|
1187
|
-
return new $ZodCheckGreaterThan({
|
|
1188
|
-
check: "greater_than",
|
|
1189
|
-
...normalizeParams(params),
|
|
1190
|
-
value,
|
|
1191
|
-
inclusive: false
|
|
1192
|
-
});
|
|
1193
|
-
}
|
|
1194
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1195
|
-
function _gte(value, params) {
|
|
1196
|
-
return new $ZodCheckGreaterThan({
|
|
1197
|
-
check: "greater_than",
|
|
1198
|
-
...normalizeParams(params),
|
|
1199
|
-
value,
|
|
1200
|
-
inclusive: true
|
|
1201
|
-
});
|
|
1202
|
-
}
|
|
1203
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1204
|
-
function _multipleOf(value, params) {
|
|
1205
|
-
return new $ZodCheckMultipleOf({
|
|
1206
|
-
check: "multiple_of",
|
|
1207
|
-
...normalizeParams(params),
|
|
1208
|
-
value
|
|
1209
|
-
});
|
|
1210
|
-
}
|
|
1211
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1212
|
-
function _maxLength(maximum, params) {
|
|
1213
|
-
return new $ZodCheckMaxLength({
|
|
1214
|
-
check: "max_length",
|
|
1215
|
-
...normalizeParams(params),
|
|
1216
|
-
maximum
|
|
1217
|
-
});
|
|
1218
|
-
}
|
|
1219
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1220
|
-
function _minLength(minimum, params) {
|
|
1221
|
-
return new $ZodCheckMinLength({
|
|
1222
|
-
check: "min_length",
|
|
1223
|
-
...normalizeParams(params),
|
|
1224
|
-
minimum
|
|
1225
|
-
});
|
|
1226
|
-
}
|
|
1227
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1228
|
-
function _length(length, params) {
|
|
1229
|
-
return new $ZodCheckLengthEquals({
|
|
1230
|
-
check: "length_equals",
|
|
1231
|
-
...normalizeParams(params),
|
|
1232
|
-
length
|
|
1233
|
-
});
|
|
1234
|
-
}
|
|
1235
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1236
|
-
function _regex(pattern, params) {
|
|
1237
|
-
return new $ZodCheckRegex({
|
|
1238
|
-
check: "string_format",
|
|
1239
|
-
format: "regex",
|
|
1240
|
-
...normalizeParams(params),
|
|
1241
|
-
pattern
|
|
1242
|
-
});
|
|
1243
|
-
}
|
|
1244
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1245
|
-
function _lowercase(params) {
|
|
1246
|
-
return new $ZodCheckLowerCase({
|
|
1247
|
-
check: "string_format",
|
|
1248
|
-
format: "lowercase",
|
|
1249
|
-
...normalizeParams(params)
|
|
1250
|
-
});
|
|
1251
|
-
}
|
|
1252
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1253
|
-
function _uppercase(params) {
|
|
1254
|
-
return new $ZodCheckUpperCase({
|
|
1255
|
-
check: "string_format",
|
|
1256
|
-
format: "uppercase",
|
|
1257
|
-
...normalizeParams(params)
|
|
1258
|
-
});
|
|
1259
|
-
}
|
|
1260
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1261
|
-
function _includes(includes, params) {
|
|
1262
|
-
return new $ZodCheckIncludes({
|
|
1263
|
-
check: "string_format",
|
|
1264
|
-
format: "includes",
|
|
1265
|
-
...normalizeParams(params),
|
|
1266
|
-
includes
|
|
1267
|
-
});
|
|
1268
|
-
}
|
|
1269
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1270
|
-
function _startsWith(prefix, params) {
|
|
1271
|
-
return new $ZodCheckStartsWith({
|
|
1272
|
-
check: "string_format",
|
|
1273
|
-
format: "starts_with",
|
|
1274
|
-
...normalizeParams(params),
|
|
1275
|
-
prefix
|
|
1276
|
-
});
|
|
1277
|
-
}
|
|
1278
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1279
|
-
function _endsWith(suffix, params) {
|
|
1280
|
-
return new $ZodCheckEndsWith({
|
|
1281
|
-
check: "string_format",
|
|
1282
|
-
format: "ends_with",
|
|
1283
|
-
...normalizeParams(params),
|
|
1284
|
-
suffix
|
|
1285
|
-
});
|
|
1286
|
-
}
|
|
1287
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1288
|
-
function _overwrite(tx) {
|
|
1289
|
-
return new $ZodCheckOverwrite({
|
|
1290
|
-
check: "overwrite",
|
|
1291
|
-
tx
|
|
1292
|
-
});
|
|
1293
|
-
}
|
|
1294
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1295
|
-
function _normalize(form) {
|
|
1296
|
-
return /* @__PURE__ */_overwrite(input => input.normalize(form));
|
|
1297
|
-
}
|
|
1298
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1299
|
-
function _trim() {
|
|
1300
|
-
return /* @__PURE__ */_overwrite(input => input.trim());
|
|
1301
|
-
}
|
|
1302
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1303
|
-
function _toLowerCase() {
|
|
1304
|
-
return /* @__PURE__ */_overwrite(input => input.toLowerCase());
|
|
1305
|
-
}
|
|
1306
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1307
|
-
function _toUpperCase() {
|
|
1308
|
-
return /* @__PURE__ */_overwrite(input => input.toUpperCase());
|
|
1309
|
-
}
|
|
1310
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1311
|
-
function _slugify() {
|
|
1312
|
-
return /* @__PURE__ */_overwrite(input => slugify(input));
|
|
1313
|
-
}
|
|
1314
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1315
|
-
function _array(Class, element, params) {
|
|
1316
|
-
return new Class({
|
|
1317
|
-
type: "array",
|
|
1318
|
-
element,
|
|
1319
|
-
...normalizeParams(params)
|
|
1320
|
-
});
|
|
1321
|
-
}
|
|
1322
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1323
|
-
function _custom(Class, fn, _params) {
|
|
1324
|
-
const norm = normalizeParams(_params);
|
|
1325
|
-
norm.abort ?? (norm.abort = true);
|
|
1326
|
-
return new Class({
|
|
1327
|
-
type: "custom",
|
|
1328
|
-
check: "custom",
|
|
1329
|
-
fn,
|
|
1330
|
-
...norm
|
|
1331
|
-
});
|
|
1332
|
-
}
|
|
1333
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1334
|
-
function _refine(Class, fn, _params) {
|
|
1335
|
-
return new Class({
|
|
1336
|
-
type: "custom",
|
|
1337
|
-
check: "custom",
|
|
1338
|
-
fn,
|
|
1339
|
-
...normalizeParams(_params)
|
|
1340
|
-
});
|
|
1341
|
-
}
|
|
1342
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1343
|
-
function _superRefine(fn) {
|
|
1344
|
-
const ch = /* @__PURE__ */_check(payload => {
|
|
1345
|
-
payload.addIssue = issue$2 => {
|
|
1346
|
-
if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));else {
|
|
1347
|
-
const _issue = issue$2;
|
|
1348
|
-
if (_issue.fatal) _issue.continue = false;
|
|
1349
|
-
_issue.code ?? (_issue.code = "custom");
|
|
1350
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
1351
|
-
_issue.inst ?? (_issue.inst = ch);
|
|
1352
|
-
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
1353
|
-
payload.issues.push(issue(_issue));
|
|
1354
|
-
}
|
|
1355
|
-
};
|
|
1356
|
-
return fn(payload.value, payload);
|
|
1357
|
-
});
|
|
1358
|
-
return ch;
|
|
1359
|
-
}
|
|
1360
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1361
|
-
function _check(fn, params) {
|
|
1362
|
-
const ch = new $ZodCheck({
|
|
1363
|
-
check: "custom",
|
|
1364
|
-
...normalizeParams(params)
|
|
1365
|
-
});
|
|
1366
|
-
ch._zod.check = fn;
|
|
1367
|
-
return ch;
|
|
1368
|
-
}
|
|
1369
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1370
|
-
function describe$2(description) {
|
|
1371
|
-
const ch = new $ZodCheck({
|
|
1372
|
-
check: "describe"
|
|
1373
|
-
});
|
|
1374
|
-
ch._zod.onattach = [inst => {
|
|
1375
|
-
const existing = globalRegistry.get(inst) ?? {};
|
|
1376
|
-
globalRegistry.add(inst, {
|
|
1377
|
-
...existing,
|
|
1378
|
-
description
|
|
1379
|
-
});
|
|
1380
|
-
}];
|
|
1381
|
-
ch._zod.check = () => {};
|
|
1382
|
-
return ch;
|
|
1383
|
-
}
|
|
1384
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1385
|
-
function meta$2(metadata) {
|
|
1386
|
-
const ch = new $ZodCheck({
|
|
1387
|
-
check: "meta"
|
|
1388
|
-
});
|
|
1389
|
-
ch._zod.onattach = [inst => {
|
|
1390
|
-
const existing = globalRegistry.get(inst) ?? {};
|
|
1391
|
-
globalRegistry.add(inst, {
|
|
1392
|
-
...existing,
|
|
1393
|
-
...metadata
|
|
1394
|
-
});
|
|
1395
|
-
}];
|
|
1396
|
-
ch._zod.check = () => {};
|
|
1397
|
-
return ch;
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
//#endregion
|
|
1401
|
-
//#region ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.js
|
|
1402
|
-
function initializeContext(params) {
|
|
1403
|
-
let target = params?.target ?? "draft-2020-12";
|
|
1404
|
-
if (target === "draft-4") target = "draft-04";
|
|
1405
|
-
if (target === "draft-7") target = "draft-07";
|
|
1406
|
-
return {
|
|
1407
|
-
processors: params.processors ?? {},
|
|
1408
|
-
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
1409
|
-
target,
|
|
1410
|
-
unrepresentable: params?.unrepresentable ?? "throw",
|
|
1411
|
-
override: params?.override ?? (() => {}),
|
|
1412
|
-
io: params?.io ?? "output",
|
|
1413
|
-
counter: 0,
|
|
1414
|
-
seen: /* @__PURE__ */new Map(),
|
|
1415
|
-
cycles: params?.cycles ?? "ref",
|
|
1416
|
-
reused: params?.reused ?? "inline",
|
|
1417
|
-
external: params?.external ?? void 0
|
|
1418
|
-
};
|
|
1419
|
-
}
|
|
1420
|
-
function process$2(schema, ctx, _params = {
|
|
1421
|
-
path: [],
|
|
1422
|
-
schemaPath: []
|
|
1423
|
-
}) {
|
|
1424
|
-
var _a;
|
|
1425
|
-
const def = schema._zod.def;
|
|
1426
|
-
const seen = ctx.seen.get(schema);
|
|
1427
|
-
if (seen) {
|
|
1428
|
-
seen.count++;
|
|
1429
|
-
if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
|
|
1430
|
-
return seen.schema;
|
|
1431
|
-
}
|
|
1432
|
-
const result = {
|
|
1433
|
-
schema: {},
|
|
1434
|
-
count: 1,
|
|
1435
|
-
cycle: void 0,
|
|
1436
|
-
path: _params.path
|
|
1437
|
-
};
|
|
1438
|
-
ctx.seen.set(schema, result);
|
|
1439
|
-
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
1440
|
-
if (overrideSchema) result.schema = overrideSchema;else {
|
|
1441
|
-
const params = {
|
|
1442
|
-
..._params,
|
|
1443
|
-
schemaPath: [..._params.schemaPath, schema],
|
|
1444
|
-
path: _params.path
|
|
1445
|
-
};
|
|
1446
|
-
if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);else {
|
|
1447
|
-
const _json = result.schema;
|
|
1448
|
-
const processor = ctx.processors[def.type];
|
|
1449
|
-
if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
1450
|
-
processor(schema, ctx, _json, params);
|
|
1451
|
-
}
|
|
1452
|
-
const parent = schema._zod.parent;
|
|
1453
|
-
if (parent) {
|
|
1454
|
-
if (!result.ref) result.ref = parent;
|
|
1455
|
-
process$2(parent, ctx, params);
|
|
1456
|
-
ctx.seen.get(parent).isParent = true;
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
|
-
const meta = ctx.metadataRegistry.get(schema);
|
|
1460
|
-
if (meta) Object.assign(result.schema, meta);
|
|
1461
|
-
if (ctx.io === "input" && isTransforming(schema)) {
|
|
1462
|
-
delete result.schema.examples;
|
|
1463
|
-
delete result.schema.default;
|
|
1464
|
-
}
|
|
1465
|
-
if (ctx.io === "input" && result.schema._prefault) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
1466
|
-
delete result.schema._prefault;
|
|
1467
|
-
return ctx.seen.get(schema).schema;
|
|
1468
|
-
}
|
|
1469
|
-
function extractDefs(ctx, schema) {
|
|
1470
|
-
const root = ctx.seen.get(schema);
|
|
1471
|
-
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
1472
|
-
const idToSchema = /* @__PURE__ */new Map();
|
|
1473
|
-
for (const entry of ctx.seen.entries()) {
|
|
1474
|
-
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
1475
|
-
if (id) {
|
|
1476
|
-
const existing = idToSchema.get(id);
|
|
1477
|
-
if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
1478
|
-
idToSchema.set(id, entry[0]);
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
const makeURI = entry => {
|
|
1482
|
-
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
1483
|
-
if (ctx.external) {
|
|
1484
|
-
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
1485
|
-
const uriGenerator = ctx.external.uri ?? (id => id);
|
|
1486
|
-
if (externalId) return {
|
|
1487
|
-
ref: uriGenerator(externalId)
|
|
1488
|
-
};
|
|
1489
|
-
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
1490
|
-
entry[1].defId = id;
|
|
1491
|
-
return {
|
|
1492
|
-
defId: id,
|
|
1493
|
-
ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
|
|
1494
|
-
};
|
|
1495
|
-
}
|
|
1496
|
-
if (entry[1] === root) return {
|
|
1497
|
-
ref: "#"
|
|
1498
|
-
};
|
|
1499
|
-
const defUriPrefix = `#/${defsSegment}/`;
|
|
1500
|
-
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
1501
|
-
return {
|
|
1502
|
-
defId,
|
|
1503
|
-
ref: defUriPrefix + defId
|
|
1504
|
-
};
|
|
1505
|
-
};
|
|
1506
|
-
const extractToDef = entry => {
|
|
1507
|
-
if (entry[1].schema.$ref) return;
|
|
1508
|
-
const seen = entry[1];
|
|
1509
|
-
const {
|
|
1510
|
-
ref,
|
|
1511
|
-
defId
|
|
1512
|
-
} = makeURI(entry);
|
|
1513
|
-
seen.def = {
|
|
1514
|
-
...seen.schema
|
|
1515
|
-
};
|
|
1516
|
-
if (defId) seen.defId = defId;
|
|
1517
|
-
const schema = seen.schema;
|
|
1518
|
-
for (const key in schema) delete schema[key];
|
|
1519
|
-
schema.$ref = ref;
|
|
1520
|
-
};
|
|
1521
|
-
if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
|
|
1522
|
-
const seen = entry[1];
|
|
1523
|
-
if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
|
|
1524
|
-
|
|
1525
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
1526
|
-
}
|
|
1527
|
-
for (const entry of ctx.seen.entries()) {
|
|
1528
|
-
const seen = entry[1];
|
|
1529
|
-
if (schema === entry[0]) {
|
|
1530
|
-
extractToDef(entry);
|
|
1531
|
-
continue;
|
|
1532
|
-
}
|
|
1533
|
-
if (ctx.external) {
|
|
1534
|
-
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
1535
|
-
if (schema !== entry[0] && ext) {
|
|
1536
|
-
extractToDef(entry);
|
|
1537
|
-
continue;
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
if (ctx.metadataRegistry.get(entry[0])?.id) {
|
|
1541
|
-
extractToDef(entry);
|
|
1542
|
-
continue;
|
|
1543
|
-
}
|
|
1544
|
-
if (seen.cycle) {
|
|
1545
|
-
extractToDef(entry);
|
|
1546
|
-
continue;
|
|
1547
|
-
}
|
|
1548
|
-
if (seen.count > 1) {
|
|
1549
|
-
if (ctx.reused === "ref") {
|
|
1550
|
-
extractToDef(entry);
|
|
1551
|
-
continue;
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
function finalize(ctx, schema) {
|
|
1557
|
-
const root = ctx.seen.get(schema);
|
|
1558
|
-
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
1559
|
-
const flattenRef = zodSchema => {
|
|
1560
|
-
const seen = ctx.seen.get(zodSchema);
|
|
1561
|
-
if (seen.ref === null) return;
|
|
1562
|
-
const schema = seen.def ?? seen.schema;
|
|
1563
|
-
const _cached = {
|
|
1564
|
-
...schema
|
|
1565
|
-
};
|
|
1566
|
-
const ref = seen.ref;
|
|
1567
|
-
seen.ref = null;
|
|
1568
|
-
if (ref) {
|
|
1569
|
-
flattenRef(ref);
|
|
1570
|
-
const refSeen = ctx.seen.get(ref);
|
|
1571
|
-
const refSchema = refSeen.schema;
|
|
1572
|
-
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
1573
|
-
schema.allOf = schema.allOf ?? [];
|
|
1574
|
-
schema.allOf.push(refSchema);
|
|
1575
|
-
} else Object.assign(schema, refSchema);
|
|
1576
|
-
Object.assign(schema, _cached);
|
|
1577
|
-
if (zodSchema._zod.parent === ref) for (const key in schema) {
|
|
1578
|
-
if (key === "$ref" || key === "allOf") continue;
|
|
1579
|
-
if (!(key in _cached)) delete schema[key];
|
|
1580
|
-
}
|
|
1581
|
-
if (refSchema.$ref && refSeen.def) for (const key in schema) {
|
|
1582
|
-
if (key === "$ref" || key === "allOf") continue;
|
|
1583
|
-
if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
const parent = zodSchema._zod.parent;
|
|
1587
|
-
if (parent && parent !== ref) {
|
|
1588
|
-
flattenRef(parent);
|
|
1589
|
-
const parentSeen = ctx.seen.get(parent);
|
|
1590
|
-
if (parentSeen?.schema.$ref) {
|
|
1591
|
-
schema.$ref = parentSeen.schema.$ref;
|
|
1592
|
-
if (parentSeen.def) for (const key in schema) {
|
|
1593
|
-
if (key === "$ref" || key === "allOf") continue;
|
|
1594
|
-
if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
ctx.override({
|
|
1599
|
-
zodSchema,
|
|
1600
|
-
jsonSchema: schema,
|
|
1601
|
-
path: seen.path ?? []
|
|
1602
|
-
});
|
|
1603
|
-
};
|
|
1604
|
-
for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
|
|
1605
|
-
const result = {};
|
|
1606
|
-
if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";else if (ctx.target === "openapi-3.0") {}
|
|
1607
|
-
if (ctx.external?.uri) {
|
|
1608
|
-
const id = ctx.external.registry.get(schema)?.id;
|
|
1609
|
-
if (!id) throw new Error("Schema is missing an `id` property");
|
|
1610
|
-
result.$id = ctx.external.uri(id);
|
|
1611
|
-
}
|
|
1612
|
-
Object.assign(result, root.def ?? root.schema);
|
|
1613
|
-
const defs = ctx.external?.defs ?? {};
|
|
1614
|
-
for (const entry of ctx.seen.entries()) {
|
|
1615
|
-
const seen = entry[1];
|
|
1616
|
-
if (seen.def && seen.defId) defs[seen.defId] = seen.def;
|
|
1617
|
-
}
|
|
1618
|
-
if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;else result.definitions = defs;
|
|
1619
|
-
try {
|
|
1620
|
-
const finalized = JSON.parse(JSON.stringify(result));
|
|
1621
|
-
Object.defineProperty(finalized, "~standard", {
|
|
1622
|
-
value: {
|
|
1623
|
-
...schema["~standard"],
|
|
1624
|
-
jsonSchema: {
|
|
1625
|
-
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
|
|
1626
|
-
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
|
|
1627
|
-
}
|
|
1628
|
-
},
|
|
1629
|
-
enumerable: false,
|
|
1630
|
-
writable: false
|
|
1631
|
-
});
|
|
1632
|
-
return finalized;
|
|
1633
|
-
} catch (_err) {
|
|
1634
|
-
throw new Error("Error converting schema to JSON.");
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
function isTransforming(_schema, _ctx) {
|
|
1638
|
-
const ctx = _ctx ?? {
|
|
1639
|
-
seen: /* @__PURE__ */new Set()
|
|
1640
|
-
};
|
|
1641
|
-
if (ctx.seen.has(_schema)) return false;
|
|
1642
|
-
ctx.seen.add(_schema);
|
|
1643
|
-
const def = _schema._zod.def;
|
|
1644
|
-
if (def.type === "transform") return true;
|
|
1645
|
-
if (def.type === "array") return isTransforming(def.element, ctx);
|
|
1646
|
-
if (def.type === "set") return isTransforming(def.valueType, ctx);
|
|
1647
|
-
if (def.type === "lazy") return isTransforming(def.getter(), ctx);
|
|
1648
|
-
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
|
|
1649
|
-
if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
1650
|
-
if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
1651
|
-
if (def.type === "pipe") return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
1652
|
-
if (def.type === "object") {
|
|
1653
|
-
for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
|
|
1654
|
-
return false;
|
|
1655
|
-
}
|
|
1656
|
-
if (def.type === "union") {
|
|
1657
|
-
for (const option of def.options) if (isTransforming(option, ctx)) return true;
|
|
1658
|
-
return false;
|
|
1659
|
-
}
|
|
1660
|
-
if (def.type === "tuple") {
|
|
1661
|
-
for (const item of def.items) if (isTransforming(item, ctx)) return true;
|
|
1662
|
-
if (def.rest && isTransforming(def.rest, ctx)) return true;
|
|
1663
|
-
return false;
|
|
1664
|
-
}
|
|
1665
|
-
return false;
|
|
1666
|
-
}
|
|
1667
|
-
/**
|
|
1668
|
-
* Creates a toJSONSchema method for a schema instance.
|
|
1669
|
-
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
|
1670
|
-
*/
|
|
1671
|
-
|
|
1672
|
-
function toJSONSchema(input, params) {
|
|
1673
|
-
if ("_idmap" in input) {
|
|
1674
|
-
const registry = input;
|
|
1675
|
-
const ctx = initializeContext({
|
|
1676
|
-
...params,
|
|
1677
|
-
processors: allProcessors
|
|
1678
|
-
});
|
|
1679
|
-
const defs = {};
|
|
1680
|
-
for (const entry of registry._idmap.entries()) {
|
|
1681
|
-
const [_, schema] = entry;
|
|
1682
|
-
process$2(schema, ctx);
|
|
1683
|
-
}
|
|
1684
|
-
const schemas = {};
|
|
1685
|
-
ctx.external = {
|
|
1686
|
-
registry,
|
|
1687
|
-
uri: params?.uri,
|
|
1688
|
-
defs
|
|
1689
|
-
};
|
|
1690
|
-
for (const entry of registry._idmap.entries()) {
|
|
1691
|
-
const [key, schema] = entry;
|
|
1692
|
-
extractDefs(ctx, schema);
|
|
1693
|
-
schemas[key] = finalize(ctx, schema);
|
|
1694
|
-
}
|
|
1695
|
-
if (Object.keys(defs).length > 0) schemas.__shared = {
|
|
1696
|
-
[ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs
|
|
1697
|
-
};
|
|
1698
|
-
return {
|
|
1699
|
-
schemas
|
|
1700
|
-
};
|
|
1701
|
-
}
|
|
1702
|
-
const ctx = initializeContext({
|
|
1703
|
-
...params,
|
|
1704
|
-
processors: allProcessors
|
|
1705
|
-
});
|
|
1706
|
-
process$2(input, ctx);
|
|
1707
|
-
extractDefs(ctx, input);
|
|
1708
|
-
return finalize(ctx, input);
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
|
-
//#endregion
|
|
1712
|
-
//#region ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/mini/schemas.js
|
|
1713
|
-
|
|
1714
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1715
|
-
function object$1(shape, params) {
|
|
1716
|
-
return new ZodMiniObject({
|
|
1717
|
-
type: "object",
|
|
1718
|
-
shape: shape ?? {},
|
|
1719
|
-
...normalizeParams(params)
|
|
1720
|
-
});
|
|
1721
|
-
}
|
|
1722
|
-
//#endregion
|
|
1723
|
-
//#region ../../node_modules/.bun/@modelcontextprotocol+sdk@1.27.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
1724
|
-
function isZ4Schema(s) {
|
|
1725
|
-
return !!s._zod;
|
|
1726
|
-
}
|
|
1727
|
-
function objectFromShape(shape) {
|
|
1728
|
-
const values = Object.values(shape);
|
|
1729
|
-
if (values.length === 0) return object$1({});
|
|
1730
|
-
const allV4 = values.every(isZ4Schema);
|
|
1731
|
-
const allV3 = values.every(s => !isZ4Schema(s));
|
|
1732
|
-
if (allV4) return object$1(shape);
|
|
1733
|
-
if (allV3) return objectType(shape);
|
|
1734
|
-
throw new Error("Mixed Zod versions detected in object shape.");
|
|
1735
|
-
}
|
|
1736
|
-
function safeParse$1(schema, data) {
|
|
1737
|
-
if (isZ4Schema(schema)) return safeParse$2(schema, data);
|
|
1738
|
-
return schema.safeParse(data);
|
|
1739
|
-
}
|
|
1740
|
-
async function safeParseAsync$1(schema, data) {
|
|
1741
|
-
if (isZ4Schema(schema)) return await safeParseAsync$2(schema, data);
|
|
1742
|
-
return await schema.safeParseAsync(data);
|
|
1743
|
-
}
|
|
1744
|
-
function getObjectShape(schema) {
|
|
1745
|
-
if (!schema) return void 0;
|
|
1746
|
-
let rawShape;
|
|
1747
|
-
if (isZ4Schema(schema)) rawShape = schema._zod?.def?.shape;else rawShape = schema.shape;
|
|
1748
|
-
if (!rawShape) return void 0;
|
|
1749
|
-
if (typeof rawShape === "function") try {
|
|
1750
|
-
return rawShape();
|
|
1751
|
-
} catch {
|
|
1752
|
-
return;
|
|
1753
|
-
}
|
|
1754
|
-
return rawShape;
|
|
1755
|
-
}
|
|
1756
|
-
/**
|
|
1757
|
-
* Normalizes a schema to an object schema. Handles both:
|
|
1758
|
-
* - Already-constructed object schemas (v3 or v4)
|
|
1759
|
-
* - Raw shapes that need to be wrapped into object schemas
|
|
1760
|
-
*/
|
|
1761
|
-
function normalizeObjectSchema(schema) {
|
|
1762
|
-
if (!schema) return void 0;
|
|
1763
|
-
if (typeof schema === "object") {
|
|
1764
|
-
const asV3 = schema;
|
|
1765
|
-
const asV4 = schema;
|
|
1766
|
-
if (!asV3._def && !asV4._zod) {
|
|
1767
|
-
const values = Object.values(schema);
|
|
1768
|
-
if (values.length > 0 && values.every(v => typeof v === "object" && v !== null && (v._def !== void 0 || v._zod !== void 0 || typeof v.parse === "function"))) return objectFromShape(schema);
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1771
|
-
if (isZ4Schema(schema)) {
|
|
1772
|
-
const def = schema._zod?.def;
|
|
1773
|
-
if (def && (def.type === "object" || def.shape !== void 0)) return schema;
|
|
1774
|
-
} else if (schema.shape !== void 0) return schema;
|
|
1775
|
-
}
|
|
1776
|
-
/**
|
|
1777
|
-
* Safely extracts an error message from a parse result error.
|
|
1778
|
-
* Zod errors can have different structures, so we handle various cases.
|
|
1779
|
-
*/
|
|
1780
|
-
function getParseErrorMessage(error) {
|
|
1781
|
-
if (error && typeof error === "object") {
|
|
1782
|
-
if ("message" in error && typeof error.message === "string") return error.message;
|
|
1783
|
-
if ("issues" in error && Array.isArray(error.issues) && error.issues.length > 0) {
|
|
1784
|
-
const firstIssue = error.issues[0];
|
|
1785
|
-
if (firstIssue && typeof firstIssue === "object" && "message" in firstIssue) return String(firstIssue.message);
|
|
1786
|
-
}
|
|
1787
|
-
try {
|
|
1788
|
-
return JSON.stringify(error);
|
|
1789
|
-
} catch {
|
|
1790
|
-
return String(error);
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
return String(error);
|
|
1794
|
-
}
|
|
1795
|
-
/**
|
|
1796
|
-
* Gets the description from a schema, if available.
|
|
1797
|
-
* Works with both Zod v3 and v4.
|
|
1798
|
-
*
|
|
1799
|
-
* Both versions expose a `.description` getter that returns the description
|
|
1800
|
-
* from their respective internal storage (v3: _def, v4: globalRegistry).
|
|
1801
|
-
*/
|
|
1802
|
-
function getSchemaDescription(schema) {
|
|
1803
|
-
return schema.description;
|
|
1804
|
-
}
|
|
1805
|
-
/**
|
|
1806
|
-
* Checks if a schema is optional.
|
|
1807
|
-
* Works with both Zod v3 and v4.
|
|
1808
|
-
*/
|
|
1809
|
-
function isSchemaOptional(schema) {
|
|
1810
|
-
if (isZ4Schema(schema)) return schema._zod?.def?.type === "optional";
|
|
1811
|
-
const v3Schema = schema;
|
|
1812
|
-
if (typeof schema.isOptional === "function") return schema.isOptional();
|
|
1813
|
-
return v3Schema._def?.typeName === "ZodOptional";
|
|
1814
|
-
}
|
|
1815
|
-
/**
|
|
1816
|
-
* Gets the literal value from a schema, if it's a literal schema.
|
|
1817
|
-
* Works with both Zod v3 and v4.
|
|
1818
|
-
* Returns undefined if the schema is not a literal or the value cannot be determined.
|
|
1819
|
-
*/
|
|
1820
|
-
function getLiteralValue(schema) {
|
|
1821
|
-
if (isZ4Schema(schema)) {
|
|
1822
|
-
const def = schema._zod?.def;
|
|
1823
|
-
if (def) {
|
|
1824
|
-
if (def.value !== void 0) return def.value;
|
|
1825
|
-
if (Array.isArray(def.values) && def.values.length > 0) return def.values[0];
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
const def = schema._def;
|
|
1829
|
-
if (def) {
|
|
1830
|
-
if (def.value !== void 0) return def.value;
|
|
1831
|
-
if (Array.isArray(def.values) && def.values.length > 0) return def.values[0];
|
|
1832
|
-
}
|
|
1833
|
-
const directValue = schema.value;
|
|
1834
|
-
if (directValue !== void 0) return directValue;
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
|
-
//#endregion
|
|
1838
|
-
//#region ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/iso.js
|
|
1839
|
-
|
|
1840
|
-
function datetime(params) {
|
|
1841
|
-
return _isoDateTime(ZodISODateTime, params);
|
|
1842
|
-
}
|
|
1843
|
-
function date(params) {
|
|
1844
|
-
return _isoDate(ZodISODate, params);
|
|
1845
|
-
}
|
|
1846
|
-
function time(params) {
|
|
1847
|
-
return _isoTime(ZodISOTime, params);
|
|
1848
|
-
}
|
|
1849
|
-
function duration(params) {
|
|
1850
|
-
return _isoDuration(ZodISODuration, params);
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1853
|
-
//#endregion
|
|
1854
|
-
//#region ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/errors.js
|
|
1855
|
-
|
|
1856
|
-
function string(params) {
|
|
1857
|
-
return _string(ZodString, params);
|
|
1858
|
-
}
|
|
1859
|
-
function number(params) {
|
|
1860
|
-
return _number(ZodNumber, params);
|
|
1861
|
-
}
|
|
1862
|
-
function int(params) {
|
|
1863
|
-
return _int(ZodNumberFormat, params);
|
|
1864
|
-
}
|
|
1865
|
-
function boolean(params) {
|
|
1866
|
-
return _boolean(ZodBoolean, params);
|
|
1867
|
-
}
|
|
1868
|
-
function _null(params) {
|
|
1869
|
-
return _null$1(ZodNull, params);
|
|
1870
|
-
}
|
|
1871
|
-
function unknown() {
|
|
1872
|
-
return _unknown(ZodUnknown);
|
|
1873
|
-
}
|
|
1874
|
-
function never(params) {
|
|
1875
|
-
return _never(ZodNever, params);
|
|
1876
|
-
}
|
|
1877
|
-
function array(element, params) {
|
|
1878
|
-
return _array(ZodArray, element, params);
|
|
1879
|
-
}
|
|
1880
|
-
function object(shape, params) {
|
|
1881
|
-
return new ZodObject({
|
|
1882
|
-
type: "object",
|
|
1883
|
-
shape: shape ?? {},
|
|
1884
|
-
...normalizeParams(params)
|
|
1885
|
-
});
|
|
1886
|
-
}
|
|
1887
|
-
function looseObject(shape, params) {
|
|
1888
|
-
return new ZodObject({
|
|
1889
|
-
type: "object",
|
|
1890
|
-
shape,
|
|
1891
|
-
catchall: unknown(),
|
|
1892
|
-
...normalizeParams(params)
|
|
1893
|
-
});
|
|
1894
|
-
}
|
|
1895
|
-
function union(options, params) {
|
|
1896
|
-
return new ZodUnion({
|
|
1897
|
-
type: "union",
|
|
1898
|
-
options,
|
|
1899
|
-
...normalizeParams(params)
|
|
1900
|
-
});
|
|
1901
|
-
}
|
|
1902
|
-
function discriminatedUnion(discriminator, options, params) {
|
|
1903
|
-
return new ZodDiscriminatedUnion({
|
|
1904
|
-
type: "union",
|
|
1905
|
-
options,
|
|
1906
|
-
discriminator,
|
|
1907
|
-
...normalizeParams(params)
|
|
1908
|
-
});
|
|
1909
|
-
}
|
|
1910
|
-
function intersection(left, right) {
|
|
1911
|
-
return new ZodIntersection({
|
|
1912
|
-
type: "intersection",
|
|
1913
|
-
left,
|
|
1914
|
-
right
|
|
1915
|
-
});
|
|
1916
|
-
}
|
|
1917
|
-
function record(keyType, valueType, params) {
|
|
1918
|
-
return new ZodRecord({
|
|
1919
|
-
type: "record",
|
|
1920
|
-
keyType,
|
|
1921
|
-
valueType,
|
|
1922
|
-
...normalizeParams(params)
|
|
1923
|
-
});
|
|
1924
|
-
}
|
|
1925
|
-
function _enum(values, params) {
|
|
1926
|
-
return new ZodEnum({
|
|
1927
|
-
type: "enum",
|
|
1928
|
-
entries: Array.isArray(values) ? Object.fromEntries(values.map(v => [v, v])) : values,
|
|
1929
|
-
...normalizeParams(params)
|
|
1930
|
-
});
|
|
1931
|
-
}
|
|
1932
|
-
function literal(value, params) {
|
|
1933
|
-
return new ZodLiteral({
|
|
1934
|
-
type: "literal",
|
|
1935
|
-
values: Array.isArray(value) ? value : [value],
|
|
1936
|
-
...normalizeParams(params)
|
|
1937
|
-
});
|
|
1938
|
-
}
|
|
1939
|
-
function transform(fn) {
|
|
1940
|
-
return new ZodTransform({
|
|
1941
|
-
type: "transform",
|
|
1942
|
-
transform: fn
|
|
1943
|
-
});
|
|
1944
|
-
}
|
|
1945
|
-
function optional(innerType) {
|
|
1946
|
-
return new ZodOptional$1({
|
|
1947
|
-
type: "optional",
|
|
1948
|
-
innerType
|
|
1949
|
-
});
|
|
1950
|
-
}
|
|
1951
|
-
function exactOptional(innerType) {
|
|
1952
|
-
return new ZodExactOptional({
|
|
1953
|
-
type: "optional",
|
|
1954
|
-
innerType
|
|
1955
|
-
});
|
|
1956
|
-
}
|
|
1957
|
-
function nullable(innerType) {
|
|
1958
|
-
return new ZodNullable({
|
|
1959
|
-
type: "nullable",
|
|
1960
|
-
innerType
|
|
1961
|
-
});
|
|
1962
|
-
}
|
|
1963
|
-
function _default(innerType, defaultValue) {
|
|
1964
|
-
return new ZodDefault({
|
|
1965
|
-
type: "default",
|
|
1966
|
-
innerType,
|
|
1967
|
-
get defaultValue() {
|
|
1968
|
-
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
1969
|
-
}
|
|
1970
|
-
});
|
|
1971
|
-
}
|
|
1972
|
-
function prefault(innerType, defaultValue) {
|
|
1973
|
-
return new ZodPrefault({
|
|
1974
|
-
type: "prefault",
|
|
1975
|
-
innerType,
|
|
1976
|
-
get defaultValue() {
|
|
1977
|
-
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
1978
|
-
}
|
|
1979
|
-
});
|
|
1980
|
-
}
|
|
1981
|
-
function nonoptional(innerType, params) {
|
|
1982
|
-
return new ZodNonOptional({
|
|
1983
|
-
type: "nonoptional",
|
|
1984
|
-
innerType,
|
|
1985
|
-
...normalizeParams(params)
|
|
1986
|
-
});
|
|
1987
|
-
}
|
|
1988
|
-
function _catch(innerType, catchValue) {
|
|
1989
|
-
return new ZodCatch({
|
|
1990
|
-
type: "catch",
|
|
1991
|
-
innerType,
|
|
1992
|
-
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
1993
|
-
});
|
|
1994
|
-
}
|
|
1995
|
-
function pipe(in_, out) {
|
|
1996
|
-
return new ZodPipe({
|
|
1997
|
-
type: "pipe",
|
|
1998
|
-
in: in_,
|
|
1999
|
-
out
|
|
2000
|
-
});
|
|
2001
|
-
}
|
|
2002
|
-
function readonly(innerType) {
|
|
2003
|
-
return new ZodReadonly({
|
|
2004
|
-
type: "readonly",
|
|
2005
|
-
innerType
|
|
2006
|
-
});
|
|
2007
|
-
}
|
|
2008
|
-
function custom(fn, _params) {
|
|
2009
|
-
return _custom(ZodCustom, fn ?? (() => true), _params);
|
|
2010
|
-
}
|
|
2011
|
-
function refine(fn, _params = {}) {
|
|
2012
|
-
return _refine(ZodCustom, fn, _params);
|
|
2013
|
-
}
|
|
2014
|
-
function superRefine(fn) {
|
|
2015
|
-
return _superRefine(fn);
|
|
2016
|
-
}
|
|
2017
|
-
function preprocess(fn, schema) {
|
|
2018
|
-
return pipe(transform(fn), schema);
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
//#endregion
|
|
2022
|
-
//#region ../../node_modules/.bun/@modelcontextprotocol+sdk@1.27.1/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
2023
|
-
|
|
2024
|
-
function assertCompleteRequestPrompt(request) {
|
|
2025
|
-
if (request.params.ref.type !== "ref/prompt") throw new TypeError(`Expected CompleteRequestPrompt, but got ${request.params.ref.type}`);
|
|
2026
|
-
}
|
|
2027
|
-
function assertCompleteRequestResourceTemplate(request) {
|
|
2028
|
-
if (request.params.ref.type !== "ref/resource") throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${request.params.ref.type}`);
|
|
2029
|
-
}
|
|
2030
|
-
/**
|
|
2031
|
-
* The server's response to a completion/complete request
|
|
2032
|
-
*/
|
|
2033
|
-
|
|
2034
|
-
//#endregion
|
|
2035
|
-
//#region ../../node_modules/.bun/@modelcontextprotocol+sdk@1.27.1/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
|
|
2036
|
-
/**
|
|
2037
|
-
* Experimental task interfaces for MCP SDK.
|
|
2038
|
-
* WARNING: These APIs are experimental and may change without notice.
|
|
2039
|
-
*/
|
|
2040
|
-
/**
|
|
2041
|
-
* Checks if a task status represents a terminal state.
|
|
2042
|
-
* Terminal states are those where the task has finished and will not change.
|
|
2043
|
-
*
|
|
2044
|
-
* @param status - The task status to check
|
|
2045
|
-
* @returns True if the status is terminal (completed, failed, or cancelled)
|
|
2046
|
-
* @experimental
|
|
2047
|
-
*/
|
|
2048
|
-
function isTerminal(status) {
|
|
2049
|
-
return status === "completed" || status === "failed" || status === "cancelled";
|
|
2050
|
-
}
|
|
2051
|
-
|
|
2052
|
-
//#endregion
|
|
2053
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
2054
|
-
|
|
2055
|
-
//#endregion
|
|
2056
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
|
|
2057
|
-
function addErrorMessage(res, key, errorMessage, refs) {
|
|
2058
|
-
if (!refs?.errorMessages) return;
|
|
2059
|
-
if (errorMessage) res.errorMessage = {
|
|
2060
|
-
...res.errorMessage,
|
|
2061
|
-
[key]: errorMessage
|
|
2062
|
-
};
|
|
2063
|
-
}
|
|
2064
|
-
function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
2065
|
-
res[key] = value;
|
|
2066
|
-
addErrorMessage(res, key, errorMessage, refs);
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
//#endregion
|
|
2070
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
|
|
2071
|
-
|
|
2072
|
-
//#endregion
|
|
2073
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
|
|
2074
|
-
function parseAnyDef(refs) {
|
|
2075
|
-
if (refs.target !== "openAi") return {};
|
|
2076
|
-
const anyDefinitionPath = [...refs.basePath, refs.definitionPath, refs.openAiAnyTypeName];
|
|
2077
|
-
refs.flags.hasReferencedOpenAiAnyType = true;
|
|
2078
|
-
return {
|
|
2079
|
-
$ref: refs.$refStrategy === "relative" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/")
|
|
2080
|
-
};
|
|
2081
|
-
}
|
|
2082
|
-
|
|
2083
|
-
//#endregion
|
|
2084
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
2085
|
-
function parseArrayDef(def, refs) {
|
|
2086
|
-
const res = {
|
|
2087
|
-
type: "array"
|
|
2088
|
-
};
|
|
2089
|
-
if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) res.items = parseDef(def.type._def, {
|
|
2090
|
-
...refs,
|
|
2091
|
-
currentPath: [...refs.currentPath, "items"]
|
|
2092
|
-
});
|
|
2093
|
-
if (def.minLength) setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
|
|
2094
|
-
if (def.maxLength) setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
|
|
2095
|
-
if (def.exactLength) {
|
|
2096
|
-
setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
|
|
2097
|
-
setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
|
|
2098
|
-
}
|
|
2099
|
-
return res;
|
|
2100
|
-
}
|
|
2101
|
-
|
|
2102
|
-
//#endregion
|
|
2103
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
|
|
2104
|
-
function parseBigintDef(def, refs) {
|
|
2105
|
-
const res = {
|
|
2106
|
-
type: "integer",
|
|
2107
|
-
format: "int64"
|
|
2108
|
-
};
|
|
2109
|
-
if (!def.checks) return res;
|
|
2110
|
-
for (const check of def.checks) switch (check.kind) {
|
|
2111
|
-
case "min":
|
|
2112
|
-
if (refs.target === "jsonSchema7") {
|
|
2113
|
-
if (check.inclusive) setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);else setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
2114
|
-
} else {
|
|
2115
|
-
if (!check.inclusive) res.exclusiveMinimum = true;
|
|
2116
|
-
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
2117
|
-
}
|
|
2118
|
-
break;
|
|
2119
|
-
case "max":
|
|
2120
|
-
if (refs.target === "jsonSchema7") {
|
|
2121
|
-
if (check.inclusive) setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);else setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
2122
|
-
} else {
|
|
2123
|
-
if (!check.inclusive) res.exclusiveMaximum = true;
|
|
2124
|
-
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
2125
|
-
}
|
|
2126
|
-
break;
|
|
2127
|
-
case "multipleOf":
|
|
2128
|
-
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
2129
|
-
break;
|
|
2130
|
-
}
|
|
2131
|
-
return res;
|
|
2132
|
-
}
|
|
2133
|
-
|
|
2134
|
-
//#endregion
|
|
2135
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
|
|
2136
|
-
function parseBooleanDef() {
|
|
2137
|
-
return {
|
|
2138
|
-
type: "boolean"
|
|
2139
|
-
};
|
|
2140
|
-
}
|
|
2141
|
-
|
|
2142
|
-
//#endregion
|
|
2143
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
|
|
2144
|
-
function parseBrandedDef(_def, refs) {
|
|
2145
|
-
return parseDef(_def.type._def, refs);
|
|
2146
|
-
}
|
|
2147
|
-
|
|
2148
|
-
//#endregion
|
|
2149
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
|
|
2150
|
-
|
|
2151
|
-
//#endregion
|
|
2152
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
|
|
2153
|
-
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
2154
|
-
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
2155
|
-
if (Array.isArray(strategy)) return {
|
|
2156
|
-
anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
|
|
2157
|
-
};
|
|
2158
|
-
switch (strategy) {
|
|
2159
|
-
case "string":
|
|
2160
|
-
case "format:date-time":
|
|
2161
|
-
return {
|
|
2162
|
-
type: "string",
|
|
2163
|
-
format: "date-time"
|
|
2164
|
-
};
|
|
2165
|
-
case "format:date":
|
|
2166
|
-
return {
|
|
2167
|
-
type: "string",
|
|
2168
|
-
format: "date"
|
|
2169
|
-
};
|
|
2170
|
-
case "integer":
|
|
2171
|
-
return integerDateParser(def, refs);
|
|
2172
|
-
}
|
|
2173
|
-
}
|
|
2174
|
-
//#endregion
|
|
2175
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
|
|
2176
|
-
function parseDefaultDef(_def, refs) {
|
|
2177
|
-
return {
|
|
2178
|
-
...parseDef(_def.innerType._def, refs),
|
|
2179
|
-
default: _def.defaultValue()
|
|
2180
|
-
};
|
|
2181
|
-
}
|
|
2182
|
-
|
|
2183
|
-
//#endregion
|
|
2184
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
|
|
2185
|
-
function parseEffectsDef(_def, refs) {
|
|
2186
|
-
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
|
|
2187
|
-
}
|
|
2188
|
-
|
|
2189
|
-
//#endregion
|
|
2190
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
|
|
2191
|
-
function parseEnumDef(def) {
|
|
2192
|
-
return {
|
|
2193
|
-
type: "string",
|
|
2194
|
-
enum: Array.from(def.values)
|
|
2195
|
-
};
|
|
2196
|
-
}
|
|
2197
|
-
|
|
2198
|
-
//#endregion
|
|
2199
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
|
|
2200
|
-
|
|
2201
|
-
function parseIntersectionDef(def, refs) {
|
|
2202
|
-
const allOf = [parseDef(def.left._def, {
|
|
2203
|
-
...refs,
|
|
2204
|
-
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
2205
|
-
}), parseDef(def.right._def, {
|
|
2206
|
-
...refs,
|
|
2207
|
-
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
2208
|
-
})].filter(x => !!x);
|
|
2209
|
-
let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? {
|
|
2210
|
-
unevaluatedProperties: false
|
|
2211
|
-
} : void 0;
|
|
2212
|
-
const mergedAllOf = [];
|
|
2213
|
-
allOf.forEach(schema => {
|
|
2214
|
-
if (isJsonSchema7AllOfType(schema)) {
|
|
2215
|
-
mergedAllOf.push(...schema.allOf);
|
|
2216
|
-
if (schema.unevaluatedProperties === void 0) unevaluatedProperties = void 0;
|
|
2217
|
-
} else {
|
|
2218
|
-
let nestedSchema = schema;
|
|
2219
|
-
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
2220
|
-
const {
|
|
2221
|
-
additionalProperties,
|
|
2222
|
-
...rest
|
|
2223
|
-
} = schema;
|
|
2224
|
-
nestedSchema = rest;
|
|
2225
|
-
} else unevaluatedProperties = void 0;
|
|
2226
|
-
mergedAllOf.push(nestedSchema);
|
|
2227
|
-
}
|
|
2228
|
-
});
|
|
2229
|
-
return mergedAllOf.length ? {
|
|
2230
|
-
allOf: mergedAllOf,
|
|
2231
|
-
...unevaluatedProperties
|
|
2232
|
-
} : void 0;
|
|
2233
|
-
}
|
|
2234
|
-
|
|
2235
|
-
//#endregion
|
|
2236
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
|
|
2237
|
-
function parseLiteralDef(def, refs) {
|
|
2238
|
-
const parsedType = typeof def.value;
|
|
2239
|
-
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") return {
|
|
2240
|
-
type: Array.isArray(def.value) ? "array" : "object"
|
|
2241
|
-
};
|
|
2242
|
-
if (refs.target === "openApi3") return {
|
|
2243
|
-
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
2244
|
-
enum: [def.value]
|
|
2245
|
-
};
|
|
2246
|
-
return {
|
|
2247
|
-
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
2248
|
-
const: def.value
|
|
2249
|
-
};
|
|
2250
|
-
}
|
|
2251
|
-
|
|
2252
|
-
//#endregion
|
|
2253
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
2254
|
-
|
|
2255
|
-
function parseStringDef(def, refs) {
|
|
2256
|
-
const res = {
|
|
2257
|
-
type: "string"
|
|
2258
|
-
};
|
|
2259
|
-
if (def.checks) for (const check of def.checks) switch (check.kind) {
|
|
2260
|
-
case "min":
|
|
2261
|
-
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
2262
|
-
break;
|
|
2263
|
-
case "max":
|
|
2264
|
-
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
2265
|
-
break;
|
|
2266
|
-
case "email":
|
|
2267
|
-
switch (refs.emailStrategy) {
|
|
2268
|
-
case "format:email":
|
|
2269
|
-
addFormat(res, "email", check.message, refs);
|
|
2270
|
-
break;
|
|
2271
|
-
case "format:idn-email":
|
|
2272
|
-
addFormat(res, "idn-email", check.message, refs);
|
|
2273
|
-
break;
|
|
2274
|
-
case "pattern:zod":
|
|
2275
|
-
addPattern(res, zodPatterns.email, check.message, refs);
|
|
2276
|
-
break;
|
|
2277
|
-
}
|
|
2278
|
-
break;
|
|
2279
|
-
case "url":
|
|
2280
|
-
addFormat(res, "uri", check.message, refs);
|
|
2281
|
-
break;
|
|
2282
|
-
case "uuid":
|
|
2283
|
-
addFormat(res, "uuid", check.message, refs);
|
|
2284
|
-
break;
|
|
2285
|
-
case "regex":
|
|
2286
|
-
addPattern(res, check.regex, check.message, refs);
|
|
2287
|
-
break;
|
|
2288
|
-
case "cuid":
|
|
2289
|
-
addPattern(res, zodPatterns.cuid, check.message, refs);
|
|
2290
|
-
break;
|
|
2291
|
-
case "cuid2":
|
|
2292
|
-
addPattern(res, zodPatterns.cuid2, check.message, refs);
|
|
2293
|
-
break;
|
|
2294
|
-
case "startsWith":
|
|
2295
|
-
addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
|
|
2296
|
-
break;
|
|
2297
|
-
case "endsWith":
|
|
2298
|
-
addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
|
|
2299
|
-
break;
|
|
2300
|
-
case "datetime":
|
|
2301
|
-
addFormat(res, "date-time", check.message, refs);
|
|
2302
|
-
break;
|
|
2303
|
-
case "date":
|
|
2304
|
-
addFormat(res, "date", check.message, refs);
|
|
2305
|
-
break;
|
|
2306
|
-
case "time":
|
|
2307
|
-
addFormat(res, "time", check.message, refs);
|
|
2308
|
-
break;
|
|
2309
|
-
case "duration":
|
|
2310
|
-
addFormat(res, "duration", check.message, refs);
|
|
2311
|
-
break;
|
|
2312
|
-
case "length":
|
|
2313
|
-
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
2314
|
-
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
2315
|
-
break;
|
|
2316
|
-
case "includes":
|
|
2317
|
-
addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
|
|
2318
|
-
break;
|
|
2319
|
-
case "ip":
|
|
2320
|
-
if (check.version !== "v6") addFormat(res, "ipv4", check.message, refs);
|
|
2321
|
-
if (check.version !== "v4") addFormat(res, "ipv6", check.message, refs);
|
|
2322
|
-
break;
|
|
2323
|
-
case "base64url":
|
|
2324
|
-
addPattern(res, zodPatterns.base64url, check.message, refs);
|
|
2325
|
-
break;
|
|
2326
|
-
case "jwt":
|
|
2327
|
-
addPattern(res, zodPatterns.jwt, check.message, refs);
|
|
2328
|
-
break;
|
|
2329
|
-
case "cidr":
|
|
2330
|
-
if (check.version !== "v6") addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
|
|
2331
|
-
if (check.version !== "v4") addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
|
|
2332
|
-
break;
|
|
2333
|
-
case "emoji":
|
|
2334
|
-
addPattern(res, zodPatterns.emoji(), check.message, refs);
|
|
2335
|
-
break;
|
|
2336
|
-
case "ulid":
|
|
2337
|
-
addPattern(res, zodPatterns.ulid, check.message, refs);
|
|
2338
|
-
break;
|
|
2339
|
-
case "base64":
|
|
2340
|
-
switch (refs.base64Strategy) {
|
|
2341
|
-
case "format:binary":
|
|
2342
|
-
addFormat(res, "binary", check.message, refs);
|
|
2343
|
-
break;
|
|
2344
|
-
case "contentEncoding:base64":
|
|
2345
|
-
setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
|
|
2346
|
-
break;
|
|
2347
|
-
case "pattern:zod":
|
|
2348
|
-
addPattern(res, zodPatterns.base64, check.message, refs);
|
|
2349
|
-
break;
|
|
2350
|
-
}
|
|
2351
|
-
break;
|
|
2352
|
-
case "nanoid":
|
|
2353
|
-
addPattern(res, zodPatterns.nanoid, check.message, refs);
|
|
2354
|
-
case "toLowerCase":
|
|
2355
|
-
case "toUpperCase":
|
|
2356
|
-
case "trim":
|
|
2357
|
-
break;
|
|
2358
|
-
default:
|
|
2359
|
-
(_ => {})(check);
|
|
2360
|
-
}
|
|
2361
|
-
return res;
|
|
2362
|
-
}
|
|
2363
|
-
function escapeLiteralCheckValue(literal, refs) {
|
|
2364
|
-
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
|
|
2365
|
-
}
|
|
2366
|
-
function escapeNonAlphaNumeric(source) {
|
|
2367
|
-
let result = "";
|
|
2368
|
-
for (let i = 0; i < source.length; i++) {
|
|
2369
|
-
if (!ALPHA_NUMERIC.has(source[i])) result += "\\";
|
|
2370
|
-
result += source[i];
|
|
2371
|
-
}
|
|
2372
|
-
return result;
|
|
2373
|
-
}
|
|
2374
|
-
function addFormat(schema, value, message, refs) {
|
|
2375
|
-
if (schema.format || schema.anyOf?.some(x => x.format)) {
|
|
2376
|
-
if (!schema.anyOf) schema.anyOf = [];
|
|
2377
|
-
if (schema.format) {
|
|
2378
|
-
schema.anyOf.push({
|
|
2379
|
-
format: schema.format,
|
|
2380
|
-
...(schema.errorMessage && refs.errorMessages && {
|
|
2381
|
-
errorMessage: {
|
|
2382
|
-
format: schema.errorMessage.format
|
|
2383
|
-
}
|
|
2384
|
-
})
|
|
2385
|
-
});
|
|
2386
|
-
delete schema.format;
|
|
2387
|
-
if (schema.errorMessage) {
|
|
2388
|
-
delete schema.errorMessage.format;
|
|
2389
|
-
if (Object.keys(schema.errorMessage).length === 0) delete schema.errorMessage;
|
|
2390
|
-
}
|
|
2391
|
-
}
|
|
2392
|
-
schema.anyOf.push({
|
|
2393
|
-
format: value,
|
|
2394
|
-
...(message && refs.errorMessages && {
|
|
2395
|
-
errorMessage: {
|
|
2396
|
-
format: message
|
|
2397
|
-
}
|
|
2398
|
-
})
|
|
2399
|
-
});
|
|
2400
|
-
} else setResponseValueAndErrors(schema, "format", value, message, refs);
|
|
2401
|
-
}
|
|
2402
|
-
function addPattern(schema, regex, message, refs) {
|
|
2403
|
-
if (schema.pattern || schema.allOf?.some(x => x.pattern)) {
|
|
2404
|
-
if (!schema.allOf) schema.allOf = [];
|
|
2405
|
-
if (schema.pattern) {
|
|
2406
|
-
schema.allOf.push({
|
|
2407
|
-
pattern: schema.pattern,
|
|
2408
|
-
...(schema.errorMessage && refs.errorMessages && {
|
|
2409
|
-
errorMessage: {
|
|
2410
|
-
pattern: schema.errorMessage.pattern
|
|
2411
|
-
}
|
|
2412
|
-
})
|
|
2413
|
-
});
|
|
2414
|
-
delete schema.pattern;
|
|
2415
|
-
if (schema.errorMessage) {
|
|
2416
|
-
delete schema.errorMessage.pattern;
|
|
2417
|
-
if (Object.keys(schema.errorMessage).length === 0) delete schema.errorMessage;
|
|
2418
|
-
}
|
|
2419
|
-
}
|
|
2420
|
-
schema.allOf.push({
|
|
2421
|
-
pattern: stringifyRegExpWithFlags(regex, refs),
|
|
2422
|
-
...(message && refs.errorMessages && {
|
|
2423
|
-
errorMessage: {
|
|
2424
|
-
pattern: message
|
|
2425
|
-
}
|
|
2426
|
-
})
|
|
2427
|
-
});
|
|
2428
|
-
} else setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
|
|
2429
|
-
}
|
|
2430
|
-
function stringifyRegExpWithFlags(regex, refs) {
|
|
2431
|
-
if (!refs.applyRegexFlags || !regex.flags) return regex.source;
|
|
2432
|
-
const flags = {
|
|
2433
|
-
i: regex.flags.includes("i"),
|
|
2434
|
-
m: regex.flags.includes("m"),
|
|
2435
|
-
s: regex.flags.includes("s")
|
|
2436
|
-
};
|
|
2437
|
-
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
2438
|
-
let pattern = "";
|
|
2439
|
-
let isEscaped = false;
|
|
2440
|
-
let inCharGroup = false;
|
|
2441
|
-
let inCharRange = false;
|
|
2442
|
-
for (let i = 0; i < source.length; i++) {
|
|
2443
|
-
if (isEscaped) {
|
|
2444
|
-
pattern += source[i];
|
|
2445
|
-
isEscaped = false;
|
|
2446
|
-
continue;
|
|
2447
|
-
}
|
|
2448
|
-
if (flags.i) {
|
|
2449
|
-
if (inCharGroup) {
|
|
2450
|
-
if (source[i].match(/[a-z]/)) {
|
|
2451
|
-
if (inCharRange) {
|
|
2452
|
-
pattern += source[i];
|
|
2453
|
-
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
2454
|
-
inCharRange = false;
|
|
2455
|
-
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
2456
|
-
pattern += source[i];
|
|
2457
|
-
inCharRange = true;
|
|
2458
|
-
} else pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
2459
|
-
continue;
|
|
2460
|
-
}
|
|
2461
|
-
} else if (source[i].match(/[a-z]/)) {
|
|
2462
|
-
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
2463
|
-
continue;
|
|
2464
|
-
}
|
|
2465
|
-
}
|
|
2466
|
-
if (flags.m) {
|
|
2467
|
-
if (source[i] === "^") {
|
|
2468
|
-
pattern += `(^|(?<=[\r\n]))`;
|
|
2469
|
-
continue;
|
|
2470
|
-
} else if (source[i] === "$") {
|
|
2471
|
-
pattern += `($|(?=[\r\n]))`;
|
|
2472
|
-
continue;
|
|
2473
|
-
}
|
|
2474
|
-
}
|
|
2475
|
-
if (flags.s && source[i] === ".") {
|
|
2476
|
-
pattern += inCharGroup ? `${source[i]}\r\n` : `[${source[i]}\r\n]`;
|
|
2477
|
-
continue;
|
|
2478
|
-
}
|
|
2479
|
-
pattern += source[i];
|
|
2480
|
-
if (source[i] === "\\") isEscaped = true;else if (inCharGroup && source[i] === "]") inCharGroup = false;else if (!inCharGroup && source[i] === "[") inCharGroup = true;
|
|
2481
|
-
}
|
|
2482
|
-
try {
|
|
2483
|
-
new RegExp(pattern);
|
|
2484
|
-
} catch {
|
|
2485
|
-
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
2486
|
-
return regex.source;
|
|
2487
|
-
}
|
|
2488
|
-
return pattern;
|
|
2489
|
-
}
|
|
2490
|
-
|
|
2491
|
-
//#endregion
|
|
2492
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
2493
|
-
function parseRecordDef(def, refs) {
|
|
2494
|
-
if (refs.target === "openAi") console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
2495
|
-
if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {
|
|
2496
|
-
type: "object",
|
|
2497
|
-
required: def.keyType._def.values,
|
|
2498
|
-
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
2499
|
-
...acc,
|
|
2500
|
-
[key]: parseDef(def.valueType._def, {
|
|
2501
|
-
...refs,
|
|
2502
|
-
currentPath: [...refs.currentPath, "properties", key]
|
|
2503
|
-
}) ?? parseAnyDef(refs)
|
|
2504
|
-
}), {}),
|
|
2505
|
-
additionalProperties: refs.rejectedAdditionalProperties
|
|
2506
|
-
};
|
|
2507
|
-
const schema = {
|
|
2508
|
-
type: "object",
|
|
2509
|
-
additionalProperties: parseDef(def.valueType._def, {
|
|
2510
|
-
...refs,
|
|
2511
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
2512
|
-
}) ?? refs.allowedAdditionalProperties
|
|
2513
|
-
};
|
|
2514
|
-
if (refs.target === "openApi3") return schema;
|
|
2515
|
-
if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
2516
|
-
const {
|
|
2517
|
-
type,
|
|
2518
|
-
...keyType
|
|
2519
|
-
} = parseStringDef(def.keyType._def, refs);
|
|
2520
|
-
return {
|
|
2521
|
-
...schema,
|
|
2522
|
-
propertyNames: keyType
|
|
2523
|
-
};
|
|
2524
|
-
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {
|
|
2525
|
-
...schema,
|
|
2526
|
-
propertyNames: {
|
|
2527
|
-
enum: def.keyType._def.values
|
|
2528
|
-
}
|
|
2529
|
-
};else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
2530
|
-
const {
|
|
2531
|
-
type,
|
|
2532
|
-
...keyType
|
|
2533
|
-
} = parseBrandedDef(def.keyType._def, refs);
|
|
2534
|
-
return {
|
|
2535
|
-
...schema,
|
|
2536
|
-
propertyNames: keyType
|
|
2537
|
-
};
|
|
2538
|
-
}
|
|
2539
|
-
return schema;
|
|
2540
|
-
}
|
|
2541
|
-
|
|
2542
|
-
//#endregion
|
|
2543
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
|
|
2544
|
-
function parseMapDef(def, refs) {
|
|
2545
|
-
if (refs.mapStrategy === "record") return parseRecordDef(def, refs);
|
|
2546
|
-
return {
|
|
2547
|
-
type: "array",
|
|
2548
|
-
maxItems: 125,
|
|
2549
|
-
items: {
|
|
2550
|
-
type: "array",
|
|
2551
|
-
items: [parseDef(def.keyType._def, {
|
|
2552
|
-
...refs,
|
|
2553
|
-
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
2554
|
-
}) || parseAnyDef(refs), parseDef(def.valueType._def, {
|
|
2555
|
-
...refs,
|
|
2556
|
-
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
2557
|
-
}) || parseAnyDef(refs)],
|
|
2558
|
-
minItems: 2,
|
|
2559
|
-
maxItems: 2
|
|
2560
|
-
}
|
|
2561
|
-
};
|
|
2562
|
-
}
|
|
2563
|
-
|
|
2564
|
-
//#endregion
|
|
2565
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
2566
|
-
function parseNativeEnumDef(def) {
|
|
2567
|
-
const object = def.values;
|
|
2568
|
-
const actualValues = Object.keys(def.values).filter(key => {
|
|
2569
|
-
return typeof object[object[key]] !== "number";
|
|
2570
|
-
}).map(key => object[key]);
|
|
2571
|
-
const parsedTypes = Array.from(new Set(actualValues.map(values => typeof values)));
|
|
2572
|
-
return {
|
|
2573
|
-
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
2574
|
-
enum: actualValues
|
|
2575
|
-
};
|
|
2576
|
-
}
|
|
2577
|
-
|
|
2578
|
-
//#endregion
|
|
2579
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
|
|
2580
|
-
function parseNeverDef(refs) {
|
|
2581
|
-
return refs.target === "openAi" ? void 0 : {
|
|
2582
|
-
not: parseAnyDef({
|
|
2583
|
-
...refs,
|
|
2584
|
-
currentPath: [...refs.currentPath, "not"]
|
|
2585
|
-
})
|
|
2586
|
-
};
|
|
2587
|
-
}
|
|
2588
|
-
|
|
2589
|
-
//#endregion
|
|
2590
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
|
|
2591
|
-
function parseNullDef(refs) {
|
|
2592
|
-
return refs.target === "openApi3" ? {
|
|
2593
|
-
enum: ["null"],
|
|
2594
|
-
nullable: true
|
|
2595
|
-
} : {
|
|
2596
|
-
type: "null"
|
|
2597
|
-
};
|
|
2598
|
-
}
|
|
2599
|
-
|
|
2600
|
-
//#endregion
|
|
2601
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
|
|
2602
|
-
|
|
2603
|
-
function parseUnionDef(def, refs) {
|
|
2604
|
-
if (refs.target === "openApi3") return asAnyOf(def, refs);
|
|
2605
|
-
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
2606
|
-
if (options.every(x => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))) {
|
|
2607
|
-
const types = options.reduce((types, x) => {
|
|
2608
|
-
const type = primitiveMappings[x._def.typeName];
|
|
2609
|
-
return type && !types.includes(type) ? [...types, type] : types;
|
|
2610
|
-
}, []);
|
|
2611
|
-
return {
|
|
2612
|
-
type: types.length > 1 ? types : types[0]
|
|
2613
|
-
};
|
|
2614
|
-
} else if (options.every(x => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
2615
|
-
const types = options.reduce((acc, x) => {
|
|
2616
|
-
const type = typeof x._def.value;
|
|
2617
|
-
switch (type) {
|
|
2618
|
-
case "string":
|
|
2619
|
-
case "number":
|
|
2620
|
-
case "boolean":
|
|
2621
|
-
return [...acc, type];
|
|
2622
|
-
case "bigint":
|
|
2623
|
-
return [...acc, "integer"];
|
|
2624
|
-
case "object":
|
|
2625
|
-
if (x._def.value === null) return [...acc, "null"];
|
|
2626
|
-
default:
|
|
2627
|
-
return acc;
|
|
2628
|
-
}
|
|
2629
|
-
}, []);
|
|
2630
|
-
if (types.length === options.length) {
|
|
2631
|
-
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
2632
|
-
return {
|
|
2633
|
-
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
2634
|
-
enum: options.reduce((acc, x) => {
|
|
2635
|
-
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
2636
|
-
}, [])
|
|
2637
|
-
};
|
|
2638
|
-
}
|
|
2639
|
-
} else if (options.every(x => x._def.typeName === "ZodEnum")) return {
|
|
2640
|
-
type: "string",
|
|
2641
|
-
enum: options.reduce((acc, x) => [...acc, ...x._def.values.filter(x => !acc.includes(x))], [])
|
|
2642
|
-
};
|
|
2643
|
-
return asAnyOf(def, refs);
|
|
2644
|
-
}
|
|
2645
|
-
//#endregion
|
|
2646
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
|
|
2647
|
-
function parseNullableDef(def, refs) {
|
|
2648
|
-
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
2649
|
-
if (refs.target === "openApi3") return {
|
|
2650
|
-
type: primitiveMappings[def.innerType._def.typeName],
|
|
2651
|
-
nullable: true
|
|
2652
|
-
};
|
|
2653
|
-
return {
|
|
2654
|
-
type: [primitiveMappings[def.innerType._def.typeName], "null"]
|
|
2655
|
-
};
|
|
2656
|
-
}
|
|
2657
|
-
if (refs.target === "openApi3") {
|
|
2658
|
-
const base = parseDef(def.innerType._def, {
|
|
2659
|
-
...refs,
|
|
2660
|
-
currentPath: [...refs.currentPath]
|
|
2661
|
-
});
|
|
2662
|
-
if (base && "$ref" in base) return {
|
|
2663
|
-
allOf: [base],
|
|
2664
|
-
nullable: true
|
|
2665
|
-
};
|
|
2666
|
-
return base && {
|
|
2667
|
-
...base,
|
|
2668
|
-
nullable: true
|
|
2669
|
-
};
|
|
2670
|
-
}
|
|
2671
|
-
const base = parseDef(def.innerType._def, {
|
|
2672
|
-
...refs,
|
|
2673
|
-
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
2674
|
-
});
|
|
2675
|
-
return base && {
|
|
2676
|
-
anyOf: [base, {
|
|
2677
|
-
type: "null"
|
|
2678
|
-
}]
|
|
2679
|
-
};
|
|
2680
|
-
}
|
|
2681
|
-
|
|
2682
|
-
//#endregion
|
|
2683
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
|
|
2684
|
-
function parseNumberDef(def, refs) {
|
|
2685
|
-
const res = {
|
|
2686
|
-
type: "number"
|
|
2687
|
-
};
|
|
2688
|
-
if (!def.checks) return res;
|
|
2689
|
-
for (const check of def.checks) switch (check.kind) {
|
|
2690
|
-
case "int":
|
|
2691
|
-
res.type = "integer";
|
|
2692
|
-
addErrorMessage(res, "type", check.message, refs);
|
|
2693
|
-
break;
|
|
2694
|
-
case "min":
|
|
2695
|
-
if (refs.target === "jsonSchema7") {
|
|
2696
|
-
if (check.inclusive) setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);else setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
2697
|
-
} else {
|
|
2698
|
-
if (!check.inclusive) res.exclusiveMinimum = true;
|
|
2699
|
-
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
2700
|
-
}
|
|
2701
|
-
break;
|
|
2702
|
-
case "max":
|
|
2703
|
-
if (refs.target === "jsonSchema7") {
|
|
2704
|
-
if (check.inclusive) setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);else setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
2705
|
-
} else {
|
|
2706
|
-
if (!check.inclusive) res.exclusiveMaximum = true;
|
|
2707
|
-
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
2708
|
-
}
|
|
2709
|
-
break;
|
|
2710
|
-
case "multipleOf":
|
|
2711
|
-
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
2712
|
-
break;
|
|
2713
|
-
}
|
|
2714
|
-
return res;
|
|
2715
|
-
}
|
|
2716
|
-
|
|
2717
|
-
//#endregion
|
|
2718
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
|
|
2719
|
-
function parseObjectDef(def, refs) {
|
|
2720
|
-
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
2721
|
-
const result = {
|
|
2722
|
-
type: "object",
|
|
2723
|
-
properties: {}
|
|
2724
|
-
};
|
|
2725
|
-
const required = [];
|
|
2726
|
-
const shape = def.shape();
|
|
2727
|
-
for (const propName in shape) {
|
|
2728
|
-
let propDef = shape[propName];
|
|
2729
|
-
if (propDef === void 0 || propDef._def === void 0) continue;
|
|
2730
|
-
let propOptional = safeIsOptional(propDef);
|
|
2731
|
-
if (propOptional && forceOptionalIntoNullable) {
|
|
2732
|
-
if (propDef._def.typeName === "ZodOptional") propDef = propDef._def.innerType;
|
|
2733
|
-
if (!propDef.isNullable()) propDef = propDef.nullable();
|
|
2734
|
-
propOptional = false;
|
|
2735
|
-
}
|
|
2736
|
-
const parsedDef = parseDef(propDef._def, {
|
|
2737
|
-
...refs,
|
|
2738
|
-
currentPath: [...refs.currentPath, "properties", propName],
|
|
2739
|
-
propertyPath: [...refs.currentPath, "properties", propName]
|
|
2740
|
-
});
|
|
2741
|
-
if (parsedDef === void 0) continue;
|
|
2742
|
-
result.properties[propName] = parsedDef;
|
|
2743
|
-
if (!propOptional) required.push(propName);
|
|
2744
|
-
}
|
|
2745
|
-
if (required.length) result.required = required;
|
|
2746
|
-
const additionalProperties = decideAdditionalProperties(def, refs);
|
|
2747
|
-
if (additionalProperties !== void 0) result.additionalProperties = additionalProperties;
|
|
2748
|
-
return result;
|
|
2749
|
-
}
|
|
2750
|
-
function decideAdditionalProperties(def, refs) {
|
|
2751
|
-
if (def.catchall._def.typeName !== "ZodNever") return parseDef(def.catchall._def, {
|
|
2752
|
-
...refs,
|
|
2753
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
2754
|
-
});
|
|
2755
|
-
switch (def.unknownKeys) {
|
|
2756
|
-
case "passthrough":
|
|
2757
|
-
return refs.allowedAdditionalProperties;
|
|
2758
|
-
case "strict":
|
|
2759
|
-
return refs.rejectedAdditionalProperties;
|
|
2760
|
-
case "strip":
|
|
2761
|
-
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
2762
|
-
}
|
|
2763
|
-
}
|
|
2764
|
-
function safeIsOptional(schema) {
|
|
2765
|
-
try {
|
|
2766
|
-
return schema.isOptional();
|
|
2767
|
-
} catch {
|
|
2768
|
-
return true;
|
|
2769
|
-
}
|
|
2770
|
-
}
|
|
2771
|
-
|
|
2772
|
-
//#endregion
|
|
2773
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
|
|
2774
|
-
|
|
2775
|
-
//#endregion
|
|
2776
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
|
|
2777
|
-
function parsePromiseDef(def, refs) {
|
|
2778
|
-
return parseDef(def.type._def, refs);
|
|
2779
|
-
}
|
|
2780
|
-
|
|
2781
|
-
//#endregion
|
|
2782
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
|
|
2783
|
-
function parseSetDef(def, refs) {
|
|
2784
|
-
const schema = {
|
|
2785
|
-
type: "array",
|
|
2786
|
-
uniqueItems: true,
|
|
2787
|
-
items: parseDef(def.valueType._def, {
|
|
2788
|
-
...refs,
|
|
2789
|
-
currentPath: [...refs.currentPath, "items"]
|
|
2790
|
-
})
|
|
2791
|
-
};
|
|
2792
|
-
if (def.minSize) setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
2793
|
-
if (def.maxSize) setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
2794
|
-
return schema;
|
|
2795
|
-
}
|
|
2796
|
-
|
|
2797
|
-
//#endregion
|
|
2798
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
|
|
2799
|
-
function parseTupleDef(def, refs) {
|
|
2800
|
-
if (def.rest) return {
|
|
2801
|
-
type: "array",
|
|
2802
|
-
minItems: def.items.length,
|
|
2803
|
-
items: def.items.map((x, i) => parseDef(x._def, {
|
|
2804
|
-
...refs,
|
|
2805
|
-
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
2806
|
-
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),
|
|
2807
|
-
additionalItems: parseDef(def.rest._def, {
|
|
2808
|
-
...refs,
|
|
2809
|
-
currentPath: [...refs.currentPath, "additionalItems"]
|
|
2810
|
-
})
|
|
2811
|
-
};else return {
|
|
2812
|
-
type: "array",
|
|
2813
|
-
minItems: def.items.length,
|
|
2814
|
-
maxItems: def.items.length,
|
|
2815
|
-
items: def.items.map((x, i) => parseDef(x._def, {
|
|
2816
|
-
...refs,
|
|
2817
|
-
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
2818
|
-
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])
|
|
2819
|
-
};
|
|
2820
|
-
}
|
|
2821
|
-
|
|
2822
|
-
//#endregion
|
|
2823
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
|
|
2824
|
-
function parseUndefinedDef(refs) {
|
|
2825
|
-
return {
|
|
2826
|
-
not: parseAnyDef(refs)
|
|
2827
|
-
};
|
|
2828
|
-
}
|
|
2829
|
-
|
|
2830
|
-
//#endregion
|
|
2831
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
|
|
2832
|
-
function parseUnknownDef(refs) {
|
|
2833
|
-
return parseAnyDef(refs);
|
|
2834
|
-
}
|
|
2835
|
-
|
|
2836
|
-
//#endregion
|
|
2837
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
|
|
2838
|
-
|
|
2839
|
-
//#endregion
|
|
2840
|
-
//#region ../../node_modules/.bun/zod-to-json-schema@3.25.1+3c5d820c62823f0b/node_modules/zod-to-json-schema/dist/esm/parseDef.js
|
|
2841
|
-
function parseDef(def, refs, forceResolution = false) {
|
|
2842
|
-
const seenItem = refs.seen.get(def);
|
|
2843
|
-
if (refs.override) {
|
|
2844
|
-
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
2845
|
-
if (overrideResult !== ignoreOverride) return overrideResult;
|
|
2846
|
-
}
|
|
2847
|
-
if (seenItem && !forceResolution) {
|
|
2848
|
-
const seenSchema = get$ref(seenItem, refs);
|
|
2849
|
-
if (seenSchema !== void 0) return seenSchema;
|
|
2850
|
-
}
|
|
2851
|
-
const newItem = {
|
|
2852
|
-
def,
|
|
2853
|
-
path: refs.currentPath,
|
|
2854
|
-
jsonSchema: void 0
|
|
2855
|
-
};
|
|
2856
|
-
refs.seen.set(def, newItem);
|
|
2857
|
-
const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
|
|
2858
|
-
const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
2859
|
-
if (jsonSchema) addMeta(def, refs, jsonSchema);
|
|
2860
|
-
if (refs.postProcess) {
|
|
2861
|
-
const postProcessResult = refs.postProcess(jsonSchema, def, refs);
|
|
2862
|
-
newItem.jsonSchema = jsonSchema;
|
|
2863
|
-
return postProcessResult;
|
|
2864
|
-
}
|
|
2865
|
-
newItem.jsonSchema = jsonSchema;
|
|
2866
|
-
return jsonSchema;
|
|
2867
|
-
}
|
|
2868
|
-
//#endregion
|
|
2869
|
-
//#region ../../node_modules/.bun/@modelcontextprotocol+sdk@1.27.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
|
|
2870
|
-
function mapMiniTarget(t) {
|
|
2871
|
-
if (!t) return "draft-7";
|
|
2872
|
-
if (t === "jsonSchema7" || t === "draft-7") return "draft-7";
|
|
2873
|
-
if (t === "jsonSchema2019-09" || t === "draft-2020-12") return "draft-2020-12";
|
|
2874
|
-
return "draft-7";
|
|
2875
|
-
}
|
|
2876
|
-
function toJsonSchemaCompat(schema, opts) {
|
|
2877
|
-
if (isZ4Schema(schema)) return toJSONSchema(schema, {
|
|
2878
|
-
target: mapMiniTarget(opts?.target),
|
|
2879
|
-
io: opts?.pipeStrategy ?? "input"
|
|
2880
|
-
});
|
|
2881
|
-
return zodToJsonSchema(schema, {
|
|
2882
|
-
strictUnions: opts?.strictUnions ?? true,
|
|
2883
|
-
pipeStrategy: opts?.pipeStrategy ?? "input"
|
|
2884
|
-
});
|
|
2885
|
-
}
|
|
2886
|
-
function getMethodLiteral(schema) {
|
|
2887
|
-
const methodSchema = getObjectShape(schema)?.method;
|
|
2888
|
-
if (!methodSchema) throw new Error("Schema is missing a method literal");
|
|
2889
|
-
const value = getLiteralValue(methodSchema);
|
|
2890
|
-
if (typeof value !== "string") throw new Error("Schema method literal must be a string");
|
|
2891
|
-
return value;
|
|
2892
|
-
}
|
|
2893
|
-
function parseWithCompat(schema, data) {
|
|
2894
|
-
const result = safeParse$1(schema, data);
|
|
2895
|
-
if (!result.success) throw result.error;
|
|
2896
|
-
return result.data;
|
|
2897
|
-
}
|
|
2898
|
-
|
|
2899
|
-
//#endregion
|
|
2900
|
-
//#region ../../node_modules/.bun/@modelcontextprotocol+sdk@1.27.1/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
|
|
2901
|
-
/**
|
|
2902
|
-
* The default request timeout, in miliseconds.
|
|
2903
|
-
*/
|
|
2904
|
-
|
|
2905
|
-
function isPlainObject(value) {
|
|
2906
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
2907
|
-
}
|
|
2908
|
-
function mergeCapabilities(base, additional) {
|
|
2909
|
-
const result = {
|
|
2910
|
-
...base
|
|
2911
|
-
};
|
|
2912
|
-
for (const key in additional) {
|
|
2913
|
-
const k = key;
|
|
2914
|
-
const addValue = additional[k];
|
|
2915
|
-
if (addValue === void 0) continue;
|
|
2916
|
-
const baseValue = result[k];
|
|
2917
|
-
if (isPlainObject(baseValue) && isPlainObject(addValue)) result[k] = {
|
|
2918
|
-
...baseValue,
|
|
2919
|
-
...addValue
|
|
2920
|
-
};else result[k] = addValue;
|
|
2921
|
-
}
|
|
2922
|
-
return result;
|
|
2923
|
-
}
|
|
2924
|
-
|
|
2925
|
-
//#endregion
|
|
2926
|
-
//#region ../../node_modules/.bun/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js
|
|
2927
|
-
|
|
2928
|
-
function createDefaultAjvInstance() {
|
|
2929
|
-
const ajv = new import_ajv.default({
|
|
2930
|
-
strict: false,
|
|
2931
|
-
validateFormats: true,
|
|
2932
|
-
validateSchema: false,
|
|
2933
|
-
allErrors: true
|
|
2934
|
-
});
|
|
2935
|
-
(0, import_dist.default)(ajv);
|
|
2936
|
-
return ajv;
|
|
2937
|
-
}
|
|
2938
|
-
/**
|
|
2939
|
-
* @example
|
|
2940
|
-
* ```typescript
|
|
2941
|
-
* // Use with default AJV instance (recommended)
|
|
2942
|
-
* import { AjvJsonSchemaValidator } from '@modelcontextprotocol/sdk/validation/ajv';
|
|
2943
|
-
* const validator = new AjvJsonSchemaValidator();
|
|
2944
|
-
*
|
|
2945
|
-
* // Use with custom AJV instance
|
|
2946
|
-
* import { Ajv } from 'ajv';
|
|
2947
|
-
* const ajv = new Ajv({ strict: true, allErrors: true });
|
|
2948
|
-
* const validator = new AjvJsonSchemaValidator(ajv);
|
|
2949
|
-
* ```
|
|
2950
|
-
*/
|
|
2951
|
-
|
|
2952
|
-
//#endregion
|
|
2953
|
-
//#region ../../node_modules/.bun/@modelcontextprotocol+sdk@1.27.1/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
|
|
2954
|
-
/**
|
|
2955
|
-
* Experimental task capability assertion helpers.
|
|
2956
|
-
* WARNING: These APIs are experimental and may change without notice.
|
|
2957
|
-
*
|
|
2958
|
-
* @experimental
|
|
2959
|
-
*/
|
|
2960
|
-
/**
|
|
2961
|
-
* Asserts that task creation is supported for tools/call.
|
|
2962
|
-
* Used by Client.assertTaskCapability and Server.assertTaskHandlerCapability.
|
|
2963
|
-
*
|
|
2964
|
-
* @param requests - The task requests capability object
|
|
2965
|
-
* @param method - The method being checked
|
|
2966
|
-
* @param entityName - 'Server' or 'Client' for error messages
|
|
2967
|
-
* @throws Error if the capability is not supported
|
|
2968
|
-
*
|
|
2969
|
-
* @experimental
|
|
2970
|
-
*/
|
|
2971
|
-
function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
2972
|
-
if (!requests) throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
2973
|
-
switch (method) {
|
|
2974
|
-
case "tools/call":
|
|
2975
|
-
if (!requests.tools?.call) throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
|
|
2976
|
-
break;
|
|
2977
|
-
default:
|
|
2978
|
-
break;
|
|
2979
|
-
}
|
|
2980
|
-
}
|
|
2981
|
-
/**
|
|
2982
|
-
* Asserts that task creation is supported for sampling/createMessage or elicitation/create.
|
|
2983
|
-
* Used by Server.assertTaskCapability and Client.assertTaskHandlerCapability.
|
|
2984
|
-
*
|
|
2985
|
-
* @param requests - The task requests capability object
|
|
2986
|
-
* @param method - The method being checked
|
|
2987
|
-
* @param entityName - 'Server' or 'Client' for error messages
|
|
2988
|
-
* @throws Error if the capability is not supported
|
|
2989
|
-
*
|
|
2990
|
-
* @experimental
|
|
2991
|
-
*/
|
|
2992
|
-
function assertClientRequestTaskCapability(requests, method, entityName) {
|
|
2993
|
-
if (!requests) throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
2994
|
-
switch (method) {
|
|
2995
|
-
case "sampling/createMessage":
|
|
2996
|
-
if (!requests.sampling?.createMessage) throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
|
|
2997
|
-
break;
|
|
2998
|
-
case "elicitation/create":
|
|
2999
|
-
if (!requests.elicitation?.create) throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
|
|
3000
|
-
break;
|
|
3001
|
-
default:
|
|
3002
|
-
break;
|
|
3003
|
-
}
|
|
3004
|
-
}
|
|
3005
|
-
|
|
3006
|
-
//#endregion
|
|
3007
|
-
//#region ../../node_modules/.bun/@modelcontextprotocol+sdk@1.27.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
3008
|
-
/**
|
|
3009
|
-
* An MCP server on top of a pluggable transport.
|
|
3010
|
-
*
|
|
3011
|
-
* This server will automatically respond to the initialization flow as initiated from the client.
|
|
3012
|
-
*
|
|
3013
|
-
* To use with custom types, extend the base Request/Notification/Result types and pass them as type parameters:
|
|
3014
|
-
*
|
|
3015
|
-
* ```typescript
|
|
3016
|
-
* // Custom schemas
|
|
3017
|
-
* const CustomRequestSchema = RequestSchema.extend({...})
|
|
3018
|
-
* const CustomNotificationSchema = NotificationSchema.extend({...})
|
|
3019
|
-
* const CustomResultSchema = ResultSchema.extend({...})
|
|
3020
|
-
*
|
|
3021
|
-
* // Type aliases
|
|
3022
|
-
* type CustomRequest = z.infer<typeof CustomRequestSchema>
|
|
3023
|
-
* type CustomNotification = z.infer<typeof CustomNotificationSchema>
|
|
3024
|
-
* type CustomResult = z.infer<typeof CustomResultSchema>
|
|
3025
|
-
*
|
|
3026
|
-
* // Create typed server
|
|
3027
|
-
* const server = new Server<CustomRequest, CustomNotification, CustomResult>({
|
|
3028
|
-
* name: "CustomServer",
|
|
3029
|
-
* version: "1.0.0"
|
|
3030
|
-
* })
|
|
3031
|
-
* ```
|
|
3032
|
-
* @deprecated Use `McpServer` instead for the high-level API. Only use `Server` for advanced use cases.
|
|
3033
|
-
*/
|
|
3034
|
-
|
|
3035
|
-
/**
|
|
3036
|
-
* Checks if a schema is completable (has completion metadata).
|
|
3037
|
-
*/
|
|
3038
|
-
function isCompletable(schema) {
|
|
3039
|
-
return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
|
|
3040
|
-
}
|
|
3041
|
-
/**
|
|
3042
|
-
* Gets the completer callback from a completable schema, if it exists.
|
|
3043
|
-
*/
|
|
3044
|
-
function getCompleter(schema) {
|
|
3045
|
-
return schema[COMPLETABLE_SYMBOL]?.complete;
|
|
3046
|
-
}
|
|
3047
|
-
/**
|
|
3048
|
-
* Validates a tool name according to the SEP specification
|
|
3049
|
-
* @param name - The tool name to validate
|
|
3050
|
-
* @returns An object containing validation result and any warnings
|
|
3051
|
-
*/
|
|
3052
|
-
function validateToolName(name) {
|
|
3053
|
-
const warnings = [];
|
|
3054
|
-
if (name.length === 0) return {
|
|
3055
|
-
isValid: false,
|
|
3056
|
-
warnings: ["Tool name cannot be empty"]
|
|
3057
|
-
};
|
|
3058
|
-
if (name.length > 128) return {
|
|
3059
|
-
isValid: false,
|
|
3060
|
-
warnings: [`Tool name exceeds maximum length of 128 characters (current: ${name.length})`]
|
|
3061
|
-
};
|
|
3062
|
-
if (name.includes(" ")) warnings.push("Tool name contains spaces, which may cause parsing issues");
|
|
3063
|
-
if (name.includes(",")) warnings.push("Tool name contains commas, which may cause parsing issues");
|
|
3064
|
-
if (name.startsWith("-") || name.endsWith("-")) warnings.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts");
|
|
3065
|
-
if (name.startsWith(".") || name.endsWith(".")) warnings.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts");
|
|
3066
|
-
if (!TOOL_NAME_REGEX.test(name)) {
|
|
3067
|
-
const invalidChars = name.split("").filter(char => !/[A-Za-z0-9._-]/.test(char)).filter((char, index, arr) => arr.indexOf(char) === index);
|
|
3068
|
-
warnings.push(`Tool name contains invalid characters: ${invalidChars.map(c => `"${c}"`).join(", ")}`, "Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)");
|
|
3069
|
-
return {
|
|
3070
|
-
isValid: false,
|
|
3071
|
-
warnings
|
|
3072
|
-
};
|
|
3073
|
-
}
|
|
3074
|
-
return {
|
|
3075
|
-
isValid: true,
|
|
3076
|
-
warnings
|
|
3077
|
-
};
|
|
3078
|
-
}
|
|
3079
|
-
/**
|
|
3080
|
-
* Issues warnings for non-conforming tool names
|
|
3081
|
-
* @param name - The tool name that triggered the warnings
|
|
3082
|
-
* @param warnings - Array of warning messages
|
|
3083
|
-
*/
|
|
3084
|
-
function issueToolNameWarning(name, warnings) {
|
|
3085
|
-
if (warnings.length > 0) {
|
|
3086
|
-
console.warn(`Tool name validation warning for "${name}":`);
|
|
3087
|
-
for (const warning of warnings) console.warn(` - ${warning}`);
|
|
3088
|
-
console.warn("Tool registration will proceed, but this may cause compatibility issues.");
|
|
3089
|
-
console.warn("Consider updating the tool name to conform to the MCP tool naming standard.");
|
|
3090
|
-
console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.");
|
|
3091
|
-
}
|
|
3092
|
-
}
|
|
3093
|
-
/**
|
|
3094
|
-
* Validates a tool name and issues warnings for non-conforming names
|
|
3095
|
-
* @param name - The tool name to validate
|
|
3096
|
-
* @returns true if the name is valid, false otherwise
|
|
3097
|
-
*/
|
|
3098
|
-
function validateAndWarnToolName(name) {
|
|
3099
|
-
const result = validateToolName(name);
|
|
3100
|
-
issueToolNameWarning(name, result.warnings);
|
|
3101
|
-
return result.isValid;
|
|
3102
|
-
}
|
|
3103
|
-
|
|
3104
|
-
//#endregion
|
|
3105
|
-
//#region ../../node_modules/.bun/@modelcontextprotocol+sdk@1.27.1/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
|
|
3106
|
-
/**
|
|
3107
|
-
* Experimental McpServer task features for MCP SDK.
|
|
3108
|
-
* WARNING: These APIs are experimental and may change without notice.
|
|
3109
|
-
*
|
|
3110
|
-
* @experimental
|
|
3111
|
-
*/
|
|
3112
|
-
/**
|
|
3113
|
-
* Experimental task features for McpServer.
|
|
3114
|
-
*
|
|
3115
|
-
* Access via `server.experimental.tasks`:
|
|
3116
|
-
* ```typescript
|
|
3117
|
-
* server.experimental.tasks.registerToolTask('long-running', config, handler);
|
|
3118
|
-
* ```
|
|
3119
|
-
*
|
|
3120
|
-
* @experimental
|
|
3121
|
-
*/
|
|
3122
|
-
|
|
3123
|
-
/**
|
|
3124
|
-
* Checks if a value looks like a Zod schema by checking for parse/safeParse methods.
|
|
3125
|
-
*/
|
|
3126
|
-
function isZodTypeLike(value) {
|
|
3127
|
-
return value !== null && typeof value === "object" && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
|
|
3128
|
-
}
|
|
3129
|
-
/**
|
|
3130
|
-
* Checks if an object is a Zod schema instance (v3 or v4).
|
|
3131
|
-
*
|
|
3132
|
-
* Zod schemas have internal markers:
|
|
3133
|
-
* - v3: `_def` property
|
|
3134
|
-
* - v4: `_zod` property
|
|
3135
|
-
*
|
|
3136
|
-
* This includes transformed schemas like z.preprocess(), z.transform(), z.pipe().
|
|
3137
|
-
*/
|
|
3138
|
-
function isZodSchemaInstance(obj) {
|
|
3139
|
-
return "_def" in obj || "_zod" in obj || isZodTypeLike(obj);
|
|
3140
|
-
}
|
|
3141
|
-
/**
|
|
3142
|
-
* Checks if an object is a "raw shape" - a plain object where values are Zod schemas.
|
|
3143
|
-
*
|
|
3144
|
-
* Raw shapes are used as shorthand: `{ name: z.string() }` instead of `z.object({ name: z.string() })`.
|
|
3145
|
-
*
|
|
3146
|
-
* IMPORTANT: This must NOT match actual Zod schema instances (like z.preprocess, z.pipe),
|
|
3147
|
-
* which have internal properties that could be mistaken for schema values.
|
|
3148
|
-
*/
|
|
3149
|
-
function isZodRawShapeCompat(obj) {
|
|
3150
|
-
if (typeof obj !== "object" || obj === null) return false;
|
|
3151
|
-
if (isZodSchemaInstance(obj)) return false;
|
|
3152
|
-
if (Object.keys(obj).length === 0) return true;
|
|
3153
|
-
return Object.values(obj).some(isZodTypeLike);
|
|
3154
|
-
}
|
|
3155
|
-
/**
|
|
3156
|
-
* Converts a provided Zod schema to a Zod object if it is a ZodRawShapeCompat,
|
|
3157
|
-
* otherwise returns the schema as is.
|
|
3158
|
-
*/
|
|
3159
|
-
function getZodSchemaObject(schema) {
|
|
3160
|
-
if (!schema) return;
|
|
3161
|
-
if (isZodRawShapeCompat(schema)) return objectFromShape(schema);
|
|
3162
|
-
return schema;
|
|
3163
|
-
}
|
|
3164
|
-
function promptArgumentsFromSchema(schema) {
|
|
3165
|
-
const shape = getObjectShape(schema);
|
|
3166
|
-
if (!shape) return [];
|
|
3167
|
-
return Object.entries(shape).map(([name, field]) => {
|
|
3168
|
-
return {
|
|
3169
|
-
name,
|
|
3170
|
-
description: getSchemaDescription(field),
|
|
3171
|
-
required: !isSchemaOptional(field)
|
|
3172
|
-
};
|
|
3173
|
-
});
|
|
3174
|
-
}
|
|
3175
|
-
function getMethodValue(schema) {
|
|
3176
|
-
const methodSchema = getObjectShape(schema)?.method;
|
|
3177
|
-
if (!methodSchema) throw new Error("Schema is missing a method literal");
|
|
3178
|
-
const value = getLiteralValue(methodSchema);
|
|
3179
|
-
if (typeof value === "string") return value;
|
|
3180
|
-
throw new Error("Schema method literal must be a string");
|
|
3181
|
-
}
|
|
3182
|
-
function createCompletionResult(suggestions) {
|
|
3183
|
-
return {
|
|
3184
|
-
completion: {
|
|
3185
|
-
values: suggestions.slice(0, 100),
|
|
3186
|
-
total: suggestions.length,
|
|
3187
|
-
hasMore: suggestions.length > 100
|
|
3188
|
-
}
|
|
3189
|
-
};
|
|
3190
|
-
}
|
|
3191
|
-
function deserializeMessage(line) {
|
|
3192
|
-
return JSONRPCMessageSchema.parse(JSON.parse(line));
|
|
3193
|
-
}
|
|
3194
|
-
function serializeMessage(message) {
|
|
3195
|
-
return JSON.stringify(message) + "\n";
|
|
3196
|
-
}
|
|
3197
|
-
|
|
3198
|
-
//#endregion
|
|
3199
|
-
//#region ../../node_modules/.bun/@modelcontextprotocol+sdk@1.27.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
3200
|
-
/**
|
|
3201
|
-
* Server transport for stdio: this communicates with an MCP client by reading from the current process' stdin and writing to stdout.
|
|
3202
|
-
*
|
|
3203
|
-
* This transport is only available in Node.js environments.
|
|
3204
|
-
*/
|
|
3205
|
-
|
|
3206
|
-
function getContext() {
|
|
3207
|
-
if (!cachedContext || contextCwd !== process.cwd()) {
|
|
3208
|
-
contextCwd = process.cwd();
|
|
3209
|
-
cachedContext = generateContext(contextCwd);
|
|
3210
|
-
}
|
|
3211
|
-
return cachedContext;
|
|
3212
|
-
}
|
|
3213
|
-
function textResult(text) {
|
|
3214
|
-
return {
|
|
3215
|
-
content: [{
|
|
3216
|
-
type: "text",
|
|
3217
|
-
text
|
|
3218
|
-
}]
|
|
3219
|
-
};
|
|
3220
|
-
}
|
|
3221
|
-
async function main() {
|
|
3222
|
-
const transport = new StdioServerTransport();
|
|
3223
|
-
await server.connect(transport);
|
|
3224
|
-
}
|
|
3225
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export { };
|