diff --git a/node_modules/zod-to-json-schema/.github/CR_logotype-full-color.png b/node_modules/zod-to-json-schema/.github/CR_logotype-full-color.png new file mode 100644 index 0000000000000000000000000000000000000000..c6bd7efd3dcc31dc9a0000194c8b3a8369bb764b Binary files /dev/null and b/node_modules/zod-to-json-schema/.github/CR_logotype-full-color.png differ diff --git a/node_modules/zod-to-json-schema/.github/FUNDING.yml b/node_modules/zod-to-json-schema/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..cce355c092d231a5ca4e1ef3365a1770334fc88d --- /dev/null +++ b/node_modules/zod-to-json-schema/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [StefanTerdell] diff --git a/node_modules/zod-to-json-schema/.prettierrc.json b/node_modules/zod-to-json-schema/.prettierrc.json new file mode 100644 index 0000000000000000000000000000000000000000..0967ef424bce6791893e9a57bb952f80fd536e93 --- /dev/null +++ b/node_modules/zod-to-json-schema/.prettierrc.json @@ -0,0 +1 @@ +{} diff --git a/node_modules/zod-to-json-schema/LICENSE b/node_modules/zod-to-json-schema/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..406daaf2d775f8a620662ea0dc5ed70e0f5668bf --- /dev/null +++ b/node_modules/zod-to-json-schema/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2020, Stefan Terdell + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file diff --git a/node_modules/zod-to-json-schema/README.md b/node_modules/zod-to-json-schema/README.md new file mode 100644 index 0000000000000000000000000000000000000000..57bc4ba1a98eb3f7fba2dc5790d5d0f01575c1fd --- /dev/null +++ b/node_modules/zod-to-json-schema/README.md @@ -0,0 +1,390 @@ +# Zod to Json Schema + +[![NPM Version](https://img.shields.io/npm/v/zod-to-json-schema.svg)](https://npmjs.org/package/zod-to-json-schema) +[![NPM Downloads](https://img.shields.io/npm/dw/zod-to-json-schema.svg)](https://npmjs.org/package/zod-to-json-schema) + +## Notice of deprecation + +As of November 2025, this project will no longer be actively maintained. [Zod v4 natively supports generating JSON schemas](https://zod.dev/json-schema#ztojsonschema), so I recommend you switch to the new major. + +Thank you to all the contributors and sponsors throughout the years! So long, and thanks for all the fish. + +## Summary + +Does what it says on the tin; converts [Zod schemas](https://github.com/colinhacks/zod) into [JSON schemas](https://json-schema.org/)! + +- Supports all relevant schema types, basic string, number and array length validations and string patterns. +- Resolves recursive and recurring schemas with internal `$ref`s. +- Supports targeting legacy Open API 3.0 specification (3.1 supports regular Json Schema). +- Supports Open AI strict mode schemas (Optional object properties are replaced with required but nullable ones). +- As of v3.25 you can use Zod v4 as a peer-dependency, so long as you still provide v3-schemas. + +_Looking for the exact opposite? Check out [json-schema-to-zod](https://npmjs.org/package/json-schema-to-zod)_ + +## Sponsors + +As this project will no longer be receiving updates I am no longer accepting new partnerships. Huge shout-out to CodeRabbit for keeping it real to the end <3 + + + + + +
+

+

+

+ + + + CodeRabbit logo + + +
+
+ Cut code review time & bugs in half +
+ coderabbit.ai +

+

