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