@tempad-dev/mcp 0.3.12 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +1 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/hub.mjs +102 -3961
- package/dist/hub.mjs.map +1 -1
- package/dist/{shared-cWtEAcwU.mjs → shared-C8rMJ76Z.mjs} +35 -20
- package/dist/shared-C8rMJ76Z.mjs.map +1 -0
- package/package.json +9 -6
- package/dist/shared-cWtEAcwU.mjs.map +0 -1
package/dist/hub.mjs
CHANGED
|
@@ -1,3883 +1,18 @@
|
|
|
1
|
-
import { a as SOCK_PATH, c as log, i as RUNTIME_DIR, o as ensureDir, r as PACKAGE_VERSION, s as ensureFile, t as ASSET_DIR } from "./shared-
|
|
1
|
+
import { a as SOCK_PATH, c as log, i as RUNTIME_DIR, o as ensureDir, r as PACKAGE_VERSION, s as ensureFile, t as ASSET_DIR } from "./shared-C8rMJ76Z.mjs";
|
|
2
2
|
import { createServer } from "node:net";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { URL
|
|
4
|
+
import { URL } from "node:url";
|
|
5
5
|
import { chmodSync, createReadStream, createWriteStream, existsSync, readFileSync, readdirSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
7
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8
|
+
import { z } from "zod";
|
|
8
9
|
import { nanoid } from "nanoid";
|
|
9
10
|
import { WebSocketServer } from "ws";
|
|
10
11
|
import { createHash } from "node:crypto";
|
|
11
12
|
import { createServer as createServer$1 } from "node:http";
|
|
12
13
|
import { Transform, pipeline } from "node:stream";
|
|
13
14
|
|
|
14
|
-
//#region
|
|
15
|
-
/** A special constant with type `never` */
|
|
16
|
-
const NEVER = Object.freeze({ status: "aborted" });
|
|
17
|
-
function $constructor(name, initializer$2, params) {
|
|
18
|
-
function init(inst, def) {
|
|
19
|
-
if (!inst._zod) Object.defineProperty(inst, "_zod", {
|
|
20
|
-
value: {
|
|
21
|
-
def,
|
|
22
|
-
constr: _,
|
|
23
|
-
traits: /* @__PURE__ */ new Set()
|
|
24
|
-
},
|
|
25
|
-
enumerable: false
|
|
26
|
-
});
|
|
27
|
-
if (inst._zod.traits.has(name)) return;
|
|
28
|
-
inst._zod.traits.add(name);
|
|
29
|
-
initializer$2(inst, def);
|
|
30
|
-
const proto = _.prototype;
|
|
31
|
-
const keys = Object.keys(proto);
|
|
32
|
-
for (let i = 0; i < keys.length; i++) {
|
|
33
|
-
const k = keys[i];
|
|
34
|
-
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const Parent = params?.Parent ?? Object;
|
|
38
|
-
class Definition extends Parent {}
|
|
39
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
40
|
-
function _(def) {
|
|
41
|
-
var _a$1;
|
|
42
|
-
const inst = params?.Parent ? new Definition() : this;
|
|
43
|
-
init(inst, def);
|
|
44
|
-
(_a$1 = inst._zod).deferred ?? (_a$1.deferred = []);
|
|
45
|
-
for (const fn of inst._zod.deferred) fn();
|
|
46
|
-
return inst;
|
|
47
|
-
}
|
|
48
|
-
Object.defineProperty(_, "init", { value: init });
|
|
49
|
-
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
50
|
-
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
51
|
-
return inst?._zod?.traits?.has(name);
|
|
52
|
-
} });
|
|
53
|
-
Object.defineProperty(_, "name", { value: name });
|
|
54
|
-
return _;
|
|
55
|
-
}
|
|
56
|
-
var $ZodAsyncError = class extends Error {
|
|
57
|
-
constructor() {
|
|
58
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
var $ZodEncodeError = class extends Error {
|
|
62
|
-
constructor(name) {
|
|
63
|
-
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
64
|
-
this.name = "ZodEncodeError";
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const globalConfig = {};
|
|
68
|
-
function config(newConfig) {
|
|
69
|
-
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
70
|
-
return globalConfig;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
//#endregion
|
|
74
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/util.js
|
|
75
|
-
function getEnumValues(entries) {
|
|
76
|
-
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
77
|
-
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
78
|
-
}
|
|
79
|
-
function jsonStringifyReplacer(_, value) {
|
|
80
|
-
if (typeof value === "bigint") return value.toString();
|
|
81
|
-
return value;
|
|
82
|
-
}
|
|
83
|
-
function cached(getter) {
|
|
84
|
-
return { get value() {
|
|
85
|
-
{
|
|
86
|
-
const value = getter();
|
|
87
|
-
Object.defineProperty(this, "value", { value });
|
|
88
|
-
return value;
|
|
89
|
-
}
|
|
90
|
-
throw new Error("cached value already set");
|
|
91
|
-
} };
|
|
92
|
-
}
|
|
93
|
-
function nullish(input) {
|
|
94
|
-
return input === null || input === void 0;
|
|
95
|
-
}
|
|
96
|
-
function cleanRegex(source) {
|
|
97
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
98
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
99
|
-
return source.slice(start, end);
|
|
100
|
-
}
|
|
101
|
-
function floatSafeRemainder(val, step) {
|
|
102
|
-
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
103
|
-
const stepString = step.toString();
|
|
104
|
-
let stepDecCount = (stepString.split(".")[1] || "").length;
|
|
105
|
-
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
|
|
106
|
-
const match = stepString.match(/\d?e-(\d?)/);
|
|
107
|
-
if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
|
|
108
|
-
}
|
|
109
|
-
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
110
|
-
return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
|
|
111
|
-
}
|
|
112
|
-
const EVALUATING = Symbol("evaluating");
|
|
113
|
-
function defineLazy(object$1, key, getter) {
|
|
114
|
-
let value = void 0;
|
|
115
|
-
Object.defineProperty(object$1, key, {
|
|
116
|
-
get() {
|
|
117
|
-
if (value === EVALUATING) return;
|
|
118
|
-
if (value === void 0) {
|
|
119
|
-
value = EVALUATING;
|
|
120
|
-
value = getter();
|
|
121
|
-
}
|
|
122
|
-
return value;
|
|
123
|
-
},
|
|
124
|
-
set(v) {
|
|
125
|
-
Object.defineProperty(object$1, key, { value: v });
|
|
126
|
-
},
|
|
127
|
-
configurable: true
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
function assignProp(target, prop, value) {
|
|
131
|
-
Object.defineProperty(target, prop, {
|
|
132
|
-
value,
|
|
133
|
-
writable: true,
|
|
134
|
-
enumerable: true,
|
|
135
|
-
configurable: true
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
function mergeDefs(...defs) {
|
|
139
|
-
const mergedDescriptors = {};
|
|
140
|
-
for (const def of defs) {
|
|
141
|
-
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
142
|
-
Object.assign(mergedDescriptors, descriptors);
|
|
143
|
-
}
|
|
144
|
-
return Object.defineProperties({}, mergedDescriptors);
|
|
145
|
-
}
|
|
146
|
-
function esc(str) {
|
|
147
|
-
return JSON.stringify(str);
|
|
148
|
-
}
|
|
149
|
-
function slugify(input) {
|
|
150
|
-
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
151
|
-
}
|
|
152
|
-
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
153
|
-
function isObject(data) {
|
|
154
|
-
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
155
|
-
}
|
|
156
|
-
const allowsEval = cached(() => {
|
|
157
|
-
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
|
|
158
|
-
try {
|
|
159
|
-
new Function("");
|
|
160
|
-
return true;
|
|
161
|
-
} catch (_) {
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
function isPlainObject(o) {
|
|
166
|
-
if (isObject(o) === false) return false;
|
|
167
|
-
const ctor = o.constructor;
|
|
168
|
-
if (ctor === void 0) return true;
|
|
169
|
-
if (typeof ctor !== "function") return true;
|
|
170
|
-
const prot = ctor.prototype;
|
|
171
|
-
if (isObject(prot) === false) return false;
|
|
172
|
-
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
function shallowClone(o) {
|
|
176
|
-
if (isPlainObject(o)) return { ...o };
|
|
177
|
-
if (Array.isArray(o)) return [...o];
|
|
178
|
-
return o;
|
|
179
|
-
}
|
|
180
|
-
const propertyKeyTypes = new Set([
|
|
181
|
-
"string",
|
|
182
|
-
"number",
|
|
183
|
-
"symbol"
|
|
184
|
-
]);
|
|
185
|
-
function escapeRegex(str) {
|
|
186
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
187
|
-
}
|
|
188
|
-
function clone(inst, def, params) {
|
|
189
|
-
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
190
|
-
if (!def || params?.parent) cl._zod.parent = inst;
|
|
191
|
-
return cl;
|
|
192
|
-
}
|
|
193
|
-
function normalizeParams(_params) {
|
|
194
|
-
const params = _params;
|
|
195
|
-
if (!params) return {};
|
|
196
|
-
if (typeof params === "string") return { error: () => params };
|
|
197
|
-
if (params?.message !== void 0) {
|
|
198
|
-
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
|
199
|
-
params.error = params.message;
|
|
200
|
-
}
|
|
201
|
-
delete params.message;
|
|
202
|
-
if (typeof params.error === "string") return {
|
|
203
|
-
...params,
|
|
204
|
-
error: () => params.error
|
|
205
|
-
};
|
|
206
|
-
return params;
|
|
207
|
-
}
|
|
208
|
-
function optionalKeys(shape) {
|
|
209
|
-
return Object.keys(shape).filter((k) => {
|
|
210
|
-
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
const NUMBER_FORMAT_RANGES = {
|
|
214
|
-
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
215
|
-
int32: [-2147483648, 2147483647],
|
|
216
|
-
uint32: [0, 4294967295],
|
|
217
|
-
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
218
|
-
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
219
|
-
};
|
|
220
|
-
function pick(schema, mask) {
|
|
221
|
-
const currDef = schema._zod.def;
|
|
222
|
-
const checks = currDef.checks;
|
|
223
|
-
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
224
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
225
|
-
get shape() {
|
|
226
|
-
const newShape = {};
|
|
227
|
-
for (const key in mask) {
|
|
228
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
229
|
-
if (!mask[key]) continue;
|
|
230
|
-
newShape[key] = currDef.shape[key];
|
|
231
|
-
}
|
|
232
|
-
assignProp(this, "shape", newShape);
|
|
233
|
-
return newShape;
|
|
234
|
-
},
|
|
235
|
-
checks: []
|
|
236
|
-
}));
|
|
237
|
-
}
|
|
238
|
-
function omit(schema, mask) {
|
|
239
|
-
const currDef = schema._zod.def;
|
|
240
|
-
const checks = currDef.checks;
|
|
241
|
-
if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
242
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
243
|
-
get shape() {
|
|
244
|
-
const newShape = { ...schema._zod.def.shape };
|
|
245
|
-
for (const key in mask) {
|
|
246
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
247
|
-
if (!mask[key]) continue;
|
|
248
|
-
delete newShape[key];
|
|
249
|
-
}
|
|
250
|
-
assignProp(this, "shape", newShape);
|
|
251
|
-
return newShape;
|
|
252
|
-
},
|
|
253
|
-
checks: []
|
|
254
|
-
}));
|
|
255
|
-
}
|
|
256
|
-
function extend(schema, shape) {
|
|
257
|
-
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
258
|
-
const checks = schema._zod.def.checks;
|
|
259
|
-
if (checks && checks.length > 0) {
|
|
260
|
-
const existingShape = schema._zod.def.shape;
|
|
261
|
-
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.");
|
|
262
|
-
}
|
|
263
|
-
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
264
|
-
const _shape = {
|
|
265
|
-
...schema._zod.def.shape,
|
|
266
|
-
...shape
|
|
267
|
-
};
|
|
268
|
-
assignProp(this, "shape", _shape);
|
|
269
|
-
return _shape;
|
|
270
|
-
} }));
|
|
271
|
-
}
|
|
272
|
-
function safeExtend(schema, shape) {
|
|
273
|
-
if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
274
|
-
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
275
|
-
const _shape = {
|
|
276
|
-
...schema._zod.def.shape,
|
|
277
|
-
...shape
|
|
278
|
-
};
|
|
279
|
-
assignProp(this, "shape", _shape);
|
|
280
|
-
return _shape;
|
|
281
|
-
} }));
|
|
282
|
-
}
|
|
283
|
-
function merge(a, b) {
|
|
284
|
-
return clone(a, mergeDefs(a._zod.def, {
|
|
285
|
-
get shape() {
|
|
286
|
-
const _shape = {
|
|
287
|
-
...a._zod.def.shape,
|
|
288
|
-
...b._zod.def.shape
|
|
289
|
-
};
|
|
290
|
-
assignProp(this, "shape", _shape);
|
|
291
|
-
return _shape;
|
|
292
|
-
},
|
|
293
|
-
get catchall() {
|
|
294
|
-
return b._zod.def.catchall;
|
|
295
|
-
},
|
|
296
|
-
checks: []
|
|
297
|
-
}));
|
|
298
|
-
}
|
|
299
|
-
function partial(Class, schema, mask) {
|
|
300
|
-
const checks = schema._zod.def.checks;
|
|
301
|
-
if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
302
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
303
|
-
get shape() {
|
|
304
|
-
const oldShape = schema._zod.def.shape;
|
|
305
|
-
const shape = { ...oldShape };
|
|
306
|
-
if (mask) for (const key in mask) {
|
|
307
|
-
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
308
|
-
if (!mask[key]) continue;
|
|
309
|
-
shape[key] = Class ? new Class({
|
|
310
|
-
type: "optional",
|
|
311
|
-
innerType: oldShape[key]
|
|
312
|
-
}) : oldShape[key];
|
|
313
|
-
}
|
|
314
|
-
else for (const key in oldShape) shape[key] = Class ? new Class({
|
|
315
|
-
type: "optional",
|
|
316
|
-
innerType: oldShape[key]
|
|
317
|
-
}) : oldShape[key];
|
|
318
|
-
assignProp(this, "shape", shape);
|
|
319
|
-
return shape;
|
|
320
|
-
},
|
|
321
|
-
checks: []
|
|
322
|
-
}));
|
|
323
|
-
}
|
|
324
|
-
function required(Class, schema, mask) {
|
|
325
|
-
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
326
|
-
const oldShape = schema._zod.def.shape;
|
|
327
|
-
const shape = { ...oldShape };
|
|
328
|
-
if (mask) for (const key in mask) {
|
|
329
|
-
if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
330
|
-
if (!mask[key]) continue;
|
|
331
|
-
shape[key] = new Class({
|
|
332
|
-
type: "nonoptional",
|
|
333
|
-
innerType: oldShape[key]
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
else for (const key in oldShape) shape[key] = new Class({
|
|
337
|
-
type: "nonoptional",
|
|
338
|
-
innerType: oldShape[key]
|
|
339
|
-
});
|
|
340
|
-
assignProp(this, "shape", shape);
|
|
341
|
-
return shape;
|
|
342
|
-
} }));
|
|
343
|
-
}
|
|
344
|
-
function aborted(x, startIndex = 0) {
|
|
345
|
-
if (x.aborted === true) return true;
|
|
346
|
-
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
|
|
347
|
-
return false;
|
|
348
|
-
}
|
|
349
|
-
function prefixIssues(path, issues) {
|
|
350
|
-
return issues.map((iss) => {
|
|
351
|
-
var _a$1;
|
|
352
|
-
(_a$1 = iss).path ?? (_a$1.path = []);
|
|
353
|
-
iss.path.unshift(path);
|
|
354
|
-
return iss;
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
function unwrapMessage(message) {
|
|
358
|
-
return typeof message === "string" ? message : message?.message;
|
|
359
|
-
}
|
|
360
|
-
function finalizeIssue(iss, ctx, config$1) {
|
|
361
|
-
const full = {
|
|
362
|
-
...iss,
|
|
363
|
-
path: iss.path ?? []
|
|
364
|
-
};
|
|
365
|
-
if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config$1.customError?.(iss)) ?? unwrapMessage(config$1.localeError?.(iss)) ?? "Invalid input";
|
|
366
|
-
delete full.inst;
|
|
367
|
-
delete full.continue;
|
|
368
|
-
if (!ctx?.reportInput) delete full.input;
|
|
369
|
-
return full;
|
|
370
|
-
}
|
|
371
|
-
function getLengthableOrigin(input) {
|
|
372
|
-
if (Array.isArray(input)) return "array";
|
|
373
|
-
if (typeof input === "string") return "string";
|
|
374
|
-
return "unknown";
|
|
375
|
-
}
|
|
376
|
-
function issue(...args) {
|
|
377
|
-
const [iss, input, inst] = args;
|
|
378
|
-
if (typeof iss === "string") return {
|
|
379
|
-
message: iss,
|
|
380
|
-
code: "custom",
|
|
381
|
-
input,
|
|
382
|
-
inst
|
|
383
|
-
};
|
|
384
|
-
return { ...iss };
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
//#endregion
|
|
388
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/errors.js
|
|
389
|
-
const initializer$1 = (inst, def) => {
|
|
390
|
-
inst.name = "$ZodError";
|
|
391
|
-
Object.defineProperty(inst, "_zod", {
|
|
392
|
-
value: inst._zod,
|
|
393
|
-
enumerable: false
|
|
394
|
-
});
|
|
395
|
-
Object.defineProperty(inst, "issues", {
|
|
396
|
-
value: def,
|
|
397
|
-
enumerable: false
|
|
398
|
-
});
|
|
399
|
-
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
400
|
-
Object.defineProperty(inst, "toString", {
|
|
401
|
-
value: () => inst.message,
|
|
402
|
-
enumerable: false
|
|
403
|
-
});
|
|
404
|
-
};
|
|
405
|
-
const $ZodError = $constructor("$ZodError", initializer$1);
|
|
406
|
-
const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
|
|
407
|
-
function flattenError(error, mapper = (issue$1) => issue$1.message) {
|
|
408
|
-
const fieldErrors = {};
|
|
409
|
-
const formErrors = [];
|
|
410
|
-
for (const sub of error.issues) if (sub.path.length > 0) {
|
|
411
|
-
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
412
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
413
|
-
} else formErrors.push(mapper(sub));
|
|
414
|
-
return {
|
|
415
|
-
formErrors,
|
|
416
|
-
fieldErrors
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
function formatError(error, mapper = (issue$1) => issue$1.message) {
|
|
420
|
-
const fieldErrors = { _errors: [] };
|
|
421
|
-
const processError = (error$1) => {
|
|
422
|
-
for (const issue$1 of error$1.issues) if (issue$1.code === "invalid_union" && issue$1.errors.length) issue$1.errors.map((issues) => processError({ issues }));
|
|
423
|
-
else if (issue$1.code === "invalid_key") processError({ issues: issue$1.issues });
|
|
424
|
-
else if (issue$1.code === "invalid_element") processError({ issues: issue$1.issues });
|
|
425
|
-
else if (issue$1.path.length === 0) fieldErrors._errors.push(mapper(issue$1));
|
|
426
|
-
else {
|
|
427
|
-
let curr = fieldErrors;
|
|
428
|
-
let i = 0;
|
|
429
|
-
while (i < issue$1.path.length) {
|
|
430
|
-
const el = issue$1.path[i];
|
|
431
|
-
if (!(i === issue$1.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
|
|
432
|
-
else {
|
|
433
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
434
|
-
curr[el]._errors.push(mapper(issue$1));
|
|
435
|
-
}
|
|
436
|
-
curr = curr[el];
|
|
437
|
-
i++;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
processError(error);
|
|
442
|
-
return fieldErrors;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
//#endregion
|
|
446
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/parse.js
|
|
447
|
-
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
448
|
-
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
|
449
|
-
const result = schema._zod.run({
|
|
450
|
-
value,
|
|
451
|
-
issues: []
|
|
452
|
-
}, ctx);
|
|
453
|
-
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
454
|
-
if (result.issues.length) {
|
|
455
|
-
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
456
|
-
captureStackTrace(e, _params?.callee);
|
|
457
|
-
throw e;
|
|
458
|
-
}
|
|
459
|
-
return result.value;
|
|
460
|
-
};
|
|
461
|
-
const parse$1 = /* @__PURE__ */ _parse($ZodRealError);
|
|
462
|
-
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
463
|
-
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
464
|
-
let result = schema._zod.run({
|
|
465
|
-
value,
|
|
466
|
-
issues: []
|
|
467
|
-
}, ctx);
|
|
468
|
-
if (result instanceof Promise) result = await result;
|
|
469
|
-
if (result.issues.length) {
|
|
470
|
-
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
471
|
-
captureStackTrace(e, params?.callee);
|
|
472
|
-
throw e;
|
|
473
|
-
}
|
|
474
|
-
return result.value;
|
|
475
|
-
};
|
|
476
|
-
const parseAsync$1 = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
477
|
-
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
478
|
-
const ctx = _ctx ? {
|
|
479
|
-
..._ctx,
|
|
480
|
-
async: false
|
|
481
|
-
} : { async: false };
|
|
482
|
-
const result = schema._zod.run({
|
|
483
|
-
value,
|
|
484
|
-
issues: []
|
|
485
|
-
}, ctx);
|
|
486
|
-
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
487
|
-
return result.issues.length ? {
|
|
488
|
-
success: false,
|
|
489
|
-
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
490
|
-
} : {
|
|
491
|
-
success: true,
|
|
492
|
-
data: result.value
|
|
493
|
-
};
|
|
494
|
-
};
|
|
495
|
-
const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
496
|
-
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
497
|
-
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
498
|
-
let result = schema._zod.run({
|
|
499
|
-
value,
|
|
500
|
-
issues: []
|
|
501
|
-
}, ctx);
|
|
502
|
-
if (result instanceof Promise) result = await result;
|
|
503
|
-
return result.issues.length ? {
|
|
504
|
-
success: false,
|
|
505
|
-
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
506
|
-
} : {
|
|
507
|
-
success: true,
|
|
508
|
-
data: result.value
|
|
509
|
-
};
|
|
510
|
-
};
|
|
511
|
-
const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
512
|
-
const _encode = (_Err) => (schema, value, _ctx) => {
|
|
513
|
-
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
514
|
-
return _parse(_Err)(schema, value, ctx);
|
|
515
|
-
};
|
|
516
|
-
const encode$1 = /* @__PURE__ */ _encode($ZodRealError);
|
|
517
|
-
const _decode = (_Err) => (schema, value, _ctx) => {
|
|
518
|
-
return _parse(_Err)(schema, value, _ctx);
|
|
519
|
-
};
|
|
520
|
-
const decode$1 = /* @__PURE__ */ _decode($ZodRealError);
|
|
521
|
-
const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
522
|
-
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
523
|
-
return _parseAsync(_Err)(schema, value, ctx);
|
|
524
|
-
};
|
|
525
|
-
const encodeAsync$1 = /* @__PURE__ */ _encodeAsync($ZodRealError);
|
|
526
|
-
const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
527
|
-
return _parseAsync(_Err)(schema, value, _ctx);
|
|
528
|
-
};
|
|
529
|
-
const decodeAsync$1 = /* @__PURE__ */ _decodeAsync($ZodRealError);
|
|
530
|
-
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
531
|
-
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
532
|
-
return _safeParse(_Err)(schema, value, ctx);
|
|
533
|
-
};
|
|
534
|
-
const safeEncode$1 = /* @__PURE__ */ _safeEncode($ZodRealError);
|
|
535
|
-
const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
536
|
-
return _safeParse(_Err)(schema, value, _ctx);
|
|
537
|
-
};
|
|
538
|
-
const safeDecode$1 = /* @__PURE__ */ _safeDecode($ZodRealError);
|
|
539
|
-
const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
540
|
-
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
541
|
-
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
542
|
-
};
|
|
543
|
-
const safeEncodeAsync$1 = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
|
|
544
|
-
const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
545
|
-
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
546
|
-
};
|
|
547
|
-
const safeDecodeAsync$1 = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
|
|
548
|
-
|
|
549
|
-
//#endregion
|
|
550
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/regexes.js
|
|
551
|
-
const cuid = /^[cC][^\s-]{8,}$/;
|
|
552
|
-
const cuid2 = /^[0-9a-z]+$/;
|
|
553
|
-
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
554
|
-
const xid = /^[0-9a-vA-V]{20}$/;
|
|
555
|
-
const ksuid = /^[A-Za-z0-9]{27}$/;
|
|
556
|
-
const nanoid$1 = /^[a-zA-Z0-9_-]{21}$/;
|
|
557
|
-
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
|
558
|
-
const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
559
|
-
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
560
|
-
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
561
|
-
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
562
|
-
*
|
|
563
|
-
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
|
564
|
-
const uuid = (version$1) => {
|
|
565
|
-
if (!version$1) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
566
|
-
return /* @__PURE__ */ new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version$1}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
567
|
-
};
|
|
568
|
-
/** Practical email validation */
|
|
569
|
-
const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
570
|
-
const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
571
|
-
function emoji() {
|
|
572
|
-
return new RegExp(_emoji$1, "u");
|
|
573
|
-
}
|
|
574
|
-
const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
575
|
-
const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
576
|
-
const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
577
|
-
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
578
|
-
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
579
|
-
const base64url = /^[A-Za-z0-9_-]*$/;
|
|
580
|
-
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
581
|
-
const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
582
|
-
const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
583
|
-
function timeSource(args) {
|
|
584
|
-
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
585
|
-
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+)?)?`;
|
|
586
|
-
}
|
|
587
|
-
function time$1(args) {
|
|
588
|
-
return /* @__PURE__ */ new RegExp(`^${timeSource(args)}$`);
|
|
589
|
-
}
|
|
590
|
-
function datetime$1(args) {
|
|
591
|
-
const time$2 = timeSource({ precision: args.precision });
|
|
592
|
-
const opts = ["Z"];
|
|
593
|
-
if (args.local) opts.push("");
|
|
594
|
-
if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
595
|
-
const timeRegex = `${time$2}(?:${opts.join("|")})`;
|
|
596
|
-
return /* @__PURE__ */ new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
597
|
-
}
|
|
598
|
-
const string$1 = (params) => {
|
|
599
|
-
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
600
|
-
return /* @__PURE__ */ new RegExp(`^${regex}$`);
|
|
601
|
-
};
|
|
602
|
-
const integer = /^-?\d+$/;
|
|
603
|
-
const number$1 = /^-?\d+(?:\.\d+)?$/;
|
|
604
|
-
const boolean$1 = /^(?:true|false)$/i;
|
|
605
|
-
const lowercase = /^[^A-Z]*$/;
|
|
606
|
-
const uppercase = /^[^a-z]*$/;
|
|
607
|
-
|
|
608
|
-
//#endregion
|
|
609
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/checks.js
|
|
610
|
-
const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
611
|
-
var _a$1;
|
|
612
|
-
inst._zod ?? (inst._zod = {});
|
|
613
|
-
inst._zod.def = def;
|
|
614
|
-
(_a$1 = inst._zod).onattach ?? (_a$1.onattach = []);
|
|
615
|
-
});
|
|
616
|
-
const numericOriginMap = {
|
|
617
|
-
number: "number",
|
|
618
|
-
bigint: "bigint",
|
|
619
|
-
object: "date"
|
|
620
|
-
};
|
|
621
|
-
const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
622
|
-
$ZodCheck.init(inst, def);
|
|
623
|
-
const origin = numericOriginMap[typeof def.value];
|
|
624
|
-
inst._zod.onattach.push((inst$1) => {
|
|
625
|
-
const bag = inst$1._zod.bag;
|
|
626
|
-
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
627
|
-
if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
|
|
628
|
-
else bag.exclusiveMaximum = def.value;
|
|
629
|
-
});
|
|
630
|
-
inst._zod.check = (payload) => {
|
|
631
|
-
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
|
|
632
|
-
payload.issues.push({
|
|
633
|
-
origin,
|
|
634
|
-
code: "too_big",
|
|
635
|
-
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
636
|
-
input: payload.value,
|
|
637
|
-
inclusive: def.inclusive,
|
|
638
|
-
inst,
|
|
639
|
-
continue: !def.abort
|
|
640
|
-
});
|
|
641
|
-
};
|
|
642
|
-
});
|
|
643
|
-
const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
644
|
-
$ZodCheck.init(inst, def);
|
|
645
|
-
const origin = numericOriginMap[typeof def.value];
|
|
646
|
-
inst._zod.onattach.push((inst$1) => {
|
|
647
|
-
const bag = inst$1._zod.bag;
|
|
648
|
-
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
649
|
-
if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
|
|
650
|
-
else bag.exclusiveMinimum = def.value;
|
|
651
|
-
});
|
|
652
|
-
inst._zod.check = (payload) => {
|
|
653
|
-
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
|
|
654
|
-
payload.issues.push({
|
|
655
|
-
origin,
|
|
656
|
-
code: "too_small",
|
|
657
|
-
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
658
|
-
input: payload.value,
|
|
659
|
-
inclusive: def.inclusive,
|
|
660
|
-
inst,
|
|
661
|
-
continue: !def.abort
|
|
662
|
-
});
|
|
663
|
-
};
|
|
664
|
-
});
|
|
665
|
-
const $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
666
|
-
$ZodCheck.init(inst, def);
|
|
667
|
-
inst._zod.onattach.push((inst$1) => {
|
|
668
|
-
var _a$1;
|
|
669
|
-
(_a$1 = inst$1._zod.bag).multipleOf ?? (_a$1.multipleOf = def.value);
|
|
670
|
-
});
|
|
671
|
-
inst._zod.check = (payload) => {
|
|
672
|
-
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
673
|
-
if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
|
|
674
|
-
payload.issues.push({
|
|
675
|
-
origin: typeof payload.value,
|
|
676
|
-
code: "not_multiple_of",
|
|
677
|
-
divisor: def.value,
|
|
678
|
-
input: payload.value,
|
|
679
|
-
inst,
|
|
680
|
-
continue: !def.abort
|
|
681
|
-
});
|
|
682
|
-
};
|
|
683
|
-
});
|
|
684
|
-
const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
|
|
685
|
-
$ZodCheck.init(inst, def);
|
|
686
|
-
def.format = def.format || "float64";
|
|
687
|
-
const isInt = def.format?.includes("int");
|
|
688
|
-
const origin = isInt ? "int" : "number";
|
|
689
|
-
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
690
|
-
inst._zod.onattach.push((inst$1) => {
|
|
691
|
-
const bag = inst$1._zod.bag;
|
|
692
|
-
bag.format = def.format;
|
|
693
|
-
bag.minimum = minimum;
|
|
694
|
-
bag.maximum = maximum;
|
|
695
|
-
if (isInt) bag.pattern = integer;
|
|
696
|
-
});
|
|
697
|
-
inst._zod.check = (payload) => {
|
|
698
|
-
const input = payload.value;
|
|
699
|
-
if (isInt) {
|
|
700
|
-
if (!Number.isInteger(input)) {
|
|
701
|
-
payload.issues.push({
|
|
702
|
-
expected: origin,
|
|
703
|
-
format: def.format,
|
|
704
|
-
code: "invalid_type",
|
|
705
|
-
continue: false,
|
|
706
|
-
input,
|
|
707
|
-
inst
|
|
708
|
-
});
|
|
709
|
-
return;
|
|
710
|
-
}
|
|
711
|
-
if (!Number.isSafeInteger(input)) {
|
|
712
|
-
if (input > 0) payload.issues.push({
|
|
713
|
-
input,
|
|
714
|
-
code: "too_big",
|
|
715
|
-
maximum: Number.MAX_SAFE_INTEGER,
|
|
716
|
-
note: "Integers must be within the safe integer range.",
|
|
717
|
-
inst,
|
|
718
|
-
origin,
|
|
719
|
-
inclusive: true,
|
|
720
|
-
continue: !def.abort
|
|
721
|
-
});
|
|
722
|
-
else payload.issues.push({
|
|
723
|
-
input,
|
|
724
|
-
code: "too_small",
|
|
725
|
-
minimum: Number.MIN_SAFE_INTEGER,
|
|
726
|
-
note: "Integers must be within the safe integer range.",
|
|
727
|
-
inst,
|
|
728
|
-
origin,
|
|
729
|
-
inclusive: true,
|
|
730
|
-
continue: !def.abort
|
|
731
|
-
});
|
|
732
|
-
return;
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
if (input < minimum) payload.issues.push({
|
|
736
|
-
origin: "number",
|
|
737
|
-
input,
|
|
738
|
-
code: "too_small",
|
|
739
|
-
minimum,
|
|
740
|
-
inclusive: true,
|
|
741
|
-
inst,
|
|
742
|
-
continue: !def.abort
|
|
743
|
-
});
|
|
744
|
-
if (input > maximum) payload.issues.push({
|
|
745
|
-
origin: "number",
|
|
746
|
-
input,
|
|
747
|
-
code: "too_big",
|
|
748
|
-
maximum,
|
|
749
|
-
inclusive: true,
|
|
750
|
-
inst,
|
|
751
|
-
continue: !def.abort
|
|
752
|
-
});
|
|
753
|
-
};
|
|
754
|
-
});
|
|
755
|
-
const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
756
|
-
var _a$1;
|
|
757
|
-
$ZodCheck.init(inst, def);
|
|
758
|
-
(_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
|
|
759
|
-
const val = payload.value;
|
|
760
|
-
return !nullish(val) && val.length !== void 0;
|
|
761
|
-
});
|
|
762
|
-
inst._zod.onattach.push((inst$1) => {
|
|
763
|
-
const curr = inst$1._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
764
|
-
if (def.maximum < curr) inst$1._zod.bag.maximum = def.maximum;
|
|
765
|
-
});
|
|
766
|
-
inst._zod.check = (payload) => {
|
|
767
|
-
const input = payload.value;
|
|
768
|
-
if (input.length <= def.maximum) return;
|
|
769
|
-
const origin = getLengthableOrigin(input);
|
|
770
|
-
payload.issues.push({
|
|
771
|
-
origin,
|
|
772
|
-
code: "too_big",
|
|
773
|
-
maximum: def.maximum,
|
|
774
|
-
inclusive: true,
|
|
775
|
-
input,
|
|
776
|
-
inst,
|
|
777
|
-
continue: !def.abort
|
|
778
|
-
});
|
|
779
|
-
};
|
|
780
|
-
});
|
|
781
|
-
const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
782
|
-
var _a$1;
|
|
783
|
-
$ZodCheck.init(inst, def);
|
|
784
|
-
(_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
|
|
785
|
-
const val = payload.value;
|
|
786
|
-
return !nullish(val) && val.length !== void 0;
|
|
787
|
-
});
|
|
788
|
-
inst._zod.onattach.push((inst$1) => {
|
|
789
|
-
const curr = inst$1._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
790
|
-
if (def.minimum > curr) inst$1._zod.bag.minimum = def.minimum;
|
|
791
|
-
});
|
|
792
|
-
inst._zod.check = (payload) => {
|
|
793
|
-
const input = payload.value;
|
|
794
|
-
if (input.length >= def.minimum) return;
|
|
795
|
-
const origin = getLengthableOrigin(input);
|
|
796
|
-
payload.issues.push({
|
|
797
|
-
origin,
|
|
798
|
-
code: "too_small",
|
|
799
|
-
minimum: def.minimum,
|
|
800
|
-
inclusive: true,
|
|
801
|
-
input,
|
|
802
|
-
inst,
|
|
803
|
-
continue: !def.abort
|
|
804
|
-
});
|
|
805
|
-
};
|
|
806
|
-
});
|
|
807
|
-
const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
808
|
-
var _a$1;
|
|
809
|
-
$ZodCheck.init(inst, def);
|
|
810
|
-
(_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
|
|
811
|
-
const val = payload.value;
|
|
812
|
-
return !nullish(val) && val.length !== void 0;
|
|
813
|
-
});
|
|
814
|
-
inst._zod.onattach.push((inst$1) => {
|
|
815
|
-
const bag = inst$1._zod.bag;
|
|
816
|
-
bag.minimum = def.length;
|
|
817
|
-
bag.maximum = def.length;
|
|
818
|
-
bag.length = def.length;
|
|
819
|
-
});
|
|
820
|
-
inst._zod.check = (payload) => {
|
|
821
|
-
const input = payload.value;
|
|
822
|
-
const length = input.length;
|
|
823
|
-
if (length === def.length) return;
|
|
824
|
-
const origin = getLengthableOrigin(input);
|
|
825
|
-
const tooBig = length > def.length;
|
|
826
|
-
payload.issues.push({
|
|
827
|
-
origin,
|
|
828
|
-
...tooBig ? {
|
|
829
|
-
code: "too_big",
|
|
830
|
-
maximum: def.length
|
|
831
|
-
} : {
|
|
832
|
-
code: "too_small",
|
|
833
|
-
minimum: def.length
|
|
834
|
-
},
|
|
835
|
-
inclusive: true,
|
|
836
|
-
exact: true,
|
|
837
|
-
input: payload.value,
|
|
838
|
-
inst,
|
|
839
|
-
continue: !def.abort
|
|
840
|
-
});
|
|
841
|
-
};
|
|
842
|
-
});
|
|
843
|
-
const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
844
|
-
var _a$1, _b;
|
|
845
|
-
$ZodCheck.init(inst, def);
|
|
846
|
-
inst._zod.onattach.push((inst$1) => {
|
|
847
|
-
const bag = inst$1._zod.bag;
|
|
848
|
-
bag.format = def.format;
|
|
849
|
-
if (def.pattern) {
|
|
850
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
851
|
-
bag.patterns.add(def.pattern);
|
|
852
|
-
}
|
|
853
|
-
});
|
|
854
|
-
if (def.pattern) (_a$1 = inst._zod).check ?? (_a$1.check = (payload) => {
|
|
855
|
-
def.pattern.lastIndex = 0;
|
|
856
|
-
if (def.pattern.test(payload.value)) return;
|
|
857
|
-
payload.issues.push({
|
|
858
|
-
origin: "string",
|
|
859
|
-
code: "invalid_format",
|
|
860
|
-
format: def.format,
|
|
861
|
-
input: payload.value,
|
|
862
|
-
...def.pattern ? { pattern: def.pattern.toString() } : {},
|
|
863
|
-
inst,
|
|
864
|
-
continue: !def.abort
|
|
865
|
-
});
|
|
866
|
-
});
|
|
867
|
-
else (_b = inst._zod).check ?? (_b.check = () => {});
|
|
868
|
-
});
|
|
869
|
-
const $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
870
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
871
|
-
inst._zod.check = (payload) => {
|
|
872
|
-
def.pattern.lastIndex = 0;
|
|
873
|
-
if (def.pattern.test(payload.value)) return;
|
|
874
|
-
payload.issues.push({
|
|
875
|
-
origin: "string",
|
|
876
|
-
code: "invalid_format",
|
|
877
|
-
format: "regex",
|
|
878
|
-
input: payload.value,
|
|
879
|
-
pattern: def.pattern.toString(),
|
|
880
|
-
inst,
|
|
881
|
-
continue: !def.abort
|
|
882
|
-
});
|
|
883
|
-
};
|
|
884
|
-
});
|
|
885
|
-
const $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
886
|
-
def.pattern ?? (def.pattern = lowercase);
|
|
887
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
888
|
-
});
|
|
889
|
-
const $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
890
|
-
def.pattern ?? (def.pattern = uppercase);
|
|
891
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
892
|
-
});
|
|
893
|
-
const $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
894
|
-
$ZodCheck.init(inst, def);
|
|
895
|
-
const escapedRegex = escapeRegex(def.includes);
|
|
896
|
-
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
897
|
-
def.pattern = pattern;
|
|
898
|
-
inst._zod.onattach.push((inst$1) => {
|
|
899
|
-
const bag = inst$1._zod.bag;
|
|
900
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
901
|
-
bag.patterns.add(pattern);
|
|
902
|
-
});
|
|
903
|
-
inst._zod.check = (payload) => {
|
|
904
|
-
if (payload.value.includes(def.includes, def.position)) return;
|
|
905
|
-
payload.issues.push({
|
|
906
|
-
origin: "string",
|
|
907
|
-
code: "invalid_format",
|
|
908
|
-
format: "includes",
|
|
909
|
-
includes: def.includes,
|
|
910
|
-
input: payload.value,
|
|
911
|
-
inst,
|
|
912
|
-
continue: !def.abort
|
|
913
|
-
});
|
|
914
|
-
};
|
|
915
|
-
});
|
|
916
|
-
const $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
917
|
-
$ZodCheck.init(inst, def);
|
|
918
|
-
const pattern = /* @__PURE__ */ new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
919
|
-
def.pattern ?? (def.pattern = pattern);
|
|
920
|
-
inst._zod.onattach.push((inst$1) => {
|
|
921
|
-
const bag = inst$1._zod.bag;
|
|
922
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
923
|
-
bag.patterns.add(pattern);
|
|
924
|
-
});
|
|
925
|
-
inst._zod.check = (payload) => {
|
|
926
|
-
if (payload.value.startsWith(def.prefix)) return;
|
|
927
|
-
payload.issues.push({
|
|
928
|
-
origin: "string",
|
|
929
|
-
code: "invalid_format",
|
|
930
|
-
format: "starts_with",
|
|
931
|
-
prefix: def.prefix,
|
|
932
|
-
input: payload.value,
|
|
933
|
-
inst,
|
|
934
|
-
continue: !def.abort
|
|
935
|
-
});
|
|
936
|
-
};
|
|
937
|
-
});
|
|
938
|
-
const $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
939
|
-
$ZodCheck.init(inst, def);
|
|
940
|
-
const pattern = /* @__PURE__ */ new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
941
|
-
def.pattern ?? (def.pattern = pattern);
|
|
942
|
-
inst._zod.onattach.push((inst$1) => {
|
|
943
|
-
const bag = inst$1._zod.bag;
|
|
944
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
945
|
-
bag.patterns.add(pattern);
|
|
946
|
-
});
|
|
947
|
-
inst._zod.check = (payload) => {
|
|
948
|
-
if (payload.value.endsWith(def.suffix)) return;
|
|
949
|
-
payload.issues.push({
|
|
950
|
-
origin: "string",
|
|
951
|
-
code: "invalid_format",
|
|
952
|
-
format: "ends_with",
|
|
953
|
-
suffix: def.suffix,
|
|
954
|
-
input: payload.value,
|
|
955
|
-
inst,
|
|
956
|
-
continue: !def.abort
|
|
957
|
-
});
|
|
958
|
-
};
|
|
959
|
-
});
|
|
960
|
-
const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
961
|
-
$ZodCheck.init(inst, def);
|
|
962
|
-
inst._zod.check = (payload) => {
|
|
963
|
-
payload.value = def.tx(payload.value);
|
|
964
|
-
};
|
|
965
|
-
});
|
|
966
|
-
|
|
967
|
-
//#endregion
|
|
968
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/doc.js
|
|
969
|
-
var Doc = class {
|
|
970
|
-
constructor(args = []) {
|
|
971
|
-
this.content = [];
|
|
972
|
-
this.indent = 0;
|
|
973
|
-
if (this) this.args = args;
|
|
974
|
-
}
|
|
975
|
-
indented(fn) {
|
|
976
|
-
this.indent += 1;
|
|
977
|
-
fn(this);
|
|
978
|
-
this.indent -= 1;
|
|
979
|
-
}
|
|
980
|
-
write(arg) {
|
|
981
|
-
if (typeof arg === "function") {
|
|
982
|
-
arg(this, { execution: "sync" });
|
|
983
|
-
arg(this, { execution: "async" });
|
|
984
|
-
return;
|
|
985
|
-
}
|
|
986
|
-
const lines = arg.split("\n").filter((x) => x);
|
|
987
|
-
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
|
|
988
|
-
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
|
|
989
|
-
for (const line of dedented) this.content.push(line);
|
|
990
|
-
}
|
|
991
|
-
compile() {
|
|
992
|
-
const F = Function;
|
|
993
|
-
const args = this?.args;
|
|
994
|
-
const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
|
|
995
|
-
return new F(...args, lines.join("\n"));
|
|
996
|
-
}
|
|
997
|
-
};
|
|
998
|
-
|
|
999
|
-
//#endregion
|
|
1000
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/versions.js
|
|
1001
|
-
const version = {
|
|
1002
|
-
major: 4,
|
|
1003
|
-
minor: 3,
|
|
1004
|
-
patch: 5
|
|
1005
|
-
};
|
|
1006
|
-
|
|
1007
|
-
//#endregion
|
|
1008
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/schemas.js
|
|
1009
|
-
const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
1010
|
-
var _a$1;
|
|
1011
|
-
inst ?? (inst = {});
|
|
1012
|
-
inst._zod.def = def;
|
|
1013
|
-
inst._zod.bag = inst._zod.bag || {};
|
|
1014
|
-
inst._zod.version = version;
|
|
1015
|
-
const checks = [...inst._zod.def.checks ?? []];
|
|
1016
|
-
if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
|
|
1017
|
-
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
|
|
1018
|
-
if (checks.length === 0) {
|
|
1019
|
-
(_a$1 = inst._zod).deferred ?? (_a$1.deferred = []);
|
|
1020
|
-
inst._zod.deferred?.push(() => {
|
|
1021
|
-
inst._zod.run = inst._zod.parse;
|
|
1022
|
-
});
|
|
1023
|
-
} else {
|
|
1024
|
-
const runChecks = (payload, checks$1, ctx) => {
|
|
1025
|
-
let isAborted = aborted(payload);
|
|
1026
|
-
let asyncResult;
|
|
1027
|
-
for (const ch of checks$1) {
|
|
1028
|
-
if (ch._zod.def.when) {
|
|
1029
|
-
if (!ch._zod.def.when(payload)) continue;
|
|
1030
|
-
} else if (isAborted) continue;
|
|
1031
|
-
const currLen = payload.issues.length;
|
|
1032
|
-
const _ = ch._zod.check(payload);
|
|
1033
|
-
if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
|
|
1034
|
-
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
1035
|
-
await _;
|
|
1036
|
-
if (payload.issues.length === currLen) return;
|
|
1037
|
-
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1038
|
-
});
|
|
1039
|
-
else {
|
|
1040
|
-
if (payload.issues.length === currLen) continue;
|
|
1041
|
-
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
if (asyncResult) return asyncResult.then(() => {
|
|
1045
|
-
return payload;
|
|
1046
|
-
});
|
|
1047
|
-
return payload;
|
|
1048
|
-
};
|
|
1049
|
-
const handleCanaryResult = (canary, payload, ctx) => {
|
|
1050
|
-
if (aborted(canary)) {
|
|
1051
|
-
canary.aborted = true;
|
|
1052
|
-
return canary;
|
|
1053
|
-
}
|
|
1054
|
-
const checkResult = runChecks(payload, checks, ctx);
|
|
1055
|
-
if (checkResult instanceof Promise) {
|
|
1056
|
-
if (ctx.async === false) throw new $ZodAsyncError();
|
|
1057
|
-
return checkResult.then((checkResult$1) => inst._zod.parse(checkResult$1, ctx));
|
|
1058
|
-
}
|
|
1059
|
-
return inst._zod.parse(checkResult, ctx);
|
|
1060
|
-
};
|
|
1061
|
-
inst._zod.run = (payload, ctx) => {
|
|
1062
|
-
if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
|
|
1063
|
-
if (ctx.direction === "backward") {
|
|
1064
|
-
const canary = inst._zod.parse({
|
|
1065
|
-
value: payload.value,
|
|
1066
|
-
issues: []
|
|
1067
|
-
}, {
|
|
1068
|
-
...ctx,
|
|
1069
|
-
skipChecks: true
|
|
1070
|
-
});
|
|
1071
|
-
if (canary instanceof Promise) return canary.then((canary$1) => {
|
|
1072
|
-
return handleCanaryResult(canary$1, payload, ctx);
|
|
1073
|
-
});
|
|
1074
|
-
return handleCanaryResult(canary, payload, ctx);
|
|
1075
|
-
}
|
|
1076
|
-
const result = inst._zod.parse(payload, ctx);
|
|
1077
|
-
if (result instanceof Promise) {
|
|
1078
|
-
if (ctx.async === false) throw new $ZodAsyncError();
|
|
1079
|
-
return result.then((result$1) => runChecks(result$1, checks, ctx));
|
|
1080
|
-
}
|
|
1081
|
-
return runChecks(result, checks, ctx);
|
|
1082
|
-
};
|
|
1083
|
-
}
|
|
1084
|
-
defineLazy(inst, "~standard", () => ({
|
|
1085
|
-
validate: (value) => {
|
|
1086
|
-
try {
|
|
1087
|
-
const r = safeParse$1(inst, value);
|
|
1088
|
-
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
1089
|
-
} catch (_) {
|
|
1090
|
-
return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
1091
|
-
}
|
|
1092
|
-
},
|
|
1093
|
-
vendor: "zod",
|
|
1094
|
-
version: 1
|
|
1095
|
-
}));
|
|
1096
|
-
});
|
|
1097
|
-
const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
1098
|
-
$ZodType.init(inst, def);
|
|
1099
|
-
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
|
|
1100
|
-
inst._zod.parse = (payload, _) => {
|
|
1101
|
-
if (def.coerce) try {
|
|
1102
|
-
payload.value = String(payload.value);
|
|
1103
|
-
} catch (_$1) {}
|
|
1104
|
-
if (typeof payload.value === "string") return payload;
|
|
1105
|
-
payload.issues.push({
|
|
1106
|
-
expected: "string",
|
|
1107
|
-
code: "invalid_type",
|
|
1108
|
-
input: payload.value,
|
|
1109
|
-
inst
|
|
1110
|
-
});
|
|
1111
|
-
return payload;
|
|
1112
|
-
};
|
|
1113
|
-
});
|
|
1114
|
-
const $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
|
|
1115
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
1116
|
-
$ZodString.init(inst, def);
|
|
1117
|
-
});
|
|
1118
|
-
const $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
|
|
1119
|
-
def.pattern ?? (def.pattern = guid);
|
|
1120
|
-
$ZodStringFormat.init(inst, def);
|
|
1121
|
-
});
|
|
1122
|
-
const $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
1123
|
-
if (def.version) {
|
|
1124
|
-
const v = {
|
|
1125
|
-
v1: 1,
|
|
1126
|
-
v2: 2,
|
|
1127
|
-
v3: 3,
|
|
1128
|
-
v4: 4,
|
|
1129
|
-
v5: 5,
|
|
1130
|
-
v6: 6,
|
|
1131
|
-
v7: 7,
|
|
1132
|
-
v8: 8
|
|
1133
|
-
}[def.version];
|
|
1134
|
-
if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
1135
|
-
def.pattern ?? (def.pattern = uuid(v));
|
|
1136
|
-
} else def.pattern ?? (def.pattern = uuid());
|
|
1137
|
-
$ZodStringFormat.init(inst, def);
|
|
1138
|
-
});
|
|
1139
|
-
const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
|
|
1140
|
-
def.pattern ?? (def.pattern = email);
|
|
1141
|
-
$ZodStringFormat.init(inst, def);
|
|
1142
|
-
});
|
|
1143
|
-
const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
1144
|
-
$ZodStringFormat.init(inst, def);
|
|
1145
|
-
inst._zod.check = (payload) => {
|
|
1146
|
-
try {
|
|
1147
|
-
const trimmed = payload.value.trim();
|
|
1148
|
-
const url = new URL(trimmed);
|
|
1149
|
-
if (def.hostname) {
|
|
1150
|
-
def.hostname.lastIndex = 0;
|
|
1151
|
-
if (!def.hostname.test(url.hostname)) payload.issues.push({
|
|
1152
|
-
code: "invalid_format",
|
|
1153
|
-
format: "url",
|
|
1154
|
-
note: "Invalid hostname",
|
|
1155
|
-
pattern: def.hostname.source,
|
|
1156
|
-
input: payload.value,
|
|
1157
|
-
inst,
|
|
1158
|
-
continue: !def.abort
|
|
1159
|
-
});
|
|
1160
|
-
}
|
|
1161
|
-
if (def.protocol) {
|
|
1162
|
-
def.protocol.lastIndex = 0;
|
|
1163
|
-
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
|
|
1164
|
-
code: "invalid_format",
|
|
1165
|
-
format: "url",
|
|
1166
|
-
note: "Invalid protocol",
|
|
1167
|
-
pattern: def.protocol.source,
|
|
1168
|
-
input: payload.value,
|
|
1169
|
-
inst,
|
|
1170
|
-
continue: !def.abort
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
if (def.normalize) payload.value = url.href;
|
|
1174
|
-
else payload.value = trimmed;
|
|
1175
|
-
return;
|
|
1176
|
-
} catch (_) {
|
|
1177
|
-
payload.issues.push({
|
|
1178
|
-
code: "invalid_format",
|
|
1179
|
-
format: "url",
|
|
1180
|
-
input: payload.value,
|
|
1181
|
-
inst,
|
|
1182
|
-
continue: !def.abort
|
|
1183
|
-
});
|
|
1184
|
-
}
|
|
1185
|
-
};
|
|
1186
|
-
});
|
|
1187
|
-
const $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
|
|
1188
|
-
def.pattern ?? (def.pattern = emoji());
|
|
1189
|
-
$ZodStringFormat.init(inst, def);
|
|
1190
|
-
});
|
|
1191
|
-
const $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
|
|
1192
|
-
def.pattern ?? (def.pattern = nanoid$1);
|
|
1193
|
-
$ZodStringFormat.init(inst, def);
|
|
1194
|
-
});
|
|
1195
|
-
const $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
|
|
1196
|
-
def.pattern ?? (def.pattern = cuid);
|
|
1197
|
-
$ZodStringFormat.init(inst, def);
|
|
1198
|
-
});
|
|
1199
|
-
const $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
|
|
1200
|
-
def.pattern ?? (def.pattern = cuid2);
|
|
1201
|
-
$ZodStringFormat.init(inst, def);
|
|
1202
|
-
});
|
|
1203
|
-
const $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
|
|
1204
|
-
def.pattern ?? (def.pattern = ulid);
|
|
1205
|
-
$ZodStringFormat.init(inst, def);
|
|
1206
|
-
});
|
|
1207
|
-
const $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
|
|
1208
|
-
def.pattern ?? (def.pattern = xid);
|
|
1209
|
-
$ZodStringFormat.init(inst, def);
|
|
1210
|
-
});
|
|
1211
|
-
const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
|
|
1212
|
-
def.pattern ?? (def.pattern = ksuid);
|
|
1213
|
-
$ZodStringFormat.init(inst, def);
|
|
1214
|
-
});
|
|
1215
|
-
const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
|
|
1216
|
-
def.pattern ?? (def.pattern = datetime$1(def));
|
|
1217
|
-
$ZodStringFormat.init(inst, def);
|
|
1218
|
-
});
|
|
1219
|
-
const $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
|
|
1220
|
-
def.pattern ?? (def.pattern = date$1);
|
|
1221
|
-
$ZodStringFormat.init(inst, def);
|
|
1222
|
-
});
|
|
1223
|
-
const $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
|
|
1224
|
-
def.pattern ?? (def.pattern = time$1(def));
|
|
1225
|
-
$ZodStringFormat.init(inst, def);
|
|
1226
|
-
});
|
|
1227
|
-
const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
|
|
1228
|
-
def.pattern ?? (def.pattern = duration$1);
|
|
1229
|
-
$ZodStringFormat.init(inst, def);
|
|
1230
|
-
});
|
|
1231
|
-
const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
|
|
1232
|
-
def.pattern ?? (def.pattern = ipv4);
|
|
1233
|
-
$ZodStringFormat.init(inst, def);
|
|
1234
|
-
inst._zod.bag.format = `ipv4`;
|
|
1235
|
-
});
|
|
1236
|
-
const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
1237
|
-
def.pattern ?? (def.pattern = ipv6);
|
|
1238
|
-
$ZodStringFormat.init(inst, def);
|
|
1239
|
-
inst._zod.bag.format = `ipv6`;
|
|
1240
|
-
inst._zod.check = (payload) => {
|
|
1241
|
-
try {
|
|
1242
|
-
new URL(`http://[${payload.value}]`);
|
|
1243
|
-
} catch {
|
|
1244
|
-
payload.issues.push({
|
|
1245
|
-
code: "invalid_format",
|
|
1246
|
-
format: "ipv6",
|
|
1247
|
-
input: payload.value,
|
|
1248
|
-
inst,
|
|
1249
|
-
continue: !def.abort
|
|
1250
|
-
});
|
|
1251
|
-
}
|
|
1252
|
-
};
|
|
1253
|
-
});
|
|
1254
|
-
const $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
1255
|
-
def.pattern ?? (def.pattern = cidrv4);
|
|
1256
|
-
$ZodStringFormat.init(inst, def);
|
|
1257
|
-
});
|
|
1258
|
-
const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
1259
|
-
def.pattern ?? (def.pattern = cidrv6);
|
|
1260
|
-
$ZodStringFormat.init(inst, def);
|
|
1261
|
-
inst._zod.check = (payload) => {
|
|
1262
|
-
const parts = payload.value.split("/");
|
|
1263
|
-
try {
|
|
1264
|
-
if (parts.length !== 2) throw new Error();
|
|
1265
|
-
const [address, prefix] = parts;
|
|
1266
|
-
if (!prefix) throw new Error();
|
|
1267
|
-
const prefixNum = Number(prefix);
|
|
1268
|
-
if (`${prefixNum}` !== prefix) throw new Error();
|
|
1269
|
-
if (prefixNum < 0 || prefixNum > 128) throw new Error();
|
|
1270
|
-
new URL(`http://[${address}]`);
|
|
1271
|
-
} catch {
|
|
1272
|
-
payload.issues.push({
|
|
1273
|
-
code: "invalid_format",
|
|
1274
|
-
format: "cidrv6",
|
|
1275
|
-
input: payload.value,
|
|
1276
|
-
inst,
|
|
1277
|
-
continue: !def.abort
|
|
1278
|
-
});
|
|
1279
|
-
}
|
|
1280
|
-
};
|
|
1281
|
-
});
|
|
1282
|
-
function isValidBase64(data) {
|
|
1283
|
-
if (data === "") return true;
|
|
1284
|
-
if (data.length % 4 !== 0) return false;
|
|
1285
|
-
try {
|
|
1286
|
-
atob(data);
|
|
1287
|
-
return true;
|
|
1288
|
-
} catch {
|
|
1289
|
-
return false;
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
1293
|
-
def.pattern ?? (def.pattern = base64);
|
|
1294
|
-
$ZodStringFormat.init(inst, def);
|
|
1295
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
1296
|
-
inst._zod.check = (payload) => {
|
|
1297
|
-
if (isValidBase64(payload.value)) return;
|
|
1298
|
-
payload.issues.push({
|
|
1299
|
-
code: "invalid_format",
|
|
1300
|
-
format: "base64",
|
|
1301
|
-
input: payload.value,
|
|
1302
|
-
inst,
|
|
1303
|
-
continue: !def.abort
|
|
1304
|
-
});
|
|
1305
|
-
};
|
|
1306
|
-
});
|
|
1307
|
-
function isValidBase64URL(data) {
|
|
1308
|
-
if (!base64url.test(data)) return false;
|
|
1309
|
-
const base64$1 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
1310
|
-
return isValidBase64(base64$1.padEnd(Math.ceil(base64$1.length / 4) * 4, "="));
|
|
1311
|
-
}
|
|
1312
|
-
const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1313
|
-
def.pattern ?? (def.pattern = base64url);
|
|
1314
|
-
$ZodStringFormat.init(inst, def);
|
|
1315
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
1316
|
-
inst._zod.check = (payload) => {
|
|
1317
|
-
if (isValidBase64URL(payload.value)) return;
|
|
1318
|
-
payload.issues.push({
|
|
1319
|
-
code: "invalid_format",
|
|
1320
|
-
format: "base64url",
|
|
1321
|
-
input: payload.value,
|
|
1322
|
-
inst,
|
|
1323
|
-
continue: !def.abort
|
|
1324
|
-
});
|
|
1325
|
-
};
|
|
1326
|
-
});
|
|
1327
|
-
const $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
|
|
1328
|
-
def.pattern ?? (def.pattern = e164);
|
|
1329
|
-
$ZodStringFormat.init(inst, def);
|
|
1330
|
-
});
|
|
1331
|
-
function isValidJWT(token, algorithm = null) {
|
|
1332
|
-
try {
|
|
1333
|
-
const tokensParts = token.split(".");
|
|
1334
|
-
if (tokensParts.length !== 3) return false;
|
|
1335
|
-
const [header] = tokensParts;
|
|
1336
|
-
if (!header) return false;
|
|
1337
|
-
const parsedHeader = JSON.parse(atob(header));
|
|
1338
|
-
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
|
|
1339
|
-
if (!parsedHeader.alg) return false;
|
|
1340
|
-
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
|
|
1341
|
-
return true;
|
|
1342
|
-
} catch {
|
|
1343
|
-
return false;
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
1347
|
-
$ZodStringFormat.init(inst, def);
|
|
1348
|
-
inst._zod.check = (payload) => {
|
|
1349
|
-
if (isValidJWT(payload.value, def.alg)) return;
|
|
1350
|
-
payload.issues.push({
|
|
1351
|
-
code: "invalid_format",
|
|
1352
|
-
format: "jwt",
|
|
1353
|
-
input: payload.value,
|
|
1354
|
-
inst,
|
|
1355
|
-
continue: !def.abort
|
|
1356
|
-
});
|
|
1357
|
-
};
|
|
1358
|
-
});
|
|
1359
|
-
const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
1360
|
-
$ZodType.init(inst, def);
|
|
1361
|
-
inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
|
|
1362
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1363
|
-
if (def.coerce) try {
|
|
1364
|
-
payload.value = Number(payload.value);
|
|
1365
|
-
} catch (_) {}
|
|
1366
|
-
const input = payload.value;
|
|
1367
|
-
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
|
|
1368
|
-
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
|
|
1369
|
-
payload.issues.push({
|
|
1370
|
-
expected: "number",
|
|
1371
|
-
code: "invalid_type",
|
|
1372
|
-
input,
|
|
1373
|
-
inst,
|
|
1374
|
-
...received ? { received } : {}
|
|
1375
|
-
});
|
|
1376
|
-
return payload;
|
|
1377
|
-
};
|
|
1378
|
-
});
|
|
1379
|
-
const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
|
|
1380
|
-
$ZodCheckNumberFormat.init(inst, def);
|
|
1381
|
-
$ZodNumber.init(inst, def);
|
|
1382
|
-
});
|
|
1383
|
-
const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
1384
|
-
$ZodType.init(inst, def);
|
|
1385
|
-
inst._zod.pattern = boolean$1;
|
|
1386
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1387
|
-
if (def.coerce) try {
|
|
1388
|
-
payload.value = Boolean(payload.value);
|
|
1389
|
-
} catch (_) {}
|
|
1390
|
-
const input = payload.value;
|
|
1391
|
-
if (typeof input === "boolean") return payload;
|
|
1392
|
-
payload.issues.push({
|
|
1393
|
-
expected: "boolean",
|
|
1394
|
-
code: "invalid_type",
|
|
1395
|
-
input,
|
|
1396
|
-
inst
|
|
1397
|
-
});
|
|
1398
|
-
return payload;
|
|
1399
|
-
};
|
|
1400
|
-
});
|
|
1401
|
-
const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
1402
|
-
$ZodType.init(inst, def);
|
|
1403
|
-
inst._zod.parse = (payload) => payload;
|
|
1404
|
-
});
|
|
1405
|
-
const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
1406
|
-
$ZodType.init(inst, def);
|
|
1407
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1408
|
-
payload.issues.push({
|
|
1409
|
-
expected: "never",
|
|
1410
|
-
code: "invalid_type",
|
|
1411
|
-
input: payload.value,
|
|
1412
|
-
inst
|
|
1413
|
-
});
|
|
1414
|
-
return payload;
|
|
1415
|
-
};
|
|
1416
|
-
});
|
|
1417
|
-
function handleArrayResult(result, final, index) {
|
|
1418
|
-
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
1419
|
-
final.value[index] = result.value;
|
|
1420
|
-
}
|
|
1421
|
-
const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
1422
|
-
$ZodType.init(inst, def);
|
|
1423
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1424
|
-
const input = payload.value;
|
|
1425
|
-
if (!Array.isArray(input)) {
|
|
1426
|
-
payload.issues.push({
|
|
1427
|
-
expected: "array",
|
|
1428
|
-
code: "invalid_type",
|
|
1429
|
-
input,
|
|
1430
|
-
inst
|
|
1431
|
-
});
|
|
1432
|
-
return payload;
|
|
1433
|
-
}
|
|
1434
|
-
payload.value = Array(input.length);
|
|
1435
|
-
const proms = [];
|
|
1436
|
-
for (let i = 0; i < input.length; i++) {
|
|
1437
|
-
const item = input[i];
|
|
1438
|
-
const result = def.element._zod.run({
|
|
1439
|
-
value: item,
|
|
1440
|
-
issues: []
|
|
1441
|
-
}, ctx);
|
|
1442
|
-
if (result instanceof Promise) proms.push(result.then((result$1) => handleArrayResult(result$1, payload, i)));
|
|
1443
|
-
else handleArrayResult(result, payload, i);
|
|
1444
|
-
}
|
|
1445
|
-
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
1446
|
-
return payload;
|
|
1447
|
-
};
|
|
1448
|
-
});
|
|
1449
|
-
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
1450
|
-
if (result.issues.length) {
|
|
1451
|
-
if (isOptionalOut && !(key in input)) return;
|
|
1452
|
-
final.issues.push(...prefixIssues(key, result.issues));
|
|
1453
|
-
}
|
|
1454
|
-
if (result.value === void 0) {
|
|
1455
|
-
if (key in input) final.value[key] = void 0;
|
|
1456
|
-
} else final.value[key] = result.value;
|
|
1457
|
-
}
|
|
1458
|
-
function normalizeDef(def) {
|
|
1459
|
-
const keys = Object.keys(def.shape);
|
|
1460
|
-
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`);
|
|
1461
|
-
const okeys = optionalKeys(def.shape);
|
|
1462
|
-
return {
|
|
1463
|
-
...def,
|
|
1464
|
-
keys,
|
|
1465
|
-
keySet: new Set(keys),
|
|
1466
|
-
numKeys: keys.length,
|
|
1467
|
-
optionalKeys: new Set(okeys)
|
|
1468
|
-
};
|
|
1469
|
-
}
|
|
1470
|
-
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
1471
|
-
const unrecognized = [];
|
|
1472
|
-
const keySet = def.keySet;
|
|
1473
|
-
const _catchall = def.catchall._zod;
|
|
1474
|
-
const t = _catchall.def.type;
|
|
1475
|
-
const isOptionalOut = _catchall.optout === "optional";
|
|
1476
|
-
for (const key in input) {
|
|
1477
|
-
if (keySet.has(key)) continue;
|
|
1478
|
-
if (t === "never") {
|
|
1479
|
-
unrecognized.push(key);
|
|
1480
|
-
continue;
|
|
1481
|
-
}
|
|
1482
|
-
const r = _catchall.run({
|
|
1483
|
-
value: input[key],
|
|
1484
|
-
issues: []
|
|
1485
|
-
}, ctx);
|
|
1486
|
-
if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult(r$1, payload, key, input, isOptionalOut)));
|
|
1487
|
-
else handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1488
|
-
}
|
|
1489
|
-
if (unrecognized.length) payload.issues.push({
|
|
1490
|
-
code: "unrecognized_keys",
|
|
1491
|
-
keys: unrecognized,
|
|
1492
|
-
input,
|
|
1493
|
-
inst
|
|
1494
|
-
});
|
|
1495
|
-
if (!proms.length) return payload;
|
|
1496
|
-
return Promise.all(proms).then(() => {
|
|
1497
|
-
return payload;
|
|
1498
|
-
});
|
|
1499
|
-
}
|
|
1500
|
-
const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
1501
|
-
$ZodType.init(inst, def);
|
|
1502
|
-
if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
|
|
1503
|
-
const sh = def.shape;
|
|
1504
|
-
Object.defineProperty(def, "shape", { get: () => {
|
|
1505
|
-
const newSh = { ...sh };
|
|
1506
|
-
Object.defineProperty(def, "shape", { value: newSh });
|
|
1507
|
-
return newSh;
|
|
1508
|
-
} });
|
|
1509
|
-
}
|
|
1510
|
-
const _normalized = cached(() => normalizeDef(def));
|
|
1511
|
-
defineLazy(inst._zod, "propValues", () => {
|
|
1512
|
-
const shape = def.shape;
|
|
1513
|
-
const propValues = {};
|
|
1514
|
-
for (const key in shape) {
|
|
1515
|
-
const field = shape[key]._zod;
|
|
1516
|
-
if (field.values) {
|
|
1517
|
-
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
1518
|
-
for (const v of field.values) propValues[key].add(v);
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
return propValues;
|
|
1522
|
-
});
|
|
1523
|
-
const isObject$1 = isObject;
|
|
1524
|
-
const catchall = def.catchall;
|
|
1525
|
-
let value;
|
|
1526
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1527
|
-
value ?? (value = _normalized.value);
|
|
1528
|
-
const input = payload.value;
|
|
1529
|
-
if (!isObject$1(input)) {
|
|
1530
|
-
payload.issues.push({
|
|
1531
|
-
expected: "object",
|
|
1532
|
-
code: "invalid_type",
|
|
1533
|
-
input,
|
|
1534
|
-
inst
|
|
1535
|
-
});
|
|
1536
|
-
return payload;
|
|
1537
|
-
}
|
|
1538
|
-
payload.value = {};
|
|
1539
|
-
const proms = [];
|
|
1540
|
-
const shape = value.shape;
|
|
1541
|
-
for (const key of value.keys) {
|
|
1542
|
-
const el = shape[key];
|
|
1543
|
-
const isOptionalOut = el._zod.optout === "optional";
|
|
1544
|
-
const r = el._zod.run({
|
|
1545
|
-
value: input[key],
|
|
1546
|
-
issues: []
|
|
1547
|
-
}, ctx);
|
|
1548
|
-
if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult(r$1, payload, key, input, isOptionalOut)));
|
|
1549
|
-
else handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1550
|
-
}
|
|
1551
|
-
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1552
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
1553
|
-
};
|
|
1554
|
-
});
|
|
1555
|
-
const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
1556
|
-
$ZodObject.init(inst, def);
|
|
1557
|
-
const superParse = inst._zod.parse;
|
|
1558
|
-
const _normalized = cached(() => normalizeDef(def));
|
|
1559
|
-
const generateFastpass = (shape) => {
|
|
1560
|
-
const doc = new Doc([
|
|
1561
|
-
"shape",
|
|
1562
|
-
"payload",
|
|
1563
|
-
"ctx"
|
|
1564
|
-
]);
|
|
1565
|
-
const normalized = _normalized.value;
|
|
1566
|
-
const parseStr = (key) => {
|
|
1567
|
-
const k = esc(key);
|
|
1568
|
-
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
1569
|
-
};
|
|
1570
|
-
doc.write(`const input = payload.value;`);
|
|
1571
|
-
const ids = Object.create(null);
|
|
1572
|
-
let counter = 0;
|
|
1573
|
-
for (const key of normalized.keys) ids[key] = `key_${counter++}`;
|
|
1574
|
-
doc.write(`const newResult = {};`);
|
|
1575
|
-
for (const key of normalized.keys) {
|
|
1576
|
-
const id = ids[key];
|
|
1577
|
-
const k = esc(key);
|
|
1578
|
-
const isOptionalOut = shape[key]?._zod?.optout === "optional";
|
|
1579
|
-
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1580
|
-
if (isOptionalOut) doc.write(`
|
|
1581
|
-
if (${id}.issues.length) {
|
|
1582
|
-
if (${k} in input) {
|
|
1583
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1584
|
-
...iss,
|
|
1585
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1586
|
-
})));
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
if (${id}.value === undefined) {
|
|
1591
|
-
if (${k} in input) {
|
|
1592
|
-
newResult[${k}] = undefined;
|
|
1593
|
-
}
|
|
1594
|
-
} else {
|
|
1595
|
-
newResult[${k}] = ${id}.value;
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
`);
|
|
1599
|
-
else doc.write(`
|
|
1600
|
-
if (${id}.issues.length) {
|
|
1601
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1602
|
-
...iss,
|
|
1603
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1604
|
-
})));
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
if (${id}.value === undefined) {
|
|
1608
|
-
if (${k} in input) {
|
|
1609
|
-
newResult[${k}] = undefined;
|
|
1610
|
-
}
|
|
1611
|
-
} else {
|
|
1612
|
-
newResult[${k}] = ${id}.value;
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
`);
|
|
1616
|
-
}
|
|
1617
|
-
doc.write(`payload.value = newResult;`);
|
|
1618
|
-
doc.write(`return payload;`);
|
|
1619
|
-
const fn = doc.compile();
|
|
1620
|
-
return (payload, ctx) => fn(shape, payload, ctx);
|
|
1621
|
-
};
|
|
1622
|
-
let fastpass;
|
|
1623
|
-
const isObject$1 = isObject;
|
|
1624
|
-
const jit = !globalConfig.jitless;
|
|
1625
|
-
const allowsEval$1 = allowsEval;
|
|
1626
|
-
const fastEnabled = jit && allowsEval$1.value;
|
|
1627
|
-
const catchall = def.catchall;
|
|
1628
|
-
let value;
|
|
1629
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1630
|
-
value ?? (value = _normalized.value);
|
|
1631
|
-
const input = payload.value;
|
|
1632
|
-
if (!isObject$1(input)) {
|
|
1633
|
-
payload.issues.push({
|
|
1634
|
-
expected: "object",
|
|
1635
|
-
code: "invalid_type",
|
|
1636
|
-
input,
|
|
1637
|
-
inst
|
|
1638
|
-
});
|
|
1639
|
-
return payload;
|
|
1640
|
-
}
|
|
1641
|
-
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
1642
|
-
if (!fastpass) fastpass = generateFastpass(def.shape);
|
|
1643
|
-
payload = fastpass(payload, ctx);
|
|
1644
|
-
if (!catchall) return payload;
|
|
1645
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
1646
|
-
}
|
|
1647
|
-
return superParse(payload, ctx);
|
|
1648
|
-
};
|
|
1649
|
-
});
|
|
1650
|
-
function handleUnionResults(results, final, inst, ctx) {
|
|
1651
|
-
for (const result of results) if (result.issues.length === 0) {
|
|
1652
|
-
final.value = result.value;
|
|
1653
|
-
return final;
|
|
1654
|
-
}
|
|
1655
|
-
const nonaborted = results.filter((r) => !aborted(r));
|
|
1656
|
-
if (nonaborted.length === 1) {
|
|
1657
|
-
final.value = nonaborted[0].value;
|
|
1658
|
-
return nonaborted[0];
|
|
1659
|
-
}
|
|
1660
|
-
final.issues.push({
|
|
1661
|
-
code: "invalid_union",
|
|
1662
|
-
input: final.value,
|
|
1663
|
-
inst,
|
|
1664
|
-
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
1665
|
-
});
|
|
1666
|
-
return final;
|
|
1667
|
-
}
|
|
1668
|
-
const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
1669
|
-
$ZodType.init(inst, def);
|
|
1670
|
-
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
|
|
1671
|
-
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
1672
|
-
defineLazy(inst._zod, "values", () => {
|
|
1673
|
-
if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
1674
|
-
});
|
|
1675
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
1676
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
1677
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
1678
|
-
return /* @__PURE__ */ new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
1679
|
-
}
|
|
1680
|
-
});
|
|
1681
|
-
const single = def.options.length === 1;
|
|
1682
|
-
const first = def.options[0]._zod.run;
|
|
1683
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1684
|
-
if (single) return first(payload, ctx);
|
|
1685
|
-
let async = false;
|
|
1686
|
-
const results = [];
|
|
1687
|
-
for (const option of def.options) {
|
|
1688
|
-
const result = option._zod.run({
|
|
1689
|
-
value: payload.value,
|
|
1690
|
-
issues: []
|
|
1691
|
-
}, ctx);
|
|
1692
|
-
if (result instanceof Promise) {
|
|
1693
|
-
results.push(result);
|
|
1694
|
-
async = true;
|
|
1695
|
-
} else {
|
|
1696
|
-
if (result.issues.length === 0) return result;
|
|
1697
|
-
results.push(result);
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
if (!async) return handleUnionResults(results, payload, inst, ctx);
|
|
1701
|
-
return Promise.all(results).then((results$1) => {
|
|
1702
|
-
return handleUnionResults(results$1, payload, inst, ctx);
|
|
1703
|
-
});
|
|
1704
|
-
};
|
|
1705
|
-
});
|
|
1706
|
-
const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
1707
|
-
def.inclusive = false;
|
|
1708
|
-
$ZodUnion.init(inst, def);
|
|
1709
|
-
const _super = inst._zod.parse;
|
|
1710
|
-
defineLazy(inst._zod, "propValues", () => {
|
|
1711
|
-
const propValues = {};
|
|
1712
|
-
for (const option of def.options) {
|
|
1713
|
-
const pv = option._zod.propValues;
|
|
1714
|
-
if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
1715
|
-
for (const [k, v] of Object.entries(pv)) {
|
|
1716
|
-
if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
|
|
1717
|
-
for (const val of v) propValues[k].add(val);
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
return propValues;
|
|
1721
|
-
});
|
|
1722
|
-
const disc = cached(() => {
|
|
1723
|
-
const opts = def.options;
|
|
1724
|
-
const map = /* @__PURE__ */ new Map();
|
|
1725
|
-
for (const o of opts) {
|
|
1726
|
-
const values = o._zod.propValues?.[def.discriminator];
|
|
1727
|
-
if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
1728
|
-
for (const v of values) {
|
|
1729
|
-
if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
1730
|
-
map.set(v, o);
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
return map;
|
|
1734
|
-
});
|
|
1735
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1736
|
-
const input = payload.value;
|
|
1737
|
-
if (!isObject(input)) {
|
|
1738
|
-
payload.issues.push({
|
|
1739
|
-
code: "invalid_type",
|
|
1740
|
-
expected: "object",
|
|
1741
|
-
input,
|
|
1742
|
-
inst
|
|
1743
|
-
});
|
|
1744
|
-
return payload;
|
|
1745
|
-
}
|
|
1746
|
-
const opt = disc.value.get(input?.[def.discriminator]);
|
|
1747
|
-
if (opt) return opt._zod.run(payload, ctx);
|
|
1748
|
-
if (def.unionFallback) return _super(payload, ctx);
|
|
1749
|
-
payload.issues.push({
|
|
1750
|
-
code: "invalid_union",
|
|
1751
|
-
errors: [],
|
|
1752
|
-
note: "No matching discriminator",
|
|
1753
|
-
discriminator: def.discriminator,
|
|
1754
|
-
input,
|
|
1755
|
-
path: [def.discriminator],
|
|
1756
|
-
inst
|
|
1757
|
-
});
|
|
1758
|
-
return payload;
|
|
1759
|
-
};
|
|
1760
|
-
});
|
|
1761
|
-
const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
1762
|
-
$ZodType.init(inst, def);
|
|
1763
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1764
|
-
const input = payload.value;
|
|
1765
|
-
const left = def.left._zod.run({
|
|
1766
|
-
value: input,
|
|
1767
|
-
issues: []
|
|
1768
|
-
}, ctx);
|
|
1769
|
-
const right = def.right._zod.run({
|
|
1770
|
-
value: input,
|
|
1771
|
-
issues: []
|
|
1772
|
-
}, ctx);
|
|
1773
|
-
if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left$1, right$1]) => {
|
|
1774
|
-
return handleIntersectionResults(payload, left$1, right$1);
|
|
1775
|
-
});
|
|
1776
|
-
return handleIntersectionResults(payload, left, right);
|
|
1777
|
-
};
|
|
1778
|
-
});
|
|
1779
|
-
function mergeValues(a, b) {
|
|
1780
|
-
if (a === b) return {
|
|
1781
|
-
valid: true,
|
|
1782
|
-
data: a
|
|
1783
|
-
};
|
|
1784
|
-
if (a instanceof Date && b instanceof Date && +a === +b) return {
|
|
1785
|
-
valid: true,
|
|
1786
|
-
data: a
|
|
1787
|
-
};
|
|
1788
|
-
if (isPlainObject(a) && isPlainObject(b)) {
|
|
1789
|
-
const bKeys = Object.keys(b);
|
|
1790
|
-
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
1791
|
-
const newObj = {
|
|
1792
|
-
...a,
|
|
1793
|
-
...b
|
|
1794
|
-
};
|
|
1795
|
-
for (const key of sharedKeys) {
|
|
1796
|
-
const sharedValue = mergeValues(a[key], b[key]);
|
|
1797
|
-
if (!sharedValue.valid) return {
|
|
1798
|
-
valid: false,
|
|
1799
|
-
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
|
|
1800
|
-
};
|
|
1801
|
-
newObj[key] = sharedValue.data;
|
|
1802
|
-
}
|
|
1803
|
-
return {
|
|
1804
|
-
valid: true,
|
|
1805
|
-
data: newObj
|
|
1806
|
-
};
|
|
1807
|
-
}
|
|
1808
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
1809
|
-
if (a.length !== b.length) return {
|
|
1810
|
-
valid: false,
|
|
1811
|
-
mergeErrorPath: []
|
|
1812
|
-
};
|
|
1813
|
-
const newArray = [];
|
|
1814
|
-
for (let index = 0; index < a.length; index++) {
|
|
1815
|
-
const itemA = a[index];
|
|
1816
|
-
const itemB = b[index];
|
|
1817
|
-
const sharedValue = mergeValues(itemA, itemB);
|
|
1818
|
-
if (!sharedValue.valid) return {
|
|
1819
|
-
valid: false,
|
|
1820
|
-
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
1821
|
-
};
|
|
1822
|
-
newArray.push(sharedValue.data);
|
|
1823
|
-
}
|
|
1824
|
-
return {
|
|
1825
|
-
valid: true,
|
|
1826
|
-
data: newArray
|
|
1827
|
-
};
|
|
1828
|
-
}
|
|
1829
|
-
return {
|
|
1830
|
-
valid: false,
|
|
1831
|
-
mergeErrorPath: []
|
|
1832
|
-
};
|
|
1833
|
-
}
|
|
1834
|
-
function handleIntersectionResults(result, left, right) {
|
|
1835
|
-
const unrecKeys = /* @__PURE__ */ new Map();
|
|
1836
|
-
let unrecIssue;
|
|
1837
|
-
for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
|
|
1838
|
-
unrecIssue ?? (unrecIssue = iss);
|
|
1839
|
-
for (const k of iss.keys) {
|
|
1840
|
-
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
1841
|
-
unrecKeys.get(k).l = true;
|
|
1842
|
-
}
|
|
1843
|
-
} else result.issues.push(iss);
|
|
1844
|
-
for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
|
|
1845
|
-
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
1846
|
-
unrecKeys.get(k).r = true;
|
|
1847
|
-
}
|
|
1848
|
-
else result.issues.push(iss);
|
|
1849
|
-
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
1850
|
-
if (bothKeys.length && unrecIssue) result.issues.push({
|
|
1851
|
-
...unrecIssue,
|
|
1852
|
-
keys: bothKeys
|
|
1853
|
-
});
|
|
1854
|
-
if (aborted(result)) return result;
|
|
1855
|
-
const merged = mergeValues(left.value, right.value);
|
|
1856
|
-
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
1857
|
-
result.value = merged.data;
|
|
1858
|
-
return result;
|
|
1859
|
-
}
|
|
1860
|
-
const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
1861
|
-
$ZodType.init(inst, def);
|
|
1862
|
-
const values = getEnumValues(def.entries);
|
|
1863
|
-
const valuesSet = new Set(values);
|
|
1864
|
-
inst._zod.values = valuesSet;
|
|
1865
|
-
inst._zod.pattern = /* @__PURE__ */ new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
1866
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1867
|
-
const input = payload.value;
|
|
1868
|
-
if (valuesSet.has(input)) return payload;
|
|
1869
|
-
payload.issues.push({
|
|
1870
|
-
code: "invalid_value",
|
|
1871
|
-
values,
|
|
1872
|
-
input,
|
|
1873
|
-
inst
|
|
1874
|
-
});
|
|
1875
|
-
return payload;
|
|
1876
|
-
};
|
|
1877
|
-
});
|
|
1878
|
-
const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
1879
|
-
$ZodType.init(inst, def);
|
|
1880
|
-
if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
|
|
1881
|
-
const values = new Set(def.values);
|
|
1882
|
-
inst._zod.values = values;
|
|
1883
|
-
inst._zod.pattern = /* @__PURE__ */ new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
|
1884
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1885
|
-
const input = payload.value;
|
|
1886
|
-
if (values.has(input)) return payload;
|
|
1887
|
-
payload.issues.push({
|
|
1888
|
-
code: "invalid_value",
|
|
1889
|
-
values: def.values,
|
|
1890
|
-
input,
|
|
1891
|
-
inst
|
|
1892
|
-
});
|
|
1893
|
-
return payload;
|
|
1894
|
-
};
|
|
1895
|
-
});
|
|
1896
|
-
const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
1897
|
-
$ZodType.init(inst, def);
|
|
1898
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1899
|
-
if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
1900
|
-
const _out = def.transform(payload.value, payload);
|
|
1901
|
-
if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
|
|
1902
|
-
payload.value = output;
|
|
1903
|
-
return payload;
|
|
1904
|
-
});
|
|
1905
|
-
if (_out instanceof Promise) throw new $ZodAsyncError();
|
|
1906
|
-
payload.value = _out;
|
|
1907
|
-
return payload;
|
|
1908
|
-
};
|
|
1909
|
-
});
|
|
1910
|
-
function handleOptionalResult(result, input) {
|
|
1911
|
-
if (result.issues.length && input === void 0) return {
|
|
1912
|
-
issues: [],
|
|
1913
|
-
value: void 0
|
|
1914
|
-
};
|
|
1915
|
-
return result;
|
|
1916
|
-
}
|
|
1917
|
-
const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
1918
|
-
$ZodType.init(inst, def);
|
|
1919
|
-
inst._zod.optin = "optional";
|
|
1920
|
-
inst._zod.optout = "optional";
|
|
1921
|
-
defineLazy(inst._zod, "values", () => {
|
|
1922
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
1923
|
-
});
|
|
1924
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
1925
|
-
const pattern = def.innerType._zod.pattern;
|
|
1926
|
-
return pattern ? /* @__PURE__ */ new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
1927
|
-
});
|
|
1928
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1929
|
-
if (def.innerType._zod.optin === "optional") {
|
|
1930
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1931
|
-
if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
|
|
1932
|
-
return handleOptionalResult(result, payload.value);
|
|
1933
|
-
}
|
|
1934
|
-
if (payload.value === void 0) return payload;
|
|
1935
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1936
|
-
};
|
|
1937
|
-
});
|
|
1938
|
-
const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
1939
|
-
$ZodOptional.init(inst, def);
|
|
1940
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1941
|
-
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
1942
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1943
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1944
|
-
};
|
|
1945
|
-
});
|
|
1946
|
-
const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
1947
|
-
$ZodType.init(inst, def);
|
|
1948
|
-
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1949
|
-
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1950
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
1951
|
-
const pattern = def.innerType._zod.pattern;
|
|
1952
|
-
return pattern ? /* @__PURE__ */ new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
1953
|
-
});
|
|
1954
|
-
defineLazy(inst._zod, "values", () => {
|
|
1955
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
|
|
1956
|
-
});
|
|
1957
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1958
|
-
if (payload.value === null) return payload;
|
|
1959
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1960
|
-
};
|
|
1961
|
-
});
|
|
1962
|
-
const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
1963
|
-
$ZodType.init(inst, def);
|
|
1964
|
-
inst._zod.optin = "optional";
|
|
1965
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1966
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1967
|
-
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
1968
|
-
if (payload.value === void 0) {
|
|
1969
|
-
payload.value = def.defaultValue;
|
|
1970
|
-
/**
|
|
1971
|
-
* $ZodDefault returns the default value immediately in forward direction.
|
|
1972
|
-
* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
|
|
1973
|
-
return payload;
|
|
1974
|
-
}
|
|
1975
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1976
|
-
if (result instanceof Promise) return result.then((result$1) => handleDefaultResult(result$1, def));
|
|
1977
|
-
return handleDefaultResult(result, def);
|
|
1978
|
-
};
|
|
1979
|
-
});
|
|
1980
|
-
function handleDefaultResult(payload, def) {
|
|
1981
|
-
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
1982
|
-
return payload;
|
|
1983
|
-
}
|
|
1984
|
-
const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
1985
|
-
$ZodType.init(inst, def);
|
|
1986
|
-
inst._zod.optin = "optional";
|
|
1987
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1988
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1989
|
-
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
1990
|
-
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
1991
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1992
|
-
};
|
|
1993
|
-
});
|
|
1994
|
-
const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
1995
|
-
$ZodType.init(inst, def);
|
|
1996
|
-
defineLazy(inst._zod, "values", () => {
|
|
1997
|
-
const v = def.innerType._zod.values;
|
|
1998
|
-
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
1999
|
-
});
|
|
2000
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2001
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2002
|
-
if (result instanceof Promise) return result.then((result$1) => handleNonOptionalResult(result$1, inst));
|
|
2003
|
-
return handleNonOptionalResult(result, inst);
|
|
2004
|
-
};
|
|
2005
|
-
});
|
|
2006
|
-
function handleNonOptionalResult(payload, inst) {
|
|
2007
|
-
if (!payload.issues.length && payload.value === void 0) payload.issues.push({
|
|
2008
|
-
code: "invalid_type",
|
|
2009
|
-
expected: "nonoptional",
|
|
2010
|
-
input: payload.value,
|
|
2011
|
-
inst
|
|
2012
|
-
});
|
|
2013
|
-
return payload;
|
|
2014
|
-
}
|
|
2015
|
-
const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
2016
|
-
$ZodType.init(inst, def);
|
|
2017
|
-
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
2018
|
-
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
2019
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2020
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2021
|
-
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2022
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2023
|
-
if (result instanceof Promise) return result.then((result$1) => {
|
|
2024
|
-
payload.value = result$1.value;
|
|
2025
|
-
if (result$1.issues.length) {
|
|
2026
|
-
payload.value = def.catchValue({
|
|
2027
|
-
...payload,
|
|
2028
|
-
error: { issues: result$1.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2029
|
-
input: payload.value
|
|
2030
|
-
});
|
|
2031
|
-
payload.issues = [];
|
|
2032
|
-
}
|
|
2033
|
-
return payload;
|
|
2034
|
-
});
|
|
2035
|
-
payload.value = result.value;
|
|
2036
|
-
if (result.issues.length) {
|
|
2037
|
-
payload.value = def.catchValue({
|
|
2038
|
-
...payload,
|
|
2039
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2040
|
-
input: payload.value
|
|
2041
|
-
});
|
|
2042
|
-
payload.issues = [];
|
|
2043
|
-
}
|
|
2044
|
-
return payload;
|
|
2045
|
-
};
|
|
2046
|
-
});
|
|
2047
|
-
const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
2048
|
-
$ZodType.init(inst, def);
|
|
2049
|
-
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
2050
|
-
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
2051
|
-
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
2052
|
-
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
2053
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2054
|
-
if (ctx.direction === "backward") {
|
|
2055
|
-
const right = def.out._zod.run(payload, ctx);
|
|
2056
|
-
if (right instanceof Promise) return right.then((right$1) => handlePipeResult(right$1, def.in, ctx));
|
|
2057
|
-
return handlePipeResult(right, def.in, ctx);
|
|
2058
|
-
}
|
|
2059
|
-
const left = def.in._zod.run(payload, ctx);
|
|
2060
|
-
if (left instanceof Promise) return left.then((left$1) => handlePipeResult(left$1, def.out, ctx));
|
|
2061
|
-
return handlePipeResult(left, def.out, ctx);
|
|
2062
|
-
};
|
|
2063
|
-
});
|
|
2064
|
-
function handlePipeResult(left, next, ctx) {
|
|
2065
|
-
if (left.issues.length) {
|
|
2066
|
-
left.aborted = true;
|
|
2067
|
-
return left;
|
|
2068
|
-
}
|
|
2069
|
-
return next._zod.run({
|
|
2070
|
-
value: left.value,
|
|
2071
|
-
issues: left.issues
|
|
2072
|
-
}, ctx);
|
|
2073
|
-
}
|
|
2074
|
-
const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
2075
|
-
$ZodType.init(inst, def);
|
|
2076
|
-
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
2077
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2078
|
-
defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
|
2079
|
-
defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
|
2080
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2081
|
-
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2082
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2083
|
-
if (result instanceof Promise) return result.then(handleReadonlyResult);
|
|
2084
|
-
return handleReadonlyResult(result);
|
|
2085
|
-
};
|
|
2086
|
-
});
|
|
2087
|
-
function handleReadonlyResult(payload) {
|
|
2088
|
-
payload.value = Object.freeze(payload.value);
|
|
2089
|
-
return payload;
|
|
2090
|
-
}
|
|
2091
|
-
const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
2092
|
-
$ZodCheck.init(inst, def);
|
|
2093
|
-
$ZodType.init(inst, def);
|
|
2094
|
-
inst._zod.parse = (payload, _) => {
|
|
2095
|
-
return payload;
|
|
2096
|
-
};
|
|
2097
|
-
inst._zod.check = (payload) => {
|
|
2098
|
-
const input = payload.value;
|
|
2099
|
-
const r = def.fn(input);
|
|
2100
|
-
if (r instanceof Promise) return r.then((r$1) => handleRefineResult(r$1, payload, input, inst));
|
|
2101
|
-
handleRefineResult(r, payload, input, inst);
|
|
2102
|
-
};
|
|
2103
|
-
});
|
|
2104
|
-
function handleRefineResult(result, payload, input, inst) {
|
|
2105
|
-
if (!result) {
|
|
2106
|
-
const _iss = {
|
|
2107
|
-
code: "custom",
|
|
2108
|
-
input,
|
|
2109
|
-
inst,
|
|
2110
|
-
path: [...inst._zod.def.path ?? []],
|
|
2111
|
-
continue: !inst._zod.def.abort
|
|
2112
|
-
};
|
|
2113
|
-
if (inst._zod.def.params) _iss.params = inst._zod.def.params;
|
|
2114
|
-
payload.issues.push(issue(_iss));
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
|
|
2118
|
-
//#endregion
|
|
2119
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/registries.js
|
|
2120
|
-
var _a;
|
|
2121
|
-
var $ZodRegistry = class {
|
|
2122
|
-
constructor() {
|
|
2123
|
-
this._map = /* @__PURE__ */ new WeakMap();
|
|
2124
|
-
this._idmap = /* @__PURE__ */ new Map();
|
|
2125
|
-
}
|
|
2126
|
-
add(schema, ..._meta) {
|
|
2127
|
-
const meta$2 = _meta[0];
|
|
2128
|
-
this._map.set(schema, meta$2);
|
|
2129
|
-
if (meta$2 && typeof meta$2 === "object" && "id" in meta$2) this._idmap.set(meta$2.id, schema);
|
|
2130
|
-
return this;
|
|
2131
|
-
}
|
|
2132
|
-
clear() {
|
|
2133
|
-
this._map = /* @__PURE__ */ new WeakMap();
|
|
2134
|
-
this._idmap = /* @__PURE__ */ new Map();
|
|
2135
|
-
return this;
|
|
2136
|
-
}
|
|
2137
|
-
remove(schema) {
|
|
2138
|
-
const meta$2 = this._map.get(schema);
|
|
2139
|
-
if (meta$2 && typeof meta$2 === "object" && "id" in meta$2) this._idmap.delete(meta$2.id);
|
|
2140
|
-
this._map.delete(schema);
|
|
2141
|
-
return this;
|
|
2142
|
-
}
|
|
2143
|
-
get(schema) {
|
|
2144
|
-
const p = schema._zod.parent;
|
|
2145
|
-
if (p) {
|
|
2146
|
-
const pm = { ...this.get(p) ?? {} };
|
|
2147
|
-
delete pm.id;
|
|
2148
|
-
const f = {
|
|
2149
|
-
...pm,
|
|
2150
|
-
...this._map.get(schema)
|
|
2151
|
-
};
|
|
2152
|
-
return Object.keys(f).length ? f : void 0;
|
|
2153
|
-
}
|
|
2154
|
-
return this._map.get(schema);
|
|
2155
|
-
}
|
|
2156
|
-
has(schema) {
|
|
2157
|
-
return this._map.has(schema);
|
|
2158
|
-
}
|
|
2159
|
-
};
|
|
2160
|
-
function registry() {
|
|
2161
|
-
return new $ZodRegistry();
|
|
2162
|
-
}
|
|
2163
|
-
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
2164
|
-
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
2165
|
-
|
|
2166
|
-
//#endregion
|
|
2167
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/api.js
|
|
2168
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2169
|
-
function _string(Class, params) {
|
|
2170
|
-
return new Class({
|
|
2171
|
-
type: "string",
|
|
2172
|
-
...normalizeParams(params)
|
|
2173
|
-
});
|
|
2174
|
-
}
|
|
2175
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2176
|
-
function _email(Class, params) {
|
|
2177
|
-
return new Class({
|
|
2178
|
-
type: "string",
|
|
2179
|
-
format: "email",
|
|
2180
|
-
check: "string_format",
|
|
2181
|
-
abort: false,
|
|
2182
|
-
...normalizeParams(params)
|
|
2183
|
-
});
|
|
2184
|
-
}
|
|
2185
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2186
|
-
function _guid(Class, params) {
|
|
2187
|
-
return new Class({
|
|
2188
|
-
type: "string",
|
|
2189
|
-
format: "guid",
|
|
2190
|
-
check: "string_format",
|
|
2191
|
-
abort: false,
|
|
2192
|
-
...normalizeParams(params)
|
|
2193
|
-
});
|
|
2194
|
-
}
|
|
2195
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2196
|
-
function _uuid(Class, params) {
|
|
2197
|
-
return new Class({
|
|
2198
|
-
type: "string",
|
|
2199
|
-
format: "uuid",
|
|
2200
|
-
check: "string_format",
|
|
2201
|
-
abort: false,
|
|
2202
|
-
...normalizeParams(params)
|
|
2203
|
-
});
|
|
2204
|
-
}
|
|
2205
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2206
|
-
function _uuidv4(Class, params) {
|
|
2207
|
-
return new Class({
|
|
2208
|
-
type: "string",
|
|
2209
|
-
format: "uuid",
|
|
2210
|
-
check: "string_format",
|
|
2211
|
-
abort: false,
|
|
2212
|
-
version: "v4",
|
|
2213
|
-
...normalizeParams(params)
|
|
2214
|
-
});
|
|
2215
|
-
}
|
|
2216
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2217
|
-
function _uuidv6(Class, params) {
|
|
2218
|
-
return new Class({
|
|
2219
|
-
type: "string",
|
|
2220
|
-
format: "uuid",
|
|
2221
|
-
check: "string_format",
|
|
2222
|
-
abort: false,
|
|
2223
|
-
version: "v6",
|
|
2224
|
-
...normalizeParams(params)
|
|
2225
|
-
});
|
|
2226
|
-
}
|
|
2227
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2228
|
-
function _uuidv7(Class, params) {
|
|
2229
|
-
return new Class({
|
|
2230
|
-
type: "string",
|
|
2231
|
-
format: "uuid",
|
|
2232
|
-
check: "string_format",
|
|
2233
|
-
abort: false,
|
|
2234
|
-
version: "v7",
|
|
2235
|
-
...normalizeParams(params)
|
|
2236
|
-
});
|
|
2237
|
-
}
|
|
2238
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2239
|
-
function _url(Class, params) {
|
|
2240
|
-
return new Class({
|
|
2241
|
-
type: "string",
|
|
2242
|
-
format: "url",
|
|
2243
|
-
check: "string_format",
|
|
2244
|
-
abort: false,
|
|
2245
|
-
...normalizeParams(params)
|
|
2246
|
-
});
|
|
2247
|
-
}
|
|
2248
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2249
|
-
function _emoji(Class, params) {
|
|
2250
|
-
return new Class({
|
|
2251
|
-
type: "string",
|
|
2252
|
-
format: "emoji",
|
|
2253
|
-
check: "string_format",
|
|
2254
|
-
abort: false,
|
|
2255
|
-
...normalizeParams(params)
|
|
2256
|
-
});
|
|
2257
|
-
}
|
|
2258
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2259
|
-
function _nanoid(Class, params) {
|
|
2260
|
-
return new Class({
|
|
2261
|
-
type: "string",
|
|
2262
|
-
format: "nanoid",
|
|
2263
|
-
check: "string_format",
|
|
2264
|
-
abort: false,
|
|
2265
|
-
...normalizeParams(params)
|
|
2266
|
-
});
|
|
2267
|
-
}
|
|
2268
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2269
|
-
function _cuid(Class, params) {
|
|
2270
|
-
return new Class({
|
|
2271
|
-
type: "string",
|
|
2272
|
-
format: "cuid",
|
|
2273
|
-
check: "string_format",
|
|
2274
|
-
abort: false,
|
|
2275
|
-
...normalizeParams(params)
|
|
2276
|
-
});
|
|
2277
|
-
}
|
|
2278
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2279
|
-
function _cuid2(Class, params) {
|
|
2280
|
-
return new Class({
|
|
2281
|
-
type: "string",
|
|
2282
|
-
format: "cuid2",
|
|
2283
|
-
check: "string_format",
|
|
2284
|
-
abort: false,
|
|
2285
|
-
...normalizeParams(params)
|
|
2286
|
-
});
|
|
2287
|
-
}
|
|
2288
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2289
|
-
function _ulid(Class, params) {
|
|
2290
|
-
return new Class({
|
|
2291
|
-
type: "string",
|
|
2292
|
-
format: "ulid",
|
|
2293
|
-
check: "string_format",
|
|
2294
|
-
abort: false,
|
|
2295
|
-
...normalizeParams(params)
|
|
2296
|
-
});
|
|
2297
|
-
}
|
|
2298
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2299
|
-
function _xid(Class, params) {
|
|
2300
|
-
return new Class({
|
|
2301
|
-
type: "string",
|
|
2302
|
-
format: "xid",
|
|
2303
|
-
check: "string_format",
|
|
2304
|
-
abort: false,
|
|
2305
|
-
...normalizeParams(params)
|
|
2306
|
-
});
|
|
2307
|
-
}
|
|
2308
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2309
|
-
function _ksuid(Class, params) {
|
|
2310
|
-
return new Class({
|
|
2311
|
-
type: "string",
|
|
2312
|
-
format: "ksuid",
|
|
2313
|
-
check: "string_format",
|
|
2314
|
-
abort: false,
|
|
2315
|
-
...normalizeParams(params)
|
|
2316
|
-
});
|
|
2317
|
-
}
|
|
2318
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2319
|
-
function _ipv4(Class, params) {
|
|
2320
|
-
return new Class({
|
|
2321
|
-
type: "string",
|
|
2322
|
-
format: "ipv4",
|
|
2323
|
-
check: "string_format",
|
|
2324
|
-
abort: false,
|
|
2325
|
-
...normalizeParams(params)
|
|
2326
|
-
});
|
|
2327
|
-
}
|
|
2328
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2329
|
-
function _ipv6(Class, params) {
|
|
2330
|
-
return new Class({
|
|
2331
|
-
type: "string",
|
|
2332
|
-
format: "ipv6",
|
|
2333
|
-
check: "string_format",
|
|
2334
|
-
abort: false,
|
|
2335
|
-
...normalizeParams(params)
|
|
2336
|
-
});
|
|
2337
|
-
}
|
|
2338
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2339
|
-
function _cidrv4(Class, params) {
|
|
2340
|
-
return new Class({
|
|
2341
|
-
type: "string",
|
|
2342
|
-
format: "cidrv4",
|
|
2343
|
-
check: "string_format",
|
|
2344
|
-
abort: false,
|
|
2345
|
-
...normalizeParams(params)
|
|
2346
|
-
});
|
|
2347
|
-
}
|
|
2348
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2349
|
-
function _cidrv6(Class, params) {
|
|
2350
|
-
return new Class({
|
|
2351
|
-
type: "string",
|
|
2352
|
-
format: "cidrv6",
|
|
2353
|
-
check: "string_format",
|
|
2354
|
-
abort: false,
|
|
2355
|
-
...normalizeParams(params)
|
|
2356
|
-
});
|
|
2357
|
-
}
|
|
2358
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2359
|
-
function _base64(Class, params) {
|
|
2360
|
-
return new Class({
|
|
2361
|
-
type: "string",
|
|
2362
|
-
format: "base64",
|
|
2363
|
-
check: "string_format",
|
|
2364
|
-
abort: false,
|
|
2365
|
-
...normalizeParams(params)
|
|
2366
|
-
});
|
|
2367
|
-
}
|
|
2368
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2369
|
-
function _base64url(Class, params) {
|
|
2370
|
-
return new Class({
|
|
2371
|
-
type: "string",
|
|
2372
|
-
format: "base64url",
|
|
2373
|
-
check: "string_format",
|
|
2374
|
-
abort: false,
|
|
2375
|
-
...normalizeParams(params)
|
|
2376
|
-
});
|
|
2377
|
-
}
|
|
2378
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2379
|
-
function _e164(Class, params) {
|
|
2380
|
-
return new Class({
|
|
2381
|
-
type: "string",
|
|
2382
|
-
format: "e164",
|
|
2383
|
-
check: "string_format",
|
|
2384
|
-
abort: false,
|
|
2385
|
-
...normalizeParams(params)
|
|
2386
|
-
});
|
|
2387
|
-
}
|
|
2388
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2389
|
-
function _jwt(Class, params) {
|
|
2390
|
-
return new Class({
|
|
2391
|
-
type: "string",
|
|
2392
|
-
format: "jwt",
|
|
2393
|
-
check: "string_format",
|
|
2394
|
-
abort: false,
|
|
2395
|
-
...normalizeParams(params)
|
|
2396
|
-
});
|
|
2397
|
-
}
|
|
2398
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2399
|
-
function _isoDateTime(Class, params) {
|
|
2400
|
-
return new Class({
|
|
2401
|
-
type: "string",
|
|
2402
|
-
format: "datetime",
|
|
2403
|
-
check: "string_format",
|
|
2404
|
-
offset: false,
|
|
2405
|
-
local: false,
|
|
2406
|
-
precision: null,
|
|
2407
|
-
...normalizeParams(params)
|
|
2408
|
-
});
|
|
2409
|
-
}
|
|
2410
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2411
|
-
function _isoDate(Class, params) {
|
|
2412
|
-
return new Class({
|
|
2413
|
-
type: "string",
|
|
2414
|
-
format: "date",
|
|
2415
|
-
check: "string_format",
|
|
2416
|
-
...normalizeParams(params)
|
|
2417
|
-
});
|
|
2418
|
-
}
|
|
2419
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2420
|
-
function _isoTime(Class, params) {
|
|
2421
|
-
return new Class({
|
|
2422
|
-
type: "string",
|
|
2423
|
-
format: "time",
|
|
2424
|
-
check: "string_format",
|
|
2425
|
-
precision: null,
|
|
2426
|
-
...normalizeParams(params)
|
|
2427
|
-
});
|
|
2428
|
-
}
|
|
2429
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2430
|
-
function _isoDuration(Class, params) {
|
|
2431
|
-
return new Class({
|
|
2432
|
-
type: "string",
|
|
2433
|
-
format: "duration",
|
|
2434
|
-
check: "string_format",
|
|
2435
|
-
...normalizeParams(params)
|
|
2436
|
-
});
|
|
2437
|
-
}
|
|
2438
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2439
|
-
function _number(Class, params) {
|
|
2440
|
-
return new Class({
|
|
2441
|
-
type: "number",
|
|
2442
|
-
checks: [],
|
|
2443
|
-
...normalizeParams(params)
|
|
2444
|
-
});
|
|
2445
|
-
}
|
|
2446
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2447
|
-
function _int(Class, params) {
|
|
2448
|
-
return new Class({
|
|
2449
|
-
type: "number",
|
|
2450
|
-
check: "number_format",
|
|
2451
|
-
abort: false,
|
|
2452
|
-
format: "safeint",
|
|
2453
|
-
...normalizeParams(params)
|
|
2454
|
-
});
|
|
2455
|
-
}
|
|
2456
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2457
|
-
function _boolean(Class, params) {
|
|
2458
|
-
return new Class({
|
|
2459
|
-
type: "boolean",
|
|
2460
|
-
...normalizeParams(params)
|
|
2461
|
-
});
|
|
2462
|
-
}
|
|
2463
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2464
|
-
function _unknown(Class) {
|
|
2465
|
-
return new Class({ type: "unknown" });
|
|
2466
|
-
}
|
|
2467
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2468
|
-
function _never(Class, params) {
|
|
2469
|
-
return new Class({
|
|
2470
|
-
type: "never",
|
|
2471
|
-
...normalizeParams(params)
|
|
2472
|
-
});
|
|
2473
|
-
}
|
|
2474
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2475
|
-
function _lt(value, params) {
|
|
2476
|
-
return new $ZodCheckLessThan({
|
|
2477
|
-
check: "less_than",
|
|
2478
|
-
...normalizeParams(params),
|
|
2479
|
-
value,
|
|
2480
|
-
inclusive: false
|
|
2481
|
-
});
|
|
2482
|
-
}
|
|
2483
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2484
|
-
function _lte(value, params) {
|
|
2485
|
-
return new $ZodCheckLessThan({
|
|
2486
|
-
check: "less_than",
|
|
2487
|
-
...normalizeParams(params),
|
|
2488
|
-
value,
|
|
2489
|
-
inclusive: true
|
|
2490
|
-
});
|
|
2491
|
-
}
|
|
2492
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2493
|
-
function _gt(value, params) {
|
|
2494
|
-
return new $ZodCheckGreaterThan({
|
|
2495
|
-
check: "greater_than",
|
|
2496
|
-
...normalizeParams(params),
|
|
2497
|
-
value,
|
|
2498
|
-
inclusive: false
|
|
2499
|
-
});
|
|
2500
|
-
}
|
|
2501
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2502
|
-
function _gte(value, params) {
|
|
2503
|
-
return new $ZodCheckGreaterThan({
|
|
2504
|
-
check: "greater_than",
|
|
2505
|
-
...normalizeParams(params),
|
|
2506
|
-
value,
|
|
2507
|
-
inclusive: true
|
|
2508
|
-
});
|
|
2509
|
-
}
|
|
2510
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2511
|
-
function _multipleOf(value, params) {
|
|
2512
|
-
return new $ZodCheckMultipleOf({
|
|
2513
|
-
check: "multiple_of",
|
|
2514
|
-
...normalizeParams(params),
|
|
2515
|
-
value
|
|
2516
|
-
});
|
|
2517
|
-
}
|
|
2518
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2519
|
-
function _maxLength(maximum, params) {
|
|
2520
|
-
return new $ZodCheckMaxLength({
|
|
2521
|
-
check: "max_length",
|
|
2522
|
-
...normalizeParams(params),
|
|
2523
|
-
maximum
|
|
2524
|
-
});
|
|
2525
|
-
}
|
|
2526
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2527
|
-
function _minLength(minimum, params) {
|
|
2528
|
-
return new $ZodCheckMinLength({
|
|
2529
|
-
check: "min_length",
|
|
2530
|
-
...normalizeParams(params),
|
|
2531
|
-
minimum
|
|
2532
|
-
});
|
|
2533
|
-
}
|
|
2534
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2535
|
-
function _length(length, params) {
|
|
2536
|
-
return new $ZodCheckLengthEquals({
|
|
2537
|
-
check: "length_equals",
|
|
2538
|
-
...normalizeParams(params),
|
|
2539
|
-
length
|
|
2540
|
-
});
|
|
2541
|
-
}
|
|
2542
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2543
|
-
function _regex(pattern, params) {
|
|
2544
|
-
return new $ZodCheckRegex({
|
|
2545
|
-
check: "string_format",
|
|
2546
|
-
format: "regex",
|
|
2547
|
-
...normalizeParams(params),
|
|
2548
|
-
pattern
|
|
2549
|
-
});
|
|
2550
|
-
}
|
|
2551
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2552
|
-
function _lowercase(params) {
|
|
2553
|
-
return new $ZodCheckLowerCase({
|
|
2554
|
-
check: "string_format",
|
|
2555
|
-
format: "lowercase",
|
|
2556
|
-
...normalizeParams(params)
|
|
2557
|
-
});
|
|
2558
|
-
}
|
|
2559
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2560
|
-
function _uppercase(params) {
|
|
2561
|
-
return new $ZodCheckUpperCase({
|
|
2562
|
-
check: "string_format",
|
|
2563
|
-
format: "uppercase",
|
|
2564
|
-
...normalizeParams(params)
|
|
2565
|
-
});
|
|
2566
|
-
}
|
|
2567
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2568
|
-
function _includes(includes, params) {
|
|
2569
|
-
return new $ZodCheckIncludes({
|
|
2570
|
-
check: "string_format",
|
|
2571
|
-
format: "includes",
|
|
2572
|
-
...normalizeParams(params),
|
|
2573
|
-
includes
|
|
2574
|
-
});
|
|
2575
|
-
}
|
|
2576
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2577
|
-
function _startsWith(prefix, params) {
|
|
2578
|
-
return new $ZodCheckStartsWith({
|
|
2579
|
-
check: "string_format",
|
|
2580
|
-
format: "starts_with",
|
|
2581
|
-
...normalizeParams(params),
|
|
2582
|
-
prefix
|
|
2583
|
-
});
|
|
2584
|
-
}
|
|
2585
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2586
|
-
function _endsWith(suffix, params) {
|
|
2587
|
-
return new $ZodCheckEndsWith({
|
|
2588
|
-
check: "string_format",
|
|
2589
|
-
format: "ends_with",
|
|
2590
|
-
...normalizeParams(params),
|
|
2591
|
-
suffix
|
|
2592
|
-
});
|
|
2593
|
-
}
|
|
2594
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2595
|
-
function _overwrite(tx) {
|
|
2596
|
-
return new $ZodCheckOverwrite({
|
|
2597
|
-
check: "overwrite",
|
|
2598
|
-
tx
|
|
2599
|
-
});
|
|
2600
|
-
}
|
|
2601
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2602
|
-
function _normalize(form) {
|
|
2603
|
-
return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
|
|
2604
|
-
}
|
|
2605
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2606
|
-
function _trim() {
|
|
2607
|
-
return /* @__PURE__ */ _overwrite((input) => input.trim());
|
|
2608
|
-
}
|
|
2609
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2610
|
-
function _toLowerCase() {
|
|
2611
|
-
return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
|
|
2612
|
-
}
|
|
2613
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2614
|
-
function _toUpperCase() {
|
|
2615
|
-
return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
|
|
2616
|
-
}
|
|
2617
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2618
|
-
function _slugify() {
|
|
2619
|
-
return /* @__PURE__ */ _overwrite((input) => slugify(input));
|
|
2620
|
-
}
|
|
2621
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2622
|
-
function _array(Class, element, params) {
|
|
2623
|
-
return new Class({
|
|
2624
|
-
type: "array",
|
|
2625
|
-
element,
|
|
2626
|
-
...normalizeParams(params)
|
|
2627
|
-
});
|
|
2628
|
-
}
|
|
2629
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2630
|
-
function _refine(Class, fn, _params) {
|
|
2631
|
-
return new Class({
|
|
2632
|
-
type: "custom",
|
|
2633
|
-
check: "custom",
|
|
2634
|
-
fn,
|
|
2635
|
-
...normalizeParams(_params)
|
|
2636
|
-
});
|
|
2637
|
-
}
|
|
2638
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2639
|
-
function _superRefine(fn) {
|
|
2640
|
-
const ch = /* @__PURE__ */ _check((payload) => {
|
|
2641
|
-
payload.addIssue = (issue$1) => {
|
|
2642
|
-
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
|
|
2643
|
-
else {
|
|
2644
|
-
const _issue = issue$1;
|
|
2645
|
-
if (_issue.fatal) _issue.continue = false;
|
|
2646
|
-
_issue.code ?? (_issue.code = "custom");
|
|
2647
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
2648
|
-
_issue.inst ?? (_issue.inst = ch);
|
|
2649
|
-
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
2650
|
-
payload.issues.push(issue(_issue));
|
|
2651
|
-
}
|
|
2652
|
-
};
|
|
2653
|
-
return fn(payload.value, payload);
|
|
2654
|
-
});
|
|
2655
|
-
return ch;
|
|
2656
|
-
}
|
|
2657
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2658
|
-
function _check(fn, params) {
|
|
2659
|
-
const ch = new $ZodCheck({
|
|
2660
|
-
check: "custom",
|
|
2661
|
-
...normalizeParams(params)
|
|
2662
|
-
});
|
|
2663
|
-
ch._zod.check = fn;
|
|
2664
|
-
return ch;
|
|
2665
|
-
}
|
|
2666
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2667
|
-
function describe$1(description) {
|
|
2668
|
-
const ch = new $ZodCheck({ check: "describe" });
|
|
2669
|
-
ch._zod.onattach = [(inst) => {
|
|
2670
|
-
const existing = globalRegistry.get(inst) ?? {};
|
|
2671
|
-
globalRegistry.add(inst, {
|
|
2672
|
-
...existing,
|
|
2673
|
-
description
|
|
2674
|
-
});
|
|
2675
|
-
}];
|
|
2676
|
-
ch._zod.check = () => {};
|
|
2677
|
-
return ch;
|
|
2678
|
-
}
|
|
2679
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2680
|
-
function meta$1(metadata) {
|
|
2681
|
-
const ch = new $ZodCheck({ check: "meta" });
|
|
2682
|
-
ch._zod.onattach = [(inst) => {
|
|
2683
|
-
const existing = globalRegistry.get(inst) ?? {};
|
|
2684
|
-
globalRegistry.add(inst, {
|
|
2685
|
-
...existing,
|
|
2686
|
-
...metadata
|
|
2687
|
-
});
|
|
2688
|
-
}];
|
|
2689
|
-
ch._zod.check = () => {};
|
|
2690
|
-
return ch;
|
|
2691
|
-
}
|
|
2692
|
-
|
|
2693
|
-
//#endregion
|
|
2694
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/to-json-schema.js
|
|
2695
|
-
function initializeContext(params) {
|
|
2696
|
-
let target = params?.target ?? "draft-2020-12";
|
|
2697
|
-
if (target === "draft-4") target = "draft-04";
|
|
2698
|
-
if (target === "draft-7") target = "draft-07";
|
|
2699
|
-
return {
|
|
2700
|
-
processors: params.processors ?? {},
|
|
2701
|
-
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
2702
|
-
target,
|
|
2703
|
-
unrepresentable: params?.unrepresentable ?? "throw",
|
|
2704
|
-
override: params?.override ?? (() => {}),
|
|
2705
|
-
io: params?.io ?? "output",
|
|
2706
|
-
counter: 0,
|
|
2707
|
-
seen: /* @__PURE__ */ new Map(),
|
|
2708
|
-
cycles: params?.cycles ?? "ref",
|
|
2709
|
-
reused: params?.reused ?? "inline",
|
|
2710
|
-
external: params?.external ?? void 0
|
|
2711
|
-
};
|
|
2712
|
-
}
|
|
2713
|
-
function process$1(schema, ctx, _params = {
|
|
2714
|
-
path: [],
|
|
2715
|
-
schemaPath: []
|
|
2716
|
-
}) {
|
|
2717
|
-
var _a$1;
|
|
2718
|
-
const def = schema._zod.def;
|
|
2719
|
-
const seen = ctx.seen.get(schema);
|
|
2720
|
-
if (seen) {
|
|
2721
|
-
seen.count++;
|
|
2722
|
-
if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
|
|
2723
|
-
return seen.schema;
|
|
2724
|
-
}
|
|
2725
|
-
const result = {
|
|
2726
|
-
schema: {},
|
|
2727
|
-
count: 1,
|
|
2728
|
-
cycle: void 0,
|
|
2729
|
-
path: _params.path
|
|
2730
|
-
};
|
|
2731
|
-
ctx.seen.set(schema, result);
|
|
2732
|
-
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
2733
|
-
if (overrideSchema) result.schema = overrideSchema;
|
|
2734
|
-
else {
|
|
2735
|
-
const params = {
|
|
2736
|
-
..._params,
|
|
2737
|
-
schemaPath: [..._params.schemaPath, schema],
|
|
2738
|
-
path: _params.path
|
|
2739
|
-
};
|
|
2740
|
-
if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
|
|
2741
|
-
else {
|
|
2742
|
-
const _json = result.schema;
|
|
2743
|
-
const processor = ctx.processors[def.type];
|
|
2744
|
-
if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
2745
|
-
processor(schema, ctx, _json, params);
|
|
2746
|
-
}
|
|
2747
|
-
const parent = schema._zod.parent;
|
|
2748
|
-
if (parent) {
|
|
2749
|
-
if (!result.ref) result.ref = parent;
|
|
2750
|
-
process$1(parent, ctx, params);
|
|
2751
|
-
ctx.seen.get(parent).isParent = true;
|
|
2752
|
-
}
|
|
2753
|
-
}
|
|
2754
|
-
const meta$2 = ctx.metadataRegistry.get(schema);
|
|
2755
|
-
if (meta$2) Object.assign(result.schema, meta$2);
|
|
2756
|
-
if (ctx.io === "input" && isTransforming(schema)) {
|
|
2757
|
-
delete result.schema.examples;
|
|
2758
|
-
delete result.schema.default;
|
|
2759
|
-
}
|
|
2760
|
-
if (ctx.io === "input" && result.schema._prefault) (_a$1 = result.schema).default ?? (_a$1.default = result.schema._prefault);
|
|
2761
|
-
delete result.schema._prefault;
|
|
2762
|
-
return ctx.seen.get(schema).schema;
|
|
2763
|
-
}
|
|
2764
|
-
function extractDefs(ctx, schema) {
|
|
2765
|
-
const root = ctx.seen.get(schema);
|
|
2766
|
-
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
2767
|
-
const idToSchema = /* @__PURE__ */ new Map();
|
|
2768
|
-
for (const entry of ctx.seen.entries()) {
|
|
2769
|
-
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
2770
|
-
if (id) {
|
|
2771
|
-
const existing = idToSchema.get(id);
|
|
2772
|
-
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.`);
|
|
2773
|
-
idToSchema.set(id, entry[0]);
|
|
2774
|
-
}
|
|
2775
|
-
}
|
|
2776
|
-
const makeURI = (entry) => {
|
|
2777
|
-
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
2778
|
-
if (ctx.external) {
|
|
2779
|
-
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
2780
|
-
const uriGenerator = ctx.external.uri ?? ((id$1) => id$1);
|
|
2781
|
-
if (externalId) return { ref: uriGenerator(externalId) };
|
|
2782
|
-
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
2783
|
-
entry[1].defId = id;
|
|
2784
|
-
return {
|
|
2785
|
-
defId: id,
|
|
2786
|
-
ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
|
|
2787
|
-
};
|
|
2788
|
-
}
|
|
2789
|
-
if (entry[1] === root) return { ref: "#" };
|
|
2790
|
-
const defUriPrefix = `#/${defsSegment}/`;
|
|
2791
|
-
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
2792
|
-
return {
|
|
2793
|
-
defId,
|
|
2794
|
-
ref: defUriPrefix + defId
|
|
2795
|
-
};
|
|
2796
|
-
};
|
|
2797
|
-
const extractToDef = (entry) => {
|
|
2798
|
-
if (entry[1].schema.$ref) return;
|
|
2799
|
-
const seen = entry[1];
|
|
2800
|
-
const { ref, defId } = makeURI(entry);
|
|
2801
|
-
seen.def = { ...seen.schema };
|
|
2802
|
-
if (defId) seen.defId = defId;
|
|
2803
|
-
const schema$1 = seen.schema;
|
|
2804
|
-
for (const key in schema$1) delete schema$1[key];
|
|
2805
|
-
schema$1.$ref = ref;
|
|
2806
|
-
};
|
|
2807
|
-
if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
|
|
2808
|
-
const seen = entry[1];
|
|
2809
|
-
if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
|
|
2810
|
-
|
|
2811
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
2812
|
-
}
|
|
2813
|
-
for (const entry of ctx.seen.entries()) {
|
|
2814
|
-
const seen = entry[1];
|
|
2815
|
-
if (schema === entry[0]) {
|
|
2816
|
-
extractToDef(entry);
|
|
2817
|
-
continue;
|
|
2818
|
-
}
|
|
2819
|
-
if (ctx.external) {
|
|
2820
|
-
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
2821
|
-
if (schema !== entry[0] && ext) {
|
|
2822
|
-
extractToDef(entry);
|
|
2823
|
-
continue;
|
|
2824
|
-
}
|
|
2825
|
-
}
|
|
2826
|
-
if (ctx.metadataRegistry.get(entry[0])?.id) {
|
|
2827
|
-
extractToDef(entry);
|
|
2828
|
-
continue;
|
|
2829
|
-
}
|
|
2830
|
-
if (seen.cycle) {
|
|
2831
|
-
extractToDef(entry);
|
|
2832
|
-
continue;
|
|
2833
|
-
}
|
|
2834
|
-
if (seen.count > 1) {
|
|
2835
|
-
if (ctx.reused === "ref") {
|
|
2836
|
-
extractToDef(entry);
|
|
2837
|
-
continue;
|
|
2838
|
-
}
|
|
2839
|
-
}
|
|
2840
|
-
}
|
|
2841
|
-
}
|
|
2842
|
-
function finalize(ctx, schema) {
|
|
2843
|
-
const root = ctx.seen.get(schema);
|
|
2844
|
-
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
2845
|
-
const flattenRef = (zodSchema) => {
|
|
2846
|
-
const seen = ctx.seen.get(zodSchema);
|
|
2847
|
-
if (seen.ref === null) return;
|
|
2848
|
-
const schema$1 = seen.def ?? seen.schema;
|
|
2849
|
-
const _cached = { ...schema$1 };
|
|
2850
|
-
const ref = seen.ref;
|
|
2851
|
-
seen.ref = null;
|
|
2852
|
-
if (ref) {
|
|
2853
|
-
flattenRef(ref);
|
|
2854
|
-
const refSeen = ctx.seen.get(ref);
|
|
2855
|
-
const refSchema = refSeen.schema;
|
|
2856
|
-
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
2857
|
-
schema$1.allOf = schema$1.allOf ?? [];
|
|
2858
|
-
schema$1.allOf.push(refSchema);
|
|
2859
|
-
} else Object.assign(schema$1, refSchema);
|
|
2860
|
-
Object.assign(schema$1, _cached);
|
|
2861
|
-
if (zodSchema._zod.parent === ref) for (const key in schema$1) {
|
|
2862
|
-
if (key === "$ref" || key === "allOf") continue;
|
|
2863
|
-
if (!(key in _cached)) delete schema$1[key];
|
|
2864
|
-
}
|
|
2865
|
-
if (refSchema.$ref) for (const key in schema$1) {
|
|
2866
|
-
if (key === "$ref" || key === "allOf") continue;
|
|
2867
|
-
if (key in refSeen.def && JSON.stringify(schema$1[key]) === JSON.stringify(refSeen.def[key])) delete schema$1[key];
|
|
2868
|
-
}
|
|
2869
|
-
}
|
|
2870
|
-
const parent = zodSchema._zod.parent;
|
|
2871
|
-
if (parent && parent !== ref) {
|
|
2872
|
-
flattenRef(parent);
|
|
2873
|
-
const parentSeen = ctx.seen.get(parent);
|
|
2874
|
-
if (parentSeen?.schema.$ref) {
|
|
2875
|
-
schema$1.$ref = parentSeen.schema.$ref;
|
|
2876
|
-
if (parentSeen.def) for (const key in schema$1) {
|
|
2877
|
-
if (key === "$ref" || key === "allOf") continue;
|
|
2878
|
-
if (key in parentSeen.def && JSON.stringify(schema$1[key]) === JSON.stringify(parentSeen.def[key])) delete schema$1[key];
|
|
2879
|
-
}
|
|
2880
|
-
}
|
|
2881
|
-
}
|
|
2882
|
-
ctx.override({
|
|
2883
|
-
zodSchema,
|
|
2884
|
-
jsonSchema: schema$1,
|
|
2885
|
-
path: seen.path ?? []
|
|
2886
|
-
});
|
|
2887
|
-
};
|
|
2888
|
-
for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
|
|
2889
|
-
const result = {};
|
|
2890
|
-
if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
2891
|
-
else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
2892
|
-
else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
2893
|
-
else if (ctx.target === "openapi-3.0") {}
|
|
2894
|
-
if (ctx.external?.uri) {
|
|
2895
|
-
const id = ctx.external.registry.get(schema)?.id;
|
|
2896
|
-
if (!id) throw new Error("Schema is missing an `id` property");
|
|
2897
|
-
result.$id = ctx.external.uri(id);
|
|
2898
|
-
}
|
|
2899
|
-
Object.assign(result, root.def ?? root.schema);
|
|
2900
|
-
const defs = ctx.external?.defs ?? {};
|
|
2901
|
-
for (const entry of ctx.seen.entries()) {
|
|
2902
|
-
const seen = entry[1];
|
|
2903
|
-
if (seen.def && seen.defId) defs[seen.defId] = seen.def;
|
|
2904
|
-
}
|
|
2905
|
-
if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
|
|
2906
|
-
else result.definitions = defs;
|
|
2907
|
-
try {
|
|
2908
|
-
const finalized = JSON.parse(JSON.stringify(result));
|
|
2909
|
-
Object.defineProperty(finalized, "~standard", {
|
|
2910
|
-
value: {
|
|
2911
|
-
...schema["~standard"],
|
|
2912
|
-
jsonSchema: {
|
|
2913
|
-
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
|
|
2914
|
-
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
|
|
2915
|
-
}
|
|
2916
|
-
},
|
|
2917
|
-
enumerable: false,
|
|
2918
|
-
writable: false
|
|
2919
|
-
});
|
|
2920
|
-
return finalized;
|
|
2921
|
-
} catch (_err) {
|
|
2922
|
-
throw new Error("Error converting schema to JSON.");
|
|
2923
|
-
}
|
|
2924
|
-
}
|
|
2925
|
-
function isTransforming(_schema, _ctx) {
|
|
2926
|
-
const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
|
|
2927
|
-
if (ctx.seen.has(_schema)) return false;
|
|
2928
|
-
ctx.seen.add(_schema);
|
|
2929
|
-
const def = _schema._zod.def;
|
|
2930
|
-
if (def.type === "transform") return true;
|
|
2931
|
-
if (def.type === "array") return isTransforming(def.element, ctx);
|
|
2932
|
-
if (def.type === "set") return isTransforming(def.valueType, ctx);
|
|
2933
|
-
if (def.type === "lazy") return isTransforming(def.getter(), ctx);
|
|
2934
|
-
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);
|
|
2935
|
-
if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
2936
|
-
if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
2937
|
-
if (def.type === "pipe") return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
2938
|
-
if (def.type === "object") {
|
|
2939
|
-
for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
|
|
2940
|
-
return false;
|
|
2941
|
-
}
|
|
2942
|
-
if (def.type === "union") {
|
|
2943
|
-
for (const option of def.options) if (isTransforming(option, ctx)) return true;
|
|
2944
|
-
return false;
|
|
2945
|
-
}
|
|
2946
|
-
if (def.type === "tuple") {
|
|
2947
|
-
for (const item of def.items) if (isTransforming(item, ctx)) return true;
|
|
2948
|
-
if (def.rest && isTransforming(def.rest, ctx)) return true;
|
|
2949
|
-
return false;
|
|
2950
|
-
}
|
|
2951
|
-
return false;
|
|
2952
|
-
}
|
|
2953
|
-
/**
|
|
2954
|
-
* Creates a toJSONSchema method for a schema instance.
|
|
2955
|
-
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
|
2956
|
-
*/
|
|
2957
|
-
const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
2958
|
-
const ctx = initializeContext({
|
|
2959
|
-
...params,
|
|
2960
|
-
processors
|
|
2961
|
-
});
|
|
2962
|
-
process$1(schema, ctx);
|
|
2963
|
-
extractDefs(ctx, schema);
|
|
2964
|
-
return finalize(ctx, schema);
|
|
2965
|
-
};
|
|
2966
|
-
const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
2967
|
-
const { libraryOptions, target } = params ?? {};
|
|
2968
|
-
const ctx = initializeContext({
|
|
2969
|
-
...libraryOptions ?? {},
|
|
2970
|
-
target,
|
|
2971
|
-
io,
|
|
2972
|
-
processors
|
|
2973
|
-
});
|
|
2974
|
-
process$1(schema, ctx);
|
|
2975
|
-
extractDefs(ctx, schema);
|
|
2976
|
-
return finalize(ctx, schema);
|
|
2977
|
-
};
|
|
2978
|
-
|
|
2979
|
-
//#endregion
|
|
2980
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/json-schema-processors.js
|
|
2981
|
-
const formatMap = {
|
|
2982
|
-
guid: "uuid",
|
|
2983
|
-
url: "uri",
|
|
2984
|
-
datetime: "date-time",
|
|
2985
|
-
json_string: "json-string",
|
|
2986
|
-
regex: ""
|
|
2987
|
-
};
|
|
2988
|
-
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
2989
|
-
const json = _json;
|
|
2990
|
-
json.type = "string";
|
|
2991
|
-
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
|
|
2992
|
-
if (typeof minimum === "number") json.minLength = minimum;
|
|
2993
|
-
if (typeof maximum === "number") json.maxLength = maximum;
|
|
2994
|
-
if (format) {
|
|
2995
|
-
json.format = formatMap[format] ?? format;
|
|
2996
|
-
if (json.format === "") delete json.format;
|
|
2997
|
-
if (format === "time") delete json.format;
|
|
2998
|
-
}
|
|
2999
|
-
if (contentEncoding) json.contentEncoding = contentEncoding;
|
|
3000
|
-
if (patterns && patterns.size > 0) {
|
|
3001
|
-
const regexes = [...patterns];
|
|
3002
|
-
if (regexes.length === 1) json.pattern = regexes[0].source;
|
|
3003
|
-
else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
|
|
3004
|
-
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
3005
|
-
pattern: regex.source
|
|
3006
|
-
}))];
|
|
3007
|
-
}
|
|
3008
|
-
};
|
|
3009
|
-
const numberProcessor = (schema, ctx, _json, _params) => {
|
|
3010
|
-
const json = _json;
|
|
3011
|
-
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
3012
|
-
if (typeof format === "string" && format.includes("int")) json.type = "integer";
|
|
3013
|
-
else json.type = "number";
|
|
3014
|
-
if (typeof exclusiveMinimum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
3015
|
-
json.minimum = exclusiveMinimum;
|
|
3016
|
-
json.exclusiveMinimum = true;
|
|
3017
|
-
} else json.exclusiveMinimum = exclusiveMinimum;
|
|
3018
|
-
if (typeof minimum === "number") {
|
|
3019
|
-
json.minimum = minimum;
|
|
3020
|
-
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") if (exclusiveMinimum >= minimum) delete json.minimum;
|
|
3021
|
-
else delete json.exclusiveMinimum;
|
|
3022
|
-
}
|
|
3023
|
-
if (typeof exclusiveMaximum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
3024
|
-
json.maximum = exclusiveMaximum;
|
|
3025
|
-
json.exclusiveMaximum = true;
|
|
3026
|
-
} else json.exclusiveMaximum = exclusiveMaximum;
|
|
3027
|
-
if (typeof maximum === "number") {
|
|
3028
|
-
json.maximum = maximum;
|
|
3029
|
-
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") if (exclusiveMaximum <= maximum) delete json.maximum;
|
|
3030
|
-
else delete json.exclusiveMaximum;
|
|
3031
|
-
}
|
|
3032
|
-
if (typeof multipleOf === "number") json.multipleOf = multipleOf;
|
|
3033
|
-
};
|
|
3034
|
-
const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
3035
|
-
json.type = "boolean";
|
|
3036
|
-
};
|
|
3037
|
-
const neverProcessor = (_schema, _ctx, json, _params) => {
|
|
3038
|
-
json.not = {};
|
|
3039
|
-
};
|
|
3040
|
-
const unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
3041
|
-
const enumProcessor = (schema, _ctx, json, _params) => {
|
|
3042
|
-
const def = schema._zod.def;
|
|
3043
|
-
const values = getEnumValues(def.entries);
|
|
3044
|
-
if (values.every((v) => typeof v === "number")) json.type = "number";
|
|
3045
|
-
if (values.every((v) => typeof v === "string")) json.type = "string";
|
|
3046
|
-
json.enum = values;
|
|
3047
|
-
};
|
|
3048
|
-
const literalProcessor = (schema, ctx, json, _params) => {
|
|
3049
|
-
const def = schema._zod.def;
|
|
3050
|
-
const vals = [];
|
|
3051
|
-
for (const val of def.values) if (val === void 0) {
|
|
3052
|
-
if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
3053
|
-
} else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
3054
|
-
else vals.push(Number(val));
|
|
3055
|
-
else vals.push(val);
|
|
3056
|
-
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
3057
|
-
const val = vals[0];
|
|
3058
|
-
json.type = val === null ? "null" : typeof val;
|
|
3059
|
-
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
|
|
3060
|
-
else json.const = val;
|
|
3061
|
-
} else {
|
|
3062
|
-
if (vals.every((v) => typeof v === "number")) json.type = "number";
|
|
3063
|
-
if (vals.every((v) => typeof v === "string")) json.type = "string";
|
|
3064
|
-
if (vals.every((v) => typeof v === "boolean")) json.type = "boolean";
|
|
3065
|
-
if (vals.every((v) => v === null)) json.type = "null";
|
|
3066
|
-
json.enum = vals;
|
|
3067
|
-
}
|
|
3068
|
-
};
|
|
3069
|
-
const customProcessor = (_schema, ctx, _json, _params) => {
|
|
3070
|
-
if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
3071
|
-
};
|
|
3072
|
-
const transformProcessor = (_schema, ctx, _json, _params) => {
|
|
3073
|
-
if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
3074
|
-
};
|
|
3075
|
-
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
3076
|
-
const json = _json;
|
|
3077
|
-
const def = schema._zod.def;
|
|
3078
|
-
const { minimum, maximum } = schema._zod.bag;
|
|
3079
|
-
if (typeof minimum === "number") json.minItems = minimum;
|
|
3080
|
-
if (typeof maximum === "number") json.maxItems = maximum;
|
|
3081
|
-
json.type = "array";
|
|
3082
|
-
json.items = process$1(def.element, ctx, {
|
|
3083
|
-
...params,
|
|
3084
|
-
path: [...params.path, "items"]
|
|
3085
|
-
});
|
|
3086
|
-
};
|
|
3087
|
-
const objectProcessor = (schema, ctx, _json, params) => {
|
|
3088
|
-
const json = _json;
|
|
3089
|
-
const def = schema._zod.def;
|
|
3090
|
-
json.type = "object";
|
|
3091
|
-
json.properties = {};
|
|
3092
|
-
const shape = def.shape;
|
|
3093
|
-
for (const key in shape) json.properties[key] = process$1(shape[key], ctx, {
|
|
3094
|
-
...params,
|
|
3095
|
-
path: [
|
|
3096
|
-
...params.path,
|
|
3097
|
-
"properties",
|
|
3098
|
-
key
|
|
3099
|
-
]
|
|
3100
|
-
});
|
|
3101
|
-
const allKeys = new Set(Object.keys(shape));
|
|
3102
|
-
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
3103
|
-
const v = def.shape[key]._zod;
|
|
3104
|
-
if (ctx.io === "input") return v.optin === void 0;
|
|
3105
|
-
else return v.optout === void 0;
|
|
3106
|
-
}));
|
|
3107
|
-
if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
|
|
3108
|
-
if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
|
|
3109
|
-
else if (!def.catchall) {
|
|
3110
|
-
if (ctx.io === "output") json.additionalProperties = false;
|
|
3111
|
-
} else if (def.catchall) json.additionalProperties = process$1(def.catchall, ctx, {
|
|
3112
|
-
...params,
|
|
3113
|
-
path: [...params.path, "additionalProperties"]
|
|
3114
|
-
});
|
|
3115
|
-
};
|
|
3116
|
-
const unionProcessor = (schema, ctx, json, params) => {
|
|
3117
|
-
const def = schema._zod.def;
|
|
3118
|
-
const isExclusive = def.inclusive === false;
|
|
3119
|
-
const options = def.options.map((x, i) => process$1(x, ctx, {
|
|
3120
|
-
...params,
|
|
3121
|
-
path: [
|
|
3122
|
-
...params.path,
|
|
3123
|
-
isExclusive ? "oneOf" : "anyOf",
|
|
3124
|
-
i
|
|
3125
|
-
]
|
|
3126
|
-
}));
|
|
3127
|
-
if (isExclusive) json.oneOf = options;
|
|
3128
|
-
else json.anyOf = options;
|
|
3129
|
-
};
|
|
3130
|
-
const intersectionProcessor = (schema, ctx, json, params) => {
|
|
3131
|
-
const def = schema._zod.def;
|
|
3132
|
-
const a = process$1(def.left, ctx, {
|
|
3133
|
-
...params,
|
|
3134
|
-
path: [
|
|
3135
|
-
...params.path,
|
|
3136
|
-
"allOf",
|
|
3137
|
-
0
|
|
3138
|
-
]
|
|
3139
|
-
});
|
|
3140
|
-
const b = process$1(def.right, ctx, {
|
|
3141
|
-
...params,
|
|
3142
|
-
path: [
|
|
3143
|
-
...params.path,
|
|
3144
|
-
"allOf",
|
|
3145
|
-
1
|
|
3146
|
-
]
|
|
3147
|
-
});
|
|
3148
|
-
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
3149
|
-
json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
|
|
3150
|
-
};
|
|
3151
|
-
const nullableProcessor = (schema, ctx, json, params) => {
|
|
3152
|
-
const def = schema._zod.def;
|
|
3153
|
-
const inner = process$1(def.innerType, ctx, params);
|
|
3154
|
-
const seen = ctx.seen.get(schema);
|
|
3155
|
-
if (ctx.target === "openapi-3.0") {
|
|
3156
|
-
seen.ref = def.innerType;
|
|
3157
|
-
json.nullable = true;
|
|
3158
|
-
} else json.anyOf = [inner, { type: "null" }];
|
|
3159
|
-
};
|
|
3160
|
-
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
3161
|
-
const def = schema._zod.def;
|
|
3162
|
-
process$1(def.innerType, ctx, params);
|
|
3163
|
-
const seen = ctx.seen.get(schema);
|
|
3164
|
-
seen.ref = def.innerType;
|
|
3165
|
-
};
|
|
3166
|
-
const defaultProcessor = (schema, ctx, json, params) => {
|
|
3167
|
-
const def = schema._zod.def;
|
|
3168
|
-
process$1(def.innerType, ctx, params);
|
|
3169
|
-
const seen = ctx.seen.get(schema);
|
|
3170
|
-
seen.ref = def.innerType;
|
|
3171
|
-
json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
3172
|
-
};
|
|
3173
|
-
const prefaultProcessor = (schema, ctx, json, params) => {
|
|
3174
|
-
const def = schema._zod.def;
|
|
3175
|
-
process$1(def.innerType, ctx, params);
|
|
3176
|
-
const seen = ctx.seen.get(schema);
|
|
3177
|
-
seen.ref = def.innerType;
|
|
3178
|
-
if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
3179
|
-
};
|
|
3180
|
-
const catchProcessor = (schema, ctx, json, params) => {
|
|
3181
|
-
const def = schema._zod.def;
|
|
3182
|
-
process$1(def.innerType, ctx, params);
|
|
3183
|
-
const seen = ctx.seen.get(schema);
|
|
3184
|
-
seen.ref = def.innerType;
|
|
3185
|
-
let catchValue;
|
|
3186
|
-
try {
|
|
3187
|
-
catchValue = def.catchValue(void 0);
|
|
3188
|
-
} catch {
|
|
3189
|
-
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
3190
|
-
}
|
|
3191
|
-
json.default = catchValue;
|
|
3192
|
-
};
|
|
3193
|
-
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
3194
|
-
const def = schema._zod.def;
|
|
3195
|
-
const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
|
|
3196
|
-
process$1(innerType, ctx, params);
|
|
3197
|
-
const seen = ctx.seen.get(schema);
|
|
3198
|
-
seen.ref = innerType;
|
|
3199
|
-
};
|
|
3200
|
-
const readonlyProcessor = (schema, ctx, json, params) => {
|
|
3201
|
-
const def = schema._zod.def;
|
|
3202
|
-
process$1(def.innerType, ctx, params);
|
|
3203
|
-
const seen = ctx.seen.get(schema);
|
|
3204
|
-
seen.ref = def.innerType;
|
|
3205
|
-
json.readOnly = true;
|
|
3206
|
-
};
|
|
3207
|
-
const optionalProcessor = (schema, ctx, _json, params) => {
|
|
3208
|
-
const def = schema._zod.def;
|
|
3209
|
-
process$1(def.innerType, ctx, params);
|
|
3210
|
-
const seen = ctx.seen.get(schema);
|
|
3211
|
-
seen.ref = def.innerType;
|
|
3212
|
-
};
|
|
3213
|
-
|
|
3214
|
-
//#endregion
|
|
3215
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/classic/iso.js
|
|
3216
|
-
const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
3217
|
-
$ZodISODateTime.init(inst, def);
|
|
3218
|
-
ZodStringFormat.init(inst, def);
|
|
3219
|
-
});
|
|
3220
|
-
function datetime(params) {
|
|
3221
|
-
return _isoDateTime(ZodISODateTime, params);
|
|
3222
|
-
}
|
|
3223
|
-
const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
|
|
3224
|
-
$ZodISODate.init(inst, def);
|
|
3225
|
-
ZodStringFormat.init(inst, def);
|
|
3226
|
-
});
|
|
3227
|
-
function date(params) {
|
|
3228
|
-
return _isoDate(ZodISODate, params);
|
|
3229
|
-
}
|
|
3230
|
-
const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
|
|
3231
|
-
$ZodISOTime.init(inst, def);
|
|
3232
|
-
ZodStringFormat.init(inst, def);
|
|
3233
|
-
});
|
|
3234
|
-
function time(params) {
|
|
3235
|
-
return _isoTime(ZodISOTime, params);
|
|
3236
|
-
}
|
|
3237
|
-
const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
|
|
3238
|
-
$ZodISODuration.init(inst, def);
|
|
3239
|
-
ZodStringFormat.init(inst, def);
|
|
3240
|
-
});
|
|
3241
|
-
function duration(params) {
|
|
3242
|
-
return _isoDuration(ZodISODuration, params);
|
|
3243
|
-
}
|
|
3244
|
-
|
|
3245
|
-
//#endregion
|
|
3246
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/classic/errors.js
|
|
3247
|
-
const initializer = (inst, issues) => {
|
|
3248
|
-
$ZodError.init(inst, issues);
|
|
3249
|
-
inst.name = "ZodError";
|
|
3250
|
-
Object.defineProperties(inst, {
|
|
3251
|
-
format: { value: (mapper) => formatError(inst, mapper) },
|
|
3252
|
-
flatten: { value: (mapper) => flattenError(inst, mapper) },
|
|
3253
|
-
addIssue: { value: (issue$1) => {
|
|
3254
|
-
inst.issues.push(issue$1);
|
|
3255
|
-
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
3256
|
-
} },
|
|
3257
|
-
addIssues: { value: (issues$1) => {
|
|
3258
|
-
inst.issues.push(...issues$1);
|
|
3259
|
-
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
3260
|
-
} },
|
|
3261
|
-
isEmpty: { get() {
|
|
3262
|
-
return inst.issues.length === 0;
|
|
3263
|
-
} }
|
|
3264
|
-
});
|
|
3265
|
-
};
|
|
3266
|
-
const ZodError = $constructor("ZodError", initializer);
|
|
3267
|
-
const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
|
|
3268
|
-
|
|
3269
|
-
//#endregion
|
|
3270
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/classic/parse.js
|
|
3271
|
-
const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
3272
|
-
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
3273
|
-
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
3274
|
-
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
3275
|
-
const encode = /* @__PURE__ */ _encode(ZodRealError);
|
|
3276
|
-
const decode = /* @__PURE__ */ _decode(ZodRealError);
|
|
3277
|
-
const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
3278
|
-
const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
3279
|
-
const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
3280
|
-
const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
3281
|
-
const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
3282
|
-
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
3283
|
-
|
|
3284
|
-
//#endregion
|
|
3285
|
-
//#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/classic/schemas.js
|
|
3286
|
-
const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
3287
|
-
$ZodType.init(inst, def);
|
|
3288
|
-
Object.assign(inst["~standard"], { jsonSchema: {
|
|
3289
|
-
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
3290
|
-
output: createStandardJSONSchemaMethod(inst, "output")
|
|
3291
|
-
} });
|
|
3292
|
-
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
3293
|
-
inst.def = def;
|
|
3294
|
-
inst.type = def.type;
|
|
3295
|
-
Object.defineProperty(inst, "_def", { value: def });
|
|
3296
|
-
inst.check = (...checks) => {
|
|
3297
|
-
return inst.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
3298
|
-
check: ch,
|
|
3299
|
-
def: { check: "custom" },
|
|
3300
|
-
onattach: []
|
|
3301
|
-
} } : ch)] }), { parent: true });
|
|
3302
|
-
};
|
|
3303
|
-
inst.with = inst.check;
|
|
3304
|
-
inst.clone = (def$1, params) => clone(inst, def$1, params);
|
|
3305
|
-
inst.brand = () => inst;
|
|
3306
|
-
inst.register = ((reg, meta$2) => {
|
|
3307
|
-
reg.add(inst, meta$2);
|
|
3308
|
-
return inst;
|
|
3309
|
-
});
|
|
3310
|
-
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
3311
|
-
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
3312
|
-
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
3313
|
-
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
3314
|
-
inst.spa = inst.safeParseAsync;
|
|
3315
|
-
inst.encode = (data, params) => encode(inst, data, params);
|
|
3316
|
-
inst.decode = (data, params) => decode(inst, data, params);
|
|
3317
|
-
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
3318
|
-
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
3319
|
-
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
3320
|
-
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
3321
|
-
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
3322
|
-
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
3323
|
-
inst.refine = (check, params) => inst.check(refine(check, params));
|
|
3324
|
-
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
3325
|
-
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
3326
|
-
inst.optional = () => optional(inst);
|
|
3327
|
-
inst.exactOptional = () => exactOptional(inst);
|
|
3328
|
-
inst.nullable = () => nullable(inst);
|
|
3329
|
-
inst.nullish = () => optional(nullable(inst));
|
|
3330
|
-
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
3331
|
-
inst.array = () => array(inst);
|
|
3332
|
-
inst.or = (arg) => union([inst, arg]);
|
|
3333
|
-
inst.and = (arg) => intersection(inst, arg);
|
|
3334
|
-
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
3335
|
-
inst.default = (def$1) => _default(inst, def$1);
|
|
3336
|
-
inst.prefault = (def$1) => prefault(inst, def$1);
|
|
3337
|
-
inst.catch = (params) => _catch(inst, params);
|
|
3338
|
-
inst.pipe = (target) => pipe(inst, target);
|
|
3339
|
-
inst.readonly = () => readonly(inst);
|
|
3340
|
-
inst.describe = (description) => {
|
|
3341
|
-
const cl = inst.clone();
|
|
3342
|
-
globalRegistry.add(cl, { description });
|
|
3343
|
-
return cl;
|
|
3344
|
-
};
|
|
3345
|
-
Object.defineProperty(inst, "description", {
|
|
3346
|
-
get() {
|
|
3347
|
-
return globalRegistry.get(inst)?.description;
|
|
3348
|
-
},
|
|
3349
|
-
configurable: true
|
|
3350
|
-
});
|
|
3351
|
-
inst.meta = (...args) => {
|
|
3352
|
-
if (args.length === 0) return globalRegistry.get(inst);
|
|
3353
|
-
const cl = inst.clone();
|
|
3354
|
-
globalRegistry.add(cl, args[0]);
|
|
3355
|
-
return cl;
|
|
3356
|
-
};
|
|
3357
|
-
inst.isOptional = () => inst.safeParse(void 0).success;
|
|
3358
|
-
inst.isNullable = () => inst.safeParse(null).success;
|
|
3359
|
-
inst.apply = (fn) => fn(inst);
|
|
3360
|
-
return inst;
|
|
3361
|
-
});
|
|
3362
|
-
/** @internal */
|
|
3363
|
-
const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
3364
|
-
$ZodString.init(inst, def);
|
|
3365
|
-
ZodType.init(inst, def);
|
|
3366
|
-
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
3367
|
-
const bag = inst._zod.bag;
|
|
3368
|
-
inst.format = bag.format ?? null;
|
|
3369
|
-
inst.minLength = bag.minimum ?? null;
|
|
3370
|
-
inst.maxLength = bag.maximum ?? null;
|
|
3371
|
-
inst.regex = (...args) => inst.check(_regex(...args));
|
|
3372
|
-
inst.includes = (...args) => inst.check(_includes(...args));
|
|
3373
|
-
inst.startsWith = (...args) => inst.check(_startsWith(...args));
|
|
3374
|
-
inst.endsWith = (...args) => inst.check(_endsWith(...args));
|
|
3375
|
-
inst.min = (...args) => inst.check(_minLength(...args));
|
|
3376
|
-
inst.max = (...args) => inst.check(_maxLength(...args));
|
|
3377
|
-
inst.length = (...args) => inst.check(_length(...args));
|
|
3378
|
-
inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
|
|
3379
|
-
inst.lowercase = (params) => inst.check(_lowercase(params));
|
|
3380
|
-
inst.uppercase = (params) => inst.check(_uppercase(params));
|
|
3381
|
-
inst.trim = () => inst.check(_trim());
|
|
3382
|
-
inst.normalize = (...args) => inst.check(_normalize(...args));
|
|
3383
|
-
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
3384
|
-
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
3385
|
-
inst.slugify = () => inst.check(_slugify());
|
|
3386
|
-
});
|
|
3387
|
-
const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
3388
|
-
$ZodString.init(inst, def);
|
|
3389
|
-
_ZodString.init(inst, def);
|
|
3390
|
-
inst.email = (params) => inst.check(_email(ZodEmail, params));
|
|
3391
|
-
inst.url = (params) => inst.check(_url(ZodURL, params));
|
|
3392
|
-
inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
|
|
3393
|
-
inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
|
|
3394
|
-
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
3395
|
-
inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
|
|
3396
|
-
inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
|
|
3397
|
-
inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
|
|
3398
|
-
inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
|
|
3399
|
-
inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
|
|
3400
|
-
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
3401
|
-
inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
|
|
3402
|
-
inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
|
|
3403
|
-
inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
|
|
3404
|
-
inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
|
|
3405
|
-
inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
|
|
3406
|
-
inst.xid = (params) => inst.check(_xid(ZodXID, params));
|
|
3407
|
-
inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
|
|
3408
|
-
inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
|
|
3409
|
-
inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
|
|
3410
|
-
inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
|
|
3411
|
-
inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
|
|
3412
|
-
inst.e164 = (params) => inst.check(_e164(ZodE164, params));
|
|
3413
|
-
inst.datetime = (params) => inst.check(datetime(params));
|
|
3414
|
-
inst.date = (params) => inst.check(date(params));
|
|
3415
|
-
inst.time = (params) => inst.check(time(params));
|
|
3416
|
-
inst.duration = (params) => inst.check(duration(params));
|
|
3417
|
-
});
|
|
3418
|
-
function string(params) {
|
|
3419
|
-
return _string(ZodString, params);
|
|
3420
|
-
}
|
|
3421
|
-
const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
|
|
3422
|
-
$ZodStringFormat.init(inst, def);
|
|
3423
|
-
_ZodString.init(inst, def);
|
|
3424
|
-
});
|
|
3425
|
-
const ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
|
|
3426
|
-
$ZodEmail.init(inst, def);
|
|
3427
|
-
ZodStringFormat.init(inst, def);
|
|
3428
|
-
});
|
|
3429
|
-
const ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
|
|
3430
|
-
$ZodGUID.init(inst, def);
|
|
3431
|
-
ZodStringFormat.init(inst, def);
|
|
3432
|
-
});
|
|
3433
|
-
const ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
|
|
3434
|
-
$ZodUUID.init(inst, def);
|
|
3435
|
-
ZodStringFormat.init(inst, def);
|
|
3436
|
-
});
|
|
3437
|
-
const ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
|
|
3438
|
-
$ZodURL.init(inst, def);
|
|
3439
|
-
ZodStringFormat.init(inst, def);
|
|
3440
|
-
});
|
|
3441
|
-
const ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
|
|
3442
|
-
$ZodEmoji.init(inst, def);
|
|
3443
|
-
ZodStringFormat.init(inst, def);
|
|
3444
|
-
});
|
|
3445
|
-
const ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
|
|
3446
|
-
$ZodNanoID.init(inst, def);
|
|
3447
|
-
ZodStringFormat.init(inst, def);
|
|
3448
|
-
});
|
|
3449
|
-
const ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
|
|
3450
|
-
$ZodCUID.init(inst, def);
|
|
3451
|
-
ZodStringFormat.init(inst, def);
|
|
3452
|
-
});
|
|
3453
|
-
const ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
|
|
3454
|
-
$ZodCUID2.init(inst, def);
|
|
3455
|
-
ZodStringFormat.init(inst, def);
|
|
3456
|
-
});
|
|
3457
|
-
const ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
|
|
3458
|
-
$ZodULID.init(inst, def);
|
|
3459
|
-
ZodStringFormat.init(inst, def);
|
|
3460
|
-
});
|
|
3461
|
-
const ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
|
|
3462
|
-
$ZodXID.init(inst, def);
|
|
3463
|
-
ZodStringFormat.init(inst, def);
|
|
3464
|
-
});
|
|
3465
|
-
const ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
|
|
3466
|
-
$ZodKSUID.init(inst, def);
|
|
3467
|
-
ZodStringFormat.init(inst, def);
|
|
3468
|
-
});
|
|
3469
|
-
const ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
|
|
3470
|
-
$ZodIPv4.init(inst, def);
|
|
3471
|
-
ZodStringFormat.init(inst, def);
|
|
3472
|
-
});
|
|
3473
|
-
const ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
|
|
3474
|
-
$ZodIPv6.init(inst, def);
|
|
3475
|
-
ZodStringFormat.init(inst, def);
|
|
3476
|
-
});
|
|
3477
|
-
const ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
|
|
3478
|
-
$ZodCIDRv4.init(inst, def);
|
|
3479
|
-
ZodStringFormat.init(inst, def);
|
|
3480
|
-
});
|
|
3481
|
-
const ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
|
|
3482
|
-
$ZodCIDRv6.init(inst, def);
|
|
3483
|
-
ZodStringFormat.init(inst, def);
|
|
3484
|
-
});
|
|
3485
|
-
const ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
|
|
3486
|
-
$ZodBase64.init(inst, def);
|
|
3487
|
-
ZodStringFormat.init(inst, def);
|
|
3488
|
-
});
|
|
3489
|
-
const ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
|
|
3490
|
-
$ZodBase64URL.init(inst, def);
|
|
3491
|
-
ZodStringFormat.init(inst, def);
|
|
3492
|
-
});
|
|
3493
|
-
const ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
|
|
3494
|
-
$ZodE164.init(inst, def);
|
|
3495
|
-
ZodStringFormat.init(inst, def);
|
|
3496
|
-
});
|
|
3497
|
-
const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
|
|
3498
|
-
$ZodJWT.init(inst, def);
|
|
3499
|
-
ZodStringFormat.init(inst, def);
|
|
3500
|
-
});
|
|
3501
|
-
const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
3502
|
-
$ZodNumber.init(inst, def);
|
|
3503
|
-
ZodType.init(inst, def);
|
|
3504
|
-
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
3505
|
-
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
3506
|
-
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
3507
|
-
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
3508
|
-
inst.lt = (value, params) => inst.check(_lt(value, params));
|
|
3509
|
-
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
3510
|
-
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
3511
|
-
inst.int = (params) => inst.check(int(params));
|
|
3512
|
-
inst.safe = (params) => inst.check(int(params));
|
|
3513
|
-
inst.positive = (params) => inst.check(_gt(0, params));
|
|
3514
|
-
inst.nonnegative = (params) => inst.check(_gte(0, params));
|
|
3515
|
-
inst.negative = (params) => inst.check(_lt(0, params));
|
|
3516
|
-
inst.nonpositive = (params) => inst.check(_lte(0, params));
|
|
3517
|
-
inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
|
|
3518
|
-
inst.step = (value, params) => inst.check(_multipleOf(value, params));
|
|
3519
|
-
inst.finite = () => inst;
|
|
3520
|
-
const bag = inst._zod.bag;
|
|
3521
|
-
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
3522
|
-
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
3523
|
-
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
|
|
3524
|
-
inst.isFinite = true;
|
|
3525
|
-
inst.format = bag.format ?? null;
|
|
3526
|
-
});
|
|
3527
|
-
function number(params) {
|
|
3528
|
-
return _number(ZodNumber, params);
|
|
3529
|
-
}
|
|
3530
|
-
const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
|
|
3531
|
-
$ZodNumberFormat.init(inst, def);
|
|
3532
|
-
ZodNumber.init(inst, def);
|
|
3533
|
-
});
|
|
3534
|
-
function int(params) {
|
|
3535
|
-
return _int(ZodNumberFormat, params);
|
|
3536
|
-
}
|
|
3537
|
-
const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
3538
|
-
$ZodBoolean.init(inst, def);
|
|
3539
|
-
ZodType.init(inst, def);
|
|
3540
|
-
inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
|
|
3541
|
-
});
|
|
3542
|
-
function boolean(params) {
|
|
3543
|
-
return _boolean(ZodBoolean, params);
|
|
3544
|
-
}
|
|
3545
|
-
const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
3546
|
-
$ZodUnknown.init(inst, def);
|
|
3547
|
-
ZodType.init(inst, def);
|
|
3548
|
-
inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
|
|
3549
|
-
});
|
|
3550
|
-
function unknown() {
|
|
3551
|
-
return _unknown(ZodUnknown);
|
|
3552
|
-
}
|
|
3553
|
-
const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
3554
|
-
$ZodNever.init(inst, def);
|
|
3555
|
-
ZodType.init(inst, def);
|
|
3556
|
-
inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
|
|
3557
|
-
});
|
|
3558
|
-
function never(params) {
|
|
3559
|
-
return _never(ZodNever, params);
|
|
3560
|
-
}
|
|
3561
|
-
const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
3562
|
-
$ZodArray.init(inst, def);
|
|
3563
|
-
ZodType.init(inst, def);
|
|
3564
|
-
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
3565
|
-
inst.element = def.element;
|
|
3566
|
-
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
3567
|
-
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
3568
|
-
inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
|
|
3569
|
-
inst.length = (len, params) => inst.check(_length(len, params));
|
|
3570
|
-
inst.unwrap = () => inst.element;
|
|
3571
|
-
});
|
|
3572
|
-
function array(element, params) {
|
|
3573
|
-
return _array(ZodArray, element, params);
|
|
3574
|
-
}
|
|
3575
|
-
const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
3576
|
-
$ZodObjectJIT.init(inst, def);
|
|
3577
|
-
ZodType.init(inst, def);
|
|
3578
|
-
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
3579
|
-
defineLazy(inst, "shape", () => {
|
|
3580
|
-
return def.shape;
|
|
3581
|
-
});
|
|
3582
|
-
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
3583
|
-
inst.catchall = (catchall) => inst.clone({
|
|
3584
|
-
...inst._zod.def,
|
|
3585
|
-
catchall
|
|
3586
|
-
});
|
|
3587
|
-
inst.passthrough = () => inst.clone({
|
|
3588
|
-
...inst._zod.def,
|
|
3589
|
-
catchall: unknown()
|
|
3590
|
-
});
|
|
3591
|
-
inst.loose = () => inst.clone({
|
|
3592
|
-
...inst._zod.def,
|
|
3593
|
-
catchall: unknown()
|
|
3594
|
-
});
|
|
3595
|
-
inst.strict = () => inst.clone({
|
|
3596
|
-
...inst._zod.def,
|
|
3597
|
-
catchall: never()
|
|
3598
|
-
});
|
|
3599
|
-
inst.strip = () => inst.clone({
|
|
3600
|
-
...inst._zod.def,
|
|
3601
|
-
catchall: void 0
|
|
3602
|
-
});
|
|
3603
|
-
inst.extend = (incoming) => {
|
|
3604
|
-
return extend(inst, incoming);
|
|
3605
|
-
};
|
|
3606
|
-
inst.safeExtend = (incoming) => {
|
|
3607
|
-
return safeExtend(inst, incoming);
|
|
3608
|
-
};
|
|
3609
|
-
inst.merge = (other) => merge(inst, other);
|
|
3610
|
-
inst.pick = (mask) => pick(inst, mask);
|
|
3611
|
-
inst.omit = (mask) => omit(inst, mask);
|
|
3612
|
-
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
3613
|
-
inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
|
|
3614
|
-
});
|
|
3615
|
-
function object(shape, params) {
|
|
3616
|
-
return new ZodObject({
|
|
3617
|
-
type: "object",
|
|
3618
|
-
shape: shape ?? {},
|
|
3619
|
-
...normalizeParams(params)
|
|
3620
|
-
});
|
|
3621
|
-
}
|
|
3622
|
-
const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
3623
|
-
$ZodUnion.init(inst, def);
|
|
3624
|
-
ZodType.init(inst, def);
|
|
3625
|
-
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
|
|
3626
|
-
inst.options = def.options;
|
|
3627
|
-
});
|
|
3628
|
-
function union(options, params) {
|
|
3629
|
-
return new ZodUnion({
|
|
3630
|
-
type: "union",
|
|
3631
|
-
options,
|
|
3632
|
-
...normalizeParams(params)
|
|
3633
|
-
});
|
|
3634
|
-
}
|
|
3635
|
-
const ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
3636
|
-
ZodUnion.init(inst, def);
|
|
3637
|
-
$ZodDiscriminatedUnion.init(inst, def);
|
|
3638
|
-
});
|
|
3639
|
-
function discriminatedUnion(discriminator, options, params) {
|
|
3640
|
-
return new ZodDiscriminatedUnion({
|
|
3641
|
-
type: "union",
|
|
3642
|
-
options,
|
|
3643
|
-
discriminator,
|
|
3644
|
-
...normalizeParams(params)
|
|
3645
|
-
});
|
|
3646
|
-
}
|
|
3647
|
-
const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
3648
|
-
$ZodIntersection.init(inst, def);
|
|
3649
|
-
ZodType.init(inst, def);
|
|
3650
|
-
inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
|
|
3651
|
-
});
|
|
3652
|
-
function intersection(left, right) {
|
|
3653
|
-
return new ZodIntersection({
|
|
3654
|
-
type: "intersection",
|
|
3655
|
-
left,
|
|
3656
|
-
right
|
|
3657
|
-
});
|
|
3658
|
-
}
|
|
3659
|
-
const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
3660
|
-
$ZodEnum.init(inst, def);
|
|
3661
|
-
ZodType.init(inst, def);
|
|
3662
|
-
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
3663
|
-
inst.enum = def.entries;
|
|
3664
|
-
inst.options = Object.values(def.entries);
|
|
3665
|
-
const keys = new Set(Object.keys(def.entries));
|
|
3666
|
-
inst.extract = (values, params) => {
|
|
3667
|
-
const newEntries = {};
|
|
3668
|
-
for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
|
|
3669
|
-
else throw new Error(`Key ${value} not found in enum`);
|
|
3670
|
-
return new ZodEnum({
|
|
3671
|
-
...def,
|
|
3672
|
-
checks: [],
|
|
3673
|
-
...normalizeParams(params),
|
|
3674
|
-
entries: newEntries
|
|
3675
|
-
});
|
|
3676
|
-
};
|
|
3677
|
-
inst.exclude = (values, params) => {
|
|
3678
|
-
const newEntries = { ...def.entries };
|
|
3679
|
-
for (const value of values) if (keys.has(value)) delete newEntries[value];
|
|
3680
|
-
else throw new Error(`Key ${value} not found in enum`);
|
|
3681
|
-
return new ZodEnum({
|
|
3682
|
-
...def,
|
|
3683
|
-
checks: [],
|
|
3684
|
-
...normalizeParams(params),
|
|
3685
|
-
entries: newEntries
|
|
3686
|
-
});
|
|
3687
|
-
};
|
|
3688
|
-
});
|
|
3689
|
-
function _enum(values, params) {
|
|
3690
|
-
return new ZodEnum({
|
|
3691
|
-
type: "enum",
|
|
3692
|
-
entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
|
|
3693
|
-
...normalizeParams(params)
|
|
3694
|
-
});
|
|
3695
|
-
}
|
|
3696
|
-
const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
3697
|
-
$ZodLiteral.init(inst, def);
|
|
3698
|
-
ZodType.init(inst, def);
|
|
3699
|
-
inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
|
|
3700
|
-
inst.values = new Set(def.values);
|
|
3701
|
-
Object.defineProperty(inst, "value", { get() {
|
|
3702
|
-
if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
3703
|
-
return def.values[0];
|
|
3704
|
-
} });
|
|
3705
|
-
});
|
|
3706
|
-
function literal(value, params) {
|
|
3707
|
-
return new ZodLiteral({
|
|
3708
|
-
type: "literal",
|
|
3709
|
-
values: Array.isArray(value) ? value : [value],
|
|
3710
|
-
...normalizeParams(params)
|
|
3711
|
-
});
|
|
3712
|
-
}
|
|
3713
|
-
const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
3714
|
-
$ZodTransform.init(inst, def);
|
|
3715
|
-
ZodType.init(inst, def);
|
|
3716
|
-
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
3717
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
3718
|
-
if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
3719
|
-
payload.addIssue = (issue$1) => {
|
|
3720
|
-
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
|
|
3721
|
-
else {
|
|
3722
|
-
const _issue = issue$1;
|
|
3723
|
-
if (_issue.fatal) _issue.continue = false;
|
|
3724
|
-
_issue.code ?? (_issue.code = "custom");
|
|
3725
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
3726
|
-
_issue.inst ?? (_issue.inst = inst);
|
|
3727
|
-
payload.issues.push(issue(_issue));
|
|
3728
|
-
}
|
|
3729
|
-
};
|
|
3730
|
-
const output = def.transform(payload.value, payload);
|
|
3731
|
-
if (output instanceof Promise) return output.then((output$1) => {
|
|
3732
|
-
payload.value = output$1;
|
|
3733
|
-
return payload;
|
|
3734
|
-
});
|
|
3735
|
-
payload.value = output;
|
|
3736
|
-
return payload;
|
|
3737
|
-
};
|
|
3738
|
-
});
|
|
3739
|
-
function transform(fn) {
|
|
3740
|
-
return new ZodTransform({
|
|
3741
|
-
type: "transform",
|
|
3742
|
-
transform: fn
|
|
3743
|
-
});
|
|
3744
|
-
}
|
|
3745
|
-
const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
3746
|
-
$ZodOptional.init(inst, def);
|
|
3747
|
-
ZodType.init(inst, def);
|
|
3748
|
-
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
3749
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3750
|
-
});
|
|
3751
|
-
function optional(innerType) {
|
|
3752
|
-
return new ZodOptional({
|
|
3753
|
-
type: "optional",
|
|
3754
|
-
innerType
|
|
3755
|
-
});
|
|
3756
|
-
}
|
|
3757
|
-
const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
3758
|
-
$ZodExactOptional.init(inst, def);
|
|
3759
|
-
ZodType.init(inst, def);
|
|
3760
|
-
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
3761
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3762
|
-
});
|
|
3763
|
-
function exactOptional(innerType) {
|
|
3764
|
-
return new ZodExactOptional({
|
|
3765
|
-
type: "optional",
|
|
3766
|
-
innerType
|
|
3767
|
-
});
|
|
3768
|
-
}
|
|
3769
|
-
const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
3770
|
-
$ZodNullable.init(inst, def);
|
|
3771
|
-
ZodType.init(inst, def);
|
|
3772
|
-
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
|
|
3773
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3774
|
-
});
|
|
3775
|
-
function nullable(innerType) {
|
|
3776
|
-
return new ZodNullable({
|
|
3777
|
-
type: "nullable",
|
|
3778
|
-
innerType
|
|
3779
|
-
});
|
|
3780
|
-
}
|
|
3781
|
-
const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
3782
|
-
$ZodDefault.init(inst, def);
|
|
3783
|
-
ZodType.init(inst, def);
|
|
3784
|
-
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
|
|
3785
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3786
|
-
inst.removeDefault = inst.unwrap;
|
|
3787
|
-
});
|
|
3788
|
-
function _default(innerType, defaultValue) {
|
|
3789
|
-
return new ZodDefault({
|
|
3790
|
-
type: "default",
|
|
3791
|
-
innerType,
|
|
3792
|
-
get defaultValue() {
|
|
3793
|
-
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
3794
|
-
}
|
|
3795
|
-
});
|
|
3796
|
-
}
|
|
3797
|
-
const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
3798
|
-
$ZodPrefault.init(inst, def);
|
|
3799
|
-
ZodType.init(inst, def);
|
|
3800
|
-
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
|
|
3801
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3802
|
-
});
|
|
3803
|
-
function prefault(innerType, defaultValue) {
|
|
3804
|
-
return new ZodPrefault({
|
|
3805
|
-
type: "prefault",
|
|
3806
|
-
innerType,
|
|
3807
|
-
get defaultValue() {
|
|
3808
|
-
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
3809
|
-
}
|
|
3810
|
-
});
|
|
3811
|
-
}
|
|
3812
|
-
const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
3813
|
-
$ZodNonOptional.init(inst, def);
|
|
3814
|
-
ZodType.init(inst, def);
|
|
3815
|
-
inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
|
|
3816
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3817
|
-
});
|
|
3818
|
-
function nonoptional(innerType, params) {
|
|
3819
|
-
return new ZodNonOptional({
|
|
3820
|
-
type: "nonoptional",
|
|
3821
|
-
innerType,
|
|
3822
|
-
...normalizeParams(params)
|
|
3823
|
-
});
|
|
3824
|
-
}
|
|
3825
|
-
const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
3826
|
-
$ZodCatch.init(inst, def);
|
|
3827
|
-
ZodType.init(inst, def);
|
|
3828
|
-
inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
|
|
3829
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3830
|
-
inst.removeCatch = inst.unwrap;
|
|
3831
|
-
});
|
|
3832
|
-
function _catch(innerType, catchValue) {
|
|
3833
|
-
return new ZodCatch({
|
|
3834
|
-
type: "catch",
|
|
3835
|
-
innerType,
|
|
3836
|
-
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
3837
|
-
});
|
|
3838
|
-
}
|
|
3839
|
-
const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
3840
|
-
$ZodPipe.init(inst, def);
|
|
3841
|
-
ZodType.init(inst, def);
|
|
3842
|
-
inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
|
|
3843
|
-
inst.in = def.in;
|
|
3844
|
-
inst.out = def.out;
|
|
3845
|
-
});
|
|
3846
|
-
function pipe(in_, out) {
|
|
3847
|
-
return new ZodPipe({
|
|
3848
|
-
type: "pipe",
|
|
3849
|
-
in: in_,
|
|
3850
|
-
out
|
|
3851
|
-
});
|
|
3852
|
-
}
|
|
3853
|
-
const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
3854
|
-
$ZodReadonly.init(inst, def);
|
|
3855
|
-
ZodType.init(inst, def);
|
|
3856
|
-
inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
|
|
3857
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3858
|
-
});
|
|
3859
|
-
function readonly(innerType) {
|
|
3860
|
-
return new ZodReadonly({
|
|
3861
|
-
type: "readonly",
|
|
3862
|
-
innerType
|
|
3863
|
-
});
|
|
3864
|
-
}
|
|
3865
|
-
const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
3866
|
-
$ZodCustom.init(inst, def);
|
|
3867
|
-
ZodType.init(inst, def);
|
|
3868
|
-
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
|
|
3869
|
-
});
|
|
3870
|
-
function refine(fn, _params = {}) {
|
|
3871
|
-
return _refine(ZodCustom, fn, _params);
|
|
3872
|
-
}
|
|
3873
|
-
function superRefine(fn) {
|
|
3874
|
-
return _superRefine(fn);
|
|
3875
|
-
}
|
|
3876
|
-
const describe = describe$1;
|
|
3877
|
-
const meta = meta$1;
|
|
3878
|
-
|
|
3879
|
-
//#endregion
|
|
3880
|
-
//#region ../mcp-shared/dist/index.js
|
|
15
|
+
//#region ../shared/dist/index.js
|
|
3881
16
|
const MCP_PORT_CANDIDATES = [
|
|
3882
17
|
6220,
|
|
3883
18
|
7431,
|
|
@@ -3902,66 +37,67 @@ const TEMPAD_MCP_ERROR_CODES = {
|
|
|
3902
37
|
ASSET_SERVER_NOT_CONFIGURED: "ASSET_SERVER_NOT_CONFIGURED",
|
|
3903
38
|
TRANSPORT_NOT_CONNECTED: "TRANSPORT_NOT_CONNECTED"
|
|
3904
39
|
};
|
|
3905
|
-
const RegisteredMessageSchema = object({
|
|
3906
|
-
type: literal("registered"),
|
|
3907
|
-
id: string()
|
|
3908
|
-
});
|
|
3909
|
-
const StateMessageSchema = object({
|
|
3910
|
-
type: literal("state"),
|
|
3911
|
-
activeId: string().nullable(),
|
|
3912
|
-
count: number().nonnegative(),
|
|
3913
|
-
port: number().positive(),
|
|
3914
|
-
assetServerUrl: string().url()
|
|
3915
|
-
});
|
|
3916
|
-
const ToolCallPayloadSchema = object({
|
|
3917
|
-
name: string(),
|
|
3918
|
-
args: unknown()
|
|
3919
|
-
});
|
|
3920
|
-
const ToolCallMessageSchema = object({
|
|
3921
|
-
type: literal("toolCall"),
|
|
3922
|
-
id: string(),
|
|
40
|
+
const RegisteredMessageSchema = z.object({
|
|
41
|
+
type: z.literal("registered"),
|
|
42
|
+
id: z.string()
|
|
43
|
+
});
|
|
44
|
+
const StateMessageSchema = z.object({
|
|
45
|
+
type: z.literal("state"),
|
|
46
|
+
activeId: z.string().nullable(),
|
|
47
|
+
count: z.number().nonnegative(),
|
|
48
|
+
port: z.number().positive(),
|
|
49
|
+
assetServerUrl: z.string().url()
|
|
50
|
+
});
|
|
51
|
+
const ToolCallPayloadSchema = z.object({
|
|
52
|
+
name: z.string(),
|
|
53
|
+
args: z.unknown()
|
|
54
|
+
});
|
|
55
|
+
const ToolCallMessageSchema = z.object({
|
|
56
|
+
type: z.literal("toolCall"),
|
|
57
|
+
id: z.string(),
|
|
3923
58
|
payload: ToolCallPayloadSchema
|
|
3924
59
|
});
|
|
3925
|
-
const MessageToExtensionSchema = discriminatedUnion("type", [
|
|
60
|
+
const MessageToExtensionSchema = z.discriminatedUnion("type", [
|
|
3926
61
|
RegisteredMessageSchema,
|
|
3927
62
|
StateMessageSchema,
|
|
3928
63
|
ToolCallMessageSchema
|
|
3929
64
|
]);
|
|
3930
|
-
const ActivateMessageSchema = object({ type: literal("activate") });
|
|
3931
|
-
const ToolResultMessageSchema = object({
|
|
3932
|
-
type: literal("toolResult"),
|
|
3933
|
-
id: string(),
|
|
3934
|
-
payload: unknown().optional(),
|
|
3935
|
-
error: unknown().optional()
|
|
3936
|
-
});
|
|
3937
|
-
const MessageFromExtensionSchema = discriminatedUnion("type", [ActivateMessageSchema, ToolResultMessageSchema]);
|
|
3938
|
-
const
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
const
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
})
|
|
3961
|
-
|
|
3962
|
-
const
|
|
3963
|
-
|
|
3964
|
-
|
|
65
|
+
const ActivateMessageSchema = z.object({ type: z.literal("activate") });
|
|
66
|
+
const ToolResultMessageSchema = z.object({
|
|
67
|
+
type: z.literal("toolResult"),
|
|
68
|
+
id: z.string(),
|
|
69
|
+
payload: z.unknown().optional(),
|
|
70
|
+
error: z.unknown().optional()
|
|
71
|
+
});
|
|
72
|
+
const MessageFromExtensionSchema = z.discriminatedUnion("type", [ActivateMessageSchema, ToolResultMessageSchema]);
|
|
73
|
+
const MCP_ASSET_RESOURCE_URI_PATTERN = new RegExp(`^${MCP_ASSET_URI_PREFIX.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[a-f0-9]{${MCP_HASH_HEX_LENGTH}}$`, "i");
|
|
74
|
+
const AssetDescriptorSchema = z.object({
|
|
75
|
+
hash: z.string().min(1),
|
|
76
|
+
url: z.string().url(),
|
|
77
|
+
mimeType: z.string().min(1),
|
|
78
|
+
size: z.number().int().nonnegative(),
|
|
79
|
+
resourceUri: z.string().regex(MCP_ASSET_RESOURCE_URI_PATTERN),
|
|
80
|
+
width: z.number().int().positive().optional(),
|
|
81
|
+
height: z.number().int().positive().optional()
|
|
82
|
+
});
|
|
83
|
+
const GetCodeParametersSchema = z.object({
|
|
84
|
+
nodeId: z.string().describe("Optional target node id; omit to use the current single selection when pulling the baseline snapshot.").optional(),
|
|
85
|
+
preferredLang: z.enum(["jsx", "vue"]).describe("Preferred output language to bias the snapshot; otherwise uses the design’s hint/detected language, then falls back to JSX.").optional(),
|
|
86
|
+
resolveTokens: z.boolean().describe("Inline token values instead of references for quick renders; default false returns token metadata so you can map into your theming system. When true, values are resolved per-node (mode-aware).").optional()
|
|
87
|
+
});
|
|
88
|
+
const GetTokenDefsParametersSchema = z.object({
|
|
89
|
+
names: z.array(z.string().regex(/^--[a-zA-Z0-9-_]+$/)).min(1).describe("Canonical token names (CSS variable form) from Object.keys(get_code.tokens) or your own list to resolve, e.g., --color-primary."),
|
|
90
|
+
includeAllModes: z.boolean().describe("Include all token modes (light/dark/etc.) instead of just the active one to mirror responsive tokens; default false.").optional()
|
|
91
|
+
});
|
|
92
|
+
const GetScreenshotParametersSchema = z.object({ nodeId: z.string().describe("Optional node id to screenshot; defaults to the current single selection. Useful when layout/overlap is uncertain (auto-layout none/inferred).").optional() });
|
|
93
|
+
const GetStructureParametersSchema = z.object({
|
|
94
|
+
nodeId: z.string().describe("Optional node id to outline; defaults to the current single selection. Useful when auto-layout hints are none/inferred or you need explicit geometry for refactors.").optional(),
|
|
95
|
+
options: z.object({ depth: z.number().int().positive().describe("Limit traversal depth; defaults to full tree (subject to safety caps).").optional() }).optional()
|
|
96
|
+
});
|
|
97
|
+
const GetAssetsParametersSchema = z.object({ hashes: z.array(z.string().regex(MCP_HASH_PATTERN)).min(1).describe("Asset hashes returned from get_code (or other tools) to download/resolve exact bytes for rasterized images or SVGs before routing through your asset pipeline.") });
|
|
98
|
+
const GetAssetsResultSchema = z.object({
|
|
99
|
+
assets: z.array(AssetDescriptorSchema),
|
|
100
|
+
missing: z.array(z.string().min(1))
|
|
3965
101
|
});
|
|
3966
102
|
|
|
3967
103
|
//#endregion
|
|
@@ -3980,8 +116,7 @@ function getImageExtension(mimeType) {
|
|
|
3980
116
|
if (override) return `.${override}`;
|
|
3981
117
|
const subtype = normalized.slice(6);
|
|
3982
118
|
if (!subtype) return "";
|
|
3983
|
-
|
|
3984
|
-
return ext ? `.${ext}` : "";
|
|
119
|
+
return `.${subtype.split("+", 1)[0] || subtype}`;
|
|
3985
120
|
}
|
|
3986
121
|
function buildAssetFilename(hash, mimeType) {
|
|
3987
122
|
const ext = getImageExtension(mimeType);
|
|
@@ -4028,39 +163,40 @@ function getMcpServerConfig() {
|
|
|
4028
163
|
//#endregion
|
|
4029
164
|
//#region src/asset-http-server.ts
|
|
4030
165
|
const LOOPBACK_HOST = "127.0.0.1";
|
|
166
|
+
const HASH_HEX_PATTERN = new RegExp(`^[a-f0-9]{${MCP_HASH_HEX_LENGTH}}$`, "i");
|
|
4031
167
|
const { maxAssetSizeBytes } = getMcpServerConfig();
|
|
4032
168
|
function createAssetHttpServer(store) {
|
|
4033
169
|
const server = createServer$1(handleRequest);
|
|
4034
|
-
let port
|
|
170
|
+
let port = null;
|
|
4035
171
|
async function start() {
|
|
4036
|
-
if (port
|
|
4037
|
-
await new Promise((resolve
|
|
172
|
+
if (port !== null) return;
|
|
173
|
+
await new Promise((resolve, reject) => {
|
|
4038
174
|
const onError = (error) => {
|
|
4039
175
|
server.off("listening", onListening);
|
|
4040
|
-
reject
|
|
176
|
+
reject(error);
|
|
4041
177
|
};
|
|
4042
178
|
const onListening = () => {
|
|
4043
179
|
server.off("error", onError);
|
|
4044
180
|
const address = server.address();
|
|
4045
181
|
if (address && typeof address === "object") {
|
|
4046
|
-
port
|
|
4047
|
-
resolve
|
|
4048
|
-
} else reject
|
|
182
|
+
port = address.port;
|
|
183
|
+
resolve();
|
|
184
|
+
} else reject(/* @__PURE__ */ new Error("Failed to determine HTTP server port."));
|
|
4049
185
|
};
|
|
4050
186
|
server.once("error", onError);
|
|
4051
187
|
server.once("listening", onListening);
|
|
4052
188
|
server.listen(0, LOOPBACK_HOST);
|
|
4053
189
|
});
|
|
4054
|
-
log.info({ port
|
|
190
|
+
log.info({ port }, "Asset HTTP server ready.");
|
|
4055
191
|
}
|
|
4056
192
|
function stop() {
|
|
4057
|
-
if (port
|
|
193
|
+
if (port === null) return;
|
|
4058
194
|
server.close();
|
|
4059
|
-
port
|
|
195
|
+
port = null;
|
|
4060
196
|
}
|
|
4061
197
|
function getBaseUrl() {
|
|
4062
|
-
if (port
|
|
4063
|
-
return `http://${LOOPBACK_HOST}:${port
|
|
198
|
+
if (port === null) throw new Error("Asset HTTP server is not running.");
|
|
199
|
+
return `http://${LOOPBACK_HOST}:${port}`;
|
|
4064
200
|
}
|
|
4065
201
|
function handleRequest(req, res) {
|
|
4066
202
|
const startedAt = Date.now();
|
|
@@ -4084,7 +220,7 @@ function createAssetHttpServer(store) {
|
|
|
4084
220
|
sendError(res, 400, "Missing URL");
|
|
4085
221
|
return;
|
|
4086
222
|
}
|
|
4087
|
-
const segments = new URL
|
|
223
|
+
const segments = new URL(req.url, getBaseUrl()).pathname.split("/").filter(Boolean);
|
|
4088
224
|
if (segments.length !== 2 || segments[0] !== "assets") {
|
|
4089
225
|
sendError(res, 404, "Not Found");
|
|
4090
226
|
return;
|
|
@@ -4147,8 +283,9 @@ function createAssetHttpServer(store) {
|
|
|
4147
283
|
stream.pipe(res);
|
|
4148
284
|
}
|
|
4149
285
|
function handleUpload(req, res, hash) {
|
|
4150
|
-
if (!
|
|
4151
|
-
|
|
286
|
+
if (!HASH_HEX_PATTERN.test(hash)) {
|
|
287
|
+
req.resume();
|
|
288
|
+
sendError(res, 400, "Invalid Hash");
|
|
4152
289
|
return;
|
|
4153
290
|
}
|
|
4154
291
|
const contentTypeHeader = req.headers["content-type"];
|
|
@@ -4307,8 +444,8 @@ function createAssetStore(options = {}) {
|
|
|
4307
444
|
const records = /* @__PURE__ */ new Map();
|
|
4308
445
|
let persistTimer = null;
|
|
4309
446
|
function loadExisting() {
|
|
4310
|
-
const list
|
|
4311
|
-
for (const record of list
|
|
447
|
+
const list = readIndex(indexPath);
|
|
448
|
+
for (const record of list) if (record?.hash && record?.filePath) records.set(record.hash, record);
|
|
4312
449
|
}
|
|
4313
450
|
function persist() {
|
|
4314
451
|
if (persistTimer) return;
|
|
@@ -4454,14 +591,14 @@ function createToolError(code, message) {
|
|
|
4454
591
|
function register(extensionId, timeout) {
|
|
4455
592
|
const requestId = nanoid();
|
|
4456
593
|
return {
|
|
4457
|
-
promise: new Promise((resolve
|
|
594
|
+
promise: new Promise((resolve, reject) => {
|
|
4458
595
|
const timer = setTimeout(() => {
|
|
4459
596
|
pendingCalls.delete(requestId);
|
|
4460
|
-
reject
|
|
597
|
+
reject(createToolError(TEMPAD_MCP_ERROR_CODES.EXTENSION_TIMEOUT, `Extension did not respond within ${timeout / 1e3}s.`));
|
|
4461
598
|
}, timeout);
|
|
4462
599
|
pendingCalls.set(requestId, {
|
|
4463
|
-
resolve
|
|
4464
|
-
reject
|
|
600
|
+
resolve,
|
|
601
|
+
reject,
|
|
4465
602
|
timer,
|
|
4466
603
|
extensionId
|
|
4467
604
|
});
|
|
@@ -4513,6 +650,10 @@ function cleanupAll() {
|
|
|
4513
650
|
|
|
4514
651
|
//#endregion
|
|
4515
652
|
//#region src/tools.ts
|
|
653
|
+
function getRecordProperty$1(record, key) {
|
|
654
|
+
if (!record || typeof record !== "object") return;
|
|
655
|
+
return Reflect.get(record, key);
|
|
656
|
+
}
|
|
4516
657
|
function extTool(definition) {
|
|
4517
658
|
return definition;
|
|
4518
659
|
}
|
|
@@ -4557,15 +698,10 @@ const TOOL_DEFS = [
|
|
|
4557
698
|
})
|
|
4558
699
|
];
|
|
4559
700
|
function extractToolErrorCode(error) {
|
|
4560
|
-
|
|
4561
|
-
if (
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
if (cause && typeof cause === "object") {
|
|
4565
|
-
const causeCode = cause.code;
|
|
4566
|
-
if (typeof causeCode === "string") return causeCode;
|
|
4567
|
-
}
|
|
4568
|
-
}
|
|
701
|
+
const code = getRecordProperty$1(error, "code");
|
|
702
|
+
if (typeof code === "string") return code;
|
|
703
|
+
const causeCode = getRecordProperty$1(getRecordProperty$1(error, "cause"), "code");
|
|
704
|
+
if (typeof causeCode === "string") return causeCode;
|
|
4569
705
|
}
|
|
4570
706
|
function extractToolErrorMessage(error) {
|
|
4571
707
|
if (error instanceof Error) return error.message || "Unknown error occurred.";
|
|
@@ -4691,6 +827,10 @@ const mcp = new McpServer({
|
|
|
4691
827
|
name: "tempad-dev-mcp",
|
|
4692
828
|
version: PACKAGE_VERSION
|
|
4693
829
|
}, instructions_default ? { instructions: instructions_default } : void 0);
|
|
830
|
+
function getRecordProperty(record, key) {
|
|
831
|
+
if (!record || typeof record !== "object") return;
|
|
832
|
+
return Reflect.get(record, key);
|
|
833
|
+
}
|
|
4694
834
|
function enrichToolDefinition(tool) {
|
|
4695
835
|
if (tool.target === "extension") return tool;
|
|
4696
836
|
switch (tool.name) {
|
|
@@ -4710,11 +850,12 @@ function createCodedError(code, message) {
|
|
|
4710
850
|
function coerceToolError(error) {
|
|
4711
851
|
if (error instanceof Error) return error;
|
|
4712
852
|
if (typeof error === "string") return new Error(error);
|
|
853
|
+
const messageValue = getRecordProperty(error, "message");
|
|
854
|
+
const codeValue = getRecordProperty(error, "code");
|
|
4713
855
|
if (error && typeof error === "object") {
|
|
4714
|
-
const
|
|
4715
|
-
const message = typeof candidate.message === "string" ? candidate.message : safeStringify(error);
|
|
856
|
+
const message = typeof messageValue === "string" ? messageValue : safeStringify(error);
|
|
4716
857
|
const err = new Error(message);
|
|
4717
|
-
if (typeof
|
|
858
|
+
if (typeof codeValue === "string") err.code = codeValue;
|
|
4718
859
|
return err;
|
|
4719
860
|
}
|
|
4720
861
|
return new Error(String(error));
|
|
@@ -5074,14 +1215,14 @@ async function startWebSocketServer() {
|
|
|
5074
1215
|
maxPayload: maxPayloadBytes
|
|
5075
1216
|
});
|
|
5076
1217
|
try {
|
|
5077
|
-
await new Promise((resolve
|
|
1218
|
+
await new Promise((resolve, reject) => {
|
|
5078
1219
|
const onError = (err) => {
|
|
5079
1220
|
server.off("listening", onListening);
|
|
5080
|
-
reject
|
|
1221
|
+
reject(err);
|
|
5081
1222
|
};
|
|
5082
1223
|
const onListening = () => {
|
|
5083
1224
|
server.off("error", onError);
|
|
5084
|
-
resolve
|
|
1225
|
+
resolve();
|
|
5085
1226
|
};
|
|
5086
1227
|
server.once("error", onError);
|
|
5087
1228
|
server.once("listening", onListening);
|