+
+ +## Usage + +### Basic example + +```typescript +import { z } from "zod"; // Or, using v3.25 or v4, "zod/v3" +import { zodToJsonSchema } from "zod-to-json-schema"; + +const mySchema = z + .object({ + myString: z.string().min(5), + myUnion: z.union([z.number(), z.boolean()]), + }) + .describe("My neat object schema"); + +const jsonSchema = zodToJsonSchema(mySchema, "mySchema"); +``` + +#### Expected output + +```json +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$ref": "#/definitions/mySchema", + "definitions": { + "mySchema": { + "description": "My neat object schema", + "type": "object", + "properties": { + "myString": { + "type": "string", + "minLength": 5 + }, + "myUnion": { + "type": ["number", "boolean"] + } + }, + "additionalProperties": false, + "required": ["myString", "myUnion"] + } + } +} +``` + +## Options + +### Schema name + +You can pass a string as the second parameter of the main zodToJsonSchema function. If you do, your schema will end up inside a definitions object property on the root and referenced from there. Alternatively, you can pass the name as the `name` property of the options object (see below). + +### Options object + +Instead of the schema name (or nothing), you can pass an options object as the second parameter. The following options are available: + +| Option | Effect | +| ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **name**?: _string_ | As described above. | +| **nameStrategy**?: "ref" \| "title" | Adds name as "title" meta instead of as a ref as described above | +| **basePath**?: string[] | The base path of the root reference builder. Defaults to ["#"]. | +| **$refStrategy**?: "root" \| "relative" \| "seen" \| "none" | The reference builder strategy; Defaults to "root". | +| **effectStrategy**?: "input" \| "any" | The effects output strategy. Defaults to "input". _See known issues!_ | +| **dateStrategy**?: "format:date" \| "format:date-time" \| "string" \| "integer" | Date strategy, integer allow to specify in unix-time min and max values. "format:date" creates a string schema with format: "date". "format:date-time" creates a string schema with format: "date-time". "string" is intepreted as "format:date-time". "integer" creates an integer schema with format "unix-time" (unless target "openApi3" is used min max checks are also respected) | +| | +| **emailStrategy**?: "format:email" \| "format:idn-email" \| "pattern:zod" | Choose how to handle the email string check. Defaults to "format:email". | +| **base64Strategy**?: "format:binary" \| "contentEnconding:base64" \| "pattern:zod" | Choose how to handle the base64 string check. Defaults to "contentEncoding:base64" as described [here](https://json-schema.org/understanding-json-schema/reference/non_json_data#contentencoding). Note that "format:binary" is not represented in the output type as it's not part of the JSON Schema spec and only intended to be used when targeting OpenAPI 3.0. Later versions of OpenAPI support contentEncoding. | +| **definitionPath**?: "definitions" \| "$defs" | The name of the definitions property when name is passed. Defaults to "definitions". | +| **target**?: "jsonSchema7" \| "jsonSchema2019-09" \| "openApi3" \| "openAi" | Which spec to target. Defaults to "jsonSchema7" | +| **strictUnions**?: boolean | Scrubs unions of any-like json schemas, like `{}` or `true`. Multiple zod types may result in these out of necessity, such as z.instanceof() | +| **definitions**?: Record | See separate section below | +| **errorMessages**?: boolean | Include custom error messages created via chained function checks for supported zod types. See section below | +| **markdownDescription**?: boolean | Copies the `description` meta to `markdownDescription` | +| **patternStrategy**?: "escape" \| "preserve" | The Zod string validations `.includes()`, `.startsWith()`, and `.endsWith()` must be converted to regex to be compatible with JSON Schema's `pattern`. For safety, all non-alphanumeric characters are `escape`d by default (consider `z.string().includes(".")`), but this can occasionally cause problems with Unicode-flagged regex parsers. Use `preserve` to prevent this escaping behaviour and preserve the exact string written, even if it results in an inaccurate regex. | +| **applyRegexFlags**?: boolean | JSON Schema's `pattern` doesn't support RegExp flags, but Zod's `z.string().regex()` does. When this option is true (default false), a best-effort is made to transform regexes into a flag-independent form (e.g. `/x/i => /[xX]/` ). Supported flags: `i` (basic Latin only), `m`, `s`. | +| **pipeStrategy**?: "all" \| "input" \| "output" | Decide which types should be included when using `z.pipe`, for example `z.string().pipe(z.number())` would return both `string` and `number` by default, only `string` for "input" and only `number` for "output". | +| **removeAdditionalStrategy**?: "passthrough" \| "strict" | Decide when `additionalProperties` should be allowed. See the section on additional properties for details. | +| **allowedAdditionalProperties**?: `true` \| `undefined` | What value to give `additionalProperties` when allowed. See the section on additional properties for details. | +| **rejectedAdditionalProperties**?: `false` \| `undefined` | What value to give `additionalProperties` when rejected. See the section on additional properties for details. | +| **override**?: callback | See section | +| **postProcess**?: callback | See section | +| **openAiAnyTypeName**?: string | Decides the name of a Json schema used to allow semi-arbitrary values in Open AI structured output. If any value in the Zod-schema resolves to any "any"-type schema it will reference a definition of this name. If no such definition is provided a default Json schema will be used. Defaults to "OpenAiAnyType" | + +### Definitions + +The definitions option lets you manually add recurring schemas into definitions for cleaner outputs. It's fully compatible with named schemas, changed definitions path and base path. Here's a simple example: + +```typescript +const myRecurringSchema = z.string(); +const myObjectSchema = z.object({ a: myRecurringSchema, b: myRecurringSchema }); + +const myJsonSchema = zodToJsonSchema(myObjectSchema, { + definitions: { myRecurringSchema }, +}); +``` + +#### Result + +```json +{ + "type": "object", + "properties": { + "a": { + "$ref": "#/definitions/myRecurringSchema" + }, + "b": { + "$ref": "#/definitions/myRecurringSchema" + } + }, + "definitions": { + "myRecurringSchema": { + "type": "string" + } + } +} +``` + +### Error Messages + +This feature allows optionally including error messages created via chained function calls for supported zod types: + +```ts +// string schema with additional chained function call checks +const EmailSchema = z.string().email("Invalid email").min(5, "Too short"); + +const jsonSchema = zodToJsonSchema(EmailSchema, { errorMessages: true }); +``` + +#### Result + +```json +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "string", + "format": "email", + "minLength": 5, + "errorMessage": { + "format": "Invalid email", + "minLength": "Too short" + } +} +``` + +This allows for field specific, validation step specific error messages which can be useful for building forms and such. This format is accepted by `react-hook-form`'s ajv resolver (and therefor `ajv-errors` which it uses under the hood). Note that if using AJV with this format will require [enabling `ajv-errors`](https://ajv.js.org/packages/ajv-errors.html#usage) as vanilla AJV does not accept this format by default. + +#### Custom Error Message Support + +- ZodString + - regex + - min, max + - email, cuid, uuid, url + - endsWith, startsWith +- ZodNumber + - min, max, lt, lte, gt, gte, + - int + - multipleOf +- ZodSet + - min, max +- ZodArray + - min, max + +### Additional properties + +By default, Zod removes undeclared properties when parsing object schemas. In order to replicate the expected output of this behaviour, the default for behaviour of zodToJsonSchema is to set `"additionalProperties"` to `false` (although the correctness of this can be debated). If you wish to allow undeclared properties you can either: + +- Set `removeAdditionalStrategy` to `"strict"`. This will allow additional properties for any object schema that is not declared with `.strict()`. +- Leave `removeAdditionalStrategy` set to its default value of `"passthrough"`, and add `.passtrough()` to your object schema. + +#### Removing the `additionalProperties` keyword using the `allowedAdditionalProperties` and/or `rejectedAdditionalProperties` options. + +Some schema definitions (like Googles Gen AI API for instance) does not allow the `additionalProperties` keyword at all. Luckily the JSON Schema spec allows for this: leaving the keyword undefined _should_ have the same effect as setting it to true (as per usual YMMV). To enable this behaviour, set the option `allowedAdditionalProperties` to `undefined`. + +To exclude the keyword even when additional properties are _not_ allowed, set the `rejectedAdditionalProperties` to `undefined` as well. + +_Heads up ⚠️: Both of these options will be ignored if your schema is declared with `.catchall(...)` as the provided schema will be used instead (if valid)._ + +#### Expected outputs + +| `z.object({})` + option | `"additionalProperties"` value | +| ------------------------- | ----------------------------------------------------------- | +| `.strip()` (default) | `false` if strategy is `"passtrough"`, `true` if `"strict"` | +| `.passtrough()` | `true` | +| `.strict()` | `false` | +| `.catchall(z.string())` | `{ "type": "string" }` | +| `.catchall(z.function())` | `undefined` (function schemas are not currently parseable) | + +Substitute `true` and `false` for `undefined` according to `allowedAdditionalProperties` and/or `rejectedAdditionalProperties` respectively. + +### `override` + +This options takes a callback receiving a Zod schema definition, the current reference object (containing the current ref path and other options), an argument containing inforation about wether or not the schema has been encountered before, and a forceResolution argument. + +Important: if you don't want to override the current item you have to return the `ignoreOverride` symbol exported from the index. This is because `undefined` is a valid option to return when you want the property to be excluded from the resulting JSON schema. + +```typescript +import zodToJsonSchema, { ignoreOverride } from "zod-to-json-schema"; + +zodToJsonSchema( + z.object({ + ignoreThis: z.string(), + overrideThis: z.string(), + removeThis: z.string(), + }), + { + override: (def, refs) => { + const path = refs.currentPath.join("/"); + + if (path === "#/properties/overrideThis") { + return { + type: "integer", + }; + } + + if (path === "#/properties/removeThis") { + return undefined; + } + + // Important! Do not return `undefined` or void unless you want to remove the property from the resulting schema completely. + return ignoreOverride; + }, + }, +); +``` + +Expected output: + +```json +{ + "type": "object", + "required": ["ignoreThis", "overrideThis"], + "properties": { + "ignoreThis": { + "type": "string" + }, + "overrideThis": { + "type": "integer" + } + }, + "additionalProperties": false +} +``` + +### `postProcess` + +Besided receiving all arguments of the `override` callback, the `postProcess` callback also receives the generated schema. It should always return a JSON Schema, or `undefined` if you wish to filter it out. Unlike the `override` callback you do not have to return `ignoreOverride` if you are happy with the produced schema; simply return it unchanged. + +```typescript +import zodToJsonSchema, { PostProcessCallback } from "zod-to-json-schema"; + +// Define the callback to be used to process the output using the PostProcessCallback type: +const postProcess: PostProcessCallback = ( + // The original output produced by the package itself: + jsonSchema, + // The ZodSchema def used to produce the original schema: + def, + // The refs object containing the current path, passed options, etc. + refs, +) => { + if (!jsonSchema) { + return jsonSchema; + } + + // Try to expand description as JSON meta: + if (jsonSchema.description) { + try { + jsonSchema = { + ...jsonSchema, + ...JSON.parse(jsonSchema.description), + }; + } catch {} + } + + // Make all numbers nullable: + if ("type" in jsonSchema! && jsonSchema.type === "number") { + jsonSchema.type = ["number", "null"]; + } + + // Add the refs path, just because + (jsonSchema as any).path = refs.currentPath; + + return jsonSchema; +}; + +const jsonSchema = zodToJsonSchema(zodSchema, { postProcess }); +``` + +#### Using `postProcess` for including examples and other meta + +Adding support for examples and other JSON Schema meta keys are among the most commonly requested features for this project. Unfortunately the current Zod major (3) has pretty anemic support for this, so some userland hacking is required. Since this is such a common usecase I've included a helper function that simply tries to parse any description as JSON and expand it into the resulting schema. + +Simply stringify whatever you want added to the output schema as the description, then import and use `jsonDescription` as the postProcess option: + +```typescript +import zodToJsonSchema, { jsonDescription } from "zod-to-json-schema"; + +const zodSchema = z.string().describe( + JSON.stringify({ + title: "My string", + description: "My description", + examples: ["Foo", "Bar"], + whatever: 123, + }), +); + +const jsonSchema = zodToJsonSchema(zodSchema, { + postProcess: jsonDescription, +}); +``` + +Expected output: + +```json +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "string", + "title": "My string", + "description": "My description", + "examples": ["Foo", "Bar"], + "whatever": 123 +} +``` + +## Known issues + +- The OpenAI target should be considered experimental for now, as some combination of options may break the compatibility. +- When using `.transform`, the return type is inferred from the supplied function. In other words, there is no schema for the return type, and there is no way to convert it in runtime. Currently the JSON schema will therefore reflect the input side of the Zod schema and not necessarily the output (the latter aka. `z.infer`). If this causes problems with your schema, consider using the effectStrategy "any", which will allow any type of output. +- JSON Schemas does not support any other key type than strings for objects. When using `z.record` with any other key type, this will be ignored. An exception to this rule is `z.enum` as is supported since 3.11.3 +- Relative JSON pointers, while published alongside [JSON schema draft 2020-12](https://json-schema.org/specification.html), is not technically a part of it. Currently, most resolvers do not handle them at all. +- Since v3, the Object parser uses `.isOptional()` to check if a property should be included in `required` or not. This has the potentially dangerous behavior of calling `.safeParse` with `undefined`. To work around this, make sure your `preprocess` and other effects callbacks are pure and not liable to throw errors. An issue has been logged in the Zod repo and can be [tracked here](https://github.com/colinhacks/zod/issues/1460). +- JSON Schema version 2020-12 is not yet officially supported. However, you should be able to use this library to obtain a compatible schema for the 2020-12 format just by changing the returned schema's `$schema` field to: "https://json-schema.org/draft/2020-12/schema#" + +## Versioning + +This package _does not_ follow semantic versioning. The major and minor versions of this package instead reflects feature parity with the [Zod package](http://npmjs.com/package/zod). + +I will do my best to keep API-breaking changes to an absolute minimum, but new features may appear as "patches", such as introducing the options pattern in 3.9.1. + +While v3.25 supports Zod v4 as a peer-dependency, it does _not_ mean it supports v4 schemas. Use `import { z } from "zod/v3"` and refer to the Zod documentation. + +## Changelog + +https://github.com/StefanTerdell/zod-to-json-schema/blob/master/changelog.md diff --git a/node_modules/zod-to-json-schema/changelog.md b/node_modules/zod-to-json-schema/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..da0e94dae1b8fbfbe4492f3d87314dda72d63475 --- /dev/null +++ b/node_modules/zod-to-json-schema/changelog.md @@ -0,0 +1,83 @@ +# Changelog + +| Version | Change | +| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 3.25.2 | Bumps the peer dependency of Zod 3 to 3.25.28 - Versions before patch 13 caused [OOM issues](https://github.com/StefanTerdell/zod-to-json-schema/issues/185) and versions between that and 28 removed the /v3 import alias. | +| 3.25.1 | Fixes large install size due to accidental inclusion of test files. Thanks, [Felix Mosheev](https://github.com/felixmosh)! | +| 3.25.0 | Adds support for v3.25 and v3 through v4 (`import { z } from "zod/v3"`). Big thank you to both [Andrey Gubanovs](https://github.com/finom) and especially to [Faïz Hernawan Abdillah](https://github.com/Abdillah), whose more minimal implementation was merged. This will likely be the final release of `zod-to-json-schema`, as v4 now supports JSON schema natively. | +| 3.24.6 | Removed use of instanceOf to check for optional properties as differing package versions could produce intermittent bugs. Added OpenAiAnyType to work around their schema restrictions. | +| 3.24.5 | Update .npmignore to drop 2 mb of test files. Thanks [Misha Kaletsky](https://github.com/mmkal)! | +| 3.24.4 | Added options to set the value of additionalProperties in objects and record | +| 3.24.3 | Adds postProcess callback option | +| 3.24.2 | Restructured internals to remove circular dependencies which apparently might cause some build systems to whine a bit. Big thanks to [Víctor Hernández](https://github.com/NanezX) for the fix. | +| 3.24.1 | Adds OpenAI target | +| 3.24.0 | Implements new string checks (jwt, base64url, cidr ipv4/v6), matching the new Zod version | +| 3.23.5 | Module import hotfix by [Enzo Monjardín](https://github.com/enzomonjardin). Thanks! | +| 3.23.4 | Fixes branded regex property names and a weird edgecase in arrays. Thanks to [Isaiah Marc Sanchez](https://github.com/imsanchez) and [Mitchell Merry](https://github.com/mitchell-merry)! | +| 3.23.3 | More tests (Thanks [Brett Zamir!](https://github.com/brettz9)), removed dead code | +| 3.23.2 | Lazily loads Emoji regex to avoid incompatibility with some environments. Thanks [Jacob Lee](https://github.com/jacoblee93)! | +| 3.23.1 | Best-effort RegEx flag support by [Spappz](https://github.com/Spappz)! Some minor fixes and additions, such as the title option. | +| 3.23.0 | Adds support for base64, date, time, duration and nanoid string validations. A warm welcome and a big thanks to [Colin](https://www.github.com/colinhacks), the creator of Zod, joining in as a contributor :) | +| 3.22.5 | Adds new z.date() parsing options and override callback | +| 3.22.4 | Adds fix for nullable references in OpenAPI mode | +| 3.22.3 | Adjust root path from "#/" to "#" according to RFC 6901 | +| 3.22.2 | Adds "output" pipe strategy | +| 3.22.1 | Fixes broken imports when using some bundlers | +| 3.22.0 | Support readonly. Export both CJS and ESM. Export everything from index. Alternative map parser. Improved pattern handling and updated sources. | +| 3.21.4 | Fixes missing support for exact array length | +| 3.21.3 | Fixes issue #77 (Reference path to nullable schemas in Open-API mode) | +| 3.21.2 | Adds "integer" type Date output to support min/max checks, markdownDescription option, fixes "none" refStrategy by adding "seen" and adds an option to use "pattern" with Zods' email enum instead of "format". | +| 3.21.1 | New target (2019-09) along with improved intersection schemas, improved mutual recursion references in definitions, descriptions respected in union parser and not removed in collapsed | +| 3.21.0 | Added new string validations (ip, emoji, etc) and BigInt checks to support Zod 3.21 | +| 3.20.5 | Added uniqueItems to Set and an option to disregard pipe schemas | +| 3.20.4 | Bugfixes and improved record parsing for openApi3 | +| 3.20.3 | Added Cuid2 support introduced in Zod 3.20.3 | +| 3.20.2 | Reintroduced conditional simplified return-type for when target is OpenAPI 3 | +| 3.20.1 | Fixed inconsistent casing in imports | +| 3.20.0 | Adds support for Zod 3.20 with catch and pipe parser as well as new string validations. Refactored Ref handling; adding definitions no longer considered experimental. Main API function refactored and simplified; output type less defined but a lot easier to maintain. Doubt anyone will miss it.
Narrator: Someone did in fact miss it | +| 3.19.4 | Adds custom error message support | +| 3.19.3 | Mark `definitions` as experimental in the readme | +| 3.19.2 | Added `definitions` option | +| 3.19.1 | Strict unions fix | +| 3.19.0 | No new features added in Zod, parity bump | +| 3.18.2 | Fixes support for native enums | +| 3.18.1 | Add strictUnions options | +| 3.18.0 | Added support for branded types | +| 3.17.2 | Fix for reference paths when supplying name option string. | +| 3.17.1 | Added startsWith and endsWith string checks. Merge multiple pattern checks into allOf array. | +| 3.17.0 | Added switch case handler for new trim "check". No changes to functionality. | +| 3.15.x - 3.16.x | Skipped: Did not change the Zod API in any way relevant for this package. | +| 3.14.1 | Dependabot security updates | +| 3.14.0 | Moves Zod into peerDependencies. Supports checks for sets, NaN-type (sort of), discriminated union type and standalone optional properties (as unions with undefined) | +| 3.12.x - 3.13.x | Skipped | +| 3.11.3 | Joins unions of enums into single enum and allows enums as keys of records | +| 3.11.2 | Adds option to target Open API 3 spec (paths) instead of Json Schema 7. | +| 3.11.1 | Performance boost when using $refStrategy `none` and internal improvements. | +| 3.11.0 | Added description support introduced in Zod 3.11.5 | +| 3.10.x | Skipped: Minor 10 did not change the Zod API | +| 3.9.5 | Type bug fix: used dev dependency types in package | +| 3.9.4 | Path bug fix and test case when using optional definitions path | +| 3.9.3 | Added option to change definition property name to $defs | +| 3.9.2 | Added option to handle transform results as any instead of relying on their input schema. | +| 3.9.1 | Refactored the way reference pointers are passed around and added options pattern to main function without braking backwards compatibility! You can now add a base path, change the reference strategy (or opt out), and still set the schema name inside the options object or outside as before. | +| 3.9.0 | Added support for multipleOf number validaion, .rest() schemas for tuples and key validation for records (only compatible with string keys due to JSON Schema limitation). | +| 3.7.x - 3.8.x | Skipped to reach functional parity with Zod versioning. | +| 3.6.1 | Realised intersection had another potential ref pathing bug. Fixed. | +| 3.6.0 | Added support for default & effects (refine). Broke out changelog.md | +| 3.5.0 | Added support for CUID string validation | +| 3.4.3 | Fixed $ref pathing for catchall and intersection. Additional tests and code structure fixes. | +| 3.4.2 | Fixed broken intersection parser (Thanks [Noah2610](https://github.com/Noah2610)!) | +| 3.4.1 | Fixed pathing bug for nullable items. | +| 3.4.0 | Added support for z.lazy() | +| 3.3.0 | Added support for catchall (additionalProperties schema on objects). Rebuilt object parser. | +| 3.2.0 | Added support for Map and Set as seen by their most common JSON definitions. Beware no standardized definition seem to exist and JSON.parse doesn't handle either natively. Their implementations here are based on the spread approach. Also further simplified intersection definition to just allOf. | +| 3.1.0 | String patterns finally supported! Fixed bugs include broken external type, unsafe nullable parsing, bad intersection implementation, and missing support for passthrough keys in objects. | +| 3.0.3 | Fixed array deep pathing bug (path contained `array` instead of `items`) | +| 3.0.2 | Fixed broken type usage (NonEmptyArrayDefinition was removed from Zod) | +| 3.0.1 | Fixed a typo in the readme | +| 3.0.0 | Compatible with Zod 3.2.0. Huge props to [Mr Hammad Asif](https://github.com/mrhammadasif) for his work on this. | +| 0.6.2 | Hotfix for undefined object properties. Could crash the parser when using Pick | +| 0.6.1 | Fixed bug in union pathing. `$Ref` was missing `/anyOf` | +| 0.6.0 | Moved `@types/json-schema` and `typescript` to dev dependencies. `@types/json-schema` is now only used for the test suites. Using `strict: true` in ts config. | +| 0.5.1 | First working release with all relevant Zod types present with most validations (except for string patterns due to Zod not exposing the source regexp pattern for those). | +| < 0.5.1 | Deprecated due to broken package structure. Please be patient, I eat crayons. | diff --git a/node_modules/zod-to-json-schema/contributing.md b/node_modules/zod-to-json-schema/contributing.md new file mode 100644 index 0000000000000000000000000000000000000000..c8b4717f8c2e45bfaa6ad51c178b61b3b7b6b5ae --- /dev/null +++ b/node_modules/zod-to-json-schema/contributing.md @@ -0,0 +1,9 @@ +# Contributing + +Hey, thanks for wanting to contribute. + +Before you open a PR, make sure to open an issue and discuss the problem you want to solve. I will not consider PRs without issues. + +I use [gitmoji](https://gitmoji.dev/) for my commit messages because I think it's fun. I encourage you to do the same, but won't enforce it. + +I check PRs and issues very rarely so please be patient. diff --git a/node_modules/zod-to-json-schema/createIndex.ts b/node_modules/zod-to-json-schema/createIndex.ts new file mode 100644 index 0000000000000000000000000000000000000000..d126fcae543b9a3271c8952e81533e33417af79e --- /dev/null +++ b/node_modules/zod-to-json-schema/createIndex.ts @@ -0,0 +1,32 @@ +import { readdirSync, writeFileSync, statSync } from "fs"; + +const ignore = ["src/index.ts"]; + +function checkSrcDir(path: string): string[] { + const lines: string[] = []; + + for (const item of readdirSync(path)) { + const itemPath = path + "/" + item; + + if (ignore.includes(itemPath)) { + continue; + } + + if (statSync(itemPath).isDirectory()) { + lines.push(...checkSrcDir(itemPath)); + } else if (item.endsWith(".ts")) { + lines.push('export * from "./' + itemPath.slice(4, -2) + 'js"'); + } + } + + return lines; +} + +const lines = checkSrcDir("src"); + +lines.push( + 'import { zodToJsonSchema } from "./zodToJsonSchema.js"', + "export default zodToJsonSchema;", +); + +writeFileSync("./src/index.ts", lines.join(";\n")); diff --git a/node_modules/zod-to-json-schema/package.json b/node_modules/zod-to-json-schema/package.json new file mode 100644 index 0000000000000000000000000000000000000000..75b3274a2624d7786ba8f6e7b250c15a2aa8311f --- /dev/null +++ b/node_modules/zod-to-json-schema/package.json @@ -0,0 +1,85 @@ +{ + "name": "zod-to-json-schema", + "version": "3.25.2", + "description": "Converts Zod schemas to Json Schemas", + "types": "./dist/types/index.d.ts", + "main": "./dist/cjs/index.js", + "module": "./dist/esm/index.js", + "exports": { + "import": { + "types": "./dist/types/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/types/index.d.ts", + "default": "./dist/cjs/index.js" + } + }, + "scripts": { + "build:test": "npm --prefix ./dist-test-v3 test && npm --prefix ./dist-test-v4 test", + "build:types": "tsc -p tsconfig.types.json", + "build:cjs": "tsc -p tsconfig.cjs.json && tsx postcjs.ts", + "build:esm": "tsc -p tsconfig.esm.json && tsx postesm.ts", + "build": "npm i && npm run gen && npm test && rimraf ./dist && npm run build:types && npm run build:cjs && npm run build:esm && npm run build:test", + "dry": "npm run build && npm pub --dry-run", + "test:watch": "tsx watch test/index.ts", + "test:gen": "tsx test/createIndex.ts", + "test": "tsx test/index.ts", + "gen": "tsx createIndex.ts" + }, + "keywords": [ + "zod", + "json", + "schema", + "open", + "api", + "conversion" + ], + "author": "Stefan Terdell", + "contributors": [ + "Hammad Asif (https://github.com/mrhammadasif)", + "Noah Rosenzweig (https://github.com/Noah2610)", + "John Wright (https://github.com/johngeorgewright)", + "Krzysztof Ciombor (https://github.com/krzysztofciombor)", + "Yuta Mombetsu (https://github.com/mokocm)", + "Tom Arad (https://github.com/tomarad)", + "Isaac Way (https://github.com/iway1)", + "Andreas Berger (https://github.com/Andy2003)", + "Jan Potoms (https://github.com/Janpot)", + "Santiago Cammi (https://github.com/scammi)", + "Philipp Burckhardt (https://github.com/Planeshifter)", + "Bram del Canho (https://github.com/Bram-dc)", + "Gilad Hecht (https://github.com/gthecht)", + "Colin McDonnell (https://github.com/colinhacks)", + "Spappz (https://github.com/Spappz)", + "Jacob Lee (https://github.com/jacoblee93)", + "Brett Zamir (https://github.com/brettz9)", + "Isaiah Marc Sanchez (https://github.com/imsanchez)", + "Mitchell Merry (https://github.com/mitchell-merry)", + "Enzo Monjardín (https://github.com/enzomonjardin)", + "Víctor Hernández (https://github.com/NanezX)", + "Faïz Hernawan Abdillah (https://github.com/Abdillah)", + "Felix Mosheev (https://github.com/felixmosh)" + ], + "repository": { + "type": "git", + "url": "https://github.com/StefanTerdell/zod-to-json-schema" + }, + "license": "ISC", + "peerDependencies": { + "zod": "^3.25.28 || ^4" + }, + "devDependencies": { + "@types/json-schema": "^7.0.9", + "@types/node": "^20.9.0", + "ajv": "^8.6.3", + "ajv-errors": "^3.0.0", + "ajv-formats": "^2.1.1", + "fast-diff": "^1.3.0", + "local-ref-resolver": "^0.2.0", + "rimraf": "^6.1.3", + "tsx": "^4.19.0", + "typescript": "^5.1.3", + "zod": "^3.25.28 || ^4" + } +} diff --git a/node_modules/zod-to-json-schema/postcjs.ts b/node_modules/zod-to-json-schema/postcjs.ts new file mode 100644 index 0000000000000000000000000000000000000000..57c29eb60908798cb61c26613d4150cf25e2af20 --- /dev/null +++ b/node_modules/zod-to-json-schema/postcjs.ts @@ -0,0 +1,3 @@ +import { writeFileSync } from "fs"; + +writeFileSync("./dist/cjs/package.json", '{"type":"commonjs"}', "utf-8"); diff --git a/node_modules/zod-to-json-schema/postesm.ts b/node_modules/zod-to-json-schema/postesm.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9a7429fe55f096a22086ab037fc503c6f88344d --- /dev/null +++ b/node_modules/zod-to-json-schema/postesm.ts @@ -0,0 +1,3 @@ +import { writeFileSync } from "fs"; + +writeFileSync("./dist/esm/package.json", '{"type":"module","main":"index.js"}', "utf-8"); diff --git a/node_modules/zod/v4-mini/index.cjs b/node_modules/zod/v4-mini/index.cjs new file mode 100644 index 0000000000000000000000000000000000000000..90a31e2ce84b8341446f7627c304cb6c9e9582b0 --- /dev/null +++ b/node_modules/zod/v4-mini/index.cjs @@ -0,0 +1,32 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.z = void 0; +const z = __importStar(require("../v4/mini/external.cjs")); +exports.z = z; +__exportStar(require("../v4/mini/external.cjs"), exports); diff --git a/node_modules/zod/v4-mini/index.d.cts b/node_modules/zod/v4-mini/index.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..bca69bd601008bc06ec8db3a95dfb78ccf550cd9 --- /dev/null +++ b/node_modules/zod/v4-mini/index.d.cts @@ -0,0 +1,3 @@ +import * as z from "../v4/mini/external.cjs"; +export * from "../v4/mini/external.cjs"; +export { z }; diff --git a/node_modules/zod/v4-mini/index.d.ts b/node_modules/zod/v4-mini/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb95da0a24829980395bc1300b1edcc8474b3dfb --- /dev/null +++ b/node_modules/zod/v4-mini/index.d.ts @@ -0,0 +1,3 @@ +import * as z from "../v4/mini/external.js"; +export * from "../v4/mini/external.js"; +export { z }; diff --git a/node_modules/zod/v4-mini/index.js b/node_modules/zod/v4-mini/index.js new file mode 100644 index 0000000000000000000000000000000000000000..bb95da0a24829980395bc1300b1edcc8474b3dfb --- /dev/null +++ b/node_modules/zod/v4-mini/index.js @@ -0,0 +1,3 @@ +import * as z from "../v4/mini/external.js"; +export * from "../v4/mini/external.js"; +export { z }; diff --git a/node_modules/zod/v4-mini/package.json b/node_modules/zod/v4-mini/package.json new file mode 100644 index 0000000000000000000000000000000000000000..f5d2e90cdae223ed38764ab1d69169a1c54b6661 --- /dev/null +++ b/node_modules/zod/v4-mini/package.json @@ -0,0 +1,7 @@ +{ + "type": "module", + "main": "./index.cjs", + "module": "./index.js", + "types": "./index.d.cts", + "sideEffects": false +} diff --git a/node_modules/zod/v4/core/parse.d.ts b/node_modules/zod/v4/core/parse.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..32b85de568680982a350c15e389689931a630c85 --- /dev/null +++ b/node_modules/zod/v4/core/parse.d.ts @@ -0,0 +1,49 @@ +import * as core from "./core.js"; +import * as errors from "./errors.js"; +import type * as schemas from "./schemas.js"; +import * as util from "./util.js"; +export type $ZodErrorClass = { + new (issues: errors.$ZodIssue[]): errors.$ZodError; +}; +export type $Parse = (schema: T, value: unknown, _ctx?: schemas.ParseContext, _params?: { + callee?: util.AnyFunc; + Err?: $ZodErrorClass; +}) => core.output; +export declare const _parse: (_Err: $ZodErrorClass) => $Parse; +export declare const parse: $Parse; +export type $ParseAsync = (schema: T, value: unknown, _ctx?: schemas.ParseContext, _params?: { + callee?: util.AnyFunc; + Err?: $ZodErrorClass; +}) => Promise>; +export declare const _parseAsync: (_Err: $ZodErrorClass) => $ParseAsync; +export declare const parseAsync: $ParseAsync; +export type $SafeParse = (schema: T, value: unknown, _ctx?: schemas.ParseContext) => util.SafeParseResult>; +export declare const _safeParse: (_Err: $ZodErrorClass) => $SafeParse; +export declare const safeParse: $SafeParse; +export type $SafeParseAsync = (schema: T, value: unknown, _ctx?: schemas.ParseContext) => Promise>>; +export declare const _safeParseAsync: (_Err: $ZodErrorClass) => $SafeParseAsync; +export declare const safeParseAsync: $SafeParseAsync; +export type $Encode = (schema: T, value: core.output, _ctx?: schemas.ParseContext) => core.input; +export declare const _encode: (_Err: $ZodErrorClass) => $Encode; +export declare const encode: $Encode; +export type $Decode = (schema: T, value: core.input, _ctx?: schemas.ParseContext) => core.output; +export declare const _decode: (_Err: $ZodErrorClass) => $Decode; +export declare const decode: $Decode; +export type $EncodeAsync = (schema: T, value: core.output, _ctx?: schemas.ParseContext) => Promise>; +export declare const _encodeAsync: (_Err: $ZodErrorClass) => $EncodeAsync; +export declare const encodeAsync: $EncodeAsync; +export type $DecodeAsync = (schema: T, value: core.input, _ctx?: schemas.ParseContext) => Promise>; +export declare const _decodeAsync: (_Err: $ZodErrorClass) => $DecodeAsync; +export declare const decodeAsync: $DecodeAsync; +export type $SafeEncode = (schema: T, value: core.output, _ctx?: schemas.ParseContext) => util.SafeParseResult>; +export declare const _safeEncode: (_Err: $ZodErrorClass) => $SafeEncode; +export declare const safeEncode: $SafeEncode; +export type $SafeDecode = (schema: T, value: core.input, _ctx?: schemas.ParseContext) => util.SafeParseResult>; +export declare const _safeDecode: (_Err: $ZodErrorClass) => $SafeDecode; +export declare const safeDecode: $SafeDecode; +export type $SafeEncodeAsync = (schema: T, value: core.output, _ctx?: schemas.ParseContext) => Promise>>; +export declare const _safeEncodeAsync: (_Err: $ZodErrorClass) => $SafeEncodeAsync; +export declare const safeEncodeAsync: $SafeEncodeAsync; +export type $SafeDecodeAsync = (schema: T, value: core.input, _ctx?: schemas.ParseContext) => Promise>>; +export declare const _safeDecodeAsync: (_Err: $ZodErrorClass) => $SafeDecodeAsync; +export declare const safeDecodeAsync: $SafeDecodeAsync; diff --git a/node_modules/zod/v4/core/parse.js b/node_modules/zod/v4/core/parse.js new file mode 100644 index 0000000000000000000000000000000000000000..1ba82bad9fe9a600267e9a2b288b941caa5467e7 --- /dev/null +++ b/node_modules/zod/v4/core/parse.js @@ -0,0 +1,93 @@ +import * as core from "./core.js"; +import * as errors from "./errors.js"; +import * as util from "./util.js"; +export const _parse = (_Err) => (schema, value, _ctx, _params) => { + const ctx = _ctx ? { ..._ctx, async: false } : { async: false }; + const result = schema._zod.run({ value, issues: [] }, ctx); + if (result instanceof Promise) { + throw new core.$ZodAsyncError(); + } + if (result.issues.length) { + const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))); + util.captureStackTrace(e, _params?.callee); + throw e; + } + return result.value; +}; +export const parse = /* @__PURE__*/ _parse(errors.$ZodRealError); +export const _parseAsync = (_Err) => async (schema, value, _ctx, params) => { + const ctx = _ctx ? { ..._ctx, async: true } : { async: true }; + let result = schema._zod.run({ value, issues: [] }, ctx); + if (result instanceof Promise) + result = await result; + if (result.issues.length) { + const e = new (params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))); + util.captureStackTrace(e, params?.callee); + throw e; + } + return result.value; +}; +export const parseAsync = /* @__PURE__*/ _parseAsync(errors.$ZodRealError); +export const _safeParse = (_Err) => (schema, value, _ctx) => { + const ctx = _ctx ? { ..._ctx, async: false } : { async: false }; + const result = schema._zod.run({ value, issues: [] }, ctx); + if (result instanceof Promise) { + throw new core.$ZodAsyncError(); + } + return result.issues.length + ? { + success: false, + error: new (_Err ?? errors.$ZodError)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))), + } + : { success: true, data: result.value }; +}; +export const safeParse = /* @__PURE__*/ _safeParse(errors.$ZodRealError); +export const _safeParseAsync = (_Err) => async (schema, value, _ctx) => { + const ctx = _ctx ? { ..._ctx, async: true } : { async: true }; + let result = schema._zod.run({ value, issues: [] }, ctx); + if (result instanceof Promise) + result = await result; + return result.issues.length + ? { + success: false, + error: new _Err(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))), + } + : { success: true, data: result.value }; +}; +export const safeParseAsync = /* @__PURE__*/ _safeParseAsync(errors.$ZodRealError); +export const _encode = (_Err) => (schema, value, _ctx) => { + const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" }; + return _parse(_Err)(schema, value, ctx); +}; +export const encode = /* @__PURE__*/ _encode(errors.$ZodRealError); +export const _decode = (_Err) => (schema, value, _ctx) => { + return _parse(_Err)(schema, value, _ctx); +}; +export const decode = /* @__PURE__*/ _decode(errors.$ZodRealError); +export const _encodeAsync = (_Err) => async (schema, value, _ctx) => { + const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" }; + return _parseAsync(_Err)(schema, value, ctx); +}; +export const encodeAsync = /* @__PURE__*/ _encodeAsync(errors.$ZodRealError); +export const _decodeAsync = (_Err) => async (schema, value, _ctx) => { + return _parseAsync(_Err)(schema, value, _ctx); +}; +export const decodeAsync = /* @__PURE__*/ _decodeAsync(errors.$ZodRealError); +export const _safeEncode = (_Err) => (schema, value, _ctx) => { + const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" }; + return _safeParse(_Err)(schema, value, ctx); +}; +export const safeEncode = /* @__PURE__*/ _safeEncode(errors.$ZodRealError); +export const _safeDecode = (_Err) => (schema, value, _ctx) => { + return _safeParse(_Err)(schema, value, _ctx); +}; +export const safeDecode = /* @__PURE__*/ _safeDecode(errors.$ZodRealError); +export const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => { + const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" }; + return _safeParseAsync(_Err)(schema, value, ctx); +}; +export const safeEncodeAsync = /* @__PURE__*/ _safeEncodeAsync(errors.$ZodRealError); +export const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => { + return _safeParseAsync(_Err)(schema, value, _ctx); +}; +export const safeDecodeAsync = /* @__PURE__*/ _safeDecodeAsync(errors.$ZodRealError); diff --git a/node_modules/zod/v4/core/regexes.cjs b/node_modules/zod/v4/core/regexes.cjs new file mode 100644 index 0000000000000000000000000000000000000000..4c0dfe16d36259e83680869c98f634026dc0842c --- /dev/null +++ b/node_modules/zod/v4/core/regexes.cjs @@ -0,0 +1,172 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.sha256_base64url = exports.sha256_base64 = exports.sha256_hex = exports.sha1_base64url = exports.sha1_base64 = exports.sha1_hex = exports.md5_base64url = exports.md5_base64 = exports.md5_hex = exports.hex = exports.uppercase = exports.lowercase = exports.undefined = exports.null = exports.boolean = exports.number = exports.integer = exports.bigint = exports.string = exports.date = exports.e164 = exports.httpProtocol = exports.domain = exports.hostname = exports.base64url = exports.base64 = exports.cidrv6 = exports.cidrv4 = exports.mac = exports.ipv6 = exports.ipv4 = exports.browserEmail = exports.idnEmail = 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; +exports.sha512_base64url = exports.sha512_base64 = exports.sha512_hex = exports.sha384_base64url = exports.sha384_base64 = exports.sha384_hex = void 0; +exports.emoji = emoji; +exports.time = time; +exports.datetime = datetime; +const util = __importStar(require("./util.cjs")); +/** + * @deprecated CUID v1 is deprecated by its authors due to information leakage + * (timestamps embedded in the id). Use {@link cuid2} instead. + * See https://github.com/paralleldrive/cuid. + */ +exports.cuid = /^[cC][0-9a-z]{6,}$/; +exports.cuid2 = /^[0-9a-z]+$/; +exports.ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/; +exports.xid = /^[0-9a-vA-V]{20}$/; +exports.ksuid = /^[A-Za-z0-9]{27}$/; +exports.nanoid = /^[a-zA-Z0-9_-]{21}$/; +/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */ +exports.duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/; +/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */ +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)?)??$/; +/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */ +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})$/; +/** Returns a regex for validating an RFC 9562/4122 UUID. + * + * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */ +const uuid = (version) => { + if (!version) + return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/; + 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})$`); +}; +exports.uuid = uuid; +exports.uuid4 = (0, exports.uuid)(4); +exports.uuid6 = (0, exports.uuid)(6); +exports.uuid7 = (0, exports.uuid)(7); +/** Practical email validation */ +exports.email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/; +/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */ +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])?)*$/; +/** The classic emailregex.com regex for RFC 5322-compliant emails */ +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,}))$/; +/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */ +exports.unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u; +exports.idnEmail = exports.unicodeEmail; +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])?)*$/; +// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression +const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`; +function emoji() { + return new RegExp(_emoji, "u"); +} +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])$/; +exports.ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/; +const mac = (delimiter) => { + const escapedDelim = util.escapeRegex(delimiter ?? ":"); + return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`); +}; +exports.mac = mac; +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])$/; +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])$/; +// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript +exports.base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/; +exports.base64url = /^[A-Za-z0-9_-]*$/; +// based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address +// export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/; +exports.hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/; +exports.domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/; +exports.httpProtocol = /^https?$/; +// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces) +// E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15 +exports.e164 = /^\+[1-9]\d{6,14}$/; +// 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])))`; +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])))`; +exports.date = new RegExp(`^${dateSource}$`); +function timeSource(args) { + const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`; + const regex = typeof args.precision === "number" + ? args.precision === -1 + ? `${hhmm}` + : args.precision === 0 + ? `${hhmm}:[0-5]\\d` + : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` + : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`; + return regex; +} +function time(args) { + return new RegExp(`^${timeSource(args)}$`); +} +// Adapted from https://stackoverflow.com/a/3143231 +function datetime(args) { + const time = timeSource({ precision: args.precision }); + const opts = ["Z"]; + if (args.local) + opts.push(""); + // if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`); + if (args.offset) + opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`); + const timeRegex = `${time}(?:${opts.join("|")})`; + return new RegExp(`^${dateSource}T(?:${timeRegex})$`); +} +const string = (params) => { + const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`; + return new RegExp(`^${regex}$`); +}; +exports.string = string; +exports.bigint = /^-?\d+n?$/; +exports.integer = /^-?\d+$/; +exports.number = /^-?\d+(?:\.\d+)?$/; +exports.boolean = /^(?:true|false)$/i; +const _null = /^null$/i; +exports.null = _null; +const _undefined = /^undefined$/i; +exports.undefined = _undefined; +// regex for string with no uppercase letters +exports.lowercase = /^[^A-Z]*$/; +// regex for string with no lowercase letters +exports.uppercase = /^[^a-z]*$/; +// regex for hexadecimal strings (any length) +exports.hex = /^[0-9a-fA-F]*$/; +// Hash regexes for different algorithms and encodings +// Helper function to create base64 regex with exact length and padding +function fixedBase64(bodyLength, padding) { + return new RegExp(`^[A-Za-z0-9+/]{${bodyLength}}${padding}$`); +} +// Helper function to create base64url regex with exact length (no padding) +function fixedBase64url(length) { + return new RegExp(`^[A-Za-z0-9_-]{${length}}$`); +} +// MD5 (16 bytes): base64 = 24 chars total (22 + "==") +exports.md5_hex = /^[0-9a-fA-F]{32}$/; +exports.md5_base64 = fixedBase64(22, "=="); +exports.md5_base64url = fixedBase64url(22); +// SHA1 (20 bytes): base64 = 28 chars total (27 + "=") +exports.sha1_hex = /^[0-9a-fA-F]{40}$/; +exports.sha1_base64 = fixedBase64(27, "="); +exports.sha1_base64url = fixedBase64url(27); +// SHA256 (32 bytes): base64 = 44 chars total (43 + "=") +exports.sha256_hex = /^[0-9a-fA-F]{64}$/; +exports.sha256_base64 = fixedBase64(43, "="); +exports.sha256_base64url = fixedBase64url(43); +// SHA384 (48 bytes): base64 = 64 chars total (no padding) +exports.sha384_hex = /^[0-9a-fA-F]{96}$/; +exports.sha384_base64 = fixedBase64(64, ""); +exports.sha384_base64url = fixedBase64url(64); +// SHA512 (64 bytes): base64 = 88 chars total (86 + "==") +exports.sha512_hex = /^[0-9a-fA-F]{128}$/; +exports.sha512_base64 = fixedBase64(86, "=="); +exports.sha512_base64url = fixedBase64url(86); diff --git a/node_modules/zod/v4/core/regexes.d.cts b/node_modules/zod/v4/core/regexes.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..14682662cbc9eef8f29436f2015a1bb2a664b0b5 --- /dev/null +++ b/node_modules/zod/v4/core/regexes.d.cts @@ -0,0 +1,85 @@ +/** + * @deprecated CUID v1 is deprecated by its authors due to information leakage + * (timestamps embedded in the id). Use {@link cuid2} instead. + * See https://github.com/paralleldrive/cuid. + */ +export declare const cuid: RegExp; +export declare const cuid2: RegExp; +export declare const ulid: RegExp; +export declare const xid: RegExp; +export declare const ksuid: RegExp; +export declare const nanoid: RegExp; +/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */ +export declare const duration: RegExp; +/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */ +export declare const extendedDuration: RegExp; +/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */ +export declare const guid: RegExp; +/** Returns a regex for validating an RFC 9562/4122 UUID. + * + * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */ +export declare const uuid: (version?: number | undefined) => RegExp; +export declare const uuid4: RegExp; +export declare const uuid6: RegExp; +export declare const uuid7: RegExp; +/** Practical email validation */ +export declare const email: RegExp; +/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */ +export declare const html5Email: RegExp; +/** The classic emailregex.com regex for RFC 5322-compliant emails */ +export declare const rfc5322Email: RegExp; +/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */ +export declare const unicodeEmail: RegExp; +export declare const idnEmail: RegExp; +export declare const browserEmail: RegExp; +export declare function emoji(): RegExp; +export declare const ipv4: RegExp; +export declare const ipv6: RegExp; +export declare const mac: (delimiter?: string) => RegExp; +export declare const cidrv4: RegExp; +export declare const cidrv6: RegExp; +export declare const base64: RegExp; +export declare const base64url: RegExp; +export declare const hostname: RegExp; +export declare const domain: RegExp; +export declare const httpProtocol: RegExp; +export declare const e164: RegExp; +export declare const date: RegExp; +export declare function time(args: { + precision?: number | null; +}): RegExp; +export declare function datetime(args: { + precision?: number | null; + offset?: boolean; + local?: boolean; +}): RegExp; +export declare const string: (params?: { + minimum?: number | undefined; + maximum?: number | undefined; +}) => RegExp; +export declare const bigint: RegExp; +export declare const integer: RegExp; +export declare const number: RegExp; +export declare const boolean: RegExp; +declare const _null: RegExp; +export { _null as null }; +declare const _undefined: RegExp; +export { _undefined as undefined }; +export declare const lowercase: RegExp; +export declare const uppercase: RegExp; +export declare const hex: RegExp; +export declare const md5_hex: RegExp; +export declare const md5_base64: RegExp; +export declare const md5_base64url: RegExp; +export declare const sha1_hex: RegExp; +export declare const sha1_base64: RegExp; +export declare const sha1_base64url: RegExp; +export declare const sha256_hex: RegExp; +export declare const sha256_base64: RegExp; +export declare const sha256_base64url: RegExp; +export declare const sha384_hex: RegExp; +export declare const sha384_base64: RegExp; +export declare const sha384_base64url: RegExp; +export declare const sha512_hex: RegExp; +export declare const sha512_base64: RegExp; +export declare const sha512_base64url: RegExp; diff --git a/node_modules/zod/v4/core/regexes.d.ts b/node_modules/zod/v4/core/regexes.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..14682662cbc9eef8f29436f2015a1bb2a664b0b5 --- /dev/null +++ b/node_modules/zod/v4/core/regexes.d.ts @@ -0,0 +1,85 @@ +/** + * @deprecated CUID v1 is deprecated by its authors due to information leakage + * (timestamps embedded in the id). Use {@link cuid2} instead. + * See https://github.com/paralleldrive/cuid. + */ +export declare const cuid: RegExp; +export declare const cuid2: RegExp; +export declare const ulid: RegExp; +export declare const xid: RegExp; +export declare const ksuid: RegExp; +export declare const nanoid: RegExp; +/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */ +export declare const duration: RegExp; +/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */ +export declare const extendedDuration: RegExp; +/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */ +export declare const guid: RegExp; +/** Returns a regex for validating an RFC 9562/4122 UUID. + * + * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */ +export declare const uuid: (version?: number | undefined) => RegExp; +export declare const uuid4: RegExp; +export declare const uuid6: RegExp; +export declare const uuid7: RegExp; +/** Practical email validation */ +export declare const email: RegExp; +/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */ +export declare const html5Email: RegExp; +/** The classic emailregex.com regex for RFC 5322-compliant emails */ +export declare const rfc5322Email: RegExp; +/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */ +export declare const unicodeEmail: RegExp; +export declare const idnEmail: RegExp; +export declare const browserEmail: RegExp; +export declare function emoji(): RegExp; +export declare const ipv4: RegExp; +export declare const ipv6: RegExp; +export declare const mac: (delimiter?: string) => RegExp; +export declare const cidrv4: RegExp; +export declare const cidrv6: RegExp; +export declare const base64: RegExp; +export declare const base64url: RegExp; +export declare const hostname: RegExp; +export declare const domain: RegExp; +export declare const httpProtocol: RegExp; +export declare const e164: RegExp; +export declare const date: RegExp; +export declare function time(args: { + precision?: number | null; +}): RegExp; +export declare function datetime(args: { + precision?: number | null; + offset?: boolean; + local?: boolean; +}): RegExp; +export declare const string: (params?: { + minimum?: number | undefined; + maximum?: number | undefined; +}) => RegExp; +export declare const bigint: RegExp; +export declare const integer: RegExp; +export declare const number: RegExp; +export declare const boolean: RegExp; +declare const _null: RegExp; +export { _null as null }; +declare const _undefined: RegExp; +export { _undefined as undefined }; +export declare const lowercase: RegExp; +export declare const uppercase: RegExp; +export declare const hex: RegExp; +export declare const md5_hex: RegExp; +export declare const md5_base64: RegExp; +export declare const md5_base64url: RegExp; +export declare const sha1_hex: RegExp; +export declare const sha1_base64: RegExp; +export declare const sha1_base64url: RegExp; +export declare const sha256_hex: RegExp; +export declare const sha256_base64: RegExp; +export declare const sha256_base64url: RegExp; +export declare const sha384_hex: RegExp; +export declare const sha384_base64: RegExp; +export declare const sha384_base64url: RegExp; +export declare const sha512_hex: RegExp; +export declare const sha512_base64: RegExp; +export declare const sha512_base64url: RegExp; diff --git a/node_modules/zod/v4/core/regexes.js b/node_modules/zod/v4/core/regexes.js new file mode 100644 index 0000000000000000000000000000000000000000..dd7caf81c27e35f6bea023484569f823e742d126 --- /dev/null +++ b/node_modules/zod/v4/core/regexes.js @@ -0,0 +1,139 @@ +import * as util from "./util.js"; +/** + * @deprecated CUID v1 is deprecated by its authors due to information leakage + * (timestamps embedded in the id). Use {@link cuid2} instead. + * See https://github.com/paralleldrive/cuid. + */ +export const cuid = /^[cC][0-9a-z]{6,}$/; +export const cuid2 = /^[0-9a-z]+$/; +export const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/; +export const xid = /^[0-9a-vA-V]{20}$/; +export const ksuid = /^[A-Za-z0-9]{27}$/; +export const nanoid = /^[a-zA-Z0-9_-]{21}$/; +/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */ +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)?)?)$/; +/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */ +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)?)??$/; +/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */ +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})$/; +/** Returns a regex for validating an RFC 9562/4122 UUID. + * + * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */ +export const uuid = (version) => { + if (!version) + return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/; + 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})$`); +}; +export const uuid4 = /*@__PURE__*/ uuid(4); +export const uuid6 = /*@__PURE__*/ uuid(6); +export const uuid7 = /*@__PURE__*/ uuid(7); +/** Practical email validation */ +export const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/; +/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */ +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])?)*$/; +/** The classic emailregex.com regex for RFC 5322-compliant emails */ +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,}))$/; +/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */ +export const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u; +export const idnEmail = unicodeEmail; +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])?)*$/; +// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression +const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`; +export function emoji() { + return new RegExp(_emoji, "u"); +} +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])$/; +export const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/; +export const mac = (delimiter) => { + const escapedDelim = util.escapeRegex(delimiter ?? ":"); + return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`); +}; +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])$/; +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])$/; +// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript +export const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/; +export const base64url = /^[A-Za-z0-9_-]*$/; +// based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address +// export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/; +export const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/; +export const domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/; +export const httpProtocol = /^https?$/; +// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces) +// E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15 +export const e164 = /^\+[1-9]\d{6,14}$/; +// 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])))`; +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])))`; +export const date = /*@__PURE__*/ new RegExp(`^${dateSource}$`); +function timeSource(args) { + const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`; + const regex = typeof args.precision === "number" + ? args.precision === -1 + ? `${hhmm}` + : args.precision === 0 + ? `${hhmm}:[0-5]\\d` + : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` + : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`; + return regex; +} +export function time(args) { + return new RegExp(`^${timeSource(args)}$`); +} +// Adapted from https://stackoverflow.com/a/3143231 +export function datetime(args) { + const time = timeSource({ precision: args.precision }); + const opts = ["Z"]; + if (args.local) + opts.push(""); + // if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`); + if (args.offset) + opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`); + const timeRegex = `${time}(?:${opts.join("|")})`; + return new RegExp(`^${dateSource}T(?:${timeRegex})$`); +} +export const string = (params) => { + const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`; + return new RegExp(`^${regex}$`); +}; +export const bigint = /^-?\d+n?$/; +export const integer = /^-?\d+$/; +export const number = /^-?\d+(?:\.\d+)?$/; +export const boolean = /^(?:true|false)$/i; +const _null = /^null$/i; +export { _null as null }; +const _undefined = /^undefined$/i; +export { _undefined as undefined }; +// regex for string with no uppercase letters +export const lowercase = /^[^A-Z]*$/; +// regex for string with no lowercase letters +export const uppercase = /^[^a-z]*$/; +// regex for hexadecimal strings (any length) +export const hex = /^[0-9a-fA-F]*$/; +// Hash regexes for different algorithms and encodings +// Helper function to create base64 regex with exact length and padding +function fixedBase64(bodyLength, padding) { + return new RegExp(`^[A-Za-z0-9+/]{${bodyLength}}${padding}$`); +} +// Helper function to create base64url regex with exact length (no padding) +function fixedBase64url(length) { + return new RegExp(`^[A-Za-z0-9_-]{${length}}$`); +} +// MD5 (16 bytes): base64 = 24 chars total (22 + "==") +export const md5_hex = /^[0-9a-fA-F]{32}$/; +export const md5_base64 = /*@__PURE__*/ fixedBase64(22, "=="); +export const md5_base64url = /*@__PURE__*/ fixedBase64url(22); +// SHA1 (20 bytes): base64 = 28 chars total (27 + "=") +export const sha1_hex = /^[0-9a-fA-F]{40}$/; +export const sha1_base64 = /*@__PURE__*/ fixedBase64(27, "="); +export const sha1_base64url = /*@__PURE__*/ fixedBase64url(27); +// SHA256 (32 bytes): base64 = 44 chars total (43 + "=") +export const sha256_hex = /^[0-9a-fA-F]{64}$/; +export const sha256_base64 = /*@__PURE__*/ fixedBase64(43, "="); +export const sha256_base64url = /*@__PURE__*/ fixedBase64url(43); +// SHA384 (48 bytes): base64 = 64 chars total (no padding) +export const sha384_hex = /^[0-9a-fA-F]{96}$/; +export const sha384_base64 = /*@__PURE__*/ fixedBase64(64, ""); +export const sha384_base64url = /*@__PURE__*/ fixedBase64url(64); +// SHA512 (64 bytes): base64 = 88 chars total (86 + "==") +export const sha512_hex = /^[0-9a-fA-F]{128}$/; +export const sha512_base64 = /*@__PURE__*/ fixedBase64(86, "=="); +export const sha512_base64url = /*@__PURE__*/ fixedBase64url(86); diff --git a/node_modules/zod/v4/core/registries.cjs b/node_modules/zod/v4/core/registries.cjs new file mode 100644 index 0000000000000000000000000000000000000000..3ab67ce0c138764cc5194e6f85881d9518cb0487 --- /dev/null +++ b/node_modules/zod/v4/core/registries.cjs @@ -0,0 +1,56 @@ +"use strict"; +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.globalRegistry = exports.$ZodRegistry = exports.$input = exports.$output = void 0; +exports.registry = registry; +exports.$output = Symbol("ZodOutput"); +exports.$input = Symbol("ZodInput"); +class $ZodRegistry { + constructor() { + this._map = new WeakMap(); + this._idmap = new Map(); + } + add(schema, ..._meta) { + const meta = _meta[0]; + this._map.set(schema, meta); + if (meta && typeof meta === "object" && "id" in meta) { + this._idmap.set(meta.id, schema); + } + return this; + } + clear() { + this._map = new WeakMap(); + this._idmap = new Map(); + return this; + } + remove(schema) { + const meta = this._map.get(schema); + if (meta && typeof meta === "object" && "id" in meta) { + this._idmap.delete(meta.id); + } + this._map.delete(schema); + return this; + } + get(schema) { + // return this._map.get(schema) as any; + // inherit metadata + const p = schema._zod.parent; + if (p) { + const pm = { ...(this.get(p) ?? {}) }; + delete pm.id; // do not inherit id + const f = { ...pm, ...this._map.get(schema) }; + return Object.keys(f).length ? f : undefined; + } + return this._map.get(schema); + } + has(schema) { + return this._map.has(schema); + } +} +exports.$ZodRegistry = $ZodRegistry; +// registries +function registry() { + return new $ZodRegistry(); +} +(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry()); +exports.globalRegistry = globalThis.__zod_globalRegistry; diff --git a/node_modules/zod/v4/core/registries.d.cts b/node_modules/zod/v4/core/registries.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..32557661246a27e0eec83c924a65ce77a3b83413 --- /dev/null +++ b/node_modules/zod/v4/core/registries.d.cts @@ -0,0 +1,35 @@ +import type * as core from "./core.cjs"; +import type { $ZodType } from "./schemas.cjs"; +export declare const $output: unique symbol; +export type $output = typeof $output; +export declare const $input: unique symbol; +export type $input = typeof $input; +export type $replace = Meta extends $output ? core.output : Meta extends $input ? core.input : Meta extends (infer M)[] ? $replace[] : Meta extends (...args: infer P) => infer R ? (...args: { + [K in keyof P]: $replace; +}) => $replace : Meta extends object ? { + [K in keyof Meta]: $replace; +} : Meta; +type MetadataType = object | undefined; +export declare class $ZodRegistry { + _meta: Meta; + _schema: Schema; + _map: WeakMap>; + _idmap: Map; + add(schema: S, ..._meta: undefined extends Meta ? [$replace?] : [$replace]): this; + clear(): this; + remove(schema: Schema): this; + get(schema: S): $replace | undefined; + has(schema: Schema): boolean; +} +export interface JSONSchemaMeta { + id?: string | undefined; + title?: string | undefined; + description?: string | undefined; + deprecated?: boolean | undefined; + [k: string]: unknown; +} +export interface GlobalMeta extends JSONSchemaMeta { +} +export declare function registry(): $ZodRegistry; +export declare const globalRegistry: $ZodRegistry; +export {}; diff --git a/node_modules/zod/v4/core/registries.d.ts b/node_modules/zod/v4/core/registries.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..345d717a09bddb6b92b02b596f02fda3da2d4cde --- /dev/null +++ b/node_modules/zod/v4/core/registries.d.ts @@ -0,0 +1,35 @@ +import type * as core from "./core.js"; +import type { $ZodType } from "./schemas.js"; +export declare const $output: unique symbol; +export type $output = typeof $output; +export declare const $input: unique symbol; +export type $input = typeof $input; +export type $replace = Meta extends $output ? core.output : Meta extends $input ? core.input : Meta extends (infer M)[] ? $replace[] : Meta extends (...args: infer P) => infer R ? (...args: { + [K in keyof P]: $replace; +}) => $replace : Meta extends object ? { + [K in keyof Meta]: $replace; +} : Meta; +type MetadataType = object | undefined; +export declare class $ZodRegistry { + _meta: Meta; + _schema: Schema; + _map: WeakMap>; + _idmap: Map; + add(schema: S, ..._meta: undefined extends Meta ? [$replace?] : [$replace]): this; + clear(): this; + remove(schema: Schema): this; + get(schema: S): $replace | undefined; + has(schema: Schema): boolean; +} +export interface JSONSchemaMeta { + id?: string | undefined; + title?: string | undefined; + description?: string | undefined; + deprecated?: boolean | undefined; + [k: string]: unknown; +} +export interface GlobalMeta extends JSONSchemaMeta { +} +export declare function registry(): $ZodRegistry; +export declare const globalRegistry: $ZodRegistry; +export {}; diff --git a/node_modules/zod/v4/core/registries.js b/node_modules/zod/v4/core/registries.js new file mode 100644 index 0000000000000000000000000000000000000000..537b1f1b97c8c95c44485efbd143766dc9f29ead --- /dev/null +++ b/node_modules/zod/v4/core/registries.js @@ -0,0 +1,51 @@ +var _a; +export const $output = Symbol("ZodOutput"); +export const $input = Symbol("ZodInput"); +export class $ZodRegistry { + constructor() { + this._map = new WeakMap(); + this._idmap = new Map(); + } + add(schema, ..._meta) { + const meta = _meta[0]; + this._map.set(schema, meta); + if (meta && typeof meta === "object" && "id" in meta) { + this._idmap.set(meta.id, schema); + } + return this; + } + clear() { + this._map = new WeakMap(); + this._idmap = new Map(); + return this; + } + remove(schema) { + const meta = this._map.get(schema); + if (meta && typeof meta === "object" && "id" in meta) { + this._idmap.delete(meta.id); + } + this._map.delete(schema); + return this; + } + get(schema) { + // return this._map.get(schema) as any; + // inherit metadata + const p = schema._zod.parent; + if (p) { + const pm = { ...(this.get(p) ?? {}) }; + delete pm.id; // do not inherit id + const f = { ...pm, ...this._map.get(schema) }; + return Object.keys(f).length ? f : undefined; + } + return this._map.get(schema); + } + has(schema) { + return this._map.has(schema); + } +} +// registries +export function registry() { + return new $ZodRegistry(); +} +(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry()); +export const globalRegistry = globalThis.__zod_globalRegistry; diff --git a/node_modules/zod/v4/core/schemas.cjs b/node_modules/zod/v4/core/schemas.cjs new file mode 100644 index 0000000000000000000000000000000000000000..1d5ac0121d81105ab1659d08509a0f59d3604788 --- /dev/null +++ b/node_modules/zod/v4/core/schemas.cjs @@ -0,0 +1,2270 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.$ZodTuple = exports.$ZodIntersection = exports.$ZodDiscriminatedUnion = exports.$ZodXor = exports.$ZodUnion = exports.$ZodObjectJIT = 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.$ZodMAC = 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; +exports.$ZodCustom = exports.$ZodLazy = exports.$ZodPromise = exports.$ZodFunction = exports.$ZodTemplateLiteral = exports.$ZodReadonly = exports.$ZodPreprocess = exports.$ZodCodec = exports.$ZodPipe = exports.$ZodNaN = exports.$ZodCatch = exports.$ZodSuccess = exports.$ZodNonOptional = exports.$ZodPrefault = exports.$ZodDefault = exports.$ZodNullable = exports.$ZodExactOptional = exports.$ZodOptional = exports.$ZodTransform = exports.$ZodFile = exports.$ZodLiteral = exports.$ZodEnum = exports.$ZodSet = exports.$ZodMap = exports.$ZodRecord = void 0; +exports.isValidBase64 = isValidBase64; +exports.isValidBase64URL = isValidBase64URL; +exports.isValidJWT = isValidJWT; +const checks = __importStar(require("./checks.cjs")); +const core = __importStar(require("./core.cjs")); +const doc_js_1 = require("./doc.cjs"); +const parse_js_1 = require("./parse.cjs"); +const regexes = __importStar(require("./regexes.cjs")); +const util = __importStar(require("./util.cjs")); +const versions_js_1 = require("./versions.cjs"); +exports.$ZodType = core.$constructor("$ZodType", (inst, def) => { + var _a; + inst ?? (inst = {}); + inst._zod.def = def; // set _def property + inst._zod.bag = inst._zod.bag || {}; // initialize _bag object + inst._zod.version = versions_js_1.version; + const checks = [...(inst._zod.def.checks ?? [])]; + // if inst is itself a checks.$ZodCheck, run it as a check + if (inst._zod.traits.has("$ZodCheck")) { + checks.unshift(inst); + } + for (const ch of checks) { + for (const fn of ch._zod.onattach) { + fn(inst); + } + } + if (checks.length === 0) { + // deferred initializer + // inst._zod.parse is not yet defined + (_a = inst._zod).deferred ?? (_a.deferred = []); + inst._zod.deferred?.push(() => { + inst._zod.run = inst._zod.parse; + }); + } + else { + const runChecks = (payload, checks, ctx) => { + let isAborted = util.aborted(payload); + let asyncResult; + for (const ch of checks) { + if (ch._zod.def.when) { + if (util.explicitlyAborted(payload)) + continue; + const shouldRun = ch._zod.def.when(payload); + if (!shouldRun) + continue; + } + else if (isAborted) { + continue; + } + const currLen = payload.issues.length; + const _ = ch._zod.check(payload); + if (_ instanceof Promise && ctx?.async === false) { + throw new core.$ZodAsyncError(); + } + if (asyncResult || _ instanceof Promise) { + asyncResult = (asyncResult ?? Promise.resolve()).then(async () => { + await _; + const nextLen = payload.issues.length; + if (nextLen === currLen) + return; + if (!isAborted) + isAborted = util.aborted(payload, currLen); + }); + } + else { + const nextLen = payload.issues.length; + if (nextLen === currLen) + continue; + if (!isAborted) + isAborted = util.aborted(payload, currLen); + } + } + if (asyncResult) { + return asyncResult.then(() => { + return payload; + }); + } + return payload; + }; + const handleCanaryResult = (canary, payload, ctx) => { + // abort if the canary is aborted + if (util.aborted(canary)) { + canary.aborted = true; + return canary; + } + // run checks first, then + const checkResult = runChecks(payload, checks, ctx); + if (checkResult instanceof Promise) { + if (ctx.async === false) + throw new core.$ZodAsyncError(); + return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx)); + } + return inst._zod.parse(checkResult, ctx); + }; + inst._zod.run = (payload, ctx) => { + if (ctx.skipChecks) { + return inst._zod.parse(payload, ctx); + } + if (ctx.direction === "backward") { + // run canary + // initial pass (no checks) + const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true }); + if (canary instanceof Promise) { + return canary.then((canary) => { + return handleCanaryResult(canary, payload, ctx); + }); + } + return handleCanaryResult(canary, payload, ctx); + } + // forward + const result = inst._zod.parse(payload, ctx); + if (result instanceof Promise) { + if (ctx.async === false) + throw new core.$ZodAsyncError(); + return result.then((result) => runChecks(result, checks, ctx)); + } + return runChecks(result, checks, ctx); + }; + } + // Lazy initialize ~standard to avoid creating objects for every schema + util.defineLazy(inst, "~standard", () => ({ + validate: (value) => { + try { + const r = (0, parse_js_1.safeParse)(inst, value); + return r.success ? { value: r.data } : { issues: r.error?.issues }; + } + catch (_) { + return (0, parse_js_1.safeParseAsync)(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues })); + } + }, + vendor: "zod", + version: 1, + })); +}); +var util_js_1 = require("./util.cjs"); +Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return util_js_1.clone; } }); +exports.$ZodString = core.$constructor("$ZodString", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? regexes.string(inst._zod.bag); + inst._zod.parse = (payload, _) => { + if (def.coerce) + try { + payload.value = String(payload.value); + } + catch (_) { } + if (typeof payload.value === "string") + return payload; + payload.issues.push({ + expected: "string", + code: "invalid_type", + input: payload.value, + inst, + }); + return payload; + }; +}); +exports.$ZodStringFormat = core.$constructor("$ZodStringFormat", (inst, def) => { + // check initialization must come first + checks.$ZodCheckStringFormat.init(inst, def); + exports.$ZodString.init(inst, def); +}); +exports.$ZodGUID = core.$constructor("$ZodGUID", (inst, def) => { + def.pattern ?? (def.pattern = regexes.guid); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodUUID = core.$constructor("$ZodUUID", (inst, def) => { + if (def.version) { + const versionMap = { + v1: 1, + v2: 2, + v3: 3, + v4: 4, + v5: 5, + v6: 6, + v7: 7, + v8: 8, + }; + const v = versionMap[def.version]; + if (v === undefined) + throw new Error(`Invalid UUID version: "${def.version}"`); + def.pattern ?? (def.pattern = regexes.uuid(v)); + } + else + def.pattern ?? (def.pattern = regexes.uuid()); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodEmail = core.$constructor("$ZodEmail", (inst, def) => { + def.pattern ?? (def.pattern = regexes.email); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodURL = core.$constructor("$ZodURL", (inst, def) => { + exports.$ZodStringFormat.init(inst, def); + inst._zod.check = (payload) => { + try { + // Trim whitespace from input + const trimmed = payload.value.trim(); + // When normalize is off, require :// for http/https URLs + // This prevents strings like "http:example.com" or "https:/path" from being silently accepted + if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source) { + if (!/^https?:\/\//i.test(trimmed)) { + payload.issues.push({ + code: "invalid_format", + format: "url", + note: "Invalid URL format", + input: payload.value, + inst, + continue: !def.abort, + }); + return; + } + } + // @ts-ignore + const url = new URL(trimmed); + if (def.hostname) { + def.hostname.lastIndex = 0; + if (!def.hostname.test(url.hostname)) { + payload.issues.push({ + code: "invalid_format", + format: "url", + note: "Invalid hostname", + pattern: def.hostname.source, + input: payload.value, + inst, + continue: !def.abort, + }); + } + } + if (def.protocol) { + def.protocol.lastIndex = 0; + if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) { + payload.issues.push({ + code: "invalid_format", + format: "url", + note: "Invalid protocol", + pattern: def.protocol.source, + input: payload.value, + inst, + continue: !def.abort, + }); + } + } + // Set the output value based on normalize flag + if (def.normalize) { + // Use normalized URL + payload.value = url.href; + } + else { + // Preserve the original input (trimmed) + payload.value = trimmed; + } + return; + } + catch (_) { + payload.issues.push({ + code: "invalid_format", + format: "url", + input: payload.value, + inst, + continue: !def.abort, + }); + } + }; +}); +exports.$ZodEmoji = core.$constructor("$ZodEmoji", (inst, def) => { + def.pattern ?? (def.pattern = regexes.emoji()); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodNanoID = core.$constructor("$ZodNanoID", (inst, def) => { + def.pattern ?? (def.pattern = regexes.nanoid); + exports.$ZodStringFormat.init(inst, def); +}); +/** + * @deprecated CUID v1 is deprecated by its authors due to information leakage + * (timestamps embedded in the id). Use {@link $ZodCUID2} instead. + * See https://github.com/paralleldrive/cuid. + */ +exports.$ZodCUID = core.$constructor("$ZodCUID", (inst, def) => { + def.pattern ?? (def.pattern = regexes.cuid); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodCUID2 = core.$constructor("$ZodCUID2", (inst, def) => { + def.pattern ?? (def.pattern = regexes.cuid2); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodULID = core.$constructor("$ZodULID", (inst, def) => { + def.pattern ?? (def.pattern = regexes.ulid); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodXID = core.$constructor("$ZodXID", (inst, def) => { + def.pattern ?? (def.pattern = regexes.xid); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodKSUID = core.$constructor("$ZodKSUID", (inst, def) => { + def.pattern ?? (def.pattern = regexes.ksuid); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodISODateTime = core.$constructor("$ZodISODateTime", (inst, def) => { + def.pattern ?? (def.pattern = regexes.datetime(def)); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodISODate = core.$constructor("$ZodISODate", (inst, def) => { + def.pattern ?? (def.pattern = regexes.date); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodISOTime = core.$constructor("$ZodISOTime", (inst, def) => { + def.pattern ?? (def.pattern = regexes.time(def)); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodISODuration = core.$constructor("$ZodISODuration", (inst, def) => { + def.pattern ?? (def.pattern = regexes.duration); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodIPv4 = core.$constructor("$ZodIPv4", (inst, def) => { + def.pattern ?? (def.pattern = regexes.ipv4); + exports.$ZodStringFormat.init(inst, def); + inst._zod.bag.format = `ipv4`; +}); +exports.$ZodIPv6 = core.$constructor("$ZodIPv6", (inst, def) => { + def.pattern ?? (def.pattern = regexes.ipv6); + exports.$ZodStringFormat.init(inst, def); + inst._zod.bag.format = `ipv6`; + inst._zod.check = (payload) => { + try { + // @ts-ignore + new URL(`http://[${payload.value}]`); + // return; + } + catch { + payload.issues.push({ + code: "invalid_format", + format: "ipv6", + input: payload.value, + inst, + continue: !def.abort, + }); + } + }; +}); +exports.$ZodMAC = core.$constructor("$ZodMAC", (inst, def) => { + def.pattern ?? (def.pattern = regexes.mac(def.delimiter)); + exports.$ZodStringFormat.init(inst, def); + inst._zod.bag.format = `mac`; +}); +exports.$ZodCIDRv4 = core.$constructor("$ZodCIDRv4", (inst, def) => { + def.pattern ?? (def.pattern = regexes.cidrv4); + exports.$ZodStringFormat.init(inst, def); +}); +exports.$ZodCIDRv6 = core.$constructor("$ZodCIDRv6", (inst, def) => { + def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation + exports.$ZodStringFormat.init(inst, def); + inst._zod.check = (payload) => { + const parts = payload.value.split("/"); + try { + if (parts.length !== 2) + throw new Error(); + const [address, prefix] = parts; + if (!prefix) + throw new Error(); + const prefixNum = Number(prefix); + if (`${prefixNum}` !== prefix) + throw new Error(); + if (prefixNum < 0 || prefixNum > 128) + throw new Error(); + // @ts-ignore + new URL(`http://[${address}]`); + } + catch { + payload.issues.push({ + code: "invalid_format", + format: "cidrv6", + input: payload.value, + inst, + continue: !def.abort, + }); + } + }; +}); +////////////////////////////// ZodBase64 ////////////////////////////// +function isValidBase64(data) { + if (data === "") + return true; + // atob ignores whitespace, so reject it up front. + if (/\s/.test(data)) + return false; + if (data.length % 4 !== 0) + return false; + try { + // @ts-ignore + atob(data); + return true; + } + catch { + return false; + } +} +exports.$ZodBase64 = core.$constructor("$ZodBase64", (inst, def) => { + def.pattern ?? (def.pattern = regexes.base64); + exports.$ZodStringFormat.init(inst, def); + inst._zod.bag.contentEncoding = "base64"; + inst._zod.check = (payload) => { + if (isValidBase64(payload.value)) + return; + payload.issues.push({ + code: "invalid_format", + format: "base64", + input: payload.value, + inst, + continue: !def.abort, + }); + }; +}); +////////////////////////////// ZodBase64 ////////////////////////////// +function isValidBase64URL(data) { + if (!regexes.base64url.test(data)) + return false; + const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/")); + const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "="); + return isValidBase64(padded); +} +exports.$ZodBase64URL = core.$constructor("$ZodBase64URL", (inst, def) => { + def.pattern ?? (def.pattern = regexes.base64url); + exports.$ZodStringFormat.init(inst, def); + inst._zod.bag.contentEncoding = "base64url"; + inst._zod.check = (payload) => { + if (isValidBase64URL(payload.value)) + return; + payload.issues.push({ + code: "invalid_format", + format: "base64url", + input: payload.value, + inst, + continue: !def.abort, + }); + }; +}); +exports.$ZodE164 = core.$constructor("$ZodE164", (inst, def) => { + def.pattern ?? (def.pattern = regexes.e164); + exports.$ZodStringFormat.init(inst, def); +}); +////////////////////////////// ZodJWT ////////////////////////////// +function isValidJWT(token, algorithm = null) { + try { + const tokensParts = token.split("."); + if (tokensParts.length !== 3) + return false; + const [header] = tokensParts; + if (!header) + return false; + // @ts-ignore + const parsedHeader = JSON.parse(atob(header)); + if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") + return false; + if (!parsedHeader.alg) + return false; + if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) + return false; + return true; + } + catch { + return false; + } +} +exports.$ZodJWT = core.$constructor("$ZodJWT", (inst, def) => { + exports.$ZodStringFormat.init(inst, def); + inst._zod.check = (payload) => { + if (isValidJWT(payload.value, def.alg)) + return; + payload.issues.push({ + code: "invalid_format", + format: "jwt", + input: payload.value, + inst, + continue: !def.abort, + }); + }; +}); +exports.$ZodCustomStringFormat = core.$constructor("$ZodCustomStringFormat", (inst, def) => { + exports.$ZodStringFormat.init(inst, def); + inst._zod.check = (payload) => { + if (def.fn(payload.value)) + return; + payload.issues.push({ + code: "invalid_format", + format: def.format, + input: payload.value, + inst, + continue: !def.abort, + }); + }; +}); +exports.$ZodNumber = core.$constructor("$ZodNumber", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number; + inst._zod.parse = (payload, _ctx) => { + if (def.coerce) + try { + payload.value = Number(payload.value); + } + catch (_) { } + const input = payload.value; + if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) { + return payload; + } + const received = typeof input === "number" + ? Number.isNaN(input) + ? "NaN" + : !Number.isFinite(input) + ? "Infinity" + : undefined + : undefined; + payload.issues.push({ + expected: "number", + code: "invalid_type", + input, + inst, + ...(received ? { received } : {}), + }); + return payload; + }; +}); +exports.$ZodNumberFormat = core.$constructor("$ZodNumberFormat", (inst, def) => { + checks.$ZodCheckNumberFormat.init(inst, def); + exports.$ZodNumber.init(inst, def); // no format checks +}); +exports.$ZodBoolean = core.$constructor("$ZodBoolean", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.pattern = regexes.boolean; + inst._zod.parse = (payload, _ctx) => { + if (def.coerce) + try { + payload.value = Boolean(payload.value); + } + catch (_) { } + const input = payload.value; + if (typeof input === "boolean") + return payload; + payload.issues.push({ + expected: "boolean", + code: "invalid_type", + input, + inst, + }); + return payload; + }; +}); +exports.$ZodBigInt = core.$constructor("$ZodBigInt", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.pattern = regexes.bigint; + inst._zod.parse = (payload, _ctx) => { + if (def.coerce) + try { + payload.value = BigInt(payload.value); + } + catch (_) { } + if (typeof payload.value === "bigint") + return payload; + payload.issues.push({ + expected: "bigint", + code: "invalid_type", + input: payload.value, + inst, + }); + return payload; + }; +}); +exports.$ZodBigIntFormat = core.$constructor("$ZodBigIntFormat", (inst, def) => { + checks.$ZodCheckBigIntFormat.init(inst, def); + exports.$ZodBigInt.init(inst, def); // no format checks +}); +exports.$ZodSymbol = core.$constructor("$ZodSymbol", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, _ctx) => { + const input = payload.value; + if (typeof input === "symbol") + return payload; + payload.issues.push({ + expected: "symbol", + code: "invalid_type", + input, + inst, + }); + return payload; + }; +}); +exports.$ZodUndefined = core.$constructor("$ZodUndefined", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.pattern = regexes.undefined; + inst._zod.values = new Set([undefined]); + inst._zod.parse = (payload, _ctx) => { + const input = payload.value; + if (typeof input === "undefined") + return payload; + payload.issues.push({ + expected: "undefined", + code: "invalid_type", + input, + inst, + }); + return payload; + }; +}); +exports.$ZodNull = core.$constructor("$ZodNull", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.pattern = regexes.null; + inst._zod.values = new Set([null]); + inst._zod.parse = (payload, _ctx) => { + const input = payload.value; + if (input === null) + return payload; + payload.issues.push({ + expected: "null", + code: "invalid_type", + input, + inst, + }); + return payload; + }; +}); +exports.$ZodAny = core.$constructor("$ZodAny", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload) => payload; +}); +exports.$ZodUnknown = core.$constructor("$ZodUnknown", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload) => payload; +}); +exports.$ZodNever = core.$constructor("$ZodNever", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, _ctx) => { + payload.issues.push({ + expected: "never", + code: "invalid_type", + input: payload.value, + inst, + }); + return payload; + }; +}); +exports.$ZodVoid = core.$constructor("$ZodVoid", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, _ctx) => { + const input = payload.value; + if (typeof input === "undefined") + return payload; + payload.issues.push({ + expected: "void", + code: "invalid_type", + input, + inst, + }); + return payload; + }; +}); +exports.$ZodDate = core.$constructor("$ZodDate", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, _ctx) => { + if (def.coerce) { + try { + payload.value = new Date(payload.value); + } + catch (_err) { } + } + const input = payload.value; + const isDate = input instanceof Date; + const isValidDate = isDate && !Number.isNaN(input.getTime()); + if (isValidDate) + return payload; + payload.issues.push({ + expected: "date", + code: "invalid_type", + input, + ...(isDate ? { received: "Invalid Date" } : {}), + inst, + }); + return payload; + }; +}); +function handleArrayResult(result, final, index) { + if (result.issues.length) { + final.issues.push(...util.prefixIssues(index, result.issues)); + } + final.value[index] = result.value; +} +exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, ctx) => { + const input = payload.value; + if (!Array.isArray(input)) { + payload.issues.push({ + expected: "array", + code: "invalid_type", + input, + inst, + }); + return payload; + } + payload.value = Array(input.length); + const proms = []; + for (let i = 0; i < input.length; i++) { + const item = input[i]; + const result = def.element._zod.run({ + value: item, + issues: [], + }, ctx); + if (result instanceof Promise) { + proms.push(result.then((result) => handleArrayResult(result, payload, i))); + } + else { + handleArrayResult(result, payload, i); + } + } + if (proms.length) { + return Promise.all(proms).then(() => payload); + } + return payload; //handleArrayResultsAsync(parseResults, final); + }; +}); +function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) { + const isPresent = key in input; + if (result.issues.length) { + // For optional-in/out schemas, ignore errors on absent keys. + if (isOptionalIn && isOptionalOut && !isPresent) { + return; + } + final.issues.push(...util.prefixIssues(key, result.issues)); + } + if (!isPresent && !isOptionalIn) { + if (!result.issues.length) { + final.issues.push({ + code: "invalid_type", + expected: "nonoptional", + input: undefined, + path: [key], + }); + } + return; + } + if (result.value === undefined) { + if (isPresent) { + final.value[key] = undefined; + } + } + else { + final.value[key] = result.value; + } +} +function normalizeDef(def) { + const keys = Object.keys(def.shape); + for (const k of keys) { + if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) { + throw new Error(`Invalid element at key "${k}": expected a Zod schema`); + } + } + const okeys = util.optionalKeys(def.shape); + return { + ...def, + keys, + keySet: new Set(keys), + numKeys: keys.length, + optionalKeys: new Set(okeys), + }; +} +function handleCatchall(proms, input, payload, ctx, def, inst) { + const unrecognized = []; + const keySet = def.keySet; + const _catchall = def.catchall._zod; + const t = _catchall.def.type; + const isOptionalIn = _catchall.optin === "optional"; + const isOptionalOut = _catchall.optout === "optional"; + for (const key in input) { + // skip __proto__ so it can't replace the result prototype via the + // assignment setter on the plain {} we build into + if (key === "__proto__") + continue; + if (keySet.has(key)) + continue; + if (t === "never") { + unrecognized.push(key); + continue; + } + const r = _catchall.run({ value: input[key], issues: [] }, ctx); + if (r instanceof Promise) { + proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut))); + } + else { + handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut); + } + } + if (unrecognized.length) { + payload.issues.push({ + code: "unrecognized_keys", + keys: unrecognized, + input, + inst, + }); + } + if (!proms.length) + return payload; + return Promise.all(proms).then(() => { + return payload; + }); +} +exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => { + // requires cast because technically $ZodObject doesn't extend + exports.$ZodType.init(inst, def); + // const sh = def.shape; + const desc = Object.getOwnPropertyDescriptor(def, "shape"); + if (!desc?.get) { + const sh = def.shape; + Object.defineProperty(def, "shape", { + get: () => { + const newSh = { ...sh }; + Object.defineProperty(def, "shape", { + value: newSh, + }); + return newSh; + }, + }); + } + const _normalized = util.cached(() => normalizeDef(def)); + util.defineLazy(inst._zod, "propValues", () => { + const shape = def.shape; + const propValues = {}; + for (const key in shape) { + const field = shape[key]._zod; + if (field.values) { + propValues[key] ?? (propValues[key] = new Set()); + for (const v of field.values) + propValues[key].add(v); + } + } + return propValues; + }); + const isObject = util.isObject; + const catchall = def.catchall; + let value; + inst._zod.parse = (payload, ctx) => { + value ?? (value = _normalized.value); + const input = payload.value; + if (!isObject(input)) { + payload.issues.push({ + expected: "object", + code: "invalid_type", + input, + inst, + }); + return payload; + } + payload.value = {}; + const proms = []; + const shape = value.shape; + for (const key of value.keys) { + const el = shape[key]; + const isOptionalIn = el._zod.optin === "optional"; + const isOptionalOut = el._zod.optout === "optional"; + const r = el._zod.run({ value: input[key], issues: [] }, ctx); + if (r instanceof Promise) { + proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut))); + } + else { + handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut); + } + } + if (!catchall) { + return proms.length ? Promise.all(proms).then(() => payload) : payload; + } + return handleCatchall(proms, input, payload, ctx, _normalized.value, inst); + }; +}); +exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => { + // requires cast because technically $ZodObject doesn't extend + exports.$ZodObject.init(inst, def); + const superParse = inst._zod.parse; + const _normalized = util.cached(() => normalizeDef(def)); + const generateFastpass = (shape) => { + const doc = new doc_js_1.Doc(["shape", "payload", "ctx"]); + const normalized = _normalized.value; + const parseStr = (key) => { + const k = util.esc(key); + return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`; + }; + doc.write(`const input = payload.value;`); + const ids = Object.create(null); + let counter = 0; + for (const key of normalized.keys) { + ids[key] = `key_${counter++}`; + } + // A: preserve key order { + doc.write(`const newResult = {};`); + for (const key of normalized.keys) { + const id = ids[key]; + const k = util.esc(key); + const schema = shape[key]; + const isOptionalIn = schema?._zod?.optin === "optional"; + const isOptionalOut = schema?._zod?.optout === "optional"; + doc.write(`const ${id} = ${parseStr(key)};`); + if (isOptionalIn && isOptionalOut) { + // For optional-in/out schemas, ignore errors on absent keys + doc.write(` + if (${id}.issues.length) { + if (${k} in input) { + payload.issues = payload.issues.concat(${id}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${k}, ...iss.path] : [${k}] + }))); + } + } + + if (${id}.value === undefined) { + if (${k} in input) { + newResult[${k}] = undefined; + } + } else { + newResult[${k}] = ${id}.value; + } + + `); + } + else if (!isOptionalIn) { + doc.write(` + const ${id}_present = ${k} in input; + if (${id}.issues.length) { + payload.issues = payload.issues.concat(${id}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${k}, ...iss.path] : [${k}] + }))); + } + if (!${id}_present && !${id}.issues.length) { + payload.issues.push({ + code: "invalid_type", + expected: "nonoptional", + input: undefined, + path: [${k}] + }); + } + + if (${id}_present) { + if (${id}.value === undefined) { + newResult[${k}] = undefined; + } else { + newResult[${k}] = ${id}.value; + } + } + + `); + } + else { + doc.write(` + if (${id}.issues.length) { + payload.issues = payload.issues.concat(${id}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${k}, ...iss.path] : [${k}] + }))); + } + + if (${id}.value === undefined) { + if (${k} in input) { + newResult[${k}] = undefined; + } + } else { + newResult[${k}] = ${id}.value; + } + + `); + } + } + doc.write(`payload.value = newResult;`); + doc.write(`return payload;`); + const fn = doc.compile(); + return (payload, ctx) => fn(shape, payload, ctx); + }; + let fastpass; + const isObject = util.isObject; + const jit = !core.globalConfig.jitless; + const allowsEval = util.allowsEval; + const fastEnabled = jit && allowsEval.value; // && !def.catchall; + const catchall = def.catchall; + let value; + inst._zod.parse = (payload, ctx) => { + value ?? (value = _normalized.value); + const input = payload.value; + if (!isObject(input)) { + payload.issues.push({ + expected: "object", + code: "invalid_type", + input, + inst, + }); + return payload; + } + if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) { + // always synchronous + if (!fastpass) + fastpass = generateFastpass(def.shape); + payload = fastpass(payload, ctx); + if (!catchall) + return payload; + return handleCatchall([], input, payload, ctx, value, inst); + } + return superParse(payload, ctx); + }; +}); +function handleUnionResults(results, final, inst, ctx) { + for (const result of results) { + if (result.issues.length === 0) { + final.value = result.value; + return final; + } + } + const nonaborted = results.filter((r) => !util.aborted(r)); + if (nonaborted.length === 1) { + final.value = nonaborted[0].value; + return nonaborted[0]; + } + final.issues.push({ + code: "invalid_union", + input: final.value, + inst, + errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))), + }); + return final; +} +exports.$ZodUnion = core.$constructor("$ZodUnion", (inst, def) => { + exports.$ZodType.init(inst, def); + util.defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined); + util.defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined); + util.defineLazy(inst._zod, "values", () => { + if (def.options.every((o) => o._zod.values)) { + return new Set(def.options.flatMap((option) => Array.from(option._zod.values))); + } + return undefined; + }); + util.defineLazy(inst._zod, "pattern", () => { + if (def.options.every((o) => o._zod.pattern)) { + const patterns = def.options.map((o) => o._zod.pattern); + return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`); + } + return undefined; + }); + const first = def.options.length === 1 ? def.options[0]._zod.run : null; + inst._zod.parse = (payload, ctx) => { + if (first) { + return first(payload, ctx); + } + let async = false; + const results = []; + for (const option of def.options) { + const result = option._zod.run({ + value: payload.value, + issues: [], + }, ctx); + if (result instanceof Promise) { + results.push(result); + async = true; + } + else { + if (result.issues.length === 0) + return result; + results.push(result); + } + } + if (!async) + return handleUnionResults(results, payload, inst, ctx); + return Promise.all(results).then((results) => { + return handleUnionResults(results, payload, inst, ctx); + }); + }; +}); +function handleExclusiveUnionResults(results, final, inst, ctx) { + const successes = results.filter((r) => r.issues.length === 0); + if (successes.length === 1) { + final.value = successes[0].value; + return final; + } + if (successes.length === 0) { + // No matches - same as regular union + final.issues.push({ + code: "invalid_union", + input: final.value, + inst, + errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))), + }); + } + else { + // Multiple matches - exclusive union failure + final.issues.push({ + code: "invalid_union", + input: final.value, + inst, + errors: [], + inclusive: false, + }); + } + return final; +} +exports.$ZodXor = core.$constructor("$ZodXor", (inst, def) => { + exports.$ZodUnion.init(inst, def); + def.inclusive = false; + const first = def.options.length === 1 ? def.options[0]._zod.run : null; + inst._zod.parse = (payload, ctx) => { + if (first) { + return first(payload, ctx); + } + let async = false; + const results = []; + for (const option of def.options) { + const result = option._zod.run({ + value: payload.value, + issues: [], + }, ctx); + if (result instanceof Promise) { + results.push(result); + async = true; + } + else { + results.push(result); + } + } + if (!async) + return handleExclusiveUnionResults(results, payload, inst, ctx); + return Promise.all(results).then((results) => { + return handleExclusiveUnionResults(results, payload, inst, ctx); + }); + }; +}); +exports.$ZodDiscriminatedUnion = +/*@__PURE__*/ +core.$constructor("$ZodDiscriminatedUnion", (inst, def) => { + def.inclusive = false; + exports.$ZodUnion.init(inst, def); + const _super = inst._zod.parse; + util.defineLazy(inst._zod, "propValues", () => { + const propValues = {}; + for (const option of def.options) { + const pv = option._zod.propValues; + if (!pv || Object.keys(pv).length === 0) + throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`); + for (const [k, v] of Object.entries(pv)) { + if (!propValues[k]) + propValues[k] = new Set(); + for (const val of v) { + propValues[k].add(val); + } + } + } + return propValues; + }); + const disc = util.cached(() => { + const opts = def.options; + const map = new Map(); + for (const o of opts) { + const values = o._zod.propValues?.[def.discriminator]; + if (!values || values.size === 0) + throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`); + for (const v of values) { + if (map.has(v)) { + throw new Error(`Duplicate discriminator value "${String(v)}"`); + } + map.set(v, o); + } + } + return map; + }); + inst._zod.parse = (payload, ctx) => { + const input = payload.value; + if (!util.isObject(input)) { + payload.issues.push({ + code: "invalid_type", + expected: "object", + input, + inst, + }); + return payload; + } + const opt = disc.value.get(input?.[def.discriminator]); + if (opt) { + return opt._zod.run(payload, ctx); + } + // Fall back to union matching when the fast discriminator path fails: + // - explicitly enabled via unionFallback, or + // - during backward direction (encode), since codec-based discriminators + // have different values in forward vs backward directions + if (def.unionFallback || ctx.direction === "backward") { + return _super(payload, ctx); + } + // no matching discriminator + payload.issues.push({ + code: "invalid_union", + errors: [], + note: "No matching discriminator", + discriminator: def.discriminator, + options: Array.from(disc.value.keys()), + input, + path: [def.discriminator], + inst, + }); + return payload; + }; +}); +exports.$ZodIntersection = core.$constructor("$ZodIntersection", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, ctx) => { + const input = payload.value; + const left = def.left._zod.run({ value: input, issues: [] }, ctx); + const right = def.right._zod.run({ value: input, issues: [] }, ctx); + const async = left instanceof Promise || right instanceof Promise; + if (async) { + return Promise.all([left, right]).then(([left, right]) => { + return handleIntersectionResults(payload, left, right); + }); + } + return handleIntersectionResults(payload, left, right); + }; +}); +function mergeValues(a, b) { + // const aType = parse.t(a); + // const bType = parse.t(b); + if (a === b) { + return { valid: true, data: a }; + } + if (a instanceof Date && b instanceof Date && +a === +b) { + return { valid: true, data: a }; + } + if (util.isPlainObject(a) && util.isPlainObject(b)) { + const bKeys = Object.keys(b); + const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1); + const newObj = { ...a, ...b }; + for (const key of sharedKeys) { + const sharedValue = mergeValues(a[key], b[key]); + if (!sharedValue.valid) { + return { + valid: false, + mergeErrorPath: [key, ...sharedValue.mergeErrorPath], + }; + } + newObj[key] = sharedValue.data; + } + return { valid: true, data: newObj }; + } + if (Array.isArray(a) && Array.isArray(b)) { + if (a.length !== b.length) { + return { valid: false, mergeErrorPath: [] }; + } + const newArray = []; + for (let index = 0; index < a.length; index++) { + const itemA = a[index]; + const itemB = b[index]; + const sharedValue = mergeValues(itemA, itemB); + if (!sharedValue.valid) { + return { + valid: false, + mergeErrorPath: [index, ...sharedValue.mergeErrorPath], + }; + } + newArray.push(sharedValue.data); + } + return { valid: true, data: newArray }; + } + return { valid: false, mergeErrorPath: [] }; +} +function handleIntersectionResults(result, left, right) { + // Track which side(s) report each key as unrecognized + const unrecKeys = new Map(); + let unrecIssue; + for (const iss of left.issues) { + if (iss.code === "unrecognized_keys") { + unrecIssue ?? (unrecIssue = iss); + for (const k of iss.keys) { + if (!unrecKeys.has(k)) + unrecKeys.set(k, {}); + unrecKeys.get(k).l = true; + } + } + else { + result.issues.push(iss); + } + } + for (const iss of right.issues) { + if (iss.code === "unrecognized_keys") { + for (const k of iss.keys) { + if (!unrecKeys.has(k)) + unrecKeys.set(k, {}); + unrecKeys.get(k).r = true; + } + } + else { + result.issues.push(iss); + } + } + // Report only keys unrecognized by BOTH sides + const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k); + if (bothKeys.length && unrecIssue) { + result.issues.push({ ...unrecIssue, keys: bothKeys }); + } + if (util.aborted(result)) + return result; + const merged = mergeValues(left.value, right.value); + if (!merged.valid) { + throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`); + } + result.value = merged.data; + return result; +} +exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => { + exports.$ZodType.init(inst, def); + const items = def.items; + inst._zod.parse = (payload, ctx) => { + const input = payload.value; + if (!Array.isArray(input)) { + payload.issues.push({ + input, + inst, + expected: "tuple", + code: "invalid_type", + }); + return payload; + } + payload.value = []; + const proms = []; + const optinStart = getTupleOptStart(items, "optin"); + const optoutStart = getTupleOptStart(items, "optout"); + if (!def.rest) { + if (input.length < optinStart) { + payload.issues.push({ + code: "too_small", + minimum: optinStart, + inclusive: true, + input, + inst, + origin: "array", + }); + return payload; + } + if (input.length > items.length) { + payload.issues.push({ + code: "too_big", + maximum: items.length, + inclusive: true, + input, + inst, + origin: "array", + }); + } + } + // Run every item in parallel, collecting results into an indexed + // array. The post-processing in `handleTupleResults` walks them in + // order so it can decide whether an absent optional-output error can + // truncate the tail or must be reported to preserve required output. + const itemResults = new Array(items.length); + for (let i = 0; i < items.length; i++) { + const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx); + if (r instanceof Promise) { + proms.push(r.then((rr) => { + itemResults[i] = rr; + })); + } + else { + itemResults[i] = r; + } + } + if (def.rest) { + let i = items.length - 1; + const rest = input.slice(items.length); + for (const el of rest) { + i++; + const result = def.rest._zod.run({ value: el, issues: [] }, ctx); + if (result instanceof Promise) { + proms.push(result.then((r) => handleTupleResult(r, payload, i))); + } + else { + handleTupleResult(result, payload, i); + } + } + } + if (proms.length) { + return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart)); + } + return handleTupleResults(itemResults, payload, items, input, optoutStart); + }; +}); +function getTupleOptStart(items, key) { + for (let i = items.length - 1; i >= 0; i--) { + if (items[i]._zod[key] !== "optional") + return i + 1; + } + return 0; +} +function handleTupleResult(result, final, index) { + if (result.issues.length) { + final.issues.push(...util.prefixIssues(index, result.issues)); + } + final.value[index] = result.value; +} +function handleTupleResults(itemResults, final, items, input, optoutStart) { + // Walk results in order. Mirror $ZodObject's swallow-on-absent-optional + // rule, but only after `optoutStart`: the first index where the output + // tuple tail can be absent. + for (let i = 0; i < items.length; i++) { + const r = itemResults[i]; + const isPresent = i < input.length; + if (r.issues.length) { + if (!isPresent && i >= optoutStart) { + final.value.length = i; + break; + } + final.issues.push(...util.prefixIssues(i, r.issues)); + } + final.value[i] = r.value; + } + // Drop trailing slots that produced `undefined` for absent input + // (the array analog of an absent optional key on an object). The + // `i >= input.length` floor is critical: an explicit `undefined` + // *inside* the input must be preserved even when the schema is + // optional-out (e.g. `z.string().or(z.undefined())` accepting an + // explicit undefined value). + for (let i = final.value.length - 1; i >= input.length; i--) { + if (items[i]._zod.optout === "optional" && final.value[i] === undefined) { + final.value.length = i; + } + else { + break; + } + } + return final; +} +exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, ctx) => { + const input = payload.value; + if (!util.isPlainObject(input)) { + payload.issues.push({ + expected: "record", + code: "invalid_type", + input, + inst, + }); + return payload; + } + const proms = []; + const values = def.keyType._zod.values; + if (values) { + payload.value = {}; + const recordKeys = new Set(); + for (const key of values) { + if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") { + recordKeys.add(typeof key === "number" ? key.toString() : key); + const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx); + if (keyResult instanceof Promise) { + throw new Error("Async schemas not supported in object keys currently"); + } + if (keyResult.issues.length) { + payload.issues.push({ + code: "invalid_key", + origin: "record", + issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())), + input: key, + path: [key], + inst, + }); + continue; + } + const outKey = keyResult.value; + const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx); + if (result instanceof Promise) { + proms.push(result.then((result) => { + if (result.issues.length) { + payload.issues.push(...util.prefixIssues(key, result.issues)); + } + payload.value[outKey] = result.value; + })); + } + else { + if (result.issues.length) { + payload.issues.push(...util.prefixIssues(key, result.issues)); + } + payload.value[outKey] = result.value; + } + } + } + let unrecognized; + for (const key in input) { + if (!recordKeys.has(key)) { + unrecognized = unrecognized ?? []; + unrecognized.push(key); + } + } + if (unrecognized && unrecognized.length > 0) { + payload.issues.push({ + code: "unrecognized_keys", + input, + inst, + keys: unrecognized, + }); + } + } + else { + payload.value = {}; + // Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object() + for (const key of Reflect.ownKeys(input)) { + if (key === "__proto__") + continue; + if (!Object.prototype.propertyIsEnumerable.call(input, key)) + continue; + let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx); + if (keyResult instanceof Promise) { + throw new Error("Async schemas not supported in object keys currently"); + } + // Numeric string fallback: if key is a numeric string and failed, retry with Number(key) + // This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals + const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length; + if (checkNumericKey) { + const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx); + if (retryResult instanceof Promise) { + throw new Error("Async schemas not supported in object keys currently"); + } + if (retryResult.issues.length === 0) { + keyResult = retryResult; + } + } + if (keyResult.issues.length) { + if (def.mode === "loose") { + // Pass through unchanged + payload.value[key] = input[key]; + } + else { + // Default "strict" behavior: error on invalid key + payload.issues.push({ + code: "invalid_key", + origin: "record", + issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())), + input: key, + path: [key], + inst, + }); + } + continue; + } + const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx); + if (result instanceof Promise) { + proms.push(result.then((result) => { + if (result.issues.length) { + payload.issues.push(...util.prefixIssues(key, result.issues)); + } + payload.value[keyResult.value] = result.value; + })); + } + else { + if (result.issues.length) { + payload.issues.push(...util.prefixIssues(key, result.issues)); + } + payload.value[keyResult.value] = result.value; + } + } + } + if (proms.length) { + return Promise.all(proms).then(() => payload); + } + return payload; + }; +}); +exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, ctx) => { + const input = payload.value; + if (!(input instanceof Map)) { + payload.issues.push({ + expected: "map", + code: "invalid_type", + input, + inst, + }); + return payload; + } + const proms = []; + payload.value = new Map(); + for (const [key, value] of input) { + const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx); + const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx); + if (keyResult instanceof Promise || valueResult instanceof Promise) { + proms.push(Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => { + handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx); + })); + } + else { + handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx); + } + } + if (proms.length) + return Promise.all(proms).then(() => payload); + return payload; + }; +}); +function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) { + if (keyResult.issues.length) { + if (util.propertyKeyTypes.has(typeof key)) { + final.issues.push(...util.prefixIssues(key, keyResult.issues)); + } + else { + final.issues.push({ + code: "invalid_key", + origin: "map", + input, + inst, + issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())), + }); + } + } + if (valueResult.issues.length) { + if (util.propertyKeyTypes.has(typeof key)) { + final.issues.push(...util.prefixIssues(key, valueResult.issues)); + } + else { + final.issues.push({ + origin: "map", + code: "invalid_element", + input, + inst, + key: key, + issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())), + }); + } + } + final.value.set(keyResult.value, valueResult.value); +} +exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, ctx) => { + const input = payload.value; + if (!(input instanceof Set)) { + payload.issues.push({ + input, + inst, + expected: "set", + code: "invalid_type", + }); + return payload; + } + const proms = []; + payload.value = new Set(); + for (const item of input) { + const result = def.valueType._zod.run({ value: item, issues: [] }, ctx); + if (result instanceof Promise) { + proms.push(result.then((result) => handleSetResult(result, payload))); + } + else + handleSetResult(result, payload); + } + if (proms.length) + return Promise.all(proms).then(() => payload); + return payload; + }; +}); +function handleSetResult(result, final) { + if (result.issues.length) { + final.issues.push(...result.issues); + } + final.value.add(result.value); +} +exports.$ZodEnum = core.$constructor("$ZodEnum", (inst, def) => { + exports.$ZodType.init(inst, def); + const values = util.getEnumValues(def.entries); + const valuesSet = new Set(values); + inst._zod.values = valuesSet; + inst._zod.pattern = new RegExp(`^(${values + .filter((k) => util.propertyKeyTypes.has(typeof k)) + .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString())) + .join("|")})$`); + inst._zod.parse = (payload, _ctx) => { + const input = payload.value; + if (valuesSet.has(input)) { + return payload; + } + payload.issues.push({ + code: "invalid_value", + values, + input, + inst, + }); + return payload; + }; +}); +exports.$ZodLiteral = core.$constructor("$ZodLiteral", (inst, def) => { + exports.$ZodType.init(inst, def); + if (def.values.length === 0) { + throw new Error("Cannot create literal schema with no valid values"); + } + const values = new Set(def.values); + inst._zod.values = values; + inst._zod.pattern = new RegExp(`^(${def.values + .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o))) + .join("|")})$`); + inst._zod.parse = (payload, _ctx) => { + const input = payload.value; + if (values.has(input)) { + return payload; + } + payload.issues.push({ + code: "invalid_value", + values: def.values, + input, + inst, + }); + return payload; + }; +}); +exports.$ZodFile = core.$constructor("$ZodFile", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, _ctx) => { + const input = payload.value; + // @ts-ignore + if (input instanceof File) + return payload; + payload.issues.push({ + expected: "file", + code: "invalid_type", + input, + inst, + }); + return payload; + }; +}); +exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.optin = "optional"; + inst._zod.parse = (payload, ctx) => { + if (ctx.direction === "backward") { + throw new core.$ZodEncodeError(inst.constructor.name); + } + const _out = def.transform(payload.value, payload); + if (ctx.async) { + const output = _out instanceof Promise ? _out : Promise.resolve(_out); + return output.then((output) => { + payload.value = output; + payload.fallback = true; + return payload; + }); + } + if (_out instanceof Promise) { + throw new core.$ZodAsyncError(); + } + payload.value = _out; + payload.fallback = true; + return payload; + }; +}); +function handleOptionalResult(result, input) { + if (input === undefined && (result.issues.length || result.fallback)) { + return { issues: [], value: undefined }; + } + return result; +} +exports.$ZodOptional = core.$constructor("$ZodOptional", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.optin = "optional"; + inst._zod.optout = "optional"; + util.defineLazy(inst._zod, "values", () => { + return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined; + }); + util.defineLazy(inst._zod, "pattern", () => { + const pattern = def.innerType._zod.pattern; + return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined; + }); + inst._zod.parse = (payload, ctx) => { + if (def.innerType._zod.optin === "optional") { + const input = payload.value; + const result = def.innerType._zod.run(payload, ctx); + if (result instanceof Promise) + return result.then((r) => handleOptionalResult(r, input)); + return handleOptionalResult(result, input); + } + if (payload.value === undefined) { + return payload; + } + return def.innerType._zod.run(payload, ctx); + }; +}); +exports.$ZodExactOptional = core.$constructor("$ZodExactOptional", (inst, def) => { + // Call parent init - inherits optin/optout = "optional" + exports.$ZodOptional.init(inst, def); + // Override values/pattern to NOT add undefined + util.defineLazy(inst._zod, "values", () => def.innerType._zod.values); + util.defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern); + // Override parse to just delegate (no undefined handling) + inst._zod.parse = (payload, ctx) => { + return def.innerType._zod.run(payload, ctx); + }; +}); +exports.$ZodNullable = core.$constructor("$ZodNullable", (inst, def) => { + exports.$ZodType.init(inst, def); + util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin); + util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout); + util.defineLazy(inst._zod, "pattern", () => { + const pattern = def.innerType._zod.pattern; + return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined; + }); + util.defineLazy(inst._zod, "values", () => { + return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined; + }); + inst._zod.parse = (payload, ctx) => { + // Forward direction (decode): allow null to pass through + if (payload.value === null) + return payload; + return def.innerType._zod.run(payload, ctx); + }; +}); +exports.$ZodDefault = core.$constructor("$ZodDefault", (inst, def) => { + exports.$ZodType.init(inst, def); + // inst._zod.qin = "true"; + inst._zod.optin = "optional"; + util.defineLazy(inst._zod, "values", () => def.innerType._zod.values); + inst._zod.parse = (payload, ctx) => { + if (ctx.direction === "backward") { + return def.innerType._zod.run(payload, ctx); + } + // Forward direction (decode): apply defaults for undefined input + if (payload.value === undefined) { + payload.value = def.defaultValue; + /** + * $ZodDefault returns the default value immediately in forward direction. + * 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. */ + return payload; + } + // Forward direction: continue with default handling + const result = def.innerType._zod.run(payload, ctx); + if (result instanceof Promise) { + return result.then((result) => handleDefaultResult(result, def)); + } + return handleDefaultResult(result, def); + }; +}); +function handleDefaultResult(payload, def) { + if (payload.value === undefined) { + payload.value = def.defaultValue; + } + return payload; +} +exports.$ZodPrefault = core.$constructor("$ZodPrefault", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.optin = "optional"; + util.defineLazy(inst._zod, "values", () => def.innerType._zod.values); + inst._zod.parse = (payload, ctx) => { + if (ctx.direction === "backward") { + return def.innerType._zod.run(payload, ctx); + } + // Forward direction (decode): apply prefault for undefined input + if (payload.value === undefined) { + payload.value = def.defaultValue; + } + return def.innerType._zod.run(payload, ctx); + }; +}); +exports.$ZodNonOptional = core.$constructor("$ZodNonOptional", (inst, def) => { + exports.$ZodType.init(inst, def); + util.defineLazy(inst._zod, "values", () => { + const v = def.innerType._zod.values; + return v ? new Set([...v].filter((x) => x !== undefined)) : undefined; + }); + inst._zod.parse = (payload, ctx) => { + const result = def.innerType._zod.run(payload, ctx); + if (result instanceof Promise) { + return result.then((result) => handleNonOptionalResult(result, inst)); + } + return handleNonOptionalResult(result, inst); + }; +}); +function handleNonOptionalResult(payload, inst) { + if (!payload.issues.length && payload.value === undefined) { + payload.issues.push({ + code: "invalid_type", + expected: "nonoptional", + input: payload.value, + inst, + }); + } + return payload; +} +exports.$ZodSuccess = core.$constructor("$ZodSuccess", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, ctx) => { + if (ctx.direction === "backward") { + throw new core.$ZodEncodeError("ZodSuccess"); + } + const result = def.innerType._zod.run(payload, ctx); + if (result instanceof Promise) { + return result.then((result) => { + payload.value = result.issues.length === 0; + return payload; + }); + } + payload.value = result.issues.length === 0; + return payload; + }; +}); +exports.$ZodCatch = core.$constructor("$ZodCatch", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.optin = "optional"; + util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout); + util.defineLazy(inst._zod, "values", () => def.innerType._zod.values); + inst._zod.parse = (payload, ctx) => { + if (ctx.direction === "backward") { + return def.innerType._zod.run(payload, ctx); + } + // Forward direction (decode): apply catch logic + const result = def.innerType._zod.run(payload, ctx); + if (result instanceof Promise) { + return result.then((result) => { + payload.value = result.value; + if (result.issues.length) { + payload.value = def.catchValue({ + ...payload, + error: { + issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())), + }, + input: payload.value, + }); + payload.issues = []; + payload.fallback = true; + } + return payload; + }); + } + payload.value = result.value; + if (result.issues.length) { + payload.value = def.catchValue({ + ...payload, + error: { + issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())), + }, + input: payload.value, + }); + payload.issues = []; + payload.fallback = true; + } + return payload; + }; +}); +exports.$ZodNaN = core.$constructor("$ZodNaN", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, _ctx) => { + if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) { + payload.issues.push({ + input: payload.value, + inst, + expected: "nan", + code: "invalid_type", + }); + return payload; + } + return payload; + }; +}); +exports.$ZodPipe = core.$constructor("$ZodPipe", (inst, def) => { + exports.$ZodType.init(inst, def); + util.defineLazy(inst._zod, "values", () => def.in._zod.values); + util.defineLazy(inst._zod, "optin", () => def.in._zod.optin); + util.defineLazy(inst._zod, "optout", () => def.out._zod.optout); + util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues); + inst._zod.parse = (payload, ctx) => { + if (ctx.direction === "backward") { + const right = def.out._zod.run(payload, ctx); + if (right instanceof Promise) { + return right.then((right) => handlePipeResult(right, def.in, ctx)); + } + return handlePipeResult(right, def.in, ctx); + } + const left = def.in._zod.run(payload, ctx); + if (left instanceof Promise) { + return left.then((left) => handlePipeResult(left, def.out, ctx)); + } + return handlePipeResult(left, def.out, ctx); + }; +}); +function handlePipeResult(left, next, ctx) { + if (left.issues.length) { + // prevent further checks + left.aborted = true; + return left; + } + return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx); +} +exports.$ZodCodec = core.$constructor("$ZodCodec", (inst, def) => { + exports.$ZodType.init(inst, def); + util.defineLazy(inst._zod, "values", () => def.in._zod.values); + util.defineLazy(inst._zod, "optin", () => def.in._zod.optin); + util.defineLazy(inst._zod, "optout", () => def.out._zod.optout); + util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues); + inst._zod.parse = (payload, ctx) => { + const direction = ctx.direction || "forward"; + if (direction === "forward") { + const left = def.in._zod.run(payload, ctx); + if (left instanceof Promise) { + return left.then((left) => handleCodecAResult(left, def, ctx)); + } + return handleCodecAResult(left, def, ctx); + } + else { + const right = def.out._zod.run(payload, ctx); + if (right instanceof Promise) { + return right.then((right) => handleCodecAResult(right, def, ctx)); + } + return handleCodecAResult(right, def, ctx); + } + }; +}); +function handleCodecAResult(result, def, ctx) { + if (result.issues.length) { + // prevent further checks + result.aborted = true; + return result; + } + const direction = ctx.direction || "forward"; + if (direction === "forward") { + const transformed = def.transform(result.value, result); + if (transformed instanceof Promise) { + return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx)); + } + return handleCodecTxResult(result, transformed, def.out, ctx); + } + else { + const transformed = def.reverseTransform(result.value, result); + if (transformed instanceof Promise) { + return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx)); + } + return handleCodecTxResult(result, transformed, def.in, ctx); + } +} +function handleCodecTxResult(left, value, nextSchema, ctx) { + // Check if transform added any issues + if (left.issues.length) { + left.aborted = true; + return left; + } + return nextSchema._zod.run({ value, issues: left.issues }, ctx); +} +exports.$ZodPreprocess = core.$constructor("$ZodPreprocess", (inst, def) => { + exports.$ZodPipe.init(inst, def); +}); +exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => { + exports.$ZodType.init(inst, def); + util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues); + util.defineLazy(inst._zod, "values", () => def.innerType._zod.values); + util.defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin); + util.defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout); + inst._zod.parse = (payload, ctx) => { + if (ctx.direction === "backward") { + return def.innerType._zod.run(payload, ctx); + } + const result = def.innerType._zod.run(payload, ctx); + if (result instanceof Promise) { + return result.then(handleReadonlyResult); + } + return handleReadonlyResult(result); + }; +}); +function handleReadonlyResult(payload) { + payload.value = Object.freeze(payload.value); + return payload; +} +exports.$ZodTemplateLiteral = core.$constructor("$ZodTemplateLiteral", (inst, def) => { + exports.$ZodType.init(inst, def); + const regexParts = []; + for (const part of def.parts) { + if (typeof part === "object" && part !== null) { + // is Zod schema + if (!part._zod.pattern) { + // if (!source) + throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`); + } + const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern; + if (!source) + throw new Error(`Invalid template literal part: ${part._zod.traits}`); + const start = source.startsWith("^") ? 1 : 0; + const end = source.endsWith("$") ? source.length - 1 : source.length; + regexParts.push(source.slice(start, end)); + } + else if (part === null || util.primitiveTypes.has(typeof part)) { + regexParts.push(util.escapeRegex(`${part}`)); + } + else { + throw new Error(`Invalid template literal part: ${part}`); + } + } + inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`); + inst._zod.parse = (payload, _ctx) => { + if (typeof payload.value !== "string") { + payload.issues.push({ + input: payload.value, + inst, + expected: "string", + code: "invalid_type", + }); + return payload; + } + inst._zod.pattern.lastIndex = 0; + if (!inst._zod.pattern.test(payload.value)) { + payload.issues.push({ + input: payload.value, + inst, + code: "invalid_format", + format: def.format ?? "template_literal", + pattern: inst._zod.pattern.source, + }); + return payload; + } + return payload; + }; +}); +exports.$ZodFunction = core.$constructor("$ZodFunction", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._def = def; + inst._zod.def = def; + inst.implement = (func) => { + if (typeof func !== "function") { + throw new Error("implement() must be called with a function"); + } + return function (...args) { + const parsedArgs = inst._def.input ? (0, parse_js_1.parse)(inst._def.input, args) : args; + const result = Reflect.apply(func, this, parsedArgs); + if (inst._def.output) { + return (0, parse_js_1.parse)(inst._def.output, result); + } + return result; + }; + }; + inst.implementAsync = (func) => { + if (typeof func !== "function") { + throw new Error("implementAsync() must be called with a function"); + } + return async function (...args) { + const parsedArgs = inst._def.input ? await (0, parse_js_1.parseAsync)(inst._def.input, args) : args; + const result = await Reflect.apply(func, this, parsedArgs); + if (inst._def.output) { + return await (0, parse_js_1.parseAsync)(inst._def.output, result); + } + return result; + }; + }; + inst._zod.parse = (payload, _ctx) => { + if (typeof payload.value !== "function") { + payload.issues.push({ + code: "invalid_type", + expected: "function", + input: payload.value, + inst, + }); + return payload; + } + // Check if output is a promise type to determine if we should use async implementation + const hasPromiseOutput = inst._def.output && inst._def.output._zod.def.type === "promise"; + if (hasPromiseOutput) { + payload.value = inst.implementAsync(payload.value); + } + else { + payload.value = inst.implement(payload.value); + } + return payload; + }; + inst.input = (...args) => { + const F = inst.constructor; + if (Array.isArray(args[0])) { + return new F({ + type: "function", + input: new exports.$ZodTuple({ + type: "tuple", + items: args[0], + rest: args[1], + }), + output: inst._def.output, + }); + } + return new F({ + type: "function", + input: args[0], + output: inst._def.output, + }); + }; + inst.output = (output) => { + const F = inst.constructor; + return new F({ + type: "function", + input: inst._def.input, + output, + }); + }; + return inst; +}); +exports.$ZodPromise = core.$constructor("$ZodPromise", (inst, def) => { + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, ctx) => { + return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx)); + }; +}); +exports.$ZodLazy = core.$constructor("$ZodLazy", (inst, def) => { + exports.$ZodType.init(inst, def); + // Cache the resolved inner type on the shared `def` so all clones of this + // lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance, + // preserving identity for cycle detection on recursive schemas. + util.defineLazy(inst._zod, "innerType", () => { + const d = def; + if (!d._cachedInner) + d._cachedInner = def.getter(); + return d._cachedInner; + }); + util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern); + util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues); + util.defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined); + util.defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? undefined); + inst._zod.parse = (payload, ctx) => { + const inner = inst._zod.innerType; + return inner._zod.run(payload, ctx); + }; +}); +exports.$ZodCustom = core.$constructor("$ZodCustom", (inst, def) => { + checks.$ZodCheck.init(inst, def); + exports.$ZodType.init(inst, def); + inst._zod.parse = (payload, _) => { + return payload; + }; + inst._zod.check = (payload) => { + const input = payload.value; + const r = def.fn(input); + if (r instanceof Promise) { + return r.then((r) => handleRefineResult(r, payload, input, inst)); + } + handleRefineResult(r, payload, input, inst); + return; + }; +}); +function handleRefineResult(result, payload, input, inst) { + if (!result) { + const _iss = { + code: "custom", + input, + inst, // incorporates params.error into issue reporting + path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting + continue: !inst._zod.def.abort, + // params: inst._zod.def.params, + }; + if (inst._zod.def.params) + _iss.params = inst._zod.def.params; + payload.issues.push(util.issue(_iss)); + } +} diff --git a/node_modules/zod/v4/core/schemas.d.cts b/node_modules/zod/v4/core/schemas.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..d2e8afd228c13e30716af25dc0ef345ea0c89a4c --- /dev/null +++ b/node_modules/zod/v4/core/schemas.d.cts @@ -0,0 +1,1184 @@ +import * as checks from "./checks.cjs"; +import * as core from "./core.cjs"; +import type * as errors from "./errors.cjs"; +import type * as JSONSchema from "./json-schema.cjs"; +import type { StandardSchemaV1 } from "./standard-schema.cjs"; +import type { ProcessParams, ToJSONSchemaContext } from "./to-json-schema.cjs"; +import * as util from "./util.cjs"; +import { version } from "./versions.cjs"; +export interface ParseContext { + /** Customize error messages. */ + readonly error?: errors.$ZodErrorMap; + /** Include the `input` field in issue objects. Default `false`. */ + readonly reportInput?: boolean; + /** Skip eval-based fast path. Default `false`. */ + readonly jitless?: boolean; +} +/** @internal */ +export interface ParseContextInternal extends ParseContext { + readonly async?: boolean | undefined; + readonly direction?: "forward" | "backward"; + readonly skipChecks?: boolean; +} +export interface ParsePayload { + value: T; + issues: errors.$ZodRawIssue[]; + /** A way to mark a whole payload as aborted. Used in codecs/pipes. */ + aborted?: boolean; + /** @internal Marks a value as a fallback that an outer wrapper (e.g. + * $ZodOptional) may override with its own interpretation when input was + * undefined. Set by $ZodCatch when catchValue substitutes and by every + * $ZodTransform invocation. */ + fallback?: boolean | undefined; +} +export type CheckFn = (input: ParsePayload) => util.MaybeAsync; +export interface $ZodTypeDef { + 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" | "function" | "custom"; + error?: errors.$ZodErrorMap | undefined; + checks?: checks.$ZodCheck[]; +} +export interface _$ZodTypeInternals { + /** The `@zod/core` version of this schema */ + version: typeof version; + /** Schema definition. */ + def: $ZodTypeDef; + /** @internal Randomly generated ID for this schema. */ + /** @internal List of deferred initializers. */ + deferred: util.AnyFunc[] | undefined; + /** @internal Parses input and runs all checks (refinements). */ + run(payload: ParsePayload, ctx: ParseContextInternal): util.MaybeAsync; + /** @internal Parses input, doesn't run checks. */ + parse(payload: ParsePayload, ctx: ParseContextInternal): util.MaybeAsync; + /** @internal Stores identifiers for the set of traits implemented by this schema. */ + traits: Set; + /** @internal Indicates that a schema output type should be considered optional inside objects. + * @default Required + */ + /** @internal */ + optin?: "optional" | undefined; + /** @internal */ + optout?: "optional" | undefined; + /** @internal The set of literal values that will pass validation. Must be an exhaustive set. Used to determine optionality in z.record(). + * + * Defined on: enum, const, literal, null, undefined + * Passthrough: optional, nullable, branded, default, catch, pipe + * Todo: unions? + */ + values?: util.PrimitiveSet | undefined; + /** Default value bubbled up from */ + /** @internal A set of literal discriminators used for the fast path in discriminated unions. */ + propValues?: util.PropValues | undefined; + /** @internal This flag indicates that a schema validation can be represented with a regular expression. Used to determine allowable schemas in z.templateLiteral(). */ + pattern: RegExp | undefined; + /** @internal The constructor function of this schema. */ + constr: new (def: any) => $ZodType; + /** @internal A catchall object for bag metadata related to this schema. Commonly modified by checks using `onattach`. */ + bag: Record; + /** @internal The set of issues this schema might throw during type checking. */ + isst: errors.$ZodIssueBase; + /** @internal Subject to change, not a public API. */ + processJSONSchema?: ((ctx: ToJSONSchemaContext, json: JSONSchema.BaseSchema, params: ProcessParams) => void) | undefined; + /** An optional method used to override `toJSONSchema` logic. */ + toJSONSchema?: () => unknown; + /** @internal The parent of this schema. Only set during certain clone operations. */ + parent?: $ZodType | undefined; +} +/** @internal */ +export interface $ZodTypeInternals extends _$ZodTypeInternals { + /** @internal The inferred output type */ + output: O; + /** @internal The inferred input type */ + input: I; +} +export type $ZodStandardSchema = StandardSchemaV1.Props, core.output>; +export type SomeType = { + _zod: _$ZodTypeInternals; +}; +export interface $ZodType = $ZodTypeInternals> { + _zod: Internals; + "~standard": $ZodStandardSchema; +} +export interface _$ZodType extends $ZodType { +} +export declare const $ZodType: core.$constructor<$ZodType>; +export { clone } from "./util.cjs"; +export interface $ZodStringDef extends $ZodTypeDef { + type: "string"; + coerce?: boolean; + checks?: checks.$ZodCheck[]; +} +export interface $ZodStringInternals extends $ZodTypeInternals { + def: $ZodStringDef; + /** @deprecated Internal API, use with caution (not deprecated) */ + pattern: RegExp; + /** @deprecated Internal API, use with caution (not deprecated) */ + isst: errors.$ZodIssueInvalidType; + bag: util.LoosePartial<{ + minimum: number; + maximum: number; + patterns: Set; + format: string; + contentEncoding: string; + }>; +} +export interface $ZodString extends _$ZodType<$ZodStringInternals> { +} +export declare const $ZodString: core.$constructor<$ZodString>; +export interface $ZodStringFormatDef extends $ZodStringDef, checks.$ZodCheckStringFormatDef { +} +export interface $ZodStringFormatInternals extends $ZodStringInternals, checks.$ZodCheckStringFormatInternals { + def: $ZodStringFormatDef; +} +export interface $ZodStringFormat extends $ZodType { + _zod: $ZodStringFormatInternals; +} +export declare const $ZodStringFormat: core.$constructor<$ZodStringFormat>; +export interface $ZodGUIDDef extends $ZodStringFormatDef<"guid"> { +} +export interface $ZodGUIDInternals extends $ZodStringFormatInternals<"guid"> { +} +export interface $ZodGUID extends $ZodType { + _zod: $ZodGUIDInternals; +} +export declare const $ZodGUID: core.$constructor<$ZodGUID>; +export interface $ZodUUIDDef extends $ZodStringFormatDef<"uuid"> { + version?: "v1" | "v2" | "v3" | "v4" | "v5" | "v6" | "v7" | "v8"; +} +export interface $ZodUUIDInternals extends $ZodStringFormatInternals<"uuid"> { + def: $ZodUUIDDef; +} +export interface $ZodUUID extends $ZodType { + _zod: $ZodUUIDInternals; +} +export declare const $ZodUUID: core.$constructor<$ZodUUID>; +export interface $ZodEmailDef extends $ZodStringFormatDef<"email"> { +} +export interface $ZodEmailInternals extends $ZodStringFormatInternals<"email"> { +} +export interface $ZodEmail extends $ZodType { + _zod: $ZodEmailInternals; +} +export declare const $ZodEmail: core.$constructor<$ZodEmail>; +export interface $ZodURLDef extends $ZodStringFormatDef<"url"> { + hostname?: RegExp | undefined; + protocol?: RegExp | undefined; + normalize?: boolean | undefined; +} +export interface $ZodURLInternals extends $ZodStringFormatInternals<"url"> { + def: $ZodURLDef; +} +export interface $ZodURL extends $ZodType { + _zod: $ZodURLInternals; +} +export declare const $ZodURL: core.$constructor<$ZodURL>; +export interface $ZodEmojiDef extends $ZodStringFormatDef<"emoji"> { +} +export interface $ZodEmojiInternals extends $ZodStringFormatInternals<"emoji"> { +} +export interface $ZodEmoji extends $ZodType { + _zod: $ZodEmojiInternals; +} +export declare const $ZodEmoji: core.$constructor<$ZodEmoji>; +export interface $ZodNanoIDDef extends $ZodStringFormatDef<"nanoid"> { +} +export interface $ZodNanoIDInternals extends $ZodStringFormatInternals<"nanoid"> { +} +export interface $ZodNanoID extends $ZodType { + _zod: $ZodNanoIDInternals; +} +export declare const $ZodNanoID: core.$constructor<$ZodNanoID>; +/** + * @deprecated CUID v1 is deprecated by its authors due to information leakage + * (timestamps embedded in the id). Use {@link $ZodCUID2} instead. + * See https://github.com/paralleldrive/cuid. + */ +export interface $ZodCUIDDef extends $ZodStringFormatDef<"cuid"> { +} +/** + * @deprecated CUID v1 is deprecated by its authors due to information leakage + * (timestamps embedded in the id). Use {@link $ZodCUID2} instead. + * See https://github.com/paralleldrive/cuid. + */ +export interface $ZodCUIDInternals extends $ZodStringFormatInternals<"cuid"> { +} +/** + * @deprecated CUID v1 is deprecated by its authors due to information leakage + * (timestamps embedded in the id). Use {@link $ZodCUID2} instead. + * See https://github.com/paralleldrive/cuid. + */ +export interface $ZodCUID extends $ZodType { + _zod: $ZodCUIDInternals; +} +/** + * @deprecated CUID v1 is deprecated by its authors due to information leakage + * (timestamps embedded in the id). Use {@link $ZodCUID2} instead. + * See https://github.com/paralleldrive/cuid. + */ +export declare const $ZodCUID: core.$constructor<$ZodCUID>; +export interface $ZodCUID2Def extends $ZodStringFormatDef<"cuid2"> { +} +export interface $ZodCUID2Internals extends $ZodStringFormatInternals<"cuid2"> { +} +export interface $ZodCUID2 extends $ZodType { + _zod: $ZodCUID2Internals; +} +export declare const $ZodCUID2: core.$constructor<$ZodCUID2>; +export interface $ZodULIDDef extends $ZodStringFormatDef<"ulid"> { +} +export interface $ZodULIDInternals extends $ZodStringFormatInternals<"ulid"> { +} +export interface $ZodULID extends $ZodType { + _zod: $ZodULIDInternals; +} +export declare const $ZodULID: core.$constructor<$ZodULID>; +export interface $ZodXIDDef extends $ZodStringFormatDef<"xid"> { +} +export interface $ZodXIDInternals extends $ZodStringFormatInternals<"xid"> { +} +export interface $ZodXID extends $ZodType { + _zod: $ZodXIDInternals; +} +export declare const $ZodXID: core.$constructor<$ZodXID>; +export interface $ZodKSUIDDef extends $ZodStringFormatDef<"ksuid"> { +} +export interface $ZodKSUIDInternals extends $ZodStringFormatInternals<"ksuid"> { +} +export interface $ZodKSUID extends $ZodType { + _zod: $ZodKSUIDInternals; +} +export declare const $ZodKSUID: core.$constructor<$ZodKSUID>; +export interface $ZodISODateTimeDef extends $ZodStringFormatDef<"datetime"> { + precision: number | null; + offset: boolean; + local: boolean; +} +export interface $ZodISODateTimeInternals extends $ZodStringFormatInternals { + def: $ZodISODateTimeDef; +} +export interface $ZodISODateTime extends $ZodType { + _zod: $ZodISODateTimeInternals; +} +export declare const $ZodISODateTime: core.$constructor<$ZodISODateTime>; +export interface $ZodISODateDef extends $ZodStringFormatDef<"date"> { +} +export interface $ZodISODateInternals extends $ZodStringFormatInternals<"date"> { +} +export interface $ZodISODate extends $ZodType { + _zod: $ZodISODateInternals; +} +export declare const $ZodISODate: core.$constructor<$ZodISODate>; +export interface $ZodISOTimeDef extends $ZodStringFormatDef<"time"> { + precision?: number | null; +} +export interface $ZodISOTimeInternals extends $ZodStringFormatInternals<"time"> { + def: $ZodISOTimeDef; +} +export interface $ZodISOTime extends $ZodType { + _zod: $ZodISOTimeInternals; +} +export declare const $ZodISOTime: core.$constructor<$ZodISOTime>; +export interface $ZodISODurationDef extends $ZodStringFormatDef<"duration"> { +} +export interface $ZodISODurationInternals extends $ZodStringFormatInternals<"duration"> { +} +export interface $ZodISODuration extends $ZodType { + _zod: $ZodISODurationInternals; +} +export declare const $ZodISODuration: core.$constructor<$ZodISODuration>; +export interface $ZodIPv4Def extends $ZodStringFormatDef<"ipv4"> { + version?: "v4"; +} +export interface $ZodIPv4Internals extends $ZodStringFormatInternals<"ipv4"> { + def: $ZodIPv4Def; +} +export interface $ZodIPv4 extends $ZodType { + _zod: $ZodIPv4Internals; +} +export declare const $ZodIPv4: core.$constructor<$ZodIPv4>; +export interface $ZodIPv6Def extends $ZodStringFormatDef<"ipv6"> { + version?: "v6"; +} +export interface $ZodIPv6Internals extends $ZodStringFormatInternals<"ipv6"> { + def: $ZodIPv6Def; +} +export interface $ZodIPv6 extends $ZodType { + _zod: $ZodIPv6Internals; +} +export declare const $ZodIPv6: core.$constructor<$ZodIPv6>; +export interface $ZodMACDef extends $ZodStringFormatDef<"mac"> { + delimiter?: string; +} +export interface $ZodMACInternals extends $ZodStringFormatInternals<"mac"> { + def: $ZodMACDef; +} +export interface $ZodMAC extends $ZodType { + _zod: $ZodMACInternals; +} +export declare const $ZodMAC: core.$constructor<$ZodMAC>; +export interface $ZodCIDRv4Def extends $ZodStringFormatDef<"cidrv4"> { + version?: "v4"; +} +export interface $ZodCIDRv4Internals extends $ZodStringFormatInternals<"cidrv4"> { + def: $ZodCIDRv4Def; +} +export interface $ZodCIDRv4 extends $ZodType { + _zod: $ZodCIDRv4Internals; +} +export declare const $ZodCIDRv4: core.$constructor<$ZodCIDRv4>; +export interface $ZodCIDRv6Def extends $ZodStringFormatDef<"cidrv6"> { + version?: "v6"; +} +export interface $ZodCIDRv6Internals extends $ZodStringFormatInternals<"cidrv6"> { + def: $ZodCIDRv6Def; +} +export interface $ZodCIDRv6 extends $ZodType { + _zod: $ZodCIDRv6Internals; +} +export declare const $ZodCIDRv6: core.$constructor<$ZodCIDRv6>; +export declare function isValidBase64(data: string): boolean; +export interface $ZodBase64Def extends $ZodStringFormatDef<"base64"> { +} +export interface $ZodBase64Internals extends $ZodStringFormatInternals<"base64"> { +} +export interface $ZodBase64 extends $ZodType { + _zod: $ZodBase64Internals; +} +export declare const $ZodBase64: core.$constructor<$ZodBase64>; +export declare function isValidBase64URL(data: string): boolean; +export interface $ZodBase64URLDef extends $ZodStringFormatDef<"base64url"> { +} +export interface $ZodBase64URLInternals extends $ZodStringFormatInternals<"base64url"> { +} +export interface $ZodBase64URL extends $ZodType { + _zod: $ZodBase64URLInternals; +} +export declare const $ZodBase64URL: core.$constructor<$ZodBase64URL>; +export interface $ZodE164Def extends $ZodStringFormatDef<"e164"> { +} +export interface $ZodE164Internals extends $ZodStringFormatInternals<"e164"> { +} +export interface $ZodE164 extends $ZodType { + _zod: $ZodE164Internals; +} +export declare const $ZodE164: core.$constructor<$ZodE164>; +export declare function isValidJWT(token: string, algorithm?: util.JWTAlgorithm | null): boolean; +export interface $ZodJWTDef extends $ZodStringFormatDef<"jwt"> { + alg?: util.JWTAlgorithm | undefined; +} +export interface $ZodJWTInternals extends $ZodStringFormatInternals<"jwt"> { + def: $ZodJWTDef; +} +export interface $ZodJWT extends $ZodType { + _zod: $ZodJWTInternals; +} +export declare const $ZodJWT: core.$constructor<$ZodJWT>; +export interface $ZodCustomStringFormatDef extends $ZodStringFormatDef { + fn: (val: string) => unknown; +} +export interface $ZodCustomStringFormatInternals extends $ZodStringFormatInternals { + def: $ZodCustomStringFormatDef; +} +export interface $ZodCustomStringFormat extends $ZodStringFormat { + _zod: $ZodCustomStringFormatInternals; +} +export declare const $ZodCustomStringFormat: core.$constructor<$ZodCustomStringFormat>; +export interface $ZodNumberDef extends $ZodTypeDef { + type: "number"; + coerce?: boolean; +} +export interface $ZodNumberInternals extends $ZodTypeInternals { + def: $ZodNumberDef; + /** @deprecated Internal API, use with caution (not deprecated) */ + pattern: RegExp; + /** @deprecated Internal API, use with caution (not deprecated) */ + isst: errors.$ZodIssueInvalidType; + bag: util.LoosePartial<{ + minimum: number; + maximum: number; + exclusiveMinimum: number; + exclusiveMaximum: number; + format: string; + pattern: RegExp; + }>; +} +export interface $ZodNumber extends $ZodType { + _zod: $ZodNumberInternals; +} +export declare const $ZodNumber: core.$constructor<$ZodNumber>; +export interface $ZodNumberFormatDef extends $ZodNumberDef, checks.$ZodCheckNumberFormatDef { +} +export interface $ZodNumberFormatInternals extends $ZodNumberInternals, checks.$ZodCheckNumberFormatInternals { + def: $ZodNumberFormatDef; + isst: errors.$ZodIssueInvalidType; +} +export interface $ZodNumberFormat extends $ZodType { + _zod: $ZodNumberFormatInternals; +} +export declare const $ZodNumberFormat: core.$constructor<$ZodNumberFormat>; +export interface $ZodBooleanDef extends $ZodTypeDef { + type: "boolean"; + coerce?: boolean; + checks?: checks.$ZodCheck[]; +} +export interface $ZodBooleanInternals extends $ZodTypeInternals { + pattern: RegExp; + def: $ZodBooleanDef; + isst: errors.$ZodIssueInvalidType; +} +export interface $ZodBoolean extends $ZodType { + _zod: $ZodBooleanInternals; +} +export declare const $ZodBoolean: core.$constructor<$ZodBoolean>; +export interface $ZodBigIntDef extends $ZodTypeDef { + type: "bigint"; + coerce?: boolean; +} +export interface $ZodBigIntInternals extends $ZodTypeInternals { + pattern: RegExp; + /** @internal Internal API, use with caution */ + def: $ZodBigIntDef; + isst: errors.$ZodIssueInvalidType; + bag: util.LoosePartial<{ + minimum: bigint; + maximum: bigint; + format: string; + }>; +} +export interface $ZodBigInt extends $ZodType { + _zod: $ZodBigIntInternals; +} +export declare const $ZodBigInt: core.$constructor<$ZodBigInt>; +export interface $ZodBigIntFormatDef extends $ZodBigIntDef, checks.$ZodCheckBigIntFormatDef { + check: "bigint_format"; +} +export interface $ZodBigIntFormatInternals extends $ZodBigIntInternals, checks.$ZodCheckBigIntFormatInternals { + def: $ZodBigIntFormatDef; +} +export interface $ZodBigIntFormat extends $ZodType { + _zod: $ZodBigIntFormatInternals; +} +export declare const $ZodBigIntFormat: core.$constructor<$ZodBigIntFormat>; +export interface $ZodSymbolDef extends $ZodTypeDef { + type: "symbol"; +} +export interface $ZodSymbolInternals extends $ZodTypeInternals { + def: $ZodSymbolDef; + isst: errors.$ZodIssueInvalidType; +} +export interface $ZodSymbol extends $ZodType { + _zod: $ZodSymbolInternals; +} +export declare const $ZodSymbol: core.$constructor<$ZodSymbol>; +export interface $ZodUndefinedDef extends $ZodTypeDef { + type: "undefined"; +} +export interface $ZodUndefinedInternals extends $ZodTypeInternals { + pattern: RegExp; + def: $ZodUndefinedDef; + values: util.PrimitiveSet; + isst: errors.$ZodIssueInvalidType; +} +export interface $ZodUndefined extends $ZodType { + _zod: $ZodUndefinedInternals; +} +export declare const $ZodUndefined: core.$constructor<$ZodUndefined>; +export interface $ZodNullDef extends $ZodTypeDef { + type: "null"; +} +export interface $ZodNullInternals extends $ZodTypeInternals { + pattern: RegExp; + def: $ZodNullDef; + values: util.PrimitiveSet; + isst: errors.$ZodIssueInvalidType; +} +export interface $ZodNull extends $ZodType { + _zod: $ZodNullInternals; +} +export declare const $ZodNull: core.$constructor<$ZodNull>; +export interface $ZodAnyDef extends $ZodTypeDef { + type: "any"; +} +export interface $ZodAnyInternals extends $ZodTypeInternals { + def: $ZodAnyDef; + isst: never; +} +export interface $ZodAny extends $ZodType { + _zod: $ZodAnyInternals; +} +export declare const $ZodAny: core.$constructor<$ZodAny>; +export interface $ZodUnknownDef extends $ZodTypeDef { + type: "unknown"; +} +export interface $ZodUnknownInternals extends $ZodTypeInternals { + def: $ZodUnknownDef; + isst: never; +} +export interface $ZodUnknown extends $ZodType { + _zod: $ZodUnknownInternals; +} +export declare const $ZodUnknown: core.$constructor<$ZodUnknown>; +export interface $ZodNeverDef extends $ZodTypeDef { + type: "never"; +} +export interface $ZodNeverInternals extends $ZodTypeInternals { + def: $ZodNeverDef; + isst: errors.$ZodIssueInvalidType; +} +export interface $ZodNever extends $ZodType { + _zod: $ZodNeverInternals; +} +export declare const $ZodNever: core.$constructor<$ZodNever>; +export interface $ZodVoidDef extends $ZodTypeDef { + type: "void"; +} +export interface $ZodVoidInternals extends $ZodTypeInternals { + def: $ZodVoidDef; + isst: errors.$ZodIssueInvalidType; +} +export interface $ZodVoid extends $ZodType { + _zod: $ZodVoidInternals; +} +export declare const $ZodVoid: core.$constructor<$ZodVoid>; +export interface $ZodDateDef extends $ZodTypeDef { + type: "date"; + coerce?: boolean; +} +export interface $ZodDateInternals extends $ZodTypeInternals { + def: $ZodDateDef; + isst: errors.$ZodIssueInvalidType; + bag: util.LoosePartial<{ + minimum: Date; + maximum: Date; + format: string; + }>; +} +export interface $ZodDate extends $ZodType { + _zod: $ZodDateInternals; +} +export declare const $ZodDate: core.$constructor<$ZodDate>; +export interface $ZodArrayDef extends $ZodTypeDef { + type: "array"; + element: T; +} +export interface $ZodArrayInternals extends _$ZodTypeInternals { + def: $ZodArrayDef; + isst: errors.$ZodIssueInvalidType; + output: core.output[]; + input: core.input[]; +} +export interface $ZodArray extends $ZodType> { +} +export declare const $ZodArray: core.$constructor<$ZodArray>; +type OptionalOutSchema = { + _zod: { + optout: "optional"; + }; +}; +type OptionalInSchema = { + _zod: { + optin: "optional"; + }; +}; +export type $InferObjectOutput> = string extends keyof T ? util.IsAny extends true ? Record : Record> : keyof (T & Extra) extends never ? Record : util.Prettify<{ + -readonly [k in keyof T as T[k] extends OptionalOutSchema ? never : k]: T[k]["_zod"]["output"]; +} & { + -readonly [k in keyof T as T[k] extends OptionalOutSchema ? k : never]?: T[k]["_zod"]["output"]; +} & Extra>; +export type $InferObjectInput> = string extends keyof T ? util.IsAny extends true ? Record : Record> : keyof (T & Extra) extends never ? Record : util.Prettify<{ + -readonly [k in keyof T as T[k] extends OptionalInSchema ? never : k]: T[k]["_zod"]["input"]; +} & { + -readonly [k in keyof T as T[k] extends OptionalInSchema ? k : never]?: T[k]["_zod"]["input"]; +} & Extra>; +export type $ZodObjectConfig = { + out: Record; + in: Record; +}; +export type $loose = { + out: Record; + in: Record; +}; +export type $strict = { + out: {}; + in: {}; +}; +export type $strip = { + out: {}; + in: {}; +}; +export type $catchall = { + out: { + [k: string]: core.output; + }; + in: { + [k: string]: core.input; + }; +}; +export type $ZodShape = Readonly<{ + [k: string]: $ZodType; +}>; +export interface $ZodObjectDef extends $ZodTypeDef { + type: "object"; + shape: Shape; + catchall?: $ZodType | undefined; +} +export interface $ZodObjectInternals< +/** @ts-ignore Cast variance */ +out Shape extends $ZodShape = $ZodShape, out Config extends $ZodObjectConfig = $ZodObjectConfig> extends _$ZodTypeInternals { + def: $ZodObjectDef; + config: Config; + isst: errors.$ZodIssueInvalidType | errors.$ZodIssueUnrecognizedKeys; + propValues: util.PropValues; + output: $InferObjectOutput; + input: $InferObjectInput; + optin?: "optional" | undefined; + optout?: "optional" | undefined; +} +export type $ZodLooseShape = Record; +export interface $ZodObject< +/** @ts-ignore Cast variance */ +out Shape extends Readonly<$ZodShape> = Readonly<$ZodShape>, out Params extends $ZodObjectConfig = $ZodObjectConfig> extends $ZodType> { +} +export declare const $ZodObject: core.$constructor<$ZodObject>; +export declare const $ZodObjectJIT: core.$constructor<$ZodObject>; +export type $InferUnionOutput = T extends any ? core.output : never; +export type $InferUnionInput = T extends any ? core.input : never; +export interface $ZodUnionDef extends $ZodTypeDef { + type: "union"; + options: Options; + inclusive?: boolean; +} +type IsOptionalIn = T extends OptionalInSchema ? true : false; +type IsOptionalOut = T extends OptionalOutSchema ? true : false; +export interface $ZodUnionInternals extends _$ZodTypeInternals { + def: $ZodUnionDef; + isst: errors.$ZodIssueInvalidUnion; + pattern: T[number]["_zod"]["pattern"]; + values: T[number]["_zod"]["values"]; + output: $InferUnionOutput; + input: $InferUnionInput; + optin: IsOptionalIn extends false ? "optional" | undefined : "optional"; + optout: IsOptionalOut extends false ? "optional" | undefined : "optional"; +} +export interface $ZodUnion extends $ZodType> { + _zod: $ZodUnionInternals; +} +export declare const $ZodUnion: core.$constructor<$ZodUnion>; +export interface $ZodXorInternals extends $ZodUnionInternals { +} +export interface $ZodXor extends $ZodType> { + _zod: $ZodXorInternals; +} +export declare const $ZodXor: core.$constructor<$ZodXor>; +export interface $ZodDiscriminatedUnionDef extends $ZodUnionDef { + discriminator: Disc; + unionFallback?: boolean; +} +export interface $ZodDiscriminatedUnionInternals extends $ZodUnionInternals { + def: $ZodDiscriminatedUnionDef; + propValues: util.PropValues; +} +export interface $ZodDiscriminatedUnion extends $ZodType { + _zod: $ZodDiscriminatedUnionInternals; +} +export declare const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion>; +export interface $ZodIntersectionDef extends $ZodTypeDef { + type: "intersection"; + left: Left; + right: Right; +} +export interface $ZodIntersectionInternals extends _$ZodTypeInternals { + def: $ZodIntersectionDef; + isst: never; + optin: A["_zod"]["optin"] | B["_zod"]["optin"]; + optout: A["_zod"]["optout"] | B["_zod"]["optout"]; + output: core.output & core.output; + input: core.input & core.input; +} +export interface $ZodIntersection extends $ZodType { + _zod: $ZodIntersectionInternals; +} +export declare const $ZodIntersection: core.$constructor<$ZodIntersection>; +export interface $ZodTupleDef extends $ZodTypeDef { + type: "tuple"; + items: T; + rest: Rest; +} +export type $InferTupleInputType = [ + ...TupleInputTypeWithOptionals, + ...(Rest extends SomeType ? core.input[] : []) +]; +type TupleInputTypeNoOptionals = { + [k in keyof T]: core.input; +}; +type TupleInputTypeWithOptionals = T extends readonly [ + ...infer Prefix extends SomeType[], + infer Tail extends SomeType +] ? Tail["_zod"]["optin"] extends "optional" ? [...TupleInputTypeWithOptionals, core.input?] : TupleInputTypeNoOptionals : []; +export type $InferTupleOutputType = [ + ...TupleOutputTypeWithOptionals, + ...(Rest extends SomeType ? core.output[] : []) +]; +type TupleOutputTypeNoOptionals = { + [k in keyof T]: core.output; +}; +type TupleOutputTypeWithOptionals = T extends readonly [ + ...infer Prefix extends SomeType[], + infer Tail extends SomeType +] ? Tail["_zod"]["optout"] extends "optional" ? [...TupleOutputTypeWithOptionals, core.output?] : TupleOutputTypeNoOptionals : []; +export interface $ZodTupleInternals extends _$ZodTypeInternals { + def: $ZodTupleDef; + isst: errors.$ZodIssueInvalidType | errors.$ZodIssueTooBig | errors.$ZodIssueTooSmall; + output: $InferTupleOutputType; + input: $InferTupleInputType; +} +export interface $ZodTuple extends $ZodType { + _zod: $ZodTupleInternals; +} +export declare const $ZodTuple: core.$constructor<$ZodTuple>; +export type $ZodRecordKey = $ZodType; +export interface $ZodRecordDef extends $ZodTypeDef { + type: "record"; + keyType: Key; + valueType: Value; + /** @default "strict" - errors on keys not matching keyType. "loose" passes through non-matching keys unchanged. */ + mode?: "strict" | "loose"; +} +export type $InferZodRecordOutput = Key extends $partial ? Partial, core.output>> : Record, core.output>; +export type $InferZodRecordInput = Key extends $partial ? Partial & PropertyKey, core.input>> : Record & PropertyKey, core.input>; +export interface $ZodRecordInternals extends $ZodTypeInternals<$InferZodRecordOutput, $InferZodRecordInput> { + def: $ZodRecordDef; + isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey>; + optin?: "optional" | undefined; + optout?: "optional" | undefined; +} +export type $partial = { + "~~partial": true; +}; +export interface $ZodRecord extends $ZodType { + _zod: $ZodRecordInternals; +} +export declare const $ZodRecord: core.$constructor<$ZodRecord>; +export interface $ZodMapDef extends $ZodTypeDef { + type: "map"; + keyType: Key; + valueType: Value; +} +export interface $ZodMapInternals extends $ZodTypeInternals, core.output>, Map, core.input>> { + def: $ZodMapDef; + isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey | errors.$ZodIssueInvalidElement; + optin?: "optional" | undefined; + optout?: "optional" | undefined; +} +export interface $ZodMap extends $ZodType { + _zod: $ZodMapInternals; +} +export declare const $ZodMap: core.$constructor<$ZodMap>; +export interface $ZodSetDef extends $ZodTypeDef { + type: "set"; + valueType: T; +} +export interface $ZodSetInternals extends $ZodTypeInternals>, Set>> { + def: $ZodSetDef; + isst: errors.$ZodIssueInvalidType; + optin?: "optional" | undefined; + optout?: "optional" | undefined; +} +export interface $ZodSet extends $ZodType { + _zod: $ZodSetInternals; +} +export declare const $ZodSet: core.$constructor<$ZodSet>; +export type $InferEnumOutput = T[keyof T] & {}; +export type $InferEnumInput = T[keyof T] & {}; +export interface $ZodEnumDef extends $ZodTypeDef { + type: "enum"; + entries: T; +} +export interface $ZodEnumInternals< +/** @ts-ignore Cast variance */ +out T extends util.EnumLike = util.EnumLike> extends $ZodTypeInternals<$InferEnumOutput, $InferEnumInput> { + def: $ZodEnumDef; + /** @deprecated Internal API, use with caution (not deprecated) */ + values: util.PrimitiveSet; + /** @deprecated Internal API, use with caution (not deprecated) */ + pattern: RegExp; + isst: errors.$ZodIssueInvalidValue; +} +export interface $ZodEnum extends $ZodType { + _zod: $ZodEnumInternals; +} +export declare const $ZodEnum: core.$constructor<$ZodEnum>; +export interface $ZodLiteralDef extends $ZodTypeDef { + type: "literal"; + values: T[]; +} +export interface $ZodLiteralInternals extends $ZodTypeInternals { + def: $ZodLiteralDef; + values: Set; + pattern: RegExp; + isst: errors.$ZodIssueInvalidValue; +} +export interface $ZodLiteral extends $ZodType { + _zod: $ZodLiteralInternals; +} +export declare const $ZodLiteral: core.$constructor<$ZodLiteral>; +type _File = typeof globalThis extends { + File: infer F extends new (...args: any[]) => any; +} ? InstanceType : {}; +/** Do not reference this directly. */ +export interface File extends _File { + readonly type: string; + readonly size: number; +} +export interface $ZodFileDef extends $ZodTypeDef { + type: "file"; +} +export interface $ZodFileInternals extends $ZodTypeInternals { + def: $ZodFileDef; + isst: errors.$ZodIssueInvalidType; + bag: util.LoosePartial<{ + minimum: number; + maximum: number; + mime: util.MimeTypes[]; + }>; +} +export interface $ZodFile extends $ZodType { + _zod: $ZodFileInternals; +} +export declare const $ZodFile: core.$constructor<$ZodFile>; +export interface $ZodTransformDef extends $ZodTypeDef { + type: "transform"; + transform: (input: unknown, payload: ParsePayload) => util.MaybeAsync; +} +export interface $ZodTransformInternals extends $ZodTypeInternals { + def: $ZodTransformDef; + isst: never; +} +export interface $ZodTransform extends $ZodType { + _zod: $ZodTransformInternals; +} +export declare const $ZodTransform: core.$constructor<$ZodTransform>; +export interface $ZodOptionalDef extends $ZodTypeDef { + type: "optional"; + innerType: T; +} +export interface $ZodOptionalInternals extends $ZodTypeInternals | undefined, core.input | undefined> { + def: $ZodOptionalDef; + optin: "optional"; + optout: "optional"; + isst: never; + values: T["_zod"]["values"]; + pattern: T["_zod"]["pattern"]; +} +export interface $ZodOptional extends $ZodType { + _zod: $ZodOptionalInternals; +} +export declare const $ZodOptional: core.$constructor<$ZodOptional>; +export interface $ZodExactOptionalDef extends $ZodOptionalDef { +} +export interface $ZodExactOptionalInternals extends $ZodOptionalInternals { + def: $ZodExactOptionalDef; + output: core.output; + input: core.input; +} +export interface $ZodExactOptional extends $ZodType { + _zod: $ZodExactOptionalInternals; +} +export declare const $ZodExactOptional: core.$constructor<$ZodExactOptional>; +export interface $ZodNullableDef extends $ZodTypeDef { + type: "nullable"; + innerType: T; +} +export interface $ZodNullableInternals extends $ZodTypeInternals | null, core.input | null> { + def: $ZodNullableDef; + optin: T["_zod"]["optin"]; + optout: T["_zod"]["optout"]; + isst: never; + values: T["_zod"]["values"]; + pattern: T["_zod"]["pattern"]; +} +export interface $ZodNullable extends $ZodType { + _zod: $ZodNullableInternals; +} +export declare const $ZodNullable: core.$constructor<$ZodNullable>; +export interface $ZodDefaultDef extends $ZodTypeDef { + type: "default"; + innerType: T; + /** The default value. May be a getter. */ + defaultValue: util.NoUndefined>; +} +export interface $ZodDefaultInternals extends $ZodTypeInternals>, core.input | undefined> { + def: $ZodDefaultDef; + optin: "optional"; + optout?: "optional" | undefined; + isst: never; + values: T["_zod"]["values"]; +} +export interface $ZodDefault extends $ZodType { + _zod: $ZodDefaultInternals; +} +export declare const $ZodDefault: core.$constructor<$ZodDefault>; +export interface $ZodPrefaultDef extends $ZodTypeDef { + type: "prefault"; + innerType: T; + /** The default value. May be a getter. */ + defaultValue: core.input; +} +export interface $ZodPrefaultInternals extends $ZodTypeInternals>, core.input | undefined> { + def: $ZodPrefaultDef; + optin: "optional"; + optout?: "optional" | undefined; + isst: never; + values: T["_zod"]["values"]; +} +export interface $ZodPrefault extends $ZodType { + _zod: $ZodPrefaultInternals; +} +export declare const $ZodPrefault: core.$constructor<$ZodPrefault>; +export interface $ZodNonOptionalDef extends $ZodTypeDef { + type: "nonoptional"; + innerType: T; +} +export interface $ZodNonOptionalInternals extends $ZodTypeInternals>, util.NoUndefined>> { + def: $ZodNonOptionalDef; + isst: errors.$ZodIssueInvalidType; + values: T["_zod"]["values"]; + optin: "optional" | undefined; + optout: "optional" | undefined; +} +export interface $ZodNonOptional extends $ZodType { + _zod: $ZodNonOptionalInternals; +} +export declare const $ZodNonOptional: core.$constructor<$ZodNonOptional>; +export interface $ZodSuccessDef extends $ZodTypeDef { + type: "success"; + innerType: T; +} +export interface $ZodSuccessInternals extends $ZodTypeInternals> { + def: $ZodSuccessDef; + isst: never; + optin: T["_zod"]["optin"]; + optout: "optional" | undefined; +} +export interface $ZodSuccess extends $ZodType { + _zod: $ZodSuccessInternals; +} +export declare const $ZodSuccess: core.$constructor<$ZodSuccess>; +export interface $ZodCatchCtx extends ParsePayload { + /** @deprecated Use `ctx.issues` */ + error: { + issues: errors.$ZodIssue[]; + }; + /** @deprecated Use `ctx.value` */ + input: unknown; +} +export interface $ZodCatchDef extends $ZodTypeDef { + type: "catch"; + innerType: T; + catchValue: (ctx: $ZodCatchCtx) => unknown; +} +export interface $ZodCatchInternals extends $ZodTypeInternals, core.input> { + def: $ZodCatchDef; + optin: T["_zod"]["optin"]; + optout: T["_zod"]["optout"]; + isst: never; + values: T["_zod"]["values"]; +} +export interface $ZodCatch extends $ZodType { + _zod: $ZodCatchInternals; +} +export declare const $ZodCatch: core.$constructor<$ZodCatch>; +export interface $ZodNaNDef extends $ZodTypeDef { + type: "nan"; +} +export interface $ZodNaNInternals extends $ZodTypeInternals { + def: $ZodNaNDef; + isst: errors.$ZodIssueInvalidType; +} +export interface $ZodNaN extends $ZodType { + _zod: $ZodNaNInternals; +} +export declare const $ZodNaN: core.$constructor<$ZodNaN>; +export interface $ZodPipeDef extends $ZodTypeDef { + type: "pipe"; + in: A; + out: B; + /** Only defined inside $ZodCodec instances. */ + transform?: (value: core.output, payload: ParsePayload>) => util.MaybeAsync>; + /** Only defined inside $ZodCodec instances. */ + reverseTransform?: (value: core.input, payload: ParsePayload>) => util.MaybeAsync>; +} +export interface $ZodPipeInternals extends $ZodTypeInternals, core.input> { + def: $ZodPipeDef; + isst: never; + values: A["_zod"]["values"]; + optin: A["_zod"]["optin"]; + optout: B["_zod"]["optout"]; + propValues: A["_zod"]["propValues"]; +} +export interface $ZodPipe extends $ZodType { + _zod: $ZodPipeInternals; +} +export declare const $ZodPipe: core.$constructor<$ZodPipe>; +export interface $ZodCodecDef extends $ZodPipeDef { + transform: (value: core.output, payload: ParsePayload>) => util.MaybeAsync>; + reverseTransform: (value: core.input, payload: ParsePayload>) => util.MaybeAsync>; +} +export interface $ZodCodecInternals extends $ZodTypeInternals, core.input> { + def: $ZodCodecDef; + isst: never; + values: A["_zod"]["values"]; + optin: A["_zod"]["optin"]; + optout: B["_zod"]["optout"]; + propValues: A["_zod"]["propValues"]; +} +export interface $ZodCodec extends $ZodType { + _zod: $ZodCodecInternals; +} +export declare const $ZodCodec: core.$constructor<$ZodCodec>; +export interface $ZodPreprocessDef extends $ZodPipeDef<$ZodTransform, B> { + in: $ZodTransform; + out: B; +} +export interface $ZodPreprocessInternals extends $ZodPipeInternals<$ZodTransform, B> { + def: $ZodPreprocessDef; + optin: B["_zod"]["optin"]; + optout: B["_zod"]["optout"]; +} +export interface $ZodPreprocess extends $ZodPipe<$ZodTransform, B> { + _zod: $ZodPreprocessInternals; +} +export declare const $ZodPreprocess: core.$constructor<$ZodPreprocess>; +export interface $ZodReadonlyDef extends $ZodTypeDef { + type: "readonly"; + innerType: T; +} +export interface $ZodReadonlyInternals extends $ZodTypeInternals>, util.MakeReadonly>> { + def: $ZodReadonlyDef; + optin: T["_zod"]["optin"]; + optout: T["_zod"]["optout"]; + isst: never; + propValues: T["_zod"]["propValues"]; + values: T["_zod"]["values"]; +} +export interface $ZodReadonly extends $ZodType { + _zod: $ZodReadonlyInternals; +} +export declare const $ZodReadonly: core.$constructor<$ZodReadonly>; +export interface $ZodTemplateLiteralDef extends $ZodTypeDef { + type: "template_literal"; + parts: $ZodTemplateLiteralPart[]; + format?: string | undefined; +} +export interface $ZodTemplateLiteralInternals