@lousy-agents/agent-shell 5.22.12 → 5.22.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1834 -1286
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3787,16 +3787,16 @@ const WORLD_SIDS = new Set([
|
|
|
3787
3787
|
function windows_security_facts_unverified(message, cause) {
|
|
3788
3788
|
throw new errors_FsSafeError("permission-unverified", message, cause === undefined ? {} : { cause });
|
|
3789
3789
|
}
|
|
3790
|
-
function
|
|
3790
|
+
function windows_security_facts_record(value) {
|
|
3791
3791
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
3792
3792
|
}
|
|
3793
3793
|
function uint32(value) {
|
|
3794
3794
|
return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 0xffff_ffff;
|
|
3795
3795
|
}
|
|
3796
3796
|
function validateAce(value, allowUnknownFlags) {
|
|
3797
|
-
if (!
|
|
3797
|
+
if (!windows_security_facts_record(value) || typeof value.sid !== "string" || !SID_RE.test(value.sid) ||
|
|
3798
3798
|
!uint32(value.mask) || (value.aceType !== "allow" && value.aceType !== "deny") ||
|
|
3799
|
-
!
|
|
3799
|
+
!windows_security_facts_record(value.flags))
|
|
3800
3800
|
return false;
|
|
3801
3801
|
const { raw } = value.flags;
|
|
3802
3802
|
if (!uint32(raw) || (raw & ~(allowUnknownFlags ? 0xff : 0xdf)) !== 0)
|
|
@@ -3810,7 +3810,7 @@ function validateAce(value, allowUnknownFlags) {
|
|
|
3810
3810
|
return fields.every(([field, bit]) => typeof flags[field] === "boolean" && flags[field] === ((raw & bit) !== 0));
|
|
3811
3811
|
}
|
|
3812
3812
|
function validateDescriptor(value, allowUnknownFlags) {
|
|
3813
|
-
if (!
|
|
3813
|
+
if (!windows_security_facts_record(value) || typeof value.ownerSid !== "string" || !SID_RE.test(value.ownerSid) ||
|
|
3814
3814
|
typeof value.currentUserSid !== "string" || !SID_RE.test(value.currentUserSid) ||
|
|
3815
3815
|
(value.currentAppContainerSid != null && (typeof value.currentAppContainerSid !== "string" || !APP_CONTAINER_SID_RE.test(value.currentAppContainerSid))) ||
|
|
3816
3816
|
typeof value.daclPresent !== "boolean" || typeof value.isLocal !== "boolean" ||
|
|
@@ -3860,7 +3860,7 @@ function summarize(facts) {
|
|
|
3860
3860
|
/** Raw reporting retains unknown flag bits; secure admission validates them below. */
|
|
3861
3861
|
function windows_security_facts_parseWindowsSecurityCommandFacts(value) {
|
|
3862
3862
|
const facts = validateDescriptor(value, true);
|
|
3863
|
-
if (!
|
|
3863
|
+
if (!windows_security_facts_record(value) || typeof value.daclProtected !== "boolean") {
|
|
3864
3864
|
windows_security_facts_unverified("Windows security command returned malformed descriptor facts");
|
|
3865
3865
|
}
|
|
3866
3866
|
return {
|
|
@@ -22262,18 +22262,23 @@ function jsonStringifyReplacer(_, value) {
|
|
|
22262
22262
|
return value.toString();
|
|
22263
22263
|
return value;
|
|
22264
22264
|
}
|
|
22265
|
+
// the accessor lives on a shared prototype: an own accessor makes every box a dictionary-mode object (~360 B and a slow load per read against ~100 B and an inlined getter here)
|
|
22266
|
+
class Cached {
|
|
22267
|
+
constructor(getter) {
|
|
22268
|
+
this._getter = getter;
|
|
22269
|
+
this._value = undefined;
|
|
22270
|
+
}
|
|
22271
|
+
get value() {
|
|
22272
|
+
const getter = this._getter;
|
|
22273
|
+
if (getter !== undefined) {
|
|
22274
|
+
this._value = getter();
|
|
22275
|
+
this._getter = undefined;
|
|
22276
|
+
}
|
|
22277
|
+
return this._value;
|
|
22278
|
+
}
|
|
22279
|
+
}
|
|
22265
22280
|
function util_cached(getter) {
|
|
22266
|
-
|
|
22267
|
-
return {
|
|
22268
|
-
get value() {
|
|
22269
|
-
if (!set) {
|
|
22270
|
-
const value = getter();
|
|
22271
|
-
Object.defineProperty(this, "value", { value });
|
|
22272
|
-
return value;
|
|
22273
|
-
}
|
|
22274
|
-
throw new Error("cached value already set");
|
|
22275
|
-
},
|
|
22276
|
-
};
|
|
22281
|
+
return new Cached(getter);
|
|
22277
22282
|
}
|
|
22278
22283
|
function nullish(input) {
|
|
22279
22284
|
return input === null || input === undefined;
|
|
@@ -22328,6 +22333,71 @@ function util_assignProp(target, prop, value) {
|
|
|
22328
22333
|
configurable: true,
|
|
22329
22334
|
});
|
|
22330
22335
|
}
|
|
22336
|
+
/**
|
|
22337
|
+
* Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
|
|
22338
|
+
*
|
|
22339
|
+
* Its keys and descriptors read without invoking anything, which is what lets a discriminated union check its discriminator, and the cycle walk read a shape, without resolving a getter that references the schema being constructed. A def that answers `shape` from an accessor of its own has none.
|
|
22340
|
+
*/
|
|
22341
|
+
function rawShape(def) {
|
|
22342
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
22343
|
+
return desc?.get ? desc.get.raw : desc?.value;
|
|
22344
|
+
}
|
|
22345
|
+
// where a builder reads its source's keys and descriptors, resolving only a shape a def answers for itself. A shape resolves by object spread, so only its enumerable keys are ever part of it.
|
|
22346
|
+
function sourceShape(schema) {
|
|
22347
|
+
return rawShape(schema._zod.def) ?? schema._zod.def.shape;
|
|
22348
|
+
}
|
|
22349
|
+
// a key whose value is not settled yet, self-caching so every read after the first gets the same one
|
|
22350
|
+
function deferProp(target, key, getter) {
|
|
22351
|
+
Object.defineProperty(target, key, {
|
|
22352
|
+
get() {
|
|
22353
|
+
const value = getter();
|
|
22354
|
+
util_assignProp(this, key, value);
|
|
22355
|
+
return value;
|
|
22356
|
+
},
|
|
22357
|
+
enumerable: true,
|
|
22358
|
+
configurable: true,
|
|
22359
|
+
});
|
|
22360
|
+
}
|
|
22361
|
+
// Writes a settled key. A plain assignment is much cheaper than `defineProperty` and produces the same descriptor, but it runs whatever setter already answers to the key — an accessor this shape deferred, or an inherited one, which `__proto__` has on every object and prototype pollution can add for any name.
|
|
22362
|
+
function putProp(target, key, value) {
|
|
22363
|
+
if (key in target)
|
|
22364
|
+
util_assignProp(target, key, value);
|
|
22365
|
+
else
|
|
22366
|
+
target[key] = value;
|
|
22367
|
+
}
|
|
22368
|
+
/**
|
|
22369
|
+
* Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
|
|
22370
|
+
*
|
|
22371
|
+
* A key the source has resolved is copied through now, so the derived shape states it outright and nothing has to resolve it to learn what it holds. A key the source still defers stays deferred, and reads back through the source's own `shape`, so it resolves once and both shapes get that one schema.
|
|
22372
|
+
*/
|
|
22373
|
+
function mirrorShape(target, source, keys, wrap) {
|
|
22374
|
+
const raw = sourceShape(source);
|
|
22375
|
+
for (const key of keys) {
|
|
22376
|
+
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
22377
|
+
if (!desc.enumerable)
|
|
22378
|
+
continue;
|
|
22379
|
+
if (desc.get) {
|
|
22380
|
+
deferProp(target, key, () => {
|
|
22381
|
+
const value = source._zod.def.shape[key];
|
|
22382
|
+
return wrap ? wrap(value, key) : value;
|
|
22383
|
+
});
|
|
22384
|
+
}
|
|
22385
|
+
else
|
|
22386
|
+
putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
|
|
22387
|
+
}
|
|
22388
|
+
}
|
|
22389
|
+
// same, for a plain shape a caller passed rather than a schema's
|
|
22390
|
+
function mirrorProps(target, source) {
|
|
22391
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
22392
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
22393
|
+
if (!desc.enumerable)
|
|
22394
|
+
continue;
|
|
22395
|
+
if (desc.get)
|
|
22396
|
+
deferProp(target, key, () => source[key]);
|
|
22397
|
+
else
|
|
22398
|
+
putProp(target, key, desc.value);
|
|
22399
|
+
}
|
|
22400
|
+
}
|
|
22331
22401
|
function mergeDefs(...defs) {
|
|
22332
22402
|
const mergedDescriptors = {};
|
|
22333
22403
|
for (const def of defs) {
|
|
@@ -22579,24 +22649,23 @@ function pick(schema, mask) {
|
|
|
22579
22649
|
if (hasChecks) {
|
|
22580
22650
|
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
22581
22651
|
}
|
|
22582
|
-
const
|
|
22583
|
-
|
|
22584
|
-
|
|
22585
|
-
|
|
22586
|
-
|
|
22587
|
-
|
|
22588
|
-
|
|
22589
|
-
|
|
22590
|
-
|
|
22591
|
-
|
|
22592
|
-
|
|
22593
|
-
}
|
|
22594
|
-
|
|
22595
|
-
|
|
22596
|
-
|
|
22597
|
-
|
|
22598
|
-
|
|
22599
|
-
return util_clone(schema, def);
|
|
22652
|
+
const newShape = {};
|
|
22653
|
+
mirrorShape(newShape, schema, maskedKeys(schema, mask));
|
|
22654
|
+
return util_clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
22655
|
+
}
|
|
22656
|
+
// the mask keys that select something, checked against the source's shape without resolving it
|
|
22657
|
+
function maskedKeys(schema, mask) {
|
|
22658
|
+
const raw = sourceShape(schema);
|
|
22659
|
+
const keys = [];
|
|
22660
|
+
// `for...in` skips symbols, so a symbol in the mask would select nothing
|
|
22661
|
+
for (const key of Reflect.ownKeys(mask)) {
|
|
22662
|
+
if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) {
|
|
22663
|
+
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
22664
|
+
}
|
|
22665
|
+
if (mask[key])
|
|
22666
|
+
keys.push(key);
|
|
22667
|
+
}
|
|
22668
|
+
return keys;
|
|
22600
22669
|
}
|
|
22601
22670
|
function omit(schema, mask) {
|
|
22602
22671
|
const currDef = schema._zod.def;
|
|
@@ -22605,23 +22674,10 @@ function omit(schema, mask) {
|
|
|
22605
22674
|
if (hasChecks) {
|
|
22606
22675
|
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
22607
22676
|
}
|
|
22608
|
-
const
|
|
22609
|
-
|
|
22610
|
-
|
|
22611
|
-
|
|
22612
|
-
if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) {
|
|
22613
|
-
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
22614
|
-
}
|
|
22615
|
-
if (!mask[key])
|
|
22616
|
-
continue;
|
|
22617
|
-
delete newShape[key];
|
|
22618
|
-
}
|
|
22619
|
-
util_assignProp(this, "shape", newShape); // self-caching
|
|
22620
|
-
return newShape;
|
|
22621
|
-
},
|
|
22622
|
-
checks: [],
|
|
22623
|
-
});
|
|
22624
|
-
return util_clone(schema, def);
|
|
22677
|
+
const omitted = new Set(maskedKeys(schema, mask));
|
|
22678
|
+
const newShape = {};
|
|
22679
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
|
|
22680
|
+
return util_clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
22625
22681
|
}
|
|
22626
22682
|
function extend(schema, shape) {
|
|
22627
22683
|
if (!isPlainObject(shape)) {
|
|
@@ -22631,48 +22687,40 @@ function extend(schema, shape) {
|
|
|
22631
22687
|
const hasChecks = checks && checks.length > 0;
|
|
22632
22688
|
if (hasChecks) {
|
|
22633
22689
|
// Only throw if new shape overlaps with existing shape. Use getOwnPropertyDescriptor to check key existence without accessing values
|
|
22634
|
-
const existingShape = schema
|
|
22690
|
+
const existingShape = sourceShape(schema);
|
|
22635
22691
|
for (const key of Reflect.ownKeys(shape)) {
|
|
22636
22692
|
if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
|
|
22637
22693
|
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
22638
22694
|
}
|
|
22639
22695
|
}
|
|
22640
22696
|
}
|
|
22641
|
-
|
|
22642
|
-
|
|
22643
|
-
|
|
22644
|
-
|
|
22645
|
-
|
|
22646
|
-
|
|
22647
|
-
|
|
22648
|
-
return
|
|
22697
|
+
return util_clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
22698
|
+
}
|
|
22699
|
+
// the source's keys, then the caller's overlaid on top
|
|
22700
|
+
function extended(schema, shape) {
|
|
22701
|
+
const newShape = {};
|
|
22702
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
|
|
22703
|
+
mirrorProps(newShape, shape);
|
|
22704
|
+
return newShape;
|
|
22649
22705
|
}
|
|
22650
22706
|
function safeExtend(schema, shape) {
|
|
22651
22707
|
if (!isPlainObject(shape)) {
|
|
22652
22708
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
22653
22709
|
}
|
|
22654
|
-
|
|
22655
|
-
get shape() {
|
|
22656
|
-
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
22657
|
-
util_assignProp(this, "shape", _shape); // self-caching
|
|
22658
|
-
return _shape;
|
|
22659
|
-
},
|
|
22660
|
-
});
|
|
22661
|
-
return util_clone(schema, def);
|
|
22710
|
+
return util_clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
22662
22711
|
}
|
|
22663
|
-
function
|
|
22712
|
+
function util_merge(a, b) {
|
|
22664
22713
|
if (!b?._zod?.def) {
|
|
22665
22714
|
throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
|
|
22666
22715
|
}
|
|
22667
22716
|
if (a._zod.def.checks?.length) {
|
|
22668
22717
|
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
22669
22718
|
}
|
|
22719
|
+
const newShape = {};
|
|
22720
|
+
mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
|
|
22721
|
+
mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
|
|
22670
22722
|
const def = mergeDefs(a._zod.def, {
|
|
22671
|
-
|
|
22672
|
-
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
22673
|
-
util_assignProp(this, "shape", _shape); // self-caching
|
|
22674
|
-
return _shape;
|
|
22675
|
-
},
|
|
22723
|
+
shape: newShape,
|
|
22676
22724
|
get catchall() {
|
|
22677
22725
|
return b._zod.def.catchall;
|
|
22678
22726
|
},
|
|
@@ -22687,78 +22735,19 @@ function partial(Class, schema, mask, name = "partial") {
|
|
|
22687
22735
|
if (hasChecks) {
|
|
22688
22736
|
throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
|
|
22689
22737
|
}
|
|
22690
|
-
const
|
|
22691
|
-
|
|
22692
|
-
|
|
22693
|
-
|
|
22694
|
-
|
|
22695
|
-
for (const key of Reflect.ownKeys(mask)) {
|
|
22696
|
-
if (!Object.prototype.hasOwnProperty.call(oldShape, key)) {
|
|
22697
|
-
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
22698
|
-
}
|
|
22699
|
-
if (!mask[key])
|
|
22700
|
-
continue;
|
|
22701
|
-
// if (oldShape[key]!._zod.optin === "optional") continue;
|
|
22702
|
-
shape[key] = Class
|
|
22703
|
-
? new Class({
|
|
22704
|
-
type: "optional",
|
|
22705
|
-
innerType: oldShape[key],
|
|
22706
|
-
})
|
|
22707
|
-
: oldShape[key];
|
|
22708
|
-
}
|
|
22709
|
-
}
|
|
22710
|
-
else {
|
|
22711
|
-
// the spread copies symbol keys; `for...in` would not reach them
|
|
22712
|
-
for (const key of Reflect.ownKeys(oldShape)) {
|
|
22713
|
-
// if (oldShape[key]!._zod.optin === "optional") continue;
|
|
22714
|
-
shape[key] = Class
|
|
22715
|
-
? new Class({
|
|
22716
|
-
type: "optional",
|
|
22717
|
-
innerType: oldShape[key],
|
|
22718
|
-
})
|
|
22719
|
-
: oldShape[key];
|
|
22720
|
-
}
|
|
22721
|
-
}
|
|
22722
|
-
util_assignProp(this, "shape", shape); // self-caching
|
|
22723
|
-
return shape;
|
|
22724
|
-
},
|
|
22725
|
-
checks: [],
|
|
22726
|
-
});
|
|
22727
|
-
return util_clone(schema, def);
|
|
22738
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;
|
|
22739
|
+
const newShape = {};
|
|
22740
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class &&
|
|
22741
|
+
((value, key) => (selected && !selected.has(key) ? value : new Class({ type: "optional", innerType: value }))));
|
|
22742
|
+
return util_clone(schema, mergeDefs(schema._zod.def, { shape: newShape, checks: [] }));
|
|
22728
22743
|
}
|
|
22729
22744
|
function util_required(Class, schema, mask) {
|
|
22730
|
-
const
|
|
22731
|
-
|
|
22732
|
-
|
|
22733
|
-
|
|
22734
|
-
|
|
22735
|
-
|
|
22736
|
-
if (!Object.prototype.hasOwnProperty.call(shape, key)) {
|
|
22737
|
-
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
22738
|
-
}
|
|
22739
|
-
if (!mask[key])
|
|
22740
|
-
continue;
|
|
22741
|
-
// overwrite with non-optional
|
|
22742
|
-
shape[key] = new Class({
|
|
22743
|
-
type: "nonoptional",
|
|
22744
|
-
innerType: oldShape[key],
|
|
22745
|
-
});
|
|
22746
|
-
}
|
|
22747
|
-
}
|
|
22748
|
-
else {
|
|
22749
|
-
for (const key of Reflect.ownKeys(oldShape)) {
|
|
22750
|
-
// overwrite with non-optional
|
|
22751
|
-
shape[key] = new Class({
|
|
22752
|
-
type: "nonoptional",
|
|
22753
|
-
innerType: oldShape[key],
|
|
22754
|
-
});
|
|
22755
|
-
}
|
|
22756
|
-
}
|
|
22757
|
-
util_assignProp(this, "shape", shape); // self-caching
|
|
22758
|
-
return shape;
|
|
22759
|
-
},
|
|
22760
|
-
});
|
|
22761
|
-
return util_clone(schema, def);
|
|
22745
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;
|
|
22746
|
+
const newShape = {};
|
|
22747
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) =>
|
|
22748
|
+
// overwrite with non-optional
|
|
22749
|
+
selected && !selected.has(key) ? value : new Class({ type: "nonoptional", innerType: value }));
|
|
22750
|
+
return util_clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
|
|
22762
22751
|
}
|
|
22763
22752
|
// invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom
|
|
22764
22753
|
function aborted(x, startIndex = 0) {
|
|
@@ -22794,6 +22783,20 @@ function unwrapMessage(message) {
|
|
|
22794
22783
|
return typeof message === "string" ? message : message?.message;
|
|
22795
22784
|
}
|
|
22796
22785
|
/* A check holds no link back to the schema it is attached to — the same check instance is shared by every clone of that schema — so the owner is stamped onto the issues a check just raised, at the only point where both are in scope. Runs on the failure path only; `start` is the issue count from before the check ran. */
|
|
22786
|
+
/** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
|
|
22787
|
+
function sizeCaps(defChecks) {
|
|
22788
|
+
const caps = [];
|
|
22789
|
+
for (const ch of defChecks ?? []) {
|
|
22790
|
+
const d = ch._zod.def;
|
|
22791
|
+
// a later check may rewrite the value
|
|
22792
|
+
if (!/_(length|size)$|_equals$/.test(d.check))
|
|
22793
|
+
break;
|
|
22794
|
+
const max = d.maximum ?? d.length ?? d.size;
|
|
22795
|
+
if (max >= 0)
|
|
22796
|
+
caps.push([max, ch]);
|
|
22797
|
+
}
|
|
22798
|
+
return caps;
|
|
22799
|
+
}
|
|
22797
22800
|
function attachSchema(issues, start, inst) {
|
|
22798
22801
|
var _a;
|
|
22799
22802
|
for (let i = start; i < issues.length; i++) {
|
|
@@ -22820,13 +22823,19 @@ function finalizeIssue(iss, ctx, config) {
|
|
|
22820
22823
|
unwrapMessage(config.customError?.(iss)) ??
|
|
22821
22824
|
unwrapMessage(config.localeError?.(iss)) ??
|
|
22822
22825
|
"Invalid input");
|
|
22823
|
-
|
|
22824
|
-
|
|
22825
|
-
|
|
22826
|
+
// an explicit own-key copy beats object rest with excluded keys, which v8 routes through a generic runtime call; Object.keys rather than for-in so an issue pushed with a prototype does not leak inherited keys, and an own __proto__ key is dropped rather than assigned through the setter
|
|
22827
|
+
const full = {};
|
|
22828
|
+
for (const k of Object.keys(iss)) {
|
|
22829
|
+
if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__")
|
|
22830
|
+
continue;
|
|
22831
|
+
full[k] = iss[k];
|
|
22832
|
+
}
|
|
22833
|
+
full.path ?? (full.path = []);
|
|
22834
|
+
full.message = message;
|
|
22826
22835
|
if (ctx?.reportInput) {
|
|
22827
|
-
|
|
22836
|
+
full.input = iss.input;
|
|
22828
22837
|
}
|
|
22829
|
-
return
|
|
22838
|
+
return full;
|
|
22830
22839
|
}
|
|
22831
22840
|
function getSizableOrigin(input) {
|
|
22832
22841
|
if (input instanceof Set)
|
|
@@ -22973,6 +22982,24 @@ function util_own(inst, key, value, enumerable = true) {
|
|
|
22973
22982
|
function hide(inst, key, value) {
|
|
22974
22983
|
return util_own(inst, key, value, false);
|
|
22975
22984
|
}
|
|
22985
|
+
/** Adds members a table derives from the instance: each builds on first read and shadows as own data, and assignment shadows the same way, as when these were own properties. */
|
|
22986
|
+
function derived(computes, table) {
|
|
22987
|
+
for (const key in computes) {
|
|
22988
|
+
const compute = computes[key];
|
|
22989
|
+
// an object literal's accessor is configurable and enumerable, and `members` copies the descriptor as written
|
|
22990
|
+
Object.defineProperty(table, key, {
|
|
22991
|
+
configurable: true,
|
|
22992
|
+
enumerable: true,
|
|
22993
|
+
get() {
|
|
22994
|
+
return util_own(this, key, compute(this));
|
|
22995
|
+
},
|
|
22996
|
+
set(value) {
|
|
22997
|
+
util_own(this, key, value);
|
|
22998
|
+
},
|
|
22999
|
+
});
|
|
23000
|
+
}
|
|
23001
|
+
return table;
|
|
23002
|
+
}
|
|
22976
23003
|
function defineBound(proto, key, fn) {
|
|
22977
23004
|
Object.defineProperty(proto, key, {
|
|
22978
23005
|
configurable: true,
|
|
@@ -23139,7 +23166,7 @@ proto, params) {
|
|
|
23139
23166
|
_zodDesc.value = undefined;
|
|
23140
23167
|
}
|
|
23141
23168
|
}
|
|
23142
|
-
if (inst._zod.traits.has(name)) {
|
|
23169
|
+
else if (inst._zod.traits.has(name)) {
|
|
23143
23170
|
return;
|
|
23144
23171
|
}
|
|
23145
23172
|
inst._zod.traits.add(name);
|
|
@@ -23222,6 +23249,7 @@ function core_config(newConfig) {
|
|
|
23222
23249
|
}
|
|
23223
23250
|
|
|
23224
23251
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/memoizer.js
|
|
23252
|
+
|
|
23225
23253
|
class $ZodCyclicError extends Error {
|
|
23226
23254
|
constructor() {
|
|
23227
23255
|
super(`Cannot parse a reference cycle that closes through a transform`);
|
|
@@ -23231,50 +23259,165 @@ class $ZodCyclicError extends Error {
|
|
|
23231
23259
|
/** Keyed off the context object every schema in one parse call already shares. */
|
|
23232
23260
|
const STATE = "~memo";
|
|
23233
23261
|
const NO_ISSUES = [];
|
|
23262
|
+
// a value a cycle can close through
|
|
23263
|
+
function isRef(value) {
|
|
23264
|
+
return value !== null && typeof value === "object";
|
|
23265
|
+
}
|
|
23234
23266
|
// Receivers prefix paths in place, so the cache and every hand-out need their own copies.
|
|
23235
23267
|
function cloneIssues(issues) {
|
|
23236
23268
|
return issues.map((iss) => (iss.path ? { ...iss, path: iss.path.slice() } : { ...iss }));
|
|
23237
23269
|
}
|
|
23238
23270
|
const recursive = /*@__PURE__*/ new WeakMap();
|
|
23271
|
+
/** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
|
|
23272
|
+
const NONE = 0;
|
|
23273
|
+
const ASSUMED = 1;
|
|
23274
|
+
const PROVEN = 2;
|
|
23239
23275
|
/** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
|
|
23240
|
-
function isRecursive(inst, stack) {
|
|
23276
|
+
function isRecursive(inst, stack, resolve) {
|
|
23241
23277
|
const cached = recursive.get(inst);
|
|
23242
23278
|
if (cached !== undefined)
|
|
23243
|
-
return cached;
|
|
23279
|
+
return cached ? PROVEN : NONE;
|
|
23244
23280
|
// Relative to the walk in progress, so not cached.
|
|
23245
23281
|
if (stack.has(inst))
|
|
23246
|
-
return
|
|
23282
|
+
return PROVEN;
|
|
23247
23283
|
stack.add(inst);
|
|
23248
|
-
let result =
|
|
23284
|
+
let result = NONE;
|
|
23249
23285
|
const check = (child) => {
|
|
23250
|
-
if (
|
|
23251
|
-
|
|
23286
|
+
if (result !== PROVEN && child?._zod) {
|
|
23287
|
+
const answer = isRecursive(child, stack, resolve);
|
|
23288
|
+
if (answer > result)
|
|
23289
|
+
result = answer;
|
|
23290
|
+
}
|
|
23252
23291
|
};
|
|
23253
|
-
|
|
23254
|
-
|
|
23255
|
-
|
|
23256
|
-
|
|
23257
|
-
|
|
23258
|
-
|
|
23259
|
-
|
|
23260
|
-
// `for...in` skips symbols, so a cycle through a declared symbol key would read as non-recursive
|
|
23261
|
-
if (shape)
|
|
23262
|
-
for (const key of Reflect.ownKeys(shape))
|
|
23263
|
-
check(shape[key]);
|
|
23264
|
-
for (const key in def) {
|
|
23265
|
-
const value = def[key];
|
|
23266
|
-
if (!value || typeof value !== "object")
|
|
23292
|
+
// `Reflect.ownKeys` rather than `Object.keys`, so a cycle through a declared symbol key is still seen
|
|
23293
|
+
const shape = (sh, spread) => {
|
|
23294
|
+
let answer = NONE;
|
|
23295
|
+
for (const key of Reflect.ownKeys(sh)) {
|
|
23296
|
+
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
23297
|
+
// an object resolves its shape by spread, so a key it does not enumerate is never parsed; `z.properties` reads every own key and so keeps them all
|
|
23298
|
+
if (spread && !desc.enumerable)
|
|
23267
23299
|
continue;
|
|
23268
|
-
|
|
23269
|
-
|
|
23270
|
-
|
|
23271
|
-
|
|
23272
|
-
|
|
23300
|
+
// resolving runs user code, and a factory mints a fresh subtree per read, so an edge the walk can't follow counts as a cycle
|
|
23301
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
|
|
23302
|
+
if (child > answer)
|
|
23303
|
+
answer = child;
|
|
23304
|
+
}
|
|
23305
|
+
return answer;
|
|
23306
|
+
};
|
|
23307
|
+
const merge = (answer) => {
|
|
23308
|
+
if (answer > result)
|
|
23309
|
+
result = answer;
|
|
23310
|
+
};
|
|
23311
|
+
const def = inst._zod.def;
|
|
23312
|
+
const kind = def.type;
|
|
23313
|
+
switch (kind) {
|
|
23314
|
+
case "object": {
|
|
23315
|
+
const raw = rawShape(def);
|
|
23316
|
+
// a def with no raw shape answers `shape` from an accessor of its own, and running that can mint a whole fresh subtree
|
|
23317
|
+
merge(raw ? shape(raw, true) : ASSUMED);
|
|
23318
|
+
check(def.catchall);
|
|
23319
|
+
break;
|
|
23320
|
+
}
|
|
23321
|
+
case "array":
|
|
23322
|
+
check(def.element);
|
|
23323
|
+
break;
|
|
23324
|
+
case "tuple":
|
|
23325
|
+
for (const el of def.items)
|
|
23326
|
+
check(el);
|
|
23327
|
+
check(def.rest);
|
|
23328
|
+
break;
|
|
23329
|
+
case "record":
|
|
23330
|
+
case "map":
|
|
23331
|
+
check(def.keyType);
|
|
23332
|
+
check(def.valueType);
|
|
23333
|
+
break;
|
|
23334
|
+
case "set":
|
|
23335
|
+
check(def.valueType);
|
|
23336
|
+
break;
|
|
23337
|
+
case "union":
|
|
23338
|
+
for (const el of def.options)
|
|
23339
|
+
check(el);
|
|
23340
|
+
break;
|
|
23341
|
+
case "intersection":
|
|
23342
|
+
check(def.left);
|
|
23343
|
+
check(def.right);
|
|
23344
|
+
break;
|
|
23345
|
+
case "optional":
|
|
23346
|
+
case "nullable":
|
|
23347
|
+
case "default":
|
|
23348
|
+
case "prefault":
|
|
23349
|
+
case "catch":
|
|
23350
|
+
case "readonly":
|
|
23351
|
+
case "nonoptional":
|
|
23352
|
+
case "promise":
|
|
23353
|
+
case "success":
|
|
23354
|
+
check(def.innerType);
|
|
23355
|
+
break;
|
|
23356
|
+
case "pipe":
|
|
23357
|
+
check(def.in);
|
|
23358
|
+
check(def.out);
|
|
23359
|
+
break;
|
|
23360
|
+
case "function":
|
|
23361
|
+
check(def.input);
|
|
23362
|
+
check(def.output);
|
|
23363
|
+
break;
|
|
23364
|
+
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
23365
|
+
case "lazy": {
|
|
23366
|
+
const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : undefined);
|
|
23367
|
+
// walked with resolution off: one hop sees past the deferral, and a lazy that yields only another unresolved lazy is generative, so it stops there
|
|
23368
|
+
merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
23369
|
+
break;
|
|
23370
|
+
}
|
|
23371
|
+
// a leaf by choice: `parts` are regex fragments, not data positions
|
|
23372
|
+
case "template_literal":
|
|
23373
|
+
// leaves
|
|
23374
|
+
case "string":
|
|
23375
|
+
case "number":
|
|
23376
|
+
case "int":
|
|
23377
|
+
case "boolean":
|
|
23378
|
+
case "bigint":
|
|
23379
|
+
case "symbol":
|
|
23380
|
+
case "undefined":
|
|
23381
|
+
case "null":
|
|
23382
|
+
case "void":
|
|
23383
|
+
case "never":
|
|
23384
|
+
case "any":
|
|
23385
|
+
case "unknown":
|
|
23386
|
+
case "date":
|
|
23387
|
+
case "nan":
|
|
23388
|
+
case "enum":
|
|
23389
|
+
case "literal":
|
|
23390
|
+
case "file":
|
|
23391
|
+
case "transform":
|
|
23392
|
+
case "custom":
|
|
23393
|
+
break;
|
|
23394
|
+
default: {
|
|
23395
|
+
// a new built-in kind becomes a compile error here
|
|
23396
|
+
kind;
|
|
23397
|
+
// a user-defined kind can still hold children, and only its author knows where, so fall back to scanning the def — skipping accessors, since reading one can run user code
|
|
23398
|
+
for (const key in def) {
|
|
23399
|
+
const desc = Object.getOwnPropertyDescriptor(def, key);
|
|
23400
|
+
if (!desc || desc.get)
|
|
23401
|
+
continue;
|
|
23402
|
+
const value = desc.value;
|
|
23403
|
+
if (!value || typeof value !== "object")
|
|
23404
|
+
continue;
|
|
23405
|
+
if (value._zod)
|
|
23406
|
+
check(value);
|
|
23407
|
+
else if (Array.isArray(value))
|
|
23408
|
+
for (const el of value)
|
|
23409
|
+
check(el);
|
|
23410
|
+
}
|
|
23273
23411
|
}
|
|
23274
23412
|
}
|
|
23275
23413
|
stack.delete(inst);
|
|
23276
|
-
|
|
23277
|
-
|
|
23414
|
+
return settle(inst, result);
|
|
23415
|
+
}
|
|
23416
|
+
/** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */
|
|
23417
|
+
function settle(inst, answer) {
|
|
23418
|
+
if (answer !== ASSUMED)
|
|
23419
|
+
recursive.set(inst, answer === PROVEN);
|
|
23420
|
+
return answer;
|
|
23278
23421
|
}
|
|
23279
23422
|
/**
|
|
23280
23423
|
* Whether one parse can re-enter this schema, i.e. its subtree contains a cycle.
|
|
@@ -23283,12 +23426,13 @@ function isRecursive(inst, stack) {
|
|
|
23283
23426
|
* generated fast path has no context to key on.
|
|
23284
23427
|
*/
|
|
23285
23428
|
function isRecursiveSchema(inst) {
|
|
23286
|
-
|
|
23429
|
+
// z.compile never parses, so nothing would ever resolve a lazy for it; it runs once and already treats a throw here as recursive
|
|
23430
|
+
return isRecursive(inst, new Set(), true) !== NONE;
|
|
23287
23431
|
}
|
|
23288
23432
|
function bucketFor(state, inst) {
|
|
23289
23433
|
let bucket = state.buckets.get(inst);
|
|
23290
23434
|
if (!bucket) {
|
|
23291
|
-
bucket = new
|
|
23435
|
+
bucket = new WeakMap();
|
|
23292
23436
|
state.buckets.set(inst, bucket);
|
|
23293
23437
|
}
|
|
23294
23438
|
return bucket;
|
|
@@ -23327,7 +23471,8 @@ const memoizer_memo = {
|
|
|
23327
23471
|
attach(inst) {
|
|
23328
23472
|
var _a;
|
|
23329
23473
|
let isRecursiveInst;
|
|
23330
|
-
|
|
23474
|
+
let rechecked = false;
|
|
23475
|
+
// a recursive schema is re-entered many times per parse and its bucket never changes
|
|
23331
23476
|
let lastCtx;
|
|
23332
23477
|
let lastBucket;
|
|
23333
23478
|
// Wraps `parse` in a deferred so it sees the container's final parse. Core's own deferred copies `parse` into `run` when there are no checks, and it ran first, so `run` is patched to match; with checks, `run` reads `parse` dynamically.
|
|
@@ -23336,21 +23481,26 @@ const memoizer_memo = {
|
|
|
23336
23481
|
const base = inst._zod.parse;
|
|
23337
23482
|
const wrapped = (payload, ctx) => {
|
|
23338
23483
|
if (isRecursiveInst === undefined) {
|
|
23339
|
-
|
|
23340
|
-
if (
|
|
23484
|
+
const walked = isRecursive(inst, new Set(), false);
|
|
23485
|
+
if (walked === NONE) {
|
|
23341
23486
|
// Nothing here can ever fire, so take it back out.
|
|
23342
23487
|
inst._zod.parse = base;
|
|
23343
23488
|
if (inst._zod.run === wrapped)
|
|
23344
23489
|
inst._zod.run = base;
|
|
23345
23490
|
return base(payload, ctx);
|
|
23346
23491
|
}
|
|
23492
|
+
// this parse resolves the deferred edges on its own path, so ask once more before latching
|
|
23493
|
+
if (walked === PROVEN || rechecked)
|
|
23494
|
+
isRecursiveInst = true;
|
|
23495
|
+
else
|
|
23496
|
+
rechecked = true;
|
|
23347
23497
|
}
|
|
23348
23498
|
const input = payload.value;
|
|
23349
|
-
if (input
|
|
23499
|
+
if (!isRef(input))
|
|
23350
23500
|
return base(payload, ctx);
|
|
23351
23501
|
let state = ctx[STATE];
|
|
23352
23502
|
if (!state) {
|
|
23353
|
-
state = { buckets: new
|
|
23503
|
+
state = { buckets: new WeakMap(), backEdges: undefined };
|
|
23354
23504
|
ctx[STATE] = state;
|
|
23355
23505
|
}
|
|
23356
23506
|
let bucket;
|
|
@@ -23372,7 +23522,7 @@ const memoizer_memo = {
|
|
|
23372
23522
|
else {
|
|
23373
23523
|
// Still being parsed: its own checks cover it, so skip them here.
|
|
23374
23524
|
payload.memo = true;
|
|
23375
|
-
state.backEdges ?? (state.backEdges = new
|
|
23525
|
+
state.backEdges ?? (state.backEdges = new WeakSet());
|
|
23376
23526
|
state.backEdges.add(hit.value);
|
|
23377
23527
|
}
|
|
23378
23528
|
return payload;
|
|
@@ -23408,7 +23558,7 @@ function memoizer() {
|
|
|
23408
23558
|
/** Whether this value is a node a back-edge resolved to before it finished. */
|
|
23409
23559
|
function isBackEdge(ctx, value) {
|
|
23410
23560
|
const backEdges = ctx[STATE]?.backEdges;
|
|
23411
|
-
return backEdges !== undefined && value
|
|
23561
|
+
return backEdges !== undefined && isRef(value) && backEdges.has(value);
|
|
23412
23562
|
}
|
|
23413
23563
|
|
|
23414
23564
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/regexes.js
|
|
@@ -23445,7 +23595,7 @@ const uuid4 = /*@__PURE__*/ (/* unused pure expression or super */ null && (uuid
|
|
|
23445
23595
|
const uuid6 = /*@__PURE__*/ (/* unused pure expression or super */ null && (uuid(6)));
|
|
23446
23596
|
const uuid7 = /*@__PURE__*/ (/* unused pure expression or super */ null && (uuid(7)));
|
|
23447
23597
|
/** Practical email validation */
|
|
23448
|
-
const email = /^(
|
|
23598
|
+
const email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
23449
23599
|
/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
|
|
23450
23600
|
const html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
23451
23601
|
/** The classic emailregex.com regex for RFC 5322-compliant emails */
|
|
@@ -23455,8 +23605,8 @@ const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
|
|
23455
23605
|
const idnEmail = (/* unused pure expression or super */ null && (unicodeEmail));
|
|
23456
23606
|
const browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
23457
23607
|
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
|
23458
|
-
// Single character class, not an alternation: the two properties overlap (U+1F9B0-U+1F9B3), so `(A|B)+` backtracks exponentially on a failed match.
|
|
23459
|
-
const _emoji = `^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
23608
|
+
// Single character class, not an alternation: the two properties overlap (U+1F9B0-U+1F9B3), so `(A|B)+` backtracks exponentially on a failed match. The leading lookahead then demands one anchor — a pictograph, a regional indicator, or the enclosing keycap — because `\p{Emoji_Component}` on its own covers ASCII digits, `#`, `*`, ZWJ, variation selectors and skin tone modifiers, none of which is an emoji without a base.
|
|
23609
|
+
const _emoji = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
23460
23610
|
function emoji() {
|
|
23461
23611
|
return new RegExp(_emoji, "u");
|
|
23462
23612
|
}
|
|
@@ -23470,7 +23620,7 @@ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-
|
|
|
23470
23620
|
const cidrv6 = /^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
23471
23621
|
// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
|
|
23472
23622
|
const regexes_base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
23473
|
-
const regexes_base64url = /^[A-Za-z0-9_-]
|
|
23623
|
+
const regexes_base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
|
|
23474
23624
|
// based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
|
|
23475
23625
|
// export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
|
23476
23626
|
const regexes_hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
@@ -23480,6 +23630,10 @@ const httpProtocol = /^https?$/;
|
|
|
23480
23630
|
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
23481
23631
|
// Credit card shape: 12–19 digits, optionally separated by single spaces or single hyphens. ISO/IEC 7812 caps the PAN at 19 digits; 12 is the shortest issued length (Maestro).
|
|
23482
23632
|
const creditCard = /^\d(?:[ -]?\d){11,18}$/;
|
|
23633
|
+
// ISO 4217 alpha codes from the SIX list, regenerated by scripts/update-iso-4217.ts
|
|
23634
|
+
const currencyCode = /^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/;
|
|
23635
|
+
// iban electronic format: 2-letter country, check digits 02-98 (the only values `98 - remainder` can produce), 11-30 bban characters
|
|
23636
|
+
const regexes_iban = /^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/;
|
|
23483
23637
|
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])))`;
|
|
23484
23638
|
/** Anchors a pattern source. The interpolation lives here rather than at the call site because
|
|
23485
23639
|
* esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
|
|
@@ -23515,6 +23669,8 @@ function datetime(args) {
|
|
|
23515
23669
|
const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
|
|
23516
23670
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
23517
23671
|
}
|
|
23672
|
+
// the unbounded form of `string()` as a literal, so every plain string shares one instance instead of building its own
|
|
23673
|
+
const anyString = /^[\s\S]{0,}$/;
|
|
23518
23674
|
const string = (params) => {
|
|
23519
23675
|
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
23520
23676
|
return new RegExp(`^${regex}$`);
|
|
@@ -23592,16 +23748,6 @@ const numericOriginMap = {
|
|
|
23592
23748
|
const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
23593
23749
|
$ZodCheck.init(inst, def);
|
|
23594
23750
|
const origin = numericOriginMap[typeof def.value];
|
|
23595
|
-
inst._zod.onattach.push((inst) => {
|
|
23596
|
-
const bag = inst._zod.bag;
|
|
23597
|
-
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
23598
|
-
if (def.value < curr) {
|
|
23599
|
-
if (def.inclusive)
|
|
23600
|
-
bag.maximum = def.value;
|
|
23601
|
-
else
|
|
23602
|
-
bag.exclusiveMaximum = def.value;
|
|
23603
|
-
}
|
|
23604
|
-
});
|
|
23605
23751
|
inst._zod.check = (payload) => {
|
|
23606
23752
|
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
|
|
23607
23753
|
return;
|
|
@@ -23620,16 +23766,6 @@ const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst,
|
|
|
23620
23766
|
const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
23621
23767
|
$ZodCheck.init(inst, def);
|
|
23622
23768
|
const origin = numericOriginMap[typeof def.value];
|
|
23623
|
-
inst._zod.onattach.push((inst) => {
|
|
23624
|
-
const bag = inst._zod.bag;
|
|
23625
|
-
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
23626
|
-
if (def.value > curr) {
|
|
23627
|
-
if (def.inclusive)
|
|
23628
|
-
bag.minimum = def.value;
|
|
23629
|
-
else
|
|
23630
|
-
bag.exclusiveMinimum = def.value;
|
|
23631
|
-
}
|
|
23632
|
-
});
|
|
23633
23769
|
inst._zod.check = (payload) => {
|
|
23634
23770
|
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
|
|
23635
23771
|
return;
|
|
@@ -23648,10 +23784,6 @@ const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan",
|
|
|
23648
23784
|
const $ZodCheckMultipleOf =
|
|
23649
23785
|
/*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
23650
23786
|
$ZodCheck.init(inst, def);
|
|
23651
|
-
inst._zod.onattach.push((inst) => {
|
|
23652
|
-
var _a;
|
|
23653
|
-
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
|
23654
|
-
});
|
|
23655
23787
|
inst._zod.check = (payload) => {
|
|
23656
23788
|
if (typeof payload.value !== typeof def.value)
|
|
23657
23789
|
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
@@ -23677,14 +23809,6 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
|
|
|
23677
23809
|
const isInt = def.format?.includes("int");
|
|
23678
23810
|
const origin = isInt ? "int" : "number";
|
|
23679
23811
|
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
23680
|
-
inst._zod.onattach.push((inst) => {
|
|
23681
|
-
const bag = inst._zod.bag;
|
|
23682
|
-
bag.format = def.format;
|
|
23683
|
-
bag.minimum = minimum;
|
|
23684
|
-
bag.maximum = maximum;
|
|
23685
|
-
if (isInt)
|
|
23686
|
-
bag.pattern = integer;
|
|
23687
|
-
});
|
|
23688
23812
|
inst._zod.check = (payload) => {
|
|
23689
23813
|
const input = payload.value;
|
|
23690
23814
|
if (isInt) {
|
|
@@ -23773,12 +23897,6 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
|
|
|
23773
23897
|
const $ZodCheckBigIntFormat = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("$ZodCheckBigIntFormat", (inst, def) => {
|
|
23774
23898
|
$ZodCheck.init(inst, def); // no format checks
|
|
23775
23899
|
const [minimum, maximum] = util.BIGINT_FORMAT_RANGES[def.format];
|
|
23776
|
-
inst._zod.onattach.push((inst) => {
|
|
23777
|
-
const bag = inst._zod.bag;
|
|
23778
|
-
bag.format = def.format;
|
|
23779
|
-
bag.minimum = minimum;
|
|
23780
|
-
bag.maximum = maximum;
|
|
23781
|
-
});
|
|
23782
23900
|
inst._zod.check = (payload) => {
|
|
23783
23901
|
const input = payload.value;
|
|
23784
23902
|
if (input < minimum) {
|
|
@@ -23809,11 +23927,6 @@ const $ZodCheckMaxSize = /*@__PURE__*/ (/* unused pure expression or super */ nu
|
|
|
23809
23927
|
var _a;
|
|
23810
23928
|
$ZodCheck.init(inst, def);
|
|
23811
23929
|
(_a = inst._zod.def).when ?? (_a.when = _whenHasSize);
|
|
23812
|
-
inst._zod.onattach.push((inst) => {
|
|
23813
|
-
const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);
|
|
23814
|
-
if (def.maximum < curr)
|
|
23815
|
-
inst._zod.bag.maximum = def.maximum;
|
|
23816
|
-
});
|
|
23817
23930
|
inst._zod.check = (payload) => {
|
|
23818
23931
|
const input = payload.value;
|
|
23819
23932
|
const size = input.size;
|
|
@@ -23834,11 +23947,6 @@ const $ZodCheckMinSize = /*@__PURE__*/ (/* unused pure expression or super */ nu
|
|
|
23834
23947
|
var _a;
|
|
23835
23948
|
$ZodCheck.init(inst, def);
|
|
23836
23949
|
(_a = inst._zod.def).when ?? (_a.when = _whenHasSize);
|
|
23837
|
-
inst._zod.onattach.push((inst) => {
|
|
23838
|
-
const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);
|
|
23839
|
-
if (def.minimum > curr)
|
|
23840
|
-
inst._zod.bag.minimum = def.minimum;
|
|
23841
|
-
});
|
|
23842
23950
|
inst._zod.check = (payload) => {
|
|
23843
23951
|
const input = payload.value;
|
|
23844
23952
|
const size = input.size;
|
|
@@ -23859,12 +23967,6 @@ const $ZodCheckSizeEquals = /*@__PURE__*/ (/* unused pure expression or super */
|
|
|
23859
23967
|
var _a;
|
|
23860
23968
|
$ZodCheck.init(inst, def);
|
|
23861
23969
|
(_a = inst._zod.def).when ?? (_a.when = _whenHasSize);
|
|
23862
|
-
inst._zod.onattach.push((inst) => {
|
|
23863
|
-
const bag = inst._zod.bag;
|
|
23864
|
-
bag.minimum = def.size;
|
|
23865
|
-
bag.maximum = def.size;
|
|
23866
|
-
bag.size = def.size;
|
|
23867
|
-
});
|
|
23868
23970
|
inst._zod.check = (payload) => {
|
|
23869
23971
|
const input = payload.value;
|
|
23870
23972
|
const size = input.size;
|
|
@@ -23886,11 +23988,6 @@ const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (ins
|
|
|
23886
23988
|
var _a;
|
|
23887
23989
|
$ZodCheck.init(inst, def);
|
|
23888
23990
|
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
23889
|
-
inst._zod.onattach.push((inst) => {
|
|
23890
|
-
const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);
|
|
23891
|
-
if (def.maximum < curr)
|
|
23892
|
-
inst._zod.bag.maximum = def.maximum;
|
|
23893
|
-
});
|
|
23894
23991
|
inst._zod.check = (payload) => {
|
|
23895
23992
|
const input = payload.value;
|
|
23896
23993
|
const units = input.length;
|
|
@@ -23914,11 +24011,6 @@ const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (ins
|
|
|
23914
24011
|
var _a;
|
|
23915
24012
|
$ZodCheck.init(inst, def);
|
|
23916
24013
|
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
23917
|
-
inst._zod.onattach.push((inst) => {
|
|
23918
|
-
const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);
|
|
23919
|
-
if (def.minimum > curr)
|
|
23920
|
-
inst._zod.bag.minimum = def.minimum;
|
|
23921
|
-
});
|
|
23922
24014
|
inst._zod.check = (payload) => {
|
|
23923
24015
|
const input = payload.value;
|
|
23924
24016
|
const units = input.length;
|
|
@@ -23944,12 +24036,6 @@ const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals"
|
|
|
23944
24036
|
var _a;
|
|
23945
24037
|
$ZodCheck.init(inst, def);
|
|
23946
24038
|
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
23947
|
-
inst._zod.onattach.push((inst) => {
|
|
23948
|
-
const bag = inst._zod.bag;
|
|
23949
|
-
bag.minimum = def.length;
|
|
23950
|
-
bag.maximum = def.length;
|
|
23951
|
-
bag.length = def.length;
|
|
23952
|
-
});
|
|
23953
24039
|
inst._zod.check = (payload) => {
|
|
23954
24040
|
const input = payload.value;
|
|
23955
24041
|
const units = input.length;
|
|
@@ -23975,14 +24061,6 @@ const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals"
|
|
|
23975
24061
|
const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
23976
24062
|
var _a, _b;
|
|
23977
24063
|
$ZodCheck.init(inst, def);
|
|
23978
|
-
inst._zod.onattach.push((inst) => {
|
|
23979
|
-
const bag = inst._zod.bag;
|
|
23980
|
-
bag.format = def.format;
|
|
23981
|
-
if (def.pattern) {
|
|
23982
|
-
bag.patterns ?? (bag.patterns = new Set());
|
|
23983
|
-
bag.patterns.add(def.pattern);
|
|
23984
|
-
}
|
|
23985
|
-
});
|
|
23986
24064
|
if (def.pattern)
|
|
23987
24065
|
(_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
23988
24066
|
def.pattern.lastIndex = 0;
|
|
@@ -24034,11 +24112,6 @@ const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst,
|
|
|
24034
24112
|
// (`{N,}`), not exactly `position` chars (`{N}`).
|
|
24035
24113
|
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
|
|
24036
24114
|
def.pattern = pattern;
|
|
24037
|
-
inst._zod.onattach.push((inst) => {
|
|
24038
|
-
const bag = inst._zod.bag;
|
|
24039
|
-
bag.patterns ?? (bag.patterns = new Set());
|
|
24040
|
-
bag.patterns.add(pattern);
|
|
24041
|
-
});
|
|
24042
24115
|
inst._zod.check = (payload) => {
|
|
24043
24116
|
if (payload.value.includes(def.includes, def.position))
|
|
24044
24117
|
return;
|
|
@@ -24057,11 +24130,6 @@ const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (i
|
|
|
24057
24130
|
$ZodCheck.init(inst, def);
|
|
24058
24131
|
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
24059
24132
|
def.pattern ?? (def.pattern = pattern);
|
|
24060
|
-
inst._zod.onattach.push((inst) => {
|
|
24061
|
-
const bag = inst._zod.bag;
|
|
24062
|
-
bag.patterns ?? (bag.patterns = new Set());
|
|
24063
|
-
bag.patterns.add(pattern);
|
|
24064
|
-
});
|
|
24065
24133
|
inst._zod.check = (payload) => {
|
|
24066
24134
|
if (payload.value.startsWith(def.prefix))
|
|
24067
24135
|
return;
|
|
@@ -24080,11 +24148,6 @@ const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst,
|
|
|
24080
24148
|
$ZodCheck.init(inst, def);
|
|
24081
24149
|
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
24082
24150
|
def.pattern ?? (def.pattern = pattern);
|
|
24083
|
-
inst._zod.onattach.push((inst) => {
|
|
24084
|
-
const bag = inst._zod.bag;
|
|
24085
|
-
bag.patterns ?? (bag.patterns = new Set());
|
|
24086
|
-
bag.patterns.add(pattern);
|
|
24087
|
-
});
|
|
24088
24151
|
inst._zod.check = (payload) => {
|
|
24089
24152
|
if (payload.value.endsWith(def.suffix))
|
|
24090
24153
|
return;
|
|
@@ -24121,12 +24184,40 @@ const $ZodCheckProperty = /*@__PURE__*/ (/* unused pure expression or super */ n
|
|
|
24121
24184
|
return;
|
|
24122
24185
|
};
|
|
24123
24186
|
})));
|
|
24187
|
+
const $ZodCheckProperties = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("$ZodCheckProperties", (inst, def) => {
|
|
24188
|
+
$ZodCheck.init(inst, def);
|
|
24189
|
+
util.hide(inst, Symbol.iterator, function* () {
|
|
24190
|
+
yield inst;
|
|
24191
|
+
});
|
|
24192
|
+
// key and schema snapshotted together: reading one live and the other cached lets a later mutation of the caller's shape object pair a stale key with a missing schema
|
|
24193
|
+
let entries;
|
|
24194
|
+
inst._zod.check = (payload) => {
|
|
24195
|
+
// the base schema already typed the value, so only a nullish one is rejected here: the properties read on a primitive too, matching z.property() on a string's length
|
|
24196
|
+
if (payload.value == null) {
|
|
24197
|
+
payload.issues.push({ expected: "object", code: "invalid_type", input: payload.value, inst });
|
|
24198
|
+
return undefined;
|
|
24199
|
+
}
|
|
24200
|
+
entries ?? (entries = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
|
|
24201
|
+
const input = payload.value;
|
|
24202
|
+
let proms;
|
|
24203
|
+
for (const [key, schema] of entries) {
|
|
24204
|
+
const result = schema._zod.run({ value: input[key], issues: [] }, {});
|
|
24205
|
+
if (result instanceof Promise) {
|
|
24206
|
+
proms ?? (proms = []);
|
|
24207
|
+
proms.push(result.then((result) => handleCheckPropertyResult(result, payload, key)));
|
|
24208
|
+
}
|
|
24209
|
+
else {
|
|
24210
|
+
handleCheckPropertyResult(result, payload, key);
|
|
24211
|
+
}
|
|
24212
|
+
}
|
|
24213
|
+
if (proms)
|
|
24214
|
+
return Promise.all(proms).then(() => undefined);
|
|
24215
|
+
return undefined;
|
|
24216
|
+
};
|
|
24217
|
+
})));
|
|
24124
24218
|
const $ZodCheckMimeType = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("$ZodCheckMimeType", (inst, def) => {
|
|
24125
24219
|
$ZodCheck.init(inst, def);
|
|
24126
24220
|
const mimeSet = new Set(def.mime);
|
|
24127
|
-
inst._zod.onattach.push((inst) => {
|
|
24128
|
-
inst._zod.bag.mime = def.mime;
|
|
24129
|
-
});
|
|
24130
24221
|
inst._zod.check = (payload) => {
|
|
24131
24222
|
if (mimeSet.has(payload.value.type))
|
|
24132
24223
|
return;
|
|
@@ -24154,10 +24245,15 @@ class Doc {
|
|
|
24154
24245
|
this.args = args;
|
|
24155
24246
|
this.closed = closed;
|
|
24156
24247
|
}
|
|
24248
|
+
// the compiler catches a child's throw and keeps writing into this doc, so the indent has to unwind with it
|
|
24157
24249
|
indented(fn) {
|
|
24158
24250
|
this.indent += 1;
|
|
24159
|
-
|
|
24160
|
-
|
|
24251
|
+
try {
|
|
24252
|
+
fn(this);
|
|
24253
|
+
}
|
|
24254
|
+
finally {
|
|
24255
|
+
this.indent -= 1;
|
|
24256
|
+
}
|
|
24161
24257
|
}
|
|
24162
24258
|
write(arg) {
|
|
24163
24259
|
if (typeof arg === "function") {
|
|
@@ -24181,658 +24277,261 @@ class Doc {
|
|
|
24181
24277
|
}
|
|
24182
24278
|
}
|
|
24183
24279
|
|
|
24184
|
-
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/
|
|
24280
|
+
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/versions.js
|
|
24281
|
+
const versions_version = {
|
|
24282
|
+
major: 4,
|
|
24283
|
+
minor: 6,
|
|
24284
|
+
patch: 6,
|
|
24285
|
+
};
|
|
24185
24286
|
|
|
24287
|
+
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/schemas.js
|
|
24186
24288
|
|
|
24187
|
-
|
|
24188
|
-
|
|
24189
|
-
|
|
24190
|
-
|
|
24191
|
-
|
|
24192
|
-
|
|
24193
|
-
|
|
24194
|
-
|
|
24195
|
-
|
|
24196
|
-
|
|
24197
|
-
}
|
|
24198
|
-
|
|
24199
|
-
|
|
24200
|
-
|
|
24201
|
-
const
|
|
24202
|
-
|
|
24203
|
-
|
|
24204
|
-
|
|
24205
|
-
|
|
24206
|
-
|
|
24207
|
-
const
|
|
24208
|
-
|
|
24209
|
-
|
|
24210
|
-
* intrinsics so that `init` on a foreign object — it accepts any object —
|
|
24211
|
-
* can never install an accessor onto a prototype we do not own. */
|
|
24212
|
-
const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
24213
|
-
const errors_initializer = (inst, def) => {
|
|
24214
|
-
inst.name = "$ZodError";
|
|
24215
|
-
errors_zodDesc.value = inst._zod;
|
|
24216
|
-
Object.defineProperty(inst, "_zod", errors_zodDesc);
|
|
24217
|
-
_issuesDesc.value = def;
|
|
24218
|
-
Object.defineProperty(inst, "issues", _issuesDesc);
|
|
24219
|
-
// Clear the shared slots; a retained `value` pins the last error's issues.
|
|
24220
|
-
errors_zodDesc.value = undefined;
|
|
24221
|
-
_issuesDesc.value = undefined;
|
|
24222
|
-
Object.defineProperty(inst, "message", _messageDesc);
|
|
24223
|
-
/* `toString` lives as a non-enumerable lazy getter on the shared
|
|
24224
|
-
* prototype; on first access it caches a per-instance closure so
|
|
24225
|
-
* detached usage still works. */
|
|
24226
|
-
const proto = Object.getPrototypeOf(inst);
|
|
24227
|
-
if (!_installedToString.has(proto)) {
|
|
24228
|
-
_installedToString.add(proto);
|
|
24229
|
-
Object.defineProperty(proto, "toString", {
|
|
24230
|
-
configurable: true,
|
|
24231
|
-
enumerable: false,
|
|
24232
|
-
get() {
|
|
24233
|
-
const value = () => this.message;
|
|
24234
|
-
Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
|
|
24235
|
-
return value;
|
|
24236
|
-
},
|
|
24237
|
-
set(value) {
|
|
24238
|
-
Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
|
|
24239
|
-
},
|
|
24240
|
-
});
|
|
24289
|
+
|
|
24290
|
+
|
|
24291
|
+
|
|
24292
|
+
|
|
24293
|
+
|
|
24294
|
+
|
|
24295
|
+
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
24296
|
+
var _a;
|
|
24297
|
+
inst ?? (inst = {});
|
|
24298
|
+
inst._zod.def = def; // set _def property
|
|
24299
|
+
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
|
24300
|
+
inst._zod.version = versions_version;
|
|
24301
|
+
const defChecks = inst._zod.def.checks;
|
|
24302
|
+
// if inst is itself a checks.$ZodCheck, run it as a check
|
|
24303
|
+
const checks = inst._zod.traits.has("$ZodCheck")
|
|
24304
|
+
? [inst, ...(defChecks ?? [])]
|
|
24305
|
+
: defChecks?.length
|
|
24306
|
+
? [...defChecks]
|
|
24307
|
+
: [];
|
|
24308
|
+
for (const ch of checks) {
|
|
24309
|
+
for (const fn of ch._zod.onattach) {
|
|
24310
|
+
fn(inst);
|
|
24311
|
+
}
|
|
24241
24312
|
}
|
|
24242
|
-
|
|
24243
|
-
|
|
24244
|
-
|
|
24245
|
-
|
|
24246
|
-
|
|
24247
|
-
|
|
24248
|
-
* ("toString", "constructor") would otherwise read through to the prototype, and assigning
|
|
24249
|
-
* "__proto__" would hit the setter instead of creating a key. */
|
|
24250
|
-
function errors_node(obj, key, make) {
|
|
24251
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
24252
|
-
if (key === "__proto__") {
|
|
24253
|
-
Object.defineProperty(obj, key, { value: make(), writable: true, enumerable: true, configurable: true });
|
|
24254
|
-
}
|
|
24255
|
-
else {
|
|
24256
|
-
obj[key] = make();
|
|
24257
|
-
}
|
|
24258
|
-
}
|
|
24259
|
-
return obj[key];
|
|
24260
|
-
}
|
|
24261
|
-
function flattenError(error, mapper = (issue) => issue.message) {
|
|
24262
|
-
const fieldErrors = {};
|
|
24263
|
-
const formErrors = [];
|
|
24264
|
-
for (const sub of error.issues) {
|
|
24265
|
-
if (sub.path.length > 0) {
|
|
24266
|
-
errors_node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
|
|
24267
|
-
}
|
|
24268
|
-
else {
|
|
24269
|
-
formErrors.push(mapper(sub));
|
|
24270
|
-
}
|
|
24313
|
+
if (checks.length === 0) {
|
|
24314
|
+
// deferred initializer inst._zod.parse is not yet defined
|
|
24315
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
24316
|
+
inst._zod.deferred?.push(() => {
|
|
24317
|
+
inst._zod.run = inst._zod.parse;
|
|
24318
|
+
});
|
|
24271
24319
|
}
|
|
24272
|
-
|
|
24273
|
-
|
|
24274
|
-
|
|
24275
|
-
|
|
24276
|
-
|
|
24277
|
-
|
|
24278
|
-
|
|
24279
|
-
|
|
24280
|
-
|
|
24281
|
-
|
|
24282
|
-
|
|
24283
|
-
|
|
24284
|
-
|
|
24285
|
-
|
|
24286
|
-
|
|
24287
|
-
|
|
24288
|
-
|
|
24289
|
-
|
|
24290
|
-
|
|
24320
|
+
else {
|
|
24321
|
+
const runChecks = (payload, checks, ctx) => {
|
|
24322
|
+
if (payload.memo)
|
|
24323
|
+
return payload;
|
|
24324
|
+
let isAborted = aborted(payload);
|
|
24325
|
+
let asyncResult;
|
|
24326
|
+
for (const ch of checks) {
|
|
24327
|
+
if (ch._zod.def.when) {
|
|
24328
|
+
if (explicitlyAborted(payload))
|
|
24329
|
+
continue;
|
|
24330
|
+
const shouldRun = ch._zod.def.when(payload);
|
|
24331
|
+
if (!shouldRun)
|
|
24332
|
+
continue;
|
|
24333
|
+
}
|
|
24334
|
+
else if (isAborted) {
|
|
24335
|
+
continue;
|
|
24336
|
+
}
|
|
24337
|
+
const currLen = payload.issues.length;
|
|
24338
|
+
const _ = ch._zod.check(payload);
|
|
24339
|
+
if (_ instanceof Promise && ctx?.async === false) {
|
|
24340
|
+
throw new $ZodAsyncError();
|
|
24341
|
+
}
|
|
24342
|
+
if (asyncResult || _ instanceof Promise) {
|
|
24343
|
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
24344
|
+
await _;
|
|
24345
|
+
const nextLen = payload.issues.length;
|
|
24346
|
+
if (nextLen === currLen)
|
|
24347
|
+
return;
|
|
24348
|
+
attachSchema(payload.issues, currLen, inst);
|
|
24349
|
+
if (!isAborted)
|
|
24350
|
+
isAborted = aborted(payload, currLen);
|
|
24351
|
+
});
|
|
24291
24352
|
}
|
|
24292
24353
|
else {
|
|
24293
|
-
|
|
24294
|
-
|
|
24295
|
-
|
|
24296
|
-
|
|
24297
|
-
|
|
24298
|
-
|
|
24299
|
-
if (el === "_errors") {
|
|
24300
|
-
if (terminal)
|
|
24301
|
-
curr._errors.push(mapper(issue));
|
|
24302
|
-
i++;
|
|
24303
|
-
continue;
|
|
24304
|
-
}
|
|
24305
|
-
// A path element may collide with an inherited property name such as
|
|
24306
|
-
// "__proto__" or "constructor". Truthiness checks read the prototype
|
|
24307
|
-
// (so no node is created, then ._errors.push throws), and bracket
|
|
24308
|
-
// assignment of "__proto__" hits the setter instead of creating an
|
|
24309
|
-
// own key. Guard the read with hasOwnProperty and create the node
|
|
24310
|
-
// with defineProperty so any path element becomes a real own key.
|
|
24311
|
-
if (!Object.prototype.hasOwnProperty.call(curr, el)) {
|
|
24312
|
-
Object.defineProperty(curr, el, {
|
|
24313
|
-
value: { _errors: [] },
|
|
24314
|
-
enumerable: true,
|
|
24315
|
-
writable: true,
|
|
24316
|
-
configurable: true,
|
|
24317
|
-
});
|
|
24318
|
-
}
|
|
24319
|
-
const node = curr[el];
|
|
24320
|
-
if (terminal) {
|
|
24321
|
-
node._errors.push(mapper(issue));
|
|
24322
|
-
}
|
|
24323
|
-
curr = node;
|
|
24324
|
-
i++;
|
|
24325
|
-
}
|
|
24354
|
+
const nextLen = payload.issues.length;
|
|
24355
|
+
if (nextLen === currLen)
|
|
24356
|
+
continue;
|
|
24357
|
+
attachSchema(payload.issues, currLen, inst);
|
|
24358
|
+
if (!isAborted)
|
|
24359
|
+
isAborted = aborted(payload, currLen);
|
|
24326
24360
|
}
|
|
24327
24361
|
}
|
|
24328
|
-
|
|
24329
|
-
|
|
24330
|
-
|
|
24331
|
-
|
|
24332
|
-
}
|
|
24333
|
-
function treeifyError(error, mapper = (issue) => issue.message) {
|
|
24334
|
-
const result = { errors: [] };
|
|
24335
|
-
const processError = (error, path = []) => {
|
|
24336
|
-
var _a;
|
|
24337
|
-
for (const issue of error.issues) {
|
|
24338
|
-
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
24339
|
-
// regular union error
|
|
24340
|
-
issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
24362
|
+
if (asyncResult) {
|
|
24363
|
+
return asyncResult.then(() => {
|
|
24364
|
+
return payload;
|
|
24365
|
+
});
|
|
24341
24366
|
}
|
|
24342
|
-
|
|
24343
|
-
|
|
24367
|
+
return payload;
|
|
24368
|
+
};
|
|
24369
|
+
const handleCanaryResult = (canary, payload, ctx) => {
|
|
24370
|
+
// abort if the canary is aborted
|
|
24371
|
+
if (aborted(canary)) {
|
|
24372
|
+
canary.aborted = true;
|
|
24373
|
+
return canary;
|
|
24344
24374
|
}
|
|
24345
|
-
|
|
24346
|
-
|
|
24375
|
+
// run checks first, then
|
|
24376
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
24377
|
+
if (checkResult instanceof Promise) {
|
|
24378
|
+
if (ctx.async === false)
|
|
24379
|
+
throw new $ZodAsyncError();
|
|
24380
|
+
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
|
24347
24381
|
}
|
|
24348
|
-
|
|
24349
|
-
|
|
24350
|
-
|
|
24351
|
-
|
|
24352
|
-
|
|
24353
|
-
|
|
24354
|
-
|
|
24355
|
-
|
|
24356
|
-
|
|
24357
|
-
|
|
24358
|
-
|
|
24359
|
-
|
|
24360
|
-
|
|
24361
|
-
// el may collide with an inherited property name ("__proto__",
|
|
24362
|
-
// "constructor", ...); ??= reads the prototype so the node is never
|
|
24363
|
-
// created and curr.errors.push throws. Guard with hasOwnProperty and
|
|
24364
|
-
// create the node with defineProperty so "__proto__" becomes a real
|
|
24365
|
-
// own key rather than invoking the prototype setter.
|
|
24366
|
-
if (!Object.prototype.hasOwnProperty.call(curr.properties, el)) {
|
|
24367
|
-
Object.defineProperty(curr.properties, el, {
|
|
24368
|
-
value: { errors: [] },
|
|
24369
|
-
enumerable: true,
|
|
24370
|
-
writable: true,
|
|
24371
|
-
configurable: true,
|
|
24372
|
-
});
|
|
24373
|
-
}
|
|
24374
|
-
curr = curr.properties[el];
|
|
24375
|
-
}
|
|
24376
|
-
else {
|
|
24377
|
-
curr.items ?? (curr.items = []);
|
|
24378
|
-
(_a = curr.items)[el] ?? (_a[el] = { errors: [] });
|
|
24379
|
-
curr = curr.items[el];
|
|
24380
|
-
}
|
|
24381
|
-
if (terminal) {
|
|
24382
|
-
curr.errors.push(mapper(issue));
|
|
24383
|
-
}
|
|
24384
|
-
i++;
|
|
24382
|
+
return inst._zod.parse(checkResult, ctx);
|
|
24383
|
+
};
|
|
24384
|
+
inst._zod.run = (payload, ctx) => {
|
|
24385
|
+
if (ctx.skipChecks) {
|
|
24386
|
+
return inst._zod.parse(payload, ctx);
|
|
24387
|
+
}
|
|
24388
|
+
if (ctx.direction === "backward") {
|
|
24389
|
+
// run canary initial pass (no checks)
|
|
24390
|
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
24391
|
+
if (canary instanceof Promise) {
|
|
24392
|
+
return canary.then((canary) => {
|
|
24393
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
24394
|
+
});
|
|
24385
24395
|
}
|
|
24396
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
24386
24397
|
}
|
|
24387
|
-
|
|
24398
|
+
// forward
|
|
24399
|
+
const result = inst._zod.parse(payload, ctx);
|
|
24400
|
+
if (result instanceof Promise) {
|
|
24401
|
+
if (ctx.async === false)
|
|
24402
|
+
throw new $ZodAsyncError();
|
|
24403
|
+
return result.then((result) => runChecks(result, checks, ctx));
|
|
24404
|
+
}
|
|
24405
|
+
return runChecks(result, checks, ctx);
|
|
24406
|
+
};
|
|
24407
|
+
}
|
|
24408
|
+
}, {
|
|
24409
|
+
// Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
|
|
24410
|
+
get "~standard"() {
|
|
24411
|
+
return hide(this, "~standard", standardProps(this));
|
|
24412
|
+
},
|
|
24413
|
+
set "~standard"(value) {
|
|
24414
|
+
util_own(this, "~standard", value);
|
|
24415
|
+
},
|
|
24416
|
+
});
|
|
24417
|
+
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
|
|
24418
|
+
// a Standard Schema result only reports issues, so a failure finalizes them straight off the raw payload: no ZodError, and no lazy result to read through
|
|
24419
|
+
const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, core_config())) } : { value: r.value };
|
|
24420
|
+
async function validateAsync(inst, value) {
|
|
24421
|
+
const ctx = { async: true };
|
|
24422
|
+
return toStandardResult((await inst._zod.run({ value, issues: [] }, ctx)), ctx);
|
|
24423
|
+
}
|
|
24424
|
+
function standardProps(inst) {
|
|
24425
|
+
return {
|
|
24426
|
+
validate: (value) => {
|
|
24427
|
+
const ctx = { async: false };
|
|
24428
|
+
try {
|
|
24429
|
+
const r = inst._zod.run({ value, issues: [] }, ctx);
|
|
24430
|
+
if (!(r instanceof Promise))
|
|
24431
|
+
return toStandardResult(r, ctx);
|
|
24432
|
+
}
|
|
24433
|
+
catch (_) { }
|
|
24434
|
+
// async function so a synchronously throwing check rejects instead of escaping validate
|
|
24435
|
+
return validateAsync(inst, value);
|
|
24436
|
+
},
|
|
24437
|
+
vendor: "zod",
|
|
24438
|
+
version: 1,
|
|
24388
24439
|
};
|
|
24389
|
-
processError(error);
|
|
24390
|
-
return result;
|
|
24391
24440
|
}
|
|
24392
|
-
|
|
24393
|
-
|
|
24394
|
-
|
|
24395
|
-
|
|
24396
|
-
|
|
24397
|
-
|
|
24398
|
-
|
|
24399
|
-
|
|
24400
|
-
|
|
24401
|
-
|
|
24402
|
-
|
|
24403
|
-
|
|
24404
|
-
|
|
24405
|
-
|
|
24406
|
-
|
|
24407
|
-
|
|
24408
|
-
|
|
24409
|
-
|
|
24410
|
-
|
|
24411
|
-
|
|
24412
|
-
|
|
24413
|
-
|
|
24414
|
-
|
|
24415
|
-
|
|
24416
|
-
|
|
24417
|
-
|
|
24418
|
-
|
|
24419
|
-
|
|
24420
|
-
|
|
24421
|
-
|
|
24422
|
-
|
|
24423
|
-
*/
|
|
24424
|
-
|
|
24425
|
-
|
|
24426
|
-
|
|
24427
|
-
|
|
24428
|
-
|
|
24429
|
-
|
|
24430
|
-
|
|
24431
|
-
|
|
24432
|
-
|
|
24433
|
-
|
|
24434
|
-
|
|
24435
|
-
|
|
24436
|
-
|
|
24437
|
-
|
|
24438
|
-
|
|
24441
|
+
|
|
24442
|
+
const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
|
|
24443
|
+
$ZodType.init(inst, def);
|
|
24444
|
+
// a format's own pattern, else unbounded; a template literal derives the check-aware form itself
|
|
24445
|
+
inst._zod.pattern = def.pattern ?? anyString;
|
|
24446
|
+
inst._zod.parse = (payload, _) => {
|
|
24447
|
+
if (def.coerce)
|
|
24448
|
+
try {
|
|
24449
|
+
payload.value = String(payload.value);
|
|
24450
|
+
}
|
|
24451
|
+
catch (_) { }
|
|
24452
|
+
if (typeof payload.value === "string")
|
|
24453
|
+
return payload;
|
|
24454
|
+
payload.issues.push({
|
|
24455
|
+
expected: "string",
|
|
24456
|
+
code: "invalid_type",
|
|
24457
|
+
input: payload.value,
|
|
24458
|
+
inst,
|
|
24459
|
+
});
|
|
24460
|
+
return payload;
|
|
24461
|
+
};
|
|
24462
|
+
});
|
|
24463
|
+
const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
|
|
24464
|
+
// check initialization must come first
|
|
24465
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
24466
|
+
$ZodString.init(inst, def);
|
|
24467
|
+
});
|
|
24468
|
+
const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def) => {
|
|
24469
|
+
def.pattern ?? (def.pattern = guid);
|
|
24470
|
+
$ZodStringFormat.init(inst, def);
|
|
24471
|
+
});
|
|
24472
|
+
const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
|
|
24473
|
+
if (def.version) {
|
|
24474
|
+
const versionMap = {
|
|
24475
|
+
v1: 1,
|
|
24476
|
+
v2: 2,
|
|
24477
|
+
v3: 3,
|
|
24478
|
+
v4: 4,
|
|
24479
|
+
v5: 5,
|
|
24480
|
+
v6: 6,
|
|
24481
|
+
v7: 7,
|
|
24482
|
+
v8: 8,
|
|
24483
|
+
};
|
|
24484
|
+
const v = versionMap[def.version];
|
|
24485
|
+
if (v === undefined)
|
|
24486
|
+
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
24487
|
+
def.pattern ?? (def.pattern = uuid(v));
|
|
24439
24488
|
}
|
|
24440
|
-
|
|
24441
|
-
|
|
24442
|
-
|
|
24443
|
-
|
|
24444
|
-
|
|
24445
|
-
|
|
24446
|
-
|
|
24447
|
-
|
|
24448
|
-
|
|
24449
|
-
|
|
24450
|
-
|
|
24489
|
+
else
|
|
24490
|
+
def.pattern ?? (def.pattern = uuid());
|
|
24491
|
+
$ZodStringFormat.init(inst, def);
|
|
24492
|
+
});
|
|
24493
|
+
const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
|
|
24494
|
+
def.pattern ?? (def.pattern = email);
|
|
24495
|
+
$ZodStringFormat.init(inst, def);
|
|
24496
|
+
});
|
|
24497
|
+
/** The `://` guard rejected the input before the URL constructor saw it. */
|
|
24498
|
+
const URL_BAD_FORMAT = 1;
|
|
24499
|
+
/** The URL parser rejected the input. */
|
|
24500
|
+
const URL_UNPARSEABLE = 2;
|
|
24501
|
+
function canParseURL(input) {
|
|
24502
|
+
try {
|
|
24503
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function")
|
|
24504
|
+
return URL.canParse(input);
|
|
24505
|
+
new URL(input);
|
|
24506
|
+
return true;
|
|
24507
|
+
}
|
|
24508
|
+
catch {
|
|
24509
|
+
return false;
|
|
24451
24510
|
}
|
|
24452
|
-
// Convert Map to formatted string
|
|
24453
|
-
return lines.join("\n");
|
|
24454
24511
|
}
|
|
24455
|
-
|
|
24456
|
-
|
|
24457
|
-
|
|
24458
|
-
|
|
24459
|
-
|
|
24460
|
-
// Always both keys, so the `_params` read site in `_parse` sees one object shape rather than two.
|
|
24461
|
-
function finalizeParams(callee, params) {
|
|
24462
|
-
return { callee: params?.callee ?? callee, Err: params?.Err };
|
|
24512
|
+
function validateURL(trimmed, def) {
|
|
24513
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
|
|
24514
|
+
return canParseURL(trimmed) || URL_UNPARSEABLE;
|
|
24515
|
+
}
|
|
24516
|
+
return parseURLObject(trimmed, def);
|
|
24463
24517
|
}
|
|
24464
|
-
|
|
24465
|
-
|
|
24466
|
-
|
|
24467
|
-
|
|
24468
|
-
|
|
24469
|
-
throw new $ZodAsyncError();
|
|
24470
|
-
}
|
|
24471
|
-
if (result.issues.length) {
|
|
24472
|
-
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, core_config())));
|
|
24473
|
-
captureStackTrace(e, _params?.callee ?? fn);
|
|
24474
|
-
throw e;
|
|
24475
|
-
}
|
|
24476
|
-
return result.value;
|
|
24477
|
-
};
|
|
24478
|
-
return fn;
|
|
24479
|
-
};
|
|
24480
|
-
const core_parse_parse = /* @__PURE__*/ parse_parse($ZodRealError);
|
|
24481
|
-
const parse_parseAsync = (_Err) => {
|
|
24482
|
-
const fn = async (schema, value, _ctx, params) => {
|
|
24483
|
-
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
24484
|
-
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
24485
|
-
if (result instanceof Promise)
|
|
24486
|
-
result = await result;
|
|
24487
|
-
if (result.issues.length) {
|
|
24488
|
-
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, core_config())));
|
|
24489
|
-
captureStackTrace(e, params?.callee ?? fn);
|
|
24490
|
-
throw e;
|
|
24491
|
-
}
|
|
24492
|
-
return result.value;
|
|
24493
|
-
};
|
|
24494
|
-
return fn;
|
|
24495
|
-
};
|
|
24496
|
-
const core_parse_parseAsync = /* @__PURE__*/ parse_parseAsync($ZodRealError);
|
|
24497
|
-
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
24498
|
-
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
24499
|
-
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
24500
|
-
if (result instanceof Promise) {
|
|
24501
|
-
throw new $ZodAsyncError();
|
|
24518
|
+
/** Parses a URL while preserving the non-normalizing HTTP guard. */
|
|
24519
|
+
function parseURLObject(trimmed, def) {
|
|
24520
|
+
// When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
|
24521
|
+
if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
|
|
24522
|
+
return URL_BAD_FORMAT;
|
|
24502
24523
|
}
|
|
24503
|
-
|
|
24504
|
-
|
|
24505
|
-
|
|
24506
|
-
|
|
24507
|
-
|
|
24508
|
-
: { success: true, data: result.value };
|
|
24509
|
-
};
|
|
24510
|
-
const safeParse = /* @__PURE__*/ _safeParse($ZodRealError);
|
|
24511
|
-
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
24512
|
-
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
24513
|
-
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
24514
|
-
if (result instanceof Promise)
|
|
24515
|
-
result = await result;
|
|
24516
|
-
return result.issues.length
|
|
24517
|
-
? {
|
|
24518
|
-
success: false,
|
|
24519
|
-
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, core_config()))),
|
|
24524
|
+
try {
|
|
24525
|
+
if (typeof URL !== "undefined") {
|
|
24526
|
+
const URLStatic = URL;
|
|
24527
|
+
if (typeof URLStatic.parse === "function")
|
|
24528
|
+
return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
|
|
24520
24529
|
}
|
|
24521
|
-
|
|
24522
|
-
|
|
24523
|
-
const safeParseAsync = /* @__PURE__*/ _safeParseAsync($ZodRealError);
|
|
24524
|
-
// registry mirrors of the compiler's sentinels, so this module never imports the compiler
|
|
24525
|
-
const COMPILE_INVALID = /* @__PURE__ */ (/* unused pure expression or super */ null && (Symbol.for("zod.compile.invalid")));
|
|
24526
|
-
const COMPILE_FALLBACK = /* @__PURE__ */ (/* unused pure expression or super */ null && (Symbol.for("zod.compile.fallback")));
|
|
24527
|
-
// Deliberately tiny, because v8 will not inline a body carrying the fallback's object literals and throw. Everything that is not the compiled happy path lives in validateFallback, and that split is worth ~35% on a compiled schema.
|
|
24528
|
-
const validate = ((schema, value, _ctx) => {
|
|
24529
|
-
const validator = schema._zod.bag.validator;
|
|
24530
|
-
if (validator !== undefined && validator(value) !== COMPILE_INVALID)
|
|
24531
|
-
return true;
|
|
24532
|
-
return validateFallback(schema, value, _ctx);
|
|
24533
|
-
});
|
|
24534
|
-
function validateFallback(schema, value, _ctx) {
|
|
24535
|
-
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
24536
|
-
const fallbackRun = schema._zod.bag.fallbackRun;
|
|
24537
|
-
let result;
|
|
24538
|
-
if (fallbackRun) {
|
|
24539
|
-
// skip nested fast paths on the fallback, so user callbacks keep the at-most-twice bound
|
|
24540
|
-
ctx[COMPILE_FALLBACK] = true;
|
|
24541
|
-
result = fallbackRun({ value, issues: [] }, ctx);
|
|
24542
|
-
}
|
|
24543
|
-
else {
|
|
24544
|
-
result = schema._zod.run({ value, issues: [] }, ctx);
|
|
24530
|
+
// @ts-ignore
|
|
24531
|
+
return new URL(trimmed);
|
|
24545
24532
|
}
|
|
24546
|
-
|
|
24547
|
-
|
|
24548
|
-
}
|
|
24549
|
-
return result.issues.length === 0;
|
|
24550
|
-
}
|
|
24551
|
-
// no fast path: the compiler keeps async parses on the runtime, because a promise-returning callback that is not declared async compiles to a throw
|
|
24552
|
-
const validateAsync = async (schema, value, _ctx) => {
|
|
24553
|
-
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
24554
|
-
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
24555
|
-
if (result instanceof Promise)
|
|
24556
|
-
result = await result;
|
|
24557
|
-
return result.issues.length === 0;
|
|
24558
|
-
};
|
|
24559
|
-
const parse_encode = (_Err) => {
|
|
24560
|
-
const parse = parse_parse(_Err);
|
|
24561
|
-
const fn = (schema, value, _ctx, _params) => {
|
|
24562
|
-
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
24563
|
-
return parse(schema, value, ctx, finalizeParams(fn, _params));
|
|
24564
|
-
};
|
|
24565
|
-
return fn;
|
|
24566
|
-
};
|
|
24567
|
-
const encode = /* @__PURE__*/ parse_encode($ZodRealError);
|
|
24568
|
-
const parse_decode = (_Err) => {
|
|
24569
|
-
const parse = parse_parse(_Err);
|
|
24570
|
-
const fn = (schema, value, _ctx, _params) => {
|
|
24571
|
-
return parse(schema, value, _ctx, finalizeParams(fn, _params));
|
|
24572
|
-
};
|
|
24573
|
-
return fn;
|
|
24574
|
-
};
|
|
24575
|
-
const decode = /* @__PURE__*/ parse_decode($ZodRealError);
|
|
24576
|
-
const parse_encodeAsync = (_Err) => {
|
|
24577
|
-
const parseAsync = parse_parseAsync(_Err);
|
|
24578
|
-
const fn = async (schema, value, _ctx, _params) => {
|
|
24579
|
-
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
24580
|
-
return (await parseAsync(schema, value, ctx, finalizeParams(fn, _params)));
|
|
24581
|
-
};
|
|
24582
|
-
return fn;
|
|
24583
|
-
};
|
|
24584
|
-
const encodeAsync = /* @__PURE__*/ parse_encodeAsync($ZodRealError);
|
|
24585
|
-
const parse_decodeAsync = (_Err) => {
|
|
24586
|
-
const parseAsync = parse_parseAsync(_Err);
|
|
24587
|
-
const fn = async (schema, value, _ctx, _params) => {
|
|
24588
|
-
return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
|
|
24589
|
-
};
|
|
24590
|
-
return fn;
|
|
24591
|
-
};
|
|
24592
|
-
const decodeAsync = /* @__PURE__*/ parse_decodeAsync($ZodRealError);
|
|
24593
|
-
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
24594
|
-
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
24595
|
-
return _safeParse(_Err)(schema, value, ctx);
|
|
24596
|
-
};
|
|
24597
|
-
const safeEncode = /* @__PURE__*/ _safeEncode($ZodRealError);
|
|
24598
|
-
const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
24599
|
-
return _safeParse(_Err)(schema, value, _ctx);
|
|
24600
|
-
};
|
|
24601
|
-
const safeDecode = /* @__PURE__*/ _safeDecode($ZodRealError);
|
|
24602
|
-
const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
24603
|
-
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
24604
|
-
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
24605
|
-
};
|
|
24606
|
-
const safeEncodeAsync = /* @__PURE__*/ _safeEncodeAsync($ZodRealError);
|
|
24607
|
-
const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
24608
|
-
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
24609
|
-
};
|
|
24610
|
-
const safeDecodeAsync = /* @__PURE__*/ _safeDecodeAsync($ZodRealError);
|
|
24611
|
-
|
|
24612
|
-
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/versions.js
|
|
24613
|
-
const versions_version = {
|
|
24614
|
-
major: 4,
|
|
24615
|
-
minor: 5,
|
|
24616
|
-
patch: 2,
|
|
24617
|
-
};
|
|
24618
|
-
|
|
24619
|
-
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/schemas.js
|
|
24620
|
-
|
|
24621
|
-
|
|
24622
|
-
|
|
24623
|
-
|
|
24624
|
-
|
|
24625
|
-
|
|
24626
|
-
|
|
24627
|
-
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
24628
|
-
var _a;
|
|
24629
|
-
inst ?? (inst = {});
|
|
24630
|
-
inst._zod.def = def; // set _def property
|
|
24631
|
-
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
|
24632
|
-
inst._zod.version = versions_version;
|
|
24633
|
-
const defChecks = inst._zod.def.checks;
|
|
24634
|
-
// if inst is itself a checks.$ZodCheck, run it as a check
|
|
24635
|
-
const checks = inst._zod.traits.has("$ZodCheck")
|
|
24636
|
-
? [inst, ...(defChecks ?? [])]
|
|
24637
|
-
: defChecks?.length
|
|
24638
|
-
? [...defChecks]
|
|
24639
|
-
: [];
|
|
24640
|
-
for (const ch of checks) {
|
|
24641
|
-
for (const fn of ch._zod.onattach) {
|
|
24642
|
-
fn(inst);
|
|
24643
|
-
}
|
|
24644
|
-
}
|
|
24645
|
-
if (checks.length === 0) {
|
|
24646
|
-
// deferred initializer inst._zod.parse is not yet defined
|
|
24647
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
24648
|
-
inst._zod.deferred?.push(() => {
|
|
24649
|
-
inst._zod.run = inst._zod.parse;
|
|
24650
|
-
});
|
|
24651
|
-
}
|
|
24652
|
-
else {
|
|
24653
|
-
const runChecks = (payload, checks, ctx) => {
|
|
24654
|
-
if (payload.memo)
|
|
24655
|
-
return payload;
|
|
24656
|
-
let isAborted = aborted(payload);
|
|
24657
|
-
let asyncResult;
|
|
24658
|
-
for (const ch of checks) {
|
|
24659
|
-
if (ch._zod.def.when) {
|
|
24660
|
-
if (explicitlyAborted(payload))
|
|
24661
|
-
continue;
|
|
24662
|
-
const shouldRun = ch._zod.def.when(payload);
|
|
24663
|
-
if (!shouldRun)
|
|
24664
|
-
continue;
|
|
24665
|
-
}
|
|
24666
|
-
else if (isAborted) {
|
|
24667
|
-
continue;
|
|
24668
|
-
}
|
|
24669
|
-
const currLen = payload.issues.length;
|
|
24670
|
-
const _ = ch._zod.check(payload);
|
|
24671
|
-
if (_ instanceof Promise && ctx?.async === false) {
|
|
24672
|
-
throw new $ZodAsyncError();
|
|
24673
|
-
}
|
|
24674
|
-
if (asyncResult || _ instanceof Promise) {
|
|
24675
|
-
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
24676
|
-
await _;
|
|
24677
|
-
const nextLen = payload.issues.length;
|
|
24678
|
-
if (nextLen === currLen)
|
|
24679
|
-
return;
|
|
24680
|
-
attachSchema(payload.issues, currLen, inst);
|
|
24681
|
-
if (!isAborted)
|
|
24682
|
-
isAborted = aborted(payload, currLen);
|
|
24683
|
-
});
|
|
24684
|
-
}
|
|
24685
|
-
else {
|
|
24686
|
-
const nextLen = payload.issues.length;
|
|
24687
|
-
if (nextLen === currLen)
|
|
24688
|
-
continue;
|
|
24689
|
-
attachSchema(payload.issues, currLen, inst);
|
|
24690
|
-
if (!isAborted)
|
|
24691
|
-
isAborted = aborted(payload, currLen);
|
|
24692
|
-
}
|
|
24693
|
-
}
|
|
24694
|
-
if (asyncResult) {
|
|
24695
|
-
return asyncResult.then(() => {
|
|
24696
|
-
return payload;
|
|
24697
|
-
});
|
|
24698
|
-
}
|
|
24699
|
-
return payload;
|
|
24700
|
-
};
|
|
24701
|
-
const handleCanaryResult = (canary, payload, ctx) => {
|
|
24702
|
-
// abort if the canary is aborted
|
|
24703
|
-
if (aborted(canary)) {
|
|
24704
|
-
canary.aborted = true;
|
|
24705
|
-
return canary;
|
|
24706
|
-
}
|
|
24707
|
-
// run checks first, then
|
|
24708
|
-
const checkResult = runChecks(payload, checks, ctx);
|
|
24709
|
-
if (checkResult instanceof Promise) {
|
|
24710
|
-
if (ctx.async === false)
|
|
24711
|
-
throw new $ZodAsyncError();
|
|
24712
|
-
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
|
24713
|
-
}
|
|
24714
|
-
return inst._zod.parse(checkResult, ctx);
|
|
24715
|
-
};
|
|
24716
|
-
inst._zod.run = (payload, ctx) => {
|
|
24717
|
-
if (ctx.skipChecks) {
|
|
24718
|
-
return inst._zod.parse(payload, ctx);
|
|
24719
|
-
}
|
|
24720
|
-
if (ctx.direction === "backward") {
|
|
24721
|
-
// run canary initial pass (no checks)
|
|
24722
|
-
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
24723
|
-
if (canary instanceof Promise) {
|
|
24724
|
-
return canary.then((canary) => {
|
|
24725
|
-
return handleCanaryResult(canary, payload, ctx);
|
|
24726
|
-
});
|
|
24727
|
-
}
|
|
24728
|
-
return handleCanaryResult(canary, payload, ctx);
|
|
24729
|
-
}
|
|
24730
|
-
// forward
|
|
24731
|
-
const result = inst._zod.parse(payload, ctx);
|
|
24732
|
-
if (result instanceof Promise) {
|
|
24733
|
-
if (ctx.async === false)
|
|
24734
|
-
throw new $ZodAsyncError();
|
|
24735
|
-
return result.then((result) => runChecks(result, checks, ctx));
|
|
24736
|
-
}
|
|
24737
|
-
return runChecks(result, checks, ctx);
|
|
24738
|
-
};
|
|
24739
|
-
}
|
|
24740
|
-
}, {
|
|
24741
|
-
// Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
|
|
24742
|
-
get "~standard"() {
|
|
24743
|
-
return hide(this, "~standard", standardProps(this));
|
|
24744
|
-
},
|
|
24745
|
-
set "~standard"(value) {
|
|
24746
|
-
util_own(this, "~standard", value);
|
|
24747
|
-
},
|
|
24748
|
-
});
|
|
24749
|
-
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
|
|
24750
|
-
const toStandardResult = (r) => r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
24751
|
-
function standardProps(inst) {
|
|
24752
|
-
return {
|
|
24753
|
-
validate: (value) => {
|
|
24754
|
-
try {
|
|
24755
|
-
return toStandardResult(safeParse(inst, value));
|
|
24756
|
-
}
|
|
24757
|
-
catch (_) {
|
|
24758
|
-
return safeParseAsync(inst, value).then(toStandardResult);
|
|
24759
|
-
}
|
|
24760
|
-
},
|
|
24761
|
-
vendor: "zod",
|
|
24762
|
-
version: 1,
|
|
24763
|
-
};
|
|
24764
|
-
}
|
|
24765
|
-
|
|
24766
|
-
const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
|
|
24767
|
-
$ZodType.init(inst, def);
|
|
24768
|
-
inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? string(inst._zod.bag);
|
|
24769
|
-
inst._zod.parse = (payload, _) => {
|
|
24770
|
-
if (def.coerce)
|
|
24771
|
-
try {
|
|
24772
|
-
payload.value = String(payload.value);
|
|
24773
|
-
}
|
|
24774
|
-
catch (_) { }
|
|
24775
|
-
if (typeof payload.value === "string")
|
|
24776
|
-
return payload;
|
|
24777
|
-
payload.issues.push({
|
|
24778
|
-
expected: "string",
|
|
24779
|
-
code: "invalid_type",
|
|
24780
|
-
input: payload.value,
|
|
24781
|
-
inst,
|
|
24782
|
-
});
|
|
24783
|
-
return payload;
|
|
24784
|
-
};
|
|
24785
|
-
});
|
|
24786
|
-
const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
|
|
24787
|
-
// check initialization must come first
|
|
24788
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
24789
|
-
$ZodString.init(inst, def);
|
|
24790
|
-
});
|
|
24791
|
-
const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def) => {
|
|
24792
|
-
def.pattern ?? (def.pattern = guid);
|
|
24793
|
-
$ZodStringFormat.init(inst, def);
|
|
24794
|
-
});
|
|
24795
|
-
const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
|
|
24796
|
-
if (def.version) {
|
|
24797
|
-
const versionMap = {
|
|
24798
|
-
v1: 1,
|
|
24799
|
-
v2: 2,
|
|
24800
|
-
v3: 3,
|
|
24801
|
-
v4: 4,
|
|
24802
|
-
v5: 5,
|
|
24803
|
-
v6: 6,
|
|
24804
|
-
v7: 7,
|
|
24805
|
-
v8: 8,
|
|
24806
|
-
};
|
|
24807
|
-
const v = versionMap[def.version];
|
|
24808
|
-
if (v === undefined)
|
|
24809
|
-
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
24810
|
-
def.pattern ?? (def.pattern = uuid(v));
|
|
24811
|
-
}
|
|
24812
|
-
else
|
|
24813
|
-
def.pattern ?? (def.pattern = uuid());
|
|
24814
|
-
$ZodStringFormat.init(inst, def);
|
|
24815
|
-
});
|
|
24816
|
-
const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
|
|
24817
|
-
def.pattern ?? (def.pattern = email);
|
|
24818
|
-
$ZodStringFormat.init(inst, def);
|
|
24819
|
-
});
|
|
24820
|
-
/** The `://` guard rejected the input before the URL constructor saw it. */
|
|
24821
|
-
const URL_BAD_FORMAT = 1;
|
|
24822
|
-
/** The URL constructor rejected the input. */
|
|
24823
|
-
const URL_UNPARSEABLE = 2;
|
|
24824
|
-
/** Parses a URL for `$ZodURL`, applying the one guard the URL constructor cannot express. Returns the parsed URL, or a code naming the stage that rejected it — the runtime needs that distinction to pick an issue note, and compiled code only needs to know it is not a URL. */
|
|
24825
|
-
function parseURLObject(trimmed, def) {
|
|
24826
|
-
// When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
|
24827
|
-
if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
|
|
24828
|
-
return URL_BAD_FORMAT;
|
|
24829
|
-
}
|
|
24830
|
-
try {
|
|
24831
|
-
// @ts-ignore
|
|
24832
|
-
return new URL(trimmed);
|
|
24833
|
-
}
|
|
24834
|
-
catch {
|
|
24835
|
-
return URL_UNPARSEABLE;
|
|
24533
|
+
catch {
|
|
24534
|
+
return URL_UNPARSEABLE;
|
|
24836
24535
|
}
|
|
24837
24536
|
}
|
|
24838
24537
|
const asciiTabOrNewline = /[\t\n\r]/g;
|
|
@@ -24854,7 +24553,7 @@ const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
|
|
|
24854
24553
|
try {
|
|
24855
24554
|
// Trim whitespace from input
|
|
24856
24555
|
const trimmed = payload.value.trim();
|
|
24857
|
-
const url =
|
|
24556
|
+
const url = validateURL(trimmed, def);
|
|
24858
24557
|
if (url === URL_BAD_FORMAT) {
|
|
24859
24558
|
payload.issues.push({
|
|
24860
24559
|
code: "invalid_format",
|
|
@@ -24876,6 +24575,10 @@ const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
|
|
|
24876
24575
|
});
|
|
24877
24576
|
return;
|
|
24878
24577
|
}
|
|
24578
|
+
if (url === true) {
|
|
24579
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
24580
|
+
return;
|
|
24581
|
+
}
|
|
24879
24582
|
if (def.hostname && !urlHostnameOk(url, def.hostname)) {
|
|
24880
24583
|
payload.issues.push({
|
|
24881
24584
|
code: "invalid_format",
|
|
@@ -24951,13 +24654,6 @@ const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
|
|
|
24951
24654
|
const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
|
|
24952
24655
|
def.pattern ?? (def.pattern = datetime(def));
|
|
24953
24656
|
$ZodStringFormat.init(inst, def);
|
|
24954
|
-
// these two drop the offset or seconds `date-time` requires — on the bag not the def, since `z.string().check(...)` lands the format on a different schema
|
|
24955
|
-
if (def.local || def.precision === -1) {
|
|
24956
|
-
inst._zod.bag.laxFormat = true;
|
|
24957
|
-
inst._zod.onattach.push((s) => {
|
|
24958
|
-
s._zod.bag.laxFormat = true;
|
|
24959
|
-
});
|
|
24960
|
-
}
|
|
24961
24657
|
});
|
|
24962
24658
|
const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
|
|
24963
24659
|
def.pattern ?? (def.pattern = date);
|
|
@@ -24974,26 +24670,17 @@ const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def
|
|
|
24974
24670
|
const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
|
|
24975
24671
|
def.pattern ?? (def.pattern = ipv4);
|
|
24976
24672
|
$ZodStringFormat.init(inst, def);
|
|
24977
|
-
inst._zod.bag.format = `ipv4`;
|
|
24978
24673
|
});
|
|
24979
24674
|
/** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
|
|
24980
24675
|
const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
24981
24676
|
function isValidIPv6(value) {
|
|
24982
24677
|
if (!ipv6Alphabet.test(value))
|
|
24983
24678
|
return false;
|
|
24984
|
-
|
|
24985
|
-
// @ts-ignore
|
|
24986
|
-
new URL(`http://[${value}]`);
|
|
24987
|
-
return true;
|
|
24988
|
-
}
|
|
24989
|
-
catch {
|
|
24990
|
-
return false;
|
|
24991
|
-
}
|
|
24679
|
+
return canParseURL(`http://[${value}]`);
|
|
24992
24680
|
}
|
|
24993
24681
|
const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
|
|
24994
24682
|
def.pattern ?? (def.pattern = ipv6);
|
|
24995
24683
|
$ZodStringFormat.init(inst, def);
|
|
24996
|
-
inst._zod.bag.format = `ipv6`;
|
|
24997
24684
|
inst._zod.check = (payload) => {
|
|
24998
24685
|
if (!isValidIPv6(payload.value)) {
|
|
24999
24686
|
payload.issues.push({
|
|
@@ -25009,7 +24696,6 @@ const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
|
|
|
25009
24696
|
const $ZodMAC = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("$ZodMAC", (inst, def) => {
|
|
25010
24697
|
def.pattern ?? (def.pattern = regexes.mac(def.delimiter));
|
|
25011
24698
|
$ZodStringFormat.init(inst, def);
|
|
25012
|
-
inst._zod.bag.format = `mac`;
|
|
25013
24699
|
})));
|
|
25014
24700
|
const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
25015
24701
|
def.pattern ?? (def.pattern = cidrv4);
|
|
@@ -25062,10 +24748,11 @@ function isValidBase64(data) {
|
|
|
25062
24748
|
return false;
|
|
25063
24749
|
}
|
|
25064
24750
|
}
|
|
24751
|
+
// lax on purpose: the quantified regexes.base64 overflows the regex stack on multi-MB input and its leading ^$| alternation leaks through template-literal composition; isValidBase64 enforces length and padding
|
|
24752
|
+
const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
25065
24753
|
const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
|
|
25066
|
-
def.pattern ?? (def.pattern =
|
|
24754
|
+
def.pattern ?? (def.pattern = base64Charset);
|
|
25067
24755
|
$ZodStringFormat.init(inst, def);
|
|
25068
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
25069
24756
|
inst._zod.check = (payload) => {
|
|
25070
24757
|
if (isValidBase64(payload.value))
|
|
25071
24758
|
return;
|
|
@@ -25078,18 +24765,19 @@ const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
|
|
|
25078
24765
|
});
|
|
25079
24766
|
};
|
|
25080
24767
|
});
|
|
25081
|
-
//////////////////////////////
|
|
24768
|
+
////////////////////////////// ZodBase64URL //////////////////////////////
|
|
24769
|
+
// lax on purpose: the quantified regexes.base64url overflows the regex stack on multi-MB input; isValidBase64 enforces length on the padded string
|
|
24770
|
+
const base64urlCharset = /^[A-Za-z0-9_-]*$/;
|
|
25082
24771
|
function isValidBase64URL(data) {
|
|
25083
|
-
if (!
|
|
24772
|
+
if (!base64urlCharset.test(data))
|
|
25084
24773
|
return false;
|
|
25085
24774
|
const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
|
|
25086
24775
|
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
|
25087
24776
|
return isValidBase64(padded);
|
|
25088
24777
|
}
|
|
25089
24778
|
const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
|
|
25090
|
-
def.pattern ?? (def.pattern =
|
|
24779
|
+
def.pattern ?? (def.pattern = base64urlCharset);
|
|
25091
24780
|
$ZodStringFormat.init(inst, def);
|
|
25092
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
25093
24781
|
inst._zod.check = (payload) => {
|
|
25094
24782
|
if (isValidBase64URL(payload.value))
|
|
25095
24783
|
return;
|
|
@@ -25114,7 +24802,7 @@ function isLuhnAlgo(digits) {
|
|
|
25114
24802
|
let bit = 1;
|
|
25115
24803
|
let sum = 0;
|
|
25116
24804
|
while (length) {
|
|
25117
|
-
const value =
|
|
24805
|
+
const value = digits.charCodeAt(--length) - 48;
|
|
25118
24806
|
bit ^= 1;
|
|
25119
24807
|
sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value] : value;
|
|
25120
24808
|
}
|
|
@@ -25141,6 +24829,42 @@ const $ZodCreditCard = /*@__PURE__*/ (/* unused pure expression or super */ null
|
|
|
25141
24829
|
});
|
|
25142
24830
|
};
|
|
25143
24831
|
})));
|
|
24832
|
+
////////////////////////////// ZodIBAN //////////////////////////////
|
|
24833
|
+
// iso 7064 mod 97-10 checksum without BigInt
|
|
24834
|
+
function isIso7064Mod97(iban) {
|
|
24835
|
+
let remainder = 0;
|
|
24836
|
+
const len = iban.length;
|
|
24837
|
+
for (let i = 4; i < len; i++) {
|
|
24838
|
+
const code = iban.charCodeAt(i);
|
|
24839
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
24840
|
+
}
|
|
24841
|
+
for (let i = 0; i < 4; i++) {
|
|
24842
|
+
const code = iban.charCodeAt(i);
|
|
24843
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
24844
|
+
}
|
|
24845
|
+
return remainder === 1;
|
|
24846
|
+
}
|
|
24847
|
+
function isValidIBAN(input) {
|
|
24848
|
+
if (!regexes.iban.test(input))
|
|
24849
|
+
return false;
|
|
24850
|
+
return isIso7064Mod97(input);
|
|
24851
|
+
}
|
|
24852
|
+
const $ZodIBAN = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("$ZodIBAN", (inst, def) => {
|
|
24853
|
+
// shape only — checksum is not expressible as a pattern
|
|
24854
|
+
def.pattern ?? (def.pattern = regexes.iban);
|
|
24855
|
+
$ZodStringFormat.init(inst, def);
|
|
24856
|
+
inst._zod.check = (payload) => {
|
|
24857
|
+
if (isValidIBAN(payload.value))
|
|
24858
|
+
return;
|
|
24859
|
+
payload.issues.push({
|
|
24860
|
+
code: "invalid_format",
|
|
24861
|
+
format: "iban",
|
|
24862
|
+
input: payload.value,
|
|
24863
|
+
inst,
|
|
24864
|
+
continue: !def.abort,
|
|
24865
|
+
});
|
|
24866
|
+
};
|
|
24867
|
+
})));
|
|
25144
24868
|
////////////////////////////// ZodJWT //////////////////////////////
|
|
25145
24869
|
function isValidJWT(token, algorithm = null) {
|
|
25146
24870
|
try {
|
|
@@ -25194,7 +24918,7 @@ const $ZodCustomStringFormat = /*@__PURE__*/ (/* unused pure expression or super
|
|
|
25194
24918
|
})));
|
|
25195
24919
|
const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
|
|
25196
24920
|
$ZodType.init(inst, def);
|
|
25197
|
-
inst._zod.pattern =
|
|
24921
|
+
inst._zod.pattern = number;
|
|
25198
24922
|
inst._zod.parse = (payload, _ctx) => {
|
|
25199
24923
|
if (def.coerce)
|
|
25200
24924
|
try {
|
|
@@ -25379,6 +25103,33 @@ const $ZodDate = /*@__PURE__*/ (/* unused pure expression or super */ null && (c
|
|
|
25379
25103
|
return payload;
|
|
25380
25104
|
};
|
|
25381
25105
|
})));
|
|
25106
|
+
// an oversized container fails its leading size checks before any element is parsed
|
|
25107
|
+
function capSize(inst, size) {
|
|
25108
|
+
const caps = sizeCaps(inst._zod.def.checks);
|
|
25109
|
+
if (!caps.length)
|
|
25110
|
+
return;
|
|
25111
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
25112
|
+
const parse = inst._zod.parse;
|
|
25113
|
+
inst._zod.parse = (payload, ctx) => {
|
|
25114
|
+
const n = size(payload.value);
|
|
25115
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
25116
|
+
for (const [max, ch] of sizeCaps(inst._zod.def.checks)) {
|
|
25117
|
+
if (n > max && ch._zod.def.when(payload)) {
|
|
25118
|
+
const start = payload.issues.length;
|
|
25119
|
+
ch._zod.check(payload);
|
|
25120
|
+
// the value is still the raw input, so no later check may read it
|
|
25121
|
+
payload.issues[start].continue = false;
|
|
25122
|
+
attachSchema(payload.issues, start, inst);
|
|
25123
|
+
return payload;
|
|
25124
|
+
}
|
|
25125
|
+
}
|
|
25126
|
+
}
|
|
25127
|
+
return parse(payload, ctx);
|
|
25128
|
+
};
|
|
25129
|
+
}
|
|
25130
|
+
const arraySize = (input) => (Array.isArray(input) ? input.length : -1);
|
|
25131
|
+
const mapSize = (input) => (input instanceof Map ? input.size : -1);
|
|
25132
|
+
const setSize = (input) => (input instanceof Set ? input.size : -1);
|
|
25382
25133
|
function handleArrayResult(result, final, index) {
|
|
25383
25134
|
if (result.issues.length) {
|
|
25384
25135
|
final.issues.push(...prefixIssues(index, result.issues));
|
|
@@ -25402,6 +25153,7 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
|
25402
25153
|
}
|
|
25403
25154
|
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
25404
25155
|
const proms = [];
|
|
25156
|
+
const abortEarly = ctx?.abortEarly;
|
|
25405
25157
|
for (let i = 0; i < input.length; i++) {
|
|
25406
25158
|
const item = input[i];
|
|
25407
25159
|
const result = def.element._zod.run({
|
|
@@ -25413,6 +25165,9 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
|
25413
25165
|
}
|
|
25414
25166
|
else {
|
|
25415
25167
|
handleArrayResult(result, payload, i);
|
|
25168
|
+
// the element's payload is authoritative here, since handleArrayResult forwards every issue; an object's is not, because it drops a failed absent optional
|
|
25169
|
+
if (abortEarly && result.issues.length !== 0 && aborted(result))
|
|
25170
|
+
break;
|
|
25416
25171
|
}
|
|
25417
25172
|
}
|
|
25418
25173
|
if (proms.length) {
|
|
@@ -25420,6 +25175,7 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
|
25420
25175
|
}
|
|
25421
25176
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
25422
25177
|
};
|
|
25178
|
+
capSize(inst, arraySize);
|
|
25423
25179
|
});
|
|
25424
25180
|
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
25425
25181
|
const isPresent = key in input;
|
|
@@ -25447,7 +25203,7 @@ function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
|
25447
25203
|
return;
|
|
25448
25204
|
}
|
|
25449
25205
|
if (result.value === undefined) {
|
|
25450
|
-
if (isPresent) {
|
|
25206
|
+
if (isPresent || (optin === "defaulted" && !isOptionalOut)) {
|
|
25451
25207
|
final.value[key] = undefined;
|
|
25452
25208
|
}
|
|
25453
25209
|
}
|
|
@@ -25479,14 +25235,21 @@ function normalizeDef(def) {
|
|
|
25479
25235
|
optionalKeys: new Set(okeys),
|
|
25480
25236
|
};
|
|
25481
25237
|
}
|
|
25482
|
-
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
25238
|
+
function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
|
|
25483
25239
|
const unrecognized = [];
|
|
25484
25240
|
const keySet = def.keySet;
|
|
25485
25241
|
const _catchall = def.catchall._zod;
|
|
25486
25242
|
const t = _catchall.def.type;
|
|
25487
25243
|
const optin = _catchall.optin;
|
|
25488
25244
|
const optout = _catchall.optout;
|
|
25245
|
+
// starts at 0, not the current length: the shape phase already ran and may have aborted
|
|
25246
|
+
let seen = 0;
|
|
25489
25247
|
for (const key in input) {
|
|
25248
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
25249
|
+
if (aborted(payload, seen))
|
|
25250
|
+
break;
|
|
25251
|
+
seen = payload.issues.length;
|
|
25252
|
+
}
|
|
25490
25253
|
// Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
|
|
25491
25254
|
if (keySet.has(key))
|
|
25492
25255
|
continue;
|
|
@@ -25524,26 +25287,22 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
25524
25287
|
return payload;
|
|
25525
25288
|
});
|
|
25526
25289
|
}
|
|
25527
|
-
// Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it. Keyed by def, so a def rebuilt by a builder is simply absent rather than inheriting the source's. Read its keys with `Object.keys`, which does not invoke them — that is what lets a discriminated union check its discriminator without resolving an option whose getters reference the union being constructed.
|
|
25528
|
-
const propShapes = new WeakMap();
|
|
25529
25290
|
const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
25530
25291
|
// requires cast because technically $ZodObject doesn't extend
|
|
25531
25292
|
$ZodType.init(inst, def);
|
|
25532
|
-
// const sh = def.shape;
|
|
25533
25293
|
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
25534
|
-
|
|
25535
|
-
|
|
25536
|
-
|
|
25537
|
-
|
|
25538
|
-
|
|
25539
|
-
|
|
25540
|
-
|
|
25541
|
-
|
|
25542
|
-
|
|
25543
|
-
|
|
25544
|
-
|
|
25545
|
-
|
|
25546
|
-
});
|
|
25294
|
+
// a cloned def carries its source's accessor, which knows the shape it answers from; adopting that keeps the clone's keys readable without running it
|
|
25295
|
+
const sh = desc?.get ? desc.get.raw : (def.shape ?? {});
|
|
25296
|
+
if (sh) {
|
|
25297
|
+
// Freezes the shape on first read, so its getters resolve once and every later read sees the same schemas.
|
|
25298
|
+
const get = () => {
|
|
25299
|
+
const newSh = { ...sh };
|
|
25300
|
+
Object.defineProperty(def, "shape", { value: newSh });
|
|
25301
|
+
get.raw = newSh;
|
|
25302
|
+
return newSh;
|
|
25303
|
+
};
|
|
25304
|
+
get.raw = sh;
|
|
25305
|
+
Object.defineProperty(def, "shape", { get });
|
|
25547
25306
|
}
|
|
25548
25307
|
const _normalized = util_cached(() => normalizeDef(def));
|
|
25549
25308
|
defineLazyInternal(inst, "propValues", (zod) => {
|
|
@@ -25584,7 +25343,14 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
|
25584
25343
|
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
25585
25344
|
const proms = [];
|
|
25586
25345
|
const shape = value.shape;
|
|
25346
|
+
const abortEarly = ctx?.abortEarly;
|
|
25347
|
+
let seen = payload.issues.length;
|
|
25587
25348
|
for (const key of value.allKeys) {
|
|
25349
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
25350
|
+
if (aborted(payload, seen))
|
|
25351
|
+
break;
|
|
25352
|
+
seen = payload.issues.length;
|
|
25353
|
+
}
|
|
25588
25354
|
if (key === "__proto__")
|
|
25589
25355
|
continue;
|
|
25590
25356
|
const el = shape[key];
|
|
@@ -25601,7 +25367,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
|
25601
25367
|
if (!catchall) {
|
|
25602
25368
|
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
25603
25369
|
}
|
|
25604
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
25370
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
|
|
25605
25371
|
};
|
|
25606
25372
|
});
|
|
25607
25373
|
const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
@@ -25616,12 +25382,18 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
25616
25382
|
// a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope
|
|
25617
25383
|
const doc = new Doc(["payload", "ctx"], { shape, inst, memo, syms });
|
|
25618
25384
|
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
25619
|
-
//
|
|
25385
|
+
// prefixes in place, like util.prefixIssues. newResult must land before the early return: a catchall runs after this and would otherwise write onto the caller's input
|
|
25620
25386
|
const prefixStr = (id, k) => `
|
|
25387
|
+
let ${id}_ab = false;
|
|
25621
25388
|
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
25622
25389
|
const iss = ${id}.issues[i];
|
|
25623
25390
|
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
25624
25391
|
payload.issues.push(iss);
|
|
25392
|
+
if (iss.continue !== true) ${id}_ab = true;
|
|
25393
|
+
}
|
|
25394
|
+
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
25395
|
+
payload.value = newResult;
|
|
25396
|
+
return payload;
|
|
25625
25397
|
}`;
|
|
25626
25398
|
doc.write(`const input = payload.value;`);
|
|
25627
25399
|
const ids = Object.create(null);
|
|
@@ -25670,6 +25442,10 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
25670
25442
|
input: undefined,
|
|
25671
25443
|
path: [${k}]
|
|
25672
25444
|
});
|
|
25445
|
+
if (ctx && ctx.abortEarly) {
|
|
25446
|
+
payload.value = newResult;
|
|
25447
|
+
return payload;
|
|
25448
|
+
}
|
|
25673
25449
|
}
|
|
25674
25450
|
|
|
25675
25451
|
if (${id}_present) {
|
|
@@ -25682,16 +25458,17 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
25682
25458
|
doc.write(`
|
|
25683
25459
|
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
25684
25460
|
}
|
|
25685
|
-
|
|
25686
|
-
|
|
25687
|
-
|
|
25688
|
-
|
|
25689
|
-
|
|
25690
|
-
|
|
25461
|
+
`);
|
|
25462
|
+
if (optin === "defaulted") {
|
|
25463
|
+
doc.write(`newResult[${k}] = ${id}.value;`);
|
|
25464
|
+
}
|
|
25465
|
+
else {
|
|
25466
|
+
doc.write(`
|
|
25467
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
25691
25468
|
newResult[${k}] = ${id}.value;
|
|
25692
25469
|
}
|
|
25693
|
-
|
|
25694
25470
|
`);
|
|
25471
|
+
}
|
|
25695
25472
|
}
|
|
25696
25473
|
}
|
|
25697
25474
|
doc.write(`payload.value = newResult;`);
|
|
@@ -25725,7 +25502,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
25725
25502
|
payload = fastpass(payload, ctx);
|
|
25726
25503
|
if (!catchall)
|
|
25727
25504
|
return payload;
|
|
25728
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
25505
|
+
return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
|
|
25729
25506
|
}
|
|
25730
25507
|
return superParse(payload, ctx);
|
|
25731
25508
|
};
|
|
@@ -25862,22 +25639,38 @@ const $ZodXor = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
|
|
|
25862
25639
|
});
|
|
25863
25640
|
};
|
|
25864
25641
|
})));
|
|
25865
|
-
/** Returns the option
|
|
25642
|
+
/** Returns the option whose discriminator claims `value`, or throws if ambiguous. */
|
|
25866
25643
|
function getDiscriminatedOption(union, value) {
|
|
25867
25644
|
const internals = union._zod;
|
|
25868
25645
|
let map = internals.bag.optionsMap;
|
|
25869
25646
|
if (!map) {
|
|
25870
|
-
map =
|
|
25871
|
-
const { options, discriminator } = internals.def;
|
|
25872
|
-
for (const option of options) {
|
|
25873
|
-
// First declaration wins, matching the order the parse path resolves a duplicate in.
|
|
25874
|
-
for (const v of option._zod.propValues?.[discriminator] ?? [])
|
|
25875
|
-
if (!map.has(v))
|
|
25876
|
-
map.set(v, option);
|
|
25877
|
-
}
|
|
25647
|
+
map = discriminatorMap(internals.def);
|
|
25878
25648
|
internals.bag.optionsMap = map;
|
|
25879
25649
|
}
|
|
25880
|
-
|
|
25650
|
+
const option = map.get(value);
|
|
25651
|
+
if (option === null)
|
|
25652
|
+
throw new Error(`Ambiguous discriminator value "${String(value)}"`);
|
|
25653
|
+
return option;
|
|
25654
|
+
}
|
|
25655
|
+
function discriminatorMap(def) {
|
|
25656
|
+
const map = new Map();
|
|
25657
|
+
for (const option of def.options) {
|
|
25658
|
+
const values = option._zod.propValues?.[def.discriminator];
|
|
25659
|
+
if (!values || values.size === 0)
|
|
25660
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
25661
|
+
for (const value of values) {
|
|
25662
|
+
if (map.has(value)) {
|
|
25663
|
+
if (value !== undefined)
|
|
25664
|
+
throw new Error(`Duplicate discriminator value "${String(value)}"`);
|
|
25665
|
+
// keep the collision marked so a later member cannot reclaim it
|
|
25666
|
+
map.set(value, null);
|
|
25667
|
+
}
|
|
25668
|
+
else {
|
|
25669
|
+
map.set(value, option);
|
|
25670
|
+
}
|
|
25671
|
+
}
|
|
25672
|
+
}
|
|
25673
|
+
return map;
|
|
25881
25674
|
}
|
|
25882
25675
|
const $ZodDiscriminatedUnion =
|
|
25883
25676
|
/*@__PURE__*/
|
|
@@ -25887,10 +25680,13 @@ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
25887
25680
|
const _super = inst._zod.parse;
|
|
25888
25681
|
defineLazyInternal(inst, "propValues", (zod) => {
|
|
25889
25682
|
const propValues = {};
|
|
25683
|
+
let undefinedCount = 0;
|
|
25890
25684
|
for (const option of zod.def.options) {
|
|
25891
25685
|
const pv = option._zod.propValues;
|
|
25892
25686
|
if (!pv || Object.keys(pv).length === 0)
|
|
25893
25687
|
throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
25688
|
+
if (pv[zod.def.discriminator]?.has(undefined))
|
|
25689
|
+
undefinedCount++;
|
|
25894
25690
|
for (const [k, v] of Object.entries(pv)) {
|
|
25895
25691
|
if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
|
|
25896
25692
|
util_assignProp(propValues, k, new Set());
|
|
@@ -25900,31 +25696,18 @@ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
25900
25696
|
}
|
|
25901
25697
|
}
|
|
25902
25698
|
}
|
|
25699
|
+
if (!zod.def.unionFallback && undefinedCount > 1)
|
|
25700
|
+
propValues[zod.def.discriminator]?.delete(undefined);
|
|
25903
25701
|
return propValues;
|
|
25904
25702
|
});
|
|
25905
|
-
// Checked now rather than in the lookup map below, so an option that lacks the discriminator fails at the `discriminatedUnion` call instead of on the first object parsed. Options whose shape cannot be enumerated without resolving it — pipes
|
|
25703
|
+
// Checked now rather than in the lookup map below, so an option that lacks the discriminator fails at the `discriminatedUnion` call instead of on the first object parsed. Options whose shape cannot be enumerated without resolving it — pipes and lazies — are left to the map.
|
|
25906
25704
|
def.options.forEach((option, i) => {
|
|
25907
|
-
const propShape =
|
|
25705
|
+
const propShape = rawShape(option._zod.def);
|
|
25908
25706
|
if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
|
|
25909
25707
|
throw new Error(`Invalid discriminated union option at index "${i}"`);
|
|
25910
25708
|
}
|
|
25911
25709
|
});
|
|
25912
|
-
const disc = util_cached(() =>
|
|
25913
|
-
const opts = def.options;
|
|
25914
|
-
const map = new Map();
|
|
25915
|
-
for (const o of opts) {
|
|
25916
|
-
const values = o._zod.propValues?.[def.discriminator];
|
|
25917
|
-
if (!values || values.size === 0)
|
|
25918
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
25919
|
-
for (const v of values) {
|
|
25920
|
-
if (map.has(v)) {
|
|
25921
|
-
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
25922
|
-
}
|
|
25923
|
-
map.set(v, o);
|
|
25924
|
-
}
|
|
25925
|
-
}
|
|
25926
|
-
return map;
|
|
25927
|
-
});
|
|
25710
|
+
const disc = util_cached(() => discriminatorMap(def));
|
|
25928
25711
|
inst._zod.parse = (payload, ctx) => {
|
|
25929
25712
|
const input = payload.value;
|
|
25930
25713
|
if (!util_isObject(input)) {
|
|
@@ -25936,8 +25719,10 @@ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
25936
25719
|
});
|
|
25937
25720
|
return payload;
|
|
25938
25721
|
}
|
|
25939
|
-
const
|
|
25940
|
-
|
|
25722
|
+
const value = input?.[def.discriminator];
|
|
25723
|
+
const opt = disc.value.get(value);
|
|
25724
|
+
// forward metadata cannot choose an encoder for an absent tag
|
|
25725
|
+
if (opt && (value !== undefined || ctx.direction !== "backward")) {
|
|
25941
25726
|
return opt._zod.run(payload, ctx);
|
|
25942
25727
|
}
|
|
25943
25728
|
// Fall back to union matching when the fast discriminator path fails:
|
|
@@ -25952,7 +25737,7 @@ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
25952
25737
|
errors: [],
|
|
25953
25738
|
note: "No matching discriminator",
|
|
25954
25739
|
discriminator: def.discriminator,
|
|
25955
|
-
options: Array.from(disc.value.keys()),
|
|
25740
|
+
options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
|
|
25956
25741
|
input,
|
|
25957
25742
|
path: [def.discriminator],
|
|
25958
25743
|
inst,
|
|
@@ -26125,6 +25910,9 @@ const $ZodTuple = /*@__PURE__*/ (/* unused pure expression or super */ null && (
|
|
|
26125
25910
|
}
|
|
26126
25911
|
// Run every item in parallel, collecting results into an indexed array. The post-processing in `handleTupleResults` walks them in order so it can decide whether an absent optional-output error can truncate the tail or must be reported to preserve required output.
|
|
26127
25912
|
const itemResults = new Array(items.length);
|
|
25913
|
+
// only tracked when there is a rest loop to skip
|
|
25914
|
+
const abortEarly = def.rest ? ctx?.abortEarly : undefined;
|
|
25915
|
+
let itemAborted = false;
|
|
26128
25916
|
for (let i = 0; i < items.length; i++) {
|
|
26129
25917
|
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
|
26130
25918
|
if (r instanceof Promise) {
|
|
@@ -26134,12 +25922,21 @@ const $ZodTuple = /*@__PURE__*/ (/* unused pure expression or super */ null && (
|
|
|
26134
25922
|
}
|
|
26135
25923
|
else {
|
|
26136
25924
|
itemResults[i] = r;
|
|
25925
|
+
if (abortEarly && !itemAborted && r.issues.length)
|
|
25926
|
+
itemAborted = util.aborted(r);
|
|
26137
25927
|
}
|
|
26138
25928
|
}
|
|
26139
|
-
|
|
25929
|
+
// sound because rest is non-empty exactly when every fixed index is present, the one case handleTupleResults cannot discard an item's issues
|
|
25930
|
+
if (def.rest && !itemAborted) {
|
|
26140
25931
|
let i = items.length - 1;
|
|
26141
25932
|
const rest = input.slice(items.length);
|
|
25933
|
+
let seen = payload.issues.length;
|
|
26142
25934
|
for (const el of rest) {
|
|
25935
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
25936
|
+
if (util.aborted(payload, seen))
|
|
25937
|
+
break;
|
|
25938
|
+
seen = payload.issues.length;
|
|
25939
|
+
}
|
|
26143
25940
|
i++;
|
|
26144
25941
|
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
|
26145
25942
|
if (result instanceof Promise) {
|
|
@@ -26221,6 +26018,7 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
26221
26018
|
});
|
|
26222
26019
|
return payload;
|
|
26223
26020
|
}
|
|
26021
|
+
// no guard in either loop below: a record's invalid_key aborts but an enclosing intersection can reconcile it, so a stopped loop hides keys the sibling does not own and the intersection then rejects nothing
|
|
26224
26022
|
const proms = [];
|
|
26225
26023
|
const values = def.keyType._zod.values;
|
|
26226
26024
|
if (values && !def.partial) {
|
|
@@ -26392,7 +26190,14 @@ const $ZodMap = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
|
|
|
26392
26190
|
}
|
|
26393
26191
|
const proms = [];
|
|
26394
26192
|
payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
|
|
26193
|
+
const abortEarly = ctx?.abortEarly;
|
|
26194
|
+
let seen = payload.issues.length;
|
|
26395
26195
|
for (const [key, value] of input) {
|
|
26196
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
26197
|
+
if (util.aborted(payload, seen))
|
|
26198
|
+
break;
|
|
26199
|
+
seen = payload.issues.length;
|
|
26200
|
+
}
|
|
26396
26201
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
26397
26202
|
const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
|
|
26398
26203
|
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
|
@@ -26408,6 +26213,7 @@ const $ZodMap = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
|
|
|
26408
26213
|
return Promise.all(proms).then(() => payload);
|
|
26409
26214
|
return payload;
|
|
26410
26215
|
};
|
|
26216
|
+
capSize(inst, mapSize);
|
|
26411
26217
|
})));
|
|
26412
26218
|
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
26413
26219
|
if (keyResult.issues.length) {
|
|
@@ -26458,7 +26264,14 @@ const $ZodSet = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
|
|
|
26458
26264
|
}
|
|
26459
26265
|
const proms = [];
|
|
26460
26266
|
payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
|
|
26267
|
+
const abortEarly = ctx?.abortEarly;
|
|
26268
|
+
let seen = payload.issues.length;
|
|
26461
26269
|
for (const item of input) {
|
|
26270
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
26271
|
+
if (util.aborted(payload, seen))
|
|
26272
|
+
break;
|
|
26273
|
+
seen = payload.issues.length;
|
|
26274
|
+
}
|
|
26462
26275
|
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
|
26463
26276
|
if (result instanceof Promise) {
|
|
26464
26277
|
proms.push(result.then((result) => handleSetResult(result, payload)));
|
|
@@ -26470,6 +26283,7 @@ const $ZodSet = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
|
|
|
26470
26283
|
return Promise.all(proms).then(() => payload);
|
|
26471
26284
|
return payload;
|
|
26472
26285
|
};
|
|
26286
|
+
capSize(inst, setSize);
|
|
26473
26287
|
})));
|
|
26474
26288
|
function handleSetResult(result, final) {
|
|
26475
26289
|
if (result.issues.length) {
|
|
@@ -26482,9 +26296,11 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
|
26482
26296
|
const values = getEnumValues(def.entries);
|
|
26483
26297
|
const valuesSet = new Set(values);
|
|
26484
26298
|
inst._zod.values = valuesSet;
|
|
26485
|
-
|
|
26486
|
-
|
|
26487
|
-
|
|
26299
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
26300
|
+
const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
|
|
26301
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
26302
|
+
return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
|
|
26303
|
+
});
|
|
26488
26304
|
inst._zod.parse = (payload, _ctx) => {
|
|
26489
26305
|
const input = payload.value;
|
|
26490
26306
|
if (valuesSet.has(input)) {
|
|
@@ -26503,12 +26319,15 @@ const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
26503
26319
|
$ZodType.init(inst, def);
|
|
26504
26320
|
const values = new Set(def.values);
|
|
26505
26321
|
inst._zod.values = values;
|
|
26506
|
-
|
|
26507
|
-
|
|
26508
|
-
|
|
26509
|
-
|
|
26510
|
-
|
|
26511
|
-
|
|
26322
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
26323
|
+
const vals = zod.def.values;
|
|
26324
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
26325
|
+
return new RegExp(vals.length
|
|
26326
|
+
? `^(${vals
|
|
26327
|
+
.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o))
|
|
26328
|
+
.join("|")})$`
|
|
26329
|
+
: "^[^\\s\\S]$");
|
|
26330
|
+
});
|
|
26512
26331
|
inst._zod.parse = (payload, _ctx) => {
|
|
26513
26332
|
const input = payload.value;
|
|
26514
26333
|
if (values.has(input)) {
|
|
@@ -26872,22 +26691,67 @@ function handleReadonlyResult(payload) {
|
|
|
26872
26691
|
payload.value = Object.freeze(payload.value);
|
|
26873
26692
|
return payload;
|
|
26874
26693
|
}
|
|
26694
|
+
// a leaf's pattern source with its own checks folded in: the last pattern-carrying check wins, else length bounds narrow the catch-all, else an integer format narrows the number form. the fold lives here instead of on `_zod.pattern` so a bundle without template literals never pays for it
|
|
26695
|
+
function leafPattern(schema) {
|
|
26696
|
+
const def = schema._zod.def;
|
|
26697
|
+
let pattern = def.pattern;
|
|
26698
|
+
let isInt = !!def.format?.includes("int");
|
|
26699
|
+
let minimum;
|
|
26700
|
+
let maximum;
|
|
26701
|
+
for (const ch of def.checks ?? []) {
|
|
26702
|
+
const d = ch._zod.def;
|
|
26703
|
+
if (d.pattern)
|
|
26704
|
+
pattern = d.pattern;
|
|
26705
|
+
isInt || (isInt = !!d.format?.includes("int"));
|
|
26706
|
+
const lo = d.minimum ?? d.length;
|
|
26707
|
+
const hi = d.maximum ?? d.length;
|
|
26708
|
+
if (lo !== undefined && (minimum === undefined || lo > minimum))
|
|
26709
|
+
minimum = lo;
|
|
26710
|
+
if (hi !== undefined && (maximum === undefined || hi < maximum))
|
|
26711
|
+
maximum = hi;
|
|
26712
|
+
}
|
|
26713
|
+
if (pattern)
|
|
26714
|
+
return pattern.source;
|
|
26715
|
+
// an empty range matches nothing at runtime, and `{8,5}` is not a legal quantifier
|
|
26716
|
+
if (minimum !== undefined && maximum !== undefined && minimum > maximum)
|
|
26717
|
+
return "(?!)";
|
|
26718
|
+
if (minimum !== undefined || maximum !== undefined)
|
|
26719
|
+
return regexes.string({ minimum, maximum }).source;
|
|
26720
|
+
const own = schema._zod.pattern;
|
|
26721
|
+
return (isInt && own === regexes.number ? regexes.integer : own)?.source;
|
|
26722
|
+
}
|
|
26723
|
+
// a part's pattern source. a wrapper's pattern embeds its inner pattern's source verbatim, so the folded form is substituted in place without knowing the wrapper's own composition; a union's options are joined the way the union builds its own pattern
|
|
26724
|
+
function partPattern(schema) {
|
|
26725
|
+
const def = schema._zod.def;
|
|
26726
|
+
const own = schema._zod.pattern?.source;
|
|
26727
|
+
// lazy resolves its inner on the internals, not the def
|
|
26728
|
+
const inner = def.innerType ?? schema._zod.innerType;
|
|
26729
|
+
if (inner) {
|
|
26730
|
+
const before = inner._zod.pattern?.source;
|
|
26731
|
+
const after = partPattern(inner);
|
|
26732
|
+
if (own && before && after && after !== before) {
|
|
26733
|
+
return own.replace(util.cleanRegex(before), () => util.cleanRegex(after));
|
|
26734
|
+
}
|
|
26735
|
+
return own;
|
|
26736
|
+
}
|
|
26737
|
+
if (def.options) {
|
|
26738
|
+
const sources = def.options.map(partPattern);
|
|
26739
|
+
if (sources.every(Boolean))
|
|
26740
|
+
return `^(${sources.map((s) => util.cleanRegex(s)).join("|")})$`;
|
|
26741
|
+
}
|
|
26742
|
+
return leafPattern(schema);
|
|
26743
|
+
}
|
|
26875
26744
|
const $ZodTemplateLiteral = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("$ZodTemplateLiteral", (inst, def) => {
|
|
26876
26745
|
$ZodType.init(inst, def);
|
|
26877
26746
|
const regexParts = [];
|
|
26878
26747
|
for (const part of def.parts) {
|
|
26879
26748
|
if (typeof part === "object" && part !== null) {
|
|
26880
26749
|
// is Zod schema
|
|
26881
|
-
|
|
26882
|
-
|
|
26750
|
+
const source = partPattern(part);
|
|
26751
|
+
if (!source) {
|
|
26883
26752
|
throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
|
|
26884
26753
|
}
|
|
26885
|
-
|
|
26886
|
-
if (!source)
|
|
26887
|
-
throw new Error(`Invalid template literal part: ${part._zod.traits}`);
|
|
26888
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
26889
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
26890
|
-
regexParts.push(source.slice(start, end));
|
|
26754
|
+
regexParts.push(util.cleanRegex(source));
|
|
26891
26755
|
}
|
|
26892
26756
|
else if (part === null || util.primitiveTypes.has(typeof part)) {
|
|
26893
26757
|
regexParts.push(util.escapeRegex(`${part}`));
|
|
@@ -27116,20 +26980,18 @@ const globalRegistry = globalThis.__zod_globalRegistry;
|
|
|
27116
26980
|
|
|
27117
26981
|
|
|
27118
26982
|
|
|
26983
|
+
function snapshotChecks(def) {
|
|
26984
|
+
if (def.checks)
|
|
26985
|
+
def.checks = [...def.checks];
|
|
26986
|
+
return def;
|
|
26987
|
+
}
|
|
27119
26988
|
// @__NO_SIDE_EFFECTS__
|
|
27120
26989
|
function _string(Class, params) {
|
|
27121
|
-
return new Class({
|
|
27122
|
-
type: "string",
|
|
27123
|
-
...normalizeParams(params),
|
|
27124
|
-
});
|
|
26990
|
+
return new Class(snapshotChecks({ type: "string", ...normalizeParams(params) }));
|
|
27125
26991
|
}
|
|
27126
26992
|
// @__NO_SIDE_EFFECTS__
|
|
27127
26993
|
function _coercedString(Class, params) {
|
|
27128
|
-
return new Class({
|
|
27129
|
-
type: "string",
|
|
27130
|
-
coerce: true,
|
|
27131
|
-
...util.normalizeParams(params),
|
|
27132
|
-
});
|
|
26994
|
+
return new Class(snapshotChecks({ type: "string", coerce: true, ...util.normalizeParams(params) }));
|
|
27133
26995
|
}
|
|
27134
26996
|
// @__NO_SIDE_EFFECTS__
|
|
27135
26997
|
function _email(Class, params) {
|
|
@@ -27370,6 +27232,16 @@ function _creditCard(Class, params) {
|
|
|
27370
27232
|
});
|
|
27371
27233
|
}
|
|
27372
27234
|
// @__NO_SIDE_EFFECTS__
|
|
27235
|
+
function _iban(Class, params) {
|
|
27236
|
+
return new Class({
|
|
27237
|
+
type: "string",
|
|
27238
|
+
format: "iban",
|
|
27239
|
+
check: "string_format",
|
|
27240
|
+
abort: false,
|
|
27241
|
+
...util.normalizeParams(params),
|
|
27242
|
+
});
|
|
27243
|
+
}
|
|
27244
|
+
// @__NO_SIDE_EFFECTS__
|
|
27373
27245
|
function _jwt(Class, params) {
|
|
27374
27246
|
return new Class({
|
|
27375
27247
|
type: "string",
|
|
@@ -27428,20 +27300,11 @@ function _isoDuration(Class, params) {
|
|
|
27428
27300
|
}
|
|
27429
27301
|
// @__NO_SIDE_EFFECTS__
|
|
27430
27302
|
function _number(Class, params) {
|
|
27431
|
-
return new Class({
|
|
27432
|
-
type: "number",
|
|
27433
|
-
checks: [],
|
|
27434
|
-
...normalizeParams(params),
|
|
27435
|
-
});
|
|
27303
|
+
return new Class(snapshotChecks({ type: "number", checks: [], ...normalizeParams(params) }));
|
|
27436
27304
|
}
|
|
27437
27305
|
// @__NO_SIDE_EFFECTS__
|
|
27438
27306
|
function _coercedNumber(Class, params) {
|
|
27439
|
-
return new Class({
|
|
27440
|
-
type: "number",
|
|
27441
|
-
coerce: true,
|
|
27442
|
-
checks: [],
|
|
27443
|
-
...util.normalizeParams(params),
|
|
27444
|
-
});
|
|
27307
|
+
return new Class(snapshotChecks({ type: "number", coerce: true, checks: [], ...util.normalizeParams(params) }));
|
|
27445
27308
|
}
|
|
27446
27309
|
// @__NO_SIDE_EFFECTS__
|
|
27447
27310
|
function _int(Class, params) {
|
|
@@ -27788,8 +27651,12 @@ function _property(property, schema, params) {
|
|
|
27788
27651
|
});
|
|
27789
27652
|
}
|
|
27790
27653
|
// @__NO_SIDE_EFFECTS__
|
|
27791
|
-
function _properties(shape) {
|
|
27792
|
-
return
|
|
27654
|
+
function _properties(shape, params) {
|
|
27655
|
+
return new checks.$ZodCheckProperties({
|
|
27656
|
+
check: "properties",
|
|
27657
|
+
shape,
|
|
27658
|
+
...util.normalizeParams(params),
|
|
27659
|
+
});
|
|
27793
27660
|
}
|
|
27794
27661
|
// @__NO_SIDE_EFFECTS__
|
|
27795
27662
|
function _mime(types, params) {
|
|
@@ -28255,6 +28122,7 @@ function to_json_schema_initializeContext(params) {
|
|
|
28255
28122
|
cycles: params?.cycles ?? "ref",
|
|
28256
28123
|
reused: params?.reused ?? "inline",
|
|
28257
28124
|
intersections: [],
|
|
28125
|
+
deferred: [],
|
|
28258
28126
|
external: params?.external ?? undefined,
|
|
28259
28127
|
};
|
|
28260
28128
|
}
|
|
@@ -28274,7 +28142,8 @@ function to_json_schema_handleUnrepresentable(schema, ctx, json, params, message
|
|
|
28274
28142
|
Object.assign(json, result);
|
|
28275
28143
|
return true;
|
|
28276
28144
|
}
|
|
28277
|
-
|
|
28145
|
+
// never rename this back to `process`: bundler polyfills inject a top-level `const process` that a lexical declaration of the same name collides with (#6397)
|
|
28146
|
+
function to_json_schema_processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
28278
28147
|
var _a;
|
|
28279
28148
|
const def = schema._zod.def;
|
|
28280
28149
|
// check for schema in seens
|
|
@@ -28320,7 +28189,7 @@ function to_json_schema_process(schema, ctx, _params = { path: [], schemaPath: [
|
|
|
28320
28189
|
// Also set ref if processor didn't (for inheritance)
|
|
28321
28190
|
if (!result.ref)
|
|
28322
28191
|
result.ref = parent;
|
|
28323
|
-
|
|
28192
|
+
to_json_schema_processSchema(parent, ctx, params);
|
|
28324
28193
|
ctx.seen.get(parent).isParent = true;
|
|
28325
28194
|
}
|
|
28326
28195
|
}
|
|
@@ -28341,6 +28210,8 @@ function to_json_schema_process(schema, ctx, _params = { path: [], schemaPath: [
|
|
|
28341
28210
|
const _result = ctx.seen.get(schema);
|
|
28342
28211
|
return _result.schema;
|
|
28343
28212
|
}
|
|
28213
|
+
/** @deprecated Renamed to `processSchema`. An export alias declares no binding, so it is safe to keep. */
|
|
28214
|
+
|
|
28344
28215
|
// Escape a reference token for use in a JSON Pointer fragment (RFC 6901): `~` becomes `~0` and `/` becomes `~1`. The `~` replacement must run first.
|
|
28345
28216
|
function encodeJSONPointerSegment(segment) {
|
|
28346
28217
|
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
@@ -28457,8 +28328,6 @@ function to_json_schema_extractDefs(ctx, schema
|
|
|
28457
28328
|
if (seen.count > 1) {
|
|
28458
28329
|
if (ctx.reused === "ref") {
|
|
28459
28330
|
extractToDef(entry);
|
|
28460
|
-
// biome-ignore lint:
|
|
28461
|
-
continue;
|
|
28462
28331
|
}
|
|
28463
28332
|
}
|
|
28464
28333
|
}
|
|
@@ -28688,6 +28557,8 @@ function to_json_schema_finalize(ctx, schema) {
|
|
|
28688
28557
|
compactTypeUnion(entry[1].def ?? entry[1].schema);
|
|
28689
28558
|
}
|
|
28690
28559
|
}
|
|
28560
|
+
for (const rewrite of ctx.deferred)
|
|
28561
|
+
rewrite();
|
|
28691
28562
|
// After flattening, every member that was extracted is a `$ref`, so the fold sees the final shape. A schema that inherits an intersection — through `z.lazy`, or any `ref` chain — holds the same `allOf` array, so fold by array identity to catch every copy.
|
|
28692
28563
|
if (ctx.intersections.length) {
|
|
28693
28564
|
const carriers = new Map();
|
|
@@ -28850,14 +28721,14 @@ function isTransforming(_schema, _ctx) {
|
|
|
28850
28721
|
*/
|
|
28851
28722
|
const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
28852
28723
|
const ctx = to_json_schema_initializeContext({ ...params, processors });
|
|
28853
|
-
|
|
28724
|
+
to_json_schema_processSchema(schema, ctx);
|
|
28854
28725
|
to_json_schema_extractDefs(ctx, schema);
|
|
28855
28726
|
return to_json_schema_finalize(ctx, schema);
|
|
28856
28727
|
};
|
|
28857
28728
|
const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
28858
28729
|
const { libraryOptions, target } = params ?? {};
|
|
28859
28730
|
const ctx = to_json_schema_initializeContext({ ...(libraryOptions ?? {}), target, io, processors });
|
|
28860
|
-
|
|
28731
|
+
to_json_schema_processSchema(schema, ctx);
|
|
28861
28732
|
to_json_schema_extractDefs(ctx, schema);
|
|
28862
28733
|
return to_json_schema_finalize(ctx, schema);
|
|
28863
28734
|
};
|
|
@@ -28865,6 +28736,101 @@ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params)
|
|
|
28865
28736
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/json-schema-processors.js
|
|
28866
28737
|
|
|
28867
28738
|
|
|
28739
|
+
|
|
28740
|
+
|
|
28741
|
+
const narrowMin = (agg, key, value) => {
|
|
28742
|
+
if (agg[key] === undefined || value > agg[key])
|
|
28743
|
+
agg[key] = value;
|
|
28744
|
+
};
|
|
28745
|
+
const narrowMax = (agg, key, value) => {
|
|
28746
|
+
if (agg[key] === undefined || value < agg[key])
|
|
28747
|
+
agg[key] = value;
|
|
28748
|
+
};
|
|
28749
|
+
const narrowBoth = (agg, value) => {
|
|
28750
|
+
narrowMin(agg, "minimum", value);
|
|
28751
|
+
narrowMax(agg, "maximum", value);
|
|
28752
|
+
};
|
|
28753
|
+
const addDivisor = (agg, value) => {
|
|
28754
|
+
agg.multipleOf ?? (agg.multipleOf = []);
|
|
28755
|
+
if (!agg.multipleOf.includes(value))
|
|
28756
|
+
agg.multipleOf.push(value);
|
|
28757
|
+
};
|
|
28758
|
+
const addPattern = (agg, pattern) => {
|
|
28759
|
+
agg.patterns ?? (agg.patterns = new Set());
|
|
28760
|
+
agg.patterns.add(pattern);
|
|
28761
|
+
};
|
|
28762
|
+
const intersectMime = (agg, mime) => {
|
|
28763
|
+
agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
|
|
28764
|
+
};
|
|
28765
|
+
// last-wins, matching the bag's historical write order; the flag keeps an integer format from being lost to a later float one
|
|
28766
|
+
const setFormat = (agg, format) => {
|
|
28767
|
+
agg.format = format;
|
|
28768
|
+
if (format.includes("int"))
|
|
28769
|
+
agg.isInt = true;
|
|
28770
|
+
};
|
|
28771
|
+
const minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
|
|
28772
|
+
const maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
|
|
28773
|
+
const formatContributor = (ranges) => (agg, def) => {
|
|
28774
|
+
setFormat(agg, def.format);
|
|
28775
|
+
const [minimum, maximum] = ranges[def.format];
|
|
28776
|
+
narrowMin(agg, "minimum", minimum);
|
|
28777
|
+
narrowMax(agg, "maximum", maximum);
|
|
28778
|
+
};
|
|
28779
|
+
const contributors = {
|
|
28780
|
+
greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
|
|
28781
|
+
less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
|
|
28782
|
+
multiple_of: (agg, def) => addDivisor(agg, def.value),
|
|
28783
|
+
number_format: formatContributor(NUMBER_FORMAT_RANGES),
|
|
28784
|
+
bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
|
|
28785
|
+
min_length: minContributor,
|
|
28786
|
+
max_length: maxContributor,
|
|
28787
|
+
length_equals: (agg, def) => narrowBoth(agg, def.length),
|
|
28788
|
+
min_size: minContributor,
|
|
28789
|
+
max_size: maxContributor,
|
|
28790
|
+
size_equals: (agg, def) => narrowBoth(agg, def.size),
|
|
28791
|
+
string_format: (agg, def) => {
|
|
28792
|
+
setFormat(agg, def.format);
|
|
28793
|
+
if (def.pattern)
|
|
28794
|
+
addPattern(agg, def.pattern);
|
|
28795
|
+
if (def.format === "base64" || def.format === "base64url")
|
|
28796
|
+
agg.contentEncoding = def.format;
|
|
28797
|
+
if (def.local || def.precision === -1)
|
|
28798
|
+
agg.laxFormat = true;
|
|
28799
|
+
},
|
|
28800
|
+
mime_type: (agg, def) => intersectMime(agg, def.mime),
|
|
28801
|
+
};
|
|
28802
|
+
function aggregateChecks(schema) {
|
|
28803
|
+
const agg = {};
|
|
28804
|
+
const def = schema._zod.def;
|
|
28805
|
+
// a format schema is its own first check, same rule as $ZodType init
|
|
28806
|
+
const list = schema._zod.traits.has("$ZodCheck")
|
|
28807
|
+
? [schema, ...(def.checks ?? [])]
|
|
28808
|
+
: (def.checks ?? []);
|
|
28809
|
+
for (const ch of list)
|
|
28810
|
+
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
28811
|
+
// reconcile with the bag so third-party onattach contributions still land; first-party residue is never tighter than the fold, so merging it back is idempotent for one and additive for the other
|
|
28812
|
+
const bag = schema._zod.bag;
|
|
28813
|
+
if (bag.minimum !== undefined)
|
|
28814
|
+
narrowMin(agg, "minimum", bag.minimum);
|
|
28815
|
+
if (bag.exclusiveMinimum !== undefined)
|
|
28816
|
+
narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
|
|
28817
|
+
if (bag.maximum !== undefined)
|
|
28818
|
+
narrowMax(agg, "maximum", bag.maximum);
|
|
28819
|
+
if (bag.exclusiveMaximum !== undefined)
|
|
28820
|
+
narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
|
|
28821
|
+
if (bag.multipleOf !== undefined)
|
|
28822
|
+
addDivisor(agg, bag.multipleOf);
|
|
28823
|
+
if (bag.format !== undefined) {
|
|
28824
|
+
agg.format ?? (agg.format = bag.format);
|
|
28825
|
+
if (bag.format.includes("int"))
|
|
28826
|
+
agg.isInt = true;
|
|
28827
|
+
}
|
|
28828
|
+
if (bag.mime)
|
|
28829
|
+
intersectMime(agg, bag.mime);
|
|
28830
|
+
for (const pattern of bag.patterns ?? [])
|
|
28831
|
+
addPattern(agg, pattern);
|
|
28832
|
+
return agg;
|
|
28833
|
+
}
|
|
28868
28834
|
const formatMap = {
|
|
28869
28835
|
guid: "uuid",
|
|
28870
28836
|
url: "uri",
|
|
@@ -28873,11 +28839,16 @@ const formatMap = {
|
|
|
28873
28839
|
regex: "", // do not set
|
|
28874
28840
|
};
|
|
28875
28841
|
// ==================== SIMPLE TYPE PROCESSORS ====================
|
|
28842
|
+
// the runtime patterns are lax so parse paths never overflow the regex stack; the emitted schema swaps in the exact block forms, which zod itself never executes
|
|
28843
|
+
const exactPatterns = new Map([
|
|
28844
|
+
[base64Charset, regexes_base64],
|
|
28845
|
+
[base64urlCharset, regexes_base64url],
|
|
28846
|
+
]);
|
|
28847
|
+
const exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
28876
28848
|
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
28877
28849
|
const json = _json;
|
|
28878
28850
|
json.type = "string";
|
|
28879
|
-
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = schema
|
|
28880
|
-
.bag;
|
|
28851
|
+
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
28881
28852
|
if (typeof minimum === "number")
|
|
28882
28853
|
json.minLength = minimum;
|
|
28883
28854
|
if (typeof maximum === "number")
|
|
@@ -28895,12 +28866,12 @@ const stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
28895
28866
|
if (contentEncoding)
|
|
28896
28867
|
json.contentEncoding = contentEncoding;
|
|
28897
28868
|
if (patterns && patterns.size > 0) {
|
|
28898
|
-
const
|
|
28899
|
-
if (
|
|
28900
|
-
json.pattern =
|
|
28901
|
-
else if (
|
|
28869
|
+
const patternList = [...patterns].map(exactPattern);
|
|
28870
|
+
if (patternList.length === 1)
|
|
28871
|
+
json.pattern = patternList[0].source;
|
|
28872
|
+
else if (patternList.length > 1) {
|
|
28902
28873
|
json.allOf = [
|
|
28903
|
-
...
|
|
28874
|
+
...patternList.map((regex) => ({
|
|
28904
28875
|
...(ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0"
|
|
28905
28876
|
? { type: "string" }
|
|
28906
28877
|
: {}),
|
|
@@ -28912,11 +28883,8 @@ const stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
28912
28883
|
};
|
|
28913
28884
|
const numberProcessor = (schema, ctx, _json, params) => {
|
|
28914
28885
|
const json = _json;
|
|
28915
|
-
const { minimum, maximum,
|
|
28916
|
-
|
|
28917
|
-
json.type = "integer";
|
|
28918
|
-
else
|
|
28919
|
-
json.type = "number";
|
|
28886
|
+
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
28887
|
+
json.type = isInt ? "integer" : "number";
|
|
28920
28888
|
// when both minimum and exclusiveMinimum exist, pick the more restrictive one
|
|
28921
28889
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
28922
28890
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
@@ -28945,12 +28913,21 @@ const numberProcessor = (schema, ctx, _json, params) => {
|
|
|
28945
28913
|
else if (typeof maximum === "number") {
|
|
28946
28914
|
json.maximum = maximum;
|
|
28947
28915
|
}
|
|
28948
|
-
if (
|
|
28916
|
+
if (multipleOf) {
|
|
28949
28917
|
// JSON Schema requires a divisor strictly greater than zero, and a non-finite one does not survive JSON at all. A negative divisor accepts exactly what its absolute value accepts, so it still maps; zero, NaN and Infinity have no keyword form.
|
|
28950
|
-
|
|
28951
|
-
|
|
28952
|
-
|
|
28953
|
-
|
|
28918
|
+
const divisors = new Set();
|
|
28919
|
+
for (const divisor of multipleOf) {
|
|
28920
|
+
if (Number.isFinite(divisor) && divisor !== 0)
|
|
28921
|
+
divisors.add(Math.abs(divisor));
|
|
28922
|
+
else
|
|
28923
|
+
to_json_schema_handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
28924
|
+
}
|
|
28925
|
+
// chained divisors are a conjunction the keyword cannot carry alone, so extras ride an allOf, same as stacked patterns
|
|
28926
|
+
const [first, ...rest] = divisors;
|
|
28927
|
+
if (first !== undefined)
|
|
28928
|
+
json.multipleOf = first;
|
|
28929
|
+
if (rest.length)
|
|
28930
|
+
json.allOf = [...(json.allOf ?? []), ...rest.map((m) => ({ multipleOf: m }))];
|
|
28954
28931
|
}
|
|
28955
28932
|
};
|
|
28956
28933
|
const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
@@ -29067,29 +29044,24 @@ const templateLiteralProcessor = (schema, _ctx, json, _params) => {
|
|
|
29067
29044
|
};
|
|
29068
29045
|
const fileProcessor = (schema, _ctx, json, _params) => {
|
|
29069
29046
|
const _json = json;
|
|
29070
|
-
|
|
29071
|
-
|
|
29072
|
-
|
|
29073
|
-
|
|
29074
|
-
};
|
|
29075
|
-
const { minimum, maximum, mime } = schema._zod.bag;
|
|
29047
|
+
_json.type = "string";
|
|
29048
|
+
_json.format = "binary";
|
|
29049
|
+
_json.contentEncoding = "binary";
|
|
29050
|
+
const { minimum, maximum, mime } = aggregateChecks(schema);
|
|
29076
29051
|
if (minimum !== undefined)
|
|
29077
|
-
|
|
29052
|
+
_json.minLength = minimum;
|
|
29078
29053
|
if (maximum !== undefined)
|
|
29079
|
-
|
|
29080
|
-
if (mime)
|
|
29081
|
-
|
|
29082
|
-
|
|
29083
|
-
|
|
29084
|
-
}
|
|
29085
|
-
|
|
29086
|
-
|
|
29087
|
-
|
|
29088
|
-
|
|
29089
|
-
|
|
29090
|
-
else {
|
|
29091
|
-
Object.assign(_json, file);
|
|
29092
|
-
}
|
|
29054
|
+
_json.maxLength = maximum;
|
|
29055
|
+
if (!mime)
|
|
29056
|
+
return;
|
|
29057
|
+
// an empty intersection means the mime checks share no value, so nothing passes at runtime; `anyOf` must be non-empty, so the false schema is `not: {}`
|
|
29058
|
+
if (mime.length === 0)
|
|
29059
|
+
_json.not = {};
|
|
29060
|
+
else if (mime.length === 1)
|
|
29061
|
+
_json.contentMediaType = mime[0];
|
|
29062
|
+
// only contentMediaType differs, so the shared props stay at the root
|
|
29063
|
+
else
|
|
29064
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
29093
29065
|
};
|
|
29094
29066
|
const successProcessor = (_schema, _ctx, json, _params) => {
|
|
29095
29067
|
json.type = "boolean";
|
|
@@ -29113,13 +29085,13 @@ const setProcessor = (schema, ctx, json, params) => {
|
|
|
29113
29085
|
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
29114
29086
|
const json = _json;
|
|
29115
29087
|
const def = schema._zod.def;
|
|
29116
|
-
const { minimum, maximum } = schema
|
|
29088
|
+
const { minimum, maximum } = aggregateChecks(schema);
|
|
29117
29089
|
if (typeof minimum === "number")
|
|
29118
29090
|
json.minItems = minimum;
|
|
29119
29091
|
if (typeof maximum === "number")
|
|
29120
29092
|
json.maxItems = maximum;
|
|
29121
29093
|
json.type = "array";
|
|
29122
|
-
json.items =
|
|
29094
|
+
json.items = to_json_schema_processSchema(def.element, ctx, {
|
|
29123
29095
|
...params,
|
|
29124
29096
|
path: [...params.path, "items"],
|
|
29125
29097
|
});
|
|
@@ -29153,24 +29125,21 @@ const objectProcessor = (schema, ctx, _json, params) => {
|
|
|
29153
29125
|
json.properties = {};
|
|
29154
29126
|
for (const key in shape) {
|
|
29155
29127
|
// assignProp so a __proto__ key becomes an own property instead of hitting the inherited setter on the plain {} we build into
|
|
29156
|
-
util_assignProp(json.properties, key,
|
|
29128
|
+
util_assignProp(json.properties, key, to_json_schema_processSchema(shape[key], ctx, {
|
|
29157
29129
|
...params,
|
|
29158
29130
|
path: [...params.path, "properties", key],
|
|
29159
29131
|
}));
|
|
29160
29132
|
}
|
|
29161
29133
|
// required keys
|
|
29162
|
-
const
|
|
29163
|
-
const
|
|
29134
|
+
const requiredKeys = [];
|
|
29135
|
+
for (const key of Object.keys(shape)) {
|
|
29164
29136
|
const field = def.shape[key];
|
|
29165
|
-
if (ctx.io === "input") {
|
|
29166
|
-
|
|
29137
|
+
if (ctx.io === "input" ? inputOptin(field) === undefined : field._zod.optout === undefined) {
|
|
29138
|
+
requiredKeys.push(key);
|
|
29167
29139
|
}
|
|
29168
|
-
|
|
29169
|
-
|
|
29170
|
-
|
|
29171
|
-
}));
|
|
29172
|
-
if (requiredKeys.size > 0) {
|
|
29173
|
-
json.required = Array.from(requiredKeys);
|
|
29140
|
+
}
|
|
29141
|
+
if (requiredKeys.length > 0) {
|
|
29142
|
+
json.required = requiredKeys;
|
|
29174
29143
|
}
|
|
29175
29144
|
// catchall
|
|
29176
29145
|
if (def.catchall?._zod.def.type === "never") {
|
|
@@ -29183,7 +29152,7 @@ const objectProcessor = (schema, ctx, _json, params) => {
|
|
|
29183
29152
|
json.additionalProperties = false;
|
|
29184
29153
|
}
|
|
29185
29154
|
else if (def.catchall) {
|
|
29186
|
-
json.additionalProperties =
|
|
29155
|
+
json.additionalProperties = to_json_schema_processSchema(def.catchall, ctx, {
|
|
29187
29156
|
...params,
|
|
29188
29157
|
path: [...params.path, "additionalProperties"],
|
|
29189
29158
|
});
|
|
@@ -29193,7 +29162,7 @@ const unionProcessor = (schema, ctx, json, params) => {
|
|
|
29193
29162
|
const def = schema._zod.def;
|
|
29194
29163
|
// Exclusive unions (inclusive === false) use oneOf (exactly one match) instead of anyOf (one or more matches). This includes both z.xor() and discriminated unions
|
|
29195
29164
|
const isExclusive = def.inclusive === false;
|
|
29196
|
-
const options = def.options.map((x, i) =>
|
|
29165
|
+
const options = def.options.map((x, i) => to_json_schema_processSchema(x, ctx, {
|
|
29197
29166
|
...params,
|
|
29198
29167
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i],
|
|
29199
29168
|
}));
|
|
@@ -29206,11 +29175,11 @@ const unionProcessor = (schema, ctx, json, params) => {
|
|
|
29206
29175
|
};
|
|
29207
29176
|
const intersectionProcessor = (schema, ctx, json, params) => {
|
|
29208
29177
|
const def = schema._zod.def;
|
|
29209
|
-
const a =
|
|
29178
|
+
const a = to_json_schema_processSchema(def.left, ctx, {
|
|
29210
29179
|
...params,
|
|
29211
29180
|
path: [...params.path, "allOf", 0],
|
|
29212
29181
|
});
|
|
29213
|
-
const b =
|
|
29182
|
+
const b = to_json_schema_processSchema(def.right, ctx, {
|
|
29214
29183
|
...params,
|
|
29215
29184
|
path: [...params.path, "allOf", 1],
|
|
29216
29185
|
});
|
|
@@ -29229,12 +29198,12 @@ const tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
29229
29198
|
json.type = "array";
|
|
29230
29199
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
29231
29200
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
29232
|
-
const prefixItems = def.items.map((x, i) =>
|
|
29201
|
+
const prefixItems = def.items.map((x, i) => processSchema(x, ctx, {
|
|
29233
29202
|
...params,
|
|
29234
29203
|
path: [...params.path, prefixPath, i],
|
|
29235
29204
|
}));
|
|
29236
29205
|
const rest = def.rest
|
|
29237
|
-
?
|
|
29206
|
+
? processSchema(def.rest, ctx, {
|
|
29238
29207
|
...params,
|
|
29239
29208
|
path: [...params.path, restPath, ...(ctx.target === "openapi-3.0" ? [def.items.length] : [])],
|
|
29240
29209
|
})
|
|
@@ -29288,40 +29257,127 @@ const tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
29288
29257
|
json.maxItems = maxItems;
|
|
29289
29258
|
}
|
|
29290
29259
|
// explicit user-defined length checks take precedence
|
|
29291
|
-
const { minimum, maximum } = schema
|
|
29260
|
+
const { minimum, maximum } = aggregateChecks(schema);
|
|
29292
29261
|
if (typeof minimum === "number")
|
|
29293
29262
|
json.minItems = minimum;
|
|
29294
29263
|
if (typeof maximum === "number")
|
|
29295
29264
|
json.maxItems = maximum;
|
|
29296
29265
|
};
|
|
29266
|
+
/** JSON object keys are always strings, so a numeric record key schema is re-expressed over the
|
|
29267
|
+
* numeric-string form the record parser matches. Deferred to `finalize`, after the flatten: a key
|
|
29268
|
+
* behind a wrapper only carries its own `type` before then, and a union key only has its branches.
|
|
29269
|
+
*
|
|
29270
|
+
* A numeric bound cannot apply to a property name, so `minimum` and its siblings are dropped rather
|
|
29271
|
+
* than carried over: keeping them beside `type: "string"` reproduces the match-nothing schema this
|
|
29272
|
+
* exists to fix. A key that carries one therefore emits wider than the record parses — `z.record(z.number().min(5), V)`
|
|
29273
|
+
* accepts `"3"` — which is the deliberate trade, since throwing on it would reject an ordinary schema
|
|
29274
|
+
* outright. */
|
|
29275
|
+
function stringifyKeyNames(bySchema, json, visited) {
|
|
29276
|
+
// an extracted key that rewrites cannot go on sharing its definition — the string form a key position needs is not the number form every other reference wants — so it inlines. One that does not rewrite keeps the `$ref`.
|
|
29277
|
+
if (json.$ref) {
|
|
29278
|
+
// a recursive key holds its own reference inside its definition, so a node already on the path is left alone rather than resolved again
|
|
29279
|
+
if (visited.has(json))
|
|
29280
|
+
return json;
|
|
29281
|
+
visited.add(json);
|
|
29282
|
+
const def = bySchema.get(json)?.def;
|
|
29283
|
+
if (!def)
|
|
29284
|
+
return json;
|
|
29285
|
+
const inlined = stringifyKeyNames(bySchema, def, visited);
|
|
29286
|
+
return inlined === def ? json : inlined;
|
|
29287
|
+
}
|
|
29288
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
29289
|
+
const branches = json[keyword];
|
|
29290
|
+
if (!Array.isArray(branches))
|
|
29291
|
+
continue;
|
|
29292
|
+
const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
|
|
29293
|
+
// rebuilding regardless would detach a key that had nothing to re-express, dropping its `$ref` and leaking the internal `id`
|
|
29294
|
+
if (mapped.some((branch, i) => branch !== branches[i]))
|
|
29295
|
+
json = { ...json, [keyword]: mapped };
|
|
29296
|
+
}
|
|
29297
|
+
// a member that already admits a string leaves the key unconstrained, so the node's own type re-expresses only when every member is numeric
|
|
29298
|
+
const types = Array.isArray(json.type) ? json.type : [json.type];
|
|
29299
|
+
const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
|
|
29300
|
+
// a heterogeneous key carries no type at all, so its numeric members are caught here instead
|
|
29301
|
+
const values = json.enum ?? (json.const !== undefined ? [json.const] : undefined);
|
|
29302
|
+
if (!numericType && !values?.some((v) => typeof v === "number"))
|
|
29303
|
+
return json;
|
|
29304
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json;
|
|
29305
|
+
if (rest.enum)
|
|
29306
|
+
rest.enum = rest.enum.map((v) => (typeof v === "number" ? String(v) : v));
|
|
29307
|
+
else if (typeof rest.const === "number")
|
|
29308
|
+
rest.const = String(rest.const);
|
|
29309
|
+
// a heterogeneous key keeps its absent type: the stringified members already say what a key may be
|
|
29310
|
+
if (!numericType)
|
|
29311
|
+
return rest;
|
|
29312
|
+
rest.type = "string";
|
|
29313
|
+
if (!values)
|
|
29314
|
+
rest.pattern = (types.includes("number") ? number : integer).source;
|
|
29315
|
+
return rest;
|
|
29316
|
+
}
|
|
29317
|
+
/** Every record of one conversion, so the carriers are found in a single pass rather than once per record. */
|
|
29318
|
+
const pendingRecords = new WeakMap();
|
|
29319
|
+
function rewriteKeyNames(ctx) {
|
|
29320
|
+
// an extracted key is resolved by the object `extractToDef` left in its place, so the map is built once rather than searched per reference. `_zod.toJSONSchema` can hand the same object to two schemas, so the first entry carrying a body wins, as a search would have found it.
|
|
29321
|
+
const bySchema = new Map();
|
|
29322
|
+
for (const entry of ctx.seen.values()) {
|
|
29323
|
+
if (entry.def && !bySchema.has(entry.schema))
|
|
29324
|
+
bySchema.set(entry.schema, entry);
|
|
29325
|
+
}
|
|
29326
|
+
const rewrites = new Map();
|
|
29327
|
+
for (const record of pendingRecords.get(ctx) ?? []) {
|
|
29328
|
+
const seen = ctx.seen.get(record);
|
|
29329
|
+
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
29330
|
+
if (!names || names === true || rewrites.has(names))
|
|
29331
|
+
continue;
|
|
29332
|
+
const rewritten = stringifyKeyNames(bySchema, names, new Set());
|
|
29333
|
+
if (rewritten !== names)
|
|
29334
|
+
rewrites.set(names, rewritten);
|
|
29335
|
+
}
|
|
29336
|
+
if (!rewrites.size)
|
|
29337
|
+
return;
|
|
29338
|
+
// the flatten has already copied each record's own properties onto every wrapper by reference, and an extracted body is another such copy, so every carrier holding a rewritten key is updated together
|
|
29339
|
+
for (const entry of ctx.seen.values()) {
|
|
29340
|
+
for (const carrier of [entry.schema, entry.def]) {
|
|
29341
|
+
const rewritten = carrier && rewrites.get(carrier.propertyNames);
|
|
29342
|
+
if (rewritten)
|
|
29343
|
+
carrier.propertyNames = rewritten;
|
|
29344
|
+
}
|
|
29345
|
+
}
|
|
29346
|
+
}
|
|
29297
29347
|
const recordProcessor = (schema, ctx, _json, params) => {
|
|
29298
29348
|
const json = _json;
|
|
29299
29349
|
const def = schema._zod.def;
|
|
29300
29350
|
json.type = "object";
|
|
29301
29351
|
// For looseRecord with regex patterns, use patternProperties. This correctly represents "only validate keys matching the pattern" semantics and composes well with allOf (intersections)
|
|
29302
29352
|
const keyType = def.keyType;
|
|
29303
|
-
const
|
|
29304
|
-
const patterns = keyBag?.patterns;
|
|
29353
|
+
const patterns = aggregateChecks(keyType).patterns;
|
|
29305
29354
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
29306
29355
|
// Use patternProperties for looseRecord with regex patterns
|
|
29307
|
-
const valueSchema =
|
|
29356
|
+
const valueSchema = to_json_schema_processSchema(def.valueType, ctx, {
|
|
29308
29357
|
...params,
|
|
29309
29358
|
path: [...params.path, "patternProperties", "*"],
|
|
29310
29359
|
});
|
|
29311
29360
|
json.patternProperties = {};
|
|
29312
29361
|
for (const pattern of patterns) {
|
|
29313
|
-
util_assignProp(json.patternProperties, pattern.source, valueSchema);
|
|
29362
|
+
util_assignProp(json.patternProperties, exactPattern(pattern).source, valueSchema);
|
|
29314
29363
|
}
|
|
29315
29364
|
}
|
|
29316
29365
|
else {
|
|
29317
29366
|
// Default behavior: use propertyNames + additionalProperties
|
|
29318
29367
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
29319
|
-
json.propertyNames =
|
|
29368
|
+
json.propertyNames = to_json_schema_processSchema(def.keyType, ctx, {
|
|
29320
29369
|
...params,
|
|
29321
29370
|
path: [...params.path, "propertyNames"],
|
|
29322
29371
|
});
|
|
29372
|
+
let pending = pendingRecords.get(ctx);
|
|
29373
|
+
if (!pending) {
|
|
29374
|
+
pending = [];
|
|
29375
|
+
pendingRecords.set(ctx, pending);
|
|
29376
|
+
ctx.deferred.push(() => rewriteKeyNames(ctx));
|
|
29377
|
+
}
|
|
29378
|
+
pending.push(schema);
|
|
29323
29379
|
}
|
|
29324
|
-
json.additionalProperties =
|
|
29380
|
+
json.additionalProperties = to_json_schema_processSchema(def.valueType, ctx, {
|
|
29325
29381
|
...params,
|
|
29326
29382
|
path: [...params.path, "additionalProperties"],
|
|
29327
29383
|
});
|
|
@@ -29333,13 +29389,13 @@ const recordProcessor = (schema, ctx, _json, params) => {
|
|
|
29333
29389
|
if (keyValues && !def.partial && !omittableOnInput) {
|
|
29334
29390
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
29335
29391
|
if (validKeyValues.length > 0) {
|
|
29336
|
-
json.required = validKeyValues;
|
|
29392
|
+
json.required = validKeyValues.map(String);
|
|
29337
29393
|
}
|
|
29338
29394
|
}
|
|
29339
29395
|
};
|
|
29340
29396
|
const nullableProcessor = (schema, ctx, json, params) => {
|
|
29341
29397
|
const def = schema._zod.def;
|
|
29342
|
-
const inner =
|
|
29398
|
+
const inner = to_json_schema_processSchema(def.innerType, ctx, params);
|
|
29343
29399
|
const seen = ctx.seen.get(schema);
|
|
29344
29400
|
if (ctx.target === "openapi-3.0") {
|
|
29345
29401
|
seen.ref = def.innerType;
|
|
@@ -29351,7 +29407,7 @@ const nullableProcessor = (schema, ctx, json, params) => {
|
|
|
29351
29407
|
};
|
|
29352
29408
|
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
29353
29409
|
const def = schema._zod.def;
|
|
29354
|
-
|
|
29410
|
+
to_json_schema_processSchema(def.innerType, ctx, params);
|
|
29355
29411
|
const seen = ctx.seen.get(schema);
|
|
29356
29412
|
seen.ref = def.innerType;
|
|
29357
29413
|
};
|
|
@@ -29374,7 +29430,7 @@ function serializeDefaultValue(value, schema, ctx, json, params) {
|
|
|
29374
29430
|
}
|
|
29375
29431
|
const defaultProcessor = (schema, ctx, json, params) => {
|
|
29376
29432
|
const def = schema._zod.def;
|
|
29377
|
-
|
|
29433
|
+
to_json_schema_processSchema(def.innerType, ctx, params);
|
|
29378
29434
|
const seen = ctx.seen.get(schema);
|
|
29379
29435
|
seen.ref = def.innerType;
|
|
29380
29436
|
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
@@ -29383,7 +29439,7 @@ const defaultProcessor = (schema, ctx, json, params) => {
|
|
|
29383
29439
|
};
|
|
29384
29440
|
const prefaultProcessor = (schema, ctx, json, params) => {
|
|
29385
29441
|
const def = schema._zod.def;
|
|
29386
|
-
|
|
29442
|
+
to_json_schema_processSchema(def.innerType, ctx, params);
|
|
29387
29443
|
const seen = ctx.seen.get(schema);
|
|
29388
29444
|
seen.ref = def.innerType;
|
|
29389
29445
|
if (ctx.io !== "input")
|
|
@@ -29394,7 +29450,7 @@ const prefaultProcessor = (schema, ctx, json, params) => {
|
|
|
29394
29450
|
};
|
|
29395
29451
|
const catchProcessor = (schema, ctx, json, params) => {
|
|
29396
29452
|
const def = schema._zod.def;
|
|
29397
|
-
|
|
29453
|
+
to_json_schema_processSchema(def.innerType, ctx, params);
|
|
29398
29454
|
const seen = ctx.seen.get(schema);
|
|
29399
29455
|
seen.ref = def.innerType;
|
|
29400
29456
|
let catchValue;
|
|
@@ -29411,32 +29467,32 @@ const pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
29411
29467
|
const def = schema._zod.def;
|
|
29412
29468
|
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
29413
29469
|
const innerType = ctx.io === "input" ? (inIsTransform ? def.out : def.in) : def.out;
|
|
29414
|
-
|
|
29470
|
+
to_json_schema_processSchema(innerType, ctx, params);
|
|
29415
29471
|
const seen = ctx.seen.get(schema);
|
|
29416
29472
|
seen.ref = innerType;
|
|
29417
29473
|
};
|
|
29418
29474
|
const readonlyProcessor = (schema, ctx, json, params) => {
|
|
29419
29475
|
const def = schema._zod.def;
|
|
29420
|
-
|
|
29476
|
+
to_json_schema_processSchema(def.innerType, ctx, params);
|
|
29421
29477
|
const seen = ctx.seen.get(schema);
|
|
29422
29478
|
seen.ref = def.innerType;
|
|
29423
29479
|
json.readOnly = true;
|
|
29424
29480
|
};
|
|
29425
29481
|
const promiseProcessor = (schema, ctx, _json, params) => {
|
|
29426
29482
|
const def = schema._zod.def;
|
|
29427
|
-
|
|
29483
|
+
processSchema(def.innerType, ctx, params);
|
|
29428
29484
|
const seen = ctx.seen.get(schema);
|
|
29429
29485
|
seen.ref = def.innerType;
|
|
29430
29486
|
};
|
|
29431
29487
|
const optionalProcessor = (schema, ctx, _json, params) => {
|
|
29432
29488
|
const def = schema._zod.def;
|
|
29433
|
-
|
|
29489
|
+
to_json_schema_processSchema(def.innerType, ctx, params);
|
|
29434
29490
|
const seen = ctx.seen.get(schema);
|
|
29435
29491
|
seen.ref = def.innerType;
|
|
29436
29492
|
};
|
|
29437
29493
|
const lazyProcessor = (schema, ctx, _json, params) => {
|
|
29438
29494
|
const innerType = schema._zod.innerType;
|
|
29439
|
-
|
|
29495
|
+
processSchema(innerType, ctx, params);
|
|
29440
29496
|
const seen = ctx.seen.get(schema);
|
|
29441
29497
|
seen.ref = innerType;
|
|
29442
29498
|
};
|
|
@@ -29491,7 +29547,7 @@ function toJSONSchema(input, params) {
|
|
|
29491
29547
|
// First pass: process all schemas to build the seen map
|
|
29492
29548
|
for (const entry of registry._idmap.entries()) {
|
|
29493
29549
|
const [_, schema] = entry;
|
|
29494
|
-
|
|
29550
|
+
processSchema(schema, ctx);
|
|
29495
29551
|
}
|
|
29496
29552
|
const schemas = {};
|
|
29497
29553
|
const external = {
|
|
@@ -29513,139 +29569,587 @@ function toJSONSchema(input, params) {
|
|
|
29513
29569
|
[defsSegment]: defs,
|
|
29514
29570
|
};
|
|
29515
29571
|
}
|
|
29516
|
-
return { schemas };
|
|
29572
|
+
return { schemas };
|
|
29573
|
+
}
|
|
29574
|
+
// Single schema case
|
|
29575
|
+
const ctx = initializeContext({ ...params, processors: allProcessors });
|
|
29576
|
+
processSchema(input, ctx);
|
|
29577
|
+
extractDefs(ctx, input);
|
|
29578
|
+
return finalize(ctx, input);
|
|
29579
|
+
}
|
|
29580
|
+
|
|
29581
|
+
;// CONCATENATED MODULE: ./node_modules/zod/v4/locales/en.js
|
|
29582
|
+
|
|
29583
|
+
const en_error = () => {
|
|
29584
|
+
const Sizable = {
|
|
29585
|
+
string: { unit: "characters", verb: "to have" },
|
|
29586
|
+
file: { unit: "bytes", verb: "to have" },
|
|
29587
|
+
array: { unit: "items", verb: "to have" },
|
|
29588
|
+
set: { unit: "items", verb: "to have" },
|
|
29589
|
+
map: { unit: "entries", verb: "to have" },
|
|
29590
|
+
};
|
|
29591
|
+
function getSizing(origin) {
|
|
29592
|
+
return Sizable[origin] ?? null;
|
|
29593
|
+
}
|
|
29594
|
+
const FormatDictionary = {
|
|
29595
|
+
regex: "input",
|
|
29596
|
+
email: "email address",
|
|
29597
|
+
url: "URL",
|
|
29598
|
+
emoji: "emoji",
|
|
29599
|
+
uuid: "UUID",
|
|
29600
|
+
uuidv4: "UUIDv4",
|
|
29601
|
+
uuidv6: "UUIDv6",
|
|
29602
|
+
nanoid: "nanoid",
|
|
29603
|
+
guid: "GUID",
|
|
29604
|
+
cuid: "cuid",
|
|
29605
|
+
cuid2: "cuid2",
|
|
29606
|
+
ulid: "ULID",
|
|
29607
|
+
xid: "XID",
|
|
29608
|
+
ksuid: "KSUID",
|
|
29609
|
+
datetime: "ISO datetime",
|
|
29610
|
+
date: "ISO date",
|
|
29611
|
+
time: "ISO time",
|
|
29612
|
+
duration: "ISO duration",
|
|
29613
|
+
ipv4: "IPv4 address",
|
|
29614
|
+
ipv6: "IPv6 address",
|
|
29615
|
+
mac: "MAC address",
|
|
29616
|
+
cidrv4: "IPv4 range",
|
|
29617
|
+
cidrv6: "IPv6 range",
|
|
29618
|
+
base64: "base64-encoded string",
|
|
29619
|
+
base64url: "base64url-encoded string",
|
|
29620
|
+
json_string: "JSON string",
|
|
29621
|
+
e164: "E.164 number",
|
|
29622
|
+
currency_code: "currency code",
|
|
29623
|
+
credit_card: "credit card number",
|
|
29624
|
+
iban: "IBAN",
|
|
29625
|
+
jwt: "JWT",
|
|
29626
|
+
template_literal: "input",
|
|
29627
|
+
};
|
|
29628
|
+
// type names: missing keys = do not translate (use raw value via ?? fallback)
|
|
29629
|
+
const TypeDictionary = {
|
|
29630
|
+
// Compatibility: "nan" -> "NaN" for display
|
|
29631
|
+
nan: "NaN",
|
|
29632
|
+
// All other type names omitted - they fall back to raw values via ?? operator
|
|
29633
|
+
};
|
|
29634
|
+
function getTypeName(type, input) {
|
|
29635
|
+
if (type === "number" && typeof input === "number" && !Number.isFinite(input)) {
|
|
29636
|
+
return String(input);
|
|
29637
|
+
}
|
|
29638
|
+
return TypeDictionary[type] ?? type;
|
|
29639
|
+
}
|
|
29640
|
+
return (issue) => {
|
|
29641
|
+
switch (issue.code) {
|
|
29642
|
+
case "invalid_type": {
|
|
29643
|
+
const expected = getTypeName(issue.expected);
|
|
29644
|
+
const receivedType = parsedType(issue.input);
|
|
29645
|
+
const received = getTypeName(receivedType, issue.input);
|
|
29646
|
+
return `Invalid input: expected ${expected}, received ${received}`;
|
|
29647
|
+
}
|
|
29648
|
+
case "invalid_value":
|
|
29649
|
+
if (issue.values.length === 1)
|
|
29650
|
+
return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
|
|
29651
|
+
return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
|
|
29652
|
+
case "too_big": {
|
|
29653
|
+
const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
|
|
29654
|
+
const sizing = getSizing(issue.origin);
|
|
29655
|
+
if (sizing)
|
|
29656
|
+
return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
|
29657
|
+
return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
|
|
29658
|
+
}
|
|
29659
|
+
case "too_small": {
|
|
29660
|
+
const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
|
|
29661
|
+
const sizing = getSizing(issue.origin);
|
|
29662
|
+
if (sizing) {
|
|
29663
|
+
return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
29664
|
+
}
|
|
29665
|
+
return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
|
|
29666
|
+
}
|
|
29667
|
+
case "invalid_format": {
|
|
29668
|
+
const _issue = issue;
|
|
29669
|
+
if (_issue.format === "starts_with") {
|
|
29670
|
+
return `Invalid string: must start with "${_issue.prefix}"`;
|
|
29671
|
+
}
|
|
29672
|
+
if (_issue.format === "ends_with")
|
|
29673
|
+
return `Invalid string: must end with "${_issue.suffix}"`;
|
|
29674
|
+
if (_issue.format === "includes")
|
|
29675
|
+
return `Invalid string: must include "${_issue.includes}"`;
|
|
29676
|
+
if (_issue.format === "regex")
|
|
29677
|
+
return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
29678
|
+
return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
|
|
29679
|
+
}
|
|
29680
|
+
case "not_multiple_of":
|
|
29681
|
+
return `Invalid number: must be a multiple of ${issue.divisor}`;
|
|
29682
|
+
case "unrecognized_keys":
|
|
29683
|
+
return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
|
|
29684
|
+
case "invalid_key":
|
|
29685
|
+
return `Invalid key in ${issue.origin}`;
|
|
29686
|
+
case "invalid_union":
|
|
29687
|
+
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
|
|
29688
|
+
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
|
29689
|
+
return `Invalid discriminator value. Expected ${opts}`;
|
|
29690
|
+
}
|
|
29691
|
+
if (issue.inclusive === false) {
|
|
29692
|
+
return "Invalid input: more than one option matched";
|
|
29693
|
+
}
|
|
29694
|
+
return "Invalid input";
|
|
29695
|
+
case "invalid_element":
|
|
29696
|
+
return `Invalid value in ${issue.origin}`;
|
|
29697
|
+
default:
|
|
29698
|
+
return `Invalid input`;
|
|
29699
|
+
}
|
|
29700
|
+
};
|
|
29701
|
+
};
|
|
29702
|
+
/* export default */ function en() {
|
|
29703
|
+
return {
|
|
29704
|
+
localeError: en_error(),
|
|
29705
|
+
};
|
|
29706
|
+
}
|
|
29707
|
+
|
|
29708
|
+
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/errors.js
|
|
29709
|
+
|
|
29710
|
+
|
|
29711
|
+
/* Computing the message eagerly is expensive (pretty-printed JSON of all
|
|
29712
|
+
* issues), so defer it until first read. The accessor functions and
|
|
29713
|
+
* descriptors are shared across instances to keep error construction
|
|
29714
|
+
* cheap; the computed message is cached on the internals object. The
|
|
29715
|
+
* setter preserves plain assignment semantics for consumers that
|
|
29716
|
+
* overwrite `message`. */
|
|
29717
|
+
function _getMessage() {
|
|
29718
|
+
const internals = this._zod;
|
|
29719
|
+
internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
|
|
29720
|
+
return internals.message;
|
|
29721
|
+
}
|
|
29722
|
+
function _setMessage(value) {
|
|
29723
|
+
this._zod.message = value;
|
|
29724
|
+
}
|
|
29725
|
+
const _messageDesc = {
|
|
29726
|
+
get: _getMessage,
|
|
29727
|
+
set: _setMessage,
|
|
29728
|
+
enumerable: true,
|
|
29729
|
+
configurable: true,
|
|
29730
|
+
};
|
|
29731
|
+
const _issuesDesc = { value: undefined, enumerable: false };
|
|
29732
|
+
/* Prototypes that already carry the lazy `toString`. Seeded with the
|
|
29733
|
+
* intrinsics so that `init` on a foreign object — it accepts any object —
|
|
29734
|
+
* can never install an accessor onto a prototype we do not own. */
|
|
29735
|
+
const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
29736
|
+
const errors_initializer = (inst, def) => {
|
|
29737
|
+
inst.name = "$ZodError";
|
|
29738
|
+
// `_zod` is already non-enumerable: $constructor's init defined it with this same descriptor
|
|
29739
|
+
_issuesDesc.value = def;
|
|
29740
|
+
Object.defineProperty(inst, "issues", _issuesDesc);
|
|
29741
|
+
// Clear the shared slot; a retained `value` pins the last error's issues.
|
|
29742
|
+
_issuesDesc.value = undefined;
|
|
29743
|
+
Object.defineProperty(inst, "message", _messageDesc);
|
|
29744
|
+
/* `toString` lives as a non-enumerable lazy getter on the shared
|
|
29745
|
+
* prototype; on first access it caches a per-instance closure so
|
|
29746
|
+
* detached usage still works. */
|
|
29747
|
+
const proto = Object.getPrototypeOf(inst);
|
|
29748
|
+
if (!_installedToString.has(proto)) {
|
|
29749
|
+
_installedToString.add(proto);
|
|
29750
|
+
Object.defineProperty(proto, "toString", {
|
|
29751
|
+
configurable: true,
|
|
29752
|
+
enumerable: false,
|
|
29753
|
+
get() {
|
|
29754
|
+
const value = () => this.message;
|
|
29755
|
+
Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
|
|
29756
|
+
return value;
|
|
29757
|
+
},
|
|
29758
|
+
set(value) {
|
|
29759
|
+
Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
|
|
29760
|
+
},
|
|
29761
|
+
});
|
|
29762
|
+
}
|
|
29763
|
+
};
|
|
29764
|
+
const $ZodError = $constructor("$ZodError", errors_initializer);
|
|
29765
|
+
const $ZodRealError = $constructor("$ZodError", errors_initializer, undefined, {
|
|
29766
|
+
Parent: Error,
|
|
29767
|
+
});
|
|
29768
|
+
/** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
|
|
29769
|
+
* ("toString", "constructor") would otherwise read through to the prototype, and assigning
|
|
29770
|
+
* "__proto__" would hit the setter instead of creating a key. */
|
|
29771
|
+
function errors_node(obj, key, make) {
|
|
29772
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
29773
|
+
if (key === "__proto__") {
|
|
29774
|
+
Object.defineProperty(obj, key, { value: make(), writable: true, enumerable: true, configurable: true });
|
|
29775
|
+
}
|
|
29776
|
+
else {
|
|
29777
|
+
obj[key] = make();
|
|
29778
|
+
}
|
|
29779
|
+
}
|
|
29780
|
+
return obj[key];
|
|
29781
|
+
}
|
|
29782
|
+
function flattenError(error, mapper = (issue) => issue.message) {
|
|
29783
|
+
const fieldErrors = {};
|
|
29784
|
+
const formErrors = [];
|
|
29785
|
+
for (const sub of error.issues) {
|
|
29786
|
+
if (sub.path.length > 0) {
|
|
29787
|
+
errors_node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
|
|
29788
|
+
}
|
|
29789
|
+
else {
|
|
29790
|
+
formErrors.push(mapper(sub));
|
|
29791
|
+
}
|
|
29792
|
+
}
|
|
29793
|
+
return { formErrors, fieldErrors };
|
|
29794
|
+
}
|
|
29795
|
+
function formatError(error, mapper = (issue) => issue.message) {
|
|
29796
|
+
const fieldErrors = { _errors: [] };
|
|
29797
|
+
const processError = (error, path = []) => {
|
|
29798
|
+
for (const issue of error.issues) {
|
|
29799
|
+
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
29800
|
+
issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
29801
|
+
}
|
|
29802
|
+
else if (issue.code === "invalid_key") {
|
|
29803
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
29804
|
+
}
|
|
29805
|
+
else if (issue.code === "invalid_element") {
|
|
29806
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
29807
|
+
}
|
|
29808
|
+
else {
|
|
29809
|
+
const fullpath = [...path, ...issue.path];
|
|
29810
|
+
if (fullpath.length === 0) {
|
|
29811
|
+
fieldErrors._errors.push(mapper(issue));
|
|
29812
|
+
}
|
|
29813
|
+
else {
|
|
29814
|
+
let curr = fieldErrors;
|
|
29815
|
+
let i = 0;
|
|
29816
|
+
while (i < fullpath.length) {
|
|
29817
|
+
const el = fullpath[i];
|
|
29818
|
+
const terminal = i === fullpath.length - 1;
|
|
29819
|
+
// `_errors` is reserved by this legacy format, so merge a matching path segment into the current node instead of treating its array as a child.
|
|
29820
|
+
if (el === "_errors") {
|
|
29821
|
+
if (terminal)
|
|
29822
|
+
curr._errors.push(mapper(issue));
|
|
29823
|
+
i++;
|
|
29824
|
+
continue;
|
|
29825
|
+
}
|
|
29826
|
+
// A path element may collide with an inherited property name such as
|
|
29827
|
+
// "__proto__" or "constructor". Truthiness checks read the prototype
|
|
29828
|
+
// (so no node is created, then ._errors.push throws), and bracket
|
|
29829
|
+
// assignment of "__proto__" hits the setter instead of creating an
|
|
29830
|
+
// own key. Guard the read with hasOwnProperty and create the node
|
|
29831
|
+
// with defineProperty so any path element becomes a real own key.
|
|
29832
|
+
if (!Object.prototype.hasOwnProperty.call(curr, el)) {
|
|
29833
|
+
Object.defineProperty(curr, el, {
|
|
29834
|
+
value: { _errors: [] },
|
|
29835
|
+
enumerable: true,
|
|
29836
|
+
writable: true,
|
|
29837
|
+
configurable: true,
|
|
29838
|
+
});
|
|
29839
|
+
}
|
|
29840
|
+
const node = curr[el];
|
|
29841
|
+
if (terminal) {
|
|
29842
|
+
node._errors.push(mapper(issue));
|
|
29843
|
+
}
|
|
29844
|
+
curr = node;
|
|
29845
|
+
i++;
|
|
29846
|
+
}
|
|
29847
|
+
}
|
|
29848
|
+
}
|
|
29849
|
+
}
|
|
29850
|
+
};
|
|
29851
|
+
processError(error);
|
|
29852
|
+
return fieldErrors;
|
|
29853
|
+
}
|
|
29854
|
+
function treeifyError(error, mapper = (issue) => issue.message) {
|
|
29855
|
+
const result = { errors: [] };
|
|
29856
|
+
const processError = (error, path = []) => {
|
|
29857
|
+
var _a;
|
|
29858
|
+
for (const issue of error.issues) {
|
|
29859
|
+
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
29860
|
+
// regular union error
|
|
29861
|
+
issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
29862
|
+
}
|
|
29863
|
+
else if (issue.code === "invalid_key") {
|
|
29864
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
29865
|
+
}
|
|
29866
|
+
else if (issue.code === "invalid_element") {
|
|
29867
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
29868
|
+
}
|
|
29869
|
+
else {
|
|
29870
|
+
const fullpath = [...path, ...issue.path];
|
|
29871
|
+
if (fullpath.length === 0) {
|
|
29872
|
+
result.errors.push(mapper(issue));
|
|
29873
|
+
continue;
|
|
29874
|
+
}
|
|
29875
|
+
let curr = result;
|
|
29876
|
+
let i = 0;
|
|
29877
|
+
while (i < fullpath.length) {
|
|
29878
|
+
const el = fullpath[i];
|
|
29879
|
+
const terminal = i === fullpath.length - 1;
|
|
29880
|
+
if (typeof el === "string") {
|
|
29881
|
+
curr.properties ?? (curr.properties = {});
|
|
29882
|
+
// el may collide with an inherited property name ("__proto__",
|
|
29883
|
+
// "constructor", ...); ??= reads the prototype so the node is never
|
|
29884
|
+
// created and curr.errors.push throws. Guard with hasOwnProperty and
|
|
29885
|
+
// create the node with defineProperty so "__proto__" becomes a real
|
|
29886
|
+
// own key rather than invoking the prototype setter.
|
|
29887
|
+
if (!Object.prototype.hasOwnProperty.call(curr.properties, el)) {
|
|
29888
|
+
Object.defineProperty(curr.properties, el, {
|
|
29889
|
+
value: { errors: [] },
|
|
29890
|
+
enumerable: true,
|
|
29891
|
+
writable: true,
|
|
29892
|
+
configurable: true,
|
|
29893
|
+
});
|
|
29894
|
+
}
|
|
29895
|
+
curr = curr.properties[el];
|
|
29896
|
+
}
|
|
29897
|
+
else {
|
|
29898
|
+
curr.items ?? (curr.items = []);
|
|
29899
|
+
(_a = curr.items)[el] ?? (_a[el] = { errors: [] });
|
|
29900
|
+
curr = curr.items[el];
|
|
29901
|
+
}
|
|
29902
|
+
if (terminal) {
|
|
29903
|
+
curr.errors.push(mapper(issue));
|
|
29904
|
+
}
|
|
29905
|
+
i++;
|
|
29906
|
+
}
|
|
29907
|
+
}
|
|
29908
|
+
}
|
|
29909
|
+
};
|
|
29910
|
+
processError(error);
|
|
29911
|
+
return result;
|
|
29912
|
+
}
|
|
29913
|
+
/** Format a ZodError as a human-readable string in the following form.
|
|
29914
|
+
*
|
|
29915
|
+
* From
|
|
29916
|
+
*
|
|
29917
|
+
* ```ts
|
|
29918
|
+
* ZodError {
|
|
29919
|
+
* issues: [
|
|
29920
|
+
* {
|
|
29921
|
+
* expected: 'string',
|
|
29922
|
+
* code: 'invalid_type',
|
|
29923
|
+
* path: [ 'username' ],
|
|
29924
|
+
* message: 'Invalid input: expected string'
|
|
29925
|
+
* },
|
|
29926
|
+
* {
|
|
29927
|
+
* expected: 'number',
|
|
29928
|
+
* code: 'invalid_type',
|
|
29929
|
+
* path: [ 'favoriteNumbers', 1 ],
|
|
29930
|
+
* message: 'Invalid input: expected number'
|
|
29931
|
+
* }
|
|
29932
|
+
* ];
|
|
29933
|
+
* }
|
|
29934
|
+
* ```
|
|
29935
|
+
*
|
|
29936
|
+
* to
|
|
29937
|
+
*
|
|
29938
|
+
* ```
|
|
29939
|
+
* username
|
|
29940
|
+
* ✖ Expected number, received string at "username
|
|
29941
|
+
* favoriteNumbers[0]
|
|
29942
|
+
* ✖ Invalid input: expected number
|
|
29943
|
+
* ```
|
|
29944
|
+
*/
|
|
29945
|
+
function toDotPath(_path) {
|
|
29946
|
+
const segs = [];
|
|
29947
|
+
const path = _path.map((seg) => (typeof seg === "object" ? seg.key : seg));
|
|
29948
|
+
for (const seg of path) {
|
|
29949
|
+
if (typeof seg === "number")
|
|
29950
|
+
segs.push(`[${seg}]`);
|
|
29951
|
+
else if (typeof seg === "symbol")
|
|
29952
|
+
segs.push(`[${JSON.stringify(String(seg))}]`);
|
|
29953
|
+
else if (/[^\w$]/.test(seg))
|
|
29954
|
+
segs.push(`[${JSON.stringify(seg)}]`);
|
|
29955
|
+
else {
|
|
29956
|
+
if (segs.length)
|
|
29957
|
+
segs.push(".");
|
|
29958
|
+
segs.push(seg);
|
|
29959
|
+
}
|
|
29960
|
+
}
|
|
29961
|
+
return segs.join("");
|
|
29962
|
+
}
|
|
29963
|
+
function prettifyError(error) {
|
|
29964
|
+
const lines = [];
|
|
29965
|
+
// sort by path length
|
|
29966
|
+
const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
|
|
29967
|
+
// Process each issue
|
|
29968
|
+
for (const issue of issues) {
|
|
29969
|
+
lines.push(`✖ ${issue.message}`);
|
|
29970
|
+
if (issue.path?.length)
|
|
29971
|
+
lines.push(` → at ${toDotPath(issue.path)}`);
|
|
29972
|
+
}
|
|
29973
|
+
// Convert Map to formatted string
|
|
29974
|
+
return lines.join("\n");
|
|
29975
|
+
}
|
|
29976
|
+
|
|
29977
|
+
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/parse.js
|
|
29978
|
+
|
|
29979
|
+
|
|
29980
|
+
|
|
29981
|
+
// Always both keys, so the `_params` read site in `_parse` sees one object shape rather than two.
|
|
29982
|
+
function finalizeParams(callee, params) {
|
|
29983
|
+
return { callee: params?.callee ?? callee, Err: params?.Err };
|
|
29984
|
+
}
|
|
29985
|
+
const parse_parse = (_Err) => {
|
|
29986
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
29987
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
29988
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
29989
|
+
if (result instanceof Promise) {
|
|
29990
|
+
throw new $ZodAsyncError();
|
|
29991
|
+
}
|
|
29992
|
+
if (result.issues.length) {
|
|
29993
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, core_config())));
|
|
29994
|
+
captureStackTrace(e, _params?.callee ?? fn);
|
|
29995
|
+
throw e;
|
|
29996
|
+
}
|
|
29997
|
+
return result.value;
|
|
29998
|
+
};
|
|
29999
|
+
return fn;
|
|
30000
|
+
};
|
|
30001
|
+
const core_parse_parse = /* @__PURE__*/ parse_parse($ZodRealError);
|
|
30002
|
+
const parse_parseAsync = (_Err) => {
|
|
30003
|
+
const fn = async (schema, value, _ctx, params) => {
|
|
30004
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
30005
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
30006
|
+
if (result instanceof Promise)
|
|
30007
|
+
result = await result;
|
|
30008
|
+
if (result.issues.length) {
|
|
30009
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, core_config())));
|
|
30010
|
+
captureStackTrace(e, params?.callee ?? fn);
|
|
30011
|
+
throw e;
|
|
30012
|
+
}
|
|
30013
|
+
return result.value;
|
|
30014
|
+
};
|
|
30015
|
+
return fn;
|
|
30016
|
+
};
|
|
30017
|
+
const core_parse_parseAsync = /* @__PURE__*/ parse_parseAsync($ZodRealError);
|
|
30018
|
+
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
30019
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
30020
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
30021
|
+
if (result instanceof Promise) {
|
|
30022
|
+
throw new $ZodAsyncError();
|
|
29517
30023
|
}
|
|
29518
|
-
|
|
29519
|
-
|
|
29520
|
-
|
|
29521
|
-
|
|
29522
|
-
|
|
29523
|
-
|
|
29524
|
-
|
|
29525
|
-
|
|
29526
|
-
|
|
29527
|
-
|
|
29528
|
-
|
|
29529
|
-
|
|
29530
|
-
|
|
29531
|
-
|
|
29532
|
-
|
|
29533
|
-
|
|
30024
|
+
return result.issues.length ? parse_failure(_Err, result.issues, ctx) : { success: true, data: result.value };
|
|
30025
|
+
};
|
|
30026
|
+
const safeParse = /* @__PURE__*/ _safeParse($ZodRealError);
|
|
30027
|
+
// the error is built on the first read of `error`: finalizing the issues and constructing the instance is most of a failing parse, and a caller that only branches on `success` never pays it. a getter in the literal keeps this small; the alternative, one shared accessor descriptor plus a hidden state slot, reads ~15% faster but costs ~75 B gzipped in every bundle
|
|
30028
|
+
function parse_failure(Err, issues, ctx) {
|
|
30029
|
+
let error;
|
|
30030
|
+
return {
|
|
30031
|
+
success: false,
|
|
30032
|
+
get error() {
|
|
30033
|
+
if (!error) {
|
|
30034
|
+
error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, core_config())));
|
|
30035
|
+
// finalizeIssue drops `input`, so the built error holds nothing; keeping the raw issues past this point pins the parsed value for the life of the result
|
|
30036
|
+
issues = undefined;
|
|
30037
|
+
ctx = undefined;
|
|
30038
|
+
}
|
|
30039
|
+
return error;
|
|
30040
|
+
},
|
|
30041
|
+
set error(e) {
|
|
30042
|
+
error = e;
|
|
30043
|
+
// a replacement makes the getter's branch unreachable, so the captures have to go here too
|
|
30044
|
+
issues = undefined;
|
|
30045
|
+
ctx = undefined;
|
|
30046
|
+
},
|
|
29534
30047
|
};
|
|
29535
|
-
|
|
29536
|
-
|
|
30048
|
+
}
|
|
30049
|
+
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
30050
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
30051
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
30052
|
+
if (result instanceof Promise)
|
|
30053
|
+
result = await result;
|
|
30054
|
+
return result.issues.length ? parse_failure(_Err, result.issues, ctx) : { success: true, data: result.value };
|
|
30055
|
+
};
|
|
30056
|
+
const safeParseAsync = /* @__PURE__*/ _safeParseAsync($ZodRealError);
|
|
30057
|
+
// registry mirrors of the compiler's sentinels, so this module never imports the compiler
|
|
30058
|
+
const COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
|
|
30059
|
+
const COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
|
|
30060
|
+
// Deliberately tiny, because v8 will not inline a body carrying the fallback's object literals and throw. Everything that is not the compiled happy path lives in validateFallback, and that split is worth ~35% on a compiled schema.
|
|
30061
|
+
const validate = ((schema, value, _ctx) => {
|
|
30062
|
+
const validator = schema._zod.bag.validator;
|
|
30063
|
+
if (validator !== undefined) {
|
|
30064
|
+
if (validator(value) !== COMPILE_INVALID)
|
|
30065
|
+
return true;
|
|
30066
|
+
// a definite sentinel means the runtime would reject, so skip the re-parse; a ctx can still change the answer
|
|
30067
|
+
if (validator.definite === true && _ctx === undefined)
|
|
30068
|
+
return false;
|
|
29537
30069
|
}
|
|
29538
|
-
|
|
29539
|
-
|
|
29540
|
-
|
|
29541
|
-
|
|
29542
|
-
|
|
29543
|
-
|
|
29544
|
-
|
|
29545
|
-
|
|
29546
|
-
|
|
29547
|
-
|
|
29548
|
-
|
|
29549
|
-
|
|
29550
|
-
|
|
29551
|
-
|
|
29552
|
-
|
|
29553
|
-
|
|
29554
|
-
|
|
29555
|
-
|
|
29556
|
-
|
|
29557
|
-
|
|
29558
|
-
|
|
29559
|
-
|
|
29560
|
-
|
|
29561
|
-
|
|
29562
|
-
|
|
29563
|
-
|
|
29564
|
-
|
|
29565
|
-
|
|
29566
|
-
|
|
29567
|
-
|
|
29568
|
-
|
|
30070
|
+
return validateFallback(schema, value, _ctx);
|
|
30071
|
+
});
|
|
30072
|
+
function validateFallback(schema, value, _ctx) {
|
|
30073
|
+
const ctx = _ctx
|
|
30074
|
+
? { ..._ctx, async: false, abortEarly: true }
|
|
30075
|
+
: { async: false, abortEarly: true };
|
|
30076
|
+
const fallbackRun = schema._zod.bag.fallbackRun;
|
|
30077
|
+
let result;
|
|
30078
|
+
if (fallbackRun) {
|
|
30079
|
+
// skip nested fast paths on the fallback, so user callbacks keep the at-most-twice bound
|
|
30080
|
+
ctx[COMPILE_FALLBACK] = true;
|
|
30081
|
+
result = fallbackRun({ value, issues: [] }, ctx);
|
|
30082
|
+
}
|
|
30083
|
+
else {
|
|
30084
|
+
result = schema._zod.run({ value, issues: [] }, ctx);
|
|
30085
|
+
}
|
|
30086
|
+
if (result instanceof Promise) {
|
|
30087
|
+
throw new $ZodAsyncError();
|
|
30088
|
+
}
|
|
30089
|
+
return result.issues.length === 0;
|
|
30090
|
+
}
|
|
30091
|
+
// no fast path: the compiler keeps async parses on the runtime, because a promise-returning callback that is not declared async compiles to a throw
|
|
30092
|
+
const parse_validateAsync = async (schema, value, _ctx) => {
|
|
30093
|
+
const ctx = _ctx
|
|
30094
|
+
? { ..._ctx, async: true, abortEarly: true }
|
|
30095
|
+
: { async: true, abortEarly: true };
|
|
30096
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
30097
|
+
if (result instanceof Promise)
|
|
30098
|
+
result = await result;
|
|
30099
|
+
return result.issues.length === 0;
|
|
30100
|
+
};
|
|
30101
|
+
const parse_encode = (_Err) => {
|
|
30102
|
+
const parse = parse_parse(_Err);
|
|
30103
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
30104
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
30105
|
+
return parse(schema, value, ctx, finalizeParams(fn, _params));
|
|
29569
30106
|
};
|
|
29570
|
-
|
|
29571
|
-
|
|
29572
|
-
|
|
29573
|
-
|
|
29574
|
-
|
|
30107
|
+
return fn;
|
|
30108
|
+
};
|
|
30109
|
+
const encode = /* @__PURE__*/ parse_encode($ZodRealError);
|
|
30110
|
+
const parse_decode = (_Err) => {
|
|
30111
|
+
const parse = parse_parse(_Err);
|
|
30112
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
30113
|
+
return parse(schema, value, _ctx, finalizeParams(fn, _params));
|
|
29575
30114
|
};
|
|
29576
|
-
|
|
29577
|
-
|
|
29578
|
-
|
|
29579
|
-
|
|
29580
|
-
|
|
29581
|
-
|
|
29582
|
-
|
|
29583
|
-
|
|
29584
|
-
case "invalid_type": {
|
|
29585
|
-
const expected = getTypeName(issue.expected);
|
|
29586
|
-
const receivedType = parsedType(issue.input);
|
|
29587
|
-
const received = getTypeName(receivedType, issue.input);
|
|
29588
|
-
return `Invalid input: expected ${expected}, received ${received}`;
|
|
29589
|
-
}
|
|
29590
|
-
case "invalid_value":
|
|
29591
|
-
if (issue.values.length === 1)
|
|
29592
|
-
return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
|
|
29593
|
-
return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
|
|
29594
|
-
case "too_big": {
|
|
29595
|
-
const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
|
|
29596
|
-
const sizing = getSizing(issue.origin);
|
|
29597
|
-
if (sizing)
|
|
29598
|
-
return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
|
29599
|
-
return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
|
|
29600
|
-
}
|
|
29601
|
-
case "too_small": {
|
|
29602
|
-
const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
|
|
29603
|
-
const sizing = getSizing(issue.origin);
|
|
29604
|
-
if (sizing) {
|
|
29605
|
-
return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
29606
|
-
}
|
|
29607
|
-
return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
|
|
29608
|
-
}
|
|
29609
|
-
case "invalid_format": {
|
|
29610
|
-
const _issue = issue;
|
|
29611
|
-
if (_issue.format === "starts_with") {
|
|
29612
|
-
return `Invalid string: must start with "${_issue.prefix}"`;
|
|
29613
|
-
}
|
|
29614
|
-
if (_issue.format === "ends_with")
|
|
29615
|
-
return `Invalid string: must end with "${_issue.suffix}"`;
|
|
29616
|
-
if (_issue.format === "includes")
|
|
29617
|
-
return `Invalid string: must include "${_issue.includes}"`;
|
|
29618
|
-
if (_issue.format === "regex")
|
|
29619
|
-
return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
29620
|
-
return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
|
|
29621
|
-
}
|
|
29622
|
-
case "not_multiple_of":
|
|
29623
|
-
return `Invalid number: must be a multiple of ${issue.divisor}`;
|
|
29624
|
-
case "unrecognized_keys":
|
|
29625
|
-
return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
|
|
29626
|
-
case "invalid_key":
|
|
29627
|
-
return `Invalid key in ${issue.origin}`;
|
|
29628
|
-
case "invalid_union":
|
|
29629
|
-
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
|
|
29630
|
-
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
|
29631
|
-
return `Invalid discriminator value. Expected ${opts}`;
|
|
29632
|
-
}
|
|
29633
|
-
if (issue.inclusive === false) {
|
|
29634
|
-
return "Invalid input: more than one option matched";
|
|
29635
|
-
}
|
|
29636
|
-
return "Invalid input";
|
|
29637
|
-
case "invalid_element":
|
|
29638
|
-
return `Invalid value in ${issue.origin}`;
|
|
29639
|
-
default:
|
|
29640
|
-
return `Invalid input`;
|
|
29641
|
-
}
|
|
30115
|
+
return fn;
|
|
30116
|
+
};
|
|
30117
|
+
const decode = /* @__PURE__*/ parse_decode($ZodRealError);
|
|
30118
|
+
const parse_encodeAsync = (_Err) => {
|
|
30119
|
+
const parseAsync = parse_parseAsync(_Err);
|
|
30120
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
30121
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
30122
|
+
return (await parseAsync(schema, value, ctx, finalizeParams(fn, _params)));
|
|
29642
30123
|
};
|
|
30124
|
+
return fn;
|
|
29643
30125
|
};
|
|
29644
|
-
|
|
29645
|
-
|
|
29646
|
-
|
|
30126
|
+
const encodeAsync = /* @__PURE__*/ parse_encodeAsync($ZodRealError);
|
|
30127
|
+
const parse_decodeAsync = (_Err) => {
|
|
30128
|
+
const parseAsync = parse_parseAsync(_Err);
|
|
30129
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
30130
|
+
return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
|
|
29647
30131
|
};
|
|
29648
|
-
|
|
30132
|
+
return fn;
|
|
30133
|
+
};
|
|
30134
|
+
const decodeAsync = /* @__PURE__*/ parse_decodeAsync($ZodRealError);
|
|
30135
|
+
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
30136
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
30137
|
+
return _safeParse(_Err)(schema, value, ctx);
|
|
30138
|
+
};
|
|
30139
|
+
const safeEncode = /* @__PURE__*/ _safeEncode($ZodRealError);
|
|
30140
|
+
const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
30141
|
+
return _safeParse(_Err)(schema, value, _ctx);
|
|
30142
|
+
};
|
|
30143
|
+
const safeDecode = /* @__PURE__*/ _safeDecode($ZodRealError);
|
|
30144
|
+
const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
30145
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
30146
|
+
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
30147
|
+
};
|
|
30148
|
+
const safeEncodeAsync = /* @__PURE__*/ _safeEncodeAsync($ZodRealError);
|
|
30149
|
+
const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
30150
|
+
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
30151
|
+
};
|
|
30152
|
+
const safeDecodeAsync = /* @__PURE__*/ _safeDecodeAsync($ZodRealError);
|
|
29649
30153
|
|
|
29650
30154
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/classic/errors.js
|
|
29651
30155
|
|
|
@@ -29732,6 +30236,7 @@ const parse_safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
|
29732
30236
|
|
|
29733
30237
|
|
|
29734
30238
|
|
|
30239
|
+
|
|
29735
30240
|
// Register English as the default locale on first ZodType construction. Hooked into the `ZodType` `$constructor` (rather than a top-level `config(en())` in `external.ts`) so bundlers honoring `sideEffects: false` can't tree-shake it out — see #5953, #5725. An explicit `z.config(z.locales.xx())` call wins regardless of order, since this only sets the default when none is present.
|
|
29736
30241
|
function _ensureDefaultLocale() {
|
|
29737
30242
|
if (!globalConfig.localeError)
|
|
@@ -29876,6 +30381,12 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
29876
30381
|
set spa(value) {
|
|
29877
30382
|
util_own(this, "spa", value);
|
|
29878
30383
|
},
|
|
30384
|
+
validate(data, params) {
|
|
30385
|
+
return validate(this, data, params);
|
|
30386
|
+
},
|
|
30387
|
+
validateAsync(data, params) {
|
|
30388
|
+
return parse_validateAsync(this, data, params);
|
|
30389
|
+
},
|
|
29879
30390
|
encode: function _encode(data, params) {
|
|
29880
30391
|
return classic_parse_encode(this, data, params, { callee: _encode });
|
|
29881
30392
|
},
|
|
@@ -29917,10 +30428,11 @@ const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
|
|
|
29917
30428
|
$ZodString.init(inst, def);
|
|
29918
30429
|
ZodType.init(inst, def);
|
|
29919
30430
|
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
29920
|
-
|
|
29921
|
-
|
|
29922
|
-
inst
|
|
29923
|
-
inst
|
|
30431
|
+
},
|
|
30432
|
+
/*@__PURE__*/ derived({
|
|
30433
|
+
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
30434
|
+
minLength: (inst) => aggregateChecks(inst).minimum ?? null,
|
|
30435
|
+
maxLength: (inst) => aggregateChecks(inst).maximum ?? null,
|
|
29924
30436
|
}, {
|
|
29925
30437
|
regex(...args) {
|
|
29926
30438
|
return this.check(_regex(...args));
|
|
@@ -29967,7 +30479,7 @@ const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
|
|
|
29967
30479
|
slugify() {
|
|
29968
30480
|
return this.check(_slugify());
|
|
29969
30481
|
},
|
|
29970
|
-
});
|
|
30482
|
+
}));
|
|
29971
30483
|
const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
|
|
29972
30484
|
$ZodString.init(inst, def);
|
|
29973
30485
|
_ZodString.init(inst, def);
|
|
@@ -30119,8 +30631,8 @@ function schemas_url(params) {
|
|
|
30119
30631
|
}
|
|
30120
30632
|
function httpUrl(params) {
|
|
30121
30633
|
return core._url(ZodURL, {
|
|
30122
|
-
protocol:
|
|
30123
|
-
hostname:
|
|
30634
|
+
protocol: regexes.httpProtocol,
|
|
30635
|
+
hostname: regexes.domain,
|
|
30124
30636
|
...util.normalizeParams(params),
|
|
30125
30637
|
});
|
|
30126
30638
|
}
|
|
@@ -30261,6 +30773,13 @@ const ZodCreditCard = /*@__PURE__*/ (/* unused pure expression or super */ null
|
|
|
30261
30773
|
function schemas_creditCard(params) {
|
|
30262
30774
|
return core._creditCard(ZodCreditCard, params);
|
|
30263
30775
|
}
|
|
30776
|
+
const ZodIBAN = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("ZodIBAN", (inst, def) => {
|
|
30777
|
+
core.$ZodIBAN.init(inst, def);
|
|
30778
|
+
ZodStringFormat.init(inst, def);
|
|
30779
|
+
})));
|
|
30780
|
+
function schemas_iban(params) {
|
|
30781
|
+
return core._iban(ZodIBAN, params);
|
|
30782
|
+
}
|
|
30264
30783
|
const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
|
|
30265
30784
|
// ZodStringFormat.init(inst, def);
|
|
30266
30785
|
$ZodJWT.init(inst, def);
|
|
@@ -30278,10 +30797,13 @@ function stringFormat(format, fnOrRegex, _params = {}) {
|
|
|
30278
30797
|
return core._stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
|
|
30279
30798
|
}
|
|
30280
30799
|
function schemas_hostname(_params) {
|
|
30281
|
-
return core._stringFormat(ZodCustomStringFormat, "hostname",
|
|
30800
|
+
return core._stringFormat(ZodCustomStringFormat, "hostname", regexes.hostname, _params);
|
|
30282
30801
|
}
|
|
30283
30802
|
function schemas_hex(_params) {
|
|
30284
|
-
return core._stringFormat(ZodCustomStringFormat, "hex",
|
|
30803
|
+
return core._stringFormat(ZodCustomStringFormat, "hex", regexes.hex, _params);
|
|
30804
|
+
}
|
|
30805
|
+
function schemas_currencyCode(_params) {
|
|
30806
|
+
return core._stringFormat(ZodCustomStringFormat, "currency_code", regexes.currencyCode, _params);
|
|
30285
30807
|
}
|
|
30286
30808
|
function hash(alg, params) {
|
|
30287
30809
|
const enc = params?.enc ?? "hex";
|
|
@@ -30295,14 +30817,22 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
|
|
|
30295
30817
|
$ZodNumber.init(inst, def);
|
|
30296
30818
|
ZodType.init(inst, def);
|
|
30297
30819
|
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
30298
|
-
const bag = inst._zod.bag;
|
|
30299
|
-
inst.minValue =
|
|
30300
|
-
Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
30301
|
-
inst.maxValue =
|
|
30302
|
-
Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
30303
|
-
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
30304
30820
|
inst.isFinite = true;
|
|
30305
|
-
|
|
30821
|
+
},
|
|
30822
|
+
/*@__PURE__*/ derived({
|
|
30823
|
+
minValue: (inst) => {
|
|
30824
|
+
const { minimum, exclusiveMinimum } = aggregateChecks(inst);
|
|
30825
|
+
return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
|
|
30826
|
+
},
|
|
30827
|
+
maxValue: (inst) => {
|
|
30828
|
+
const { maximum, exclusiveMaximum } = aggregateChecks(inst);
|
|
30829
|
+
return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
|
|
30830
|
+
},
|
|
30831
|
+
isInt: (inst) => {
|
|
30832
|
+
const { isInt, multipleOf } = aggregateChecks(inst);
|
|
30833
|
+
return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
|
|
30834
|
+
},
|
|
30835
|
+
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
30306
30836
|
}, {
|
|
30307
30837
|
gt(value, params) {
|
|
30308
30838
|
return this.check(_gt(value, params));
|
|
@@ -30349,7 +30879,7 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
|
|
|
30349
30879
|
finite() {
|
|
30350
30880
|
return this;
|
|
30351
30881
|
},
|
|
30352
|
-
});
|
|
30882
|
+
}));
|
|
30353
30883
|
function schemas_number(params) {
|
|
30354
30884
|
return _number(ZodNumber, params);
|
|
30355
30885
|
}
|
|
@@ -30384,10 +30914,11 @@ const ZodBigInt = /*@__PURE__*/ (/* unused pure expression or super */ null && (
|
|
|
30384
30914
|
core.$ZodBigInt.init(inst, def);
|
|
30385
30915
|
ZodType.init(inst, def);
|
|
30386
30916
|
inst._zod.processJSONSchema = (ctx, json, params) => processors.bigintProcessor(inst, ctx, json, params);
|
|
30387
|
-
|
|
30388
|
-
|
|
30389
|
-
inst
|
|
30390
|
-
inst
|
|
30917
|
+
},
|
|
30918
|
+
/*@__PURE__*/ util.derived({
|
|
30919
|
+
minValue: (inst) => processors.aggregateChecks(inst).minimum ?? null,
|
|
30920
|
+
maxValue: (inst) => processors.aggregateChecks(inst).maximum ?? null,
|
|
30921
|
+
format: (inst) => processors.aggregateChecks(inst).format ?? null,
|
|
30391
30922
|
}, {
|
|
30392
30923
|
gte(value, params) {
|
|
30393
30924
|
return this.check(checks.gte(value, params));
|
|
@@ -30422,7 +30953,7 @@ const ZodBigInt = /*@__PURE__*/ (/* unused pure expression or super */ null && (
|
|
|
30422
30953
|
multipleOf(value, params) {
|
|
30423
30954
|
return this.check(checks.multipleOf(value, params));
|
|
30424
30955
|
},
|
|
30425
|
-
})));
|
|
30956
|
+
}))));
|
|
30426
30957
|
function schemas_bigint(params) {
|
|
30427
30958
|
return core._bigint(ZodBigInt, params);
|
|
30428
30959
|
}
|
|
@@ -30501,10 +31032,17 @@ const ZodDate = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
|
|
|
30501
31032
|
inst._zod.processJSONSchema = (ctx, json, params) => processors.dateProcessor(inst, ctx, json, params);
|
|
30502
31033
|
inst.min = (value, params) => inst.check(checks.gte(value, params));
|
|
30503
31034
|
inst.max = (value, params) => inst.check(checks.lte(value, params));
|
|
30504
|
-
|
|
30505
|
-
|
|
30506
|
-
|
|
30507
|
-
})
|
|
31035
|
+
},
|
|
31036
|
+
/*@__PURE__*/ util.derived({
|
|
31037
|
+
minDate: (inst) => {
|
|
31038
|
+
const { minimum } = processors.aggregateChecks(inst);
|
|
31039
|
+
return minimum ? new Date(minimum) : null;
|
|
31040
|
+
},
|
|
31041
|
+
maxDate: (inst) => {
|
|
31042
|
+
const { maximum } = processors.aggregateChecks(inst);
|
|
31043
|
+
return maximum ? new Date(maximum) : null;
|
|
31044
|
+
},
|
|
31045
|
+
}, {}))));
|
|
30508
31046
|
function schemas_date(params) {
|
|
30509
31047
|
return core._date(ZodDate, params);
|
|
30510
31048
|
}
|
|
@@ -30550,19 +31088,20 @@ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
|
30550
31088
|
return schemas_enum(Object.keys(this._zod.def.shape));
|
|
30551
31089
|
},
|
|
30552
31090
|
catchall(catchall) {
|
|
30553
|
-
|
|
31091
|
+
// `mergeDefs` rather than a spread: spreading reads `shape`, and resolving it can mint a whole fresh subtree
|
|
31092
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: catchall }));
|
|
30554
31093
|
},
|
|
30555
31094
|
passthrough() {
|
|
30556
|
-
return this.clone(
|
|
31095
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: schemas_unknown() }));
|
|
30557
31096
|
},
|
|
30558
31097
|
loose() {
|
|
30559
|
-
return this.clone(
|
|
31098
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: schemas_unknown() }));
|
|
30560
31099
|
},
|
|
30561
31100
|
strict() {
|
|
30562
|
-
return this.clone(
|
|
31101
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
|
|
30563
31102
|
},
|
|
30564
31103
|
strip() {
|
|
30565
|
-
return this.clone(
|
|
31104
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: undefined }));
|
|
30566
31105
|
},
|
|
30567
31106
|
extend(incoming) {
|
|
30568
31107
|
return extend(this, incoming);
|
|
@@ -30571,7 +31110,7 @@ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
|
30571
31110
|
return safeExtend(this, incoming);
|
|
30572
31111
|
},
|
|
30573
31112
|
merge(other) {
|
|
30574
|
-
return
|
|
31113
|
+
return util_merge(this, other);
|
|
30575
31114
|
},
|
|
30576
31115
|
pick(mask) {
|
|
30577
31116
|
return pick(this, mask);
|
|
@@ -30778,7 +31317,7 @@ const ZodSet = /*@__PURE__*/ (/* unused pure expression or super */ null && (cor
|
|
|
30778
31317
|
inst.max = (...args) => inst.check(core._maxSize(...args));
|
|
30779
31318
|
inst.size = (...args) => inst.check(core._size(...args));
|
|
30780
31319
|
})));
|
|
30781
|
-
function
|
|
31320
|
+
function set(valueType, params) {
|
|
30782
31321
|
return new ZodSet({
|
|
30783
31322
|
type: "set",
|
|
30784
31323
|
valueType: valueType,
|
|
@@ -30790,7 +31329,8 @@ const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
|
|
|
30790
31329
|
ZodType.init(inst, def);
|
|
30791
31330
|
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
30792
31331
|
inst.enum = def.entries;
|
|
30793
|
-
|
|
31332
|
+
// reuse the parsed value set so a numeric TS enum's reverse-mapping keys stay out
|
|
31333
|
+
inst.options = [...inst._zod.values];
|
|
30794
31334
|
const keys = new Set(Object.keys(def.entries));
|
|
30795
31335
|
inst.extract = (values, params) => {
|
|
30796
31336
|
const newEntries = {};
|
|
@@ -31172,8 +31712,16 @@ function superRefine(fn, params) {
|
|
|
31172
31712
|
// Re-export describe and meta from core
|
|
31173
31713
|
const schemas_describe = describe;
|
|
31174
31714
|
const schemas_meta = api_meta;
|
|
31715
|
+
const ZodInstanceOf = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("ZodInstanceOf", (inst, def) => {
|
|
31716
|
+
ZodCustom.init(inst, def);
|
|
31717
|
+
}, {
|
|
31718
|
+
properties(shape, params) {
|
|
31719
|
+
// asserts in place, so the narrowed output type is truthful without a wrapper
|
|
31720
|
+
return this.check(core._properties(shape, params));
|
|
31721
|
+
},
|
|
31722
|
+
})));
|
|
31175
31723
|
function _instanceof(cls, params = {}) {
|
|
31176
|
-
const inst = new
|
|
31724
|
+
const inst = new ZodInstanceOf({
|
|
31177
31725
|
type: "custom",
|
|
31178
31726
|
check: "custom",
|
|
31179
31727
|
fn: (data) => data instanceof cls,
|