Spaces:
Paused
Paused
Upload folder using huggingface_hub (part 19)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- node_modules/zod-to-json-schema/.github/CR_logotype-full-color.png +0 -0
- node_modules/zod-to-json-schema/.github/FUNDING.yml +1 -0
- node_modules/zod-to-json-schema/.prettierrc.json +1 -0
- node_modules/zod-to-json-schema/LICENSE +15 -0
- node_modules/zod-to-json-schema/README.md +390 -0
- node_modules/zod-to-json-schema/changelog.md +83 -0
- node_modules/zod-to-json-schema/contributing.md +9 -0
- node_modules/zod-to-json-schema/createIndex.ts +32 -0
- node_modules/zod-to-json-schema/package.json +85 -0
- node_modules/zod-to-json-schema/postcjs.ts +3 -0
- node_modules/zod-to-json-schema/postesm.ts +3 -0
- node_modules/zod/v4-mini/index.cjs +32 -0
- node_modules/zod/v4-mini/index.d.cts +3 -0
- node_modules/zod/v4-mini/index.d.ts +3 -0
- node_modules/zod/v4-mini/index.js +3 -0
- node_modules/zod/v4-mini/package.json +7 -0
- node_modules/zod/v4/core/parse.d.ts +49 -0
- node_modules/zod/v4/core/parse.js +93 -0
- node_modules/zod/v4/core/regexes.cjs +172 -0
- node_modules/zod/v4/core/regexes.d.cts +85 -0
- node_modules/zod/v4/core/regexes.d.ts +85 -0
- node_modules/zod/v4/core/regexes.js +139 -0
- node_modules/zod/v4/core/registries.cjs +56 -0
- node_modules/zod/v4/core/registries.d.cts +35 -0
- node_modules/zod/v4/core/registries.d.ts +35 -0
- node_modules/zod/v4/core/registries.js +51 -0
- node_modules/zod/v4/core/schemas.cjs +2270 -0
- node_modules/zod/v4/core/schemas.d.cts +1184 -0
- node_modules/zod/v4/core/schemas.d.ts +1184 -0
- node_modules/zod/v4/core/schemas.js +2239 -0
- node_modules/zod/v4/core/standard-schema.cjs +2 -0
- node_modules/zod/v4/core/standard-schema.d.cts +126 -0
- node_modules/zod/v4/core/standard-schema.d.ts +126 -0
- node_modules/zod/v4/core/standard-schema.js +1 -0
- node_modules/zod/v4/core/to-json-schema.cjs +457 -0
- node_modules/zod/v4/core/to-json-schema.d.cts +114 -0
- node_modules/zod/v4/core/to-json-schema.d.ts +114 -0
- node_modules/zod/v4/core/to-json-schema.js +448 -0
- node_modules/zod/v4/core/util.cjs +734 -0
- node_modules/zod/v4/core/util.d.cts +200 -0
- node_modules/zod/v4/core/util.d.ts +200 -0
- node_modules/zod/v4/core/util.js +674 -0
- node_modules/zod/v4/core/versions.cjs +8 -0
- node_modules/zod/v4/core/versions.d.cts +5 -0
- node_modules/zod/v4/core/versions.d.ts +5 -0
- node_modules/zod/v4/core/versions.js +5 -0
- node_modules/zod/v4/index.cjs +22 -0
- node_modules/zod/v4/index.d.cts +3 -0
- node_modules/zod/v4/index.d.ts +3 -0
- node_modules/zod/v4/index.js +3 -0
node_modules/zod-to-json-schema/.github/CR_logotype-full-color.png
ADDED
|
node_modules/zod-to-json-schema/.github/FUNDING.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
github: [StefanTerdell]
|
node_modules/zod-to-json-schema/.prettierrc.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{}
|
node_modules/zod-to-json-schema/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ISC License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2020, Stefan Terdell
|
| 4 |
+
|
| 5 |
+
Permission to use, copy, modify, and/or distribute this software for any
|
| 6 |
+
purpose with or without fee is hereby granted, provided that the above
|
| 7 |
+
copyright notice and this permission notice appear in all copies.
|
| 8 |
+
|
| 9 |
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 10 |
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 11 |
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 12 |
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 13 |
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 14 |
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 15 |
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
node_modules/zod-to-json-schema/README.md
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Zod to Json Schema
|
| 2 |
+
|
| 3 |
+
[](https://npmjs.org/package/zod-to-json-schema)
|
| 4 |
+
[](https://npmjs.org/package/zod-to-json-schema)
|
| 5 |
+
|
| 6 |
+
## Notice of deprecation
|
| 7 |
+
|
| 8 |
+
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.
|
| 9 |
+
|
| 10 |
+
Thank you to all the contributors and sponsors throughout the years! So long, and thanks for all the fish.
|
| 11 |
+
|
| 12 |
+
## Summary
|
| 13 |
+
|
| 14 |
+
Does what it says on the tin; converts [Zod schemas](https://github.com/colinhacks/zod) into [JSON schemas](https://json-schema.org/)!
|
| 15 |
+
|
| 16 |
+
- Supports all relevant schema types, basic string, number and array length validations and string patterns.
|
| 17 |
+
- Resolves recursive and recurring schemas with internal `$ref`s.
|
| 18 |
+
- Supports targeting legacy Open API 3.0 specification (3.1 supports regular Json Schema).
|
| 19 |
+
- Supports Open AI strict mode schemas (Optional object properties are replaced with required but nullable ones).
|
| 20 |
+
- As of v3.25 you can use Zod v4 as a peer-dependency, so long as you still provide v3-schemas.
|
| 21 |
+
|
| 22 |
+
_Looking for the exact opposite? Check out [json-schema-to-zod](https://npmjs.org/package/json-schema-to-zod)_
|
| 23 |
+
|
| 24 |
+
## Sponsors
|
| 25 |
+
|
| 26 |
+
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
|
| 27 |
+
|
| 28 |
+
<table align="center" style="justify-content: center;align-items: center;display: flex;">
|
| 29 |
+
<tr>
|
| 30 |
+
<td align="center">
|
| 31 |
+
<p></p>
|
| 32 |
+
<p>
|
| 33 |
+
<div style="background-color: white; padding: 4px; padding-bottom: 8px;" alt="stainless">
|
| 34 |
+
<a href="https://www.coderabbit.ai/">
|
| 35 |
+
<picture height="45px">
|
| 36 |
+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/eea24edb-ff20-4532-b57c-e8719f455d6d">
|
| 37 |
+
<img alt="CodeRabbit logo" height="45px" src="https://github.com/user-attachments/assets/d791bc7d-dc60-4d55-9c31-97779839cb74">
|
| 38 |
+
</picture>
|
| 39 |
+
</a>
|
| 40 |
+
</div>
|
| 41 |
+
<br />
|
| 42 |
+
Cut code review time & bugs in half
|
| 43 |
+
<br/>
|
| 44 |
+
<a href="https://www.coderabbit.ai/" style="text-decoration:none;">coderabbit.ai</a>
|
| 45 |
+
</p>
|
| 46 |
+
<p></p>
|
| 47 |
+
</td>
|
| 48 |
+
</tr>
|
| 49 |
+
</table>
|
| 50 |
+
|
| 51 |
+
## Usage
|
| 52 |
+
|
| 53 |
+
### Basic example
|
| 54 |
+
|
| 55 |
+
```typescript
|
| 56 |
+
import { z } from "zod"; // Or, using v3.25 or v4, "zod/v3"
|
| 57 |
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
| 58 |
+
|
| 59 |
+
const mySchema = z
|
| 60 |
+
.object({
|
| 61 |
+
myString: z.string().min(5),
|
| 62 |
+
myUnion: z.union([z.number(), z.boolean()]),
|
| 63 |
+
})
|
| 64 |
+
.describe("My neat object schema");
|
| 65 |
+
|
| 66 |
+
const jsonSchema = zodToJsonSchema(mySchema, "mySchema");
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
#### Expected output
|
| 70 |
+
|
| 71 |
+
```json
|
| 72 |
+
{
|
| 73 |
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
| 74 |
+
"$ref": "#/definitions/mySchema",
|
| 75 |
+
"definitions": {
|
| 76 |
+
"mySchema": {
|
| 77 |
+
"description": "My neat object schema",
|
| 78 |
+
"type": "object",
|
| 79 |
+
"properties": {
|
| 80 |
+
"myString": {
|
| 81 |
+
"type": "string",
|
| 82 |
+
"minLength": 5
|
| 83 |
+
},
|
| 84 |
+
"myUnion": {
|
| 85 |
+
"type": ["number", "boolean"]
|
| 86 |
+
}
|
| 87 |
+
},
|
| 88 |
+
"additionalProperties": false,
|
| 89 |
+
"required": ["myString", "myUnion"]
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
## Options
|
| 96 |
+
|
| 97 |
+
### Schema name
|
| 98 |
+
|
| 99 |
+
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).
|
| 100 |
+
|
| 101 |
+
### Options object
|
| 102 |
+
|
| 103 |
+
Instead of the schema name (or nothing), you can pass an options object as the second parameter. The following options are available:
|
| 104 |
+
|
| 105 |
+
| Option | Effect |
|
| 106 |
+
| ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 107 |
+
| **name**?: _string_ | As described above. |
|
| 108 |
+
| **nameStrategy**?: "ref" \| "title" | Adds name as "title" meta instead of as a ref as described above |
|
| 109 |
+
| **basePath**?: string[] | The base path of the root reference builder. Defaults to ["#"]. |
|
| 110 |
+
| **$refStrategy**?: "root" \| "relative" \| "seen" \| "none" | The reference builder strategy; <ul><li>**"root"** resolves $refs from the root up, ie: "#/definitions/mySchema".</li><li>**"relative"** uses [relative JSON pointers](https://tools.ietf.org/id/draft-handrews-relative-json-pointer-00.html). _See known issues!_</li><li>**"seen"** reuses the output of any "seen" Zod schema. In theory it's a more performant version of "none", but in practice this behaviour can cause issues with nested schemas and has now gotten its own option.</li> <li>**"none"** ignores referencing all together, creating a new schema branch even on "seen" schemas. Recursive references defaults to "any", ie `{}`.</li></ul> Defaults to "root". |
|
| 111 |
+
| **effectStrategy**?: "input" \| "any" | The effects output strategy. Defaults to "input". _See known issues!_ |
|
| 112 |
+
| **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) |
|
| 113 |
+
| |
|
| 114 |
+
| **emailStrategy**?: "format:email" \| "format:idn-email" \| "pattern:zod" | Choose how to handle the email string check. Defaults to "format:email". |
|
| 115 |
+
| **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. |
|
| 116 |
+
| **definitionPath**?: "definitions" \| "$defs" | The name of the definitions property when name is passed. Defaults to "definitions". |
|
| 117 |
+
| **target**?: "jsonSchema7" \| "jsonSchema2019-09" \| "openApi3" \| "openAi" | Which spec to target. Defaults to "jsonSchema7" |
|
| 118 |
+
| **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() |
|
| 119 |
+
| **definitions**?: Record<string, ZodSchema> | See separate section below |
|
| 120 |
+
| **errorMessages**?: boolean | Include custom error messages created via chained function checks for supported zod types. See section below |
|
| 121 |
+
| **markdownDescription**?: boolean | Copies the `description` meta to `markdownDescription` |
|
| 122 |
+
| **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. |
|
| 123 |
+
| **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`. |
|
| 124 |
+
| **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". |
|
| 125 |
+
| **removeAdditionalStrategy**?: "passthrough" \| "strict" | Decide when `additionalProperties` should be allowed. See the section on additional properties for details. |
|
| 126 |
+
| **allowedAdditionalProperties**?: `true` \| `undefined` | What value to give `additionalProperties` when allowed. See the section on additional properties for details. |
|
| 127 |
+
| **rejectedAdditionalProperties**?: `false` \| `undefined` | What value to give `additionalProperties` when rejected. See the section on additional properties for details. |
|
| 128 |
+
| **override**?: callback | See section |
|
| 129 |
+
| **postProcess**?: callback | See section |
|
| 130 |
+
| **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" |
|
| 131 |
+
|
| 132 |
+
### Definitions
|
| 133 |
+
|
| 134 |
+
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:
|
| 135 |
+
|
| 136 |
+
```typescript
|
| 137 |
+
const myRecurringSchema = z.string();
|
| 138 |
+
const myObjectSchema = z.object({ a: myRecurringSchema, b: myRecurringSchema });
|
| 139 |
+
|
| 140 |
+
const myJsonSchema = zodToJsonSchema(myObjectSchema, {
|
| 141 |
+
definitions: { myRecurringSchema },
|
| 142 |
+
});
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
#### Result
|
| 146 |
+
|
| 147 |
+
```json
|
| 148 |
+
{
|
| 149 |
+
"type": "object",
|
| 150 |
+
"properties": {
|
| 151 |
+
"a": {
|
| 152 |
+
"$ref": "#/definitions/myRecurringSchema"
|
| 153 |
+
},
|
| 154 |
+
"b": {
|
| 155 |
+
"$ref": "#/definitions/myRecurringSchema"
|
| 156 |
+
}
|
| 157 |
+
},
|
| 158 |
+
"definitions": {
|
| 159 |
+
"myRecurringSchema": {
|
| 160 |
+
"type": "string"
|
| 161 |
+
}
|
| 162 |
+
}
|
| 163 |
+
}
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
+
### Error Messages
|
| 167 |
+
|
| 168 |
+
This feature allows optionally including error messages created via chained function calls for supported zod types:
|
| 169 |
+
|
| 170 |
+
```ts
|
| 171 |
+
// string schema with additional chained function call checks
|
| 172 |
+
const EmailSchema = z.string().email("Invalid email").min(5, "Too short");
|
| 173 |
+
|
| 174 |
+
const jsonSchema = zodToJsonSchema(EmailSchema, { errorMessages: true });
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
#### Result
|
| 178 |
+
|
| 179 |
+
```json
|
| 180 |
+
{
|
| 181 |
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
| 182 |
+
"type": "string",
|
| 183 |
+
"format": "email",
|
| 184 |
+
"minLength": 5,
|
| 185 |
+
"errorMessage": {
|
| 186 |
+
"format": "Invalid email",
|
| 187 |
+
"minLength": "Too short"
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
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.
|
| 193 |
+
|
| 194 |
+
#### Custom Error Message Support
|
| 195 |
+
|
| 196 |
+
- ZodString
|
| 197 |
+
- regex
|
| 198 |
+
- min, max
|
| 199 |
+
- email, cuid, uuid, url
|
| 200 |
+
- endsWith, startsWith
|
| 201 |
+
- ZodNumber
|
| 202 |
+
- min, max, lt, lte, gt, gte,
|
| 203 |
+
- int
|
| 204 |
+
- multipleOf
|
| 205 |
+
- ZodSet
|
| 206 |
+
- min, max
|
| 207 |
+
- ZodArray
|
| 208 |
+
- min, max
|
| 209 |
+
|
| 210 |
+
### Additional properties
|
| 211 |
+
|
| 212 |
+
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:
|
| 213 |
+
|
| 214 |
+
- Set `removeAdditionalStrategy` to `"strict"`. This will allow additional properties for any object schema that is not declared with `.strict()`.
|
| 215 |
+
- Leave `removeAdditionalStrategy` set to its default value of `"passthrough"`, and add `.passtrough()` to your object schema.
|
| 216 |
+
|
| 217 |
+
#### Removing the `additionalProperties` keyword using the `allowedAdditionalProperties` and/or `rejectedAdditionalProperties` options.
|
| 218 |
+
|
| 219 |
+
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`.
|
| 220 |
+
|
| 221 |
+
To exclude the keyword even when additional properties are _not_ allowed, set the `rejectedAdditionalProperties` to `undefined` as well.
|
| 222 |
+
|
| 223 |
+
_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)._
|
| 224 |
+
|
| 225 |
+
#### Expected outputs
|
| 226 |
+
|
| 227 |
+
| `z.object({})` + option | `"additionalProperties"` value |
|
| 228 |
+
| ------------------------- | ----------------------------------------------------------- |
|
| 229 |
+
| `.strip()` (default) | `false` if strategy is `"passtrough"`, `true` if `"strict"` |
|
| 230 |
+
| `.passtrough()` | `true` |
|
| 231 |
+
| `.strict()` | `false` |
|
| 232 |
+
| `.catchall(z.string())` | `{ "type": "string" }` |
|
| 233 |
+
| `.catchall(z.function())` | `undefined` (function schemas are not currently parseable) |
|
| 234 |
+
|
| 235 |
+
Substitute `true` and `false` for `undefined` according to `allowedAdditionalProperties` and/or `rejectedAdditionalProperties` respectively.
|
| 236 |
+
|
| 237 |
+
### `override`
|
| 238 |
+
|
| 239 |
+
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.
|
| 240 |
+
|
| 241 |
+
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.
|
| 242 |
+
|
| 243 |
+
```typescript
|
| 244 |
+
import zodToJsonSchema, { ignoreOverride } from "zod-to-json-schema";
|
| 245 |
+
|
| 246 |
+
zodToJsonSchema(
|
| 247 |
+
z.object({
|
| 248 |
+
ignoreThis: z.string(),
|
| 249 |
+
overrideThis: z.string(),
|
| 250 |
+
removeThis: z.string(),
|
| 251 |
+
}),
|
| 252 |
+
{
|
| 253 |
+
override: (def, refs) => {
|
| 254 |
+
const path = refs.currentPath.join("/");
|
| 255 |
+
|
| 256 |
+
if (path === "#/properties/overrideThis") {
|
| 257 |
+
return {
|
| 258 |
+
type: "integer",
|
| 259 |
+
};
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
if (path === "#/properties/removeThis") {
|
| 263 |
+
return undefined;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
// Important! Do not return `undefined` or void unless you want to remove the property from the resulting schema completely.
|
| 267 |
+
return ignoreOverride;
|
| 268 |
+
},
|
| 269 |
+
},
|
| 270 |
+
);
|
| 271 |
+
```
|
| 272 |
+
|
| 273 |
+
Expected output:
|
| 274 |
+
|
| 275 |
+
```json
|
| 276 |
+
{
|
| 277 |
+
"type": "object",
|
| 278 |
+
"required": ["ignoreThis", "overrideThis"],
|
| 279 |
+
"properties": {
|
| 280 |
+
"ignoreThis": {
|
| 281 |
+
"type": "string"
|
| 282 |
+
},
|
| 283 |
+
"overrideThis": {
|
| 284 |
+
"type": "integer"
|
| 285 |
+
}
|
| 286 |
+
},
|
| 287 |
+
"additionalProperties": false
|
| 288 |
+
}
|
| 289 |
+
```
|
| 290 |
+
|
| 291 |
+
### `postProcess`
|
| 292 |
+
|
| 293 |
+
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.
|
| 294 |
+
|
| 295 |
+
```typescript
|
| 296 |
+
import zodToJsonSchema, { PostProcessCallback } from "zod-to-json-schema";
|
| 297 |
+
|
| 298 |
+
// Define the callback to be used to process the output using the PostProcessCallback type:
|
| 299 |
+
const postProcess: PostProcessCallback = (
|
| 300 |
+
// The original output produced by the package itself:
|
| 301 |
+
jsonSchema,
|
| 302 |
+
// The ZodSchema def used to produce the original schema:
|
| 303 |
+
def,
|
| 304 |
+
// The refs object containing the current path, passed options, etc.
|
| 305 |
+
refs,
|
| 306 |
+
) => {
|
| 307 |
+
if (!jsonSchema) {
|
| 308 |
+
return jsonSchema;
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
// Try to expand description as JSON meta:
|
| 312 |
+
if (jsonSchema.description) {
|
| 313 |
+
try {
|
| 314 |
+
jsonSchema = {
|
| 315 |
+
...jsonSchema,
|
| 316 |
+
...JSON.parse(jsonSchema.description),
|
| 317 |
+
};
|
| 318 |
+
} catch {}
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
// Make all numbers nullable:
|
| 322 |
+
if ("type" in jsonSchema! && jsonSchema.type === "number") {
|
| 323 |
+
jsonSchema.type = ["number", "null"];
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
// Add the refs path, just because
|
| 327 |
+
(jsonSchema as any).path = refs.currentPath;
|
| 328 |
+
|
| 329 |
+
return jsonSchema;
|
| 330 |
+
};
|
| 331 |
+
|
| 332 |
+
const jsonSchema = zodToJsonSchema(zodSchema, { postProcess });
|
| 333 |
+
```
|
| 334 |
+
|
| 335 |
+
#### Using `postProcess` for including examples and other meta
|
| 336 |
+
|
| 337 |
+
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.
|
| 338 |
+
|
| 339 |
+
Simply stringify whatever you want added to the output schema as the description, then import and use `jsonDescription` as the postProcess option:
|
| 340 |
+
|
| 341 |
+
```typescript
|
| 342 |
+
import zodToJsonSchema, { jsonDescription } from "zod-to-json-schema";
|
| 343 |
+
|
| 344 |
+
const zodSchema = z.string().describe(
|
| 345 |
+
JSON.stringify({
|
| 346 |
+
title: "My string",
|
| 347 |
+
description: "My description",
|
| 348 |
+
examples: ["Foo", "Bar"],
|
| 349 |
+
whatever: 123,
|
| 350 |
+
}),
|
| 351 |
+
);
|
| 352 |
+
|
| 353 |
+
const jsonSchema = zodToJsonSchema(zodSchema, {
|
| 354 |
+
postProcess: jsonDescription,
|
| 355 |
+
});
|
| 356 |
+
```
|
| 357 |
+
|
| 358 |
+
Expected output:
|
| 359 |
+
|
| 360 |
+
```json
|
| 361 |
+
{
|
| 362 |
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
| 363 |
+
"type": "string",
|
| 364 |
+
"title": "My string",
|
| 365 |
+
"description": "My description",
|
| 366 |
+
"examples": ["Foo", "Bar"],
|
| 367 |
+
"whatever": 123
|
| 368 |
+
}
|
| 369 |
+
```
|
| 370 |
+
|
| 371 |
+
## Known issues
|
| 372 |
+
|
| 373 |
+
- The OpenAI target should be considered experimental for now, as some combination of options may break the compatibility.
|
| 374 |
+
- 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.
|
| 375 |
+
- 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
|
| 376 |
+
- 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.
|
| 377 |
+
- 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).
|
| 378 |
+
- 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#"
|
| 379 |
+
|
| 380 |
+
## Versioning
|
| 381 |
+
|
| 382 |
+
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).
|
| 383 |
+
|
| 384 |
+
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.
|
| 385 |
+
|
| 386 |
+
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.
|
| 387 |
+
|
| 388 |
+
## Changelog
|
| 389 |
+
|
| 390 |
+
https://github.com/StefanTerdell/zod-to-json-schema/blob/master/changelog.md
|
node_modules/zod-to-json-schema/changelog.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Changelog
|
| 2 |
+
|
| 3 |
+
| Version | Change |
|
| 4 |
+
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 5 |
+
| 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. |
|
| 6 |
+
| 3.25.1 | Fixes large install size due to accidental inclusion of test files. Thanks, [Felix Mosheev](https://github.com/felixmosh)! |
|
| 7 |
+
| 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. |
|
| 8 |
+
| 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. |
|
| 9 |
+
| 3.24.5 | Update .npmignore to drop 2 mb of test files. Thanks [Misha Kaletsky](https://github.com/mmkal)! |
|
| 10 |
+
| 3.24.4 | Added options to set the value of additionalProperties in objects and record |
|
| 11 |
+
| 3.24.3 | Adds postProcess callback option |
|
| 12 |
+
| 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. |
|
| 13 |
+
| 3.24.1 | Adds OpenAI target |
|
| 14 |
+
| 3.24.0 | Implements new string checks (jwt, base64url, cidr ipv4/v6), matching the new Zod version |
|
| 15 |
+
| 3.23.5 | Module import hotfix by [Enzo Monjardín](https://github.com/enzomonjardin). Thanks! |
|
| 16 |
+
| 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)! |
|
| 17 |
+
| 3.23.3 | More tests (Thanks [Brett Zamir!](https://github.com/brettz9)), removed dead code |
|
| 18 |
+
| 3.23.2 | Lazily loads Emoji regex to avoid incompatibility with some environments. Thanks [Jacob Lee](https://github.com/jacoblee93)! |
|
| 19 |
+
| 3.23.1 | Best-effort RegEx flag support by [Spappz](https://github.com/Spappz)! Some minor fixes and additions, such as the title option. |
|
| 20 |
+
| 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 :) |
|
| 21 |
+
| 3.22.5 | Adds new z.date() parsing options and override callback |
|
| 22 |
+
| 3.22.4 | Adds fix for nullable references in OpenAPI mode |
|
| 23 |
+
| 3.22.3 | Adjust root path from "#/" to "#" according to RFC 6901 |
|
| 24 |
+
| 3.22.2 | Adds "output" pipe strategy |
|
| 25 |
+
| 3.22.1 | Fixes broken imports when using some bundlers |
|
| 26 |
+
| 3.22.0 | Support readonly. Export both CJS and ESM. Export everything from index. Alternative map parser. Improved pattern handling and updated sources. |
|
| 27 |
+
| 3.21.4 | Fixes missing support for exact array length |
|
| 28 |
+
| 3.21.3 | Fixes issue #77 (Reference path to nullable schemas in Open-API mode) |
|
| 29 |
+
| 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". |
|
| 30 |
+
| 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 |
|
| 31 |
+
| 3.21.0 | Added new string validations (ip, emoji, etc) and BigInt checks to support Zod 3.21 |
|
| 32 |
+
| 3.20.5 | Added uniqueItems to Set and an option to disregard pipe schemas |
|
| 33 |
+
| 3.20.4 | Bugfixes and improved record parsing for openApi3 |
|
| 34 |
+
| 3.20.3 | Added Cuid2 support introduced in Zod 3.20.3 |
|
| 35 |
+
| 3.20.2 | Reintroduced conditional simplified return-type for when target is OpenAPI 3 |
|
| 36 |
+
| 3.20.1 | Fixed inconsistent casing in imports |
|
| 37 |
+
| 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. <br/><quote><i>Narrator: Someone did in fact miss it</i></quote> |
|
| 38 |
+
| 3.19.4 | Adds custom error message support |
|
| 39 |
+
| 3.19.3 | Mark `definitions` as experimental in the readme |
|
| 40 |
+
| 3.19.2 | Added `definitions` option |
|
| 41 |
+
| 3.19.1 | Strict unions fix |
|
| 42 |
+
| 3.19.0 | No new features added in Zod, parity bump |
|
| 43 |
+
| 3.18.2 | Fixes support for native enums |
|
| 44 |
+
| 3.18.1 | Add strictUnions options |
|
| 45 |
+
| 3.18.0 | Added support for branded types |
|
| 46 |
+
| 3.17.2 | Fix for reference paths when supplying name option string. |
|
| 47 |
+
| 3.17.1 | Added startsWith and endsWith string checks. Merge multiple pattern checks into allOf array. |
|
| 48 |
+
| 3.17.0 | Added switch case handler for new trim "check". No changes to functionality. |
|
| 49 |
+
| 3.15.x - 3.16.x | Skipped: Did not change the Zod API in any way relevant for this package. |
|
| 50 |
+
| 3.14.1 | Dependabot security updates |
|
| 51 |
+
| 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) |
|
| 52 |
+
| 3.12.x - 3.13.x | Skipped |
|
| 53 |
+
| 3.11.3 | Joins unions of enums into single enum and allows enums as keys of records |
|
| 54 |
+
| 3.11.2 | Adds option to target Open API 3 spec (paths) instead of Json Schema 7. |
|
| 55 |
+
| 3.11.1 | Performance boost when using $refStrategy `none` and internal improvements. |
|
| 56 |
+
| 3.11.0 | Added description support introduced in Zod 3.11.5 |
|
| 57 |
+
| 3.10.x | Skipped: Minor 10 did not change the Zod API |
|
| 58 |
+
| 3.9.5 | Type bug fix: used dev dependency types in package |
|
| 59 |
+
| 3.9.4 | Path bug fix and test case when using optional definitions path |
|
| 60 |
+
| 3.9.3 | Added option to change definition property name to $defs |
|
| 61 |
+
| 3.9.2 | Added option to handle transform results as any instead of relying on their input schema. |
|
| 62 |
+
| 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. |
|
| 63 |
+
| 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). |
|
| 64 |
+
| 3.7.x - 3.8.x | Skipped to reach functional parity with Zod versioning. |
|
| 65 |
+
| 3.6.1 | Realised intersection had another potential ref pathing bug. Fixed. |
|
| 66 |
+
| 3.6.0 | Added support for default & effects (refine). Broke out changelog.md |
|
| 67 |
+
| 3.5.0 | Added support for CUID string validation |
|
| 68 |
+
| 3.4.3 | Fixed $ref pathing for catchall and intersection. Additional tests and code structure fixes. |
|
| 69 |
+
| 3.4.2 | Fixed broken intersection parser (Thanks [Noah2610](https://github.com/Noah2610)!) |
|
| 70 |
+
| 3.4.1 | Fixed pathing bug for nullable items. |
|
| 71 |
+
| 3.4.0 | Added support for z.lazy() |
|
| 72 |
+
| 3.3.0 | Added support for catchall (additionalProperties schema on objects). Rebuilt object parser. |
|
| 73 |
+
| 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. |
|
| 74 |
+
| 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. |
|
| 75 |
+
| 3.0.3 | Fixed array deep pathing bug (path contained `array` instead of `items`) |
|
| 76 |
+
| 3.0.2 | Fixed broken type usage (NonEmptyArrayDefinition was removed from Zod) |
|
| 77 |
+
| 3.0.1 | Fixed a typo in the readme |
|
| 78 |
+
| 3.0.0 | Compatible with Zod 3.2.0. Huge props to [Mr Hammad Asif](https://github.com/mrhammadasif) for his work on this. |
|
| 79 |
+
| 0.6.2 | Hotfix for undefined object properties. Could crash the parser when using Pick |
|
| 80 |
+
| 0.6.1 | Fixed bug in union pathing. `$Ref` was missing `/anyOf` |
|
| 81 |
+
| 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. |
|
| 82 |
+
| 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). |
|
| 83 |
+
| < 0.5.1 | Deprecated due to broken package structure. Please be patient, I eat crayons. |
|
node_modules/zod-to-json-schema/contributing.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contributing
|
| 2 |
+
|
| 3 |
+
Hey, thanks for wanting to contribute.
|
| 4 |
+
|
| 5 |
+
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.
|
| 6 |
+
|
| 7 |
+
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.
|
| 8 |
+
|
| 9 |
+
I check PRs and issues very rarely so please be patient.
|
node_modules/zod-to-json-schema/createIndex.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { readdirSync, writeFileSync, statSync } from "fs";
|
| 2 |
+
|
| 3 |
+
const ignore = ["src/index.ts"];
|
| 4 |
+
|
| 5 |
+
function checkSrcDir(path: string): string[] {
|
| 6 |
+
const lines: string[] = [];
|
| 7 |
+
|
| 8 |
+
for (const item of readdirSync(path)) {
|
| 9 |
+
const itemPath = path + "/" + item;
|
| 10 |
+
|
| 11 |
+
if (ignore.includes(itemPath)) {
|
| 12 |
+
continue;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
if (statSync(itemPath).isDirectory()) {
|
| 16 |
+
lines.push(...checkSrcDir(itemPath));
|
| 17 |
+
} else if (item.endsWith(".ts")) {
|
| 18 |
+
lines.push('export * from "./' + itemPath.slice(4, -2) + 'js"');
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
return lines;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
const lines = checkSrcDir("src");
|
| 26 |
+
|
| 27 |
+
lines.push(
|
| 28 |
+
'import { zodToJsonSchema } from "./zodToJsonSchema.js"',
|
| 29 |
+
"export default zodToJsonSchema;",
|
| 30 |
+
);
|
| 31 |
+
|
| 32 |
+
writeFileSync("./src/index.ts", lines.join(";\n"));
|
node_modules/zod-to-json-schema/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "zod-to-json-schema",
|
| 3 |
+
"version": "3.25.2",
|
| 4 |
+
"description": "Converts Zod schemas to Json Schemas",
|
| 5 |
+
"types": "./dist/types/index.d.ts",
|
| 6 |
+
"main": "./dist/cjs/index.js",
|
| 7 |
+
"module": "./dist/esm/index.js",
|
| 8 |
+
"exports": {
|
| 9 |
+
"import": {
|
| 10 |
+
"types": "./dist/types/index.d.ts",
|
| 11 |
+
"default": "./dist/esm/index.js"
|
| 12 |
+
},
|
| 13 |
+
"require": {
|
| 14 |
+
"types": "./dist/types/index.d.ts",
|
| 15 |
+
"default": "./dist/cjs/index.js"
|
| 16 |
+
}
|
| 17 |
+
},
|
| 18 |
+
"scripts": {
|
| 19 |
+
"build:test": "npm --prefix ./dist-test-v3 test && npm --prefix ./dist-test-v4 test",
|
| 20 |
+
"build:types": "tsc -p tsconfig.types.json",
|
| 21 |
+
"build:cjs": "tsc -p tsconfig.cjs.json && tsx postcjs.ts",
|
| 22 |
+
"build:esm": "tsc -p tsconfig.esm.json && tsx postesm.ts",
|
| 23 |
+
"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",
|
| 24 |
+
"dry": "npm run build && npm pub --dry-run",
|
| 25 |
+
"test:watch": "tsx watch test/index.ts",
|
| 26 |
+
"test:gen": "tsx test/createIndex.ts",
|
| 27 |
+
"test": "tsx test/index.ts",
|
| 28 |
+
"gen": "tsx createIndex.ts"
|
| 29 |
+
},
|
| 30 |
+
"keywords": [
|
| 31 |
+
"zod",
|
| 32 |
+
"json",
|
| 33 |
+
"schema",
|
| 34 |
+
"open",
|
| 35 |
+
"api",
|
| 36 |
+
"conversion"
|
| 37 |
+
],
|
| 38 |
+
"author": "Stefan Terdell",
|
| 39 |
+
"contributors": [
|
| 40 |
+
"Hammad Asif (https://github.com/mrhammadasif)",
|
| 41 |
+
"Noah Rosenzweig (https://github.com/Noah2610)",
|
| 42 |
+
"John Wright (https://github.com/johngeorgewright)",
|
| 43 |
+
"Krzysztof Ciombor (https://github.com/krzysztofciombor)",
|
| 44 |
+
"Yuta Mombetsu (https://github.com/mokocm)",
|
| 45 |
+
"Tom Arad (https://github.com/tomarad)",
|
| 46 |
+
"Isaac Way (https://github.com/iway1)",
|
| 47 |
+
"Andreas Berger (https://github.com/Andy2003)",
|
| 48 |
+
"Jan Potoms (https://github.com/Janpot)",
|
| 49 |
+
"Santiago Cammi (https://github.com/scammi)",
|
| 50 |
+
"Philipp Burckhardt (https://github.com/Planeshifter)",
|
| 51 |
+
"Bram del Canho (https://github.com/Bram-dc)",
|
| 52 |
+
"Gilad Hecht (https://github.com/gthecht)",
|
| 53 |
+
"Colin McDonnell (https://github.com/colinhacks)",
|
| 54 |
+
"Spappz (https://github.com/Spappz)",
|
| 55 |
+
"Jacob Lee (https://github.com/jacoblee93)",
|
| 56 |
+
"Brett Zamir (https://github.com/brettz9)",
|
| 57 |
+
"Isaiah Marc Sanchez (https://github.com/imsanchez)",
|
| 58 |
+
"Mitchell Merry (https://github.com/mitchell-merry)",
|
| 59 |
+
"Enzo Monjardín (https://github.com/enzomonjardin)",
|
| 60 |
+
"Víctor Hernández (https://github.com/NanezX)",
|
| 61 |
+
"Faïz Hernawan Abdillah (https://github.com/Abdillah)",
|
| 62 |
+
"Felix Mosheev (https://github.com/felixmosh)"
|
| 63 |
+
],
|
| 64 |
+
"repository": {
|
| 65 |
+
"type": "git",
|
| 66 |
+
"url": "https://github.com/StefanTerdell/zod-to-json-schema"
|
| 67 |
+
},
|
| 68 |
+
"license": "ISC",
|
| 69 |
+
"peerDependencies": {
|
| 70 |
+
"zod": "^3.25.28 || ^4"
|
| 71 |
+
},
|
| 72 |
+
"devDependencies": {
|
| 73 |
+
"@types/json-schema": "^7.0.9",
|
| 74 |
+
"@types/node": "^20.9.0",
|
| 75 |
+
"ajv": "^8.6.3",
|
| 76 |
+
"ajv-errors": "^3.0.0",
|
| 77 |
+
"ajv-formats": "^2.1.1",
|
| 78 |
+
"fast-diff": "^1.3.0",
|
| 79 |
+
"local-ref-resolver": "^0.2.0",
|
| 80 |
+
"rimraf": "^6.1.3",
|
| 81 |
+
"tsx": "^4.19.0",
|
| 82 |
+
"typescript": "^5.1.3",
|
| 83 |
+
"zod": "^3.25.28 || ^4"
|
| 84 |
+
}
|
| 85 |
+
}
|
node_modules/zod-to-json-schema/postcjs.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { writeFileSync } from "fs";
|
| 2 |
+
|
| 3 |
+
writeFileSync("./dist/cjs/package.json", '{"type":"commonjs"}', "utf-8");
|
node_modules/zod-to-json-schema/postesm.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { writeFileSync } from "fs";
|
| 2 |
+
|
| 3 |
+
writeFileSync("./dist/esm/package.json", '{"type":"module","main":"index.js"}', "utf-8");
|
node_modules/zod/v4-mini/index.cjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 3 |
+
if (k2 === undefined) k2 = k;
|
| 4 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 5 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 6 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 7 |
+
}
|
| 8 |
+
Object.defineProperty(o, k2, desc);
|
| 9 |
+
}) : (function(o, m, k, k2) {
|
| 10 |
+
if (k2 === undefined) k2 = k;
|
| 11 |
+
o[k2] = m[k];
|
| 12 |
+
}));
|
| 13 |
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
| 14 |
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
| 15 |
+
}) : function(o, v) {
|
| 16 |
+
o["default"] = v;
|
| 17 |
+
});
|
| 18 |
+
var __importStar = (this && this.__importStar) || function (mod) {
|
| 19 |
+
if (mod && mod.__esModule) return mod;
|
| 20 |
+
var result = {};
|
| 21 |
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
| 22 |
+
__setModuleDefault(result, mod);
|
| 23 |
+
return result;
|
| 24 |
+
};
|
| 25 |
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
| 26 |
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
| 27 |
+
};
|
| 28 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 29 |
+
exports.z = void 0;
|
| 30 |
+
const z = __importStar(require("../v4/mini/external.cjs"));
|
| 31 |
+
exports.z = z;
|
| 32 |
+
__exportStar(require("../v4/mini/external.cjs"), exports);
|
node_modules/zod/v4-mini/index.d.cts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as z from "../v4/mini/external.cjs";
|
| 2 |
+
export * from "../v4/mini/external.cjs";
|
| 3 |
+
export { z };
|
node_modules/zod/v4-mini/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as z from "../v4/mini/external.js";
|
| 2 |
+
export * from "../v4/mini/external.js";
|
| 3 |
+
export { z };
|
node_modules/zod/v4-mini/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as z from "../v4/mini/external.js";
|
| 2 |
+
export * from "../v4/mini/external.js";
|
| 3 |
+
export { z };
|
node_modules/zod/v4-mini/package.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"type": "module",
|
| 3 |
+
"main": "./index.cjs",
|
| 4 |
+
"module": "./index.js",
|
| 5 |
+
"types": "./index.d.cts",
|
| 6 |
+
"sideEffects": false
|
| 7 |
+
}
|
node_modules/zod/v4/core/parse.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as core from "./core.js";
|
| 2 |
+
import * as errors from "./errors.js";
|
| 3 |
+
import type * as schemas from "./schemas.js";
|
| 4 |
+
import * as util from "./util.js";
|
| 5 |
+
export type $ZodErrorClass = {
|
| 6 |
+
new (issues: errors.$ZodIssue[]): errors.$ZodError;
|
| 7 |
+
};
|
| 8 |
+
export type $Parse = <T extends schemas.$ZodType>(schema: T, value: unknown, _ctx?: schemas.ParseContext<errors.$ZodIssue>, _params?: {
|
| 9 |
+
callee?: util.AnyFunc;
|
| 10 |
+
Err?: $ZodErrorClass;
|
| 11 |
+
}) => core.output<T>;
|
| 12 |
+
export declare const _parse: (_Err: $ZodErrorClass) => $Parse;
|
| 13 |
+
export declare const parse: $Parse;
|
| 14 |
+
export type $ParseAsync = <T extends schemas.$ZodType>(schema: T, value: unknown, _ctx?: schemas.ParseContext<errors.$ZodIssue>, _params?: {
|
| 15 |
+
callee?: util.AnyFunc;
|
| 16 |
+
Err?: $ZodErrorClass;
|
| 17 |
+
}) => Promise<core.output<T>>;
|
| 18 |
+
export declare const _parseAsync: (_Err: $ZodErrorClass) => $ParseAsync;
|
| 19 |
+
export declare const parseAsync: $ParseAsync;
|
| 20 |
+
export type $SafeParse = <T extends schemas.$ZodType>(schema: T, value: unknown, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => util.SafeParseResult<core.output<T>>;
|
| 21 |
+
export declare const _safeParse: (_Err: $ZodErrorClass) => $SafeParse;
|
| 22 |
+
export declare const safeParse: $SafeParse;
|
| 23 |
+
export type $SafeParseAsync = <T extends schemas.$ZodType>(schema: T, value: unknown, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => Promise<util.SafeParseResult<core.output<T>>>;
|
| 24 |
+
export declare const _safeParseAsync: (_Err: $ZodErrorClass) => $SafeParseAsync;
|
| 25 |
+
export declare const safeParseAsync: $SafeParseAsync;
|
| 26 |
+
export type $Encode = <T extends schemas.$ZodType>(schema: T, value: core.output<T>, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => core.input<T>;
|
| 27 |
+
export declare const _encode: (_Err: $ZodErrorClass) => $Encode;
|
| 28 |
+
export declare const encode: $Encode;
|
| 29 |
+
export type $Decode = <T extends schemas.$ZodType>(schema: T, value: core.input<T>, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => core.output<T>;
|
| 30 |
+
export declare const _decode: (_Err: $ZodErrorClass) => $Decode;
|
| 31 |
+
export declare const decode: $Decode;
|
| 32 |
+
export type $EncodeAsync = <T extends schemas.$ZodType>(schema: T, value: core.output<T>, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => Promise<core.input<T>>;
|
| 33 |
+
export declare const _encodeAsync: (_Err: $ZodErrorClass) => $EncodeAsync;
|
| 34 |
+
export declare const encodeAsync: $EncodeAsync;
|
| 35 |
+
export type $DecodeAsync = <T extends schemas.$ZodType>(schema: T, value: core.input<T>, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => Promise<core.output<T>>;
|
| 36 |
+
export declare const _decodeAsync: (_Err: $ZodErrorClass) => $DecodeAsync;
|
| 37 |
+
export declare const decodeAsync: $DecodeAsync;
|
| 38 |
+
export type $SafeEncode = <T extends schemas.$ZodType>(schema: T, value: core.output<T>, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => util.SafeParseResult<core.input<T>>;
|
| 39 |
+
export declare const _safeEncode: (_Err: $ZodErrorClass) => $SafeEncode;
|
| 40 |
+
export declare const safeEncode: $SafeEncode;
|
| 41 |
+
export type $SafeDecode = <T extends schemas.$ZodType>(schema: T, value: core.input<T>, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => util.SafeParseResult<core.output<T>>;
|
| 42 |
+
export declare const _safeDecode: (_Err: $ZodErrorClass) => $SafeDecode;
|
| 43 |
+
export declare const safeDecode: $SafeDecode;
|
| 44 |
+
export type $SafeEncodeAsync = <T extends schemas.$ZodType>(schema: T, value: core.output<T>, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => Promise<util.SafeParseResult<core.input<T>>>;
|
| 45 |
+
export declare const _safeEncodeAsync: (_Err: $ZodErrorClass) => $SafeEncodeAsync;
|
| 46 |
+
export declare const safeEncodeAsync: $SafeEncodeAsync;
|
| 47 |
+
export type $SafeDecodeAsync = <T extends schemas.$ZodType>(schema: T, value: core.input<T>, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => Promise<util.SafeParseResult<core.output<T>>>;
|
| 48 |
+
export declare const _safeDecodeAsync: (_Err: $ZodErrorClass) => $SafeDecodeAsync;
|
| 49 |
+
export declare const safeDecodeAsync: $SafeDecodeAsync;
|
node_modules/zod/v4/core/parse.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as core from "./core.js";
|
| 2 |
+
import * as errors from "./errors.js";
|
| 3 |
+
import * as util from "./util.js";
|
| 4 |
+
export const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
| 5 |
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
| 6 |
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
| 7 |
+
if (result instanceof Promise) {
|
| 8 |
+
throw new core.$ZodAsyncError();
|
| 9 |
+
}
|
| 10 |
+
if (result.issues.length) {
|
| 11 |
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
|
| 12 |
+
util.captureStackTrace(e, _params?.callee);
|
| 13 |
+
throw e;
|
| 14 |
+
}
|
| 15 |
+
return result.value;
|
| 16 |
+
};
|
| 17 |
+
export const parse = /* @__PURE__*/ _parse(errors.$ZodRealError);
|
| 18 |
+
export const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
| 19 |
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
| 20 |
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
| 21 |
+
if (result instanceof Promise)
|
| 22 |
+
result = await result;
|
| 23 |
+
if (result.issues.length) {
|
| 24 |
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
|
| 25 |
+
util.captureStackTrace(e, params?.callee);
|
| 26 |
+
throw e;
|
| 27 |
+
}
|
| 28 |
+
return result.value;
|
| 29 |
+
};
|
| 30 |
+
export const parseAsync = /* @__PURE__*/ _parseAsync(errors.$ZodRealError);
|
| 31 |
+
export const _safeParse = (_Err) => (schema, value, _ctx) => {
|
| 32 |
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
| 33 |
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
| 34 |
+
if (result instanceof Promise) {
|
| 35 |
+
throw new core.$ZodAsyncError();
|
| 36 |
+
}
|
| 37 |
+
return result.issues.length
|
| 38 |
+
? {
|
| 39 |
+
success: false,
|
| 40 |
+
error: new (_Err ?? errors.$ZodError)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
|
| 41 |
+
}
|
| 42 |
+
: { success: true, data: result.value };
|
| 43 |
+
};
|
| 44 |
+
export const safeParse = /* @__PURE__*/ _safeParse(errors.$ZodRealError);
|
| 45 |
+
export const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
| 46 |
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
| 47 |
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
| 48 |
+
if (result instanceof Promise)
|
| 49 |
+
result = await result;
|
| 50 |
+
return result.issues.length
|
| 51 |
+
? {
|
| 52 |
+
success: false,
|
| 53 |
+
error: new _Err(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
|
| 54 |
+
}
|
| 55 |
+
: { success: true, data: result.value };
|
| 56 |
+
};
|
| 57 |
+
export const safeParseAsync = /* @__PURE__*/ _safeParseAsync(errors.$ZodRealError);
|
| 58 |
+
export const _encode = (_Err) => (schema, value, _ctx) => {
|
| 59 |
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
| 60 |
+
return _parse(_Err)(schema, value, ctx);
|
| 61 |
+
};
|
| 62 |
+
export const encode = /* @__PURE__*/ _encode(errors.$ZodRealError);
|
| 63 |
+
export const _decode = (_Err) => (schema, value, _ctx) => {
|
| 64 |
+
return _parse(_Err)(schema, value, _ctx);
|
| 65 |
+
};
|
| 66 |
+
export const decode = /* @__PURE__*/ _decode(errors.$ZodRealError);
|
| 67 |
+
export const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
| 68 |
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
| 69 |
+
return _parseAsync(_Err)(schema, value, ctx);
|
| 70 |
+
};
|
| 71 |
+
export const encodeAsync = /* @__PURE__*/ _encodeAsync(errors.$ZodRealError);
|
| 72 |
+
export const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
| 73 |
+
return _parseAsync(_Err)(schema, value, _ctx);
|
| 74 |
+
};
|
| 75 |
+
export const decodeAsync = /* @__PURE__*/ _decodeAsync(errors.$ZodRealError);
|
| 76 |
+
export const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
| 77 |
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
| 78 |
+
return _safeParse(_Err)(schema, value, ctx);
|
| 79 |
+
};
|
| 80 |
+
export const safeEncode = /* @__PURE__*/ _safeEncode(errors.$ZodRealError);
|
| 81 |
+
export const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
| 82 |
+
return _safeParse(_Err)(schema, value, _ctx);
|
| 83 |
+
};
|
| 84 |
+
export const safeDecode = /* @__PURE__*/ _safeDecode(errors.$ZodRealError);
|
| 85 |
+
export const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
| 86 |
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
| 87 |
+
return _safeParseAsync(_Err)(schema, value, ctx);
|
| 88 |
+
};
|
| 89 |
+
export const safeEncodeAsync = /* @__PURE__*/ _safeEncodeAsync(errors.$ZodRealError);
|
| 90 |
+
export const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
| 91 |
+
return _safeParseAsync(_Err)(schema, value, _ctx);
|
| 92 |
+
};
|
| 93 |
+
export const safe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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 3 |
+
if (k2 === undefined) k2 = k;
|
| 4 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 5 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 6 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 7 |
+
}
|
| 8 |
+
Object.defineProperty(o, k2, desc);
|
| 9 |
+
}) : (function(o, m, k, k2) {
|
| 10 |
+
if (k2 === undefined) k2 = k;
|
| 11 |
+
o[k2] = m[k];
|
| 12 |
+
}));
|
| 13 |
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
| 14 |
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
| 15 |
+
}) : function(o, v) {
|
| 16 |
+
o["default"] = v;
|
| 17 |
+
});
|
| 18 |
+
var __importStar = (this && this.__importStar) || function (mod) {
|
| 19 |
+
if (mod && mod.__esModule) return mod;
|
| 20 |
+
var result = {};
|
| 21 |
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
| 22 |
+
__setModuleDefault(result, mod);
|
| 23 |
+
return result;
|
| 24 |
+
};
|
| 25 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 26 |
+
exports.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;
|
| 27 |
+
exports.sha512_base64url = exports.sha512_base64 = exports.sha512_hex = exports.sha384_base64url = exports.sha384_base64 = exports.sha384_hex = void 0;
|
| 28 |
+
exports.emoji = emoji;
|
| 29 |
+
exports.time = time;
|
| 30 |
+
exports.datetime = datetime;
|
| 31 |
+
const util = __importStar(require("./util.cjs"));
|
| 32 |
+
/**
|
| 33 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 34 |
+
* (timestamps embedded in the id). Use {@link cuid2} instead.
|
| 35 |
+
* See https://github.com/paralleldrive/cuid.
|
| 36 |
+
*/
|
| 37 |
+
exports.cuid = /^[cC][0-9a-z]{6,}$/;
|
| 38 |
+
exports.cuid2 = /^[0-9a-z]+$/;
|
| 39 |
+
exports.ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
| 40 |
+
exports.xid = /^[0-9a-vA-V]{20}$/;
|
| 41 |
+
exports.ksuid = /^[A-Za-z0-9]{27}$/;
|
| 42 |
+
exports.nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
| 43 |
+
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
| 44 |
+
exports.duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
| 45 |
+
/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
|
| 46 |
+
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)?)??$/;
|
| 47 |
+
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
| 48 |
+
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})$/;
|
| 49 |
+
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
| 50 |
+
*
|
| 51 |
+
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
| 52 |
+
const uuid = (version) => {
|
| 53 |
+
if (!version)
|
| 54 |
+
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)$/;
|
| 55 |
+
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})$`);
|
| 56 |
+
};
|
| 57 |
+
exports.uuid = uuid;
|
| 58 |
+
exports.uuid4 = (0, exports.uuid)(4);
|
| 59 |
+
exports.uuid6 = (0, exports.uuid)(6);
|
| 60 |
+
exports.uuid7 = (0, exports.uuid)(7);
|
| 61 |
+
/** Practical email validation */
|
| 62 |
+
exports.email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
| 63 |
+
/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
|
| 64 |
+
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])?)*$/;
|
| 65 |
+
/** The classic emailregex.com regex for RFC 5322-compliant emails */
|
| 66 |
+
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,}))$/;
|
| 67 |
+
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
| 68 |
+
exports.unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
| 69 |
+
exports.idnEmail = exports.unicodeEmail;
|
| 70 |
+
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])?)*$/;
|
| 71 |
+
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
| 72 |
+
const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
| 73 |
+
function emoji() {
|
| 74 |
+
return new RegExp(_emoji, "u");
|
| 75 |
+
}
|
| 76 |
+
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])$/;
|
| 77 |
+
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}|:))$/;
|
| 78 |
+
const mac = (delimiter) => {
|
| 79 |
+
const escapedDelim = util.escapeRegex(delimiter ?? ":");
|
| 80 |
+
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
|
| 81 |
+
};
|
| 82 |
+
exports.mac = mac;
|
| 83 |
+
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])$/;
|
| 84 |
+
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])$/;
|
| 85 |
+
// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
|
| 86 |
+
exports.base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
| 87 |
+
exports.base64url = /^[A-Za-z0-9_-]*$/;
|
| 88 |
+
// based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
|
| 89 |
+
// export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
| 90 |
+
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])?)*\.?$/;
|
| 91 |
+
exports.domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
| 92 |
+
exports.httpProtocol = /^https?$/;
|
| 93 |
+
// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
|
| 94 |
+
// E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
|
| 95 |
+
exports.e164 = /^\+[1-9]\d{6,14}$/;
|
| 96 |
+
// 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])))`;
|
| 97 |
+
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])))`;
|
| 98 |
+
exports.date = new RegExp(`^${dateSource}$`);
|
| 99 |
+
function timeSource(args) {
|
| 100 |
+
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
| 101 |
+
const regex = typeof args.precision === "number"
|
| 102 |
+
? args.precision === -1
|
| 103 |
+
? `${hhmm}`
|
| 104 |
+
: args.precision === 0
|
| 105 |
+
? `${hhmm}:[0-5]\\d`
|
| 106 |
+
: `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}`
|
| 107 |
+
: `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
| 108 |
+
return regex;
|
| 109 |
+
}
|
| 110 |
+
function time(args) {
|
| 111 |
+
return new RegExp(`^${timeSource(args)}$`);
|
| 112 |
+
}
|
| 113 |
+
// Adapted from https://stackoverflow.com/a/3143231
|
| 114 |
+
function datetime(args) {
|
| 115 |
+
const time = timeSource({ precision: args.precision });
|
| 116 |
+
const opts = ["Z"];
|
| 117 |
+
if (args.local)
|
| 118 |
+
opts.push("");
|
| 119 |
+
// if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
|
| 120 |
+
if (args.offset)
|
| 121 |
+
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
| 122 |
+
const timeRegex = `${time}(?:${opts.join("|")})`;
|
| 123 |
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
| 124 |
+
}
|
| 125 |
+
const string = (params) => {
|
| 126 |
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
| 127 |
+
return new RegExp(`^${regex}$`);
|
| 128 |
+
};
|
| 129 |
+
exports.string = string;
|
| 130 |
+
exports.bigint = /^-?\d+n?$/;
|
| 131 |
+
exports.integer = /^-?\d+$/;
|
| 132 |
+
exports.number = /^-?\d+(?:\.\d+)?$/;
|
| 133 |
+
exports.boolean = /^(?:true|false)$/i;
|
| 134 |
+
const _null = /^null$/i;
|
| 135 |
+
exports.null = _null;
|
| 136 |
+
const _undefined = /^undefined$/i;
|
| 137 |
+
exports.undefined = _undefined;
|
| 138 |
+
// regex for string with no uppercase letters
|
| 139 |
+
exports.lowercase = /^[^A-Z]*$/;
|
| 140 |
+
// regex for string with no lowercase letters
|
| 141 |
+
exports.uppercase = /^[^a-z]*$/;
|
| 142 |
+
// regex for hexadecimal strings (any length)
|
| 143 |
+
exports.hex = /^[0-9a-fA-F]*$/;
|
| 144 |
+
// Hash regexes for different algorithms and encodings
|
| 145 |
+
// Helper function to create base64 regex with exact length and padding
|
| 146 |
+
function fixedBase64(bodyLength, padding) {
|
| 147 |
+
return new RegExp(`^[A-Za-z0-9+/]{${bodyLength}}${padding}$`);
|
| 148 |
+
}
|
| 149 |
+
// Helper function to create base64url regex with exact length (no padding)
|
| 150 |
+
function fixedBase64url(length) {
|
| 151 |
+
return new RegExp(`^[A-Za-z0-9_-]{${length}}$`);
|
| 152 |
+
}
|
| 153 |
+
// MD5 (16 bytes): base64 = 24 chars total (22 + "==")
|
| 154 |
+
exports.md5_hex = /^[0-9a-fA-F]{32}$/;
|
| 155 |
+
exports.md5_base64 = fixedBase64(22, "==");
|
| 156 |
+
exports.md5_base64url = fixedBase64url(22);
|
| 157 |
+
// SHA1 (20 bytes): base64 = 28 chars total (27 + "=")
|
| 158 |
+
exports.sha1_hex = /^[0-9a-fA-F]{40}$/;
|
| 159 |
+
exports.sha1_base64 = fixedBase64(27, "=");
|
| 160 |
+
exports.sha1_base64url = fixedBase64url(27);
|
| 161 |
+
// SHA256 (32 bytes): base64 = 44 chars total (43 + "=")
|
| 162 |
+
exports.sha256_hex = /^[0-9a-fA-F]{64}$/;
|
| 163 |
+
exports.sha256_base64 = fixedBase64(43, "=");
|
| 164 |
+
exports.sha256_base64url = fixedBase64url(43);
|
| 165 |
+
// SHA384 (48 bytes): base64 = 64 chars total (no padding)
|
| 166 |
+
exports.sha384_hex = /^[0-9a-fA-F]{96}$/;
|
| 167 |
+
exports.sha384_base64 = fixedBase64(64, "");
|
| 168 |
+
exports.sha384_base64url = fixedBase64url(64);
|
| 169 |
+
// SHA512 (64 bytes): base64 = 88 chars total (86 + "==")
|
| 170 |
+
exports.sha512_hex = /^[0-9a-fA-F]{128}$/;
|
| 171 |
+
exports.sha512_base64 = fixedBase64(86, "==");
|
| 172 |
+
exports.sha512_base64url = fixedBase64url(86);
|
node_modules/zod/v4/core/regexes.d.cts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 3 |
+
* (timestamps embedded in the id). Use {@link cuid2} instead.
|
| 4 |
+
* See https://github.com/paralleldrive/cuid.
|
| 5 |
+
*/
|
| 6 |
+
export declare const cuid: RegExp;
|
| 7 |
+
export declare const cuid2: RegExp;
|
| 8 |
+
export declare const ulid: RegExp;
|
| 9 |
+
export declare const xid: RegExp;
|
| 10 |
+
export declare const ksuid: RegExp;
|
| 11 |
+
export declare const nanoid: RegExp;
|
| 12 |
+
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
| 13 |
+
export declare const duration: RegExp;
|
| 14 |
+
/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
|
| 15 |
+
export declare const extendedDuration: RegExp;
|
| 16 |
+
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
| 17 |
+
export declare const guid: RegExp;
|
| 18 |
+
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
| 19 |
+
*
|
| 20 |
+
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
| 21 |
+
export declare const uuid: (version?: number | undefined) => RegExp;
|
| 22 |
+
export declare const uuid4: RegExp;
|
| 23 |
+
export declare const uuid6: RegExp;
|
| 24 |
+
export declare const uuid7: RegExp;
|
| 25 |
+
/** Practical email validation */
|
| 26 |
+
export declare const email: RegExp;
|
| 27 |
+
/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
|
| 28 |
+
export declare const html5Email: RegExp;
|
| 29 |
+
/** The classic emailregex.com regex for RFC 5322-compliant emails */
|
| 30 |
+
export declare const rfc5322Email: RegExp;
|
| 31 |
+
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
| 32 |
+
export declare const unicodeEmail: RegExp;
|
| 33 |
+
export declare const idnEmail: RegExp;
|
| 34 |
+
export declare const browserEmail: RegExp;
|
| 35 |
+
export declare function emoji(): RegExp;
|
| 36 |
+
export declare const ipv4: RegExp;
|
| 37 |
+
export declare const ipv6: RegExp;
|
| 38 |
+
export declare const mac: (delimiter?: string) => RegExp;
|
| 39 |
+
export declare const cidrv4: RegExp;
|
| 40 |
+
export declare const cidrv6: RegExp;
|
| 41 |
+
export declare const base64: RegExp;
|
| 42 |
+
export declare const base64url: RegExp;
|
| 43 |
+
export declare const hostname: RegExp;
|
| 44 |
+
export declare const domain: RegExp;
|
| 45 |
+
export declare const httpProtocol: RegExp;
|
| 46 |
+
export declare const e164: RegExp;
|
| 47 |
+
export declare const date: RegExp;
|
| 48 |
+
export declare function time(args: {
|
| 49 |
+
precision?: number | null;
|
| 50 |
+
}): RegExp;
|
| 51 |
+
export declare function datetime(args: {
|
| 52 |
+
precision?: number | null;
|
| 53 |
+
offset?: boolean;
|
| 54 |
+
local?: boolean;
|
| 55 |
+
}): RegExp;
|
| 56 |
+
export declare const string: (params?: {
|
| 57 |
+
minimum?: number | undefined;
|
| 58 |
+
maximum?: number | undefined;
|
| 59 |
+
}) => RegExp;
|
| 60 |
+
export declare const bigint: RegExp;
|
| 61 |
+
export declare const integer: RegExp;
|
| 62 |
+
export declare const number: RegExp;
|
| 63 |
+
export declare const boolean: RegExp;
|
| 64 |
+
declare const _null: RegExp;
|
| 65 |
+
export { _null as null };
|
| 66 |
+
declare const _undefined: RegExp;
|
| 67 |
+
export { _undefined as undefined };
|
| 68 |
+
export declare const lowercase: RegExp;
|
| 69 |
+
export declare const uppercase: RegExp;
|
| 70 |
+
export declare const hex: RegExp;
|
| 71 |
+
export declare const md5_hex: RegExp;
|
| 72 |
+
export declare const md5_base64: RegExp;
|
| 73 |
+
export declare const md5_base64url: RegExp;
|
| 74 |
+
export declare const sha1_hex: RegExp;
|
| 75 |
+
export declare const sha1_base64: RegExp;
|
| 76 |
+
export declare const sha1_base64url: RegExp;
|
| 77 |
+
export declare const sha256_hex: RegExp;
|
| 78 |
+
export declare const sha256_base64: RegExp;
|
| 79 |
+
export declare const sha256_base64url: RegExp;
|
| 80 |
+
export declare const sha384_hex: RegExp;
|
| 81 |
+
export declare const sha384_base64: RegExp;
|
| 82 |
+
export declare const sha384_base64url: RegExp;
|
| 83 |
+
export declare const sha512_hex: RegExp;
|
| 84 |
+
export declare const sha512_base64: RegExp;
|
| 85 |
+
export declare const sha512_base64url: RegExp;
|
node_modules/zod/v4/core/regexes.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 3 |
+
* (timestamps embedded in the id). Use {@link cuid2} instead.
|
| 4 |
+
* See https://github.com/paralleldrive/cuid.
|
| 5 |
+
*/
|
| 6 |
+
export declare const cuid: RegExp;
|
| 7 |
+
export declare const cuid2: RegExp;
|
| 8 |
+
export declare const ulid: RegExp;
|
| 9 |
+
export declare const xid: RegExp;
|
| 10 |
+
export declare const ksuid: RegExp;
|
| 11 |
+
export declare const nanoid: RegExp;
|
| 12 |
+
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
| 13 |
+
export declare const duration: RegExp;
|
| 14 |
+
/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
|
| 15 |
+
export declare const extendedDuration: RegExp;
|
| 16 |
+
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
| 17 |
+
export declare const guid: RegExp;
|
| 18 |
+
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
| 19 |
+
*
|
| 20 |
+
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
| 21 |
+
export declare const uuid: (version?: number | undefined) => RegExp;
|
| 22 |
+
export declare const uuid4: RegExp;
|
| 23 |
+
export declare const uuid6: RegExp;
|
| 24 |
+
export declare const uuid7: RegExp;
|
| 25 |
+
/** Practical email validation */
|
| 26 |
+
export declare const email: RegExp;
|
| 27 |
+
/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
|
| 28 |
+
export declare const html5Email: RegExp;
|
| 29 |
+
/** The classic emailregex.com regex for RFC 5322-compliant emails */
|
| 30 |
+
export declare const rfc5322Email: RegExp;
|
| 31 |
+
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
| 32 |
+
export declare const unicodeEmail: RegExp;
|
| 33 |
+
export declare const idnEmail: RegExp;
|
| 34 |
+
export declare const browserEmail: RegExp;
|
| 35 |
+
export declare function emoji(): RegExp;
|
| 36 |
+
export declare const ipv4: RegExp;
|
| 37 |
+
export declare const ipv6: RegExp;
|
| 38 |
+
export declare const mac: (delimiter?: string) => RegExp;
|
| 39 |
+
export declare const cidrv4: RegExp;
|
| 40 |
+
export declare const cidrv6: RegExp;
|
| 41 |
+
export declare const base64: RegExp;
|
| 42 |
+
export declare const base64url: RegExp;
|
| 43 |
+
export declare const hostname: RegExp;
|
| 44 |
+
export declare const domain: RegExp;
|
| 45 |
+
export declare const httpProtocol: RegExp;
|
| 46 |
+
export declare const e164: RegExp;
|
| 47 |
+
export declare const date: RegExp;
|
| 48 |
+
export declare function time(args: {
|
| 49 |
+
precision?: number | null;
|
| 50 |
+
}): RegExp;
|
| 51 |
+
export declare function datetime(args: {
|
| 52 |
+
precision?: number | null;
|
| 53 |
+
offset?: boolean;
|
| 54 |
+
local?: boolean;
|
| 55 |
+
}): RegExp;
|
| 56 |
+
export declare const string: (params?: {
|
| 57 |
+
minimum?: number | undefined;
|
| 58 |
+
maximum?: number | undefined;
|
| 59 |
+
}) => RegExp;
|
| 60 |
+
export declare const bigint: RegExp;
|
| 61 |
+
export declare const integer: RegExp;
|
| 62 |
+
export declare const number: RegExp;
|
| 63 |
+
export declare const boolean: RegExp;
|
| 64 |
+
declare const _null: RegExp;
|
| 65 |
+
export { _null as null };
|
| 66 |
+
declare const _undefined: RegExp;
|
| 67 |
+
export { _undefined as undefined };
|
| 68 |
+
export declare const lowercase: RegExp;
|
| 69 |
+
export declare const uppercase: RegExp;
|
| 70 |
+
export declare const hex: RegExp;
|
| 71 |
+
export declare const md5_hex: RegExp;
|
| 72 |
+
export declare const md5_base64: RegExp;
|
| 73 |
+
export declare const md5_base64url: RegExp;
|
| 74 |
+
export declare const sha1_hex: RegExp;
|
| 75 |
+
export declare const sha1_base64: RegExp;
|
| 76 |
+
export declare const sha1_base64url: RegExp;
|
| 77 |
+
export declare const sha256_hex: RegExp;
|
| 78 |
+
export declare const sha256_base64: RegExp;
|
| 79 |
+
export declare const sha256_base64url: RegExp;
|
| 80 |
+
export declare const sha384_hex: RegExp;
|
| 81 |
+
export declare const sha384_base64: RegExp;
|
| 82 |
+
export declare const sha384_base64url: RegExp;
|
| 83 |
+
export declare const sha512_hex: RegExp;
|
| 84 |
+
export declare const sha512_base64: RegExp;
|
| 85 |
+
export declare const sha512_base64url: RegExp;
|
node_modules/zod/v4/core/regexes.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as util from "./util.js";
|
| 2 |
+
/**
|
| 3 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 4 |
+
* (timestamps embedded in the id). Use {@link cuid2} instead.
|
| 5 |
+
* See https://github.com/paralleldrive/cuid.
|
| 6 |
+
*/
|
| 7 |
+
export const cuid = /^[cC][0-9a-z]{6,}$/;
|
| 8 |
+
export const cuid2 = /^[0-9a-z]+$/;
|
| 9 |
+
export const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
| 10 |
+
export const xid = /^[0-9a-vA-V]{20}$/;
|
| 11 |
+
export const ksuid = /^[A-Za-z0-9]{27}$/;
|
| 12 |
+
export const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
| 13 |
+
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
| 14 |
+
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)?)?)$/;
|
| 15 |
+
/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
|
| 16 |
+
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)?)??$/;
|
| 17 |
+
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
| 18 |
+
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})$/;
|
| 19 |
+
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
| 20 |
+
*
|
| 21 |
+
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
| 22 |
+
export const uuid = (version) => {
|
| 23 |
+
if (!version)
|
| 24 |
+
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
| 25 |
+
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
| 26 |
+
};
|
| 27 |
+
export const uuid4 = /*@__PURE__*/ uuid(4);
|
| 28 |
+
export const uuid6 = /*@__PURE__*/ uuid(6);
|
| 29 |
+
export const uuid7 = /*@__PURE__*/ uuid(7);
|
| 30 |
+
/** Practical email validation */
|
| 31 |
+
export const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
| 32 |
+
/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
|
| 33 |
+
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])?)*$/;
|
| 34 |
+
/** The classic emailregex.com regex for RFC 5322-compliant emails */
|
| 35 |
+
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,}))$/;
|
| 36 |
+
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
| 37 |
+
export const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
| 38 |
+
export const idnEmail = unicodeEmail;
|
| 39 |
+
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])?)*$/;
|
| 40 |
+
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
| 41 |
+
const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
| 42 |
+
export function emoji() {
|
| 43 |
+
return new RegExp(_emoji, "u");
|
| 44 |
+
}
|
| 45 |
+
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])$/;
|
| 46 |
+
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}|:))$/;
|
| 47 |
+
export const mac = (delimiter) => {
|
| 48 |
+
const escapedDelim = util.escapeRegex(delimiter ?? ":");
|
| 49 |
+
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
|
| 50 |
+
};
|
| 51 |
+
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])$/;
|
| 52 |
+
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])$/;
|
| 53 |
+
// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
|
| 54 |
+
export const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
| 55 |
+
export const base64url = /^[A-Za-z0-9_-]*$/;
|
| 56 |
+
// based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
|
| 57 |
+
// export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
| 58 |
+
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])?)*\.?$/;
|
| 59 |
+
export const domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
| 60 |
+
export const httpProtocol = /^https?$/;
|
| 61 |
+
// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
|
| 62 |
+
// E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
|
| 63 |
+
export const e164 = /^\+[1-9]\d{6,14}$/;
|
| 64 |
+
// 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])))`;
|
| 65 |
+
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])))`;
|
| 66 |
+
export const date = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
|
| 67 |
+
function timeSource(args) {
|
| 68 |
+
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
| 69 |
+
const regex = typeof args.precision === "number"
|
| 70 |
+
? args.precision === -1
|
| 71 |
+
? `${hhmm}`
|
| 72 |
+
: args.precision === 0
|
| 73 |
+
? `${hhmm}:[0-5]\\d`
|
| 74 |
+
: `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}`
|
| 75 |
+
: `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
| 76 |
+
return regex;
|
| 77 |
+
}
|
| 78 |
+
export function time(args) {
|
| 79 |
+
return new RegExp(`^${timeSource(args)}$`);
|
| 80 |
+
}
|
| 81 |
+
// Adapted from https://stackoverflow.com/a/3143231
|
| 82 |
+
export function datetime(args) {
|
| 83 |
+
const time = timeSource({ precision: args.precision });
|
| 84 |
+
const opts = ["Z"];
|
| 85 |
+
if (args.local)
|
| 86 |
+
opts.push("");
|
| 87 |
+
// if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
|
| 88 |
+
if (args.offset)
|
| 89 |
+
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
| 90 |
+
const timeRegex = `${time}(?:${opts.join("|")})`;
|
| 91 |
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
| 92 |
+
}
|
| 93 |
+
export const string = (params) => {
|
| 94 |
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
| 95 |
+
return new RegExp(`^${regex}$`);
|
| 96 |
+
};
|
| 97 |
+
export const bigint = /^-?\d+n?$/;
|
| 98 |
+
export const integer = /^-?\d+$/;
|
| 99 |
+
export const number = /^-?\d+(?:\.\d+)?$/;
|
| 100 |
+
export const boolean = /^(?:true|false)$/i;
|
| 101 |
+
const _null = /^null$/i;
|
| 102 |
+
export { _null as null };
|
| 103 |
+
const _undefined = /^undefined$/i;
|
| 104 |
+
export { _undefined as undefined };
|
| 105 |
+
// regex for string with no uppercase letters
|
| 106 |
+
export const lowercase = /^[^A-Z]*$/;
|
| 107 |
+
// regex for string with no lowercase letters
|
| 108 |
+
export const uppercase = /^[^a-z]*$/;
|
| 109 |
+
// regex for hexadecimal strings (any length)
|
| 110 |
+
export const hex = /^[0-9a-fA-F]*$/;
|
| 111 |
+
// Hash regexes for different algorithms and encodings
|
| 112 |
+
// Helper function to create base64 regex with exact length and padding
|
| 113 |
+
function fixedBase64(bodyLength, padding) {
|
| 114 |
+
return new RegExp(`^[A-Za-z0-9+/]{${bodyLength}}${padding}$`);
|
| 115 |
+
}
|
| 116 |
+
// Helper function to create base64url regex with exact length (no padding)
|
| 117 |
+
function fixedBase64url(length) {
|
| 118 |
+
return new RegExp(`^[A-Za-z0-9_-]{${length}}$`);
|
| 119 |
+
}
|
| 120 |
+
// MD5 (16 bytes): base64 = 24 chars total (22 + "==")
|
| 121 |
+
export const md5_hex = /^[0-9a-fA-F]{32}$/;
|
| 122 |
+
export const md5_base64 = /*@__PURE__*/ fixedBase64(22, "==");
|
| 123 |
+
export const md5_base64url = /*@__PURE__*/ fixedBase64url(22);
|
| 124 |
+
// SHA1 (20 bytes): base64 = 28 chars total (27 + "=")
|
| 125 |
+
export const sha1_hex = /^[0-9a-fA-F]{40}$/;
|
| 126 |
+
export const sha1_base64 = /*@__PURE__*/ fixedBase64(27, "=");
|
| 127 |
+
export const sha1_base64url = /*@__PURE__*/ fixedBase64url(27);
|
| 128 |
+
// SHA256 (32 bytes): base64 = 44 chars total (43 + "=")
|
| 129 |
+
export const sha256_hex = /^[0-9a-fA-F]{64}$/;
|
| 130 |
+
export const sha256_base64 = /*@__PURE__*/ fixedBase64(43, "=");
|
| 131 |
+
export const sha256_base64url = /*@__PURE__*/ fixedBase64url(43);
|
| 132 |
+
// SHA384 (48 bytes): base64 = 64 chars total (no padding)
|
| 133 |
+
export const sha384_hex = /^[0-9a-fA-F]{96}$/;
|
| 134 |
+
export const sha384_base64 = /*@__PURE__*/ fixedBase64(64, "");
|
| 135 |
+
export const sha384_base64url = /*@__PURE__*/ fixedBase64url(64);
|
| 136 |
+
// SHA512 (64 bytes): base64 = 88 chars total (86 + "==")
|
| 137 |
+
export const sha512_hex = /^[0-9a-fA-F]{128}$/;
|
| 138 |
+
export const sha512_base64 = /*@__PURE__*/ fixedBase64(86, "==");
|
| 139 |
+
export const sha512_base64url = /*@__PURE__*/ fixedBase64url(86);
|
node_modules/zod/v4/core/registries.cjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var _a;
|
| 3 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 4 |
+
exports.globalRegistry = exports.$ZodRegistry = exports.$input = exports.$output = void 0;
|
| 5 |
+
exports.registry = registry;
|
| 6 |
+
exports.$output = Symbol("ZodOutput");
|
| 7 |
+
exports.$input = Symbol("ZodInput");
|
| 8 |
+
class $ZodRegistry {
|
| 9 |
+
constructor() {
|
| 10 |
+
this._map = new WeakMap();
|
| 11 |
+
this._idmap = new Map();
|
| 12 |
+
}
|
| 13 |
+
add(schema, ..._meta) {
|
| 14 |
+
const meta = _meta[0];
|
| 15 |
+
this._map.set(schema, meta);
|
| 16 |
+
if (meta && typeof meta === "object" && "id" in meta) {
|
| 17 |
+
this._idmap.set(meta.id, schema);
|
| 18 |
+
}
|
| 19 |
+
return this;
|
| 20 |
+
}
|
| 21 |
+
clear() {
|
| 22 |
+
this._map = new WeakMap();
|
| 23 |
+
this._idmap = new Map();
|
| 24 |
+
return this;
|
| 25 |
+
}
|
| 26 |
+
remove(schema) {
|
| 27 |
+
const meta = this._map.get(schema);
|
| 28 |
+
if (meta && typeof meta === "object" && "id" in meta) {
|
| 29 |
+
this._idmap.delete(meta.id);
|
| 30 |
+
}
|
| 31 |
+
this._map.delete(schema);
|
| 32 |
+
return this;
|
| 33 |
+
}
|
| 34 |
+
get(schema) {
|
| 35 |
+
// return this._map.get(schema) as any;
|
| 36 |
+
// inherit metadata
|
| 37 |
+
const p = schema._zod.parent;
|
| 38 |
+
if (p) {
|
| 39 |
+
const pm = { ...(this.get(p) ?? {}) };
|
| 40 |
+
delete pm.id; // do not inherit id
|
| 41 |
+
const f = { ...pm, ...this._map.get(schema) };
|
| 42 |
+
return Object.keys(f).length ? f : undefined;
|
| 43 |
+
}
|
| 44 |
+
return this._map.get(schema);
|
| 45 |
+
}
|
| 46 |
+
has(schema) {
|
| 47 |
+
return this._map.has(schema);
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
exports.$ZodRegistry = $ZodRegistry;
|
| 51 |
+
// registries
|
| 52 |
+
function registry() {
|
| 53 |
+
return new $ZodRegistry();
|
| 54 |
+
}
|
| 55 |
+
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
| 56 |
+
exports.globalRegistry = globalThis.__zod_globalRegistry;
|
node_modules/zod/v4/core/registries.d.cts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as core from "./core.cjs";
|
| 2 |
+
import type { $ZodType } from "./schemas.cjs";
|
| 3 |
+
export declare const $output: unique symbol;
|
| 4 |
+
export type $output = typeof $output;
|
| 5 |
+
export declare const $input: unique symbol;
|
| 6 |
+
export type $input = typeof $input;
|
| 7 |
+
export type $replace<Meta, S extends $ZodType> = Meta extends $output ? core.output<S> : Meta extends $input ? core.input<S> : Meta extends (infer M)[] ? $replace<M, S>[] : Meta extends (...args: infer P) => infer R ? (...args: {
|
| 8 |
+
[K in keyof P]: $replace<P[K], S>;
|
| 9 |
+
}) => $replace<R, S> : Meta extends object ? {
|
| 10 |
+
[K in keyof Meta]: $replace<Meta[K], S>;
|
| 11 |
+
} : Meta;
|
| 12 |
+
type MetadataType = object | undefined;
|
| 13 |
+
export declare class $ZodRegistry<Meta extends MetadataType = MetadataType, Schema extends $ZodType = $ZodType> {
|
| 14 |
+
_meta: Meta;
|
| 15 |
+
_schema: Schema;
|
| 16 |
+
_map: WeakMap<Schema, $replace<Meta, Schema>>;
|
| 17 |
+
_idmap: Map<string, Schema>;
|
| 18 |
+
add<S extends Schema>(schema: S, ..._meta: undefined extends Meta ? [$replace<Meta, S>?] : [$replace<Meta, S>]): this;
|
| 19 |
+
clear(): this;
|
| 20 |
+
remove(schema: Schema): this;
|
| 21 |
+
get<S extends Schema>(schema: S): $replace<Meta, S> | undefined;
|
| 22 |
+
has(schema: Schema): boolean;
|
| 23 |
+
}
|
| 24 |
+
export interface JSONSchemaMeta {
|
| 25 |
+
id?: string | undefined;
|
| 26 |
+
title?: string | undefined;
|
| 27 |
+
description?: string | undefined;
|
| 28 |
+
deprecated?: boolean | undefined;
|
| 29 |
+
[k: string]: unknown;
|
| 30 |
+
}
|
| 31 |
+
export interface GlobalMeta extends JSONSchemaMeta {
|
| 32 |
+
}
|
| 33 |
+
export declare function registry<T extends MetadataType = MetadataType, S extends $ZodType = $ZodType>(): $ZodRegistry<T, S>;
|
| 34 |
+
export declare const globalRegistry: $ZodRegistry<GlobalMeta>;
|
| 35 |
+
export {};
|
node_modules/zod/v4/core/registries.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as core from "./core.js";
|
| 2 |
+
import type { $ZodType } from "./schemas.js";
|
| 3 |
+
export declare const $output: unique symbol;
|
| 4 |
+
export type $output = typeof $output;
|
| 5 |
+
export declare const $input: unique symbol;
|
| 6 |
+
export type $input = typeof $input;
|
| 7 |
+
export type $replace<Meta, S extends $ZodType> = Meta extends $output ? core.output<S> : Meta extends $input ? core.input<S> : Meta extends (infer M)[] ? $replace<M, S>[] : Meta extends (...args: infer P) => infer R ? (...args: {
|
| 8 |
+
[K in keyof P]: $replace<P[K], S>;
|
| 9 |
+
}) => $replace<R, S> : Meta extends object ? {
|
| 10 |
+
[K in keyof Meta]: $replace<Meta[K], S>;
|
| 11 |
+
} : Meta;
|
| 12 |
+
type MetadataType = object | undefined;
|
| 13 |
+
export declare class $ZodRegistry<Meta extends MetadataType = MetadataType, Schema extends $ZodType = $ZodType> {
|
| 14 |
+
_meta: Meta;
|
| 15 |
+
_schema: Schema;
|
| 16 |
+
_map: WeakMap<Schema, $replace<Meta, Schema>>;
|
| 17 |
+
_idmap: Map<string, Schema>;
|
| 18 |
+
add<S extends Schema>(schema: S, ..._meta: undefined extends Meta ? [$replace<Meta, S>?] : [$replace<Meta, S>]): this;
|
| 19 |
+
clear(): this;
|
| 20 |
+
remove(schema: Schema): this;
|
| 21 |
+
get<S extends Schema>(schema: S): $replace<Meta, S> | undefined;
|
| 22 |
+
has(schema: Schema): boolean;
|
| 23 |
+
}
|
| 24 |
+
export interface JSONSchemaMeta {
|
| 25 |
+
id?: string | undefined;
|
| 26 |
+
title?: string | undefined;
|
| 27 |
+
description?: string | undefined;
|
| 28 |
+
deprecated?: boolean | undefined;
|
| 29 |
+
[k: string]: unknown;
|
| 30 |
+
}
|
| 31 |
+
export interface GlobalMeta extends JSONSchemaMeta {
|
| 32 |
+
}
|
| 33 |
+
export declare function registry<T extends MetadataType = MetadataType, S extends $ZodType = $ZodType>(): $ZodRegistry<T, S>;
|
| 34 |
+
export declare const globalRegistry: $ZodRegistry<GlobalMeta>;
|
| 35 |
+
export {};
|
node_modules/zod/v4/core/registries.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var _a;
|
| 2 |
+
export const $output = Symbol("ZodOutput");
|
| 3 |
+
export const $input = Symbol("ZodInput");
|
| 4 |
+
export class $ZodRegistry {
|
| 5 |
+
constructor() {
|
| 6 |
+
this._map = new WeakMap();
|
| 7 |
+
this._idmap = new Map();
|
| 8 |
+
}
|
| 9 |
+
add(schema, ..._meta) {
|
| 10 |
+
const meta = _meta[0];
|
| 11 |
+
this._map.set(schema, meta);
|
| 12 |
+
if (meta && typeof meta === "object" && "id" in meta) {
|
| 13 |
+
this._idmap.set(meta.id, schema);
|
| 14 |
+
}
|
| 15 |
+
return this;
|
| 16 |
+
}
|
| 17 |
+
clear() {
|
| 18 |
+
this._map = new WeakMap();
|
| 19 |
+
this._idmap = new Map();
|
| 20 |
+
return this;
|
| 21 |
+
}
|
| 22 |
+
remove(schema) {
|
| 23 |
+
const meta = this._map.get(schema);
|
| 24 |
+
if (meta && typeof meta === "object" && "id" in meta) {
|
| 25 |
+
this._idmap.delete(meta.id);
|
| 26 |
+
}
|
| 27 |
+
this._map.delete(schema);
|
| 28 |
+
return this;
|
| 29 |
+
}
|
| 30 |
+
get(schema) {
|
| 31 |
+
// return this._map.get(schema) as any;
|
| 32 |
+
// inherit metadata
|
| 33 |
+
const p = schema._zod.parent;
|
| 34 |
+
if (p) {
|
| 35 |
+
const pm = { ...(this.get(p) ?? {}) };
|
| 36 |
+
delete pm.id; // do not inherit id
|
| 37 |
+
const f = { ...pm, ...this._map.get(schema) };
|
| 38 |
+
return Object.keys(f).length ? f : undefined;
|
| 39 |
+
}
|
| 40 |
+
return this._map.get(schema);
|
| 41 |
+
}
|
| 42 |
+
has(schema) {
|
| 43 |
+
return this._map.has(schema);
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
// registries
|
| 47 |
+
export function registry() {
|
| 48 |
+
return new $ZodRegistry();
|
| 49 |
+
}
|
| 50 |
+
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
| 51 |
+
export const globalRegistry = globalThis.__zod_globalRegistry;
|
node_modules/zod/v4/core/schemas.cjs
ADDED
|
@@ -0,0 +1,2270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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Binding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 3 |
+
if (k2 === undefined) k2 = k;
|
| 4 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 5 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 6 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 7 |
+
}
|
| 8 |
+
Object.defineProperty(o, k2, desc);
|
| 9 |
+
}) : (function(o, m, k, k2) {
|
| 10 |
+
if (k2 === undefined) k2 = k;
|
| 11 |
+
o[k2] = m[k];
|
| 12 |
+
}));
|
| 13 |
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
| 14 |
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
| 15 |
+
}) : function(o, v) {
|
| 16 |
+
o["default"] = v;
|
| 17 |
+
});
|
| 18 |
+
var __importStar = (this && this.__importStar) || function (mod) {
|
| 19 |
+
if (mod && mod.__esModule) return mod;
|
| 20 |
+
var result = {};
|
| 21 |
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
| 22 |
+
__setModuleDefault(result, mod);
|
| 23 |
+
return result;
|
| 24 |
+
};
|
| 25 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 26 |
+
exports.$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;
|
| 27 |
+
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;
|
| 28 |
+
exports.isValidBase64 = isValidBase64;
|
| 29 |
+
exports.isValidBase64URL = isValidBase64URL;
|
| 30 |
+
exports.isValidJWT = isValidJWT;
|
| 31 |
+
const checks = __importStar(require("./checks.cjs"));
|
| 32 |
+
const core = __importStar(require("./core.cjs"));
|
| 33 |
+
const doc_js_1 = require("./doc.cjs");
|
| 34 |
+
const parse_js_1 = require("./parse.cjs");
|
| 35 |
+
const regexes = __importStar(require("./regexes.cjs"));
|
| 36 |
+
const util = __importStar(require("./util.cjs"));
|
| 37 |
+
const versions_js_1 = require("./versions.cjs");
|
| 38 |
+
exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
|
| 39 |
+
var _a;
|
| 40 |
+
inst ?? (inst = {});
|
| 41 |
+
inst._zod.def = def; // set _def property
|
| 42 |
+
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
| 43 |
+
inst._zod.version = versions_js_1.version;
|
| 44 |
+
const checks = [...(inst._zod.def.checks ?? [])];
|
| 45 |
+
// if inst is itself a checks.$ZodCheck, run it as a check
|
| 46 |
+
if (inst._zod.traits.has("$ZodCheck")) {
|
| 47 |
+
checks.unshift(inst);
|
| 48 |
+
}
|
| 49 |
+
for (const ch of checks) {
|
| 50 |
+
for (const fn of ch._zod.onattach) {
|
| 51 |
+
fn(inst);
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
if (checks.length === 0) {
|
| 55 |
+
// deferred initializer
|
| 56 |
+
// inst._zod.parse is not yet defined
|
| 57 |
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
| 58 |
+
inst._zod.deferred?.push(() => {
|
| 59 |
+
inst._zod.run = inst._zod.parse;
|
| 60 |
+
});
|
| 61 |
+
}
|
| 62 |
+
else {
|
| 63 |
+
const runChecks = (payload, checks, ctx) => {
|
| 64 |
+
let isAborted = util.aborted(payload);
|
| 65 |
+
let asyncResult;
|
| 66 |
+
for (const ch of checks) {
|
| 67 |
+
if (ch._zod.def.when) {
|
| 68 |
+
if (util.explicitlyAborted(payload))
|
| 69 |
+
continue;
|
| 70 |
+
const shouldRun = ch._zod.def.when(payload);
|
| 71 |
+
if (!shouldRun)
|
| 72 |
+
continue;
|
| 73 |
+
}
|
| 74 |
+
else if (isAborted) {
|
| 75 |
+
continue;
|
| 76 |
+
}
|
| 77 |
+
const currLen = payload.issues.length;
|
| 78 |
+
const _ = ch._zod.check(payload);
|
| 79 |
+
if (_ instanceof Promise && ctx?.async === false) {
|
| 80 |
+
throw new core.$ZodAsyncError();
|
| 81 |
+
}
|
| 82 |
+
if (asyncResult || _ instanceof Promise) {
|
| 83 |
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
| 84 |
+
await _;
|
| 85 |
+
const nextLen = payload.issues.length;
|
| 86 |
+
if (nextLen === currLen)
|
| 87 |
+
return;
|
| 88 |
+
if (!isAborted)
|
| 89 |
+
isAborted = util.aborted(payload, currLen);
|
| 90 |
+
});
|
| 91 |
+
}
|
| 92 |
+
else {
|
| 93 |
+
const nextLen = payload.issues.length;
|
| 94 |
+
if (nextLen === currLen)
|
| 95 |
+
continue;
|
| 96 |
+
if (!isAborted)
|
| 97 |
+
isAborted = util.aborted(payload, currLen);
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
if (asyncResult) {
|
| 101 |
+
return asyncResult.then(() => {
|
| 102 |
+
return payload;
|
| 103 |
+
});
|
| 104 |
+
}
|
| 105 |
+
return payload;
|
| 106 |
+
};
|
| 107 |
+
const handleCanaryResult = (canary, payload, ctx) => {
|
| 108 |
+
// abort if the canary is aborted
|
| 109 |
+
if (util.aborted(canary)) {
|
| 110 |
+
canary.aborted = true;
|
| 111 |
+
return canary;
|
| 112 |
+
}
|
| 113 |
+
// run checks first, then
|
| 114 |
+
const checkResult = runChecks(payload, checks, ctx);
|
| 115 |
+
if (checkResult instanceof Promise) {
|
| 116 |
+
if (ctx.async === false)
|
| 117 |
+
throw new core.$ZodAsyncError();
|
| 118 |
+
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
| 119 |
+
}
|
| 120 |
+
return inst._zod.parse(checkResult, ctx);
|
| 121 |
+
};
|
| 122 |
+
inst._zod.run = (payload, ctx) => {
|
| 123 |
+
if (ctx.skipChecks) {
|
| 124 |
+
return inst._zod.parse(payload, ctx);
|
| 125 |
+
}
|
| 126 |
+
if (ctx.direction === "backward") {
|
| 127 |
+
// run canary
|
| 128 |
+
// initial pass (no checks)
|
| 129 |
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
| 130 |
+
if (canary instanceof Promise) {
|
| 131 |
+
return canary.then((canary) => {
|
| 132 |
+
return handleCanaryResult(canary, payload, ctx);
|
| 133 |
+
});
|
| 134 |
+
}
|
| 135 |
+
return handleCanaryResult(canary, payload, ctx);
|
| 136 |
+
}
|
| 137 |
+
// forward
|
| 138 |
+
const result = inst._zod.parse(payload, ctx);
|
| 139 |
+
if (result instanceof Promise) {
|
| 140 |
+
if (ctx.async === false)
|
| 141 |
+
throw new core.$ZodAsyncError();
|
| 142 |
+
return result.then((result) => runChecks(result, checks, ctx));
|
| 143 |
+
}
|
| 144 |
+
return runChecks(result, checks, ctx);
|
| 145 |
+
};
|
| 146 |
+
}
|
| 147 |
+
// Lazy initialize ~standard to avoid creating objects for every schema
|
| 148 |
+
util.defineLazy(inst, "~standard", () => ({
|
| 149 |
+
validate: (value) => {
|
| 150 |
+
try {
|
| 151 |
+
const r = (0, parse_js_1.safeParse)(inst, value);
|
| 152 |
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
| 153 |
+
}
|
| 154 |
+
catch (_) {
|
| 155 |
+
return (0, parse_js_1.safeParseAsync)(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
|
| 156 |
+
}
|
| 157 |
+
},
|
| 158 |
+
vendor: "zod",
|
| 159 |
+
version: 1,
|
| 160 |
+
}));
|
| 161 |
+
});
|
| 162 |
+
var util_js_1 = require("./util.cjs");
|
| 163 |
+
Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return util_js_1.clone; } });
|
| 164 |
+
exports.$ZodString = core.$constructor("$ZodString", (inst, def) => {
|
| 165 |
+
exports.$ZodType.init(inst, def);
|
| 166 |
+
inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? regexes.string(inst._zod.bag);
|
| 167 |
+
inst._zod.parse = (payload, _) => {
|
| 168 |
+
if (def.coerce)
|
| 169 |
+
try {
|
| 170 |
+
payload.value = String(payload.value);
|
| 171 |
+
}
|
| 172 |
+
catch (_) { }
|
| 173 |
+
if (typeof payload.value === "string")
|
| 174 |
+
return payload;
|
| 175 |
+
payload.issues.push({
|
| 176 |
+
expected: "string",
|
| 177 |
+
code: "invalid_type",
|
| 178 |
+
input: payload.value,
|
| 179 |
+
inst,
|
| 180 |
+
});
|
| 181 |
+
return payload;
|
| 182 |
+
};
|
| 183 |
+
});
|
| 184 |
+
exports.$ZodStringFormat = core.$constructor("$ZodStringFormat", (inst, def) => {
|
| 185 |
+
// check initialization must come first
|
| 186 |
+
checks.$ZodCheckStringFormat.init(inst, def);
|
| 187 |
+
exports.$ZodString.init(inst, def);
|
| 188 |
+
});
|
| 189 |
+
exports.$ZodGUID = core.$constructor("$ZodGUID", (inst, def) => {
|
| 190 |
+
def.pattern ?? (def.pattern = regexes.guid);
|
| 191 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 192 |
+
});
|
| 193 |
+
exports.$ZodUUID = core.$constructor("$ZodUUID", (inst, def) => {
|
| 194 |
+
if (def.version) {
|
| 195 |
+
const versionMap = {
|
| 196 |
+
v1: 1,
|
| 197 |
+
v2: 2,
|
| 198 |
+
v3: 3,
|
| 199 |
+
v4: 4,
|
| 200 |
+
v5: 5,
|
| 201 |
+
v6: 6,
|
| 202 |
+
v7: 7,
|
| 203 |
+
v8: 8,
|
| 204 |
+
};
|
| 205 |
+
const v = versionMap[def.version];
|
| 206 |
+
if (v === undefined)
|
| 207 |
+
throw new Error(`Invalid UUID version: "${def.version}"`);
|
| 208 |
+
def.pattern ?? (def.pattern = regexes.uuid(v));
|
| 209 |
+
}
|
| 210 |
+
else
|
| 211 |
+
def.pattern ?? (def.pattern = regexes.uuid());
|
| 212 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 213 |
+
});
|
| 214 |
+
exports.$ZodEmail = core.$constructor("$ZodEmail", (inst, def) => {
|
| 215 |
+
def.pattern ?? (def.pattern = regexes.email);
|
| 216 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 217 |
+
});
|
| 218 |
+
exports.$ZodURL = core.$constructor("$ZodURL", (inst, def) => {
|
| 219 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 220 |
+
inst._zod.check = (payload) => {
|
| 221 |
+
try {
|
| 222 |
+
// Trim whitespace from input
|
| 223 |
+
const trimmed = payload.value.trim();
|
| 224 |
+
// When normalize is off, require :// for http/https URLs
|
| 225 |
+
// This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
| 226 |
+
if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source) {
|
| 227 |
+
if (!/^https?:\/\//i.test(trimmed)) {
|
| 228 |
+
payload.issues.push({
|
| 229 |
+
code: "invalid_format",
|
| 230 |
+
format: "url",
|
| 231 |
+
note: "Invalid URL format",
|
| 232 |
+
input: payload.value,
|
| 233 |
+
inst,
|
| 234 |
+
continue: !def.abort,
|
| 235 |
+
});
|
| 236 |
+
return;
|
| 237 |
+
}
|
| 238 |
+
}
|
| 239 |
+
// @ts-ignore
|
| 240 |
+
const url = new URL(trimmed);
|
| 241 |
+
if (def.hostname) {
|
| 242 |
+
def.hostname.lastIndex = 0;
|
| 243 |
+
if (!def.hostname.test(url.hostname)) {
|
| 244 |
+
payload.issues.push({
|
| 245 |
+
code: "invalid_format",
|
| 246 |
+
format: "url",
|
| 247 |
+
note: "Invalid hostname",
|
| 248 |
+
pattern: def.hostname.source,
|
| 249 |
+
input: payload.value,
|
| 250 |
+
inst,
|
| 251 |
+
continue: !def.abort,
|
| 252 |
+
});
|
| 253 |
+
}
|
| 254 |
+
}
|
| 255 |
+
if (def.protocol) {
|
| 256 |
+
def.protocol.lastIndex = 0;
|
| 257 |
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
|
| 258 |
+
payload.issues.push({
|
| 259 |
+
code: "invalid_format",
|
| 260 |
+
format: "url",
|
| 261 |
+
note: "Invalid protocol",
|
| 262 |
+
pattern: def.protocol.source,
|
| 263 |
+
input: payload.value,
|
| 264 |
+
inst,
|
| 265 |
+
continue: !def.abort,
|
| 266 |
+
});
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
// Set the output value based on normalize flag
|
| 270 |
+
if (def.normalize) {
|
| 271 |
+
// Use normalized URL
|
| 272 |
+
payload.value = url.href;
|
| 273 |
+
}
|
| 274 |
+
else {
|
| 275 |
+
// Preserve the original input (trimmed)
|
| 276 |
+
payload.value = trimmed;
|
| 277 |
+
}
|
| 278 |
+
return;
|
| 279 |
+
}
|
| 280 |
+
catch (_) {
|
| 281 |
+
payload.issues.push({
|
| 282 |
+
code: "invalid_format",
|
| 283 |
+
format: "url",
|
| 284 |
+
input: payload.value,
|
| 285 |
+
inst,
|
| 286 |
+
continue: !def.abort,
|
| 287 |
+
});
|
| 288 |
+
}
|
| 289 |
+
};
|
| 290 |
+
});
|
| 291 |
+
exports.$ZodEmoji = core.$constructor("$ZodEmoji", (inst, def) => {
|
| 292 |
+
def.pattern ?? (def.pattern = regexes.emoji());
|
| 293 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 294 |
+
});
|
| 295 |
+
exports.$ZodNanoID = core.$constructor("$ZodNanoID", (inst, def) => {
|
| 296 |
+
def.pattern ?? (def.pattern = regexes.nanoid);
|
| 297 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 298 |
+
});
|
| 299 |
+
/**
|
| 300 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 301 |
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
| 302 |
+
* See https://github.com/paralleldrive/cuid.
|
| 303 |
+
*/
|
| 304 |
+
exports.$ZodCUID = core.$constructor("$ZodCUID", (inst, def) => {
|
| 305 |
+
def.pattern ?? (def.pattern = regexes.cuid);
|
| 306 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 307 |
+
});
|
| 308 |
+
exports.$ZodCUID2 = core.$constructor("$ZodCUID2", (inst, def) => {
|
| 309 |
+
def.pattern ?? (def.pattern = regexes.cuid2);
|
| 310 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 311 |
+
});
|
| 312 |
+
exports.$ZodULID = core.$constructor("$ZodULID", (inst, def) => {
|
| 313 |
+
def.pattern ?? (def.pattern = regexes.ulid);
|
| 314 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 315 |
+
});
|
| 316 |
+
exports.$ZodXID = core.$constructor("$ZodXID", (inst, def) => {
|
| 317 |
+
def.pattern ?? (def.pattern = regexes.xid);
|
| 318 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 319 |
+
});
|
| 320 |
+
exports.$ZodKSUID = core.$constructor("$ZodKSUID", (inst, def) => {
|
| 321 |
+
def.pattern ?? (def.pattern = regexes.ksuid);
|
| 322 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 323 |
+
});
|
| 324 |
+
exports.$ZodISODateTime = core.$constructor("$ZodISODateTime", (inst, def) => {
|
| 325 |
+
def.pattern ?? (def.pattern = regexes.datetime(def));
|
| 326 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 327 |
+
});
|
| 328 |
+
exports.$ZodISODate = core.$constructor("$ZodISODate", (inst, def) => {
|
| 329 |
+
def.pattern ?? (def.pattern = regexes.date);
|
| 330 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 331 |
+
});
|
| 332 |
+
exports.$ZodISOTime = core.$constructor("$ZodISOTime", (inst, def) => {
|
| 333 |
+
def.pattern ?? (def.pattern = regexes.time(def));
|
| 334 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 335 |
+
});
|
| 336 |
+
exports.$ZodISODuration = core.$constructor("$ZodISODuration", (inst, def) => {
|
| 337 |
+
def.pattern ?? (def.pattern = regexes.duration);
|
| 338 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 339 |
+
});
|
| 340 |
+
exports.$ZodIPv4 = core.$constructor("$ZodIPv4", (inst, def) => {
|
| 341 |
+
def.pattern ?? (def.pattern = regexes.ipv4);
|
| 342 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 343 |
+
inst._zod.bag.format = `ipv4`;
|
| 344 |
+
});
|
| 345 |
+
exports.$ZodIPv6 = core.$constructor("$ZodIPv6", (inst, def) => {
|
| 346 |
+
def.pattern ?? (def.pattern = regexes.ipv6);
|
| 347 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 348 |
+
inst._zod.bag.format = `ipv6`;
|
| 349 |
+
inst._zod.check = (payload) => {
|
| 350 |
+
try {
|
| 351 |
+
// @ts-ignore
|
| 352 |
+
new URL(`http://[${payload.value}]`);
|
| 353 |
+
// return;
|
| 354 |
+
}
|
| 355 |
+
catch {
|
| 356 |
+
payload.issues.push({
|
| 357 |
+
code: "invalid_format",
|
| 358 |
+
format: "ipv6",
|
| 359 |
+
input: payload.value,
|
| 360 |
+
inst,
|
| 361 |
+
continue: !def.abort,
|
| 362 |
+
});
|
| 363 |
+
}
|
| 364 |
+
};
|
| 365 |
+
});
|
| 366 |
+
exports.$ZodMAC = core.$constructor("$ZodMAC", (inst, def) => {
|
| 367 |
+
def.pattern ?? (def.pattern = regexes.mac(def.delimiter));
|
| 368 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 369 |
+
inst._zod.bag.format = `mac`;
|
| 370 |
+
});
|
| 371 |
+
exports.$ZodCIDRv4 = core.$constructor("$ZodCIDRv4", (inst, def) => {
|
| 372 |
+
def.pattern ?? (def.pattern = regexes.cidrv4);
|
| 373 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 374 |
+
});
|
| 375 |
+
exports.$ZodCIDRv6 = core.$constructor("$ZodCIDRv6", (inst, def) => {
|
| 376 |
+
def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
|
| 377 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 378 |
+
inst._zod.check = (payload) => {
|
| 379 |
+
const parts = payload.value.split("/");
|
| 380 |
+
try {
|
| 381 |
+
if (parts.length !== 2)
|
| 382 |
+
throw new Error();
|
| 383 |
+
const [address, prefix] = parts;
|
| 384 |
+
if (!prefix)
|
| 385 |
+
throw new Error();
|
| 386 |
+
const prefixNum = Number(prefix);
|
| 387 |
+
if (`${prefixNum}` !== prefix)
|
| 388 |
+
throw new Error();
|
| 389 |
+
if (prefixNum < 0 || prefixNum > 128)
|
| 390 |
+
throw new Error();
|
| 391 |
+
// @ts-ignore
|
| 392 |
+
new URL(`http://[${address}]`);
|
| 393 |
+
}
|
| 394 |
+
catch {
|
| 395 |
+
payload.issues.push({
|
| 396 |
+
code: "invalid_format",
|
| 397 |
+
format: "cidrv6",
|
| 398 |
+
input: payload.value,
|
| 399 |
+
inst,
|
| 400 |
+
continue: !def.abort,
|
| 401 |
+
});
|
| 402 |
+
}
|
| 403 |
+
};
|
| 404 |
+
});
|
| 405 |
+
////////////////////////////// ZodBase64 //////////////////////////////
|
| 406 |
+
function isValidBase64(data) {
|
| 407 |
+
if (data === "")
|
| 408 |
+
return true;
|
| 409 |
+
// atob ignores whitespace, so reject it up front.
|
| 410 |
+
if (/\s/.test(data))
|
| 411 |
+
return false;
|
| 412 |
+
if (data.length % 4 !== 0)
|
| 413 |
+
return false;
|
| 414 |
+
try {
|
| 415 |
+
// @ts-ignore
|
| 416 |
+
atob(data);
|
| 417 |
+
return true;
|
| 418 |
+
}
|
| 419 |
+
catch {
|
| 420 |
+
return false;
|
| 421 |
+
}
|
| 422 |
+
}
|
| 423 |
+
exports.$ZodBase64 = core.$constructor("$ZodBase64", (inst, def) => {
|
| 424 |
+
def.pattern ?? (def.pattern = regexes.base64);
|
| 425 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 426 |
+
inst._zod.bag.contentEncoding = "base64";
|
| 427 |
+
inst._zod.check = (payload) => {
|
| 428 |
+
if (isValidBase64(payload.value))
|
| 429 |
+
return;
|
| 430 |
+
payload.issues.push({
|
| 431 |
+
code: "invalid_format",
|
| 432 |
+
format: "base64",
|
| 433 |
+
input: payload.value,
|
| 434 |
+
inst,
|
| 435 |
+
continue: !def.abort,
|
| 436 |
+
});
|
| 437 |
+
};
|
| 438 |
+
});
|
| 439 |
+
////////////////////////////// ZodBase64 //////////////////////////////
|
| 440 |
+
function isValidBase64URL(data) {
|
| 441 |
+
if (!regexes.base64url.test(data))
|
| 442 |
+
return false;
|
| 443 |
+
const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
|
| 444 |
+
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
| 445 |
+
return isValidBase64(padded);
|
| 446 |
+
}
|
| 447 |
+
exports.$ZodBase64URL = core.$constructor("$ZodBase64URL", (inst, def) => {
|
| 448 |
+
def.pattern ?? (def.pattern = regexes.base64url);
|
| 449 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 450 |
+
inst._zod.bag.contentEncoding = "base64url";
|
| 451 |
+
inst._zod.check = (payload) => {
|
| 452 |
+
if (isValidBase64URL(payload.value))
|
| 453 |
+
return;
|
| 454 |
+
payload.issues.push({
|
| 455 |
+
code: "invalid_format",
|
| 456 |
+
format: "base64url",
|
| 457 |
+
input: payload.value,
|
| 458 |
+
inst,
|
| 459 |
+
continue: !def.abort,
|
| 460 |
+
});
|
| 461 |
+
};
|
| 462 |
+
});
|
| 463 |
+
exports.$ZodE164 = core.$constructor("$ZodE164", (inst, def) => {
|
| 464 |
+
def.pattern ?? (def.pattern = regexes.e164);
|
| 465 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 466 |
+
});
|
| 467 |
+
////////////////////////////// ZodJWT //////////////////////////////
|
| 468 |
+
function isValidJWT(token, algorithm = null) {
|
| 469 |
+
try {
|
| 470 |
+
const tokensParts = token.split(".");
|
| 471 |
+
if (tokensParts.length !== 3)
|
| 472 |
+
return false;
|
| 473 |
+
const [header] = tokensParts;
|
| 474 |
+
if (!header)
|
| 475 |
+
return false;
|
| 476 |
+
// @ts-ignore
|
| 477 |
+
const parsedHeader = JSON.parse(atob(header));
|
| 478 |
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
| 479 |
+
return false;
|
| 480 |
+
if (!parsedHeader.alg)
|
| 481 |
+
return false;
|
| 482 |
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
|
| 483 |
+
return false;
|
| 484 |
+
return true;
|
| 485 |
+
}
|
| 486 |
+
catch {
|
| 487 |
+
return false;
|
| 488 |
+
}
|
| 489 |
+
}
|
| 490 |
+
exports.$ZodJWT = core.$constructor("$ZodJWT", (inst, def) => {
|
| 491 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 492 |
+
inst._zod.check = (payload) => {
|
| 493 |
+
if (isValidJWT(payload.value, def.alg))
|
| 494 |
+
return;
|
| 495 |
+
payload.issues.push({
|
| 496 |
+
code: "invalid_format",
|
| 497 |
+
format: "jwt",
|
| 498 |
+
input: payload.value,
|
| 499 |
+
inst,
|
| 500 |
+
continue: !def.abort,
|
| 501 |
+
});
|
| 502 |
+
};
|
| 503 |
+
});
|
| 504 |
+
exports.$ZodCustomStringFormat = core.$constructor("$ZodCustomStringFormat", (inst, def) => {
|
| 505 |
+
exports.$ZodStringFormat.init(inst, def);
|
| 506 |
+
inst._zod.check = (payload) => {
|
| 507 |
+
if (def.fn(payload.value))
|
| 508 |
+
return;
|
| 509 |
+
payload.issues.push({
|
| 510 |
+
code: "invalid_format",
|
| 511 |
+
format: def.format,
|
| 512 |
+
input: payload.value,
|
| 513 |
+
inst,
|
| 514 |
+
continue: !def.abort,
|
| 515 |
+
});
|
| 516 |
+
};
|
| 517 |
+
});
|
| 518 |
+
exports.$ZodNumber = core.$constructor("$ZodNumber", (inst, def) => {
|
| 519 |
+
exports.$ZodType.init(inst, def);
|
| 520 |
+
inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;
|
| 521 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 522 |
+
if (def.coerce)
|
| 523 |
+
try {
|
| 524 |
+
payload.value = Number(payload.value);
|
| 525 |
+
}
|
| 526 |
+
catch (_) { }
|
| 527 |
+
const input = payload.value;
|
| 528 |
+
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
|
| 529 |
+
return payload;
|
| 530 |
+
}
|
| 531 |
+
const received = typeof input === "number"
|
| 532 |
+
? Number.isNaN(input)
|
| 533 |
+
? "NaN"
|
| 534 |
+
: !Number.isFinite(input)
|
| 535 |
+
? "Infinity"
|
| 536 |
+
: undefined
|
| 537 |
+
: undefined;
|
| 538 |
+
payload.issues.push({
|
| 539 |
+
expected: "number",
|
| 540 |
+
code: "invalid_type",
|
| 541 |
+
input,
|
| 542 |
+
inst,
|
| 543 |
+
...(received ? { received } : {}),
|
| 544 |
+
});
|
| 545 |
+
return payload;
|
| 546 |
+
};
|
| 547 |
+
});
|
| 548 |
+
exports.$ZodNumberFormat = core.$constructor("$ZodNumberFormat", (inst, def) => {
|
| 549 |
+
checks.$ZodCheckNumberFormat.init(inst, def);
|
| 550 |
+
exports.$ZodNumber.init(inst, def); // no format checks
|
| 551 |
+
});
|
| 552 |
+
exports.$ZodBoolean = core.$constructor("$ZodBoolean", (inst, def) => {
|
| 553 |
+
exports.$ZodType.init(inst, def);
|
| 554 |
+
inst._zod.pattern = regexes.boolean;
|
| 555 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 556 |
+
if (def.coerce)
|
| 557 |
+
try {
|
| 558 |
+
payload.value = Boolean(payload.value);
|
| 559 |
+
}
|
| 560 |
+
catch (_) { }
|
| 561 |
+
const input = payload.value;
|
| 562 |
+
if (typeof input === "boolean")
|
| 563 |
+
return payload;
|
| 564 |
+
payload.issues.push({
|
| 565 |
+
expected: "boolean",
|
| 566 |
+
code: "invalid_type",
|
| 567 |
+
input,
|
| 568 |
+
inst,
|
| 569 |
+
});
|
| 570 |
+
return payload;
|
| 571 |
+
};
|
| 572 |
+
});
|
| 573 |
+
exports.$ZodBigInt = core.$constructor("$ZodBigInt", (inst, def) => {
|
| 574 |
+
exports.$ZodType.init(inst, def);
|
| 575 |
+
inst._zod.pattern = regexes.bigint;
|
| 576 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 577 |
+
if (def.coerce)
|
| 578 |
+
try {
|
| 579 |
+
payload.value = BigInt(payload.value);
|
| 580 |
+
}
|
| 581 |
+
catch (_) { }
|
| 582 |
+
if (typeof payload.value === "bigint")
|
| 583 |
+
return payload;
|
| 584 |
+
payload.issues.push({
|
| 585 |
+
expected: "bigint",
|
| 586 |
+
code: "invalid_type",
|
| 587 |
+
input: payload.value,
|
| 588 |
+
inst,
|
| 589 |
+
});
|
| 590 |
+
return payload;
|
| 591 |
+
};
|
| 592 |
+
});
|
| 593 |
+
exports.$ZodBigIntFormat = core.$constructor("$ZodBigIntFormat", (inst, def) => {
|
| 594 |
+
checks.$ZodCheckBigIntFormat.init(inst, def);
|
| 595 |
+
exports.$ZodBigInt.init(inst, def); // no format checks
|
| 596 |
+
});
|
| 597 |
+
exports.$ZodSymbol = core.$constructor("$ZodSymbol", (inst, def) => {
|
| 598 |
+
exports.$ZodType.init(inst, def);
|
| 599 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 600 |
+
const input = payload.value;
|
| 601 |
+
if (typeof input === "symbol")
|
| 602 |
+
return payload;
|
| 603 |
+
payload.issues.push({
|
| 604 |
+
expected: "symbol",
|
| 605 |
+
code: "invalid_type",
|
| 606 |
+
input,
|
| 607 |
+
inst,
|
| 608 |
+
});
|
| 609 |
+
return payload;
|
| 610 |
+
};
|
| 611 |
+
});
|
| 612 |
+
exports.$ZodUndefined = core.$constructor("$ZodUndefined", (inst, def) => {
|
| 613 |
+
exports.$ZodType.init(inst, def);
|
| 614 |
+
inst._zod.pattern = regexes.undefined;
|
| 615 |
+
inst._zod.values = new Set([undefined]);
|
| 616 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 617 |
+
const input = payload.value;
|
| 618 |
+
if (typeof input === "undefined")
|
| 619 |
+
return payload;
|
| 620 |
+
payload.issues.push({
|
| 621 |
+
expected: "undefined",
|
| 622 |
+
code: "invalid_type",
|
| 623 |
+
input,
|
| 624 |
+
inst,
|
| 625 |
+
});
|
| 626 |
+
return payload;
|
| 627 |
+
};
|
| 628 |
+
});
|
| 629 |
+
exports.$ZodNull = core.$constructor("$ZodNull", (inst, def) => {
|
| 630 |
+
exports.$ZodType.init(inst, def);
|
| 631 |
+
inst._zod.pattern = regexes.null;
|
| 632 |
+
inst._zod.values = new Set([null]);
|
| 633 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 634 |
+
const input = payload.value;
|
| 635 |
+
if (input === null)
|
| 636 |
+
return payload;
|
| 637 |
+
payload.issues.push({
|
| 638 |
+
expected: "null",
|
| 639 |
+
code: "invalid_type",
|
| 640 |
+
input,
|
| 641 |
+
inst,
|
| 642 |
+
});
|
| 643 |
+
return payload;
|
| 644 |
+
};
|
| 645 |
+
});
|
| 646 |
+
exports.$ZodAny = core.$constructor("$ZodAny", (inst, def) => {
|
| 647 |
+
exports.$ZodType.init(inst, def);
|
| 648 |
+
inst._zod.parse = (payload) => payload;
|
| 649 |
+
});
|
| 650 |
+
exports.$ZodUnknown = core.$constructor("$ZodUnknown", (inst, def) => {
|
| 651 |
+
exports.$ZodType.init(inst, def);
|
| 652 |
+
inst._zod.parse = (payload) => payload;
|
| 653 |
+
});
|
| 654 |
+
exports.$ZodNever = core.$constructor("$ZodNever", (inst, def) => {
|
| 655 |
+
exports.$ZodType.init(inst, def);
|
| 656 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 657 |
+
payload.issues.push({
|
| 658 |
+
expected: "never",
|
| 659 |
+
code: "invalid_type",
|
| 660 |
+
input: payload.value,
|
| 661 |
+
inst,
|
| 662 |
+
});
|
| 663 |
+
return payload;
|
| 664 |
+
};
|
| 665 |
+
});
|
| 666 |
+
exports.$ZodVoid = core.$constructor("$ZodVoid", (inst, def) => {
|
| 667 |
+
exports.$ZodType.init(inst, def);
|
| 668 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 669 |
+
const input = payload.value;
|
| 670 |
+
if (typeof input === "undefined")
|
| 671 |
+
return payload;
|
| 672 |
+
payload.issues.push({
|
| 673 |
+
expected: "void",
|
| 674 |
+
code: "invalid_type",
|
| 675 |
+
input,
|
| 676 |
+
inst,
|
| 677 |
+
});
|
| 678 |
+
return payload;
|
| 679 |
+
};
|
| 680 |
+
});
|
| 681 |
+
exports.$ZodDate = core.$constructor("$ZodDate", (inst, def) => {
|
| 682 |
+
exports.$ZodType.init(inst, def);
|
| 683 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 684 |
+
if (def.coerce) {
|
| 685 |
+
try {
|
| 686 |
+
payload.value = new Date(payload.value);
|
| 687 |
+
}
|
| 688 |
+
catch (_err) { }
|
| 689 |
+
}
|
| 690 |
+
const input = payload.value;
|
| 691 |
+
const isDate = input instanceof Date;
|
| 692 |
+
const isValidDate = isDate && !Number.isNaN(input.getTime());
|
| 693 |
+
if (isValidDate)
|
| 694 |
+
return payload;
|
| 695 |
+
payload.issues.push({
|
| 696 |
+
expected: "date",
|
| 697 |
+
code: "invalid_type",
|
| 698 |
+
input,
|
| 699 |
+
...(isDate ? { received: "Invalid Date" } : {}),
|
| 700 |
+
inst,
|
| 701 |
+
});
|
| 702 |
+
return payload;
|
| 703 |
+
};
|
| 704 |
+
});
|
| 705 |
+
function handleArrayResult(result, final, index) {
|
| 706 |
+
if (result.issues.length) {
|
| 707 |
+
final.issues.push(...util.prefixIssues(index, result.issues));
|
| 708 |
+
}
|
| 709 |
+
final.value[index] = result.value;
|
| 710 |
+
}
|
| 711 |
+
exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
|
| 712 |
+
exports.$ZodType.init(inst, def);
|
| 713 |
+
inst._zod.parse = (payload, ctx) => {
|
| 714 |
+
const input = payload.value;
|
| 715 |
+
if (!Array.isArray(input)) {
|
| 716 |
+
payload.issues.push({
|
| 717 |
+
expected: "array",
|
| 718 |
+
code: "invalid_type",
|
| 719 |
+
input,
|
| 720 |
+
inst,
|
| 721 |
+
});
|
| 722 |
+
return payload;
|
| 723 |
+
}
|
| 724 |
+
payload.value = Array(input.length);
|
| 725 |
+
const proms = [];
|
| 726 |
+
for (let i = 0; i < input.length; i++) {
|
| 727 |
+
const item = input[i];
|
| 728 |
+
const result = def.element._zod.run({
|
| 729 |
+
value: item,
|
| 730 |
+
issues: [],
|
| 731 |
+
}, ctx);
|
| 732 |
+
if (result instanceof Promise) {
|
| 733 |
+
proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
| 734 |
+
}
|
| 735 |
+
else {
|
| 736 |
+
handleArrayResult(result, payload, i);
|
| 737 |
+
}
|
| 738 |
+
}
|
| 739 |
+
if (proms.length) {
|
| 740 |
+
return Promise.all(proms).then(() => payload);
|
| 741 |
+
}
|
| 742 |
+
return payload; //handleArrayResultsAsync(parseResults, final);
|
| 743 |
+
};
|
| 744 |
+
});
|
| 745 |
+
function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
|
| 746 |
+
const isPresent = key in input;
|
| 747 |
+
if (result.issues.length) {
|
| 748 |
+
// For optional-in/out schemas, ignore errors on absent keys.
|
| 749 |
+
if (isOptionalIn && isOptionalOut && !isPresent) {
|
| 750 |
+
return;
|
| 751 |
+
}
|
| 752 |
+
final.issues.push(...util.prefixIssues(key, result.issues));
|
| 753 |
+
}
|
| 754 |
+
if (!isPresent && !isOptionalIn) {
|
| 755 |
+
if (!result.issues.length) {
|
| 756 |
+
final.issues.push({
|
| 757 |
+
code: "invalid_type",
|
| 758 |
+
expected: "nonoptional",
|
| 759 |
+
input: undefined,
|
| 760 |
+
path: [key],
|
| 761 |
+
});
|
| 762 |
+
}
|
| 763 |
+
return;
|
| 764 |
+
}
|
| 765 |
+
if (result.value === undefined) {
|
| 766 |
+
if (isPresent) {
|
| 767 |
+
final.value[key] = undefined;
|
| 768 |
+
}
|
| 769 |
+
}
|
| 770 |
+
else {
|
| 771 |
+
final.value[key] = result.value;
|
| 772 |
+
}
|
| 773 |
+
}
|
| 774 |
+
function normalizeDef(def) {
|
| 775 |
+
const keys = Object.keys(def.shape);
|
| 776 |
+
for (const k of keys) {
|
| 777 |
+
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
| 778 |
+
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
| 779 |
+
}
|
| 780 |
+
}
|
| 781 |
+
const okeys = util.optionalKeys(def.shape);
|
| 782 |
+
return {
|
| 783 |
+
...def,
|
| 784 |
+
keys,
|
| 785 |
+
keySet: new Set(keys),
|
| 786 |
+
numKeys: keys.length,
|
| 787 |
+
optionalKeys: new Set(okeys),
|
| 788 |
+
};
|
| 789 |
+
}
|
| 790 |
+
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
| 791 |
+
const unrecognized = [];
|
| 792 |
+
const keySet = def.keySet;
|
| 793 |
+
const _catchall = def.catchall._zod;
|
| 794 |
+
const t = _catchall.def.type;
|
| 795 |
+
const isOptionalIn = _catchall.optin === "optional";
|
| 796 |
+
const isOptionalOut = _catchall.optout === "optional";
|
| 797 |
+
for (const key in input) {
|
| 798 |
+
// skip __proto__ so it can't replace the result prototype via the
|
| 799 |
+
// assignment setter on the plain {} we build into
|
| 800 |
+
if (key === "__proto__")
|
| 801 |
+
continue;
|
| 802 |
+
if (keySet.has(key))
|
| 803 |
+
continue;
|
| 804 |
+
if (t === "never") {
|
| 805 |
+
unrecognized.push(key);
|
| 806 |
+
continue;
|
| 807 |
+
}
|
| 808 |
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
| 809 |
+
if (r instanceof Promise) {
|
| 810 |
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
| 811 |
+
}
|
| 812 |
+
else {
|
| 813 |
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
| 814 |
+
}
|
| 815 |
+
}
|
| 816 |
+
if (unrecognized.length) {
|
| 817 |
+
payload.issues.push({
|
| 818 |
+
code: "unrecognized_keys",
|
| 819 |
+
keys: unrecognized,
|
| 820 |
+
input,
|
| 821 |
+
inst,
|
| 822 |
+
});
|
| 823 |
+
}
|
| 824 |
+
if (!proms.length)
|
| 825 |
+
return payload;
|
| 826 |
+
return Promise.all(proms).then(() => {
|
| 827 |
+
return payload;
|
| 828 |
+
});
|
| 829 |
+
}
|
| 830 |
+
exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
|
| 831 |
+
// requires cast because technically $ZodObject doesn't extend
|
| 832 |
+
exports.$ZodType.init(inst, def);
|
| 833 |
+
// const sh = def.shape;
|
| 834 |
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
| 835 |
+
if (!desc?.get) {
|
| 836 |
+
const sh = def.shape;
|
| 837 |
+
Object.defineProperty(def, "shape", {
|
| 838 |
+
get: () => {
|
| 839 |
+
const newSh = { ...sh };
|
| 840 |
+
Object.defineProperty(def, "shape", {
|
| 841 |
+
value: newSh,
|
| 842 |
+
});
|
| 843 |
+
return newSh;
|
| 844 |
+
},
|
| 845 |
+
});
|
| 846 |
+
}
|
| 847 |
+
const _normalized = util.cached(() => normalizeDef(def));
|
| 848 |
+
util.defineLazy(inst._zod, "propValues", () => {
|
| 849 |
+
const shape = def.shape;
|
| 850 |
+
const propValues = {};
|
| 851 |
+
for (const key in shape) {
|
| 852 |
+
const field = shape[key]._zod;
|
| 853 |
+
if (field.values) {
|
| 854 |
+
propValues[key] ?? (propValues[key] = new Set());
|
| 855 |
+
for (const v of field.values)
|
| 856 |
+
propValues[key].add(v);
|
| 857 |
+
}
|
| 858 |
+
}
|
| 859 |
+
return propValues;
|
| 860 |
+
});
|
| 861 |
+
const isObject = util.isObject;
|
| 862 |
+
const catchall = def.catchall;
|
| 863 |
+
let value;
|
| 864 |
+
inst._zod.parse = (payload, ctx) => {
|
| 865 |
+
value ?? (value = _normalized.value);
|
| 866 |
+
const input = payload.value;
|
| 867 |
+
if (!isObject(input)) {
|
| 868 |
+
payload.issues.push({
|
| 869 |
+
expected: "object",
|
| 870 |
+
code: "invalid_type",
|
| 871 |
+
input,
|
| 872 |
+
inst,
|
| 873 |
+
});
|
| 874 |
+
return payload;
|
| 875 |
+
}
|
| 876 |
+
payload.value = {};
|
| 877 |
+
const proms = [];
|
| 878 |
+
const shape = value.shape;
|
| 879 |
+
for (const key of value.keys) {
|
| 880 |
+
const el = shape[key];
|
| 881 |
+
const isOptionalIn = el._zod.optin === "optional";
|
| 882 |
+
const isOptionalOut = el._zod.optout === "optional";
|
| 883 |
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
| 884 |
+
if (r instanceof Promise) {
|
| 885 |
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
| 886 |
+
}
|
| 887 |
+
else {
|
| 888 |
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
| 889 |
+
}
|
| 890 |
+
}
|
| 891 |
+
if (!catchall) {
|
| 892 |
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
| 893 |
+
}
|
| 894 |
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
| 895 |
+
};
|
| 896 |
+
});
|
| 897 |
+
exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
|
| 898 |
+
// requires cast because technically $ZodObject doesn't extend
|
| 899 |
+
exports.$ZodObject.init(inst, def);
|
| 900 |
+
const superParse = inst._zod.parse;
|
| 901 |
+
const _normalized = util.cached(() => normalizeDef(def));
|
| 902 |
+
const generateFastpass = (shape) => {
|
| 903 |
+
const doc = new doc_js_1.Doc(["shape", "payload", "ctx"]);
|
| 904 |
+
const normalized = _normalized.value;
|
| 905 |
+
const parseStr = (key) => {
|
| 906 |
+
const k = util.esc(key);
|
| 907 |
+
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
| 908 |
+
};
|
| 909 |
+
doc.write(`const input = payload.value;`);
|
| 910 |
+
const ids = Object.create(null);
|
| 911 |
+
let counter = 0;
|
| 912 |
+
for (const key of normalized.keys) {
|
| 913 |
+
ids[key] = `key_${counter++}`;
|
| 914 |
+
}
|
| 915 |
+
// A: preserve key order {
|
| 916 |
+
doc.write(`const newResult = {};`);
|
| 917 |
+
for (const key of normalized.keys) {
|
| 918 |
+
const id = ids[key];
|
| 919 |
+
const k = util.esc(key);
|
| 920 |
+
const schema = shape[key];
|
| 921 |
+
const isOptionalIn = schema?._zod?.optin === "optional";
|
| 922 |
+
const isOptionalOut = schema?._zod?.optout === "optional";
|
| 923 |
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
| 924 |
+
if (isOptionalIn && isOptionalOut) {
|
| 925 |
+
// For optional-in/out schemas, ignore errors on absent keys
|
| 926 |
+
doc.write(`
|
| 927 |
+
if (${id}.issues.length) {
|
| 928 |
+
if (${k} in input) {
|
| 929 |
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
| 930 |
+
...iss,
|
| 931 |
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
| 932 |
+
})));
|
| 933 |
+
}
|
| 934 |
+
}
|
| 935 |
+
|
| 936 |
+
if (${id}.value === undefined) {
|
| 937 |
+
if (${k} in input) {
|
| 938 |
+
newResult[${k}] = undefined;
|
| 939 |
+
}
|
| 940 |
+
} else {
|
| 941 |
+
newResult[${k}] = ${id}.value;
|
| 942 |
+
}
|
| 943 |
+
|
| 944 |
+
`);
|
| 945 |
+
}
|
| 946 |
+
else if (!isOptionalIn) {
|
| 947 |
+
doc.write(`
|
| 948 |
+
const ${id}_present = ${k} in input;
|
| 949 |
+
if (${id}.issues.length) {
|
| 950 |
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
| 951 |
+
...iss,
|
| 952 |
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
| 953 |
+
})));
|
| 954 |
+
}
|
| 955 |
+
if (!${id}_present && !${id}.issues.length) {
|
| 956 |
+
payload.issues.push({
|
| 957 |
+
code: "invalid_type",
|
| 958 |
+
expected: "nonoptional",
|
| 959 |
+
input: undefined,
|
| 960 |
+
path: [${k}]
|
| 961 |
+
});
|
| 962 |
+
}
|
| 963 |
+
|
| 964 |
+
if (${id}_present) {
|
| 965 |
+
if (${id}.value === undefined) {
|
| 966 |
+
newResult[${k}] = undefined;
|
| 967 |
+
} else {
|
| 968 |
+
newResult[${k}] = ${id}.value;
|
| 969 |
+
}
|
| 970 |
+
}
|
| 971 |
+
|
| 972 |
+
`);
|
| 973 |
+
}
|
| 974 |
+
else {
|
| 975 |
+
doc.write(`
|
| 976 |
+
if (${id}.issues.length) {
|
| 977 |
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
| 978 |
+
...iss,
|
| 979 |
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
| 980 |
+
})));
|
| 981 |
+
}
|
| 982 |
+
|
| 983 |
+
if (${id}.value === undefined) {
|
| 984 |
+
if (${k} in input) {
|
| 985 |
+
newResult[${k}] = undefined;
|
| 986 |
+
}
|
| 987 |
+
} else {
|
| 988 |
+
newResult[${k}] = ${id}.value;
|
| 989 |
+
}
|
| 990 |
+
|
| 991 |
+
`);
|
| 992 |
+
}
|
| 993 |
+
}
|
| 994 |
+
doc.write(`payload.value = newResult;`);
|
| 995 |
+
doc.write(`return payload;`);
|
| 996 |
+
const fn = doc.compile();
|
| 997 |
+
return (payload, ctx) => fn(shape, payload, ctx);
|
| 998 |
+
};
|
| 999 |
+
let fastpass;
|
| 1000 |
+
const isObject = util.isObject;
|
| 1001 |
+
const jit = !core.globalConfig.jitless;
|
| 1002 |
+
const allowsEval = util.allowsEval;
|
| 1003 |
+
const fastEnabled = jit && allowsEval.value; // && !def.catchall;
|
| 1004 |
+
const catchall = def.catchall;
|
| 1005 |
+
let value;
|
| 1006 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1007 |
+
value ?? (value = _normalized.value);
|
| 1008 |
+
const input = payload.value;
|
| 1009 |
+
if (!isObject(input)) {
|
| 1010 |
+
payload.issues.push({
|
| 1011 |
+
expected: "object",
|
| 1012 |
+
code: "invalid_type",
|
| 1013 |
+
input,
|
| 1014 |
+
inst,
|
| 1015 |
+
});
|
| 1016 |
+
return payload;
|
| 1017 |
+
}
|
| 1018 |
+
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
| 1019 |
+
// always synchronous
|
| 1020 |
+
if (!fastpass)
|
| 1021 |
+
fastpass = generateFastpass(def.shape);
|
| 1022 |
+
payload = fastpass(payload, ctx);
|
| 1023 |
+
if (!catchall)
|
| 1024 |
+
return payload;
|
| 1025 |
+
return handleCatchall([], input, payload, ctx, value, inst);
|
| 1026 |
+
}
|
| 1027 |
+
return superParse(payload, ctx);
|
| 1028 |
+
};
|
| 1029 |
+
});
|
| 1030 |
+
function handleUnionResults(results, final, inst, ctx) {
|
| 1031 |
+
for (const result of results) {
|
| 1032 |
+
if (result.issues.length === 0) {
|
| 1033 |
+
final.value = result.value;
|
| 1034 |
+
return final;
|
| 1035 |
+
}
|
| 1036 |
+
}
|
| 1037 |
+
const nonaborted = results.filter((r) => !util.aborted(r));
|
| 1038 |
+
if (nonaborted.length === 1) {
|
| 1039 |
+
final.value = nonaborted[0].value;
|
| 1040 |
+
return nonaborted[0];
|
| 1041 |
+
}
|
| 1042 |
+
final.issues.push({
|
| 1043 |
+
code: "invalid_union",
|
| 1044 |
+
input: final.value,
|
| 1045 |
+
inst,
|
| 1046 |
+
errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
|
| 1047 |
+
});
|
| 1048 |
+
return final;
|
| 1049 |
+
}
|
| 1050 |
+
exports.$ZodUnion = core.$constructor("$ZodUnion", (inst, def) => {
|
| 1051 |
+
exports.$ZodType.init(inst, def);
|
| 1052 |
+
util.defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
|
| 1053 |
+
util.defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
| 1054 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1055 |
+
if (def.options.every((o) => o._zod.values)) {
|
| 1056 |
+
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
| 1057 |
+
}
|
| 1058 |
+
return undefined;
|
| 1059 |
+
});
|
| 1060 |
+
util.defineLazy(inst._zod, "pattern", () => {
|
| 1061 |
+
if (def.options.every((o) => o._zod.pattern)) {
|
| 1062 |
+
const patterns = def.options.map((o) => o._zod.pattern);
|
| 1063 |
+
return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
|
| 1064 |
+
}
|
| 1065 |
+
return undefined;
|
| 1066 |
+
});
|
| 1067 |
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
| 1068 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1069 |
+
if (first) {
|
| 1070 |
+
return first(payload, ctx);
|
| 1071 |
+
}
|
| 1072 |
+
let async = false;
|
| 1073 |
+
const results = [];
|
| 1074 |
+
for (const option of def.options) {
|
| 1075 |
+
const result = option._zod.run({
|
| 1076 |
+
value: payload.value,
|
| 1077 |
+
issues: [],
|
| 1078 |
+
}, ctx);
|
| 1079 |
+
if (result instanceof Promise) {
|
| 1080 |
+
results.push(result);
|
| 1081 |
+
async = true;
|
| 1082 |
+
}
|
| 1083 |
+
else {
|
| 1084 |
+
if (result.issues.length === 0)
|
| 1085 |
+
return result;
|
| 1086 |
+
results.push(result);
|
| 1087 |
+
}
|
| 1088 |
+
}
|
| 1089 |
+
if (!async)
|
| 1090 |
+
return handleUnionResults(results, payload, inst, ctx);
|
| 1091 |
+
return Promise.all(results).then((results) => {
|
| 1092 |
+
return handleUnionResults(results, payload, inst, ctx);
|
| 1093 |
+
});
|
| 1094 |
+
};
|
| 1095 |
+
});
|
| 1096 |
+
function handleExclusiveUnionResults(results, final, inst, ctx) {
|
| 1097 |
+
const successes = results.filter((r) => r.issues.length === 0);
|
| 1098 |
+
if (successes.length === 1) {
|
| 1099 |
+
final.value = successes[0].value;
|
| 1100 |
+
return final;
|
| 1101 |
+
}
|
| 1102 |
+
if (successes.length === 0) {
|
| 1103 |
+
// No matches - same as regular union
|
| 1104 |
+
final.issues.push({
|
| 1105 |
+
code: "invalid_union",
|
| 1106 |
+
input: final.value,
|
| 1107 |
+
inst,
|
| 1108 |
+
errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
|
| 1109 |
+
});
|
| 1110 |
+
}
|
| 1111 |
+
else {
|
| 1112 |
+
// Multiple matches - exclusive union failure
|
| 1113 |
+
final.issues.push({
|
| 1114 |
+
code: "invalid_union",
|
| 1115 |
+
input: final.value,
|
| 1116 |
+
inst,
|
| 1117 |
+
errors: [],
|
| 1118 |
+
inclusive: false,
|
| 1119 |
+
});
|
| 1120 |
+
}
|
| 1121 |
+
return final;
|
| 1122 |
+
}
|
| 1123 |
+
exports.$ZodXor = core.$constructor("$ZodXor", (inst, def) => {
|
| 1124 |
+
exports.$ZodUnion.init(inst, def);
|
| 1125 |
+
def.inclusive = false;
|
| 1126 |
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
| 1127 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1128 |
+
if (first) {
|
| 1129 |
+
return first(payload, ctx);
|
| 1130 |
+
}
|
| 1131 |
+
let async = false;
|
| 1132 |
+
const results = [];
|
| 1133 |
+
for (const option of def.options) {
|
| 1134 |
+
const result = option._zod.run({
|
| 1135 |
+
value: payload.value,
|
| 1136 |
+
issues: [],
|
| 1137 |
+
}, ctx);
|
| 1138 |
+
if (result instanceof Promise) {
|
| 1139 |
+
results.push(result);
|
| 1140 |
+
async = true;
|
| 1141 |
+
}
|
| 1142 |
+
else {
|
| 1143 |
+
results.push(result);
|
| 1144 |
+
}
|
| 1145 |
+
}
|
| 1146 |
+
if (!async)
|
| 1147 |
+
return handleExclusiveUnionResults(results, payload, inst, ctx);
|
| 1148 |
+
return Promise.all(results).then((results) => {
|
| 1149 |
+
return handleExclusiveUnionResults(results, payload, inst, ctx);
|
| 1150 |
+
});
|
| 1151 |
+
};
|
| 1152 |
+
});
|
| 1153 |
+
exports.$ZodDiscriminatedUnion =
|
| 1154 |
+
/*@__PURE__*/
|
| 1155 |
+
core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
| 1156 |
+
def.inclusive = false;
|
| 1157 |
+
exports.$ZodUnion.init(inst, def);
|
| 1158 |
+
const _super = inst._zod.parse;
|
| 1159 |
+
util.defineLazy(inst._zod, "propValues", () => {
|
| 1160 |
+
const propValues = {};
|
| 1161 |
+
for (const option of def.options) {
|
| 1162 |
+
const pv = option._zod.propValues;
|
| 1163 |
+
if (!pv || Object.keys(pv).length === 0)
|
| 1164 |
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
| 1165 |
+
for (const [k, v] of Object.entries(pv)) {
|
| 1166 |
+
if (!propValues[k])
|
| 1167 |
+
propValues[k] = new Set();
|
| 1168 |
+
for (const val of v) {
|
| 1169 |
+
propValues[k].add(val);
|
| 1170 |
+
}
|
| 1171 |
+
}
|
| 1172 |
+
}
|
| 1173 |
+
return propValues;
|
| 1174 |
+
});
|
| 1175 |
+
const disc = util.cached(() => {
|
| 1176 |
+
const opts = def.options;
|
| 1177 |
+
const map = new Map();
|
| 1178 |
+
for (const o of opts) {
|
| 1179 |
+
const values = o._zod.propValues?.[def.discriminator];
|
| 1180 |
+
if (!values || values.size === 0)
|
| 1181 |
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
| 1182 |
+
for (const v of values) {
|
| 1183 |
+
if (map.has(v)) {
|
| 1184 |
+
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
| 1185 |
+
}
|
| 1186 |
+
map.set(v, o);
|
| 1187 |
+
}
|
| 1188 |
+
}
|
| 1189 |
+
return map;
|
| 1190 |
+
});
|
| 1191 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1192 |
+
const input = payload.value;
|
| 1193 |
+
if (!util.isObject(input)) {
|
| 1194 |
+
payload.issues.push({
|
| 1195 |
+
code: "invalid_type",
|
| 1196 |
+
expected: "object",
|
| 1197 |
+
input,
|
| 1198 |
+
inst,
|
| 1199 |
+
});
|
| 1200 |
+
return payload;
|
| 1201 |
+
}
|
| 1202 |
+
const opt = disc.value.get(input?.[def.discriminator]);
|
| 1203 |
+
if (opt) {
|
| 1204 |
+
return opt._zod.run(payload, ctx);
|
| 1205 |
+
}
|
| 1206 |
+
// Fall back to union matching when the fast discriminator path fails:
|
| 1207 |
+
// - explicitly enabled via unionFallback, or
|
| 1208 |
+
// - during backward direction (encode), since codec-based discriminators
|
| 1209 |
+
// have different values in forward vs backward directions
|
| 1210 |
+
if (def.unionFallback || ctx.direction === "backward") {
|
| 1211 |
+
return _super(payload, ctx);
|
| 1212 |
+
}
|
| 1213 |
+
// no matching discriminator
|
| 1214 |
+
payload.issues.push({
|
| 1215 |
+
code: "invalid_union",
|
| 1216 |
+
errors: [],
|
| 1217 |
+
note: "No matching discriminator",
|
| 1218 |
+
discriminator: def.discriminator,
|
| 1219 |
+
options: Array.from(disc.value.keys()),
|
| 1220 |
+
input,
|
| 1221 |
+
path: [def.discriminator],
|
| 1222 |
+
inst,
|
| 1223 |
+
});
|
| 1224 |
+
return payload;
|
| 1225 |
+
};
|
| 1226 |
+
});
|
| 1227 |
+
exports.$ZodIntersection = core.$constructor("$ZodIntersection", (inst, def) => {
|
| 1228 |
+
exports.$ZodType.init(inst, def);
|
| 1229 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1230 |
+
const input = payload.value;
|
| 1231 |
+
const left = def.left._zod.run({ value: input, issues: [] }, ctx);
|
| 1232 |
+
const right = def.right._zod.run({ value: input, issues: [] }, ctx);
|
| 1233 |
+
const async = left instanceof Promise || right instanceof Promise;
|
| 1234 |
+
if (async) {
|
| 1235 |
+
return Promise.all([left, right]).then(([left, right]) => {
|
| 1236 |
+
return handleIntersectionResults(payload, left, right);
|
| 1237 |
+
});
|
| 1238 |
+
}
|
| 1239 |
+
return handleIntersectionResults(payload, left, right);
|
| 1240 |
+
};
|
| 1241 |
+
});
|
| 1242 |
+
function mergeValues(a, b) {
|
| 1243 |
+
// const aType = parse.t(a);
|
| 1244 |
+
// const bType = parse.t(b);
|
| 1245 |
+
if (a === b) {
|
| 1246 |
+
return { valid: true, data: a };
|
| 1247 |
+
}
|
| 1248 |
+
if (a instanceof Date && b instanceof Date && +a === +b) {
|
| 1249 |
+
return { valid: true, data: a };
|
| 1250 |
+
}
|
| 1251 |
+
if (util.isPlainObject(a) && util.isPlainObject(b)) {
|
| 1252 |
+
const bKeys = Object.keys(b);
|
| 1253 |
+
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
| 1254 |
+
const newObj = { ...a, ...b };
|
| 1255 |
+
for (const key of sharedKeys) {
|
| 1256 |
+
const sharedValue = mergeValues(a[key], b[key]);
|
| 1257 |
+
if (!sharedValue.valid) {
|
| 1258 |
+
return {
|
| 1259 |
+
valid: false,
|
| 1260 |
+
mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
|
| 1261 |
+
};
|
| 1262 |
+
}
|
| 1263 |
+
newObj[key] = sharedValue.data;
|
| 1264 |
+
}
|
| 1265 |
+
return { valid: true, data: newObj };
|
| 1266 |
+
}
|
| 1267 |
+
if (Array.isArray(a) && Array.isArray(b)) {
|
| 1268 |
+
if (a.length !== b.length) {
|
| 1269 |
+
return { valid: false, mergeErrorPath: [] };
|
| 1270 |
+
}
|
| 1271 |
+
const newArray = [];
|
| 1272 |
+
for (let index = 0; index < a.length; index++) {
|
| 1273 |
+
const itemA = a[index];
|
| 1274 |
+
const itemB = b[index];
|
| 1275 |
+
const sharedValue = mergeValues(itemA, itemB);
|
| 1276 |
+
if (!sharedValue.valid) {
|
| 1277 |
+
return {
|
| 1278 |
+
valid: false,
|
| 1279 |
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
|
| 1280 |
+
};
|
| 1281 |
+
}
|
| 1282 |
+
newArray.push(sharedValue.data);
|
| 1283 |
+
}
|
| 1284 |
+
return { valid: true, data: newArray };
|
| 1285 |
+
}
|
| 1286 |
+
return { valid: false, mergeErrorPath: [] };
|
| 1287 |
+
}
|
| 1288 |
+
function handleIntersectionResults(result, left, right) {
|
| 1289 |
+
// Track which side(s) report each key as unrecognized
|
| 1290 |
+
const unrecKeys = new Map();
|
| 1291 |
+
let unrecIssue;
|
| 1292 |
+
for (const iss of left.issues) {
|
| 1293 |
+
if (iss.code === "unrecognized_keys") {
|
| 1294 |
+
unrecIssue ?? (unrecIssue = iss);
|
| 1295 |
+
for (const k of iss.keys) {
|
| 1296 |
+
if (!unrecKeys.has(k))
|
| 1297 |
+
unrecKeys.set(k, {});
|
| 1298 |
+
unrecKeys.get(k).l = true;
|
| 1299 |
+
}
|
| 1300 |
+
}
|
| 1301 |
+
else {
|
| 1302 |
+
result.issues.push(iss);
|
| 1303 |
+
}
|
| 1304 |
+
}
|
| 1305 |
+
for (const iss of right.issues) {
|
| 1306 |
+
if (iss.code === "unrecognized_keys") {
|
| 1307 |
+
for (const k of iss.keys) {
|
| 1308 |
+
if (!unrecKeys.has(k))
|
| 1309 |
+
unrecKeys.set(k, {});
|
| 1310 |
+
unrecKeys.get(k).r = true;
|
| 1311 |
+
}
|
| 1312 |
+
}
|
| 1313 |
+
else {
|
| 1314 |
+
result.issues.push(iss);
|
| 1315 |
+
}
|
| 1316 |
+
}
|
| 1317 |
+
// Report only keys unrecognized by BOTH sides
|
| 1318 |
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
| 1319 |
+
if (bothKeys.length && unrecIssue) {
|
| 1320 |
+
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
| 1321 |
+
}
|
| 1322 |
+
if (util.aborted(result))
|
| 1323 |
+
return result;
|
| 1324 |
+
const merged = mergeValues(left.value, right.value);
|
| 1325 |
+
if (!merged.valid) {
|
| 1326 |
+
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
| 1327 |
+
}
|
| 1328 |
+
result.value = merged.data;
|
| 1329 |
+
return result;
|
| 1330 |
+
}
|
| 1331 |
+
exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => {
|
| 1332 |
+
exports.$ZodType.init(inst, def);
|
| 1333 |
+
const items = def.items;
|
| 1334 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1335 |
+
const input = payload.value;
|
| 1336 |
+
if (!Array.isArray(input)) {
|
| 1337 |
+
payload.issues.push({
|
| 1338 |
+
input,
|
| 1339 |
+
inst,
|
| 1340 |
+
expected: "tuple",
|
| 1341 |
+
code: "invalid_type",
|
| 1342 |
+
});
|
| 1343 |
+
return payload;
|
| 1344 |
+
}
|
| 1345 |
+
payload.value = [];
|
| 1346 |
+
const proms = [];
|
| 1347 |
+
const optinStart = getTupleOptStart(items, "optin");
|
| 1348 |
+
const optoutStart = getTupleOptStart(items, "optout");
|
| 1349 |
+
if (!def.rest) {
|
| 1350 |
+
if (input.length < optinStart) {
|
| 1351 |
+
payload.issues.push({
|
| 1352 |
+
code: "too_small",
|
| 1353 |
+
minimum: optinStart,
|
| 1354 |
+
inclusive: true,
|
| 1355 |
+
input,
|
| 1356 |
+
inst,
|
| 1357 |
+
origin: "array",
|
| 1358 |
+
});
|
| 1359 |
+
return payload;
|
| 1360 |
+
}
|
| 1361 |
+
if (input.length > items.length) {
|
| 1362 |
+
payload.issues.push({
|
| 1363 |
+
code: "too_big",
|
| 1364 |
+
maximum: items.length,
|
| 1365 |
+
inclusive: true,
|
| 1366 |
+
input,
|
| 1367 |
+
inst,
|
| 1368 |
+
origin: "array",
|
| 1369 |
+
});
|
| 1370 |
+
}
|
| 1371 |
+
}
|
| 1372 |
+
// Run every item in parallel, collecting results into an indexed
|
| 1373 |
+
// array. The post-processing in `handleTupleResults` walks them in
|
| 1374 |
+
// order so it can decide whether an absent optional-output error can
|
| 1375 |
+
// truncate the tail or must be reported to preserve required output.
|
| 1376 |
+
const itemResults = new Array(items.length);
|
| 1377 |
+
for (let i = 0; i < items.length; i++) {
|
| 1378 |
+
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
| 1379 |
+
if (r instanceof Promise) {
|
| 1380 |
+
proms.push(r.then((rr) => {
|
| 1381 |
+
itemResults[i] = rr;
|
| 1382 |
+
}));
|
| 1383 |
+
}
|
| 1384 |
+
else {
|
| 1385 |
+
itemResults[i] = r;
|
| 1386 |
+
}
|
| 1387 |
+
}
|
| 1388 |
+
if (def.rest) {
|
| 1389 |
+
let i = items.length - 1;
|
| 1390 |
+
const rest = input.slice(items.length);
|
| 1391 |
+
for (const el of rest) {
|
| 1392 |
+
i++;
|
| 1393 |
+
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
| 1394 |
+
if (result instanceof Promise) {
|
| 1395 |
+
proms.push(result.then((r) => handleTupleResult(r, payload, i)));
|
| 1396 |
+
}
|
| 1397 |
+
else {
|
| 1398 |
+
handleTupleResult(result, payload, i);
|
| 1399 |
+
}
|
| 1400 |
+
}
|
| 1401 |
+
}
|
| 1402 |
+
if (proms.length) {
|
| 1403 |
+
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
|
| 1404 |
+
}
|
| 1405 |
+
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
| 1406 |
+
};
|
| 1407 |
+
});
|
| 1408 |
+
function getTupleOptStart(items, key) {
|
| 1409 |
+
for (let i = items.length - 1; i >= 0; i--) {
|
| 1410 |
+
if (items[i]._zod[key] !== "optional")
|
| 1411 |
+
return i + 1;
|
| 1412 |
+
}
|
| 1413 |
+
return 0;
|
| 1414 |
+
}
|
| 1415 |
+
function handleTupleResult(result, final, index) {
|
| 1416 |
+
if (result.issues.length) {
|
| 1417 |
+
final.issues.push(...util.prefixIssues(index, result.issues));
|
| 1418 |
+
}
|
| 1419 |
+
final.value[index] = result.value;
|
| 1420 |
+
}
|
| 1421 |
+
function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
| 1422 |
+
// Walk results in order. Mirror $ZodObject's swallow-on-absent-optional
|
| 1423 |
+
// rule, but only after `optoutStart`: the first index where the output
|
| 1424 |
+
// tuple tail can be absent.
|
| 1425 |
+
for (let i = 0; i < items.length; i++) {
|
| 1426 |
+
const r = itemResults[i];
|
| 1427 |
+
const isPresent = i < input.length;
|
| 1428 |
+
if (r.issues.length) {
|
| 1429 |
+
if (!isPresent && i >= optoutStart) {
|
| 1430 |
+
final.value.length = i;
|
| 1431 |
+
break;
|
| 1432 |
+
}
|
| 1433 |
+
final.issues.push(...util.prefixIssues(i, r.issues));
|
| 1434 |
+
}
|
| 1435 |
+
final.value[i] = r.value;
|
| 1436 |
+
}
|
| 1437 |
+
// Drop trailing slots that produced `undefined` for absent input
|
| 1438 |
+
// (the array analog of an absent optional key on an object). The
|
| 1439 |
+
// `i >= input.length` floor is critical: an explicit `undefined`
|
| 1440 |
+
// *inside* the input must be preserved even when the schema is
|
| 1441 |
+
// optional-out (e.g. `z.string().or(z.undefined())` accepting an
|
| 1442 |
+
// explicit undefined value).
|
| 1443 |
+
for (let i = final.value.length - 1; i >= input.length; i--) {
|
| 1444 |
+
if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
|
| 1445 |
+
final.value.length = i;
|
| 1446 |
+
}
|
| 1447 |
+
else {
|
| 1448 |
+
break;
|
| 1449 |
+
}
|
| 1450 |
+
}
|
| 1451 |
+
return final;
|
| 1452 |
+
}
|
| 1453 |
+
exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
|
| 1454 |
+
exports.$ZodType.init(inst, def);
|
| 1455 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1456 |
+
const input = payload.value;
|
| 1457 |
+
if (!util.isPlainObject(input)) {
|
| 1458 |
+
payload.issues.push({
|
| 1459 |
+
expected: "record",
|
| 1460 |
+
code: "invalid_type",
|
| 1461 |
+
input,
|
| 1462 |
+
inst,
|
| 1463 |
+
});
|
| 1464 |
+
return payload;
|
| 1465 |
+
}
|
| 1466 |
+
const proms = [];
|
| 1467 |
+
const values = def.keyType._zod.values;
|
| 1468 |
+
if (values) {
|
| 1469 |
+
payload.value = {};
|
| 1470 |
+
const recordKeys = new Set();
|
| 1471 |
+
for (const key of values) {
|
| 1472 |
+
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
| 1473 |
+
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
| 1474 |
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
| 1475 |
+
if (keyResult instanceof Promise) {
|
| 1476 |
+
throw new Error("Async schemas not supported in object keys currently");
|
| 1477 |
+
}
|
| 1478 |
+
if (keyResult.issues.length) {
|
| 1479 |
+
payload.issues.push({
|
| 1480 |
+
code: "invalid_key",
|
| 1481 |
+
origin: "record",
|
| 1482 |
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1483 |
+
input: key,
|
| 1484 |
+
path: [key],
|
| 1485 |
+
inst,
|
| 1486 |
+
});
|
| 1487 |
+
continue;
|
| 1488 |
+
}
|
| 1489 |
+
const outKey = keyResult.value;
|
| 1490 |
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
| 1491 |
+
if (result instanceof Promise) {
|
| 1492 |
+
proms.push(result.then((result) => {
|
| 1493 |
+
if (result.issues.length) {
|
| 1494 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1495 |
+
}
|
| 1496 |
+
payload.value[outKey] = result.value;
|
| 1497 |
+
}));
|
| 1498 |
+
}
|
| 1499 |
+
else {
|
| 1500 |
+
if (result.issues.length) {
|
| 1501 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1502 |
+
}
|
| 1503 |
+
payload.value[outKey] = result.value;
|
| 1504 |
+
}
|
| 1505 |
+
}
|
| 1506 |
+
}
|
| 1507 |
+
let unrecognized;
|
| 1508 |
+
for (const key in input) {
|
| 1509 |
+
if (!recordKeys.has(key)) {
|
| 1510 |
+
unrecognized = unrecognized ?? [];
|
| 1511 |
+
unrecognized.push(key);
|
| 1512 |
+
}
|
| 1513 |
+
}
|
| 1514 |
+
if (unrecognized && unrecognized.length > 0) {
|
| 1515 |
+
payload.issues.push({
|
| 1516 |
+
code: "unrecognized_keys",
|
| 1517 |
+
input,
|
| 1518 |
+
inst,
|
| 1519 |
+
keys: unrecognized,
|
| 1520 |
+
});
|
| 1521 |
+
}
|
| 1522 |
+
}
|
| 1523 |
+
else {
|
| 1524 |
+
payload.value = {};
|
| 1525 |
+
// Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
|
| 1526 |
+
for (const key of Reflect.ownKeys(input)) {
|
| 1527 |
+
if (key === "__proto__")
|
| 1528 |
+
continue;
|
| 1529 |
+
if (!Object.prototype.propertyIsEnumerable.call(input, key))
|
| 1530 |
+
continue;
|
| 1531 |
+
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
| 1532 |
+
if (keyResult instanceof Promise) {
|
| 1533 |
+
throw new Error("Async schemas not supported in object keys currently");
|
| 1534 |
+
}
|
| 1535 |
+
// Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
|
| 1536 |
+
// This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
|
| 1537 |
+
const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
|
| 1538 |
+
if (checkNumericKey) {
|
| 1539 |
+
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
| 1540 |
+
if (retryResult instanceof Promise) {
|
| 1541 |
+
throw new Error("Async schemas not supported in object keys currently");
|
| 1542 |
+
}
|
| 1543 |
+
if (retryResult.issues.length === 0) {
|
| 1544 |
+
keyResult = retryResult;
|
| 1545 |
+
}
|
| 1546 |
+
}
|
| 1547 |
+
if (keyResult.issues.length) {
|
| 1548 |
+
if (def.mode === "loose") {
|
| 1549 |
+
// Pass through unchanged
|
| 1550 |
+
payload.value[key] = input[key];
|
| 1551 |
+
}
|
| 1552 |
+
else {
|
| 1553 |
+
// Default "strict" behavior: error on invalid key
|
| 1554 |
+
payload.issues.push({
|
| 1555 |
+
code: "invalid_key",
|
| 1556 |
+
origin: "record",
|
| 1557 |
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1558 |
+
input: key,
|
| 1559 |
+
path: [key],
|
| 1560 |
+
inst,
|
| 1561 |
+
});
|
| 1562 |
+
}
|
| 1563 |
+
continue;
|
| 1564 |
+
}
|
| 1565 |
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
| 1566 |
+
if (result instanceof Promise) {
|
| 1567 |
+
proms.push(result.then((result) => {
|
| 1568 |
+
if (result.issues.length) {
|
| 1569 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1570 |
+
}
|
| 1571 |
+
payload.value[keyResult.value] = result.value;
|
| 1572 |
+
}));
|
| 1573 |
+
}
|
| 1574 |
+
else {
|
| 1575 |
+
if (result.issues.length) {
|
| 1576 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1577 |
+
}
|
| 1578 |
+
payload.value[keyResult.value] = result.value;
|
| 1579 |
+
}
|
| 1580 |
+
}
|
| 1581 |
+
}
|
| 1582 |
+
if (proms.length) {
|
| 1583 |
+
return Promise.all(proms).then(() => payload);
|
| 1584 |
+
}
|
| 1585 |
+
return payload;
|
| 1586 |
+
};
|
| 1587 |
+
});
|
| 1588 |
+
exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => {
|
| 1589 |
+
exports.$ZodType.init(inst, def);
|
| 1590 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1591 |
+
const input = payload.value;
|
| 1592 |
+
if (!(input instanceof Map)) {
|
| 1593 |
+
payload.issues.push({
|
| 1594 |
+
expected: "map",
|
| 1595 |
+
code: "invalid_type",
|
| 1596 |
+
input,
|
| 1597 |
+
inst,
|
| 1598 |
+
});
|
| 1599 |
+
return payload;
|
| 1600 |
+
}
|
| 1601 |
+
const proms = [];
|
| 1602 |
+
payload.value = new Map();
|
| 1603 |
+
for (const [key, value] of input) {
|
| 1604 |
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
| 1605 |
+
const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
|
| 1606 |
+
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
| 1607 |
+
proms.push(Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
|
| 1608 |
+
handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
|
| 1609 |
+
}));
|
| 1610 |
+
}
|
| 1611 |
+
else {
|
| 1612 |
+
handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
|
| 1613 |
+
}
|
| 1614 |
+
}
|
| 1615 |
+
if (proms.length)
|
| 1616 |
+
return Promise.all(proms).then(() => payload);
|
| 1617 |
+
return payload;
|
| 1618 |
+
};
|
| 1619 |
+
});
|
| 1620 |
+
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
| 1621 |
+
if (keyResult.issues.length) {
|
| 1622 |
+
if (util.propertyKeyTypes.has(typeof key)) {
|
| 1623 |
+
final.issues.push(...util.prefixIssues(key, keyResult.issues));
|
| 1624 |
+
}
|
| 1625 |
+
else {
|
| 1626 |
+
final.issues.push({
|
| 1627 |
+
code: "invalid_key",
|
| 1628 |
+
origin: "map",
|
| 1629 |
+
input,
|
| 1630 |
+
inst,
|
| 1631 |
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1632 |
+
});
|
| 1633 |
+
}
|
| 1634 |
+
}
|
| 1635 |
+
if (valueResult.issues.length) {
|
| 1636 |
+
if (util.propertyKeyTypes.has(typeof key)) {
|
| 1637 |
+
final.issues.push(...util.prefixIssues(key, valueResult.issues));
|
| 1638 |
+
}
|
| 1639 |
+
else {
|
| 1640 |
+
final.issues.push({
|
| 1641 |
+
origin: "map",
|
| 1642 |
+
code: "invalid_element",
|
| 1643 |
+
input,
|
| 1644 |
+
inst,
|
| 1645 |
+
key: key,
|
| 1646 |
+
issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1647 |
+
});
|
| 1648 |
+
}
|
| 1649 |
+
}
|
| 1650 |
+
final.value.set(keyResult.value, valueResult.value);
|
| 1651 |
+
}
|
| 1652 |
+
exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => {
|
| 1653 |
+
exports.$ZodType.init(inst, def);
|
| 1654 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1655 |
+
const input = payload.value;
|
| 1656 |
+
if (!(input instanceof Set)) {
|
| 1657 |
+
payload.issues.push({
|
| 1658 |
+
input,
|
| 1659 |
+
inst,
|
| 1660 |
+
expected: "set",
|
| 1661 |
+
code: "invalid_type",
|
| 1662 |
+
});
|
| 1663 |
+
return payload;
|
| 1664 |
+
}
|
| 1665 |
+
const proms = [];
|
| 1666 |
+
payload.value = new Set();
|
| 1667 |
+
for (const item of input) {
|
| 1668 |
+
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
| 1669 |
+
if (result instanceof Promise) {
|
| 1670 |
+
proms.push(result.then((result) => handleSetResult(result, payload)));
|
| 1671 |
+
}
|
| 1672 |
+
else
|
| 1673 |
+
handleSetResult(result, payload);
|
| 1674 |
+
}
|
| 1675 |
+
if (proms.length)
|
| 1676 |
+
return Promise.all(proms).then(() => payload);
|
| 1677 |
+
return payload;
|
| 1678 |
+
};
|
| 1679 |
+
});
|
| 1680 |
+
function handleSetResult(result, final) {
|
| 1681 |
+
if (result.issues.length) {
|
| 1682 |
+
final.issues.push(...result.issues);
|
| 1683 |
+
}
|
| 1684 |
+
final.value.add(result.value);
|
| 1685 |
+
}
|
| 1686 |
+
exports.$ZodEnum = core.$constructor("$ZodEnum", (inst, def) => {
|
| 1687 |
+
exports.$ZodType.init(inst, def);
|
| 1688 |
+
const values = util.getEnumValues(def.entries);
|
| 1689 |
+
const valuesSet = new Set(values);
|
| 1690 |
+
inst._zod.values = valuesSet;
|
| 1691 |
+
inst._zod.pattern = new RegExp(`^(${values
|
| 1692 |
+
.filter((k) => util.propertyKeyTypes.has(typeof k))
|
| 1693 |
+
.map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString()))
|
| 1694 |
+
.join("|")})$`);
|
| 1695 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1696 |
+
const input = payload.value;
|
| 1697 |
+
if (valuesSet.has(input)) {
|
| 1698 |
+
return payload;
|
| 1699 |
+
}
|
| 1700 |
+
payload.issues.push({
|
| 1701 |
+
code: "invalid_value",
|
| 1702 |
+
values,
|
| 1703 |
+
input,
|
| 1704 |
+
inst,
|
| 1705 |
+
});
|
| 1706 |
+
return payload;
|
| 1707 |
+
};
|
| 1708 |
+
});
|
| 1709 |
+
exports.$ZodLiteral = core.$constructor("$ZodLiteral", (inst, def) => {
|
| 1710 |
+
exports.$ZodType.init(inst, def);
|
| 1711 |
+
if (def.values.length === 0) {
|
| 1712 |
+
throw new Error("Cannot create literal schema with no valid values");
|
| 1713 |
+
}
|
| 1714 |
+
const values = new Set(def.values);
|
| 1715 |
+
inst._zod.values = values;
|
| 1716 |
+
inst._zod.pattern = new RegExp(`^(${def.values
|
| 1717 |
+
.map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)))
|
| 1718 |
+
.join("|")})$`);
|
| 1719 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1720 |
+
const input = payload.value;
|
| 1721 |
+
if (values.has(input)) {
|
| 1722 |
+
return payload;
|
| 1723 |
+
}
|
| 1724 |
+
payload.issues.push({
|
| 1725 |
+
code: "invalid_value",
|
| 1726 |
+
values: def.values,
|
| 1727 |
+
input,
|
| 1728 |
+
inst,
|
| 1729 |
+
});
|
| 1730 |
+
return payload;
|
| 1731 |
+
};
|
| 1732 |
+
});
|
| 1733 |
+
exports.$ZodFile = core.$constructor("$ZodFile", (inst, def) => {
|
| 1734 |
+
exports.$ZodType.init(inst, def);
|
| 1735 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1736 |
+
const input = payload.value;
|
| 1737 |
+
// @ts-ignore
|
| 1738 |
+
if (input instanceof File)
|
| 1739 |
+
return payload;
|
| 1740 |
+
payload.issues.push({
|
| 1741 |
+
expected: "file",
|
| 1742 |
+
code: "invalid_type",
|
| 1743 |
+
input,
|
| 1744 |
+
inst,
|
| 1745 |
+
});
|
| 1746 |
+
return payload;
|
| 1747 |
+
};
|
| 1748 |
+
});
|
| 1749 |
+
exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
|
| 1750 |
+
exports.$ZodType.init(inst, def);
|
| 1751 |
+
inst._zod.optin = "optional";
|
| 1752 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1753 |
+
if (ctx.direction === "backward") {
|
| 1754 |
+
throw new core.$ZodEncodeError(inst.constructor.name);
|
| 1755 |
+
}
|
| 1756 |
+
const _out = def.transform(payload.value, payload);
|
| 1757 |
+
if (ctx.async) {
|
| 1758 |
+
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
| 1759 |
+
return output.then((output) => {
|
| 1760 |
+
payload.value = output;
|
| 1761 |
+
payload.fallback = true;
|
| 1762 |
+
return payload;
|
| 1763 |
+
});
|
| 1764 |
+
}
|
| 1765 |
+
if (_out instanceof Promise) {
|
| 1766 |
+
throw new core.$ZodAsyncError();
|
| 1767 |
+
}
|
| 1768 |
+
payload.value = _out;
|
| 1769 |
+
payload.fallback = true;
|
| 1770 |
+
return payload;
|
| 1771 |
+
};
|
| 1772 |
+
});
|
| 1773 |
+
function handleOptionalResult(result, input) {
|
| 1774 |
+
if (input === undefined && (result.issues.length || result.fallback)) {
|
| 1775 |
+
return { issues: [], value: undefined };
|
| 1776 |
+
}
|
| 1777 |
+
return result;
|
| 1778 |
+
}
|
| 1779 |
+
exports.$ZodOptional = core.$constructor("$ZodOptional", (inst, def) => {
|
| 1780 |
+
exports.$ZodType.init(inst, def);
|
| 1781 |
+
inst._zod.optin = "optional";
|
| 1782 |
+
inst._zod.optout = "optional";
|
| 1783 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1784 |
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
|
| 1785 |
+
});
|
| 1786 |
+
util.defineLazy(inst._zod, "pattern", () => {
|
| 1787 |
+
const pattern = def.innerType._zod.pattern;
|
| 1788 |
+
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
|
| 1789 |
+
});
|
| 1790 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1791 |
+
if (def.innerType._zod.optin === "optional") {
|
| 1792 |
+
const input = payload.value;
|
| 1793 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1794 |
+
if (result instanceof Promise)
|
| 1795 |
+
return result.then((r) => handleOptionalResult(r, input));
|
| 1796 |
+
return handleOptionalResult(result, input);
|
| 1797 |
+
}
|
| 1798 |
+
if (payload.value === undefined) {
|
| 1799 |
+
return payload;
|
| 1800 |
+
}
|
| 1801 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1802 |
+
};
|
| 1803 |
+
});
|
| 1804 |
+
exports.$ZodExactOptional = core.$constructor("$ZodExactOptional", (inst, def) => {
|
| 1805 |
+
// Call parent init - inherits optin/optout = "optional"
|
| 1806 |
+
exports.$ZodOptional.init(inst, def);
|
| 1807 |
+
// Override values/pattern to NOT add undefined
|
| 1808 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1809 |
+
util.defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
| 1810 |
+
// Override parse to just delegate (no undefined handling)
|
| 1811 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1812 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1813 |
+
};
|
| 1814 |
+
});
|
| 1815 |
+
exports.$ZodNullable = core.$constructor("$ZodNullable", (inst, def) => {
|
| 1816 |
+
exports.$ZodType.init(inst, def);
|
| 1817 |
+
util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
| 1818 |
+
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
| 1819 |
+
util.defineLazy(inst._zod, "pattern", () => {
|
| 1820 |
+
const pattern = def.innerType._zod.pattern;
|
| 1821 |
+
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
|
| 1822 |
+
});
|
| 1823 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1824 |
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
| 1825 |
+
});
|
| 1826 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1827 |
+
// Forward direction (decode): allow null to pass through
|
| 1828 |
+
if (payload.value === null)
|
| 1829 |
+
return payload;
|
| 1830 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1831 |
+
};
|
| 1832 |
+
});
|
| 1833 |
+
exports.$ZodDefault = core.$constructor("$ZodDefault", (inst, def) => {
|
| 1834 |
+
exports.$ZodType.init(inst, def);
|
| 1835 |
+
// inst._zod.qin = "true";
|
| 1836 |
+
inst._zod.optin = "optional";
|
| 1837 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1838 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1839 |
+
if (ctx.direction === "backward") {
|
| 1840 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1841 |
+
}
|
| 1842 |
+
// Forward direction (decode): apply defaults for undefined input
|
| 1843 |
+
if (payload.value === undefined) {
|
| 1844 |
+
payload.value = def.defaultValue;
|
| 1845 |
+
/**
|
| 1846 |
+
* $ZodDefault returns the default value immediately in forward direction.
|
| 1847 |
+
* 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. */
|
| 1848 |
+
return payload;
|
| 1849 |
+
}
|
| 1850 |
+
// Forward direction: continue with default handling
|
| 1851 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1852 |
+
if (result instanceof Promise) {
|
| 1853 |
+
return result.then((result) => handleDefaultResult(result, def));
|
| 1854 |
+
}
|
| 1855 |
+
return handleDefaultResult(result, def);
|
| 1856 |
+
};
|
| 1857 |
+
});
|
| 1858 |
+
function handleDefaultResult(payload, def) {
|
| 1859 |
+
if (payload.value === undefined) {
|
| 1860 |
+
payload.value = def.defaultValue;
|
| 1861 |
+
}
|
| 1862 |
+
return payload;
|
| 1863 |
+
}
|
| 1864 |
+
exports.$ZodPrefault = core.$constructor("$ZodPrefault", (inst, def) => {
|
| 1865 |
+
exports.$ZodType.init(inst, def);
|
| 1866 |
+
inst._zod.optin = "optional";
|
| 1867 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1868 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1869 |
+
if (ctx.direction === "backward") {
|
| 1870 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1871 |
+
}
|
| 1872 |
+
// Forward direction (decode): apply prefault for undefined input
|
| 1873 |
+
if (payload.value === undefined) {
|
| 1874 |
+
payload.value = def.defaultValue;
|
| 1875 |
+
}
|
| 1876 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1877 |
+
};
|
| 1878 |
+
});
|
| 1879 |
+
exports.$ZodNonOptional = core.$constructor("$ZodNonOptional", (inst, def) => {
|
| 1880 |
+
exports.$ZodType.init(inst, def);
|
| 1881 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1882 |
+
const v = def.innerType._zod.values;
|
| 1883 |
+
return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
|
| 1884 |
+
});
|
| 1885 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1886 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1887 |
+
if (result instanceof Promise) {
|
| 1888 |
+
return result.then((result) => handleNonOptionalResult(result, inst));
|
| 1889 |
+
}
|
| 1890 |
+
return handleNonOptionalResult(result, inst);
|
| 1891 |
+
};
|
| 1892 |
+
});
|
| 1893 |
+
function handleNonOptionalResult(payload, inst) {
|
| 1894 |
+
if (!payload.issues.length && payload.value === undefined) {
|
| 1895 |
+
payload.issues.push({
|
| 1896 |
+
code: "invalid_type",
|
| 1897 |
+
expected: "nonoptional",
|
| 1898 |
+
input: payload.value,
|
| 1899 |
+
inst,
|
| 1900 |
+
});
|
| 1901 |
+
}
|
| 1902 |
+
return payload;
|
| 1903 |
+
}
|
| 1904 |
+
exports.$ZodSuccess = core.$constructor("$ZodSuccess", (inst, def) => {
|
| 1905 |
+
exports.$ZodType.init(inst, def);
|
| 1906 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1907 |
+
if (ctx.direction === "backward") {
|
| 1908 |
+
throw new core.$ZodEncodeError("ZodSuccess");
|
| 1909 |
+
}
|
| 1910 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1911 |
+
if (result instanceof Promise) {
|
| 1912 |
+
return result.then((result) => {
|
| 1913 |
+
payload.value = result.issues.length === 0;
|
| 1914 |
+
return payload;
|
| 1915 |
+
});
|
| 1916 |
+
}
|
| 1917 |
+
payload.value = result.issues.length === 0;
|
| 1918 |
+
return payload;
|
| 1919 |
+
};
|
| 1920 |
+
});
|
| 1921 |
+
exports.$ZodCatch = core.$constructor("$ZodCatch", (inst, def) => {
|
| 1922 |
+
exports.$ZodType.init(inst, def);
|
| 1923 |
+
inst._zod.optin = "optional";
|
| 1924 |
+
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
| 1925 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1926 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1927 |
+
if (ctx.direction === "backward") {
|
| 1928 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1929 |
+
}
|
| 1930 |
+
// Forward direction (decode): apply catch logic
|
| 1931 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1932 |
+
if (result instanceof Promise) {
|
| 1933 |
+
return result.then((result) => {
|
| 1934 |
+
payload.value = result.value;
|
| 1935 |
+
if (result.issues.length) {
|
| 1936 |
+
payload.value = def.catchValue({
|
| 1937 |
+
...payload,
|
| 1938 |
+
error: {
|
| 1939 |
+
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1940 |
+
},
|
| 1941 |
+
input: payload.value,
|
| 1942 |
+
});
|
| 1943 |
+
payload.issues = [];
|
| 1944 |
+
payload.fallback = true;
|
| 1945 |
+
}
|
| 1946 |
+
return payload;
|
| 1947 |
+
});
|
| 1948 |
+
}
|
| 1949 |
+
payload.value = result.value;
|
| 1950 |
+
if (result.issues.length) {
|
| 1951 |
+
payload.value = def.catchValue({
|
| 1952 |
+
...payload,
|
| 1953 |
+
error: {
|
| 1954 |
+
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1955 |
+
},
|
| 1956 |
+
input: payload.value,
|
| 1957 |
+
});
|
| 1958 |
+
payload.issues = [];
|
| 1959 |
+
payload.fallback = true;
|
| 1960 |
+
}
|
| 1961 |
+
return payload;
|
| 1962 |
+
};
|
| 1963 |
+
});
|
| 1964 |
+
exports.$ZodNaN = core.$constructor("$ZodNaN", (inst, def) => {
|
| 1965 |
+
exports.$ZodType.init(inst, def);
|
| 1966 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1967 |
+
if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
|
| 1968 |
+
payload.issues.push({
|
| 1969 |
+
input: payload.value,
|
| 1970 |
+
inst,
|
| 1971 |
+
expected: "nan",
|
| 1972 |
+
code: "invalid_type",
|
| 1973 |
+
});
|
| 1974 |
+
return payload;
|
| 1975 |
+
}
|
| 1976 |
+
return payload;
|
| 1977 |
+
};
|
| 1978 |
+
});
|
| 1979 |
+
exports.$ZodPipe = core.$constructor("$ZodPipe", (inst, def) => {
|
| 1980 |
+
exports.$ZodType.init(inst, def);
|
| 1981 |
+
util.defineLazy(inst._zod, "values", () => def.in._zod.values);
|
| 1982 |
+
util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
| 1983 |
+
util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
| 1984 |
+
util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
| 1985 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1986 |
+
if (ctx.direction === "backward") {
|
| 1987 |
+
const right = def.out._zod.run(payload, ctx);
|
| 1988 |
+
if (right instanceof Promise) {
|
| 1989 |
+
return right.then((right) => handlePipeResult(right, def.in, ctx));
|
| 1990 |
+
}
|
| 1991 |
+
return handlePipeResult(right, def.in, ctx);
|
| 1992 |
+
}
|
| 1993 |
+
const left = def.in._zod.run(payload, ctx);
|
| 1994 |
+
if (left instanceof Promise) {
|
| 1995 |
+
return left.then((left) => handlePipeResult(left, def.out, ctx));
|
| 1996 |
+
}
|
| 1997 |
+
return handlePipeResult(left, def.out, ctx);
|
| 1998 |
+
};
|
| 1999 |
+
});
|
| 2000 |
+
function handlePipeResult(left, next, ctx) {
|
| 2001 |
+
if (left.issues.length) {
|
| 2002 |
+
// prevent further checks
|
| 2003 |
+
left.aborted = true;
|
| 2004 |
+
return left;
|
| 2005 |
+
}
|
| 2006 |
+
return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx);
|
| 2007 |
+
}
|
| 2008 |
+
exports.$ZodCodec = core.$constructor("$ZodCodec", (inst, def) => {
|
| 2009 |
+
exports.$ZodType.init(inst, def);
|
| 2010 |
+
util.defineLazy(inst._zod, "values", () => def.in._zod.values);
|
| 2011 |
+
util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
| 2012 |
+
util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
| 2013 |
+
util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
| 2014 |
+
inst._zod.parse = (payload, ctx) => {
|
| 2015 |
+
const direction = ctx.direction || "forward";
|
| 2016 |
+
if (direction === "forward") {
|
| 2017 |
+
const left = def.in._zod.run(payload, ctx);
|
| 2018 |
+
if (left instanceof Promise) {
|
| 2019 |
+
return left.then((left) => handleCodecAResult(left, def, ctx));
|
| 2020 |
+
}
|
| 2021 |
+
return handleCodecAResult(left, def, ctx);
|
| 2022 |
+
}
|
| 2023 |
+
else {
|
| 2024 |
+
const right = def.out._zod.run(payload, ctx);
|
| 2025 |
+
if (right instanceof Promise) {
|
| 2026 |
+
return right.then((right) => handleCodecAResult(right, def, ctx));
|
| 2027 |
+
}
|
| 2028 |
+
return handleCodecAResult(right, def, ctx);
|
| 2029 |
+
}
|
| 2030 |
+
};
|
| 2031 |
+
});
|
| 2032 |
+
function handleCodecAResult(result, def, ctx) {
|
| 2033 |
+
if (result.issues.length) {
|
| 2034 |
+
// prevent further checks
|
| 2035 |
+
result.aborted = true;
|
| 2036 |
+
return result;
|
| 2037 |
+
}
|
| 2038 |
+
const direction = ctx.direction || "forward";
|
| 2039 |
+
if (direction === "forward") {
|
| 2040 |
+
const transformed = def.transform(result.value, result);
|
| 2041 |
+
if (transformed instanceof Promise) {
|
| 2042 |
+
return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx));
|
| 2043 |
+
}
|
| 2044 |
+
return handleCodecTxResult(result, transformed, def.out, ctx);
|
| 2045 |
+
}
|
| 2046 |
+
else {
|
| 2047 |
+
const transformed = def.reverseTransform(result.value, result);
|
| 2048 |
+
if (transformed instanceof Promise) {
|
| 2049 |
+
return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx));
|
| 2050 |
+
}
|
| 2051 |
+
return handleCodecTxResult(result, transformed, def.in, ctx);
|
| 2052 |
+
}
|
| 2053 |
+
}
|
| 2054 |
+
function handleCodecTxResult(left, value, nextSchema, ctx) {
|
| 2055 |
+
// Check if transform added any issues
|
| 2056 |
+
if (left.issues.length) {
|
| 2057 |
+
left.aborted = true;
|
| 2058 |
+
return left;
|
| 2059 |
+
}
|
| 2060 |
+
return nextSchema._zod.run({ value, issues: left.issues }, ctx);
|
| 2061 |
+
}
|
| 2062 |
+
exports.$ZodPreprocess = core.$constructor("$ZodPreprocess", (inst, def) => {
|
| 2063 |
+
exports.$ZodPipe.init(inst, def);
|
| 2064 |
+
});
|
| 2065 |
+
exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => {
|
| 2066 |
+
exports.$ZodType.init(inst, def);
|
| 2067 |
+
util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
| 2068 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 2069 |
+
util.defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
| 2070 |
+
util.defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
| 2071 |
+
inst._zod.parse = (payload, ctx) => {
|
| 2072 |
+
if (ctx.direction === "backward") {
|
| 2073 |
+
return def.innerType._zod.run(payload, ctx);
|
| 2074 |
+
}
|
| 2075 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 2076 |
+
if (result instanceof Promise) {
|
| 2077 |
+
return result.then(handleReadonlyResult);
|
| 2078 |
+
}
|
| 2079 |
+
return handleReadonlyResult(result);
|
| 2080 |
+
};
|
| 2081 |
+
});
|
| 2082 |
+
function handleReadonlyResult(payload) {
|
| 2083 |
+
payload.value = Object.freeze(payload.value);
|
| 2084 |
+
return payload;
|
| 2085 |
+
}
|
| 2086 |
+
exports.$ZodTemplateLiteral = core.$constructor("$ZodTemplateLiteral", (inst, def) => {
|
| 2087 |
+
exports.$ZodType.init(inst, def);
|
| 2088 |
+
const regexParts = [];
|
| 2089 |
+
for (const part of def.parts) {
|
| 2090 |
+
if (typeof part === "object" && part !== null) {
|
| 2091 |
+
// is Zod schema
|
| 2092 |
+
if (!part._zod.pattern) {
|
| 2093 |
+
// if (!source)
|
| 2094 |
+
throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
|
| 2095 |
+
}
|
| 2096 |
+
const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
|
| 2097 |
+
if (!source)
|
| 2098 |
+
throw new Error(`Invalid template literal part: ${part._zod.traits}`);
|
| 2099 |
+
const start = source.startsWith("^") ? 1 : 0;
|
| 2100 |
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
| 2101 |
+
regexParts.push(source.slice(start, end));
|
| 2102 |
+
}
|
| 2103 |
+
else if (part === null || util.primitiveTypes.has(typeof part)) {
|
| 2104 |
+
regexParts.push(util.escapeRegex(`${part}`));
|
| 2105 |
+
}
|
| 2106 |
+
else {
|
| 2107 |
+
throw new Error(`Invalid template literal part: ${part}`);
|
| 2108 |
+
}
|
| 2109 |
+
}
|
| 2110 |
+
inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
|
| 2111 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 2112 |
+
if (typeof payload.value !== "string") {
|
| 2113 |
+
payload.issues.push({
|
| 2114 |
+
input: payload.value,
|
| 2115 |
+
inst,
|
| 2116 |
+
expected: "string",
|
| 2117 |
+
code: "invalid_type",
|
| 2118 |
+
});
|
| 2119 |
+
return payload;
|
| 2120 |
+
}
|
| 2121 |
+
inst._zod.pattern.lastIndex = 0;
|
| 2122 |
+
if (!inst._zod.pattern.test(payload.value)) {
|
| 2123 |
+
payload.issues.push({
|
| 2124 |
+
input: payload.value,
|
| 2125 |
+
inst,
|
| 2126 |
+
code: "invalid_format",
|
| 2127 |
+
format: def.format ?? "template_literal",
|
| 2128 |
+
pattern: inst._zod.pattern.source,
|
| 2129 |
+
});
|
| 2130 |
+
return payload;
|
| 2131 |
+
}
|
| 2132 |
+
return payload;
|
| 2133 |
+
};
|
| 2134 |
+
});
|
| 2135 |
+
exports.$ZodFunction = core.$constructor("$ZodFunction", (inst, def) => {
|
| 2136 |
+
exports.$ZodType.init(inst, def);
|
| 2137 |
+
inst._def = def;
|
| 2138 |
+
inst._zod.def = def;
|
| 2139 |
+
inst.implement = (func) => {
|
| 2140 |
+
if (typeof func !== "function") {
|
| 2141 |
+
throw new Error("implement() must be called with a function");
|
| 2142 |
+
}
|
| 2143 |
+
return function (...args) {
|
| 2144 |
+
const parsedArgs = inst._def.input ? (0, parse_js_1.parse)(inst._def.input, args) : args;
|
| 2145 |
+
const result = Reflect.apply(func, this, parsedArgs);
|
| 2146 |
+
if (inst._def.output) {
|
| 2147 |
+
return (0, parse_js_1.parse)(inst._def.output, result);
|
| 2148 |
+
}
|
| 2149 |
+
return result;
|
| 2150 |
+
};
|
| 2151 |
+
};
|
| 2152 |
+
inst.implementAsync = (func) => {
|
| 2153 |
+
if (typeof func !== "function") {
|
| 2154 |
+
throw new Error("implementAsync() must be called with a function");
|
| 2155 |
+
}
|
| 2156 |
+
return async function (...args) {
|
| 2157 |
+
const parsedArgs = inst._def.input ? await (0, parse_js_1.parseAsync)(inst._def.input, args) : args;
|
| 2158 |
+
const result = await Reflect.apply(func, this, parsedArgs);
|
| 2159 |
+
if (inst._def.output) {
|
| 2160 |
+
return await (0, parse_js_1.parseAsync)(inst._def.output, result);
|
| 2161 |
+
}
|
| 2162 |
+
return result;
|
| 2163 |
+
};
|
| 2164 |
+
};
|
| 2165 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 2166 |
+
if (typeof payload.value !== "function") {
|
| 2167 |
+
payload.issues.push({
|
| 2168 |
+
code: "invalid_type",
|
| 2169 |
+
expected: "function",
|
| 2170 |
+
input: payload.value,
|
| 2171 |
+
inst,
|
| 2172 |
+
});
|
| 2173 |
+
return payload;
|
| 2174 |
+
}
|
| 2175 |
+
// Check if output is a promise type to determine if we should use async implementation
|
| 2176 |
+
const hasPromiseOutput = inst._def.output && inst._def.output._zod.def.type === "promise";
|
| 2177 |
+
if (hasPromiseOutput) {
|
| 2178 |
+
payload.value = inst.implementAsync(payload.value);
|
| 2179 |
+
}
|
| 2180 |
+
else {
|
| 2181 |
+
payload.value = inst.implement(payload.value);
|
| 2182 |
+
}
|
| 2183 |
+
return payload;
|
| 2184 |
+
};
|
| 2185 |
+
inst.input = (...args) => {
|
| 2186 |
+
const F = inst.constructor;
|
| 2187 |
+
if (Array.isArray(args[0])) {
|
| 2188 |
+
return new F({
|
| 2189 |
+
type: "function",
|
| 2190 |
+
input: new exports.$ZodTuple({
|
| 2191 |
+
type: "tuple",
|
| 2192 |
+
items: args[0],
|
| 2193 |
+
rest: args[1],
|
| 2194 |
+
}),
|
| 2195 |
+
output: inst._def.output,
|
| 2196 |
+
});
|
| 2197 |
+
}
|
| 2198 |
+
return new F({
|
| 2199 |
+
type: "function",
|
| 2200 |
+
input: args[0],
|
| 2201 |
+
output: inst._def.output,
|
| 2202 |
+
});
|
| 2203 |
+
};
|
| 2204 |
+
inst.output = (output) => {
|
| 2205 |
+
const F = inst.constructor;
|
| 2206 |
+
return new F({
|
| 2207 |
+
type: "function",
|
| 2208 |
+
input: inst._def.input,
|
| 2209 |
+
output,
|
| 2210 |
+
});
|
| 2211 |
+
};
|
| 2212 |
+
return inst;
|
| 2213 |
+
});
|
| 2214 |
+
exports.$ZodPromise = core.$constructor("$ZodPromise", (inst, def) => {
|
| 2215 |
+
exports.$ZodType.init(inst, def);
|
| 2216 |
+
inst._zod.parse = (payload, ctx) => {
|
| 2217 |
+
return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
|
| 2218 |
+
};
|
| 2219 |
+
});
|
| 2220 |
+
exports.$ZodLazy = core.$constructor("$ZodLazy", (inst, def) => {
|
| 2221 |
+
exports.$ZodType.init(inst, def);
|
| 2222 |
+
// Cache the resolved inner type on the shared `def` so all clones of this
|
| 2223 |
+
// lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance,
|
| 2224 |
+
// preserving identity for cycle detection on recursive schemas.
|
| 2225 |
+
util.defineLazy(inst._zod, "innerType", () => {
|
| 2226 |
+
const d = def;
|
| 2227 |
+
if (!d._cachedInner)
|
| 2228 |
+
d._cachedInner = def.getter();
|
| 2229 |
+
return d._cachedInner;
|
| 2230 |
+
});
|
| 2231 |
+
util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
|
| 2232 |
+
util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
|
| 2233 |
+
util.defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined);
|
| 2234 |
+
util.defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? undefined);
|
| 2235 |
+
inst._zod.parse = (payload, ctx) => {
|
| 2236 |
+
const inner = inst._zod.innerType;
|
| 2237 |
+
return inner._zod.run(payload, ctx);
|
| 2238 |
+
};
|
| 2239 |
+
});
|
| 2240 |
+
exports.$ZodCustom = core.$constructor("$ZodCustom", (inst, def) => {
|
| 2241 |
+
checks.$ZodCheck.init(inst, def);
|
| 2242 |
+
exports.$ZodType.init(inst, def);
|
| 2243 |
+
inst._zod.parse = (payload, _) => {
|
| 2244 |
+
return payload;
|
| 2245 |
+
};
|
| 2246 |
+
inst._zod.check = (payload) => {
|
| 2247 |
+
const input = payload.value;
|
| 2248 |
+
const r = def.fn(input);
|
| 2249 |
+
if (r instanceof Promise) {
|
| 2250 |
+
return r.then((r) => handleRefineResult(r, payload, input, inst));
|
| 2251 |
+
}
|
| 2252 |
+
handleRefineResult(r, payload, input, inst);
|
| 2253 |
+
return;
|
| 2254 |
+
};
|
| 2255 |
+
});
|
| 2256 |
+
function handleRefineResult(result, payload, input, inst) {
|
| 2257 |
+
if (!result) {
|
| 2258 |
+
const _iss = {
|
| 2259 |
+
code: "custom",
|
| 2260 |
+
input,
|
| 2261 |
+
inst, // incorporates params.error into issue reporting
|
| 2262 |
+
path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
|
| 2263 |
+
continue: !inst._zod.def.abort,
|
| 2264 |
+
// params: inst._zod.def.params,
|
| 2265 |
+
};
|
| 2266 |
+
if (inst._zod.def.params)
|
| 2267 |
+
_iss.params = inst._zod.def.params;
|
| 2268 |
+
payload.issues.push(util.issue(_iss));
|
| 2269 |
+
}
|
| 2270 |
+
}
|
node_modules/zod/v4/core/schemas.d.cts
ADDED
|
@@ -0,0 +1,1184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as checks from "./checks.cjs";
|
| 2 |
+
import * as core from "./core.cjs";
|
| 3 |
+
import type * as errors from "./errors.cjs";
|
| 4 |
+
import type * as JSONSchema from "./json-schema.cjs";
|
| 5 |
+
import type { StandardSchemaV1 } from "./standard-schema.cjs";
|
| 6 |
+
import type { ProcessParams, ToJSONSchemaContext } from "./to-json-schema.cjs";
|
| 7 |
+
import * as util from "./util.cjs";
|
| 8 |
+
import { version } from "./versions.cjs";
|
| 9 |
+
export interface ParseContext<T extends errors.$ZodIssueBase = never> {
|
| 10 |
+
/** Customize error messages. */
|
| 11 |
+
readonly error?: errors.$ZodErrorMap<T>;
|
| 12 |
+
/** Include the `input` field in issue objects. Default `false`. */
|
| 13 |
+
readonly reportInput?: boolean;
|
| 14 |
+
/** Skip eval-based fast path. Default `false`. */
|
| 15 |
+
readonly jitless?: boolean;
|
| 16 |
+
}
|
| 17 |
+
/** @internal */
|
| 18 |
+
export interface ParseContextInternal<T extends errors.$ZodIssueBase = never> extends ParseContext<T> {
|
| 19 |
+
readonly async?: boolean | undefined;
|
| 20 |
+
readonly direction?: "forward" | "backward";
|
| 21 |
+
readonly skipChecks?: boolean;
|
| 22 |
+
}
|
| 23 |
+
export interface ParsePayload<T = unknown> {
|
| 24 |
+
value: T;
|
| 25 |
+
issues: errors.$ZodRawIssue[];
|
| 26 |
+
/** A way to mark a whole payload as aborted. Used in codecs/pipes. */
|
| 27 |
+
aborted?: boolean;
|
| 28 |
+
/** @internal Marks a value as a fallback that an outer wrapper (e.g.
|
| 29 |
+
* $ZodOptional) may override with its own interpretation when input was
|
| 30 |
+
* undefined. Set by $ZodCatch when catchValue substitutes and by every
|
| 31 |
+
* $ZodTransform invocation. */
|
| 32 |
+
fallback?: boolean | undefined;
|
| 33 |
+
}
|
| 34 |
+
export type CheckFn<T> = (input: ParsePayload<T>) => util.MaybeAsync<void>;
|
| 35 |
+
export interface $ZodTypeDef {
|
| 36 |
+
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";
|
| 37 |
+
error?: errors.$ZodErrorMap<never> | undefined;
|
| 38 |
+
checks?: checks.$ZodCheck<never>[];
|
| 39 |
+
}
|
| 40 |
+
export interface _$ZodTypeInternals {
|
| 41 |
+
/** The `@zod/core` version of this schema */
|
| 42 |
+
version: typeof version;
|
| 43 |
+
/** Schema definition. */
|
| 44 |
+
def: $ZodTypeDef;
|
| 45 |
+
/** @internal Randomly generated ID for this schema. */
|
| 46 |
+
/** @internal List of deferred initializers. */
|
| 47 |
+
deferred: util.AnyFunc[] | undefined;
|
| 48 |
+
/** @internal Parses input and runs all checks (refinements). */
|
| 49 |
+
run(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
|
| 50 |
+
/** @internal Parses input, doesn't run checks. */
|
| 51 |
+
parse(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
|
| 52 |
+
/** @internal Stores identifiers for the set of traits implemented by this schema. */
|
| 53 |
+
traits: Set<string>;
|
| 54 |
+
/** @internal Indicates that a schema output type should be considered optional inside objects.
|
| 55 |
+
* @default Required
|
| 56 |
+
*/
|
| 57 |
+
/** @internal */
|
| 58 |
+
optin?: "optional" | undefined;
|
| 59 |
+
/** @internal */
|
| 60 |
+
optout?: "optional" | undefined;
|
| 61 |
+
/** @internal The set of literal values that will pass validation. Must be an exhaustive set. Used to determine optionality in z.record().
|
| 62 |
+
*
|
| 63 |
+
* Defined on: enum, const, literal, null, undefined
|
| 64 |
+
* Passthrough: optional, nullable, branded, default, catch, pipe
|
| 65 |
+
* Todo: unions?
|
| 66 |
+
*/
|
| 67 |
+
values?: util.PrimitiveSet | undefined;
|
| 68 |
+
/** Default value bubbled up from */
|
| 69 |
+
/** @internal A set of literal discriminators used for the fast path in discriminated unions. */
|
| 70 |
+
propValues?: util.PropValues | undefined;
|
| 71 |
+
/** @internal This flag indicates that a schema validation can be represented with a regular expression. Used to determine allowable schemas in z.templateLiteral(). */
|
| 72 |
+
pattern: RegExp | undefined;
|
| 73 |
+
/** @internal The constructor function of this schema. */
|
| 74 |
+
constr: new (def: any) => $ZodType;
|
| 75 |
+
/** @internal A catchall object for bag metadata related to this schema. Commonly modified by checks using `onattach`. */
|
| 76 |
+
bag: Record<string, unknown>;
|
| 77 |
+
/** @internal The set of issues this schema might throw during type checking. */
|
| 78 |
+
isst: errors.$ZodIssueBase;
|
| 79 |
+
/** @internal Subject to change, not a public API. */
|
| 80 |
+
processJSONSchema?: ((ctx: ToJSONSchemaContext, json: JSONSchema.BaseSchema, params: ProcessParams) => void) | undefined;
|
| 81 |
+
/** An optional method used to override `toJSONSchema` logic. */
|
| 82 |
+
toJSONSchema?: () => unknown;
|
| 83 |
+
/** @internal The parent of this schema. Only set during certain clone operations. */
|
| 84 |
+
parent?: $ZodType | undefined;
|
| 85 |
+
}
|
| 86 |
+
/** @internal */
|
| 87 |
+
export interface $ZodTypeInternals<out O = unknown, out I = unknown> extends _$ZodTypeInternals {
|
| 88 |
+
/** @internal The inferred output type */
|
| 89 |
+
output: O;
|
| 90 |
+
/** @internal The inferred input type */
|
| 91 |
+
input: I;
|
| 92 |
+
}
|
| 93 |
+
export type $ZodStandardSchema<T> = StandardSchemaV1.Props<core.input<T>, core.output<T>>;
|
| 94 |
+
export type SomeType = {
|
| 95 |
+
_zod: _$ZodTypeInternals;
|
| 96 |
+
};
|
| 97 |
+
export interface $ZodType<O = unknown, I = unknown, Internals extends $ZodTypeInternals<O, I> = $ZodTypeInternals<O, I>> {
|
| 98 |
+
_zod: Internals;
|
| 99 |
+
"~standard": $ZodStandardSchema<this>;
|
| 100 |
+
}
|
| 101 |
+
export interface _$ZodType<T extends $ZodTypeInternals = $ZodTypeInternals> extends $ZodType<T["output"], T["input"], T> {
|
| 102 |
+
}
|
| 103 |
+
export declare const $ZodType: core.$constructor<$ZodType>;
|
| 104 |
+
export { clone } from "./util.cjs";
|
| 105 |
+
export interface $ZodStringDef extends $ZodTypeDef {
|
| 106 |
+
type: "string";
|
| 107 |
+
coerce?: boolean;
|
| 108 |
+
checks?: checks.$ZodCheck<string>[];
|
| 109 |
+
}
|
| 110 |
+
export interface $ZodStringInternals<Input> extends $ZodTypeInternals<string, Input> {
|
| 111 |
+
def: $ZodStringDef;
|
| 112 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 113 |
+
pattern: RegExp;
|
| 114 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 115 |
+
isst: errors.$ZodIssueInvalidType;
|
| 116 |
+
bag: util.LoosePartial<{
|
| 117 |
+
minimum: number;
|
| 118 |
+
maximum: number;
|
| 119 |
+
patterns: Set<RegExp>;
|
| 120 |
+
format: string;
|
| 121 |
+
contentEncoding: string;
|
| 122 |
+
}>;
|
| 123 |
+
}
|
| 124 |
+
export interface $ZodString<Input = unknown> extends _$ZodType<$ZodStringInternals<Input>> {
|
| 125 |
+
}
|
| 126 |
+
export declare const $ZodString: core.$constructor<$ZodString>;
|
| 127 |
+
export interface $ZodStringFormatDef<Format extends string = string> extends $ZodStringDef, checks.$ZodCheckStringFormatDef<Format> {
|
| 128 |
+
}
|
| 129 |
+
export interface $ZodStringFormatInternals<Format extends string = string> extends $ZodStringInternals<string>, checks.$ZodCheckStringFormatInternals {
|
| 130 |
+
def: $ZodStringFormatDef<Format>;
|
| 131 |
+
}
|
| 132 |
+
export interface $ZodStringFormat<Format extends string = string> extends $ZodType {
|
| 133 |
+
_zod: $ZodStringFormatInternals<Format>;
|
| 134 |
+
}
|
| 135 |
+
export declare const $ZodStringFormat: core.$constructor<$ZodStringFormat>;
|
| 136 |
+
export interface $ZodGUIDDef extends $ZodStringFormatDef<"guid"> {
|
| 137 |
+
}
|
| 138 |
+
export interface $ZodGUIDInternals extends $ZodStringFormatInternals<"guid"> {
|
| 139 |
+
}
|
| 140 |
+
export interface $ZodGUID extends $ZodType {
|
| 141 |
+
_zod: $ZodGUIDInternals;
|
| 142 |
+
}
|
| 143 |
+
export declare const $ZodGUID: core.$constructor<$ZodGUID>;
|
| 144 |
+
export interface $ZodUUIDDef extends $ZodStringFormatDef<"uuid"> {
|
| 145 |
+
version?: "v1" | "v2" | "v3" | "v4" | "v5" | "v6" | "v7" | "v8";
|
| 146 |
+
}
|
| 147 |
+
export interface $ZodUUIDInternals extends $ZodStringFormatInternals<"uuid"> {
|
| 148 |
+
def: $ZodUUIDDef;
|
| 149 |
+
}
|
| 150 |
+
export interface $ZodUUID extends $ZodType {
|
| 151 |
+
_zod: $ZodUUIDInternals;
|
| 152 |
+
}
|
| 153 |
+
export declare const $ZodUUID: core.$constructor<$ZodUUID>;
|
| 154 |
+
export interface $ZodEmailDef extends $ZodStringFormatDef<"email"> {
|
| 155 |
+
}
|
| 156 |
+
export interface $ZodEmailInternals extends $ZodStringFormatInternals<"email"> {
|
| 157 |
+
}
|
| 158 |
+
export interface $ZodEmail extends $ZodType {
|
| 159 |
+
_zod: $ZodEmailInternals;
|
| 160 |
+
}
|
| 161 |
+
export declare const $ZodEmail: core.$constructor<$ZodEmail>;
|
| 162 |
+
export interface $ZodURLDef extends $ZodStringFormatDef<"url"> {
|
| 163 |
+
hostname?: RegExp | undefined;
|
| 164 |
+
protocol?: RegExp | undefined;
|
| 165 |
+
normalize?: boolean | undefined;
|
| 166 |
+
}
|
| 167 |
+
export interface $ZodURLInternals extends $ZodStringFormatInternals<"url"> {
|
| 168 |
+
def: $ZodURLDef;
|
| 169 |
+
}
|
| 170 |
+
export interface $ZodURL extends $ZodType {
|
| 171 |
+
_zod: $ZodURLInternals;
|
| 172 |
+
}
|
| 173 |
+
export declare const $ZodURL: core.$constructor<$ZodURL>;
|
| 174 |
+
export interface $ZodEmojiDef extends $ZodStringFormatDef<"emoji"> {
|
| 175 |
+
}
|
| 176 |
+
export interface $ZodEmojiInternals extends $ZodStringFormatInternals<"emoji"> {
|
| 177 |
+
}
|
| 178 |
+
export interface $ZodEmoji extends $ZodType {
|
| 179 |
+
_zod: $ZodEmojiInternals;
|
| 180 |
+
}
|
| 181 |
+
export declare const $ZodEmoji: core.$constructor<$ZodEmoji>;
|
| 182 |
+
export interface $ZodNanoIDDef extends $ZodStringFormatDef<"nanoid"> {
|
| 183 |
+
}
|
| 184 |
+
export interface $ZodNanoIDInternals extends $ZodStringFormatInternals<"nanoid"> {
|
| 185 |
+
}
|
| 186 |
+
export interface $ZodNanoID extends $ZodType {
|
| 187 |
+
_zod: $ZodNanoIDInternals;
|
| 188 |
+
}
|
| 189 |
+
export declare const $ZodNanoID: core.$constructor<$ZodNanoID>;
|
| 190 |
+
/**
|
| 191 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 192 |
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
| 193 |
+
* See https://github.com/paralleldrive/cuid.
|
| 194 |
+
*/
|
| 195 |
+
export interface $ZodCUIDDef extends $ZodStringFormatDef<"cuid"> {
|
| 196 |
+
}
|
| 197 |
+
/**
|
| 198 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 199 |
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
| 200 |
+
* See https://github.com/paralleldrive/cuid.
|
| 201 |
+
*/
|
| 202 |
+
export interface $ZodCUIDInternals extends $ZodStringFormatInternals<"cuid"> {
|
| 203 |
+
}
|
| 204 |
+
/**
|
| 205 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 206 |
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
| 207 |
+
* See https://github.com/paralleldrive/cuid.
|
| 208 |
+
*/
|
| 209 |
+
export interface $ZodCUID extends $ZodType {
|
| 210 |
+
_zod: $ZodCUIDInternals;
|
| 211 |
+
}
|
| 212 |
+
/**
|
| 213 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 214 |
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
| 215 |
+
* See https://github.com/paralleldrive/cuid.
|
| 216 |
+
*/
|
| 217 |
+
export declare const $ZodCUID: core.$constructor<$ZodCUID>;
|
| 218 |
+
export interface $ZodCUID2Def extends $ZodStringFormatDef<"cuid2"> {
|
| 219 |
+
}
|
| 220 |
+
export interface $ZodCUID2Internals extends $ZodStringFormatInternals<"cuid2"> {
|
| 221 |
+
}
|
| 222 |
+
export interface $ZodCUID2 extends $ZodType {
|
| 223 |
+
_zod: $ZodCUID2Internals;
|
| 224 |
+
}
|
| 225 |
+
export declare const $ZodCUID2: core.$constructor<$ZodCUID2>;
|
| 226 |
+
export interface $ZodULIDDef extends $ZodStringFormatDef<"ulid"> {
|
| 227 |
+
}
|
| 228 |
+
export interface $ZodULIDInternals extends $ZodStringFormatInternals<"ulid"> {
|
| 229 |
+
}
|
| 230 |
+
export interface $ZodULID extends $ZodType {
|
| 231 |
+
_zod: $ZodULIDInternals;
|
| 232 |
+
}
|
| 233 |
+
export declare const $ZodULID: core.$constructor<$ZodULID>;
|
| 234 |
+
export interface $ZodXIDDef extends $ZodStringFormatDef<"xid"> {
|
| 235 |
+
}
|
| 236 |
+
export interface $ZodXIDInternals extends $ZodStringFormatInternals<"xid"> {
|
| 237 |
+
}
|
| 238 |
+
export interface $ZodXID extends $ZodType {
|
| 239 |
+
_zod: $ZodXIDInternals;
|
| 240 |
+
}
|
| 241 |
+
export declare const $ZodXID: core.$constructor<$ZodXID>;
|
| 242 |
+
export interface $ZodKSUIDDef extends $ZodStringFormatDef<"ksuid"> {
|
| 243 |
+
}
|
| 244 |
+
export interface $ZodKSUIDInternals extends $ZodStringFormatInternals<"ksuid"> {
|
| 245 |
+
}
|
| 246 |
+
export interface $ZodKSUID extends $ZodType {
|
| 247 |
+
_zod: $ZodKSUIDInternals;
|
| 248 |
+
}
|
| 249 |
+
export declare const $ZodKSUID: core.$constructor<$ZodKSUID>;
|
| 250 |
+
export interface $ZodISODateTimeDef extends $ZodStringFormatDef<"datetime"> {
|
| 251 |
+
precision: number | null;
|
| 252 |
+
offset: boolean;
|
| 253 |
+
local: boolean;
|
| 254 |
+
}
|
| 255 |
+
export interface $ZodISODateTimeInternals extends $ZodStringFormatInternals {
|
| 256 |
+
def: $ZodISODateTimeDef;
|
| 257 |
+
}
|
| 258 |
+
export interface $ZodISODateTime extends $ZodType {
|
| 259 |
+
_zod: $ZodISODateTimeInternals;
|
| 260 |
+
}
|
| 261 |
+
export declare const $ZodISODateTime: core.$constructor<$ZodISODateTime>;
|
| 262 |
+
export interface $ZodISODateDef extends $ZodStringFormatDef<"date"> {
|
| 263 |
+
}
|
| 264 |
+
export interface $ZodISODateInternals extends $ZodStringFormatInternals<"date"> {
|
| 265 |
+
}
|
| 266 |
+
export interface $ZodISODate extends $ZodType {
|
| 267 |
+
_zod: $ZodISODateInternals;
|
| 268 |
+
}
|
| 269 |
+
export declare const $ZodISODate: core.$constructor<$ZodISODate>;
|
| 270 |
+
export interface $ZodISOTimeDef extends $ZodStringFormatDef<"time"> {
|
| 271 |
+
precision?: number | null;
|
| 272 |
+
}
|
| 273 |
+
export interface $ZodISOTimeInternals extends $ZodStringFormatInternals<"time"> {
|
| 274 |
+
def: $ZodISOTimeDef;
|
| 275 |
+
}
|
| 276 |
+
export interface $ZodISOTime extends $ZodType {
|
| 277 |
+
_zod: $ZodISOTimeInternals;
|
| 278 |
+
}
|
| 279 |
+
export declare const $ZodISOTime: core.$constructor<$ZodISOTime>;
|
| 280 |
+
export interface $ZodISODurationDef extends $ZodStringFormatDef<"duration"> {
|
| 281 |
+
}
|
| 282 |
+
export interface $ZodISODurationInternals extends $ZodStringFormatInternals<"duration"> {
|
| 283 |
+
}
|
| 284 |
+
export interface $ZodISODuration extends $ZodType {
|
| 285 |
+
_zod: $ZodISODurationInternals;
|
| 286 |
+
}
|
| 287 |
+
export declare const $ZodISODuration: core.$constructor<$ZodISODuration>;
|
| 288 |
+
export interface $ZodIPv4Def extends $ZodStringFormatDef<"ipv4"> {
|
| 289 |
+
version?: "v4";
|
| 290 |
+
}
|
| 291 |
+
export interface $ZodIPv4Internals extends $ZodStringFormatInternals<"ipv4"> {
|
| 292 |
+
def: $ZodIPv4Def;
|
| 293 |
+
}
|
| 294 |
+
export interface $ZodIPv4 extends $ZodType {
|
| 295 |
+
_zod: $ZodIPv4Internals;
|
| 296 |
+
}
|
| 297 |
+
export declare const $ZodIPv4: core.$constructor<$ZodIPv4>;
|
| 298 |
+
export interface $ZodIPv6Def extends $ZodStringFormatDef<"ipv6"> {
|
| 299 |
+
version?: "v6";
|
| 300 |
+
}
|
| 301 |
+
export interface $ZodIPv6Internals extends $ZodStringFormatInternals<"ipv6"> {
|
| 302 |
+
def: $ZodIPv6Def;
|
| 303 |
+
}
|
| 304 |
+
export interface $ZodIPv6 extends $ZodType {
|
| 305 |
+
_zod: $ZodIPv6Internals;
|
| 306 |
+
}
|
| 307 |
+
export declare const $ZodIPv6: core.$constructor<$ZodIPv6>;
|
| 308 |
+
export interface $ZodMACDef extends $ZodStringFormatDef<"mac"> {
|
| 309 |
+
delimiter?: string;
|
| 310 |
+
}
|
| 311 |
+
export interface $ZodMACInternals extends $ZodStringFormatInternals<"mac"> {
|
| 312 |
+
def: $ZodMACDef;
|
| 313 |
+
}
|
| 314 |
+
export interface $ZodMAC extends $ZodType {
|
| 315 |
+
_zod: $ZodMACInternals;
|
| 316 |
+
}
|
| 317 |
+
export declare const $ZodMAC: core.$constructor<$ZodMAC>;
|
| 318 |
+
export interface $ZodCIDRv4Def extends $ZodStringFormatDef<"cidrv4"> {
|
| 319 |
+
version?: "v4";
|
| 320 |
+
}
|
| 321 |
+
export interface $ZodCIDRv4Internals extends $ZodStringFormatInternals<"cidrv4"> {
|
| 322 |
+
def: $ZodCIDRv4Def;
|
| 323 |
+
}
|
| 324 |
+
export interface $ZodCIDRv4 extends $ZodType {
|
| 325 |
+
_zod: $ZodCIDRv4Internals;
|
| 326 |
+
}
|
| 327 |
+
export declare const $ZodCIDRv4: core.$constructor<$ZodCIDRv4>;
|
| 328 |
+
export interface $ZodCIDRv6Def extends $ZodStringFormatDef<"cidrv6"> {
|
| 329 |
+
version?: "v6";
|
| 330 |
+
}
|
| 331 |
+
export interface $ZodCIDRv6Internals extends $ZodStringFormatInternals<"cidrv6"> {
|
| 332 |
+
def: $ZodCIDRv6Def;
|
| 333 |
+
}
|
| 334 |
+
export interface $ZodCIDRv6 extends $ZodType {
|
| 335 |
+
_zod: $ZodCIDRv6Internals;
|
| 336 |
+
}
|
| 337 |
+
export declare const $ZodCIDRv6: core.$constructor<$ZodCIDRv6>;
|
| 338 |
+
export declare function isValidBase64(data: string): boolean;
|
| 339 |
+
export interface $ZodBase64Def extends $ZodStringFormatDef<"base64"> {
|
| 340 |
+
}
|
| 341 |
+
export interface $ZodBase64Internals extends $ZodStringFormatInternals<"base64"> {
|
| 342 |
+
}
|
| 343 |
+
export interface $ZodBase64 extends $ZodType {
|
| 344 |
+
_zod: $ZodBase64Internals;
|
| 345 |
+
}
|
| 346 |
+
export declare const $ZodBase64: core.$constructor<$ZodBase64>;
|
| 347 |
+
export declare function isValidBase64URL(data: string): boolean;
|
| 348 |
+
export interface $ZodBase64URLDef extends $ZodStringFormatDef<"base64url"> {
|
| 349 |
+
}
|
| 350 |
+
export interface $ZodBase64URLInternals extends $ZodStringFormatInternals<"base64url"> {
|
| 351 |
+
}
|
| 352 |
+
export interface $ZodBase64URL extends $ZodType {
|
| 353 |
+
_zod: $ZodBase64URLInternals;
|
| 354 |
+
}
|
| 355 |
+
export declare const $ZodBase64URL: core.$constructor<$ZodBase64URL>;
|
| 356 |
+
export interface $ZodE164Def extends $ZodStringFormatDef<"e164"> {
|
| 357 |
+
}
|
| 358 |
+
export interface $ZodE164Internals extends $ZodStringFormatInternals<"e164"> {
|
| 359 |
+
}
|
| 360 |
+
export interface $ZodE164 extends $ZodType {
|
| 361 |
+
_zod: $ZodE164Internals;
|
| 362 |
+
}
|
| 363 |
+
export declare const $ZodE164: core.$constructor<$ZodE164>;
|
| 364 |
+
export declare function isValidJWT(token: string, algorithm?: util.JWTAlgorithm | null): boolean;
|
| 365 |
+
export interface $ZodJWTDef extends $ZodStringFormatDef<"jwt"> {
|
| 366 |
+
alg?: util.JWTAlgorithm | undefined;
|
| 367 |
+
}
|
| 368 |
+
export interface $ZodJWTInternals extends $ZodStringFormatInternals<"jwt"> {
|
| 369 |
+
def: $ZodJWTDef;
|
| 370 |
+
}
|
| 371 |
+
export interface $ZodJWT extends $ZodType {
|
| 372 |
+
_zod: $ZodJWTInternals;
|
| 373 |
+
}
|
| 374 |
+
export declare const $ZodJWT: core.$constructor<$ZodJWT>;
|
| 375 |
+
export interface $ZodCustomStringFormatDef<Format extends string = string> extends $ZodStringFormatDef<Format> {
|
| 376 |
+
fn: (val: string) => unknown;
|
| 377 |
+
}
|
| 378 |
+
export interface $ZodCustomStringFormatInternals<Format extends string = string> extends $ZodStringFormatInternals<Format> {
|
| 379 |
+
def: $ZodCustomStringFormatDef<Format>;
|
| 380 |
+
}
|
| 381 |
+
export interface $ZodCustomStringFormat<Format extends string = string> extends $ZodStringFormat<Format> {
|
| 382 |
+
_zod: $ZodCustomStringFormatInternals<Format>;
|
| 383 |
+
}
|
| 384 |
+
export declare const $ZodCustomStringFormat: core.$constructor<$ZodCustomStringFormat>;
|
| 385 |
+
export interface $ZodNumberDef extends $ZodTypeDef {
|
| 386 |
+
type: "number";
|
| 387 |
+
coerce?: boolean;
|
| 388 |
+
}
|
| 389 |
+
export interface $ZodNumberInternals<Input = unknown> extends $ZodTypeInternals<number, Input> {
|
| 390 |
+
def: $ZodNumberDef;
|
| 391 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 392 |
+
pattern: RegExp;
|
| 393 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 394 |
+
isst: errors.$ZodIssueInvalidType;
|
| 395 |
+
bag: util.LoosePartial<{
|
| 396 |
+
minimum: number;
|
| 397 |
+
maximum: number;
|
| 398 |
+
exclusiveMinimum: number;
|
| 399 |
+
exclusiveMaximum: number;
|
| 400 |
+
format: string;
|
| 401 |
+
pattern: RegExp;
|
| 402 |
+
}>;
|
| 403 |
+
}
|
| 404 |
+
export interface $ZodNumber<Input = unknown> extends $ZodType {
|
| 405 |
+
_zod: $ZodNumberInternals<Input>;
|
| 406 |
+
}
|
| 407 |
+
export declare const $ZodNumber: core.$constructor<$ZodNumber>;
|
| 408 |
+
export interface $ZodNumberFormatDef extends $ZodNumberDef, checks.$ZodCheckNumberFormatDef {
|
| 409 |
+
}
|
| 410 |
+
export interface $ZodNumberFormatInternals extends $ZodNumberInternals<number>, checks.$ZodCheckNumberFormatInternals {
|
| 411 |
+
def: $ZodNumberFormatDef;
|
| 412 |
+
isst: errors.$ZodIssueInvalidType;
|
| 413 |
+
}
|
| 414 |
+
export interface $ZodNumberFormat extends $ZodType {
|
| 415 |
+
_zod: $ZodNumberFormatInternals;
|
| 416 |
+
}
|
| 417 |
+
export declare const $ZodNumberFormat: core.$constructor<$ZodNumberFormat>;
|
| 418 |
+
export interface $ZodBooleanDef extends $ZodTypeDef {
|
| 419 |
+
type: "boolean";
|
| 420 |
+
coerce?: boolean;
|
| 421 |
+
checks?: checks.$ZodCheck<boolean>[];
|
| 422 |
+
}
|
| 423 |
+
export interface $ZodBooleanInternals<T = unknown> extends $ZodTypeInternals<boolean, T> {
|
| 424 |
+
pattern: RegExp;
|
| 425 |
+
def: $ZodBooleanDef;
|
| 426 |
+
isst: errors.$ZodIssueInvalidType;
|
| 427 |
+
}
|
| 428 |
+
export interface $ZodBoolean<T = unknown> extends $ZodType {
|
| 429 |
+
_zod: $ZodBooleanInternals<T>;
|
| 430 |
+
}
|
| 431 |
+
export declare const $ZodBoolean: core.$constructor<$ZodBoolean>;
|
| 432 |
+
export interface $ZodBigIntDef extends $ZodTypeDef {
|
| 433 |
+
type: "bigint";
|
| 434 |
+
coerce?: boolean;
|
| 435 |
+
}
|
| 436 |
+
export interface $ZodBigIntInternals<T = unknown> extends $ZodTypeInternals<bigint, T> {
|
| 437 |
+
pattern: RegExp;
|
| 438 |
+
/** @internal Internal API, use with caution */
|
| 439 |
+
def: $ZodBigIntDef;
|
| 440 |
+
isst: errors.$ZodIssueInvalidType;
|
| 441 |
+
bag: util.LoosePartial<{
|
| 442 |
+
minimum: bigint;
|
| 443 |
+
maximum: bigint;
|
| 444 |
+
format: string;
|
| 445 |
+
}>;
|
| 446 |
+
}
|
| 447 |
+
export interface $ZodBigInt<T = unknown> extends $ZodType {
|
| 448 |
+
_zod: $ZodBigIntInternals<T>;
|
| 449 |
+
}
|
| 450 |
+
export declare const $ZodBigInt: core.$constructor<$ZodBigInt>;
|
| 451 |
+
export interface $ZodBigIntFormatDef extends $ZodBigIntDef, checks.$ZodCheckBigIntFormatDef {
|
| 452 |
+
check: "bigint_format";
|
| 453 |
+
}
|
| 454 |
+
export interface $ZodBigIntFormatInternals extends $ZodBigIntInternals<bigint>, checks.$ZodCheckBigIntFormatInternals {
|
| 455 |
+
def: $ZodBigIntFormatDef;
|
| 456 |
+
}
|
| 457 |
+
export interface $ZodBigIntFormat extends $ZodType {
|
| 458 |
+
_zod: $ZodBigIntFormatInternals;
|
| 459 |
+
}
|
| 460 |
+
export declare const $ZodBigIntFormat: core.$constructor<$ZodBigIntFormat>;
|
| 461 |
+
export interface $ZodSymbolDef extends $ZodTypeDef {
|
| 462 |
+
type: "symbol";
|
| 463 |
+
}
|
| 464 |
+
export interface $ZodSymbolInternals extends $ZodTypeInternals<symbol, symbol> {
|
| 465 |
+
def: $ZodSymbolDef;
|
| 466 |
+
isst: errors.$ZodIssueInvalidType;
|
| 467 |
+
}
|
| 468 |
+
export interface $ZodSymbol extends $ZodType {
|
| 469 |
+
_zod: $ZodSymbolInternals;
|
| 470 |
+
}
|
| 471 |
+
export declare const $ZodSymbol: core.$constructor<$ZodSymbol>;
|
| 472 |
+
export interface $ZodUndefinedDef extends $ZodTypeDef {
|
| 473 |
+
type: "undefined";
|
| 474 |
+
}
|
| 475 |
+
export interface $ZodUndefinedInternals extends $ZodTypeInternals<undefined, undefined> {
|
| 476 |
+
pattern: RegExp;
|
| 477 |
+
def: $ZodUndefinedDef;
|
| 478 |
+
values: util.PrimitiveSet;
|
| 479 |
+
isst: errors.$ZodIssueInvalidType;
|
| 480 |
+
}
|
| 481 |
+
export interface $ZodUndefined extends $ZodType {
|
| 482 |
+
_zod: $ZodUndefinedInternals;
|
| 483 |
+
}
|
| 484 |
+
export declare const $ZodUndefined: core.$constructor<$ZodUndefined>;
|
| 485 |
+
export interface $ZodNullDef extends $ZodTypeDef {
|
| 486 |
+
type: "null";
|
| 487 |
+
}
|
| 488 |
+
export interface $ZodNullInternals extends $ZodTypeInternals<null, null> {
|
| 489 |
+
pattern: RegExp;
|
| 490 |
+
def: $ZodNullDef;
|
| 491 |
+
values: util.PrimitiveSet;
|
| 492 |
+
isst: errors.$ZodIssueInvalidType;
|
| 493 |
+
}
|
| 494 |
+
export interface $ZodNull extends $ZodType {
|
| 495 |
+
_zod: $ZodNullInternals;
|
| 496 |
+
}
|
| 497 |
+
export declare const $ZodNull: core.$constructor<$ZodNull>;
|
| 498 |
+
export interface $ZodAnyDef extends $ZodTypeDef {
|
| 499 |
+
type: "any";
|
| 500 |
+
}
|
| 501 |
+
export interface $ZodAnyInternals extends $ZodTypeInternals<any, any> {
|
| 502 |
+
def: $ZodAnyDef;
|
| 503 |
+
isst: never;
|
| 504 |
+
}
|
| 505 |
+
export interface $ZodAny extends $ZodType {
|
| 506 |
+
_zod: $ZodAnyInternals;
|
| 507 |
+
}
|
| 508 |
+
export declare const $ZodAny: core.$constructor<$ZodAny>;
|
| 509 |
+
export interface $ZodUnknownDef extends $ZodTypeDef {
|
| 510 |
+
type: "unknown";
|
| 511 |
+
}
|
| 512 |
+
export interface $ZodUnknownInternals extends $ZodTypeInternals<unknown, unknown> {
|
| 513 |
+
def: $ZodUnknownDef;
|
| 514 |
+
isst: never;
|
| 515 |
+
}
|
| 516 |
+
export interface $ZodUnknown extends $ZodType {
|
| 517 |
+
_zod: $ZodUnknownInternals;
|
| 518 |
+
}
|
| 519 |
+
export declare const $ZodUnknown: core.$constructor<$ZodUnknown>;
|
| 520 |
+
export interface $ZodNeverDef extends $ZodTypeDef {
|
| 521 |
+
type: "never";
|
| 522 |
+
}
|
| 523 |
+
export interface $ZodNeverInternals extends $ZodTypeInternals<never, never> {
|
| 524 |
+
def: $ZodNeverDef;
|
| 525 |
+
isst: errors.$ZodIssueInvalidType;
|
| 526 |
+
}
|
| 527 |
+
export interface $ZodNever extends $ZodType {
|
| 528 |
+
_zod: $ZodNeverInternals;
|
| 529 |
+
}
|
| 530 |
+
export declare const $ZodNever: core.$constructor<$ZodNever>;
|
| 531 |
+
export interface $ZodVoidDef extends $ZodTypeDef {
|
| 532 |
+
type: "void";
|
| 533 |
+
}
|
| 534 |
+
export interface $ZodVoidInternals extends $ZodTypeInternals<void, void> {
|
| 535 |
+
def: $ZodVoidDef;
|
| 536 |
+
isst: errors.$ZodIssueInvalidType;
|
| 537 |
+
}
|
| 538 |
+
export interface $ZodVoid extends $ZodType {
|
| 539 |
+
_zod: $ZodVoidInternals;
|
| 540 |
+
}
|
| 541 |
+
export declare const $ZodVoid: core.$constructor<$ZodVoid>;
|
| 542 |
+
export interface $ZodDateDef extends $ZodTypeDef {
|
| 543 |
+
type: "date";
|
| 544 |
+
coerce?: boolean;
|
| 545 |
+
}
|
| 546 |
+
export interface $ZodDateInternals<T = unknown> extends $ZodTypeInternals<Date, T> {
|
| 547 |
+
def: $ZodDateDef;
|
| 548 |
+
isst: errors.$ZodIssueInvalidType;
|
| 549 |
+
bag: util.LoosePartial<{
|
| 550 |
+
minimum: Date;
|
| 551 |
+
maximum: Date;
|
| 552 |
+
format: string;
|
| 553 |
+
}>;
|
| 554 |
+
}
|
| 555 |
+
export interface $ZodDate<T = unknown> extends $ZodType {
|
| 556 |
+
_zod: $ZodDateInternals<T>;
|
| 557 |
+
}
|
| 558 |
+
export declare const $ZodDate: core.$constructor<$ZodDate>;
|
| 559 |
+
export interface $ZodArrayDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 560 |
+
type: "array";
|
| 561 |
+
element: T;
|
| 562 |
+
}
|
| 563 |
+
export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$ZodTypeInternals {
|
| 564 |
+
def: $ZodArrayDef<T>;
|
| 565 |
+
isst: errors.$ZodIssueInvalidType;
|
| 566 |
+
output: core.output<T>[];
|
| 567 |
+
input: core.input<T>[];
|
| 568 |
+
}
|
| 569 |
+
export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {
|
| 570 |
+
}
|
| 571 |
+
export declare const $ZodArray: core.$constructor<$ZodArray>;
|
| 572 |
+
type OptionalOutSchema = {
|
| 573 |
+
_zod: {
|
| 574 |
+
optout: "optional";
|
| 575 |
+
};
|
| 576 |
+
};
|
| 577 |
+
type OptionalInSchema = {
|
| 578 |
+
_zod: {
|
| 579 |
+
optin: "optional";
|
| 580 |
+
};
|
| 581 |
+
};
|
| 582 |
+
export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? util.IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, core.output<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
| 583 |
+
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? never : k]: T[k]["_zod"]["output"];
|
| 584 |
+
} & {
|
| 585 |
+
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? k : never]?: T[k]["_zod"]["output"];
|
| 586 |
+
} & Extra>;
|
| 587 |
+
export type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? util.IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, core.input<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
| 588 |
+
-readonly [k in keyof T as T[k] extends OptionalInSchema ? never : k]: T[k]["_zod"]["input"];
|
| 589 |
+
} & {
|
| 590 |
+
-readonly [k in keyof T as T[k] extends OptionalInSchema ? k : never]?: T[k]["_zod"]["input"];
|
| 591 |
+
} & Extra>;
|
| 592 |
+
export type $ZodObjectConfig = {
|
| 593 |
+
out: Record<string, unknown>;
|
| 594 |
+
in: Record<string, unknown>;
|
| 595 |
+
};
|
| 596 |
+
export type $loose = {
|
| 597 |
+
out: Record<string, unknown>;
|
| 598 |
+
in: Record<string, unknown>;
|
| 599 |
+
};
|
| 600 |
+
export type $strict = {
|
| 601 |
+
out: {};
|
| 602 |
+
in: {};
|
| 603 |
+
};
|
| 604 |
+
export type $strip = {
|
| 605 |
+
out: {};
|
| 606 |
+
in: {};
|
| 607 |
+
};
|
| 608 |
+
export type $catchall<T extends SomeType> = {
|
| 609 |
+
out: {
|
| 610 |
+
[k: string]: core.output<T>;
|
| 611 |
+
};
|
| 612 |
+
in: {
|
| 613 |
+
[k: string]: core.input<T>;
|
| 614 |
+
};
|
| 615 |
+
};
|
| 616 |
+
export type $ZodShape = Readonly<{
|
| 617 |
+
[k: string]: $ZodType;
|
| 618 |
+
}>;
|
| 619 |
+
export interface $ZodObjectDef<Shape extends $ZodShape = $ZodShape> extends $ZodTypeDef {
|
| 620 |
+
type: "object";
|
| 621 |
+
shape: Shape;
|
| 622 |
+
catchall?: $ZodType | undefined;
|
| 623 |
+
}
|
| 624 |
+
export interface $ZodObjectInternals<
|
| 625 |
+
/** @ts-ignore Cast variance */
|
| 626 |
+
out Shape extends $ZodShape = $ZodShape, out Config extends $ZodObjectConfig = $ZodObjectConfig> extends _$ZodTypeInternals {
|
| 627 |
+
def: $ZodObjectDef<Shape>;
|
| 628 |
+
config: Config;
|
| 629 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueUnrecognizedKeys;
|
| 630 |
+
propValues: util.PropValues;
|
| 631 |
+
output: $InferObjectOutput<Shape, Config["out"]>;
|
| 632 |
+
input: $InferObjectInput<Shape, Config["in"]>;
|
| 633 |
+
optin?: "optional" | undefined;
|
| 634 |
+
optout?: "optional" | undefined;
|
| 635 |
+
}
|
| 636 |
+
export type $ZodLooseShape = Record<string, any>;
|
| 637 |
+
export interface $ZodObject<
|
| 638 |
+
/** @ts-ignore Cast variance */
|
| 639 |
+
out Shape extends Readonly<$ZodShape> = Readonly<$ZodShape>, out Params extends $ZodObjectConfig = $ZodObjectConfig> extends $ZodType<any, any, $ZodObjectInternals<Shape, Params>> {
|
| 640 |
+
}
|
| 641 |
+
export declare const $ZodObject: core.$constructor<$ZodObject>;
|
| 642 |
+
export declare const $ZodObjectJIT: core.$constructor<$ZodObject>;
|
| 643 |
+
export type $InferUnionOutput<T extends SomeType> = T extends any ? core.output<T> : never;
|
| 644 |
+
export type $InferUnionInput<T extends SomeType> = T extends any ? core.input<T> : never;
|
| 645 |
+
export interface $ZodUnionDef<Options extends readonly SomeType[] = readonly $ZodType[]> extends $ZodTypeDef {
|
| 646 |
+
type: "union";
|
| 647 |
+
options: Options;
|
| 648 |
+
inclusive?: boolean;
|
| 649 |
+
}
|
| 650 |
+
type IsOptionalIn<T extends SomeType> = T extends OptionalInSchema ? true : false;
|
| 651 |
+
type IsOptionalOut<T extends SomeType> = T extends OptionalOutSchema ? true : false;
|
| 652 |
+
export interface $ZodUnionInternals<T extends readonly SomeType[] = readonly $ZodType[]> extends _$ZodTypeInternals {
|
| 653 |
+
def: $ZodUnionDef<T>;
|
| 654 |
+
isst: errors.$ZodIssueInvalidUnion;
|
| 655 |
+
pattern: T[number]["_zod"]["pattern"];
|
| 656 |
+
values: T[number]["_zod"]["values"];
|
| 657 |
+
output: $InferUnionOutput<T[number]>;
|
| 658 |
+
input: $InferUnionInput<T[number]>;
|
| 659 |
+
optin: IsOptionalIn<T[number]> extends false ? "optional" | undefined : "optional";
|
| 660 |
+
optout: IsOptionalOut<T[number]> extends false ? "optional" | undefined : "optional";
|
| 661 |
+
}
|
| 662 |
+
export interface $ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType<any, any, $ZodUnionInternals<T>> {
|
| 663 |
+
_zod: $ZodUnionInternals<T>;
|
| 664 |
+
}
|
| 665 |
+
export declare const $ZodUnion: core.$constructor<$ZodUnion>;
|
| 666 |
+
export interface $ZodXorInternals<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodUnionInternals<T> {
|
| 667 |
+
}
|
| 668 |
+
export interface $ZodXor<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType<any, any, $ZodXorInternals<T>> {
|
| 669 |
+
_zod: $ZodXorInternals<T>;
|
| 670 |
+
}
|
| 671 |
+
export declare const $ZodXor: core.$constructor<$ZodXor>;
|
| 672 |
+
export interface $ZodDiscriminatedUnionDef<Options extends readonly SomeType[] = readonly $ZodType[], Disc extends string = string> extends $ZodUnionDef<Options> {
|
| 673 |
+
discriminator: Disc;
|
| 674 |
+
unionFallback?: boolean;
|
| 675 |
+
}
|
| 676 |
+
export interface $ZodDiscriminatedUnionInternals<Options extends readonly SomeType[] = readonly $ZodType[], Disc extends string = string> extends $ZodUnionInternals<Options> {
|
| 677 |
+
def: $ZodDiscriminatedUnionDef<Options, Disc>;
|
| 678 |
+
propValues: util.PropValues;
|
| 679 |
+
}
|
| 680 |
+
export interface $ZodDiscriminatedUnion<Options extends readonly SomeType[] = readonly $ZodType[], Disc extends string = string> extends $ZodType {
|
| 681 |
+
_zod: $ZodDiscriminatedUnionInternals<Options, Disc>;
|
| 682 |
+
}
|
| 683 |
+
export declare const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion>;
|
| 684 |
+
export interface $ZodIntersectionDef<Left extends SomeType = $ZodType, Right extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 685 |
+
type: "intersection";
|
| 686 |
+
left: Left;
|
| 687 |
+
right: Right;
|
| 688 |
+
}
|
| 689 |
+
export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends _$ZodTypeInternals {
|
| 690 |
+
def: $ZodIntersectionDef<A, B>;
|
| 691 |
+
isst: never;
|
| 692 |
+
optin: A["_zod"]["optin"] | B["_zod"]["optin"];
|
| 693 |
+
optout: A["_zod"]["optout"] | B["_zod"]["optout"];
|
| 694 |
+
output: core.output<A> & core.output<B>;
|
| 695 |
+
input: core.input<A> & core.input<B>;
|
| 696 |
+
}
|
| 697 |
+
export interface $ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
| 698 |
+
_zod: $ZodIntersectionInternals<A, B>;
|
| 699 |
+
}
|
| 700 |
+
export declare const $ZodIntersection: core.$constructor<$ZodIntersection>;
|
| 701 |
+
export interface $ZodTupleDef<T extends util.TupleItems = readonly $ZodType[], Rest extends SomeType | null = $ZodType | null> extends $ZodTypeDef {
|
| 702 |
+
type: "tuple";
|
| 703 |
+
items: T;
|
| 704 |
+
rest: Rest;
|
| 705 |
+
}
|
| 706 |
+
export type $InferTupleInputType<T extends util.TupleItems, Rest extends SomeType | null> = [
|
| 707 |
+
...TupleInputTypeWithOptionals<T>,
|
| 708 |
+
...(Rest extends SomeType ? core.input<Rest>[] : [])
|
| 709 |
+
];
|
| 710 |
+
type TupleInputTypeNoOptionals<T extends util.TupleItems> = {
|
| 711 |
+
[k in keyof T]: core.input<T[k]>;
|
| 712 |
+
};
|
| 713 |
+
type TupleInputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
|
| 714 |
+
...infer Prefix extends SomeType[],
|
| 715 |
+
infer Tail extends SomeType
|
| 716 |
+
] ? Tail["_zod"]["optin"] extends "optional" ? [...TupleInputTypeWithOptionals<Prefix>, core.input<Tail>?] : TupleInputTypeNoOptionals<T> : [];
|
| 717 |
+
export type $InferTupleOutputType<T extends util.TupleItems, Rest extends SomeType | null> = [
|
| 718 |
+
...TupleOutputTypeWithOptionals<T>,
|
| 719 |
+
...(Rest extends SomeType ? core.output<Rest>[] : [])
|
| 720 |
+
];
|
| 721 |
+
type TupleOutputTypeNoOptionals<T extends util.TupleItems> = {
|
| 722 |
+
[k in keyof T]: core.output<T[k]>;
|
| 723 |
+
};
|
| 724 |
+
type TupleOutputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
|
| 725 |
+
...infer Prefix extends SomeType[],
|
| 726 |
+
infer Tail extends SomeType
|
| 727 |
+
] ? Tail["_zod"]["optout"] extends "optional" ? [...TupleOutputTypeWithOptionals<Prefix>, core.output<Tail>?] : TupleOutputTypeNoOptionals<T> : [];
|
| 728 |
+
export interface $ZodTupleInternals<T extends util.TupleItems = readonly $ZodType[], Rest extends SomeType | null = $ZodType | null> extends _$ZodTypeInternals {
|
| 729 |
+
def: $ZodTupleDef<T, Rest>;
|
| 730 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueTooBig<unknown[]> | errors.$ZodIssueTooSmall<unknown[]>;
|
| 731 |
+
output: $InferTupleOutputType<T, Rest>;
|
| 732 |
+
input: $InferTupleInputType<T, Rest>;
|
| 733 |
+
}
|
| 734 |
+
export interface $ZodTuple<T extends util.TupleItems = readonly $ZodType[], Rest extends SomeType | null = $ZodType | null> extends $ZodType {
|
| 735 |
+
_zod: $ZodTupleInternals<T, Rest>;
|
| 736 |
+
}
|
| 737 |
+
export declare const $ZodTuple: core.$constructor<$ZodTuple>;
|
| 738 |
+
export type $ZodRecordKey = $ZodType<string | number | symbol, unknown>;
|
| 739 |
+
export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 740 |
+
type: "record";
|
| 741 |
+
keyType: Key;
|
| 742 |
+
valueType: Value;
|
| 743 |
+
/** @default "strict" - errors on keys not matching keyType. "loose" passes through non-matching keys unchanged. */
|
| 744 |
+
mode?: "strict" | "loose";
|
| 745 |
+
}
|
| 746 |
+
export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.output<Key>, core.output<Value>>> : Record<core.output<Key>, core.output<Value>>;
|
| 747 |
+
export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.input<Key> & PropertyKey, core.input<Value>>> : Record<core.input<Key> & PropertyKey, core.input<Value>>;
|
| 748 |
+
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
|
| 749 |
+
def: $ZodRecordDef<Key, Value>;
|
| 750 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
| 751 |
+
optin?: "optional" | undefined;
|
| 752 |
+
optout?: "optional" | undefined;
|
| 753 |
+
}
|
| 754 |
+
export type $partial = {
|
| 755 |
+
"~~partial": true;
|
| 756 |
+
};
|
| 757 |
+
export interface $ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodType {
|
| 758 |
+
_zod: $ZodRecordInternals<Key, Value>;
|
| 759 |
+
}
|
| 760 |
+
export declare const $ZodRecord: core.$constructor<$ZodRecord>;
|
| 761 |
+
export interface $ZodMapDef<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 762 |
+
type: "map";
|
| 763 |
+
keyType: Key;
|
| 764 |
+
valueType: Value;
|
| 765 |
+
}
|
| 766 |
+
export interface $ZodMapInternals<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodTypeInternals<Map<core.output<Key>, core.output<Value>>, Map<core.input<Key>, core.input<Value>>> {
|
| 767 |
+
def: $ZodMapDef<Key, Value>;
|
| 768 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey | errors.$ZodIssueInvalidElement<unknown>;
|
| 769 |
+
optin?: "optional" | undefined;
|
| 770 |
+
optout?: "optional" | undefined;
|
| 771 |
+
}
|
| 772 |
+
export interface $ZodMap<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodType {
|
| 773 |
+
_zod: $ZodMapInternals<Key, Value>;
|
| 774 |
+
}
|
| 775 |
+
export declare const $ZodMap: core.$constructor<$ZodMap>;
|
| 776 |
+
export interface $ZodSetDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 777 |
+
type: "set";
|
| 778 |
+
valueType: T;
|
| 779 |
+
}
|
| 780 |
+
export interface $ZodSetInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<Set<core.output<T>>, Set<core.input<T>>> {
|
| 781 |
+
def: $ZodSetDef<T>;
|
| 782 |
+
isst: errors.$ZodIssueInvalidType;
|
| 783 |
+
optin?: "optional" | undefined;
|
| 784 |
+
optout?: "optional" | undefined;
|
| 785 |
+
}
|
| 786 |
+
export interface $ZodSet<T extends SomeType = $ZodType> extends $ZodType {
|
| 787 |
+
_zod: $ZodSetInternals<T>;
|
| 788 |
+
}
|
| 789 |
+
export declare const $ZodSet: core.$constructor<$ZodSet>;
|
| 790 |
+
export type $InferEnumOutput<T extends util.EnumLike> = T[keyof T] & {};
|
| 791 |
+
export type $InferEnumInput<T extends util.EnumLike> = T[keyof T] & {};
|
| 792 |
+
export interface $ZodEnumDef<T extends util.EnumLike = util.EnumLike> extends $ZodTypeDef {
|
| 793 |
+
type: "enum";
|
| 794 |
+
entries: T;
|
| 795 |
+
}
|
| 796 |
+
export interface $ZodEnumInternals<
|
| 797 |
+
/** @ts-ignore Cast variance */
|
| 798 |
+
out T extends util.EnumLike = util.EnumLike> extends $ZodTypeInternals<$InferEnumOutput<T>, $InferEnumInput<T>> {
|
| 799 |
+
def: $ZodEnumDef<T>;
|
| 800 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 801 |
+
values: util.PrimitiveSet;
|
| 802 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 803 |
+
pattern: RegExp;
|
| 804 |
+
isst: errors.$ZodIssueInvalidValue;
|
| 805 |
+
}
|
| 806 |
+
export interface $ZodEnum<T extends util.EnumLike = util.EnumLike> extends $ZodType {
|
| 807 |
+
_zod: $ZodEnumInternals<T>;
|
| 808 |
+
}
|
| 809 |
+
export declare const $ZodEnum: core.$constructor<$ZodEnum>;
|
| 810 |
+
export interface $ZodLiteralDef<T extends util.Literal> extends $ZodTypeDef {
|
| 811 |
+
type: "literal";
|
| 812 |
+
values: T[];
|
| 813 |
+
}
|
| 814 |
+
export interface $ZodLiteralInternals<T extends util.Literal = util.Literal> extends $ZodTypeInternals<T, T> {
|
| 815 |
+
def: $ZodLiteralDef<T>;
|
| 816 |
+
values: Set<T>;
|
| 817 |
+
pattern: RegExp;
|
| 818 |
+
isst: errors.$ZodIssueInvalidValue;
|
| 819 |
+
}
|
| 820 |
+
export interface $ZodLiteral<T extends util.Literal = util.Literal> extends $ZodType {
|
| 821 |
+
_zod: $ZodLiteralInternals<T>;
|
| 822 |
+
}
|
| 823 |
+
export declare const $ZodLiteral: core.$constructor<$ZodLiteral>;
|
| 824 |
+
type _File = typeof globalThis extends {
|
| 825 |
+
File: infer F extends new (...args: any[]) => any;
|
| 826 |
+
} ? InstanceType<F> : {};
|
| 827 |
+
/** Do not reference this directly. */
|
| 828 |
+
export interface File extends _File {
|
| 829 |
+
readonly type: string;
|
| 830 |
+
readonly size: number;
|
| 831 |
+
}
|
| 832 |
+
export interface $ZodFileDef extends $ZodTypeDef {
|
| 833 |
+
type: "file";
|
| 834 |
+
}
|
| 835 |
+
export interface $ZodFileInternals extends $ZodTypeInternals<File, File> {
|
| 836 |
+
def: $ZodFileDef;
|
| 837 |
+
isst: errors.$ZodIssueInvalidType;
|
| 838 |
+
bag: util.LoosePartial<{
|
| 839 |
+
minimum: number;
|
| 840 |
+
maximum: number;
|
| 841 |
+
mime: util.MimeTypes[];
|
| 842 |
+
}>;
|
| 843 |
+
}
|
| 844 |
+
export interface $ZodFile extends $ZodType {
|
| 845 |
+
_zod: $ZodFileInternals;
|
| 846 |
+
}
|
| 847 |
+
export declare const $ZodFile: core.$constructor<$ZodFile>;
|
| 848 |
+
export interface $ZodTransformDef extends $ZodTypeDef {
|
| 849 |
+
type: "transform";
|
| 850 |
+
transform: (input: unknown, payload: ParsePayload<unknown>) => util.MaybeAsync<unknown>;
|
| 851 |
+
}
|
| 852 |
+
export interface $ZodTransformInternals<O = unknown, I = unknown> extends $ZodTypeInternals<O, I> {
|
| 853 |
+
def: $ZodTransformDef;
|
| 854 |
+
isst: never;
|
| 855 |
+
}
|
| 856 |
+
export interface $ZodTransform<O = unknown, I = unknown> extends $ZodType {
|
| 857 |
+
_zod: $ZodTransformInternals<O, I>;
|
| 858 |
+
}
|
| 859 |
+
export declare const $ZodTransform: core.$constructor<$ZodTransform>;
|
| 860 |
+
export interface $ZodOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 861 |
+
type: "optional";
|
| 862 |
+
innerType: T;
|
| 863 |
+
}
|
| 864 |
+
export interface $ZodOptionalInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T> | undefined, core.input<T> | undefined> {
|
| 865 |
+
def: $ZodOptionalDef<T>;
|
| 866 |
+
optin: "optional";
|
| 867 |
+
optout: "optional";
|
| 868 |
+
isst: never;
|
| 869 |
+
values: T["_zod"]["values"];
|
| 870 |
+
pattern: T["_zod"]["pattern"];
|
| 871 |
+
}
|
| 872 |
+
export interface $ZodOptional<T extends SomeType = $ZodType> extends $ZodType {
|
| 873 |
+
_zod: $ZodOptionalInternals<T>;
|
| 874 |
+
}
|
| 875 |
+
export declare const $ZodOptional: core.$constructor<$ZodOptional>;
|
| 876 |
+
export interface $ZodExactOptionalDef<T extends SomeType = $ZodType> extends $ZodOptionalDef<T> {
|
| 877 |
+
}
|
| 878 |
+
export interface $ZodExactOptionalInternals<T extends SomeType = $ZodType> extends $ZodOptionalInternals<T> {
|
| 879 |
+
def: $ZodExactOptionalDef<T>;
|
| 880 |
+
output: core.output<T>;
|
| 881 |
+
input: core.input<T>;
|
| 882 |
+
}
|
| 883 |
+
export interface $ZodExactOptional<T extends SomeType = $ZodType> extends $ZodType {
|
| 884 |
+
_zod: $ZodExactOptionalInternals<T>;
|
| 885 |
+
}
|
| 886 |
+
export declare const $ZodExactOptional: core.$constructor<$ZodExactOptional>;
|
| 887 |
+
export interface $ZodNullableDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 888 |
+
type: "nullable";
|
| 889 |
+
innerType: T;
|
| 890 |
+
}
|
| 891 |
+
export interface $ZodNullableInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T> | null, core.input<T> | null> {
|
| 892 |
+
def: $ZodNullableDef<T>;
|
| 893 |
+
optin: T["_zod"]["optin"];
|
| 894 |
+
optout: T["_zod"]["optout"];
|
| 895 |
+
isst: never;
|
| 896 |
+
values: T["_zod"]["values"];
|
| 897 |
+
pattern: T["_zod"]["pattern"];
|
| 898 |
+
}
|
| 899 |
+
export interface $ZodNullable<T extends SomeType = $ZodType> extends $ZodType {
|
| 900 |
+
_zod: $ZodNullableInternals<T>;
|
| 901 |
+
}
|
| 902 |
+
export declare const $ZodNullable: core.$constructor<$ZodNullable>;
|
| 903 |
+
export interface $ZodDefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 904 |
+
type: "default";
|
| 905 |
+
innerType: T;
|
| 906 |
+
/** The default value. May be a getter. */
|
| 907 |
+
defaultValue: util.NoUndefined<core.output<T>>;
|
| 908 |
+
}
|
| 909 |
+
export interface $ZodDefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
|
| 910 |
+
def: $ZodDefaultDef<T>;
|
| 911 |
+
optin: "optional";
|
| 912 |
+
optout?: "optional" | undefined;
|
| 913 |
+
isst: never;
|
| 914 |
+
values: T["_zod"]["values"];
|
| 915 |
+
}
|
| 916 |
+
export interface $ZodDefault<T extends SomeType = $ZodType> extends $ZodType {
|
| 917 |
+
_zod: $ZodDefaultInternals<T>;
|
| 918 |
+
}
|
| 919 |
+
export declare const $ZodDefault: core.$constructor<$ZodDefault>;
|
| 920 |
+
export interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 921 |
+
type: "prefault";
|
| 922 |
+
innerType: T;
|
| 923 |
+
/** The default value. May be a getter. */
|
| 924 |
+
defaultValue: core.input<T>;
|
| 925 |
+
}
|
| 926 |
+
export interface $ZodPrefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
|
| 927 |
+
def: $ZodPrefaultDef<T>;
|
| 928 |
+
optin: "optional";
|
| 929 |
+
optout?: "optional" | undefined;
|
| 930 |
+
isst: never;
|
| 931 |
+
values: T["_zod"]["values"];
|
| 932 |
+
}
|
| 933 |
+
export interface $ZodPrefault<T extends SomeType = $ZodType> extends $ZodType {
|
| 934 |
+
_zod: $ZodPrefaultInternals<T>;
|
| 935 |
+
}
|
| 936 |
+
export declare const $ZodPrefault: core.$constructor<$ZodPrefault>;
|
| 937 |
+
export interface $ZodNonOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 938 |
+
type: "nonoptional";
|
| 939 |
+
innerType: T;
|
| 940 |
+
}
|
| 941 |
+
export interface $ZodNonOptionalInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, util.NoUndefined<core.input<T>>> {
|
| 942 |
+
def: $ZodNonOptionalDef<T>;
|
| 943 |
+
isst: errors.$ZodIssueInvalidType;
|
| 944 |
+
values: T["_zod"]["values"];
|
| 945 |
+
optin: "optional" | undefined;
|
| 946 |
+
optout: "optional" | undefined;
|
| 947 |
+
}
|
| 948 |
+
export interface $ZodNonOptional<T extends SomeType = $ZodType> extends $ZodType {
|
| 949 |
+
_zod: $ZodNonOptionalInternals<T>;
|
| 950 |
+
}
|
| 951 |
+
export declare const $ZodNonOptional: core.$constructor<$ZodNonOptional>;
|
| 952 |
+
export interface $ZodSuccessDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 953 |
+
type: "success";
|
| 954 |
+
innerType: T;
|
| 955 |
+
}
|
| 956 |
+
export interface $ZodSuccessInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<boolean, core.input<T>> {
|
| 957 |
+
def: $ZodSuccessDef<T>;
|
| 958 |
+
isst: never;
|
| 959 |
+
optin: T["_zod"]["optin"];
|
| 960 |
+
optout: "optional" | undefined;
|
| 961 |
+
}
|
| 962 |
+
export interface $ZodSuccess<T extends SomeType = $ZodType> extends $ZodType {
|
| 963 |
+
_zod: $ZodSuccessInternals<T>;
|
| 964 |
+
}
|
| 965 |
+
export declare const $ZodSuccess: core.$constructor<$ZodSuccess>;
|
| 966 |
+
export interface $ZodCatchCtx extends ParsePayload {
|
| 967 |
+
/** @deprecated Use `ctx.issues` */
|
| 968 |
+
error: {
|
| 969 |
+
issues: errors.$ZodIssue[];
|
| 970 |
+
};
|
| 971 |
+
/** @deprecated Use `ctx.value` */
|
| 972 |
+
input: unknown;
|
| 973 |
+
}
|
| 974 |
+
export interface $ZodCatchDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 975 |
+
type: "catch";
|
| 976 |
+
innerType: T;
|
| 977 |
+
catchValue: (ctx: $ZodCatchCtx) => unknown;
|
| 978 |
+
}
|
| 979 |
+
export interface $ZodCatchInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, core.input<T>> {
|
| 980 |
+
def: $ZodCatchDef<T>;
|
| 981 |
+
optin: T["_zod"]["optin"];
|
| 982 |
+
optout: T["_zod"]["optout"];
|
| 983 |
+
isst: never;
|
| 984 |
+
values: T["_zod"]["values"];
|
| 985 |
+
}
|
| 986 |
+
export interface $ZodCatch<T extends SomeType = $ZodType> extends $ZodType {
|
| 987 |
+
_zod: $ZodCatchInternals<T>;
|
| 988 |
+
}
|
| 989 |
+
export declare const $ZodCatch: core.$constructor<$ZodCatch>;
|
| 990 |
+
export interface $ZodNaNDef extends $ZodTypeDef {
|
| 991 |
+
type: "nan";
|
| 992 |
+
}
|
| 993 |
+
export interface $ZodNaNInternals extends $ZodTypeInternals<number, number> {
|
| 994 |
+
def: $ZodNaNDef;
|
| 995 |
+
isst: errors.$ZodIssueInvalidType;
|
| 996 |
+
}
|
| 997 |
+
export interface $ZodNaN extends $ZodType {
|
| 998 |
+
_zod: $ZodNaNInternals;
|
| 999 |
+
}
|
| 1000 |
+
export declare const $ZodNaN: core.$constructor<$ZodNaN>;
|
| 1001 |
+
export interface $ZodPipeDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 1002 |
+
type: "pipe";
|
| 1003 |
+
in: A;
|
| 1004 |
+
out: B;
|
| 1005 |
+
/** Only defined inside $ZodCodec instances. */
|
| 1006 |
+
transform?: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
|
| 1007 |
+
/** Only defined inside $ZodCodec instances. */
|
| 1008 |
+
reverseTransform?: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
|
| 1009 |
+
}
|
| 1010 |
+
export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
|
| 1011 |
+
def: $ZodPipeDef<A, B>;
|
| 1012 |
+
isst: never;
|
| 1013 |
+
values: A["_zod"]["values"];
|
| 1014 |
+
optin: A["_zod"]["optin"];
|
| 1015 |
+
optout: B["_zod"]["optout"];
|
| 1016 |
+
propValues: A["_zod"]["propValues"];
|
| 1017 |
+
}
|
| 1018 |
+
export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
| 1019 |
+
_zod: $ZodPipeInternals<A, B>;
|
| 1020 |
+
}
|
| 1021 |
+
export declare const $ZodPipe: core.$constructor<$ZodPipe>;
|
| 1022 |
+
export interface $ZodCodecDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodPipeDef<A, B> {
|
| 1023 |
+
transform: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
|
| 1024 |
+
reverseTransform: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
|
| 1025 |
+
}
|
| 1026 |
+
export interface $ZodCodecInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
|
| 1027 |
+
def: $ZodCodecDef<A, B>;
|
| 1028 |
+
isst: never;
|
| 1029 |
+
values: A["_zod"]["values"];
|
| 1030 |
+
optin: A["_zod"]["optin"];
|
| 1031 |
+
optout: B["_zod"]["optout"];
|
| 1032 |
+
propValues: A["_zod"]["propValues"];
|
| 1033 |
+
}
|
| 1034 |
+
export interface $ZodCodec<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
| 1035 |
+
_zod: $ZodCodecInternals<A, B>;
|
| 1036 |
+
}
|
| 1037 |
+
export declare const $ZodCodec: core.$constructor<$ZodCodec>;
|
| 1038 |
+
export interface $ZodPreprocessDef<B extends SomeType = $ZodType> extends $ZodPipeDef<$ZodTransform, B> {
|
| 1039 |
+
in: $ZodTransform;
|
| 1040 |
+
out: B;
|
| 1041 |
+
}
|
| 1042 |
+
export interface $ZodPreprocessInternals<B extends SomeType = $ZodType> extends $ZodPipeInternals<$ZodTransform, B> {
|
| 1043 |
+
def: $ZodPreprocessDef<B>;
|
| 1044 |
+
optin: B["_zod"]["optin"];
|
| 1045 |
+
optout: B["_zod"]["optout"];
|
| 1046 |
+
}
|
| 1047 |
+
export interface $ZodPreprocess<B extends SomeType = $ZodType> extends $ZodPipe<$ZodTransform, B> {
|
| 1048 |
+
_zod: $ZodPreprocessInternals<B>;
|
| 1049 |
+
}
|
| 1050 |
+
export declare const $ZodPreprocess: core.$constructor<$ZodPreprocess>;
|
| 1051 |
+
export interface $ZodReadonlyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 1052 |
+
type: "readonly";
|
| 1053 |
+
innerType: T;
|
| 1054 |
+
}
|
| 1055 |
+
export interface $ZodReadonlyInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.MakeReadonly<core.output<T>>, util.MakeReadonly<core.input<T>>> {
|
| 1056 |
+
def: $ZodReadonlyDef<T>;
|
| 1057 |
+
optin: T["_zod"]["optin"];
|
| 1058 |
+
optout: T["_zod"]["optout"];
|
| 1059 |
+
isst: never;
|
| 1060 |
+
propValues: T["_zod"]["propValues"];
|
| 1061 |
+
values: T["_zod"]["values"];
|
| 1062 |
+
}
|
| 1063 |
+
export interface $ZodReadonly<T extends SomeType = $ZodType> extends $ZodType {
|
| 1064 |
+
_zod: $ZodReadonlyInternals<T>;
|
| 1065 |
+
}
|
| 1066 |
+
export declare const $ZodReadonly: core.$constructor<$ZodReadonly>;
|
| 1067 |
+
export interface $ZodTemplateLiteralDef extends $ZodTypeDef {
|
| 1068 |
+
type: "template_literal";
|
| 1069 |
+
parts: $ZodTemplateLiteralPart[];
|
| 1070 |
+
format?: string | undefined;
|
| 1071 |
+
}
|
| 1072 |
+
export interface $ZodTemplateLiteralInternals<Template extends string = string> extends $ZodTypeInternals<Template, Template> {
|
| 1073 |
+
pattern: RegExp;
|
| 1074 |
+
def: $ZodTemplateLiteralDef;
|
| 1075 |
+
isst: errors.$ZodIssueInvalidType;
|
| 1076 |
+
}
|
| 1077 |
+
export interface $ZodTemplateLiteral<Template extends string = string> extends $ZodType {
|
| 1078 |
+
_zod: $ZodTemplateLiteralInternals<Template>;
|
| 1079 |
+
}
|
| 1080 |
+
type LiteralPart = Exclude<util.Literal, symbol>;
|
| 1081 |
+
interface SchemaPartInternals extends $ZodTypeInternals<LiteralPart, LiteralPart> {
|
| 1082 |
+
pattern: RegExp;
|
| 1083 |
+
}
|
| 1084 |
+
interface SchemaPart extends $ZodType {
|
| 1085 |
+
_zod: SchemaPartInternals;
|
| 1086 |
+
}
|
| 1087 |
+
export type $ZodTemplateLiteralPart = LiteralPart | SchemaPart;
|
| 1088 |
+
type UndefinedToEmptyString<T> = T extends undefined ? "" : T;
|
| 1089 |
+
type AppendToTemplateLiteral<Template extends string, Suffix extends LiteralPart | $ZodType> = Suffix extends LiteralPart ? `${Template}${UndefinedToEmptyString<Suffix>}` : Suffix extends $ZodType ? `${Template}${core.output<Suffix> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}` : never;
|
| 1090 |
+
export type ConcatenateTupleOfStrings<T extends string[]> = T extends [
|
| 1091 |
+
infer First extends string,
|
| 1092 |
+
...infer Rest extends string[]
|
| 1093 |
+
] ? Rest extends string[] ? First extends "" ? ConcatenateTupleOfStrings<Rest> : `${First}${ConcatenateTupleOfStrings<Rest>}` : never : "";
|
| 1094 |
+
export type ConvertPartsToStringTuple<Parts extends $ZodTemplateLiteralPart[]> = {
|
| 1095 |
+
[K in keyof Parts]: Parts[K] extends LiteralPart ? `${UndefinedToEmptyString<Parts[K]>}` : Parts[K] extends $ZodType ? `${core.output<Parts[K]> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}` : never;
|
| 1096 |
+
};
|
| 1097 |
+
export type ToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = ConcatenateTupleOfStrings<ConvertPartsToStringTuple<Parts>>;
|
| 1098 |
+
export type $PartsToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = [] extends Parts ? `` : Parts extends [...infer Rest, infer Last extends $ZodTemplateLiteralPart] ? Rest extends $ZodTemplateLiteralPart[] ? AppendToTemplateLiteral<$PartsToTemplateLiteral<Rest>, Last> : never : never;
|
| 1099 |
+
export declare const $ZodTemplateLiteral: core.$constructor<$ZodTemplateLiteral>;
|
| 1100 |
+
export type $ZodFunctionArgs = $ZodType<unknown[], unknown[]>;
|
| 1101 |
+
export type $ZodFunctionIn = $ZodFunctionArgs;
|
| 1102 |
+
export type $ZodFunctionOut = $ZodType;
|
| 1103 |
+
export type $InferInnerFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>) => core.input<Returns>;
|
| 1104 |
+
export type $InferInnerFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>) => util.MaybeAsync<core.input<Returns>>;
|
| 1105 |
+
export type $InferOuterFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>) => core.output<Returns>;
|
| 1106 |
+
export type $InferOuterFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>) => Promise<core.output<Returns>>;
|
| 1107 |
+
export interface $ZodFunctionDef<In extends $ZodFunctionIn = $ZodFunctionIn, Out extends $ZodFunctionOut = $ZodFunctionOut> extends $ZodTypeDef {
|
| 1108 |
+
type: "function";
|
| 1109 |
+
input: In;
|
| 1110 |
+
output: Out;
|
| 1111 |
+
}
|
| 1112 |
+
export interface $ZodFunctionInternals<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> extends $ZodTypeInternals<$InferOuterFunctionType<Args, Returns>, $InferInnerFunctionType<Args, Returns>> {
|
| 1113 |
+
def: $ZodFunctionDef<Args, Returns>;
|
| 1114 |
+
isst: errors.$ZodIssueInvalidType;
|
| 1115 |
+
}
|
| 1116 |
+
export interface $ZodFunction<Args extends $ZodFunctionIn = $ZodFunctionIn, Returns extends $ZodFunctionOut = $ZodFunctionOut> extends $ZodType<any, any, $ZodFunctionInternals<Args, Returns>> {
|
| 1117 |
+
/** @deprecated */
|
| 1118 |
+
_def: $ZodFunctionDef<Args, Returns>;
|
| 1119 |
+
_input: $InferInnerFunctionType<Args, Returns>;
|
| 1120 |
+
_output: $InferOuterFunctionType<Args, Returns>;
|
| 1121 |
+
implement<F extends $InferInnerFunctionType<Args, Returns>>(func: F): (...args: Parameters<this["_output"]>) => ReturnType<F> extends ReturnType<this["_output"]> ? ReturnType<F> : ReturnType<this["_output"]>;
|
| 1122 |
+
implementAsync<F extends $InferInnerFunctionTypeAsync<Args, Returns>>(func: F): F extends $InferOuterFunctionTypeAsync<Args, Returns> ? F : $InferOuterFunctionTypeAsync<Args, Returns>;
|
| 1123 |
+
input<const Items extends util.TupleItems, const Rest extends $ZodFunctionOut = $ZodFunctionOut>(args: Items, rest?: Rest): $ZodFunction<$ZodTuple<Items, Rest>, Returns>;
|
| 1124 |
+
input<NewArgs extends $ZodFunctionIn>(args: NewArgs): $ZodFunction<NewArgs, Returns>;
|
| 1125 |
+
input(...args: any[]): $ZodFunction<any, Returns>;
|
| 1126 |
+
output<NewReturns extends $ZodType>(output: NewReturns): $ZodFunction<Args, NewReturns>;
|
| 1127 |
+
}
|
| 1128 |
+
export interface $ZodFunctionParams<I extends $ZodFunctionIn, O extends $ZodType> {
|
| 1129 |
+
input?: I;
|
| 1130 |
+
output?: O;
|
| 1131 |
+
}
|
| 1132 |
+
export declare const $ZodFunction: core.$constructor<$ZodFunction>;
|
| 1133 |
+
export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 1134 |
+
type: "promise";
|
| 1135 |
+
innerType: T;
|
| 1136 |
+
}
|
| 1137 |
+
export interface $ZodPromiseInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<Promise<core.output<T>>, util.MaybeAsync<core.input<T>>> {
|
| 1138 |
+
def: $ZodPromiseDef<T>;
|
| 1139 |
+
isst: never;
|
| 1140 |
+
}
|
| 1141 |
+
export interface $ZodPromise<T extends SomeType = $ZodType> extends $ZodType {
|
| 1142 |
+
_zod: $ZodPromiseInternals<T>;
|
| 1143 |
+
}
|
| 1144 |
+
export declare const $ZodPromise: core.$constructor<$ZodPromise>;
|
| 1145 |
+
export interface $ZodLazyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 1146 |
+
type: "lazy";
|
| 1147 |
+
getter: () => T;
|
| 1148 |
+
}
|
| 1149 |
+
export interface $ZodLazyInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, core.input<T>> {
|
| 1150 |
+
def: $ZodLazyDef<T>;
|
| 1151 |
+
isst: never;
|
| 1152 |
+
/** Auto-cached way to retrieve the inner schema */
|
| 1153 |
+
innerType: T;
|
| 1154 |
+
pattern: T["_zod"]["pattern"];
|
| 1155 |
+
propValues: T["_zod"]["propValues"];
|
| 1156 |
+
optin: T["_zod"]["optin"];
|
| 1157 |
+
optout: T["_zod"]["optout"];
|
| 1158 |
+
}
|
| 1159 |
+
export interface $ZodLazy<T extends SomeType = $ZodType> extends $ZodType {
|
| 1160 |
+
_zod: $ZodLazyInternals<T>;
|
| 1161 |
+
}
|
| 1162 |
+
export declare const $ZodLazy: core.$constructor<$ZodLazy>;
|
| 1163 |
+
export interface $ZodCustomDef<O = unknown> extends $ZodTypeDef, checks.$ZodCheckDef {
|
| 1164 |
+
type: "custom";
|
| 1165 |
+
check: "custom";
|
| 1166 |
+
path?: PropertyKey[] | undefined;
|
| 1167 |
+
error?: errors.$ZodErrorMap | undefined;
|
| 1168 |
+
params?: Record<string, any> | undefined;
|
| 1169 |
+
fn: (arg: O) => unknown;
|
| 1170 |
+
}
|
| 1171 |
+
export interface $ZodCustomInternals<O = unknown, I = unknown> extends $ZodTypeInternals<O, I>, checks.$ZodCheckInternals<O> {
|
| 1172 |
+
def: $ZodCustomDef;
|
| 1173 |
+
issc: errors.$ZodIssue;
|
| 1174 |
+
isst: never;
|
| 1175 |
+
bag: util.LoosePartial<{
|
| 1176 |
+
Class: typeof util.Class;
|
| 1177 |
+
}>;
|
| 1178 |
+
}
|
| 1179 |
+
export interface $ZodCustom<O = unknown, I = unknown> extends $ZodType {
|
| 1180 |
+
_zod: $ZodCustomInternals<O, I>;
|
| 1181 |
+
}
|
| 1182 |
+
export declare const $ZodCustom: core.$constructor<$ZodCustom>;
|
| 1183 |
+
export type $ZodTypes = $ZodString | $ZodNumber | $ZodBigInt | $ZodBoolean | $ZodDate | $ZodSymbol | $ZodUndefined | $ZodNullable | $ZodNull | $ZodAny | $ZodUnknown | $ZodNever | $ZodVoid | $ZodArray | $ZodObject | $ZodUnion | $ZodIntersection | $ZodTuple | $ZodRecord | $ZodMap | $ZodSet | $ZodLiteral | $ZodEnum | $ZodFunction | $ZodPromise | $ZodLazy | $ZodOptional | $ZodDefault | $ZodPrefault | $ZodTemplateLiteral | $ZodCustom | $ZodTransform | $ZodNonOptional | $ZodReadonly | $ZodNaN | $ZodPipe | $ZodSuccess | $ZodCatch | $ZodFile;
|
| 1184 |
+
export type $ZodStringFormatTypes = $ZodGUID | $ZodUUID | $ZodEmail | $ZodURL | $ZodEmoji | $ZodNanoID | $ZodCUID | $ZodCUID2 | $ZodULID | $ZodXID | $ZodKSUID | $ZodISODateTime | $ZodISODate | $ZodISOTime | $ZodISODuration | $ZodIPv4 | $ZodIPv6 | $ZodMAC | $ZodCIDRv4 | $ZodCIDRv6 | $ZodBase64 | $ZodBase64URL | $ZodE164 | $ZodJWT | $ZodCustomStringFormat<"hex"> | $ZodCustomStringFormat<util.HashFormat> | $ZodCustomStringFormat<"hostname">;
|
node_modules/zod/v4/core/schemas.d.ts
ADDED
|
@@ -0,0 +1,1184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as checks from "./checks.js";
|
| 2 |
+
import * as core from "./core.js";
|
| 3 |
+
import type * as errors from "./errors.js";
|
| 4 |
+
import type * as JSONSchema from "./json-schema.js";
|
| 5 |
+
import type { StandardSchemaV1 } from "./standard-schema.js";
|
| 6 |
+
import type { ProcessParams, ToJSONSchemaContext } from "./to-json-schema.js";
|
| 7 |
+
import * as util from "./util.js";
|
| 8 |
+
import { version } from "./versions.js";
|
| 9 |
+
export interface ParseContext<T extends errors.$ZodIssueBase = never> {
|
| 10 |
+
/** Customize error messages. */
|
| 11 |
+
readonly error?: errors.$ZodErrorMap<T>;
|
| 12 |
+
/** Include the `input` field in issue objects. Default `false`. */
|
| 13 |
+
readonly reportInput?: boolean;
|
| 14 |
+
/** Skip eval-based fast path. Default `false`. */
|
| 15 |
+
readonly jitless?: boolean;
|
| 16 |
+
}
|
| 17 |
+
/** @internal */
|
| 18 |
+
export interface ParseContextInternal<T extends errors.$ZodIssueBase = never> extends ParseContext<T> {
|
| 19 |
+
readonly async?: boolean | undefined;
|
| 20 |
+
readonly direction?: "forward" | "backward";
|
| 21 |
+
readonly skipChecks?: boolean;
|
| 22 |
+
}
|
| 23 |
+
export interface ParsePayload<T = unknown> {
|
| 24 |
+
value: T;
|
| 25 |
+
issues: errors.$ZodRawIssue[];
|
| 26 |
+
/** A way to mark a whole payload as aborted. Used in codecs/pipes. */
|
| 27 |
+
aborted?: boolean;
|
| 28 |
+
/** @internal Marks a value as a fallback that an outer wrapper (e.g.
|
| 29 |
+
* $ZodOptional) may override with its own interpretation when input was
|
| 30 |
+
* undefined. Set by $ZodCatch when catchValue substitutes and by every
|
| 31 |
+
* $ZodTransform invocation. */
|
| 32 |
+
fallback?: boolean | undefined;
|
| 33 |
+
}
|
| 34 |
+
export type CheckFn<T> = (input: ParsePayload<T>) => util.MaybeAsync<void>;
|
| 35 |
+
export interface $ZodTypeDef {
|
| 36 |
+
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";
|
| 37 |
+
error?: errors.$ZodErrorMap<never> | undefined;
|
| 38 |
+
checks?: checks.$ZodCheck<never>[];
|
| 39 |
+
}
|
| 40 |
+
export interface _$ZodTypeInternals {
|
| 41 |
+
/** The `@zod/core` version of this schema */
|
| 42 |
+
version: typeof version;
|
| 43 |
+
/** Schema definition. */
|
| 44 |
+
def: $ZodTypeDef;
|
| 45 |
+
/** @internal Randomly generated ID for this schema. */
|
| 46 |
+
/** @internal List of deferred initializers. */
|
| 47 |
+
deferred: util.AnyFunc[] | undefined;
|
| 48 |
+
/** @internal Parses input and runs all checks (refinements). */
|
| 49 |
+
run(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
|
| 50 |
+
/** @internal Parses input, doesn't run checks. */
|
| 51 |
+
parse(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
|
| 52 |
+
/** @internal Stores identifiers for the set of traits implemented by this schema. */
|
| 53 |
+
traits: Set<string>;
|
| 54 |
+
/** @internal Indicates that a schema output type should be considered optional inside objects.
|
| 55 |
+
* @default Required
|
| 56 |
+
*/
|
| 57 |
+
/** @internal */
|
| 58 |
+
optin?: "optional" | undefined;
|
| 59 |
+
/** @internal */
|
| 60 |
+
optout?: "optional" | undefined;
|
| 61 |
+
/** @internal The set of literal values that will pass validation. Must be an exhaustive set. Used to determine optionality in z.record().
|
| 62 |
+
*
|
| 63 |
+
* Defined on: enum, const, literal, null, undefined
|
| 64 |
+
* Passthrough: optional, nullable, branded, default, catch, pipe
|
| 65 |
+
* Todo: unions?
|
| 66 |
+
*/
|
| 67 |
+
values?: util.PrimitiveSet | undefined;
|
| 68 |
+
/** Default value bubbled up from */
|
| 69 |
+
/** @internal A set of literal discriminators used for the fast path in discriminated unions. */
|
| 70 |
+
propValues?: util.PropValues | undefined;
|
| 71 |
+
/** @internal This flag indicates that a schema validation can be represented with a regular expression. Used to determine allowable schemas in z.templateLiteral(). */
|
| 72 |
+
pattern: RegExp | undefined;
|
| 73 |
+
/** @internal The constructor function of this schema. */
|
| 74 |
+
constr: new (def: any) => $ZodType;
|
| 75 |
+
/** @internal A catchall object for bag metadata related to this schema. Commonly modified by checks using `onattach`. */
|
| 76 |
+
bag: Record<string, unknown>;
|
| 77 |
+
/** @internal The set of issues this schema might throw during type checking. */
|
| 78 |
+
isst: errors.$ZodIssueBase;
|
| 79 |
+
/** @internal Subject to change, not a public API. */
|
| 80 |
+
processJSONSchema?: ((ctx: ToJSONSchemaContext, json: JSONSchema.BaseSchema, params: ProcessParams) => void) | undefined;
|
| 81 |
+
/** An optional method used to override `toJSONSchema` logic. */
|
| 82 |
+
toJSONSchema?: () => unknown;
|
| 83 |
+
/** @internal The parent of this schema. Only set during certain clone operations. */
|
| 84 |
+
parent?: $ZodType | undefined;
|
| 85 |
+
}
|
| 86 |
+
/** @internal */
|
| 87 |
+
export interface $ZodTypeInternals<out O = unknown, out I = unknown> extends _$ZodTypeInternals {
|
| 88 |
+
/** @internal The inferred output type */
|
| 89 |
+
output: O;
|
| 90 |
+
/** @internal The inferred input type */
|
| 91 |
+
input: I;
|
| 92 |
+
}
|
| 93 |
+
export type $ZodStandardSchema<T> = StandardSchemaV1.Props<core.input<T>, core.output<T>>;
|
| 94 |
+
export type SomeType = {
|
| 95 |
+
_zod: _$ZodTypeInternals;
|
| 96 |
+
};
|
| 97 |
+
export interface $ZodType<O = unknown, I = unknown, Internals extends $ZodTypeInternals<O, I> = $ZodTypeInternals<O, I>> {
|
| 98 |
+
_zod: Internals;
|
| 99 |
+
"~standard": $ZodStandardSchema<this>;
|
| 100 |
+
}
|
| 101 |
+
export interface _$ZodType<T extends $ZodTypeInternals = $ZodTypeInternals> extends $ZodType<T["output"], T["input"], T> {
|
| 102 |
+
}
|
| 103 |
+
export declare const $ZodType: core.$constructor<$ZodType>;
|
| 104 |
+
export { clone } from "./util.js";
|
| 105 |
+
export interface $ZodStringDef extends $ZodTypeDef {
|
| 106 |
+
type: "string";
|
| 107 |
+
coerce?: boolean;
|
| 108 |
+
checks?: checks.$ZodCheck<string>[];
|
| 109 |
+
}
|
| 110 |
+
export interface $ZodStringInternals<Input> extends $ZodTypeInternals<string, Input> {
|
| 111 |
+
def: $ZodStringDef;
|
| 112 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 113 |
+
pattern: RegExp;
|
| 114 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 115 |
+
isst: errors.$ZodIssueInvalidType;
|
| 116 |
+
bag: util.LoosePartial<{
|
| 117 |
+
minimum: number;
|
| 118 |
+
maximum: number;
|
| 119 |
+
patterns: Set<RegExp>;
|
| 120 |
+
format: string;
|
| 121 |
+
contentEncoding: string;
|
| 122 |
+
}>;
|
| 123 |
+
}
|
| 124 |
+
export interface $ZodString<Input = unknown> extends _$ZodType<$ZodStringInternals<Input>> {
|
| 125 |
+
}
|
| 126 |
+
export declare const $ZodString: core.$constructor<$ZodString>;
|
| 127 |
+
export interface $ZodStringFormatDef<Format extends string = string> extends $ZodStringDef, checks.$ZodCheckStringFormatDef<Format> {
|
| 128 |
+
}
|
| 129 |
+
export interface $ZodStringFormatInternals<Format extends string = string> extends $ZodStringInternals<string>, checks.$ZodCheckStringFormatInternals {
|
| 130 |
+
def: $ZodStringFormatDef<Format>;
|
| 131 |
+
}
|
| 132 |
+
export interface $ZodStringFormat<Format extends string = string> extends $ZodType {
|
| 133 |
+
_zod: $ZodStringFormatInternals<Format>;
|
| 134 |
+
}
|
| 135 |
+
export declare const $ZodStringFormat: core.$constructor<$ZodStringFormat>;
|
| 136 |
+
export interface $ZodGUIDDef extends $ZodStringFormatDef<"guid"> {
|
| 137 |
+
}
|
| 138 |
+
export interface $ZodGUIDInternals extends $ZodStringFormatInternals<"guid"> {
|
| 139 |
+
}
|
| 140 |
+
export interface $ZodGUID extends $ZodType {
|
| 141 |
+
_zod: $ZodGUIDInternals;
|
| 142 |
+
}
|
| 143 |
+
export declare const $ZodGUID: core.$constructor<$ZodGUID>;
|
| 144 |
+
export interface $ZodUUIDDef extends $ZodStringFormatDef<"uuid"> {
|
| 145 |
+
version?: "v1" | "v2" | "v3" | "v4" | "v5" | "v6" | "v7" | "v8";
|
| 146 |
+
}
|
| 147 |
+
export interface $ZodUUIDInternals extends $ZodStringFormatInternals<"uuid"> {
|
| 148 |
+
def: $ZodUUIDDef;
|
| 149 |
+
}
|
| 150 |
+
export interface $ZodUUID extends $ZodType {
|
| 151 |
+
_zod: $ZodUUIDInternals;
|
| 152 |
+
}
|
| 153 |
+
export declare const $ZodUUID: core.$constructor<$ZodUUID>;
|
| 154 |
+
export interface $ZodEmailDef extends $ZodStringFormatDef<"email"> {
|
| 155 |
+
}
|
| 156 |
+
export interface $ZodEmailInternals extends $ZodStringFormatInternals<"email"> {
|
| 157 |
+
}
|
| 158 |
+
export interface $ZodEmail extends $ZodType {
|
| 159 |
+
_zod: $ZodEmailInternals;
|
| 160 |
+
}
|
| 161 |
+
export declare const $ZodEmail: core.$constructor<$ZodEmail>;
|
| 162 |
+
export interface $ZodURLDef extends $ZodStringFormatDef<"url"> {
|
| 163 |
+
hostname?: RegExp | undefined;
|
| 164 |
+
protocol?: RegExp | undefined;
|
| 165 |
+
normalize?: boolean | undefined;
|
| 166 |
+
}
|
| 167 |
+
export interface $ZodURLInternals extends $ZodStringFormatInternals<"url"> {
|
| 168 |
+
def: $ZodURLDef;
|
| 169 |
+
}
|
| 170 |
+
export interface $ZodURL extends $ZodType {
|
| 171 |
+
_zod: $ZodURLInternals;
|
| 172 |
+
}
|
| 173 |
+
export declare const $ZodURL: core.$constructor<$ZodURL>;
|
| 174 |
+
export interface $ZodEmojiDef extends $ZodStringFormatDef<"emoji"> {
|
| 175 |
+
}
|
| 176 |
+
export interface $ZodEmojiInternals extends $ZodStringFormatInternals<"emoji"> {
|
| 177 |
+
}
|
| 178 |
+
export interface $ZodEmoji extends $ZodType {
|
| 179 |
+
_zod: $ZodEmojiInternals;
|
| 180 |
+
}
|
| 181 |
+
export declare const $ZodEmoji: core.$constructor<$ZodEmoji>;
|
| 182 |
+
export interface $ZodNanoIDDef extends $ZodStringFormatDef<"nanoid"> {
|
| 183 |
+
}
|
| 184 |
+
export interface $ZodNanoIDInternals extends $ZodStringFormatInternals<"nanoid"> {
|
| 185 |
+
}
|
| 186 |
+
export interface $ZodNanoID extends $ZodType {
|
| 187 |
+
_zod: $ZodNanoIDInternals;
|
| 188 |
+
}
|
| 189 |
+
export declare const $ZodNanoID: core.$constructor<$ZodNanoID>;
|
| 190 |
+
/**
|
| 191 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 192 |
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
| 193 |
+
* See https://github.com/paralleldrive/cuid.
|
| 194 |
+
*/
|
| 195 |
+
export interface $ZodCUIDDef extends $ZodStringFormatDef<"cuid"> {
|
| 196 |
+
}
|
| 197 |
+
/**
|
| 198 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 199 |
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
| 200 |
+
* See https://github.com/paralleldrive/cuid.
|
| 201 |
+
*/
|
| 202 |
+
export interface $ZodCUIDInternals extends $ZodStringFormatInternals<"cuid"> {
|
| 203 |
+
}
|
| 204 |
+
/**
|
| 205 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 206 |
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
| 207 |
+
* See https://github.com/paralleldrive/cuid.
|
| 208 |
+
*/
|
| 209 |
+
export interface $ZodCUID extends $ZodType {
|
| 210 |
+
_zod: $ZodCUIDInternals;
|
| 211 |
+
}
|
| 212 |
+
/**
|
| 213 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 214 |
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
| 215 |
+
* See https://github.com/paralleldrive/cuid.
|
| 216 |
+
*/
|
| 217 |
+
export declare const $ZodCUID: core.$constructor<$ZodCUID>;
|
| 218 |
+
export interface $ZodCUID2Def extends $ZodStringFormatDef<"cuid2"> {
|
| 219 |
+
}
|
| 220 |
+
export interface $ZodCUID2Internals extends $ZodStringFormatInternals<"cuid2"> {
|
| 221 |
+
}
|
| 222 |
+
export interface $ZodCUID2 extends $ZodType {
|
| 223 |
+
_zod: $ZodCUID2Internals;
|
| 224 |
+
}
|
| 225 |
+
export declare const $ZodCUID2: core.$constructor<$ZodCUID2>;
|
| 226 |
+
export interface $ZodULIDDef extends $ZodStringFormatDef<"ulid"> {
|
| 227 |
+
}
|
| 228 |
+
export interface $ZodULIDInternals extends $ZodStringFormatInternals<"ulid"> {
|
| 229 |
+
}
|
| 230 |
+
export interface $ZodULID extends $ZodType {
|
| 231 |
+
_zod: $ZodULIDInternals;
|
| 232 |
+
}
|
| 233 |
+
export declare const $ZodULID: core.$constructor<$ZodULID>;
|
| 234 |
+
export interface $ZodXIDDef extends $ZodStringFormatDef<"xid"> {
|
| 235 |
+
}
|
| 236 |
+
export interface $ZodXIDInternals extends $ZodStringFormatInternals<"xid"> {
|
| 237 |
+
}
|
| 238 |
+
export interface $ZodXID extends $ZodType {
|
| 239 |
+
_zod: $ZodXIDInternals;
|
| 240 |
+
}
|
| 241 |
+
export declare const $ZodXID: core.$constructor<$ZodXID>;
|
| 242 |
+
export interface $ZodKSUIDDef extends $ZodStringFormatDef<"ksuid"> {
|
| 243 |
+
}
|
| 244 |
+
export interface $ZodKSUIDInternals extends $ZodStringFormatInternals<"ksuid"> {
|
| 245 |
+
}
|
| 246 |
+
export interface $ZodKSUID extends $ZodType {
|
| 247 |
+
_zod: $ZodKSUIDInternals;
|
| 248 |
+
}
|
| 249 |
+
export declare const $ZodKSUID: core.$constructor<$ZodKSUID>;
|
| 250 |
+
export interface $ZodISODateTimeDef extends $ZodStringFormatDef<"datetime"> {
|
| 251 |
+
precision: number | null;
|
| 252 |
+
offset: boolean;
|
| 253 |
+
local: boolean;
|
| 254 |
+
}
|
| 255 |
+
export interface $ZodISODateTimeInternals extends $ZodStringFormatInternals {
|
| 256 |
+
def: $ZodISODateTimeDef;
|
| 257 |
+
}
|
| 258 |
+
export interface $ZodISODateTime extends $ZodType {
|
| 259 |
+
_zod: $ZodISODateTimeInternals;
|
| 260 |
+
}
|
| 261 |
+
export declare const $ZodISODateTime: core.$constructor<$ZodISODateTime>;
|
| 262 |
+
export interface $ZodISODateDef extends $ZodStringFormatDef<"date"> {
|
| 263 |
+
}
|
| 264 |
+
export interface $ZodISODateInternals extends $ZodStringFormatInternals<"date"> {
|
| 265 |
+
}
|
| 266 |
+
export interface $ZodISODate extends $ZodType {
|
| 267 |
+
_zod: $ZodISODateInternals;
|
| 268 |
+
}
|
| 269 |
+
export declare const $ZodISODate: core.$constructor<$ZodISODate>;
|
| 270 |
+
export interface $ZodISOTimeDef extends $ZodStringFormatDef<"time"> {
|
| 271 |
+
precision?: number | null;
|
| 272 |
+
}
|
| 273 |
+
export interface $ZodISOTimeInternals extends $ZodStringFormatInternals<"time"> {
|
| 274 |
+
def: $ZodISOTimeDef;
|
| 275 |
+
}
|
| 276 |
+
export interface $ZodISOTime extends $ZodType {
|
| 277 |
+
_zod: $ZodISOTimeInternals;
|
| 278 |
+
}
|
| 279 |
+
export declare const $ZodISOTime: core.$constructor<$ZodISOTime>;
|
| 280 |
+
export interface $ZodISODurationDef extends $ZodStringFormatDef<"duration"> {
|
| 281 |
+
}
|
| 282 |
+
export interface $ZodISODurationInternals extends $ZodStringFormatInternals<"duration"> {
|
| 283 |
+
}
|
| 284 |
+
export interface $ZodISODuration extends $ZodType {
|
| 285 |
+
_zod: $ZodISODurationInternals;
|
| 286 |
+
}
|
| 287 |
+
export declare const $ZodISODuration: core.$constructor<$ZodISODuration>;
|
| 288 |
+
export interface $ZodIPv4Def extends $ZodStringFormatDef<"ipv4"> {
|
| 289 |
+
version?: "v4";
|
| 290 |
+
}
|
| 291 |
+
export interface $ZodIPv4Internals extends $ZodStringFormatInternals<"ipv4"> {
|
| 292 |
+
def: $ZodIPv4Def;
|
| 293 |
+
}
|
| 294 |
+
export interface $ZodIPv4 extends $ZodType {
|
| 295 |
+
_zod: $ZodIPv4Internals;
|
| 296 |
+
}
|
| 297 |
+
export declare const $ZodIPv4: core.$constructor<$ZodIPv4>;
|
| 298 |
+
export interface $ZodIPv6Def extends $ZodStringFormatDef<"ipv6"> {
|
| 299 |
+
version?: "v6";
|
| 300 |
+
}
|
| 301 |
+
export interface $ZodIPv6Internals extends $ZodStringFormatInternals<"ipv6"> {
|
| 302 |
+
def: $ZodIPv6Def;
|
| 303 |
+
}
|
| 304 |
+
export interface $ZodIPv6 extends $ZodType {
|
| 305 |
+
_zod: $ZodIPv6Internals;
|
| 306 |
+
}
|
| 307 |
+
export declare const $ZodIPv6: core.$constructor<$ZodIPv6>;
|
| 308 |
+
export interface $ZodMACDef extends $ZodStringFormatDef<"mac"> {
|
| 309 |
+
delimiter?: string;
|
| 310 |
+
}
|
| 311 |
+
export interface $ZodMACInternals extends $ZodStringFormatInternals<"mac"> {
|
| 312 |
+
def: $ZodMACDef;
|
| 313 |
+
}
|
| 314 |
+
export interface $ZodMAC extends $ZodType {
|
| 315 |
+
_zod: $ZodMACInternals;
|
| 316 |
+
}
|
| 317 |
+
export declare const $ZodMAC: core.$constructor<$ZodMAC>;
|
| 318 |
+
export interface $ZodCIDRv4Def extends $ZodStringFormatDef<"cidrv4"> {
|
| 319 |
+
version?: "v4";
|
| 320 |
+
}
|
| 321 |
+
export interface $ZodCIDRv4Internals extends $ZodStringFormatInternals<"cidrv4"> {
|
| 322 |
+
def: $ZodCIDRv4Def;
|
| 323 |
+
}
|
| 324 |
+
export interface $ZodCIDRv4 extends $ZodType {
|
| 325 |
+
_zod: $ZodCIDRv4Internals;
|
| 326 |
+
}
|
| 327 |
+
export declare const $ZodCIDRv4: core.$constructor<$ZodCIDRv4>;
|
| 328 |
+
export interface $ZodCIDRv6Def extends $ZodStringFormatDef<"cidrv6"> {
|
| 329 |
+
version?: "v6";
|
| 330 |
+
}
|
| 331 |
+
export interface $ZodCIDRv6Internals extends $ZodStringFormatInternals<"cidrv6"> {
|
| 332 |
+
def: $ZodCIDRv6Def;
|
| 333 |
+
}
|
| 334 |
+
export interface $ZodCIDRv6 extends $ZodType {
|
| 335 |
+
_zod: $ZodCIDRv6Internals;
|
| 336 |
+
}
|
| 337 |
+
export declare const $ZodCIDRv6: core.$constructor<$ZodCIDRv6>;
|
| 338 |
+
export declare function isValidBase64(data: string): boolean;
|
| 339 |
+
export interface $ZodBase64Def extends $ZodStringFormatDef<"base64"> {
|
| 340 |
+
}
|
| 341 |
+
export interface $ZodBase64Internals extends $ZodStringFormatInternals<"base64"> {
|
| 342 |
+
}
|
| 343 |
+
export interface $ZodBase64 extends $ZodType {
|
| 344 |
+
_zod: $ZodBase64Internals;
|
| 345 |
+
}
|
| 346 |
+
export declare const $ZodBase64: core.$constructor<$ZodBase64>;
|
| 347 |
+
export declare function isValidBase64URL(data: string): boolean;
|
| 348 |
+
export interface $ZodBase64URLDef extends $ZodStringFormatDef<"base64url"> {
|
| 349 |
+
}
|
| 350 |
+
export interface $ZodBase64URLInternals extends $ZodStringFormatInternals<"base64url"> {
|
| 351 |
+
}
|
| 352 |
+
export interface $ZodBase64URL extends $ZodType {
|
| 353 |
+
_zod: $ZodBase64URLInternals;
|
| 354 |
+
}
|
| 355 |
+
export declare const $ZodBase64URL: core.$constructor<$ZodBase64URL>;
|
| 356 |
+
export interface $ZodE164Def extends $ZodStringFormatDef<"e164"> {
|
| 357 |
+
}
|
| 358 |
+
export interface $ZodE164Internals extends $ZodStringFormatInternals<"e164"> {
|
| 359 |
+
}
|
| 360 |
+
export interface $ZodE164 extends $ZodType {
|
| 361 |
+
_zod: $ZodE164Internals;
|
| 362 |
+
}
|
| 363 |
+
export declare const $ZodE164: core.$constructor<$ZodE164>;
|
| 364 |
+
export declare function isValidJWT(token: string, algorithm?: util.JWTAlgorithm | null): boolean;
|
| 365 |
+
export interface $ZodJWTDef extends $ZodStringFormatDef<"jwt"> {
|
| 366 |
+
alg?: util.JWTAlgorithm | undefined;
|
| 367 |
+
}
|
| 368 |
+
export interface $ZodJWTInternals extends $ZodStringFormatInternals<"jwt"> {
|
| 369 |
+
def: $ZodJWTDef;
|
| 370 |
+
}
|
| 371 |
+
export interface $ZodJWT extends $ZodType {
|
| 372 |
+
_zod: $ZodJWTInternals;
|
| 373 |
+
}
|
| 374 |
+
export declare const $ZodJWT: core.$constructor<$ZodJWT>;
|
| 375 |
+
export interface $ZodCustomStringFormatDef<Format extends string = string> extends $ZodStringFormatDef<Format> {
|
| 376 |
+
fn: (val: string) => unknown;
|
| 377 |
+
}
|
| 378 |
+
export interface $ZodCustomStringFormatInternals<Format extends string = string> extends $ZodStringFormatInternals<Format> {
|
| 379 |
+
def: $ZodCustomStringFormatDef<Format>;
|
| 380 |
+
}
|
| 381 |
+
export interface $ZodCustomStringFormat<Format extends string = string> extends $ZodStringFormat<Format> {
|
| 382 |
+
_zod: $ZodCustomStringFormatInternals<Format>;
|
| 383 |
+
}
|
| 384 |
+
export declare const $ZodCustomStringFormat: core.$constructor<$ZodCustomStringFormat>;
|
| 385 |
+
export interface $ZodNumberDef extends $ZodTypeDef {
|
| 386 |
+
type: "number";
|
| 387 |
+
coerce?: boolean;
|
| 388 |
+
}
|
| 389 |
+
export interface $ZodNumberInternals<Input = unknown> extends $ZodTypeInternals<number, Input> {
|
| 390 |
+
def: $ZodNumberDef;
|
| 391 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 392 |
+
pattern: RegExp;
|
| 393 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 394 |
+
isst: errors.$ZodIssueInvalidType;
|
| 395 |
+
bag: util.LoosePartial<{
|
| 396 |
+
minimum: number;
|
| 397 |
+
maximum: number;
|
| 398 |
+
exclusiveMinimum: number;
|
| 399 |
+
exclusiveMaximum: number;
|
| 400 |
+
format: string;
|
| 401 |
+
pattern: RegExp;
|
| 402 |
+
}>;
|
| 403 |
+
}
|
| 404 |
+
export interface $ZodNumber<Input = unknown> extends $ZodType {
|
| 405 |
+
_zod: $ZodNumberInternals<Input>;
|
| 406 |
+
}
|
| 407 |
+
export declare const $ZodNumber: core.$constructor<$ZodNumber>;
|
| 408 |
+
export interface $ZodNumberFormatDef extends $ZodNumberDef, checks.$ZodCheckNumberFormatDef {
|
| 409 |
+
}
|
| 410 |
+
export interface $ZodNumberFormatInternals extends $ZodNumberInternals<number>, checks.$ZodCheckNumberFormatInternals {
|
| 411 |
+
def: $ZodNumberFormatDef;
|
| 412 |
+
isst: errors.$ZodIssueInvalidType;
|
| 413 |
+
}
|
| 414 |
+
export interface $ZodNumberFormat extends $ZodType {
|
| 415 |
+
_zod: $ZodNumberFormatInternals;
|
| 416 |
+
}
|
| 417 |
+
export declare const $ZodNumberFormat: core.$constructor<$ZodNumberFormat>;
|
| 418 |
+
export interface $ZodBooleanDef extends $ZodTypeDef {
|
| 419 |
+
type: "boolean";
|
| 420 |
+
coerce?: boolean;
|
| 421 |
+
checks?: checks.$ZodCheck<boolean>[];
|
| 422 |
+
}
|
| 423 |
+
export interface $ZodBooleanInternals<T = unknown> extends $ZodTypeInternals<boolean, T> {
|
| 424 |
+
pattern: RegExp;
|
| 425 |
+
def: $ZodBooleanDef;
|
| 426 |
+
isst: errors.$ZodIssueInvalidType;
|
| 427 |
+
}
|
| 428 |
+
export interface $ZodBoolean<T = unknown> extends $ZodType {
|
| 429 |
+
_zod: $ZodBooleanInternals<T>;
|
| 430 |
+
}
|
| 431 |
+
export declare const $ZodBoolean: core.$constructor<$ZodBoolean>;
|
| 432 |
+
export interface $ZodBigIntDef extends $ZodTypeDef {
|
| 433 |
+
type: "bigint";
|
| 434 |
+
coerce?: boolean;
|
| 435 |
+
}
|
| 436 |
+
export interface $ZodBigIntInternals<T = unknown> extends $ZodTypeInternals<bigint, T> {
|
| 437 |
+
pattern: RegExp;
|
| 438 |
+
/** @internal Internal API, use with caution */
|
| 439 |
+
def: $ZodBigIntDef;
|
| 440 |
+
isst: errors.$ZodIssueInvalidType;
|
| 441 |
+
bag: util.LoosePartial<{
|
| 442 |
+
minimum: bigint;
|
| 443 |
+
maximum: bigint;
|
| 444 |
+
format: string;
|
| 445 |
+
}>;
|
| 446 |
+
}
|
| 447 |
+
export interface $ZodBigInt<T = unknown> extends $ZodType {
|
| 448 |
+
_zod: $ZodBigIntInternals<T>;
|
| 449 |
+
}
|
| 450 |
+
export declare const $ZodBigInt: core.$constructor<$ZodBigInt>;
|
| 451 |
+
export interface $ZodBigIntFormatDef extends $ZodBigIntDef, checks.$ZodCheckBigIntFormatDef {
|
| 452 |
+
check: "bigint_format";
|
| 453 |
+
}
|
| 454 |
+
export interface $ZodBigIntFormatInternals extends $ZodBigIntInternals<bigint>, checks.$ZodCheckBigIntFormatInternals {
|
| 455 |
+
def: $ZodBigIntFormatDef;
|
| 456 |
+
}
|
| 457 |
+
export interface $ZodBigIntFormat extends $ZodType {
|
| 458 |
+
_zod: $ZodBigIntFormatInternals;
|
| 459 |
+
}
|
| 460 |
+
export declare const $ZodBigIntFormat: core.$constructor<$ZodBigIntFormat>;
|
| 461 |
+
export interface $ZodSymbolDef extends $ZodTypeDef {
|
| 462 |
+
type: "symbol";
|
| 463 |
+
}
|
| 464 |
+
export interface $ZodSymbolInternals extends $ZodTypeInternals<symbol, symbol> {
|
| 465 |
+
def: $ZodSymbolDef;
|
| 466 |
+
isst: errors.$ZodIssueInvalidType;
|
| 467 |
+
}
|
| 468 |
+
export interface $ZodSymbol extends $ZodType {
|
| 469 |
+
_zod: $ZodSymbolInternals;
|
| 470 |
+
}
|
| 471 |
+
export declare const $ZodSymbol: core.$constructor<$ZodSymbol>;
|
| 472 |
+
export interface $ZodUndefinedDef extends $ZodTypeDef {
|
| 473 |
+
type: "undefined";
|
| 474 |
+
}
|
| 475 |
+
export interface $ZodUndefinedInternals extends $ZodTypeInternals<undefined, undefined> {
|
| 476 |
+
pattern: RegExp;
|
| 477 |
+
def: $ZodUndefinedDef;
|
| 478 |
+
values: util.PrimitiveSet;
|
| 479 |
+
isst: errors.$ZodIssueInvalidType;
|
| 480 |
+
}
|
| 481 |
+
export interface $ZodUndefined extends $ZodType {
|
| 482 |
+
_zod: $ZodUndefinedInternals;
|
| 483 |
+
}
|
| 484 |
+
export declare const $ZodUndefined: core.$constructor<$ZodUndefined>;
|
| 485 |
+
export interface $ZodNullDef extends $ZodTypeDef {
|
| 486 |
+
type: "null";
|
| 487 |
+
}
|
| 488 |
+
export interface $ZodNullInternals extends $ZodTypeInternals<null, null> {
|
| 489 |
+
pattern: RegExp;
|
| 490 |
+
def: $ZodNullDef;
|
| 491 |
+
values: util.PrimitiveSet;
|
| 492 |
+
isst: errors.$ZodIssueInvalidType;
|
| 493 |
+
}
|
| 494 |
+
export interface $ZodNull extends $ZodType {
|
| 495 |
+
_zod: $ZodNullInternals;
|
| 496 |
+
}
|
| 497 |
+
export declare const $ZodNull: core.$constructor<$ZodNull>;
|
| 498 |
+
export interface $ZodAnyDef extends $ZodTypeDef {
|
| 499 |
+
type: "any";
|
| 500 |
+
}
|
| 501 |
+
export interface $ZodAnyInternals extends $ZodTypeInternals<any, any> {
|
| 502 |
+
def: $ZodAnyDef;
|
| 503 |
+
isst: never;
|
| 504 |
+
}
|
| 505 |
+
export interface $ZodAny extends $ZodType {
|
| 506 |
+
_zod: $ZodAnyInternals;
|
| 507 |
+
}
|
| 508 |
+
export declare const $ZodAny: core.$constructor<$ZodAny>;
|
| 509 |
+
export interface $ZodUnknownDef extends $ZodTypeDef {
|
| 510 |
+
type: "unknown";
|
| 511 |
+
}
|
| 512 |
+
export interface $ZodUnknownInternals extends $ZodTypeInternals<unknown, unknown> {
|
| 513 |
+
def: $ZodUnknownDef;
|
| 514 |
+
isst: never;
|
| 515 |
+
}
|
| 516 |
+
export interface $ZodUnknown extends $ZodType {
|
| 517 |
+
_zod: $ZodUnknownInternals;
|
| 518 |
+
}
|
| 519 |
+
export declare const $ZodUnknown: core.$constructor<$ZodUnknown>;
|
| 520 |
+
export interface $ZodNeverDef extends $ZodTypeDef {
|
| 521 |
+
type: "never";
|
| 522 |
+
}
|
| 523 |
+
export interface $ZodNeverInternals extends $ZodTypeInternals<never, never> {
|
| 524 |
+
def: $ZodNeverDef;
|
| 525 |
+
isst: errors.$ZodIssueInvalidType;
|
| 526 |
+
}
|
| 527 |
+
export interface $ZodNever extends $ZodType {
|
| 528 |
+
_zod: $ZodNeverInternals;
|
| 529 |
+
}
|
| 530 |
+
export declare const $ZodNever: core.$constructor<$ZodNever>;
|
| 531 |
+
export interface $ZodVoidDef extends $ZodTypeDef {
|
| 532 |
+
type: "void";
|
| 533 |
+
}
|
| 534 |
+
export interface $ZodVoidInternals extends $ZodTypeInternals<void, void> {
|
| 535 |
+
def: $ZodVoidDef;
|
| 536 |
+
isst: errors.$ZodIssueInvalidType;
|
| 537 |
+
}
|
| 538 |
+
export interface $ZodVoid extends $ZodType {
|
| 539 |
+
_zod: $ZodVoidInternals;
|
| 540 |
+
}
|
| 541 |
+
export declare const $ZodVoid: core.$constructor<$ZodVoid>;
|
| 542 |
+
export interface $ZodDateDef extends $ZodTypeDef {
|
| 543 |
+
type: "date";
|
| 544 |
+
coerce?: boolean;
|
| 545 |
+
}
|
| 546 |
+
export interface $ZodDateInternals<T = unknown> extends $ZodTypeInternals<Date, T> {
|
| 547 |
+
def: $ZodDateDef;
|
| 548 |
+
isst: errors.$ZodIssueInvalidType;
|
| 549 |
+
bag: util.LoosePartial<{
|
| 550 |
+
minimum: Date;
|
| 551 |
+
maximum: Date;
|
| 552 |
+
format: string;
|
| 553 |
+
}>;
|
| 554 |
+
}
|
| 555 |
+
export interface $ZodDate<T = unknown> extends $ZodType {
|
| 556 |
+
_zod: $ZodDateInternals<T>;
|
| 557 |
+
}
|
| 558 |
+
export declare const $ZodDate: core.$constructor<$ZodDate>;
|
| 559 |
+
export interface $ZodArrayDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 560 |
+
type: "array";
|
| 561 |
+
element: T;
|
| 562 |
+
}
|
| 563 |
+
export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$ZodTypeInternals {
|
| 564 |
+
def: $ZodArrayDef<T>;
|
| 565 |
+
isst: errors.$ZodIssueInvalidType;
|
| 566 |
+
output: core.output<T>[];
|
| 567 |
+
input: core.input<T>[];
|
| 568 |
+
}
|
| 569 |
+
export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {
|
| 570 |
+
}
|
| 571 |
+
export declare const $ZodArray: core.$constructor<$ZodArray>;
|
| 572 |
+
type OptionalOutSchema = {
|
| 573 |
+
_zod: {
|
| 574 |
+
optout: "optional";
|
| 575 |
+
};
|
| 576 |
+
};
|
| 577 |
+
type OptionalInSchema = {
|
| 578 |
+
_zod: {
|
| 579 |
+
optin: "optional";
|
| 580 |
+
};
|
| 581 |
+
};
|
| 582 |
+
export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? util.IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, core.output<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
| 583 |
+
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? never : k]: T[k]["_zod"]["output"];
|
| 584 |
+
} & {
|
| 585 |
+
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? k : never]?: T[k]["_zod"]["output"];
|
| 586 |
+
} & Extra>;
|
| 587 |
+
export type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? util.IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, core.input<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : util.Prettify<{
|
| 588 |
+
-readonly [k in keyof T as T[k] extends OptionalInSchema ? never : k]: T[k]["_zod"]["input"];
|
| 589 |
+
} & {
|
| 590 |
+
-readonly [k in keyof T as T[k] extends OptionalInSchema ? k : never]?: T[k]["_zod"]["input"];
|
| 591 |
+
} & Extra>;
|
| 592 |
+
export type $ZodObjectConfig = {
|
| 593 |
+
out: Record<string, unknown>;
|
| 594 |
+
in: Record<string, unknown>;
|
| 595 |
+
};
|
| 596 |
+
export type $loose = {
|
| 597 |
+
out: Record<string, unknown>;
|
| 598 |
+
in: Record<string, unknown>;
|
| 599 |
+
};
|
| 600 |
+
export type $strict = {
|
| 601 |
+
out: {};
|
| 602 |
+
in: {};
|
| 603 |
+
};
|
| 604 |
+
export type $strip = {
|
| 605 |
+
out: {};
|
| 606 |
+
in: {};
|
| 607 |
+
};
|
| 608 |
+
export type $catchall<T extends SomeType> = {
|
| 609 |
+
out: {
|
| 610 |
+
[k: string]: core.output<T>;
|
| 611 |
+
};
|
| 612 |
+
in: {
|
| 613 |
+
[k: string]: core.input<T>;
|
| 614 |
+
};
|
| 615 |
+
};
|
| 616 |
+
export type $ZodShape = Readonly<{
|
| 617 |
+
[k: string]: $ZodType;
|
| 618 |
+
}>;
|
| 619 |
+
export interface $ZodObjectDef<Shape extends $ZodShape = $ZodShape> extends $ZodTypeDef {
|
| 620 |
+
type: "object";
|
| 621 |
+
shape: Shape;
|
| 622 |
+
catchall?: $ZodType | undefined;
|
| 623 |
+
}
|
| 624 |
+
export interface $ZodObjectInternals<
|
| 625 |
+
/** @ts-ignore Cast variance */
|
| 626 |
+
out Shape extends $ZodShape = $ZodShape, out Config extends $ZodObjectConfig = $ZodObjectConfig> extends _$ZodTypeInternals {
|
| 627 |
+
def: $ZodObjectDef<Shape>;
|
| 628 |
+
config: Config;
|
| 629 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueUnrecognizedKeys;
|
| 630 |
+
propValues: util.PropValues;
|
| 631 |
+
output: $InferObjectOutput<Shape, Config["out"]>;
|
| 632 |
+
input: $InferObjectInput<Shape, Config["in"]>;
|
| 633 |
+
optin?: "optional" | undefined;
|
| 634 |
+
optout?: "optional" | undefined;
|
| 635 |
+
}
|
| 636 |
+
export type $ZodLooseShape = Record<string, any>;
|
| 637 |
+
export interface $ZodObject<
|
| 638 |
+
/** @ts-ignore Cast variance */
|
| 639 |
+
out Shape extends Readonly<$ZodShape> = Readonly<$ZodShape>, out Params extends $ZodObjectConfig = $ZodObjectConfig> extends $ZodType<any, any, $ZodObjectInternals<Shape, Params>> {
|
| 640 |
+
}
|
| 641 |
+
export declare const $ZodObject: core.$constructor<$ZodObject>;
|
| 642 |
+
export declare const $ZodObjectJIT: core.$constructor<$ZodObject>;
|
| 643 |
+
export type $InferUnionOutput<T extends SomeType> = T extends any ? core.output<T> : never;
|
| 644 |
+
export type $InferUnionInput<T extends SomeType> = T extends any ? core.input<T> : never;
|
| 645 |
+
export interface $ZodUnionDef<Options extends readonly SomeType[] = readonly $ZodType[]> extends $ZodTypeDef {
|
| 646 |
+
type: "union";
|
| 647 |
+
options: Options;
|
| 648 |
+
inclusive?: boolean;
|
| 649 |
+
}
|
| 650 |
+
type IsOptionalIn<T extends SomeType> = T extends OptionalInSchema ? true : false;
|
| 651 |
+
type IsOptionalOut<T extends SomeType> = T extends OptionalOutSchema ? true : false;
|
| 652 |
+
export interface $ZodUnionInternals<T extends readonly SomeType[] = readonly $ZodType[]> extends _$ZodTypeInternals {
|
| 653 |
+
def: $ZodUnionDef<T>;
|
| 654 |
+
isst: errors.$ZodIssueInvalidUnion;
|
| 655 |
+
pattern: T[number]["_zod"]["pattern"];
|
| 656 |
+
values: T[number]["_zod"]["values"];
|
| 657 |
+
output: $InferUnionOutput<T[number]>;
|
| 658 |
+
input: $InferUnionInput<T[number]>;
|
| 659 |
+
optin: IsOptionalIn<T[number]> extends false ? "optional" | undefined : "optional";
|
| 660 |
+
optout: IsOptionalOut<T[number]> extends false ? "optional" | undefined : "optional";
|
| 661 |
+
}
|
| 662 |
+
export interface $ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType<any, any, $ZodUnionInternals<T>> {
|
| 663 |
+
_zod: $ZodUnionInternals<T>;
|
| 664 |
+
}
|
| 665 |
+
export declare const $ZodUnion: core.$constructor<$ZodUnion>;
|
| 666 |
+
export interface $ZodXorInternals<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodUnionInternals<T> {
|
| 667 |
+
}
|
| 668 |
+
export interface $ZodXor<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType<any, any, $ZodXorInternals<T>> {
|
| 669 |
+
_zod: $ZodXorInternals<T>;
|
| 670 |
+
}
|
| 671 |
+
export declare const $ZodXor: core.$constructor<$ZodXor>;
|
| 672 |
+
export interface $ZodDiscriminatedUnionDef<Options extends readonly SomeType[] = readonly $ZodType[], Disc extends string = string> extends $ZodUnionDef<Options> {
|
| 673 |
+
discriminator: Disc;
|
| 674 |
+
unionFallback?: boolean;
|
| 675 |
+
}
|
| 676 |
+
export interface $ZodDiscriminatedUnionInternals<Options extends readonly SomeType[] = readonly $ZodType[], Disc extends string = string> extends $ZodUnionInternals<Options> {
|
| 677 |
+
def: $ZodDiscriminatedUnionDef<Options, Disc>;
|
| 678 |
+
propValues: util.PropValues;
|
| 679 |
+
}
|
| 680 |
+
export interface $ZodDiscriminatedUnion<Options extends readonly SomeType[] = readonly $ZodType[], Disc extends string = string> extends $ZodType {
|
| 681 |
+
_zod: $ZodDiscriminatedUnionInternals<Options, Disc>;
|
| 682 |
+
}
|
| 683 |
+
export declare const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion>;
|
| 684 |
+
export interface $ZodIntersectionDef<Left extends SomeType = $ZodType, Right extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 685 |
+
type: "intersection";
|
| 686 |
+
left: Left;
|
| 687 |
+
right: Right;
|
| 688 |
+
}
|
| 689 |
+
export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends _$ZodTypeInternals {
|
| 690 |
+
def: $ZodIntersectionDef<A, B>;
|
| 691 |
+
isst: never;
|
| 692 |
+
optin: A["_zod"]["optin"] | B["_zod"]["optin"];
|
| 693 |
+
optout: A["_zod"]["optout"] | B["_zod"]["optout"];
|
| 694 |
+
output: core.output<A> & core.output<B>;
|
| 695 |
+
input: core.input<A> & core.input<B>;
|
| 696 |
+
}
|
| 697 |
+
export interface $ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
| 698 |
+
_zod: $ZodIntersectionInternals<A, B>;
|
| 699 |
+
}
|
| 700 |
+
export declare const $ZodIntersection: core.$constructor<$ZodIntersection>;
|
| 701 |
+
export interface $ZodTupleDef<T extends util.TupleItems = readonly $ZodType[], Rest extends SomeType | null = $ZodType | null> extends $ZodTypeDef {
|
| 702 |
+
type: "tuple";
|
| 703 |
+
items: T;
|
| 704 |
+
rest: Rest;
|
| 705 |
+
}
|
| 706 |
+
export type $InferTupleInputType<T extends util.TupleItems, Rest extends SomeType | null> = [
|
| 707 |
+
...TupleInputTypeWithOptionals<T>,
|
| 708 |
+
...(Rest extends SomeType ? core.input<Rest>[] : [])
|
| 709 |
+
];
|
| 710 |
+
type TupleInputTypeNoOptionals<T extends util.TupleItems> = {
|
| 711 |
+
[k in keyof T]: core.input<T[k]>;
|
| 712 |
+
};
|
| 713 |
+
type TupleInputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
|
| 714 |
+
...infer Prefix extends SomeType[],
|
| 715 |
+
infer Tail extends SomeType
|
| 716 |
+
] ? Tail["_zod"]["optin"] extends "optional" ? [...TupleInputTypeWithOptionals<Prefix>, core.input<Tail>?] : TupleInputTypeNoOptionals<T> : [];
|
| 717 |
+
export type $InferTupleOutputType<T extends util.TupleItems, Rest extends SomeType | null> = [
|
| 718 |
+
...TupleOutputTypeWithOptionals<T>,
|
| 719 |
+
...(Rest extends SomeType ? core.output<Rest>[] : [])
|
| 720 |
+
];
|
| 721 |
+
type TupleOutputTypeNoOptionals<T extends util.TupleItems> = {
|
| 722 |
+
[k in keyof T]: core.output<T[k]>;
|
| 723 |
+
};
|
| 724 |
+
type TupleOutputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
|
| 725 |
+
...infer Prefix extends SomeType[],
|
| 726 |
+
infer Tail extends SomeType
|
| 727 |
+
] ? Tail["_zod"]["optout"] extends "optional" ? [...TupleOutputTypeWithOptionals<Prefix>, core.output<Tail>?] : TupleOutputTypeNoOptionals<T> : [];
|
| 728 |
+
export interface $ZodTupleInternals<T extends util.TupleItems = readonly $ZodType[], Rest extends SomeType | null = $ZodType | null> extends _$ZodTypeInternals {
|
| 729 |
+
def: $ZodTupleDef<T, Rest>;
|
| 730 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueTooBig<unknown[]> | errors.$ZodIssueTooSmall<unknown[]>;
|
| 731 |
+
output: $InferTupleOutputType<T, Rest>;
|
| 732 |
+
input: $InferTupleInputType<T, Rest>;
|
| 733 |
+
}
|
| 734 |
+
export interface $ZodTuple<T extends util.TupleItems = readonly $ZodType[], Rest extends SomeType | null = $ZodType | null> extends $ZodType {
|
| 735 |
+
_zod: $ZodTupleInternals<T, Rest>;
|
| 736 |
+
}
|
| 737 |
+
export declare const $ZodTuple: core.$constructor<$ZodTuple>;
|
| 738 |
+
export type $ZodRecordKey = $ZodType<string | number | symbol, unknown>;
|
| 739 |
+
export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 740 |
+
type: "record";
|
| 741 |
+
keyType: Key;
|
| 742 |
+
valueType: Value;
|
| 743 |
+
/** @default "strict" - errors on keys not matching keyType. "loose" passes through non-matching keys unchanged. */
|
| 744 |
+
mode?: "strict" | "loose";
|
| 745 |
+
}
|
| 746 |
+
export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.output<Key>, core.output<Value>>> : Record<core.output<Key>, core.output<Value>>;
|
| 747 |
+
export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.input<Key> & PropertyKey, core.input<Value>>> : Record<core.input<Key> & PropertyKey, core.input<Value>>;
|
| 748 |
+
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
|
| 749 |
+
def: $ZodRecordDef<Key, Value>;
|
| 750 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
| 751 |
+
optin?: "optional" | undefined;
|
| 752 |
+
optout?: "optional" | undefined;
|
| 753 |
+
}
|
| 754 |
+
export type $partial = {
|
| 755 |
+
"~~partial": true;
|
| 756 |
+
};
|
| 757 |
+
export interface $ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodType {
|
| 758 |
+
_zod: $ZodRecordInternals<Key, Value>;
|
| 759 |
+
}
|
| 760 |
+
export declare const $ZodRecord: core.$constructor<$ZodRecord>;
|
| 761 |
+
export interface $ZodMapDef<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 762 |
+
type: "map";
|
| 763 |
+
keyType: Key;
|
| 764 |
+
valueType: Value;
|
| 765 |
+
}
|
| 766 |
+
export interface $ZodMapInternals<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodTypeInternals<Map<core.output<Key>, core.output<Value>>, Map<core.input<Key>, core.input<Value>>> {
|
| 767 |
+
def: $ZodMapDef<Key, Value>;
|
| 768 |
+
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey | errors.$ZodIssueInvalidElement<unknown>;
|
| 769 |
+
optin?: "optional" | undefined;
|
| 770 |
+
optout?: "optional" | undefined;
|
| 771 |
+
}
|
| 772 |
+
export interface $ZodMap<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodType {
|
| 773 |
+
_zod: $ZodMapInternals<Key, Value>;
|
| 774 |
+
}
|
| 775 |
+
export declare const $ZodMap: core.$constructor<$ZodMap>;
|
| 776 |
+
export interface $ZodSetDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 777 |
+
type: "set";
|
| 778 |
+
valueType: T;
|
| 779 |
+
}
|
| 780 |
+
export interface $ZodSetInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<Set<core.output<T>>, Set<core.input<T>>> {
|
| 781 |
+
def: $ZodSetDef<T>;
|
| 782 |
+
isst: errors.$ZodIssueInvalidType;
|
| 783 |
+
optin?: "optional" | undefined;
|
| 784 |
+
optout?: "optional" | undefined;
|
| 785 |
+
}
|
| 786 |
+
export interface $ZodSet<T extends SomeType = $ZodType> extends $ZodType {
|
| 787 |
+
_zod: $ZodSetInternals<T>;
|
| 788 |
+
}
|
| 789 |
+
export declare const $ZodSet: core.$constructor<$ZodSet>;
|
| 790 |
+
export type $InferEnumOutput<T extends util.EnumLike> = T[keyof T] & {};
|
| 791 |
+
export type $InferEnumInput<T extends util.EnumLike> = T[keyof T] & {};
|
| 792 |
+
export interface $ZodEnumDef<T extends util.EnumLike = util.EnumLike> extends $ZodTypeDef {
|
| 793 |
+
type: "enum";
|
| 794 |
+
entries: T;
|
| 795 |
+
}
|
| 796 |
+
export interface $ZodEnumInternals<
|
| 797 |
+
/** @ts-ignore Cast variance */
|
| 798 |
+
out T extends util.EnumLike = util.EnumLike> extends $ZodTypeInternals<$InferEnumOutput<T>, $InferEnumInput<T>> {
|
| 799 |
+
def: $ZodEnumDef<T>;
|
| 800 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 801 |
+
values: util.PrimitiveSet;
|
| 802 |
+
/** @deprecated Internal API, use with caution (not deprecated) */
|
| 803 |
+
pattern: RegExp;
|
| 804 |
+
isst: errors.$ZodIssueInvalidValue;
|
| 805 |
+
}
|
| 806 |
+
export interface $ZodEnum<T extends util.EnumLike = util.EnumLike> extends $ZodType {
|
| 807 |
+
_zod: $ZodEnumInternals<T>;
|
| 808 |
+
}
|
| 809 |
+
export declare const $ZodEnum: core.$constructor<$ZodEnum>;
|
| 810 |
+
export interface $ZodLiteralDef<T extends util.Literal> extends $ZodTypeDef {
|
| 811 |
+
type: "literal";
|
| 812 |
+
values: T[];
|
| 813 |
+
}
|
| 814 |
+
export interface $ZodLiteralInternals<T extends util.Literal = util.Literal> extends $ZodTypeInternals<T, T> {
|
| 815 |
+
def: $ZodLiteralDef<T>;
|
| 816 |
+
values: Set<T>;
|
| 817 |
+
pattern: RegExp;
|
| 818 |
+
isst: errors.$ZodIssueInvalidValue;
|
| 819 |
+
}
|
| 820 |
+
export interface $ZodLiteral<T extends util.Literal = util.Literal> extends $ZodType {
|
| 821 |
+
_zod: $ZodLiteralInternals<T>;
|
| 822 |
+
}
|
| 823 |
+
export declare const $ZodLiteral: core.$constructor<$ZodLiteral>;
|
| 824 |
+
type _File = typeof globalThis extends {
|
| 825 |
+
File: infer F extends new (...args: any[]) => any;
|
| 826 |
+
} ? InstanceType<F> : {};
|
| 827 |
+
/** Do not reference this directly. */
|
| 828 |
+
export interface File extends _File {
|
| 829 |
+
readonly type: string;
|
| 830 |
+
readonly size: number;
|
| 831 |
+
}
|
| 832 |
+
export interface $ZodFileDef extends $ZodTypeDef {
|
| 833 |
+
type: "file";
|
| 834 |
+
}
|
| 835 |
+
export interface $ZodFileInternals extends $ZodTypeInternals<File, File> {
|
| 836 |
+
def: $ZodFileDef;
|
| 837 |
+
isst: errors.$ZodIssueInvalidType;
|
| 838 |
+
bag: util.LoosePartial<{
|
| 839 |
+
minimum: number;
|
| 840 |
+
maximum: number;
|
| 841 |
+
mime: util.MimeTypes[];
|
| 842 |
+
}>;
|
| 843 |
+
}
|
| 844 |
+
export interface $ZodFile extends $ZodType {
|
| 845 |
+
_zod: $ZodFileInternals;
|
| 846 |
+
}
|
| 847 |
+
export declare const $ZodFile: core.$constructor<$ZodFile>;
|
| 848 |
+
export interface $ZodTransformDef extends $ZodTypeDef {
|
| 849 |
+
type: "transform";
|
| 850 |
+
transform: (input: unknown, payload: ParsePayload<unknown>) => util.MaybeAsync<unknown>;
|
| 851 |
+
}
|
| 852 |
+
export interface $ZodTransformInternals<O = unknown, I = unknown> extends $ZodTypeInternals<O, I> {
|
| 853 |
+
def: $ZodTransformDef;
|
| 854 |
+
isst: never;
|
| 855 |
+
}
|
| 856 |
+
export interface $ZodTransform<O = unknown, I = unknown> extends $ZodType {
|
| 857 |
+
_zod: $ZodTransformInternals<O, I>;
|
| 858 |
+
}
|
| 859 |
+
export declare const $ZodTransform: core.$constructor<$ZodTransform>;
|
| 860 |
+
export interface $ZodOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 861 |
+
type: "optional";
|
| 862 |
+
innerType: T;
|
| 863 |
+
}
|
| 864 |
+
export interface $ZodOptionalInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T> | undefined, core.input<T> | undefined> {
|
| 865 |
+
def: $ZodOptionalDef<T>;
|
| 866 |
+
optin: "optional";
|
| 867 |
+
optout: "optional";
|
| 868 |
+
isst: never;
|
| 869 |
+
values: T["_zod"]["values"];
|
| 870 |
+
pattern: T["_zod"]["pattern"];
|
| 871 |
+
}
|
| 872 |
+
export interface $ZodOptional<T extends SomeType = $ZodType> extends $ZodType {
|
| 873 |
+
_zod: $ZodOptionalInternals<T>;
|
| 874 |
+
}
|
| 875 |
+
export declare const $ZodOptional: core.$constructor<$ZodOptional>;
|
| 876 |
+
export interface $ZodExactOptionalDef<T extends SomeType = $ZodType> extends $ZodOptionalDef<T> {
|
| 877 |
+
}
|
| 878 |
+
export interface $ZodExactOptionalInternals<T extends SomeType = $ZodType> extends $ZodOptionalInternals<T> {
|
| 879 |
+
def: $ZodExactOptionalDef<T>;
|
| 880 |
+
output: core.output<T>;
|
| 881 |
+
input: core.input<T>;
|
| 882 |
+
}
|
| 883 |
+
export interface $ZodExactOptional<T extends SomeType = $ZodType> extends $ZodType {
|
| 884 |
+
_zod: $ZodExactOptionalInternals<T>;
|
| 885 |
+
}
|
| 886 |
+
export declare const $ZodExactOptional: core.$constructor<$ZodExactOptional>;
|
| 887 |
+
export interface $ZodNullableDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 888 |
+
type: "nullable";
|
| 889 |
+
innerType: T;
|
| 890 |
+
}
|
| 891 |
+
export interface $ZodNullableInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T> | null, core.input<T> | null> {
|
| 892 |
+
def: $ZodNullableDef<T>;
|
| 893 |
+
optin: T["_zod"]["optin"];
|
| 894 |
+
optout: T["_zod"]["optout"];
|
| 895 |
+
isst: never;
|
| 896 |
+
values: T["_zod"]["values"];
|
| 897 |
+
pattern: T["_zod"]["pattern"];
|
| 898 |
+
}
|
| 899 |
+
export interface $ZodNullable<T extends SomeType = $ZodType> extends $ZodType {
|
| 900 |
+
_zod: $ZodNullableInternals<T>;
|
| 901 |
+
}
|
| 902 |
+
export declare const $ZodNullable: core.$constructor<$ZodNullable>;
|
| 903 |
+
export interface $ZodDefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 904 |
+
type: "default";
|
| 905 |
+
innerType: T;
|
| 906 |
+
/** The default value. May be a getter. */
|
| 907 |
+
defaultValue: util.NoUndefined<core.output<T>>;
|
| 908 |
+
}
|
| 909 |
+
export interface $ZodDefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
|
| 910 |
+
def: $ZodDefaultDef<T>;
|
| 911 |
+
optin: "optional";
|
| 912 |
+
optout?: "optional" | undefined;
|
| 913 |
+
isst: never;
|
| 914 |
+
values: T["_zod"]["values"];
|
| 915 |
+
}
|
| 916 |
+
export interface $ZodDefault<T extends SomeType = $ZodType> extends $ZodType {
|
| 917 |
+
_zod: $ZodDefaultInternals<T>;
|
| 918 |
+
}
|
| 919 |
+
export declare const $ZodDefault: core.$constructor<$ZodDefault>;
|
| 920 |
+
export interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 921 |
+
type: "prefault";
|
| 922 |
+
innerType: T;
|
| 923 |
+
/** The default value. May be a getter. */
|
| 924 |
+
defaultValue: core.input<T>;
|
| 925 |
+
}
|
| 926 |
+
export interface $ZodPrefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
|
| 927 |
+
def: $ZodPrefaultDef<T>;
|
| 928 |
+
optin: "optional";
|
| 929 |
+
optout?: "optional" | undefined;
|
| 930 |
+
isst: never;
|
| 931 |
+
values: T["_zod"]["values"];
|
| 932 |
+
}
|
| 933 |
+
export interface $ZodPrefault<T extends SomeType = $ZodType> extends $ZodType {
|
| 934 |
+
_zod: $ZodPrefaultInternals<T>;
|
| 935 |
+
}
|
| 936 |
+
export declare const $ZodPrefault: core.$constructor<$ZodPrefault>;
|
| 937 |
+
export interface $ZodNonOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 938 |
+
type: "nonoptional";
|
| 939 |
+
innerType: T;
|
| 940 |
+
}
|
| 941 |
+
export interface $ZodNonOptionalInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, util.NoUndefined<core.input<T>>> {
|
| 942 |
+
def: $ZodNonOptionalDef<T>;
|
| 943 |
+
isst: errors.$ZodIssueInvalidType;
|
| 944 |
+
values: T["_zod"]["values"];
|
| 945 |
+
optin: "optional" | undefined;
|
| 946 |
+
optout: "optional" | undefined;
|
| 947 |
+
}
|
| 948 |
+
export interface $ZodNonOptional<T extends SomeType = $ZodType> extends $ZodType {
|
| 949 |
+
_zod: $ZodNonOptionalInternals<T>;
|
| 950 |
+
}
|
| 951 |
+
export declare const $ZodNonOptional: core.$constructor<$ZodNonOptional>;
|
| 952 |
+
export interface $ZodSuccessDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 953 |
+
type: "success";
|
| 954 |
+
innerType: T;
|
| 955 |
+
}
|
| 956 |
+
export interface $ZodSuccessInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<boolean, core.input<T>> {
|
| 957 |
+
def: $ZodSuccessDef<T>;
|
| 958 |
+
isst: never;
|
| 959 |
+
optin: T["_zod"]["optin"];
|
| 960 |
+
optout: "optional" | undefined;
|
| 961 |
+
}
|
| 962 |
+
export interface $ZodSuccess<T extends SomeType = $ZodType> extends $ZodType {
|
| 963 |
+
_zod: $ZodSuccessInternals<T>;
|
| 964 |
+
}
|
| 965 |
+
export declare const $ZodSuccess: core.$constructor<$ZodSuccess>;
|
| 966 |
+
export interface $ZodCatchCtx extends ParsePayload {
|
| 967 |
+
/** @deprecated Use `ctx.issues` */
|
| 968 |
+
error: {
|
| 969 |
+
issues: errors.$ZodIssue[];
|
| 970 |
+
};
|
| 971 |
+
/** @deprecated Use `ctx.value` */
|
| 972 |
+
input: unknown;
|
| 973 |
+
}
|
| 974 |
+
export interface $ZodCatchDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 975 |
+
type: "catch";
|
| 976 |
+
innerType: T;
|
| 977 |
+
catchValue: (ctx: $ZodCatchCtx) => unknown;
|
| 978 |
+
}
|
| 979 |
+
export interface $ZodCatchInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, core.input<T>> {
|
| 980 |
+
def: $ZodCatchDef<T>;
|
| 981 |
+
optin: T["_zod"]["optin"];
|
| 982 |
+
optout: T["_zod"]["optout"];
|
| 983 |
+
isst: never;
|
| 984 |
+
values: T["_zod"]["values"];
|
| 985 |
+
}
|
| 986 |
+
export interface $ZodCatch<T extends SomeType = $ZodType> extends $ZodType {
|
| 987 |
+
_zod: $ZodCatchInternals<T>;
|
| 988 |
+
}
|
| 989 |
+
export declare const $ZodCatch: core.$constructor<$ZodCatch>;
|
| 990 |
+
export interface $ZodNaNDef extends $ZodTypeDef {
|
| 991 |
+
type: "nan";
|
| 992 |
+
}
|
| 993 |
+
export interface $ZodNaNInternals extends $ZodTypeInternals<number, number> {
|
| 994 |
+
def: $ZodNaNDef;
|
| 995 |
+
isst: errors.$ZodIssueInvalidType;
|
| 996 |
+
}
|
| 997 |
+
export interface $ZodNaN extends $ZodType {
|
| 998 |
+
_zod: $ZodNaNInternals;
|
| 999 |
+
}
|
| 1000 |
+
export declare const $ZodNaN: core.$constructor<$ZodNaN>;
|
| 1001 |
+
export interface $ZodPipeDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 1002 |
+
type: "pipe";
|
| 1003 |
+
in: A;
|
| 1004 |
+
out: B;
|
| 1005 |
+
/** Only defined inside $ZodCodec instances. */
|
| 1006 |
+
transform?: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
|
| 1007 |
+
/** Only defined inside $ZodCodec instances. */
|
| 1008 |
+
reverseTransform?: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
|
| 1009 |
+
}
|
| 1010 |
+
export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
|
| 1011 |
+
def: $ZodPipeDef<A, B>;
|
| 1012 |
+
isst: never;
|
| 1013 |
+
values: A["_zod"]["values"];
|
| 1014 |
+
optin: A["_zod"]["optin"];
|
| 1015 |
+
optout: B["_zod"]["optout"];
|
| 1016 |
+
propValues: A["_zod"]["propValues"];
|
| 1017 |
+
}
|
| 1018 |
+
export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
| 1019 |
+
_zod: $ZodPipeInternals<A, B>;
|
| 1020 |
+
}
|
| 1021 |
+
export declare const $ZodPipe: core.$constructor<$ZodPipe>;
|
| 1022 |
+
export interface $ZodCodecDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodPipeDef<A, B> {
|
| 1023 |
+
transform: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
|
| 1024 |
+
reverseTransform: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
|
| 1025 |
+
}
|
| 1026 |
+
export interface $ZodCodecInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
|
| 1027 |
+
def: $ZodCodecDef<A, B>;
|
| 1028 |
+
isst: never;
|
| 1029 |
+
values: A["_zod"]["values"];
|
| 1030 |
+
optin: A["_zod"]["optin"];
|
| 1031 |
+
optout: B["_zod"]["optout"];
|
| 1032 |
+
propValues: A["_zod"]["propValues"];
|
| 1033 |
+
}
|
| 1034 |
+
export interface $ZodCodec<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
|
| 1035 |
+
_zod: $ZodCodecInternals<A, B>;
|
| 1036 |
+
}
|
| 1037 |
+
export declare const $ZodCodec: core.$constructor<$ZodCodec>;
|
| 1038 |
+
export interface $ZodPreprocessDef<B extends SomeType = $ZodType> extends $ZodPipeDef<$ZodTransform, B> {
|
| 1039 |
+
in: $ZodTransform;
|
| 1040 |
+
out: B;
|
| 1041 |
+
}
|
| 1042 |
+
export interface $ZodPreprocessInternals<B extends SomeType = $ZodType> extends $ZodPipeInternals<$ZodTransform, B> {
|
| 1043 |
+
def: $ZodPreprocessDef<B>;
|
| 1044 |
+
optin: B["_zod"]["optin"];
|
| 1045 |
+
optout: B["_zod"]["optout"];
|
| 1046 |
+
}
|
| 1047 |
+
export interface $ZodPreprocess<B extends SomeType = $ZodType> extends $ZodPipe<$ZodTransform, B> {
|
| 1048 |
+
_zod: $ZodPreprocessInternals<B>;
|
| 1049 |
+
}
|
| 1050 |
+
export declare const $ZodPreprocess: core.$constructor<$ZodPreprocess>;
|
| 1051 |
+
export interface $ZodReadonlyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 1052 |
+
type: "readonly";
|
| 1053 |
+
innerType: T;
|
| 1054 |
+
}
|
| 1055 |
+
export interface $ZodReadonlyInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<util.MakeReadonly<core.output<T>>, util.MakeReadonly<core.input<T>>> {
|
| 1056 |
+
def: $ZodReadonlyDef<T>;
|
| 1057 |
+
optin: T["_zod"]["optin"];
|
| 1058 |
+
optout: T["_zod"]["optout"];
|
| 1059 |
+
isst: never;
|
| 1060 |
+
propValues: T["_zod"]["propValues"];
|
| 1061 |
+
values: T["_zod"]["values"];
|
| 1062 |
+
}
|
| 1063 |
+
export interface $ZodReadonly<T extends SomeType = $ZodType> extends $ZodType {
|
| 1064 |
+
_zod: $ZodReadonlyInternals<T>;
|
| 1065 |
+
}
|
| 1066 |
+
export declare const $ZodReadonly: core.$constructor<$ZodReadonly>;
|
| 1067 |
+
export interface $ZodTemplateLiteralDef extends $ZodTypeDef {
|
| 1068 |
+
type: "template_literal";
|
| 1069 |
+
parts: $ZodTemplateLiteralPart[];
|
| 1070 |
+
format?: string | undefined;
|
| 1071 |
+
}
|
| 1072 |
+
export interface $ZodTemplateLiteralInternals<Template extends string = string> extends $ZodTypeInternals<Template, Template> {
|
| 1073 |
+
pattern: RegExp;
|
| 1074 |
+
def: $ZodTemplateLiteralDef;
|
| 1075 |
+
isst: errors.$ZodIssueInvalidType;
|
| 1076 |
+
}
|
| 1077 |
+
export interface $ZodTemplateLiteral<Template extends string = string> extends $ZodType {
|
| 1078 |
+
_zod: $ZodTemplateLiteralInternals<Template>;
|
| 1079 |
+
}
|
| 1080 |
+
type LiteralPart = Exclude<util.Literal, symbol>;
|
| 1081 |
+
interface SchemaPartInternals extends $ZodTypeInternals<LiteralPart, LiteralPart> {
|
| 1082 |
+
pattern: RegExp;
|
| 1083 |
+
}
|
| 1084 |
+
interface SchemaPart extends $ZodType {
|
| 1085 |
+
_zod: SchemaPartInternals;
|
| 1086 |
+
}
|
| 1087 |
+
export type $ZodTemplateLiteralPart = LiteralPart | SchemaPart;
|
| 1088 |
+
type UndefinedToEmptyString<T> = T extends undefined ? "" : T;
|
| 1089 |
+
type AppendToTemplateLiteral<Template extends string, Suffix extends LiteralPart | $ZodType> = Suffix extends LiteralPart ? `${Template}${UndefinedToEmptyString<Suffix>}` : Suffix extends $ZodType ? `${Template}${core.output<Suffix> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}` : never;
|
| 1090 |
+
export type ConcatenateTupleOfStrings<T extends string[]> = T extends [
|
| 1091 |
+
infer First extends string,
|
| 1092 |
+
...infer Rest extends string[]
|
| 1093 |
+
] ? Rest extends string[] ? First extends "" ? ConcatenateTupleOfStrings<Rest> : `${First}${ConcatenateTupleOfStrings<Rest>}` : never : "";
|
| 1094 |
+
export type ConvertPartsToStringTuple<Parts extends $ZodTemplateLiteralPart[]> = {
|
| 1095 |
+
[K in keyof Parts]: Parts[K] extends LiteralPart ? `${UndefinedToEmptyString<Parts[K]>}` : Parts[K] extends $ZodType ? `${core.output<Parts[K]> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}` : never;
|
| 1096 |
+
};
|
| 1097 |
+
export type ToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = ConcatenateTupleOfStrings<ConvertPartsToStringTuple<Parts>>;
|
| 1098 |
+
export type $PartsToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = [] extends Parts ? `` : Parts extends [...infer Rest, infer Last extends $ZodTemplateLiteralPart] ? Rest extends $ZodTemplateLiteralPart[] ? AppendToTemplateLiteral<$PartsToTemplateLiteral<Rest>, Last> : never : never;
|
| 1099 |
+
export declare const $ZodTemplateLiteral: core.$constructor<$ZodTemplateLiteral>;
|
| 1100 |
+
export type $ZodFunctionArgs = $ZodType<unknown[], unknown[]>;
|
| 1101 |
+
export type $ZodFunctionIn = $ZodFunctionArgs;
|
| 1102 |
+
export type $ZodFunctionOut = $ZodType;
|
| 1103 |
+
export type $InferInnerFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>) => core.input<Returns>;
|
| 1104 |
+
export type $InferInnerFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>) => util.MaybeAsync<core.input<Returns>>;
|
| 1105 |
+
export type $InferOuterFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>) => core.output<Returns>;
|
| 1106 |
+
export type $InferOuterFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>) => Promise<core.output<Returns>>;
|
| 1107 |
+
export interface $ZodFunctionDef<In extends $ZodFunctionIn = $ZodFunctionIn, Out extends $ZodFunctionOut = $ZodFunctionOut> extends $ZodTypeDef {
|
| 1108 |
+
type: "function";
|
| 1109 |
+
input: In;
|
| 1110 |
+
output: Out;
|
| 1111 |
+
}
|
| 1112 |
+
export interface $ZodFunctionInternals<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> extends $ZodTypeInternals<$InferOuterFunctionType<Args, Returns>, $InferInnerFunctionType<Args, Returns>> {
|
| 1113 |
+
def: $ZodFunctionDef<Args, Returns>;
|
| 1114 |
+
isst: errors.$ZodIssueInvalidType;
|
| 1115 |
+
}
|
| 1116 |
+
export interface $ZodFunction<Args extends $ZodFunctionIn = $ZodFunctionIn, Returns extends $ZodFunctionOut = $ZodFunctionOut> extends $ZodType<any, any, $ZodFunctionInternals<Args, Returns>> {
|
| 1117 |
+
/** @deprecated */
|
| 1118 |
+
_def: $ZodFunctionDef<Args, Returns>;
|
| 1119 |
+
_input: $InferInnerFunctionType<Args, Returns>;
|
| 1120 |
+
_output: $InferOuterFunctionType<Args, Returns>;
|
| 1121 |
+
implement<F extends $InferInnerFunctionType<Args, Returns>>(func: F): (...args: Parameters<this["_output"]>) => ReturnType<F> extends ReturnType<this["_output"]> ? ReturnType<F> : ReturnType<this["_output"]>;
|
| 1122 |
+
implementAsync<F extends $InferInnerFunctionTypeAsync<Args, Returns>>(func: F): F extends $InferOuterFunctionTypeAsync<Args, Returns> ? F : $InferOuterFunctionTypeAsync<Args, Returns>;
|
| 1123 |
+
input<const Items extends util.TupleItems, const Rest extends $ZodFunctionOut = $ZodFunctionOut>(args: Items, rest?: Rest): $ZodFunction<$ZodTuple<Items, Rest>, Returns>;
|
| 1124 |
+
input<NewArgs extends $ZodFunctionIn>(args: NewArgs): $ZodFunction<NewArgs, Returns>;
|
| 1125 |
+
input(...args: any[]): $ZodFunction<any, Returns>;
|
| 1126 |
+
output<NewReturns extends $ZodType>(output: NewReturns): $ZodFunction<Args, NewReturns>;
|
| 1127 |
+
}
|
| 1128 |
+
export interface $ZodFunctionParams<I extends $ZodFunctionIn, O extends $ZodType> {
|
| 1129 |
+
input?: I;
|
| 1130 |
+
output?: O;
|
| 1131 |
+
}
|
| 1132 |
+
export declare const $ZodFunction: core.$constructor<$ZodFunction>;
|
| 1133 |
+
export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 1134 |
+
type: "promise";
|
| 1135 |
+
innerType: T;
|
| 1136 |
+
}
|
| 1137 |
+
export interface $ZodPromiseInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<Promise<core.output<T>>, util.MaybeAsync<core.input<T>>> {
|
| 1138 |
+
def: $ZodPromiseDef<T>;
|
| 1139 |
+
isst: never;
|
| 1140 |
+
}
|
| 1141 |
+
export interface $ZodPromise<T extends SomeType = $ZodType> extends $ZodType {
|
| 1142 |
+
_zod: $ZodPromiseInternals<T>;
|
| 1143 |
+
}
|
| 1144 |
+
export declare const $ZodPromise: core.$constructor<$ZodPromise>;
|
| 1145 |
+
export interface $ZodLazyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
| 1146 |
+
type: "lazy";
|
| 1147 |
+
getter: () => T;
|
| 1148 |
+
}
|
| 1149 |
+
export interface $ZodLazyInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, core.input<T>> {
|
| 1150 |
+
def: $ZodLazyDef<T>;
|
| 1151 |
+
isst: never;
|
| 1152 |
+
/** Auto-cached way to retrieve the inner schema */
|
| 1153 |
+
innerType: T;
|
| 1154 |
+
pattern: T["_zod"]["pattern"];
|
| 1155 |
+
propValues: T["_zod"]["propValues"];
|
| 1156 |
+
optin: T["_zod"]["optin"];
|
| 1157 |
+
optout: T["_zod"]["optout"];
|
| 1158 |
+
}
|
| 1159 |
+
export interface $ZodLazy<T extends SomeType = $ZodType> extends $ZodType {
|
| 1160 |
+
_zod: $ZodLazyInternals<T>;
|
| 1161 |
+
}
|
| 1162 |
+
export declare const $ZodLazy: core.$constructor<$ZodLazy>;
|
| 1163 |
+
export interface $ZodCustomDef<O = unknown> extends $ZodTypeDef, checks.$ZodCheckDef {
|
| 1164 |
+
type: "custom";
|
| 1165 |
+
check: "custom";
|
| 1166 |
+
path?: PropertyKey[] | undefined;
|
| 1167 |
+
error?: errors.$ZodErrorMap | undefined;
|
| 1168 |
+
params?: Record<string, any> | undefined;
|
| 1169 |
+
fn: (arg: O) => unknown;
|
| 1170 |
+
}
|
| 1171 |
+
export interface $ZodCustomInternals<O = unknown, I = unknown> extends $ZodTypeInternals<O, I>, checks.$ZodCheckInternals<O> {
|
| 1172 |
+
def: $ZodCustomDef;
|
| 1173 |
+
issc: errors.$ZodIssue;
|
| 1174 |
+
isst: never;
|
| 1175 |
+
bag: util.LoosePartial<{
|
| 1176 |
+
Class: typeof util.Class;
|
| 1177 |
+
}>;
|
| 1178 |
+
}
|
| 1179 |
+
export interface $ZodCustom<O = unknown, I = unknown> extends $ZodType {
|
| 1180 |
+
_zod: $ZodCustomInternals<O, I>;
|
| 1181 |
+
}
|
| 1182 |
+
export declare const $ZodCustom: core.$constructor<$ZodCustom>;
|
| 1183 |
+
export type $ZodTypes = $ZodString | $ZodNumber | $ZodBigInt | $ZodBoolean | $ZodDate | $ZodSymbol | $ZodUndefined | $ZodNullable | $ZodNull | $ZodAny | $ZodUnknown | $ZodNever | $ZodVoid | $ZodArray | $ZodObject | $ZodUnion | $ZodIntersection | $ZodTuple | $ZodRecord | $ZodMap | $ZodSet | $ZodLiteral | $ZodEnum | $ZodFunction | $ZodPromise | $ZodLazy | $ZodOptional | $ZodDefault | $ZodPrefault | $ZodTemplateLiteral | $ZodCustom | $ZodTransform | $ZodNonOptional | $ZodReadonly | $ZodNaN | $ZodPipe | $ZodSuccess | $ZodCatch | $ZodFile;
|
| 1184 |
+
export type $ZodStringFormatTypes = $ZodGUID | $ZodUUID | $ZodEmail | $ZodURL | $ZodEmoji | $ZodNanoID | $ZodCUID | $ZodCUID2 | $ZodULID | $ZodXID | $ZodKSUID | $ZodISODateTime | $ZodISODate | $ZodISOTime | $ZodISODuration | $ZodIPv4 | $ZodIPv6 | $ZodMAC | $ZodCIDRv4 | $ZodCIDRv6 | $ZodBase64 | $ZodBase64URL | $ZodE164 | $ZodJWT | $ZodCustomStringFormat<"hex"> | $ZodCustomStringFormat<util.HashFormat> | $ZodCustomStringFormat<"hostname">;
|
node_modules/zod/v4/core/schemas.js
ADDED
|
@@ -0,0 +1,2239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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from "./doc.js";
|
| 4 |
+
import { parse, parseAsync, safeParse, safeParseAsync } from "./parse.js";
|
| 5 |
+
import * as regexes from "./regexes.js";
|
| 6 |
+
import * as util from "./util.js";
|
| 7 |
+
import { version } from "./versions.js";
|
| 8 |
+
export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def) => {
|
| 9 |
+
var _a;
|
| 10 |
+
inst ?? (inst = {});
|
| 11 |
+
inst._zod.def = def; // set _def property
|
| 12 |
+
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
| 13 |
+
inst._zod.version = version;
|
| 14 |
+
const checks = [...(inst._zod.def.checks ?? [])];
|
| 15 |
+
// if inst is itself a checks.$ZodCheck, run it as a check
|
| 16 |
+
if (inst._zod.traits.has("$ZodCheck")) {
|
| 17 |
+
checks.unshift(inst);
|
| 18 |
+
}
|
| 19 |
+
for (const ch of checks) {
|
| 20 |
+
for (const fn of ch._zod.onattach) {
|
| 21 |
+
fn(inst);
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
if (checks.length === 0) {
|
| 25 |
+
// deferred initializer
|
| 26 |
+
// inst._zod.parse is not yet defined
|
| 27 |
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
| 28 |
+
inst._zod.deferred?.push(() => {
|
| 29 |
+
inst._zod.run = inst._zod.parse;
|
| 30 |
+
});
|
| 31 |
+
}
|
| 32 |
+
else {
|
| 33 |
+
const runChecks = (payload, checks, ctx) => {
|
| 34 |
+
let isAborted = util.aborted(payload);
|
| 35 |
+
let asyncResult;
|
| 36 |
+
for (const ch of checks) {
|
| 37 |
+
if (ch._zod.def.when) {
|
| 38 |
+
if (util.explicitlyAborted(payload))
|
| 39 |
+
continue;
|
| 40 |
+
const shouldRun = ch._zod.def.when(payload);
|
| 41 |
+
if (!shouldRun)
|
| 42 |
+
continue;
|
| 43 |
+
}
|
| 44 |
+
else if (isAborted) {
|
| 45 |
+
continue;
|
| 46 |
+
}
|
| 47 |
+
const currLen = payload.issues.length;
|
| 48 |
+
const _ = ch._zod.check(payload);
|
| 49 |
+
if (_ instanceof Promise && ctx?.async === false) {
|
| 50 |
+
throw new core.$ZodAsyncError();
|
| 51 |
+
}
|
| 52 |
+
if (asyncResult || _ instanceof Promise) {
|
| 53 |
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
| 54 |
+
await _;
|
| 55 |
+
const nextLen = payload.issues.length;
|
| 56 |
+
if (nextLen === currLen)
|
| 57 |
+
return;
|
| 58 |
+
if (!isAborted)
|
| 59 |
+
isAborted = util.aborted(payload, currLen);
|
| 60 |
+
});
|
| 61 |
+
}
|
| 62 |
+
else {
|
| 63 |
+
const nextLen = payload.issues.length;
|
| 64 |
+
if (nextLen === currLen)
|
| 65 |
+
continue;
|
| 66 |
+
if (!isAborted)
|
| 67 |
+
isAborted = util.aborted(payload, currLen);
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
if (asyncResult) {
|
| 71 |
+
return asyncResult.then(() => {
|
| 72 |
+
return payload;
|
| 73 |
+
});
|
| 74 |
+
}
|
| 75 |
+
return payload;
|
| 76 |
+
};
|
| 77 |
+
const handleCanaryResult = (canary, payload, ctx) => {
|
| 78 |
+
// abort if the canary is aborted
|
| 79 |
+
if (util.aborted(canary)) {
|
| 80 |
+
canary.aborted = true;
|
| 81 |
+
return canary;
|
| 82 |
+
}
|
| 83 |
+
// run checks first, then
|
| 84 |
+
const checkResult = runChecks(payload, checks, ctx);
|
| 85 |
+
if (checkResult instanceof Promise) {
|
| 86 |
+
if (ctx.async === false)
|
| 87 |
+
throw new core.$ZodAsyncError();
|
| 88 |
+
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
| 89 |
+
}
|
| 90 |
+
return inst._zod.parse(checkResult, ctx);
|
| 91 |
+
};
|
| 92 |
+
inst._zod.run = (payload, ctx) => {
|
| 93 |
+
if (ctx.skipChecks) {
|
| 94 |
+
return inst._zod.parse(payload, ctx);
|
| 95 |
+
}
|
| 96 |
+
if (ctx.direction === "backward") {
|
| 97 |
+
// run canary
|
| 98 |
+
// initial pass (no checks)
|
| 99 |
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
| 100 |
+
if (canary instanceof Promise) {
|
| 101 |
+
return canary.then((canary) => {
|
| 102 |
+
return handleCanaryResult(canary, payload, ctx);
|
| 103 |
+
});
|
| 104 |
+
}
|
| 105 |
+
return handleCanaryResult(canary, payload, ctx);
|
| 106 |
+
}
|
| 107 |
+
// forward
|
| 108 |
+
const result = inst._zod.parse(payload, ctx);
|
| 109 |
+
if (result instanceof Promise) {
|
| 110 |
+
if (ctx.async === false)
|
| 111 |
+
throw new core.$ZodAsyncError();
|
| 112 |
+
return result.then((result) => runChecks(result, checks, ctx));
|
| 113 |
+
}
|
| 114 |
+
return runChecks(result, checks, ctx);
|
| 115 |
+
};
|
| 116 |
+
}
|
| 117 |
+
// Lazy initialize ~standard to avoid creating objects for every schema
|
| 118 |
+
util.defineLazy(inst, "~standard", () => ({
|
| 119 |
+
validate: (value) => {
|
| 120 |
+
try {
|
| 121 |
+
const r = safeParse(inst, value);
|
| 122 |
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
| 123 |
+
}
|
| 124 |
+
catch (_) {
|
| 125 |
+
return safeParseAsync(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
|
| 126 |
+
}
|
| 127 |
+
},
|
| 128 |
+
vendor: "zod",
|
| 129 |
+
version: 1,
|
| 130 |
+
}));
|
| 131 |
+
});
|
| 132 |
+
export { clone } from "./util.js";
|
| 133 |
+
export const $ZodString = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
|
| 134 |
+
$ZodType.init(inst, def);
|
| 135 |
+
inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? regexes.string(inst._zod.bag);
|
| 136 |
+
inst._zod.parse = (payload, _) => {
|
| 137 |
+
if (def.coerce)
|
| 138 |
+
try {
|
| 139 |
+
payload.value = String(payload.value);
|
| 140 |
+
}
|
| 141 |
+
catch (_) { }
|
| 142 |
+
if (typeof payload.value === "string")
|
| 143 |
+
return payload;
|
| 144 |
+
payload.issues.push({
|
| 145 |
+
expected: "string",
|
| 146 |
+
code: "invalid_type",
|
| 147 |
+
input: payload.value,
|
| 148 |
+
inst,
|
| 149 |
+
});
|
| 150 |
+
return payload;
|
| 151 |
+
};
|
| 152 |
+
});
|
| 153 |
+
export const $ZodStringFormat = /*@__PURE__*/ core.$constructor("$ZodStringFormat", (inst, def) => {
|
| 154 |
+
// check initialization must come first
|
| 155 |
+
checks.$ZodCheckStringFormat.init(inst, def);
|
| 156 |
+
$ZodString.init(inst, def);
|
| 157 |
+
});
|
| 158 |
+
export const $ZodGUID = /*@__PURE__*/ core.$constructor("$ZodGUID", (inst, def) => {
|
| 159 |
+
def.pattern ?? (def.pattern = regexes.guid);
|
| 160 |
+
$ZodStringFormat.init(inst, def);
|
| 161 |
+
});
|
| 162 |
+
export const $ZodUUID = /*@__PURE__*/ core.$constructor("$ZodUUID", (inst, def) => {
|
| 163 |
+
if (def.version) {
|
| 164 |
+
const versionMap = {
|
| 165 |
+
v1: 1,
|
| 166 |
+
v2: 2,
|
| 167 |
+
v3: 3,
|
| 168 |
+
v4: 4,
|
| 169 |
+
v5: 5,
|
| 170 |
+
v6: 6,
|
| 171 |
+
v7: 7,
|
| 172 |
+
v8: 8,
|
| 173 |
+
};
|
| 174 |
+
const v = versionMap[def.version];
|
| 175 |
+
if (v === undefined)
|
| 176 |
+
throw new Error(`Invalid UUID version: "${def.version}"`);
|
| 177 |
+
def.pattern ?? (def.pattern = regexes.uuid(v));
|
| 178 |
+
}
|
| 179 |
+
else
|
| 180 |
+
def.pattern ?? (def.pattern = regexes.uuid());
|
| 181 |
+
$ZodStringFormat.init(inst, def);
|
| 182 |
+
});
|
| 183 |
+
export const $ZodEmail = /*@__PURE__*/ core.$constructor("$ZodEmail", (inst, def) => {
|
| 184 |
+
def.pattern ?? (def.pattern = regexes.email);
|
| 185 |
+
$ZodStringFormat.init(inst, def);
|
| 186 |
+
});
|
| 187 |
+
export const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
|
| 188 |
+
$ZodStringFormat.init(inst, def);
|
| 189 |
+
inst._zod.check = (payload) => {
|
| 190 |
+
try {
|
| 191 |
+
// Trim whitespace from input
|
| 192 |
+
const trimmed = payload.value.trim();
|
| 193 |
+
// When normalize is off, require :// for http/https URLs
|
| 194 |
+
// This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
| 195 |
+
if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source) {
|
| 196 |
+
if (!/^https?:\/\//i.test(trimmed)) {
|
| 197 |
+
payload.issues.push({
|
| 198 |
+
code: "invalid_format",
|
| 199 |
+
format: "url",
|
| 200 |
+
note: "Invalid URL format",
|
| 201 |
+
input: payload.value,
|
| 202 |
+
inst,
|
| 203 |
+
continue: !def.abort,
|
| 204 |
+
});
|
| 205 |
+
return;
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
// @ts-ignore
|
| 209 |
+
const url = new URL(trimmed);
|
| 210 |
+
if (def.hostname) {
|
| 211 |
+
def.hostname.lastIndex = 0;
|
| 212 |
+
if (!def.hostname.test(url.hostname)) {
|
| 213 |
+
payload.issues.push({
|
| 214 |
+
code: "invalid_format",
|
| 215 |
+
format: "url",
|
| 216 |
+
note: "Invalid hostname",
|
| 217 |
+
pattern: def.hostname.source,
|
| 218 |
+
input: payload.value,
|
| 219 |
+
inst,
|
| 220 |
+
continue: !def.abort,
|
| 221 |
+
});
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
if (def.protocol) {
|
| 225 |
+
def.protocol.lastIndex = 0;
|
| 226 |
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
|
| 227 |
+
payload.issues.push({
|
| 228 |
+
code: "invalid_format",
|
| 229 |
+
format: "url",
|
| 230 |
+
note: "Invalid protocol",
|
| 231 |
+
pattern: def.protocol.source,
|
| 232 |
+
input: payload.value,
|
| 233 |
+
inst,
|
| 234 |
+
continue: !def.abort,
|
| 235 |
+
});
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
// Set the output value based on normalize flag
|
| 239 |
+
if (def.normalize) {
|
| 240 |
+
// Use normalized URL
|
| 241 |
+
payload.value = url.href;
|
| 242 |
+
}
|
| 243 |
+
else {
|
| 244 |
+
// Preserve the original input (trimmed)
|
| 245 |
+
payload.value = trimmed;
|
| 246 |
+
}
|
| 247 |
+
return;
|
| 248 |
+
}
|
| 249 |
+
catch (_) {
|
| 250 |
+
payload.issues.push({
|
| 251 |
+
code: "invalid_format",
|
| 252 |
+
format: "url",
|
| 253 |
+
input: payload.value,
|
| 254 |
+
inst,
|
| 255 |
+
continue: !def.abort,
|
| 256 |
+
});
|
| 257 |
+
}
|
| 258 |
+
};
|
| 259 |
+
});
|
| 260 |
+
export const $ZodEmoji = /*@__PURE__*/ core.$constructor("$ZodEmoji", (inst, def) => {
|
| 261 |
+
def.pattern ?? (def.pattern = regexes.emoji());
|
| 262 |
+
$ZodStringFormat.init(inst, def);
|
| 263 |
+
});
|
| 264 |
+
export const $ZodNanoID = /*@__PURE__*/ core.$constructor("$ZodNanoID", (inst, def) => {
|
| 265 |
+
def.pattern ?? (def.pattern = regexes.nanoid);
|
| 266 |
+
$ZodStringFormat.init(inst, def);
|
| 267 |
+
});
|
| 268 |
+
/**
|
| 269 |
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
| 270 |
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
| 271 |
+
* See https://github.com/paralleldrive/cuid.
|
| 272 |
+
*/
|
| 273 |
+
export const $ZodCUID = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def) => {
|
| 274 |
+
def.pattern ?? (def.pattern = regexes.cuid);
|
| 275 |
+
$ZodStringFormat.init(inst, def);
|
| 276 |
+
});
|
| 277 |
+
export const $ZodCUID2 = /*@__PURE__*/ core.$constructor("$ZodCUID2", (inst, def) => {
|
| 278 |
+
def.pattern ?? (def.pattern = regexes.cuid2);
|
| 279 |
+
$ZodStringFormat.init(inst, def);
|
| 280 |
+
});
|
| 281 |
+
export const $ZodULID = /*@__PURE__*/ core.$constructor("$ZodULID", (inst, def) => {
|
| 282 |
+
def.pattern ?? (def.pattern = regexes.ulid);
|
| 283 |
+
$ZodStringFormat.init(inst, def);
|
| 284 |
+
});
|
| 285 |
+
export const $ZodXID = /*@__PURE__*/ core.$constructor("$ZodXID", (inst, def) => {
|
| 286 |
+
def.pattern ?? (def.pattern = regexes.xid);
|
| 287 |
+
$ZodStringFormat.init(inst, def);
|
| 288 |
+
});
|
| 289 |
+
export const $ZodKSUID = /*@__PURE__*/ core.$constructor("$ZodKSUID", (inst, def) => {
|
| 290 |
+
def.pattern ?? (def.pattern = regexes.ksuid);
|
| 291 |
+
$ZodStringFormat.init(inst, def);
|
| 292 |
+
});
|
| 293 |
+
export const $ZodISODateTime = /*@__PURE__*/ core.$constructor("$ZodISODateTime", (inst, def) => {
|
| 294 |
+
def.pattern ?? (def.pattern = regexes.datetime(def));
|
| 295 |
+
$ZodStringFormat.init(inst, def);
|
| 296 |
+
});
|
| 297 |
+
export const $ZodISODate = /*@__PURE__*/ core.$constructor("$ZodISODate", (inst, def) => {
|
| 298 |
+
def.pattern ?? (def.pattern = regexes.date);
|
| 299 |
+
$ZodStringFormat.init(inst, def);
|
| 300 |
+
});
|
| 301 |
+
export const $ZodISOTime = /*@__PURE__*/ core.$constructor("$ZodISOTime", (inst, def) => {
|
| 302 |
+
def.pattern ?? (def.pattern = regexes.time(def));
|
| 303 |
+
$ZodStringFormat.init(inst, def);
|
| 304 |
+
});
|
| 305 |
+
export const $ZodISODuration = /*@__PURE__*/ core.$constructor("$ZodISODuration", (inst, def) => {
|
| 306 |
+
def.pattern ?? (def.pattern = regexes.duration);
|
| 307 |
+
$ZodStringFormat.init(inst, def);
|
| 308 |
+
});
|
| 309 |
+
export const $ZodIPv4 = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def) => {
|
| 310 |
+
def.pattern ?? (def.pattern = regexes.ipv4);
|
| 311 |
+
$ZodStringFormat.init(inst, def);
|
| 312 |
+
inst._zod.bag.format = `ipv4`;
|
| 313 |
+
});
|
| 314 |
+
export const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def) => {
|
| 315 |
+
def.pattern ?? (def.pattern = regexes.ipv6);
|
| 316 |
+
$ZodStringFormat.init(inst, def);
|
| 317 |
+
inst._zod.bag.format = `ipv6`;
|
| 318 |
+
inst._zod.check = (payload) => {
|
| 319 |
+
try {
|
| 320 |
+
// @ts-ignore
|
| 321 |
+
new URL(`http://[${payload.value}]`);
|
| 322 |
+
// return;
|
| 323 |
+
}
|
| 324 |
+
catch {
|
| 325 |
+
payload.issues.push({
|
| 326 |
+
code: "invalid_format",
|
| 327 |
+
format: "ipv6",
|
| 328 |
+
input: payload.value,
|
| 329 |
+
inst,
|
| 330 |
+
continue: !def.abort,
|
| 331 |
+
});
|
| 332 |
+
}
|
| 333 |
+
};
|
| 334 |
+
});
|
| 335 |
+
export const $ZodMAC = /*@__PURE__*/ core.$constructor("$ZodMAC", (inst, def) => {
|
| 336 |
+
def.pattern ?? (def.pattern = regexes.mac(def.delimiter));
|
| 337 |
+
$ZodStringFormat.init(inst, def);
|
| 338 |
+
inst._zod.bag.format = `mac`;
|
| 339 |
+
});
|
| 340 |
+
export const $ZodCIDRv4 = /*@__PURE__*/ core.$constructor("$ZodCIDRv4", (inst, def) => {
|
| 341 |
+
def.pattern ?? (def.pattern = regexes.cidrv4);
|
| 342 |
+
$ZodStringFormat.init(inst, def);
|
| 343 |
+
});
|
| 344 |
+
export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, def) => {
|
| 345 |
+
def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
|
| 346 |
+
$ZodStringFormat.init(inst, def);
|
| 347 |
+
inst._zod.check = (payload) => {
|
| 348 |
+
const parts = payload.value.split("/");
|
| 349 |
+
try {
|
| 350 |
+
if (parts.length !== 2)
|
| 351 |
+
throw new Error();
|
| 352 |
+
const [address, prefix] = parts;
|
| 353 |
+
if (!prefix)
|
| 354 |
+
throw new Error();
|
| 355 |
+
const prefixNum = Number(prefix);
|
| 356 |
+
if (`${prefixNum}` !== prefix)
|
| 357 |
+
throw new Error();
|
| 358 |
+
if (prefixNum < 0 || prefixNum > 128)
|
| 359 |
+
throw new Error();
|
| 360 |
+
// @ts-ignore
|
| 361 |
+
new URL(`http://[${address}]`);
|
| 362 |
+
}
|
| 363 |
+
catch {
|
| 364 |
+
payload.issues.push({
|
| 365 |
+
code: "invalid_format",
|
| 366 |
+
format: "cidrv6",
|
| 367 |
+
input: payload.value,
|
| 368 |
+
inst,
|
| 369 |
+
continue: !def.abort,
|
| 370 |
+
});
|
| 371 |
+
}
|
| 372 |
+
};
|
| 373 |
+
});
|
| 374 |
+
////////////////////////////// ZodBase64 //////////////////////////////
|
| 375 |
+
export function isValidBase64(data) {
|
| 376 |
+
if (data === "")
|
| 377 |
+
return true;
|
| 378 |
+
// atob ignores whitespace, so reject it up front.
|
| 379 |
+
if (/\s/.test(data))
|
| 380 |
+
return false;
|
| 381 |
+
if (data.length % 4 !== 0)
|
| 382 |
+
return false;
|
| 383 |
+
try {
|
| 384 |
+
// @ts-ignore
|
| 385 |
+
atob(data);
|
| 386 |
+
return true;
|
| 387 |
+
}
|
| 388 |
+
catch {
|
| 389 |
+
return false;
|
| 390 |
+
}
|
| 391 |
+
}
|
| 392 |
+
export const $ZodBase64 = /*@__PURE__*/ core.$constructor("$ZodBase64", (inst, def) => {
|
| 393 |
+
def.pattern ?? (def.pattern = regexes.base64);
|
| 394 |
+
$ZodStringFormat.init(inst, def);
|
| 395 |
+
inst._zod.bag.contentEncoding = "base64";
|
| 396 |
+
inst._zod.check = (payload) => {
|
| 397 |
+
if (isValidBase64(payload.value))
|
| 398 |
+
return;
|
| 399 |
+
payload.issues.push({
|
| 400 |
+
code: "invalid_format",
|
| 401 |
+
format: "base64",
|
| 402 |
+
input: payload.value,
|
| 403 |
+
inst,
|
| 404 |
+
continue: !def.abort,
|
| 405 |
+
});
|
| 406 |
+
};
|
| 407 |
+
});
|
| 408 |
+
////////////////////////////// ZodBase64 //////////////////////////////
|
| 409 |
+
export function isValidBase64URL(data) {
|
| 410 |
+
if (!regexes.base64url.test(data))
|
| 411 |
+
return false;
|
| 412 |
+
const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
|
| 413 |
+
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
| 414 |
+
return isValidBase64(padded);
|
| 415 |
+
}
|
| 416 |
+
export const $ZodBase64URL = /*@__PURE__*/ core.$constructor("$ZodBase64URL", (inst, def) => {
|
| 417 |
+
def.pattern ?? (def.pattern = regexes.base64url);
|
| 418 |
+
$ZodStringFormat.init(inst, def);
|
| 419 |
+
inst._zod.bag.contentEncoding = "base64url";
|
| 420 |
+
inst._zod.check = (payload) => {
|
| 421 |
+
if (isValidBase64URL(payload.value))
|
| 422 |
+
return;
|
| 423 |
+
payload.issues.push({
|
| 424 |
+
code: "invalid_format",
|
| 425 |
+
format: "base64url",
|
| 426 |
+
input: payload.value,
|
| 427 |
+
inst,
|
| 428 |
+
continue: !def.abort,
|
| 429 |
+
});
|
| 430 |
+
};
|
| 431 |
+
});
|
| 432 |
+
export const $ZodE164 = /*@__PURE__*/ core.$constructor("$ZodE164", (inst, def) => {
|
| 433 |
+
def.pattern ?? (def.pattern = regexes.e164);
|
| 434 |
+
$ZodStringFormat.init(inst, def);
|
| 435 |
+
});
|
| 436 |
+
////////////////////////////// ZodJWT //////////////////////////////
|
| 437 |
+
export function isValidJWT(token, algorithm = null) {
|
| 438 |
+
try {
|
| 439 |
+
const tokensParts = token.split(".");
|
| 440 |
+
if (tokensParts.length !== 3)
|
| 441 |
+
return false;
|
| 442 |
+
const [header] = tokensParts;
|
| 443 |
+
if (!header)
|
| 444 |
+
return false;
|
| 445 |
+
// @ts-ignore
|
| 446 |
+
const parsedHeader = JSON.parse(atob(header));
|
| 447 |
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
| 448 |
+
return false;
|
| 449 |
+
if (!parsedHeader.alg)
|
| 450 |
+
return false;
|
| 451 |
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
|
| 452 |
+
return false;
|
| 453 |
+
return true;
|
| 454 |
+
}
|
| 455 |
+
catch {
|
| 456 |
+
return false;
|
| 457 |
+
}
|
| 458 |
+
}
|
| 459 |
+
export const $ZodJWT = /*@__PURE__*/ core.$constructor("$ZodJWT", (inst, def) => {
|
| 460 |
+
$ZodStringFormat.init(inst, def);
|
| 461 |
+
inst._zod.check = (payload) => {
|
| 462 |
+
if (isValidJWT(payload.value, def.alg))
|
| 463 |
+
return;
|
| 464 |
+
payload.issues.push({
|
| 465 |
+
code: "invalid_format",
|
| 466 |
+
format: "jwt",
|
| 467 |
+
input: payload.value,
|
| 468 |
+
inst,
|
| 469 |
+
continue: !def.abort,
|
| 470 |
+
});
|
| 471 |
+
};
|
| 472 |
+
});
|
| 473 |
+
export const $ZodCustomStringFormat = /*@__PURE__*/ core.$constructor("$ZodCustomStringFormat", (inst, def) => {
|
| 474 |
+
$ZodStringFormat.init(inst, def);
|
| 475 |
+
inst._zod.check = (payload) => {
|
| 476 |
+
if (def.fn(payload.value))
|
| 477 |
+
return;
|
| 478 |
+
payload.issues.push({
|
| 479 |
+
code: "invalid_format",
|
| 480 |
+
format: def.format,
|
| 481 |
+
input: payload.value,
|
| 482 |
+
inst,
|
| 483 |
+
continue: !def.abort,
|
| 484 |
+
});
|
| 485 |
+
};
|
| 486 |
+
});
|
| 487 |
+
export const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
|
| 488 |
+
$ZodType.init(inst, def);
|
| 489 |
+
inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;
|
| 490 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 491 |
+
if (def.coerce)
|
| 492 |
+
try {
|
| 493 |
+
payload.value = Number(payload.value);
|
| 494 |
+
}
|
| 495 |
+
catch (_) { }
|
| 496 |
+
const input = payload.value;
|
| 497 |
+
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
|
| 498 |
+
return payload;
|
| 499 |
+
}
|
| 500 |
+
const received = typeof input === "number"
|
| 501 |
+
? Number.isNaN(input)
|
| 502 |
+
? "NaN"
|
| 503 |
+
: !Number.isFinite(input)
|
| 504 |
+
? "Infinity"
|
| 505 |
+
: undefined
|
| 506 |
+
: undefined;
|
| 507 |
+
payload.issues.push({
|
| 508 |
+
expected: "number",
|
| 509 |
+
code: "invalid_type",
|
| 510 |
+
input,
|
| 511 |
+
inst,
|
| 512 |
+
...(received ? { received } : {}),
|
| 513 |
+
});
|
| 514 |
+
return payload;
|
| 515 |
+
};
|
| 516 |
+
});
|
| 517 |
+
export const $ZodNumberFormat = /*@__PURE__*/ core.$constructor("$ZodNumberFormat", (inst, def) => {
|
| 518 |
+
checks.$ZodCheckNumberFormat.init(inst, def);
|
| 519 |
+
$ZodNumber.init(inst, def); // no format checks
|
| 520 |
+
});
|
| 521 |
+
export const $ZodBoolean = /*@__PURE__*/ core.$constructor("$ZodBoolean", (inst, def) => {
|
| 522 |
+
$ZodType.init(inst, def);
|
| 523 |
+
inst._zod.pattern = regexes.boolean;
|
| 524 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 525 |
+
if (def.coerce)
|
| 526 |
+
try {
|
| 527 |
+
payload.value = Boolean(payload.value);
|
| 528 |
+
}
|
| 529 |
+
catch (_) { }
|
| 530 |
+
const input = payload.value;
|
| 531 |
+
if (typeof input === "boolean")
|
| 532 |
+
return payload;
|
| 533 |
+
payload.issues.push({
|
| 534 |
+
expected: "boolean",
|
| 535 |
+
code: "invalid_type",
|
| 536 |
+
input,
|
| 537 |
+
inst,
|
| 538 |
+
});
|
| 539 |
+
return payload;
|
| 540 |
+
};
|
| 541 |
+
});
|
| 542 |
+
export const $ZodBigInt = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, def) => {
|
| 543 |
+
$ZodType.init(inst, def);
|
| 544 |
+
inst._zod.pattern = regexes.bigint;
|
| 545 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 546 |
+
if (def.coerce)
|
| 547 |
+
try {
|
| 548 |
+
payload.value = BigInt(payload.value);
|
| 549 |
+
}
|
| 550 |
+
catch (_) { }
|
| 551 |
+
if (typeof payload.value === "bigint")
|
| 552 |
+
return payload;
|
| 553 |
+
payload.issues.push({
|
| 554 |
+
expected: "bigint",
|
| 555 |
+
code: "invalid_type",
|
| 556 |
+
input: payload.value,
|
| 557 |
+
inst,
|
| 558 |
+
});
|
| 559 |
+
return payload;
|
| 560 |
+
};
|
| 561 |
+
});
|
| 562 |
+
export const $ZodBigIntFormat = /*@__PURE__*/ core.$constructor("$ZodBigIntFormat", (inst, def) => {
|
| 563 |
+
checks.$ZodCheckBigIntFormat.init(inst, def);
|
| 564 |
+
$ZodBigInt.init(inst, def); // no format checks
|
| 565 |
+
});
|
| 566 |
+
export const $ZodSymbol = /*@__PURE__*/ core.$constructor("$ZodSymbol", (inst, def) => {
|
| 567 |
+
$ZodType.init(inst, def);
|
| 568 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 569 |
+
const input = payload.value;
|
| 570 |
+
if (typeof input === "symbol")
|
| 571 |
+
return payload;
|
| 572 |
+
payload.issues.push({
|
| 573 |
+
expected: "symbol",
|
| 574 |
+
code: "invalid_type",
|
| 575 |
+
input,
|
| 576 |
+
inst,
|
| 577 |
+
});
|
| 578 |
+
return payload;
|
| 579 |
+
};
|
| 580 |
+
});
|
| 581 |
+
export const $ZodUndefined = /*@__PURE__*/ core.$constructor("$ZodUndefined", (inst, def) => {
|
| 582 |
+
$ZodType.init(inst, def);
|
| 583 |
+
inst._zod.pattern = regexes.undefined;
|
| 584 |
+
inst._zod.values = new Set([undefined]);
|
| 585 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 586 |
+
const input = payload.value;
|
| 587 |
+
if (typeof input === "undefined")
|
| 588 |
+
return payload;
|
| 589 |
+
payload.issues.push({
|
| 590 |
+
expected: "undefined",
|
| 591 |
+
code: "invalid_type",
|
| 592 |
+
input,
|
| 593 |
+
inst,
|
| 594 |
+
});
|
| 595 |
+
return payload;
|
| 596 |
+
};
|
| 597 |
+
});
|
| 598 |
+
export const $ZodNull = /*@__PURE__*/ core.$constructor("$ZodNull", (inst, def) => {
|
| 599 |
+
$ZodType.init(inst, def);
|
| 600 |
+
inst._zod.pattern = regexes.null;
|
| 601 |
+
inst._zod.values = new Set([null]);
|
| 602 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 603 |
+
const input = payload.value;
|
| 604 |
+
if (input === null)
|
| 605 |
+
return payload;
|
| 606 |
+
payload.issues.push({
|
| 607 |
+
expected: "null",
|
| 608 |
+
code: "invalid_type",
|
| 609 |
+
input,
|
| 610 |
+
inst,
|
| 611 |
+
});
|
| 612 |
+
return payload;
|
| 613 |
+
};
|
| 614 |
+
});
|
| 615 |
+
export const $ZodAny = /*@__PURE__*/ core.$constructor("$ZodAny", (inst, def) => {
|
| 616 |
+
$ZodType.init(inst, def);
|
| 617 |
+
inst._zod.parse = (payload) => payload;
|
| 618 |
+
});
|
| 619 |
+
export const $ZodUnknown = /*@__PURE__*/ core.$constructor("$ZodUnknown", (inst, def) => {
|
| 620 |
+
$ZodType.init(inst, def);
|
| 621 |
+
inst._zod.parse = (payload) => payload;
|
| 622 |
+
});
|
| 623 |
+
export const $ZodNever = /*@__PURE__*/ core.$constructor("$ZodNever", (inst, def) => {
|
| 624 |
+
$ZodType.init(inst, def);
|
| 625 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 626 |
+
payload.issues.push({
|
| 627 |
+
expected: "never",
|
| 628 |
+
code: "invalid_type",
|
| 629 |
+
input: payload.value,
|
| 630 |
+
inst,
|
| 631 |
+
});
|
| 632 |
+
return payload;
|
| 633 |
+
};
|
| 634 |
+
});
|
| 635 |
+
export const $ZodVoid = /*@__PURE__*/ core.$constructor("$ZodVoid", (inst, def) => {
|
| 636 |
+
$ZodType.init(inst, def);
|
| 637 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 638 |
+
const input = payload.value;
|
| 639 |
+
if (typeof input === "undefined")
|
| 640 |
+
return payload;
|
| 641 |
+
payload.issues.push({
|
| 642 |
+
expected: "void",
|
| 643 |
+
code: "invalid_type",
|
| 644 |
+
input,
|
| 645 |
+
inst,
|
| 646 |
+
});
|
| 647 |
+
return payload;
|
| 648 |
+
};
|
| 649 |
+
});
|
| 650 |
+
export const $ZodDate = /*@__PURE__*/ core.$constructor("$ZodDate", (inst, def) => {
|
| 651 |
+
$ZodType.init(inst, def);
|
| 652 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 653 |
+
if (def.coerce) {
|
| 654 |
+
try {
|
| 655 |
+
payload.value = new Date(payload.value);
|
| 656 |
+
}
|
| 657 |
+
catch (_err) { }
|
| 658 |
+
}
|
| 659 |
+
const input = payload.value;
|
| 660 |
+
const isDate = input instanceof Date;
|
| 661 |
+
const isValidDate = isDate && !Number.isNaN(input.getTime());
|
| 662 |
+
if (isValidDate)
|
| 663 |
+
return payload;
|
| 664 |
+
payload.issues.push({
|
| 665 |
+
expected: "date",
|
| 666 |
+
code: "invalid_type",
|
| 667 |
+
input,
|
| 668 |
+
...(isDate ? { received: "Invalid Date" } : {}),
|
| 669 |
+
inst,
|
| 670 |
+
});
|
| 671 |
+
return payload;
|
| 672 |
+
};
|
| 673 |
+
});
|
| 674 |
+
function handleArrayResult(result, final, index) {
|
| 675 |
+
if (result.issues.length) {
|
| 676 |
+
final.issues.push(...util.prefixIssues(index, result.issues));
|
| 677 |
+
}
|
| 678 |
+
final.value[index] = result.value;
|
| 679 |
+
}
|
| 680 |
+
export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
|
| 681 |
+
$ZodType.init(inst, def);
|
| 682 |
+
inst._zod.parse = (payload, ctx) => {
|
| 683 |
+
const input = payload.value;
|
| 684 |
+
if (!Array.isArray(input)) {
|
| 685 |
+
payload.issues.push({
|
| 686 |
+
expected: "array",
|
| 687 |
+
code: "invalid_type",
|
| 688 |
+
input,
|
| 689 |
+
inst,
|
| 690 |
+
});
|
| 691 |
+
return payload;
|
| 692 |
+
}
|
| 693 |
+
payload.value = Array(input.length);
|
| 694 |
+
const proms = [];
|
| 695 |
+
for (let i = 0; i < input.length; i++) {
|
| 696 |
+
const item = input[i];
|
| 697 |
+
const result = def.element._zod.run({
|
| 698 |
+
value: item,
|
| 699 |
+
issues: [],
|
| 700 |
+
}, ctx);
|
| 701 |
+
if (result instanceof Promise) {
|
| 702 |
+
proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
| 703 |
+
}
|
| 704 |
+
else {
|
| 705 |
+
handleArrayResult(result, payload, i);
|
| 706 |
+
}
|
| 707 |
+
}
|
| 708 |
+
if (proms.length) {
|
| 709 |
+
return Promise.all(proms).then(() => payload);
|
| 710 |
+
}
|
| 711 |
+
return payload; //handleArrayResultsAsync(parseResults, final);
|
| 712 |
+
};
|
| 713 |
+
});
|
| 714 |
+
function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
|
| 715 |
+
const isPresent = key in input;
|
| 716 |
+
if (result.issues.length) {
|
| 717 |
+
// For optional-in/out schemas, ignore errors on absent keys.
|
| 718 |
+
if (isOptionalIn && isOptionalOut && !isPresent) {
|
| 719 |
+
return;
|
| 720 |
+
}
|
| 721 |
+
final.issues.push(...util.prefixIssues(key, result.issues));
|
| 722 |
+
}
|
| 723 |
+
if (!isPresent && !isOptionalIn) {
|
| 724 |
+
if (!result.issues.length) {
|
| 725 |
+
final.issues.push({
|
| 726 |
+
code: "invalid_type",
|
| 727 |
+
expected: "nonoptional",
|
| 728 |
+
input: undefined,
|
| 729 |
+
path: [key],
|
| 730 |
+
});
|
| 731 |
+
}
|
| 732 |
+
return;
|
| 733 |
+
}
|
| 734 |
+
if (result.value === undefined) {
|
| 735 |
+
if (isPresent) {
|
| 736 |
+
final.value[key] = undefined;
|
| 737 |
+
}
|
| 738 |
+
}
|
| 739 |
+
else {
|
| 740 |
+
final.value[key] = result.value;
|
| 741 |
+
}
|
| 742 |
+
}
|
| 743 |
+
function normalizeDef(def) {
|
| 744 |
+
const keys = Object.keys(def.shape);
|
| 745 |
+
for (const k of keys) {
|
| 746 |
+
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
| 747 |
+
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
| 748 |
+
}
|
| 749 |
+
}
|
| 750 |
+
const okeys = util.optionalKeys(def.shape);
|
| 751 |
+
return {
|
| 752 |
+
...def,
|
| 753 |
+
keys,
|
| 754 |
+
keySet: new Set(keys),
|
| 755 |
+
numKeys: keys.length,
|
| 756 |
+
optionalKeys: new Set(okeys),
|
| 757 |
+
};
|
| 758 |
+
}
|
| 759 |
+
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
| 760 |
+
const unrecognized = [];
|
| 761 |
+
const keySet = def.keySet;
|
| 762 |
+
const _catchall = def.catchall._zod;
|
| 763 |
+
const t = _catchall.def.type;
|
| 764 |
+
const isOptionalIn = _catchall.optin === "optional";
|
| 765 |
+
const isOptionalOut = _catchall.optout === "optional";
|
| 766 |
+
for (const key in input) {
|
| 767 |
+
// skip __proto__ so it can't replace the result prototype via the
|
| 768 |
+
// assignment setter on the plain {} we build into
|
| 769 |
+
if (key === "__proto__")
|
| 770 |
+
continue;
|
| 771 |
+
if (keySet.has(key))
|
| 772 |
+
continue;
|
| 773 |
+
if (t === "never") {
|
| 774 |
+
unrecognized.push(key);
|
| 775 |
+
continue;
|
| 776 |
+
}
|
| 777 |
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
| 778 |
+
if (r instanceof Promise) {
|
| 779 |
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
| 780 |
+
}
|
| 781 |
+
else {
|
| 782 |
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
| 783 |
+
}
|
| 784 |
+
}
|
| 785 |
+
if (unrecognized.length) {
|
| 786 |
+
payload.issues.push({
|
| 787 |
+
code: "unrecognized_keys",
|
| 788 |
+
keys: unrecognized,
|
| 789 |
+
input,
|
| 790 |
+
inst,
|
| 791 |
+
});
|
| 792 |
+
}
|
| 793 |
+
if (!proms.length)
|
| 794 |
+
return payload;
|
| 795 |
+
return Promise.all(proms).then(() => {
|
| 796 |
+
return payload;
|
| 797 |
+
});
|
| 798 |
+
}
|
| 799 |
+
export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
|
| 800 |
+
// requires cast because technically $ZodObject doesn't extend
|
| 801 |
+
$ZodType.init(inst, def);
|
| 802 |
+
// const sh = def.shape;
|
| 803 |
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
| 804 |
+
if (!desc?.get) {
|
| 805 |
+
const sh = def.shape;
|
| 806 |
+
Object.defineProperty(def, "shape", {
|
| 807 |
+
get: () => {
|
| 808 |
+
const newSh = { ...sh };
|
| 809 |
+
Object.defineProperty(def, "shape", {
|
| 810 |
+
value: newSh,
|
| 811 |
+
});
|
| 812 |
+
return newSh;
|
| 813 |
+
},
|
| 814 |
+
});
|
| 815 |
+
}
|
| 816 |
+
const _normalized = util.cached(() => normalizeDef(def));
|
| 817 |
+
util.defineLazy(inst._zod, "propValues", () => {
|
| 818 |
+
const shape = def.shape;
|
| 819 |
+
const propValues = {};
|
| 820 |
+
for (const key in shape) {
|
| 821 |
+
const field = shape[key]._zod;
|
| 822 |
+
if (field.values) {
|
| 823 |
+
propValues[key] ?? (propValues[key] = new Set());
|
| 824 |
+
for (const v of field.values)
|
| 825 |
+
propValues[key].add(v);
|
| 826 |
+
}
|
| 827 |
+
}
|
| 828 |
+
return propValues;
|
| 829 |
+
});
|
| 830 |
+
const isObject = util.isObject;
|
| 831 |
+
const catchall = def.catchall;
|
| 832 |
+
let value;
|
| 833 |
+
inst._zod.parse = (payload, ctx) => {
|
| 834 |
+
value ?? (value = _normalized.value);
|
| 835 |
+
const input = payload.value;
|
| 836 |
+
if (!isObject(input)) {
|
| 837 |
+
payload.issues.push({
|
| 838 |
+
expected: "object",
|
| 839 |
+
code: "invalid_type",
|
| 840 |
+
input,
|
| 841 |
+
inst,
|
| 842 |
+
});
|
| 843 |
+
return payload;
|
| 844 |
+
}
|
| 845 |
+
payload.value = {};
|
| 846 |
+
const proms = [];
|
| 847 |
+
const shape = value.shape;
|
| 848 |
+
for (const key of value.keys) {
|
| 849 |
+
const el = shape[key];
|
| 850 |
+
const isOptionalIn = el._zod.optin === "optional";
|
| 851 |
+
const isOptionalOut = el._zod.optout === "optional";
|
| 852 |
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
| 853 |
+
if (r instanceof Promise) {
|
| 854 |
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
| 855 |
+
}
|
| 856 |
+
else {
|
| 857 |
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
| 858 |
+
}
|
| 859 |
+
}
|
| 860 |
+
if (!catchall) {
|
| 861 |
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
| 862 |
+
}
|
| 863 |
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
| 864 |
+
};
|
| 865 |
+
});
|
| 866 |
+
export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (inst, def) => {
|
| 867 |
+
// requires cast because technically $ZodObject doesn't extend
|
| 868 |
+
$ZodObject.init(inst, def);
|
| 869 |
+
const superParse = inst._zod.parse;
|
| 870 |
+
const _normalized = util.cached(() => normalizeDef(def));
|
| 871 |
+
const generateFastpass = (shape) => {
|
| 872 |
+
const doc = new Doc(["shape", "payload", "ctx"]);
|
| 873 |
+
const normalized = _normalized.value;
|
| 874 |
+
const parseStr = (key) => {
|
| 875 |
+
const k = util.esc(key);
|
| 876 |
+
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
| 877 |
+
};
|
| 878 |
+
doc.write(`const input = payload.value;`);
|
| 879 |
+
const ids = Object.create(null);
|
| 880 |
+
let counter = 0;
|
| 881 |
+
for (const key of normalized.keys) {
|
| 882 |
+
ids[key] = `key_${counter++}`;
|
| 883 |
+
}
|
| 884 |
+
// A: preserve key order {
|
| 885 |
+
doc.write(`const newResult = {};`);
|
| 886 |
+
for (const key of normalized.keys) {
|
| 887 |
+
const id = ids[key];
|
| 888 |
+
const k = util.esc(key);
|
| 889 |
+
const schema = shape[key];
|
| 890 |
+
const isOptionalIn = schema?._zod?.optin === "optional";
|
| 891 |
+
const isOptionalOut = schema?._zod?.optout === "optional";
|
| 892 |
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
| 893 |
+
if (isOptionalIn && isOptionalOut) {
|
| 894 |
+
// For optional-in/out schemas, ignore errors on absent keys
|
| 895 |
+
doc.write(`
|
| 896 |
+
if (${id}.issues.length) {
|
| 897 |
+
if (${k} in input) {
|
| 898 |
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
| 899 |
+
...iss,
|
| 900 |
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
| 901 |
+
})));
|
| 902 |
+
}
|
| 903 |
+
}
|
| 904 |
+
|
| 905 |
+
if (${id}.value === undefined) {
|
| 906 |
+
if (${k} in input) {
|
| 907 |
+
newResult[${k}] = undefined;
|
| 908 |
+
}
|
| 909 |
+
} else {
|
| 910 |
+
newResult[${k}] = ${id}.value;
|
| 911 |
+
}
|
| 912 |
+
|
| 913 |
+
`);
|
| 914 |
+
}
|
| 915 |
+
else if (!isOptionalIn) {
|
| 916 |
+
doc.write(`
|
| 917 |
+
const ${id}_present = ${k} in input;
|
| 918 |
+
if (${id}.issues.length) {
|
| 919 |
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
| 920 |
+
...iss,
|
| 921 |
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
| 922 |
+
})));
|
| 923 |
+
}
|
| 924 |
+
if (!${id}_present && !${id}.issues.length) {
|
| 925 |
+
payload.issues.push({
|
| 926 |
+
code: "invalid_type",
|
| 927 |
+
expected: "nonoptional",
|
| 928 |
+
input: undefined,
|
| 929 |
+
path: [${k}]
|
| 930 |
+
});
|
| 931 |
+
}
|
| 932 |
+
|
| 933 |
+
if (${id}_present) {
|
| 934 |
+
if (${id}.value === undefined) {
|
| 935 |
+
newResult[${k}] = undefined;
|
| 936 |
+
} else {
|
| 937 |
+
newResult[${k}] = ${id}.value;
|
| 938 |
+
}
|
| 939 |
+
}
|
| 940 |
+
|
| 941 |
+
`);
|
| 942 |
+
}
|
| 943 |
+
else {
|
| 944 |
+
doc.write(`
|
| 945 |
+
if (${id}.issues.length) {
|
| 946 |
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
| 947 |
+
...iss,
|
| 948 |
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
| 949 |
+
})));
|
| 950 |
+
}
|
| 951 |
+
|
| 952 |
+
if (${id}.value === undefined) {
|
| 953 |
+
if (${k} in input) {
|
| 954 |
+
newResult[${k}] = undefined;
|
| 955 |
+
}
|
| 956 |
+
} else {
|
| 957 |
+
newResult[${k}] = ${id}.value;
|
| 958 |
+
}
|
| 959 |
+
|
| 960 |
+
`);
|
| 961 |
+
}
|
| 962 |
+
}
|
| 963 |
+
doc.write(`payload.value = newResult;`);
|
| 964 |
+
doc.write(`return payload;`);
|
| 965 |
+
const fn = doc.compile();
|
| 966 |
+
return (payload, ctx) => fn(shape, payload, ctx);
|
| 967 |
+
};
|
| 968 |
+
let fastpass;
|
| 969 |
+
const isObject = util.isObject;
|
| 970 |
+
const jit = !core.globalConfig.jitless;
|
| 971 |
+
const allowsEval = util.allowsEval;
|
| 972 |
+
const fastEnabled = jit && allowsEval.value; // && !def.catchall;
|
| 973 |
+
const catchall = def.catchall;
|
| 974 |
+
let value;
|
| 975 |
+
inst._zod.parse = (payload, ctx) => {
|
| 976 |
+
value ?? (value = _normalized.value);
|
| 977 |
+
const input = payload.value;
|
| 978 |
+
if (!isObject(input)) {
|
| 979 |
+
payload.issues.push({
|
| 980 |
+
expected: "object",
|
| 981 |
+
code: "invalid_type",
|
| 982 |
+
input,
|
| 983 |
+
inst,
|
| 984 |
+
});
|
| 985 |
+
return payload;
|
| 986 |
+
}
|
| 987 |
+
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
| 988 |
+
// always synchronous
|
| 989 |
+
if (!fastpass)
|
| 990 |
+
fastpass = generateFastpass(def.shape);
|
| 991 |
+
payload = fastpass(payload, ctx);
|
| 992 |
+
if (!catchall)
|
| 993 |
+
return payload;
|
| 994 |
+
return handleCatchall([], input, payload, ctx, value, inst);
|
| 995 |
+
}
|
| 996 |
+
return superParse(payload, ctx);
|
| 997 |
+
};
|
| 998 |
+
});
|
| 999 |
+
function handleUnionResults(results, final, inst, ctx) {
|
| 1000 |
+
for (const result of results) {
|
| 1001 |
+
if (result.issues.length === 0) {
|
| 1002 |
+
final.value = result.value;
|
| 1003 |
+
return final;
|
| 1004 |
+
}
|
| 1005 |
+
}
|
| 1006 |
+
const nonaborted = results.filter((r) => !util.aborted(r));
|
| 1007 |
+
if (nonaborted.length === 1) {
|
| 1008 |
+
final.value = nonaborted[0].value;
|
| 1009 |
+
return nonaborted[0];
|
| 1010 |
+
}
|
| 1011 |
+
final.issues.push({
|
| 1012 |
+
code: "invalid_union",
|
| 1013 |
+
input: final.value,
|
| 1014 |
+
inst,
|
| 1015 |
+
errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
|
| 1016 |
+
});
|
| 1017 |
+
return final;
|
| 1018 |
+
}
|
| 1019 |
+
export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
|
| 1020 |
+
$ZodType.init(inst, def);
|
| 1021 |
+
util.defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
|
| 1022 |
+
util.defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
| 1023 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1024 |
+
if (def.options.every((o) => o._zod.values)) {
|
| 1025 |
+
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
| 1026 |
+
}
|
| 1027 |
+
return undefined;
|
| 1028 |
+
});
|
| 1029 |
+
util.defineLazy(inst._zod, "pattern", () => {
|
| 1030 |
+
if (def.options.every((o) => o._zod.pattern)) {
|
| 1031 |
+
const patterns = def.options.map((o) => o._zod.pattern);
|
| 1032 |
+
return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
|
| 1033 |
+
}
|
| 1034 |
+
return undefined;
|
| 1035 |
+
});
|
| 1036 |
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
| 1037 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1038 |
+
if (first) {
|
| 1039 |
+
return first(payload, ctx);
|
| 1040 |
+
}
|
| 1041 |
+
let async = false;
|
| 1042 |
+
const results = [];
|
| 1043 |
+
for (const option of def.options) {
|
| 1044 |
+
const result = option._zod.run({
|
| 1045 |
+
value: payload.value,
|
| 1046 |
+
issues: [],
|
| 1047 |
+
}, ctx);
|
| 1048 |
+
if (result instanceof Promise) {
|
| 1049 |
+
results.push(result);
|
| 1050 |
+
async = true;
|
| 1051 |
+
}
|
| 1052 |
+
else {
|
| 1053 |
+
if (result.issues.length === 0)
|
| 1054 |
+
return result;
|
| 1055 |
+
results.push(result);
|
| 1056 |
+
}
|
| 1057 |
+
}
|
| 1058 |
+
if (!async)
|
| 1059 |
+
return handleUnionResults(results, payload, inst, ctx);
|
| 1060 |
+
return Promise.all(results).then((results) => {
|
| 1061 |
+
return handleUnionResults(results, payload, inst, ctx);
|
| 1062 |
+
});
|
| 1063 |
+
};
|
| 1064 |
+
});
|
| 1065 |
+
function handleExclusiveUnionResults(results, final, inst, ctx) {
|
| 1066 |
+
const successes = results.filter((r) => r.issues.length === 0);
|
| 1067 |
+
if (successes.length === 1) {
|
| 1068 |
+
final.value = successes[0].value;
|
| 1069 |
+
return final;
|
| 1070 |
+
}
|
| 1071 |
+
if (successes.length === 0) {
|
| 1072 |
+
// No matches - same as regular union
|
| 1073 |
+
final.issues.push({
|
| 1074 |
+
code: "invalid_union",
|
| 1075 |
+
input: final.value,
|
| 1076 |
+
inst,
|
| 1077 |
+
errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
|
| 1078 |
+
});
|
| 1079 |
+
}
|
| 1080 |
+
else {
|
| 1081 |
+
// Multiple matches - exclusive union failure
|
| 1082 |
+
final.issues.push({
|
| 1083 |
+
code: "invalid_union",
|
| 1084 |
+
input: final.value,
|
| 1085 |
+
inst,
|
| 1086 |
+
errors: [],
|
| 1087 |
+
inclusive: false,
|
| 1088 |
+
});
|
| 1089 |
+
}
|
| 1090 |
+
return final;
|
| 1091 |
+
}
|
| 1092 |
+
export const $ZodXor = /*@__PURE__*/ core.$constructor("$ZodXor", (inst, def) => {
|
| 1093 |
+
$ZodUnion.init(inst, def);
|
| 1094 |
+
def.inclusive = false;
|
| 1095 |
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
| 1096 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1097 |
+
if (first) {
|
| 1098 |
+
return first(payload, ctx);
|
| 1099 |
+
}
|
| 1100 |
+
let async = false;
|
| 1101 |
+
const results = [];
|
| 1102 |
+
for (const option of def.options) {
|
| 1103 |
+
const result = option._zod.run({
|
| 1104 |
+
value: payload.value,
|
| 1105 |
+
issues: [],
|
| 1106 |
+
}, ctx);
|
| 1107 |
+
if (result instanceof Promise) {
|
| 1108 |
+
results.push(result);
|
| 1109 |
+
async = true;
|
| 1110 |
+
}
|
| 1111 |
+
else {
|
| 1112 |
+
results.push(result);
|
| 1113 |
+
}
|
| 1114 |
+
}
|
| 1115 |
+
if (!async)
|
| 1116 |
+
return handleExclusiveUnionResults(results, payload, inst, ctx);
|
| 1117 |
+
return Promise.all(results).then((results) => {
|
| 1118 |
+
return handleExclusiveUnionResults(results, payload, inst, ctx);
|
| 1119 |
+
});
|
| 1120 |
+
};
|
| 1121 |
+
});
|
| 1122 |
+
export const $ZodDiscriminatedUnion =
|
| 1123 |
+
/*@__PURE__*/
|
| 1124 |
+
core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
| 1125 |
+
def.inclusive = false;
|
| 1126 |
+
$ZodUnion.init(inst, def);
|
| 1127 |
+
const _super = inst._zod.parse;
|
| 1128 |
+
util.defineLazy(inst._zod, "propValues", () => {
|
| 1129 |
+
const propValues = {};
|
| 1130 |
+
for (const option of def.options) {
|
| 1131 |
+
const pv = option._zod.propValues;
|
| 1132 |
+
if (!pv || Object.keys(pv).length === 0)
|
| 1133 |
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
| 1134 |
+
for (const [k, v] of Object.entries(pv)) {
|
| 1135 |
+
if (!propValues[k])
|
| 1136 |
+
propValues[k] = new Set();
|
| 1137 |
+
for (const val of v) {
|
| 1138 |
+
propValues[k].add(val);
|
| 1139 |
+
}
|
| 1140 |
+
}
|
| 1141 |
+
}
|
| 1142 |
+
return propValues;
|
| 1143 |
+
});
|
| 1144 |
+
const disc = util.cached(() => {
|
| 1145 |
+
const opts = def.options;
|
| 1146 |
+
const map = new Map();
|
| 1147 |
+
for (const o of opts) {
|
| 1148 |
+
const values = o._zod.propValues?.[def.discriminator];
|
| 1149 |
+
if (!values || values.size === 0)
|
| 1150 |
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
| 1151 |
+
for (const v of values) {
|
| 1152 |
+
if (map.has(v)) {
|
| 1153 |
+
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
| 1154 |
+
}
|
| 1155 |
+
map.set(v, o);
|
| 1156 |
+
}
|
| 1157 |
+
}
|
| 1158 |
+
return map;
|
| 1159 |
+
});
|
| 1160 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1161 |
+
const input = payload.value;
|
| 1162 |
+
if (!util.isObject(input)) {
|
| 1163 |
+
payload.issues.push({
|
| 1164 |
+
code: "invalid_type",
|
| 1165 |
+
expected: "object",
|
| 1166 |
+
input,
|
| 1167 |
+
inst,
|
| 1168 |
+
});
|
| 1169 |
+
return payload;
|
| 1170 |
+
}
|
| 1171 |
+
const opt = disc.value.get(input?.[def.discriminator]);
|
| 1172 |
+
if (opt) {
|
| 1173 |
+
return opt._zod.run(payload, ctx);
|
| 1174 |
+
}
|
| 1175 |
+
// Fall back to union matching when the fast discriminator path fails:
|
| 1176 |
+
// - explicitly enabled via unionFallback, or
|
| 1177 |
+
// - during backward direction (encode), since codec-based discriminators
|
| 1178 |
+
// have different values in forward vs backward directions
|
| 1179 |
+
if (def.unionFallback || ctx.direction === "backward") {
|
| 1180 |
+
return _super(payload, ctx);
|
| 1181 |
+
}
|
| 1182 |
+
// no matching discriminator
|
| 1183 |
+
payload.issues.push({
|
| 1184 |
+
code: "invalid_union",
|
| 1185 |
+
errors: [],
|
| 1186 |
+
note: "No matching discriminator",
|
| 1187 |
+
discriminator: def.discriminator,
|
| 1188 |
+
options: Array.from(disc.value.keys()),
|
| 1189 |
+
input,
|
| 1190 |
+
path: [def.discriminator],
|
| 1191 |
+
inst,
|
| 1192 |
+
});
|
| 1193 |
+
return payload;
|
| 1194 |
+
};
|
| 1195 |
+
});
|
| 1196 |
+
export const $ZodIntersection = /*@__PURE__*/ core.$constructor("$ZodIntersection", (inst, def) => {
|
| 1197 |
+
$ZodType.init(inst, def);
|
| 1198 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1199 |
+
const input = payload.value;
|
| 1200 |
+
const left = def.left._zod.run({ value: input, issues: [] }, ctx);
|
| 1201 |
+
const right = def.right._zod.run({ value: input, issues: [] }, ctx);
|
| 1202 |
+
const async = left instanceof Promise || right instanceof Promise;
|
| 1203 |
+
if (async) {
|
| 1204 |
+
return Promise.all([left, right]).then(([left, right]) => {
|
| 1205 |
+
return handleIntersectionResults(payload, left, right);
|
| 1206 |
+
});
|
| 1207 |
+
}
|
| 1208 |
+
return handleIntersectionResults(payload, left, right);
|
| 1209 |
+
};
|
| 1210 |
+
});
|
| 1211 |
+
function mergeValues(a, b) {
|
| 1212 |
+
// const aType = parse.t(a);
|
| 1213 |
+
// const bType = parse.t(b);
|
| 1214 |
+
if (a === b) {
|
| 1215 |
+
return { valid: true, data: a };
|
| 1216 |
+
}
|
| 1217 |
+
if (a instanceof Date && b instanceof Date && +a === +b) {
|
| 1218 |
+
return { valid: true, data: a };
|
| 1219 |
+
}
|
| 1220 |
+
if (util.isPlainObject(a) && util.isPlainObject(b)) {
|
| 1221 |
+
const bKeys = Object.keys(b);
|
| 1222 |
+
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
| 1223 |
+
const newObj = { ...a, ...b };
|
| 1224 |
+
for (const key of sharedKeys) {
|
| 1225 |
+
const sharedValue = mergeValues(a[key], b[key]);
|
| 1226 |
+
if (!sharedValue.valid) {
|
| 1227 |
+
return {
|
| 1228 |
+
valid: false,
|
| 1229 |
+
mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
|
| 1230 |
+
};
|
| 1231 |
+
}
|
| 1232 |
+
newObj[key] = sharedValue.data;
|
| 1233 |
+
}
|
| 1234 |
+
return { valid: true, data: newObj };
|
| 1235 |
+
}
|
| 1236 |
+
if (Array.isArray(a) && Array.isArray(b)) {
|
| 1237 |
+
if (a.length !== b.length) {
|
| 1238 |
+
return { valid: false, mergeErrorPath: [] };
|
| 1239 |
+
}
|
| 1240 |
+
const newArray = [];
|
| 1241 |
+
for (let index = 0; index < a.length; index++) {
|
| 1242 |
+
const itemA = a[index];
|
| 1243 |
+
const itemB = b[index];
|
| 1244 |
+
const sharedValue = mergeValues(itemA, itemB);
|
| 1245 |
+
if (!sharedValue.valid) {
|
| 1246 |
+
return {
|
| 1247 |
+
valid: false,
|
| 1248 |
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
|
| 1249 |
+
};
|
| 1250 |
+
}
|
| 1251 |
+
newArray.push(sharedValue.data);
|
| 1252 |
+
}
|
| 1253 |
+
return { valid: true, data: newArray };
|
| 1254 |
+
}
|
| 1255 |
+
return { valid: false, mergeErrorPath: [] };
|
| 1256 |
+
}
|
| 1257 |
+
function handleIntersectionResults(result, left, right) {
|
| 1258 |
+
// Track which side(s) report each key as unrecognized
|
| 1259 |
+
const unrecKeys = new Map();
|
| 1260 |
+
let unrecIssue;
|
| 1261 |
+
for (const iss of left.issues) {
|
| 1262 |
+
if (iss.code === "unrecognized_keys") {
|
| 1263 |
+
unrecIssue ?? (unrecIssue = iss);
|
| 1264 |
+
for (const k of iss.keys) {
|
| 1265 |
+
if (!unrecKeys.has(k))
|
| 1266 |
+
unrecKeys.set(k, {});
|
| 1267 |
+
unrecKeys.get(k).l = true;
|
| 1268 |
+
}
|
| 1269 |
+
}
|
| 1270 |
+
else {
|
| 1271 |
+
result.issues.push(iss);
|
| 1272 |
+
}
|
| 1273 |
+
}
|
| 1274 |
+
for (const iss of right.issues) {
|
| 1275 |
+
if (iss.code === "unrecognized_keys") {
|
| 1276 |
+
for (const k of iss.keys) {
|
| 1277 |
+
if (!unrecKeys.has(k))
|
| 1278 |
+
unrecKeys.set(k, {});
|
| 1279 |
+
unrecKeys.get(k).r = true;
|
| 1280 |
+
}
|
| 1281 |
+
}
|
| 1282 |
+
else {
|
| 1283 |
+
result.issues.push(iss);
|
| 1284 |
+
}
|
| 1285 |
+
}
|
| 1286 |
+
// Report only keys unrecognized by BOTH sides
|
| 1287 |
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
| 1288 |
+
if (bothKeys.length && unrecIssue) {
|
| 1289 |
+
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
| 1290 |
+
}
|
| 1291 |
+
if (util.aborted(result))
|
| 1292 |
+
return result;
|
| 1293 |
+
const merged = mergeValues(left.value, right.value);
|
| 1294 |
+
if (!merged.valid) {
|
| 1295 |
+
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
| 1296 |
+
}
|
| 1297 |
+
result.value = merged.data;
|
| 1298 |
+
return result;
|
| 1299 |
+
}
|
| 1300 |
+
export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
|
| 1301 |
+
$ZodType.init(inst, def);
|
| 1302 |
+
const items = def.items;
|
| 1303 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1304 |
+
const input = payload.value;
|
| 1305 |
+
if (!Array.isArray(input)) {
|
| 1306 |
+
payload.issues.push({
|
| 1307 |
+
input,
|
| 1308 |
+
inst,
|
| 1309 |
+
expected: "tuple",
|
| 1310 |
+
code: "invalid_type",
|
| 1311 |
+
});
|
| 1312 |
+
return payload;
|
| 1313 |
+
}
|
| 1314 |
+
payload.value = [];
|
| 1315 |
+
const proms = [];
|
| 1316 |
+
const optinStart = getTupleOptStart(items, "optin");
|
| 1317 |
+
const optoutStart = getTupleOptStart(items, "optout");
|
| 1318 |
+
if (!def.rest) {
|
| 1319 |
+
if (input.length < optinStart) {
|
| 1320 |
+
payload.issues.push({
|
| 1321 |
+
code: "too_small",
|
| 1322 |
+
minimum: optinStart,
|
| 1323 |
+
inclusive: true,
|
| 1324 |
+
input,
|
| 1325 |
+
inst,
|
| 1326 |
+
origin: "array",
|
| 1327 |
+
});
|
| 1328 |
+
return payload;
|
| 1329 |
+
}
|
| 1330 |
+
if (input.length > items.length) {
|
| 1331 |
+
payload.issues.push({
|
| 1332 |
+
code: "too_big",
|
| 1333 |
+
maximum: items.length,
|
| 1334 |
+
inclusive: true,
|
| 1335 |
+
input,
|
| 1336 |
+
inst,
|
| 1337 |
+
origin: "array",
|
| 1338 |
+
});
|
| 1339 |
+
}
|
| 1340 |
+
}
|
| 1341 |
+
// Run every item in parallel, collecting results into an indexed
|
| 1342 |
+
// array. The post-processing in `handleTupleResults` walks them in
|
| 1343 |
+
// order so it can decide whether an absent optional-output error can
|
| 1344 |
+
// truncate the tail or must be reported to preserve required output.
|
| 1345 |
+
const itemResults = new Array(items.length);
|
| 1346 |
+
for (let i = 0; i < items.length; i++) {
|
| 1347 |
+
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
| 1348 |
+
if (r instanceof Promise) {
|
| 1349 |
+
proms.push(r.then((rr) => {
|
| 1350 |
+
itemResults[i] = rr;
|
| 1351 |
+
}));
|
| 1352 |
+
}
|
| 1353 |
+
else {
|
| 1354 |
+
itemResults[i] = r;
|
| 1355 |
+
}
|
| 1356 |
+
}
|
| 1357 |
+
if (def.rest) {
|
| 1358 |
+
let i = items.length - 1;
|
| 1359 |
+
const rest = input.slice(items.length);
|
| 1360 |
+
for (const el of rest) {
|
| 1361 |
+
i++;
|
| 1362 |
+
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
| 1363 |
+
if (result instanceof Promise) {
|
| 1364 |
+
proms.push(result.then((r) => handleTupleResult(r, payload, i)));
|
| 1365 |
+
}
|
| 1366 |
+
else {
|
| 1367 |
+
handleTupleResult(result, payload, i);
|
| 1368 |
+
}
|
| 1369 |
+
}
|
| 1370 |
+
}
|
| 1371 |
+
if (proms.length) {
|
| 1372 |
+
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
|
| 1373 |
+
}
|
| 1374 |
+
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
| 1375 |
+
};
|
| 1376 |
+
});
|
| 1377 |
+
function getTupleOptStart(items, key) {
|
| 1378 |
+
for (let i = items.length - 1; i >= 0; i--) {
|
| 1379 |
+
if (items[i]._zod[key] !== "optional")
|
| 1380 |
+
return i + 1;
|
| 1381 |
+
}
|
| 1382 |
+
return 0;
|
| 1383 |
+
}
|
| 1384 |
+
function handleTupleResult(result, final, index) {
|
| 1385 |
+
if (result.issues.length) {
|
| 1386 |
+
final.issues.push(...util.prefixIssues(index, result.issues));
|
| 1387 |
+
}
|
| 1388 |
+
final.value[index] = result.value;
|
| 1389 |
+
}
|
| 1390 |
+
function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
| 1391 |
+
// Walk results in order. Mirror $ZodObject's swallow-on-absent-optional
|
| 1392 |
+
// rule, but only after `optoutStart`: the first index where the output
|
| 1393 |
+
// tuple tail can be absent.
|
| 1394 |
+
for (let i = 0; i < items.length; i++) {
|
| 1395 |
+
const r = itemResults[i];
|
| 1396 |
+
const isPresent = i < input.length;
|
| 1397 |
+
if (r.issues.length) {
|
| 1398 |
+
if (!isPresent && i >= optoutStart) {
|
| 1399 |
+
final.value.length = i;
|
| 1400 |
+
break;
|
| 1401 |
+
}
|
| 1402 |
+
final.issues.push(...util.prefixIssues(i, r.issues));
|
| 1403 |
+
}
|
| 1404 |
+
final.value[i] = r.value;
|
| 1405 |
+
}
|
| 1406 |
+
// Drop trailing slots that produced `undefined` for absent input
|
| 1407 |
+
// (the array analog of an absent optional key on an object). The
|
| 1408 |
+
// `i >= input.length` floor is critical: an explicit `undefined`
|
| 1409 |
+
// *inside* the input must be preserved even when the schema is
|
| 1410 |
+
// optional-out (e.g. `z.string().or(z.undefined())` accepting an
|
| 1411 |
+
// explicit undefined value).
|
| 1412 |
+
for (let i = final.value.length - 1; i >= input.length; i--) {
|
| 1413 |
+
if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
|
| 1414 |
+
final.value.length = i;
|
| 1415 |
+
}
|
| 1416 |
+
else {
|
| 1417 |
+
break;
|
| 1418 |
+
}
|
| 1419 |
+
}
|
| 1420 |
+
return final;
|
| 1421 |
+
}
|
| 1422 |
+
export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
|
| 1423 |
+
$ZodType.init(inst, def);
|
| 1424 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1425 |
+
const input = payload.value;
|
| 1426 |
+
if (!util.isPlainObject(input)) {
|
| 1427 |
+
payload.issues.push({
|
| 1428 |
+
expected: "record",
|
| 1429 |
+
code: "invalid_type",
|
| 1430 |
+
input,
|
| 1431 |
+
inst,
|
| 1432 |
+
});
|
| 1433 |
+
return payload;
|
| 1434 |
+
}
|
| 1435 |
+
const proms = [];
|
| 1436 |
+
const values = def.keyType._zod.values;
|
| 1437 |
+
if (values) {
|
| 1438 |
+
payload.value = {};
|
| 1439 |
+
const recordKeys = new Set();
|
| 1440 |
+
for (const key of values) {
|
| 1441 |
+
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
| 1442 |
+
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
| 1443 |
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
| 1444 |
+
if (keyResult instanceof Promise) {
|
| 1445 |
+
throw new Error("Async schemas not supported in object keys currently");
|
| 1446 |
+
}
|
| 1447 |
+
if (keyResult.issues.length) {
|
| 1448 |
+
payload.issues.push({
|
| 1449 |
+
code: "invalid_key",
|
| 1450 |
+
origin: "record",
|
| 1451 |
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1452 |
+
input: key,
|
| 1453 |
+
path: [key],
|
| 1454 |
+
inst,
|
| 1455 |
+
});
|
| 1456 |
+
continue;
|
| 1457 |
+
}
|
| 1458 |
+
const outKey = keyResult.value;
|
| 1459 |
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
| 1460 |
+
if (result instanceof Promise) {
|
| 1461 |
+
proms.push(result.then((result) => {
|
| 1462 |
+
if (result.issues.length) {
|
| 1463 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1464 |
+
}
|
| 1465 |
+
payload.value[outKey] = result.value;
|
| 1466 |
+
}));
|
| 1467 |
+
}
|
| 1468 |
+
else {
|
| 1469 |
+
if (result.issues.length) {
|
| 1470 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1471 |
+
}
|
| 1472 |
+
payload.value[outKey] = result.value;
|
| 1473 |
+
}
|
| 1474 |
+
}
|
| 1475 |
+
}
|
| 1476 |
+
let unrecognized;
|
| 1477 |
+
for (const key in input) {
|
| 1478 |
+
if (!recordKeys.has(key)) {
|
| 1479 |
+
unrecognized = unrecognized ?? [];
|
| 1480 |
+
unrecognized.push(key);
|
| 1481 |
+
}
|
| 1482 |
+
}
|
| 1483 |
+
if (unrecognized && unrecognized.length > 0) {
|
| 1484 |
+
payload.issues.push({
|
| 1485 |
+
code: "unrecognized_keys",
|
| 1486 |
+
input,
|
| 1487 |
+
inst,
|
| 1488 |
+
keys: unrecognized,
|
| 1489 |
+
});
|
| 1490 |
+
}
|
| 1491 |
+
}
|
| 1492 |
+
else {
|
| 1493 |
+
payload.value = {};
|
| 1494 |
+
// Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
|
| 1495 |
+
for (const key of Reflect.ownKeys(input)) {
|
| 1496 |
+
if (key === "__proto__")
|
| 1497 |
+
continue;
|
| 1498 |
+
if (!Object.prototype.propertyIsEnumerable.call(input, key))
|
| 1499 |
+
continue;
|
| 1500 |
+
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
| 1501 |
+
if (keyResult instanceof Promise) {
|
| 1502 |
+
throw new Error("Async schemas not supported in object keys currently");
|
| 1503 |
+
}
|
| 1504 |
+
// Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
|
| 1505 |
+
// This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
|
| 1506 |
+
const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
|
| 1507 |
+
if (checkNumericKey) {
|
| 1508 |
+
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
| 1509 |
+
if (retryResult instanceof Promise) {
|
| 1510 |
+
throw new Error("Async schemas not supported in object keys currently");
|
| 1511 |
+
}
|
| 1512 |
+
if (retryResult.issues.length === 0) {
|
| 1513 |
+
keyResult = retryResult;
|
| 1514 |
+
}
|
| 1515 |
+
}
|
| 1516 |
+
if (keyResult.issues.length) {
|
| 1517 |
+
if (def.mode === "loose") {
|
| 1518 |
+
// Pass through unchanged
|
| 1519 |
+
payload.value[key] = input[key];
|
| 1520 |
+
}
|
| 1521 |
+
else {
|
| 1522 |
+
// Default "strict" behavior: error on invalid key
|
| 1523 |
+
payload.issues.push({
|
| 1524 |
+
code: "invalid_key",
|
| 1525 |
+
origin: "record",
|
| 1526 |
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1527 |
+
input: key,
|
| 1528 |
+
path: [key],
|
| 1529 |
+
inst,
|
| 1530 |
+
});
|
| 1531 |
+
}
|
| 1532 |
+
continue;
|
| 1533 |
+
}
|
| 1534 |
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
| 1535 |
+
if (result instanceof Promise) {
|
| 1536 |
+
proms.push(result.then((result) => {
|
| 1537 |
+
if (result.issues.length) {
|
| 1538 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1539 |
+
}
|
| 1540 |
+
payload.value[keyResult.value] = result.value;
|
| 1541 |
+
}));
|
| 1542 |
+
}
|
| 1543 |
+
else {
|
| 1544 |
+
if (result.issues.length) {
|
| 1545 |
+
payload.issues.push(...util.prefixIssues(key, result.issues));
|
| 1546 |
+
}
|
| 1547 |
+
payload.value[keyResult.value] = result.value;
|
| 1548 |
+
}
|
| 1549 |
+
}
|
| 1550 |
+
}
|
| 1551 |
+
if (proms.length) {
|
| 1552 |
+
return Promise.all(proms).then(() => payload);
|
| 1553 |
+
}
|
| 1554 |
+
return payload;
|
| 1555 |
+
};
|
| 1556 |
+
});
|
| 1557 |
+
export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
|
| 1558 |
+
$ZodType.init(inst, def);
|
| 1559 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1560 |
+
const input = payload.value;
|
| 1561 |
+
if (!(input instanceof Map)) {
|
| 1562 |
+
payload.issues.push({
|
| 1563 |
+
expected: "map",
|
| 1564 |
+
code: "invalid_type",
|
| 1565 |
+
input,
|
| 1566 |
+
inst,
|
| 1567 |
+
});
|
| 1568 |
+
return payload;
|
| 1569 |
+
}
|
| 1570 |
+
const proms = [];
|
| 1571 |
+
payload.value = new Map();
|
| 1572 |
+
for (const [key, value] of input) {
|
| 1573 |
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
| 1574 |
+
const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
|
| 1575 |
+
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
| 1576 |
+
proms.push(Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
|
| 1577 |
+
handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
|
| 1578 |
+
}));
|
| 1579 |
+
}
|
| 1580 |
+
else {
|
| 1581 |
+
handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
|
| 1582 |
+
}
|
| 1583 |
+
}
|
| 1584 |
+
if (proms.length)
|
| 1585 |
+
return Promise.all(proms).then(() => payload);
|
| 1586 |
+
return payload;
|
| 1587 |
+
};
|
| 1588 |
+
});
|
| 1589 |
+
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
| 1590 |
+
if (keyResult.issues.length) {
|
| 1591 |
+
if (util.propertyKeyTypes.has(typeof key)) {
|
| 1592 |
+
final.issues.push(...util.prefixIssues(key, keyResult.issues));
|
| 1593 |
+
}
|
| 1594 |
+
else {
|
| 1595 |
+
final.issues.push({
|
| 1596 |
+
code: "invalid_key",
|
| 1597 |
+
origin: "map",
|
| 1598 |
+
input,
|
| 1599 |
+
inst,
|
| 1600 |
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1601 |
+
});
|
| 1602 |
+
}
|
| 1603 |
+
}
|
| 1604 |
+
if (valueResult.issues.length) {
|
| 1605 |
+
if (util.propertyKeyTypes.has(typeof key)) {
|
| 1606 |
+
final.issues.push(...util.prefixIssues(key, valueResult.issues));
|
| 1607 |
+
}
|
| 1608 |
+
else {
|
| 1609 |
+
final.issues.push({
|
| 1610 |
+
origin: "map",
|
| 1611 |
+
code: "invalid_element",
|
| 1612 |
+
input,
|
| 1613 |
+
inst,
|
| 1614 |
+
key: key,
|
| 1615 |
+
issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1616 |
+
});
|
| 1617 |
+
}
|
| 1618 |
+
}
|
| 1619 |
+
final.value.set(keyResult.value, valueResult.value);
|
| 1620 |
+
}
|
| 1621 |
+
export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
|
| 1622 |
+
$ZodType.init(inst, def);
|
| 1623 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1624 |
+
const input = payload.value;
|
| 1625 |
+
if (!(input instanceof Set)) {
|
| 1626 |
+
payload.issues.push({
|
| 1627 |
+
input,
|
| 1628 |
+
inst,
|
| 1629 |
+
expected: "set",
|
| 1630 |
+
code: "invalid_type",
|
| 1631 |
+
});
|
| 1632 |
+
return payload;
|
| 1633 |
+
}
|
| 1634 |
+
const proms = [];
|
| 1635 |
+
payload.value = new Set();
|
| 1636 |
+
for (const item of input) {
|
| 1637 |
+
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
| 1638 |
+
if (result instanceof Promise) {
|
| 1639 |
+
proms.push(result.then((result) => handleSetResult(result, payload)));
|
| 1640 |
+
}
|
| 1641 |
+
else
|
| 1642 |
+
handleSetResult(result, payload);
|
| 1643 |
+
}
|
| 1644 |
+
if (proms.length)
|
| 1645 |
+
return Promise.all(proms).then(() => payload);
|
| 1646 |
+
return payload;
|
| 1647 |
+
};
|
| 1648 |
+
});
|
| 1649 |
+
function handleSetResult(result, final) {
|
| 1650 |
+
if (result.issues.length) {
|
| 1651 |
+
final.issues.push(...result.issues);
|
| 1652 |
+
}
|
| 1653 |
+
final.value.add(result.value);
|
| 1654 |
+
}
|
| 1655 |
+
export const $ZodEnum = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def) => {
|
| 1656 |
+
$ZodType.init(inst, def);
|
| 1657 |
+
const values = util.getEnumValues(def.entries);
|
| 1658 |
+
const valuesSet = new Set(values);
|
| 1659 |
+
inst._zod.values = valuesSet;
|
| 1660 |
+
inst._zod.pattern = new RegExp(`^(${values
|
| 1661 |
+
.filter((k) => util.propertyKeyTypes.has(typeof k))
|
| 1662 |
+
.map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString()))
|
| 1663 |
+
.join("|")})$`);
|
| 1664 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1665 |
+
const input = payload.value;
|
| 1666 |
+
if (valuesSet.has(input)) {
|
| 1667 |
+
return payload;
|
| 1668 |
+
}
|
| 1669 |
+
payload.issues.push({
|
| 1670 |
+
code: "invalid_value",
|
| 1671 |
+
values,
|
| 1672 |
+
input,
|
| 1673 |
+
inst,
|
| 1674 |
+
});
|
| 1675 |
+
return payload;
|
| 1676 |
+
};
|
| 1677 |
+
});
|
| 1678 |
+
export const $ZodLiteral = /*@__PURE__*/ core.$constructor("$ZodLiteral", (inst, def) => {
|
| 1679 |
+
$ZodType.init(inst, def);
|
| 1680 |
+
if (def.values.length === 0) {
|
| 1681 |
+
throw new Error("Cannot create literal schema with no valid values");
|
| 1682 |
+
}
|
| 1683 |
+
const values = new Set(def.values);
|
| 1684 |
+
inst._zod.values = values;
|
| 1685 |
+
inst._zod.pattern = new RegExp(`^(${def.values
|
| 1686 |
+
.map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)))
|
| 1687 |
+
.join("|")})$`);
|
| 1688 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1689 |
+
const input = payload.value;
|
| 1690 |
+
if (values.has(input)) {
|
| 1691 |
+
return payload;
|
| 1692 |
+
}
|
| 1693 |
+
payload.issues.push({
|
| 1694 |
+
code: "invalid_value",
|
| 1695 |
+
values: def.values,
|
| 1696 |
+
input,
|
| 1697 |
+
inst,
|
| 1698 |
+
});
|
| 1699 |
+
return payload;
|
| 1700 |
+
};
|
| 1701 |
+
});
|
| 1702 |
+
export const $ZodFile = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def) => {
|
| 1703 |
+
$ZodType.init(inst, def);
|
| 1704 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1705 |
+
const input = payload.value;
|
| 1706 |
+
// @ts-ignore
|
| 1707 |
+
if (input instanceof File)
|
| 1708 |
+
return payload;
|
| 1709 |
+
payload.issues.push({
|
| 1710 |
+
expected: "file",
|
| 1711 |
+
code: "invalid_type",
|
| 1712 |
+
input,
|
| 1713 |
+
inst,
|
| 1714 |
+
});
|
| 1715 |
+
return payload;
|
| 1716 |
+
};
|
| 1717 |
+
});
|
| 1718 |
+
export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (inst, def) => {
|
| 1719 |
+
$ZodType.init(inst, def);
|
| 1720 |
+
inst._zod.optin = "optional";
|
| 1721 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1722 |
+
if (ctx.direction === "backward") {
|
| 1723 |
+
throw new core.$ZodEncodeError(inst.constructor.name);
|
| 1724 |
+
}
|
| 1725 |
+
const _out = def.transform(payload.value, payload);
|
| 1726 |
+
if (ctx.async) {
|
| 1727 |
+
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
| 1728 |
+
return output.then((output) => {
|
| 1729 |
+
payload.value = output;
|
| 1730 |
+
payload.fallback = true;
|
| 1731 |
+
return payload;
|
| 1732 |
+
});
|
| 1733 |
+
}
|
| 1734 |
+
if (_out instanceof Promise) {
|
| 1735 |
+
throw new core.$ZodAsyncError();
|
| 1736 |
+
}
|
| 1737 |
+
payload.value = _out;
|
| 1738 |
+
payload.fallback = true;
|
| 1739 |
+
return payload;
|
| 1740 |
+
};
|
| 1741 |
+
});
|
| 1742 |
+
function handleOptionalResult(result, input) {
|
| 1743 |
+
if (input === undefined && (result.issues.length || result.fallback)) {
|
| 1744 |
+
return { issues: [], value: undefined };
|
| 1745 |
+
}
|
| 1746 |
+
return result;
|
| 1747 |
+
}
|
| 1748 |
+
export const $ZodOptional = /*@__PURE__*/ core.$constructor("$ZodOptional", (inst, def) => {
|
| 1749 |
+
$ZodType.init(inst, def);
|
| 1750 |
+
inst._zod.optin = "optional";
|
| 1751 |
+
inst._zod.optout = "optional";
|
| 1752 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1753 |
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
|
| 1754 |
+
});
|
| 1755 |
+
util.defineLazy(inst._zod, "pattern", () => {
|
| 1756 |
+
const pattern = def.innerType._zod.pattern;
|
| 1757 |
+
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
|
| 1758 |
+
});
|
| 1759 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1760 |
+
if (def.innerType._zod.optin === "optional") {
|
| 1761 |
+
const input = payload.value;
|
| 1762 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1763 |
+
if (result instanceof Promise)
|
| 1764 |
+
return result.then((r) => handleOptionalResult(r, input));
|
| 1765 |
+
return handleOptionalResult(result, input);
|
| 1766 |
+
}
|
| 1767 |
+
if (payload.value === undefined) {
|
| 1768 |
+
return payload;
|
| 1769 |
+
}
|
| 1770 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1771 |
+
};
|
| 1772 |
+
});
|
| 1773 |
+
export const $ZodExactOptional = /*@__PURE__*/ core.$constructor("$ZodExactOptional", (inst, def) => {
|
| 1774 |
+
// Call parent init - inherits optin/optout = "optional"
|
| 1775 |
+
$ZodOptional.init(inst, def);
|
| 1776 |
+
// Override values/pattern to NOT add undefined
|
| 1777 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1778 |
+
util.defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
| 1779 |
+
// Override parse to just delegate (no undefined handling)
|
| 1780 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1781 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1782 |
+
};
|
| 1783 |
+
});
|
| 1784 |
+
export const $ZodNullable = /*@__PURE__*/ core.$constructor("$ZodNullable", (inst, def) => {
|
| 1785 |
+
$ZodType.init(inst, def);
|
| 1786 |
+
util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
| 1787 |
+
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
| 1788 |
+
util.defineLazy(inst._zod, "pattern", () => {
|
| 1789 |
+
const pattern = def.innerType._zod.pattern;
|
| 1790 |
+
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
|
| 1791 |
+
});
|
| 1792 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1793 |
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
| 1794 |
+
});
|
| 1795 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1796 |
+
// Forward direction (decode): allow null to pass through
|
| 1797 |
+
if (payload.value === null)
|
| 1798 |
+
return payload;
|
| 1799 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1800 |
+
};
|
| 1801 |
+
});
|
| 1802 |
+
export const $ZodDefault = /*@__PURE__*/ core.$constructor("$ZodDefault", (inst, def) => {
|
| 1803 |
+
$ZodType.init(inst, def);
|
| 1804 |
+
// inst._zod.qin = "true";
|
| 1805 |
+
inst._zod.optin = "optional";
|
| 1806 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1807 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1808 |
+
if (ctx.direction === "backward") {
|
| 1809 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1810 |
+
}
|
| 1811 |
+
// Forward direction (decode): apply defaults for undefined input
|
| 1812 |
+
if (payload.value === undefined) {
|
| 1813 |
+
payload.value = def.defaultValue;
|
| 1814 |
+
/**
|
| 1815 |
+
* $ZodDefault returns the default value immediately in forward direction.
|
| 1816 |
+
* 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. */
|
| 1817 |
+
return payload;
|
| 1818 |
+
}
|
| 1819 |
+
// Forward direction: continue with default handling
|
| 1820 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1821 |
+
if (result instanceof Promise) {
|
| 1822 |
+
return result.then((result) => handleDefaultResult(result, def));
|
| 1823 |
+
}
|
| 1824 |
+
return handleDefaultResult(result, def);
|
| 1825 |
+
};
|
| 1826 |
+
});
|
| 1827 |
+
function handleDefaultResult(payload, def) {
|
| 1828 |
+
if (payload.value === undefined) {
|
| 1829 |
+
payload.value = def.defaultValue;
|
| 1830 |
+
}
|
| 1831 |
+
return payload;
|
| 1832 |
+
}
|
| 1833 |
+
export const $ZodPrefault = /*@__PURE__*/ core.$constructor("$ZodPrefault", (inst, def) => {
|
| 1834 |
+
$ZodType.init(inst, def);
|
| 1835 |
+
inst._zod.optin = "optional";
|
| 1836 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1837 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1838 |
+
if (ctx.direction === "backward") {
|
| 1839 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1840 |
+
}
|
| 1841 |
+
// Forward direction (decode): apply prefault for undefined input
|
| 1842 |
+
if (payload.value === undefined) {
|
| 1843 |
+
payload.value = def.defaultValue;
|
| 1844 |
+
}
|
| 1845 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1846 |
+
};
|
| 1847 |
+
});
|
| 1848 |
+
export const $ZodNonOptional = /*@__PURE__*/ core.$constructor("$ZodNonOptional", (inst, def) => {
|
| 1849 |
+
$ZodType.init(inst, def);
|
| 1850 |
+
util.defineLazy(inst._zod, "values", () => {
|
| 1851 |
+
const v = def.innerType._zod.values;
|
| 1852 |
+
return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
|
| 1853 |
+
});
|
| 1854 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1855 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1856 |
+
if (result instanceof Promise) {
|
| 1857 |
+
return result.then((result) => handleNonOptionalResult(result, inst));
|
| 1858 |
+
}
|
| 1859 |
+
return handleNonOptionalResult(result, inst);
|
| 1860 |
+
};
|
| 1861 |
+
});
|
| 1862 |
+
function handleNonOptionalResult(payload, inst) {
|
| 1863 |
+
if (!payload.issues.length && payload.value === undefined) {
|
| 1864 |
+
payload.issues.push({
|
| 1865 |
+
code: "invalid_type",
|
| 1866 |
+
expected: "nonoptional",
|
| 1867 |
+
input: payload.value,
|
| 1868 |
+
inst,
|
| 1869 |
+
});
|
| 1870 |
+
}
|
| 1871 |
+
return payload;
|
| 1872 |
+
}
|
| 1873 |
+
export const $ZodSuccess = /*@__PURE__*/ core.$constructor("$ZodSuccess", (inst, def) => {
|
| 1874 |
+
$ZodType.init(inst, def);
|
| 1875 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1876 |
+
if (ctx.direction === "backward") {
|
| 1877 |
+
throw new core.$ZodEncodeError("ZodSuccess");
|
| 1878 |
+
}
|
| 1879 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1880 |
+
if (result instanceof Promise) {
|
| 1881 |
+
return result.then((result) => {
|
| 1882 |
+
payload.value = result.issues.length === 0;
|
| 1883 |
+
return payload;
|
| 1884 |
+
});
|
| 1885 |
+
}
|
| 1886 |
+
payload.value = result.issues.length === 0;
|
| 1887 |
+
return payload;
|
| 1888 |
+
};
|
| 1889 |
+
});
|
| 1890 |
+
export const $ZodCatch = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
|
| 1891 |
+
$ZodType.init(inst, def);
|
| 1892 |
+
inst._zod.optin = "optional";
|
| 1893 |
+
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
| 1894 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 1895 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1896 |
+
if (ctx.direction === "backward") {
|
| 1897 |
+
return def.innerType._zod.run(payload, ctx);
|
| 1898 |
+
}
|
| 1899 |
+
// Forward direction (decode): apply catch logic
|
| 1900 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 1901 |
+
if (result instanceof Promise) {
|
| 1902 |
+
return result.then((result) => {
|
| 1903 |
+
payload.value = result.value;
|
| 1904 |
+
if (result.issues.length) {
|
| 1905 |
+
payload.value = def.catchValue({
|
| 1906 |
+
...payload,
|
| 1907 |
+
error: {
|
| 1908 |
+
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1909 |
+
},
|
| 1910 |
+
input: payload.value,
|
| 1911 |
+
});
|
| 1912 |
+
payload.issues = [];
|
| 1913 |
+
payload.fallback = true;
|
| 1914 |
+
}
|
| 1915 |
+
return payload;
|
| 1916 |
+
});
|
| 1917 |
+
}
|
| 1918 |
+
payload.value = result.value;
|
| 1919 |
+
if (result.issues.length) {
|
| 1920 |
+
payload.value = def.catchValue({
|
| 1921 |
+
...payload,
|
| 1922 |
+
error: {
|
| 1923 |
+
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
| 1924 |
+
},
|
| 1925 |
+
input: payload.value,
|
| 1926 |
+
});
|
| 1927 |
+
payload.issues = [];
|
| 1928 |
+
payload.fallback = true;
|
| 1929 |
+
}
|
| 1930 |
+
return payload;
|
| 1931 |
+
};
|
| 1932 |
+
});
|
| 1933 |
+
export const $ZodNaN = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) => {
|
| 1934 |
+
$ZodType.init(inst, def);
|
| 1935 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 1936 |
+
if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
|
| 1937 |
+
payload.issues.push({
|
| 1938 |
+
input: payload.value,
|
| 1939 |
+
inst,
|
| 1940 |
+
expected: "nan",
|
| 1941 |
+
code: "invalid_type",
|
| 1942 |
+
});
|
| 1943 |
+
return payload;
|
| 1944 |
+
}
|
| 1945 |
+
return payload;
|
| 1946 |
+
};
|
| 1947 |
+
});
|
| 1948 |
+
export const $ZodPipe = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
|
| 1949 |
+
$ZodType.init(inst, def);
|
| 1950 |
+
util.defineLazy(inst._zod, "values", () => def.in._zod.values);
|
| 1951 |
+
util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
| 1952 |
+
util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
| 1953 |
+
util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
| 1954 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1955 |
+
if (ctx.direction === "backward") {
|
| 1956 |
+
const right = def.out._zod.run(payload, ctx);
|
| 1957 |
+
if (right instanceof Promise) {
|
| 1958 |
+
return right.then((right) => handlePipeResult(right, def.in, ctx));
|
| 1959 |
+
}
|
| 1960 |
+
return handlePipeResult(right, def.in, ctx);
|
| 1961 |
+
}
|
| 1962 |
+
const left = def.in._zod.run(payload, ctx);
|
| 1963 |
+
if (left instanceof Promise) {
|
| 1964 |
+
return left.then((left) => handlePipeResult(left, def.out, ctx));
|
| 1965 |
+
}
|
| 1966 |
+
return handlePipeResult(left, def.out, ctx);
|
| 1967 |
+
};
|
| 1968 |
+
});
|
| 1969 |
+
function handlePipeResult(left, next, ctx) {
|
| 1970 |
+
if (left.issues.length) {
|
| 1971 |
+
// prevent further checks
|
| 1972 |
+
left.aborted = true;
|
| 1973 |
+
return left;
|
| 1974 |
+
}
|
| 1975 |
+
return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx);
|
| 1976 |
+
}
|
| 1977 |
+
export const $ZodCodec = /*@__PURE__*/ core.$constructor("$ZodCodec", (inst, def) => {
|
| 1978 |
+
$ZodType.init(inst, def);
|
| 1979 |
+
util.defineLazy(inst._zod, "values", () => def.in._zod.values);
|
| 1980 |
+
util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
| 1981 |
+
util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
| 1982 |
+
util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
| 1983 |
+
inst._zod.parse = (payload, ctx) => {
|
| 1984 |
+
const direction = ctx.direction || "forward";
|
| 1985 |
+
if (direction === "forward") {
|
| 1986 |
+
const left = def.in._zod.run(payload, ctx);
|
| 1987 |
+
if (left instanceof Promise) {
|
| 1988 |
+
return left.then((left) => handleCodecAResult(left, def, ctx));
|
| 1989 |
+
}
|
| 1990 |
+
return handleCodecAResult(left, def, ctx);
|
| 1991 |
+
}
|
| 1992 |
+
else {
|
| 1993 |
+
const right = def.out._zod.run(payload, ctx);
|
| 1994 |
+
if (right instanceof Promise) {
|
| 1995 |
+
return right.then((right) => handleCodecAResult(right, def, ctx));
|
| 1996 |
+
}
|
| 1997 |
+
return handleCodecAResult(right, def, ctx);
|
| 1998 |
+
}
|
| 1999 |
+
};
|
| 2000 |
+
});
|
| 2001 |
+
function handleCodecAResult(result, def, ctx) {
|
| 2002 |
+
if (result.issues.length) {
|
| 2003 |
+
// prevent further checks
|
| 2004 |
+
result.aborted = true;
|
| 2005 |
+
return result;
|
| 2006 |
+
}
|
| 2007 |
+
const direction = ctx.direction || "forward";
|
| 2008 |
+
if (direction === "forward") {
|
| 2009 |
+
const transformed = def.transform(result.value, result);
|
| 2010 |
+
if (transformed instanceof Promise) {
|
| 2011 |
+
return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx));
|
| 2012 |
+
}
|
| 2013 |
+
return handleCodecTxResult(result, transformed, def.out, ctx);
|
| 2014 |
+
}
|
| 2015 |
+
else {
|
| 2016 |
+
const transformed = def.reverseTransform(result.value, result);
|
| 2017 |
+
if (transformed instanceof Promise) {
|
| 2018 |
+
return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx));
|
| 2019 |
+
}
|
| 2020 |
+
return handleCodecTxResult(result, transformed, def.in, ctx);
|
| 2021 |
+
}
|
| 2022 |
+
}
|
| 2023 |
+
function handleCodecTxResult(left, value, nextSchema, ctx) {
|
| 2024 |
+
// Check if transform added any issues
|
| 2025 |
+
if (left.issues.length) {
|
| 2026 |
+
left.aborted = true;
|
| 2027 |
+
return left;
|
| 2028 |
+
}
|
| 2029 |
+
return nextSchema._zod.run({ value, issues: left.issues }, ctx);
|
| 2030 |
+
}
|
| 2031 |
+
export const $ZodPreprocess = /*@__PURE__*/ core.$constructor("$ZodPreprocess", (inst, def) => {
|
| 2032 |
+
$ZodPipe.init(inst, def);
|
| 2033 |
+
});
|
| 2034 |
+
export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (inst, def) => {
|
| 2035 |
+
$ZodType.init(inst, def);
|
| 2036 |
+
util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
| 2037 |
+
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
| 2038 |
+
util.defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
| 2039 |
+
util.defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
| 2040 |
+
inst._zod.parse = (payload, ctx) => {
|
| 2041 |
+
if (ctx.direction === "backward") {
|
| 2042 |
+
return def.innerType._zod.run(payload, ctx);
|
| 2043 |
+
}
|
| 2044 |
+
const result = def.innerType._zod.run(payload, ctx);
|
| 2045 |
+
if (result instanceof Promise) {
|
| 2046 |
+
return result.then(handleReadonlyResult);
|
| 2047 |
+
}
|
| 2048 |
+
return handleReadonlyResult(result);
|
| 2049 |
+
};
|
| 2050 |
+
});
|
| 2051 |
+
function handleReadonlyResult(payload) {
|
| 2052 |
+
payload.value = Object.freeze(payload.value);
|
| 2053 |
+
return payload;
|
| 2054 |
+
}
|
| 2055 |
+
export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplateLiteral", (inst, def) => {
|
| 2056 |
+
$ZodType.init(inst, def);
|
| 2057 |
+
const regexParts = [];
|
| 2058 |
+
for (const part of def.parts) {
|
| 2059 |
+
if (typeof part === "object" && part !== null) {
|
| 2060 |
+
// is Zod schema
|
| 2061 |
+
if (!part._zod.pattern) {
|
| 2062 |
+
// if (!source)
|
| 2063 |
+
throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
|
| 2064 |
+
}
|
| 2065 |
+
const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
|
| 2066 |
+
if (!source)
|
| 2067 |
+
throw new Error(`Invalid template literal part: ${part._zod.traits}`);
|
| 2068 |
+
const start = source.startsWith("^") ? 1 : 0;
|
| 2069 |
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
| 2070 |
+
regexParts.push(source.slice(start, end));
|
| 2071 |
+
}
|
| 2072 |
+
else if (part === null || util.primitiveTypes.has(typeof part)) {
|
| 2073 |
+
regexParts.push(util.escapeRegex(`${part}`));
|
| 2074 |
+
}
|
| 2075 |
+
else {
|
| 2076 |
+
throw new Error(`Invalid template literal part: ${part}`);
|
| 2077 |
+
}
|
| 2078 |
+
}
|
| 2079 |
+
inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
|
| 2080 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 2081 |
+
if (typeof payload.value !== "string") {
|
| 2082 |
+
payload.issues.push({
|
| 2083 |
+
input: payload.value,
|
| 2084 |
+
inst,
|
| 2085 |
+
expected: "string",
|
| 2086 |
+
code: "invalid_type",
|
| 2087 |
+
});
|
| 2088 |
+
return payload;
|
| 2089 |
+
}
|
| 2090 |
+
inst._zod.pattern.lastIndex = 0;
|
| 2091 |
+
if (!inst._zod.pattern.test(payload.value)) {
|
| 2092 |
+
payload.issues.push({
|
| 2093 |
+
input: payload.value,
|
| 2094 |
+
inst,
|
| 2095 |
+
code: "invalid_format",
|
| 2096 |
+
format: def.format ?? "template_literal",
|
| 2097 |
+
pattern: inst._zod.pattern.source,
|
| 2098 |
+
});
|
| 2099 |
+
return payload;
|
| 2100 |
+
}
|
| 2101 |
+
return payload;
|
| 2102 |
+
};
|
| 2103 |
+
});
|
| 2104 |
+
export const $ZodFunction = /*@__PURE__*/ core.$constructor("$ZodFunction", (inst, def) => {
|
| 2105 |
+
$ZodType.init(inst, def);
|
| 2106 |
+
inst._def = def;
|
| 2107 |
+
inst._zod.def = def;
|
| 2108 |
+
inst.implement = (func) => {
|
| 2109 |
+
if (typeof func !== "function") {
|
| 2110 |
+
throw new Error("implement() must be called with a function");
|
| 2111 |
+
}
|
| 2112 |
+
return function (...args) {
|
| 2113 |
+
const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
|
| 2114 |
+
const result = Reflect.apply(func, this, parsedArgs);
|
| 2115 |
+
if (inst._def.output) {
|
| 2116 |
+
return parse(inst._def.output, result);
|
| 2117 |
+
}
|
| 2118 |
+
return result;
|
| 2119 |
+
};
|
| 2120 |
+
};
|
| 2121 |
+
inst.implementAsync = (func) => {
|
| 2122 |
+
if (typeof func !== "function") {
|
| 2123 |
+
throw new Error("implementAsync() must be called with a function");
|
| 2124 |
+
}
|
| 2125 |
+
return async function (...args) {
|
| 2126 |
+
const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
|
| 2127 |
+
const result = await Reflect.apply(func, this, parsedArgs);
|
| 2128 |
+
if (inst._def.output) {
|
| 2129 |
+
return await parseAsync(inst._def.output, result);
|
| 2130 |
+
}
|
| 2131 |
+
return result;
|
| 2132 |
+
};
|
| 2133 |
+
};
|
| 2134 |
+
inst._zod.parse = (payload, _ctx) => {
|
| 2135 |
+
if (typeof payload.value !== "function") {
|
| 2136 |
+
payload.issues.push({
|
| 2137 |
+
code: "invalid_type",
|
| 2138 |
+
expected: "function",
|
| 2139 |
+
input: payload.value,
|
| 2140 |
+
inst,
|
| 2141 |
+
});
|
| 2142 |
+
return payload;
|
| 2143 |
+
}
|
| 2144 |
+
// Check if output is a promise type to determine if we should use async implementation
|
| 2145 |
+
const hasPromiseOutput = inst._def.output && inst._def.output._zod.def.type === "promise";
|
| 2146 |
+
if (hasPromiseOutput) {
|
| 2147 |
+
payload.value = inst.implementAsync(payload.value);
|
| 2148 |
+
}
|
| 2149 |
+
else {
|
| 2150 |
+
payload.value = inst.implement(payload.value);
|
| 2151 |
+
}
|
| 2152 |
+
return payload;
|
| 2153 |
+
};
|
| 2154 |
+
inst.input = (...args) => {
|
| 2155 |
+
const F = inst.constructor;
|
| 2156 |
+
if (Array.isArray(args[0])) {
|
| 2157 |
+
return new F({
|
| 2158 |
+
type: "function",
|
| 2159 |
+
input: new $ZodTuple({
|
| 2160 |
+
type: "tuple",
|
| 2161 |
+
items: args[0],
|
| 2162 |
+
rest: args[1],
|
| 2163 |
+
}),
|
| 2164 |
+
output: inst._def.output,
|
| 2165 |
+
});
|
| 2166 |
+
}
|
| 2167 |
+
return new F({
|
| 2168 |
+
type: "function",
|
| 2169 |
+
input: args[0],
|
| 2170 |
+
output: inst._def.output,
|
| 2171 |
+
});
|
| 2172 |
+
};
|
| 2173 |
+
inst.output = (output) => {
|
| 2174 |
+
const F = inst.constructor;
|
| 2175 |
+
return new F({
|
| 2176 |
+
type: "function",
|
| 2177 |
+
input: inst._def.input,
|
| 2178 |
+
output,
|
| 2179 |
+
});
|
| 2180 |
+
};
|
| 2181 |
+
return inst;
|
| 2182 |
+
});
|
| 2183 |
+
export const $ZodPromise = /*@__PURE__*/ core.$constructor("$ZodPromise", (inst, def) => {
|
| 2184 |
+
$ZodType.init(inst, def);
|
| 2185 |
+
inst._zod.parse = (payload, ctx) => {
|
| 2186 |
+
return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
|
| 2187 |
+
};
|
| 2188 |
+
});
|
| 2189 |
+
export const $ZodLazy = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
|
| 2190 |
+
$ZodType.init(inst, def);
|
| 2191 |
+
// Cache the resolved inner type on the shared `def` so all clones of this
|
| 2192 |
+
// lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance,
|
| 2193 |
+
// preserving identity for cycle detection on recursive schemas.
|
| 2194 |
+
util.defineLazy(inst._zod, "innerType", () => {
|
| 2195 |
+
const d = def;
|
| 2196 |
+
if (!d._cachedInner)
|
| 2197 |
+
d._cachedInner = def.getter();
|
| 2198 |
+
return d._cachedInner;
|
| 2199 |
+
});
|
| 2200 |
+
util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
|
| 2201 |
+
util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
|
| 2202 |
+
util.defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined);
|
| 2203 |
+
util.defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? undefined);
|
| 2204 |
+
inst._zod.parse = (payload, ctx) => {
|
| 2205 |
+
const inner = inst._zod.innerType;
|
| 2206 |
+
return inner._zod.run(payload, ctx);
|
| 2207 |
+
};
|
| 2208 |
+
});
|
| 2209 |
+
export const $ZodCustom = /*@__PURE__*/ core.$constructor("$ZodCustom", (inst, def) => {
|
| 2210 |
+
checks.$ZodCheck.init(inst, def);
|
| 2211 |
+
$ZodType.init(inst, def);
|
| 2212 |
+
inst._zod.parse = (payload, _) => {
|
| 2213 |
+
return payload;
|
| 2214 |
+
};
|
| 2215 |
+
inst._zod.check = (payload) => {
|
| 2216 |
+
const input = payload.value;
|
| 2217 |
+
const r = def.fn(input);
|
| 2218 |
+
if (r instanceof Promise) {
|
| 2219 |
+
return r.then((r) => handleRefineResult(r, payload, input, inst));
|
| 2220 |
+
}
|
| 2221 |
+
handleRefineResult(r, payload, input, inst);
|
| 2222 |
+
return;
|
| 2223 |
+
};
|
| 2224 |
+
});
|
| 2225 |
+
function handleRefineResult(result, payload, input, inst) {
|
| 2226 |
+
if (!result) {
|
| 2227 |
+
const _iss = {
|
| 2228 |
+
code: "custom",
|
| 2229 |
+
input,
|
| 2230 |
+
inst, // incorporates params.error into issue reporting
|
| 2231 |
+
path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
|
| 2232 |
+
continue: !inst._zod.def.abort,
|
| 2233 |
+
// params: inst._zod.def.params,
|
| 2234 |
+
};
|
| 2235 |
+
if (inst._zod.def.params)
|
| 2236 |
+
_iss.params = inst._zod.def.params;
|
| 2237 |
+
payload.issues.push(util.issue(_iss));
|
| 2238 |
+
}
|
| 2239 |
+
}
|
node_modules/zod/v4/core/standard-schema.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
node_modules/zod/v4/core/standard-schema.d.cts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** The Standard interface. */
|
| 2 |
+
export interface StandardTypedV1<Input = unknown, Output = Input> {
|
| 3 |
+
/** The Standard properties. */
|
| 4 |
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
| 5 |
+
}
|
| 6 |
+
export declare namespace StandardTypedV1 {
|
| 7 |
+
/** The Standard properties interface. */
|
| 8 |
+
interface Props<Input = unknown, Output = Input> {
|
| 9 |
+
/** The version number of the standard. */
|
| 10 |
+
readonly version: 1;
|
| 11 |
+
/** The vendor name of the schema library. */
|
| 12 |
+
readonly vendor: string;
|
| 13 |
+
/** Inferred types associated with the schema. */
|
| 14 |
+
readonly types?: Types<Input, Output> | undefined;
|
| 15 |
+
}
|
| 16 |
+
/** The Standard types interface. */
|
| 17 |
+
interface Types<Input = unknown, Output = Input> {
|
| 18 |
+
/** The input type of the schema. */
|
| 19 |
+
readonly input: Input;
|
| 20 |
+
/** The output type of the schema. */
|
| 21 |
+
readonly output: Output;
|
| 22 |
+
}
|
| 23 |
+
/** Infers the input type of a Standard. */
|
| 24 |
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
| 25 |
+
/** Infers the output type of a Standard. */
|
| 26 |
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
| 27 |
+
}
|
| 28 |
+
/** The Standard Schema interface. */
|
| 29 |
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
| 30 |
+
/** The Standard Schema properties. */
|
| 31 |
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
| 32 |
+
}
|
| 33 |
+
export declare namespace StandardSchemaV1 {
|
| 34 |
+
/** The Standard Schema properties interface. */
|
| 35 |
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
| 36 |
+
/** Validates unknown input values. */
|
| 37 |
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
| 38 |
+
}
|
| 39 |
+
/** The result interface of the validate function. */
|
| 40 |
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
| 41 |
+
/** The result interface if validation succeeds. */
|
| 42 |
+
interface SuccessResult<Output> {
|
| 43 |
+
/** The typed output value. */
|
| 44 |
+
readonly value: Output;
|
| 45 |
+
/** The absence of issues indicates success. */
|
| 46 |
+
readonly issues?: undefined;
|
| 47 |
+
}
|
| 48 |
+
interface Options {
|
| 49 |
+
/** Implicit support for additional vendor-specific parameters, if needed. */
|
| 50 |
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
| 51 |
+
}
|
| 52 |
+
/** The result interface if validation fails. */
|
| 53 |
+
interface FailureResult {
|
| 54 |
+
/** The issues of failed validation. */
|
| 55 |
+
readonly issues: ReadonlyArray<Issue>;
|
| 56 |
+
}
|
| 57 |
+
/** The issue interface of the failure output. */
|
| 58 |
+
interface Issue {
|
| 59 |
+
/** The error message of the issue. */
|
| 60 |
+
readonly message: string;
|
| 61 |
+
/** The path of the issue, if any. */
|
| 62 |
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
| 63 |
+
}
|
| 64 |
+
/** The path segment interface of the issue. */
|
| 65 |
+
interface PathSegment {
|
| 66 |
+
/** The key representing a path segment. */
|
| 67 |
+
readonly key: PropertyKey;
|
| 68 |
+
}
|
| 69 |
+
/** The Standard types interface. */
|
| 70 |
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {
|
| 71 |
+
}
|
| 72 |
+
/** Infers the input type of a Standard. */
|
| 73 |
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
| 74 |
+
/** Infers the output type of a Standard. */
|
| 75 |
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
| 76 |
+
}
|
| 77 |
+
/** The Standard JSON Schema interface. */
|
| 78 |
+
export interface StandardJSONSchemaV1<Input = unknown, Output = Input> {
|
| 79 |
+
/** The Standard JSON Schema properties. */
|
| 80 |
+
readonly "~standard": StandardJSONSchemaV1.Props<Input, Output>;
|
| 81 |
+
}
|
| 82 |
+
export declare namespace StandardJSONSchemaV1 {
|
| 83 |
+
/** The Standard JSON Schema properties interface. */
|
| 84 |
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
| 85 |
+
/** Methods for generating the input/output JSON Schema. */
|
| 86 |
+
readonly jsonSchema: Converter;
|
| 87 |
+
}
|
| 88 |
+
/** The Standard JSON Schema converter interface. */
|
| 89 |
+
interface Converter {
|
| 90 |
+
/** Converts the input type to JSON Schema. May throw if conversion is not supported. */
|
| 91 |
+
readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
|
| 92 |
+
/** Converts the output type to JSON Schema. May throw if conversion is not supported. */
|
| 93 |
+
readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
|
| 94 |
+
}
|
| 95 |
+
/** The target version of the generated JSON Schema.
|
| 96 |
+
*
|
| 97 |
+
* It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use.
|
| 98 |
+
*
|
| 99 |
+
* The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`.
|
| 100 |
+
*
|
| 101 |
+
* All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.
|
| 102 |
+
*/
|
| 103 |
+
type Target = "draft-2020-12" | "draft-07" | "openapi-3.0" | ({} & string);
|
| 104 |
+
/** The options for the input/output methods. */
|
| 105 |
+
interface Options {
|
| 106 |
+
/** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */
|
| 107 |
+
readonly target: Target;
|
| 108 |
+
/** Implicit support for additional vendor-specific parameters, if needed. */
|
| 109 |
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
| 110 |
+
}
|
| 111 |
+
/** The Standard types interface. */
|
| 112 |
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {
|
| 113 |
+
}
|
| 114 |
+
/** Infers the input type of a Standard. */
|
| 115 |
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
| 116 |
+
/** Infers the output type of a Standard. */
|
| 117 |
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
| 118 |
+
}
|
| 119 |
+
export interface StandardSchemaWithJSONProps<Input = unknown, Output = Input> extends StandardSchemaV1.Props<Input, Output>, StandardJSONSchemaV1.Props<Input, Output> {
|
| 120 |
+
}
|
| 121 |
+
/**
|
| 122 |
+
* An interface that combines StandardJSONSchema and StandardSchema.
|
| 123 |
+
*/
|
| 124 |
+
export interface StandardSchemaWithJSON<Input = unknown, Output = Input> {
|
| 125 |
+
"~standard": StandardSchemaWithJSONProps<Input, Output>;
|
| 126 |
+
}
|
node_modules/zod/v4/core/standard-schema.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** The Standard interface. */
|
| 2 |
+
export interface StandardTypedV1<Input = unknown, Output = Input> {
|
| 3 |
+
/** The Standard properties. */
|
| 4 |
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
| 5 |
+
}
|
| 6 |
+
export declare namespace StandardTypedV1 {
|
| 7 |
+
/** The Standard properties interface. */
|
| 8 |
+
interface Props<Input = unknown, Output = Input> {
|
| 9 |
+
/** The version number of the standard. */
|
| 10 |
+
readonly version: 1;
|
| 11 |
+
/** The vendor name of the schema library. */
|
| 12 |
+
readonly vendor: string;
|
| 13 |
+
/** Inferred types associated with the schema. */
|
| 14 |
+
readonly types?: Types<Input, Output> | undefined;
|
| 15 |
+
}
|
| 16 |
+
/** The Standard types interface. */
|
| 17 |
+
interface Types<Input = unknown, Output = Input> {
|
| 18 |
+
/** The input type of the schema. */
|
| 19 |
+
readonly input: Input;
|
| 20 |
+
/** The output type of the schema. */
|
| 21 |
+
readonly output: Output;
|
| 22 |
+
}
|
| 23 |
+
/** Infers the input type of a Standard. */
|
| 24 |
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
| 25 |
+
/** Infers the output type of a Standard. */
|
| 26 |
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
| 27 |
+
}
|
| 28 |
+
/** The Standard Schema interface. */
|
| 29 |
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
| 30 |
+
/** The Standard Schema properties. */
|
| 31 |
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
| 32 |
+
}
|
| 33 |
+
export declare namespace StandardSchemaV1 {
|
| 34 |
+
/** The Standard Schema properties interface. */
|
| 35 |
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
| 36 |
+
/** Validates unknown input values. */
|
| 37 |
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
| 38 |
+
}
|
| 39 |
+
/** The result interface of the validate function. */
|
| 40 |
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
| 41 |
+
/** The result interface if validation succeeds. */
|
| 42 |
+
interface SuccessResult<Output> {
|
| 43 |
+
/** The typed output value. */
|
| 44 |
+
readonly value: Output;
|
| 45 |
+
/** The absence of issues indicates success. */
|
| 46 |
+
readonly issues?: undefined;
|
| 47 |
+
}
|
| 48 |
+
interface Options {
|
| 49 |
+
/** Implicit support for additional vendor-specific parameters, if needed. */
|
| 50 |
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
| 51 |
+
}
|
| 52 |
+
/** The result interface if validation fails. */
|
| 53 |
+
interface FailureResult {
|
| 54 |
+
/** The issues of failed validation. */
|
| 55 |
+
readonly issues: ReadonlyArray<Issue>;
|
| 56 |
+
}
|
| 57 |
+
/** The issue interface of the failure output. */
|
| 58 |
+
interface Issue {
|
| 59 |
+
/** The error message of the issue. */
|
| 60 |
+
readonly message: string;
|
| 61 |
+
/** The path of the issue, if any. */
|
| 62 |
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
| 63 |
+
}
|
| 64 |
+
/** The path segment interface of the issue. */
|
| 65 |
+
interface PathSegment {
|
| 66 |
+
/** The key representing a path segment. */
|
| 67 |
+
readonly key: PropertyKey;
|
| 68 |
+
}
|
| 69 |
+
/** The Standard types interface. */
|
| 70 |
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {
|
| 71 |
+
}
|
| 72 |
+
/** Infers the input type of a Standard. */
|
| 73 |
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
| 74 |
+
/** Infers the output type of a Standard. */
|
| 75 |
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
| 76 |
+
}
|
| 77 |
+
/** The Standard JSON Schema interface. */
|
| 78 |
+
export interface StandardJSONSchemaV1<Input = unknown, Output = Input> {
|
| 79 |
+
/** The Standard JSON Schema properties. */
|
| 80 |
+
readonly "~standard": StandardJSONSchemaV1.Props<Input, Output>;
|
| 81 |
+
}
|
| 82 |
+
export declare namespace StandardJSONSchemaV1 {
|
| 83 |
+
/** The Standard JSON Schema properties interface. */
|
| 84 |
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
| 85 |
+
/** Methods for generating the input/output JSON Schema. */
|
| 86 |
+
readonly jsonSchema: Converter;
|
| 87 |
+
}
|
| 88 |
+
/** The Standard JSON Schema converter interface. */
|
| 89 |
+
interface Converter {
|
| 90 |
+
/** Converts the input type to JSON Schema. May throw if conversion is not supported. */
|
| 91 |
+
readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
|
| 92 |
+
/** Converts the output type to JSON Schema. May throw if conversion is not supported. */
|
| 93 |
+
readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
|
| 94 |
+
}
|
| 95 |
+
/** The target version of the generated JSON Schema.
|
| 96 |
+
*
|
| 97 |
+
* It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use.
|
| 98 |
+
*
|
| 99 |
+
* The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`.
|
| 100 |
+
*
|
| 101 |
+
* All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.
|
| 102 |
+
*/
|
| 103 |
+
type Target = "draft-2020-12" | "draft-07" | "openapi-3.0" | ({} & string);
|
| 104 |
+
/** The options for the input/output methods. */
|
| 105 |
+
interface Options {
|
| 106 |
+
/** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */
|
| 107 |
+
readonly target: Target;
|
| 108 |
+
/** Implicit support for additional vendor-specific parameters, if needed. */
|
| 109 |
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
| 110 |
+
}
|
| 111 |
+
/** The Standard types interface. */
|
| 112 |
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {
|
| 113 |
+
}
|
| 114 |
+
/** Infers the input type of a Standard. */
|
| 115 |
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
| 116 |
+
/** Infers the output type of a Standard. */
|
| 117 |
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
| 118 |
+
}
|
| 119 |
+
export interface StandardSchemaWithJSONProps<Input = unknown, Output = Input> extends StandardSchemaV1.Props<Input, Output>, StandardJSONSchemaV1.Props<Input, Output> {
|
| 120 |
+
}
|
| 121 |
+
/**
|
| 122 |
+
* An interface that combines StandardJSONSchema and StandardSchema.
|
| 123 |
+
*/
|
| 124 |
+
export interface StandardSchemaWithJSON<Input = unknown, Output = Input> {
|
| 125 |
+
"~standard": StandardSchemaWithJSONProps<Input, Output>;
|
| 126 |
+
}
|
node_modules/zod/v4/core/standard-schema.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export {};
|
node_modules/zod/v4/core/to-json-schema.cjs
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.createStandardJSONSchemaMethod = exports.createToJSONSchemaMethod = void 0;
|
| 4 |
+
exports.initializeContext = initializeContext;
|
| 5 |
+
exports.process = process;
|
| 6 |
+
exports.extractDefs = extractDefs;
|
| 7 |
+
exports.finalize = finalize;
|
| 8 |
+
const registries_js_1 = require("./registries.cjs");
|
| 9 |
+
// function initializeContext<T extends schemas.$ZodType>(inputs: JSONSchemaGeneratorParams<T>): ToJSONSchemaContext<T> {
|
| 10 |
+
// return {
|
| 11 |
+
// processor: inputs.processor,
|
| 12 |
+
// metadataRegistry: inputs.metadata ?? globalRegistry,
|
| 13 |
+
// target: inputs.target ?? "draft-2020-12",
|
| 14 |
+
// unrepresentable: inputs.unrepresentable ?? "throw",
|
| 15 |
+
// };
|
| 16 |
+
// }
|
| 17 |
+
function initializeContext(params) {
|
| 18 |
+
// Normalize target: convert old non-hyphenated versions to hyphenated versions
|
| 19 |
+
let target = params?.target ?? "draft-2020-12";
|
| 20 |
+
if (target === "draft-4")
|
| 21 |
+
target = "draft-04";
|
| 22 |
+
if (target === "draft-7")
|
| 23 |
+
target = "draft-07";
|
| 24 |
+
return {
|
| 25 |
+
processors: params.processors ?? {},
|
| 26 |
+
metadataRegistry: params?.metadata ?? registries_js_1.globalRegistry,
|
| 27 |
+
target,
|
| 28 |
+
unrepresentable: params?.unrepresentable ?? "throw",
|
| 29 |
+
override: params?.override ?? (() => { }),
|
| 30 |
+
io: params?.io ?? "output",
|
| 31 |
+
counter: 0,
|
| 32 |
+
seen: new Map(),
|
| 33 |
+
cycles: params?.cycles ?? "ref",
|
| 34 |
+
reused: params?.reused ?? "inline",
|
| 35 |
+
external: params?.external ?? undefined,
|
| 36 |
+
};
|
| 37 |
+
}
|
| 38 |
+
function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
| 39 |
+
var _a;
|
| 40 |
+
const def = schema._zod.def;
|
| 41 |
+
// check for schema in seens
|
| 42 |
+
const seen = ctx.seen.get(schema);
|
| 43 |
+
if (seen) {
|
| 44 |
+
seen.count++;
|
| 45 |
+
// check if cycle
|
| 46 |
+
const isCycle = _params.schemaPath.includes(schema);
|
| 47 |
+
if (isCycle) {
|
| 48 |
+
seen.cycle = _params.path;
|
| 49 |
+
}
|
| 50 |
+
return seen.schema;
|
| 51 |
+
}
|
| 52 |
+
// initialize
|
| 53 |
+
const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
|
| 54 |
+
ctx.seen.set(schema, result);
|
| 55 |
+
// custom method overrides default behavior
|
| 56 |
+
const overrideSchema = schema._zod.toJSONSchema?.();
|
| 57 |
+
if (overrideSchema) {
|
| 58 |
+
result.schema = overrideSchema;
|
| 59 |
+
}
|
| 60 |
+
else {
|
| 61 |
+
const params = {
|
| 62 |
+
..._params,
|
| 63 |
+
schemaPath: [..._params.schemaPath, schema],
|
| 64 |
+
path: _params.path,
|
| 65 |
+
};
|
| 66 |
+
if (schema._zod.processJSONSchema) {
|
| 67 |
+
schema._zod.processJSONSchema(ctx, result.schema, params);
|
| 68 |
+
}
|
| 69 |
+
else {
|
| 70 |
+
const _json = result.schema;
|
| 71 |
+
const processor = ctx.processors[def.type];
|
| 72 |
+
if (!processor) {
|
| 73 |
+
throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
| 74 |
+
}
|
| 75 |
+
processor(schema, ctx, _json, params);
|
| 76 |
+
}
|
| 77 |
+
const parent = schema._zod.parent;
|
| 78 |
+
if (parent) {
|
| 79 |
+
// Also set ref if processor didn't (for inheritance)
|
| 80 |
+
if (!result.ref)
|
| 81 |
+
result.ref = parent;
|
| 82 |
+
process(parent, ctx, params);
|
| 83 |
+
ctx.seen.get(parent).isParent = true;
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
// metadata
|
| 87 |
+
const meta = ctx.metadataRegistry.get(schema);
|
| 88 |
+
if (meta)
|
| 89 |
+
Object.assign(result.schema, meta);
|
| 90 |
+
if (ctx.io === "input" && isTransforming(schema)) {
|
| 91 |
+
// examples/defaults only apply to output type of pipe
|
| 92 |
+
delete result.schema.examples;
|
| 93 |
+
delete result.schema.default;
|
| 94 |
+
}
|
| 95 |
+
// set prefault as default
|
| 96 |
+
if (ctx.io === "input" && "_prefault" in result.schema)
|
| 97 |
+
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
| 98 |
+
delete result.schema._prefault;
|
| 99 |
+
// pulling fresh from ctx.seen in case it was overwritten
|
| 100 |
+
const _result = ctx.seen.get(schema);
|
| 101 |
+
return _result.schema;
|
| 102 |
+
}
|
| 103 |
+
function extractDefs(ctx, schema
|
| 104 |
+
// params: EmitParams
|
| 105 |
+
) {
|
| 106 |
+
// iterate over seen map;
|
| 107 |
+
const root = ctx.seen.get(schema);
|
| 108 |
+
if (!root)
|
| 109 |
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
| 110 |
+
// Track ids to detect duplicates across different schemas
|
| 111 |
+
const idToSchema = new Map();
|
| 112 |
+
for (const entry of ctx.seen.entries()) {
|
| 113 |
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
| 114 |
+
if (id) {
|
| 115 |
+
const existing = idToSchema.get(id);
|
| 116 |
+
if (existing && existing !== entry[0]) {
|
| 117 |
+
throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
| 118 |
+
}
|
| 119 |
+
idToSchema.set(id, entry[0]);
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
// returns a ref to the schema
|
| 123 |
+
// defId will be empty if the ref points to an external schema (or #)
|
| 124 |
+
const makeURI = (entry) => {
|
| 125 |
+
// comparing the seen objects because sometimes
|
| 126 |
+
// multiple schemas map to the same seen object.
|
| 127 |
+
// e.g. lazy
|
| 128 |
+
// external is configured
|
| 129 |
+
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
| 130 |
+
if (ctx.external) {
|
| 131 |
+
const externalId = ctx.external.registry.get(entry[0])?.id; // ?? "__shared";// `__schema${ctx.counter++}`;
|
| 132 |
+
// check if schema is in the external registry
|
| 133 |
+
const uriGenerator = ctx.external.uri ?? ((id) => id);
|
| 134 |
+
if (externalId) {
|
| 135 |
+
return { ref: uriGenerator(externalId) };
|
| 136 |
+
}
|
| 137 |
+
// otherwise, add to __shared
|
| 138 |
+
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
| 139 |
+
entry[1].defId = id; // set defId so it will be reused if needed
|
| 140 |
+
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
| 141 |
+
}
|
| 142 |
+
if (entry[1] === root) {
|
| 143 |
+
return { ref: "#" };
|
| 144 |
+
}
|
| 145 |
+
// self-contained schema
|
| 146 |
+
const uriPrefix = `#`;
|
| 147 |
+
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
| 148 |
+
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
| 149 |
+
return { defId, ref: defUriPrefix + defId };
|
| 150 |
+
};
|
| 151 |
+
// stored cached version in `def` property
|
| 152 |
+
// remove all properties, set $ref
|
| 153 |
+
const extractToDef = (entry) => {
|
| 154 |
+
// if the schema is already a reference, do not extract it
|
| 155 |
+
if (entry[1].schema.$ref) {
|
| 156 |
+
return;
|
| 157 |
+
}
|
| 158 |
+
const seen = entry[1];
|
| 159 |
+
const { ref, defId } = makeURI(entry);
|
| 160 |
+
seen.def = { ...seen.schema };
|
| 161 |
+
// defId won't be set if the schema is a reference to an external schema
|
| 162 |
+
// or if the schema is the root schema
|
| 163 |
+
if (defId)
|
| 164 |
+
seen.defId = defId;
|
| 165 |
+
// wipe away all properties except $ref
|
| 166 |
+
const schema = seen.schema;
|
| 167 |
+
for (const key in schema) {
|
| 168 |
+
delete schema[key];
|
| 169 |
+
}
|
| 170 |
+
schema.$ref = ref;
|
| 171 |
+
};
|
| 172 |
+
// throw on cycles
|
| 173 |
+
// break cycles
|
| 174 |
+
if (ctx.cycles === "throw") {
|
| 175 |
+
for (const entry of ctx.seen.entries()) {
|
| 176 |
+
const seen = entry[1];
|
| 177 |
+
if (seen.cycle) {
|
| 178 |
+
throw new Error("Cycle detected: " +
|
| 179 |
+
`#/${seen.cycle?.join("/")}/<root>` +
|
| 180 |
+
'\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.');
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
// extract schemas into $defs
|
| 185 |
+
for (const entry of ctx.seen.entries()) {
|
| 186 |
+
const seen = entry[1];
|
| 187 |
+
// convert root schema to # $ref
|
| 188 |
+
if (schema === entry[0]) {
|
| 189 |
+
extractToDef(entry); // this has special handling for the root schema
|
| 190 |
+
continue;
|
| 191 |
+
}
|
| 192 |
+
// extract schemas that are in the external registry
|
| 193 |
+
if (ctx.external) {
|
| 194 |
+
const ext = ctx.external.registry.get(entry[0])?.id;
|
| 195 |
+
if (schema !== entry[0] && ext) {
|
| 196 |
+
extractToDef(entry);
|
| 197 |
+
continue;
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
// extract schemas with `id` meta
|
| 201 |
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
| 202 |
+
if (id) {
|
| 203 |
+
extractToDef(entry);
|
| 204 |
+
continue;
|
| 205 |
+
}
|
| 206 |
+
// break cycles
|
| 207 |
+
if (seen.cycle) {
|
| 208 |
+
// any
|
| 209 |
+
extractToDef(entry);
|
| 210 |
+
continue;
|
| 211 |
+
}
|
| 212 |
+
// extract reused schemas
|
| 213 |
+
if (seen.count > 1) {
|
| 214 |
+
if (ctx.reused === "ref") {
|
| 215 |
+
extractToDef(entry);
|
| 216 |
+
// biome-ignore lint:
|
| 217 |
+
continue;
|
| 218 |
+
}
|
| 219 |
+
}
|
| 220 |
+
}
|
| 221 |
+
}
|
| 222 |
+
function finalize(ctx, schema) {
|
| 223 |
+
const root = ctx.seen.get(schema);
|
| 224 |
+
if (!root)
|
| 225 |
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
| 226 |
+
// flatten refs - inherit properties from parent schemas
|
| 227 |
+
const flattenRef = (zodSchema) => {
|
| 228 |
+
const seen = ctx.seen.get(zodSchema);
|
| 229 |
+
// already processed
|
| 230 |
+
if (seen.ref === null)
|
| 231 |
+
return;
|
| 232 |
+
const schema = seen.def ?? seen.schema;
|
| 233 |
+
const _cached = { ...schema };
|
| 234 |
+
const ref = seen.ref;
|
| 235 |
+
seen.ref = null; // prevent infinite recursion
|
| 236 |
+
if (ref) {
|
| 237 |
+
flattenRef(ref);
|
| 238 |
+
const refSeen = ctx.seen.get(ref);
|
| 239 |
+
const refSchema = refSeen.schema;
|
| 240 |
+
// merge referenced schema into current
|
| 241 |
+
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
| 242 |
+
// older drafts can't combine $ref with other properties
|
| 243 |
+
schema.allOf = schema.allOf ?? [];
|
| 244 |
+
schema.allOf.push(refSchema);
|
| 245 |
+
}
|
| 246 |
+
else {
|
| 247 |
+
Object.assign(schema, refSchema);
|
| 248 |
+
}
|
| 249 |
+
// restore child's own properties (child wins)
|
| 250 |
+
Object.assign(schema, _cached);
|
| 251 |
+
const isParentRef = zodSchema._zod.parent === ref;
|
| 252 |
+
// For parent chain, child is a refinement - remove parent-only properties
|
| 253 |
+
if (isParentRef) {
|
| 254 |
+
for (const key in schema) {
|
| 255 |
+
if (key === "$ref" || key === "allOf")
|
| 256 |
+
continue;
|
| 257 |
+
if (!(key in _cached)) {
|
| 258 |
+
delete schema[key];
|
| 259 |
+
}
|
| 260 |
+
}
|
| 261 |
+
}
|
| 262 |
+
// When ref was extracted to $defs, remove properties that match the definition
|
| 263 |
+
if (refSchema.$ref && refSeen.def) {
|
| 264 |
+
for (const key in schema) {
|
| 265 |
+
if (key === "$ref" || key === "allOf")
|
| 266 |
+
continue;
|
| 267 |
+
if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) {
|
| 268 |
+
delete schema[key];
|
| 269 |
+
}
|
| 270 |
+
}
|
| 271 |
+
}
|
| 272 |
+
}
|
| 273 |
+
// If parent was extracted (has $ref), propagate $ref to this schema
|
| 274 |
+
// This handles cases like: readonly().meta({id}).describe()
|
| 275 |
+
// where processor sets ref to innerType but parent should be referenced
|
| 276 |
+
const parent = zodSchema._zod.parent;
|
| 277 |
+
if (parent && parent !== ref) {
|
| 278 |
+
// Ensure parent is processed first so its def has inherited properties
|
| 279 |
+
flattenRef(parent);
|
| 280 |
+
const parentSeen = ctx.seen.get(parent);
|
| 281 |
+
if (parentSeen?.schema.$ref) {
|
| 282 |
+
schema.$ref = parentSeen.schema.$ref;
|
| 283 |
+
// De-duplicate with parent's definition
|
| 284 |
+
if (parentSeen.def) {
|
| 285 |
+
for (const key in schema) {
|
| 286 |
+
if (key === "$ref" || key === "allOf")
|
| 287 |
+
continue;
|
| 288 |
+
if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) {
|
| 289 |
+
delete schema[key];
|
| 290 |
+
}
|
| 291 |
+
}
|
| 292 |
+
}
|
| 293 |
+
}
|
| 294 |
+
}
|
| 295 |
+
// execute overrides
|
| 296 |
+
ctx.override({
|
| 297 |
+
zodSchema: zodSchema,
|
| 298 |
+
jsonSchema: schema,
|
| 299 |
+
path: seen.path ?? [],
|
| 300 |
+
});
|
| 301 |
+
};
|
| 302 |
+
for (const entry of [...ctx.seen.entries()].reverse()) {
|
| 303 |
+
flattenRef(entry[0]);
|
| 304 |
+
}
|
| 305 |
+
const result = {};
|
| 306 |
+
if (ctx.target === "draft-2020-12") {
|
| 307 |
+
result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
| 308 |
+
}
|
| 309 |
+
else if (ctx.target === "draft-07") {
|
| 310 |
+
result.$schema = "http://json-schema.org/draft-07/schema#";
|
| 311 |
+
}
|
| 312 |
+
else if (ctx.target === "draft-04") {
|
| 313 |
+
result.$schema = "http://json-schema.org/draft-04/schema#";
|
| 314 |
+
}
|
| 315 |
+
else if (ctx.target === "openapi-3.0") {
|
| 316 |
+
// OpenAPI 3.0 schema objects should not include a $schema property
|
| 317 |
+
}
|
| 318 |
+
else {
|
| 319 |
+
// Arbitrary string values are allowed but won't have a $schema property set
|
| 320 |
+
}
|
| 321 |
+
if (ctx.external?.uri) {
|
| 322 |
+
const id = ctx.external.registry.get(schema)?.id;
|
| 323 |
+
if (!id)
|
| 324 |
+
throw new Error("Schema is missing an `id` property");
|
| 325 |
+
result.$id = ctx.external.uri(id);
|
| 326 |
+
}
|
| 327 |
+
Object.assign(result, root.def ?? root.schema);
|
| 328 |
+
// The `id` in `.meta()` is a Zod-specific registration tag used to extract
|
| 329 |
+
// schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
|
| 330 |
+
// from the output body where it would otherwise leak. The id is preserved
|
| 331 |
+
// implicitly via the $defs key (and via $ref paths).
|
| 332 |
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
| 333 |
+
if (rootMetaId !== undefined && result.id === rootMetaId)
|
| 334 |
+
delete result.id;
|
| 335 |
+
// build defs object
|
| 336 |
+
const defs = ctx.external?.defs ?? {};
|
| 337 |
+
for (const entry of ctx.seen.entries()) {
|
| 338 |
+
const seen = entry[1];
|
| 339 |
+
if (seen.def && seen.defId) {
|
| 340 |
+
if (seen.def.id === seen.defId)
|
| 341 |
+
delete seen.def.id;
|
| 342 |
+
defs[seen.defId] = seen.def;
|
| 343 |
+
}
|
| 344 |
+
}
|
| 345 |
+
// set definitions in result
|
| 346 |
+
if (ctx.external) {
|
| 347 |
+
}
|
| 348 |
+
else {
|
| 349 |
+
if (Object.keys(defs).length > 0) {
|
| 350 |
+
if (ctx.target === "draft-2020-12") {
|
| 351 |
+
result.$defs = defs;
|
| 352 |
+
}
|
| 353 |
+
else {
|
| 354 |
+
result.definitions = defs;
|
| 355 |
+
}
|
| 356 |
+
}
|
| 357 |
+
}
|
| 358 |
+
try {
|
| 359 |
+
// this "finalizes" this schema and ensures all cycles are removed
|
| 360 |
+
// each call to finalize() is functionally independent
|
| 361 |
+
// though the seen map is shared
|
| 362 |
+
const finalized = JSON.parse(JSON.stringify(result));
|
| 363 |
+
Object.defineProperty(finalized, "~standard", {
|
| 364 |
+
value: {
|
| 365 |
+
...schema["~standard"],
|
| 366 |
+
jsonSchema: {
|
| 367 |
+
input: (0, exports.createStandardJSONSchemaMethod)(schema, "input", ctx.processors),
|
| 368 |
+
output: (0, exports.createStandardJSONSchemaMethod)(schema, "output", ctx.processors),
|
| 369 |
+
},
|
| 370 |
+
},
|
| 371 |
+
enumerable: false,
|
| 372 |
+
writable: false,
|
| 373 |
+
});
|
| 374 |
+
return finalized;
|
| 375 |
+
}
|
| 376 |
+
catch (_err) {
|
| 377 |
+
throw new Error("Error converting schema to JSON.");
|
| 378 |
+
}
|
| 379 |
+
}
|
| 380 |
+
function isTransforming(_schema, _ctx) {
|
| 381 |
+
const ctx = _ctx ?? { seen: new Set() };
|
| 382 |
+
if (ctx.seen.has(_schema))
|
| 383 |
+
return false;
|
| 384 |
+
ctx.seen.add(_schema);
|
| 385 |
+
const def = _schema._zod.def;
|
| 386 |
+
if (def.type === "transform")
|
| 387 |
+
return true;
|
| 388 |
+
if (def.type === "array")
|
| 389 |
+
return isTransforming(def.element, ctx);
|
| 390 |
+
if (def.type === "set")
|
| 391 |
+
return isTransforming(def.valueType, ctx);
|
| 392 |
+
if (def.type === "lazy")
|
| 393 |
+
return isTransforming(def.getter(), ctx);
|
| 394 |
+
if (def.type === "promise" ||
|
| 395 |
+
def.type === "optional" ||
|
| 396 |
+
def.type === "nonoptional" ||
|
| 397 |
+
def.type === "nullable" ||
|
| 398 |
+
def.type === "readonly" ||
|
| 399 |
+
def.type === "default" ||
|
| 400 |
+
def.type === "prefault") {
|
| 401 |
+
return isTransforming(def.innerType, ctx);
|
| 402 |
+
}
|
| 403 |
+
if (def.type === "intersection") {
|
| 404 |
+
return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
| 405 |
+
}
|
| 406 |
+
if (def.type === "record" || def.type === "map") {
|
| 407 |
+
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
| 408 |
+
}
|
| 409 |
+
if (def.type === "pipe") {
|
| 410 |
+
if (_schema._zod.traits.has("$ZodCodec"))
|
| 411 |
+
return true;
|
| 412 |
+
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
| 413 |
+
}
|
| 414 |
+
if (def.type === "object") {
|
| 415 |
+
for (const key in def.shape) {
|
| 416 |
+
if (isTransforming(def.shape[key], ctx))
|
| 417 |
+
return true;
|
| 418 |
+
}
|
| 419 |
+
return false;
|
| 420 |
+
}
|
| 421 |
+
if (def.type === "union") {
|
| 422 |
+
for (const option of def.options) {
|
| 423 |
+
if (isTransforming(option, ctx))
|
| 424 |
+
return true;
|
| 425 |
+
}
|
| 426 |
+
return false;
|
| 427 |
+
}
|
| 428 |
+
if (def.type === "tuple") {
|
| 429 |
+
for (const item of def.items) {
|
| 430 |
+
if (isTransforming(item, ctx))
|
| 431 |
+
return true;
|
| 432 |
+
}
|
| 433 |
+
if (def.rest && isTransforming(def.rest, ctx))
|
| 434 |
+
return true;
|
| 435 |
+
return false;
|
| 436 |
+
}
|
| 437 |
+
return false;
|
| 438 |
+
}
|
| 439 |
+
/**
|
| 440 |
+
* Creates a toJSONSchema method for a schema instance.
|
| 441 |
+
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
| 442 |
+
*/
|
| 443 |
+
const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
| 444 |
+
const ctx = initializeContext({ ...params, processors });
|
| 445 |
+
process(schema, ctx);
|
| 446 |
+
extractDefs(ctx, schema);
|
| 447 |
+
return finalize(ctx, schema);
|
| 448 |
+
};
|
| 449 |
+
exports.createToJSONSchemaMethod = createToJSONSchemaMethod;
|
| 450 |
+
const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
| 451 |
+
const { libraryOptions, target } = params ?? {};
|
| 452 |
+
const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors });
|
| 453 |
+
process(schema, ctx);
|
| 454 |
+
extractDefs(ctx, schema);
|
| 455 |
+
return finalize(ctx, schema);
|
| 456 |
+
};
|
| 457 |
+
exports.createStandardJSONSchemaMethod = createStandardJSONSchemaMethod;
|
node_modules/zod/v4/core/to-json-schema.d.cts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as core from "../core/index.cjs";
|
| 2 |
+
import type * as JSONSchema from "./json-schema.cjs";
|
| 3 |
+
import { type $ZodRegistry } from "./registries.cjs";
|
| 4 |
+
import type * as schemas from "./schemas.cjs";
|
| 5 |
+
import type { StandardJSONSchemaV1, StandardSchemaWithJSONProps } from "./standard-schema.cjs";
|
| 6 |
+
export type Processor<T extends schemas.$ZodType = schemas.$ZodType> = (schema: T, ctx: ToJSONSchemaContext, json: JSONSchema.BaseSchema, params: ProcessParams) => void;
|
| 7 |
+
export interface JSONSchemaGeneratorParams {
|
| 8 |
+
processors: Record<string, Processor>;
|
| 9 |
+
/** A registry used to look up metadata for each schema. Any schema with an `id` property will be extracted as a $def.
|
| 10 |
+
* @default globalRegistry */
|
| 11 |
+
metadata?: $ZodRegistry<Record<string, any>>;
|
| 12 |
+
/** The JSON Schema version to target.
|
| 13 |
+
* - `"draft-2020-12"` — Default. JSON Schema Draft 2020-12
|
| 14 |
+
* - `"draft-07"` — JSON Schema Draft 7
|
| 15 |
+
* - `"draft-04"` — JSON Schema Draft 4
|
| 16 |
+
* - `"openapi-3.0"` — OpenAPI 3.0 Schema Object */
|
| 17 |
+
target?: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | ({} & string) | undefined;
|
| 18 |
+
/** How to handle unrepresentable types.
|
| 19 |
+
* - `"throw"` — Default. Unrepresentable types throw an error
|
| 20 |
+
* - `"any"` — Unrepresentable types become `{}` */
|
| 21 |
+
unrepresentable?: "throw" | "any";
|
| 22 |
+
/** Arbitrary custom logic that can be used to modify the generated JSON Schema. */
|
| 23 |
+
override?: (ctx: {
|
| 24 |
+
zodSchema: schemas.$ZodTypes;
|
| 25 |
+
jsonSchema: JSONSchema.BaseSchema;
|
| 26 |
+
path: (string | number)[];
|
| 27 |
+
}) => void;
|
| 28 |
+
/** Whether to extract the `"input"` or `"output"` type. Relevant to transforms, defaults, coerced primitives, etc.
|
| 29 |
+
* - `"output"` — Default. Convert the output schema.
|
| 30 |
+
* - `"input"` — Convert the input schema. */
|
| 31 |
+
io?: "input" | "output";
|
| 32 |
+
cycles?: "ref" | "throw";
|
| 33 |
+
reused?: "ref" | "inline";
|
| 34 |
+
external?: {
|
| 35 |
+
registry: $ZodRegistry<{
|
| 36 |
+
id?: string | undefined;
|
| 37 |
+
}>;
|
| 38 |
+
uri?: ((id: string) => string) | undefined;
|
| 39 |
+
defs: Record<string, JSONSchema.BaseSchema>;
|
| 40 |
+
} | undefined;
|
| 41 |
+
}
|
| 42 |
+
/**
|
| 43 |
+
* Parameters for the toJSONSchema function.
|
| 44 |
+
*/
|
| 45 |
+
export type ToJSONSchemaParams = Omit<JSONSchemaGeneratorParams, "processors" | "external">;
|
| 46 |
+
/**
|
| 47 |
+
* Parameters for the toJSONSchema function when passing a registry.
|
| 48 |
+
*/
|
| 49 |
+
export interface RegistryToJSONSchemaParams extends ToJSONSchemaParams {
|
| 50 |
+
uri?: (id: string) => string;
|
| 51 |
+
}
|
| 52 |
+
export interface ProcessParams {
|
| 53 |
+
schemaPath: schemas.$ZodType[];
|
| 54 |
+
path: (string | number)[];
|
| 55 |
+
}
|
| 56 |
+
export interface Seen {
|
| 57 |
+
/** JSON Schema result for this Zod schema */
|
| 58 |
+
schema: JSONSchema.BaseSchema;
|
| 59 |
+
/** A cached version of the schema that doesn't get overwritten during ref resolution */
|
| 60 |
+
def?: JSONSchema.BaseSchema;
|
| 61 |
+
defId?: string | undefined;
|
| 62 |
+
/** Number of times this schema was encountered during traversal */
|
| 63 |
+
count: number;
|
| 64 |
+
/** Cycle path */
|
| 65 |
+
cycle?: (string | number)[] | undefined;
|
| 66 |
+
isParent?: boolean | undefined;
|
| 67 |
+
/** Schema to inherit JSON Schema properties from (set by processor for wrappers) */
|
| 68 |
+
ref?: schemas.$ZodType | null;
|
| 69 |
+
/** JSON Schema property path for this schema */
|
| 70 |
+
path?: (string | number)[] | undefined;
|
| 71 |
+
}
|
| 72 |
+
export interface ToJSONSchemaContext {
|
| 73 |
+
processors: Record<string, Processor>;
|
| 74 |
+
metadataRegistry: $ZodRegistry<Record<string, any>>;
|
| 75 |
+
target: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | ({} & string);
|
| 76 |
+
unrepresentable: "throw" | "any";
|
| 77 |
+
override: (ctx: {
|
| 78 |
+
zodSchema: schemas.$ZodType;
|
| 79 |
+
jsonSchema: JSONSchema.BaseSchema;
|
| 80 |
+
path: (string | number)[];
|
| 81 |
+
}) => void;
|
| 82 |
+
io: "input" | "output";
|
| 83 |
+
counter: number;
|
| 84 |
+
seen: Map<schemas.$ZodType, Seen>;
|
| 85 |
+
cycles: "ref" | "throw";
|
| 86 |
+
reused: "ref" | "inline";
|
| 87 |
+
external?: {
|
| 88 |
+
registry: $ZodRegistry<{
|
| 89 |
+
id?: string | undefined;
|
| 90 |
+
}>;
|
| 91 |
+
uri?: ((id: string) => string) | undefined;
|
| 92 |
+
defs: Record<string, JSONSchema.BaseSchema>;
|
| 93 |
+
} | undefined;
|
| 94 |
+
}
|
| 95 |
+
export declare function initializeContext(params: JSONSchemaGeneratorParams): ToJSONSchemaContext;
|
| 96 |
+
export declare function process<T extends schemas.$ZodType>(schema: T, ctx: ToJSONSchemaContext, _params?: ProcessParams): JSONSchema.BaseSchema;
|
| 97 |
+
export declare function extractDefs<T extends schemas.$ZodType>(ctx: ToJSONSchemaContext, schema: T): void;
|
| 98 |
+
export declare function finalize<T extends schemas.$ZodType>(ctx: ToJSONSchemaContext, schema: T): ZodStandardJSONSchemaPayload<T>;
|
| 99 |
+
export type ZodStandardSchemaWithJSON<T> = StandardSchemaWithJSONProps<core.input<T>, core.output<T>>;
|
| 100 |
+
export interface ZodStandardJSONSchemaPayload<T> extends JSONSchema.BaseSchema {
|
| 101 |
+
"~standard": ZodStandardSchemaWithJSON<T>;
|
| 102 |
+
}
|
| 103 |
+
/**
|
| 104 |
+
* Creates a toJSONSchema method for a schema instance.
|
| 105 |
+
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
| 106 |
+
*/
|
| 107 |
+
export declare const createToJSONSchemaMethod: <T extends schemas.$ZodType>(schema: T, processors?: Record<string, Processor>) => (params?: ToJSONSchemaParams) => ZodStandardJSONSchemaPayload<T>;
|
| 108 |
+
/**
|
| 109 |
+
* Creates a toJSONSchema method for a schema instance.
|
| 110 |
+
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
| 111 |
+
*/
|
| 112 |
+
type StandardJSONSchemaMethodParams = Parameters<StandardJSONSchemaV1["~standard"]["jsonSchema"]["input"]>[0];
|
| 113 |
+
export declare const createStandardJSONSchemaMethod: <T extends schemas.$ZodType>(schema: T, io: "input" | "output", processors?: Record<string, Processor>) => (params?: StandardJSONSchemaMethodParams) => JSONSchema.BaseSchema;
|
| 114 |
+
export {};
|
node_modules/zod/v4/core/to-json-schema.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as core from "../core/index.js";
|
| 2 |
+
import type * as JSONSchema from "./json-schema.js";
|
| 3 |
+
import { type $ZodRegistry } from "./registries.js";
|
| 4 |
+
import type * as schemas from "./schemas.js";
|
| 5 |
+
import type { StandardJSONSchemaV1, StandardSchemaWithJSONProps } from "./standard-schema.js";
|
| 6 |
+
export type Processor<T extends schemas.$ZodType = schemas.$ZodType> = (schema: T, ctx: ToJSONSchemaContext, json: JSONSchema.BaseSchema, params: ProcessParams) => void;
|
| 7 |
+
export interface JSONSchemaGeneratorParams {
|
| 8 |
+
processors: Record<string, Processor>;
|
| 9 |
+
/** A registry used to look up metadata for each schema. Any schema with an `id` property will be extracted as a $def.
|
| 10 |
+
* @default globalRegistry */
|
| 11 |
+
metadata?: $ZodRegistry<Record<string, any>>;
|
| 12 |
+
/** The JSON Schema version to target.
|
| 13 |
+
* - `"draft-2020-12"` — Default. JSON Schema Draft 2020-12
|
| 14 |
+
* - `"draft-07"` — JSON Schema Draft 7
|
| 15 |
+
* - `"draft-04"` — JSON Schema Draft 4
|
| 16 |
+
* - `"openapi-3.0"` — OpenAPI 3.0 Schema Object */
|
| 17 |
+
target?: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | ({} & string) | undefined;
|
| 18 |
+
/** How to handle unrepresentable types.
|
| 19 |
+
* - `"throw"` — Default. Unrepresentable types throw an error
|
| 20 |
+
* - `"any"` — Unrepresentable types become `{}` */
|
| 21 |
+
unrepresentable?: "throw" | "any";
|
| 22 |
+
/** Arbitrary custom logic that can be used to modify the generated JSON Schema. */
|
| 23 |
+
override?: (ctx: {
|
| 24 |
+
zodSchema: schemas.$ZodTypes;
|
| 25 |
+
jsonSchema: JSONSchema.BaseSchema;
|
| 26 |
+
path: (string | number)[];
|
| 27 |
+
}) => void;
|
| 28 |
+
/** Whether to extract the `"input"` or `"output"` type. Relevant to transforms, defaults, coerced primitives, etc.
|
| 29 |
+
* - `"output"` — Default. Convert the output schema.
|
| 30 |
+
* - `"input"` — Convert the input schema. */
|
| 31 |
+
io?: "input" | "output";
|
| 32 |
+
cycles?: "ref" | "throw";
|
| 33 |
+
reused?: "ref" | "inline";
|
| 34 |
+
external?: {
|
| 35 |
+
registry: $ZodRegistry<{
|
| 36 |
+
id?: string | undefined;
|
| 37 |
+
}>;
|
| 38 |
+
uri?: ((id: string) => string) | undefined;
|
| 39 |
+
defs: Record<string, JSONSchema.BaseSchema>;
|
| 40 |
+
} | undefined;
|
| 41 |
+
}
|
| 42 |
+
/**
|
| 43 |
+
* Parameters for the toJSONSchema function.
|
| 44 |
+
*/
|
| 45 |
+
export type ToJSONSchemaParams = Omit<JSONSchemaGeneratorParams, "processors" | "external">;
|
| 46 |
+
/**
|
| 47 |
+
* Parameters for the toJSONSchema function when passing a registry.
|
| 48 |
+
*/
|
| 49 |
+
export interface RegistryToJSONSchemaParams extends ToJSONSchemaParams {
|
| 50 |
+
uri?: (id: string) => string;
|
| 51 |
+
}
|
| 52 |
+
export interface ProcessParams {
|
| 53 |
+
schemaPath: schemas.$ZodType[];
|
| 54 |
+
path: (string | number)[];
|
| 55 |
+
}
|
| 56 |
+
export interface Seen {
|
| 57 |
+
/** JSON Schema result for this Zod schema */
|
| 58 |
+
schema: JSONSchema.BaseSchema;
|
| 59 |
+
/** A cached version of the schema that doesn't get overwritten during ref resolution */
|
| 60 |
+
def?: JSONSchema.BaseSchema;
|
| 61 |
+
defId?: string | undefined;
|
| 62 |
+
/** Number of times this schema was encountered during traversal */
|
| 63 |
+
count: number;
|
| 64 |
+
/** Cycle path */
|
| 65 |
+
cycle?: (string | number)[] | undefined;
|
| 66 |
+
isParent?: boolean | undefined;
|
| 67 |
+
/** Schema to inherit JSON Schema properties from (set by processor for wrappers) */
|
| 68 |
+
ref?: schemas.$ZodType | null;
|
| 69 |
+
/** JSON Schema property path for this schema */
|
| 70 |
+
path?: (string | number)[] | undefined;
|
| 71 |
+
}
|
| 72 |
+
export interface ToJSONSchemaContext {
|
| 73 |
+
processors: Record<string, Processor>;
|
| 74 |
+
metadataRegistry: $ZodRegistry<Record<string, any>>;
|
| 75 |
+
target: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | ({} & string);
|
| 76 |
+
unrepresentable: "throw" | "any";
|
| 77 |
+
override: (ctx: {
|
| 78 |
+
zodSchema: schemas.$ZodType;
|
| 79 |
+
jsonSchema: JSONSchema.BaseSchema;
|
| 80 |
+
path: (string | number)[];
|
| 81 |
+
}) => void;
|
| 82 |
+
io: "input" | "output";
|
| 83 |
+
counter: number;
|
| 84 |
+
seen: Map<schemas.$ZodType, Seen>;
|
| 85 |
+
cycles: "ref" | "throw";
|
| 86 |
+
reused: "ref" | "inline";
|
| 87 |
+
external?: {
|
| 88 |
+
registry: $ZodRegistry<{
|
| 89 |
+
id?: string | undefined;
|
| 90 |
+
}>;
|
| 91 |
+
uri?: ((id: string) => string) | undefined;
|
| 92 |
+
defs: Record<string, JSONSchema.BaseSchema>;
|
| 93 |
+
} | undefined;
|
| 94 |
+
}
|
| 95 |
+
export declare function initializeContext(params: JSONSchemaGeneratorParams): ToJSONSchemaContext;
|
| 96 |
+
export declare function process<T extends schemas.$ZodType>(schema: T, ctx: ToJSONSchemaContext, _params?: ProcessParams): JSONSchema.BaseSchema;
|
| 97 |
+
export declare function extractDefs<T extends schemas.$ZodType>(ctx: ToJSONSchemaContext, schema: T): void;
|
| 98 |
+
export declare function finalize<T extends schemas.$ZodType>(ctx: ToJSONSchemaContext, schema: T): ZodStandardJSONSchemaPayload<T>;
|
| 99 |
+
export type ZodStandardSchemaWithJSON<T> = StandardSchemaWithJSONProps<core.input<T>, core.output<T>>;
|
| 100 |
+
export interface ZodStandardJSONSchemaPayload<T> extends JSONSchema.BaseSchema {
|
| 101 |
+
"~standard": ZodStandardSchemaWithJSON<T>;
|
| 102 |
+
}
|
| 103 |
+
/**
|
| 104 |
+
* Creates a toJSONSchema method for a schema instance.
|
| 105 |
+
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
| 106 |
+
*/
|
| 107 |
+
export declare const createToJSONSchemaMethod: <T extends schemas.$ZodType>(schema: T, processors?: Record<string, Processor>) => (params?: ToJSONSchemaParams) => ZodStandardJSONSchemaPayload<T>;
|
| 108 |
+
/**
|
| 109 |
+
* Creates a toJSONSchema method for a schema instance.
|
| 110 |
+
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
| 111 |
+
*/
|
| 112 |
+
type StandardJSONSchemaMethodParams = Parameters<StandardJSONSchemaV1["~standard"]["jsonSchema"]["input"]>[0];
|
| 113 |
+
export declare const createStandardJSONSchemaMethod: <T extends schemas.$ZodType>(schema: T, io: "input" | "output", processors?: Record<string, Processor>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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { globalRegistry } from "./registries.js";
|
| 2 |
+
// function initializeContext<T extends schemas.$ZodType>(inputs: JSONSchemaGeneratorParams<T>): ToJSONSchemaContext<T> {
|
| 3 |
+
// return {
|
| 4 |
+
// processor: inputs.processor,
|
| 5 |
+
// metadataRegistry: inputs.metadata ?? globalRegistry,
|
| 6 |
+
// target: inputs.target ?? "draft-2020-12",
|
| 7 |
+
// unrepresentable: inputs.unrepresentable ?? "throw",
|
| 8 |
+
// };
|
| 9 |
+
// }
|
| 10 |
+
export function initializeContext(params) {
|
| 11 |
+
// Normalize target: convert old non-hyphenated versions to hyphenated versions
|
| 12 |
+
let target = params?.target ?? "draft-2020-12";
|
| 13 |
+
if (target === "draft-4")
|
| 14 |
+
target = "draft-04";
|
| 15 |
+
if (target === "draft-7")
|
| 16 |
+
target = "draft-07";
|
| 17 |
+
return {
|
| 18 |
+
processors: params.processors ?? {},
|
| 19 |
+
metadataRegistry: params?.metadata ?? globalRegistry,
|
| 20 |
+
target,
|
| 21 |
+
unrepresentable: params?.unrepresentable ?? "throw",
|
| 22 |
+
override: params?.override ?? (() => { }),
|
| 23 |
+
io: params?.io ?? "output",
|
| 24 |
+
counter: 0,
|
| 25 |
+
seen: new Map(),
|
| 26 |
+
cycles: params?.cycles ?? "ref",
|
| 27 |
+
reused: params?.reused ?? "inline",
|
| 28 |
+
external: params?.external ?? undefined,
|
| 29 |
+
};
|
| 30 |
+
}
|
| 31 |
+
export function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
| 32 |
+
var _a;
|
| 33 |
+
const def = schema._zod.def;
|
| 34 |
+
// check for schema in seens
|
| 35 |
+
const seen = ctx.seen.get(schema);
|
| 36 |
+
if (seen) {
|
| 37 |
+
seen.count++;
|
| 38 |
+
// check if cycle
|
| 39 |
+
const isCycle = _params.schemaPath.includes(schema);
|
| 40 |
+
if (isCycle) {
|
| 41 |
+
seen.cycle = _params.path;
|
| 42 |
+
}
|
| 43 |
+
return seen.schema;
|
| 44 |
+
}
|
| 45 |
+
// initialize
|
| 46 |
+
const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
|
| 47 |
+
ctx.seen.set(schema, result);
|
| 48 |
+
// custom method overrides default behavior
|
| 49 |
+
const overrideSchema = schema._zod.toJSONSchema?.();
|
| 50 |
+
if (overrideSchema) {
|
| 51 |
+
result.schema = overrideSchema;
|
| 52 |
+
}
|
| 53 |
+
else {
|
| 54 |
+
const params = {
|
| 55 |
+
..._params,
|
| 56 |
+
schemaPath: [..._params.schemaPath, schema],
|
| 57 |
+
path: _params.path,
|
| 58 |
+
};
|
| 59 |
+
if (schema._zod.processJSONSchema) {
|
| 60 |
+
schema._zod.processJSONSchema(ctx, result.schema, params);
|
| 61 |
+
}
|
| 62 |
+
else {
|
| 63 |
+
const _json = result.schema;
|
| 64 |
+
const processor = ctx.processors[def.type];
|
| 65 |
+
if (!processor) {
|
| 66 |
+
throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
| 67 |
+
}
|
| 68 |
+
processor(schema, ctx, _json, params);
|
| 69 |
+
}
|
| 70 |
+
const parent = schema._zod.parent;
|
| 71 |
+
if (parent) {
|
| 72 |
+
// Also set ref if processor didn't (for inheritance)
|
| 73 |
+
if (!result.ref)
|
| 74 |
+
result.ref = parent;
|
| 75 |
+
process(parent, ctx, params);
|
| 76 |
+
ctx.seen.get(parent).isParent = true;
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
// metadata
|
| 80 |
+
const meta = ctx.metadataRegistry.get(schema);
|
| 81 |
+
if (meta)
|
| 82 |
+
Object.assign(result.schema, meta);
|
| 83 |
+
if (ctx.io === "input" && isTransforming(schema)) {
|
| 84 |
+
// examples/defaults only apply to output type of pipe
|
| 85 |
+
delete result.schema.examples;
|
| 86 |
+
delete result.schema.default;
|
| 87 |
+
}
|
| 88 |
+
// set prefault as default
|
| 89 |
+
if (ctx.io === "input" && "_prefault" in result.schema)
|
| 90 |
+
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
| 91 |
+
delete result.schema._prefault;
|
| 92 |
+
// pulling fresh from ctx.seen in case it was overwritten
|
| 93 |
+
const _result = ctx.seen.get(schema);
|
| 94 |
+
return _result.schema;
|
| 95 |
+
}
|
| 96 |
+
export function extractDefs(ctx, schema
|
| 97 |
+
// params: EmitParams
|
| 98 |
+
) {
|
| 99 |
+
// iterate over seen map;
|
| 100 |
+
const root = ctx.seen.get(schema);
|
| 101 |
+
if (!root)
|
| 102 |
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
| 103 |
+
// Track ids to detect duplicates across different schemas
|
| 104 |
+
const idToSchema = new Map();
|
| 105 |
+
for (const entry of ctx.seen.entries()) {
|
| 106 |
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
| 107 |
+
if (id) {
|
| 108 |
+
const existing = idToSchema.get(id);
|
| 109 |
+
if (existing && existing !== entry[0]) {
|
| 110 |
+
throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
| 111 |
+
}
|
| 112 |
+
idToSchema.set(id, entry[0]);
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
// returns a ref to the schema
|
| 116 |
+
// defId will be empty if the ref points to an external schema (or #)
|
| 117 |
+
const makeURI = (entry) => {
|
| 118 |
+
// comparing the seen objects because sometimes
|
| 119 |
+
// multiple schemas map to the same seen object.
|
| 120 |
+
// e.g. lazy
|
| 121 |
+
// external is configured
|
| 122 |
+
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
| 123 |
+
if (ctx.external) {
|
| 124 |
+
const externalId = ctx.external.registry.get(entry[0])?.id; // ?? "__shared";// `__schema${ctx.counter++}`;
|
| 125 |
+
// check if schema is in the external registry
|
| 126 |
+
const uriGenerator = ctx.external.uri ?? ((id) => id);
|
| 127 |
+
if (externalId) {
|
| 128 |
+
return { ref: uriGenerator(externalId) };
|
| 129 |
+
}
|
| 130 |
+
// otherwise, add to __shared
|
| 131 |
+
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
| 132 |
+
entry[1].defId = id; // set defId so it will be reused if needed
|
| 133 |
+
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
| 134 |
+
}
|
| 135 |
+
if (entry[1] === root) {
|
| 136 |
+
return { ref: "#" };
|
| 137 |
+
}
|
| 138 |
+
// self-contained schema
|
| 139 |
+
const uriPrefix = `#`;
|
| 140 |
+
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
| 141 |
+
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
| 142 |
+
return { defId, ref: defUriPrefix + defId };
|
| 143 |
+
};
|
| 144 |
+
// stored cached version in `def` property
|
| 145 |
+
// remove all properties, set $ref
|
| 146 |
+
const extractToDef = (entry) => {
|
| 147 |
+
// if the schema is already a reference, do not extract it
|
| 148 |
+
if (entry[1].schema.$ref) {
|
| 149 |
+
return;
|
| 150 |
+
}
|
| 151 |
+
const seen = entry[1];
|
| 152 |
+
const { ref, defId } = makeURI(entry);
|
| 153 |
+
seen.def = { ...seen.schema };
|
| 154 |
+
// defId won't be set if the schema is a reference to an external schema
|
| 155 |
+
// or if the schema is the root schema
|
| 156 |
+
if (defId)
|
| 157 |
+
seen.defId = defId;
|
| 158 |
+
// wipe away all properties except $ref
|
| 159 |
+
const schema = seen.schema;
|
| 160 |
+
for (const key in schema) {
|
| 161 |
+
delete schema[key];
|
| 162 |
+
}
|
| 163 |
+
schema.$ref = ref;
|
| 164 |
+
};
|
| 165 |
+
// throw on cycles
|
| 166 |
+
// break cycles
|
| 167 |
+
if (ctx.cycles === "throw") {
|
| 168 |
+
for (const entry of ctx.seen.entries()) {
|
| 169 |
+
const seen = entry[1];
|
| 170 |
+
if (seen.cycle) {
|
| 171 |
+
throw new Error("Cycle detected: " +
|
| 172 |
+
`#/${seen.cycle?.join("/")}/<root>` +
|
| 173 |
+
'\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.');
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
// extract schemas into $defs
|
| 178 |
+
for (const entry of ctx.seen.entries()) {
|
| 179 |
+
const seen = entry[1];
|
| 180 |
+
// convert root schema to # $ref
|
| 181 |
+
if (schema === entry[0]) {
|
| 182 |
+
extractToDef(entry); // this has special handling for the root schema
|
| 183 |
+
continue;
|
| 184 |
+
}
|
| 185 |
+
// extract schemas that are in the external registry
|
| 186 |
+
if (ctx.external) {
|
| 187 |
+
const ext = ctx.external.registry.get(entry[0])?.id;
|
| 188 |
+
if (schema !== entry[0] && ext) {
|
| 189 |
+
extractToDef(entry);
|
| 190 |
+
continue;
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
// extract schemas with `id` meta
|
| 194 |
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
| 195 |
+
if (id) {
|
| 196 |
+
extractToDef(entry);
|
| 197 |
+
continue;
|
| 198 |
+
}
|
| 199 |
+
// break cycles
|
| 200 |
+
if (seen.cycle) {
|
| 201 |
+
// any
|
| 202 |
+
extractToDef(entry);
|
| 203 |
+
continue;
|
| 204 |
+
}
|
| 205 |
+
// extract reused schemas
|
| 206 |
+
if (seen.count > 1) {
|
| 207 |
+
if (ctx.reused === "ref") {
|
| 208 |
+
extractToDef(entry);
|
| 209 |
+
// biome-ignore lint:
|
| 210 |
+
continue;
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
}
|
| 215 |
+
export function finalize(ctx, schema) {
|
| 216 |
+
const root = ctx.seen.get(schema);
|
| 217 |
+
if (!root)
|
| 218 |
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
| 219 |
+
// flatten refs - inherit properties from parent schemas
|
| 220 |
+
const flattenRef = (zodSchema) => {
|
| 221 |
+
const seen = ctx.seen.get(zodSchema);
|
| 222 |
+
// already processed
|
| 223 |
+
if (seen.ref === null)
|
| 224 |
+
return;
|
| 225 |
+
const schema = seen.def ?? seen.schema;
|
| 226 |
+
const _cached = { ...schema };
|
| 227 |
+
const ref = seen.ref;
|
| 228 |
+
seen.ref = null; // prevent infinite recursion
|
| 229 |
+
if (ref) {
|
| 230 |
+
flattenRef(ref);
|
| 231 |
+
const refSeen = ctx.seen.get(ref);
|
| 232 |
+
const refSchema = refSeen.schema;
|
| 233 |
+
// merge referenced schema into current
|
| 234 |
+
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
| 235 |
+
// older drafts can't combine $ref with other properties
|
| 236 |
+
schema.allOf = schema.allOf ?? [];
|
| 237 |
+
schema.allOf.push(refSchema);
|
| 238 |
+
}
|
| 239 |
+
else {
|
| 240 |
+
Object.assign(schema, refSchema);
|
| 241 |
+
}
|
| 242 |
+
// restore child's own properties (child wins)
|
| 243 |
+
Object.assign(schema, _cached);
|
| 244 |
+
const isParentRef = zodSchema._zod.parent === ref;
|
| 245 |
+
// For parent chain, child is a refinement - remove parent-only properties
|
| 246 |
+
if (isParentRef) {
|
| 247 |
+
for (const key in schema) {
|
| 248 |
+
if (key === "$ref" || key === "allOf")
|
| 249 |
+
continue;
|
| 250 |
+
if (!(key in _cached)) {
|
| 251 |
+
delete schema[key];
|
| 252 |
+
}
|
| 253 |
+
}
|
| 254 |
+
}
|
| 255 |
+
// When ref was extracted to $defs, remove properties that match the definition
|
| 256 |
+
if (refSchema.$ref && refSeen.def) {
|
| 257 |
+
for (const key in schema) {
|
| 258 |
+
if (key === "$ref" || key === "allOf")
|
| 259 |
+
continue;
|
| 260 |
+
if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) {
|
| 261 |
+
delete schema[key];
|
| 262 |
+
}
|
| 263 |
+
}
|
| 264 |
+
}
|
| 265 |
+
}
|
| 266 |
+
// If parent was extracted (has $ref), propagate $ref to this schema
|
| 267 |
+
// This handles cases like: readonly().meta({id}).describe()
|
| 268 |
+
// where processor sets ref to innerType but parent should be referenced
|
| 269 |
+
const parent = zodSchema._zod.parent;
|
| 270 |
+
if (parent && parent !== ref) {
|
| 271 |
+
// Ensure parent is processed first so its def has inherited properties
|
| 272 |
+
flattenRef(parent);
|
| 273 |
+
const parentSeen = ctx.seen.get(parent);
|
| 274 |
+
if (parentSeen?.schema.$ref) {
|
| 275 |
+
schema.$ref = parentSeen.schema.$ref;
|
| 276 |
+
// De-duplicate with parent's definition
|
| 277 |
+
if (parentSeen.def) {
|
| 278 |
+
for (const key in schema) {
|
| 279 |
+
if (key === "$ref" || key === "allOf")
|
| 280 |
+
continue;
|
| 281 |
+
if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) {
|
| 282 |
+
delete schema[key];
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
}
|
| 286 |
+
}
|
| 287 |
+
}
|
| 288 |
+
// execute overrides
|
| 289 |
+
ctx.override({
|
| 290 |
+
zodSchema: zodSchema,
|
| 291 |
+
jsonSchema: schema,
|
| 292 |
+
path: seen.path ?? [],
|
| 293 |
+
});
|
| 294 |
+
};
|
| 295 |
+
for (const entry of [...ctx.seen.entries()].reverse()) {
|
| 296 |
+
flattenRef(entry[0]);
|
| 297 |
+
}
|
| 298 |
+
const result = {};
|
| 299 |
+
if (ctx.target === "draft-2020-12") {
|
| 300 |
+
result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
| 301 |
+
}
|
| 302 |
+
else if (ctx.target === "draft-07") {
|
| 303 |
+
result.$schema = "http://json-schema.org/draft-07/schema#";
|
| 304 |
+
}
|
| 305 |
+
else if (ctx.target === "draft-04") {
|
| 306 |
+
result.$schema = "http://json-schema.org/draft-04/schema#";
|
| 307 |
+
}
|
| 308 |
+
else if (ctx.target === "openapi-3.0") {
|
| 309 |
+
// OpenAPI 3.0 schema objects should not include a $schema property
|
| 310 |
+
}
|
| 311 |
+
else {
|
| 312 |
+
// Arbitrary string values are allowed but won't have a $schema property set
|
| 313 |
+
}
|
| 314 |
+
if (ctx.external?.uri) {
|
| 315 |
+
const id = ctx.external.registry.get(schema)?.id;
|
| 316 |
+
if (!id)
|
| 317 |
+
throw new Error("Schema is missing an `id` property");
|
| 318 |
+
result.$id = ctx.external.uri(id);
|
| 319 |
+
}
|
| 320 |
+
Object.assign(result, root.def ?? root.schema);
|
| 321 |
+
// The `id` in `.meta()` is a Zod-specific registration tag used to extract
|
| 322 |
+
// schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
|
| 323 |
+
// from the output body where it would otherwise leak. The id is preserved
|
| 324 |
+
// implicitly via the $defs key (and via $ref paths).
|
| 325 |
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
| 326 |
+
if (rootMetaId !== undefined && result.id === rootMetaId)
|
| 327 |
+
delete result.id;
|
| 328 |
+
// build defs object
|
| 329 |
+
const defs = ctx.external?.defs ?? {};
|
| 330 |
+
for (const entry of ctx.seen.entries()) {
|
| 331 |
+
const seen = entry[1];
|
| 332 |
+
if (seen.def && seen.defId) {
|
| 333 |
+
if (seen.def.id === seen.defId)
|
| 334 |
+
delete seen.def.id;
|
| 335 |
+
defs[seen.defId] = seen.def;
|
| 336 |
+
}
|
| 337 |
+
}
|
| 338 |
+
// set definitions in result
|
| 339 |
+
if (ctx.external) {
|
| 340 |
+
}
|
| 341 |
+
else {
|
| 342 |
+
if (Object.keys(defs).length > 0) {
|
| 343 |
+
if (ctx.target === "draft-2020-12") {
|
| 344 |
+
result.$defs = defs;
|
| 345 |
+
}
|
| 346 |
+
else {
|
| 347 |
+
result.definitions = defs;
|
| 348 |
+
}
|
| 349 |
+
}
|
| 350 |
+
}
|
| 351 |
+
try {
|
| 352 |
+
// this "finalizes" this schema and ensures all cycles are removed
|
| 353 |
+
// each call to finalize() is functionally independent
|
| 354 |
+
// though the seen map is shared
|
| 355 |
+
const finalized = JSON.parse(JSON.stringify(result));
|
| 356 |
+
Object.defineProperty(finalized, "~standard", {
|
| 357 |
+
value: {
|
| 358 |
+
...schema["~standard"],
|
| 359 |
+
jsonSchema: {
|
| 360 |
+
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
|
| 361 |
+
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors),
|
| 362 |
+
},
|
| 363 |
+
},
|
| 364 |
+
enumerable: false,
|
| 365 |
+
writable: false,
|
| 366 |
+
});
|
| 367 |
+
return finalized;
|
| 368 |
+
}
|
| 369 |
+
catch (_err) {
|
| 370 |
+
throw new Error("Error converting schema to JSON.");
|
| 371 |
+
}
|
| 372 |
+
}
|
| 373 |
+
function isTransforming(_schema, _ctx) {
|
| 374 |
+
const ctx = _ctx ?? { seen: new Set() };
|
| 375 |
+
if (ctx.seen.has(_schema))
|
| 376 |
+
return false;
|
| 377 |
+
ctx.seen.add(_schema);
|
| 378 |
+
const def = _schema._zod.def;
|
| 379 |
+
if (def.type === "transform")
|
| 380 |
+
return true;
|
| 381 |
+
if (def.type === "array")
|
| 382 |
+
return isTransforming(def.element, ctx);
|
| 383 |
+
if (def.type === "set")
|
| 384 |
+
return isTransforming(def.valueType, ctx);
|
| 385 |
+
if (def.type === "lazy")
|
| 386 |
+
return isTransforming(def.getter(), ctx);
|
| 387 |
+
if (def.type === "promise" ||
|
| 388 |
+
def.type === "optional" ||
|
| 389 |
+
def.type === "nonoptional" ||
|
| 390 |
+
def.type === "nullable" ||
|
| 391 |
+
def.type === "readonly" ||
|
| 392 |
+
def.type === "default" ||
|
| 393 |
+
def.type === "prefault") {
|
| 394 |
+
return isTransforming(def.innerType, ctx);
|
| 395 |
+
}
|
| 396 |
+
if (def.type === "intersection") {
|
| 397 |
+
return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
| 398 |
+
}
|
| 399 |
+
if (def.type === "record" || def.type === "map") {
|
| 400 |
+
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
| 401 |
+
}
|
| 402 |
+
if (def.type === "pipe") {
|
| 403 |
+
if (_schema._zod.traits.has("$ZodCodec"))
|
| 404 |
+
return true;
|
| 405 |
+
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
| 406 |
+
}
|
| 407 |
+
if (def.type === "object") {
|
| 408 |
+
for (const key in def.shape) {
|
| 409 |
+
if (isTransforming(def.shape[key], ctx))
|
| 410 |
+
return true;
|
| 411 |
+
}
|
| 412 |
+
return false;
|
| 413 |
+
}
|
| 414 |
+
if (def.type === "union") {
|
| 415 |
+
for (const option of def.options) {
|
| 416 |
+
if (isTransforming(option, ctx))
|
| 417 |
+
return true;
|
| 418 |
+
}
|
| 419 |
+
return false;
|
| 420 |
+
}
|
| 421 |
+
if (def.type === "tuple") {
|
| 422 |
+
for (const item of def.items) {
|
| 423 |
+
if (isTransforming(item, ctx))
|
| 424 |
+
return true;
|
| 425 |
+
}
|
| 426 |
+
if (def.rest && isTransforming(def.rest, ctx))
|
| 427 |
+
return true;
|
| 428 |
+
return false;
|
| 429 |
+
}
|
| 430 |
+
return false;
|
| 431 |
+
}
|
| 432 |
+
/**
|
| 433 |
+
* Creates a toJSONSchema method for a schema instance.
|
| 434 |
+
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
| 435 |
+
*/
|
| 436 |
+
export const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
| 437 |
+
const ctx = initializeContext({ ...params, processors });
|
| 438 |
+
process(schema, ctx);
|
| 439 |
+
extractDefs(ctx, schema);
|
| 440 |
+
return finalize(ctx, schema);
|
| 441 |
+
};
|
| 442 |
+
export const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
| 443 |
+
const { libraryOptions, target } = params ?? {};
|
| 444 |
+
const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors });
|
| 445 |
+
process(schema, ctx);
|
| 446 |
+
extractDefs(ctx, schema);
|
| 447 |
+
return finalize(ctx, schema);
|
| 448 |
+
};
|
node_modules/zod/v4/core/util.cjs
ADDED
|
@@ -0,0 +1,734 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.Class = exports.BIGINT_FORMAT_RANGES = exports.NUMBER_FORMAT_RANGES = exports.primitiveTypes = exports.propertyKeyTypes = exports.getParsedType = exports.allowsEval = exports.captureStackTrace = void 0;
|
| 4 |
+
exports.assertEqual = assertEqual;
|
| 5 |
+
exports.assertNotEqual = assertNotEqual;
|
| 6 |
+
exports.assertIs = assertIs;
|
| 7 |
+
exports.assertNever = assertNever;
|
| 8 |
+
exports.assert = assert;
|
| 9 |
+
exports.getEnumValues = getEnumValues;
|
| 10 |
+
exports.joinValues = joinValues;
|
| 11 |
+
exports.jsonStringifyReplacer = jsonStringifyReplacer;
|
| 12 |
+
exports.cached = cached;
|
| 13 |
+
exports.nullish = nullish;
|
| 14 |
+
exports.cleanRegex = cleanRegex;
|
| 15 |
+
exports.floatSafeRemainder = floatSafeRemainder;
|
| 16 |
+
exports.defineLazy = defineLazy;
|
| 17 |
+
exports.objectClone = objectClone;
|
| 18 |
+
exports.assignProp = assignProp;
|
| 19 |
+
exports.mergeDefs = mergeDefs;
|
| 20 |
+
exports.cloneDef = cloneDef;
|
| 21 |
+
exports.getElementAtPath = getElementAtPath;
|
| 22 |
+
exports.promiseAllObject = promiseAllObject;
|
| 23 |
+
exports.randomString = randomString;
|
| 24 |
+
exports.esc = esc;
|
| 25 |
+
exports.slugify = slugify;
|
| 26 |
+
exports.isObject = isObject;
|
| 27 |
+
exports.isPlainObject = isPlainObject;
|
| 28 |
+
exports.shallowClone = shallowClone;
|
| 29 |
+
exports.numKeys = numKeys;
|
| 30 |
+
exports.escapeRegex = escapeRegex;
|
| 31 |
+
exports.clone = clone;
|
| 32 |
+
exports.normalizeParams = normalizeParams;
|
| 33 |
+
exports.createTransparentProxy = createTransparentProxy;
|
| 34 |
+
exports.stringifyPrimitive = stringifyPrimitive;
|
| 35 |
+
exports.optionalKeys = optionalKeys;
|
| 36 |
+
exports.pick = pick;
|
| 37 |
+
exports.omit = omit;
|
| 38 |
+
exports.extend = extend;
|
| 39 |
+
exports.safeExtend = safeExtend;
|
| 40 |
+
exports.merge = merge;
|
| 41 |
+
exports.partial = partial;
|
| 42 |
+
exports.required = required;
|
| 43 |
+
exports.aborted = aborted;
|
| 44 |
+
exports.explicitlyAborted = explicitlyAborted;
|
| 45 |
+
exports.prefixIssues = prefixIssues;
|
| 46 |
+
exports.unwrapMessage = unwrapMessage;
|
| 47 |
+
exports.finalizeIssue = finalizeIssue;
|
| 48 |
+
exports.getSizableOrigin = getSizableOrigin;
|
| 49 |
+
exports.getLengthableOrigin = getLengthableOrigin;
|
| 50 |
+
exports.parsedType = parsedType;
|
| 51 |
+
exports.issue = issue;
|
| 52 |
+
exports.cleanEnum = cleanEnum;
|
| 53 |
+
exports.base64ToUint8Array = base64ToUint8Array;
|
| 54 |
+
exports.uint8ArrayToBase64 = uint8ArrayToBase64;
|
| 55 |
+
exports.base64urlToUint8Array = base64urlToUint8Array;
|
| 56 |
+
exports.uint8ArrayToBase64url = uint8ArrayToBase64url;
|
| 57 |
+
exports.hexToUint8Array = hexToUint8Array;
|
| 58 |
+
exports.uint8ArrayToHex = uint8ArrayToHex;
|
| 59 |
+
const core_js_1 = require("./core.cjs");
|
| 60 |
+
// functions
|
| 61 |
+
function assertEqual(val) {
|
| 62 |
+
return val;
|
| 63 |
+
}
|
| 64 |
+
function assertNotEqual(val) {
|
| 65 |
+
return val;
|
| 66 |
+
}
|
| 67 |
+
function assertIs(_arg) { }
|
| 68 |
+
function assertNever(_x) {
|
| 69 |
+
throw new Error("Unexpected value in exhaustive check");
|
| 70 |
+
}
|
| 71 |
+
function assert(_) { }
|
| 72 |
+
function getEnumValues(entries) {
|
| 73 |
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
| 74 |
+
const values = Object.entries(entries)
|
| 75 |
+
.filter(([k, _]) => numericValues.indexOf(+k) === -1)
|
| 76 |
+
.map(([_, v]) => v);
|
| 77 |
+
return values;
|
| 78 |
+
}
|
| 79 |
+
function joinValues(array, separator = "|") {
|
| 80 |
+
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
| 81 |
+
}
|
| 82 |
+
function jsonStringifyReplacer(_, value) {
|
| 83 |
+
if (typeof value === "bigint")
|
| 84 |
+
return value.toString();
|
| 85 |
+
return value;
|
| 86 |
+
}
|
| 87 |
+
function cached(getter) {
|
| 88 |
+
const set = false;
|
| 89 |
+
return {
|
| 90 |
+
get value() {
|
| 91 |
+
if (!set) {
|
| 92 |
+
const value = getter();
|
| 93 |
+
Object.defineProperty(this, "value", { value });
|
| 94 |
+
return value;
|
| 95 |
+
}
|
| 96 |
+
throw new Error("cached value already set");
|
| 97 |
+
},
|
| 98 |
+
};
|
| 99 |
+
}
|
| 100 |
+
function nullish(input) {
|
| 101 |
+
return input === null || input === undefined;
|
| 102 |
+
}
|
| 103 |
+
function cleanRegex(source) {
|
| 104 |
+
const start = source.startsWith("^") ? 1 : 0;
|
| 105 |
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
| 106 |
+
return source.slice(start, end);
|
| 107 |
+
}
|
| 108 |
+
function floatSafeRemainder(val, step) {
|
| 109 |
+
const ratio = val / step;
|
| 110 |
+
const roundedRatio = Math.round(ratio);
|
| 111 |
+
// Use a relative epsilon scaled to the magnitude of the result
|
| 112 |
+
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
| 113 |
+
if (Math.abs(ratio - roundedRatio) < tolerance)
|
| 114 |
+
return 0;
|
| 115 |
+
return ratio - roundedRatio;
|
| 116 |
+
}
|
| 117 |
+
const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
|
| 118 |
+
function defineLazy(object, key, getter) {
|
| 119 |
+
let value = undefined;
|
| 120 |
+
Object.defineProperty(object, key, {
|
| 121 |
+
get() {
|
| 122 |
+
if (value === EVALUATING) {
|
| 123 |
+
// Circular reference detected, return undefined to break the cycle
|
| 124 |
+
return undefined;
|
| 125 |
+
}
|
| 126 |
+
if (value === undefined) {
|
| 127 |
+
value = EVALUATING;
|
| 128 |
+
value = getter();
|
| 129 |
+
}
|
| 130 |
+
return value;
|
| 131 |
+
},
|
| 132 |
+
set(v) {
|
| 133 |
+
Object.defineProperty(object, key, {
|
| 134 |
+
value: v,
|
| 135 |
+
// configurable: true,
|
| 136 |
+
});
|
| 137 |
+
// object[key] = v;
|
| 138 |
+
},
|
| 139 |
+
configurable: true,
|
| 140 |
+
});
|
| 141 |
+
}
|
| 142 |
+
function objectClone(obj) {
|
| 143 |
+
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
| 144 |
+
}
|
| 145 |
+
function assignProp(target, prop, value) {
|
| 146 |
+
Object.defineProperty(target, prop, {
|
| 147 |
+
value,
|
| 148 |
+
writable: true,
|
| 149 |
+
enumerable: true,
|
| 150 |
+
configurable: true,
|
| 151 |
+
});
|
| 152 |
+
}
|
| 153 |
+
function mergeDefs(...defs) {
|
| 154 |
+
const mergedDescriptors = {};
|
| 155 |
+
for (const def of defs) {
|
| 156 |
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
| 157 |
+
Object.assign(mergedDescriptors, descriptors);
|
| 158 |
+
}
|
| 159 |
+
return Object.defineProperties({}, mergedDescriptors);
|
| 160 |
+
}
|
| 161 |
+
function cloneDef(schema) {
|
| 162 |
+
return mergeDefs(schema._zod.def);
|
| 163 |
+
}
|
| 164 |
+
function getElementAtPath(obj, path) {
|
| 165 |
+
if (!path)
|
| 166 |
+
return obj;
|
| 167 |
+
return path.reduce((acc, key) => acc?.[key], obj);
|
| 168 |
+
}
|
| 169 |
+
function promiseAllObject(promisesObj) {
|
| 170 |
+
const keys = Object.keys(promisesObj);
|
| 171 |
+
const promises = keys.map((key) => promisesObj[key]);
|
| 172 |
+
return Promise.all(promises).then((results) => {
|
| 173 |
+
const resolvedObj = {};
|
| 174 |
+
for (let i = 0; i < keys.length; i++) {
|
| 175 |
+
resolvedObj[keys[i]] = results[i];
|
| 176 |
+
}
|
| 177 |
+
return resolvedObj;
|
| 178 |
+
});
|
| 179 |
+
}
|
| 180 |
+
function randomString(length = 10) {
|
| 181 |
+
const chars = "abcdefghijklmnopqrstuvwxyz";
|
| 182 |
+
let str = "";
|
| 183 |
+
for (let i = 0; i < length; i++) {
|
| 184 |
+
str += chars[Math.floor(Math.random() * chars.length)];
|
| 185 |
+
}
|
| 186 |
+
return str;
|
| 187 |
+
}
|
| 188 |
+
function esc(str) {
|
| 189 |
+
return JSON.stringify(str);
|
| 190 |
+
}
|
| 191 |
+
function slugify(input) {
|
| 192 |
+
return input
|
| 193 |
+
.toLowerCase()
|
| 194 |
+
.trim()
|
| 195 |
+
.replace(/[^\w\s-]/g, "")
|
| 196 |
+
.replace(/[\s_-]+/g, "-")
|
| 197 |
+
.replace(/^-+|-+$/g, "");
|
| 198 |
+
}
|
| 199 |
+
exports.captureStackTrace = ("captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => { });
|
| 200 |
+
function isObject(data) {
|
| 201 |
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
| 202 |
+
}
|
| 203 |
+
exports.allowsEval = cached(() => {
|
| 204 |
+
// Skip the probe under `jitless`: strict CSPs report the caught `new Function`
|
| 205 |
+
// as a `securitypolicyviolation` even though the throw is swallowed.
|
| 206 |
+
if (core_js_1.globalConfig.jitless) {
|
| 207 |
+
return false;
|
| 208 |
+
}
|
| 209 |
+
// @ts-ignore
|
| 210 |
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
| 211 |
+
return false;
|
| 212 |
+
}
|
| 213 |
+
try {
|
| 214 |
+
const F = Function;
|
| 215 |
+
new F("");
|
| 216 |
+
return true;
|
| 217 |
+
}
|
| 218 |
+
catch (_) {
|
| 219 |
+
return false;
|
| 220 |
+
}
|
| 221 |
+
});
|
| 222 |
+
function isPlainObject(o) {
|
| 223 |
+
if (isObject(o) === false)
|
| 224 |
+
return false;
|
| 225 |
+
// modified constructor
|
| 226 |
+
const ctor = o.constructor;
|
| 227 |
+
if (ctor === undefined)
|
| 228 |
+
return true;
|
| 229 |
+
if (typeof ctor !== "function")
|
| 230 |
+
return true;
|
| 231 |
+
// modified prototype
|
| 232 |
+
const prot = ctor.prototype;
|
| 233 |
+
if (isObject(prot) === false)
|
| 234 |
+
return false;
|
| 235 |
+
// ctor doesn't have static `isPrototypeOf`
|
| 236 |
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
| 237 |
+
return false;
|
| 238 |
+
}
|
| 239 |
+
return true;
|
| 240 |
+
}
|
| 241 |
+
function shallowClone(o) {
|
| 242 |
+
if (isPlainObject(o))
|
| 243 |
+
return { ...o };
|
| 244 |
+
if (Array.isArray(o))
|
| 245 |
+
return [...o];
|
| 246 |
+
if (o instanceof Map)
|
| 247 |
+
return new Map(o);
|
| 248 |
+
if (o instanceof Set)
|
| 249 |
+
return new Set(o);
|
| 250 |
+
return o;
|
| 251 |
+
}
|
| 252 |
+
function numKeys(data) {
|
| 253 |
+
let keyCount = 0;
|
| 254 |
+
for (const key in data) {
|
| 255 |
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
| 256 |
+
keyCount++;
|
| 257 |
+
}
|
| 258 |
+
}
|
| 259 |
+
return keyCount;
|
| 260 |
+
}
|
| 261 |
+
const getParsedType = (data) => {
|
| 262 |
+
const t = typeof data;
|
| 263 |
+
switch (t) {
|
| 264 |
+
case "undefined":
|
| 265 |
+
return "undefined";
|
| 266 |
+
case "string":
|
| 267 |
+
return "string";
|
| 268 |
+
case "number":
|
| 269 |
+
return Number.isNaN(data) ? "nan" : "number";
|
| 270 |
+
case "boolean":
|
| 271 |
+
return "boolean";
|
| 272 |
+
case "function":
|
| 273 |
+
return "function";
|
| 274 |
+
case "bigint":
|
| 275 |
+
return "bigint";
|
| 276 |
+
case "symbol":
|
| 277 |
+
return "symbol";
|
| 278 |
+
case "object":
|
| 279 |
+
if (Array.isArray(data)) {
|
| 280 |
+
return "array";
|
| 281 |
+
}
|
| 282 |
+
if (data === null) {
|
| 283 |
+
return "null";
|
| 284 |
+
}
|
| 285 |
+
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
| 286 |
+
return "promise";
|
| 287 |
+
}
|
| 288 |
+
if (typeof Map !== "undefined" && data instanceof Map) {
|
| 289 |
+
return "map";
|
| 290 |
+
}
|
| 291 |
+
if (typeof Set !== "undefined" && data instanceof Set) {
|
| 292 |
+
return "set";
|
| 293 |
+
}
|
| 294 |
+
if (typeof Date !== "undefined" && data instanceof Date) {
|
| 295 |
+
return "date";
|
| 296 |
+
}
|
| 297 |
+
// @ts-ignore
|
| 298 |
+
if (typeof File !== "undefined" && data instanceof File) {
|
| 299 |
+
return "file";
|
| 300 |
+
}
|
| 301 |
+
return "object";
|
| 302 |
+
default:
|
| 303 |
+
throw new Error(`Unknown data type: ${t}`);
|
| 304 |
+
}
|
| 305 |
+
};
|
| 306 |
+
exports.getParsedType = getParsedType;
|
| 307 |
+
exports.propertyKeyTypes = new Set(["string", "number", "symbol"]);
|
| 308 |
+
exports.primitiveTypes = new Set([
|
| 309 |
+
"string",
|
| 310 |
+
"number",
|
| 311 |
+
"bigint",
|
| 312 |
+
"boolean",
|
| 313 |
+
"symbol",
|
| 314 |
+
"undefined",
|
| 315 |
+
]);
|
| 316 |
+
function escapeRegex(str) {
|
| 317 |
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
| 318 |
+
}
|
| 319 |
+
// zod-specific utils
|
| 320 |
+
function clone(inst, def, params) {
|
| 321 |
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
| 322 |
+
if (!def || params?.parent)
|
| 323 |
+
cl._zod.parent = inst;
|
| 324 |
+
return cl;
|
| 325 |
+
}
|
| 326 |
+
function normalizeParams(_params) {
|
| 327 |
+
const params = _params;
|
| 328 |
+
if (!params)
|
| 329 |
+
return {};
|
| 330 |
+
if (typeof params === "string")
|
| 331 |
+
return { error: () => params };
|
| 332 |
+
if (params?.message !== undefined) {
|
| 333 |
+
if (params?.error !== undefined)
|
| 334 |
+
throw new Error("Cannot specify both `message` and `error` params");
|
| 335 |
+
params.error = params.message;
|
| 336 |
+
}
|
| 337 |
+
delete params.message;
|
| 338 |
+
if (typeof params.error === "string")
|
| 339 |
+
return { ...params, error: () => params.error };
|
| 340 |
+
return params;
|
| 341 |
+
}
|
| 342 |
+
function createTransparentProxy(getter) {
|
| 343 |
+
let target;
|
| 344 |
+
return new Proxy({}, {
|
| 345 |
+
get(_, prop, receiver) {
|
| 346 |
+
target ?? (target = getter());
|
| 347 |
+
return Reflect.get(target, prop, receiver);
|
| 348 |
+
},
|
| 349 |
+
set(_, prop, value, receiver) {
|
| 350 |
+
target ?? (target = getter());
|
| 351 |
+
return Reflect.set(target, prop, value, receiver);
|
| 352 |
+
},
|
| 353 |
+
has(_, prop) {
|
| 354 |
+
target ?? (target = getter());
|
| 355 |
+
return Reflect.has(target, prop);
|
| 356 |
+
},
|
| 357 |
+
deleteProperty(_, prop) {
|
| 358 |
+
target ?? (target = getter());
|
| 359 |
+
return Reflect.deleteProperty(target, prop);
|
| 360 |
+
},
|
| 361 |
+
ownKeys(_) {
|
| 362 |
+
target ?? (target = getter());
|
| 363 |
+
return Reflect.ownKeys(target);
|
| 364 |
+
},
|
| 365 |
+
getOwnPropertyDescriptor(_, prop) {
|
| 366 |
+
target ?? (target = getter());
|
| 367 |
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
| 368 |
+
},
|
| 369 |
+
defineProperty(_, prop, descriptor) {
|
| 370 |
+
target ?? (target = getter());
|
| 371 |
+
return Reflect.defineProperty(target, prop, descriptor);
|
| 372 |
+
},
|
| 373 |
+
});
|
| 374 |
+
}
|
| 375 |
+
function stringifyPrimitive(value) {
|
| 376 |
+
if (typeof value === "bigint")
|
| 377 |
+
return value.toString() + "n";
|
| 378 |
+
if (typeof value === "string")
|
| 379 |
+
return `"${value}"`;
|
| 380 |
+
return `${value}`;
|
| 381 |
+
}
|
| 382 |
+
function optionalKeys(shape) {
|
| 383 |
+
return Object.keys(shape).filter((k) => {
|
| 384 |
+
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
| 385 |
+
});
|
| 386 |
+
}
|
| 387 |
+
exports.NUMBER_FORMAT_RANGES = {
|
| 388 |
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
| 389 |
+
int32: [-2147483648, 2147483647],
|
| 390 |
+
uint32: [0, 4294967295],
|
| 391 |
+
float32: [-3.4028234663852886e38, 3.4028234663852886e38],
|
| 392 |
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE],
|
| 393 |
+
};
|
| 394 |
+
exports.BIGINT_FORMAT_RANGES = {
|
| 395 |
+
int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
|
| 396 |
+
uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")],
|
| 397 |
+
};
|
| 398 |
+
function pick(schema, mask) {
|
| 399 |
+
const currDef = schema._zod.def;
|
| 400 |
+
const checks = currDef.checks;
|
| 401 |
+
const hasChecks = checks && checks.length > 0;
|
| 402 |
+
if (hasChecks) {
|
| 403 |
+
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
| 404 |
+
}
|
| 405 |
+
const def = mergeDefs(schema._zod.def, {
|
| 406 |
+
get shape() {
|
| 407 |
+
const newShape = {};
|
| 408 |
+
for (const key in mask) {
|
| 409 |
+
if (!(key in currDef.shape)) {
|
| 410 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 411 |
+
}
|
| 412 |
+
if (!mask[key])
|
| 413 |
+
continue;
|
| 414 |
+
newShape[key] = currDef.shape[key];
|
| 415 |
+
}
|
| 416 |
+
assignProp(this, "shape", newShape); // self-caching
|
| 417 |
+
return newShape;
|
| 418 |
+
},
|
| 419 |
+
checks: [],
|
| 420 |
+
});
|
| 421 |
+
return clone(schema, def);
|
| 422 |
+
}
|
| 423 |
+
function omit(schema, mask) {
|
| 424 |
+
const currDef = schema._zod.def;
|
| 425 |
+
const checks = currDef.checks;
|
| 426 |
+
const hasChecks = checks && checks.length > 0;
|
| 427 |
+
if (hasChecks) {
|
| 428 |
+
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
| 429 |
+
}
|
| 430 |
+
const def = mergeDefs(schema._zod.def, {
|
| 431 |
+
get shape() {
|
| 432 |
+
const newShape = { ...schema._zod.def.shape };
|
| 433 |
+
for (const key in mask) {
|
| 434 |
+
if (!(key in currDef.shape)) {
|
| 435 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 436 |
+
}
|
| 437 |
+
if (!mask[key])
|
| 438 |
+
continue;
|
| 439 |
+
delete newShape[key];
|
| 440 |
+
}
|
| 441 |
+
assignProp(this, "shape", newShape); // self-caching
|
| 442 |
+
return newShape;
|
| 443 |
+
},
|
| 444 |
+
checks: [],
|
| 445 |
+
});
|
| 446 |
+
return clone(schema, def);
|
| 447 |
+
}
|
| 448 |
+
function extend(schema, shape) {
|
| 449 |
+
if (!isPlainObject(shape)) {
|
| 450 |
+
throw new Error("Invalid input to extend: expected a plain object");
|
| 451 |
+
}
|
| 452 |
+
const checks = schema._zod.def.checks;
|
| 453 |
+
const hasChecks = checks && checks.length > 0;
|
| 454 |
+
if (hasChecks) {
|
| 455 |
+
// Only throw if new shape overlaps with existing shape
|
| 456 |
+
// Use getOwnPropertyDescriptor to check key existence without accessing values
|
| 457 |
+
const existingShape = schema._zod.def.shape;
|
| 458 |
+
for (const key in shape) {
|
| 459 |
+
if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
|
| 460 |
+
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
| 461 |
+
}
|
| 462 |
+
}
|
| 463 |
+
}
|
| 464 |
+
const def = mergeDefs(schema._zod.def, {
|
| 465 |
+
get shape() {
|
| 466 |
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
| 467 |
+
assignProp(this, "shape", _shape); // self-caching
|
| 468 |
+
return _shape;
|
| 469 |
+
},
|
| 470 |
+
});
|
| 471 |
+
return clone(schema, def);
|
| 472 |
+
}
|
| 473 |
+
function safeExtend(schema, shape) {
|
| 474 |
+
if (!isPlainObject(shape)) {
|
| 475 |
+
throw new Error("Invalid input to safeExtend: expected a plain object");
|
| 476 |
+
}
|
| 477 |
+
const def = mergeDefs(schema._zod.def, {
|
| 478 |
+
get shape() {
|
| 479 |
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
| 480 |
+
assignProp(this, "shape", _shape); // self-caching
|
| 481 |
+
return _shape;
|
| 482 |
+
},
|
| 483 |
+
});
|
| 484 |
+
return clone(schema, def);
|
| 485 |
+
}
|
| 486 |
+
function merge(a, b) {
|
| 487 |
+
if (a._zod.def.checks?.length) {
|
| 488 |
+
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
| 489 |
+
}
|
| 490 |
+
const def = mergeDefs(a._zod.def, {
|
| 491 |
+
get shape() {
|
| 492 |
+
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
| 493 |
+
assignProp(this, "shape", _shape); // self-caching
|
| 494 |
+
return _shape;
|
| 495 |
+
},
|
| 496 |
+
get catchall() {
|
| 497 |
+
return b._zod.def.catchall;
|
| 498 |
+
},
|
| 499 |
+
checks: b._zod.def.checks ?? [],
|
| 500 |
+
});
|
| 501 |
+
return clone(a, def);
|
| 502 |
+
}
|
| 503 |
+
function partial(Class, schema, mask) {
|
| 504 |
+
const currDef = schema._zod.def;
|
| 505 |
+
const checks = currDef.checks;
|
| 506 |
+
const hasChecks = checks && checks.length > 0;
|
| 507 |
+
if (hasChecks) {
|
| 508 |
+
throw new Error(".partial() cannot be used on object schemas containing refinements");
|
| 509 |
+
}
|
| 510 |
+
const def = mergeDefs(schema._zod.def, {
|
| 511 |
+
get shape() {
|
| 512 |
+
const oldShape = schema._zod.def.shape;
|
| 513 |
+
const shape = { ...oldShape };
|
| 514 |
+
if (mask) {
|
| 515 |
+
for (const key in mask) {
|
| 516 |
+
if (!(key in oldShape)) {
|
| 517 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 518 |
+
}
|
| 519 |
+
if (!mask[key])
|
| 520 |
+
continue;
|
| 521 |
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
| 522 |
+
shape[key] = Class
|
| 523 |
+
? new Class({
|
| 524 |
+
type: "optional",
|
| 525 |
+
innerType: oldShape[key],
|
| 526 |
+
})
|
| 527 |
+
: oldShape[key];
|
| 528 |
+
}
|
| 529 |
+
}
|
| 530 |
+
else {
|
| 531 |
+
for (const key in oldShape) {
|
| 532 |
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
| 533 |
+
shape[key] = Class
|
| 534 |
+
? new Class({
|
| 535 |
+
type: "optional",
|
| 536 |
+
innerType: oldShape[key],
|
| 537 |
+
})
|
| 538 |
+
: oldShape[key];
|
| 539 |
+
}
|
| 540 |
+
}
|
| 541 |
+
assignProp(this, "shape", shape); // self-caching
|
| 542 |
+
return shape;
|
| 543 |
+
},
|
| 544 |
+
checks: [],
|
| 545 |
+
});
|
| 546 |
+
return clone(schema, def);
|
| 547 |
+
}
|
| 548 |
+
function required(Class, schema, mask) {
|
| 549 |
+
const def = mergeDefs(schema._zod.def, {
|
| 550 |
+
get shape() {
|
| 551 |
+
const oldShape = schema._zod.def.shape;
|
| 552 |
+
const shape = { ...oldShape };
|
| 553 |
+
if (mask) {
|
| 554 |
+
for (const key in mask) {
|
| 555 |
+
if (!(key in shape)) {
|
| 556 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 557 |
+
}
|
| 558 |
+
if (!mask[key])
|
| 559 |
+
continue;
|
| 560 |
+
// overwrite with non-optional
|
| 561 |
+
shape[key] = new Class({
|
| 562 |
+
type: "nonoptional",
|
| 563 |
+
innerType: oldShape[key],
|
| 564 |
+
});
|
| 565 |
+
}
|
| 566 |
+
}
|
| 567 |
+
else {
|
| 568 |
+
for (const key in oldShape) {
|
| 569 |
+
// overwrite with non-optional
|
| 570 |
+
shape[key] = new Class({
|
| 571 |
+
type: "nonoptional",
|
| 572 |
+
innerType: oldShape[key],
|
| 573 |
+
});
|
| 574 |
+
}
|
| 575 |
+
}
|
| 576 |
+
assignProp(this, "shape", shape); // self-caching
|
| 577 |
+
return shape;
|
| 578 |
+
},
|
| 579 |
+
});
|
| 580 |
+
return clone(schema, def);
|
| 581 |
+
}
|
| 582 |
+
// invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom
|
| 583 |
+
function aborted(x, startIndex = 0) {
|
| 584 |
+
if (x.aborted === true)
|
| 585 |
+
return true;
|
| 586 |
+
for (let i = startIndex; i < x.issues.length; i++) {
|
| 587 |
+
if (x.issues[i]?.continue !== true) {
|
| 588 |
+
return true;
|
| 589 |
+
}
|
| 590 |
+
}
|
| 591 |
+
return false;
|
| 592 |
+
}
|
| 593 |
+
// Checks for explicit abort (continue === false), as opposed to implicit abort (continue === undefined).
|
| 594 |
+
// Used to respect `abort: true` in .refine() even for checks that have a `when` function.
|
| 595 |
+
function explicitlyAborted(x, startIndex = 0) {
|
| 596 |
+
if (x.aborted === true)
|
| 597 |
+
return true;
|
| 598 |
+
for (let i = startIndex; i < x.issues.length; i++) {
|
| 599 |
+
if (x.issues[i]?.continue === false) {
|
| 600 |
+
return true;
|
| 601 |
+
}
|
| 602 |
+
}
|
| 603 |
+
return false;
|
| 604 |
+
}
|
| 605 |
+
function prefixIssues(path, issues) {
|
| 606 |
+
return issues.map((iss) => {
|
| 607 |
+
var _a;
|
| 608 |
+
(_a = iss).path ?? (_a.path = []);
|
| 609 |
+
iss.path.unshift(path);
|
| 610 |
+
return iss;
|
| 611 |
+
});
|
| 612 |
+
}
|
| 613 |
+
function unwrapMessage(message) {
|
| 614 |
+
return typeof message === "string" ? message : message?.message;
|
| 615 |
+
}
|
| 616 |
+
function finalizeIssue(iss, ctx, config) {
|
| 617 |
+
const message = iss.message
|
| 618 |
+
? iss.message
|
| 619 |
+
: (unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
|
| 620 |
+
unwrapMessage(ctx?.error?.(iss)) ??
|
| 621 |
+
unwrapMessage(config.customError?.(iss)) ??
|
| 622 |
+
unwrapMessage(config.localeError?.(iss)) ??
|
| 623 |
+
"Invalid input");
|
| 624 |
+
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
|
| 625 |
+
rest.path ?? (rest.path = []);
|
| 626 |
+
rest.message = message;
|
| 627 |
+
if (ctx?.reportInput) {
|
| 628 |
+
rest.input = _input;
|
| 629 |
+
}
|
| 630 |
+
return rest;
|
| 631 |
+
}
|
| 632 |
+
function getSizableOrigin(input) {
|
| 633 |
+
if (input instanceof Set)
|
| 634 |
+
return "set";
|
| 635 |
+
if (input instanceof Map)
|
| 636 |
+
return "map";
|
| 637 |
+
// @ts-ignore
|
| 638 |
+
if (input instanceof File)
|
| 639 |
+
return "file";
|
| 640 |
+
return "unknown";
|
| 641 |
+
}
|
| 642 |
+
function getLengthableOrigin(input) {
|
| 643 |
+
if (Array.isArray(input))
|
| 644 |
+
return "array";
|
| 645 |
+
if (typeof input === "string")
|
| 646 |
+
return "string";
|
| 647 |
+
return "unknown";
|
| 648 |
+
}
|
| 649 |
+
function parsedType(data) {
|
| 650 |
+
const t = typeof data;
|
| 651 |
+
switch (t) {
|
| 652 |
+
case "number": {
|
| 653 |
+
return Number.isNaN(data) ? "nan" : "number";
|
| 654 |
+
}
|
| 655 |
+
case "object": {
|
| 656 |
+
if (data === null) {
|
| 657 |
+
return "null";
|
| 658 |
+
}
|
| 659 |
+
if (Array.isArray(data)) {
|
| 660 |
+
return "array";
|
| 661 |
+
}
|
| 662 |
+
const obj = data;
|
| 663 |
+
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
|
| 664 |
+
return obj.constructor.name;
|
| 665 |
+
}
|
| 666 |
+
}
|
| 667 |
+
}
|
| 668 |
+
return t;
|
| 669 |
+
}
|
| 670 |
+
function issue(...args) {
|
| 671 |
+
const [iss, input, inst] = args;
|
| 672 |
+
if (typeof iss === "string") {
|
| 673 |
+
return {
|
| 674 |
+
message: iss,
|
| 675 |
+
code: "custom",
|
| 676 |
+
input,
|
| 677 |
+
inst,
|
| 678 |
+
};
|
| 679 |
+
}
|
| 680 |
+
return { ...iss };
|
| 681 |
+
}
|
| 682 |
+
function cleanEnum(obj) {
|
| 683 |
+
return Object.entries(obj)
|
| 684 |
+
.filter(([k, _]) => {
|
| 685 |
+
// return true if NaN, meaning it's not a number, thus a string key
|
| 686 |
+
return Number.isNaN(Number.parseInt(k, 10));
|
| 687 |
+
})
|
| 688 |
+
.map((el) => el[1]);
|
| 689 |
+
}
|
| 690 |
+
// Codec utility functions
|
| 691 |
+
function base64ToUint8Array(base64) {
|
| 692 |
+
const binaryString = atob(base64);
|
| 693 |
+
const bytes = new Uint8Array(binaryString.length);
|
| 694 |
+
for (let i = 0; i < binaryString.length; i++) {
|
| 695 |
+
bytes[i] = binaryString.charCodeAt(i);
|
| 696 |
+
}
|
| 697 |
+
return bytes;
|
| 698 |
+
}
|
| 699 |
+
function uint8ArrayToBase64(bytes) {
|
| 700 |
+
let binaryString = "";
|
| 701 |
+
for (let i = 0; i < bytes.length; i++) {
|
| 702 |
+
binaryString += String.fromCharCode(bytes[i]);
|
| 703 |
+
}
|
| 704 |
+
return btoa(binaryString);
|
| 705 |
+
}
|
| 706 |
+
function base64urlToUint8Array(base64url) {
|
| 707 |
+
const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
|
| 708 |
+
const padding = "=".repeat((4 - (base64.length % 4)) % 4);
|
| 709 |
+
return base64ToUint8Array(base64 + padding);
|
| 710 |
+
}
|
| 711 |
+
function uint8ArrayToBase64url(bytes) {
|
| 712 |
+
return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
| 713 |
+
}
|
| 714 |
+
function hexToUint8Array(hex) {
|
| 715 |
+
const cleanHex = hex.replace(/^0x/, "");
|
| 716 |
+
if (cleanHex.length % 2 !== 0) {
|
| 717 |
+
throw new Error("Invalid hex string length");
|
| 718 |
+
}
|
| 719 |
+
const bytes = new Uint8Array(cleanHex.length / 2);
|
| 720 |
+
for (let i = 0; i < cleanHex.length; i += 2) {
|
| 721 |
+
bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
|
| 722 |
+
}
|
| 723 |
+
return bytes;
|
| 724 |
+
}
|
| 725 |
+
function uint8ArrayToHex(bytes) {
|
| 726 |
+
return Array.from(bytes)
|
| 727 |
+
.map((b) => b.toString(16).padStart(2, "0"))
|
| 728 |
+
.join("");
|
| 729 |
+
}
|
| 730 |
+
// instanceof
|
| 731 |
+
class Class {
|
| 732 |
+
constructor(..._args) { }
|
| 733 |
+
}
|
| 734 |
+
exports.Class = Class;
|
node_modules/zod/v4/core/util.d.cts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as checks from "./checks.cjs";
|
| 2 |
+
import type { $ZodConfig } from "./core.cjs";
|
| 3 |
+
import type * as errors from "./errors.cjs";
|
| 4 |
+
import type * as schemas from "./schemas.cjs";
|
| 5 |
+
export type JSONType = string | number | boolean | null | JSONType[] | {
|
| 6 |
+
[key: string]: JSONType;
|
| 7 |
+
};
|
| 8 |
+
export type JWTAlgorithm = "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | (string & {});
|
| 9 |
+
export type HashAlgorithm = "md5" | "sha1" | "sha256" | "sha384" | "sha512";
|
| 10 |
+
export type HashEncoding = "hex" | "base64" | "base64url";
|
| 11 |
+
export type HashFormat = `${HashAlgorithm}_${HashEncoding}`;
|
| 12 |
+
export type IPVersion = "v4" | "v6";
|
| 13 |
+
export type MimeTypes = "application/json" | "application/xml" | "application/x-www-form-urlencoded" | "application/javascript" | "application/pdf" | "application/zip" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/octet-stream" | "application/graphql" | "text/html" | "text/plain" | "text/css" | "text/javascript" | "text/csv" | "image/png" | "image/jpeg" | "image/gif" | "image/svg+xml" | "image/webp" | "audio/mpeg" | "audio/ogg" | "audio/wav" | "audio/webm" | "video/mp4" | "video/webm" | "video/ogg" | "font/woff" | "font/woff2" | "font/ttf" | "font/otf" | "multipart/form-data" | (string & {});
|
| 14 |
+
export type ParsedTypes = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "file" | "date" | "array" | "map" | "set" | "nan" | "null" | "promise";
|
| 15 |
+
export type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
|
| 16 |
+
export type AssertNotEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? false : true;
|
| 17 |
+
export type AssertExtends<T, U> = T extends U ? T : never;
|
| 18 |
+
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
| 19 |
+
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
| 20 |
+
export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
|
| 21 |
+
export type MakePartial<T, K extends keyof T> = Omit<T, K> & InexactPartial<Pick<T, K>>;
|
| 22 |
+
export type MakeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
| 23 |
+
export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
|
| 24 |
+
export type NoUndefined<T> = T extends undefined ? never : T;
|
| 25 |
+
export type Whatever = {} | undefined | null;
|
| 26 |
+
export type LoosePartial<T extends object> = InexactPartial<T> & {
|
| 27 |
+
[k: string]: unknown;
|
| 28 |
+
};
|
| 29 |
+
export type Mask<Keys extends PropertyKey> = {
|
| 30 |
+
[K in Keys]?: true;
|
| 31 |
+
};
|
| 32 |
+
export type Writeable<T> = {
|
| 33 |
+
-readonly [P in keyof T]: T[P];
|
| 34 |
+
} & {};
|
| 35 |
+
export type InexactPartial<T> = {
|
| 36 |
+
[P in keyof T]?: T[P] | undefined;
|
| 37 |
+
};
|
| 38 |
+
export type EmptyObject = Record<string, never>;
|
| 39 |
+
export type BuiltIn = (((...args: any[]) => any) | (new (...args: any[]) => any)) | {
|
| 40 |
+
readonly [Symbol.toStringTag]: string;
|
| 41 |
+
} | Date | Error | Generator | Promise<unknown> | RegExp;
|
| 42 |
+
export type MakeReadonly<T> = T extends Map<infer K, infer V> ? ReadonlyMap<K, V> : T extends Set<infer V> ? ReadonlySet<V> : T extends [infer Head, ...infer Tail] ? readonly [Head, ...Tail] : T extends Array<infer V> ? ReadonlyArray<V> : T extends BuiltIn ? T : Readonly<T>;
|
| 43 |
+
export type SomeObject = Record<PropertyKey, any>;
|
| 44 |
+
export type Identity<T> = T;
|
| 45 |
+
export type Flatten<T> = Identity<{
|
| 46 |
+
[k in keyof T]: T[k];
|
| 47 |
+
}>;
|
| 48 |
+
export type Mapped<T> = {
|
| 49 |
+
[k in keyof T]: T[k];
|
| 50 |
+
};
|
| 51 |
+
export type Prettify<T> = {
|
| 52 |
+
[K in keyof T]: T[K];
|
| 53 |
+
} & {};
|
| 54 |
+
export type NoNeverKeys<T> = {
|
| 55 |
+
[k in keyof T]: [T[k]] extends [never] ? never : k;
|
| 56 |
+
}[keyof T];
|
| 57 |
+
export type NoNever<T> = Identity<{
|
| 58 |
+
[k in NoNeverKeys<T>]: k extends keyof T ? T[k] : never;
|
| 59 |
+
}>;
|
| 60 |
+
export type Extend<A extends SomeObject, B extends SomeObject> = Flatten<keyof A & keyof B extends never ? A & B : {
|
| 61 |
+
[K in keyof A as K extends keyof B ? never : K]: A[K];
|
| 62 |
+
} & {
|
| 63 |
+
[K in keyof B]: B[K];
|
| 64 |
+
}>;
|
| 65 |
+
export type TupleItems = ReadonlyArray<schemas.SomeType>;
|
| 66 |
+
export type AnyFunc = (...args: any[]) => any;
|
| 67 |
+
export type IsProp<T, K extends keyof T> = T[K] extends AnyFunc ? never : K;
|
| 68 |
+
export type MaybeAsync<T> = T | Promise<T>;
|
| 69 |
+
export type KeyOf<T> = keyof OmitIndexSignature<T>;
|
| 70 |
+
export type OmitIndexSignature<T> = {
|
| 71 |
+
[K in keyof T as string extends K ? never : K extends string ? K : never]: T[K];
|
| 72 |
+
};
|
| 73 |
+
export type ExtractIndexSignature<T> = {
|
| 74 |
+
[K in keyof T as string extends K ? K : K extends string ? never : K]: T[K];
|
| 75 |
+
};
|
| 76 |
+
export type Keys<T extends object> = keyof OmitIndexSignature<T>;
|
| 77 |
+
export type SchemaClass<T extends schemas.SomeType> = {
|
| 78 |
+
new (def: T["_zod"]["def"]): T;
|
| 79 |
+
};
|
| 80 |
+
export type EnumValue = string | number;
|
| 81 |
+
export type EnumLike = Readonly<Record<string, EnumValue>>;
|
| 82 |
+
export type ToEnum<T extends EnumValue> = Flatten<{
|
| 83 |
+
[k in T]: k;
|
| 84 |
+
}>;
|
| 85 |
+
export type KeysEnum<T extends object> = ToEnum<Exclude<keyof T, symbol>>;
|
| 86 |
+
export type KeysArray<T extends object> = Flatten<(keyof T & string)[]>;
|
| 87 |
+
export type Literal = string | number | bigint | boolean | null | undefined;
|
| 88 |
+
export type LiteralArray = Array<Literal>;
|
| 89 |
+
export type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
| 90 |
+
export type PrimitiveArray = Array<Primitive>;
|
| 91 |
+
export type HasSize = {
|
| 92 |
+
size: number;
|
| 93 |
+
};
|
| 94 |
+
export type HasLength = {
|
| 95 |
+
length: number;
|
| 96 |
+
};
|
| 97 |
+
export type Numeric = number | bigint | Date;
|
| 98 |
+
export type SafeParseResult<T> = SafeParseSuccess<T> | SafeParseError<T>;
|
| 99 |
+
export type SafeParseSuccess<T> = {
|
| 100 |
+
success: true;
|
| 101 |
+
data: T;
|
| 102 |
+
error?: never;
|
| 103 |
+
};
|
| 104 |
+
export type SafeParseError<T> = {
|
| 105 |
+
success: false;
|
| 106 |
+
data?: never;
|
| 107 |
+
error: errors.$ZodError<T>;
|
| 108 |
+
};
|
| 109 |
+
export type PropValues = Record<string, Set<Primitive>>;
|
| 110 |
+
export type PrimitiveSet = Set<Primitive>;
|
| 111 |
+
export declare function assertEqual<A, B>(val: AssertEqual<A, B>): AssertEqual<A, B>;
|
| 112 |
+
export declare function assertNotEqual<A, B>(val: AssertNotEqual<A, B>): AssertNotEqual<A, B>;
|
| 113 |
+
export declare function assertIs<T>(_arg: T): void;
|
| 114 |
+
export declare function assertNever(_x: never): never;
|
| 115 |
+
export declare function assert<T>(_: any): asserts _ is T;
|
| 116 |
+
export declare function getEnumValues(entries: EnumLike): EnumValue[];
|
| 117 |
+
export declare function joinValues<T extends Primitive[]>(array: T, separator?: string): string;
|
| 118 |
+
export declare function jsonStringifyReplacer(_: string, value: any): any;
|
| 119 |
+
export declare function cached<T>(getter: () => T): {
|
| 120 |
+
value: T;
|
| 121 |
+
};
|
| 122 |
+
export declare function nullish(input: any): boolean;
|
| 123 |
+
export declare function cleanRegex(source: string): string;
|
| 124 |
+
export declare function floatSafeRemainder(val: number, step: number): number;
|
| 125 |
+
export declare function defineLazy<T, K extends keyof T>(object: T, key: K, getter: () => T[K]): void;
|
| 126 |
+
export declare function objectClone(obj: object): any;
|
| 127 |
+
export declare function assignProp<T extends object, K extends PropertyKey>(target: T, prop: K, value: K extends keyof T ? T[K] : any): void;
|
| 128 |
+
export declare function mergeDefs(...defs: Record<string, any>[]): any;
|
| 129 |
+
export declare function cloneDef(schema: schemas.$ZodType): any;
|
| 130 |
+
export declare function getElementAtPath(obj: any, path: (string | number)[] | null | undefined): any;
|
| 131 |
+
export declare function promiseAllObject<T extends object>(promisesObj: T): Promise<{
|
| 132 |
+
[k in keyof T]: Awaited<T[k]>;
|
| 133 |
+
}>;
|
| 134 |
+
export declare function randomString(length?: number): string;
|
| 135 |
+
export declare function esc(str: string): string;
|
| 136 |
+
export declare function slugify(input: string): string;
|
| 137 |
+
export declare const captureStackTrace: (targetObject: object, constructorOpt?: Function) => void;
|
| 138 |
+
export declare function isObject(data: any): data is Record<PropertyKey, unknown>;
|
| 139 |
+
export declare const allowsEval: {
|
| 140 |
+
value: boolean;
|
| 141 |
+
};
|
| 142 |
+
export declare function isPlainObject(o: any): o is Record<PropertyKey, unknown>;
|
| 143 |
+
export declare function shallowClone(o: any): any;
|
| 144 |
+
export declare function numKeys(data: any): number;
|
| 145 |
+
export declare const getParsedType: (data: any) => ParsedTypes;
|
| 146 |
+
export declare const propertyKeyTypes: Set<string>;
|
| 147 |
+
export declare const primitiveTypes: Set<string>;
|
| 148 |
+
export declare function escapeRegex(str: string): string;
|
| 149 |
+
export declare function clone<T extends schemas.$ZodType>(inst: T, def?: T["_zod"]["def"], params?: {
|
| 150 |
+
parent: boolean;
|
| 151 |
+
}): T;
|
| 152 |
+
export type EmptyToNever<T> = keyof T extends never ? never : T;
|
| 153 |
+
export type Normalize<T> = T extends undefined ? never : T extends Record<any, any> ? Flatten<{
|
| 154 |
+
[k in keyof Omit<T, "error" | "message">]: T[k];
|
| 155 |
+
} & ("error" extends keyof T ? {
|
| 156 |
+
error?: Exclude<T["error"], string>;
|
| 157 |
+
} : unknown)> : never;
|
| 158 |
+
export declare function normalizeParams<T>(_params: T): Normalize<T>;
|
| 159 |
+
export declare function createTransparentProxy<T extends object>(getter: () => T): T;
|
| 160 |
+
export declare function stringifyPrimitive(value: any): string;
|
| 161 |
+
export declare function optionalKeys(shape: schemas.$ZodShape): string[];
|
| 162 |
+
export type CleanKey<T extends PropertyKey> = T extends `?${infer K}` ? K : T extends `${infer K}?` ? K : T;
|
| 163 |
+
export type ToCleanMap<T extends schemas.$ZodLooseShape> = {
|
| 164 |
+
[k in keyof T]: k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k;
|
| 165 |
+
};
|
| 166 |
+
export type FromCleanMap<T extends schemas.$ZodLooseShape> = {
|
| 167 |
+
[k in keyof T as k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k]: k;
|
| 168 |
+
};
|
| 169 |
+
export declare const NUMBER_FORMAT_RANGES: Record<checks.$ZodNumberFormats, [number, number]>;
|
| 170 |
+
export declare const BIGINT_FORMAT_RANGES: Record<checks.$ZodBigIntFormats, [bigint, bigint]>;
|
| 171 |
+
export declare function pick(schema: schemas.$ZodObject, mask: Record<string, unknown>): any;
|
| 172 |
+
export declare function omit(schema: schemas.$ZodObject, mask: object): any;
|
| 173 |
+
export declare function extend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any;
|
| 174 |
+
export declare function safeExtend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any;
|
| 175 |
+
export declare function merge(a: schemas.$ZodObject, b: schemas.$ZodObject): any;
|
| 176 |
+
export declare function partial(Class: SchemaClass<schemas.$ZodOptional> | null, schema: schemas.$ZodObject, mask: object | undefined): any;
|
| 177 |
+
export declare function required(Class: SchemaClass<schemas.$ZodNonOptional>, schema: schemas.$ZodObject, mask: object | undefined): any;
|
| 178 |
+
export type Constructor<T, Def extends any[] = any[]> = new (...args: Def) => T;
|
| 179 |
+
export declare function aborted(x: schemas.ParsePayload, startIndex?: number): boolean;
|
| 180 |
+
export declare function explicitlyAborted(x: schemas.ParsePayload, startIndex?: number): boolean;
|
| 181 |
+
export declare function prefixIssues(path: PropertyKey, issues: errors.$ZodRawIssue[]): errors.$ZodRawIssue[];
|
| 182 |
+
export declare function unwrapMessage(message: string | {
|
| 183 |
+
message: string;
|
| 184 |
+
} | undefined | null): string | undefined;
|
| 185 |
+
export declare function finalizeIssue(iss: errors.$ZodRawIssue, ctx: schemas.ParseContextInternal | undefined, config: $ZodConfig): errors.$ZodIssue;
|
| 186 |
+
export declare function getSizableOrigin(input: any): "set" | "map" | "file" | "unknown";
|
| 187 |
+
export declare function getLengthableOrigin(input: any): "array" | "string" | "unknown";
|
| 188 |
+
export declare function parsedType(data: unknown): errors.$ZodInvalidTypeExpected;
|
| 189 |
+
export declare function issue(_iss: string, input: any, inst: any): errors.$ZodRawIssue;
|
| 190 |
+
export declare function issue(_iss: errors.$ZodRawIssue): errors.$ZodRawIssue;
|
| 191 |
+
export declare function cleanEnum(obj: Record<string, EnumValue>): EnumValue[];
|
| 192 |
+
export declare function base64ToUint8Array(base64: string): InstanceType<typeof Uint8Array>;
|
| 193 |
+
export declare function uint8ArrayToBase64(bytes: Uint8Array): string;
|
| 194 |
+
export declare function base64urlToUint8Array(base64url: string): InstanceType<typeof Uint8Array>;
|
| 195 |
+
export declare function uint8ArrayToBase64url(bytes: Uint8Array): string;
|
| 196 |
+
export declare function hexToUint8Array(hex: string): InstanceType<typeof Uint8Array>;
|
| 197 |
+
export declare function uint8ArrayToHex(bytes: Uint8Array): string;
|
| 198 |
+
export declare abstract class Class {
|
| 199 |
+
constructor(..._args: any[]);
|
| 200 |
+
}
|
node_modules/zod/v4/core/util.d.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as checks from "./checks.js";
|
| 2 |
+
import type { $ZodConfig } from "./core.js";
|
| 3 |
+
import type * as errors from "./errors.js";
|
| 4 |
+
import type * as schemas from "./schemas.js";
|
| 5 |
+
export type JSONType = string | number | boolean | null | JSONType[] | {
|
| 6 |
+
[key: string]: JSONType;
|
| 7 |
+
};
|
| 8 |
+
export type JWTAlgorithm = "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | (string & {});
|
| 9 |
+
export type HashAlgorithm = "md5" | "sha1" | "sha256" | "sha384" | "sha512";
|
| 10 |
+
export type HashEncoding = "hex" | "base64" | "base64url";
|
| 11 |
+
export type HashFormat = `${HashAlgorithm}_${HashEncoding}`;
|
| 12 |
+
export type IPVersion = "v4" | "v6";
|
| 13 |
+
export type MimeTypes = "application/json" | "application/xml" | "application/x-www-form-urlencoded" | "application/javascript" | "application/pdf" | "application/zip" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/octet-stream" | "application/graphql" | "text/html" | "text/plain" | "text/css" | "text/javascript" | "text/csv" | "image/png" | "image/jpeg" | "image/gif" | "image/svg+xml" | "image/webp" | "audio/mpeg" | "audio/ogg" | "audio/wav" | "audio/webm" | "video/mp4" | "video/webm" | "video/ogg" | "font/woff" | "font/woff2" | "font/ttf" | "font/otf" | "multipart/form-data" | (string & {});
|
| 14 |
+
export type ParsedTypes = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "file" | "date" | "array" | "map" | "set" | "nan" | "null" | "promise";
|
| 15 |
+
export type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
|
| 16 |
+
export type AssertNotEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? false : true;
|
| 17 |
+
export type AssertExtends<T, U> = T extends U ? T : never;
|
| 18 |
+
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
| 19 |
+
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
| 20 |
+
export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
|
| 21 |
+
export type MakePartial<T, K extends keyof T> = Omit<T, K> & InexactPartial<Pick<T, K>>;
|
| 22 |
+
export type MakeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
| 23 |
+
export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
|
| 24 |
+
export type NoUndefined<T> = T extends undefined ? never : T;
|
| 25 |
+
export type Whatever = {} | undefined | null;
|
| 26 |
+
export type LoosePartial<T extends object> = InexactPartial<T> & {
|
| 27 |
+
[k: string]: unknown;
|
| 28 |
+
};
|
| 29 |
+
export type Mask<Keys extends PropertyKey> = {
|
| 30 |
+
[K in Keys]?: true;
|
| 31 |
+
};
|
| 32 |
+
export type Writeable<T> = {
|
| 33 |
+
-readonly [P in keyof T]: T[P];
|
| 34 |
+
} & {};
|
| 35 |
+
export type InexactPartial<T> = {
|
| 36 |
+
[P in keyof T]?: T[P] | undefined;
|
| 37 |
+
};
|
| 38 |
+
export type EmptyObject = Record<string, never>;
|
| 39 |
+
export type BuiltIn = (((...args: any[]) => any) | (new (...args: any[]) => any)) | {
|
| 40 |
+
readonly [Symbol.toStringTag]: string;
|
| 41 |
+
} | Date | Error | Generator | Promise<unknown> | RegExp;
|
| 42 |
+
export type MakeReadonly<T> = T extends Map<infer K, infer V> ? ReadonlyMap<K, V> : T extends Set<infer V> ? ReadonlySet<V> : T extends [infer Head, ...infer Tail] ? readonly [Head, ...Tail] : T extends Array<infer V> ? ReadonlyArray<V> : T extends BuiltIn ? T : Readonly<T>;
|
| 43 |
+
export type SomeObject = Record<PropertyKey, any>;
|
| 44 |
+
export type Identity<T> = T;
|
| 45 |
+
export type Flatten<T> = Identity<{
|
| 46 |
+
[k in keyof T]: T[k];
|
| 47 |
+
}>;
|
| 48 |
+
export type Mapped<T> = {
|
| 49 |
+
[k in keyof T]: T[k];
|
| 50 |
+
};
|
| 51 |
+
export type Prettify<T> = {
|
| 52 |
+
[K in keyof T]: T[K];
|
| 53 |
+
} & {};
|
| 54 |
+
export type NoNeverKeys<T> = {
|
| 55 |
+
[k in keyof T]: [T[k]] extends [never] ? never : k;
|
| 56 |
+
}[keyof T];
|
| 57 |
+
export type NoNever<T> = Identity<{
|
| 58 |
+
[k in NoNeverKeys<T>]: k extends keyof T ? T[k] : never;
|
| 59 |
+
}>;
|
| 60 |
+
export type Extend<A extends SomeObject, B extends SomeObject> = Flatten<keyof A & keyof B extends never ? A & B : {
|
| 61 |
+
[K in keyof A as K extends keyof B ? never : K]: A[K];
|
| 62 |
+
} & {
|
| 63 |
+
[K in keyof B]: B[K];
|
| 64 |
+
}>;
|
| 65 |
+
export type TupleItems = ReadonlyArray<schemas.SomeType>;
|
| 66 |
+
export type AnyFunc = (...args: any[]) => any;
|
| 67 |
+
export type IsProp<T, K extends keyof T> = T[K] extends AnyFunc ? never : K;
|
| 68 |
+
export type MaybeAsync<T> = T | Promise<T>;
|
| 69 |
+
export type KeyOf<T> = keyof OmitIndexSignature<T>;
|
| 70 |
+
export type OmitIndexSignature<T> = {
|
| 71 |
+
[K in keyof T as string extends K ? never : K extends string ? K : never]: T[K];
|
| 72 |
+
};
|
| 73 |
+
export type ExtractIndexSignature<T> = {
|
| 74 |
+
[K in keyof T as string extends K ? K : K extends string ? never : K]: T[K];
|
| 75 |
+
};
|
| 76 |
+
export type Keys<T extends object> = keyof OmitIndexSignature<T>;
|
| 77 |
+
export type SchemaClass<T extends schemas.SomeType> = {
|
| 78 |
+
new (def: T["_zod"]["def"]): T;
|
| 79 |
+
};
|
| 80 |
+
export type EnumValue = string | number;
|
| 81 |
+
export type EnumLike = Readonly<Record<string, EnumValue>>;
|
| 82 |
+
export type ToEnum<T extends EnumValue> = Flatten<{
|
| 83 |
+
[k in T]: k;
|
| 84 |
+
}>;
|
| 85 |
+
export type KeysEnum<T extends object> = ToEnum<Exclude<keyof T, symbol>>;
|
| 86 |
+
export type KeysArray<T extends object> = Flatten<(keyof T & string)[]>;
|
| 87 |
+
export type Literal = string | number | bigint | boolean | null | undefined;
|
| 88 |
+
export type LiteralArray = Array<Literal>;
|
| 89 |
+
export type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
| 90 |
+
export type PrimitiveArray = Array<Primitive>;
|
| 91 |
+
export type HasSize = {
|
| 92 |
+
size: number;
|
| 93 |
+
};
|
| 94 |
+
export type HasLength = {
|
| 95 |
+
length: number;
|
| 96 |
+
};
|
| 97 |
+
export type Numeric = number | bigint | Date;
|
| 98 |
+
export type SafeParseResult<T> = SafeParseSuccess<T> | SafeParseError<T>;
|
| 99 |
+
export type SafeParseSuccess<T> = {
|
| 100 |
+
success: true;
|
| 101 |
+
data: T;
|
| 102 |
+
error?: never;
|
| 103 |
+
};
|
| 104 |
+
export type SafeParseError<T> = {
|
| 105 |
+
success: false;
|
| 106 |
+
data?: never;
|
| 107 |
+
error: errors.$ZodError<T>;
|
| 108 |
+
};
|
| 109 |
+
export type PropValues = Record<string, Set<Primitive>>;
|
| 110 |
+
export type PrimitiveSet = Set<Primitive>;
|
| 111 |
+
export declare function assertEqual<A, B>(val: AssertEqual<A, B>): AssertEqual<A, B>;
|
| 112 |
+
export declare function assertNotEqual<A, B>(val: AssertNotEqual<A, B>): AssertNotEqual<A, B>;
|
| 113 |
+
export declare function assertIs<T>(_arg: T): void;
|
| 114 |
+
export declare function assertNever(_x: never): never;
|
| 115 |
+
export declare function assert<T>(_: any): asserts _ is T;
|
| 116 |
+
export declare function getEnumValues(entries: EnumLike): EnumValue[];
|
| 117 |
+
export declare function joinValues<T extends Primitive[]>(array: T, separator?: string): string;
|
| 118 |
+
export declare function jsonStringifyReplacer(_: string, value: any): any;
|
| 119 |
+
export declare function cached<T>(getter: () => T): {
|
| 120 |
+
value: T;
|
| 121 |
+
};
|
| 122 |
+
export declare function nullish(input: any): boolean;
|
| 123 |
+
export declare function cleanRegex(source: string): string;
|
| 124 |
+
export declare function floatSafeRemainder(val: number, step: number): number;
|
| 125 |
+
export declare function defineLazy<T, K extends keyof T>(object: T, key: K, getter: () => T[K]): void;
|
| 126 |
+
export declare function objectClone(obj: object): any;
|
| 127 |
+
export declare function assignProp<T extends object, K extends PropertyKey>(target: T, prop: K, value: K extends keyof T ? T[K] : any): void;
|
| 128 |
+
export declare function mergeDefs(...defs: Record<string, any>[]): any;
|
| 129 |
+
export declare function cloneDef(schema: schemas.$ZodType): any;
|
| 130 |
+
export declare function getElementAtPath(obj: any, path: (string | number)[] | null | undefined): any;
|
| 131 |
+
export declare function promiseAllObject<T extends object>(promisesObj: T): Promise<{
|
| 132 |
+
[k in keyof T]: Awaited<T[k]>;
|
| 133 |
+
}>;
|
| 134 |
+
export declare function randomString(length?: number): string;
|
| 135 |
+
export declare function esc(str: string): string;
|
| 136 |
+
export declare function slugify(input: string): string;
|
| 137 |
+
export declare const captureStackTrace: (targetObject: object, constructorOpt?: Function) => void;
|
| 138 |
+
export declare function isObject(data: any): data is Record<PropertyKey, unknown>;
|
| 139 |
+
export declare const allowsEval: {
|
| 140 |
+
value: boolean;
|
| 141 |
+
};
|
| 142 |
+
export declare function isPlainObject(o: any): o is Record<PropertyKey, unknown>;
|
| 143 |
+
export declare function shallowClone(o: any): any;
|
| 144 |
+
export declare function numKeys(data: any): number;
|
| 145 |
+
export declare const getParsedType: (data: any) => ParsedTypes;
|
| 146 |
+
export declare const propertyKeyTypes: Set<string>;
|
| 147 |
+
export declare const primitiveTypes: Set<string>;
|
| 148 |
+
export declare function escapeRegex(str: string): string;
|
| 149 |
+
export declare function clone<T extends schemas.$ZodType>(inst: T, def?: T["_zod"]["def"], params?: {
|
| 150 |
+
parent: boolean;
|
| 151 |
+
}): T;
|
| 152 |
+
export type EmptyToNever<T> = keyof T extends never ? never : T;
|
| 153 |
+
export type Normalize<T> = T extends undefined ? never : T extends Record<any, any> ? Flatten<{
|
| 154 |
+
[k in keyof Omit<T, "error" | "message">]: T[k];
|
| 155 |
+
} & ("error" extends keyof T ? {
|
| 156 |
+
error?: Exclude<T["error"], string>;
|
| 157 |
+
} : unknown)> : never;
|
| 158 |
+
export declare function normalizeParams<T>(_params: T): Normalize<T>;
|
| 159 |
+
export declare function createTransparentProxy<T extends object>(getter: () => T): T;
|
| 160 |
+
export declare function stringifyPrimitive(value: any): string;
|
| 161 |
+
export declare function optionalKeys(shape: schemas.$ZodShape): string[];
|
| 162 |
+
export type CleanKey<T extends PropertyKey> = T extends `?${infer K}` ? K : T extends `${infer K}?` ? K : T;
|
| 163 |
+
export type ToCleanMap<T extends schemas.$ZodLooseShape> = {
|
| 164 |
+
[k in keyof T]: k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k;
|
| 165 |
+
};
|
| 166 |
+
export type FromCleanMap<T extends schemas.$ZodLooseShape> = {
|
| 167 |
+
[k in keyof T as k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k]: k;
|
| 168 |
+
};
|
| 169 |
+
export declare const NUMBER_FORMAT_RANGES: Record<checks.$ZodNumberFormats, [number, number]>;
|
| 170 |
+
export declare const BIGINT_FORMAT_RANGES: Record<checks.$ZodBigIntFormats, [bigint, bigint]>;
|
| 171 |
+
export declare function pick(schema: schemas.$ZodObject, mask: Record<string, unknown>): any;
|
| 172 |
+
export declare function omit(schema: schemas.$ZodObject, mask: object): any;
|
| 173 |
+
export declare function extend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any;
|
| 174 |
+
export declare function safeExtend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any;
|
| 175 |
+
export declare function merge(a: schemas.$ZodObject, b: schemas.$ZodObject): any;
|
| 176 |
+
export declare function partial(Class: SchemaClass<schemas.$ZodOptional> | null, schema: schemas.$ZodObject, mask: object | undefined): any;
|
| 177 |
+
export declare function required(Class: SchemaClass<schemas.$ZodNonOptional>, schema: schemas.$ZodObject, mask: object | undefined): any;
|
| 178 |
+
export type Constructor<T, Def extends any[] = any[]> = new (...args: Def) => T;
|
| 179 |
+
export declare function aborted(x: schemas.ParsePayload, startIndex?: number): boolean;
|
| 180 |
+
export declare function explicitlyAborted(x: schemas.ParsePayload, startIndex?: number): boolean;
|
| 181 |
+
export declare function prefixIssues(path: PropertyKey, issues: errors.$ZodRawIssue[]): errors.$ZodRawIssue[];
|
| 182 |
+
export declare function unwrapMessage(message: string | {
|
| 183 |
+
message: string;
|
| 184 |
+
} | undefined | null): string | undefined;
|
| 185 |
+
export declare function finalizeIssue(iss: errors.$ZodRawIssue, ctx: schemas.ParseContextInternal | undefined, config: $ZodConfig): errors.$ZodIssue;
|
| 186 |
+
export declare function getSizableOrigin(input: any): "set" | "map" | "file" | "unknown";
|
| 187 |
+
export declare function getLengthableOrigin(input: any): "array" | "string" | "unknown";
|
| 188 |
+
export declare function parsedType(data: unknown): errors.$ZodInvalidTypeExpected;
|
| 189 |
+
export declare function issue(_iss: string, input: any, inst: any): errors.$ZodRawIssue;
|
| 190 |
+
export declare function issue(_iss: errors.$ZodRawIssue): errors.$ZodRawIssue;
|
| 191 |
+
export declare function cleanEnum(obj: Record<string, EnumValue>): EnumValue[];
|
| 192 |
+
export declare function base64ToUint8Array(base64: string): InstanceType<typeof Uint8Array>;
|
| 193 |
+
export declare function uint8ArrayToBase64(bytes: Uint8Array): string;
|
| 194 |
+
export declare function base64urlToUint8Array(base64url: string): InstanceType<typeof Uint8Array>;
|
| 195 |
+
export declare function uint8ArrayToBase64url(bytes: Uint8Array): string;
|
| 196 |
+
export declare function hexToUint8Array(hex: string): InstanceType<typeof Uint8Array>;
|
| 197 |
+
export declare function uint8ArrayToHex(bytes: Uint8Array): string;
|
| 198 |
+
export declare abstract class Class {
|
| 199 |
+
constructor(..._args: any[]);
|
| 200 |
+
}
|
node_modules/zod/v4/core/util.js
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { globalConfig } from "./core.js";
|
| 2 |
+
// functions
|
| 3 |
+
export function assertEqual(val) {
|
| 4 |
+
return val;
|
| 5 |
+
}
|
| 6 |
+
export function assertNotEqual(val) {
|
| 7 |
+
return val;
|
| 8 |
+
}
|
| 9 |
+
export function assertIs(_arg) { }
|
| 10 |
+
export function assertNever(_x) {
|
| 11 |
+
throw new Error("Unexpected value in exhaustive check");
|
| 12 |
+
}
|
| 13 |
+
export function assert(_) { }
|
| 14 |
+
export function getEnumValues(entries) {
|
| 15 |
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
| 16 |
+
const values = Object.entries(entries)
|
| 17 |
+
.filter(([k, _]) => numericValues.indexOf(+k) === -1)
|
| 18 |
+
.map(([_, v]) => v);
|
| 19 |
+
return values;
|
| 20 |
+
}
|
| 21 |
+
export function joinValues(array, separator = "|") {
|
| 22 |
+
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
| 23 |
+
}
|
| 24 |
+
export function jsonStringifyReplacer(_, value) {
|
| 25 |
+
if (typeof value === "bigint")
|
| 26 |
+
return value.toString();
|
| 27 |
+
return value;
|
| 28 |
+
}
|
| 29 |
+
export function cached(getter) {
|
| 30 |
+
const set = false;
|
| 31 |
+
return {
|
| 32 |
+
get value() {
|
| 33 |
+
if (!set) {
|
| 34 |
+
const value = getter();
|
| 35 |
+
Object.defineProperty(this, "value", { value });
|
| 36 |
+
return value;
|
| 37 |
+
}
|
| 38 |
+
throw new Error("cached value already set");
|
| 39 |
+
},
|
| 40 |
+
};
|
| 41 |
+
}
|
| 42 |
+
export function nullish(input) {
|
| 43 |
+
return input === null || input === undefined;
|
| 44 |
+
}
|
| 45 |
+
export function cleanRegex(source) {
|
| 46 |
+
const start = source.startsWith("^") ? 1 : 0;
|
| 47 |
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
| 48 |
+
return source.slice(start, end);
|
| 49 |
+
}
|
| 50 |
+
export function floatSafeRemainder(val, step) {
|
| 51 |
+
const ratio = val / step;
|
| 52 |
+
const roundedRatio = Math.round(ratio);
|
| 53 |
+
// Use a relative epsilon scaled to the magnitude of the result
|
| 54 |
+
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
| 55 |
+
if (Math.abs(ratio - roundedRatio) < tolerance)
|
| 56 |
+
return 0;
|
| 57 |
+
return ratio - roundedRatio;
|
| 58 |
+
}
|
| 59 |
+
const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
|
| 60 |
+
export function defineLazy(object, key, getter) {
|
| 61 |
+
let value = undefined;
|
| 62 |
+
Object.defineProperty(object, key, {
|
| 63 |
+
get() {
|
| 64 |
+
if (value === EVALUATING) {
|
| 65 |
+
// Circular reference detected, return undefined to break the cycle
|
| 66 |
+
return undefined;
|
| 67 |
+
}
|
| 68 |
+
if (value === undefined) {
|
| 69 |
+
value = EVALUATING;
|
| 70 |
+
value = getter();
|
| 71 |
+
}
|
| 72 |
+
return value;
|
| 73 |
+
},
|
| 74 |
+
set(v) {
|
| 75 |
+
Object.defineProperty(object, key, {
|
| 76 |
+
value: v,
|
| 77 |
+
// configurable: true,
|
| 78 |
+
});
|
| 79 |
+
// object[key] = v;
|
| 80 |
+
},
|
| 81 |
+
configurable: true,
|
| 82 |
+
});
|
| 83 |
+
}
|
| 84 |
+
export function objectClone(obj) {
|
| 85 |
+
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
| 86 |
+
}
|
| 87 |
+
export function assignProp(target, prop, value) {
|
| 88 |
+
Object.defineProperty(target, prop, {
|
| 89 |
+
value,
|
| 90 |
+
writable: true,
|
| 91 |
+
enumerable: true,
|
| 92 |
+
configurable: true,
|
| 93 |
+
});
|
| 94 |
+
}
|
| 95 |
+
export function mergeDefs(...defs) {
|
| 96 |
+
const mergedDescriptors = {};
|
| 97 |
+
for (const def of defs) {
|
| 98 |
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
| 99 |
+
Object.assign(mergedDescriptors, descriptors);
|
| 100 |
+
}
|
| 101 |
+
return Object.defineProperties({}, mergedDescriptors);
|
| 102 |
+
}
|
| 103 |
+
export function cloneDef(schema) {
|
| 104 |
+
return mergeDefs(schema._zod.def);
|
| 105 |
+
}
|
| 106 |
+
export function getElementAtPath(obj, path) {
|
| 107 |
+
if (!path)
|
| 108 |
+
return obj;
|
| 109 |
+
return path.reduce((acc, key) => acc?.[key], obj);
|
| 110 |
+
}
|
| 111 |
+
export function promiseAllObject(promisesObj) {
|
| 112 |
+
const keys = Object.keys(promisesObj);
|
| 113 |
+
const promises = keys.map((key) => promisesObj[key]);
|
| 114 |
+
return Promise.all(promises).then((results) => {
|
| 115 |
+
const resolvedObj = {};
|
| 116 |
+
for (let i = 0; i < keys.length; i++) {
|
| 117 |
+
resolvedObj[keys[i]] = results[i];
|
| 118 |
+
}
|
| 119 |
+
return resolvedObj;
|
| 120 |
+
});
|
| 121 |
+
}
|
| 122 |
+
export function randomString(length = 10) {
|
| 123 |
+
const chars = "abcdefghijklmnopqrstuvwxyz";
|
| 124 |
+
let str = "";
|
| 125 |
+
for (let i = 0; i < length; i++) {
|
| 126 |
+
str += chars[Math.floor(Math.random() * chars.length)];
|
| 127 |
+
}
|
| 128 |
+
return str;
|
| 129 |
+
}
|
| 130 |
+
export function esc(str) {
|
| 131 |
+
return JSON.stringify(str);
|
| 132 |
+
}
|
| 133 |
+
export function slugify(input) {
|
| 134 |
+
return input
|
| 135 |
+
.toLowerCase()
|
| 136 |
+
.trim()
|
| 137 |
+
.replace(/[^\w\s-]/g, "")
|
| 138 |
+
.replace(/[\s_-]+/g, "-")
|
| 139 |
+
.replace(/^-+|-+$/g, "");
|
| 140 |
+
}
|
| 141 |
+
export const captureStackTrace = ("captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => { });
|
| 142 |
+
export function isObject(data) {
|
| 143 |
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
| 144 |
+
}
|
| 145 |
+
export const allowsEval = /* @__PURE__*/ cached(() => {
|
| 146 |
+
// Skip the probe under `jitless`: strict CSPs report the caught `new Function`
|
| 147 |
+
// as a `securitypolicyviolation` even though the throw is swallowed.
|
| 148 |
+
if (globalConfig.jitless) {
|
| 149 |
+
return false;
|
| 150 |
+
}
|
| 151 |
+
// @ts-ignore
|
| 152 |
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
| 153 |
+
return false;
|
| 154 |
+
}
|
| 155 |
+
try {
|
| 156 |
+
const F = Function;
|
| 157 |
+
new F("");
|
| 158 |
+
return true;
|
| 159 |
+
}
|
| 160 |
+
catch (_) {
|
| 161 |
+
return false;
|
| 162 |
+
}
|
| 163 |
+
});
|
| 164 |
+
export function isPlainObject(o) {
|
| 165 |
+
if (isObject(o) === false)
|
| 166 |
+
return false;
|
| 167 |
+
// modified constructor
|
| 168 |
+
const ctor = o.constructor;
|
| 169 |
+
if (ctor === undefined)
|
| 170 |
+
return true;
|
| 171 |
+
if (typeof ctor !== "function")
|
| 172 |
+
return true;
|
| 173 |
+
// modified prototype
|
| 174 |
+
const prot = ctor.prototype;
|
| 175 |
+
if (isObject(prot) === false)
|
| 176 |
+
return false;
|
| 177 |
+
// ctor doesn't have static `isPrototypeOf`
|
| 178 |
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
| 179 |
+
return false;
|
| 180 |
+
}
|
| 181 |
+
return true;
|
| 182 |
+
}
|
| 183 |
+
export function shallowClone(o) {
|
| 184 |
+
if (isPlainObject(o))
|
| 185 |
+
return { ...o };
|
| 186 |
+
if (Array.isArray(o))
|
| 187 |
+
return [...o];
|
| 188 |
+
if (o instanceof Map)
|
| 189 |
+
return new Map(o);
|
| 190 |
+
if (o instanceof Set)
|
| 191 |
+
return new Set(o);
|
| 192 |
+
return o;
|
| 193 |
+
}
|
| 194 |
+
export function numKeys(data) {
|
| 195 |
+
let keyCount = 0;
|
| 196 |
+
for (const key in data) {
|
| 197 |
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
| 198 |
+
keyCount++;
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
return keyCount;
|
| 202 |
+
}
|
| 203 |
+
export const getParsedType = (data) => {
|
| 204 |
+
const t = typeof data;
|
| 205 |
+
switch (t) {
|
| 206 |
+
case "undefined":
|
| 207 |
+
return "undefined";
|
| 208 |
+
case "string":
|
| 209 |
+
return "string";
|
| 210 |
+
case "number":
|
| 211 |
+
return Number.isNaN(data) ? "nan" : "number";
|
| 212 |
+
case "boolean":
|
| 213 |
+
return "boolean";
|
| 214 |
+
case "function":
|
| 215 |
+
return "function";
|
| 216 |
+
case "bigint":
|
| 217 |
+
return "bigint";
|
| 218 |
+
case "symbol":
|
| 219 |
+
return "symbol";
|
| 220 |
+
case "object":
|
| 221 |
+
if (Array.isArray(data)) {
|
| 222 |
+
return "array";
|
| 223 |
+
}
|
| 224 |
+
if (data === null) {
|
| 225 |
+
return "null";
|
| 226 |
+
}
|
| 227 |
+
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
| 228 |
+
return "promise";
|
| 229 |
+
}
|
| 230 |
+
if (typeof Map !== "undefined" && data instanceof Map) {
|
| 231 |
+
return "map";
|
| 232 |
+
}
|
| 233 |
+
if (typeof Set !== "undefined" && data instanceof Set) {
|
| 234 |
+
return "set";
|
| 235 |
+
}
|
| 236 |
+
if (typeof Date !== "undefined" && data instanceof Date) {
|
| 237 |
+
return "date";
|
| 238 |
+
}
|
| 239 |
+
// @ts-ignore
|
| 240 |
+
if (typeof File !== "undefined" && data instanceof File) {
|
| 241 |
+
return "file";
|
| 242 |
+
}
|
| 243 |
+
return "object";
|
| 244 |
+
default:
|
| 245 |
+
throw new Error(`Unknown data type: ${t}`);
|
| 246 |
+
}
|
| 247 |
+
};
|
| 248 |
+
export const propertyKeyTypes = /* @__PURE__*/ new Set(["string", "number", "symbol"]);
|
| 249 |
+
export const primitiveTypes = /* @__PURE__*/ new Set([
|
| 250 |
+
"string",
|
| 251 |
+
"number",
|
| 252 |
+
"bigint",
|
| 253 |
+
"boolean",
|
| 254 |
+
"symbol",
|
| 255 |
+
"undefined",
|
| 256 |
+
]);
|
| 257 |
+
export function escapeRegex(str) {
|
| 258 |
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
| 259 |
+
}
|
| 260 |
+
// zod-specific utils
|
| 261 |
+
export function clone(inst, def, params) {
|
| 262 |
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
| 263 |
+
if (!def || params?.parent)
|
| 264 |
+
cl._zod.parent = inst;
|
| 265 |
+
return cl;
|
| 266 |
+
}
|
| 267 |
+
export function normalizeParams(_params) {
|
| 268 |
+
const params = _params;
|
| 269 |
+
if (!params)
|
| 270 |
+
return {};
|
| 271 |
+
if (typeof params === "string")
|
| 272 |
+
return { error: () => params };
|
| 273 |
+
if (params?.message !== undefined) {
|
| 274 |
+
if (params?.error !== undefined)
|
| 275 |
+
throw new Error("Cannot specify both `message` and `error` params");
|
| 276 |
+
params.error = params.message;
|
| 277 |
+
}
|
| 278 |
+
delete params.message;
|
| 279 |
+
if (typeof params.error === "string")
|
| 280 |
+
return { ...params, error: () => params.error };
|
| 281 |
+
return params;
|
| 282 |
+
}
|
| 283 |
+
export function createTransparentProxy(getter) {
|
| 284 |
+
let target;
|
| 285 |
+
return new Proxy({}, {
|
| 286 |
+
get(_, prop, receiver) {
|
| 287 |
+
target ?? (target = getter());
|
| 288 |
+
return Reflect.get(target, prop, receiver);
|
| 289 |
+
},
|
| 290 |
+
set(_, prop, value, receiver) {
|
| 291 |
+
target ?? (target = getter());
|
| 292 |
+
return Reflect.set(target, prop, value, receiver);
|
| 293 |
+
},
|
| 294 |
+
has(_, prop) {
|
| 295 |
+
target ?? (target = getter());
|
| 296 |
+
return Reflect.has(target, prop);
|
| 297 |
+
},
|
| 298 |
+
deleteProperty(_, prop) {
|
| 299 |
+
target ?? (target = getter());
|
| 300 |
+
return Reflect.deleteProperty(target, prop);
|
| 301 |
+
},
|
| 302 |
+
ownKeys(_) {
|
| 303 |
+
target ?? (target = getter());
|
| 304 |
+
return Reflect.ownKeys(target);
|
| 305 |
+
},
|
| 306 |
+
getOwnPropertyDescriptor(_, prop) {
|
| 307 |
+
target ?? (target = getter());
|
| 308 |
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
| 309 |
+
},
|
| 310 |
+
defineProperty(_, prop, descriptor) {
|
| 311 |
+
target ?? (target = getter());
|
| 312 |
+
return Reflect.defineProperty(target, prop, descriptor);
|
| 313 |
+
},
|
| 314 |
+
});
|
| 315 |
+
}
|
| 316 |
+
export function stringifyPrimitive(value) {
|
| 317 |
+
if (typeof value === "bigint")
|
| 318 |
+
return value.toString() + "n";
|
| 319 |
+
if (typeof value === "string")
|
| 320 |
+
return `"${value}"`;
|
| 321 |
+
return `${value}`;
|
| 322 |
+
}
|
| 323 |
+
export function optionalKeys(shape) {
|
| 324 |
+
return Object.keys(shape).filter((k) => {
|
| 325 |
+
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
| 326 |
+
});
|
| 327 |
+
}
|
| 328 |
+
export const NUMBER_FORMAT_RANGES = {
|
| 329 |
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
| 330 |
+
int32: [-2147483648, 2147483647],
|
| 331 |
+
uint32: [0, 4294967295],
|
| 332 |
+
float32: [-3.4028234663852886e38, 3.4028234663852886e38],
|
| 333 |
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE],
|
| 334 |
+
};
|
| 335 |
+
export const BIGINT_FORMAT_RANGES = {
|
| 336 |
+
int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
|
| 337 |
+
uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")],
|
| 338 |
+
};
|
| 339 |
+
export function pick(schema, mask) {
|
| 340 |
+
const currDef = schema._zod.def;
|
| 341 |
+
const checks = currDef.checks;
|
| 342 |
+
const hasChecks = checks && checks.length > 0;
|
| 343 |
+
if (hasChecks) {
|
| 344 |
+
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
| 345 |
+
}
|
| 346 |
+
const def = mergeDefs(schema._zod.def, {
|
| 347 |
+
get shape() {
|
| 348 |
+
const newShape = {};
|
| 349 |
+
for (const key in mask) {
|
| 350 |
+
if (!(key in currDef.shape)) {
|
| 351 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 352 |
+
}
|
| 353 |
+
if (!mask[key])
|
| 354 |
+
continue;
|
| 355 |
+
newShape[key] = currDef.shape[key];
|
| 356 |
+
}
|
| 357 |
+
assignProp(this, "shape", newShape); // self-caching
|
| 358 |
+
return newShape;
|
| 359 |
+
},
|
| 360 |
+
checks: [],
|
| 361 |
+
});
|
| 362 |
+
return clone(schema, def);
|
| 363 |
+
}
|
| 364 |
+
export function omit(schema, mask) {
|
| 365 |
+
const currDef = schema._zod.def;
|
| 366 |
+
const checks = currDef.checks;
|
| 367 |
+
const hasChecks = checks && checks.length > 0;
|
| 368 |
+
if (hasChecks) {
|
| 369 |
+
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
| 370 |
+
}
|
| 371 |
+
const def = mergeDefs(schema._zod.def, {
|
| 372 |
+
get shape() {
|
| 373 |
+
const newShape = { ...schema._zod.def.shape };
|
| 374 |
+
for (const key in mask) {
|
| 375 |
+
if (!(key in currDef.shape)) {
|
| 376 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 377 |
+
}
|
| 378 |
+
if (!mask[key])
|
| 379 |
+
continue;
|
| 380 |
+
delete newShape[key];
|
| 381 |
+
}
|
| 382 |
+
assignProp(this, "shape", newShape); // self-caching
|
| 383 |
+
return newShape;
|
| 384 |
+
},
|
| 385 |
+
checks: [],
|
| 386 |
+
});
|
| 387 |
+
return clone(schema, def);
|
| 388 |
+
}
|
| 389 |
+
export function extend(schema, shape) {
|
| 390 |
+
if (!isPlainObject(shape)) {
|
| 391 |
+
throw new Error("Invalid input to extend: expected a plain object");
|
| 392 |
+
}
|
| 393 |
+
const checks = schema._zod.def.checks;
|
| 394 |
+
const hasChecks = checks && checks.length > 0;
|
| 395 |
+
if (hasChecks) {
|
| 396 |
+
// Only throw if new shape overlaps with existing shape
|
| 397 |
+
// Use getOwnPropertyDescriptor to check key existence without accessing values
|
| 398 |
+
const existingShape = schema._zod.def.shape;
|
| 399 |
+
for (const key in shape) {
|
| 400 |
+
if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
|
| 401 |
+
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
| 402 |
+
}
|
| 403 |
+
}
|
| 404 |
+
}
|
| 405 |
+
const def = mergeDefs(schema._zod.def, {
|
| 406 |
+
get shape() {
|
| 407 |
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
| 408 |
+
assignProp(this, "shape", _shape); // self-caching
|
| 409 |
+
return _shape;
|
| 410 |
+
},
|
| 411 |
+
});
|
| 412 |
+
return clone(schema, def);
|
| 413 |
+
}
|
| 414 |
+
export function safeExtend(schema, shape) {
|
| 415 |
+
if (!isPlainObject(shape)) {
|
| 416 |
+
throw new Error("Invalid input to safeExtend: expected a plain object");
|
| 417 |
+
}
|
| 418 |
+
const def = mergeDefs(schema._zod.def, {
|
| 419 |
+
get shape() {
|
| 420 |
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
| 421 |
+
assignProp(this, "shape", _shape); // self-caching
|
| 422 |
+
return _shape;
|
| 423 |
+
},
|
| 424 |
+
});
|
| 425 |
+
return clone(schema, def);
|
| 426 |
+
}
|
| 427 |
+
export function merge(a, b) {
|
| 428 |
+
if (a._zod.def.checks?.length) {
|
| 429 |
+
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
| 430 |
+
}
|
| 431 |
+
const def = mergeDefs(a._zod.def, {
|
| 432 |
+
get shape() {
|
| 433 |
+
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
| 434 |
+
assignProp(this, "shape", _shape); // self-caching
|
| 435 |
+
return _shape;
|
| 436 |
+
},
|
| 437 |
+
get catchall() {
|
| 438 |
+
return b._zod.def.catchall;
|
| 439 |
+
},
|
| 440 |
+
checks: b._zod.def.checks ?? [],
|
| 441 |
+
});
|
| 442 |
+
return clone(a, def);
|
| 443 |
+
}
|
| 444 |
+
export function partial(Class, schema, mask) {
|
| 445 |
+
const currDef = schema._zod.def;
|
| 446 |
+
const checks = currDef.checks;
|
| 447 |
+
const hasChecks = checks && checks.length > 0;
|
| 448 |
+
if (hasChecks) {
|
| 449 |
+
throw new Error(".partial() cannot be used on object schemas containing refinements");
|
| 450 |
+
}
|
| 451 |
+
const def = mergeDefs(schema._zod.def, {
|
| 452 |
+
get shape() {
|
| 453 |
+
const oldShape = schema._zod.def.shape;
|
| 454 |
+
const shape = { ...oldShape };
|
| 455 |
+
if (mask) {
|
| 456 |
+
for (const key in mask) {
|
| 457 |
+
if (!(key in oldShape)) {
|
| 458 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 459 |
+
}
|
| 460 |
+
if (!mask[key])
|
| 461 |
+
continue;
|
| 462 |
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
| 463 |
+
shape[key] = Class
|
| 464 |
+
? new Class({
|
| 465 |
+
type: "optional",
|
| 466 |
+
innerType: oldShape[key],
|
| 467 |
+
})
|
| 468 |
+
: oldShape[key];
|
| 469 |
+
}
|
| 470 |
+
}
|
| 471 |
+
else {
|
| 472 |
+
for (const key in oldShape) {
|
| 473 |
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
| 474 |
+
shape[key] = Class
|
| 475 |
+
? new Class({
|
| 476 |
+
type: "optional",
|
| 477 |
+
innerType: oldShape[key],
|
| 478 |
+
})
|
| 479 |
+
: oldShape[key];
|
| 480 |
+
}
|
| 481 |
+
}
|
| 482 |
+
assignProp(this, "shape", shape); // self-caching
|
| 483 |
+
return shape;
|
| 484 |
+
},
|
| 485 |
+
checks: [],
|
| 486 |
+
});
|
| 487 |
+
return clone(schema, def);
|
| 488 |
+
}
|
| 489 |
+
export function required(Class, schema, mask) {
|
| 490 |
+
const def = mergeDefs(schema._zod.def, {
|
| 491 |
+
get shape() {
|
| 492 |
+
const oldShape = schema._zod.def.shape;
|
| 493 |
+
const shape = { ...oldShape };
|
| 494 |
+
if (mask) {
|
| 495 |
+
for (const key in mask) {
|
| 496 |
+
if (!(key in shape)) {
|
| 497 |
+
throw new Error(`Unrecognized key: "${key}"`);
|
| 498 |
+
}
|
| 499 |
+
if (!mask[key])
|
| 500 |
+
continue;
|
| 501 |
+
// overwrite with non-optional
|
| 502 |
+
shape[key] = new Class({
|
| 503 |
+
type: "nonoptional",
|
| 504 |
+
innerType: oldShape[key],
|
| 505 |
+
});
|
| 506 |
+
}
|
| 507 |
+
}
|
| 508 |
+
else {
|
| 509 |
+
for (const key in oldShape) {
|
| 510 |
+
// overwrite with non-optional
|
| 511 |
+
shape[key] = new Class({
|
| 512 |
+
type: "nonoptional",
|
| 513 |
+
innerType: oldShape[key],
|
| 514 |
+
});
|
| 515 |
+
}
|
| 516 |
+
}
|
| 517 |
+
assignProp(this, "shape", shape); // self-caching
|
| 518 |
+
return shape;
|
| 519 |
+
},
|
| 520 |
+
});
|
| 521 |
+
return clone(schema, def);
|
| 522 |
+
}
|
| 523 |
+
// invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom
|
| 524 |
+
export function aborted(x, startIndex = 0) {
|
| 525 |
+
if (x.aborted === true)
|
| 526 |
+
return true;
|
| 527 |
+
for (let i = startIndex; i < x.issues.length; i++) {
|
| 528 |
+
if (x.issues[i]?.continue !== true) {
|
| 529 |
+
return true;
|
| 530 |
+
}
|
| 531 |
+
}
|
| 532 |
+
return false;
|
| 533 |
+
}
|
| 534 |
+
// Checks for explicit abort (continue === false), as opposed to implicit abort (continue === undefined).
|
| 535 |
+
// Used to respect `abort: true` in .refine() even for checks that have a `when` function.
|
| 536 |
+
export function explicitlyAborted(x, startIndex = 0) {
|
| 537 |
+
if (x.aborted === true)
|
| 538 |
+
return true;
|
| 539 |
+
for (let i = startIndex; i < x.issues.length; i++) {
|
| 540 |
+
if (x.issues[i]?.continue === false) {
|
| 541 |
+
return true;
|
| 542 |
+
}
|
| 543 |
+
}
|
| 544 |
+
return false;
|
| 545 |
+
}
|
| 546 |
+
export function prefixIssues(path, issues) {
|
| 547 |
+
return issues.map((iss) => {
|
| 548 |
+
var _a;
|
| 549 |
+
(_a = iss).path ?? (_a.path = []);
|
| 550 |
+
iss.path.unshift(path);
|
| 551 |
+
return iss;
|
| 552 |
+
});
|
| 553 |
+
}
|
| 554 |
+
export function unwrapMessage(message) {
|
| 555 |
+
return typeof message === "string" ? message : message?.message;
|
| 556 |
+
}
|
| 557 |
+
export function finalizeIssue(iss, ctx, config) {
|
| 558 |
+
const message = iss.message
|
| 559 |
+
? iss.message
|
| 560 |
+
: (unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
|
| 561 |
+
unwrapMessage(ctx?.error?.(iss)) ??
|
| 562 |
+
unwrapMessage(config.customError?.(iss)) ??
|
| 563 |
+
unwrapMessage(config.localeError?.(iss)) ??
|
| 564 |
+
"Invalid input");
|
| 565 |
+
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
|
| 566 |
+
rest.path ?? (rest.path = []);
|
| 567 |
+
rest.message = message;
|
| 568 |
+
if (ctx?.reportInput) {
|
| 569 |
+
rest.input = _input;
|
| 570 |
+
}
|
| 571 |
+
return rest;
|
| 572 |
+
}
|
| 573 |
+
export function getSizableOrigin(input) {
|
| 574 |
+
if (input instanceof Set)
|
| 575 |
+
return "set";
|
| 576 |
+
if (input instanceof Map)
|
| 577 |
+
return "map";
|
| 578 |
+
// @ts-ignore
|
| 579 |
+
if (input instanceof File)
|
| 580 |
+
return "file";
|
| 581 |
+
return "unknown";
|
| 582 |
+
}
|
| 583 |
+
export function getLengthableOrigin(input) {
|
| 584 |
+
if (Array.isArray(input))
|
| 585 |
+
return "array";
|
| 586 |
+
if (typeof input === "string")
|
| 587 |
+
return "string";
|
| 588 |
+
return "unknown";
|
| 589 |
+
}
|
| 590 |
+
export function parsedType(data) {
|
| 591 |
+
const t = typeof data;
|
| 592 |
+
switch (t) {
|
| 593 |
+
case "number": {
|
| 594 |
+
return Number.isNaN(data) ? "nan" : "number";
|
| 595 |
+
}
|
| 596 |
+
case "object": {
|
| 597 |
+
if (data === null) {
|
| 598 |
+
return "null";
|
| 599 |
+
}
|
| 600 |
+
if (Array.isArray(data)) {
|
| 601 |
+
return "array";
|
| 602 |
+
}
|
| 603 |
+
const obj = data;
|
| 604 |
+
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
|
| 605 |
+
return obj.constructor.name;
|
| 606 |
+
}
|
| 607 |
+
}
|
| 608 |
+
}
|
| 609 |
+
return t;
|
| 610 |
+
}
|
| 611 |
+
export function issue(...args) {
|
| 612 |
+
const [iss, input, inst] = args;
|
| 613 |
+
if (typeof iss === "string") {
|
| 614 |
+
return {
|
| 615 |
+
message: iss,
|
| 616 |
+
code: "custom",
|
| 617 |
+
input,
|
| 618 |
+
inst,
|
| 619 |
+
};
|
| 620 |
+
}
|
| 621 |
+
return { ...iss };
|
| 622 |
+
}
|
| 623 |
+
export function cleanEnum(obj) {
|
| 624 |
+
return Object.entries(obj)
|
| 625 |
+
.filter(([k, _]) => {
|
| 626 |
+
// return true if NaN, meaning it's not a number, thus a string key
|
| 627 |
+
return Number.isNaN(Number.parseInt(k, 10));
|
| 628 |
+
})
|
| 629 |
+
.map((el) => el[1]);
|
| 630 |
+
}
|
| 631 |
+
// Codec utility functions
|
| 632 |
+
export function base64ToUint8Array(base64) {
|
| 633 |
+
const binaryString = atob(base64);
|
| 634 |
+
const bytes = new Uint8Array(binaryString.length);
|
| 635 |
+
for (let i = 0; i < binaryString.length; i++) {
|
| 636 |
+
bytes[i] = binaryString.charCodeAt(i);
|
| 637 |
+
}
|
| 638 |
+
return bytes;
|
| 639 |
+
}
|
| 640 |
+
export function uint8ArrayToBase64(bytes) {
|
| 641 |
+
let binaryString = "";
|
| 642 |
+
for (let i = 0; i < bytes.length; i++) {
|
| 643 |
+
binaryString += String.fromCharCode(bytes[i]);
|
| 644 |
+
}
|
| 645 |
+
return btoa(binaryString);
|
| 646 |
+
}
|
| 647 |
+
export function base64urlToUint8Array(base64url) {
|
| 648 |
+
const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
|
| 649 |
+
const padding = "=".repeat((4 - (base64.length % 4)) % 4);
|
| 650 |
+
return base64ToUint8Array(base64 + padding);
|
| 651 |
+
}
|
| 652 |
+
export function uint8ArrayToBase64url(bytes) {
|
| 653 |
+
return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
| 654 |
+
}
|
| 655 |
+
export function hexToUint8Array(hex) {
|
| 656 |
+
const cleanHex = hex.replace(/^0x/, "");
|
| 657 |
+
if (cleanHex.length % 2 !== 0) {
|
| 658 |
+
throw new Error("Invalid hex string length");
|
| 659 |
+
}
|
| 660 |
+
const bytes = new Uint8Array(cleanHex.length / 2);
|
| 661 |
+
for (let i = 0; i < cleanHex.length; i += 2) {
|
| 662 |
+
bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
|
| 663 |
+
}
|
| 664 |
+
return bytes;
|
| 665 |
+
}
|
| 666 |
+
export function uint8ArrayToHex(bytes) {
|
| 667 |
+
return Array.from(bytes)
|
| 668 |
+
.map((b) => b.toString(16).padStart(2, "0"))
|
| 669 |
+
.join("");
|
| 670 |
+
}
|
| 671 |
+
// instanceof
|
| 672 |
+
export class Class {
|
| 673 |
+
constructor(..._args) { }
|
| 674 |
+
}
|
node_modules/zod/v4/core/versions.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.version = void 0;
|
| 4 |
+
exports.version = {
|
| 5 |
+
major: 4,
|
| 6 |
+
minor: 4,
|
| 7 |
+
patch: 3,
|
| 8 |
+
};
|
node_modules/zod/v4/core/versions.d.cts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export declare const version: {
|
| 2 |
+
readonly major: 4;
|
| 3 |
+
readonly minor: 4;
|
| 4 |
+
readonly patch: number;
|
| 5 |
+
};
|
node_modules/zod/v4/core/versions.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export declare const version: {
|
| 2 |
+
readonly major: 4;
|
| 3 |
+
readonly minor: 4;
|
| 4 |
+
readonly patch: number;
|
| 5 |
+
};
|
node_modules/zod/v4/core/versions.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export const version = {
|
| 2 |
+
major: 4,
|
| 3 |
+
minor: 4,
|
| 4 |
+
patch: 3,
|
| 5 |
+
};
|
node_modules/zod/v4/index.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 3 |
+
if (k2 === undefined) k2 = k;
|
| 4 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 5 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 6 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 7 |
+
}
|
| 8 |
+
Object.defineProperty(o, k2, desc);
|
| 9 |
+
}) : (function(o, m, k, k2) {
|
| 10 |
+
if (k2 === undefined) k2 = k;
|
| 11 |
+
o[k2] = m[k];
|
| 12 |
+
}));
|
| 13 |
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
| 14 |
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
| 15 |
+
};
|
| 16 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 17 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 18 |
+
};
|
| 19 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 20 |
+
const index_js_1 = __importDefault(require("./classic/index.cjs"));
|
| 21 |
+
__exportStar(require("./classic/index.cjs"), exports);
|
| 22 |
+
exports.default = index_js_1.default;
|
node_modules/zod/v4/index.d.cts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import z4 from "./classic/index.cjs";
|
| 2 |
+
export * from "./classic/index.cjs";
|
| 3 |
+
export default z4;
|
node_modules/zod/v4/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import z4 from "./classic/index.js";
|
| 2 |
+
export * from "./classic/index.js";
|
| 3 |
+
export default z4;
|
node_modules/zod/v4/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import z4 from "./classic/index.js";
|
| 2 |
+
export * from "./classic/index.js";
|
| 3 |
+
export default z4;
|