Leon4gr45 commited on
Commit
ce70b47
·
verified ·
1 Parent(s): 9f6e2b4

Upload folder using huggingface_hub (part 11)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. node_modules/@jimp/plugin-color/node_modules/zod/src/v4-mini/index.ts +1 -0
  3. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/refine.test.ts +532 -0
  4. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/registries.test.ts +204 -0
  5. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/set.test.ts +179 -0
  6. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +57 -0
  7. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +109 -0
  8. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/string.test.ts +881 -0
  9. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +66 -0
  10. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +758 -0
  11. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +2314 -0
  12. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/transform.test.ts +250 -0
  13. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/tuple.test.ts +163 -0
  14. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/union.test.ts +94 -0
  15. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
  16. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
  17. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/api.ts +1594 -0
  18. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/checks.ts +1283 -0
  19. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/config.ts +15 -0
  20. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/core.ts +134 -0
  21. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/doc.ts +44 -0
  22. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/errors.ts +424 -0
  23. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/function.ts +176 -0
  24. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/index.ts +15 -0
  25. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/json-schema.ts +143 -0
  26. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/parse.ts +94 -0
  27. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/regexes.ts +135 -0
  28. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/registries.ts +96 -0
  29. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/schemas.ts +0 -0
  30. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/standard-schema.ts +64 -0
  31. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/tests/index.test.ts +46 -0
  32. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
  33. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
  34. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
  35. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
  36. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/to-json-schema.ts +977 -0
  37. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/util.ts +775 -0
  38. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/versions.ts +5 -0
  39. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/zsf.ts +323 -0
  40. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/index.ts +4 -0
  41. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/ar.ts +125 -0
  42. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/az.ts +121 -0
  43. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/be.ts +184 -0
  44. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/ca.ts +127 -0
  45. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/cs.ts +142 -0
  46. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/de.ts +124 -0
  47. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/en.ts +127 -0
  48. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/eo.ts +125 -0
  49. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/es.ts +125 -0
  50. node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/fa.ts +134 -0
.gitattributes CHANGED
@@ -30,3 +30,5 @@ node_modules/@jimp/js-bmp/src/images/windows95.png filter=lfs diff=lfs merge=lfs
30
  node_modules/@jimp/plugin-blit/src/__image_snapshots__/index-node-test-ts-blit-over-image-blit-alpha-1-snap.png filter=lfs diff=lfs merge=lfs -text
31
  node_modules/@jimp/plugin-blit/src/images/blit-alpha.png filter=lfs diff=lfs merge=lfs -text
32
  node_modules/@jimp/plugin-blur/src/__image_snapshots__/index-node-test-ts-has-alpha-image-with-alpha-1-snap.png filter=lfs diff=lfs merge=lfs -text
 
 
 
30
  node_modules/@jimp/plugin-blit/src/__image_snapshots__/index-node-test-ts-blit-over-image-blit-alpha-1-snap.png filter=lfs diff=lfs merge=lfs -text
31
  node_modules/@jimp/plugin-blit/src/images/blit-alpha.png filter=lfs diff=lfs merge=lfs -text
32
  node_modules/@jimp/plugin-blur/src/__image_snapshots__/index-node-test-ts-has-alpha-image-with-alpha-1-snap.png filter=lfs diff=lfs merge=lfs -text
33
+ node_modules/@jimp/plugin-color/src/__image_snapshots__/convolution-node-test-ts-convolution-new-pixel-value-is-greater-than-255-1-snap.png filter=lfs diff=lfs merge=lfs -text
34
+ node_modules/@jimp/plugin-color/src/images/qr.jpg filter=lfs diff=lfs merge=lfs -text
node_modules/@jimp/plugin-color/node_modules/zod/src/v4-mini/index.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export * from "../v4/mini/index.js";
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/refine.test.ts ADDED
@@ -0,0 +1,532 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { describe, expect, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ describe("basic refinement functionality", () => {
5
+ test("should create a new schema instance when refining", () => {
6
+ const obj1 = z.object({
7
+ first: z.string(),
8
+ second: z.string(),
9
+ });
10
+ const obj2 = obj1.partial().strict();
11
+ const obj3 = obj2.refine((data) => data.first || data.second, "Either first or second should be filled in.");
12
+
13
+ expect(obj1 === (obj2 as any)).toEqual(false);
14
+ expect(obj2 === (obj3 as any)).toEqual(false);
15
+ });
16
+
17
+ test("should validate according to refinement logic", () => {
18
+ const schema = z
19
+ .object({
20
+ first: z.string(),
21
+ second: z.string(),
22
+ })
23
+ .partial()
24
+ .strict()
25
+ .refine((data) => data.first || data.second, "Either first or second should be filled in.");
26
+
27
+ // Should fail on empty object
28
+ expect(() => schema.parse({})).toThrow();
29
+
30
+ // Should pass with first property
31
+ expect(schema.parse({ first: "a" })).toEqual({ first: "a" });
32
+
33
+ // Should pass with second property
34
+ expect(schema.parse({ second: "a" })).toEqual({ second: "a" });
35
+
36
+ // Should pass with both properties
37
+ expect(schema.parse({ first: "a", second: "a" })).toEqual({ first: "a", second: "a" });
38
+ });
39
+
40
+ test("should validate strict mode correctly", () => {
41
+ const schema = z
42
+ .object({
43
+ first: z.string(),
44
+ second: z.string(),
45
+ })
46
+ .partial()
47
+ .strict();
48
+
49
+ // Should throw on extra properties
50
+ expect(() => schema.parse({ third: "adsf" })).toThrow();
51
+ });
52
+ });
53
+
54
+ describe("refinement with custom error messages", () => {
55
+ test("should use custom error message when validation fails", () => {
56
+ const validationSchema = z
57
+ .object({
58
+ email: z.string().email(),
59
+ password: z.string(),
60
+ confirmPassword: z.string(),
61
+ })
62
+ .refine((data) => data.password === data.confirmPassword, "Both password and confirmation must match");
63
+
64
+ const result = validationSchema.safeParse({
65
+ email: "aaaa@gmail.com",
66
+ password: "aaaaaaaa",
67
+ confirmPassword: "bbbbbbbb",
68
+ });
69
+
70
+ expect(result.success).toEqual(false);
71
+ if (!result.success) {
72
+ expect(result.error.issues[0].message).toEqual("Both password and confirmation must match");
73
+ }
74
+ });
75
+ });
76
+
77
+ describe("async refinements", () => {
78
+ test("should support async refinement functions", async () => {
79
+ const validationSchema = z
80
+ .object({
81
+ email: z.string().email(),
82
+ password: z.string(),
83
+ confirmPassword: z.string(),
84
+ })
85
+ .refine(
86
+ (data) => Promise.resolve().then(() => data.password === data.confirmPassword),
87
+ "Both password and confirmation must match"
88
+ );
89
+
90
+ // Should pass with matching passwords
91
+ const validData = {
92
+ email: "aaaa@gmail.com",
93
+ password: "password",
94
+ confirmPassword: "password",
95
+ };
96
+
97
+ await expect(validationSchema.parseAsync(validData)).resolves.toEqual(validData);
98
+
99
+ // Should fail with non-matching passwords
100
+ await expect(
101
+ validationSchema.parseAsync({
102
+ email: "aaaa@gmail.com",
103
+ password: "password",
104
+ confirmPassword: "different",
105
+ })
106
+ ).rejects.toThrow();
107
+ });
108
+ });
109
+
110
+ describe("early termination options", () => {
111
+ test("should abort early with continue: false", () => {
112
+ const schema = z
113
+ .string()
114
+ .superRefine((val, ctx) => {
115
+ if (val.length < 2) {
116
+ ctx.addIssue({
117
+ code: "custom",
118
+ message: "BAD",
119
+ continue: false,
120
+ });
121
+ }
122
+ })
123
+ .refine((_) => false);
124
+
125
+ const result = schema.safeParse("");
126
+ expect(result.success).toEqual(false);
127
+ if (!result.success) {
128
+ expect(result.error.issues.length).toEqual(1);
129
+ expect(result.error.issues[0].message).toEqual("BAD");
130
+ }
131
+ });
132
+
133
+ test("should abort early with fatal: true", () => {
134
+ const schema = z
135
+ .string()
136
+ .superRefine((val, ctx) => {
137
+ if (val.length < 2) {
138
+ ctx.addIssue({
139
+ code: "custom",
140
+ fatal: true,
141
+ message: "BAD",
142
+ });
143
+ }
144
+ })
145
+ .refine((_) => false);
146
+
147
+ const result = schema.safeParse("");
148
+ expect(result.success).toEqual(false);
149
+ if (!result.success) {
150
+ expect(result.error.issues.length).toEqual(1);
151
+ expect(result.error.issues[0].message).toEqual("BAD");
152
+ }
153
+ });
154
+
155
+ test("should abort early with abort flag", () => {
156
+ const schema = z
157
+ .string()
158
+ .refine((_) => false, { abort: true })
159
+ .refine((_) => false);
160
+
161
+ const result = schema.safeParse("");
162
+ expect(result.success).toEqual(false);
163
+ if (!result.success) {
164
+ expect(result.error.issues.length).toEqual(1);
165
+ }
166
+ });
167
+ });
168
+
169
+ describe("custom error paths", () => {
170
+ test("should use custom path in error message", async () => {
171
+ const result = await z
172
+ .object({ password: z.string(), confirm: z.string() })
173
+ .refine((data) => data.confirm === data.password, { path: ["confirm"] })
174
+ .safeParse({ password: "asdf", confirm: "qewr" });
175
+
176
+ expect(result.success).toEqual(false);
177
+ if (!result.success) {
178
+ expect(result.error.issues[0].path).toEqual(["confirm"]);
179
+ }
180
+ });
181
+ });
182
+
183
+ describe("superRefine functionality", () => {
184
+ test("should support multiple validation rules", () => {
185
+ const Strings = z.array(z.string()).superRefine((val, ctx) => {
186
+ if (val.length > 3) {
187
+ ctx.addIssue({
188
+ input: val,
189
+ code: "too_big",
190
+ origin: "array",
191
+ maximum: 3,
192
+ inclusive: true,
193
+ exact: true,
194
+ message: "Too many items 😡",
195
+ });
196
+ }
197
+
198
+ if (val.length !== new Set(val).size) {
199
+ ctx.addIssue({
200
+ input: val,
201
+ code: "custom",
202
+ message: `No duplicates allowed.`,
203
+ });
204
+ }
205
+ });
206
+
207
+ // Should fail with too many items and duplicates
208
+ const result = Strings.safeParse(["asfd", "asfd", "asfd", "asfd"]);
209
+ expect(result.success).toEqual(false);
210
+ if (!result.success) {
211
+ expect(result.error.issues.length).toEqual(2);
212
+ expect(result.error.issues[0].message).toEqual("Too many items 😡");
213
+ expect(result.error.issues[1].message).toEqual("No duplicates allowed.");
214
+ }
215
+
216
+ // Should pass with valid input
217
+ const validArray = ["asfd", "qwer"];
218
+ expect(Strings.parse(validArray)).toEqual(validArray);
219
+ });
220
+
221
+ test("should support async superRefine", async () => {
222
+ const Strings = z.array(z.string()).superRefine(async (val, ctx) => {
223
+ if (val.length > 3) {
224
+ ctx.addIssue({
225
+ input: val,
226
+ code: "too_big",
227
+ origin: "array",
228
+ maximum: 3,
229
+ inclusive: true,
230
+ message: "Too many items 😡",
231
+ });
232
+ }
233
+
234
+ if (val.length !== new Set(val).size) {
235
+ ctx.addIssue({
236
+ input: val,
237
+ code: "custom",
238
+ message: `No duplicates allowed.`,
239
+ });
240
+ }
241
+ });
242
+
243
+ // Should fail with too many items and duplicates
244
+ const result = await Strings.safeParseAsync(["asfd", "asfd", "asfd", "asfd"]);
245
+ expect(result.success).toEqual(false);
246
+ if (!result.success) {
247
+ expect(result.error.issues.length).toEqual(2);
248
+ }
249
+
250
+ // Should pass with valid input
251
+ const validArray = ["asfd", "qwer"];
252
+ await expect(Strings.parseAsync(validArray)).resolves.toEqual(validArray);
253
+ });
254
+
255
+ test("should accept string as shorthand for custom error message", () => {
256
+ const schema = z.string().superRefine((_, ctx) => {
257
+ ctx.addIssue("bad stuff");
258
+ });
259
+
260
+ const result = schema.safeParse("asdf");
261
+ expect(result.success).toEqual(false);
262
+ if (!result.success) {
263
+ expect(result.error.issues).toHaveLength(1);
264
+ expect(result.error.issues[0].message).toEqual("bad stuff");
265
+ }
266
+ });
267
+
268
+ test("should respect fatal flag in superRefine", () => {
269
+ const schema = z
270
+ .string()
271
+ .superRefine((val, ctx) => {
272
+ if (val === "") {
273
+ ctx.addIssue({
274
+ input: val,
275
+ code: "custom",
276
+ message: "foo",
277
+ fatal: true,
278
+ });
279
+ }
280
+ })
281
+ .superRefine((val, ctx) => {
282
+ if (val !== " ") {
283
+ ctx.addIssue({
284
+ input: val,
285
+ code: "custom",
286
+ message: "bar",
287
+ });
288
+ }
289
+ });
290
+
291
+ const result = schema.safeParse("");
292
+ expect(result.success).toEqual(false);
293
+ if (!result.success) {
294
+ expect(result.error.issues.length).toEqual(1);
295
+ expect(result.error.issues[0].message).toEqual("foo");
296
+ }
297
+ });
298
+ });
299
+
300
+ describe("chained refinements", () => {
301
+ test("should collect all validation errors when appropriate", () => {
302
+ const objectSchema = z
303
+ .object({
304
+ length: z.number(),
305
+ size: z.number(),
306
+ })
307
+ .refine(({ length }) => length > 5, {
308
+ path: ["length"],
309
+ message: "length greater than 5",
310
+ })
311
+ .refine(({ size }) => size > 7, {
312
+ path: ["size"],
313
+ message: "size greater than 7",
314
+ });
315
+
316
+ // Should fail with one error
317
+ const r1 = objectSchema.safeParse({
318
+ length: 4,
319
+ size: 9,
320
+ });
321
+ expect(r1.success).toEqual(false);
322
+ if (!r1.success) {
323
+ expect(r1.error.issues.length).toEqual(1);
324
+ expect(r1.error.issues[0].path).toEqual(["length"]);
325
+ }
326
+
327
+ // Should fail with two errors
328
+ const r2 = objectSchema.safeParse({
329
+ length: 4,
330
+ size: 3,
331
+ });
332
+ expect(r2.success).toEqual(false);
333
+ if (!r2.success) {
334
+ expect(r2.error.issues.length).toEqual(2);
335
+ }
336
+
337
+ // Should pass with valid input
338
+ const validData = {
339
+ length: 6,
340
+ size: 8,
341
+ };
342
+ expect(objectSchema.parse(validData)).toEqual(validData);
343
+ });
344
+ });
345
+
346
+ // Commented tests can be uncommented once type-checking issues are resolved
347
+ /*
348
+ describe("type refinement", () => {
349
+ test("refinement type guard", () => {
350
+ const validationSchema = z.object({
351
+ a: z.string().refine((s): s is "a" => s === "a"),
352
+ });
353
+ type Input = z.input<typeof validationSchema>;
354
+ type Schema = z.infer<typeof validationSchema>;
355
+
356
+ expectTypeOf<Input["a"]>().not.toEqualTypeOf<"a">();
357
+ expectTypeOf<Input["a"]>().toEqualTypeOf<string>();
358
+
359
+ expectTypeOf<Schema["a"]>().toEqualTypeOf<"a">();
360
+ expectTypeOf<Schema["a"]>().not.toEqualTypeOf<string>();
361
+ });
362
+
363
+ test("superRefine - type narrowing", () => {
364
+ type NarrowType = { type: string; age: number };
365
+ const schema = z
366
+ .object({
367
+ type: z.string(),
368
+ age: z.number(),
369
+ })
370
+ .nullable()
371
+ .superRefine((arg, ctx): arg is NarrowType => {
372
+ if (!arg) {
373
+ // still need to make a call to ctx.addIssue
374
+ ctx.addIssue({
375
+ input: arg,
376
+ code: "custom",
377
+ message: "cannot be null",
378
+ fatal: true,
379
+ });
380
+ return false;
381
+ }
382
+ return true;
383
+ });
384
+
385
+ expectTypeOf<z.infer<typeof schema>>().toEqualTypeOf<NarrowType>();
386
+
387
+ expect(schema.safeParse({ type: "test", age: 0 }).success).toEqual(true);
388
+ expect(schema.safeParse(null).success).toEqual(false);
389
+ });
390
+
391
+ test("chained mixed refining types", () => {
392
+ type firstRefinement = { first: string; second: number; third: true };
393
+ type secondRefinement = { first: "bob"; second: number; third: true };
394
+ type thirdRefinement = { first: "bob"; second: 33; third: true };
395
+ const schema = z
396
+ .object({
397
+ first: z.string(),
398
+ second: z.number(),
399
+ third: z.boolean(),
400
+ })
401
+ .nullable()
402
+ .refine((arg): arg is firstRefinement => !!arg?.third)
403
+ .superRefine((arg, ctx): arg is secondRefinement => {
404
+ expectTypeOf<typeof arg>().toEqualTypeOf<firstRefinement>();
405
+ if (arg.first !== "bob") {
406
+ ctx.addIssue({
407
+ input: arg,
408
+ code: "custom",
409
+ message: "`first` property must be `bob`",
410
+ });
411
+ return false;
412
+ }
413
+ return true;
414
+ })
415
+ .refine((arg): arg is thirdRefinement => {
416
+ expectTypeOf<typeof arg>().toEqualTypeOf<secondRefinement>();
417
+ return arg.second === 33;
418
+ });
419
+
420
+ expectTypeOf<z.infer<typeof schema>>().toEqualTypeOf<thirdRefinement>();
421
+ });
422
+ });
423
+ */
424
+
425
+ test("when", () => {
426
+ const schema = z
427
+ .strictObject({
428
+ password: z.string().min(8),
429
+ confirmPassword: z.string(),
430
+ other: z.string(),
431
+ })
432
+ .refine(
433
+ (data) => {
434
+ console.log("running check...");
435
+ console.log(data);
436
+ console.log(data.password);
437
+ return data.password === data.confirmPassword;
438
+ },
439
+ {
440
+ message: "Passwords do not match",
441
+ path: ["confirmPassword"],
442
+ when(payload) {
443
+ if (payload.value === undefined) return false;
444
+ if (payload.value === null) return false;
445
+ // no issues with confirmPassword or password
446
+ return payload.issues.every((iss) => iss.path?.[0] !== "confirmPassword" && iss.path?.[0] !== "password");
447
+ },
448
+ }
449
+ );
450
+
451
+ expect(schema.safeParse(undefined)).toMatchInlineSnapshot(`
452
+ {
453
+ "error": [ZodError: [
454
+ {
455
+ "expected": "object",
456
+ "code": "invalid_type",
457
+ "path": [],
458
+ "message": "Invalid input: expected object, received undefined"
459
+ }
460
+ ]],
461
+ "success": false,
462
+ }
463
+ `);
464
+ expect(schema.safeParse(null)).toMatchInlineSnapshot(`
465
+ {
466
+ "error": [ZodError: [
467
+ {
468
+ "expected": "object",
469
+ "code": "invalid_type",
470
+ "path": [],
471
+ "message": "Invalid input: expected object, received null"
472
+ }
473
+ ]],
474
+ "success": false,
475
+ }
476
+ `);
477
+ expect(
478
+ schema.safeParse({
479
+ password: "asdf",
480
+ confirmPassword: "asdfg",
481
+ other: "qwer",
482
+ })
483
+ ).toMatchInlineSnapshot(`
484
+ {
485
+ "error": [ZodError: [
486
+ {
487
+ "origin": "string",
488
+ "code": "too_small",
489
+ "minimum": 8,
490
+ "inclusive": true,
491
+ "path": [
492
+ "password"
493
+ ],
494
+ "message": "Too small: expected string to have >=8 characters"
495
+ }
496
+ ]],
497
+ "success": false,
498
+ }
499
+ `);
500
+
501
+ expect(
502
+ schema.safeParse({
503
+ password: "asdf",
504
+ confirmPassword: "asdfg",
505
+ other: 1234,
506
+ })
507
+ ).toMatchInlineSnapshot(`
508
+ {
509
+ "error": [ZodError: [
510
+ {
511
+ "origin": "string",
512
+ "code": "too_small",
513
+ "minimum": 8,
514
+ "inclusive": true,
515
+ "path": [
516
+ "password"
517
+ ],
518
+ "message": "Too small: expected string to have >=8 characters"
519
+ },
520
+ {
521
+ "expected": "string",
522
+ "code": "invalid_type",
523
+ "path": [
524
+ "other"
525
+ ],
526
+ "message": "Invalid input: expected string, received number"
527
+ }
528
+ ]],
529
+ "success": false,
530
+ }
531
+ `);
532
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/registries.test.ts ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ test("globalRegistry", () => {
5
+ const reg = z.registry();
6
+
7
+ const a = z.string();
8
+ reg.add(a);
9
+ expect(reg.has(a)).toEqual(true);
10
+
11
+ reg.remove(a);
12
+ expect(reg.has(a)).toEqual(false);
13
+
14
+ a.register(z.globalRegistry, { field: "sup" });
15
+ expect(z.globalRegistry.has(a)).toEqual(true);
16
+ expect(z.globalRegistry.get(a)).toEqual({ field: "sup" });
17
+
18
+ z.globalRegistry.remove(a);
19
+ expect(z.globalRegistry.has(a)).toEqual(false);
20
+ });
21
+
22
+ test("z.registry", () => {
23
+ const fieldRegistry = z.registry<{ name: string; description: string }>();
24
+
25
+ const a = z.string();
26
+ fieldRegistry.add(a, { name: "hello", description: "world" });
27
+ const a_meta = fieldRegistry.get(a);
28
+ expect(a_meta).toEqual({ name: "hello", description: "world" });
29
+
30
+ fieldRegistry.remove(a);
31
+ expect(fieldRegistry.has(a)).toEqual(false);
32
+ expect(fieldRegistry.get(a)).toEqual(undefined);
33
+ });
34
+
35
+ test("z.registry no metadata", () => {
36
+ const fieldRegistry = z.registry();
37
+
38
+ const a = z.string();
39
+ fieldRegistry.add(a);
40
+ fieldRegistry.add(z.number());
41
+ expect(fieldRegistry.get(a)).toEqual(undefined);
42
+ expect(fieldRegistry.has(a)).toEqual(true);
43
+ });
44
+
45
+ test("z.registry with schema constraints", () => {
46
+ const fieldRegistry = z.registry<{ name: string; description: string }, z.ZodString>();
47
+
48
+ const a = z.string();
49
+ fieldRegistry.add(a, { name: "hello", description: "world" });
50
+ // @ts-expect-error
51
+ fieldRegistry.add(z.number(), { name: "test" });
52
+ // @ts-expect-error
53
+ z.number().register(fieldRegistry, { name: "test", description: "test" });
54
+ });
55
+
56
+ // test("z.namedRegistry", () => {
57
+ // const namedReg = z
58
+ // .namedRegistry<{ name: string; description: string }>()
59
+ // .add(z.string(), { name: "hello", description: "world" })
60
+ // .add(z.number(), { name: "number", description: "number" });
61
+
62
+ // expect(namedReg.get("hello")).toEqual({
63
+ // name: "hello",
64
+ // description: "world",
65
+ // });
66
+ // expect(namedReg.has("hello")).toEqual(true);
67
+ // expect(namedReg.get("number")).toEqual({
68
+ // name: "number",
69
+ // description: "number",
70
+ // });
71
+
72
+ // // @ts-expect-error
73
+ // namedReg.get("world");
74
+ // // @ts-expect-error
75
+ // expect(namedReg.get("world")).toEqual(undefined);
76
+
77
+ // const hello = namedReg.get("hello");
78
+ // expect(hello).toEqual({ name: "hello", description: "world" });
79
+ // expectTypeOf<typeof hello>().toEqualTypeOf<{
80
+ // name: "hello";
81
+ // description: "world";
82
+ // }>();
83
+ // expectTypeOf<typeof namedReg.items>().toEqualTypeOf<{
84
+ // hello: { name: "hello"; description: "world" };
85
+ // number: { name: "number"; description: "number" };
86
+ // }>();
87
+ // });
88
+
89
+ test("output type in registry meta", () => {
90
+ const reg = z.registry<{ out: z.$output }>();
91
+ const a = z.string();
92
+ reg.add(a, { out: "asdf" });
93
+ // @ts-expect-error
94
+ reg.add(a, 1234);
95
+ expectTypeOf(reg.get(a)).toEqualTypeOf<{ out: string } | undefined>();
96
+ });
97
+
98
+ test("output type in registry meta - objects and arrays", () => {
99
+ const reg = z.registry<{ name: string; examples: z.$output[] }>();
100
+ const a = z.string();
101
+ reg.add(a, { name: "hello", examples: ["world"] });
102
+
103
+ // @ts-expect-error
104
+ reg.add(a, { name: "hello", examples: "world" });
105
+ expectTypeOf(reg.get(a)).toEqualTypeOf<{ name: string; examples: string[] } | undefined>();
106
+ });
107
+
108
+ test("input type in registry meta", () => {
109
+ const reg = z.registry<{ in: z.$input }>();
110
+ const a = z.pipe(z.number(), z.transform(String));
111
+ reg.add(a, { in: 1234 });
112
+ // @ts-expect-error
113
+ reg.add(a, "1234");
114
+ expectTypeOf(reg.get(a)).toEqualTypeOf<{ in: number } | undefined>();
115
+ });
116
+
117
+ test("input type in registry meta - objects and arrays", () => {
118
+ const reg = z.registry<{ name: string; examples: z.$input[] }>();
119
+ const a = z.pipe(z.number(), z.transform(String));
120
+ reg.add(a, { name: "hello", examples: [1234] });
121
+
122
+ // @ts-expect-error
123
+ reg.add(a, { name: "hello", examples: "world" });
124
+ expectTypeOf(reg.get(a)).toEqualTypeOf<{ name: string; examples: number[] } | undefined>();
125
+ });
126
+
127
+ test(".meta method", () => {
128
+ const a1 = z.string();
129
+ const a2 = a1.meta({ name: "hello" });
130
+
131
+ expect(a1.meta()).toEqual(undefined);
132
+ expect(a2.meta()).toEqual({ name: "hello" });
133
+ expect(a1 === a2).toEqual(false);
134
+ });
135
+
136
+ test(".meta metadata does not bubble up", () => {
137
+ const a1 = z.string().meta({ name: "hello" });
138
+ const a2 = a1.optional();
139
+
140
+ expect(a1.meta()).toEqual({ name: "hello" });
141
+ expect(a2.meta()).toEqual(undefined);
142
+ });
143
+
144
+ test(".describe", () => {
145
+ const a1 = z.string();
146
+ const a2 = a1.describe("Hello");
147
+
148
+ expect(a1.description).toEqual(undefined);
149
+ expect(a2.description).toEqual("Hello");
150
+ });
151
+
152
+ test("inherit across clone", () => {
153
+ const A = z.string().meta({ a: true });
154
+ expect(A.meta()).toEqual({ a: true });
155
+ const B = A.meta({ b: true });
156
+ expect(B.meta()).toEqual({ a: true, b: true });
157
+ const C = B.describe("hello");
158
+ expect(C.meta()).toEqual({ a: true, b: true, description: "hello" });
159
+ });
160
+
161
+ test("loose examples", () => {
162
+ z.string().register(z.globalRegistry, {
163
+ examples: ["example"],
164
+ });
165
+ });
166
+
167
+ test("function meta witout replacement", () => {
168
+ const myReg = z.registry<{
169
+ defaulter: (arg: string, test: boolean) => number;
170
+ }>();
171
+
172
+ const mySchema = z.date();
173
+ myReg.add(mySchema, {
174
+ defaulter: (arg, _test) => {
175
+ return arg.length;
176
+ },
177
+ });
178
+
179
+ expect(myReg.get(mySchema)!.defaulter("hello", true)).toEqual(5);
180
+ });
181
+
182
+ test("function meta with replacement", () => {
183
+ const myReg = z.registry<{
184
+ defaulter: (arg: z.$input, test: boolean) => z.$output;
185
+ }>();
186
+
187
+ const mySchema = z.string().transform((val) => val.length);
188
+ myReg.add(mySchema, {
189
+ defaulter: (arg, _test) => {
190
+ return arg.length;
191
+ },
192
+ });
193
+
194
+ expect(myReg.get(mySchema)!.defaulter("hello", true)).toEqual(5);
195
+ });
196
+
197
+ test("test .clear()", () => {
198
+ const reg = z.registry();
199
+ const a = z.string();
200
+ reg.add(a);
201
+ expect(reg.has(a)).toEqual(true);
202
+ reg.clear();
203
+ expect(reg.has(a)).toEqual(false);
204
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/set.test.ts ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ const stringSet = z.set(z.string());
5
+ type stringSet = z.infer<typeof stringSet>;
6
+
7
+ const minTwo = z.set(z.string()).min(2);
8
+ const maxTwo = z.set(z.string()).max(2);
9
+ const justTwo = z.set(z.string()).size(2);
10
+ const nonEmpty = z.set(z.string()).nonempty();
11
+ const nonEmptyMax = z.set(z.string()).nonempty().max(2);
12
+
13
+ test("type inference", () => {
14
+ expectTypeOf<stringSet>().toEqualTypeOf<Set<string>>();
15
+ });
16
+
17
+ test("valid parse", () => {
18
+ const result = stringSet.safeParse(new Set(["first", "second"]));
19
+ expect(result.success).toEqual(true);
20
+ expect(result.data!.has("first")).toEqual(true);
21
+ expect(result.data!.has("second")).toEqual(true);
22
+ expect(result.data!.has("third")).toEqual(false);
23
+
24
+ expect(() => {
25
+ minTwo.parse(new Set(["a", "b"]));
26
+ minTwo.parse(new Set(["a", "b", "c"]));
27
+ maxTwo.parse(new Set(["a", "b"]));
28
+ maxTwo.parse(new Set(["a"]));
29
+ justTwo.parse(new Set(["a", "b"]));
30
+ nonEmpty.parse(new Set(["a"]));
31
+ nonEmptyMax.parse(new Set(["a"]));
32
+ }).not.toThrow();
33
+ });
34
+
35
+ test("valid parse async", async () => {
36
+ const result = await stringSet.spa(new Set(["first", "second"]));
37
+ expect(result.success).toEqual(true);
38
+ expect(result.data!.has("first")).toEqual(true);
39
+ expect(result.data!.has("second")).toEqual(true);
40
+ expect(result.data!.has("third")).toEqual(false);
41
+
42
+ const asyncResult = await stringSet.safeParse(new Set(["first", "second"]));
43
+ expect(asyncResult.success).toEqual(true);
44
+ expect(asyncResult.data!.has("first")).toEqual(true);
45
+ expect(asyncResult.data!.has("second")).toEqual(true);
46
+ expect(asyncResult.data!.has("third")).toEqual(false);
47
+ });
48
+
49
+ test("valid parse: size-related methods", () => {
50
+ expect(() => {
51
+ minTwo.parse(new Set(["a", "b"]));
52
+ minTwo.parse(new Set(["a", "b", "c"]));
53
+ maxTwo.parse(new Set(["a", "b"]));
54
+ maxTwo.parse(new Set(["a"]));
55
+ justTwo.parse(new Set(["a", "b"]));
56
+ nonEmpty.parse(new Set(["a"]));
57
+ nonEmptyMax.parse(new Set(["a"]));
58
+ }).not.toThrow();
59
+
60
+ const sizeZeroResult = stringSet.parse(new Set());
61
+ expect(sizeZeroResult.size).toBe(0);
62
+
63
+ const sizeTwoResult = minTwo.parse(new Set(["a", "b"]));
64
+ expect(sizeTwoResult.size).toBe(2);
65
+ });
66
+
67
+ test("failing when parsing empty set in nonempty ", () => {
68
+ const result = nonEmpty.safeParse(new Set());
69
+ expect(result.success).toEqual(false);
70
+ expect(result.error!.issues.length).toEqual(1);
71
+ expect(result.error!.issues[0].code).toEqual("too_small");
72
+ });
73
+
74
+ test("failing when set is smaller than min() ", () => {
75
+ const result = minTwo.safeParse(new Set(["just_one"]));
76
+ expect(result.success).toEqual(false);
77
+ expect(result.error!.issues.length).toEqual(1);
78
+ expect(result.error!.issues[0].code).toEqual("too_small");
79
+ });
80
+
81
+ test("failing when set is bigger than max() ", () => {
82
+ const result = maxTwo.safeParse(new Set(["one", "two", "three"]));
83
+ expect(result.success).toEqual(false);
84
+ expect(result.error!.issues.length).toEqual(1);
85
+ expect(result.error!.issues[0].code).toEqual("too_big");
86
+ });
87
+
88
+ test("doesn’t throw when an empty set is given", () => {
89
+ const result = stringSet.safeParse(new Set([]));
90
+ expect(result.success).toEqual(true);
91
+ });
92
+
93
+ test("throws when a Map is given", () => {
94
+ const result = stringSet.safeParse(new Map([]));
95
+ expect(result.success).toEqual(false);
96
+ expect(result.error).toMatchInlineSnapshot(`
97
+ [ZodError: [
98
+ {
99
+ "expected": "set",
100
+ "code": "invalid_type",
101
+ "path": [],
102
+ "message": "Invalid input: expected set, received Map"
103
+ }
104
+ ]]
105
+ `);
106
+ });
107
+
108
+ test("throws when the given set has invalid input", () => {
109
+ const result = stringSet.safeParse(new Set([Symbol()]));
110
+ expect(result.success).toEqual(false);
111
+ expect(result.error!.issues.length).toEqual(1);
112
+ expect(result.error).toMatchInlineSnapshot(`
113
+ [ZodError: [
114
+ {
115
+ "expected": "string",
116
+ "code": "invalid_type",
117
+ "path": [],
118
+ "message": "Invalid input: expected string, received symbol"
119
+ }
120
+ ]]
121
+ `);
122
+ });
123
+
124
+ test("throws when the given set has multiple invalid entries", () => {
125
+ const result = stringSet.safeParse(new Set([1, 2] as any[]));
126
+ expect(result.success).toEqual(false);
127
+ expect(result.error!.issues.length).toEqual(2);
128
+ expect(result.error).toMatchInlineSnapshot(`
129
+ [ZodError: [
130
+ {
131
+ "expected": "string",
132
+ "code": "invalid_type",
133
+ "path": [],
134
+ "message": "Invalid input: expected string, received number"
135
+ },
136
+ {
137
+ "expected": "string",
138
+ "code": "invalid_type",
139
+ "path": [],
140
+ "message": "Invalid input: expected string, received number"
141
+ }
142
+ ]]
143
+ `);
144
+ });
145
+
146
+ test("min/max", async () => {
147
+ const schema = z.set(z.string()).min(4).max(5);
148
+
149
+ const r1 = schema.safeParse(new Set(["a", "b", "c", "d"]));
150
+ expect(r1.success).toEqual(true);
151
+
152
+ const r2 = schema.safeParse(new Set(["a", "b", "c"]));
153
+ expect(r2.success).toEqual(false);
154
+ expect(r2.error!.issues).toMatchInlineSnapshot(`
155
+ [
156
+ {
157
+ "code": "too_small",
158
+ "message": "Too small: expected set to have >4 items",
159
+ "minimum": 4,
160
+ "origin": "set",
161
+ "path": [],
162
+ },
163
+ ]
164
+ `);
165
+
166
+ const r3 = schema.safeParse(new Set(["a", "b", "c", "d", "e", "f"]));
167
+ expect(r3.success).toEqual(false);
168
+ expect(r3.error!.issues).toMatchInlineSnapshot(`
169
+ [
170
+ {
171
+ "code": "too_big",
172
+ "maximum": 5,
173
+ "message": "Too big: expected set to have <5 items",
174
+ "origin": "set",
175
+ "path": [],
176
+ },
177
+ ]
178
+ `);
179
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+
3
+ import * as z from "zod/v4";
4
+
5
+ test("length checks", async () => {
6
+ const schema = z.string();
7
+ const result = await schema["~standard"].validate(12);
8
+ expect(result).toMatchInlineSnapshot(`
9
+ {
10
+ "issues": [
11
+ {
12
+ "code": "invalid_type",
13
+ "expected": "string",
14
+ "message": "Invalid input: expected string, received number",
15
+ "path": [],
16
+ },
17
+ ],
18
+ }
19
+ `);
20
+ });
21
+
22
+ test("length checks", async () => {
23
+ const schema = z.string();
24
+ const result = await schema["~standard"].validate("asdf");
25
+ expect(result).toMatchInlineSnapshot(`
26
+ {
27
+ "value": "asdf",
28
+ }
29
+ `);
30
+ });
31
+
32
+ test("length checks", async () => {
33
+ const schema = z.string().refine(async (val) => val.length > 5);
34
+ const result = await schema["~standard"].validate(12);
35
+ expect(result).toMatchInlineSnapshot(`
36
+ {
37
+ "issues": [
38
+ {
39
+ "code": "invalid_type",
40
+ "expected": "string",
41
+ "message": "Invalid input: expected string, received number",
42
+ "path": [],
43
+ },
44
+ ],
45
+ }
46
+ `);
47
+ });
48
+
49
+ test("length checks", async () => {
50
+ const schema = z.string().refine(async (val) => val.length > 5);
51
+ const result = await schema["~standard"].validate("234134134");
52
+ expect(result).toMatchInlineSnapshot(`
53
+ {
54
+ "value": "234134134",
55
+ }
56
+ `);
57
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/string-formats.test.ts ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+
3
+ import * as z from "zod/v4";
4
+
5
+ test("string format methods", () => {
6
+ const a = z.email().min(10);
7
+ const b = z.email().max(10);
8
+ const c = z.email().length(10);
9
+ const d = z.email().uppercase();
10
+ const e = z.email().lowercase();
11
+
12
+ // Positive and negative cases for `a`
13
+ expect(a.safeParse("longemail@example.com").success).toBe(true); // Positive
14
+ expect(a.safeParse("ort@e.co").success).toBe(false); // Negative
15
+
16
+ // Positive and negative cases for `b`
17
+ expect(b.safeParse("sho@e.co").success).toBe(true); // Positive
18
+ expect(b.safeParse("longemail@example.com").success).toBe(false); // Negative
19
+
20
+ // Positive and negative cases for `c`
21
+ expect(c.safeParse("56780@e.co").success).toBe(true); // Positive
22
+ expect(c.safeParse("shoasdfasdfrt@e.co").success).toBe(false); // Negative
23
+
24
+ // Positive and negative cases for `d`
25
+ expect(d.safeParse("EMAIL@EXAMPLE.COM").success).toBe(true); // Positive
26
+ expect(d.safeParse("email@example.com").success).toBe(false); // Negative
27
+
28
+ // Positive and negative cases for `e`
29
+ expect(e.safeParse("email@example.com").success).toBe(true); // Positive
30
+ expect(e.safeParse("EMAIL@EXAMPLE.COM").success).toBe(false); // Negative
31
+ });
32
+
33
+ test("z.stringFormat", () => {
34
+ const ccRegex = /^(?:\d{14,19}|\d{4}(?: \d{3,6}){2,4}|\d{4}(?:-\d{3,6}){2,4})$/u;
35
+
36
+ const a = z
37
+ .stringFormat("creditCard", (val) => ccRegex.test(val), {
38
+ error: `Invalid credit card number`,
39
+ })
40
+ .refine((_) => false, "Also bad");
41
+
42
+ expect(a.safeParse("asdf")).toMatchInlineSnapshot(`
43
+ {
44
+ "error": [ZodError: [
45
+ {
46
+ "code": "invalid_format",
47
+ "format": "creditCard",
48
+ "path": [],
49
+ "message": "Invalid credit card number"
50
+ },
51
+ {
52
+ "code": "custom",
53
+ "path": [],
54
+ "message": "Also bad"
55
+ }
56
+ ]],
57
+ "success": false,
58
+ }
59
+ `);
60
+ expect(a.safeParse("1234-5678-9012-3456")).toMatchInlineSnapshot(`
61
+ {
62
+ "error": [ZodError: [
63
+ {
64
+ "code": "custom",
65
+ "path": [],
66
+ "message": "Also bad"
67
+ }
68
+ ]],
69
+ "success": false,
70
+ }
71
+ `);
72
+ expect(a.def.pattern).toMatchInlineSnapshot(`undefined`);
73
+
74
+ const b = z
75
+ .stringFormat("creditCard", ccRegex, {
76
+ abort: true,
77
+ error: `Invalid credit card number`,
78
+ })
79
+ .refine((_) => false, "Also bad");
80
+
81
+ expect(b.safeParse("asdf")).toMatchInlineSnapshot(`
82
+ {
83
+ "error": [ZodError: [
84
+ {
85
+ "code": "invalid_format",
86
+ "format": "creditCard",
87
+ "path": [],
88
+ "message": "Invalid credit card number"
89
+ }
90
+ ]],
91
+ "success": false,
92
+ }
93
+ `);
94
+ expect(b.safeParse("1234-5678-9012-3456")).toMatchInlineSnapshot(`
95
+ {
96
+ "error": [ZodError: [
97
+ {
98
+ "code": "custom",
99
+ "path": [],
100
+ "message": "Also bad"
101
+ }
102
+ ]],
103
+ "success": false,
104
+ }
105
+ `);
106
+ expect(b.def.pattern).toMatchInlineSnapshot(
107
+ `/\\^\\(\\?:\\\\d\\{14,19\\}\\|\\\\d\\{4\\}\\(\\?: \\\\d\\{3,6\\}\\)\\{2,4\\}\\|\\\\d\\{4\\}\\(\\?:-\\\\d\\{3,6\\}\\)\\{2,4\\}\\)\\$/u`
108
+ );
109
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/string.test.ts ADDED
@@ -0,0 +1,881 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { randomBytes } from "node:crypto";
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v4";
5
+
6
+ const minFive = z.string().min(5, "min5");
7
+ const maxFive = z.string().max(5, "max5");
8
+ const justFive = z.string().length(5);
9
+ const nonempty = z.string().min(1, "nonempty");
10
+ const includes = z.string().includes("includes");
11
+ const includesFromIndex2 = z.string().includes("includes", { position: 2 });
12
+ const startsWith = z.string().startsWith("startsWith");
13
+ const endsWith = z.string().endsWith("endsWith");
14
+
15
+ test("length checks", () => {
16
+ minFive.parse("12345");
17
+ minFive.parse("123456");
18
+ maxFive.parse("12345");
19
+ maxFive.parse("1234");
20
+ nonempty.parse("1");
21
+ justFive.parse("12345");
22
+
23
+ expect(() => minFive.parse("1234")).toThrow();
24
+ expect(() => maxFive.parse("123456")).toThrow();
25
+ expect(() => nonempty.parse("")).toThrow();
26
+ expect(() => justFive.parse("1234")).toThrow();
27
+ expect(() => justFive.parse("123456")).toThrow();
28
+ });
29
+
30
+ test("includes", () => {
31
+ includes.parse("XincludesXX");
32
+ includesFromIndex2.parse("XXXincludesXX");
33
+
34
+ expect(() => includes.parse("XincludeXX")).toThrow();
35
+ expect(() => includesFromIndex2.parse("XincludesXX")).toThrow();
36
+ });
37
+
38
+ test("startswith/endswith", () => {
39
+ startsWith.parse("startsWithX");
40
+ endsWith.parse("XendsWith");
41
+
42
+ expect(() => startsWith.parse("x")).toThrow();
43
+ expect(() => endsWith.parse("x")).toThrow();
44
+ });
45
+
46
+ test("email validations", () => {
47
+ const validEmails = [
48
+ `email@domain.com`,
49
+ `firstname.lastname@domain.com`,
50
+ `email@subdomain.domain.com`,
51
+ `firstname+lastname@domain.com`,
52
+ `1234567890@domain.com`,
53
+ `email@domain-one.com`,
54
+ `_______@domain.com`,
55
+ `email@domain.name`,
56
+ `email@domain.co.jp`,
57
+ `firstname-lastname@domain.com`,
58
+ `very.common@example.com`,
59
+ `disposable.style.email.with+symbol@example.com`,
60
+ `other.email-with-hyphen@example.com`,
61
+ `fully-qualified-domain@example.com`,
62
+ `user.name+tag+sorting@example.com`,
63
+ `x@example.com`,
64
+ `mojojojo@asdf.example.com`,
65
+ `example-indeed@strange-example.com`,
66
+ `example@s.example`,
67
+ `user-@example.org`,
68
+ `user@my-example.com`,
69
+ `a@b.cd`,
70
+ `work+user@mail.com`,
71
+ `tom@test.te-st.com`,
72
+ `something@subdomain.domain-with-hyphens.tld`,
73
+ `common'name@domain.com`,
74
+ `francois@etu.inp-n7.fr`,
75
+ ];
76
+ const invalidEmails = [
77
+ // no "printable characters"
78
+ // `user%example.com@example.org`,
79
+ // `mailhost!username@example.org`,
80
+ // `test/test@test.com`,
81
+
82
+ // double @
83
+ `francois@@etu.inp-n7.fr`,
84
+ // do not support quotes
85
+ `"email"@domain.com`,
86
+ `"e asdf sadf ?<>ail"@domain.com`,
87
+ `" "@example.org`,
88
+ `"john..doe"@example.org`,
89
+ `"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com`,
90
+ // do not support comma
91
+ `a,b@domain.com`,
92
+
93
+ // do not support IPv4
94
+ `email@123.123.123.123`,
95
+ `email@[123.123.123.123]`,
96
+ `postmaster@123.123.123.123`,
97
+ `user@[68.185.127.196]`,
98
+ `ipv4@[85.129.96.247]`,
99
+ `valid@[79.208.229.53]`,
100
+ `valid@[255.255.255.255]`,
101
+ `valid@[255.0.55.2]`,
102
+ `valid@[255.0.55.2]`,
103
+
104
+ // do not support ipv6
105
+ `hgrebert0@[IPv6:4dc8:ac7:ce79:8878:1290:6098:5c50:1f25]`,
106
+ `bshapiro4@[IPv6:3669:c709:e981:4884:59a3:75d1:166b:9ae]`,
107
+ `jsmith@[IPv6:2001:db8::1]`,
108
+ `postmaster@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]`,
109
+ `postmaster@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:192.168.1.1]`,
110
+
111
+ // microsoft test cases
112
+ `plainaddress`,
113
+ `#@%^%#$@#$@#.com`,
114
+ `@domain.com`,
115
+ `Joe Smith &lt;email@domain.com&gt;`,
116
+ `email.domain.com`,
117
+ `email@domain@domain.com`,
118
+ `.email@domain.com`,
119
+ `email.@domain.com`,
120
+ `email..email@domain.com`,
121
+ `あいうえお@domain.com`,
122
+ `email@domain.com (Joe Smith)`,
123
+ `email@domain`,
124
+ `email@-domain.com`,
125
+ `email@111.222.333.44444`,
126
+ `email@domain..com`,
127
+ `Abc.example.com`,
128
+ `A@b@c@example.com`,
129
+ `colin..hacks@domain.com`,
130
+ `a"b(c)d,e:f;g<h>i[j\k]l@example.com`,
131
+ `just"not"right@example.com`,
132
+ `this is"not\allowed@example.com`,
133
+ `this\ still\"not\\allowed@example.com`,
134
+
135
+ // random
136
+ `i_like_underscore@but_its_not_allowed_in_this_part.example.com`,
137
+ `QA[icon]CHOCOLATE[icon]@test.com`,
138
+ `invalid@-start.com`,
139
+ `invalid@end.com-`,
140
+ `a.b@c.d`,
141
+ `invalid@[1.1.1.-1]`,
142
+ `invalid@[68.185.127.196.55]`,
143
+ `temp@[192.168.1]`,
144
+ `temp@[9.18.122.]`,
145
+ `double..point@test.com`,
146
+ `asdad@test..com`,
147
+ `asdad@hghg...sd...au`,
148
+ `asdad@hghg........au`,
149
+ `invalid@[256.2.2.48]`,
150
+ `invalid@[256.2.2.48]`,
151
+ `invalid@[999.465.265.1]`,
152
+ `jkibbey4@[IPv6:82c4:19a8::70a9:2aac:557::ea69:d985:28d]`,
153
+ `mlivesay3@[9952:143f:b4df:2179:49a1:5e82:b92e:6b6]`,
154
+ `gbacher0@[IPv6:bc37:4d3f:5048:2e26:37cc:248e:df8e:2f7f:af]`,
155
+ `invalid@[IPv6:5348:4ed3:5d38:67fb:e9b:acd2:c13:192.168.256.1]`,
156
+ `test@.com`,
157
+ `aaaaaaaaaaaaaaalongemailthatcausesregexDoSvulnerability@test.c`,
158
+ ];
159
+ const emailSchema = z.string().email();
160
+
161
+ expect(
162
+ validEmails.every((email) => {
163
+ return emailSchema.safeParse(email).success;
164
+ })
165
+ ).toBe(true);
166
+ expect(
167
+ invalidEmails.every((email) => {
168
+ return emailSchema.safeParse(email).success === false;
169
+ })
170
+ ).toBe(true);
171
+ });
172
+
173
+ test("base64 validations", () => {
174
+ const validBase64Strings = [
175
+ "SGVsbG8gV29ybGQ=", // "Hello World"
176
+ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==", // "This is an encoded string"
177
+ "TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcms=", // "Many hands make light work"
178
+ "UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", // "Patience is the key to success"
179
+ "QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", // "Base64 encoding is fun"
180
+ "MTIzNDU2Nzg5MA==", // "1234567890"
181
+ "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=", // "abcdefghijklmnopqrstuvwxyz"
182
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo=", // "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
183
+ "ISIkJSMmJyonKCk=", // "!\"#$%&'()*"
184
+ "", // Empty string is technically a valid base64
185
+ ];
186
+
187
+ for (const str of validBase64Strings) {
188
+ expect(str + z.string().base64().safeParse(str).success).toBe(`${str}true`);
189
+ }
190
+
191
+ const invalidBase64Strings = [
192
+ "12345", // Not padded correctly, not a multiple of 4 characters
193
+ "SGVsbG8gV29ybGQ", // Missing padding
194
+ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw", // Missing padding
195
+ "!UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", // Invalid character '!'
196
+ "?QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", // Invalid character '?'
197
+ ".MTIzND2Nzg5MC4=", // Invalid character '.'
198
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo", // Missing padding
199
+ ];
200
+
201
+ for (const str of invalidBase64Strings) {
202
+ expect(str + z.string().base64().safeParse(str).success).toBe(`${str}false`);
203
+ }
204
+ });
205
+
206
+ test("base64url validations", () => {
207
+ const base64url = z.string().base64url();
208
+
209
+ const validBase64URLStrings = [
210
+ "SGVsbG8gV29ybGQ", // "Hello World"
211
+
212
+ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw", // "This is an encoded string"
213
+
214
+ "TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcms", // "Many hands make light work"
215
+
216
+ "UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", // "Patience is the key to success"
217
+ "QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg", // "Base64 encoding is fun"
218
+
219
+ "MTIzNDU2Nzg5MA", // "1234567890"
220
+
221
+ "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo", // "abcdefghijklmnopqrstuvwxyz"
222
+
223
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo", // "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
224
+
225
+ "ISIkJSMmJyonKCk", // "!\"#$%&'()*"
226
+
227
+ "", // Empty string is technically valid base64url
228
+ "w7_Dv8O-w74K", // ÿÿþþ
229
+ "123456",
230
+ ];
231
+
232
+ for (const str of validBase64URLStrings) {
233
+ expect(str + base64url.safeParse(str).success).toBe(`${str}true`);
234
+ }
235
+
236
+ const invalidBase64URLStrings = [
237
+ "w7/Dv8O+w74K", // Has + and / characters (is base64)
238
+ "12345", // Invalid length (not a multiple of 4 characters when adding allowed number of padding characters)
239
+ "12345===", // Not padded correctly
240
+ "!UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", // Invalid character '!'
241
+ "?QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", // Invalid character '?'
242
+ ".MTIzND2Nzg5MC4=", // Invalid character '.'
243
+
244
+ // disallow valid padding
245
+ "SGVsbG8gV29ybGQ=", // "Hello World" with padding
246
+ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==", // "This is an encoded string" with padding
247
+ "TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcms=", // "Many hands make light work" with padding
248
+ "QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", // "Base64 encoding is fun" with padding
249
+ "MTIzNDU2Nzg5MA==", // "1234567890" with padding
250
+ "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=", // "abcdefghijklmnopqrstuvwxyz with padding"
251
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo=", // "ABCDEFGHIJKLMNOPQRSTUVWXYZ" with padding
252
+ "ISIkJSMmJyonKCk=", // "!\"#$%&'()*" with padding
253
+ ];
254
+
255
+ for (const str of invalidBase64URLStrings) {
256
+ expect(str + base64url.safeParse(str).success).toBe(`${str}false`);
257
+ }
258
+ });
259
+
260
+ test("big base64 and base64url", () => {
261
+ const bigbase64 = randomBytes(1024 * 1024 * 10).toString("base64");
262
+ z.base64().parse(bigbase64);
263
+ const bigbase64url = randomBytes(1024 * 1024 * 10).toString("base64url");
264
+ z.base64url().parse(bigbase64url);
265
+ });
266
+
267
+ function makeJwt(header: object, payload: object) {
268
+ const headerBase64 = Buffer.from(JSON.stringify(header)).toString("base64url");
269
+ const payloadBase64 = Buffer.from(JSON.stringify(payload)).toString("base64url");
270
+ const signature = "signature"; // Placeholder for the signature
271
+ return `${headerBase64}.${payloadBase64}.${signature}`;
272
+ }
273
+
274
+ test("jwt token", () => {
275
+ const jwt = z.string().jwt();
276
+ expect(() => jwt.parse("invalid")).toThrow();
277
+ expect(() => jwt.parse("invalid.invalid")).toThrow();
278
+ expect(() => jwt.parse("invalid.invalid.invalid")).toThrow();
279
+
280
+ // Valid JWTs
281
+ const es256jwt = z.string().jwt({ alg: "ES256" });
282
+ const d1 = makeJwt({ typ: "JWT", alg: "ES256" }, {});
283
+ jwt.parse(d1);
284
+ es256jwt.parse(d1);
285
+
286
+ // Invalid header
287
+ const d2 = makeJwt({}, {});
288
+ expect(() => jwt.parse(d2)).toThrow();
289
+
290
+ // Wrong algorithm
291
+ const d3 = makeJwt({ typ: "JWT", alg: "RS256" }, {});
292
+ expect(() => es256jwt.parse(d3)).toThrow();
293
+
294
+ // missing typ is fine
295
+ const d4 = makeJwt({ alg: "HS256" }, {});
296
+ jwt.parse(d4);
297
+
298
+ // type isn't JWT
299
+ const d5 = makeJwt({ typ: "SUP", alg: "HS256" }, { foo: "bar" });
300
+ expect(() => jwt.parse(d5)).toThrow();
301
+ });
302
+
303
+ test("url validations", () => {
304
+ const url = z.string().url();
305
+ url.parse("http://google.com");
306
+ url.parse("https://google.com/asdf?asdf=ljk3lk4&asdf=234#asdf");
307
+ url.parse("https://anonymous:flabada@developer.mozilla.org/en-US/docs/Web/API/URL/password");
308
+ url.parse("https://localhost");
309
+ url.parse("https://my.local");
310
+ url.parse("http://aslkfjdalsdfkjaf");
311
+ url.parse("http://localhost");
312
+
313
+ url.parse("c:");
314
+
315
+ expect(() => url.parse("asdf")).toThrow();
316
+ expect(() => url.parse("https:/")).toThrow();
317
+ expect(() => url.parse("asdfj@lkjsdf.com")).toThrow();
318
+ expect(() => url.parse("https://")).toThrow();
319
+ });
320
+
321
+ test("httpurl", () => {
322
+ const httpUrl = z.url({
323
+ protocol: /^https?$/,
324
+ hostname: z.regexes.domain,
325
+ // /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/
326
+ });
327
+
328
+ httpUrl.parse("https://example.com");
329
+ httpUrl.parse("http://example.com");
330
+ // ports
331
+ httpUrl.parse("https://example.com:8080");
332
+ httpUrl.parse("http://example.com:8080");
333
+ // subdomains
334
+ httpUrl.parse("https://sub.example.com");
335
+ httpUrl.parse("http://sub.example.com");
336
+ // paths
337
+ httpUrl.parse("https://example.com/path/to/resource");
338
+ httpUrl.parse("http://example.com/path/to/resource");
339
+ // query parameters
340
+ httpUrl.parse("https://example.com/path?query=param");
341
+ httpUrl.parse("http://example.com/path?query=param");
342
+ // fragment identifiers
343
+ httpUrl.parse("https://example.com/path#fragment");
344
+ httpUrl.parse("http://example.com/path#fragment");
345
+ // fails
346
+ expect(() => httpUrl.parse("ftp://example.com")).toThrow();
347
+ expect(() => httpUrl.parse("shttp://example.com")).toThrow();
348
+ expect(() => httpUrl.parse("httpz://example.com")).toThrow();
349
+ expect(() => httpUrl.parse("http://")).toThrow();
350
+ expect(() => httpUrl.parse("http://localhost")).toThrow();
351
+ expect(() => httpUrl.parse("http://-asdf.com")).toThrow();
352
+ expect(() =>
353
+ httpUrl.parse(
354
+ "http://asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf.com"
355
+ )
356
+ ).toThrow();
357
+ expect(() => httpUrl.parse("http://asdf.c")).toThrow();
358
+ expect(() => httpUrl.parse("mailto:asdf@lckj.com")).toThrow();
359
+ });
360
+
361
+ test("url error overrides", () => {
362
+ try {
363
+ z.string().url().parse("https");
364
+ } catch (err) {
365
+ expect((err as z.ZodError).issues[0].message).toEqual("Invalid URL");
366
+ }
367
+ try {
368
+ z.string().url("badurl").parse("https");
369
+ } catch (err) {
370
+ expect((err as z.ZodError).issues[0].message).toEqual("badurl");
371
+ }
372
+ try {
373
+ z.string().url({ message: "badurl" }).parse("https");
374
+ } catch (err) {
375
+ expect((err as z.ZodError).issues[0].message).toEqual("badurl");
376
+ }
377
+ });
378
+
379
+ test("emoji validations", () => {
380
+ const emoji = z.string().emoji();
381
+
382
+ emoji.parse("👋👋👋👋");
383
+ emoji.parse("🍺👩‍🚀🫡");
384
+ emoji.parse("💚💙💜💛❤️");
385
+ emoji.parse("🐛🗝🐏🍡🎦🚢🏨💫🎌☘🗡😹🔒🎬➡️🍹🗂🚨⚜🕑〽️🚦🌊🍴💍🍌💰😳🌺🍃");
386
+ emoji.parse("🇹🇷🤽🏿‍♂️");
387
+ emoji.parse(
388
+ "😀😁😂🤣😃😄😅😆😉😊😋😎😍😘🥰😗😙😚☺️☺🙂🤗🤩🤔🤨😐😑😶🙄😏😣😥😮🤐😯😪😫😴😌😛😜😝🤤😒😓😔😕🙃🤑😲☹️☹🙁😖😞😟😤😢😭😦😧😨😩🤯😬😰😱🥵🥶😳🤪😵😡😠🤬😷🤒🤕🤢🤮🤧😇🤠🥳🥴🥺🤥🤫🤭🧐🤓😈👿🤡👹👺💀☠️☠👻👽👾🤖💩😺😸😹😻😼😽🙀😿😾🙈🙉🙊🏻🏼🏽🏾🏿👶👶🏻👶🏼👶🏽👶🏾👶🏿🧒🧒🏻🧒🏼🧒🏽🧒🏾🧒🏿👦👦🏻👦🏼👦🏽👦🏾👦🏿👧👧🏻👧🏼👧🏽👧🏾👧🏿🧑🧑🏻🧑🏼🧑🏽🧑🏾🧑🏿👨👨🏻👨🏼👨🏽👨🏾👨🏿👩👩🏻👩🏼👩🏽👩🏾👩🏿🧓🧓🏻🧓🏼🧓🏽🧓🏾🧓🏿👴👴🏻👴🏼👴🏽👴🏾👴🏿👵👵🏻👵🏼👵🏽👵🏾👵🏿👨‍⚕️👨‍⚕👨🏻‍⚕️👨🏻‍⚕👨🏼‍⚕️👨🏼‍⚕👨🏽‍⚕️👨🏽‍⚕👨🏾‍⚕️👨🏾‍⚕👨🏿‍⚕️👨🏿‍⚕👩‍⚕️👩‍⚕👩🏻‍⚕️👩🏻‍⚕👩🏼‍⚕️👩🏼‍⚕👩🏽‍⚕️👩🏽‍⚕👩🏾‍⚕️👩🏾‍⚕👩🏿‍⚕️👩🏿‍⚕👨‍🎓👨🏻‍🎓👨🏼‍🎓👨🏽‍🎓👨🏾‍🎓👨🏿‍🎓👩‍🎓👩🏻‍🎓👩🏼‍🎓👩🏽‍🎓👩🏾‍🎓👩🏿‍🎓👨‍🏫👨🏻‍🏫👨🏼‍🏫👨🏽‍🏫👨🏾‍🏫👨🏿‍🏫👩‍🏫👩🏻‍🏫👩🏼‍🏫👩🏽‍🏫👩🏾‍🏫👩🏿‍🏫👨‍⚖️👨‍⚖👨🏻‍⚖️👨🏻‍⚖👨🏼‍⚖️👨🏼‍⚖👨🏽‍⚖️👨🏽‍⚖👨🏾‍⚖️👨🏾‍⚖👨🏿‍⚖️👨🏿‍⚖👩‍⚖️👩‍⚖👩🏻‍⚖️👩🏻‍⚖👩🏼‍⚖️👩🏼‍⚖👩🏽‍⚖️👩🏽‍⚖👩🏾‍⚖️👩🏾‍⚖👩🏿‍⚖️👩🏿‍⚖👨‍🌾👨🏻‍🌾👨🏼‍🌾👨🏽‍🌾👨🏾‍🌾👨🏿‍🌾👩‍🌾👩🏻‍🌾👩🏼‍🌾👩🏽‍🌾👩🏾‍🌾👩🏿‍🌾👨‍🍳👨🏻‍🍳👨🏼‍🍳👨🏽‍🍳👨🏾‍🍳👨🏿‍🍳👩‍🍳👩🏻‍🍳👩🏼‍🍳👩🏽‍🍳👩🏾‍🍳👩🏿‍🍳👨‍🔧👨🏻‍🔧👨🏼‍🔧👨🏽‍🔧👨🏾‍🔧👨🏿‍🔧👩‍🔧👩🏻‍🔧👩🏼‍🔧👩🏽‍🔧👩🏾‍🔧👩🏿‍🔧👨‍🏭👨🏻‍🏭👨🏼‍🏭👨🏽‍🏭👨🏾‍🏭👨🏿‍🏭👩‍🏭👩🏻‍🏭👩🏼‍🏭👩🏽‍🏭👩🏾‍🏭👩🏿‍🏭👨‍💼👨🏻‍💼👨🏼‍💼👨🏽‍💼👨🏾‍💼👨🏿‍💼👩‍💼👩🏻‍💼👩🏼‍💼👩🏽‍💼👩🏾‍💼👩🏿‍💼👨‍🔬👨🏻‍🔬👨🏼‍🔬👨🏽‍🔬👨🏾‍🔬👨🏿‍🔬👩‍🔬👩🏻‍🔬👩🏼‍🔬👩🏽‍🔬👩🏾‍🔬👩🏿‍🔬👨‍💻👨🏻‍💻👨🏼‍💻👨🏽‍💻👨🏾‍💻👨🏿‍💻👩‍💻👩🏻‍💻👩🏼‍💻👩🏽‍💻👩🏾‍💻👩🏿‍💻👨‍🎤👨🏻‍🎤👨🏼‍🎤👨🏽‍🎤👨🏾‍🎤👨🏿‍🎤👩‍🎤👩🏻‍🎤👩🏼‍🎤👩🏽‍🎤👩🏾‍🎤👩🏿‍🎤👨‍🎨👨🏻‍🎨👨🏼‍🎨👨🏽‍🎨👨🏾‍🎨👨🏿‍🎨👩‍🎨👩🏻‍🎨👩🏼‍🎨👩🏽‍🎨👩🏾‍🎨👩🏿‍🎨👨‍✈️👨‍✈👨🏻‍✈️👨🏻‍✈👨🏼‍✈️👨🏼‍✈👨🏽‍✈️👨🏽‍✈👨🏾‍✈️👨🏾‍✈👨🏿‍✈️👨🏿‍✈👩‍✈️👩‍✈👩🏻‍✈️👩🏻‍✈👩🏼‍✈️👩🏼‍✈👩🏽‍✈️👩🏽‍✈👩🏾‍✈️👩🏾‍✈👩🏿‍✈️👩🏿‍✈👨‍🚀👨🏻‍🚀👨🏼‍🚀👨🏽‍🚀👨🏾‍🚀👨🏿‍🚀👩‍🚀👩🏻‍🚀👩🏼‍🚀👩🏽‍🚀👩🏾‍🚀👩🏿‍🚀👨‍🚒👨🏻‍🚒👨🏼‍🚒👨🏽‍🚒👨🏾‍🚒👨🏿‍🚒👩‍🚒👩🏻‍🚒👩🏼‍🚒👩🏽‍🚒👩🏾‍🚒👩🏿‍🚒👮👮🏻👮🏼👮🏽👮🏾👮🏿👮‍♂️👮‍♂👮🏻‍♂️👮🏻‍♂👮🏼‍♂️👮🏼‍♂👮🏽‍♂️👮🏽‍♂👮🏾‍♂️👮🏾‍♂👮🏿‍♂️👮🏿‍♂👮‍♀️👮‍♀👮🏻‍♀️👮🏻‍♀👮🏼‍♀️👮🏼‍♀👮🏽‍♀️👮🏽‍♀👮🏾‍♀️👮🏾‍♀👮🏿‍♀️👮🏿‍♀🕵️🕵🕵🏻🕵🏼🕵🏽🕵🏾🕵🏿🕵️‍♂️🕵‍♂️🕵️‍♂🕵‍♂🕵🏻‍♂️🕵🏻‍♂🕵🏼‍♂️🕵🏼‍♂🕵🏽‍♂️🕵🏽‍♂🕵🏾‍♂️🕵🏾‍♂🕵🏿‍♂️🕵🏿‍♂🕵️‍♀️🕵‍♀️🕵️‍♀🕵‍♀🕵🏻‍♀️🕵🏻‍♀🕵🏼‍♀️🕵🏼‍♀🕵🏽‍♀️🕵🏽‍♀🕵🏾‍♀️🕵🏾‍♀🕵🏿‍♀️🕵🏿‍♀💂💂🏻💂🏼💂🏽💂🏾💂🏿💂‍♂️💂‍♂💂🏻‍♂️💂🏻‍♂💂🏼‍♂️💂🏼‍♂💂🏽‍♂️💂🏽‍♂💂🏾‍♂️💂🏾‍♂💂🏿‍♂️💂🏿‍♂💂‍♀️💂‍♀💂🏻‍♀️💂🏻‍♀💂🏼‍♀️💂🏼‍♀💂🏽‍♀️💂🏽‍♀💂🏾‍♀️💂🏾‍♀💂🏿‍♀️💂🏿‍♀👷👷🏻👷🏼👷🏽👷🏾👷🏿👷‍♂️👷‍♂👷🏻‍♂️👷🏻‍♂👷🏼‍♂️👷🏼‍♂👷🏽‍♂️👷🏽‍♂👷🏾‍♂️👷🏾‍♂👷🏿‍♂️👷🏿‍♂👷‍♀️👷‍♀👷🏻‍♀️👷🏻‍♀👷🏼‍♀️👷🏼‍♀👷🏽‍♀️👷🏽‍♀👷🏾‍♀️👷🏾‍♀👷🏿‍♀️👷🏿‍♀🤴🤴🏻🤴🏼🤴🏽🤴🏾🤴🏿👸👸🏻👸🏼👸🏽👸🏾👸🏿👳👳🏻👳🏼👳🏽👳🏾👳🏿👳‍♂️👳‍♂👳🏻‍♂️👳🏻‍♂👳🏼‍♂️👳🏼‍♂👳🏽‍♂️👳🏽‍♂👳🏾‍♂️👳🏾‍♂👳🏿‍♂️👳🏿‍♂👳‍♀️👳‍♀👳🏻‍♀️👳🏻‍♀👳🏼‍♀️👳🏼‍♀👳🏽‍♀️👳🏽‍♀👳🏾‍♀️👳🏾‍♀👳🏿‍♀️👳🏿‍♀👲👲🏻👲🏼👲🏽👲🏾👲🏿🧕🧕🏻🧕🏼🧕🏽🧕🏾🧕🏿🧔🧔🏻🧔🏼🧔🏽🧔🏾🧔🏿👱👱🏻👱🏼👱🏽👱🏾👱🏿👱‍♂️👱‍♂👱🏻‍♂️👱🏻‍♂👱🏼‍♂️👱🏼‍♂👱🏽‍♂️👱🏽‍♂👱🏾‍♂️👱����‍♂👱🏿‍♂️👱🏿‍♂👱‍♀️👱‍♀👱🏻‍♀️👱🏻‍♀👱🏼‍♀️👱🏼‍♀👱🏽‍♀️👱🏽‍♀👱🏾‍♀️👱🏾‍♀👱🏿‍♀️👱🏿‍♀👨‍🦰👨🏻‍🦰👨🏼‍🦰👨🏽‍🦰👨🏾‍🦰👨🏿‍🦰👩‍🦰👩🏻‍🦰👩🏼‍🦰👩🏽‍🦰👩🏾‍🦰👩🏿‍🦰👨‍🦱👨🏻‍🦱👨🏼‍🦱👨🏽‍🦱👨🏾‍🦱👨🏿‍🦱👩‍🦱👩🏻‍🦱👩🏼‍🦱👩🏽‍🦱👩🏾‍🦱👩🏿‍🦱👨‍🦲👨🏻‍🦲👨🏼‍🦲👨🏽‍🦲👨🏾‍🦲👨🏿‍🦲👩‍🦲👩🏻‍🦲👩🏼‍🦲👩🏽‍🦲👩🏾‍🦲👩🏿‍🦲👨‍🦳👨🏻‍🦳👨🏼‍🦳👨🏽‍🦳👨🏾‍🦳👨🏿‍🦳👩‍🦳👩🏻‍🦳👩🏼‍🦳👩🏽‍🦳👩🏾‍🦳👩🏿‍🦳🤵🤵🏻🤵🏼🤵🏽🤵🏾🤵🏿👰👰🏻👰🏼👰🏽👰🏾👰🏿🤰🤰🏻🤰🏼🤰🏽🤰🏾🤰🏿🤱🤱🏻🤱🏼🤱🏽🤱🏾🤱🏿👼👼🏻👼🏼👼🏽👼🏾👼🏿🎅🎅🏻🎅🏼🎅🏽🎅🏾🎅🏿🤶🤶🏻🤶🏼🤶🏽🤶🏾🤶🏿🦸🦸🏻🦸🏼🦸🏽🦸🏾🦸🏿🦸‍♀️🦸‍♀🦸🏻‍♀️🦸🏻‍♀🦸🏼‍♀️🦸🏼‍♀🦸🏽‍♀️🦸🏽‍♀🦸🏾‍♀️🦸🏾‍♀🦸🏿‍♀️🦸🏿‍♀🦸‍♂️🦸‍♂🦸🏻‍♂️🦸🏻‍♂🦸🏼‍♂️🦸🏼‍♂🦸🏽‍♂️🦸🏽‍♂🦸🏾‍♂️🦸🏾‍♂🦸🏿‍♂️🦸🏿‍♂🦹🦹🏻🦹🏼🦹🏽🦹🏾🦹🏿🦹‍♀️🦹‍♀🦹🏻‍♀️🦹🏻‍♀🦹🏼‍♀️🦹🏼‍♀🦹🏽‍♀️🦹🏽‍♀🦹🏾‍♀️🦹🏾‍♀🦹🏿‍♀️🦹🏿‍♀🦹‍♂️🦹‍♂🦹🏻‍♂️🦹🏻‍♂🦹🏼‍♂️🦹🏼‍♂🦹🏽‍♂️🦹🏽‍♂🦹🏾‍♂️🦹🏾‍♂🦹🏿‍♂️🦹🏿‍♂🧙🧙🏻🧙🏼🧙🏽🧙🏾🧙🏿🧙‍♀️🧙‍♀🧙🏻‍♀️🧙🏻‍♀🧙🏼‍♀️🧙🏼‍♀🧙🏽‍♀️🧙🏽‍♀🧙🏾‍♀️🧙🏾‍♀🧙🏿‍♀️🧙🏿‍♀🧙‍♂️🧙‍♂🧙🏻‍♂️🧙🏻‍♂🧙🏼‍♂️🧙🏼‍♂🧙🏽‍♂️🧙🏽‍♂🧙🏾‍♂️🧙🏾‍♂🧙🏿‍♂️🧙🏿‍♂🧚🧚🏻🧚🏼🧚🏽🧚🏾🧚🏿🧚‍♀️🧚‍♀🧚🏻‍♀️🧚🏻‍♀🧚🏼‍♀️🧚🏼‍♀🧚🏽‍♀️🧚🏽‍♀🧚🏾‍♀️🧚🏾‍♀🧚🏿‍♀️🧚🏿‍♀🧚‍♂️🧚‍♂🧚🏻‍♂️🧚🏻‍♂🧚🏼‍♂️🧚🏼‍♂🧚🏽‍♂️🧚🏽‍♂🧚🏾‍♂️🧚🏾‍♂🧚🏿‍♂️🧚🏿‍♂🧛🧛🏻🧛🏼🧛🏽🧛🏾🧛🏿🧛‍♀️🧛‍♀🧛🏻‍♀️🧛🏻‍♀🧛🏼‍♀️🧛🏼‍♀🧛🏽‍♀️🧛🏽‍♀🧛🏾‍♀️🧛🏾‍♀🧛🏿‍♀️🧛🏿‍♀🧛‍♂️🧛‍♂🧛🏻‍♂️🧛🏻‍♂🧛🏼‍♂️🧛🏼‍♂🧛🏽‍♂️🧛🏽‍♂🧛🏾‍♂️🧛🏾‍♂🧛🏿‍♂️🧛🏿‍♂🧜🧜🏻🧜🏼🧜🏽🧜🏾🧜🏿🧜‍♀️🧜‍♀🧜🏻‍♀️🧜🏻‍♀🧜🏼‍♀️🧜🏼‍♀🧜🏽‍♀️🧜🏽‍♀🧜🏾‍♀️🧜🏾‍♀🧜🏿‍♀️🧜🏿‍♀🧜‍♂️🧜‍♂🧜🏻‍♂️🧜🏻‍♂🧜🏼‍♂️🧜🏼‍♂🧜🏽‍♂️🧜🏽‍♂🧜🏾‍♂️🧜🏾‍♂🧜🏿‍♂️🧜🏿‍♂🧝🧝🏻🧝🏼🧝🏽🧝🏾🧝🏿🧝‍♀️🧝‍♀🧝🏻‍♀️🧝🏻‍♀🧝🏼‍♀️🧝🏼‍♀🧝🏽‍♀️🧝🏽‍♀🧝🏾‍♀️🧝🏾‍♀🧝🏿‍♀️🧝🏿‍♀🧝‍♂️🧝‍♂🧝🏻‍♂️🧝🏻‍♂🧝🏼‍♂️🧝🏼‍♂🧝🏽‍♂️🧝🏽‍♂🧝🏾‍♂️🧝🏾‍♂🧝🏿‍♂️🧝🏿‍♂🧞🧞‍♀️🧞‍♀🧞‍♂️🧞‍♂🧟🧟‍♀️🧟‍♀🧟‍♂️🧟‍♂🙍🙍🏻🙍🏼🙍🏽🙍🏾🙍🏿🙍‍♂️🙍‍♂🙍🏻‍♂️🙍🏻‍♂🙍🏼‍♂️🙍🏼‍♂🙍🏽‍♂️🙍🏽‍♂🙍🏾‍♂️🙍🏾‍♂🙍🏿‍♂️🙍🏿‍♂🙍‍♀️🙍‍♀🙍🏻‍♀️🙍🏻‍♀🙍🏼‍♀️🙍🏼‍♀🙍🏽‍♀️🙍🏽‍♀🙍🏾‍♀️🙍🏾‍♀🙍🏿‍♀️🙍🏿‍♀🙎🙎🏻🙎🏼🙎🏽🙎🏾🙎🏿🙎‍♂️🙎‍♂🙎🏻‍♂️🙎🏻‍♂🙎🏼‍♂️🙎🏼‍♂🙎🏽‍♂️🙎🏽‍♂🙎🏾‍♂️🙎🏾‍♂🙎🏿‍♂️🙎🏿‍♂🙎‍♀️🙎‍♀🙎🏻‍♀️🙎🏻‍♀🙎🏼‍♀️🙎🏼‍♀🙎🏽‍♀️🙎🏽‍♀🙎🏾‍♀️🙎🏾‍♀🙎🏿‍♀️🙎🏿‍♀🙅🙅🏻🙅🏼🙅🏽🙅🏾🙅🏿🙅‍♂️🙅‍♂🙅🏻‍♂️🙅🏻‍♂🙅🏼‍♂️🙅🏼‍♂🙅🏽‍♂️🙅🏽‍♂🙅🏾‍♂️🙅🏾‍♂🙅🏿‍♂���🙅🏿‍♂🙅‍♀️🙅‍♀🙅🏻‍♀️🙅🏻‍♀🙅🏼‍♀️🙅🏼‍♀🙅🏽‍♀️🙅🏽‍♀🙅🏾‍♀️🙅🏾‍♀🙅🏿‍♀️🙅🏿‍♀🙆🙆🏻🙆🏼🙆🏽🙆🏾🙆🏿🙆‍♂️🙆‍♂🙆🏻‍♂️🙆🏻‍♂🙆🏼‍♂️🙆🏼‍♂🙆🏽‍♂️🙆🏽‍♂🙆🏾‍♂️🙆🏾‍♂🙆🏿‍♂️🙆🏿‍♂🙆‍♀️🙆‍♀🙆🏻‍♀️🙆🏻‍♀🙆🏼‍♀️🙆🏼‍♀🙆🏽‍♀️🙆🏽‍♀🙆🏾‍♀️🙆🏾‍♀🙆🏿‍♀️🙆🏿‍♀💁💁🏻💁🏼💁🏽💁🏾💁🏿💁‍♂️💁‍♂💁🏻‍♂️💁🏻‍♂💁🏼‍♂️💁🏼‍♂💁🏽‍♂️💁🏽‍♂💁🏾‍♂️💁🏾‍♂💁🏿‍♂️💁🏿‍♂💁‍♀️💁‍♀💁🏻‍♀️💁🏻‍♀💁🏼‍♀️💁🏼‍♀💁🏽‍♀️💁🏽‍♀💁🏾‍♀️💁🏾‍♀💁🏿‍♀️💁🏿‍♀🙋🙋🏻🙋🏼🙋🏽🙋🏾🙋🏿🙋‍♂️🙋‍♂🙋🏻‍♂️🙋🏻‍♂🙋🏼‍♂️🙋🏼‍♂🙋🏽‍♂️🙋🏽‍♂🙋🏾‍♂️🙋🏾‍♂🙋🏿‍♂️🙋🏿‍♂🙋‍♀️🙋‍♀🙋🏻‍♀️🙋🏻‍♀🙋🏼‍♀️🙋🏼‍♀🙋🏽‍♀️🙋🏽‍♀🙋🏾‍♀️🙋🏾‍♀🙋🏿‍♀️🙋🏿‍♀🙇🙇🏻🙇🏼🙇🏽🙇🏾🙇🏿🙇‍♂️🙇‍♂🙇🏻‍♂️🙇🏻‍♂🙇🏼‍♂️🙇🏼‍♂🙇🏽‍♂️🙇🏽‍♂🙇🏾‍♂️🙇🏾‍♂🙇🏿‍♂️🙇🏿‍♂🙇‍♀️🙇‍♀🙇🏻‍♀️🙇🏻‍♀🙇🏼‍♀️🙇🏼‍♀🙇🏽‍♀️🙇🏽‍♀🙇🏾‍♀️🙇🏾‍♀🙇🏿‍♀️🙇🏿‍♀🤦🤦🏻🤦🏼🤦🏽🤦🏾🤦🏿🤦‍♂️🤦‍♂🤦🏻‍♂️🤦🏻‍♂🤦🏼‍♂️🤦🏼‍♂🤦🏽‍♂️🤦🏽‍♂🤦🏾‍♂️🤦🏾‍♂🤦🏿‍♂️🤦🏿‍♂🤦‍♀️🤦‍♀🤦🏻‍♀️🤦🏻‍♀🤦🏼‍♀️🤦🏼‍♀🤦🏽‍♀️🤦🏽‍♀🤦🏾‍♀️🤦🏾‍♀🤦🏿‍♀️🤦🏿‍♀🤷🤷🏻🤷🏼🤷🏽🤷🏾🤷🏿🤷‍♂️🤷‍♂🤷🏻‍♂️🤷🏻‍♂🤷🏼‍♂️🤷🏼‍♂🤷🏽‍♂️🤷🏽‍♂🤷🏾‍♂️🤷🏾‍♂🤷🏿‍♂️🤷🏿‍♂🤷‍♀️🤷‍♀🤷🏻‍♀️🤷🏻‍♀🤷🏼‍♀️🤷🏼‍♀🤷🏽‍♀️🤷🏽‍♀🤷🏾‍♀️🤷🏾‍♀🤷🏿‍♀️🤷🏿‍♀💆💆🏻💆🏼💆🏽💆🏾💆🏿💆‍♂️💆‍♂💆🏻‍♂️💆🏻‍♂💆🏼‍♂️💆🏼‍♂💆🏽‍♂️💆🏽‍♂💆🏾‍♂️💆🏾‍♂💆🏿‍♂️💆🏿‍♂💆‍♀️💆‍♀💆🏻‍♀️💆🏻‍♀💆🏼‍♀️💆🏼‍♀💆🏽‍♀️💆🏽‍♀💆🏾‍♀️💆🏾‍♀💆🏿‍♀️💆🏿‍♀💇💇🏻💇🏼💇🏽💇🏾💇🏿💇‍♂️💇‍♂💇🏻‍♂️💇🏻‍♂💇🏼‍♂️💇🏼‍♂💇🏽‍♂️💇🏽‍♂💇🏾‍♂️💇🏾‍♂💇🏿‍♂️💇🏿‍♂💇‍♀️💇‍♀💇🏻‍♀️💇🏻‍♀💇🏼‍♀️💇🏼‍♀💇🏽‍♀️💇🏽‍♀💇🏾‍♀️💇🏾‍♀💇🏿‍♀️💇🏿‍♀🚶🚶🏻🚶🏼🚶🏽🚶🏾🚶🏿🚶‍♂️🚶‍♂🚶🏻‍♂️🚶🏻‍♂🚶🏼‍♂️🚶🏼‍♂🚶🏽‍♂️🚶🏽‍♂🚶🏾‍♂️🚶🏾‍♂🚶🏿‍♂️🚶🏿‍♂🚶‍♀️🚶‍♀🚶🏻‍♀️🚶🏻‍♀🚶🏼‍♀️🚶🏼‍♀🚶🏽‍♀️🚶🏽‍♀🚶🏾‍♀️🚶🏾‍♀🚶🏿‍♀️🚶🏿‍♀🏃🏃🏻🏃🏼🏃🏽🏃🏾🏃🏿🏃‍♂️🏃‍♂🏃🏻‍♂️🏃🏻‍♂🏃🏼‍♂️🏃🏼‍♂🏃🏽‍♂️🏃🏽‍♂🏃🏾‍♂️🏃🏾‍♂🏃🏿‍♂️🏃🏿‍♂🏃‍♀️🏃‍♀🏃🏻‍♀️🏃🏻‍♀🏃🏼‍♀️🏃🏼‍♀🏃🏽‍♀️🏃🏽‍♀🏃🏾‍♀️🏃🏾‍♀🏃🏿‍♀️🏃🏿‍♀💃💃🏻💃🏼💃🏽💃🏾💃🏿🕺🕺🏻🕺🏼🕺🏽🕺🏾🕺🏿👯👯‍♂️👯‍♂👯‍♀️👯‍♀🧖🧖🏻🧖🏼🧖🏽🧖🏾🧖🏿🧖‍♀️🧖‍♀🧖🏻‍♀️🧖🏻‍♀🧖🏼‍♀️🧖🏼‍♀🧖🏽‍♀️🧖🏽‍♀🧖🏾‍♀️🧖🏾‍♀🧖🏿‍♀️🧖🏿‍♀🧖‍♂️🧖‍♂🧖🏻‍♂️🧖🏻‍♂🧖🏼‍♂️🧖🏼‍♂🧖🏽‍♂️🧖🏽‍♂🧖🏾‍♂️🧖🏾‍♂🧖🏿‍♂️🧖🏿‍♂🧗🧗🏻🧗🏼🧗🏽🧗🏾🧗🏿🧗‍♀️🧗‍♀🧗🏻‍♀️🧗🏻‍♀🧗🏼‍♀️🧗🏼‍♀🧗🏽‍♀️🧗🏽‍♀🧗🏾‍♀️🧗🏾‍♀🧗🏿‍♀️🧗🏿‍♀🧗‍♂️🧗‍♂🧗🏻‍♂️🧗🏻‍♂🧗🏼‍♂️🧗🏼‍♂🧗🏽‍♂️🧗🏽‍♂🧗🏾‍♂️🧗🏾‍♂🧗🏿‍♂️���🏿‍♂🧘🧘🏻🧘🏼🧘🏽🧘🏾🧘🏿🧘‍♀️🧘‍♀🧘🏻‍♀️🧘🏻‍♀🧘🏼‍♀️🧘🏼‍♀🧘🏽‍♀️🧘🏽‍♀🧘🏾‍♀️🧘🏾‍♀🧘🏿‍♀️🧘🏿‍♀🧘‍♂️🧘‍♂🧘🏻‍♂️🧘🏻‍♂🧘🏼‍♂️🧘🏼‍♂🧘🏽‍♂️🧘🏽‍♂🧘🏾‍♂️🧘🏾‍♂🧘🏿‍♂️🧘🏿‍♂🛀🛀🏻🛀🏼🛀🏽🛀🏾🛀🏿🛌🛌🏻🛌🏼🛌🏽🛌🏾🛌🏿🕴️🕴🕴🏻🕴🏼🕴🏽🕴🏾🕴🏿🗣️🗣👤👥🤺🏇🏇🏻🏇🏼🏇🏽🏇🏾🏇🏿⛷️⛷🏂🏂🏻🏂🏼🏂🏽🏂🏾🏂🏿🏌️🏌🏌🏻🏌🏼🏌🏽🏌🏾🏌🏿🏌️‍♂️🏌‍♂️🏌️‍♂🏌‍♂🏌🏻‍♂️🏌🏻‍♂🏌🏼‍♂️🏌🏼‍♂🏌🏽‍♂️🏌🏽‍♂🏌🏾‍♂️🏌🏾‍♂🏌🏿‍♂️🏌🏿‍♂🏌️‍♀️🏌‍♀️🏌️‍♀🏌‍♀🏌🏻‍♀️🏌🏻‍♀🏌🏼‍♀️🏌🏼‍♀🏌🏽‍♀️🏌🏽‍♀🏌🏾‍♀️🏌🏾‍♀🏌🏿‍♀️🏌🏿‍♀🏄🏄🏻🏄🏼🏄🏽🏄🏾🏄🏿🏄‍♂️🏄‍♂🏄🏻‍♂️🏄🏻‍♂🏄🏼‍♂️🏄🏼‍♂🏄🏽‍♂️🏄🏽‍♂🏄🏾‍♂️🏄🏾‍♂🏄🏿‍♂️🏄🏿‍♂🏄‍♀️🏄‍♀🏄🏻‍♀️🏄🏻‍♀🏄🏼‍♀️🏄🏼‍♀🏄🏽‍♀️🏄🏽‍♀🏄🏾‍♀️🏄🏾‍♀🏄🏿‍♀️🏄🏿‍♀🚣🚣🏻🚣🏼🚣🏽🚣🏾🚣🏿🚣‍♂️🚣‍♂🚣🏻‍♂️🚣🏻‍♂🚣🏼‍♂️🚣🏼‍♂🚣🏽‍♂️🚣🏽‍♂🚣🏾‍♂️🚣🏾‍♂🚣🏿‍♂️🚣🏿‍♂🚣‍♀️🚣‍♀🚣🏻‍♀️🚣🏻‍♀🚣🏼‍♀️🚣🏼‍♀🚣🏽‍♀️🚣🏽‍♀🚣🏾‍♀️🚣🏾‍♀🚣🏿‍♀️🚣🏿‍♀🏊🏊🏻🏊🏼🏊🏽🏊🏾🏊🏿🏊‍♂️🏊‍♂🏊🏻‍♂️🏊🏻‍♂🏊🏼‍♂️🏊🏼‍♂🏊🏽‍♂️🏊🏽‍♂🏊🏾‍♂️🏊🏾‍♂🏊🏿‍♂️🏊🏿‍♂🏊‍♀️🏊‍♀🏊🏻‍♀️🏊🏻‍♀🏊🏼‍♀️🏊🏼‍♀🏊🏽‍♀️🏊🏽‍♀🏊🏾‍♀️🏊🏾‍♀🏊🏿‍♀️🏊🏿‍♀⛹️⛹⛹🏻⛹🏼⛹🏽⛹🏾⛹🏿⛹️‍♂️⛹‍♂️⛹️‍♂⛹‍♂⛹🏻‍♂️⛹🏻‍♂⛹🏼‍♂️⛹🏼‍♂⛹🏽‍♂️⛹🏽‍♂⛹🏾‍♂️⛹🏾‍♂⛹🏿‍♂️⛹🏿‍♂⛹️‍♀️⛹‍♀️⛹️‍♀⛹‍♀⛹🏻‍♀️⛹🏻‍♀⛹🏼‍♀️⛹🏼‍♀⛹🏽‍♀️⛹🏽‍♀⛹🏾‍♀️⛹🏾‍♀⛹🏿‍♀️⛹🏿‍♀🏋️🏋🏋🏻🏋🏼🏋🏽🏋🏾🏋🏿🏋️‍♂️🏋‍♂️🏋️‍♂🏋‍♂🏋🏻‍♂️🏋🏻‍♂🏋🏼‍♂️🏋🏼‍♂🏋🏽‍♂️🏋🏽‍♂🏋🏾‍♂️🏋🏾‍♂🏋🏿‍♂️🏋🏿‍♂🏋️‍♀️🏋‍♀️🏋️‍♀🏋‍♀🏋🏻‍♀️🏋🏻‍♀🏋🏼‍♀️🏋🏼‍♀🏋🏽‍♀️🏋🏽‍♀🏋🏾‍♀️🏋🏾‍♀🏋🏿‍♀️🏋🏿‍♀🚴🚴🏻🚴🏼🚴🏽🚴🏾🚴🏿🚴‍♂️🚴‍♂🚴🏻‍♂️🚴🏻‍♂🚴🏼‍♂️🚴🏼‍♂🚴🏽‍♂️🚴🏽‍♂🚴🏾‍♂️🚴🏾‍♂🚴🏿‍♂️🚴🏿‍♂🚴‍♀️🚴‍♀🚴🏻‍♀️🚴🏻‍♀🚴🏼‍♀️🚴🏼‍♀🚴🏽‍♀️🚴🏽‍♀🚴🏾‍♀️🚴🏾‍♀🚴🏿‍♀️🚴🏿‍♀🚵🚵🏻🚵🏼🚵🏽🚵🏾🚵🏿🚵‍♂️🚵‍♂🚵🏻‍♂️🚵🏻‍♂🚵🏼‍♂️🚵🏼‍♂🚵🏽‍♂️🚵🏽‍♂🚵🏾‍♂️🚵🏾‍♂🚵🏿‍♂️🚵🏿‍♂🚵‍♀️🚵‍♀🚵🏻‍♀️🚵🏻‍♀🚵🏼‍♀️🚵🏼‍♀🚵🏽‍♀️🚵🏽‍♀🚵🏾‍♀️🚵🏾‍♀🚵🏿‍♀️🚵🏿‍♀🏎️🏎🏍️🏍🤸🤸🏻🤸🏼🤸🏽🤸🏾🤸🏿🤸‍♂️🤸‍♂🤸🏻‍♂️🤸🏻‍♂🤸🏼‍♂️🤸🏼‍♂🤸🏽‍♂️🤸🏽‍♂🤸🏾‍♂️🤸🏾‍♂🤸🏿‍♂️🤸🏿‍♂🤸‍♀️🤸‍♀🤸🏻‍♀️🤸🏻‍♀🤸🏼‍♀️🤸🏼‍♀🤸🏽‍♀️🤸🏽‍♀🤸🏾‍♀️🤸🏾‍♀🤸🏿‍♀️🤸🏿‍♀🤼🤼‍♂️🤼‍♂🤼‍♀️🤼‍♀🤽🤽🏻🤽🏼🤽🏽🤽🏾🤽🏿🤽‍♂️🤽‍♂🤽🏻‍♂️🤽🏻‍♂🤽🏼‍♂️🤽🏼‍♂🤽🏽‍♂️🤽🏽‍♂🤽🏾‍♂️🤽🏾‍♂🤽🏿‍♂️🤽🏿‍♂🤽‍♀️🤽‍♀🤽🏻‍♀️🤽🏻‍♀🤽🏼‍♀️🤽🏼‍♀🤽🏽‍♀️🤽🏽‍♀🤽🏾‍♀️🤽🏾‍♀🤽🏿‍♀️🤽🏿‍♀🤾🤾🏻🤾🏼🤾🏽🤾🏾🤾🏿🤾‍♂️🤾‍♂🤾🏻‍♂️🤾🏻‍♂🤾🏼‍♂️🤾🏼‍♂🤾🏽‍♂️🤾🏽‍♂🤾🏾‍♂️🤾🏾‍♂🤾🏿‍♂️🤾🏿���♂🤾‍♀️🤾‍♀🤾🏻‍♀️🤾🏻‍♀🤾🏼‍♀️🤾🏼‍♀🤾🏽‍♀️🤾🏽‍♀🤾🏾‍♀️🤾🏾‍♀🤾🏿‍♀️🤾🏿‍♀🤹🤹🏻🤹🏼🤹🏽🤹🏾🤹🏿🤹‍♂️🤹‍♂🤹🏻‍♂️🤹🏻‍♂🤹🏼‍♂️🤹🏼‍♂🤹🏽‍♂️🤹🏽‍♂🤹🏾‍♂️🤹🏾‍♂🤹🏿‍♂️🤹🏿‍♂🤹‍♀️🤹‍♀🤹🏻‍♀️🤹🏻‍♀🤹🏼‍♀️🤹🏼‍♀🤹🏽‍♀️🤹🏽‍♀🤹🏾‍♀️🤹🏾‍♀🤹🏿‍♀️🤹🏿‍♀👫👬👭💏👩‍❤️‍💋‍👨👩‍❤‍💋‍👨👨‍❤️‍💋‍👨👨‍❤‍💋‍👨👩‍❤️‍💋‍👩👩‍❤‍💋‍👩💑👩‍❤️‍👨👩‍❤‍👨👨‍❤️‍👨👨‍❤‍👨👩‍❤️‍👩👩‍❤‍👩👪👨‍👩‍👦👨‍👩‍👧👨‍👩‍👧‍👦👨‍👩‍👦‍👦👨‍👩‍👧‍👧👨‍👨‍👦👨‍👨‍👧👨‍👨‍👧‍👦👨‍👨‍👦‍👦👨‍👨‍👧‍👧👩‍👩‍👦👩‍👩‍👧👩‍👩‍👧‍👦👩‍👩‍👦‍👦👩‍👩‍👧‍👧👨‍👦👨‍👦‍👦👨‍👧👨‍👧‍👦👨‍👧‍👧👩‍👦👩‍👦‍👦👩‍👧👩‍👧‍👦👩‍👧‍👧🤳🤳🏻🤳🏼🤳🏽🤳🏾🤳🏿💪💪🏻💪🏼💪🏽💪🏾💪🏿🦵🦵🏻🦵🏼🦵🏽🦵🏾🦵🏿🦶🦶🏻🦶🏼🦶🏽🦶🏾🦶🏿👈👈🏻👈🏼👈🏽👈🏾👈🏿👉👉🏻👉🏼👉🏽👉🏾👉🏿☝️☝☝🏻☝🏼☝🏽☝🏾☝🏿👆👆🏻👆🏼👆🏽👆🏾👆🏿🖕🖕🏻🖕🏼🖕🏽🖕🏾🖕🏿👇👇🏻👇🏼👇🏽👇🏾👇🏿✌️✌✌🏻✌🏼✌🏽✌🏾✌🏿🤞🤞🏻🤞🏼🤞🏽🤞🏾🤞🏿🖖🖖🏻🖖🏼🖖🏽🖖🏾🖖🏿🤘🤘🏻🤘🏼🤘🏽🤘🏾🤘🏿🤙🤙🏻🤙🏼🤙🏽🤙🏾🤙🏿🖐️🖐🖐🏻🖐🏼🖐🏽🖐🏾🖐🏿✋✋🏻✋🏼✋🏽✋🏾✋🏿👌👌🏻👌🏼👌🏽👌🏾👌🏿👍👍🏻👍🏼👍🏽👍🏾👍🏿👎👎🏻👎🏼👎🏽👎🏾👎🏿✊✊🏻✊🏼✊🏽✊🏾✊🏿👊👊🏻👊🏼👊🏽👊🏾👊🏿🤛🤛🏻🤛🏼🤛🏽🤛🏾🤛🏿🤜🤜🏻🤜🏼🤜🏽🤜🏾🤜🏿🤚🤚🏻🤚🏼🤚🏽🤚🏾🤚🏿👋👋🏻👋🏼👋🏽👋🏾👋🏿🤟🤟🏻🤟🏼🤟🏽🤟🏾🤟🏿✍️✍✍🏻✍🏼✍🏽✍🏾✍🏿👏👏🏻👏🏼👏🏽👏🏾👏🏿👐👐🏻👐🏼👐🏽👐🏾👐🏿🙌🙌🏻🙌🏼🙌🏽🙌🏾🙌🏿🤲🤲🏻🤲🏼🤲🏽🤲🏾🤲🏿🙏🙏🏻🙏🏼🙏🏽🙏🏾🙏🏿🤝💅💅🏻💅🏼💅🏽💅🏾💅🏿👂👂🏻👂🏼👂🏽👂🏾👂🏿👃👃🏻👃🏼👃🏽👃🏾👃🏿🦰🦱🦲🦳👣👀👁️👁👁️‍🗨️👁‍🗨️👁️‍🗨👁‍🗨🧠🦴🦷👅👄💋💘❤️❤💓💔💕💖💗💙💚💛🧡💜🖤💝💞💟❣️❣💌💤💢💣💥💦💨💫💬🗨️🗨🗯️🗯💭🕳️🕳👓🕶️🕶🥽🥼👔👕👖🧣🧤🧥🧦👗👘👙👚👛👜👝🛍️🛍🎒👞👟🥾🥿👠👡👢👑👒🎩🎓🧢⛑️⛑📿💄💍💎🐵🐒🦍🐶🐕🐩🐺🦊🦝🐱🐈🦁🐯🐅🐆🐴🐎🦄🦓🦌🐮🐂🐃🐄🐷🐖🐗🐽🐏🐑🐐🐪🐫🦙🦒🐘🦏🦛🐭🐁🐀🐹🐰🐇🐿️🐿🦔🦇🐻🐨🐼🦘🦡🐾🦃🐔🐓🐣🐤🐥🐦🐧🕊️🕊🦅🦆🦢🦉🦚🦜🐸🐊🐢🦎🐍🐲🐉🦕🦖🐳🐋🐬🐟🐠🐡🦈🐙🐚🦀🦞🦐🦑🐌🦋🐛🐜🐝🐞🦗🕷️🕷🕸️🕸🦂🦟🦠💐🌸💮🏵️🏵🌹🥀🌺🌻🌼🌷🌱🌲🌳🌴🌵🌾🌿☘️☘🍀🍁🍂🍃🍇🍈🍉🍊🍋🍌🍍🥭🍎🍏🍐🍑🍒🍓🥝🍅🥥🥑🍆🥔🥕🌽🌶️🌶🥒🥬🥦🍄🥜🌰🍞🥐🥖🥨🥯🥞🧀🍖🍗🥩🥓🍔🍟🍕🌭🥪🌮🌯🥙🥚🍳🥘🍲🥣🥗🍿🧂🥫🍱🍘🍙🍚🍛🍜🍝🍠🍢🍣🍤🍥🥮🍡🥟🥠🥡🍦🍧🍨🍩🍪🎂🍰🧁🥧🍫🍬🍭🍮🍯🍼🥛☕🍵🍶🍾🍷🍸🍹🍺🍻🥂🥃🥤🥢🍽️🍽🍴🥄🔪🏺🌍🌎🌏🌐🗺️🗺🗾🧭🏔️🏔⛰️⛰🌋🗻🏕️🏕🏖️🏖🏜️🏜🏝️🏝🏞️🏞🏟️🏟🏛️🏛🏗️🏗🧱🏘️🏘🏚️🏚🏠🏡🏢🏣🏤🏥🏦🏨🏩🏪🏫🏬🏭🏯🏰💒🗼🗽⛪🕌🕍⛩️⛩🕋⛲⛺🌁🌃🏙️🏙🌄🌅🌆🌇🌉♨️♨🌌🎠🎡🎢💈🎪🚂🚃🚄🚅🚆🚇🚈🚉🚊🚝🚞🚋🚌🚍🚎🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚲🛴🛹🛵🚏🛣️🛣🛤️🛤🛢️🛢⛽🚨🚥🚦🛑🚧⚓⛵🛶🚤🛳️🛳⛴️⛴🛥️🛥🚢✈️✈🛩️🛩🛫🛬💺🚁🚟🚠🚡🛰️🛰🚀🛸🛎️🛎🧳⌛⏳⌚⏰⏱️⏱⏲️⏲🕰️🕰🕛🕧🕐🕜🕑🕝🕒🕞🕓🕟🕔🕠🕕🕡🕖🕢🕗🕣🕘🕤🕙🕥🕚🕦🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌡️🌡☀️☀🌝🌞⭐🌟🌠☁️☁⛅⛈️⛈🌤️🌤🌥️🌥🌦️🌦🌧️🌧🌨️🌨🌩️🌩🌪️🌪🌫️🌫🌬️🌬🌀🌈🌂☂️☂☔⛱️⛱⚡❄️❄☃️☃⛄☄️☄🔥💧🌊🎃🎄🎆🎇🧨✨🎈🎉🎊🎋🎍🎎🎏🎐🎑🧧🎀🎁🎗️🎗🎟️🎟🎫🎖️🎖🏆🏅🥇🥈🥉⚽⚾🥎🏀🏐🏈🏉🎾🥏🎳🏏🏑🏒🥍🏓🏸🥊🥋🥅⛳⛸️⛸🎣🎽🎿🛷🥌🎯🎱🔮🧿🎮🕹️🕹🎰🎲🧩🧸♠️♠♥️♥♦️♦♣️♣♟️♟🃏🀄🎴🎭🖼️🖼🎨🧵🧶🔇🔈🔉🔊📢📣📯🔔🔕🎼🎵🎶🎙️🎙🎚️🎚🎛️🎛🎤🎧📻🎷🎸🎹🎺🎻🥁📱📲☎️☎📞📟📠🔋🔌💻🖥️🖥🖨️🖨⌨️⌨🖱️🖱🖲️🖲💽💾💿📀🧮🎥🎞️🎞📽️📽🎬📺📷📸📹📼🔍🔎🕯️🕯💡🔦🏮📔📕📖📗📘📙📚📓📒📃📜📄📰🗞️🗞📑🔖🏷️🏷💰💴💵💶💷💸💳🧾💹💱💲✉️✉📧📨📩📤📥📦📫📪📬📭📮🗳️🗳✏️✏✒️✒🖋️🖋🖊️🖊🖌️🖌🖍️🖍📝💼📁📂🗂️🗂📅📆🗒️🗒🗓️🗓📇📈📉📊📋📌📍📎🖇️🖇📏📐✂️✂🗃️🗃🗄️🗄🗑️🗑🔒🔓🔏🔐🔑🗝️🗝🔨⛏️⛏⚒️⚒🛠️🛠🗡️🗡⚔️⚔🔫🏹🛡️🛡🔧🔩⚙️⚙🗜️🗜⚖️⚖🔗⛓️⛓🧰🧲⚗️⚗🧪🧫🧬🔬🔭📡💉💊🚪🛏️🛏🛋️🛋🚽🚿🛁🧴🧷🧹🧺🧻🧼🧽🧯🛒🚬⚰️⚰⚱️⚱🗿🏧🚮🚰♿🚹🚺🚻🚼🚾🛂🛃🛄🛅⚠️⚠🚸⛔🚫🚳🚭🚯🚱🚷📵🔞☢️☢☣️☣⬆️⬆↗️↗➡️➡↘️↘⬇️⬇↙️↙⬅️⬅↖️↖↕️↕↔️↔↩️↩↪️↪⤴️⤴⤵️⤵🔃🔄🔙🔚🔛🔜🔝🛐⚛️⚛🕉️🕉✡️✡☸️☸☯️☯✝️✝☦️☦☪️☪☮️☮🕎🔯♈♉♊♋♌♍♎♏♐♑♒♓⛎🔀🔁🔂▶️▶⏩⏭️⏭⏯️⏯◀️◀⏪⏮️⏮🔼⏫🔽⏬⏸️⏸⏹️⏹⏺️⏺⏏️⏏🎦🔅🔆📶📳📴♀️♀♂️♂⚕️⚕♾️♾♻️♻⚜️⚜🔱📛🔰⭕✅☑️☑✔️✔✖️✖❌❎➕➖➗➰➿〽️〽✳️✳✴️✴❇️❇‼️‼⁉️⁉❓❔❕❗〰️〰©️©®️®™️™#️⃣#⃣*️⃣*⃣0️⃣0⃣1️⃣1⃣2️⃣2⃣3️⃣3⃣4️⃣4⃣5️⃣5⃣6️⃣6⃣7️⃣7⃣8️⃣8⃣9️⃣9⃣🔟💯🔠🔡🔢🔣🔤🅰️🅰🆎🅱️🅱🆑🆒🆓ℹ️ℹ🆔Ⓜ️Ⓜ🆕🆖🅾️🅾🆗🅿️🅿🆘🆙🆚🈁🈂️🈂🈷️🈷🈶🈯🉐🈹🈚🈲🉑🈸🈴🈳㊗️㊗㊙️㊙🈺🈵▪️▪▫️▫◻️◻◼️◼◽◾⬛⬜🔶🔷🔸🔹🔺🔻💠🔘🔲🔳⚪⚫🔴🔵🏁🚩🎌🏴🏳️🏳🏳️‍🌈🏳‍🌈🏴‍☠️🏴‍☠🇦🇨🇦🇩🇦🇪🇦🇫🇦🇬🇦🇮🇦🇱🇦🇲🇦🇴🇦🇶🇦🇷🇦🇸🇦🇹🇦🇺🇦🇼🇦🇽🇦🇿🇧🇦🇧🇧🇧🇩🇧🇪🇧🇫🇧🇬🇧🇭🇧🇮🇧🇯🇧🇱🇧🇲🇧🇳🇧🇴🇧🇶🇧🇷🇧🇸🇧🇹🇧🇻🇧🇼🇧🇾🇧🇿🇨🇦🇨🇨🇨🇩🇨🇫🇨🇬🇨🇭🇨🇮🇨🇰🇨🇱🇨🇲🇨🇳🇨🇴🇨🇵🇨🇷🇨🇺🇨🇻🇨🇼🇨🇽🇨🇾🇨🇿🇩🇪🇩🇬🇩🇯🇩🇰🇩🇲🇩🇴🇩🇿🇪🇦🇪🇨🇪🇪🇪🇬🇪🇭🇪🇷🇪🇸🇪🇹🇪🇺🇫🇮🇫🇯🇫🇰🇫🇲🇫🇴🇫🇷🇬🇦🇬🇧🇬🇩🇬🇪🇬🇫🇬🇬🇬🇭🇬🇮🇬🇱🇬🇲🇬🇳🇬🇵🇬🇶🇬🇷🇬🇸🇬🇹🇬🇺🇬🇼🇬🇾🇭🇰🇭🇲🇭🇳🇭🇷🇭🇹🇭🇺🇮🇨🇮🇩🇮🇪🇮🇱🇮🇲🇮🇳🇮🇴🇮🇶🇮🇷🇮🇸🇮🇹🇯🇪🇯🇲🇯🇴🇯🇵🇰🇪🇰🇬🇰🇭🇰🇮🇰🇲🇰🇳🇰🇵🇰🇷🇰🇼🇰🇾🇰🇿🇱🇦🇱🇧🇱🇨🇱🇮🇱🇰🇱🇷🇱🇸🇱🇹🇱🇺🇱🇻🇱🇾🇲🇦🇲🇨🇲🇩🇲🇪🇲🇫🇲🇬🇲🇭🇲🇰🇲🇱🇲🇲🇲🇳🇲🇴🇲🇵🇲🇶🇲🇷🇲🇸🇲🇹🇲🇺🇲🇻🇲🇼🇲🇽🇲🇾🇲🇿🇳🇦🇳🇨🇳🇪🇳🇫🇳🇬🇳🇮🇳🇱🇳🇴🇳🇵🇳🇷🇳🇺🇳🇿🇴🇲🇵🇦🇵🇪🇵🇫🇵🇬🇵🇭🇵🇰🇵🇱🇵🇲🇵🇳🇵🇷🇵🇸🇵🇹🇵🇼🇵🇾🇶🇦🇷🇪🇷🇴🇷🇸🇷🇺🇷🇼🇸🇦🇸🇧🇸🇨🇸🇩🇸🇪🇸🇬🇸🇭🇸🇮🇸🇯🇸🇰🇸🇱🇸🇲🇸🇳🇸🇴🇸🇷🇸🇸🇸🇹🇸🇻🇸🇽🇸🇾🇸🇿🇹🇦🇹🇨🇹🇩🇹🇫🇹🇬🇹🇭🇹🇯🇹🇰🇹🇱🇹🇲🇹🇳🇹🇴🇹🇷🇹🇹🇹🇻🇹🇼🇹🇿🇺🇦🇺🇬🇺🇲🇺🇳🇺🇸🇺🇾🇺🇿🇻🇦🇻🇨🇻🇪🇻🇬🇻🇮🇻🇳🇻🇺🇼🇫🇼🇸🇽🇰🇾🇪🇾🇹🇿🇦🇿🇲🇿🇼🏴󠁧󠁢󠁥󠁮󠁧󠁿🏴󠁧󠁢󠁳󠁣󠁴��🏴󠁧󠁢󠁷󠁬󠁳󠁿"
389
+ );
390
+ expect(() => emoji.parse(":-)")).toThrow();
391
+ expect(() => emoji.parse("😀 is an emoji")).toThrow();
392
+ expect(() => emoji.parse("😀stuff")).toThrow();
393
+ expect(() => emoji.parse("stuff😀")).toThrow();
394
+ });
395
+
396
+ test("nanoid", () => {
397
+ const nanoid = z.string().nanoid("custom error");
398
+ nanoid.parse("lfNZluvAxMkf7Q8C5H-QS");
399
+ nanoid.parse("mIU_4PJWikaU8fMbmkouz");
400
+ nanoid.parse("Hb9ZUtUa2JDm_dD-47EGv");
401
+ nanoid.parse("5Noocgv_8vQ9oPijj4ioQ");
402
+ const result = nanoid.safeParse("Xq90uDyhddC53KsoASYJGX");
403
+ expect(result).toMatchObject({ success: false });
404
+
405
+ expect(result.error!.issues[0].message).toEqual("custom error");
406
+ expect(result.error).toMatchInlineSnapshot(`
407
+ [ZodError: [
408
+ {
409
+ "origin": "string",
410
+ "code": "invalid_format",
411
+ "format": "nanoid",
412
+ "pattern": "/^[a-zA-Z0-9_-]{21}$/",
413
+ "path": [],
414
+ "message": "custom error"
415
+ }
416
+ ]]
417
+ `);
418
+ });
419
+
420
+ test("bad nanoid", () => {
421
+ const nanoid = z.string().nanoid("custom error");
422
+ nanoid.parse("ySh_984wpDUu7IQRrLXAp");
423
+ const result = nanoid.safeParse("invalid nanoid");
424
+ expect(result).toMatchObject({ success: false });
425
+
426
+ expect(result.error!.issues[0].message).toEqual("custom error");
427
+ expect(result.error).toMatchInlineSnapshot(`
428
+ [ZodError: [
429
+ {
430
+ "origin": "string",
431
+ "code": "invalid_format",
432
+ "format": "nanoid",
433
+ "pattern": "/^[a-zA-Z0-9_-]{21}$/",
434
+ "path": [],
435
+ "message": "custom error"
436
+ }
437
+ ]]
438
+ `);
439
+ });
440
+
441
+ test("good uuid", () => {
442
+ const uuid = z.string().uuid("custom error");
443
+ const goodUuids = [
444
+ "9491d710-3185-1e06-bea0-6a2f275345e0",
445
+ "9491d710-3185-2e06-bea0-6a2f275345e0",
446
+ "9491d710-3185-3e06-bea0-6a2f275345e0",
447
+ "9491d710-3185-4e06-bea0-6a2f275345e0",
448
+ "9491d710-3185-5e06-bea0-6a2f275345e0",
449
+ "9491d710-3185-5e06-aea0-6a2f275345e0",
450
+ "9491d710-3185-5e06-8ea0-6a2f275345e0",
451
+ "9491d710-3185-5e06-9ea0-6a2f275345e0",
452
+ "00000000-0000-0000-0000-000000000000",
453
+ ];
454
+
455
+ for (const goodUuid of goodUuids) {
456
+ const result = uuid.safeParse(goodUuid);
457
+ expect(result.success).toEqual(true);
458
+ }
459
+ });
460
+
461
+ test(`bad uuid`, () => {
462
+ const uuid = z.string().uuid("custom error");
463
+ for (const badUuid of [
464
+ "9491d710-3185-0e06-bea0-6a2f275345e0",
465
+ "9491d710-3185-5e06-0ea0-6a2f275345e0",
466
+ "d89e7b01-7598-ed11-9d7a-0022489382fd", // new sequential id
467
+ "b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 4122: Reserved, NCS backward compatibility
468
+ "92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 4122: Reserved, Microsoft Corporation backward compatibility
469
+ "invalid uuid",
470
+ "9491d710-3185-4e06-bea0-6a2f275345e0X",
471
+ "ffffffff-ffff-ffff-ffff-ffffffffffff",
472
+ ]) {
473
+ const result = uuid.safeParse(badUuid);
474
+ expect(result).toMatchObject({ success: false });
475
+ expect(result.error?.issues[0].message).toEqual("custom error");
476
+ }
477
+ });
478
+
479
+ test("good guid", () => {
480
+ const guid = z.string().guid("custom error");
481
+ for (const goodGuid of [
482
+ "9491d710-3185-4e06-bea0-6a2f275345e0",
483
+ "d89e7b01-7598-ed11-9d7a-0022489382fd", // new sequential id
484
+ "b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 4122: Reserved, NCS backward compatibility
485
+ "92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 4122: Reserved, Microsoft Corporation backward compatibility
486
+ "00000000-0000-0000-0000-000000000000",
487
+ "ffffffff-ffff-ffff-ffff-ffffffffffff",
488
+ ]) {
489
+ const result = guid.safeParse(goodGuid);
490
+ expect(result.success).toEqual(true);
491
+ }
492
+ });
493
+
494
+ test("bad guid", () => {
495
+ const guid = z.string().guid("custom error");
496
+ for (const badGuid of ["9491d710-3185-4e06-bea0-6a2f275345e0X"]) {
497
+ const result = guid.safeParse(badGuid);
498
+ expect(result).toMatchObject({ success: false });
499
+ expect(result.error?.issues[0].message).toEqual("custom error");
500
+ }
501
+ });
502
+
503
+ test("cuid", () => {
504
+ const cuid = z.string().cuid();
505
+ cuid.parse("ckopqwooh000001la8mbi2im9");
506
+ const result = cuid.safeParse("cifjhdsfhsd-invalid-cuid");
507
+ expect(result).toMatchObject({ success: false });
508
+
509
+ expect(result.error!.issues[0].message).toEqual("Invalid cuid");
510
+ expect(result.error).toMatchInlineSnapshot(`
511
+ [ZodError: [
512
+ {
513
+ "origin": "string",
514
+ "code": "invalid_format",
515
+ "format": "cuid",
516
+ "pattern": "/^[cC][^\\\\s-]{8,}$/",
517
+ "path": [],
518
+ "message": "Invalid cuid"
519
+ }
520
+ ]]
521
+ `);
522
+ });
523
+
524
+ test("cuid2", () => {
525
+ const cuid2 = z.string().cuid2();
526
+ const validStrings = [
527
+ "a", // short string
528
+ "tz4a98xxat96iws9zmbrgj3a", // normal string
529
+ "kf5vz6ssxe4zjcb409rjgo747tc5qjazgptvotk6", // longer than require("@paralleldrive/cuid2").bigLength
530
+ ];
531
+ for (const s of validStrings) {
532
+ cuid2.parse(s);
533
+ }
534
+
535
+ const invalidStrings = [
536
+ "", // empty string
537
+ "tz4a98xxat96iws9zMbrgj3a", // include uppercase
538
+ "tz4a98xxat96iws-zmbrgj3a", // involve symbols
539
+ ];
540
+ const results = invalidStrings.map((s) => cuid2.safeParse(s));
541
+ expect(results.every((r) => !r.success)).toEqual(true);
542
+ if (!results[0].success) {
543
+ expect(results[0].error.issues[0].message).toEqual("Invalid cuid2");
544
+ }
545
+ });
546
+
547
+ test("ulid", () => {
548
+ const ulid = z.string().ulid();
549
+ ulid.parse("01ARZ3NDEKTSV4RRFFQ69G5FAV");
550
+ const result = ulid.safeParse("invalidulid");
551
+ expect(result).toMatchObject({ success: false });
552
+ const tooLong = "01ARZ3NDEKTSV4RRFFQ69G5FAVA";
553
+ expect(ulid.safeParse(tooLong)).toMatchObject({ success: false });
554
+
555
+ const caseInsensitive = ulid.safeParse("01arZ3nDeKTsV4RRffQ69G5FAV");
556
+ expect(caseInsensitive.success).toEqual(true);
557
+
558
+ expect(result.error!.issues[0].message).toEqual("Invalid ULID");
559
+ expect(result.error).toMatchInlineSnapshot(`
560
+ [ZodError: [
561
+ {
562
+ "origin": "string",
563
+ "code": "invalid_format",
564
+ "format": "ulid",
565
+ "pattern": "/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/",
566
+ "path": [],
567
+ "message": "Invalid ULID"
568
+ }
569
+ ]]
570
+ `);
571
+ });
572
+
573
+ test("xid", () => {
574
+ const xid = z.string().xid();
575
+ xid.parse("9m4e2mr0ui3e8a215n4g");
576
+ const result = xid.safeParse("invalidxid");
577
+ expect(result).toMatchObject({ success: false });
578
+
579
+ expect(result.error!.issues[0].message).toEqual("Invalid XID");
580
+ expect(result.error).toMatchInlineSnapshot(`
581
+ [ZodError: [
582
+ {
583
+ "origin": "string",
584
+ "code": "invalid_format",
585
+ "format": "xid",
586
+ "pattern": "/^[0-9a-vA-V]{20}$/",
587
+ "path": [],
588
+ "message": "Invalid XID"
589
+ }
590
+ ]]
591
+ `);
592
+ });
593
+
594
+ test("ksuid", () => {
595
+ const ksuid = z.string().ksuid();
596
+ ksuid.parse("0o0t9hkGxgFLtd3lmJ4TSTeY0Vb");
597
+ const result = ksuid.safeParse("invalidksuid");
598
+ expect(result).toMatchObject({ success: false });
599
+ const tooLong = "0o0t9hkGxgFLtd3lmJ4TSTeY0VbA";
600
+ expect(ksuid.safeParse(tooLong)).toMatchObject({ success: false });
601
+ expect(result.error!.issues).toMatchInlineSnapshot(`
602
+ [
603
+ {
604
+ "code": "invalid_format",
605
+ "format": "ksuid",
606
+ "message": "Invalid KSUID",
607
+ "origin": "string",
608
+ "path": [],
609
+ "pattern": "/^[A-Za-z0-9]{27}$/",
610
+ },
611
+ ]
612
+ `);
613
+ });
614
+
615
+ test("regex", () => {
616
+ z.string()
617
+ .regex(/^moo+$/)
618
+ .parse("mooooo");
619
+ expect(() => z.string().uuid().parse("purr")).toThrow();
620
+ });
621
+
622
+ test("regexp error message", () => {
623
+ const result = z
624
+ .string()
625
+ .regex(/^moo+$/)
626
+ .safeParse("boooo");
627
+ expect(result.error!.issues).toMatchInlineSnapshot(`
628
+ [
629
+ {
630
+ "code": "invalid_format",
631
+ "format": "regex",
632
+ "message": "Invalid string: must match pattern /^moo+$/",
633
+ "origin": "string",
634
+ "path": [],
635
+ "pattern": "/^moo+$/",
636
+ },
637
+ ]
638
+ `);
639
+
640
+ expect(() => z.string().uuid().parse("purr")).toThrow();
641
+ });
642
+
643
+ test("regexp error custom message", () => {
644
+ const result = z
645
+ .string()
646
+ .regex(/^moo+$/, { message: "Custom error message" })
647
+ .safeParse("boooo");
648
+ expect(result.error!.issues).toMatchInlineSnapshot(`
649
+ [
650
+ {
651
+ "code": "invalid_format",
652
+ "format": "regex",
653
+ "message": "Custom error message",
654
+ "origin": "string",
655
+ "path": [],
656
+ "pattern": "/^moo+$/",
657
+ },
658
+ ]
659
+ `);
660
+
661
+ expect(() => z.string().uuid().parse("purr")).toThrow();
662
+ });
663
+
664
+ test("regex lastIndex reset", () => {
665
+ const schema = z.string().regex(/^\d+$/g);
666
+ expect(schema.safeParse("123").success).toEqual(true);
667
+ expect(schema.safeParse("123").success).toEqual(true);
668
+ expect(schema.safeParse("123").success).toEqual(true);
669
+ expect(schema.safeParse("123").success).toEqual(true);
670
+ expect(schema.safeParse("123").success).toEqual(true);
671
+ });
672
+
673
+ test("format", () => {
674
+ expect(z.string().email().format).toEqual("email");
675
+ expect(z.string().url().format).toEqual("url");
676
+ expect(z.string().jwt().format).toEqual("jwt");
677
+ expect(z.string().emoji().format).toEqual("emoji");
678
+ expect(z.string().guid().format).toEqual("guid");
679
+ expect(z.string().uuid().format).toEqual("uuid");
680
+ expect(z.string().uuidv4().format).toEqual("uuid");
681
+ expect(z.string().uuidv6().format).toEqual("uuid");
682
+ expect(z.string().uuidv7().format).toEqual("uuid");
683
+ expect(z.string().nanoid().format).toEqual("nanoid");
684
+ expect(z.string().guid().format).toEqual("guid");
685
+ expect(z.string().cuid().format).toEqual("cuid");
686
+ expect(z.string().cuid2().format).toEqual("cuid2");
687
+ expect(z.string().ulid().format).toEqual("ulid");
688
+ expect(z.string().base64().format).toEqual("base64");
689
+ // expect(z.string().jsonString().format).toEqual("json_string");
690
+ // expect(z.string().json().format).toEqual("json_string");
691
+ expect(z.string().xid().format).toEqual("xid");
692
+ expect(z.string().ksuid().format).toEqual("ksuid");
693
+ // expect(z.string().ip().format).toEqual("ip");
694
+ expect(z.string().ipv4().format).toEqual("ipv4");
695
+ expect(z.string().ipv6().format).toEqual("ipv6");
696
+ expect(z.string().e164().format).toEqual("e164");
697
+ expect(z.string().datetime().format).toEqual("datetime");
698
+ expect(z.string().date().format).toEqual("date");
699
+ expect(z.string().time().format).toEqual("time");
700
+ expect(z.string().duration().format).toEqual("duration");
701
+ });
702
+
703
+ test("min max getters", () => {
704
+ expect(z.string().min(5).minLength).toEqual(5);
705
+ expect(z.string().min(5).min(10).minLength).toEqual(10);
706
+ expect(z.string().minLength).toEqual(null);
707
+
708
+ expect(z.string().max(5).maxLength).toEqual(5);
709
+ expect(z.string().max(5).max(1).maxLength).toEqual(1);
710
+ expect(z.string().max(5).max(10).maxLength).toEqual(5);
711
+ expect(z.string().maxLength).toEqual(null);
712
+ });
713
+
714
+ test("trim", () => {
715
+ expect(z.string().trim().min(2).parse(" 12 ")).toEqual("12");
716
+
717
+ // ordering of methods is respected
718
+ expect(z.string().min(2).trim().parse(" 1 ")).toEqual("1");
719
+ expect(() => z.string().trim().min(2).parse(" 1 ")).toThrow();
720
+ });
721
+
722
+ test("lowerCase", () => {
723
+ expect(z.string().toLowerCase().parse("ASDF")).toEqual("asdf");
724
+ expect(z.string().toUpperCase().parse("asdf")).toEqual("ASDF");
725
+ });
726
+
727
+ // test("IP validation", () => {
728
+ // const ipSchema = z.string().ip();
729
+
730
+ // // General IP validation (accepts both v4 and v6)
731
+ // expect(ipSchema.safeParse("114.71.82.94").success).toBe(true);
732
+ // expect(ipSchema.safeParse("0.0.0.0").success).toBe(true);
733
+ // expect(ipSchema.safeParse("37.85.236.115").success).toBe(true);
734
+ // expect(ipSchema.safeParse("1e5e:e6c8:daac:514b:114b:e360:d8c0:682c").success).toBe(true);
735
+ // expect(ipSchema.safeParse("9d4:c956:420f:5788:4339:9b3b:2418:75c3").success).toBe(true);
736
+ // expect(ipSchema.safeParse("a6ea::2454:a5ce:94.105.123.75").success).toBe(true);
737
+ // expect(ipSchema.safeParse("474f:4c83::4e40:a47:ff95:0cda").success).toBe(true);
738
+ // expect(ipSchema.safeParse("d329:0:25b4:db47:a9d1:0:4926:0000").success).toBe(true);
739
+ // expect(ipSchema.safeParse("e48:10fb:1499:3e28:e4b6:dea5:4692:912c").success).toBe(true);
740
+
741
+ // expect(ipSchema.safeParse("d329:1be4:25b4:db47:a9d1:dc71:4926:992c:14af").success).toBe(false);
742
+ // expect(ipSchema.safeParse("d5e7:7214:2b78::3906:85e6:53cc:709:32ba").success).toBe(false);
743
+ // expect(ipSchema.safeParse("8f69::c757:395e:976e::3441").success).toBe(false);
744
+ // expect(ipSchema.safeParse("54cb::473f:d516:0.255.256.22").success).toBe(false);
745
+ // expect(ipSchema.safeParse("54cb::473f:d516:192.168.1").success).toBe(false);
746
+ // expect(ipSchema.safeParse("256.0.4.4").success).toBe(false);
747
+ // expect(ipSchema.safeParse("-1.0.555.4").success).toBe(false);
748
+ // expect(ipSchema.safeParse("0.0.0.0.0").success).toBe(false);
749
+ // expect(ipSchema.safeParse("1.1.1").success).toBe(false);
750
+ // });
751
+
752
+ test("IPv4 validation", () => {
753
+ const ipv4 = z.string().ipv4();
754
+
755
+ // Valid IPv4 addresses
756
+ expect(ipv4.safeParse("114.71.82.94").success).toBe(true);
757
+ expect(ipv4.safeParse("0.0.0.0").success).toBe(true);
758
+ expect(ipv4.safeParse("37.85.236.115").success).toBe(true);
759
+ expect(ipv4.safeParse("192.168.0.1").success).toBe(true);
760
+ expect(ipv4.safeParse("255.255.255.255").success).toBe(true);
761
+ expect(ipv4.safeParse("1.2.3.4").success).toBe(true);
762
+
763
+ // Invalid IPv4 addresses
764
+ expect(ipv4.safeParse("256.0.4.4").success).toBe(false);
765
+ expect(ipv4.safeParse("-1.0.555.4").success).toBe(false);
766
+ expect(ipv4.safeParse("0.0.0.0.0").success).toBe(false);
767
+ expect(ipv4.safeParse("1.1.1").success).toBe(false);
768
+ expect(ipv4.safeParse("1e5e:e6c8:daac:514b:114b:e360:d8c0:682c").success).toBe(false);
769
+ expect(ipv4.safeParse("a6ea::2454:a5ce:94.105.123.75").success).toBe(false);
770
+ expect(ipv4.safeParse("not an ip").success).toBe(false);
771
+ expect(ipv4.safeParse("1.2.3").success).toBe(false);
772
+ expect(ipv4.safeParse("1.2.3.4.5").success).toBe(false);
773
+ expect(ipv4.safeParse("1.2.3.256").success).toBe(false);
774
+
775
+ // Test specific error
776
+ expect(() => ipv4.parse("6097:adfa:6f0b:220d:db08:5021:6191:7990")).toThrow();
777
+ });
778
+
779
+ test("IPv6 validation", () => {
780
+ const ipv6 = z.string().ipv6();
781
+
782
+ // Valid IPv6 addresses
783
+ expect(ipv6.safeParse("1e5e:e6c8:daac:514b:114b:e360:d8c0:682c").success).toBe(true);
784
+ expect(ipv6.safeParse("9d4:c956:420f:5788:4339:9b3b:2418:75c3").success).toBe(true);
785
+ expect(ipv6.safeParse("a6ea::2454:a5ce:94.105.123.75").success).toBe(true);
786
+ expect(ipv6.safeParse("474f:4c83::4e40:a47:ff95:0cda").success).toBe(true);
787
+ expect(ipv6.safeParse("d329:0:25b4:db47:a9d1:0:4926:0000").success).toBe(true);
788
+ expect(ipv6.safeParse("e48:10fb:1499:3e28:e4b6:dea5:4692:912c").success).toBe(true);
789
+ expect(ipv6.safeParse("::1").success).toBe(true);
790
+ expect(ipv6.safeParse("2001:db8::").success).toBe(true);
791
+ expect(ipv6.safeParse("2001:0db8:85a3:0000:0000:8a2e:0370:7334").success).toBe(true);
792
+ expect(ipv6.safeParse("2001:db8::192.168.0.1").success).toBe(true);
793
+ expect(ipv6.safeParse("::ffff:192.168.0.1").success).toBe(true);
794
+ expect(ipv6.safeParse("::ffff:c000:0280").success).toBe(true); // IPv4-mapped IPv6 address
795
+ expect(ipv6.safeParse("64:ff9b::192.168.0.1").success).toBe(true); // IPv4/IPv6 translation
796
+
797
+ // Invalid IPv6 addresses
798
+ expect(ipv6.safeParse("d329:1be4:25b4:db47:a9d1:dc71:4926:992c:14af").success).toBe(false);
799
+ expect(ipv6.safeParse("d5e7:7214:2b78::3906:85e6:53cc:709:32ba").success).toBe(false);
800
+ expect(ipv6.safeParse("8f69::c757:395e:976e::3441").success).toBe(false);
801
+ expect(ipv6.safeParse("54cb::473f:d516:0.255.256.22").success).toBe(false);
802
+ expect(ipv6.safeParse("54cb::473f:d516:192.168.1").success).toBe(false);
803
+ expect(ipv6.safeParse("114.71.82.94").success).toBe(false);
804
+ expect(ipv6.safeParse("not an ip").success).toBe(false);
805
+ expect(ipv6.safeParse("g123::1234:5678").success).toBe(false);
806
+
807
+ // Test specific error
808
+ expect(() => ipv6.parse("254.164.77.1")).toThrow();
809
+ });
810
+
811
+ test("CIDR v4 validation", () => {
812
+ const cidrV4 = z.string().cidrv4();
813
+
814
+ // Valid CIDR v4 addresses
815
+ expect(cidrV4.safeParse("192.168.0.0/24").success).toBe(true);
816
+ expect(cidrV4.safeParse("10.0.0.0/8").success).toBe(true);
817
+ expect(cidrV4.safeParse("172.16.0.0/12").success).toBe(true);
818
+ expect(cidrV4.safeParse("0.0.0.0/0").success).toBe(true);
819
+ expect(cidrV4.safeParse("255.255.255.255/32").success).toBe(true);
820
+
821
+ // Invalid CIDR v4 addresses
822
+ expect(cidrV4.safeParse("192.168.0.0").success).toBe(false); // Missing prefix
823
+ expect(cidrV4.safeParse("192.168.0.0/33").success).toBe(false); // Invalid prefix length
824
+ expect(cidrV4.safeParse("256.0.0.0/24").success).toBe(false); // Invalid IP
825
+ expect(cidrV4.safeParse("192.168.0.0/-1").success).toBe(false); // Negative prefix length
826
+ expect(cidrV4.safeParse("not a cidr").success).toBe(false); // Invalid format
827
+ });
828
+
829
+ test("CIDR v6 validation", () => {
830
+ const cidrV6 = z.string().cidrv6();
831
+
832
+ // Valid CIDR v6 addresses
833
+ expect(cidrV6.safeParse("2001:db8::/32").success).toBe(true);
834
+ expect(cidrV6.safeParse("::/0").success).toBe(true);
835
+ expect(cidrV6.safeParse("fe80::/10").success).toBe(true);
836
+ expect(cidrV6.safeParse("::1/128").success).toBe(true);
837
+ expect(cidrV6.safeParse("2001:0db8:85a3::/64").success).toBe(true);
838
+
839
+ // Invalid CIDR v6 addresses
840
+ expect(cidrV6.safeParse("2001:db8::").success).toBe(false); // Missing prefix
841
+ expect(cidrV6.safeParse("2001:db8::/129").success).toBe(false); // Invalid prefix length
842
+ expect(cidrV6.safeParse("2001:db8::/abc").success).toBe(false); // Invalid prefix format
843
+ expect(cidrV6.safeParse("not a cidr").success).toBe(false); // Invalid format
844
+ expect(cidrV6.safeParse("192.168.0.0/24").success).toBe(false); // IPv4 CIDR in v6 validation
845
+ });
846
+
847
+ test("E.164 validation", () => {
848
+ const e164Number = z.string().e164();
849
+ expect(e164Number.safeParse("+1555555").success).toBe(true);
850
+
851
+ const validE164Numbers = [
852
+ "+1555555", // min-length (7 digits + '+')
853
+ "+15555555",
854
+ "+155555555",
855
+ "+1555555555",
856
+ "+15555555555",
857
+ "+155555555555",
858
+ "+1555555555555",
859
+ "+15555555555555",
860
+ "+155555555555555",
861
+ "+105555555555555",
862
+ "+100555555555555", // max-length (15 digits + '+')
863
+ ];
864
+
865
+ const invalidE164Numbers = [
866
+ "", // empty
867
+ "+", // only plus sign
868
+ "-", // wrong sign
869
+ " 555555555", // starts with space
870
+ "555555555", // missing plus sign
871
+ "+1 555 555 555", // space after plus sign
872
+ "+1555 555 555", // space between numbers
873
+ "+1555+555", // multiple plus signs
874
+ "+1555555555555555", // too long
875
+ "+115abc55", // non numeric characters in number part
876
+ "+1555555 ", // space after number
877
+ ];
878
+
879
+ expect(validE164Numbers.every((number) => e164Number.safeParse(number).success)).toBe(true);
880
+ expect(invalidE164Numbers.every((number) => e164Number.safeParse(number).success === false)).toBe(true);
881
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/stringbool.test.ts ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ test("z.stringbool", () => {
5
+ const a = z.stringbool();
6
+ type a = z.infer<typeof a>;
7
+ expectTypeOf<a>().toEqualTypeOf<boolean>();
8
+ type a_in = z.input<typeof a>;
9
+ expectTypeOf<a_in>().toEqualTypeOf<string>();
10
+
11
+ expect(z.parse(a, "true")).toEqual(true);
12
+ expect(z.parse(a, "yes")).toEqual(true);
13
+ expect(z.parse(a, "1")).toEqual(true);
14
+ expect(z.parse(a, "on")).toEqual(true);
15
+ expect(z.parse(a, "y")).toEqual(true);
16
+ expect(z.parse(a, "enabled")).toEqual(true);
17
+ expect(z.parse(a, "TRUE")).toEqual(true);
18
+
19
+ expect(z.parse(a, "false")).toEqual(false);
20
+ expect(z.parse(a, "no")).toEqual(false);
21
+ expect(z.parse(a, "0")).toEqual(false);
22
+ expect(z.parse(a, "off")).toEqual(false);
23
+ expect(z.parse(a, "n")).toEqual(false);
24
+ expect(z.parse(a, "disabled")).toEqual(false);
25
+ expect(z.parse(a, "FALSE")).toEqual(false);
26
+
27
+ expect(z.safeParse(a, "other")).toMatchObject({ success: false });
28
+ expect(z.safeParse(a, "")).toMatchObject({ success: false });
29
+ expect(z.safeParse(a, undefined)).toMatchObject({ success: false });
30
+ expect(z.safeParse(a, {})).toMatchObject({ success: false });
31
+ expect(z.safeParse(a, true)).toMatchObject({ success: false });
32
+ expect(z.safeParse(a, false)).toMatchObject({ success: false });
33
+ });
34
+
35
+ test("custom values", () => {
36
+ const b = z.stringbool({
37
+ truthy: ["y"],
38
+ falsy: ["N"],
39
+ });
40
+ expect(z.parse(b, "y")).toEqual(true);
41
+ expect(z.parse(b, "Y")).toEqual(true);
42
+ expect(z.parse(b, "n")).toEqual(false);
43
+ expect(z.parse(b, "N")).toEqual(false);
44
+ expect(z.safeParse(b, "true")).toMatchObject({ success: false });
45
+ expect(z.safeParse(b, "false")).toMatchObject({ success: false });
46
+ });
47
+
48
+ test("custom values - case sensitive", () => {
49
+ const c = z.stringbool({
50
+ truthy: ["y"],
51
+ falsy: ["N"],
52
+ case: "sensitive",
53
+ });
54
+ expect(z.parse(c, "y")).toEqual(true);
55
+ expect(z.safeParse(c, "Y")).toMatchObject({ success: false });
56
+ expect(z.parse(c, "N")).toEqual(false);
57
+ expect(z.safeParse(c, "n")).toMatchObject({ success: false });
58
+ expect(z.safeParse(c, "TRUE")).toMatchObject({ success: false });
59
+ });
60
+
61
+ // test custom error messages
62
+ test("z.stringbool with custom error messages", () => {
63
+ const a = z.stringbool("wrong!");
64
+
65
+ expect(() => a.parse("")).toThrowError("wrong!");
66
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/template-literal.test.ts ADDED
@@ -0,0 +1,758 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ const empty = z.templateLiteral([]);
5
+ const hello = z.templateLiteral(["hello"]);
6
+ const world = z.templateLiteral(["", z.literal("world")]);
7
+ const one = z.templateLiteral([1]);
8
+ const two = z.templateLiteral(["", z.literal(2)]);
9
+ const truee = z.templateLiteral([true]);
10
+ const anotherTrue = z.templateLiteral(["", z.literal(true)]);
11
+ const falsee = z.templateLiteral([false]);
12
+ const anotherFalse = z.templateLiteral(["", z.literal(false)]);
13
+ const nulll = z.templateLiteral([null]);
14
+ const anotherNull = z.templateLiteral(["", z.null()]);
15
+ const undefinedd = z.templateLiteral([undefined]);
16
+ const anotherUndefined = z.templateLiteral(["", z.undefined()]);
17
+ const anyString = z.templateLiteral(["", z.string()]);
18
+ const lazyString = z.templateLiteral(["", z.lazy(() => z.string())]);
19
+ const anyNumber = z.templateLiteral(["", z.number()]);
20
+ const anyInt = z.templateLiteral(["", z.number().int()]);
21
+ // const anyFiniteNumber = z.templateLiteral(["", z.number().finite()]);
22
+ // const anyNegativeNumber = z.templateLiteral(["", z.number().negative()]);
23
+ // const anyPositiveNumber = z.templateLiteral(["", z.number().positive()]);
24
+ // const zeroButInADumbWay = z.templateLiteral(["", z.number().nonnegative().nonpositive()]);
25
+ // const finiteButInADumbWay = z.templateLiteral(["", z.number().min(5).max(10)]);
26
+ const bool = z.templateLiteral(["", z.boolean()]);
27
+ const bigone = z.templateLiteral(["", z.literal(BigInt(1))]);
28
+ const anyBigint = z.templateLiteral(["", z.bigint()]);
29
+ const nullableYo = z.templateLiteral(["", z.nullable(z.literal("yo"))]);
30
+ const nullableString = z.templateLiteral(["", z.nullable(z.string())]);
31
+ const optionalYeah = z.templateLiteral(["", z.literal("yeah").optional()]);
32
+
33
+ const optionalString = z.templateLiteral(["", z.string().optional()]);
34
+ const optionalNumber = z.templateLiteral(["", z.number().optional()]);
35
+ const nullishBruh = z.templateLiteral(["", z.literal("bruh").nullish()]);
36
+ const nullishString = z.templateLiteral(["", z.string().nullish()]);
37
+ const cuid = z.templateLiteral(["", z.string().cuid()]);
38
+ const cuidZZZ = z.templateLiteral(["", z.string().cuid(), "ZZZ"]);
39
+ const cuid2 = z.templateLiteral(["", z.string().cuid2()]);
40
+ const datetime = z.templateLiteral(["", z.string().datetime()]);
41
+ const email = z.templateLiteral(["", z.string().email()]);
42
+ // const ip = z.templateLiteral(["", z.string().ip()]);
43
+ const ipv4 = z.templateLiteral(["", z.string().ipv4()]);
44
+ const ipv6 = z.templateLiteral(["", z.string().ipv6()]);
45
+ const ulid = z.templateLiteral(["", z.string().ulid()]);
46
+ const uuid = z.templateLiteral(["", z.string().uuid()]);
47
+ const stringAToZ = z.templateLiteral(["", z.string().regex(/^[a-z]+$/)]);
48
+ const stringStartsWith = z.templateLiteral(["", z.string().startsWith("hello")]);
49
+ const stringEndsWith = z.templateLiteral(["", z.string().endsWith("world")]);
50
+ const stringMax5 = z.templateLiteral(["", z.string().max(5)]);
51
+ const stringMin5 = z.templateLiteral(["", z.string().min(5)]);
52
+ const stringLen5 = z.templateLiteral(["", z.string().length(5)]);
53
+ const stringMin5Max10 = z.templateLiteral(["", z.string().min(5).max(10)]);
54
+ const stringStartsWithMax5 = z.templateLiteral(["", z.string().startsWith("hello").max(5)]);
55
+ const brandedString = z.templateLiteral(["", z.string().min(1).brand("myBrand")]);
56
+ // const anything = z.templateLiteral(["", z.any()]);
57
+
58
+ const url = z.templateLiteral(["https://", z.string().regex(/\w+/), ".", z.enum(["com", "net"])]);
59
+
60
+ const measurement = z.templateLiteral([
61
+ "",
62
+ z.number().finite(),
63
+ z.enum(["px", "em", "rem", "vh", "vw", "vmin", "vmax"]).optional(),
64
+ ]);
65
+
66
+ const connectionString = z.templateLiteral([
67
+ "mongodb://",
68
+ z
69
+ .templateLiteral([
70
+ "",
71
+ z.string().regex(/\w+/).describe("username"),
72
+ ":",
73
+ z.string().regex(/\w+/).describe("password"),
74
+ "@",
75
+ ])
76
+ .optional(),
77
+ z.string().regex(/\w+/).describe("host"),
78
+ ":",
79
+ z.number().finite().int().positive().describe("port"),
80
+ z
81
+ .templateLiteral([
82
+ "/",
83
+ z.string().regex(/\w+/).optional().describe("defaultauthdb"),
84
+ z
85
+ .templateLiteral([
86
+ "?",
87
+ z
88
+ .string()
89
+ .regex(/^\w+=\w+(&\w+=\w+)*$/)
90
+ .optional()
91
+ .describe("options"),
92
+ ])
93
+ .optional(),
94
+ ])
95
+ .optional(),
96
+ ]);
97
+
98
+ test("template literal type inference", () => {
99
+ expectTypeOf<z.infer<typeof empty>>().toEqualTypeOf<``>();
100
+ expectTypeOf<z.infer<typeof hello>>().toEqualTypeOf<`hello`>();
101
+ expectTypeOf<z.infer<typeof world>>().toEqualTypeOf<`world`>();
102
+ expectTypeOf<z.infer<typeof one>>().toEqualTypeOf<`1`>();
103
+ expectTypeOf<z.infer<typeof two>>().toEqualTypeOf<`2`>();
104
+ expectTypeOf<z.infer<typeof truee>>().toEqualTypeOf<`true`>();
105
+ expectTypeOf<z.infer<typeof anotherTrue>>().toEqualTypeOf<`true`>();
106
+ expectTypeOf<z.infer<typeof falsee>>().toEqualTypeOf<`false`>();
107
+ expectTypeOf<z.infer<typeof anotherFalse>>().toEqualTypeOf<`false`>();
108
+ expectTypeOf<z.infer<typeof nulll>>().toEqualTypeOf<`null`>();
109
+ expectTypeOf<z.infer<typeof anotherNull>>().toEqualTypeOf<`null`>();
110
+ expectTypeOf<z.infer<typeof undefinedd>>().toEqualTypeOf<``>();
111
+ expectTypeOf<z.infer<typeof anotherUndefined>>().toEqualTypeOf<``>();
112
+ expectTypeOf<z.infer<typeof anyString>>().toEqualTypeOf<string>();
113
+ expectTypeOf<z.infer<typeof lazyString>>().toEqualTypeOf<string>();
114
+ expectTypeOf<z.infer<typeof anyNumber>>().toEqualTypeOf<`${number}`>();
115
+ expectTypeOf<z.infer<typeof anyInt>>().toEqualTypeOf<`${number}`>();
116
+ // expectTypeOf<z.infer<typeof anyFiniteNumber>>().toEqualTypeOf<`${number}`>();
117
+ // expectTypeOf<z.infer<typeof anyNegativeNumber>>().toEqualTypeOf<`${number}`>();
118
+ // expectTypeOf<z.infer<typeof anyPositiveNumber>>().toEqualTypeOf<`${number}`>();
119
+ // expectTypeOf<z.infer<typeof zeroButInADumbWay>>().toEqualTypeOf<`${number}`>();
120
+ // expectTypeOf<z.infer<typeof finiteButInADumbWay>>().toEqualTypeOf<`${number}`>();
121
+ expectTypeOf<z.infer<typeof bool>>().toEqualTypeOf<`true` | `false`>();
122
+ expectTypeOf<z.infer<typeof bigone>>().toEqualTypeOf<`${bigint}`>();
123
+ expectTypeOf<z.infer<typeof anyBigint>>().toEqualTypeOf<`${bigint}`>();
124
+ expectTypeOf<z.infer<typeof nullableYo>>().toEqualTypeOf<`yo` | `null`>();
125
+ expectTypeOf<z.infer<typeof nullableString>>().toEqualTypeOf<string>();
126
+ expectTypeOf<z.infer<typeof optionalYeah>>().toEqualTypeOf<`yeah` | ``>();
127
+ expectTypeOf<z.infer<typeof optionalString>>().toEqualTypeOf<string>();
128
+ expectTypeOf<z.infer<typeof optionalNumber>>().toEqualTypeOf<`${number}` | ``>();
129
+ expectTypeOf<z.infer<typeof nullishBruh>>().toEqualTypeOf<`bruh` | `null` | ``>();
130
+ expectTypeOf<z.infer<typeof nullishString>>().toEqualTypeOf<string>();
131
+ expectTypeOf<z.infer<typeof cuid>>().toEqualTypeOf<string>();
132
+ expectTypeOf<z.infer<typeof cuidZZZ>>().toEqualTypeOf<`${string}ZZZ`>();
133
+ expectTypeOf<z.infer<typeof cuid2>>().toEqualTypeOf<string>();
134
+ expectTypeOf<z.infer<typeof datetime>>().toEqualTypeOf<string>();
135
+ expectTypeOf<z.infer<typeof email>>().toEqualTypeOf<string>();
136
+ // expectTypeOf<z.infer<typeof ip>>().toEqualTypeOf<string>();
137
+ expectTypeOf<z.infer<typeof ipv4>>().toEqualTypeOf<string>();
138
+ expectTypeOf<z.infer<typeof ipv6>>().toEqualTypeOf<string>();
139
+ expectTypeOf<z.infer<typeof ulid>>().toEqualTypeOf<string>();
140
+ expectTypeOf<z.infer<typeof uuid>>().toEqualTypeOf<string>();
141
+ expectTypeOf<z.infer<typeof stringAToZ>>().toEqualTypeOf<string>();
142
+ expectTypeOf<z.infer<typeof stringStartsWith>>().toEqualTypeOf<string>();
143
+ expectTypeOf<z.infer<typeof stringEndsWith>>().toEqualTypeOf<string>();
144
+ expectTypeOf<z.infer<typeof stringMax5>>().toEqualTypeOf<string>();
145
+ expectTypeOf<z.infer<typeof stringMin5>>().toEqualTypeOf<string>();
146
+ expectTypeOf<z.infer<typeof stringLen5>>().toEqualTypeOf<string>();
147
+ expectTypeOf<z.infer<typeof stringMin5Max10>>().toEqualTypeOf<string>();
148
+ expectTypeOf<z.infer<typeof stringStartsWithMax5>>().toEqualTypeOf<string>();
149
+ expectTypeOf<z.infer<typeof brandedString>>().toEqualTypeOf<`${string & z.core.$brand<"myBrand">}`>();
150
+
151
+ // expectTypeOf<z.infer<typeof anything>>().toEqualTypeOf<`${any}`>();
152
+
153
+ expectTypeOf<z.infer<typeof url>>().toEqualTypeOf<`https://${string}.com` | `https://${string}.net`>();
154
+
155
+ expectTypeOf<z.infer<typeof measurement>>().toEqualTypeOf<
156
+ | `${number}`
157
+ | `${number}px`
158
+ | `${number}em`
159
+ | `${number}rem`
160
+ | `${number}vh`
161
+ | `${number}vw`
162
+ | `${number}vmin`
163
+ | `${number}vmax`
164
+ >();
165
+
166
+ expectTypeOf<z.infer<typeof connectionString>>().toEqualTypeOf<
167
+ | `mongodb://${string}:${number}`
168
+ | `mongodb://${string}:${number}/${string}`
169
+ | `mongodb://${string}:${number}/${string}?${string}`
170
+ | `mongodb://${string}:${string}@${string}:${number}`
171
+ | `mongodb://${string}:${string}@${string}:${number}/${string}`
172
+ | `mongodb://${string}:${string}@${string}:${number}/${string}?${string}`
173
+ >();
174
+ });
175
+
176
+ test("template literal unsupported args", () => {
177
+ expect(() =>
178
+ // @ts-expect-error
179
+ z.templateLiteral([z.object({})])
180
+ ).toThrow();
181
+ expect(() =>
182
+ // @ts-expect-error
183
+ z.templateLiteral([z.array(z.object({}))])
184
+ ).toThrow();
185
+ expect(() =>
186
+ // @ts-expect-error
187
+ z.templateLiteral([z.union([z.object({}), z.string()])])
188
+ ).toThrow();
189
+ // @ts-expect-error
190
+ expect(() => z.templateLiteral([z.date()])).toThrow();
191
+ expect(() =>
192
+ // @ts-expect-error
193
+ z.templateLiteral([z.custom<object>((_) => true)])
194
+ ).toThrow();
195
+ expect(() =>
196
+ z.templateLiteral([
197
+ // @ts-expect-error
198
+ z.discriminatedUnion("discriminator", [z.object({}), z.object({})]),
199
+ ])
200
+ ).toThrow();
201
+ expect(() =>
202
+ // @ts-expect-error
203
+ z.templateLiteral([z.function()])
204
+ ).toThrow();
205
+ expect(() =>
206
+ // @ts-expect-error
207
+ z.templateLiteral([z.instanceof(class MyClass {})])
208
+ ).toThrow();
209
+ expect(() =>
210
+ // @ts-expect-error
211
+ z.templateLiteral([z.intersection(z.object({}), z.object({}))])
212
+ ).toThrow();
213
+ expect(() =>
214
+ // @ts-expect-error
215
+ z.templateLiteral([z.map(z.string(), z.string())])
216
+ ).toThrow();
217
+ expect(() =>
218
+ // @ts-expect-error
219
+ z.templateLiteral([z.nullable(z.object({}))])
220
+ ).toThrow();
221
+ expect(() =>
222
+ // @ts-expect-error
223
+ z.templateLiteral([z.optional(z.object({}))])
224
+ ).toThrow();
225
+ expect(() =>
226
+ // @ts-expect-error
227
+ z.templateLiteral([z.promise()])
228
+ ).toThrow();
229
+ expect(() =>
230
+ // @ts-expect-error
231
+ z.templateLiteral([z.record(z.unknown())])
232
+ ).toThrow();
233
+ expect(() =>
234
+ // @ts-expect-error
235
+ z.templateLiteral([z.set(z.string())])
236
+ ).toThrow();
237
+ expect(() =>
238
+ // @ts-expect-error
239
+ z.templateLiteral([z.symbol()])
240
+ ).toThrow();
241
+ expect(() =>
242
+ // @ts-expect-error
243
+ z.templateLiteral([z.tuple([z.string()])])
244
+ ).toThrow();
245
+ expect(() =>
246
+ // @ts-expect-error
247
+ z.templateLiteral([z.unknown()])
248
+ ).toThrow();
249
+ expect(() =>
250
+ // @ts-expect-error
251
+ z.templateLiteral([z.void()])
252
+ ).toThrow();
253
+
254
+ expect(() =>
255
+ // @ts-expect-error
256
+ z.templateLiteral([z.never()])
257
+ ).toThrow();
258
+ // @ts-expect-error
259
+ expect(() => z.templateLiteral([z.nan()])).toThrow();
260
+ expect(() =>
261
+ // @ts-expect-error
262
+ z.templateLiteral([z.pipe(z.string(), z.string())])
263
+ ).toThrow();
264
+ expect(() =>
265
+ // @ts-expect-error
266
+ z.templateLiteral([z.preprocess(() => true, z.boolean())])
267
+ ).toThrow();
268
+ expect(() =>
269
+ // @ts-expect-error
270
+ z.templateLiteral([z.object({}).brand("brand")])
271
+ ).toThrow();
272
+
273
+ // these constraints aren't enforced but they shouldn't throw
274
+ z.templateLiteral([z.number().multipleOf(2)]);
275
+ z.templateLiteral([z.string().emoji()]);
276
+ z.templateLiteral([z.string().url()]);
277
+ z.templateLiteral([z.string().url()]);
278
+ z.templateLiteral([z.string().trim()]);
279
+ z.templateLiteral([z.string().includes("train")]);
280
+ z.templateLiteral([z.string().toLowerCase()]);
281
+ z.templateLiteral([z.string().toUpperCase()]);
282
+ });
283
+
284
+ test("template literal parsing - success - basic cases", () => {
285
+ expect(() => z.templateLiteral([]).parse(7)).toThrow();
286
+
287
+ empty.parse("");
288
+ hello.parse("hello");
289
+ world.parse("world");
290
+ one.parse("1");
291
+ two.parse("2");
292
+ truee.parse("true");
293
+ anotherTrue.parse("true");
294
+ falsee.parse("false");
295
+ anotherFalse.parse("false");
296
+ nulll.parse("null");
297
+ anotherNull.parse("null");
298
+ undefinedd.parse("undefined");
299
+ anotherUndefined.parse("undefined");
300
+ anyString.parse("blahblahblah");
301
+ anyString.parse("");
302
+ lazyString.parse("blahblahblah");
303
+ lazyString.parse("");
304
+ anyNumber.parse("123");
305
+ anyNumber.parse("1.23");
306
+ anyNumber.parse("0");
307
+ anyNumber.parse("-1.23");
308
+ anyNumber.parse("-123");
309
+ // anyNumber.parse("Infinity");
310
+ // anyNumber.parse("-Infinity");
311
+ anyInt.parse("123");
312
+ // anyInt.parse("-123");
313
+ // anyFiniteNumber.parse("123");
314
+ // anyFiniteNumber.parse("1.23");
315
+ // anyFiniteNumber.parse("0");
316
+ // anyFiniteNumber.parse("-1.23");
317
+ // anyFiniteNumber.parse("-123");
318
+ // anyNegativeNumber.parse("-123");
319
+ // anyNegativeNumber.parse("-1.23");
320
+ // anyNegativeNumber.parse("-Infinity");
321
+ // anyPositiveNumber.parse("123");
322
+ // anyPositiveNumber.parse("1.23");
323
+ // anyPositiveNumber.parse("Infinity");
324
+ // zeroButInADumbWay.parse("0");
325
+ // zeroButInADumbWay.parse("00000");
326
+ // finiteButInADumbWay.parse("5");
327
+ // finiteButInADumbWay.parse("10");
328
+ // finiteButInADumbWay.parse("6.66");
329
+ bool.parse("true");
330
+ bool.parse("false");
331
+ bigone.parse("1");
332
+ anyBigint.parse("123456");
333
+ anyBigint.parse("0");
334
+ // anyBigint.parse("-123456");
335
+ nullableYo.parse("yo");
336
+ nullableYo.parse("null");
337
+ nullableString.parse("abc");
338
+ nullableString.parse("null");
339
+ optionalYeah.parse("yeah");
340
+ optionalYeah.parse("");
341
+ optionalString.parse("abc");
342
+ optionalString.parse("");
343
+ optionalNumber.parse("123");
344
+ optionalNumber.parse("1.23");
345
+ optionalNumber.parse("0");
346
+ optionalNumber.parse("-1.23");
347
+ optionalNumber.parse("-123");
348
+ // optionalNumber.parse("Infinity");
349
+ // optionalNumber.parse("-Infinity");
350
+ nullishBruh.parse("bruh");
351
+ nullishBruh.parse("null");
352
+ nullishBruh.parse("");
353
+ cuid.parse("cjld2cyuq0000t3rmniod1foy");
354
+ cuidZZZ.parse("cjld2cyuq0000t3rmniod1foyZZZ");
355
+ cuid2.parse("tz4a98xxat96iws9zmbrgj3a");
356
+ datetime.parse(new Date().toISOString());
357
+ email.parse("info@example.com");
358
+ // ip.parse("213.174.246.205");
359
+ // ip.parse("c359:f57c:21e5:39eb:1187:e501:f936:b452");
360
+ ipv4.parse("213.174.246.205");
361
+ ipv6.parse("c359:f57c:21e5:39eb:1187:e501:f936:b452");
362
+ ulid.parse("01GW3D2QZJBYB6P1Z1AE997VPW");
363
+ uuid.parse("808989fd-3a6e-4af2-b607-737323a176f6");
364
+ stringAToZ.parse("asudgaskhdgashd");
365
+ stringStartsWith.parse("hello world");
366
+ stringEndsWith.parse("hello world");
367
+ stringMax5.parse("hello");
368
+ stringMin5.parse("hello");
369
+ stringLen5.parse("hello");
370
+ stringMin5Max10.parse("hello worl");
371
+ stringStartsWithMax5.parse("hello");
372
+ brandedString.parse("branded string");
373
+ });
374
+
375
+ test("template literal parsing - failure - basic cases", () => {
376
+ expect(() => empty.parse("a")).toThrow();
377
+ expect(() => hello.parse("hello!")).toThrow();
378
+ expect(() => hello.parse("!hello")).toThrow();
379
+ expect(() => world.parse("world!")).toThrow();
380
+ expect(() => world.parse("!world")).toThrow();
381
+ expect(() => one.parse("2")).toThrow();
382
+ expect(() => one.parse("12")).toThrow();
383
+ expect(() => one.parse("21")).toThrow();
384
+ expect(() => two.parse("1")).toThrow();
385
+ expect(() => two.parse("21")).toThrow();
386
+ expect(() => two.parse("12")).toThrow();
387
+ expect(() => truee.parse("false")).toThrow();
388
+ expect(() => truee.parse("1true")).toThrow();
389
+ expect(() => truee.parse("true1")).toThrow();
390
+ expect(() => anotherTrue.parse("false")).toThrow();
391
+ expect(() => anotherTrue.parse("1true")).toThrow();
392
+ expect(() => anotherTrue.parse("true1")).toThrow();
393
+ expect(() => falsee.parse("true")).toThrow();
394
+ expect(() => falsee.parse("1false")).toThrow();
395
+ expect(() => falsee.parse("false1")).toThrow();
396
+ expect(() => anotherFalse.parse("true")).toThrow();
397
+ expect(() => anotherFalse.parse("1false")).toThrow();
398
+ expect(() => anotherFalse.parse("false1")).toThrow();
399
+ expect(() => nulll.parse("123")).toThrow();
400
+ expect(() => nulll.parse("null1")).toThrow();
401
+ expect(() => nulll.parse("1null")).toThrow();
402
+ expect(() => anotherNull.parse("123")).toThrow();
403
+ expect(() => anotherNull.parse("null1")).toThrow();
404
+ expect(() => anotherNull.parse("1null")).toThrow();
405
+ expect(() => undefinedd.parse("123")).toThrow();
406
+ expect(() => undefinedd.parse("undefined1")).toThrow();
407
+ expect(() => undefinedd.parse("1undefined")).toThrow();
408
+ expect(() => anotherUndefined.parse("123")).toThrow();
409
+ expect(() => anotherUndefined.parse("undefined1")).toThrow();
410
+ expect(() => anotherUndefined.parse("1undefined")).toThrow();
411
+ expect(() => anyNumber.parse("2a")).toThrow();
412
+ expect(() => anyNumber.parse("a2")).toThrow();
413
+ expect(() => anyNumber.parse("-2a")).toThrow();
414
+ expect(() => anyNumber.parse("a-2")).toThrow();
415
+ expect(() => anyNumber.parse("2.5a")).toThrow();
416
+ expect(() => anyNumber.parse("a2.5")).toThrow();
417
+ expect(() => anyNumber.parse("Infinitya")).toThrow();
418
+ expect(() => anyNumber.parse("aInfinity")).toThrow();
419
+ expect(() => anyNumber.parse("-Infinitya")).toThrow();
420
+ expect(() => anyNumber.parse("a-Infinity")).toThrow();
421
+ expect(() => anyNumber.parse("2e5")).toThrow();
422
+ expect(() => anyNumber.parse("2e-5")).toThrow();
423
+ expect(() => anyNumber.parse("2e+5")).toThrow();
424
+ expect(() => anyNumber.parse("-2e5")).toThrow();
425
+ expect(() => anyNumber.parse("-2e-5")).toThrow();
426
+ expect(() => anyNumber.parse("-2e+5")).toThrow();
427
+ expect(() => anyNumber.parse("2.1e5")).toThrow();
428
+ expect(() => anyNumber.parse("2.1e-5")).toThrow();
429
+ expect(() => anyNumber.parse("2.1e+5")).toThrow();
430
+ expect(() => anyNumber.parse("-2.1e5")).toThrow();
431
+ expect(() => anyNumber.parse("-2.1e-5")).toThrow();
432
+ expect(() => anyNumber.parse("-2.1e+5")).toThrow();
433
+ expect(() => anyNumber.parse("-Infinity")).toThrow();
434
+ expect(() => anyNumber.parse("Infinity")).toThrow();
435
+ expect(() => anyInt.parse("1.23")).toThrow();
436
+ expect(() => anyInt.parse("-1.23")).toThrow();
437
+ expect(() => anyInt.parse("d1")).toThrow();
438
+ expect(() => anyInt.parse("1d")).toThrow();
439
+ // expect(() => anyFiniteNumber.parse("Infinity")).toThrow();
440
+ // expect(() => anyFiniteNumber.parse("-Infinity")).toThrow();
441
+ // expect(() => anyFiniteNumber.parse("123a")).toThrow();
442
+ // expect(() => anyFiniteNumber.parse("a123")).toThrow();
443
+ // expect(() => anyNegativeNumber.parse("0")).toThrow();
444
+ // expect(() => anyNegativeNumber.parse("1")).toThrow();
445
+ // expect(() => anyNegativeNumber.parse("Infinity")).toThrow();
446
+ // expect(() => anyPositiveNumber.parse("0")).toThrow();
447
+ // expect(() => anyPositiveNumber.parse("-1")).toThrow();
448
+ // expect(() => anyPositiveNumber.parse("-Infinity")).toThrow();
449
+ // expect(() => zeroButInADumbWay.parse("1")).toThrow();
450
+ // expect(() => zeroButInADumbWay.parse("-1")).toThrow();
451
+ // expect(() => finiteButInADumbWay.parse("Infinity")).toThrow();
452
+ // expect(() => finiteButInADumbWay.parse("-Infinity")).toThrow();
453
+ // expect(() => finiteButInADumbWay.parse("-5")).toThrow();
454
+ // expect(() => finiteButInADumbWay.parse("10a")).toThrow();
455
+ // expect(() => finiteButInADumbWay.parse("a10")).toThrow();
456
+ expect(() => bool.parse("123")).toThrow();
457
+ expect(() => bigone.parse("2")).toThrow();
458
+ expect(() => bigone.parse("c1")).toThrow();
459
+ expect(() => anyBigint.parse("1.23")).toThrow();
460
+ expect(() => anyBigint.parse("-1.23")).toThrow();
461
+ expect(() => anyBigint.parse("c123")).toThrow();
462
+ expect(() => nullableYo.parse("yo1")).toThrow();
463
+ expect(() => nullableYo.parse("1yo")).toThrow();
464
+ expect(() => nullableYo.parse("null1")).toThrow();
465
+ expect(() => nullableYo.parse("1null")).toThrow();
466
+ expect(() => optionalYeah.parse("yeah1")).toThrow();
467
+ expect(() => optionalYeah.parse("1yeah")).toThrow();
468
+ expect(() => optionalYeah.parse("undefined")).toThrow();
469
+ expect(() => optionalNumber.parse("123a")).toThrow();
470
+ expect(() => optionalNumber.parse("a123")).toThrow();
471
+ // expect(() => optionalNumber.parse("Infinitya")).toThrow();
472
+ // expect(() => optionalNumber.parse("aInfinity")).toThrow();
473
+ expect(() => nullishBruh.parse("bruh1")).toThrow();
474
+ expect(() => nullishBruh.parse("1bruh")).toThrow();
475
+ expect(() => nullishBruh.parse("null1")).toThrow();
476
+ expect(() => nullishBruh.parse("1null")).toThrow();
477
+ expect(() => nullishBruh.parse("undefined")).toThrow();
478
+ expect(() => cuid.parse("bjld2cyuq0000t3rmniod1foy")).toThrow();
479
+ expect(() => cuid.parse("cjld2cyu")).toThrow();
480
+ expect(() => cuid.parse("cjld2 cyu")).toThrow();
481
+ expect(() => cuid.parse("cjld2cyuq0000t3rmniod1foy ")).toThrow();
482
+ expect(() => cuid.parse("1cjld2cyuq0000t3rmniod1foy")).toThrow();
483
+ expect(() => cuidZZZ.parse("cjld2cyuq0000t3rmniod1foy")).toThrow();
484
+ expect(() => cuidZZZ.parse("cjld2cyuq0000t3rmniod1foyZZY")).toThrow();
485
+ expect(() => cuidZZZ.parse("cjld2cyuq0000t3rmniod1foyZZZ1")).toThrow();
486
+ expect(() => cuidZZZ.parse("1cjld2cyuq0000t3rmniod1foyZZZ")).toThrow();
487
+ expect(() => cuid2.parse("A9z4a98xxat96iws9zmbrgj3a")).toThrow();
488
+ expect(() => cuid2.parse("tz4a98xxat96iws9zmbrgj3!")).toThrow();
489
+ expect(() => datetime.parse("2022-01-01 00:00:00")).toThrow();
490
+ expect(() => email.parse("info@example.com@")).toThrow();
491
+ // expect(() => ip.parse("213.174.246:205")).toThrow();
492
+ // expect(() => ip.parse("c359.f57c:21e5:39eb:1187:e501:f936:b452")).toThrow();
493
+ expect(() => ipv4.parse("1213.174.246.205")).toThrow();
494
+ expect(() => ipv4.parse("c359:f57c:21e5:39eb:1187:e501:f936:b452")).toThrow();
495
+ expect(() => ipv6.parse("c359:f57c:21e5:39eb:1187:e501:f936:b4521")).toThrow();
496
+ expect(() => ipv6.parse("213.174.246.205")).toThrow();
497
+ expect(() => ulid.parse("01GW3D2QZJBYB6P1Z1AE997VPW!")).toThrow();
498
+ expect(() => uuid.parse("808989fd-3a6e-4af2-b607-737323a176f6Z")).toThrow();
499
+ expect(() => uuid.parse("Z808989fd-3a6e-4af2-b607-737323a176f6")).toThrow();
500
+ expect(() => stringAToZ.parse("asdasdasd1")).toThrow();
501
+ expect(() => stringAToZ.parse("1asdasdasd")).toThrow();
502
+ expect(() => stringStartsWith.parse("ahello")).toThrow();
503
+ expect(() => stringEndsWith.parse("worlda")).toThrow();
504
+ expect(() => stringMax5.parse("123456")).toThrow();
505
+ expect(() => stringMin5.parse("1234")).toThrow();
506
+ expect(() => stringLen5.parse("123456")).toThrow();
507
+ expect(() => stringLen5.parse("1234")).toThrow();
508
+ expect(() => stringMin5Max10.parse("1234")).toThrow();
509
+ expect(() => stringMin5Max10.parse("12345678901")).toThrow();
510
+
511
+ // the "startswith" overrides the max length
512
+ // expect(() => stringStartsWithMax5.parse("hello1")).toThrow();
513
+ expect(() => stringStartsWithMax5.parse("1hell")).toThrow();
514
+ expect(() => brandedString.parse("")).toThrow();
515
+ });
516
+
517
+ test("regexes", () => {
518
+ expect(empty._zod.pattern.source).toMatchInlineSnapshot(`"^$"`);
519
+ expect(hello._zod.pattern.source).toMatchInlineSnapshot(`"^hello$"`);
520
+ expect(world._zod.pattern.source).toMatchInlineSnapshot(`"^(world)$"`);
521
+ expect(one._zod.pattern.source).toMatchInlineSnapshot(`"^1$"`);
522
+ expect(two._zod.pattern.source).toMatchInlineSnapshot(`"^(2)$"`);
523
+ expect(truee._zod.pattern.source).toMatchInlineSnapshot(`"^true$"`);
524
+ expect(anotherTrue._zod.pattern.source).toMatchInlineSnapshot(`"^(true)$"`);
525
+ expect(falsee._zod.pattern.source).toMatchInlineSnapshot(`"^false$"`);
526
+ expect(anotherFalse._zod.pattern.source).toMatchInlineSnapshot(`"^(false)$"`);
527
+ expect(nulll._zod.pattern.source).toMatchInlineSnapshot(`"^null$"`);
528
+ expect(anotherNull._zod.pattern.source).toMatchInlineSnapshot(`"^null$"`);
529
+ expect(undefinedd._zod.pattern.source).toMatchInlineSnapshot(`"^undefined$"`);
530
+ expect(anotherUndefined._zod.pattern.source).toMatchInlineSnapshot(`"^undefined$"`);
531
+ expect(anyString._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{0,}$"`);
532
+ expect(lazyString._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{0,}$"`);
533
+ expect(anyNumber._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?$"`);
534
+ expect(anyInt._zod.pattern.source).toMatchInlineSnapshot(`"^\\d+$"`);
535
+ // expect(anyFiniteNumber._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?$"`);
536
+ // expect(anyNegativeNumber._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?$"`);
537
+ // expect(anyPositiveNumber._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?$"`);
538
+ // expect(zeroButInADumbWay._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?$"`);
539
+ // expect(finiteButInADumbWay._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?$"`);
540
+ expect(bool._zod.pattern.source).toMatchInlineSnapshot(`"^true|false$"`);
541
+ expect(bigone._zod.pattern.source).toMatchInlineSnapshot(`"^(1)$"`);
542
+ expect(anyBigint._zod.pattern.source).toMatchInlineSnapshot(`"^\\d+n?$"`);
543
+ expect(nullableYo._zod.pattern.source).toMatchInlineSnapshot(`"^((yo)|null)$"`);
544
+ expect(nullableString._zod.pattern.source).toMatchInlineSnapshot(`"^([\\s\\S]{0,}|null)$"`);
545
+ expect(optionalYeah._zod.pattern.source).toMatchInlineSnapshot(`"^((yeah))?$"`);
546
+ expect(optionalString._zod.pattern.source).toMatchInlineSnapshot(`"^([\\s\\S]{0,})?$"`);
547
+ expect(optionalNumber._zod.pattern.source).toMatchInlineSnapshot(`"^(-?\\d+(?:\\.\\d+)?)?$"`);
548
+ expect(nullishBruh._zod.pattern.source).toMatchInlineSnapshot(`"^(((bruh)|null))?$"`);
549
+ expect(nullishString._zod.pattern.source).toMatchInlineSnapshot(`"^(([\\s\\S]{0,}|null))?$"`);
550
+ expect(cuid._zod.pattern.source).toMatchInlineSnapshot(`"^[cC][^\\s-]{8,}$"`);
551
+ expect(cuidZZZ._zod.pattern.source).toMatchInlineSnapshot(`"^[cC][^\\s-]{8,}ZZZ$"`);
552
+ expect(cuid2._zod.pattern.source).toMatchInlineSnapshot(`"^[0-9a-z]+$"`);
553
+ expect(datetime._zod.pattern.source).toMatchInlineSnapshot(
554
+ `"^(?:(?:\\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])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"`
555
+ );
556
+ expect(email._zod.pattern.source).toMatchInlineSnapshot(
557
+ `"^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"`
558
+ );
559
+ // expect(ip._zod.pattern.source).toMatchInlineSnapshot(
560
+ // `"^(^(?:(?: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])$)|(^(([a-fA-F0-9]{1,4}:){7}|::([a-fA-F0-9]{1,4}:){0,6}|([a-fA-F0-9]{1,4}:){1}:([a-fA-F0-9]{1,4}:){0,5}|([a-fA-F0-9]{1,4}:){2}:([a-fA-F0-9]{1,4}:){0,4}|([a-fA-F0-9]{1,4}:){3}:([a-fA-F0-9]{1,4}:){0,3}|([a-fA-F0-9]{1,4}:){4}:([a-fA-F0-9]{1,4}:){0,2}|([a-fA-F0-9]{1,4}:){5}:([a-fA-F0-9]{1,4}:){0,1})([a-fA-F0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$)$"`
561
+ // );
562
+ expect(ipv4._zod.pattern.source).toMatchInlineSnapshot(
563
+ `"^(?:(?: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])$"`
564
+ );
565
+ expect(ipv6._zod.pattern.source).toMatchInlineSnapshot(
566
+ `"^(([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})$"`
567
+ );
568
+ expect(ulid._zod.pattern.source).toMatchInlineSnapshot(`"^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"`);
569
+ expect(uuid._zod.pattern.source).toMatchInlineSnapshot(
570
+ `"^([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)$"`
571
+ );
572
+ expect(stringAToZ._zod.pattern.source).toMatchInlineSnapshot(`"^[a-z]+$"`);
573
+ expect(stringStartsWith._zod.pattern.source).toMatchInlineSnapshot(`"^hello.*$"`);
574
+ expect(stringEndsWith._zod.pattern.source).toMatchInlineSnapshot(`"^.*world$"`);
575
+ expect(stringMax5._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{0,5}$"`);
576
+ expect(stringMin5._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{5,}$"`);
577
+ expect(stringLen5._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{5,5}$"`);
578
+ expect(stringMin5Max10._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{5,10}$"`);
579
+ expect(brandedString._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{1,}$"`);
580
+ expect(url._zod.pattern.source).toMatchInlineSnapshot(`"^https:\\/\\/\\w+\\.(com|net)$"`);
581
+ expect(measurement._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?((px|em|rem|vh|vw|vmin|vmax))?$"`);
582
+ expect(connectionString._zod.pattern.source).toMatchInlineSnapshot(
583
+ `"^mongodb:\\/\\/(\\w+:\\w+@)?\\w+:\\d+(\\/(\\w+)?(\\?(\\w+=\\w+(&\\w+=\\w+)*)?)?)?$"`
584
+ );
585
+ });
586
+
587
+ test("template literal parsing - success - complex cases", () => {
588
+ url.parse("https://example.com");
589
+ url.parse("https://speedtest.net");
590
+
591
+ // measurement.parse(1);
592
+ // measurement.parse(1.1);
593
+ // measurement.parse(0);
594
+ // measurement.parse(-1.1);
595
+ // measurement.parse(-1);
596
+ measurement.parse("1");
597
+ measurement.parse("1.1");
598
+ measurement.parse("0");
599
+ measurement.parse("-1");
600
+ measurement.parse("-1.1");
601
+ measurement.parse("1px");
602
+ measurement.parse("1.1px");
603
+ measurement.parse("0px");
604
+ measurement.parse("-1px");
605
+ measurement.parse("-1.1px");
606
+ measurement.parse("1em");
607
+ measurement.parse("1.1em");
608
+ measurement.parse("0em");
609
+ measurement.parse("-1em");
610
+ measurement.parse("-1.1em");
611
+ measurement.parse("1rem");
612
+ measurement.parse("1.1rem");
613
+ measurement.parse("0rem");
614
+ measurement.parse("-1rem");
615
+ measurement.parse("-1.1rem");
616
+ measurement.parse("1vh");
617
+ measurement.parse("1.1vh");
618
+ measurement.parse("0vh");
619
+ measurement.parse("-1vh");
620
+ measurement.parse("-1.1vh");
621
+ measurement.parse("1vw");
622
+ measurement.parse("1.1vw");
623
+ measurement.parse("0vw");
624
+ measurement.parse("-1vw");
625
+ measurement.parse("-1.1vw");
626
+ measurement.parse("1vmin");
627
+ measurement.parse("1.1vmin");
628
+ measurement.parse("0vmin");
629
+ measurement.parse("-1vmin");
630
+ measurement.parse("-1.1vmin");
631
+ measurement.parse("1vmax");
632
+ measurement.parse("1.1vmax");
633
+ measurement.parse("0vmax");
634
+ measurement.parse("-1vmax");
635
+ measurement.parse("-1.1vmax");
636
+
637
+ connectionString.parse("mongodb://host:1234");
638
+ connectionString.parse("mongodb://host:1234/");
639
+ connectionString.parse("mongodb://host:1234/defaultauthdb");
640
+ connectionString.parse("mongodb://host:1234/defaultauthdb?authSource=admin");
641
+ connectionString.parse("mongodb://host:1234/defaultauthdb?authSource=admin&connectTimeoutMS=300000");
642
+ connectionString.parse("mongodb://host:1234/?authSource=admin");
643
+ connectionString.parse("mongodb://host:1234/?authSource=admin&connectTimeoutMS=300000");
644
+ connectionString.parse("mongodb://username:password@host:1234");
645
+ connectionString.parse("mongodb://username:password@host:1234/");
646
+ connectionString.parse("mongodb://username:password@host:1234/defaultauthdb");
647
+ connectionString.parse("mongodb://username:password@host:1234/defaultauthdb?authSource=admin");
648
+ connectionString.parse(
649
+ "mongodb://username:password@host:1234/defaultauthdb?authSource=admin&connectTimeoutMS=300000"
650
+ );
651
+ connectionString.parse("mongodb://username:password@host:1234/?authSource=admin");
652
+ connectionString.parse("mongodb://username:password@host:1234/?authSource=admin&connectTimeoutMS=300000");
653
+ });
654
+
655
+ test("template literal parsing - failure - complex cases", () => {
656
+ expect(() => url.parse("http://example.com")).toThrow();
657
+ expect(() => url.parse("https://.com")).toThrow();
658
+ expect(() => url.parse("https://examplecom")).toThrow();
659
+ expect(() => url.parse("https://example.org")).toThrow();
660
+ expect(() => url.parse("https://example.net.il")).toThrow();
661
+
662
+ expect(() => measurement.parse("1.1.1")).toThrow();
663
+ expect(() => measurement.parse("Infinity")).toThrow();
664
+ expect(() => measurement.parse("-Infinity")).toThrow();
665
+ expect(() => measurement.parse("NaN")).toThrow();
666
+ expect(() => measurement.parse("1%")).toThrow();
667
+
668
+ expect(() => connectionString.parse("mongod://host:1234")).toThrow();
669
+ expect(() => connectionString.parse("mongodb://:1234")).toThrow();
670
+ expect(() => connectionString.parse("mongodb://host1234")).toThrow();
671
+ expect(() => connectionString.parse("mongodb://host:d234")).toThrow();
672
+ expect(() => connectionString.parse("mongodb://host:12.34")).toThrow();
673
+ expect(() => connectionString.parse("mongodb://host:-1234")).toThrow();
674
+ expect(() => connectionString.parse("mongodb://host:-12.34")).toThrow();
675
+ expect(() => connectionString.parse("mongodb://host:")).toThrow();
676
+ expect(() => connectionString.parse("mongodb://:password@host:1234")).toThrow();
677
+ expect(() => connectionString.parse("mongodb://usernamepassword@host:1234")).toThrow();
678
+ expect(() => connectionString.parse("mongodb://username:@host:1234")).toThrow();
679
+ expect(() => connectionString.parse("mongodb://@host:1234")).toThrow();
680
+ expect(() => connectionString.parse("mongodb://host:1234/defaultauthdb?authSourceadmin")).toThrow();
681
+ expect(() => connectionString.parse("mongodb://host:1234/?authSourceadmin")).toThrow();
682
+ expect(() => connectionString.parse("mongodb://host:1234/defaultauthdb?&authSource=admin")).toThrow();
683
+ expect(() => connectionString.parse("mongodb://host:1234/?&authSource=admin")).toThrow();
684
+ });
685
+
686
+ test("template literal parsing - failure - issue format", () => {
687
+ expect(anotherNull.safeParse("1null")).toMatchInlineSnapshot(`
688
+ {
689
+ "error": [ZodError: [
690
+ {
691
+ "code": "invalid_format",
692
+ "format": "template_literal",
693
+ "pattern": "^null$",
694
+ "path": [],
695
+ "message": "Invalid input"
696
+ }
697
+ ]],
698
+ "success": false,
699
+ }
700
+ `);
701
+ expect(cuidZZZ.safeParse("1cjld2cyuq0000t3rmniod1foyZZZ")).toMatchInlineSnapshot(`
702
+ {
703
+ "error": [ZodError: [
704
+ {
705
+ "code": "invalid_format",
706
+ "format": "template_literal",
707
+ "pattern": "^[cC][^\\\\s-]{8,}ZZZ$",
708
+ "path": [],
709
+ "message": "Invalid input"
710
+ }
711
+ ]],
712
+ "success": false,
713
+ }
714
+ `);
715
+ expect(stringMin5Max10.safeParse("1234")).toMatchInlineSnapshot(`
716
+ {
717
+ "error": [ZodError: [
718
+ {
719
+ "code": "invalid_format",
720
+ "format": "template_literal",
721
+ "pattern": "^[\\\\s\\\\S]{5,10}$",
722
+ "path": [],
723
+ "message": "Invalid input"
724
+ }
725
+ ]],
726
+ "success": false,
727
+ }
728
+ `);
729
+ expect(connectionString.safeParse("mongodb://host:1234/defaultauthdb?authSourceadmin")).toMatchInlineSnapshot(`
730
+ {
731
+ "error": [ZodError: [
732
+ {
733
+ "code": "invalid_format",
734
+ "format": "template_literal",
735
+ "pattern": "^mongodb:\\\\/\\\\/(\\\\w+:\\\\w+@)?\\\\w+:\\\\d+(\\\\/(\\\\w+)?(\\\\?(\\\\w+=\\\\w+(&\\\\w+=\\\\w+)*)?)?)?$",
736
+ "path": [],
737
+ "message": "Invalid input"
738
+ }
739
+ ]],
740
+ "success": false,
741
+ }
742
+ `);
743
+
744
+ expect(stringStartsWithMax5.safeParse("1hell")).toMatchInlineSnapshot(`
745
+ {
746
+ "error": [ZodError: [
747
+ {
748
+ "code": "invalid_format",
749
+ "format": "template_literal",
750
+ "pattern": "^hello.*$",
751
+ "path": [],
752
+ "message": "Invalid input"
753
+ }
754
+ ]],
755
+ "success": false,
756
+ }
757
+ `);
758
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts ADDED
@@ -0,0 +1,2314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { describe, expect, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+ // import * as zCore from "zod/v4/core";
4
+
5
+ describe("toJSONSchema", () => {
6
+ test("primitive types", () => {
7
+ expect(z.toJSONSchema(z.string())).toMatchInlineSnapshot(`
8
+ {
9
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
10
+ "type": "string",
11
+ }
12
+ `);
13
+ expect(z.toJSONSchema(z.number())).toMatchInlineSnapshot(`
14
+ {
15
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
16
+ "type": "number",
17
+ }
18
+ `);
19
+ expect(z.toJSONSchema(z.boolean())).toMatchInlineSnapshot(`
20
+ {
21
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
22
+ "type": "boolean",
23
+ }
24
+ `);
25
+ expect(z.toJSONSchema(z.null())).toMatchInlineSnapshot(`
26
+ {
27
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
28
+ "type": "null",
29
+ }
30
+ `);
31
+ expect(z.toJSONSchema(z.undefined(), { unrepresentable: "any" })).toMatchInlineSnapshot(`
32
+ {
33
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
34
+ }
35
+ `);
36
+ expect(z.toJSONSchema(z.any())).toMatchInlineSnapshot(`
37
+ {
38
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
39
+ }
40
+ `);
41
+ expect(z.toJSONSchema(z.unknown())).toMatchInlineSnapshot(`
42
+ {
43
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
44
+ }
45
+ `);
46
+ expect(z.toJSONSchema(z.never())).toMatchInlineSnapshot(`
47
+ {
48
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
49
+ "not": {},
50
+ }
51
+ `);
52
+ expect(z.toJSONSchema(z.email())).toMatchInlineSnapshot(`
53
+ {
54
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
55
+ "format": "email",
56
+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
57
+ "type": "string",
58
+ }
59
+ `);
60
+ expect(z.toJSONSchema(z.iso.datetime())).toMatchInlineSnapshot(`
61
+ {
62
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
63
+ "format": "date-time",
64
+ "pattern": "^(?:(?:\\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])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
65
+ "type": "string",
66
+ }
67
+ `);
68
+ expect(z.toJSONSchema(z.iso.date())).toMatchInlineSnapshot(`
69
+ {
70
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
71
+ "format": "date",
72
+ "pattern": "^(?:(?:\\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])))$",
73
+ "type": "string",
74
+ }
75
+ `);
76
+ expect(z.toJSONSchema(z.iso.time())).toMatchInlineSnapshot(`
77
+ {
78
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
79
+ "format": "time",
80
+ "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$",
81
+ "type": "string",
82
+ }
83
+ `);
84
+ expect(z.toJSONSchema(z.iso.duration())).toMatchInlineSnapshot(`
85
+ {
86
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
87
+ "format": "duration",
88
+ "pattern": "^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$",
89
+ "type": "string",
90
+ }
91
+ `);
92
+ expect(z.toJSONSchema(z.ipv4())).toMatchInlineSnapshot(`
93
+ {
94
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
95
+ "format": "ipv4",
96
+ "pattern": "^(?:(?: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])$",
97
+ "type": "string",
98
+ }
99
+ `);
100
+ expect(z.toJSONSchema(z.ipv6())).toMatchInlineSnapshot(`
101
+ {
102
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
103
+ "format": "ipv6",
104
+ "pattern": "^(([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})$",
105
+ "type": "string",
106
+ }
107
+ `);
108
+ expect(z.toJSONSchema(z.uuid())).toMatchInlineSnapshot(`
109
+ {
110
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
111
+ "format": "uuid",
112
+ "pattern": "^([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)$",
113
+ "type": "string",
114
+ }
115
+ `);
116
+ expect(z.toJSONSchema(z.guid())).toMatchInlineSnapshot(`
117
+ {
118
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
119
+ "format": "uuid",
120
+ "pattern": "^([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})$",
121
+ "type": "string",
122
+ }
123
+ `);
124
+ expect(z.toJSONSchema(z.url())).toMatchInlineSnapshot(`
125
+ {
126
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
127
+ "format": "uri",
128
+ "type": "string",
129
+ }
130
+ `);
131
+ expect(z.toJSONSchema(z.base64())).toMatchInlineSnapshot(`
132
+ {
133
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
134
+ "contentEncoding": "base64",
135
+ "format": "base64",
136
+ "pattern": "^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$",
137
+ "type": "string",
138
+ }
139
+ `);
140
+ expect(z.toJSONSchema(z.cuid())).toMatchInlineSnapshot(`
141
+ {
142
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
143
+ "format": "cuid",
144
+ "pattern": "^[cC][^\\s-]{8,}$",
145
+ "type": "string",
146
+ }
147
+ `);
148
+ // expect(z.toJSONSchema(z.regex(/asdf/))).toMatchInlineSnapshot();
149
+ expect(z.toJSONSchema(z.emoji())).toMatchInlineSnapshot(`
150
+ {
151
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
152
+ "format": "emoji",
153
+ "pattern": "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",
154
+ "type": "string",
155
+ }
156
+ `);
157
+ expect(z.toJSONSchema(z.nanoid())).toMatchInlineSnapshot(`
158
+ {
159
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
160
+ "format": "nanoid",
161
+ "pattern": "^[a-zA-Z0-9_-]{21}$",
162
+ "type": "string",
163
+ }
164
+ `);
165
+ expect(z.toJSONSchema(z.cuid2())).toMatchInlineSnapshot(`
166
+ {
167
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
168
+ "format": "cuid2",
169
+ "pattern": "^[0-9a-z]+$",
170
+ "type": "string",
171
+ }
172
+ `);
173
+ expect(z.toJSONSchema(z.ulid())).toMatchInlineSnapshot(`
174
+ {
175
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
176
+ "format": "ulid",
177
+ "pattern": "^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$",
178
+ "type": "string",
179
+ }
180
+ `);
181
+ // expect(z.toJSONSchema(z.cidr())).toMatchInlineSnapshot();
182
+ expect(z.toJSONSchema(z.number())).toMatchInlineSnapshot(`
183
+ {
184
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
185
+ "type": "number",
186
+ }
187
+ `);
188
+ expect(z.toJSONSchema(z.int())).toMatchInlineSnapshot(`
189
+ {
190
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
191
+ "maximum": 9007199254740991,
192
+ "minimum": -9007199254740991,
193
+ "type": "integer",
194
+ }
195
+ `);
196
+ expect(z.toJSONSchema(z.int32())).toMatchInlineSnapshot(`
197
+ {
198
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
199
+ "maximum": 2147483647,
200
+ "minimum": -2147483648,
201
+ "type": "integer",
202
+ }
203
+ `);
204
+ expect(z.toJSONSchema(z.float32())).toMatchInlineSnapshot(`
205
+ {
206
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
207
+ "maximum": 3.4028234663852886e+38,
208
+ "minimum": -3.4028234663852886e+38,
209
+ "type": "number",
210
+ }
211
+ `);
212
+ expect(z.toJSONSchema(z.float64())).toMatchInlineSnapshot(`
213
+ {
214
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
215
+ "maximum": 1.7976931348623157e+308,
216
+ "minimum": -1.7976931348623157e+308,
217
+ "type": "number",
218
+ }
219
+ `);
220
+ expect(z.toJSONSchema(z.jwt())).toMatchInlineSnapshot(`
221
+ {
222
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
223
+ "format": "jwt",
224
+ "type": "string",
225
+ }
226
+ `);
227
+ });
228
+
229
+ test("unsupported schema types", () => {
230
+ expect(() => z.toJSONSchema(z.bigint())).toThrow("BigInt cannot be represented in JSON Schema");
231
+ expect(() => z.toJSONSchema(z.int64())).toThrow("BigInt cannot be represented in JSON Schema");
232
+ expect(() => z.toJSONSchema(z.symbol())).toThrow("Symbols cannot be represented in JSON Schema");
233
+ expect(() => z.toJSONSchema(z.void())).toThrow("Void cannot be represented in JSON Schema");
234
+ expect(() => z.toJSONSchema(z.undefined())).toThrow("Undefined cannot be represented in JSON Schema");
235
+ expect(() => z.toJSONSchema(z.date())).toThrow("Date cannot be represented in JSON Schema");
236
+ expect(() => z.toJSONSchema(z.map(z.string(), z.number()))).toThrow("Map cannot be represented in JSON Schema");
237
+ expect(() => z.toJSONSchema(z.set(z.string()))).toThrow("Set cannot be represented in JSON Schema");
238
+ expect(() => z.toJSONSchema(z.custom(() => true))).toThrow("Custom types cannot be represented in JSON Schema");
239
+
240
+ // Transform
241
+ const transformSchema = z.string().transform((val) => Number.parseInt(val));
242
+ expect(() => z.toJSONSchema(transformSchema)).toThrow("Transforms cannot be represented in JSON Schema");
243
+
244
+ // Static catch values
245
+ const staticCatchSchema = z.string().catch(() => "sup");
246
+ expect(z.toJSONSchema(staticCatchSchema)).toMatchInlineSnapshot(`
247
+ {
248
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
249
+ "default": "sup",
250
+ "type": "string",
251
+ }
252
+ `);
253
+
254
+ // Dynamic catch values
255
+ const dynamicCatchSchema = z.string().catch((ctx) => `${ctx.issues.length}`);
256
+ expect(() => z.toJSONSchema(dynamicCatchSchema)).toThrow("Dynamic catch values are not supported in JSON Schema");
257
+ });
258
+
259
+ test("string formats", () => {
260
+ expect(z.toJSONSchema(z.string().email())).toMatchInlineSnapshot(`
261
+ {
262
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
263
+ "format": "email",
264
+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
265
+ "type": "string",
266
+ }
267
+ `);
268
+ expect(z.toJSONSchema(z.string().uuid())).toMatchInlineSnapshot(`
269
+ {
270
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
271
+ "format": "uuid",
272
+ "pattern": "^([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)$",
273
+ "type": "string",
274
+ }
275
+ `);
276
+ expect(z.toJSONSchema(z.iso.datetime())).toMatchInlineSnapshot(`
277
+ {
278
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
279
+ "format": "date-time",
280
+ "pattern": "^(?:(?:\\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])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
281
+ "type": "string",
282
+ }
283
+ `);
284
+
285
+ expect(z.toJSONSchema(z.iso.date())).toMatchInlineSnapshot(`
286
+ {
287
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
288
+ "format": "date",
289
+ "pattern": "^(?:(?:\\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])))$",
290
+ "type": "string",
291
+ }
292
+ `);
293
+ expect(z.toJSONSchema(z.iso.time())).toMatchInlineSnapshot(`
294
+ {
295
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
296
+ "format": "time",
297
+ "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$",
298
+ "type": "string",
299
+ }
300
+ `);
301
+ expect(z.toJSONSchema(z.iso.duration())).toMatchInlineSnapshot(`
302
+ {
303
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
304
+ "format": "duration",
305
+ "pattern": "^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$",
306
+ "type": "string",
307
+ }
308
+ `);
309
+ // expect(z.toJSONSchema(z.string().ip())).toMatchInlineSnapshot(`
310
+ // {
311
+ // "pattern": /\\(\\^\\(\\?:\\(\\?: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\\]\\)\\$\\)\\|\\(\\^\\(\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{7\\}\\|::\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,6\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{1\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,5\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{2\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,4\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{3\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,3\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{4\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,2\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{5\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,1\\}\\)\\(\\[a-fA-F0-9\\]\\{1,4\\}\\|\\(\\(\\(25\\[0-5\\]\\)\\|\\(2\\[0-4\\]\\[0-9\\]\\)\\|\\(1\\[0-9\\]\\{2\\}\\)\\|\\(\\[0-9\\]\\{1,2\\}\\)\\)\\\\\\.\\)\\{3\\}\\(\\(25\\[0-5\\]\\)\\|\\(2\\[0-4\\]\\[0-9\\]\\)\\|\\(1\\[0-9\\]\\{2\\}\\)\\|\\(\\[0-9\\]\\{1,2\\}\\)\\)\\)\\$\\)/,
312
+ // "type": "string",
313
+ // }
314
+ // `);
315
+ expect(z.toJSONSchema(z.ipv4())).toMatchInlineSnapshot(`
316
+ {
317
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
318
+ "format": "ipv4",
319
+ "pattern": "^(?:(?: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])$",
320
+ "type": "string",
321
+ }
322
+ `);
323
+
324
+ expect(z.toJSONSchema(z.ipv6())).toMatchInlineSnapshot(`
325
+ {
326
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
327
+ "format": "ipv6",
328
+ "pattern": "^(([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})$",
329
+ "type": "string",
330
+ }
331
+ `);
332
+
333
+ expect(z.toJSONSchema(z.base64())).toMatchInlineSnapshot(`
334
+ {
335
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
336
+ "contentEncoding": "base64",
337
+ "format": "base64",
338
+ "pattern": "^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$",
339
+ "type": "string",
340
+ }
341
+ `);
342
+ expect(z.toJSONSchema(z.url())).toMatchInlineSnapshot(`
343
+ {
344
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
345
+ "format": "uri",
346
+ "type": "string",
347
+ }
348
+ `);
349
+ expect(z.toJSONSchema(z.guid())).toMatchInlineSnapshot(`
350
+ {
351
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
352
+ "format": "uuid",
353
+ "pattern": "^([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})$",
354
+ "type": "string",
355
+ }
356
+ `);
357
+ expect(z.toJSONSchema(z.string().regex(/asdf/))).toMatchInlineSnapshot(`
358
+ {
359
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
360
+ "pattern": "asdf",
361
+ "type": "string",
362
+ }
363
+ `);
364
+ });
365
+
366
+ test("string patterns", () => {
367
+ expect(
368
+ z.toJSONSchema(
369
+ z
370
+ .string()
371
+ .startsWith("hello")
372
+ .includes("cruel")
373
+ .includes("dark", { position: 10 })
374
+ .endsWith("world")
375
+ .regex(/stuff/)
376
+ )
377
+ ).toMatchInlineSnapshot(`
378
+ {
379
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
380
+ "allOf": [
381
+ {
382
+ "pattern": "^hello.*",
383
+ },
384
+ {
385
+ "pattern": "cruel",
386
+ },
387
+ {
388
+ "pattern": "^.{10}dark",
389
+ },
390
+ {
391
+ "pattern": ".*world$",
392
+ },
393
+ {
394
+ "pattern": "stuff",
395
+ },
396
+ ],
397
+ "type": "string",
398
+ }
399
+ `);
400
+
401
+ expect(
402
+ z.toJSONSchema(
403
+ z
404
+ .string()
405
+ .startsWith("hello")
406
+ .includes("cruel")
407
+ .includes("dark", { position: 10 })
408
+ .endsWith("world")
409
+ .regex(/stuff/),
410
+ {
411
+ target: "draft-7",
412
+ }
413
+ )
414
+ ).toMatchInlineSnapshot(`
415
+ {
416
+ "$schema": "http://json-schema.org/draft-07/schema#",
417
+ "allOf": [
418
+ {
419
+ "pattern": "^hello.*",
420
+ "type": "string",
421
+ },
422
+ {
423
+ "pattern": "cruel",
424
+ "type": "string",
425
+ },
426
+ {
427
+ "pattern": "^.{10}dark",
428
+ "type": "string",
429
+ },
430
+ {
431
+ "pattern": ".*world$",
432
+ "type": "string",
433
+ },
434
+ {
435
+ "pattern": "stuff",
436
+ "type": "string",
437
+ },
438
+ ],
439
+ "type": "string",
440
+ }
441
+ `);
442
+ });
443
+
444
+ test("number constraints", () => {
445
+ expect(z.toJSONSchema(z.number().min(5).max(10))).toMatchInlineSnapshot(
446
+ `
447
+ {
448
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
449
+ "maximum": 10,
450
+ "minimum": 5,
451
+ "type": "number",
452
+ }
453
+ `
454
+ );
455
+
456
+ expect(z.toJSONSchema(z.number().gt(5).gt(10))).toMatchInlineSnapshot(`
457
+ {
458
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
459
+ "exclusiveMinimum": 10,
460
+ "type": "number",
461
+ }
462
+ `);
463
+
464
+ expect(z.toJSONSchema(z.number().gt(5).gte(10))).toMatchInlineSnapshot(`
465
+ {
466
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
467
+ "minimum": 10,
468
+ "type": "number",
469
+ }
470
+ `);
471
+
472
+ expect(z.toJSONSchema(z.number().lt(5).lt(3))).toMatchInlineSnapshot(`
473
+ {
474
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
475
+ "exclusiveMaximum": 3,
476
+ "type": "number",
477
+ }
478
+ `);
479
+
480
+ expect(z.toJSONSchema(z.number().lt(5).lt(3).lte(2))).toMatchInlineSnapshot(`
481
+ {
482
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
483
+ "maximum": 2,
484
+ "type": "number",
485
+ }
486
+ `);
487
+
488
+ expect(z.toJSONSchema(z.number().lt(5).lte(3))).toMatchInlineSnapshot(`
489
+ {
490
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
491
+ "maximum": 3,
492
+ "type": "number",
493
+ }
494
+ `);
495
+
496
+ expect(z.toJSONSchema(z.number().gt(5).lt(10))).toMatchInlineSnapshot(`
497
+ {
498
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
499
+ "exclusiveMaximum": 10,
500
+ "exclusiveMinimum": 5,
501
+ "type": "number",
502
+ }
503
+ `);
504
+ expect(z.toJSONSchema(z.number().gte(5).lte(10))).toMatchInlineSnapshot(`
505
+ {
506
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
507
+ "maximum": 10,
508
+ "minimum": 5,
509
+ "type": "number",
510
+ }
511
+ `);
512
+ expect(z.toJSONSchema(z.number().positive())).toMatchInlineSnapshot(`
513
+ {
514
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
515
+ "exclusiveMinimum": 0,
516
+ "type": "number",
517
+ }
518
+ `);
519
+ expect(z.toJSONSchema(z.number().negative())).toMatchInlineSnapshot(`
520
+ {
521
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
522
+ "exclusiveMaximum": 0,
523
+ "type": "number",
524
+ }
525
+ `);
526
+ expect(z.toJSONSchema(z.number().nonpositive())).toMatchInlineSnapshot(`
527
+ {
528
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
529
+ "maximum": 0,
530
+ "type": "number",
531
+ }
532
+ `);
533
+ expect(z.toJSONSchema(z.number().nonnegative())).toMatchInlineSnapshot(`
534
+ {
535
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
536
+ "minimum": 0,
537
+ "type": "number",
538
+ }
539
+ `);
540
+ });
541
+
542
+ test("arrays", () => {
543
+ expect(z.toJSONSchema(z.array(z.string()))).toMatchInlineSnapshot(`
544
+ {
545
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
546
+ "items": {
547
+ "type": "string",
548
+ },
549
+ "type": "array",
550
+ }
551
+ `);
552
+ });
553
+
554
+ test("unions", () => {
555
+ const schema = z.union([z.string(), z.number()]);
556
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
557
+ {
558
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
559
+ "anyOf": [
560
+ {
561
+ "type": "string",
562
+ },
563
+ {
564
+ "type": "number",
565
+ },
566
+ ],
567
+ }
568
+ `);
569
+ });
570
+
571
+ test("intersections", () => {
572
+ const schema = z.intersection(z.object({ name: z.string() }), z.object({ age: z.number() }));
573
+
574
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
575
+ {
576
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
577
+ "allOf": [
578
+ {
579
+ "additionalProperties": false,
580
+ "properties": {
581
+ "name": {
582
+ "type": "string",
583
+ },
584
+ },
585
+ "required": [
586
+ "name",
587
+ ],
588
+ "type": "object",
589
+ },
590
+ {
591
+ "additionalProperties": false,
592
+ "properties": {
593
+ "age": {
594
+ "type": "number",
595
+ },
596
+ },
597
+ "required": [
598
+ "age",
599
+ ],
600
+ "type": "object",
601
+ },
602
+ ],
603
+ }
604
+ `);
605
+ });
606
+
607
+ test("record", () => {
608
+ const schema = z.record(z.string(), z.boolean());
609
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
610
+ {
611
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
612
+ "additionalProperties": {
613
+ "type": "boolean",
614
+ },
615
+ "propertyNames": {
616
+ "type": "string",
617
+ },
618
+ "type": "object",
619
+ }
620
+ `);
621
+ });
622
+
623
+ test("tuple", () => {
624
+ const schema = z.tuple([z.string(), z.number()]).rest(z.boolean());
625
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
626
+ {
627
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
628
+ "items": {
629
+ "type": "boolean",
630
+ },
631
+ "prefixItems": [
632
+ {
633
+ "type": "string",
634
+ },
635
+ {
636
+ "type": "number",
637
+ },
638
+ ],
639
+ "type": "array",
640
+ }
641
+ `);
642
+ });
643
+
644
+ test("promise", () => {
645
+ const schema = z.promise(z.string());
646
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
647
+ {
648
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
649
+ "type": "string",
650
+ }
651
+ `);
652
+ });
653
+
654
+ test("lazy", () => {
655
+ const schema = z.lazy(() => z.string());
656
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
657
+ {
658
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
659
+ "type": "string",
660
+ }
661
+ `);
662
+ });
663
+
664
+ // enum
665
+ test("enum", () => {
666
+ const a = z.enum(["a", "b", "c"]);
667
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
668
+ {
669
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
670
+ "enum": [
671
+ "a",
672
+ "b",
673
+ "c",
674
+ ],
675
+ "type": "string",
676
+ }
677
+ `);
678
+
679
+ enum B {
680
+ A = 0,
681
+ B = 1,
682
+ C = 2,
683
+ }
684
+
685
+ const b = z.enum(B);
686
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
687
+ {
688
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
689
+ "enum": [
690
+ 0,
691
+ 1,
692
+ 2,
693
+ ],
694
+ "type": "number",
695
+ }
696
+ `);
697
+ });
698
+
699
+ // literal
700
+ test("literal", () => {
701
+ const a = z.literal("hello");
702
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
703
+ {
704
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
705
+ "const": "hello",
706
+ "type": "string",
707
+ }
708
+ `);
709
+
710
+ const b = z.literal(7);
711
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
712
+ {
713
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
714
+ "const": 7,
715
+ "type": "number",
716
+ }
717
+ `);
718
+
719
+ const c = z.literal(["hello", undefined, null, 5, BigInt(1324)]);
720
+ expect(() => z.toJSONSchema(c)).toThrow();
721
+
722
+ const d = z.literal(["hello", null, 5]);
723
+ expect(z.toJSONSchema(d)).toMatchInlineSnapshot(`
724
+ {
725
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
726
+ "enum": [
727
+ "hello",
728
+ null,
729
+ 5,
730
+ ],
731
+ }
732
+ `);
733
+
734
+ const e = z.literal(["hello", "zod", "v4"]);
735
+ expect(z.toJSONSchema(e)).toMatchInlineSnapshot(`
736
+ {
737
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
738
+ "enum": [
739
+ "hello",
740
+ "zod",
741
+ "v4",
742
+ ],
743
+ "type": "string",
744
+ }
745
+ `);
746
+ });
747
+
748
+ // pipe
749
+ test("pipe", () => {
750
+ const schema = z
751
+ .string()
752
+ .transform((val) => Number.parseInt(val))
753
+ .pipe(z.number());
754
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
755
+ {
756
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
757
+ "type": "number",
758
+ }
759
+ `);
760
+ });
761
+
762
+ test("simple objects", () => {
763
+ const schema = z.object({
764
+ name: z.string(),
765
+ age: z.number(),
766
+ });
767
+
768
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(
769
+ `
770
+ {
771
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
772
+ "additionalProperties": false,
773
+ "properties": {
774
+ "age": {
775
+ "type": "number",
776
+ },
777
+ "name": {
778
+ "type": "string",
779
+ },
780
+ },
781
+ "required": [
782
+ "name",
783
+ "age",
784
+ ],
785
+ "type": "object",
786
+ }
787
+ `
788
+ );
789
+ });
790
+
791
+ test("additionalproperties in z.object", () => {
792
+ const a = z.object({
793
+ name: z.string(),
794
+ });
795
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
796
+ {
797
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
798
+ "additionalProperties": false,
799
+ "properties": {
800
+ "name": {
801
+ "type": "string",
802
+ },
803
+ },
804
+ "required": [
805
+ "name",
806
+ ],
807
+ "type": "object",
808
+ }
809
+ `);
810
+ expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
811
+ {
812
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
813
+ "properties": {
814
+ "name": {
815
+ "type": "string",
816
+ },
817
+ },
818
+ "required": [
819
+ "name",
820
+ ],
821
+ "type": "object",
822
+ }
823
+ `);
824
+ expect(
825
+ z.toJSONSchema(a, {
826
+ io: "input",
827
+ override(ctx) {
828
+ const def = ctx.zodSchema._zod.def;
829
+ if (def.type === "object" && !def.catchall) {
830
+ (ctx.jsonSchema as z.core.JSONSchema.ObjectSchema).additionalProperties = false;
831
+ }
832
+ },
833
+ })
834
+ ).toMatchInlineSnapshot(`
835
+ {
836
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
837
+ "additionalProperties": false,
838
+ "properties": {
839
+ "name": {
840
+ "type": "string",
841
+ },
842
+ },
843
+ "required": [
844
+ "name",
845
+ ],
846
+ "type": "object",
847
+ }
848
+ `);
849
+ });
850
+
851
+ test("catchall objects", () => {
852
+ const a = z.strictObject({
853
+ name: z.string(),
854
+ age: z.number(),
855
+ });
856
+
857
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
858
+ {
859
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
860
+ "additionalProperties": false,
861
+ "properties": {
862
+ "age": {
863
+ "type": "number",
864
+ },
865
+ "name": {
866
+ "type": "string",
867
+ },
868
+ },
869
+ "required": [
870
+ "name",
871
+ "age",
872
+ ],
873
+ "type": "object",
874
+ }
875
+ `);
876
+
877
+ const b = z
878
+ .object({
879
+ name: z.string(),
880
+ })
881
+ .catchall(z.string());
882
+
883
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
884
+ {
885
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
886
+ "additionalProperties": {
887
+ "type": "string",
888
+ },
889
+ "properties": {
890
+ "name": {
891
+ "type": "string",
892
+ },
893
+ },
894
+ "required": [
895
+ "name",
896
+ ],
897
+ "type": "object",
898
+ }
899
+ `);
900
+
901
+ const c = z.looseObject({
902
+ name: z.string(),
903
+ });
904
+
905
+ expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
906
+ {
907
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
908
+ "additionalProperties": {},
909
+ "properties": {
910
+ "name": {
911
+ "type": "string",
912
+ },
913
+ },
914
+ "required": [
915
+ "name",
916
+ ],
917
+ "type": "object",
918
+ }
919
+ `);
920
+ });
921
+
922
+ test("optional fields - object", () => {
923
+ const schema = z.object({
924
+ required: z.string(),
925
+ optional: z.string().optional(),
926
+ nonoptional: z.string().optional().nonoptional(),
927
+ });
928
+
929
+ const result = z.toJSONSchema(schema);
930
+
931
+ expect(result).toMatchInlineSnapshot(`
932
+ {
933
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
934
+ "additionalProperties": false,
935
+ "properties": {
936
+ "nonoptional": {
937
+ "type": "string",
938
+ },
939
+ "optional": {
940
+ "type": "string",
941
+ },
942
+ "required": {
943
+ "type": "string",
944
+ },
945
+ },
946
+ "required": [
947
+ "required",
948
+ "nonoptional",
949
+ ],
950
+ "type": "object",
951
+ }
952
+ `);
953
+ });
954
+
955
+ test("recursive object", () => {
956
+ interface Category {
957
+ name: string;
958
+ subcategories: Category[];
959
+ }
960
+
961
+ const categorySchema: z.ZodType<Category> = z.object({
962
+ name: z.string(),
963
+ subcategories: z.array(z.lazy(() => categorySchema)),
964
+ });
965
+
966
+ const result = z.toJSONSchema(categorySchema);
967
+ expect(result).toMatchInlineSnapshot(`
968
+ {
969
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
970
+ "additionalProperties": false,
971
+ "properties": {
972
+ "name": {
973
+ "type": "string",
974
+ },
975
+ "subcategories": {
976
+ "items": {
977
+ "$ref": "#",
978
+ },
979
+ "type": "array",
980
+ },
981
+ },
982
+ "required": [
983
+ "name",
984
+ "subcategories",
985
+ ],
986
+ "type": "object",
987
+ }
988
+ `);
989
+ });
990
+
991
+ test("simple interface", () => {
992
+ const userSchema = z.object({
993
+ name: z.string(),
994
+ age: z.number().optional(),
995
+ });
996
+
997
+ const result = z.toJSONSchema(userSchema);
998
+ expect(result).toMatchInlineSnapshot(`
999
+ {
1000
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1001
+ "additionalProperties": false,
1002
+ "properties": {
1003
+ "age": {
1004
+ "type": "number",
1005
+ },
1006
+ "name": {
1007
+ "type": "string",
1008
+ },
1009
+ },
1010
+ "required": [
1011
+ "name",
1012
+ ],
1013
+ "type": "object",
1014
+ }
1015
+ `);
1016
+ });
1017
+
1018
+ test("catchall interface", () => {
1019
+ const a = z.strictObject({
1020
+ name: z.string(),
1021
+ age: z.number(),
1022
+ });
1023
+
1024
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
1025
+ {
1026
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1027
+ "additionalProperties": false,
1028
+ "properties": {
1029
+ "age": {
1030
+ "type": "number",
1031
+ },
1032
+ "name": {
1033
+ "type": "string",
1034
+ },
1035
+ },
1036
+ "required": [
1037
+ "name",
1038
+ "age",
1039
+ ],
1040
+ "type": "object",
1041
+ }
1042
+ `);
1043
+
1044
+ const b = z
1045
+ .object({
1046
+ name: z.string(),
1047
+ })
1048
+ .catchall(z.string());
1049
+
1050
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
1051
+ {
1052
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1053
+ "additionalProperties": {
1054
+ "type": "string",
1055
+ },
1056
+ "properties": {
1057
+ "name": {
1058
+ "type": "string",
1059
+ },
1060
+ },
1061
+ "required": [
1062
+ "name",
1063
+ ],
1064
+ "type": "object",
1065
+ }
1066
+ `);
1067
+
1068
+ const c = z.looseObject({
1069
+ name: z.string(),
1070
+ });
1071
+
1072
+ expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
1073
+ {
1074
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1075
+ "additionalProperties": {},
1076
+ "properties": {
1077
+ "name": {
1078
+ "type": "string",
1079
+ },
1080
+ },
1081
+ "required": [
1082
+ "name",
1083
+ ],
1084
+ "type": "object",
1085
+ }
1086
+ `);
1087
+ });
1088
+
1089
+ test("recursive interface schemas", () => {
1090
+ const TreeNodeSchema = z.object({
1091
+ id: z.string(),
1092
+ get children() {
1093
+ return TreeNodeSchema;
1094
+ },
1095
+ });
1096
+
1097
+ const result = z.toJSONSchema(TreeNodeSchema);
1098
+
1099
+ // Should have definitions for recursive schema
1100
+ expect(JSON.stringify(result, null, 2)).toMatchInlineSnapshot(
1101
+ `
1102
+ "{
1103
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1104
+ "type": "object",
1105
+ "properties": {
1106
+ "id": {
1107
+ "type": "string"
1108
+ },
1109
+ "children": {
1110
+ "$ref": "#"
1111
+ }
1112
+ },
1113
+ "required": [
1114
+ "id",
1115
+ "children"
1116
+ ],
1117
+ "additionalProperties": false
1118
+ }"
1119
+ `
1120
+ );
1121
+ });
1122
+
1123
+ test("mutually recursive interface schemas", () => {
1124
+ const FolderSchema = z.object({
1125
+ name: z.string(),
1126
+ get files() {
1127
+ return z.array(FileSchema);
1128
+ },
1129
+ });
1130
+
1131
+ const FileSchema = z.object({
1132
+ name: z.string(),
1133
+ get parent() {
1134
+ return FolderSchema;
1135
+ },
1136
+ });
1137
+
1138
+ const result = z.toJSONSchema(FolderSchema);
1139
+
1140
+ // Should have definitions for both schemas
1141
+ expect(JSON.stringify(result, null, 2)).toMatchInlineSnapshot(
1142
+ `
1143
+ "{
1144
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1145
+ "type": "object",
1146
+ "properties": {
1147
+ "name": {
1148
+ "type": "string"
1149
+ },
1150
+ "files": {
1151
+ "type": "array",
1152
+ "items": {
1153
+ "type": "object",
1154
+ "properties": {
1155
+ "name": {
1156
+ "type": "string"
1157
+ },
1158
+ "parent": {
1159
+ "$ref": "#"
1160
+ }
1161
+ },
1162
+ "required": [
1163
+ "name",
1164
+ "parent"
1165
+ ],
1166
+ "additionalProperties": false
1167
+ }
1168
+ }
1169
+ },
1170
+ "required": [
1171
+ "name",
1172
+ "files"
1173
+ ],
1174
+ "additionalProperties": false
1175
+ }"
1176
+ `
1177
+ );
1178
+ });
1179
+ });
1180
+
1181
+ test("override", () => {
1182
+ const schema = z.z.toJSONSchema(z.string(), {
1183
+ override: (ctx) => {
1184
+ ctx.zodSchema;
1185
+ ctx.jsonSchema;
1186
+ ctx.jsonSchema.whatever = "sup";
1187
+ },
1188
+ });
1189
+ expect(schema).toMatchInlineSnapshot(`
1190
+ {
1191
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1192
+ "type": "string",
1193
+ "whatever": "sup",
1194
+ }
1195
+ `);
1196
+ });
1197
+
1198
+ test("override: do not run on references", () => {
1199
+ let overrideCount = 0;
1200
+ const schema = z
1201
+ .union([z.string().date(), z.string().datetime(), z.string().datetime({ local: true })])
1202
+ .meta({ a: true })
1203
+ .transform((str) => new Date(str))
1204
+ .meta({ b: true })
1205
+ .pipe(z.date())
1206
+ .meta({ c: true })
1207
+ .brand("dateIn");
1208
+ z.z.toJSONSchema(schema, {
1209
+ unrepresentable: "any",
1210
+ io: "input",
1211
+ override(_) {
1212
+ overrideCount++;
1213
+ },
1214
+ });
1215
+
1216
+ expect(overrideCount).toBe(6);
1217
+ });
1218
+
1219
+ test("override with refs", () => {
1220
+ const a = z.string().optional();
1221
+ const result = z.z.toJSONSchema(a, {
1222
+ override(ctx) {
1223
+ if (ctx.zodSchema._zod.def.type === "string") {
1224
+ ctx.jsonSchema.type = "STRING" as "string";
1225
+ }
1226
+ },
1227
+ });
1228
+
1229
+ expect(result).toMatchInlineSnapshot(`
1230
+ {
1231
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1232
+ "type": "STRING",
1233
+ }
1234
+ `);
1235
+ });
1236
+
1237
+ test("override execution order", () => {
1238
+ const schema = z.union([z.string(), z.number()]);
1239
+ let unionSchema!: any;
1240
+ z.z.toJSONSchema(schema, {
1241
+ override(ctx) {
1242
+ if (ctx.zodSchema._zod.def.type === "union") {
1243
+ unionSchema = ctx.jsonSchema;
1244
+ }
1245
+ },
1246
+ });
1247
+
1248
+ expect(unionSchema).toMatchInlineSnapshot(`
1249
+ {
1250
+ "anyOf": [
1251
+ {
1252
+ "type": "string",
1253
+ },
1254
+ {
1255
+ "type": "number",
1256
+ },
1257
+ ],
1258
+ }
1259
+ `);
1260
+ });
1261
+
1262
+ test("override with path", () => {
1263
+ const userSchema = z.object({
1264
+ name: z.string(),
1265
+ age: z.number(),
1266
+ });
1267
+
1268
+ const capturedPaths: (string | number)[][] = [];
1269
+
1270
+ z.toJSONSchema(userSchema, {
1271
+ override(ctx) {
1272
+ capturedPaths.push(ctx.path);
1273
+ },
1274
+ });
1275
+
1276
+ expect(capturedPaths).toMatchInlineSnapshot(`
1277
+ [
1278
+ [
1279
+ "properties",
1280
+ "age",
1281
+ ],
1282
+ [
1283
+ "properties",
1284
+ "name",
1285
+ ],
1286
+ [],
1287
+ ]
1288
+ `);
1289
+ });
1290
+
1291
+ test("pipe", () => {
1292
+ const mySchema = z
1293
+ .string()
1294
+ .transform((val) => val.length)
1295
+ .pipe(z.number());
1296
+ // ZodPipe
1297
+
1298
+ const a = z.z.toJSONSchema(mySchema);
1299
+ expect(a).toMatchInlineSnapshot(`
1300
+ {
1301
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1302
+ "type": "number",
1303
+ }
1304
+ `);
1305
+ // => { type: "number" }
1306
+
1307
+ const b = z.z.toJSONSchema(mySchema, { io: "input" });
1308
+ expect(b).toMatchInlineSnapshot(`
1309
+ {
1310
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1311
+ "type": "string",
1312
+ }
1313
+ `);
1314
+ // => { type: "string" }
1315
+ });
1316
+
1317
+ test("passthrough schemas", () => {
1318
+ const Internal = z.object({
1319
+ num: z.number(),
1320
+ str: z.string(),
1321
+ });
1322
+ //.meta({ id: "Internal" });
1323
+
1324
+ const External = z.object({
1325
+ a: Internal,
1326
+ b: Internal.optional(),
1327
+ c: z.lazy(() => Internal),
1328
+ d: z.promise(Internal),
1329
+ e: z.pipe(Internal, Internal),
1330
+ });
1331
+
1332
+ const result = z.z.toJSONSchema(External, {
1333
+ reused: "ref",
1334
+ });
1335
+ expect(result).toMatchInlineSnapshot(`
1336
+ {
1337
+ "$defs": {
1338
+ "__schema0": {
1339
+ "additionalProperties": false,
1340
+ "properties": {
1341
+ "num": {
1342
+ "type": "number",
1343
+ },
1344
+ "str": {
1345
+ "type": "string",
1346
+ },
1347
+ },
1348
+ "required": [
1349
+ "num",
1350
+ "str",
1351
+ ],
1352
+ "type": "object",
1353
+ },
1354
+ },
1355
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1356
+ "additionalProperties": false,
1357
+ "properties": {
1358
+ "a": {
1359
+ "$ref": "#/$defs/__schema0",
1360
+ },
1361
+ "b": {
1362
+ "$ref": "#/$defs/__schema0",
1363
+ },
1364
+ "c": {
1365
+ "$ref": "#/$defs/__schema0",
1366
+ },
1367
+ "d": {
1368
+ "$ref": "#/$defs/__schema0",
1369
+ },
1370
+ "e": {
1371
+ "$ref": "#/$defs/__schema0",
1372
+ },
1373
+ },
1374
+ "required": [
1375
+ "a",
1376
+ "c",
1377
+ "d",
1378
+ "e",
1379
+ ],
1380
+ "type": "object",
1381
+ }
1382
+ `);
1383
+ });
1384
+
1385
+ test("extract schemas with id", () => {
1386
+ const name = z.string().meta({ id: "name" });
1387
+ const result = z.z.toJSONSchema(
1388
+ z.object({
1389
+ first_name: name,
1390
+ last_name: name.nullable(),
1391
+ middle_name: name.optional(),
1392
+ age: z.number().meta({ id: "age" }),
1393
+ })
1394
+ );
1395
+ expect(result).toMatchInlineSnapshot(`
1396
+ {
1397
+ "$defs": {
1398
+ "age": {
1399
+ "id": "age",
1400
+ "type": "number",
1401
+ },
1402
+ "name": {
1403
+ "id": "name",
1404
+ "type": "string",
1405
+ },
1406
+ },
1407
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1408
+ "additionalProperties": false,
1409
+ "properties": {
1410
+ "age": {
1411
+ "$ref": "#/$defs/age",
1412
+ },
1413
+ "first_name": {
1414
+ "$ref": "#/$defs/name",
1415
+ },
1416
+ "last_name": {
1417
+ "anyOf": [
1418
+ {
1419
+ "$ref": "#/$defs/name",
1420
+ },
1421
+ {
1422
+ "type": "null",
1423
+ },
1424
+ ],
1425
+ },
1426
+ "middle_name": {
1427
+ "$ref": "#/$defs/name",
1428
+ },
1429
+ },
1430
+ "required": [
1431
+ "first_name",
1432
+ "last_name",
1433
+ "age",
1434
+ ],
1435
+ "type": "object",
1436
+ }
1437
+ `);
1438
+ });
1439
+
1440
+ test("unrepresentable literal values are ignored", () => {
1441
+ const a = z.z.toJSONSchema(z.literal(["hello", null, 5, BigInt(1324), undefined]), { unrepresentable: "any" });
1442
+ expect(a).toMatchInlineSnapshot(`
1443
+ {
1444
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1445
+ "enum": [
1446
+ "hello",
1447
+ null,
1448
+ 5,
1449
+ 1324,
1450
+ ],
1451
+ }
1452
+ `);
1453
+
1454
+ const b = z.z.toJSONSchema(z.literal([undefined, null, 5, BigInt(1324)]), { unrepresentable: "any" });
1455
+ expect(b).toMatchInlineSnapshot(`
1456
+ {
1457
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1458
+ "enum": [
1459
+ null,
1460
+ 5,
1461
+ 1324,
1462
+ ],
1463
+ }
1464
+ `);
1465
+
1466
+ const c = z.z.toJSONSchema(z.literal([undefined]), { unrepresentable: "any" });
1467
+ expect(c).toMatchInlineSnapshot(`
1468
+ {
1469
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1470
+ }
1471
+ `);
1472
+ });
1473
+
1474
+ test("describe with id", () => {
1475
+ const jobId = z.string().meta({ id: "jobId" });
1476
+
1477
+ const a = z.z.toJSONSchema(
1478
+ z.object({
1479
+ current: jobId.describe("Current job"),
1480
+ previous: jobId.describe("Previous job"),
1481
+ })
1482
+ );
1483
+ expect(a).toMatchInlineSnapshot(`
1484
+ {
1485
+ "$defs": {
1486
+ "jobId": {
1487
+ "id": "jobId",
1488
+ "type": "string",
1489
+ },
1490
+ },
1491
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1492
+ "additionalProperties": false,
1493
+ "properties": {
1494
+ "current": {
1495
+ "$ref": "#/$defs/jobId",
1496
+ "description": "Current job",
1497
+ },
1498
+ "previous": {
1499
+ "$ref": "#/$defs/jobId",
1500
+ "description": "Previous job",
1501
+ },
1502
+ },
1503
+ "required": [
1504
+ "current",
1505
+ "previous",
1506
+ ],
1507
+ "type": "object",
1508
+ }
1509
+ `);
1510
+ });
1511
+
1512
+ test("overwrite id", () => {
1513
+ const jobId = z.string().meta({ id: "aaa" });
1514
+
1515
+ const a = z.z.toJSONSchema(
1516
+ z.object({
1517
+ current: jobId,
1518
+ previous: jobId.meta({ id: "bbb" }),
1519
+ })
1520
+ );
1521
+ expect(a).toMatchInlineSnapshot(`
1522
+ {
1523
+ "$defs": {
1524
+ "aaa": {
1525
+ "id": "aaa",
1526
+ "type": "string",
1527
+ },
1528
+ "bbb": {
1529
+ "$ref": "#/$defs/aaa",
1530
+ "id": "bbb",
1531
+ },
1532
+ },
1533
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1534
+ "additionalProperties": false,
1535
+ "properties": {
1536
+ "current": {
1537
+ "$ref": "#/$defs/aaa",
1538
+ },
1539
+ "previous": {
1540
+ "$ref": "#/$defs/bbb",
1541
+ },
1542
+ },
1543
+ "required": [
1544
+ "current",
1545
+ "previous",
1546
+ ],
1547
+ "type": "object",
1548
+ }
1549
+ `);
1550
+
1551
+ const b = z.z.toJSONSchema(
1552
+ z.object({
1553
+ current: jobId,
1554
+ previous: jobId.meta({ id: "ccc" }),
1555
+ }),
1556
+ {
1557
+ reused: "ref",
1558
+ }
1559
+ );
1560
+ expect(b).toMatchInlineSnapshot(`
1561
+ {
1562
+ "$defs": {
1563
+ "aaa": {
1564
+ "id": "aaa",
1565
+ "type": "string",
1566
+ },
1567
+ "ccc": {
1568
+ "$ref": "#/$defs/aaa",
1569
+ "id": "ccc",
1570
+ },
1571
+ },
1572
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1573
+ "additionalProperties": false,
1574
+ "properties": {
1575
+ "current": {
1576
+ "$ref": "#/$defs/aaa",
1577
+ },
1578
+ "previous": {
1579
+ "$ref": "#/$defs/ccc",
1580
+ },
1581
+ },
1582
+ "required": [
1583
+ "current",
1584
+ "previous",
1585
+ ],
1586
+ "type": "object",
1587
+ }
1588
+ `);
1589
+ });
1590
+
1591
+ test("overwrite descriptions", () => {
1592
+ const field = z.string().describe("a").describe("b").describe("c");
1593
+
1594
+ const a = z.z.toJSONSchema(
1595
+ z.object({
1596
+ d: field.describe("d"),
1597
+ e: field.describe("e"),
1598
+ })
1599
+ );
1600
+ expect(a).toMatchInlineSnapshot(`
1601
+ {
1602
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1603
+ "additionalProperties": false,
1604
+ "properties": {
1605
+ "d": {
1606
+ "description": "d",
1607
+ "type": "string",
1608
+ },
1609
+ "e": {
1610
+ "description": "e",
1611
+ "type": "string",
1612
+ },
1613
+ },
1614
+ "required": [
1615
+ "d",
1616
+ "e",
1617
+ ],
1618
+ "type": "object",
1619
+ }
1620
+ `);
1621
+
1622
+ const b = z.z.toJSONSchema(
1623
+ z.object({
1624
+ d: field.describe("d"),
1625
+ e: field.describe("e"),
1626
+ }),
1627
+ {
1628
+ reused: "ref",
1629
+ }
1630
+ );
1631
+ expect(b).toMatchInlineSnapshot(`
1632
+ {
1633
+ "$defs": {
1634
+ "__schema0": {
1635
+ "description": "c",
1636
+ "type": "string",
1637
+ },
1638
+ },
1639
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1640
+ "additionalProperties": false,
1641
+ "properties": {
1642
+ "d": {
1643
+ "$ref": "#/$defs/__schema0",
1644
+ "description": "d",
1645
+ },
1646
+ "e": {
1647
+ "$ref": "#/$defs/__schema0",
1648
+ "description": "e",
1649
+ },
1650
+ },
1651
+ "required": [
1652
+ "d",
1653
+ "e",
1654
+ ],
1655
+ "type": "object",
1656
+ }
1657
+ `);
1658
+ });
1659
+
1660
+ test("top-level readonly", () => {
1661
+ const A = z
1662
+ .object({
1663
+ name: z.string(),
1664
+ get b() {
1665
+ return B;
1666
+ },
1667
+ })
1668
+ .readonly()
1669
+ .meta({ id: "A" });
1670
+ // z.globalRegistry.add(A, { id: "A" });
1671
+ // .meta({ id: "A" });
1672
+
1673
+ const B = z
1674
+ .object({
1675
+ name: z.string(),
1676
+ get a() {
1677
+ return A;
1678
+ },
1679
+ })
1680
+ .readonly()
1681
+ .meta({ id: "B" });
1682
+ // z.globalRegistry.add(B, { id: "B" });
1683
+ // .meta({ id: "B" });
1684
+
1685
+ const result = z.z.toJSONSchema(A);
1686
+ expect(result).toMatchInlineSnapshot(`
1687
+ {
1688
+ "$defs": {
1689
+ "B": {
1690
+ "additionalProperties": false,
1691
+ "id": "B",
1692
+ "properties": {
1693
+ "a": {
1694
+ "$ref": "#",
1695
+ },
1696
+ "name": {
1697
+ "type": "string",
1698
+ },
1699
+ },
1700
+ "readOnly": true,
1701
+ "required": [
1702
+ "name",
1703
+ "a",
1704
+ ],
1705
+ "type": "object",
1706
+ },
1707
+ },
1708
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1709
+ "additionalProperties": false,
1710
+ "id": "A",
1711
+ "properties": {
1712
+ "b": {
1713
+ "$ref": "#/$defs/B",
1714
+ },
1715
+ "name": {
1716
+ "type": "string",
1717
+ },
1718
+ },
1719
+ "readOnly": true,
1720
+ "required": [
1721
+ "name",
1722
+ "b",
1723
+ ],
1724
+ "type": "object",
1725
+ }
1726
+ `);
1727
+ });
1728
+
1729
+ test("basic registry", () => {
1730
+ const myRegistry = z.registry<{ id: string }>();
1731
+ const User = z.object({
1732
+ name: z.string(),
1733
+ get posts() {
1734
+ return z.array(Post);
1735
+ },
1736
+ });
1737
+
1738
+ const Post = z.object({
1739
+ title: z.string(),
1740
+ content: z.string(),
1741
+ get author() {
1742
+ return User;
1743
+ },
1744
+ });
1745
+
1746
+ myRegistry.add(User, { id: "User" });
1747
+ myRegistry.add(Post, { id: "Post" });
1748
+
1749
+ const result = z.z.toJSONSchema(myRegistry, { uri: (id) => `https://example.com/${id}.json` });
1750
+ expect(result).toMatchInlineSnapshot(`
1751
+ {
1752
+ "schemas": {
1753
+ "Post": {
1754
+ "$id": "https://example.com/Post.json",
1755
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1756
+ "additionalProperties": false,
1757
+ "properties": {
1758
+ "author": {
1759
+ "$ref": "https://example.com/User.json",
1760
+ },
1761
+ "content": {
1762
+ "type": "string",
1763
+ },
1764
+ "title": {
1765
+ "type": "string",
1766
+ },
1767
+ },
1768
+ "required": [
1769
+ "title",
1770
+ "content",
1771
+ "author",
1772
+ ],
1773
+ "type": "object",
1774
+ },
1775
+ "User": {
1776
+ "$id": "https://example.com/User.json",
1777
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1778
+ "additionalProperties": false,
1779
+ "properties": {
1780
+ "name": {
1781
+ "type": "string",
1782
+ },
1783
+ "posts": {
1784
+ "items": {
1785
+ "$ref": "https://example.com/Post.json",
1786
+ },
1787
+ "type": "array",
1788
+ },
1789
+ },
1790
+ "required": [
1791
+ "name",
1792
+ "posts",
1793
+ ],
1794
+ "type": "object",
1795
+ },
1796
+ },
1797
+ }
1798
+ `);
1799
+ });
1800
+
1801
+ test("_ref", () => {
1802
+ // const a = z.promise(z.string().describe("a"));
1803
+ const a = z.z.toJSONSchema(z.promise(z.string().describe("a")));
1804
+ expect(a).toMatchInlineSnapshot(`
1805
+ {
1806
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1807
+ "description": "a",
1808
+ "type": "string",
1809
+ }
1810
+ `);
1811
+
1812
+ const b = z.z.toJSONSchema(z.lazy(() => z.string().describe("a")));
1813
+ expect(b).toMatchInlineSnapshot(`
1814
+ {
1815
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1816
+ "description": "a",
1817
+ "type": "string",
1818
+ }
1819
+ `);
1820
+
1821
+ const c = z.z.toJSONSchema(z.optional(z.string().describe("a")));
1822
+ expect(c).toMatchInlineSnapshot(`
1823
+ {
1824
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1825
+ "description": "a",
1826
+ "type": "string",
1827
+ }
1828
+ `);
1829
+ });
1830
+
1831
+ test("defaults/prefaults", () => {
1832
+ const a = z
1833
+ .string()
1834
+ .transform((val) => val.length)
1835
+ .pipe(z.number());
1836
+ const b = a.prefault("hello");
1837
+ const c = a.default(1234);
1838
+
1839
+ // a
1840
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
1841
+ {
1842
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1843
+ "type": "number",
1844
+ }
1845
+ `);
1846
+ expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
1847
+ {
1848
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1849
+ "type": "string",
1850
+ }
1851
+ `);
1852
+
1853
+ // b
1854
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
1855
+ {
1856
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1857
+ "type": "number",
1858
+ }
1859
+ `);
1860
+ expect(z.toJSONSchema(b, { io: "input" })).toMatchInlineSnapshot(`
1861
+ {
1862
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1863
+ "default": "hello",
1864
+ "type": "string",
1865
+ }
1866
+ `);
1867
+ // c
1868
+ expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
1869
+ {
1870
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1871
+ "default": 1234,
1872
+ "type": "number",
1873
+ }
1874
+ `);
1875
+ expect(z.toJSONSchema(c, { io: "input" })).toMatchInlineSnapshot(`
1876
+ {
1877
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1878
+ "type": "string",
1879
+ }
1880
+ `);
1881
+ });
1882
+
1883
+ test("input type", () => {
1884
+ const schema = z.object({
1885
+ a: z.string(),
1886
+ b: z.string().optional(),
1887
+ c: z.string().default("hello"),
1888
+ d: z.string().nullable(),
1889
+ e: z.string().prefault("hello"),
1890
+ f: z.string().catch("hello"),
1891
+ g: z.never(),
1892
+ h: z.union([z.string(), z.number().default(2)]),
1893
+ i: z.union([z.string(), z.string().optional()]),
1894
+ });
1895
+ expect(z.toJSONSchema(schema, { io: "input" })).toMatchInlineSnapshot(`
1896
+ {
1897
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1898
+ "properties": {
1899
+ "a": {
1900
+ "type": "string",
1901
+ },
1902
+ "b": {
1903
+ "type": "string",
1904
+ },
1905
+ "c": {
1906
+ "default": "hello",
1907
+ "type": "string",
1908
+ },
1909
+ "d": {
1910
+ "anyOf": [
1911
+ {
1912
+ "type": "string",
1913
+ },
1914
+ {
1915
+ "type": "null",
1916
+ },
1917
+ ],
1918
+ },
1919
+ "e": {
1920
+ "default": "hello",
1921
+ "type": "string",
1922
+ },
1923
+ "f": {
1924
+ "default": "hello",
1925
+ "type": "string",
1926
+ },
1927
+ "g": {
1928
+ "not": {},
1929
+ },
1930
+ "h": {
1931
+ "anyOf": [
1932
+ {
1933
+ "type": "string",
1934
+ },
1935
+ {
1936
+ "default": 2,
1937
+ "type": "number",
1938
+ },
1939
+ ],
1940
+ },
1941
+ "i": {
1942
+ "anyOf": [
1943
+ {
1944
+ "type": "string",
1945
+ },
1946
+ {
1947
+ "type": "string",
1948
+ },
1949
+ ],
1950
+ },
1951
+ },
1952
+ "required": [
1953
+ "a",
1954
+ "d",
1955
+ "g",
1956
+ ],
1957
+ "type": "object",
1958
+ }
1959
+ `);
1960
+ expect(z.toJSONSchema(schema, { io: "output" })).toMatchInlineSnapshot(`
1961
+ {
1962
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1963
+ "additionalProperties": false,
1964
+ "properties": {
1965
+ "a": {
1966
+ "type": "string",
1967
+ },
1968
+ "b": {
1969
+ "type": "string",
1970
+ },
1971
+ "c": {
1972
+ "default": "hello",
1973
+ "type": "string",
1974
+ },
1975
+ "d": {
1976
+ "anyOf": [
1977
+ {
1978
+ "type": "string",
1979
+ },
1980
+ {
1981
+ "type": "null",
1982
+ },
1983
+ ],
1984
+ },
1985
+ "e": {
1986
+ "type": "string",
1987
+ },
1988
+ "f": {
1989
+ "default": "hello",
1990
+ "type": "string",
1991
+ },
1992
+ "g": {
1993
+ "not": {},
1994
+ },
1995
+ "h": {
1996
+ "anyOf": [
1997
+ {
1998
+ "type": "string",
1999
+ },
2000
+ {
2001
+ "default": 2,
2002
+ "type": "number",
2003
+ },
2004
+ ],
2005
+ },
2006
+ "i": {
2007
+ "anyOf": [
2008
+ {
2009
+ "type": "string",
2010
+ },
2011
+ {
2012
+ "type": "string",
2013
+ },
2014
+ ],
2015
+ },
2016
+ },
2017
+ "required": [
2018
+ "a",
2019
+ "c",
2020
+ "d",
2021
+ "e",
2022
+ "f",
2023
+ "g",
2024
+ "h",
2025
+ ],
2026
+ "type": "object",
2027
+ }
2028
+ `);
2029
+ });
2030
+
2031
+ test("examples on pipe", () => {
2032
+ const schema = z
2033
+ .string()
2034
+ .meta({ examples: ["test"] })
2035
+ .transform(Number)
2036
+ // .pipe(z.transform(Number).meta({ examples: [4] }))
2037
+ .meta({ examples: [4] });
2038
+
2039
+ const i = z.z.toJSONSchema(schema, { io: "input", unrepresentable: "any" });
2040
+ expect(i).toMatchInlineSnapshot(`
2041
+ {
2042
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2043
+ "examples": [
2044
+ "test",
2045
+ ],
2046
+ "type": "string",
2047
+ }
2048
+ `);
2049
+ const o = z.z.toJSONSchema(schema, { io: "output", unrepresentable: "any" });
2050
+ expect(o).toMatchInlineSnapshot(`
2051
+ {
2052
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2053
+ "examples": [
2054
+ 4,
2055
+ ],
2056
+ }
2057
+ `);
2058
+ });
2059
+
2060
+ // test("number checks", () => {
2061
+ // expect(z.z.toJSONSchema(z.number().int())).toMatchInlineSnapshot(`
2062
+ // {
2063
+ // "maximum": 9007199254740991,
2064
+ // "minimum": -9007199254740991,
2065
+ // "type": "integer",
2066
+ // }
2067
+ // `);
2068
+ // expect(z.z.toJSONSchema(z.int())).toMatchInlineSnapshot(`
2069
+ // {
2070
+ // "maximum": 9007199254740991,
2071
+ // "minimum": -9007199254740991,
2072
+ // "type": "integer",
2073
+ // }
2074
+ // `);
2075
+ // expect(z.z.toJSONSchema(z.int().positive())).toMatchInlineSnapshot(`
2076
+ // {
2077
+ // "exclusiveMinimum": 0,
2078
+ // "maximum": 9007199254740991,
2079
+ // "minimum": -9007199254740991,
2080
+ // "type": "integer",
2081
+ // }
2082
+ // `);
2083
+ // expect(z.z.toJSONSchema(z.int().nonnegative())).toMatchInlineSnapshot(`
2084
+ // {
2085
+ // "maximum": 9007199254740991,
2086
+ // "minimum": 0,
2087
+ // "type": "integer",
2088
+ // }
2089
+ // `);
2090
+ // expect(z.z.toJSONSchema(z.int().gt(0))).toMatchInlineSnapshot(`
2091
+ // {
2092
+ // "exclusiveMinimum": 0,
2093
+ // "maximum": 9007199254740991,
2094
+ // "minimum": -9007199254740991,
2095
+ // "type": "integer",
2096
+ // }
2097
+ // `);
2098
+ // expect(z.z.toJSONSchema(z.int().gte(0))).toMatchInlineSnapshot(`
2099
+ // {
2100
+ // "maximum": 9007199254740991,
2101
+ // "minimum": 0,
2102
+ // "type": "integer",
2103
+ // }
2104
+ // `);
2105
+
2106
+ // });
2107
+
2108
+ test("use output type for preprocess", () => {
2109
+ const a = z.preprocess((val) => String(val), z.string());
2110
+
2111
+ expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
2112
+ {
2113
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2114
+ "type": "string",
2115
+ }
2116
+ `);
2117
+ });
2118
+
2119
+ // test("isTransforming", () => {
2120
+ // const tx = z.core.isTransforming;
2121
+ // expect(tx(z.string())).toEqual(false);
2122
+ // expect(tx(z.string().transform((val) => val))).toEqual(true);
2123
+ // expect(tx(z.string().pipe(z.string()))).toEqual(false);
2124
+ // expect(
2125
+ // tx(
2126
+ // z
2127
+ // .string()
2128
+ // .transform((val) => val)
2129
+ // .pipe(z.string())
2130
+ // )
2131
+ // ).toEqual(true);
2132
+
2133
+ // const a = z.transform((val) => val);
2134
+ // expect(tx(z.transform((val) => val))).toEqual(true);
2135
+ // expect(tx(a.optional())).toEqual(true);
2136
+
2137
+ // const b = z.string().optional();
2138
+ // expect(tx(b)).toEqual(false);
2139
+
2140
+ // const c = z.string().prefault("hello");
2141
+ // expect(tx(c)).toEqual(false);
2142
+
2143
+ // const d = z.string().default("hello");
2144
+ // expect(tx(d)).toEqual(false);
2145
+ // });
2146
+
2147
+ test("flatten simple intersections", () => {
2148
+ const FirstSchema = z.object({
2149
+ testNum: z.number(),
2150
+ });
2151
+
2152
+ const SecondSchema = z.object({
2153
+ testStr: z.string(),
2154
+ });
2155
+
2156
+ const ThirdSchema = z.object({
2157
+ testBool: z.boolean(),
2158
+ });
2159
+
2160
+ const HelloSchema = FirstSchema.and(SecondSchema).and(ThirdSchema).describe("123");
2161
+
2162
+ // Zod 3
2163
+ // console.log(JSON.stringify(zodToJsonSchema(HelloSchema), null, 2));
2164
+
2165
+ // Zod 4
2166
+ const result = z.toJSONSchema(HelloSchema, { target: "draft-7" });
2167
+ expect(result).toMatchInlineSnapshot(`
2168
+ {
2169
+ "$schema": "http://json-schema.org/draft-07/schema#",
2170
+ "allOf": [
2171
+ {
2172
+ "additionalProperties": false,
2173
+ "properties": {
2174
+ "testNum": {
2175
+ "type": "number",
2176
+ },
2177
+ },
2178
+ "required": [
2179
+ "testNum",
2180
+ ],
2181
+ "type": "object",
2182
+ },
2183
+ {
2184
+ "additionalProperties": false,
2185
+ "properties": {
2186
+ "testStr": {
2187
+ "type": "string",
2188
+ },
2189
+ },
2190
+ "required": [
2191
+ "testStr",
2192
+ ],
2193
+ "type": "object",
2194
+ },
2195
+ {
2196
+ "additionalProperties": false,
2197
+ "properties": {
2198
+ "testBool": {
2199
+ "type": "boolean",
2200
+ },
2201
+ },
2202
+ "required": [
2203
+ "testBool",
2204
+ ],
2205
+ "type": "object",
2206
+ },
2207
+ ],
2208
+ "description": "123",
2209
+ }
2210
+ `);
2211
+ });
2212
+
2213
+ test("z.file()", () => {
2214
+ const a = z.file();
2215
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
2216
+ {
2217
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2218
+ "contentEncoding": "binary",
2219
+ "format": "binary",
2220
+ "type": "string",
2221
+ }
2222
+ `);
2223
+
2224
+ const b = z.file().mime("image/png").min(1000).max(10000);
2225
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
2226
+ {
2227
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2228
+ "contentEncoding": "binary",
2229
+ "contentMediaType": "image/png",
2230
+ "format": "binary",
2231
+ "maxLength": 10000,
2232
+ "minLength": 1000,
2233
+ "type": "string",
2234
+ }
2235
+ `);
2236
+
2237
+ const c = z.file().mime(["image/png", "image/jpg"]).min(1000).max(10000);
2238
+ expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
2239
+ {
2240
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2241
+ "anyOf": [
2242
+ {
2243
+ "contentEncoding": "binary",
2244
+ "contentMediaType": "image/png",
2245
+ "format": "binary",
2246
+ "maxLength": 10000,
2247
+ "minLength": 1000,
2248
+ "type": "string",
2249
+ },
2250
+ {
2251
+ "contentEncoding": "binary",
2252
+ "contentMediaType": "image/jpg",
2253
+ "format": "binary",
2254
+ "maxLength": 10000,
2255
+ "minLength": 1000,
2256
+ "type": "string",
2257
+ },
2258
+ ],
2259
+ }
2260
+ `);
2261
+ });
2262
+
2263
+ test("custom toJSONSchema", () => {
2264
+ const schema = z.instanceof(Date);
2265
+ schema._zod.toJSONSchema = () => ({
2266
+ type: "string",
2267
+ format: "date-time",
2268
+ });
2269
+
2270
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
2271
+ {
2272
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2273
+ "format": "date-time",
2274
+ "type": "string",
2275
+ }
2276
+ `);
2277
+ });
2278
+
2279
+ test("cycle detection - root", () => {
2280
+ const schema = z.object({
2281
+ name: z.string(),
2282
+ get subcategories() {
2283
+ return z.array(schema);
2284
+ },
2285
+ });
2286
+
2287
+ expect(() => z.toJSONSchema(schema, { cycles: "throw" })).toThrowErrorMatchingInlineSnapshot(`
2288
+ [Error: Cycle detected: #/properties/subcategories/items/<root>
2289
+
2290
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.]
2291
+ `);
2292
+ });
2293
+
2294
+ test("cycle detection - mutual recursion", () => {
2295
+ const A = z.object({
2296
+ name: z.string(),
2297
+ get subcategories() {
2298
+ return z.array(B);
2299
+ },
2300
+ });
2301
+
2302
+ const B = z.object({
2303
+ name: z.string(),
2304
+ get subcategories() {
2305
+ return z.array(A);
2306
+ },
2307
+ });
2308
+
2309
+ expect(() => z.toJSONSchema(A, { cycles: "throw" })).toThrowErrorMatchingInlineSnapshot(`
2310
+ [Error: Cycle detected: #/properties/subcategories/items/properties/subcategories/items/<root>
2311
+
2312
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.]
2313
+ `);
2314
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/transform.test.ts ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ test("transform ctx.addIssue with parse", () => {
5
+ const strs = ["foo", "bar"];
6
+ const schema = z.string().transform((data, ctx) => {
7
+ const i = strs.indexOf(data);
8
+ if (i === -1) {
9
+ ctx.addIssue({
10
+ input: data,
11
+ code: "custom",
12
+ message: `${data} is not one of our allowed strings`,
13
+ });
14
+ }
15
+ return data.length;
16
+ });
17
+ const result = schema.safeParse("asdf");
18
+ expect(result.success).toEqual(false);
19
+ expect(result.error!).toMatchInlineSnapshot(`
20
+ [ZodError: [
21
+ {
22
+ "code": "custom",
23
+ "message": "asdf is not one of our allowed strings",
24
+ "path": []
25
+ }
26
+ ]]
27
+ `);
28
+ });
29
+
30
+ test("transform ctx.addIssue with parseAsync", async () => {
31
+ const strs = ["foo", "bar"];
32
+
33
+ const result = await z
34
+ .string()
35
+ .transform(async (data, ctx) => {
36
+ const i = strs.indexOf(data);
37
+ if (i === -1) {
38
+ ctx.addIssue({
39
+ input: data,
40
+ code: "custom",
41
+ message: `${data} is not one of our allowed strings`,
42
+ });
43
+ }
44
+ return data.length;
45
+ })
46
+ .safeParseAsync("asdf");
47
+
48
+ expect(result).toMatchInlineSnapshot(`
49
+ {
50
+ "error": [ZodError: [
51
+ {
52
+ "code": "custom",
53
+ "message": "asdf is not one of our allowed strings",
54
+ "path": []
55
+ }
56
+ ]],
57
+ "success": false,
58
+ }
59
+ `);
60
+ });
61
+
62
+ test("z.NEVER in transform", () => {
63
+ const foo = z
64
+ .number()
65
+ .optional()
66
+ .transform((val, ctx) => {
67
+ if (!val) {
68
+ ctx.addIssue({
69
+ input: val,
70
+ code: z.ZodIssueCode.custom,
71
+ message: "bad",
72
+ });
73
+ return z.NEVER;
74
+ }
75
+ return val;
76
+ });
77
+ type foo = z.infer<typeof foo>;
78
+ expectTypeOf<foo>().toEqualTypeOf<number>();
79
+ const arg = foo.safeParse(undefined);
80
+ if (!arg.success) {
81
+ expect(arg.error.issues[0].message).toEqual("bad");
82
+ }
83
+ });
84
+
85
+ test("basic transformations", () => {
86
+ const r1 = z
87
+ .string()
88
+ .transform((data) => data.length)
89
+ .parse("asdf");
90
+ expect(r1).toEqual(4);
91
+ });
92
+
93
+ test("coercion", () => {
94
+ const numToString = z.number().transform((n) => String(n));
95
+ const data = z
96
+ .object({
97
+ id: numToString,
98
+ })
99
+ .parse({ id: 5 });
100
+
101
+ expect(data).toEqual({ id: "5" });
102
+ });
103
+
104
+ test("async coercion", async () => {
105
+ const numToString = z.number().transform(async (n) => String(n));
106
+ const data = await z
107
+ .object({
108
+ id: numToString,
109
+ })
110
+ .parseAsync({ id: 5 });
111
+
112
+ expect(data).toEqual({ id: "5" });
113
+ });
114
+
115
+ test("sync coercion async error", async () => {
116
+ const asyncNumberToString = z.number().transform(async (n) => String(n));
117
+ expect(() =>
118
+ z
119
+ .object({
120
+ id: asyncNumberToString,
121
+ })
122
+ .parse({ id: 5 })
123
+ ).toThrow();
124
+ // expect(data).toEqual({ id: '5' });
125
+ });
126
+
127
+ test("default", () => {
128
+ const data = z.string().default("asdf").parse(undefined); // => "asdf"
129
+ expect(data).toEqual("asdf");
130
+ });
131
+
132
+ test("dynamic default", () => {
133
+ const data = z
134
+ .string()
135
+ .default(() => "string")
136
+ .parse(undefined); // => "asdf"
137
+ expect(data).toEqual("string");
138
+ });
139
+
140
+ test("default when property is null or undefined", () => {
141
+ const data = z
142
+ .object({
143
+ foo: z.boolean().nullable().default(true),
144
+ bar: z.boolean().default(true),
145
+ })
146
+ .parse({ foo: null });
147
+
148
+ expect(data).toEqual({ foo: null, bar: true });
149
+ });
150
+
151
+ test("default with falsy values", () => {
152
+ const schema = z.object({
153
+ emptyStr: z.string().default("def"),
154
+ zero: z.number().default(5),
155
+ falseBoolean: z.boolean().default(true),
156
+ });
157
+ const input = { emptyStr: "", zero: 0, falseBoolean: true };
158
+ const output = schema.parse(input);
159
+ // defaults are not supposed to be used
160
+ expect(output).toEqual(input);
161
+ });
162
+
163
+ test("object typing", () => {
164
+ const stringToNumber = z.string().transform((arg) => Number.parseFloat(arg));
165
+
166
+ const t1 = z.object({
167
+ stringToNumber,
168
+ });
169
+
170
+ type t1 = z.input<typeof t1>;
171
+ type t2 = z.output<typeof t1>;
172
+
173
+ expectTypeOf<t1>().toEqualTypeOf<{ stringToNumber: string }>();
174
+ expectTypeOf<t2>().toEqualTypeOf<{ stringToNumber: number }>();
175
+ });
176
+
177
+ test("transform method overloads", () => {
178
+ const t1 = z.string().transform((val) => val.toUpperCase());
179
+ expect(t1.parse("asdf")).toEqual("ASDF");
180
+
181
+ const t2 = z.string().transform((val) => val.length);
182
+ expect(t2.parse("asdf")).toEqual(4);
183
+ });
184
+
185
+ test("multiple transformers", () => {
186
+ const stringToNumber = z.string().transform((arg) => Number.parseFloat(arg));
187
+
188
+ const doubler = stringToNumber.transform((val) => {
189
+ return val * 2;
190
+ });
191
+ expect(doubler.parse("5")).toEqual(10);
192
+ });
193
+
194
+ test("short circuit on dirty", () => {
195
+ const schema = z
196
+ .string()
197
+ .refine(() => false)
198
+ .transform((val) => val.toUpperCase());
199
+ const result = schema.safeParse("asdf");
200
+ expect(result.success).toEqual(false);
201
+
202
+ expect(result.error).toMatchInlineSnapshot(`
203
+ [ZodError: [
204
+ {
205
+ "code": "custom",
206
+ "path": [],
207
+ "message": "Invalid input"
208
+ }
209
+ ]]
210
+ `);
211
+
212
+ const result2 = schema.safeParse(1234);
213
+ expect(result2.success).toEqual(false);
214
+ if (!result2.success) {
215
+ expect(result2.error.issues[0].code).toEqual(z.ZodIssueCode.invalid_type);
216
+ }
217
+ });
218
+
219
+ test("async short circuit on dirty", async () => {
220
+ const schema = z
221
+ .string()
222
+ .refine(() => false)
223
+ .transform((val) => val.toUpperCase());
224
+ const result = await schema.spa("asdf");
225
+ expect(result.success).toEqual(false);
226
+
227
+ expect(result.error).toMatchInlineSnapshot(`
228
+ [ZodError: [
229
+ {
230
+ "code": "custom",
231
+ "path": [],
232
+ "message": "Invalid input"
233
+ }
234
+ ]]
235
+ `);
236
+
237
+ const result2 = await schema.spa(1234);
238
+ expect(result2.success).toEqual(false);
239
+
240
+ expect(result2.error).toMatchInlineSnapshot(`
241
+ [ZodError: [
242
+ {
243
+ "expected": "string",
244
+ "code": "invalid_type",
245
+ "path": [],
246
+ "message": "Invalid input: expected string, received number"
247
+ }
248
+ ]]
249
+ `);
250
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/tuple.test.ts ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ test("successful validation", () => {
5
+ const testTuple = z.tuple([z.string(), z.number()]);
6
+ expectTypeOf<typeof testTuple._output>().toEqualTypeOf<[string, number]>();
7
+
8
+ const val = testTuple.parse(["asdf", 1234]);
9
+ expect(val).toEqual(val);
10
+
11
+ const r1 = testTuple.safeParse(["asdf", "asdf"]);
12
+ expect(r1.success).toEqual(false);
13
+ expect(r1.error!).toMatchInlineSnapshot(`
14
+ [ZodError: [
15
+ {
16
+ "expected": "number",
17
+ "code": "invalid_type",
18
+ "path": [
19
+ 1
20
+ ],
21
+ "message": "Invalid input: expected number, received string"
22
+ }
23
+ ]]
24
+ `);
25
+
26
+ const r2 = testTuple.safeParse(["asdf", 1234, true]);
27
+ expect(r2.success).toEqual(false);
28
+ expect(r2.error!).toMatchInlineSnapshot(`
29
+ [ZodError: [
30
+ {
31
+ "origin": "array",
32
+ "code": "too_big",
33
+ "maximum": 2,
34
+ "path": [],
35
+ "message": "Too big: expected array to have <2 items"
36
+ }
37
+ ]]
38
+ `);
39
+
40
+ const r3 = testTuple.safeParse({});
41
+ expect(r3.success).toEqual(false);
42
+ expect(r3.error!).toMatchInlineSnapshot(`
43
+ [ZodError: [
44
+ {
45
+ "expected": "tuple",
46
+ "code": "invalid_type",
47
+ "path": [],
48
+ "message": "Invalid input: expected tuple, received object"
49
+ }
50
+ ]]
51
+ `);
52
+ });
53
+
54
+ test("async validation", async () => {
55
+ const testTuple = z
56
+ .tuple([z.string().refine(async () => true), z.number().refine(async () => true)])
57
+ .refine(async () => true);
58
+ expectTypeOf<typeof testTuple._output>().toEqualTypeOf<[string, number]>();
59
+
60
+ const val = await testTuple.parseAsync(["asdf", 1234]);
61
+ expect(val).toEqual(val);
62
+
63
+ const r1 = await testTuple.safeParseAsync(["asdf", "asdf"]);
64
+ expect(r1.success).toEqual(false);
65
+ expect(r1.error!).toMatchInlineSnapshot(`
66
+ [ZodError: [
67
+ {
68
+ "expected": "number",
69
+ "code": "invalid_type",
70
+ "path": [
71
+ 1
72
+ ],
73
+ "message": "Invalid input: expected number, received string"
74
+ }
75
+ ]]
76
+ `);
77
+
78
+ const r2 = await testTuple.safeParseAsync(["asdf", 1234, true]);
79
+ expect(r2.success).toEqual(false);
80
+ expect(r2.error!).toMatchInlineSnapshot(`
81
+ [ZodError: [
82
+ {
83
+ "origin": "array",
84
+ "code": "too_big",
85
+ "maximum": 2,
86
+ "path": [],
87
+ "message": "Too big: expected array to have <2 items"
88
+ }
89
+ ]]
90
+ `);
91
+
92
+ const r3 = await testTuple.safeParseAsync({});
93
+ expect(r3.success).toEqual(false);
94
+ expect(r3.error!).toMatchInlineSnapshot(`
95
+ [ZodError: [
96
+ {
97
+ "expected": "tuple",
98
+ "code": "invalid_type",
99
+ "path": [],
100
+ "message": "Invalid input: expected tuple, received object"
101
+ }
102
+ ]]
103
+ `);
104
+ });
105
+
106
+ test("tuple with optional elements", () => {
107
+ const myTuple = z.tuple([z.string(), z.number().optional(), z.string().optional()]).rest(z.boolean());
108
+ expectTypeOf<typeof myTuple._output>().toEqualTypeOf<[string, number?, string?, ...boolean[]]>();
109
+
110
+ const goodData = [["asdf"], ["asdf", 1234], ["asdf", 1234, "asdf"], ["asdf", 1234, "asdf", true, false, true]];
111
+ for (const data of goodData) {
112
+ expect(myTuple.parse(data)).toEqual(data);
113
+ }
114
+
115
+ const badData = [
116
+ ["asdf", "asdf"],
117
+ ["asdf", 1234, "asdf", "asdf"],
118
+ ["asdf", 1234, "asdf", true, false, "asdf"],
119
+ ];
120
+ for (const data of badData) {
121
+ expect(() => myTuple.parse(data)).toThrow();
122
+ }
123
+ });
124
+
125
+ test("tuple with optional elements followed by required", () => {
126
+ const myTuple = z.tuple([z.string(), z.number().optional(), z.string()]).rest(z.boolean());
127
+ expectTypeOf<typeof myTuple._output>().toEqualTypeOf<[string, number | undefined, string, ...boolean[]]>();
128
+
129
+ const goodData = [
130
+ ["asdf", 1234, "asdf"],
131
+ ["asdf", 1234, "asdf", true, false, true],
132
+ ];
133
+ for (const data of goodData) {
134
+ expect(myTuple.parse(data)).toEqual(data);
135
+ }
136
+
137
+ const badData = [
138
+ ["asdf"],
139
+ ["asdf", 1234],
140
+ ["asdf", 1234, "asdf", "asdf"],
141
+ ["asdf", 1234, "asdf", true, false, "asdf"],
142
+ ];
143
+ for (const data of badData) {
144
+ expect(() => myTuple.parse(data)).toThrow();
145
+ }
146
+ });
147
+
148
+ test("tuple with rest schema", () => {
149
+ const myTuple = z.tuple([z.string(), z.number()]).rest(z.boolean());
150
+ expect(myTuple.parse(["asdf", 1234, true, false, true])).toEqual(["asdf", 1234, true, false, true]);
151
+
152
+ expect(myTuple.parse(["asdf", 1234])).toEqual(["asdf", 1234]);
153
+
154
+ expect(() => myTuple.parse(["asdf", 1234, "asdf"])).toThrow();
155
+ type t1 = z.output<typeof myTuple>;
156
+
157
+ expectTypeOf<t1>().toEqualTypeOf<[string, number, ...boolean[]]>();
158
+ });
159
+
160
+ test("sparse array input", () => {
161
+ const schema = z.tuple([z.string(), z.number()]);
162
+ expect(() => schema.parse(new Array(2))).toThrow();
163
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/union.test.ts ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+
3
+ import * as z from "zod/v4";
4
+
5
+ test("function parsing", () => {
6
+ const schema = z.union([z.string().refine(() => false), z.number().refine(() => false)]);
7
+ const result = schema.safeParse("asdf");
8
+ expect(result.success).toEqual(false);
9
+ });
10
+
11
+ test("union 2", () => {
12
+ const result = z.union([z.number(), z.string().refine(() => false)]).safeParse("a");
13
+ expect(result.success).toEqual(false);
14
+ });
15
+
16
+ test("return valid over invalid", () => {
17
+ const schema = z.union([
18
+ z.object({
19
+ email: z.string().email(),
20
+ }),
21
+ z.string(),
22
+ ]);
23
+ expect(schema.parse("asdf")).toEqual("asdf");
24
+ expect(schema.parse({ email: "asdlkjf@lkajsdf.com" })).toEqual({
25
+ email: "asdlkjf@lkajsdf.com",
26
+ });
27
+ });
28
+
29
+ test("return errors from both union arms", () => {
30
+ const result = z.union([z.number(), z.string().refine(() => false)]).safeParse("a");
31
+ expect(result.success).toEqual(false);
32
+ if (!result.success) {
33
+ expect(result.error.issues).toMatchInlineSnapshot(`
34
+ [
35
+ {
36
+ "code": "invalid_union",
37
+ "errors": [
38
+ [
39
+ {
40
+ "code": "invalid_type",
41
+ "expected": "number",
42
+ "message": "Invalid input: expected number, received string",
43
+ "path": [],
44
+ },
45
+ ],
46
+ [
47
+ {
48
+ "code": "custom",
49
+ "message": "Invalid input",
50
+ "path": [],
51
+ },
52
+ ],
53
+ ],
54
+ "message": "Invalid input",
55
+ "path": [],
56
+ },
57
+ ]
58
+ `);
59
+ }
60
+ });
61
+
62
+ test("options getter", async () => {
63
+ const union = z.union([z.string(), z.number()]);
64
+ union.options[0].parse("asdf");
65
+ union.options[1].parse(1234);
66
+ await union.options[0].parseAsync("asdf");
67
+ await union.options[1].parseAsync(1234);
68
+ });
69
+
70
+ test("readonly union", async () => {
71
+ const options = [z.string(), z.number()] as const;
72
+ const union = z.union(options);
73
+ union.parse("asdf");
74
+ union.parse(12);
75
+ });
76
+
77
+ test("union inferred types", () => {
78
+ const test = z.object({}).or(z.array(z.object({})));
79
+
80
+ type Test = z.output<typeof test>; // <— any
81
+ expectTypeOf<Test>().toEqualTypeOf<Record<string, never> | Array<Record<string, never>>>();
82
+ });
83
+
84
+ test("union values", () => {
85
+ const schema = z.union([z.literal("a"), z.literal("b"), z.literal("c")]);
86
+
87
+ expect(schema._zod.values).toMatchInlineSnapshot(`
88
+ Set {
89
+ "a",
90
+ "b",
91
+ "c",
92
+ }
93
+ `);
94
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/validations.test.ts ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+
3
+ import * as z from "zod/v4";
4
+
5
+ test("string length", async () => {
6
+ try {
7
+ await z.string().length(4).parseAsync("asd");
8
+ } catch (err) {
9
+ // ("String must contain exactly 4 character(s)");
10
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
11
+ [
12
+ {
13
+ "code": "too_small",
14
+ "exact": true,
15
+ "inclusive": true,
16
+ "message": "Too small: expected string to have >=4 characters",
17
+ "minimum": 4,
18
+ "origin": "string",
19
+ "path": [],
20
+ },
21
+ ]
22
+ `);
23
+ }
24
+
25
+ try {
26
+ await z.string().length(4).parseAsync("asdaa");
27
+ } catch (err) {
28
+ // ("String must contain exactly 4 character(s)");
29
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
30
+ [
31
+ {
32
+ "code": "too_big",
33
+ "exact": true,
34
+ "inclusive": true,
35
+ "maximum": 4,
36
+ "message": "Too big: expected string to have <=4 characters",
37
+ "origin": "string",
38
+ "path": [],
39
+ },
40
+ ]
41
+ `);
42
+ }
43
+ });
44
+
45
+ test("string min/max", async () => {
46
+ try {
47
+ await z.string().min(4).parseAsync("asd");
48
+ } catch (err) {
49
+ // ("String must contain at least 4 character(s)");
50
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
51
+ [
52
+ {
53
+ "code": "too_small",
54
+ "inclusive": true,
55
+ "message": "Too small: expected string to have >=4 characters",
56
+ "minimum": 4,
57
+ "origin": "string",
58
+ "path": [],
59
+ },
60
+ ]
61
+ `);
62
+ }
63
+ });
64
+
65
+ test("string max", async () => {
66
+ try {
67
+ await z.string().max(4).parseAsync("aasdfsdfsd");
68
+ } catch (err) {
69
+ // ("String must contain at most 4 character(s)");
70
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
71
+ [
72
+ {
73
+ "code": "too_big",
74
+ "inclusive": true,
75
+ "maximum": 4,
76
+ "message": "Too big: expected string to have <=4 characters",
77
+ "origin": "string",
78
+ "path": [],
79
+ },
80
+ ]
81
+ `);
82
+ }
83
+ });
84
+
85
+ test("number min", async () => {
86
+ try {
87
+ await z.number().min(3).parseAsync(2);
88
+ } catch (err) {
89
+ // ("Number must be greater than or equal to 3");
90
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
91
+ [
92
+ {
93
+ "code": "too_small",
94
+ "inclusive": true,
95
+ "message": "Too small: expected number to be >=3",
96
+ "minimum": 3,
97
+ "origin": "number",
98
+ "path": [],
99
+ },
100
+ ]
101
+ `);
102
+ }
103
+ });
104
+
105
+ test("number gte", async () => {
106
+ try {
107
+ await z.number().gte(3).parseAsync(2);
108
+ } catch (err) {
109
+ // ("Number must be greater than or equal to 3");
110
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
111
+ [
112
+ {
113
+ "code": "too_small",
114
+ "inclusive": true,
115
+ "message": "Too small: expected number to be >=3",
116
+ "minimum": 3,
117
+ "origin": "number",
118
+ "path": [],
119
+ },
120
+ ]
121
+ `);
122
+ }
123
+ });
124
+
125
+ test("number gt", async () => {
126
+ try {
127
+ await z.number().gt(3).parseAsync(3);
128
+ } catch (err) {
129
+ // ("Number must be greater than or equal to 3");
130
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
131
+ [
132
+ {
133
+ "code": "too_small",
134
+ "inclusive": false,
135
+ "message": "Too small: expected number to be >3",
136
+ "minimum": 3,
137
+ "origin": "number",
138
+ "path": [],
139
+ },
140
+ ]
141
+ `);
142
+ }
143
+ });
144
+
145
+ test("number max", async () => {
146
+ try {
147
+ await z.number().max(3).parseAsync(4);
148
+ } catch (err) {
149
+ // ("Number must be less than or equal to 3");
150
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
151
+ [
152
+ {
153
+ "code": "too_big",
154
+ "inclusive": true,
155
+ "maximum": 3,
156
+ "message": "Too big: expected number to be <=3",
157
+ "origin": "number",
158
+ "path": [],
159
+ },
160
+ ]
161
+ `);
162
+ }
163
+ });
164
+
165
+ test("number lte", async () => {
166
+ try {
167
+ await z.number().lte(3).parseAsync(4);
168
+ } catch (err) {
169
+ // ("Number must be less than or equal to 3");
170
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
171
+ [
172
+ {
173
+ "code": "too_big",
174
+ "inclusive": true,
175
+ "maximum": 3,
176
+ "message": "Too big: expected number to be <=3",
177
+ "origin": "number",
178
+ "path": [],
179
+ },
180
+ ]
181
+ `);
182
+ }
183
+ });
184
+
185
+ test("number lt", async () => {
186
+ try {
187
+ await z.number().lt(3).parseAsync(3);
188
+ } catch (err) {
189
+ // ("Number must be less than or equal to 3");
190
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
191
+ [
192
+ {
193
+ "code": "too_big",
194
+ "inclusive": false,
195
+ "maximum": 3,
196
+ "message": "Too big: expected number to be <3",
197
+ "origin": "number",
198
+ "path": [],
199
+ },
200
+ ]
201
+ `);
202
+ }
203
+ });
204
+
205
+ test("number nonnegative", async () => {
206
+ try {
207
+ await z.number().nonnegative().parseAsync(-1);
208
+ } catch (err) {
209
+ // ("Number must be greater than or equal to 0");
210
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
211
+ [
212
+ {
213
+ "code": "too_small",
214
+ "inclusive": true,
215
+ "message": "Too small: expected number to be >=0",
216
+ "minimum": 0,
217
+ "origin": "number",
218
+ "path": [],
219
+ },
220
+ ]
221
+ `);
222
+ }
223
+ });
224
+
225
+ test("number nonpositive", async () => {
226
+ try {
227
+ await z.number().nonpositive().parseAsync(1);
228
+ } catch (err) {
229
+ // ("Number must be less than or equal to 0");
230
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
231
+ [
232
+ {
233
+ "code": "too_big",
234
+ "inclusive": true,
235
+ "maximum": 0,
236
+ "message": "Too big: expected number to be <=0",
237
+ "origin": "number",
238
+ "path": [],
239
+ },
240
+ ]
241
+ `);
242
+ }
243
+ });
244
+
245
+ test("number negative", async () => {
246
+ try {
247
+ await z.number().negative().parseAsync(1);
248
+ } catch (err) {
249
+ // ("Number must be less than 0");
250
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
251
+ [
252
+ {
253
+ "code": "too_big",
254
+ "inclusive": false,
255
+ "maximum": 0,
256
+ "message": "Too big: expected number to be <0",
257
+ "origin": "number",
258
+ "path": [],
259
+ },
260
+ ]
261
+ `);
262
+ }
263
+ });
264
+
265
+ test("number positive", async () => {
266
+ try {
267
+ await z.number().positive().parseAsync(-1);
268
+ } catch (err) {
269
+ // ("Number must be greater than 0");
270
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
271
+ [
272
+ {
273
+ "code": "too_small",
274
+ "inclusive": false,
275
+ "message": "Too small: expected number to be >0",
276
+ "minimum": 0,
277
+ "origin": "number",
278
+ "path": [],
279
+ },
280
+ ]
281
+ `);
282
+ }
283
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/classic/tests/void.test.ts ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+ test("void", () => {
4
+ const v = z.void();
5
+ v.parse(undefined);
6
+
7
+ expect(() => v.parse(null)).toThrow();
8
+ expect(() => v.parse("")).toThrow();
9
+
10
+ type v = z.infer<typeof v>;
11
+ expectTypeOf<v>().toEqualTypeOf<void>();
12
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/api.ts ADDED
@@ -0,0 +1,1594 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as checks from "./checks.js";
2
+ import type * as core from "./core.js";
3
+ import type * as errors from "./errors.js";
4
+ import * as schemas from "./schemas.js";
5
+ import * as util from "./util.js";
6
+
7
+ export type Params<
8
+ T extends schemas.$ZodType | checks.$ZodCheck,
9
+ IssueTypes extends errors.$ZodIssueBase,
10
+ OmitKeys extends keyof T["_zod"]["def"] = never,
11
+ > = util.Flatten<
12
+ Partial<
13
+ util.EmptyToNever<
14
+ Omit<T["_zod"]["def"], OmitKeys> &
15
+ ([IssueTypes] extends [never]
16
+ ? {} // unknown
17
+ : {
18
+ error?: string | errors.$ZodErrorMap<IssueTypes> | undefined;
19
+ /** @deprecated This parameter is deprecated. Use `error` instead. */
20
+ message?: string | undefined; // supported in Zod 3
21
+ })
22
+ >
23
+ >
24
+ >;
25
+
26
+ export type TypeParams<
27
+ T extends schemas.$ZodType = schemas.$ZodType & { _isst: never },
28
+ AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "checks" | "error"> = never,
29
+ > = Params<T, NonNullable<T["_zod"]["isst"]>, "type" | "checks" | "error" | AlsoOmit>;
30
+
31
+ // strips types that are not exposed in the public factory
32
+ // incl. `error`, `check`
33
+ export type CheckParams<
34
+ T extends checks.$ZodCheck = checks.$ZodCheck, // & { _issc: never },
35
+ AlsoOmit extends Exclude<keyof T["_zod"]["def"], "check" | "error"> = never,
36
+ > = Params<T, NonNullable<T["_zod"]["issc"]>, "check" | "error" | AlsoOmit>;
37
+
38
+ // strips types that are not exposed in the public factory
39
+ // incl. `type`, `checks`, `error`, `check`, `format`
40
+ export type StringFormatParams<
41
+ T extends schemas.$ZodStringFormat = schemas.$ZodStringFormat,
42
+ AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "coerce" | "checks" | "error" | "check" | "format"> = never,
43
+ > = Params<
44
+ T,
45
+ NonNullable<T["_zod"]["isst"] | T["_zod"]["issc"]>,
46
+ "type" | "coerce" | "checks" | "error" | "check" | "format" | AlsoOmit
47
+ >;
48
+
49
+ export type CheckStringFormatParams<
50
+ T extends schemas.$ZodStringFormat = schemas.$ZodStringFormat,
51
+ AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "coerce" | "checks" | "error" | "check" | "format"> = never,
52
+ > = Params<T, NonNullable<T["_zod"]["issc"]>, "type" | "coerce" | "checks" | "error" | "check" | "format" | AlsoOmit>;
53
+
54
+ export type CheckTypeParams<
55
+ T extends schemas.$ZodType & checks.$ZodCheck = schemas.$ZodType & checks.$ZodCheck,
56
+ AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "checks" | "error" | "check"> = never,
57
+ > = Params<T, NonNullable<T["_zod"]["isst"] | T["_zod"]["issc"]>, "type" | "checks" | "error" | "check" | AlsoOmit>;
58
+
59
+ // String
60
+ export type $ZodStringParams = TypeParams<schemas.$ZodString<string>, "coerce">;
61
+ export function _string<T extends schemas.$ZodString>(
62
+ Class: util.SchemaClass<T>,
63
+ params?: string | $ZodStringParams
64
+ ): T {
65
+ return new Class({
66
+ type: "string",
67
+ ...util.normalizeParams(params),
68
+ });
69
+ }
70
+
71
+ export function _coercedString<T extends schemas.$ZodString>(
72
+ Class: util.SchemaClass<T>,
73
+ params?: string | $ZodStringParams
74
+ ): T {
75
+ return new Class({
76
+ type: "string",
77
+ coerce: true,
78
+ ...util.normalizeParams(params),
79
+ });
80
+ }
81
+
82
+ export type $ZodStringFormatParams = CheckTypeParams<schemas.$ZodStringFormat, "format" | "coerce">;
83
+ export type $ZodCheckStringFormatParams = CheckParams<checks.$ZodCheckStringFormat, "format">;
84
+ // custom format
85
+
86
+ // Email
87
+ export type $ZodEmailParams = StringFormatParams<schemas.$ZodEmail>;
88
+ export type $ZodCheckEmailParams = CheckStringFormatParams<schemas.$ZodEmail>;
89
+ export function _email<T extends schemas.$ZodEmail>(
90
+ Class: util.SchemaClass<T>,
91
+ params?: string | $ZodEmailParams | $ZodCheckEmailParams
92
+ ): T {
93
+ return new Class({
94
+ type: "string",
95
+ format: "email",
96
+ check: "string_format",
97
+ abort: false,
98
+ ...util.normalizeParams(params),
99
+ });
100
+ }
101
+
102
+ // GUID
103
+ export type $ZodGUIDParams = StringFormatParams<schemas.$ZodGUID, "pattern">;
104
+ export type $ZodCheckGUIDParams = CheckStringFormatParams<schemas.$ZodGUID, "pattern">;
105
+ export function _guid<T extends schemas.$ZodGUID>(
106
+ Class: util.SchemaClass<T>,
107
+ params?: string | $ZodGUIDParams | $ZodCheckGUIDParams
108
+ ): T {
109
+ return new Class({
110
+ type: "string",
111
+ format: "guid",
112
+ check: "string_format",
113
+ abort: false,
114
+ ...util.normalizeParams(params),
115
+ });
116
+ }
117
+
118
+ // UUID
119
+ export type $ZodUUIDParams = StringFormatParams<schemas.$ZodUUID, "pattern">;
120
+ export type $ZodCheckUUIDParams = CheckStringFormatParams<schemas.$ZodUUID, "pattern">;
121
+ export function _uuid<T extends schemas.$ZodUUID>(
122
+ Class: util.SchemaClass<T>,
123
+ params?: string | $ZodUUIDParams | $ZodCheckUUIDParams
124
+ ): T {
125
+ return new Class({
126
+ type: "string",
127
+ format: "uuid",
128
+ check: "string_format",
129
+ abort: false,
130
+ ...util.normalizeParams(params),
131
+ });
132
+ }
133
+
134
+ // UUIDv4
135
+ export type $ZodUUIDv4Params = StringFormatParams<schemas.$ZodUUID, "pattern">;
136
+ export type $ZodCheckUUIDv4Params = CheckStringFormatParams<schemas.$ZodUUID, "pattern">;
137
+ export function _uuidv4<T extends schemas.$ZodUUID>(
138
+ Class: util.SchemaClass<T>,
139
+ params?: string | $ZodUUIDv4Params | $ZodCheckUUIDv4Params
140
+ ): T {
141
+ return new Class({
142
+ type: "string",
143
+ format: "uuid",
144
+ check: "string_format",
145
+ abort: false,
146
+ version: "v4",
147
+ ...util.normalizeParams(params),
148
+ });
149
+ }
150
+
151
+ // UUIDv6
152
+ export type $ZodUUIDv6Params = StringFormatParams<schemas.$ZodUUID, "pattern">;
153
+ export type $ZodCheckUUIDv6Params = CheckStringFormatParams<schemas.$ZodUUID, "pattern">;
154
+ export function _uuidv6<T extends schemas.$ZodUUID>(
155
+ Class: util.SchemaClass<T>,
156
+ params?: string | $ZodUUIDv6Params | $ZodCheckUUIDv6Params
157
+ ): T {
158
+ return new Class({
159
+ type: "string",
160
+ format: "uuid",
161
+ check: "string_format",
162
+ abort: false,
163
+ version: "v6",
164
+ ...util.normalizeParams(params),
165
+ });
166
+ }
167
+
168
+ // UUIDv7
169
+ export type $ZodUUIDv7Params = StringFormatParams<schemas.$ZodUUID, "pattern">;
170
+ export type $ZodCheckUUIDv7Params = CheckStringFormatParams<schemas.$ZodUUID, "pattern">;
171
+ export function _uuidv7<T extends schemas.$ZodUUID>(
172
+ Class: util.SchemaClass<T>,
173
+ params?: string | $ZodUUIDv7Params | $ZodCheckUUIDv7Params
174
+ ): T {
175
+ return new Class({
176
+ type: "string",
177
+ format: "uuid",
178
+ check: "string_format",
179
+ abort: false,
180
+ version: "v7",
181
+ ...util.normalizeParams(params),
182
+ });
183
+ }
184
+
185
+ // URL
186
+ export type $ZodURLParams = StringFormatParams<schemas.$ZodURL>;
187
+ export type $ZodCheckURLParams = CheckStringFormatParams<schemas.$ZodURL>;
188
+ export function _url<T extends schemas.$ZodURL>(
189
+ Class: util.SchemaClass<T>,
190
+ params?: string | $ZodURLParams | $ZodCheckURLParams
191
+ ): T {
192
+ return new Class({
193
+ type: "string",
194
+ format: "url",
195
+ check: "string_format",
196
+ abort: false,
197
+ ...util.normalizeParams(params),
198
+ });
199
+ }
200
+
201
+ // Emoji
202
+ export type $ZodEmojiParams = StringFormatParams<schemas.$ZodEmoji>;
203
+ export type $ZodCheckEmojiParams = CheckStringFormatParams<schemas.$ZodEmoji>;
204
+ export function _emoji<T extends schemas.$ZodEmoji>(
205
+ Class: util.SchemaClass<T>,
206
+ params?: string | $ZodEmojiParams | $ZodCheckEmojiParams
207
+ ): T {
208
+ return new Class({
209
+ type: "string",
210
+ format: "emoji",
211
+ check: "string_format",
212
+ abort: false,
213
+ ...util.normalizeParams(params),
214
+ });
215
+ }
216
+
217
+ // NanoID
218
+ export type $ZodNanoIDParams = StringFormatParams<schemas.$ZodNanoID>;
219
+ export type $ZodCheckNanoIDParams = CheckStringFormatParams<schemas.$ZodNanoID>;
220
+ export function _nanoid<T extends schemas.$ZodNanoID>(
221
+ Class: util.SchemaClass<T>,
222
+ params?: string | $ZodNanoIDParams | $ZodCheckNanoIDParams
223
+ ): T {
224
+ return new Class({
225
+ type: "string",
226
+ format: "nanoid",
227
+ check: "string_format",
228
+ abort: false,
229
+ ...util.normalizeParams(params),
230
+ });
231
+ }
232
+
233
+ // CUID
234
+ export type $ZodCUIDParams = StringFormatParams<schemas.$ZodCUID>;
235
+ export type $ZodCheckCUIDParams = CheckStringFormatParams<schemas.$ZodCUID>;
236
+ export function _cuid<T extends schemas.$ZodCUID>(
237
+ Class: util.SchemaClass<T>,
238
+ params?: string | $ZodCUIDParams | $ZodCheckCUIDParams
239
+ ): T {
240
+ return new Class({
241
+ type: "string",
242
+ format: "cuid",
243
+ check: "string_format",
244
+ abort: false,
245
+ ...util.normalizeParams(params),
246
+ });
247
+ }
248
+
249
+ // CUID2
250
+ export type $ZodCUID2Params = StringFormatParams<schemas.$ZodCUID2>;
251
+ export type $ZodCheckCUID2Params = CheckStringFormatParams<schemas.$ZodCUID2>;
252
+ export function _cuid2<T extends schemas.$ZodCUID2>(
253
+ Class: util.SchemaClass<T>,
254
+ params?: string | $ZodCUID2Params | $ZodCheckCUID2Params
255
+ ): T {
256
+ return new Class({
257
+ type: "string",
258
+ format: "cuid2",
259
+ check: "string_format",
260
+ abort: false,
261
+ ...util.normalizeParams(params),
262
+ });
263
+ }
264
+
265
+ // ULID
266
+ export type $ZodULIDParams = StringFormatParams<schemas.$ZodULID>;
267
+ export type $ZodCheckULIDParams = CheckStringFormatParams<schemas.$ZodULID>;
268
+ export function _ulid<T extends schemas.$ZodULID>(
269
+ Class: util.SchemaClass<T>,
270
+ params?: string | $ZodULIDParams | $ZodCheckULIDParams
271
+ ): T {
272
+ return new Class({
273
+ type: "string",
274
+ format: "ulid",
275
+ check: "string_format",
276
+ abort: false,
277
+ ...util.normalizeParams(params),
278
+ });
279
+ }
280
+
281
+ // XID
282
+ export type $ZodXIDParams = StringFormatParams<schemas.$ZodXID>;
283
+ export type $ZodCheckXIDParams = CheckStringFormatParams<schemas.$ZodXID>;
284
+ export function _xid<T extends schemas.$ZodXID>(
285
+ Class: util.SchemaClass<T>,
286
+ params?: string | $ZodXIDParams | $ZodCheckXIDParams
287
+ ): T {
288
+ return new Class({
289
+ type: "string",
290
+ format: "xid",
291
+ check: "string_format",
292
+ abort: false,
293
+ ...util.normalizeParams(params),
294
+ });
295
+ }
296
+
297
+ // KSUID
298
+ export type $ZodKSUIDParams = StringFormatParams<schemas.$ZodKSUID>;
299
+ export type $ZodCheckKSUIDParams = CheckStringFormatParams<schemas.$ZodKSUID>;
300
+ export function _ksuid<T extends schemas.$ZodKSUID>(
301
+ Class: util.SchemaClass<T>,
302
+ params?: string | $ZodKSUIDParams | $ZodCheckKSUIDParams
303
+ ): T {
304
+ return new Class({
305
+ type: "string",
306
+ format: "ksuid",
307
+ check: "string_format",
308
+ abort: false,
309
+ ...util.normalizeParams(params),
310
+ });
311
+ }
312
+
313
+ // IP
314
+ // export type $ZodIPParams = StringFormatParams<schemas.$ZodIP, "pattern">;
315
+ // export type $ZodCheckIPParams = CheckStringFormatParams<schemas.$ZodIP, "pattern">;
316
+ // export function _ip<T extends schemas.$ZodIP>(
317
+ // Class: util.SchemaClass<T>,
318
+ // params?: string | $ZodIPParams | $ZodCheckIPParams
319
+ // ): T {
320
+ // return new Class({
321
+ // type: "string",
322
+ // format: "ip",
323
+ // check: "string_format",
324
+ // abort: false,
325
+ // ...util.normalizeParams(params),
326
+ // });
327
+ // }
328
+
329
+ // IPv4
330
+ export type $ZodIPv4Params = StringFormatParams<schemas.$ZodIPv4, "pattern">;
331
+ export type $ZodCheckIPv4Params = CheckStringFormatParams<schemas.$ZodIPv4, "pattern">;
332
+ export function _ipv4<T extends schemas.$ZodIPv4>(
333
+ Class: util.SchemaClass<T>,
334
+ params?: string | $ZodIPv4Params | $ZodCheckIPv4Params
335
+ ): T {
336
+ return new Class({
337
+ type: "string",
338
+ format: "ipv4",
339
+ check: "string_format",
340
+ abort: false,
341
+ ...util.normalizeParams(params),
342
+ });
343
+ }
344
+
345
+ // IPv6
346
+ export type $ZodIPv6Params = StringFormatParams<schemas.$ZodIPv6, "pattern">;
347
+ export type $ZodCheckIPv6Params = CheckStringFormatParams<schemas.$ZodIPv6, "pattern">;
348
+ export function _ipv6<T extends schemas.$ZodIPv6>(
349
+ Class: util.SchemaClass<T>,
350
+ params?: string | $ZodIPv6Params | $ZodCheckIPv6Params
351
+ ): T {
352
+ return new Class({
353
+ type: "string",
354
+ format: "ipv6",
355
+ check: "string_format",
356
+ abort: false,
357
+ ...util.normalizeParams(params),
358
+ });
359
+ }
360
+
361
+ // CIDRv4
362
+ export type $ZodCIDRv4Params = StringFormatParams<schemas.$ZodCIDRv4, "pattern">;
363
+ export type $ZodCheckCIDRv4Params = CheckStringFormatParams<schemas.$ZodCIDRv4, "pattern">;
364
+ export function _cidrv4<T extends schemas.$ZodCIDRv4>(
365
+ Class: util.SchemaClass<T>,
366
+ params?: string | $ZodCIDRv4Params | $ZodCheckCIDRv4Params
367
+ ): T {
368
+ return new Class({
369
+ type: "string",
370
+ format: "cidrv4",
371
+ check: "string_format",
372
+ abort: false,
373
+ ...util.normalizeParams(params),
374
+ });
375
+ }
376
+
377
+ // CIDRv6
378
+ export type $ZodCIDRv6Params = StringFormatParams<schemas.$ZodCIDRv6, "pattern">;
379
+ export type $ZodCheckCIDRv6Params = CheckStringFormatParams<schemas.$ZodCIDRv6, "pattern">;
380
+ export function _cidrv6<T extends schemas.$ZodCIDRv6>(
381
+ Class: util.SchemaClass<T>,
382
+ params?: string | $ZodCIDRv6Params | $ZodCheckCIDRv6Params
383
+ ): T {
384
+ return new Class({
385
+ type: "string",
386
+ format: "cidrv6",
387
+ check: "string_format",
388
+ abort: false,
389
+ ...util.normalizeParams(params),
390
+ });
391
+ }
392
+
393
+ // Base64
394
+ export type $ZodBase64Params = StringFormatParams<schemas.$ZodBase64, "pattern">;
395
+ export type $ZodCheckBase64Params = CheckStringFormatParams<schemas.$ZodBase64, "pattern">;
396
+ export function _base64<T extends schemas.$ZodBase64>(
397
+ Class: util.SchemaClass<T>,
398
+ params?: string | $ZodBase64Params | $ZodCheckBase64Params
399
+ ): T {
400
+ return new Class({
401
+ type: "string",
402
+ format: "base64",
403
+ check: "string_format",
404
+ abort: false,
405
+ ...util.normalizeParams(params),
406
+ });
407
+ }
408
+
409
+ // base64url
410
+ export type $ZodBase64URLParams = StringFormatParams<schemas.$ZodBase64URL, "pattern">;
411
+ export type $ZodCheckBase64URLParams = CheckStringFormatParams<schemas.$ZodBase64URL, "pattern">;
412
+ export function _base64url<T extends schemas.$ZodBase64URL>(
413
+ Class: util.SchemaClass<T>,
414
+ params?: string | $ZodBase64URLParams | $ZodCheckBase64URLParams
415
+ ): T {
416
+ return new Class({
417
+ type: "string",
418
+ format: "base64url",
419
+ check: "string_format",
420
+ abort: false,
421
+ ...util.normalizeParams(params),
422
+ });
423
+ }
424
+
425
+ // E164
426
+ export type $ZodE164Params = StringFormatParams<schemas.$ZodE164>;
427
+ export type $ZodCheckE164Params = CheckStringFormatParams<schemas.$ZodE164>;
428
+ export function _e164<T extends schemas.$ZodE164>(
429
+ Class: util.SchemaClass<T>,
430
+ params?: string | $ZodE164Params | $ZodCheckE164Params
431
+ ): T {
432
+ return new Class({
433
+ type: "string",
434
+ format: "e164",
435
+ check: "string_format",
436
+ abort: false,
437
+ ...util.normalizeParams(params),
438
+ });
439
+ }
440
+
441
+ // JWT
442
+ export type $ZodJWTParams = StringFormatParams<schemas.$ZodJWT, "pattern">;
443
+ export type $ZodCheckJWTParams = CheckStringFormatParams<schemas.$ZodJWT, "pattern">;
444
+ export function _jwt<T extends schemas.$ZodJWT>(
445
+ Class: util.SchemaClass<T>,
446
+ params?: string | $ZodJWTParams | $ZodCheckJWTParams
447
+ ): T {
448
+ return new Class({
449
+ type: "string",
450
+ format: "jwt",
451
+ check: "string_format",
452
+ abort: false,
453
+ ...util.normalizeParams(params),
454
+ });
455
+ }
456
+
457
+ export const TimePrecision = {
458
+ Any: null,
459
+ Minute: -1,
460
+ Second: 0,
461
+ Millisecond: 3,
462
+ Microsecond: 6,
463
+ } as const;
464
+ // ISODateTime
465
+ export type $ZodISODateTimeParams = StringFormatParams<schemas.$ZodISODateTime, "pattern">;
466
+ export type $ZodCheckISODateTimeParams = CheckStringFormatParams<schemas.$ZodISODateTime, "pattern">;
467
+ export function _isoDateTime<T extends schemas.$ZodISODateTime>(
468
+ Class: util.SchemaClass<T>,
469
+ params?: string | $ZodISODateTimeParams | $ZodCheckISODateTimeParams
470
+ ): T {
471
+ return new Class({
472
+ type: "string",
473
+ format: "datetime",
474
+ check: "string_format",
475
+ offset: false,
476
+ local: false,
477
+ precision: null,
478
+ ...util.normalizeParams(params),
479
+ });
480
+ }
481
+
482
+ // ISODate
483
+ export type $ZodISODateParams = StringFormatParams<schemas.$ZodISODate, "pattern">;
484
+ export type $ZodCheckISODateParams = CheckStringFormatParams<schemas.$ZodISODate, "pattern">;
485
+ export function _isoDate<T extends schemas.$ZodISODate>(
486
+ Class: util.SchemaClass<T>,
487
+ params?: string | $ZodISODateParams | $ZodCheckISODateParams
488
+ ): T {
489
+ return new Class({
490
+ type: "string",
491
+ format: "date",
492
+ check: "string_format",
493
+ ...util.normalizeParams(params),
494
+ });
495
+ }
496
+
497
+ // ISOTime
498
+ export type $ZodISOTimeParams = StringFormatParams<schemas.$ZodISOTime, "pattern">;
499
+ export type $ZodCheckISOTimeParams = CheckStringFormatParams<schemas.$ZodISOTime, "pattern">;
500
+ export function _isoTime<T extends schemas.$ZodISOTime>(
501
+ Class: util.SchemaClass<T>,
502
+ params?: string | $ZodISOTimeParams | $ZodCheckISOTimeParams
503
+ ): T {
504
+ return new Class({
505
+ type: "string",
506
+ format: "time",
507
+ check: "string_format",
508
+ precision: null,
509
+ ...util.normalizeParams(params),
510
+ });
511
+ }
512
+
513
+ // ISODuration
514
+ export type $ZodISODurationParams = StringFormatParams<schemas.$ZodISODuration>;
515
+ export type $ZodCheckISODurationParams = CheckStringFormatParams<schemas.$ZodISODuration>;
516
+ export function _isoDuration<T extends schemas.$ZodISODuration>(
517
+ Class: util.SchemaClass<T>,
518
+ params?: string | $ZodISODurationParams | $ZodCheckISODurationParams
519
+ ): T {
520
+ return new Class({
521
+ type: "string",
522
+ format: "duration",
523
+ check: "string_format",
524
+ ...util.normalizeParams(params),
525
+ });
526
+ }
527
+
528
+ // Number
529
+ export type $ZodNumberParams = TypeParams<schemas.$ZodNumber<number>, "coerce">;
530
+ export type $ZodNumberFormatParams = CheckTypeParams<schemas.$ZodNumberFormat, "format" | "coerce">;
531
+ export type $ZodCheckNumberFormatParams = CheckParams<checks.$ZodCheckNumberFormat, "format">;
532
+ export function _number<T extends schemas.$ZodNumber>(
533
+ Class: util.SchemaClass<T>,
534
+ params?: string | $ZodNumberParams
535
+ ): T {
536
+ return new Class({
537
+ type: "number",
538
+ checks: [],
539
+ ...util.normalizeParams(params),
540
+ });
541
+ }
542
+
543
+ export function _coercedNumber<T extends schemas.$ZodNumber>(
544
+ Class: util.SchemaClass<T>,
545
+ params?: string | $ZodNumberParams
546
+ ): T {
547
+ return new Class({
548
+ type: "number",
549
+ coerce: true,
550
+ checks: [],
551
+ ...util.normalizeParams(params),
552
+ });
553
+ }
554
+
555
+ export function _int<T extends schemas.$ZodNumberFormat>(
556
+ Class: util.SchemaClass<T>,
557
+ params?: string | $ZodCheckNumberFormatParams
558
+ ): T {
559
+ return new Class({
560
+ type: "number",
561
+ check: "number_format",
562
+ abort: false,
563
+ format: "safeint",
564
+ ...util.normalizeParams(params),
565
+ });
566
+ }
567
+ export function _float32<T extends schemas.$ZodNumberFormat>(
568
+ Class: util.SchemaClass<T>,
569
+ params?: string | $ZodCheckNumberFormatParams
570
+ ): T {
571
+ return new Class({
572
+ type: "number",
573
+ check: "number_format",
574
+ abort: false,
575
+ format: "float32",
576
+ ...util.normalizeParams(params),
577
+ });
578
+ }
579
+ export function _float64<T extends schemas.$ZodNumberFormat>(
580
+ Class: util.SchemaClass<T>,
581
+ params?: string | $ZodCheckNumberFormatParams
582
+ ): T {
583
+ return new Class({
584
+ type: "number",
585
+ check: "number_format",
586
+ abort: false,
587
+ format: "float64",
588
+ ...util.normalizeParams(params),
589
+ });
590
+ }
591
+ export function _int32<T extends schemas.$ZodNumberFormat>(
592
+ Class: util.SchemaClass<T>,
593
+ params?: string | $ZodCheckNumberFormatParams
594
+ ): T {
595
+ return new Class({
596
+ type: "number",
597
+ check: "number_format",
598
+ abort: false,
599
+ format: "int32",
600
+ ...util.normalizeParams(params),
601
+ });
602
+ }
603
+ export function _uint32<T extends schemas.$ZodNumberFormat>(
604
+ Class: util.SchemaClass<T>,
605
+ params?: string | $ZodCheckNumberFormatParams
606
+ ): T {
607
+ return new Class({
608
+ type: "number",
609
+ check: "number_format",
610
+ abort: false,
611
+ format: "uint32",
612
+ ...util.normalizeParams(params),
613
+ });
614
+ }
615
+
616
+ // Boolean
617
+ export type $ZodBooleanParams = TypeParams<schemas.$ZodBoolean<boolean>, "coerce">;
618
+ export function _boolean<T extends schemas.$ZodBoolean>(
619
+ Class: util.SchemaClass<T>,
620
+ params?: string | $ZodBooleanParams
621
+ ): T {
622
+ return new Class({
623
+ type: "boolean",
624
+ ...util.normalizeParams(params),
625
+ });
626
+ }
627
+ export function _coercedBoolean<T extends schemas.$ZodBoolean>(
628
+ Class: util.SchemaClass<T>,
629
+ params?: string | $ZodBooleanParams
630
+ ): T {
631
+ return new Class({
632
+ type: "boolean",
633
+ coerce: true,
634
+ ...util.normalizeParams(params),
635
+ });
636
+ }
637
+
638
+ // BigInt
639
+ export type $ZodBigIntParams = TypeParams<schemas.$ZodBigInt<bigint>>;
640
+ export type $ZodBigIntFormatParams = CheckTypeParams<schemas.$ZodBigIntFormat, "format" | "coerce">;
641
+ export type $ZodCheckBigIntFormatParams = CheckParams<checks.$ZodCheckBigIntFormat, "format">;
642
+ export function _bigint<T extends schemas.$ZodBigInt>(
643
+ Class: util.SchemaClass<T>,
644
+ params?: string | $ZodBigIntParams
645
+ ): T {
646
+ return new Class({
647
+ type: "bigint",
648
+ ...util.normalizeParams(params),
649
+ });
650
+ }
651
+ export function _coercedBigint<T extends schemas.$ZodBigInt>(
652
+ Class: util.SchemaClass<T>,
653
+ params?: string | $ZodBigIntParams
654
+ ): T {
655
+ return new Class({
656
+ type: "bigint",
657
+ coerce: true,
658
+ ...util.normalizeParams(params),
659
+ });
660
+ }
661
+
662
+ export function _int64<T extends schemas.$ZodBigIntFormat>(
663
+ Class: util.SchemaClass<T>,
664
+ params?: string | $ZodBigIntFormatParams
665
+ ): T {
666
+ return new Class({
667
+ type: "bigint",
668
+ check: "bigint_format",
669
+ abort: false,
670
+ format: "int64",
671
+ ...util.normalizeParams(params),
672
+ });
673
+ }
674
+ export function _uint64<T extends schemas.$ZodBigIntFormat>(
675
+ Class: util.SchemaClass<T>,
676
+ params?: string | $ZodBigIntFormatParams
677
+ ): T {
678
+ return new Class({
679
+ type: "bigint",
680
+ check: "bigint_format",
681
+ abort: false,
682
+ format: "uint64",
683
+ ...util.normalizeParams(params),
684
+ });
685
+ }
686
+
687
+ // Symbol
688
+ export type $ZodSymbolParams = TypeParams<schemas.$ZodSymbol>;
689
+ export function _symbol<T extends schemas.$ZodSymbol>(
690
+ Class: util.SchemaClass<T>,
691
+ params?: string | $ZodSymbolParams
692
+ ): T {
693
+ return new Class({
694
+ type: "symbol",
695
+ ...util.normalizeParams(params),
696
+ });
697
+ }
698
+
699
+ // Undefined
700
+ export type $ZodUndefinedParams = TypeParams<schemas.$ZodUndefined>;
701
+ export function _undefined<T extends schemas.$ZodUndefined>(
702
+ Class: util.SchemaClass<T>,
703
+ params?: string | $ZodUndefinedParams
704
+ ): T {
705
+ return new Class({
706
+ type: "undefined",
707
+ ...util.normalizeParams(params),
708
+ });
709
+ }
710
+
711
+ // Null
712
+ export type $ZodNullParams = TypeParams<schemas.$ZodNull>;
713
+ export function _null<T extends schemas.$ZodNull>(Class: util.SchemaClass<T>, params?: string | $ZodNullParams): T {
714
+ return new Class({
715
+ type: "null",
716
+ ...util.normalizeParams(params),
717
+ });
718
+ }
719
+
720
+ // Any
721
+ export type $ZodAnyParams = TypeParams<schemas.$ZodAny>;
722
+ export function _any<T extends schemas.$ZodAny>(Class: util.SchemaClass<T>): T {
723
+ return new Class({
724
+ type: "any",
725
+ });
726
+ }
727
+
728
+ // Unknown
729
+ export type $ZodUnknownParams = TypeParams<schemas.$ZodUnknown>;
730
+ export function _unknown<T extends schemas.$ZodUnknown>(Class: util.SchemaClass<T>): T {
731
+ return new Class({
732
+ type: "unknown",
733
+ });
734
+ }
735
+
736
+ // Never
737
+ export type $ZodNeverParams = TypeParams<schemas.$ZodNever>;
738
+ export function _never<T extends schemas.$ZodNever>(Class: util.SchemaClass<T>, params?: string | $ZodNeverParams): T {
739
+ return new Class({
740
+ type: "never",
741
+ ...util.normalizeParams(params),
742
+ });
743
+ }
744
+
745
+ // Void
746
+ export type $ZodVoidParams = TypeParams<schemas.$ZodVoid>;
747
+ export function _void<T extends schemas.$ZodVoid>(Class: util.SchemaClass<T>, params?: string | $ZodVoidParams): T {
748
+ return new Class({
749
+ type: "void",
750
+ ...util.normalizeParams(params),
751
+ });
752
+ }
753
+
754
+ // Date
755
+ export type $ZodDateParams = TypeParams<schemas.$ZodDate, "coerce">;
756
+ export function _date<T extends schemas.$ZodDate>(Class: util.SchemaClass<T>, params?: string | $ZodDateParams): T {
757
+ return new Class({
758
+ type: "date",
759
+ ...util.normalizeParams(params),
760
+ });
761
+ }
762
+ export function _coercedDate<T extends schemas.$ZodDate>(
763
+ Class: util.SchemaClass<T>,
764
+ params?: string | $ZodDateParams
765
+ ): T {
766
+ return new Class({
767
+ type: "date",
768
+ coerce: true,
769
+ ...util.normalizeParams(params),
770
+ });
771
+ }
772
+
773
+ // NaN
774
+ export type $ZodNaNParams = TypeParams<schemas.$ZodNaN>;
775
+ export function _nan<T extends schemas.$ZodNaN>(Class: util.SchemaClass<T>, params?: string | $ZodNaNParams): T {
776
+ return new Class({
777
+ type: "nan",
778
+ ...util.normalizeParams(params),
779
+ });
780
+ }
781
+
782
+ // export type $ZodCheckParams = CheckParams<checks.$ZodCheck, "abort">;
783
+
784
+ export type $ZodCheckLessThanParams = CheckParams<checks.$ZodCheckLessThan, "inclusive" | "value">;
785
+ export function _lt(
786
+ value: util.Numeric,
787
+ params?: string | $ZodCheckLessThanParams
788
+ ): checks.$ZodCheckLessThan<util.Numeric> {
789
+ return new checks.$ZodCheckLessThan({
790
+ check: "less_than",
791
+ ...util.normalizeParams(params),
792
+ value,
793
+ inclusive: false,
794
+ });
795
+ }
796
+
797
+ export function _lte(
798
+ value: util.Numeric,
799
+ params?: string | $ZodCheckLessThanParams
800
+ ): checks.$ZodCheckLessThan<util.Numeric> {
801
+ return new checks.$ZodCheckLessThan({
802
+ check: "less_than",
803
+
804
+ ...util.normalizeParams(params),
805
+ value,
806
+ inclusive: true,
807
+ });
808
+ }
809
+ export {
810
+ /** @deprecated Use `z.lte()` instead. */
811
+ _lte as _max,
812
+ };
813
+
814
+ // ZodCheckGreaterThan
815
+ export type $ZodCheckGreaterThanParams = CheckParams<checks.$ZodCheckGreaterThan, "inclusive" | "value">;
816
+ export function _gt(value: util.Numeric, params?: string | $ZodCheckGreaterThanParams): checks.$ZodCheckGreaterThan {
817
+ return new checks.$ZodCheckGreaterThan({
818
+ check: "greater_than",
819
+
820
+ ...util.normalizeParams(params),
821
+ value,
822
+ inclusive: false,
823
+ });
824
+ }
825
+
826
+ export function _gte(value: util.Numeric, params?: string | $ZodCheckGreaterThanParams): checks.$ZodCheckGreaterThan {
827
+ return new checks.$ZodCheckGreaterThan({
828
+ check: "greater_than",
829
+ ...util.normalizeParams(params),
830
+ value,
831
+ inclusive: true,
832
+ });
833
+ }
834
+
835
+ export {
836
+ /** @deprecated Use `z.gte()` instead. */
837
+ _gte as _min,
838
+ };
839
+
840
+ export function _positive(params?: string | $ZodCheckGreaterThanParams): checks.$ZodCheckGreaterThan {
841
+ return _gt(0, params);
842
+ }
843
+
844
+ // negative
845
+ export function _negative(params?: string | $ZodCheckLessThanParams): checks.$ZodCheckLessThan {
846
+ return _lt(0, params);
847
+ }
848
+
849
+ // nonpositive
850
+ export function _nonpositive(params?: string | $ZodCheckLessThanParams): checks.$ZodCheckLessThan {
851
+ return _lte(0, params);
852
+ }
853
+
854
+ // nonnegative
855
+ export function _nonnegative(params?: string | $ZodCheckGreaterThanParams): checks.$ZodCheckGreaterThan {
856
+ return _gte(0, params);
857
+ }
858
+
859
+ export type $ZodCheckMultipleOfParams = CheckParams<checks.$ZodCheckMultipleOf, "value">;
860
+ export function _multipleOf(
861
+ value: number | bigint,
862
+ params?: string | $ZodCheckMultipleOfParams
863
+ ): checks.$ZodCheckMultipleOf {
864
+ return new checks.$ZodCheckMultipleOf({
865
+ check: "multiple_of",
866
+ ...util.normalizeParams(params),
867
+ value,
868
+ });
869
+ }
870
+
871
+ export type $ZodCheckMaxSizeParams = CheckParams<checks.$ZodCheckMaxSize, "maximum">;
872
+ export function _maxSize(
873
+ maximum: number,
874
+ params?: string | $ZodCheckMaxSizeParams
875
+ ): checks.$ZodCheckMaxSize<util.HasSize> {
876
+ return new checks.$ZodCheckMaxSize({
877
+ check: "max_size",
878
+ ...util.normalizeParams(params),
879
+ maximum,
880
+ });
881
+ }
882
+
883
+ export type $ZodCheckMinSizeParams = CheckParams<checks.$ZodCheckMinSize, "minimum">;
884
+ export function _minSize(
885
+ minimum: number,
886
+ params?: string | $ZodCheckMinSizeParams
887
+ ): checks.$ZodCheckMinSize<util.HasSize> {
888
+ return new checks.$ZodCheckMinSize({
889
+ check: "min_size",
890
+ ...util.normalizeParams(params),
891
+ minimum,
892
+ });
893
+ }
894
+
895
+ export type $ZodCheckSizeEqualsParams = CheckParams<checks.$ZodCheckSizeEquals, "size">;
896
+ export function _size(
897
+ size: number,
898
+ params?: string | $ZodCheckSizeEqualsParams
899
+ ): checks.$ZodCheckSizeEquals<util.HasSize> {
900
+ return new checks.$ZodCheckSizeEquals({
901
+ check: "size_equals",
902
+ ...util.normalizeParams(params),
903
+ size,
904
+ });
905
+ }
906
+
907
+ export type $ZodCheckMaxLengthParams = CheckParams<checks.$ZodCheckMaxLength, "maximum">;
908
+ export function _maxLength(
909
+ maximum: number,
910
+ params?: string | $ZodCheckMaxLengthParams
911
+ ): checks.$ZodCheckMaxLength<util.HasLength> {
912
+ const ch = new checks.$ZodCheckMaxLength({
913
+ check: "max_length",
914
+ ...util.normalizeParams(params),
915
+ maximum,
916
+ });
917
+ return ch;
918
+ }
919
+
920
+ export type $ZodCheckMinLengthParams = CheckParams<checks.$ZodCheckMinLength, "minimum">;
921
+ export function _minLength(
922
+ minimum: number,
923
+ params?: string | $ZodCheckMinLengthParams
924
+ ): checks.$ZodCheckMinLength<util.HasLength> {
925
+ return new checks.$ZodCheckMinLength({
926
+ check: "min_length",
927
+ ...util.normalizeParams(params),
928
+ minimum,
929
+ });
930
+ }
931
+
932
+ export type $ZodCheckLengthEqualsParams = CheckParams<checks.$ZodCheckLengthEquals, "length">;
933
+ export function _length(
934
+ length: number,
935
+ params?: string | $ZodCheckLengthEqualsParams
936
+ ): checks.$ZodCheckLengthEquals<util.HasLength> {
937
+ return new checks.$ZodCheckLengthEquals({
938
+ check: "length_equals",
939
+ ...util.normalizeParams(params),
940
+ length,
941
+ });
942
+ }
943
+
944
+ export type $ZodCheckRegexParams = CheckParams<checks.$ZodCheckRegex, "format" | "pattern">;
945
+ export function _regex(pattern: RegExp, params?: string | $ZodCheckRegexParams): checks.$ZodCheckRegex {
946
+ return new checks.$ZodCheckRegex({
947
+ check: "string_format",
948
+ format: "regex",
949
+ ...util.normalizeParams(params),
950
+ pattern,
951
+ });
952
+ }
953
+
954
+ export type $ZodCheckLowerCaseParams = CheckParams<checks.$ZodCheckLowerCase, "format">;
955
+ export function _lowercase(params?: string | $ZodCheckLowerCaseParams): checks.$ZodCheckLowerCase {
956
+ return new checks.$ZodCheckLowerCase({
957
+ check: "string_format",
958
+ format: "lowercase",
959
+ ...util.normalizeParams(params),
960
+ });
961
+ }
962
+
963
+ export type $ZodCheckUpperCaseParams = CheckParams<checks.$ZodCheckUpperCase, "format">;
964
+
965
+ export function _uppercase(params?: string | $ZodCheckUpperCaseParams): checks.$ZodCheckUpperCase {
966
+ return new checks.$ZodCheckUpperCase({
967
+ check: "string_format",
968
+ format: "uppercase",
969
+ ...util.normalizeParams(params),
970
+ });
971
+ }
972
+
973
+ export type $ZodCheckIncludesParams = CheckParams<checks.$ZodCheckIncludes, "includes" | "format" | "pattern">;
974
+ export function _includes(includes: string, params?: string | $ZodCheckIncludesParams): checks.$ZodCheckIncludes {
975
+ return new checks.$ZodCheckIncludes({
976
+ check: "string_format",
977
+ format: "includes",
978
+ ...util.normalizeParams(params),
979
+ includes,
980
+ });
981
+ }
982
+ export type $ZodCheckStartsWithParams = CheckParams<checks.$ZodCheckStartsWith, "prefix" | "format" | "pattern">;
983
+ export function _startsWith(prefix: string, params?: string | $ZodCheckStartsWithParams): checks.$ZodCheckStartsWith {
984
+ return new checks.$ZodCheckStartsWith({
985
+ check: "string_format",
986
+ format: "starts_with",
987
+ ...util.normalizeParams(params),
988
+ prefix,
989
+ });
990
+ }
991
+
992
+ export type $ZodCheckEndsWithParams = CheckParams<checks.$ZodCheckEndsWith, "suffix" | "format" | "pattern">;
993
+
994
+ export function _endsWith(suffix: string, params?: string | $ZodCheckEndsWithParams): checks.$ZodCheckEndsWith {
995
+ return new checks.$ZodCheckEndsWith({
996
+ check: "string_format",
997
+ format: "ends_with",
998
+ ...util.normalizeParams(params),
999
+ suffix,
1000
+ });
1001
+ }
1002
+
1003
+ export type $ZodCheckPropertyParams = CheckParams<checks.$ZodCheckProperty, "property" | "schema">;
1004
+ export function _property<K extends string, T extends schemas.$ZodType>(
1005
+ property: K,
1006
+ schema: T,
1007
+ params?: string | $ZodCheckPropertyParams
1008
+ ): checks.$ZodCheckProperty<{ [k in K]: core.output<T> }> {
1009
+ return new checks.$ZodCheckProperty({
1010
+ check: "property",
1011
+ property,
1012
+ schema,
1013
+ ...util.normalizeParams(params),
1014
+ });
1015
+ }
1016
+
1017
+ export type $ZodCheckMimeTypeParams = CheckParams<checks.$ZodCheckMimeType, "mime">;
1018
+ export function _mime(types: util.MimeTypes[], params?: string | $ZodCheckMimeTypeParams): checks.$ZodCheckMimeType {
1019
+ return new checks.$ZodCheckMimeType({
1020
+ check: "mime_type",
1021
+ mime: types,
1022
+ ...util.normalizeParams(params),
1023
+ });
1024
+ }
1025
+
1026
+ export function _overwrite<T>(tx: (input: T) => T): checks.$ZodCheckOverwrite<T> {
1027
+ return new checks.$ZodCheckOverwrite({
1028
+ check: "overwrite",
1029
+ tx,
1030
+ }) as checks.$ZodCheckOverwrite<T>;
1031
+ }
1032
+ // normalize
1033
+ export function _normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): checks.$ZodCheckOverwrite<string> {
1034
+ return _overwrite((input) => input.normalize(form));
1035
+ }
1036
+
1037
+ // trim
1038
+ export function _trim(): checks.$ZodCheckOverwrite<string> {
1039
+ return _overwrite((input) => input.trim());
1040
+ }
1041
+ // toLowerCase
1042
+ export function _toLowerCase(): checks.$ZodCheckOverwrite<string> {
1043
+ return _overwrite((input) => input.toLowerCase());
1044
+ }
1045
+ // toUpperCase
1046
+ export function _toUpperCase(): checks.$ZodCheckOverwrite<string> {
1047
+ return _overwrite((input) => input.toUpperCase());
1048
+ }
1049
+
1050
+ /////// collections ///////
1051
+
1052
+ // Array
1053
+ export type $ZodArrayParams = TypeParams<schemas.$ZodArray, "element">;
1054
+ export function _array<T extends schemas.$ZodType>(
1055
+ Class: util.SchemaClass<schemas.$ZodArray>,
1056
+ element: T,
1057
+ params?: string | $ZodArrayParams
1058
+ ): schemas.$ZodArray<T> {
1059
+ return new Class({
1060
+ type: "array",
1061
+ element,
1062
+ // get element() {
1063
+ // return element;
1064
+ // },
1065
+ ...util.normalizeParams(params),
1066
+ }) as any;
1067
+ }
1068
+
1069
+ export type $ZodObjectParams = TypeParams<schemas.$ZodObject, "shape" | "catchall">;
1070
+
1071
+ // ZodUnion
1072
+ export type $ZodUnionParams = TypeParams<schemas.$ZodUnion, "options">;
1073
+ export function _union<const T extends readonly schemas.$ZodObject[]>(
1074
+ Class: util.SchemaClass<schemas.$ZodUnion>,
1075
+ options: T,
1076
+ params?: string | $ZodUnionParams
1077
+ ): schemas.$ZodUnion<T> {
1078
+ return new Class({
1079
+ type: "union",
1080
+ options,
1081
+ ...util.normalizeParams(params),
1082
+ }) as any;
1083
+ }
1084
+
1085
+ // ZodDiscriminatedUnion
1086
+ export interface $ZodTypeDiscriminableInternals extends schemas.$ZodTypeInternals {
1087
+ propValues: util.PropValues;
1088
+ }
1089
+
1090
+ export interface $ZodTypeDiscriminable extends schemas.$ZodType {
1091
+ _zod: $ZodTypeDiscriminableInternals;
1092
+ }
1093
+ export type $ZodDiscriminatedUnionParams = TypeParams<schemas.$ZodDiscriminatedUnion, "options" | "discriminator">;
1094
+ export function _discriminatedUnion<Types extends [$ZodTypeDiscriminable, ...$ZodTypeDiscriminable[]]>(
1095
+ Class: util.SchemaClass<schemas.$ZodDiscriminatedUnion>,
1096
+ discriminator: string,
1097
+ options: Types,
1098
+ params?: string | $ZodDiscriminatedUnionParams
1099
+ ): schemas.$ZodDiscriminatedUnion<Types> {
1100
+ return new Class({
1101
+ type: "union",
1102
+ options,
1103
+ discriminator,
1104
+ ...util.normalizeParams(params),
1105
+ }) as any;
1106
+ }
1107
+
1108
+ // ZodIntersection
1109
+ export type $ZodIntersectionParams = TypeParams<schemas.$ZodIntersection, "left" | "right">;
1110
+ export function _intersection<T extends schemas.$ZodObject, U extends schemas.$ZodObject>(
1111
+ Class: util.SchemaClass<schemas.$ZodIntersection>,
1112
+ left: T,
1113
+ right: U
1114
+ ): schemas.$ZodIntersection<T, U> {
1115
+ return new Class({
1116
+ type: "intersection",
1117
+ left,
1118
+ right,
1119
+ }) as any;
1120
+ }
1121
+
1122
+ // ZodTuple
1123
+ export type $ZodTupleParams = TypeParams<schemas.$ZodTuple, "items" | "rest">;
1124
+ export function _tuple<T extends readonly [schemas.$ZodType, ...schemas.$ZodType[]]>(
1125
+ Class: util.SchemaClass<schemas.$ZodTuple>,
1126
+ items: T,
1127
+ params?: string | $ZodTupleParams
1128
+ ): schemas.$ZodTuple<T, null>;
1129
+ export function _tuple<T extends readonly [schemas.$ZodType, ...schemas.$ZodType[]], Rest extends schemas.$ZodType>(
1130
+ Class: util.SchemaClass<schemas.$ZodTuple>,
1131
+ items: T,
1132
+ rest: Rest,
1133
+ params?: string | $ZodTupleParams
1134
+ ): schemas.$ZodTuple<T, Rest>;
1135
+ // export function _tuple(
1136
+ // Class: util.SchemaClass<schemas.$ZodTuple>,
1137
+ // items: [],
1138
+ // params?: string | $ZodTupleParams
1139
+ // ): schemas.$ZodTuple<[], null>;
1140
+ export function _tuple(
1141
+ Class: util.SchemaClass<schemas.$ZodTuple>,
1142
+ items: schemas.$ZodType[],
1143
+ _paramsOrRest?: string | $ZodTupleParams | schemas.$ZodType,
1144
+ _params?: string | $ZodTupleParams
1145
+ ) {
1146
+ const hasRest = _paramsOrRest instanceof schemas.$ZodType;
1147
+ const params = hasRest ? _params : _paramsOrRest;
1148
+ const rest = hasRest ? _paramsOrRest : null;
1149
+ return new Class({
1150
+ type: "tuple",
1151
+ items,
1152
+ rest,
1153
+ ...util.normalizeParams(params),
1154
+ });
1155
+ }
1156
+
1157
+ // ZodRecord
1158
+ export type $ZodRecordParams = TypeParams<schemas.$ZodRecord, "keyType" | "valueType">;
1159
+ export function _record<Key extends schemas.$ZodRecordKey, Value extends schemas.$ZodObject>(
1160
+ Class: util.SchemaClass<schemas.$ZodRecord>,
1161
+ keyType: Key,
1162
+ valueType: Value,
1163
+ params?: string | $ZodRecordParams
1164
+ ): schemas.$ZodRecord<Key, Value> {
1165
+ return new Class({
1166
+ type: "record",
1167
+ keyType,
1168
+ valueType,
1169
+ ...util.normalizeParams(params),
1170
+ }) as any;
1171
+ }
1172
+
1173
+ // ZodMap
1174
+ export type $ZodMapParams = TypeParams<schemas.$ZodMap, "keyType" | "valueType">;
1175
+ export function _map<Key extends schemas.$ZodObject, Value extends schemas.$ZodObject>(
1176
+ Class: util.SchemaClass<schemas.$ZodMap>,
1177
+ keyType: Key,
1178
+ valueType: Value,
1179
+ params?: string | $ZodMapParams
1180
+ ): schemas.$ZodMap<Key, Value> {
1181
+ return new Class({
1182
+ type: "map",
1183
+ keyType,
1184
+ valueType,
1185
+ ...util.normalizeParams(params),
1186
+ }) as any;
1187
+ }
1188
+
1189
+ // ZodSet
1190
+ export type $ZodSetParams = TypeParams<schemas.$ZodSet, "valueType">;
1191
+ export function _set<Value extends schemas.$ZodObject>(
1192
+ Class: util.SchemaClass<schemas.$ZodSet>,
1193
+ valueType: Value,
1194
+ params?: string | $ZodSetParams
1195
+ ): schemas.$ZodSet<Value> {
1196
+ return new Class({
1197
+ type: "set",
1198
+ valueType,
1199
+ ...util.normalizeParams(params),
1200
+ }) as any;
1201
+ }
1202
+
1203
+ // ZodEnum
1204
+ export type $ZodEnumParams = TypeParams<schemas.$ZodEnum, "entries">;
1205
+ export function _enum<const T extends string[]>(
1206
+ Class: util.SchemaClass<schemas.$ZodEnum>,
1207
+ values: T,
1208
+ params?: string | $ZodEnumParams
1209
+ ): schemas.$ZodEnum<util.ToEnum<T[number]>>;
1210
+ export function _enum<T extends util.EnumLike>(
1211
+ Class: util.SchemaClass<schemas.$ZodEnum>,
1212
+ entries: T,
1213
+ params?: string | $ZodEnumParams
1214
+ ): schemas.$ZodEnum<T>;
1215
+ export function _enum(Class: util.SchemaClass<schemas.$ZodEnum>, values: any, params?: string | $ZodEnumParams) {
1216
+ const entries: any = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
1217
+ // if (Array.isArray(values)) {
1218
+ // for (const value of values) {
1219
+ // entries[value] = value;
1220
+ // }
1221
+ // } else {
1222
+ // Object.assign(entries, values);
1223
+ // }
1224
+ // const entries: util.EnumLike = {};
1225
+ // for (const val of values) {
1226
+ // entries[val] = val;
1227
+ // }
1228
+
1229
+ return new Class({
1230
+ type: "enum",
1231
+ entries,
1232
+ ...util.normalizeParams(params),
1233
+ }) as any;
1234
+ }
1235
+
1236
+ /** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
1237
+ *
1238
+ * ```ts
1239
+ * enum Colors { red, green, blue }
1240
+ * z.enum(Colors);
1241
+ * ```
1242
+ */
1243
+ export function _nativeEnum<T extends util.EnumLike>(
1244
+ Class: util.SchemaClass<schemas.$ZodEnum>,
1245
+ entries: T,
1246
+ params?: string | $ZodEnumParams
1247
+ ): schemas.$ZodEnum<T> {
1248
+ return new Class({
1249
+ type: "enum",
1250
+ entries,
1251
+ ...util.normalizeParams(params),
1252
+ }) as any;
1253
+ }
1254
+
1255
+ // ZodLiteral
1256
+ export type $ZodLiteralParams = TypeParams<schemas.$ZodLiteral, "values">;
1257
+ export function _literal<const T extends Array<util.Literal>>(
1258
+ Class: util.SchemaClass<schemas.$ZodLiteral>,
1259
+ value: T,
1260
+ params?: string | $ZodLiteralParams
1261
+ ): schemas.$ZodLiteral<T[number]>;
1262
+ export function _literal<const T extends util.Literal>(
1263
+ Class: util.SchemaClass<schemas.$ZodLiteral>,
1264
+ value: T,
1265
+ params?: string | $ZodLiteralParams
1266
+ ): schemas.$ZodLiteral<T>;
1267
+ export function _literal(Class: util.SchemaClass<schemas.$ZodLiteral>, value: any, params: any) {
1268
+ return new Class({
1269
+ type: "literal",
1270
+ values: Array.isArray(value) ? value : [value],
1271
+ ...util.normalizeParams(params),
1272
+ });
1273
+ }
1274
+
1275
+ // ZodFile
1276
+ export type $ZodFileParams = TypeParams<schemas.$ZodFile>;
1277
+ export function _file(Class: util.SchemaClass<schemas.$ZodFile>, params?: string | $ZodFileParams): schemas.$ZodFile {
1278
+ return new Class({
1279
+ type: "file",
1280
+ ...util.normalizeParams(params),
1281
+ });
1282
+ }
1283
+
1284
+ // ZodTransform
1285
+ export type $ZodTransformParams = TypeParams<schemas.$ZodTransform, "transform">;
1286
+ export function _transform<I = unknown, O = I>(
1287
+ Class: util.SchemaClass<schemas.$ZodTransform>,
1288
+ fn: (input: I, ctx?: schemas.ParsePayload) => O
1289
+ ): schemas.$ZodTransform<Awaited<O>, I> {
1290
+ return new Class({
1291
+ type: "transform",
1292
+ transform: fn as any,
1293
+ }) as any;
1294
+ }
1295
+
1296
+ // ZodOptional
1297
+ export type $ZodOptionalParams = TypeParams<schemas.$ZodOptional, "innerType">;
1298
+ export function _optional<T extends schemas.$ZodObject>(
1299
+ Class: util.SchemaClass<schemas.$ZodOptional>,
1300
+ innerType: T
1301
+ ): schemas.$ZodOptional<T> {
1302
+ return new Class({
1303
+ type: "optional",
1304
+ innerType,
1305
+ }) as any;
1306
+ }
1307
+
1308
+ // ZodNullable
1309
+ export type $ZodNullableParams = TypeParams<schemas.$ZodNullable, "innerType">;
1310
+ export function _nullable<T extends schemas.$ZodObject>(
1311
+ Class: util.SchemaClass<schemas.$ZodNullable>,
1312
+ innerType: T
1313
+ ): schemas.$ZodNullable<T> {
1314
+ return new Class({
1315
+ type: "nullable",
1316
+ innerType,
1317
+ }) as any;
1318
+ }
1319
+
1320
+ // ZodDefault
1321
+ export type $ZodDefaultParams = TypeParams<schemas.$ZodDefault, "innerType" | "defaultValue">;
1322
+ export function _default<T extends schemas.$ZodObject>(
1323
+ Class: util.SchemaClass<schemas.$ZodDefault>,
1324
+ innerType: T,
1325
+ defaultValue: util.NoUndefined<core.output<T>> | (() => util.NoUndefined<core.output<T>>)
1326
+ ): schemas.$ZodDefault<T> {
1327
+ return new Class({
1328
+ type: "default",
1329
+ innerType,
1330
+ get defaultValue() {
1331
+ return typeof defaultValue === "function" ? (defaultValue as Function)() : defaultValue;
1332
+ },
1333
+ }) as any;
1334
+ }
1335
+
1336
+ // ZodNonOptional
1337
+ export type $ZodNonOptionalParams = TypeParams<schemas.$ZodNonOptional, "innerType">;
1338
+ export function _nonoptional<T extends schemas.$ZodObject>(
1339
+ Class: util.SchemaClass<schemas.$ZodNonOptional>,
1340
+ innerType: T,
1341
+ params?: string | $ZodNonOptionalParams
1342
+ ): schemas.$ZodNonOptional<T> {
1343
+ return new Class({
1344
+ type: "nonoptional",
1345
+ innerType,
1346
+ ...util.normalizeParams(params),
1347
+ }) as any;
1348
+ }
1349
+
1350
+ // ZodSuccess
1351
+ export type $ZodSuccessParams = TypeParams<schemas.$ZodSuccess, "innerType">;
1352
+ export function _success<T extends schemas.$ZodObject>(
1353
+ Class: util.SchemaClass<schemas.$ZodSuccess>,
1354
+ innerType: T
1355
+ ): schemas.$ZodSuccess<T> {
1356
+ return new Class({
1357
+ type: "success",
1358
+ innerType,
1359
+ }) as any;
1360
+ }
1361
+
1362
+ // ZodCatch
1363
+ export type $ZodCatchParams = TypeParams<schemas.$ZodCatch, "innerType" | "catchValue">;
1364
+ export function _catch<T extends schemas.$ZodObject>(
1365
+ Class: util.SchemaClass<schemas.$ZodCatch>,
1366
+ innerType: T,
1367
+ catchValue: core.output<T> | ((ctx: schemas.$ZodCatchCtx) => core.output<T>)
1368
+ ): schemas.$ZodCatch<T> {
1369
+ return new Class({
1370
+ type: "catch",
1371
+ innerType,
1372
+ catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue) as any,
1373
+ }) as any;
1374
+ }
1375
+
1376
+ // ZodPipe
1377
+ export type $ZodPipeParams = TypeParams<schemas.$ZodPipe, "in" | "out">;
1378
+ export function _pipe<
1379
+ const A extends schemas.$ZodType,
1380
+ B extends schemas.$ZodType<unknown, core.output<A>> = schemas.$ZodType<unknown, core.output<A>>,
1381
+ >(
1382
+ Class: util.SchemaClass<schemas.$ZodPipe>,
1383
+ in_: A,
1384
+ out: B | schemas.$ZodType<unknown, core.output<A>>
1385
+ ): schemas.$ZodPipe<A, B> {
1386
+ return new Class({
1387
+ type: "pipe",
1388
+ in: in_,
1389
+ out,
1390
+ }) as any;
1391
+ }
1392
+
1393
+ // ZodReadonly
1394
+ export type $ZodReadonlyParams = TypeParams<schemas.$ZodReadonly, "innerType">;
1395
+ export function _readonly<T extends schemas.$ZodObject>(
1396
+ Class: util.SchemaClass<schemas.$ZodReadonly>,
1397
+ innerType: T
1398
+ ): schemas.$ZodReadonly<T> {
1399
+ return new Class({
1400
+ type: "readonly",
1401
+ innerType,
1402
+ }) as any;
1403
+ }
1404
+
1405
+ // ZodTemplateLiteral
1406
+ export type $ZodTemplateLiteralParams = TypeParams<schemas.$ZodTemplateLiteral, "parts">;
1407
+ export function _templateLiteral<const Parts extends schemas.$ZodTemplateLiteralPart[]>(
1408
+ Class: util.SchemaClass<schemas.$ZodTemplateLiteral>,
1409
+ parts: Parts,
1410
+ params?: string | $ZodTemplateLiteralParams
1411
+ ): schemas.$ZodTemplateLiteral<schemas.$PartsToTemplateLiteral<Parts>> {
1412
+ return new Class({
1413
+ type: "template_literal",
1414
+ parts,
1415
+ ...util.normalizeParams(params),
1416
+ }) as any;
1417
+ }
1418
+
1419
+ // ZodLazy
1420
+ export type $ZodLazyParams = TypeParams<schemas.$ZodLazy, "getter">;
1421
+ export function _lazy<T extends schemas.$ZodType>(
1422
+ Class: util.SchemaClass<schemas.$ZodLazy>,
1423
+ getter: () => T
1424
+ ): schemas.$ZodLazy<T> {
1425
+ return new Class({
1426
+ type: "lazy",
1427
+ getter,
1428
+ }) as any;
1429
+ }
1430
+
1431
+ // ZodPromise
1432
+ export type $ZodPromiseParams = TypeParams<schemas.$ZodPromise, "innerType">;
1433
+ export function _promise<T extends schemas.$ZodObject>(
1434
+ Class: util.SchemaClass<schemas.$ZodPromise>,
1435
+ innerType: T
1436
+ ): schemas.$ZodPromise<T> {
1437
+ return new Class({
1438
+ type: "promise",
1439
+ innerType,
1440
+ }) as any;
1441
+ }
1442
+
1443
+ // ZodCustom
1444
+ export type $ZodCustomParams = CheckTypeParams<schemas.$ZodCustom, "fn">;
1445
+ export function _custom<O = unknown, I = O>(
1446
+ Class: util.SchemaClass<schemas.$ZodCustom>,
1447
+ fn: (data: O) => unknown,
1448
+ _params: string | $ZodCustomParams | undefined
1449
+ ): schemas.$ZodCustom<O, I> {
1450
+ const norm = util.normalizeParams(_params);
1451
+ norm.abort ??= true; // default to abort:false
1452
+ const schema = new Class({
1453
+ type: "custom",
1454
+ check: "custom",
1455
+ fn: fn as any,
1456
+ ...norm,
1457
+ });
1458
+
1459
+ return schema as any;
1460
+ }
1461
+
1462
+ // export function _refine<T>(
1463
+ // Class: util.SchemaClass<schemas.$ZodCustom>,
1464
+ // fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>,
1465
+ // _params: string | $ZodCustomParams = {}
1466
+ // ): checks.$ZodCheck<T> {
1467
+ // return _custom(Class, fn, _params);
1468
+ // }
1469
+ // same as _custom but defaults to abort:false
1470
+ export function _refine<O = unknown, I = O>(
1471
+ Class: util.SchemaClass<schemas.$ZodCustom>,
1472
+ fn: (data: O) => unknown,
1473
+ _params: string | $ZodCustomParams | undefined
1474
+ ): schemas.$ZodCustom<O, I> {
1475
+ const schema = new Class({
1476
+ type: "custom",
1477
+ check: "custom",
1478
+ fn: fn as any,
1479
+ ...util.normalizeParams(_params),
1480
+ });
1481
+
1482
+ return schema as any;
1483
+ }
1484
+
1485
+ // export type $ZodCustomParams = CheckTypeParams<schemas.$ZodCustom, "fn">
1486
+
1487
+ ///////// STRINGBOOL /////////
1488
+
1489
+ // stringbool
1490
+ export interface $ZodStringBoolParams extends TypeParams {
1491
+ truthy?: string[];
1492
+ falsy?: string[];
1493
+ /**
1494
+ * Options: `"sensitive"`, `"insensitive"`
1495
+ *
1496
+ * @default `"insensitive"`
1497
+ */
1498
+ case?: "sensitive" | "insensitive" | undefined;
1499
+ }
1500
+
1501
+ export function _stringbool(
1502
+ Classes: {
1503
+ Pipe?: typeof schemas.$ZodPipe;
1504
+ Boolean?: typeof schemas.$ZodBoolean;
1505
+ Transform?: typeof schemas.$ZodTransform;
1506
+ String?: typeof schemas.$ZodString;
1507
+ },
1508
+ _params?: string | $ZodStringBoolParams
1509
+ ): schemas.$ZodPipe<
1510
+ schemas.$ZodPipe<schemas.$ZodString, schemas.$ZodTransform<boolean, string>>,
1511
+ schemas.$ZodBoolean<boolean>
1512
+ > {
1513
+ const params = util.normalizeParams(_params);
1514
+
1515
+ let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
1516
+ let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
1517
+ if (params.case !== "sensitive") {
1518
+ truthyArray = truthyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
1519
+ falsyArray = falsyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
1520
+ }
1521
+
1522
+ const truthySet = new Set(truthyArray);
1523
+ const falsySet = new Set(falsyArray);
1524
+
1525
+ const _Pipe = Classes.Pipe ?? schemas.$ZodPipe;
1526
+ const _Boolean = Classes.Boolean ?? schemas.$ZodBoolean;
1527
+ const _String = Classes.String ?? schemas.$ZodString;
1528
+ const _Transform = Classes.Transform ?? schemas.$ZodTransform;
1529
+
1530
+ const tx = new _Transform({
1531
+ type: "transform",
1532
+ transform: (input, payload: schemas.ParsePayload<unknown>) => {
1533
+ let data: string = input as string;
1534
+ if (params.case !== "sensitive") data = data.toLowerCase();
1535
+ if (truthySet.has(data)) {
1536
+ return true;
1537
+ } else if (falsySet.has(data)) {
1538
+ return false;
1539
+ } else {
1540
+ payload.issues.push({
1541
+ code: "invalid_value",
1542
+ expected: "stringbool",
1543
+ values: [...truthySet, ...falsySet],
1544
+ input: payload.value,
1545
+ inst: tx,
1546
+ });
1547
+ return {} as never;
1548
+ }
1549
+ },
1550
+ error: params.error,
1551
+ });
1552
+ // params.error;
1553
+
1554
+ const innerPipe = new _Pipe({
1555
+ type: "pipe",
1556
+ in: new _String({ type: "string", error: params.error }),
1557
+ out: tx,
1558
+ error: params.error,
1559
+ });
1560
+
1561
+ const outerPipe = new _Pipe({
1562
+ type: "pipe",
1563
+ in: innerPipe,
1564
+ out: new _Boolean({
1565
+ type: "boolean",
1566
+ error: params.error,
1567
+ }),
1568
+ error: params.error,
1569
+ });
1570
+ return outerPipe as any;
1571
+ }
1572
+
1573
+ export function _stringFormat<Format extends string>(
1574
+ Class: typeof schemas.$ZodCustomStringFormat,
1575
+ format: Format,
1576
+ fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp,
1577
+ _params: string | $ZodStringFormatParams = {}
1578
+ ): schemas.$ZodCustomStringFormat<Format> {
1579
+ const params = util.normalizeParams(_params);
1580
+ const def: schemas.$ZodCustomStringFormatDef = {
1581
+ ...util.normalizeParams(_params),
1582
+ check: "string_format",
1583
+ type: "string",
1584
+ format,
1585
+ fn: typeof fnOrRegex === "function" ? fnOrRegex : (val) => fnOrRegex.test(val),
1586
+ ...params,
1587
+ };
1588
+ if (fnOrRegex instanceof RegExp) {
1589
+ def.pattern = fnOrRegex;
1590
+ }
1591
+
1592
+ const inst = new Class(def);
1593
+ return inst as any;
1594
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/checks.ts ADDED
@@ -0,0 +1,1283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // import { $ZodType } from "./schemas.js";
2
+
3
+ import * as core from "./core.js";
4
+ import type * as errors from "./errors.js";
5
+ import * as regexes from "./regexes.js";
6
+ import type * as schemas from "./schemas.js";
7
+ import * as util from "./util.js";
8
+
9
+ ////////////////////////////// CHECKS ///////////////////////////////////////
10
+
11
+ export interface $ZodCheckDef {
12
+ check: string;
13
+ error?: errors.$ZodErrorMap<never> | undefined;
14
+ /** If true, no later checks will be executed if this check fails. Default `false`. */
15
+ abort?: boolean | undefined;
16
+ /** If provided, this check will only be executed if the function returns `true`. Defaults to `payload => z.util.isAborted(payload)`. */
17
+ when?: ((payload: schemas.ParsePayload) => boolean) | undefined;
18
+ }
19
+
20
+ export interface $ZodCheckInternals<T> {
21
+ def: $ZodCheckDef;
22
+ /** The set of issues this check might throw. */
23
+ issc?: errors.$ZodIssueBase;
24
+ check(payload: schemas.ParsePayload<T>): util.MaybeAsync<void>;
25
+ onattach: ((schema: schemas.$ZodType) => void)[];
26
+ }
27
+
28
+ export interface $ZodCheck<in T = never> {
29
+ _zod: $ZodCheckInternals<T>;
30
+ }
31
+
32
+ export const $ZodCheck: core.$constructor<$ZodCheck<any>> = /*@__PURE__*/ core.$constructor(
33
+ "$ZodCheck",
34
+ (inst, def) => {
35
+ inst._zod ??= {} as any;
36
+ inst._zod.def = def;
37
+ inst._zod.onattach ??= [];
38
+ }
39
+ );
40
+
41
+ ///////////////////////////////////////
42
+ ///// $ZodCheckLessThan /////
43
+ ///////////////////////////////////////
44
+ export interface $ZodCheckLessThanDef extends $ZodCheckDef {
45
+ check: "less_than";
46
+ value: util.Numeric;
47
+ inclusive: boolean;
48
+ }
49
+
50
+ export interface $ZodCheckLessThanInternals<T extends util.Numeric = util.Numeric> extends $ZodCheckInternals<T> {
51
+ def: $ZodCheckLessThanDef;
52
+ issc: errors.$ZodIssueTooBig<T>;
53
+ }
54
+
55
+ const numericOriginMap = {
56
+ number: "number",
57
+ bigint: "bigint",
58
+ object: "date",
59
+ } as const;
60
+ export interface $ZodCheckLessThan<T extends util.Numeric = util.Numeric> extends $ZodCheck<T> {
61
+ _zod: $ZodCheckLessThanInternals<T>;
62
+ }
63
+
64
+ export const $ZodCheckLessThan: core.$constructor<$ZodCheckLessThan> = /*@__PURE__*/ core.$constructor(
65
+ "$ZodCheckLessThan",
66
+ (inst, def) => {
67
+ $ZodCheck.init(inst, def);
68
+ const origin = numericOriginMap[typeof def.value as "number" | "bigint" | "object"];
69
+
70
+ inst._zod.onattach.push((inst) => {
71
+ const bag = inst._zod.bag;
72
+ const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
73
+ if (def.value < curr) {
74
+ if (def.inclusive) bag.maximum = def.value;
75
+ else bag.exclusiveMaximum = def.value;
76
+ }
77
+ });
78
+
79
+ inst._zod.check = (payload) => {
80
+ if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
81
+ return;
82
+ }
83
+
84
+ payload.issues.push({
85
+ origin,
86
+ code: "too_big",
87
+ maximum: def.value as number,
88
+ input: payload.value,
89
+ inclusive: def.inclusive,
90
+ inst,
91
+ continue: !def.abort,
92
+ });
93
+ };
94
+ }
95
+ );
96
+
97
+ /////////////////////////////////////
98
+ ///// $ZodCheckGreaterThan /////
99
+ /////////////////////////////////////
100
+ export interface $ZodCheckGreaterThanDef extends $ZodCheckDef {
101
+ check: "greater_than";
102
+ value: util.Numeric;
103
+ inclusive: boolean;
104
+ }
105
+
106
+ export interface $ZodCheckGreaterThanInternals<T extends util.Numeric = util.Numeric> extends $ZodCheckInternals<T> {
107
+ def: $ZodCheckGreaterThanDef;
108
+ issc: errors.$ZodIssueTooSmall<T>;
109
+ }
110
+
111
+ export interface $ZodCheckGreaterThan<T extends util.Numeric = util.Numeric> extends $ZodCheck<T> {
112
+ _zod: $ZodCheckGreaterThanInternals<T>;
113
+ }
114
+
115
+ export const $ZodCheckGreaterThan: core.$constructor<$ZodCheckGreaterThan> = /*@__PURE__*/ core.$constructor(
116
+ "$ZodCheckGreaterThan",
117
+ (inst, def) => {
118
+ $ZodCheck.init(inst, def);
119
+ const origin = numericOriginMap[typeof def.value as "number" | "bigint" | "object"];
120
+
121
+ inst._zod.onattach.push((inst) => {
122
+ const bag = inst._zod.bag;
123
+ const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
124
+ if (def.value > curr) {
125
+ if (def.inclusive) bag.minimum = def.value;
126
+ else bag.exclusiveMinimum = def.value;
127
+ }
128
+ });
129
+
130
+ inst._zod.check = (payload) => {
131
+ if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
132
+ return;
133
+ }
134
+
135
+ payload.issues.push({
136
+ origin,
137
+ code: "too_small",
138
+ minimum: def.value as number,
139
+ input: payload.value,
140
+ inclusive: def.inclusive,
141
+ inst,
142
+ continue: !def.abort,
143
+ });
144
+ };
145
+ }
146
+ );
147
+
148
+ /////////////////////////////////////
149
+ ///// $ZodCheckMultipleOf /////
150
+ /////////////////////////////////////
151
+ // https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#31711034
152
+
153
+ export interface $ZodCheckMultipleOfDef<T extends number | bigint = number | bigint> extends $ZodCheckDef {
154
+ check: "multiple_of";
155
+ value: T;
156
+ }
157
+
158
+ export interface $ZodCheckMultipleOfInternals<T extends number | bigint = number | bigint>
159
+ extends $ZodCheckInternals<T> {
160
+ def: $ZodCheckMultipleOfDef<T>;
161
+ issc: errors.$ZodIssueNotMultipleOf;
162
+ }
163
+
164
+ export interface $ZodCheckMultipleOf<T extends number | bigint = number | bigint> extends $ZodCheck<T> {
165
+ _zod: $ZodCheckMultipleOfInternals<T>;
166
+ }
167
+
168
+ export const $ZodCheckMultipleOf: core.$constructor<$ZodCheckMultipleOf<number | bigint>> =
169
+ /*@__PURE__*/ core.$constructor("$ZodCheckMultipleOf", (inst, def) => {
170
+ $ZodCheck.init(inst, def);
171
+
172
+ inst._zod.onattach.push((inst) => {
173
+ inst._zod.bag.multipleOf ??= def.value;
174
+ });
175
+
176
+ inst._zod.check = (payload) => {
177
+ if (typeof payload.value !== typeof def.value)
178
+ throw new Error("Cannot mix number and bigint in multiple_of check.");
179
+ const isMultiple =
180
+ typeof payload.value === "bigint"
181
+ ? payload.value % (def.value as bigint) === BigInt(0)
182
+ : util.floatSafeRemainder(payload.value, def.value as number) === 0;
183
+
184
+ if (isMultiple) return;
185
+ payload.issues.push({
186
+ origin: typeof payload.value as "number",
187
+ code: "not_multiple_of",
188
+ divisor: def.value as number,
189
+ input: payload.value,
190
+ inst,
191
+ continue: !def.abort,
192
+ });
193
+ };
194
+ });
195
+
196
+ /////////////////////////////////////
197
+ ///// $ZodCheckFinite /////
198
+ /////////////////////////////////////
199
+ // interface $ZodCheckFiniteDef extends $ZodCheckDef {
200
+ // check: "finite";
201
+ // }
202
+
203
+ // export interface $ZodCheckFinite extends $ZodCheckInternals<number> {
204
+ // _def: $ZodCheckFiniteDef;
205
+ // _issc:
206
+ // | errors.$ZodIssueTooBig<"number", number>
207
+ // | errors.$ZodIssueTooSmall<"number", number>;
208
+ // }
209
+
210
+ // export const $ZodCheckFinite: core.$constructor<$ZodCheckFinite> =
211
+ // core.$constructor("$ZodCheckFinite", (inst, def) => {
212
+ // $ZodCheck.init(inst, def);
213
+
214
+ // inst._zod.onattach = (inst) => {
215
+ // inst["_bag"].finite = true;
216
+ // };
217
+
218
+ // inst._zod.check = (payload) => {
219
+ // if (Number.isFinite(payload.value)) return;
220
+ // payload.issues.push({
221
+ // origin: "number",
222
+ // ...(payload.value === Number.POSITIVE_INFINITY
223
+ // ? {
224
+ // code: "too_big",
225
+ // maximum: Number.POSITIVE_INFINITY,
226
+ // }
227
+ // : {
228
+ // code: "too_small",
229
+ // minimum: Number.NEGATIVE_INFINITY,
230
+ // }),
231
+ // // code: payload.value === Number.POSITIVE_INFINITY ? "too_big" : "too_big",
232
+ // // maximum: Number.POSITIVE_INFINITY,
233
+ // inclusive: false,
234
+ // input: payload.value,
235
+ // inst,
236
+ // });
237
+ // };
238
+ // });
239
+
240
+ ///////////////////////////////////////
241
+ ///// $ZodCheckNumberFormat /////
242
+ ///////////////////////////////////////
243
+
244
+ export type $ZodNumberFormats = "int32" | "uint32" | "float32" | "float64" | "safeint";
245
+
246
+ export interface $ZodCheckNumberFormatDef extends $ZodCheckDef {
247
+ check: "number_format";
248
+ format: $ZodNumberFormats;
249
+ // abort?: boolean;
250
+ }
251
+
252
+ export interface $ZodCheckNumberFormatInternals extends $ZodCheckInternals<number> {
253
+ def: $ZodCheckNumberFormatDef;
254
+ issc: errors.$ZodIssueInvalidType | errors.$ZodIssueTooBig<"number"> | errors.$ZodIssueTooSmall<"number">;
255
+ // bag: util.LoosePartial<{
256
+ // minimum?: number | undefined;
257
+ // }>;
258
+ }
259
+
260
+ export interface $ZodCheckNumberFormat extends $ZodCheck<number> {
261
+ _zod: $ZodCheckNumberFormatInternals;
262
+ }
263
+
264
+ export const $ZodCheckNumberFormat: core.$constructor<$ZodCheckNumberFormat> = /*@__PURE__*/ core.$constructor(
265
+ "$ZodCheckNumberFormat",
266
+ (inst, def) => {
267
+ $ZodCheck.init(inst, def); // no format checks
268
+ def.format = def.format || "float64";
269
+
270
+ const isInt = def.format?.includes("int");
271
+ const origin = isInt ? "int" : "number";
272
+ const [minimum, maximum] = util.NUMBER_FORMAT_RANGES[def.format];
273
+
274
+ inst._zod.onattach.push((inst) => {
275
+ const bag = inst._zod.bag;
276
+ bag.format = def.format;
277
+ bag.minimum = minimum;
278
+ bag.maximum = maximum;
279
+ if (isInt) bag.pattern = regexes.integer;
280
+ });
281
+
282
+ inst._zod.check = (payload) => {
283
+ const input = payload.value;
284
+
285
+ if (isInt) {
286
+ if (!Number.isInteger(input)) {
287
+ // invalid_format issue
288
+ // payload.issues.push({
289
+ // expected: def.format,
290
+ // format: def.format,
291
+ // code: "invalid_format",
292
+ // input,
293
+ // inst,
294
+ // });
295
+ // invalid_type issue
296
+ payload.issues.push({
297
+ expected: origin,
298
+ format: def.format,
299
+ code: "invalid_type",
300
+ input,
301
+ inst,
302
+ });
303
+
304
+ return;
305
+
306
+ // not_multiple_of issue
307
+ // payload.issues.push({
308
+ // code: "not_multiple_of",
309
+ // origin: "number",
310
+ // input,
311
+ // inst,
312
+ // divisor: 1,
313
+ // });
314
+ }
315
+ if (!Number.isSafeInteger(input)) {
316
+ if (input > 0) {
317
+ // too_big
318
+ payload.issues.push({
319
+ input,
320
+ code: "too_big",
321
+ maximum: Number.MAX_SAFE_INTEGER,
322
+ note: "Integers must be within the safe integer range.",
323
+ inst,
324
+ origin,
325
+ continue: !def.abort,
326
+ });
327
+ } else {
328
+ // too_small
329
+ payload.issues.push({
330
+ input,
331
+ code: "too_small",
332
+ minimum: Number.MIN_SAFE_INTEGER,
333
+ note: "Integers must be within the safe integer range.",
334
+ inst,
335
+ origin,
336
+ continue: !def.abort,
337
+ });
338
+ }
339
+
340
+ return;
341
+ }
342
+ }
343
+
344
+ if (input < minimum) {
345
+ payload.issues.push({
346
+ origin: "number",
347
+ input,
348
+ code: "too_small",
349
+ minimum,
350
+ inclusive: true,
351
+ inst,
352
+ continue: !def.abort,
353
+ });
354
+ }
355
+
356
+ if (input > maximum) {
357
+ payload.issues.push({
358
+ origin: "number",
359
+ input,
360
+ code: "too_big",
361
+ maximum,
362
+ inst,
363
+ } as any);
364
+ }
365
+ };
366
+ }
367
+ );
368
+
369
+ /////////////////////////////////////
370
+ ///// $ZodCheckBigIntFormat /////
371
+ /////////////////////////////////////
372
+
373
+ export type $ZodBigIntFormats = "int64" | "uint64";
374
+
375
+ export interface $ZodCheckBigIntFormatDef extends $ZodCheckDef {
376
+ check: "bigint_format";
377
+ format: $ZodBigIntFormats | undefined;
378
+ }
379
+
380
+ export interface $ZodCheckBigIntFormatInternals extends $ZodCheckInternals<bigint> {
381
+ def: $ZodCheckBigIntFormatDef;
382
+ issc: errors.$ZodIssueTooBig<"bigint"> | errors.$ZodIssueTooSmall<"bigint">;
383
+ }
384
+
385
+ export interface $ZodCheckBigIntFormat extends $ZodCheck<bigint> {
386
+ _zod: $ZodCheckBigIntFormatInternals;
387
+ }
388
+
389
+ export const $ZodCheckBigIntFormat: core.$constructor<$ZodCheckBigIntFormat> = /*@__PURE__*/ core.$constructor(
390
+ "$ZodCheckBigIntFormat",
391
+ (inst, def) => {
392
+ $ZodCheck.init(inst, def); // no format checks
393
+
394
+ const [minimum, maximum] = util.BIGINT_FORMAT_RANGES[def.format!];
395
+
396
+ inst._zod.onattach.push((inst) => {
397
+ const bag = inst._zod.bag;
398
+ bag.format = def.format;
399
+ bag.minimum = minimum;
400
+ bag.maximum = maximum;
401
+ });
402
+
403
+ inst._zod.check = (payload) => {
404
+ const input = payload.value;
405
+
406
+ if (input < minimum) {
407
+ payload.issues.push({
408
+ origin: "bigint",
409
+ input,
410
+ code: "too_small",
411
+ minimum: minimum as any,
412
+ inclusive: true,
413
+ inst,
414
+ continue: !def.abort,
415
+ });
416
+ }
417
+
418
+ if (input > maximum) {
419
+ payload.issues.push({
420
+ origin: "bigint",
421
+ input,
422
+ code: "too_big",
423
+ maximum,
424
+ inst,
425
+ } as any);
426
+ }
427
+ };
428
+ }
429
+ );
430
+
431
+ //////////////////////////////////
432
+ ///// $ZodCheckMaxSize /////
433
+ //////////////////////////////////
434
+ export interface $ZodCheckMaxSizeDef extends $ZodCheckDef {
435
+ check: "max_size";
436
+ maximum: number;
437
+ }
438
+
439
+ export interface $ZodCheckMaxSizeInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
440
+ def: $ZodCheckMaxSizeDef;
441
+ issc: errors.$ZodIssueTooBig<T>;
442
+ }
443
+
444
+ export interface $ZodCheckMaxSize<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
445
+ _zod: $ZodCheckMaxSizeInternals<T>;
446
+ }
447
+
448
+ export const $ZodCheckMaxSize: core.$constructor<$ZodCheckMaxSize> = /*@__PURE__*/ core.$constructor(
449
+ "$ZodCheckMaxSize",
450
+ (inst, def) => {
451
+ $ZodCheck.init(inst, def);
452
+
453
+ inst._zod.def.when ??= (payload) => {
454
+ const val = payload.value;
455
+ return !util.nullish(val) && (val as any).size !== undefined;
456
+ };
457
+
458
+ inst._zod.onattach.push((inst) => {
459
+ const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY) as number;
460
+ if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
461
+ });
462
+
463
+ inst._zod.check = (payload) => {
464
+ const input = payload.value;
465
+ const size = input.size;
466
+
467
+ if (size <= def.maximum) return;
468
+ payload.issues.push({
469
+ origin: util.getSizableOrigin(input),
470
+ code: "too_big",
471
+ maximum: def.maximum,
472
+ input,
473
+ inst,
474
+ continue: !def.abort,
475
+ });
476
+ };
477
+ }
478
+ );
479
+
480
+ //////////////////////////////////
481
+ ///// $ZodCheckMinSize /////
482
+ //////////////////////////////////
483
+ export interface $ZodCheckMinSizeDef extends $ZodCheckDef {
484
+ check: "min_size";
485
+ minimum: number;
486
+ }
487
+
488
+ export interface $ZodCheckMinSizeInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
489
+ def: $ZodCheckMinSizeDef;
490
+ issc: errors.$ZodIssueTooSmall<T>;
491
+ }
492
+
493
+ export interface $ZodCheckMinSize<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
494
+ _zod: $ZodCheckMinSizeInternals<T>;
495
+ }
496
+
497
+ export const $ZodCheckMinSize: core.$constructor<$ZodCheckMinSize> = /*@__PURE__*/ core.$constructor(
498
+ "$ZodCheckMinSize",
499
+ (inst, def) => {
500
+ $ZodCheck.init(inst, def);
501
+
502
+ inst._zod.def.when ??= (payload) => {
503
+ const val = payload.value;
504
+ return !util.nullish(val) && (val as any).size !== undefined;
505
+ };
506
+
507
+ inst._zod.onattach.push((inst) => {
508
+ const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY) as number;
509
+ if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
510
+ });
511
+
512
+ inst._zod.check = (payload) => {
513
+ const input = payload.value;
514
+ const size = input.size;
515
+
516
+ if (size >= def.minimum) return;
517
+ payload.issues.push({
518
+ origin: util.getSizableOrigin(input),
519
+ code: "too_small",
520
+ minimum: def.minimum,
521
+ input,
522
+ inst,
523
+ continue: !def.abort,
524
+ });
525
+ };
526
+ }
527
+ );
528
+
529
+ /////////////////////////////////////
530
+ ///// $ZodCheckSizeEquals /////
531
+ /////////////////////////////////////
532
+ export interface $ZodCheckSizeEqualsDef extends $ZodCheckDef {
533
+ check: "size_equals";
534
+ size: number;
535
+ }
536
+
537
+ export interface $ZodCheckSizeEqualsInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
538
+ def: $ZodCheckSizeEqualsDef;
539
+ issc: errors.$ZodIssueTooBig<T> | errors.$ZodIssueTooSmall<T>;
540
+ }
541
+
542
+ export interface $ZodCheckSizeEquals<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
543
+ _zod: $ZodCheckSizeEqualsInternals<T>;
544
+ }
545
+
546
+ export const $ZodCheckSizeEquals: core.$constructor<$ZodCheckSizeEquals> = /*@__PURE__*/ core.$constructor(
547
+ "$ZodCheckSizeEquals",
548
+ (inst, def) => {
549
+ $ZodCheck.init(inst, def);
550
+
551
+ inst._zod.def.when ??= (payload) => {
552
+ const val = payload.value;
553
+ return !util.nullish(val) && (val as any).size !== undefined;
554
+ };
555
+
556
+ inst._zod.onattach.push((inst) => {
557
+ const bag = inst._zod.bag;
558
+ bag.minimum = def.size;
559
+ bag.maximum = def.size;
560
+ bag.size = def.size;
561
+ });
562
+
563
+ inst._zod.check = (payload) => {
564
+ const input = payload.value;
565
+ const size = input.size;
566
+ if (size === def.size) return;
567
+
568
+ const tooBig = size > def.size;
569
+ payload.issues.push({
570
+ origin: util.getSizableOrigin(input),
571
+ ...(tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size }),
572
+ inclusive: true,
573
+ exact: true,
574
+ input: payload.value,
575
+ inst,
576
+ continue: !def.abort,
577
+ });
578
+ };
579
+ }
580
+ );
581
+
582
+ //////////////////////////////////
583
+ ///// $ZodCheckMaxLength /////
584
+ //////////////////////////////////
585
+
586
+ export interface $ZodCheckMaxLengthDef extends $ZodCheckDef {
587
+ check: "max_length";
588
+ maximum: number;
589
+ }
590
+
591
+ export interface $ZodCheckMaxLengthInternals<T extends util.HasLength = util.HasLength> extends $ZodCheckInternals<T> {
592
+ def: $ZodCheckMaxLengthDef;
593
+ issc: errors.$ZodIssueTooBig<T>;
594
+ }
595
+
596
+ export interface $ZodCheckMaxLength<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
597
+ _zod: $ZodCheckMaxLengthInternals<T>;
598
+ }
599
+
600
+ export const $ZodCheckMaxLength: core.$constructor<$ZodCheckMaxLength> = /*@__PURE__*/ core.$constructor(
601
+ "$ZodCheckMaxLength",
602
+ (inst, def) => {
603
+ $ZodCheck.init(inst, def);
604
+
605
+ inst._zod.def.when ??= (payload) => {
606
+ const val = payload.value;
607
+ return !util.nullish(val) && (val as any).length !== undefined;
608
+ };
609
+
610
+ inst._zod.onattach.push((inst) => {
611
+ const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY) as number;
612
+ if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
613
+ });
614
+
615
+ inst._zod.check = (payload) => {
616
+ const input = payload.value;
617
+ const length = input.length;
618
+
619
+ if (length <= def.maximum) return;
620
+ const origin = util.getLengthableOrigin(input);
621
+ payload.issues.push({
622
+ origin,
623
+ code: "too_big",
624
+ maximum: def.maximum,
625
+ inclusive: true,
626
+ input,
627
+ inst,
628
+ continue: !def.abort,
629
+ });
630
+ };
631
+ }
632
+ );
633
+
634
+ //////////////////////////////////
635
+ ///// $ZodCheckMinLength /////
636
+ //////////////////////////////////
637
+ export interface $ZodCheckMinLengthDef extends $ZodCheckDef {
638
+ check: "min_length";
639
+ minimum: number;
640
+ }
641
+
642
+ export interface $ZodCheckMinLengthInternals<T extends util.HasLength = util.HasLength> extends $ZodCheckInternals<T> {
643
+ def: $ZodCheckMinLengthDef;
644
+ issc: errors.$ZodIssueTooSmall<T>;
645
+ }
646
+
647
+ export interface $ZodCheckMinLength<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
648
+ _zod: $ZodCheckMinLengthInternals<T>;
649
+ }
650
+
651
+ export const $ZodCheckMinLength: core.$constructor<$ZodCheckMinLength> = /*@__PURE__*/ core.$constructor(
652
+ "$ZodCheckMinLength",
653
+ (inst, def) => {
654
+ $ZodCheck.init(inst, def);
655
+
656
+ inst._zod.def.when ??= (payload) => {
657
+ const val = payload.value;
658
+ return !util.nullish(val) && (val as any).length !== undefined;
659
+ };
660
+
661
+ inst._zod.onattach.push((inst) => {
662
+ const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY) as number;
663
+ if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
664
+ });
665
+
666
+ inst._zod.check = (payload) => {
667
+ const input = payload.value;
668
+ const length = input.length;
669
+
670
+ if (length >= def.minimum) return;
671
+ const origin = util.getLengthableOrigin(input);
672
+ payload.issues.push({
673
+ origin,
674
+ code: "too_small",
675
+ minimum: def.minimum,
676
+ inclusive: true,
677
+ input,
678
+ inst,
679
+ continue: !def.abort,
680
+ });
681
+ };
682
+ }
683
+ );
684
+
685
+ /////////////////////////////////////
686
+ ///// $ZodCheckLengthEquals /////
687
+ /////////////////////////////////////
688
+ export interface $ZodCheckLengthEqualsDef extends $ZodCheckDef {
689
+ check: "length_equals";
690
+ length: number;
691
+ }
692
+
693
+ export interface $ZodCheckLengthEqualsInternals<T extends util.HasLength = util.HasLength>
694
+ extends $ZodCheckInternals<T> {
695
+ def: $ZodCheckLengthEqualsDef;
696
+ issc: errors.$ZodIssueTooBig<T> | errors.$ZodIssueTooSmall<T>;
697
+ }
698
+
699
+ export interface $ZodCheckLengthEquals<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
700
+ _zod: $ZodCheckLengthEqualsInternals<T>;
701
+ }
702
+
703
+ export const $ZodCheckLengthEquals: core.$constructor<$ZodCheckLengthEquals> = /*@__PURE__*/ core.$constructor(
704
+ "$ZodCheckLengthEquals",
705
+ (inst, def) => {
706
+ $ZodCheck.init(inst, def);
707
+
708
+ inst._zod.def.when ??= (payload) => {
709
+ const val = payload.value;
710
+ return !util.nullish(val) && (val as any).length !== undefined;
711
+ };
712
+
713
+ inst._zod.onattach.push((inst) => {
714
+ const bag = inst._zod.bag;
715
+ bag.minimum = def.length;
716
+ bag.maximum = def.length;
717
+ bag.length = def.length;
718
+ });
719
+
720
+ inst._zod.check = (payload) => {
721
+ const input = payload.value;
722
+ const length = input.length;
723
+ if (length === def.length) return;
724
+ const origin = util.getLengthableOrigin(input);
725
+ const tooBig = length > def.length;
726
+ payload.issues.push({
727
+ origin,
728
+ ...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
729
+ inclusive: true,
730
+ exact: true,
731
+ input: payload.value,
732
+ inst,
733
+ continue: !def.abort,
734
+ });
735
+ };
736
+ }
737
+ );
738
+
739
+ /////////////////////////////////////////////
740
+ ///// $ZodCheckStringFormatRegex /////
741
+ /////////////////////////////////////////////
742
+ export type $ZodStringFormats =
743
+ | "email"
744
+ | "url"
745
+ | "emoji"
746
+ | "uuid"
747
+ | "guid"
748
+ | "nanoid"
749
+ | "cuid"
750
+ | "cuid2"
751
+ | "ulid"
752
+ | "xid"
753
+ | "ksuid"
754
+ | "datetime"
755
+ | "date"
756
+ | "time"
757
+ | "duration"
758
+ | "ipv4"
759
+ | "ipv6"
760
+ | "cidrv4"
761
+ | "cidrv6"
762
+ | "base64"
763
+ | "base64url"
764
+ | "json_string"
765
+ | "e164"
766
+ | "lowercase"
767
+ | "uppercase"
768
+ | "regex"
769
+ | "jwt"
770
+ | "starts_with"
771
+ | "ends_with"
772
+ | "includes";
773
+ export interface $ZodCheckStringFormatDef<Format extends string = string> extends $ZodCheckDef {
774
+ check: "string_format";
775
+ format: Format;
776
+ pattern?: RegExp | undefined;
777
+ }
778
+
779
+ export interface $ZodCheckStringFormatInternals extends $ZodCheckInternals<string> {
780
+ def: $ZodCheckStringFormatDef;
781
+ issc: errors.$ZodIssueInvalidStringFormat;
782
+ }
783
+
784
+ export interface $ZodCheckStringFormat extends $ZodCheck<string> {
785
+ _zod: $ZodCheckStringFormatInternals;
786
+ }
787
+
788
+ export const $ZodCheckStringFormat: core.$constructor<$ZodCheckStringFormat> = /*@__PURE__*/ core.$constructor(
789
+ "$ZodCheckStringFormat",
790
+ (inst, def) => {
791
+ $ZodCheck.init(inst, def);
792
+
793
+ inst._zod.onattach.push((inst) => {
794
+ const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
795
+ bag.format = def.format;
796
+ if (def.pattern) {
797
+ bag.patterns ??= new Set();
798
+ bag.patterns.add(def.pattern);
799
+ }
800
+ });
801
+
802
+ if (def.pattern)
803
+ inst._zod.check ??= (payload) => {
804
+ def.pattern!.lastIndex = 0;
805
+ if (def.pattern!.test(payload.value)) return;
806
+ payload.issues.push({
807
+ origin: "string",
808
+ code: "invalid_format",
809
+ format: def.format,
810
+ input: payload.value,
811
+ ...(def.pattern ? { pattern: def.pattern.toString() } : {}),
812
+ inst,
813
+ continue: !def.abort,
814
+ });
815
+ };
816
+ else inst._zod.check ??= () => {};
817
+ }
818
+ );
819
+
820
+ ////////////////////////////////
821
+ ///// $ZodCheckRegex /////
822
+ ////////////////////////////////
823
+ export interface $ZodCheckRegexDef extends $ZodCheckStringFormatDef {
824
+ format: "regex";
825
+ pattern: RegExp;
826
+ }
827
+
828
+ export interface $ZodCheckRegexInternals extends $ZodCheckInternals<string> {
829
+ def: $ZodCheckRegexDef;
830
+ issc: errors.$ZodIssueInvalidStringFormat;
831
+ }
832
+
833
+ export interface $ZodCheckRegex extends $ZodCheck<string> {
834
+ _zod: $ZodCheckRegexInternals;
835
+ }
836
+
837
+ export const $ZodCheckRegex: core.$constructor<$ZodCheckRegex> = /*@__PURE__*/ core.$constructor(
838
+ "$ZodCheckRegex",
839
+ (inst, def) => {
840
+ $ZodCheckStringFormat.init(inst, def);
841
+
842
+ inst._zod.check = (payload) => {
843
+ def.pattern.lastIndex = 0;
844
+ if (def.pattern.test(payload.value)) return;
845
+ payload.issues.push({
846
+ origin: "string",
847
+ code: "invalid_format",
848
+ format: "regex",
849
+ input: payload.value,
850
+ pattern: def.pattern.toString(),
851
+ inst,
852
+ continue: !def.abort,
853
+ });
854
+ };
855
+ }
856
+ );
857
+
858
+ ///////////////////////////////////
859
+ ///// $ZodCheckJSONString /////
860
+ ///////////////////////////////////
861
+ // interface $ZodCheckJSONStringDef extends $ZodCheckStringFormatDef<"json_string"> {
862
+ // // check: "string_format";
863
+ // // format: "json_string";
864
+ // // error?: errors.$ZodErrorMap<errors.$ZodIssueInvalidStringFormat> | undefined;
865
+ // }
866
+
867
+ // export interface $ZodCheckJSONString extends $ZodCheckStringFormat {
868
+ // _def: $ZodCheckJSONStringDef;
869
+ // }
870
+
871
+ // export const $ZodCheckJSONString: core.$constructor<$ZodCheckJSONString> = /*@__PURE__*/ core.$constructor(
872
+ // "$ZodCheckJSONString",
873
+ // (inst, def) => {
874
+ // $ZodCheck.init(inst, def);
875
+
876
+ // inst._zod.check = (payload) => {
877
+ // try {
878
+ // JSON.parse(payload.value);
879
+ // return;
880
+ // } catch (_) {
881
+ // payload.issues.push({
882
+ // origin: "string",
883
+ // code: "invalid_format",
884
+ // format: def.format,
885
+ // input: payload.value,
886
+ // inst,
887
+ // continue: !def.abort,
888
+ // });
889
+ // }
890
+ // };
891
+ // }
892
+ // );
893
+
894
+ //////////////////////////////////////
895
+ ///// $ZodCheckLowerCase /////
896
+ //////////////////////////////////////
897
+ export interface $ZodCheckLowerCaseDef extends $ZodCheckStringFormatDef<"lowercase"> {}
898
+
899
+ export interface $ZodCheckLowerCaseInternals extends $ZodCheckInternals<string> {
900
+ def: $ZodCheckLowerCaseDef;
901
+ issc: errors.$ZodIssueInvalidStringFormat;
902
+ }
903
+
904
+ export interface $ZodCheckLowerCase extends $ZodCheck<string> {
905
+ _zod: $ZodCheckLowerCaseInternals;
906
+ }
907
+
908
+ export const $ZodCheckLowerCase: core.$constructor<$ZodCheckLowerCase> = /*@__PURE__*/ core.$constructor(
909
+ "$ZodCheckLowerCase",
910
+ (inst, def) => {
911
+ def.pattern ??= regexes.lowercase;
912
+ $ZodCheckStringFormat.init(inst, def);
913
+ }
914
+ );
915
+
916
+ //////////////////////////////////////
917
+ ///// $ZodCheckUpperCase /////
918
+ //////////////////////////////////////
919
+ export interface $ZodCheckUpperCaseDef extends $ZodCheckStringFormatDef<"uppercase"> {}
920
+
921
+ export interface $ZodCheckUpperCaseInternals extends $ZodCheckInternals<string> {
922
+ def: $ZodCheckUpperCaseDef;
923
+ issc: errors.$ZodIssueInvalidStringFormat;
924
+ }
925
+
926
+ export interface $ZodCheckUpperCase extends $ZodCheck<string> {
927
+ _zod: $ZodCheckUpperCaseInternals;
928
+ }
929
+
930
+ export const $ZodCheckUpperCase: core.$constructor<$ZodCheckUpperCase> = /*@__PURE__*/ core.$constructor(
931
+ "$ZodCheckUpperCase",
932
+ (inst, def) => {
933
+ def.pattern ??= regexes.uppercase;
934
+ $ZodCheckStringFormat.init(inst, def);
935
+ }
936
+ );
937
+
938
+ ///////////////////////////////////
939
+ ///// $ZodCheckIncludes /////
940
+ ///////////////////////////////////
941
+ export interface $ZodCheckIncludesDef extends $ZodCheckStringFormatDef<"includes"> {
942
+ includes: string;
943
+ position?: number | undefined;
944
+ }
945
+
946
+ export interface $ZodCheckIncludesInternals extends $ZodCheckInternals<string> {
947
+ def: $ZodCheckIncludesDef;
948
+ issc: errors.$ZodIssueInvalidStringFormat;
949
+ }
950
+
951
+ export interface $ZodCheckIncludes extends $ZodCheck<string> {
952
+ _zod: $ZodCheckIncludesInternals;
953
+ }
954
+
955
+ export const $ZodCheckIncludes: core.$constructor<$ZodCheckIncludes> = /*@__PURE__*/ core.$constructor(
956
+ "$ZodCheckIncludes",
957
+ (inst, def) => {
958
+ $ZodCheck.init(inst, def);
959
+
960
+ const escapedRegex = util.escapeRegex(def.includes);
961
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
962
+ def.pattern = pattern;
963
+ inst._zod.onattach.push((inst) => {
964
+ const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
965
+ bag.patterns ??= new Set();
966
+ bag.patterns.add(pattern);
967
+ });
968
+
969
+ inst._zod.check = (payload) => {
970
+ if (payload.value.includes(def.includes, def.position)) return;
971
+ payload.issues.push({
972
+ origin: "string",
973
+ code: "invalid_format",
974
+ format: "includes",
975
+ includes: def.includes,
976
+ input: payload.value,
977
+ inst,
978
+ continue: !def.abort,
979
+ });
980
+ };
981
+ }
982
+ );
983
+
984
+ /////////////////////////////////////
985
+ ///// $ZodCheckStartsWith /////
986
+ /////////////////////////////////////
987
+ export interface $ZodCheckStartsWithDef extends $ZodCheckStringFormatDef<"starts_with"> {
988
+ prefix: string;
989
+ }
990
+
991
+ export interface $ZodCheckStartsWithInternals extends $ZodCheckInternals<string> {
992
+ def: $ZodCheckStartsWithDef;
993
+ issc: errors.$ZodIssueInvalidStringFormat;
994
+ }
995
+
996
+ export interface $ZodCheckStartsWith extends $ZodCheck<string> {
997
+ _zod: $ZodCheckStartsWithInternals;
998
+ }
999
+
1000
+ export const $ZodCheckStartsWith: core.$constructor<$ZodCheckStartsWith> = /*@__PURE__*/ core.$constructor(
1001
+ "$ZodCheckStartsWith",
1002
+ (inst, def) => {
1003
+ $ZodCheck.init(inst, def);
1004
+
1005
+ const pattern = new RegExp(`^${util.escapeRegex(def.prefix)}.*`);
1006
+ def.pattern ??= pattern;
1007
+ inst._zod.onattach.push((inst) => {
1008
+ const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
1009
+ bag.patterns ??= new Set();
1010
+ bag.patterns.add(pattern);
1011
+ });
1012
+
1013
+ inst._zod.check = (payload) => {
1014
+ if (payload.value.startsWith(def.prefix)) return;
1015
+ payload.issues.push({
1016
+ origin: "string",
1017
+ code: "invalid_format",
1018
+ format: "starts_with",
1019
+ prefix: def.prefix,
1020
+ input: payload.value,
1021
+ inst,
1022
+ continue: !def.abort,
1023
+ });
1024
+ };
1025
+ }
1026
+ );
1027
+
1028
+ //////////////////////////////////
1029
+ ///// $ZodCheckEndsWith /////
1030
+ //////////////////////////////////
1031
+ export interface $ZodCheckEndsWithDef extends $ZodCheckStringFormatDef<"ends_with"> {
1032
+ suffix: string;
1033
+ }
1034
+
1035
+ export interface $ZodCheckEndsWithInternals extends $ZodCheckInternals<string> {
1036
+ def: $ZodCheckEndsWithDef;
1037
+ issc: errors.$ZodIssueInvalidStringFormat;
1038
+ }
1039
+
1040
+ export interface $ZodCheckEndsWith extends $ZodCheckInternals<string> {
1041
+ _zod: $ZodCheckEndsWithInternals;
1042
+ }
1043
+
1044
+ export const $ZodCheckEndsWith: core.$constructor<$ZodCheckEndsWith> = /*@__PURE__*/ core.$constructor(
1045
+ "$ZodCheckEndsWith",
1046
+ (inst, def) => {
1047
+ $ZodCheck.init(inst, def);
1048
+
1049
+ const pattern = new RegExp(`.*${util.escapeRegex(def.suffix)}$`);
1050
+ def.pattern ??= pattern;
1051
+ inst._zod.onattach.push((inst) => {
1052
+ const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
1053
+ bag.patterns ??= new Set();
1054
+ bag.patterns.add(pattern);
1055
+ });
1056
+
1057
+ inst._zod.check = (payload) => {
1058
+ if (payload.value.endsWith(def.suffix)) return;
1059
+ payload.issues.push({
1060
+ origin: "string",
1061
+ code: "invalid_format",
1062
+ format: "ends_with",
1063
+ suffix: def.suffix,
1064
+ input: payload.value,
1065
+ inst,
1066
+ continue: !def.abort,
1067
+ });
1068
+ };
1069
+ }
1070
+ );
1071
+
1072
+ ///////////////////////////////////
1073
+ ///// $ZodCheckProperty /////
1074
+ ///////////////////////////////////
1075
+ function handleCheckPropertyResult(
1076
+ result: schemas.ParsePayload<unknown>,
1077
+ payload: schemas.ParsePayload<unknown>,
1078
+ property: string
1079
+ ) {
1080
+ if (result.issues.length) {
1081
+ payload.issues.push(...util.prefixIssues(property, result.issues));
1082
+ }
1083
+ }
1084
+ export interface $ZodCheckPropertyDef extends $ZodCheckDef {
1085
+ check: "property";
1086
+ property: string;
1087
+ schema: schemas.$ZodType;
1088
+ }
1089
+
1090
+ export interface $ZodCheckPropertyInternals<T extends object = object> extends $ZodCheckInternals<T> {
1091
+ def: $ZodCheckPropertyDef;
1092
+ issc: errors.$ZodIssue;
1093
+ }
1094
+
1095
+ export interface $ZodCheckProperty<T extends object = object> extends $ZodCheck<T> {
1096
+ _zod: $ZodCheckPropertyInternals<T>;
1097
+ }
1098
+
1099
+ export const $ZodCheckProperty: core.$constructor<$ZodCheckProperty> = /*@__PURE__*/ core.$constructor(
1100
+ "$ZodCheckProperty",
1101
+ (inst, def) => {
1102
+ $ZodCheck.init(inst, def);
1103
+
1104
+ inst._zod.check = (payload) => {
1105
+ const result = def.schema._zod.run(
1106
+ {
1107
+ value: (payload.value as any)[def.property],
1108
+ issues: [],
1109
+ },
1110
+ {}
1111
+ );
1112
+
1113
+ if (result instanceof Promise) {
1114
+ return result.then((result) => handleCheckPropertyResult(result, payload, def.property));
1115
+ }
1116
+
1117
+ handleCheckPropertyResult(result, payload, def.property);
1118
+ return;
1119
+ };
1120
+ }
1121
+ );
1122
+
1123
+ ///////////////////////////////////
1124
+ ///// $ZodCheckMimeType /////
1125
+ ///////////////////////////////////
1126
+ export interface $ZodCheckMimeTypeDef extends $ZodCheckDef {
1127
+ check: "mime_type";
1128
+ mime: util.MimeTypes[];
1129
+ }
1130
+
1131
+ export interface $ZodCheckMimeTypeInternals<T extends File = File> extends $ZodCheckInternals<T> {
1132
+ def: $ZodCheckMimeTypeDef;
1133
+ issc: errors.$ZodIssueInvalidValue;
1134
+ }
1135
+
1136
+ export interface $ZodCheckMimeType<T extends File = File> extends $ZodCheck<T> {
1137
+ _zod: $ZodCheckMimeTypeInternals<T>;
1138
+ }
1139
+
1140
+ export const $ZodCheckMimeType: core.$constructor<$ZodCheckMimeType> = /*@__PURE__*/ core.$constructor(
1141
+ "$ZodCheckMimeType",
1142
+ (inst, def) => {
1143
+ $ZodCheck.init(inst, def);
1144
+ const mimeSet = new Set(def.mime);
1145
+ inst._zod.onattach.push((inst) => {
1146
+ inst._zod.bag.mime = def.mime;
1147
+ });
1148
+ inst._zod.check = (payload) => {
1149
+ if (mimeSet.has(payload.value.type)) return;
1150
+ payload.issues.push({
1151
+ code: "invalid_value",
1152
+ values: def.mime,
1153
+ input: payload.value.type,
1154
+ inst,
1155
+ });
1156
+ };
1157
+ }
1158
+ );
1159
+
1160
+ ///////////////////////////////////
1161
+ ///// $ZodCheckFileName /////
1162
+ ///////////////////////////////////
1163
+ // interface $ZodCheckFileNameDef extends $ZodCheckDef {
1164
+ // check: "file_name";
1165
+ // fileName: string;
1166
+ // error?: errors.$ZodErrorMap<errors.$ZodIssueInvalidType> | undefined;
1167
+ // }
1168
+ // export interface $ZodCheckFileName<T extends File = File>
1169
+ // extends $ZodCheckInternals<T> {
1170
+ // _def: $ZodCheckFileNameDef;
1171
+ // }
1172
+
1173
+ // export const $ZodCheckFileName: core.$constructor<$ZodCheckFileName> =
1174
+ // core.$constructor("$ZodCheckFileName", (inst, def) => {
1175
+ // $ZodCheck.init(inst, def);
1176
+
1177
+ // inst._zod.check = (payload) => {
1178
+ // if (def.fileName === payload.value.name) return;
1179
+ // payload.issues.push({
1180
+ // origin: "file",
1181
+ // code: "invalid_value",
1182
+ // options: [def.fileName],
1183
+ // input: payload.value,
1184
+ // path: ["name"],
1185
+ // inst,
1186
+ // });
1187
+ // };
1188
+ // });
1189
+
1190
+ ///////////////////////////////////
1191
+ ///// $ZodCheckOverwrite /////
1192
+ ///////////////////////////////////
1193
+ export interface $ZodCheckOverwriteDef<T = unknown> extends $ZodCheckDef {
1194
+ check: "overwrite";
1195
+ tx(value: T): T;
1196
+ }
1197
+
1198
+ export interface $ZodCheckOverwriteInternals<T = unknown> extends $ZodCheckInternals<T> {
1199
+ def: $ZodCheckOverwriteDef<T>;
1200
+ issc: never;
1201
+ }
1202
+
1203
+ export interface $ZodCheckOverwrite<T = unknown> extends $ZodCheck<T> {
1204
+ _zod: $ZodCheckOverwriteInternals<T>;
1205
+ }
1206
+
1207
+ export const $ZodCheckOverwrite: core.$constructor<$ZodCheckOverwrite> = /*@__PURE__*/ core.$constructor(
1208
+ "$ZodCheckOverwrite",
1209
+ (inst, def) => {
1210
+ $ZodCheck.init(inst, def);
1211
+
1212
+ inst._zod.check = (payload) => {
1213
+ payload.value = def.tx(payload.value);
1214
+ };
1215
+ }
1216
+ );
1217
+
1218
+ // ///////////////////////////////
1219
+ // ///// $ZodCheckTrim /////
1220
+ // ///////////////////////////////
1221
+ // export interface $ZodCheckTrimDef extends $ZodCheckDef {
1222
+ // check: "trim";
1223
+ // error?: errors.$ZodErrorMap<never> | undefined;
1224
+ // }
1225
+ // export interface $ZodCheckTrim extends $ZodCheckInternals<string> {
1226
+ // _def: $ZodCheckTrimDef;
1227
+ // }
1228
+
1229
+ // export const $ZodCheckTrim: core.$constructor<$ZodCheckTrim> =
1230
+ // core.$constructor("$ZodCheckTrim", (inst, def) => {
1231
+ // $ZodCheck.init(inst, def);
1232
+
1233
+ // inst._zod.check = (payload) => {
1234
+ // payload.value = payload.value.trim();
1235
+ // };
1236
+ // });
1237
+
1238
+ // //////////////////////////////////////
1239
+ // ///// $ZodCheckNormalize /////
1240
+ // //////////////////////////////////////
1241
+ // interface $ZodCheckNormalizeDef extends $ZodCheckDef {
1242
+ // check: "normalize";
1243
+ // error?: errors.$ZodErrorMap<never> | undefined;
1244
+ // }
1245
+
1246
+ // export interface $ZodCheckNormalize extends $ZodCheckInternals<string> {
1247
+ // _def: $ZodCheckNormalizeDef;
1248
+ // }
1249
+
1250
+ // export const $ZodCheckNormalize: core.$constructor<$ZodCheckNormalize> =
1251
+ // core.$constructor("$ZodCheckNormalize", (inst, def) => {
1252
+ // $ZodCheck.init(inst, def);
1253
+
1254
+ // inst._zod.check = (payload) => {
1255
+ // payload.value = payload.value.normalize();
1256
+ // };
1257
+ // });
1258
+
1259
+ export type $ZodChecks =
1260
+ | $ZodCheckLessThan
1261
+ | $ZodCheckGreaterThan
1262
+ | $ZodCheckMultipleOf
1263
+ | $ZodCheckNumberFormat
1264
+ | $ZodCheckBigIntFormat
1265
+ | $ZodCheckMaxSize
1266
+ | $ZodCheckMinSize
1267
+ | $ZodCheckSizeEquals
1268
+ | $ZodCheckMaxLength
1269
+ | $ZodCheckMinLength
1270
+ | $ZodCheckLengthEquals
1271
+ | $ZodCheckStringFormat
1272
+ | $ZodCheckProperty
1273
+ | $ZodCheckMimeType
1274
+ | $ZodCheckOverwrite;
1275
+
1276
+ export type $ZodStringFormatChecks =
1277
+ | $ZodCheckRegex
1278
+ | $ZodCheckLowerCase
1279
+ | $ZodCheckUpperCase
1280
+ | $ZodCheckIncludes
1281
+ | $ZodCheckStartsWith
1282
+ | $ZodCheckEndsWith
1283
+ | schemas.$ZodStringFormatTypes; // union of string format schema types
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/config.ts ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type * as errors from "./errors.js";
2
+
3
+ export interface $ZodConfig {
4
+ /** Custom error map. Overrides `config().localeError`. */
5
+ customError?: errors.$ZodErrorMap | undefined;
6
+ /** Localized error map. Lowest priority. */
7
+ localeError?: errors.$ZodErrorMap | undefined;
8
+ }
9
+
10
+ export const globalConfig: $ZodConfig = {};
11
+
12
+ export function config(config?: Partial<$ZodConfig>): $ZodConfig {
13
+ if (config) Object.assign(globalConfig, config);
14
+ return globalConfig;
15
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/core.ts ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type * as errors from "./errors.js";
2
+ import type * as schemas from "./schemas.js";
3
+ import type { Class } from "./util.js";
4
+ ////////////////////////////// CONSTRUCTORS ///////////////////////////////////////
5
+
6
+ type ZodTrait = { _zod: { def: any; [k: string]: any } };
7
+ export interface $constructor<T extends ZodTrait, D = T["_zod"]["def"]> {
8
+ new (def: D): T;
9
+ init(inst: T, def: D): asserts inst is T;
10
+ }
11
+
12
+ /** A special constant with type `never` */
13
+ export const NEVER: never = Object.freeze({
14
+ status: "aborted",
15
+ }) as never;
16
+
17
+ export /*@__NO_SIDE_EFFECTS__*/ function $constructor<T extends ZodTrait, D = T["_zod"]["def"]>(
18
+ name: string,
19
+ initializer: (inst: T, def: D) => void,
20
+ params?: { Parent?: typeof Class }
21
+ ): $constructor<T, D> {
22
+ function init(inst: T, def: D) {
23
+ Object.defineProperty(inst, "_zod", {
24
+ value: inst._zod ?? {},
25
+ enumerable: false,
26
+ });
27
+
28
+ inst._zod.traits ??= new Set();
29
+
30
+ inst._zod.traits.add(name);
31
+ initializer(inst, def);
32
+ // support prototype modifications
33
+ for (const k in _.prototype) {
34
+ if (!(k in inst)) Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
35
+ }
36
+ inst._zod.constr = _;
37
+ inst._zod.def = def;
38
+ }
39
+
40
+ // doesn't work if Parent has a constructor with arguments
41
+ const Parent = params?.Parent ?? Object;
42
+ class Definition extends Parent {}
43
+ Object.defineProperty(Definition, "name", { value: name });
44
+
45
+ function _(this: any, def: D) {
46
+ const inst = params?.Parent ? new Definition() : this;
47
+ init(inst, def);
48
+ inst._zod.deferred ??= [];
49
+ for (const fn of inst._zod.deferred) {
50
+ fn();
51
+ }
52
+ return inst;
53
+ }
54
+
55
+ Object.defineProperty(_, "init", { value: init });
56
+ Object.defineProperty(_, Symbol.hasInstance, {
57
+ value: (inst: any) => {
58
+ if (params?.Parent && inst instanceof params.Parent) return true;
59
+ return inst?._zod?.traits?.has(name);
60
+ },
61
+ });
62
+ Object.defineProperty(_, "name", { value: name });
63
+ return _ as any;
64
+ }
65
+
66
+ ////////////////////////////// UTILITIES ///////////////////////////////////////
67
+ export const $brand: unique symbol = Symbol("zod_brand");
68
+ export type $brand<T extends string | number | symbol = string | number | symbol> = {
69
+ [$brand]: { [k in T]: true };
70
+ };
71
+
72
+ export type $ZodBranded<T extends schemas.SomeType, Brand extends string | number | symbol> = T &
73
+ Record<"_zod", Record<"output", output<T> & $brand<Brand>>>;
74
+
75
+ export class $ZodAsyncError extends Error {
76
+ constructor() {
77
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
78
+ }
79
+ }
80
+
81
+ //////////////////////////// TYPE HELPERS ///////////////////////////////////
82
+
83
+ // export type input<T extends schemas.$ZodType> = T["_zod"]["input"];
84
+ // export type output<T extends schemas.$ZodType> = T["_zod"]["output"];
85
+ // export type input<T extends schemas.$ZodType> = T["_zod"]["input"];
86
+ // export type output<T extends schemas.$ZodType> = T["_zod"]["output"];
87
+ export type input<T> = T extends { _zod: { input: any } } ? Required<T["_zod"]>["input"] : unknown;
88
+ export type output<T> = T extends { _zod: { output: any } } ? Required<T["_zod"]>["output"] : unknown;
89
+
90
+ // Mk2
91
+ // export type input<T> = T extends { _zod: { "~input": any } }
92
+ // ? T["_zod"]["~input"]
93
+ // : T extends { _zod: { input: any } }
94
+ // ? T["_zod"]["input"]
95
+ // : never;
96
+ // export type output<T> = T extends { _zod: { "~output": any } }
97
+ // ? T["_zod"]["~output"]
98
+ // : T extends { _zod: { output: any } }
99
+ // ? T["_zod"]["output"]
100
+ // : never;
101
+ // Mk 3
102
+ // export type input<T extends schemas.$ZodType> = T["_zod"]["input"];
103
+ // export type output<T extends schemas.$ZodType> = T["_zod"]["output"];
104
+ // Mk 4
105
+ // export type input<T extends schemas.$ZodType> = T[] extends { _zod: { "~input": any } }
106
+ // ? T["_zod"]["~input"]
107
+ // : T extends { _zod: { input: any } }
108
+ // ? T["_zod"]["input"]
109
+ // : never;
110
+ // export type output<T extends schemas.$ZodType> = T extends { _zod: { "~output": any } }
111
+ // ? T["_zod"]["~output"]
112
+ // : T extends { _zod: { output: any } }
113
+ // ? T["_zod"]["output"]
114
+ // : never;
115
+
116
+ export type { output as infer };
117
+
118
+ ////////////////////////////// CONFIG ///////////////////////////////////////
119
+
120
+ export interface $ZodConfig {
121
+ /** Custom error map. Overrides `config().localeError`. */
122
+ customError?: errors.$ZodErrorMap | undefined;
123
+ /** Localized error map. Lowest priority. */
124
+ localeError?: errors.$ZodErrorMap | undefined;
125
+ /** Disable JIT schema compilation. Useful in environments that disallow `eval`. */
126
+ jitless?: boolean | undefined;
127
+ }
128
+
129
+ export const globalConfig: $ZodConfig = {};
130
+
131
+ export function config(newConfig?: Partial<$ZodConfig>): $ZodConfig {
132
+ if (newConfig) Object.assign(globalConfig, newConfig);
133
+ return globalConfig;
134
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/doc.ts ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ type ModeWriter = (doc: Doc, modes: { execution: "sync" | "async" }) => void;
2
+
3
+ export class Doc {
4
+ args!: string[];
5
+ content: string[] = [];
6
+ indent = 0;
7
+
8
+ constructor(args: string[] = []) {
9
+ if (this) this.args = args;
10
+ }
11
+
12
+ indented(fn: (doc: Doc) => void) {
13
+ this.indent += 1;
14
+ fn(this);
15
+ this.indent -= 1;
16
+ }
17
+
18
+ write(fn: ModeWriter): void;
19
+ write(line: string): void;
20
+ write(arg: any) {
21
+ if (typeof arg === "function") {
22
+ (arg as ModeWriter)(this, { execution: "sync" });
23
+ (arg as ModeWriter)(this, { execution: "async" });
24
+ return;
25
+ }
26
+
27
+ const content = arg as string;
28
+ const lines = content.split("\n").filter((x) => x);
29
+ const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
30
+ const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
31
+ for (const line of dedented) {
32
+ this.content.push(line);
33
+ }
34
+ }
35
+
36
+ compile() {
37
+ const F = Function;
38
+ const args = this?.args;
39
+ const content = this?.content ?? [``];
40
+ const lines = [...content.map((x) => ` ${x}`)];
41
+ // console.log(lines.join("\n"));
42
+ return new F(...args, lines.join("\n"));
43
+ }
44
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/errors.ts ADDED
@@ -0,0 +1,424 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodCheck, $ZodStringFormats } from "./checks.js";
2
+ import { $constructor } from "./core.js";
3
+ import type { $ZodType } from "./schemas.js";
4
+ import * as util from "./util.js";
5
+
6
+ ///////////////////////////
7
+ //// base type ////
8
+ ///////////////////////////
9
+ export interface $ZodIssueBase {
10
+ readonly code?: string;
11
+ readonly input?: unknown;
12
+ readonly path: PropertyKey[];
13
+ readonly message: string;
14
+ // [k: string]: unknown;
15
+ }
16
+
17
+ ////////////////////////////////
18
+ //// issue subtypes ////
19
+ ////////////////////////////////
20
+ export interface $ZodIssueInvalidType<Input = unknown> extends $ZodIssueBase {
21
+ readonly code: "invalid_type";
22
+ readonly expected: $ZodType["_zod"]["def"]["type"];
23
+ readonly input: Input;
24
+ }
25
+
26
+ export interface $ZodIssueTooBig<Input = unknown> extends $ZodIssueBase {
27
+ readonly code: "too_big";
28
+ readonly origin: "number" | "int" | "bigint" | "date" | "string" | "array" | "set" | "file" | (string & {});
29
+ readonly maximum: number | bigint;
30
+ readonly inclusive?: boolean;
31
+ readonly exact?: boolean;
32
+ readonly input: Input;
33
+ }
34
+
35
+ export interface $ZodIssueTooSmall<Input = unknown> extends $ZodIssueBase {
36
+ readonly code: "too_small";
37
+ readonly origin: "number" | "int" | "bigint" | "date" | "string" | "array" | "set" | "file" | (string & {});
38
+ readonly minimum: number | bigint;
39
+ /** True if the allowable range includes the minimum */
40
+ readonly inclusive?: boolean;
41
+ /** True if the allowed value is fixed (e.g.` z.length(5)`), not a range (`z.minLength(5)`) */
42
+ readonly exact?: boolean;
43
+ readonly input: Input;
44
+ }
45
+
46
+ export interface $ZodIssueInvalidStringFormat extends $ZodIssueBase {
47
+ readonly code: "invalid_format";
48
+ readonly format: $ZodStringFormats | (string & {});
49
+ readonly pattern?: string;
50
+ readonly input: string;
51
+ }
52
+
53
+ export interface $ZodIssueNotMultipleOf<Input extends number | bigint = number | bigint> extends $ZodIssueBase {
54
+ readonly code: "not_multiple_of";
55
+ readonly divisor: number;
56
+ readonly input: Input;
57
+ }
58
+
59
+ export interface $ZodIssueUnrecognizedKeys extends $ZodIssueBase {
60
+ readonly code: "unrecognized_keys";
61
+ readonly keys: string[];
62
+ readonly input: Record<string, unknown>;
63
+ }
64
+
65
+ export interface $ZodIssueInvalidUnion extends $ZodIssueBase {
66
+ readonly code: "invalid_union";
67
+ readonly errors: $ZodIssue[][];
68
+ readonly input: unknown;
69
+ }
70
+
71
+ export interface $ZodIssueInvalidKey<Input = unknown> extends $ZodIssueBase {
72
+ readonly code: "invalid_key";
73
+ readonly origin: "map" | "record";
74
+ readonly issues: $ZodIssue[];
75
+ readonly input: Input;
76
+ }
77
+
78
+ export interface $ZodIssueInvalidElement<Input = unknown> extends $ZodIssueBase {
79
+ readonly code: "invalid_element";
80
+ readonly origin: "map" | "set";
81
+ readonly key: unknown;
82
+ readonly issues: $ZodIssue[];
83
+ readonly input: Input;
84
+ }
85
+
86
+ export interface $ZodIssueInvalidValue<Input = unknown> extends $ZodIssueBase {
87
+ readonly code: "invalid_value";
88
+ readonly values: util.Primitive[];
89
+ readonly input: Input;
90
+ }
91
+
92
+ export interface $ZodIssueCustom extends $ZodIssueBase {
93
+ readonly code: "custom";
94
+ readonly params?: Record<string, any> | undefined;
95
+ readonly input: unknown;
96
+ }
97
+
98
+ ////////////////////////////////////////////
99
+ //// first-party string formats ////
100
+ ////////////////////////////////////////////
101
+
102
+ export interface $ZodIssueStringCommonFormats extends $ZodIssueInvalidStringFormat {
103
+ format: Exclude<$ZodStringFormats, "regex" | "jwt" | "starts_with" | "ends_with" | "includes">;
104
+ }
105
+
106
+ export interface $ZodIssueStringInvalidRegex extends $ZodIssueInvalidStringFormat {
107
+ format: "regex";
108
+ pattern: string;
109
+ }
110
+
111
+ export interface $ZodIssueStringInvalidJWT extends $ZodIssueInvalidStringFormat {
112
+ format: "jwt";
113
+ algorithm?: string;
114
+ }
115
+
116
+ export interface $ZodIssueStringStartsWith extends $ZodIssueInvalidStringFormat {
117
+ format: "starts_with";
118
+ prefix: string;
119
+ }
120
+
121
+ export interface $ZodIssueStringEndsWith extends $ZodIssueInvalidStringFormat {
122
+ format: "ends_with";
123
+ suffix: string;
124
+ }
125
+
126
+ export interface $ZodIssueStringIncludes extends $ZodIssueInvalidStringFormat {
127
+ format: "includes";
128
+ includes: string;
129
+ }
130
+
131
+ export type $ZodStringFormatIssues =
132
+ | $ZodIssueStringCommonFormats
133
+ | $ZodIssueStringInvalidRegex
134
+ | $ZodIssueStringInvalidJWT
135
+ | $ZodIssueStringStartsWith
136
+ | $ZodIssueStringEndsWith
137
+ | $ZodIssueStringIncludes;
138
+
139
+ ////////////////////////
140
+ //// utils /////
141
+ ////////////////////////
142
+
143
+ export type $ZodIssue =
144
+ | $ZodIssueInvalidType
145
+ | $ZodIssueTooBig
146
+ | $ZodIssueTooSmall
147
+ | $ZodIssueInvalidStringFormat
148
+ | $ZodIssueNotMultipleOf
149
+ | $ZodIssueUnrecognizedKeys
150
+ | $ZodIssueInvalidUnion
151
+ | $ZodIssueInvalidKey
152
+ | $ZodIssueInvalidElement
153
+ | $ZodIssueInvalidValue
154
+ | $ZodIssueCustom;
155
+
156
+ export type $ZodIssueCode = $ZodIssue["code"];
157
+
158
+ export type $ZodRawIssue<T extends $ZodIssueBase = $ZodIssue> = T extends any ? RawIssue<T> : never;
159
+ type RawIssue<T extends $ZodIssueBase> = util.Flatten<
160
+ util.MakePartial<T, "message" | "path"> & {
161
+ /** The input data */
162
+ readonly input?: unknown;
163
+ /** The schema or check that originated this issue. */
164
+ readonly inst?: $ZodType | $ZodCheck;
165
+ /** @deprecated Internal use only. If `true`, Zod will continue executing validation despite this issue. */
166
+ readonly continue?: boolean | undefined;
167
+ } & Record<string, any>
168
+ >;
169
+
170
+ export interface $ZodErrorMap<T extends $ZodIssueBase = $ZodIssue> {
171
+ // biome-ignore lint:
172
+ (issue: $ZodRawIssue<T>): { message: string } | string | undefined | null;
173
+ }
174
+
175
+ //////////////////////// ERROR CLASS ////////////////////////
176
+
177
+ // const ZOD_ERROR: symbol = Symbol.for("{{zod.error}}");
178
+ export interface $ZodError<T = unknown> extends Error {
179
+ type: T;
180
+ issues: $ZodIssue[];
181
+ _zod: {
182
+ output: T;
183
+ def: $ZodIssue[];
184
+ };
185
+ stack?: string;
186
+ name: string;
187
+ }
188
+
189
+ const initializer = (inst: $ZodError, def: $ZodIssue[]): void => {
190
+ inst.name = "$ZodError";
191
+ Object.defineProperty(inst, "_zod", {
192
+ value: inst._zod,
193
+ enumerable: false,
194
+ });
195
+ Object.defineProperty(inst, "issues", {
196
+ value: def,
197
+ enumerable: false,
198
+ });
199
+ Object.defineProperty(inst, "message", {
200
+ get() {
201
+ return JSON.stringify(def, util.jsonStringifyReplacer, 2);
202
+ },
203
+ enumerable: true,
204
+ // configurable: false,
205
+ });
206
+ Object.defineProperty(inst, "toString", {
207
+ value: () => inst.message,
208
+ enumerable: false,
209
+ });
210
+ };
211
+
212
+ export const $ZodError: $constructor<$ZodError> = $constructor("$ZodError", initializer);
213
+ interface $ZodRealError<T = any> extends $ZodError<T> {}
214
+ export const $ZodRealError: $constructor<$ZodRealError> = $constructor("$ZodError", initializer, { Parent: Error });
215
+
216
+ /////////////////// ERROR UTILITIES ////////////////////////
217
+
218
+ // flatten
219
+ export type $ZodFlattenedError<T, U = string> = _FlattenedError<T, U>;
220
+ type _FlattenedError<T, U = string> = {
221
+ formErrors: U[];
222
+ fieldErrors: {
223
+ [P in keyof T]?: U[];
224
+ };
225
+ };
226
+
227
+ export function flattenError<T>(error: $ZodError<T>): _FlattenedError<T>;
228
+ export function flattenError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): _FlattenedError<T, U>;
229
+ export function flattenError(error: $ZodError, mapper = (issue: $ZodIssue) => issue.message): any {
230
+ const fieldErrors: any = {};
231
+ const formErrors: any[] = [];
232
+ for (const sub of error.issues) {
233
+ if (sub.path.length > 0) {
234
+ fieldErrors[sub.path[0]!] = fieldErrors[sub.path[0]!] || [];
235
+ fieldErrors[sub.path[0]!].push(mapper(sub));
236
+ } else {
237
+ formErrors.push(mapper(sub));
238
+ }
239
+ }
240
+ return { formErrors, fieldErrors };
241
+ }
242
+
243
+ type _ZodFormattedError<T, U = string> = T extends [any, ...any[]]
244
+ ? { [K in keyof T]?: $ZodFormattedError<T[K], U> }
245
+ : T extends any[]
246
+ ? { [k: number]: $ZodFormattedError<T[number], U> }
247
+ : T extends object
248
+ ? util.Flatten<{ [K in keyof T]?: $ZodFormattedError<T[K], U> }>
249
+ : any;
250
+
251
+ export type $ZodFormattedError<T, U = string> = {
252
+ _errors: U[];
253
+ } & util.Flatten<_ZodFormattedError<T, U>>;
254
+
255
+ export function formatError<T>(error: $ZodError<T>): $ZodFormattedError<T>;
256
+ export function formatError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): $ZodFormattedError<T, U>;
257
+ export function formatError<T>(error: $ZodError, _mapper?: any) {
258
+ const mapper: (issue: $ZodIssue) => any =
259
+ _mapper ||
260
+ function (issue: $ZodIssue) {
261
+ return issue.message;
262
+ };
263
+ const fieldErrors: $ZodFormattedError<T> = { _errors: [] } as any;
264
+ const processError = (error: { issues: $ZodIssue[] }) => {
265
+ for (const issue of error.issues) {
266
+ if (issue.code === "invalid_union" && issue.errors.length) {
267
+ issue.errors.map((issues) => processError({ issues }));
268
+ } else if (issue.code === "invalid_key") {
269
+ processError({ issues: issue.issues });
270
+ } else if (issue.code === "invalid_element") {
271
+ processError({ issues: issue.issues });
272
+ } else if (issue.path.length === 0) {
273
+ (fieldErrors as any)._errors.push(mapper(issue));
274
+ } else {
275
+ let curr: any = fieldErrors;
276
+ let i = 0;
277
+ while (i < issue.path.length) {
278
+ const el = issue.path[i]!;
279
+ const terminal = i === issue.path.length - 1;
280
+
281
+ if (!terminal) {
282
+ curr[el] = curr[el] || { _errors: [] };
283
+ } else {
284
+ curr[el] = curr[el] || { _errors: [] };
285
+ curr[el]._errors.push(mapper(issue));
286
+ }
287
+
288
+ curr = curr[el];
289
+ i++;
290
+ }
291
+ }
292
+ }
293
+ };
294
+ processError(error);
295
+ return fieldErrors;
296
+ }
297
+
298
+ export type $ZodErrorTree<T, U = string> = T extends [any, ...any[]]
299
+ ? { errors: U[]; items?: { [K in keyof T]?: $ZodErrorTree<T[K], U> } }
300
+ : T extends any[]
301
+ ? { errors: U[]; items?: Array<$ZodErrorTree<T[number], U>> }
302
+ : T extends object
303
+ ? { errors: U[]; properties?: { [K in keyof T]?: $ZodErrorTree<T[K], U> } }
304
+ : { errors: U[] };
305
+
306
+ export function treeifyError<T>(error: $ZodError<T>): $ZodErrorTree<T>;
307
+ export function treeifyError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): $ZodErrorTree<T, U>;
308
+ export function treeifyError<T>(error: $ZodError, _mapper?: any) {
309
+ const mapper: (issue: $ZodIssue) => any =
310
+ _mapper ||
311
+ function (issue: $ZodIssue) {
312
+ return issue.message;
313
+ };
314
+ const result: $ZodErrorTree<T> = { errors: [] } as any;
315
+ const processError = (error: { issues: $ZodIssue[] }, path: PropertyKey[] = []) => {
316
+ for (const issue of error.issues) {
317
+ if (issue.code === "invalid_union" && issue.errors.length) {
318
+ // regular union error
319
+ issue.errors.map((issues) => processError({ issues }, issue.path));
320
+ } else if (issue.code === "invalid_key") {
321
+ processError({ issues: issue.issues }, issue.path);
322
+ } else if (issue.code === "invalid_element") {
323
+ processError({ issues: issue.issues }, issue.path);
324
+ } else {
325
+ const fullpath = [...path, ...issue.path];
326
+ if (fullpath.length === 0) {
327
+ result.errors.push(mapper(issue));
328
+ continue;
329
+ }
330
+
331
+ let curr: any = result;
332
+ let i = 0;
333
+ while (i < fullpath.length) {
334
+ const el = fullpath[i]!;
335
+
336
+ const terminal = i === fullpath.length - 1;
337
+ if (typeof el === "string") {
338
+ curr.properties ??= {};
339
+ curr.properties[el] ??= { errors: [] };
340
+ curr = curr.properties[el];
341
+ } else {
342
+ curr.items ??= [];
343
+ curr.items[el] ??= { errors: [] };
344
+ curr = curr.items[el];
345
+ }
346
+
347
+ if (terminal) {
348
+ curr.errors.push(mapper(issue));
349
+ }
350
+
351
+ i++;
352
+ }
353
+ }
354
+ }
355
+ };
356
+ processError(error);
357
+ return result;
358
+ }
359
+
360
+ /** Format a ZodError as a human-readable string in the following form.
361
+ *
362
+ * From
363
+ *
364
+ * ```ts
365
+ * ZodError {
366
+ * issues: [
367
+ * {
368
+ * expected: 'string',
369
+ * code: 'invalid_type',
370
+ * path: [ 'username' ],
371
+ * message: 'Invalid input: expected string'
372
+ * },
373
+ * {
374
+ * expected: 'number',
375
+ * code: 'invalid_type',
376
+ * path: [ 'favoriteNumbers', 1 ],
377
+ * message: 'Invalid input: expected number'
378
+ * }
379
+ * ];
380
+ * }
381
+ * ```
382
+ *
383
+ * to
384
+ *
385
+ * ```
386
+ * username
387
+ * ✖ Expected number, received string at "username
388
+ * favoriteNumbers[0]
389
+ * ✖ Invalid input: expected number
390
+ * ```
391
+ */
392
+ export function toDotPath(path: (string | number | symbol)[]): string {
393
+ const segs: string[] = [];
394
+ for (const seg of path) {
395
+ if (typeof seg === "number") segs.push(`[${seg}]`);
396
+ else if (typeof seg === "symbol") segs.push(`[${JSON.stringify(String(seg))}]`);
397
+ else if (/[^\w$]/.test(seg)) segs.push(`[${JSON.stringify(seg)}]`);
398
+ else {
399
+ if (segs.length) segs.push(".");
400
+ segs.push(seg);
401
+ }
402
+ }
403
+
404
+ return segs.join("");
405
+ }
406
+
407
+ interface BaseError {
408
+ issues: $ZodIssueBase[];
409
+ }
410
+
411
+ export function prettifyError(error: BaseError): string {
412
+ const lines: string[] = [];
413
+ // sort by path length
414
+ const issues = [...error.issues].sort((a, b) => a.path.length - b.path.length);
415
+
416
+ // Process each issue
417
+ for (const issue of issues) {
418
+ lines.push(`✖ ${issue.message}`);
419
+ if (issue.path?.length) lines.push(` → at ${toDotPath(issue.path)}`);
420
+ }
421
+
422
+ // Convert Map to formatted string
423
+ return lines.join("\n");
424
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/function.ts ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { _array, _tuple, _unknown } from "./api.js";
2
+ import type * as core from "./core.js";
3
+ import { parse, parseAsync } from "./parse.js";
4
+ import * as schemas from "./schemas.js";
5
+ import { $ZodTuple } from "./schemas.js";
6
+ import type * as util from "./util.js";
7
+
8
+ //////////////////////////////////////////
9
+ //////////////////////////////////////////
10
+ ////////// //////////
11
+ ////////// $ZodFunction //////////
12
+ ////////// //////////
13
+ //////////////////////////////////////////
14
+ //////////////////////////////////////////
15
+ export interface $ZodFunctionDef<
16
+ In extends $ZodFunctionIn = $ZodFunctionIn,
17
+ Out extends $ZodFunctionOut = $ZodFunctionOut,
18
+ > {
19
+ type: "function";
20
+ input: In;
21
+ output: Out;
22
+ }
23
+
24
+ export type $ZodFunctionArgs = schemas.$ZodType<unknown[], unknown[]>;
25
+ export type $ZodFunctionIn = $ZodFunctionArgs;
26
+ export type $ZodFunctionOut = schemas.$ZodType;
27
+
28
+ export type $InferInnerFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
29
+ ...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>
30
+ ) => core.input<Returns>;
31
+
32
+ export type $InferInnerFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
33
+ ...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>
34
+ ) => util.MaybeAsync<core.input<Returns>>;
35
+
36
+ export type $InferOuterFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
37
+ ...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>
38
+ ) => core.output<Returns>;
39
+
40
+ export type $InferOuterFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
41
+ ...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>
42
+ ) => util.MaybeAsync<core.output<Returns>>;
43
+
44
+ export class $ZodFunction<
45
+ Args extends $ZodFunctionIn = $ZodFunctionIn,
46
+ Returns extends $ZodFunctionOut = $ZodFunctionOut,
47
+ > {
48
+ def: $ZodFunctionDef<Args, Returns>;
49
+
50
+ /** @deprecated */
51
+ _def!: $ZodFunctionDef<Args, Returns>;
52
+ _input!: $InferInnerFunctionType<Args, Returns>;
53
+ _output!: $InferOuterFunctionType<Args, Returns>;
54
+
55
+ constructor(def: $ZodFunctionDef<Args, Returns>) {
56
+ this._def = def;
57
+ this.def = def;
58
+ }
59
+
60
+ implement<F extends $InferInnerFunctionType<Args, Returns>>(
61
+ func: F
62
+ ): // allow for return type inference
63
+ (
64
+ ...args: Parameters<this["_output"]>
65
+ ) => ReturnType<F> extends ReturnType<this["_output"]> ? ReturnType<F> : ReturnType<this["_output"]> {
66
+ if (typeof func !== "function") {
67
+ throw new Error("implement() must be called with a function");
68
+ }
69
+ const impl = ((...args: any[]) => {
70
+ const parsedArgs = this._def.input ? parse(this._def.input, args, undefined, { callee: impl }) : args;
71
+ if (!Array.isArray(parsedArgs)) {
72
+ throw new Error("Invalid arguments schema: not an array or tuple schema.");
73
+ }
74
+ const output = func(...(parsedArgs as any));
75
+ return this._def.output ? parse(this._def.output, output, undefined, { callee: impl }) : output;
76
+ }) as any;
77
+ return impl;
78
+ }
79
+
80
+ implementAsync<F extends $InferInnerFunctionTypeAsync<Args, Returns>>(
81
+ func: F
82
+ ): F extends $InferOuterFunctionTypeAsync<Args, Returns> ? F : $InferOuterFunctionTypeAsync<Args, Returns> {
83
+ if (typeof func !== "function") {
84
+ throw new Error("implement() must be called with a function");
85
+ }
86
+
87
+ const impl = (async (...args: any[]) => {
88
+ const parsedArgs = this._def.input ? await parseAsync(this._def.input, args, undefined, { callee: impl }) : args;
89
+ if (!Array.isArray(parsedArgs)) {
90
+ throw new Error("Invalid arguments schema: not an array or tuple schema.");
91
+ }
92
+ const output = await func(...(parsedArgs as any));
93
+ return this._def.output ? parseAsync(this._def.output, output, undefined, { callee: impl }) : output;
94
+ }) as any;
95
+ return impl;
96
+ }
97
+
98
+ input<const Items extends util.TupleItems, const Rest extends $ZodFunctionOut = $ZodFunctionOut>(
99
+ args: Items,
100
+ rest?: Rest
101
+ ): $ZodFunction<schemas.$ZodTuple<Items, Rest>, Returns>;
102
+ input<NewArgs extends $ZodFunctionIn>(args: NewArgs): $ZodFunction<NewArgs, Returns>;
103
+ input(...args: any[]): $ZodFunction<any, Returns> {
104
+ const F: any = this.constructor;
105
+ if (Array.isArray(args[0])) {
106
+ return new F({
107
+ type: "function",
108
+ input: new $ZodTuple({
109
+ type: "tuple",
110
+ items: args[0],
111
+ rest: args[1],
112
+ }),
113
+ output: this._def.output,
114
+ });
115
+ }
116
+
117
+ return new F({
118
+ type: "function",
119
+ input: args[0],
120
+ output: this._def.output,
121
+ });
122
+ }
123
+
124
+ output<NewReturns extends schemas.$ZodType>(output: NewReturns): $ZodFunction<Args, NewReturns> {
125
+ const F: any = this.constructor;
126
+ return new F({
127
+ type: "function",
128
+ input: this._def.input,
129
+ output,
130
+ });
131
+ }
132
+ }
133
+
134
+ export interface $ZodFunctionParams<I extends $ZodFunctionIn, O extends schemas.$ZodType> {
135
+ input?: I;
136
+ output?: O;
137
+ }
138
+
139
+ function _function(): $ZodFunction;
140
+ function _function<const In extends Array<schemas.$ZodType> = Array<schemas.$ZodType>>(params: {
141
+ input: In;
142
+ }): $ZodFunction<$ZodTuple<In, null>, $ZodFunctionOut>;
143
+ function _function<
144
+ const In extends Array<schemas.$ZodType> = Array<schemas.$ZodType>,
145
+ const Out extends $ZodFunctionOut = $ZodFunctionOut,
146
+ >(params: {
147
+ input: In;
148
+ output: Out;
149
+ }): $ZodFunction<$ZodTuple<In, null>, Out>;
150
+ function _function<const In extends $ZodFunctionIn = $ZodFunctionIn>(params: {
151
+ input: In;
152
+ }): $ZodFunction<In, $ZodFunctionOut>;
153
+ function _function<const Out extends $ZodFunctionOut = $ZodFunctionOut>(params: {
154
+ output: Out;
155
+ }): $ZodFunction<$ZodFunctionIn, Out>;
156
+ function _function<
157
+ In extends $ZodFunctionIn = $ZodFunctionIn,
158
+ Out extends schemas.$ZodType = schemas.$ZodType,
159
+ >(params?: {
160
+ input: In;
161
+ output: Out;
162
+ }): $ZodFunction<In, Out>;
163
+ function _function(params?: {
164
+ output?: schemas.$ZodType;
165
+ input?: $ZodFunctionArgs | Array<schemas.$ZodType>;
166
+ }): any {
167
+ return new $ZodFunction({
168
+ type: "function",
169
+ input: Array.isArray(params?.input)
170
+ ? _tuple(schemas.$ZodTuple, params?.input as any)
171
+ : (params?.input ?? _array(schemas.$ZodArray, _unknown(schemas.$ZodUnknown))),
172
+ output: params?.output ?? _unknown(schemas.$ZodUnknown),
173
+ });
174
+ }
175
+
176
+ export { _function as function };
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/index.ts ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export * from "./core.js";
2
+ export * from "./parse.js";
3
+ export * from "./errors.js";
4
+ export * from "./schemas.js";
5
+ export * from "./checks.js";
6
+ export * from "./versions.js";
7
+ export * as util from "./util.js";
8
+ export * as regexes from "./regexes.js";
9
+ export * as locales from "../locales/index.js";
10
+ export * from "./registries.js";
11
+ export * from "./doc.js";
12
+ export * from "./function.js";
13
+ export * from "./api.js";
14
+ export * from "./to-json-schema.js";
15
+ export * as JSONSchema from "./json-schema.js";
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/json-schema.ts ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export type Schema =
2
+ | ObjectSchema
3
+ | ArraySchema
4
+ | StringSchema
5
+ | NumberSchema
6
+ | IntegerSchema
7
+ | BooleanSchema
8
+ | NullSchema;
9
+
10
+ // export type JsonType = "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
11
+
12
+ // export interface JSONSchema {
13
+ // type?: string ;
14
+ // $id?: string ;
15
+ // id?: string ;
16
+ // $schema?: string ;
17
+ // $ref?: string ;
18
+ // $anchor?: string ;
19
+ // $defs?: { [key: string]: JSONSchema } ;
20
+ // definitions?: { [key: string]: JSONSchema } ;
21
+ // $comment?: string ;
22
+ // title?: string ;
23
+ // description?: string ;
24
+ // default?: unknown ;
25
+ // examples?: unknown[] ;
26
+ // readOnly?: boolean ;
27
+ // writeOnly?: boolean ;
28
+ // deprecated?: boolean ;
29
+ // allOf?: JSONSchema[] ;
30
+ // anyOf?: JSONSchema[] ;
31
+ // oneOf?: JSONSchema[] ;
32
+ // not?: JSONSchema ;
33
+ // if?: JSONSchema ;
34
+ // then?: JSONSchema ;
35
+ // else?: JSONSchema ;
36
+ // enum?: Array<string | number | boolean | null> ;
37
+ // const?: string | number | boolean | null ;
38
+ // [k: string]: unknown;
39
+
40
+ // /** A special key used as an intermediate representation of extends-style relationships. Omitted as a $ref with additional properties. */
41
+ // // _ref?: JSONSchema;
42
+ // _prefault?: unknown ;
43
+ // }
44
+
45
+ export type _JSONSchema = boolean | JSONSchema;
46
+ export type JSONSchema = {
47
+ [k: string]: unknown;
48
+ $schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#";
49
+ $id?: string;
50
+ $anchor?: string;
51
+ $ref?: string;
52
+ $dynamicRef?: string;
53
+ $dynamicAnchor?: string;
54
+ $vocabulary?: Record<string, boolean>;
55
+ $comment?: string;
56
+ $defs?: Record<string, JSONSchema>;
57
+ type?: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
58
+ additionalItems?: _JSONSchema;
59
+ unevaluatedItems?: _JSONSchema;
60
+ prefixItems?: _JSONSchema[];
61
+ items?: _JSONSchema | _JSONSchema[];
62
+ contains?: _JSONSchema;
63
+ additionalProperties?: _JSONSchema;
64
+ unevaluatedProperties?: _JSONSchema;
65
+ properties?: Record<string, _JSONSchema>;
66
+ patternProperties?: Record<string, _JSONSchema>;
67
+ dependentSchemas?: Record<string, _JSONSchema>;
68
+ propertyNames?: _JSONSchema;
69
+ if?: _JSONSchema;
70
+ then?: _JSONSchema;
71
+ else?: _JSONSchema;
72
+ allOf?: JSONSchema[];
73
+ anyOf?: JSONSchema[];
74
+ oneOf?: JSONSchema[];
75
+ not?: _JSONSchema;
76
+ multipleOf?: number;
77
+ maximum?: number;
78
+ exclusiveMaximum?: number;
79
+ minimum?: number;
80
+ exclusiveMinimum?: number;
81
+ maxLength?: number;
82
+ minLength?: number;
83
+ pattern?: string;
84
+ maxItems?: number;
85
+ minItems?: number;
86
+ uniqueItems?: boolean;
87
+ maxContains?: number;
88
+ minContains?: number;
89
+ maxProperties?: number;
90
+ minProperties?: number;
91
+ required?: string[];
92
+ dependentRequired?: Record<string, string[]>;
93
+ enum?: Array<string | number | boolean | null>;
94
+ const?: string | number | boolean | null;
95
+
96
+ // metadata
97
+ id?: string;
98
+ title?: string;
99
+ description?: string;
100
+ default?: unknown;
101
+ deprecated?: boolean;
102
+ readOnly?: boolean;
103
+ writeOnly?: boolean;
104
+ examples?: unknown[];
105
+ format?: string;
106
+ contentMediaType?: string;
107
+ contentEncoding?: string;
108
+ contentSchema?: JSONSchema;
109
+
110
+ // internal
111
+ _prefault?: unknown;
112
+ };
113
+
114
+ // for backwards compatibility
115
+ export type BaseSchema = JSONSchema;
116
+
117
+ export interface ObjectSchema extends JSONSchema {
118
+ type: "object";
119
+ }
120
+
121
+ export interface ArraySchema extends JSONSchema {
122
+ type: "array";
123
+ }
124
+
125
+ export interface StringSchema extends JSONSchema {
126
+ type: "string";
127
+ }
128
+
129
+ export interface NumberSchema extends JSONSchema {
130
+ type: "number";
131
+ }
132
+
133
+ export interface IntegerSchema extends JSONSchema {
134
+ type: "integer";
135
+ }
136
+
137
+ export interface BooleanSchema extends JSONSchema {
138
+ type: "boolean";
139
+ }
140
+
141
+ export interface NullSchema extends JSONSchema {
142
+ type: "null";
143
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/parse.ts ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
6
+ export type $ZodErrorClass = { new (issues: errors.$ZodIssue[]): errors.$ZodError };
7
+
8
+ /////////// METHODS ///////////
9
+ export type $Parse = <T extends schemas.$ZodType>(
10
+ schema: T,
11
+ value: unknown,
12
+ _ctx?: schemas.ParseContext<errors.$ZodIssue>,
13
+ _params?: { callee?: util.AnyFunc; Err?: $ZodErrorClass }
14
+ ) => core.output<T>;
15
+
16
+ export const _parse: (_Err: $ZodErrorClass) => $Parse = (_Err) => (schema, value, _ctx, _params) => {
17
+ const ctx: schemas.ParseContextInternal = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
18
+ const result = schema._zod.run({ value, issues: [] }, ctx);
19
+ if (result instanceof Promise) {
20
+ throw new core.$ZodAsyncError();
21
+ }
22
+ if (result.issues.length) {
23
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
24
+ util.captureStackTrace(e, _params?.callee);
25
+ throw e;
26
+ }
27
+ return result.value as core.output<typeof schema>;
28
+ };
29
+
30
+ export const parse: $Parse = /* @__PURE__*/ _parse(errors.$ZodRealError);
31
+
32
+ export type $ParseAsync = <T extends schemas.$ZodType>(
33
+ schema: T,
34
+ value: unknown,
35
+ _ctx?: schemas.ParseContext<errors.$ZodIssue>,
36
+ _params?: { callee?: util.AnyFunc; Err?: $ZodErrorClass }
37
+ ) => Promise<core.output<T>>;
38
+
39
+ export const _parseAsync: (_Err: $ZodErrorClass) => $ParseAsync = (_Err) => async (schema, value, _ctx, params) => {
40
+ const ctx: schemas.ParseContextInternal = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
41
+ let result = schema._zod.run({ value, issues: [] }, ctx);
42
+ if (result instanceof Promise) result = await result;
43
+ if (result.issues.length) {
44
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
45
+ util.captureStackTrace(e, params?.callee);
46
+ throw e;
47
+ }
48
+ return result.value as core.output<typeof schema>;
49
+ };
50
+
51
+ export const parseAsync: $ParseAsync = /* @__PURE__*/ _parseAsync(errors.$ZodRealError);
52
+
53
+ export type $SafeParse = <T extends schemas.$ZodType>(
54
+ schema: T,
55
+ value: unknown,
56
+ _ctx?: schemas.ParseContext<errors.$ZodIssue>
57
+ ) => util.SafeParseResult<core.output<T>>;
58
+
59
+ export const _safeParse: (_Err: $ZodErrorClass) => $SafeParse = (_Err) => (schema, value, _ctx) => {
60
+ const ctx: schemas.ParseContextInternal = _ctx ? { ..._ctx, async: false } : { async: false };
61
+ const result = schema._zod.run({ value, issues: [] }, ctx);
62
+ if (result instanceof Promise) {
63
+ throw new core.$ZodAsyncError();
64
+ }
65
+
66
+ return result.issues.length
67
+ ? {
68
+ success: false,
69
+ error: new (_Err ?? errors.$ZodError)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
70
+ }
71
+ : ({ success: true, data: result.value } as any);
72
+ };
73
+ export const safeParse: $SafeParse = /* @__PURE__*/ _safeParse(errors.$ZodRealError);
74
+
75
+ export type $SafeParseAsync = <T extends schemas.$ZodType>(
76
+ schema: T,
77
+ value: unknown,
78
+ _ctx?: schemas.ParseContext<errors.$ZodIssue>
79
+ ) => Promise<util.SafeParseResult<core.output<T>>>;
80
+
81
+ export const _safeParseAsync: (_Err: $ZodErrorClass) => $SafeParseAsync = (_Err) => async (schema, value, _ctx) => {
82
+ const ctx: schemas.ParseContextInternal = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
83
+ let result = schema._zod.run({ value, issues: [] }, ctx);
84
+ if (result instanceof Promise) result = await result;
85
+
86
+ return result.issues.length
87
+ ? {
88
+ success: false,
89
+ error: new _Err(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
90
+ }
91
+ : ({ success: true, data: result.value } as any);
92
+ };
93
+
94
+ export const safeParseAsync: $SafeParseAsync = /* @__PURE__*/ _safeParseAsync(errors.$ZodRealError);
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/regexes.ts ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export const cuid: RegExp = /^[cC][^\s-]{8,}$/;
2
+ export const cuid2: RegExp = /^[0-9a-z]+$/;
3
+ export const ulid: RegExp = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
4
+ export const xid: RegExp = /^[0-9a-vA-V]{20}$/;
5
+ export const ksuid: RegExp = /^[A-Za-z0-9]{27}$/;
6
+ export const nanoid: RegExp = /^[a-zA-Z0-9_-]{21}$/;
7
+
8
+ /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
9
+ export const duration: RegExp =
10
+ /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
11
+
12
+ /** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
13
+ export const extendedDuration: RegExp =
14
+ /^[-+]?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)?)??$/;
15
+
16
+ /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
17
+ export const guid: RegExp = /^([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})$/;
18
+
19
+ /** Returns a regex for validating an RFC 4122 UUID.
20
+ *
21
+ * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
22
+ export const uuid = (version?: number | undefined): RegExp => {
23
+ if (!version)
24
+ return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;
25
+ return new RegExp(
26
+ `^([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})$`
27
+ );
28
+ };
29
+ export const uuid4: RegExp = /*@__PURE__*/ uuid(4);
30
+ export const uuid6: RegExp = /*@__PURE__*/ uuid(6);
31
+ export const uuid7: RegExp = /*@__PURE__*/ uuid(7);
32
+
33
+ /** Practical email validation */
34
+ export const email: RegExp =
35
+ /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
36
+
37
+ /** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
38
+ export const html5Email: RegExp =
39
+ /^[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
+
41
+ /** The classic emailregex.com regex for RFC 5322-compliant emails */
42
+ export const rfc5322Email =
43
+ /^(([^<>()\[\]\\.,;:\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,}))$/;
44
+
45
+ /** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
46
+ export const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
47
+
48
+ export const browserEmail: RegExp =
49
+ /^[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])?)*$/;
50
+ // from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
51
+
52
+ export const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
53
+ export function emoji(): RegExp {
54
+ return new RegExp(_emoji, "u");
55
+ }
56
+
57
+ export const ipv4: RegExp =
58
+ /^(?:(?: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])$/;
59
+ export const ipv6: RegExp =
60
+ /^(([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})$/;
61
+
62
+ export const cidrv4: RegExp =
63
+ /^((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])$/;
64
+ export const cidrv6: RegExp =
65
+ /^(([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])$/;
66
+
67
+ // https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
68
+ export const base64: RegExp = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
69
+ export const base64url: RegExp = /^[A-Za-z0-9_-]*$/;
70
+
71
+ // based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
72
+ // export const hostname: RegExp =
73
+ // /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)+([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/;
74
+ export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
75
+ export const domain: RegExp = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
76
+
77
+ // https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
78
+ export const e164: RegExp = /^\+(?:[0-9]){6,14}[0-9]$/;
79
+
80
+ // 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])))`;
81
+ 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])))`;
82
+ export const date: RegExp = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
83
+
84
+ function timeSource(args: { precision?: number | null | undefined }) {
85
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
86
+ const regex =
87
+ typeof args.precision === "number"
88
+ ? args.precision === -1
89
+ ? `${hhmm}`
90
+ : args.precision === 0
91
+ ? `${hhmm}:[0-5]\\d`
92
+ : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}`
93
+ : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
94
+ return regex;
95
+ }
96
+ export function time(args: {
97
+ precision?: number | null;
98
+ // local?: boolean;
99
+ }): RegExp {
100
+ return new RegExp(`^${timeSource(args)}$`);
101
+ }
102
+
103
+ // Adapted from https://stackoverflow.com/a/3143231
104
+ export function datetime(args: {
105
+ precision?: number | null;
106
+ offset?: boolean;
107
+ local?: boolean;
108
+ }): RegExp {
109
+ const time = timeSource({ precision: args.precision });
110
+ const opts = ["Z"];
111
+ if (args.local) opts.push("");
112
+ if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
113
+ const timeRegex = `${time}(?:${opts.join("|")})`;
114
+
115
+ return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
116
+ }
117
+
118
+ export const string = (params?: { minimum?: number | undefined; maximum?: number | undefined }): RegExp => {
119
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
120
+ return new RegExp(`^${regex}$`);
121
+ };
122
+
123
+ export const bigint: RegExp = /^\d+n?$/;
124
+ export const integer: RegExp = /^\d+$/;
125
+ export const number: RegExp = /^-?\d+(?:\.\d+)?/i;
126
+ export const boolean: RegExp = /true|false/i;
127
+ const _null: RegExp = /null/i;
128
+ export { _null as null };
129
+ const _undefined: RegExp = /undefined/i;
130
+ export { _undefined as undefined };
131
+
132
+ // regex for string with no uppercase letters
133
+ export const lowercase: RegExp = /^[^A-Z]*$/;
134
+ // regex for string with no lowercase letters
135
+ export const uppercase: RegExp = /^[^a-z]*$/;
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/registries.ts ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type * as core from "./core.js";
2
+ import type { $ZodType } from "./schemas.js";
3
+
4
+ export const $output: unique symbol = Symbol("ZodOutput");
5
+ export type $output = typeof $output;
6
+ export const $input: unique symbol = Symbol("ZodInput");
7
+ export type $input = typeof $input;
8
+
9
+ export type $replace<Meta, S extends $ZodType> = Meta extends $output
10
+ ? core.output<S>
11
+ : Meta extends $input
12
+ ? core.input<S>
13
+ : Meta extends (infer M)[]
14
+ ? $replace<M, S>[]
15
+ : Meta extends (...args: infer P) => infer R
16
+ ? (
17
+ ...args: {
18
+ [K in keyof P]: $replace<P[K], S>; // tuple
19
+ }
20
+ ) => $replace<R, S>
21
+ : // handle objects
22
+ Meta extends object
23
+ ? { [K in keyof Meta]: $replace<Meta[K], S> }
24
+ : Meta;
25
+
26
+ type MetadataType = Record<string, unknown> | undefined;
27
+ export class $ZodRegistry<Meta extends MetadataType = MetadataType, Schema extends $ZodType = $ZodType> {
28
+ _meta!: Meta;
29
+ _schema!: Schema;
30
+ _map: Map<Schema, $replace<Meta, Schema>> = new Map();
31
+ _idmap: Map<string, Schema> = new Map();
32
+
33
+ add<S extends Schema>(
34
+ schema: S,
35
+ ..._meta: undefined extends Meta ? [$replace<Meta, S>?] : [$replace<Meta, S>]
36
+ ): this {
37
+ const meta: any = _meta[0];
38
+ this._map.set(schema, meta!);
39
+ if (meta && typeof meta === "object" && "id" in meta) {
40
+ if (this._idmap.has(meta.id!)) {
41
+ throw new Error(`ID ${meta.id} already exists in the registry`);
42
+ }
43
+ this._idmap.set(meta.id!, schema);
44
+ }
45
+ return this as any;
46
+ }
47
+
48
+ clear(): this {
49
+ this._map = new Map();
50
+ this._idmap = new Map();
51
+ return this;
52
+ }
53
+
54
+ remove(schema: Schema): this {
55
+ const meta: any = this._map.get(schema);
56
+ if (meta && typeof meta === "object" && "id" in meta) {
57
+ this._idmap.delete(meta.id!);
58
+ }
59
+ this._map.delete(schema);
60
+ return this;
61
+ }
62
+
63
+ get<S extends Schema>(schema: S): $replace<Meta, S> | undefined {
64
+ // return this._map.get(schema) as any;
65
+
66
+ // inherit metadata
67
+ const p = schema._zod.parent as Schema;
68
+ if (p) {
69
+ const pm: any = { ...(this.get(p) ?? {}) };
70
+ delete pm.id; // do not inherit id
71
+ return { ...pm, ...this._map.get(schema) } as any;
72
+ }
73
+ return this._map.get(schema) as any;
74
+ }
75
+
76
+ has(schema: Schema): boolean {
77
+ return this._map.has(schema);
78
+ }
79
+ }
80
+
81
+ export interface JSONSchemaMeta {
82
+ id?: string | undefined;
83
+ title?: string | undefined;
84
+ description?: string | undefined;
85
+ deprecated?: boolean | undefined;
86
+ [k: string]: unknown;
87
+ }
88
+
89
+ export interface GlobalMeta extends JSONSchemaMeta {}
90
+
91
+ // registries
92
+ export function registry<T extends MetadataType = MetadataType, S extends $ZodType = $ZodType>(): $ZodRegistry<T, S> {
93
+ return new $ZodRegistry<T, S>();
94
+ }
95
+
96
+ export const globalRegistry: $ZodRegistry<GlobalMeta> = /*@__PURE__*/ registry<GlobalMeta>();
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/schemas.ts ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/standard-schema.ts ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /** The Standard Schema interface. */
2
+ export interface StandardSchemaV1<Input = unknown, Output = Input> {
3
+ /** The Standard Schema properties. */
4
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
5
+ }
6
+
7
+ export declare namespace StandardSchemaV1 {
8
+ /** The Standard Schema properties interface. */
9
+ export interface Props<Input = unknown, Output = Input> {
10
+ /** The version number of the standard. */
11
+ readonly version: 1;
12
+ /** The vendor name of the schema library. */
13
+ readonly vendor: string;
14
+ /** Validates unknown input values. */
15
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
16
+ /** Inferred types associated with the schema. */
17
+ readonly types?: Types<Input, Output> | undefined;
18
+ }
19
+
20
+ /** The result interface of the validate function. */
21
+ export type Result<Output> = SuccessResult<Output> | FailureResult;
22
+
23
+ /** The result interface if validation succeeds. */
24
+ export interface SuccessResult<Output> {
25
+ /** The typed output value. */
26
+ readonly value: Output;
27
+ /** The non-existent issues. */
28
+ readonly issues?: undefined;
29
+ }
30
+
31
+ /** The result interface if validation fails. */
32
+ export interface FailureResult {
33
+ /** The issues of failed validation. */
34
+ readonly issues: ReadonlyArray<Issue>;
35
+ }
36
+
37
+ /** The issue interface of the failure output. */
38
+ export interface Issue {
39
+ /** The error message of the issue. */
40
+ readonly message: string;
41
+ /** The path of the issue, if any. */
42
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
43
+ }
44
+
45
+ /** The path segment interface of the issue. */
46
+ export interface PathSegment {
47
+ /** The key representing a path segment. */
48
+ readonly key: PropertyKey;
49
+ }
50
+
51
+ /** The Standard Schema types interface. */
52
+ export interface Types<Input = unknown, Output = Input> {
53
+ /** The input type of the schema. */
54
+ readonly input: Input;
55
+ /** The output type of the schema. */
56
+ readonly output: Output;
57
+ }
58
+
59
+ /** Infers the input type of a Standard Schema. */
60
+ export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
61
+
62
+ /** Infers the output type of a Standard Schema. */
63
+ export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
64
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/tests/index.test.ts ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v3";
3
+
4
+ test("test", () => {
5
+ expect(true).toBe(true);
6
+ });
7
+
8
+ test("test2", () => {
9
+ expect(() => z.string().parse(234)).toThrowErrorMatchingInlineSnapshot(`
10
+ [ZodError: [
11
+ {
12
+ "code": "invalid_type",
13
+ "expected": "string",
14
+ "received": "number",
15
+ "path": [],
16
+ "message": "Expected string, received number"
17
+ }
18
+ ]]
19
+ `);
20
+ });
21
+
22
+ test("async validation", async () => {
23
+ const testTuple = z
24
+ .tuple([z.string().refine(async () => true), z.number().refine(async () => true)])
25
+ .refine(async () => true);
26
+ expectTypeOf<typeof testTuple._output>().toEqualTypeOf<[string, number]>();
27
+
28
+ const val = await testTuple.parseAsync(["asdf", 1234]);
29
+ expect(val).toEqual(val);
30
+
31
+ const r1 = await testTuple.safeParseAsync(["asdf", "asdf"]);
32
+ expect(r1.success).toEqual(false);
33
+ expect(r1.error!).toMatchInlineSnapshot(`
34
+ [ZodError: [
35
+ {
36
+ "code": "invalid_type",
37
+ "expected": "number",
38
+ "received": "string",
39
+ "path": [
40
+ 1
41
+ ],
42
+ "message": "Expected number, received string"
43
+ }
44
+ ]]
45
+ `);
46
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/tests/locales/be.test.ts ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { describe, expect, it } from "vitest";
2
+ import be from "../../../locales/be.js";
3
+
4
+ describe("Belarusian localization", () => {
5
+ const localeError = be().localeError;
6
+
7
+ describe("pluralization rules", () => {
8
+ for (const { type, cases } of TEST_CASES) {
9
+ describe(`${type} pluralization`, () => {
10
+ for (const { count, expected } of cases) {
11
+ it(`correctly pluralizes ${count} ${type}`, () => {
12
+ const error = localeError({
13
+ code: "too_small",
14
+ minimum: count,
15
+ type: "number",
16
+ inclusive: true,
17
+ path: [],
18
+ origin: type,
19
+ input: count - 1,
20
+ });
21
+ expect(error).toContain(expected);
22
+ });
23
+ }
24
+ });
25
+ }
26
+
27
+ it("handles negative numbers correctly", () => {
28
+ const error = localeError({
29
+ code: "too_small",
30
+ minimum: -2,
31
+ type: "number",
32
+ inclusive: true,
33
+ path: [],
34
+ origin: "array",
35
+ input: -3,
36
+ });
37
+ expect(error).toContain("-2 элементы");
38
+ });
39
+
40
+ it("handles zero correctly", () => {
41
+ const error = localeError({
42
+ code: "too_small",
43
+ minimum: 0,
44
+ type: "number",
45
+ inclusive: true,
46
+ path: [],
47
+ origin: "array",
48
+ input: -1,
49
+ });
50
+ expect(error).toContain("0 элементаў");
51
+ });
52
+
53
+ it("handles bigint values correctly", () => {
54
+ const error = localeError({
55
+ code: "too_small",
56
+ minimum: BigInt(21),
57
+ type: "number",
58
+ inclusive: true,
59
+ path: [],
60
+ origin: "array",
61
+ input: BigInt(20),
62
+ });
63
+ expect(error).toContain("21 элемент");
64
+ });
65
+ });
66
+ });
67
+
68
+ const TEST_CASES = [
69
+ {
70
+ type: "array",
71
+ cases: [
72
+ { count: 1, expected: "1 элемент" },
73
+ { count: 2, expected: "2 элементы" },
74
+ { count: 5, expected: "5 элементаў" },
75
+ { count: 11, expected: "11 элементаў" },
76
+ { count: 21, expected: "21 элемент" },
77
+ { count: 22, expected: "22 элементы" },
78
+ { count: 25, expected: "25 элементаў" },
79
+ { count: 101, expected: "101 элемент" },
80
+ { count: 111, expected: "111 элементаў" },
81
+ ],
82
+ },
83
+ {
84
+ type: "set",
85
+ cases: [
86
+ { count: 1, expected: "1 элемент" },
87
+ { count: 2, expected: "2 элементы" },
88
+ { count: 5, expected: "5 элементаў" },
89
+ { count: 11, expected: "11 элементаў" },
90
+ { count: 21, expected: "21 элемент" },
91
+ { count: 22, expected: "22 элементы" },
92
+ { count: 25, expected: "25 элементаў" },
93
+ { count: 101, expected: "101 элемент" },
94
+ { count: 111, expected: "111 элементаў" },
95
+ ],
96
+ },
97
+ {
98
+ type: "string",
99
+ cases: [
100
+ { count: 1, expected: "1 сімвал" },
101
+ { count: 2, expected: "2 сімвалы" },
102
+ { count: 5, expected: "5 сімвалаў" },
103
+ { count: 11, expected: "11 сімвалаў" },
104
+ { count: 21, expected: "21 сімвал" },
105
+ { count: 22, expected: "22 сімвалы" },
106
+ { count: 25, expected: "25 сімвалаў" },
107
+ ],
108
+ },
109
+ {
110
+ type: "file",
111
+ cases: [
112
+ { count: 0, expected: "0 байтаў" },
113
+ { count: 1, expected: "1 байт" },
114
+ { count: 2, expected: "2 байты" },
115
+ { count: 5, expected: "5 байтаў" },
116
+ { count: 11, expected: "11 байтаў" },
117
+ { count: 21, expected: "21 байт" },
118
+ { count: 22, expected: "22 байты" },
119
+ { count: 25, expected: "25 байтаў" },
120
+ { count: 101, expected: "101 байт" },
121
+ { count: 110, expected: "110 байтаў" },
122
+ ],
123
+ },
124
+ ] as const;
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/tests/locales/en.test.ts ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import { parsedType } from "../../../locales/en.js";
3
+
4
+ test("parsedType", () => {
5
+ expect(parsedType("string")).toBe("string");
6
+ expect(parsedType(1)).toBe("number");
7
+ expect(parsedType(true)).toBe("boolean");
8
+ expect(parsedType(null)).toBe("null");
9
+ expect(parsedType(undefined)).toBe("undefined");
10
+ expect(parsedType([])).toBe("array");
11
+ expect(parsedType({})).toBe("object");
12
+ expect(parsedType(new Date())).toBe("Date");
13
+ expect(parsedType(new Map())).toBe("Map");
14
+ expect(parsedType(new Set())).toBe("Set");
15
+ expect(parsedType(new Error())).toBe("Error");
16
+
17
+ const nullPrototype = Object.create(null);
18
+ expect(parsedType(nullPrototype)).toBe("object");
19
+
20
+ const doubleNullPrototype = Object.create(Object.create(null));
21
+ expect(parsedType(doubleNullPrototype)).toBe("object");
22
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/tests/locales/ru.test.ts ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { describe, expect, it } from "vitest";
2
+ import ru from "../../../locales/ru.js";
3
+
4
+ describe("Russian localization", () => {
5
+ const localeError = ru().localeError;
6
+
7
+ describe("pluralization rules", () => {
8
+ for (const { type, cases } of TEST_CASES) {
9
+ describe(`${type} pluralization`, () => {
10
+ for (const { count, expected } of cases) {
11
+ it(`correctly pluralizes ${count} ${type}`, () => {
12
+ const error = localeError({
13
+ code: "too_small",
14
+ minimum: count,
15
+ type: "number",
16
+ inclusive: true,
17
+ path: [],
18
+ origin: type,
19
+ input: count - 1,
20
+ });
21
+
22
+ expect(error).toContain(expected);
23
+ });
24
+ }
25
+ });
26
+ }
27
+
28
+ it("handles negative numbers correctly", () => {
29
+ const error = localeError({
30
+ code: "too_small",
31
+ minimum: -2,
32
+ type: "number",
33
+ inclusive: true,
34
+ path: [],
35
+ origin: "array",
36
+ input: -3,
37
+ });
38
+
39
+ expect(error).toContain("-2 элемента");
40
+ });
41
+
42
+ it("handles zero correctly", () => {
43
+ const error = localeError({
44
+ code: "too_small",
45
+ minimum: 0,
46
+ type: "number",
47
+ inclusive: true,
48
+ path: [],
49
+ origin: "array",
50
+ input: -1,
51
+ });
52
+
53
+ expect(error).toContain("0 элементов");
54
+ });
55
+
56
+ it("handles bigint values correctly", () => {
57
+ const error = localeError({
58
+ code: "too_small",
59
+ minimum: BigInt(21),
60
+ type: "number",
61
+ inclusive: true,
62
+ path: [],
63
+ origin: "array",
64
+ input: BigInt(20),
65
+ });
66
+
67
+ expect(error).toContain("21 элемент");
68
+ });
69
+ });
70
+ });
71
+
72
+ const TEST_CASES = [
73
+ {
74
+ type: "array",
75
+ cases: [
76
+ { count: 1, expected: "1 элемент" },
77
+ { count: 2, expected: "2 элемента" },
78
+ { count: 5, expected: "5 элементов" },
79
+ { count: 11, expected: "11 элементов" },
80
+ { count: 21, expected: "21 элемент" },
81
+ { count: 22, expected: "22 элемента" },
82
+ { count: 25, expected: "25 элементов" },
83
+ { count: 101, expected: "101 элемент" },
84
+ { count: 111, expected: "111 элементов" },
85
+ ],
86
+ },
87
+ {
88
+ type: "set",
89
+ cases: [
90
+ { count: 1, expected: "1 элемент" },
91
+ { count: 2, expected: "2 элемента" },
92
+ { count: 5, expected: "5 элементов" },
93
+ { count: 11, expected: "11 элементов" },
94
+ { count: 21, expected: "21 элемент" },
95
+ { count: 22, expected: "22 элемента" },
96
+ { count: 25, expected: "25 элементов" },
97
+ { count: 101, expected: "101 элемент" },
98
+ { count: 111, expected: "111 элементов" },
99
+ ],
100
+ },
101
+ {
102
+ type: "string",
103
+ cases: [
104
+ { count: 1, expected: "1 символ" },
105
+ { count: 2, expected: "2 символа" },
106
+ { count: 5, expected: "5 символов" },
107
+ { count: 11, expected: "11 символов" },
108
+ { count: 21, expected: "21 символ" },
109
+ { count: 22, expected: "22 символа" },
110
+ { count: 25, expected: "25 символов" },
111
+ ],
112
+ },
113
+ {
114
+ type: "file",
115
+ cases: [
116
+ { count: 0, expected: "0 байт" },
117
+ { count: 1, expected: "1 байт" },
118
+ { count: 2, expected: "2 байта" },
119
+ { count: 5, expected: "5 байт" },
120
+ { count: 11, expected: "11 байт" },
121
+ { count: 21, expected: "21 байт" },
122
+ { count: 22, expected: "22 байта" },
123
+ { count: 25, expected: "25 байт" },
124
+ { count: 101, expected: "101 байт" },
125
+ { count: 110, expected: "110 байт" },
126
+ ],
127
+ },
128
+ ] as const;
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/tests/locales/tr.test.ts ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+ import { parsedType } from "../../../locales/tr.js";
4
+
5
+ test("parsedType", () => {
6
+ expect(parsedType("string")).toBe("string");
7
+ expect(parsedType(1)).toBe("number");
8
+ expect(parsedType(true)).toBe("boolean");
9
+ expect(parsedType(null)).toBe("null");
10
+ expect(parsedType(undefined)).toBe("undefined");
11
+ expect(parsedType([])).toBe("array");
12
+ expect(parsedType({})).toBe("object");
13
+ expect(parsedType(new Date())).toBe("Date");
14
+ expect(parsedType(new Map())).toBe("Map");
15
+ expect(parsedType(new Set())).toBe("Set");
16
+ expect(parsedType(new Error())).toBe("Error");
17
+
18
+ const nullPrototype = Object.create(null);
19
+ expect(parsedType(nullPrototype)).toBe("object");
20
+
21
+ const doubleNullPrototype = Object.create(Object.create(null));
22
+ expect(parsedType(doubleNullPrototype)).toBe("object");
23
+
24
+ expect(parsedType(Number.NaN)).toBe("NaN");
25
+ });
26
+
27
+ test("locales - tr", () => {
28
+ z.config(z.locales.tr());
29
+
30
+ const invalidType = z.number().safeParse("a");
31
+ expect(invalidType.error!.issues[0].code).toBe("invalid_type");
32
+ expect(invalidType.error!.issues[0].message).toBe("Geçersiz değer: beklenen number, alınan string");
33
+
34
+ const invalidType2 = z.string().safeParse(1);
35
+ expect(invalidType2.error!.issues[0].code).toBe("invalid_type");
36
+ expect(invalidType2.error!.issues[0].message).toBe("Geçersiz değer: beklenen string, alınan number");
37
+
38
+ const invalidValue = z.enum(["a", "b"]).safeParse(1);
39
+ expect(invalidValue.error!.issues[0].code).toBe("invalid_value");
40
+ expect(invalidValue.error!.issues[0].message).toBe('Geçersiz seçenek: aşağıdakilerden biri olmalı: "a"|"b"');
41
+
42
+ const tooBig = z.number().max(10).safeParse(15);
43
+ expect(tooBig.error!.issues[0].code).toBe("too_big");
44
+ expect(tooBig.error!.issues[0].message).toBe("Çok büyük: beklenen number <=10");
45
+
46
+ const tooSmall = z.number().min(10).safeParse(5);
47
+ expect(tooSmall.error!.issues[0].code).toBe("too_small");
48
+ expect(tooSmall.error!.issues[0].message).toBe("Çok küçük: beklenen number >=10");
49
+
50
+ const invalidFormatRegex = z.string().regex(/abcd/).safeParse("invalid-string");
51
+ expect(invalidFormatRegex.error!.issues[0].code).toBe("invalid_format");
52
+ expect(invalidFormatRegex.error!.issues[0].message).toBe("Geçersiz metin: /abcd/ desenine uymalı");
53
+
54
+ const invalidFormatStartsWith = z.string().startsWith("abcd").safeParse("invalid-string");
55
+ expect(invalidFormatStartsWith.error!.issues[0].code).toBe("invalid_format");
56
+ expect(invalidFormatStartsWith.error!.issues[0].message).toBe('Geçersiz metin: "abcd" ile başlamalı');
57
+
58
+ const notMultipleOf = z.number().multipleOf(3).safeParse(10);
59
+ expect(notMultipleOf.error!.issues[0].code).toBe("not_multiple_of");
60
+ expect(notMultipleOf.error!.issues[0].message).toBe("Geçersiz sayı: 3 ile tam bölünebilmeli");
61
+
62
+ const unrecognizedKeys = z.object({ a: z.string(), b: z.number() }).strict().safeParse({ a: "a", b: 1, c: 2 });
63
+ expect(unrecognizedKeys.error!.issues[0].code).toBe("unrecognized_keys");
64
+ expect(unrecognizedKeys.error!.issues[0].message).toBe('Tanınmayan anahtar: "c"');
65
+
66
+ const invalidUnion = z.union([z.string(), z.number()]).safeParse(true);
67
+ expect(invalidUnion.error!.issues[0].code).toBe("invalid_union");
68
+ expect(invalidUnion.error!.issues[0].message).toBe("Geçersiz değer");
69
+ });
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/to-json-schema.ts ADDED
@@ -0,0 +1,977 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type * as checks from "./checks.js";
2
+ import type * as JSONSchema from "./json-schema.js";
3
+ import { $ZodRegistry, globalRegistry } from "./registries.js";
4
+ import type * as schemas from "./schemas.js";
5
+ import { getEnumValues } from "./util.js";
6
+
7
+ interface JSONSchemaGeneratorParams {
8
+ /** A registry used to look up metadata for each schema. Any schema with an `id` property will be extracted as a $def.
9
+ * @default globalRegistry */
10
+ metadata?: $ZodRegistry<Record<string, any>>;
11
+ /** The JSON Schema version to target.
12
+ * - `"draft-2020-12"` — Default. JSON Schema Draft 2020-12
13
+ * - `"draft-7"` — JSON Schema Draft 7 */
14
+ target?: "draft-7" | "draft-2020-12";
15
+ /** How to handle unrepresentable types.
16
+ * - `"throw"` — Default. Unrepresentable types throw an error
17
+ * - `"any"` — Unrepresentable types become `{}` */
18
+ unrepresentable?: "throw" | "any";
19
+ /** Arbitrary custom logic that can be used to modify the generated JSON Schema. */
20
+ override?: (ctx: {
21
+ zodSchema: schemas.$ZodTypes;
22
+ jsonSchema: JSONSchema.BaseSchema;
23
+ path: (string | number)[];
24
+ }) => void;
25
+ /** Whether to extract the `"input"` or `"output"` type. Relevant to transforms, Error converting schema to JSONz, defaults, coerced primitives, etc.
26
+ * - `"output"` — Default. Convert the output schema.
27
+ * - `"input"` — Convert the input schema. */
28
+ io?: "input" | "output";
29
+ }
30
+
31
+ interface ProcessParams {
32
+ schemaPath: schemas.$ZodType[];
33
+ path: (string | number)[];
34
+ }
35
+
36
+ interface EmitParams {
37
+ /** How to handle cycles.
38
+ * - `"ref"` — Default. Cycles will be broken using $defs
39
+ * - `"throw"` — Cycles will throw an error if encountered */
40
+ cycles?: "ref" | "throw";
41
+ /* How to handle reused schemas.
42
+ * - `"inline"` — Default. Reused schemas will be inlined
43
+ * - `"ref"` — Reused schemas will be extracted as $defs */
44
+ reused?: "ref" | "inline";
45
+
46
+ external?:
47
+ | {
48
+ /** */
49
+ registry: $ZodRegistry<{ id?: string | undefined }>;
50
+ uri?: ((id: string) => string) | undefined;
51
+ defs: Record<string, JSONSchema.BaseSchema>;
52
+ }
53
+ | undefined;
54
+ }
55
+
56
+ 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
+ ref?: schemas.$ZodType | undefined | null;
68
+ /** JSON Schema property path for this schema */
69
+ path?: (string | number)[] | undefined;
70
+ }
71
+
72
+ export class JSONSchemaGenerator {
73
+ metadataRegistry: $ZodRegistry<Record<string, any>>;
74
+ target: "draft-7" | "draft-2020-12";
75
+ unrepresentable: "throw" | "any";
76
+ override: (ctx: {
77
+ zodSchema: schemas.$ZodTypes;
78
+ jsonSchema: JSONSchema.BaseSchema;
79
+ path: (string | number)[];
80
+ }) => void;
81
+ io: "input" | "output";
82
+
83
+ counter = 0;
84
+ seen: Map<schemas.$ZodType, Seen>;
85
+
86
+ constructor(params?: JSONSchemaGeneratorParams) {
87
+ this.metadataRegistry = params?.metadata ?? globalRegistry;
88
+ this.target = params?.target ?? "draft-2020-12";
89
+ this.unrepresentable = params?.unrepresentable ?? "throw";
90
+ this.override = params?.override ?? (() => {});
91
+ this.io = params?.io ?? "output";
92
+
93
+ this.seen = new Map();
94
+ }
95
+
96
+ process(schema: schemas.$ZodType, _params: ProcessParams = { path: [], schemaPath: [] }): JSONSchema.BaseSchema {
97
+ const def = (schema as schemas.$ZodTypes)._zod.def;
98
+
99
+ const formatMap: Partial<Record<checks.$ZodStringFormats, string | undefined>> = {
100
+ guid: "uuid",
101
+ url: "uri",
102
+ datetime: "date-time",
103
+ json_string: "json-string",
104
+ regex: "", // do not set
105
+ };
106
+
107
+ // check for schema in seens
108
+ const seen = this.seen.get(schema);
109
+
110
+ if (seen) {
111
+ seen.count++;
112
+
113
+ // check if cycle
114
+ const isCycle = _params.schemaPath.includes(schema);
115
+ if (isCycle) {
116
+ seen.cycle = _params.path;
117
+ }
118
+
119
+ return seen.schema;
120
+ }
121
+
122
+ // initialize
123
+ const result: Seen = { schema: {}, count: 1, cycle: undefined, path: _params.path };
124
+ this.seen.set(schema, result);
125
+
126
+ // custom method overrides default behavior
127
+ const overrideSchema = schema._zod.toJSONSchema?.();
128
+ if (overrideSchema) {
129
+ result.schema = overrideSchema as any;
130
+ } else {
131
+ const params = {
132
+ ..._params,
133
+ schemaPath: [..._params.schemaPath, schema],
134
+ path: _params.path,
135
+ };
136
+
137
+ const parent = schema._zod.parent;
138
+
139
+ if (parent) {
140
+ // schema was cloned from another schema
141
+ result.ref = parent;
142
+ this.process(parent, params);
143
+ this.seen.get(parent)!.isParent = true;
144
+ } else {
145
+ const _json = result.schema;
146
+ switch (def.type) {
147
+ case "string": {
148
+ const json: JSONSchema.StringSchema = _json as any;
149
+ json.type = "string";
150
+ const { minimum, maximum, format, patterns, contentEncoding } = schema._zod
151
+ .bag as schemas.$ZodStringInternals<unknown>["bag"];
152
+ if (typeof minimum === "number") json.minLength = minimum;
153
+ if (typeof maximum === "number") json.maxLength = maximum;
154
+ // custom pattern overrides format
155
+ if (format) {
156
+ json.format = formatMap[format as checks.$ZodStringFormats] ?? format;
157
+ if (json.format === "") delete json.format; // empty format is not valid
158
+ }
159
+ if (contentEncoding) json.contentEncoding = contentEncoding;
160
+ if (patterns && patterns.size > 0) {
161
+ const regexes = [...patterns];
162
+ if (regexes.length === 1) json.pattern = regexes[0]!.source;
163
+ else if (regexes.length > 1) {
164
+ result.schema.allOf = [
165
+ ...regexes.map((regex) => ({
166
+ ...(this.target === "draft-7" ? ({ type: "string" } as const) : {}),
167
+ pattern: regex.source,
168
+ })),
169
+ ];
170
+ }
171
+ }
172
+
173
+ break;
174
+ }
175
+ case "number": {
176
+ const json: JSONSchema.NumberSchema | JSONSchema.IntegerSchema = _json as any;
177
+ const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
178
+ if (typeof format === "string" && format.includes("int")) json.type = "integer";
179
+ else json.type = "number";
180
+
181
+ if (typeof exclusiveMinimum === "number") json.exclusiveMinimum = exclusiveMinimum;
182
+ if (typeof minimum === "number") {
183
+ json.minimum = minimum;
184
+ if (typeof exclusiveMinimum === "number") {
185
+ if (exclusiveMinimum >= minimum) delete json.minimum;
186
+ else delete json.exclusiveMinimum;
187
+ }
188
+ }
189
+
190
+ if (typeof exclusiveMaximum === "number") json.exclusiveMaximum = exclusiveMaximum;
191
+ if (typeof maximum === "number") {
192
+ json.maximum = maximum;
193
+ if (typeof exclusiveMaximum === "number") {
194
+ if (exclusiveMaximum <= maximum) delete json.maximum;
195
+ else delete json.exclusiveMaximum;
196
+ }
197
+ }
198
+
199
+ if (typeof multipleOf === "number") json.multipleOf = multipleOf;
200
+
201
+ break;
202
+ }
203
+ case "boolean": {
204
+ const json = _json as JSONSchema.BooleanSchema;
205
+ json.type = "boolean";
206
+ break;
207
+ }
208
+ case "bigint": {
209
+ if (this.unrepresentable === "throw") {
210
+ throw new Error("BigInt cannot be represented in JSON Schema");
211
+ }
212
+ break;
213
+ }
214
+ case "symbol": {
215
+ if (this.unrepresentable === "throw") {
216
+ throw new Error("Symbols cannot be represented in JSON Schema");
217
+ }
218
+ break;
219
+ }
220
+ case "null": {
221
+ _json.type = "null";
222
+ break;
223
+ }
224
+ case "any": {
225
+ break;
226
+ }
227
+ case "unknown": {
228
+ break;
229
+ }
230
+ case "undefined": {
231
+ if (this.unrepresentable === "throw") {
232
+ throw new Error("Undefined cannot be represented in JSON Schema");
233
+ }
234
+ break;
235
+ }
236
+ case "void": {
237
+ if (this.unrepresentable === "throw") {
238
+ throw new Error("Void cannot be represented in JSON Schema");
239
+ }
240
+ break;
241
+ }
242
+ case "never": {
243
+ _json.not = {};
244
+ break;
245
+ }
246
+ case "date": {
247
+ if (this.unrepresentable === "throw") {
248
+ throw new Error("Date cannot be represented in JSON Schema");
249
+ }
250
+ break;
251
+ }
252
+ case "array": {
253
+ const json: JSONSchema.ArraySchema = _json as any;
254
+ const { minimum, maximum } = schema._zod.bag;
255
+ if (typeof minimum === "number") json.minItems = minimum;
256
+ if (typeof maximum === "number") json.maxItems = maximum;
257
+
258
+ json.type = "array";
259
+ json.items = this.process(def.element, { ...params, path: [...params.path, "items"] });
260
+ break;
261
+ }
262
+ case "object": {
263
+ const json: JSONSchema.ObjectSchema = _json as any;
264
+ json.type = "object";
265
+ json.properties = {};
266
+ const shape = def.shape; // params.shapeCache.get(schema)!;
267
+
268
+ for (const key in shape) {
269
+ json.properties[key] = this.process(shape[key]!, {
270
+ ...params,
271
+ path: [...params.path, "properties", key],
272
+ });
273
+ }
274
+
275
+ // required keys
276
+ const allKeys = new Set(Object.keys(shape));
277
+ // const optionalKeys = new Set(def.optional);
278
+ const requiredKeys = new Set(
279
+ [...allKeys].filter((key) => {
280
+ const v = def.shape[key]!._zod;
281
+ if (this.io === "input") {
282
+ return v.optin === undefined;
283
+ } else {
284
+ return v.optout === undefined;
285
+ }
286
+ })
287
+ );
288
+
289
+ if (requiredKeys.size > 0) {
290
+ json.required = Array.from(requiredKeys);
291
+ }
292
+
293
+ // catchall
294
+ if (def.catchall?._zod.def.type === "never") {
295
+ // strict
296
+ json.additionalProperties = false;
297
+ } else if (!def.catchall) {
298
+ // regular
299
+ if (this.io === "output") json.additionalProperties = false;
300
+ } else if (def.catchall) {
301
+ json.additionalProperties = this.process(def.catchall, {
302
+ ...params,
303
+ path: [...params.path, "additionalProperties"],
304
+ });
305
+ }
306
+
307
+ break;
308
+ }
309
+ case "union": {
310
+ const json: JSONSchema.BaseSchema = _json as any;
311
+ json.anyOf = def.options.map((x, i) =>
312
+ this.process(x, {
313
+ ...params,
314
+ path: [...params.path, "anyOf", i],
315
+ })
316
+ );
317
+ break;
318
+ }
319
+ case "intersection": {
320
+ const json: JSONSchema.BaseSchema = _json as any;
321
+ const a = this.process(def.left, {
322
+ ...params,
323
+ path: [...params.path, "allOf", 0],
324
+ });
325
+ const b = this.process(def.right, {
326
+ ...params,
327
+ path: [...params.path, "allOf", 1],
328
+ });
329
+
330
+ const isSimpleIntersection = (val: any) => "allOf" in val && Object.keys(val).length === 1;
331
+ const allOf = [
332
+ ...(isSimpleIntersection(a) ? (a.allOf as any[]) : [a]),
333
+ ...(isSimpleIntersection(b) ? (b.allOf as any[]) : [b]),
334
+ ];
335
+ json.allOf = allOf;
336
+ break;
337
+ }
338
+ case "tuple": {
339
+ const json: JSONSchema.ArraySchema = _json as any;
340
+ json.type = "array";
341
+ const prefixItems = def.items.map((x, i) =>
342
+ this.process(x, { ...params, path: [...params.path, "prefixItems", i] })
343
+ );
344
+ if (this.target === "draft-2020-12") {
345
+ json.prefixItems = prefixItems;
346
+ } else {
347
+ json.items = prefixItems;
348
+ }
349
+
350
+ if (def.rest) {
351
+ const rest = this.process(def.rest, {
352
+ ...params,
353
+ path: [...params.path, "items"],
354
+ });
355
+ if (this.target === "draft-2020-12") {
356
+ json.items = rest;
357
+ } else {
358
+ json.additionalItems = rest;
359
+ }
360
+ }
361
+
362
+ // additionalItems
363
+ if (def.rest) {
364
+ json.items = this.process(def.rest, {
365
+ ...params,
366
+ path: [...params.path, "items"],
367
+ });
368
+ }
369
+
370
+ // length
371
+ const { minimum, maximum } = schema._zod.bag as {
372
+ minimum?: number;
373
+ maximum?: number;
374
+ };
375
+ if (typeof minimum === "number") json.minItems = minimum;
376
+ if (typeof maximum === "number") json.maxItems = maximum;
377
+ break;
378
+ }
379
+ case "record": {
380
+ const json: JSONSchema.ObjectSchema = _json as any;
381
+ json.type = "object";
382
+ json.propertyNames = this.process(def.keyType, { ...params, path: [...params.path, "propertyNames"] });
383
+ json.additionalProperties = this.process(def.valueType, {
384
+ ...params,
385
+ path: [...params.path, "additionalProperties"],
386
+ });
387
+ break;
388
+ }
389
+ case "map": {
390
+ if (this.unrepresentable === "throw") {
391
+ throw new Error("Map cannot be represented in JSON Schema");
392
+ }
393
+ break;
394
+ }
395
+ case "set": {
396
+ if (this.unrepresentable === "throw") {
397
+ throw new Error("Set cannot be represented in JSON Schema");
398
+ }
399
+ break;
400
+ }
401
+ case "enum": {
402
+ const json: JSONSchema.BaseSchema = _json as any;
403
+ const values = getEnumValues(def.entries);
404
+ // Number enums can have both string and number values
405
+ if (values.every((v) => typeof v === "number")) json.type = "number";
406
+ if (values.every((v) => typeof v === "string")) json.type = "string";
407
+ json.enum = values;
408
+ break;
409
+ }
410
+ case "literal": {
411
+ const json: JSONSchema.BaseSchema = _json as any;
412
+ const vals: (string | number | boolean | null)[] = [];
413
+ for (const val of def.values) {
414
+ if (val === undefined) {
415
+ if (this.unrepresentable === "throw") {
416
+ throw new Error("Literal `undefined` cannot be represented in JSON Schema");
417
+ } else {
418
+ // do not add to vals
419
+ }
420
+ } else if (typeof val === "bigint") {
421
+ if (this.unrepresentable === "throw") {
422
+ throw new Error("BigInt literals cannot be represented in JSON Schema");
423
+ } else {
424
+ vals.push(Number(val));
425
+ }
426
+ } else {
427
+ vals.push(val);
428
+ }
429
+ }
430
+ if (vals.length === 0) {
431
+ // do nothing (an undefined literal was stripped)
432
+ } else if (vals.length === 1) {
433
+ const val = vals[0]!;
434
+ json.type = val === null ? ("null" as const) : (typeof val as any);
435
+ json.const = val;
436
+ } else {
437
+ if (vals.every((v) => typeof v === "number")) json.type = "number";
438
+ if (vals.every((v) => typeof v === "string")) json.type = "string";
439
+ if (vals.every((v) => typeof v === "boolean")) json.type = "string";
440
+ if (vals.every((v) => v === null)) json.type = "null";
441
+ json.enum = vals;
442
+ }
443
+ break;
444
+ }
445
+
446
+ case "file": {
447
+ const json: JSONSchema.StringSchema = _json as any;
448
+ const file: JSONSchema.StringSchema = {
449
+ type: "string",
450
+ format: "binary",
451
+ contentEncoding: "binary",
452
+ };
453
+
454
+ const { minimum, maximum, mime } = schema._zod.bag as schemas.$ZodFileInternals["bag"];
455
+ if (minimum !== undefined) file.minLength = minimum;
456
+ if (maximum !== undefined) file.maxLength = maximum;
457
+ if (mime) {
458
+ if (mime.length === 1) {
459
+ file.contentMediaType = mime[0]!;
460
+ Object.assign(json, file);
461
+ } else {
462
+ json.anyOf = mime.map((m) => {
463
+ const mFile: JSONSchema.StringSchema = { ...file, contentMediaType: m };
464
+ return mFile;
465
+ });
466
+ }
467
+ } else {
468
+ Object.assign(json, file);
469
+ }
470
+
471
+ // if (this.unrepresentable === "throw") {
472
+ // throw new Error("File cannot be represented in JSON Schema");
473
+ // }
474
+ break;
475
+ }
476
+ case "transform": {
477
+ if (this.unrepresentable === "throw") {
478
+ throw new Error("Transforms cannot be represented in JSON Schema");
479
+ }
480
+ break;
481
+ }
482
+
483
+ case "nullable": {
484
+ const inner = this.process(def.innerType, params);
485
+ _json.anyOf = [inner, { type: "null" }];
486
+ break;
487
+ }
488
+ case "nonoptional": {
489
+ this.process(def.innerType, params);
490
+ result.ref = def.innerType;
491
+ break;
492
+ }
493
+ case "success": {
494
+ const json = _json as JSONSchema.BooleanSchema;
495
+ json.type = "boolean";
496
+ break;
497
+ }
498
+ case "default": {
499
+ this.process(def.innerType, params);
500
+ result.ref = def.innerType;
501
+ _json.default = JSON.parse(JSON.stringify(def.defaultValue));
502
+ break;
503
+ }
504
+ case "prefault": {
505
+ this.process(def.innerType, params);
506
+ result.ref = def.innerType;
507
+ if (this.io === "input") _json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
508
+
509
+ break;
510
+ }
511
+ case "catch": {
512
+ // use conditionals
513
+ this.process(def.innerType, params);
514
+ result.ref = def.innerType;
515
+ let catchValue: any;
516
+ try {
517
+ catchValue = def.catchValue(undefined as any);
518
+ } catch {
519
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
520
+ }
521
+ _json.default = catchValue;
522
+ break;
523
+ }
524
+ case "nan": {
525
+ if (this.unrepresentable === "throw") {
526
+ throw new Error("NaN cannot be represented in JSON Schema");
527
+ }
528
+ break;
529
+ }
530
+ case "template_literal": {
531
+ const json = _json as JSONSchema.StringSchema;
532
+ const pattern = schema._zod.pattern;
533
+ if (!pattern) throw new Error("Pattern not found in template literal");
534
+ json.type = "string";
535
+ json.pattern = pattern.source;
536
+ break;
537
+ }
538
+ case "pipe": {
539
+ const innerType = this.io === "input" ? (def.in._zod.def.type === "transform" ? def.out : def.in) : def.out;
540
+ this.process(innerType, params);
541
+ result.ref = innerType;
542
+ break;
543
+ }
544
+ case "readonly": {
545
+ this.process(def.innerType, params);
546
+ result.ref = def.innerType;
547
+ _json.readOnly = true;
548
+ break;
549
+ }
550
+ // passthrough types
551
+ case "promise": {
552
+ this.process(def.innerType, params);
553
+ result.ref = def.innerType;
554
+ break;
555
+ }
556
+ case "optional": {
557
+ this.process(def.innerType, params);
558
+ result.ref = def.innerType;
559
+ break;
560
+ }
561
+ case "lazy": {
562
+ const innerType = (schema as schemas.$ZodLazy)._zod.innerType;
563
+ this.process(innerType, params);
564
+ result.ref = innerType;
565
+ break;
566
+ }
567
+ case "custom": {
568
+ if (this.unrepresentable === "throw") {
569
+ throw new Error("Custom types cannot be represented in JSON Schema");
570
+ }
571
+ break;
572
+ }
573
+ default: {
574
+ def satisfies never;
575
+ }
576
+ }
577
+ }
578
+ }
579
+
580
+ // metadata
581
+ const meta = this.metadataRegistry.get(schema);
582
+ if (meta) Object.assign(result.schema, meta);
583
+
584
+ if (this.io === "input" && isTransforming(schema)) {
585
+ // examples/defaults only apply to output type of pipe
586
+ delete result.schema.examples;
587
+ delete result.schema.default;
588
+ }
589
+
590
+ // set prefault as default
591
+ if (this.io === "input" && result.schema._prefault) result.schema.default ??= result.schema._prefault;
592
+ delete result.schema._prefault;
593
+
594
+ // pulling fresh from this.seen in case it was overwritten
595
+ const _result = this.seen.get(schema)!;
596
+
597
+ return _result.schema;
598
+ }
599
+
600
+ emit(schema: schemas.$ZodType, _params?: EmitParams): JSONSchema.BaseSchema {
601
+ const params = {
602
+ cycles: _params?.cycles ?? "ref",
603
+ reused: _params?.reused ?? "inline",
604
+ // unrepresentable: _params?.unrepresentable ?? "throw",
605
+ // uri: _params?.uri ?? ((id) => `${id}`),
606
+ external: _params?.external ?? undefined,
607
+ } satisfies EmitParams;
608
+
609
+ // iterate over seen map;
610
+ const root = this.seen.get(schema);
611
+
612
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
613
+
614
+ // initialize result with root schema fields
615
+ // Object.assign(result, seen.cached);
616
+
617
+ // returns a ref to the schema
618
+ // defId will be empty if the ref points to an external schema (or #)
619
+ const makeURI = (entry: [schemas.$ZodType<unknown, unknown>, Seen]): { ref: string; defId?: string } => {
620
+ // comparing the seen objects because sometimes
621
+ // multiple schemas map to the same seen object.
622
+ // e.g. lazy
623
+
624
+ // external is configured
625
+ const defsSegment = this.target === "draft-2020-12" ? "$defs" : "definitions";
626
+ if (params.external) {
627
+ const externalId = params.external.registry.get(entry[0])?.id; // ?? "__shared";// `__schema${this.counter++}`;
628
+
629
+ // check if schema is in the external registry
630
+ const uriGenerator = params.external.uri ?? ((id) => id);
631
+ if (externalId) {
632
+ return { ref: uriGenerator(externalId) };
633
+ }
634
+
635
+ // otherwise, add to __shared
636
+ const id: string = entry[1].defId ?? (entry[1].schema.id as string) ?? `schema${this.counter++}`;
637
+ entry[1].defId = id; // set defId so it will be reused if needed
638
+ return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
639
+ }
640
+
641
+ if (entry[1] === root) {
642
+ return { ref: "#" };
643
+ }
644
+
645
+ // self-contained schema
646
+ const uriPrefix = `#`;
647
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
648
+ const defId = entry[1].schema.id ?? `__schema${this.counter++}`;
649
+ return { defId, ref: defUriPrefix + defId };
650
+ };
651
+
652
+ // stored cached version in `def` property
653
+ // remove all properties, set $ref
654
+ const extractToDef = (entry: [schemas.$ZodType<unknown, unknown>, Seen]): void => {
655
+ // if the schema is already a reference, do not extract it
656
+ if (entry[1].schema.$ref) {
657
+ return;
658
+ }
659
+ const seen = entry[1];
660
+ const { ref, defId } = makeURI(entry);
661
+
662
+ seen.def = { ...seen.schema };
663
+ // defId won't be set if the schema is a reference to an external schema
664
+ if (defId) seen.defId = defId;
665
+ // wipe away all properties except $ref
666
+ const schema = seen.schema;
667
+ for (const key in schema) {
668
+ delete schema[key];
669
+ }
670
+ schema.$ref = ref;
671
+ };
672
+
673
+ // throw on cycles
674
+
675
+ // break cycles
676
+ if (params.cycles === "throw") {
677
+ for (const entry of this.seen.entries()) {
678
+ const seen = entry[1];
679
+ if (seen.cycle) {
680
+ throw new Error(
681
+ "Cycle detected: " +
682
+ `#/${seen.cycle?.join("/")}/<root>` +
683
+ '\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.'
684
+ );
685
+ }
686
+ }
687
+ }
688
+
689
+ // extract schemas into $defs
690
+ for (const entry of this.seen.entries()) {
691
+ const seen = entry[1];
692
+
693
+ // convert root schema to # $ref
694
+ if (schema === entry[0]) {
695
+ extractToDef(entry); // this has special handling for the root schema
696
+ continue;
697
+ }
698
+
699
+ // extract schemas that are in the external registry
700
+ if (params.external) {
701
+ const ext = params.external.registry.get(entry[0])?.id;
702
+ if (schema !== entry[0] && ext) {
703
+ extractToDef(entry);
704
+ continue;
705
+ }
706
+ }
707
+
708
+ // extract schemas with `id` meta
709
+ const id = this.metadataRegistry.get(entry[0])?.id;
710
+ if (id) {
711
+ extractToDef(entry);
712
+ continue;
713
+ }
714
+
715
+ // break cycles
716
+ if (seen.cycle) {
717
+ // any
718
+ extractToDef(entry);
719
+ continue;
720
+ }
721
+
722
+ // extract reused schemas
723
+ if (seen.count > 1) {
724
+ if (params.reused === "ref") {
725
+ extractToDef(entry);
726
+ // biome-ignore lint:
727
+ continue;
728
+ }
729
+ }
730
+ }
731
+
732
+ // flatten _refs
733
+ const flattenRef = (zodSchema: schemas.$ZodType, params: Pick<ToJSONSchemaParams, "target">) => {
734
+ const seen = this.seen.get(zodSchema)!;
735
+ const schema = seen.def ?? seen.schema;
736
+
737
+ const _cached = { ...schema };
738
+
739
+ // already seen
740
+ if (seen.ref === null) {
741
+ return;
742
+ }
743
+
744
+ // flatten ref if defined
745
+ const ref = seen.ref;
746
+ seen.ref = null; // prevent recursion
747
+ if (ref) {
748
+ flattenRef(ref, params);
749
+
750
+ // merge referenced schema into current
751
+ const refSchema = this.seen.get(ref)!.schema;
752
+ if (refSchema.$ref && params.target === "draft-7") {
753
+ schema.allOf = schema.allOf ?? [];
754
+ schema.allOf.push(refSchema);
755
+ } else {
756
+ Object.assign(schema, refSchema);
757
+ Object.assign(schema, _cached); // prevent overwriting any fields in the original schema
758
+ }
759
+ }
760
+
761
+ // execute overrides
762
+ if (!seen.isParent)
763
+ this.override({
764
+ zodSchema: zodSchema as schemas.$ZodTypes,
765
+ jsonSchema: schema,
766
+ path: seen.path ?? [],
767
+ });
768
+ };
769
+
770
+ for (const entry of [...this.seen.entries()].reverse()) {
771
+ flattenRef(entry[0], { target: this.target });
772
+ }
773
+
774
+ const result: JSONSchema.BaseSchema = {};
775
+ if (this.target === "draft-2020-12") {
776
+ result.$schema = "https://json-schema.org/draft/2020-12/schema";
777
+ } else if (this.target === "draft-7") {
778
+ result.$schema = "http://json-schema.org/draft-07/schema#";
779
+ } else {
780
+ console.warn(`Invalid target: ${this.target}`);
781
+ }
782
+
783
+ if (params.external?.uri) {
784
+ const id = params.external.registry.get(schema)?.id;
785
+ if (!id) throw new Error("Schema is missing an `id` property");
786
+ result.$id = params.external.uri(id);
787
+ }
788
+
789
+ Object.assign(result, root.def);
790
+
791
+ // build defs object
792
+ const defs: JSONSchema.BaseSchema["$defs"] = params.external?.defs ?? {};
793
+ for (const entry of this.seen.entries()) {
794
+ const seen = entry[1];
795
+ if (seen.def && seen.defId) {
796
+ defs[seen.defId] = seen.def;
797
+ }
798
+ }
799
+
800
+ // set definitions in result
801
+ if (params.external) {
802
+ } else {
803
+ if (Object.keys(defs).length > 0) {
804
+ if (this.target === "draft-2020-12") {
805
+ result.$defs = defs;
806
+ } else {
807
+ result.definitions = defs;
808
+ }
809
+ }
810
+ }
811
+
812
+ try {
813
+ // this "finalizes" this schema and ensures all cycles are removed
814
+ // each call to .emit() is functionally independent
815
+ // though the seen map is shared
816
+ return JSON.parse(JSON.stringify(result));
817
+ } catch (_err) {
818
+ throw new Error("Error converting schema to JSON.");
819
+ }
820
+ }
821
+ }
822
+
823
+ interface ToJSONSchemaParams extends Omit<JSONSchemaGeneratorParams & EmitParams, "external"> {}
824
+ interface RegistryToJSONSchemaParams extends Omit<JSONSchemaGeneratorParams & EmitParams, "external"> {
825
+ uri?: (id: string) => string;
826
+ }
827
+
828
+ export function toJSONSchema(schema: schemas.$ZodType, _params?: ToJSONSchemaParams): JSONSchema.BaseSchema;
829
+ export function toJSONSchema(
830
+ registry: $ZodRegistry<{ id?: string | undefined }>,
831
+ _params?: RegistryToJSONSchemaParams
832
+ ): { schemas: Record<string, JSONSchema.BaseSchema> };
833
+ export function toJSONSchema(
834
+ input: schemas.$ZodType | $ZodRegistry<{ id?: string | undefined }>,
835
+ _params?: ToJSONSchemaParams
836
+ ): any {
837
+ if (input instanceof $ZodRegistry) {
838
+ const gen = new JSONSchemaGenerator(_params);
839
+ const defs: any = {};
840
+ for (const entry of input._idmap.entries()) {
841
+ const [_, schema] = entry;
842
+ gen.process(schema);
843
+ }
844
+
845
+ const schemas: Record<string, JSONSchema.BaseSchema> = {};
846
+ const external = {
847
+ registry: input,
848
+ uri: (_params as RegistryToJSONSchemaParams)?.uri,
849
+ defs,
850
+ };
851
+ for (const entry of input._idmap.entries()) {
852
+ const [key, schema] = entry;
853
+ schemas[key] = gen.emit(schema, {
854
+ ..._params,
855
+ external,
856
+ });
857
+ }
858
+
859
+ if (Object.keys(defs).length > 0) {
860
+ const defsSegment = gen.target === "draft-2020-12" ? "$defs" : "definitions";
861
+ schemas.__shared = {
862
+ [defsSegment]: defs,
863
+ };
864
+ }
865
+
866
+ return { schemas };
867
+ }
868
+
869
+ const gen = new JSONSchemaGenerator(_params);
870
+ gen.process(input);
871
+
872
+ return gen.emit(input, _params);
873
+ }
874
+
875
+ function isTransforming(
876
+ _schema: schemas.$ZodType,
877
+ _ctx?: {
878
+ seen: Set<schemas.$ZodType>;
879
+ }
880
+ ): boolean {
881
+ const ctx = _ctx ?? { seen: new Set() };
882
+
883
+ if (ctx.seen.has(_schema)) return false;
884
+ ctx.seen.add(_schema);
885
+
886
+ const schema = _schema as schemas.$ZodTypes;
887
+ const def = schema._zod.def;
888
+ switch (def.type) {
889
+ case "string":
890
+ case "number":
891
+ case "bigint":
892
+ case "boolean":
893
+ case "date":
894
+ case "symbol":
895
+ case "undefined":
896
+ case "null":
897
+ case "any":
898
+ case "unknown":
899
+ case "never":
900
+ case "void":
901
+ case "literal":
902
+ case "enum":
903
+ case "nan":
904
+ case "file":
905
+ case "template_literal":
906
+ return false;
907
+ case "array": {
908
+ return isTransforming(def.element, ctx);
909
+ }
910
+ case "object": {
911
+ for (const key in def.shape) {
912
+ if (isTransforming(def.shape[key]!, ctx)) return true;
913
+ }
914
+ return false;
915
+ }
916
+ case "union": {
917
+ for (const option of def.options) {
918
+ if (isTransforming(option, ctx)) return true;
919
+ }
920
+ return false;
921
+ }
922
+ case "intersection": {
923
+ return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
924
+ }
925
+ case "tuple": {
926
+ for (const item of def.items) {
927
+ if (isTransforming(item, ctx)) return true;
928
+ }
929
+ if (def.rest && isTransforming(def.rest, ctx)) return true;
930
+ return false;
931
+ }
932
+ case "record": {
933
+ return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
934
+ }
935
+ case "map": {
936
+ return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
937
+ }
938
+ case "set": {
939
+ return isTransforming(def.valueType, ctx);
940
+ }
941
+
942
+ // inner types
943
+ case "promise":
944
+ case "optional":
945
+ case "nonoptional":
946
+ case "nullable":
947
+ case "readonly":
948
+ return isTransforming(def.innerType, ctx);
949
+ case "lazy":
950
+ return isTransforming(def.getter(), ctx);
951
+ case "default": {
952
+ return isTransforming(def.innerType, ctx);
953
+ }
954
+ case "prefault": {
955
+ return isTransforming(def.innerType, ctx);
956
+ }
957
+ case "custom": {
958
+ return false;
959
+ }
960
+ case "transform": {
961
+ return true;
962
+ }
963
+ case "pipe": {
964
+ return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
965
+ }
966
+ case "success": {
967
+ return false;
968
+ }
969
+ case "catch": {
970
+ return false;
971
+ }
972
+
973
+ default:
974
+ def satisfies never;
975
+ }
976
+ throw new Error(`Unknown schema type: ${(def as any).type}`);
977
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/util.ts ADDED
@@ -0,0 +1,775 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
6
+ // json
7
+ export type JSONType = string | number | boolean | null | JSONType[] | { [key: string]: JSONType };
8
+ export type JWTAlgorithm =
9
+ | "HS256"
10
+ | "HS384"
11
+ | "HS512"
12
+ | "RS256"
13
+ | "RS384"
14
+ | "RS512"
15
+ | "ES256"
16
+ | "ES384"
17
+ | "ES512"
18
+ | "PS256"
19
+ | "PS384"
20
+ | "PS512"
21
+ | "EdDSA"
22
+ | (string & {});
23
+ export type IPVersion = "v4" | "v6";
24
+ export type MimeTypes =
25
+ | "application/json"
26
+ | "application/xml"
27
+ | "application/x-www-form-urlencoded"
28
+ | "application/javascript"
29
+ | "application/pdf"
30
+ | "application/zip"
31
+ | "application/vnd.ms-excel"
32
+ | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
33
+ | "application/msword"
34
+ | "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
35
+ | "application/vnd.ms-powerpoint"
36
+ | "application/vnd.openxmlformats-officedocument.presentationml.presentation"
37
+ | "application/octet-stream"
38
+ | "application/graphql"
39
+ | "text/html"
40
+ | "text/plain"
41
+ | "text/css"
42
+ | "text/javascript"
43
+ | "text/csv"
44
+ | "image/png"
45
+ | "image/jpeg"
46
+ | "image/gif"
47
+ | "image/svg+xml"
48
+ | "image/webp"
49
+ | "audio/mpeg"
50
+ | "audio/ogg"
51
+ | "audio/wav"
52
+ | "audio/webm"
53
+ | "video/mp4"
54
+ | "video/webm"
55
+ | "video/ogg"
56
+ | "font/woff"
57
+ | "font/woff2"
58
+ | "font/ttf"
59
+ | "font/otf"
60
+ | "multipart/form-data"
61
+ | (string & {});
62
+ export type ParsedTypes =
63
+ | "string"
64
+ | "number"
65
+ | "bigint"
66
+ | "boolean"
67
+ | "symbol"
68
+ | "undefined"
69
+ | "object"
70
+ | "function"
71
+ | "file"
72
+ | "date"
73
+ | "array"
74
+ | "map"
75
+ | "set"
76
+ | "nan"
77
+ | "null"
78
+ | "promise";
79
+
80
+ // utils
81
+ export type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
82
+ export type AssertNotEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? false : true;
83
+ export type AssertExtends<T, U> = T extends U ? T : never;
84
+ export type IsAny<T> = 0 extends 1 & T ? true : false;
85
+ export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
86
+ export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
87
+ export type MakePartial<T, K extends keyof T> = Omit<T, K> & InexactPartial<Pick<T, K>>;
88
+ export type MakeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
89
+
90
+ export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
91
+ export type NoUndefined<T> = T extends undefined ? never : T;
92
+ export type Whatever = {} | undefined | null;
93
+ export type LoosePartial<T extends object> = InexactPartial<T> & {
94
+ [k: string]: unknown;
95
+ };
96
+ export type Mask<Keys extends PropertyKey> = { [K in Keys]?: true };
97
+ export type Writeable<T> = { -readonly [P in keyof T]: T[P] } & {};
98
+ export type InexactPartial<T> = {
99
+ [P in keyof T]?: T[P] | undefined;
100
+ };
101
+ export type EmptyObject = Record<string, never>;
102
+ export type BuiltIn =
103
+ | (((...args: any[]) => any) | (new (...args: any[]) => any))
104
+ | { readonly [Symbol.toStringTag]: string }
105
+ | Date
106
+ | Error
107
+ | Generator
108
+ | Promise<unknown>
109
+ | RegExp;
110
+ export type MakeReadonly<T> = T extends Map<infer K, infer V>
111
+ ? ReadonlyMap<K, V>
112
+ : T extends Set<infer V>
113
+ ? ReadonlySet<V>
114
+ : T extends [infer Head, ...infer Tail]
115
+ ? readonly [Head, ...Tail]
116
+ : T extends Array<infer V>
117
+ ? ReadonlyArray<V>
118
+ : T extends BuiltIn
119
+ ? T
120
+ : Readonly<T>;
121
+ export type SomeObject = Record<PropertyKey, any>;
122
+ export type Identity<T> = T;
123
+ export type Flatten<T> = Identity<{ [k in keyof T]: T[k] }>;
124
+ export type Mapped<T> = { [k in keyof T]: T[k] };
125
+ export type Prettify<T> = {
126
+ [K in keyof T]: T[K];
127
+ } & {};
128
+
129
+ export type NoNeverKeys<T> = {
130
+ [k in keyof T]: [T[k]] extends [never] ? never : k;
131
+ }[keyof T];
132
+ export type NoNever<T> = Identity<{
133
+ [k in NoNeverKeys<T>]: k extends keyof T ? T[k] : never;
134
+ }>;
135
+ export type Extend<A extends SomeObject, B extends SomeObject> = Flatten<
136
+ // fast path when there is no keys overlap
137
+ keyof A & keyof B extends never
138
+ ? A & B
139
+ : {
140
+ [K in keyof A as K extends keyof B ? never : K]: A[K];
141
+ } & {
142
+ [K in keyof B]: B[K];
143
+ }
144
+ >;
145
+
146
+ export type TupleItems = ReadonlyArray<schemas.SomeType>;
147
+ export type AnyFunc = (...args: any[]) => any;
148
+ export type IsProp<T, K extends keyof T> = T[K] extends AnyFunc ? never : K;
149
+ export type MaybeAsync<T> = T | Promise<T>;
150
+ export type KeyOf<T> = keyof OmitIndexSignature<T>;
151
+ export type OmitIndexSignature<T> = {
152
+ [K in keyof T as string extends K ? never : K extends string ? K : never]: T[K];
153
+ };
154
+ export type ExtractIndexSignature<T> = {
155
+ [K in keyof T as string extends K ? K : K extends string ? never : K]: T[K];
156
+ };
157
+ export type Keys<T extends object> = keyof OmitIndexSignature<T>;
158
+
159
+ export type SchemaClass<T extends schemas.SomeType> = {
160
+ new (def: T["_zod"]["def"]): T;
161
+ };
162
+ export type EnumValue = string | number; // | bigint | boolean | symbol;
163
+ export type EnumLike = Readonly<Record<string, EnumValue>>;
164
+ export type ToEnum<T extends EnumValue> = Flatten<{ [k in T]: k }>;
165
+ export type KeysEnum<T extends object> = ToEnum<Exclude<keyof T, symbol>>;
166
+ export type KeysArray<T extends object> = Flatten<(keyof T & string)[]>;
167
+ export type Literal = string | number | bigint | boolean | null | undefined;
168
+ export type LiteralArray = Array<Literal>;
169
+ export type Primitive = string | number | symbol | bigint | boolean | null | undefined;
170
+ export type PrimitiveArray = Array<Primitive>;
171
+ export type HasSize = { size: number };
172
+ export type HasLength = { length: number }; // string | Array<unknown> | Set<unknown> | File;
173
+ export type Numeric = number | bigint | Date;
174
+ export type SafeParseResult<T> = SafeParseSuccess<T> | SafeParseError<T>;
175
+ export type SafeParseSuccess<T> = { success: true; data: T; error?: never };
176
+ export type SafeParseError<T> = {
177
+ success: false;
178
+ data?: never;
179
+ error: errors.$ZodError<T>;
180
+ };
181
+
182
+ export type PropValues = Record<string, Set<Primitive>>;
183
+ export type PrimitiveSet = Set<Primitive>;
184
+
185
+ // functions
186
+ export function assertEqual<A, B>(val: AssertEqual<A, B>): AssertEqual<A, B> {
187
+ return val;
188
+ }
189
+
190
+ export function assertNotEqual<A, B>(val: AssertNotEqual<A, B>): AssertNotEqual<A, B> {
191
+ return val;
192
+ }
193
+
194
+ export function assertIs<T>(_arg: T): void {}
195
+
196
+ export function assertNever(_x: never): never {
197
+ throw new Error();
198
+ }
199
+ export function assert<T>(_: any): asserts _ is T {}
200
+
201
+ export function getEnumValues(entries: EnumLike): EnumValue[] {
202
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
203
+ const values = Object.entries(entries)
204
+ .filter(([k, _]) => numericValues.indexOf(+k) === -1)
205
+ .map(([_, v]) => v);
206
+ return values;
207
+ }
208
+
209
+ export function joinValues<T extends Primitive[]>(array: T, separator = "|"): string {
210
+ return array.map((val) => stringifyPrimitive(val)).join(separator);
211
+ }
212
+
213
+ export function jsonStringifyReplacer(_: string, value: any): any {
214
+ if (typeof value === "bigint") return value.toString();
215
+ return value;
216
+ }
217
+
218
+ export function cached<T>(getter: () => T): { value: T } {
219
+ const set = false;
220
+ return {
221
+ get value() {
222
+ if (!set) {
223
+ const value = getter();
224
+ Object.defineProperty(this, "value", { value });
225
+ return value;
226
+ }
227
+ throw new Error("cached value already set");
228
+ },
229
+ };
230
+ }
231
+
232
+ export function nullish(input: any): boolean {
233
+ return input === null || input === undefined;
234
+ }
235
+
236
+ export function cleanRegex(source: string): string {
237
+ const start = source.startsWith("^") ? 1 : 0;
238
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
239
+ return source.slice(start, end);
240
+ }
241
+
242
+ export function floatSafeRemainder(val: number, step: number): number {
243
+ const valDecCount = (val.toString().split(".")[1] || "").length;
244
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
245
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
246
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
247
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
248
+ return (valInt % stepInt) / 10 ** decCount;
249
+ }
250
+
251
+ export function defineLazy<T, K extends keyof T>(object: T, key: K, getter: () => T[K]): void {
252
+ const set = false;
253
+ Object.defineProperty(object, key, {
254
+ get() {
255
+ if (!set) {
256
+ const value = getter();
257
+ object[key] = value;
258
+ return value;
259
+ }
260
+ throw new Error("cached value already set");
261
+ },
262
+ set(v) {
263
+ Object.defineProperty(object, key, {
264
+ value: v,
265
+ // configurable: true,
266
+ });
267
+ // object[key] = v;
268
+ },
269
+ configurable: true,
270
+ });
271
+ }
272
+
273
+ export function assignProp<T extends object, K extends PropertyKey>(
274
+ target: T,
275
+ prop: K,
276
+ value: K extends keyof T ? T[K] : any
277
+ ): void {
278
+ Object.defineProperty(target, prop, {
279
+ value,
280
+ writable: true,
281
+ enumerable: true,
282
+ configurable: true,
283
+ });
284
+ }
285
+
286
+ export function getElementAtPath(obj: any, path: (string | number)[] | null | undefined): any {
287
+ if (!path) return obj;
288
+ return path.reduce((acc, key) => acc?.[key], obj);
289
+ }
290
+
291
+ export function promiseAllObject<T extends object>(promisesObj: T): Promise<{ [k in keyof T]: Awaited<T[k]> }> {
292
+ const keys = Object.keys(promisesObj);
293
+ const promises = keys.map((key) => (promisesObj as any)[key]);
294
+
295
+ return Promise.all(promises).then((results) => {
296
+ const resolvedObj: any = {};
297
+ for (let i = 0; i < keys.length; i++) {
298
+ resolvedObj[keys[i]!] = results[i];
299
+ }
300
+ return resolvedObj;
301
+ });
302
+ }
303
+
304
+ export function randomString(length = 10): string {
305
+ const chars = "abcdefghijklmnopqrstuvwxyz";
306
+ let str = "";
307
+ for (let i = 0; i < length; i++) {
308
+ str += chars[Math.floor(Math.random() * chars.length)];
309
+ }
310
+ return str;
311
+ }
312
+
313
+ export function esc(str: string): string {
314
+ return JSON.stringify(str);
315
+ }
316
+
317
+ export const captureStackTrace: (targetObject: object, constructorOpt?: Function) => void = Error.captureStackTrace
318
+ ? Error.captureStackTrace
319
+ : (..._args) => {};
320
+
321
+ export function isObject(data: any): data is Record<PropertyKey, unknown> {
322
+ return typeof data === "object" && data !== null && !Array.isArray(data);
323
+ }
324
+
325
+ export const allowsEval: { value: boolean } = cached(() => {
326
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
327
+ return false;
328
+ }
329
+
330
+ try {
331
+ const F = Function;
332
+ new F("");
333
+ return true;
334
+ } catch (_) {
335
+ return false;
336
+ }
337
+ });
338
+
339
+ export function isPlainObject(o: any): o is Record<PropertyKey, unknown> {
340
+ if (isObject(o) === false) return false;
341
+
342
+ // modified constructor
343
+ const ctor = o.constructor;
344
+ if (ctor === undefined) return true;
345
+
346
+ // modified prototype
347
+ const prot = ctor.prototype;
348
+ if (isObject(prot) === false) return false;
349
+
350
+ // ctor doesn't have static `isPrototypeOf`
351
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
352
+ return false;
353
+ }
354
+
355
+ return true;
356
+ }
357
+
358
+ export function numKeys(data: any): number {
359
+ let keyCount = 0;
360
+ for (const key in data) {
361
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
362
+ keyCount++;
363
+ }
364
+ }
365
+ return keyCount;
366
+ }
367
+
368
+ export const getParsedType = (data: any): ParsedTypes => {
369
+ const t = typeof data;
370
+
371
+ switch (t) {
372
+ case "undefined":
373
+ return "undefined";
374
+
375
+ case "string":
376
+ return "string";
377
+
378
+ case "number":
379
+ return Number.isNaN(data) ? "nan" : "number";
380
+
381
+ case "boolean":
382
+ return "boolean";
383
+
384
+ case "function":
385
+ return "function";
386
+
387
+ case "bigint":
388
+ return "bigint";
389
+
390
+ case "symbol":
391
+ return "symbol";
392
+
393
+ case "object":
394
+ if (Array.isArray(data)) {
395
+ return "array";
396
+ }
397
+ if (data === null) {
398
+ return "null";
399
+ }
400
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
401
+ return "promise";
402
+ }
403
+ if (typeof Map !== "undefined" && data instanceof Map) {
404
+ return "map";
405
+ }
406
+ if (typeof Set !== "undefined" && data instanceof Set) {
407
+ return "set";
408
+ }
409
+ if (typeof Date !== "undefined" && data instanceof Date) {
410
+ return "date";
411
+ }
412
+ if (typeof File !== "undefined" && data instanceof File) {
413
+ return "file";
414
+ }
415
+ return "object";
416
+
417
+ default:
418
+ throw new Error(`Unknown data type: ${t}`);
419
+ }
420
+ };
421
+
422
+ export const propertyKeyTypes: Set<string> = new Set(["string", "number", "symbol"]);
423
+ export const primitiveTypes: Set<string> = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
424
+ export function escapeRegex(str: string): string {
425
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
426
+ }
427
+
428
+ // zod-specific utils
429
+ export function clone<T extends schemas.$ZodType>(inst: T, def?: T["_zod"]["def"], params?: { parent: boolean }): T {
430
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
431
+ if (!def || params?.parent) cl._zod.parent = inst;
432
+ return cl as any;
433
+ }
434
+
435
+ export type EmptyToNever<T> = keyof T extends never ? never : T;
436
+
437
+ export type Normalize<T> = T extends undefined
438
+ ? never
439
+ : T extends Record<any, any>
440
+ ? Flatten<
441
+ {
442
+ [k in keyof Omit<T, "error" | "message">]: T[k];
443
+ } & ("error" extends keyof T
444
+ ? {
445
+ error?: Exclude<T["error"], string>;
446
+ // path?: PropertyKey[] | undefined;
447
+ // message?: string | undefined;
448
+ }
449
+ : unknown)
450
+ >
451
+ : never;
452
+
453
+ export function normalizeParams<T>(_params: T): Normalize<T> {
454
+ const params: any = _params;
455
+
456
+ if (!params) return {} as any;
457
+ if (typeof params === "string") return { error: () => params } as any;
458
+ if (params?.message !== undefined) {
459
+ if (params?.error !== undefined) throw new Error("Cannot specify both `message` and `error` params");
460
+ params.error = params.message;
461
+ }
462
+ delete params.message;
463
+ if (typeof params.error === "string") return { ...params, error: () => params.error } as any;
464
+ return params;
465
+ }
466
+
467
+ export function createTransparentProxy<T extends object>(getter: () => T): T {
468
+ let target: T;
469
+ return new Proxy(
470
+ {},
471
+ {
472
+ get(_, prop, receiver) {
473
+ target ??= getter();
474
+ return Reflect.get(target, prop, receiver);
475
+ },
476
+ set(_, prop, value, receiver) {
477
+ target ??= getter();
478
+ return Reflect.set(target, prop, value, receiver);
479
+ },
480
+ has(_, prop) {
481
+ target ??= getter();
482
+ return Reflect.has(target, prop);
483
+ },
484
+ deleteProperty(_, prop) {
485
+ target ??= getter();
486
+ return Reflect.deleteProperty(target, prop);
487
+ },
488
+ ownKeys(_) {
489
+ target ??= getter();
490
+ return Reflect.ownKeys(target);
491
+ },
492
+ getOwnPropertyDescriptor(_, prop) {
493
+ target ??= getter();
494
+ return Reflect.getOwnPropertyDescriptor(target, prop);
495
+ },
496
+ defineProperty(_, prop, descriptor) {
497
+ target ??= getter();
498
+ return Reflect.defineProperty(target, prop, descriptor);
499
+ },
500
+ }
501
+ ) as T;
502
+ }
503
+
504
+ export function stringifyPrimitive(value: any): string {
505
+ if (typeof value === "bigint") return value.toString() + "n";
506
+ if (typeof value === "string") return `"${value}"`;
507
+ return `${value}`;
508
+ }
509
+
510
+ export function optionalKeys(shape: schemas.$ZodShape): string[] {
511
+ return Object.keys(shape).filter((k) => {
512
+ return shape[k]!._zod.optin === "optional" && shape[k]!._zod.optout === "optional";
513
+ });
514
+ }
515
+
516
+ export type CleanKey<T extends PropertyKey> = T extends `?${infer K}` ? K : T extends `${infer K}?` ? K : T;
517
+ export type ToCleanMap<T extends schemas.$ZodLooseShape> = {
518
+ [k in keyof T]: k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k;
519
+ };
520
+ export type FromCleanMap<T extends schemas.$ZodLooseShape> = {
521
+ [k in keyof T as k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k]: k;
522
+ };
523
+
524
+ export const NUMBER_FORMAT_RANGES: Record<checks.$ZodNumberFormats, [number, number]> = {
525
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
526
+ int32: [-2147483648, 2147483647],
527
+ uint32: [0, 4294967295],
528
+ float32: [-3.4028234663852886e38, 3.4028234663852886e38],
529
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE],
530
+ };
531
+
532
+ export const BIGINT_FORMAT_RANGES: Record<checks.$ZodBigIntFormats, [bigint, bigint]> = {
533
+ int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
534
+ uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")],
535
+ };
536
+
537
+ export function pick(schema: schemas.$ZodObject, mask: Record<string, unknown>): any {
538
+ const newShape: Writeable<schemas.$ZodShape> = {};
539
+ const currDef = schema._zod.def; //.shape;
540
+
541
+ for (const key in mask) {
542
+ if (!(key in currDef.shape)) {
543
+ throw new Error(`Unrecognized key: "${key}"`);
544
+ }
545
+ if (!mask[key]) continue;
546
+
547
+ // pick key
548
+ newShape[key] = currDef.shape[key]!;
549
+ }
550
+
551
+ return clone(schema, {
552
+ ...schema._zod.def,
553
+ shape: newShape,
554
+ checks: [],
555
+ }) as any;
556
+ }
557
+
558
+ export function omit(schema: schemas.$ZodObject, mask: object): any {
559
+ const newShape: Writeable<schemas.$ZodShape> = { ...schema._zod.def.shape };
560
+ const currDef = schema._zod.def; //.shape;
561
+ for (const key in mask) {
562
+ if (!(key in currDef.shape)) {
563
+ throw new Error(`Unrecognized key: "${key}"`);
564
+ }
565
+ if (!(mask as any)[key]) continue;
566
+
567
+ delete newShape[key];
568
+ }
569
+ return clone(schema, {
570
+ ...schema._zod.def,
571
+ shape: newShape,
572
+ checks: [],
573
+ });
574
+ }
575
+
576
+ export function extend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any {
577
+ if (!isPlainObject(shape)) {
578
+ throw new Error("Invalid input to extend: expected a plain object");
579
+ }
580
+ const def = {
581
+ ...schema._zod.def,
582
+ get shape() {
583
+ const _shape = { ...schema._zod.def.shape, ...shape };
584
+ assignProp(this, "shape", _shape); // self-caching
585
+ return _shape;
586
+ },
587
+ checks: [], // delete existing checks
588
+ } as any;
589
+ return clone(schema, def) as any;
590
+ }
591
+
592
+ export function merge(a: schemas.$ZodObject, b: schemas.$ZodObject): any {
593
+ return clone(a, {
594
+ ...a._zod.def,
595
+ get shape() {
596
+ const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
597
+ assignProp(this, "shape", _shape); // self-caching
598
+ return _shape;
599
+ },
600
+ catchall: b._zod.def.catchall,
601
+ checks: [], // delete existing checks
602
+ }) as any;
603
+ }
604
+
605
+ export function partial(
606
+ Class: SchemaClass<schemas.$ZodOptional> | null,
607
+ schema: schemas.$ZodObject,
608
+ mask: object | undefined
609
+ ): any {
610
+ const oldShape = schema._zod.def.shape;
611
+ const shape: Writeable<schemas.$ZodShape> = { ...oldShape };
612
+
613
+ if (mask) {
614
+ for (const key in mask) {
615
+ if (!(key in oldShape)) {
616
+ throw new Error(`Unrecognized key: "${key}"`);
617
+ }
618
+ if (!(mask as any)[key]) continue;
619
+ // if (oldShape[key]!._zod.optin === "optional") continue;
620
+ shape[key] = Class
621
+ ? new Class({
622
+ type: "optional",
623
+ innerType: oldShape[key]!,
624
+ })
625
+ : oldShape[key]!;
626
+ }
627
+ } else {
628
+ for (const key in oldShape) {
629
+ // if (oldShape[key]!._zod.optin === "optional") continue;
630
+ shape[key] = Class
631
+ ? new Class({
632
+ type: "optional",
633
+ innerType: oldShape[key]!,
634
+ })
635
+ : oldShape[key]!;
636
+ }
637
+ }
638
+
639
+ return clone(schema, {
640
+ ...schema._zod.def,
641
+ shape,
642
+ checks: [],
643
+ }) as any;
644
+ }
645
+
646
+ export function required(
647
+ Class: SchemaClass<schemas.$ZodNonOptional>,
648
+ schema: schemas.$ZodObject,
649
+ mask: object | undefined
650
+ ): any {
651
+ const oldShape = schema._zod.def.shape;
652
+ const shape: Writeable<schemas.$ZodShape> = { ...oldShape };
653
+
654
+ if (mask) {
655
+ for (const key in mask) {
656
+ if (!(key in shape)) {
657
+ throw new Error(`Unrecognized key: "${key}"`);
658
+ }
659
+ if (!(mask as any)[key]) continue;
660
+ // overwrite with non-optional
661
+ shape[key] = new Class({
662
+ type: "nonoptional",
663
+ innerType: oldShape[key]!,
664
+ });
665
+ }
666
+ } else {
667
+ for (const key in oldShape) {
668
+ // overwrite with non-optional
669
+ shape[key] = new Class({
670
+ type: "nonoptional",
671
+ innerType: oldShape[key]!,
672
+ });
673
+ }
674
+ }
675
+
676
+ return clone(schema, {
677
+ ...schema._zod.def,
678
+ shape,
679
+ // optional: [],
680
+ checks: [],
681
+ }) as any;
682
+ }
683
+
684
+ export type Constructor<T, Def extends any[] = any[]> = new (...args: Def) => T;
685
+
686
+ export function aborted(x: schemas.ParsePayload, startIndex = 0): boolean {
687
+ for (let i = startIndex; i < x.issues.length; i++) {
688
+ if (x.issues[i]?.continue !== true) return true;
689
+ }
690
+ return false;
691
+ }
692
+
693
+ export function prefixIssues(path: PropertyKey, issues: errors.$ZodRawIssue[]): errors.$ZodRawIssue[] {
694
+ return issues.map((iss) => {
695
+ (iss as any).path ??= [];
696
+ (iss as any).path.unshift(path);
697
+ return iss;
698
+ });
699
+ }
700
+
701
+ export function unwrapMessage(message: string | { message: string } | undefined | null): string | undefined {
702
+ return typeof message === "string" ? message : message?.message;
703
+ }
704
+
705
+ export function finalizeIssue(
706
+ iss: errors.$ZodRawIssue,
707
+ ctx: schemas.ParseContextInternal | undefined,
708
+ config: $ZodConfig
709
+ ): errors.$ZodIssue {
710
+ const full = { ...iss, path: iss.path ?? [] } as errors.$ZodIssue;
711
+
712
+ // for backwards compatibility
713
+ if (!iss.message) {
714
+ const message =
715
+ unwrapMessage(iss.inst?._zod.def?.error?.(iss as never)) ??
716
+ unwrapMessage(ctx?.error?.(iss as never)) ??
717
+ unwrapMessage(config.customError?.(iss)) ??
718
+ unwrapMessage(config.localeError?.(iss)) ??
719
+ "Invalid input";
720
+ (full as any).message = message;
721
+ }
722
+
723
+ // delete (full as any).def;
724
+ delete (full as any).inst;
725
+ delete (full as any).continue;
726
+ if (!ctx?.reportInput) {
727
+ delete (full as any).input;
728
+ }
729
+
730
+ return full;
731
+ }
732
+
733
+ export function getSizableOrigin(input: any): "set" | "map" | "file" | "unknown" {
734
+ if (input instanceof Set) return "set";
735
+ if (input instanceof Map) return "map";
736
+ if (input instanceof File) return "file";
737
+ return "unknown";
738
+ }
739
+
740
+ export function getLengthableOrigin(input: any): "array" | "string" | "unknown" {
741
+ if (Array.isArray(input)) return "array";
742
+ if (typeof input === "string") return "string";
743
+ return "unknown";
744
+ }
745
+
746
+ ////////// REFINES //////////
747
+ export function issue(_iss: string, input: any, inst: any): errors.$ZodRawIssue;
748
+ export function issue(_iss: errors.$ZodRawIssue): errors.$ZodRawIssue;
749
+ export function issue(...args: [string | errors.$ZodRawIssue, any?, any?]): errors.$ZodRawIssue {
750
+ const [iss, input, inst] = args;
751
+ if (typeof iss === "string") {
752
+ return {
753
+ message: iss,
754
+ code: "custom",
755
+ input,
756
+ inst,
757
+ };
758
+ }
759
+
760
+ return { ...iss };
761
+ }
762
+
763
+ export function cleanEnum(obj: Record<string, EnumValue>): EnumValue[] {
764
+ return Object.entries(obj)
765
+ .filter(([k, _]) => {
766
+ // return true if NaN, meaning it's not a number, thus a string key
767
+ return Number.isNaN(Number.parseInt(k, 10));
768
+ })
769
+ .map((el) => el[1]);
770
+ }
771
+
772
+ // instanceof
773
+ export abstract class Class {
774
+ constructor(..._args: any[]) {}
775
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/versions.ts ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ export const version = {
2
+ major: 4,
3
+ minor: 0,
4
+ patch: 0 as number,
5
+ } as const;
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/core/zsf.ts ADDED
@@ -0,0 +1,323 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ///////////////////////////////////////////////////
2
+ //////////////// TYPES ///////////////////
3
+ ///////////////////////////////////////////////////
4
+
5
+ export interface $ZSF {
6
+ $zsf: { version: number };
7
+ type: string;
8
+ // default value if not defined
9
+ default: unknown;
10
+ // fallback value if validation fails
11
+ fallback: unknown;
12
+ }
13
+
14
+ export interface $ZSFString extends $ZSF {
15
+ type: "string";
16
+ min_length?: number;
17
+ max_length?: number;
18
+ pattern?: string;
19
+ }
20
+
21
+ export type NumberTypes = "float32" | "int32" | "uint32" | "float64" | "int64" | "uint64" | "bigint" | "bigdecimal";
22
+
23
+ export interface $ZSFNumber extends $ZSF {
24
+ type: "number";
25
+ format?: NumberTypes;
26
+ minimum?: number;
27
+ maximum?: number;
28
+ multiple_of?: number;
29
+ }
30
+
31
+ export interface $ZSFBoolean extends $ZSF {
32
+ type: "boolean";
33
+ }
34
+
35
+ export interface $ZSFNull extends $ZSF {
36
+ type: "null";
37
+ }
38
+
39
+ export interface $ZSFUndefined extends $ZSF {
40
+ type: "undefined";
41
+ }
42
+
43
+ export interface $ZSFOptional<T extends $ZSF = $ZSF> extends $ZSF {
44
+ type: "optional";
45
+ inner: T;
46
+ }
47
+
48
+ export interface $ZSFNever extends $ZSF {
49
+ type: "never";
50
+ }
51
+
52
+ export interface $ZSFAny extends $ZSF {
53
+ type: "any";
54
+ }
55
+
56
+ /** Supports */
57
+ export interface $ZSFEnum<Elements extends { [k: string]: $ZSFLiteral } = { [k: string]: $ZSFLiteral }> extends $ZSF {
58
+ type: "enum";
59
+ elements: Elements;
60
+ }
61
+
62
+ export interface $ZSFArray<PrefixItems extends $ZSF[] = $ZSF[], Items extends $ZSF = $ZSF> extends $ZSF {
63
+ type: "array";
64
+ prefixItems: PrefixItems;
65
+ items: Items;
66
+ }
67
+
68
+ // type $ZSFObjectProperties = { [k: string]: $ZSF };
69
+ type $ZSFObjectProperties = Array<{
70
+ key: string;
71
+ value: $ZSF;
72
+ format?: "literal" | "pattern";
73
+ ordering?: number;
74
+ }>;
75
+ export interface $ZSFObject<Properties extends $ZSFObjectProperties = $ZSFObjectProperties> extends $ZSF {
76
+ type: "object";
77
+ properties: Properties;
78
+ }
79
+
80
+ // export interface $ZSFTuple<
81
+ // Items extends $ZSF[] = $ZSF[],
82
+ // Rest extends $ZSF = $ZSF,
83
+ // > extends $ZSF {
84
+ // type: "array";
85
+ // items: Items;
86
+ // rest: Rest;
87
+ // }
88
+
89
+ /** Supports arbitrary literal values */
90
+ export interface $ZSFLiteral<T extends $ZSF = $ZSF> extends $ZSF {
91
+ type: "literal";
92
+ schema: T;
93
+ value: unknown;
94
+ }
95
+
96
+ export interface $ZSFUnion<Elements extends $ZSF[] = $ZSF[]> extends $ZSF {
97
+ type: "union";
98
+ elements: Elements;
99
+ }
100
+
101
+ export interface $ZSFIntersection extends $ZSF {
102
+ type: "intersection";
103
+ elements: $ZSF[];
104
+ }
105
+
106
+ export interface $ZSFMap<K extends $ZSF = $ZSF, V extends $ZSF = $ZSF> extends $ZSF {
107
+ type: "map";
108
+ keys: K;
109
+ values: V;
110
+ }
111
+
112
+ export interface $ZSFConditional<If extends $ZSF, Then extends $ZSF, Else extends $ZSF> extends $ZSF {
113
+ type: "conditional";
114
+ if: If;
115
+ then: Then;
116
+ else: Else;
117
+ }
118
+
119
+ /////////////////////////////////////////////////
120
+ //////////////// CHECKS ////////////////
121
+ /////////////////////////////////////////////////
122
+
123
+ // export interface $ZSFCheckRegex {
124
+ // check: "regex";
125
+ // pattern: string;
126
+ // }
127
+
128
+ // export interface $ZSFCheckEmail {
129
+ // check: "email";
130
+ // }
131
+
132
+ // export interface $ZSFCheckURL {
133
+ // check: "url";
134
+ // }
135
+
136
+ // export interface $ZSFCheckEmoji {
137
+ // check: "emoji";
138
+ // }
139
+
140
+ // export interface $ZSFCheckUUID {
141
+ // check: "uuid";
142
+ // }
143
+
144
+ // export interface $ZSFCheckUUIDv4 {
145
+ // check: "uuidv4";
146
+ // }
147
+
148
+ // export interface $ZSFCheckUUIDv6 {
149
+ // check: "uuidv6";
150
+ // }
151
+
152
+ // export interface $ZSFCheckNanoid {
153
+ // check: "nanoid";
154
+ // }
155
+
156
+ // export interface $ZSFCheckGUID {
157
+ // check: "guid";
158
+ // }
159
+
160
+ // export interface $ZSFCheckCUID {
161
+ // check: "cuid";
162
+ // }
163
+
164
+ // export interface $ZSFCheckCUID2 {
165
+ // check: "cuid2";
166
+ // }
167
+
168
+ // export interface $ZSFCheckULID {
169
+ // check: "ulid";
170
+ // }
171
+
172
+ // export interface $ZSFCheckXID {
173
+ // check: "xid";
174
+ // }
175
+
176
+ // export interface $ZSFCheckKSUID {
177
+ // check: "ksuid";
178
+ // }
179
+
180
+ // export interface $ZSFCheckISODateTime {
181
+ // check: "datetime";
182
+ // precision?: number;
183
+ // local?: boolean;
184
+ // }
185
+
186
+ // export interface $ZSFCheckISODate {
187
+ // check: "date";
188
+ // }
189
+
190
+ // export interface $ZSFCheckISOTime {
191
+ // check: "time";
192
+ // precision?: number;
193
+ // local?: boolean;
194
+ // }
195
+
196
+ // export interface $ZSFCheckDuration {
197
+ // check: "duration";
198
+ // }
199
+
200
+ // export interface $ZSFCheckIP {
201
+ // check: "ip";
202
+ // }
203
+
204
+ // export interface $ZSFCheckIPv4 {
205
+ // check: "ipv4";
206
+ // }
207
+
208
+ // export interface $ZSFCheckIPv6 {
209
+ // check: "ipv6";
210
+ // }
211
+
212
+ // export interface $ZSFCheckBase64 {
213
+ // check: "base64";
214
+ // }
215
+
216
+ // export interface $ZSFCheckJWT {
217
+ // check: "jwt";
218
+ // }
219
+
220
+ // export interface $ZSFCheckJSONString {
221
+ // check: "json_string";
222
+ // }
223
+
224
+ // export interface $ZSFCheckPrefix {
225
+ // check: "prefix";
226
+ // prefix: string;
227
+ // }
228
+
229
+ // export interface $ZSFCheckSuffix {
230
+ // check: "suffix";
231
+ // suffix: string;
232
+ // }
233
+
234
+ // export interface $ZSFCheckIncludes {
235
+ // check: "includes";
236
+ // includes: string;
237
+ // }
238
+
239
+ // export interface $ZSFCheckMinSize {
240
+ // check: "min_size";
241
+ // minimum: number;
242
+ // }
243
+
244
+ // export interface $ZSFCheckMaxSize {
245
+ // check: "max_size";
246
+ // maximum: number;
247
+ // }
248
+
249
+ // export interface $ZSFCheckSizeEquals {
250
+ // check: "size_equals";
251
+ // size: number;
252
+ // }
253
+
254
+ // export interface $ZSFCheckLessThan {
255
+ // check: "less_than";
256
+ // maximum: number | bigint | Date;
257
+ // }
258
+
259
+ // export interface $ZSFCheckLessThanOrEqual {
260
+ // check: "less_than_or_equal";
261
+ // maximum: number | bigint | Date;
262
+ // }
263
+
264
+ // export interface $ZSFCheckGreaterThan {
265
+ // check: "greater_than";
266
+ // minimum: number | bigint | Date;
267
+ // }
268
+
269
+ // export interface $ZSFCheckGreaterThanOrEqual {
270
+ // check: "greater_than_or_equal";
271
+ // minimum: number | bigint | Date;
272
+ // }
273
+
274
+ // export interface $ZSFCheckEquals {
275
+ // check: "equals";
276
+ // value: number | bigint | Date;
277
+ // }
278
+
279
+ // export interface $ZSFCheckMultipleOf {
280
+ // check: "multiple_of";
281
+ // multipleOf: number;
282
+ // }
283
+
284
+ // export type $ZSFStringFormatChecks =
285
+ // | $ZSFCheckRegex
286
+ // | $ZSFCheckEmail
287
+ // | $ZSFCheckURL
288
+ // | $ZSFCheckEmoji
289
+ // | $ZSFCheckUUID
290
+ // | $ZSFCheckUUIDv4
291
+ // | $ZSFCheckUUIDv6
292
+ // | $ZSFCheckNanoid
293
+ // | $ZSFCheckGUID
294
+ // | $ZSFCheckCUID
295
+ // | $ZSFCheckCUID2
296
+ // | $ZSFCheckULID
297
+ // | $ZSFCheckXID
298
+ // | $ZSFCheckKSUID
299
+ // | $ZSFCheckISODateTime
300
+ // | $ZSFCheckISODate
301
+ // | $ZSFCheckISOTime
302
+ // | $ZSFCheckDuration
303
+ // | $ZSFCheckIP
304
+ // | $ZSFCheckIPv4
305
+ // | $ZSFCheckIPv6
306
+ // | $ZSFCheckBase64
307
+ // | $ZSFCheckJWT
308
+ // | $ZSFCheckJSONString
309
+ // | $ZSFCheckPrefix
310
+ // | $ZSFCheckSuffix
311
+ // | $ZSFCheckIncludes;
312
+
313
+ // export type $ZSFCheck =
314
+ // | $ZSFStringFormatChecks
315
+ // | $ZSFCheckMinSize
316
+ // | $ZSFCheckMaxSize
317
+ // | $ZSFCheckSizeEquals
318
+ // | $ZSFCheckLessThan
319
+ // | $ZSFCheckLessThanOrEqual
320
+ // | $ZSFCheckGreaterThan
321
+ // | $ZSFCheckGreaterThanOrEqual
322
+ // | $ZSFCheckEquals
323
+ // | $ZSFCheckMultipleOf;
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/index.ts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import z4 from "./classic/index.js";
2
+ export * from "./classic/index.js";
3
+
4
+ export default z4;
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/ar.ts ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "حرف", verb: "أن يحوي" },
8
+ file: { unit: "بايت", verb: "أن يحوي" },
9
+ array: { unit: "عنصر", verb: "أن يحوي" },
10
+ set: { unit: "عنصر", verb: "أن يحوي" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const parsedType = (data: any): string => {
18
+ const t = typeof data;
19
+
20
+ switch (t) {
21
+ case "number": {
22
+ return Number.isNaN(data) ? "NaN" : "number";
23
+ }
24
+ case "object": {
25
+ if (Array.isArray(data)) {
26
+ return "array";
27
+ }
28
+ if (data === null) {
29
+ return "null";
30
+ }
31
+
32
+ if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
33
+ return data.constructor.name;
34
+ }
35
+ }
36
+ }
37
+ return t;
38
+ };
39
+
40
+ const Nouns: {
41
+ [k in $ZodStringFormats | (string & {})]?: string;
42
+ } = {
43
+ regex: "مدخل",
44
+ email: "بريد إلكتروني",
45
+ url: "رابط",
46
+ emoji: "إيموجي",
47
+ uuid: "UUID",
48
+ uuidv4: "UUIDv4",
49
+ uuidv6: "UUIDv6",
50
+ nanoid: "nanoid",
51
+ guid: "GUID",
52
+ cuid: "cuid",
53
+ cuid2: "cuid2",
54
+ ulid: "ULID",
55
+ xid: "XID",
56
+ ksuid: "KSUID",
57
+ datetime: "تاريخ ووقت بمعيار ISO",
58
+ date: "تاريخ بمعيار ISO",
59
+ time: "وقت بمعيار ISO",
60
+ duration: "مدة بمعيار ISO",
61
+ ipv4: "عنوان IPv4",
62
+ ipv6: "عنوان IPv6",
63
+ cidrv4: "مدى عناوين بصيغة IPv4",
64
+ cidrv6: "مدى عناوين بصيغة IPv6",
65
+ base64: "نَص بترميز base64-encoded",
66
+ base64url: "نَص بترميز base64url-encoded",
67
+ json_string: "نَص على هيئة JSON",
68
+ e164: "رقم هاتف بمعيار E.164",
69
+ jwt: "JWT",
70
+ template_literal: "مدخل",
71
+ };
72
+
73
+ return (issue) => {
74
+ switch (issue.code) {
75
+ case "invalid_type":
76
+ return `مدخلات غير مقبولة: يفترض إدخال ${issue.expected}، ولكن تم إدخال ${parsedType(issue.input)}`;
77
+ case "invalid_value":
78
+ if (issue.values.length === 1)
79
+ return `مدخلات غير مقبولة: يفترض إدخال ${util.stringifyPrimitive(issue.values[0])}`;
80
+ return `اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${util.joinValues(issue.values, "|")}`;
81
+ case "too_big": {
82
+ const adj = issue.inclusive ? "<=" : "<";
83
+ const sizing = getSizing(issue.origin);
84
+ if (sizing)
85
+ return ` أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "عنصر"}`;
86
+ return `أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()}`;
87
+ }
88
+ case "too_small": {
89
+ const adj = issue.inclusive ? ">=" : ">";
90
+ const sizing = getSizing(issue.origin);
91
+ if (sizing) {
92
+ return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
93
+ }
94
+
95
+ return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()}`;
96
+ }
97
+ case "invalid_format": {
98
+ const _issue = issue as errors.$ZodStringFormatIssues;
99
+ if (_issue.format === "starts_with") return `نَص غير مقبول: يجب أن يبدأ بـ "${issue.prefix}"`;
100
+ if (_issue.format === "ends_with") return `نَص غير مقبول: يجب أن ينتهي بـ "${_issue.suffix}"`;
101
+ if (_issue.format === "includes") return `نَص غير مقبول: يجب أن يتضمَّن "${_issue.includes}"`;
102
+ if (_issue.format === "regex") return `نَص غير مقبول: يجب أن يطابق النمط ${_issue.pattern}`;
103
+ return `${Nouns[_issue.format] ?? issue.format} غير مقبول`;
104
+ }
105
+ case "not_multiple_of":
106
+ return `رقم غير مقبول: يجب أن يكون من مضاعفات ${issue.divisor}`;
107
+ case "unrecognized_keys":
108
+ return `معرف${issue.keys.length > 1 ? "ات" : ""} غريب${issue.keys.length > 1 ? "ة" : ""}: ${util.joinValues(issue.keys, "، ")}`;
109
+ case "invalid_key":
110
+ return `معرف غير مقبول في ${issue.origin}`;
111
+ case "invalid_union":
112
+ return "مدخل غير مقبول";
113
+ case "invalid_element":
114
+ return `مدخل غير مقبول في ${issue.origin}`;
115
+ default:
116
+ return "مدخل غير مقبول";
117
+ }
118
+ };
119
+ };
120
+
121
+ export default function (): { localeError: errors.$ZodErrorMap } {
122
+ return {
123
+ localeError: error(),
124
+ };
125
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/az.ts ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "simvol", verb: "olmalıdır" },
8
+ file: { unit: "bayt", verb: "olmalıdır" },
9
+ array: { unit: "element", verb: "olmalıdır" },
10
+ set: { unit: "element", verb: "olmalıdır" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const parsedType = (data: any): string => {
18
+ const t = typeof data;
19
+
20
+ switch (t) {
21
+ case "number": {
22
+ return Number.isNaN(data) ? "NaN" : "number";
23
+ }
24
+ case "object": {
25
+ if (Array.isArray(data)) {
26
+ return "array";
27
+ }
28
+ if (data === null) {
29
+ return "null";
30
+ }
31
+
32
+ if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
33
+ return data.constructor.name;
34
+ }
35
+ }
36
+ }
37
+ return t;
38
+ };
39
+
40
+ const Nouns: {
41
+ [k in $ZodStringFormats | (string & {})]?: string;
42
+ } = {
43
+ regex: "input",
44
+ email: "email address",
45
+ url: "URL",
46
+ emoji: "emoji",
47
+ uuid: "UUID",
48
+ uuidv4: "UUIDv4",
49
+ uuidv6: "UUIDv6",
50
+ nanoid: "nanoid",
51
+ guid: "GUID",
52
+ cuid: "cuid",
53
+ cuid2: "cuid2",
54
+ ulid: "ULID",
55
+ xid: "XID",
56
+ ksuid: "KSUID",
57
+ datetime: "ISO datetime",
58
+ date: "ISO date",
59
+ time: "ISO time",
60
+ duration: "ISO duration",
61
+ ipv4: "IPv4 address",
62
+ ipv6: "IPv6 address",
63
+ cidrv4: "IPv4 range",
64
+ cidrv6: "IPv6 range",
65
+ base64: "base64-encoded string",
66
+ base64url: "base64url-encoded string",
67
+ json_string: "JSON string",
68
+ e164: "E.164 number",
69
+ jwt: "JWT",
70
+ template_literal: "input",
71
+ };
72
+
73
+ return (issue) => {
74
+ switch (issue.code) {
75
+ case "invalid_type":
76
+ return `Yanlış dəyər: gözlənilən ${issue.expected}, daxil olan ${parsedType(issue.input)}`;
77
+ case "invalid_value":
78
+ if (issue.values.length === 1) return `Yanlış dəyər: gözlənilən ${util.stringifyPrimitive(issue.values[0])}`;
79
+ return `Yanlış seçim: aşağıdakılardan biri olmalıdır: ${util.joinValues(issue.values, "|")}`;
80
+ case "too_big": {
81
+ const adj = issue.inclusive ? "<=" : "<";
82
+ const sizing = getSizing(issue.origin);
83
+ if (sizing)
84
+ return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "element"}`;
85
+ return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()}`;
86
+ }
87
+ case "too_small": {
88
+ const adj = issue.inclusive ? ">=" : ">";
89
+ const sizing = getSizing(issue.origin);
90
+ if (sizing) return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
91
+ return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()}`;
92
+ }
93
+ case "invalid_format": {
94
+ const _issue = issue as errors.$ZodStringFormatIssues;
95
+ if (_issue.format === "starts_with") return `Yanlış mətn: "${_issue.prefix}" ilə başlamalıdır`;
96
+ if (_issue.format === "ends_with") return `Yanlış mətn: "${_issue.suffix}" ilə bitməlidir`;
97
+ if (_issue.format === "includes") return `Yanlış mətn: "${_issue.includes}" daxil olmalıdır`;
98
+ if (_issue.format === "regex") return `Yanlış mətn: ${_issue.pattern} şablonuna uyğun olmalıdır`;
99
+ return `Yanlış ${Nouns[_issue.format] ?? issue.format}`;
100
+ }
101
+ case "not_multiple_of":
102
+ return `Yanlış ədəd: ${issue.divisor} ilə bölünə bilən olmalıdır`;
103
+ case "unrecognized_keys":
104
+ return `Tanınmayan açar${issue.keys.length > 1 ? "lar" : ""}: ${util.joinValues(issue.keys, ", ")}`;
105
+ case "invalid_key":
106
+ return `${issue.origin} daxilində yanlış açar`;
107
+ case "invalid_union":
108
+ return "Yanlış dəyər";
109
+ case "invalid_element":
110
+ return `${issue.origin} daxilində yanlış dəyər`;
111
+ default:
112
+ return `Yanlış dəyər`;
113
+ }
114
+ };
115
+ };
116
+
117
+ export default function (): { localeError: errors.$ZodErrorMap } {
118
+ return {
119
+ localeError: error(),
120
+ };
121
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/be.ts ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ function getBelarusianPlural(count: number, one: string, few: string, many: string): string {
6
+ const absCount = Math.abs(count);
7
+ const lastDigit = absCount % 10;
8
+ const lastTwoDigits = absCount % 100;
9
+
10
+ if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
11
+ return many;
12
+ }
13
+
14
+ if (lastDigit === 1) {
15
+ return one;
16
+ }
17
+
18
+ if (lastDigit >= 2 && lastDigit <= 4) {
19
+ return few;
20
+ }
21
+
22
+ return many;
23
+ }
24
+
25
+ interface BelarusianSizable {
26
+ unit: {
27
+ one: string;
28
+ few: string;
29
+ many: string;
30
+ };
31
+ verb: string;
32
+ }
33
+ const error: () => errors.$ZodErrorMap = () => {
34
+ const Sizable: Record<string, BelarusianSizable> = {
35
+ string: {
36
+ unit: {
37
+ one: "сімвал",
38
+ few: "сімвалы",
39
+ many: "сімвалаў",
40
+ },
41
+ verb: "мець",
42
+ },
43
+ array: {
44
+ unit: {
45
+ one: "элемент",
46
+ few: "элементы",
47
+ many: "элементаў",
48
+ },
49
+ verb: "мець",
50
+ },
51
+ set: {
52
+ unit: {
53
+ one: "элемент",
54
+ few: "элементы",
55
+ many: "элементаў",
56
+ },
57
+ verb: "мець",
58
+ },
59
+ file: {
60
+ unit: {
61
+ one: "байт",
62
+ few: "байты",
63
+ many: "байтаў",
64
+ },
65
+ verb: "мець",
66
+ },
67
+ };
68
+
69
+ function getSizing(origin: string): BelarusianSizable | null {
70
+ return Sizable[origin] ?? null;
71
+ }
72
+
73
+ const parsedType = (data: any): string => {
74
+ const t = typeof data;
75
+
76
+ switch (t) {
77
+ case "number": {
78
+ return Number.isNaN(data) ? "NaN" : "лік";
79
+ }
80
+ case "object": {
81
+ if (Array.isArray(data)) {
82
+ return "масіў";
83
+ }
84
+ if (data === null) {
85
+ return "null";
86
+ }
87
+
88
+ if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
89
+ return data.constructor.name;
90
+ }
91
+ }
92
+ }
93
+ return t;
94
+ };
95
+
96
+ const Nouns: {
97
+ [k in $ZodStringFormats | (string & {})]?: string;
98
+ } = {
99
+ regex: "увод",
100
+ email: "email адрас",
101
+ url: "URL",
102
+ emoji: "эмодзі",
103
+ uuid: "UUID",
104
+ uuidv4: "UUIDv4",
105
+ uuidv6: "UUIDv6",
106
+ nanoid: "nanoid",
107
+ guid: "GUID",
108
+ cuid: "cuid",
109
+ cuid2: "cuid2",
110
+ ulid: "ULID",
111
+ xid: "XID",
112
+ ksuid: "KSUID",
113
+ datetime: "ISO дата і час",
114
+ date: "ISO дата",
115
+ time: "ISO час",
116
+ duration: "ISO працягласць",
117
+ ipv4: "IPv4 адрас",
118
+ ipv6: "IPv6 адрас",
119
+ cidrv4: "IPv4 дыяпазон",
120
+ cidrv6: "IPv6 дыяпазон",
121
+ base64: "радок у фармаце base64",
122
+ base64url: "радок у фармаце base64url",
123
+ json_string: "JSON радок",
124
+ e164: "нумар E.164",
125
+ jwt: "JWT",
126
+ template_literal: "увод",
127
+ };
128
+
129
+ return (issue) => {
130
+ switch (issue.code) {
131
+ case "invalid_type":
132
+ return `Няправільны ўвод: чакаўся ${issue.expected}, атрымана ${parsedType(issue.input)}`;
133
+ case "invalid_value":
134
+ if (issue.values.length === 1) return `Няправільны ўвод: чакалася ${util.stringifyPrimitive(issue.values[0])}`;
135
+ return `Няправільны варыянт: чакаўся адзін з ${util.joinValues(issue.values, "|")}`;
136
+ case "too_big": {
137
+ const adj = issue.inclusive ? "<=" : "<";
138
+ const sizing = getSizing(issue.origin);
139
+ if (sizing) {
140
+ const maxValue = Number(issue.maximum);
141
+ const unit = getBelarusianPlural(maxValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
142
+ return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна ${sizing.verb} ${adj}${issue.maximum.toString()} ${unit}`;
143
+ }
144
+ return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна быць ${adj}${issue.maximum.toString()}`;
145
+ }
146
+ case "too_small": {
147
+ const adj = issue.inclusive ? ">=" : ">";
148
+ const sizing = getSizing(issue.origin);
149
+ if (sizing) {
150
+ const minValue = Number(issue.minimum);
151
+ const unit = getBelarusianPlural(minValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
152
+ return `Занадта малы: чакалася, што ${issue.origin} павінна ${sizing.verb} ${adj}${issue.minimum.toString()} ${unit}`;
153
+ }
154
+ return `Занадта малы: чакалася, што ${issue.origin} павінна быць ${adj}${issue.minimum.toString()}`;
155
+ }
156
+ case "invalid_format": {
157
+ const _issue = issue as errors.$ZodStringFormatIssues;
158
+ if (_issue.format === "starts_with") return `Няправільны радок: павінен пачынацца з "${_issue.prefix}"`;
159
+ if (_issue.format === "ends_with") return `Няправільны радок: павінен заканчвацца на "${_issue.suffix}"`;
160
+ if (_issue.format === "includes") return `Няправільны радок: павінен змяшчаць "${_issue.includes}"`;
161
+ if (_issue.format === "regex") return `Няправільны радок: павінен адпавядаць шаблону ${_issue.pattern}`;
162
+ return `Няправільны ${Nouns[_issue.format] ?? issue.format}`;
163
+ }
164
+ case "not_multiple_of":
165
+ return `Няправільны лік: павінен быць кратным ${issue.divisor}`;
166
+ case "unrecognized_keys":
167
+ return `Нераспазнаны ${issue.keys.length > 1 ? "ключы" : "ключ"}: ${util.joinValues(issue.keys, ", ")}`;
168
+ case "invalid_key":
169
+ return `Няправільны ключ у ${issue.origin}`;
170
+ case "invalid_union":
171
+ return "Няправільны ўвод";
172
+ case "invalid_element":
173
+ return `Няправільнае значэнне ў ${issue.origin}`;
174
+ default:
175
+ return `Няправільны ўвод`;
176
+ }
177
+ };
178
+ };
179
+
180
+ export default function (): { localeError: errors.$ZodErrorMap } {
181
+ return {
182
+ localeError: error(),
183
+ };
184
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/ca.ts ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "caràcters", verb: "contenir" },
8
+ file: { unit: "bytes", verb: "contenir" },
9
+ array: { unit: "elements", verb: "contenir" },
10
+ set: { unit: "elements", verb: "contenir" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const parsedType = (data: any): string => {
18
+ const t = typeof data;
19
+
20
+ switch (t) {
21
+ case "number": {
22
+ return Number.isNaN(data) ? "NaN" : "number";
23
+ }
24
+ case "object": {
25
+ if (Array.isArray(data)) {
26
+ return "array";
27
+ }
28
+ if (data === null) {
29
+ return "null";
30
+ }
31
+
32
+ if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
33
+ return data.constructor.name;
34
+ }
35
+ }
36
+ }
37
+ return t;
38
+ };
39
+
40
+ const Nouns: {
41
+ [k in $ZodStringFormats | (string & {})]?: string;
42
+ } = {
43
+ regex: "entrada",
44
+ email: "adreça electrònica",
45
+ url: "URL",
46
+ emoji: "emoji",
47
+ uuid: "UUID",
48
+ uuidv4: "UUIDv4",
49
+ uuidv6: "UUIDv6",
50
+ nanoid: "nanoid",
51
+ guid: "GUID",
52
+ cuid: "cuid",
53
+ cuid2: "cuid2",
54
+ ulid: "ULID",
55
+ xid: "XID",
56
+ ksuid: "KSUID",
57
+ datetime: "data i hora ISO",
58
+ date: "data ISO",
59
+ time: "hora ISO",
60
+ duration: "durada ISO",
61
+ ipv4: "adreça IPv4",
62
+ ipv6: "adreça IPv6",
63
+ cidrv4: "rang IPv4",
64
+ cidrv6: "rang IPv6",
65
+ base64: "cadena codificada en base64",
66
+ base64url: "cadena codificada en base64url",
67
+ json_string: "cadena JSON",
68
+ e164: "número E.164",
69
+ jwt: "JWT",
70
+ template_literal: "entrada",
71
+ };
72
+
73
+ return (issue) => {
74
+ switch (issue.code) {
75
+ case "invalid_type":
76
+ return `Tipus invàlid: s'esperava ${issue.expected}, s'ha rebut ${parsedType(issue.input)}`;
77
+ // return `Tipus invàlid: s'esperava ${issue.expected}, s'ha rebut ${util.getParsedType(issue.input)}`;
78
+ case "invalid_value":
79
+ if (issue.values.length === 1) return `Valor invàlid: s'esperava ${util.stringifyPrimitive(issue.values[0])}`;
80
+ return `Opció invàlida: s'esperava una de ${util.joinValues(issue.values, " o ")}`;
81
+ case "too_big": {
82
+ const adj = issue.inclusive ? "com a màxim" : "menys de";
83
+ const sizing = getSizing(issue.origin);
84
+ if (sizing)
85
+ return `Massa gran: s'esperava que ${issue.origin ?? "el valor"} contingués ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
86
+ return `Massa gran: s'esperava que ${issue.origin ?? "el valor"} fos ${adj} ${issue.maximum.toString()}`;
87
+ }
88
+ case "too_small": {
89
+ const adj = issue.inclusive ? "com a mínim" : "més de";
90
+ const sizing = getSizing(issue.origin);
91
+ if (sizing) {
92
+ return `Massa petit: s'esperava que ${issue.origin} contingués ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
93
+ }
94
+
95
+ return `Massa petit: s'esperava que ${issue.origin} fos ${adj} ${issue.minimum.toString()}`;
96
+ }
97
+ case "invalid_format": {
98
+ const _issue = issue as errors.$ZodStringFormatIssues;
99
+ if (_issue.format === "starts_with") {
100
+ return `Format invàlid: ha de començar amb "${_issue.prefix}"`;
101
+ }
102
+ if (_issue.format === "ends_with") return `Format invàlid: ha d'acabar amb "${_issue.suffix}"`;
103
+ if (_issue.format === "includes") return `Format invàlid: ha d'incloure "${_issue.includes}"`;
104
+ if (_issue.format === "regex") return `Format invàlid: ha de coincidir amb el patró ${_issue.pattern}`;
105
+ return `Format invàlid per a ${Nouns[_issue.format] ?? issue.format}`;
106
+ }
107
+ case "not_multiple_of":
108
+ return `Número invàlid: ha de ser múltiple de ${issue.divisor}`;
109
+ case "unrecognized_keys":
110
+ return `Clau${issue.keys.length > 1 ? "s" : ""} no reconeguda${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
111
+ case "invalid_key":
112
+ return `Clau invàlida a ${issue.origin}`;
113
+ case "invalid_union":
114
+ return "Entrada invàlida"; // Could also be "Tipus d'unió invàlid" but "Entrada invàlida" is more general
115
+ case "invalid_element":
116
+ return `Element invàlid a ${issue.origin}`;
117
+ default:
118
+ return `Entrada invàlida`;
119
+ }
120
+ };
121
+ };
122
+
123
+ export default function (): { localeError: errors.$ZodErrorMap } {
124
+ return {
125
+ localeError: error(),
126
+ };
127
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/cs.ts ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "znaků", verb: "mít" },
8
+ file: { unit: "bajtů", verb: "mít" },
9
+ array: { unit: "prvků", verb: "mít" },
10
+ set: { unit: "prvků", verb: "mít" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const parsedType = (data: any): string => {
18
+ const t = typeof data;
19
+
20
+ switch (t) {
21
+ case "number": {
22
+ return Number.isNaN(data) ? "NaN" : "číslo";
23
+ }
24
+ case "string": {
25
+ return "řetězec";
26
+ }
27
+ case "boolean": {
28
+ return "boolean";
29
+ }
30
+ case "bigint": {
31
+ return "bigint";
32
+ }
33
+ case "function": {
34
+ return "funkce";
35
+ }
36
+ case "symbol": {
37
+ return "symbol";
38
+ }
39
+ case "undefined": {
40
+ return "undefined";
41
+ }
42
+ case "object": {
43
+ if (Array.isArray(data)) {
44
+ return "pole";
45
+ }
46
+ if (data === null) {
47
+ return "null";
48
+ }
49
+
50
+ if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
51
+ return data.constructor.name;
52
+ }
53
+ }
54
+ }
55
+ return t;
56
+ };
57
+
58
+ const Nouns: {
59
+ [k in $ZodStringFormats | (string & {})]?: string;
60
+ } = {
61
+ regex: "regulární výraz",
62
+ email: "e-mailová adresa",
63
+ url: "URL",
64
+ emoji: "emoji",
65
+ uuid: "UUID",
66
+ uuidv4: "UUIDv4",
67
+ uuidv6: "UUIDv6",
68
+ nanoid: "nanoid",
69
+ guid: "GUID",
70
+ cuid: "cuid",
71
+ cuid2: "cuid2",
72
+ ulid: "ULID",
73
+ xid: "XID",
74
+ ksuid: "KSUID",
75
+ datetime: "datum a čas ve formátu ISO",
76
+ date: "datum ve formátu ISO",
77
+ time: "čas ve formátu ISO",
78
+ duration: "doba trvání ISO",
79
+ ipv4: "IPv4 adresa",
80
+ ipv6: "IPv6 adresa",
81
+ cidrv4: "rozsah IPv4",
82
+ cidrv6: "rozsah IPv6",
83
+ base64: "řetězec zakódovaný ve formátu base64",
84
+ base64url: "řetězec zakódovaný ve formátu base64url",
85
+ json_string: "řetězec ve formátu JSON",
86
+ e164: "číslo E.164",
87
+ jwt: "JWT",
88
+ template_literal: "vstup",
89
+ };
90
+
91
+ return (issue) => {
92
+ switch (issue.code) {
93
+ case "invalid_type":
94
+ return `Neplatný vstup: očekáváno ${issue.expected}, obdrženo ${parsedType(issue.input)}`;
95
+ case "invalid_value":
96
+ if (issue.values.length === 1) return `Neplatný vstup: očekáváno ${util.stringifyPrimitive(issue.values[0])}`;
97
+ return `Neplatná možnost: očekávána jedna z hodnot ${util.joinValues(issue.values, "|")}`;
98
+ case "too_big": {
99
+ const adj = issue.inclusive ? "<=" : "<";
100
+ const sizing = getSizing(issue.origin);
101
+ if (sizing) {
102
+ return `Hodnota je příliš velká: ${issue.origin ?? "hodnota"} musí mít ${adj}${issue.maximum.toString()} ${sizing.unit ?? "prvků"}`;
103
+ }
104
+ return `Hodnota je příliš velká: ${issue.origin ?? "hodnota"} musí být ${adj}${issue.maximum.toString()}`;
105
+ }
106
+ case "too_small": {
107
+ const adj = issue.inclusive ? ">=" : ">";
108
+ const sizing = getSizing(issue.origin);
109
+ if (sizing) {
110
+ return `Hodnota je příliš malá: ${issue.origin ?? "hodnota"} musí mít ${adj}${issue.minimum.toString()} ${sizing.unit ?? "prvků"}`;
111
+ }
112
+ return `Hodnota je příliš malá: ${issue.origin ?? "hodnota"} musí být ${adj}${issue.minimum.toString()}`;
113
+ }
114
+ case "invalid_format": {
115
+ const _issue = issue as errors.$ZodStringFormatIssues;
116
+ if (_issue.format === "starts_with") return `Neplatný řetězec: musí začínat na "${_issue.prefix}"`;
117
+ if (_issue.format === "ends_with") return `Neplatný řetězec: musí končit na "${_issue.suffix}"`;
118
+ if (_issue.format === "includes") return `Neplatný řetězec: musí obsahovat "${_issue.includes}"`;
119
+ if (_issue.format === "regex") return `Neplatný řetězec: musí odpovídat vzoru ${_issue.pattern}`;
120
+ return `Neplatný formát ${Nouns[_issue.format] ?? issue.format}`;
121
+ }
122
+ case "not_multiple_of":
123
+ return `Neplatné číslo: musí být násobkem ${issue.divisor}`;
124
+ case "unrecognized_keys":
125
+ return `Neznámé klíče: ${util.joinValues(issue.keys, ", ")}`;
126
+ case "invalid_key":
127
+ return `Neplatný klíč v ${issue.origin}`;
128
+ case "invalid_union":
129
+ return "Neplatný vstup";
130
+ case "invalid_element":
131
+ return `Neplatná hodnota v ${issue.origin}`;
132
+ default:
133
+ return `Neplatný vstup`;
134
+ }
135
+ };
136
+ };
137
+
138
+ export default function (): { localeError: errors.$ZodErrorMap } {
139
+ return {
140
+ localeError: error(),
141
+ };
142
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/de.ts ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "Zeichen", verb: "zu haben" },
8
+ file: { unit: "Bytes", verb: "zu haben" },
9
+ array: { unit: "Elemente", verb: "zu haben" },
10
+ set: { unit: "Elemente", verb: "zu haben" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const parsedType = (data: any): string => {
18
+ const t = typeof data;
19
+
20
+ switch (t) {
21
+ case "number": {
22
+ return Number.isNaN(data) ? "NaN" : "Zahl";
23
+ }
24
+ case "object": {
25
+ if (Array.isArray(data)) {
26
+ return "Array";
27
+ }
28
+ if (data === null) {
29
+ return "null";
30
+ }
31
+
32
+ if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
33
+ return data.constructor.name;
34
+ }
35
+ }
36
+ }
37
+ return t;
38
+ };
39
+
40
+ const Nouns: {
41
+ [k in $ZodStringFormats | (string & {})]?: string;
42
+ } = {
43
+ regex: "Eingabe",
44
+ email: "E-Mail-Adresse",
45
+ url: "URL",
46
+ emoji: "Emoji",
47
+ uuid: "UUID",
48
+ uuidv4: "UUIDv4",
49
+ uuidv6: "UUIDv6",
50
+ nanoid: "nanoid",
51
+ guid: "GUID",
52
+ cuid: "cuid",
53
+ cuid2: "cuid2",
54
+ ulid: "ULID",
55
+ xid: "XID",
56
+ ksuid: "KSUID",
57
+ datetime: "ISO-Datum und -Uhrzeit",
58
+ date: "ISO-Datum",
59
+ time: "ISO-Uhrzeit",
60
+ duration: "ISO-Dauer",
61
+ ipv4: "IPv4-Adresse",
62
+ ipv6: "IPv6-Adresse",
63
+ cidrv4: "IPv4-Bereich",
64
+ cidrv6: "IPv6-Bereich",
65
+ base64: "Base64-codierter String",
66
+ base64url: "Base64-URL-codierter String",
67
+ json_string: "JSON-String",
68
+ e164: "E.164-Nummer",
69
+ jwt: "JWT",
70
+ template_literal: "Eingabe",
71
+ };
72
+
73
+ return (issue) => {
74
+ switch (issue.code) {
75
+ case "invalid_type":
76
+ return `Ungültige Eingabe: erwartet ${issue.expected}, erhalten ${parsedType(issue.input)}`;
77
+ case "invalid_value":
78
+ if (issue.values.length === 1) return `Ungültige Eingabe: erwartet ${util.stringifyPrimitive(issue.values[0])}`;
79
+ return `Ungültige Option: erwartet eine von ${util.joinValues(issue.values, "|")}`;
80
+ case "too_big": {
81
+ const adj = issue.inclusive ? "<=" : "<";
82
+ const sizing = getSizing(issue.origin);
83
+ if (sizing)
84
+ return `Zu groß: erwartet, dass ${issue.origin ?? "Wert"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "Elemente"} hat`;
85
+ return `Zu groß: erwartet, dass ${issue.origin ?? "Wert"} ${adj}${issue.maximum.toString()} ist`;
86
+ }
87
+ case "too_small": {
88
+ const adj = issue.inclusive ? ">=" : ">";
89
+ const sizing = getSizing(issue.origin);
90
+ if (sizing) {
91
+ return `Zu klein: erwartet, dass ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} hat`;
92
+ }
93
+
94
+ return `Zu klein: erwartet, dass ${issue.origin} ${adj}${issue.minimum.toString()} ist`;
95
+ }
96
+ case "invalid_format": {
97
+ const _issue = issue as errors.$ZodStringFormatIssues;
98
+ if (_issue.format === "starts_with") return `Ungültiger String: muss mit "${_issue.prefix}" beginnen`;
99
+ if (_issue.format === "ends_with") return `Ungültiger String: muss mit "${_issue.suffix}" enden`;
100
+ if (_issue.format === "includes") return `Ungültiger String: muss "${_issue.includes}" enthalten`;
101
+ if (_issue.format === "regex") return `Ungültiger String: muss dem Muster ${_issue.pattern} entsprechen`;
102
+ return `Ungültig: ${Nouns[_issue.format] ?? issue.format}`;
103
+ }
104
+ case "not_multiple_of":
105
+ return `Ungültige Zahl: muss ein Vielfaches von ${issue.divisor} sein`;
106
+ case "unrecognized_keys":
107
+ return `${issue.keys.length > 1 ? "Unbekannte Schlüssel" : "Unbekannter Schlüssel"}: ${util.joinValues(issue.keys, ", ")}`;
108
+ case "invalid_key":
109
+ return `Ungültiger Schlüssel in ${issue.origin}`;
110
+ case "invalid_union":
111
+ return "Ungültige Eingabe";
112
+ case "invalid_element":
113
+ return `Ungültiger Wert in ${issue.origin}`;
114
+ default:
115
+ return `Ungültige Eingabe`;
116
+ }
117
+ };
118
+ };
119
+
120
+ export default function (): { localeError: errors.$ZodErrorMap } {
121
+ return {
122
+ localeError: error(),
123
+ };
124
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/en.ts ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ export const parsedType = (data: any): string => {
6
+ const t = typeof data;
7
+
8
+ switch (t) {
9
+ case "number": {
10
+ return Number.isNaN(data) ? "NaN" : "number";
11
+ }
12
+ case "object": {
13
+ if (Array.isArray(data)) {
14
+ return "array";
15
+ }
16
+ if (data === null) {
17
+ return "null";
18
+ }
19
+
20
+ if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
21
+ return data.constructor.name;
22
+ }
23
+ }
24
+ }
25
+ return t;
26
+ };
27
+
28
+ const error: () => errors.$ZodErrorMap = () => {
29
+ const Sizable: Record<string, { unit: string; verb: string }> = {
30
+ string: { unit: "characters", verb: "to have" },
31
+ file: { unit: "bytes", verb: "to have" },
32
+ array: { unit: "items", verb: "to have" },
33
+ set: { unit: "items", verb: "to have" },
34
+ };
35
+
36
+ function getSizing(origin: string): { unit: string; verb: string } | null {
37
+ return Sizable[origin] ?? null;
38
+ }
39
+
40
+ const Nouns: {
41
+ [k in $ZodStringFormats | (string & {})]?: string;
42
+ } = {
43
+ regex: "input",
44
+ email: "email address",
45
+ url: "URL",
46
+ emoji: "emoji",
47
+ uuid: "UUID",
48
+ uuidv4: "UUIDv4",
49
+ uuidv6: "UUIDv6",
50
+ nanoid: "nanoid",
51
+ guid: "GUID",
52
+ cuid: "cuid",
53
+ cuid2: "cuid2",
54
+ ulid: "ULID",
55
+ xid: "XID",
56
+ ksuid: "KSUID",
57
+ datetime: "ISO datetime",
58
+ date: "ISO date",
59
+ time: "ISO time",
60
+ duration: "ISO duration",
61
+ ipv4: "IPv4 address",
62
+ ipv6: "IPv6 address",
63
+ cidrv4: "IPv4 range",
64
+ cidrv6: "IPv6 range",
65
+ base64: "base64-encoded string",
66
+ base64url: "base64url-encoded string",
67
+ json_string: "JSON string",
68
+ e164: "E.164 number",
69
+ jwt: "JWT",
70
+ template_literal: "input",
71
+ };
72
+
73
+ return (issue) => {
74
+ switch (issue.code) {
75
+ case "invalid_type":
76
+ return `Invalid input: expected ${issue.expected}, received ${parsedType(issue.input)}`;
77
+
78
+ case "invalid_value":
79
+ if (issue.values.length === 1) return `Invalid input: expected ${util.stringifyPrimitive(issue.values[0])}`;
80
+ return `Invalid option: expected one of ${util.joinValues(issue.values, "|")}`;
81
+ case "too_big": {
82
+ const adj = issue.inclusive ? "<=" : "<";
83
+ const sizing = getSizing(issue.origin);
84
+ if (sizing)
85
+ return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
86
+ return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
87
+ }
88
+ case "too_small": {
89
+ const adj = issue.inclusive ? ">=" : ">";
90
+ const sizing = getSizing(issue.origin);
91
+ if (sizing) {
92
+ return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
93
+ }
94
+
95
+ return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
96
+ }
97
+ case "invalid_format": {
98
+ const _issue = issue as errors.$ZodStringFormatIssues;
99
+ if (_issue.format === "starts_with") {
100
+ return `Invalid string: must start with "${_issue.prefix}"`;
101
+ }
102
+ if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
103
+ if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
104
+ if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
105
+ return `Invalid ${Nouns[_issue.format] ?? issue.format}`;
106
+ }
107
+ case "not_multiple_of":
108
+ return `Invalid number: must be a multiple of ${issue.divisor}`;
109
+ case "unrecognized_keys":
110
+ return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
111
+ case "invalid_key":
112
+ return `Invalid key in ${issue.origin}`;
113
+ case "invalid_union":
114
+ return "Invalid input";
115
+ case "invalid_element":
116
+ return `Invalid value in ${issue.origin}`;
117
+ default:
118
+ return `Invalid input`;
119
+ }
120
+ };
121
+ };
122
+
123
+ export default function (): { localeError: errors.$ZodErrorMap } {
124
+ return {
125
+ localeError: error(),
126
+ };
127
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/eo.ts ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ export const parsedType = (data: any): string => {
6
+ const t = typeof data;
7
+
8
+ switch (t) {
9
+ case "number": {
10
+ return Number.isNaN(data) ? "NaN" : "nombro";
11
+ }
12
+ case "object": {
13
+ if (Array.isArray(data)) {
14
+ return "tabelo";
15
+ }
16
+ if (data === null) {
17
+ return "senvalora";
18
+ }
19
+
20
+ if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
21
+ return data.constructor.name;
22
+ }
23
+ }
24
+ }
25
+ return t;
26
+ };
27
+
28
+ const error: () => errors.$ZodErrorMap = () => {
29
+ const Sizable: Record<string, { unit: string; verb: string }> = {
30
+ string: { unit: "karaktrojn", verb: "havi" },
31
+ file: { unit: "bajtojn", verb: "havi" },
32
+ array: { unit: "elementojn", verb: "havi" },
33
+ set: { unit: "elementojn", verb: "havi" },
34
+ };
35
+
36
+ function getSizing(origin: string): { unit: string; verb: string } | null {
37
+ return Sizable[origin] ?? null;
38
+ }
39
+
40
+ const Nouns: {
41
+ [k in $ZodStringFormats | (string & {})]?: string;
42
+ } = {
43
+ regex: "enigo",
44
+ email: "retadreso",
45
+ url: "URL",
46
+ emoji: "emoĝio",
47
+ uuid: "UUID",
48
+ uuidv4: "UUIDv4",
49
+ uuidv6: "UUIDv6",
50
+ nanoid: "nanoid",
51
+ guid: "GUID",
52
+ cuid: "cuid",
53
+ cuid2: "cuid2",
54
+ ulid: "ULID",
55
+ xid: "XID",
56
+ ksuid: "KSUID",
57
+ datetime: "ISO-datotempo",
58
+ date: "ISO-dato",
59
+ time: "ISO-tempo",
60
+ duration: "ISO-daŭro",
61
+ ipv4: "IPv4-adreso",
62
+ ipv6: "IPv6-adreso",
63
+ cidrv4: "IPv4-rango",
64
+ cidrv6: "IPv6-rango",
65
+ base64: "64-ume kodita karaktraro",
66
+ base64url: "URL-64-ume kodita karaktraro",
67
+ json_string: "JSON-karaktraro",
68
+ e164: "E.164-nombro",
69
+ jwt: "JWT",
70
+ template_literal: "enigo",
71
+ };
72
+
73
+ return (issue) => {
74
+ switch (issue.code) {
75
+ case "invalid_type":
76
+ return `Nevalida enigo: atendiĝis ${issue.expected}, riceviĝis ${parsedType(issue.input)}`;
77
+
78
+ case "invalid_value":
79
+ if (issue.values.length === 1) return `Nevalida enigo: atendiĝis ${util.stringifyPrimitive(issue.values[0])}`;
80
+ return `Nevalida opcio: atendiĝis unu el ${util.joinValues(issue.values, "|")}`;
81
+ case "too_big": {
82
+ const adj = issue.inclusive ? "<=" : "<";
83
+ const sizing = getSizing(issue.origin);
84
+ if (sizing)
85
+ return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementojn"}`;
86
+ return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()}`;
87
+ }
88
+ case "too_small": {
89
+ const adj = issue.inclusive ? ">=" : ">";
90
+ const sizing = getSizing(issue.origin);
91
+ if (sizing) {
92
+ return `Tro malgranda: atendiĝis ke ${issue.origin} havu ${adj}${issue.minimum.toString()} ${sizing.unit}`;
93
+ }
94
+
95
+ return `Tro malgranda: atendiĝis ke ${issue.origin} estu ${adj}${issue.minimum.toString()}`;
96
+ }
97
+ case "invalid_format": {
98
+ const _issue = issue as errors.$ZodStringFormatIssues;
99
+ if (_issue.format === "starts_with") return `Nevalida karaktraro: devas komenciĝi per "${_issue.prefix}"`;
100
+ if (_issue.format === "ends_with") return `Nevalida karaktraro: devas finiĝi per "${_issue.suffix}"`;
101
+ if (_issue.format === "includes") return `Nevalida karaktraro: devas inkluzivi "${_issue.includes}"`;
102
+ if (_issue.format === "regex") return `Nevalida karaktraro: devas kongrui kun la modelo ${_issue.pattern}`;
103
+ return `Nevalida ${Nouns[_issue.format] ?? issue.format}`;
104
+ }
105
+ case "not_multiple_of":
106
+ return `Nevalida nombro: devas esti oblo de ${issue.divisor}`;
107
+ case "unrecognized_keys":
108
+ return `Nekonata${issue.keys.length > 1 ? "j" : ""} ŝlosilo${issue.keys.length > 1 ? "j" : ""}: ${util.joinValues(issue.keys, ", ")}`;
109
+ case "invalid_key":
110
+ return `Nevalida ŝlosilo en ${issue.origin}`;
111
+ case "invalid_union":
112
+ return "Nevalida enigo";
113
+ case "invalid_element":
114
+ return `Nevalida valoro en ${issue.origin}`;
115
+ default:
116
+ return `Nevalida enigo`;
117
+ }
118
+ };
119
+ };
120
+
121
+ export default function (): { localeError: errors.$ZodErrorMap } {
122
+ return {
123
+ localeError: error(),
124
+ };
125
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/es.ts ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "caracteres", verb: "tener" },
8
+ file: { unit: "bytes", verb: "tener" },
9
+ array: { unit: "elementos", verb: "tener" },
10
+ set: { unit: "elementos", verb: "tener" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const parsedType = (data: any): string => {
18
+ const t = typeof data;
19
+
20
+ switch (t) {
21
+ case "number": {
22
+ return Number.isNaN(data) ? "NaN" : "número";
23
+ }
24
+ case "object": {
25
+ if (Array.isArray(data)) {
26
+ return "arreglo";
27
+ }
28
+ if (data === null) {
29
+ return "nulo";
30
+ }
31
+ if (Object.getPrototypeOf(data) !== Object.prototype) {
32
+ return data.constructor.name;
33
+ }
34
+ }
35
+ }
36
+ return t;
37
+ };
38
+
39
+ const Nouns: {
40
+ [k in $ZodStringFormats | (string & {})]?: string;
41
+ } = {
42
+ regex: "entrada",
43
+ email: "dirección de correo electrónico",
44
+ url: "URL",
45
+ emoji: "emoji",
46
+ uuid: "UUID",
47
+ uuidv4: "UUIDv4",
48
+ uuidv6: "UUIDv6",
49
+ nanoid: "nanoid",
50
+ guid: "GUID",
51
+ cuid: "cuid",
52
+ cuid2: "cuid2",
53
+ ulid: "ULID",
54
+ xid: "XID",
55
+ ksuid: "KSUID",
56
+ datetime: "fecha y hora ISO",
57
+ date: "fecha ISO",
58
+ time: "hora ISO",
59
+ duration: "duración ISO",
60
+ ipv4: "dirección IPv4",
61
+ ipv6: "dirección IPv6",
62
+ cidrv4: "rango IPv4",
63
+ cidrv6: "rango IPv6",
64
+ base64: "cadena codificada en base64",
65
+ base64url: "URL codificada en base64",
66
+ json_string: "cadena JSON",
67
+ e164: "número E.164",
68
+ jwt: "JWT",
69
+ template_literal: "entrada",
70
+ };
71
+
72
+ return (issue) => {
73
+ switch (issue.code) {
74
+ case "invalid_type":
75
+ return `Entrada inválida: se esperaba ${issue.expected}, recibido ${parsedType(issue.input)}`;
76
+ // return `Entrada inválida: se esperaba ${issue.expected}, recibido ${util.getParsedType(issue.input)}`;
77
+ case "invalid_value":
78
+ if (issue.values.length === 1)
79
+ return `Entrada inválida: se esperaba ${util.stringifyPrimitive(issue.values[0])}`;
80
+ return `Opción inválida: se esperaba una de ${util.joinValues(issue.values, "|")}`;
81
+ case "too_big": {
82
+ const adj = issue.inclusive ? "<=" : "<";
83
+ const sizing = getSizing(issue.origin);
84
+ if (sizing)
85
+ return `Demasiado grande: se esperaba que ${issue.origin ?? "valor"} tuviera ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementos"}`;
86
+ return `Demasiado grande: se esperaba que ${issue.origin ?? "valor"} fuera ${adj}${issue.maximum.toString()}`;
87
+ }
88
+ case "too_small": {
89
+ const adj = issue.inclusive ? ">=" : ">";
90
+ const sizing = getSizing(issue.origin);
91
+ if (sizing) {
92
+ return `Demasiado pequeño: se esperaba que ${issue.origin} tuviera ${adj}${issue.minimum.toString()} ${sizing.unit}`;
93
+ }
94
+
95
+ return `Demasiado pequeño: se esperaba que ${issue.origin} fuera ${adj}${issue.minimum.toString()}`;
96
+ }
97
+ case "invalid_format": {
98
+ const _issue = issue as errors.$ZodStringFormatIssues;
99
+ if (_issue.format === "starts_with") return `Cadena inválida: debe comenzar con "${_issue.prefix}"`;
100
+ if (_issue.format === "ends_with") return `Cadena inválida: debe terminar en "${_issue.suffix}"`;
101
+ if (_issue.format === "includes") return `Cadena inválida: debe incluir "${_issue.includes}"`;
102
+ if (_issue.format === "regex") return `Cadena inválida: debe coincidir con el patrón ${_issue.pattern}`;
103
+ return `Inválido ${Nouns[_issue.format] ?? issue.format}`;
104
+ }
105
+ case "not_multiple_of":
106
+ return `Número inválido: debe ser múltiplo de ${issue.divisor}`;
107
+ case "unrecognized_keys":
108
+ return `Llave${issue.keys.length > 1 ? "s" : ""} desconocida${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
109
+ case "invalid_key":
110
+ return `Llave inválida en ${issue.origin}`;
111
+ case "invalid_union":
112
+ return "Entrada inválida";
113
+ case "invalid_element":
114
+ return `Valor inválido en ${issue.origin}`;
115
+ default:
116
+ return `Entrada inválida`;
117
+ }
118
+ };
119
+ };
120
+
121
+ export default function (): { localeError: errors.$ZodErrorMap } {
122
+ return {
123
+ localeError: error(),
124
+ };
125
+ }
node_modules/@jimp/plugin-color/node_modules/zod/src/v4/locales/fa.ts ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "کاراکتر", verb: "داشته باشد" },
8
+ file: { unit: "بایت", verb: "داشته باشد" },
9
+ array: { unit: "آیتم", verb: "داشته باشد" },
10
+ set: { unit: "آیتم", verb: "داشته باشد" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const parsedType = (data: any): string => {
18
+ const t = typeof data;
19
+
20
+ switch (t) {
21
+ case "number": {
22
+ return Number.isNaN(data) ? "NaN" : "عدد";
23
+ }
24
+ case "object": {
25
+ if (Array.isArray(data)) {
26
+ return "آرایه";
27
+ }
28
+ if (data === null) {
29
+ return "null";
30
+ }
31
+
32
+ if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
33
+ return data.constructor.name;
34
+ }
35
+ }
36
+ }
37
+ return t;
38
+ };
39
+
40
+ const Nouns: {
41
+ [k in $ZodStringFormats | (string & {})]?: string;
42
+ } = {
43
+ regex: "ورودی",
44
+ email: "آدرس ایمیل",
45
+ url: "URL",
46
+ emoji: "ایموجی",
47
+ uuid: "UUID",
48
+ uuidv4: "UUIDv4",
49
+ uuidv6: "UUIDv6",
50
+ nanoid: "nanoid",
51
+ guid: "GUID",
52
+ cuid: "cuid",
53
+ cuid2: "cuid2",
54
+ ulid: "ULID",
55
+ xid: "XID",
56
+ ksuid: "KSUID",
57
+ datetime: "تاریخ و زمان ایزو",
58
+ date: "تاریخ ایزو",
59
+ time: "زمان ایزو",
60
+ duration: "مدت زمان ایزو",
61
+ ipv4: "IPv4 آدرس",
62
+ ipv6: "IPv6 آدرس",
63
+ cidrv4: "IPv4 دامنه",
64
+ cidrv6: "IPv6 دامنه",
65
+ base64: "base64-encoded رشته",
66
+ base64url: "base64url-encoded رشته",
67
+ json_string: "JSON رشته",
68
+ e164: "E.164 عدد",
69
+ jwt: "JWT",
70
+ template_literal: "ورودی",
71
+ };
72
+
73
+ return (issue) => {
74
+ switch (issue.code) {
75
+ case "invalid_type":
76
+ return `ورودی نامعتبر: می‌بایست ${issue.expected} می‌بود، ${parsedType(issue.input)} دریافت شد`;
77
+ case "invalid_value":
78
+ if (issue.values.length === 1) {
79
+ return `ورودی نامعتبر: می‌بایست ${util.stringifyPrimitive(issue.values[0])} می‌بود`;
80
+ }
81
+ return `گزینه نامعتبر: می‌بایست یکی از ${util.joinValues(issue.values, "|")} می‌بود`;
82
+ case "too_big": {
83
+ const adj = issue.inclusive ? "<=" : "<";
84
+ const sizing = getSizing(issue.origin);
85
+ if (sizing) {
86
+ return `خیلی بزرگ: ${issue.origin ?? "مقدار"} باید ${adj}${issue.maximum.toString()} ${sizing.unit ?? "عنصر"} باشد`;
87
+ }
88
+ return `خیلی بزرگ: ${issue.origin ?? "مقدار"} باید ${adj}${issue.maximum.toString()} باشد`;
89
+ }
90
+ case "too_small": {
91
+ const adj = issue.inclusive ? ">=" : ">";
92
+ const sizing = getSizing(issue.origin);
93
+ if (sizing) {
94
+ return `خیلی کوچک: ${issue.origin} باید ${adj}${issue.minimum.toString()} ${sizing.unit} باشد`;
95
+ }
96
+ return `خیلی کوچک: ${issue.origin} باید ${adj}${issue.minimum.toString()} باشد`;
97
+ }
98
+ case "invalid_format": {
99
+ const _issue = issue as errors.$ZodStringFormatIssues;
100
+ if (_issue.format === "starts_with") {
101
+ return `رشته نامعتبر: باید با "${_issue.prefix}" شروع شود`;
102
+ }
103
+ if (_issue.format === "ends_with") {
104
+ return `رشته نامعتبر: باید با "${_issue.suffix}" تمام شود`;
105
+ }
106
+ if (_issue.format === "includes") {
107
+ return `رشته نامعتبر: باید شامل "${_issue.includes}" باشد`;
108
+ }
109
+ if (_issue.format === "regex") {
110
+ return `رشته نامعتبر: باید با الگوی ${_issue.pattern} مطابقت داشته باشد`;
111
+ }
112
+ return `${Nouns[_issue.format] ?? issue.format} نامعتبر`;
113
+ }
114
+ case "not_multiple_of":
115
+ return `عدد نامعتبر: باید مضرب ${issue.divisor} باشد`;
116
+ case "unrecognized_keys":
117
+ return `کلید${issue.keys.length > 1 ? "های" : ""} ناشناس: ${util.joinValues(issue.keys, ", ")}`;
118
+ case "invalid_key":
119
+ return `کلید ناشناس در ${issue.origin}`;
120
+ case "invalid_union":
121
+ return `ورودی نامعتبر`;
122
+ case "invalid_element":
123
+ return `مقدار نامعتبر در ${issue.origin}`;
124
+ default:
125
+ return `ورودی نامعتبر`;
126
+ }
127
+ };
128
+ };
129
+
130
+ export default function (): { localeError: errors.$ZodErrorMap } {
131
+ return {
132
+ localeError: error(),
133
+ };
134
+ }