@keycloakify/angular 21.0.0-rc.2 → 21.0.0-rc.3
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/bin/187.index.js +64 -70
- package/bin/476.index.js +62 -68
- package/bin/{343.index.js → 644.index.js} +2287 -1200
- package/bin/671.index.js +62 -68
- package/bin/942.index.js +62 -68
- package/bin/index.js +12 -9
- package/fesm2022/keycloakify-angular-account-directives-kc-class.mjs +3 -3
- package/fesm2022/keycloakify-angular-account-pages-account.mjs +3 -3
- package/fesm2022/keycloakify-angular-account-pages-applications.mjs +3 -3
- package/fesm2022/keycloakify-angular-account-pages-federatedIdentity.mjs +3 -3
- package/fesm2022/keycloakify-angular-account-pages-log.mjs +3 -3
- package/fesm2022/keycloakify-angular-account-pages-password.mjs +10 -10
- package/fesm2022/keycloakify-angular-account-pages-password.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-account-pages-sessions.mjs +3 -3
- package/fesm2022/keycloakify-angular-account-pages-totp.mjs +3 -3
- package/fesm2022/keycloakify-angular-account-services-account-resource-injector.mjs +3 -3
- package/fesm2022/keycloakify-angular-account-services-i18n.mjs +3 -3
- package/fesm2022/keycloakify-angular-account-template.mjs +4 -4
- package/fesm2022/keycloakify-angular-account-template.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-lib-directives-attributes.mjs +4 -4
- package/fesm2022/keycloakify-angular-lib-directives-attributes.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-lib-pipes-input-type.mjs +3 -3
- package/fesm2022/keycloakify-angular-lib-pipes-is-array-with-empty-object.mjs +3 -3
- package/fesm2022/keycloakify-angular-lib-pipes-kc-sanitize.mjs +3 -3
- package/fesm2022/keycloakify-angular-lib-pipes-to-array.mjs +3 -3
- package/fesm2022/keycloakify-angular-lib-pipes-to-number.mjs +3 -3
- package/fesm2022/keycloakify-angular-lib-services-resource-injector.mjs +3 -3
- package/fesm2022/keycloakify-angular-login-components-add-remove-buttons-multi-valued-attribute.mjs +8 -8
- package/fesm2022/keycloakify-angular-login-components-add-remove-buttons-multi-valued-attribute.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-components-field-errors.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-components-field-errors.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-components-group-label.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-components-group-label.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-components-input-field-by-type.mjs +7 -7
- package/fesm2022/keycloakify-angular-login-components-input-field-by-type.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-components-input-tag-selects.mjs +8 -8
- package/fesm2022/keycloakify-angular-login-components-input-tag-selects.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-components-input-tag.mjs +9 -9
- package/fesm2022/keycloakify-angular-login-components-input-tag.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-components-logout-other-sessions.mjs +3 -3
- package/fesm2022/keycloakify-angular-login-components-password-wrapper.mjs +5 -5
- package/fesm2022/keycloakify-angular-login-components-password-wrapper.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-components-select-tag.mjs +8 -8
- package/fesm2022/keycloakify-angular-login-components-select-tag.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-components-textarea-tag.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-components-textarea-tag.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-components-user-profile-form-fields.mjs +3 -3
- package/fesm2022/keycloakify-angular-login-directives-kc-class.mjs +3 -3
- package/fesm2022/keycloakify-angular-login-pages-code.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-code.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-delete-account-confirm.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-delete-account-confirm.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-delete-credential.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-delete-credential.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-error.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-error.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-frontchannel-logout.mjs +7 -7
- package/fesm2022/keycloakify-angular-login-pages-frontchannel-logout.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-idp-review-user-profile.mjs +7 -7
- package/fesm2022/keycloakify-angular-login-pages-idp-review-user-profile.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-info.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-info.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-config-totp.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-config-totp.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-idp-link-confirm-override.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-idp-link-confirm-override.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-idp-link-confirm.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-idp-link-confirm.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-idp-link-email.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-idp-link-email.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-oauth-grant.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-oauth-grant.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-oauth2-device-verify-user-code.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-oauth2-device-verify-user-code.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-otp.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-otp.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-page-expired.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-page-expired.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-passkeys-conditional-authenticate.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-passkeys-conditional-authenticate.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-password.mjs +7 -7
- package/fesm2022/keycloakify-angular-login-pages-login-password.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-recovery-authn-code-config.mjs +7 -7
- package/fesm2022/keycloakify-angular-login-pages-login-recovery-authn-code-config.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-recovery-authn-code-input.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-recovery-authn-code-input.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-reset-otp.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-reset-otp.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-reset-password.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-reset-password.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-update-password.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-update-password.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-update-profile.mjs +7 -7
- package/fesm2022/keycloakify-angular-login-pages-login-update-profile.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-username.mjs +7 -7
- package/fesm2022/keycloakify-angular-login-pages-login-username.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-verify-email.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-verify-email.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login-x509-info.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-login-x509-info.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-login.mjs +7 -7
- package/fesm2022/keycloakify-angular-login-pages-login.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-logout-confirm.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-logout-confirm.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-register.mjs +8 -8
- package/fesm2022/keycloakify-angular-login-pages-register.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-saml-post-form.mjs +7 -7
- package/fesm2022/keycloakify-angular-login-pages-saml-post-form.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-select-authenticator.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-select-authenticator.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-terms.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-terms.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-update-email.mjs +7 -7
- package/fesm2022/keycloakify-angular-login-pages-update-email.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-webauthn-authenticate.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-webauthn-authenticate.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-webauthn-error.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-webauthn-error.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-pages-webauthn-register.mjs +6 -6
- package/fesm2022/keycloakify-angular-login-pages-webauthn-register.mjs.map +1 -1
- package/fesm2022/keycloakify-angular-login-services-i18n.mjs +3 -3
- package/fesm2022/keycloakify-angular-login-services-login-resource-injector.mjs +3 -3
- package/fesm2022/keycloakify-angular-login-services-user-profile-form.mjs +3 -3
- package/fesm2022/keycloakify-angular-login-template.mjs +8 -8
- package/fesm2022/keycloakify-angular-login-template.mjs.map +1 -1
- package/package.json +1 -1
- package/src/bin/tools/getThisCodebaseRootDirPath.ts +7 -0
- package/src/bin/tools/nodeModulesBinDirPath.ts +34 -1
- package/src/bin/tools/runPrettier.ts +43 -39
- package/src/bin/tools/readThisNpmPackageVersion.ts +0 -24
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const id =
|
|
2
|
-
export const ids = [
|
|
1
|
+
export const id = 644;
|
|
2
|
+
export const ids = [644];
|
|
3
3
|
export const modules = {
|
|
4
4
|
|
|
5
5
|
/***/ 94:
|
|
@@ -29,7 +29,7 @@ function symToStr(wrap) {
|
|
|
29
29
|
|
|
30
30
|
/***/ }),
|
|
31
31
|
|
|
32
|
-
/***/
|
|
32
|
+
/***/ 788:
|
|
33
33
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
34
34
|
|
|
35
35
|
|
|
@@ -41,7 +41,288 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
41
41
|
L5J: () => (/* reexport */ unknown)
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
// UNUSED EXPORTS: $brand, $input, $output, NEVER, TimePrecision, ZodAny, ZodArray, ZodBase64, ZodBase64URL, ZodBigInt, ZodBigIntFormat, ZodBoolean, ZodCIDRv4, ZodCIDRv6, ZodCUID, ZodCUID2, ZodCatch, ZodCodec, ZodCustom, ZodCustomStringFormat, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodE164, ZodEmail, ZodEmoji, ZodEnum, ZodError, ZodFile, ZodFirstPartyTypeKind, ZodFunction, ZodGUID, ZodIPv4, ZodIPv6, ZodISODate, ZodISODateTime, ZodISODuration, ZodISOTime, ZodIntersection, ZodIssueCode, ZodJWT, ZodKSUID, ZodLazy, ZodLiteral, ZodMAC, ZodMap, ZodNaN, ZodNanoID, ZodNever, ZodNonOptional, ZodNull, ZodNullable, ZodNumber, ZodNumberFormat, ZodObject, ZodOptional, ZodPipe, ZodPrefault, ZodPromise, ZodReadonly, ZodRealError, ZodRecord, ZodSet, ZodString, ZodStringFormat, ZodSuccess, ZodSymbol, ZodTemplateLiteral, ZodTransform, ZodTuple, ZodType, ZodULID, ZodURL, ZodUUID, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, ZodXID, _ZodString, _default, _function, any, array, base64, base64url, bigint, boolean, catch, check, cidrv4, cidrv6, clone, codec, coerce, config, core, cuid, cuid2, custom, date, decode, decodeAsync, describe, discriminatedUnion, e164, email, emoji, encode, encodeAsync, endsWith, enum, file, flattenError, float32, float64, formatError, function, getErrorMap, globalRegistry, gt, gte, guid, hash, hex, hostname, httpUrl, includes, instanceof, int, int32, int64, intersection, ipv4, ipv6, iso, json, jwt, keyof, ksuid, lazy, length, literal, locales, looseObject, lowercase, lt, lte, mac, map, maxLength, maxSize, meta, mime, minLength, minSize, multipleOf, nan, nanoid, nativeEnum, negative, never, nonnegative, nonoptional, nonpositive, normalize, null, nullable, nullish, number, optional, overwrite, parse, parseAsync, partialRecord, pipe, positive, prefault, preprocess, prettifyError, promise, property, readonly, refine, regex, regexes, registry, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, setErrorMap, size, slugify, startsWith, strictObject, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, toJSONSchema, toLowerCase, toUpperCase, transform, treeifyError, trim, tuple, uint32, uint64, ulid, undefined, union, uppercase, url, util, uuid, uuidv4, uuidv6, uuidv7, void, xid
|
|
44
|
+
// UNUSED EXPORTS: $brand, $input, $output, NEVER, TimePrecision, ZodAny, ZodArray, ZodBase64, ZodBase64URL, ZodBigInt, ZodBigIntFormat, ZodBoolean, ZodCIDRv4, ZodCIDRv6, ZodCUID, ZodCUID2, ZodCatch, ZodCodec, ZodCustom, ZodCustomStringFormat, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodE164, ZodEmail, ZodEmoji, ZodEnum, ZodError, ZodFile, ZodFirstPartyTypeKind, ZodFunction, ZodGUID, ZodIPv4, ZodIPv6, ZodISODate, ZodISODateTime, ZodISODuration, ZodISOTime, ZodIntersection, ZodIssueCode, ZodJWT, ZodKSUID, ZodLazy, ZodLiteral, ZodMAC, ZodMap, ZodNaN, ZodNanoID, ZodNever, ZodNonOptional, ZodNull, ZodNullable, ZodNumber, ZodNumberFormat, ZodObject, ZodOptional, ZodPipe, ZodPrefault, ZodPromise, ZodReadonly, ZodRealError, ZodRecord, ZodSet, ZodString, ZodStringFormat, ZodSuccess, ZodSymbol, ZodTemplateLiteral, ZodTransform, ZodTuple, ZodType, ZodULID, ZodURL, ZodUUID, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, ZodXID, ZodXor, _ZodString, _default, _function, any, array, base64, base64url, bigint, boolean, catch, check, cidrv4, cidrv6, clone, codec, coerce, config, core, cuid, cuid2, custom, date, decode, decodeAsync, describe, discriminatedUnion, e164, email, emoji, encode, encodeAsync, endsWith, enum, file, flattenError, float32, float64, formatError, fromJSONSchema, function, getErrorMap, globalRegistry, gt, gte, guid, hash, hex, hostname, httpUrl, includes, instanceof, int, int32, int64, intersection, ipv4, ipv6, iso, json, jwt, keyof, ksuid, lazy, length, literal, locales, looseObject, looseRecord, lowercase, lt, lte, mac, map, maxLength, maxSize, meta, mime, minLength, minSize, multipleOf, nan, nanoid, nativeEnum, negative, never, nonnegative, nonoptional, nonpositive, normalize, null, nullable, nullish, number, optional, overwrite, parse, parseAsync, partialRecord, pipe, positive, prefault, preprocess, prettifyError, promise, property, readonly, refine, regex, regexes, registry, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, setErrorMap, size, slugify, startsWith, strictObject, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, toJSONSchema, toLowerCase, toUpperCase, transform, treeifyError, trim, tuple, uint32, uint64, ulid, undefined, union, uppercase, url, util, uuid, uuidv4, uuidv6, uuidv7, void, xid, xor
|
|
45
|
+
|
|
46
|
+
// NAMESPACE OBJECT: ./node_modules/zod/v4/core/regexes.js
|
|
47
|
+
var regexes_namespaceObject = {};
|
|
48
|
+
__webpack_require__.r(regexes_namespaceObject);
|
|
49
|
+
__webpack_require__.d(regexes_namespaceObject, {
|
|
50
|
+
base64: () => (base64),
|
|
51
|
+
base64url: () => (base64url),
|
|
52
|
+
bigint: () => (bigint),
|
|
53
|
+
boolean: () => (regexes_boolean),
|
|
54
|
+
browserEmail: () => (browserEmail),
|
|
55
|
+
cidrv4: () => (cidrv4),
|
|
56
|
+
cidrv6: () => (cidrv6),
|
|
57
|
+
cuid: () => (cuid),
|
|
58
|
+
cuid2: () => (cuid2),
|
|
59
|
+
date: () => (date),
|
|
60
|
+
datetime: () => (datetime),
|
|
61
|
+
domain: () => (domain),
|
|
62
|
+
duration: () => (duration),
|
|
63
|
+
e164: () => (e164),
|
|
64
|
+
email: () => (email),
|
|
65
|
+
emoji: () => (emoji),
|
|
66
|
+
extendedDuration: () => (extendedDuration),
|
|
67
|
+
guid: () => (guid),
|
|
68
|
+
hex: () => (hex),
|
|
69
|
+
hostname: () => (hostname),
|
|
70
|
+
html5Email: () => (html5Email),
|
|
71
|
+
idnEmail: () => (idnEmail),
|
|
72
|
+
integer: () => (integer),
|
|
73
|
+
ipv4: () => (ipv4),
|
|
74
|
+
ipv6: () => (ipv6),
|
|
75
|
+
ksuid: () => (ksuid),
|
|
76
|
+
lowercase: () => (lowercase),
|
|
77
|
+
mac: () => (mac),
|
|
78
|
+
md5_base64: () => (md5_base64),
|
|
79
|
+
md5_base64url: () => (md5_base64url),
|
|
80
|
+
md5_hex: () => (md5_hex),
|
|
81
|
+
nanoid: () => (nanoid),
|
|
82
|
+
"null": () => (_null),
|
|
83
|
+
number: () => (number),
|
|
84
|
+
rfc5322Email: () => (rfc5322Email),
|
|
85
|
+
sha1_base64: () => (sha1_base64),
|
|
86
|
+
sha1_base64url: () => (sha1_base64url),
|
|
87
|
+
sha1_hex: () => (sha1_hex),
|
|
88
|
+
sha256_base64: () => (sha256_base64),
|
|
89
|
+
sha256_base64url: () => (sha256_base64url),
|
|
90
|
+
sha256_hex: () => (sha256_hex),
|
|
91
|
+
sha384_base64: () => (sha384_base64),
|
|
92
|
+
sha384_base64url: () => (sha384_base64url),
|
|
93
|
+
sha384_hex: () => (sha384_hex),
|
|
94
|
+
sha512_base64: () => (sha512_base64),
|
|
95
|
+
sha512_base64url: () => (sha512_base64url),
|
|
96
|
+
sha512_hex: () => (sha512_hex),
|
|
97
|
+
string: () => (string),
|
|
98
|
+
time: () => (time),
|
|
99
|
+
ulid: () => (ulid),
|
|
100
|
+
undefined: () => (_undefined),
|
|
101
|
+
unicodeEmail: () => (unicodeEmail),
|
|
102
|
+
uppercase: () => (uppercase),
|
|
103
|
+
uuid: () => (uuid),
|
|
104
|
+
uuid4: () => (uuid4),
|
|
105
|
+
uuid6: () => (uuid6),
|
|
106
|
+
uuid7: () => (uuid7),
|
|
107
|
+
xid: () => (xid)
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// NAMESPACE OBJECT: ./node_modules/zod/v4/classic/checks.js
|
|
111
|
+
var classic_checks_namespaceObject = {};
|
|
112
|
+
__webpack_require__.r(classic_checks_namespaceObject);
|
|
113
|
+
__webpack_require__.d(classic_checks_namespaceObject, {
|
|
114
|
+
endsWith: () => (_endsWith),
|
|
115
|
+
gt: () => (_gt),
|
|
116
|
+
gte: () => (_gte),
|
|
117
|
+
includes: () => (_includes),
|
|
118
|
+
length: () => (_length),
|
|
119
|
+
lowercase: () => (_lowercase),
|
|
120
|
+
lt: () => (_lt),
|
|
121
|
+
lte: () => (_lte),
|
|
122
|
+
maxLength: () => (_maxLength),
|
|
123
|
+
maxSize: () => (_maxSize),
|
|
124
|
+
mime: () => (_mime),
|
|
125
|
+
minLength: () => (_minLength),
|
|
126
|
+
minSize: () => (_minSize),
|
|
127
|
+
multipleOf: () => (_multipleOf),
|
|
128
|
+
negative: () => (_negative),
|
|
129
|
+
nonnegative: () => (_nonnegative),
|
|
130
|
+
nonpositive: () => (_nonpositive),
|
|
131
|
+
normalize: () => (_normalize),
|
|
132
|
+
overwrite: () => (_overwrite),
|
|
133
|
+
positive: () => (_positive),
|
|
134
|
+
property: () => (_property),
|
|
135
|
+
regex: () => (_regex),
|
|
136
|
+
size: () => (_size),
|
|
137
|
+
slugify: () => (_slugify),
|
|
138
|
+
startsWith: () => (_startsWith),
|
|
139
|
+
toLowerCase: () => (_toLowerCase),
|
|
140
|
+
toUpperCase: () => (_toUpperCase),
|
|
141
|
+
trim: () => (_trim),
|
|
142
|
+
uppercase: () => (_uppercase)
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// NAMESPACE OBJECT: ./node_modules/zod/v4/classic/iso.js
|
|
146
|
+
var iso_namespaceObject = {};
|
|
147
|
+
__webpack_require__.r(iso_namespaceObject);
|
|
148
|
+
__webpack_require__.d(iso_namespaceObject, {
|
|
149
|
+
ZodISODate: () => (ZodISODate),
|
|
150
|
+
ZodISODateTime: () => (ZodISODateTime),
|
|
151
|
+
ZodISODuration: () => (ZodISODuration),
|
|
152
|
+
ZodISOTime: () => (ZodISOTime),
|
|
153
|
+
date: () => (iso_date),
|
|
154
|
+
datetime: () => (iso_datetime),
|
|
155
|
+
duration: () => (iso_duration),
|
|
156
|
+
time: () => (iso_time)
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// NAMESPACE OBJECT: ./node_modules/zod/v4/classic/schemas.js
|
|
160
|
+
var classic_schemas_namespaceObject = {};
|
|
161
|
+
__webpack_require__.r(classic_schemas_namespaceObject);
|
|
162
|
+
__webpack_require__.d(classic_schemas_namespaceObject, {
|
|
163
|
+
ZodAny: () => (ZodAny),
|
|
164
|
+
ZodArray: () => (ZodArray),
|
|
165
|
+
ZodBase64: () => (ZodBase64),
|
|
166
|
+
ZodBase64URL: () => (ZodBase64URL),
|
|
167
|
+
ZodBigInt: () => (ZodBigInt),
|
|
168
|
+
ZodBigIntFormat: () => (ZodBigIntFormat),
|
|
169
|
+
ZodBoolean: () => (ZodBoolean),
|
|
170
|
+
ZodCIDRv4: () => (ZodCIDRv4),
|
|
171
|
+
ZodCIDRv6: () => (ZodCIDRv6),
|
|
172
|
+
ZodCUID: () => (ZodCUID),
|
|
173
|
+
ZodCUID2: () => (ZodCUID2),
|
|
174
|
+
ZodCatch: () => (ZodCatch),
|
|
175
|
+
ZodCodec: () => (ZodCodec),
|
|
176
|
+
ZodCustom: () => (ZodCustom),
|
|
177
|
+
ZodCustomStringFormat: () => (ZodCustomStringFormat),
|
|
178
|
+
ZodDate: () => (ZodDate),
|
|
179
|
+
ZodDefault: () => (ZodDefault),
|
|
180
|
+
ZodDiscriminatedUnion: () => (ZodDiscriminatedUnion),
|
|
181
|
+
ZodE164: () => (ZodE164),
|
|
182
|
+
ZodEmail: () => (ZodEmail),
|
|
183
|
+
ZodEmoji: () => (ZodEmoji),
|
|
184
|
+
ZodEnum: () => (ZodEnum),
|
|
185
|
+
ZodFile: () => (ZodFile),
|
|
186
|
+
ZodFunction: () => (ZodFunction),
|
|
187
|
+
ZodGUID: () => (ZodGUID),
|
|
188
|
+
ZodIPv4: () => (ZodIPv4),
|
|
189
|
+
ZodIPv6: () => (ZodIPv6),
|
|
190
|
+
ZodIntersection: () => (ZodIntersection),
|
|
191
|
+
ZodJWT: () => (ZodJWT),
|
|
192
|
+
ZodKSUID: () => (ZodKSUID),
|
|
193
|
+
ZodLazy: () => (ZodLazy),
|
|
194
|
+
ZodLiteral: () => (ZodLiteral),
|
|
195
|
+
ZodMAC: () => (ZodMAC),
|
|
196
|
+
ZodMap: () => (ZodMap),
|
|
197
|
+
ZodNaN: () => (ZodNaN),
|
|
198
|
+
ZodNanoID: () => (ZodNanoID),
|
|
199
|
+
ZodNever: () => (ZodNever),
|
|
200
|
+
ZodNonOptional: () => (ZodNonOptional),
|
|
201
|
+
ZodNull: () => (ZodNull),
|
|
202
|
+
ZodNullable: () => (ZodNullable),
|
|
203
|
+
ZodNumber: () => (ZodNumber),
|
|
204
|
+
ZodNumberFormat: () => (ZodNumberFormat),
|
|
205
|
+
ZodObject: () => (ZodObject),
|
|
206
|
+
ZodOptional: () => (ZodOptional),
|
|
207
|
+
ZodPipe: () => (ZodPipe),
|
|
208
|
+
ZodPrefault: () => (ZodPrefault),
|
|
209
|
+
ZodPromise: () => (ZodPromise),
|
|
210
|
+
ZodReadonly: () => (ZodReadonly),
|
|
211
|
+
ZodRecord: () => (ZodRecord),
|
|
212
|
+
ZodSet: () => (ZodSet),
|
|
213
|
+
ZodString: () => (ZodString),
|
|
214
|
+
ZodStringFormat: () => (ZodStringFormat),
|
|
215
|
+
ZodSuccess: () => (ZodSuccess),
|
|
216
|
+
ZodSymbol: () => (ZodSymbol),
|
|
217
|
+
ZodTemplateLiteral: () => (ZodTemplateLiteral),
|
|
218
|
+
ZodTransform: () => (ZodTransform),
|
|
219
|
+
ZodTuple: () => (ZodTuple),
|
|
220
|
+
ZodType: () => (ZodType),
|
|
221
|
+
ZodULID: () => (ZodULID),
|
|
222
|
+
ZodURL: () => (ZodURL),
|
|
223
|
+
ZodUUID: () => (ZodUUID),
|
|
224
|
+
ZodUndefined: () => (ZodUndefined),
|
|
225
|
+
ZodUnion: () => (ZodUnion),
|
|
226
|
+
ZodUnknown: () => (ZodUnknown),
|
|
227
|
+
ZodVoid: () => (ZodVoid),
|
|
228
|
+
ZodXID: () => (ZodXID),
|
|
229
|
+
ZodXor: () => (ZodXor),
|
|
230
|
+
_ZodString: () => (_ZodString),
|
|
231
|
+
_default: () => (schemas_default),
|
|
232
|
+
_function: () => (_function),
|
|
233
|
+
any: () => (any),
|
|
234
|
+
array: () => (array),
|
|
235
|
+
base64: () => (schemas_base64),
|
|
236
|
+
base64url: () => (schemas_base64url),
|
|
237
|
+
bigint: () => (schemas_bigint),
|
|
238
|
+
boolean: () => (schemas_boolean),
|
|
239
|
+
"catch": () => (schemas_catch),
|
|
240
|
+
check: () => (check),
|
|
241
|
+
cidrv4: () => (schemas_cidrv4),
|
|
242
|
+
cidrv6: () => (schemas_cidrv6),
|
|
243
|
+
codec: () => (codec),
|
|
244
|
+
cuid: () => (schemas_cuid),
|
|
245
|
+
cuid2: () => (schemas_cuid2),
|
|
246
|
+
custom: () => (custom),
|
|
247
|
+
date: () => (schemas_date),
|
|
248
|
+
describe: () => (schemas_describe),
|
|
249
|
+
discriminatedUnion: () => (discriminatedUnion),
|
|
250
|
+
e164: () => (schemas_e164),
|
|
251
|
+
email: () => (schemas_email),
|
|
252
|
+
emoji: () => (schemas_emoji),
|
|
253
|
+
"enum": () => (schemas_enum),
|
|
254
|
+
file: () => (file),
|
|
255
|
+
float32: () => (float32),
|
|
256
|
+
float64: () => (float64),
|
|
257
|
+
"function": () => (_function),
|
|
258
|
+
guid: () => (schemas_guid),
|
|
259
|
+
hash: () => (hash),
|
|
260
|
+
hex: () => (schemas_hex),
|
|
261
|
+
hostname: () => (schemas_hostname),
|
|
262
|
+
httpUrl: () => (httpUrl),
|
|
263
|
+
"instanceof": () => (_instanceof),
|
|
264
|
+
int: () => (schemas_int),
|
|
265
|
+
int32: () => (int32),
|
|
266
|
+
int64: () => (int64),
|
|
267
|
+
intersection: () => (intersection),
|
|
268
|
+
ipv4: () => (schemas_ipv4),
|
|
269
|
+
ipv6: () => (schemas_ipv6),
|
|
270
|
+
json: () => (json),
|
|
271
|
+
jwt: () => (jwt),
|
|
272
|
+
keyof: () => (keyof),
|
|
273
|
+
ksuid: () => (schemas_ksuid),
|
|
274
|
+
lazy: () => (lazy),
|
|
275
|
+
literal: () => (literal),
|
|
276
|
+
looseObject: () => (looseObject),
|
|
277
|
+
looseRecord: () => (looseRecord),
|
|
278
|
+
mac: () => (schemas_mac),
|
|
279
|
+
map: () => (map),
|
|
280
|
+
meta: () => (schemas_meta),
|
|
281
|
+
nan: () => (nan),
|
|
282
|
+
nanoid: () => (schemas_nanoid),
|
|
283
|
+
nativeEnum: () => (nativeEnum),
|
|
284
|
+
never: () => (never),
|
|
285
|
+
nonoptional: () => (nonoptional),
|
|
286
|
+
"null": () => (schemas_null),
|
|
287
|
+
nullable: () => (nullable),
|
|
288
|
+
nullish: () => (schemas_nullish),
|
|
289
|
+
number: () => (schemas_number),
|
|
290
|
+
object: () => (object),
|
|
291
|
+
optional: () => (optional),
|
|
292
|
+
partialRecord: () => (partialRecord),
|
|
293
|
+
pipe: () => (pipe),
|
|
294
|
+
prefault: () => (prefault),
|
|
295
|
+
preprocess: () => (preprocess),
|
|
296
|
+
promise: () => (promise),
|
|
297
|
+
readonly: () => (readonly),
|
|
298
|
+
record: () => (record),
|
|
299
|
+
refine: () => (refine),
|
|
300
|
+
set: () => (set),
|
|
301
|
+
strictObject: () => (strictObject),
|
|
302
|
+
string: () => (schemas_string),
|
|
303
|
+
stringFormat: () => (stringFormat),
|
|
304
|
+
stringbool: () => (stringbool),
|
|
305
|
+
success: () => (success),
|
|
306
|
+
superRefine: () => (superRefine),
|
|
307
|
+
symbol: () => (symbol),
|
|
308
|
+
templateLiteral: () => (templateLiteral),
|
|
309
|
+
transform: () => (transform),
|
|
310
|
+
tuple: () => (tuple),
|
|
311
|
+
uint32: () => (uint32),
|
|
312
|
+
uint64: () => (uint64),
|
|
313
|
+
ulid: () => (schemas_ulid),
|
|
314
|
+
undefined: () => (schemas_undefined),
|
|
315
|
+
union: () => (union),
|
|
316
|
+
unknown: () => (unknown),
|
|
317
|
+
url: () => (url),
|
|
318
|
+
uuid: () => (schemas_uuid),
|
|
319
|
+
uuidv4: () => (uuidv4),
|
|
320
|
+
uuidv6: () => (uuidv6),
|
|
321
|
+
uuidv7: () => (uuidv7),
|
|
322
|
+
"void": () => (schemas_void),
|
|
323
|
+
xid: () => (schemas_xid),
|
|
324
|
+
xor: () => (xor)
|
|
325
|
+
});
|
|
45
326
|
|
|
46
327
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/core.js
|
|
47
328
|
/** A special constant with type `never` */
|
|
@@ -131,10 +412,10 @@ function assertNotEqual(val) {
|
|
|
131
412
|
}
|
|
132
413
|
function assertIs(_arg) { }
|
|
133
414
|
function assertNever(_x) {
|
|
134
|
-
throw new Error();
|
|
415
|
+
throw new Error("Unexpected value in exhaustive check");
|
|
135
416
|
}
|
|
136
417
|
function assert(_) { }
|
|
137
|
-
function
|
|
418
|
+
function getEnumValues(entries) {
|
|
138
419
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
139
420
|
const values = Object.entries(entries)
|
|
140
421
|
.filter(([k, _]) => numericValues.indexOf(+k) === -1)
|
|
@@ -935,7 +1216,7 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
935
1216
|
}
|
|
936
1217
|
return result.value;
|
|
937
1218
|
};
|
|
938
|
-
const
|
|
1219
|
+
const parse = /* @__PURE__*/ _parse($ZodRealError);
|
|
939
1220
|
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
940
1221
|
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
941
1222
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
@@ -948,7 +1229,7 @@ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
|
948
1229
|
}
|
|
949
1230
|
return result.value;
|
|
950
1231
|
};
|
|
951
|
-
const
|
|
1232
|
+
const parseAsync = /* @__PURE__*/ _parseAsync($ZodRealError);
|
|
952
1233
|
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
953
1234
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
954
1235
|
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
@@ -1035,9 +1316,9 @@ const uuid = (version) => {
|
|
|
1035
1316
|
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
1036
1317
|
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
1037
1318
|
};
|
|
1038
|
-
const uuid4 = /*@__PURE__*/
|
|
1039
|
-
const uuid6 = /*@__PURE__*/
|
|
1040
|
-
const uuid7 = /*@__PURE__*/
|
|
1319
|
+
const uuid4 = /*@__PURE__*/ uuid(4);
|
|
1320
|
+
const uuid6 = /*@__PURE__*/ uuid(6);
|
|
1321
|
+
const uuid7 = /*@__PURE__*/ uuid(7);
|
|
1041
1322
|
/** Practical email validation */
|
|
1042
1323
|
const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
1043
1324
|
/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
|
|
@@ -1046,7 +1327,7 @@ const html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]
|
|
|
1046
1327
|
const rfc5322Email = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
1047
1328
|
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
|
1048
1329
|
const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
|
1049
|
-
const idnEmail =
|
|
1330
|
+
const idnEmail = unicodeEmail;
|
|
1050
1331
|
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])?)*$/;
|
|
1051
1332
|
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
|
1052
1333
|
const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
@@ -1056,7 +1337,7 @@ function emoji() {
|
|
|
1056
1337
|
const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
1057
1338
|
const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
1058
1339
|
const mac = (delimiter) => {
|
|
1059
|
-
const escapedDelim =
|
|
1340
|
+
const escapedDelim = escapeRegex(delimiter ?? ":");
|
|
1060
1341
|
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
|
|
1061
1342
|
};
|
|
1062
1343
|
const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
@@ -1128,24 +1409,24 @@ function fixedBase64url(length) {
|
|
|
1128
1409
|
}
|
|
1129
1410
|
// MD5 (16 bytes): base64 = 24 chars total (22 + "==")
|
|
1130
1411
|
const md5_hex = /^[0-9a-fA-F]{32}$/;
|
|
1131
|
-
const md5_base64 = /*@__PURE__*/
|
|
1132
|
-
const md5_base64url = /*@__PURE__*/
|
|
1412
|
+
const md5_base64 = /*@__PURE__*/ fixedBase64(22, "==");
|
|
1413
|
+
const md5_base64url = /*@__PURE__*/ fixedBase64url(22);
|
|
1133
1414
|
// SHA1 (20 bytes): base64 = 28 chars total (27 + "=")
|
|
1134
1415
|
const sha1_hex = /^[0-9a-fA-F]{40}$/;
|
|
1135
|
-
const sha1_base64 = /*@__PURE__*/
|
|
1136
|
-
const sha1_base64url = /*@__PURE__*/
|
|
1416
|
+
const sha1_base64 = /*@__PURE__*/ fixedBase64(27, "=");
|
|
1417
|
+
const sha1_base64url = /*@__PURE__*/ fixedBase64url(27);
|
|
1137
1418
|
// SHA256 (32 bytes): base64 = 44 chars total (43 + "=")
|
|
1138
1419
|
const sha256_hex = /^[0-9a-fA-F]{64}$/;
|
|
1139
|
-
const sha256_base64 = /*@__PURE__*/
|
|
1140
|
-
const sha256_base64url = /*@__PURE__*/
|
|
1420
|
+
const sha256_base64 = /*@__PURE__*/ fixedBase64(43, "=");
|
|
1421
|
+
const sha256_base64url = /*@__PURE__*/ fixedBase64url(43);
|
|
1141
1422
|
// SHA384 (48 bytes): base64 = 64 chars total (no padding)
|
|
1142
1423
|
const sha384_hex = /^[0-9a-fA-F]{96}$/;
|
|
1143
|
-
const sha384_base64 = /*@__PURE__*/
|
|
1144
|
-
const sha384_base64url = /*@__PURE__*/
|
|
1424
|
+
const sha384_base64 = /*@__PURE__*/ fixedBase64(64, "");
|
|
1425
|
+
const sha384_base64url = /*@__PURE__*/ fixedBase64url(64);
|
|
1145
1426
|
// SHA512 (64 bytes): base64 = 88 chars total (86 + "==")
|
|
1146
1427
|
const sha512_hex = /^[0-9a-fA-F]{128}$/;
|
|
1147
|
-
const sha512_base64 = /*@__PURE__*/
|
|
1148
|
-
const sha512_base64url = /*@__PURE__*/
|
|
1428
|
+
const sha512_base64 = /*@__PURE__*/ fixedBase64(86, "==");
|
|
1429
|
+
const sha512_base64url = /*@__PURE__*/ fixedBase64url(86);
|
|
1149
1430
|
|
|
1150
1431
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/checks.js
|
|
1151
1432
|
// import { $ZodType } from "./schemas.js";
|
|
@@ -1163,7 +1444,7 @@ const numericOriginMap = {
|
|
|
1163
1444
|
bigint: "bigint",
|
|
1164
1445
|
object: "date",
|
|
1165
1446
|
};
|
|
1166
|
-
const $ZodCheckLessThan = /*@__PURE__*/
|
|
1447
|
+
const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
1167
1448
|
$ZodCheck.init(inst, def);
|
|
1168
1449
|
const origin = numericOriginMap[typeof def.value];
|
|
1169
1450
|
inst._zod.onattach.push((inst) => {
|
|
@@ -1190,8 +1471,8 @@ const $ZodCheckLessThan = /*@__PURE__*/ (/* unused pure expression or super */ n
|
|
|
1190
1471
|
continue: !def.abort,
|
|
1191
1472
|
});
|
|
1192
1473
|
};
|
|
1193
|
-
})
|
|
1194
|
-
const $ZodCheckGreaterThan = /*@__PURE__*/
|
|
1474
|
+
});
|
|
1475
|
+
const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
1195
1476
|
$ZodCheck.init(inst, def);
|
|
1196
1477
|
const origin = numericOriginMap[typeof def.value];
|
|
1197
1478
|
inst._zod.onattach.push((inst) => {
|
|
@@ -1218,9 +1499,9 @@ const $ZodCheckGreaterThan = /*@__PURE__*/ (/* unused pure expression or super *
|
|
|
1218
1499
|
continue: !def.abort,
|
|
1219
1500
|
});
|
|
1220
1501
|
};
|
|
1221
|
-
})
|
|
1502
|
+
});
|
|
1222
1503
|
const $ZodCheckMultipleOf =
|
|
1223
|
-
/*@__PURE__*/
|
|
1504
|
+
/*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
1224
1505
|
$ZodCheck.init(inst, def);
|
|
1225
1506
|
inst._zod.onattach.push((inst) => {
|
|
1226
1507
|
var _a;
|
|
@@ -1231,7 +1512,7 @@ const $ZodCheckMultipleOf =
|
|
|
1231
1512
|
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
1232
1513
|
const isMultiple = typeof payload.value === "bigint"
|
|
1233
1514
|
? payload.value % def.value === BigInt(0)
|
|
1234
|
-
:
|
|
1515
|
+
: floatSafeRemainder(payload.value, def.value) === 0;
|
|
1235
1516
|
if (isMultiple)
|
|
1236
1517
|
return;
|
|
1237
1518
|
payload.issues.push({
|
|
@@ -1243,20 +1524,20 @@ const $ZodCheckMultipleOf =
|
|
|
1243
1524
|
continue: !def.abort,
|
|
1244
1525
|
});
|
|
1245
1526
|
};
|
|
1246
|
-
})
|
|
1247
|
-
const $ZodCheckNumberFormat = /*@__PURE__*/
|
|
1527
|
+
});
|
|
1528
|
+
const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat", (inst, def) => {
|
|
1248
1529
|
$ZodCheck.init(inst, def); // no format checks
|
|
1249
1530
|
def.format = def.format || "float64";
|
|
1250
1531
|
const isInt = def.format?.includes("int");
|
|
1251
1532
|
const origin = isInt ? "int" : "number";
|
|
1252
|
-
const [minimum, maximum] =
|
|
1533
|
+
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
1253
1534
|
inst._zod.onattach.push((inst) => {
|
|
1254
1535
|
const bag = inst._zod.bag;
|
|
1255
1536
|
bag.format = def.format;
|
|
1256
1537
|
bag.minimum = minimum;
|
|
1257
1538
|
bag.maximum = maximum;
|
|
1258
1539
|
if (isInt)
|
|
1259
|
-
bag.pattern =
|
|
1540
|
+
bag.pattern = integer;
|
|
1260
1541
|
});
|
|
1261
1542
|
inst._zod.check = (payload) => {
|
|
1262
1543
|
const input = payload.value;
|
|
@@ -1338,10 +1619,10 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ (/* unused pure expression or super
|
|
|
1338
1619
|
});
|
|
1339
1620
|
}
|
|
1340
1621
|
};
|
|
1341
|
-
})
|
|
1342
|
-
const $ZodCheckBigIntFormat = /*@__PURE__*/
|
|
1622
|
+
});
|
|
1623
|
+
const $ZodCheckBigIntFormat = /*@__PURE__*/ $constructor("$ZodCheckBigIntFormat", (inst, def) => {
|
|
1343
1624
|
$ZodCheck.init(inst, def); // no format checks
|
|
1344
|
-
const [minimum, maximum] =
|
|
1625
|
+
const [minimum, maximum] = BIGINT_FORMAT_RANGES[def.format];
|
|
1345
1626
|
inst._zod.onattach.push((inst) => {
|
|
1346
1627
|
const bag = inst._zod.bag;
|
|
1347
1628
|
bag.format = def.format;
|
|
@@ -1371,13 +1652,13 @@ const $ZodCheckBigIntFormat = /*@__PURE__*/ (/* unused pure expression or super
|
|
|
1371
1652
|
});
|
|
1372
1653
|
}
|
|
1373
1654
|
};
|
|
1374
|
-
})
|
|
1375
|
-
const $ZodCheckMaxSize = /*@__PURE__*/
|
|
1655
|
+
});
|
|
1656
|
+
const $ZodCheckMaxSize = /*@__PURE__*/ $constructor("$ZodCheckMaxSize", (inst, def) => {
|
|
1376
1657
|
var _a;
|
|
1377
1658
|
$ZodCheck.init(inst, def);
|
|
1378
1659
|
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1379
1660
|
const val = payload.value;
|
|
1380
|
-
return !
|
|
1661
|
+
return !nullish(val) && val.size !== undefined;
|
|
1381
1662
|
});
|
|
1382
1663
|
inst._zod.onattach.push((inst) => {
|
|
1383
1664
|
const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);
|
|
@@ -1390,7 +1671,7 @@ const $ZodCheckMaxSize = /*@__PURE__*/ (/* unused pure expression or super */ nu
|
|
|
1390
1671
|
if (size <= def.maximum)
|
|
1391
1672
|
return;
|
|
1392
1673
|
payload.issues.push({
|
|
1393
|
-
origin:
|
|
1674
|
+
origin: getSizableOrigin(input),
|
|
1394
1675
|
code: "too_big",
|
|
1395
1676
|
maximum: def.maximum,
|
|
1396
1677
|
inclusive: true,
|
|
@@ -1399,13 +1680,13 @@ const $ZodCheckMaxSize = /*@__PURE__*/ (/* unused pure expression or super */ nu
|
|
|
1399
1680
|
continue: !def.abort,
|
|
1400
1681
|
});
|
|
1401
1682
|
};
|
|
1402
|
-
})
|
|
1403
|
-
const $ZodCheckMinSize = /*@__PURE__*/
|
|
1683
|
+
});
|
|
1684
|
+
const $ZodCheckMinSize = /*@__PURE__*/ $constructor("$ZodCheckMinSize", (inst, def) => {
|
|
1404
1685
|
var _a;
|
|
1405
1686
|
$ZodCheck.init(inst, def);
|
|
1406
1687
|
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1407
1688
|
const val = payload.value;
|
|
1408
|
-
return !
|
|
1689
|
+
return !nullish(val) && val.size !== undefined;
|
|
1409
1690
|
});
|
|
1410
1691
|
inst._zod.onattach.push((inst) => {
|
|
1411
1692
|
const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);
|
|
@@ -1418,7 +1699,7 @@ const $ZodCheckMinSize = /*@__PURE__*/ (/* unused pure expression or super */ nu
|
|
|
1418
1699
|
if (size >= def.minimum)
|
|
1419
1700
|
return;
|
|
1420
1701
|
payload.issues.push({
|
|
1421
|
-
origin:
|
|
1702
|
+
origin: getSizableOrigin(input),
|
|
1422
1703
|
code: "too_small",
|
|
1423
1704
|
minimum: def.minimum,
|
|
1424
1705
|
inclusive: true,
|
|
@@ -1427,13 +1708,13 @@ const $ZodCheckMinSize = /*@__PURE__*/ (/* unused pure expression or super */ nu
|
|
|
1427
1708
|
continue: !def.abort,
|
|
1428
1709
|
});
|
|
1429
1710
|
};
|
|
1430
|
-
})
|
|
1431
|
-
const $ZodCheckSizeEquals = /*@__PURE__*/
|
|
1711
|
+
});
|
|
1712
|
+
const $ZodCheckSizeEquals = /*@__PURE__*/ $constructor("$ZodCheckSizeEquals", (inst, def) => {
|
|
1432
1713
|
var _a;
|
|
1433
1714
|
$ZodCheck.init(inst, def);
|
|
1434
1715
|
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1435
1716
|
const val = payload.value;
|
|
1436
|
-
return !
|
|
1717
|
+
return !nullish(val) && val.size !== undefined;
|
|
1437
1718
|
});
|
|
1438
1719
|
inst._zod.onattach.push((inst) => {
|
|
1439
1720
|
const bag = inst._zod.bag;
|
|
@@ -1448,7 +1729,7 @@ const $ZodCheckSizeEquals = /*@__PURE__*/ (/* unused pure expression or super */
|
|
|
1448
1729
|
return;
|
|
1449
1730
|
const tooBig = size > def.size;
|
|
1450
1731
|
payload.issues.push({
|
|
1451
|
-
origin:
|
|
1732
|
+
origin: getSizableOrigin(input),
|
|
1452
1733
|
...(tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size }),
|
|
1453
1734
|
inclusive: true,
|
|
1454
1735
|
exact: true,
|
|
@@ -1457,7 +1738,7 @@ const $ZodCheckSizeEquals = /*@__PURE__*/ (/* unused pure expression or super */
|
|
|
1457
1738
|
continue: !def.abort,
|
|
1458
1739
|
});
|
|
1459
1740
|
};
|
|
1460
|
-
})
|
|
1741
|
+
});
|
|
1461
1742
|
const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
1462
1743
|
var _a;
|
|
1463
1744
|
$ZodCheck.init(inst, def);
|
|
@@ -1676,10 +1957,10 @@ const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst,
|
|
|
1676
1957
|
///////////////////////////////////
|
|
1677
1958
|
function handleCheckPropertyResult(result, payload, property) {
|
|
1678
1959
|
if (result.issues.length) {
|
|
1679
|
-
payload.issues.push(...
|
|
1960
|
+
payload.issues.push(...prefixIssues(property, result.issues));
|
|
1680
1961
|
}
|
|
1681
1962
|
}
|
|
1682
|
-
const $ZodCheckProperty = /*@__PURE__*/
|
|
1963
|
+
const $ZodCheckProperty = /*@__PURE__*/ $constructor("$ZodCheckProperty", (inst, def) => {
|
|
1683
1964
|
$ZodCheck.init(inst, def);
|
|
1684
1965
|
inst._zod.check = (payload) => {
|
|
1685
1966
|
const result = def.schema._zod.run({
|
|
@@ -1692,8 +1973,8 @@ const $ZodCheckProperty = /*@__PURE__*/ (/* unused pure expression or super */ n
|
|
|
1692
1973
|
handleCheckPropertyResult(result, payload, def.property);
|
|
1693
1974
|
return;
|
|
1694
1975
|
};
|
|
1695
|
-
})
|
|
1696
|
-
const $ZodCheckMimeType = /*@__PURE__*/
|
|
1976
|
+
});
|
|
1977
|
+
const $ZodCheckMimeType = /*@__PURE__*/ $constructor("$ZodCheckMimeType", (inst, def) => {
|
|
1697
1978
|
$ZodCheck.init(inst, def);
|
|
1698
1979
|
const mimeSet = new Set(def.mime);
|
|
1699
1980
|
inst._zod.onattach.push((inst) => {
|
|
@@ -1710,7 +1991,7 @@ const $ZodCheckMimeType = /*@__PURE__*/ (/* unused pure expression or super */ n
|
|
|
1710
1991
|
continue: !def.abort,
|
|
1711
1992
|
});
|
|
1712
1993
|
};
|
|
1713
|
-
})
|
|
1994
|
+
});
|
|
1714
1995
|
const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
1715
1996
|
$ZodCheck.init(inst, def);
|
|
1716
1997
|
inst._zod.check = (payload) => {
|
|
@@ -1758,8 +2039,8 @@ class Doc {
|
|
|
1758
2039
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/versions.js
|
|
1759
2040
|
const version = {
|
|
1760
2041
|
major: 4,
|
|
1761
|
-
minor:
|
|
1762
|
-
patch:
|
|
2042
|
+
minor: 2,
|
|
2043
|
+
patch: 1,
|
|
1763
2044
|
};
|
|
1764
2045
|
|
|
1765
2046
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/schemas.js
|
|
@@ -1837,16 +2118,6 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
1837
2118
|
}
|
|
1838
2119
|
return payload;
|
|
1839
2120
|
};
|
|
1840
|
-
// const handleChecksResult = (
|
|
1841
|
-
// checkResult: ParsePayload,
|
|
1842
|
-
// originalResult: ParsePayload,
|
|
1843
|
-
// ctx: ParseContextInternal
|
|
1844
|
-
// ): util.MaybeAsync<ParsePayload> => {
|
|
1845
|
-
// // if the checks mutated the value && there are no issues, re-parse the result
|
|
1846
|
-
// if (checkResult.value !== originalResult.value && !checkResult.issues.length)
|
|
1847
|
-
// return inst._zod.parse(checkResult, ctx);
|
|
1848
|
-
// return originalResult;
|
|
1849
|
-
// };
|
|
1850
2121
|
const handleCanaryResult = (canary, payload, ctx) => {
|
|
1851
2122
|
// abort if the canary is aborted
|
|
1852
2123
|
if (aborted(canary)) {
|
|
@@ -2084,11 +2355,11 @@ const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
|
|
|
2084
2355
|
}
|
|
2085
2356
|
};
|
|
2086
2357
|
});
|
|
2087
|
-
const $ZodMAC = /*@__PURE__*/
|
|
2088
|
-
def.pattern ?? (def.pattern =
|
|
2358
|
+
const $ZodMAC = /*@__PURE__*/ $constructor("$ZodMAC", (inst, def) => {
|
|
2359
|
+
def.pattern ?? (def.pattern = mac(def.delimiter));
|
|
2089
2360
|
$ZodStringFormat.init(inst, def);
|
|
2090
2361
|
inst._zod.bag.format = `mac`;
|
|
2091
|
-
})
|
|
2362
|
+
});
|
|
2092
2363
|
const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
2093
2364
|
def.pattern ?? (def.pattern = cidrv4);
|
|
2094
2365
|
$ZodStringFormat.init(inst, def);
|
|
@@ -2219,7 +2490,7 @@ const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
|
|
|
2219
2490
|
});
|
|
2220
2491
|
};
|
|
2221
2492
|
});
|
|
2222
|
-
const $ZodCustomStringFormat = /*@__PURE__*/
|
|
2493
|
+
const $ZodCustomStringFormat = /*@__PURE__*/ $constructor("$ZodCustomStringFormat", (inst, def) => {
|
|
2223
2494
|
$ZodStringFormat.init(inst, def);
|
|
2224
2495
|
inst._zod.check = (payload) => {
|
|
2225
2496
|
if (def.fn(payload.value))
|
|
@@ -2232,10 +2503,10 @@ const $ZodCustomStringFormat = /*@__PURE__*/ (/* unused pure expression or super
|
|
|
2232
2503
|
continue: !def.abort,
|
|
2233
2504
|
});
|
|
2234
2505
|
};
|
|
2235
|
-
})
|
|
2236
|
-
const $ZodNumber = /*@__PURE__*/
|
|
2506
|
+
});
|
|
2507
|
+
const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
|
|
2237
2508
|
$ZodType.init(inst, def);
|
|
2238
|
-
inst._zod.pattern = inst._zod.bag.pattern ??
|
|
2509
|
+
inst._zod.pattern = inst._zod.bag.pattern ?? number;
|
|
2239
2510
|
inst._zod.parse = (payload, _ctx) => {
|
|
2240
2511
|
if (def.coerce)
|
|
2241
2512
|
try {
|
|
@@ -2262,14 +2533,14 @@ const $ZodNumber = /*@__PURE__*/ (/* unused pure expression or super */ null &&
|
|
|
2262
2533
|
});
|
|
2263
2534
|
return payload;
|
|
2264
2535
|
};
|
|
2265
|
-
})
|
|
2266
|
-
const $ZodNumberFormat = /*@__PURE__*/
|
|
2267
|
-
|
|
2536
|
+
});
|
|
2537
|
+
const $ZodNumberFormat = /*@__PURE__*/ $constructor("$ZodNumberFormat", (inst, def) => {
|
|
2538
|
+
$ZodCheckNumberFormat.init(inst, def);
|
|
2268
2539
|
$ZodNumber.init(inst, def); // no format checks
|
|
2269
|
-
})
|
|
2270
|
-
const $ZodBoolean = /*@__PURE__*/
|
|
2540
|
+
});
|
|
2541
|
+
const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def) => {
|
|
2271
2542
|
$ZodType.init(inst, def);
|
|
2272
|
-
inst._zod.pattern =
|
|
2543
|
+
inst._zod.pattern = regexes_boolean;
|
|
2273
2544
|
inst._zod.parse = (payload, _ctx) => {
|
|
2274
2545
|
if (def.coerce)
|
|
2275
2546
|
try {
|
|
@@ -2287,10 +2558,10 @@ const $ZodBoolean = /*@__PURE__*/ (/* unused pure expression or super */ null &&
|
|
|
2287
2558
|
});
|
|
2288
2559
|
return payload;
|
|
2289
2560
|
};
|
|
2290
|
-
})
|
|
2291
|
-
const $ZodBigInt = /*@__PURE__*/
|
|
2561
|
+
});
|
|
2562
|
+
const $ZodBigInt = /*@__PURE__*/ $constructor("$ZodBigInt", (inst, def) => {
|
|
2292
2563
|
$ZodType.init(inst, def);
|
|
2293
|
-
inst._zod.pattern =
|
|
2564
|
+
inst._zod.pattern = bigint;
|
|
2294
2565
|
inst._zod.parse = (payload, _ctx) => {
|
|
2295
2566
|
if (def.coerce)
|
|
2296
2567
|
try {
|
|
@@ -2307,12 +2578,12 @@ const $ZodBigInt = /*@__PURE__*/ (/* unused pure expression or super */ null &&
|
|
|
2307
2578
|
});
|
|
2308
2579
|
return payload;
|
|
2309
2580
|
};
|
|
2310
|
-
})
|
|
2311
|
-
const $ZodBigIntFormat = /*@__PURE__*/
|
|
2312
|
-
|
|
2581
|
+
});
|
|
2582
|
+
const $ZodBigIntFormat = /*@__PURE__*/ $constructor("$ZodBigIntFormat", (inst, def) => {
|
|
2583
|
+
$ZodCheckBigIntFormat.init(inst, def);
|
|
2313
2584
|
$ZodBigInt.init(inst, def); // no format checks
|
|
2314
|
-
})
|
|
2315
|
-
const $ZodSymbol = /*@__PURE__*/
|
|
2585
|
+
});
|
|
2586
|
+
const $ZodSymbol = /*@__PURE__*/ $constructor("$ZodSymbol", (inst, def) => {
|
|
2316
2587
|
$ZodType.init(inst, def);
|
|
2317
2588
|
inst._zod.parse = (payload, _ctx) => {
|
|
2318
2589
|
const input = payload.value;
|
|
@@ -2326,10 +2597,10 @@ const $ZodSymbol = /*@__PURE__*/ (/* unused pure expression or super */ null &&
|
|
|
2326
2597
|
});
|
|
2327
2598
|
return payload;
|
|
2328
2599
|
};
|
|
2329
|
-
})
|
|
2330
|
-
const $ZodUndefined = /*@__PURE__*/
|
|
2600
|
+
});
|
|
2601
|
+
const $ZodUndefined = /*@__PURE__*/ $constructor("$ZodUndefined", (inst, def) => {
|
|
2331
2602
|
$ZodType.init(inst, def);
|
|
2332
|
-
inst._zod.pattern =
|
|
2603
|
+
inst._zod.pattern = _undefined;
|
|
2333
2604
|
inst._zod.values = new Set([undefined]);
|
|
2334
2605
|
inst._zod.optin = "optional";
|
|
2335
2606
|
inst._zod.optout = "optional";
|
|
@@ -2345,10 +2616,10 @@ const $ZodUndefined = /*@__PURE__*/ (/* unused pure expression or super */ null
|
|
|
2345
2616
|
});
|
|
2346
2617
|
return payload;
|
|
2347
2618
|
};
|
|
2348
|
-
})
|
|
2349
|
-
const $ZodNull = /*@__PURE__*/
|
|
2619
|
+
});
|
|
2620
|
+
const $ZodNull = /*@__PURE__*/ $constructor("$ZodNull", (inst, def) => {
|
|
2350
2621
|
$ZodType.init(inst, def);
|
|
2351
|
-
inst._zod.pattern =
|
|
2622
|
+
inst._zod.pattern = _null;
|
|
2352
2623
|
inst._zod.values = new Set([null]);
|
|
2353
2624
|
inst._zod.parse = (payload, _ctx) => {
|
|
2354
2625
|
const input = payload.value;
|
|
@@ -2362,11 +2633,11 @@ const $ZodNull = /*@__PURE__*/ (/* unused pure expression or super */ null && (c
|
|
|
2362
2633
|
});
|
|
2363
2634
|
return payload;
|
|
2364
2635
|
};
|
|
2365
|
-
})
|
|
2366
|
-
const $ZodAny = /*@__PURE__*/
|
|
2636
|
+
});
|
|
2637
|
+
const $ZodAny = /*@__PURE__*/ $constructor("$ZodAny", (inst, def) => {
|
|
2367
2638
|
$ZodType.init(inst, def);
|
|
2368
2639
|
inst._zod.parse = (payload) => payload;
|
|
2369
|
-
})
|
|
2640
|
+
});
|
|
2370
2641
|
const $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def) => {
|
|
2371
2642
|
$ZodType.init(inst, def);
|
|
2372
2643
|
inst._zod.parse = (payload) => payload;
|
|
@@ -2383,7 +2654,7 @@ const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def) => {
|
|
|
2383
2654
|
return payload;
|
|
2384
2655
|
};
|
|
2385
2656
|
});
|
|
2386
|
-
const $ZodVoid = /*@__PURE__*/
|
|
2657
|
+
const $ZodVoid = /*@__PURE__*/ $constructor("$ZodVoid", (inst, def) => {
|
|
2387
2658
|
$ZodType.init(inst, def);
|
|
2388
2659
|
inst._zod.parse = (payload, _ctx) => {
|
|
2389
2660
|
const input = payload.value;
|
|
@@ -2397,8 +2668,8 @@ const $ZodVoid = /*@__PURE__*/ (/* unused pure expression or super */ null && (c
|
|
|
2397
2668
|
});
|
|
2398
2669
|
return payload;
|
|
2399
2670
|
};
|
|
2400
|
-
})
|
|
2401
|
-
const $ZodDate = /*@__PURE__*/
|
|
2671
|
+
});
|
|
2672
|
+
const $ZodDate = /*@__PURE__*/ $constructor("$ZodDate", (inst, def) => {
|
|
2402
2673
|
$ZodType.init(inst, def);
|
|
2403
2674
|
inst._zod.parse = (payload, _ctx) => {
|
|
2404
2675
|
if (def.coerce) {
|
|
@@ -2421,7 +2692,7 @@ const $ZodDate = /*@__PURE__*/ (/* unused pure expression or super */ null && (c
|
|
|
2421
2692
|
});
|
|
2422
2693
|
return payload;
|
|
2423
2694
|
};
|
|
2424
|
-
})
|
|
2695
|
+
});
|
|
2425
2696
|
function handleArrayResult(result, final, index) {
|
|
2426
2697
|
if (result.issues.length) {
|
|
2427
2698
|
final.issues.push(...prefixIssues(index, result.issues));
|
|
@@ -2737,12 +3008,71 @@ const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
|
|
|
2737
3008
|
});
|
|
2738
3009
|
};
|
|
2739
3010
|
});
|
|
3011
|
+
function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
3012
|
+
const successes = results.filter((r) => r.issues.length === 0);
|
|
3013
|
+
if (successes.length === 1) {
|
|
3014
|
+
final.value = successes[0].value;
|
|
3015
|
+
return final;
|
|
3016
|
+
}
|
|
3017
|
+
if (successes.length === 0) {
|
|
3018
|
+
// No matches - same as regular union
|
|
3019
|
+
final.issues.push({
|
|
3020
|
+
code: "invalid_union",
|
|
3021
|
+
input: final.value,
|
|
3022
|
+
inst,
|
|
3023
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config()))),
|
|
3024
|
+
});
|
|
3025
|
+
}
|
|
3026
|
+
else {
|
|
3027
|
+
// Multiple matches - exclusive union failure
|
|
3028
|
+
final.issues.push({
|
|
3029
|
+
code: "invalid_union",
|
|
3030
|
+
input: final.value,
|
|
3031
|
+
inst,
|
|
3032
|
+
errors: [],
|
|
3033
|
+
inclusive: false,
|
|
3034
|
+
});
|
|
3035
|
+
}
|
|
3036
|
+
return final;
|
|
3037
|
+
}
|
|
3038
|
+
const $ZodXor = /*@__PURE__*/ $constructor("$ZodXor", (inst, def) => {
|
|
3039
|
+
$ZodUnion.init(inst, def);
|
|
3040
|
+
def.inclusive = false;
|
|
3041
|
+
const single = def.options.length === 1;
|
|
3042
|
+
const first = def.options[0]._zod.run;
|
|
3043
|
+
inst._zod.parse = (payload, ctx) => {
|
|
3044
|
+
if (single) {
|
|
3045
|
+
return first(payload, ctx);
|
|
3046
|
+
}
|
|
3047
|
+
let async = false;
|
|
3048
|
+
const results = [];
|
|
3049
|
+
for (const option of def.options) {
|
|
3050
|
+
const result = option._zod.run({
|
|
3051
|
+
value: payload.value,
|
|
3052
|
+
issues: [],
|
|
3053
|
+
}, ctx);
|
|
3054
|
+
if (result instanceof Promise) {
|
|
3055
|
+
results.push(result);
|
|
3056
|
+
async = true;
|
|
3057
|
+
}
|
|
3058
|
+
else {
|
|
3059
|
+
results.push(result);
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
if (!async)
|
|
3063
|
+
return handleExclusiveUnionResults(results, payload, inst, ctx);
|
|
3064
|
+
return Promise.all(results).then((results) => {
|
|
3065
|
+
return handleExclusiveUnionResults(results, payload, inst, ctx);
|
|
3066
|
+
});
|
|
3067
|
+
};
|
|
3068
|
+
});
|
|
2740
3069
|
const $ZodDiscriminatedUnion =
|
|
2741
3070
|
/*@__PURE__*/
|
|
2742
|
-
|
|
3071
|
+
$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
3072
|
+
def.inclusive = false;
|
|
2743
3073
|
$ZodUnion.init(inst, def);
|
|
2744
3074
|
const _super = inst._zod.parse;
|
|
2745
|
-
|
|
3075
|
+
defineLazy(inst._zod, "propValues", () => {
|
|
2746
3076
|
const propValues = {};
|
|
2747
3077
|
for (const option of def.options) {
|
|
2748
3078
|
const pv = option._zod.propValues;
|
|
@@ -2758,7 +3088,7 @@ const $ZodDiscriminatedUnion =
|
|
|
2758
3088
|
}
|
|
2759
3089
|
return propValues;
|
|
2760
3090
|
});
|
|
2761
|
-
const disc =
|
|
3091
|
+
const disc = cached(() => {
|
|
2762
3092
|
const opts = def.options;
|
|
2763
3093
|
const map = new Map();
|
|
2764
3094
|
for (const o of opts) {
|
|
@@ -2776,7 +3106,7 @@ const $ZodDiscriminatedUnion =
|
|
|
2776
3106
|
});
|
|
2777
3107
|
inst._zod.parse = (payload, ctx) => {
|
|
2778
3108
|
const input = payload.value;
|
|
2779
|
-
if (!
|
|
3109
|
+
if (!util_isObject(input)) {
|
|
2780
3110
|
payload.issues.push({
|
|
2781
3111
|
code: "invalid_type",
|
|
2782
3112
|
expected: "object",
|
|
@@ -2804,7 +3134,7 @@ const $ZodDiscriminatedUnion =
|
|
|
2804
3134
|
});
|
|
2805
3135
|
return payload;
|
|
2806
3136
|
};
|
|
2807
|
-
})
|
|
3137
|
+
});
|
|
2808
3138
|
const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
|
|
2809
3139
|
$ZodType.init(inst, def);
|
|
2810
3140
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -2882,7 +3212,7 @@ function handleIntersectionResults(result, left, right) {
|
|
|
2882
3212
|
result.value = merged.data;
|
|
2883
3213
|
return result;
|
|
2884
3214
|
}
|
|
2885
|
-
const $ZodTuple = /*@__PURE__*/
|
|
3215
|
+
const $ZodTuple = /*@__PURE__*/ $constructor("$ZodTuple", (inst, def) => {
|
|
2886
3216
|
$ZodType.init(inst, def);
|
|
2887
3217
|
const items = def.items;
|
|
2888
3218
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -2950,10 +3280,10 @@ const $ZodTuple = /*@__PURE__*/ (/* unused pure expression or super */ null && (
|
|
|
2950
3280
|
return Promise.all(proms).then(() => payload);
|
|
2951
3281
|
return payload;
|
|
2952
3282
|
};
|
|
2953
|
-
})
|
|
3283
|
+
});
|
|
2954
3284
|
function handleTupleResult(result, final, index) {
|
|
2955
3285
|
if (result.issues.length) {
|
|
2956
|
-
final.issues.push(...
|
|
3286
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
2957
3287
|
}
|
|
2958
3288
|
final.value[index] = result.value;
|
|
2959
3289
|
}
|
|
@@ -3021,15 +3351,21 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
3021
3351
|
throw new Error("Async schemas not supported in object keys currently");
|
|
3022
3352
|
}
|
|
3023
3353
|
if (keyResult.issues.length) {
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3354
|
+
if (def.mode === "loose") {
|
|
3355
|
+
// Pass through unchanged
|
|
3356
|
+
payload.value[key] = input[key];
|
|
3357
|
+
}
|
|
3358
|
+
else {
|
|
3359
|
+
// Default "strict" behavior: error on invalid key
|
|
3360
|
+
payload.issues.push({
|
|
3361
|
+
code: "invalid_key",
|
|
3362
|
+
origin: "record",
|
|
3363
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
3364
|
+
input: key,
|
|
3365
|
+
path: [key],
|
|
3366
|
+
inst,
|
|
3367
|
+
});
|
|
3368
|
+
}
|
|
3033
3369
|
continue;
|
|
3034
3370
|
}
|
|
3035
3371
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
@@ -3055,7 +3391,7 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
3055
3391
|
return payload;
|
|
3056
3392
|
};
|
|
3057
3393
|
});
|
|
3058
|
-
const $ZodMap = /*@__PURE__*/
|
|
3394
|
+
const $ZodMap = /*@__PURE__*/ $constructor("$ZodMap", (inst, def) => {
|
|
3059
3395
|
$ZodType.init(inst, def);
|
|
3060
3396
|
inst._zod.parse = (payload, ctx) => {
|
|
3061
3397
|
const input = payload.value;
|
|
@@ -3086,11 +3422,11 @@ const $ZodMap = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
|
|
|
3086
3422
|
return Promise.all(proms).then(() => payload);
|
|
3087
3423
|
return payload;
|
|
3088
3424
|
};
|
|
3089
|
-
})
|
|
3425
|
+
});
|
|
3090
3426
|
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
3091
3427
|
if (keyResult.issues.length) {
|
|
3092
|
-
if (
|
|
3093
|
-
final.issues.push(...
|
|
3428
|
+
if (propertyKeyTypes.has(typeof key)) {
|
|
3429
|
+
final.issues.push(...prefixIssues(key, keyResult.issues));
|
|
3094
3430
|
}
|
|
3095
3431
|
else {
|
|
3096
3432
|
final.issues.push({
|
|
@@ -3098,13 +3434,13 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
3098
3434
|
origin: "map",
|
|
3099
3435
|
input,
|
|
3100
3436
|
inst,
|
|
3101
|
-
issues: keyResult.issues.map((iss) =>
|
|
3437
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
3102
3438
|
});
|
|
3103
3439
|
}
|
|
3104
3440
|
}
|
|
3105
3441
|
if (valueResult.issues.length) {
|
|
3106
|
-
if (
|
|
3107
|
-
final.issues.push(...
|
|
3442
|
+
if (propertyKeyTypes.has(typeof key)) {
|
|
3443
|
+
final.issues.push(...prefixIssues(key, valueResult.issues));
|
|
3108
3444
|
}
|
|
3109
3445
|
else {
|
|
3110
3446
|
final.issues.push({
|
|
@@ -3113,13 +3449,13 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
3113
3449
|
input,
|
|
3114
3450
|
inst,
|
|
3115
3451
|
key: key,
|
|
3116
|
-
issues: valueResult.issues.map((iss) =>
|
|
3452
|
+
issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
3117
3453
|
});
|
|
3118
3454
|
}
|
|
3119
3455
|
}
|
|
3120
3456
|
final.value.set(keyResult.value, valueResult.value);
|
|
3121
3457
|
}
|
|
3122
|
-
const $ZodSet = /*@__PURE__*/
|
|
3458
|
+
const $ZodSet = /*@__PURE__*/ $constructor("$ZodSet", (inst, def) => {
|
|
3123
3459
|
$ZodType.init(inst, def);
|
|
3124
3460
|
inst._zod.parse = (payload, ctx) => {
|
|
3125
3461
|
const input = payload.value;
|
|
@@ -3146,7 +3482,7 @@ const $ZodSet = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
|
|
|
3146
3482
|
return Promise.all(proms).then(() => payload);
|
|
3147
3483
|
return payload;
|
|
3148
3484
|
};
|
|
3149
|
-
})
|
|
3485
|
+
});
|
|
3150
3486
|
function handleSetResult(result, final) {
|
|
3151
3487
|
if (result.issues.length) {
|
|
3152
3488
|
final.issues.push(...result.issues);
|
|
@@ -3155,7 +3491,7 @@ function handleSetResult(result, final) {
|
|
|
3155
3491
|
}
|
|
3156
3492
|
const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
3157
3493
|
$ZodType.init(inst, def);
|
|
3158
|
-
const values =
|
|
3494
|
+
const values = getEnumValues(def.entries);
|
|
3159
3495
|
const valuesSet = new Set(values);
|
|
3160
3496
|
inst._zod.values = valuesSet;
|
|
3161
3497
|
inst._zod.pattern = new RegExp(`^(${values
|
|
@@ -3176,7 +3512,7 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
|
3176
3512
|
return payload;
|
|
3177
3513
|
};
|
|
3178
3514
|
});
|
|
3179
|
-
const $ZodLiteral = /*@__PURE__*/
|
|
3515
|
+
const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
|
|
3180
3516
|
$ZodType.init(inst, def);
|
|
3181
3517
|
if (def.values.length === 0) {
|
|
3182
3518
|
throw new Error("Cannot create literal schema with no valid values");
|
|
@@ -3184,7 +3520,7 @@ const $ZodLiteral = /*@__PURE__*/ (/* unused pure expression or super */ null &&
|
|
|
3184
3520
|
const values = new Set(def.values);
|
|
3185
3521
|
inst._zod.values = values;
|
|
3186
3522
|
inst._zod.pattern = new RegExp(`^(${def.values
|
|
3187
|
-
.map((o) => (typeof o === "string" ?
|
|
3523
|
+
.map((o) => (typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)))
|
|
3188
3524
|
.join("|")})$`);
|
|
3189
3525
|
inst._zod.parse = (payload, _ctx) => {
|
|
3190
3526
|
const input = payload.value;
|
|
@@ -3199,8 +3535,8 @@ const $ZodLiteral = /*@__PURE__*/ (/* unused pure expression or super */ null &&
|
|
|
3199
3535
|
});
|
|
3200
3536
|
return payload;
|
|
3201
3537
|
};
|
|
3202
|
-
})
|
|
3203
|
-
const $ZodFile = /*@__PURE__*/
|
|
3538
|
+
});
|
|
3539
|
+
const $ZodFile = /*@__PURE__*/ $constructor("$ZodFile", (inst, def) => {
|
|
3204
3540
|
$ZodType.init(inst, def);
|
|
3205
3541
|
inst._zod.parse = (payload, _ctx) => {
|
|
3206
3542
|
const input = payload.value;
|
|
@@ -3215,7 +3551,7 @@ const $ZodFile = /*@__PURE__*/ (/* unused pure expression or super */ null && (c
|
|
|
3215
3551
|
});
|
|
3216
3552
|
return payload;
|
|
3217
3553
|
};
|
|
3218
|
-
})
|
|
3554
|
+
});
|
|
3219
3555
|
const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
|
|
3220
3556
|
$ZodType.init(inst, def);
|
|
3221
3557
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -3356,11 +3692,11 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
3356
3692
|
}
|
|
3357
3693
|
return payload;
|
|
3358
3694
|
}
|
|
3359
|
-
const $ZodSuccess = /*@__PURE__*/
|
|
3695
|
+
const $ZodSuccess = /*@__PURE__*/ $constructor("$ZodSuccess", (inst, def) => {
|
|
3360
3696
|
$ZodType.init(inst, def);
|
|
3361
3697
|
inst._zod.parse = (payload, ctx) => {
|
|
3362
3698
|
if (ctx.direction === "backward") {
|
|
3363
|
-
throw new
|
|
3699
|
+
throw new $ZodEncodeError("ZodSuccess");
|
|
3364
3700
|
}
|
|
3365
3701
|
const result = def.innerType._zod.run(payload, ctx);
|
|
3366
3702
|
if (result instanceof Promise) {
|
|
@@ -3372,7 +3708,7 @@ const $ZodSuccess = /*@__PURE__*/ (/* unused pure expression or super */ null &&
|
|
|
3372
3708
|
payload.value = result.issues.length === 0;
|
|
3373
3709
|
return payload;
|
|
3374
3710
|
};
|
|
3375
|
-
})
|
|
3711
|
+
});
|
|
3376
3712
|
const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
|
|
3377
3713
|
$ZodType.init(inst, def);
|
|
3378
3714
|
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
@@ -3414,7 +3750,7 @@ const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
|
|
|
3414
3750
|
return payload;
|
|
3415
3751
|
};
|
|
3416
3752
|
});
|
|
3417
|
-
const $ZodNaN = /*@__PURE__*/
|
|
3753
|
+
const $ZodNaN = /*@__PURE__*/ $constructor("$ZodNaN", (inst, def) => {
|
|
3418
3754
|
$ZodType.init(inst, def);
|
|
3419
3755
|
inst._zod.parse = (payload, _ctx) => {
|
|
3420
3756
|
if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
|
|
@@ -3428,7 +3764,7 @@ const $ZodNaN = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
|
|
|
3428
3764
|
}
|
|
3429
3765
|
return payload;
|
|
3430
3766
|
};
|
|
3431
|
-
})
|
|
3767
|
+
});
|
|
3432
3768
|
const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
|
|
3433
3769
|
$ZodType.init(inst, def);
|
|
3434
3770
|
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
@@ -3458,12 +3794,12 @@ function handlePipeResult(left, next, ctx) {
|
|
|
3458
3794
|
}
|
|
3459
3795
|
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
3460
3796
|
}
|
|
3461
|
-
const $ZodCodec = /*@__PURE__*/
|
|
3797
|
+
const $ZodCodec = /*@__PURE__*/ $constructor("$ZodCodec", (inst, def) => {
|
|
3462
3798
|
$ZodType.init(inst, def);
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3799
|
+
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
3800
|
+
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
3801
|
+
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
3802
|
+
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
3467
3803
|
inst._zod.parse = (payload, ctx) => {
|
|
3468
3804
|
const direction = ctx.direction || "forward";
|
|
3469
3805
|
if (direction === "forward") {
|
|
@@ -3481,7 +3817,7 @@ const $ZodCodec = /*@__PURE__*/ (/* unused pure expression or super */ null && (
|
|
|
3481
3817
|
return handleCodecAResult(right, def, ctx);
|
|
3482
3818
|
}
|
|
3483
3819
|
};
|
|
3484
|
-
})
|
|
3820
|
+
});
|
|
3485
3821
|
function handleCodecAResult(result, def, ctx) {
|
|
3486
3822
|
if (result.issues.length) {
|
|
3487
3823
|
// prevent further checks
|
|
@@ -3533,7 +3869,7 @@ function handleReadonlyResult(payload) {
|
|
|
3533
3869
|
payload.value = Object.freeze(payload.value);
|
|
3534
3870
|
return payload;
|
|
3535
3871
|
}
|
|
3536
|
-
const $ZodTemplateLiteral = /*@__PURE__*/
|
|
3872
|
+
const $ZodTemplateLiteral = /*@__PURE__*/ $constructor("$ZodTemplateLiteral", (inst, def) => {
|
|
3537
3873
|
$ZodType.init(inst, def);
|
|
3538
3874
|
const regexParts = [];
|
|
3539
3875
|
for (const part of def.parts) {
|
|
@@ -3550,8 +3886,8 @@ const $ZodTemplateLiteral = /*@__PURE__*/ (/* unused pure expression or super */
|
|
|
3550
3886
|
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
3551
3887
|
regexParts.push(source.slice(start, end));
|
|
3552
3888
|
}
|
|
3553
|
-
else if (part === null ||
|
|
3554
|
-
regexParts.push(
|
|
3889
|
+
else if (part === null || primitiveTypes.has(typeof part)) {
|
|
3890
|
+
regexParts.push(escapeRegex(`${part}`));
|
|
3555
3891
|
}
|
|
3556
3892
|
else {
|
|
3557
3893
|
throw new Error(`Invalid template literal part: ${part}`);
|
|
@@ -3581,8 +3917,8 @@ const $ZodTemplateLiteral = /*@__PURE__*/ (/* unused pure expression or super */
|
|
|
3581
3917
|
}
|
|
3582
3918
|
return payload;
|
|
3583
3919
|
};
|
|
3584
|
-
})
|
|
3585
|
-
const $ZodFunction = /*@__PURE__*/
|
|
3920
|
+
});
|
|
3921
|
+
const $ZodFunction = /*@__PURE__*/ $constructor("$ZodFunction", (inst, def) => {
|
|
3586
3922
|
$ZodType.init(inst, def);
|
|
3587
3923
|
inst._def = def;
|
|
3588
3924
|
inst._zod.def = def;
|
|
@@ -3660,14 +3996,14 @@ const $ZodFunction = /*@__PURE__*/ (/* unused pure expression or super */ null &
|
|
|
3660
3996
|
});
|
|
3661
3997
|
};
|
|
3662
3998
|
return inst;
|
|
3663
|
-
})
|
|
3664
|
-
const $ZodPromise = /*@__PURE__*/
|
|
3999
|
+
});
|
|
4000
|
+
const $ZodPromise = /*@__PURE__*/ $constructor("$ZodPromise", (inst, def) => {
|
|
3665
4001
|
$ZodType.init(inst, def);
|
|
3666
4002
|
inst._zod.parse = (payload, ctx) => {
|
|
3667
4003
|
return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
|
|
3668
4004
|
};
|
|
3669
|
-
})
|
|
3670
|
-
const $ZodLazy = /*@__PURE__*/
|
|
4005
|
+
});
|
|
4006
|
+
const $ZodLazy = /*@__PURE__*/ $constructor("$ZodLazy", (inst, def) => {
|
|
3671
4007
|
$ZodType.init(inst, def);
|
|
3672
4008
|
// let _innerType!: any;
|
|
3673
4009
|
// util.defineLazy(def, "getter", () => {
|
|
@@ -3676,16 +4012,16 @@ const $ZodLazy = /*@__PURE__*/ (/* unused pure expression or super */ null && (c
|
|
|
3676
4012
|
// }
|
|
3677
4013
|
// return () => _innerType;
|
|
3678
4014
|
// });
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
4015
|
+
defineLazy(inst._zod, "innerType", () => def.getter());
|
|
4016
|
+
defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
|
|
4017
|
+
defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
|
|
4018
|
+
defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined);
|
|
4019
|
+
defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? undefined);
|
|
3684
4020
|
inst._zod.parse = (payload, ctx) => {
|
|
3685
4021
|
const inner = inst._zod.innerType;
|
|
3686
4022
|
return inner._zod.run(payload, ctx);
|
|
3687
4023
|
};
|
|
3688
|
-
})
|
|
4024
|
+
});
|
|
3689
4025
|
const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
|
|
3690
4026
|
$ZodCheck.init(inst, def);
|
|
3691
4027
|
$ZodType.init(inst, def);
|
|
@@ -9546,7 +9882,7 @@ const yo_error = () => {
|
|
|
9546
9882
|
var _a;
|
|
9547
9883
|
const $output = Symbol("ZodOutput");
|
|
9548
9884
|
const $input = Symbol("ZodInput");
|
|
9549
|
-
class
|
|
9885
|
+
class $ZodRegistry {
|
|
9550
9886
|
constructor() {
|
|
9551
9887
|
this._map = new WeakMap();
|
|
9552
9888
|
this._idmap = new Map();
|
|
@@ -9593,10 +9929,10 @@ class registries_$ZodRegistry {
|
|
|
9593
9929
|
}
|
|
9594
9930
|
// registries
|
|
9595
9931
|
function registry() {
|
|
9596
|
-
return new
|
|
9932
|
+
return new $ZodRegistry();
|
|
9597
9933
|
}
|
|
9598
9934
|
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
9599
|
-
const
|
|
9935
|
+
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
9600
9936
|
|
|
9601
9937
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/api.js
|
|
9602
9938
|
|
|
@@ -9769,7 +10105,7 @@ function _mac(Class, params) {
|
|
|
9769
10105
|
format: "mac",
|
|
9770
10106
|
check: "string_format",
|
|
9771
10107
|
abort: false,
|
|
9772
|
-
...
|
|
10108
|
+
...normalizeParams(params),
|
|
9773
10109
|
});
|
|
9774
10110
|
}
|
|
9775
10111
|
function _cidrv4(Class, params) {
|
|
@@ -9873,7 +10209,7 @@ function _number(Class, params) {
|
|
|
9873
10209
|
return new Class({
|
|
9874
10210
|
type: "number",
|
|
9875
10211
|
checks: [],
|
|
9876
|
-
...
|
|
10212
|
+
...normalizeParams(params),
|
|
9877
10213
|
});
|
|
9878
10214
|
}
|
|
9879
10215
|
function _coercedNumber(Class, params) {
|
|
@@ -9890,7 +10226,7 @@ function _int(Class, params) {
|
|
|
9890
10226
|
check: "number_format",
|
|
9891
10227
|
abort: false,
|
|
9892
10228
|
format: "safeint",
|
|
9893
|
-
...
|
|
10229
|
+
...normalizeParams(params),
|
|
9894
10230
|
});
|
|
9895
10231
|
}
|
|
9896
10232
|
function _float32(Class, params) {
|
|
@@ -9899,7 +10235,7 @@ function _float32(Class, params) {
|
|
|
9899
10235
|
check: "number_format",
|
|
9900
10236
|
abort: false,
|
|
9901
10237
|
format: "float32",
|
|
9902
|
-
...
|
|
10238
|
+
...normalizeParams(params),
|
|
9903
10239
|
});
|
|
9904
10240
|
}
|
|
9905
10241
|
function _float64(Class, params) {
|
|
@@ -9908,7 +10244,7 @@ function _float64(Class, params) {
|
|
|
9908
10244
|
check: "number_format",
|
|
9909
10245
|
abort: false,
|
|
9910
10246
|
format: "float64",
|
|
9911
|
-
...
|
|
10247
|
+
...normalizeParams(params),
|
|
9912
10248
|
});
|
|
9913
10249
|
}
|
|
9914
10250
|
function _int32(Class, params) {
|
|
@@ -9917,7 +10253,7 @@ function _int32(Class, params) {
|
|
|
9917
10253
|
check: "number_format",
|
|
9918
10254
|
abort: false,
|
|
9919
10255
|
format: "int32",
|
|
9920
|
-
...
|
|
10256
|
+
...normalizeParams(params),
|
|
9921
10257
|
});
|
|
9922
10258
|
}
|
|
9923
10259
|
function _uint32(Class, params) {
|
|
@@ -9926,13 +10262,13 @@ function _uint32(Class, params) {
|
|
|
9926
10262
|
check: "number_format",
|
|
9927
10263
|
abort: false,
|
|
9928
10264
|
format: "uint32",
|
|
9929
|
-
...
|
|
10265
|
+
...normalizeParams(params),
|
|
9930
10266
|
});
|
|
9931
10267
|
}
|
|
9932
10268
|
function _boolean(Class, params) {
|
|
9933
10269
|
return new Class({
|
|
9934
10270
|
type: "boolean",
|
|
9935
|
-
...
|
|
10271
|
+
...normalizeParams(params),
|
|
9936
10272
|
});
|
|
9937
10273
|
}
|
|
9938
10274
|
function _coercedBoolean(Class, params) {
|
|
@@ -9945,7 +10281,7 @@ function _coercedBoolean(Class, params) {
|
|
|
9945
10281
|
function _bigint(Class, params) {
|
|
9946
10282
|
return new Class({
|
|
9947
10283
|
type: "bigint",
|
|
9948
|
-
...
|
|
10284
|
+
...normalizeParams(params),
|
|
9949
10285
|
});
|
|
9950
10286
|
}
|
|
9951
10287
|
function _coercedBigint(Class, params) {
|
|
@@ -9961,7 +10297,7 @@ function _int64(Class, params) {
|
|
|
9961
10297
|
check: "bigint_format",
|
|
9962
10298
|
abort: false,
|
|
9963
10299
|
format: "int64",
|
|
9964
|
-
...
|
|
10300
|
+
...normalizeParams(params),
|
|
9965
10301
|
});
|
|
9966
10302
|
}
|
|
9967
10303
|
function _uint64(Class, params) {
|
|
@@ -9970,25 +10306,25 @@ function _uint64(Class, params) {
|
|
|
9970
10306
|
check: "bigint_format",
|
|
9971
10307
|
abort: false,
|
|
9972
10308
|
format: "uint64",
|
|
9973
|
-
...
|
|
10309
|
+
...normalizeParams(params),
|
|
9974
10310
|
});
|
|
9975
10311
|
}
|
|
9976
10312
|
function _symbol(Class, params) {
|
|
9977
10313
|
return new Class({
|
|
9978
10314
|
type: "symbol",
|
|
9979
|
-
...
|
|
10315
|
+
...normalizeParams(params),
|
|
9980
10316
|
});
|
|
9981
10317
|
}
|
|
9982
10318
|
function api_undefined(Class, params) {
|
|
9983
10319
|
return new Class({
|
|
9984
10320
|
type: "undefined",
|
|
9985
|
-
...
|
|
10321
|
+
...normalizeParams(params),
|
|
9986
10322
|
});
|
|
9987
10323
|
}
|
|
9988
10324
|
function api_null(Class, params) {
|
|
9989
10325
|
return new Class({
|
|
9990
10326
|
type: "null",
|
|
9991
|
-
...
|
|
10327
|
+
...normalizeParams(params),
|
|
9992
10328
|
});
|
|
9993
10329
|
}
|
|
9994
10330
|
function _any(Class) {
|
|
@@ -10010,13 +10346,13 @@ function _never(Class, params) {
|
|
|
10010
10346
|
function _void(Class, params) {
|
|
10011
10347
|
return new Class({
|
|
10012
10348
|
type: "void",
|
|
10013
|
-
...
|
|
10349
|
+
...normalizeParams(params),
|
|
10014
10350
|
});
|
|
10015
10351
|
}
|
|
10016
10352
|
function _date(Class, params) {
|
|
10017
10353
|
return new Class({
|
|
10018
10354
|
type: "date",
|
|
10019
|
-
...
|
|
10355
|
+
...normalizeParams(params),
|
|
10020
10356
|
});
|
|
10021
10357
|
}
|
|
10022
10358
|
function _coercedDate(Class, params) {
|
|
@@ -10029,38 +10365,38 @@ function _coercedDate(Class, params) {
|
|
|
10029
10365
|
function _nan(Class, params) {
|
|
10030
10366
|
return new Class({
|
|
10031
10367
|
type: "nan",
|
|
10032
|
-
...
|
|
10368
|
+
...normalizeParams(params),
|
|
10033
10369
|
});
|
|
10034
10370
|
}
|
|
10035
10371
|
function _lt(value, params) {
|
|
10036
|
-
return new
|
|
10372
|
+
return new $ZodCheckLessThan({
|
|
10037
10373
|
check: "less_than",
|
|
10038
|
-
...
|
|
10374
|
+
...normalizeParams(params),
|
|
10039
10375
|
value,
|
|
10040
10376
|
inclusive: false,
|
|
10041
10377
|
});
|
|
10042
10378
|
}
|
|
10043
10379
|
function _lte(value, params) {
|
|
10044
|
-
return new
|
|
10380
|
+
return new $ZodCheckLessThan({
|
|
10045
10381
|
check: "less_than",
|
|
10046
|
-
...
|
|
10382
|
+
...normalizeParams(params),
|
|
10047
10383
|
value,
|
|
10048
10384
|
inclusive: true,
|
|
10049
10385
|
});
|
|
10050
10386
|
}
|
|
10051
10387
|
|
|
10052
10388
|
function _gt(value, params) {
|
|
10053
|
-
return new
|
|
10389
|
+
return new $ZodCheckGreaterThan({
|
|
10054
10390
|
check: "greater_than",
|
|
10055
|
-
...
|
|
10391
|
+
...normalizeParams(params),
|
|
10056
10392
|
value,
|
|
10057
10393
|
inclusive: false,
|
|
10058
10394
|
});
|
|
10059
10395
|
}
|
|
10060
10396
|
function _gte(value, params) {
|
|
10061
|
-
return new
|
|
10397
|
+
return new $ZodCheckGreaterThan({
|
|
10062
10398
|
check: "greater_than",
|
|
10063
|
-
...
|
|
10399
|
+
...normalizeParams(params),
|
|
10064
10400
|
value,
|
|
10065
10401
|
inclusive: true,
|
|
10066
10402
|
});
|
|
@@ -10082,30 +10418,30 @@ function _nonnegative(params) {
|
|
|
10082
10418
|
return _gte(0, params);
|
|
10083
10419
|
}
|
|
10084
10420
|
function _multipleOf(value, params) {
|
|
10085
|
-
return new
|
|
10421
|
+
return new $ZodCheckMultipleOf({
|
|
10086
10422
|
check: "multiple_of",
|
|
10087
|
-
...
|
|
10423
|
+
...normalizeParams(params),
|
|
10088
10424
|
value,
|
|
10089
10425
|
});
|
|
10090
10426
|
}
|
|
10091
10427
|
function _maxSize(maximum, params) {
|
|
10092
|
-
return new
|
|
10428
|
+
return new $ZodCheckMaxSize({
|
|
10093
10429
|
check: "max_size",
|
|
10094
|
-
...
|
|
10430
|
+
...normalizeParams(params),
|
|
10095
10431
|
maximum,
|
|
10096
10432
|
});
|
|
10097
10433
|
}
|
|
10098
10434
|
function _minSize(minimum, params) {
|
|
10099
|
-
return new
|
|
10435
|
+
return new $ZodCheckMinSize({
|
|
10100
10436
|
check: "min_size",
|
|
10101
|
-
...
|
|
10437
|
+
...normalizeParams(params),
|
|
10102
10438
|
minimum,
|
|
10103
10439
|
});
|
|
10104
10440
|
}
|
|
10105
10441
|
function _size(size, params) {
|
|
10106
|
-
return new
|
|
10442
|
+
return new $ZodCheckSizeEquals({
|
|
10107
10443
|
check: "size_equals",
|
|
10108
|
-
...
|
|
10444
|
+
...normalizeParams(params),
|
|
10109
10445
|
size,
|
|
10110
10446
|
});
|
|
10111
10447
|
}
|
|
@@ -10178,18 +10514,18 @@ function _endsWith(suffix, params) {
|
|
|
10178
10514
|
});
|
|
10179
10515
|
}
|
|
10180
10516
|
function _property(property, schema, params) {
|
|
10181
|
-
return new
|
|
10517
|
+
return new $ZodCheckProperty({
|
|
10182
10518
|
check: "property",
|
|
10183
10519
|
property,
|
|
10184
10520
|
schema,
|
|
10185
|
-
...
|
|
10521
|
+
...normalizeParams(params),
|
|
10186
10522
|
});
|
|
10187
10523
|
}
|
|
10188
10524
|
function _mime(types, params) {
|
|
10189
|
-
return new
|
|
10525
|
+
return new $ZodCheckMimeType({
|
|
10190
10526
|
check: "mime_type",
|
|
10191
10527
|
mime: types,
|
|
10192
|
-
...
|
|
10528
|
+
...normalizeParams(params),
|
|
10193
10529
|
});
|
|
10194
10530
|
}
|
|
10195
10531
|
function _overwrite(tx) {
|
|
@@ -10235,6 +10571,14 @@ function _union(Class, options, params) {
|
|
|
10235
10571
|
...util.normalizeParams(params),
|
|
10236
10572
|
});
|
|
10237
10573
|
}
|
|
10574
|
+
function _xor(Class, options, params) {
|
|
10575
|
+
return new Class({
|
|
10576
|
+
type: "union",
|
|
10577
|
+
options,
|
|
10578
|
+
inclusive: false,
|
|
10579
|
+
...util.normalizeParams(params),
|
|
10580
|
+
});
|
|
10581
|
+
}
|
|
10238
10582
|
function _discriminatedUnion(Class, discriminator, options, params) {
|
|
10239
10583
|
return new Class({
|
|
10240
10584
|
type: "union",
|
|
@@ -10332,7 +10676,7 @@ function _literal(Class, value, params) {
|
|
|
10332
10676
|
function _file(Class, params) {
|
|
10333
10677
|
return new Class({
|
|
10334
10678
|
type: "file",
|
|
10335
|
-
...
|
|
10679
|
+
...normalizeParams(params),
|
|
10336
10680
|
});
|
|
10337
10681
|
}
|
|
10338
10682
|
function _transform(Class, fn) {
|
|
@@ -10415,7 +10759,7 @@ function _promise(Class, innerType) {
|
|
|
10415
10759
|
});
|
|
10416
10760
|
}
|
|
10417
10761
|
function _custom(Class, fn, _params) {
|
|
10418
|
-
const norm =
|
|
10762
|
+
const norm = normalizeParams(_params);
|
|
10419
10763
|
norm.abort ?? (norm.abort = true); // default to abort:false
|
|
10420
10764
|
const schema = new Class({
|
|
10421
10765
|
type: "custom",
|
|
@@ -10469,8 +10813,8 @@ function describe(description) {
|
|
|
10469
10813
|
const ch = new $ZodCheck({ check: "describe" });
|
|
10470
10814
|
ch._zod.onattach = [
|
|
10471
10815
|
(inst) => {
|
|
10472
|
-
const existing =
|
|
10473
|
-
|
|
10816
|
+
const existing = globalRegistry.get(inst) ?? {};
|
|
10817
|
+
globalRegistry.add(inst, { ...existing, description });
|
|
10474
10818
|
},
|
|
10475
10819
|
];
|
|
10476
10820
|
ch._zod.check = () => { }; // no-op check
|
|
@@ -10480,15 +10824,15 @@ function meta(metadata) {
|
|
|
10480
10824
|
const ch = new $ZodCheck({ check: "meta" });
|
|
10481
10825
|
ch._zod.onattach = [
|
|
10482
10826
|
(inst) => {
|
|
10483
|
-
const existing =
|
|
10484
|
-
|
|
10827
|
+
const existing = globalRegistry.get(inst) ?? {};
|
|
10828
|
+
globalRegistry.add(inst, { ...existing, ...metadata });
|
|
10485
10829
|
},
|
|
10486
10830
|
];
|
|
10487
10831
|
ch._zod.check = () => { }; // no-op check
|
|
10488
10832
|
return ch;
|
|
10489
10833
|
}
|
|
10490
10834
|
function _stringbool(Classes, _params) {
|
|
10491
|
-
const params =
|
|
10835
|
+
const params = normalizeParams(_params);
|
|
10492
10836
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
10493
10837
|
let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
|
|
10494
10838
|
if (params.case !== "sensitive") {
|
|
@@ -10497,9 +10841,9 @@ function _stringbool(Classes, _params) {
|
|
|
10497
10841
|
}
|
|
10498
10842
|
const truthySet = new Set(truthyArray);
|
|
10499
10843
|
const falsySet = new Set(falsyArray);
|
|
10500
|
-
const _Codec = Classes.Codec ??
|
|
10501
|
-
const _Boolean = Classes.Boolean ??
|
|
10502
|
-
const _String = Classes.String ??
|
|
10844
|
+
const _Codec = Classes.Codec ?? $ZodCodec;
|
|
10845
|
+
const _Boolean = Classes.Boolean ?? $ZodBoolean;
|
|
10846
|
+
const _String = Classes.String ?? $ZodString;
|
|
10503
10847
|
const stringSchema = new _String({ type: "string", error: params.error });
|
|
10504
10848
|
const booleanSchema = new _Boolean({ type: "boolean", error: params.error });
|
|
10505
10849
|
const codec = new _Codec({
|
|
@@ -10541,9 +10885,9 @@ function _stringbool(Classes, _params) {
|
|
|
10541
10885
|
return codec;
|
|
10542
10886
|
}
|
|
10543
10887
|
function _stringFormat(Class, format, fnOrRegex, _params = {}) {
|
|
10544
|
-
const params =
|
|
10888
|
+
const params = normalizeParams(_params);
|
|
10545
10889
|
const def = {
|
|
10546
|
-
...
|
|
10890
|
+
...normalizeParams(_params),
|
|
10547
10891
|
check: "string_format",
|
|
10548
10892
|
type: "string",
|
|
10549
10893
|
format,
|
|
@@ -10559,825 +10903,313 @@ function _stringFormat(Class, format, fnOrRegex, _params = {}) {
|
|
|
10559
10903
|
|
|
10560
10904
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/to-json-schema.js
|
|
10561
10905
|
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10906
|
+
// function initializeContext<T extends schemas.$ZodType>(inputs: JSONSchemaGeneratorParams<T>): ToJSONSchemaContext<T> {
|
|
10907
|
+
// return {
|
|
10908
|
+
// processor: inputs.processor,
|
|
10909
|
+
// metadataRegistry: inputs.metadata ?? globalRegistry,
|
|
10910
|
+
// target: inputs.target ?? "draft-2020-12",
|
|
10911
|
+
// unrepresentable: inputs.unrepresentable ?? "throw",
|
|
10912
|
+
// };
|
|
10913
|
+
// }
|
|
10914
|
+
function to_json_schema_initializeContext(params) {
|
|
10915
|
+
// Normalize target: convert old non-hyphenated versions to hyphenated versions
|
|
10916
|
+
let target = params?.target ?? "draft-2020-12";
|
|
10917
|
+
if (target === "draft-4")
|
|
10918
|
+
target = "draft-04";
|
|
10919
|
+
if (target === "draft-7")
|
|
10920
|
+
target = "draft-07";
|
|
10921
|
+
return {
|
|
10922
|
+
processors: params.processors ?? {},
|
|
10923
|
+
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
10924
|
+
target,
|
|
10925
|
+
unrepresentable: params?.unrepresentable ?? "throw",
|
|
10926
|
+
override: params?.override ?? (() => { }),
|
|
10927
|
+
io: params?.io ?? "output",
|
|
10928
|
+
counter: 0,
|
|
10929
|
+
seen: new Map(),
|
|
10930
|
+
cycles: params?.cycles ?? "ref",
|
|
10931
|
+
reused: params?.reused ?? "inline",
|
|
10932
|
+
external: params?.external ?? undefined,
|
|
10933
|
+
};
|
|
10934
|
+
}
|
|
10935
|
+
function to_json_schema_process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
10936
|
+
var _a;
|
|
10937
|
+
const def = schema._zod.def;
|
|
10938
|
+
// check for schema in seens
|
|
10939
|
+
const seen = ctx.seen.get(schema);
|
|
10940
|
+
if (seen) {
|
|
10941
|
+
seen.count++;
|
|
10942
|
+
// check if cycle
|
|
10943
|
+
const isCycle = _params.schemaPath.includes(schema);
|
|
10944
|
+
if (isCycle) {
|
|
10945
|
+
seen.cycle = _params.path;
|
|
10946
|
+
}
|
|
10947
|
+
return seen.schema;
|
|
10948
|
+
}
|
|
10949
|
+
// initialize
|
|
10950
|
+
const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
|
|
10951
|
+
ctx.seen.set(schema, result);
|
|
10952
|
+
// custom method overrides default behavior
|
|
10953
|
+
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
10954
|
+
if (overrideSchema) {
|
|
10955
|
+
result.schema = overrideSchema;
|
|
10572
10956
|
}
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
url: "uri",
|
|
10579
|
-
datetime: "date-time",
|
|
10580
|
-
json_string: "json-string",
|
|
10581
|
-
regex: "", // do not set
|
|
10957
|
+
else {
|
|
10958
|
+
const params = {
|
|
10959
|
+
..._params,
|
|
10960
|
+
schemaPath: [..._params.schemaPath, schema],
|
|
10961
|
+
path: _params.path,
|
|
10582
10962
|
};
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
|
|
10591
|
-
|
|
10592
|
-
return seen.schema;
|
|
10593
|
-
}
|
|
10594
|
-
// initialize
|
|
10595
|
-
const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
|
|
10596
|
-
this.seen.set(schema, result);
|
|
10597
|
-
// custom method overrides default behavior
|
|
10598
|
-
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
10599
|
-
if (overrideSchema) {
|
|
10600
|
-
result.schema = overrideSchema;
|
|
10963
|
+
const parent = schema._zod.parent;
|
|
10964
|
+
if (parent) {
|
|
10965
|
+
// schema was cloned from another schema
|
|
10966
|
+
result.ref = parent;
|
|
10967
|
+
to_json_schema_process(parent, ctx, params);
|
|
10968
|
+
ctx.seen.get(parent).isParent = true;
|
|
10969
|
+
}
|
|
10970
|
+
else if (schema._zod.processJSONSchema) {
|
|
10971
|
+
schema._zod.processJSONSchema(ctx, result.schema, params);
|
|
10601
10972
|
}
|
|
10602
10973
|
else {
|
|
10603
|
-
const
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
}
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
|
|
10611
|
-
|
|
10612
|
-
|
|
10613
|
-
|
|
10974
|
+
const _json = result.schema;
|
|
10975
|
+
const processor = ctx.processors[def.type];
|
|
10976
|
+
if (!processor) {
|
|
10977
|
+
throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
10978
|
+
}
|
|
10979
|
+
processor(schema, ctx, _json, params);
|
|
10980
|
+
}
|
|
10981
|
+
}
|
|
10982
|
+
// metadata
|
|
10983
|
+
const meta = ctx.metadataRegistry.get(schema);
|
|
10984
|
+
if (meta)
|
|
10985
|
+
Object.assign(result.schema, meta);
|
|
10986
|
+
if (ctx.io === "input" && isTransforming(schema)) {
|
|
10987
|
+
// examples/defaults only apply to output type of pipe
|
|
10988
|
+
delete result.schema.examples;
|
|
10989
|
+
delete result.schema.default;
|
|
10990
|
+
}
|
|
10991
|
+
// set prefault as default
|
|
10992
|
+
if (ctx.io === "input" && result.schema._prefault)
|
|
10993
|
+
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
10994
|
+
delete result.schema._prefault;
|
|
10995
|
+
// pulling fresh from ctx.seen in case it was overwritten
|
|
10996
|
+
const _result = ctx.seen.get(schema);
|
|
10997
|
+
return _result.schema;
|
|
10998
|
+
}
|
|
10999
|
+
function to_json_schema_extractDefs(ctx, schema
|
|
11000
|
+
// params: EmitParams
|
|
11001
|
+
) {
|
|
11002
|
+
// iterate over seen map;
|
|
11003
|
+
const root = ctx.seen.get(schema);
|
|
11004
|
+
if (!root)
|
|
11005
|
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
11006
|
+
// returns a ref to the schema
|
|
11007
|
+
// defId will be empty if the ref points to an external schema (or #)
|
|
11008
|
+
const makeURI = (entry) => {
|
|
11009
|
+
// comparing the seen objects because sometimes
|
|
11010
|
+
// multiple schemas map to the same seen object.
|
|
11011
|
+
// e.g. lazy
|
|
11012
|
+
// external is configured
|
|
11013
|
+
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
11014
|
+
if (ctx.external) {
|
|
11015
|
+
const externalId = ctx.external.registry.get(entry[0])?.id; // ?? "__shared";// `__schema${ctx.counter++}`;
|
|
11016
|
+
// check if schema is in the external registry
|
|
11017
|
+
const uriGenerator = ctx.external.uri ?? ((id) => id);
|
|
11018
|
+
if (externalId) {
|
|
11019
|
+
return { ref: uriGenerator(externalId) };
|
|
11020
|
+
}
|
|
11021
|
+
// otherwise, add to __shared
|
|
11022
|
+
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
11023
|
+
entry[1].defId = id; // set defId so it will be reused if needed
|
|
11024
|
+
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
|
11025
|
+
}
|
|
11026
|
+
if (entry[1] === root) {
|
|
11027
|
+
return { ref: "#" };
|
|
11028
|
+
}
|
|
11029
|
+
// self-contained schema
|
|
11030
|
+
const uriPrefix = `#`;
|
|
11031
|
+
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
11032
|
+
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
11033
|
+
return { defId, ref: defUriPrefix + defId };
|
|
11034
|
+
};
|
|
11035
|
+
// stored cached version in `def` property
|
|
11036
|
+
// remove all properties, set $ref
|
|
11037
|
+
const extractToDef = (entry) => {
|
|
11038
|
+
// if the schema is already a reference, do not extract it
|
|
11039
|
+
if (entry[1].schema.$ref) {
|
|
11040
|
+
return;
|
|
11041
|
+
}
|
|
11042
|
+
const seen = entry[1];
|
|
11043
|
+
const { ref, defId } = makeURI(entry);
|
|
11044
|
+
seen.def = { ...seen.schema };
|
|
11045
|
+
// defId won't be set if the schema is a reference to an external schema
|
|
11046
|
+
// or if the schema is the root schema
|
|
11047
|
+
if (defId)
|
|
11048
|
+
seen.defId = defId;
|
|
11049
|
+
// wipe away all properties except $ref
|
|
11050
|
+
const schema = seen.schema;
|
|
11051
|
+
for (const key in schema) {
|
|
11052
|
+
delete schema[key];
|
|
11053
|
+
}
|
|
11054
|
+
schema.$ref = ref;
|
|
11055
|
+
};
|
|
11056
|
+
// throw on cycles
|
|
11057
|
+
// break cycles
|
|
11058
|
+
if (ctx.cycles === "throw") {
|
|
11059
|
+
for (const entry of ctx.seen.entries()) {
|
|
11060
|
+
const seen = entry[1];
|
|
11061
|
+
if (seen.cycle) {
|
|
11062
|
+
throw new Error("Cycle detected: " +
|
|
11063
|
+
`#/${seen.cycle?.join("/")}/<root>` +
|
|
11064
|
+
'\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.');
|
|
11065
|
+
}
|
|
11066
|
+
}
|
|
11067
|
+
}
|
|
11068
|
+
// extract schemas into $defs
|
|
11069
|
+
for (const entry of ctx.seen.entries()) {
|
|
11070
|
+
const seen = entry[1];
|
|
11071
|
+
// convert root schema to # $ref
|
|
11072
|
+
if (schema === entry[0]) {
|
|
11073
|
+
extractToDef(entry); // this has special handling for the root schema
|
|
11074
|
+
continue;
|
|
11075
|
+
}
|
|
11076
|
+
// extract schemas that are in the external registry
|
|
11077
|
+
if (ctx.external) {
|
|
11078
|
+
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
11079
|
+
if (schema !== entry[0] && ext) {
|
|
11080
|
+
extractToDef(entry);
|
|
11081
|
+
continue;
|
|
11082
|
+
}
|
|
11083
|
+
}
|
|
11084
|
+
// extract schemas with `id` meta
|
|
11085
|
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
11086
|
+
if (id) {
|
|
11087
|
+
extractToDef(entry);
|
|
11088
|
+
continue;
|
|
11089
|
+
}
|
|
11090
|
+
// break cycles
|
|
11091
|
+
if (seen.cycle) {
|
|
11092
|
+
// any
|
|
11093
|
+
extractToDef(entry);
|
|
11094
|
+
continue;
|
|
11095
|
+
}
|
|
11096
|
+
// extract reused schemas
|
|
11097
|
+
if (seen.count > 1) {
|
|
11098
|
+
if (ctx.reused === "ref") {
|
|
11099
|
+
extractToDef(entry);
|
|
11100
|
+
// biome-ignore lint:
|
|
11101
|
+
continue;
|
|
11102
|
+
}
|
|
11103
|
+
}
|
|
11104
|
+
}
|
|
11105
|
+
}
|
|
11106
|
+
function to_json_schema_finalize(ctx, schema) {
|
|
11107
|
+
//
|
|
11108
|
+
// iterate over seen map;
|
|
11109
|
+
const root = ctx.seen.get(schema);
|
|
11110
|
+
if (!root)
|
|
11111
|
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
11112
|
+
// flatten _refs
|
|
11113
|
+
const flattenRef = (zodSchema) => {
|
|
11114
|
+
const seen = ctx.seen.get(zodSchema);
|
|
11115
|
+
const schema = seen.def ?? seen.schema;
|
|
11116
|
+
const _cached = { ...schema };
|
|
11117
|
+
// already seen
|
|
11118
|
+
if (seen.ref === null) {
|
|
11119
|
+
return;
|
|
11120
|
+
}
|
|
11121
|
+
// flatten ref if defined
|
|
11122
|
+
const ref = seen.ref;
|
|
11123
|
+
seen.ref = null; // prevent recursion
|
|
11124
|
+
if (ref) {
|
|
11125
|
+
flattenRef(ref);
|
|
11126
|
+
// merge referenced schema into current
|
|
11127
|
+
const refSchema = ctx.seen.get(ref).schema;
|
|
11128
|
+
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
11129
|
+
schema.allOf = schema.allOf ?? [];
|
|
11130
|
+
schema.allOf.push(refSchema);
|
|
10614
11131
|
}
|
|
10615
11132
|
else {
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
case "string": {
|
|
10619
|
-
const json = _json;
|
|
10620
|
-
json.type = "string";
|
|
10621
|
-
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod
|
|
10622
|
-
.bag;
|
|
10623
|
-
if (typeof minimum === "number")
|
|
10624
|
-
json.minLength = minimum;
|
|
10625
|
-
if (typeof maximum === "number")
|
|
10626
|
-
json.maxLength = maximum;
|
|
10627
|
-
// custom pattern overrides format
|
|
10628
|
-
if (format) {
|
|
10629
|
-
json.format = formatMap[format] ?? format;
|
|
10630
|
-
if (json.format === "")
|
|
10631
|
-
delete json.format; // empty format is not valid
|
|
10632
|
-
}
|
|
10633
|
-
if (contentEncoding)
|
|
10634
|
-
json.contentEncoding = contentEncoding;
|
|
10635
|
-
if (patterns && patterns.size > 0) {
|
|
10636
|
-
const regexes = [...patterns];
|
|
10637
|
-
if (regexes.length === 1)
|
|
10638
|
-
json.pattern = regexes[0].source;
|
|
10639
|
-
else if (regexes.length > 1) {
|
|
10640
|
-
result.schema.allOf = [
|
|
10641
|
-
...regexes.map((regex) => ({
|
|
10642
|
-
...(this.target === "draft-7" || this.target === "draft-4" || this.target === "openapi-3.0"
|
|
10643
|
-
? { type: "string" }
|
|
10644
|
-
: {}),
|
|
10645
|
-
pattern: regex.source,
|
|
10646
|
-
})),
|
|
10647
|
-
];
|
|
10648
|
-
}
|
|
10649
|
-
}
|
|
10650
|
-
break;
|
|
10651
|
-
}
|
|
10652
|
-
case "number": {
|
|
10653
|
-
const json = _json;
|
|
10654
|
-
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
10655
|
-
if (typeof format === "string" && format.includes("int"))
|
|
10656
|
-
json.type = "integer";
|
|
10657
|
-
else
|
|
10658
|
-
json.type = "number";
|
|
10659
|
-
if (typeof exclusiveMinimum === "number") {
|
|
10660
|
-
if (this.target === "draft-4" || this.target === "openapi-3.0") {
|
|
10661
|
-
json.minimum = exclusiveMinimum;
|
|
10662
|
-
json.exclusiveMinimum = true;
|
|
10663
|
-
}
|
|
10664
|
-
else {
|
|
10665
|
-
json.exclusiveMinimum = exclusiveMinimum;
|
|
10666
|
-
}
|
|
10667
|
-
}
|
|
10668
|
-
if (typeof minimum === "number") {
|
|
10669
|
-
json.minimum = minimum;
|
|
10670
|
-
if (typeof exclusiveMinimum === "number" && this.target !== "draft-4") {
|
|
10671
|
-
if (exclusiveMinimum >= minimum)
|
|
10672
|
-
delete json.minimum;
|
|
10673
|
-
else
|
|
10674
|
-
delete json.exclusiveMinimum;
|
|
10675
|
-
}
|
|
10676
|
-
}
|
|
10677
|
-
if (typeof exclusiveMaximum === "number") {
|
|
10678
|
-
if (this.target === "draft-4" || this.target === "openapi-3.0") {
|
|
10679
|
-
json.maximum = exclusiveMaximum;
|
|
10680
|
-
json.exclusiveMaximum = true;
|
|
10681
|
-
}
|
|
10682
|
-
else {
|
|
10683
|
-
json.exclusiveMaximum = exclusiveMaximum;
|
|
10684
|
-
}
|
|
10685
|
-
}
|
|
10686
|
-
if (typeof maximum === "number") {
|
|
10687
|
-
json.maximum = maximum;
|
|
10688
|
-
if (typeof exclusiveMaximum === "number" && this.target !== "draft-4") {
|
|
10689
|
-
if (exclusiveMaximum <= maximum)
|
|
10690
|
-
delete json.maximum;
|
|
10691
|
-
else
|
|
10692
|
-
delete json.exclusiveMaximum;
|
|
10693
|
-
}
|
|
10694
|
-
}
|
|
10695
|
-
if (typeof multipleOf === "number")
|
|
10696
|
-
json.multipleOf = multipleOf;
|
|
10697
|
-
break;
|
|
10698
|
-
}
|
|
10699
|
-
case "boolean": {
|
|
10700
|
-
const json = _json;
|
|
10701
|
-
json.type = "boolean";
|
|
10702
|
-
break;
|
|
10703
|
-
}
|
|
10704
|
-
case "bigint": {
|
|
10705
|
-
if (this.unrepresentable === "throw") {
|
|
10706
|
-
throw new Error("BigInt cannot be represented in JSON Schema");
|
|
10707
|
-
}
|
|
10708
|
-
break;
|
|
10709
|
-
}
|
|
10710
|
-
case "symbol": {
|
|
10711
|
-
if (this.unrepresentable === "throw") {
|
|
10712
|
-
throw new Error("Symbols cannot be represented in JSON Schema");
|
|
10713
|
-
}
|
|
10714
|
-
break;
|
|
10715
|
-
}
|
|
10716
|
-
case "null": {
|
|
10717
|
-
if (this.target === "openapi-3.0") {
|
|
10718
|
-
_json.type = "string";
|
|
10719
|
-
_json.nullable = true;
|
|
10720
|
-
_json.enum = [null];
|
|
10721
|
-
}
|
|
10722
|
-
else
|
|
10723
|
-
_json.type = "null";
|
|
10724
|
-
break;
|
|
10725
|
-
}
|
|
10726
|
-
case "any": {
|
|
10727
|
-
break;
|
|
10728
|
-
}
|
|
10729
|
-
case "unknown": {
|
|
10730
|
-
break;
|
|
10731
|
-
}
|
|
10732
|
-
case "undefined": {
|
|
10733
|
-
if (this.unrepresentable === "throw") {
|
|
10734
|
-
throw new Error("Undefined cannot be represented in JSON Schema");
|
|
10735
|
-
}
|
|
10736
|
-
break;
|
|
10737
|
-
}
|
|
10738
|
-
case "void": {
|
|
10739
|
-
if (this.unrepresentable === "throw") {
|
|
10740
|
-
throw new Error("Void cannot be represented in JSON Schema");
|
|
10741
|
-
}
|
|
10742
|
-
break;
|
|
10743
|
-
}
|
|
10744
|
-
case "never": {
|
|
10745
|
-
_json.not = {};
|
|
10746
|
-
break;
|
|
10747
|
-
}
|
|
10748
|
-
case "date": {
|
|
10749
|
-
if (this.unrepresentable === "throw") {
|
|
10750
|
-
throw new Error("Date cannot be represented in JSON Schema");
|
|
10751
|
-
}
|
|
10752
|
-
break;
|
|
10753
|
-
}
|
|
10754
|
-
case "array": {
|
|
10755
|
-
const json = _json;
|
|
10756
|
-
const { minimum, maximum } = schema._zod.bag;
|
|
10757
|
-
if (typeof minimum === "number")
|
|
10758
|
-
json.minItems = minimum;
|
|
10759
|
-
if (typeof maximum === "number")
|
|
10760
|
-
json.maxItems = maximum;
|
|
10761
|
-
json.type = "array";
|
|
10762
|
-
json.items = this.process(def.element, { ...params, path: [...params.path, "items"] });
|
|
10763
|
-
break;
|
|
10764
|
-
}
|
|
10765
|
-
case "object": {
|
|
10766
|
-
const json = _json;
|
|
10767
|
-
json.type = "object";
|
|
10768
|
-
json.properties = {};
|
|
10769
|
-
const shape = def.shape; // params.shapeCache.get(schema)!;
|
|
10770
|
-
for (const key in shape) {
|
|
10771
|
-
json.properties[key] = this.process(shape[key], {
|
|
10772
|
-
...params,
|
|
10773
|
-
path: [...params.path, "properties", key],
|
|
10774
|
-
});
|
|
10775
|
-
}
|
|
10776
|
-
// required keys
|
|
10777
|
-
const allKeys = new Set(Object.keys(shape));
|
|
10778
|
-
// const optionalKeys = new Set(def.optional);
|
|
10779
|
-
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
10780
|
-
const v = def.shape[key]._zod;
|
|
10781
|
-
if (this.io === "input") {
|
|
10782
|
-
return v.optin === undefined;
|
|
10783
|
-
}
|
|
10784
|
-
else {
|
|
10785
|
-
return v.optout === undefined;
|
|
10786
|
-
}
|
|
10787
|
-
}));
|
|
10788
|
-
if (requiredKeys.size > 0) {
|
|
10789
|
-
json.required = Array.from(requiredKeys);
|
|
10790
|
-
}
|
|
10791
|
-
// catchall
|
|
10792
|
-
if (def.catchall?._zod.def.type === "never") {
|
|
10793
|
-
// strict
|
|
10794
|
-
json.additionalProperties = false;
|
|
10795
|
-
}
|
|
10796
|
-
else if (!def.catchall) {
|
|
10797
|
-
// regular
|
|
10798
|
-
if (this.io === "output")
|
|
10799
|
-
json.additionalProperties = false;
|
|
10800
|
-
}
|
|
10801
|
-
else if (def.catchall) {
|
|
10802
|
-
json.additionalProperties = this.process(def.catchall, {
|
|
10803
|
-
...params,
|
|
10804
|
-
path: [...params.path, "additionalProperties"],
|
|
10805
|
-
});
|
|
10806
|
-
}
|
|
10807
|
-
break;
|
|
10808
|
-
}
|
|
10809
|
-
case "union": {
|
|
10810
|
-
const json = _json;
|
|
10811
|
-
// Discriminated unions use oneOf (exactly one match) instead of anyOf (one or more matches)
|
|
10812
|
-
// because the discriminator field ensures mutual exclusivity between options in JSON Schema
|
|
10813
|
-
const isDiscriminated = def.discriminator !== undefined;
|
|
10814
|
-
const options = def.options.map((x, i) => this.process(x, {
|
|
10815
|
-
...params,
|
|
10816
|
-
path: [...params.path, isDiscriminated ? "oneOf" : "anyOf", i],
|
|
10817
|
-
}));
|
|
10818
|
-
if (isDiscriminated) {
|
|
10819
|
-
json.oneOf = options;
|
|
10820
|
-
}
|
|
10821
|
-
else {
|
|
10822
|
-
json.anyOf = options;
|
|
10823
|
-
}
|
|
10824
|
-
break;
|
|
10825
|
-
}
|
|
10826
|
-
case "intersection": {
|
|
10827
|
-
const json = _json;
|
|
10828
|
-
const a = this.process(def.left, {
|
|
10829
|
-
...params,
|
|
10830
|
-
path: [...params.path, "allOf", 0],
|
|
10831
|
-
});
|
|
10832
|
-
const b = this.process(def.right, {
|
|
10833
|
-
...params,
|
|
10834
|
-
path: [...params.path, "allOf", 1],
|
|
10835
|
-
});
|
|
10836
|
-
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
10837
|
-
const allOf = [
|
|
10838
|
-
...(isSimpleIntersection(a) ? a.allOf : [a]),
|
|
10839
|
-
...(isSimpleIntersection(b) ? b.allOf : [b]),
|
|
10840
|
-
];
|
|
10841
|
-
json.allOf = allOf;
|
|
10842
|
-
break;
|
|
10843
|
-
}
|
|
10844
|
-
case "tuple": {
|
|
10845
|
-
const json = _json;
|
|
10846
|
-
json.type = "array";
|
|
10847
|
-
const prefixPath = this.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
10848
|
-
const restPath = this.target === "draft-2020-12" ? "items" : this.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
10849
|
-
const prefixItems = def.items.map((x, i) => this.process(x, {
|
|
10850
|
-
...params,
|
|
10851
|
-
path: [...params.path, prefixPath, i],
|
|
10852
|
-
}));
|
|
10853
|
-
const rest = def.rest
|
|
10854
|
-
? this.process(def.rest, {
|
|
10855
|
-
...params,
|
|
10856
|
-
path: [...params.path, restPath, ...(this.target === "openapi-3.0" ? [def.items.length] : [])],
|
|
10857
|
-
})
|
|
10858
|
-
: null;
|
|
10859
|
-
if (this.target === "draft-2020-12") {
|
|
10860
|
-
json.prefixItems = prefixItems;
|
|
10861
|
-
if (rest) {
|
|
10862
|
-
json.items = rest;
|
|
10863
|
-
}
|
|
10864
|
-
}
|
|
10865
|
-
else if (this.target === "openapi-3.0") {
|
|
10866
|
-
json.items = {
|
|
10867
|
-
anyOf: prefixItems,
|
|
10868
|
-
};
|
|
10869
|
-
if (rest) {
|
|
10870
|
-
json.items.anyOf.push(rest);
|
|
10871
|
-
}
|
|
10872
|
-
json.minItems = prefixItems.length;
|
|
10873
|
-
if (!rest) {
|
|
10874
|
-
json.maxItems = prefixItems.length;
|
|
10875
|
-
}
|
|
10876
|
-
}
|
|
10877
|
-
else {
|
|
10878
|
-
json.items = prefixItems;
|
|
10879
|
-
if (rest) {
|
|
10880
|
-
json.additionalItems = rest;
|
|
10881
|
-
}
|
|
10882
|
-
}
|
|
10883
|
-
// length
|
|
10884
|
-
const { minimum, maximum } = schema._zod.bag;
|
|
10885
|
-
if (typeof minimum === "number")
|
|
10886
|
-
json.minItems = minimum;
|
|
10887
|
-
if (typeof maximum === "number")
|
|
10888
|
-
json.maxItems = maximum;
|
|
10889
|
-
break;
|
|
10890
|
-
}
|
|
10891
|
-
case "record": {
|
|
10892
|
-
const json = _json;
|
|
10893
|
-
json.type = "object";
|
|
10894
|
-
if (this.target === "draft-7" || this.target === "draft-2020-12") {
|
|
10895
|
-
json.propertyNames = this.process(def.keyType, {
|
|
10896
|
-
...params,
|
|
10897
|
-
path: [...params.path, "propertyNames"],
|
|
10898
|
-
});
|
|
10899
|
-
}
|
|
10900
|
-
json.additionalProperties = this.process(def.valueType, {
|
|
10901
|
-
...params,
|
|
10902
|
-
path: [...params.path, "additionalProperties"],
|
|
10903
|
-
});
|
|
10904
|
-
break;
|
|
10905
|
-
}
|
|
10906
|
-
case "map": {
|
|
10907
|
-
if (this.unrepresentable === "throw") {
|
|
10908
|
-
throw new Error("Map cannot be represented in JSON Schema");
|
|
10909
|
-
}
|
|
10910
|
-
break;
|
|
10911
|
-
}
|
|
10912
|
-
case "set": {
|
|
10913
|
-
if (this.unrepresentable === "throw") {
|
|
10914
|
-
throw new Error("Set cannot be represented in JSON Schema");
|
|
10915
|
-
}
|
|
10916
|
-
break;
|
|
10917
|
-
}
|
|
10918
|
-
case "enum": {
|
|
10919
|
-
const json = _json;
|
|
10920
|
-
const values = getEnumValues(def.entries);
|
|
10921
|
-
// Number enums can have both string and number values
|
|
10922
|
-
if (values.every((v) => typeof v === "number"))
|
|
10923
|
-
json.type = "number";
|
|
10924
|
-
if (values.every((v) => typeof v === "string"))
|
|
10925
|
-
json.type = "string";
|
|
10926
|
-
json.enum = values;
|
|
10927
|
-
break;
|
|
10928
|
-
}
|
|
10929
|
-
case "literal": {
|
|
10930
|
-
const json = _json;
|
|
10931
|
-
const vals = [];
|
|
10932
|
-
for (const val of def.values) {
|
|
10933
|
-
if (val === undefined) {
|
|
10934
|
-
if (this.unrepresentable === "throw") {
|
|
10935
|
-
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
10936
|
-
}
|
|
10937
|
-
else {
|
|
10938
|
-
// do not add to vals
|
|
10939
|
-
}
|
|
10940
|
-
}
|
|
10941
|
-
else if (typeof val === "bigint") {
|
|
10942
|
-
if (this.unrepresentable === "throw") {
|
|
10943
|
-
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
10944
|
-
}
|
|
10945
|
-
else {
|
|
10946
|
-
vals.push(Number(val));
|
|
10947
|
-
}
|
|
10948
|
-
}
|
|
10949
|
-
else {
|
|
10950
|
-
vals.push(val);
|
|
10951
|
-
}
|
|
10952
|
-
}
|
|
10953
|
-
if (vals.length === 0) {
|
|
10954
|
-
// do nothing (an undefined literal was stripped)
|
|
10955
|
-
}
|
|
10956
|
-
else if (vals.length === 1) {
|
|
10957
|
-
const val = vals[0];
|
|
10958
|
-
json.type = val === null ? "null" : typeof val;
|
|
10959
|
-
if (this.target === "draft-4" || this.target === "openapi-3.0") {
|
|
10960
|
-
json.enum = [val];
|
|
10961
|
-
}
|
|
10962
|
-
else {
|
|
10963
|
-
json.const = val;
|
|
10964
|
-
}
|
|
10965
|
-
}
|
|
10966
|
-
else {
|
|
10967
|
-
if (vals.every((v) => typeof v === "number"))
|
|
10968
|
-
json.type = "number";
|
|
10969
|
-
if (vals.every((v) => typeof v === "string"))
|
|
10970
|
-
json.type = "string";
|
|
10971
|
-
if (vals.every((v) => typeof v === "boolean"))
|
|
10972
|
-
json.type = "string";
|
|
10973
|
-
if (vals.every((v) => v === null))
|
|
10974
|
-
json.type = "null";
|
|
10975
|
-
json.enum = vals;
|
|
10976
|
-
}
|
|
10977
|
-
break;
|
|
10978
|
-
}
|
|
10979
|
-
case "file": {
|
|
10980
|
-
const json = _json;
|
|
10981
|
-
const file = {
|
|
10982
|
-
type: "string",
|
|
10983
|
-
format: "binary",
|
|
10984
|
-
contentEncoding: "binary",
|
|
10985
|
-
};
|
|
10986
|
-
const { minimum, maximum, mime } = schema._zod.bag;
|
|
10987
|
-
if (minimum !== undefined)
|
|
10988
|
-
file.minLength = minimum;
|
|
10989
|
-
if (maximum !== undefined)
|
|
10990
|
-
file.maxLength = maximum;
|
|
10991
|
-
if (mime) {
|
|
10992
|
-
if (mime.length === 1) {
|
|
10993
|
-
file.contentMediaType = mime[0];
|
|
10994
|
-
Object.assign(json, file);
|
|
10995
|
-
}
|
|
10996
|
-
else {
|
|
10997
|
-
json.anyOf = mime.map((m) => {
|
|
10998
|
-
const mFile = { ...file, contentMediaType: m };
|
|
10999
|
-
return mFile;
|
|
11000
|
-
});
|
|
11001
|
-
}
|
|
11002
|
-
}
|
|
11003
|
-
else {
|
|
11004
|
-
Object.assign(json, file);
|
|
11005
|
-
}
|
|
11006
|
-
// if (this.unrepresentable === "throw") {
|
|
11007
|
-
// throw new Error("File cannot be represented in JSON Schema");
|
|
11008
|
-
// }
|
|
11009
|
-
break;
|
|
11010
|
-
}
|
|
11011
|
-
case "transform": {
|
|
11012
|
-
if (this.unrepresentable === "throw") {
|
|
11013
|
-
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
11014
|
-
}
|
|
11015
|
-
break;
|
|
11016
|
-
}
|
|
11017
|
-
case "nullable": {
|
|
11018
|
-
const inner = this.process(def.innerType, params);
|
|
11019
|
-
if (this.target === "openapi-3.0") {
|
|
11020
|
-
result.ref = def.innerType;
|
|
11021
|
-
_json.nullable = true;
|
|
11022
|
-
}
|
|
11023
|
-
else {
|
|
11024
|
-
_json.anyOf = [inner, { type: "null" }];
|
|
11025
|
-
}
|
|
11026
|
-
break;
|
|
11027
|
-
}
|
|
11028
|
-
case "nonoptional": {
|
|
11029
|
-
this.process(def.innerType, params);
|
|
11030
|
-
result.ref = def.innerType;
|
|
11031
|
-
break;
|
|
11032
|
-
}
|
|
11033
|
-
case "success": {
|
|
11034
|
-
const json = _json;
|
|
11035
|
-
json.type = "boolean";
|
|
11036
|
-
break;
|
|
11037
|
-
}
|
|
11038
|
-
case "default": {
|
|
11039
|
-
this.process(def.innerType, params);
|
|
11040
|
-
result.ref = def.innerType;
|
|
11041
|
-
_json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
11042
|
-
break;
|
|
11043
|
-
}
|
|
11044
|
-
case "prefault": {
|
|
11045
|
-
this.process(def.innerType, params);
|
|
11046
|
-
result.ref = def.innerType;
|
|
11047
|
-
if (this.io === "input")
|
|
11048
|
-
_json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
11049
|
-
break;
|
|
11050
|
-
}
|
|
11051
|
-
case "catch": {
|
|
11052
|
-
// use conditionals
|
|
11053
|
-
this.process(def.innerType, params);
|
|
11054
|
-
result.ref = def.innerType;
|
|
11055
|
-
let catchValue;
|
|
11056
|
-
try {
|
|
11057
|
-
catchValue = def.catchValue(undefined);
|
|
11058
|
-
}
|
|
11059
|
-
catch {
|
|
11060
|
-
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
11061
|
-
}
|
|
11062
|
-
_json.default = catchValue;
|
|
11063
|
-
break;
|
|
11064
|
-
}
|
|
11065
|
-
case "nan": {
|
|
11066
|
-
if (this.unrepresentable === "throw") {
|
|
11067
|
-
throw new Error("NaN cannot be represented in JSON Schema");
|
|
11068
|
-
}
|
|
11069
|
-
break;
|
|
11070
|
-
}
|
|
11071
|
-
case "template_literal": {
|
|
11072
|
-
const json = _json;
|
|
11073
|
-
const pattern = schema._zod.pattern;
|
|
11074
|
-
if (!pattern)
|
|
11075
|
-
throw new Error("Pattern not found in template literal");
|
|
11076
|
-
json.type = "string";
|
|
11077
|
-
json.pattern = pattern.source;
|
|
11078
|
-
break;
|
|
11079
|
-
}
|
|
11080
|
-
case "pipe": {
|
|
11081
|
-
const innerType = this.io === "input" ? (def.in._zod.def.type === "transform" ? def.out : def.in) : def.out;
|
|
11082
|
-
this.process(innerType, params);
|
|
11083
|
-
result.ref = innerType;
|
|
11084
|
-
break;
|
|
11085
|
-
}
|
|
11086
|
-
case "readonly": {
|
|
11087
|
-
this.process(def.innerType, params);
|
|
11088
|
-
result.ref = def.innerType;
|
|
11089
|
-
_json.readOnly = true;
|
|
11090
|
-
break;
|
|
11091
|
-
}
|
|
11092
|
-
// passthrough types
|
|
11093
|
-
case "promise": {
|
|
11094
|
-
this.process(def.innerType, params);
|
|
11095
|
-
result.ref = def.innerType;
|
|
11096
|
-
break;
|
|
11097
|
-
}
|
|
11098
|
-
case "optional": {
|
|
11099
|
-
this.process(def.innerType, params);
|
|
11100
|
-
result.ref = def.innerType;
|
|
11101
|
-
break;
|
|
11102
|
-
}
|
|
11103
|
-
case "lazy": {
|
|
11104
|
-
const innerType = schema._zod.innerType;
|
|
11105
|
-
this.process(innerType, params);
|
|
11106
|
-
result.ref = innerType;
|
|
11107
|
-
break;
|
|
11108
|
-
}
|
|
11109
|
-
case "custom": {
|
|
11110
|
-
if (this.unrepresentable === "throw") {
|
|
11111
|
-
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
11112
|
-
}
|
|
11113
|
-
break;
|
|
11114
|
-
}
|
|
11115
|
-
case "function": {
|
|
11116
|
-
if (this.unrepresentable === "throw") {
|
|
11117
|
-
throw new Error("Function types cannot be represented in JSON Schema");
|
|
11118
|
-
}
|
|
11119
|
-
break;
|
|
11120
|
-
}
|
|
11121
|
-
default: {
|
|
11122
|
-
def;
|
|
11123
|
-
}
|
|
11124
|
-
}
|
|
11133
|
+
Object.assign(schema, refSchema);
|
|
11134
|
+
Object.assign(schema, _cached); // prevent overwriting any fields in the original schema
|
|
11125
11135
|
}
|
|
11126
11136
|
}
|
|
11127
|
-
//
|
|
11128
|
-
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
|
-
|
|
11135
|
-
|
|
11136
|
-
|
|
11137
|
-
if (this.io === "input" && result.schema._prefault)
|
|
11138
|
-
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
11139
|
-
delete result.schema._prefault;
|
|
11140
|
-
// pulling fresh from this.seen in case it was overwritten
|
|
11141
|
-
const _result = this.seen.get(schema);
|
|
11142
|
-
return _result.schema;
|
|
11137
|
+
// execute overrides
|
|
11138
|
+
if (!seen.isParent)
|
|
11139
|
+
ctx.override({
|
|
11140
|
+
zodSchema: zodSchema,
|
|
11141
|
+
jsonSchema: schema,
|
|
11142
|
+
path: seen.path ?? [],
|
|
11143
|
+
});
|
|
11144
|
+
};
|
|
11145
|
+
for (const entry of [...ctx.seen.entries()].reverse()) {
|
|
11146
|
+
flattenRef(entry[0]);
|
|
11143
11147
|
}
|
|
11144
|
-
|
|
11145
|
-
|
|
11146
|
-
|
|
11147
|
-
|
|
11148
|
-
|
|
11149
|
-
|
|
11150
|
-
|
|
11151
|
-
|
|
11152
|
-
|
|
11153
|
-
|
|
11154
|
-
|
|
11155
|
-
|
|
11156
|
-
|
|
11157
|
-
|
|
11158
|
-
//
|
|
11159
|
-
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
|
|
11164
|
-
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
|
|
11168
|
-
|
|
11169
|
-
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
// otherwise, add to __shared
|
|
11174
|
-
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${this.counter++}`;
|
|
11175
|
-
entry[1].defId = id; // set defId so it will be reused if needed
|
|
11176
|
-
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
|
11177
|
-
}
|
|
11178
|
-
if (entry[1] === root) {
|
|
11179
|
-
return { ref: "#" };
|
|
11180
|
-
}
|
|
11181
|
-
// self-contained schema
|
|
11182
|
-
const uriPrefix = `#`;
|
|
11183
|
-
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
11184
|
-
const defId = entry[1].schema.id ?? `__schema${this.counter++}`;
|
|
11185
|
-
return { defId, ref: defUriPrefix + defId };
|
|
11186
|
-
};
|
|
11187
|
-
// stored cached version in `def` property
|
|
11188
|
-
// remove all properties, set $ref
|
|
11189
|
-
const extractToDef = (entry) => {
|
|
11190
|
-
// if the schema is already a reference, do not extract it
|
|
11191
|
-
if (entry[1].schema.$ref) {
|
|
11192
|
-
return;
|
|
11193
|
-
}
|
|
11194
|
-
const seen = entry[1];
|
|
11195
|
-
const { ref, defId } = makeURI(entry);
|
|
11196
|
-
seen.def = { ...seen.schema };
|
|
11197
|
-
// defId won't be set if the schema is a reference to an external schema
|
|
11198
|
-
if (defId)
|
|
11199
|
-
seen.defId = defId;
|
|
11200
|
-
// wipe away all properties except $ref
|
|
11201
|
-
const schema = seen.schema;
|
|
11202
|
-
for (const key in schema) {
|
|
11203
|
-
delete schema[key];
|
|
11204
|
-
}
|
|
11205
|
-
schema.$ref = ref;
|
|
11206
|
-
};
|
|
11207
|
-
// throw on cycles
|
|
11208
|
-
// break cycles
|
|
11209
|
-
if (params.cycles === "throw") {
|
|
11210
|
-
for (const entry of this.seen.entries()) {
|
|
11211
|
-
const seen = entry[1];
|
|
11212
|
-
if (seen.cycle) {
|
|
11213
|
-
throw new Error("Cycle detected: " +
|
|
11214
|
-
`#/${seen.cycle?.join("/")}/<root>` +
|
|
11215
|
-
'\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.');
|
|
11216
|
-
}
|
|
11217
|
-
}
|
|
11218
|
-
}
|
|
11219
|
-
// extract schemas into $defs
|
|
11220
|
-
for (const entry of this.seen.entries()) {
|
|
11221
|
-
const seen = entry[1];
|
|
11222
|
-
// convert root schema to # $ref
|
|
11223
|
-
if (schema === entry[0]) {
|
|
11224
|
-
extractToDef(entry); // this has special handling for the root schema
|
|
11225
|
-
continue;
|
|
11226
|
-
}
|
|
11227
|
-
// extract schemas that are in the external registry
|
|
11228
|
-
if (params.external) {
|
|
11229
|
-
const ext = params.external.registry.get(entry[0])?.id;
|
|
11230
|
-
if (schema !== entry[0] && ext) {
|
|
11231
|
-
extractToDef(entry);
|
|
11232
|
-
continue;
|
|
11233
|
-
}
|
|
11234
|
-
}
|
|
11235
|
-
// extract schemas with `id` meta
|
|
11236
|
-
const id = this.metadataRegistry.get(entry[0])?.id;
|
|
11237
|
-
if (id) {
|
|
11238
|
-
extractToDef(entry);
|
|
11239
|
-
continue;
|
|
11240
|
-
}
|
|
11241
|
-
// break cycles
|
|
11242
|
-
if (seen.cycle) {
|
|
11243
|
-
// any
|
|
11244
|
-
extractToDef(entry);
|
|
11245
|
-
continue;
|
|
11246
|
-
}
|
|
11247
|
-
// extract reused schemas
|
|
11248
|
-
if (seen.count > 1) {
|
|
11249
|
-
if (params.reused === "ref") {
|
|
11250
|
-
extractToDef(entry);
|
|
11251
|
-
// biome-ignore lint:
|
|
11252
|
-
continue;
|
|
11253
|
-
}
|
|
11254
|
-
}
|
|
11255
|
-
}
|
|
11256
|
-
// flatten _refs
|
|
11257
|
-
const flattenRef = (zodSchema, params) => {
|
|
11258
|
-
const seen = this.seen.get(zodSchema);
|
|
11259
|
-
const schema = seen.def ?? seen.schema;
|
|
11260
|
-
const _cached = { ...schema };
|
|
11261
|
-
// already seen
|
|
11262
|
-
if (seen.ref === null) {
|
|
11263
|
-
return;
|
|
11264
|
-
}
|
|
11265
|
-
// flatten ref if defined
|
|
11266
|
-
const ref = seen.ref;
|
|
11267
|
-
seen.ref = null; // prevent recursion
|
|
11268
|
-
if (ref) {
|
|
11269
|
-
flattenRef(ref, params);
|
|
11270
|
-
// merge referenced schema into current
|
|
11271
|
-
const refSchema = this.seen.get(ref).schema;
|
|
11272
|
-
if (refSchema.$ref &&
|
|
11273
|
-
(params.target === "draft-7" || params.target === "draft-4" || params.target === "openapi-3.0")) {
|
|
11274
|
-
schema.allOf = schema.allOf ?? [];
|
|
11275
|
-
schema.allOf.push(refSchema);
|
|
11276
|
-
}
|
|
11277
|
-
else {
|
|
11278
|
-
Object.assign(schema, refSchema);
|
|
11279
|
-
Object.assign(schema, _cached); // prevent overwriting any fields in the original schema
|
|
11280
|
-
}
|
|
11281
|
-
}
|
|
11282
|
-
// execute overrides
|
|
11283
|
-
if (!seen.isParent)
|
|
11284
|
-
this.override({
|
|
11285
|
-
zodSchema: zodSchema,
|
|
11286
|
-
jsonSchema: schema,
|
|
11287
|
-
path: seen.path ?? [],
|
|
11288
|
-
});
|
|
11289
|
-
};
|
|
11290
|
-
for (const entry of [...this.seen.entries()].reverse()) {
|
|
11291
|
-
flattenRef(entry[0], { target: this.target });
|
|
11292
|
-
}
|
|
11293
|
-
const result = {};
|
|
11294
|
-
if (this.target === "draft-2020-12") {
|
|
11295
|
-
result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
11296
|
-
}
|
|
11297
|
-
else if (this.target === "draft-7") {
|
|
11298
|
-
result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
11299
|
-
}
|
|
11300
|
-
else if (this.target === "draft-4") {
|
|
11301
|
-
result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
11302
|
-
}
|
|
11303
|
-
else if (this.target === "openapi-3.0") {
|
|
11304
|
-
// OpenAPI 3.0 schema objects should not include a $schema property
|
|
11148
|
+
const result = {};
|
|
11149
|
+
if (ctx.target === "draft-2020-12") {
|
|
11150
|
+
result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
11151
|
+
}
|
|
11152
|
+
else if (ctx.target === "draft-07") {
|
|
11153
|
+
result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
11154
|
+
}
|
|
11155
|
+
else if (ctx.target === "draft-04") {
|
|
11156
|
+
result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
11157
|
+
}
|
|
11158
|
+
else if (ctx.target === "openapi-3.0") {
|
|
11159
|
+
// OpenAPI 3.0 schema objects should not include a $schema property
|
|
11160
|
+
}
|
|
11161
|
+
else {
|
|
11162
|
+
// Arbitrary string values are allowed but won't have a $schema property set
|
|
11163
|
+
}
|
|
11164
|
+
if (ctx.external?.uri) {
|
|
11165
|
+
const id = ctx.external.registry.get(schema)?.id;
|
|
11166
|
+
if (!id)
|
|
11167
|
+
throw new Error("Schema is missing an `id` property");
|
|
11168
|
+
result.$id = ctx.external.uri(id);
|
|
11169
|
+
}
|
|
11170
|
+
Object.assign(result, root.def ?? root.schema);
|
|
11171
|
+
// build defs object
|
|
11172
|
+
const defs = ctx.external?.defs ?? {};
|
|
11173
|
+
for (const entry of ctx.seen.entries()) {
|
|
11174
|
+
const seen = entry[1];
|
|
11175
|
+
if (seen.def && seen.defId) {
|
|
11176
|
+
defs[seen.defId] = seen.def;
|
|
11305
11177
|
}
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
if (
|
|
11313
|
-
|
|
11314
|
-
result.$id = params.external.uri(id);
|
|
11315
|
-
}
|
|
11316
|
-
Object.assign(result, root.def);
|
|
11317
|
-
// build defs object
|
|
11318
|
-
const defs = params.external?.defs ?? {};
|
|
11319
|
-
for (const entry of this.seen.entries()) {
|
|
11320
|
-
const seen = entry[1];
|
|
11321
|
-
if (seen.def && seen.defId) {
|
|
11322
|
-
defs[seen.defId] = seen.def;
|
|
11178
|
+
}
|
|
11179
|
+
// set definitions in result
|
|
11180
|
+
if (ctx.external) {
|
|
11181
|
+
}
|
|
11182
|
+
else {
|
|
11183
|
+
if (Object.keys(defs).length > 0) {
|
|
11184
|
+
if (ctx.target === "draft-2020-12") {
|
|
11185
|
+
result.$defs = defs;
|
|
11323
11186
|
}
|
|
11324
|
-
|
|
11325
|
-
|
|
11326
|
-
if (params.external) {
|
|
11327
|
-
}
|
|
11328
|
-
else {
|
|
11329
|
-
if (Object.keys(defs).length > 0) {
|
|
11330
|
-
if (this.target === "draft-2020-12") {
|
|
11331
|
-
result.$defs = defs;
|
|
11332
|
-
}
|
|
11333
|
-
else {
|
|
11334
|
-
result.definitions = defs;
|
|
11335
|
-
}
|
|
11187
|
+
else {
|
|
11188
|
+
result.definitions = defs;
|
|
11336
11189
|
}
|
|
11337
11190
|
}
|
|
11338
|
-
try {
|
|
11339
|
-
// this "finalizes" this schema and ensures all cycles are removed
|
|
11340
|
-
// each call to .emit() is functionally independent
|
|
11341
|
-
// though the seen map is shared
|
|
11342
|
-
return JSON.parse(JSON.stringify(result));
|
|
11343
|
-
}
|
|
11344
|
-
catch (_err) {
|
|
11345
|
-
throw new Error("Error converting schema to JSON.");
|
|
11346
|
-
}
|
|
11347
11191
|
}
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
const
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
|
|
11359
|
-
|
|
11360
|
-
|
|
11361
|
-
|
|
11362
|
-
|
|
11363
|
-
|
|
11364
|
-
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
|
|
11368
|
-
});
|
|
11369
|
-
}
|
|
11370
|
-
if (Object.keys(defs).length > 0) {
|
|
11371
|
-
const defsSegment = gen.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
11372
|
-
schemas.__shared = {
|
|
11373
|
-
[defsSegment]: defs,
|
|
11374
|
-
};
|
|
11375
|
-
}
|
|
11376
|
-
return { schemas };
|
|
11192
|
+
try {
|
|
11193
|
+
// this "finalizes" this schema and ensures all cycles are removed
|
|
11194
|
+
// each call to finalize() is functionally independent
|
|
11195
|
+
// though the seen map is shared
|
|
11196
|
+
const finalized = JSON.parse(JSON.stringify(result));
|
|
11197
|
+
Object.defineProperty(finalized, "~standard", {
|
|
11198
|
+
value: {
|
|
11199
|
+
...schema["~standard"],
|
|
11200
|
+
jsonSchema: {
|
|
11201
|
+
input: createStandardJSONSchemaMethod(schema, "input"),
|
|
11202
|
+
output: createStandardJSONSchemaMethod(schema, "output"),
|
|
11203
|
+
},
|
|
11204
|
+
},
|
|
11205
|
+
enumerable: false,
|
|
11206
|
+
writable: false,
|
|
11207
|
+
});
|
|
11208
|
+
return finalized;
|
|
11209
|
+
}
|
|
11210
|
+
catch (_err) {
|
|
11211
|
+
throw new Error("Error converting schema to JSON.");
|
|
11377
11212
|
}
|
|
11378
|
-
const gen = new JSONSchemaGenerator(_params);
|
|
11379
|
-
gen.process(input);
|
|
11380
|
-
return gen.emit(input, _params);
|
|
11381
11213
|
}
|
|
11382
11214
|
function isTransforming(_schema, _ctx) {
|
|
11383
11215
|
const ctx = _ctx ?? { seen: new Set() };
|
|
@@ -11436,6 +11268,696 @@ function isTransforming(_schema, _ctx) {
|
|
|
11436
11268
|
}
|
|
11437
11269
|
return false;
|
|
11438
11270
|
}
|
|
11271
|
+
/**
|
|
11272
|
+
* Creates a toJSONSchema method for a schema instance.
|
|
11273
|
+
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
|
11274
|
+
*/
|
|
11275
|
+
const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
11276
|
+
const ctx = to_json_schema_initializeContext({ ...params, processors });
|
|
11277
|
+
to_json_schema_process(schema, ctx);
|
|
11278
|
+
to_json_schema_extractDefs(ctx, schema);
|
|
11279
|
+
return to_json_schema_finalize(ctx, schema);
|
|
11280
|
+
};
|
|
11281
|
+
const createStandardJSONSchemaMethod = (schema, io) => (params) => {
|
|
11282
|
+
const { libraryOptions, target } = params ?? {};
|
|
11283
|
+
const ctx = to_json_schema_initializeContext({ ...(libraryOptions ?? {}), target, io, processors: {} });
|
|
11284
|
+
to_json_schema_process(schema, ctx);
|
|
11285
|
+
to_json_schema_extractDefs(ctx, schema);
|
|
11286
|
+
return to_json_schema_finalize(ctx, schema);
|
|
11287
|
+
};
|
|
11288
|
+
|
|
11289
|
+
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/json-schema-processors.js
|
|
11290
|
+
|
|
11291
|
+
|
|
11292
|
+
const formatMap = {
|
|
11293
|
+
guid: "uuid",
|
|
11294
|
+
url: "uri",
|
|
11295
|
+
datetime: "date-time",
|
|
11296
|
+
json_string: "json-string",
|
|
11297
|
+
regex: "", // do not set
|
|
11298
|
+
};
|
|
11299
|
+
// ==================== SIMPLE TYPE PROCESSORS ====================
|
|
11300
|
+
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
11301
|
+
const json = _json;
|
|
11302
|
+
json.type = "string";
|
|
11303
|
+
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod
|
|
11304
|
+
.bag;
|
|
11305
|
+
if (typeof minimum === "number")
|
|
11306
|
+
json.minLength = minimum;
|
|
11307
|
+
if (typeof maximum === "number")
|
|
11308
|
+
json.maxLength = maximum;
|
|
11309
|
+
// custom pattern overrides format
|
|
11310
|
+
if (format) {
|
|
11311
|
+
json.format = formatMap[format] ?? format;
|
|
11312
|
+
if (json.format === "")
|
|
11313
|
+
delete json.format; // empty format is not valid
|
|
11314
|
+
}
|
|
11315
|
+
if (contentEncoding)
|
|
11316
|
+
json.contentEncoding = contentEncoding;
|
|
11317
|
+
if (patterns && patterns.size > 0) {
|
|
11318
|
+
const regexes = [...patterns];
|
|
11319
|
+
if (regexes.length === 1)
|
|
11320
|
+
json.pattern = regexes[0].source;
|
|
11321
|
+
else if (regexes.length > 1) {
|
|
11322
|
+
json.allOf = [
|
|
11323
|
+
...regexes.map((regex) => ({
|
|
11324
|
+
...(ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0"
|
|
11325
|
+
? { type: "string" }
|
|
11326
|
+
: {}),
|
|
11327
|
+
pattern: regex.source,
|
|
11328
|
+
})),
|
|
11329
|
+
];
|
|
11330
|
+
}
|
|
11331
|
+
}
|
|
11332
|
+
};
|
|
11333
|
+
const numberProcessor = (schema, ctx, _json, _params) => {
|
|
11334
|
+
const json = _json;
|
|
11335
|
+
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
11336
|
+
if (typeof format === "string" && format.includes("int"))
|
|
11337
|
+
json.type = "integer";
|
|
11338
|
+
else
|
|
11339
|
+
json.type = "number";
|
|
11340
|
+
if (typeof exclusiveMinimum === "number") {
|
|
11341
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
11342
|
+
json.minimum = exclusiveMinimum;
|
|
11343
|
+
json.exclusiveMinimum = true;
|
|
11344
|
+
}
|
|
11345
|
+
else {
|
|
11346
|
+
json.exclusiveMinimum = exclusiveMinimum;
|
|
11347
|
+
}
|
|
11348
|
+
}
|
|
11349
|
+
if (typeof minimum === "number") {
|
|
11350
|
+
json.minimum = minimum;
|
|
11351
|
+
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
|
|
11352
|
+
if (exclusiveMinimum >= minimum)
|
|
11353
|
+
delete json.minimum;
|
|
11354
|
+
else
|
|
11355
|
+
delete json.exclusiveMinimum;
|
|
11356
|
+
}
|
|
11357
|
+
}
|
|
11358
|
+
if (typeof exclusiveMaximum === "number") {
|
|
11359
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
11360
|
+
json.maximum = exclusiveMaximum;
|
|
11361
|
+
json.exclusiveMaximum = true;
|
|
11362
|
+
}
|
|
11363
|
+
else {
|
|
11364
|
+
json.exclusiveMaximum = exclusiveMaximum;
|
|
11365
|
+
}
|
|
11366
|
+
}
|
|
11367
|
+
if (typeof maximum === "number") {
|
|
11368
|
+
json.maximum = maximum;
|
|
11369
|
+
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
|
|
11370
|
+
if (exclusiveMaximum <= maximum)
|
|
11371
|
+
delete json.maximum;
|
|
11372
|
+
else
|
|
11373
|
+
delete json.exclusiveMaximum;
|
|
11374
|
+
}
|
|
11375
|
+
}
|
|
11376
|
+
if (typeof multipleOf === "number")
|
|
11377
|
+
json.multipleOf = multipleOf;
|
|
11378
|
+
};
|
|
11379
|
+
const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
11380
|
+
json.type = "boolean";
|
|
11381
|
+
};
|
|
11382
|
+
const bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
11383
|
+
if (ctx.unrepresentable === "throw") {
|
|
11384
|
+
throw new Error("BigInt cannot be represented in JSON Schema");
|
|
11385
|
+
}
|
|
11386
|
+
};
|
|
11387
|
+
const symbolProcessor = (_schema, ctx, _json, _params) => {
|
|
11388
|
+
if (ctx.unrepresentable === "throw") {
|
|
11389
|
+
throw new Error("Symbols cannot be represented in JSON Schema");
|
|
11390
|
+
}
|
|
11391
|
+
};
|
|
11392
|
+
const nullProcessor = (_schema, ctx, json, _params) => {
|
|
11393
|
+
if (ctx.target === "openapi-3.0") {
|
|
11394
|
+
json.type = "string";
|
|
11395
|
+
json.nullable = true;
|
|
11396
|
+
json.enum = [null];
|
|
11397
|
+
}
|
|
11398
|
+
else {
|
|
11399
|
+
json.type = "null";
|
|
11400
|
+
}
|
|
11401
|
+
};
|
|
11402
|
+
const undefinedProcessor = (_schema, ctx, _json, _params) => {
|
|
11403
|
+
if (ctx.unrepresentable === "throw") {
|
|
11404
|
+
throw new Error("Undefined cannot be represented in JSON Schema");
|
|
11405
|
+
}
|
|
11406
|
+
};
|
|
11407
|
+
const voidProcessor = (_schema, ctx, _json, _params) => {
|
|
11408
|
+
if (ctx.unrepresentable === "throw") {
|
|
11409
|
+
throw new Error("Void cannot be represented in JSON Schema");
|
|
11410
|
+
}
|
|
11411
|
+
};
|
|
11412
|
+
const neverProcessor = (_schema, _ctx, json, _params) => {
|
|
11413
|
+
json.not = {};
|
|
11414
|
+
};
|
|
11415
|
+
const anyProcessor = (_schema, _ctx, _json, _params) => {
|
|
11416
|
+
// empty schema accepts anything
|
|
11417
|
+
};
|
|
11418
|
+
const unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
11419
|
+
// empty schema accepts anything
|
|
11420
|
+
};
|
|
11421
|
+
const dateProcessor = (_schema, ctx, _json, _params) => {
|
|
11422
|
+
if (ctx.unrepresentable === "throw") {
|
|
11423
|
+
throw new Error("Date cannot be represented in JSON Schema");
|
|
11424
|
+
}
|
|
11425
|
+
};
|
|
11426
|
+
const enumProcessor = (schema, _ctx, json, _params) => {
|
|
11427
|
+
const def = schema._zod.def;
|
|
11428
|
+
const values = getEnumValues(def.entries);
|
|
11429
|
+
// Number enums can have both string and number values
|
|
11430
|
+
if (values.every((v) => typeof v === "number"))
|
|
11431
|
+
json.type = "number";
|
|
11432
|
+
if (values.every((v) => typeof v === "string"))
|
|
11433
|
+
json.type = "string";
|
|
11434
|
+
json.enum = values;
|
|
11435
|
+
};
|
|
11436
|
+
const literalProcessor = (schema, ctx, json, _params) => {
|
|
11437
|
+
const def = schema._zod.def;
|
|
11438
|
+
const vals = [];
|
|
11439
|
+
for (const val of def.values) {
|
|
11440
|
+
if (val === undefined) {
|
|
11441
|
+
if (ctx.unrepresentable === "throw") {
|
|
11442
|
+
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
11443
|
+
}
|
|
11444
|
+
else {
|
|
11445
|
+
// do not add to vals
|
|
11446
|
+
}
|
|
11447
|
+
}
|
|
11448
|
+
else if (typeof val === "bigint") {
|
|
11449
|
+
if (ctx.unrepresentable === "throw") {
|
|
11450
|
+
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
11451
|
+
}
|
|
11452
|
+
else {
|
|
11453
|
+
vals.push(Number(val));
|
|
11454
|
+
}
|
|
11455
|
+
}
|
|
11456
|
+
else {
|
|
11457
|
+
vals.push(val);
|
|
11458
|
+
}
|
|
11459
|
+
}
|
|
11460
|
+
if (vals.length === 0) {
|
|
11461
|
+
// do nothing (an undefined literal was stripped)
|
|
11462
|
+
}
|
|
11463
|
+
else if (vals.length === 1) {
|
|
11464
|
+
const val = vals[0];
|
|
11465
|
+
json.type = val === null ? "null" : typeof val;
|
|
11466
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
11467
|
+
json.enum = [val];
|
|
11468
|
+
}
|
|
11469
|
+
else {
|
|
11470
|
+
json.const = val;
|
|
11471
|
+
}
|
|
11472
|
+
}
|
|
11473
|
+
else {
|
|
11474
|
+
if (vals.every((v) => typeof v === "number"))
|
|
11475
|
+
json.type = "number";
|
|
11476
|
+
if (vals.every((v) => typeof v === "string"))
|
|
11477
|
+
json.type = "string";
|
|
11478
|
+
if (vals.every((v) => typeof v === "boolean"))
|
|
11479
|
+
json.type = "boolean";
|
|
11480
|
+
if (vals.every((v) => v === null))
|
|
11481
|
+
json.type = "null";
|
|
11482
|
+
json.enum = vals;
|
|
11483
|
+
}
|
|
11484
|
+
};
|
|
11485
|
+
const nanProcessor = (_schema, ctx, _json, _params) => {
|
|
11486
|
+
if (ctx.unrepresentable === "throw") {
|
|
11487
|
+
throw new Error("NaN cannot be represented in JSON Schema");
|
|
11488
|
+
}
|
|
11489
|
+
};
|
|
11490
|
+
const templateLiteralProcessor = (schema, _ctx, json, _params) => {
|
|
11491
|
+
const _json = json;
|
|
11492
|
+
const pattern = schema._zod.pattern;
|
|
11493
|
+
if (!pattern)
|
|
11494
|
+
throw new Error("Pattern not found in template literal");
|
|
11495
|
+
_json.type = "string";
|
|
11496
|
+
_json.pattern = pattern.source;
|
|
11497
|
+
};
|
|
11498
|
+
const fileProcessor = (schema, _ctx, json, _params) => {
|
|
11499
|
+
const _json = json;
|
|
11500
|
+
const file = {
|
|
11501
|
+
type: "string",
|
|
11502
|
+
format: "binary",
|
|
11503
|
+
contentEncoding: "binary",
|
|
11504
|
+
};
|
|
11505
|
+
const { minimum, maximum, mime } = schema._zod.bag;
|
|
11506
|
+
if (minimum !== undefined)
|
|
11507
|
+
file.minLength = minimum;
|
|
11508
|
+
if (maximum !== undefined)
|
|
11509
|
+
file.maxLength = maximum;
|
|
11510
|
+
if (mime) {
|
|
11511
|
+
if (mime.length === 1) {
|
|
11512
|
+
file.contentMediaType = mime[0];
|
|
11513
|
+
Object.assign(_json, file);
|
|
11514
|
+
}
|
|
11515
|
+
else {
|
|
11516
|
+
_json.anyOf = mime.map((m) => {
|
|
11517
|
+
const mFile = { ...file, contentMediaType: m };
|
|
11518
|
+
return mFile;
|
|
11519
|
+
});
|
|
11520
|
+
}
|
|
11521
|
+
}
|
|
11522
|
+
else {
|
|
11523
|
+
Object.assign(_json, file);
|
|
11524
|
+
}
|
|
11525
|
+
};
|
|
11526
|
+
const successProcessor = (_schema, _ctx, json, _params) => {
|
|
11527
|
+
json.type = "boolean";
|
|
11528
|
+
};
|
|
11529
|
+
const customProcessor = (_schema, ctx, _json, _params) => {
|
|
11530
|
+
if (ctx.unrepresentable === "throw") {
|
|
11531
|
+
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
11532
|
+
}
|
|
11533
|
+
};
|
|
11534
|
+
const functionProcessor = (_schema, ctx, _json, _params) => {
|
|
11535
|
+
if (ctx.unrepresentable === "throw") {
|
|
11536
|
+
throw new Error("Function types cannot be represented in JSON Schema");
|
|
11537
|
+
}
|
|
11538
|
+
};
|
|
11539
|
+
const transformProcessor = (_schema, ctx, _json, _params) => {
|
|
11540
|
+
if (ctx.unrepresentable === "throw") {
|
|
11541
|
+
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
11542
|
+
}
|
|
11543
|
+
};
|
|
11544
|
+
const mapProcessor = (_schema, ctx, _json, _params) => {
|
|
11545
|
+
if (ctx.unrepresentable === "throw") {
|
|
11546
|
+
throw new Error("Map cannot be represented in JSON Schema");
|
|
11547
|
+
}
|
|
11548
|
+
};
|
|
11549
|
+
const setProcessor = (_schema, ctx, _json, _params) => {
|
|
11550
|
+
if (ctx.unrepresentable === "throw") {
|
|
11551
|
+
throw new Error("Set cannot be represented in JSON Schema");
|
|
11552
|
+
}
|
|
11553
|
+
};
|
|
11554
|
+
// ==================== COMPOSITE TYPE PROCESSORS ====================
|
|
11555
|
+
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
11556
|
+
const json = _json;
|
|
11557
|
+
const def = schema._zod.def;
|
|
11558
|
+
const { minimum, maximum } = schema._zod.bag;
|
|
11559
|
+
if (typeof minimum === "number")
|
|
11560
|
+
json.minItems = minimum;
|
|
11561
|
+
if (typeof maximum === "number")
|
|
11562
|
+
json.maxItems = maximum;
|
|
11563
|
+
json.type = "array";
|
|
11564
|
+
json.items = to_json_schema_process(def.element, ctx, { ...params, path: [...params.path, "items"] });
|
|
11565
|
+
};
|
|
11566
|
+
const objectProcessor = (schema, ctx, _json, params) => {
|
|
11567
|
+
const json = _json;
|
|
11568
|
+
const def = schema._zod.def;
|
|
11569
|
+
json.type = "object";
|
|
11570
|
+
json.properties = {};
|
|
11571
|
+
const shape = def.shape;
|
|
11572
|
+
for (const key in shape) {
|
|
11573
|
+
json.properties[key] = to_json_schema_process(shape[key], ctx, {
|
|
11574
|
+
...params,
|
|
11575
|
+
path: [...params.path, "properties", key],
|
|
11576
|
+
});
|
|
11577
|
+
}
|
|
11578
|
+
// required keys
|
|
11579
|
+
const allKeys = new Set(Object.keys(shape));
|
|
11580
|
+
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
11581
|
+
const v = def.shape[key]._zod;
|
|
11582
|
+
if (ctx.io === "input") {
|
|
11583
|
+
return v.optin === undefined;
|
|
11584
|
+
}
|
|
11585
|
+
else {
|
|
11586
|
+
return v.optout === undefined;
|
|
11587
|
+
}
|
|
11588
|
+
}));
|
|
11589
|
+
if (requiredKeys.size > 0) {
|
|
11590
|
+
json.required = Array.from(requiredKeys);
|
|
11591
|
+
}
|
|
11592
|
+
// catchall
|
|
11593
|
+
if (def.catchall?._zod.def.type === "never") {
|
|
11594
|
+
// strict
|
|
11595
|
+
json.additionalProperties = false;
|
|
11596
|
+
}
|
|
11597
|
+
else if (!def.catchall) {
|
|
11598
|
+
// regular
|
|
11599
|
+
if (ctx.io === "output")
|
|
11600
|
+
json.additionalProperties = false;
|
|
11601
|
+
}
|
|
11602
|
+
else if (def.catchall) {
|
|
11603
|
+
json.additionalProperties = to_json_schema_process(def.catchall, ctx, {
|
|
11604
|
+
...params,
|
|
11605
|
+
path: [...params.path, "additionalProperties"],
|
|
11606
|
+
});
|
|
11607
|
+
}
|
|
11608
|
+
};
|
|
11609
|
+
const unionProcessor = (schema, ctx, json, params) => {
|
|
11610
|
+
const def = schema._zod.def;
|
|
11611
|
+
// Exclusive unions (inclusive === false) use oneOf (exactly one match) instead of anyOf (one or more matches)
|
|
11612
|
+
// This includes both z.xor() and discriminated unions
|
|
11613
|
+
const isExclusive = def.inclusive === false;
|
|
11614
|
+
const options = def.options.map((x, i) => to_json_schema_process(x, ctx, {
|
|
11615
|
+
...params,
|
|
11616
|
+
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i],
|
|
11617
|
+
}));
|
|
11618
|
+
if (isExclusive) {
|
|
11619
|
+
json.oneOf = options;
|
|
11620
|
+
}
|
|
11621
|
+
else {
|
|
11622
|
+
json.anyOf = options;
|
|
11623
|
+
}
|
|
11624
|
+
};
|
|
11625
|
+
const intersectionProcessor = (schema, ctx, json, params) => {
|
|
11626
|
+
const def = schema._zod.def;
|
|
11627
|
+
const a = to_json_schema_process(def.left, ctx, {
|
|
11628
|
+
...params,
|
|
11629
|
+
path: [...params.path, "allOf", 0],
|
|
11630
|
+
});
|
|
11631
|
+
const b = to_json_schema_process(def.right, ctx, {
|
|
11632
|
+
...params,
|
|
11633
|
+
path: [...params.path, "allOf", 1],
|
|
11634
|
+
});
|
|
11635
|
+
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
11636
|
+
const allOf = [
|
|
11637
|
+
...(isSimpleIntersection(a) ? a.allOf : [a]),
|
|
11638
|
+
...(isSimpleIntersection(b) ? b.allOf : [b]),
|
|
11639
|
+
];
|
|
11640
|
+
json.allOf = allOf;
|
|
11641
|
+
};
|
|
11642
|
+
const tupleProcessor = (schema, ctx, _json, params) => {
|
|
11643
|
+
const json = _json;
|
|
11644
|
+
const def = schema._zod.def;
|
|
11645
|
+
json.type = "array";
|
|
11646
|
+
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
11647
|
+
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
11648
|
+
const prefixItems = def.items.map((x, i) => to_json_schema_process(x, ctx, {
|
|
11649
|
+
...params,
|
|
11650
|
+
path: [...params.path, prefixPath, i],
|
|
11651
|
+
}));
|
|
11652
|
+
const rest = def.rest
|
|
11653
|
+
? to_json_schema_process(def.rest, ctx, {
|
|
11654
|
+
...params,
|
|
11655
|
+
path: [...params.path, restPath, ...(ctx.target === "openapi-3.0" ? [def.items.length] : [])],
|
|
11656
|
+
})
|
|
11657
|
+
: null;
|
|
11658
|
+
if (ctx.target === "draft-2020-12") {
|
|
11659
|
+
json.prefixItems = prefixItems;
|
|
11660
|
+
if (rest) {
|
|
11661
|
+
json.items = rest;
|
|
11662
|
+
}
|
|
11663
|
+
}
|
|
11664
|
+
else if (ctx.target === "openapi-3.0") {
|
|
11665
|
+
json.items = {
|
|
11666
|
+
anyOf: prefixItems,
|
|
11667
|
+
};
|
|
11668
|
+
if (rest) {
|
|
11669
|
+
json.items.anyOf.push(rest);
|
|
11670
|
+
}
|
|
11671
|
+
json.minItems = prefixItems.length;
|
|
11672
|
+
if (!rest) {
|
|
11673
|
+
json.maxItems = prefixItems.length;
|
|
11674
|
+
}
|
|
11675
|
+
}
|
|
11676
|
+
else {
|
|
11677
|
+
json.items = prefixItems;
|
|
11678
|
+
if (rest) {
|
|
11679
|
+
json.additionalItems = rest;
|
|
11680
|
+
}
|
|
11681
|
+
}
|
|
11682
|
+
// length
|
|
11683
|
+
const { minimum, maximum } = schema._zod.bag;
|
|
11684
|
+
if (typeof minimum === "number")
|
|
11685
|
+
json.minItems = minimum;
|
|
11686
|
+
if (typeof maximum === "number")
|
|
11687
|
+
json.maxItems = maximum;
|
|
11688
|
+
};
|
|
11689
|
+
const recordProcessor = (schema, ctx, _json, params) => {
|
|
11690
|
+
const json = _json;
|
|
11691
|
+
const def = schema._zod.def;
|
|
11692
|
+
json.type = "object";
|
|
11693
|
+
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
11694
|
+
json.propertyNames = to_json_schema_process(def.keyType, ctx, {
|
|
11695
|
+
...params,
|
|
11696
|
+
path: [...params.path, "propertyNames"],
|
|
11697
|
+
});
|
|
11698
|
+
}
|
|
11699
|
+
json.additionalProperties = to_json_schema_process(def.valueType, ctx, {
|
|
11700
|
+
...params,
|
|
11701
|
+
path: [...params.path, "additionalProperties"],
|
|
11702
|
+
});
|
|
11703
|
+
};
|
|
11704
|
+
const nullableProcessor = (schema, ctx, json, params) => {
|
|
11705
|
+
const def = schema._zod.def;
|
|
11706
|
+
const inner = to_json_schema_process(def.innerType, ctx, params);
|
|
11707
|
+
const seen = ctx.seen.get(schema);
|
|
11708
|
+
if (ctx.target === "openapi-3.0") {
|
|
11709
|
+
seen.ref = def.innerType;
|
|
11710
|
+
json.nullable = true;
|
|
11711
|
+
}
|
|
11712
|
+
else {
|
|
11713
|
+
json.anyOf = [inner, { type: "null" }];
|
|
11714
|
+
}
|
|
11715
|
+
};
|
|
11716
|
+
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
11717
|
+
const def = schema._zod.def;
|
|
11718
|
+
to_json_schema_process(def.innerType, ctx, params);
|
|
11719
|
+
const seen = ctx.seen.get(schema);
|
|
11720
|
+
seen.ref = def.innerType;
|
|
11721
|
+
};
|
|
11722
|
+
const defaultProcessor = (schema, ctx, json, params) => {
|
|
11723
|
+
const def = schema._zod.def;
|
|
11724
|
+
to_json_schema_process(def.innerType, ctx, params);
|
|
11725
|
+
const seen = ctx.seen.get(schema);
|
|
11726
|
+
seen.ref = def.innerType;
|
|
11727
|
+
json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
11728
|
+
};
|
|
11729
|
+
const prefaultProcessor = (schema, ctx, json, params) => {
|
|
11730
|
+
const def = schema._zod.def;
|
|
11731
|
+
to_json_schema_process(def.innerType, ctx, params);
|
|
11732
|
+
const seen = ctx.seen.get(schema);
|
|
11733
|
+
seen.ref = def.innerType;
|
|
11734
|
+
if (ctx.io === "input")
|
|
11735
|
+
json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
11736
|
+
};
|
|
11737
|
+
const catchProcessor = (schema, ctx, json, params) => {
|
|
11738
|
+
const def = schema._zod.def;
|
|
11739
|
+
to_json_schema_process(def.innerType, ctx, params);
|
|
11740
|
+
const seen = ctx.seen.get(schema);
|
|
11741
|
+
seen.ref = def.innerType;
|
|
11742
|
+
let catchValue;
|
|
11743
|
+
try {
|
|
11744
|
+
catchValue = def.catchValue(undefined);
|
|
11745
|
+
}
|
|
11746
|
+
catch {
|
|
11747
|
+
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
11748
|
+
}
|
|
11749
|
+
json.default = catchValue;
|
|
11750
|
+
};
|
|
11751
|
+
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
11752
|
+
const def = schema._zod.def;
|
|
11753
|
+
const innerType = ctx.io === "input" ? (def.in._zod.def.type === "transform" ? def.out : def.in) : def.out;
|
|
11754
|
+
to_json_schema_process(innerType, ctx, params);
|
|
11755
|
+
const seen = ctx.seen.get(schema);
|
|
11756
|
+
seen.ref = innerType;
|
|
11757
|
+
};
|
|
11758
|
+
const readonlyProcessor = (schema, ctx, json, params) => {
|
|
11759
|
+
const def = schema._zod.def;
|
|
11760
|
+
to_json_schema_process(def.innerType, ctx, params);
|
|
11761
|
+
const seen = ctx.seen.get(schema);
|
|
11762
|
+
seen.ref = def.innerType;
|
|
11763
|
+
json.readOnly = true;
|
|
11764
|
+
};
|
|
11765
|
+
const promiseProcessor = (schema, ctx, _json, params) => {
|
|
11766
|
+
const def = schema._zod.def;
|
|
11767
|
+
to_json_schema_process(def.innerType, ctx, params);
|
|
11768
|
+
const seen = ctx.seen.get(schema);
|
|
11769
|
+
seen.ref = def.innerType;
|
|
11770
|
+
};
|
|
11771
|
+
const optionalProcessor = (schema, ctx, _json, params) => {
|
|
11772
|
+
const def = schema._zod.def;
|
|
11773
|
+
to_json_schema_process(def.innerType, ctx, params);
|
|
11774
|
+
const seen = ctx.seen.get(schema);
|
|
11775
|
+
seen.ref = def.innerType;
|
|
11776
|
+
};
|
|
11777
|
+
const lazyProcessor = (schema, ctx, _json, params) => {
|
|
11778
|
+
const innerType = schema._zod.innerType;
|
|
11779
|
+
to_json_schema_process(innerType, ctx, params);
|
|
11780
|
+
const seen = ctx.seen.get(schema);
|
|
11781
|
+
seen.ref = innerType;
|
|
11782
|
+
};
|
|
11783
|
+
// ==================== ALL PROCESSORS ====================
|
|
11784
|
+
const json_schema_processors_allProcessors = {
|
|
11785
|
+
string: stringProcessor,
|
|
11786
|
+
number: numberProcessor,
|
|
11787
|
+
boolean: booleanProcessor,
|
|
11788
|
+
bigint: bigintProcessor,
|
|
11789
|
+
symbol: symbolProcessor,
|
|
11790
|
+
null: nullProcessor,
|
|
11791
|
+
undefined: undefinedProcessor,
|
|
11792
|
+
void: voidProcessor,
|
|
11793
|
+
never: neverProcessor,
|
|
11794
|
+
any: anyProcessor,
|
|
11795
|
+
unknown: unknownProcessor,
|
|
11796
|
+
date: dateProcessor,
|
|
11797
|
+
enum: enumProcessor,
|
|
11798
|
+
literal: literalProcessor,
|
|
11799
|
+
nan: nanProcessor,
|
|
11800
|
+
template_literal: templateLiteralProcessor,
|
|
11801
|
+
file: fileProcessor,
|
|
11802
|
+
success: successProcessor,
|
|
11803
|
+
custom: customProcessor,
|
|
11804
|
+
function: functionProcessor,
|
|
11805
|
+
transform: transformProcessor,
|
|
11806
|
+
map: mapProcessor,
|
|
11807
|
+
set: setProcessor,
|
|
11808
|
+
array: arrayProcessor,
|
|
11809
|
+
object: objectProcessor,
|
|
11810
|
+
union: unionProcessor,
|
|
11811
|
+
intersection: intersectionProcessor,
|
|
11812
|
+
tuple: tupleProcessor,
|
|
11813
|
+
record: recordProcessor,
|
|
11814
|
+
nullable: nullableProcessor,
|
|
11815
|
+
nonoptional: nonoptionalProcessor,
|
|
11816
|
+
default: defaultProcessor,
|
|
11817
|
+
prefault: prefaultProcessor,
|
|
11818
|
+
catch: catchProcessor,
|
|
11819
|
+
pipe: pipeProcessor,
|
|
11820
|
+
readonly: readonlyProcessor,
|
|
11821
|
+
promise: promiseProcessor,
|
|
11822
|
+
optional: optionalProcessor,
|
|
11823
|
+
lazy: lazyProcessor,
|
|
11824
|
+
};
|
|
11825
|
+
function toJSONSchema(input, params) {
|
|
11826
|
+
if ("_idmap" in input) {
|
|
11827
|
+
// Registry case
|
|
11828
|
+
const registry = input;
|
|
11829
|
+
const ctx = initializeContext({ ...params, processors: json_schema_processors_allProcessors });
|
|
11830
|
+
const defs = {};
|
|
11831
|
+
// First pass: process all schemas to build the seen map
|
|
11832
|
+
for (const entry of registry._idmap.entries()) {
|
|
11833
|
+
const [_, schema] = entry;
|
|
11834
|
+
process(schema, ctx);
|
|
11835
|
+
}
|
|
11836
|
+
const schemas = {};
|
|
11837
|
+
const external = {
|
|
11838
|
+
registry,
|
|
11839
|
+
uri: params?.uri,
|
|
11840
|
+
defs,
|
|
11841
|
+
};
|
|
11842
|
+
// Update the context with external configuration
|
|
11843
|
+
ctx.external = external;
|
|
11844
|
+
// Second pass: emit each schema
|
|
11845
|
+
for (const entry of registry._idmap.entries()) {
|
|
11846
|
+
const [key, schema] = entry;
|
|
11847
|
+
extractDefs(ctx, schema);
|
|
11848
|
+
schemas[key] = finalize(ctx, schema);
|
|
11849
|
+
}
|
|
11850
|
+
if (Object.keys(defs).length > 0) {
|
|
11851
|
+
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
11852
|
+
schemas.__shared = {
|
|
11853
|
+
[defsSegment]: defs,
|
|
11854
|
+
};
|
|
11855
|
+
}
|
|
11856
|
+
return { schemas };
|
|
11857
|
+
}
|
|
11858
|
+
// Single schema case
|
|
11859
|
+
const ctx = initializeContext({ ...params, processors: json_schema_processors_allProcessors });
|
|
11860
|
+
process(input, ctx);
|
|
11861
|
+
extractDefs(ctx, input);
|
|
11862
|
+
return finalize(ctx, input);
|
|
11863
|
+
}
|
|
11864
|
+
|
|
11865
|
+
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/json-schema-generator.js
|
|
11866
|
+
|
|
11867
|
+
|
|
11868
|
+
/**
|
|
11869
|
+
* Legacy class-based interface for JSON Schema generation.
|
|
11870
|
+
* This class wraps the new functional implementation to provide backward compatibility.
|
|
11871
|
+
*
|
|
11872
|
+
* @deprecated Use the `toJSONSchema` function instead for new code.
|
|
11873
|
+
*
|
|
11874
|
+
* @example
|
|
11875
|
+
* ```typescript
|
|
11876
|
+
* // Legacy usage (still supported)
|
|
11877
|
+
* const gen = new JSONSchemaGenerator({ target: "draft-07" });
|
|
11878
|
+
* gen.process(schema);
|
|
11879
|
+
* const result = gen.emit(schema);
|
|
11880
|
+
*
|
|
11881
|
+
* // Preferred modern usage
|
|
11882
|
+
* const result = toJSONSchema(schema, { target: "draft-07" });
|
|
11883
|
+
* ```
|
|
11884
|
+
*/
|
|
11885
|
+
class JSONSchemaGenerator {
|
|
11886
|
+
/** @deprecated Access via ctx instead */
|
|
11887
|
+
get metadataRegistry() {
|
|
11888
|
+
return this.ctx.metadataRegistry;
|
|
11889
|
+
}
|
|
11890
|
+
/** @deprecated Access via ctx instead */
|
|
11891
|
+
get target() {
|
|
11892
|
+
return this.ctx.target;
|
|
11893
|
+
}
|
|
11894
|
+
/** @deprecated Access via ctx instead */
|
|
11895
|
+
get unrepresentable() {
|
|
11896
|
+
return this.ctx.unrepresentable;
|
|
11897
|
+
}
|
|
11898
|
+
/** @deprecated Access via ctx instead */
|
|
11899
|
+
get override() {
|
|
11900
|
+
return this.ctx.override;
|
|
11901
|
+
}
|
|
11902
|
+
/** @deprecated Access via ctx instead */
|
|
11903
|
+
get io() {
|
|
11904
|
+
return this.ctx.io;
|
|
11905
|
+
}
|
|
11906
|
+
/** @deprecated Access via ctx instead */
|
|
11907
|
+
get counter() {
|
|
11908
|
+
return this.ctx.counter;
|
|
11909
|
+
}
|
|
11910
|
+
set counter(value) {
|
|
11911
|
+
this.ctx.counter = value;
|
|
11912
|
+
}
|
|
11913
|
+
/** @deprecated Access via ctx instead */
|
|
11914
|
+
get seen() {
|
|
11915
|
+
return this.ctx.seen;
|
|
11916
|
+
}
|
|
11917
|
+
constructor(params) {
|
|
11918
|
+
// Normalize target for internal context
|
|
11919
|
+
let normalizedTarget = params?.target ?? "draft-2020-12";
|
|
11920
|
+
if (normalizedTarget === "draft-4")
|
|
11921
|
+
normalizedTarget = "draft-04";
|
|
11922
|
+
if (normalizedTarget === "draft-7")
|
|
11923
|
+
normalizedTarget = "draft-07";
|
|
11924
|
+
this.ctx = initializeContext({
|
|
11925
|
+
processors: allProcessors,
|
|
11926
|
+
target: normalizedTarget,
|
|
11927
|
+
...(params?.metadata && { metadata: params.metadata }),
|
|
11928
|
+
...(params?.unrepresentable && { unrepresentable: params.unrepresentable }),
|
|
11929
|
+
...(params?.override && { override: params.override }),
|
|
11930
|
+
...(params?.io && { io: params.io }),
|
|
11931
|
+
});
|
|
11932
|
+
}
|
|
11933
|
+
/**
|
|
11934
|
+
* Process a schema to prepare it for JSON Schema generation.
|
|
11935
|
+
* This must be called before emit().
|
|
11936
|
+
*/
|
|
11937
|
+
process(schema, _params = { path: [], schemaPath: [] }) {
|
|
11938
|
+
return process(schema, this.ctx, _params);
|
|
11939
|
+
}
|
|
11940
|
+
/**
|
|
11941
|
+
* Emit the final JSON Schema after processing.
|
|
11942
|
+
* Must call process() first.
|
|
11943
|
+
*/
|
|
11944
|
+
emit(schema, _params) {
|
|
11945
|
+
// Apply emit params to the context
|
|
11946
|
+
if (_params) {
|
|
11947
|
+
if (_params.cycles)
|
|
11948
|
+
this.ctx.cycles = _params.cycles;
|
|
11949
|
+
if (_params.reused)
|
|
11950
|
+
this.ctx.reused = _params.reused;
|
|
11951
|
+
if (_params.external)
|
|
11952
|
+
this.ctx.external = _params.external;
|
|
11953
|
+
}
|
|
11954
|
+
extractDefs(this.ctx, schema);
|
|
11955
|
+
const result = finalize(this.ctx, schema);
|
|
11956
|
+
// Strip ~standard property to match old implementation's return type
|
|
11957
|
+
const { "~standard": _, ...plainResult } = result;
|
|
11958
|
+
return plainResult;
|
|
11959
|
+
}
|
|
11960
|
+
}
|
|
11439
11961
|
|
|
11440
11962
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/core/index.js
|
|
11441
11963
|
|
|
@@ -11453,6 +11975,8 @@ function isTransforming(_schema, _ctx) {
|
|
|
11453
11975
|
|
|
11454
11976
|
|
|
11455
11977
|
|
|
11978
|
+
|
|
11979
|
+
|
|
11456
11980
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/classic/checks.js
|
|
11457
11981
|
|
|
11458
11982
|
|
|
@@ -11541,8 +12065,8 @@ const ZodRealError = $constructor("ZodError", errors_initializer, {
|
|
|
11541
12065
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/classic/parse.js
|
|
11542
12066
|
|
|
11543
12067
|
|
|
11544
|
-
const
|
|
11545
|
-
const
|
|
12068
|
+
const parse_parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
12069
|
+
const parse_parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
11546
12070
|
const parse_safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
11547
12071
|
const parse_safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
11548
12072
|
// Codec functions
|
|
@@ -11561,8 +12085,17 @@ const parse_safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
|
11561
12085
|
|
|
11562
12086
|
|
|
11563
12087
|
|
|
12088
|
+
|
|
12089
|
+
|
|
11564
12090
|
const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
11565
12091
|
$ZodType.init(inst, def);
|
|
12092
|
+
Object.assign(inst["~standard"], {
|
|
12093
|
+
jsonSchema: {
|
|
12094
|
+
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
12095
|
+
output: createStandardJSONSchemaMethod(inst, "output"),
|
|
12096
|
+
},
|
|
12097
|
+
});
|
|
12098
|
+
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
11566
12099
|
inst.def = def;
|
|
11567
12100
|
inst.type = def.type;
|
|
11568
12101
|
Object.defineProperty(inst, "_def", { value: def });
|
|
@@ -11582,9 +12115,9 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
11582
12115
|
return inst;
|
|
11583
12116
|
});
|
|
11584
12117
|
// parsing
|
|
11585
|
-
inst.parse = (data, params) =>
|
|
12118
|
+
inst.parse = (data, params) => parse_parse(inst, data, params, { callee: inst.parse });
|
|
11586
12119
|
inst.safeParse = (data, params) => parse_safeParse(inst, data, params);
|
|
11587
|
-
inst.parseAsync = async (data, params) =>
|
|
12120
|
+
inst.parseAsync = async (data, params) => parse_parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
11588
12121
|
inst.safeParseAsync = async (data, params) => parse_safeParseAsync(inst, data, params);
|
|
11589
12122
|
inst.spa = inst.safeParseAsync;
|
|
11590
12123
|
// encoding/decoding
|
|
@@ -11618,21 +12151,21 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
11618
12151
|
// meta
|
|
11619
12152
|
inst.describe = (description) => {
|
|
11620
12153
|
const cl = inst.clone();
|
|
11621
|
-
|
|
12154
|
+
globalRegistry.add(cl, { description });
|
|
11622
12155
|
return cl;
|
|
11623
12156
|
};
|
|
11624
12157
|
Object.defineProperty(inst, "description", {
|
|
11625
12158
|
get() {
|
|
11626
|
-
return
|
|
12159
|
+
return globalRegistry.get(inst)?.description;
|
|
11627
12160
|
},
|
|
11628
12161
|
configurable: true,
|
|
11629
12162
|
});
|
|
11630
12163
|
inst.meta = (...args) => {
|
|
11631
12164
|
if (args.length === 0) {
|
|
11632
|
-
return
|
|
12165
|
+
return globalRegistry.get(inst);
|
|
11633
12166
|
}
|
|
11634
12167
|
const cl = inst.clone();
|
|
11635
|
-
|
|
12168
|
+
globalRegistry.add(cl, args[0]);
|
|
11636
12169
|
return cl;
|
|
11637
12170
|
};
|
|
11638
12171
|
// helpers
|
|
@@ -11644,6 +12177,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
11644
12177
|
const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
|
|
11645
12178
|
$ZodString.init(inst, def);
|
|
11646
12179
|
ZodType.init(inst, def);
|
|
12180
|
+
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
11647
12181
|
const bag = inst._zod.bag;
|
|
11648
12182
|
inst.format = bag.format ?? null;
|
|
11649
12183
|
inst.minLength = bag.minimum ?? null;
|
|
@@ -11711,7 +12245,7 @@ const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
|
|
|
11711
12245
|
ZodStringFormat.init(inst, def);
|
|
11712
12246
|
});
|
|
11713
12247
|
function schemas_email(params) {
|
|
11714
|
-
return
|
|
12248
|
+
return _email(ZodEmail, params);
|
|
11715
12249
|
}
|
|
11716
12250
|
const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
|
|
11717
12251
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11719,7 +12253,7 @@ const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
|
|
|
11719
12253
|
ZodStringFormat.init(inst, def);
|
|
11720
12254
|
});
|
|
11721
12255
|
function schemas_guid(params) {
|
|
11722
|
-
return
|
|
12256
|
+
return _guid(ZodGUID, params);
|
|
11723
12257
|
}
|
|
11724
12258
|
const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
|
|
11725
12259
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11727,18 +12261,18 @@ const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
|
|
|
11727
12261
|
ZodStringFormat.init(inst, def);
|
|
11728
12262
|
});
|
|
11729
12263
|
function schemas_uuid(params) {
|
|
11730
|
-
return
|
|
12264
|
+
return _uuid(ZodUUID, params);
|
|
11731
12265
|
}
|
|
11732
12266
|
function uuidv4(params) {
|
|
11733
|
-
return
|
|
12267
|
+
return _uuidv4(ZodUUID, params);
|
|
11734
12268
|
}
|
|
11735
12269
|
// ZodUUIDv6
|
|
11736
12270
|
function uuidv6(params) {
|
|
11737
|
-
return
|
|
12271
|
+
return _uuidv6(ZodUUID, params);
|
|
11738
12272
|
}
|
|
11739
12273
|
// ZodUUIDv7
|
|
11740
12274
|
function uuidv7(params) {
|
|
11741
|
-
return
|
|
12275
|
+
return _uuidv7(ZodUUID, params);
|
|
11742
12276
|
}
|
|
11743
12277
|
const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
|
|
11744
12278
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11746,13 +12280,13 @@ const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
|
|
|
11746
12280
|
ZodStringFormat.init(inst, def);
|
|
11747
12281
|
});
|
|
11748
12282
|
function url(params) {
|
|
11749
|
-
return
|
|
12283
|
+
return _url(ZodURL, params);
|
|
11750
12284
|
}
|
|
11751
12285
|
function httpUrl(params) {
|
|
11752
|
-
return
|
|
12286
|
+
return _url(ZodURL, {
|
|
11753
12287
|
protocol: /^https?$/,
|
|
11754
|
-
hostname:
|
|
11755
|
-
...
|
|
12288
|
+
hostname: domain,
|
|
12289
|
+
...normalizeParams(params),
|
|
11756
12290
|
});
|
|
11757
12291
|
}
|
|
11758
12292
|
const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
|
|
@@ -11761,7 +12295,7 @@ const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
|
|
|
11761
12295
|
ZodStringFormat.init(inst, def);
|
|
11762
12296
|
});
|
|
11763
12297
|
function schemas_emoji(params) {
|
|
11764
|
-
return
|
|
12298
|
+
return api_emoji(ZodEmoji, params);
|
|
11765
12299
|
}
|
|
11766
12300
|
const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
|
|
11767
12301
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11769,7 +12303,7 @@ const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
|
|
|
11769
12303
|
ZodStringFormat.init(inst, def);
|
|
11770
12304
|
});
|
|
11771
12305
|
function schemas_nanoid(params) {
|
|
11772
|
-
return
|
|
12306
|
+
return _nanoid(ZodNanoID, params);
|
|
11773
12307
|
}
|
|
11774
12308
|
const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
|
|
11775
12309
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11777,7 +12311,7 @@ const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
|
|
|
11777
12311
|
ZodStringFormat.init(inst, def);
|
|
11778
12312
|
});
|
|
11779
12313
|
function schemas_cuid(params) {
|
|
11780
|
-
return
|
|
12314
|
+
return _cuid(ZodCUID, params);
|
|
11781
12315
|
}
|
|
11782
12316
|
const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
|
|
11783
12317
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11785,7 +12319,7 @@ const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
|
|
|
11785
12319
|
ZodStringFormat.init(inst, def);
|
|
11786
12320
|
});
|
|
11787
12321
|
function schemas_cuid2(params) {
|
|
11788
|
-
return
|
|
12322
|
+
return _cuid2(ZodCUID2, params);
|
|
11789
12323
|
}
|
|
11790
12324
|
const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
|
|
11791
12325
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11793,7 +12327,7 @@ const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
|
|
|
11793
12327
|
ZodStringFormat.init(inst, def);
|
|
11794
12328
|
});
|
|
11795
12329
|
function schemas_ulid(params) {
|
|
11796
|
-
return
|
|
12330
|
+
return _ulid(ZodULID, params);
|
|
11797
12331
|
}
|
|
11798
12332
|
const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
|
|
11799
12333
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11801,7 +12335,7 @@ const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
|
|
|
11801
12335
|
ZodStringFormat.init(inst, def);
|
|
11802
12336
|
});
|
|
11803
12337
|
function schemas_xid(params) {
|
|
11804
|
-
return
|
|
12338
|
+
return _xid(ZodXID, params);
|
|
11805
12339
|
}
|
|
11806
12340
|
const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
|
|
11807
12341
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11809,7 +12343,7 @@ const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
|
|
|
11809
12343
|
ZodStringFormat.init(inst, def);
|
|
11810
12344
|
});
|
|
11811
12345
|
function schemas_ksuid(params) {
|
|
11812
|
-
return
|
|
12346
|
+
return _ksuid(ZodKSUID, params);
|
|
11813
12347
|
}
|
|
11814
12348
|
const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
|
|
11815
12349
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11817,15 +12351,15 @@ const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
|
|
|
11817
12351
|
ZodStringFormat.init(inst, def);
|
|
11818
12352
|
});
|
|
11819
12353
|
function schemas_ipv4(params) {
|
|
11820
|
-
return
|
|
12354
|
+
return _ipv4(ZodIPv4, params);
|
|
11821
12355
|
}
|
|
11822
|
-
const ZodMAC = /*@__PURE__*/
|
|
12356
|
+
const ZodMAC = /*@__PURE__*/ $constructor("ZodMAC", (inst, def) => {
|
|
11823
12357
|
// ZodStringFormat.init(inst, def);
|
|
11824
|
-
|
|
12358
|
+
$ZodMAC.init(inst, def);
|
|
11825
12359
|
ZodStringFormat.init(inst, def);
|
|
11826
|
-
})
|
|
12360
|
+
});
|
|
11827
12361
|
function schemas_mac(params) {
|
|
11828
|
-
return
|
|
12362
|
+
return _mac(ZodMAC, params);
|
|
11829
12363
|
}
|
|
11830
12364
|
const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
|
|
11831
12365
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11833,21 +12367,21 @@ const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
|
|
|
11833
12367
|
ZodStringFormat.init(inst, def);
|
|
11834
12368
|
});
|
|
11835
12369
|
function schemas_ipv6(params) {
|
|
11836
|
-
return
|
|
12370
|
+
return _ipv6(ZodIPv6, params);
|
|
11837
12371
|
}
|
|
11838
12372
|
const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def) => {
|
|
11839
12373
|
$ZodCIDRv4.init(inst, def);
|
|
11840
12374
|
ZodStringFormat.init(inst, def);
|
|
11841
12375
|
});
|
|
11842
12376
|
function schemas_cidrv4(params) {
|
|
11843
|
-
return
|
|
12377
|
+
return _cidrv4(ZodCIDRv4, params);
|
|
11844
12378
|
}
|
|
11845
12379
|
const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def) => {
|
|
11846
12380
|
$ZodCIDRv6.init(inst, def);
|
|
11847
12381
|
ZodStringFormat.init(inst, def);
|
|
11848
12382
|
});
|
|
11849
12383
|
function schemas_cidrv6(params) {
|
|
11850
|
-
return
|
|
12384
|
+
return _cidrv6(ZodCIDRv6, params);
|
|
11851
12385
|
}
|
|
11852
12386
|
const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
|
|
11853
12387
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11855,7 +12389,7 @@ const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
|
|
|
11855
12389
|
ZodStringFormat.init(inst, def);
|
|
11856
12390
|
});
|
|
11857
12391
|
function schemas_base64(params) {
|
|
11858
|
-
return
|
|
12392
|
+
return _base64(ZodBase64, params);
|
|
11859
12393
|
}
|
|
11860
12394
|
const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
|
|
11861
12395
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11863,7 +12397,7 @@ const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
|
|
|
11863
12397
|
ZodStringFormat.init(inst, def);
|
|
11864
12398
|
});
|
|
11865
12399
|
function schemas_base64url(params) {
|
|
11866
|
-
return
|
|
12400
|
+
return _base64url(ZodBase64URL, params);
|
|
11867
12401
|
}
|
|
11868
12402
|
const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
|
|
11869
12403
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11871,7 +12405,7 @@ const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
|
|
|
11871
12405
|
ZodStringFormat.init(inst, def);
|
|
11872
12406
|
});
|
|
11873
12407
|
function schemas_e164(params) {
|
|
11874
|
-
return
|
|
12408
|
+
return _e164(ZodE164, params);
|
|
11875
12409
|
}
|
|
11876
12410
|
const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
|
|
11877
12411
|
// ZodStringFormat.init(inst, def);
|
|
@@ -11879,47 +12413,48 @@ const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
|
|
|
11879
12413
|
ZodStringFormat.init(inst, def);
|
|
11880
12414
|
});
|
|
11881
12415
|
function jwt(params) {
|
|
11882
|
-
return
|
|
12416
|
+
return _jwt(ZodJWT, params);
|
|
11883
12417
|
}
|
|
11884
|
-
const ZodCustomStringFormat = /*@__PURE__*/
|
|
12418
|
+
const ZodCustomStringFormat = /*@__PURE__*/ $constructor("ZodCustomStringFormat", (inst, def) => {
|
|
11885
12419
|
// ZodStringFormat.init(inst, def);
|
|
11886
|
-
|
|
12420
|
+
$ZodCustomStringFormat.init(inst, def);
|
|
11887
12421
|
ZodStringFormat.init(inst, def);
|
|
11888
|
-
})
|
|
12422
|
+
});
|
|
11889
12423
|
function stringFormat(format, fnOrRegex, _params = {}) {
|
|
11890
|
-
return
|
|
12424
|
+
return _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
|
|
11891
12425
|
}
|
|
11892
12426
|
function schemas_hostname(_params) {
|
|
11893
|
-
return
|
|
12427
|
+
return _stringFormat(ZodCustomStringFormat, "hostname", hostname, _params);
|
|
11894
12428
|
}
|
|
11895
12429
|
function schemas_hex(_params) {
|
|
11896
|
-
return
|
|
12430
|
+
return _stringFormat(ZodCustomStringFormat, "hex", hex, _params);
|
|
11897
12431
|
}
|
|
11898
12432
|
function hash(alg, params) {
|
|
11899
12433
|
const enc = params?.enc ?? "hex";
|
|
11900
12434
|
const format = `${alg}_${enc}`;
|
|
11901
|
-
const regex =
|
|
12435
|
+
const regex = regexes_namespaceObject[format];
|
|
11902
12436
|
if (!regex)
|
|
11903
12437
|
throw new Error(`Unrecognized hash format: ${format}`);
|
|
11904
|
-
return
|
|
12438
|
+
return _stringFormat(ZodCustomStringFormat, format, regex, params);
|
|
11905
12439
|
}
|
|
11906
|
-
const ZodNumber = /*@__PURE__*/
|
|
11907
|
-
|
|
12440
|
+
const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
|
|
12441
|
+
$ZodNumber.init(inst, def);
|
|
11908
12442
|
ZodType.init(inst, def);
|
|
11909
|
-
inst.
|
|
11910
|
-
inst.
|
|
11911
|
-
inst.
|
|
11912
|
-
inst.
|
|
11913
|
-
inst.
|
|
11914
|
-
inst.
|
|
12443
|
+
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
12444
|
+
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
12445
|
+
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
12446
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
12447
|
+
inst.lt = (value, params) => inst.check(_lt(value, params));
|
|
12448
|
+
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
12449
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
11915
12450
|
inst.int = (params) => inst.check(schemas_int(params));
|
|
11916
12451
|
inst.safe = (params) => inst.check(schemas_int(params));
|
|
11917
|
-
inst.positive = (params) => inst.check(
|
|
11918
|
-
inst.nonnegative = (params) => inst.check(
|
|
11919
|
-
inst.negative = (params) => inst.check(
|
|
11920
|
-
inst.nonpositive = (params) => inst.check(
|
|
11921
|
-
inst.multipleOf = (value, params) => inst.check(
|
|
11922
|
-
inst.step = (value, params) => inst.check(
|
|
12452
|
+
inst.positive = (params) => inst.check(_gt(0, params));
|
|
12453
|
+
inst.nonnegative = (params) => inst.check(_gte(0, params));
|
|
12454
|
+
inst.negative = (params) => inst.check(_lt(0, params));
|
|
12455
|
+
inst.nonpositive = (params) => inst.check(_lte(0, params));
|
|
12456
|
+
inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
|
|
12457
|
+
inst.step = (value, params) => inst.check(_multipleOf(value, params));
|
|
11923
12458
|
// inst.finite = (params) => inst.check(core.finite(params));
|
|
11924
12459
|
inst.finite = () => inst;
|
|
11925
12460
|
const bag = inst._zod.bag;
|
|
@@ -11930,105 +12465,112 @@ const ZodNumber = /*@__PURE__*/ (/* unused pure expression or super */ null && (
|
|
|
11930
12465
|
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
11931
12466
|
inst.isFinite = true;
|
|
11932
12467
|
inst.format = bag.format ?? null;
|
|
11933
|
-
})
|
|
12468
|
+
});
|
|
11934
12469
|
function schemas_number(params) {
|
|
11935
|
-
return
|
|
12470
|
+
return _number(ZodNumber, params);
|
|
11936
12471
|
}
|
|
11937
|
-
const ZodNumberFormat = /*@__PURE__*/
|
|
11938
|
-
|
|
12472
|
+
const ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def) => {
|
|
12473
|
+
$ZodNumberFormat.init(inst, def);
|
|
11939
12474
|
ZodNumber.init(inst, def);
|
|
11940
|
-
})
|
|
12475
|
+
});
|
|
11941
12476
|
function schemas_int(params) {
|
|
11942
|
-
return
|
|
12477
|
+
return _int(ZodNumberFormat, params);
|
|
11943
12478
|
}
|
|
11944
12479
|
function float32(params) {
|
|
11945
|
-
return
|
|
12480
|
+
return _float32(ZodNumberFormat, params);
|
|
11946
12481
|
}
|
|
11947
12482
|
function float64(params) {
|
|
11948
|
-
return
|
|
12483
|
+
return _float64(ZodNumberFormat, params);
|
|
11949
12484
|
}
|
|
11950
12485
|
function int32(params) {
|
|
11951
|
-
return
|
|
12486
|
+
return _int32(ZodNumberFormat, params);
|
|
11952
12487
|
}
|
|
11953
12488
|
function uint32(params) {
|
|
11954
|
-
return
|
|
12489
|
+
return _uint32(ZodNumberFormat, params);
|
|
11955
12490
|
}
|
|
11956
|
-
const ZodBoolean = /*@__PURE__*/
|
|
11957
|
-
|
|
12491
|
+
const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
|
|
12492
|
+
$ZodBoolean.init(inst, def);
|
|
11958
12493
|
ZodType.init(inst, def);
|
|
11959
|
-
|
|
12494
|
+
inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
|
|
12495
|
+
});
|
|
11960
12496
|
function schemas_boolean(params) {
|
|
11961
|
-
return
|
|
12497
|
+
return _boolean(ZodBoolean, params);
|
|
11962
12498
|
}
|
|
11963
|
-
const ZodBigInt = /*@__PURE__*/
|
|
11964
|
-
|
|
12499
|
+
const ZodBigInt = /*@__PURE__*/ $constructor("ZodBigInt", (inst, def) => {
|
|
12500
|
+
$ZodBigInt.init(inst, def);
|
|
11965
12501
|
ZodType.init(inst, def);
|
|
11966
|
-
inst.
|
|
11967
|
-
inst.
|
|
11968
|
-
inst.
|
|
11969
|
-
inst.
|
|
11970
|
-
inst.
|
|
11971
|
-
inst.
|
|
11972
|
-
inst.
|
|
11973
|
-
inst.
|
|
11974
|
-
inst.
|
|
11975
|
-
inst.
|
|
11976
|
-
inst.
|
|
11977
|
-
inst.
|
|
11978
|
-
inst.
|
|
12502
|
+
inst._zod.processJSONSchema = (ctx, json, params) => bigintProcessor(inst, ctx, json, params);
|
|
12503
|
+
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
12504
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
12505
|
+
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
12506
|
+
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
12507
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
12508
|
+
inst.lt = (value, params) => inst.check(_lt(value, params));
|
|
12509
|
+
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
12510
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
12511
|
+
inst.positive = (params) => inst.check(_gt(BigInt(0), params));
|
|
12512
|
+
inst.negative = (params) => inst.check(_lt(BigInt(0), params));
|
|
12513
|
+
inst.nonpositive = (params) => inst.check(_lte(BigInt(0), params));
|
|
12514
|
+
inst.nonnegative = (params) => inst.check(_gte(BigInt(0), params));
|
|
12515
|
+
inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
|
|
11979
12516
|
const bag = inst._zod.bag;
|
|
11980
12517
|
inst.minValue = bag.minimum ?? null;
|
|
11981
12518
|
inst.maxValue = bag.maximum ?? null;
|
|
11982
12519
|
inst.format = bag.format ?? null;
|
|
11983
|
-
})
|
|
12520
|
+
});
|
|
11984
12521
|
function schemas_bigint(params) {
|
|
11985
|
-
return
|
|
12522
|
+
return _bigint(ZodBigInt, params);
|
|
11986
12523
|
}
|
|
11987
|
-
const ZodBigIntFormat = /*@__PURE__*/
|
|
11988
|
-
|
|
12524
|
+
const ZodBigIntFormat = /*@__PURE__*/ $constructor("ZodBigIntFormat", (inst, def) => {
|
|
12525
|
+
$ZodBigIntFormat.init(inst, def);
|
|
11989
12526
|
ZodBigInt.init(inst, def);
|
|
11990
|
-
})
|
|
12527
|
+
});
|
|
11991
12528
|
// int64
|
|
11992
12529
|
function int64(params) {
|
|
11993
|
-
return
|
|
12530
|
+
return _int64(ZodBigIntFormat, params);
|
|
11994
12531
|
}
|
|
11995
12532
|
// uint64
|
|
11996
12533
|
function uint64(params) {
|
|
11997
|
-
return
|
|
12534
|
+
return _uint64(ZodBigIntFormat, params);
|
|
11998
12535
|
}
|
|
11999
|
-
const ZodSymbol = /*@__PURE__*/
|
|
12000
|
-
|
|
12536
|
+
const ZodSymbol = /*@__PURE__*/ $constructor("ZodSymbol", (inst, def) => {
|
|
12537
|
+
$ZodSymbol.init(inst, def);
|
|
12001
12538
|
ZodType.init(inst, def);
|
|
12002
|
-
|
|
12539
|
+
inst._zod.processJSONSchema = (ctx, json, params) => symbolProcessor(inst, ctx, json, params);
|
|
12540
|
+
});
|
|
12003
12541
|
function symbol(params) {
|
|
12004
|
-
return
|
|
12542
|
+
return _symbol(ZodSymbol, params);
|
|
12005
12543
|
}
|
|
12006
|
-
const ZodUndefined = /*@__PURE__*/
|
|
12007
|
-
|
|
12544
|
+
const ZodUndefined = /*@__PURE__*/ $constructor("ZodUndefined", (inst, def) => {
|
|
12545
|
+
$ZodUndefined.init(inst, def);
|
|
12008
12546
|
ZodType.init(inst, def);
|
|
12009
|
-
|
|
12547
|
+
inst._zod.processJSONSchema = (ctx, json, params) => undefinedProcessor(inst, ctx, json, params);
|
|
12548
|
+
});
|
|
12010
12549
|
function schemas_undefined(params) {
|
|
12011
|
-
return
|
|
12550
|
+
return api_undefined(ZodUndefined, params);
|
|
12012
12551
|
}
|
|
12013
12552
|
|
|
12014
|
-
const ZodNull = /*@__PURE__*/
|
|
12015
|
-
|
|
12553
|
+
const ZodNull = /*@__PURE__*/ $constructor("ZodNull", (inst, def) => {
|
|
12554
|
+
$ZodNull.init(inst, def);
|
|
12016
12555
|
ZodType.init(inst, def);
|
|
12017
|
-
|
|
12556
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nullProcessor(inst, ctx, json, params);
|
|
12557
|
+
});
|
|
12018
12558
|
function schemas_null(params) {
|
|
12019
|
-
return
|
|
12559
|
+
return api_null(ZodNull, params);
|
|
12020
12560
|
}
|
|
12021
12561
|
|
|
12022
|
-
const ZodAny = /*@__PURE__*/
|
|
12023
|
-
|
|
12562
|
+
const ZodAny = /*@__PURE__*/ $constructor("ZodAny", (inst, def) => {
|
|
12563
|
+
$ZodAny.init(inst, def);
|
|
12024
12564
|
ZodType.init(inst, def);
|
|
12025
|
-
|
|
12565
|
+
inst._zod.processJSONSchema = (ctx, json, params) => anyProcessor(inst, ctx, json, params);
|
|
12566
|
+
});
|
|
12026
12567
|
function any() {
|
|
12027
|
-
return
|
|
12568
|
+
return _any(ZodAny);
|
|
12028
12569
|
}
|
|
12029
12570
|
const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
|
|
12030
12571
|
$ZodUnknown.init(inst, def);
|
|
12031
12572
|
ZodType.init(inst, def);
|
|
12573
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
|
|
12032
12574
|
});
|
|
12033
12575
|
function unknown() {
|
|
12034
12576
|
return _unknown(ZodUnknown);
|
|
@@ -12036,33 +12578,37 @@ function unknown() {
|
|
|
12036
12578
|
const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
|
|
12037
12579
|
$ZodNever.init(inst, def);
|
|
12038
12580
|
ZodType.init(inst, def);
|
|
12581
|
+
inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
|
|
12039
12582
|
});
|
|
12040
12583
|
function never(params) {
|
|
12041
12584
|
return _never(ZodNever, params);
|
|
12042
12585
|
}
|
|
12043
|
-
const ZodVoid = /*@__PURE__*/
|
|
12044
|
-
|
|
12586
|
+
const ZodVoid = /*@__PURE__*/ $constructor("ZodVoid", (inst, def) => {
|
|
12587
|
+
$ZodVoid.init(inst, def);
|
|
12045
12588
|
ZodType.init(inst, def);
|
|
12046
|
-
|
|
12589
|
+
inst._zod.processJSONSchema = (ctx, json, params) => voidProcessor(inst, ctx, json, params);
|
|
12590
|
+
});
|
|
12047
12591
|
function schemas_void(params) {
|
|
12048
|
-
return
|
|
12592
|
+
return _void(ZodVoid, params);
|
|
12049
12593
|
}
|
|
12050
12594
|
|
|
12051
|
-
const ZodDate = /*@__PURE__*/
|
|
12052
|
-
|
|
12595
|
+
const ZodDate = /*@__PURE__*/ $constructor("ZodDate", (inst, def) => {
|
|
12596
|
+
$ZodDate.init(inst, def);
|
|
12053
12597
|
ZodType.init(inst, def);
|
|
12054
|
-
inst.
|
|
12055
|
-
inst.
|
|
12598
|
+
inst._zod.processJSONSchema = (ctx, json, params) => dateProcessor(inst, ctx, json, params);
|
|
12599
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
12600
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
12056
12601
|
const c = inst._zod.bag;
|
|
12057
12602
|
inst.minDate = c.minimum ? new Date(c.minimum) : null;
|
|
12058
12603
|
inst.maxDate = c.maximum ? new Date(c.maximum) : null;
|
|
12059
|
-
})
|
|
12604
|
+
});
|
|
12060
12605
|
function schemas_date(params) {
|
|
12061
|
-
return
|
|
12606
|
+
return _date(ZodDate, params);
|
|
12062
12607
|
}
|
|
12063
12608
|
const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
|
|
12064
12609
|
$ZodArray.init(inst, def);
|
|
12065
12610
|
ZodType.init(inst, def);
|
|
12611
|
+
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
12066
12612
|
inst.element = def.element;
|
|
12067
12613
|
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
12068
12614
|
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
@@ -12081,6 +12627,7 @@ function keyof(schema) {
|
|
|
12081
12627
|
const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
12082
12628
|
$ZodObjectJIT.init(inst, def);
|
|
12083
12629
|
ZodType.init(inst, def);
|
|
12630
|
+
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
12084
12631
|
defineLazy(inst, "shape", () => {
|
|
12085
12632
|
return def.shape;
|
|
12086
12633
|
});
|
|
@@ -12116,7 +12663,7 @@ function strictObject(shape, params) {
|
|
|
12116
12663
|
type: "object",
|
|
12117
12664
|
shape,
|
|
12118
12665
|
catchall: never(),
|
|
12119
|
-
...
|
|
12666
|
+
...normalizeParams(params),
|
|
12120
12667
|
});
|
|
12121
12668
|
}
|
|
12122
12669
|
// looseObject
|
|
@@ -12125,12 +12672,13 @@ function looseObject(shape, params) {
|
|
|
12125
12672
|
type: "object",
|
|
12126
12673
|
shape,
|
|
12127
12674
|
catchall: unknown(),
|
|
12128
|
-
...
|
|
12675
|
+
...normalizeParams(params),
|
|
12129
12676
|
});
|
|
12130
12677
|
}
|
|
12131
12678
|
const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
|
|
12132
12679
|
$ZodUnion.init(inst, def);
|
|
12133
12680
|
ZodType.init(inst, def);
|
|
12681
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
|
|
12134
12682
|
inst.options = def.options;
|
|
12135
12683
|
});
|
|
12136
12684
|
function union(options, params) {
|
|
@@ -12140,22 +12688,40 @@ function union(options, params) {
|
|
|
12140
12688
|
...normalizeParams(params),
|
|
12141
12689
|
});
|
|
12142
12690
|
}
|
|
12143
|
-
const
|
|
12691
|
+
const ZodXor = /*@__PURE__*/ $constructor("ZodXor", (inst, def) => {
|
|
12144
12692
|
ZodUnion.init(inst, def);
|
|
12145
|
-
|
|
12146
|
-
|
|
12693
|
+
$ZodXor.init(inst, def);
|
|
12694
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
|
|
12695
|
+
inst.options = def.options;
|
|
12696
|
+
});
|
|
12697
|
+
/** Creates an exclusive union (XOR) where exactly one option must match.
|
|
12698
|
+
* Unlike regular unions that succeed when any option matches, xor fails if
|
|
12699
|
+
* zero or more than one option matches the input. */
|
|
12700
|
+
function xor(options, params) {
|
|
12701
|
+
return new ZodXor({
|
|
12702
|
+
type: "union",
|
|
12703
|
+
options: options,
|
|
12704
|
+
inclusive: false,
|
|
12705
|
+
...normalizeParams(params),
|
|
12706
|
+
});
|
|
12707
|
+
}
|
|
12708
|
+
const ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
12709
|
+
ZodUnion.init(inst, def);
|
|
12710
|
+
$ZodDiscriminatedUnion.init(inst, def);
|
|
12711
|
+
});
|
|
12147
12712
|
function discriminatedUnion(discriminator, options, params) {
|
|
12148
12713
|
// const [options, params] = args;
|
|
12149
12714
|
return new ZodDiscriminatedUnion({
|
|
12150
12715
|
type: "union",
|
|
12151
12716
|
options,
|
|
12152
12717
|
discriminator,
|
|
12153
|
-
...
|
|
12718
|
+
...normalizeParams(params),
|
|
12154
12719
|
});
|
|
12155
12720
|
}
|
|
12156
12721
|
const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
|
|
12157
12722
|
$ZodIntersection.init(inst, def);
|
|
12158
12723
|
ZodType.init(inst, def);
|
|
12724
|
+
inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
|
|
12159
12725
|
});
|
|
12160
12726
|
function intersection(left, right) {
|
|
12161
12727
|
return new ZodIntersection({
|
|
@@ -12164,28 +12730,30 @@ function intersection(left, right) {
|
|
|
12164
12730
|
right: right,
|
|
12165
12731
|
});
|
|
12166
12732
|
}
|
|
12167
|
-
const ZodTuple = /*@__PURE__*/
|
|
12168
|
-
|
|
12733
|
+
const ZodTuple = /*@__PURE__*/ $constructor("ZodTuple", (inst, def) => {
|
|
12734
|
+
$ZodTuple.init(inst, def);
|
|
12169
12735
|
ZodType.init(inst, def);
|
|
12736
|
+
inst._zod.processJSONSchema = (ctx, json, params) => tupleProcessor(inst, ctx, json, params);
|
|
12170
12737
|
inst.rest = (rest) => inst.clone({
|
|
12171
12738
|
...inst._zod.def,
|
|
12172
12739
|
rest: rest,
|
|
12173
12740
|
});
|
|
12174
|
-
})
|
|
12741
|
+
});
|
|
12175
12742
|
function tuple(items, _paramsOrRest, _params) {
|
|
12176
|
-
const hasRest = _paramsOrRest instanceof
|
|
12743
|
+
const hasRest = _paramsOrRest instanceof $ZodType;
|
|
12177
12744
|
const params = hasRest ? _params : _paramsOrRest;
|
|
12178
12745
|
const rest = hasRest ? _paramsOrRest : null;
|
|
12179
12746
|
return new ZodTuple({
|
|
12180
12747
|
type: "tuple",
|
|
12181
12748
|
items: items,
|
|
12182
12749
|
rest,
|
|
12183
|
-
...
|
|
12750
|
+
...normalizeParams(params),
|
|
12184
12751
|
});
|
|
12185
12752
|
}
|
|
12186
12753
|
const ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
|
|
12187
12754
|
$ZodRecord.init(inst, def);
|
|
12188
12755
|
ZodType.init(inst, def);
|
|
12756
|
+
inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
|
|
12189
12757
|
inst.keyType = def.keyType;
|
|
12190
12758
|
inst.valueType = def.valueType;
|
|
12191
12759
|
});
|
|
@@ -12199,47 +12767,59 @@ function record(keyType, valueType, params) {
|
|
|
12199
12767
|
}
|
|
12200
12768
|
// type alksjf = core.output<core.$ZodRecordKey>;
|
|
12201
12769
|
function partialRecord(keyType, valueType, params) {
|
|
12202
|
-
const k =
|
|
12770
|
+
const k = clone(keyType);
|
|
12203
12771
|
k._zod.values = undefined;
|
|
12204
12772
|
return new ZodRecord({
|
|
12205
12773
|
type: "record",
|
|
12206
12774
|
keyType: k,
|
|
12207
12775
|
valueType: valueType,
|
|
12208
|
-
...
|
|
12776
|
+
...normalizeParams(params),
|
|
12209
12777
|
});
|
|
12210
12778
|
}
|
|
12211
|
-
|
|
12212
|
-
|
|
12779
|
+
function looseRecord(keyType, valueType, params) {
|
|
12780
|
+
return new ZodRecord({
|
|
12781
|
+
type: "record",
|
|
12782
|
+
keyType,
|
|
12783
|
+
valueType: valueType,
|
|
12784
|
+
mode: "loose",
|
|
12785
|
+
...normalizeParams(params),
|
|
12786
|
+
});
|
|
12787
|
+
}
|
|
12788
|
+
const ZodMap = /*@__PURE__*/ $constructor("ZodMap", (inst, def) => {
|
|
12789
|
+
$ZodMap.init(inst, def);
|
|
12213
12790
|
ZodType.init(inst, def);
|
|
12791
|
+
inst._zod.processJSONSchema = (ctx, json, params) => mapProcessor(inst, ctx, json, params);
|
|
12214
12792
|
inst.keyType = def.keyType;
|
|
12215
12793
|
inst.valueType = def.valueType;
|
|
12216
|
-
})
|
|
12794
|
+
});
|
|
12217
12795
|
function map(keyType, valueType, params) {
|
|
12218
12796
|
return new ZodMap({
|
|
12219
12797
|
type: "map",
|
|
12220
12798
|
keyType: keyType,
|
|
12221
12799
|
valueType: valueType,
|
|
12222
|
-
...
|
|
12800
|
+
...normalizeParams(params),
|
|
12223
12801
|
});
|
|
12224
12802
|
}
|
|
12225
|
-
const ZodSet = /*@__PURE__*/
|
|
12226
|
-
|
|
12803
|
+
const ZodSet = /*@__PURE__*/ $constructor("ZodSet", (inst, def) => {
|
|
12804
|
+
$ZodSet.init(inst, def);
|
|
12227
12805
|
ZodType.init(inst, def);
|
|
12228
|
-
inst.
|
|
12229
|
-
inst.
|
|
12230
|
-
inst.
|
|
12231
|
-
inst.
|
|
12232
|
-
|
|
12806
|
+
inst._zod.processJSONSchema = (ctx, json, params) => setProcessor(inst, ctx, json, params);
|
|
12807
|
+
inst.min = (...args) => inst.check(_minSize(...args));
|
|
12808
|
+
inst.nonempty = (params) => inst.check(_minSize(1, params));
|
|
12809
|
+
inst.max = (...args) => inst.check(_maxSize(...args));
|
|
12810
|
+
inst.size = (...args) => inst.check(_size(...args));
|
|
12811
|
+
});
|
|
12233
12812
|
function set(valueType, params) {
|
|
12234
12813
|
return new ZodSet({
|
|
12235
12814
|
type: "set",
|
|
12236
12815
|
valueType: valueType,
|
|
12237
|
-
...
|
|
12816
|
+
...normalizeParams(params),
|
|
12238
12817
|
});
|
|
12239
12818
|
}
|
|
12240
12819
|
const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
|
|
12241
12820
|
$ZodEnum.init(inst, def);
|
|
12242
12821
|
ZodType.init(inst, def);
|
|
12822
|
+
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
12243
12823
|
inst.enum = def.entries;
|
|
12244
12824
|
inst.options = Object.values(def.entries);
|
|
12245
12825
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -12296,12 +12876,13 @@ function nativeEnum(entries, params) {
|
|
|
12296
12876
|
return new ZodEnum({
|
|
12297
12877
|
type: "enum",
|
|
12298
12878
|
entries,
|
|
12299
|
-
...
|
|
12879
|
+
...normalizeParams(params),
|
|
12300
12880
|
});
|
|
12301
12881
|
}
|
|
12302
|
-
const ZodLiteral = /*@__PURE__*/
|
|
12303
|
-
|
|
12882
|
+
const ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (inst, def) => {
|
|
12883
|
+
$ZodLiteral.init(inst, def);
|
|
12304
12884
|
ZodType.init(inst, def);
|
|
12885
|
+
inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
|
|
12305
12886
|
inst.values = new Set(def.values);
|
|
12306
12887
|
Object.defineProperty(inst, "value", {
|
|
12307
12888
|
get() {
|
|
@@ -12311,27 +12892,29 @@ const ZodLiteral = /*@__PURE__*/ (/* unused pure expression or super */ null &&
|
|
|
12311
12892
|
return def.values[0];
|
|
12312
12893
|
},
|
|
12313
12894
|
});
|
|
12314
|
-
})
|
|
12895
|
+
});
|
|
12315
12896
|
function literal(value, params) {
|
|
12316
12897
|
return new ZodLiteral({
|
|
12317
12898
|
type: "literal",
|
|
12318
12899
|
values: Array.isArray(value) ? value : [value],
|
|
12319
|
-
...
|
|
12900
|
+
...normalizeParams(params),
|
|
12320
12901
|
});
|
|
12321
12902
|
}
|
|
12322
|
-
const ZodFile = /*@__PURE__*/
|
|
12323
|
-
|
|
12903
|
+
const ZodFile = /*@__PURE__*/ $constructor("ZodFile", (inst, def) => {
|
|
12904
|
+
$ZodFile.init(inst, def);
|
|
12324
12905
|
ZodType.init(inst, def);
|
|
12325
|
-
inst.
|
|
12326
|
-
inst.
|
|
12327
|
-
inst.
|
|
12328
|
-
|
|
12906
|
+
inst._zod.processJSONSchema = (ctx, json, params) => fileProcessor(inst, ctx, json, params);
|
|
12907
|
+
inst.min = (size, params) => inst.check(_minSize(size, params));
|
|
12908
|
+
inst.max = (size, params) => inst.check(_maxSize(size, params));
|
|
12909
|
+
inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
|
|
12910
|
+
});
|
|
12329
12911
|
function file(params) {
|
|
12330
|
-
return
|
|
12912
|
+
return _file(ZodFile, params);
|
|
12331
12913
|
}
|
|
12332
12914
|
const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
12333
12915
|
$ZodTransform.init(inst, def);
|
|
12334
12916
|
ZodType.init(inst, def);
|
|
12917
|
+
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
12335
12918
|
inst._zod.parse = (payload, _ctx) => {
|
|
12336
12919
|
if (_ctx.direction === "backward") {
|
|
12337
12920
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -12372,6 +12955,7 @@ function transform(fn) {
|
|
|
12372
12955
|
const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
|
|
12373
12956
|
$ZodOptional.init(inst, def);
|
|
12374
12957
|
ZodType.init(inst, def);
|
|
12958
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
12375
12959
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
12376
12960
|
});
|
|
12377
12961
|
function optional(innerType) {
|
|
@@ -12383,6 +12967,7 @@ function optional(innerType) {
|
|
|
12383
12967
|
const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
|
|
12384
12968
|
$ZodNullable.init(inst, def);
|
|
12385
12969
|
ZodType.init(inst, def);
|
|
12970
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
|
|
12386
12971
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
12387
12972
|
});
|
|
12388
12973
|
function nullable(innerType) {
|
|
@@ -12398,6 +12983,7 @@ function schemas_nullish(innerType) {
|
|
|
12398
12983
|
const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
|
|
12399
12984
|
$ZodDefault.init(inst, def);
|
|
12400
12985
|
ZodType.init(inst, def);
|
|
12986
|
+
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
|
|
12401
12987
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
12402
12988
|
inst.removeDefault = inst.unwrap;
|
|
12403
12989
|
});
|
|
@@ -12413,6 +12999,7 @@ function schemas_default(innerType, defaultValue) {
|
|
|
12413
12999
|
const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
|
|
12414
13000
|
$ZodPrefault.init(inst, def);
|
|
12415
13001
|
ZodType.init(inst, def);
|
|
13002
|
+
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
|
|
12416
13003
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
12417
13004
|
});
|
|
12418
13005
|
function prefault(innerType, defaultValue) {
|
|
@@ -12427,6 +13014,7 @@ function prefault(innerType, defaultValue) {
|
|
|
12427
13014
|
const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
|
|
12428
13015
|
$ZodNonOptional.init(inst, def);
|
|
12429
13016
|
ZodType.init(inst, def);
|
|
13017
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
|
|
12430
13018
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
12431
13019
|
});
|
|
12432
13020
|
function nonoptional(innerType, params) {
|
|
@@ -12436,11 +13024,12 @@ function nonoptional(innerType, params) {
|
|
|
12436
13024
|
...normalizeParams(params),
|
|
12437
13025
|
});
|
|
12438
13026
|
}
|
|
12439
|
-
const ZodSuccess = /*@__PURE__*/
|
|
12440
|
-
|
|
13027
|
+
const ZodSuccess = /*@__PURE__*/ $constructor("ZodSuccess", (inst, def) => {
|
|
13028
|
+
$ZodSuccess.init(inst, def);
|
|
12441
13029
|
ZodType.init(inst, def);
|
|
13030
|
+
inst._zod.processJSONSchema = (ctx, json, params) => successProcessor(inst, ctx, json, params);
|
|
12442
13031
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
12443
|
-
})
|
|
13032
|
+
});
|
|
12444
13033
|
function success(innerType) {
|
|
12445
13034
|
return new ZodSuccess({
|
|
12446
13035
|
type: "success",
|
|
@@ -12450,6 +13039,7 @@ function success(innerType) {
|
|
|
12450
13039
|
const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
|
|
12451
13040
|
$ZodCatch.init(inst, def);
|
|
12452
13041
|
ZodType.init(inst, def);
|
|
13042
|
+
inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
|
|
12453
13043
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
12454
13044
|
inst.removeCatch = inst.unwrap;
|
|
12455
13045
|
});
|
|
@@ -12461,16 +13051,18 @@ function schemas_catch(innerType, catchValue) {
|
|
|
12461
13051
|
});
|
|
12462
13052
|
}
|
|
12463
13053
|
|
|
12464
|
-
const ZodNaN = /*@__PURE__*/
|
|
12465
|
-
|
|
13054
|
+
const ZodNaN = /*@__PURE__*/ $constructor("ZodNaN", (inst, def) => {
|
|
13055
|
+
$ZodNaN.init(inst, def);
|
|
12466
13056
|
ZodType.init(inst, def);
|
|
12467
|
-
|
|
13057
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nanProcessor(inst, ctx, json, params);
|
|
13058
|
+
});
|
|
12468
13059
|
function nan(params) {
|
|
12469
|
-
return
|
|
13060
|
+
return _nan(ZodNaN, params);
|
|
12470
13061
|
}
|
|
12471
13062
|
const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
|
|
12472
13063
|
$ZodPipe.init(inst, def);
|
|
12473
13064
|
ZodType.init(inst, def);
|
|
13065
|
+
inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
|
|
12474
13066
|
inst.in = def.in;
|
|
12475
13067
|
inst.out = def.out;
|
|
12476
13068
|
});
|
|
@@ -12482,10 +13074,10 @@ function pipe(in_, out) {
|
|
|
12482
13074
|
// ...util.normalizeParams(params),
|
|
12483
13075
|
});
|
|
12484
13076
|
}
|
|
12485
|
-
const ZodCodec = /*@__PURE__*/
|
|
13077
|
+
const ZodCodec = /*@__PURE__*/ $constructor("ZodCodec", (inst, def) => {
|
|
12486
13078
|
ZodPipe.init(inst, def);
|
|
12487
|
-
|
|
12488
|
-
})
|
|
13079
|
+
$ZodCodec.init(inst, def);
|
|
13080
|
+
});
|
|
12489
13081
|
function codec(in_, out, params) {
|
|
12490
13082
|
return new ZodCodec({
|
|
12491
13083
|
type: "pipe",
|
|
@@ -12498,6 +13090,7 @@ function codec(in_, out, params) {
|
|
|
12498
13090
|
const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
|
|
12499
13091
|
$ZodReadonly.init(inst, def);
|
|
12500
13092
|
ZodType.init(inst, def);
|
|
13093
|
+
inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
|
|
12501
13094
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
12502
13095
|
});
|
|
12503
13096
|
function readonly(innerType) {
|
|
@@ -12506,43 +13099,47 @@ function readonly(innerType) {
|
|
|
12506
13099
|
innerType: innerType,
|
|
12507
13100
|
});
|
|
12508
13101
|
}
|
|
12509
|
-
const ZodTemplateLiteral = /*@__PURE__*/
|
|
12510
|
-
|
|
13102
|
+
const ZodTemplateLiteral = /*@__PURE__*/ $constructor("ZodTemplateLiteral", (inst, def) => {
|
|
13103
|
+
$ZodTemplateLiteral.init(inst, def);
|
|
12511
13104
|
ZodType.init(inst, def);
|
|
12512
|
-
|
|
13105
|
+
inst._zod.processJSONSchema = (ctx, json, params) => templateLiteralProcessor(inst, ctx, json, params);
|
|
13106
|
+
});
|
|
12513
13107
|
function templateLiteral(parts, params) {
|
|
12514
13108
|
return new ZodTemplateLiteral({
|
|
12515
13109
|
type: "template_literal",
|
|
12516
13110
|
parts,
|
|
12517
|
-
...
|
|
13111
|
+
...normalizeParams(params),
|
|
12518
13112
|
});
|
|
12519
13113
|
}
|
|
12520
|
-
const ZodLazy = /*@__PURE__*/
|
|
12521
|
-
|
|
13114
|
+
const ZodLazy = /*@__PURE__*/ $constructor("ZodLazy", (inst, def) => {
|
|
13115
|
+
$ZodLazy.init(inst, def);
|
|
12522
13116
|
ZodType.init(inst, def);
|
|
13117
|
+
inst._zod.processJSONSchema = (ctx, json, params) => lazyProcessor(inst, ctx, json, params);
|
|
12523
13118
|
inst.unwrap = () => inst._zod.def.getter();
|
|
12524
|
-
})
|
|
13119
|
+
});
|
|
12525
13120
|
function lazy(getter) {
|
|
12526
13121
|
return new ZodLazy({
|
|
12527
13122
|
type: "lazy",
|
|
12528
13123
|
getter: getter,
|
|
12529
13124
|
});
|
|
12530
13125
|
}
|
|
12531
|
-
const ZodPromise = /*@__PURE__*/
|
|
12532
|
-
|
|
13126
|
+
const ZodPromise = /*@__PURE__*/ $constructor("ZodPromise", (inst, def) => {
|
|
13127
|
+
$ZodPromise.init(inst, def);
|
|
12533
13128
|
ZodType.init(inst, def);
|
|
13129
|
+
inst._zod.processJSONSchema = (ctx, json, params) => promiseProcessor(inst, ctx, json, params);
|
|
12534
13130
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
12535
|
-
})
|
|
13131
|
+
});
|
|
12536
13132
|
function promise(innerType) {
|
|
12537
13133
|
return new ZodPromise({
|
|
12538
13134
|
type: "promise",
|
|
12539
13135
|
innerType: innerType,
|
|
12540
13136
|
});
|
|
12541
13137
|
}
|
|
12542
|
-
const ZodFunction = /*@__PURE__*/
|
|
12543
|
-
|
|
13138
|
+
const ZodFunction = /*@__PURE__*/ $constructor("ZodFunction", (inst, def) => {
|
|
13139
|
+
$ZodFunction.init(inst, def);
|
|
12544
13140
|
ZodType.init(inst, def);
|
|
12545
|
-
|
|
13141
|
+
inst._zod.processJSONSchema = (ctx, json, params) => functionProcessor(inst, ctx, json, params);
|
|
13142
|
+
});
|
|
12546
13143
|
function _function(params) {
|
|
12547
13144
|
return new ZodFunction({
|
|
12548
13145
|
type: "function",
|
|
@@ -12554,10 +13151,11 @@ function _function(params) {
|
|
|
12554
13151
|
const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
|
|
12555
13152
|
$ZodCustom.init(inst, def);
|
|
12556
13153
|
ZodType.init(inst, def);
|
|
13154
|
+
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
|
|
12557
13155
|
});
|
|
12558
13156
|
// custom checks
|
|
12559
13157
|
function check(fn) {
|
|
12560
|
-
const ch = new
|
|
13158
|
+
const ch = new $ZodCheck({
|
|
12561
13159
|
check: "custom",
|
|
12562
13160
|
// ...util.normalizeParams(params),
|
|
12563
13161
|
});
|
|
@@ -12565,7 +13163,7 @@ function check(fn) {
|
|
|
12565
13163
|
return ch;
|
|
12566
13164
|
}
|
|
12567
13165
|
function custom(fn, _params) {
|
|
12568
|
-
return
|
|
13166
|
+
return _custom(ZodCustom, fn ?? (() => true), _params);
|
|
12569
13167
|
}
|
|
12570
13168
|
function refine(fn, _params = {}) {
|
|
12571
13169
|
return _refine(ZodCustom, fn, _params);
|
|
@@ -12585,14 +13183,14 @@ function _instanceof(cls, params = {
|
|
|
12585
13183
|
check: "custom",
|
|
12586
13184
|
fn: (data) => data instanceof cls,
|
|
12587
13185
|
abort: true,
|
|
12588
|
-
...
|
|
13186
|
+
...normalizeParams(params),
|
|
12589
13187
|
});
|
|
12590
13188
|
inst._zod.bag.Class = cls;
|
|
12591
13189
|
return inst;
|
|
12592
13190
|
}
|
|
12593
13191
|
|
|
12594
13192
|
// stringbool
|
|
12595
|
-
const stringbool = (...args) =>
|
|
13193
|
+
const stringbool = (...args) => _stringbool({
|
|
12596
13194
|
Codec: ZodCodec,
|
|
12597
13195
|
Boolean: ZodBoolean,
|
|
12598
13196
|
String: ZodString,
|
|
@@ -12642,6 +13240,493 @@ var ZodFirstPartyTypeKind;
|
|
|
12642
13240
|
(function (ZodFirstPartyTypeKind) {
|
|
12643
13241
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
12644
13242
|
|
|
13243
|
+
;// CONCATENATED MODULE: ./node_modules/zod/v4/classic/from-json-schema.js
|
|
13244
|
+
|
|
13245
|
+
|
|
13246
|
+
|
|
13247
|
+
// Local z object to avoid circular dependency with ../index.js
|
|
13248
|
+
const z = {
|
|
13249
|
+
...classic_schemas_namespaceObject,
|
|
13250
|
+
...classic_checks_namespaceObject,
|
|
13251
|
+
iso: iso_namespaceObject,
|
|
13252
|
+
};
|
|
13253
|
+
function detectVersion(schema, defaultTarget) {
|
|
13254
|
+
const $schema = schema.$schema;
|
|
13255
|
+
if ($schema === "https://json-schema.org/draft/2020-12/schema") {
|
|
13256
|
+
return "draft-2020-12";
|
|
13257
|
+
}
|
|
13258
|
+
if ($schema === "http://json-schema.org/draft-07/schema#") {
|
|
13259
|
+
return "draft-7";
|
|
13260
|
+
}
|
|
13261
|
+
if ($schema === "http://json-schema.org/draft-04/schema#") {
|
|
13262
|
+
return "draft-4";
|
|
13263
|
+
}
|
|
13264
|
+
// Use defaultTarget if provided, otherwise default to draft-2020-12
|
|
13265
|
+
return defaultTarget ?? "draft-2020-12";
|
|
13266
|
+
}
|
|
13267
|
+
function resolveRef(ref, ctx) {
|
|
13268
|
+
if (!ref.startsWith("#")) {
|
|
13269
|
+
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
13270
|
+
}
|
|
13271
|
+
const path = ref.slice(1).split("/").filter(Boolean);
|
|
13272
|
+
// Handle root reference "#"
|
|
13273
|
+
if (path.length === 0) {
|
|
13274
|
+
return ctx.rootSchema;
|
|
13275
|
+
}
|
|
13276
|
+
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
13277
|
+
if (path[0] === defsKey) {
|
|
13278
|
+
const key = path[1];
|
|
13279
|
+
if (!key || !ctx.defs[key]) {
|
|
13280
|
+
throw new Error(`Reference not found: ${ref}`);
|
|
13281
|
+
}
|
|
13282
|
+
return ctx.defs[key];
|
|
13283
|
+
}
|
|
13284
|
+
throw new Error(`Reference not found: ${ref}`);
|
|
13285
|
+
}
|
|
13286
|
+
function convertBaseSchema(schema, ctx) {
|
|
13287
|
+
// Handle unsupported features
|
|
13288
|
+
if (schema.not !== undefined) {
|
|
13289
|
+
// Special case: { not: {} } represents never
|
|
13290
|
+
if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
|
|
13291
|
+
return z.never();
|
|
13292
|
+
}
|
|
13293
|
+
throw new Error("not is not supported in Zod (except { not: {} } for never)");
|
|
13294
|
+
}
|
|
13295
|
+
if (schema.unevaluatedItems !== undefined) {
|
|
13296
|
+
throw new Error("unevaluatedItems is not supported");
|
|
13297
|
+
}
|
|
13298
|
+
if (schema.unevaluatedProperties !== undefined) {
|
|
13299
|
+
throw new Error("unevaluatedProperties is not supported");
|
|
13300
|
+
}
|
|
13301
|
+
if (schema.if !== undefined || schema.then !== undefined || schema.else !== undefined) {
|
|
13302
|
+
throw new Error("Conditional schemas (if/then/else) are not supported");
|
|
13303
|
+
}
|
|
13304
|
+
if (schema.dependentSchemas !== undefined || schema.dependentRequired !== undefined) {
|
|
13305
|
+
throw new Error("dependentSchemas and dependentRequired are not supported");
|
|
13306
|
+
}
|
|
13307
|
+
// Handle $ref
|
|
13308
|
+
if (schema.$ref) {
|
|
13309
|
+
const refPath = schema.$ref;
|
|
13310
|
+
if (ctx.refs.has(refPath)) {
|
|
13311
|
+
return ctx.refs.get(refPath);
|
|
13312
|
+
}
|
|
13313
|
+
if (ctx.processing.has(refPath)) {
|
|
13314
|
+
// Circular reference - use lazy
|
|
13315
|
+
return z.lazy(() => {
|
|
13316
|
+
if (!ctx.refs.has(refPath)) {
|
|
13317
|
+
throw new Error(`Circular reference not resolved: ${refPath}`);
|
|
13318
|
+
}
|
|
13319
|
+
return ctx.refs.get(refPath);
|
|
13320
|
+
});
|
|
13321
|
+
}
|
|
13322
|
+
ctx.processing.add(refPath);
|
|
13323
|
+
const resolved = resolveRef(refPath, ctx);
|
|
13324
|
+
const zodSchema = convertSchema(resolved, ctx);
|
|
13325
|
+
ctx.refs.set(refPath, zodSchema);
|
|
13326
|
+
ctx.processing.delete(refPath);
|
|
13327
|
+
return zodSchema;
|
|
13328
|
+
}
|
|
13329
|
+
// Handle enum
|
|
13330
|
+
if (schema.enum !== undefined) {
|
|
13331
|
+
const enumValues = schema.enum;
|
|
13332
|
+
// Special case: OpenAPI 3.0 null representation { type: "string", nullable: true, enum: [null] }
|
|
13333
|
+
if (ctx.version === "openapi-3.0" &&
|
|
13334
|
+
schema.nullable === true &&
|
|
13335
|
+
enumValues.length === 1 &&
|
|
13336
|
+
enumValues[0] === null) {
|
|
13337
|
+
return z.null();
|
|
13338
|
+
}
|
|
13339
|
+
if (enumValues.length === 0) {
|
|
13340
|
+
return z.never();
|
|
13341
|
+
}
|
|
13342
|
+
if (enumValues.length === 1) {
|
|
13343
|
+
return z.literal(enumValues[0]);
|
|
13344
|
+
}
|
|
13345
|
+
// Check if all values are strings
|
|
13346
|
+
if (enumValues.every((v) => typeof v === "string")) {
|
|
13347
|
+
return z.enum(enumValues);
|
|
13348
|
+
}
|
|
13349
|
+
// Mixed types - use union of literals
|
|
13350
|
+
const literalSchemas = enumValues.map((v) => z.literal(v));
|
|
13351
|
+
if (literalSchemas.length < 2) {
|
|
13352
|
+
return literalSchemas[0];
|
|
13353
|
+
}
|
|
13354
|
+
return z.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
|
|
13355
|
+
}
|
|
13356
|
+
// Handle const
|
|
13357
|
+
if (schema.const !== undefined) {
|
|
13358
|
+
return z.literal(schema.const);
|
|
13359
|
+
}
|
|
13360
|
+
// Handle type
|
|
13361
|
+
const type = schema.type;
|
|
13362
|
+
if (Array.isArray(type)) {
|
|
13363
|
+
// Expand type array into anyOf union
|
|
13364
|
+
const typeSchemas = type.map((t) => {
|
|
13365
|
+
const typeSchema = { ...schema, type: t };
|
|
13366
|
+
return convertBaseSchema(typeSchema, ctx);
|
|
13367
|
+
});
|
|
13368
|
+
if (typeSchemas.length === 0) {
|
|
13369
|
+
return z.never();
|
|
13370
|
+
}
|
|
13371
|
+
if (typeSchemas.length === 1) {
|
|
13372
|
+
return typeSchemas[0];
|
|
13373
|
+
}
|
|
13374
|
+
return z.union(typeSchemas);
|
|
13375
|
+
}
|
|
13376
|
+
if (!type) {
|
|
13377
|
+
// No type specified - empty schema (any)
|
|
13378
|
+
return z.any();
|
|
13379
|
+
}
|
|
13380
|
+
let zodSchema;
|
|
13381
|
+
switch (type) {
|
|
13382
|
+
case "string": {
|
|
13383
|
+
let stringSchema = z.string();
|
|
13384
|
+
// Apply format using .check() with Zod format functions
|
|
13385
|
+
if (schema.format) {
|
|
13386
|
+
const format = schema.format;
|
|
13387
|
+
// Map common formats to Zod check functions
|
|
13388
|
+
if (format === "email") {
|
|
13389
|
+
stringSchema = stringSchema.check(z.email());
|
|
13390
|
+
}
|
|
13391
|
+
else if (format === "uri" || format === "uri-reference") {
|
|
13392
|
+
stringSchema = stringSchema.check(z.url());
|
|
13393
|
+
}
|
|
13394
|
+
else if (format === "uuid" || format === "guid") {
|
|
13395
|
+
stringSchema = stringSchema.check(z.uuid());
|
|
13396
|
+
}
|
|
13397
|
+
else if (format === "date-time") {
|
|
13398
|
+
stringSchema = stringSchema.check(z.iso.datetime());
|
|
13399
|
+
}
|
|
13400
|
+
else if (format === "date") {
|
|
13401
|
+
stringSchema = stringSchema.check(z.iso.date());
|
|
13402
|
+
}
|
|
13403
|
+
else if (format === "time") {
|
|
13404
|
+
stringSchema = stringSchema.check(z.iso.time());
|
|
13405
|
+
}
|
|
13406
|
+
else if (format === "duration") {
|
|
13407
|
+
stringSchema = stringSchema.check(z.iso.duration());
|
|
13408
|
+
}
|
|
13409
|
+
else if (format === "ipv4") {
|
|
13410
|
+
stringSchema = stringSchema.check(z.ipv4());
|
|
13411
|
+
}
|
|
13412
|
+
else if (format === "ipv6") {
|
|
13413
|
+
stringSchema = stringSchema.check(z.ipv6());
|
|
13414
|
+
}
|
|
13415
|
+
else if (format === "mac") {
|
|
13416
|
+
stringSchema = stringSchema.check(z.mac());
|
|
13417
|
+
}
|
|
13418
|
+
else if (format === "cidr") {
|
|
13419
|
+
stringSchema = stringSchema.check(z.cidrv4());
|
|
13420
|
+
}
|
|
13421
|
+
else if (format === "cidr-v6") {
|
|
13422
|
+
stringSchema = stringSchema.check(z.cidrv6());
|
|
13423
|
+
}
|
|
13424
|
+
else if (format === "base64") {
|
|
13425
|
+
stringSchema = stringSchema.check(z.base64());
|
|
13426
|
+
}
|
|
13427
|
+
else if (format === "base64url") {
|
|
13428
|
+
stringSchema = stringSchema.check(z.base64url());
|
|
13429
|
+
}
|
|
13430
|
+
else if (format === "e164") {
|
|
13431
|
+
stringSchema = stringSchema.check(z.e164());
|
|
13432
|
+
}
|
|
13433
|
+
else if (format === "jwt") {
|
|
13434
|
+
stringSchema = stringSchema.check(z.jwt());
|
|
13435
|
+
}
|
|
13436
|
+
else if (format === "emoji") {
|
|
13437
|
+
stringSchema = stringSchema.check(z.emoji());
|
|
13438
|
+
}
|
|
13439
|
+
else if (format === "nanoid") {
|
|
13440
|
+
stringSchema = stringSchema.check(z.nanoid());
|
|
13441
|
+
}
|
|
13442
|
+
else if (format === "cuid") {
|
|
13443
|
+
stringSchema = stringSchema.check(z.cuid());
|
|
13444
|
+
}
|
|
13445
|
+
else if (format === "cuid2") {
|
|
13446
|
+
stringSchema = stringSchema.check(z.cuid2());
|
|
13447
|
+
}
|
|
13448
|
+
else if (format === "ulid") {
|
|
13449
|
+
stringSchema = stringSchema.check(z.ulid());
|
|
13450
|
+
}
|
|
13451
|
+
else if (format === "xid") {
|
|
13452
|
+
stringSchema = stringSchema.check(z.xid());
|
|
13453
|
+
}
|
|
13454
|
+
else if (format === "ksuid") {
|
|
13455
|
+
stringSchema = stringSchema.check(z.ksuid());
|
|
13456
|
+
}
|
|
13457
|
+
// Note: json-string format is not currently supported by Zod
|
|
13458
|
+
// Custom formats are ignored - keep as plain string
|
|
13459
|
+
}
|
|
13460
|
+
// Apply constraints
|
|
13461
|
+
if (typeof schema.minLength === "number") {
|
|
13462
|
+
stringSchema = stringSchema.min(schema.minLength);
|
|
13463
|
+
}
|
|
13464
|
+
if (typeof schema.maxLength === "number") {
|
|
13465
|
+
stringSchema = stringSchema.max(schema.maxLength);
|
|
13466
|
+
}
|
|
13467
|
+
if (schema.pattern) {
|
|
13468
|
+
// JSON Schema patterns are not implicitly anchored (match anywhere in string)
|
|
13469
|
+
stringSchema = stringSchema.regex(new RegExp(schema.pattern));
|
|
13470
|
+
}
|
|
13471
|
+
zodSchema = stringSchema;
|
|
13472
|
+
break;
|
|
13473
|
+
}
|
|
13474
|
+
case "number":
|
|
13475
|
+
case "integer": {
|
|
13476
|
+
let numberSchema = type === "integer" ? z.number().int() : z.number();
|
|
13477
|
+
// Apply constraints
|
|
13478
|
+
if (typeof schema.minimum === "number") {
|
|
13479
|
+
numberSchema = numberSchema.min(schema.minimum);
|
|
13480
|
+
}
|
|
13481
|
+
if (typeof schema.maximum === "number") {
|
|
13482
|
+
numberSchema = numberSchema.max(schema.maximum);
|
|
13483
|
+
}
|
|
13484
|
+
if (typeof schema.exclusiveMinimum === "number") {
|
|
13485
|
+
numberSchema = numberSchema.gt(schema.exclusiveMinimum);
|
|
13486
|
+
}
|
|
13487
|
+
else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
|
|
13488
|
+
numberSchema = numberSchema.gt(schema.minimum);
|
|
13489
|
+
}
|
|
13490
|
+
if (typeof schema.exclusiveMaximum === "number") {
|
|
13491
|
+
numberSchema = numberSchema.lt(schema.exclusiveMaximum);
|
|
13492
|
+
}
|
|
13493
|
+
else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
|
|
13494
|
+
numberSchema = numberSchema.lt(schema.maximum);
|
|
13495
|
+
}
|
|
13496
|
+
if (typeof schema.multipleOf === "number") {
|
|
13497
|
+
numberSchema = numberSchema.multipleOf(schema.multipleOf);
|
|
13498
|
+
}
|
|
13499
|
+
zodSchema = numberSchema;
|
|
13500
|
+
break;
|
|
13501
|
+
}
|
|
13502
|
+
case "boolean": {
|
|
13503
|
+
zodSchema = z.boolean();
|
|
13504
|
+
break;
|
|
13505
|
+
}
|
|
13506
|
+
case "null": {
|
|
13507
|
+
zodSchema = z.null();
|
|
13508
|
+
break;
|
|
13509
|
+
}
|
|
13510
|
+
case "object": {
|
|
13511
|
+
const shape = {};
|
|
13512
|
+
const properties = schema.properties || {};
|
|
13513
|
+
const requiredSet = new Set(schema.required || []);
|
|
13514
|
+
// Convert properties - mark optional ones
|
|
13515
|
+
for (const [key, propSchema] of Object.entries(properties)) {
|
|
13516
|
+
const propZodSchema = convertSchema(propSchema, ctx);
|
|
13517
|
+
// If not in required array, make it optional
|
|
13518
|
+
shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
|
|
13519
|
+
}
|
|
13520
|
+
// Handle propertyNames
|
|
13521
|
+
if (schema.propertyNames) {
|
|
13522
|
+
const keySchema = convertSchema(schema.propertyNames, ctx);
|
|
13523
|
+
const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object"
|
|
13524
|
+
? convertSchema(schema.additionalProperties, ctx)
|
|
13525
|
+
: z.any();
|
|
13526
|
+
// Case A: No properties (pure record)
|
|
13527
|
+
if (Object.keys(shape).length === 0) {
|
|
13528
|
+
zodSchema = z.record(keySchema, valueSchema);
|
|
13529
|
+
break;
|
|
13530
|
+
}
|
|
13531
|
+
// Case B: With properties (intersection of object and looseRecord)
|
|
13532
|
+
const objectSchema = z.object(shape).passthrough();
|
|
13533
|
+
const recordSchema = z.looseRecord(keySchema, valueSchema);
|
|
13534
|
+
zodSchema = z.intersection(objectSchema, recordSchema);
|
|
13535
|
+
break;
|
|
13536
|
+
}
|
|
13537
|
+
// Handle patternProperties
|
|
13538
|
+
if (schema.patternProperties) {
|
|
13539
|
+
// patternProperties: keys matching pattern must satisfy corresponding schema
|
|
13540
|
+
// Use loose records so non-matching keys pass through
|
|
13541
|
+
const patternProps = schema.patternProperties;
|
|
13542
|
+
const patternKeys = Object.keys(patternProps);
|
|
13543
|
+
const looseRecords = [];
|
|
13544
|
+
for (const pattern of patternKeys) {
|
|
13545
|
+
const patternValue = convertSchema(patternProps[pattern], ctx);
|
|
13546
|
+
const keySchema = z.string().regex(new RegExp(pattern));
|
|
13547
|
+
looseRecords.push(z.looseRecord(keySchema, patternValue));
|
|
13548
|
+
}
|
|
13549
|
+
// Build intersection: object schema + all pattern property records
|
|
13550
|
+
const schemasToIntersect = [];
|
|
13551
|
+
if (Object.keys(shape).length > 0) {
|
|
13552
|
+
// Use passthrough so patternProperties can validate additional keys
|
|
13553
|
+
schemasToIntersect.push(z.object(shape).passthrough());
|
|
13554
|
+
}
|
|
13555
|
+
schemasToIntersect.push(...looseRecords);
|
|
13556
|
+
if (schemasToIntersect.length === 0) {
|
|
13557
|
+
zodSchema = z.object({}).passthrough();
|
|
13558
|
+
}
|
|
13559
|
+
else if (schemasToIntersect.length === 1) {
|
|
13560
|
+
zodSchema = schemasToIntersect[0];
|
|
13561
|
+
}
|
|
13562
|
+
else {
|
|
13563
|
+
// Chain intersections: (A & B) & C & D ...
|
|
13564
|
+
let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
|
|
13565
|
+
for (let i = 2; i < schemasToIntersect.length; i++) {
|
|
13566
|
+
result = z.intersection(result, schemasToIntersect[i]);
|
|
13567
|
+
}
|
|
13568
|
+
zodSchema = result;
|
|
13569
|
+
}
|
|
13570
|
+
break;
|
|
13571
|
+
}
|
|
13572
|
+
// Handle additionalProperties
|
|
13573
|
+
// In JSON Schema, additionalProperties defaults to true (allow any extra properties)
|
|
13574
|
+
// In Zod, objects strip unknown keys by default, so we need to handle this explicitly
|
|
13575
|
+
const objectSchema = z.object(shape);
|
|
13576
|
+
if (schema.additionalProperties === false) {
|
|
13577
|
+
// Strict mode - no extra properties allowed
|
|
13578
|
+
zodSchema = objectSchema.strict();
|
|
13579
|
+
}
|
|
13580
|
+
else if (typeof schema.additionalProperties === "object") {
|
|
13581
|
+
// Extra properties must match the specified schema
|
|
13582
|
+
zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx));
|
|
13583
|
+
}
|
|
13584
|
+
else {
|
|
13585
|
+
// additionalProperties is true or undefined - allow any extra properties (passthrough)
|
|
13586
|
+
zodSchema = objectSchema.passthrough();
|
|
13587
|
+
}
|
|
13588
|
+
break;
|
|
13589
|
+
}
|
|
13590
|
+
case "array": {
|
|
13591
|
+
// TODO: uniqueItems is not supported
|
|
13592
|
+
// TODO: contains/minContains/maxContains are not supported
|
|
13593
|
+
// Check if this is a tuple (prefixItems or items as array)
|
|
13594
|
+
const prefixItems = schema.prefixItems;
|
|
13595
|
+
const items = schema.items;
|
|
13596
|
+
if (prefixItems && Array.isArray(prefixItems)) {
|
|
13597
|
+
// Tuple with prefixItems (draft-2020-12)
|
|
13598
|
+
const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
|
|
13599
|
+
const rest = items && typeof items === "object" && !Array.isArray(items)
|
|
13600
|
+
? convertSchema(items, ctx)
|
|
13601
|
+
: undefined;
|
|
13602
|
+
if (rest) {
|
|
13603
|
+
zodSchema = z.tuple(tupleItems).rest(rest);
|
|
13604
|
+
}
|
|
13605
|
+
else {
|
|
13606
|
+
zodSchema = z.tuple(tupleItems);
|
|
13607
|
+
}
|
|
13608
|
+
// Apply minItems/maxItems constraints to tuples
|
|
13609
|
+
if (typeof schema.minItems === "number") {
|
|
13610
|
+
zodSchema = zodSchema.check(z.minLength(schema.minItems));
|
|
13611
|
+
}
|
|
13612
|
+
if (typeof schema.maxItems === "number") {
|
|
13613
|
+
zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
|
|
13614
|
+
}
|
|
13615
|
+
}
|
|
13616
|
+
else if (Array.isArray(items)) {
|
|
13617
|
+
// Tuple with items array (draft-7)
|
|
13618
|
+
const tupleItems = items.map((item) => convertSchema(item, ctx));
|
|
13619
|
+
const rest = schema.additionalItems && typeof schema.additionalItems === "object"
|
|
13620
|
+
? convertSchema(schema.additionalItems, ctx)
|
|
13621
|
+
: undefined; // additionalItems: false means no rest, handled by default tuple behavior
|
|
13622
|
+
if (rest) {
|
|
13623
|
+
zodSchema = z.tuple(tupleItems).rest(rest);
|
|
13624
|
+
}
|
|
13625
|
+
else {
|
|
13626
|
+
zodSchema = z.tuple(tupleItems);
|
|
13627
|
+
}
|
|
13628
|
+
// Apply minItems/maxItems constraints to tuples
|
|
13629
|
+
if (typeof schema.minItems === "number") {
|
|
13630
|
+
zodSchema = zodSchema.check(z.minLength(schema.minItems));
|
|
13631
|
+
}
|
|
13632
|
+
if (typeof schema.maxItems === "number") {
|
|
13633
|
+
zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
|
|
13634
|
+
}
|
|
13635
|
+
}
|
|
13636
|
+
else if (items !== undefined) {
|
|
13637
|
+
// Regular array
|
|
13638
|
+
const element = convertSchema(items, ctx);
|
|
13639
|
+
let arraySchema = z.array(element);
|
|
13640
|
+
// Apply constraints
|
|
13641
|
+
if (typeof schema.minItems === "number") {
|
|
13642
|
+
arraySchema = arraySchema.min(schema.minItems);
|
|
13643
|
+
}
|
|
13644
|
+
if (typeof schema.maxItems === "number") {
|
|
13645
|
+
arraySchema = arraySchema.max(schema.maxItems);
|
|
13646
|
+
}
|
|
13647
|
+
zodSchema = arraySchema;
|
|
13648
|
+
}
|
|
13649
|
+
else {
|
|
13650
|
+
// No items specified - array of any
|
|
13651
|
+
zodSchema = z.array(z.any());
|
|
13652
|
+
}
|
|
13653
|
+
break;
|
|
13654
|
+
}
|
|
13655
|
+
default:
|
|
13656
|
+
throw new Error(`Unsupported type: ${type}`);
|
|
13657
|
+
}
|
|
13658
|
+
// Apply metadata
|
|
13659
|
+
if (schema.description) {
|
|
13660
|
+
zodSchema = zodSchema.describe(schema.description);
|
|
13661
|
+
}
|
|
13662
|
+
if (schema.default !== undefined) {
|
|
13663
|
+
zodSchema = zodSchema.default(schema.default);
|
|
13664
|
+
}
|
|
13665
|
+
return zodSchema;
|
|
13666
|
+
}
|
|
13667
|
+
function convertSchema(schema, ctx) {
|
|
13668
|
+
if (typeof schema === "boolean") {
|
|
13669
|
+
return schema ? z.any() : z.never();
|
|
13670
|
+
}
|
|
13671
|
+
// Convert base schema first (ignoring composition keywords)
|
|
13672
|
+
let baseSchema = convertBaseSchema(schema, ctx);
|
|
13673
|
+
const hasExplicitType = schema.type || schema.enum !== undefined || schema.const !== undefined;
|
|
13674
|
+
// Process composition keywords LAST (they can appear together)
|
|
13675
|
+
// Handle anyOf - wrap base schema with union
|
|
13676
|
+
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
13677
|
+
const options = schema.anyOf.map((s) => convertSchema(s, ctx));
|
|
13678
|
+
const anyOfUnion = z.union(options);
|
|
13679
|
+
baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
13680
|
+
}
|
|
13681
|
+
// Handle oneOf - exclusive union (exactly one must match)
|
|
13682
|
+
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
13683
|
+
const options = schema.oneOf.map((s) => convertSchema(s, ctx));
|
|
13684
|
+
const oneOfUnion = z.xor(options);
|
|
13685
|
+
baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
13686
|
+
}
|
|
13687
|
+
// Handle allOf - wrap base schema with intersection
|
|
13688
|
+
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
13689
|
+
if (schema.allOf.length === 0) {
|
|
13690
|
+
baseSchema = hasExplicitType ? baseSchema : z.any();
|
|
13691
|
+
}
|
|
13692
|
+
else {
|
|
13693
|
+
let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
|
|
13694
|
+
const startIdx = hasExplicitType ? 0 : 1;
|
|
13695
|
+
for (let i = startIdx; i < schema.allOf.length; i++) {
|
|
13696
|
+
result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
|
|
13697
|
+
}
|
|
13698
|
+
baseSchema = result;
|
|
13699
|
+
}
|
|
13700
|
+
}
|
|
13701
|
+
// Handle nullable (OpenAPI 3.0)
|
|
13702
|
+
if (schema.nullable === true && ctx.version === "openapi-3.0") {
|
|
13703
|
+
baseSchema = z.nullable(baseSchema);
|
|
13704
|
+
}
|
|
13705
|
+
// Handle readOnly
|
|
13706
|
+
if (schema.readOnly === true) {
|
|
13707
|
+
baseSchema = z.readonly(baseSchema);
|
|
13708
|
+
}
|
|
13709
|
+
return baseSchema;
|
|
13710
|
+
}
|
|
13711
|
+
/**
|
|
13712
|
+
* Converts a JSON Schema to a Zod schema. This function should be considered semi-experimental. It's behavior is liable to change. */
|
|
13713
|
+
function fromJSONSchema(schema, params) {
|
|
13714
|
+
// Handle boolean schemas
|
|
13715
|
+
if (typeof schema === "boolean") {
|
|
13716
|
+
return schema ? z.any() : z.never();
|
|
13717
|
+
}
|
|
13718
|
+
const version = detectVersion(schema, params?.defaultTarget);
|
|
13719
|
+
const defs = (schema.$defs || schema.definitions || {});
|
|
13720
|
+
const ctx = {
|
|
13721
|
+
version,
|
|
13722
|
+
defs,
|
|
13723
|
+
refs: new Map(),
|
|
13724
|
+
processing: new Set(),
|
|
13725
|
+
rootSchema: schema,
|
|
13726
|
+
};
|
|
13727
|
+
return convertSchema(schema, ctx);
|
|
13728
|
+
}
|
|
13729
|
+
|
|
12645
13730
|
;// CONCATENATED MODULE: ./node_modules/zod/v4/classic/coerce.js
|
|
12646
13731
|
|
|
12647
13732
|
|
|
@@ -12674,6 +13759,8 @@ function coerce_date(params) {
|
|
|
12674
13759
|
config(en());
|
|
12675
13760
|
|
|
12676
13761
|
|
|
13762
|
+
|
|
13763
|
+
|
|
12677
13764
|
// iso
|
|
12678
13765
|
// must be exported from top-level
|
|
12679
13766
|
// https://github.com/colinhacks/zod/issues/4491
|