Spaces:
Paused
Paused
Upload folder using huggingface_hub (part 11)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- node_modules/@jimp/plugin-contain/node_modules/zod/v4-mini/index.cjs +17 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4-mini/index.d.cts +1 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4-mini/index.d.ts +1 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4-mini/index.js +1 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/parse.d.ts +25 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/parse.js +57 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/regexes.cjs +103 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/regexes.d.cts +62 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/regexes.d.ts +62 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/regexes.js +95 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/registries.cjs +56 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/registries.d.cts +35 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/registries.d.ts +35 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/registries.js +51 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/schemas.cjs +1748 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/schemas.d.cts +1041 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/schemas.d.ts +1041 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/schemas.js +1717 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/standard-schema.cjs +2 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/standard-schema.d.cts +55 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/standard-schema.d.ts +55 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/standard-schema.js +1 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/to-json-schema.cjs +854 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/to-json-schema.d.cts +88 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/to-json-schema.d.ts +88 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/to-json-schema.js +849 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/util.cjs +539 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/util.d.cts +183 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/util.d.ts +183 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/util.js +493 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/versions.cjs +8 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/versions.d.cts +5 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/versions.d.ts +5 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/versions.js +5 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/index.cjs +22 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/index.d.cts +3 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/index.d.ts +3 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/index.js +3 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/ar.cjs +142 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/ar.d.cts +4 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/ar.d.ts +4 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/ar.js +116 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/az.cjs +141 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/az.d.cts +4 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/az.d.ts +4 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/az.js +115 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/be.cjs +190 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/be.d.cts +4 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/be.d.ts +4 -0
- node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/be.js +164 -0
node_modules/@jimp/plugin-contain/node_modules/zod/v4-mini/index.cjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 3 |
+
if (k2 === undefined) k2 = k;
|
| 4 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 5 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 6 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 7 |
+
}
|
| 8 |
+
Object.defineProperty(o, k2, desc);
|
| 9 |
+
}) : (function(o, m, k, k2) {
|
| 10 |
+
if (k2 === undefined) k2 = k;
|
| 11 |
+
o[k2] = m[k];
|
| 12 |
+
}));
|
| 13 |
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
| 14 |
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
| 15 |
+
};
|
| 16 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 17 |
+
__exportStar(require("../v4/mini/index.cjs"), exports);
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4-mini/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export * from "../v4/mini/index.cjs";
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4-mini/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export * from "../v4/mini/index.js";
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4-mini/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export * from "../v4/mini/index.js";
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/parse.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as core from "./core.js";
|
| 2 |
+
import * as errors from "./errors.js";
|
| 3 |
+
import type * as schemas from "./schemas.js";
|
| 4 |
+
import * as util from "./util.js";
|
| 5 |
+
export type $ZodErrorClass = {
|
| 6 |
+
new (issues: errors.$ZodIssue[]): errors.$ZodError;
|
| 7 |
+
};
|
| 8 |
+
export type $Parse = <T extends schemas.$ZodType>(schema: T, value: unknown, _ctx?: schemas.ParseContext<errors.$ZodIssue>, _params?: {
|
| 9 |
+
callee?: util.AnyFunc;
|
| 10 |
+
Err?: $ZodErrorClass;
|
| 11 |
+
}) => core.output<T>;
|
| 12 |
+
export declare const _parse: (_Err: $ZodErrorClass) => $Parse;
|
| 13 |
+
export declare const parse: $Parse;
|
| 14 |
+
export type $ParseAsync = <T extends schemas.$ZodType>(schema: T, value: unknown, _ctx?: schemas.ParseContext<errors.$ZodIssue>, _params?: {
|
| 15 |
+
callee?: util.AnyFunc;
|
| 16 |
+
Err?: $ZodErrorClass;
|
| 17 |
+
}) => Promise<core.output<T>>;
|
| 18 |
+
export declare const _parseAsync: (_Err: $ZodErrorClass) => $ParseAsync;
|
| 19 |
+
export declare const parseAsync: $ParseAsync;
|
| 20 |
+
export type $SafeParse = <T extends schemas.$ZodType>(schema: T, value: unknown, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => util.SafeParseResult<core.output<T>>;
|
| 21 |
+
export declare const _safeParse: (_Err: $ZodErrorClass) => $SafeParse;
|
| 22 |
+
export declare const safeParse: $SafeParse;
|
| 23 |
+
export type $SafeParseAsync = <T extends schemas.$ZodType>(schema: T, value: unknown, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => Promise<util.SafeParseResult<core.output<T>>>;
|
| 24 |
+
export declare const _safeParseAsync: (_Err: $ZodErrorClass) => $SafeParseAsync;
|
| 25 |
+
export declare const safeParseAsync: $SafeParseAsync;
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/parse.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as core from "./core.js";
|
| 2 |
+
import * as errors from "./errors.js";
|
| 3 |
+
import * as util from "./util.js";
|
| 4 |
+
export const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
| 5 |
+
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
| 6 |
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
| 7 |
+
if (result instanceof Promise) {
|
| 8 |
+
throw new core.$ZodAsyncError();
|
| 9 |
+
}
|
| 10 |
+
if (result.issues.length) {
|
| 11 |
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
|
| 12 |
+
util.captureStackTrace(e, _params?.callee);
|
| 13 |
+
throw e;
|
| 14 |
+
}
|
| 15 |
+
return result.value;
|
| 16 |
+
};
|
| 17 |
+
export const parse = /* @__PURE__*/ _parse(errors.$ZodRealError);
|
| 18 |
+
export const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
| 19 |
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
| 20 |
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
| 21 |
+
if (result instanceof Promise)
|
| 22 |
+
result = await result;
|
| 23 |
+
if (result.issues.length) {
|
| 24 |
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
|
| 25 |
+
util.captureStackTrace(e, params?.callee);
|
| 26 |
+
throw e;
|
| 27 |
+
}
|
| 28 |
+
return result.value;
|
| 29 |
+
};
|
| 30 |
+
export const parseAsync = /* @__PURE__*/ _parseAsync(errors.$ZodRealError);
|
| 31 |
+
export const _safeParse = (_Err) => (schema, value, _ctx) => {
|
| 32 |
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
| 33 |
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
| 34 |
+
if (result instanceof Promise) {
|
| 35 |
+
throw new core.$ZodAsyncError();
|
| 36 |
+
}
|
| 37 |
+
return result.issues.length
|
| 38 |
+
? {
|
| 39 |
+
success: false,
|
| 40 |
+
error: new (_Err ?? errors.$ZodError)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
|
| 41 |
+
}
|
| 42 |
+
: { success: true, data: result.value };
|
| 43 |
+
};
|
| 44 |
+
export const safeParse = /* @__PURE__*/ _safeParse(errors.$ZodRealError);
|
| 45 |
+
export const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
| 46 |
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
| 47 |
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
| 48 |
+
if (result instanceof Promise)
|
| 49 |
+
result = await result;
|
| 50 |
+
return result.issues.length
|
| 51 |
+
? {
|
| 52 |
+
success: false,
|
| 53 |
+
error: new _Err(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
|
| 54 |
+
}
|
| 55 |
+
: { success: true, data: result.value };
|
| 56 |
+
};
|
| 57 |
+
export const safeParseAsync = /* @__PURE__*/ _safeParseAsync(errors.$ZodRealError);
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/regexes.cjs
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.uppercase = exports.lowercase = exports.undefined = exports.null = exports.boolean = exports.number = exports.integer = exports.bigint = exports.string = exports.date = exports.e164 = exports.domain = exports.hostname = exports.base64url = exports.base64 = exports.cidrv6 = exports.cidrv4 = exports.ipv6 = exports.ipv4 = exports._emoji = exports.browserEmail = exports.unicodeEmail = exports.rfc5322Email = exports.html5Email = exports.email = exports.uuid7 = exports.uuid6 = exports.uuid4 = exports.uuid = exports.guid = exports.extendedDuration = exports.duration = exports.nanoid = exports.ksuid = exports.xid = exports.ulid = exports.cuid2 = exports.cuid = void 0;
|
| 4 |
+
exports.emoji = emoji;
|
| 5 |
+
exports.time = time;
|
| 6 |
+
exports.datetime = datetime;
|
| 7 |
+
exports.cuid = /^[cC][^\s-]{8,}$/;
|
| 8 |
+
exports.cuid2 = /^[0-9a-z]+$/;
|
| 9 |
+
exports.ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
| 10 |
+
exports.xid = /^[0-9a-vA-V]{20}$/;
|
| 11 |
+
exports.ksuid = /^[A-Za-z0-9]{27}$/;
|
| 12 |
+
exports.nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
| 13 |
+
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
| 14 |
+
exports.duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
| 15 |
+
/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
|
| 16 |
+
exports.extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
| 17 |
+
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
| 18 |
+
exports.guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
| 19 |
+
/** Returns a regex for validating an RFC 4122 UUID.
|
| 20 |
+
*
|
| 21 |
+
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
| 22 |
+
const uuid = (version) => {
|
| 23 |
+
if (!version)
|
| 24 |
+
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)$/;
|
| 25 |
+
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})$`);
|
| 26 |
+
};
|
| 27 |
+
exports.uuid = uuid;
|
| 28 |
+
exports.uuid4 = (0, exports.uuid)(4);
|
| 29 |
+
exports.uuid6 = (0, exports.uuid)(6);
|
| 30 |
+
exports.uuid7 = (0, exports.uuid)(7);
|
| 31 |
+
/** Practical email validation */
|
| 32 |
+
exports.email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
| 33 |
+
/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
|
| 34 |
+
exports.html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
| 35 |
+
/** The classic emailregex.com regex for RFC 5322-compliant emails */
|
| 36 |
+
exports.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,}))$/;
|
| 37 |
+
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
| 38 |
+
exports.unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
| 39 |
+
exports.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])?)*$/;
|
| 40 |
+
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
| 41 |
+
exports._emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
| 42 |
+
function emoji() {
|
| 43 |
+
return new RegExp(exports._emoji, "u");
|
| 44 |
+
}
|
| 45 |
+
exports.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])$/;
|
| 46 |
+
exports.ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/;
|
| 47 |
+
exports.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])$/;
|
| 48 |
+
exports.cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
| 49 |
+
// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
|
| 50 |
+
exports.base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
| 51 |
+
exports.base64url = /^[A-Za-z0-9_-]*$/;
|
| 52 |
+
// based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
|
| 53 |
+
// export const hostname: RegExp =
|
| 54 |
+
// /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)+([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/;
|
| 55 |
+
exports.hostname = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
| 56 |
+
exports.domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
| 57 |
+
// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
|
| 58 |
+
exports.e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
| 59 |
+
// const dateSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
| 60 |
+
const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
| 61 |
+
exports.date = new RegExp(`^${dateSource}$`);
|
| 62 |
+
function timeSource(args) {
|
| 63 |
+
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
| 64 |
+
const regex = typeof args.precision === "number"
|
| 65 |
+
? args.precision === -1
|
| 66 |
+
? `${hhmm}`
|
| 67 |
+
: args.precision === 0
|
| 68 |
+
? `${hhmm}:[0-5]\\d`
|
| 69 |
+
: `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}`
|
| 70 |
+
: `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
| 71 |
+
return regex;
|
| 72 |
+
}
|
| 73 |
+
function time(args) {
|
| 74 |
+
return new RegExp(`^${timeSource(args)}$`);
|
| 75 |
+
}
|
| 76 |
+
// Adapted from https://stackoverflow.com/a/3143231
|
| 77 |
+
function datetime(args) {
|
| 78 |
+
const time = timeSource({ precision: args.precision });
|
| 79 |
+
const opts = ["Z"];
|
| 80 |
+
if (args.local)
|
| 81 |
+
opts.push("");
|
| 82 |
+
if (args.offset)
|
| 83 |
+
opts.push(`([+-]\\d{2}:\\d{2})`);
|
| 84 |
+
const timeRegex = `${time}(?:${opts.join("|")})`;
|
| 85 |
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
| 86 |
+
}
|
| 87 |
+
const string = (params) => {
|
| 88 |
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
| 89 |
+
return new RegExp(`^${regex}$`);
|
| 90 |
+
};
|
| 91 |
+
exports.string = string;
|
| 92 |
+
exports.bigint = /^\d+n?$/;
|
| 93 |
+
exports.integer = /^\d+$/;
|
| 94 |
+
exports.number = /^-?\d+(?:\.\d+)?/i;
|
| 95 |
+
exports.boolean = /true|false/i;
|
| 96 |
+
const _null = /null/i;
|
| 97 |
+
exports.null = _null;
|
| 98 |
+
const _undefined = /undefined/i;
|
| 99 |
+
exports.undefined = _undefined;
|
| 100 |
+
// regex for string with no uppercase letters
|
| 101 |
+
exports.lowercase = /^[^A-Z]*$/;
|
| 102 |
+
// regex for string with no lowercase letters
|
| 103 |
+
exports.uppercase = /^[^a-z]*$/;
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/regexes.d.cts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export declare const cuid: RegExp;
|
| 2 |
+
export declare const cuid2: RegExp;
|
| 3 |
+
export declare const ulid: RegExp;
|
| 4 |
+
export declare const xid: RegExp;
|
| 5 |
+
export declare const ksuid: RegExp;
|
| 6 |
+
export declare const nanoid: RegExp;
|
| 7 |
+
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
| 8 |
+
export declare const duration: RegExp;
|
| 9 |
+
/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
|
| 10 |
+
export declare const extendedDuration: RegExp;
|
| 11 |
+
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
| 12 |
+
export declare const guid: RegExp;
|
| 13 |
+
/** Returns a regex for validating an RFC 4122 UUID.
|
| 14 |
+
*
|
| 15 |
+
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
| 16 |
+
export declare const uuid: (version?: number | undefined) => RegExp;
|
| 17 |
+
export declare const uuid4: RegExp;
|
| 18 |
+
export declare const uuid6: RegExp;
|
| 19 |
+
export declare const uuid7: RegExp;
|
| 20 |
+
/** Practical email validation */
|
| 21 |
+
export declare const email: RegExp;
|
| 22 |
+
/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
|
| 23 |
+
export declare const html5Email: RegExp;
|
| 24 |
+
/** The classic emailregex.com regex for RFC 5322-compliant emails */
|
| 25 |
+
export declare const rfc5322Email: RegExp;
|
| 26 |
+
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
| 27 |
+
export declare const unicodeEmail: RegExp;
|
| 28 |
+
export declare const browserEmail: RegExp;
|
| 29 |
+
export declare const _emoji = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
| 30 |
+
export declare function emoji(): RegExp;
|
| 31 |
+
export declare const ipv4: RegExp;
|
| 32 |
+
export declare const ipv6: RegExp;
|
| 33 |
+
export declare const cidrv4: RegExp;
|
| 34 |
+
export declare const cidrv6: RegExp;
|
| 35 |
+
export declare const base64: RegExp;
|
| 36 |
+
export declare const base64url: RegExp;
|
| 37 |
+
export declare const hostname: RegExp;
|
| 38 |
+
export declare const domain: RegExp;
|
| 39 |
+
export declare const e164: RegExp;
|
| 40 |
+
export declare const date: RegExp;
|
| 41 |
+
export declare function time(args: {
|
| 42 |
+
precision?: number | null;
|
| 43 |
+
}): RegExp;
|
| 44 |
+
export declare function datetime(args: {
|
| 45 |
+
precision?: number | null;
|
| 46 |
+
offset?: boolean;
|
| 47 |
+
local?: boolean;
|
| 48 |
+
}): RegExp;
|
| 49 |
+
export declare const string: (params?: {
|
| 50 |
+
minimum?: number | undefined;
|
| 51 |
+
maximum?: number | undefined;
|
| 52 |
+
}) => RegExp;
|
| 53 |
+
export declare const bigint: RegExp;
|
| 54 |
+
export declare const integer: RegExp;
|
| 55 |
+
export declare const number: RegExp;
|
| 56 |
+
export declare const boolean: RegExp;
|
| 57 |
+
declare const _null: RegExp;
|
| 58 |
+
export { _null as null };
|
| 59 |
+
declare const _undefined: RegExp;
|
| 60 |
+
export { _undefined as undefined };
|
| 61 |
+
export declare const lowercase: RegExp;
|
| 62 |
+
export declare const uppercase: RegExp;
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/regexes.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export declare const cuid: RegExp;
|
| 2 |
+
export declare const cuid2: RegExp;
|
| 3 |
+
export declare const ulid: RegExp;
|
| 4 |
+
export declare const xid: RegExp;
|
| 5 |
+
export declare const ksuid: RegExp;
|
| 6 |
+
export declare const nanoid: RegExp;
|
| 7 |
+
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
| 8 |
+
export declare const duration: RegExp;
|
| 9 |
+
/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
|
| 10 |
+
export declare const extendedDuration: RegExp;
|
| 11 |
+
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
| 12 |
+
export declare const guid: RegExp;
|
| 13 |
+
/** Returns a regex for validating an RFC 4122 UUID.
|
| 14 |
+
*
|
| 15 |
+
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
| 16 |
+
export declare const uuid: (version?: number | undefined) => RegExp;
|
| 17 |
+
export declare const uuid4: RegExp;
|
| 18 |
+
export declare const uuid6: RegExp;
|
| 19 |
+
export declare const uuid7: RegExp;
|
| 20 |
+
/** Practical email validation */
|
| 21 |
+
export declare const email: RegExp;
|
| 22 |
+
/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
|
| 23 |
+
export declare const html5Email: RegExp;
|
| 24 |
+
/** The classic emailregex.com regex for RFC 5322-compliant emails */
|
| 25 |
+
export declare const rfc5322Email: RegExp;
|
| 26 |
+
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
| 27 |
+
export declare const unicodeEmail: RegExp;
|
| 28 |
+
export declare const browserEmail: RegExp;
|
| 29 |
+
export declare const _emoji = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
| 30 |
+
export declare function emoji(): RegExp;
|
| 31 |
+
export declare const ipv4: RegExp;
|
| 32 |
+
export declare const ipv6: RegExp;
|
| 33 |
+
export declare const cidrv4: RegExp;
|
| 34 |
+
export declare const cidrv6: RegExp;
|
| 35 |
+
export declare const base64: RegExp;
|
| 36 |
+
export declare const base64url: RegExp;
|
| 37 |
+
export declare const hostname: RegExp;
|
| 38 |
+
export declare const domain: RegExp;
|
| 39 |
+
export declare const e164: RegExp;
|
| 40 |
+
export declare const date: RegExp;
|
| 41 |
+
export declare function time(args: {
|
| 42 |
+
precision?: number | null;
|
| 43 |
+
}): RegExp;
|
| 44 |
+
export declare function datetime(args: {
|
| 45 |
+
precision?: number | null;
|
| 46 |
+
offset?: boolean;
|
| 47 |
+
local?: boolean;
|
| 48 |
+
}): RegExp;
|
| 49 |
+
export declare const string: (params?: {
|
| 50 |
+
minimum?: number | undefined;
|
| 51 |
+
maximum?: number | undefined;
|
| 52 |
+
}) => RegExp;
|
| 53 |
+
export declare const bigint: RegExp;
|
| 54 |
+
export declare const integer: RegExp;
|
| 55 |
+
export declare const number: RegExp;
|
| 56 |
+
export declare const boolean: RegExp;
|
| 57 |
+
declare const _null: RegExp;
|
| 58 |
+
export { _null as null };
|
| 59 |
+
declare const _undefined: RegExp;
|
| 60 |
+
export { _undefined as undefined };
|
| 61 |
+
export declare const lowercase: RegExp;
|
| 62 |
+
export declare const uppercase: RegExp;
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/regexes.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export const cuid = /^[cC][^\s-]{8,}$/;
|
| 2 |
+
export const cuid2 = /^[0-9a-z]+$/;
|
| 3 |
+
export const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
| 4 |
+
export const xid = /^[0-9a-vA-V]{20}$/;
|
| 5 |
+
export const ksuid = /^[A-Za-z0-9]{27}$/;
|
| 6 |
+
export const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
| 7 |
+
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
| 8 |
+
export const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
| 9 |
+
/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
|
| 10 |
+
export const extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
| 11 |
+
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
| 12 |
+
export const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
| 13 |
+
/** Returns a regex for validating an RFC 4122 UUID.
|
| 14 |
+
*
|
| 15 |
+
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
| 16 |
+
export const uuid = (version) => {
|
| 17 |
+
if (!version)
|
| 18 |
+
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)$/;
|
| 19 |
+
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})$`);
|
| 20 |
+
};
|
| 21 |
+
export const uuid4 = /*@__PURE__*/ uuid(4);
|
| 22 |
+
export const uuid6 = /*@__PURE__*/ uuid(6);
|
| 23 |
+
export const uuid7 = /*@__PURE__*/ uuid(7);
|
| 24 |
+
/** Practical email validation */
|
| 25 |
+
export const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
| 26 |
+
/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
|
| 27 |
+
export const html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
| 28 |
+
/** The classic emailregex.com regex for RFC 5322-compliant emails */
|
| 29 |
+
export 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,}))$/;
|
| 30 |
+
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
| 31 |
+
export const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
| 32 |
+
export 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])?)*$/;
|
| 33 |
+
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
| 34 |
+
export const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
| 35 |
+
export function emoji() {
|
| 36 |
+
return new RegExp(_emoji, "u");
|
| 37 |
+
}
|
| 38 |
+
export 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])$/;
|
| 39 |
+
export const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/;
|
| 40 |
+
export 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])$/;
|
| 41 |
+
export const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
| 42 |
+
// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
|
| 43 |
+
export const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
| 44 |
+
export const base64url = /^[A-Za-z0-9_-]*$/;
|
| 45 |
+
// based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
|
| 46 |
+
// export const hostname: RegExp =
|
| 47 |
+
// /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)+([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/;
|
| 48 |
+
export const hostname = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
| 49 |
+
export const domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
| 50 |
+
// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
|
| 51 |
+
export const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
| 52 |
+
// const dateSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
| 53 |
+
const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
| 54 |
+
export const date = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
|
| 55 |
+
function timeSource(args) {
|
| 56 |
+
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
| 57 |
+
const regex = typeof args.precision === "number"
|
| 58 |
+
? args.precision === -1
|
| 59 |
+
? `${hhmm}`
|
| 60 |
+
: args.precision === 0
|
| 61 |
+
? `${hhmm}:[0-5]\\d`
|
| 62 |
+
: `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}`
|
| 63 |
+
: `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
| 64 |
+
return regex;
|
| 65 |
+
}
|
| 66 |
+
export function time(args) {
|
| 67 |
+
return new RegExp(`^${timeSource(args)}$`);
|
| 68 |
+
}
|
| 69 |
+
// Adapted from https://stackoverflow.com/a/3143231
|
| 70 |
+
export function datetime(args) {
|
| 71 |
+
const time = timeSource({ precision: args.precision });
|
| 72 |
+
const opts = ["Z"];
|
| 73 |
+
if (args.local)
|
| 74 |
+
opts.push("");
|
| 75 |
+
if (args.offset)
|
| 76 |
+
opts.push(`([+-]\\d{2}:\\d{2})`);
|
| 77 |
+
const timeRegex = `${time}(?:${opts.join("|")})`;
|
| 78 |
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
| 79 |
+
}
|
| 80 |
+
export const string = (params) => {
|
| 81 |
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
| 82 |
+
return new RegExp(`^${regex}$`);
|
| 83 |
+
};
|
| 84 |
+
export const bigint = /^\d+n?$/;
|
| 85 |
+
export const integer = /^\d+$/;
|
| 86 |
+
export const number = /^-?\d+(?:\.\d+)?/i;
|
| 87 |
+
export const boolean = /true|false/i;
|
| 88 |
+
const _null = /null/i;
|
| 89 |
+
export { _null as null };
|
| 90 |
+
const _undefined = /undefined/i;
|
| 91 |
+
export { _undefined as undefined };
|
| 92 |
+
// regex for string with no uppercase letters
|
| 93 |
+
export const lowercase = /^[^A-Z]*$/;
|
| 94 |
+
// regex for string with no lowercase letters
|
| 95 |
+
export const uppercase = /^[^a-z]*$/;
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/registries.cjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.globalRegistry = exports.$ZodRegistry = exports.$input = exports.$output = void 0;
|
| 4 |
+
exports.registry = registry;
|
| 5 |
+
exports.$output = Symbol("ZodOutput");
|
| 6 |
+
exports.$input = Symbol("ZodInput");
|
| 7 |
+
class $ZodRegistry {
|
| 8 |
+
constructor() {
|
| 9 |
+
this._map = new Map();
|
| 10 |
+
this._idmap = new Map();
|
| 11 |
+
}
|
| 12 |
+
add(schema, ..._meta) {
|
| 13 |
+
const meta = _meta[0];
|
| 14 |
+
this._map.set(schema, meta);
|
| 15 |
+
if (meta && typeof meta === "object" && "id" in meta) {
|
| 16 |
+
if (this._idmap.has(meta.id)) {
|
| 17 |
+
throw new Error(`ID ${meta.id} already exists in the registry`);
|
| 18 |
+
}
|
| 19 |
+
this._idmap.set(meta.id, schema);
|
| 20 |
+
}
|
| 21 |
+
return this;
|
| 22 |
+
}
|
| 23 |
+
clear() {
|
| 24 |
+
this._map = new Map();
|
| 25 |
+
this._idmap = new Map();
|
| 26 |
+
return this;
|
| 27 |
+
}
|
| 28 |
+
remove(schema) {
|
| 29 |
+
const meta = this._map.get(schema);
|
| 30 |
+
if (meta && typeof meta === "object" && "id" in meta) {
|
| 31 |
+
this._idmap.delete(meta.id);
|
| 32 |
+
}
|
| 33 |
+
this._map.delete(schema);
|
| 34 |
+
return this;
|
| 35 |
+
}
|
| 36 |
+
get(schema) {
|
| 37 |
+
// return this._map.get(schema) as any;
|
| 38 |
+
// inherit metadata
|
| 39 |
+
const p = schema._zod.parent;
|
| 40 |
+
if (p) {
|
| 41 |
+
const pm = { ...(this.get(p) ?? {}) };
|
| 42 |
+
delete pm.id; // do not inherit id
|
| 43 |
+
return { ...pm, ...this._map.get(schema) };
|
| 44 |
+
}
|
| 45 |
+
return this._map.get(schema);
|
| 46 |
+
}
|
| 47 |
+
has(schema) {
|
| 48 |
+
return this._map.has(schema);
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
exports.$ZodRegistry = $ZodRegistry;
|
| 52 |
+
// registries
|
| 53 |
+
function registry() {
|
| 54 |
+
return new $ZodRegistry();
|
| 55 |
+
}
|
| 56 |
+
exports.globalRegistry = registry();
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/registries.d.cts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as core from "./core.cjs";
|
| 2 |
+
import type { $ZodType } from "./schemas.cjs";
|
| 3 |
+
export declare const $output: unique symbol;
|
| 4 |
+
export type $output = typeof $output;
|
| 5 |
+
export declare const $input: unique symbol;
|
| 6 |
+
export type $input = typeof $input;
|
| 7 |
+
export type $replace<Meta, S extends $ZodType> = Meta extends $output ? core.output<S> : Meta extends $input ? core.input<S> : Meta extends (infer M)[] ? $replace<M, S>[] : Meta extends (...args: infer P) => infer R ? (...args: {
|
| 8 |
+
[K in keyof P]: $replace<P[K], S>;
|
| 9 |
+
}) => $replace<R, S> : Meta extends object ? {
|
| 10 |
+
[K in keyof Meta]: $replace<Meta[K], S>;
|
| 11 |
+
} : Meta;
|
| 12 |
+
type MetadataType = Record<string, unknown> | undefined;
|
| 13 |
+
export declare class $ZodRegistry<Meta extends MetadataType = MetadataType, Schema extends $ZodType = $ZodType> {
|
| 14 |
+
_meta: Meta;
|
| 15 |
+
_schema: Schema;
|
| 16 |
+
_map: Map<Schema, $replace<Meta, Schema>>;
|
| 17 |
+
_idmap: Map<string, Schema>;
|
| 18 |
+
add<S extends Schema>(schema: S, ..._meta: undefined extends Meta ? [$replace<Meta, S>?] : [$replace<Meta, S>]): this;
|
| 19 |
+
clear(): this;
|
| 20 |
+
remove(schema: Schema): this;
|
| 21 |
+
get<S extends Schema>(schema: S): $replace<Meta, S> | undefined;
|
| 22 |
+
has(schema: Schema): boolean;
|
| 23 |
+
}
|
| 24 |
+
export interface JSONSchemaMeta {
|
| 25 |
+
id?: string | undefined;
|
| 26 |
+
title?: string | undefined;
|
| 27 |
+
description?: string | undefined;
|
| 28 |
+
deprecated?: boolean | undefined;
|
| 29 |
+
[k: string]: unknown;
|
| 30 |
+
}
|
| 31 |
+
export interface GlobalMeta extends JSONSchemaMeta {
|
| 32 |
+
}
|
| 33 |
+
export declare function registry<T extends MetadataType = MetadataType, S extends $ZodType = $ZodType>(): $ZodRegistry<T, S>;
|
| 34 |
+
export declare const globalRegistry: $ZodRegistry<GlobalMeta>;
|
| 35 |
+
export {};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/registries.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as core from "./core.js";
|
| 2 |
+
import type { $ZodType } from "./schemas.js";
|
| 3 |
+
export declare const $output: unique symbol;
|
| 4 |
+
export type $output = typeof $output;
|
| 5 |
+
export declare const $input: unique symbol;
|
| 6 |
+
export type $input = typeof $input;
|
| 7 |
+
export type $replace<Meta, S extends $ZodType> = Meta extends $output ? core.output<S> : Meta extends $input ? core.input<S> : Meta extends (infer M)[] ? $replace<M, S>[] : Meta extends (...args: infer P) => infer R ? (...args: {
|
| 8 |
+
[K in keyof P]: $replace<P[K], S>;
|
| 9 |
+
}) => $replace<R, S> : Meta extends object ? {
|
| 10 |
+
[K in keyof Meta]: $replace<Meta[K], S>;
|
| 11 |
+
} : Meta;
|
| 12 |
+
type MetadataType = Record<string, unknown> | undefined;
|
| 13 |
+
export declare class $ZodRegistry<Meta extends MetadataType = MetadataType, Schema extends $ZodType = $ZodType> {
|
| 14 |
+
_meta: Meta;
|
| 15 |
+
_schema: Schema;
|
| 16 |
+
_map: Map<Schema, $replace<Meta, Schema>>;
|
| 17 |
+
_idmap: Map<string, Schema>;
|
| 18 |
+
add<S extends Schema>(schema: S, ..._meta: undefined extends Meta ? [$replace<Meta, S>?] : [$replace<Meta, S>]): this;
|
| 19 |
+
clear(): this;
|
| 20 |
+
remove(schema: Schema): this;
|
| 21 |
+
get<S extends Schema>(schema: S): $replace<Meta, S> | undefined;
|
| 22 |
+
has(schema: Schema): boolean;
|
| 23 |
+
}
|
| 24 |
+
export interface JSONSchemaMeta {
|
| 25 |
+
id?: string | undefined;
|
| 26 |
+
title?: string | undefined;
|
| 27 |
+
description?: string | undefined;
|
| 28 |
+
deprecated?: boolean | undefined;
|
| 29 |
+
[k: string]: unknown;
|
| 30 |
+
}
|
| 31 |
+
export interface GlobalMeta extends JSONSchemaMeta {
|
| 32 |
+
}
|
| 33 |
+
export declare function registry<T extends MetadataType = MetadataType, S extends $ZodType = $ZodType>(): $ZodRegistry<T, S>;
|
| 34 |
+
export declare const globalRegistry: $ZodRegistry<GlobalMeta>;
|
| 35 |
+
export {};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/registries.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export const $output = Symbol("ZodOutput");
|
| 2 |
+
export const $input = Symbol("ZodInput");
|
| 3 |
+
export class $ZodRegistry {
|
| 4 |
+
constructor() {
|
| 5 |
+
this._map = new Map();
|
| 6 |
+
this._idmap = new Map();
|
| 7 |
+
}
|
| 8 |
+
add(schema, ..._meta) {
|
| 9 |
+
const meta = _meta[0];
|
| 10 |
+
this._map.set(schema, meta);
|
| 11 |
+
if (meta && typeof meta === "object" && "id" in meta) {
|
| 12 |
+
if (this._idmap.has(meta.id)) {
|
| 13 |
+
throw new Error(`ID ${meta.id} already exists in the registry`);
|
| 14 |
+
}
|
| 15 |
+
this._idmap.set(meta.id, schema);
|
| 16 |
+
}
|
| 17 |
+
return this;
|
| 18 |
+
}
|
| 19 |
+
clear() {
|
| 20 |
+
this._map = new Map();
|
| 21 |
+
this._idmap = new Map();
|
| 22 |
+
return this;
|
| 23 |
+
}
|
| 24 |
+
remove(schema) {
|
| 25 |
+
const meta = this._map.get(schema);
|
| 26 |
+
if (meta && typeof meta === "object" && "id" in meta) {
|
| 27 |
+
this._idmap.delete(meta.id);
|
| 28 |
+
}
|
| 29 |
+
this._map.delete(schema);
|
| 30 |
+
return this;
|
| 31 |
+
}
|
| 32 |
+
get(schema) {
|
| 33 |
+
// return this._map.get(schema) as any;
|
| 34 |
+
// inherit metadata
|
| 35 |
+
const p = schema._zod.parent;
|
| 36 |
+
if (p) {
|
| 37 |
+
const pm = { ...(this.get(p) ?? {}) };
|
| 38 |
+
delete pm.id; // do not inherit id
|
| 39 |
+
return { ...pm, ...this._map.get(schema) };
|
| 40 |
+
}
|
| 41 |
+
return this._map.get(schema);
|
| 42 |
+
}
|
| 43 |
+
has(schema) {
|
| 44 |
+
return this._map.has(schema);
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
// registries
|
| 48 |
+
export function registry() {
|
| 49 |
+
return new $ZodRegistry();
|
| 50 |
+
}
|
| 51 |
+
export const globalRegistry = /*@__PURE__*/ registry();
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/schemas.cjs
ADDED
|
@@ -0,0 +1,1748 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 3 |
+
if (k2 === undefined) k2 = k;
|
| 4 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 5 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 6 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 7 |
+
}
|
| 8 |
+
Object.defineProperty(o, k2, desc);
|
| 9 |
+
}) : (function(o, m, k, k2) {
|
| 10 |
+
if (k2 === undefined) k2 = k;
|
| 11 |
+
o[k2] = m[k];
|
| 12 |
+
}));
|
| 13 |
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
| 14 |
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
| 15 |
+
}) : function(o, v) {
|
| 16 |
+
o["default"] = v;
|
| 17 |
+
});
|
| 18 |
+
var __importStar = (this && this.__importStar) || function (mod) {
|
| 19 |
+
if (mod && mod.__esModule) return mod;
|
| 20 |
+
var result = {};
|
| 21 |
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
| 22 |
+
__setModuleDefault(result, mod);
|
| 23 |
+
return result;
|
| 24 |
+
};
|
| 25 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 26 |
+
exports.$ZodSet = exports.$ZodMap = exports.$ZodRecord = exports.$ZodTuple = exports.$ZodIntersection = exports.$ZodDiscriminatedUnion = exports.$ZodUnion = exports.$ZodObject = exports.$ZodArray = exports.$ZodDate = exports.$ZodVoid = exports.$ZodNever = exports.$ZodUnknown = exports.$ZodAny = exports.$ZodNull = exports.$ZodUndefined = exports.$ZodSymbol = exports.$ZodBigIntFormat = exports.$ZodBigInt = exports.$ZodBoolean = exports.$ZodNumberFormat = exports.$ZodNumber = exports.$ZodCustomStringFormat = exports.$ZodJWT = exports.$ZodE164 = exports.$ZodBase64URL = exports.$ZodBase64 = exports.$ZodCIDRv6 = exports.$ZodCIDRv4 = exports.$ZodIPv6 = exports.$ZodIPv4 = exports.$ZodISODuration = exports.$ZodISOTime = exports.$ZodISODate = exports.$ZodISODateTime = exports.$ZodKSUID = exports.$ZodXID = exports.$ZodULID = exports.$ZodCUID2 = exports.$ZodCUID = exports.$ZodNanoID = exports.$ZodEmoji = exports.$ZodURL = exports.$ZodEmail = exports.$ZodUUID = exports.$ZodGUID = exports.$ZodStringFormat = exports.$ZodString = exports.clone = exports.$ZodType = void 0;
|
| 27 |
+
exports.$ZodCustom = exports.$ZodLazy = exports.$ZodPromise = exports.$ZodTemplateLiteral = exports.$ZodReadonly = exports.$ZodPipe = exports.$ZodNaN = exports.$ZodCatch = exports.$ZodSuccess = exports.$ZodNonOptional = exports.$ZodPrefault = exports.$ZodDefault = exports.$ZodNullable = exports.$ZodOptional = exports.$ZodTransform = exports.$ZodFile = exports.$ZodLiteral = exports.$ZodEnum = void 0;
|
| 28 |
+
exports.isValidBase64 = isValidBase64;
|
| 29 |
+
exports.isValidBase64URL = isValidBase64URL;
|
| 30 |
+
exports.isValidJWT = isValidJWT;
|
| 31 |
+
const checks = __importStar(require("./checks.cjs"));
|
| 32 |
+
const core = __importStar(require("./core.cjs"));
|
| 33 |
+
const doc_js_1 = require("./doc.cjs");
|
| 34 |
+
const parse_js_1 = require("./parse.cjs");
|
| 35 |
+
const regexes = __importStar(require("./regexes.cjs"));
|
| 36 |
+
const util = __importStar(require("./util.cjs"));
|
| 37 |
+
const versions_js_1 = require("./versions.cjs");
|
| 38 |
+
exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
|
| 39 |
+
var _a;
|
| 40 |
+
inst ?? (inst = {});
|
| 41 |
+
inst._zod.def = def; // set _def property
|
| 42 |
+
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
| 43 |
+
inst._zod.version = versions_js_1.version;
|
| 44 |
+
const checks = [...(inst._zod.def.checks ?? [])];
|
| 45 |
+
// if inst is itself a checks.$ZodCheck, run it as a check
|
| 46 |
+
if (inst._zod.traits.has("$ZodCheck")) {
|
| 47 |
+
checks.unshift(inst);
|
| 48 |
+
}
|
| 49 |
+
//
|
| 50 |
+
for (const ch of checks) {
|
| 51 |
+
for (const fn of ch._zod.onattach) {
|
| 52 |
+
fn(inst);
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
if (checks.length === 0) {
|
| 56 |
+
// deferred initializer
|
| 57 |
+
// inst._zod.parse is not yet defined
|
| 58 |
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
| 59 |
+
inst._zod.deferred?.push(() => {
|
| 60 |
+
inst._zod.run = inst._zod.parse;
|
| 61 |
+
});
|
| 62 |
+
}
|
| 63 |
+
else {
|
| 64 |
+
const runChecks = (payload, checks, ctx) => {
|
| 65 |
+
let isAborted = util.aborted(payload);
|
| 66 |
+
let asyncResult;
|
| 67 |
+
for (const ch of checks) {
|
| 68 |
+
if (ch._zod.def.when) {
|
| 69 |
+
const shouldRun = ch._zod.def.when(payload);
|
| 70 |
+
if (!shouldRun)
|
| 71 |
+
continue;
|
| 72 |
+
}
|
| 73 |
+
else if (isAborted) {
|
| 74 |
+
continue;
|
| 75 |
+
}
|
| 76 |
+
const currLen = payload.issues.length;
|
| 77 |
+
const _ = ch._zod.check(payload);
|
| 78 |
+
if (_ instanceof Promise && ctx?.async === false) {
|
| 79 |
+
throw new core.$ZodAsyncError();
|
| 80 |
+
}
|
| 81 |
+
if (asyncResult || _ instanceof Promise) {
|
| 82 |
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
| 83 |
+
await _;
|
| 84 |
+
const nextLen = payload.issues.length;
|
| 85 |
+
if (nextLen === currLen)
|
| 86 |
+
return;
|
| 87 |
+
if (!isAborted)
|
| 88 |
+
isAborted = util.aborted(payload, currLen);
|
| 89 |
+
});
|
| 90 |
+
}
|
| 91 |
+
else {
|
| 92 |
+
const nextLen = payload.issues.length;
|
| 93 |
+
if (nextLen === currLen)
|
| 94 |
+
continue;
|
| 95 |
+
if (!isAborted)
|
| 96 |
+
isAborted = util.aborted(payload, currLen);
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
if (asyncResult) {
|
| 100 |
+
return asyncResult.then(() => {
|
| 101 |
+
return payload;
|
| 102 |
+
});
|
| 103 |
+
}
|
| 104 |
+
return payload;
|
| 105 |
+
};
|
| 106 |
+
inst._zod.run = (payload, ctx) => {
|
| 107 |
+
const result = inst._zod.parse(payload, ctx);
|
| 108 |
+
if (result instanceof Promise) {
|
| 109 |
+
if (ctx.async === false)
|
| 110 |
+
throw new core.$ZodAsyncError();
|
| 111 |
+
return result.then((result) => runChecks(result, checks, ctx));
|
| 112 |
+
}
|
| 113 |
+
return runChecks(result, checks, ctx);
|
| 114 |
+
};
|
| 115 |
+
}
|
| 116 |
+
inst["~standard"] = {
|
| 117 |
+
validate: (value) => {
|
| 118 |
+
try {
|
| 119 |
+
const r = (0, parse_js_1.safeParse)(inst, value);
|
| 120 |
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
| 121 |
+
}
|
| 122 |
+
catch (_) {
|
| 123 |
+
return (0, parse_js_1.safeParseAsync)(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
|
| 124 |
+
}
|
| 125 |
+
},
|
| 126 |
+
vendor: "zod",
|
| 127 |
+
version: 1,
|
| 128 |
+
};
|
| 129 |
+
});
|
| 130 |
+
var util_js_1 = require("./util.cjs");
|
| 131 |
+
Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return util_js_1.clone; } });
|
| 132 |
+
exports.$ZodString = core.$constructor("$ZodString", (inst, def) => {
|
| 133 |
+
exports.$ZodType.init(inst, def);
|
| 134 |
+
inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? regexes.string(inst._zod.bag);
|
| 135 |
+
inst._zod.parse = (payload, _) => {
|
| 136 |
+
if (def.coerce)
|
| 137 |
+
try {
|
| 138 |
+
payload.value = String(payload.value);
|
| 139 |
+
}
|
| 140 |
+
catch (_) { }
|
| 141 |
+
if (typeof payload.value === "string")
|
| 142 |
+
return payload;
|
| 143 |
+
payload.issues.push({
|
| 144 |
+
expected: "string",
|
| 145 |
+
code: "invalid_type",
|
| 146 |
+
input: payload.value,
|
| 147 |
+
inst,
|
| 148 |
+
});
|
| 149 |
+
return payload;
|
| 150 |
+
};
|
| 151 |
+
});
|
| 152 |
+
exports.$ZodStringFormat = core.$constructor("$ZodStringFormat", (inst, def) => {
|
| 153 |
+
// check initialization must come first
|
| 154 |
+
checks.$ZodCheckStringFormat.init(inst, def);
|
| 155 |
+
exports.$ZodString.init(inst, def);
|
| 156 |
+
});
|
| 157 |
+
exports.$ZodGUID = core.$constructor("$ZodGUID", (inst, def) => {
|
| 158 |
+
def.pattern ?? (def.pattern = regexes.guid);
|
| 159 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 160 |
+
});
|
| 161 |
+
exports.$ZodUUID = core.$constructor("$ZodUUID", (inst, def) => {
|
| 162 |
+
if (def.version) {
|
| 163 |
+
const versionMap = {
|
| 164 |
+
v1: 1,
|
| 165 |
+
v2: 2,
|
| 166 |
+
v3: 3,
|
| 167 |
+
v4: 4,
|
| 168 |
+
v5: 5,
|
| 169 |
+
v6: 6,
|
| 170 |
+
v7: 7,
|
| 171 |
+
v8: 8,
|
| 172 |
+
};
|
| 173 |
+
const v = versionMap[def.version];
|
| 174 |
+
if (v === undefined)
|
| 175 |
+
throw new Error(`Invalid UUID version: "${def.version}"`);
|
| 176 |
+
def.pattern ?? (def.pattern = regexes.uuid(v));
|
| 177 |
+
}
|
| 178 |
+
else
|
| 179 |
+
def.pattern ?? (def.pattern = regexes.uuid());
|
| 180 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 181 |
+
});
|
| 182 |
+
exports.$ZodEmail = core.$constructor("$ZodEmail", (inst, def) => {
|
| 183 |
+
def.pattern ?? (def.pattern = regexes.email);
|
| 184 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 185 |
+
});
|
| 186 |
+
exports.$ZodURL = core.$constructor("$ZodURL", (inst, def) => {
|
| 187 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 188 |
+
inst._zod.check = (payload) => {
|
| 189 |
+
try {
|
| 190 |
+
const orig = payload.value;
|
| 191 |
+
const url = new URL(orig);
|
| 192 |
+
const href = url.href;
|
| 193 |
+
if (def.hostname) {
|
| 194 |
+
def.hostname.lastIndex = 0;
|
| 195 |
+
if (!def.hostname.test(url.hostname)) {
|
| 196 |
+
payload.issues.push({
|
| 197 |
+
code: "invalid_format",
|
| 198 |
+
format: "url",
|
| 199 |
+
note: "Invalid hostname",
|
| 200 |
+
pattern: regexes.hostname.source,
|
| 201 |
+
input: payload.value,
|
| 202 |
+
inst,
|
| 203 |
+
continue: !def.abort,
|
| 204 |
+
});
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
if (def.protocol) {
|
| 208 |
+
def.protocol.lastIndex = 0;
|
| 209 |
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
|
| 210 |
+
payload.issues.push({
|
| 211 |
+
code: "invalid_format",
|
| 212 |
+
format: "url",
|
| 213 |
+
note: "Invalid protocol",
|
| 214 |
+
pattern: def.protocol.source,
|
| 215 |
+
input: payload.value,
|
| 216 |
+
inst,
|
| 217 |
+
continue: !def.abort,
|
| 218 |
+
});
|
| 219 |
+
}
|
| 220 |
+
}
|
| 221 |
+
// payload.value = url.href;
|
| 222 |
+
if (!orig.endsWith("/") && href.endsWith("/")) {
|
| 223 |
+
payload.value = href.slice(0, -1);
|
| 224 |
+
}
|
| 225 |
+
else {
|
| 226 |
+
payload.value = href;
|
| 227 |
+
}
|
| 228 |
+
return;
|
| 229 |
+
}
|
| 230 |
+
catch (_) {
|
| 231 |
+
payload.issues.push({
|
| 232 |
+
code: "invalid_format",
|
| 233 |
+
format: "url",
|
| 234 |
+
input: payload.value,
|
| 235 |
+
inst,
|
| 236 |
+
continue: !def.abort,
|
| 237 |
+
});
|
| 238 |
+
}
|
| 239 |
+
};
|
| 240 |
+
});
|
| 241 |
+
exports.$ZodEmoji = core.$constructor("$ZodEmoji", (inst, def) => {
|
| 242 |
+
def.pattern ?? (def.pattern = regexes.emoji());
|
| 243 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 244 |
+
});
|
| 245 |
+
exports.$ZodNanoID = core.$constructor("$ZodNanoID", (inst, def) => {
|
| 246 |
+
def.pattern ?? (def.pattern = regexes.nanoid);
|
| 247 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 248 |
+
});
|
| 249 |
+
exports.$ZodCUID = core.$constructor("$ZodCUID", (inst, def) => {
|
| 250 |
+
def.pattern ?? (def.pattern = regexes.cuid);
|
| 251 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 252 |
+
});
|
| 253 |
+
exports.$ZodCUID2 = core.$constructor("$ZodCUID2", (inst, def) => {
|
| 254 |
+
def.pattern ?? (def.pattern = regexes.cuid2);
|
| 255 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 256 |
+
});
|
| 257 |
+
exports.$ZodULID = core.$constructor("$ZodULID", (inst, def) => {
|
| 258 |
+
def.pattern ?? (def.pattern = regexes.ulid);
|
| 259 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 260 |
+
});
|
| 261 |
+
exports.$ZodXID = core.$constructor("$ZodXID", (inst, def) => {
|
| 262 |
+
def.pattern ?? (def.pattern = regexes.xid);
|
| 263 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 264 |
+
});
|
| 265 |
+
exports.$ZodKSUID = core.$constructor("$ZodKSUID", (inst, def) => {
|
| 266 |
+
def.pattern ?? (def.pattern = regexes.ksuid);
|
| 267 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 268 |
+
});
|
| 269 |
+
exports.$ZodISODateTime = core.$constructor("$ZodISODateTime", (inst, def) => {
|
| 270 |
+
def.pattern ?? (def.pattern = regexes.datetime(def));
|
| 271 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 272 |
+
});
|
| 273 |
+
exports.$ZodISODate = core.$constructor("$ZodISODate", (inst, def) => {
|
| 274 |
+
def.pattern ?? (def.pattern = regexes.date);
|
| 275 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 276 |
+
});
|
| 277 |
+
exports.$ZodISOTime = core.$constructor("$ZodISOTime", (inst, def) => {
|
| 278 |
+
def.pattern ?? (def.pattern = regexes.time(def));
|
| 279 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 280 |
+
});
|
| 281 |
+
exports.$ZodISODuration = core.$constructor("$ZodISODuration", (inst, def) => {
|
| 282 |
+
def.pattern ?? (def.pattern = regexes.duration);
|
| 283 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 284 |
+
});
|
| 285 |
+
exports.$ZodIPv4 = core.$constructor("$ZodIPv4", (inst, def) => {
|
| 286 |
+
def.pattern ?? (def.pattern = regexes.ipv4);
|
| 287 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 288 |
+
inst._zod.onattach.push((inst) => {
|
| 289 |
+
const bag = inst._zod.bag;
|
| 290 |
+
bag.format = `ipv4`;
|
| 291 |
+
});
|
| 292 |
+
});
|
| 293 |
+
exports.$ZodIPv6 = core.$constructor("$ZodIPv6", (inst, def) => {
|
| 294 |
+
def.pattern ?? (def.pattern = regexes.ipv6);
|
| 295 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 296 |
+
inst._zod.onattach.push((inst) => {
|
| 297 |
+
const bag = inst._zod.bag;
|
| 298 |
+
bag.format = `ipv6`;
|
| 299 |
+
});
|
| 300 |
+
inst._zod.check = (payload) => {
|
| 301 |
+
try {
|
| 302 |
+
new URL(`http://[${payload.value}]`);
|
| 303 |
+
// return;
|
| 304 |
+
}
|
| 305 |
+
catch {
|
| 306 |
+
payload.issues.push({
|
| 307 |
+
code: "invalid_format",
|
| 308 |
+
format: "ipv6",
|
| 309 |
+
input: payload.value,
|
| 310 |
+
inst,
|
| 311 |
+
continue: !def.abort,
|
| 312 |
+
});
|
| 313 |
+
}
|
| 314 |
+
};
|
| 315 |
+
});
|
| 316 |
+
exports.$ZodCIDRv4 = core.$constructor("$ZodCIDRv4", (inst, def) => {
|
| 317 |
+
def.pattern ?? (def.pattern = regexes.cidrv4);
|
| 318 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 319 |
+
});
|
| 320 |
+
exports.$ZodCIDRv6 = core.$constructor("$ZodCIDRv6", (inst, def) => {
|
| 321 |
+
def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
|
| 322 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 323 |
+
inst._zod.check = (payload) => {
|
| 324 |
+
const [address, prefix] = payload.value.split("/");
|
| 325 |
+
try {
|
| 326 |
+
if (!prefix)
|
| 327 |
+
throw new Error();
|
| 328 |
+
const prefixNum = Number(prefix);
|
| 329 |
+
if (`${prefixNum}` !== prefix)
|
| 330 |
+
throw new Error();
|
| 331 |
+
if (prefixNum < 0 || prefixNum > 128)
|
| 332 |
+
throw new Error();
|
| 333 |
+
new URL(`http://[${address}]`);
|
| 334 |
+
}
|
| 335 |
+
catch {
|
| 336 |
+
payload.issues.push({
|
| 337 |
+
code: "invalid_format",
|
| 338 |
+
format: "cidrv6",
|
| 339 |
+
input: payload.value,
|
| 340 |
+
inst,
|
| 341 |
+
continue: !def.abort,
|
| 342 |
+
});
|
| 343 |
+
}
|
| 344 |
+
};
|
| 345 |
+
});
|
| 346 |
+
////////////////////////////// ZodBase64 //////////////////////////////
|
| 347 |
+
function isValidBase64(data) {
|
| 348 |
+
if (data === "")
|
| 349 |
+
return true;
|
| 350 |
+
if (data.length % 4 !== 0)
|
| 351 |
+
return false;
|
| 352 |
+
try {
|
| 353 |
+
atob(data);
|
| 354 |
+
return true;
|
| 355 |
+
}
|
| 356 |
+
catch {
|
| 357 |
+
return false;
|
| 358 |
+
}
|
| 359 |
+
}
|
| 360 |
+
exports.$ZodBase64 = core.$constructor("$ZodBase64", (inst, def) => {
|
| 361 |
+
def.pattern ?? (def.pattern = regexes.base64);
|
| 362 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 363 |
+
inst._zod.onattach.push((inst) => {
|
| 364 |
+
inst._zod.bag.contentEncoding = "base64";
|
| 365 |
+
});
|
| 366 |
+
inst._zod.check = (payload) => {
|
| 367 |
+
if (isValidBase64(payload.value))
|
| 368 |
+
return;
|
| 369 |
+
payload.issues.push({
|
| 370 |
+
code: "invalid_format",
|
| 371 |
+
format: "base64",
|
| 372 |
+
input: payload.value,
|
| 373 |
+
inst,
|
| 374 |
+
continue: !def.abort,
|
| 375 |
+
});
|
| 376 |
+
};
|
| 377 |
+
});
|
| 378 |
+
////////////////////////////// ZodBase64 //////////////////////////////
|
| 379 |
+
function isValidBase64URL(data) {
|
| 380 |
+
if (!regexes.base64url.test(data))
|
| 381 |
+
return false;
|
| 382 |
+
const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
|
| 383 |
+
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
| 384 |
+
return isValidBase64(padded);
|
| 385 |
+
}
|
| 386 |
+
exports.$ZodBase64URL = core.$constructor("$ZodBase64URL", (inst, def) => {
|
| 387 |
+
def.pattern ?? (def.pattern = regexes.base64url);
|
| 388 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 389 |
+
inst._zod.onattach.push((inst) => {
|
| 390 |
+
inst._zod.bag.contentEncoding = "base64url";
|
| 391 |
+
});
|
| 392 |
+
inst._zod.check = (payload) => {
|
| 393 |
+
if (isValidBase64URL(payload.value))
|
| 394 |
+
return;
|
| 395 |
+
payload.issues.push({
|
| 396 |
+
code: "invalid_format",
|
| 397 |
+
format: "base64url",
|
| 398 |
+
input: payload.value,
|
| 399 |
+
inst,
|
| 400 |
+
continue: !def.abort,
|
| 401 |
+
});
|
| 402 |
+
};
|
| 403 |
+
});
|
| 404 |
+
exports.$ZodE164 = core.$constructor("$ZodE164", (inst, def) => {
|
| 405 |
+
def.pattern ?? (def.pattern = regexes.e164);
|
| 406 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 407 |
+
});
|
| 408 |
+
////////////////////////////// ZodJWT //////////////////////////////
|
| 409 |
+
function isValidJWT(token, algorithm = null) {
|
| 410 |
+
try {
|
| 411 |
+
const tokensParts = token.split(".");
|
| 412 |
+
if (tokensParts.length !== 3)
|
| 413 |
+
return false;
|
| 414 |
+
const [header] = tokensParts;
|
| 415 |
+
if (!header)
|
| 416 |
+
return false;
|
| 417 |
+
const parsedHeader = JSON.parse(atob(header));
|
| 418 |
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
| 419 |
+
return false;
|
| 420 |
+
if (!parsedHeader.alg)
|
| 421 |
+
return false;
|
| 422 |
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
|
| 423 |
+
return false;
|
| 424 |
+
return true;
|
| 425 |
+
}
|
| 426 |
+
catch {
|
| 427 |
+
return false;
|
| 428 |
+
}
|
| 429 |
+
}
|
| 430 |
+
exports.$ZodJWT = core.$constructor("$ZodJWT", (inst, def) => {
|
| 431 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 432 |
+
inst._zod.check = (payload) => {
|
| 433 |
+
if (isValidJWT(payload.value, def.alg))
|
| 434 |
+
return;
|
| 435 |
+
payload.issues.push({
|
| 436 |
+
code: "invalid_format",
|
| 437 |
+
format: "jwt",
|
| 438 |
+
input: payload.value,
|
| 439 |
+
inst,
|
| 440 |
+
continue: !def.abort,
|
| 441 |
+
});
|
| 442 |
+
};
|
| 443 |
+
});
|
| 444 |
+
exports.$ZodCustomStringFormat = core.$constructor("$ZodCustomStringFormat", (inst, def) => {
|
| 445 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 446 |
+
inst._zod.check = (payload) => {
|
| 447 |
+
if (def.fn(payload.value))
|
| 448 |
+
return;
|
| 449 |
+
payload.issues.push({
|
| 450 |
+
code: "invalid_format",
|
| 451 |
+
format: def.format,
|
| 452 |
+
input: payload.value,
|
| 453 |
+
inst,
|
| 454 |
+
continue: !def.abort,
|
| 455 |
+
});
|
| 456 |
+
};
|
| 457 |
+
});
|
| 458 |
+
exports.$ZodNumber = core.$constructor("$ZodNumber", (inst, def) => {
|
| 459 |
+
exports.$ZodType.init(inst, def);
|
| 460 |
+
inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;
|
| 461 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 462 |
+
if (def.coerce)
|
| 463 |
+
try {
|
| 464 |
+
payload.value = Number(payload.value);
|
| 465 |
+
}
|
| 466 |
+
catch (_) { }
|
| 467 |
+
const input = payload.value;
|
| 468 |
+
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
|
| 469 |
+
return payload;
|
| 470 |
+
}
|
| 471 |
+
const received = typeof input === "number"
|
| 472 |
+
? Number.isNaN(input)
|
| 473 |
+
? "NaN"
|
| 474 |
+
: !Number.isFinite(input)
|
| 475 |
+
? "Infinity"
|
| 476 |
+
: undefined
|
| 477 |
+
: undefined;
|
| 478 |
+
payload.issues.push({
|
| 479 |
+
expected: "number",
|
| 480 |
+
code: "invalid_type",
|
| 481 |
+
input,
|
| 482 |
+
inst,
|
| 483 |
+
...(received ? { received } : {}),
|
| 484 |
+
});
|
| 485 |
+
return payload;
|
| 486 |
+
};
|
| 487 |
+
});
|
| 488 |
+
exports.$ZodNumberFormat = core.$constructor("$ZodNumber", (inst, def) => {
|
| 489 |
+
checks.$ZodCheckNumberFormat.init(inst, def);
|
| 490 |
+
exports.$ZodNumber.init(inst, def); // no format checksp
|
| 491 |
+
});
|
| 492 |
+
exports.$ZodBoolean = core.$constructor("$ZodBoolean", (inst, def) => {
|
| 493 |
+
exports.$ZodType.init(inst, def);
|
| 494 |
+
inst._zod.pattern = regexes.boolean;
|
| 495 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 496 |
+
if (def.coerce)
|
| 497 |
+
try {
|
| 498 |
+
payload.value = Boolean(payload.value);
|
| 499 |
+
}
|
| 500 |
+
catch (_) { }
|
| 501 |
+
const input = payload.value;
|
| 502 |
+
if (typeof input === "boolean")
|
| 503 |
+
return payload;
|
| 504 |
+
payload.issues.push({
|
| 505 |
+
expected: "boolean",
|
| 506 |
+
code: "invalid_type",
|
| 507 |
+
input,
|
| 508 |
+
inst,
|
| 509 |
+
});
|
| 510 |
+
return payload;
|
| 511 |
+
};
|
| 512 |
+
});
|
| 513 |
+
exports.$ZodBigInt = core.$constructor("$ZodBigInt", (inst, def) => {
|
| 514 |
+
exports.$ZodType.init(inst, def);
|
| 515 |
+
inst._zod.pattern = regexes.bigint;
|
| 516 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 517 |
+
if (def.coerce)
|
| 518 |
+
try {
|
| 519 |
+
payload.value = BigInt(payload.value);
|
| 520 |
+
}
|
| 521 |
+
catch (_) { }
|
| 522 |
+
if (typeof payload.value === "bigint")
|
| 523 |
+
return payload;
|
| 524 |
+
payload.issues.push({
|
| 525 |
+
expected: "bigint",
|
| 526 |
+
code: "invalid_type",
|
| 527 |
+
input: payload.value,
|
| 528 |
+
inst,
|
| 529 |
+
});
|
| 530 |
+
return payload;
|
| 531 |
+
};
|
| 532 |
+
});
|
| 533 |
+
exports.$ZodBigIntFormat = core.$constructor("$ZodBigInt", (inst, def) => {
|
| 534 |
+
checks.$ZodCheckBigIntFormat.init(inst, def);
|
| 535 |
+
exports.$ZodBigInt.init(inst, def); // no format checks
|
| 536 |
+
});
|
| 537 |
+
exports.$ZodSymbol = core.$constructor("$ZodSymbol", (inst, def) => {
|
| 538 |
+
exports.$ZodType.init(inst, def);
|
| 539 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 540 |
+
const input = payload.value;
|
| 541 |
+
if (typeof input === "symbol")
|
| 542 |
+
return payload;
|
| 543 |
+
payload.issues.push({
|
| 544 |
+
expected: "symbol",
|
| 545 |
+
code: "invalid_type",
|
| 546 |
+
input,
|
| 547 |
+
inst,
|
| 548 |
+
});
|
| 549 |
+
return payload;
|
| 550 |
+
};
|
| 551 |
+
});
|
| 552 |
+
exports.$ZodUndefined = core.$constructor("$ZodUndefined", (inst, def) => {
|
| 553 |
+
exports.$ZodType.init(inst, def);
|
| 554 |
+
inst._zod.pattern = regexes.undefined;
|
| 555 |
+
inst._zod.values = new Set([undefined]);
|
| 556 |
+
inst._zod.optin = "optional";
|
| 557 |
+
inst._zod.optout = "optional";
|
| 558 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 559 |
+
const input = payload.value;
|
| 560 |
+
if (typeof input === "undefined")
|
| 561 |
+
return payload;
|
| 562 |
+
payload.issues.push({
|
| 563 |
+
expected: "undefined",
|
| 564 |
+
code: "invalid_type",
|
| 565 |
+
input,
|
| 566 |
+
inst,
|
| 567 |
+
});
|
| 568 |
+
return payload;
|
| 569 |
+
};
|
| 570 |
+
});
|
| 571 |
+
exports.$ZodNull = core.$constructor("$ZodNull", (inst, def) => {
|
| 572 |
+
exports.$ZodType.init(inst, def);
|
| 573 |
+
inst._zod.pattern = regexes.null;
|
| 574 |
+
inst._zod.values = new Set([null]);
|
| 575 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 576 |
+
const input = payload.value;
|
| 577 |
+
if (input === null)
|
| 578 |
+
return payload;
|
| 579 |
+
payload.issues.push({
|
| 580 |
+
expected: "null",
|
| 581 |
+
code: "invalid_type",
|
| 582 |
+
input,
|
| 583 |
+
inst,
|
| 584 |
+
});
|
| 585 |
+
return payload;
|
| 586 |
+
};
|
| 587 |
+
});
|
| 588 |
+
exports.$ZodAny = core.$constructor("$ZodAny", (inst, def) => {
|
| 589 |
+
exports.$ZodType.init(inst, def);
|
| 590 |
+
inst._zod.parse = (payload) => payload;
|
| 591 |
+
});
|
| 592 |
+
exports.$ZodUnknown = core.$constructor("$ZodUnknown", (inst, def) => {
|
| 593 |
+
exports.$ZodType.init(inst, def);
|
| 594 |
+
inst._zod.parse = (payload) => payload;
|
| 595 |
+
});
|
| 596 |
+
exports.$ZodNever = core.$constructor("$ZodNever", (inst, def) => {
|
| 597 |
+
exports.$ZodType.init(inst, def);
|
| 598 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 599 |
+
payload.issues.push({
|
| 600 |
+
expected: "never",
|
| 601 |
+
code: "invalid_type",
|
| 602 |
+
input: payload.value,
|
| 603 |
+
inst,
|
| 604 |
+
});
|
| 605 |
+
return payload;
|
| 606 |
+
};
|
| 607 |
+
});
|
| 608 |
+
exports.$ZodVoid = core.$constructor("$ZodVoid", (inst, def) => {
|
| 609 |
+
exports.$ZodType.init(inst, def);
|
| 610 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 611 |
+
const input = payload.value;
|
| 612 |
+
if (typeof input === "undefined")
|
| 613 |
+
return payload;
|
| 614 |
+
payload.issues.push({
|
| 615 |
+
expected: "void",
|
| 616 |
+
code: "invalid_type",
|
| 617 |
+
input,
|
| 618 |
+
inst,
|
| 619 |
+
});
|
| 620 |
+
return payload;
|
| 621 |
+
};
|
| 622 |
+
});
|
| 623 |
+
exports.$ZodDate = core.$constructor("$ZodDate", (inst, def) => {
|
| 624 |
+
exports.$ZodType.init(inst, def);
|
| 625 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 626 |
+
if (def.coerce) {
|
| 627 |
+
try {
|
| 628 |
+
payload.value = new Date(payload.value);
|
| 629 |
+
}
|
| 630 |
+
catch (_err) { }
|
| 631 |
+
}
|
| 632 |
+
const input = payload.value;
|
| 633 |
+
const isDate = input instanceof Date;
|
| 634 |
+
const isValidDate = isDate && !Number.isNaN(input.getTime());
|
| 635 |
+
if (isValidDate)
|
| 636 |
+
return payload;
|
| 637 |
+
payload.issues.push({
|
| 638 |
+
expected: "date",
|
| 639 |
+
code: "invalid_type",
|
| 640 |
+
input,
|
| 641 |
+
...(isDate ? { received: "Invalid Date" } : {}),
|
| 642 |
+
inst,
|
| 643 |
+
});
|
| 644 |
+
return payload;
|
| 645 |
+
};
|
| 646 |
+
});
|
| 647 |
+
function handleArrayResult(result, final, index) {
|
| 648 |
+
if (result.issues.length) {
|
| 649 |
+
final.issues.push(...util.prefixIssues(index, result.issues));
|
| 650 |
+
}
|
| 651 |
+
final.value[index] = result.value;
|
| 652 |
+
}
|
| 653 |
+
exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
|
| 654 |
+
exports.$ZodType.init(inst, def);
|
| 655 |
+
inst._zod.parse = (payload, ctx) => {
|
| 656 |
+
const input = payload.value;
|
| 657 |
+
if (!Array.isArray(input)) {
|
| 658 |
+
payload.issues.push({
|
| 659 |
+
expected: "array",
|
| 660 |
+
code: "invalid_type",
|
| 661 |
+
input,
|
| 662 |
+
inst,
|
| 663 |
+
});
|
| 664 |
+
return payload;
|
| 665 |
+
}
|
| 666 |
+
payload.value = Array(input.length);
|
| 667 |
+
const proms = [];
|
| 668 |
+
for (let i = 0; i < input.length; i++) {
|
| 669 |
+
const item = input[i];
|
| 670 |
+
const result = def.element._zod.run({
|
| 671 |
+
value: item,
|
| 672 |
+
issues: [],
|
| 673 |
+
}, ctx);
|
| 674 |
+
if (result instanceof Promise) {
|
| 675 |
+
proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
| 676 |
+
}
|
| 677 |
+
else {
|
| 678 |
+
handleArrayResult(result, payload, i);
|
| 679 |
+
}
|
| 680 |
+
}
|
| 681 |
+
if (proms.length) {
|
| 682 |
+
return Promise.all(proms).then(() => payload);
|
| 683 |
+
}
|
| 684 |
+
return payload; //handleArrayResultsAsync(parseResults, final);
|
| 685 |
+
};
|
| 686 |
+
});
|
| 687 |
+
function handleObjectResult(result, final, key) {
|
| 688 |
+
// if(isOptional)
|
| 689 |
+
if (result.issues.length) {
|
| 690 |
+
final.issues.push(...util.prefixIssues(key, result.issues));
|
| 691 |
+
}
|
| 692 |
+
final.value[key] = result.value;
|
| 693 |
+
}
|
| 694 |
+
function handleOptionalObjectResult(result, final, key, input) {
|
| 695 |
+
if (result.issues.length) {
|
| 696 |
+
// validation failed against value schema
|
| 697 |
+
if (input[key] === undefined) {
|
| 698 |
+
// if input was undefined, ignore the error
|
| 699 |
+
if (key in input) {
|
| 700 |
+
final.value[key] = undefined;
|
| 701 |
+
}
|
| 702 |
+
else {
|
| 703 |
+
final.value[key] = result.value;
|
| 704 |
+
}
|
| 705 |
+
}
|
| 706 |
+
else {
|
| 707 |
+
final.issues.push(...util.prefixIssues(key, result.issues));
|
| 708 |
+
}
|
| 709 |
+
}
|
| 710 |
+
else if (result.value === undefined) {
|
| 711 |
+
// validation returned `undefined`
|
| 712 |
+
if (key in input)
|
| 713 |
+
final.value[key] = undefined;
|
| 714 |
+
}
|
| 715 |
+
else {
|
| 716 |
+
// non-undefined value
|
| 717 |
+
final.value[key] = result.value;
|
| 718 |
+
}
|
| 719 |
+
}
|
| 720 |
+
exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
|
| 721 |
+
// requires cast because technically $ZodObject doesn't extend
|
| 722 |
+
exports.$ZodType.init(inst, def);
|
| 723 |
+
const _normalized = util.cached(() => {
|
| 724 |
+
const keys = Object.keys(def.shape);
|
| 725 |
+
for (const k of keys) {
|
| 726 |
+
if (!(def.shape[k] instanceof exports.$ZodType)) {
|
| 727 |
+
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
| 728 |
+
}
|
| 729 |
+
}
|
| 730 |
+
const okeys = util.optionalKeys(def.shape);
|
| 731 |
+
return {
|
| 732 |
+
shape: def.shape,
|
| 733 |
+
keys,
|
| 734 |
+
keySet: new Set(keys),
|
| 735 |
+
numKeys: keys.length,
|
| 736 |
+
optionalKeys: new Set(okeys),
|
| 737 |
+
};
|
| 738 |
+
});
|
| 739 |
+
util.defineLazy(inst._zod, "propValues", () => {
|
| 740 |
+
const shape = def.shape;
|
| 741 |
+
const propValues = {};
|
| 742 |
+
for (const key in shape) {
|
| 743 |
+
const field = shape[key]._zod;
|
| 744 |
+
if (field.values) {
|
| 745 |
+
propValues[key] ?? (propValues[key] = new Set());
|
| 746 |
+
for (const v of field.values)
|
| 747 |
+
propValues[key].add(v);
|
| 748 |
+
}
|
| 749 |
+
}
|
| 750 |
+
return propValues;
|
| 751 |
+
});
|
| 752 |
+
const generateFastpass = (shape) => {
|
| 753 |
+
const doc = new doc_js_1.Doc(["shape", "payload", "ctx"]);
|
| 754 |
+
const normalized = _normalized.value;
|
| 755 |
+
const parseStr = (key) => {
|
| 756 |
+
const k = util.esc(key);
|
| 757 |
+
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
| 758 |
+
};
|
| 759 |
+
doc.write(`const input = payload.value;`);
|
| 760 |
+
const ids = Object.create(null);
|
| 761 |
+
let counter = 0;
|
| 762 |
+
for (const key of normalized.keys) {
|
| 763 |
+
ids[key] = `key_${counter++}`;
|
| 764 |
+
}
|
| 765 |
+
// A: preserve key order {
|
| 766 |
+
doc.write(`const newResult = {}`);
|
| 767 |
+
for (const key of normalized.keys) {
|
| 768 |
+
if (normalized.optionalKeys.has(key)) {
|
| 769 |
+
const id = ids[key];
|
| 770 |
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
| 771 |
+
const k = util.esc(key);
|
| 772 |
+
doc.write(`
|
| 773 |
+
if (${id}.issues.length) {
|
| 774 |
+
if (input[${k}] === undefined) {
|
| 775 |
+
if (${k} in input) {
|
| 776 |
+
newResult[${k}] = undefined;
|
| 777 |
+
}
|
| 778 |
+
} else {
|
| 779 |
+
payload.issues = payload.issues.concat(
|
| 780 |
+
${id}.issues.map((iss) => ({
|
| 781 |
+
...iss,
|
| 782 |
+
path: iss.path ? [${k}, ...iss.path] : [${k}],
|
| 783 |
+
}))
|
| 784 |
+
);
|
| 785 |
+
}
|
| 786 |
+
} else if (${id}.value === undefined) {
|
| 787 |
+
if (${k} in input) newResult[${k}] = undefined;
|
| 788 |
+
} else {
|
| 789 |
+
newResult[${k}] = ${id}.value;
|
| 790 |
+
}
|
| 791 |
+
`);
|
| 792 |
+
}
|
| 793 |
+
else {
|
| 794 |
+
const id = ids[key];
|
| 795 |
+
// const id = ids[key];
|
| 796 |
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
| 797 |
+
doc.write(`
|
| 798 |
+
if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
| 799 |
+
...iss,
|
| 800 |
+
path: iss.path ? [${util.esc(key)}, ...iss.path] : [${util.esc(key)}]
|
| 801 |
+
})));`);
|
| 802 |
+
doc.write(`newResult[${util.esc(key)}] = ${id}.value`);
|
| 803 |
+
}
|
| 804 |
+
}
|
| 805 |
+
doc.write(`payload.value = newResult;`);
|
| 806 |
+
doc.write(`return payload;`);
|
| 807 |
+
const fn = doc.compile();
|
| 808 |
+
return (payload, ctx) => fn(shape, payload, ctx);
|
| 809 |
+
};
|
| 810 |
+
let fastpass;
|
| 811 |
+
const isObject = util.isObject;
|
| 812 |
+
const jit = !core.globalConfig.jitless;
|
| 813 |
+
const allowsEval = util.allowsEval;
|
| 814 |
+
const fastEnabled = jit && allowsEval.value; // && !def.catchall;
|
| 815 |
+
const catchall = def.catchall;
|
| 816 |
+
let value;
|
| 817 |
+
inst._zod.parse = (payload, ctx) => {
|
| 818 |
+
value ?? (value = _normalized.value);
|
| 819 |
+
const input = payload.value;
|
| 820 |
+
if (!isObject(input)) {
|
| 821 |
+
payload.issues.push({
|
| 822 |
+
expected: "object",
|
| 823 |
+
code: "invalid_type",
|
| 824 |
+
input,
|
| 825 |
+
inst,
|
| 826 |
+
});
|
| 827 |
+
return payload;
|
| 828 |
+
}
|
| 829 |
+
const proms = [];
|
| 830 |
+
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
| 831 |
+
// always synchronous
|
| 832 |
+
if (!fastpass)
|
| 833 |
+
fastpass = generateFastpass(def.shape);
|
| 834 |
+
payload = fastpass(payload, ctx);
|
| 835 |
+
}
|
| 836 |
+
else {
|
| 837 |
+
payload.value = {};
|
| 838 |
+
const shape = value.shape;
|
| 839 |
+
for (const key of value.keys) {
|
| 840 |
+
const el = shape[key];
|
| 841 |
+
// do not add omitted optional keys
|
| 842 |
+
// if (!(key in input)) {
|
| 843 |
+
// if (optionalKeys.has(key)) continue;
|
| 844 |
+
// payload.issues.push({
|
| 845 |
+
// code: "invalid_type",
|
| 846 |
+
// path: [key],
|
| 847 |
+
// expected: "nonoptional",
|
| 848 |
+
// note: `Missing required key: "${key}"`,
|
| 849 |
+
// input,
|
| 850 |
+
// inst,
|
| 851 |
+
// });
|
| 852 |
+
// }
|
| 853 |
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
| 854 |
+
const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
|
| 855 |
+
if (r instanceof Promise) {
|
| 856 |
+
proms.push(r.then((r) => isOptional ? handleOptionalObjectResult(r, payload, key, input) : handleObjectResult(r, payload, key)));
|
| 857 |
+
}
|
| 858 |
+
else if (isOptional) {
|
| 859 |
+
handleOptionalObjectResult(r, payload, key, input);
|
| 860 |
+
}
|
| 861 |
+
else {
|
| 862 |
+
handleObjectResult(r, payload, key);
|
| 863 |
+
}
|
| 864 |
+
}
|
| 865 |
+
}
|
| 866 |
+
if (!catchall) {
|
| 867 |
+
// return payload;
|
| 868 |
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
| 869 |
+
}
|
| 870 |
+
const unrecognized = [];
|
| 871 |
+
// iterate over input keys
|
| 872 |
+
const keySet = value.keySet;
|
| 873 |
+
const _catchall = catchall._zod;
|
| 874 |
+
const t = _catchall.def.type;
|
| 875 |
+
for (const key of Object.keys(input)) {
|
| 876 |
+
if (keySet.has(key))
|
| 877 |
+
continue;
|
| 878 |
+
if (t === "never") {
|
| 879 |
+
unrecognized.push(key);
|
| 880 |
+
continue;
|
| 881 |
+
}
|
| 882 |
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
| 883 |
+
if (r instanceof Promise) {
|
| 884 |
+
proms.push(r.then((r) => handleObjectResult(r, payload, key)));
|
| 885 |
+
}
|
| 886 |
+
else {
|
| 887 |
+
handleObjectResult(r, payload, key);
|
| 888 |
+
}
|
| 889 |
+
}
|
| 890 |
+
if (unrecognized.length) {
|
| 891 |
+
payload.issues.push({
|
| 892 |
+
code: "unrecognized_keys",
|
| 893 |
+
keys: unrecognized,
|
| 894 |
+
input,
|
| 895 |
+
inst,
|
| 896 |
+
});
|
| 897 |
+
}
|
| 898 |
+
if (!proms.length)
|
| 899 |
+
return payload;
|
| 900 |
+
return Promise.all(proms).then(() => {
|
| 901 |
+
return payload;
|
| 902 |
+
});
|
| 903 |
+
};
|
| 904 |
+
});
|
| 905 |
+
function handleUnionResults(results, final, inst, ctx) {
|
| 906 |
+
for (const result of results) {
|
| 907 |
+
if (result.issues.length === 0) {
|
| 908 |
+
final.value = result.value;
|
| 909 |
+
return final;
|
| 910 |
+
}
|
| 911 |
+
}
|
| 912 |
+
final.issues.push({
|
| 913 |
+
code: "invalid_union",
|
| 914 |
+
input: final.value,
|
| 915 |
+
inst,
|
| 916 |
+
errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
|
| 917 |
+
});
|
| 918 |
+
return final;
|
| 919 |
+
}
|
| 920 |
+
exports.$ZodUnion = core.$constructor("$ZodUnion", (inst, def) => {
|
| 921 |
+
exports.$ZodType.init(inst, def);
|
| 922 |
+
util.defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
|
| 923 |
+
util.defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
| 924 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 925 |
+
if (def.options.every((o) => o._zod.values)) {
|
| 926 |
+
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
| 927 |
+
}
|
| 928 |
+
return undefined;
|
| 929 |
+
});
|
| 930 |
+
util.defineLazy(inst._zod, "pattern", () => {
|
| 931 |
+
if (def.options.every((o) => o._zod.pattern)) {
|
| 932 |
+
const patterns = def.options.map((o) => o._zod.pattern);
|
| 933 |
+
return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
|
| 934 |
+
}
|
| 935 |
+
return undefined;
|
| 936 |
+
});
|
| 937 |
+
inst._zod.parse = (payload, ctx) => {
|
| 938 |
+
let async = false;
|
| 939 |
+
const results = [];
|
| 940 |
+
for (const option of def.options) {
|
| 941 |
+
const result = option._zod.run({
|
| 942 |
+
value: payload.value,
|
| 943 |
+
issues: [],
|
| 944 |
+
}, ctx);
|
| 945 |
+
if (result instanceof Promise) {
|
| 946 |
+
results.push(result);
|
| 947 |
+
async = true;
|
| 948 |
+
}
|
| 949 |
+
else {
|
| 950 |
+
if (result.issues.length === 0)
|
| 951 |
+
return result;
|
| 952 |
+
results.push(result);
|
| 953 |
+
}
|
| 954 |
+
}
|
| 955 |
+
if (!async)
|
| 956 |
+
return handleUnionResults(results, payload, inst, ctx);
|
| 957 |
+
return Promise.all(results).then((results) => {
|
| 958 |
+
return handleUnionResults(results, payload, inst, ctx);
|
| 959 |
+
});
|
| 960 |
+
};
|
| 961 |
+
});
|
| 962 |
+
exports.$ZodDiscriminatedUnion =
|
| 963 |
+
/*@__PURE__*/
|
| 964 |
+
core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
| 965 |
+
exports.$ZodUnion.init(inst, def);
|
| 966 |
+
const _super = inst._zod.parse;
|
| 967 |
+
util.defineLazy(inst._zod, "propValues", () => {
|
| 968 |
+
const propValues = {};
|
| 969 |
+
for (const option of def.options) {
|
| 970 |
+
const pv = option._zod.propValues;
|
| 971 |
+
if (!pv || Object.keys(pv).length === 0)
|
| 972 |
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
| 973 |
+
for (const [k, v] of Object.entries(pv)) {
|
| 974 |
+
if (!propValues[k])
|
| 975 |
+
propValues[k] = new Set();
|
| 976 |
+
for (const val of v) {
|
| 977 |
+
propValues[k].add(val);
|
| 978 |
+
}
|
| 979 |
+
}
|
| 980 |
+
}
|
| 981 |
+
return propValues;
|
| 982 |
+
});
|
| 983 |
+
const disc = util.cached(() => {
|
| 984 |
+
const opts = def.options;
|
| 985 |
+
const map = new Map();
|
| 986 |
+
for (const o of opts) {
|
| 987 |
+
const values = o._zod.propValues[def.discriminator];
|
| 988 |
+
if (!values || values.size === 0)
|
| 989 |
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
| 990 |
+
for (const v of values) {
|
| 991 |
+
if (map.has(v)) {
|
| 992 |
+
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
| 993 |
+
}
|
| 994 |
+
map.set(v, o);
|
| 995 |
+
}
|
| 996 |
+
}
|
| 997 |
+
return map;
|
| 998 |
+
});
|
| 999 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1000 |
+
const input = payload.value;
|
| 1001 |
+
if (!util.isObject(input)) {
|
| 1002 |
+
payload.issues.push({
|
| 1003 |
+
code: "invalid_type",
|
| 1004 |
+
expected: "object",
|
| 1005 |
+
input,
|
| 1006 |
+
inst,
|
| 1007 |
+
});
|
| 1008 |
+
return payload;
|
| 1009 |
+
}
|
| 1010 |
+
const opt = disc.value.get(input?.[def.discriminator]);
|
| 1011 |
+
if (opt) {
|
| 1012 |
+
return opt._zod.run(payload, ctx);
|
| 1013 |
+
}
|
| 1014 |
+
if (def.unionFallback) {
|
| 1015 |
+
return _super(payload, ctx);
|
| 1016 |
+
}
|
| 1017 |
+
// no matching discriminator
|
| 1018 |
+
payload.issues.push({
|
| 1019 |
+
code: "invalid_union",
|
| 1020 |
+
errors: [],
|
| 1021 |
+
note: "No matching discriminator",
|
| 1022 |
+
input,
|
| 1023 |
+
path: [def.discriminator],
|
| 1024 |
+
inst,
|
| 1025 |
+
});
|
| 1026 |
+
return payload;
|
| 1027 |
+
};
|
| 1028 |
+
});
|
| 1029 |
+
exports.$ZodIntersection = core.$constructor("$ZodIntersection", (inst, def) => {
|
| 1030 |
+
exports.$ZodType.init(inst, def);
|
| 1031 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1032 |
+
const input = payload.value;
|
| 1033 |
+
const left = def.left._zod.run({ value: input, issues: [] }, ctx);
|
| 1034 |
+
const right = def.right._zod.run({ value: input, issues: [] }, ctx);
|
| 1035 |
+
const async = left instanceof Promise || right instanceof Promise;
|
| 1036 |
+
if (async) {
|
| 1037 |
+
return Promise.all([left, right]).then(([left, right]) => {
|
| 1038 |
+
return handleIntersectionResults(payload, left, right);
|
| 1039 |
+
});
|
| 1040 |
+
}
|
| 1041 |
+
return handleIntersectionResults(payload, left, right);
|
| 1042 |
+
};
|
| 1043 |
+
});
|
| 1044 |
+
function mergeValues(a, b) {
|
| 1045 |
+
// const aType = parse.t(a);
|
| 1046 |
+
// const bType = parse.t(b);
|
| 1047 |
+
if (a === b) {
|
| 1048 |
+
return { valid: true, data: a };
|
| 1049 |
+
}
|
| 1050 |
+
if (a instanceof Date && b instanceof Date && +a === +b) {
|
| 1051 |
+
return { valid: true, data: a };
|
| 1052 |
+
}
|
| 1053 |
+
if (util.isPlainObject(a) && util.isPlainObject(b)) {
|
| 1054 |
+
const bKeys = Object.keys(b);
|
| 1055 |
+
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
| 1056 |
+
const newObj = { ...a, ...b };
|
| 1057 |
+
for (const key of sharedKeys) {
|
| 1058 |
+
const sharedValue = mergeValues(a[key], b[key]);
|
| 1059 |
+
if (!sharedValue.valid) {
|
| 1060 |
+
return {
|
| 1061 |
+
valid: false,
|
| 1062 |
+
mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
|
| 1063 |
+
};
|
| 1064 |
+
}
|
| 1065 |
+
newObj[key] = sharedValue.data;
|
| 1066 |
+
}
|
| 1067 |
+
return { valid: true, data: newObj };
|
| 1068 |
+
}
|
| 1069 |
+
if (Array.isArray(a) && Array.isArray(b)) {
|
| 1070 |
+
if (a.length !== b.length) {
|
| 1071 |
+
return { valid: false, mergeErrorPath: [] };
|
| 1072 |
+
}
|
| 1073 |
+
const newArray = [];
|
| 1074 |
+
for (let index = 0; index < a.length; index++) {
|
| 1075 |
+
const itemA = a[index];
|
| 1076 |
+
const itemB = b[index];
|
| 1077 |
+
const sharedValue = mergeValues(itemA, itemB);
|
| 1078 |
+
if (!sharedValue.valid) {
|
| 1079 |
+
return {
|
| 1080 |
+
valid: false,
|
| 1081 |
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
|
| 1082 |
+
};
|
| 1083 |
+
}
|
| 1084 |
+
newArray.push(sharedValue.data);
|
| 1085 |
+
}
|
| 1086 |
+
return { valid: true, data: newArray };
|
| 1087 |
+
}
|
| 1088 |
+
return { valid: false, mergeErrorPath: [] };
|
| 1089 |
+
}
|
| 1090 |
+
function handleIntersectionResults(result, left, right) {
|
| 1091 |
+
if (left.issues.length) {
|
| 1092 |
+
result.issues.push(...left.issues);
|
| 1093 |
+
}
|
| 1094 |
+
if (right.issues.length) {
|
| 1095 |
+
result.issues.push(...right.issues);
|
| 1096 |
+
}
|
| 1097 |
+
if (util.aborted(result))
|
| 1098 |
+
return result;
|
| 1099 |
+
const merged = mergeValues(left.value, right.value);
|
| 1100 |
+
if (!merged.valid) {
|
| 1101 |
+
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
| 1102 |
+
}
|
| 1103 |
+
result.value = merged.data;
|
| 1104 |
+
return result;
|
| 1105 |
+
}
|
| 1106 |
+
exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => {
|
| 1107 |
+
exports.$ZodType.init(inst, def);
|
| 1108 |
+
const items = def.items;
|
| 1109 |
+
const optStart = items.length - [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
|
| 1110 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1111 |
+
const input = payload.value;
|
| 1112 |
+
if (!Array.isArray(input)) {
|
| 1113 |
+
payload.issues.push({
|
| 1114 |
+
input,
|
| 1115 |
+
inst,
|
| 1116 |
+
expected: "tuple",
|
| 1117 |
+
code: "invalid_type",
|
| 1118 |
+
});
|
| 1119 |
+
return payload;
|
| 1120 |
+
}
|
| 1121 |
+
payload.value = [];
|
| 1122 |
+
const proms = [];
|
| 1123 |
+
if (!def.rest) {
|
| 1124 |
+
const tooBig = input.length > items.length;
|
| 1125 |
+
const tooSmall = input.length < optStart - 1;
|
| 1126 |
+
if (tooBig || tooSmall) {
|
| 1127 |
+
payload.issues.push({
|
| 1128 |
+
input,
|
| 1129 |
+
inst,
|
| 1130 |
+
origin: "array",
|
| 1131 |
+
...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
|
| 1132 |
+
});
|
| 1133 |
+
return payload;
|
| 1134 |
+
}
|
| 1135 |
+
}
|
| 1136 |
+
let i = -1;
|
| 1137 |
+
for (const item of items) {
|
| 1138 |
+
i++;
|
| 1139 |
+
if (i >= input.length)
|
| 1140 |
+
if (i >= optStart)
|
| 1141 |
+
continue;
|
| 1142 |
+
const result = item._zod.run({
|
| 1143 |
+
value: input[i],
|
| 1144 |
+
issues: [],
|
| 1145 |
+
}, ctx);
|
| 1146 |
+
if (result instanceof Promise) {
|
| 1147 |
+
proms.push(result.then((result) => handleTupleResult(result, payload, i)));
|
| 1148 |
+
}
|
| 1149 |
+
else {
|
| 1150 |
+
handleTupleResult(result, payload, i);
|
| 1151 |
+
}
|
| 1152 |
+
}
|
| 1153 |
+
if (def.rest) {
|
| 1154 |
+
const rest = input.slice(items.length);
|
| 1155 |
+
for (const el of rest) {
|
| 1156 |
+
i++;
|
| 1157 |
+
const result = def.rest._zod.run({
|
| 1158 |
+
value: el,
|
| 1159 |
+
issues: [],
|
| 1160 |
+
}, ctx);
|
| 1161 |
+
if (result instanceof Promise) {
|
| 1162 |
+
proms.push(result.then((result) => handleTupleResult(result, payload, i)));
|
| 1163 |
+
}
|
| 1164 |
+
else {
|
| 1165 |
+
handleTupleResult(result, payload, i);
|
| 1166 |
+
}
|
| 1167 |
+
}
|
| 1168 |
+
}
|
| 1169 |
+
if (proms.length)
|
| 1170 |
+
return Promise.all(proms).then(() => payload);
|
| 1171 |
+
return payload;
|
| 1172 |
+
};
|
| 1173 |
+
});
|
| 1174 |
+
function handleTupleResult(result, final, index) {
|
| 1175 |
+
if (result.issues.length) {
|
| 1176 |
+
final.issues.push(...util.prefixIssues(index, result.issues));
|
| 1177 |
+
}
|
| 1178 |
+
final.value[index] = result.value;
|
| 1179 |
+
}
|
| 1180 |
+
exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
|
| 1181 |
+
exports.$ZodType.init(inst, def);
|
| 1182 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1183 |
+
const input = payload.value;
|
| 1184 |
+
if (!util.isPlainObject(input)) {
|
| 1185 |
+
payload.issues.push({
|
| 1186 |
+
expected: "record",
|
| 1187 |
+
code: "invalid_type",
|
| 1188 |
+
input,
|
| 1189 |
+
inst,
|
| 1190 |
+
});
|
| 1191 |
+
return payload;
|
| 1192 |
+
}
|
| 1193 |
+
const proms = [];
|
| 1194 |
+
if (def.keyType._zod.values) {
|
| 1195 |
+
const values = def.keyType._zod.values;
|
| 1196 |
+
payload.value = {};
|
| 1197 |
+
for (const key of values) {
|
| 1198 |
+
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
| 1199 |
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
| 1200 |
+
if (result instanceof Promise) {
|
| 1201 |
+
proms.push(result.then((result) => {
|
| 1202 |
+
if (result.issues.length) {
|
| 1203 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1204 |
+
}
|
| 1205 |
+
payload.value[key] = result.value;
|
| 1206 |
+
}));
|
| 1207 |
+
}
|
| 1208 |
+
else {
|
| 1209 |
+
if (result.issues.length) {
|
| 1210 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1211 |
+
}
|
| 1212 |
+
payload.value[key] = result.value;
|
| 1213 |
+
}
|
| 1214 |
+
}
|
| 1215 |
+
}
|
| 1216 |
+
let unrecognized;
|
| 1217 |
+
for (const key in input) {
|
| 1218 |
+
if (!values.has(key)) {
|
| 1219 |
+
unrecognized = unrecognized ?? [];
|
| 1220 |
+
unrecognized.push(key);
|
| 1221 |
+
}
|
| 1222 |
+
}
|
| 1223 |
+
if (unrecognized && unrecognized.length > 0) {
|
| 1224 |
+
payload.issues.push({
|
| 1225 |
+
code: "unrecognized_keys",
|
| 1226 |
+
input,
|
| 1227 |
+
inst,
|
| 1228 |
+
keys: unrecognized,
|
| 1229 |
+
});
|
| 1230 |
+
}
|
| 1231 |
+
}
|
| 1232 |
+
else {
|
| 1233 |
+
payload.value = {};
|
| 1234 |
+
for (const key of Reflect.ownKeys(input)) {
|
| 1235 |
+
if (key === "__proto__")
|
| 1236 |
+
continue;
|
| 1237 |
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
| 1238 |
+
if (keyResult instanceof Promise) {
|
| 1239 |
+
throw new Error("Async schemas not supported in object keys currently");
|
| 1240 |
+
}
|
| 1241 |
+
if (keyResult.issues.length) {
|
| 1242 |
+
payload.issues.push({
|
| 1243 |
+
origin: "record",
|
| 1244 |
+
code: "invalid_key",
|
| 1245 |
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1246 |
+
input: key,
|
| 1247 |
+
path: [key],
|
| 1248 |
+
inst,
|
| 1249 |
+
});
|
| 1250 |
+
payload.value[keyResult.value] = keyResult.value;
|
| 1251 |
+
continue;
|
| 1252 |
+
}
|
| 1253 |
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
| 1254 |
+
if (result instanceof Promise) {
|
| 1255 |
+
proms.push(result.then((result) => {
|
| 1256 |
+
if (result.issues.length) {
|
| 1257 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1258 |
+
}
|
| 1259 |
+
payload.value[keyResult.value] = result.value;
|
| 1260 |
+
}));
|
| 1261 |
+
}
|
| 1262 |
+
else {
|
| 1263 |
+
if (result.issues.length) {
|
| 1264 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1265 |
+
}
|
| 1266 |
+
payload.value[keyResult.value] = result.value;
|
| 1267 |
+
}
|
| 1268 |
+
}
|
| 1269 |
+
}
|
| 1270 |
+
if (proms.length) {
|
| 1271 |
+
return Promise.all(proms).then(() => payload);
|
| 1272 |
+
}
|
| 1273 |
+
return payload;
|
| 1274 |
+
};
|
| 1275 |
+
});
|
| 1276 |
+
exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => {
|
| 1277 |
+
exports.$ZodType.init(inst, def);
|
| 1278 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1279 |
+
const input = payload.value;
|
| 1280 |
+
if (!(input instanceof Map)) {
|
| 1281 |
+
payload.issues.push({
|
| 1282 |
+
expected: "map",
|
| 1283 |
+
code: "invalid_type",
|
| 1284 |
+
input,
|
| 1285 |
+
inst,
|
| 1286 |
+
});
|
| 1287 |
+
return payload;
|
| 1288 |
+
}
|
| 1289 |
+
const proms = [];
|
| 1290 |
+
payload.value = new Map();
|
| 1291 |
+
for (const [key, value] of input) {
|
| 1292 |
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
| 1293 |
+
const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
|
| 1294 |
+
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
| 1295 |
+
proms.push(Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
|
| 1296 |
+
handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
|
| 1297 |
+
}));
|
| 1298 |
+
}
|
| 1299 |
+
else {
|
| 1300 |
+
handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
|
| 1301 |
+
}
|
| 1302 |
+
}
|
| 1303 |
+
if (proms.length)
|
| 1304 |
+
return Promise.all(proms).then(() => payload);
|
| 1305 |
+
return payload;
|
| 1306 |
+
};
|
| 1307 |
+
});
|
| 1308 |
+
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
| 1309 |
+
if (keyResult.issues.length) {
|
| 1310 |
+
if (util.propertyKeyTypes.has(typeof key)) {
|
| 1311 |
+
final.issues.push(...util.prefixIssues(key, keyResult.issues));
|
| 1312 |
+
}
|
| 1313 |
+
else {
|
| 1314 |
+
final.issues.push({
|
| 1315 |
+
origin: "map",
|
| 1316 |
+
code: "invalid_key",
|
| 1317 |
+
input,
|
| 1318 |
+
inst,
|
| 1319 |
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1320 |
+
});
|
| 1321 |
+
}
|
| 1322 |
+
}
|
| 1323 |
+
if (valueResult.issues.length) {
|
| 1324 |
+
if (util.propertyKeyTypes.has(typeof key)) {
|
| 1325 |
+
final.issues.push(...util.prefixIssues(key, valueResult.issues));
|
| 1326 |
+
}
|
| 1327 |
+
else {
|
| 1328 |
+
final.issues.push({
|
| 1329 |
+
origin: "map",
|
| 1330 |
+
code: "invalid_element",
|
| 1331 |
+
input,
|
| 1332 |
+
inst,
|
| 1333 |
+
key: key,
|
| 1334 |
+
issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1335 |
+
});
|
| 1336 |
+
}
|
| 1337 |
+
}
|
| 1338 |
+
final.value.set(keyResult.value, valueResult.value);
|
| 1339 |
+
}
|
| 1340 |
+
exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => {
|
| 1341 |
+
exports.$ZodType.init(inst, def);
|
| 1342 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1343 |
+
const input = payload.value;
|
| 1344 |
+
if (!(input instanceof Set)) {
|
| 1345 |
+
payload.issues.push({
|
| 1346 |
+
input,
|
| 1347 |
+
inst,
|
| 1348 |
+
expected: "set",
|
| 1349 |
+
code: "invalid_type",
|
| 1350 |
+
});
|
| 1351 |
+
return payload;
|
| 1352 |
+
}
|
| 1353 |
+
const proms = [];
|
| 1354 |
+
payload.value = new Set();
|
| 1355 |
+
for (const item of input) {
|
| 1356 |
+
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
| 1357 |
+
if (result instanceof Promise) {
|
| 1358 |
+
proms.push(result.then((result) => handleSetResult(result, payload)));
|
| 1359 |
+
}
|
| 1360 |
+
else
|
| 1361 |
+
handleSetResult(result, payload);
|
| 1362 |
+
}
|
| 1363 |
+
if (proms.length)
|
| 1364 |
+
return Promise.all(proms).then(() => payload);
|
| 1365 |
+
return payload;
|
| 1366 |
+
};
|
| 1367 |
+
});
|
| 1368 |
+
function handleSetResult(result, final) {
|
| 1369 |
+
if (result.issues.length) {
|
| 1370 |
+
final.issues.push(...result.issues);
|
| 1371 |
+
}
|
| 1372 |
+
final.value.add(result.value);
|
| 1373 |
+
}
|
| 1374 |
+
exports.$ZodEnum = core.$constructor("$ZodEnum", (inst, def) => {
|
| 1375 |
+
exports.$ZodType.init(inst, def);
|
| 1376 |
+
const values = util.getEnumValues(def.entries);
|
| 1377 |
+
inst._zod.values = new Set(values);
|
| 1378 |
+
inst._zod.pattern = new RegExp(`^(${values
|
| 1379 |
+
.filter((k) => util.propertyKeyTypes.has(typeof k))
|
| 1380 |
+
.map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString()))
|
| 1381 |
+
.join("|")})$`);
|
| 1382 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1383 |
+
const input = payload.value;
|
| 1384 |
+
if (inst._zod.values.has(input)) {
|
| 1385 |
+
return payload;
|
| 1386 |
+
}
|
| 1387 |
+
payload.issues.push({
|
| 1388 |
+
code: "invalid_value",
|
| 1389 |
+
values,
|
| 1390 |
+
input,
|
| 1391 |
+
inst,
|
| 1392 |
+
});
|
| 1393 |
+
return payload;
|
| 1394 |
+
};
|
| 1395 |
+
});
|
| 1396 |
+
exports.$ZodLiteral = core.$constructor("$ZodLiteral", (inst, def) => {
|
| 1397 |
+
exports.$ZodType.init(inst, def);
|
| 1398 |
+
inst._zod.values = new Set(def.values);
|
| 1399 |
+
inst._zod.pattern = new RegExp(`^(${def.values
|
| 1400 |
+
.map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? o.toString() : String(o)))
|
| 1401 |
+
.join("|")})$`);
|
| 1402 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1403 |
+
const input = payload.value;
|
| 1404 |
+
if (inst._zod.values.has(input)) {
|
| 1405 |
+
return payload;
|
| 1406 |
+
}
|
| 1407 |
+
payload.issues.push({
|
| 1408 |
+
code: "invalid_value",
|
| 1409 |
+
values: def.values,
|
| 1410 |
+
input,
|
| 1411 |
+
inst,
|
| 1412 |
+
});
|
| 1413 |
+
return payload;
|
| 1414 |
+
};
|
| 1415 |
+
});
|
| 1416 |
+
exports.$ZodFile = core.$constructor("$ZodFile", (inst, def) => {
|
| 1417 |
+
exports.$ZodType.init(inst, def);
|
| 1418 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1419 |
+
const input = payload.value;
|
| 1420 |
+
if (input instanceof File)
|
| 1421 |
+
return payload;
|
| 1422 |
+
payload.issues.push({
|
| 1423 |
+
expected: "file",
|
| 1424 |
+
code: "invalid_type",
|
| 1425 |
+
input,
|
| 1426 |
+
inst,
|
| 1427 |
+
});
|
| 1428 |
+
return payload;
|
| 1429 |
+
};
|
| 1430 |
+
});
|
| 1431 |
+
exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
|
| 1432 |
+
exports.$ZodType.init(inst, def);
|
| 1433 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1434 |
+
const _out = def.transform(payload.value, payload);
|
| 1435 |
+
if (_ctx.async) {
|
| 1436 |
+
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
| 1437 |
+
return output.then((output) => {
|
| 1438 |
+
payload.value = output;
|
| 1439 |
+
return payload;
|
| 1440 |
+
});
|
| 1441 |
+
}
|
| 1442 |
+
if (_out instanceof Promise) {
|
| 1443 |
+
throw new core.$ZodAsyncError();
|
| 1444 |
+
}
|
| 1445 |
+
payload.value = _out;
|
| 1446 |
+
return payload;
|
| 1447 |
+
};
|
| 1448 |
+
});
|
| 1449 |
+
exports.$ZodOptional = core.$constructor("$ZodOptional", (inst, def) => {
|
| 1450 |
+
exports.$ZodType.init(inst, def);
|
| 1451 |
+
inst._zod.optin = "optional";
|
| 1452 |
+
inst._zod.optout = "optional";
|
| 1453 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1454 |
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
|
| 1455 |
+
});
|
| 1456 |
+
util.defineLazy(inst._zod, "pattern", () => {
|
| 1457 |
+
const pattern = def.innerType._zod.pattern;
|
| 1458 |
+
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
|
| 1459 |
+
});
|
| 1460 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1461 |
+
if (def.innerType._zod.optin === "optional") {
|
| 1462 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1463 |
+
}
|
| 1464 |
+
if (payload.value === undefined) {
|
| 1465 |
+
return payload;
|
| 1466 |
+
}
|
| 1467 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1468 |
+
};
|
| 1469 |
+
});
|
| 1470 |
+
exports.$ZodNullable = core.$constructor("$ZodNullable", (inst, def) => {
|
| 1471 |
+
exports.$ZodType.init(inst, def);
|
| 1472 |
+
util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
| 1473 |
+
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
| 1474 |
+
util.defineLazy(inst._zod, "pattern", () => {
|
| 1475 |
+
const pattern = def.innerType._zod.pattern;
|
| 1476 |
+
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
|
| 1477 |
+
});
|
| 1478 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1479 |
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
| 1480 |
+
});
|
| 1481 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1482 |
+
if (payload.value === null)
|
| 1483 |
+
return payload;
|
| 1484 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1485 |
+
};
|
| 1486 |
+
});
|
| 1487 |
+
exports.$ZodDefault = core.$constructor("$ZodDefault", (inst, def) => {
|
| 1488 |
+
exports.$ZodType.init(inst, def);
|
| 1489 |
+
// inst._zod.qin = "true";
|
| 1490 |
+
inst._zod.optin = "optional";
|
| 1491 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1492 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1493 |
+
if (payload.value === undefined) {
|
| 1494 |
+
payload.value = def.defaultValue;
|
| 1495 |
+
/**
|
| 1496 |
+
* $ZodDefault always returns the default value immediately.
|
| 1497 |
+
* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
|
| 1498 |
+
return payload;
|
| 1499 |
+
}
|
| 1500 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1501 |
+
if (result instanceof Promise) {
|
| 1502 |
+
return result.then((result) => handleDefaultResult(result, def));
|
| 1503 |
+
}
|
| 1504 |
+
return handleDefaultResult(result, def);
|
| 1505 |
+
};
|
| 1506 |
+
});
|
| 1507 |
+
function handleDefaultResult(payload, def) {
|
| 1508 |
+
if (payload.value === undefined) {
|
| 1509 |
+
payload.value = def.defaultValue;
|
| 1510 |
+
}
|
| 1511 |
+
return payload;
|
| 1512 |
+
}
|
| 1513 |
+
exports.$ZodPrefault = core.$constructor("$ZodPrefault", (inst, def) => {
|
| 1514 |
+
exports.$ZodType.init(inst, def);
|
| 1515 |
+
inst._zod.optin = "optional";
|
| 1516 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1517 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1518 |
+
if (payload.value === undefined) {
|
| 1519 |
+
payload.value = def.defaultValue;
|
| 1520 |
+
}
|
| 1521 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1522 |
+
};
|
| 1523 |
+
});
|
| 1524 |
+
exports.$ZodNonOptional = core.$constructor("$ZodNonOptional", (inst, def) => {
|
| 1525 |
+
exports.$ZodType.init(inst, def);
|
| 1526 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1527 |
+
const v = def.innerType._zod.values;
|
| 1528 |
+
return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
|
| 1529 |
+
});
|
| 1530 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1531 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1532 |
+
if (result instanceof Promise) {
|
| 1533 |
+
return result.then((result) => handleNonOptionalResult(result, inst));
|
| 1534 |
+
}
|
| 1535 |
+
return handleNonOptionalResult(result, inst);
|
| 1536 |
+
};
|
| 1537 |
+
});
|
| 1538 |
+
function handleNonOptionalResult(payload, inst) {
|
| 1539 |
+
if (!payload.issues.length && payload.value === undefined) {
|
| 1540 |
+
payload.issues.push({
|
| 1541 |
+
code: "invalid_type",
|
| 1542 |
+
expected: "nonoptional",
|
| 1543 |
+
input: payload.value,
|
| 1544 |
+
inst,
|
| 1545 |
+
});
|
| 1546 |
+
}
|
| 1547 |
+
return payload;
|
| 1548 |
+
}
|
| 1549 |
+
exports.$ZodSuccess = core.$constructor("$ZodSuccess", (inst, def) => {
|
| 1550 |
+
exports.$ZodType.init(inst, def);
|
| 1551 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1552 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1553 |
+
if (result instanceof Promise) {
|
| 1554 |
+
return result.then((result) => {
|
| 1555 |
+
payload.value = result.issues.length === 0;
|
| 1556 |
+
return payload;
|
| 1557 |
+
});
|
| 1558 |
+
}
|
| 1559 |
+
payload.value = result.issues.length === 0;
|
| 1560 |
+
return payload;
|
| 1561 |
+
};
|
| 1562 |
+
});
|
| 1563 |
+
exports.$ZodCatch = core.$constructor("$ZodCatch", (inst, def) => {
|
| 1564 |
+
exports.$ZodType.init(inst, def);
|
| 1565 |
+
inst._zod.optin = "optional";
|
| 1566 |
+
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
| 1567 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1568 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1569 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1570 |
+
if (result instanceof Promise) {
|
| 1571 |
+
return result.then((result) => {
|
| 1572 |
+
payload.value = result.value;
|
| 1573 |
+
if (result.issues.length) {
|
| 1574 |
+
payload.value = def.catchValue({
|
| 1575 |
+
...payload,
|
| 1576 |
+
error: {
|
| 1577 |
+
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1578 |
+
},
|
| 1579 |
+
input: payload.value,
|
| 1580 |
+
});
|
| 1581 |
+
payload.issues = [];
|
| 1582 |
+
}
|
| 1583 |
+
return payload;
|
| 1584 |
+
});
|
| 1585 |
+
}
|
| 1586 |
+
payload.value = result.value;
|
| 1587 |
+
if (result.issues.length) {
|
| 1588 |
+
payload.value = def.catchValue({
|
| 1589 |
+
...payload,
|
| 1590 |
+
error: {
|
| 1591 |
+
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1592 |
+
},
|
| 1593 |
+
input: payload.value,
|
| 1594 |
+
});
|
| 1595 |
+
payload.issues = [];
|
| 1596 |
+
}
|
| 1597 |
+
return payload;
|
| 1598 |
+
};
|
| 1599 |
+
});
|
| 1600 |
+
exports.$ZodNaN = core.$constructor("$ZodNaN", (inst, def) => {
|
| 1601 |
+
exports.$ZodType.init(inst, def);
|
| 1602 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1603 |
+
if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
|
| 1604 |
+
payload.issues.push({
|
| 1605 |
+
input: payload.value,
|
| 1606 |
+
inst,
|
| 1607 |
+
expected: "nan",
|
| 1608 |
+
code: "invalid_type",
|
| 1609 |
+
});
|
| 1610 |
+
return payload;
|
| 1611 |
+
}
|
| 1612 |
+
return payload;
|
| 1613 |
+
};
|
| 1614 |
+
});
|
| 1615 |
+
exports.$ZodPipe = core.$constructor("$ZodPipe", (inst, def) => {
|
| 1616 |
+
exports.$ZodType.init(inst, def);
|
| 1617 |
+
util.defineLazy(inst._zod, "values", () => def.in._zod.values);
|
| 1618 |
+
util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
| 1619 |
+
util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
| 1620 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1621 |
+
const left = def.in._zod.run(payload, ctx);
|
| 1622 |
+
if (left instanceof Promise) {
|
| 1623 |
+
return left.then((left) => handlePipeResult(left, def, ctx));
|
| 1624 |
+
}
|
| 1625 |
+
return handlePipeResult(left, def, ctx);
|
| 1626 |
+
};
|
| 1627 |
+
});
|
| 1628 |
+
function handlePipeResult(left, def, ctx) {
|
| 1629 |
+
if (util.aborted(left)) {
|
| 1630 |
+
return left;
|
| 1631 |
+
}
|
| 1632 |
+
return def.out._zod.run({ value: left.value, issues: left.issues }, ctx);
|
| 1633 |
+
}
|
| 1634 |
+
exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => {
|
| 1635 |
+
exports.$ZodType.init(inst, def);
|
| 1636 |
+
util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
| 1637 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1638 |
+
util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
| 1639 |
+
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
| 1640 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1641 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1642 |
+
if (result instanceof Promise) {
|
| 1643 |
+
return result.then(handleReadonlyResult);
|
| 1644 |
+
}
|
| 1645 |
+
return handleReadonlyResult(result);
|
| 1646 |
+
};
|
| 1647 |
+
});
|
| 1648 |
+
function handleReadonlyResult(payload) {
|
| 1649 |
+
payload.value = Object.freeze(payload.value);
|
| 1650 |
+
return payload;
|
| 1651 |
+
}
|
| 1652 |
+
exports.$ZodTemplateLiteral = core.$constructor("$ZodTemplateLiteral", (inst, def) => {
|
| 1653 |
+
exports.$ZodType.init(inst, def);
|
| 1654 |
+
const regexParts = [];
|
| 1655 |
+
for (const part of def.parts) {
|
| 1656 |
+
if (part instanceof exports.$ZodType) {
|
| 1657 |
+
if (!part._zod.pattern) {
|
| 1658 |
+
// if (!source)
|
| 1659 |
+
throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
|
| 1660 |
+
}
|
| 1661 |
+
const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
|
| 1662 |
+
if (!source)
|
| 1663 |
+
throw new Error(`Invalid template literal part: ${part._zod.traits}`);
|
| 1664 |
+
const start = source.startsWith("^") ? 1 : 0;
|
| 1665 |
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
| 1666 |
+
regexParts.push(source.slice(start, end));
|
| 1667 |
+
}
|
| 1668 |
+
else if (part === null || util.primitiveTypes.has(typeof part)) {
|
| 1669 |
+
regexParts.push(util.escapeRegex(`${part}`));
|
| 1670 |
+
}
|
| 1671 |
+
else {
|
| 1672 |
+
throw new Error(`Invalid template literal part: ${part}`);
|
| 1673 |
+
}
|
| 1674 |
+
}
|
| 1675 |
+
inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
|
| 1676 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1677 |
+
if (typeof payload.value !== "string") {
|
| 1678 |
+
payload.issues.push({
|
| 1679 |
+
input: payload.value,
|
| 1680 |
+
inst,
|
| 1681 |
+
expected: "template_literal",
|
| 1682 |
+
code: "invalid_type",
|
| 1683 |
+
});
|
| 1684 |
+
return payload;
|
| 1685 |
+
}
|
| 1686 |
+
inst._zod.pattern.lastIndex = 0;
|
| 1687 |
+
if (!inst._zod.pattern.test(payload.value)) {
|
| 1688 |
+
payload.issues.push({
|
| 1689 |
+
input: payload.value,
|
| 1690 |
+
inst,
|
| 1691 |
+
code: "invalid_format",
|
| 1692 |
+
format: "template_literal",
|
| 1693 |
+
pattern: inst._zod.pattern.source,
|
| 1694 |
+
});
|
| 1695 |
+
return payload;
|
| 1696 |
+
}
|
| 1697 |
+
return payload;
|
| 1698 |
+
};
|
| 1699 |
+
});
|
| 1700 |
+
exports.$ZodPromise = core.$constructor("$ZodPromise", (inst, def) => {
|
| 1701 |
+
exports.$ZodType.init(inst, def);
|
| 1702 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1703 |
+
return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
|
| 1704 |
+
};
|
| 1705 |
+
});
|
| 1706 |
+
exports.$ZodLazy = core.$constructor("$ZodLazy", (inst, def) => {
|
| 1707 |
+
exports.$ZodType.init(inst, def);
|
| 1708 |
+
util.defineLazy(inst._zod, "innerType", () => def.getter());
|
| 1709 |
+
util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType._zod.pattern);
|
| 1710 |
+
util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType._zod.propValues);
|
| 1711 |
+
util.defineLazy(inst._zod, "optin", () => inst._zod.innerType._zod.optin);
|
| 1712 |
+
util.defineLazy(inst._zod, "optout", () => inst._zod.innerType._zod.optout);
|
| 1713 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1714 |
+
const inner = inst._zod.innerType;
|
| 1715 |
+
return inner._zod.run(payload, ctx);
|
| 1716 |
+
};
|
| 1717 |
+
});
|
| 1718 |
+
exports.$ZodCustom = core.$constructor("$ZodCustom", (inst, def) => {
|
| 1719 |
+
checks.$ZodCheck.init(inst, def);
|
| 1720 |
+
exports.$ZodType.init(inst, def);
|
| 1721 |
+
inst._zod.parse = (payload, _) => {
|
| 1722 |
+
return payload;
|
| 1723 |
+
};
|
| 1724 |
+
inst._zod.check = (payload) => {
|
| 1725 |
+
const input = payload.value;
|
| 1726 |
+
const r = def.fn(input);
|
| 1727 |
+
if (r instanceof Promise) {
|
| 1728 |
+
return r.then((r) => handleRefineResult(r, payload, input, inst));
|
| 1729 |
+
}
|
| 1730 |
+
handleRefineResult(r, payload, input, inst);
|
| 1731 |
+
return;
|
| 1732 |
+
};
|
| 1733 |
+
});
|
| 1734 |
+
function handleRefineResult(result, payload, input, inst) {
|
| 1735 |
+
if (!result) {
|
| 1736 |
+
const _iss = {
|
| 1737 |
+
code: "custom",
|
| 1738 |
+
input,
|
| 1739 |
+
inst, // incorporates params.error into issue reporting
|
| 1740 |
+
path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
|
| 1741 |
+
continue: !inst._zod.def.abort,
|
| 1742 |
+
// params: inst._zod.def.params,
|
| 1743 |
+
};
|
| 1744 |
+
if (inst._zod.def.params)
|
| 1745 |
+
_iss.params = inst._zod.def.params;
|
| 1746 |
+
payload.issues.push(util.issue(_iss));
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as checks from "./checks.cjs";
|
| 2 |
+
import * as core from "./core.cjs";
|
| 3 |
+
import type * as errors from "./errors.cjs";
|
| 4 |
+
import type { StandardSchemaV1 } from "./standard-schema.cjs";
|
| 5 |
+
import * as util from "./util.cjs";
|
| 6 |
+
import { version } from "./versions.cjs";
|
| 7 |
+
export interface ParseContext<T extends errors.$ZodIssueBase = never> {
|
| 8 |
+
/** Customize error messages. */
|
| 9 |
+
readonly error?: errors.$ZodErrorMap<T>;
|
| 10 |
+
/** Include the `input` field in issue objects. Default `false`. */
|
| 11 |
+
readonly reportInput?: boolean;
|
| 12 |
+
/** Skip eval-based fast path. Default `false`. */
|
| 13 |
+
readonly jitless?: boolean;
|
| 14 |
+
}
|
| 15 |
+
/** @internal */
|
| 16 |
+
export interface ParseContextInternal<T extends errors.$ZodIssueBase = never> extends ParseContext<T> {
|
| 17 |
+
readonly async?: boolean | undefined;
|
| 18 |
+
}
|
| 19 |
+
export interface ParsePayload<T = unknown> {
|
| 20 |
+
value: T;
|
| 21 |
+
issues: errors.$ZodRawIssue[];
|
| 22 |
+
}
|
| 23 |
+
export type CheckFn<T> = (input: ParsePayload<T>) => util.MaybeAsync<void>;
|
| 24 |
+
export interface $ZodTypeDef {
|
| 25 |
+
type: "string" | "number" | "int" | "boolean" | "bigint" | "symbol" | "null" | "undefined" | "void" | "never" | "any" | "unknown" | "date" | "object" | "record" | "file" | "array" | "tuple" | "union" | "intersection" | "map" | "set" | "enum" | "literal" | "nullable" | "optional" | "nonoptional" | "success" | "transform" | "default" | "prefault" | "catch" | "nan" | "pipe" | "readonly" | "template_literal" | "promise" | "lazy" | "custom";
|
| 26 |
+
error?: errors.$ZodErrorMap<never> | undefined;
|
| 27 |
+
checks?: checks.$ZodCheck<never>[];
|
| 28 |
+
}
|
| 29 |
+
export interface _$ZodTypeInternals {
|
| 30 |
+
/** The `@zod/core` version of this schema */
|
| 31 |
+
version: typeof version;
|
| 32 |
+
/** Schema definition. */
|
| 33 |
+
def: $ZodTypeDef;
|
| 34 |
+
/** @internal Randomly generated ID for this schema. */
|
| 35 |
+
/** @internal List of deferred initializers. */
|
| 36 |
+
deferred: util.AnyFunc[] | undefined;
|
| 37 |
+
/** @internal Parses input and runs all checks (refinements). */
|
| 38 |
+
run(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
|
| 39 |
+
/** @internal Parses input, doesn't run checks. */
|
| 40 |
+
parse(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
|
| 41 |
+
/** @internal Stores identifiers for the set of traits implemented by this schema. */
|
| 42 |
+
traits: Set<string>;
|
| 43 |
+
/** @internal Indicates that a schema output type should be considered optional inside objects.
|
| 44 |
+
* @default Required
|
| 45 |
+
*/
|
| 46 |
+
/** @internal */
|
| 47 |
+
optin?: "optional" | undefined;
|
| 48 |
+
/** @internal */
|
| 49 |
+
optout?: "optional" | undefined;
|
| 50 |
+
/** @internal The set of literal values that will pass validation. Must be an exhaustive set. Used to determine optionality in z.record().
|
| 51 |
+
*
|
| 52 |
+
* Defined on: enum, const, literal, null, undefined
|
| 53 |
+
* Passthrough: optional, nullable, branded, default, catch, pipe
|
| 54 |
+
* Todo: unions?
|
| 55 |
+
*/
|
| 56 |
+
values?: util.PrimitiveSet | undefined;
|
| 57 |
+
/** @internal A set of literal discriminators used for the fast path in discriminated unions. */
|
| 58 |
+
propValues?: util.PropValues | undefined;
|
| 59 |
+
/** @internal This flag indicates that a schema validation can be represented with a regular expression. Used to determine allowable schemas in z.templateLiteral(). */
|
| 60 |
+
pattern: RegExp | undefined;
|
| 61 |
+
/** @internal The constructor function of this schema. */
|
| 62 |
+
constr: new (def: any) => $ZodType;
|
| 63 |
+
/** @internal A catchall object for bag metadata related to this schema. Commonly modified by checks using `onattach`. */
|
| 64 |
+
bag: Record<string, unknown>;
|
| 65 |
+
/** @internal The set of issues this schema might throw during type checking. */
|
| 66 |
+
isst: errors.$ZodIssueBase;
|
| 67 |
+
/** An optional method used to override `toJSONSchema` logic. */
|
| 68 |
+
toJSONSchema?: () => unknown;
|
| 69 |
+
/** @internal The parent of this schema. Only set during certain clone operations. */
|
| 70 |
+
parent?: $ZodType | undefined;
|
| 71 |
+
}
|
| 72 |
+
/** @internal */
|
| 73 |
+
export interface $ZodTypeInternals<out O = unknown, out I = unknown> extends _$ZodTypeInternals {
|
| 74 |
+
/** @internal The inferred output type */
|
| 75 |
+
output: O;
|
| 76 |
+
/** @internal The inferred input type */
|
| 77 |
+
input: I;
|
| 78 |
+
}
|
| 79 |
+
export type $ZodStandardSchema<T> = StandardSchemaV1.Props<core.input<T>, core.output<T>>;
|
| 80 |
+
export type SomeType = {
|
| 81 |
+
_zod: _$ZodTypeInternals;
|
| 82 |
+
};
|
| 83 |
+
export interface $ZodType<O = unknown, I = unknown, Internals extends $ZodTypeInternals<O, I> = $ZodTypeInternals<O, I>> {
|
| 84 |
+
_zod: Internals;
|
| 85 |
+
"~standard": $ZodStandardSchema<this>;
|
| 86 |
+
}
|
| 87 |
+
export interface _$ZodType<T extends $ZodTypeInternals = $ZodTypeInternals> extends $ZodType<T["output"], T["input"], T> {
|
| 88 |
+
}
|
| 89 |
+
export declare const $ZodType: core.$constructor<$ZodType>;
|
| 90 |
+
export { clone } from "./util.cjs";
|
| 91 |
+
export interface $ZodStringDef extends $ZodTypeDef {
|
| 92 |
+
type: "string";
|
| 93 |
+
coerce?: boolean;
|
| 94 |
+
checks?: checks.$ZodCheck<string>[];
|
| 95 |
+
}
|
| 96 |
+
export interface $ZodStringInternals<Input> extends $ZodTypeInternals<string, Input> {
|
| 97 |
+
def: $ZodStringDef;
|
| 98 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 99 |
+
pattern: RegExp;
|
| 100 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 101 |
+
isst: errors.$ZodIssueInvalidType;
|
| 102 |
+
bag: util.LoosePartial<{
|
| 103 |
+
minimum: number;
|
| 104 |
+
maximum: number;
|
| 105 |
+
patterns: Set<RegExp>;
|
| 106 |
+
format: string;
|
| 107 |
+
contentEncoding: string;
|
| 108 |
+
}>;
|
| 109 |
+
}
|
| 110 |
+
export interface $ZodString<Input = unknown> extends _$ZodType<$ZodStringInternals<Input>> {
|
| 111 |
+
}
|
| 112 |
+
export declare const $ZodString: core.$constructor<$ZodString>;
|
| 113 |
+
export interface $ZodStringFormatDef<Format extends string = string> extends $ZodStringDef, checks.$ZodCheckStringFormatDef<Format> {
|
| 114 |
+
}
|
| 115 |
+
export interface $ZodStringFormatInternals<Format extends string = string> extends $ZodStringInternals<string>, checks.$ZodCheckStringFormatInternals {
|
| 116 |
+
def: $ZodStringFormatDef<Format>;
|
| 117 |
+
}
|
| 118 |
+
export interface $ZodStringFormat<Format extends string = string> extends $ZodType {
|
| 119 |
+
_zod: $ZodStringFormatInternals<Format>;
|
| 120 |
+
}
|
| 121 |
+
export declare const $ZodStringFormat: core.$constructor<$ZodStringFormat>;
|
| 122 |
+
export interface $ZodGUIDDef extends $ZodStringFormatDef<"guid"> {
|
| 123 |
+
}
|
| 124 |
+
export interface $ZodGUIDInternals extends $ZodStringFormatInternals<"guid"> {
|
| 125 |
+
}
|
| 126 |
+
export interface $ZodGUID extends $ZodType {
|
| 127 |
+
_zod: $ZodGUIDInternals;
|
| 128 |
+
}
|
| 129 |
+
export declare const $ZodGUID: core.$constructor<$ZodGUID>;
|
| 130 |
+
export interface $ZodUUIDDef extends $ZodStringFormatDef<"uuid"> {
|
| 131 |
+
version?: "v1" | "v2" | "v3" | "v4" | "v5" | "v6" | "v7" | "v8";
|
| 132 |
+
}
|
| 133 |
+
export interface $ZodUUIDInternals extends $ZodStringFormatInternals<"uuid"> {
|
| 134 |
+
def: $ZodUUIDDef;
|
| 135 |
+
}
|
| 136 |
+
export interface $ZodUUID extends $ZodType {
|
| 137 |
+
_zod: $ZodUUIDInternals;
|
| 138 |
+
}
|
| 139 |
+
export declare const $ZodUUID: core.$constructor<$ZodUUID>;
|
| 140 |
+
export interface $ZodEmailDef extends $ZodStringFormatDef<"email"> {
|
| 141 |
+
}
|
| 142 |
+
export interface $ZodEmailInternals extends $ZodStringFormatInternals<"email"> {
|
| 143 |
+
}
|
| 144 |
+
export interface $ZodEmail extends $ZodType {
|
| 145 |
+
_zod: $ZodEmailInternals;
|
| 146 |
+
}
|
| 147 |
+
export declare const $ZodEmail: core.$constructor<$ZodEmail>;
|
| 148 |
+
export interface $ZodURLDef extends $ZodStringFormatDef<"url"> {
|
| 149 |
+
hostname?: RegExp | undefined;
|
| 150 |
+
protocol?: RegExp | undefined;
|
| 151 |
+
}
|
| 152 |
+
export interface $ZodURLInternals extends $ZodStringFormatInternals<"url"> {
|
| 153 |
+
def: $ZodURLDef;
|
| 154 |
+
}
|
| 155 |
+
export interface $ZodURL extends $ZodType {
|
| 156 |
+
_zod: $ZodURLInternals;
|
| 157 |
+
}
|
| 158 |
+
export declare const $ZodURL: core.$constructor<$ZodURL>;
|
| 159 |
+
export interface $ZodEmojiDef extends $ZodStringFormatDef<"emoji"> {
|
| 160 |
+
}
|
| 161 |
+
export interface $ZodEmojiInternals extends $ZodStringFormatInternals<"emoji"> {
|
| 162 |
+
}
|
| 163 |
+
export interface $ZodEmoji extends $ZodType {
|
| 164 |
+
_zod: $ZodEmojiInternals;
|
| 165 |
+
}
|
| 166 |
+
export declare const $ZodEmoji: core.$constructor<$ZodEmoji>;
|
| 167 |
+
export interface $ZodNanoIDDef extends $ZodStringFormatDef<"nanoid"> {
|
| 168 |
+
}
|
| 169 |
+
export interface $ZodNanoIDInternals extends $ZodStringFormatInternals<"nanoid"> {
|
| 170 |
+
}
|
| 171 |
+
export interface $ZodNanoID extends $ZodType {
|
| 172 |
+
_zod: $ZodNanoIDInternals;
|
| 173 |
+
}
|
| 174 |
+
export declare const $ZodNanoID: core.$constructor<$ZodNanoID>;
|
| 175 |
+
export interface $ZodCUIDDef extends $ZodStringFormatDef<"cuid"> {
|
| 176 |
+
}
|
| 177 |
+
export interface $ZodCUIDInternals extends $ZodStringFormatInternals<"cuid"> {
|
| 178 |
+
}
|
| 179 |
+
export interface $ZodCUID extends $ZodType {
|
| 180 |
+
_zod: $ZodCUIDInternals;
|
| 181 |
+
}
|
| 182 |
+
export declare const $ZodCUID: core.$constructor<$ZodCUID>;
|
| 183 |
+
export interface $ZodCUID2Def extends $ZodStringFormatDef<"cuid2"> {
|
| 184 |
+
}
|
| 185 |
+
export interface $ZodCUID2Internals extends $ZodStringFormatInternals<"cuid2"> {
|
| 186 |
+
}
|
| 187 |
+
export interface $ZodCUID2 extends $ZodType {
|
| 188 |
+
_zod: $ZodCUID2Internals;
|
| 189 |
+
}
|
| 190 |
+
export declare const $ZodCUID2: core.$constructor<$ZodCUID2>;
|
| 191 |
+
export interface $ZodULIDDef extends $ZodStringFormatDef<"ulid"> {
|
| 192 |
+
}
|
| 193 |
+
export interface $ZodULIDInternals extends $ZodStringFormatInternals<"ulid"> {
|
| 194 |
+
}
|
| 195 |
+
export interface $ZodULID extends $ZodType {
|
| 196 |
+
_zod: $ZodULIDInternals;
|
| 197 |
+
}
|
| 198 |
+
export declare const $ZodULID: core.$constructor<$ZodULID>;
|
| 199 |
+
export interface $ZodXIDDef extends $ZodStringFormatDef<"xid"> {
|
| 200 |
+
}
|
| 201 |
+
export interface $ZodXIDInternals extends $ZodStringFormatInternals<"xid"> {
|
| 202 |
+
}
|
| 203 |
+
export interface $ZodXID extends $ZodType {
|
| 204 |
+
_zod: $ZodXIDInternals;
|
| 205 |
+
}
|
| 206 |
+
export declare const $ZodXID: core.$constructor<$ZodXID>;
|
| 207 |
+
export interface $ZodKSUIDDef extends $ZodStringFormatDef<"ksuid"> {
|
| 208 |
+
}
|
| 209 |
+
export interface $ZodKSUIDInternals extends $ZodStringFormatInternals<"ksuid"> {
|
| 210 |
+
}
|
| 211 |
+
export interface $ZodKSUID extends $ZodType {
|
| 212 |
+
_zod: $ZodKSUIDInternals;
|
| 213 |
+
}
|
| 214 |
+
export declare const $ZodKSUID: core.$constructor<$ZodKSUID>;
|
| 215 |
+
export interface $ZodISODateTimeDef extends $ZodStringFormatDef<"datetime"> {
|
| 216 |
+
precision: number | null;
|
| 217 |
+
offset: boolean;
|
| 218 |
+
local: boolean;
|
| 219 |
+
}
|
| 220 |
+
export interface $ZodISODateTimeInternals extends $ZodStringFormatInternals {
|
| 221 |
+
def: $ZodISODateTimeDef;
|
| 222 |
+
}
|
| 223 |
+
export interface $ZodISODateTime extends $ZodType {
|
| 224 |
+
_zod: $ZodISODateTimeInternals;
|
| 225 |
+
}
|
| 226 |
+
export declare const $ZodISODateTime: core.$constructor<$ZodISODateTime>;
|
| 227 |
+
export interface $ZodISODateDef extends $ZodStringFormatDef<"date"> {
|
| 228 |
+
}
|
| 229 |
+
export interface $ZodISODateInternals extends $ZodStringFormatInternals<"date"> {
|
| 230 |
+
}
|
| 231 |
+
export interface $ZodISODate extends $ZodType {
|
| 232 |
+
_zod: $ZodISODateInternals;
|
| 233 |
+
}
|
| 234 |
+
export declare const $ZodISODate: core.$constructor<$ZodISODate>;
|
| 235 |
+
export interface $ZodISOTimeDef extends $ZodStringFormatDef<"time"> {
|
| 236 |
+
precision?: number | null;
|
| 237 |
+
}
|
| 238 |
+
export interface $ZodISOTimeInternals extends $ZodStringFormatInternals<"time"> {
|
| 239 |
+
def: $ZodISOTimeDef;
|
| 240 |
+
}
|
| 241 |
+
export interface $ZodISOTime extends $ZodType {
|
| 242 |
+
_zod: $ZodISOTimeInternals;
|
| 243 |
+
}
|
| 244 |
+
export declare const $ZodISOTime: core.$constructor<$ZodISOTime>;
|
| 245 |
+
export interface $ZodISODurationDef extends $ZodStringFormatDef<"duration"> {
|
| 246 |
+
}
|
| 247 |
+
export interface $ZodISODurationInternals extends $ZodStringFormatInternals<"duration"> {
|
| 248 |
+
}
|
| 249 |
+
export interface $ZodISODuration extends $ZodType {
|
| 250 |
+
_zod: $ZodISODurationInternals;
|
| 251 |
+
}
|
| 252 |
+
export declare const $ZodISODuration: core.$constructor<$ZodISODuration>;
|
| 253 |
+
export interface $ZodIPv4Def extends $ZodStringFormatDef<"ipv4"> {
|
| 254 |
+
version?: "v4";
|
| 255 |
+
}
|
| 256 |
+
export interface $ZodIPv4Internals extends $ZodStringFormatInternals<"ipv4"> {
|
| 257 |
+
def: $ZodIPv4Def;
|
| 258 |
+
}
|
| 259 |
+
export interface $ZodIPv4 extends $ZodType {
|
| 260 |
+
_zod: $ZodIPv4Internals;
|
| 261 |
+
}
|
| 262 |
+
export declare const $ZodIPv4: core.$constructor<$ZodIPv4>;
|
| 263 |
+
export interface $ZodIPv6Def extends $ZodStringFormatDef<"ipv6"> {
|
| 264 |
+
version?: "v6";
|
| 265 |
+
}
|
| 266 |
+
export interface $ZodIPv6Internals extends $ZodStringFormatInternals<"ipv6"> {
|
| 267 |
+
def: $ZodIPv6Def;
|
| 268 |
+
}
|
| 269 |
+
export interface $ZodIPv6 extends $ZodType {
|
| 270 |
+
_zod: $ZodIPv6Internals;
|
| 271 |
+
}
|
| 272 |
+
export declare const $ZodIPv6: core.$constructor<$ZodIPv6>;
|
| 273 |
+
export interface $ZodCIDRv4Def extends $ZodStringFormatDef<"cidrv4"> {
|
| 274 |
+
version?: "v4";
|
| 275 |
+
}
|
| 276 |
+
export interface $ZodCIDRv4Internals extends $ZodStringFormatInternals<"cidrv4"> {
|
| 277 |
+
def: $ZodCIDRv4Def;
|
| 278 |
+
}
|
| 279 |
+
export interface $ZodCIDRv4 extends $ZodType {
|
| 280 |
+
_zod: $ZodCIDRv4Internals;
|
| 281 |
+
}
|
| 282 |
+
export declare const $ZodCIDRv4: core.$constructor<$ZodCIDRv4>;
|
| 283 |
+
export interface $ZodCIDRv6Def extends $ZodStringFormatDef<"cidrv6"> {
|
| 284 |
+
version?: "v6";
|
| 285 |
+
}
|
| 286 |
+
export interface $ZodCIDRv6Internals extends $ZodStringFormatInternals<"cidrv6"> {
|
| 287 |
+
def: $ZodCIDRv6Def;
|
| 288 |
+
}
|
| 289 |
+
export interface $ZodCIDRv6 extends $ZodType {
|
| 290 |
+
_zod: $ZodCIDRv6Internals;
|
| 291 |
+
}
|
| 292 |
+
export declare const $ZodCIDRv6: core.$constructor<$ZodCIDRv6>;
|
| 293 |
+
export declare function isValidBase64(data: string): boolean;
|
| 294 |
+
export interface $ZodBase64Def extends $ZodStringFormatDef<"base64"> {
|
| 295 |
+
}
|
| 296 |
+
export interface $ZodBase64Internals extends $ZodStringFormatInternals<"base64"> {
|
| 297 |
+
}
|
| 298 |
+
export interface $ZodBase64 extends $ZodType {
|
| 299 |
+
_zod: $ZodBase64Internals;
|
| 300 |
+
}
|
| 301 |
+
export declare const $ZodBase64: core.$constructor<$ZodBase64>;
|
| 302 |
+
export declare function isValidBase64URL(data: string): boolean;
|
| 303 |
+
export interface $ZodBase64URLDef extends $ZodStringFormatDef<"base64url"> {
|
| 304 |
+
}
|
| 305 |
+
export interface $ZodBase64URLInternals extends $ZodStringFormatInternals<"base64url"> {
|
| 306 |
+
}
|
| 307 |
+
export interface $ZodBase64URL extends $ZodType {
|
| 308 |
+
_zod: $ZodBase64URLInternals;
|
| 309 |
+
}
|
| 310 |
+
export declare const $ZodBase64URL: core.$constructor<$ZodBase64URL>;
|
| 311 |
+
export interface $ZodE164Def extends $ZodStringFormatDef<"e164"> {
|
| 312 |
+
}
|
| 313 |
+
export interface $ZodE164Internals extends $ZodStringFormatInternals<"e164"> {
|
| 314 |
+
}
|
| 315 |
+
export interface $ZodE164 extends $ZodType {
|
| 316 |
+
_zod: $ZodE164Internals;
|
| 317 |
+
}
|
| 318 |
+
export declare const $ZodE164: core.$constructor<$ZodE164>;
|
| 319 |
+
export declare function isValidJWT(token: string, algorithm?: util.JWTAlgorithm | null): boolean;
|
| 320 |
+
export interface $ZodJWTDef extends $ZodStringFormatDef<"jwt"> {
|
| 321 |
+
alg?: util.JWTAlgorithm | undefined;
|
| 322 |
+
}
|
| 323 |
+
export interface $ZodJWTInternals extends $ZodStringFormatInternals<"jwt"> {
|
| 324 |
+
def: $ZodJWTDef;
|
| 325 |
+
}
|
| 326 |
+
export interface $ZodJWT extends $ZodType {
|
| 327 |
+
_zod: $ZodJWTInternals;
|
| 328 |
+
}
|
| 329 |
+
export declare const $ZodJWT: core.$constructor<$ZodJWT>;
|
| 330 |
+
export interface $ZodCustomStringFormatDef<Format extends string = string> extends $ZodStringFormatDef<Format> {
|
| 331 |
+
fn: (val: string) => unknown;
|
| 332 |
+
}
|
| 333 |
+
export interface $ZodCustomStringFormatInternals<Format extends string = string> extends $ZodStringFormatInternals<Format> {
|
| 334 |
+
def: $ZodCustomStringFormatDef<Format>;
|
| 335 |
+
}
|
| 336 |
+
export interface $ZodCustomStringFormat<Format extends string = string> extends $ZodStringFormat<Format> {
|
| 337 |
+
_zod: $ZodCustomStringFormatInternals<Format>;
|
| 338 |
+
}
|
| 339 |
+
export declare const $ZodCustomStringFormat: core.$constructor<$ZodCustomStringFormat>;
|
| 340 |
+
export interface $ZodNumberDef extends $ZodTypeDef {
|
| 341 |
+
type: "number";
|
| 342 |
+
coerce?: boolean;
|
| 343 |
+
}
|
| 344 |
+
export interface $ZodNumberInternals<Input = unknown> extends $ZodTypeInternals<number, Input> {
|
| 345 |
+
def: $ZodNumberDef;
|
| 346 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 347 |
+
pattern: RegExp;
|
| 348 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 349 |
+
isst: errors.$ZodIssueInvalidType;
|
| 350 |
+
bag: util.LoosePartial<{
|
| 351 |
+
minimum: number;
|
| 352 |
+
maximum: number;
|
| 353 |
+
exclusiveMinimum: number;
|
| 354 |
+
exclusiveMaximum: number;
|
| 355 |
+
format: string;
|
| 356 |
+
pattern: RegExp;
|
| 357 |
+
}>;
|
| 358 |
+
}
|
| 359 |
+
export interface $ZodNumber<Input = unknown> extends $ZodType {
|
| 360 |
+
_zod: $ZodNumberInternals<Input>;
|
| 361 |
+
}
|
| 362 |
+
export declare const $ZodNumber: core.$constructor<$ZodNumber>;
|
| 363 |
+
export interface $ZodNumberFormatDef extends $ZodNumberDef, checks.$ZodCheckNumberFormatDef {
|
| 364 |
+
}
|
| 365 |
+
export interface $ZodNumberFormatInternals extends $ZodNumberInternals<number>, checks.$ZodCheckNumberFormatInternals {
|
| 366 |
+
def: $ZodNumberFormatDef;
|
| 367 |
+
isst: errors.$ZodIssueInvalidType;
|
| 368 |
+
}
|
| 369 |
+
export interface $ZodNumberFormat extends $ZodType {
|
| 370 |
+
_zod: $ZodNumberFormatInternals;
|
| 371 |
+
}
|
| 372 |
+
export declare const $ZodNumberFormat: core.$constructor<$ZodNumberFormat>;
|
| 373 |
+
export interface $ZodBooleanDef extends $ZodTypeDef {
|
| 374 |
+
type: "boolean";
|
| 375 |
+
coerce?: boolean;
|
| 376 |
+
checks?: checks.$ZodCheck<boolean>[];
|
| 377 |
+
}
|
| 378 |
+
export interface $ZodBooleanInternals<T = unknown> extends $ZodTypeInternals<boolean, T> {
|
| 379 |
+
pattern: RegExp;
|
| 380 |
+
def: $ZodBooleanDef;
|
| 381 |
+
isst: errors.$ZodIssueInvalidType;
|
| 382 |
+
}
|
| 383 |
+
export interface $ZodBoolean<T = unknown> extends $ZodType {
|
| 384 |
+
_zod: $ZodBooleanInternals<T>;
|
| 385 |
+
}
|
| 386 |
+
export declare const $ZodBoolean: core.$constructor<$ZodBoolean>;
|
| 387 |
+
export interface $ZodBigIntDef extends $ZodTypeDef {
|
| 388 |
+
type: "bigint";
|
| 389 |
+
coerce?: boolean;
|
| 390 |
+
}
|
| 391 |
+
export interface $ZodBigIntInternals<T = unknown> extends $ZodTypeInternals<bigint, T> {
|
| 392 |
+
pattern: RegExp;
|
| 393 |
+
/** @internal Internal API, use with caution */
|
| 394 |
+
def: $ZodBigIntDef;
|
| 395 |
+
isst: errors.$ZodIssueInvalidType;
|
| 396 |
+
bag: util.LoosePartial<{
|
| 397 |
+
minimum: bigint;
|
| 398 |
+
maximum: bigint;
|
| 399 |
+
format: string;
|
| 400 |
+
}>;
|
| 401 |
+
}
|
| 402 |
+
export interface $ZodBigInt<T = unknown> extends $ZodType {
|
| 403 |
+
_zod: $ZodBigIntInternals<T>;
|
| 404 |
+
}
|
| 405 |
+
export declare const $ZodBigInt: core.$constructor<$ZodBigInt>;
|
| 406 |
+
export interface $ZodBigIntFormatDef extends $ZodBigIntDef, checks.$ZodCheckBigIntFormatDef {
|
| 407 |
+
check: "bigint_format";
|
| 408 |
+
}
|
| 409 |
+
export interface $ZodBigIntFormatInternals extends $ZodBigIntInternals<bigint>, checks.$ZodCheckBigIntFormatInternals {
|
| 410 |
+
def: $ZodBigIntFormatDef;
|
| 411 |
+
}
|
| 412 |
+
export interface $ZodBigIntFormat extends $ZodType {
|
| 413 |
+
_zod: $ZodBigIntFormatInternals;
|
| 414 |
+
}
|
| 415 |
+
export declare const $ZodBigIntFormat: core.$constructor<$ZodBigIntFormat>;
|
| 416 |
+
export interface $ZodSymbolDef extends $ZodTypeDef {
|
| 417 |
+
type: "symbol";
|
| 418 |
+
}
|
| 419 |
+
export interface $ZodSymbolInternals extends $ZodTypeInternals<symbol, symbol> {
|
| 420 |
+
def: $ZodSymbolDef;
|
| 421 |
+
isst: errors.$ZodIssueInvalidType;
|
| 422 |
+
}
|
| 423 |
+
export interface $ZodSymbol extends $ZodType {
|
| 424 |
+
_zod: $ZodSymbolInternals;
|
| 425 |
+
}
|
| 426 |
+
export declare const $ZodSymbol: core.$constructor<$ZodSymbol>;
|
| 427 |
+
export interface $ZodUndefinedDef extends $ZodTypeDef {
|
| 428 |
+
type: "undefined";
|
| 429 |
+
}
|
| 430 |
+
export interface $ZodUndefinedInternals extends $ZodTypeInternals<undefined, undefined> {
|
| 431 |
+
pattern: RegExp;
|
| 432 |
+
def: $ZodUndefinedDef;
|
| 433 |
+
values: util.PrimitiveSet;
|
| 434 |
+
isst: errors.$ZodIssueInvalidType;
|
| 435 |
+
}
|
| 436 |
+
export interface $ZodUndefined extends $ZodType {
|
| 437 |
+
_zod: $ZodUndefinedInternals;
|
| 438 |
+
}
|
| 439 |
+
export declare const $ZodUndefined: core.$constructor<$ZodUndefined>;
|
| 440 |
+
export interface $ZodNullDef extends $ZodTypeDef {
|
| 441 |
+
type: "null";
|
| 442 |
+
}
|
| 443 |
+
export interface $ZodNullInternals extends $ZodTypeInternals<null, null> {
|
| 444 |
+
pattern: RegExp;
|
| 445 |
+
def: $ZodNullDef;
|
| 446 |
+
values: util.PrimitiveSet;
|
| 447 |
+
isst: errors.$ZodIssueInvalidType;
|
| 448 |
+
}
|
| 449 |
+
export interface $ZodNull extends $ZodType {
|
| 450 |
+
_zod: $ZodNullInternals;
|
| 451 |
+
}
|
| 452 |
+
export declare const $ZodNull: core.$constructor<$ZodNull>;
|
| 453 |
+
export interface $ZodAnyDef extends $ZodTypeDef {
|
| 454 |
+
type: "any";
|
| 455 |
+
}
|
| 456 |
+
export interface $ZodAnyInternals extends $ZodTypeInternals<any, any> {
|
| 457 |
+
def: $ZodAnyDef;
|
| 458 |
+
isst: never;
|
| 459 |
+
}
|
| 460 |
+
export interface $ZodAny extends $ZodType {
|
| 461 |
+
_zod: $ZodAnyInternals;
|
| 462 |
+
}
|
| 463 |
+
export declare const $ZodAny: core.$constructor<$ZodAny>;
|
| 464 |
+
export interface $ZodUnknownDef extends $ZodTypeDef {
|
| 465 |
+
type: "unknown";
|
| 466 |
+
}
|
| 467 |
+
export interface $ZodUnknownInternals extends $ZodTypeInternals<unknown, unknown> {
|
| 468 |
+
def: $ZodUnknownDef;
|
| 469 |
+
isst: never;
|
| 470 |
+
}
|
| 471 |
+
export interface $ZodUnknown extends $ZodType {
|
| 472 |
+
_zod: $ZodUnknownInternals;
|
| 473 |
+
}
|
| 474 |
+
export declare const $ZodUnknown: core.$constructor<$ZodUnknown>;
|
| 475 |
+
export interface $ZodNeverDef extends $ZodTypeDef {
|
| 476 |
+
type: "never";
|
| 477 |
+
}
|
| 478 |
+
export interface $ZodNeverInternals extends $ZodTypeInternals<never, never> {
|
| 479 |
+
def: $ZodNeverDef;
|
| 480 |
+
isst: errors.$ZodIssueInvalidType;
|
| 481 |
+
}
|
| 482 |
+
export interface $ZodNever extends $ZodType {
|
| 483 |
+
_zod: $ZodNeverInternals;
|
| 484 |
+
}
|
| 485 |
+
export declare const $ZodNever: core.$constructor<$ZodNever>;
|
| 486 |
+
export interface $ZodVoidDef extends $ZodTypeDef {
|
| 487 |
+
type: "void";
|
| 488 |
+
}
|
| 489 |
+
export interface $ZodVoidInternals extends $ZodTypeInternals<void, void> {
|
| 490 |
+
def: $ZodVoidDef;
|
| 491 |
+
isst: errors.$ZodIssueInvalidType;
|
| 492 |
+
}
|
| 493 |
+
export interface $ZodVoid extends $ZodType {
|
| 494 |
+
_zod: $ZodVoidInternals;
|
| 495 |
+
}
|
| 496 |
+
export declare const $ZodVoid: core.$constructor<$ZodVoid>;
|
| 497 |
+
export interface $ZodDateDef extends $ZodTypeDef {
|
| 498 |
+
type: "date";
|
| 499 |
+
coerce?: boolean;
|
| 500 |
+
}
|
| 501 |
+
export interface $ZodDateInternals<T = unknown> extends $ZodTypeInternals<Date, T> {
|
| 502 |
+
def: $ZodDateDef;
|
| 503 |
+
isst: errors.$ZodIssueInvalidType;
|
| 504 |
+
bag: util.LoosePartial<{
|
| 505 |
+
minimum: Date;
|
| 506 |
+
maximum: Date;
|
| 507 |
+
format: string;
|
| 508 |
+
}>;
|
| 509 |
+
}
|
| 510 |
+
export interface $ZodDate<T = unknown> extends $ZodType {
|
| 511 |
+
_zod: $ZodDateInternals<T>;
|
| 512 |
+
}
|
| 513 |
+
export declare const $ZodDate: core.$constructor<$ZodDate>;
|
| 514 |
+
export interface $ZodArrayDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 515 |
+
type: "array";
|
| 516 |
+
element: T;
|
| 517 |
+
}
|
| 518 |
+
export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$ZodTypeInternals {
|
| 519 |
+
def: $ZodArrayDef<T>;
|
| 520 |
+
isst: errors.$ZodIssueInvalidType;
|
| 521 |
+
output: core.output<T>[];
|
| 522 |
+
input: core.input<T>[];
|
| 523 |
+
}
|
| 524 |
+
export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {
|
| 525 |
+
}
|
| 526 |
+
export declare const $ZodArray: core.$constructor<$ZodArray>;
|
| 527 |
+
type OptionalOutSchema = {
|
| 528 |
+
_zod: {
|
| 529 |
+
optout: "optional";
|
| 530 |
+
};
|
| 531 |
+
};
|
| 532 |
+
type OptionalInSchema = {
|
| 533 |
+
_zod: {
|
| 534 |
+
optin: "optional";
|
| 535 |
+
};
|
| 536 |
+
};
|
| 537 |
+
export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? util.IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, core.output<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
| 538 |
+
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? never : k]: T[k]["_zod"]["output"];
|
| 539 |
+
} & {
|
| 540 |
+
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? k : never]?: T[k]["_zod"]["output"];
|
| 541 |
+
} & Extra>;
|
| 542 |
+
export type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? util.IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, core.input<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
| 543 |
+
-readonly [k in keyof T as T[k] extends OptionalInSchema ? never : k]: T[k]["_zod"]["input"];
|
| 544 |
+
} & {
|
| 545 |
+
-readonly [k in keyof T as T[k] extends OptionalInSchema ? k : never]?: T[k]["_zod"]["input"];
|
| 546 |
+
} & Extra>;
|
| 547 |
+
export type $ZodObjectConfig = {
|
| 548 |
+
out: Record<string, unknown>;
|
| 549 |
+
in: Record<string, unknown>;
|
| 550 |
+
};
|
| 551 |
+
export type $loose = {
|
| 552 |
+
out: Record<string, unknown>;
|
| 553 |
+
in: Record<string, unknown>;
|
| 554 |
+
};
|
| 555 |
+
export type $strict = {
|
| 556 |
+
out: {};
|
| 557 |
+
in: {};
|
| 558 |
+
};
|
| 559 |
+
export type $strip = {
|
| 560 |
+
out: {};
|
| 561 |
+
in: {};
|
| 562 |
+
};
|
| 563 |
+
export type $catchall<T extends SomeType> = {
|
| 564 |
+
out: {
|
| 565 |
+
[k: string]: core.output<T>;
|
| 566 |
+
};
|
| 567 |
+
in: {
|
| 568 |
+
[k: string]: core.input<T>;
|
| 569 |
+
};
|
| 570 |
+
};
|
| 571 |
+
export type $ZodShape = Readonly<{
|
| 572 |
+
[k: string]: $ZodType;
|
| 573 |
+
}>;
|
| 574 |
+
export interface $ZodObjectDef<Shape extends $ZodShape = $ZodShape> extends $ZodTypeDef {
|
| 575 |
+
type: "object";
|
| 576 |
+
shape: Shape;
|
| 577 |
+
catchall?: $ZodType | undefined;
|
| 578 |
+
}
|
| 579 |
+
export interface $ZodObjectInternals<
|
| 580 |
+
/** @ts-ignore Cast variance */
|
| 581 |
+
out Shape extends Readonly<$ZodShape> = Readonly<$ZodShape>, out Config extends $ZodObjectConfig = $ZodObjectConfig> extends _$ZodTypeInternals {
|
| 582 |
+
def: $ZodObjectDef<Shape>;
|
| 583 |
+
config: Config;
|
| 584 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueUnrecognizedKeys;
|
| 585 |
+
propValues: util.PropValues;
|
| 586 |
+
output: $InferObjectOutput<Shape, Config["out"]>;
|
| 587 |
+
input: $InferObjectInput<Shape, Config["in"]>;
|
| 588 |
+
}
|
| 589 |
+
export type $ZodLooseShape = Record<string, any>;
|
| 590 |
+
export interface $ZodObject<
|
| 591 |
+
/** @ts-ignore Cast variance */
|
| 592 |
+
out Shape extends Readonly<$ZodShape> = Readonly<$ZodShape>, out Params extends $ZodObjectConfig = $ZodObjectConfig> extends $ZodType<any, any, $ZodObjectInternals<Shape, Params>> {
|
| 593 |
+
"~standard": $ZodStandardSchema<this>;
|
| 594 |
+
}
|
| 595 |
+
export declare const $ZodObject: core.$constructor<$ZodObject>;
|
| 596 |
+
export type $InferUnionOutput<T extends SomeType> = T extends any ? core.output<T> : never;
|
| 597 |
+
export type $InferUnionInput<T extends SomeType> = T extends any ? core.input<T> : never;
|
| 598 |
+
export interface $ZodUnionDef<Options extends readonly SomeType[] = readonly $ZodType[]> extends $ZodTypeDef {
|
| 599 |
+
type: "union";
|
| 600 |
+
options: Options;
|
| 601 |
+
}
|
| 602 |
+
type IsOptionalIn<T extends SomeType> = T extends OptionalInSchema ? true : false;
|
| 603 |
+
type IsOptionalOut<T extends SomeType> = T extends OptionalOutSchema ? true : false;
|
| 604 |
+
export interface $ZodUnionInternals<T extends readonly SomeType[] = readonly $ZodType[]> extends _$ZodTypeInternals {
|
| 605 |
+
def: $ZodUnionDef<T>;
|
| 606 |
+
isst: errors.$ZodIssueInvalidUnion;
|
| 607 |
+
pattern: T[number]["_zod"]["pattern"];
|
| 608 |
+
values: T[number]["_zod"]["values"];
|
| 609 |
+
output: $InferUnionOutput<T[number]>;
|
| 610 |
+
input: $InferUnionInput<T[number]>;
|
| 611 |
+
optin: IsOptionalIn<T[number]> extends false ? "optional" | undefined : "optional";
|
| 612 |
+
optout: IsOptionalOut<T[number]> extends false ? "optional" | undefined : "optional";
|
| 613 |
+
}
|
| 614 |
+
export interface $ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType<any, any, $ZodUnionInternals<T>> {
|
| 615 |
+
_zod: $ZodUnionInternals<T>;
|
| 616 |
+
}
|
| 617 |
+
export declare const $ZodUnion: core.$constructor<$ZodUnion>;
|
| 618 |
+
export interface $ZodDiscriminatedUnionDef<Options extends readonly SomeType[] = readonly $ZodType[]> extends $ZodUnionDef<Options> {
|
| 619 |
+
discriminator: string;
|
| 620 |
+
unionFallback?: boolean;
|
| 621 |
+
}
|
| 622 |
+
export interface $ZodDiscriminatedUnionInternals<Options extends readonly SomeType[] = readonly $ZodType[]> extends $ZodUnionInternals<Options> {
|
| 623 |
+
def: $ZodDiscriminatedUnionDef<Options>;
|
| 624 |
+
propValues: util.PropValues;
|
| 625 |
+
}
|
| 626 |
+
export interface $ZodDiscriminatedUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType {
|
| 627 |
+
_zod: $ZodDiscriminatedUnionInternals<T>;
|
| 628 |
+
}
|
| 629 |
+
export declare const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion>;
|
| 630 |
+
export interface $ZodIntersectionDef<Left extends SomeType = $ZodType, Right extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 631 |
+
type: "intersection";
|
| 632 |
+
left: Left;
|
| 633 |
+
right: Right;
|
| 634 |
+
}
|
| 635 |
+
export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<A> & core.output<B>, core.input<A> & core.input<B>> {
|
| 636 |
+
def: $ZodIntersectionDef<A, B>;
|
| 637 |
+
isst: never;
|
| 638 |
+
optin: A["_zod"]["optin"] | B["_zod"]["optin"];
|
| 639 |
+
optout: A["_zod"]["optout"] | B["_zod"]["optout"];
|
| 640 |
+
}
|
| 641 |
+
export interface $ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
| 642 |
+
_zod: $ZodIntersectionInternals<A, B>;
|
| 643 |
+
}
|
| 644 |
+
export declare const $ZodIntersection: core.$constructor<$ZodIntersection>;
|
| 645 |
+
export interface $ZodTupleDef<T extends util.TupleItems = readonly $ZodType[], Rest extends SomeType | null = $ZodType | null> extends $ZodTypeDef {
|
| 646 |
+
type: "tuple";
|
| 647 |
+
items: T;
|
| 648 |
+
rest: Rest;
|
| 649 |
+
}
|
| 650 |
+
export type $InferTupleInputType<T extends util.TupleItems, Rest extends SomeType | null> = [
|
| 651 |
+
...TupleInputTypeWithOptionals<T>,
|
| 652 |
+
...(Rest extends SomeType ? core.input<Rest>[] : [])
|
| 653 |
+
];
|
| 654 |
+
type TupleInputTypeNoOptionals<T extends util.TupleItems> = {
|
| 655 |
+
[k in keyof T]: core.input<T[k]>;
|
| 656 |
+
};
|
| 657 |
+
type TupleInputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
|
| 658 |
+
...infer Prefix extends SomeType[],
|
| 659 |
+
infer Tail extends SomeType
|
| 660 |
+
] ? Tail["_zod"]["optin"] extends "optional" ? [...TupleInputTypeWithOptionals<Prefix>, core.input<Tail>?] : TupleInputTypeNoOptionals<T> : [];
|
| 661 |
+
export type $InferTupleOutputType<T extends util.TupleItems, Rest extends SomeType | null> = [
|
| 662 |
+
...TupleOutputTypeWithOptionals<T>,
|
| 663 |
+
...(Rest extends SomeType ? core.output<Rest>[] : [])
|
| 664 |
+
];
|
| 665 |
+
type TupleOutputTypeNoOptionals<T extends util.TupleItems> = {
|
| 666 |
+
[k in keyof T]: core.output<T[k]>;
|
| 667 |
+
};
|
| 668 |
+
type TupleOutputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
|
| 669 |
+
...infer Prefix extends SomeType[],
|
| 670 |
+
infer Tail extends SomeType
|
| 671 |
+
] ? Tail["_zod"]["optout"] extends "optional" ? [...TupleOutputTypeWithOptionals<Prefix>, core.output<Tail>?] : TupleOutputTypeNoOptionals<T> : [];
|
| 672 |
+
export interface $ZodTupleInternals<T extends util.TupleItems = readonly $ZodType[], Rest extends SomeType | null = $ZodType | null> extends $ZodTypeInternals<$InferTupleOutputType<T, Rest>, $InferTupleInputType<T, Rest>> {
|
| 673 |
+
def: $ZodTupleDef<T, Rest>;
|
| 674 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueTooBig<unknown[]> | errors.$ZodIssueTooSmall<unknown[]>;
|
| 675 |
+
}
|
| 676 |
+
export interface $ZodTuple<T extends util.TupleItems = readonly $ZodType[], Rest extends SomeType | null = $ZodType | null> extends $ZodType {
|
| 677 |
+
_zod: $ZodTupleInternals<T, Rest>;
|
| 678 |
+
}
|
| 679 |
+
export declare const $ZodTuple: core.$constructor<$ZodTuple>;
|
| 680 |
+
export type $ZodRecordKey = $ZodType<string | number | symbol, string | number | symbol>;
|
| 681 |
+
export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 682 |
+
type: "record";
|
| 683 |
+
keyType: Key;
|
| 684 |
+
valueType: Value;
|
| 685 |
+
}
|
| 686 |
+
export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.output<Key>, core.output<Value>>> : Record<core.output<Key>, core.output<Value>>;
|
| 687 |
+
export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.input<Key>, core.input<Value>>> : Record<core.input<Key>, core.input<Value>>;
|
| 688 |
+
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
|
| 689 |
+
def: $ZodRecordDef<Key, Value>;
|
| 690 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
| 691 |
+
optin?: "optional" | undefined;
|
| 692 |
+
optout?: "optional" | undefined;
|
| 693 |
+
}
|
| 694 |
+
export type $partial = {
|
| 695 |
+
"~~partial": true;
|
| 696 |
+
};
|
| 697 |
+
export interface $ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodType {
|
| 698 |
+
_zod: $ZodRecordInternals<Key, Value>;
|
| 699 |
+
}
|
| 700 |
+
export declare const $ZodRecord: core.$constructor<$ZodRecord>;
|
| 701 |
+
export interface $ZodMapDef<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 702 |
+
type: "map";
|
| 703 |
+
keyType: Key;
|
| 704 |
+
valueType: Value;
|
| 705 |
+
}
|
| 706 |
+
export interface $ZodMapInternals<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodTypeInternals<Map<core.output<Key>, core.output<Value>>, Map<core.input<Key>, core.input<Value>>> {
|
| 707 |
+
def: $ZodMapDef<Key, Value>;
|
| 708 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey | errors.$ZodIssueInvalidElement<unknown>;
|
| 709 |
+
optin?: "optional" | undefined;
|
| 710 |
+
optout?: "optional" | undefined;
|
| 711 |
+
}
|
| 712 |
+
export interface $ZodMap<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodType {
|
| 713 |
+
_zod: $ZodMapInternals<Key, Value>;
|
| 714 |
+
}
|
| 715 |
+
export declare const $ZodMap: core.$constructor<$ZodMap>;
|
| 716 |
+
export interface $ZodSetDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 717 |
+
type: "set";
|
| 718 |
+
valueType: T;
|
| 719 |
+
}
|
| 720 |
+
export interface $ZodSetInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<Set<core.output<T>>, Set<core.input<T>>> {
|
| 721 |
+
def: $ZodSetDef<T>;
|
| 722 |
+
isst: errors.$ZodIssueInvalidType;
|
| 723 |
+
optin?: "optional" | undefined;
|
| 724 |
+
optout?: "optional" | undefined;
|
| 725 |
+
}
|
| 726 |
+
export interface $ZodSet<T extends SomeType = $ZodType> extends $ZodType {
|
| 727 |
+
_zod: $ZodSetInternals<T>;
|
| 728 |
+
}
|
| 729 |
+
export declare const $ZodSet: core.$constructor<$ZodSet>;
|
| 730 |
+
export type $InferEnumOutput<T extends util.EnumLike> = T[keyof T] & {};
|
| 731 |
+
export type $InferEnumInput<T extends util.EnumLike> = T[keyof T] & {};
|
| 732 |
+
export interface $ZodEnumDef<T extends util.EnumLike = util.EnumLike> extends $ZodTypeDef {
|
| 733 |
+
type: "enum";
|
| 734 |
+
entries: T;
|
| 735 |
+
}
|
| 736 |
+
export interface $ZodEnumInternals<
|
| 737 |
+
/** @ts-ignore Cast variance */
|
| 738 |
+
out T extends util.EnumLike = util.EnumLike> extends $ZodTypeInternals<$InferEnumOutput<T>, $InferEnumInput<T>> {
|
| 739 |
+
def: $ZodEnumDef<T>;
|
| 740 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 741 |
+
values: util.PrimitiveSet;
|
| 742 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 743 |
+
pattern: RegExp;
|
| 744 |
+
isst: errors.$ZodIssueInvalidValue;
|
| 745 |
+
}
|
| 746 |
+
export interface $ZodEnum<T extends util.EnumLike = util.EnumLike> extends $ZodType {
|
| 747 |
+
_zod: $ZodEnumInternals<T>;
|
| 748 |
+
}
|
| 749 |
+
export declare const $ZodEnum: core.$constructor<$ZodEnum>;
|
| 750 |
+
export interface $ZodLiteralDef<T extends util.Literal> extends $ZodTypeDef {
|
| 751 |
+
type: "literal";
|
| 752 |
+
values: T[];
|
| 753 |
+
}
|
| 754 |
+
export interface $ZodLiteralInternals<T extends util.Literal = util.Literal> extends $ZodTypeInternals<T, T> {
|
| 755 |
+
def: $ZodLiteralDef<T>;
|
| 756 |
+
values: Set<T>;
|
| 757 |
+
pattern: RegExp;
|
| 758 |
+
isst: errors.$ZodIssueInvalidValue;
|
| 759 |
+
}
|
| 760 |
+
export interface $ZodLiteral<T extends util.Literal = util.Literal> extends $ZodType {
|
| 761 |
+
_zod: $ZodLiteralInternals<T>;
|
| 762 |
+
}
|
| 763 |
+
export declare const $ZodLiteral: core.$constructor<$ZodLiteral>;
|
| 764 |
+
declare global {
|
| 765 |
+
interface File {
|
| 766 |
+
}
|
| 767 |
+
}
|
| 768 |
+
export interface $ZodFileDef extends $ZodTypeDef {
|
| 769 |
+
type: "file";
|
| 770 |
+
}
|
| 771 |
+
export interface $ZodFileInternals extends $ZodTypeInternals<File, File> {
|
| 772 |
+
def: $ZodFileDef;
|
| 773 |
+
isst: errors.$ZodIssueInvalidType;
|
| 774 |
+
bag: util.LoosePartial<{
|
| 775 |
+
minimum: number;
|
| 776 |
+
maximum: number;
|
| 777 |
+
mime: util.MimeTypes[];
|
| 778 |
+
}>;
|
| 779 |
+
}
|
| 780 |
+
export interface $ZodFile extends $ZodType {
|
| 781 |
+
_zod: $ZodFileInternals;
|
| 782 |
+
}
|
| 783 |
+
export declare const $ZodFile: core.$constructor<$ZodFile>;
|
| 784 |
+
export interface $ZodTransformDef extends $ZodTypeDef {
|
| 785 |
+
type: "transform";
|
| 786 |
+
transform: (input: unknown, payload: ParsePayload<unknown>) => util.MaybeAsync<unknown>;
|
| 787 |
+
}
|
| 788 |
+
export interface $ZodTransformInternals<O = unknown, I = unknown> extends $ZodTypeInternals<O, I> {
|
| 789 |
+
def: $ZodTransformDef;
|
| 790 |
+
isst: never;
|
| 791 |
+
}
|
| 792 |
+
export interface $ZodTransform<O = unknown, I = unknown> extends $ZodType {
|
| 793 |
+
_zod: $ZodTransformInternals<O, I>;
|
| 794 |
+
}
|
| 795 |
+
export declare const $ZodTransform: core.$constructor<$ZodTransform>;
|
| 796 |
+
export interface $ZodOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 797 |
+
type: "optional";
|
| 798 |
+
innerType: T;
|
| 799 |
+
}
|
| 800 |
+
export interface $ZodOptionalInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T> | undefined, core.input<T> | undefined> {
|
| 801 |
+
def: $ZodOptionalDef<T>;
|
| 802 |
+
optin: "optional";
|
| 803 |
+
optout: "optional";
|
| 804 |
+
isst: never;
|
| 805 |
+
values: T["_zod"]["values"];
|
| 806 |
+
pattern: T["_zod"]["pattern"];
|
| 807 |
+
}
|
| 808 |
+
export interface $ZodOptional<T extends SomeType = $ZodType> extends $ZodType {
|
| 809 |
+
_zod: $ZodOptionalInternals<T>;
|
| 810 |
+
}
|
| 811 |
+
export declare const $ZodOptional: core.$constructor<$ZodOptional>;
|
| 812 |
+
export interface $ZodNullableDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 813 |
+
type: "nullable";
|
| 814 |
+
innerType: T;
|
| 815 |
+
}
|
| 816 |
+
export interface $ZodNullableInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T> | null, core.input<T> | null> {
|
| 817 |
+
def: $ZodNullableDef<T>;
|
| 818 |
+
optin: T["_zod"]["optin"];
|
| 819 |
+
optout: T["_zod"]["optout"];
|
| 820 |
+
isst: never;
|
| 821 |
+
values: T["_zod"]["values"];
|
| 822 |
+
pattern: T["_zod"]["pattern"];
|
| 823 |
+
}
|
| 824 |
+
export interface $ZodNullable<T extends SomeType = $ZodType> extends $ZodType {
|
| 825 |
+
_zod: $ZodNullableInternals<T>;
|
| 826 |
+
}
|
| 827 |
+
export declare const $ZodNullable: core.$constructor<$ZodNullable>;
|
| 828 |
+
export interface $ZodDefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 829 |
+
type: "default";
|
| 830 |
+
innerType: T;
|
| 831 |
+
/** The default value. May be a getter. */
|
| 832 |
+
defaultValue: util.NoUndefined<core.output<T>>;
|
| 833 |
+
}
|
| 834 |
+
export interface $ZodDefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
|
| 835 |
+
def: $ZodDefaultDef<T>;
|
| 836 |
+
optin: "optional";
|
| 837 |
+
optout?: "optional" | undefined;
|
| 838 |
+
isst: never;
|
| 839 |
+
values: T["_zod"]["values"];
|
| 840 |
+
}
|
| 841 |
+
export interface $ZodDefault<T extends SomeType = $ZodType> extends $ZodType {
|
| 842 |
+
_zod: $ZodDefaultInternals<T>;
|
| 843 |
+
}
|
| 844 |
+
export declare const $ZodDefault: core.$constructor<$ZodDefault>;
|
| 845 |
+
export interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 846 |
+
type: "prefault";
|
| 847 |
+
innerType: T;
|
| 848 |
+
/** The default value. May be a getter. */
|
| 849 |
+
defaultValue: core.input<T>;
|
| 850 |
+
}
|
| 851 |
+
export interface $ZodPrefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
|
| 852 |
+
def: $ZodPrefaultDef<T>;
|
| 853 |
+
optin: "optional";
|
| 854 |
+
optout?: "optional" | undefined;
|
| 855 |
+
isst: never;
|
| 856 |
+
values: T["_zod"]["values"];
|
| 857 |
+
}
|
| 858 |
+
export interface $ZodPrefault<T extends SomeType = $ZodType> extends $ZodType {
|
| 859 |
+
_zod: $ZodPrefaultInternals<T>;
|
| 860 |
+
}
|
| 861 |
+
export declare const $ZodPrefault: core.$constructor<$ZodPrefault>;
|
| 862 |
+
export interface $ZodNonOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 863 |
+
type: "nonoptional";
|
| 864 |
+
innerType: T;
|
| 865 |
+
}
|
| 866 |
+
export interface $ZodNonOptionalInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, util.NoUndefined<core.input<T>>> {
|
| 867 |
+
def: $ZodNonOptionalDef<T>;
|
| 868 |
+
isst: errors.$ZodIssueInvalidType;
|
| 869 |
+
values: T["_zod"]["values"];
|
| 870 |
+
optin: "optional" | undefined;
|
| 871 |
+
optout: "optional" | undefined;
|
| 872 |
+
}
|
| 873 |
+
export interface $ZodNonOptional<T extends SomeType = $ZodType> extends $ZodType {
|
| 874 |
+
_zod: $ZodNonOptionalInternals<T>;
|
| 875 |
+
}
|
| 876 |
+
export declare const $ZodNonOptional: core.$constructor<$ZodNonOptional>;
|
| 877 |
+
export interface $ZodSuccessDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 878 |
+
type: "success";
|
| 879 |
+
innerType: T;
|
| 880 |
+
}
|
| 881 |
+
export interface $ZodSuccessInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<boolean, core.input<T>> {
|
| 882 |
+
def: $ZodSuccessDef<T>;
|
| 883 |
+
isst: never;
|
| 884 |
+
optin: T["_zod"]["optin"];
|
| 885 |
+
optout: "optional" | undefined;
|
| 886 |
+
}
|
| 887 |
+
export interface $ZodSuccess<T extends SomeType = $ZodType> extends $ZodType {
|
| 888 |
+
_zod: $ZodSuccessInternals<T>;
|
| 889 |
+
}
|
| 890 |
+
export declare const $ZodSuccess: core.$constructor<$ZodSuccess>;
|
| 891 |
+
export interface $ZodCatchCtx extends ParsePayload {
|
| 892 |
+
/** @deprecated Use `ctx.issues` */
|
| 893 |
+
error: {
|
| 894 |
+
issues: errors.$ZodIssue[];
|
| 895 |
+
};
|
| 896 |
+
/** @deprecated Use `ctx.value` */
|
| 897 |
+
input: unknown;
|
| 898 |
+
}
|
| 899 |
+
export interface $ZodCatchDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 900 |
+
type: "catch";
|
| 901 |
+
innerType: T;
|
| 902 |
+
catchValue: (ctx: $ZodCatchCtx) => unknown;
|
| 903 |
+
}
|
| 904 |
+
export interface $ZodCatchInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, core.input<T> | util.Whatever> {
|
| 905 |
+
def: $ZodCatchDef<T>;
|
| 906 |
+
optin: T["_zod"]["optin"];
|
| 907 |
+
optout: T["_zod"]["optout"];
|
| 908 |
+
isst: never;
|
| 909 |
+
values: T["_zod"]["values"];
|
| 910 |
+
}
|
| 911 |
+
export interface $ZodCatch<T extends SomeType = $ZodType> extends $ZodType {
|
| 912 |
+
_zod: $ZodCatchInternals<T>;
|
| 913 |
+
}
|
| 914 |
+
export declare const $ZodCatch: core.$constructor<$ZodCatch>;
|
| 915 |
+
export interface $ZodNaNDef extends $ZodTypeDef {
|
| 916 |
+
type: "nan";
|
| 917 |
+
}
|
| 918 |
+
export interface $ZodNaNInternals extends $ZodTypeInternals<number, number> {
|
| 919 |
+
def: $ZodNaNDef;
|
| 920 |
+
isst: errors.$ZodIssueInvalidType;
|
| 921 |
+
}
|
| 922 |
+
export interface $ZodNaN extends $ZodType {
|
| 923 |
+
_zod: $ZodNaNInternals;
|
| 924 |
+
}
|
| 925 |
+
export declare const $ZodNaN: core.$constructor<$ZodNaN>;
|
| 926 |
+
export interface $ZodPipeDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 927 |
+
type: "pipe";
|
| 928 |
+
in: A;
|
| 929 |
+
out: B;
|
| 930 |
+
}
|
| 931 |
+
export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
|
| 932 |
+
def: $ZodPipeDef<A, B>;
|
| 933 |
+
isst: never;
|
| 934 |
+
values: A["_zod"]["values"];
|
| 935 |
+
optin: A["_zod"]["optin"];
|
| 936 |
+
optout: B["_zod"]["optout"];
|
| 937 |
+
}
|
| 938 |
+
export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
| 939 |
+
_zod: $ZodPipeInternals<A, B>;
|
| 940 |
+
}
|
| 941 |
+
export declare const $ZodPipe: core.$constructor<$ZodPipe>;
|
| 942 |
+
export interface $ZodReadonlyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 943 |
+
type: "readonly";
|
| 944 |
+
innerType: T;
|
| 945 |
+
}
|
| 946 |
+
export interface $ZodReadonlyInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.MakeReadonly<core.output<T>>, util.MakeReadonly<core.input<T>>> {
|
| 947 |
+
def: $ZodReadonlyDef<T>;
|
| 948 |
+
optin: T["_zod"]["optin"];
|
| 949 |
+
optout: T["_zod"]["optout"];
|
| 950 |
+
isst: never;
|
| 951 |
+
propValues: T["_zod"]["propValues"];
|
| 952 |
+
values: T["_zod"]["values"];
|
| 953 |
+
}
|
| 954 |
+
export interface $ZodReadonly<T extends SomeType = $ZodType> extends $ZodType {
|
| 955 |
+
_zod: $ZodReadonlyInternals<T>;
|
| 956 |
+
}
|
| 957 |
+
export declare const $ZodReadonly: core.$constructor<$ZodReadonly>;
|
| 958 |
+
export interface $ZodTemplateLiteralDef extends $ZodTypeDef {
|
| 959 |
+
type: "template_literal";
|
| 960 |
+
parts: $ZodTemplateLiteralPart[];
|
| 961 |
+
}
|
| 962 |
+
export interface $ZodTemplateLiteralInternals<Template extends string = string> extends $ZodTypeInternals<Template, Template> {
|
| 963 |
+
pattern: RegExp;
|
| 964 |
+
def: $ZodTemplateLiteralDef;
|
| 965 |
+
isst: errors.$ZodIssueInvalidType;
|
| 966 |
+
}
|
| 967 |
+
export interface $ZodTemplateLiteral<Template extends string = string> extends $ZodType {
|
| 968 |
+
_zod: $ZodTemplateLiteralInternals<Template>;
|
| 969 |
+
}
|
| 970 |
+
type LiteralPart = Exclude<util.Literal, symbol>;
|
| 971 |
+
interface SchemaPartInternals extends $ZodTypeInternals<LiteralPart, LiteralPart> {
|
| 972 |
+
pattern: RegExp;
|
| 973 |
+
}
|
| 974 |
+
interface SchemaPart extends $ZodType {
|
| 975 |
+
_zod: SchemaPartInternals;
|
| 976 |
+
}
|
| 977 |
+
export type $ZodTemplateLiteralPart = LiteralPart | SchemaPart;
|
| 978 |
+
type UndefinedToEmptyString<T> = T extends undefined ? "" : T;
|
| 979 |
+
type AppendToTemplateLiteral<Template extends string, Suffix extends LiteralPart | $ZodType> = Suffix extends LiteralPart ? `${Template}${UndefinedToEmptyString<Suffix>}` : Suffix extends $ZodType ? `${Template}${core.output<Suffix> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}` : never;
|
| 980 |
+
export type ConcatenateTupleOfStrings<T extends string[]> = T extends [
|
| 981 |
+
infer First extends string,
|
| 982 |
+
...infer Rest extends string[]
|
| 983 |
+
] ? Rest extends string[] ? First extends "" ? ConcatenateTupleOfStrings<Rest> : `${First}${ConcatenateTupleOfStrings<Rest>}` : never : "";
|
| 984 |
+
export type ConvertPartsToStringTuple<Parts extends $ZodTemplateLiteralPart[]> = {
|
| 985 |
+
[K in keyof Parts]: Parts[K] extends LiteralPart ? `${UndefinedToEmptyString<Parts[K]>}` : Parts[K] extends $ZodType ? `${core.output<Parts[K]> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}` : never;
|
| 986 |
+
};
|
| 987 |
+
export type ToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = ConcatenateTupleOfStrings<ConvertPartsToStringTuple<Parts>>;
|
| 988 |
+
export type $PartsToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = [] extends Parts ? `` : Parts extends [...infer Rest, infer Last extends $ZodTemplateLiteralPart] ? Rest extends $ZodTemplateLiteralPart[] ? AppendToTemplateLiteral<$PartsToTemplateLiteral<Rest>, Last> : never : never;
|
| 989 |
+
export declare const $ZodTemplateLiteral: core.$constructor<$ZodTemplateLiteral>;
|
| 990 |
+
export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 991 |
+
type: "promise";
|
| 992 |
+
innerType: T;
|
| 993 |
+
}
|
| 994 |
+
export interface $ZodPromiseInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, util.MaybeAsync<core.input<T>>> {
|
| 995 |
+
def: $ZodPromiseDef<T>;
|
| 996 |
+
isst: never;
|
| 997 |
+
}
|
| 998 |
+
export interface $ZodPromise<T extends SomeType = $ZodType> extends $ZodType {
|
| 999 |
+
_zod: $ZodPromiseInternals<T>;
|
| 1000 |
+
}
|
| 1001 |
+
export declare const $ZodPromise: core.$constructor<$ZodPromise>;
|
| 1002 |
+
export interface $ZodLazyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 1003 |
+
type: "lazy";
|
| 1004 |
+
getter: () => T;
|
| 1005 |
+
}
|
| 1006 |
+
export interface $ZodLazyInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, core.input<T>> {
|
| 1007 |
+
def: $ZodLazyDef<T>;
|
| 1008 |
+
isst: never;
|
| 1009 |
+
/** Auto-cached way to retrieve the inner schema */
|
| 1010 |
+
innerType: T;
|
| 1011 |
+
pattern: T["_zod"]["pattern"];
|
| 1012 |
+
propValues: T["_zod"]["propValues"];
|
| 1013 |
+
optin: T["_zod"]["optin"];
|
| 1014 |
+
optout: T["_zod"]["optout"];
|
| 1015 |
+
}
|
| 1016 |
+
export interface $ZodLazy<T extends SomeType = $ZodType> extends $ZodType {
|
| 1017 |
+
_zod: $ZodLazyInternals<T>;
|
| 1018 |
+
}
|
| 1019 |
+
export declare const $ZodLazy: core.$constructor<$ZodLazy>;
|
| 1020 |
+
export interface $ZodCustomDef<O = unknown> extends $ZodTypeDef, checks.$ZodCheckDef {
|
| 1021 |
+
type: "custom";
|
| 1022 |
+
check: "custom";
|
| 1023 |
+
path?: PropertyKey[] | undefined;
|
| 1024 |
+
error?: errors.$ZodErrorMap | undefined;
|
| 1025 |
+
params?: Record<string, any> | undefined;
|
| 1026 |
+
fn: (arg: O) => unknown;
|
| 1027 |
+
}
|
| 1028 |
+
export interface $ZodCustomInternals<O = unknown, I = unknown> extends $ZodTypeInternals<O, I>, checks.$ZodCheckInternals<O> {
|
| 1029 |
+
def: $ZodCustomDef;
|
| 1030 |
+
issc: errors.$ZodIssue;
|
| 1031 |
+
isst: never;
|
| 1032 |
+
bag: util.LoosePartial<{
|
| 1033 |
+
Class: typeof util.Class;
|
| 1034 |
+
}>;
|
| 1035 |
+
}
|
| 1036 |
+
export interface $ZodCustom<O = unknown, I = unknown> extends $ZodType {
|
| 1037 |
+
_zod: $ZodCustomInternals<O, I>;
|
| 1038 |
+
}
|
| 1039 |
+
export declare const $ZodCustom: core.$constructor<$ZodCustom>;
|
| 1040 |
+
export type $ZodTypes = $ZodString | $ZodNumber | $ZodBigInt | $ZodBoolean | $ZodDate | $ZodSymbol | $ZodUndefined | $ZodNullable | $ZodNull | $ZodAny | $ZodUnknown | $ZodNever | $ZodVoid | $ZodArray | $ZodObject | $ZodUnion | $ZodIntersection | $ZodTuple | $ZodRecord | $ZodMap | $ZodSet | $ZodLiteral | $ZodEnum | $ZodPromise | $ZodLazy | $ZodOptional | $ZodDefault | $ZodPrefault | $ZodTemplateLiteral | $ZodCustom | $ZodTransform | $ZodNonOptional | $ZodReadonly | $ZodNaN | $ZodPipe | $ZodSuccess | $ZodCatch | $ZodFile;
|
| 1041 |
+
export type $ZodStringFormatTypes = $ZodGUID | $ZodUUID | $ZodEmail | $ZodURL | $ZodEmoji | $ZodNanoID | $ZodCUID | $ZodCUID2 | $ZodULID | $ZodXID | $ZodKSUID | $ZodISODateTime | $ZodISODate | $ZodISOTime | $ZodISODuration | $ZodIPv4 | $ZodIPv6 | $ZodCIDRv4 | $ZodCIDRv6 | $ZodBase64 | $ZodBase64URL | $ZodE164 | $ZodJWT;
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/schemas.d.ts
ADDED
|
@@ -0,0 +1,1041 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as checks from "./checks.js";
|
| 2 |
+
import * as core from "./core.js";
|
| 3 |
+
import type * as errors from "./errors.js";
|
| 4 |
+
import type { StandardSchemaV1 } from "./standard-schema.js";
|
| 5 |
+
import * as util from "./util.js";
|
| 6 |
+
import { version } from "./versions.js";
|
| 7 |
+
export interface ParseContext<T extends errors.$ZodIssueBase = never> {
|
| 8 |
+
/** Customize error messages. */
|
| 9 |
+
readonly error?: errors.$ZodErrorMap<T>;
|
| 10 |
+
/** Include the `input` field in issue objects. Default `false`. */
|
| 11 |
+
readonly reportInput?: boolean;
|
| 12 |
+
/** Skip eval-based fast path. Default `false`. */
|
| 13 |
+
readonly jitless?: boolean;
|
| 14 |
+
}
|
| 15 |
+
/** @internal */
|
| 16 |
+
export interface ParseContextInternal<T extends errors.$ZodIssueBase = never> extends ParseContext<T> {
|
| 17 |
+
readonly async?: boolean | undefined;
|
| 18 |
+
}
|
| 19 |
+
export interface ParsePayload<T = unknown> {
|
| 20 |
+
value: T;
|
| 21 |
+
issues: errors.$ZodRawIssue[];
|
| 22 |
+
}
|
| 23 |
+
export type CheckFn<T> = (input: ParsePayload<T>) => util.MaybeAsync<void>;
|
| 24 |
+
export interface $ZodTypeDef {
|
| 25 |
+
type: "string" | "number" | "int" | "boolean" | "bigint" | "symbol" | "null" | "undefined" | "void" | "never" | "any" | "unknown" | "date" | "object" | "record" | "file" | "array" | "tuple" | "union" | "intersection" | "map" | "set" | "enum" | "literal" | "nullable" | "optional" | "nonoptional" | "success" | "transform" | "default" | "prefault" | "catch" | "nan" | "pipe" | "readonly" | "template_literal" | "promise" | "lazy" | "custom";
|
| 26 |
+
error?: errors.$ZodErrorMap<never> | undefined;
|
| 27 |
+
checks?: checks.$ZodCheck<never>[];
|
| 28 |
+
}
|
| 29 |
+
export interface _$ZodTypeInternals {
|
| 30 |
+
/** The `@zod/core` version of this schema */
|
| 31 |
+
version: typeof version;
|
| 32 |
+
/** Schema definition. */
|
| 33 |
+
def: $ZodTypeDef;
|
| 34 |
+
/** @internal Randomly generated ID for this schema. */
|
| 35 |
+
/** @internal List of deferred initializers. */
|
| 36 |
+
deferred: util.AnyFunc[] | undefined;
|
| 37 |
+
/** @internal Parses input and runs all checks (refinements). */
|
| 38 |
+
run(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
|
| 39 |
+
/** @internal Parses input, doesn't run checks. */
|
| 40 |
+
parse(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
|
| 41 |
+
/** @internal Stores identifiers for the set of traits implemented by this schema. */
|
| 42 |
+
traits: Set<string>;
|
| 43 |
+
/** @internal Indicates that a schema output type should be considered optional inside objects.
|
| 44 |
+
* @default Required
|
| 45 |
+
*/
|
| 46 |
+
/** @internal */
|
| 47 |
+
optin?: "optional" | undefined;
|
| 48 |
+
/** @internal */
|
| 49 |
+
optout?: "optional" | undefined;
|
| 50 |
+
/** @internal The set of literal values that will pass validation. Must be an exhaustive set. Used to determine optionality in z.record().
|
| 51 |
+
*
|
| 52 |
+
* Defined on: enum, const, literal, null, undefined
|
| 53 |
+
* Passthrough: optional, nullable, branded, default, catch, pipe
|
| 54 |
+
* Todo: unions?
|
| 55 |
+
*/
|
| 56 |
+
values?: util.PrimitiveSet | undefined;
|
| 57 |
+
/** @internal A set of literal discriminators used for the fast path in discriminated unions. */
|
| 58 |
+
propValues?: util.PropValues | undefined;
|
| 59 |
+
/** @internal This flag indicates that a schema validation can be represented with a regular expression. Used to determine allowable schemas in z.templateLiteral(). */
|
| 60 |
+
pattern: RegExp | undefined;
|
| 61 |
+
/** @internal The constructor function of this schema. */
|
| 62 |
+
constr: new (def: any) => $ZodType;
|
| 63 |
+
/** @internal A catchall object for bag metadata related to this schema. Commonly modified by checks using `onattach`. */
|
| 64 |
+
bag: Record<string, unknown>;
|
| 65 |
+
/** @internal The set of issues this schema might throw during type checking. */
|
| 66 |
+
isst: errors.$ZodIssueBase;
|
| 67 |
+
/** An optional method used to override `toJSONSchema` logic. */
|
| 68 |
+
toJSONSchema?: () => unknown;
|
| 69 |
+
/** @internal The parent of this schema. Only set during certain clone operations. */
|
| 70 |
+
parent?: $ZodType | undefined;
|
| 71 |
+
}
|
| 72 |
+
/** @internal */
|
| 73 |
+
export interface $ZodTypeInternals<out O = unknown, out I = unknown> extends _$ZodTypeInternals {
|
| 74 |
+
/** @internal The inferred output type */
|
| 75 |
+
output: O;
|
| 76 |
+
/** @internal The inferred input type */
|
| 77 |
+
input: I;
|
| 78 |
+
}
|
| 79 |
+
export type $ZodStandardSchema<T> = StandardSchemaV1.Props<core.input<T>, core.output<T>>;
|
| 80 |
+
export type SomeType = {
|
| 81 |
+
_zod: _$ZodTypeInternals;
|
| 82 |
+
};
|
| 83 |
+
export interface $ZodType<O = unknown, I = unknown, Internals extends $ZodTypeInternals<O, I> = $ZodTypeInternals<O, I>> {
|
| 84 |
+
_zod: Internals;
|
| 85 |
+
"~standard": $ZodStandardSchema<this>;
|
| 86 |
+
}
|
| 87 |
+
export interface _$ZodType<T extends $ZodTypeInternals = $ZodTypeInternals> extends $ZodType<T["output"], T["input"], T> {
|
| 88 |
+
}
|
| 89 |
+
export declare const $ZodType: core.$constructor<$ZodType>;
|
| 90 |
+
export { clone } from "./util.js";
|
| 91 |
+
export interface $ZodStringDef extends $ZodTypeDef {
|
| 92 |
+
type: "string";
|
| 93 |
+
coerce?: boolean;
|
| 94 |
+
checks?: checks.$ZodCheck<string>[];
|
| 95 |
+
}
|
| 96 |
+
export interface $ZodStringInternals<Input> extends $ZodTypeInternals<string, Input> {
|
| 97 |
+
def: $ZodStringDef;
|
| 98 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 99 |
+
pattern: RegExp;
|
| 100 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 101 |
+
isst: errors.$ZodIssueInvalidType;
|
| 102 |
+
bag: util.LoosePartial<{
|
| 103 |
+
minimum: number;
|
| 104 |
+
maximum: number;
|
| 105 |
+
patterns: Set<RegExp>;
|
| 106 |
+
format: string;
|
| 107 |
+
contentEncoding: string;
|
| 108 |
+
}>;
|
| 109 |
+
}
|
| 110 |
+
export interface $ZodString<Input = unknown> extends _$ZodType<$ZodStringInternals<Input>> {
|
| 111 |
+
}
|
| 112 |
+
export declare const $ZodString: core.$constructor<$ZodString>;
|
| 113 |
+
export interface $ZodStringFormatDef<Format extends string = string> extends $ZodStringDef, checks.$ZodCheckStringFormatDef<Format> {
|
| 114 |
+
}
|
| 115 |
+
export interface $ZodStringFormatInternals<Format extends string = string> extends $ZodStringInternals<string>, checks.$ZodCheckStringFormatInternals {
|
| 116 |
+
def: $ZodStringFormatDef<Format>;
|
| 117 |
+
}
|
| 118 |
+
export interface $ZodStringFormat<Format extends string = string> extends $ZodType {
|
| 119 |
+
_zod: $ZodStringFormatInternals<Format>;
|
| 120 |
+
}
|
| 121 |
+
export declare const $ZodStringFormat: core.$constructor<$ZodStringFormat>;
|
| 122 |
+
export interface $ZodGUIDDef extends $ZodStringFormatDef<"guid"> {
|
| 123 |
+
}
|
| 124 |
+
export interface $ZodGUIDInternals extends $ZodStringFormatInternals<"guid"> {
|
| 125 |
+
}
|
| 126 |
+
export interface $ZodGUID extends $ZodType {
|
| 127 |
+
_zod: $ZodGUIDInternals;
|
| 128 |
+
}
|
| 129 |
+
export declare const $ZodGUID: core.$constructor<$ZodGUID>;
|
| 130 |
+
export interface $ZodUUIDDef extends $ZodStringFormatDef<"uuid"> {
|
| 131 |
+
version?: "v1" | "v2" | "v3" | "v4" | "v5" | "v6" | "v7" | "v8";
|
| 132 |
+
}
|
| 133 |
+
export interface $ZodUUIDInternals extends $ZodStringFormatInternals<"uuid"> {
|
| 134 |
+
def: $ZodUUIDDef;
|
| 135 |
+
}
|
| 136 |
+
export interface $ZodUUID extends $ZodType {
|
| 137 |
+
_zod: $ZodUUIDInternals;
|
| 138 |
+
}
|
| 139 |
+
export declare const $ZodUUID: core.$constructor<$ZodUUID>;
|
| 140 |
+
export interface $ZodEmailDef extends $ZodStringFormatDef<"email"> {
|
| 141 |
+
}
|
| 142 |
+
export interface $ZodEmailInternals extends $ZodStringFormatInternals<"email"> {
|
| 143 |
+
}
|
| 144 |
+
export interface $ZodEmail extends $ZodType {
|
| 145 |
+
_zod: $ZodEmailInternals;
|
| 146 |
+
}
|
| 147 |
+
export declare const $ZodEmail: core.$constructor<$ZodEmail>;
|
| 148 |
+
export interface $ZodURLDef extends $ZodStringFormatDef<"url"> {
|
| 149 |
+
hostname?: RegExp | undefined;
|
| 150 |
+
protocol?: RegExp | undefined;
|
| 151 |
+
}
|
| 152 |
+
export interface $ZodURLInternals extends $ZodStringFormatInternals<"url"> {
|
| 153 |
+
def: $ZodURLDef;
|
| 154 |
+
}
|
| 155 |
+
export interface $ZodURL extends $ZodType {
|
| 156 |
+
_zod: $ZodURLInternals;
|
| 157 |
+
}
|
| 158 |
+
export declare const $ZodURL: core.$constructor<$ZodURL>;
|
| 159 |
+
export interface $ZodEmojiDef extends $ZodStringFormatDef<"emoji"> {
|
| 160 |
+
}
|
| 161 |
+
export interface $ZodEmojiInternals extends $ZodStringFormatInternals<"emoji"> {
|
| 162 |
+
}
|
| 163 |
+
export interface $ZodEmoji extends $ZodType {
|
| 164 |
+
_zod: $ZodEmojiInternals;
|
| 165 |
+
}
|
| 166 |
+
export declare const $ZodEmoji: core.$constructor<$ZodEmoji>;
|
| 167 |
+
export interface $ZodNanoIDDef extends $ZodStringFormatDef<"nanoid"> {
|
| 168 |
+
}
|
| 169 |
+
export interface $ZodNanoIDInternals extends $ZodStringFormatInternals<"nanoid"> {
|
| 170 |
+
}
|
| 171 |
+
export interface $ZodNanoID extends $ZodType {
|
| 172 |
+
_zod: $ZodNanoIDInternals;
|
| 173 |
+
}
|
| 174 |
+
export declare const $ZodNanoID: core.$constructor<$ZodNanoID>;
|
| 175 |
+
export interface $ZodCUIDDef extends $ZodStringFormatDef<"cuid"> {
|
| 176 |
+
}
|
| 177 |
+
export interface $ZodCUIDInternals extends $ZodStringFormatInternals<"cuid"> {
|
| 178 |
+
}
|
| 179 |
+
export interface $ZodCUID extends $ZodType {
|
| 180 |
+
_zod: $ZodCUIDInternals;
|
| 181 |
+
}
|
| 182 |
+
export declare const $ZodCUID: core.$constructor<$ZodCUID>;
|
| 183 |
+
export interface $ZodCUID2Def extends $ZodStringFormatDef<"cuid2"> {
|
| 184 |
+
}
|
| 185 |
+
export interface $ZodCUID2Internals extends $ZodStringFormatInternals<"cuid2"> {
|
| 186 |
+
}
|
| 187 |
+
export interface $ZodCUID2 extends $ZodType {
|
| 188 |
+
_zod: $ZodCUID2Internals;
|
| 189 |
+
}
|
| 190 |
+
export declare const $ZodCUID2: core.$constructor<$ZodCUID2>;
|
| 191 |
+
export interface $ZodULIDDef extends $ZodStringFormatDef<"ulid"> {
|
| 192 |
+
}
|
| 193 |
+
export interface $ZodULIDInternals extends $ZodStringFormatInternals<"ulid"> {
|
| 194 |
+
}
|
| 195 |
+
export interface $ZodULID extends $ZodType {
|
| 196 |
+
_zod: $ZodULIDInternals;
|
| 197 |
+
}
|
| 198 |
+
export declare const $ZodULID: core.$constructor<$ZodULID>;
|
| 199 |
+
export interface $ZodXIDDef extends $ZodStringFormatDef<"xid"> {
|
| 200 |
+
}
|
| 201 |
+
export interface $ZodXIDInternals extends $ZodStringFormatInternals<"xid"> {
|
| 202 |
+
}
|
| 203 |
+
export interface $ZodXID extends $ZodType {
|
| 204 |
+
_zod: $ZodXIDInternals;
|
| 205 |
+
}
|
| 206 |
+
export declare const $ZodXID: core.$constructor<$ZodXID>;
|
| 207 |
+
export interface $ZodKSUIDDef extends $ZodStringFormatDef<"ksuid"> {
|
| 208 |
+
}
|
| 209 |
+
export interface $ZodKSUIDInternals extends $ZodStringFormatInternals<"ksuid"> {
|
| 210 |
+
}
|
| 211 |
+
export interface $ZodKSUID extends $ZodType {
|
| 212 |
+
_zod: $ZodKSUIDInternals;
|
| 213 |
+
}
|
| 214 |
+
export declare const $ZodKSUID: core.$constructor<$ZodKSUID>;
|
| 215 |
+
export interface $ZodISODateTimeDef extends $ZodStringFormatDef<"datetime"> {
|
| 216 |
+
precision: number | null;
|
| 217 |
+
offset: boolean;
|
| 218 |
+
local: boolean;
|
| 219 |
+
}
|
| 220 |
+
export interface $ZodISODateTimeInternals extends $ZodStringFormatInternals {
|
| 221 |
+
def: $ZodISODateTimeDef;
|
| 222 |
+
}
|
| 223 |
+
export interface $ZodISODateTime extends $ZodType {
|
| 224 |
+
_zod: $ZodISODateTimeInternals;
|
| 225 |
+
}
|
| 226 |
+
export declare const $ZodISODateTime: core.$constructor<$ZodISODateTime>;
|
| 227 |
+
export interface $ZodISODateDef extends $ZodStringFormatDef<"date"> {
|
| 228 |
+
}
|
| 229 |
+
export interface $ZodISODateInternals extends $ZodStringFormatInternals<"date"> {
|
| 230 |
+
}
|
| 231 |
+
export interface $ZodISODate extends $ZodType {
|
| 232 |
+
_zod: $ZodISODateInternals;
|
| 233 |
+
}
|
| 234 |
+
export declare const $ZodISODate: core.$constructor<$ZodISODate>;
|
| 235 |
+
export interface $ZodISOTimeDef extends $ZodStringFormatDef<"time"> {
|
| 236 |
+
precision?: number | null;
|
| 237 |
+
}
|
| 238 |
+
export interface $ZodISOTimeInternals extends $ZodStringFormatInternals<"time"> {
|
| 239 |
+
def: $ZodISOTimeDef;
|
| 240 |
+
}
|
| 241 |
+
export interface $ZodISOTime extends $ZodType {
|
| 242 |
+
_zod: $ZodISOTimeInternals;
|
| 243 |
+
}
|
| 244 |
+
export declare const $ZodISOTime: core.$constructor<$ZodISOTime>;
|
| 245 |
+
export interface $ZodISODurationDef extends $ZodStringFormatDef<"duration"> {
|
| 246 |
+
}
|
| 247 |
+
export interface $ZodISODurationInternals extends $ZodStringFormatInternals<"duration"> {
|
| 248 |
+
}
|
| 249 |
+
export interface $ZodISODuration extends $ZodType {
|
| 250 |
+
_zod: $ZodISODurationInternals;
|
| 251 |
+
}
|
| 252 |
+
export declare const $ZodISODuration: core.$constructor<$ZodISODuration>;
|
| 253 |
+
export interface $ZodIPv4Def extends $ZodStringFormatDef<"ipv4"> {
|
| 254 |
+
version?: "v4";
|
| 255 |
+
}
|
| 256 |
+
export interface $ZodIPv4Internals extends $ZodStringFormatInternals<"ipv4"> {
|
| 257 |
+
def: $ZodIPv4Def;
|
| 258 |
+
}
|
| 259 |
+
export interface $ZodIPv4 extends $ZodType {
|
| 260 |
+
_zod: $ZodIPv4Internals;
|
| 261 |
+
}
|
| 262 |
+
export declare const $ZodIPv4: core.$constructor<$ZodIPv4>;
|
| 263 |
+
export interface $ZodIPv6Def extends $ZodStringFormatDef<"ipv6"> {
|
| 264 |
+
version?: "v6";
|
| 265 |
+
}
|
| 266 |
+
export interface $ZodIPv6Internals extends $ZodStringFormatInternals<"ipv6"> {
|
| 267 |
+
def: $ZodIPv6Def;
|
| 268 |
+
}
|
| 269 |
+
export interface $ZodIPv6 extends $ZodType {
|
| 270 |
+
_zod: $ZodIPv6Internals;
|
| 271 |
+
}
|
| 272 |
+
export declare const $ZodIPv6: core.$constructor<$ZodIPv6>;
|
| 273 |
+
export interface $ZodCIDRv4Def extends $ZodStringFormatDef<"cidrv4"> {
|
| 274 |
+
version?: "v4";
|
| 275 |
+
}
|
| 276 |
+
export interface $ZodCIDRv4Internals extends $ZodStringFormatInternals<"cidrv4"> {
|
| 277 |
+
def: $ZodCIDRv4Def;
|
| 278 |
+
}
|
| 279 |
+
export interface $ZodCIDRv4 extends $ZodType {
|
| 280 |
+
_zod: $ZodCIDRv4Internals;
|
| 281 |
+
}
|
| 282 |
+
export declare const $ZodCIDRv4: core.$constructor<$ZodCIDRv4>;
|
| 283 |
+
export interface $ZodCIDRv6Def extends $ZodStringFormatDef<"cidrv6"> {
|
| 284 |
+
version?: "v6";
|
| 285 |
+
}
|
| 286 |
+
export interface $ZodCIDRv6Internals extends $ZodStringFormatInternals<"cidrv6"> {
|
| 287 |
+
def: $ZodCIDRv6Def;
|
| 288 |
+
}
|
| 289 |
+
export interface $ZodCIDRv6 extends $ZodType {
|
| 290 |
+
_zod: $ZodCIDRv6Internals;
|
| 291 |
+
}
|
| 292 |
+
export declare const $ZodCIDRv6: core.$constructor<$ZodCIDRv6>;
|
| 293 |
+
export declare function isValidBase64(data: string): boolean;
|
| 294 |
+
export interface $ZodBase64Def extends $ZodStringFormatDef<"base64"> {
|
| 295 |
+
}
|
| 296 |
+
export interface $ZodBase64Internals extends $ZodStringFormatInternals<"base64"> {
|
| 297 |
+
}
|
| 298 |
+
export interface $ZodBase64 extends $ZodType {
|
| 299 |
+
_zod: $ZodBase64Internals;
|
| 300 |
+
}
|
| 301 |
+
export declare const $ZodBase64: core.$constructor<$ZodBase64>;
|
| 302 |
+
export declare function isValidBase64URL(data: string): boolean;
|
| 303 |
+
export interface $ZodBase64URLDef extends $ZodStringFormatDef<"base64url"> {
|
| 304 |
+
}
|
| 305 |
+
export interface $ZodBase64URLInternals extends $ZodStringFormatInternals<"base64url"> {
|
| 306 |
+
}
|
| 307 |
+
export interface $ZodBase64URL extends $ZodType {
|
| 308 |
+
_zod: $ZodBase64URLInternals;
|
| 309 |
+
}
|
| 310 |
+
export declare const $ZodBase64URL: core.$constructor<$ZodBase64URL>;
|
| 311 |
+
export interface $ZodE164Def extends $ZodStringFormatDef<"e164"> {
|
| 312 |
+
}
|
| 313 |
+
export interface $ZodE164Internals extends $ZodStringFormatInternals<"e164"> {
|
| 314 |
+
}
|
| 315 |
+
export interface $ZodE164 extends $ZodType {
|
| 316 |
+
_zod: $ZodE164Internals;
|
| 317 |
+
}
|
| 318 |
+
export declare const $ZodE164: core.$constructor<$ZodE164>;
|
| 319 |
+
export declare function isValidJWT(token: string, algorithm?: util.JWTAlgorithm | null): boolean;
|
| 320 |
+
export interface $ZodJWTDef extends $ZodStringFormatDef<"jwt"> {
|
| 321 |
+
alg?: util.JWTAlgorithm | undefined;
|
| 322 |
+
}
|
| 323 |
+
export interface $ZodJWTInternals extends $ZodStringFormatInternals<"jwt"> {
|
| 324 |
+
def: $ZodJWTDef;
|
| 325 |
+
}
|
| 326 |
+
export interface $ZodJWT extends $ZodType {
|
| 327 |
+
_zod: $ZodJWTInternals;
|
| 328 |
+
}
|
| 329 |
+
export declare const $ZodJWT: core.$constructor<$ZodJWT>;
|
| 330 |
+
export interface $ZodCustomStringFormatDef<Format extends string = string> extends $ZodStringFormatDef<Format> {
|
| 331 |
+
fn: (val: string) => unknown;
|
| 332 |
+
}
|
| 333 |
+
export interface $ZodCustomStringFormatInternals<Format extends string = string> extends $ZodStringFormatInternals<Format> {
|
| 334 |
+
def: $ZodCustomStringFormatDef<Format>;
|
| 335 |
+
}
|
| 336 |
+
export interface $ZodCustomStringFormat<Format extends string = string> extends $ZodStringFormat<Format> {
|
| 337 |
+
_zod: $ZodCustomStringFormatInternals<Format>;
|
| 338 |
+
}
|
| 339 |
+
export declare const $ZodCustomStringFormat: core.$constructor<$ZodCustomStringFormat>;
|
| 340 |
+
export interface $ZodNumberDef extends $ZodTypeDef {
|
| 341 |
+
type: "number";
|
| 342 |
+
coerce?: boolean;
|
| 343 |
+
}
|
| 344 |
+
export interface $ZodNumberInternals<Input = unknown> extends $ZodTypeInternals<number, Input> {
|
| 345 |
+
def: $ZodNumberDef;
|
| 346 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 347 |
+
pattern: RegExp;
|
| 348 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 349 |
+
isst: errors.$ZodIssueInvalidType;
|
| 350 |
+
bag: util.LoosePartial<{
|
| 351 |
+
minimum: number;
|
| 352 |
+
maximum: number;
|
| 353 |
+
exclusiveMinimum: number;
|
| 354 |
+
exclusiveMaximum: number;
|
| 355 |
+
format: string;
|
| 356 |
+
pattern: RegExp;
|
| 357 |
+
}>;
|
| 358 |
+
}
|
| 359 |
+
export interface $ZodNumber<Input = unknown> extends $ZodType {
|
| 360 |
+
_zod: $ZodNumberInternals<Input>;
|
| 361 |
+
}
|
| 362 |
+
export declare const $ZodNumber: core.$constructor<$ZodNumber>;
|
| 363 |
+
export interface $ZodNumberFormatDef extends $ZodNumberDef, checks.$ZodCheckNumberFormatDef {
|
| 364 |
+
}
|
| 365 |
+
export interface $ZodNumberFormatInternals extends $ZodNumberInternals<number>, checks.$ZodCheckNumberFormatInternals {
|
| 366 |
+
def: $ZodNumberFormatDef;
|
| 367 |
+
isst: errors.$ZodIssueInvalidType;
|
| 368 |
+
}
|
| 369 |
+
export interface $ZodNumberFormat extends $ZodType {
|
| 370 |
+
_zod: $ZodNumberFormatInternals;
|
| 371 |
+
}
|
| 372 |
+
export declare const $ZodNumberFormat: core.$constructor<$ZodNumberFormat>;
|
| 373 |
+
export interface $ZodBooleanDef extends $ZodTypeDef {
|
| 374 |
+
type: "boolean";
|
| 375 |
+
coerce?: boolean;
|
| 376 |
+
checks?: checks.$ZodCheck<boolean>[];
|
| 377 |
+
}
|
| 378 |
+
export interface $ZodBooleanInternals<T = unknown> extends $ZodTypeInternals<boolean, T> {
|
| 379 |
+
pattern: RegExp;
|
| 380 |
+
def: $ZodBooleanDef;
|
| 381 |
+
isst: errors.$ZodIssueInvalidType;
|
| 382 |
+
}
|
| 383 |
+
export interface $ZodBoolean<T = unknown> extends $ZodType {
|
| 384 |
+
_zod: $ZodBooleanInternals<T>;
|
| 385 |
+
}
|
| 386 |
+
export declare const $ZodBoolean: core.$constructor<$ZodBoolean>;
|
| 387 |
+
export interface $ZodBigIntDef extends $ZodTypeDef {
|
| 388 |
+
type: "bigint";
|
| 389 |
+
coerce?: boolean;
|
| 390 |
+
}
|
| 391 |
+
export interface $ZodBigIntInternals<T = unknown> extends $ZodTypeInternals<bigint, T> {
|
| 392 |
+
pattern: RegExp;
|
| 393 |
+
/** @internal Internal API, use with caution */
|
| 394 |
+
def: $ZodBigIntDef;
|
| 395 |
+
isst: errors.$ZodIssueInvalidType;
|
| 396 |
+
bag: util.LoosePartial<{
|
| 397 |
+
minimum: bigint;
|
| 398 |
+
maximum: bigint;
|
| 399 |
+
format: string;
|
| 400 |
+
}>;
|
| 401 |
+
}
|
| 402 |
+
export interface $ZodBigInt<T = unknown> extends $ZodType {
|
| 403 |
+
_zod: $ZodBigIntInternals<T>;
|
| 404 |
+
}
|
| 405 |
+
export declare const $ZodBigInt: core.$constructor<$ZodBigInt>;
|
| 406 |
+
export interface $ZodBigIntFormatDef extends $ZodBigIntDef, checks.$ZodCheckBigIntFormatDef {
|
| 407 |
+
check: "bigint_format";
|
| 408 |
+
}
|
| 409 |
+
export interface $ZodBigIntFormatInternals extends $ZodBigIntInternals<bigint>, checks.$ZodCheckBigIntFormatInternals {
|
| 410 |
+
def: $ZodBigIntFormatDef;
|
| 411 |
+
}
|
| 412 |
+
export interface $ZodBigIntFormat extends $ZodType {
|
| 413 |
+
_zod: $ZodBigIntFormatInternals;
|
| 414 |
+
}
|
| 415 |
+
export declare const $ZodBigIntFormat: core.$constructor<$ZodBigIntFormat>;
|
| 416 |
+
export interface $ZodSymbolDef extends $ZodTypeDef {
|
| 417 |
+
type: "symbol";
|
| 418 |
+
}
|
| 419 |
+
export interface $ZodSymbolInternals extends $ZodTypeInternals<symbol, symbol> {
|
| 420 |
+
def: $ZodSymbolDef;
|
| 421 |
+
isst: errors.$ZodIssueInvalidType;
|
| 422 |
+
}
|
| 423 |
+
export interface $ZodSymbol extends $ZodType {
|
| 424 |
+
_zod: $ZodSymbolInternals;
|
| 425 |
+
}
|
| 426 |
+
export declare const $ZodSymbol: core.$constructor<$ZodSymbol>;
|
| 427 |
+
export interface $ZodUndefinedDef extends $ZodTypeDef {
|
| 428 |
+
type: "undefined";
|
| 429 |
+
}
|
| 430 |
+
export interface $ZodUndefinedInternals extends $ZodTypeInternals<undefined, undefined> {
|
| 431 |
+
pattern: RegExp;
|
| 432 |
+
def: $ZodUndefinedDef;
|
| 433 |
+
values: util.PrimitiveSet;
|
| 434 |
+
isst: errors.$ZodIssueInvalidType;
|
| 435 |
+
}
|
| 436 |
+
export interface $ZodUndefined extends $ZodType {
|
| 437 |
+
_zod: $ZodUndefinedInternals;
|
| 438 |
+
}
|
| 439 |
+
export declare const $ZodUndefined: core.$constructor<$ZodUndefined>;
|
| 440 |
+
export interface $ZodNullDef extends $ZodTypeDef {
|
| 441 |
+
type: "null";
|
| 442 |
+
}
|
| 443 |
+
export interface $ZodNullInternals extends $ZodTypeInternals<null, null> {
|
| 444 |
+
pattern: RegExp;
|
| 445 |
+
def: $ZodNullDef;
|
| 446 |
+
values: util.PrimitiveSet;
|
| 447 |
+
isst: errors.$ZodIssueInvalidType;
|
| 448 |
+
}
|
| 449 |
+
export interface $ZodNull extends $ZodType {
|
| 450 |
+
_zod: $ZodNullInternals;
|
| 451 |
+
}
|
| 452 |
+
export declare const $ZodNull: core.$constructor<$ZodNull>;
|
| 453 |
+
export interface $ZodAnyDef extends $ZodTypeDef {
|
| 454 |
+
type: "any";
|
| 455 |
+
}
|
| 456 |
+
export interface $ZodAnyInternals extends $ZodTypeInternals<any, any> {
|
| 457 |
+
def: $ZodAnyDef;
|
| 458 |
+
isst: never;
|
| 459 |
+
}
|
| 460 |
+
export interface $ZodAny extends $ZodType {
|
| 461 |
+
_zod: $ZodAnyInternals;
|
| 462 |
+
}
|
| 463 |
+
export declare const $ZodAny: core.$constructor<$ZodAny>;
|
| 464 |
+
export interface $ZodUnknownDef extends $ZodTypeDef {
|
| 465 |
+
type: "unknown";
|
| 466 |
+
}
|
| 467 |
+
export interface $ZodUnknownInternals extends $ZodTypeInternals<unknown, unknown> {
|
| 468 |
+
def: $ZodUnknownDef;
|
| 469 |
+
isst: never;
|
| 470 |
+
}
|
| 471 |
+
export interface $ZodUnknown extends $ZodType {
|
| 472 |
+
_zod: $ZodUnknownInternals;
|
| 473 |
+
}
|
| 474 |
+
export declare const $ZodUnknown: core.$constructor<$ZodUnknown>;
|
| 475 |
+
export interface $ZodNeverDef extends $ZodTypeDef {
|
| 476 |
+
type: "never";
|
| 477 |
+
}
|
| 478 |
+
export interface $ZodNeverInternals extends $ZodTypeInternals<never, never> {
|
| 479 |
+
def: $ZodNeverDef;
|
| 480 |
+
isst: errors.$ZodIssueInvalidType;
|
| 481 |
+
}
|
| 482 |
+
export interface $ZodNever extends $ZodType {
|
| 483 |
+
_zod: $ZodNeverInternals;
|
| 484 |
+
}
|
| 485 |
+
export declare const $ZodNever: core.$constructor<$ZodNever>;
|
| 486 |
+
export interface $ZodVoidDef extends $ZodTypeDef {
|
| 487 |
+
type: "void";
|
| 488 |
+
}
|
| 489 |
+
export interface $ZodVoidInternals extends $ZodTypeInternals<void, void> {
|
| 490 |
+
def: $ZodVoidDef;
|
| 491 |
+
isst: errors.$ZodIssueInvalidType;
|
| 492 |
+
}
|
| 493 |
+
export interface $ZodVoid extends $ZodType {
|
| 494 |
+
_zod: $ZodVoidInternals;
|
| 495 |
+
}
|
| 496 |
+
export declare const $ZodVoid: core.$constructor<$ZodVoid>;
|
| 497 |
+
export interface $ZodDateDef extends $ZodTypeDef {
|
| 498 |
+
type: "date";
|
| 499 |
+
coerce?: boolean;
|
| 500 |
+
}
|
| 501 |
+
export interface $ZodDateInternals<T = unknown> extends $ZodTypeInternals<Date, T> {
|
| 502 |
+
def: $ZodDateDef;
|
| 503 |
+
isst: errors.$ZodIssueInvalidType;
|
| 504 |
+
bag: util.LoosePartial<{
|
| 505 |
+
minimum: Date;
|
| 506 |
+
maximum: Date;
|
| 507 |
+
format: string;
|
| 508 |
+
}>;
|
| 509 |
+
}
|
| 510 |
+
export interface $ZodDate<T = unknown> extends $ZodType {
|
| 511 |
+
_zod: $ZodDateInternals<T>;
|
| 512 |
+
}
|
| 513 |
+
export declare const $ZodDate: core.$constructor<$ZodDate>;
|
| 514 |
+
export interface $ZodArrayDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 515 |
+
type: "array";
|
| 516 |
+
element: T;
|
| 517 |
+
}
|
| 518 |
+
export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$ZodTypeInternals {
|
| 519 |
+
def: $ZodArrayDef<T>;
|
| 520 |
+
isst: errors.$ZodIssueInvalidType;
|
| 521 |
+
output: core.output<T>[];
|
| 522 |
+
input: core.input<T>[];
|
| 523 |
+
}
|
| 524 |
+
export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {
|
| 525 |
+
}
|
| 526 |
+
export declare const $ZodArray: core.$constructor<$ZodArray>;
|
| 527 |
+
type OptionalOutSchema = {
|
| 528 |
+
_zod: {
|
| 529 |
+
optout: "optional";
|
| 530 |
+
};
|
| 531 |
+
};
|
| 532 |
+
type OptionalInSchema = {
|
| 533 |
+
_zod: {
|
| 534 |
+
optin: "optional";
|
| 535 |
+
};
|
| 536 |
+
};
|
| 537 |
+
export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? util.IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, core.output<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
| 538 |
+
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? never : k]: T[k]["_zod"]["output"];
|
| 539 |
+
} & {
|
| 540 |
+
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? k : never]?: T[k]["_zod"]["output"];
|
| 541 |
+
} & Extra>;
|
| 542 |
+
export type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? util.IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, core.input<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
| 543 |
+
-readonly [k in keyof T as T[k] extends OptionalInSchema ? never : k]: T[k]["_zod"]["input"];
|
| 544 |
+
} & {
|
| 545 |
+
-readonly [k in keyof T as T[k] extends OptionalInSchema ? k : never]?: T[k]["_zod"]["input"];
|
| 546 |
+
} & Extra>;
|
| 547 |
+
export type $ZodObjectConfig = {
|
| 548 |
+
out: Record<string, unknown>;
|
| 549 |
+
in: Record<string, unknown>;
|
| 550 |
+
};
|
| 551 |
+
export type $loose = {
|
| 552 |
+
out: Record<string, unknown>;
|
| 553 |
+
in: Record<string, unknown>;
|
| 554 |
+
};
|
| 555 |
+
export type $strict = {
|
| 556 |
+
out: {};
|
| 557 |
+
in: {};
|
| 558 |
+
};
|
| 559 |
+
export type $strip = {
|
| 560 |
+
out: {};
|
| 561 |
+
in: {};
|
| 562 |
+
};
|
| 563 |
+
export type $catchall<T extends SomeType> = {
|
| 564 |
+
out: {
|
| 565 |
+
[k: string]: core.output<T>;
|
| 566 |
+
};
|
| 567 |
+
in: {
|
| 568 |
+
[k: string]: core.input<T>;
|
| 569 |
+
};
|
| 570 |
+
};
|
| 571 |
+
export type $ZodShape = Readonly<{
|
| 572 |
+
[k: string]: $ZodType;
|
| 573 |
+
}>;
|
| 574 |
+
export interface $ZodObjectDef<Shape extends $ZodShape = $ZodShape> extends $ZodTypeDef {
|
| 575 |
+
type: "object";
|
| 576 |
+
shape: Shape;
|
| 577 |
+
catchall?: $ZodType | undefined;
|
| 578 |
+
}
|
| 579 |
+
export interface $ZodObjectInternals<
|
| 580 |
+
/** @ts-ignore Cast variance */
|
| 581 |
+
out Shape extends Readonly<$ZodShape> = Readonly<$ZodShape>, out Config extends $ZodObjectConfig = $ZodObjectConfig> extends _$ZodTypeInternals {
|
| 582 |
+
def: $ZodObjectDef<Shape>;
|
| 583 |
+
config: Config;
|
| 584 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueUnrecognizedKeys;
|
| 585 |
+
propValues: util.PropValues;
|
| 586 |
+
output: $InferObjectOutput<Shape, Config["out"]>;
|
| 587 |
+
input: $InferObjectInput<Shape, Config["in"]>;
|
| 588 |
+
}
|
| 589 |
+
export type $ZodLooseShape = Record<string, any>;
|
| 590 |
+
export interface $ZodObject<
|
| 591 |
+
/** @ts-ignore Cast variance */
|
| 592 |
+
out Shape extends Readonly<$ZodShape> = Readonly<$ZodShape>, out Params extends $ZodObjectConfig = $ZodObjectConfig> extends $ZodType<any, any, $ZodObjectInternals<Shape, Params>> {
|
| 593 |
+
"~standard": $ZodStandardSchema<this>;
|
| 594 |
+
}
|
| 595 |
+
export declare const $ZodObject: core.$constructor<$ZodObject>;
|
| 596 |
+
export type $InferUnionOutput<T extends SomeType> = T extends any ? core.output<T> : never;
|
| 597 |
+
export type $InferUnionInput<T extends SomeType> = T extends any ? core.input<T> : never;
|
| 598 |
+
export interface $ZodUnionDef<Options extends readonly SomeType[] = readonly $ZodType[]> extends $ZodTypeDef {
|
| 599 |
+
type: "union";
|
| 600 |
+
options: Options;
|
| 601 |
+
}
|
| 602 |
+
type IsOptionalIn<T extends SomeType> = T extends OptionalInSchema ? true : false;
|
| 603 |
+
type IsOptionalOut<T extends SomeType> = T extends OptionalOutSchema ? true : false;
|
| 604 |
+
export interface $ZodUnionInternals<T extends readonly SomeType[] = readonly $ZodType[]> extends _$ZodTypeInternals {
|
| 605 |
+
def: $ZodUnionDef<T>;
|
| 606 |
+
isst: errors.$ZodIssueInvalidUnion;
|
| 607 |
+
pattern: T[number]["_zod"]["pattern"];
|
| 608 |
+
values: T[number]["_zod"]["values"];
|
| 609 |
+
output: $InferUnionOutput<T[number]>;
|
| 610 |
+
input: $InferUnionInput<T[number]>;
|
| 611 |
+
optin: IsOptionalIn<T[number]> extends false ? "optional" | undefined : "optional";
|
| 612 |
+
optout: IsOptionalOut<T[number]> extends false ? "optional" | undefined : "optional";
|
| 613 |
+
}
|
| 614 |
+
export interface $ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType<any, any, $ZodUnionInternals<T>> {
|
| 615 |
+
_zod: $ZodUnionInternals<T>;
|
| 616 |
+
}
|
| 617 |
+
export declare const $ZodUnion: core.$constructor<$ZodUnion>;
|
| 618 |
+
export interface $ZodDiscriminatedUnionDef<Options extends readonly SomeType[] = readonly $ZodType[]> extends $ZodUnionDef<Options> {
|
| 619 |
+
discriminator: string;
|
| 620 |
+
unionFallback?: boolean;
|
| 621 |
+
}
|
| 622 |
+
export interface $ZodDiscriminatedUnionInternals<Options extends readonly SomeType[] = readonly $ZodType[]> extends $ZodUnionInternals<Options> {
|
| 623 |
+
def: $ZodDiscriminatedUnionDef<Options>;
|
| 624 |
+
propValues: util.PropValues;
|
| 625 |
+
}
|
| 626 |
+
export interface $ZodDiscriminatedUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType {
|
| 627 |
+
_zod: $ZodDiscriminatedUnionInternals<T>;
|
| 628 |
+
}
|
| 629 |
+
export declare const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion>;
|
| 630 |
+
export interface $ZodIntersectionDef<Left extends SomeType = $ZodType, Right extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 631 |
+
type: "intersection";
|
| 632 |
+
left: Left;
|
| 633 |
+
right: Right;
|
| 634 |
+
}
|
| 635 |
+
export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<A> & core.output<B>, core.input<A> & core.input<B>> {
|
| 636 |
+
def: $ZodIntersectionDef<A, B>;
|
| 637 |
+
isst: never;
|
| 638 |
+
optin: A["_zod"]["optin"] | B["_zod"]["optin"];
|
| 639 |
+
optout: A["_zod"]["optout"] | B["_zod"]["optout"];
|
| 640 |
+
}
|
| 641 |
+
export interface $ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
| 642 |
+
_zod: $ZodIntersectionInternals<A, B>;
|
| 643 |
+
}
|
| 644 |
+
export declare const $ZodIntersection: core.$constructor<$ZodIntersection>;
|
| 645 |
+
export interface $ZodTupleDef<T extends util.TupleItems = readonly $ZodType[], Rest extends SomeType | null = $ZodType | null> extends $ZodTypeDef {
|
| 646 |
+
type: "tuple";
|
| 647 |
+
items: T;
|
| 648 |
+
rest: Rest;
|
| 649 |
+
}
|
| 650 |
+
export type $InferTupleInputType<T extends util.TupleItems, Rest extends SomeType | null> = [
|
| 651 |
+
...TupleInputTypeWithOptionals<T>,
|
| 652 |
+
...(Rest extends SomeType ? core.input<Rest>[] : [])
|
| 653 |
+
];
|
| 654 |
+
type TupleInputTypeNoOptionals<T extends util.TupleItems> = {
|
| 655 |
+
[k in keyof T]: core.input<T[k]>;
|
| 656 |
+
};
|
| 657 |
+
type TupleInputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
|
| 658 |
+
...infer Prefix extends SomeType[],
|
| 659 |
+
infer Tail extends SomeType
|
| 660 |
+
] ? Tail["_zod"]["optin"] extends "optional" ? [...TupleInputTypeWithOptionals<Prefix>, core.input<Tail>?] : TupleInputTypeNoOptionals<T> : [];
|
| 661 |
+
export type $InferTupleOutputType<T extends util.TupleItems, Rest extends SomeType | null> = [
|
| 662 |
+
...TupleOutputTypeWithOptionals<T>,
|
| 663 |
+
...(Rest extends SomeType ? core.output<Rest>[] : [])
|
| 664 |
+
];
|
| 665 |
+
type TupleOutputTypeNoOptionals<T extends util.TupleItems> = {
|
| 666 |
+
[k in keyof T]: core.output<T[k]>;
|
| 667 |
+
};
|
| 668 |
+
type TupleOutputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
|
| 669 |
+
...infer Prefix extends SomeType[],
|
| 670 |
+
infer Tail extends SomeType
|
| 671 |
+
] ? Tail["_zod"]["optout"] extends "optional" ? [...TupleOutputTypeWithOptionals<Prefix>, core.output<Tail>?] : TupleOutputTypeNoOptionals<T> : [];
|
| 672 |
+
export interface $ZodTupleInternals<T extends util.TupleItems = readonly $ZodType[], Rest extends SomeType | null = $ZodType | null> extends $ZodTypeInternals<$InferTupleOutputType<T, Rest>, $InferTupleInputType<T, Rest>> {
|
| 673 |
+
def: $ZodTupleDef<T, Rest>;
|
| 674 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueTooBig<unknown[]> | errors.$ZodIssueTooSmall<unknown[]>;
|
| 675 |
+
}
|
| 676 |
+
export interface $ZodTuple<T extends util.TupleItems = readonly $ZodType[], Rest extends SomeType | null = $ZodType | null> extends $ZodType {
|
| 677 |
+
_zod: $ZodTupleInternals<T, Rest>;
|
| 678 |
+
}
|
| 679 |
+
export declare const $ZodTuple: core.$constructor<$ZodTuple>;
|
| 680 |
+
export type $ZodRecordKey = $ZodType<string | number | symbol, string | number | symbol>;
|
| 681 |
+
export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 682 |
+
type: "record";
|
| 683 |
+
keyType: Key;
|
| 684 |
+
valueType: Value;
|
| 685 |
+
}
|
| 686 |
+
export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.output<Key>, core.output<Value>>> : Record<core.output<Key>, core.output<Value>>;
|
| 687 |
+
export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.input<Key>, core.input<Value>>> : Record<core.input<Key>, core.input<Value>>;
|
| 688 |
+
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
|
| 689 |
+
def: $ZodRecordDef<Key, Value>;
|
| 690 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
| 691 |
+
optin?: "optional" | undefined;
|
| 692 |
+
optout?: "optional" | undefined;
|
| 693 |
+
}
|
| 694 |
+
export type $partial = {
|
| 695 |
+
"~~partial": true;
|
| 696 |
+
};
|
| 697 |
+
export interface $ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodType {
|
| 698 |
+
_zod: $ZodRecordInternals<Key, Value>;
|
| 699 |
+
}
|
| 700 |
+
export declare const $ZodRecord: core.$constructor<$ZodRecord>;
|
| 701 |
+
export interface $ZodMapDef<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 702 |
+
type: "map";
|
| 703 |
+
keyType: Key;
|
| 704 |
+
valueType: Value;
|
| 705 |
+
}
|
| 706 |
+
export interface $ZodMapInternals<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodTypeInternals<Map<core.output<Key>, core.output<Value>>, Map<core.input<Key>, core.input<Value>>> {
|
| 707 |
+
def: $ZodMapDef<Key, Value>;
|
| 708 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey | errors.$ZodIssueInvalidElement<unknown>;
|
| 709 |
+
optin?: "optional" | undefined;
|
| 710 |
+
optout?: "optional" | undefined;
|
| 711 |
+
}
|
| 712 |
+
export interface $ZodMap<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodType {
|
| 713 |
+
_zod: $ZodMapInternals<Key, Value>;
|
| 714 |
+
}
|
| 715 |
+
export declare const $ZodMap: core.$constructor<$ZodMap>;
|
| 716 |
+
export interface $ZodSetDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 717 |
+
type: "set";
|
| 718 |
+
valueType: T;
|
| 719 |
+
}
|
| 720 |
+
export interface $ZodSetInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<Set<core.output<T>>, Set<core.input<T>>> {
|
| 721 |
+
def: $ZodSetDef<T>;
|
| 722 |
+
isst: errors.$ZodIssueInvalidType;
|
| 723 |
+
optin?: "optional" | undefined;
|
| 724 |
+
optout?: "optional" | undefined;
|
| 725 |
+
}
|
| 726 |
+
export interface $ZodSet<T extends SomeType = $ZodType> extends $ZodType {
|
| 727 |
+
_zod: $ZodSetInternals<T>;
|
| 728 |
+
}
|
| 729 |
+
export declare const $ZodSet: core.$constructor<$ZodSet>;
|
| 730 |
+
export type $InferEnumOutput<T extends util.EnumLike> = T[keyof T] & {};
|
| 731 |
+
export type $InferEnumInput<T extends util.EnumLike> = T[keyof T] & {};
|
| 732 |
+
export interface $ZodEnumDef<T extends util.EnumLike = util.EnumLike> extends $ZodTypeDef {
|
| 733 |
+
type: "enum";
|
| 734 |
+
entries: T;
|
| 735 |
+
}
|
| 736 |
+
export interface $ZodEnumInternals<
|
| 737 |
+
/** @ts-ignore Cast variance */
|
| 738 |
+
out T extends util.EnumLike = util.EnumLike> extends $ZodTypeInternals<$InferEnumOutput<T>, $InferEnumInput<T>> {
|
| 739 |
+
def: $ZodEnumDef<T>;
|
| 740 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 741 |
+
values: util.PrimitiveSet;
|
| 742 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 743 |
+
pattern: RegExp;
|
| 744 |
+
isst: errors.$ZodIssueInvalidValue;
|
| 745 |
+
}
|
| 746 |
+
export interface $ZodEnum<T extends util.EnumLike = util.EnumLike> extends $ZodType {
|
| 747 |
+
_zod: $ZodEnumInternals<T>;
|
| 748 |
+
}
|
| 749 |
+
export declare const $ZodEnum: core.$constructor<$ZodEnum>;
|
| 750 |
+
export interface $ZodLiteralDef<T extends util.Literal> extends $ZodTypeDef {
|
| 751 |
+
type: "literal";
|
| 752 |
+
values: T[];
|
| 753 |
+
}
|
| 754 |
+
export interface $ZodLiteralInternals<T extends util.Literal = util.Literal> extends $ZodTypeInternals<T, T> {
|
| 755 |
+
def: $ZodLiteralDef<T>;
|
| 756 |
+
values: Set<T>;
|
| 757 |
+
pattern: RegExp;
|
| 758 |
+
isst: errors.$ZodIssueInvalidValue;
|
| 759 |
+
}
|
| 760 |
+
export interface $ZodLiteral<T extends util.Literal = util.Literal> extends $ZodType {
|
| 761 |
+
_zod: $ZodLiteralInternals<T>;
|
| 762 |
+
}
|
| 763 |
+
export declare const $ZodLiteral: core.$constructor<$ZodLiteral>;
|
| 764 |
+
declare global {
|
| 765 |
+
interface File {
|
| 766 |
+
}
|
| 767 |
+
}
|
| 768 |
+
export interface $ZodFileDef extends $ZodTypeDef {
|
| 769 |
+
type: "file";
|
| 770 |
+
}
|
| 771 |
+
export interface $ZodFileInternals extends $ZodTypeInternals<File, File> {
|
| 772 |
+
def: $ZodFileDef;
|
| 773 |
+
isst: errors.$ZodIssueInvalidType;
|
| 774 |
+
bag: util.LoosePartial<{
|
| 775 |
+
minimum: number;
|
| 776 |
+
maximum: number;
|
| 777 |
+
mime: util.MimeTypes[];
|
| 778 |
+
}>;
|
| 779 |
+
}
|
| 780 |
+
export interface $ZodFile extends $ZodType {
|
| 781 |
+
_zod: $ZodFileInternals;
|
| 782 |
+
}
|
| 783 |
+
export declare const $ZodFile: core.$constructor<$ZodFile>;
|
| 784 |
+
export interface $ZodTransformDef extends $ZodTypeDef {
|
| 785 |
+
type: "transform";
|
| 786 |
+
transform: (input: unknown, payload: ParsePayload<unknown>) => util.MaybeAsync<unknown>;
|
| 787 |
+
}
|
| 788 |
+
export interface $ZodTransformInternals<O = unknown, I = unknown> extends $ZodTypeInternals<O, I> {
|
| 789 |
+
def: $ZodTransformDef;
|
| 790 |
+
isst: never;
|
| 791 |
+
}
|
| 792 |
+
export interface $ZodTransform<O = unknown, I = unknown> extends $ZodType {
|
| 793 |
+
_zod: $ZodTransformInternals<O, I>;
|
| 794 |
+
}
|
| 795 |
+
export declare const $ZodTransform: core.$constructor<$ZodTransform>;
|
| 796 |
+
export interface $ZodOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 797 |
+
type: "optional";
|
| 798 |
+
innerType: T;
|
| 799 |
+
}
|
| 800 |
+
export interface $ZodOptionalInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T> | undefined, core.input<T> | undefined> {
|
| 801 |
+
def: $ZodOptionalDef<T>;
|
| 802 |
+
optin: "optional";
|
| 803 |
+
optout: "optional";
|
| 804 |
+
isst: never;
|
| 805 |
+
values: T["_zod"]["values"];
|
| 806 |
+
pattern: T["_zod"]["pattern"];
|
| 807 |
+
}
|
| 808 |
+
export interface $ZodOptional<T extends SomeType = $ZodType> extends $ZodType {
|
| 809 |
+
_zod: $ZodOptionalInternals<T>;
|
| 810 |
+
}
|
| 811 |
+
export declare const $ZodOptional: core.$constructor<$ZodOptional>;
|
| 812 |
+
export interface $ZodNullableDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 813 |
+
type: "nullable";
|
| 814 |
+
innerType: T;
|
| 815 |
+
}
|
| 816 |
+
export interface $ZodNullableInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T> | null, core.input<T> | null> {
|
| 817 |
+
def: $ZodNullableDef<T>;
|
| 818 |
+
optin: T["_zod"]["optin"];
|
| 819 |
+
optout: T["_zod"]["optout"];
|
| 820 |
+
isst: never;
|
| 821 |
+
values: T["_zod"]["values"];
|
| 822 |
+
pattern: T["_zod"]["pattern"];
|
| 823 |
+
}
|
| 824 |
+
export interface $ZodNullable<T extends SomeType = $ZodType> extends $ZodType {
|
| 825 |
+
_zod: $ZodNullableInternals<T>;
|
| 826 |
+
}
|
| 827 |
+
export declare const $ZodNullable: core.$constructor<$ZodNullable>;
|
| 828 |
+
export interface $ZodDefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 829 |
+
type: "default";
|
| 830 |
+
innerType: T;
|
| 831 |
+
/** The default value. May be a getter. */
|
| 832 |
+
defaultValue: util.NoUndefined<core.output<T>>;
|
| 833 |
+
}
|
| 834 |
+
export interface $ZodDefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
|
| 835 |
+
def: $ZodDefaultDef<T>;
|
| 836 |
+
optin: "optional";
|
| 837 |
+
optout?: "optional" | undefined;
|
| 838 |
+
isst: never;
|
| 839 |
+
values: T["_zod"]["values"];
|
| 840 |
+
}
|
| 841 |
+
export interface $ZodDefault<T extends SomeType = $ZodType> extends $ZodType {
|
| 842 |
+
_zod: $ZodDefaultInternals<T>;
|
| 843 |
+
}
|
| 844 |
+
export declare const $ZodDefault: core.$constructor<$ZodDefault>;
|
| 845 |
+
export interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 846 |
+
type: "prefault";
|
| 847 |
+
innerType: T;
|
| 848 |
+
/** The default value. May be a getter. */
|
| 849 |
+
defaultValue: core.input<T>;
|
| 850 |
+
}
|
| 851 |
+
export interface $ZodPrefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
|
| 852 |
+
def: $ZodPrefaultDef<T>;
|
| 853 |
+
optin: "optional";
|
| 854 |
+
optout?: "optional" | undefined;
|
| 855 |
+
isst: never;
|
| 856 |
+
values: T["_zod"]["values"];
|
| 857 |
+
}
|
| 858 |
+
export interface $ZodPrefault<T extends SomeType = $ZodType> extends $ZodType {
|
| 859 |
+
_zod: $ZodPrefaultInternals<T>;
|
| 860 |
+
}
|
| 861 |
+
export declare const $ZodPrefault: core.$constructor<$ZodPrefault>;
|
| 862 |
+
export interface $ZodNonOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 863 |
+
type: "nonoptional";
|
| 864 |
+
innerType: T;
|
| 865 |
+
}
|
| 866 |
+
export interface $ZodNonOptionalInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, util.NoUndefined<core.input<T>>> {
|
| 867 |
+
def: $ZodNonOptionalDef<T>;
|
| 868 |
+
isst: errors.$ZodIssueInvalidType;
|
| 869 |
+
values: T["_zod"]["values"];
|
| 870 |
+
optin: "optional" | undefined;
|
| 871 |
+
optout: "optional" | undefined;
|
| 872 |
+
}
|
| 873 |
+
export interface $ZodNonOptional<T extends SomeType = $ZodType> extends $ZodType {
|
| 874 |
+
_zod: $ZodNonOptionalInternals<T>;
|
| 875 |
+
}
|
| 876 |
+
export declare const $ZodNonOptional: core.$constructor<$ZodNonOptional>;
|
| 877 |
+
export interface $ZodSuccessDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 878 |
+
type: "success";
|
| 879 |
+
innerType: T;
|
| 880 |
+
}
|
| 881 |
+
export interface $ZodSuccessInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<boolean, core.input<T>> {
|
| 882 |
+
def: $ZodSuccessDef<T>;
|
| 883 |
+
isst: never;
|
| 884 |
+
optin: T["_zod"]["optin"];
|
| 885 |
+
optout: "optional" | undefined;
|
| 886 |
+
}
|
| 887 |
+
export interface $ZodSuccess<T extends SomeType = $ZodType> extends $ZodType {
|
| 888 |
+
_zod: $ZodSuccessInternals<T>;
|
| 889 |
+
}
|
| 890 |
+
export declare const $ZodSuccess: core.$constructor<$ZodSuccess>;
|
| 891 |
+
export interface $ZodCatchCtx extends ParsePayload {
|
| 892 |
+
/** @deprecated Use `ctx.issues` */
|
| 893 |
+
error: {
|
| 894 |
+
issues: errors.$ZodIssue[];
|
| 895 |
+
};
|
| 896 |
+
/** @deprecated Use `ctx.value` */
|
| 897 |
+
input: unknown;
|
| 898 |
+
}
|
| 899 |
+
export interface $ZodCatchDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 900 |
+
type: "catch";
|
| 901 |
+
innerType: T;
|
| 902 |
+
catchValue: (ctx: $ZodCatchCtx) => unknown;
|
| 903 |
+
}
|
| 904 |
+
export interface $ZodCatchInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, core.input<T> | util.Whatever> {
|
| 905 |
+
def: $ZodCatchDef<T>;
|
| 906 |
+
optin: T["_zod"]["optin"];
|
| 907 |
+
optout: T["_zod"]["optout"];
|
| 908 |
+
isst: never;
|
| 909 |
+
values: T["_zod"]["values"];
|
| 910 |
+
}
|
| 911 |
+
export interface $ZodCatch<T extends SomeType = $ZodType> extends $ZodType {
|
| 912 |
+
_zod: $ZodCatchInternals<T>;
|
| 913 |
+
}
|
| 914 |
+
export declare const $ZodCatch: core.$constructor<$ZodCatch>;
|
| 915 |
+
export interface $ZodNaNDef extends $ZodTypeDef {
|
| 916 |
+
type: "nan";
|
| 917 |
+
}
|
| 918 |
+
export interface $ZodNaNInternals extends $ZodTypeInternals<number, number> {
|
| 919 |
+
def: $ZodNaNDef;
|
| 920 |
+
isst: errors.$ZodIssueInvalidType;
|
| 921 |
+
}
|
| 922 |
+
export interface $ZodNaN extends $ZodType {
|
| 923 |
+
_zod: $ZodNaNInternals;
|
| 924 |
+
}
|
| 925 |
+
export declare const $ZodNaN: core.$constructor<$ZodNaN>;
|
| 926 |
+
export interface $ZodPipeDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 927 |
+
type: "pipe";
|
| 928 |
+
in: A;
|
| 929 |
+
out: B;
|
| 930 |
+
}
|
| 931 |
+
export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
|
| 932 |
+
def: $ZodPipeDef<A, B>;
|
| 933 |
+
isst: never;
|
| 934 |
+
values: A["_zod"]["values"];
|
| 935 |
+
optin: A["_zod"]["optin"];
|
| 936 |
+
optout: B["_zod"]["optout"];
|
| 937 |
+
}
|
| 938 |
+
export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
| 939 |
+
_zod: $ZodPipeInternals<A, B>;
|
| 940 |
+
}
|
| 941 |
+
export declare const $ZodPipe: core.$constructor<$ZodPipe>;
|
| 942 |
+
export interface $ZodReadonlyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 943 |
+
type: "readonly";
|
| 944 |
+
innerType: T;
|
| 945 |
+
}
|
| 946 |
+
export interface $ZodReadonlyInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.MakeReadonly<core.output<T>>, util.MakeReadonly<core.input<T>>> {
|
| 947 |
+
def: $ZodReadonlyDef<T>;
|
| 948 |
+
optin: T["_zod"]["optin"];
|
| 949 |
+
optout: T["_zod"]["optout"];
|
| 950 |
+
isst: never;
|
| 951 |
+
propValues: T["_zod"]["propValues"];
|
| 952 |
+
values: T["_zod"]["values"];
|
| 953 |
+
}
|
| 954 |
+
export interface $ZodReadonly<T extends SomeType = $ZodType> extends $ZodType {
|
| 955 |
+
_zod: $ZodReadonlyInternals<T>;
|
| 956 |
+
}
|
| 957 |
+
export declare const $ZodReadonly: core.$constructor<$ZodReadonly>;
|
| 958 |
+
export interface $ZodTemplateLiteralDef extends $ZodTypeDef {
|
| 959 |
+
type: "template_literal";
|
| 960 |
+
parts: $ZodTemplateLiteralPart[];
|
| 961 |
+
}
|
| 962 |
+
export interface $ZodTemplateLiteralInternals<Template extends string = string> extends $ZodTypeInternals<Template, Template> {
|
| 963 |
+
pattern: RegExp;
|
| 964 |
+
def: $ZodTemplateLiteralDef;
|
| 965 |
+
isst: errors.$ZodIssueInvalidType;
|
| 966 |
+
}
|
| 967 |
+
export interface $ZodTemplateLiteral<Template extends string = string> extends $ZodType {
|
| 968 |
+
_zod: $ZodTemplateLiteralInternals<Template>;
|
| 969 |
+
}
|
| 970 |
+
type LiteralPart = Exclude<util.Literal, symbol>;
|
| 971 |
+
interface SchemaPartInternals extends $ZodTypeInternals<LiteralPart, LiteralPart> {
|
| 972 |
+
pattern: RegExp;
|
| 973 |
+
}
|
| 974 |
+
interface SchemaPart extends $ZodType {
|
| 975 |
+
_zod: SchemaPartInternals;
|
| 976 |
+
}
|
| 977 |
+
export type $ZodTemplateLiteralPart = LiteralPart | SchemaPart;
|
| 978 |
+
type UndefinedToEmptyString<T> = T extends undefined ? "" : T;
|
| 979 |
+
type AppendToTemplateLiteral<Template extends string, Suffix extends LiteralPart | $ZodType> = Suffix extends LiteralPart ? `${Template}${UndefinedToEmptyString<Suffix>}` : Suffix extends $ZodType ? `${Template}${core.output<Suffix> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}` : never;
|
| 980 |
+
export type ConcatenateTupleOfStrings<T extends string[]> = T extends [
|
| 981 |
+
infer First extends string,
|
| 982 |
+
...infer Rest extends string[]
|
| 983 |
+
] ? Rest extends string[] ? First extends "" ? ConcatenateTupleOfStrings<Rest> : `${First}${ConcatenateTupleOfStrings<Rest>}` : never : "";
|
| 984 |
+
export type ConvertPartsToStringTuple<Parts extends $ZodTemplateLiteralPart[]> = {
|
| 985 |
+
[K in keyof Parts]: Parts[K] extends LiteralPart ? `${UndefinedToEmptyString<Parts[K]>}` : Parts[K] extends $ZodType ? `${core.output<Parts[K]> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}` : never;
|
| 986 |
+
};
|
| 987 |
+
export type ToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = ConcatenateTupleOfStrings<ConvertPartsToStringTuple<Parts>>;
|
| 988 |
+
export type $PartsToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = [] extends Parts ? `` : Parts extends [...infer Rest, infer Last extends $ZodTemplateLiteralPart] ? Rest extends $ZodTemplateLiteralPart[] ? AppendToTemplateLiteral<$PartsToTemplateLiteral<Rest>, Last> : never : never;
|
| 989 |
+
export declare const $ZodTemplateLiteral: core.$constructor<$ZodTemplateLiteral>;
|
| 990 |
+
export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 991 |
+
type: "promise";
|
| 992 |
+
innerType: T;
|
| 993 |
+
}
|
| 994 |
+
export interface $ZodPromiseInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, util.MaybeAsync<core.input<T>>> {
|
| 995 |
+
def: $ZodPromiseDef<T>;
|
| 996 |
+
isst: never;
|
| 997 |
+
}
|
| 998 |
+
export interface $ZodPromise<T extends SomeType = $ZodType> extends $ZodType {
|
| 999 |
+
_zod: $ZodPromiseInternals<T>;
|
| 1000 |
+
}
|
| 1001 |
+
export declare const $ZodPromise: core.$constructor<$ZodPromise>;
|
| 1002 |
+
export interface $ZodLazyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 1003 |
+
type: "lazy";
|
| 1004 |
+
getter: () => T;
|
| 1005 |
+
}
|
| 1006 |
+
export interface $ZodLazyInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, core.input<T>> {
|
| 1007 |
+
def: $ZodLazyDef<T>;
|
| 1008 |
+
isst: never;
|
| 1009 |
+
/** Auto-cached way to retrieve the inner schema */
|
| 1010 |
+
innerType: T;
|
| 1011 |
+
pattern: T["_zod"]["pattern"];
|
| 1012 |
+
propValues: T["_zod"]["propValues"];
|
| 1013 |
+
optin: T["_zod"]["optin"];
|
| 1014 |
+
optout: T["_zod"]["optout"];
|
| 1015 |
+
}
|
| 1016 |
+
export interface $ZodLazy<T extends SomeType = $ZodType> extends $ZodType {
|
| 1017 |
+
_zod: $ZodLazyInternals<T>;
|
| 1018 |
+
}
|
| 1019 |
+
export declare const $ZodLazy: core.$constructor<$ZodLazy>;
|
| 1020 |
+
export interface $ZodCustomDef<O = unknown> extends $ZodTypeDef, checks.$ZodCheckDef {
|
| 1021 |
+
type: "custom";
|
| 1022 |
+
check: "custom";
|
| 1023 |
+
path?: PropertyKey[] | undefined;
|
| 1024 |
+
error?: errors.$ZodErrorMap | undefined;
|
| 1025 |
+
params?: Record<string, any> | undefined;
|
| 1026 |
+
fn: (arg: O) => unknown;
|
| 1027 |
+
}
|
| 1028 |
+
export interface $ZodCustomInternals<O = unknown, I = unknown> extends $ZodTypeInternals<O, I>, checks.$ZodCheckInternals<O> {
|
| 1029 |
+
def: $ZodCustomDef;
|
| 1030 |
+
issc: errors.$ZodIssue;
|
| 1031 |
+
isst: never;
|
| 1032 |
+
bag: util.LoosePartial<{
|
| 1033 |
+
Class: typeof util.Class;
|
| 1034 |
+
}>;
|
| 1035 |
+
}
|
| 1036 |
+
export interface $ZodCustom<O = unknown, I = unknown> extends $ZodType {
|
| 1037 |
+
_zod: $ZodCustomInternals<O, I>;
|
| 1038 |
+
}
|
| 1039 |
+
export declare const $ZodCustom: core.$constructor<$ZodCustom>;
|
| 1040 |
+
export type $ZodTypes = $ZodString | $ZodNumber | $ZodBigInt | $ZodBoolean | $ZodDate | $ZodSymbol | $ZodUndefined | $ZodNullable | $ZodNull | $ZodAny | $ZodUnknown | $ZodNever | $ZodVoid | $ZodArray | $ZodObject | $ZodUnion | $ZodIntersection | $ZodTuple | $ZodRecord | $ZodMap | $ZodSet | $ZodLiteral | $ZodEnum | $ZodPromise | $ZodLazy | $ZodOptional | $ZodDefault | $ZodPrefault | $ZodTemplateLiteral | $ZodCustom | $ZodTransform | $ZodNonOptional | $ZodReadonly | $ZodNaN | $ZodPipe | $ZodSuccess | $ZodCatch | $ZodFile;
|
| 1041 |
+
export type $ZodStringFormatTypes = $ZodGUID | $ZodUUID | $ZodEmail | $ZodURL | $ZodEmoji | $ZodNanoID | $ZodCUID | $ZodCUID2 | $ZodULID | $ZodXID | $ZodKSUID | $ZodISODateTime | $ZodISODate | $ZodISOTime | $ZodISODuration | $ZodIPv4 | $ZodIPv6 | $ZodCIDRv4 | $ZodCIDRv6 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as checks from "./checks.js";
|
| 2 |
+
import * as core from "./core.js";
|
| 3 |
+
import { Doc } from "./doc.js";
|
| 4 |
+
import { safeParse, safeParseAsync } from "./parse.js";
|
| 5 |
+
import * as regexes from "./regexes.js";
|
| 6 |
+
import * as util from "./util.js";
|
| 7 |
+
import { version } from "./versions.js";
|
| 8 |
+
export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def) => {
|
| 9 |
+
var _a;
|
| 10 |
+
inst ?? (inst = {});
|
| 11 |
+
inst._zod.def = def; // set _def property
|
| 12 |
+
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
| 13 |
+
inst._zod.version = version;
|
| 14 |
+
const checks = [...(inst._zod.def.checks ?? [])];
|
| 15 |
+
// if inst is itself a checks.$ZodCheck, run it as a check
|
| 16 |
+
if (inst._zod.traits.has("$ZodCheck")) {
|
| 17 |
+
checks.unshift(inst);
|
| 18 |
+
}
|
| 19 |
+
//
|
| 20 |
+
for (const ch of checks) {
|
| 21 |
+
for (const fn of ch._zod.onattach) {
|
| 22 |
+
fn(inst);
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
if (checks.length === 0) {
|
| 26 |
+
// deferred initializer
|
| 27 |
+
// inst._zod.parse is not yet defined
|
| 28 |
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
| 29 |
+
inst._zod.deferred?.push(() => {
|
| 30 |
+
inst._zod.run = inst._zod.parse;
|
| 31 |
+
});
|
| 32 |
+
}
|
| 33 |
+
else {
|
| 34 |
+
const runChecks = (payload, checks, ctx) => {
|
| 35 |
+
let isAborted = util.aborted(payload);
|
| 36 |
+
let asyncResult;
|
| 37 |
+
for (const ch of checks) {
|
| 38 |
+
if (ch._zod.def.when) {
|
| 39 |
+
const shouldRun = ch._zod.def.when(payload);
|
| 40 |
+
if (!shouldRun)
|
| 41 |
+
continue;
|
| 42 |
+
}
|
| 43 |
+
else if (isAborted) {
|
| 44 |
+
continue;
|
| 45 |
+
}
|
| 46 |
+
const currLen = payload.issues.length;
|
| 47 |
+
const _ = ch._zod.check(payload);
|
| 48 |
+
if (_ instanceof Promise && ctx?.async === false) {
|
| 49 |
+
throw new core.$ZodAsyncError();
|
| 50 |
+
}
|
| 51 |
+
if (asyncResult || _ instanceof Promise) {
|
| 52 |
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
| 53 |
+
await _;
|
| 54 |
+
const nextLen = payload.issues.length;
|
| 55 |
+
if (nextLen === currLen)
|
| 56 |
+
return;
|
| 57 |
+
if (!isAborted)
|
| 58 |
+
isAborted = util.aborted(payload, currLen);
|
| 59 |
+
});
|
| 60 |
+
}
|
| 61 |
+
else {
|
| 62 |
+
const nextLen = payload.issues.length;
|
| 63 |
+
if (nextLen === currLen)
|
| 64 |
+
continue;
|
| 65 |
+
if (!isAborted)
|
| 66 |
+
isAborted = util.aborted(payload, currLen);
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
if (asyncResult) {
|
| 70 |
+
return asyncResult.then(() => {
|
| 71 |
+
return payload;
|
| 72 |
+
});
|
| 73 |
+
}
|
| 74 |
+
return payload;
|
| 75 |
+
};
|
| 76 |
+
inst._zod.run = (payload, ctx) => {
|
| 77 |
+
const result = inst._zod.parse(payload, ctx);
|
| 78 |
+
if (result instanceof Promise) {
|
| 79 |
+
if (ctx.async === false)
|
| 80 |
+
throw new core.$ZodAsyncError();
|
| 81 |
+
return result.then((result) => runChecks(result, checks, ctx));
|
| 82 |
+
}
|
| 83 |
+
return runChecks(result, checks, ctx);
|
| 84 |
+
};
|
| 85 |
+
}
|
| 86 |
+
inst["~standard"] = {
|
| 87 |
+
validate: (value) => {
|
| 88 |
+
try {
|
| 89 |
+
const r = safeParse(inst, value);
|
| 90 |
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
| 91 |
+
}
|
| 92 |
+
catch (_) {
|
| 93 |
+
return safeParseAsync(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
vendor: "zod",
|
| 97 |
+
version: 1,
|
| 98 |
+
};
|
| 99 |
+
});
|
| 100 |
+
export { clone } from "./util.js";
|
| 101 |
+
export const $ZodString = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
|
| 102 |
+
$ZodType.init(inst, def);
|
| 103 |
+
inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? regexes.string(inst._zod.bag);
|
| 104 |
+
inst._zod.parse = (payload, _) => {
|
| 105 |
+
if (def.coerce)
|
| 106 |
+
try {
|
| 107 |
+
payload.value = String(payload.value);
|
| 108 |
+
}
|
| 109 |
+
catch (_) { }
|
| 110 |
+
if (typeof payload.value === "string")
|
| 111 |
+
return payload;
|
| 112 |
+
payload.issues.push({
|
| 113 |
+
expected: "string",
|
| 114 |
+
code: "invalid_type",
|
| 115 |
+
input: payload.value,
|
| 116 |
+
inst,
|
| 117 |
+
});
|
| 118 |
+
return payload;
|
| 119 |
+
};
|
| 120 |
+
});
|
| 121 |
+
export const $ZodStringFormat = /*@__PURE__*/ core.$constructor("$ZodStringFormat", (inst, def) => {
|
| 122 |
+
// check initialization must come first
|
| 123 |
+
checks.$ZodCheckStringFormat.init(inst, def);
|
| 124 |
+
$ZodString.init(inst, def);
|
| 125 |
+
});
|
| 126 |
+
export const $ZodGUID = /*@__PURE__*/ core.$constructor("$ZodGUID", (inst, def) => {
|
| 127 |
+
def.pattern ?? (def.pattern = regexes.guid);
|
| 128 |
+
$ZodStringFormat.init(inst, def);
|
| 129 |
+
});
|
| 130 |
+
export const $ZodUUID = /*@__PURE__*/ core.$constructor("$ZodUUID", (inst, def) => {
|
| 131 |
+
if (def.version) {
|
| 132 |
+
const versionMap = {
|
| 133 |
+
v1: 1,
|
| 134 |
+
v2: 2,
|
| 135 |
+
v3: 3,
|
| 136 |
+
v4: 4,
|
| 137 |
+
v5: 5,
|
| 138 |
+
v6: 6,
|
| 139 |
+
v7: 7,
|
| 140 |
+
v8: 8,
|
| 141 |
+
};
|
| 142 |
+
const v = versionMap[def.version];
|
| 143 |
+
if (v === undefined)
|
| 144 |
+
throw new Error(`Invalid UUID version: "${def.version}"`);
|
| 145 |
+
def.pattern ?? (def.pattern = regexes.uuid(v));
|
| 146 |
+
}
|
| 147 |
+
else
|
| 148 |
+
def.pattern ?? (def.pattern = regexes.uuid());
|
| 149 |
+
$ZodStringFormat.init(inst, def);
|
| 150 |
+
});
|
| 151 |
+
export const $ZodEmail = /*@__PURE__*/ core.$constructor("$ZodEmail", (inst, def) => {
|
| 152 |
+
def.pattern ?? (def.pattern = regexes.email);
|
| 153 |
+
$ZodStringFormat.init(inst, def);
|
| 154 |
+
});
|
| 155 |
+
export const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
|
| 156 |
+
$ZodStringFormat.init(inst, def);
|
| 157 |
+
inst._zod.check = (payload) => {
|
| 158 |
+
try {
|
| 159 |
+
const orig = payload.value;
|
| 160 |
+
const url = new URL(orig);
|
| 161 |
+
const href = url.href;
|
| 162 |
+
if (def.hostname) {
|
| 163 |
+
def.hostname.lastIndex = 0;
|
| 164 |
+
if (!def.hostname.test(url.hostname)) {
|
| 165 |
+
payload.issues.push({
|
| 166 |
+
code: "invalid_format",
|
| 167 |
+
format: "url",
|
| 168 |
+
note: "Invalid hostname",
|
| 169 |
+
pattern: regexes.hostname.source,
|
| 170 |
+
input: payload.value,
|
| 171 |
+
inst,
|
| 172 |
+
continue: !def.abort,
|
| 173 |
+
});
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
if (def.protocol) {
|
| 177 |
+
def.protocol.lastIndex = 0;
|
| 178 |
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
|
| 179 |
+
payload.issues.push({
|
| 180 |
+
code: "invalid_format",
|
| 181 |
+
format: "url",
|
| 182 |
+
note: "Invalid protocol",
|
| 183 |
+
pattern: def.protocol.source,
|
| 184 |
+
input: payload.value,
|
| 185 |
+
inst,
|
| 186 |
+
continue: !def.abort,
|
| 187 |
+
});
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
// payload.value = url.href;
|
| 191 |
+
if (!orig.endsWith("/") && href.endsWith("/")) {
|
| 192 |
+
payload.value = href.slice(0, -1);
|
| 193 |
+
}
|
| 194 |
+
else {
|
| 195 |
+
payload.value = href;
|
| 196 |
+
}
|
| 197 |
+
return;
|
| 198 |
+
}
|
| 199 |
+
catch (_) {
|
| 200 |
+
payload.issues.push({
|
| 201 |
+
code: "invalid_format",
|
| 202 |
+
format: "url",
|
| 203 |
+
input: payload.value,
|
| 204 |
+
inst,
|
| 205 |
+
continue: !def.abort,
|
| 206 |
+
});
|
| 207 |
+
}
|
| 208 |
+
};
|
| 209 |
+
});
|
| 210 |
+
export const $ZodEmoji = /*@__PURE__*/ core.$constructor("$ZodEmoji", (inst, def) => {
|
| 211 |
+
def.pattern ?? (def.pattern = regexes.emoji());
|
| 212 |
+
$ZodStringFormat.init(inst, def);
|
| 213 |
+
});
|
| 214 |
+
export const $ZodNanoID = /*@__PURE__*/ core.$constructor("$ZodNanoID", (inst, def) => {
|
| 215 |
+
def.pattern ?? (def.pattern = regexes.nanoid);
|
| 216 |
+
$ZodStringFormat.init(inst, def);
|
| 217 |
+
});
|
| 218 |
+
export const $ZodCUID = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def) => {
|
| 219 |
+
def.pattern ?? (def.pattern = regexes.cuid);
|
| 220 |
+
$ZodStringFormat.init(inst, def);
|
| 221 |
+
});
|
| 222 |
+
export const $ZodCUID2 = /*@__PURE__*/ core.$constructor("$ZodCUID2", (inst, def) => {
|
| 223 |
+
def.pattern ?? (def.pattern = regexes.cuid2);
|
| 224 |
+
$ZodStringFormat.init(inst, def);
|
| 225 |
+
});
|
| 226 |
+
export const $ZodULID = /*@__PURE__*/ core.$constructor("$ZodULID", (inst, def) => {
|
| 227 |
+
def.pattern ?? (def.pattern = regexes.ulid);
|
| 228 |
+
$ZodStringFormat.init(inst, def);
|
| 229 |
+
});
|
| 230 |
+
export const $ZodXID = /*@__PURE__*/ core.$constructor("$ZodXID", (inst, def) => {
|
| 231 |
+
def.pattern ?? (def.pattern = regexes.xid);
|
| 232 |
+
$ZodStringFormat.init(inst, def);
|
| 233 |
+
});
|
| 234 |
+
export const $ZodKSUID = /*@__PURE__*/ core.$constructor("$ZodKSUID", (inst, def) => {
|
| 235 |
+
def.pattern ?? (def.pattern = regexes.ksuid);
|
| 236 |
+
$ZodStringFormat.init(inst, def);
|
| 237 |
+
});
|
| 238 |
+
export const $ZodISODateTime = /*@__PURE__*/ core.$constructor("$ZodISODateTime", (inst, def) => {
|
| 239 |
+
def.pattern ?? (def.pattern = regexes.datetime(def));
|
| 240 |
+
$ZodStringFormat.init(inst, def);
|
| 241 |
+
});
|
| 242 |
+
export const $ZodISODate = /*@__PURE__*/ core.$constructor("$ZodISODate", (inst, def) => {
|
| 243 |
+
def.pattern ?? (def.pattern = regexes.date);
|
| 244 |
+
$ZodStringFormat.init(inst, def);
|
| 245 |
+
});
|
| 246 |
+
export const $ZodISOTime = /*@__PURE__*/ core.$constructor("$ZodISOTime", (inst, def) => {
|
| 247 |
+
def.pattern ?? (def.pattern = regexes.time(def));
|
| 248 |
+
$ZodStringFormat.init(inst, def);
|
| 249 |
+
});
|
| 250 |
+
export const $ZodISODuration = /*@__PURE__*/ core.$constructor("$ZodISODuration", (inst, def) => {
|
| 251 |
+
def.pattern ?? (def.pattern = regexes.duration);
|
| 252 |
+
$ZodStringFormat.init(inst, def);
|
| 253 |
+
});
|
| 254 |
+
export const $ZodIPv4 = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def) => {
|
| 255 |
+
def.pattern ?? (def.pattern = regexes.ipv4);
|
| 256 |
+
$ZodStringFormat.init(inst, def);
|
| 257 |
+
inst._zod.onattach.push((inst) => {
|
| 258 |
+
const bag = inst._zod.bag;
|
| 259 |
+
bag.format = `ipv4`;
|
| 260 |
+
});
|
| 261 |
+
});
|
| 262 |
+
export const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def) => {
|
| 263 |
+
def.pattern ?? (def.pattern = regexes.ipv6);
|
| 264 |
+
$ZodStringFormat.init(inst, def);
|
| 265 |
+
inst._zod.onattach.push((inst) => {
|
| 266 |
+
const bag = inst._zod.bag;
|
| 267 |
+
bag.format = `ipv6`;
|
| 268 |
+
});
|
| 269 |
+
inst._zod.check = (payload) => {
|
| 270 |
+
try {
|
| 271 |
+
new URL(`http://[${payload.value}]`);
|
| 272 |
+
// return;
|
| 273 |
+
}
|
| 274 |
+
catch {
|
| 275 |
+
payload.issues.push({
|
| 276 |
+
code: "invalid_format",
|
| 277 |
+
format: "ipv6",
|
| 278 |
+
input: payload.value,
|
| 279 |
+
inst,
|
| 280 |
+
continue: !def.abort,
|
| 281 |
+
});
|
| 282 |
+
}
|
| 283 |
+
};
|
| 284 |
+
});
|
| 285 |
+
export const $ZodCIDRv4 = /*@__PURE__*/ core.$constructor("$ZodCIDRv4", (inst, def) => {
|
| 286 |
+
def.pattern ?? (def.pattern = regexes.cidrv4);
|
| 287 |
+
$ZodStringFormat.init(inst, def);
|
| 288 |
+
});
|
| 289 |
+
export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, def) => {
|
| 290 |
+
def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
|
| 291 |
+
$ZodStringFormat.init(inst, def);
|
| 292 |
+
inst._zod.check = (payload) => {
|
| 293 |
+
const [address, prefix] = payload.value.split("/");
|
| 294 |
+
try {
|
| 295 |
+
if (!prefix)
|
| 296 |
+
throw new Error();
|
| 297 |
+
const prefixNum = Number(prefix);
|
| 298 |
+
if (`${prefixNum}` !== prefix)
|
| 299 |
+
throw new Error();
|
| 300 |
+
if (prefixNum < 0 || prefixNum > 128)
|
| 301 |
+
throw new Error();
|
| 302 |
+
new URL(`http://[${address}]`);
|
| 303 |
+
}
|
| 304 |
+
catch {
|
| 305 |
+
payload.issues.push({
|
| 306 |
+
code: "invalid_format",
|
| 307 |
+
format: "cidrv6",
|
| 308 |
+
input: payload.value,
|
| 309 |
+
inst,
|
| 310 |
+
continue: !def.abort,
|
| 311 |
+
});
|
| 312 |
+
}
|
| 313 |
+
};
|
| 314 |
+
});
|
| 315 |
+
////////////////////////////// ZodBase64 //////////////////////////////
|
| 316 |
+
export function isValidBase64(data) {
|
| 317 |
+
if (data === "")
|
| 318 |
+
return true;
|
| 319 |
+
if (data.length % 4 !== 0)
|
| 320 |
+
return false;
|
| 321 |
+
try {
|
| 322 |
+
atob(data);
|
| 323 |
+
return true;
|
| 324 |
+
}
|
| 325 |
+
catch {
|
| 326 |
+
return false;
|
| 327 |
+
}
|
| 328 |
+
}
|
| 329 |
+
export const $ZodBase64 = /*@__PURE__*/ core.$constructor("$ZodBase64", (inst, def) => {
|
| 330 |
+
def.pattern ?? (def.pattern = regexes.base64);
|
| 331 |
+
$ZodStringFormat.init(inst, def);
|
| 332 |
+
inst._zod.onattach.push((inst) => {
|
| 333 |
+
inst._zod.bag.contentEncoding = "base64";
|
| 334 |
+
});
|
| 335 |
+
inst._zod.check = (payload) => {
|
| 336 |
+
if (isValidBase64(payload.value))
|
| 337 |
+
return;
|
| 338 |
+
payload.issues.push({
|
| 339 |
+
code: "invalid_format",
|
| 340 |
+
format: "base64",
|
| 341 |
+
input: payload.value,
|
| 342 |
+
inst,
|
| 343 |
+
continue: !def.abort,
|
| 344 |
+
});
|
| 345 |
+
};
|
| 346 |
+
});
|
| 347 |
+
////////////////////////////// ZodBase64 //////////////////////////////
|
| 348 |
+
export function isValidBase64URL(data) {
|
| 349 |
+
if (!regexes.base64url.test(data))
|
| 350 |
+
return false;
|
| 351 |
+
const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
|
| 352 |
+
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
| 353 |
+
return isValidBase64(padded);
|
| 354 |
+
}
|
| 355 |
+
export const $ZodBase64URL = /*@__PURE__*/ core.$constructor("$ZodBase64URL", (inst, def) => {
|
| 356 |
+
def.pattern ?? (def.pattern = regexes.base64url);
|
| 357 |
+
$ZodStringFormat.init(inst, def);
|
| 358 |
+
inst._zod.onattach.push((inst) => {
|
| 359 |
+
inst._zod.bag.contentEncoding = "base64url";
|
| 360 |
+
});
|
| 361 |
+
inst._zod.check = (payload) => {
|
| 362 |
+
if (isValidBase64URL(payload.value))
|
| 363 |
+
return;
|
| 364 |
+
payload.issues.push({
|
| 365 |
+
code: "invalid_format",
|
| 366 |
+
format: "base64url",
|
| 367 |
+
input: payload.value,
|
| 368 |
+
inst,
|
| 369 |
+
continue: !def.abort,
|
| 370 |
+
});
|
| 371 |
+
};
|
| 372 |
+
});
|
| 373 |
+
export const $ZodE164 = /*@__PURE__*/ core.$constructor("$ZodE164", (inst, def) => {
|
| 374 |
+
def.pattern ?? (def.pattern = regexes.e164);
|
| 375 |
+
$ZodStringFormat.init(inst, def);
|
| 376 |
+
});
|
| 377 |
+
////////////////////////////// ZodJWT //////////////////////////////
|
| 378 |
+
export function isValidJWT(token, algorithm = null) {
|
| 379 |
+
try {
|
| 380 |
+
const tokensParts = token.split(".");
|
| 381 |
+
if (tokensParts.length !== 3)
|
| 382 |
+
return false;
|
| 383 |
+
const [header] = tokensParts;
|
| 384 |
+
if (!header)
|
| 385 |
+
return false;
|
| 386 |
+
const parsedHeader = JSON.parse(atob(header));
|
| 387 |
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
| 388 |
+
return false;
|
| 389 |
+
if (!parsedHeader.alg)
|
| 390 |
+
return false;
|
| 391 |
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
|
| 392 |
+
return false;
|
| 393 |
+
return true;
|
| 394 |
+
}
|
| 395 |
+
catch {
|
| 396 |
+
return false;
|
| 397 |
+
}
|
| 398 |
+
}
|
| 399 |
+
export const $ZodJWT = /*@__PURE__*/ core.$constructor("$ZodJWT", (inst, def) => {
|
| 400 |
+
$ZodStringFormat.init(inst, def);
|
| 401 |
+
inst._zod.check = (payload) => {
|
| 402 |
+
if (isValidJWT(payload.value, def.alg))
|
| 403 |
+
return;
|
| 404 |
+
payload.issues.push({
|
| 405 |
+
code: "invalid_format",
|
| 406 |
+
format: "jwt",
|
| 407 |
+
input: payload.value,
|
| 408 |
+
inst,
|
| 409 |
+
continue: !def.abort,
|
| 410 |
+
});
|
| 411 |
+
};
|
| 412 |
+
});
|
| 413 |
+
export const $ZodCustomStringFormat = /*@__PURE__*/ core.$constructor("$ZodCustomStringFormat", (inst, def) => {
|
| 414 |
+
$ZodStringFormat.init(inst, def);
|
| 415 |
+
inst._zod.check = (payload) => {
|
| 416 |
+
if (def.fn(payload.value))
|
| 417 |
+
return;
|
| 418 |
+
payload.issues.push({
|
| 419 |
+
code: "invalid_format",
|
| 420 |
+
format: def.format,
|
| 421 |
+
input: payload.value,
|
| 422 |
+
inst,
|
| 423 |
+
continue: !def.abort,
|
| 424 |
+
});
|
| 425 |
+
};
|
| 426 |
+
});
|
| 427 |
+
export const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
|
| 428 |
+
$ZodType.init(inst, def);
|
| 429 |
+
inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;
|
| 430 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 431 |
+
if (def.coerce)
|
| 432 |
+
try {
|
| 433 |
+
payload.value = Number(payload.value);
|
| 434 |
+
}
|
| 435 |
+
catch (_) { }
|
| 436 |
+
const input = payload.value;
|
| 437 |
+
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
|
| 438 |
+
return payload;
|
| 439 |
+
}
|
| 440 |
+
const received = typeof input === "number"
|
| 441 |
+
? Number.isNaN(input)
|
| 442 |
+
? "NaN"
|
| 443 |
+
: !Number.isFinite(input)
|
| 444 |
+
? "Infinity"
|
| 445 |
+
: undefined
|
| 446 |
+
: undefined;
|
| 447 |
+
payload.issues.push({
|
| 448 |
+
expected: "number",
|
| 449 |
+
code: "invalid_type",
|
| 450 |
+
input,
|
| 451 |
+
inst,
|
| 452 |
+
...(received ? { received } : {}),
|
| 453 |
+
});
|
| 454 |
+
return payload;
|
| 455 |
+
};
|
| 456 |
+
});
|
| 457 |
+
export const $ZodNumberFormat = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
|
| 458 |
+
checks.$ZodCheckNumberFormat.init(inst, def);
|
| 459 |
+
$ZodNumber.init(inst, def); // no format checksp
|
| 460 |
+
});
|
| 461 |
+
export const $ZodBoolean = /*@__PURE__*/ core.$constructor("$ZodBoolean", (inst, def) => {
|
| 462 |
+
$ZodType.init(inst, def);
|
| 463 |
+
inst._zod.pattern = regexes.boolean;
|
| 464 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 465 |
+
if (def.coerce)
|
| 466 |
+
try {
|
| 467 |
+
payload.value = Boolean(payload.value);
|
| 468 |
+
}
|
| 469 |
+
catch (_) { }
|
| 470 |
+
const input = payload.value;
|
| 471 |
+
if (typeof input === "boolean")
|
| 472 |
+
return payload;
|
| 473 |
+
payload.issues.push({
|
| 474 |
+
expected: "boolean",
|
| 475 |
+
code: "invalid_type",
|
| 476 |
+
input,
|
| 477 |
+
inst,
|
| 478 |
+
});
|
| 479 |
+
return payload;
|
| 480 |
+
};
|
| 481 |
+
});
|
| 482 |
+
export const $ZodBigInt = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, def) => {
|
| 483 |
+
$ZodType.init(inst, def);
|
| 484 |
+
inst._zod.pattern = regexes.bigint;
|
| 485 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 486 |
+
if (def.coerce)
|
| 487 |
+
try {
|
| 488 |
+
payload.value = BigInt(payload.value);
|
| 489 |
+
}
|
| 490 |
+
catch (_) { }
|
| 491 |
+
if (typeof payload.value === "bigint")
|
| 492 |
+
return payload;
|
| 493 |
+
payload.issues.push({
|
| 494 |
+
expected: "bigint",
|
| 495 |
+
code: "invalid_type",
|
| 496 |
+
input: payload.value,
|
| 497 |
+
inst,
|
| 498 |
+
});
|
| 499 |
+
return payload;
|
| 500 |
+
};
|
| 501 |
+
});
|
| 502 |
+
export const $ZodBigIntFormat = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, def) => {
|
| 503 |
+
checks.$ZodCheckBigIntFormat.init(inst, def);
|
| 504 |
+
$ZodBigInt.init(inst, def); // no format checks
|
| 505 |
+
});
|
| 506 |
+
export const $ZodSymbol = /*@__PURE__*/ core.$constructor("$ZodSymbol", (inst, def) => {
|
| 507 |
+
$ZodType.init(inst, def);
|
| 508 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 509 |
+
const input = payload.value;
|
| 510 |
+
if (typeof input === "symbol")
|
| 511 |
+
return payload;
|
| 512 |
+
payload.issues.push({
|
| 513 |
+
expected: "symbol",
|
| 514 |
+
code: "invalid_type",
|
| 515 |
+
input,
|
| 516 |
+
inst,
|
| 517 |
+
});
|
| 518 |
+
return payload;
|
| 519 |
+
};
|
| 520 |
+
});
|
| 521 |
+
export const $ZodUndefined = /*@__PURE__*/ core.$constructor("$ZodUndefined", (inst, def) => {
|
| 522 |
+
$ZodType.init(inst, def);
|
| 523 |
+
inst._zod.pattern = regexes.undefined;
|
| 524 |
+
inst._zod.values = new Set([undefined]);
|
| 525 |
+
inst._zod.optin = "optional";
|
| 526 |
+
inst._zod.optout = "optional";
|
| 527 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 528 |
+
const input = payload.value;
|
| 529 |
+
if (typeof input === "undefined")
|
| 530 |
+
return payload;
|
| 531 |
+
payload.issues.push({
|
| 532 |
+
expected: "undefined",
|
| 533 |
+
code: "invalid_type",
|
| 534 |
+
input,
|
| 535 |
+
inst,
|
| 536 |
+
});
|
| 537 |
+
return payload;
|
| 538 |
+
};
|
| 539 |
+
});
|
| 540 |
+
export const $ZodNull = /*@__PURE__*/ core.$constructor("$ZodNull", (inst, def) => {
|
| 541 |
+
$ZodType.init(inst, def);
|
| 542 |
+
inst._zod.pattern = regexes.null;
|
| 543 |
+
inst._zod.values = new Set([null]);
|
| 544 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 545 |
+
const input = payload.value;
|
| 546 |
+
if (input === null)
|
| 547 |
+
return payload;
|
| 548 |
+
payload.issues.push({
|
| 549 |
+
expected: "null",
|
| 550 |
+
code: "invalid_type",
|
| 551 |
+
input,
|
| 552 |
+
inst,
|
| 553 |
+
});
|
| 554 |
+
return payload;
|
| 555 |
+
};
|
| 556 |
+
});
|
| 557 |
+
export const $ZodAny = /*@__PURE__*/ core.$constructor("$ZodAny", (inst, def) => {
|
| 558 |
+
$ZodType.init(inst, def);
|
| 559 |
+
inst._zod.parse = (payload) => payload;
|
| 560 |
+
});
|
| 561 |
+
export const $ZodUnknown = /*@__PURE__*/ core.$constructor("$ZodUnknown", (inst, def) => {
|
| 562 |
+
$ZodType.init(inst, def);
|
| 563 |
+
inst._zod.parse = (payload) => payload;
|
| 564 |
+
});
|
| 565 |
+
export const $ZodNever = /*@__PURE__*/ core.$constructor("$ZodNever", (inst, def) => {
|
| 566 |
+
$ZodType.init(inst, def);
|
| 567 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 568 |
+
payload.issues.push({
|
| 569 |
+
expected: "never",
|
| 570 |
+
code: "invalid_type",
|
| 571 |
+
input: payload.value,
|
| 572 |
+
inst,
|
| 573 |
+
});
|
| 574 |
+
return payload;
|
| 575 |
+
};
|
| 576 |
+
});
|
| 577 |
+
export const $ZodVoid = /*@__PURE__*/ core.$constructor("$ZodVoid", (inst, def) => {
|
| 578 |
+
$ZodType.init(inst, def);
|
| 579 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 580 |
+
const input = payload.value;
|
| 581 |
+
if (typeof input === "undefined")
|
| 582 |
+
return payload;
|
| 583 |
+
payload.issues.push({
|
| 584 |
+
expected: "void",
|
| 585 |
+
code: "invalid_type",
|
| 586 |
+
input,
|
| 587 |
+
inst,
|
| 588 |
+
});
|
| 589 |
+
return payload;
|
| 590 |
+
};
|
| 591 |
+
});
|
| 592 |
+
export const $ZodDate = /*@__PURE__*/ core.$constructor("$ZodDate", (inst, def) => {
|
| 593 |
+
$ZodType.init(inst, def);
|
| 594 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 595 |
+
if (def.coerce) {
|
| 596 |
+
try {
|
| 597 |
+
payload.value = new Date(payload.value);
|
| 598 |
+
}
|
| 599 |
+
catch (_err) { }
|
| 600 |
+
}
|
| 601 |
+
const input = payload.value;
|
| 602 |
+
const isDate = input instanceof Date;
|
| 603 |
+
const isValidDate = isDate && !Number.isNaN(input.getTime());
|
| 604 |
+
if (isValidDate)
|
| 605 |
+
return payload;
|
| 606 |
+
payload.issues.push({
|
| 607 |
+
expected: "date",
|
| 608 |
+
code: "invalid_type",
|
| 609 |
+
input,
|
| 610 |
+
...(isDate ? { received: "Invalid Date" } : {}),
|
| 611 |
+
inst,
|
| 612 |
+
});
|
| 613 |
+
return payload;
|
| 614 |
+
};
|
| 615 |
+
});
|
| 616 |
+
function handleArrayResult(result, final, index) {
|
| 617 |
+
if (result.issues.length) {
|
| 618 |
+
final.issues.push(...util.prefixIssues(index, result.issues));
|
| 619 |
+
}
|
| 620 |
+
final.value[index] = result.value;
|
| 621 |
+
}
|
| 622 |
+
export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
|
| 623 |
+
$ZodType.init(inst, def);
|
| 624 |
+
inst._zod.parse = (payload, ctx) => {
|
| 625 |
+
const input = payload.value;
|
| 626 |
+
if (!Array.isArray(input)) {
|
| 627 |
+
payload.issues.push({
|
| 628 |
+
expected: "array",
|
| 629 |
+
code: "invalid_type",
|
| 630 |
+
input,
|
| 631 |
+
inst,
|
| 632 |
+
});
|
| 633 |
+
return payload;
|
| 634 |
+
}
|
| 635 |
+
payload.value = Array(input.length);
|
| 636 |
+
const proms = [];
|
| 637 |
+
for (let i = 0; i < input.length; i++) {
|
| 638 |
+
const item = input[i];
|
| 639 |
+
const result = def.element._zod.run({
|
| 640 |
+
value: item,
|
| 641 |
+
issues: [],
|
| 642 |
+
}, ctx);
|
| 643 |
+
if (result instanceof Promise) {
|
| 644 |
+
proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
| 645 |
+
}
|
| 646 |
+
else {
|
| 647 |
+
handleArrayResult(result, payload, i);
|
| 648 |
+
}
|
| 649 |
+
}
|
| 650 |
+
if (proms.length) {
|
| 651 |
+
return Promise.all(proms).then(() => payload);
|
| 652 |
+
}
|
| 653 |
+
return payload; //handleArrayResultsAsync(parseResults, final);
|
| 654 |
+
};
|
| 655 |
+
});
|
| 656 |
+
function handleObjectResult(result, final, key) {
|
| 657 |
+
// if(isOptional)
|
| 658 |
+
if (result.issues.length) {
|
| 659 |
+
final.issues.push(...util.prefixIssues(key, result.issues));
|
| 660 |
+
}
|
| 661 |
+
final.value[key] = result.value;
|
| 662 |
+
}
|
| 663 |
+
function handleOptionalObjectResult(result, final, key, input) {
|
| 664 |
+
if (result.issues.length) {
|
| 665 |
+
// validation failed against value schema
|
| 666 |
+
if (input[key] === undefined) {
|
| 667 |
+
// if input was undefined, ignore the error
|
| 668 |
+
if (key in input) {
|
| 669 |
+
final.value[key] = undefined;
|
| 670 |
+
}
|
| 671 |
+
else {
|
| 672 |
+
final.value[key] = result.value;
|
| 673 |
+
}
|
| 674 |
+
}
|
| 675 |
+
else {
|
| 676 |
+
final.issues.push(...util.prefixIssues(key, result.issues));
|
| 677 |
+
}
|
| 678 |
+
}
|
| 679 |
+
else if (result.value === undefined) {
|
| 680 |
+
// validation returned `undefined`
|
| 681 |
+
if (key in input)
|
| 682 |
+
final.value[key] = undefined;
|
| 683 |
+
}
|
| 684 |
+
else {
|
| 685 |
+
// non-undefined value
|
| 686 |
+
final.value[key] = result.value;
|
| 687 |
+
}
|
| 688 |
+
}
|
| 689 |
+
export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
|
| 690 |
+
// requires cast because technically $ZodObject doesn't extend
|
| 691 |
+
$ZodType.init(inst, def);
|
| 692 |
+
const _normalized = util.cached(() => {
|
| 693 |
+
const keys = Object.keys(def.shape);
|
| 694 |
+
for (const k of keys) {
|
| 695 |
+
if (!(def.shape[k] instanceof $ZodType)) {
|
| 696 |
+
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
| 697 |
+
}
|
| 698 |
+
}
|
| 699 |
+
const okeys = util.optionalKeys(def.shape);
|
| 700 |
+
return {
|
| 701 |
+
shape: def.shape,
|
| 702 |
+
keys,
|
| 703 |
+
keySet: new Set(keys),
|
| 704 |
+
numKeys: keys.length,
|
| 705 |
+
optionalKeys: new Set(okeys),
|
| 706 |
+
};
|
| 707 |
+
});
|
| 708 |
+
util.defineLazy(inst._zod, "propValues", () => {
|
| 709 |
+
const shape = def.shape;
|
| 710 |
+
const propValues = {};
|
| 711 |
+
for (const key in shape) {
|
| 712 |
+
const field = shape[key]._zod;
|
| 713 |
+
if (field.values) {
|
| 714 |
+
propValues[key] ?? (propValues[key] = new Set());
|
| 715 |
+
for (const v of field.values)
|
| 716 |
+
propValues[key].add(v);
|
| 717 |
+
}
|
| 718 |
+
}
|
| 719 |
+
return propValues;
|
| 720 |
+
});
|
| 721 |
+
const generateFastpass = (shape) => {
|
| 722 |
+
const doc = new Doc(["shape", "payload", "ctx"]);
|
| 723 |
+
const normalized = _normalized.value;
|
| 724 |
+
const parseStr = (key) => {
|
| 725 |
+
const k = util.esc(key);
|
| 726 |
+
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
| 727 |
+
};
|
| 728 |
+
doc.write(`const input = payload.value;`);
|
| 729 |
+
const ids = Object.create(null);
|
| 730 |
+
let counter = 0;
|
| 731 |
+
for (const key of normalized.keys) {
|
| 732 |
+
ids[key] = `key_${counter++}`;
|
| 733 |
+
}
|
| 734 |
+
// A: preserve key order {
|
| 735 |
+
doc.write(`const newResult = {}`);
|
| 736 |
+
for (const key of normalized.keys) {
|
| 737 |
+
if (normalized.optionalKeys.has(key)) {
|
| 738 |
+
const id = ids[key];
|
| 739 |
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
| 740 |
+
const k = util.esc(key);
|
| 741 |
+
doc.write(`
|
| 742 |
+
if (${id}.issues.length) {
|
| 743 |
+
if (input[${k}] === undefined) {
|
| 744 |
+
if (${k} in input) {
|
| 745 |
+
newResult[${k}] = undefined;
|
| 746 |
+
}
|
| 747 |
+
} else {
|
| 748 |
+
payload.issues = payload.issues.concat(
|
| 749 |
+
${id}.issues.map((iss) => ({
|
| 750 |
+
...iss,
|
| 751 |
+
path: iss.path ? [${k}, ...iss.path] : [${k}],
|
| 752 |
+
}))
|
| 753 |
+
);
|
| 754 |
+
}
|
| 755 |
+
} else if (${id}.value === undefined) {
|
| 756 |
+
if (${k} in input) newResult[${k}] = undefined;
|
| 757 |
+
} else {
|
| 758 |
+
newResult[${k}] = ${id}.value;
|
| 759 |
+
}
|
| 760 |
+
`);
|
| 761 |
+
}
|
| 762 |
+
else {
|
| 763 |
+
const id = ids[key];
|
| 764 |
+
// const id = ids[key];
|
| 765 |
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
| 766 |
+
doc.write(`
|
| 767 |
+
if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
| 768 |
+
...iss,
|
| 769 |
+
path: iss.path ? [${util.esc(key)}, ...iss.path] : [${util.esc(key)}]
|
| 770 |
+
})));`);
|
| 771 |
+
doc.write(`newResult[${util.esc(key)}] = ${id}.value`);
|
| 772 |
+
}
|
| 773 |
+
}
|
| 774 |
+
doc.write(`payload.value = newResult;`);
|
| 775 |
+
doc.write(`return payload;`);
|
| 776 |
+
const fn = doc.compile();
|
| 777 |
+
return (payload, ctx) => fn(shape, payload, ctx);
|
| 778 |
+
};
|
| 779 |
+
let fastpass;
|
| 780 |
+
const isObject = util.isObject;
|
| 781 |
+
const jit = !core.globalConfig.jitless;
|
| 782 |
+
const allowsEval = util.allowsEval;
|
| 783 |
+
const fastEnabled = jit && allowsEval.value; // && !def.catchall;
|
| 784 |
+
const catchall = def.catchall;
|
| 785 |
+
let value;
|
| 786 |
+
inst._zod.parse = (payload, ctx) => {
|
| 787 |
+
value ?? (value = _normalized.value);
|
| 788 |
+
const input = payload.value;
|
| 789 |
+
if (!isObject(input)) {
|
| 790 |
+
payload.issues.push({
|
| 791 |
+
expected: "object",
|
| 792 |
+
code: "invalid_type",
|
| 793 |
+
input,
|
| 794 |
+
inst,
|
| 795 |
+
});
|
| 796 |
+
return payload;
|
| 797 |
+
}
|
| 798 |
+
const proms = [];
|
| 799 |
+
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
| 800 |
+
// always synchronous
|
| 801 |
+
if (!fastpass)
|
| 802 |
+
fastpass = generateFastpass(def.shape);
|
| 803 |
+
payload = fastpass(payload, ctx);
|
| 804 |
+
}
|
| 805 |
+
else {
|
| 806 |
+
payload.value = {};
|
| 807 |
+
const shape = value.shape;
|
| 808 |
+
for (const key of value.keys) {
|
| 809 |
+
const el = shape[key];
|
| 810 |
+
// do not add omitted optional keys
|
| 811 |
+
// if (!(key in input)) {
|
| 812 |
+
// if (optionalKeys.has(key)) continue;
|
| 813 |
+
// payload.issues.push({
|
| 814 |
+
// code: "invalid_type",
|
| 815 |
+
// path: [key],
|
| 816 |
+
// expected: "nonoptional",
|
| 817 |
+
// note: `Missing required key: "${key}"`,
|
| 818 |
+
// input,
|
| 819 |
+
// inst,
|
| 820 |
+
// });
|
| 821 |
+
// }
|
| 822 |
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
| 823 |
+
const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
|
| 824 |
+
if (r instanceof Promise) {
|
| 825 |
+
proms.push(r.then((r) => isOptional ? handleOptionalObjectResult(r, payload, key, input) : handleObjectResult(r, payload, key)));
|
| 826 |
+
}
|
| 827 |
+
else if (isOptional) {
|
| 828 |
+
handleOptionalObjectResult(r, payload, key, input);
|
| 829 |
+
}
|
| 830 |
+
else {
|
| 831 |
+
handleObjectResult(r, payload, key);
|
| 832 |
+
}
|
| 833 |
+
}
|
| 834 |
+
}
|
| 835 |
+
if (!catchall) {
|
| 836 |
+
// return payload;
|
| 837 |
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
| 838 |
+
}
|
| 839 |
+
const unrecognized = [];
|
| 840 |
+
// iterate over input keys
|
| 841 |
+
const keySet = value.keySet;
|
| 842 |
+
const _catchall = catchall._zod;
|
| 843 |
+
const t = _catchall.def.type;
|
| 844 |
+
for (const key of Object.keys(input)) {
|
| 845 |
+
if (keySet.has(key))
|
| 846 |
+
continue;
|
| 847 |
+
if (t === "never") {
|
| 848 |
+
unrecognized.push(key);
|
| 849 |
+
continue;
|
| 850 |
+
}
|
| 851 |
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
| 852 |
+
if (r instanceof Promise) {
|
| 853 |
+
proms.push(r.then((r) => handleObjectResult(r, payload, key)));
|
| 854 |
+
}
|
| 855 |
+
else {
|
| 856 |
+
handleObjectResult(r, payload, key);
|
| 857 |
+
}
|
| 858 |
+
}
|
| 859 |
+
if (unrecognized.length) {
|
| 860 |
+
payload.issues.push({
|
| 861 |
+
code: "unrecognized_keys",
|
| 862 |
+
keys: unrecognized,
|
| 863 |
+
input,
|
| 864 |
+
inst,
|
| 865 |
+
});
|
| 866 |
+
}
|
| 867 |
+
if (!proms.length)
|
| 868 |
+
return payload;
|
| 869 |
+
return Promise.all(proms).then(() => {
|
| 870 |
+
return payload;
|
| 871 |
+
});
|
| 872 |
+
};
|
| 873 |
+
});
|
| 874 |
+
function handleUnionResults(results, final, inst, ctx) {
|
| 875 |
+
for (const result of results) {
|
| 876 |
+
if (result.issues.length === 0) {
|
| 877 |
+
final.value = result.value;
|
| 878 |
+
return final;
|
| 879 |
+
}
|
| 880 |
+
}
|
| 881 |
+
final.issues.push({
|
| 882 |
+
code: "invalid_union",
|
| 883 |
+
input: final.value,
|
| 884 |
+
inst,
|
| 885 |
+
errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
|
| 886 |
+
});
|
| 887 |
+
return final;
|
| 888 |
+
}
|
| 889 |
+
export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
|
| 890 |
+
$ZodType.init(inst, def);
|
| 891 |
+
util.defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
|
| 892 |
+
util.defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
| 893 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 894 |
+
if (def.options.every((o) => o._zod.values)) {
|
| 895 |
+
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
| 896 |
+
}
|
| 897 |
+
return undefined;
|
| 898 |
+
});
|
| 899 |
+
util.defineLazy(inst._zod, "pattern", () => {
|
| 900 |
+
if (def.options.every((o) => o._zod.pattern)) {
|
| 901 |
+
const patterns = def.options.map((o) => o._zod.pattern);
|
| 902 |
+
return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
|
| 903 |
+
}
|
| 904 |
+
return undefined;
|
| 905 |
+
});
|
| 906 |
+
inst._zod.parse = (payload, ctx) => {
|
| 907 |
+
let async = false;
|
| 908 |
+
const results = [];
|
| 909 |
+
for (const option of def.options) {
|
| 910 |
+
const result = option._zod.run({
|
| 911 |
+
value: payload.value,
|
| 912 |
+
issues: [],
|
| 913 |
+
}, ctx);
|
| 914 |
+
if (result instanceof Promise) {
|
| 915 |
+
results.push(result);
|
| 916 |
+
async = true;
|
| 917 |
+
}
|
| 918 |
+
else {
|
| 919 |
+
if (result.issues.length === 0)
|
| 920 |
+
return result;
|
| 921 |
+
results.push(result);
|
| 922 |
+
}
|
| 923 |
+
}
|
| 924 |
+
if (!async)
|
| 925 |
+
return handleUnionResults(results, payload, inst, ctx);
|
| 926 |
+
return Promise.all(results).then((results) => {
|
| 927 |
+
return handleUnionResults(results, payload, inst, ctx);
|
| 928 |
+
});
|
| 929 |
+
};
|
| 930 |
+
});
|
| 931 |
+
export const $ZodDiscriminatedUnion =
|
| 932 |
+
/*@__PURE__*/
|
| 933 |
+
core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
| 934 |
+
$ZodUnion.init(inst, def);
|
| 935 |
+
const _super = inst._zod.parse;
|
| 936 |
+
util.defineLazy(inst._zod, "propValues", () => {
|
| 937 |
+
const propValues = {};
|
| 938 |
+
for (const option of def.options) {
|
| 939 |
+
const pv = option._zod.propValues;
|
| 940 |
+
if (!pv || Object.keys(pv).length === 0)
|
| 941 |
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
| 942 |
+
for (const [k, v] of Object.entries(pv)) {
|
| 943 |
+
if (!propValues[k])
|
| 944 |
+
propValues[k] = new Set();
|
| 945 |
+
for (const val of v) {
|
| 946 |
+
propValues[k].add(val);
|
| 947 |
+
}
|
| 948 |
+
}
|
| 949 |
+
}
|
| 950 |
+
return propValues;
|
| 951 |
+
});
|
| 952 |
+
const disc = util.cached(() => {
|
| 953 |
+
const opts = def.options;
|
| 954 |
+
const map = new Map();
|
| 955 |
+
for (const o of opts) {
|
| 956 |
+
const values = o._zod.propValues[def.discriminator];
|
| 957 |
+
if (!values || values.size === 0)
|
| 958 |
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
| 959 |
+
for (const v of values) {
|
| 960 |
+
if (map.has(v)) {
|
| 961 |
+
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
| 962 |
+
}
|
| 963 |
+
map.set(v, o);
|
| 964 |
+
}
|
| 965 |
+
}
|
| 966 |
+
return map;
|
| 967 |
+
});
|
| 968 |
+
inst._zod.parse = (payload, ctx) => {
|
| 969 |
+
const input = payload.value;
|
| 970 |
+
if (!util.isObject(input)) {
|
| 971 |
+
payload.issues.push({
|
| 972 |
+
code: "invalid_type",
|
| 973 |
+
expected: "object",
|
| 974 |
+
input,
|
| 975 |
+
inst,
|
| 976 |
+
});
|
| 977 |
+
return payload;
|
| 978 |
+
}
|
| 979 |
+
const opt = disc.value.get(input?.[def.discriminator]);
|
| 980 |
+
if (opt) {
|
| 981 |
+
return opt._zod.run(payload, ctx);
|
| 982 |
+
}
|
| 983 |
+
if (def.unionFallback) {
|
| 984 |
+
return _super(payload, ctx);
|
| 985 |
+
}
|
| 986 |
+
// no matching discriminator
|
| 987 |
+
payload.issues.push({
|
| 988 |
+
code: "invalid_union",
|
| 989 |
+
errors: [],
|
| 990 |
+
note: "No matching discriminator",
|
| 991 |
+
input,
|
| 992 |
+
path: [def.discriminator],
|
| 993 |
+
inst,
|
| 994 |
+
});
|
| 995 |
+
return payload;
|
| 996 |
+
};
|
| 997 |
+
});
|
| 998 |
+
export const $ZodIntersection = /*@__PURE__*/ core.$constructor("$ZodIntersection", (inst, def) => {
|
| 999 |
+
$ZodType.init(inst, def);
|
| 1000 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1001 |
+
const input = payload.value;
|
| 1002 |
+
const left = def.left._zod.run({ value: input, issues: [] }, ctx);
|
| 1003 |
+
const right = def.right._zod.run({ value: input, issues: [] }, ctx);
|
| 1004 |
+
const async = left instanceof Promise || right instanceof Promise;
|
| 1005 |
+
if (async) {
|
| 1006 |
+
return Promise.all([left, right]).then(([left, right]) => {
|
| 1007 |
+
return handleIntersectionResults(payload, left, right);
|
| 1008 |
+
});
|
| 1009 |
+
}
|
| 1010 |
+
return handleIntersectionResults(payload, left, right);
|
| 1011 |
+
};
|
| 1012 |
+
});
|
| 1013 |
+
function mergeValues(a, b) {
|
| 1014 |
+
// const aType = parse.t(a);
|
| 1015 |
+
// const bType = parse.t(b);
|
| 1016 |
+
if (a === b) {
|
| 1017 |
+
return { valid: true, data: a };
|
| 1018 |
+
}
|
| 1019 |
+
if (a instanceof Date && b instanceof Date && +a === +b) {
|
| 1020 |
+
return { valid: true, data: a };
|
| 1021 |
+
}
|
| 1022 |
+
if (util.isPlainObject(a) && util.isPlainObject(b)) {
|
| 1023 |
+
const bKeys = Object.keys(b);
|
| 1024 |
+
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
| 1025 |
+
const newObj = { ...a, ...b };
|
| 1026 |
+
for (const key of sharedKeys) {
|
| 1027 |
+
const sharedValue = mergeValues(a[key], b[key]);
|
| 1028 |
+
if (!sharedValue.valid) {
|
| 1029 |
+
return {
|
| 1030 |
+
valid: false,
|
| 1031 |
+
mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
|
| 1032 |
+
};
|
| 1033 |
+
}
|
| 1034 |
+
newObj[key] = sharedValue.data;
|
| 1035 |
+
}
|
| 1036 |
+
return { valid: true, data: newObj };
|
| 1037 |
+
}
|
| 1038 |
+
if (Array.isArray(a) && Array.isArray(b)) {
|
| 1039 |
+
if (a.length !== b.length) {
|
| 1040 |
+
return { valid: false, mergeErrorPath: [] };
|
| 1041 |
+
}
|
| 1042 |
+
const newArray = [];
|
| 1043 |
+
for (let index = 0; index < a.length; index++) {
|
| 1044 |
+
const itemA = a[index];
|
| 1045 |
+
const itemB = b[index];
|
| 1046 |
+
const sharedValue = mergeValues(itemA, itemB);
|
| 1047 |
+
if (!sharedValue.valid) {
|
| 1048 |
+
return {
|
| 1049 |
+
valid: false,
|
| 1050 |
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
|
| 1051 |
+
};
|
| 1052 |
+
}
|
| 1053 |
+
newArray.push(sharedValue.data);
|
| 1054 |
+
}
|
| 1055 |
+
return { valid: true, data: newArray };
|
| 1056 |
+
}
|
| 1057 |
+
return { valid: false, mergeErrorPath: [] };
|
| 1058 |
+
}
|
| 1059 |
+
function handleIntersectionResults(result, left, right) {
|
| 1060 |
+
if (left.issues.length) {
|
| 1061 |
+
result.issues.push(...left.issues);
|
| 1062 |
+
}
|
| 1063 |
+
if (right.issues.length) {
|
| 1064 |
+
result.issues.push(...right.issues);
|
| 1065 |
+
}
|
| 1066 |
+
if (util.aborted(result))
|
| 1067 |
+
return result;
|
| 1068 |
+
const merged = mergeValues(left.value, right.value);
|
| 1069 |
+
if (!merged.valid) {
|
| 1070 |
+
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
| 1071 |
+
}
|
| 1072 |
+
result.value = merged.data;
|
| 1073 |
+
return result;
|
| 1074 |
+
}
|
| 1075 |
+
export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
|
| 1076 |
+
$ZodType.init(inst, def);
|
| 1077 |
+
const items = def.items;
|
| 1078 |
+
const optStart = items.length - [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
|
| 1079 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1080 |
+
const input = payload.value;
|
| 1081 |
+
if (!Array.isArray(input)) {
|
| 1082 |
+
payload.issues.push({
|
| 1083 |
+
input,
|
| 1084 |
+
inst,
|
| 1085 |
+
expected: "tuple",
|
| 1086 |
+
code: "invalid_type",
|
| 1087 |
+
});
|
| 1088 |
+
return payload;
|
| 1089 |
+
}
|
| 1090 |
+
payload.value = [];
|
| 1091 |
+
const proms = [];
|
| 1092 |
+
if (!def.rest) {
|
| 1093 |
+
const tooBig = input.length > items.length;
|
| 1094 |
+
const tooSmall = input.length < optStart - 1;
|
| 1095 |
+
if (tooBig || tooSmall) {
|
| 1096 |
+
payload.issues.push({
|
| 1097 |
+
input,
|
| 1098 |
+
inst,
|
| 1099 |
+
origin: "array",
|
| 1100 |
+
...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
|
| 1101 |
+
});
|
| 1102 |
+
return payload;
|
| 1103 |
+
}
|
| 1104 |
+
}
|
| 1105 |
+
let i = -1;
|
| 1106 |
+
for (const item of items) {
|
| 1107 |
+
i++;
|
| 1108 |
+
if (i >= input.length)
|
| 1109 |
+
if (i >= optStart)
|
| 1110 |
+
continue;
|
| 1111 |
+
const result = item._zod.run({
|
| 1112 |
+
value: input[i],
|
| 1113 |
+
issues: [],
|
| 1114 |
+
}, ctx);
|
| 1115 |
+
if (result instanceof Promise) {
|
| 1116 |
+
proms.push(result.then((result) => handleTupleResult(result, payload, i)));
|
| 1117 |
+
}
|
| 1118 |
+
else {
|
| 1119 |
+
handleTupleResult(result, payload, i);
|
| 1120 |
+
}
|
| 1121 |
+
}
|
| 1122 |
+
if (def.rest) {
|
| 1123 |
+
const rest = input.slice(items.length);
|
| 1124 |
+
for (const el of rest) {
|
| 1125 |
+
i++;
|
| 1126 |
+
const result = def.rest._zod.run({
|
| 1127 |
+
value: el,
|
| 1128 |
+
issues: [],
|
| 1129 |
+
}, ctx);
|
| 1130 |
+
if (result instanceof Promise) {
|
| 1131 |
+
proms.push(result.then((result) => handleTupleResult(result, payload, i)));
|
| 1132 |
+
}
|
| 1133 |
+
else {
|
| 1134 |
+
handleTupleResult(result, payload, i);
|
| 1135 |
+
}
|
| 1136 |
+
}
|
| 1137 |
+
}
|
| 1138 |
+
if (proms.length)
|
| 1139 |
+
return Promise.all(proms).then(() => payload);
|
| 1140 |
+
return payload;
|
| 1141 |
+
};
|
| 1142 |
+
});
|
| 1143 |
+
function handleTupleResult(result, final, index) {
|
| 1144 |
+
if (result.issues.length) {
|
| 1145 |
+
final.issues.push(...util.prefixIssues(index, result.issues));
|
| 1146 |
+
}
|
| 1147 |
+
final.value[index] = result.value;
|
| 1148 |
+
}
|
| 1149 |
+
export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
|
| 1150 |
+
$ZodType.init(inst, def);
|
| 1151 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1152 |
+
const input = payload.value;
|
| 1153 |
+
if (!util.isPlainObject(input)) {
|
| 1154 |
+
payload.issues.push({
|
| 1155 |
+
expected: "record",
|
| 1156 |
+
code: "invalid_type",
|
| 1157 |
+
input,
|
| 1158 |
+
inst,
|
| 1159 |
+
});
|
| 1160 |
+
return payload;
|
| 1161 |
+
}
|
| 1162 |
+
const proms = [];
|
| 1163 |
+
if (def.keyType._zod.values) {
|
| 1164 |
+
const values = def.keyType._zod.values;
|
| 1165 |
+
payload.value = {};
|
| 1166 |
+
for (const key of values) {
|
| 1167 |
+
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
| 1168 |
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
| 1169 |
+
if (result instanceof Promise) {
|
| 1170 |
+
proms.push(result.then((result) => {
|
| 1171 |
+
if (result.issues.length) {
|
| 1172 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1173 |
+
}
|
| 1174 |
+
payload.value[key] = result.value;
|
| 1175 |
+
}));
|
| 1176 |
+
}
|
| 1177 |
+
else {
|
| 1178 |
+
if (result.issues.length) {
|
| 1179 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1180 |
+
}
|
| 1181 |
+
payload.value[key] = result.value;
|
| 1182 |
+
}
|
| 1183 |
+
}
|
| 1184 |
+
}
|
| 1185 |
+
let unrecognized;
|
| 1186 |
+
for (const key in input) {
|
| 1187 |
+
if (!values.has(key)) {
|
| 1188 |
+
unrecognized = unrecognized ?? [];
|
| 1189 |
+
unrecognized.push(key);
|
| 1190 |
+
}
|
| 1191 |
+
}
|
| 1192 |
+
if (unrecognized && unrecognized.length > 0) {
|
| 1193 |
+
payload.issues.push({
|
| 1194 |
+
code: "unrecognized_keys",
|
| 1195 |
+
input,
|
| 1196 |
+
inst,
|
| 1197 |
+
keys: unrecognized,
|
| 1198 |
+
});
|
| 1199 |
+
}
|
| 1200 |
+
}
|
| 1201 |
+
else {
|
| 1202 |
+
payload.value = {};
|
| 1203 |
+
for (const key of Reflect.ownKeys(input)) {
|
| 1204 |
+
if (key === "__proto__")
|
| 1205 |
+
continue;
|
| 1206 |
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
| 1207 |
+
if (keyResult instanceof Promise) {
|
| 1208 |
+
throw new Error("Async schemas not supported in object keys currently");
|
| 1209 |
+
}
|
| 1210 |
+
if (keyResult.issues.length) {
|
| 1211 |
+
payload.issues.push({
|
| 1212 |
+
origin: "record",
|
| 1213 |
+
code: "invalid_key",
|
| 1214 |
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1215 |
+
input: key,
|
| 1216 |
+
path: [key],
|
| 1217 |
+
inst,
|
| 1218 |
+
});
|
| 1219 |
+
payload.value[keyResult.value] = keyResult.value;
|
| 1220 |
+
continue;
|
| 1221 |
+
}
|
| 1222 |
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
| 1223 |
+
if (result instanceof Promise) {
|
| 1224 |
+
proms.push(result.then((result) => {
|
| 1225 |
+
if (result.issues.length) {
|
| 1226 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1227 |
+
}
|
| 1228 |
+
payload.value[keyResult.value] = result.value;
|
| 1229 |
+
}));
|
| 1230 |
+
}
|
| 1231 |
+
else {
|
| 1232 |
+
if (result.issues.length) {
|
| 1233 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1234 |
+
}
|
| 1235 |
+
payload.value[keyResult.value] = result.value;
|
| 1236 |
+
}
|
| 1237 |
+
}
|
| 1238 |
+
}
|
| 1239 |
+
if (proms.length) {
|
| 1240 |
+
return Promise.all(proms).then(() => payload);
|
| 1241 |
+
}
|
| 1242 |
+
return payload;
|
| 1243 |
+
};
|
| 1244 |
+
});
|
| 1245 |
+
export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
|
| 1246 |
+
$ZodType.init(inst, def);
|
| 1247 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1248 |
+
const input = payload.value;
|
| 1249 |
+
if (!(input instanceof Map)) {
|
| 1250 |
+
payload.issues.push({
|
| 1251 |
+
expected: "map",
|
| 1252 |
+
code: "invalid_type",
|
| 1253 |
+
input,
|
| 1254 |
+
inst,
|
| 1255 |
+
});
|
| 1256 |
+
return payload;
|
| 1257 |
+
}
|
| 1258 |
+
const proms = [];
|
| 1259 |
+
payload.value = new Map();
|
| 1260 |
+
for (const [key, value] of input) {
|
| 1261 |
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
| 1262 |
+
const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
|
| 1263 |
+
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
| 1264 |
+
proms.push(Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
|
| 1265 |
+
handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
|
| 1266 |
+
}));
|
| 1267 |
+
}
|
| 1268 |
+
else {
|
| 1269 |
+
handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
|
| 1270 |
+
}
|
| 1271 |
+
}
|
| 1272 |
+
if (proms.length)
|
| 1273 |
+
return Promise.all(proms).then(() => payload);
|
| 1274 |
+
return payload;
|
| 1275 |
+
};
|
| 1276 |
+
});
|
| 1277 |
+
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
| 1278 |
+
if (keyResult.issues.length) {
|
| 1279 |
+
if (util.propertyKeyTypes.has(typeof key)) {
|
| 1280 |
+
final.issues.push(...util.prefixIssues(key, keyResult.issues));
|
| 1281 |
+
}
|
| 1282 |
+
else {
|
| 1283 |
+
final.issues.push({
|
| 1284 |
+
origin: "map",
|
| 1285 |
+
code: "invalid_key",
|
| 1286 |
+
input,
|
| 1287 |
+
inst,
|
| 1288 |
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1289 |
+
});
|
| 1290 |
+
}
|
| 1291 |
+
}
|
| 1292 |
+
if (valueResult.issues.length) {
|
| 1293 |
+
if (util.propertyKeyTypes.has(typeof key)) {
|
| 1294 |
+
final.issues.push(...util.prefixIssues(key, valueResult.issues));
|
| 1295 |
+
}
|
| 1296 |
+
else {
|
| 1297 |
+
final.issues.push({
|
| 1298 |
+
origin: "map",
|
| 1299 |
+
code: "invalid_element",
|
| 1300 |
+
input,
|
| 1301 |
+
inst,
|
| 1302 |
+
key: key,
|
| 1303 |
+
issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1304 |
+
});
|
| 1305 |
+
}
|
| 1306 |
+
}
|
| 1307 |
+
final.value.set(keyResult.value, valueResult.value);
|
| 1308 |
+
}
|
| 1309 |
+
export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
|
| 1310 |
+
$ZodType.init(inst, def);
|
| 1311 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1312 |
+
const input = payload.value;
|
| 1313 |
+
if (!(input instanceof Set)) {
|
| 1314 |
+
payload.issues.push({
|
| 1315 |
+
input,
|
| 1316 |
+
inst,
|
| 1317 |
+
expected: "set",
|
| 1318 |
+
code: "invalid_type",
|
| 1319 |
+
});
|
| 1320 |
+
return payload;
|
| 1321 |
+
}
|
| 1322 |
+
const proms = [];
|
| 1323 |
+
payload.value = new Set();
|
| 1324 |
+
for (const item of input) {
|
| 1325 |
+
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
| 1326 |
+
if (result instanceof Promise) {
|
| 1327 |
+
proms.push(result.then((result) => handleSetResult(result, payload)));
|
| 1328 |
+
}
|
| 1329 |
+
else
|
| 1330 |
+
handleSetResult(result, payload);
|
| 1331 |
+
}
|
| 1332 |
+
if (proms.length)
|
| 1333 |
+
return Promise.all(proms).then(() => payload);
|
| 1334 |
+
return payload;
|
| 1335 |
+
};
|
| 1336 |
+
});
|
| 1337 |
+
function handleSetResult(result, final) {
|
| 1338 |
+
if (result.issues.length) {
|
| 1339 |
+
final.issues.push(...result.issues);
|
| 1340 |
+
}
|
| 1341 |
+
final.value.add(result.value);
|
| 1342 |
+
}
|
| 1343 |
+
export const $ZodEnum = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def) => {
|
| 1344 |
+
$ZodType.init(inst, def);
|
| 1345 |
+
const values = util.getEnumValues(def.entries);
|
| 1346 |
+
inst._zod.values = new Set(values);
|
| 1347 |
+
inst._zod.pattern = new RegExp(`^(${values
|
| 1348 |
+
.filter((k) => util.propertyKeyTypes.has(typeof k))
|
| 1349 |
+
.map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString()))
|
| 1350 |
+
.join("|")})$`);
|
| 1351 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1352 |
+
const input = payload.value;
|
| 1353 |
+
if (inst._zod.values.has(input)) {
|
| 1354 |
+
return payload;
|
| 1355 |
+
}
|
| 1356 |
+
payload.issues.push({
|
| 1357 |
+
code: "invalid_value",
|
| 1358 |
+
values,
|
| 1359 |
+
input,
|
| 1360 |
+
inst,
|
| 1361 |
+
});
|
| 1362 |
+
return payload;
|
| 1363 |
+
};
|
| 1364 |
+
});
|
| 1365 |
+
export const $ZodLiteral = /*@__PURE__*/ core.$constructor("$ZodLiteral", (inst, def) => {
|
| 1366 |
+
$ZodType.init(inst, def);
|
| 1367 |
+
inst._zod.values = new Set(def.values);
|
| 1368 |
+
inst._zod.pattern = new RegExp(`^(${def.values
|
| 1369 |
+
.map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? o.toString() : String(o)))
|
| 1370 |
+
.join("|")})$`);
|
| 1371 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1372 |
+
const input = payload.value;
|
| 1373 |
+
if (inst._zod.values.has(input)) {
|
| 1374 |
+
return payload;
|
| 1375 |
+
}
|
| 1376 |
+
payload.issues.push({
|
| 1377 |
+
code: "invalid_value",
|
| 1378 |
+
values: def.values,
|
| 1379 |
+
input,
|
| 1380 |
+
inst,
|
| 1381 |
+
});
|
| 1382 |
+
return payload;
|
| 1383 |
+
};
|
| 1384 |
+
});
|
| 1385 |
+
export const $ZodFile = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def) => {
|
| 1386 |
+
$ZodType.init(inst, def);
|
| 1387 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1388 |
+
const input = payload.value;
|
| 1389 |
+
if (input instanceof File)
|
| 1390 |
+
return payload;
|
| 1391 |
+
payload.issues.push({
|
| 1392 |
+
expected: "file",
|
| 1393 |
+
code: "invalid_type",
|
| 1394 |
+
input,
|
| 1395 |
+
inst,
|
| 1396 |
+
});
|
| 1397 |
+
return payload;
|
| 1398 |
+
};
|
| 1399 |
+
});
|
| 1400 |
+
export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (inst, def) => {
|
| 1401 |
+
$ZodType.init(inst, def);
|
| 1402 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1403 |
+
const _out = def.transform(payload.value, payload);
|
| 1404 |
+
if (_ctx.async) {
|
| 1405 |
+
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
| 1406 |
+
return output.then((output) => {
|
| 1407 |
+
payload.value = output;
|
| 1408 |
+
return payload;
|
| 1409 |
+
});
|
| 1410 |
+
}
|
| 1411 |
+
if (_out instanceof Promise) {
|
| 1412 |
+
throw new core.$ZodAsyncError();
|
| 1413 |
+
}
|
| 1414 |
+
payload.value = _out;
|
| 1415 |
+
return payload;
|
| 1416 |
+
};
|
| 1417 |
+
});
|
| 1418 |
+
export const $ZodOptional = /*@__PURE__*/ core.$constructor("$ZodOptional", (inst, def) => {
|
| 1419 |
+
$ZodType.init(inst, def);
|
| 1420 |
+
inst._zod.optin = "optional";
|
| 1421 |
+
inst._zod.optout = "optional";
|
| 1422 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1423 |
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
|
| 1424 |
+
});
|
| 1425 |
+
util.defineLazy(inst._zod, "pattern", () => {
|
| 1426 |
+
const pattern = def.innerType._zod.pattern;
|
| 1427 |
+
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
|
| 1428 |
+
});
|
| 1429 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1430 |
+
if (def.innerType._zod.optin === "optional") {
|
| 1431 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1432 |
+
}
|
| 1433 |
+
if (payload.value === undefined) {
|
| 1434 |
+
return payload;
|
| 1435 |
+
}
|
| 1436 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1437 |
+
};
|
| 1438 |
+
});
|
| 1439 |
+
export const $ZodNullable = /*@__PURE__*/ core.$constructor("$ZodNullable", (inst, def) => {
|
| 1440 |
+
$ZodType.init(inst, def);
|
| 1441 |
+
util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
| 1442 |
+
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
| 1443 |
+
util.defineLazy(inst._zod, "pattern", () => {
|
| 1444 |
+
const pattern = def.innerType._zod.pattern;
|
| 1445 |
+
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
|
| 1446 |
+
});
|
| 1447 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1448 |
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
| 1449 |
+
});
|
| 1450 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1451 |
+
if (payload.value === null)
|
| 1452 |
+
return payload;
|
| 1453 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1454 |
+
};
|
| 1455 |
+
});
|
| 1456 |
+
export const $ZodDefault = /*@__PURE__*/ core.$constructor("$ZodDefault", (inst, def) => {
|
| 1457 |
+
$ZodType.init(inst, def);
|
| 1458 |
+
// inst._zod.qin = "true";
|
| 1459 |
+
inst._zod.optin = "optional";
|
| 1460 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1461 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1462 |
+
if (payload.value === undefined) {
|
| 1463 |
+
payload.value = def.defaultValue;
|
| 1464 |
+
/**
|
| 1465 |
+
* $ZodDefault always returns the default value immediately.
|
| 1466 |
+
* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
|
| 1467 |
+
return payload;
|
| 1468 |
+
}
|
| 1469 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1470 |
+
if (result instanceof Promise) {
|
| 1471 |
+
return result.then((result) => handleDefaultResult(result, def));
|
| 1472 |
+
}
|
| 1473 |
+
return handleDefaultResult(result, def);
|
| 1474 |
+
};
|
| 1475 |
+
});
|
| 1476 |
+
function handleDefaultResult(payload, def) {
|
| 1477 |
+
if (payload.value === undefined) {
|
| 1478 |
+
payload.value = def.defaultValue;
|
| 1479 |
+
}
|
| 1480 |
+
return payload;
|
| 1481 |
+
}
|
| 1482 |
+
export const $ZodPrefault = /*@__PURE__*/ core.$constructor("$ZodPrefault", (inst, def) => {
|
| 1483 |
+
$ZodType.init(inst, def);
|
| 1484 |
+
inst._zod.optin = "optional";
|
| 1485 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1486 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1487 |
+
if (payload.value === undefined) {
|
| 1488 |
+
payload.value = def.defaultValue;
|
| 1489 |
+
}
|
| 1490 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1491 |
+
};
|
| 1492 |
+
});
|
| 1493 |
+
export const $ZodNonOptional = /*@__PURE__*/ core.$constructor("$ZodNonOptional", (inst, def) => {
|
| 1494 |
+
$ZodType.init(inst, def);
|
| 1495 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1496 |
+
const v = def.innerType._zod.values;
|
| 1497 |
+
return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
|
| 1498 |
+
});
|
| 1499 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1500 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1501 |
+
if (result instanceof Promise) {
|
| 1502 |
+
return result.then((result) => handleNonOptionalResult(result, inst));
|
| 1503 |
+
}
|
| 1504 |
+
return handleNonOptionalResult(result, inst);
|
| 1505 |
+
};
|
| 1506 |
+
});
|
| 1507 |
+
function handleNonOptionalResult(payload, inst) {
|
| 1508 |
+
if (!payload.issues.length && payload.value === undefined) {
|
| 1509 |
+
payload.issues.push({
|
| 1510 |
+
code: "invalid_type",
|
| 1511 |
+
expected: "nonoptional",
|
| 1512 |
+
input: payload.value,
|
| 1513 |
+
inst,
|
| 1514 |
+
});
|
| 1515 |
+
}
|
| 1516 |
+
return payload;
|
| 1517 |
+
}
|
| 1518 |
+
export const $ZodSuccess = /*@__PURE__*/ core.$constructor("$ZodSuccess", (inst, def) => {
|
| 1519 |
+
$ZodType.init(inst, def);
|
| 1520 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1521 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1522 |
+
if (result instanceof Promise) {
|
| 1523 |
+
return result.then((result) => {
|
| 1524 |
+
payload.value = result.issues.length === 0;
|
| 1525 |
+
return payload;
|
| 1526 |
+
});
|
| 1527 |
+
}
|
| 1528 |
+
payload.value = result.issues.length === 0;
|
| 1529 |
+
return payload;
|
| 1530 |
+
};
|
| 1531 |
+
});
|
| 1532 |
+
export const $ZodCatch = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
|
| 1533 |
+
$ZodType.init(inst, def);
|
| 1534 |
+
inst._zod.optin = "optional";
|
| 1535 |
+
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
| 1536 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1537 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1538 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1539 |
+
if (result instanceof Promise) {
|
| 1540 |
+
return result.then((result) => {
|
| 1541 |
+
payload.value = result.value;
|
| 1542 |
+
if (result.issues.length) {
|
| 1543 |
+
payload.value = def.catchValue({
|
| 1544 |
+
...payload,
|
| 1545 |
+
error: {
|
| 1546 |
+
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1547 |
+
},
|
| 1548 |
+
input: payload.value,
|
| 1549 |
+
});
|
| 1550 |
+
payload.issues = [];
|
| 1551 |
+
}
|
| 1552 |
+
return payload;
|
| 1553 |
+
});
|
| 1554 |
+
}
|
| 1555 |
+
payload.value = result.value;
|
| 1556 |
+
if (result.issues.length) {
|
| 1557 |
+
payload.value = def.catchValue({
|
| 1558 |
+
...payload,
|
| 1559 |
+
error: {
|
| 1560 |
+
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1561 |
+
},
|
| 1562 |
+
input: payload.value,
|
| 1563 |
+
});
|
| 1564 |
+
payload.issues = [];
|
| 1565 |
+
}
|
| 1566 |
+
return payload;
|
| 1567 |
+
};
|
| 1568 |
+
});
|
| 1569 |
+
export const $ZodNaN = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) => {
|
| 1570 |
+
$ZodType.init(inst, def);
|
| 1571 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1572 |
+
if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
|
| 1573 |
+
payload.issues.push({
|
| 1574 |
+
input: payload.value,
|
| 1575 |
+
inst,
|
| 1576 |
+
expected: "nan",
|
| 1577 |
+
code: "invalid_type",
|
| 1578 |
+
});
|
| 1579 |
+
return payload;
|
| 1580 |
+
}
|
| 1581 |
+
return payload;
|
| 1582 |
+
};
|
| 1583 |
+
});
|
| 1584 |
+
export const $ZodPipe = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
|
| 1585 |
+
$ZodType.init(inst, def);
|
| 1586 |
+
util.defineLazy(inst._zod, "values", () => def.in._zod.values);
|
| 1587 |
+
util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
| 1588 |
+
util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
| 1589 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1590 |
+
const left = def.in._zod.run(payload, ctx);
|
| 1591 |
+
if (left instanceof Promise) {
|
| 1592 |
+
return left.then((left) => handlePipeResult(left, def, ctx));
|
| 1593 |
+
}
|
| 1594 |
+
return handlePipeResult(left, def, ctx);
|
| 1595 |
+
};
|
| 1596 |
+
});
|
| 1597 |
+
function handlePipeResult(left, def, ctx) {
|
| 1598 |
+
if (util.aborted(left)) {
|
| 1599 |
+
return left;
|
| 1600 |
+
}
|
| 1601 |
+
return def.out._zod.run({ value: left.value, issues: left.issues }, ctx);
|
| 1602 |
+
}
|
| 1603 |
+
export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (inst, def) => {
|
| 1604 |
+
$ZodType.init(inst, def);
|
| 1605 |
+
util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
| 1606 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1607 |
+
util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
| 1608 |
+
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
| 1609 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1610 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1611 |
+
if (result instanceof Promise) {
|
| 1612 |
+
return result.then(handleReadonlyResult);
|
| 1613 |
+
}
|
| 1614 |
+
return handleReadonlyResult(result);
|
| 1615 |
+
};
|
| 1616 |
+
});
|
| 1617 |
+
function handleReadonlyResult(payload) {
|
| 1618 |
+
payload.value = Object.freeze(payload.value);
|
| 1619 |
+
return payload;
|
| 1620 |
+
}
|
| 1621 |
+
export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplateLiteral", (inst, def) => {
|
| 1622 |
+
$ZodType.init(inst, def);
|
| 1623 |
+
const regexParts = [];
|
| 1624 |
+
for (const part of def.parts) {
|
| 1625 |
+
if (part instanceof $ZodType) {
|
| 1626 |
+
if (!part._zod.pattern) {
|
| 1627 |
+
// if (!source)
|
| 1628 |
+
throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
|
| 1629 |
+
}
|
| 1630 |
+
const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
|
| 1631 |
+
if (!source)
|
| 1632 |
+
throw new Error(`Invalid template literal part: ${part._zod.traits}`);
|
| 1633 |
+
const start = source.startsWith("^") ? 1 : 0;
|
| 1634 |
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
| 1635 |
+
regexParts.push(source.slice(start, end));
|
| 1636 |
+
}
|
| 1637 |
+
else if (part === null || util.primitiveTypes.has(typeof part)) {
|
| 1638 |
+
regexParts.push(util.escapeRegex(`${part}`));
|
| 1639 |
+
}
|
| 1640 |
+
else {
|
| 1641 |
+
throw new Error(`Invalid template literal part: ${part}`);
|
| 1642 |
+
}
|
| 1643 |
+
}
|
| 1644 |
+
inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
|
| 1645 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1646 |
+
if (typeof payload.value !== "string") {
|
| 1647 |
+
payload.issues.push({
|
| 1648 |
+
input: payload.value,
|
| 1649 |
+
inst,
|
| 1650 |
+
expected: "template_literal",
|
| 1651 |
+
code: "invalid_type",
|
| 1652 |
+
});
|
| 1653 |
+
return payload;
|
| 1654 |
+
}
|
| 1655 |
+
inst._zod.pattern.lastIndex = 0;
|
| 1656 |
+
if (!inst._zod.pattern.test(payload.value)) {
|
| 1657 |
+
payload.issues.push({
|
| 1658 |
+
input: payload.value,
|
| 1659 |
+
inst,
|
| 1660 |
+
code: "invalid_format",
|
| 1661 |
+
format: "template_literal",
|
| 1662 |
+
pattern: inst._zod.pattern.source,
|
| 1663 |
+
});
|
| 1664 |
+
return payload;
|
| 1665 |
+
}
|
| 1666 |
+
return payload;
|
| 1667 |
+
};
|
| 1668 |
+
});
|
| 1669 |
+
export const $ZodPromise = /*@__PURE__*/ core.$constructor("$ZodPromise", (inst, def) => {
|
| 1670 |
+
$ZodType.init(inst, def);
|
| 1671 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1672 |
+
return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
|
| 1673 |
+
};
|
| 1674 |
+
});
|
| 1675 |
+
export const $ZodLazy = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
|
| 1676 |
+
$ZodType.init(inst, def);
|
| 1677 |
+
util.defineLazy(inst._zod, "innerType", () => def.getter());
|
| 1678 |
+
util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType._zod.pattern);
|
| 1679 |
+
util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType._zod.propValues);
|
| 1680 |
+
util.defineLazy(inst._zod, "optin", () => inst._zod.innerType._zod.optin);
|
| 1681 |
+
util.defineLazy(inst._zod, "optout", () => inst._zod.innerType._zod.optout);
|
| 1682 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1683 |
+
const inner = inst._zod.innerType;
|
| 1684 |
+
return inner._zod.run(payload, ctx);
|
| 1685 |
+
};
|
| 1686 |
+
});
|
| 1687 |
+
export const $ZodCustom = /*@__PURE__*/ core.$constructor("$ZodCustom", (inst, def) => {
|
| 1688 |
+
checks.$ZodCheck.init(inst, def);
|
| 1689 |
+
$ZodType.init(inst, def);
|
| 1690 |
+
inst._zod.parse = (payload, _) => {
|
| 1691 |
+
return payload;
|
| 1692 |
+
};
|
| 1693 |
+
inst._zod.check = (payload) => {
|
| 1694 |
+
const input = payload.value;
|
| 1695 |
+
const r = def.fn(input);
|
| 1696 |
+
if (r instanceof Promise) {
|
| 1697 |
+
return r.then((r) => handleRefineResult(r, payload, input, inst));
|
| 1698 |
+
}
|
| 1699 |
+
handleRefineResult(r, payload, input, inst);
|
| 1700 |
+
return;
|
| 1701 |
+
};
|
| 1702 |
+
});
|
| 1703 |
+
function handleRefineResult(result, payload, input, inst) {
|
| 1704 |
+
if (!result) {
|
| 1705 |
+
const _iss = {
|
| 1706 |
+
code: "custom",
|
| 1707 |
+
input,
|
| 1708 |
+
inst, // incorporates params.error into issue reporting
|
| 1709 |
+
path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
|
| 1710 |
+
continue: !inst._zod.def.abort,
|
| 1711 |
+
// params: inst._zod.def.params,
|
| 1712 |
+
};
|
| 1713 |
+
if (inst._zod.def.params)
|
| 1714 |
+
_iss.params = inst._zod.def.params;
|
| 1715 |
+
payload.issues.push(util.issue(_iss));
|
| 1716 |
+
}
|
| 1717 |
+
}
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/standard-schema.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/standard-schema.d.cts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** The Standard Schema interface. */
|
| 2 |
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
| 3 |
+
/** The Standard Schema properties. */
|
| 4 |
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
| 5 |
+
}
|
| 6 |
+
export declare namespace StandardSchemaV1 {
|
| 7 |
+
/** The Standard Schema properties interface. */
|
| 8 |
+
interface Props<Input = unknown, Output = Input> {
|
| 9 |
+
/** The version number of the standard. */
|
| 10 |
+
readonly version: 1;
|
| 11 |
+
/** The vendor name of the schema library. */
|
| 12 |
+
readonly vendor: string;
|
| 13 |
+
/** Validates unknown input values. */
|
| 14 |
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
| 15 |
+
/** Inferred types associated with the schema. */
|
| 16 |
+
readonly types?: Types<Input, Output> | undefined;
|
| 17 |
+
}
|
| 18 |
+
/** The result interface of the validate function. */
|
| 19 |
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
| 20 |
+
/** The result interface if validation succeeds. */
|
| 21 |
+
interface SuccessResult<Output> {
|
| 22 |
+
/** The typed output value. */
|
| 23 |
+
readonly value: Output;
|
| 24 |
+
/** The non-existent issues. */
|
| 25 |
+
readonly issues?: undefined;
|
| 26 |
+
}
|
| 27 |
+
/** The result interface if validation fails. */
|
| 28 |
+
interface FailureResult {
|
| 29 |
+
/** The issues of failed validation. */
|
| 30 |
+
readonly issues: ReadonlyArray<Issue>;
|
| 31 |
+
}
|
| 32 |
+
/** The issue interface of the failure output. */
|
| 33 |
+
interface Issue {
|
| 34 |
+
/** The error message of the issue. */
|
| 35 |
+
readonly message: string;
|
| 36 |
+
/** The path of the issue, if any. */
|
| 37 |
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
| 38 |
+
}
|
| 39 |
+
/** The path segment interface of the issue. */
|
| 40 |
+
interface PathSegment {
|
| 41 |
+
/** The key representing a path segment. */
|
| 42 |
+
readonly key: PropertyKey;
|
| 43 |
+
}
|
| 44 |
+
/** The Standard Schema types interface. */
|
| 45 |
+
interface Types<Input = unknown, Output = Input> {
|
| 46 |
+
/** The input type of the schema. */
|
| 47 |
+
readonly input: Input;
|
| 48 |
+
/** The output type of the schema. */
|
| 49 |
+
readonly output: Output;
|
| 50 |
+
}
|
| 51 |
+
/** Infers the input type of a Standard Schema. */
|
| 52 |
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
| 53 |
+
/** Infers the output type of a Standard Schema. */
|
| 54 |
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
| 55 |
+
}
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/standard-schema.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** The Standard Schema interface. */
|
| 2 |
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
| 3 |
+
/** The Standard Schema properties. */
|
| 4 |
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
| 5 |
+
}
|
| 6 |
+
export declare namespace StandardSchemaV1 {
|
| 7 |
+
/** The Standard Schema properties interface. */
|
| 8 |
+
interface Props<Input = unknown, Output = Input> {
|
| 9 |
+
/** The version number of the standard. */
|
| 10 |
+
readonly version: 1;
|
| 11 |
+
/** The vendor name of the schema library. */
|
| 12 |
+
readonly vendor: string;
|
| 13 |
+
/** Validates unknown input values. */
|
| 14 |
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
| 15 |
+
/** Inferred types associated with the schema. */
|
| 16 |
+
readonly types?: Types<Input, Output> | undefined;
|
| 17 |
+
}
|
| 18 |
+
/** The result interface of the validate function. */
|
| 19 |
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
| 20 |
+
/** The result interface if validation succeeds. */
|
| 21 |
+
interface SuccessResult<Output> {
|
| 22 |
+
/** The typed output value. */
|
| 23 |
+
readonly value: Output;
|
| 24 |
+
/** The non-existent issues. */
|
| 25 |
+
readonly issues?: undefined;
|
| 26 |
+
}
|
| 27 |
+
/** The result interface if validation fails. */
|
| 28 |
+
interface FailureResult {
|
| 29 |
+
/** The issues of failed validation. */
|
| 30 |
+
readonly issues: ReadonlyArray<Issue>;
|
| 31 |
+
}
|
| 32 |
+
/** The issue interface of the failure output. */
|
| 33 |
+
interface Issue {
|
| 34 |
+
/** The error message of the issue. */
|
| 35 |
+
readonly message: string;
|
| 36 |
+
/** The path of the issue, if any. */
|
| 37 |
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
| 38 |
+
}
|
| 39 |
+
/** The path segment interface of the issue. */
|
| 40 |
+
interface PathSegment {
|
| 41 |
+
/** The key representing a path segment. */
|
| 42 |
+
readonly key: PropertyKey;
|
| 43 |
+
}
|
| 44 |
+
/** The Standard Schema types interface. */
|
| 45 |
+
interface Types<Input = unknown, Output = Input> {
|
| 46 |
+
/** The input type of the schema. */
|
| 47 |
+
readonly input: Input;
|
| 48 |
+
/** The output type of the schema. */
|
| 49 |
+
readonly output: Output;
|
| 50 |
+
}
|
| 51 |
+
/** Infers the input type of a Standard Schema. */
|
| 52 |
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
| 53 |
+
/** Infers the output type of a Standard Schema. */
|
| 54 |
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
| 55 |
+
}
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/standard-schema.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export {};
|
node_modules/@jimp/plugin-contain/node_modules/zod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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.JSONSchemaGenerator = void 0;
|
| 4 |
+
exports.toJSONSchema = toJSONSchema;
|
| 5 |
+
const registries_js_1 = require("./registries.cjs");
|
| 6 |
+
const util_js_1 = require("./util.cjs");
|
| 7 |
+
class JSONSchemaGenerator {
|
| 8 |
+
constructor(params) {
|
| 9 |
+
this.counter = 0;
|
| 10 |
+
this.metadataRegistry = params?.metadata ?? registries_js_1.globalRegistry;
|
| 11 |
+
this.target = params?.target ?? "draft-2020-12";
|
| 12 |
+
this.unrepresentable = params?.unrepresentable ?? "throw";
|
| 13 |
+
this.override = params?.override ?? (() => { });
|
| 14 |
+
this.io = params?.io ?? "output";
|
| 15 |
+
this.seen = new Map();
|
| 16 |
+
}
|
| 17 |
+
process(schema, _params = { path: [], schemaPath: [] }) {
|
| 18 |
+
var _a;
|
| 19 |
+
const def = schema._zod.def;
|
| 20 |
+
const formatMap = {
|
| 21 |
+
guid: "uuid",
|
| 22 |
+
url: "uri",
|
| 23 |
+
datetime: "date-time",
|
| 24 |
+
json_string: "json-string",
|
| 25 |
+
regex: "", // do not set
|
| 26 |
+
};
|
| 27 |
+
// check for schema in seens
|
| 28 |
+
const seen = this.seen.get(schema);
|
| 29 |
+
if (seen) {
|
| 30 |
+
seen.count++;
|
| 31 |
+
// check if cycle
|
| 32 |
+
const isCycle = _params.schemaPath.includes(schema);
|
| 33 |
+
if (isCycle) {
|
| 34 |
+
seen.cycle = _params.path;
|
| 35 |
+
}
|
| 36 |
+
return seen.schema;
|
| 37 |
+
}
|
| 38 |
+
// initialize
|
| 39 |
+
const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
|
| 40 |
+
this.seen.set(schema, result);
|
| 41 |
+
// custom method overrides default behavior
|
| 42 |
+
const overrideSchema = schema._zod.toJSONSchema?.();
|
| 43 |
+
if (overrideSchema) {
|
| 44 |
+
result.schema = overrideSchema;
|
| 45 |
+
}
|
| 46 |
+
else {
|
| 47 |
+
const params = {
|
| 48 |
+
..._params,
|
| 49 |
+
schemaPath: [..._params.schemaPath, schema],
|
| 50 |
+
path: _params.path,
|
| 51 |
+
};
|
| 52 |
+
const parent = schema._zod.parent;
|
| 53 |
+
if (parent) {
|
| 54 |
+
// schema was cloned from another schema
|
| 55 |
+
result.ref = parent;
|
| 56 |
+
this.process(parent, params);
|
| 57 |
+
this.seen.get(parent).isParent = true;
|
| 58 |
+
}
|
| 59 |
+
else {
|
| 60 |
+
const _json = result.schema;
|
| 61 |
+
switch (def.type) {
|
| 62 |
+
case "string": {
|
| 63 |
+
const json = _json;
|
| 64 |
+
json.type = "string";
|
| 65 |
+
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod
|
| 66 |
+
.bag;
|
| 67 |
+
if (typeof minimum === "number")
|
| 68 |
+
json.minLength = minimum;
|
| 69 |
+
if (typeof maximum === "number")
|
| 70 |
+
json.maxLength = maximum;
|
| 71 |
+
// custom pattern overrides format
|
| 72 |
+
if (format) {
|
| 73 |
+
json.format = formatMap[format] ?? format;
|
| 74 |
+
if (json.format === "")
|
| 75 |
+
delete json.format; // empty format is not valid
|
| 76 |
+
}
|
| 77 |
+
if (contentEncoding)
|
| 78 |
+
json.contentEncoding = contentEncoding;
|
| 79 |
+
if (patterns && patterns.size > 0) {
|
| 80 |
+
const regexes = [...patterns];
|
| 81 |
+
if (regexes.length === 1)
|
| 82 |
+
json.pattern = regexes[0].source;
|
| 83 |
+
else if (regexes.length > 1) {
|
| 84 |
+
result.schema.allOf = [
|
| 85 |
+
...regexes.map((regex) => ({
|
| 86 |
+
...(this.target === "draft-7" ? { type: "string" } : {}),
|
| 87 |
+
pattern: regex.source,
|
| 88 |
+
})),
|
| 89 |
+
];
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
break;
|
| 93 |
+
}
|
| 94 |
+
case "number": {
|
| 95 |
+
const json = _json;
|
| 96 |
+
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
| 97 |
+
if (typeof format === "string" && format.includes("int"))
|
| 98 |
+
json.type = "integer";
|
| 99 |
+
else
|
| 100 |
+
json.type = "number";
|
| 101 |
+
if (typeof exclusiveMinimum === "number")
|
| 102 |
+
json.exclusiveMinimum = exclusiveMinimum;
|
| 103 |
+
if (typeof minimum === "number") {
|
| 104 |
+
json.minimum = minimum;
|
| 105 |
+
if (typeof exclusiveMinimum === "number") {
|
| 106 |
+
if (exclusiveMinimum >= minimum)
|
| 107 |
+
delete json.minimum;
|
| 108 |
+
else
|
| 109 |
+
delete json.exclusiveMinimum;
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
if (typeof exclusiveMaximum === "number")
|
| 113 |
+
json.exclusiveMaximum = exclusiveMaximum;
|
| 114 |
+
if (typeof maximum === "number") {
|
| 115 |
+
json.maximum = maximum;
|
| 116 |
+
if (typeof exclusiveMaximum === "number") {
|
| 117 |
+
if (exclusiveMaximum <= maximum)
|
| 118 |
+
delete json.maximum;
|
| 119 |
+
else
|
| 120 |
+
delete json.exclusiveMaximum;
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
if (typeof multipleOf === "number")
|
| 124 |
+
json.multipleOf = multipleOf;
|
| 125 |
+
break;
|
| 126 |
+
}
|
| 127 |
+
case "boolean": {
|
| 128 |
+
const json = _json;
|
| 129 |
+
json.type = "boolean";
|
| 130 |
+
break;
|
| 131 |
+
}
|
| 132 |
+
case "bigint": {
|
| 133 |
+
if (this.unrepresentable === "throw") {
|
| 134 |
+
throw new Error("BigInt cannot be represented in JSON Schema");
|
| 135 |
+
}
|
| 136 |
+
break;
|
| 137 |
+
}
|
| 138 |
+
case "symbol": {
|
| 139 |
+
if (this.unrepresentable === "throw") {
|
| 140 |
+
throw new Error("Symbols cannot be represented in JSON Schema");
|
| 141 |
+
}
|
| 142 |
+
break;
|
| 143 |
+
}
|
| 144 |
+
case "null": {
|
| 145 |
+
_json.type = "null";
|
| 146 |
+
break;
|
| 147 |
+
}
|
| 148 |
+
case "any": {
|
| 149 |
+
break;
|
| 150 |
+
}
|
| 151 |
+
case "unknown": {
|
| 152 |
+
break;
|
| 153 |
+
}
|
| 154 |
+
case "undefined": {
|
| 155 |
+
if (this.unrepresentable === "throw") {
|
| 156 |
+
throw new Error("Undefined cannot be represented in JSON Schema");
|
| 157 |
+
}
|
| 158 |
+
break;
|
| 159 |
+
}
|
| 160 |
+
case "void": {
|
| 161 |
+
if (this.unrepresentable === "throw") {
|
| 162 |
+
throw new Error("Void cannot be represented in JSON Schema");
|
| 163 |
+
}
|
| 164 |
+
break;
|
| 165 |
+
}
|
| 166 |
+
case "never": {
|
| 167 |
+
_json.not = {};
|
| 168 |
+
break;
|
| 169 |
+
}
|
| 170 |
+
case "date": {
|
| 171 |
+
if (this.unrepresentable === "throw") {
|
| 172 |
+
throw new Error("Date cannot be represented in JSON Schema");
|
| 173 |
+
}
|
| 174 |
+
break;
|
| 175 |
+
}
|
| 176 |
+
case "array": {
|
| 177 |
+
const json = _json;
|
| 178 |
+
const { minimum, maximum } = schema._zod.bag;
|
| 179 |
+
if (typeof minimum === "number")
|
| 180 |
+
json.minItems = minimum;
|
| 181 |
+
if (typeof maximum === "number")
|
| 182 |
+
json.maxItems = maximum;
|
| 183 |
+
json.type = "array";
|
| 184 |
+
json.items = this.process(def.element, { ...params, path: [...params.path, "items"] });
|
| 185 |
+
break;
|
| 186 |
+
}
|
| 187 |
+
case "object": {
|
| 188 |
+
const json = _json;
|
| 189 |
+
json.type = "object";
|
| 190 |
+
json.properties = {};
|
| 191 |
+
const shape = def.shape; // params.shapeCache.get(schema)!;
|
| 192 |
+
for (const key in shape) {
|
| 193 |
+
json.properties[key] = this.process(shape[key], {
|
| 194 |
+
...params,
|
| 195 |
+
path: [...params.path, "properties", key],
|
| 196 |
+
});
|
| 197 |
+
}
|
| 198 |
+
// required keys
|
| 199 |
+
const allKeys = new Set(Object.keys(shape));
|
| 200 |
+
// const optionalKeys = new Set(def.optional);
|
| 201 |
+
const requiredKeys = new Set([...allKeys].filter((key) => {
|
| 202 |
+
const v = def.shape[key]._zod;
|
| 203 |
+
if (this.io === "input") {
|
| 204 |
+
return v.optin === undefined;
|
| 205 |
+
}
|
| 206 |
+
else {
|
| 207 |
+
return v.optout === undefined;
|
| 208 |
+
}
|
| 209 |
+
}));
|
| 210 |
+
if (requiredKeys.size > 0) {
|
| 211 |
+
json.required = Array.from(requiredKeys);
|
| 212 |
+
}
|
| 213 |
+
// catchall
|
| 214 |
+
if (def.catchall?._zod.def.type === "never") {
|
| 215 |
+
// strict
|
| 216 |
+
json.additionalProperties = false;
|
| 217 |
+
}
|
| 218 |
+
else if (!def.catchall) {
|
| 219 |
+
// regular
|
| 220 |
+
if (this.io === "output")
|
| 221 |
+
json.additionalProperties = false;
|
| 222 |
+
}
|
| 223 |
+
else if (def.catchall) {
|
| 224 |
+
json.additionalProperties = this.process(def.catchall, {
|
| 225 |
+
...params,
|
| 226 |
+
path: [...params.path, "additionalProperties"],
|
| 227 |
+
});
|
| 228 |
+
}
|
| 229 |
+
break;
|
| 230 |
+
}
|
| 231 |
+
case "union": {
|
| 232 |
+
const json = _json;
|
| 233 |
+
json.anyOf = def.options.map((x, i) => this.process(x, {
|
| 234 |
+
...params,
|
| 235 |
+
path: [...params.path, "anyOf", i],
|
| 236 |
+
}));
|
| 237 |
+
break;
|
| 238 |
+
}
|
| 239 |
+
case "intersection": {
|
| 240 |
+
const json = _json;
|
| 241 |
+
const a = this.process(def.left, {
|
| 242 |
+
...params,
|
| 243 |
+
path: [...params.path, "allOf", 0],
|
| 244 |
+
});
|
| 245 |
+
const b = this.process(def.right, {
|
| 246 |
+
...params,
|
| 247 |
+
path: [...params.path, "allOf", 1],
|
| 248 |
+
});
|
| 249 |
+
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
| 250 |
+
const allOf = [
|
| 251 |
+
...(isSimpleIntersection(a) ? a.allOf : [a]),
|
| 252 |
+
...(isSimpleIntersection(b) ? b.allOf : [b]),
|
| 253 |
+
];
|
| 254 |
+
json.allOf = allOf;
|
| 255 |
+
break;
|
| 256 |
+
}
|
| 257 |
+
case "tuple": {
|
| 258 |
+
const json = _json;
|
| 259 |
+
json.type = "array";
|
| 260 |
+
const prefixItems = def.items.map((x, i) => this.process(x, { ...params, path: [...params.path, "prefixItems", i] }));
|
| 261 |
+
if (this.target === "draft-2020-12") {
|
| 262 |
+
json.prefixItems = prefixItems;
|
| 263 |
+
}
|
| 264 |
+
else {
|
| 265 |
+
json.items = prefixItems;
|
| 266 |
+
}
|
| 267 |
+
if (def.rest) {
|
| 268 |
+
const rest = this.process(def.rest, {
|
| 269 |
+
...params,
|
| 270 |
+
path: [...params.path, "items"],
|
| 271 |
+
});
|
| 272 |
+
if (this.target === "draft-2020-12") {
|
| 273 |
+
json.items = rest;
|
| 274 |
+
}
|
| 275 |
+
else {
|
| 276 |
+
json.additionalItems = rest;
|
| 277 |
+
}
|
| 278 |
+
}
|
| 279 |
+
// additionalItems
|
| 280 |
+
if (def.rest) {
|
| 281 |
+
json.items = this.process(def.rest, {
|
| 282 |
+
...params,
|
| 283 |
+
path: [...params.path, "items"],
|
| 284 |
+
});
|
| 285 |
+
}
|
| 286 |
+
// length
|
| 287 |
+
const { minimum, maximum } = schema._zod.bag;
|
| 288 |
+
if (typeof minimum === "number")
|
| 289 |
+
json.minItems = minimum;
|
| 290 |
+
if (typeof maximum === "number")
|
| 291 |
+
json.maxItems = maximum;
|
| 292 |
+
break;
|
| 293 |
+
}
|
| 294 |
+
case "record": {
|
| 295 |
+
const json = _json;
|
| 296 |
+
json.type = "object";
|
| 297 |
+
json.propertyNames = this.process(def.keyType, { ...params, path: [...params.path, "propertyNames"] });
|
| 298 |
+
json.additionalProperties = this.process(def.valueType, {
|
| 299 |
+
...params,
|
| 300 |
+
path: [...params.path, "additionalProperties"],
|
| 301 |
+
});
|
| 302 |
+
break;
|
| 303 |
+
}
|
| 304 |
+
case "map": {
|
| 305 |
+
if (this.unrepresentable === "throw") {
|
| 306 |
+
throw new Error("Map cannot be represented in JSON Schema");
|
| 307 |
+
}
|
| 308 |
+
break;
|
| 309 |
+
}
|
| 310 |
+
case "set": {
|
| 311 |
+
if (this.unrepresentable === "throw") {
|
| 312 |
+
throw new Error("Set cannot be represented in JSON Schema");
|
| 313 |
+
}
|
| 314 |
+
break;
|
| 315 |
+
}
|
| 316 |
+
case "enum": {
|
| 317 |
+
const json = _json;
|
| 318 |
+
const values = (0, util_js_1.getEnumValues)(def.entries);
|
| 319 |
+
// Number enums can have both string and number values
|
| 320 |
+
if (values.every((v) => typeof v === "number"))
|
| 321 |
+
json.type = "number";
|
| 322 |
+
if (values.every((v) => typeof v === "string"))
|
| 323 |
+
json.type = "string";
|
| 324 |
+
json.enum = values;
|
| 325 |
+
break;
|
| 326 |
+
}
|
| 327 |
+
case "literal": {
|
| 328 |
+
const json = _json;
|
| 329 |
+
const vals = [];
|
| 330 |
+
for (const val of def.values) {
|
| 331 |
+
if (val === undefined) {
|
| 332 |
+
if (this.unrepresentable === "throw") {
|
| 333 |
+
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
| 334 |
+
}
|
| 335 |
+
else {
|
| 336 |
+
// do not add to vals
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
else if (typeof val === "bigint") {
|
| 340 |
+
if (this.unrepresentable === "throw") {
|
| 341 |
+
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
| 342 |
+
}
|
| 343 |
+
else {
|
| 344 |
+
vals.push(Number(val));
|
| 345 |
+
}
|
| 346 |
+
}
|
| 347 |
+
else {
|
| 348 |
+
vals.push(val);
|
| 349 |
+
}
|
| 350 |
+
}
|
| 351 |
+
if (vals.length === 0) {
|
| 352 |
+
// do nothing (an undefined literal was stripped)
|
| 353 |
+
}
|
| 354 |
+
else if (vals.length === 1) {
|
| 355 |
+
const val = vals[0];
|
| 356 |
+
json.type = val === null ? "null" : typeof val;
|
| 357 |
+
json.const = val;
|
| 358 |
+
}
|
| 359 |
+
else {
|
| 360 |
+
if (vals.every((v) => typeof v === "number"))
|
| 361 |
+
json.type = "number";
|
| 362 |
+
if (vals.every((v) => typeof v === "string"))
|
| 363 |
+
json.type = "string";
|
| 364 |
+
if (vals.every((v) => typeof v === "boolean"))
|
| 365 |
+
json.type = "string";
|
| 366 |
+
if (vals.every((v) => v === null))
|
| 367 |
+
json.type = "null";
|
| 368 |
+
json.enum = vals;
|
| 369 |
+
}
|
| 370 |
+
break;
|
| 371 |
+
}
|
| 372 |
+
case "file": {
|
| 373 |
+
const json = _json;
|
| 374 |
+
const file = {
|
| 375 |
+
type: "string",
|
| 376 |
+
format: "binary",
|
| 377 |
+
contentEncoding: "binary",
|
| 378 |
+
};
|
| 379 |
+
const { minimum, maximum, mime } = schema._zod.bag;
|
| 380 |
+
if (minimum !== undefined)
|
| 381 |
+
file.minLength = minimum;
|
| 382 |
+
if (maximum !== undefined)
|
| 383 |
+
file.maxLength = maximum;
|
| 384 |
+
if (mime) {
|
| 385 |
+
if (mime.length === 1) {
|
| 386 |
+
file.contentMediaType = mime[0];
|
| 387 |
+
Object.assign(json, file);
|
| 388 |
+
}
|
| 389 |
+
else {
|
| 390 |
+
json.anyOf = mime.map((m) => {
|
| 391 |
+
const mFile = { ...file, contentMediaType: m };
|
| 392 |
+
return mFile;
|
| 393 |
+
});
|
| 394 |
+
}
|
| 395 |
+
}
|
| 396 |
+
else {
|
| 397 |
+
Object.assign(json, file);
|
| 398 |
+
}
|
| 399 |
+
// if (this.unrepresentable === "throw") {
|
| 400 |
+
// throw new Error("File cannot be represented in JSON Schema");
|
| 401 |
+
// }
|
| 402 |
+
break;
|
| 403 |
+
}
|
| 404 |
+
case "transform": {
|
| 405 |
+
if (this.unrepresentable === "throw") {
|
| 406 |
+
throw new Error("Transforms cannot be represented in JSON Schema");
|
| 407 |
+
}
|
| 408 |
+
break;
|
| 409 |
+
}
|
| 410 |
+
case "nullable": {
|
| 411 |
+
const inner = this.process(def.innerType, params);
|
| 412 |
+
_json.anyOf = [inner, { type: "null" }];
|
| 413 |
+
break;
|
| 414 |
+
}
|
| 415 |
+
case "nonoptional": {
|
| 416 |
+
this.process(def.innerType, params);
|
| 417 |
+
result.ref = def.innerType;
|
| 418 |
+
break;
|
| 419 |
+
}
|
| 420 |
+
case "success": {
|
| 421 |
+
const json = _json;
|
| 422 |
+
json.type = "boolean";
|
| 423 |
+
break;
|
| 424 |
+
}
|
| 425 |
+
case "default": {
|
| 426 |
+
this.process(def.innerType, params);
|
| 427 |
+
result.ref = def.innerType;
|
| 428 |
+
_json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
| 429 |
+
break;
|
| 430 |
+
}
|
| 431 |
+
case "prefault": {
|
| 432 |
+
this.process(def.innerType, params);
|
| 433 |
+
result.ref = def.innerType;
|
| 434 |
+
if (this.io === "input")
|
| 435 |
+
_json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
| 436 |
+
break;
|
| 437 |
+
}
|
| 438 |
+
case "catch": {
|
| 439 |
+
// use conditionals
|
| 440 |
+
this.process(def.innerType, params);
|
| 441 |
+
result.ref = def.innerType;
|
| 442 |
+
let catchValue;
|
| 443 |
+
try {
|
| 444 |
+
catchValue = def.catchValue(undefined);
|
| 445 |
+
}
|
| 446 |
+
catch {
|
| 447 |
+
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
| 448 |
+
}
|
| 449 |
+
_json.default = catchValue;
|
| 450 |
+
break;
|
| 451 |
+
}
|
| 452 |
+
case "nan": {
|
| 453 |
+
if (this.unrepresentable === "throw") {
|
| 454 |
+
throw new Error("NaN cannot be represented in JSON Schema");
|
| 455 |
+
}
|
| 456 |
+
break;
|
| 457 |
+
}
|
| 458 |
+
case "template_literal": {
|
| 459 |
+
const json = _json;
|
| 460 |
+
const pattern = schema._zod.pattern;
|
| 461 |
+
if (!pattern)
|
| 462 |
+
throw new Error("Pattern not found in template literal");
|
| 463 |
+
json.type = "string";
|
| 464 |
+
json.pattern = pattern.source;
|
| 465 |
+
break;
|
| 466 |
+
}
|
| 467 |
+
case "pipe": {
|
| 468 |
+
const innerType = this.io === "input" ? (def.in._zod.def.type === "transform" ? def.out : def.in) : def.out;
|
| 469 |
+
this.process(innerType, params);
|
| 470 |
+
result.ref = innerType;
|
| 471 |
+
break;
|
| 472 |
+
}
|
| 473 |
+
case "readonly": {
|
| 474 |
+
this.process(def.innerType, params);
|
| 475 |
+
result.ref = def.innerType;
|
| 476 |
+
_json.readOnly = true;
|
| 477 |
+
break;
|
| 478 |
+
}
|
| 479 |
+
// passthrough types
|
| 480 |
+
case "promise": {
|
| 481 |
+
this.process(def.innerType, params);
|
| 482 |
+
result.ref = def.innerType;
|
| 483 |
+
break;
|
| 484 |
+
}
|
| 485 |
+
case "optional": {
|
| 486 |
+
this.process(def.innerType, params);
|
| 487 |
+
result.ref = def.innerType;
|
| 488 |
+
break;
|
| 489 |
+
}
|
| 490 |
+
case "lazy": {
|
| 491 |
+
const innerType = schema._zod.innerType;
|
| 492 |
+
this.process(innerType, params);
|
| 493 |
+
result.ref = innerType;
|
| 494 |
+
break;
|
| 495 |
+
}
|
| 496 |
+
case "custom": {
|
| 497 |
+
if (this.unrepresentable === "throw") {
|
| 498 |
+
throw new Error("Custom types cannot be represented in JSON Schema");
|
| 499 |
+
}
|
| 500 |
+
break;
|
| 501 |
+
}
|
| 502 |
+
default: {
|
| 503 |
+
def;
|
| 504 |
+
}
|
| 505 |
+
}
|
| 506 |
+
}
|
| 507 |
+
}
|
| 508 |
+
// metadata
|
| 509 |
+
const meta = this.metadataRegistry.get(schema);
|
| 510 |
+
if (meta)
|
| 511 |
+
Object.assign(result.schema, meta);
|
| 512 |
+
if (this.io === "input" && isTransforming(schema)) {
|
| 513 |
+
// examples/defaults only apply to output type of pipe
|
| 514 |
+
delete result.schema.examples;
|
| 515 |
+
delete result.schema.default;
|
| 516 |
+
}
|
| 517 |
+
// set prefault as default
|
| 518 |
+
if (this.io === "input" && result.schema._prefault)
|
| 519 |
+
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
| 520 |
+
delete result.schema._prefault;
|
| 521 |
+
// pulling fresh from this.seen in case it was overwritten
|
| 522 |
+
const _result = this.seen.get(schema);
|
| 523 |
+
return _result.schema;
|
| 524 |
+
}
|
| 525 |
+
emit(schema, _params) {
|
| 526 |
+
const params = {
|
| 527 |
+
cycles: _params?.cycles ?? "ref",
|
| 528 |
+
reused: _params?.reused ?? "inline",
|
| 529 |
+
// unrepresentable: _params?.unrepresentable ?? "throw",
|
| 530 |
+
// uri: _params?.uri ?? ((id) => `${id}`),
|
| 531 |
+
external: _params?.external ?? undefined,
|
| 532 |
+
};
|
| 533 |
+
// iterate over seen map;
|
| 534 |
+
const root = this.seen.get(schema);
|
| 535 |
+
if (!root)
|
| 536 |
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
| 537 |
+
// initialize result with root schema fields
|
| 538 |
+
// Object.assign(result, seen.cached);
|
| 539 |
+
// returns a ref to the schema
|
| 540 |
+
// defId will be empty if the ref points to an external schema (or #)
|
| 541 |
+
const makeURI = (entry) => {
|
| 542 |
+
// comparing the seen objects because sometimes
|
| 543 |
+
// multiple schemas map to the same seen object.
|
| 544 |
+
// e.g. lazy
|
| 545 |
+
// external is configured
|
| 546 |
+
const defsSegment = this.target === "draft-2020-12" ? "$defs" : "definitions";
|
| 547 |
+
if (params.external) {
|
| 548 |
+
const externalId = params.external.registry.get(entry[0])?.id; // ?? "__shared";// `__schema${this.counter++}`;
|
| 549 |
+
// check if schema is in the external registry
|
| 550 |
+
const uriGenerator = params.external.uri ?? ((id) => id);
|
| 551 |
+
if (externalId) {
|
| 552 |
+
return { ref: uriGenerator(externalId) };
|
| 553 |
+
}
|
| 554 |
+
// otherwise, add to __shared
|
| 555 |
+
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${this.counter++}`;
|
| 556 |
+
entry[1].defId = id; // set defId so it will be reused if needed
|
| 557 |
+
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
| 558 |
+
}
|
| 559 |
+
if (entry[1] === root) {
|
| 560 |
+
return { ref: "#" };
|
| 561 |
+
}
|
| 562 |
+
// self-contained schema
|
| 563 |
+
const uriPrefix = `#`;
|
| 564 |
+
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
| 565 |
+
const defId = entry[1].schema.id ?? `__schema${this.counter++}`;
|
| 566 |
+
return { defId, ref: defUriPrefix + defId };
|
| 567 |
+
};
|
| 568 |
+
// stored cached version in `def` property
|
| 569 |
+
// remove all properties, set $ref
|
| 570 |
+
const extractToDef = (entry) => {
|
| 571 |
+
// if the schema is already a reference, do not extract it
|
| 572 |
+
if (entry[1].schema.$ref) {
|
| 573 |
+
return;
|
| 574 |
+
}
|
| 575 |
+
const seen = entry[1];
|
| 576 |
+
const { ref, defId } = makeURI(entry);
|
| 577 |
+
seen.def = { ...seen.schema };
|
| 578 |
+
// defId won't be set if the schema is a reference to an external schema
|
| 579 |
+
if (defId)
|
| 580 |
+
seen.defId = defId;
|
| 581 |
+
// wipe away all properties except $ref
|
| 582 |
+
const schema = seen.schema;
|
| 583 |
+
for (const key in schema) {
|
| 584 |
+
delete schema[key];
|
| 585 |
+
}
|
| 586 |
+
schema.$ref = ref;
|
| 587 |
+
};
|
| 588 |
+
// throw on cycles
|
| 589 |
+
// break cycles
|
| 590 |
+
if (params.cycles === "throw") {
|
| 591 |
+
for (const entry of this.seen.entries()) {
|
| 592 |
+
const seen = entry[1];
|
| 593 |
+
if (seen.cycle) {
|
| 594 |
+
throw new Error("Cycle detected: " +
|
| 595 |
+
`#/${seen.cycle?.join("/")}/<root>` +
|
| 596 |
+
'\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.');
|
| 597 |
+
}
|
| 598 |
+
}
|
| 599 |
+
}
|
| 600 |
+
// extract schemas into $defs
|
| 601 |
+
for (const entry of this.seen.entries()) {
|
| 602 |
+
const seen = entry[1];
|
| 603 |
+
// convert root schema to # $ref
|
| 604 |
+
if (schema === entry[0]) {
|
| 605 |
+
extractToDef(entry); // this has special handling for the root schema
|
| 606 |
+
continue;
|
| 607 |
+
}
|
| 608 |
+
// extract schemas that are in the external registry
|
| 609 |
+
if (params.external) {
|
| 610 |
+
const ext = params.external.registry.get(entry[0])?.id;
|
| 611 |
+
if (schema !== entry[0] && ext) {
|
| 612 |
+
extractToDef(entry);
|
| 613 |
+
continue;
|
| 614 |
+
}
|
| 615 |
+
}
|
| 616 |
+
// extract schemas with `id` meta
|
| 617 |
+
const id = this.metadataRegistry.get(entry[0])?.id;
|
| 618 |
+
if (id) {
|
| 619 |
+
extractToDef(entry);
|
| 620 |
+
continue;
|
| 621 |
+
}
|
| 622 |
+
// break cycles
|
| 623 |
+
if (seen.cycle) {
|
| 624 |
+
// any
|
| 625 |
+
extractToDef(entry);
|
| 626 |
+
continue;
|
| 627 |
+
}
|
| 628 |
+
// extract reused schemas
|
| 629 |
+
if (seen.count > 1) {
|
| 630 |
+
if (params.reused === "ref") {
|
| 631 |
+
extractToDef(entry);
|
| 632 |
+
// biome-ignore lint:
|
| 633 |
+
continue;
|
| 634 |
+
}
|
| 635 |
+
}
|
| 636 |
+
}
|
| 637 |
+
// flatten _refs
|
| 638 |
+
const flattenRef = (zodSchema, params) => {
|
| 639 |
+
const seen = this.seen.get(zodSchema);
|
| 640 |
+
const schema = seen.def ?? seen.schema;
|
| 641 |
+
const _cached = { ...schema };
|
| 642 |
+
// already seen
|
| 643 |
+
if (seen.ref === null) {
|
| 644 |
+
return;
|
| 645 |
+
}
|
| 646 |
+
// flatten ref if defined
|
| 647 |
+
const ref = seen.ref;
|
| 648 |
+
seen.ref = null; // prevent recursion
|
| 649 |
+
if (ref) {
|
| 650 |
+
flattenRef(ref, params);
|
| 651 |
+
// merge referenced schema into current
|
| 652 |
+
const refSchema = this.seen.get(ref).schema;
|
| 653 |
+
if (refSchema.$ref && params.target === "draft-7") {
|
| 654 |
+
schema.allOf = schema.allOf ?? [];
|
| 655 |
+
schema.allOf.push(refSchema);
|
| 656 |
+
}
|
| 657 |
+
else {
|
| 658 |
+
Object.assign(schema, refSchema);
|
| 659 |
+
Object.assign(schema, _cached); // prevent overwriting any fields in the original schema
|
| 660 |
+
}
|
| 661 |
+
}
|
| 662 |
+
// execute overrides
|
| 663 |
+
if (!seen.isParent)
|
| 664 |
+
this.override({
|
| 665 |
+
zodSchema: zodSchema,
|
| 666 |
+
jsonSchema: schema,
|
| 667 |
+
path: seen.path ?? [],
|
| 668 |
+
});
|
| 669 |
+
};
|
| 670 |
+
for (const entry of [...this.seen.entries()].reverse()) {
|
| 671 |
+
flattenRef(entry[0], { target: this.target });
|
| 672 |
+
}
|
| 673 |
+
const result = {};
|
| 674 |
+
if (this.target === "draft-2020-12") {
|
| 675 |
+
result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
| 676 |
+
}
|
| 677 |
+
else if (this.target === "draft-7") {
|
| 678 |
+
result.$schema = "http://json-schema.org/draft-07/schema#";
|
| 679 |
+
}
|
| 680 |
+
else {
|
| 681 |
+
console.warn(`Invalid target: ${this.target}`);
|
| 682 |
+
}
|
| 683 |
+
if (params.external?.uri) {
|
| 684 |
+
const id = params.external.registry.get(schema)?.id;
|
| 685 |
+
if (!id)
|
| 686 |
+
throw new Error("Schema is missing an `id` property");
|
| 687 |
+
result.$id = params.external.uri(id);
|
| 688 |
+
}
|
| 689 |
+
Object.assign(result, root.def);
|
| 690 |
+
// build defs object
|
| 691 |
+
const defs = params.external?.defs ?? {};
|
| 692 |
+
for (const entry of this.seen.entries()) {
|
| 693 |
+
const seen = entry[1];
|
| 694 |
+
if (seen.def && seen.defId) {
|
| 695 |
+
defs[seen.defId] = seen.def;
|
| 696 |
+
}
|
| 697 |
+
}
|
| 698 |
+
// set definitions in result
|
| 699 |
+
if (params.external) {
|
| 700 |
+
}
|
| 701 |
+
else {
|
| 702 |
+
if (Object.keys(defs).length > 0) {
|
| 703 |
+
if (this.target === "draft-2020-12") {
|
| 704 |
+
result.$defs = defs;
|
| 705 |
+
}
|
| 706 |
+
else {
|
| 707 |
+
result.definitions = defs;
|
| 708 |
+
}
|
| 709 |
+
}
|
| 710 |
+
}
|
| 711 |
+
try {
|
| 712 |
+
// this "finalizes" this schema and ensures all cycles are removed
|
| 713 |
+
// each call to .emit() is functionally independent
|
| 714 |
+
// though the seen map is shared
|
| 715 |
+
return JSON.parse(JSON.stringify(result));
|
| 716 |
+
}
|
| 717 |
+
catch (_err) {
|
| 718 |
+
throw new Error("Error converting schema to JSON.");
|
| 719 |
+
}
|
| 720 |
+
}
|
| 721 |
+
}
|
| 722 |
+
exports.JSONSchemaGenerator = JSONSchemaGenerator;
|
| 723 |
+
function toJSONSchema(input, _params) {
|
| 724 |
+
if (input instanceof registries_js_1.$ZodRegistry) {
|
| 725 |
+
const gen = new JSONSchemaGenerator(_params);
|
| 726 |
+
const defs = {};
|
| 727 |
+
for (const entry of input._idmap.entries()) {
|
| 728 |
+
const [_, schema] = entry;
|
| 729 |
+
gen.process(schema);
|
| 730 |
+
}
|
| 731 |
+
const schemas = {};
|
| 732 |
+
const external = {
|
| 733 |
+
registry: input,
|
| 734 |
+
uri: _params?.uri,
|
| 735 |
+
defs,
|
| 736 |
+
};
|
| 737 |
+
for (const entry of input._idmap.entries()) {
|
| 738 |
+
const [key, schema] = entry;
|
| 739 |
+
schemas[key] = gen.emit(schema, {
|
| 740 |
+
..._params,
|
| 741 |
+
external,
|
| 742 |
+
});
|
| 743 |
+
}
|
| 744 |
+
if (Object.keys(defs).length > 0) {
|
| 745 |
+
const defsSegment = gen.target === "draft-2020-12" ? "$defs" : "definitions";
|
| 746 |
+
schemas.__shared = {
|
| 747 |
+
[defsSegment]: defs,
|
| 748 |
+
};
|
| 749 |
+
}
|
| 750 |
+
return { schemas };
|
| 751 |
+
}
|
| 752 |
+
const gen = new JSONSchemaGenerator(_params);
|
| 753 |
+
gen.process(input);
|
| 754 |
+
return gen.emit(input, _params);
|
| 755 |
+
}
|
| 756 |
+
function isTransforming(_schema, _ctx) {
|
| 757 |
+
const ctx = _ctx ?? { seen: new Set() };
|
| 758 |
+
if (ctx.seen.has(_schema))
|
| 759 |
+
return false;
|
| 760 |
+
ctx.seen.add(_schema);
|
| 761 |
+
const schema = _schema;
|
| 762 |
+
const def = schema._zod.def;
|
| 763 |
+
switch (def.type) {
|
| 764 |
+
case "string":
|
| 765 |
+
case "number":
|
| 766 |
+
case "bigint":
|
| 767 |
+
case "boolean":
|
| 768 |
+
case "date":
|
| 769 |
+
case "symbol":
|
| 770 |
+
case "undefined":
|
| 771 |
+
case "null":
|
| 772 |
+
case "any":
|
| 773 |
+
case "unknown":
|
| 774 |
+
case "never":
|
| 775 |
+
case "void":
|
| 776 |
+
case "literal":
|
| 777 |
+
case "enum":
|
| 778 |
+
case "nan":
|
| 779 |
+
case "file":
|
| 780 |
+
case "template_literal":
|
| 781 |
+
return false;
|
| 782 |
+
case "array": {
|
| 783 |
+
return isTransforming(def.element, ctx);
|
| 784 |
+
}
|
| 785 |
+
case "object": {
|
| 786 |
+
for (const key in def.shape) {
|
| 787 |
+
if (isTransforming(def.shape[key], ctx))
|
| 788 |
+
return true;
|
| 789 |
+
}
|
| 790 |
+
return false;
|
| 791 |
+
}
|
| 792 |
+
case "union": {
|
| 793 |
+
for (const option of def.options) {
|
| 794 |
+
if (isTransforming(option, ctx))
|
| 795 |
+
return true;
|
| 796 |
+
}
|
| 797 |
+
return false;
|
| 798 |
+
}
|
| 799 |
+
case "intersection": {
|
| 800 |
+
return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
| 801 |
+
}
|
| 802 |
+
case "tuple": {
|
| 803 |
+
for (const item of def.items) {
|
| 804 |
+
if (isTransforming(item, ctx))
|
| 805 |
+
return true;
|
| 806 |
+
}
|
| 807 |
+
if (def.rest && isTransforming(def.rest, ctx))
|
| 808 |
+
return true;
|
| 809 |
+
return false;
|
| 810 |
+
}
|
| 811 |
+
case "record": {
|
| 812 |
+
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
| 813 |
+
}
|
| 814 |
+
case "map": {
|
| 815 |
+
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
| 816 |
+
}
|
| 817 |
+
case "set": {
|
| 818 |
+
return isTransforming(def.valueType, ctx);
|
| 819 |
+
}
|
| 820 |
+
// inner types
|
| 821 |
+
case "promise":
|
| 822 |
+
case "optional":
|
| 823 |
+
case "nonoptional":
|
| 824 |
+
case "nullable":
|
| 825 |
+
case "readonly":
|
| 826 |
+
return isTransforming(def.innerType, ctx);
|
| 827 |
+
case "lazy":
|
| 828 |
+
return isTransforming(def.getter(), ctx);
|
| 829 |
+
case "default": {
|
| 830 |
+
return isTransforming(def.innerType, ctx);
|
| 831 |
+
}
|
| 832 |
+
case "prefault": {
|
| 833 |
+
return isTransforming(def.innerType, ctx);
|
| 834 |
+
}
|
| 835 |
+
case "custom": {
|
| 836 |
+
return false;
|
| 837 |
+
}
|
| 838 |
+
case "transform": {
|
| 839 |
+
return true;
|
| 840 |
+
}
|
| 841 |
+
case "pipe": {
|
| 842 |
+
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
| 843 |
+
}
|
| 844 |
+
case "success": {
|
| 845 |
+
return false;
|
| 846 |
+
}
|
| 847 |
+
case "catch": {
|
| 848 |
+
return false;
|
| 849 |
+
}
|
| 850 |
+
default:
|
| 851 |
+
def;
|
| 852 |
+
}
|
| 853 |
+
throw new Error(`Unknown schema type: ${def.type}`);
|
| 854 |
+
}
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/to-json-schema.d.cts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as JSONSchema from "./json-schema.cjs";
|
| 2 |
+
import { $ZodRegistry } from "./registries.cjs";
|
| 3 |
+
import type * as schemas from "./schemas.cjs";
|
| 4 |
+
interface JSONSchemaGeneratorParams {
|
| 5 |
+
/** A registry used to look up metadata for each schema. Any schema with an `id` property will be extracted as a $def.
|
| 6 |
+
* @default globalRegistry */
|
| 7 |
+
metadata?: $ZodRegistry<Record<string, any>>;
|
| 8 |
+
/** The JSON Schema version to target.
|
| 9 |
+
* - `"draft-2020-12"` — Default. JSON Schema Draft 2020-12
|
| 10 |
+
* - `"draft-7"` — JSON Schema Draft 7 */
|
| 11 |
+
target?: "draft-7" | "draft-2020-12";
|
| 12 |
+
/** How to handle unrepresentable types.
|
| 13 |
+
* - `"throw"` — Default. Unrepresentable types throw an error
|
| 14 |
+
* - `"any"` — Unrepresentable types become `{}` */
|
| 15 |
+
unrepresentable?: "throw" | "any";
|
| 16 |
+
/** Arbitrary custom logic that can be used to modify the generated JSON Schema. */
|
| 17 |
+
override?: (ctx: {
|
| 18 |
+
zodSchema: schemas.$ZodTypes;
|
| 19 |
+
jsonSchema: JSONSchema.BaseSchema;
|
| 20 |
+
path: (string | number)[];
|
| 21 |
+
}) => void;
|
| 22 |
+
/** Whether to extract the `"input"` or `"output"` type. Relevant to transforms, Error converting schema to JSONz, defaults, coerced primitives, etc.
|
| 23 |
+
* - `"output"` — Default. Convert the output schema.
|
| 24 |
+
* - `"input"` — Convert the input schema. */
|
| 25 |
+
io?: "input" | "output";
|
| 26 |
+
}
|
| 27 |
+
interface ProcessParams {
|
| 28 |
+
schemaPath: schemas.$ZodType[];
|
| 29 |
+
path: (string | number)[];
|
| 30 |
+
}
|
| 31 |
+
interface EmitParams {
|
| 32 |
+
/** How to handle cycles.
|
| 33 |
+
* - `"ref"` — Default. Cycles will be broken using $defs
|
| 34 |
+
* - `"throw"` — Cycles will throw an error if encountered */
|
| 35 |
+
cycles?: "ref" | "throw";
|
| 36 |
+
reused?: "ref" | "inline";
|
| 37 |
+
external?: {
|
| 38 |
+
/** */
|
| 39 |
+
registry: $ZodRegistry<{
|
| 40 |
+
id?: string | undefined;
|
| 41 |
+
}>;
|
| 42 |
+
uri?: ((id: string) => string) | undefined;
|
| 43 |
+
defs: Record<string, JSONSchema.BaseSchema>;
|
| 44 |
+
} | undefined;
|
| 45 |
+
}
|
| 46 |
+
interface Seen {
|
| 47 |
+
/** JSON Schema result for this Zod schema */
|
| 48 |
+
schema: JSONSchema.BaseSchema;
|
| 49 |
+
/** A cached version of the schema that doesn't get overwritten during ref resolution */
|
| 50 |
+
def?: JSONSchema.BaseSchema;
|
| 51 |
+
defId?: string | undefined;
|
| 52 |
+
/** Number of times this schema was encountered during traversal */
|
| 53 |
+
count: number;
|
| 54 |
+
/** Cycle path */
|
| 55 |
+
cycle?: (string | number)[] | undefined;
|
| 56 |
+
isParent?: boolean | undefined;
|
| 57 |
+
ref?: schemas.$ZodType | undefined | null;
|
| 58 |
+
/** JSON Schema property path for this schema */
|
| 59 |
+
path?: (string | number)[] | undefined;
|
| 60 |
+
}
|
| 61 |
+
export declare class JSONSchemaGenerator {
|
| 62 |
+
metadataRegistry: $ZodRegistry<Record<string, any>>;
|
| 63 |
+
target: "draft-7" | "draft-2020-12";
|
| 64 |
+
unrepresentable: "throw" | "any";
|
| 65 |
+
override: (ctx: {
|
| 66 |
+
zodSchema: schemas.$ZodTypes;
|
| 67 |
+
jsonSchema: JSONSchema.BaseSchema;
|
| 68 |
+
path: (string | number)[];
|
| 69 |
+
}) => void;
|
| 70 |
+
io: "input" | "output";
|
| 71 |
+
counter: number;
|
| 72 |
+
seen: Map<schemas.$ZodType, Seen>;
|
| 73 |
+
constructor(params?: JSONSchemaGeneratorParams);
|
| 74 |
+
process(schema: schemas.$ZodType, _params?: ProcessParams): JSONSchema.BaseSchema;
|
| 75 |
+
emit(schema: schemas.$ZodType, _params?: EmitParams): JSONSchema.BaseSchema;
|
| 76 |
+
}
|
| 77 |
+
interface ToJSONSchemaParams extends Omit<JSONSchemaGeneratorParams & EmitParams, "external"> {
|
| 78 |
+
}
|
| 79 |
+
interface RegistryToJSONSchemaParams extends Omit<JSONSchemaGeneratorParams & EmitParams, "external"> {
|
| 80 |
+
uri?: (id: string) => string;
|
| 81 |
+
}
|
| 82 |
+
export declare function toJSONSchema(schema: schemas.$ZodType, _params?: ToJSONSchemaParams): JSONSchema.BaseSchema;
|
| 83 |
+
export declare function toJSONSchema(registry: $ZodRegistry<{
|
| 84 |
+
id?: string | undefined;
|
| 85 |
+
}>, _params?: RegistryToJSONSchemaParams): {
|
| 86 |
+
schemas: Record<string, JSONSchema.BaseSchema>;
|
| 87 |
+
};
|
| 88 |
+
export {};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/to-json-schema.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as JSONSchema from "./json-schema.js";
|
| 2 |
+
import { $ZodRegistry } from "./registries.js";
|
| 3 |
+
import type * as schemas from "./schemas.js";
|
| 4 |
+
interface JSONSchemaGeneratorParams {
|
| 5 |
+
/** A registry used to look up metadata for each schema. Any schema with an `id` property will be extracted as a $def.
|
| 6 |
+
* @default globalRegistry */
|
| 7 |
+
metadata?: $ZodRegistry<Record<string, any>>;
|
| 8 |
+
/** The JSON Schema version to target.
|
| 9 |
+
* - `"draft-2020-12"` — Default. JSON Schema Draft 2020-12
|
| 10 |
+
* - `"draft-7"` — JSON Schema Draft 7 */
|
| 11 |
+
target?: "draft-7" | "draft-2020-12";
|
| 12 |
+
/** How to handle unrepresentable types.
|
| 13 |
+
* - `"throw"` — Default. Unrepresentable types throw an error
|
| 14 |
+
* - `"any"` — Unrepresentable types become `{}` */
|
| 15 |
+
unrepresentable?: "throw" | "any";
|
| 16 |
+
/** Arbitrary custom logic that can be used to modify the generated JSON Schema. */
|
| 17 |
+
override?: (ctx: {
|
| 18 |
+
zodSchema: schemas.$ZodTypes;
|
| 19 |
+
jsonSchema: JSONSchema.BaseSchema;
|
| 20 |
+
path: (string | number)[];
|
| 21 |
+
}) => void;
|
| 22 |
+
/** Whether to extract the `"input"` or `"output"` type. Relevant to transforms, Error converting schema to JSONz, defaults, coerced primitives, etc.
|
| 23 |
+
* - `"output"` — Default. Convert the output schema.
|
| 24 |
+
* - `"input"` — Convert the input schema. */
|
| 25 |
+
io?: "input" | "output";
|
| 26 |
+
}
|
| 27 |
+
interface ProcessParams {
|
| 28 |
+
schemaPath: schemas.$ZodType[];
|
| 29 |
+
path: (string | number)[];
|
| 30 |
+
}
|
| 31 |
+
interface EmitParams {
|
| 32 |
+
/** How to handle cycles.
|
| 33 |
+
* - `"ref"` — Default. Cycles will be broken using $defs
|
| 34 |
+
* - `"throw"` — Cycles will throw an error if encountered */
|
| 35 |
+
cycles?: "ref" | "throw";
|
| 36 |
+
reused?: "ref" | "inline";
|
| 37 |
+
external?: {
|
| 38 |
+
/** */
|
| 39 |
+
registry: $ZodRegistry<{
|
| 40 |
+
id?: string | undefined;
|
| 41 |
+
}>;
|
| 42 |
+
uri?: ((id: string) => string) | undefined;
|
| 43 |
+
defs: Record<string, JSONSchema.BaseSchema>;
|
| 44 |
+
} | undefined;
|
| 45 |
+
}
|
| 46 |
+
interface Seen {
|
| 47 |
+
/** JSON Schema result for this Zod schema */
|
| 48 |
+
schema: JSONSchema.BaseSchema;
|
| 49 |
+
/** A cached version of the schema that doesn't get overwritten during ref resolution */
|
| 50 |
+
def?: JSONSchema.BaseSchema;
|
| 51 |
+
defId?: string | undefined;
|
| 52 |
+
/** Number of times this schema was encountered during traversal */
|
| 53 |
+
count: number;
|
| 54 |
+
/** Cycle path */
|
| 55 |
+
cycle?: (string | number)[] | undefined;
|
| 56 |
+
isParent?: boolean | undefined;
|
| 57 |
+
ref?: schemas.$ZodType | undefined | null;
|
| 58 |
+
/** JSON Schema property path for this schema */
|
| 59 |
+
path?: (string | number)[] | undefined;
|
| 60 |
+
}
|
| 61 |
+
export declare class JSONSchemaGenerator {
|
| 62 |
+
metadataRegistry: $ZodRegistry<Record<string, any>>;
|
| 63 |
+
target: "draft-7" | "draft-2020-12";
|
| 64 |
+
unrepresentable: "throw" | "any";
|
| 65 |
+
override: (ctx: {
|
| 66 |
+
zodSchema: schemas.$ZodTypes;
|
| 67 |
+
jsonSchema: JSONSchema.BaseSchema;
|
| 68 |
+
path: (string | number)[];
|
| 69 |
+
}) => void;
|
| 70 |
+
io: "input" | "output";
|
| 71 |
+
counter: number;
|
| 72 |
+
seen: Map<schemas.$ZodType, Seen>;
|
| 73 |
+
constructor(params?: JSONSchemaGeneratorParams);
|
| 74 |
+
process(schema: schemas.$ZodType, _params?: ProcessParams): JSONSchema.BaseSchema;
|
| 75 |
+
emit(schema: schemas.$ZodType, _params?: EmitParams): JSONSchema.BaseSchema;
|
| 76 |
+
}
|
| 77 |
+
interface ToJSONSchemaParams extends Omit<JSONSchemaGeneratorParams & EmitParams, "external"> {
|
| 78 |
+
}
|
| 79 |
+
interface RegistryToJSONSchemaParams extends Omit<JSONSchemaGeneratorParams & EmitParams, "external"> {
|
| 80 |
+
uri?: (id: string) => string;
|
| 81 |
+
}
|
| 82 |
+
export declare function toJSONSchema(schema: schemas.$ZodType, _params?: ToJSONSchemaParams): JSONSchema.BaseSchema;
|
| 83 |
+
export declare function toJSONSchema(registry: $ZodRegistry<{
|
| 84 |
+
id?: string | undefined;
|
| 85 |
+
}>, _params?: RegistryToJSONSchemaParams): {
|
| 86 |
+
schemas: Record<string, JSONSchema.BaseSchema>;
|
| 87 |
+
};
|
| 88 |
+
export {};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/to-json-schema.js
ADDED
|
@@ -0,0 +1,849 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { $ZodRegistry, globalRegistry } from "./registries.js";
|
| 2 |
+
import { getEnumValues } from "./util.js";
|
| 3 |
+
export class JSONSchemaGenerator {
|
| 4 |
+
constructor(params) {
|
| 5 |
+
this.counter = 0;
|
| 6 |
+
this.metadataRegistry = params?.metadata ?? globalRegistry;
|
| 7 |
+
this.target = params?.target ?? "draft-2020-12";
|
| 8 |
+
this.unrepresentable = params?.unrepresentable ?? "throw";
|
| 9 |
+
this.override = params?.override ?? (() => { });
|
| 10 |
+
this.io = params?.io ?? "output";
|
| 11 |
+
this.seen = new Map();
|
| 12 |
+
}
|
| 13 |
+
process(schema, _params = { path: [], schemaPath: [] }) {
|
| 14 |
+
var _a;
|
| 15 |
+
const def = schema._zod.def;
|
| 16 |
+
const formatMap = {
|
| 17 |
+
guid: "uuid",
|
| 18 |
+
url: "uri",
|
| 19 |
+
datetime: "date-time",
|
| 20 |
+
json_string: "json-string",
|
| 21 |
+
regex: "", // do not set
|
| 22 |
+
};
|
| 23 |
+
// check for schema in seens
|
| 24 |
+
const seen = this.seen.get(schema);
|
| 25 |
+
if (seen) {
|
| 26 |
+
seen.count++;
|
| 27 |
+
// check if cycle
|
| 28 |
+
const isCycle = _params.schemaPath.includes(schema);
|
| 29 |
+
if (isCycle) {
|
| 30 |
+
seen.cycle = _params.path;
|
| 31 |
+
}
|
| 32 |
+
return seen.schema;
|
| 33 |
+
}
|
| 34 |
+
// initialize
|
| 35 |
+
const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
|
| 36 |
+
this.seen.set(schema, result);
|
| 37 |
+
// custom method overrides default behavior
|
| 38 |
+
const overrideSchema = schema._zod.toJSONSchema?.();
|
| 39 |
+
if (overrideSchema) {
|
| 40 |
+
result.schema = overrideSchema;
|
| 41 |
+
}
|
| 42 |
+
else {
|
| 43 |
+
const params = {
|
| 44 |
+
..._params,
|
| 45 |
+
schemaPath: [..._params.schemaPath, schema],
|
| 46 |
+
path: _params.path,
|
| 47 |
+
};
|
| 48 |
+
const parent = schema._zod.parent;
|
| 49 |
+
if (parent) {
|
| 50 |
+
// schema was cloned from another schema
|
| 51 |
+
result.ref = parent;
|
| 52 |
+
this.process(parent, params);
|
| 53 |
+
this.seen.get(parent).isParent = true;
|
| 54 |
+
}
|
| 55 |
+
else {
|
| 56 |
+
const _json = result.schema;
|
| 57 |
+
switch (def.type) {
|
| 58 |
+
case "string": {
|
| 59 |
+
const json = _json;
|
| 60 |
+
json.type = "string";
|
| 61 |
+
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod
|
| 62 |
+
.bag;
|
| 63 |
+
if (typeof minimum === "number")
|
| 64 |
+
json.minLength = minimum;
|
| 65 |
+
if (typeof maximum === "number")
|
| 66 |
+
json.maxLength = maximum;
|
| 67 |
+
// custom pattern overrides format
|
| 68 |
+
if (format) {
|
| 69 |
+
json.format = formatMap[format] ?? format;
|
| 70 |
+
if (json.format === "")
|
| 71 |
+
delete json.format; // empty format is not valid
|
| 72 |
+
}
|
| 73 |
+
if (contentEncoding)
|
| 74 |
+
json.contentEncoding = contentEncoding;
|
| 75 |
+
if (patterns && patterns.size > 0) {
|
| 76 |
+
const regexes = [...patterns];
|
| 77 |
+
if (regexes.length === 1)
|
| 78 |
+
json.pattern = regexes[0].source;
|
| 79 |
+
else if (regexes.length > 1) {
|
| 80 |
+
result.schema.allOf = [
|
| 81 |
+
...regexes.map((regex) => ({
|
| 82 |
+
...(this.target === "draft-7" ? { type: "string" } : {}),
|
| 83 |
+
pattern: regex.source,
|
| 84 |
+
})),
|
| 85 |
+
];
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
break;
|
| 89 |
+
}
|
| 90 |
+
case "number": {
|
| 91 |
+
const json = _json;
|
| 92 |
+
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
| 93 |
+
if (typeof format === "string" && format.includes("int"))
|
| 94 |
+
json.type = "integer";
|
| 95 |
+
else
|
| 96 |
+
json.type = "number";
|
| 97 |
+
if (typeof exclusiveMinimum === "number")
|
| 98 |
+
json.exclusiveMinimum = exclusiveMinimum;
|
| 99 |
+
if (typeof minimum === "number") {
|
| 100 |
+
json.minimum = minimum;
|
| 101 |
+
if (typeof exclusiveMinimum === "number") {
|
| 102 |
+
if (exclusiveMinimum >= minimum)
|
| 103 |
+
delete json.minimum;
|
| 104 |
+
else
|
| 105 |
+
delete json.exclusiveMinimum;
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
if (typeof exclusiveMaximum === "number")
|
| 109 |
+
json.exclusiveMaximum = exclusiveMaximum;
|
| 110 |
+
if (typeof maximum === "number") {
|
| 111 |
+
json.maximum = maximum;
|
| 112 |
+
if (typeof exclusiveMaximum === "number") {
|
| 113 |
+
if (exclusiveMaximum <= maximum)
|
| 114 |
+
delete json.maximum;
|
| 115 |
+
else
|
| 116 |
+
delete json.exclusiveMaximum;
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
if (typeof multipleOf === "number")
|
| 120 |
+
json.multipleOf = multipleOf;
|
| 121 |
+
break;
|
| 122 |
+
}
|
| 123 |
+
case "boolean": {
|
| 124 |
+
const json = _json;
|
| 125 |
+
json.type = "boolean";
|
| 126 |
+
break;
|
| 127 |
+
}
|
| 128 |
+
case "bigint": {
|
| 129 |
+
if (this.unrepresentable === "throw") {
|
| 130 |
+
throw new Error("BigInt cannot be represented in JSON Schema");
|
| 131 |
+
}
|
| 132 |
+
break;
|
| 133 |
+
}
|
| 134 |
+
case "symbol": {
|
| 135 |
+
if (this.unrepresentable === "throw") {
|
| 136 |
+
throw new Error("Symbols cannot be represented in JSON Schema");
|
| 137 |
+
}
|
| 138 |
+
break;
|
| 139 |
+
}
|
| 140 |
+
case "null": {
|
| 141 |
+
_json.type = "null";
|
| 142 |
+
break;
|
| 143 |
+
}
|
| 144 |
+
case "any": {
|
| 145 |
+
break;
|
| 146 |
+
}
|
| 147 |
+
case "unknown": {
|
| 148 |
+
break;
|
| 149 |
+
}
|
| 150 |
+
case "undefined": {
|
| 151 |
+
if (this.unrepresentable === "throw") {
|
| 152 |
+
throw new Error("Undefined cannot be represented in JSON Schema");
|
| 153 |
+
}
|
| 154 |
+
break;
|
| 155 |
+
}
|
| 156 |
+
case "void": {
|
| 157 |
+
if (this.unrepresentable === "throw") {
|
| 158 |
+
throw new Error("Void cannot be represented in JSON Schema");
|
| 159 |
+
}
|
| 160 |
+
break;
|
| 161 |
+
}
|
| 162 |
+
case "never": {
|
| 163 |
+
_json.not = {};
|
| 164 |
+
break;
|
| 165 |
+
}
|
| 166 |
+
case "date": {
|
| 167 |
+
if (this.unrepresentable === "throw") {
|
| 168 |
+
throw new Error("Date cannot be represented in JSON Schema");
|
| 169 |
+
}
|
| 170 |
+
break;
|
| 171 |
+
}
|
| 172 |
+
case "array": {
|
| 173 |
+
const json = _json;
|
| 174 |
+
const { minimum, maximum } = schema._zod.bag;
|
| 175 |
+
if (typeof minimum === "number")
|
| 176 |
+
json.minItems = minimum;
|
| 177 |
+
if (typeof maximum === "number")
|
| 178 |
+
json.maxItems = maximum;
|
| 179 |
+
json.type = "array";
|
| 180 |
+
json.items = this.process(def.element, { ...params, path: [...params.path, "items"] });
|
| 181 |
+
break;
|
| 182 |
+
}
|
| 183 |
+
case "object": {
|
| 184 |
+
const json = _json;
|
| 185 |
+
json.type = "object";
|
| 186 |
+
json.properties = {};
|
| 187 |
+
const shape = def.shape; // params.shapeCache.get(schema)!;
|
| 188 |
+
for (const key in shape) {
|
| 189 |
+
json.properties[key] = this.process(shape[key], {
|
| 190 |
+
...params,
|
| 191 |
+
path: [...params.path, "properties", key],
|
| 192 |
+
});
|
| 193 |
+
}
|
| 194 |
+
// required keys
|
| 195 |
+
const allKeys = new Set(Object.keys(shape));
|
| 196 |
+
// const optionalKeys = new Set(def.optional);
|
| 197 |
+
const requiredKeys = new Set([...allKeys].filter((key) => {
|
| 198 |
+
const v = def.shape[key]._zod;
|
| 199 |
+
if (this.io === "input") {
|
| 200 |
+
return v.optin === undefined;
|
| 201 |
+
}
|
| 202 |
+
else {
|
| 203 |
+
return v.optout === undefined;
|
| 204 |
+
}
|
| 205 |
+
}));
|
| 206 |
+
if (requiredKeys.size > 0) {
|
| 207 |
+
json.required = Array.from(requiredKeys);
|
| 208 |
+
}
|
| 209 |
+
// catchall
|
| 210 |
+
if (def.catchall?._zod.def.type === "never") {
|
| 211 |
+
// strict
|
| 212 |
+
json.additionalProperties = false;
|
| 213 |
+
}
|
| 214 |
+
else if (!def.catchall) {
|
| 215 |
+
// regular
|
| 216 |
+
if (this.io === "output")
|
| 217 |
+
json.additionalProperties = false;
|
| 218 |
+
}
|
| 219 |
+
else if (def.catchall) {
|
| 220 |
+
json.additionalProperties = this.process(def.catchall, {
|
| 221 |
+
...params,
|
| 222 |
+
path: [...params.path, "additionalProperties"],
|
| 223 |
+
});
|
| 224 |
+
}
|
| 225 |
+
break;
|
| 226 |
+
}
|
| 227 |
+
case "union": {
|
| 228 |
+
const json = _json;
|
| 229 |
+
json.anyOf = def.options.map((x, i) => this.process(x, {
|
| 230 |
+
...params,
|
| 231 |
+
path: [...params.path, "anyOf", i],
|
| 232 |
+
}));
|
| 233 |
+
break;
|
| 234 |
+
}
|
| 235 |
+
case "intersection": {
|
| 236 |
+
const json = _json;
|
| 237 |
+
const a = this.process(def.left, {
|
| 238 |
+
...params,
|
| 239 |
+
path: [...params.path, "allOf", 0],
|
| 240 |
+
});
|
| 241 |
+
const b = this.process(def.right, {
|
| 242 |
+
...params,
|
| 243 |
+
path: [...params.path, "allOf", 1],
|
| 244 |
+
});
|
| 245 |
+
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
| 246 |
+
const allOf = [
|
| 247 |
+
...(isSimpleIntersection(a) ? a.allOf : [a]),
|
| 248 |
+
...(isSimpleIntersection(b) ? b.allOf : [b]),
|
| 249 |
+
];
|
| 250 |
+
json.allOf = allOf;
|
| 251 |
+
break;
|
| 252 |
+
}
|
| 253 |
+
case "tuple": {
|
| 254 |
+
const json = _json;
|
| 255 |
+
json.type = "array";
|
| 256 |
+
const prefixItems = def.items.map((x, i) => this.process(x, { ...params, path: [...params.path, "prefixItems", i] }));
|
| 257 |
+
if (this.target === "draft-2020-12") {
|
| 258 |
+
json.prefixItems = prefixItems;
|
| 259 |
+
}
|
| 260 |
+
else {
|
| 261 |
+
json.items = prefixItems;
|
| 262 |
+
}
|
| 263 |
+
if (def.rest) {
|
| 264 |
+
const rest = this.process(def.rest, {
|
| 265 |
+
...params,
|
| 266 |
+
path: [...params.path, "items"],
|
| 267 |
+
});
|
| 268 |
+
if (this.target === "draft-2020-12") {
|
| 269 |
+
json.items = rest;
|
| 270 |
+
}
|
| 271 |
+
else {
|
| 272 |
+
json.additionalItems = rest;
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
// additionalItems
|
| 276 |
+
if (def.rest) {
|
| 277 |
+
json.items = this.process(def.rest, {
|
| 278 |
+
...params,
|
| 279 |
+
path: [...params.path, "items"],
|
| 280 |
+
});
|
| 281 |
+
}
|
| 282 |
+
// length
|
| 283 |
+
const { minimum, maximum } = schema._zod.bag;
|
| 284 |
+
if (typeof minimum === "number")
|
| 285 |
+
json.minItems = minimum;
|
| 286 |
+
if (typeof maximum === "number")
|
| 287 |
+
json.maxItems = maximum;
|
| 288 |
+
break;
|
| 289 |
+
}
|
| 290 |
+
case "record": {
|
| 291 |
+
const json = _json;
|
| 292 |
+
json.type = "object";
|
| 293 |
+
json.propertyNames = this.process(def.keyType, { ...params, path: [...params.path, "propertyNames"] });
|
| 294 |
+
json.additionalProperties = this.process(def.valueType, {
|
| 295 |
+
...params,
|
| 296 |
+
path: [...params.path, "additionalProperties"],
|
| 297 |
+
});
|
| 298 |
+
break;
|
| 299 |
+
}
|
| 300 |
+
case "map": {
|
| 301 |
+
if (this.unrepresentable === "throw") {
|
| 302 |
+
throw new Error("Map cannot be represented in JSON Schema");
|
| 303 |
+
}
|
| 304 |
+
break;
|
| 305 |
+
}
|
| 306 |
+
case "set": {
|
| 307 |
+
if (this.unrepresentable === "throw") {
|
| 308 |
+
throw new Error("Set cannot be represented in JSON Schema");
|
| 309 |
+
}
|
| 310 |
+
break;
|
| 311 |
+
}
|
| 312 |
+
case "enum": {
|
| 313 |
+
const json = _json;
|
| 314 |
+
const values = getEnumValues(def.entries);
|
| 315 |
+
// Number enums can have both string and number values
|
| 316 |
+
if (values.every((v) => typeof v === "number"))
|
| 317 |
+
json.type = "number";
|
| 318 |
+
if (values.every((v) => typeof v === "string"))
|
| 319 |
+
json.type = "string";
|
| 320 |
+
json.enum = values;
|
| 321 |
+
break;
|
| 322 |
+
}
|
| 323 |
+
case "literal": {
|
| 324 |
+
const json = _json;
|
| 325 |
+
const vals = [];
|
| 326 |
+
for (const val of def.values) {
|
| 327 |
+
if (val === undefined) {
|
| 328 |
+
if (this.unrepresentable === "throw") {
|
| 329 |
+
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
| 330 |
+
}
|
| 331 |
+
else {
|
| 332 |
+
// do not add to vals
|
| 333 |
+
}
|
| 334 |
+
}
|
| 335 |
+
else if (typeof val === "bigint") {
|
| 336 |
+
if (this.unrepresentable === "throw") {
|
| 337 |
+
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
| 338 |
+
}
|
| 339 |
+
else {
|
| 340 |
+
vals.push(Number(val));
|
| 341 |
+
}
|
| 342 |
+
}
|
| 343 |
+
else {
|
| 344 |
+
vals.push(val);
|
| 345 |
+
}
|
| 346 |
+
}
|
| 347 |
+
if (vals.length === 0) {
|
| 348 |
+
// do nothing (an undefined literal was stripped)
|
| 349 |
+
}
|
| 350 |
+
else if (vals.length === 1) {
|
| 351 |
+
const val = vals[0];
|
| 352 |
+
json.type = val === null ? "null" : typeof val;
|
| 353 |
+
json.const = val;
|
| 354 |
+
}
|
| 355 |
+
else {
|
| 356 |
+
if (vals.every((v) => typeof v === "number"))
|
| 357 |
+
json.type = "number";
|
| 358 |
+
if (vals.every((v) => typeof v === "string"))
|
| 359 |
+
json.type = "string";
|
| 360 |
+
if (vals.every((v) => typeof v === "boolean"))
|
| 361 |
+
json.type = "string";
|
| 362 |
+
if (vals.every((v) => v === null))
|
| 363 |
+
json.type = "null";
|
| 364 |
+
json.enum = vals;
|
| 365 |
+
}
|
| 366 |
+
break;
|
| 367 |
+
}
|
| 368 |
+
case "file": {
|
| 369 |
+
const json = _json;
|
| 370 |
+
const file = {
|
| 371 |
+
type: "string",
|
| 372 |
+
format: "binary",
|
| 373 |
+
contentEncoding: "binary",
|
| 374 |
+
};
|
| 375 |
+
const { minimum, maximum, mime } = schema._zod.bag;
|
| 376 |
+
if (minimum !== undefined)
|
| 377 |
+
file.minLength = minimum;
|
| 378 |
+
if (maximum !== undefined)
|
| 379 |
+
file.maxLength = maximum;
|
| 380 |
+
if (mime) {
|
| 381 |
+
if (mime.length === 1) {
|
| 382 |
+
file.contentMediaType = mime[0];
|
| 383 |
+
Object.assign(json, file);
|
| 384 |
+
}
|
| 385 |
+
else {
|
| 386 |
+
json.anyOf = mime.map((m) => {
|
| 387 |
+
const mFile = { ...file, contentMediaType: m };
|
| 388 |
+
return mFile;
|
| 389 |
+
});
|
| 390 |
+
}
|
| 391 |
+
}
|
| 392 |
+
else {
|
| 393 |
+
Object.assign(json, file);
|
| 394 |
+
}
|
| 395 |
+
// if (this.unrepresentable === "throw") {
|
| 396 |
+
// throw new Error("File cannot be represented in JSON Schema");
|
| 397 |
+
// }
|
| 398 |
+
break;
|
| 399 |
+
}
|
| 400 |
+
case "transform": {
|
| 401 |
+
if (this.unrepresentable === "throw") {
|
| 402 |
+
throw new Error("Transforms cannot be represented in JSON Schema");
|
| 403 |
+
}
|
| 404 |
+
break;
|
| 405 |
+
}
|
| 406 |
+
case "nullable": {
|
| 407 |
+
const inner = this.process(def.innerType, params);
|
| 408 |
+
_json.anyOf = [inner, { type: "null" }];
|
| 409 |
+
break;
|
| 410 |
+
}
|
| 411 |
+
case "nonoptional": {
|
| 412 |
+
this.process(def.innerType, params);
|
| 413 |
+
result.ref = def.innerType;
|
| 414 |
+
break;
|
| 415 |
+
}
|
| 416 |
+
case "success": {
|
| 417 |
+
const json = _json;
|
| 418 |
+
json.type = "boolean";
|
| 419 |
+
break;
|
| 420 |
+
}
|
| 421 |
+
case "default": {
|
| 422 |
+
this.process(def.innerType, params);
|
| 423 |
+
result.ref = def.innerType;
|
| 424 |
+
_json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
| 425 |
+
break;
|
| 426 |
+
}
|
| 427 |
+
case "prefault": {
|
| 428 |
+
this.process(def.innerType, params);
|
| 429 |
+
result.ref = def.innerType;
|
| 430 |
+
if (this.io === "input")
|
| 431 |
+
_json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
| 432 |
+
break;
|
| 433 |
+
}
|
| 434 |
+
case "catch": {
|
| 435 |
+
// use conditionals
|
| 436 |
+
this.process(def.innerType, params);
|
| 437 |
+
result.ref = def.innerType;
|
| 438 |
+
let catchValue;
|
| 439 |
+
try {
|
| 440 |
+
catchValue = def.catchValue(undefined);
|
| 441 |
+
}
|
| 442 |
+
catch {
|
| 443 |
+
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
| 444 |
+
}
|
| 445 |
+
_json.default = catchValue;
|
| 446 |
+
break;
|
| 447 |
+
}
|
| 448 |
+
case "nan": {
|
| 449 |
+
if (this.unrepresentable === "throw") {
|
| 450 |
+
throw new Error("NaN cannot be represented in JSON Schema");
|
| 451 |
+
}
|
| 452 |
+
break;
|
| 453 |
+
}
|
| 454 |
+
case "template_literal": {
|
| 455 |
+
const json = _json;
|
| 456 |
+
const pattern = schema._zod.pattern;
|
| 457 |
+
if (!pattern)
|
| 458 |
+
throw new Error("Pattern not found in template literal");
|
| 459 |
+
json.type = "string";
|
| 460 |
+
json.pattern = pattern.source;
|
| 461 |
+
break;
|
| 462 |
+
}
|
| 463 |
+
case "pipe": {
|
| 464 |
+
const innerType = this.io === "input" ? (def.in._zod.def.type === "transform" ? def.out : def.in) : def.out;
|
| 465 |
+
this.process(innerType, params);
|
| 466 |
+
result.ref = innerType;
|
| 467 |
+
break;
|
| 468 |
+
}
|
| 469 |
+
case "readonly": {
|
| 470 |
+
this.process(def.innerType, params);
|
| 471 |
+
result.ref = def.innerType;
|
| 472 |
+
_json.readOnly = true;
|
| 473 |
+
break;
|
| 474 |
+
}
|
| 475 |
+
// passthrough types
|
| 476 |
+
case "promise": {
|
| 477 |
+
this.process(def.innerType, params);
|
| 478 |
+
result.ref = def.innerType;
|
| 479 |
+
break;
|
| 480 |
+
}
|
| 481 |
+
case "optional": {
|
| 482 |
+
this.process(def.innerType, params);
|
| 483 |
+
result.ref = def.innerType;
|
| 484 |
+
break;
|
| 485 |
+
}
|
| 486 |
+
case "lazy": {
|
| 487 |
+
const innerType = schema._zod.innerType;
|
| 488 |
+
this.process(innerType, params);
|
| 489 |
+
result.ref = innerType;
|
| 490 |
+
break;
|
| 491 |
+
}
|
| 492 |
+
case "custom": {
|
| 493 |
+
if (this.unrepresentable === "throw") {
|
| 494 |
+
throw new Error("Custom types cannot be represented in JSON Schema");
|
| 495 |
+
}
|
| 496 |
+
break;
|
| 497 |
+
}
|
| 498 |
+
default: {
|
| 499 |
+
def;
|
| 500 |
+
}
|
| 501 |
+
}
|
| 502 |
+
}
|
| 503 |
+
}
|
| 504 |
+
// metadata
|
| 505 |
+
const meta = this.metadataRegistry.get(schema);
|
| 506 |
+
if (meta)
|
| 507 |
+
Object.assign(result.schema, meta);
|
| 508 |
+
if (this.io === "input" && isTransforming(schema)) {
|
| 509 |
+
// examples/defaults only apply to output type of pipe
|
| 510 |
+
delete result.schema.examples;
|
| 511 |
+
delete result.schema.default;
|
| 512 |
+
}
|
| 513 |
+
// set prefault as default
|
| 514 |
+
if (this.io === "input" && result.schema._prefault)
|
| 515 |
+
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
| 516 |
+
delete result.schema._prefault;
|
| 517 |
+
// pulling fresh from this.seen in case it was overwritten
|
| 518 |
+
const _result = this.seen.get(schema);
|
| 519 |
+
return _result.schema;
|
| 520 |
+
}
|
| 521 |
+
emit(schema, _params) {
|
| 522 |
+
const params = {
|
| 523 |
+
cycles: _params?.cycles ?? "ref",
|
| 524 |
+
reused: _params?.reused ?? "inline",
|
| 525 |
+
// unrepresentable: _params?.unrepresentable ?? "throw",
|
| 526 |
+
// uri: _params?.uri ?? ((id) => `${id}`),
|
| 527 |
+
external: _params?.external ?? undefined,
|
| 528 |
+
};
|
| 529 |
+
// iterate over seen map;
|
| 530 |
+
const root = this.seen.get(schema);
|
| 531 |
+
if (!root)
|
| 532 |
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
| 533 |
+
// initialize result with root schema fields
|
| 534 |
+
// Object.assign(result, seen.cached);
|
| 535 |
+
// returns a ref to the schema
|
| 536 |
+
// defId will be empty if the ref points to an external schema (or #)
|
| 537 |
+
const makeURI = (entry) => {
|
| 538 |
+
// comparing the seen objects because sometimes
|
| 539 |
+
// multiple schemas map to the same seen object.
|
| 540 |
+
// e.g. lazy
|
| 541 |
+
// external is configured
|
| 542 |
+
const defsSegment = this.target === "draft-2020-12" ? "$defs" : "definitions";
|
| 543 |
+
if (params.external) {
|
| 544 |
+
const externalId = params.external.registry.get(entry[0])?.id; // ?? "__shared";// `__schema${this.counter++}`;
|
| 545 |
+
// check if schema is in the external registry
|
| 546 |
+
const uriGenerator = params.external.uri ?? ((id) => id);
|
| 547 |
+
if (externalId) {
|
| 548 |
+
return { ref: uriGenerator(externalId) };
|
| 549 |
+
}
|
| 550 |
+
// otherwise, add to __shared
|
| 551 |
+
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${this.counter++}`;
|
| 552 |
+
entry[1].defId = id; // set defId so it will be reused if needed
|
| 553 |
+
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
| 554 |
+
}
|
| 555 |
+
if (entry[1] === root) {
|
| 556 |
+
return { ref: "#" };
|
| 557 |
+
}
|
| 558 |
+
// self-contained schema
|
| 559 |
+
const uriPrefix = `#`;
|
| 560 |
+
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
| 561 |
+
const defId = entry[1].schema.id ?? `__schema${this.counter++}`;
|
| 562 |
+
return { defId, ref: defUriPrefix + defId };
|
| 563 |
+
};
|
| 564 |
+
// stored cached version in `def` property
|
| 565 |
+
// remove all properties, set $ref
|
| 566 |
+
const extractToDef = (entry) => {
|
| 567 |
+
// if the schema is already a reference, do not extract it
|
| 568 |
+
if (entry[1].schema.$ref) {
|
| 569 |
+
return;
|
| 570 |
+
}
|
| 571 |
+
const seen = entry[1];
|
| 572 |
+
const { ref, defId } = makeURI(entry);
|
| 573 |
+
seen.def = { ...seen.schema };
|
| 574 |
+
// defId won't be set if the schema is a reference to an external schema
|
| 575 |
+
if (defId)
|
| 576 |
+
seen.defId = defId;
|
| 577 |
+
// wipe away all properties except $ref
|
| 578 |
+
const schema = seen.schema;
|
| 579 |
+
for (const key in schema) {
|
| 580 |
+
delete schema[key];
|
| 581 |
+
}
|
| 582 |
+
schema.$ref = ref;
|
| 583 |
+
};
|
| 584 |
+
// throw on cycles
|
| 585 |
+
// break cycles
|
| 586 |
+
if (params.cycles === "throw") {
|
| 587 |
+
for (const entry of this.seen.entries()) {
|
| 588 |
+
const seen = entry[1];
|
| 589 |
+
if (seen.cycle) {
|
| 590 |
+
throw new Error("Cycle detected: " +
|
| 591 |
+
`#/${seen.cycle?.join("/")}/<root>` +
|
| 592 |
+
'\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.');
|
| 593 |
+
}
|
| 594 |
+
}
|
| 595 |
+
}
|
| 596 |
+
// extract schemas into $defs
|
| 597 |
+
for (const entry of this.seen.entries()) {
|
| 598 |
+
const seen = entry[1];
|
| 599 |
+
// convert root schema to # $ref
|
| 600 |
+
if (schema === entry[0]) {
|
| 601 |
+
extractToDef(entry); // this has special handling for the root schema
|
| 602 |
+
continue;
|
| 603 |
+
}
|
| 604 |
+
// extract schemas that are in the external registry
|
| 605 |
+
if (params.external) {
|
| 606 |
+
const ext = params.external.registry.get(entry[0])?.id;
|
| 607 |
+
if (schema !== entry[0] && ext) {
|
| 608 |
+
extractToDef(entry);
|
| 609 |
+
continue;
|
| 610 |
+
}
|
| 611 |
+
}
|
| 612 |
+
// extract schemas with `id` meta
|
| 613 |
+
const id = this.metadataRegistry.get(entry[0])?.id;
|
| 614 |
+
if (id) {
|
| 615 |
+
extractToDef(entry);
|
| 616 |
+
continue;
|
| 617 |
+
}
|
| 618 |
+
// break cycles
|
| 619 |
+
if (seen.cycle) {
|
| 620 |
+
// any
|
| 621 |
+
extractToDef(entry);
|
| 622 |
+
continue;
|
| 623 |
+
}
|
| 624 |
+
// extract reused schemas
|
| 625 |
+
if (seen.count > 1) {
|
| 626 |
+
if (params.reused === "ref") {
|
| 627 |
+
extractToDef(entry);
|
| 628 |
+
// biome-ignore lint:
|
| 629 |
+
continue;
|
| 630 |
+
}
|
| 631 |
+
}
|
| 632 |
+
}
|
| 633 |
+
// flatten _refs
|
| 634 |
+
const flattenRef = (zodSchema, params) => {
|
| 635 |
+
const seen = this.seen.get(zodSchema);
|
| 636 |
+
const schema = seen.def ?? seen.schema;
|
| 637 |
+
const _cached = { ...schema };
|
| 638 |
+
// already seen
|
| 639 |
+
if (seen.ref === null) {
|
| 640 |
+
return;
|
| 641 |
+
}
|
| 642 |
+
// flatten ref if defined
|
| 643 |
+
const ref = seen.ref;
|
| 644 |
+
seen.ref = null; // prevent recursion
|
| 645 |
+
if (ref) {
|
| 646 |
+
flattenRef(ref, params);
|
| 647 |
+
// merge referenced schema into current
|
| 648 |
+
const refSchema = this.seen.get(ref).schema;
|
| 649 |
+
if (refSchema.$ref && params.target === "draft-7") {
|
| 650 |
+
schema.allOf = schema.allOf ?? [];
|
| 651 |
+
schema.allOf.push(refSchema);
|
| 652 |
+
}
|
| 653 |
+
else {
|
| 654 |
+
Object.assign(schema, refSchema);
|
| 655 |
+
Object.assign(schema, _cached); // prevent overwriting any fields in the original schema
|
| 656 |
+
}
|
| 657 |
+
}
|
| 658 |
+
// execute overrides
|
| 659 |
+
if (!seen.isParent)
|
| 660 |
+
this.override({
|
| 661 |
+
zodSchema: zodSchema,
|
| 662 |
+
jsonSchema: schema,
|
| 663 |
+
path: seen.path ?? [],
|
| 664 |
+
});
|
| 665 |
+
};
|
| 666 |
+
for (const entry of [...this.seen.entries()].reverse()) {
|
| 667 |
+
flattenRef(entry[0], { target: this.target });
|
| 668 |
+
}
|
| 669 |
+
const result = {};
|
| 670 |
+
if (this.target === "draft-2020-12") {
|
| 671 |
+
result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
| 672 |
+
}
|
| 673 |
+
else if (this.target === "draft-7") {
|
| 674 |
+
result.$schema = "http://json-schema.org/draft-07/schema#";
|
| 675 |
+
}
|
| 676 |
+
else {
|
| 677 |
+
console.warn(`Invalid target: ${this.target}`);
|
| 678 |
+
}
|
| 679 |
+
if (params.external?.uri) {
|
| 680 |
+
const id = params.external.registry.get(schema)?.id;
|
| 681 |
+
if (!id)
|
| 682 |
+
throw new Error("Schema is missing an `id` property");
|
| 683 |
+
result.$id = params.external.uri(id);
|
| 684 |
+
}
|
| 685 |
+
Object.assign(result, root.def);
|
| 686 |
+
// build defs object
|
| 687 |
+
const defs = params.external?.defs ?? {};
|
| 688 |
+
for (const entry of this.seen.entries()) {
|
| 689 |
+
const seen = entry[1];
|
| 690 |
+
if (seen.def && seen.defId) {
|
| 691 |
+
defs[seen.defId] = seen.def;
|
| 692 |
+
}
|
| 693 |
+
}
|
| 694 |
+
// set definitions in result
|
| 695 |
+
if (params.external) {
|
| 696 |
+
}
|
| 697 |
+
else {
|
| 698 |
+
if (Object.keys(defs).length > 0) {
|
| 699 |
+
if (this.target === "draft-2020-12") {
|
| 700 |
+
result.$defs = defs;
|
| 701 |
+
}
|
| 702 |
+
else {
|
| 703 |
+
result.definitions = defs;
|
| 704 |
+
}
|
| 705 |
+
}
|
| 706 |
+
}
|
| 707 |
+
try {
|
| 708 |
+
// this "finalizes" this schema and ensures all cycles are removed
|
| 709 |
+
// each call to .emit() is functionally independent
|
| 710 |
+
// though the seen map is shared
|
| 711 |
+
return JSON.parse(JSON.stringify(result));
|
| 712 |
+
}
|
| 713 |
+
catch (_err) {
|
| 714 |
+
throw new Error("Error converting schema to JSON.");
|
| 715 |
+
}
|
| 716 |
+
}
|
| 717 |
+
}
|
| 718 |
+
export function toJSONSchema(input, _params) {
|
| 719 |
+
if (input instanceof $ZodRegistry) {
|
| 720 |
+
const gen = new JSONSchemaGenerator(_params);
|
| 721 |
+
const defs = {};
|
| 722 |
+
for (const entry of input._idmap.entries()) {
|
| 723 |
+
const [_, schema] = entry;
|
| 724 |
+
gen.process(schema);
|
| 725 |
+
}
|
| 726 |
+
const schemas = {};
|
| 727 |
+
const external = {
|
| 728 |
+
registry: input,
|
| 729 |
+
uri: _params?.uri,
|
| 730 |
+
defs,
|
| 731 |
+
};
|
| 732 |
+
for (const entry of input._idmap.entries()) {
|
| 733 |
+
const [key, schema] = entry;
|
| 734 |
+
schemas[key] = gen.emit(schema, {
|
| 735 |
+
..._params,
|
| 736 |
+
external,
|
| 737 |
+
});
|
| 738 |
+
}
|
| 739 |
+
if (Object.keys(defs).length > 0) {
|
| 740 |
+
const defsSegment = gen.target === "draft-2020-12" ? "$defs" : "definitions";
|
| 741 |
+
schemas.__shared = {
|
| 742 |
+
[defsSegment]: defs,
|
| 743 |
+
};
|
| 744 |
+
}
|
| 745 |
+
return { schemas };
|
| 746 |
+
}
|
| 747 |
+
const gen = new JSONSchemaGenerator(_params);
|
| 748 |
+
gen.process(input);
|
| 749 |
+
return gen.emit(input, _params);
|
| 750 |
+
}
|
| 751 |
+
function isTransforming(_schema, _ctx) {
|
| 752 |
+
const ctx = _ctx ?? { seen: new Set() };
|
| 753 |
+
if (ctx.seen.has(_schema))
|
| 754 |
+
return false;
|
| 755 |
+
ctx.seen.add(_schema);
|
| 756 |
+
const schema = _schema;
|
| 757 |
+
const def = schema._zod.def;
|
| 758 |
+
switch (def.type) {
|
| 759 |
+
case "string":
|
| 760 |
+
case "number":
|
| 761 |
+
case "bigint":
|
| 762 |
+
case "boolean":
|
| 763 |
+
case "date":
|
| 764 |
+
case "symbol":
|
| 765 |
+
case "undefined":
|
| 766 |
+
case "null":
|
| 767 |
+
case "any":
|
| 768 |
+
case "unknown":
|
| 769 |
+
case "never":
|
| 770 |
+
case "void":
|
| 771 |
+
case "literal":
|
| 772 |
+
case "enum":
|
| 773 |
+
case "nan":
|
| 774 |
+
case "file":
|
| 775 |
+
case "template_literal":
|
| 776 |
+
return false;
|
| 777 |
+
case "array": {
|
| 778 |
+
return isTransforming(def.element, ctx);
|
| 779 |
+
}
|
| 780 |
+
case "object": {
|
| 781 |
+
for (const key in def.shape) {
|
| 782 |
+
if (isTransforming(def.shape[key], ctx))
|
| 783 |
+
return true;
|
| 784 |
+
}
|
| 785 |
+
return false;
|
| 786 |
+
}
|
| 787 |
+
case "union": {
|
| 788 |
+
for (const option of def.options) {
|
| 789 |
+
if (isTransforming(option, ctx))
|
| 790 |
+
return true;
|
| 791 |
+
}
|
| 792 |
+
return false;
|
| 793 |
+
}
|
| 794 |
+
case "intersection": {
|
| 795 |
+
return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
| 796 |
+
}
|
| 797 |
+
case "tuple": {
|
| 798 |
+
for (const item of def.items) {
|
| 799 |
+
if (isTransforming(item, ctx))
|
| 800 |
+
return true;
|
| 801 |
+
}
|
| 802 |
+
if (def.rest && isTransforming(def.rest, ctx))
|
| 803 |
+
return true;
|
| 804 |
+
return false;
|
| 805 |
+
}
|
| 806 |
+
case "record": {
|
| 807 |
+
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
| 808 |
+
}
|
| 809 |
+
case "map": {
|
| 810 |
+
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
| 811 |
+
}
|
| 812 |
+
case "set": {
|
| 813 |
+
return isTransforming(def.valueType, ctx);
|
| 814 |
+
}
|
| 815 |
+
// inner types
|
| 816 |
+
case "promise":
|
| 817 |
+
case "optional":
|
| 818 |
+
case "nonoptional":
|
| 819 |
+
case "nullable":
|
| 820 |
+
case "readonly":
|
| 821 |
+
return isTransforming(def.innerType, ctx);
|
| 822 |
+
case "lazy":
|
| 823 |
+
return isTransforming(def.getter(), ctx);
|
| 824 |
+
case "default": {
|
| 825 |
+
return isTransforming(def.innerType, ctx);
|
| 826 |
+
}
|
| 827 |
+
case "prefault": {
|
| 828 |
+
return isTransforming(def.innerType, ctx);
|
| 829 |
+
}
|
| 830 |
+
case "custom": {
|
| 831 |
+
return false;
|
| 832 |
+
}
|
| 833 |
+
case "transform": {
|
| 834 |
+
return true;
|
| 835 |
+
}
|
| 836 |
+
case "pipe": {
|
| 837 |
+
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
| 838 |
+
}
|
| 839 |
+
case "success": {
|
| 840 |
+
return false;
|
| 841 |
+
}
|
| 842 |
+
case "catch": {
|
| 843 |
+
return false;
|
| 844 |
+
}
|
| 845 |
+
default:
|
| 846 |
+
def;
|
| 847 |
+
}
|
| 848 |
+
throw new Error(`Unknown schema type: ${def.type}`);
|
| 849 |
+
}
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/util.cjs
ADDED
|
@@ -0,0 +1,539 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.Class = exports.BIGINT_FORMAT_RANGES = exports.NUMBER_FORMAT_RANGES = exports.primitiveTypes = exports.propertyKeyTypes = exports.getParsedType = exports.allowsEval = exports.captureStackTrace = void 0;
|
| 4 |
+
exports.assertEqual = assertEqual;
|
| 5 |
+
exports.assertNotEqual = assertNotEqual;
|
| 6 |
+
exports.assertIs = assertIs;
|
| 7 |
+
exports.assertNever = assertNever;
|
| 8 |
+
exports.assert = assert;
|
| 9 |
+
exports.getEnumValues = getEnumValues;
|
| 10 |
+
exports.joinValues = joinValues;
|
| 11 |
+
exports.jsonStringifyReplacer = jsonStringifyReplacer;
|
| 12 |
+
exports.cached = cached;
|
| 13 |
+
exports.nullish = nullish;
|
| 14 |
+
exports.cleanRegex = cleanRegex;
|
| 15 |
+
exports.floatSafeRemainder = floatSafeRemainder;
|
| 16 |
+
exports.defineLazy = defineLazy;
|
| 17 |
+
exports.assignProp = assignProp;
|
| 18 |
+
exports.getElementAtPath = getElementAtPath;
|
| 19 |
+
exports.promiseAllObject = promiseAllObject;
|
| 20 |
+
exports.randomString = randomString;
|
| 21 |
+
exports.esc = esc;
|
| 22 |
+
exports.isObject = isObject;
|
| 23 |
+
exports.isPlainObject = isPlainObject;
|
| 24 |
+
exports.numKeys = numKeys;
|
| 25 |
+
exports.escapeRegex = escapeRegex;
|
| 26 |
+
exports.clone = clone;
|
| 27 |
+
exports.normalizeParams = normalizeParams;
|
| 28 |
+
exports.createTransparentProxy = createTransparentProxy;
|
| 29 |
+
exports.stringifyPrimitive = stringifyPrimitive;
|
| 30 |
+
exports.optionalKeys = optionalKeys;
|
| 31 |
+
exports.pick = pick;
|
| 32 |
+
exports.omit = omit;
|
| 33 |
+
exports.extend = extend;
|
| 34 |
+
exports.merge = merge;
|
| 35 |
+
exports.partial = partial;
|
| 36 |
+
exports.required = required;
|
| 37 |
+
exports.aborted = aborted;
|
| 38 |
+
exports.prefixIssues = prefixIssues;
|
| 39 |
+
exports.unwrapMessage = unwrapMessage;
|
| 40 |
+
exports.finalizeIssue = finalizeIssue;
|
| 41 |
+
exports.getSizableOrigin = getSizableOrigin;
|
| 42 |
+
exports.getLengthableOrigin = getLengthableOrigin;
|
| 43 |
+
exports.issue = issue;
|
| 44 |
+
exports.cleanEnum = cleanEnum;
|
| 45 |
+
// functions
|
| 46 |
+
function assertEqual(val) {
|
| 47 |
+
return val;
|
| 48 |
+
}
|
| 49 |
+
function assertNotEqual(val) {
|
| 50 |
+
return val;
|
| 51 |
+
}
|
| 52 |
+
function assertIs(_arg) { }
|
| 53 |
+
function assertNever(_x) {
|
| 54 |
+
throw new Error();
|
| 55 |
+
}
|
| 56 |
+
function assert(_) { }
|
| 57 |
+
function getEnumValues(entries) {
|
| 58 |
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
| 59 |
+
const values = Object.entries(entries)
|
| 60 |
+
.filter(([k, _]) => numericValues.indexOf(+k) === -1)
|
| 61 |
+
.map(([_, v]) => v);
|
| 62 |
+
return values;
|
| 63 |
+
}
|
| 64 |
+
function joinValues(array, separator = "|") {
|
| 65 |
+
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
| 66 |
+
}
|
| 67 |
+
function jsonStringifyReplacer(_, value) {
|
| 68 |
+
if (typeof value === "bigint")
|
| 69 |
+
return value.toString();
|
| 70 |
+
return value;
|
| 71 |
+
}
|
| 72 |
+
function cached(getter) {
|
| 73 |
+
const set = false;
|
| 74 |
+
return {
|
| 75 |
+
get value() {
|
| 76 |
+
if (!set) {
|
| 77 |
+
const value = getter();
|
| 78 |
+
Object.defineProperty(this, "value", { value });
|
| 79 |
+
return value;
|
| 80 |
+
}
|
| 81 |
+
throw new Error("cached value already set");
|
| 82 |
+
},
|
| 83 |
+
};
|
| 84 |
+
}
|
| 85 |
+
function nullish(input) {
|
| 86 |
+
return input === null || input === undefined;
|
| 87 |
+
}
|
| 88 |
+
function cleanRegex(source) {
|
| 89 |
+
const start = source.startsWith("^") ? 1 : 0;
|
| 90 |
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
| 91 |
+
return source.slice(start, end);
|
| 92 |
+
}
|
| 93 |
+
function floatSafeRemainder(val, step) {
|
| 94 |
+
const valDecCount = (val.toString().split(".")[1] || "").length;
|
| 95 |
+
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
| 96 |
+
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
| 97 |
+
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
| 98 |
+
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
| 99 |
+
return (valInt % stepInt) / 10 ** decCount;
|
| 100 |
+
}
|
| 101 |
+
function defineLazy(object, key, getter) {
|
| 102 |
+
const set = false;
|
| 103 |
+
Object.defineProperty(object, key, {
|
| 104 |
+
get() {
|
| 105 |
+
if (!set) {
|
| 106 |
+
const value = getter();
|
| 107 |
+
object[key] = value;
|
| 108 |
+
return value;
|
| 109 |
+
}
|
| 110 |
+
throw new Error("cached value already set");
|
| 111 |
+
},
|
| 112 |
+
set(v) {
|
| 113 |
+
Object.defineProperty(object, key, {
|
| 114 |
+
value: v,
|
| 115 |
+
// configurable: true,
|
| 116 |
+
});
|
| 117 |
+
// object[key] = v;
|
| 118 |
+
},
|
| 119 |
+
configurable: true,
|
| 120 |
+
});
|
| 121 |
+
}
|
| 122 |
+
function assignProp(target, prop, value) {
|
| 123 |
+
Object.defineProperty(target, prop, {
|
| 124 |
+
value,
|
| 125 |
+
writable: true,
|
| 126 |
+
enumerable: true,
|
| 127 |
+
configurable: true,
|
| 128 |
+
});
|
| 129 |
+
}
|
| 130 |
+
function getElementAtPath(obj, path) {
|
| 131 |
+
if (!path)
|
| 132 |
+
return obj;
|
| 133 |
+
return path.reduce((acc, key) => acc?.[key], obj);
|
| 134 |
+
}
|
| 135 |
+
function promiseAllObject(promisesObj) {
|
| 136 |
+
const keys = Object.keys(promisesObj);
|
| 137 |
+
const promises = keys.map((key) => promisesObj[key]);
|
| 138 |
+
return Promise.all(promises).then((results) => {
|
| 139 |
+
const resolvedObj = {};
|
| 140 |
+
for (let i = 0; i < keys.length; i++) {
|
| 141 |
+
resolvedObj[keys[i]] = results[i];
|
| 142 |
+
}
|
| 143 |
+
return resolvedObj;
|
| 144 |
+
});
|
| 145 |
+
}
|
| 146 |
+
function randomString(length = 10) {
|
| 147 |
+
const chars = "abcdefghijklmnopqrstuvwxyz";
|
| 148 |
+
let str = "";
|
| 149 |
+
for (let i = 0; i < length; i++) {
|
| 150 |
+
str += chars[Math.floor(Math.random() * chars.length)];
|
| 151 |
+
}
|
| 152 |
+
return str;
|
| 153 |
+
}
|
| 154 |
+
function esc(str) {
|
| 155 |
+
return JSON.stringify(str);
|
| 156 |
+
}
|
| 157 |
+
exports.captureStackTrace = Error.captureStackTrace
|
| 158 |
+
? Error.captureStackTrace
|
| 159 |
+
: (..._args) => { };
|
| 160 |
+
function isObject(data) {
|
| 161 |
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
| 162 |
+
}
|
| 163 |
+
exports.allowsEval = cached(() => {
|
| 164 |
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
| 165 |
+
return false;
|
| 166 |
+
}
|
| 167 |
+
try {
|
| 168 |
+
const F = Function;
|
| 169 |
+
new F("");
|
| 170 |
+
return true;
|
| 171 |
+
}
|
| 172 |
+
catch (_) {
|
| 173 |
+
return false;
|
| 174 |
+
}
|
| 175 |
+
});
|
| 176 |
+
function isPlainObject(o) {
|
| 177 |
+
if (isObject(o) === false)
|
| 178 |
+
return false;
|
| 179 |
+
// modified constructor
|
| 180 |
+
const ctor = o.constructor;
|
| 181 |
+
if (ctor === undefined)
|
| 182 |
+
return true;
|
| 183 |
+
// modified prototype
|
| 184 |
+
const prot = ctor.prototype;
|
| 185 |
+
if (isObject(prot) === false)
|
| 186 |
+
return false;
|
| 187 |
+
// ctor doesn't have static `isPrototypeOf`
|
| 188 |
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
| 189 |
+
return false;
|
| 190 |
+
}
|
| 191 |
+
return true;
|
| 192 |
+
}
|
| 193 |
+
function numKeys(data) {
|
| 194 |
+
let keyCount = 0;
|
| 195 |
+
for (const key in data) {
|
| 196 |
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
| 197 |
+
keyCount++;
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
return keyCount;
|
| 201 |
+
}
|
| 202 |
+
const getParsedType = (data) => {
|
| 203 |
+
const t = typeof data;
|
| 204 |
+
switch (t) {
|
| 205 |
+
case "undefined":
|
| 206 |
+
return "undefined";
|
| 207 |
+
case "string":
|
| 208 |
+
return "string";
|
| 209 |
+
case "number":
|
| 210 |
+
return Number.isNaN(data) ? "nan" : "number";
|
| 211 |
+
case "boolean":
|
| 212 |
+
return "boolean";
|
| 213 |
+
case "function":
|
| 214 |
+
return "function";
|
| 215 |
+
case "bigint":
|
| 216 |
+
return "bigint";
|
| 217 |
+
case "symbol":
|
| 218 |
+
return "symbol";
|
| 219 |
+
case "object":
|
| 220 |
+
if (Array.isArray(data)) {
|
| 221 |
+
return "array";
|
| 222 |
+
}
|
| 223 |
+
if (data === null) {
|
| 224 |
+
return "null";
|
| 225 |
+
}
|
| 226 |
+
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
| 227 |
+
return "promise";
|
| 228 |
+
}
|
| 229 |
+
if (typeof Map !== "undefined" && data instanceof Map) {
|
| 230 |
+
return "map";
|
| 231 |
+
}
|
| 232 |
+
if (typeof Set !== "undefined" && data instanceof Set) {
|
| 233 |
+
return "set";
|
| 234 |
+
}
|
| 235 |
+
if (typeof Date !== "undefined" && data instanceof Date) {
|
| 236 |
+
return "date";
|
| 237 |
+
}
|
| 238 |
+
if (typeof File !== "undefined" && data instanceof File) {
|
| 239 |
+
return "file";
|
| 240 |
+
}
|
| 241 |
+
return "object";
|
| 242 |
+
default:
|
| 243 |
+
throw new Error(`Unknown data type: ${t}`);
|
| 244 |
+
}
|
| 245 |
+
};
|
| 246 |
+
exports.getParsedType = getParsedType;
|
| 247 |
+
exports.propertyKeyTypes = new Set(["string", "number", "symbol"]);
|
| 248 |
+
exports.primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
|
| 249 |
+
function escapeRegex(str) {
|
| 250 |
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
| 251 |
+
}
|
| 252 |
+
// zod-specific utils
|
| 253 |
+
function clone(inst, def, params) {
|
| 254 |
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
| 255 |
+
if (!def || params?.parent)
|
| 256 |
+
cl._zod.parent = inst;
|
| 257 |
+
return cl;
|
| 258 |
+
}
|
| 259 |
+
function normalizeParams(_params) {
|
| 260 |
+
const params = _params;
|
| 261 |
+
if (!params)
|
| 262 |
+
return {};
|
| 263 |
+
if (typeof params === "string")
|
| 264 |
+
return { error: () => params };
|
| 265 |
+
if (params?.message !== undefined) {
|
| 266 |
+
if (params?.error !== undefined)
|
| 267 |
+
throw new Error("Cannot specify both `message` and `error` params");
|
| 268 |
+
params.error = params.message;
|
| 269 |
+
}
|
| 270 |
+
delete params.message;
|
| 271 |
+
if (typeof params.error === "string")
|
| 272 |
+
return { ...params, error: () => params.error };
|
| 273 |
+
return params;
|
| 274 |
+
}
|
| 275 |
+
function createTransparentProxy(getter) {
|
| 276 |
+
let target;
|
| 277 |
+
return new Proxy({}, {
|
| 278 |
+
get(_, prop, receiver) {
|
| 279 |
+
target ?? (target = getter());
|
| 280 |
+
return Reflect.get(target, prop, receiver);
|
| 281 |
+
},
|
| 282 |
+
set(_, prop, value, receiver) {
|
| 283 |
+
target ?? (target = getter());
|
| 284 |
+
return Reflect.set(target, prop, value, receiver);
|
| 285 |
+
},
|
| 286 |
+
has(_, prop) {
|
| 287 |
+
target ?? (target = getter());
|
| 288 |
+
return Reflect.has(target, prop);
|
| 289 |
+
},
|
| 290 |
+
deleteProperty(_, prop) {
|
| 291 |
+
target ?? (target = getter());
|
| 292 |
+
return Reflect.deleteProperty(target, prop);
|
| 293 |
+
},
|
| 294 |
+
ownKeys(_) {
|
| 295 |
+
target ?? (target = getter());
|
| 296 |
+
return Reflect.ownKeys(target);
|
| 297 |
+
},
|
| 298 |
+
getOwnPropertyDescriptor(_, prop) {
|
| 299 |
+
target ?? (target = getter());
|
| 300 |
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
| 301 |
+
},
|
| 302 |
+
defineProperty(_, prop, descriptor) {
|
| 303 |
+
target ?? (target = getter());
|
| 304 |
+
return Reflect.defineProperty(target, prop, descriptor);
|
| 305 |
+
},
|
| 306 |
+
});
|
| 307 |
+
}
|
| 308 |
+
function stringifyPrimitive(value) {
|
| 309 |
+
if (typeof value === "bigint")
|
| 310 |
+
return value.toString() + "n";
|
| 311 |
+
if (typeof value === "string")
|
| 312 |
+
return `"${value}"`;
|
| 313 |
+
return `${value}`;
|
| 314 |
+
}
|
| 315 |
+
function optionalKeys(shape) {
|
| 316 |
+
return Object.keys(shape).filter((k) => {
|
| 317 |
+
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
| 318 |
+
});
|
| 319 |
+
}
|
| 320 |
+
exports.NUMBER_FORMAT_RANGES = {
|
| 321 |
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
| 322 |
+
int32: [-2147483648, 2147483647],
|
| 323 |
+
uint32: [0, 4294967295],
|
| 324 |
+
float32: [-3.4028234663852886e38, 3.4028234663852886e38],
|
| 325 |
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE],
|
| 326 |
+
};
|
| 327 |
+
exports.BIGINT_FORMAT_RANGES = {
|
| 328 |
+
int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
|
| 329 |
+
uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")],
|
| 330 |
+
};
|
| 331 |
+
function pick(schema, mask) {
|
| 332 |
+
const newShape = {};
|
| 333 |
+
const currDef = schema._zod.def; //.shape;
|
| 334 |
+
for (const key in mask) {
|
| 335 |
+
if (!(key in currDef.shape)) {
|
| 336 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 337 |
+
}
|
| 338 |
+
if (!mask[key])
|
| 339 |
+
continue;
|
| 340 |
+
// pick key
|
| 341 |
+
newShape[key] = currDef.shape[key];
|
| 342 |
+
}
|
| 343 |
+
return clone(schema, {
|
| 344 |
+
...schema._zod.def,
|
| 345 |
+
shape: newShape,
|
| 346 |
+
checks: [],
|
| 347 |
+
});
|
| 348 |
+
}
|
| 349 |
+
function omit(schema, mask) {
|
| 350 |
+
const newShape = { ...schema._zod.def.shape };
|
| 351 |
+
const currDef = schema._zod.def; //.shape;
|
| 352 |
+
for (const key in mask) {
|
| 353 |
+
if (!(key in currDef.shape)) {
|
| 354 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 355 |
+
}
|
| 356 |
+
if (!mask[key])
|
| 357 |
+
continue;
|
| 358 |
+
delete newShape[key];
|
| 359 |
+
}
|
| 360 |
+
return clone(schema, {
|
| 361 |
+
...schema._zod.def,
|
| 362 |
+
shape: newShape,
|
| 363 |
+
checks: [],
|
| 364 |
+
});
|
| 365 |
+
}
|
| 366 |
+
function extend(schema, shape) {
|
| 367 |
+
if (!isPlainObject(shape)) {
|
| 368 |
+
throw new Error("Invalid input to extend: expected a plain object");
|
| 369 |
+
}
|
| 370 |
+
const def = {
|
| 371 |
+
...schema._zod.def,
|
| 372 |
+
get shape() {
|
| 373 |
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
| 374 |
+
assignProp(this, "shape", _shape); // self-caching
|
| 375 |
+
return _shape;
|
| 376 |
+
},
|
| 377 |
+
checks: [], // delete existing checks
|
| 378 |
+
};
|
| 379 |
+
return clone(schema, def);
|
| 380 |
+
}
|
| 381 |
+
function merge(a, b) {
|
| 382 |
+
return clone(a, {
|
| 383 |
+
...a._zod.def,
|
| 384 |
+
get shape() {
|
| 385 |
+
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
| 386 |
+
assignProp(this, "shape", _shape); // self-caching
|
| 387 |
+
return _shape;
|
| 388 |
+
},
|
| 389 |
+
catchall: b._zod.def.catchall,
|
| 390 |
+
checks: [], // delete existing checks
|
| 391 |
+
});
|
| 392 |
+
}
|
| 393 |
+
function partial(Class, schema, mask) {
|
| 394 |
+
const oldShape = schema._zod.def.shape;
|
| 395 |
+
const shape = { ...oldShape };
|
| 396 |
+
if (mask) {
|
| 397 |
+
for (const key in mask) {
|
| 398 |
+
if (!(key in oldShape)) {
|
| 399 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 400 |
+
}
|
| 401 |
+
if (!mask[key])
|
| 402 |
+
continue;
|
| 403 |
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
| 404 |
+
shape[key] = Class
|
| 405 |
+
? new Class({
|
| 406 |
+
type: "optional",
|
| 407 |
+
innerType: oldShape[key],
|
| 408 |
+
})
|
| 409 |
+
: oldShape[key];
|
| 410 |
+
}
|
| 411 |
+
}
|
| 412 |
+
else {
|
| 413 |
+
for (const key in oldShape) {
|
| 414 |
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
| 415 |
+
shape[key] = Class
|
| 416 |
+
? new Class({
|
| 417 |
+
type: "optional",
|
| 418 |
+
innerType: oldShape[key],
|
| 419 |
+
})
|
| 420 |
+
: oldShape[key];
|
| 421 |
+
}
|
| 422 |
+
}
|
| 423 |
+
return clone(schema, {
|
| 424 |
+
...schema._zod.def,
|
| 425 |
+
shape,
|
| 426 |
+
checks: [],
|
| 427 |
+
});
|
| 428 |
+
}
|
| 429 |
+
function required(Class, schema, mask) {
|
| 430 |
+
const oldShape = schema._zod.def.shape;
|
| 431 |
+
const shape = { ...oldShape };
|
| 432 |
+
if (mask) {
|
| 433 |
+
for (const key in mask) {
|
| 434 |
+
if (!(key in shape)) {
|
| 435 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 436 |
+
}
|
| 437 |
+
if (!mask[key])
|
| 438 |
+
continue;
|
| 439 |
+
// overwrite with non-optional
|
| 440 |
+
shape[key] = new Class({
|
| 441 |
+
type: "nonoptional",
|
| 442 |
+
innerType: oldShape[key],
|
| 443 |
+
});
|
| 444 |
+
}
|
| 445 |
+
}
|
| 446 |
+
else {
|
| 447 |
+
for (const key in oldShape) {
|
| 448 |
+
// overwrite with non-optional
|
| 449 |
+
shape[key] = new Class({
|
| 450 |
+
type: "nonoptional",
|
| 451 |
+
innerType: oldShape[key],
|
| 452 |
+
});
|
| 453 |
+
}
|
| 454 |
+
}
|
| 455 |
+
return clone(schema, {
|
| 456 |
+
...schema._zod.def,
|
| 457 |
+
shape,
|
| 458 |
+
// optional: [],
|
| 459 |
+
checks: [],
|
| 460 |
+
});
|
| 461 |
+
}
|
| 462 |
+
function aborted(x, startIndex = 0) {
|
| 463 |
+
for (let i = startIndex; i < x.issues.length; i++) {
|
| 464 |
+
if (x.issues[i]?.continue !== true)
|
| 465 |
+
return true;
|
| 466 |
+
}
|
| 467 |
+
return false;
|
| 468 |
+
}
|
| 469 |
+
function prefixIssues(path, issues) {
|
| 470 |
+
return issues.map((iss) => {
|
| 471 |
+
var _a;
|
| 472 |
+
(_a = iss).path ?? (_a.path = []);
|
| 473 |
+
iss.path.unshift(path);
|
| 474 |
+
return iss;
|
| 475 |
+
});
|
| 476 |
+
}
|
| 477 |
+
function unwrapMessage(message) {
|
| 478 |
+
return typeof message === "string" ? message : message?.message;
|
| 479 |
+
}
|
| 480 |
+
function finalizeIssue(iss, ctx, config) {
|
| 481 |
+
const full = { ...iss, path: iss.path ?? [] };
|
| 482 |
+
// for backwards compatibility
|
| 483 |
+
if (!iss.message) {
|
| 484 |
+
const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
|
| 485 |
+
unwrapMessage(ctx?.error?.(iss)) ??
|
| 486 |
+
unwrapMessage(config.customError?.(iss)) ??
|
| 487 |
+
unwrapMessage(config.localeError?.(iss)) ??
|
| 488 |
+
"Invalid input";
|
| 489 |
+
full.message = message;
|
| 490 |
+
}
|
| 491 |
+
// delete (full as any).def;
|
| 492 |
+
delete full.inst;
|
| 493 |
+
delete full.continue;
|
| 494 |
+
if (!ctx?.reportInput) {
|
| 495 |
+
delete full.input;
|
| 496 |
+
}
|
| 497 |
+
return full;
|
| 498 |
+
}
|
| 499 |
+
function getSizableOrigin(input) {
|
| 500 |
+
if (input instanceof Set)
|
| 501 |
+
return "set";
|
| 502 |
+
if (input instanceof Map)
|
| 503 |
+
return "map";
|
| 504 |
+
if (input instanceof File)
|
| 505 |
+
return "file";
|
| 506 |
+
return "unknown";
|
| 507 |
+
}
|
| 508 |
+
function getLengthableOrigin(input) {
|
| 509 |
+
if (Array.isArray(input))
|
| 510 |
+
return "array";
|
| 511 |
+
if (typeof input === "string")
|
| 512 |
+
return "string";
|
| 513 |
+
return "unknown";
|
| 514 |
+
}
|
| 515 |
+
function issue(...args) {
|
| 516 |
+
const [iss, input, inst] = args;
|
| 517 |
+
if (typeof iss === "string") {
|
| 518 |
+
return {
|
| 519 |
+
message: iss,
|
| 520 |
+
code: "custom",
|
| 521 |
+
input,
|
| 522 |
+
inst,
|
| 523 |
+
};
|
| 524 |
+
}
|
| 525 |
+
return { ...iss };
|
| 526 |
+
}
|
| 527 |
+
function cleanEnum(obj) {
|
| 528 |
+
return Object.entries(obj)
|
| 529 |
+
.filter(([k, _]) => {
|
| 530 |
+
// return true if NaN, meaning it's not a number, thus a string key
|
| 531 |
+
return Number.isNaN(Number.parseInt(k, 10));
|
| 532 |
+
})
|
| 533 |
+
.map((el) => el[1]);
|
| 534 |
+
}
|
| 535 |
+
// instanceof
|
| 536 |
+
class Class {
|
| 537 |
+
constructor(..._args) { }
|
| 538 |
+
}
|
| 539 |
+
exports.Class = Class;
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/util.d.cts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as checks from "./checks.cjs";
|
| 2 |
+
import type { $ZodConfig } from "./core.cjs";
|
| 3 |
+
import type * as errors from "./errors.cjs";
|
| 4 |
+
import type * as schemas from "./schemas.cjs";
|
| 5 |
+
export type JSONType = string | number | boolean | null | JSONType[] | {
|
| 6 |
+
[key: string]: JSONType;
|
| 7 |
+
};
|
| 8 |
+
export type JWTAlgorithm = "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | (string & {});
|
| 9 |
+
export type IPVersion = "v4" | "v6";
|
| 10 |
+
export type MimeTypes = "application/json" | "application/xml" | "application/x-www-form-urlencoded" | "application/javascript" | "application/pdf" | "application/zip" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/octet-stream" | "application/graphql" | "text/html" | "text/plain" | "text/css" | "text/javascript" | "text/csv" | "image/png" | "image/jpeg" | "image/gif" | "image/svg+xml" | "image/webp" | "audio/mpeg" | "audio/ogg" | "audio/wav" | "audio/webm" | "video/mp4" | "video/webm" | "video/ogg" | "font/woff" | "font/woff2" | "font/ttf" | "font/otf" | "multipart/form-data" | (string & {});
|
| 11 |
+
export type ParsedTypes = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "file" | "date" | "array" | "map" | "set" | "nan" | "null" | "promise";
|
| 12 |
+
export type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
|
| 13 |
+
export type AssertNotEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? false : true;
|
| 14 |
+
export type AssertExtends<T, U> = T extends U ? T : never;
|
| 15 |
+
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
| 16 |
+
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
| 17 |
+
export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
|
| 18 |
+
export type MakePartial<T, K extends keyof T> = Omit<T, K> & InexactPartial<Pick<T, K>>;
|
| 19 |
+
export type MakeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
| 20 |
+
export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
|
| 21 |
+
export type NoUndefined<T> = T extends undefined ? never : T;
|
| 22 |
+
export type Whatever = {} | undefined | null;
|
| 23 |
+
export type LoosePartial<T extends object> = InexactPartial<T> & {
|
| 24 |
+
[k: string]: unknown;
|
| 25 |
+
};
|
| 26 |
+
export type Mask<Keys extends PropertyKey> = {
|
| 27 |
+
[K in Keys]?: true;
|
| 28 |
+
};
|
| 29 |
+
export type Writeable<T> = {
|
| 30 |
+
-readonly [P in keyof T]: T[P];
|
| 31 |
+
} & {};
|
| 32 |
+
export type InexactPartial<T> = {
|
| 33 |
+
[P in keyof T]?: T[P] | undefined;
|
| 34 |
+
};
|
| 35 |
+
export type EmptyObject = Record<string, never>;
|
| 36 |
+
export type BuiltIn = (((...args: any[]) => any) | (new (...args: any[]) => any)) | {
|
| 37 |
+
readonly [Symbol.toStringTag]: string;
|
| 38 |
+
} | Date | Error | Generator | Promise<unknown> | RegExp;
|
| 39 |
+
export type MakeReadonly<T> = T extends Map<infer K, infer V> ? ReadonlyMap<K, V> : T extends Set<infer V> ? ReadonlySet<V> : T extends [infer Head, ...infer Tail] ? readonly [Head, ...Tail] : T extends Array<infer V> ? ReadonlyArray<V> : T extends BuiltIn ? T : Readonly<T>;
|
| 40 |
+
export type SomeObject = Record<PropertyKey, any>;
|
| 41 |
+
export type Identity<T> = T;
|
| 42 |
+
export type Flatten<T> = Identity<{
|
| 43 |
+
[k in keyof T]: T[k];
|
| 44 |
+
}>;
|
| 45 |
+
export type Mapped<T> = {
|
| 46 |
+
[k in keyof T]: T[k];
|
| 47 |
+
};
|
| 48 |
+
export type Prettify<T> = {
|
| 49 |
+
[K in keyof T]: T[K];
|
| 50 |
+
} & {};
|
| 51 |
+
export type NoNeverKeys<T> = {
|
| 52 |
+
[k in keyof T]: [T[k]] extends [never] ? never : k;
|
| 53 |
+
}[keyof T];
|
| 54 |
+
export type NoNever<T> = Identity<{
|
| 55 |
+
[k in NoNeverKeys<T>]: k extends keyof T ? T[k] : never;
|
| 56 |
+
}>;
|
| 57 |
+
export type Extend<A extends SomeObject, B extends SomeObject> = Flatten<keyof A & keyof B extends never ? A & B : {
|
| 58 |
+
[K in keyof A as K extends keyof B ? never : K]: A[K];
|
| 59 |
+
} & {
|
| 60 |
+
[K in keyof B]: B[K];
|
| 61 |
+
}>;
|
| 62 |
+
export type TupleItems = ReadonlyArray<schemas.SomeType>;
|
| 63 |
+
export type AnyFunc = (...args: any[]) => any;
|
| 64 |
+
export type IsProp<T, K extends keyof T> = T[K] extends AnyFunc ? never : K;
|
| 65 |
+
export type MaybeAsync<T> = T | Promise<T>;
|
| 66 |
+
export type KeyOf<T> = keyof OmitIndexSignature<T>;
|
| 67 |
+
export type OmitIndexSignature<T> = {
|
| 68 |
+
[K in keyof T as string extends K ? never : K extends string ? K : never]: T[K];
|
| 69 |
+
};
|
| 70 |
+
export type ExtractIndexSignature<T> = {
|
| 71 |
+
[K in keyof T as string extends K ? K : K extends string ? never : K]: T[K];
|
| 72 |
+
};
|
| 73 |
+
export type Keys<T extends object> = keyof OmitIndexSignature<T>;
|
| 74 |
+
export type SchemaClass<T extends schemas.SomeType> = {
|
| 75 |
+
new (def: T["_zod"]["def"]): T;
|
| 76 |
+
};
|
| 77 |
+
export type EnumValue = string | number;
|
| 78 |
+
export type EnumLike = Readonly<Record<string, EnumValue>>;
|
| 79 |
+
export type ToEnum<T extends EnumValue> = Flatten<{
|
| 80 |
+
[k in T]: k;
|
| 81 |
+
}>;
|
| 82 |
+
export type KeysEnum<T extends object> = ToEnum<Exclude<keyof T, symbol>>;
|
| 83 |
+
export type KeysArray<T extends object> = Flatten<(keyof T & string)[]>;
|
| 84 |
+
export type Literal = string | number | bigint | boolean | null | undefined;
|
| 85 |
+
export type LiteralArray = Array<Literal>;
|
| 86 |
+
export type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
| 87 |
+
export type PrimitiveArray = Array<Primitive>;
|
| 88 |
+
export type HasSize = {
|
| 89 |
+
size: number;
|
| 90 |
+
};
|
| 91 |
+
export type HasLength = {
|
| 92 |
+
length: number;
|
| 93 |
+
};
|
| 94 |
+
export type Numeric = number | bigint | Date;
|
| 95 |
+
export type SafeParseResult<T> = SafeParseSuccess<T> | SafeParseError<T>;
|
| 96 |
+
export type SafeParseSuccess<T> = {
|
| 97 |
+
success: true;
|
| 98 |
+
data: T;
|
| 99 |
+
error?: never;
|
| 100 |
+
};
|
| 101 |
+
export type SafeParseError<T> = {
|
| 102 |
+
success: false;
|
| 103 |
+
data?: never;
|
| 104 |
+
error: errors.$ZodError<T>;
|
| 105 |
+
};
|
| 106 |
+
export type PropValues = Record<string, Set<Primitive>>;
|
| 107 |
+
export type PrimitiveSet = Set<Primitive>;
|
| 108 |
+
export declare function assertEqual<A, B>(val: AssertEqual<A, B>): AssertEqual<A, B>;
|
| 109 |
+
export declare function assertNotEqual<A, B>(val: AssertNotEqual<A, B>): AssertNotEqual<A, B>;
|
| 110 |
+
export declare function assertIs<T>(_arg: T): void;
|
| 111 |
+
export declare function assertNever(_x: never): never;
|
| 112 |
+
export declare function assert<T>(_: any): asserts _ is T;
|
| 113 |
+
export declare function getEnumValues(entries: EnumLike): EnumValue[];
|
| 114 |
+
export declare function joinValues<T extends Primitive[]>(array: T, separator?: string): string;
|
| 115 |
+
export declare function jsonStringifyReplacer(_: string, value: any): any;
|
| 116 |
+
export declare function cached<T>(getter: () => T): {
|
| 117 |
+
value: T;
|
| 118 |
+
};
|
| 119 |
+
export declare function nullish(input: any): boolean;
|
| 120 |
+
export declare function cleanRegex(source: string): string;
|
| 121 |
+
export declare function floatSafeRemainder(val: number, step: number): number;
|
| 122 |
+
export declare function defineLazy<T, K extends keyof T>(object: T, key: K, getter: () => T[K]): void;
|
| 123 |
+
export declare function assignProp<T extends object, K extends PropertyKey>(target: T, prop: K, value: K extends keyof T ? T[K] : any): void;
|
| 124 |
+
export declare function getElementAtPath(obj: any, path: (string | number)[] | null | undefined): any;
|
| 125 |
+
export declare function promiseAllObject<T extends object>(promisesObj: T): Promise<{
|
| 126 |
+
[k in keyof T]: Awaited<T[k]>;
|
| 127 |
+
}>;
|
| 128 |
+
export declare function randomString(length?: number): string;
|
| 129 |
+
export declare function esc(str: string): string;
|
| 130 |
+
export declare const captureStackTrace: (targetObject: object, constructorOpt?: Function) => void;
|
| 131 |
+
export declare function isObject(data: any): data is Record<PropertyKey, unknown>;
|
| 132 |
+
export declare const allowsEval: {
|
| 133 |
+
value: boolean;
|
| 134 |
+
};
|
| 135 |
+
export declare function isPlainObject(o: any): o is Record<PropertyKey, unknown>;
|
| 136 |
+
export declare function numKeys(data: any): number;
|
| 137 |
+
export declare const getParsedType: (data: any) => ParsedTypes;
|
| 138 |
+
export declare const propertyKeyTypes: Set<string>;
|
| 139 |
+
export declare const primitiveTypes: Set<string>;
|
| 140 |
+
export declare function escapeRegex(str: string): string;
|
| 141 |
+
export declare function clone<T extends schemas.$ZodType>(inst: T, def?: T["_zod"]["def"], params?: {
|
| 142 |
+
parent: boolean;
|
| 143 |
+
}): T;
|
| 144 |
+
export type EmptyToNever<T> = keyof T extends never ? never : T;
|
| 145 |
+
export type Normalize<T> = T extends undefined ? never : T extends Record<any, any> ? Flatten<{
|
| 146 |
+
[k in keyof Omit<T, "error" | "message">]: T[k];
|
| 147 |
+
} & ("error" extends keyof T ? {
|
| 148 |
+
error?: Exclude<T["error"], string>;
|
| 149 |
+
} : unknown)> : never;
|
| 150 |
+
export declare function normalizeParams<T>(_params: T): Normalize<T>;
|
| 151 |
+
export declare function createTransparentProxy<T extends object>(getter: () => T): T;
|
| 152 |
+
export declare function stringifyPrimitive(value: any): string;
|
| 153 |
+
export declare function optionalKeys(shape: schemas.$ZodShape): string[];
|
| 154 |
+
export type CleanKey<T extends PropertyKey> = T extends `?${infer K}` ? K : T extends `${infer K}?` ? K : T;
|
| 155 |
+
export type ToCleanMap<T extends schemas.$ZodLooseShape> = {
|
| 156 |
+
[k in keyof T]: k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k;
|
| 157 |
+
};
|
| 158 |
+
export type FromCleanMap<T extends schemas.$ZodLooseShape> = {
|
| 159 |
+
[k in keyof T as k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k]: k;
|
| 160 |
+
};
|
| 161 |
+
export declare const NUMBER_FORMAT_RANGES: Record<checks.$ZodNumberFormats, [number, number]>;
|
| 162 |
+
export declare const BIGINT_FORMAT_RANGES: Record<checks.$ZodBigIntFormats, [bigint, bigint]>;
|
| 163 |
+
export declare function pick(schema: schemas.$ZodObject, mask: Record<string, unknown>): any;
|
| 164 |
+
export declare function omit(schema: schemas.$ZodObject, mask: object): any;
|
| 165 |
+
export declare function extend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any;
|
| 166 |
+
export declare function merge(a: schemas.$ZodObject, b: schemas.$ZodObject): any;
|
| 167 |
+
export declare function partial(Class: SchemaClass<schemas.$ZodOptional> | null, schema: schemas.$ZodObject, mask: object | undefined): any;
|
| 168 |
+
export declare function required(Class: SchemaClass<schemas.$ZodNonOptional>, schema: schemas.$ZodObject, mask: object | undefined): any;
|
| 169 |
+
export type Constructor<T, Def extends any[] = any[]> = new (...args: Def) => T;
|
| 170 |
+
export declare function aborted(x: schemas.ParsePayload, startIndex?: number): boolean;
|
| 171 |
+
export declare function prefixIssues(path: PropertyKey, issues: errors.$ZodRawIssue[]): errors.$ZodRawIssue[];
|
| 172 |
+
export declare function unwrapMessage(message: string | {
|
| 173 |
+
message: string;
|
| 174 |
+
} | undefined | null): string | undefined;
|
| 175 |
+
export declare function finalizeIssue(iss: errors.$ZodRawIssue, ctx: schemas.ParseContextInternal | undefined, config: $ZodConfig): errors.$ZodIssue;
|
| 176 |
+
export declare function getSizableOrigin(input: any): "set" | "map" | "file" | "unknown";
|
| 177 |
+
export declare function getLengthableOrigin(input: any): "array" | "string" | "unknown";
|
| 178 |
+
export declare function issue(_iss: string, input: any, inst: any): errors.$ZodRawIssue;
|
| 179 |
+
export declare function issue(_iss: errors.$ZodRawIssue): errors.$ZodRawIssue;
|
| 180 |
+
export declare function cleanEnum(obj: Record<string, EnumValue>): EnumValue[];
|
| 181 |
+
export declare abstract class Class {
|
| 182 |
+
constructor(..._args: any[]);
|
| 183 |
+
}
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/util.d.ts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as checks from "./checks.js";
|
| 2 |
+
import type { $ZodConfig } from "./core.js";
|
| 3 |
+
import type * as errors from "./errors.js";
|
| 4 |
+
import type * as schemas from "./schemas.js";
|
| 5 |
+
export type JSONType = string | number | boolean | null | JSONType[] | {
|
| 6 |
+
[key: string]: JSONType;
|
| 7 |
+
};
|
| 8 |
+
export type JWTAlgorithm = "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | (string & {});
|
| 9 |
+
export type IPVersion = "v4" | "v6";
|
| 10 |
+
export type MimeTypes = "application/json" | "application/xml" | "application/x-www-form-urlencoded" | "application/javascript" | "application/pdf" | "application/zip" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/octet-stream" | "application/graphql" | "text/html" | "text/plain" | "text/css" | "text/javascript" | "text/csv" | "image/png" | "image/jpeg" | "image/gif" | "image/svg+xml" | "image/webp" | "audio/mpeg" | "audio/ogg" | "audio/wav" | "audio/webm" | "video/mp4" | "video/webm" | "video/ogg" | "font/woff" | "font/woff2" | "font/ttf" | "font/otf" | "multipart/form-data" | (string & {});
|
| 11 |
+
export type ParsedTypes = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "file" | "date" | "array" | "map" | "set" | "nan" | "null" | "promise";
|
| 12 |
+
export type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
|
| 13 |
+
export type AssertNotEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? false : true;
|
| 14 |
+
export type AssertExtends<T, U> = T extends U ? T : never;
|
| 15 |
+
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
| 16 |
+
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
| 17 |
+
export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
|
| 18 |
+
export type MakePartial<T, K extends keyof T> = Omit<T, K> & InexactPartial<Pick<T, K>>;
|
| 19 |
+
export type MakeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
| 20 |
+
export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
|
| 21 |
+
export type NoUndefined<T> = T extends undefined ? never : T;
|
| 22 |
+
export type Whatever = {} | undefined | null;
|
| 23 |
+
export type LoosePartial<T extends object> = InexactPartial<T> & {
|
| 24 |
+
[k: string]: unknown;
|
| 25 |
+
};
|
| 26 |
+
export type Mask<Keys extends PropertyKey> = {
|
| 27 |
+
[K in Keys]?: true;
|
| 28 |
+
};
|
| 29 |
+
export type Writeable<T> = {
|
| 30 |
+
-readonly [P in keyof T]: T[P];
|
| 31 |
+
} & {};
|
| 32 |
+
export type InexactPartial<T> = {
|
| 33 |
+
[P in keyof T]?: T[P] | undefined;
|
| 34 |
+
};
|
| 35 |
+
export type EmptyObject = Record<string, never>;
|
| 36 |
+
export type BuiltIn = (((...args: any[]) => any) | (new (...args: any[]) => any)) | {
|
| 37 |
+
readonly [Symbol.toStringTag]: string;
|
| 38 |
+
} | Date | Error | Generator | Promise<unknown> | RegExp;
|
| 39 |
+
export type MakeReadonly<T> = T extends Map<infer K, infer V> ? ReadonlyMap<K, V> : T extends Set<infer V> ? ReadonlySet<V> : T extends [infer Head, ...infer Tail] ? readonly [Head, ...Tail] : T extends Array<infer V> ? ReadonlyArray<V> : T extends BuiltIn ? T : Readonly<T>;
|
| 40 |
+
export type SomeObject = Record<PropertyKey, any>;
|
| 41 |
+
export type Identity<T> = T;
|
| 42 |
+
export type Flatten<T> = Identity<{
|
| 43 |
+
[k in keyof T]: T[k];
|
| 44 |
+
}>;
|
| 45 |
+
export type Mapped<T> = {
|
| 46 |
+
[k in keyof T]: T[k];
|
| 47 |
+
};
|
| 48 |
+
export type Prettify<T> = {
|
| 49 |
+
[K in keyof T]: T[K];
|
| 50 |
+
} & {};
|
| 51 |
+
export type NoNeverKeys<T> = {
|
| 52 |
+
[k in keyof T]: [T[k]] extends [never] ? never : k;
|
| 53 |
+
}[keyof T];
|
| 54 |
+
export type NoNever<T> = Identity<{
|
| 55 |
+
[k in NoNeverKeys<T>]: k extends keyof T ? T[k] : never;
|
| 56 |
+
}>;
|
| 57 |
+
export type Extend<A extends SomeObject, B extends SomeObject> = Flatten<keyof A & keyof B extends never ? A & B : {
|
| 58 |
+
[K in keyof A as K extends keyof B ? never : K]: A[K];
|
| 59 |
+
} & {
|
| 60 |
+
[K in keyof B]: B[K];
|
| 61 |
+
}>;
|
| 62 |
+
export type TupleItems = ReadonlyArray<schemas.SomeType>;
|
| 63 |
+
export type AnyFunc = (...args: any[]) => any;
|
| 64 |
+
export type IsProp<T, K extends keyof T> = T[K] extends AnyFunc ? never : K;
|
| 65 |
+
export type MaybeAsync<T> = T | Promise<T>;
|
| 66 |
+
export type KeyOf<T> = keyof OmitIndexSignature<T>;
|
| 67 |
+
export type OmitIndexSignature<T> = {
|
| 68 |
+
[K in keyof T as string extends K ? never : K extends string ? K : never]: T[K];
|
| 69 |
+
};
|
| 70 |
+
export type ExtractIndexSignature<T> = {
|
| 71 |
+
[K in keyof T as string extends K ? K : K extends string ? never : K]: T[K];
|
| 72 |
+
};
|
| 73 |
+
export type Keys<T extends object> = keyof OmitIndexSignature<T>;
|
| 74 |
+
export type SchemaClass<T extends schemas.SomeType> = {
|
| 75 |
+
new (def: T["_zod"]["def"]): T;
|
| 76 |
+
};
|
| 77 |
+
export type EnumValue = string | number;
|
| 78 |
+
export type EnumLike = Readonly<Record<string, EnumValue>>;
|
| 79 |
+
export type ToEnum<T extends EnumValue> = Flatten<{
|
| 80 |
+
[k in T]: k;
|
| 81 |
+
}>;
|
| 82 |
+
export type KeysEnum<T extends object> = ToEnum<Exclude<keyof T, symbol>>;
|
| 83 |
+
export type KeysArray<T extends object> = Flatten<(keyof T & string)[]>;
|
| 84 |
+
export type Literal = string | number | bigint | boolean | null | undefined;
|
| 85 |
+
export type LiteralArray = Array<Literal>;
|
| 86 |
+
export type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
| 87 |
+
export type PrimitiveArray = Array<Primitive>;
|
| 88 |
+
export type HasSize = {
|
| 89 |
+
size: number;
|
| 90 |
+
};
|
| 91 |
+
export type HasLength = {
|
| 92 |
+
length: number;
|
| 93 |
+
};
|
| 94 |
+
export type Numeric = number | bigint | Date;
|
| 95 |
+
export type SafeParseResult<T> = SafeParseSuccess<T> | SafeParseError<T>;
|
| 96 |
+
export type SafeParseSuccess<T> = {
|
| 97 |
+
success: true;
|
| 98 |
+
data: T;
|
| 99 |
+
error?: never;
|
| 100 |
+
};
|
| 101 |
+
export type SafeParseError<T> = {
|
| 102 |
+
success: false;
|
| 103 |
+
data?: never;
|
| 104 |
+
error: errors.$ZodError<T>;
|
| 105 |
+
};
|
| 106 |
+
export type PropValues = Record<string, Set<Primitive>>;
|
| 107 |
+
export type PrimitiveSet = Set<Primitive>;
|
| 108 |
+
export declare function assertEqual<A, B>(val: AssertEqual<A, B>): AssertEqual<A, B>;
|
| 109 |
+
export declare function assertNotEqual<A, B>(val: AssertNotEqual<A, B>): AssertNotEqual<A, B>;
|
| 110 |
+
export declare function assertIs<T>(_arg: T): void;
|
| 111 |
+
export declare function assertNever(_x: never): never;
|
| 112 |
+
export declare function assert<T>(_: any): asserts _ is T;
|
| 113 |
+
export declare function getEnumValues(entries: EnumLike): EnumValue[];
|
| 114 |
+
export declare function joinValues<T extends Primitive[]>(array: T, separator?: string): string;
|
| 115 |
+
export declare function jsonStringifyReplacer(_: string, value: any): any;
|
| 116 |
+
export declare function cached<T>(getter: () => T): {
|
| 117 |
+
value: T;
|
| 118 |
+
};
|
| 119 |
+
export declare function nullish(input: any): boolean;
|
| 120 |
+
export declare function cleanRegex(source: string): string;
|
| 121 |
+
export declare function floatSafeRemainder(val: number, step: number): number;
|
| 122 |
+
export declare function defineLazy<T, K extends keyof T>(object: T, key: K, getter: () => T[K]): void;
|
| 123 |
+
export declare function assignProp<T extends object, K extends PropertyKey>(target: T, prop: K, value: K extends keyof T ? T[K] : any): void;
|
| 124 |
+
export declare function getElementAtPath(obj: any, path: (string | number)[] | null | undefined): any;
|
| 125 |
+
export declare function promiseAllObject<T extends object>(promisesObj: T): Promise<{
|
| 126 |
+
[k in keyof T]: Awaited<T[k]>;
|
| 127 |
+
}>;
|
| 128 |
+
export declare function randomString(length?: number): string;
|
| 129 |
+
export declare function esc(str: string): string;
|
| 130 |
+
export declare const captureStackTrace: (targetObject: object, constructorOpt?: Function) => void;
|
| 131 |
+
export declare function isObject(data: any): data is Record<PropertyKey, unknown>;
|
| 132 |
+
export declare const allowsEval: {
|
| 133 |
+
value: boolean;
|
| 134 |
+
};
|
| 135 |
+
export declare function isPlainObject(o: any): o is Record<PropertyKey, unknown>;
|
| 136 |
+
export declare function numKeys(data: any): number;
|
| 137 |
+
export declare const getParsedType: (data: any) => ParsedTypes;
|
| 138 |
+
export declare const propertyKeyTypes: Set<string>;
|
| 139 |
+
export declare const primitiveTypes: Set<string>;
|
| 140 |
+
export declare function escapeRegex(str: string): string;
|
| 141 |
+
export declare function clone<T extends schemas.$ZodType>(inst: T, def?: T["_zod"]["def"], params?: {
|
| 142 |
+
parent: boolean;
|
| 143 |
+
}): T;
|
| 144 |
+
export type EmptyToNever<T> = keyof T extends never ? never : T;
|
| 145 |
+
export type Normalize<T> = T extends undefined ? never : T extends Record<any, any> ? Flatten<{
|
| 146 |
+
[k in keyof Omit<T, "error" | "message">]: T[k];
|
| 147 |
+
} & ("error" extends keyof T ? {
|
| 148 |
+
error?: Exclude<T["error"], string>;
|
| 149 |
+
} : unknown)> : never;
|
| 150 |
+
export declare function normalizeParams<T>(_params: T): Normalize<T>;
|
| 151 |
+
export declare function createTransparentProxy<T extends object>(getter: () => T): T;
|
| 152 |
+
export declare function stringifyPrimitive(value: any): string;
|
| 153 |
+
export declare function optionalKeys(shape: schemas.$ZodShape): string[];
|
| 154 |
+
export type CleanKey<T extends PropertyKey> = T extends `?${infer K}` ? K : T extends `${infer K}?` ? K : T;
|
| 155 |
+
export type ToCleanMap<T extends schemas.$ZodLooseShape> = {
|
| 156 |
+
[k in keyof T]: k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k;
|
| 157 |
+
};
|
| 158 |
+
export type FromCleanMap<T extends schemas.$ZodLooseShape> = {
|
| 159 |
+
[k in keyof T as k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k]: k;
|
| 160 |
+
};
|
| 161 |
+
export declare const NUMBER_FORMAT_RANGES: Record<checks.$ZodNumberFormats, [number, number]>;
|
| 162 |
+
export declare const BIGINT_FORMAT_RANGES: Record<checks.$ZodBigIntFormats, [bigint, bigint]>;
|
| 163 |
+
export declare function pick(schema: schemas.$ZodObject, mask: Record<string, unknown>): any;
|
| 164 |
+
export declare function omit(schema: schemas.$ZodObject, mask: object): any;
|
| 165 |
+
export declare function extend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any;
|
| 166 |
+
export declare function merge(a: schemas.$ZodObject, b: schemas.$ZodObject): any;
|
| 167 |
+
export declare function partial(Class: SchemaClass<schemas.$ZodOptional> | null, schema: schemas.$ZodObject, mask: object | undefined): any;
|
| 168 |
+
export declare function required(Class: SchemaClass<schemas.$ZodNonOptional>, schema: schemas.$ZodObject, mask: object | undefined): any;
|
| 169 |
+
export type Constructor<T, Def extends any[] = any[]> = new (...args: Def) => T;
|
| 170 |
+
export declare function aborted(x: schemas.ParsePayload, startIndex?: number): boolean;
|
| 171 |
+
export declare function prefixIssues(path: PropertyKey, issues: errors.$ZodRawIssue[]): errors.$ZodRawIssue[];
|
| 172 |
+
export declare function unwrapMessage(message: string | {
|
| 173 |
+
message: string;
|
| 174 |
+
} | undefined | null): string | undefined;
|
| 175 |
+
export declare function finalizeIssue(iss: errors.$ZodRawIssue, ctx: schemas.ParseContextInternal | undefined, config: $ZodConfig): errors.$ZodIssue;
|
| 176 |
+
export declare function getSizableOrigin(input: any): "set" | "map" | "file" | "unknown";
|
| 177 |
+
export declare function getLengthableOrigin(input: any): "array" | "string" | "unknown";
|
| 178 |
+
export declare function issue(_iss: string, input: any, inst: any): errors.$ZodRawIssue;
|
| 179 |
+
export declare function issue(_iss: errors.$ZodRawIssue): errors.$ZodRawIssue;
|
| 180 |
+
export declare function cleanEnum(obj: Record<string, EnumValue>): EnumValue[];
|
| 181 |
+
export declare abstract class Class {
|
| 182 |
+
constructor(..._args: any[]);
|
| 183 |
+
}
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/util.js
ADDED
|
@@ -0,0 +1,493 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// functions
|
| 2 |
+
export function assertEqual(val) {
|
| 3 |
+
return val;
|
| 4 |
+
}
|
| 5 |
+
export function assertNotEqual(val) {
|
| 6 |
+
return val;
|
| 7 |
+
}
|
| 8 |
+
export function assertIs(_arg) { }
|
| 9 |
+
export function assertNever(_x) {
|
| 10 |
+
throw new Error();
|
| 11 |
+
}
|
| 12 |
+
export function assert(_) { }
|
| 13 |
+
export function getEnumValues(entries) {
|
| 14 |
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
| 15 |
+
const values = Object.entries(entries)
|
| 16 |
+
.filter(([k, _]) => numericValues.indexOf(+k) === -1)
|
| 17 |
+
.map(([_, v]) => v);
|
| 18 |
+
return values;
|
| 19 |
+
}
|
| 20 |
+
export function joinValues(array, separator = "|") {
|
| 21 |
+
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
| 22 |
+
}
|
| 23 |
+
export function jsonStringifyReplacer(_, value) {
|
| 24 |
+
if (typeof value === "bigint")
|
| 25 |
+
return value.toString();
|
| 26 |
+
return value;
|
| 27 |
+
}
|
| 28 |
+
export function cached(getter) {
|
| 29 |
+
const set = false;
|
| 30 |
+
return {
|
| 31 |
+
get value() {
|
| 32 |
+
if (!set) {
|
| 33 |
+
const value = getter();
|
| 34 |
+
Object.defineProperty(this, "value", { value });
|
| 35 |
+
return value;
|
| 36 |
+
}
|
| 37 |
+
throw new Error("cached value already set");
|
| 38 |
+
},
|
| 39 |
+
};
|
| 40 |
+
}
|
| 41 |
+
export function nullish(input) {
|
| 42 |
+
return input === null || input === undefined;
|
| 43 |
+
}
|
| 44 |
+
export function cleanRegex(source) {
|
| 45 |
+
const start = source.startsWith("^") ? 1 : 0;
|
| 46 |
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
| 47 |
+
return source.slice(start, end);
|
| 48 |
+
}
|
| 49 |
+
export function floatSafeRemainder(val, step) {
|
| 50 |
+
const valDecCount = (val.toString().split(".")[1] || "").length;
|
| 51 |
+
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
| 52 |
+
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
| 53 |
+
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
| 54 |
+
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
| 55 |
+
return (valInt % stepInt) / 10 ** decCount;
|
| 56 |
+
}
|
| 57 |
+
export function defineLazy(object, key, getter) {
|
| 58 |
+
const set = false;
|
| 59 |
+
Object.defineProperty(object, key, {
|
| 60 |
+
get() {
|
| 61 |
+
if (!set) {
|
| 62 |
+
const value = getter();
|
| 63 |
+
object[key] = value;
|
| 64 |
+
return value;
|
| 65 |
+
}
|
| 66 |
+
throw new Error("cached value already set");
|
| 67 |
+
},
|
| 68 |
+
set(v) {
|
| 69 |
+
Object.defineProperty(object, key, {
|
| 70 |
+
value: v,
|
| 71 |
+
// configurable: true,
|
| 72 |
+
});
|
| 73 |
+
// object[key] = v;
|
| 74 |
+
},
|
| 75 |
+
configurable: true,
|
| 76 |
+
});
|
| 77 |
+
}
|
| 78 |
+
export function assignProp(target, prop, value) {
|
| 79 |
+
Object.defineProperty(target, prop, {
|
| 80 |
+
value,
|
| 81 |
+
writable: true,
|
| 82 |
+
enumerable: true,
|
| 83 |
+
configurable: true,
|
| 84 |
+
});
|
| 85 |
+
}
|
| 86 |
+
export function getElementAtPath(obj, path) {
|
| 87 |
+
if (!path)
|
| 88 |
+
return obj;
|
| 89 |
+
return path.reduce((acc, key) => acc?.[key], obj);
|
| 90 |
+
}
|
| 91 |
+
export function promiseAllObject(promisesObj) {
|
| 92 |
+
const keys = Object.keys(promisesObj);
|
| 93 |
+
const promises = keys.map((key) => promisesObj[key]);
|
| 94 |
+
return Promise.all(promises).then((results) => {
|
| 95 |
+
const resolvedObj = {};
|
| 96 |
+
for (let i = 0; i < keys.length; i++) {
|
| 97 |
+
resolvedObj[keys[i]] = results[i];
|
| 98 |
+
}
|
| 99 |
+
return resolvedObj;
|
| 100 |
+
});
|
| 101 |
+
}
|
| 102 |
+
export function randomString(length = 10) {
|
| 103 |
+
const chars = "abcdefghijklmnopqrstuvwxyz";
|
| 104 |
+
let str = "";
|
| 105 |
+
for (let i = 0; i < length; i++) {
|
| 106 |
+
str += chars[Math.floor(Math.random() * chars.length)];
|
| 107 |
+
}
|
| 108 |
+
return str;
|
| 109 |
+
}
|
| 110 |
+
export function esc(str) {
|
| 111 |
+
return JSON.stringify(str);
|
| 112 |
+
}
|
| 113 |
+
export const captureStackTrace = Error.captureStackTrace
|
| 114 |
+
? Error.captureStackTrace
|
| 115 |
+
: (..._args) => { };
|
| 116 |
+
export function isObject(data) {
|
| 117 |
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
| 118 |
+
}
|
| 119 |
+
export const allowsEval = cached(() => {
|
| 120 |
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
| 121 |
+
return false;
|
| 122 |
+
}
|
| 123 |
+
try {
|
| 124 |
+
const F = Function;
|
| 125 |
+
new F("");
|
| 126 |
+
return true;
|
| 127 |
+
}
|
| 128 |
+
catch (_) {
|
| 129 |
+
return false;
|
| 130 |
+
}
|
| 131 |
+
});
|
| 132 |
+
export function isPlainObject(o) {
|
| 133 |
+
if (isObject(o) === false)
|
| 134 |
+
return false;
|
| 135 |
+
// modified constructor
|
| 136 |
+
const ctor = o.constructor;
|
| 137 |
+
if (ctor === undefined)
|
| 138 |
+
return true;
|
| 139 |
+
// modified prototype
|
| 140 |
+
const prot = ctor.prototype;
|
| 141 |
+
if (isObject(prot) === false)
|
| 142 |
+
return false;
|
| 143 |
+
// ctor doesn't have static `isPrototypeOf`
|
| 144 |
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
| 145 |
+
return false;
|
| 146 |
+
}
|
| 147 |
+
return true;
|
| 148 |
+
}
|
| 149 |
+
export function numKeys(data) {
|
| 150 |
+
let keyCount = 0;
|
| 151 |
+
for (const key in data) {
|
| 152 |
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
| 153 |
+
keyCount++;
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
return keyCount;
|
| 157 |
+
}
|
| 158 |
+
export const getParsedType = (data) => {
|
| 159 |
+
const t = typeof data;
|
| 160 |
+
switch (t) {
|
| 161 |
+
case "undefined":
|
| 162 |
+
return "undefined";
|
| 163 |
+
case "string":
|
| 164 |
+
return "string";
|
| 165 |
+
case "number":
|
| 166 |
+
return Number.isNaN(data) ? "nan" : "number";
|
| 167 |
+
case "boolean":
|
| 168 |
+
return "boolean";
|
| 169 |
+
case "function":
|
| 170 |
+
return "function";
|
| 171 |
+
case "bigint":
|
| 172 |
+
return "bigint";
|
| 173 |
+
case "symbol":
|
| 174 |
+
return "symbol";
|
| 175 |
+
case "object":
|
| 176 |
+
if (Array.isArray(data)) {
|
| 177 |
+
return "array";
|
| 178 |
+
}
|
| 179 |
+
if (data === null) {
|
| 180 |
+
return "null";
|
| 181 |
+
}
|
| 182 |
+
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
| 183 |
+
return "promise";
|
| 184 |
+
}
|
| 185 |
+
if (typeof Map !== "undefined" && data instanceof Map) {
|
| 186 |
+
return "map";
|
| 187 |
+
}
|
| 188 |
+
if (typeof Set !== "undefined" && data instanceof Set) {
|
| 189 |
+
return "set";
|
| 190 |
+
}
|
| 191 |
+
if (typeof Date !== "undefined" && data instanceof Date) {
|
| 192 |
+
return "date";
|
| 193 |
+
}
|
| 194 |
+
if (typeof File !== "undefined" && data instanceof File) {
|
| 195 |
+
return "file";
|
| 196 |
+
}
|
| 197 |
+
return "object";
|
| 198 |
+
default:
|
| 199 |
+
throw new Error(`Unknown data type: ${t}`);
|
| 200 |
+
}
|
| 201 |
+
};
|
| 202 |
+
export const propertyKeyTypes = new Set(["string", "number", "symbol"]);
|
| 203 |
+
export const primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
|
| 204 |
+
export function escapeRegex(str) {
|
| 205 |
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
| 206 |
+
}
|
| 207 |
+
// zod-specific utils
|
| 208 |
+
export function clone(inst, def, params) {
|
| 209 |
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
| 210 |
+
if (!def || params?.parent)
|
| 211 |
+
cl._zod.parent = inst;
|
| 212 |
+
return cl;
|
| 213 |
+
}
|
| 214 |
+
export function normalizeParams(_params) {
|
| 215 |
+
const params = _params;
|
| 216 |
+
if (!params)
|
| 217 |
+
return {};
|
| 218 |
+
if (typeof params === "string")
|
| 219 |
+
return { error: () => params };
|
| 220 |
+
if (params?.message !== undefined) {
|
| 221 |
+
if (params?.error !== undefined)
|
| 222 |
+
throw new Error("Cannot specify both `message` and `error` params");
|
| 223 |
+
params.error = params.message;
|
| 224 |
+
}
|
| 225 |
+
delete params.message;
|
| 226 |
+
if (typeof params.error === "string")
|
| 227 |
+
return { ...params, error: () => params.error };
|
| 228 |
+
return params;
|
| 229 |
+
}
|
| 230 |
+
export function createTransparentProxy(getter) {
|
| 231 |
+
let target;
|
| 232 |
+
return new Proxy({}, {
|
| 233 |
+
get(_, prop, receiver) {
|
| 234 |
+
target ?? (target = getter());
|
| 235 |
+
return Reflect.get(target, prop, receiver);
|
| 236 |
+
},
|
| 237 |
+
set(_, prop, value, receiver) {
|
| 238 |
+
target ?? (target = getter());
|
| 239 |
+
return Reflect.set(target, prop, value, receiver);
|
| 240 |
+
},
|
| 241 |
+
has(_, prop) {
|
| 242 |
+
target ?? (target = getter());
|
| 243 |
+
return Reflect.has(target, prop);
|
| 244 |
+
},
|
| 245 |
+
deleteProperty(_, prop) {
|
| 246 |
+
target ?? (target = getter());
|
| 247 |
+
return Reflect.deleteProperty(target, prop);
|
| 248 |
+
},
|
| 249 |
+
ownKeys(_) {
|
| 250 |
+
target ?? (target = getter());
|
| 251 |
+
return Reflect.ownKeys(target);
|
| 252 |
+
},
|
| 253 |
+
getOwnPropertyDescriptor(_, prop) {
|
| 254 |
+
target ?? (target = getter());
|
| 255 |
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
| 256 |
+
},
|
| 257 |
+
defineProperty(_, prop, descriptor) {
|
| 258 |
+
target ?? (target = getter());
|
| 259 |
+
return Reflect.defineProperty(target, prop, descriptor);
|
| 260 |
+
},
|
| 261 |
+
});
|
| 262 |
+
}
|
| 263 |
+
export function stringifyPrimitive(value) {
|
| 264 |
+
if (typeof value === "bigint")
|
| 265 |
+
return value.toString() + "n";
|
| 266 |
+
if (typeof value === "string")
|
| 267 |
+
return `"${value}"`;
|
| 268 |
+
return `${value}`;
|
| 269 |
+
}
|
| 270 |
+
export function optionalKeys(shape) {
|
| 271 |
+
return Object.keys(shape).filter((k) => {
|
| 272 |
+
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
| 273 |
+
});
|
| 274 |
+
}
|
| 275 |
+
export const NUMBER_FORMAT_RANGES = {
|
| 276 |
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
| 277 |
+
int32: [-2147483648, 2147483647],
|
| 278 |
+
uint32: [0, 4294967295],
|
| 279 |
+
float32: [-3.4028234663852886e38, 3.4028234663852886e38],
|
| 280 |
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE],
|
| 281 |
+
};
|
| 282 |
+
export const BIGINT_FORMAT_RANGES = {
|
| 283 |
+
int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
|
| 284 |
+
uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")],
|
| 285 |
+
};
|
| 286 |
+
export function pick(schema, mask) {
|
| 287 |
+
const newShape = {};
|
| 288 |
+
const currDef = schema._zod.def; //.shape;
|
| 289 |
+
for (const key in mask) {
|
| 290 |
+
if (!(key in currDef.shape)) {
|
| 291 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 292 |
+
}
|
| 293 |
+
if (!mask[key])
|
| 294 |
+
continue;
|
| 295 |
+
// pick key
|
| 296 |
+
newShape[key] = currDef.shape[key];
|
| 297 |
+
}
|
| 298 |
+
return clone(schema, {
|
| 299 |
+
...schema._zod.def,
|
| 300 |
+
shape: newShape,
|
| 301 |
+
checks: [],
|
| 302 |
+
});
|
| 303 |
+
}
|
| 304 |
+
export function omit(schema, mask) {
|
| 305 |
+
const newShape = { ...schema._zod.def.shape };
|
| 306 |
+
const currDef = schema._zod.def; //.shape;
|
| 307 |
+
for (const key in mask) {
|
| 308 |
+
if (!(key in currDef.shape)) {
|
| 309 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 310 |
+
}
|
| 311 |
+
if (!mask[key])
|
| 312 |
+
continue;
|
| 313 |
+
delete newShape[key];
|
| 314 |
+
}
|
| 315 |
+
return clone(schema, {
|
| 316 |
+
...schema._zod.def,
|
| 317 |
+
shape: newShape,
|
| 318 |
+
checks: [],
|
| 319 |
+
});
|
| 320 |
+
}
|
| 321 |
+
export function extend(schema, shape) {
|
| 322 |
+
if (!isPlainObject(shape)) {
|
| 323 |
+
throw new Error("Invalid input to extend: expected a plain object");
|
| 324 |
+
}
|
| 325 |
+
const def = {
|
| 326 |
+
...schema._zod.def,
|
| 327 |
+
get shape() {
|
| 328 |
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
| 329 |
+
assignProp(this, "shape", _shape); // self-caching
|
| 330 |
+
return _shape;
|
| 331 |
+
},
|
| 332 |
+
checks: [], // delete existing checks
|
| 333 |
+
};
|
| 334 |
+
return clone(schema, def);
|
| 335 |
+
}
|
| 336 |
+
export function merge(a, b) {
|
| 337 |
+
return clone(a, {
|
| 338 |
+
...a._zod.def,
|
| 339 |
+
get shape() {
|
| 340 |
+
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
| 341 |
+
assignProp(this, "shape", _shape); // self-caching
|
| 342 |
+
return _shape;
|
| 343 |
+
},
|
| 344 |
+
catchall: b._zod.def.catchall,
|
| 345 |
+
checks: [], // delete existing checks
|
| 346 |
+
});
|
| 347 |
+
}
|
| 348 |
+
export function partial(Class, schema, mask) {
|
| 349 |
+
const oldShape = schema._zod.def.shape;
|
| 350 |
+
const shape = { ...oldShape };
|
| 351 |
+
if (mask) {
|
| 352 |
+
for (const key in mask) {
|
| 353 |
+
if (!(key in oldShape)) {
|
| 354 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 355 |
+
}
|
| 356 |
+
if (!mask[key])
|
| 357 |
+
continue;
|
| 358 |
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
| 359 |
+
shape[key] = Class
|
| 360 |
+
? new Class({
|
| 361 |
+
type: "optional",
|
| 362 |
+
innerType: oldShape[key],
|
| 363 |
+
})
|
| 364 |
+
: oldShape[key];
|
| 365 |
+
}
|
| 366 |
+
}
|
| 367 |
+
else {
|
| 368 |
+
for (const key in oldShape) {
|
| 369 |
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
| 370 |
+
shape[key] = Class
|
| 371 |
+
? new Class({
|
| 372 |
+
type: "optional",
|
| 373 |
+
innerType: oldShape[key],
|
| 374 |
+
})
|
| 375 |
+
: oldShape[key];
|
| 376 |
+
}
|
| 377 |
+
}
|
| 378 |
+
return clone(schema, {
|
| 379 |
+
...schema._zod.def,
|
| 380 |
+
shape,
|
| 381 |
+
checks: [],
|
| 382 |
+
});
|
| 383 |
+
}
|
| 384 |
+
export function required(Class, schema, mask) {
|
| 385 |
+
const oldShape = schema._zod.def.shape;
|
| 386 |
+
const shape = { ...oldShape };
|
| 387 |
+
if (mask) {
|
| 388 |
+
for (const key in mask) {
|
| 389 |
+
if (!(key in shape)) {
|
| 390 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 391 |
+
}
|
| 392 |
+
if (!mask[key])
|
| 393 |
+
continue;
|
| 394 |
+
// overwrite with non-optional
|
| 395 |
+
shape[key] = new Class({
|
| 396 |
+
type: "nonoptional",
|
| 397 |
+
innerType: oldShape[key],
|
| 398 |
+
});
|
| 399 |
+
}
|
| 400 |
+
}
|
| 401 |
+
else {
|
| 402 |
+
for (const key in oldShape) {
|
| 403 |
+
// overwrite with non-optional
|
| 404 |
+
shape[key] = new Class({
|
| 405 |
+
type: "nonoptional",
|
| 406 |
+
innerType: oldShape[key],
|
| 407 |
+
});
|
| 408 |
+
}
|
| 409 |
+
}
|
| 410 |
+
return clone(schema, {
|
| 411 |
+
...schema._zod.def,
|
| 412 |
+
shape,
|
| 413 |
+
// optional: [],
|
| 414 |
+
checks: [],
|
| 415 |
+
});
|
| 416 |
+
}
|
| 417 |
+
export function aborted(x, startIndex = 0) {
|
| 418 |
+
for (let i = startIndex; i < x.issues.length; i++) {
|
| 419 |
+
if (x.issues[i]?.continue !== true)
|
| 420 |
+
return true;
|
| 421 |
+
}
|
| 422 |
+
return false;
|
| 423 |
+
}
|
| 424 |
+
export function prefixIssues(path, issues) {
|
| 425 |
+
return issues.map((iss) => {
|
| 426 |
+
var _a;
|
| 427 |
+
(_a = iss).path ?? (_a.path = []);
|
| 428 |
+
iss.path.unshift(path);
|
| 429 |
+
return iss;
|
| 430 |
+
});
|
| 431 |
+
}
|
| 432 |
+
export function unwrapMessage(message) {
|
| 433 |
+
return typeof message === "string" ? message : message?.message;
|
| 434 |
+
}
|
| 435 |
+
export function finalizeIssue(iss, ctx, config) {
|
| 436 |
+
const full = { ...iss, path: iss.path ?? [] };
|
| 437 |
+
// for backwards compatibility
|
| 438 |
+
if (!iss.message) {
|
| 439 |
+
const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
|
| 440 |
+
unwrapMessage(ctx?.error?.(iss)) ??
|
| 441 |
+
unwrapMessage(config.customError?.(iss)) ??
|
| 442 |
+
unwrapMessage(config.localeError?.(iss)) ??
|
| 443 |
+
"Invalid input";
|
| 444 |
+
full.message = message;
|
| 445 |
+
}
|
| 446 |
+
// delete (full as any).def;
|
| 447 |
+
delete full.inst;
|
| 448 |
+
delete full.continue;
|
| 449 |
+
if (!ctx?.reportInput) {
|
| 450 |
+
delete full.input;
|
| 451 |
+
}
|
| 452 |
+
return full;
|
| 453 |
+
}
|
| 454 |
+
export function getSizableOrigin(input) {
|
| 455 |
+
if (input instanceof Set)
|
| 456 |
+
return "set";
|
| 457 |
+
if (input instanceof Map)
|
| 458 |
+
return "map";
|
| 459 |
+
if (input instanceof File)
|
| 460 |
+
return "file";
|
| 461 |
+
return "unknown";
|
| 462 |
+
}
|
| 463 |
+
export function getLengthableOrigin(input) {
|
| 464 |
+
if (Array.isArray(input))
|
| 465 |
+
return "array";
|
| 466 |
+
if (typeof input === "string")
|
| 467 |
+
return "string";
|
| 468 |
+
return "unknown";
|
| 469 |
+
}
|
| 470 |
+
export function issue(...args) {
|
| 471 |
+
const [iss, input, inst] = args;
|
| 472 |
+
if (typeof iss === "string") {
|
| 473 |
+
return {
|
| 474 |
+
message: iss,
|
| 475 |
+
code: "custom",
|
| 476 |
+
input,
|
| 477 |
+
inst,
|
| 478 |
+
};
|
| 479 |
+
}
|
| 480 |
+
return { ...iss };
|
| 481 |
+
}
|
| 482 |
+
export function cleanEnum(obj) {
|
| 483 |
+
return Object.entries(obj)
|
| 484 |
+
.filter(([k, _]) => {
|
| 485 |
+
// return true if NaN, meaning it's not a number, thus a string key
|
| 486 |
+
return Number.isNaN(Number.parseInt(k, 10));
|
| 487 |
+
})
|
| 488 |
+
.map((el) => el[1]);
|
| 489 |
+
}
|
| 490 |
+
// instanceof
|
| 491 |
+
export class Class {
|
| 492 |
+
constructor(..._args) { }
|
| 493 |
+
}
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/versions.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.version = void 0;
|
| 4 |
+
exports.version = {
|
| 5 |
+
major: 4,
|
| 6 |
+
minor: 0,
|
| 7 |
+
patch: 0,
|
| 8 |
+
};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/versions.d.cts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export declare const version: {
|
| 2 |
+
readonly major: 4;
|
| 3 |
+
readonly minor: 0;
|
| 4 |
+
readonly patch: number;
|
| 5 |
+
};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/versions.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export declare const version: {
|
| 2 |
+
readonly major: 4;
|
| 3 |
+
readonly minor: 0;
|
| 4 |
+
readonly patch: number;
|
| 5 |
+
};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/core/versions.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export const version = {
|
| 2 |
+
major: 4,
|
| 3 |
+
minor: 0,
|
| 4 |
+
patch: 0,
|
| 5 |
+
};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/index.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 3 |
+
if (k2 === undefined) k2 = k;
|
| 4 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 5 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 6 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 7 |
+
}
|
| 8 |
+
Object.defineProperty(o, k2, desc);
|
| 9 |
+
}) : (function(o, m, k, k2) {
|
| 10 |
+
if (k2 === undefined) k2 = k;
|
| 11 |
+
o[k2] = m[k];
|
| 12 |
+
}));
|
| 13 |
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
| 14 |
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
| 15 |
+
};
|
| 16 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 17 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 18 |
+
};
|
| 19 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 20 |
+
const index_js_1 = __importDefault(require("./classic/index.cjs"));
|
| 21 |
+
__exportStar(require("./classic/index.cjs"), exports);
|
| 22 |
+
exports.default = index_js_1.default;
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/index.d.cts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import z4 from "./classic/index.cjs";
|
| 2 |
+
export * from "./classic/index.cjs";
|
| 3 |
+
export default z4;
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import z4 from "./classic/index.js";
|
| 2 |
+
export * from "./classic/index.js";
|
| 3 |
+
export default z4;
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import z4 from "./classic/index.js";
|
| 2 |
+
export * from "./classic/index.js";
|
| 3 |
+
export default z4;
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/ar.cjs
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 3 |
+
if (k2 === undefined) k2 = k;
|
| 4 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 5 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 6 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 7 |
+
}
|
| 8 |
+
Object.defineProperty(o, k2, desc);
|
| 9 |
+
}) : (function(o, m, k, k2) {
|
| 10 |
+
if (k2 === undefined) k2 = k;
|
| 11 |
+
o[k2] = m[k];
|
| 12 |
+
}));
|
| 13 |
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
| 14 |
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
| 15 |
+
}) : function(o, v) {
|
| 16 |
+
o["default"] = v;
|
| 17 |
+
});
|
| 18 |
+
var __importStar = (this && this.__importStar) || function (mod) {
|
| 19 |
+
if (mod && mod.__esModule) return mod;
|
| 20 |
+
var result = {};
|
| 21 |
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
| 22 |
+
__setModuleDefault(result, mod);
|
| 23 |
+
return result;
|
| 24 |
+
};
|
| 25 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 26 |
+
exports.default = default_1;
|
| 27 |
+
const util = __importStar(require("../core/util.cjs"));
|
| 28 |
+
const error = () => {
|
| 29 |
+
const Sizable = {
|
| 30 |
+
string: { unit: "حرف", verb: "أن يحوي" },
|
| 31 |
+
file: { unit: "بايت", verb: "أن يحوي" },
|
| 32 |
+
array: { unit: "عنصر", verb: "أن يحوي" },
|
| 33 |
+
set: { unit: "عنصر", verb: "أن يحوي" },
|
| 34 |
+
};
|
| 35 |
+
function getSizing(origin) {
|
| 36 |
+
return Sizable[origin] ?? null;
|
| 37 |
+
}
|
| 38 |
+
const parsedType = (data) => {
|
| 39 |
+
const t = typeof data;
|
| 40 |
+
switch (t) {
|
| 41 |
+
case "number": {
|
| 42 |
+
return Number.isNaN(data) ? "NaN" : "number";
|
| 43 |
+
}
|
| 44 |
+
case "object": {
|
| 45 |
+
if (Array.isArray(data)) {
|
| 46 |
+
return "array";
|
| 47 |
+
}
|
| 48 |
+
if (data === null) {
|
| 49 |
+
return "null";
|
| 50 |
+
}
|
| 51 |
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
| 52 |
+
return data.constructor.name;
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
return t;
|
| 57 |
+
};
|
| 58 |
+
const Nouns = {
|
| 59 |
+
regex: "مدخل",
|
| 60 |
+
email: "بريد إلكتروني",
|
| 61 |
+
url: "رابط",
|
| 62 |
+
emoji: "إيموجي",
|
| 63 |
+
uuid: "UUID",
|
| 64 |
+
uuidv4: "UUIDv4",
|
| 65 |
+
uuidv6: "UUIDv6",
|
| 66 |
+
nanoid: "nanoid",
|
| 67 |
+
guid: "GUID",
|
| 68 |
+
cuid: "cuid",
|
| 69 |
+
cuid2: "cuid2",
|
| 70 |
+
ulid: "ULID",
|
| 71 |
+
xid: "XID",
|
| 72 |
+
ksuid: "KSUID",
|
| 73 |
+
datetime: "تاريخ ووقت بمعيار ISO",
|
| 74 |
+
date: "تاريخ بمعيار ISO",
|
| 75 |
+
time: "وقت بمعيار ISO",
|
| 76 |
+
duration: "مدة بمعيار ISO",
|
| 77 |
+
ipv4: "عنوان IPv4",
|
| 78 |
+
ipv6: "عنوان IPv6",
|
| 79 |
+
cidrv4: "مدى عناوين بصيغة IPv4",
|
| 80 |
+
cidrv6: "مدى عناوين بصيغة IPv6",
|
| 81 |
+
base64: "نَص بترميز base64-encoded",
|
| 82 |
+
base64url: "نَص بترميز base64url-encoded",
|
| 83 |
+
json_string: "نَص على هيئة JSON",
|
| 84 |
+
e164: "رقم هاتف بمعيار E.164",
|
| 85 |
+
jwt: "JWT",
|
| 86 |
+
template_literal: "مدخل",
|
| 87 |
+
};
|
| 88 |
+
return (issue) => {
|
| 89 |
+
switch (issue.code) {
|
| 90 |
+
case "invalid_type":
|
| 91 |
+
return `مدخلات غير مقبولة: يفترض إدخال ${issue.expected}، ولكن تم إدخال ${parsedType(issue.input)}`;
|
| 92 |
+
case "invalid_value":
|
| 93 |
+
if (issue.values.length === 1)
|
| 94 |
+
return `مدخلات غير مقبولة: يفترض إدخال ${util.stringifyPrimitive(issue.values[0])}`;
|
| 95 |
+
return `اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${util.joinValues(issue.values, "|")}`;
|
| 96 |
+
case "too_big": {
|
| 97 |
+
const adj = issue.inclusive ? "<=" : "<";
|
| 98 |
+
const sizing = getSizing(issue.origin);
|
| 99 |
+
if (sizing)
|
| 100 |
+
return ` أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "عنصر"}`;
|
| 101 |
+
return `أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()}`;
|
| 102 |
+
}
|
| 103 |
+
case "too_small": {
|
| 104 |
+
const adj = issue.inclusive ? ">=" : ">";
|
| 105 |
+
const sizing = getSizing(issue.origin);
|
| 106 |
+
if (sizing) {
|
| 107 |
+
return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
|
| 108 |
+
}
|
| 109 |
+
return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()}`;
|
| 110 |
+
}
|
| 111 |
+
case "invalid_format": {
|
| 112 |
+
const _issue = issue;
|
| 113 |
+
if (_issue.format === "starts_with")
|
| 114 |
+
return `نَص غير مقبول: يجب أن يبدأ بـ "${issue.prefix}"`;
|
| 115 |
+
if (_issue.format === "ends_with")
|
| 116 |
+
return `نَص غير مقبول: يجب أن ينتهي بـ "${_issue.suffix}"`;
|
| 117 |
+
if (_issue.format === "includes")
|
| 118 |
+
return `نَص غير مقبول: يجب أن يتضمَّن "${_issue.includes}"`;
|
| 119 |
+
if (_issue.format === "regex")
|
| 120 |
+
return `نَص غير مقبول: يجب أن يطابق النمط ${_issue.pattern}`;
|
| 121 |
+
return `${Nouns[_issue.format] ?? issue.format} غير مقبول`;
|
| 122 |
+
}
|
| 123 |
+
case "not_multiple_of":
|
| 124 |
+
return `رقم غير مقبول: يجب أن يكون من مضاعفات ${issue.divisor}`;
|
| 125 |
+
case "unrecognized_keys":
|
| 126 |
+
return `معرف${issue.keys.length > 1 ? "ات" : ""} غريب${issue.keys.length > 1 ? "ة" : ""}: ${util.joinValues(issue.keys, "، ")}`;
|
| 127 |
+
case "invalid_key":
|
| 128 |
+
return `معرف غير مقبول في ${issue.origin}`;
|
| 129 |
+
case "invalid_union":
|
| 130 |
+
return "مدخل غير مقبول";
|
| 131 |
+
case "invalid_element":
|
| 132 |
+
return `مدخل غير مقبول في ${issue.origin}`;
|
| 133 |
+
default:
|
| 134 |
+
return "مدخل غير مقبول";
|
| 135 |
+
}
|
| 136 |
+
};
|
| 137 |
+
};
|
| 138 |
+
function default_1() {
|
| 139 |
+
return {
|
| 140 |
+
localeError: error(),
|
| 141 |
+
};
|
| 142 |
+
}
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/ar.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as errors from "../core/errors.cjs";
|
| 2 |
+
export default function (): {
|
| 3 |
+
localeError: errors.$ZodErrorMap;
|
| 4 |
+
};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/ar.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as errors from "../core/errors.js";
|
| 2 |
+
export default function (): {
|
| 3 |
+
localeError: errors.$ZodErrorMap;
|
| 4 |
+
};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/ar.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as util from "../core/util.js";
|
| 2 |
+
const error = () => {
|
| 3 |
+
const Sizable = {
|
| 4 |
+
string: { unit: "حرف", verb: "أن يحوي" },
|
| 5 |
+
file: { unit: "بايت", verb: "أن يحوي" },
|
| 6 |
+
array: { unit: "عنصر", verb: "أن يحوي" },
|
| 7 |
+
set: { unit: "عنصر", verb: "أن يحوي" },
|
| 8 |
+
};
|
| 9 |
+
function getSizing(origin) {
|
| 10 |
+
return Sizable[origin] ?? null;
|
| 11 |
+
}
|
| 12 |
+
const parsedType = (data) => {
|
| 13 |
+
const t = typeof data;
|
| 14 |
+
switch (t) {
|
| 15 |
+
case "number": {
|
| 16 |
+
return Number.isNaN(data) ? "NaN" : "number";
|
| 17 |
+
}
|
| 18 |
+
case "object": {
|
| 19 |
+
if (Array.isArray(data)) {
|
| 20 |
+
return "array";
|
| 21 |
+
}
|
| 22 |
+
if (data === null) {
|
| 23 |
+
return "null";
|
| 24 |
+
}
|
| 25 |
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
| 26 |
+
return data.constructor.name;
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
return t;
|
| 31 |
+
};
|
| 32 |
+
const Nouns = {
|
| 33 |
+
regex: "مدخل",
|
| 34 |
+
email: "بريد إلكتروني",
|
| 35 |
+
url: "رابط",
|
| 36 |
+
emoji: "إيموجي",
|
| 37 |
+
uuid: "UUID",
|
| 38 |
+
uuidv4: "UUIDv4",
|
| 39 |
+
uuidv6: "UUIDv6",
|
| 40 |
+
nanoid: "nanoid",
|
| 41 |
+
guid: "GUID",
|
| 42 |
+
cuid: "cuid",
|
| 43 |
+
cuid2: "cuid2",
|
| 44 |
+
ulid: "ULID",
|
| 45 |
+
xid: "XID",
|
| 46 |
+
ksuid: "KSUID",
|
| 47 |
+
datetime: "تاريخ ووقت بمعيار ISO",
|
| 48 |
+
date: "تاريخ بمعيار ISO",
|
| 49 |
+
time: "وقت بمعيار ISO",
|
| 50 |
+
duration: "مدة بمعيار ISO",
|
| 51 |
+
ipv4: "عنوان IPv4",
|
| 52 |
+
ipv6: "عنوان IPv6",
|
| 53 |
+
cidrv4: "مدى عناوين بصيغة IPv4",
|
| 54 |
+
cidrv6: "مدى عناوين بصيغة IPv6",
|
| 55 |
+
base64: "نَص بترميز base64-encoded",
|
| 56 |
+
base64url: "نَص بترميز base64url-encoded",
|
| 57 |
+
json_string: "نَص على هيئة JSON",
|
| 58 |
+
e164: "رقم هاتف بمعيار E.164",
|
| 59 |
+
jwt: "JWT",
|
| 60 |
+
template_literal: "مدخل",
|
| 61 |
+
};
|
| 62 |
+
return (issue) => {
|
| 63 |
+
switch (issue.code) {
|
| 64 |
+
case "invalid_type":
|
| 65 |
+
return `مدخلات غير مقبولة: يفترض إدخال ${issue.expected}، ولكن تم إدخال ${parsedType(issue.input)}`;
|
| 66 |
+
case "invalid_value":
|
| 67 |
+
if (issue.values.length === 1)
|
| 68 |
+
return `مدخلات غير مقبولة: يفترض إدخال ${util.stringifyPrimitive(issue.values[0])}`;
|
| 69 |
+
return `اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${util.joinValues(issue.values, "|")}`;
|
| 70 |
+
case "too_big": {
|
| 71 |
+
const adj = issue.inclusive ? "<=" : "<";
|
| 72 |
+
const sizing = getSizing(issue.origin);
|
| 73 |
+
if (sizing)
|
| 74 |
+
return ` أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "عنصر"}`;
|
| 75 |
+
return `أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()}`;
|
| 76 |
+
}
|
| 77 |
+
case "too_small": {
|
| 78 |
+
const adj = issue.inclusive ? ">=" : ">";
|
| 79 |
+
const sizing = getSizing(issue.origin);
|
| 80 |
+
if (sizing) {
|
| 81 |
+
return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
|
| 82 |
+
}
|
| 83 |
+
return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()}`;
|
| 84 |
+
}
|
| 85 |
+
case "invalid_format": {
|
| 86 |
+
const _issue = issue;
|
| 87 |
+
if (_issue.format === "starts_with")
|
| 88 |
+
return `نَص غير مقبول: يجب أن يبدأ بـ "${issue.prefix}"`;
|
| 89 |
+
if (_issue.format === "ends_with")
|
| 90 |
+
return `نَص غير مقبول: يجب أن ينتهي بـ "${_issue.suffix}"`;
|
| 91 |
+
if (_issue.format === "includes")
|
| 92 |
+
return `نَص غير مقبول: يجب أن يتضمَّن "${_issue.includes}"`;
|
| 93 |
+
if (_issue.format === "regex")
|
| 94 |
+
return `نَص غير مقبول: يجب أن يطابق النمط ${_issue.pattern}`;
|
| 95 |
+
return `${Nouns[_issue.format] ?? issue.format} غير مقبول`;
|
| 96 |
+
}
|
| 97 |
+
case "not_multiple_of":
|
| 98 |
+
return `رقم غير مقبول: يجب أن يكون من مضاعفات ${issue.divisor}`;
|
| 99 |
+
case "unrecognized_keys":
|
| 100 |
+
return `معرف${issue.keys.length > 1 ? "ات" : ""} غريب${issue.keys.length > 1 ? "ة" : ""}: ${util.joinValues(issue.keys, "، ")}`;
|
| 101 |
+
case "invalid_key":
|
| 102 |
+
return `معرف غير مقبول في ${issue.origin}`;
|
| 103 |
+
case "invalid_union":
|
| 104 |
+
return "مدخل غير مقبول";
|
| 105 |
+
case "invalid_element":
|
| 106 |
+
return `مدخل غير مقبول في ${issue.origin}`;
|
| 107 |
+
default:
|
| 108 |
+
return "مدخل غير مقبول";
|
| 109 |
+
}
|
| 110 |
+
};
|
| 111 |
+
};
|
| 112 |
+
export default function () {
|
| 113 |
+
return {
|
| 114 |
+
localeError: error(),
|
| 115 |
+
};
|
| 116 |
+
}
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/az.cjs
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 3 |
+
if (k2 === undefined) k2 = k;
|
| 4 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 5 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 6 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 7 |
+
}
|
| 8 |
+
Object.defineProperty(o, k2, desc);
|
| 9 |
+
}) : (function(o, m, k, k2) {
|
| 10 |
+
if (k2 === undefined) k2 = k;
|
| 11 |
+
o[k2] = m[k];
|
| 12 |
+
}));
|
| 13 |
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
| 14 |
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
| 15 |
+
}) : function(o, v) {
|
| 16 |
+
o["default"] = v;
|
| 17 |
+
});
|
| 18 |
+
var __importStar = (this && this.__importStar) || function (mod) {
|
| 19 |
+
if (mod && mod.__esModule) return mod;
|
| 20 |
+
var result = {};
|
| 21 |
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
| 22 |
+
__setModuleDefault(result, mod);
|
| 23 |
+
return result;
|
| 24 |
+
};
|
| 25 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 26 |
+
exports.default = default_1;
|
| 27 |
+
const util = __importStar(require("../core/util.cjs"));
|
| 28 |
+
const error = () => {
|
| 29 |
+
const Sizable = {
|
| 30 |
+
string: { unit: "simvol", verb: "olmalıdır" },
|
| 31 |
+
file: { unit: "bayt", verb: "olmalıdır" },
|
| 32 |
+
array: { unit: "element", verb: "olmalıdır" },
|
| 33 |
+
set: { unit: "element", verb: "olmalıdır" },
|
| 34 |
+
};
|
| 35 |
+
function getSizing(origin) {
|
| 36 |
+
return Sizable[origin] ?? null;
|
| 37 |
+
}
|
| 38 |
+
const parsedType = (data) => {
|
| 39 |
+
const t = typeof data;
|
| 40 |
+
switch (t) {
|
| 41 |
+
case "number": {
|
| 42 |
+
return Number.isNaN(data) ? "NaN" : "number";
|
| 43 |
+
}
|
| 44 |
+
case "object": {
|
| 45 |
+
if (Array.isArray(data)) {
|
| 46 |
+
return "array";
|
| 47 |
+
}
|
| 48 |
+
if (data === null) {
|
| 49 |
+
return "null";
|
| 50 |
+
}
|
| 51 |
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
| 52 |
+
return data.constructor.name;
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
return t;
|
| 57 |
+
};
|
| 58 |
+
const Nouns = {
|
| 59 |
+
regex: "input",
|
| 60 |
+
email: "email address",
|
| 61 |
+
url: "URL",
|
| 62 |
+
emoji: "emoji",
|
| 63 |
+
uuid: "UUID",
|
| 64 |
+
uuidv4: "UUIDv4",
|
| 65 |
+
uuidv6: "UUIDv6",
|
| 66 |
+
nanoid: "nanoid",
|
| 67 |
+
guid: "GUID",
|
| 68 |
+
cuid: "cuid",
|
| 69 |
+
cuid2: "cuid2",
|
| 70 |
+
ulid: "ULID",
|
| 71 |
+
xid: "XID",
|
| 72 |
+
ksuid: "KSUID",
|
| 73 |
+
datetime: "ISO datetime",
|
| 74 |
+
date: "ISO date",
|
| 75 |
+
time: "ISO time",
|
| 76 |
+
duration: "ISO duration",
|
| 77 |
+
ipv4: "IPv4 address",
|
| 78 |
+
ipv6: "IPv6 address",
|
| 79 |
+
cidrv4: "IPv4 range",
|
| 80 |
+
cidrv6: "IPv6 range",
|
| 81 |
+
base64: "base64-encoded string",
|
| 82 |
+
base64url: "base64url-encoded string",
|
| 83 |
+
json_string: "JSON string",
|
| 84 |
+
e164: "E.164 number",
|
| 85 |
+
jwt: "JWT",
|
| 86 |
+
template_literal: "input",
|
| 87 |
+
};
|
| 88 |
+
return (issue) => {
|
| 89 |
+
switch (issue.code) {
|
| 90 |
+
case "invalid_type":
|
| 91 |
+
return `Yanlış dəyər: gözlənilən ${issue.expected}, daxil olan ${parsedType(issue.input)}`;
|
| 92 |
+
case "invalid_value":
|
| 93 |
+
if (issue.values.length === 1)
|
| 94 |
+
return `Yanlış dəyər: gözlənilən ${util.stringifyPrimitive(issue.values[0])}`;
|
| 95 |
+
return `Yanlış seçim: aşağıdakılardan biri olmalıdır: ${util.joinValues(issue.values, "|")}`;
|
| 96 |
+
case "too_big": {
|
| 97 |
+
const adj = issue.inclusive ? "<=" : "<";
|
| 98 |
+
const sizing = getSizing(issue.origin);
|
| 99 |
+
if (sizing)
|
| 100 |
+
return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "element"}`;
|
| 101 |
+
return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()}`;
|
| 102 |
+
}
|
| 103 |
+
case "too_small": {
|
| 104 |
+
const adj = issue.inclusive ? ">=" : ">";
|
| 105 |
+
const sizing = getSizing(issue.origin);
|
| 106 |
+
if (sizing)
|
| 107 |
+
return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
| 108 |
+
return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()}`;
|
| 109 |
+
}
|
| 110 |
+
case "invalid_format": {
|
| 111 |
+
const _issue = issue;
|
| 112 |
+
if (_issue.format === "starts_with")
|
| 113 |
+
return `Yanlış mətn: "${_issue.prefix}" ilə başlamalıdır`;
|
| 114 |
+
if (_issue.format === "ends_with")
|
| 115 |
+
return `Yanlış mətn: "${_issue.suffix}" ilə bitməlidir`;
|
| 116 |
+
if (_issue.format === "includes")
|
| 117 |
+
return `Yanlış mətn: "${_issue.includes}" daxil olmalıdır`;
|
| 118 |
+
if (_issue.format === "regex")
|
| 119 |
+
return `Yanlış mətn: ${_issue.pattern} şablonuna uyğun olmalıdır`;
|
| 120 |
+
return `Yanlış ${Nouns[_issue.format] ?? issue.format}`;
|
| 121 |
+
}
|
| 122 |
+
case "not_multiple_of":
|
| 123 |
+
return `Yanlış ədəd: ${issue.divisor} ilə bölünə bilən olmalıdır`;
|
| 124 |
+
case "unrecognized_keys":
|
| 125 |
+
return `Tanınmayan açar${issue.keys.length > 1 ? "lar" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
| 126 |
+
case "invalid_key":
|
| 127 |
+
return `${issue.origin} daxilində yanlış açar`;
|
| 128 |
+
case "invalid_union":
|
| 129 |
+
return "Yanlış dəyər";
|
| 130 |
+
case "invalid_element":
|
| 131 |
+
return `${issue.origin} daxilində yanlış dəyər`;
|
| 132 |
+
default:
|
| 133 |
+
return `Yanlış dəyər`;
|
| 134 |
+
}
|
| 135 |
+
};
|
| 136 |
+
};
|
| 137 |
+
function default_1() {
|
| 138 |
+
return {
|
| 139 |
+
localeError: error(),
|
| 140 |
+
};
|
| 141 |
+
}
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/az.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as errors from "../core/errors.cjs";
|
| 2 |
+
export default function (): {
|
| 3 |
+
localeError: errors.$ZodErrorMap;
|
| 4 |
+
};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/az.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as errors from "../core/errors.js";
|
| 2 |
+
export default function (): {
|
| 3 |
+
localeError: errors.$ZodErrorMap;
|
| 4 |
+
};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/az.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as util from "../core/util.js";
|
| 2 |
+
const error = () => {
|
| 3 |
+
const Sizable = {
|
| 4 |
+
string: { unit: "simvol", verb: "olmalıdır" },
|
| 5 |
+
file: { unit: "bayt", verb: "olmalıdır" },
|
| 6 |
+
array: { unit: "element", verb: "olmalıdır" },
|
| 7 |
+
set: { unit: "element", verb: "olmalıdır" },
|
| 8 |
+
};
|
| 9 |
+
function getSizing(origin) {
|
| 10 |
+
return Sizable[origin] ?? null;
|
| 11 |
+
}
|
| 12 |
+
const parsedType = (data) => {
|
| 13 |
+
const t = typeof data;
|
| 14 |
+
switch (t) {
|
| 15 |
+
case "number": {
|
| 16 |
+
return Number.isNaN(data) ? "NaN" : "number";
|
| 17 |
+
}
|
| 18 |
+
case "object": {
|
| 19 |
+
if (Array.isArray(data)) {
|
| 20 |
+
return "array";
|
| 21 |
+
}
|
| 22 |
+
if (data === null) {
|
| 23 |
+
return "null";
|
| 24 |
+
}
|
| 25 |
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
| 26 |
+
return data.constructor.name;
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
return t;
|
| 31 |
+
};
|
| 32 |
+
const Nouns = {
|
| 33 |
+
regex: "input",
|
| 34 |
+
email: "email address",
|
| 35 |
+
url: "URL",
|
| 36 |
+
emoji: "emoji",
|
| 37 |
+
uuid: "UUID",
|
| 38 |
+
uuidv4: "UUIDv4",
|
| 39 |
+
uuidv6: "UUIDv6",
|
| 40 |
+
nanoid: "nanoid",
|
| 41 |
+
guid: "GUID",
|
| 42 |
+
cuid: "cuid",
|
| 43 |
+
cuid2: "cuid2",
|
| 44 |
+
ulid: "ULID",
|
| 45 |
+
xid: "XID",
|
| 46 |
+
ksuid: "KSUID",
|
| 47 |
+
datetime: "ISO datetime",
|
| 48 |
+
date: "ISO date",
|
| 49 |
+
time: "ISO time",
|
| 50 |
+
duration: "ISO duration",
|
| 51 |
+
ipv4: "IPv4 address",
|
| 52 |
+
ipv6: "IPv6 address",
|
| 53 |
+
cidrv4: "IPv4 range",
|
| 54 |
+
cidrv6: "IPv6 range",
|
| 55 |
+
base64: "base64-encoded string",
|
| 56 |
+
base64url: "base64url-encoded string",
|
| 57 |
+
json_string: "JSON string",
|
| 58 |
+
e164: "E.164 number",
|
| 59 |
+
jwt: "JWT",
|
| 60 |
+
template_literal: "input",
|
| 61 |
+
};
|
| 62 |
+
return (issue) => {
|
| 63 |
+
switch (issue.code) {
|
| 64 |
+
case "invalid_type":
|
| 65 |
+
return `Yanlış dəyər: gözlənilən ${issue.expected}, daxil olan ${parsedType(issue.input)}`;
|
| 66 |
+
case "invalid_value":
|
| 67 |
+
if (issue.values.length === 1)
|
| 68 |
+
return `Yanlış dəyər: gözlənilən ${util.stringifyPrimitive(issue.values[0])}`;
|
| 69 |
+
return `Yanlış seçim: aşağıdakılardan biri olmalıdır: ${util.joinValues(issue.values, "|")}`;
|
| 70 |
+
case "too_big": {
|
| 71 |
+
const adj = issue.inclusive ? "<=" : "<";
|
| 72 |
+
const sizing = getSizing(issue.origin);
|
| 73 |
+
if (sizing)
|
| 74 |
+
return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "element"}`;
|
| 75 |
+
return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()}`;
|
| 76 |
+
}
|
| 77 |
+
case "too_small": {
|
| 78 |
+
const adj = issue.inclusive ? ">=" : ">";
|
| 79 |
+
const sizing = getSizing(issue.origin);
|
| 80 |
+
if (sizing)
|
| 81 |
+
return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
| 82 |
+
return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()}`;
|
| 83 |
+
}
|
| 84 |
+
case "invalid_format": {
|
| 85 |
+
const _issue = issue;
|
| 86 |
+
if (_issue.format === "starts_with")
|
| 87 |
+
return `Yanlış mətn: "${_issue.prefix}" ilə başlamalıdır`;
|
| 88 |
+
if (_issue.format === "ends_with")
|
| 89 |
+
return `Yanlış mətn: "${_issue.suffix}" ilə bitməlidir`;
|
| 90 |
+
if (_issue.format === "includes")
|
| 91 |
+
return `Yanlış mətn: "${_issue.includes}" daxil olmalıdır`;
|
| 92 |
+
if (_issue.format === "regex")
|
| 93 |
+
return `Yanlış mətn: ${_issue.pattern} şablonuna uyğun olmalıdır`;
|
| 94 |
+
return `Yanlış ${Nouns[_issue.format] ?? issue.format}`;
|
| 95 |
+
}
|
| 96 |
+
case "not_multiple_of":
|
| 97 |
+
return `Yanlış ədəd: ${issue.divisor} ilə bölünə bilən olmalıdır`;
|
| 98 |
+
case "unrecognized_keys":
|
| 99 |
+
return `Tanınmayan açar${issue.keys.length > 1 ? "lar" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
| 100 |
+
case "invalid_key":
|
| 101 |
+
return `${issue.origin} daxilində yanlış açar`;
|
| 102 |
+
case "invalid_union":
|
| 103 |
+
return "Yanlış dəyər";
|
| 104 |
+
case "invalid_element":
|
| 105 |
+
return `${issue.origin} daxilində yanlış dəyər`;
|
| 106 |
+
default:
|
| 107 |
+
return `Yanlış dəyər`;
|
| 108 |
+
}
|
| 109 |
+
};
|
| 110 |
+
};
|
| 111 |
+
export default function () {
|
| 112 |
+
return {
|
| 113 |
+
localeError: error(),
|
| 114 |
+
};
|
| 115 |
+
}
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/be.cjs
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 3 |
+
if (k2 === undefined) k2 = k;
|
| 4 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 5 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 6 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 7 |
+
}
|
| 8 |
+
Object.defineProperty(o, k2, desc);
|
| 9 |
+
}) : (function(o, m, k, k2) {
|
| 10 |
+
if (k2 === undefined) k2 = k;
|
| 11 |
+
o[k2] = m[k];
|
| 12 |
+
}));
|
| 13 |
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
| 14 |
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
| 15 |
+
}) : function(o, v) {
|
| 16 |
+
o["default"] = v;
|
| 17 |
+
});
|
| 18 |
+
var __importStar = (this && this.__importStar) || function (mod) {
|
| 19 |
+
if (mod && mod.__esModule) return mod;
|
| 20 |
+
var result = {};
|
| 21 |
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
| 22 |
+
__setModuleDefault(result, mod);
|
| 23 |
+
return result;
|
| 24 |
+
};
|
| 25 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 26 |
+
exports.default = default_1;
|
| 27 |
+
const util = __importStar(require("../core/util.cjs"));
|
| 28 |
+
function getBelarusianPlural(count, one, few, many) {
|
| 29 |
+
const absCount = Math.abs(count);
|
| 30 |
+
const lastDigit = absCount % 10;
|
| 31 |
+
const lastTwoDigits = absCount % 100;
|
| 32 |
+
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
| 33 |
+
return many;
|
| 34 |
+
}
|
| 35 |
+
if (lastDigit === 1) {
|
| 36 |
+
return one;
|
| 37 |
+
}
|
| 38 |
+
if (lastDigit >= 2 && lastDigit <= 4) {
|
| 39 |
+
return few;
|
| 40 |
+
}
|
| 41 |
+
return many;
|
| 42 |
+
}
|
| 43 |
+
const error = () => {
|
| 44 |
+
const Sizable = {
|
| 45 |
+
string: {
|
| 46 |
+
unit: {
|
| 47 |
+
one: "сімвал",
|
| 48 |
+
few: "сімвалы",
|
| 49 |
+
many: "сімвалаў",
|
| 50 |
+
},
|
| 51 |
+
verb: "мець",
|
| 52 |
+
},
|
| 53 |
+
array: {
|
| 54 |
+
unit: {
|
| 55 |
+
one: "элемент",
|
| 56 |
+
few: "элементы",
|
| 57 |
+
many: "элементаў",
|
| 58 |
+
},
|
| 59 |
+
verb: "мець",
|
| 60 |
+
},
|
| 61 |
+
set: {
|
| 62 |
+
unit: {
|
| 63 |
+
one: "элемент",
|
| 64 |
+
few: "элементы",
|
| 65 |
+
many: "элементаў",
|
| 66 |
+
},
|
| 67 |
+
verb: "мець",
|
| 68 |
+
},
|
| 69 |
+
file: {
|
| 70 |
+
unit: {
|
| 71 |
+
one: "байт",
|
| 72 |
+
few: "байты",
|
| 73 |
+
many: "байтаў",
|
| 74 |
+
},
|
| 75 |
+
verb: "мець",
|
| 76 |
+
},
|
| 77 |
+
};
|
| 78 |
+
function getSizing(origin) {
|
| 79 |
+
return Sizable[origin] ?? null;
|
| 80 |
+
}
|
| 81 |
+
const parsedType = (data) => {
|
| 82 |
+
const t = typeof data;
|
| 83 |
+
switch (t) {
|
| 84 |
+
case "number": {
|
| 85 |
+
return Number.isNaN(data) ? "NaN" : "лік";
|
| 86 |
+
}
|
| 87 |
+
case "object": {
|
| 88 |
+
if (Array.isArray(data)) {
|
| 89 |
+
return "масіў";
|
| 90 |
+
}
|
| 91 |
+
if (data === null) {
|
| 92 |
+
return "null";
|
| 93 |
+
}
|
| 94 |
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
| 95 |
+
return data.constructor.name;
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
return t;
|
| 100 |
+
};
|
| 101 |
+
const Nouns = {
|
| 102 |
+
regex: "увод",
|
| 103 |
+
email: "email адрас",
|
| 104 |
+
url: "URL",
|
| 105 |
+
emoji: "эмодзі",
|
| 106 |
+
uuid: "UUID",
|
| 107 |
+
uuidv4: "UUIDv4",
|
| 108 |
+
uuidv6: "UUIDv6",
|
| 109 |
+
nanoid: "nanoid",
|
| 110 |
+
guid: "GUID",
|
| 111 |
+
cuid: "cuid",
|
| 112 |
+
cuid2: "cuid2",
|
| 113 |
+
ulid: "ULID",
|
| 114 |
+
xid: "XID",
|
| 115 |
+
ksuid: "KSUID",
|
| 116 |
+
datetime: "ISO дата і час",
|
| 117 |
+
date: "ISO дата",
|
| 118 |
+
time: "ISO час",
|
| 119 |
+
duration: "ISO працягласць",
|
| 120 |
+
ipv4: "IPv4 адрас",
|
| 121 |
+
ipv6: "IPv6 адрас",
|
| 122 |
+
cidrv4: "IPv4 дыяпазон",
|
| 123 |
+
cidrv6: "IPv6 дыяпазон",
|
| 124 |
+
base64: "радок у фармаце base64",
|
| 125 |
+
base64url: "радок у фармаце base64url",
|
| 126 |
+
json_string: "JSON радок",
|
| 127 |
+
e164: "нумар E.164",
|
| 128 |
+
jwt: "JWT",
|
| 129 |
+
template_literal: "увод",
|
| 130 |
+
};
|
| 131 |
+
return (issue) => {
|
| 132 |
+
switch (issue.code) {
|
| 133 |
+
case "invalid_type":
|
| 134 |
+
return `Няправільны ўвод: чакаўся ${issue.expected}, атрымана ${parsedType(issue.input)}`;
|
| 135 |
+
case "invalid_value":
|
| 136 |
+
if (issue.values.length === 1)
|
| 137 |
+
return `Няправільны ўвод: чакалася ${util.stringifyPrimitive(issue.values[0])}`;
|
| 138 |
+
return `Няправільны варыянт: чакаўся адзін з ${util.joinValues(issue.values, "|")}`;
|
| 139 |
+
case "too_big": {
|
| 140 |
+
const adj = issue.inclusive ? "<=" : "<";
|
| 141 |
+
const sizing = getSizing(issue.origin);
|
| 142 |
+
if (sizing) {
|
| 143 |
+
const maxValue = Number(issue.maximum);
|
| 144 |
+
const unit = getBelarusianPlural(maxValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
|
| 145 |
+
return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна ${sizing.verb} ${adj}${issue.maximum.toString()} ${unit}`;
|
| 146 |
+
}
|
| 147 |
+
return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна быць ${adj}${issue.maximum.toString()}`;
|
| 148 |
+
}
|
| 149 |
+
case "too_small": {
|
| 150 |
+
const adj = issue.inclusive ? ">=" : ">";
|
| 151 |
+
const sizing = getSizing(issue.origin);
|
| 152 |
+
if (sizing) {
|
| 153 |
+
const minValue = Number(issue.minimum);
|
| 154 |
+
const unit = getBelarusianPlural(minValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
|
| 155 |
+
return `Занадта малы: чакалася, што ${issue.origin} павінна ${sizing.verb} ${adj}${issue.minimum.toString()} ${unit}`;
|
| 156 |
+
}
|
| 157 |
+
return `Занадта малы: чакалася, што ${issue.origin} павінна быць ${adj}${issue.minimum.toString()}`;
|
| 158 |
+
}
|
| 159 |
+
case "invalid_format": {
|
| 160 |
+
const _issue = issue;
|
| 161 |
+
if (_issue.format === "starts_with")
|
| 162 |
+
return `Няправільны радок: павінен пачынацца з "${_issue.prefix}"`;
|
| 163 |
+
if (_issue.format === "ends_with")
|
| 164 |
+
return `Няправільны радок: павінен заканчвацца на "${_issue.suffix}"`;
|
| 165 |
+
if (_issue.format === "includes")
|
| 166 |
+
return `Няправільны радок: павінен змяшчаць "${_issue.includes}"`;
|
| 167 |
+
if (_issue.format === "regex")
|
| 168 |
+
return `Няправільны радок: павінен адпавядаць шаблону ${_issue.pattern}`;
|
| 169 |
+
return `Няправільны ${Nouns[_issue.format] ?? issue.format}`;
|
| 170 |
+
}
|
| 171 |
+
case "not_multiple_of":
|
| 172 |
+
return `Няправільны лік: павінен быць кратным ${issue.divisor}`;
|
| 173 |
+
case "unrecognized_keys":
|
| 174 |
+
return `Нераспазнаны ${issue.keys.length > 1 ? "ключы" : "ключ"}: ${util.joinValues(issue.keys, ", ")}`;
|
| 175 |
+
case "invalid_key":
|
| 176 |
+
return `Няправільны ключ у ${issue.origin}`;
|
| 177 |
+
case "invalid_union":
|
| 178 |
+
return "Няправільны ўвод";
|
| 179 |
+
case "invalid_element":
|
| 180 |
+
return `Няправільнае значэнне ў ${issue.origin}`;
|
| 181 |
+
default:
|
| 182 |
+
return `Няправільны ўвод`;
|
| 183 |
+
}
|
| 184 |
+
};
|
| 185 |
+
};
|
| 186 |
+
function default_1() {
|
| 187 |
+
return {
|
| 188 |
+
localeError: error(),
|
| 189 |
+
};
|
| 190 |
+
}
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/be.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as errors from "../core/errors.cjs";
|
| 2 |
+
export default function (): {
|
| 3 |
+
localeError: errors.$ZodErrorMap;
|
| 4 |
+
};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/be.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as errors from "../core/errors.js";
|
| 2 |
+
export default function (): {
|
| 3 |
+
localeError: errors.$ZodErrorMap;
|
| 4 |
+
};
|
node_modules/@jimp/plugin-contain/node_modules/zod/v4/locales/be.js
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as util from "../core/util.js";
|
| 2 |
+
function getBelarusianPlural(count, one, few, many) {
|
| 3 |
+
const absCount = Math.abs(count);
|
| 4 |
+
const lastDigit = absCount % 10;
|
| 5 |
+
const lastTwoDigits = absCount % 100;
|
| 6 |
+
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
| 7 |
+
return many;
|
| 8 |
+
}
|
| 9 |
+
if (lastDigit === 1) {
|
| 10 |
+
return one;
|
| 11 |
+
}
|
| 12 |
+
if (lastDigit >= 2 && lastDigit <= 4) {
|
| 13 |
+
return few;
|
| 14 |
+
}
|
| 15 |
+
return many;
|
| 16 |
+
}
|
| 17 |
+
const error = () => {
|
| 18 |
+
const Sizable = {
|
| 19 |
+
string: {
|
| 20 |
+
unit: {
|
| 21 |
+
one: "сімвал",
|
| 22 |
+
few: "сімвалы",
|
| 23 |
+
many: "сімвалаў",
|
| 24 |
+
},
|
| 25 |
+
verb: "мець",
|
| 26 |
+
},
|
| 27 |
+
array: {
|
| 28 |
+
unit: {
|
| 29 |
+
one: "элемент",
|
| 30 |
+
few: "элементы",
|
| 31 |
+
many: "элементаў",
|
| 32 |
+
},
|
| 33 |
+
verb: "мець",
|
| 34 |
+
},
|
| 35 |
+
set: {
|
| 36 |
+
unit: {
|
| 37 |
+
one: "элемент",
|
| 38 |
+
few: "элементы",
|
| 39 |
+
many: "элементаў",
|
| 40 |
+
},
|
| 41 |
+
verb: "мець",
|
| 42 |
+
},
|
| 43 |
+
file: {
|
| 44 |
+
unit: {
|
| 45 |
+
one: "байт",
|
| 46 |
+
few: "байты",
|
| 47 |
+
many: "байтаў",
|
| 48 |
+
},
|
| 49 |
+
verb: "мець",
|
| 50 |
+
},
|
| 51 |
+
};
|
| 52 |
+
function getSizing(origin) {
|
| 53 |
+
return Sizable[origin] ?? null;
|
| 54 |
+
}
|
| 55 |
+
const parsedType = (data) => {
|
| 56 |
+
const t = typeof data;
|
| 57 |
+
switch (t) {
|
| 58 |
+
case "number": {
|
| 59 |
+
return Number.isNaN(data) ? "NaN" : "лік";
|
| 60 |
+
}
|
| 61 |
+
case "object": {
|
| 62 |
+
if (Array.isArray(data)) {
|
| 63 |
+
return "масіў";
|
| 64 |
+
}
|
| 65 |
+
if (data === null) {
|
| 66 |
+
return "null";
|
| 67 |
+
}
|
| 68 |
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
| 69 |
+
return data.constructor.name;
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
return t;
|
| 74 |
+
};
|
| 75 |
+
const Nouns = {
|
| 76 |
+
regex: "увод",
|
| 77 |
+
email: "email адрас",
|
| 78 |
+
url: "URL",
|
| 79 |
+
emoji: "эмодзі",
|
| 80 |
+
uuid: "UUID",
|
| 81 |
+
uuidv4: "UUIDv4",
|
| 82 |
+
uuidv6: "UUIDv6",
|
| 83 |
+
nanoid: "nanoid",
|
| 84 |
+
guid: "GUID",
|
| 85 |
+
cuid: "cuid",
|
| 86 |
+
cuid2: "cuid2",
|
| 87 |
+
ulid: "ULID",
|
| 88 |
+
xid: "XID",
|
| 89 |
+
ksuid: "KSUID",
|
| 90 |
+
datetime: "ISO дата і час",
|
| 91 |
+
date: "ISO дата",
|
| 92 |
+
time: "ISO час",
|
| 93 |
+
duration: "ISO працягласць",
|
| 94 |
+
ipv4: "IPv4 адрас",
|
| 95 |
+
ipv6: "IPv6 адрас",
|
| 96 |
+
cidrv4: "IPv4 дыяпазон",
|
| 97 |
+
cidrv6: "IPv6 дыяпазон",
|
| 98 |
+
base64: "радок у фармаце base64",
|
| 99 |
+
base64url: "радок у фармаце base64url",
|
| 100 |
+
json_string: "JSON радок",
|
| 101 |
+
e164: "нумар E.164",
|
| 102 |
+
jwt: "JWT",
|
| 103 |
+
template_literal: "увод",
|
| 104 |
+
};
|
| 105 |
+
return (issue) => {
|
| 106 |
+
switch (issue.code) {
|
| 107 |
+
case "invalid_type":
|
| 108 |
+
return `Няправільны ўвод: чакаўся ${issue.expected}, атрымана ${parsedType(issue.input)}`;
|
| 109 |
+
case "invalid_value":
|
| 110 |
+
if (issue.values.length === 1)
|
| 111 |
+
return `Няправільны ўвод: чакалася ${util.stringifyPrimitive(issue.values[0])}`;
|
| 112 |
+
return `Няправільны варыянт: чакаўся адзін з ${util.joinValues(issue.values, "|")}`;
|
| 113 |
+
case "too_big": {
|
| 114 |
+
const adj = issue.inclusive ? "<=" : "<";
|
| 115 |
+
const sizing = getSizing(issue.origin);
|
| 116 |
+
if (sizing) {
|
| 117 |
+
const maxValue = Number(issue.maximum);
|
| 118 |
+
const unit = getBelarusianPlural(maxValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
|
| 119 |
+
return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна ${sizing.verb} ${adj}${issue.maximum.toString()} ${unit}`;
|
| 120 |
+
}
|
| 121 |
+
return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна быць ${adj}${issue.maximum.toString()}`;
|
| 122 |
+
}
|
| 123 |
+
case "too_small": {
|
| 124 |
+
const adj = issue.inclusive ? ">=" : ">";
|
| 125 |
+
const sizing = getSizing(issue.origin);
|
| 126 |
+
if (sizing) {
|
| 127 |
+
const minValue = Number(issue.minimum);
|
| 128 |
+
const unit = getBelarusianPlural(minValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
|
| 129 |
+
return `Занадта малы: чакалася, што ${issue.origin} павінна ${sizing.verb} ${adj}${issue.minimum.toString()} ${unit}`;
|
| 130 |
+
}
|
| 131 |
+
return `Занадта малы: чакалася, што ${issue.origin} павінна быць ${adj}${issue.minimum.toString()}`;
|
| 132 |
+
}
|
| 133 |
+
case "invalid_format": {
|
| 134 |
+
const _issue = issue;
|
| 135 |
+
if (_issue.format === "starts_with")
|
| 136 |
+
return `Няправільны радок: павінен пачынацца з "${_issue.prefix}"`;
|
| 137 |
+
if (_issue.format === "ends_with")
|
| 138 |
+
return `Няправільны радок: павінен заканчвацца на "${_issue.suffix}"`;
|
| 139 |
+
if (_issue.format === "includes")
|
| 140 |
+
return `Няправільны радок: павінен змяшчаць "${_issue.includes}"`;
|
| 141 |
+
if (_issue.format === "regex")
|
| 142 |
+
return `Няправільны радок: павінен адпавядаць шаблону ${_issue.pattern}`;
|
| 143 |
+
return `Няправільны ${Nouns[_issue.format] ?? issue.format}`;
|
| 144 |
+
}
|
| 145 |
+
case "not_multiple_of":
|
| 146 |
+
return `Няправільны лік: павінен быць кратным ${issue.divisor}`;
|
| 147 |
+
case "unrecognized_keys":
|
| 148 |
+
return `Нераспазнаны ${issue.keys.length > 1 ? "ключы" : "ключ"}: ${util.joinValues(issue.keys, ", ")}`;
|
| 149 |
+
case "invalid_key":
|
| 150 |
+
return `Няправільны ключ у ${issue.origin}`;
|
| 151 |
+
case "invalid_union":
|
| 152 |
+
return "Няправільны ўвод";
|
| 153 |
+
case "invalid_element":
|
| 154 |
+
return `Няправільнае значэнне ў ${issue.origin}`;
|
| 155 |
+
default:
|
| 156 |
+
return `Няправільны ўвод`;
|
| 157 |
+
}
|
| 158 |
+
};
|
| 159 |
+
};
|
| 160 |
+
export default function () {
|
| 161 |
+
return {
|
| 162 |
+
localeError: error(),
|
| 163 |
+
};
|
| 164 |
+
}
|