Leon4gr45 commited on
Commit
54dd3d0
·
verified ·
1 Parent(s): 68f823a

Upload folder using huggingface_hub (part 9)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/external.ts +6 -0
  2. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
  3. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
  4. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
  5. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
  6. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
  7. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/helpers/util.ts +224 -0
  8. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/index.ts +4 -0
  9. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/locales/en.ts +124 -0
  10. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/standard-schema.ts +113 -0
  11. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/Mocker.ts +54 -0
  12. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
  13. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
  14. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/array.test.ts +71 -0
  15. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
  16. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
  17. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/base.test.ts +29 -0
  18. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/bigint.test.ts +55 -0
  19. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/branded.test.ts +53 -0
  20. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/catch.test.ts +220 -0
  21. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/coerce.test.ts +133 -0
  22. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/complex.test.ts +56 -0
  23. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/custom.test.ts +31 -0
  24. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/date.test.ts +32 -0
  25. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
  26. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/default.test.ts +112 -0
  27. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/description.test.ts +33 -0
  28. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
  29. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/enum.test.ts +80 -0
  30. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/error.test.ts +551 -0
  31. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
  32. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
  33. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/function.test.ts +257 -0
  34. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/generics.test.ts +48 -0
  35. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
  36. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/intersection.test.ts +110 -0
  37. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/language-server.source.ts +76 -0
  38. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/language-server.test.ts +207 -0
  39. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/literal.test.ts +36 -0
  40. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/map.test.ts +110 -0
  41. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/masking.test.ts +4 -0
  42. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/mocker.test.ts +19 -0
  43. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/nan.test.ts +21 -0
  44. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/nativeEnum.test.ts +87 -0
  45. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/nullable.test.ts +42 -0
  46. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/number.test.ts +176 -0
  47. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/object-augmentation.test.ts +29 -0
  48. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
  49. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/object.test.ts +434 -0
  50. node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/optional.test.ts +42 -0
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/external.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ export * from "./errors.js";
2
+ export * from "./helpers/parseUtil.js";
3
+ export * from "./helpers/typeAliases.js";
4
+ export * from "./helpers/util.js";
5
+ export * from "./types.js";
6
+ export * from "./ZodError.js";
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/helpers/enumUtil.ts ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export namespace enumUtil {
2
+ type UnionToIntersectionFn<T> = (T extends unknown ? (k: () => T) => void : never) extends (
3
+ k: infer Intersection
4
+ ) => void
5
+ ? Intersection
6
+ : never;
7
+
8
+ type GetUnionLast<T> = UnionToIntersectionFn<T> extends () => infer Last ? Last : never;
9
+
10
+ type UnionToTuple<T, Tuple extends unknown[] = []> = [T] extends [never]
11
+ ? Tuple
12
+ : UnionToTuple<Exclude<T, GetUnionLast<T>>, [GetUnionLast<T>, ...Tuple]>;
13
+
14
+ type CastToStringTuple<T> = T extends [string, ...string[]] ? T : never;
15
+
16
+ export type UnionToTupleString<T> = CastToStringTuple<UnionToTuple<T>>;
17
+ }
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/helpers/errorUtil.ts ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ export namespace errorUtil {
2
+ export type ErrMessage = string | { message?: string | undefined };
3
+ export const errToObj = (message?: ErrMessage): { message?: string | undefined } =>
4
+ typeof message === "string" ? { message } : message || {};
5
+ // biome-ignore lint:
6
+ export const toString = (message?: ErrMessage): string | undefined =>
7
+ typeof message === "string" ? message : message?.message;
8
+ }
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/helpers/parseUtil.ts ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { IssueData, ZodErrorMap, ZodIssue } from "../ZodError.js";
2
+ import { getErrorMap } from "../errors.js";
3
+ import defaultErrorMap from "../locales/en.js";
4
+ import type { ZodParsedType } from "./util.js";
5
+
6
+ export const makeIssue = (params: {
7
+ data: any;
8
+ path: (string | number)[];
9
+ errorMaps: ZodErrorMap[];
10
+ issueData: IssueData;
11
+ }): ZodIssue => {
12
+ const { data, path, errorMaps, issueData } = params;
13
+ const fullPath = [...path, ...(issueData.path || [])];
14
+ const fullIssue = {
15
+ ...issueData,
16
+ path: fullPath,
17
+ };
18
+
19
+ if (issueData.message !== undefined) {
20
+ return {
21
+ ...issueData,
22
+ path: fullPath,
23
+ message: issueData.message,
24
+ };
25
+ }
26
+
27
+ let errorMessage = "";
28
+ const maps = errorMaps
29
+ .filter((m) => !!m)
30
+ .slice()
31
+ .reverse();
32
+ for (const map of maps) {
33
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
34
+ }
35
+
36
+ return {
37
+ ...issueData,
38
+ path: fullPath,
39
+ message: errorMessage,
40
+ };
41
+ };
42
+
43
+ export type ParseParams = {
44
+ path: (string | number)[];
45
+ errorMap: ZodErrorMap;
46
+ async: boolean;
47
+ };
48
+
49
+ export type ParsePathComponent = string | number;
50
+ export type ParsePath = ParsePathComponent[];
51
+ export const EMPTY_PATH: ParsePath = [];
52
+
53
+ export interface ParseContext {
54
+ readonly common: {
55
+ readonly issues: ZodIssue[];
56
+ readonly contextualErrorMap?: ZodErrorMap | undefined;
57
+ readonly async: boolean;
58
+ };
59
+ readonly path: ParsePath;
60
+ readonly schemaErrorMap?: ZodErrorMap | undefined;
61
+ readonly parent: ParseContext | null;
62
+ readonly data: any;
63
+ readonly parsedType: ZodParsedType;
64
+ }
65
+
66
+ export type ParseInput = {
67
+ data: any;
68
+ path: (string | number)[];
69
+ parent: ParseContext;
70
+ };
71
+
72
+ export function addIssueToContext(ctx: ParseContext, issueData: IssueData): void {
73
+ const overrideMap = getErrorMap();
74
+ const issue = makeIssue({
75
+ issueData: issueData,
76
+ data: ctx.data,
77
+ path: ctx.path,
78
+ errorMaps: [
79
+ ctx.common.contextualErrorMap, // contextual error map is first priority
80
+ ctx.schemaErrorMap, // then schema-bound map if available
81
+ overrideMap, // then global override map
82
+ overrideMap === defaultErrorMap ? undefined : defaultErrorMap, // then global default map
83
+ ].filter((x) => !!x),
84
+ });
85
+ ctx.common.issues.push(issue);
86
+ }
87
+
88
+ export type ObjectPair = {
89
+ key: SyncParseReturnType<any>;
90
+ value: SyncParseReturnType<any>;
91
+ };
92
+ export class ParseStatus {
93
+ value: "aborted" | "dirty" | "valid" = "valid";
94
+ dirty(): void {
95
+ if (this.value === "valid") this.value = "dirty";
96
+ }
97
+ abort(): void {
98
+ if (this.value !== "aborted") this.value = "aborted";
99
+ }
100
+
101
+ static mergeArray(status: ParseStatus, results: SyncParseReturnType<any>[]): SyncParseReturnType {
102
+ const arrayValue: any[] = [];
103
+ for (const s of results) {
104
+ if (s.status === "aborted") return INVALID;
105
+ if (s.status === "dirty") status.dirty();
106
+ arrayValue.push(s.value);
107
+ }
108
+
109
+ return { status: status.value, value: arrayValue };
110
+ }
111
+
112
+ static async mergeObjectAsync(
113
+ status: ParseStatus,
114
+ pairs: { key: ParseReturnType<any>; value: ParseReturnType<any> }[]
115
+ ): Promise<SyncParseReturnType<any>> {
116
+ const syncPairs: ObjectPair[] = [];
117
+ for (const pair of pairs) {
118
+ const key = await pair.key;
119
+ const value = await pair.value;
120
+ syncPairs.push({
121
+ key,
122
+ value,
123
+ });
124
+ }
125
+ return ParseStatus.mergeObjectSync(status, syncPairs);
126
+ }
127
+
128
+ static mergeObjectSync(
129
+ status: ParseStatus,
130
+ pairs: {
131
+ key: SyncParseReturnType<any>;
132
+ value: SyncParseReturnType<any>;
133
+ alwaysSet?: boolean;
134
+ }[]
135
+ ): SyncParseReturnType {
136
+ const finalObject: any = {};
137
+ for (const pair of pairs) {
138
+ const { key, value } = pair;
139
+ if (key.status === "aborted") return INVALID;
140
+ if (value.status === "aborted") return INVALID;
141
+ if (key.status === "dirty") status.dirty();
142
+ if (value.status === "dirty") status.dirty();
143
+
144
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
145
+ finalObject[key.value] = value.value;
146
+ }
147
+ }
148
+
149
+ return { status: status.value, value: finalObject };
150
+ }
151
+ }
152
+ export interface ParseResult {
153
+ status: "aborted" | "dirty" | "valid";
154
+ data: any;
155
+ }
156
+
157
+ export type INVALID = { status: "aborted" };
158
+ export const INVALID: INVALID = Object.freeze({
159
+ status: "aborted",
160
+ });
161
+
162
+ export type DIRTY<T> = { status: "dirty"; value: T };
163
+ export const DIRTY = <T>(value: T): DIRTY<T> => ({ status: "dirty", value });
164
+
165
+ export type OK<T> = { status: "valid"; value: T };
166
+ export const OK = <T>(value: T): OK<T> => ({ status: "valid", value });
167
+
168
+ export type SyncParseReturnType<T = any> = OK<T> | DIRTY<T> | INVALID;
169
+ export type AsyncParseReturnType<T> = Promise<SyncParseReturnType<T>>;
170
+ export type ParseReturnType<T> = SyncParseReturnType<T> | AsyncParseReturnType<T>;
171
+
172
+ export const isAborted = (x: ParseReturnType<any>): x is INVALID => (x as any).status === "aborted";
173
+ export const isDirty = <T>(x: ParseReturnType<T>): x is OK<T> | DIRTY<T> => (x as any).status === "dirty";
174
+ export const isValid = <T>(x: ParseReturnType<T>): x is OK<T> => (x as any).status === "valid";
175
+ export const isAsync = <T>(x: ParseReturnType<T>): x is AsyncParseReturnType<T> =>
176
+ typeof Promise !== "undefined" && x instanceof Promise;
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/helpers/partialUtil.ts ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {
2
+ ZodArray,
3
+ ZodNullable,
4
+ ZodObject,
5
+ ZodOptional,
6
+ ZodRawShape,
7
+ ZodTuple,
8
+ ZodTupleItems,
9
+ ZodTypeAny,
10
+ } from "../types.js";
11
+
12
+ export namespace partialUtil {
13
+ export type DeepPartial<T extends ZodTypeAny> = T extends ZodObject<ZodRawShape>
14
+ ? ZodObject<
15
+ { [k in keyof T["shape"]]: ZodOptional<DeepPartial<T["shape"][k]>> },
16
+ T["_def"]["unknownKeys"],
17
+ T["_def"]["catchall"]
18
+ >
19
+ : T extends ZodArray<infer Type, infer Card>
20
+ ? ZodArray<DeepPartial<Type>, Card>
21
+ : T extends ZodOptional<infer Type>
22
+ ? ZodOptional<DeepPartial<Type>>
23
+ : T extends ZodNullable<infer Type>
24
+ ? ZodNullable<DeepPartial<Type>>
25
+ : T extends ZodTuple<infer Items>
26
+ ? {
27
+ [k in keyof Items]: Items[k] extends ZodTypeAny ? DeepPartial<Items[k]> : never;
28
+ } extends infer PI
29
+ ? PI extends ZodTupleItems
30
+ ? ZodTuple<PI>
31
+ : never
32
+ : never
33
+ : T;
34
+ }
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/helpers/typeAliases.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ export type Primitive = string | number | symbol | bigint | boolean | null | undefined;
2
+ export type Scalars = Primitive | Primitive[];
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/helpers/util.ts ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export namespace util {
2
+ type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
3
+
4
+ export type isAny<T> = 0 extends 1 & T ? true : false;
5
+ export const assertEqual = <A, B>(_: AssertEqual<A, B>): void => {};
6
+ export function assertIs<T>(_arg: T): void {}
7
+ export function assertNever(_x: never): never {
8
+ throw new Error();
9
+ }
10
+
11
+ export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
12
+ export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
13
+ export type MakePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
14
+ export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
15
+ export type InexactPartial<T> = { [k in keyof T]?: T[k] | undefined };
16
+ export const arrayToEnum = <T extends string, U extends [T, ...T[]]>(items: U): { [k in U[number]]: k } => {
17
+ const obj: any = {};
18
+ for (const item of items) {
19
+ obj[item] = item;
20
+ }
21
+ return obj;
22
+ };
23
+
24
+ export const getValidEnumValues = (obj: any): any[] => {
25
+ const validKeys = objectKeys(obj).filter((k: any) => typeof obj[obj[k]] !== "number");
26
+ const filtered: any = {};
27
+ for (const k of validKeys) {
28
+ filtered[k] = obj[k];
29
+ }
30
+ return objectValues(filtered);
31
+ };
32
+
33
+ export const objectValues = (obj: any): any[] => {
34
+ return objectKeys(obj).map(function (e) {
35
+ return obj[e];
36
+ });
37
+ };
38
+
39
+ export const objectKeys: ObjectConstructor["keys"] =
40
+ typeof Object.keys === "function" // eslint-disable-line ban/ban
41
+ ? (obj: any) => Object.keys(obj) // eslint-disable-line ban/ban
42
+ : (object: any) => {
43
+ const keys = [];
44
+ for (const key in object) {
45
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
46
+ keys.push(key);
47
+ }
48
+ }
49
+ return keys;
50
+ };
51
+
52
+ export const find = <T>(arr: T[], checker: (arg: T) => any): T | undefined => {
53
+ for (const item of arr) {
54
+ if (checker(item)) return item;
55
+ }
56
+ return undefined;
57
+ };
58
+
59
+ export type identity<T> = objectUtil.identity<T>;
60
+ export type flatten<T> = objectUtil.flatten<T>;
61
+
62
+ export type noUndefined<T> = T extends undefined ? never : T;
63
+
64
+ export const isInteger: NumberConstructor["isInteger"] =
65
+ typeof Number.isInteger === "function"
66
+ ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
67
+ : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
68
+
69
+ export function joinValues<T extends any[]>(array: T, separator = " | "): string {
70
+ return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
71
+ }
72
+
73
+ export const jsonStringifyReplacer = (_: string, value: any): any => {
74
+ if (typeof value === "bigint") {
75
+ return value.toString();
76
+ }
77
+ return value;
78
+ };
79
+ }
80
+
81
+ export namespace objectUtil {
82
+ export type MergeShapes<U, V> =
83
+ // fast path when there is no keys overlap
84
+ keyof U & keyof V extends never
85
+ ? U & V
86
+ : {
87
+ [k in Exclude<keyof U, keyof V>]: U[k];
88
+ } & V;
89
+
90
+ type optionalKeys<T extends object> = {
91
+ [k in keyof T]: undefined extends T[k] ? k : never;
92
+ }[keyof T];
93
+ type requiredKeys<T extends object> = {
94
+ [k in keyof T]: undefined extends T[k] ? never : k;
95
+ }[keyof T];
96
+ export type addQuestionMarks<T extends object, _O = any> = {
97
+ [K in requiredKeys<T>]: T[K];
98
+ } & {
99
+ [K in optionalKeys<T>]?: T[K];
100
+ } & { [k in keyof T]?: unknown };
101
+
102
+ export type identity<T> = T;
103
+ export type flatten<T> = identity<{ [k in keyof T]: T[k] }>;
104
+
105
+ export type noNeverKeys<T> = {
106
+ [k in keyof T]: [T[k]] extends [never] ? never : k;
107
+ }[keyof T];
108
+
109
+ export type noNever<T> = identity<{
110
+ [k in noNeverKeys<T>]: k extends keyof T ? T[k] : never;
111
+ }>;
112
+
113
+ export const mergeShapes = <U, T>(first: U, second: T): T & U => {
114
+ return {
115
+ ...first,
116
+ ...second, // second overwrites first
117
+ };
118
+ };
119
+
120
+ export type extendShape<A extends object, B extends object> = keyof A & keyof B extends never // fast path when there is no keys overlap
121
+ ? A & B
122
+ : {
123
+ [K in keyof A as K extends keyof B ? never : K]: A[K];
124
+ } & {
125
+ [K in keyof B]: B[K];
126
+ };
127
+ }
128
+
129
+ export const ZodParsedType: {
130
+ string: "string";
131
+ nan: "nan";
132
+ number: "number";
133
+ integer: "integer";
134
+ float: "float";
135
+ boolean: "boolean";
136
+ date: "date";
137
+ bigint: "bigint";
138
+ symbol: "symbol";
139
+ function: "function";
140
+ undefined: "undefined";
141
+ null: "null";
142
+ array: "array";
143
+ object: "object";
144
+ unknown: "unknown";
145
+ promise: "promise";
146
+ void: "void";
147
+ never: "never";
148
+ map: "map";
149
+ set: "set";
150
+ } = util.arrayToEnum([
151
+ "string",
152
+ "nan",
153
+ "number",
154
+ "integer",
155
+ "float",
156
+ "boolean",
157
+ "date",
158
+ "bigint",
159
+ "symbol",
160
+ "function",
161
+ "undefined",
162
+ "null",
163
+ "array",
164
+ "object",
165
+ "unknown",
166
+ "promise",
167
+ "void",
168
+ "never",
169
+ "map",
170
+ "set",
171
+ ]);
172
+
173
+ export type ZodParsedType = keyof typeof ZodParsedType;
174
+
175
+ export const getParsedType = (data: any): ZodParsedType => {
176
+ const t = typeof data;
177
+
178
+ switch (t) {
179
+ case "undefined":
180
+ return ZodParsedType.undefined;
181
+
182
+ case "string":
183
+ return ZodParsedType.string;
184
+
185
+ case "number":
186
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
187
+
188
+ case "boolean":
189
+ return ZodParsedType.boolean;
190
+
191
+ case "function":
192
+ return ZodParsedType.function;
193
+
194
+ case "bigint":
195
+ return ZodParsedType.bigint;
196
+
197
+ case "symbol":
198
+ return ZodParsedType.symbol;
199
+
200
+ case "object":
201
+ if (Array.isArray(data)) {
202
+ return ZodParsedType.array;
203
+ }
204
+ if (data === null) {
205
+ return ZodParsedType.null;
206
+ }
207
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
208
+ return ZodParsedType.promise;
209
+ }
210
+ if (typeof Map !== "undefined" && data instanceof Map) {
211
+ return ZodParsedType.map;
212
+ }
213
+ if (typeof Set !== "undefined" && data instanceof Set) {
214
+ return ZodParsedType.set;
215
+ }
216
+ if (typeof Date !== "undefined" && data instanceof Date) {
217
+ return ZodParsedType.date;
218
+ }
219
+ return ZodParsedType.object;
220
+
221
+ default:
222
+ return ZodParsedType.unknown;
223
+ }
224
+ };
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/index.ts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import * as z from "./external.js";
2
+ export * from "./external.js";
3
+ export { z };
4
+ export default z;
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/locales/en.ts ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { type ZodErrorMap, ZodIssueCode } from "../ZodError.js";
2
+ import { util, ZodParsedType } from "../helpers/util.js";
3
+
4
+ const errorMap: ZodErrorMap = (issue, _ctx) => {
5
+ let message: string;
6
+ switch (issue.code) {
7
+ case ZodIssueCode.invalid_type:
8
+ if (issue.received === ZodParsedType.undefined) {
9
+ message = "Required";
10
+ } else {
11
+ message = `Expected ${issue.expected}, received ${issue.received}`;
12
+ }
13
+ break;
14
+ case ZodIssueCode.invalid_literal:
15
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
16
+ break;
17
+ case ZodIssueCode.unrecognized_keys:
18
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
19
+ break;
20
+ case ZodIssueCode.invalid_union:
21
+ message = `Invalid input`;
22
+ break;
23
+ case ZodIssueCode.invalid_union_discriminator:
24
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
25
+ break;
26
+ case ZodIssueCode.invalid_enum_value:
27
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
28
+ break;
29
+ case ZodIssueCode.invalid_arguments:
30
+ message = `Invalid function arguments`;
31
+ break;
32
+ case ZodIssueCode.invalid_return_type:
33
+ message = `Invalid function return type`;
34
+ break;
35
+ case ZodIssueCode.invalid_date:
36
+ message = `Invalid date`;
37
+ break;
38
+ case ZodIssueCode.invalid_string:
39
+ if (typeof issue.validation === "object") {
40
+ if ("includes" in issue.validation) {
41
+ message = `Invalid input: must include "${issue.validation.includes}"`;
42
+
43
+ if (typeof issue.validation.position === "number") {
44
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
45
+ }
46
+ } else if ("startsWith" in issue.validation) {
47
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
48
+ } else if ("endsWith" in issue.validation) {
49
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
50
+ } else {
51
+ util.assertNever(issue.validation);
52
+ }
53
+ } else if (issue.validation !== "regex") {
54
+ message = `Invalid ${issue.validation}`;
55
+ } else {
56
+ message = "Invalid";
57
+ }
58
+ break;
59
+ case ZodIssueCode.too_small:
60
+ if (issue.type === "array")
61
+ message = `Array must contain ${
62
+ issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`
63
+ } ${issue.minimum} element(s)`;
64
+ else if (issue.type === "string")
65
+ message = `String must contain ${
66
+ issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`
67
+ } ${issue.minimum} character(s)`;
68
+ else if (issue.type === "number")
69
+ message = `Number must be ${
70
+ issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `
71
+ }${issue.minimum}`;
72
+ else if (issue.type === "bigint")
73
+ message = `Number must be ${
74
+ issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `
75
+ }${issue.minimum}`;
76
+ else if (issue.type === "date")
77
+ message = `Date must be ${
78
+ issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `
79
+ }${new Date(Number(issue.minimum))}`;
80
+ else message = "Invalid input";
81
+ break;
82
+ case ZodIssueCode.too_big:
83
+ if (issue.type === "array")
84
+ message = `Array must contain ${
85
+ issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`
86
+ } ${issue.maximum} element(s)`;
87
+ else if (issue.type === "string")
88
+ message = `String must contain ${
89
+ issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`
90
+ } ${issue.maximum} character(s)`;
91
+ else if (issue.type === "number")
92
+ message = `Number must be ${
93
+ issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`
94
+ } ${issue.maximum}`;
95
+ else if (issue.type === "bigint")
96
+ message = `BigInt must be ${
97
+ issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`
98
+ } ${issue.maximum}`;
99
+ else if (issue.type === "date")
100
+ message = `Date must be ${
101
+ issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`
102
+ } ${new Date(Number(issue.maximum))}`;
103
+ else message = "Invalid input";
104
+ break;
105
+ case ZodIssueCode.custom:
106
+ message = `Invalid input`;
107
+ break;
108
+ case ZodIssueCode.invalid_intersection_types:
109
+ message = `Intersection results could not be merged`;
110
+ break;
111
+ case ZodIssueCode.not_multiple_of:
112
+ message = `Number must be a multiple of ${issue.multipleOf}`;
113
+ break;
114
+ case ZodIssueCode.not_finite:
115
+ message = "Number must be finite";
116
+ break;
117
+ default:
118
+ message = _ctx.defaultError;
119
+ util.assertNever(issue);
120
+ }
121
+ return { message };
122
+ };
123
+
124
+ export default errorMap;
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/standard-schema.ts ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * The Standard Schema interface.
3
+ */
4
+ export type StandardSchemaV1<Input = unknown, Output = Input> = {
5
+ /**
6
+ * The Standard Schema properties.
7
+ */
8
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
9
+ };
10
+
11
+ export declare namespace StandardSchemaV1 {
12
+ /**
13
+ * The Standard Schema properties interface.
14
+ */
15
+ export interface Props<Input = unknown, Output = Input> {
16
+ /**
17
+ * The version number of the standard.
18
+ */
19
+ readonly version: 1;
20
+ /**
21
+ * The vendor name of the schema library.
22
+ */
23
+ readonly vendor: string;
24
+ /**
25
+ * Validates unknown input values.
26
+ */
27
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
28
+ /**
29
+ * Inferred types associated with the schema.
30
+ */
31
+ readonly types?: Types<Input, Output> | undefined;
32
+ }
33
+
34
+ /**
35
+ * The result interface of the validate function.
36
+ */
37
+ export type Result<Output> = SuccessResult<Output> | FailureResult;
38
+
39
+ /**
40
+ * The result interface if validation succeeds.
41
+ */
42
+ export interface SuccessResult<Output> {
43
+ /**
44
+ * The typed output value.
45
+ */
46
+ readonly value: Output;
47
+ /**
48
+ * The non-existent issues.
49
+ */
50
+ readonly issues?: undefined;
51
+ }
52
+
53
+ /**
54
+ * The result interface if validation fails.
55
+ */
56
+ export interface FailureResult {
57
+ /**
58
+ * The issues of failed validation.
59
+ */
60
+ readonly issues: ReadonlyArray<Issue>;
61
+ }
62
+
63
+ /**
64
+ * The issue interface of the failure output.
65
+ */
66
+ export interface Issue {
67
+ /**
68
+ * The error message of the issue.
69
+ */
70
+ readonly message: string;
71
+ /**
72
+ * The path of the issue, if any.
73
+ */
74
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
75
+ }
76
+
77
+ /**
78
+ * The path segment interface of the issue.
79
+ */
80
+ export interface PathSegment {
81
+ /**
82
+ * The key representing a path segment.
83
+ */
84
+ readonly key: PropertyKey;
85
+ }
86
+
87
+ /**
88
+ * The Standard Schema types interface.
89
+ */
90
+ export interface Types<Input = unknown, Output = Input> {
91
+ /**
92
+ * The input type of the schema.
93
+ */
94
+ readonly input: Input;
95
+ /**
96
+ * The output type of the schema.
97
+ */
98
+ readonly output: Output;
99
+ }
100
+
101
+ /**
102
+ * Infers the input type of a Standard Schema.
103
+ */
104
+ export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
105
+
106
+ /**
107
+ * Infers the output type of a Standard Schema.
108
+ */
109
+ export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
110
+
111
+ // biome-ignore lint/complexity/noUselessEmptyExport: needed for granular visibility control of TS namespace
112
+ export {};
113
+ }
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/Mocker.ts ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function getRandomInt(max: number) {
2
+ return Math.floor(Math.random() * Math.floor(max));
3
+ }
4
+
5
+ const testSymbol = Symbol("test");
6
+
7
+ export class Mocker {
8
+ pick = (...args: any[]): any => {
9
+ return args[getRandomInt(args.length)];
10
+ };
11
+
12
+ get string(): string {
13
+ return Math.random().toString(36).substring(7);
14
+ }
15
+ get number(): number {
16
+ return Math.random() * 100;
17
+ }
18
+ get bigint(): bigint {
19
+ return BigInt(Math.floor(Math.random() * 10000));
20
+ }
21
+ get boolean(): boolean {
22
+ return Math.random() < 0.5;
23
+ }
24
+ get date(): Date {
25
+ return new Date(Math.floor(Date.now() * Math.random()));
26
+ }
27
+ get symbol(): symbol {
28
+ return testSymbol;
29
+ }
30
+ get null(): null {
31
+ return null;
32
+ }
33
+ get undefined(): undefined {
34
+ return undefined;
35
+ }
36
+ get stringOptional(): string | undefined {
37
+ return this.pick(this.string, this.undefined);
38
+ }
39
+ get stringNullable(): string | null {
40
+ return this.pick(this.string, this.null);
41
+ }
42
+ get numberOptional(): number | undefined {
43
+ return this.pick(this.number, this.undefined);
44
+ }
45
+ get numberNullable(): number | null {
46
+ return this.pick(this.number, this.null);
47
+ }
48
+ get booleanOptional(): boolean | undefined {
49
+ return this.pick(this.boolean, this.undefined);
50
+ }
51
+ get booleanNullable(): boolean | null {
52
+ return this.pick(this.boolean, this.null);
53
+ }
54
+ }
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/all-errors.test.ts ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ const Test = z.object({
8
+ f1: z.number(),
9
+ f2: z.string().optional(),
10
+ f3: z.string().nullable(),
11
+ f4: z.array(z.object({ t: z.union([z.string(), z.boolean()]) })),
12
+ });
13
+ type TestFlattenedErrors = z.inferFlattenedErrors<typeof Test, { message: string; code: number }>;
14
+ type TestFormErrors = z.inferFlattenedErrors<typeof Test>;
15
+
16
+ test("default flattened errors type inference", () => {
17
+ type TestTypeErrors = {
18
+ formErrors: string[];
19
+ fieldErrors: { [P in keyof z.TypeOf<typeof Test>]?: string[] | undefined };
20
+ };
21
+
22
+ util.assertEqual<z.inferFlattenedErrors<typeof Test>, TestTypeErrors>(true);
23
+ util.assertEqual<z.inferFlattenedErrors<typeof Test, { message: string }>, TestTypeErrors>(false);
24
+ });
25
+
26
+ test("custom flattened errors type inference", () => {
27
+ type ErrorType = { message: string; code: number };
28
+ type TestTypeErrors = {
29
+ formErrors: ErrorType[];
30
+ fieldErrors: {
31
+ [P in keyof z.TypeOf<typeof Test>]?: ErrorType[] | undefined;
32
+ };
33
+ };
34
+
35
+ util.assertEqual<z.inferFlattenedErrors<typeof Test>, TestTypeErrors>(false);
36
+ util.assertEqual<z.inferFlattenedErrors<typeof Test, { message: string; code: number }>, TestTypeErrors>(true);
37
+ util.assertEqual<z.inferFlattenedErrors<typeof Test, { message: string }>, TestTypeErrors>(false);
38
+ });
39
+
40
+ test("form errors type inference", () => {
41
+ type TestTypeErrors = {
42
+ formErrors: string[];
43
+ fieldErrors: { [P in keyof z.TypeOf<typeof Test>]?: string[] | undefined };
44
+ };
45
+
46
+ util.assertEqual<z.inferFlattenedErrors<typeof Test>, TestTypeErrors>(true);
47
+ });
48
+
49
+ test(".flatten() type assertion", () => {
50
+ const parsed = Test.safeParse({}) as z.SafeParseError<void>;
51
+ const validFlattenedErrors: TestFlattenedErrors = parsed.error.flatten(() => ({ message: "", code: 0 }));
52
+ // @ts-expect-error should fail assertion between `TestFlattenedErrors` and unmapped `flatten()`.
53
+ const invalidFlattenedErrors: TestFlattenedErrors = parsed.error.flatten();
54
+ const validFormErrors: TestFormErrors = parsed.error.flatten();
55
+ // @ts-expect-error should fail assertion between `TestFormErrors` and mapped `flatten()`.
56
+ const invalidFormErrors: TestFormErrors = parsed.error.flatten(() => ({
57
+ message: "string",
58
+ code: 0,
59
+ }));
60
+
61
+ [validFlattenedErrors, invalidFlattenedErrors, validFormErrors, invalidFormErrors];
62
+ });
63
+
64
+ test(".formErrors type assertion", () => {
65
+ const parsed = Test.safeParse({}) as z.SafeParseError<void>;
66
+ const validFormErrors: TestFormErrors = parsed.error.formErrors;
67
+ // @ts-expect-error should fail assertion between `TestFlattenedErrors` and `.formErrors`.
68
+ const invalidFlattenedErrors: TestFlattenedErrors = parsed.error.formErrors;
69
+
70
+ [validFormErrors, invalidFlattenedErrors];
71
+ });
72
+
73
+ test("all errors", () => {
74
+ const propertySchema = z.string();
75
+ const schema = z
76
+ .object({
77
+ a: propertySchema,
78
+ b: propertySchema,
79
+ })
80
+ .refine(
81
+ (val) => {
82
+ return val.a === val.b;
83
+ },
84
+ { message: "Must be equal" }
85
+ );
86
+
87
+ try {
88
+ schema.parse({
89
+ a: "asdf",
90
+ b: "qwer",
91
+ });
92
+ } catch (error) {
93
+ if (error instanceof z.ZodError) {
94
+ expect(error.flatten()).toEqual({
95
+ formErrors: ["Must be equal"],
96
+ fieldErrors: {},
97
+ });
98
+ }
99
+ }
100
+
101
+ try {
102
+ schema.parse({
103
+ a: null,
104
+ b: null,
105
+ });
106
+ } catch (_error) {
107
+ const error = _error as z.ZodError;
108
+ expect(error.flatten()).toEqual({
109
+ formErrors: [],
110
+ fieldErrors: {
111
+ a: ["Expected string, received null"],
112
+ b: ["Expected string, received null"],
113
+ },
114
+ });
115
+
116
+ expect(error.flatten((iss) => iss.message.toUpperCase())).toEqual({
117
+ formErrors: [],
118
+ fieldErrors: {
119
+ a: ["EXPECTED STRING, RECEIVED NULL"],
120
+ b: ["EXPECTED STRING, RECEIVED NULL"],
121
+ },
122
+ });
123
+ // Test identity
124
+
125
+ expect(error.flatten((i: z.ZodIssue) => i)).toEqual({
126
+ formErrors: [],
127
+ fieldErrors: {
128
+ a: [
129
+ {
130
+ code: "invalid_type",
131
+ expected: "string",
132
+ message: "Expected string, received null",
133
+ path: ["a"],
134
+ received: "null",
135
+ },
136
+ ],
137
+ b: [
138
+ {
139
+ code: "invalid_type",
140
+ expected: "string",
141
+ message: "Expected string, received null",
142
+ path: ["b"],
143
+ received: "null",
144
+ },
145
+ ],
146
+ },
147
+ });
148
+ // Test mapping
149
+ expect(error.flatten((i: z.ZodIssue) => i.message.length)).toEqual({
150
+ formErrors: [],
151
+ fieldErrors: {
152
+ a: ["Expected string, received null".length],
153
+ b: ["Expected string, received null".length],
154
+ },
155
+ });
156
+ }
157
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/anyunknown.test.ts ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ test("check any inference", () => {
8
+ const t1 = z.any();
9
+ t1.optional();
10
+ t1.nullable();
11
+ type t1 = z.infer<typeof t1>;
12
+ util.assertEqual<t1, any>(true);
13
+ });
14
+
15
+ test("check unknown inference", () => {
16
+ const t1 = z.unknown();
17
+ t1.optional();
18
+ t1.nullable();
19
+ type t1 = z.infer<typeof t1>;
20
+ util.assertEqual<t1, unknown>(true);
21
+ });
22
+
23
+ test("check never inference", () => {
24
+ const t1 = z.never();
25
+ expect(() => t1.parse(undefined)).toThrow();
26
+ expect(() => t1.parse("asdf")).toThrow();
27
+ expect(() => t1.parse(null)).toThrow();
28
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/array.test.ts ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ const minTwo = z.string().array().min(2);
8
+ const maxTwo = z.string().array().max(2);
9
+ const justTwo = z.string().array().length(2);
10
+ const intNum = z.string().array().nonempty();
11
+ const nonEmptyMax = z.string().array().nonempty().max(2);
12
+
13
+ type t1 = z.infer<typeof nonEmptyMax>;
14
+ util.assertEqual<[string, ...string[]], t1>(true);
15
+
16
+ type t2 = z.infer<typeof minTwo>;
17
+ util.assertEqual<string[], t2>(true);
18
+
19
+ test("passing validations", () => {
20
+ minTwo.parse(["a", "a"]);
21
+ minTwo.parse(["a", "a", "a"]);
22
+ maxTwo.parse(["a", "a"]);
23
+ maxTwo.parse(["a"]);
24
+ justTwo.parse(["a", "a"]);
25
+ intNum.parse(["a"]);
26
+ nonEmptyMax.parse(["a"]);
27
+ });
28
+
29
+ test("failing validations", () => {
30
+ expect(() => minTwo.parse(["a"])).toThrow();
31
+ expect(() => maxTwo.parse(["a", "a", "a"])).toThrow();
32
+ expect(() => justTwo.parse(["a"])).toThrow();
33
+ expect(() => justTwo.parse(["a", "a", "a"])).toThrow();
34
+ expect(() => intNum.parse([])).toThrow();
35
+ expect(() => nonEmptyMax.parse([])).toThrow();
36
+ expect(() => nonEmptyMax.parse(["a", "a", "a"])).toThrow();
37
+ });
38
+
39
+ test("parse empty array in nonempty", () => {
40
+ expect(() =>
41
+ z
42
+ .array(z.string())
43
+ .nonempty()
44
+ .parse([] as any)
45
+ ).toThrow();
46
+ });
47
+
48
+ test("get element", () => {
49
+ justTwo.element.parse("asdf");
50
+ expect(() => justTwo.element.parse(12)).toThrow();
51
+ });
52
+
53
+ test("continue parsing despite array size error", () => {
54
+ const schema = z.object({
55
+ people: z.string().array().min(2),
56
+ });
57
+
58
+ const result = schema.safeParse({
59
+ people: [123],
60
+ });
61
+ expect(result.success).toEqual(false);
62
+ if (!result.success) {
63
+ expect(result.error.issues.length).toEqual(2);
64
+ }
65
+ });
66
+
67
+ test("parse should fail given sparse array", () => {
68
+ const schema = z.array(z.string()).nonempty().min(1).max(3);
69
+
70
+ expect(() => schema.parse(new Array(3))).toThrow();
71
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/async-parsing.test.ts ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ /// string
7
+ const stringSchema = z.string();
8
+
9
+ test("string async parse", async () => {
10
+ const goodData = "XXX";
11
+ const badData = 12;
12
+
13
+ const goodResult = await stringSchema.safeParseAsync(goodData);
14
+ expect(goodResult.success).toBe(true);
15
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
16
+
17
+ const badResult = await stringSchema.safeParseAsync(badData);
18
+ expect(badResult.success).toBe(false);
19
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
20
+ });
21
+
22
+ /// number
23
+ const numberSchema = z.number();
24
+ test("number async parse", async () => {
25
+ const goodData = 1234.2353;
26
+ const badData = "1234";
27
+
28
+ const goodResult = await numberSchema.safeParseAsync(goodData);
29
+ expect(goodResult.success).toBe(true);
30
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
31
+
32
+ const badResult = await numberSchema.safeParseAsync(badData);
33
+ expect(badResult.success).toBe(false);
34
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
35
+ });
36
+
37
+ /// bigInt
38
+ const bigIntSchema = z.bigint();
39
+ test("bigInt async parse", async () => {
40
+ const goodData = BigInt(145);
41
+ const badData = 134;
42
+
43
+ const goodResult = await bigIntSchema.safeParseAsync(goodData);
44
+ expect(goodResult.success).toBe(true);
45
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
46
+
47
+ const badResult = await bigIntSchema.safeParseAsync(badData);
48
+ expect(badResult.success).toBe(false);
49
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
50
+ });
51
+
52
+ /// boolean
53
+ const booleanSchema = z.boolean();
54
+ test("boolean async parse", async () => {
55
+ const goodData = true;
56
+ const badData = 1;
57
+
58
+ const goodResult = await booleanSchema.safeParseAsync(goodData);
59
+ expect(goodResult.success).toBe(true);
60
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
61
+
62
+ const badResult = await booleanSchema.safeParseAsync(badData);
63
+ expect(badResult.success).toBe(false);
64
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
65
+ });
66
+
67
+ /// date
68
+ const dateSchema = z.date();
69
+ test("date async parse", async () => {
70
+ const goodData = new Date();
71
+ const badData = new Date().toISOString();
72
+
73
+ const goodResult = await dateSchema.safeParseAsync(goodData);
74
+ expect(goodResult.success).toBe(true);
75
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
76
+
77
+ const badResult = await dateSchema.safeParseAsync(badData);
78
+ expect(badResult.success).toBe(false);
79
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
80
+ });
81
+
82
+ /// undefined
83
+ const undefinedSchema = z.undefined();
84
+ test("undefined async parse", async () => {
85
+ const goodData = undefined;
86
+ const badData = "XXX";
87
+
88
+ const goodResult = await undefinedSchema.safeParseAsync(goodData);
89
+ expect(goodResult.success).toBe(true);
90
+ if (goodResult.success) expect(goodResult.data).toEqual(undefined);
91
+
92
+ const badResult = await undefinedSchema.safeParseAsync(badData);
93
+ expect(badResult.success).toBe(false);
94
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
95
+ });
96
+
97
+ /// null
98
+ const nullSchema = z.null();
99
+ test("null async parse", async () => {
100
+ const goodData = null;
101
+ const badData = undefined;
102
+
103
+ const goodResult = await nullSchema.safeParseAsync(goodData);
104
+ expect(goodResult.success).toBe(true);
105
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
106
+
107
+ const badResult = await nullSchema.safeParseAsync(badData);
108
+ expect(badResult.success).toBe(false);
109
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
110
+ });
111
+
112
+ /// any
113
+ const anySchema = z.any();
114
+ test("any async parse", async () => {
115
+ const goodData = [{}];
116
+ // const badData = 'XXX';
117
+
118
+ const goodResult = await anySchema.safeParseAsync(goodData);
119
+ expect(goodResult.success).toBe(true);
120
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
121
+
122
+ // const badResult = await anySchema.safeParseAsync(badData);
123
+ // expect(badResult.success).toBe(false);
124
+ // if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
125
+ });
126
+
127
+ /// unknown
128
+ const unknownSchema = z.unknown();
129
+ test("unknown async parse", async () => {
130
+ const goodData = ["asdf", 124, () => {}];
131
+ // const badData = 'XXX';
132
+
133
+ const goodResult = await unknownSchema.safeParseAsync(goodData);
134
+ expect(goodResult.success).toBe(true);
135
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
136
+
137
+ // const badResult = await unknownSchema.safeParseAsync(badData);
138
+ // expect(badResult.success).toBe(false);
139
+ // if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
140
+ });
141
+
142
+ /// void
143
+ const voidSchema = z.void();
144
+ test("void async parse", async () => {
145
+ const goodData = undefined;
146
+ const badData = 0;
147
+
148
+ const goodResult = await voidSchema.safeParseAsync(goodData);
149
+ expect(goodResult.success).toBe(true);
150
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
151
+
152
+ const badResult = await voidSchema.safeParseAsync(badData);
153
+ expect(badResult.success).toBe(false);
154
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
155
+ });
156
+
157
+ /// array
158
+ const arraySchema = z.array(z.string());
159
+ test("array async parse", async () => {
160
+ const goodData = ["XXX"];
161
+ const badData = "XXX";
162
+
163
+ const goodResult = await arraySchema.safeParseAsync(goodData);
164
+ expect(goodResult.success).toBe(true);
165
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
166
+
167
+ const badResult = await arraySchema.safeParseAsync(badData);
168
+ expect(badResult.success).toBe(false);
169
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
170
+ });
171
+
172
+ /// object
173
+ const objectSchema = z.object({ string: z.string() });
174
+ test("object async parse", async () => {
175
+ const goodData = { string: "XXX" };
176
+ const badData = { string: 12 };
177
+
178
+ const goodResult = await objectSchema.safeParseAsync(goodData);
179
+ expect(goodResult.success).toBe(true);
180
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
181
+
182
+ const badResult = await objectSchema.safeParseAsync(badData);
183
+ expect(badResult.success).toBe(false);
184
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
185
+ });
186
+
187
+ /// union
188
+ const unionSchema = z.union([z.string(), z.undefined()]);
189
+ test("union async parse", async () => {
190
+ const goodData = undefined;
191
+ const badData = null;
192
+
193
+ const goodResult = await unionSchema.safeParseAsync(goodData);
194
+ expect(goodResult.success).toBe(true);
195
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
196
+
197
+ const badResult = await unionSchema.safeParseAsync(badData);
198
+ expect(badResult.success).toBe(false);
199
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
200
+ });
201
+
202
+ /// record
203
+ const recordSchema = z.record(z.object({}));
204
+ test("record async parse", async () => {
205
+ const goodData = { adsf: {}, asdf: {} };
206
+ const badData = [{}];
207
+
208
+ const goodResult = await recordSchema.safeParseAsync(goodData);
209
+ expect(goodResult.success).toBe(true);
210
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
211
+
212
+ const badResult = await recordSchema.safeParseAsync(badData);
213
+ expect(badResult.success).toBe(false);
214
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
215
+ });
216
+
217
+ /// function
218
+ const functionSchema = z.function();
219
+ test("function async parse", async () => {
220
+ const goodData = () => {};
221
+ const badData = "XXX";
222
+
223
+ const goodResult = await functionSchema.safeParseAsync(goodData);
224
+ expect(goodResult.success).toBe(true);
225
+ if (goodResult.success) expect(typeof goodResult.data).toEqual("function");
226
+
227
+ const badResult = await functionSchema.safeParseAsync(badData);
228
+ expect(badResult.success).toBe(false);
229
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
230
+ });
231
+
232
+ /// literal
233
+ const literalSchema = z.literal("asdf");
234
+ test("literal async parse", async () => {
235
+ const goodData = "asdf";
236
+ const badData = "asdff";
237
+
238
+ const goodResult = await literalSchema.safeParseAsync(goodData);
239
+ expect(goodResult.success).toBe(true);
240
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
241
+
242
+ const badResult = await literalSchema.safeParseAsync(badData);
243
+ expect(badResult.success).toBe(false);
244
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
245
+ });
246
+
247
+ /// enum
248
+ const enumSchema = z.enum(["fish", "whale"]);
249
+ test("enum async parse", async () => {
250
+ const goodData = "whale";
251
+ const badData = "leopard";
252
+
253
+ const goodResult = await enumSchema.safeParseAsync(goodData);
254
+ expect(goodResult.success).toBe(true);
255
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
256
+
257
+ const badResult = await enumSchema.safeParseAsync(badData);
258
+ expect(badResult.success).toBe(false);
259
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
260
+ });
261
+
262
+ /// nativeEnum
263
+ enum nativeEnumTest {
264
+ asdf = "qwer",
265
+ }
266
+ // @ts-ignore
267
+ const nativeEnumSchema = z.nativeEnum(nativeEnumTest);
268
+ test("nativeEnum async parse", async () => {
269
+ const goodData = nativeEnumTest.asdf;
270
+ const badData = "asdf";
271
+
272
+ const goodResult = await nativeEnumSchema.safeParseAsync(goodData);
273
+ expect(goodResult.success).toBe(true);
274
+ if (goodResult.success) expect(goodResult.data).toEqual(goodData);
275
+
276
+ const badResult = await nativeEnumSchema.safeParseAsync(badData);
277
+ expect(badResult.success).toBe(false);
278
+ if (!badResult.success) expect(badResult.error).toBeInstanceOf(z.ZodError);
279
+ });
280
+
281
+ /// promise
282
+ const promiseSchema = z.promise(z.number());
283
+ test("promise async parse good", async () => {
284
+ const goodData = Promise.resolve(123);
285
+
286
+ const goodResult = await promiseSchema.safeParseAsync(goodData);
287
+ expect(goodResult.success).toBe(true);
288
+ if (goodResult.success) {
289
+ expect(goodResult.data).toBeInstanceOf(Promise);
290
+ const data = await goodResult.data;
291
+ expect(data).toEqual(123);
292
+ // expect(goodResult.data).resolves.toEqual(124);
293
+ // return goodResult.data;
294
+ } else {
295
+ throw new Error("success should be true");
296
+ }
297
+ });
298
+
299
+ test("promise async parse bad", async () => {
300
+ const badData = Promise.resolve("XXX");
301
+ const badResult = await promiseSchema.safeParseAsync(badData);
302
+ expect(badResult.success).toBe(true);
303
+ if (badResult.success) {
304
+ await expect(badResult.data).rejects.toBeInstanceOf(z.ZodError);
305
+ } else {
306
+ throw new Error("success should be true");
307
+ }
308
+ });
309
+
310
+ test("async validation non-empty strings", async () => {
311
+ const base = z.object({
312
+ hello: z.string().refine((x) => x && x.length > 0),
313
+ foo: z.string().refine((x) => x && x.length > 0),
314
+ });
315
+
316
+ const testval = { hello: "", foo: "" };
317
+ const result1 = base.safeParse(testval);
318
+ const result2 = base.safeParseAsync(testval);
319
+
320
+ const r1 = result1;
321
+ await result2.then((r2) => {
322
+ if (r1.success === false && r2.success === false) expect(r1.error.issues.length).toBe(r2.error.issues.length); // <--- r1 has length 2, r2 has length 1
323
+ });
324
+ });
325
+
326
+ test("async validation multiple errors 1", async () => {
327
+ const base = z.object({
328
+ hello: z.string(),
329
+ foo: z.number(),
330
+ });
331
+
332
+ const testval = { hello: 3, foo: "hello" };
333
+ const result1 = base.safeParse(testval);
334
+ const result2 = base.safeParseAsync(testval);
335
+
336
+ const r1 = result1;
337
+ await result2.then((r2) => {
338
+ if (r1.success === false && r2.success === false) expect(r2.error.issues.length).toBe(r1.error.issues.length);
339
+ });
340
+ });
341
+
342
+ test("async validation multiple errors 2", async () => {
343
+ const base = (is_async?: boolean) =>
344
+ z.object({
345
+ hello: z.string(),
346
+ foo: z.object({
347
+ bar: z.number().refine(is_async ? async () => false : () => false),
348
+ }),
349
+ });
350
+
351
+ const testval = { hello: 3, foo: { bar: 4 } };
352
+ const result1 = base().safeParse(testval);
353
+ const result2 = base(true).safeParseAsync(testval);
354
+
355
+ const r1 = result1;
356
+ await result2.then((r2) => {
357
+ if (r1.success === false && r2.success === false) expect(r2.error.issues.length).toBe(r1.error.issues.length);
358
+ });
359
+ });
360
+
361
+ test("ensure early async failure prevents follow-up refinement checks", async () => {
362
+ let count = 0;
363
+ const base = z.object({
364
+ hello: z.string(),
365
+ foo: z
366
+ .number()
367
+ .refine(async () => {
368
+ count++;
369
+ return true;
370
+ })
371
+ .refine(async () => {
372
+ count++;
373
+ return true;
374
+ }, "Good"),
375
+ });
376
+
377
+ const testval = { hello: "bye", foo: 3 };
378
+ const result = await base.safeParseAsync(testval);
379
+ if (result.success === false) {
380
+ expect(result.error.issues.length).toBe(1);
381
+ expect(count).toBe(1);
382
+ }
383
+
384
+ // await result.then((r) => {
385
+ // if (r.success === false) expect(r.error.issues.length).toBe(1);
386
+ // expect(count).toBe(2);
387
+ // });
388
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/async-refinements.test.ts ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ test("parse async test", async () => {
7
+ const schema1 = z.string().refine(async (_val) => false);
8
+ expect(() => schema1.parse("asdf")).toThrow();
9
+
10
+ const schema2 = z.string().refine((_val) => Promise.resolve(true));
11
+ return await expect(() => schema2.parse("asdf")).toThrow();
12
+ });
13
+
14
+ test("parseAsync async test", async () => {
15
+ const schema1 = z.string().refine(async (_val) => true);
16
+ await schema1.parseAsync("asdf");
17
+
18
+ const schema2 = z.string().refine(async (_val) => false);
19
+ return await expect(schema2.parseAsync("asdf")).rejects.toBeDefined();
20
+ // expect(async () => await schema2.parseAsync('asdf')).toThrow();
21
+ });
22
+
23
+ test("parseAsync async test", async () => {
24
+ // expect.assertions(2);
25
+
26
+ const schema1 = z.string().refine((_val) => Promise.resolve(true));
27
+ const v1 = await schema1.parseAsync("asdf");
28
+ expect(v1).toEqual("asdf");
29
+
30
+ const schema2 = z.string().refine((_val) => Promise.resolve(false));
31
+ await expect(schema2.parseAsync("asdf")).rejects.toBeDefined();
32
+
33
+ const schema3 = z.string().refine((_val) => Promise.resolve(true));
34
+ await expect(schema3.parseAsync("asdf")).resolves.toEqual("asdf");
35
+ return await expect(schema3.parseAsync("qwer")).resolves.toEqual("qwer");
36
+ });
37
+
38
+ test("parseAsync async with value", async () => {
39
+ const schema1 = z.string().refine(async (val) => {
40
+ return val.length > 5;
41
+ });
42
+ await expect(schema1.parseAsync("asdf")).rejects.toBeDefined();
43
+
44
+ const v = await schema1.parseAsync("asdf123");
45
+ return await expect(v).toEqual("asdf123");
46
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/base.test.ts ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ test("type guard", () => {
8
+ const stringToNumber = z.string().transform((arg) => arg.length);
9
+
10
+ const s1 = z.object({
11
+ stringToNumber,
12
+ });
13
+ type t1 = z.input<typeof s1>;
14
+
15
+ const data = { stringToNumber: "asdf" };
16
+ const parsed = s1.safeParse(data);
17
+ if (parsed.success) {
18
+ util.assertEqual<typeof data, t1>(true);
19
+ }
20
+ });
21
+
22
+ test("test this binding", () => {
23
+ const callback = (predicate: (val: string) => boolean) => {
24
+ return predicate("hello");
25
+ };
26
+
27
+ expect(callback((value) => z.string().safeParse(value).success)).toBe(true); // true
28
+ expect(callback((value) => z.string().safeParse(value).success)).toBe(true); // true
29
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/bigint.test.ts ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ const gtFive = z.bigint().gt(BigInt(5));
7
+ const gteFive = z.bigint().gte(BigInt(5));
8
+ const ltFive = z.bigint().lt(BigInt(5));
9
+ const lteFive = z.bigint().lte(BigInt(5));
10
+ const positive = z.bigint().positive();
11
+ const negative = z.bigint().negative();
12
+ const nonnegative = z.bigint().nonnegative();
13
+ const nonpositive = z.bigint().nonpositive();
14
+ const multipleOfFive = z.bigint().multipleOf(BigInt(5));
15
+
16
+ test("passing validations", () => {
17
+ z.bigint().parse(BigInt(1));
18
+ z.bigint().parse(BigInt(0));
19
+ z.bigint().parse(BigInt(-1));
20
+ gtFive.parse(BigInt(6));
21
+ gteFive.parse(BigInt(5));
22
+ gteFive.parse(BigInt(6));
23
+ ltFive.parse(BigInt(4));
24
+ lteFive.parse(BigInt(5));
25
+ lteFive.parse(BigInt(4));
26
+ positive.parse(BigInt(3));
27
+ negative.parse(BigInt(-2));
28
+ nonnegative.parse(BigInt(0));
29
+ nonnegative.parse(BigInt(7));
30
+ nonpositive.parse(BigInt(0));
31
+ nonpositive.parse(BigInt(-12));
32
+ multipleOfFive.parse(BigInt(15));
33
+ });
34
+
35
+ test("failing validations", () => {
36
+ expect(() => gtFive.parse(BigInt(5))).toThrow();
37
+ expect(() => gteFive.parse(BigInt(4))).toThrow();
38
+ expect(() => ltFive.parse(BigInt(5))).toThrow();
39
+ expect(() => lteFive.parse(BigInt(6))).toThrow();
40
+ expect(() => positive.parse(BigInt(0))).toThrow();
41
+ expect(() => positive.parse(BigInt(-2))).toThrow();
42
+ expect(() => negative.parse(BigInt(0))).toThrow();
43
+ expect(() => negative.parse(BigInt(3))).toThrow();
44
+ expect(() => nonnegative.parse(BigInt(-1))).toThrow();
45
+ expect(() => nonpositive.parse(BigInt(1))).toThrow();
46
+ expect(() => multipleOfFive.parse(BigInt(13))).toThrow();
47
+ });
48
+
49
+ test("min max getters", () => {
50
+ expect(z.bigint().min(BigInt(5)).minValue).toEqual(BigInt(5));
51
+ expect(z.bigint().min(BigInt(5)).min(BigInt(10)).minValue).toEqual(BigInt(10));
52
+
53
+ expect(z.bigint().max(BigInt(5)).maxValue).toEqual(BigInt(5));
54
+ expect(z.bigint().max(BigInt(5)).max(BigInt(1)).maxValue).toEqual(BigInt(1));
55
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/branded.test.ts ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ test("branded types", () => {
8
+ const mySchema = z
9
+ .object({
10
+ name: z.string(),
11
+ })
12
+ .brand<"superschema">();
13
+
14
+ // simple branding
15
+ type MySchema = z.infer<typeof mySchema>;
16
+ util.assertEqual<MySchema, { name: string } & { [z.BRAND]: { superschema: true } }>(true);
17
+
18
+ const doStuff = (arg: MySchema) => arg;
19
+ doStuff(mySchema.parse({ name: "hello there" }));
20
+
21
+ // inheritance
22
+ const extendedSchema = mySchema.brand<"subschema">();
23
+ type ExtendedSchema = z.infer<typeof extendedSchema>;
24
+ util.assertEqual<ExtendedSchema, { name: string } & z.BRAND<"superschema"> & z.BRAND<"subschema">>(true);
25
+
26
+ doStuff(extendedSchema.parse({ name: "hello again" }));
27
+
28
+ // number branding
29
+ const numberSchema = z.number().brand<42>();
30
+ type NumberSchema = z.infer<typeof numberSchema>;
31
+ util.assertEqual<NumberSchema, number & { [z.BRAND]: { 42: true } }>(true);
32
+
33
+ // symbol branding
34
+ const MyBrand: unique symbol = Symbol("hello");
35
+ type MyBrand = typeof MyBrand;
36
+ const symbolBrand = z.number().brand<"sup">().brand<typeof MyBrand>();
37
+ type SymbolBrand = z.infer<typeof symbolBrand>;
38
+ // number & { [z.BRAND]: { sup: true, [MyBrand]: true } }
39
+ util.assertEqual<SymbolBrand, number & z.BRAND<"sup"> & z.BRAND<MyBrand>>(true);
40
+
41
+ // keeping brands out of input types
42
+ const age = z.number().brand<"age">();
43
+
44
+ type Age = z.infer<typeof age>;
45
+ type AgeInput = z.input<typeof age>;
46
+
47
+ util.assertEqual<AgeInput, Age>(false);
48
+ util.assertEqual<number, AgeInput>(true);
49
+ util.assertEqual<number & z.BRAND<"age">, Age>(true);
50
+
51
+ // @ts-expect-error
52
+ doStuff({ name: "hello there!" });
53
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/catch.test.ts ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import { z } from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ test("basic catch", () => {
8
+ expect(z.string().catch("default").parse(undefined)).toBe("default");
9
+ });
10
+
11
+ test("catch fn does not run when parsing succeeds", () => {
12
+ let isCalled = false;
13
+ const cb = () => {
14
+ isCalled = true;
15
+ return "asdf";
16
+ };
17
+ expect(z.string().catch(cb).parse("test")).toBe("test");
18
+ expect(isCalled).toEqual(false);
19
+ });
20
+
21
+ test("basic catch async", async () => {
22
+ const result = await z.string().catch("default").parseAsync(1243);
23
+ expect(result).toBe("default");
24
+ });
25
+
26
+ test("catch replace wrong types", () => {
27
+ expect(z.string().catch("default").parse(true)).toBe("default");
28
+ expect(z.string().catch("default").parse(true)).toBe("default");
29
+ expect(z.string().catch("default").parse(15)).toBe("default");
30
+ expect(z.string().catch("default").parse([])).toBe("default");
31
+ expect(z.string().catch("default").parse(new Map())).toBe("default");
32
+ expect(z.string().catch("default").parse(new Set())).toBe("default");
33
+ expect(z.string().catch("default").parse({})).toBe("default");
34
+ });
35
+
36
+ test("catch with transform", () => {
37
+ const stringWithDefault = z
38
+ .string()
39
+ .transform((val) => val.toUpperCase())
40
+ .catch("default");
41
+ expect(stringWithDefault.parse(undefined)).toBe("default");
42
+ expect(stringWithDefault.parse(15)).toBe("default");
43
+ expect(stringWithDefault).toBeInstanceOf(z.ZodCatch);
44
+ expect(stringWithDefault._def.innerType).toBeInstanceOf(z.ZodEffects);
45
+ expect(stringWithDefault._def.innerType._def.schema).toBeInstanceOf(z.ZodSchema);
46
+
47
+ type inp = z.input<typeof stringWithDefault>;
48
+ util.assertEqual<inp, unknown>(true);
49
+ type out = z.output<typeof stringWithDefault>;
50
+ util.assertEqual<out, string>(true);
51
+ });
52
+
53
+ test("catch on existing optional", () => {
54
+ const stringWithDefault = z.string().optional().catch("asdf");
55
+ expect(stringWithDefault.parse(undefined)).toBe(undefined);
56
+ expect(stringWithDefault.parse(15)).toBe("asdf");
57
+ expect(stringWithDefault).toBeInstanceOf(z.ZodCatch);
58
+ expect(stringWithDefault._def.innerType).toBeInstanceOf(z.ZodOptional);
59
+ expect(stringWithDefault._def.innerType._def.innerType).toBeInstanceOf(z.ZodString);
60
+
61
+ type inp = z.input<typeof stringWithDefault>;
62
+ util.assertEqual<inp, unknown>(true);
63
+ type out = z.output<typeof stringWithDefault>;
64
+ util.assertEqual<out, string | undefined>(true);
65
+ });
66
+
67
+ test("optional on catch", () => {
68
+ const stringWithDefault = z.string().catch("asdf").optional();
69
+
70
+ type inp = z.input<typeof stringWithDefault>;
71
+ util.assertEqual<inp, unknown>(true);
72
+ type out = z.output<typeof stringWithDefault>;
73
+ util.assertEqual<out, string | undefined>(true);
74
+ });
75
+
76
+ test("complex chain example", () => {
77
+ const complex = z
78
+ .string()
79
+ .catch("asdf")
80
+ .transform((val) => val + "!")
81
+ .transform((val) => val.toUpperCase())
82
+ .catch("qwer")
83
+ .removeCatch()
84
+ .optional()
85
+ .catch("asdfasdf");
86
+
87
+ expect(complex.parse("qwer")).toBe("QWER!");
88
+ expect(complex.parse(15)).toBe("ASDF!");
89
+ expect(complex.parse(true)).toBe("ASDF!");
90
+ });
91
+
92
+ test("removeCatch", () => {
93
+ const stringWithRemovedDefault = z.string().catch("asdf").removeCatch();
94
+
95
+ type out = z.output<typeof stringWithRemovedDefault>;
96
+ util.assertEqual<out, string>(true);
97
+ });
98
+
99
+ test("nested", () => {
100
+ const inner = z.string().catch("asdf");
101
+ const outer = z.object({ inner }).catch({
102
+ inner: "asdf",
103
+ });
104
+ type input = z.input<typeof outer>;
105
+ util.assertEqual<input, unknown>(true);
106
+ type out = z.output<typeof outer>;
107
+ util.assertEqual<out, { inner: string }>(true);
108
+ expect(outer.parse(undefined)).toEqual({ inner: "asdf" });
109
+ expect(outer.parse({})).toEqual({ inner: "asdf" });
110
+ expect(outer.parse({ inner: undefined })).toEqual({ inner: "asdf" });
111
+ });
112
+
113
+ test("chained catch", () => {
114
+ const stringWithDefault = z.string().catch("inner").catch("outer");
115
+ const result = stringWithDefault.parse(undefined);
116
+ expect(result).toEqual("inner");
117
+ const resultDiff = stringWithDefault.parse(5);
118
+ expect(resultDiff).toEqual("inner");
119
+ });
120
+
121
+ test("factory", () => {
122
+ z.ZodCatch.create(z.string(), {
123
+ catch: "asdf",
124
+ }).parse(undefined);
125
+ });
126
+
127
+ test("native enum", () => {
128
+ enum Fruits {
129
+ apple = "apple",
130
+ orange = "orange",
131
+ }
132
+
133
+ const schema = z.object({
134
+ fruit: z.nativeEnum(Fruits).catch(Fruits.apple),
135
+ });
136
+
137
+ expect(schema.parse({})).toEqual({ fruit: Fruits.apple });
138
+ expect(schema.parse({ fruit: 15 })).toEqual({ fruit: Fruits.apple });
139
+ });
140
+
141
+ test("enum", () => {
142
+ const schema = z.object({
143
+ fruit: z.enum(["apple", "orange"]).catch("apple"),
144
+ });
145
+
146
+ expect(schema.parse({})).toEqual({ fruit: "apple" });
147
+ expect(schema.parse({ fruit: true })).toEqual({ fruit: "apple" });
148
+ expect(schema.parse({ fruit: 15 })).toEqual({ fruit: "apple" });
149
+ });
150
+
151
+ test("reported issues with nested usage", () => {
152
+ const schema = z.object({
153
+ string: z.string(),
154
+ obj: z.object({
155
+ sub: z.object({
156
+ lit: z.literal("a"),
157
+ subCatch: z.number().catch(23),
158
+ }),
159
+ midCatch: z.number().catch(42),
160
+ }),
161
+ number: z.number().catch(0),
162
+ bool: z.boolean(),
163
+ });
164
+
165
+ try {
166
+ schema.parse({
167
+ string: {},
168
+ obj: {
169
+ sub: {
170
+ lit: "b",
171
+ subCatch: "24",
172
+ },
173
+ midCatch: 444,
174
+ },
175
+ number: "",
176
+ bool: "yes",
177
+ });
178
+ } catch (error) {
179
+ const issues = (error as z.ZodError).issues;
180
+
181
+ expect(issues.length).toEqual(3);
182
+ expect(issues[0].message).toMatch("string");
183
+ expect(issues[1].message).toMatch("literal");
184
+ expect(issues[2].message).toMatch("boolean");
185
+ }
186
+ });
187
+
188
+ test("catch error", () => {
189
+ let catchError: z.ZodError | undefined = undefined;
190
+
191
+ const schema = z.object({
192
+ age: z.number(),
193
+ name: z.string().catch((ctx) => {
194
+ catchError = ctx.error;
195
+
196
+ return "John Doe";
197
+ }),
198
+ });
199
+
200
+ const result = schema.safeParse({
201
+ age: null,
202
+ name: null,
203
+ });
204
+
205
+ expect(result.success).toEqual(false);
206
+ expect(!result.success && result.error.issues.length).toEqual(1);
207
+ expect(!result.success && result.error.issues[0].message).toMatch("number");
208
+
209
+ expect(catchError).toBeInstanceOf(z.ZodError);
210
+ expect(catchError !== undefined && (catchError as z.ZodError).issues.length).toEqual(1);
211
+ expect(catchError !== undefined && (catchError as z.ZodError).issues[0].message).toMatch("string");
212
+ });
213
+
214
+ test("ctx.input", () => {
215
+ const schema = z.string().catch((ctx) => {
216
+ return String(ctx.input);
217
+ });
218
+
219
+ expect(schema.parse(123)).toEqual("123");
220
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/coerce.test.ts ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ test("string coercion", () => {
7
+ const schema = z.coerce.string();
8
+ expect(schema.parse("sup")).toEqual("sup");
9
+ expect(schema.parse("")).toEqual("");
10
+ expect(schema.parse(12)).toEqual("12");
11
+ expect(schema.parse(0)).toEqual("0");
12
+ expect(schema.parse(-12)).toEqual("-12");
13
+ expect(schema.parse(3.14)).toEqual("3.14");
14
+ expect(schema.parse(BigInt(15))).toEqual("15");
15
+ expect(schema.parse(Number.NaN)).toEqual("NaN");
16
+ expect(schema.parse(Number.POSITIVE_INFINITY)).toEqual("Infinity");
17
+ expect(schema.parse(Number.NEGATIVE_INFINITY)).toEqual("-Infinity");
18
+ expect(schema.parse(true)).toEqual("true");
19
+ expect(schema.parse(false)).toEqual("false");
20
+ expect(schema.parse(null)).toEqual("null");
21
+ expect(schema.parse(undefined)).toEqual("undefined");
22
+ expect(schema.parse({ hello: "world!" })).toEqual("[object Object]");
23
+ expect(schema.parse(["item", "another_item"])).toEqual("item,another_item");
24
+ expect(schema.parse([])).toEqual("");
25
+ expect(schema.parse(new Date("2022-01-01T00:00:00.000Z"))).toEqual(new Date("2022-01-01T00:00:00.000Z").toString());
26
+ });
27
+
28
+ test("number coercion", () => {
29
+ const schema = z.coerce.number();
30
+ expect(schema.parse("12")).toEqual(12);
31
+ expect(schema.parse("0")).toEqual(0);
32
+ expect(schema.parse("-12")).toEqual(-12);
33
+ expect(schema.parse("3.14")).toEqual(3.14);
34
+ expect(schema.parse("")).toEqual(0);
35
+ expect(() => schema.parse("NOT_A_NUMBER")).toThrow(); // z.ZodError
36
+ expect(schema.parse(12)).toEqual(12);
37
+ expect(schema.parse(0)).toEqual(0);
38
+ expect(schema.parse(-12)).toEqual(-12);
39
+ expect(schema.parse(3.14)).toEqual(3.14);
40
+ expect(schema.parse(BigInt(15))).toEqual(15);
41
+ expect(() => schema.parse(Number.NaN)).toThrow(); // z.ZodError
42
+ expect(schema.parse(Number.POSITIVE_INFINITY)).toEqual(Number.POSITIVE_INFINITY);
43
+ expect(schema.parse(Number.NEGATIVE_INFINITY)).toEqual(Number.NEGATIVE_INFINITY);
44
+ expect(schema.parse(true)).toEqual(1);
45
+ expect(schema.parse(false)).toEqual(0);
46
+ expect(schema.parse(null)).toEqual(0);
47
+ expect(() => schema.parse(undefined)).toThrow(); // z.ZodError
48
+ expect(() => schema.parse({ hello: "world!" })).toThrow(); // z.ZodError
49
+ expect(() => schema.parse(["item", "another_item"])).toThrow(); // z.ZodError
50
+ expect(schema.parse([])).toEqual(0);
51
+ expect(schema.parse(new Date(1670139203496))).toEqual(1670139203496);
52
+ });
53
+
54
+ test("boolean coercion", () => {
55
+ const schema = z.coerce.boolean();
56
+ expect(schema.parse("true")).toEqual(true);
57
+ expect(schema.parse("false")).toEqual(true);
58
+ expect(schema.parse("0")).toEqual(true);
59
+ expect(schema.parse("1")).toEqual(true);
60
+ expect(schema.parse("")).toEqual(false);
61
+ expect(schema.parse(1)).toEqual(true);
62
+ expect(schema.parse(0)).toEqual(false);
63
+ expect(schema.parse(-1)).toEqual(true);
64
+ expect(schema.parse(3.14)).toEqual(true);
65
+ expect(schema.parse(BigInt(15))).toEqual(true);
66
+ expect(schema.parse(Number.NaN)).toEqual(false);
67
+ expect(schema.parse(Number.POSITIVE_INFINITY)).toEqual(true);
68
+ expect(schema.parse(Number.NEGATIVE_INFINITY)).toEqual(true);
69
+ expect(schema.parse(true)).toEqual(true);
70
+ expect(schema.parse(false)).toEqual(false);
71
+ expect(schema.parse(null)).toEqual(false);
72
+ expect(schema.parse(undefined)).toEqual(false);
73
+ expect(schema.parse({ hello: "world!" })).toEqual(true);
74
+ expect(schema.parse(["item", "another_item"])).toEqual(true);
75
+ expect(schema.parse([])).toEqual(true);
76
+ expect(schema.parse(new Date(1670139203496))).toEqual(true);
77
+ });
78
+
79
+ test("bigint coercion", () => {
80
+ const schema = z.coerce.bigint();
81
+ expect(schema.parse("5")).toEqual(BigInt(5));
82
+ expect(schema.parse("0")).toEqual(BigInt(0));
83
+ expect(schema.parse("-5")).toEqual(BigInt(-5));
84
+ expect(() => schema.parse("3.14")).toThrow(); // not a z.ZodError!
85
+ expect(schema.parse("")).toEqual(BigInt(0));
86
+ expect(() => schema.parse("NOT_A_NUMBER")).toThrow(); // not a z.ZodError!
87
+ expect(schema.parse(5)).toEqual(BigInt(5));
88
+ expect(schema.parse(0)).toEqual(BigInt(0));
89
+ expect(schema.parse(-5)).toEqual(BigInt(-5));
90
+ expect(() => schema.parse(3.14)).toThrow(); // not a z.ZodError!
91
+ expect(schema.parse(BigInt(5))).toEqual(BigInt(5));
92
+ expect(() => schema.parse(Number.NaN)).toThrow(); // not a z.ZodError!
93
+ expect(() => schema.parse(Number.POSITIVE_INFINITY)).toThrow(); // not a z.ZodError!
94
+ expect(() => schema.parse(Number.NEGATIVE_INFINITY)).toThrow(); // not a z.ZodError!
95
+ expect(schema.parse(true)).toEqual(BigInt(1));
96
+ expect(schema.parse(false)).toEqual(BigInt(0));
97
+ expect(() => schema.parse(null)).toThrow(); // not a z.ZodError!
98
+ expect(() => schema.parse(undefined)).toThrow(); // not a z.ZodError!
99
+ expect(() => schema.parse({ hello: "world!" })).toThrow(); // not a z.ZodError!
100
+ expect(() => schema.parse(["item", "another_item"])).toThrow(); // not a z.ZodError!
101
+ expect(schema.parse([])).toEqual(BigInt(0));
102
+ expect(schema.parse(new Date(1670139203496))).toEqual(BigInt(1670139203496));
103
+ });
104
+
105
+ test("date coercion", () => {
106
+ const schema = z.coerce.date();
107
+ expect(schema.parse(new Date().toDateString())).toBeInstanceOf(Date);
108
+ expect(schema.parse(new Date().toISOString())).toBeInstanceOf(Date);
109
+ expect(schema.parse(new Date().toUTCString())).toBeInstanceOf(Date);
110
+ expect(schema.parse("5")).toBeInstanceOf(Date);
111
+ expect(schema.parse("2000-01-01")).toBeInstanceOf(Date);
112
+ // expect(schema.parse("0")).toBeInstanceOf(Date);
113
+ // expect(schema.parse("-5")).toBeInstanceOf(Date);
114
+ // expect(schema.parse("3.14")).toBeInstanceOf(Date);
115
+ expect(() => schema.parse("")).toThrow(); // z.ZodError
116
+ expect(() => schema.parse("NOT_A_DATE")).toThrow(); // z.ZodError
117
+ expect(schema.parse(5)).toBeInstanceOf(Date);
118
+ expect(schema.parse(0)).toBeInstanceOf(Date);
119
+ expect(schema.parse(-5)).toBeInstanceOf(Date);
120
+ expect(schema.parse(3.14)).toBeInstanceOf(Date);
121
+ expect(() => schema.parse(BigInt(5))).toThrow(); // not a z.ZodError!
122
+ expect(() => schema.parse(Number.NaN)).toThrow(); // z.ZodError
123
+ expect(() => schema.parse(Number.POSITIVE_INFINITY)).toThrow(); // z.ZodError
124
+ expect(() => schema.parse(Number.NEGATIVE_INFINITY)).toThrow(); // z.ZodError
125
+ expect(schema.parse(true)).toBeInstanceOf(Date);
126
+ expect(schema.parse(false)).toBeInstanceOf(Date);
127
+ expect(schema.parse(null)).toBeInstanceOf(Date);
128
+ expect(() => schema.parse(undefined)).toThrow(); // z.ZodError
129
+ expect(() => schema.parse({ hello: "world!" })).toThrow(); // z.ZodError
130
+ expect(() => schema.parse(["item", "another_item"])).toThrow(); // z.ZodError
131
+ expect(() => schema.parse([])).toThrow(); // z.ZodError
132
+ expect(schema.parse(new Date())).toBeInstanceOf(Date);
133
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/complex.test.ts ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { test } from "vitest";
2
+ import * as z from "zod/v3";
3
+
4
+ const crazySchema = z.object({
5
+ tuple: z.tuple([
6
+ z.string().nullable().optional(),
7
+ z.number().nullable().optional(),
8
+ z.boolean().nullable().optional(),
9
+ z.null().nullable().optional(),
10
+ z.undefined().nullable().optional(),
11
+ z.literal("1234").nullable().optional(),
12
+ ]),
13
+ merged: z
14
+ .object({
15
+ k1: z.string().optional(),
16
+ })
17
+ .merge(z.object({ k1: z.string().nullable(), k2: z.number() })),
18
+ union: z.array(z.union([z.literal("asdf"), z.literal(12)])).nonempty(),
19
+ array: z.array(z.number()),
20
+ // sumTransformer: z.transformer(z.array(z.number()), z.number(), (arg) => {
21
+ // return arg.reduce((a, b) => a + b, 0);
22
+ // }),
23
+ sumMinLength: z.array(z.number()).refine((arg) => arg.length > 5),
24
+ intersection: z.intersection(z.object({ p1: z.string().optional() }), z.object({ p1: z.number().optional() })),
25
+ enum: z.intersection(z.enum(["zero", "one"]), z.enum(["one", "two"])),
26
+ nonstrict: z.object({ points: z.number() }).nonstrict(),
27
+ numProm: z.promise(z.number()),
28
+ lenfun: z.function(z.tuple([z.string()]), z.boolean()),
29
+ });
30
+
31
+ // const asyncCrazySchema = crazySchema.extend({
32
+ // // async_transform: z.transformer(
33
+ // // z.array(z.number()),
34
+ // // z.number(),
35
+ // // async (arg) => {
36
+ // // return arg.reduce((a, b) => a + b, 0);
37
+ // // }
38
+ // // ),
39
+ // async_refine: z.array(z.number()).refine(async (arg) => arg.length > 5),
40
+ // });
41
+
42
+ test("parse", () => {
43
+ crazySchema.parse({
44
+ tuple: ["asdf", 1234, true, null, undefined, "1234"],
45
+ merged: { k1: "asdf", k2: 12 },
46
+ union: ["asdf", 12, "asdf", 12, "asdf", 12],
47
+ array: [12, 15, 16],
48
+ // sumTransformer: [12, 15, 16],
49
+ sumMinLength: [12, 15, 16, 98, 24, 63],
50
+ intersection: {},
51
+ enum: "one",
52
+ nonstrict: { points: 1234 },
53
+ numProm: Promise.resolve(12),
54
+ lenfun: (x: string) => x.length,
55
+ });
56
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/custom.test.ts ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ test("passing validations", () => {
7
+ const example1 = z.custom<number>((x) => typeof x === "number");
8
+ example1.parse(1234);
9
+ expect(() => example1.parse({})).toThrow();
10
+ });
11
+
12
+ test("string params", () => {
13
+ const example1 = z.custom<number>((x) => typeof x !== "number", "customerr");
14
+ const result = example1.safeParse(1234);
15
+ expect(result.success).toEqual(false);
16
+ // @ts-ignore
17
+ expect(JSON.stringify(result.error).includes("customerr")).toEqual(true);
18
+ });
19
+
20
+ test("async validations", async () => {
21
+ const example1 = z.custom<number>(async (x) => {
22
+ return typeof x === "number";
23
+ });
24
+ const r1 = await example1.safeParseAsync(1234);
25
+ expect(r1.success).toEqual(true);
26
+ expect(r1.data).toEqual(1234);
27
+
28
+ const r2 = await example1.safeParseAsync("asdf");
29
+ expect(r2.success).toEqual(false);
30
+ expect(r2.error!.issues.length).toEqual(1);
31
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/date.test.ts ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ const beforeBenchmarkDate = new Date(2022, 10, 4);
7
+ const benchmarkDate = new Date(2022, 10, 5);
8
+ const afterBenchmarkDate = new Date(2022, 10, 6);
9
+
10
+ const minCheck = z.date().min(benchmarkDate);
11
+ const maxCheck = z.date().max(benchmarkDate);
12
+
13
+ test("passing validations", () => {
14
+ minCheck.parse(benchmarkDate);
15
+ minCheck.parse(afterBenchmarkDate);
16
+
17
+ maxCheck.parse(benchmarkDate);
18
+ maxCheck.parse(beforeBenchmarkDate);
19
+ });
20
+
21
+ test("failing validations", () => {
22
+ expect(() => minCheck.parse(beforeBenchmarkDate)).toThrow();
23
+ expect(() => maxCheck.parse(afterBenchmarkDate)).toThrow();
24
+ });
25
+
26
+ test("min max getters", () => {
27
+ expect(minCheck.minDate).toEqual(benchmarkDate);
28
+ expect(minCheck.min(afterBenchmarkDate).minDate).toEqual(afterBenchmarkDate);
29
+
30
+ expect(maxCheck.maxDate).toEqual(benchmarkDate);
31
+ expect(maxCheck.max(beforeBenchmarkDate).maxDate).toEqual(beforeBenchmarkDate);
32
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/deepmasking.test.ts ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ test("test", () => {
7
+ z;
8
+ });
9
+
10
+ // const fish = z.object({
11
+ // name: z.string(),
12
+ // props: z.object({
13
+ // color: z.string(),
14
+ // numScales: z.number(),
15
+ // }),
16
+ // });
17
+
18
+ // const nonStrict = z
19
+ // .object({
20
+ // name: z.string(),
21
+ // color: z.string(),
22
+ // })
23
+ // .nonstrict();
24
+
25
+ // test('object pick type', () => {
26
+ // const modNonStrictFish = nonStrict.omit({ name: true });
27
+ // modNonStrictFish.parse({ color: 'asdf' });
28
+
29
+ // const bad1 = () => fish.pick({ props: { unknown: true } } as any);
30
+ // const bad2 = () => fish.omit({ name: true, props: { unknown: true } } as any);
31
+
32
+ // expect(bad1).toThrow();
33
+ // expect(bad2).toThrow();
34
+ // });
35
+
36
+ // test('f1', () => {
37
+ // const f1 = fish.pick(true);
38
+ // f1.parse({ name: 'a', props: { color: 'b', numScales: 3 } });
39
+ // });
40
+ // test('f2', () => {
41
+ // const f2 = fish.pick({ props: true });
42
+ // f2.parse({ props: { color: 'asdf', numScales: 1 } });
43
+ // const badcheck2 = () => f2.parse({ name: 'a', props: { color: 'b', numScales: 3 } } as any);
44
+ // expect(badcheck2).toThrow();
45
+ // });
46
+ // test('f3', () => {
47
+ // const f3 = fish.pick({ props: { color: true } });
48
+ // f3.parse({ props: { color: 'b' } });
49
+ // const badcheck3 = () => f3.parse({ name: 'a', props: { color: 'b', numScales: 3 } } as any);
50
+ // expect(badcheck3).toThrow();
51
+ // });
52
+ // test('f4', () => {
53
+ // const badcheck4 = () => fish.pick({ props: { color: true, unknown: true } });
54
+ // expect(badcheck4).toThrow();
55
+ // });
56
+ // test('f6', () => {
57
+ // const f6 = fish.omit({ props: true });
58
+ // const badcheck6 = () => f6.parse({ name: 'a', props: { color: 'b', numScales: 3 } } as any);
59
+ // f6.parse({ name: 'adsf' });
60
+ // expect(badcheck6).toThrow();
61
+ // });
62
+ // test('f7', () => {
63
+ // const f7 = fish.omit({ props: { color: true } });
64
+ // f7.parse({ name: 'a', props: { numScales: 3 } });
65
+ // const badcheck7 = () => f7.parse({ name: 'a', props: { color: 'b', numScales: 3 } } as any);
66
+ // expect(badcheck7).toThrow();
67
+ // });
68
+ // test('f8', () => {
69
+ // const badcheck8 = () => fish.omit({ props: { color: true, unknown: true } });
70
+ // expect(badcheck8).toThrow();
71
+ // });
72
+ // test('f9', () => {
73
+ // const f9 = nonStrict.pick(true);
74
+ // f9.parse({ name: 'a', color: 'asdf' });
75
+ // });
76
+ // test('f10', () => {
77
+ // const f10 = nonStrict.pick({ name: true });
78
+ // f10.parse({ name: 'a' });
79
+ // const val = f10.parse({ name: 'a', color: 'b' });
80
+ // expect(val).toEqual({ name: 'a' });
81
+ // });
82
+ // test('f12', () => {
83
+ // const badfcheck12 = () => nonStrict.omit({ color: true, asdf: true });
84
+ // expect(badfcheck12).toThrow();
85
+ // });
86
+
87
+ // test('array masking', () => {
88
+ // const fishArray = z.array(fish);
89
+ // const modFishArray = fishArray.pick({
90
+ // name: true,
91
+ // props: {
92
+ // numScales: true,
93
+ // },
94
+ // });
95
+
96
+ // modFishArray.parse([{ name: 'fish', props: { numScales: 12 } }]);
97
+ // const bad1 = () => modFishArray.parse([{ name: 'fish', props: { numScales: 12, color: 'asdf' } }] as any);
98
+ // expect(bad1).toThrow();
99
+ // });
100
+
101
+ // test('array masking', () => {
102
+ // const fishArray = z.array(fish);
103
+ // const fail = () =>
104
+ // fishArray.pick({
105
+ // name: true,
106
+ // props: {
107
+ // whatever: true,
108
+ // },
109
+ // } as any);
110
+ // expect(fail).toThrow();
111
+ // });
112
+
113
+ // test('array masking', () => {
114
+ // const fishArray = z.array(fish);
115
+ // const fail = () =>
116
+ // fishArray.omit({
117
+ // whateve: true,
118
+ // } as any);
119
+ // expect(fail).toThrow();
120
+ // });
121
+
122
+ // test('array masking', () => {
123
+ // const fishArray = z.array(fish);
124
+ // const modFishList = fishArray.omit({
125
+ // name: true,
126
+ // props: {
127
+ // color: true,
128
+ // },
129
+ // });
130
+
131
+ // modFishList.parse([{ props: { numScales: 12 } }]);
132
+ // const fail = () => modFishList.parse([{ name: 'hello', props: { numScales: 12 } }] as any);
133
+ // expect(fail).toThrow();
134
+ // });
135
+
136
+ // test('primitive array masking', () => {
137
+ // const fishArray = z.array(z.number());
138
+ // const fail = () => fishArray.pick({} as any);
139
+ // expect(fail).toThrow();
140
+ // });
141
+
142
+ // test('other array masking', () => {
143
+ // const fishArray = z.array(z.array(z.number()));
144
+ // const fail = () => fishArray.pick({} as any);
145
+ // expect(fail).toThrow();
146
+ // });
147
+
148
+ // test('invalid mask #1', () => {
149
+ // const fail = () => fish.pick(1 as any);
150
+ // expect(fail).toThrow();
151
+ // });
152
+
153
+ // test('invalid mask #2', () => {
154
+ // const fail = () => fish.pick([] as any);
155
+ // expect(fail).toThrow();
156
+ // });
157
+
158
+ // test('invalid mask #3', () => {
159
+ // const fail = () => fish.pick(false as any);
160
+ // expect(fail).toThrow();
161
+ // });
162
+
163
+ // test('invalid mask #4', () => {
164
+ // const fail = () => fish.pick('asdf' as any);
165
+ // expect(fail).toThrow();
166
+ // });
167
+
168
+ // test('invalid mask #5', () => {
169
+ // const fail = () => fish.omit(1 as any);
170
+ // expect(fail).toThrow();
171
+ // });
172
+
173
+ // test('invalid mask #6', () => {
174
+ // const fail = () => fish.omit([] as any);
175
+ // expect(fail).toThrow();
176
+ // });
177
+
178
+ // test('invalid mask #7', () => {
179
+ // const fail = () => fish.omit(false as any);
180
+ // expect(fail).toThrow();
181
+ // });
182
+
183
+ // test('invalid mask #8', () => {
184
+ // const fail = () => fish.omit('asdf' as any);
185
+ // expect(fail).toThrow();
186
+ // });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/default.test.ts ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import { z } from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ test("basic defaults", () => {
8
+ expect(z.string().default("default").parse(undefined)).toBe("default");
9
+ });
10
+
11
+ test("default with transform", () => {
12
+ const stringWithDefault = z
13
+ .string()
14
+ .transform((val) => val.toUpperCase())
15
+ .default("default");
16
+ expect(stringWithDefault.parse(undefined)).toBe("DEFAULT");
17
+ expect(stringWithDefault).toBeInstanceOf(z.ZodDefault);
18
+ expect(stringWithDefault._def.innerType).toBeInstanceOf(z.ZodEffects);
19
+ expect(stringWithDefault._def.innerType._def.schema).toBeInstanceOf(z.ZodSchema);
20
+
21
+ type inp = z.input<typeof stringWithDefault>;
22
+ util.assertEqual<inp, string | undefined>(true);
23
+ type out = z.output<typeof stringWithDefault>;
24
+ util.assertEqual<out, string>(true);
25
+ });
26
+
27
+ test("default on existing optional", () => {
28
+ const stringWithDefault = z.string().optional().default("asdf");
29
+ expect(stringWithDefault.parse(undefined)).toBe("asdf");
30
+ expect(stringWithDefault).toBeInstanceOf(z.ZodDefault);
31
+ expect(stringWithDefault._def.innerType).toBeInstanceOf(z.ZodOptional);
32
+ expect(stringWithDefault._def.innerType._def.innerType).toBeInstanceOf(z.ZodString);
33
+
34
+ type inp = z.input<typeof stringWithDefault>;
35
+ util.assertEqual<inp, string | undefined>(true);
36
+ type out = z.output<typeof stringWithDefault>;
37
+ util.assertEqual<out, string>(true);
38
+ });
39
+
40
+ test("optional on default", () => {
41
+ const stringWithDefault = z.string().default("asdf").optional();
42
+
43
+ type inp = z.input<typeof stringWithDefault>;
44
+ util.assertEqual<inp, string | undefined>(true);
45
+ type out = z.output<typeof stringWithDefault>;
46
+ util.assertEqual<out, string | undefined>(true);
47
+ });
48
+
49
+ test("complex chain example", () => {
50
+ const complex = z
51
+ .string()
52
+ .default("asdf")
53
+ .transform((val) => val.toUpperCase())
54
+ .default("qwer")
55
+ .removeDefault()
56
+ .optional()
57
+ .default("asdfasdf");
58
+
59
+ expect(complex.parse(undefined)).toBe("ASDFASDF");
60
+ });
61
+
62
+ test("removeDefault", () => {
63
+ const stringWithRemovedDefault = z.string().default("asdf").removeDefault();
64
+
65
+ type out = z.output<typeof stringWithRemovedDefault>;
66
+ util.assertEqual<out, string>(true);
67
+ });
68
+
69
+ test("nested", () => {
70
+ const inner = z.string().default("asdf");
71
+ const outer = z.object({ inner }).default({
72
+ inner: undefined,
73
+ });
74
+ type input = z.input<typeof outer>;
75
+ util.assertEqual<input, { inner?: string | undefined } | undefined>(true);
76
+ type out = z.output<typeof outer>;
77
+ util.assertEqual<out, { inner: string }>(true);
78
+ expect(outer.parse(undefined)).toEqual({ inner: "asdf" });
79
+ expect(outer.parse({})).toEqual({ inner: "asdf" });
80
+ expect(outer.parse({ inner: undefined })).toEqual({ inner: "asdf" });
81
+ });
82
+
83
+ test("chained defaults", () => {
84
+ const stringWithDefault = z.string().default("inner").default("outer");
85
+ const result = stringWithDefault.parse(undefined);
86
+ expect(result).toEqual("outer");
87
+ });
88
+
89
+ test("factory", () => {
90
+ expect(z.ZodDefault.create(z.string(), { default: "asdf" }).parse(undefined)).toEqual("asdf");
91
+ });
92
+
93
+ test("native enum", () => {
94
+ enum Fruits {
95
+ apple = "apple",
96
+ orange = "orange",
97
+ }
98
+
99
+ const schema = z.object({
100
+ fruit: z.nativeEnum(Fruits).default(Fruits.apple),
101
+ });
102
+
103
+ expect(schema.parse({})).toEqual({ fruit: Fruits.apple });
104
+ });
105
+
106
+ test("enum", () => {
107
+ const schema = z.object({
108
+ fruit: z.enum(["apple", "orange"]).default("apple"),
109
+ });
110
+
111
+ expect(schema.parse({})).toEqual({ fruit: "apple" });
112
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/description.test.ts ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ const description = "a description";
7
+
8
+ test("passing `description` to schema should add a description", () => {
9
+ expect(z.string({ description }).description).toEqual(description);
10
+ expect(z.number({ description }).description).toEqual(description);
11
+ expect(z.boolean({ description }).description).toEqual(description);
12
+ });
13
+
14
+ test("`.describe` should add a description", () => {
15
+ expect(z.string().describe(description).description).toEqual(description);
16
+ expect(z.number().describe(description).description).toEqual(description);
17
+ expect(z.boolean().describe(description).description).toEqual(description);
18
+ });
19
+
20
+ test("description should carry over to chained schemas", () => {
21
+ const schema = z.string({ description });
22
+ expect(schema.description).toEqual(description);
23
+ expect(schema.optional().description).toEqual(description);
24
+ expect(schema.optional().nullable().default("default").description).toEqual(description);
25
+ });
26
+
27
+ test("description should not carry over to chained array schema", () => {
28
+ const schema = z.string().describe(description);
29
+
30
+ expect(schema.description).toEqual(description);
31
+ expect(schema.array().description).toEqual(undefined);
32
+ expect(z.array(schema).description).toEqual(undefined);
33
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/discriminated-unions.test.ts ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ test("valid", () => {
7
+ expect(
8
+ z
9
+ .discriminatedUnion("type", [
10
+ z.object({ type: z.literal("a"), a: z.string() }),
11
+ z.object({ type: z.literal("b"), b: z.string() }),
12
+ ])
13
+ .parse({ type: "a", a: "abc" })
14
+ ).toEqual({ type: "a", a: "abc" });
15
+ });
16
+
17
+ test("valid - discriminator value of various primitive types", () => {
18
+ const schema = z.discriminatedUnion("type", [
19
+ z.object({ type: z.literal("1"), val: z.literal(1) }),
20
+ z.object({ type: z.literal(1), val: z.literal(2) }),
21
+ z.object({ type: z.literal(BigInt(1)), val: z.literal(3) }),
22
+ z.object({ type: z.literal("true"), val: z.literal(4) }),
23
+ z.object({ type: z.literal(true), val: z.literal(5) }),
24
+ z.object({ type: z.literal("null"), val: z.literal(6) }),
25
+ z.object({ type: z.literal(null), val: z.literal(7) }),
26
+ z.object({ type: z.literal("undefined"), val: z.literal(8) }),
27
+ z.object({ type: z.literal(undefined), val: z.literal(9) }),
28
+ z.object({ type: z.literal("transform"), val: z.literal(10) }),
29
+ z.object({ type: z.literal("refine"), val: z.literal(11) }),
30
+ z.object({ type: z.literal("superRefine"), val: z.literal(12) }),
31
+ ]);
32
+
33
+ expect(schema.parse({ type: "1", val: 1 })).toEqual({ type: "1", val: 1 });
34
+ expect(schema.parse({ type: 1, val: 2 })).toEqual({ type: 1, val: 2 });
35
+ expect(schema.parse({ type: BigInt(1), val: 3 })).toEqual({
36
+ type: BigInt(1),
37
+ val: 3,
38
+ });
39
+ expect(schema.parse({ type: "true", val: 4 })).toEqual({
40
+ type: "true",
41
+ val: 4,
42
+ });
43
+ expect(schema.parse({ type: true, val: 5 })).toEqual({
44
+ type: true,
45
+ val: 5,
46
+ });
47
+ expect(schema.parse({ type: "null", val: 6 })).toEqual({
48
+ type: "null",
49
+ val: 6,
50
+ });
51
+ expect(schema.parse({ type: null, val: 7 })).toEqual({
52
+ type: null,
53
+ val: 7,
54
+ });
55
+ expect(schema.parse({ type: "undefined", val: 8 })).toEqual({
56
+ type: "undefined",
57
+ val: 8,
58
+ });
59
+ expect(schema.parse({ type: undefined, val: 9 })).toEqual({
60
+ type: undefined,
61
+ val: 9,
62
+ });
63
+ });
64
+
65
+ test("invalid - null", () => {
66
+ try {
67
+ z.discriminatedUnion("type", [
68
+ z.object({ type: z.literal("a"), a: z.string() }),
69
+ z.object({ type: z.literal("b"), b: z.string() }),
70
+ ]).parse(null);
71
+ throw new Error();
72
+ } catch (e: any) {
73
+ expect(JSON.parse(e.message)).toEqual([
74
+ {
75
+ code: z.ZodIssueCode.invalid_type,
76
+ expected: z.ZodParsedType.object,
77
+ message: "Expected object, received null",
78
+ received: z.ZodParsedType.null,
79
+ path: [],
80
+ },
81
+ ]);
82
+ }
83
+ });
84
+
85
+ test("invalid discriminator value", () => {
86
+ try {
87
+ z.discriminatedUnion("type", [
88
+ z.object({ type: z.literal("a"), a: z.string() }),
89
+ z.object({ type: z.literal("b"), b: z.string() }),
90
+ ]).parse({ type: "x", a: "abc" });
91
+ throw new Error();
92
+ } catch (e: any) {
93
+ expect(JSON.parse(e.message)).toEqual([
94
+ {
95
+ code: z.ZodIssueCode.invalid_union_discriminator,
96
+ options: ["a", "b"],
97
+ message: "Invalid discriminator value. Expected 'a' | 'b'",
98
+ path: ["type"],
99
+ },
100
+ ]);
101
+ }
102
+ });
103
+
104
+ test("valid discriminator value, invalid data", () => {
105
+ try {
106
+ z.discriminatedUnion("type", [
107
+ z.object({ type: z.literal("a"), a: z.string() }),
108
+ z.object({ type: z.literal("b"), b: z.string() }),
109
+ ]).parse({ type: "a", b: "abc" });
110
+ throw new Error();
111
+ } catch (e: any) {
112
+ expect(JSON.parse(e.message)).toEqual([
113
+ {
114
+ code: z.ZodIssueCode.invalid_type,
115
+ expected: z.ZodParsedType.string,
116
+ message: "Required",
117
+ path: ["a"],
118
+ received: z.ZodParsedType.undefined,
119
+ },
120
+ ]);
121
+ }
122
+ });
123
+
124
+ test("wrong schema - missing discriminator", () => {
125
+ try {
126
+ z.discriminatedUnion("type", [
127
+ z.object({ type: z.literal("a"), a: z.string() }),
128
+ z.object({ b: z.string() }) as any,
129
+ ]);
130
+ throw new Error();
131
+ } catch (e: any) {
132
+ expect(e.message.includes("could not be extracted")).toBe(true);
133
+ }
134
+ });
135
+
136
+ test("wrong schema - duplicate discriminator values", () => {
137
+ try {
138
+ z.discriminatedUnion("type", [
139
+ z.object({ type: z.literal("a"), a: z.string() }),
140
+ z.object({ type: z.literal("a"), b: z.string() }),
141
+ ]);
142
+ throw new Error();
143
+ } catch (e: any) {
144
+ expect(e.message.includes("has duplicate value")).toEqual(true);
145
+ }
146
+ });
147
+
148
+ test("async - valid", async () => {
149
+ expect(
150
+ await z
151
+ .discriminatedUnion("type", [
152
+ z.object({
153
+ type: z.literal("a"),
154
+ a: z
155
+ .string()
156
+ .refine(async () => true)
157
+ .transform(async (val) => Number(val)),
158
+ }),
159
+ z.object({
160
+ type: z.literal("b"),
161
+ b: z.string(),
162
+ }),
163
+ ])
164
+ .parseAsync({ type: "a", a: "1" })
165
+ ).toEqual({ type: "a", a: 1 });
166
+ });
167
+
168
+ test("async - invalid", async () => {
169
+ try {
170
+ await z
171
+ .discriminatedUnion("type", [
172
+ z.object({
173
+ type: z.literal("a"),
174
+ a: z
175
+ .string()
176
+ .refine(async () => true)
177
+ .transform(async (val) => val),
178
+ }),
179
+ z.object({
180
+ type: z.literal("b"),
181
+ b: z.string(),
182
+ }),
183
+ ])
184
+ .parseAsync({ type: "a", a: 1 });
185
+ throw new Error();
186
+ } catch (e: any) {
187
+ expect(JSON.parse(e.message)).toEqual([
188
+ {
189
+ code: "invalid_type",
190
+ expected: "string",
191
+ received: "number",
192
+ path: ["a"],
193
+ message: "Expected string, received number",
194
+ },
195
+ ]);
196
+ }
197
+ });
198
+
199
+ test("valid - literals with .default or .preprocess", () => {
200
+ const schema = z.discriminatedUnion("type", [
201
+ z.object({
202
+ type: z.literal("foo").default("foo"),
203
+ a: z.string(),
204
+ }),
205
+ z.object({
206
+ type: z.literal("custom"),
207
+ method: z.string(),
208
+ }),
209
+ z.object({
210
+ type: z.preprocess((val) => String(val), z.literal("bar")),
211
+ c: z.string(),
212
+ }),
213
+ ]);
214
+ expect(schema.parse({ type: "foo", a: "foo" })).toEqual({
215
+ type: "foo",
216
+ a: "foo",
217
+ });
218
+ });
219
+
220
+ test("enum and nativeEnum", () => {
221
+ enum MyEnum {
222
+ d = 0,
223
+ e = "e",
224
+ }
225
+
226
+ const schema = z.discriminatedUnion("key", [
227
+ z.object({
228
+ key: z.literal("a"),
229
+ // Add other properties specific to this option
230
+ }),
231
+ z.object({
232
+ key: z.enum(["b", "c"]),
233
+ // Add other properties specific to this option
234
+ }),
235
+ z.object({
236
+ key: z.nativeEnum(MyEnum),
237
+ // Add other properties specific to this option
238
+ }),
239
+ ]);
240
+
241
+ // type schema = z.infer<typeof schema>;
242
+
243
+ schema.parse({ key: "a" });
244
+ schema.parse({ key: "b" });
245
+ schema.parse({ key: "c" });
246
+ schema.parse({ key: MyEnum.d });
247
+ schema.parse({ key: MyEnum.e });
248
+ schema.parse({ key: "e" });
249
+ });
250
+
251
+ test("branded", () => {
252
+ const schema = z.discriminatedUnion("key", [
253
+ z.object({
254
+ key: z.literal("a"),
255
+ // Add other properties specific to this option
256
+ }),
257
+ z.object({
258
+ key: z.literal("b").brand("asdfaf"),
259
+ // Add other properties specific to this option
260
+ }),
261
+ ]);
262
+
263
+ // type schema = z.infer<typeof schema>;
264
+
265
+ schema.parse({ key: "a" });
266
+ schema.parse({ key: "b" });
267
+ expect(() => {
268
+ schema.parse({ key: "c" });
269
+ }).toThrow();
270
+ });
271
+
272
+ test("optional and nullable", () => {
273
+ const schema = z.discriminatedUnion("key", [
274
+ z.object({
275
+ key: z.literal("a").optional(),
276
+ a: z.literal(true),
277
+ }),
278
+ z.object({
279
+ key: z.literal("b").nullable(),
280
+ b: z.literal(true),
281
+ // Add other properties specific to this option
282
+ }),
283
+ ]);
284
+
285
+ type schema = z.infer<typeof schema>;
286
+ z.util.assertEqual<schema, { key?: "a" | undefined; a: true } | { key: "b" | null; b: true }>(true);
287
+
288
+ schema.parse({ key: "a", a: true });
289
+ schema.parse({ key: undefined, a: true });
290
+ schema.parse({ key: "b", b: true });
291
+ schema.parse({ key: null, b: true });
292
+ expect(() => {
293
+ schema.parse({ key: null, a: true });
294
+ }).toThrow();
295
+ expect(() => {
296
+ schema.parse({ key: "b", a: true });
297
+ }).toThrow();
298
+
299
+ const value = schema.parse({ key: null, b: true });
300
+
301
+ if (!("key" in value)) value.a;
302
+ if (value.key === undefined) value.a;
303
+ if (value.key === "a") value.a;
304
+ if (value.key === "b") value.b;
305
+ if (value.key === null) value.b;
306
+ });
307
+
308
+ test("readonly array of options", () => {
309
+ const options = [
310
+ z.object({ type: z.literal("x"), val: z.literal(1) }),
311
+ z.object({ type: z.literal("y"), val: z.literal(2) }),
312
+ ] as const;
313
+
314
+ expect(z.discriminatedUnion("type", options).parse({ type: "x", val: 1 })).toEqual({ type: "x", val: 1 });
315
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/enum.test.ts ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ test("create enum", () => {
8
+ const MyEnum = z.enum(["Red", "Green", "Blue"]);
9
+ expect(MyEnum.Values.Red).toEqual("Red");
10
+ expect(MyEnum.Enum.Red).toEqual("Red");
11
+ expect(MyEnum.enum.Red).toEqual("Red");
12
+ });
13
+
14
+ test("infer enum", () => {
15
+ const MyEnum = z.enum(["Red", "Green", "Blue"]);
16
+ type MyEnum = z.infer<typeof MyEnum>;
17
+ util.assertEqual<MyEnum, "Red" | "Green" | "Blue">(true);
18
+ });
19
+
20
+ test("get options", () => {
21
+ expect(z.enum(["tuna", "trout"]).options).toEqual(["tuna", "trout"]);
22
+ });
23
+
24
+ test("readonly enum", () => {
25
+ const HTTP_SUCCESS = ["200", "201"] as const;
26
+ const arg = z.enum(HTTP_SUCCESS);
27
+ type arg = z.infer<typeof arg>;
28
+ util.assertEqual<arg, "200" | "201">(true);
29
+
30
+ arg.parse("201");
31
+ expect(() => arg.parse("202")).toThrow();
32
+ });
33
+
34
+ test("error params", () => {
35
+ const result = z.enum(["test"], { required_error: "REQUIRED" }).safeParse(undefined);
36
+ expect(result.success).toEqual(false);
37
+ if (!result.success) {
38
+ expect(result.error.issues[0].message).toEqual("REQUIRED");
39
+ }
40
+ });
41
+
42
+ test("extract/exclude", () => {
43
+ const foods = ["Pasta", "Pizza", "Tacos", "Burgers", "Salad"] as const;
44
+ const FoodEnum = z.enum(foods);
45
+ const ItalianEnum = FoodEnum.extract(["Pasta", "Pizza"]);
46
+ const UnhealthyEnum = FoodEnum.exclude(["Salad"]);
47
+ const EmptyFoodEnum = FoodEnum.exclude(foods);
48
+
49
+ util.assertEqual<z.infer<typeof ItalianEnum>, "Pasta" | "Pizza">(true);
50
+ util.assertEqual<z.infer<typeof UnhealthyEnum>, "Pasta" | "Pizza" | "Tacos" | "Burgers">(true);
51
+ // @ts-expect-error TS2344
52
+ util.assertEqual<typeof EmptyFoodEnum, z.ZodEnum<[]>>(true);
53
+ util.assertEqual<z.infer<typeof EmptyFoodEnum>, never>(true);
54
+ });
55
+
56
+ test("error map in extract/exclude", () => {
57
+ const foods = ["Pasta", "Pizza", "Tacos", "Burgers", "Salad"] as const;
58
+ const FoodEnum = z.enum(foods, {
59
+ errorMap: () => ({ message: "This is not food!" }),
60
+ });
61
+ const ItalianEnum = FoodEnum.extract(["Pasta", "Pizza"]);
62
+ const foodsError = FoodEnum.safeParse("Cucumbers");
63
+ const italianError = ItalianEnum.safeParse("Tacos");
64
+ if (!foodsError.success && !italianError.success) {
65
+ expect(foodsError.error.issues[0].message).toEqual(italianError.error.issues[0].message);
66
+ }
67
+
68
+ const UnhealthyEnum = FoodEnum.exclude(["Salad"], {
69
+ errorMap: () => ({ message: "This is not healthy food!" }),
70
+ });
71
+ const unhealthyError = UnhealthyEnum.safeParse("Salad");
72
+ if (!unhealthyError.success) {
73
+ expect(unhealthyError.error.issues[0].message).toEqual("This is not healthy food!");
74
+ }
75
+ });
76
+
77
+ test("readonly in ZodEnumDef", () => {
78
+ let _t!: z.ZodEnumDef<readonly ["a", "b"]>;
79
+ _t;
80
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/error.test.ts ADDED
@@ -0,0 +1,551 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { ZodError, ZodIssueCode } from "../ZodError.js";
6
+ import { ZodParsedType } from "../helpers/util.js";
7
+
8
+ test("error creation", () => {
9
+ const err1 = ZodError.create([]);
10
+ err1.addIssue({
11
+ code: ZodIssueCode.invalid_type,
12
+ expected: ZodParsedType.object,
13
+ received: ZodParsedType.string,
14
+ path: [],
15
+ message: "",
16
+ fatal: true,
17
+ });
18
+ err1.isEmpty;
19
+
20
+ const err2 = ZodError.create(err1.issues);
21
+ const err3 = new ZodError([]);
22
+ err3.addIssues(err1.issues);
23
+ err3.addIssue(err1.issues[0]);
24
+ err1.message;
25
+ err2.message;
26
+ err3.message;
27
+ });
28
+
29
+ const errorMap: z.ZodErrorMap = (error, ctx) => {
30
+ if (error.code === ZodIssueCode.invalid_type) {
31
+ if (error.expected === "string") {
32
+ return { message: "bad type!" };
33
+ }
34
+ }
35
+ if (error.code === ZodIssueCode.custom) {
36
+ return { message: `less-than-${error.params?.minimum}` };
37
+ }
38
+ return { message: ctx.defaultError };
39
+ };
40
+
41
+ test("type error with custom error map", () => {
42
+ try {
43
+ z.string().parse(234, { errorMap });
44
+ } catch (err) {
45
+ const zerr: z.ZodError = err as any;
46
+
47
+ expect(zerr.issues[0].code).toEqual(z.ZodIssueCode.invalid_type);
48
+ expect(zerr.issues[0].message).toEqual(`bad type!`);
49
+ }
50
+ });
51
+
52
+ test("refinement fail with params", () => {
53
+ try {
54
+ z.number()
55
+ .refine((val) => val >= 3, {
56
+ params: { minimum: 3 },
57
+ })
58
+ .parse(2, { errorMap });
59
+ } catch (err) {
60
+ const zerr: z.ZodError = err as any;
61
+ expect(zerr.issues[0].code).toEqual(z.ZodIssueCode.custom);
62
+ expect(zerr.issues[0].message).toEqual(`less-than-3`);
63
+ }
64
+ });
65
+
66
+ test("custom error with custom errormap", () => {
67
+ try {
68
+ z.string()
69
+ .refine((val) => val.length > 12, {
70
+ params: { minimum: 13 },
71
+ message: "override",
72
+ })
73
+ .parse("asdf", { errorMap });
74
+ } catch (err) {
75
+ const zerr: z.ZodError = err as any;
76
+ expect(zerr.issues[0].message).toEqual("override");
77
+ }
78
+ });
79
+
80
+ test("default error message", () => {
81
+ try {
82
+ z.number()
83
+ .refine((x) => x > 3)
84
+ .parse(2);
85
+ } catch (err) {
86
+ const zerr: z.ZodError = err as any;
87
+ expect(zerr.issues.length).toEqual(1);
88
+ expect(zerr.issues[0].message).toEqual("Invalid input");
89
+ }
90
+ });
91
+
92
+ test("override error in refine", () => {
93
+ try {
94
+ z.number()
95
+ .refine((x) => x > 3, "override")
96
+ .parse(2);
97
+ } catch (err) {
98
+ const zerr: z.ZodError = err as any;
99
+ expect(zerr.issues.length).toEqual(1);
100
+ expect(zerr.issues[0].message).toEqual("override");
101
+ }
102
+ });
103
+
104
+ test("override error in refinement", () => {
105
+ try {
106
+ z.number()
107
+ .refine((x) => x > 3, {
108
+ message: "override",
109
+ })
110
+ .parse(2);
111
+ } catch (err) {
112
+ const zerr: z.ZodError = err as any;
113
+ expect(zerr.issues.length).toEqual(1);
114
+ expect(zerr.issues[0].message).toEqual("override");
115
+ }
116
+ });
117
+
118
+ test("array minimum", () => {
119
+ try {
120
+ z.array(z.string()).min(3, "tooshort").parse(["asdf", "qwer"]);
121
+ } catch (err) {
122
+ const zerr: ZodError = err as any;
123
+ expect(zerr.issues[0].code).toEqual(ZodIssueCode.too_small);
124
+ expect(zerr.issues[0].message).toEqual("tooshort");
125
+ }
126
+ try {
127
+ z.array(z.string()).min(3).parse(["asdf", "qwer"]);
128
+ } catch (err) {
129
+ const zerr: ZodError = err as any;
130
+ expect(zerr.issues[0].code).toEqual(ZodIssueCode.too_small);
131
+ expect(zerr.issues[0].message).toEqual(`Array must contain at least 3 element(s)`);
132
+ }
133
+ });
134
+
135
+ // implement test for semi-smart union logic that checks for type error on either left or right
136
+ // test("union smart errors", () => {
137
+ // // expect.assertions(2);
138
+
139
+ // const p1 = z
140
+ // .union([z.string(), z.number().refine((x) => x > 0)])
141
+ // .safeParse(-3.2);
142
+
143
+ // if (p1.success === true) throw new Error();
144
+ // expect(p1.success).toBe(false);
145
+ // expect(p1.error.issues[0].code).toEqual(ZodIssueCode.custom);
146
+
147
+ // const p2 = z.union([z.string(), z.number()]).safeParse(false);
148
+ // // .catch(err => expect(err.issues[0].code).toEqual(ZodIssueCode.invalid_union));
149
+ // if (p2.success === true) throw new Error();
150
+ // expect(p2.success).toBe(false);
151
+ // expect(p2.error.issues[0].code).toEqual(ZodIssueCode.invalid_union);
152
+ // });
153
+
154
+ test("custom path in custom error map", () => {
155
+ const schema = z.object({
156
+ items: z.array(z.string()).refine((data) => data.length > 3, {
157
+ path: ["items-too-few"],
158
+ }),
159
+ });
160
+
161
+ const errorMap: z.ZodErrorMap = (error) => {
162
+ expect(error.path.length).toBe(2);
163
+ return { message: "doesnt matter" };
164
+ };
165
+ const result = schema.safeParse({ items: ["first"] }, { errorMap });
166
+ expect(result.success).toEqual(false);
167
+ if (!result.success) {
168
+ expect(result.error.issues[0].path).toEqual(["items", "items-too-few"]);
169
+ }
170
+ });
171
+
172
+ test("error metadata from value", () => {
173
+ const dynamicRefine = z.string().refine(
174
+ (val) => val === val.toUpperCase(),
175
+ (val) => ({ params: { val } })
176
+ );
177
+
178
+ const result = dynamicRefine.safeParse("asdf");
179
+ expect(result.success).toEqual(false);
180
+ if (!result.success) {
181
+ const sub = result.error.issues[0];
182
+ expect(result.error.issues[0].code).toEqual("custom");
183
+ if (sub.code === "custom") {
184
+ expect(sub.params!.val).toEqual("asdf");
185
+ }
186
+ }
187
+ });
188
+
189
+ // test("don't call refine after validation failed", () => {
190
+ // const asdf = z
191
+ // .union([
192
+ // z.number(),
193
+ // z.string().transform(z.number(), (val) => {
194
+ // return parseFloat(val);
195
+ // }),
196
+ // ])
197
+ // .refine((v) => v >= 1);
198
+
199
+ // expect(() => asdf.safeParse("foo")).not.toThrow();
200
+ // });
201
+
202
+ test("root level formatting", () => {
203
+ const schema = z.string().email();
204
+ const result = schema.safeParse("asdfsdf");
205
+ expect(result.success).toEqual(false);
206
+ if (!result.success) {
207
+ expect(result.error.format()._errors).toEqual(["Invalid email"]);
208
+ }
209
+ });
210
+
211
+ test("custom path", () => {
212
+ const schema = z
213
+ .object({
214
+ password: z.string(),
215
+ confirm: z.string(),
216
+ })
217
+ .refine((val) => val.confirm === val.password, { path: ["confirm"] });
218
+
219
+ const result = schema.safeParse({
220
+ password: "peanuts",
221
+ confirm: "qeanuts",
222
+ });
223
+
224
+ expect(result.success).toEqual(false);
225
+ if (!result.success) {
226
+ // nested errors
227
+ const error = result.error.format();
228
+ expect(error._errors).toEqual([]);
229
+ expect(error.password?._errors).toEqual(undefined);
230
+ expect(error.confirm?._errors).toEqual(["Invalid input"]);
231
+ }
232
+ });
233
+
234
+ test("custom path", () => {
235
+ const schema = z
236
+ .object({
237
+ password: z.string().min(6),
238
+ confirm: z.string().min(6),
239
+ })
240
+ .refine((val) => val.confirm === val.password);
241
+
242
+ const result = schema.safeParse({
243
+ password: "qwer",
244
+ confirm: "asdf",
245
+ });
246
+
247
+ expect(result.success).toEqual(false);
248
+ if (!result.success) {
249
+ expect(result.error.issues.length).toEqual(3);
250
+ }
251
+ });
252
+
253
+ const schema = z.object({
254
+ inner: z.object({
255
+ name: z
256
+ .string()
257
+ .refine((val) => val.length > 5)
258
+ .array()
259
+ .refine((val) => val.length <= 1),
260
+ }),
261
+ });
262
+
263
+ test("no abort early on refinements", () => {
264
+ const invalidItem = {
265
+ inner: { name: ["aasd", "asdfasdfasfd"] },
266
+ };
267
+
268
+ const result1 = schema.safeParse(invalidItem);
269
+ expect(result1.success).toEqual(false);
270
+ if (!result1.success) {
271
+ expect(result1.error.issues.length).toEqual(2);
272
+ }
273
+ });
274
+ test("formatting", () => {
275
+ const invalidItem = {
276
+ inner: { name: ["aasd", "asdfasdfasfd"] },
277
+ };
278
+ const invalidArray = {
279
+ inner: { name: ["asdfasdf", "asdfasdfasfd"] },
280
+ };
281
+ const result1 = schema.safeParse(invalidItem);
282
+ const result2 = schema.safeParse(invalidArray);
283
+
284
+ expect(result1.success).toEqual(false);
285
+ expect(result2.success).toEqual(false);
286
+ if (!result1.success) {
287
+ const error = result1.error.format();
288
+
289
+ expect(error._errors).toEqual([]);
290
+ expect(error.inner?._errors).toEqual([]);
291
+ // expect(error.inner?.name?._errors).toEqual(["Invalid input"]);
292
+ // expect(error.inner?.name?.[0]._errors).toEqual(["Invalid input"]);
293
+ expect(error.inner?.name?.[1]).toEqual(undefined);
294
+ }
295
+ if (!result2.success) {
296
+ type FormattedError = z.inferFormattedError<typeof schema>;
297
+ const error: FormattedError = result2.error.format();
298
+ expect(error._errors).toEqual([]);
299
+ expect(error.inner?._errors).toEqual([]);
300
+ expect(error.inner?.name?._errors).toEqual(["Invalid input"]);
301
+ expect(error.inner?.name?.[0]).toEqual(undefined);
302
+ expect(error.inner?.name?.[1]).toEqual(undefined);
303
+ expect(error.inner?.name?.[2]).toEqual(undefined);
304
+ }
305
+
306
+ // test custom mapper
307
+ if (!result2.success) {
308
+ type FormattedError = z.inferFormattedError<typeof schema, number>;
309
+ const error: FormattedError = result2.error.format(() => 5);
310
+ expect(error._errors).toEqual([]);
311
+ expect(error.inner?._errors).toEqual([]);
312
+ expect(error.inner?.name?._errors).toEqual([5]);
313
+ }
314
+ });
315
+
316
+ test("formatting with nullable and optional fields", () => {
317
+ const nameSchema = z.string().refine((val) => val.length > 5);
318
+ const schema = z.object({
319
+ nullableObject: z.object({ name: nameSchema }).nullable(),
320
+ nullableArray: z.array(nameSchema).nullable(),
321
+ nullableTuple: z.tuple([nameSchema, nameSchema, z.number()]).nullable(),
322
+ optionalObject: z.object({ name: nameSchema }).optional(),
323
+ optionalArray: z.array(nameSchema).optional(),
324
+ optionalTuple: z.tuple([nameSchema, nameSchema, z.number()]).optional(),
325
+ });
326
+ const invalidItem = {
327
+ nullableObject: { name: "abcd" },
328
+ nullableArray: ["abcd"],
329
+ nullableTuple: ["abcd", "abcd", 1],
330
+ optionalObject: { name: "abcd" },
331
+ optionalArray: ["abcd"],
332
+ optionalTuple: ["abcd", "abcd", 1],
333
+ };
334
+ const result = schema.safeParse(invalidItem);
335
+ expect(result.success).toEqual(false);
336
+ if (!result.success) {
337
+ type FormattedError = z.inferFormattedError<typeof schema>;
338
+ const error: FormattedError = result.error.format();
339
+ expect(error._errors).toEqual([]);
340
+ expect(error.nullableObject?._errors).toEqual([]);
341
+ expect(error.nullableObject?.name?._errors).toEqual(["Invalid input"]);
342
+ expect(error.nullableArray?._errors).toEqual([]);
343
+ expect(error.nullableArray?.[0]?._errors).toEqual(["Invalid input"]);
344
+ expect(error.nullableTuple?._errors).toEqual([]);
345
+ expect(error.nullableTuple?.[0]?._errors).toEqual(["Invalid input"]);
346
+ expect(error.nullableTuple?.[1]?._errors).toEqual(["Invalid input"]);
347
+ expect(error.optionalObject?._errors).toEqual([]);
348
+ expect(error.optionalObject?.name?._errors).toEqual(["Invalid input"]);
349
+ expect(error.optionalArray?._errors).toEqual([]);
350
+ expect(error.optionalArray?.[0]?._errors).toEqual(["Invalid input"]);
351
+ expect(error.optionalTuple?._errors).toEqual([]);
352
+ expect(error.optionalTuple?.[0]?._errors).toEqual(["Invalid input"]);
353
+ expect(error.optionalTuple?.[1]?._errors).toEqual(["Invalid input"]);
354
+ }
355
+ });
356
+
357
+ const stringWithCustomError = z.string({
358
+ errorMap: (issue, ctx) => ({
359
+ message: issue.code === "invalid_type" ? (ctx.data ? "Invalid name" : "Name is required") : ctx.defaultError,
360
+ }),
361
+ });
362
+
363
+ test("schema-bound error map", () => {
364
+ const result = stringWithCustomError.safeParse(1234);
365
+ expect(result.success).toEqual(false);
366
+ if (!result.success) {
367
+ expect(result.error.issues[0].message).toEqual("Invalid name");
368
+ }
369
+
370
+ const result2 = stringWithCustomError.safeParse(undefined);
371
+ expect(result2.success).toEqual(false);
372
+ if (!result2.success) {
373
+ expect(result2.error.issues[0].message).toEqual("Name is required");
374
+ }
375
+
376
+ // support contextual override
377
+ const result3 = stringWithCustomError.safeParse(undefined, {
378
+ errorMap: () => ({ message: "OVERRIDE" }),
379
+ });
380
+ expect(result3.success).toEqual(false);
381
+ if (!result3.success) {
382
+ expect(result3.error.issues[0].message).toEqual("OVERRIDE");
383
+ }
384
+ });
385
+
386
+ test("overrideErrorMap", () => {
387
+ // support overrideErrorMap
388
+ z.setErrorMap(() => ({ message: "OVERRIDE" }));
389
+ const result4 = stringWithCustomError.min(10).safeParse("tooshort");
390
+ expect(result4.success).toEqual(false);
391
+ if (!result4.success) {
392
+ expect(result4.error.issues[0].message).toEqual("OVERRIDE");
393
+ }
394
+ z.setErrorMap(z.defaultErrorMap);
395
+ });
396
+
397
+ test("invalid and required", () => {
398
+ const str = z.string({
399
+ invalid_type_error: "Invalid name",
400
+ required_error: "Name is required",
401
+ });
402
+ const result1 = str.safeParse(1234);
403
+ expect(result1.success).toEqual(false);
404
+ if (!result1.success) {
405
+ expect(result1.error.issues[0].message).toEqual("Invalid name");
406
+ }
407
+ const result2 = str.safeParse(undefined);
408
+ expect(result2.success).toEqual(false);
409
+ if (!result2.success) {
410
+ expect(result2.error.issues[0].message).toEqual("Name is required");
411
+ }
412
+ });
413
+
414
+ test("Fallback to default required error", () => {
415
+ const str = z.string({
416
+ invalid_type_error: "Invalid name",
417
+ // required_error: "Name is required",
418
+ });
419
+
420
+ const result2 = str.safeParse(undefined);
421
+ expect(result2.success).toEqual(false);
422
+ if (!result2.success) {
423
+ expect(result2.error.issues[0].message).toEqual("Required");
424
+ }
425
+ });
426
+
427
+ test("invalid and required and errorMap", () => {
428
+ expect(() => {
429
+ return z.string({
430
+ invalid_type_error: "Invalid name",
431
+ required_error: "Name is required",
432
+ errorMap: () => ({ message: "OVERRIDE" }),
433
+ });
434
+ }).toThrow();
435
+ });
436
+
437
+ test("strict error message", () => {
438
+ const errorMsg = "Invalid object";
439
+ const obj = z.object({ x: z.string() }).strict(errorMsg);
440
+ const result = obj.safeParse({ x: "a", y: "b" });
441
+ expect(result.success).toEqual(false);
442
+ if (!result.success) {
443
+ expect(result.error.issues[0].message).toEqual(errorMsg);
444
+ }
445
+ });
446
+
447
+ test("enum error message, invalid enum elementstring", () => {
448
+ try {
449
+ z.enum(["Tuna", "Trout"]).parse("Salmon");
450
+ } catch (err) {
451
+ const zerr: z.ZodError = err as any;
452
+ expect(zerr.issues.length).toEqual(1);
453
+ expect(zerr.issues[0].message).toEqual("Invalid enum value. Expected 'Tuna' | 'Trout', received 'Salmon'");
454
+ }
455
+ });
456
+
457
+ test("enum error message, invalid type", () => {
458
+ try {
459
+ z.enum(["Tuna", "Trout"]).parse(12);
460
+ } catch (err) {
461
+ const zerr: z.ZodError = err as any;
462
+ expect(zerr.issues.length).toEqual(1);
463
+ expect(zerr.issues[0].message).toEqual("Expected 'Tuna' | 'Trout', received number");
464
+ }
465
+ });
466
+
467
+ test("nativeEnum default error message", () => {
468
+ enum Fish {
469
+ Tuna = "Tuna",
470
+ Trout = "Trout",
471
+ }
472
+ try {
473
+ z.nativeEnum(Fish).parse("Salmon");
474
+ } catch (err) {
475
+ const zerr: z.ZodError = err as any;
476
+ expect(zerr.issues.length).toEqual(1);
477
+ expect(zerr.issues[0].message).toEqual("Invalid enum value. Expected 'Tuna' | 'Trout', received 'Salmon'");
478
+ }
479
+ });
480
+
481
+ test("literal default error message", () => {
482
+ try {
483
+ z.literal("Tuna").parse("Trout");
484
+ } catch (err) {
485
+ const zerr: z.ZodError = err as any;
486
+ expect(zerr.issues.length).toEqual(1);
487
+ expect(zerr.issues[0].message).toEqual(`Invalid literal value, expected "Tuna"`);
488
+ }
489
+ });
490
+
491
+ test("literal bigint default error message", () => {
492
+ try {
493
+ z.literal(BigInt(12)).parse(BigInt(13));
494
+ } catch (err) {
495
+ const zerr: z.ZodError = err as any;
496
+ expect(zerr.issues.length).toEqual(1);
497
+ expect(zerr.issues[0].message).toEqual(`Invalid literal value, expected "12"`);
498
+ }
499
+ });
500
+
501
+ test("enum with message returns the custom error message", () => {
502
+ const schema = z.enum(["apple", "banana"], {
503
+ message: "the value provided is invalid",
504
+ });
505
+
506
+ const result1 = schema.safeParse("berries");
507
+ expect(result1.success).toEqual(false);
508
+ if (!result1.success) {
509
+ expect(result1.error.issues[0].message).toEqual("the value provided is invalid");
510
+ }
511
+
512
+ const result2 = schema.safeParse(undefined);
513
+ expect(result2.success).toEqual(false);
514
+ if (!result2.success) {
515
+ expect(result2.error.issues[0].message).toEqual("the value provided is invalid");
516
+ }
517
+
518
+ const result3 = schema.safeParse("banana");
519
+ expect(result3.success).toEqual(true);
520
+
521
+ const result4 = schema.safeParse(null);
522
+ expect(result4.success).toEqual(false);
523
+ if (!result4.success) {
524
+ expect(result4.error.issues[0].message).toEqual("the value provided is invalid");
525
+ }
526
+ });
527
+
528
+ test("when the message is falsy, it is used as is provided", () => {
529
+ const schema = z.string().max(1, { message: "" });
530
+ const result = schema.safeParse("asdf");
531
+ expect(result.success).toEqual(false);
532
+ if (!result.success) {
533
+ expect(result.error.issues[0].message).toEqual("");
534
+ }
535
+ });
536
+
537
+ // test("dont short circuit on continuable errors", () => {
538
+ // const user = z
539
+ // .object({
540
+ // password: z.string().min(6),
541
+ // confirm: z.string(),
542
+ // })
543
+ // .refine((data) => data.password === data.confirm, {
544
+ // message: "Passwords don't match",
545
+ // path: ["confirm"],
546
+ // });
547
+ // const result = user.safeParse({ password: "asdf", confirm: "qwer" });
548
+ // if (!result.success) {
549
+ // expect(result.error.issues.length).toEqual(2);
550
+ // }
551
+ // });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/firstparty.test.ts ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ test("first party switch", () => {
8
+ const myType = z.string() as z.ZodFirstPartySchemaTypes;
9
+ const def = myType._def;
10
+
11
+ switch (def.typeName) {
12
+ case z.ZodFirstPartyTypeKind.ZodString:
13
+ break;
14
+ case z.ZodFirstPartyTypeKind.ZodNumber:
15
+ break;
16
+ case z.ZodFirstPartyTypeKind.ZodNaN:
17
+ break;
18
+ case z.ZodFirstPartyTypeKind.ZodBigInt:
19
+ break;
20
+ case z.ZodFirstPartyTypeKind.ZodBoolean:
21
+ break;
22
+ case z.ZodFirstPartyTypeKind.ZodDate:
23
+ break;
24
+ case z.ZodFirstPartyTypeKind.ZodUndefined:
25
+ break;
26
+ case z.ZodFirstPartyTypeKind.ZodNull:
27
+ break;
28
+ case z.ZodFirstPartyTypeKind.ZodAny:
29
+ break;
30
+ case z.ZodFirstPartyTypeKind.ZodUnknown:
31
+ break;
32
+ case z.ZodFirstPartyTypeKind.ZodNever:
33
+ break;
34
+ case z.ZodFirstPartyTypeKind.ZodVoid:
35
+ break;
36
+ case z.ZodFirstPartyTypeKind.ZodArray:
37
+ break;
38
+ case z.ZodFirstPartyTypeKind.ZodObject:
39
+ break;
40
+ case z.ZodFirstPartyTypeKind.ZodUnion:
41
+ break;
42
+ case z.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
43
+ break;
44
+ case z.ZodFirstPartyTypeKind.ZodIntersection:
45
+ break;
46
+ case z.ZodFirstPartyTypeKind.ZodTuple:
47
+ break;
48
+ case z.ZodFirstPartyTypeKind.ZodRecord:
49
+ break;
50
+ case z.ZodFirstPartyTypeKind.ZodMap:
51
+ break;
52
+ case z.ZodFirstPartyTypeKind.ZodSet:
53
+ break;
54
+ case z.ZodFirstPartyTypeKind.ZodFunction:
55
+ break;
56
+ case z.ZodFirstPartyTypeKind.ZodLazy:
57
+ break;
58
+ case z.ZodFirstPartyTypeKind.ZodLiteral:
59
+ break;
60
+ case z.ZodFirstPartyTypeKind.ZodEnum:
61
+ break;
62
+ case z.ZodFirstPartyTypeKind.ZodEffects:
63
+ break;
64
+ case z.ZodFirstPartyTypeKind.ZodNativeEnum:
65
+ break;
66
+ case z.ZodFirstPartyTypeKind.ZodOptional:
67
+ break;
68
+ case z.ZodFirstPartyTypeKind.ZodNullable:
69
+ break;
70
+ case z.ZodFirstPartyTypeKind.ZodDefault:
71
+ break;
72
+ case z.ZodFirstPartyTypeKind.ZodCatch:
73
+ break;
74
+ case z.ZodFirstPartyTypeKind.ZodPromise:
75
+ break;
76
+ case z.ZodFirstPartyTypeKind.ZodBranded:
77
+ break;
78
+ case z.ZodFirstPartyTypeKind.ZodPipeline:
79
+ break;
80
+ case z.ZodFirstPartyTypeKind.ZodSymbol:
81
+ break;
82
+ case z.ZodFirstPartyTypeKind.ZodReadonly:
83
+ break;
84
+ default:
85
+ util.assertNever(def);
86
+ }
87
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { test } from "vitest";
3
+
4
+ import type { ZodFirstPartySchemaTypes, ZodFirstPartyTypeKind } from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ test("Identify missing [ZodFirstPartySchemaTypes]", () => {
8
+ type ZodFirstPartySchemaForType<T extends ZodFirstPartyTypeKind> = ZodFirstPartySchemaTypes extends infer Schema
9
+ ? Schema extends { _def: { typeName: T } }
10
+ ? Schema
11
+ : never
12
+ : never;
13
+ type ZodMappedTypes = {
14
+ [key in ZodFirstPartyTypeKind]: ZodFirstPartySchemaForType<key>;
15
+ };
16
+ type ZodFirstPartySchemaTypesMissingFromUnion = keyof {
17
+ [key in keyof ZodMappedTypes as ZodMappedTypes[key] extends { _def: never } ? key : never]: unknown;
18
+ };
19
+
20
+ util.assertEqual<ZodFirstPartySchemaTypesMissingFromUnion, never>(true);
21
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/function.test.ts ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ const args1 = z.tuple([z.string()]);
8
+ const returns1 = z.number();
9
+ const func1 = z.function(args1, returns1);
10
+
11
+ test("function parsing", () => {
12
+ const parsed = func1.parse((arg: any) => arg.length);
13
+ parsed("asdf");
14
+ });
15
+
16
+ test("parsed function fail 1", () => {
17
+ const parsed = func1.parse((x: string) => x);
18
+ expect(() => parsed("asdf")).toThrow();
19
+ });
20
+
21
+ test("parsed function fail 2", () => {
22
+ const parsed = func1.parse((x: string) => x);
23
+ expect(() => parsed(13 as any)).toThrow();
24
+ });
25
+
26
+ test("function inference 1", () => {
27
+ type func1 = z.TypeOf<typeof func1>;
28
+ util.assertEqual<func1, (k: string) => number>(true);
29
+ });
30
+
31
+ test("method parsing", () => {
32
+ const methodObject = z.object({
33
+ property: z.number(),
34
+ method: z.function().args(z.string()).returns(z.number()),
35
+ });
36
+ const methodInstance = {
37
+ property: 3,
38
+ method: function (s: string) {
39
+ return s.length + this.property;
40
+ },
41
+ };
42
+ const parsed = methodObject.parse(methodInstance);
43
+ expect(parsed.method("length=8")).toBe(11); // 8 length + 3 property
44
+ });
45
+
46
+ test("async method parsing", async () => {
47
+ const methodObject = z.object({
48
+ property: z.number(),
49
+ method: z.function().args(z.string()).returns(z.promise(z.number())),
50
+ });
51
+ const methodInstance = {
52
+ property: 3,
53
+ method: async function (s: string) {
54
+ return s.length + this.property;
55
+ },
56
+ };
57
+ const parsed = methodObject.parse(methodInstance);
58
+ expect(await parsed.method("length=8")).toBe(11); // 8 length + 3 property
59
+ });
60
+
61
+ test("args method", () => {
62
+ const t1 = z.function();
63
+ type t1 = z.infer<typeof t1>;
64
+ util.assertEqual<t1, (...args_1: unknown[]) => unknown>(true);
65
+
66
+ const t2 = t1.args(z.string());
67
+ type t2 = z.infer<typeof t2>;
68
+ util.assertEqual<t2, (arg: string, ...args_1: unknown[]) => unknown>(true);
69
+
70
+ const t3 = t2.returns(z.boolean());
71
+ type t3 = z.infer<typeof t3>;
72
+ util.assertEqual<t3, (arg: string, ...args_1: unknown[]) => boolean>(true);
73
+ });
74
+
75
+ const args2 = z.tuple([
76
+ z.object({
77
+ f1: z.number(),
78
+ f2: z.string().nullable(),
79
+ f3: z.array(z.boolean().optional()).optional(),
80
+ }),
81
+ ]);
82
+ const returns2 = z.union([z.string(), z.number()]);
83
+
84
+ const func2 = z.function(args2, returns2);
85
+
86
+ test("function inference 2", () => {
87
+ type func2 = z.TypeOf<typeof func2>;
88
+ util.assertEqual<
89
+ func2,
90
+ (arg: {
91
+ f1: number;
92
+ f2: string | null;
93
+ f3?: (boolean | undefined)[] | undefined;
94
+ }) => string | number
95
+ >(true);
96
+ });
97
+
98
+ test("valid function run", () => {
99
+ const validFunc2Instance = func2.validate((_x) => {
100
+ return "adf" as any;
101
+ });
102
+
103
+ const checker = () => {
104
+ validFunc2Instance({
105
+ f1: 21,
106
+ f2: "asdf",
107
+ f3: [true, false],
108
+ });
109
+ };
110
+
111
+ checker();
112
+ });
113
+
114
+ test("input validation error", () => {
115
+ const invalidFuncInstance = func2.validate((_x) => {
116
+ return "adf" as any;
117
+ });
118
+
119
+ const checker = () => {
120
+ invalidFuncInstance("Invalid_input" as any);
121
+ };
122
+
123
+ expect(checker).toThrow();
124
+ });
125
+
126
+ test("output validation error", () => {
127
+ const invalidFuncInstance = func2.validate((_x) => {
128
+ return ["this", "is", "not", "valid", "output"] as any;
129
+ });
130
+
131
+ const checker = () => {
132
+ invalidFuncInstance({
133
+ f1: 21,
134
+ f2: "asdf",
135
+ f3: [true, false],
136
+ });
137
+ };
138
+
139
+ expect(checker).toThrow();
140
+ });
141
+
142
+ z.function(z.tuple([z.string()])).args()._def.args;
143
+
144
+ test("special function error codes", () => {
145
+ const checker = z.function(z.tuple([z.string()]), z.boolean()).implement((arg) => {
146
+ return arg.length as any;
147
+ });
148
+ try {
149
+ checker("12" as any);
150
+ } catch (err) {
151
+ const zerr = err as z.ZodError;
152
+ const first = zerr.issues[0];
153
+ if (first.code !== z.ZodIssueCode.invalid_return_type) throw new Error();
154
+
155
+ expect(first.returnTypeError).toBeInstanceOf(z.ZodError);
156
+ }
157
+
158
+ try {
159
+ checker(12 as any);
160
+ } catch (err) {
161
+ const zerr = err as z.ZodError;
162
+ const first = zerr.issues[0];
163
+ if (first.code !== z.ZodIssueCode.invalid_arguments) throw new Error();
164
+ expect(first.argumentsError).toBeInstanceOf(z.ZodError);
165
+ }
166
+ });
167
+
168
+ test("function with async refinements", async () => {
169
+ const func = z
170
+ .function()
171
+ .args(z.string().refine(async (val) => val.length > 10))
172
+ .returns(z.promise(z.number().refine(async (val) => val > 10)))
173
+ .implement(async (val) => {
174
+ return val.length;
175
+ });
176
+ const results = [];
177
+ try {
178
+ await func("asdfasdf");
179
+ results.push("success");
180
+ } catch (_err) {
181
+ results.push("fail");
182
+ }
183
+ try {
184
+ await func("asdflkjasdflkjsf");
185
+ results.push("success");
186
+ } catch (_err) {
187
+ results.push("fail");
188
+ }
189
+
190
+ expect(results).toEqual(["fail", "success"]);
191
+ });
192
+
193
+ test("non async function with async refinements should fail", async () => {
194
+ const func = z
195
+ .function()
196
+ .args(z.string().refine(async (val) => val.length > 10))
197
+ .returns(z.number().refine(async (val) => val > 10))
198
+ .implement((val) => {
199
+ return val.length;
200
+ });
201
+
202
+ const results = [];
203
+ try {
204
+ await func("asdasdfasdffasdf");
205
+ results.push("success");
206
+ } catch (_err) {
207
+ results.push("fail");
208
+ }
209
+
210
+ expect(results).toEqual(["fail"]);
211
+ });
212
+
213
+ test("allow extra parameters", () => {
214
+ const maxLength5 = z
215
+ .function()
216
+ .args(z.string())
217
+ .returns(z.boolean())
218
+ .implement((str, _arg, _qewr) => {
219
+ return str.length <= 5;
220
+ });
221
+
222
+ const filteredList = ["apple", "orange", "pear", "banana", "strawberry"].filter(maxLength5);
223
+ expect(filteredList.length).toEqual(2);
224
+ });
225
+
226
+ test("params and returnType getters", () => {
227
+ const func = z.function().args(z.string()).returns(z.string());
228
+
229
+ func.parameters().items[0].parse("asdf");
230
+ func.returnType().parse("asdf");
231
+ });
232
+
233
+ test("inference with transforms", () => {
234
+ const funcSchema = z
235
+ .function()
236
+ .args(z.string().transform((val) => val.length))
237
+ .returns(z.object({ val: z.number() }));
238
+ const myFunc = funcSchema.implement((val) => {
239
+ return { val, extra: "stuff" };
240
+ });
241
+ myFunc("asdf");
242
+
243
+ util.assertEqual<typeof myFunc, (arg: string, ...args_1: unknown[]) => { val: number; extra: string }>(true);
244
+ });
245
+
246
+ test("fallback to OuterTypeOfFunction", () => {
247
+ const funcSchema = z
248
+ .function()
249
+ .args(z.string().transform((val) => val.length))
250
+ .returns(z.object({ arg: z.number() }).transform((val) => val.arg));
251
+
252
+ const myFunc = funcSchema.implement((val) => {
253
+ return { arg: val, arg2: false };
254
+ });
255
+
256
+ util.assertEqual<typeof myFunc, (arg: string, ...args_1: unknown[]) => number>(true);
257
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/generics.test.ts ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ test("generics", () => {
8
+ async function stripOuter<TData extends z.ZodTypeAny>(schema: TData, data: unknown) {
9
+ return z
10
+ .object({
11
+ nested: schema, // as z.ZodTypeAny,
12
+ })
13
+ .transform((data) => {
14
+ return data.nested!;
15
+ })
16
+ .parse({ nested: data });
17
+ }
18
+
19
+ const result = stripOuter(z.object({ a: z.string() }), { a: "asdf" });
20
+ util.assertEqual<typeof result, Promise<{ a: string }>>(true);
21
+ });
22
+
23
+ // test("assignability", () => {
24
+ // const createSchemaAndParse = <K extends string, VS extends z.ZodString>(
25
+ // key: K,
26
+ // valueSchema: VS,
27
+ // data: unknown
28
+ // ) => {
29
+ // const schema = z.object({
30
+ // [key]: valueSchema,
31
+ // } as { [k in K]: VS });
32
+ // return { [key]: valueSchema };
33
+ // const parsed = schema.parse(data);
34
+ // return parsed;
35
+ // // const inferred: z.infer<z.ZodObject<{ [k in K]: VS }>> = parsed;
36
+ // // return inferred;
37
+ // };
38
+ // const parsed = createSchemaAndParse("foo", z.string(), { foo: "" });
39
+ // util.assertEqual<typeof parsed, { foo: string }>(true);
40
+ // });
41
+
42
+ test("nested no undefined", () => {
43
+ const inner = z.string().or(z.array(z.string()));
44
+ const outer = z.object({ inner });
45
+ type outerSchema = z.infer<typeof outer>;
46
+ z.util.assertEqual<outerSchema, { inner: string | string[] }>(true);
47
+ expect(outer.safeParse({ inner: undefined }).success).toEqual(false);
48
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/instanceof.test.ts ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ test("instanceof", async () => {
8
+ class Test {}
9
+ class Subtest extends Test {}
10
+ abstract class AbstractBar {
11
+ constructor(public val: string) {}
12
+ }
13
+ class Bar extends AbstractBar {}
14
+
15
+ const TestSchema = z.instanceof(Test);
16
+ const SubtestSchema = z.instanceof(Subtest);
17
+ const AbstractSchema = z.instanceof(AbstractBar);
18
+ const BarSchema = z.instanceof(Bar);
19
+
20
+ TestSchema.parse(new Test());
21
+ TestSchema.parse(new Subtest());
22
+ SubtestSchema.parse(new Subtest());
23
+ AbstractSchema.parse(new Bar("asdf"));
24
+ const bar = BarSchema.parse(new Bar("asdf"));
25
+ expect(bar.val).toEqual("asdf");
26
+
27
+ await expect(() => SubtestSchema.parse(new Test())).toThrow(/Input not instance of Subtest/);
28
+ await expect(() => TestSchema.parse(12)).toThrow(/Input not instance of Test/);
29
+
30
+ util.assertEqual<Test, z.infer<typeof TestSchema>>(true);
31
+ });
32
+
33
+ test("instanceof fatal", () => {
34
+ const schema = z.instanceof(Date).refine((d) => d.toString());
35
+ const res = schema.safeParse(null);
36
+ expect(res.success).toBe(false);
37
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/intersection.test.ts ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ test("object intersection", () => {
7
+ const BaseTeacher = z.object({
8
+ subjects: z.array(z.string()),
9
+ });
10
+ const HasID = z.object({ id: z.string() });
11
+
12
+ const Teacher = z.intersection(BaseTeacher.passthrough(), HasID); // BaseTeacher.merge(HasID);
13
+ const data = {
14
+ subjects: ["math"],
15
+ id: "asdfasdf",
16
+ };
17
+ expect(Teacher.parse(data)).toEqual(data);
18
+ expect(() => Teacher.parse({ subject: data.subjects })).toThrow();
19
+ expect(Teacher.parse({ ...data, extra: 12 })).toEqual({ ...data, extra: 12 });
20
+
21
+ expect(() => z.intersection(BaseTeacher.strict(), HasID).parse({ ...data, extra: 12 })).toThrow();
22
+ });
23
+
24
+ test("deep intersection", () => {
25
+ const Animal = z.object({
26
+ properties: z.object({
27
+ is_animal: z.boolean(),
28
+ }),
29
+ });
30
+ const Cat = z
31
+ .object({
32
+ properties: z.object({
33
+ jumped: z.boolean(),
34
+ }),
35
+ })
36
+ .and(Animal);
37
+
38
+ type _Cat = z.infer<typeof Cat>;
39
+ // const cat:Cat = 'asdf' as any;
40
+ const cat = Cat.parse({ properties: { is_animal: true, jumped: true } });
41
+ expect(cat.properties).toEqual({ is_animal: true, jumped: true });
42
+ });
43
+
44
+ test("deep intersection of arrays", async () => {
45
+ const Author = z.object({
46
+ posts: z.array(
47
+ z.object({
48
+ post_id: z.number(),
49
+ })
50
+ ),
51
+ });
52
+ const Registry = z
53
+ .object({
54
+ posts: z.array(
55
+ z.object({
56
+ title: z.string(),
57
+ })
58
+ ),
59
+ })
60
+ .and(Author);
61
+
62
+ const posts = [
63
+ { post_id: 1, title: "Novels" },
64
+ { post_id: 2, title: "Fairy tales" },
65
+ ];
66
+ const cat = Registry.parse({ posts });
67
+ expect(cat.posts).toEqual(posts);
68
+ const asyncCat = await Registry.parseAsync({ posts });
69
+ expect(asyncCat.posts).toEqual(posts);
70
+ });
71
+
72
+ test("invalid intersection types", async () => {
73
+ const numberIntersection = z.intersection(
74
+ z.number(),
75
+ z.number().transform((x) => x + 1)
76
+ );
77
+
78
+ const syncResult = numberIntersection.safeParse(1234);
79
+ expect(syncResult.success).toEqual(false);
80
+ if (!syncResult.success) {
81
+ expect(syncResult.error.issues[0].code).toEqual(z.ZodIssueCode.invalid_intersection_types);
82
+ }
83
+
84
+ const asyncResult = await numberIntersection.spa(1234);
85
+ expect(asyncResult.success).toEqual(false);
86
+ if (!asyncResult.success) {
87
+ expect(asyncResult.error.issues[0].code).toEqual(z.ZodIssueCode.invalid_intersection_types);
88
+ }
89
+ });
90
+
91
+ test("invalid array merge", async () => {
92
+ const stringArrInt = z.intersection(
93
+ z.string().array(),
94
+ z
95
+ .string()
96
+ .array()
97
+ .transform((val) => [...val, "asdf"])
98
+ );
99
+ const syncResult = stringArrInt.safeParse(["asdf", "qwer"]);
100
+ expect(syncResult.success).toEqual(false);
101
+ if (!syncResult.success) {
102
+ expect(syncResult.error.issues[0].code).toEqual(z.ZodIssueCode.invalid_intersection_types);
103
+ }
104
+
105
+ const asyncResult = await stringArrInt.spa(["asdf", "qwer"]);
106
+ expect(asyncResult.success).toEqual(false);
107
+ if (!asyncResult.success) {
108
+ expect(asyncResult.error.issues[0].code).toEqual(z.ZodIssueCode.invalid_intersection_types);
109
+ }
110
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/language-server.source.ts ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as z from "zod/v3";
2
+
3
+ export const filePath = __filename;
4
+
5
+ // z.object()
6
+
7
+ export const Test = z.object({
8
+ f1: z.number(),
9
+ });
10
+
11
+ export type Test = z.infer<typeof Test>;
12
+
13
+ export const instanceOfTest: Test = {
14
+ f1: 1,
15
+ };
16
+
17
+ // z.object().merge()
18
+
19
+ export const TestMerge = z
20
+ .object({
21
+ f2: z.string().optional(),
22
+ })
23
+ .merge(Test);
24
+
25
+ export type TestMerge = z.infer<typeof TestMerge>;
26
+
27
+ export const instanceOfTestMerge: TestMerge = {
28
+ f1: 1,
29
+ f2: "string",
30
+ };
31
+
32
+ // z.union()
33
+
34
+ export const TestUnion = z.union([
35
+ z.object({
36
+ f2: z.string().optional(),
37
+ }),
38
+ Test,
39
+ ]);
40
+
41
+ export type TestUnion = z.infer<typeof TestUnion>;
42
+
43
+ export const instanceOfTestUnion: TestUnion = {
44
+ f1: 1,
45
+ f2: "string",
46
+ };
47
+
48
+ // z.object().partial()
49
+
50
+ export const TestPartial = Test.partial();
51
+
52
+ export type TestPartial = z.infer<typeof TestPartial>;
53
+
54
+ export const instanceOfTestPartial: TestPartial = {
55
+ f1: 1,
56
+ };
57
+
58
+ // z.object().pick()
59
+
60
+ export const TestPick = TestMerge.pick({ f1: true });
61
+
62
+ export type TestPick = z.infer<typeof TestPick>;
63
+
64
+ export const instanceOfTestPick: TestPick = {
65
+ f1: 1,
66
+ };
67
+
68
+ // z.object().omit()
69
+
70
+ export const TestOmit = TestMerge.omit({ f2: true });
71
+
72
+ export type TestOmit = z.infer<typeof TestOmit>;
73
+
74
+ export const instanceOfTestOmit: TestOmit = {
75
+ f1: 1,
76
+ };
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/language-server.test.ts ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { test } from "vitest";
2
+ // import path from "path";
3
+ // import { Node, Project, SyntaxKind } from "ts-morph";
4
+
5
+ // import { filePath } from "./language-server.source";
6
+
7
+ // The following tool is helpful for understanding the TypeScript AST associated with these tests:
8
+ // https://ts-ast-viewer.com/ (just copy the contents of language-server.source into the viewer)
9
+
10
+ test("", () => {});
11
+ // describe("Executing Go To Definition (and therefore Find Usages and Rename Refactoring) using an IDE works on inferred object properties", () => {
12
+ // // Compile file developmentEnvironment.source
13
+ // const project = new Project({
14
+ // tsConfigFilePath: path.join(__dirname, "..", "..", "tsconfig.json"),
15
+ // skipAddingFilesFromTsConfig: true,
16
+ // });
17
+ // const sourceFile = project.addSourceFileAtPath(filePath);
18
+
19
+ // test("works for object properties inferred from z.object()", () => {
20
+ // // Find usage of Test.f1 property
21
+ // const instanceVariable =
22
+ // sourceFile.getVariableDeclarationOrThrow("instanceOfTest");
23
+ // const propertyBeingAssigned = getPropertyBeingAssigned(
24
+ // instanceVariable,
25
+ // "f1"
26
+ // );
27
+
28
+ // // Find definition of Test.f1 property
29
+ // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0];
30
+ // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind(
31
+ // SyntaxKind.VariableDeclaration
32
+ // );
33
+
34
+ // // Assert that find definition returned the Zod definition of Test
35
+ // expect(definitionOfProperty?.getText()).toEqual("f1: z.number()");
36
+ // expect(parentOfProperty?.getName()).toEqual("Test");
37
+ // });
38
+
39
+ // // test("works for first object properties inferred from z.object().merge()", () => {
40
+ // // // Find usage of TestMerge.f1 property
41
+ // // const instanceVariable = sourceFile.getVariableDeclarationOrThrow(
42
+ // // "instanceOfTestMerge"
43
+ // // );
44
+ // // const propertyBeingAssigned = getPropertyBeingAssigned(
45
+ // // instanceVariable,
46
+ // // "f1"
47
+ // // );
48
+
49
+ // // // Find definition of TestMerge.f1 property
50
+ // // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0];
51
+ // // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind(
52
+ // // SyntaxKind.VariableDeclaration
53
+ // // );
54
+
55
+ // // // Assert that find definition returned the Zod definition of Test
56
+ // // expect(definitionOfProperty?.getText()).toEqual("f1: z.number()");
57
+ // // expect(parentOfProperty?.getName()).toEqual("Test");
58
+ // // });
59
+
60
+ // // test("works for second object properties inferred from z.object().merge()", () => {
61
+ // // // Find usage of TestMerge.f2 property
62
+ // // const instanceVariable = sourceFile.getVariableDeclarationOrThrow(
63
+ // // "instanceOfTestMerge"
64
+ // // );
65
+ // // const propertyBeingAssigned = getPropertyBeingAssigned(
66
+ // // instanceVariable,
67
+ // // "f2"
68
+ // // );
69
+
70
+ // // // Find definition of TestMerge.f2 property
71
+ // // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0];
72
+ // // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind(
73
+ // // SyntaxKind.VariableDeclaration
74
+ // // );
75
+
76
+ // // // Assert that find definition returned the Zod definition of TestMerge
77
+ // // expect(definitionOfProperty?.getText()).toEqual(
78
+ // // "f2: z.string().optional()"
79
+ // // );
80
+ // // expect(parentOfProperty?.getName()).toEqual("TestMerge");
81
+ // // });
82
+
83
+ // test("works for first object properties inferred from z.union()", () => {
84
+ // // Find usage of TestUnion.f1 property
85
+ // const instanceVariable = sourceFile.getVariableDeclarationOrThrow(
86
+ // "instanceOfTestUnion"
87
+ // );
88
+ // const propertyBeingAssigned = getPropertyBeingAssigned(
89
+ // instanceVariable,
90
+ // "f1"
91
+ // );
92
+
93
+ // // Find definition of TestUnion.f1 property
94
+ // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0];
95
+ // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind(
96
+ // SyntaxKind.VariableDeclaration
97
+ // );
98
+
99
+ // // Assert that find definition returned the Zod definition of Test
100
+ // expect(definitionOfProperty?.getText()).toEqual("f1: z.number()");
101
+ // expect(parentOfProperty?.getName()).toEqual("Test");
102
+ // });
103
+
104
+ // test("works for second object properties inferred from z.union()", () => {
105
+ // // Find usage of TestUnion.f2 property
106
+ // const instanceVariable = sourceFile.getVariableDeclarationOrThrow(
107
+ // "instanceOfTestUnion"
108
+ // );
109
+ // const propertyBeingAssigned = getPropertyBeingAssigned(
110
+ // instanceVariable,
111
+ // "f2"
112
+ // );
113
+
114
+ // // Find definition of TestUnion.f2 property
115
+ // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0];
116
+ // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind(
117
+ // SyntaxKind.VariableDeclaration
118
+ // );
119
+
120
+ // // Assert that find definition returned the Zod definition of TestUnion
121
+ // expect(definitionOfProperty?.getText()).toEqual(
122
+ // "f2: z.string().optional()"
123
+ // );
124
+ // expect(parentOfProperty?.getName()).toEqual("TestUnion");
125
+ // });
126
+
127
+ // test("works for object properties inferred from z.object().partial()", () => {
128
+ // // Find usage of TestPartial.f1 property
129
+ // const instanceVariable = sourceFile.getVariableDeclarationOrThrow(
130
+ // "instanceOfTestPartial"
131
+ // );
132
+ // const propertyBeingAssigned = getPropertyBeingAssigned(
133
+ // instanceVariable,
134
+ // "f1"
135
+ // );
136
+
137
+ // // Find definition of TestPartial.f1 property
138
+ // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0];
139
+ // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind(
140
+ // SyntaxKind.VariableDeclaration
141
+ // );
142
+
143
+ // // Assert that find definition returned the Zod definition of Test
144
+ // expect(definitionOfProperty?.getText()).toEqual("f1: z.number()");
145
+ // expect(parentOfProperty?.getName()).toEqual("Test");
146
+ // });
147
+
148
+ // test("works for object properties inferred from z.object().pick()", () => {
149
+ // // Find usage of TestPick.f1 property
150
+ // const instanceVariable =
151
+ // sourceFile.getVariableDeclarationOrThrow("instanceOfTestPick");
152
+ // const propertyBeingAssigned = getPropertyBeingAssigned(
153
+ // instanceVariable,
154
+ // "f1"
155
+ // );
156
+
157
+ // // Find definition of TestPick.f1 property
158
+ // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0];
159
+ // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind(
160
+ // SyntaxKind.VariableDeclaration
161
+ // );
162
+
163
+ // // Assert that find definition returned the Zod definition of Test
164
+ // expect(definitionOfProperty?.getText()).toEqual("f1: z.number()");
165
+ // expect(parentOfProperty?.getName()).toEqual("Test");
166
+ // });
167
+
168
+ // test("works for object properties inferred from z.object().omit()", () => {
169
+ // // Find usage of TestOmit.f1 property
170
+ // const instanceVariable =
171
+ // sourceFile.getVariableDeclarationOrThrow("instanceOfTestOmit");
172
+ // const propertyBeingAssigned = getPropertyBeingAssigned(
173
+ // instanceVariable,
174
+ // "f1"
175
+ // );
176
+
177
+ // // Find definition of TestOmit.f1 property
178
+ // const definitionOfProperty = propertyBeingAssigned?.getDefinitionNodes()[0];
179
+ // const parentOfProperty = definitionOfProperty?.getFirstAncestorByKind(
180
+ // SyntaxKind.VariableDeclaration
181
+ // );
182
+
183
+ // // Assert that find definition returned the Zod definition of Test
184
+ // expect(definitionOfProperty?.getText()).toEqual("f1: z.number()");
185
+ // expect(parentOfProperty?.getName()).toEqual("Test");
186
+ // });
187
+ // });
188
+
189
+ // const getPropertyBeingAssigned = (node: Node, name: string) => {
190
+ // const propertyAssignment = node.forEachDescendant((descendent) =>
191
+ // Node.isPropertyAssignment(descendent) && descendent.getName() == name
192
+ // ? descendent
193
+ // : undefined
194
+ // );
195
+
196
+ // if (propertyAssignment == null)
197
+ // fail(`Could not find property assignment with name ${name}`);
198
+
199
+ // const propertyLiteral = propertyAssignment.getFirstDescendantByKind(
200
+ // SyntaxKind.Identifier
201
+ // );
202
+
203
+ // if (propertyLiteral == null)
204
+ // fail(`Could not find property literal with name ${name}`);
205
+
206
+ // return propertyLiteral;
207
+ // };
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/literal.test.ts ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ const literalTuna = z.literal("tuna");
7
+ const literalFortyTwo = z.literal(42);
8
+ const literalTrue = z.literal(true);
9
+
10
+ const terrificSymbol = Symbol("terrific");
11
+ const literalTerrificSymbol = z.literal(terrificSymbol);
12
+
13
+ test("passing validations", () => {
14
+ literalTuna.parse("tuna");
15
+ literalFortyTwo.parse(42);
16
+ literalTrue.parse(true);
17
+ literalTerrificSymbol.parse(terrificSymbol);
18
+ });
19
+
20
+ test("failing validations", () => {
21
+ expect(() => literalTuna.parse("shark")).toThrow();
22
+ expect(() => literalFortyTwo.parse(43)).toThrow();
23
+ expect(() => literalTrue.parse(false)).toThrow();
24
+ expect(() => literalTerrificSymbol.parse(Symbol("terrific"))).toThrow();
25
+ });
26
+
27
+ test("invalid_literal should have `received` field with data", () => {
28
+ const data = "shark";
29
+ const result = literalTuna.safeParse(data);
30
+ if (!result.success) {
31
+ const issue = result.error.issues[0];
32
+ if (issue.code === "invalid_literal") {
33
+ expect(issue.received).toBe(data);
34
+ }
35
+ }
36
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/map.test.ts ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { ZodIssueCode } from "zod/v3";
6
+ import { util } from "../helpers/util.js";
7
+
8
+ const stringMap = z.map(z.string(), z.string());
9
+ type stringMap = z.infer<typeof stringMap>;
10
+
11
+ test("type inference", () => {
12
+ util.assertEqual<stringMap, Map<string, string>>(true);
13
+ });
14
+
15
+ test("valid parse", () => {
16
+ const result = stringMap.safeParse(
17
+ new Map([
18
+ ["first", "foo"],
19
+ ["second", "bar"],
20
+ ])
21
+ );
22
+ expect(result.success).toEqual(true);
23
+ if (result.success) {
24
+ expect(result.data.has("first")).toEqual(true);
25
+ expect(result.data.has("second")).toEqual(true);
26
+ expect(result.data.get("first")).toEqual("foo");
27
+ expect(result.data.get("second")).toEqual("bar");
28
+ }
29
+ });
30
+
31
+ test("valid parse async", async () => {
32
+ const result = await stringMap.spa(
33
+ new Map([
34
+ ["first", "foo"],
35
+ ["second", "bar"],
36
+ ])
37
+ );
38
+ expect(result.success).toEqual(true);
39
+ if (result.success) {
40
+ expect(result.data.has("first")).toEqual(true);
41
+ expect(result.data.has("second")).toEqual(true);
42
+ expect(result.data.get("first")).toEqual("foo");
43
+ expect(result.data.get("second")).toEqual("bar");
44
+ }
45
+ });
46
+
47
+ test("throws when a Set is given", () => {
48
+ const result = stringMap.safeParse(new Set([]));
49
+ expect(result.success).toEqual(false);
50
+ if (result.success === false) {
51
+ expect(result.error.issues.length).toEqual(1);
52
+ expect(result.error.issues[0].code).toEqual(ZodIssueCode.invalid_type);
53
+ }
54
+ });
55
+
56
+ test("throws when the given map has invalid key and invalid input", () => {
57
+ const result = stringMap.safeParse(new Map([[42, Symbol()]]));
58
+ expect(result.success).toEqual(false);
59
+ if (result.success === false) {
60
+ expect(result.error.issues.length).toEqual(2);
61
+ expect(result.error.issues[0].code).toEqual(ZodIssueCode.invalid_type);
62
+ expect(result.error.issues[0].path).toEqual([0, "key"]);
63
+ expect(result.error.issues[1].code).toEqual(ZodIssueCode.invalid_type);
64
+ expect(result.error.issues[1].path).toEqual([0, "value"]);
65
+ }
66
+ });
67
+
68
+ test("throws when the given map has multiple invalid entries", () => {
69
+ // const result = stringMap.safeParse(new Map([[42, Symbol()]]));
70
+
71
+ const result = stringMap.safeParse(
72
+ new Map([
73
+ [1, "foo"],
74
+ ["bar", 2],
75
+ ] as [any, any][]) as Map<any, any>
76
+ );
77
+
78
+ // const result = stringMap.safeParse(new Map([[42, Symbol()]]));
79
+ expect(result.success).toEqual(false);
80
+ if (result.success === false) {
81
+ expect(result.error.issues.length).toEqual(2);
82
+ expect(result.error.issues[0].code).toEqual(ZodIssueCode.invalid_type);
83
+ expect(result.error.issues[0].path).toEqual([0, "key"]);
84
+ expect(result.error.issues[1].code).toEqual(ZodIssueCode.invalid_type);
85
+ expect(result.error.issues[1].path).toEqual([1, "value"]);
86
+ }
87
+ });
88
+
89
+ test("dirty", async () => {
90
+ const map = z.map(
91
+ z.string().refine((val) => val === val.toUpperCase(), {
92
+ message: "Keys must be uppercase",
93
+ }),
94
+ z.string()
95
+ );
96
+ const result = await map.spa(
97
+ new Map([
98
+ ["first", "foo"],
99
+ ["second", "bar"],
100
+ ])
101
+ );
102
+ expect(result.success).toEqual(false);
103
+ if (!result.success) {
104
+ expect(result.error.issues.length).toEqual(2);
105
+ expect(result.error.issues[0].code).toEqual(z.ZodIssueCode.custom);
106
+ expect(result.error.issues[0].message).toEqual("Keys must be uppercase");
107
+ expect(result.error.issues[1].code).toEqual(z.ZodIssueCode.custom);
108
+ expect(result.error.issues[1].message).toEqual("Keys must be uppercase");
109
+ }
110
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/masking.test.ts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { test } from "vitest";
3
+
4
+ test("masking test", () => {});
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/mocker.test.ts ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { test } from "vitest";
3
+
4
+ import { Mocker } from "./Mocker.js";
5
+
6
+ test("mocker", () => {
7
+ const mocker = new Mocker();
8
+ mocker.string;
9
+ mocker.number;
10
+ mocker.boolean;
11
+ mocker.null;
12
+ mocker.undefined;
13
+ mocker.stringOptional;
14
+ mocker.stringNullable;
15
+ mocker.numberOptional;
16
+ mocker.numberNullable;
17
+ mocker.booleanOptional;
18
+ mocker.booleanNullable;
19
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/nan.test.ts ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ const schema = z.nan();
7
+
8
+ test("passing validations", () => {
9
+ schema.parse(Number.NaN);
10
+ schema.parse(Number("Not a number"));
11
+ });
12
+
13
+ test("failing validations", () => {
14
+ expect(() => schema.parse(5)).toThrow();
15
+ expect(() => schema.parse("John")).toThrow();
16
+ expect(() => schema.parse(true)).toThrow();
17
+ expect(() => schema.parse(null)).toThrow();
18
+ expect(() => schema.parse(undefined)).toThrow();
19
+ expect(() => schema.parse({})).toThrow();
20
+ expect(() => schema.parse([])).toThrow();
21
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/nativeEnum.test.ts ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ test("nativeEnum test with consts", () => {
8
+ const Fruits: { Apple: "apple"; Banana: "banana" } = {
9
+ Apple: "apple",
10
+ Banana: "banana",
11
+ };
12
+ const fruitEnum = z.nativeEnum(Fruits);
13
+ type fruitEnum = z.infer<typeof fruitEnum>;
14
+ fruitEnum.parse("apple");
15
+ fruitEnum.parse("banana");
16
+ fruitEnum.parse(Fruits.Apple);
17
+ fruitEnum.parse(Fruits.Banana);
18
+ util.assertEqual<fruitEnum, "apple" | "banana">(true);
19
+ });
20
+
21
+ test("nativeEnum test with real enum", () => {
22
+ enum Fruits {
23
+ Apple = "apple",
24
+ Banana = "banana",
25
+ }
26
+ // @ts-ignore
27
+ const fruitEnum = z.nativeEnum(Fruits);
28
+ type fruitEnum = z.infer<typeof fruitEnum>;
29
+ fruitEnum.parse("apple");
30
+ fruitEnum.parse("banana");
31
+ fruitEnum.parse(Fruits.Apple);
32
+ fruitEnum.parse(Fruits.Banana);
33
+ util.assertIs<fruitEnum extends Fruits ? true : false>(true);
34
+ });
35
+
36
+ test("nativeEnum test with const with numeric keys", () => {
37
+ const FruitValues = {
38
+ Apple: 10,
39
+ Banana: 20,
40
+ // @ts-ignore
41
+ } as const;
42
+ const fruitEnum = z.nativeEnum(FruitValues);
43
+ type fruitEnum = z.infer<typeof fruitEnum>;
44
+ fruitEnum.parse(10);
45
+ fruitEnum.parse(20);
46
+ fruitEnum.parse(FruitValues.Apple);
47
+ fruitEnum.parse(FruitValues.Banana);
48
+ util.assertEqual<fruitEnum, 10 | 20>(true);
49
+ });
50
+
51
+ test("from enum", () => {
52
+ enum Fruits {
53
+ Cantaloupe = 0,
54
+ Apple = "apple",
55
+ Banana = "banana",
56
+ }
57
+
58
+ const FruitEnum = z.nativeEnum(Fruits as any);
59
+ type _FruitEnum = z.infer<typeof FruitEnum>;
60
+ FruitEnum.parse(Fruits.Cantaloupe);
61
+ FruitEnum.parse(Fruits.Apple);
62
+ FruitEnum.parse("apple");
63
+ FruitEnum.parse(0);
64
+ expect(() => FruitEnum.parse(1)).toThrow();
65
+ expect(() => FruitEnum.parse("Apple")).toThrow();
66
+ expect(() => FruitEnum.parse("Cantaloupe")).toThrow();
67
+ });
68
+
69
+ test("from const", () => {
70
+ const Greek = {
71
+ Alpha: "a",
72
+ Beta: "b",
73
+ Gamma: 3,
74
+ // @ts-ignore
75
+ } as const;
76
+
77
+ const GreekEnum = z.nativeEnum(Greek);
78
+ type _GreekEnum = z.infer<typeof GreekEnum>;
79
+ GreekEnum.parse("a");
80
+ GreekEnum.parse("b");
81
+ GreekEnum.parse(3);
82
+ expect(() => GreekEnum.parse("v")).toThrow();
83
+ expect(() => GreekEnum.parse("Alpha")).toThrow();
84
+ expect(() => GreekEnum.parse(2)).toThrow();
85
+
86
+ expect(GreekEnum.enum.Alpha).toEqual("a");
87
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/nullable.test.ts ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ function checkErrors(a: z.ZodTypeAny, bad: any) {
7
+ let expected: any;
8
+ try {
9
+ a.parse(bad);
10
+ } catch (error) {
11
+ expected = (error as z.ZodError).formErrors;
12
+ }
13
+ try {
14
+ a.nullable().parse(bad);
15
+ } catch (error) {
16
+ expect((error as z.ZodError).formErrors).toEqual(expected);
17
+ }
18
+ }
19
+
20
+ test("Should have error messages appropriate for the underlying type", () => {
21
+ checkErrors(z.string().min(2), 1);
22
+ z.string().min(2).nullable().parse(null);
23
+ checkErrors(z.number().gte(2), 1);
24
+ z.number().gte(2).nullable().parse(null);
25
+ checkErrors(z.boolean(), "");
26
+ z.boolean().nullable().parse(null);
27
+ checkErrors(z.null(), null);
28
+ z.null().nullable().parse(null);
29
+ checkErrors(z.null(), {});
30
+ z.null().nullable().parse(null);
31
+ checkErrors(z.object({}), 1);
32
+ z.object({}).nullable().parse(null);
33
+ checkErrors(z.tuple([]), 1);
34
+ z.tuple([]).nullable().parse(null);
35
+ checkErrors(z.unknown(), 1);
36
+ z.unknown().nullable().parse(null);
37
+ });
38
+
39
+ test("unwrap", () => {
40
+ const unwrapped = z.string().nullable().unwrap();
41
+ expect(unwrapped).toBeInstanceOf(z.ZodString);
42
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/number.test.ts ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ const gtFive = z.number().gt(5);
7
+ const gteFive = z.number().gte(-5).gte(5);
8
+ const minFive = z.number().min(0).min(5);
9
+ const ltFive = z.number().lte(10).lt(5);
10
+ const lteFive = z.number().lte(5);
11
+ const maxFive = z.number().max(10).max(5);
12
+ const intNum = z.number().int();
13
+ const positive = z.number().positive();
14
+ const negative = z.number().negative();
15
+ const nonpositive = z.number().nonpositive();
16
+ const nonnegative = z.number().nonnegative();
17
+ const multipleOfFive = z.number().multipleOf(5);
18
+ const multipleOfNegativeFive = z.number().multipleOf(-5);
19
+ const finite = z.number().finite();
20
+ const safe = z.number().safe();
21
+ const stepPointOne = z.number().step(0.1);
22
+ const stepPointZeroZeroZeroOne = z.number().step(0.0001);
23
+ const stepSixPointFour = z.number().step(6.4);
24
+
25
+ test("passing validations", () => {
26
+ z.number().parse(1);
27
+ z.number().parse(1.5);
28
+ z.number().parse(0);
29
+ z.number().parse(-1.5);
30
+ z.number().parse(-1);
31
+ z.number().parse(Number.POSITIVE_INFINITY);
32
+ z.number().parse(Number.NEGATIVE_INFINITY);
33
+ gtFive.parse(6);
34
+ gtFive.parse(Number.POSITIVE_INFINITY);
35
+ gteFive.parse(5);
36
+ gteFive.parse(Number.POSITIVE_INFINITY);
37
+ minFive.parse(5);
38
+ minFive.parse(Number.POSITIVE_INFINITY);
39
+ ltFive.parse(4);
40
+ ltFive.parse(Number.NEGATIVE_INFINITY);
41
+ lteFive.parse(5);
42
+ lteFive.parse(Number.NEGATIVE_INFINITY);
43
+ maxFive.parse(5);
44
+ maxFive.parse(Number.NEGATIVE_INFINITY);
45
+ intNum.parse(4);
46
+ positive.parse(1);
47
+ positive.parse(Number.POSITIVE_INFINITY);
48
+ negative.parse(-1);
49
+ negative.parse(Number.NEGATIVE_INFINITY);
50
+ nonpositive.parse(0);
51
+ nonpositive.parse(-1);
52
+ nonpositive.parse(Number.NEGATIVE_INFINITY);
53
+ nonnegative.parse(0);
54
+ nonnegative.parse(1);
55
+ nonnegative.parse(Number.POSITIVE_INFINITY);
56
+ multipleOfFive.parse(15);
57
+ multipleOfFive.parse(-15);
58
+ multipleOfNegativeFive.parse(-15);
59
+ multipleOfNegativeFive.parse(15);
60
+ finite.parse(123);
61
+ safe.parse(Number.MIN_SAFE_INTEGER);
62
+ safe.parse(Number.MAX_SAFE_INTEGER);
63
+ stepPointOne.parse(6);
64
+ stepPointOne.parse(6.1);
65
+ stepPointOne.parse(6.1);
66
+ stepSixPointFour.parse(12.8);
67
+ stepPointZeroZeroZeroOne.parse(3.01);
68
+ });
69
+
70
+ test("failing validations", () => {
71
+ expect(() => ltFive.parse(5)).toThrow();
72
+ expect(() => lteFive.parse(6)).toThrow();
73
+ expect(() => maxFive.parse(6)).toThrow();
74
+ expect(() => gtFive.parse(5)).toThrow();
75
+ expect(() => gteFive.parse(4)).toThrow();
76
+ expect(() => minFive.parse(4)).toThrow();
77
+ expect(() => intNum.parse(3.14)).toThrow();
78
+ expect(() => positive.parse(0)).toThrow();
79
+ expect(() => positive.parse(-1)).toThrow();
80
+ expect(() => negative.parse(0)).toThrow();
81
+ expect(() => negative.parse(1)).toThrow();
82
+ expect(() => nonpositive.parse(1)).toThrow();
83
+ expect(() => nonnegative.parse(-1)).toThrow();
84
+ expect(() => multipleOfFive.parse(7.5)).toThrow();
85
+ expect(() => multipleOfFive.parse(-7.5)).toThrow();
86
+ expect(() => multipleOfNegativeFive.parse(-7.5)).toThrow();
87
+ expect(() => multipleOfNegativeFive.parse(7.5)).toThrow();
88
+ expect(() => finite.parse(Number.POSITIVE_INFINITY)).toThrow();
89
+ expect(() => finite.parse(Number.NEGATIVE_INFINITY)).toThrow();
90
+ expect(() => safe.parse(Number.MIN_SAFE_INTEGER - 1)).toThrow();
91
+ expect(() => safe.parse(Number.MAX_SAFE_INTEGER + 1)).toThrow();
92
+
93
+ expect(() => stepPointOne.parse(6.11)).toThrow();
94
+ expect(() => stepPointOne.parse(6.1000000001)).toThrow();
95
+ expect(() => stepSixPointFour.parse(6.41)).toThrow();
96
+ });
97
+
98
+ test("parse NaN", () => {
99
+ expect(() => z.number().parse(Number.NaN)).toThrow();
100
+ });
101
+
102
+ test("min max getters", () => {
103
+ expect(z.number().minValue).toBeNull;
104
+ expect(ltFive.minValue).toBeNull;
105
+ expect(lteFive.minValue).toBeNull;
106
+ expect(maxFive.minValue).toBeNull;
107
+ expect(negative.minValue).toBeNull;
108
+ expect(nonpositive.minValue).toBeNull;
109
+ expect(intNum.minValue).toBeNull;
110
+ expect(multipleOfFive.minValue).toBeNull;
111
+ expect(finite.minValue).toBeNull;
112
+ expect(gtFive.minValue).toEqual(5);
113
+ expect(gteFive.minValue).toEqual(5);
114
+ expect(minFive.minValue).toEqual(5);
115
+ expect(minFive.min(10).minValue).toEqual(10);
116
+ expect(positive.minValue).toEqual(0);
117
+ expect(nonnegative.minValue).toEqual(0);
118
+ expect(safe.minValue).toEqual(Number.MIN_SAFE_INTEGER);
119
+
120
+ expect(z.number().maxValue).toBeNull;
121
+ expect(gtFive.maxValue).toBeNull;
122
+ expect(gteFive.maxValue).toBeNull;
123
+ expect(minFive.maxValue).toBeNull;
124
+ expect(positive.maxValue).toBeNull;
125
+ expect(nonnegative.maxValue).toBeNull;
126
+ expect(intNum.minValue).toBeNull;
127
+ expect(multipleOfFive.minValue).toBeNull;
128
+ expect(finite.minValue).toBeNull;
129
+ expect(ltFive.maxValue).toEqual(5);
130
+ expect(lteFive.maxValue).toEqual(5);
131
+ expect(maxFive.maxValue).toEqual(5);
132
+ expect(maxFive.max(1).maxValue).toEqual(1);
133
+ expect(negative.maxValue).toEqual(0);
134
+ expect(nonpositive.maxValue).toEqual(0);
135
+ expect(safe.maxValue).toEqual(Number.MAX_SAFE_INTEGER);
136
+ });
137
+
138
+ test("int getter", () => {
139
+ expect(z.number().isInt).toEqual(false);
140
+ expect(z.number().multipleOf(1.5).isInt).toEqual(false);
141
+ expect(gtFive.isInt).toEqual(false);
142
+ expect(gteFive.isInt).toEqual(false);
143
+ expect(minFive.isInt).toEqual(false);
144
+ expect(positive.isInt).toEqual(false);
145
+ expect(nonnegative.isInt).toEqual(false);
146
+ expect(finite.isInt).toEqual(false);
147
+ expect(ltFive.isInt).toEqual(false);
148
+ expect(lteFive.isInt).toEqual(false);
149
+ expect(maxFive.isInt).toEqual(false);
150
+ expect(negative.isInt).toEqual(false);
151
+ expect(nonpositive.isInt).toEqual(false);
152
+ expect(safe.isInt).toEqual(false);
153
+
154
+ expect(intNum.isInt).toEqual(true);
155
+ expect(multipleOfFive.isInt).toEqual(true);
156
+ });
157
+
158
+ test("finite getter", () => {
159
+ expect(z.number().isFinite).toEqual(false);
160
+ expect(gtFive.isFinite).toEqual(false);
161
+ expect(gteFive.isFinite).toEqual(false);
162
+ expect(minFive.isFinite).toEqual(false);
163
+ expect(positive.isFinite).toEqual(false);
164
+ expect(nonnegative.isFinite).toEqual(false);
165
+ expect(ltFive.isFinite).toEqual(false);
166
+ expect(lteFive.isFinite).toEqual(false);
167
+ expect(maxFive.isFinite).toEqual(false);
168
+ expect(negative.isFinite).toEqual(false);
169
+ expect(nonpositive.isFinite).toEqual(false);
170
+
171
+ expect(finite.isFinite).toEqual(true);
172
+ expect(intNum.isFinite).toEqual(true);
173
+ expect(multipleOfFive.isFinite).toEqual(true);
174
+ expect(z.number().min(5).max(10).isFinite).toEqual(true);
175
+ expect(safe.isFinite).toEqual(true);
176
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/object-augmentation.test.ts ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ test("object augmentation", () => {
7
+ const Animal = z
8
+ .object({
9
+ species: z.string(),
10
+ })
11
+ .augment({
12
+ population: z.number(),
13
+ });
14
+ // overwrites `species`
15
+ const ModifiedAnimal = Animal.augment({
16
+ species: z.array(z.string()),
17
+ });
18
+ ModifiedAnimal.parse({
19
+ species: ["asd"],
20
+ population: 1324,
21
+ });
22
+
23
+ const bad = () =>
24
+ ModifiedAnimal.parse({
25
+ species: "asdf",
26
+ population: 1324,
27
+ } as any);
28
+ expect(bad).toThrow();
29
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ const RealSet = Set;
7
+ const RealMap = Map;
8
+ const RealDate = Date;
9
+
10
+ test("doesn’t throw when Date is undefined", () => {
11
+ delete (globalThis as any).Date;
12
+ const result = z.object({}).safeParse({});
13
+ expect(result.success).toEqual(true);
14
+ globalThis.Date = RealDate;
15
+ });
16
+
17
+ test("doesn’t throw when Set is undefined", () => {
18
+ delete (globalThis as any).Set;
19
+ const result = z.object({}).safeParse({});
20
+ expect(result.success).toEqual(true);
21
+ globalThis.Set = RealSet;
22
+ });
23
+
24
+ test("doesn’t throw when Map is undefined", () => {
25
+ delete (globalThis as any).Map;
26
+ const result = z.object({}).safeParse({});
27
+ expect(result.success).toEqual(true);
28
+ globalThis.Map = RealMap;
29
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/object.test.ts ADDED
@@ -0,0 +1,434 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+ import { util } from "../helpers/util.js";
6
+
7
+ const Test = z.object({
8
+ f1: z.number(),
9
+ f2: z.string().optional(),
10
+ f3: z.string().nullable(),
11
+ f4: z.array(z.object({ t: z.union([z.string(), z.boolean()]) })),
12
+ });
13
+
14
+ test("object type inference", () => {
15
+ type TestType = {
16
+ f1: number;
17
+ f2?: string | undefined;
18
+ f3: string | null;
19
+ f4: { t: string | boolean }[];
20
+ };
21
+
22
+ util.assertEqual<z.TypeOf<typeof Test>, TestType>(true);
23
+ });
24
+
25
+ test("unknown throw", () => {
26
+ const asdf: unknown = 35;
27
+ expect(() => Test.parse(asdf)).toThrow();
28
+ });
29
+
30
+ test("shape() should return schema of particular key", () => {
31
+ const f1Schema = Test.shape.f1;
32
+ const f2Schema = Test.shape.f2;
33
+ const f3Schema = Test.shape.f3;
34
+ const f4Schema = Test.shape.f4;
35
+
36
+ expect(f1Schema).toBeInstanceOf(z.ZodNumber);
37
+ expect(f2Schema).toBeInstanceOf(z.ZodOptional);
38
+ expect(f3Schema).toBeInstanceOf(z.ZodNullable);
39
+ expect(f4Schema).toBeInstanceOf(z.ZodArray);
40
+ });
41
+
42
+ test("correct parsing", () => {
43
+ Test.parse({
44
+ f1: 12,
45
+ f2: "string",
46
+ f3: "string",
47
+ f4: [
48
+ {
49
+ t: "string",
50
+ },
51
+ ],
52
+ });
53
+
54
+ Test.parse({
55
+ f1: 12,
56
+ f3: null,
57
+ f4: [
58
+ {
59
+ t: false,
60
+ },
61
+ ],
62
+ });
63
+ });
64
+
65
+ test("incorrect #1", () => {
66
+ expect(() => Test.parse({} as any)).toThrow();
67
+ });
68
+
69
+ test("nonstrict by default", () => {
70
+ z.object({ points: z.number() }).parse({
71
+ points: 2314,
72
+ unknown: "asdf",
73
+ });
74
+ });
75
+
76
+ const data = {
77
+ points: 2314,
78
+ unknown: "asdf",
79
+ };
80
+
81
+ test("strip by default", () => {
82
+ const val = z.object({ points: z.number() }).parse(data);
83
+ expect(val).toEqual({ points: 2314 });
84
+ });
85
+
86
+ test("unknownkeys override", () => {
87
+ const val = z.object({ points: z.number() }).strict().passthrough().strip().nonstrict().parse(data);
88
+
89
+ expect(val).toEqual(data);
90
+ });
91
+
92
+ test("passthrough unknown", () => {
93
+ const val = z.object({ points: z.number() }).passthrough().parse(data);
94
+
95
+ expect(val).toEqual(data);
96
+ });
97
+
98
+ test("strip unknown", () => {
99
+ const val = z.object({ points: z.number() }).strip().parse(data);
100
+
101
+ expect(val).toEqual({ points: 2314 });
102
+ });
103
+
104
+ test("strict", () => {
105
+ const val = z.object({ points: z.number() }).strict().safeParse(data);
106
+
107
+ expect(val.success).toEqual(false);
108
+ });
109
+
110
+ test("catchall inference", () => {
111
+ const o1 = z
112
+ .object({
113
+ first: z.string(),
114
+ })
115
+ .catchall(z.number());
116
+
117
+ const d1 = o1.parse({ first: "asdf", num: 1243 });
118
+ util.assertEqual<number, (typeof d1)["asdf"]>(true);
119
+ util.assertEqual<string, (typeof d1)["first"]>(true);
120
+ });
121
+
122
+ test("catchall overrides strict", () => {
123
+ const o1 = z.object({ first: z.string().optional() }).strict().catchall(z.number());
124
+
125
+ // should run fine
126
+ // setting a catchall overrides the unknownKeys behavior
127
+ o1.parse({
128
+ asdf: 1234,
129
+ });
130
+
131
+ // should only run catchall validation
132
+ // against unknown keys
133
+ o1.parse({
134
+ first: "asdf",
135
+ asdf: 1234,
136
+ });
137
+ });
138
+
139
+ test("catchall overrides strict", () => {
140
+ const o1 = z
141
+ .object({
142
+ first: z.string(),
143
+ })
144
+ .strict()
145
+ .catchall(z.number());
146
+
147
+ // should run fine
148
+ // setting a catchall overrides the unknownKeys behavior
149
+ o1.parse({
150
+ first: "asdf",
151
+ asdf: 1234,
152
+ });
153
+ });
154
+
155
+ test("test that optional keys are unset", async () => {
156
+ const SNamedEntity = z.object({
157
+ id: z.string(),
158
+ set: z.string().optional(),
159
+ unset: z.string().optional(),
160
+ });
161
+ const result = await SNamedEntity.parse({
162
+ id: "asdf",
163
+ set: undefined,
164
+ });
165
+ // eslint-disable-next-line ban/ban
166
+ expect(Object.keys(result)).toEqual(["id", "set"]);
167
+ });
168
+
169
+ test("test catchall parsing", async () => {
170
+ const result = z.object({ name: z.string() }).catchall(z.number()).parse({ name: "Foo", validExtraKey: 61 });
171
+
172
+ expect(result).toEqual({ name: "Foo", validExtraKey: 61 });
173
+
174
+ const result2 = z
175
+ .object({ name: z.string() })
176
+ .catchall(z.number())
177
+ .safeParse({ name: "Foo", validExtraKey: 61, invalid: "asdf" });
178
+
179
+ expect(result2.success).toEqual(false);
180
+ });
181
+
182
+ test("test nonexistent keys", async () => {
183
+ const Schema = z.union([z.object({ a: z.string() }), z.object({ b: z.number() })]);
184
+ const obj = { a: "A" };
185
+ const result = await Schema.spa(obj); // Works with 1.11.10, breaks with 2.0.0-beta.21
186
+ expect(result.success).toBe(true);
187
+ });
188
+
189
+ test("test async union", async () => {
190
+ const Schema2 = z.union([
191
+ z.object({
192
+ ty: z.string(),
193
+ }),
194
+ z.object({
195
+ ty: z.number(),
196
+ }),
197
+ ]);
198
+
199
+ const obj = { ty: "A" };
200
+ const result = await Schema2.spa(obj); // Works with 1.11.10, breaks with 2.0.0-beta.21
201
+ expect(result.success).toEqual(true);
202
+ });
203
+
204
+ test("test inferred merged type", async () => {
205
+ const asdf = z.object({ a: z.string() }).merge(z.object({ a: z.number() }));
206
+ type asdf = z.infer<typeof asdf>;
207
+ util.assertEqual<asdf, { a: number }>(true);
208
+ });
209
+
210
+ test("inferred merged object type with optional properties", async () => {
211
+ const Merged = z
212
+ .object({ a: z.string(), b: z.string().optional() })
213
+ .merge(z.object({ a: z.string().optional(), b: z.string() }));
214
+ type Merged = z.infer<typeof Merged>;
215
+ util.assertEqual<Merged, { a?: string; b: string }>(true);
216
+ // todo
217
+ // util.assertEqual<Merged, { a?: string; b: string }>(true);
218
+ });
219
+
220
+ test("inferred unioned object type with optional properties", async () => {
221
+ const Unioned = z.union([
222
+ z.object({ a: z.string(), b: z.string().optional() }),
223
+ z.object({ a: z.string().optional(), b: z.string() }),
224
+ ]);
225
+ type Unioned = z.infer<typeof Unioned>;
226
+ util.assertEqual<Unioned, { a: string; b?: string } | { a?: string; b: string }>(true);
227
+ });
228
+
229
+ test("inferred enum type", async () => {
230
+ const Enum = z.object({ a: z.string(), b: z.string().optional() }).keyof();
231
+
232
+ expect(Enum.Values).toEqual({
233
+ a: "a",
234
+ b: "b",
235
+ });
236
+ expect(Enum.enum).toEqual({
237
+ a: "a",
238
+ b: "b",
239
+ });
240
+ expect(Enum._def.values).toEqual(["a", "b"]);
241
+ type Enum = z.infer<typeof Enum>;
242
+ util.assertEqual<Enum, "a" | "b">(true);
243
+ });
244
+
245
+ test("inferred partial object type with optional properties", async () => {
246
+ const Partial = z.object({ a: z.string(), b: z.string().optional() }).partial();
247
+ type Partial = z.infer<typeof Partial>;
248
+ util.assertEqual<Partial, { a?: string; b?: string }>(true);
249
+ });
250
+
251
+ test("inferred picked object type with optional properties", async () => {
252
+ const Picked = z.object({ a: z.string(), b: z.string().optional() }).pick({ b: true });
253
+ type Picked = z.infer<typeof Picked>;
254
+ util.assertEqual<Picked, { b?: string }>(true);
255
+ });
256
+
257
+ test("inferred type for unknown/any keys", () => {
258
+ const myType = z.object({
259
+ anyOptional: z.any().optional(),
260
+ anyRequired: z.any(),
261
+ unknownOptional: z.unknown().optional(),
262
+ unknownRequired: z.unknown(),
263
+ });
264
+ type myType = z.infer<typeof myType>;
265
+ util.assertEqual<
266
+ myType,
267
+ {
268
+ anyOptional?: any;
269
+ anyRequired?: any;
270
+ unknownOptional?: unknown;
271
+ unknownRequired?: unknown;
272
+ }
273
+ >(true);
274
+ });
275
+
276
+ test("setKey", () => {
277
+ const base = z.object({ name: z.string() });
278
+ const withNewKey = base.setKey("age", z.number());
279
+
280
+ type withNewKey = z.infer<typeof withNewKey>;
281
+ util.assertEqual<withNewKey, { name: string; age: number }>(true);
282
+ withNewKey.parse({ name: "asdf", age: 1234 });
283
+ });
284
+
285
+ test("strictcreate", async () => {
286
+ const strictObj = z.strictObject({
287
+ name: z.string(),
288
+ });
289
+
290
+ const syncResult = strictObj.safeParse({ name: "asdf", unexpected: 13 });
291
+ expect(syncResult.success).toEqual(false);
292
+
293
+ const asyncResult = await strictObj.spa({ name: "asdf", unexpected: 13 });
294
+ expect(asyncResult.success).toEqual(false);
295
+ });
296
+
297
+ test("object with refine", async () => {
298
+ const schema = z
299
+ .object({
300
+ a: z.string().default("foo"),
301
+ b: z.number(),
302
+ })
303
+ .refine(() => true);
304
+ expect(schema.parse({ b: 5 })).toEqual({ b: 5, a: "foo" });
305
+ const result = await schema.parseAsync({ b: 5 });
306
+ expect(result).toEqual({ b: 5, a: "foo" });
307
+ });
308
+
309
+ test("intersection of object with date", async () => {
310
+ const schema = z.object({
311
+ a: z.date(),
312
+ });
313
+ expect(schema.and(schema).parse({ a: new Date(1637353595983) })).toEqual({
314
+ a: new Date(1637353595983),
315
+ });
316
+ const result = await schema.parseAsync({ a: new Date(1637353595983) });
317
+ expect(result).toEqual({ a: new Date(1637353595983) });
318
+ });
319
+
320
+ test("intersection of object with refine with date", async () => {
321
+ const schema = z
322
+ .object({
323
+ a: z.date(),
324
+ })
325
+ .refine(() => true);
326
+ expect(schema.and(schema).parse({ a: new Date(1637353595983) })).toEqual({
327
+ a: new Date(1637353595983),
328
+ });
329
+ const result = await schema.parseAsync({ a: new Date(1637353595983) });
330
+ expect(result).toEqual({ a: new Date(1637353595983) });
331
+ });
332
+
333
+ test("constructor key", () => {
334
+ const person = z
335
+ .object({
336
+ name: z.string(),
337
+ })
338
+ .strict();
339
+
340
+ expect(() =>
341
+ person.parse({
342
+ name: "bob dylan",
343
+ constructor: 61,
344
+ })
345
+ ).toThrow();
346
+ });
347
+
348
+ test("constructor key", () => {
349
+ const Example = z.object({
350
+ prop: z.string(),
351
+ opt: z.number().optional(),
352
+ arr: z.string().array(),
353
+ });
354
+
355
+ type Example = z.infer<typeof Example>;
356
+ util.assertEqual<keyof Example, "prop" | "opt" | "arr">(true);
357
+ });
358
+
359
+ test("unknownkeys merging", () => {
360
+ // This one is "strict"
361
+ const schemaA = z
362
+ .object({
363
+ a: z.string(),
364
+ })
365
+ .strict();
366
+
367
+ // This one is "strip"
368
+ const schemaB = z
369
+ .object({
370
+ b: z.string(),
371
+ })
372
+ .catchall(z.string());
373
+
374
+ const mergedSchema = schemaA.merge(schemaB);
375
+ type mergedSchema = typeof mergedSchema;
376
+ util.assertEqual<mergedSchema["_def"]["unknownKeys"], "strip">(true);
377
+ expect(mergedSchema._def.unknownKeys).toEqual("strip");
378
+
379
+ util.assertEqual<mergedSchema["_def"]["catchall"], z.ZodString>(true);
380
+ expect(mergedSchema._def.catchall instanceof z.ZodString).toEqual(true);
381
+ });
382
+
383
+ const personToExtend = z.object({
384
+ firstName: z.string(),
385
+ lastName: z.string(),
386
+ });
387
+
388
+ test("extend() should return schema with new key", () => {
389
+ const PersonWithNickname = personToExtend.extend({ nickName: z.string() });
390
+ type PersonWithNickname = z.infer<typeof PersonWithNickname>;
391
+
392
+ const expected = { firstName: "f", nickName: "n", lastName: "l" };
393
+ const actual = PersonWithNickname.parse(expected);
394
+
395
+ expect(actual).toEqual(expected);
396
+ util.assertEqual<keyof PersonWithNickname, "firstName" | "lastName" | "nickName">(true);
397
+ util.assertEqual<PersonWithNickname, { firstName: string; lastName: string; nickName: string }>(true);
398
+ });
399
+
400
+ test("extend() should have power to override existing key", () => {
401
+ const PersonWithNumberAsLastName = personToExtend.extend({
402
+ lastName: z.number(),
403
+ });
404
+ type PersonWithNumberAsLastName = z.infer<typeof PersonWithNumberAsLastName>;
405
+
406
+ const expected = { firstName: "f", lastName: 42 };
407
+ const actual = PersonWithNumberAsLastName.parse(expected);
408
+
409
+ expect(actual).toEqual(expected);
410
+ util.assertEqual<PersonWithNumberAsLastName, { firstName: string; lastName: number }>(true);
411
+ });
412
+
413
+ test("passthrough index signature", () => {
414
+ const a = z.object({ a: z.string() });
415
+ type a = z.infer<typeof a>;
416
+ util.assertEqual<{ a: string }, a>(true);
417
+ const b = a.passthrough();
418
+ type b = z.infer<typeof b>;
419
+ util.assertEqual<{ a: string } & { [k: string]: unknown }, b>(true);
420
+ });
421
+
422
+ test("xor", () => {
423
+ type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
424
+ type XOR<T, U> = T extends object ? (U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : U) : T;
425
+
426
+ type A = { name: string; a: number };
427
+ type B = { name: string; b: number };
428
+ type C = XOR<A, B>;
429
+ type Outer = { data: C };
430
+
431
+ const _Outer: z.ZodType<Outer> = z.object({
432
+ data: z.union([z.object({ name: z.string(), a: z.number() }), z.object({ name: z.string(), b: z.number() })]),
433
+ });
434
+ });
node_modules/@jimp/plugin-circle/node_modules/zod/src/v3/tests/optional.test.ts ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v3";
5
+
6
+ function checkErrors(a: z.ZodTypeAny, bad: any) {
7
+ let expected: any;
8
+ try {
9
+ a.parse(bad);
10
+ } catch (error) {
11
+ expected = (error as z.ZodError).formErrors;
12
+ }
13
+ try {
14
+ a.optional().parse(bad);
15
+ } catch (error) {
16
+ expect((error as z.ZodError).formErrors).toEqual(expected);
17
+ }
18
+ }
19
+
20
+ test("Should have error messages appropriate for the underlying type", () => {
21
+ checkErrors(z.string().min(2), 1);
22
+ z.string().min(2).optional().parse(undefined);
23
+ checkErrors(z.number().gte(2), 1);
24
+ z.number().gte(2).optional().parse(undefined);
25
+ checkErrors(z.boolean(), "");
26
+ z.boolean().optional().parse(undefined);
27
+ checkErrors(z.undefined(), null);
28
+ z.undefined().optional().parse(undefined);
29
+ checkErrors(z.null(), {});
30
+ z.null().optional().parse(undefined);
31
+ checkErrors(z.object({}), 1);
32
+ z.object({}).optional().parse(undefined);
33
+ checkErrors(z.tuple([]), 1);
34
+ z.tuple([]).optional().parse(undefined);
35
+ checkErrors(z.unknown(), 1);
36
+ z.unknown().optional().parse(undefined);
37
+ });
38
+
39
+ test("unwrap", () => {
40
+ const unwrapped = z.string().optional().unwrap();
41
+ expect(unwrapped).toBeInstanceOf(z.ZodString);
42
+ });