@weapp-core/schematics 6.0.3 → 6.0.4

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