Leon4gr45 commited on
Commit
08ed12c
·
verified ·
1 Parent(s): 213003b

Upload folder using huggingface_hub (part 15)

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-flip/node_modules/zod/package.json +118 -0
  2. node_modules/@jimp/plugin-flip/node_modules/zod/src/index.ts +4 -0
  3. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/ZodError.ts +330 -0
  4. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
  5. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  6. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/index.ts +59 -0
  7. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
  8. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/object.ts +69 -0
  9. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
  10. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
  11. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/string.ts +55 -0
  12. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/union.ts +80 -0
  13. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/errors.ts +13 -0
  14. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/external.ts +6 -0
  15. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
  16. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
  17. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
  18. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
  19. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
  20. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/helpers/util.ts +224 -0
  21. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/index.ts +4 -0
  22. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/locales/en.ts +124 -0
  23. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/standard-schema.ts +113 -0
  24. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/Mocker.ts +54 -0
  25. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
  26. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
  27. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/array.test.ts +71 -0
  28. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
  29. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
  30. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/base.test.ts +29 -0
  31. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/bigint.test.ts +55 -0
  32. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/branded.test.ts +53 -0
  33. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/catch.test.ts +220 -0
  34. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/coerce.test.ts +133 -0
  35. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/complex.test.ts +56 -0
  36. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/custom.test.ts +31 -0
  37. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/date.test.ts +32 -0
  38. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
  39. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/default.test.ts +112 -0
  40. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/description.test.ts +33 -0
  41. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
  42. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/enum.test.ts +80 -0
  43. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/error.test.ts +551 -0
  44. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
  45. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
  46. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/function.test.ts +257 -0
  47. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/generics.test.ts +48 -0
  48. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
  49. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/intersection.test.ts +110 -0
  50. node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/tests/language-server.source.ts +76 -0
