@bylqwjc/media-editor-video 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +55 -0
- package/dist/chunk-EK7ODJWE.js +1 -0
- package/dist/index-CX2iAapm.d.ts +51 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +2273 -0
- package/dist/lazy.d.ts +7 -0
- package/dist/lazy.js +1 -0
- package/dist/legacy.js +65 -0
- package/node_modules/@media-editor/client/LICENSE +21 -0
- package/node_modules/@media-editor/client/README.md +27 -0
- package/node_modules/@media-editor/client/dist/index.d.ts +24 -0
- package/node_modules/@media-editor/client/dist/index.js +1 -0
- package/node_modules/@media-editor/client/package.json +22 -0
- package/node_modules/@media-editor/core/LICENSE +21 -0
- package/node_modules/@media-editor/core/README.md +14 -0
- package/node_modules/@media-editor/core/dist/browser.d.ts +100 -0
- package/node_modules/@media-editor/core/dist/browser.js +3 -0
- package/node_modules/@media-editor/core/dist/chunk-MGKYVYOH.js +1 -0
- package/node_modules/@media-editor/core/dist/chunk-USY6UDGL.js +1 -0
- package/node_modules/@media-editor/core/dist/chunk-XCBM7P7N.js +1 -0
- package/node_modules/@media-editor/core/dist/engine.d.ts +359 -0
- package/node_modules/@media-editor/core/dist/engine.js +1 -0
- package/node_modules/@media-editor/core/dist/index.d.ts +264 -0
- package/node_modules/@media-editor/core/dist/index.js +1 -0
- package/node_modules/@media-editor/core/dist/platform-presets-B-o4C6uY.d.ts +80 -0
- package/node_modules/@media-editor/core/dist/state-B85vkf7_.d.ts +1027 -0
- package/node_modules/@media-editor/core/node_modules/zod/LICENSE +21 -0
- package/node_modules/@media-editor/core/node_modules/zod/README.md +208 -0
- package/node_modules/@media-editor/core/node_modules/zod/index.d.cts +4 -0
- package/node_modules/@media-editor/core/node_modules/zod/index.js +1 -0
- package/node_modules/@media-editor/core/node_modules/zod/package.json +74 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/ZodError.d.cts +164 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/ZodError.js +1 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/errors.d.cts +5 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/errors.js +1 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/external.d.cts +6 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/external.js +1 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/helpers/enumUtil.js +0 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/helpers/errorUtil.js +1 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/helpers/parseUtil.js +1 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/helpers/partialUtil.js +0 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/helpers/typeAliases.js +0 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/helpers/util.d.cts +85 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/helpers/util.js +1 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/index.d.cts +4 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/index.js +1 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/locales/en.d.cts +3 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/locales/en.js +1 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/standard-schema.d.cts +102 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/standard-schema.js +0 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/types.d.cts +1031 -0
- package/node_modules/@media-editor/core/node_modules/zod/v3/types.js +1 -0
- package/node_modules/@media-editor/core/package.json +34 -0
- package/package.json +33 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Colin McDonnell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="logo.svg" width="200px" align="center" alt="Zod logo" />
|
|
3
|
+
<h1 align="center">Zod</h1>
|
|
4
|
+
<p align="center">
|
|
5
|
+
TypeScript-first schema validation with static type inference
|
|
6
|
+
<br/>
|
|
7
|
+
by <a href="https://x.com/colinhacks">@colinhacks</a>
|
|
8
|
+
</p>
|
|
9
|
+
</p>
|
|
10
|
+
<br/>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://github.com/colinhacks/zod/actions?query=branch%3Amaster"><img src="https://github.com/colinhacks/zod/actions/workflows/test.yml/badge.svg?event=push&branch=master" alt="Zod CI status" /></a>
|
|
14
|
+
<a href="https://opensource.org/licenses/MIT" rel="nofollow"><img src="https://img.shields.io/github/license/colinhacks/zod" alt="License"></a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/zod" rel="nofollow"><img src="https://img.shields.io/npm/dw/zod.svg" alt="npm"></a>
|
|
16
|
+
<a href="https://discord.gg/KaSRdyX2vc" rel="nofollow"><img src="https://img.shields.io/discord/893487829802418277?label=Discord&logo=discord&logoColor=white" alt="discord server"></a>
|
|
17
|
+
<a href="https://github.com/colinhacks/zod" rel="nofollow"><img src="https://img.shields.io/github/stars/colinhacks/zod" alt="stars"></a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<div align="center">
|
|
21
|
+
<a href="https://zod.dev/api">Docs</a>
|
|
22
|
+
<span> • </span>
|
|
23
|
+
<a href="https://discord.gg/RcG33DQJdf">Discord</a>
|
|
24
|
+
<span> • </span>
|
|
25
|
+
<a href="https://twitter.com/colinhacks">𝕏</a>
|
|
26
|
+
<span> • </span>
|
|
27
|
+
<a href="https://bsky.app/profile/zod.dev">Bluesky</a>
|
|
28
|
+
<br />
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<br/>
|
|
32
|
+
<br/>
|
|
33
|
+
|
|
34
|
+
<h2 align="center">Featured sponsor: Jazz</h2>
|
|
35
|
+
|
|
36
|
+
<div align="center">
|
|
37
|
+
<a href="https://jazz.tools/?utm_source=zod">
|
|
38
|
+
<picture width="85%" >
|
|
39
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/garden-co/jazz/938f6767e46cdfded60e50d99bf3b533f4809c68/homepage/homepage/public/Zod%20sponsor%20message.png">
|
|
40
|
+
<img alt="jazz logo" src="https://raw.githubusercontent.com/garden-co/jazz/938f6767e46cdfded60e50d99bf3b533f4809c68/homepage/homepage/public/Zod%20sponsor%20message.png" width="85%">
|
|
41
|
+
</picture>
|
|
42
|
+
</a>
|
|
43
|
+
<br/>
|
|
44
|
+
<p><sub>Learn more about <a target="_blank" rel="noopener noreferrer" href="mailto:sponsorship@colinhacks.com">featured sponsorships</a></sub></p>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<br/>
|
|
48
|
+
<br/>
|
|
49
|
+
<br/>
|
|
50
|
+
|
|
51
|
+
### [Read the docs →](https://zod.dev/api)
|
|
52
|
+
|
|
53
|
+
<br/>
|
|
54
|
+
<br/>
|
|
55
|
+
|
|
56
|
+
## What is Zod?
|
|
57
|
+
|
|
58
|
+
Zod is a TypeScript-first validation library. Define a schema and parse some data with it. You'll get back a strongly typed, validated result.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import * as z from "zod/v4";
|
|
62
|
+
|
|
63
|
+
const User = z.object({
|
|
64
|
+
name: z.string(),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// some untrusted data...
|
|
68
|
+
const input = {
|
|
69
|
+
/* stuff */
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// the parsed result is validated and type safe!
|
|
73
|
+
const data = User.parse(input);
|
|
74
|
+
|
|
75
|
+
// so you can use it with confidence :)
|
|
76
|
+
console.log(data.name);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
<br/>
|
|
80
|
+
|
|
81
|
+
## Features
|
|
82
|
+
|
|
83
|
+
- Zero external dependencies
|
|
84
|
+
- Works in Node.js and all modern browsers
|
|
85
|
+
- Tiny: `2kb` core bundle (gzipped)
|
|
86
|
+
- Immutable API: methods return a new instance
|
|
87
|
+
- Concise interface
|
|
88
|
+
- Works with TypeScript and plain JS
|
|
89
|
+
- Built-in JSON Schema conversion
|
|
90
|
+
- Extensive ecosystem
|
|
91
|
+
|
|
92
|
+
<br/>
|
|
93
|
+
|
|
94
|
+
## Installation
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
npm install zod
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
<br/>
|
|
101
|
+
|
|
102
|
+
## Basic usage
|
|
103
|
+
|
|
104
|
+
Before you can do anything else, you need to define a schema. For the purposes of this guide, we'll use a simple object schema.
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import * as z from "zod/v4";
|
|
108
|
+
|
|
109
|
+
const Player = z.object({
|
|
110
|
+
username: z.string(),
|
|
111
|
+
xp: z.number(),
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Parsing data
|
|
116
|
+
|
|
117
|
+
Given any Zod schema, use `.parse` to validate an input. If it's valid, Zod returns a strongly-typed _deep clone_ of the input.
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
Player.parse({ username: "billie", xp: 100 });
|
|
121
|
+
// => returns { username: "billie", xp: 100 }
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Note** — If your schema uses certain asynchronous APIs like `async` [refinements](#refine) or [transforms](#transform), you'll need to use the `.parseAsync()` method instead.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
const schema = z.string().refine(async (val) => val.length <= 8);
|
|
128
|
+
|
|
129
|
+
await schema.parseAsync("hello");
|
|
130
|
+
// => "hello"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Handling errors
|
|
134
|
+
|
|
135
|
+
When validation fails, the `.parse()` method will throw a `ZodError` instance with granular information about the validation issues.
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
try {
|
|
139
|
+
Player.parse({ username: 42, xp: "100" });
|
|
140
|
+
} catch (err) {
|
|
141
|
+
if (err instanceof z.ZodError) {
|
|
142
|
+
err.issues;
|
|
143
|
+
/* [
|
|
144
|
+
{
|
|
145
|
+
expected: 'string',
|
|
146
|
+
code: 'invalid_type',
|
|
147
|
+
path: [ 'username' ],
|
|
148
|
+
message: 'Invalid input: expected string'
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
expected: 'number',
|
|
152
|
+
code: 'invalid_type',
|
|
153
|
+
path: [ 'xp' ],
|
|
154
|
+
message: 'Invalid input: expected number'
|
|
155
|
+
}
|
|
156
|
+
] */
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
To avoid a `try/catch` block, you can use the `.safeParse()` method to get back a plain result object containing either the successfully parsed data or a `ZodError`. The result type is a [discriminated union](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions), so you can handle both cases conveniently.
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
const result = Player.safeParse({ username: 42, xp: "100" });
|
|
165
|
+
if (!result.success) {
|
|
166
|
+
result.error; // ZodError instance
|
|
167
|
+
} else {
|
|
168
|
+
result.data; // { username: string; xp: number }
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Note** — If your schema uses certain asynchronous APIs like `async` [refinements](#refine) or [transforms](#transform), you'll need to use the `.safeParseAsync()` method instead.
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
const schema = z.string().refine(async (val) => val.length <= 8);
|
|
176
|
+
|
|
177
|
+
await schema.safeParseAsync("hello");
|
|
178
|
+
// => { success: true; data: "hello" }
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Inferring types
|
|
182
|
+
|
|
183
|
+
Zod infers a static type from your schema definitions. You can extract this type with the `z.infer<>` utility and use it however you like.
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
const Player = z.object({
|
|
187
|
+
username: z.string(),
|
|
188
|
+
xp: z.number(),
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// extract the inferred type
|
|
192
|
+
type Player = z.infer<typeof Player>;
|
|
193
|
+
|
|
194
|
+
// use it in your code
|
|
195
|
+
const player: Player = { username: "billie", xp: 100 };
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
In some cases, the input & output types of a schema can diverge. For instance, the `.transform()` API can convert the input from one type to another. In these cases, you can extract the input and output types independently:
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
const mySchema = z.string().transform((val) => val.length);
|
|
202
|
+
|
|
203
|
+
type MySchemaIn = z.input<typeof mySchema>;
|
|
204
|
+
// => string
|
|
205
|
+
|
|
206
|
+
type MySchemaOut = z.output<typeof mySchema>; // equivalent to z.infer<typeof mySchema>
|
|
207
|
+
// number
|
|
208
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as o from"./v3/external.js";export*from"./v3/external.js";var r=o;export{r as default,o as z};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zod",
|
|
3
|
+
"version": "3.25.76",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"author": "Colin McDonnell <zod@colinhacks.com>",
|
|
6
|
+
"description": "TypeScript-first schema declaration and validation library with static type inference",
|
|
7
|
+
"files": [
|
|
8
|
+
"src",
|
|
9
|
+
"**/*.js",
|
|
10
|
+
"**/*.mjs",
|
|
11
|
+
"**/*.cjs",
|
|
12
|
+
"**/*.d.ts",
|
|
13
|
+
"**/*.d.mts",
|
|
14
|
+
"**/*.d.cts"
|
|
15
|
+
],
|
|
16
|
+
"funding": "https://github.com/sponsors/colinhacks",
|
|
17
|
+
"homepage": "https://zod.dev",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"typescript",
|
|
20
|
+
"schema",
|
|
21
|
+
"validation",
|
|
22
|
+
"type",
|
|
23
|
+
"inference"
|
|
24
|
+
],
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "./index.js",
|
|
28
|
+
"types": "./index.d.cts",
|
|
29
|
+
"module": "./index.js",
|
|
30
|
+
"zshy": {
|
|
31
|
+
"exports": {
|
|
32
|
+
"./package.json": "./package.json",
|
|
33
|
+
".": "./src/index.ts",
|
|
34
|
+
"./v3": "./src/v3/index.ts"
|
|
35
|
+
},
|
|
36
|
+
"sourceDialects": [
|
|
37
|
+
"@zod/source"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"exports": {
|
|
41
|
+
"./package.json": "./package.json",
|
|
42
|
+
".": {
|
|
43
|
+
"@zod/source": "./src/index.ts",
|
|
44
|
+
"types": "./index.d.cts",
|
|
45
|
+
"import": "./index.js"
|
|
46
|
+
},
|
|
47
|
+
"./v3": {
|
|
48
|
+
"@zod/source": "./src/v3/index.ts",
|
|
49
|
+
"types": "./v3/index.d.cts",
|
|
50
|
+
"import": "./v3/index.js"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/colinhacks/zod.git"
|
|
56
|
+
},
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/colinhacks/zod/issues"
|
|
59
|
+
},
|
|
60
|
+
"support": {
|
|
61
|
+
"backing": {
|
|
62
|
+
"npm-funding": true
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"clean": "git clean -xdf . -e node_modules",
|
|
67
|
+
"build": "zshy --project tsconfig.build.json",
|
|
68
|
+
"postbuild": "pnpm biome check --write .",
|
|
69
|
+
"test:watch": "pnpm vitest",
|
|
70
|
+
"test": "pnpm vitest run",
|
|
71
|
+
"bump:beta": "pnpm version \"v$(pnpm pkg get version | jq -r)-beta.$(date +%Y%m%dT%H%M%S)\"",
|
|
72
|
+
"pub:beta": "pnpm bump:beta && pnpm publish --tag next --publish-branch v4 --no-git-checks --dry-run"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { Primitive } from "./helpers/typeAliases.cjs";
|
|
2
|
+
import { util, type ZodParsedType } from "./helpers/util.cjs";
|
|
3
|
+
import type { TypeOf, ZodType } from "./index.cjs";
|
|
4
|
+
type allKeys<T> = T extends any ? keyof T : never;
|
|
5
|
+
export type inferFlattenedErrors<T extends ZodType<any, any, any>, U = string> = typeToFlattenedError<TypeOf<T>, U>;
|
|
6
|
+
export type typeToFlattenedError<T, U = string> = {
|
|
7
|
+
formErrors: U[];
|
|
8
|
+
fieldErrors: {
|
|
9
|
+
[P in allKeys<T>]?: U[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare const ZodIssueCode: {
|
|
13
|
+
invalid_type: "invalid_type";
|
|
14
|
+
invalid_literal: "invalid_literal";
|
|
15
|
+
custom: "custom";
|
|
16
|
+
invalid_union: "invalid_union";
|
|
17
|
+
invalid_union_discriminator: "invalid_union_discriminator";
|
|
18
|
+
invalid_enum_value: "invalid_enum_value";
|
|
19
|
+
unrecognized_keys: "unrecognized_keys";
|
|
20
|
+
invalid_arguments: "invalid_arguments";
|
|
21
|
+
invalid_return_type: "invalid_return_type";
|
|
22
|
+
invalid_date: "invalid_date";
|
|
23
|
+
invalid_string: "invalid_string";
|
|
24
|
+
too_small: "too_small";
|
|
25
|
+
too_big: "too_big";
|
|
26
|
+
invalid_intersection_types: "invalid_intersection_types";
|
|
27
|
+
not_multiple_of: "not_multiple_of";
|
|
28
|
+
not_finite: "not_finite";
|
|
29
|
+
};
|
|
30
|
+
export type ZodIssueCode = keyof typeof ZodIssueCode;
|
|
31
|
+
export type ZodIssueBase = {
|
|
32
|
+
path: (string | number)[];
|
|
33
|
+
message?: string | undefined;
|
|
34
|
+
};
|
|
35
|
+
export interface ZodInvalidTypeIssue extends ZodIssueBase {
|
|
36
|
+
code: typeof ZodIssueCode.invalid_type;
|
|
37
|
+
expected: ZodParsedType;
|
|
38
|
+
received: ZodParsedType;
|
|
39
|
+
}
|
|
40
|
+
export interface ZodInvalidLiteralIssue extends ZodIssueBase {
|
|
41
|
+
code: typeof ZodIssueCode.invalid_literal;
|
|
42
|
+
expected: unknown;
|
|
43
|
+
received: unknown;
|
|
44
|
+
}
|
|
45
|
+
export interface ZodUnrecognizedKeysIssue extends ZodIssueBase {
|
|
46
|
+
code: typeof ZodIssueCode.unrecognized_keys;
|
|
47
|
+
keys: string[];
|
|
48
|
+
}
|
|
49
|
+
export interface ZodInvalidUnionIssue extends ZodIssueBase {
|
|
50
|
+
code: typeof ZodIssueCode.invalid_union;
|
|
51
|
+
unionErrors: ZodError[];
|
|
52
|
+
}
|
|
53
|
+
export interface ZodInvalidUnionDiscriminatorIssue extends ZodIssueBase {
|
|
54
|
+
code: typeof ZodIssueCode.invalid_union_discriminator;
|
|
55
|
+
options: Primitive[];
|
|
56
|
+
}
|
|
57
|
+
export interface ZodInvalidEnumValueIssue extends ZodIssueBase {
|
|
58
|
+
received: string | number;
|
|
59
|
+
code: typeof ZodIssueCode.invalid_enum_value;
|
|
60
|
+
options: (string | number)[];
|
|
61
|
+
}
|
|
62
|
+
export interface ZodInvalidArgumentsIssue extends ZodIssueBase {
|
|
63
|
+
code: typeof ZodIssueCode.invalid_arguments;
|
|
64
|
+
argumentsError: ZodError;
|
|
65
|
+
}
|
|
66
|
+
export interface ZodInvalidReturnTypeIssue extends ZodIssueBase {
|
|
67
|
+
code: typeof ZodIssueCode.invalid_return_type;
|
|
68
|
+
returnTypeError: ZodError;
|
|
69
|
+
}
|
|
70
|
+
export interface ZodInvalidDateIssue extends ZodIssueBase {
|
|
71
|
+
code: typeof ZodIssueCode.invalid_date;
|
|
72
|
+
}
|
|
73
|
+
export type StringValidation = "email" | "url" | "emoji" | "uuid" | "nanoid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "date" | "time" | "duration" | "ip" | "cidr" | "base64" | "jwt" | "base64url" | {
|
|
74
|
+
includes: string;
|
|
75
|
+
position?: number | undefined;
|
|
76
|
+
} | {
|
|
77
|
+
startsWith: string;
|
|
78
|
+
} | {
|
|
79
|
+
endsWith: string;
|
|
80
|
+
};
|
|
81
|
+
export interface ZodInvalidStringIssue extends ZodIssueBase {
|
|
82
|
+
code: typeof ZodIssueCode.invalid_string;
|
|
83
|
+
validation: StringValidation;
|
|
84
|
+
}
|
|
85
|
+
export interface ZodTooSmallIssue extends ZodIssueBase {
|
|
86
|
+
code: typeof ZodIssueCode.too_small;
|
|
87
|
+
minimum: number | bigint;
|
|
88
|
+
inclusive: boolean;
|
|
89
|
+
exact?: boolean;
|
|
90
|
+
type: "array" | "string" | "number" | "set" | "date" | "bigint";
|
|
91
|
+
}
|
|
92
|
+
export interface ZodTooBigIssue extends ZodIssueBase {
|
|
93
|
+
code: typeof ZodIssueCode.too_big;
|
|
94
|
+
maximum: number | bigint;
|
|
95
|
+
inclusive: boolean;
|
|
96
|
+
exact?: boolean;
|
|
97
|
+
type: "array" | "string" | "number" | "set" | "date" | "bigint";
|
|
98
|
+
}
|
|
99
|
+
export interface ZodInvalidIntersectionTypesIssue extends ZodIssueBase {
|
|
100
|
+
code: typeof ZodIssueCode.invalid_intersection_types;
|
|
101
|
+
}
|
|
102
|
+
export interface ZodNotMultipleOfIssue extends ZodIssueBase {
|
|
103
|
+
code: typeof ZodIssueCode.not_multiple_of;
|
|
104
|
+
multipleOf: number | bigint;
|
|
105
|
+
}
|
|
106
|
+
export interface ZodNotFiniteIssue extends ZodIssueBase {
|
|
107
|
+
code: typeof ZodIssueCode.not_finite;
|
|
108
|
+
}
|
|
109
|
+
export interface ZodCustomIssue extends ZodIssueBase {
|
|
110
|
+
code: typeof ZodIssueCode.custom;
|
|
111
|
+
params?: {
|
|
112
|
+
[k: string]: any;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export type DenormalizedError = {
|
|
116
|
+
[k: string]: DenormalizedError | string[];
|
|
117
|
+
};
|
|
118
|
+
export type ZodIssueOptionalMessage = ZodInvalidTypeIssue | ZodInvalidLiteralIssue | ZodUnrecognizedKeysIssue | ZodInvalidUnionIssue | ZodInvalidUnionDiscriminatorIssue | ZodInvalidEnumValueIssue | ZodInvalidArgumentsIssue | ZodInvalidReturnTypeIssue | ZodInvalidDateIssue | ZodInvalidStringIssue | ZodTooSmallIssue | ZodTooBigIssue | ZodInvalidIntersectionTypesIssue | ZodNotMultipleOfIssue | ZodNotFiniteIssue | ZodCustomIssue;
|
|
119
|
+
export type ZodIssue = ZodIssueOptionalMessage & {
|
|
120
|
+
fatal?: boolean | undefined;
|
|
121
|
+
message: string;
|
|
122
|
+
};
|
|
123
|
+
export declare const quotelessJson: (obj: any) => string;
|
|
124
|
+
type recursiveZodFormattedError<T> = T extends [any, ...any[]] ? {
|
|
125
|
+
[K in keyof T]?: ZodFormattedError<T[K]>;
|
|
126
|
+
} : T extends any[] ? {
|
|
127
|
+
[k: number]: ZodFormattedError<T[number]>;
|
|
128
|
+
} : T extends object ? {
|
|
129
|
+
[K in keyof T]?: ZodFormattedError<T[K]>;
|
|
130
|
+
} : unknown;
|
|
131
|
+
export type ZodFormattedError<T, U = string> = {
|
|
132
|
+
_errors: U[];
|
|
133
|
+
} & recursiveZodFormattedError<NonNullable<T>>;
|
|
134
|
+
export type inferFormattedError<T extends ZodType<any, any, any>, U = string> = ZodFormattedError<TypeOf<T>, U>;
|
|
135
|
+
export declare class ZodError<T = any> extends Error {
|
|
136
|
+
issues: ZodIssue[];
|
|
137
|
+
get errors(): ZodIssue[];
|
|
138
|
+
constructor(issues: ZodIssue[]);
|
|
139
|
+
format(): ZodFormattedError<T>;
|
|
140
|
+
format<U>(mapper: (issue: ZodIssue) => U): ZodFormattedError<T, U>;
|
|
141
|
+
static create: (issues: ZodIssue[]) => ZodError<any>;
|
|
142
|
+
static assert(value: unknown): asserts value is ZodError;
|
|
143
|
+
toString(): string;
|
|
144
|
+
get message(): string;
|
|
145
|
+
get isEmpty(): boolean;
|
|
146
|
+
addIssue: (sub: ZodIssue) => void;
|
|
147
|
+
addIssues: (subs?: ZodIssue[]) => void;
|
|
148
|
+
flatten(): typeToFlattenedError<T>;
|
|
149
|
+
flatten<U>(mapper?: (issue: ZodIssue) => U): typeToFlattenedError<T, U>;
|
|
150
|
+
get formErrors(): typeToFlattenedError<T, string>;
|
|
151
|
+
}
|
|
152
|
+
type stripPath<T extends object> = T extends any ? util.OmitKeys<T, "path"> : never;
|
|
153
|
+
export type IssueData = stripPath<ZodIssueOptionalMessage> & {
|
|
154
|
+
path?: (string | number)[];
|
|
155
|
+
fatal?: boolean | undefined;
|
|
156
|
+
};
|
|
157
|
+
export type ErrorMapCtx = {
|
|
158
|
+
defaultError: string;
|
|
159
|
+
data: any;
|
|
160
|
+
};
|
|
161
|
+
export type ZodErrorMap = (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => {
|
|
162
|
+
message: string;
|
|
163
|
+
};
|
|
164
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{util as h}from"./helpers/util.js";const d=h.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),f=c=>JSON.stringify(c,null,2).replace(/"([^"]+)":/g,"$1:");class l extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const s=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,s):this.__proto__=s,this.name="ZodError",this.issues=t}format(t){const s=t||function(o){return o.message},e={_errors:[]},i=o=>{for(const r of o.issues)if(r.code==="invalid_union")r.unionErrors.map(i);else if(r.code==="invalid_return_type")i(r.returnTypeError);else if(r.code==="invalid_arguments")i(r.argumentsError);else if(r.path.length===0)e._errors.push(s(r));else{let n=e,a=0;for(;a<r.path.length;){const u=r.path[a];a===r.path.length-1?(n[u]=n[u]||{_errors:[]},n[u]._errors.push(s(r))):n[u]=n[u]||{_errors:[]},n=n[u],a++}}};return i(this),e}static assert(t){if(!(t instanceof l))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,h.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=s=>s.message){const s={},e=[];for(const i of this.issues)if(i.path.length>0){const o=i.path[0];s[o]=s[o]||[],s[o].push(t(i))}else e.push(t(i));return{formErrors:e,fieldErrors:s}}get formErrors(){return this.flatten()}}l.create=c=>new l(c);export{l as ZodError,d as ZodIssueCode,f as quotelessJson};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"./locales/en.js";let o=r;function p(t){o=t}function a(){return o}export{r as defaultErrorMap,a as getErrorMap,p as setErrorMap};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./errors.js";export*from"./helpers/parseUtil.js";export*from"./helpers/typeAliases.js";export*from"./helpers/util.js";export*from"./types.js";export*from"./ZodError.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare namespace enumUtil {
|
|
2
|
+
type UnionToIntersectionFn<T> = (T extends unknown ? (k: () => T) => void : never) extends (k: infer Intersection) => void ? Intersection : never;
|
|
3
|
+
type GetUnionLast<T> = UnionToIntersectionFn<T> extends () => infer Last ? Last : never;
|
|
4
|
+
type UnionToTuple<T, Tuple extends unknown[] = []> = [T] extends [never] ? Tuple : UnionToTuple<Exclude<T, GetUnionLast<T>>, [GetUnionLast<T>, ...Tuple]>;
|
|
5
|
+
type CastToStringTuple<T> = T extends [string, ...string[]] ? T : never;
|
|
6
|
+
export type UnionToTupleString<T> = CastToStringTuple<UnionToTuple<T>>;
|
|
7
|
+
export {};
|
|
8
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o;(function(r){r.errToObj=t=>typeof t=="string"?{message:t}:t||{},r.toString=t=>typeof t=="string"?t:t?.message})(o||(o={}));export{o as errorUtil};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { IssueData, ZodErrorMap, ZodIssue } from "../ZodError.cjs";
|
|
2
|
+
import type { ZodParsedType } from "./util.cjs";
|
|
3
|
+
export declare const makeIssue: (params: {
|
|
4
|
+
data: any;
|
|
5
|
+
path: (string | number)[];
|
|
6
|
+
errorMaps: ZodErrorMap[];
|
|
7
|
+
issueData: IssueData;
|
|
8
|
+
}) => ZodIssue;
|
|
9
|
+
export type ParseParams = {
|
|
10
|
+
path: (string | number)[];
|
|
11
|
+
errorMap: ZodErrorMap;
|
|
12
|
+
async: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type ParsePathComponent = string | number;
|
|
15
|
+
export type ParsePath = ParsePathComponent[];
|
|
16
|
+
export declare const EMPTY_PATH: ParsePath;
|
|
17
|
+
export interface ParseContext {
|
|
18
|
+
readonly common: {
|
|
19
|
+
readonly issues: ZodIssue[];
|
|
20
|
+
readonly contextualErrorMap?: ZodErrorMap | undefined;
|
|
21
|
+
readonly async: boolean;
|
|
22
|
+
};
|
|
23
|
+
readonly path: ParsePath;
|
|
24
|
+
readonly schemaErrorMap?: ZodErrorMap | undefined;
|
|
25
|
+
readonly parent: ParseContext | null;
|
|
26
|
+
readonly data: any;
|
|
27
|
+
readonly parsedType: ZodParsedType;
|
|
28
|
+
}
|
|
29
|
+
export type ParseInput = {
|
|
30
|
+
data: any;
|
|
31
|
+
path: (string | number)[];
|
|
32
|
+
parent: ParseContext;
|
|
33
|
+
};
|
|
34
|
+
export declare function addIssueToContext(ctx: ParseContext, issueData: IssueData): void;
|
|
35
|
+
export type ObjectPair = {
|
|
36
|
+
key: SyncParseReturnType<any>;
|
|
37
|
+
value: SyncParseReturnType<any>;
|
|
38
|
+
};
|
|
39
|
+
export declare class ParseStatus {
|
|
40
|
+
value: "aborted" | "dirty" | "valid";
|
|
41
|
+
dirty(): void;
|
|
42
|
+
abort(): void;
|
|
43
|
+
static mergeArray(status: ParseStatus, results: SyncParseReturnType<any>[]): SyncParseReturnType;
|
|
44
|
+
static mergeObjectAsync(status: ParseStatus, pairs: {
|
|
45
|
+
key: ParseReturnType<any>;
|
|
46
|
+
value: ParseReturnType<any>;
|
|
47
|
+
}[]): Promise<SyncParseReturnType<any>>;
|
|
48
|
+
static mergeObjectSync(status: ParseStatus, pairs: {
|
|
49
|
+
key: SyncParseReturnType<any>;
|
|
50
|
+
value: SyncParseReturnType<any>;
|
|
51
|
+
alwaysSet?: boolean;
|
|
52
|
+
}[]): SyncParseReturnType;
|
|
53
|
+
}
|
|
54
|
+
export interface ParseResult {
|
|
55
|
+
status: "aborted" | "dirty" | "valid";
|
|
56
|
+
data: any;
|
|
57
|
+
}
|
|
58
|
+
export type INVALID = {
|
|
59
|
+
status: "aborted";
|
|
60
|
+
};
|
|
61
|
+
export declare const INVALID: INVALID;
|
|
62
|
+
export type DIRTY<T> = {
|
|
63
|
+
status: "dirty";
|
|
64
|
+
value: T;
|
|
65
|
+
};
|
|
66
|
+
export declare const DIRTY: <T>(value: T) => DIRTY<T>;
|
|
67
|
+
export type OK<T> = {
|
|
68
|
+
status: "valid";
|
|
69
|
+
value: T;
|
|
70
|
+
};
|
|
71
|
+
export declare const OK: <T>(value: T) => OK<T>;
|
|
72
|
+
export type SyncParseReturnType<T = any> = OK<T> | DIRTY<T> | INVALID;
|
|
73
|
+
export type AsyncParseReturnType<T> = Promise<SyncParseReturnType<T>>;
|
|
74
|
+
export type ParseReturnType<T> = SyncParseReturnType<T> | AsyncParseReturnType<T>;
|
|
75
|
+
export declare const isAborted: (x: ParseReturnType<any>) => x is INVALID;
|
|
76
|
+
export declare const isDirty: <T>(x: ParseReturnType<T>) => x is OK<T> | DIRTY<T>;
|
|
77
|
+
export declare const isValid: <T>(x: ParseReturnType<T>) => x is OK<T>;
|
|
78
|
+
export declare const isAsync: <T>(x: ParseReturnType<T>) => x is AsyncParseReturnType<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getErrorMap as f}from"../errors.js";import d from"../locales/en.js";const y=t=>{const{data:s,path:a,errorMaps:r,issueData:e}=t,o=[...a,...e.path||[]],i={...e,path:o};if(e.message!==void 0)return{...e,path:o,message:e.message};let u="";const p=r.filter(n=>!!n).slice().reverse();for(const n of p)u=n(i,{data:s,defaultError:u}).message;return{...e,path:o,message:u}},h=[];function b(t,s){const a=f(),r=y({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,a,a===d?void 0:d].filter(e=>!!e)});t.common.issues.push(r)}class l{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(s,a){const r=[];for(const e of a){if(e.status==="aborted")return c;e.status==="dirty"&&s.dirty(),r.push(e.value)}return{status:s.value,value:r}}static async mergeObjectAsync(s,a){const r=[];for(const e of a){const o=await e.key,i=await e.value;r.push({key:o,value:i})}return l.mergeObjectSync(s,r)}static mergeObjectSync(s,a){const r={};for(const e of a){const{key:o,value:i}=e;if(o.status==="aborted"||i.status==="aborted")return c;o.status==="dirty"&&s.dirty(),i.status==="dirty"&&s.dirty(),o.value!=="__proto__"&&(typeof i.value<"u"||e.alwaysSet)&&(r[o.value]=i.value)}return{status:s.value,value:r}}}const c=Object.freeze({status:"aborted"}),g=t=>({status:"dirty",value:t}),x=t=>({status:"valid",value:t}),M=t=>t.status==="aborted",A=t=>t.status==="dirty",E=t=>t.status==="valid",I=t=>typeof Promise<"u"&&t instanceof Promise;export{g as DIRTY,h as EMPTY_PATH,c as INVALID,x as OK,l as ParseStatus,b as addIssueToContext,M as isAborted,I as isAsync,A as isDirty,E as isValid,y as makeIssue};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ZodArray, ZodNullable, ZodObject, ZodOptional, ZodRawShape, ZodTuple, ZodTupleItems, ZodTypeAny } from "../types.cjs";
|
|
2
|
+
export declare namespace partialUtil {
|
|
3
|
+
type DeepPartial<T extends ZodTypeAny> = T extends ZodObject<ZodRawShape> ? ZodObject<{
|
|
4
|
+
[k in keyof T["shape"]]: ZodOptional<DeepPartial<T["shape"][k]>>;
|
|
5
|
+
}, T["_def"]["unknownKeys"], T["_def"]["catchall"]> : T extends ZodArray<infer Type, infer Card> ? ZodArray<DeepPartial<Type>, Card> : T extends ZodOptional<infer Type> ? ZodOptional<DeepPartial<Type>> : T extends ZodNullable<infer Type> ? ZodNullable<DeepPartial<Type>> : T extends ZodTuple<infer Items> ? {
|
|
6
|
+
[k in keyof Items]: Items[k] extends ZodTypeAny ? DeepPartial<Items[k]> : never;
|
|
7
|
+
} extends infer PI ? PI extends ZodTupleItems ? ZodTuple<PI> : never : never : T;
|
|
8
|
+
}
|
|
File without changes
|
|
File without changes
|