fullstacked 0.12.0-1273 → 0.12.0-1291
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/fullstacked_modules/@fullstacked/ai-agent/index.ts +20 -2
- package/fullstacked_modules/@fullstacked/ai-agent/lock.json +469 -38
- package/fullstacked_modules/@fullstacked/ai-agent/package.json +11 -1
- package/fullstacked_modules/@fullstacked/ai-agent/src/conversation.ts +72 -14
- package/fullstacked_modules/@fullstacked/ai-agent/src/index.ts +1 -2
- package/fullstacked_modules/@fullstacked/ai-agent/src/markdown.ts +8 -4
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/anthropic.ts +46 -0
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/deepseek.ts +46 -0
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/google.ts +40 -0
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/index.ts +41 -0
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/interface.ts +19 -0
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/mistral.ts +47 -0
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/ollama.ts +26 -9
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/openai.ts +21 -9
- package/fullstacked_modules/@fullstacked/ai-agent/src/providers/xai.ts +43 -0
- package/fullstacked_modules/@fullstacked/ai-agent/summary.txt +7 -0
- package/fullstacked_modules/ai/index.js +155667 -87447
- package/fullstacked_modules/ai/tools/fs.ts +12 -2
- package/fullstacked_modules/fetch/index.ts +41 -16
- package/fullstacked_modules/fs/fs.ts +1 -1
- package/fullstacked_modules/zod/README.md +3 -3
- package/fullstacked_modules/zod/index.d.cts +2 -2
- package/fullstacked_modules/zod/index.d.ts +2 -2
- package/fullstacked_modules/zod/package.json +10 -26
- package/fullstacked_modules/zod/src/index.ts +2 -2
- package/fullstacked_modules/zod/src/v3/tests/string.test.ts +2 -2
- package/fullstacked_modules/zod/src/v3/types.ts +1 -3
- package/fullstacked_modules/zod/src/v4/classic/checks.ts +0 -1
- package/fullstacked_modules/zod/src/v4/classic/compat.ts +0 -4
- package/fullstacked_modules/zod/src/v4/classic/errors.ts +2 -9
- package/fullstacked_modules/zod/src/v4/classic/schemas.ts +47 -24
- package/fullstacked_modules/zod/src/v4/classic/tests/catch.test.ts +5 -4
- package/fullstacked_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -6
- package/fullstacked_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -42
- package/fullstacked_modules/zod/src/v4/classic/tests/error-utils.test.ts +2 -70
- package/fullstacked_modules/zod/src/v4/classic/tests/file.test.ts +2 -5
- package/fullstacked_modules/zod/src/v4/classic/tests/literal.test.ts +0 -25
- package/fullstacked_modules/zod/src/v4/classic/tests/number.test.ts +0 -23
- package/fullstacked_modules/zod/src/v4/classic/tests/optional.test.ts +0 -13
- package/fullstacked_modules/zod/src/v4/classic/tests/partial.test.ts +0 -193
- package/fullstacked_modules/zod/src/v4/classic/tests/pickomit.test.ts +5 -5
- package/fullstacked_modules/zod/src/v4/classic/tests/preprocess.test.ts +15 -4
- package/fullstacked_modules/zod/src/v4/classic/tests/record.test.ts +1 -15
- package/fullstacked_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -121
- package/fullstacked_modules/zod/src/v4/classic/tests/string.test.ts +4 -119
- package/fullstacked_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -3
- package/fullstacked_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -27
- package/fullstacked_modules/zod/src/v4/classic/tests/transform.test.ts +0 -104
- package/fullstacked_modules/zod/src/v4/classic/tests/tuple.test.ts +2 -2
- package/fullstacked_modules/zod/src/v4/classic/tests/union.test.ts +3 -90
- package/fullstacked_modules/zod/src/v4/core/api.ts +96 -130
- package/fullstacked_modules/zod/src/v4/core/checks.ts +2 -4
- package/fullstacked_modules/zod/src/v4/core/doc.ts +2 -2
- package/fullstacked_modules/zod/src/v4/core/errors.ts +44 -43
- package/fullstacked_modules/zod/src/v4/core/json-schema.ts +3 -6
- package/fullstacked_modules/zod/src/v4/core/regexes.ts +6 -9
- package/fullstacked_modules/zod/src/v4/core/registries.ts +2 -3
- package/fullstacked_modules/zod/src/v4/core/schemas.ts +107 -165
- package/fullstacked_modules/zod/src/v4/core/to-json-schema.ts +11 -38
- package/fullstacked_modules/zod/src/v4/core/util.ts +105 -157
- package/fullstacked_modules/zod/src/v4/core/versions.ts +1 -1
- package/fullstacked_modules/zod/src/v4/locales/index.ts +0 -3
- package/fullstacked_modules/zod/src/v4/mini/schemas.ts +1 -14
- package/fullstacked_modules/zod/src/v4/mini/tests/assignability.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/computed.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/error.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/index.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/number.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/object.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/prototypes.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/recursive-types.test.ts +1 -1
- package/fullstacked_modules/zod/src/v4/mini/tests/string.test.ts +1 -1
- package/fullstacked_modules/zod/v3/ZodError.d.cts +6 -6
- package/fullstacked_modules/zod/v3/ZodError.d.ts +6 -6
- package/fullstacked_modules/zod/v3/locales/en.d.cts +1 -1
- package/fullstacked_modules/zod/v3/types.d.cts +1 -4
- package/fullstacked_modules/zod/v3/types.d.ts +1 -4
- package/fullstacked_modules/zod/v4/classic/checks.d.cts +1 -1
- package/fullstacked_modules/zod/v4/classic/checks.d.ts +1 -1
- package/fullstacked_modules/zod/v4/classic/compat.d.cts +0 -4
- package/fullstacked_modules/zod/v4/classic/compat.d.ts +0 -4
- package/fullstacked_modules/zod/v4/classic/schemas.d.cts +20 -9
- package/fullstacked_modules/zod/v4/classic/schemas.d.ts +20 -9
- package/fullstacked_modules/zod/v4/core/api.d.cts +72 -84
- package/fullstacked_modules/zod/v4/core/api.d.ts +72 -84
- package/fullstacked_modules/zod/v4/core/checks.d.cts +2 -2
- package/fullstacked_modules/zod/v4/core/checks.d.ts +2 -2
- package/fullstacked_modules/zod/v4/core/doc.d.cts +1 -1
- package/fullstacked_modules/zod/v4/core/doc.d.ts +1 -1
- package/fullstacked_modules/zod/v4/core/errors.d.cts +22 -24
- package/fullstacked_modules/zod/v4/core/errors.d.ts +22 -24
- package/fullstacked_modules/zod/v4/core/json-schema.d.cts +3 -3
- package/fullstacked_modules/zod/v4/core/json-schema.d.ts +3 -3
- package/fullstacked_modules/zod/v4/core/regexes.d.cts +2 -2
- package/fullstacked_modules/zod/v4/core/regexes.d.ts +2 -2
- package/fullstacked_modules/zod/v4/core/registries.d.cts +1 -1
- package/fullstacked_modules/zod/v4/core/registries.d.ts +1 -1
- package/fullstacked_modules/zod/v4/core/schemas.d.cts +6 -20
- package/fullstacked_modules/zod/v4/core/schemas.d.ts +6 -20
- package/fullstacked_modules/zod/v4/core/to-json-schema.d.cts +3 -4
- package/fullstacked_modules/zod/v4/core/to-json-schema.d.ts +3 -4
- package/fullstacked_modules/zod/v4/core/util.d.cts +0 -2
- package/fullstacked_modules/zod/v4/core/util.d.ts +0 -2
- package/fullstacked_modules/zod/v4/locales/ar.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/az.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/be.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ca.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/cs.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/de.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/es.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/fa.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/fi.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/fr-CA.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/fr.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/he.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/hu.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/id.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/index.d.cts +0 -3
- package/fullstacked_modules/zod/v4/locales/index.d.ts +0 -3
- package/fullstacked_modules/zod/v4/locales/it.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ja.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/kh.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ko.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/mk.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ms.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/nl.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/no.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ota.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/pl.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ps.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/pt.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ru.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/sl.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/sv.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ta.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/th.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ua.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/ur.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/vi.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/zh-CN.d.cts +1 -2
- package/fullstacked_modules/zod/v4/locales/zh-TW.d.cts +1 -2
- package/fullstacked_modules/zod/v4/mini/schemas.d.cts +0 -2
- package/fullstacked_modules/zod/v4/mini/schemas.d.ts +0 -2
- package/package.json +1 -1
- package/fullstacked_modules/zod/locales/index.d.cts +0 -1
- package/fullstacked_modules/zod/locales/index.d.ts +0 -1
- package/fullstacked_modules/zod/mini/index.d.cts +0 -1
- package/fullstacked_modules/zod/mini/index.d.ts +0 -1
- package/fullstacked_modules/zod/src/locales/index.ts +0 -1
- package/fullstacked_modules/zod/src/mini/index.ts +0 -1
- package/fullstacked_modules/zod/src/v4/core/tests/extend.test.ts +0 -18
- package/fullstacked_modules/zod/src/v4/locales/bg.ts +0 -136
- package/fullstacked_modules/zod/src/v4/locales/da.ts +0 -141
- package/fullstacked_modules/zod/src/v4/locales/is.ts +0 -127
- package/fullstacked_modules/zod/src/v4/locales/yo.ts +0 -131
- package/fullstacked_modules/zod/v4/locales/bg.d.cts +0 -5
- package/fullstacked_modules/zod/v4/locales/bg.d.ts +0 -5
- package/fullstacked_modules/zod/v4/locales/da.d.cts +0 -5
- package/fullstacked_modules/zod/v4/locales/da.d.ts +0 -4
- package/fullstacked_modules/zod/v4/locales/is.d.cts +0 -5
- package/fullstacked_modules/zod/v4/locales/is.d.ts +0 -5
- package/fullstacked_modules/zod/v4/locales/yo.d.cts +0 -5
- package/fullstacked_modules/zod/v4/locales/yo.d.ts +0 -4
|
@@ -25,7 +25,12 @@ export function createToolFS(opts?: Partial<ToolFSOptions>) {
|
|
|
25
25
|
schema: z.object({
|
|
26
26
|
path: z.string()
|
|
27
27
|
}),
|
|
28
|
-
fn: ({ path }) =>
|
|
28
|
+
fn: async ({ path }) => {
|
|
29
|
+
const success = await fs.mkdir(fixPath(path));
|
|
30
|
+
return success
|
|
31
|
+
? `Successfully created directory ${path}.`
|
|
32
|
+
: `Failed to create directory ${path}.`;
|
|
33
|
+
},
|
|
29
34
|
message: ({ path }) => `Creating directory \`${path}\``
|
|
30
35
|
}),
|
|
31
36
|
createTool({
|
|
@@ -53,7 +58,12 @@ export function createToolFS(opts?: Partial<ToolFSOptions>) {
|
|
|
53
58
|
path: z.string(),
|
|
54
59
|
contents: z.string()
|
|
55
60
|
}),
|
|
56
|
-
fn: ({ path, contents }) =>
|
|
61
|
+
fn: async ({ path, contents }) => {
|
|
62
|
+
const success = await fs.writeFile(fixPath(path), contents);
|
|
63
|
+
return success
|
|
64
|
+
? `Successfully written ${contents.length} characters to ${path}.`
|
|
65
|
+
: `Failed to write to ${path}.`;
|
|
66
|
+
},
|
|
57
67
|
message: ({ path }) => `Writing to \`${path}\``
|
|
58
68
|
})
|
|
59
69
|
];
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "../bridge/serialization";
|
|
8
8
|
import core_message from "../core_message";
|
|
9
9
|
import { ar } from "zod/v4/locales";
|
|
10
|
+
import platform, { Platform } from "../platform";
|
|
10
11
|
|
|
11
12
|
const te = new TextEncoder();
|
|
12
13
|
|
|
@@ -122,14 +123,44 @@ export default function core_fetch(
|
|
|
122
123
|
});
|
|
123
124
|
}
|
|
124
125
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
type ActiveRequest = {
|
|
127
|
+
url: string;
|
|
128
|
+
resolveResponse(response: Response): void;
|
|
129
|
+
resolveStream?: (param: { done: boolean; chunk: Uint8Array }) => void;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const activeFetch2Requests = new Map<number, ActiveRequest>();
|
|
133
|
+
|
|
134
|
+
// in WASM everything in synchronous and calling
|
|
135
|
+
// resolveStream on the next event loop assures the promise is well set
|
|
136
|
+
//
|
|
137
|
+
// this is call at a very high pace, so it's better to avoid the "if" at every streamed bit
|
|
138
|
+
const processStream =
|
|
139
|
+
platform === Platform.WASM
|
|
140
|
+
? function (
|
|
141
|
+
id: number,
|
|
142
|
+
request: ActiveRequest,
|
|
143
|
+
done: boolean,
|
|
144
|
+
chunk: Uint8Array
|
|
145
|
+
) {
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
request.resolveStream({ done, chunk });
|
|
148
|
+
if (done) {
|
|
149
|
+
activeFetch2Requests.delete(id);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
: function (
|
|
154
|
+
id: number,
|
|
155
|
+
request: ActiveRequest,
|
|
156
|
+
done: boolean,
|
|
157
|
+
chunk: Uint8Array
|
|
158
|
+
) {
|
|
159
|
+
request.resolveStream({ done, chunk });
|
|
160
|
+
if (done) {
|
|
161
|
+
activeFetch2Requests.delete(id);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
133
164
|
|
|
134
165
|
let addedListener2 = false;
|
|
135
166
|
function receivedResponse2(base64Data: string) {
|
|
@@ -143,10 +174,7 @@ function receivedResponse2(base64Data: string) {
|
|
|
143
174
|
|
|
144
175
|
if (request.resolveStream) {
|
|
145
176
|
const [done, chunk] = args.slice(1);
|
|
146
|
-
|
|
147
|
-
if (done) {
|
|
148
|
-
activeFetch2Requests.delete(id);
|
|
149
|
-
}
|
|
177
|
+
processStream(id, request, done, chunk);
|
|
150
178
|
return;
|
|
151
179
|
}
|
|
152
180
|
|
|
@@ -154,7 +182,7 @@ function receivedResponse2(base64Data: string) {
|
|
|
154
182
|
|
|
155
183
|
const ok = status <= 299;
|
|
156
184
|
|
|
157
|
-
let finished =
|
|
185
|
+
let finished = statusText === "Failed fetch";
|
|
158
186
|
const read = async () => {
|
|
159
187
|
if (finished) {
|
|
160
188
|
return { done: true };
|
|
@@ -182,9 +210,6 @@ function receivedResponse2(base64Data: string) {
|
|
|
182
210
|
};
|
|
183
211
|
|
|
184
212
|
const readBody = async () => {
|
|
185
|
-
if (!ok) {
|
|
186
|
-
return te.encode(statusText) as Uint8Array<ArrayBuffer>;
|
|
187
|
-
}
|
|
188
213
|
let body = new Uint8Array();
|
|
189
214
|
for await (const chunk of responseIterator) {
|
|
190
215
|
const buffer = new Uint8Array(body.byteLength + chunk.byteLength);
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<br/>
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
|
-
<a href="https://github.com/colinhacks/zod/actions?query=branch%
|
|
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
14
|
<a href="https://opensource.org/licenses/MIT" rel="nofollow"><img src="https://img.shields.io/github/license/colinhacks/zod" alt="License"></a>
|
|
15
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
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>
|
|
@@ -58,7 +58,7 @@
|
|
|
58
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
59
|
|
|
60
60
|
```ts
|
|
61
|
-
import * as z from "zod";
|
|
61
|
+
import * as z from "zod/v4";
|
|
62
62
|
|
|
63
63
|
const User = z.object({
|
|
64
64
|
name: z.string(),
|
|
@@ -104,7 +104,7 @@ npm install zod
|
|
|
104
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
105
|
|
|
106
106
|
```ts
|
|
107
|
-
import * as z from "zod";
|
|
107
|
+
import * as z from "zod/v4";
|
|
108
108
|
|
|
109
109
|
const Player = z.object({
|
|
110
110
|
username: z.string(),
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.25.76",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"license": "MIT",
|
|
6
5
|
"author": "Colin McDonnell <zod@colinhacks.com>",
|
|
7
6
|
"description": "TypeScript-first schema declaration and validation library with static type inference",
|
|
8
|
-
"homepage": "https://zod.dev",
|
|
9
|
-
"llms": "https://zod.dev/llms.txt",
|
|
10
|
-
"llmsFull": "https://zod.dev/llms-full.txt",
|
|
11
|
-
"mcpServer": "https://mcp.inkeep.com/zod/mcp",
|
|
12
|
-
"funding": "https://github.com/sponsors/colinhacks",
|
|
13
|
-
"sideEffects": false,
|
|
14
7
|
"files": [
|
|
15
8
|
"src",
|
|
16
9
|
"**/*.js",
|
|
@@ -20,6 +13,8 @@
|
|
|
20
13
|
"**/*.d.mts",
|
|
21
14
|
"**/*.d.cts"
|
|
22
15
|
],
|
|
16
|
+
"funding": "https://github.com/sponsors/colinhacks",
|
|
17
|
+
"homepage": "https://zod.dev",
|
|
23
18
|
"keywords": [
|
|
24
19
|
"typescript",
|
|
25
20
|
"schema",
|
|
@@ -27,6 +22,8 @@
|
|
|
27
22
|
"type",
|
|
28
23
|
"inference"
|
|
29
24
|
],
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"sideEffects": false,
|
|
30
27
|
"main": "./index.cjs",
|
|
31
28
|
"types": "./index.d.cts",
|
|
32
29
|
"module": "./index.js",
|
|
@@ -34,8 +31,6 @@
|
|
|
34
31
|
"exports": {
|
|
35
32
|
"./package.json": "./package.json",
|
|
36
33
|
".": "./src/index.ts",
|
|
37
|
-
"./mini": "./src/mini/index.ts",
|
|
38
|
-
"./locales": "./src/locales/index.ts",
|
|
39
34
|
"./v3": "./src/v3/index.ts",
|
|
40
35
|
"./v4": "./src/v4/index.ts",
|
|
41
36
|
"./v4-mini": "./src/v4-mini/index.ts",
|
|
@@ -44,9 +39,9 @@
|
|
|
44
39
|
"./v4/locales": "./src/v4/locales/index.ts",
|
|
45
40
|
"./v4/locales/*": "./src/v4/locales/*"
|
|
46
41
|
},
|
|
47
|
-
"
|
|
48
|
-
"@zod/source"
|
|
49
|
-
|
|
42
|
+
"sourceDialects": [
|
|
43
|
+
"@zod/source"
|
|
44
|
+
]
|
|
50
45
|
},
|
|
51
46
|
"exports": {
|
|
52
47
|
"./package.json": "./package.json",
|
|
@@ -56,18 +51,6 @@
|
|
|
56
51
|
"import": "./index.js",
|
|
57
52
|
"require": "./index.cjs"
|
|
58
53
|
},
|
|
59
|
-
"./mini": {
|
|
60
|
-
"@zod/source": "./src/mini/index.ts",
|
|
61
|
-
"types": "./mini/index.d.cts",
|
|
62
|
-
"import": "./mini/index.js",
|
|
63
|
-
"require": "./mini/index.cjs"
|
|
64
|
-
},
|
|
65
|
-
"./locales": {
|
|
66
|
-
"@zod/source": "./src/locales/index.ts",
|
|
67
|
-
"types": "./locales/index.d.cts",
|
|
68
|
-
"import": "./locales/index.js",
|
|
69
|
-
"require": "./locales/index.cjs"
|
|
70
|
-
},
|
|
71
54
|
"./v3": {
|
|
72
55
|
"@zod/source": "./src/v3/index.ts",
|
|
73
56
|
"types": "./v3/index.d.cts",
|
|
@@ -129,6 +112,7 @@
|
|
|
129
112
|
"postbuild": "pnpm biome check --write .",
|
|
130
113
|
"test:watch": "pnpm vitest",
|
|
131
114
|
"test": "pnpm vitest run",
|
|
132
|
-
"
|
|
115
|
+
"bump:beta": "pnpm version \"v$(pnpm pkg get version | jq -r)-beta.$(date +%Y%m%dT%H%M%S)\"",
|
|
116
|
+
"pub:beta": "pnpm bump:beta && pnpm publish --tag next --publish-branch v4 --no-git-checks --dry-run"
|
|
133
117
|
}
|
|
134
118
|
}
|
|
@@ -342,8 +342,8 @@ test("uuid", () => {
|
|
|
342
342
|
uuid.parse("9491d710-3185-4e06-bea0-6a2f275345e0");
|
|
343
343
|
uuid.parse("d89e7b01-7598-ed11-9d7a-0022489382fd"); // new sequential id
|
|
344
344
|
uuid.parse("00000000-0000-0000-0000-000000000000");
|
|
345
|
-
uuid.parse("b3ce60f8-e8b9-40f5-1150-172ede56ff74"); // Variant 0 - RFC
|
|
346
|
-
uuid.parse("92e76bf9-28b3-4730-cd7f-cb6bc51f8c09"); // Variant 2 - RFC
|
|
345
|
+
uuid.parse("b3ce60f8-e8b9-40f5-1150-172ede56ff74"); // Variant 0 - RFC 4122: Reserved, NCS backward compatibility
|
|
346
|
+
uuid.parse("92e76bf9-28b3-4730-cd7f-cb6bc51f8c09"); // Variant 2 - RFC 4122: Reserved, Microsoft Corporation backward compatibility
|
|
347
347
|
const result = uuid.safeParse("9491d710-3185-4e06-bea0-6a2f275345e0X");
|
|
348
348
|
expect(result.success).toEqual(false);
|
|
349
349
|
if (!result.success) {
|
|
@@ -705,7 +705,6 @@ function isValidJWT(jwt: string, alg?: string): boolean {
|
|
|
705
705
|
.replace(/-/g, "+")
|
|
706
706
|
.replace(/_/g, "/")
|
|
707
707
|
.padEnd(header.length + ((4 - (header.length % 4)) % 4), "=");
|
|
708
|
-
// @ts-ignore
|
|
709
708
|
const decoded = JSON.parse(atob(base64));
|
|
710
709
|
if (typeof decoded !== "object" || decoded === null) return false;
|
|
711
710
|
if ("typ" in decoded && decoded?.typ !== "JWT") return false;
|
|
@@ -876,7 +875,6 @@ export class ZodString extends ZodType<string, ZodStringDef, string> {
|
|
|
876
875
|
}
|
|
877
876
|
} else if (check.kind === "url") {
|
|
878
877
|
try {
|
|
879
|
-
// @ts-ignore
|
|
880
878
|
new URL(input.data);
|
|
881
879
|
} catch {
|
|
882
880
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -2456,7 +2454,7 @@ export class ZodObject<
|
|
|
2456
2454
|
Output = objectOutputType<T, Catchall, UnknownKeys>,
|
|
2457
2455
|
Input = objectInputType<T, Catchall, UnknownKeys>,
|
|
2458
2456
|
> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
|
|
2459
|
-
_cached: { shape: T; keys: string[] } | null = null;
|
|
2457
|
+
private _cached: { shape: T; keys: string[] } | null = null;
|
|
2460
2458
|
|
|
2461
2459
|
_getCached(): { shape: T; keys: string[] } {
|
|
2462
2460
|
if (this._cached !== null) return this._cached;
|
|
@@ -63,8 +63,4 @@ export type {
|
|
|
63
63
|
ZodType as Schema,
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
/** Included for Zod 3 compatibility */
|
|
67
66
|
export type ZodRawShape = core.$ZodShape;
|
|
68
|
-
|
|
69
|
-
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
70
|
-
export enum ZodFirstPartyTypeKind {}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as core from "../core/index.js";
|
|
2
2
|
import { $ZodError } from "../core/index.js";
|
|
3
|
-
import * as util from "../core/util.js";
|
|
4
3
|
|
|
5
4
|
/** @deprecated Use `z.core.$ZodIssue` from `@zod/core` instead, especially if you are building a library on top of Zod. */
|
|
6
5
|
export type ZodIssue = core.$ZodIssue;
|
|
@@ -35,17 +34,11 @@ const initializer = (inst: ZodError, issues: core.$ZodIssue[]) => {
|
|
|
35
34
|
// enumerable: false,
|
|
36
35
|
},
|
|
37
36
|
addIssue: {
|
|
38
|
-
value: (issue: any) =>
|
|
39
|
-
inst.issues.push(issue);
|
|
40
|
-
inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);
|
|
41
|
-
},
|
|
37
|
+
value: (issue: any) => inst.issues.push(issue),
|
|
42
38
|
// enumerable: false,
|
|
43
39
|
},
|
|
44
40
|
addIssues: {
|
|
45
|
-
value: (issues: any) =>
|
|
46
|
-
inst.issues.push(...issues);
|
|
47
|
-
inst.message = JSON.stringify(inst.issues, util.jsonStringifyReplacer, 2);
|
|
48
|
-
},
|
|
41
|
+
value: (issues: any) => inst.issues.push(...issues),
|
|
49
42
|
// enumerable: false,
|
|
50
43
|
},
|
|
51
44
|
isEmpty: {
|
|
@@ -13,6 +13,10 @@ import * as parse from "./parse.js";
|
|
|
13
13
|
///////////////////////////////////////////
|
|
14
14
|
///////////////////////////////////////////
|
|
15
15
|
|
|
16
|
+
export interface RefinementCtx<T = unknown> extends core.ParsePayload<T> {
|
|
17
|
+
addIssue(arg: string | core.$ZodRawIssue | Partial<core.$ZodIssueCustom>): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
export interface ZodType<
|
|
17
21
|
out Output = unknown,
|
|
18
22
|
out Input = unknown,
|
|
@@ -57,8 +61,9 @@ export interface ZodType<
|
|
|
57
61
|
|
|
58
62
|
// refinements
|
|
59
63
|
refine(check: (arg: core.output<this>) => unknown | Promise<unknown>, params?: string | core.$ZodCustomParams): this;
|
|
64
|
+
/** @deprecated Use `.check()` instead. */
|
|
60
65
|
superRefine(
|
|
61
|
-
refinement: (arg: core.output<this>, ctx:
|
|
66
|
+
refinement: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => void | Promise<void>
|
|
62
67
|
): this;
|
|
63
68
|
overwrite(fn: (x: core.output<this>) => core.output<this>): this;
|
|
64
69
|
|
|
@@ -75,7 +80,7 @@ export interface ZodType<
|
|
|
75
80
|
or<T extends core.SomeType>(option: T): ZodUnion<[this, T]>;
|
|
76
81
|
and<T extends core.SomeType>(incoming: T): ZodIntersection<this, T>;
|
|
77
82
|
transform<NewOut>(
|
|
78
|
-
transform: (arg: core.output<this>, ctx:
|
|
83
|
+
transform: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>
|
|
79
84
|
): ZodPipe<this, ZodTransform<Awaited<NewOut>, core.output<this>>>;
|
|
80
85
|
catch(def: core.output<this>): ZodCatch<this>;
|
|
81
86
|
catch(def: (ctx: core.$ZodCatchCtx) => core.output<this>): ZodCatch<this>;
|
|
@@ -693,10 +698,6 @@ export function stringFormat<Format extends string>(
|
|
|
693
698
|
return core._stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params) as any;
|
|
694
699
|
}
|
|
695
700
|
|
|
696
|
-
export function hostname(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hostname"> {
|
|
697
|
-
return core._stringFormat(ZodCustomStringFormat, "hostname", core.regexes.hostname, _params) as any;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
701
|
// ZodNumber
|
|
701
702
|
export interface _ZodNumber<Internals extends core.$ZodNumberInternals = core.$ZodNumberInternals>
|
|
702
703
|
extends _ZodType<Internals> {
|
|
@@ -1068,10 +1069,22 @@ export interface ZodObject<
|
|
|
1068
1069
|
/** This is the default behavior. This method call is likely unnecessary. */
|
|
1069
1070
|
strip(): ZodObject<Shape, core.$strip>;
|
|
1070
1071
|
|
|
1071
|
-
extend<U extends core.$ZodLooseShape
|
|
1072
|
+
extend<U extends core.$ZodLooseShape & Partial<Record<keyof Shape, core.SomeType>>>(
|
|
1073
|
+
shape: U
|
|
1074
|
+
): ZodObject<util.Extend<Shape, U>, Config>;
|
|
1072
1075
|
|
|
1073
1076
|
/**
|
|
1074
|
-
* @deprecated Use
|
|
1077
|
+
* @deprecated Use spread syntax and the `.shape` property to combine two object schemas:
|
|
1078
|
+
*
|
|
1079
|
+
* ```ts
|
|
1080
|
+
* const A = z.object({ a: z.string() });
|
|
1081
|
+
* const B = z.object({ b: z.number() });
|
|
1082
|
+
*
|
|
1083
|
+
* const C = z.object({
|
|
1084
|
+
* ...A.shape,
|
|
1085
|
+
* ...B.shape
|
|
1086
|
+
* });
|
|
1087
|
+
* ```
|
|
1075
1088
|
*/
|
|
1076
1089
|
merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
|
|
1077
1090
|
|
|
@@ -1128,6 +1141,7 @@ export const ZodObject: core.$constructor<ZodObject> = /*@__PURE__*/ core.$const
|
|
|
1128
1141
|
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape)) as any;
|
|
1129
1142
|
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall as any as core.$ZodType }) as any;
|
|
1130
1143
|
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
1144
|
+
// inst.nonstrict = () => inst.clone({ ...inst._zod.def, catchall: api.unknown() });
|
|
1131
1145
|
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
1132
1146
|
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
|
1133
1147
|
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
|
|
@@ -1219,7 +1233,6 @@ export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[]
|
|
|
1219
1233
|
extends ZodUnion<Options>,
|
|
1220
1234
|
core.$ZodDiscriminatedUnion<Options> {
|
|
1221
1235
|
_zod: core.$ZodDiscriminatedUnionInternals<Options>;
|
|
1222
|
-
def: core.$ZodDiscriminatedUnionDef<Options>;
|
|
1223
1236
|
}
|
|
1224
1237
|
export const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion> = /*@__PURE__*/ core.$constructor(
|
|
1225
1238
|
"ZodDiscriminatedUnion",
|
|
@@ -1347,11 +1360,9 @@ export function partialRecord<Key extends core.$ZodRecordKey, Value extends core
|
|
|
1347
1360
|
valueType: Value,
|
|
1348
1361
|
params?: string | core.$ZodRecordParams
|
|
1349
1362
|
): ZodRecord<Key & core.$partial, Value> {
|
|
1350
|
-
const k = core.clone(keyType);
|
|
1351
|
-
k._zod.values = undefined;
|
|
1352
1363
|
return new ZodRecord({
|
|
1353
1364
|
type: "record",
|
|
1354
|
-
keyType:
|
|
1365
|
+
keyType: union([keyType, never()]),
|
|
1355
1366
|
valueType: valueType as any,
|
|
1356
1367
|
...util.normalizeParams(params),
|
|
1357
1368
|
}) as any;
|
|
@@ -1572,7 +1583,7 @@ export const ZodTransform: core.$constructor<ZodTransform> = /*@__PURE__*/ core.
|
|
|
1572
1583
|
ZodType.init(inst, def);
|
|
1573
1584
|
|
|
1574
1585
|
inst._zod.parse = (payload, _ctx) => {
|
|
1575
|
-
(payload as
|
|
1586
|
+
(payload as RefinementCtx).addIssue = (issue) => {
|
|
1576
1587
|
if (typeof issue === "string") {
|
|
1577
1588
|
payload.issues.push(util.issue(issue, payload.value, def));
|
|
1578
1589
|
} else {
|
|
@@ -1583,7 +1594,7 @@ export const ZodTransform: core.$constructor<ZodTransform> = /*@__PURE__*/ core.
|
|
|
1583
1594
|
_issue.code ??= "custom";
|
|
1584
1595
|
_issue.input ??= payload.value;
|
|
1585
1596
|
_issue.inst ??= inst;
|
|
1586
|
-
|
|
1597
|
+
_issue.continue ??= true;
|
|
1587
1598
|
payload.issues.push(util.issue(_issue));
|
|
1588
1599
|
}
|
|
1589
1600
|
};
|
|
@@ -1837,16 +1848,12 @@ export function pipe(in_: core.SomeType, out: core.SomeType) {
|
|
|
1837
1848
|
// ZodReadonly
|
|
1838
1849
|
export interface ZodReadonly<T extends core.SomeType = core.$ZodType>
|
|
1839
1850
|
extends _ZodType<core.$ZodReadonlyInternals<T>>,
|
|
1840
|
-
core.$ZodReadonly<T> {
|
|
1841
|
-
unwrap(): T;
|
|
1842
|
-
}
|
|
1851
|
+
core.$ZodReadonly<T> {}
|
|
1843
1852
|
export const ZodReadonly: core.$constructor<ZodReadonly> = /*@__PURE__*/ core.$constructor(
|
|
1844
1853
|
"ZodReadonly",
|
|
1845
1854
|
(inst, def) => {
|
|
1846
1855
|
core.$ZodReadonly.init(inst, def);
|
|
1847
1856
|
ZodType.init(inst, def);
|
|
1848
|
-
|
|
1849
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
1850
1857
|
}
|
|
1851
1858
|
);
|
|
1852
1859
|
|
|
@@ -1955,10 +1962,26 @@ export function refine<T>(
|
|
|
1955
1962
|
}
|
|
1956
1963
|
|
|
1957
1964
|
// superRefine
|
|
1958
|
-
export function superRefine<T>(
|
|
1959
|
-
|
|
1960
|
-
)
|
|
1961
|
-
|
|
1965
|
+
export function superRefine<T>(fn: (arg: T, payload: RefinementCtx<T>) => void | Promise<void>): core.$ZodCheck<T> {
|
|
1966
|
+
const ch = check<T>((payload) => {
|
|
1967
|
+
(payload as RefinementCtx).addIssue = (issue) => {
|
|
1968
|
+
if (typeof issue === "string") {
|
|
1969
|
+
payload.issues.push(util.issue(issue, payload.value, ch._zod.def));
|
|
1970
|
+
} else {
|
|
1971
|
+
// for Zod 3 backwards compatibility
|
|
1972
|
+
const _issue: any = issue;
|
|
1973
|
+
if (_issue.fatal) _issue.continue = false;
|
|
1974
|
+
_issue.code ??= "custom";
|
|
1975
|
+
_issue.input ??= payload.value;
|
|
1976
|
+
_issue.inst ??= ch;
|
|
1977
|
+
_issue.continue ??= !ch._zod.def.abort;
|
|
1978
|
+
payload.issues.push(util.issue(_issue));
|
|
1979
|
+
}
|
|
1980
|
+
};
|
|
1981
|
+
|
|
1982
|
+
return fn(payload.value, payload as RefinementCtx<T>);
|
|
1983
|
+
});
|
|
1984
|
+
return ch;
|
|
1962
1985
|
}
|
|
1963
1986
|
|
|
1964
1987
|
type ZodInstanceOfParams = core.Params<
|
|
@@ -2024,7 +2047,7 @@ export function json(params?: string | core.$ZodCustomParams): ZodJSONSchema {
|
|
|
2024
2047
|
|
|
2025
2048
|
// /** @deprecated Use `z.pipe()` and `z.transform()` instead. */
|
|
2026
2049
|
export function preprocess<A, U extends core.SomeType, B = unknown>(
|
|
2027
|
-
fn: (arg: B, ctx:
|
|
2050
|
+
fn: (arg: B, ctx: RefinementCtx) => A,
|
|
2028
2051
|
schema: U
|
|
2029
2052
|
): ZodPipe<ZodTransform<A, B>, U> {
|
|
2030
2053
|
return pipe(transform(fn as any), schema as any) as any;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { expect, expectTypeOf, test } from "vitest";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
+
import type { util } from "zod/v4/core";
|
|
3
4
|
|
|
4
5
|
test("basic catch", () => {
|
|
5
6
|
expect(z.string().catch("default").parse(undefined)).toBe("default");
|
|
@@ -44,7 +45,7 @@ test("catch with transform", () => {
|
|
|
44
45
|
expect(stringWithDefault.unwrap().out).toBeInstanceOf(z.ZodTransform);
|
|
45
46
|
|
|
46
47
|
type inp = z.input<typeof stringWithDefault>;
|
|
47
|
-
expectTypeOf<inp>().toEqualTypeOf<string>();
|
|
48
|
+
expectTypeOf<inp>().toEqualTypeOf<string | util.Whatever>();
|
|
48
49
|
type out = z.output<typeof stringWithDefault>;
|
|
49
50
|
expectTypeOf<out>().toEqualTypeOf<string>();
|
|
50
51
|
});
|
|
@@ -58,7 +59,7 @@ test("catch on existing optional", () => {
|
|
|
58
59
|
expect(stringWithDefault.unwrap().unwrap()).toBeInstanceOf(z.ZodString);
|
|
59
60
|
|
|
60
61
|
type inp = z.input<typeof stringWithDefault>;
|
|
61
|
-
expectTypeOf<inp>().toEqualTypeOf<string | undefined>();
|
|
62
|
+
expectTypeOf<inp>().toEqualTypeOf<string | undefined | util.Whatever>();
|
|
62
63
|
type out = z.output<typeof stringWithDefault>;
|
|
63
64
|
expectTypeOf<out>().toEqualTypeOf<string | undefined>();
|
|
64
65
|
});
|
|
@@ -67,7 +68,7 @@ test("optional on catch", () => {
|
|
|
67
68
|
const stringWithDefault = z.string().catch("asdf").optional();
|
|
68
69
|
|
|
69
70
|
type inp = z.input<typeof stringWithDefault>;
|
|
70
|
-
expectTypeOf<inp>().toEqualTypeOf<string |
|
|
71
|
+
expectTypeOf<inp>().toEqualTypeOf<string | util.Whatever>();
|
|
71
72
|
type out = z.output<typeof stringWithDefault>;
|
|
72
73
|
expectTypeOf<out>().toEqualTypeOf<string | undefined>();
|
|
73
74
|
});
|
|
@@ -101,7 +102,7 @@ test("nested", () => {
|
|
|
101
102
|
inner: "asdf",
|
|
102
103
|
});
|
|
103
104
|
type input = z.input<typeof outer>;
|
|
104
|
-
expectTypeOf<input>().toEqualTypeOf<{ inner: string }>();
|
|
105
|
+
expectTypeOf<input>().toEqualTypeOf<{ inner: string | util.Whatever } | util.Whatever>();
|
|
105
106
|
type out = z.output<typeof outer>;
|
|
106
107
|
|
|
107
108
|
expectTypeOf<out>().toEqualTypeOf<{ inner: string }>();
|
|
@@ -62,12 +62,6 @@ test("datetime parsing with offset", () => {
|
|
|
62
62
|
expect(() => datetimeOffset.parse("2020-10-14T17:42:29+03")).toThrow();
|
|
63
63
|
expect(() => datetimeOffset.parse("tuna")).toThrow();
|
|
64
64
|
expect(() => datetimeOffset.parse("2022-10-13T09:52:31.Z")).toThrow();
|
|
65
|
-
|
|
66
|
-
// Invalid offset tests
|
|
67
|
-
expect(() => datetimeOffset.parse("2020-10-14T17:42:29+24:00")).toThrow(); // out of range hours
|
|
68
|
-
expect(() => datetimeOffset.parse("2020-10-14T17:42:29+00:60")).toThrow(); // out of range minutes
|
|
69
|
-
expect(() => datetimeOffset.parse("2020-10-14T17:42:29+1:30")).toThrow(); // single digit hours
|
|
70
|
-
expect(() => datetimeOffset.parse("2020-10-14T17:42:29+00:")).toThrow(); // incomplete offset
|
|
71
65
|
});
|
|
72
66
|
|
|
73
67
|
test("datetime parsing with offset and precision 0", () => {
|
|
@@ -157,7 +157,6 @@ test("invalid discriminator value", () => {
|
|
|
157
157
|
"code": "invalid_union",
|
|
158
158
|
"errors": [],
|
|
159
159
|
"note": "No matching discriminator",
|
|
160
|
-
"discriminator": "type",
|
|
161
160
|
"path": [
|
|
162
161
|
"type"
|
|
163
162
|
],
|
|
@@ -618,44 +617,3 @@ test("readonly literal discriminator", () => {
|
|
|
618
617
|
discUnion.parse({ type: "c", a: "hello" });
|
|
619
618
|
}).toThrow();
|
|
620
619
|
});
|
|
621
|
-
|
|
622
|
-
test("pipes", () => {
|
|
623
|
-
const schema = z
|
|
624
|
-
.object({
|
|
625
|
-
type: z.literal("foo"),
|
|
626
|
-
})
|
|
627
|
-
.transform((s) => ({ ...s, v: 2 }));
|
|
628
|
-
|
|
629
|
-
expect(schema._zod.propValues).toMatchInlineSnapshot(`
|
|
630
|
-
{
|
|
631
|
-
"type": Set {
|
|
632
|
-
"foo",
|
|
633
|
-
},
|
|
634
|
-
}
|
|
635
|
-
`);
|
|
636
|
-
|
|
637
|
-
const schema2 = z.object({
|
|
638
|
-
type: z.literal("bar"),
|
|
639
|
-
});
|
|
640
|
-
|
|
641
|
-
const combinedSchema = z.discriminatedUnion("type", [schema, schema2], {
|
|
642
|
-
unionFallback: false,
|
|
643
|
-
});
|
|
644
|
-
|
|
645
|
-
combinedSchema.parse({
|
|
646
|
-
type: "foo",
|
|
647
|
-
v: 2,
|
|
648
|
-
});
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
test("def", () => {
|
|
652
|
-
const schema = z.discriminatedUnion(
|
|
653
|
-
"type",
|
|
654
|
-
[z.object({ type: z.literal("play") }), z.object({ type: z.literal("pause") })],
|
|
655
|
-
{ unionFallback: true }
|
|
656
|
-
);
|
|
657
|
-
|
|
658
|
-
expect(schema.def).toBeDefined();
|
|
659
|
-
expect(schema.def.discriminator).toEqual("type");
|
|
660
|
-
expect(schema.def.unionFallback).toEqual(true);
|
|
661
|
-
});
|