node_modules/@jimp/plugin-flip/node_modules/zod/package.json ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "zod",
3
+ "version": "3.25.76",
4
+ "type": "module",
5
+ "author": "Colin McDonnell <zod@colinhacks.com>",
6
+ "description": "TypeScript-first schema declaration and validation library with static type inference",
7
+ "files": [
8
+ "src",
9
+ "**/*.js",
10
+ "**/*.mjs",
11
+ "**/*.cjs",
12
+ "**/*.d.ts",
13
+ "**/*.d.mts",
14
+ "**/*.d.cts"
15
+ ],
16
+ "funding": "https://github.com/sponsors/colinhacks",
17
+ "homepage": "https://zod.dev",
18
+ "keywords": [
19
+ "typescript",
20
+ "schema",
21
+ "validation",
22
+ "type",
23
+ "inference"
24
+ ],
25
+ "license": "MIT",
26
+ "sideEffects": false,
27
+ "main": "./index.cjs",
28
+ "types": "./index.d.cts",
29
+ "module": "./index.js",
30
+ "zshy": {
31
+ "exports": {
32
+ "./package.json": "./package.json",
33
+ ".": "./src/index.ts",
34
+ "./v3": "./src/v3/index.ts",
35
+ "./v4": "./src/v4/index.ts",
36
+ "./v4-mini": "./src/v4-mini/index.ts",
37
+ "./v4/mini": "./src/v4/mini/index.ts",
38
+ "./v4/core": "./src/v4/core/index.ts",
39
+ "./v4/locales": "./src/v4/locales/index.ts",
40
+ "./v4/locales/*": "./src/v4/locales/*"
41
+ },
42
+ "sourceDialects": [
43
+ "@zod/source"
44
+ ]
45
+ },
46
+ "exports": {
47
+ "./package.json": "./package.json",
48
+ ".": {
49
+ "@zod/source": "./src/index.ts",
50
+ "types": "./index.d.cts",
51
+ "import": "./index.js",
52
+ "require": "./index.cjs"
53
+ },
54
+ "./v3": {
55
+ "@zod/source": "./src/v3/index.ts",
56
+ "types": "./v3/index.d.cts",
57
+ "import": "./v3/index.js",
58
+ "require": "./v3/index.cjs"
59
+ },
60
+ "./v4": {
61
+ "@zod/source": "./src/v4/index.ts",
62
+ "types": "./v4/index.d.cts",
63
+ "import": "./v4/index.js",
64
+ "require": "./v4/index.cjs"
65
+ },
66
+ "./v4-mini": {
67
+ "@zod/source": "./src/v4-mini/index.ts",
68
+ "types": "./v4-mini/index.d.cts",
69
+ "import": "./v4-mini/index.js",
70
+ "require": "./v4-mini/index.cjs"
71
+ },
72
+ "./v4/mini": {
73
+ "@zod/source": "./src/v4/mini/index.ts",
74
+ "types": "./v4/mini/index.d.cts",
75
+ "import": "./v4/mini/index.js",
76
+ "require": "./v4/mini/index.cjs"
77
+ },
78
+ "./v4/core": {
79
+ "@zod/source": "./src/v4/core/index.ts",
80
+ "types": "./v4/core/index.d.cts",
81
+ "import": "./v4/core/index.js",
82
+ "require": "./v4/core/index.cjs"
83
+ },
84
+ "./v4/locales": {
85
+ "@zod/source": "./src/v4/locales/index.ts",
86
+ "types": "./v4/locales/index.d.cts",
87
+ "import": "./v4/locales/index.js",
88
+ "require": "./v4/locales/index.cjs"
89
+ },
90
+ "./v4/locales/*": {
91
+ "@zod/source": "./src/v4/locales/*",
92
+ "types": "./v4/locales/*",
93
+ "import": "./v4/locales/*",
94
+ "require": "./v4/locales/*"
95
+ }
96
+ },
97
+ "repository": {
98
+ "type": "git",
99
+ "url": "git+https://github.com/colinhacks/zod.git"
100
+ },
101
+ "bugs": {
102
+ "url": "https://github.com/colinhacks/zod/issues"
103
+ },
104
+ "support": {
105
+ "backing": {
106
+ "npm-funding": true
107
+ }
108
+ },
109
+ "scripts": {
110
+ "clean": "git clean -xdf . -e node_modules",
111
+ "build": "zshy --project tsconfig.build.json",
112
+ "postbuild": "pnpm biome check --write .",
113
+ "test:watch": "pnpm vitest",
114
+ "test": "pnpm vitest run",
115
+ "bump:beta": "pnpm version \"v$(pnpm pkg get version | jq -r)-beta.$(date +%Y%m%dT%H%M%S)\"",
116
+ "pub:beta": "pnpm bump:beta && pnpm publish --tag next --publish-branch v4 --no-git-checks --dry-run"
117
+ }
118
+ }
node_modules/@jimp/plugin-flip/node_modules/zod/src/index.ts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import * as z from "./v3/external.js";
2
+ export * from "./v3/external.js";
3
+ export { z };
4
+ export default z;
node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/ZodError.ts ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { Primitive } from "./helpers/typeAliases.js";
2
+ import { util, type ZodParsedType } from "./helpers/util.js";
3
+ import type { TypeOf, ZodType } from "./index.js";
4
+
5
+ type allKeys<T> = T extends any ? keyof T : never;
6
+
7
+ export type inferFlattenedErrors<T extends ZodType<any, any, any>, U = string> = typeToFlattenedError<TypeOf<T>, U>;
8
+ export type typeToFlattenedError<T, U = string> = {
9
+ formErrors: U[];
10
+ fieldErrors: {
11
+ [P in allKeys<T>]?: U[];
12
+ };
13
+ };
14
+
15
+ export const ZodIssueCode = util.arrayToEnum([
16
+ "invalid_type",
17
+ "invalid_literal",
18
+ "custom",
19
+ "invalid_union",
20
+ "invalid_union_discriminator",
21
+ "invalid_enum_value",
22
+ "unrecognized_keys",
23
+ "invalid_arguments",
24
+ "invalid_return_type",
25
+ "invalid_date",
26
+ "invalid_string",
27
+ "too_small",
28
+ "too_big",
29
+ "invalid_intersection_types",
30
+ "not_multiple_of",
31
+ "not_finite",
32
+ ]);
33
+
34
+ export type ZodIssueCode = keyof typeof ZodIssueCode;
35
+
36
+ export type ZodIssueBase = {
37
+ path: (string | number)[];
38
+ message?: string | undefined;
39
+ };
40
+
41
+ export interface ZodInvalidTypeIssue extends ZodIssueBase {
42
+ code: typeof ZodIssueCode.invalid_type;
43
+ expected: ZodParsedType;
44
+ received: ZodParsedType;
45
+ }
46
+
47
+ export interface ZodInvalidLiteralIssue extends ZodIssueBase {
48
+ code: typeof ZodIssueCode.invalid_literal;
49
+ expected: unknown;
50
+ received: unknown;
51
+ }
52
+
53
+ export interface ZodUnrecognizedKeysIssue extends ZodIssueBase {
54
+ code: typeof ZodIssueCode.unrecognized_keys;
55
+ keys: string[];
56
+ }
57
+
58
+ export interface ZodInvalidUnionIssue extends ZodIssueBase {
59
+ code: typeof ZodIssueCode.invalid_union;
60
+ unionErrors: ZodError[];
61
+ }
62
+
63
+ export interface ZodInvalidUnionDiscriminatorIssue extends ZodIssueBase {
64
+ code: typeof ZodIssueCode.invalid_union_discriminator;
65
+ options: Primitive[];
66
+ }
67
+
68
+ export interface ZodInvalidEnumValueIssue extends ZodIssueBase {
69
+ received: string | number;
70
+ code: typeof ZodIssueCode.invalid_enum_value;
71
+ options: (string | number)[];
72
+ }
73
+
74
+ export interface ZodInvalidArgumentsIssue extends ZodIssueBase {
75
+ code: typeof ZodIssueCode.invalid_arguments;
76
+ argumentsError: ZodError;
77
+ }
78
+
79
+ export interface ZodInvalidReturnTypeIssue extends ZodIssueBase {
80
+ code: typeof ZodIssueCode.invalid_return_type;
81
+ returnTypeError: ZodError;
82
+ }
83
+
84
+ export interface ZodInvalidDateIssue extends ZodIssueBase {
85
+ code: typeof ZodIssueCode.invalid_date;
86
+ }
87
+
88
+ export type StringValidation =
89
+ | "email"
90
+ | "url"
91
+ | "emoji"
92
+ | "uuid"
93
+ | "nanoid"
94
+ | "regex"
95
+ | "cuid"
96
+ | "cuid2"
97
+ | "ulid"
98
+ | "datetime"
99
+ | "date"
100
+ | "time"
101
+ | "duration"
102
+ | "ip"
103
+ | "cidr"
104
+ | "base64"
105
+ | "jwt"
106
+ | "base64url"
107
+ | { includes: string; position?: number | undefined }
108
+ | { startsWith: string }
109
+ | { endsWith: string };
110
+
111
+ export interface ZodInvalidStringIssue extends ZodIssueBase {
112
+ code: typeof ZodIssueCode.invalid_string;
113
+ validation: StringValidation;
114
+ }
115
+
116
+ export interface ZodTooSmallIssue extends ZodIssueBase {
117
+ code: typeof ZodIssueCode.too_small;
118
+ minimum: number | bigint;
119
+ inclusive: boolean;
120
+ exact?: boolean;
121
+ type: "array" | "string" | "number" | "set" | "date" | "bigint";
122
+ }
123
+
124
+ export interface ZodTooBigIssue extends ZodIssueBase {
125
+ code: typeof ZodIssueCode.too_big;
126
+ maximum: number | bigint;
127
+ inclusive: boolean;
128
+ exact?: boolean;
129
+ type: "array" | "string" | "number" | "set" | "date" | "bigint";
130
+ }
131
+
132
+ export interface ZodInvalidIntersectionTypesIssue extends ZodIssueBase {
133
+ code: typeof ZodIssueCode.invalid_intersection_types;
134
+ }
135
+
136
+ export interface ZodNotMultipleOfIssue extends ZodIssueBase {
137
+ code: typeof ZodIssueCode.not_multiple_of;
138
+ multipleOf: number | bigint;
139
+ }
140
+
141
+ export interface ZodNotFiniteIssue extends ZodIssueBase {
142
+ code: typeof ZodIssueCode.not_finite;
143
+ }
144
+
145
+ export interface ZodCustomIssue extends ZodIssueBase {
146
+ code: typeof ZodIssueCode.custom;
147
+ params?: { [k: string]: any };
148
+ }
149
+
150
+ export type DenormalizedError = { [k: string]: DenormalizedError | string[] };
151
+
152
+ export type ZodIssueOptionalMessage =
153
+ | ZodInvalidTypeIssue
154
+ | ZodInvalidLiteralIssue
155
+ | ZodUnrecognizedKeysIssue
156
+ | ZodInvalidUnionIssue
157
+ | ZodInvalidUnionDiscriminatorIssue
158
+ | ZodInvalidEnumValueIssue
159
+ | ZodInvalidArgumentsIssue
160
+ | ZodInvalidReturnTypeIssue
161
+ | ZodInvalidDateIssue
162
+ | ZodInvalidStringIssue
163
+ | ZodTooSmallIssue
164
+ | ZodTooBigIssue
165
+ | ZodInvalidIntersectionTypesIssue
166
+ | ZodNotMultipleOfIssue
167
+ | ZodNotFiniteIssue
168
+ | ZodCustomIssue;
169
+
170
+ export type ZodIssue = ZodIssueOptionalMessage & {
171
+ fatal?: boolean | undefined;
172
+ message: string;
173
+ };
174
+
175
+ export const quotelessJson = (obj: any) => {
176
+ const json = JSON.stringify(obj, null, 2);
177
+ return json.replace(/"([^"]+)":/g, "$1:");
178
+ };
179
+
180
+ type recursiveZodFormattedError<T> = T extends [any, ...any[]]
181
+ ? { [K in keyof T]?: ZodFormattedError<T[K]> }
182
+ : T extends any[]
183
+ ? { [k: number]: ZodFormattedError<T[number]> }
184
+ : T extends object
185
+ ? { [K in keyof T]?: ZodFormattedError<T[K]> }
186
+ : unknown;
187
+
188
+ export type ZodFormattedError<T, U = string> = {
189
+ _errors: U[];
190
+ } & recursiveZodFormattedError<NonNullable<T>>;
191
+
192
+ export type inferFormattedError<T extends ZodType<any, any, any>, U = string> = ZodFormattedError<TypeOf<T>, U>;
193
+
194
+ export class ZodError<T = any> extends Error {
195
+ issues: ZodIssue[] = [];
196
+
197
+ get errors() {
198
+ return this.issues;
199
+ }
200
+
201
+ constructor(issues: ZodIssue[]) {
202
+ super();
203
+
204
+ const actualProto = new.target.prototype;
205
+ if (Object.setPrototypeOf) {
206
+ // eslint-disable-next-line ban/ban
207
+ Object.setPrototypeOf(this, actualProto);
208
+ } else {
209
+ (this as any).__proto__ = actualProto;
210
+ }
211
+ this.name = "ZodError";
212
+ this.issues = issues;
213
+ }
214
+
215
+ format(): ZodFormattedError<T>;
216
+ format<U>(mapper: (issue: ZodIssue) => U): ZodFormattedError<T, U>;
217
+ format(_mapper?: any) {
218
+ const mapper: (issue: ZodIssue) => any =
219
+ _mapper ||
220
+ function (issue: ZodIssue) {
221
+ return issue.message;
222
+ };
223
+ const fieldErrors: ZodFormattedError<T> = { _errors: [] } as any;
224
+ const processError = (error: ZodError) => {
225
+ for (const issue of error.issues) {
226
+ if (issue.code === "invalid_union") {
227
+ issue.unionErrors.map(processError);
228
+ } else if (issue.code === "invalid_return_type") {
229
+ processError(issue.returnTypeError);
230
+ } else if (issue.code === "invalid_arguments") {
231
+ processError(issue.argumentsError);
232
+ } else if (issue.path.length === 0) {
233
+ (fieldErrors as any)._errors.push(mapper(issue));
234
+ } else {
235
+ let curr: any = fieldErrors;
236
+ let i = 0;
237
+ while (i < issue.path.length) {
238
+ const el = issue.path[i]!;
239
+ const terminal = i === issue.path.length - 1;
240
+
241
+ if (!terminal) {
242
+ curr[el] = curr[el] || { _errors: [] };
243
+ // if (typeof el === "string") {
244
+ // curr[el] = curr[el] || { _errors: [] };
245
+ // } else if (typeof el === "number") {
246
+ // const errorArray: any = [];
247
+ // errorArray._errors = [];
248
+ // curr[el] = curr[el] || errorArray;
249
+ // }
250
+ } else {
251
+ curr[el] = curr[el] || { _errors: [] };
252
+ curr[el]._errors.push(mapper(issue));
253
+ }
254
+
255
+ curr = curr[el];
256
+ i++;
257
+ }
258
+ }
259
+ }
260
+ };
261
+
262
+ processError(this);
263
+ return fieldErrors;
264
+ }
265
+
266
+ static create = (issues: ZodIssue[]) => {
267
+ const error = new ZodError(issues);
268
+ return error;
269
+ };
270
+
271
+ static assert(value: unknown): asserts value is ZodError {
272
+ if (!(value instanceof ZodError)) {
273
+ throw new Error(`Not a ZodError: ${value}`);
274
+ }
275
+ }
276
+
277
+ override toString() {
278
+ return this.message;
279
+ }
280
+ override get message() {
281
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
282
+ }
283
+
284
+ get isEmpty(): boolean {
285
+ return this.issues.length === 0;
286
+ }
287
+
288
+ addIssue = (sub: ZodIssue) => {
289
+ this.issues = [...this.issues, sub];
290
+ };
291
+
292
+ addIssues = (subs: ZodIssue[] = []) => {
293
+ this.issues = [...this.issues, ...subs];
294
+ };
295
+
296
+ flatten(): typeToFlattenedError<T>;
297
+ flatten<U>(mapper?: (issue: ZodIssue) => U): typeToFlattenedError<T, U>;
298
+ flatten<U = string>(mapper: (issue: ZodIssue) => U = (issue: ZodIssue) => issue.message as any): any {
299
+ const fieldErrors: any = {};
300
+ const formErrors: U[] = [];
301
+ for (const sub of this.issues) {
302
+ if (sub.path.length > 0) {
303
+ const firstEl = sub.path[0]!;
304
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
305
+ fieldErrors[firstEl].push(mapper(sub));
306
+ } else {
307
+ formErrors.push(mapper(sub));
308
+ }
309
+ }
310
+ return { formErrors, fieldErrors };
311
+ }
312
+
313
+ get formErrors() {
314
+ return this.flatten();
315
+ }
316
+ }
317
+
318
+ type stripPath<T extends object> = T extends any ? util.OmitKeys<T, "path"> : never;
319
+
320
+ export type IssueData = stripPath<ZodIssueOptionalMessage> & {
321
+ path?: (string | number)[];
322
+ fatal?: boolean | undefined;
323
+ };
324
+
325
+ export type ErrorMapCtx = {
326
+ defaultError: string;
327
+ data: any;
328
+ };
329
+
330
+ export type ZodErrorMap = (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => { message: string };
node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/datetime.ts ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ const datetimeValidationSuite = new Benchmark.Suite("datetime");
4
+
5
+ const DATA = "2021-01-01";
6
+ const MONTHS_31 = new Set([1, 3, 5, 7, 8, 10, 12]);
7
+ const MONTHS_30 = new Set([4, 6, 9, 11]);
8
+
9
+ const simpleDatetimeRegex = /^(\d{4})-(\d{2})-(\d{2})$/;
10
+ const datetimeRegexNoLeapYearValidation =
11
+ /^\d{4}-((0[13578]|10|12)-31|(0[13-9]|1[0-2])-30|(0[1-9]|1[0-2])-(0[1-9]|1\d|2\d))$/;
12
+ const datetimeRegexWithLeapYearValidation =
13
+ /^((\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\d|3[01])|(0[469]|11)-(0[1-9]|[12]\d|30)|(02)-(0[1-9]|1\d|2[0-8])))$/;
14
+
15
+ datetimeValidationSuite
16
+ .add("new Date()", () => {
17
+ return !Number.isNaN(new Date(DATA).getTime());
18
+ })
19
+ .add("regex (no validation)", () => {
20
+ return simpleDatetimeRegex.test(DATA);
21
+ })
22
+ .add("regex (no leap year)", () => {
23
+ return datetimeRegexNoLeapYearValidation.test(DATA);
24
+ })
25
+ .add("regex (w/ leap year)", () => {
26
+ return datetimeRegexWithLeapYearValidation.test(DATA);
27
+ })
28
+ .add("capture groups + code", () => {
29
+ const match = DATA.match(simpleDatetimeRegex);
30
+ if (!match) return false;
31
+
32
+ // Extract year, month, and day from the capture groups
33
+ const year = Number.parseInt(match[1], 10);
34
+ const month = Number.parseInt(match[2], 10); // month is 0-indexed in JavaScript Date, so subtract 1
35
+ const day = Number.parseInt(match[3], 10);
36
+
37
+ if (month === 2) {
38
+ if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {
39
+ return day <= 29;
40
+ }
41
+ return day <= 28;
42
+ }
43
+ if (MONTHS_30.has(month)) {
44
+ return day <= 30;
45
+ }
46
+ if (MONTHS_31.has(month)) {
47
+ return day <= 31;
48
+ }
49
+ return false;
50
+ })
51
+
52
+ .on("cycle", (e: Benchmark.Event) => {
53
+ console.log(`${datetimeValidationSuite.name!}: ${e.target}`);
54
+ });
55
+
56
+ export default {
57
+ suites: [datetimeValidationSuite],
58
+ };
node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ import { z } from "zod/v3";
4
+
5
+ const doubleSuite = new Benchmark.Suite("z.discriminatedUnion: double");
6
+ const manySuite = new Benchmark.Suite("z.discriminatedUnion: many");
7
+
8
+ const aSchema = z.object({
9
+ type: z.literal("a"),
10
+ });
11
+ const objA = {
12
+ type: "a",
13
+ };
14
+
15
+ const bSchema = z.object({
16
+ type: z.literal("b"),
17
+ });
18
+ const objB = {
19
+ type: "b",
20
+ };
21
+
22
+ const cSchema = z.object({
23
+ type: z.literal("c"),
24
+ });
25
+ const objC = {
26
+ type: "c",
27
+ };
28
+
29
+ const dSchema = z.object({
30
+ type: z.literal("d"),
31
+ });
32
+
33
+ const double = z.discriminatedUnion("type", [aSchema, bSchema]);
34
+ const many = z.discriminatedUnion("type", [aSchema, bSchema, cSchema, dSchema]);
35
+
36
+ doubleSuite
37
+ .add("valid: a", () => {
38
+ double.parse(objA);
39
+ })
40
+ .add("valid: b", () => {
41
+ double.parse(objB);
42
+ })
43
+ .add("invalid: null", () => {
44
+ try {
45
+ double.parse(null);
46
+ } catch (_err) {}
47
+ })
48
+ .add("invalid: wrong shape", () => {
49
+ try {
50
+ double.parse(objC);
51
+ } catch (_err) {}
52
+ })
53
+ .on("cycle", (e: Benchmark.Event) => {
54
+ console.log(`${(doubleSuite as any).name}: ${e.target}`);
55
+ });
56
+
57
+ manySuite
58
+ .add("valid: a", () => {
59
+ many.parse(objA);
60
+ })
61
+ .add("valid: c", () => {
62
+ many.parse(objC);
63
+ })
64
+ .add("invalid: null", () => {
65
+ try {
66
+ many.parse(null);
67
+ } catch (_err) {}
68
+ })
69
+ .add("invalid: wrong shape", () => {
70
+ try {
71
+ many.parse({ type: "unknown" });
72
+ } catch (_err) {}
73
+ })
74
+ .on("cycle", (e: Benchmark.Event) => {
75
+ console.log(`${(manySuite as any).name}: ${e.target}`);
76
+ });
77
+
78
+ export default {
79
+ suites: [doubleSuite, manySuite],
80
+ };
node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/index.ts ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type Benchmark from "benchmark";
2
+
3
+ import datetimeBenchmarks from "./datetime.js";
4
+ import discriminatedUnionBenchmarks from "./discriminatedUnion.js";
5
+ import ipv4Benchmarks from "./ipv4.js";
6
+ import objectBenchmarks from "./object.js";
7
+ import primitiveBenchmarks from "./primitives.js";
8
+ import realworld from "./realworld.js";
9
+ import stringBenchmarks from "./string.js";
10
+ import unionBenchmarks from "./union.js";
11
+
12
+ const argv = process.argv.slice(2);
13
+ let suites: Benchmark.Suite[] = [];
14
+
15
+ if (!argv.length) {
16
+ suites = [
17
+ ...realworld.suites,
18
+ ...primitiveBenchmarks.suites,
19
+ ...stringBenchmarks.suites,
20
+ ...objectBenchmarks.suites,
21
+ ...unionBenchmarks.suites,
22
+ ...discriminatedUnionBenchmarks.suites,
23
+ ];
24
+ } else {
25
+ if (argv.includes("--realworld")) {
26
+ suites.push(...realworld.suites);
27
+ }
28
+ if (argv.includes("--primitives")) {
29
+ suites.push(...primitiveBenchmarks.suites);
30
+ }
31
+ if (argv.includes("--string")) {
32
+ suites.push(...stringBenchmarks.suites);
33
+ }
34
+ if (argv.includes("--object")) {
35
+ suites.push(...objectBenchmarks.suites);
36
+ }
37
+ if (argv.includes("--union")) {
38
+ suites.push(...unionBenchmarks.suites);
39
+ }
40
+ if (argv.includes("--discriminatedUnion")) {
41
+ suites.push(...datetimeBenchmarks.suites);
42
+ }
43
+ if (argv.includes("--datetime")) {
44
+ suites.push(...datetimeBenchmarks.suites);
45
+ }
46
+ if (argv.includes("--ipv4")) {
47
+ suites.push(...ipv4Benchmarks.suites);
48
+ }
49
+ }
50
+
51
+ for (const suite of suites) {
52
+ suite.run({});
53
+ }
54
+
55
+ // exit on Ctrl-C
56
+ process.on("SIGINT", function () {
57
+ console.log("Exiting...");
58
+ process.exit();
59
+ });
node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/ipv4.ts ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ const suite = new Benchmark.Suite("ipv4");
4
+
5
+ const DATA = "127.0.0.1";
6
+ const ipv4RegexA =
7
+ /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;
8
+ const ipv4RegexB =
9
+ /^(?:(?:(?=(25[0-5]))\1|(?=(2[0-4][0-9]))\2|(?=(1[0-9]{2}))\3|(?=([0-9]{1,2}))\4)\.){3}(?:(?=(25[0-5]))\5|(?=(2[0-4][0-9]))\6|(?=(1[0-9]{2}))\7|(?=([0-9]{1,2}))\8)$/;
10
+ const ipv4RegexC = /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;
11
+ const ipv4RegexD = /^(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/;
12
+ const ipv4RegexE = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.){3}(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)$/;
13
+ const ipv4RegexF = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/;
14
+ const ipv4RegexG = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/;
15
+ const ipv4RegexH = /^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\.(?!$)|$)){4}$/;
16
+ const ipv4RegexI =
17
+ /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
18
+
19
+ suite
20
+ .add("A", () => {
21
+ return ipv4RegexA.test(DATA);
22
+ })
23
+ .add("B", () => {
24
+ return ipv4RegexB.test(DATA);
25
+ })
26
+ .add("C", () => {
27
+ return ipv4RegexC.test(DATA);
28
+ })
29
+ .add("D", () => {
30
+ return ipv4RegexD.test(DATA);
31
+ })
32
+ .add("E", () => {
33
+ return ipv4RegexE.test(DATA);
34
+ })
35
+ .add("F", () => {
36
+ return ipv4RegexF.test(DATA);
37
+ })
38
+ .add("G", () => {
39
+ return ipv4RegexG.test(DATA);
40
+ })
41
+ .add("H", () => {
42
+ return ipv4RegexH.test(DATA);
43
+ })
44
+ .add("I", () => {
45
+ return ipv4RegexI.test(DATA);
46
+ })
47
+ .on("cycle", (e: Benchmark.Event) => {
48
+ console.log(`${suite.name!}: ${e.target}`);
49
+ });
50
+
51
+ export default {
52
+ suites: [suite],
53
+ };
54
+
55
+ if (require.main === module) {
56
+ suite.run();
57
+ }
node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/object.ts ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ import { z } from "zod/v3";
4
+
5
+ const emptySuite = new Benchmark.Suite("z.object: empty");
6
+ const shortSuite = new Benchmark.Suite("z.object: short");
7
+ const longSuite = new Benchmark.Suite("z.object: long");
8
+
9
+ const empty = z.object({});
10
+ const short = z.object({
11
+ string: z.string(),
12
+ });
13
+ const long = z.object({
14
+ string: z.string(),
15
+ number: z.number(),
16
+ boolean: z.boolean(),
17
+ });
18
+
19
+ emptySuite
20
+ .add("valid", () => {
21
+ empty.parse({});
22
+ })
23
+ .add("valid: extra keys", () => {
24
+ empty.parse({ string: "string" });
25
+ })
26
+ .add("invalid: null", () => {
27
+ try {
28
+ empty.parse(null);
29
+ } catch (_err) {}
30
+ })
31
+ .on("cycle", (e: Benchmark.Event) => {
32
+ console.log(`${(emptySuite as any).name}: ${e.target}`);
33
+ });
34
+
35
+ shortSuite
36
+ .add("valid", () => {
37
+ short.parse({ string: "string" });
38
+ })
39
+ .add("valid: extra keys", () => {
40
+ short.parse({ string: "string", number: 42 });
41
+ })
42
+ .add("invalid: null", () => {
43
+ try {
44
+ short.parse(null);
45
+ } catch (_err) {}
46
+ })
47
+ .on("cycle", (e: Benchmark.Event) => {
48
+ console.log(`${(shortSuite as any).name}: ${e.target}`);
49
+ });
50
+
51
+ longSuite
52
+ .add("valid", () => {
53
+ long.parse({ string: "string", number: 42, boolean: true });
54
+ })
55
+ .add("valid: extra keys", () => {
56
+ long.parse({ string: "string", number: 42, boolean: true, list: [] });
57
+ })
58
+ .add("invalid: null", () => {
59
+ try {
60
+ long.parse(null);
61
+ } catch (_err) {}
62
+ })
63
+ .on("cycle", (e: Benchmark.Event) => {
64
+ console.log(`${(longSuite as any).name}: ${e.target}`);
65
+ });
66
+
67
+ export default {
68
+ suites: [emptySuite, shortSuite, longSuite],
69
+ };
node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/primitives.ts ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ import { z } from "zod/v3";
4
+ import { Mocker } from "../tests/Mocker.js";
5
+
6
+ const val = new Mocker();
7
+
8
+ const enumSuite = new Benchmark.Suite("z.enum");
9
+ const enumSchema = z.enum(["a", "b", "c"]);
10
+
11
+ enumSuite
12
+ .add("valid", () => {
13
+ enumSchema.parse("a");
14
+ })
15
+ .add("invalid", () => {
16
+ try {
17
+ enumSchema.parse("x");
18
+ } catch (_e: any) {}
19
+ })
20
+ .on("cycle", (e: Benchmark.Event) => {
21
+ console.log(`z.enum: ${e.target}`);
22
+ });
23
+
24
+ const longEnumSuite = new Benchmark.Suite("long z.enum");
25
+ const longEnumSchema = z.enum([
26
+ "one",
27
+ "two",
28
+ "three",
29
+ "four",
30
+ "five",
31
+ "six",
32
+ "seven",
33
+ "eight",
34
+ "nine",
35
+ "ten",
36
+ "eleven",
37
+ "twelve",
38
+ "thirteen",
39
+ "fourteen",
40
+ "fifteen",
41
+ "sixteen",
42
+ "seventeen",
43
+ ]);
44
+
45
+ longEnumSuite
46
+ .add("valid", () => {
47
+ longEnumSchema.parse("five");
48
+ })
49
+ .add("invalid", () => {
50
+ try {
51
+ longEnumSchema.parse("invalid");
52
+ } catch (_e: any) {}
53
+ })
54
+ .on("cycle", (e: Benchmark.Event) => {
55
+ console.log(`long z.enum: ${e.target}`);
56
+ });
57
+
58
+ const undefinedSuite = new Benchmark.Suite("z.undefined");
59
+ const undefinedSchema = z.undefined();
60
+
61
+ undefinedSuite
62
+ .add("valid", () => {
63
+ undefinedSchema.parse(undefined);
64
+ })
65
+ .add("invalid", () => {
66
+ try {
67
+ undefinedSchema.parse(1);
68
+ } catch (_e: any) {}
69
+ })
70
+ .on("cycle", (e: Benchmark.Event) => {
71
+ console.log(`z.undefined: ${e.target}`);
72
+ });
73
+
74
+ const literalSuite = new Benchmark.Suite("z.literal");
75
+ const short = "short";
76
+ const bad = "bad";
77
+ const literalSchema = z.literal("short");
78
+
79
+ literalSuite
80
+ .add("valid", () => {
81
+ literalSchema.parse(short);
82
+ })
83
+ .add("invalid", () => {
84
+ try {
85
+ literalSchema.parse(bad);
86
+ } catch (_e: any) {}
87
+ })
88
+ .on("cycle", (e: Benchmark.Event) => {
89
+ console.log(`z.literal: ${e.target}`);
90
+ });
91
+
92
+ const numberSuite = new Benchmark.Suite("z.number");
93
+ const numberSchema = z.number().int();
94
+
95
+ numberSuite
96
+ .add("valid", () => {
97
+ numberSchema.parse(1);
98
+ })
99
+ .add("invalid type", () => {
100
+ try {
101
+ numberSchema.parse("bad");
102
+ } catch (_e: any) {}
103
+ })
104
+ .add("invalid number", () => {
105
+ try {
106
+ numberSchema.parse(0.5);
107
+ } catch (_e: any) {}
108
+ })
109
+ .on("cycle", (e: Benchmark.Event) => {
110
+ console.log(`z.number: ${e.target}`);
111
+ });
112
+
113
+ const dateSuite = new Benchmark.Suite("z.date");
114
+
115
+ const plainDate = z.date();
116
+ const minMaxDate = z.date().min(new Date("2021-01-01")).max(new Date("2030-01-01"));
117
+
118
+ dateSuite
119
+ .add("valid", () => {
120
+ plainDate.parse(new Date());
121
+ })
122
+ .add("invalid", () => {
123
+ try {
124
+ plainDate.parse(1);
125
+ } catch (_e: any) {}
126
+ })
127
+ .add("valid min and max", () => {
128
+ minMaxDate.parse(new Date("2023-01-01"));
129
+ })
130
+ .add("invalid min", () => {
131
+ try {
132
+ minMaxDate.parse(new Date("2019-01-01"));
133
+ } catch (_e: any) {}
134
+ })
135
+ .add("invalid max", () => {
136
+ try {
137
+ minMaxDate.parse(new Date("2031-01-01"));
138
+ } catch (_e: any) {}
139
+ })
140
+ .on("cycle", (e: Benchmark.Event) => {
141
+ console.log(`z.date: ${e.target}`);
142
+ });
143
+
144
+ const symbolSuite = new Benchmark.Suite("z.symbol");
145
+ const symbolSchema = z.symbol();
146
+
147
+ symbolSuite
148
+ .add("valid", () => {
149
+ symbolSchema.parse(val.symbol);
150
+ })
151
+ .add("invalid", () => {
152
+ try {
153
+ symbolSchema.parse(1);
154
+ } catch (_e: any) {}
155
+ })
156
+ .on("cycle", (e: Benchmark.Event) => {
157
+ console.log(`z.symbol: ${e.target}`);
158
+ });
159
+
160
+ export default {
161
+ suites: [enumSuite, longEnumSuite, undefinedSuite, literalSuite, numberSuite, dateSuite, symbolSuite],
162
+ };
node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/realworld.ts ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ import { z } from "zod/v3";
4
+
5
+ const shortSuite = new Benchmark.Suite("realworld");
6
+
7
+ const People = z.array(
8
+ z.object({
9
+ type: z.literal("person"),
10
+ hair: z.enum(["blue", "brown"]),
11
+ active: z.boolean(),
12
+ name: z.string(),
13
+ age: z.number().int(),
14
+ hobbies: z.array(z.string()),
15
+ address: z.object({
16
+ street: z.string(),
17
+ zip: z.string(),
18
+ country: z.string(),
19
+ }),
20
+ })
21
+ );
22
+
23
+ let i = 0;
24
+
25
+ function num() {
26
+ return ++i;
27
+ }
28
+
29
+ function str() {
30
+ return (++i % 100).toString(16);
31
+ }
32
+
33
+ function array<T>(fn: () => T): T[] {
34
+ return Array.from({ length: ++i % 10 }, () => fn());
35
+ }
36
+
37
+ const people = Array.from({ length: 100 }, () => {
38
+ return {
39
+ type: "person",
40
+ hair: i % 2 ? "blue" : "brown",
41
+ active: !!(i % 2),
42
+ name: str(),
43
+ age: num(),
44
+ hobbies: array(str),
45
+ address: {
46
+ street: str(),
47
+ zip: str(),
48
+ country: str(),
49
+ },
50
+ };
51
+ });
52
+
53
+ shortSuite
54
+ .add("valid", () => {
55
+ People.parse(people);
56
+ })
57
+ .on("cycle", (e: Benchmark.Event) => {
58
+ console.log(`${(shortSuite as any).name}: ${e.target}`);
59
+ });
60
+
61
+ export default {
62
+ suites: [shortSuite],
63
+ };
node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/string.ts ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ import { z } from "zod/v3";
4
+
5
+ const SUITE_NAME = "z.string";
6
+ const suite = new Benchmark.Suite(SUITE_NAME);
7
+
8
+ const empty = "";
9
+ const short = "short";
10
+ const long = "long".repeat(256);
11
+ const manual = (str: unknown) => {
12
+ if (typeof str !== "string") {
13
+ throw new Error("Not a string");
14
+ }
15
+
16
+ return str;
17
+ };
18
+ const stringSchema = z.string();
19
+ const optionalStringSchema = z.string().optional();
20
+ const optionalNullableStringSchema = z.string().optional().nullable();
21
+
22
+ suite
23
+ .add("empty string", () => {
24
+ stringSchema.parse(empty);
25
+ })
26
+ .add("short string", () => {
27
+ stringSchema.parse(short);
28
+ })
29
+ .add("long string", () => {
30
+ stringSchema.parse(long);
31
+ })
32
+ .add("optional string", () => {
33
+ optionalStringSchema.parse(long);
34
+ })
35
+ .add("nullable string", () => {
36
+ optionalNullableStringSchema.parse(long);
37
+ })
38
+ .add("nullable (null) string", () => {
39
+ optionalNullableStringSchema.parse(null);
40
+ })
41
+ .add("invalid: null", () => {
42
+ try {
43
+ stringSchema.parse(null);
44
+ } catch (_err) {}
45
+ })
46
+ .add("manual parser: long", () => {
47
+ manual(long);
48
+ })
49
+ .on("cycle", (e: Benchmark.Event) => {
50
+ console.log(`${SUITE_NAME}: ${e.target}`);
51
+ });
52
+
53
+ export default {
54
+ suites: [suite],
55
+ };
node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/benchmarks/union.ts ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ import { z } from "zod/v3";
4
+
5
+ const doubleSuite = new Benchmark.Suite("z.union: double");
6
+ const manySuite = new Benchmark.Suite("z.union: many");
7
+
8
+ const aSchema = z.object({
9
+ type: z.literal("a"),
10
+ });
11
+ const objA = {
12
+ type: "a",
13
+ };
14
+
15
+ const bSchema = z.object({
16
+ type: z.literal("b"),
17
+ });
18
+ const objB = {
19
+ type: "b",
20
+ };
21
+
22
+ const cSchema = z.object({
23
+ type: z.literal("c"),
24
+ });
25
+ const objC = {
26
+ type: "c",
27
+ };
28
+
29
+ const dSchema = z.object({
30
+ type: z.literal("d"),
31
+ });
32
+
33
+ const double = z.union([aSchema, bSchema]);
34
+ const many = z.union([aSchema, bSchema, cSchema, dSchema]);
35
+
36
+ doubleSuite
37
+ .add("valid: a", () => {
38
+ double.parse(objA);
39
+ })
40
+ .add("valid: b", () => {
41
+ double.parse(objB);
42
+ })
43
+ .add("invalid: null", () => {
44
+ try {
45
+ double.parse(null);
46
+ } catch (_err) {}
47
+ })
48
+ .add("invalid: wrong shape", () => {
49
+ try {
50
+ double.parse(objC);
51
+ } catch (_err) {}
52
+ })
53
+ .on("cycle", (e: Benchmark.Event) => {
54
+ console.log(`${(doubleSuite as any).name}: ${e.target}`);
55
+ });
56
+
57
+ manySuite
58
+ .add("valid: a", () => {
59
+ many.parse(objA);
60
+ })
61
+ .add("valid: c", () => {
62
+ many.parse(objC);
63
+ })
64
+ .add("invalid: null", () => {
65
+ try {
66
+ many.parse(null);
67
+ } catch (_err) {}
68
+ })
69
+ .add("invalid: wrong shape", () => {
70
+ try {
71
+ many.parse({ type: "unknown" });
72
+ } catch (_err) {}
73
+ })
74
+ .on("cycle", (e: Benchmark.Event) => {
75
+ console.log(`${(manySuite as any).name}: ${e.target}`);
76
+ });
77
+
78
+ export default {
79
+ suites: [doubleSuite, manySuite],
80
+ };
node_modules/@jimp/plugin-flip/node_modules/zod/src/v3/errors.ts ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { ZodErrorMap } from "./ZodError.js";
2
+ import defaultErrorMap from "./locales/en.js";
3
+
4
+ let overrideErrorMap = defaultErrorMap;
5
+ export { defaultErrorMap };
6
+
7
+ export function setErrorMap(map: ZodErrorMap) {
8
+ overrideErrorMap = map;
9
+ }
10
+
11
+ export function getErrorMap() {
12
+ return overrideErrorMap;
13
+ }
node_modules/@jimp/plugin-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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-flip/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
+ };