unocab 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +108 -0
  3. package/esm/_dnt.shims.d.ts +4 -0
  4. package/esm/_dnt.shims.js +62 -0
  5. package/esm/_dnt.test_shims.d.ts +7 -0
  6. package/esm/deps/deno.land/std@0.190.0/fmt/colors.d.ts +270 -0
  7. package/esm/deps/deno.land/std@0.190.0/testing/_diff.d.ts +26 -0
  8. package/esm/deps/deno.land/std@0.190.0/testing/_format.d.ts +1 -0
  9. package/esm/deps/deno.land/std@0.190.0/testing/asserts.d.ts +284 -0
  10. package/esm/deps/deno.land/x/zod@v3.21.4/ZodError.d.ts +163 -0
  11. package/esm/deps/deno.land/x/zod@v3.21.4/ZodError.js +148 -0
  12. package/esm/deps/deno.land/x/zod@v3.21.4/errors.d.ts +5 -0
  13. package/esm/deps/deno.land/x/zod@v3.21.4/errors.js +9 -0
  14. package/esm/deps/deno.land/x/zod@v3.21.4/external.d.ts +6 -0
  15. package/esm/deps/deno.land/x/zod@v3.21.4/external.js +6 -0
  16. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.d.ts +8 -0
  17. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.js +1 -0
  18. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.d.ts +9 -0
  19. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.js +5 -0
  20. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.d.ts +78 -0
  21. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.js +104 -0
  22. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.d.ts +8 -0
  23. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.js +1 -0
  24. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.d.ts +2 -0
  25. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.js +1 -0
  26. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/util.d.ts +68 -0
  27. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/util.js +138 -0
  28. package/esm/deps/deno.land/x/zod@v3.21.4/index.d.ts +4 -0
  29. package/esm/deps/deno.land/x/zod@v3.21.4/index.js +4 -0
  30. package/esm/deps/deno.land/x/zod@v3.21.4/locales/en.d.ts +3 -0
  31. package/esm/deps/deno.land/x/zod@v3.21.4/locales/en.js +127 -0
  32. package/esm/deps/deno.land/x/zod@v3.21.4/mod.d.ts +1 -0
  33. package/esm/deps/deno.land/x/zod@v3.21.4/mod.js +1 -0
  34. package/esm/deps/deno.land/x/zod@v3.21.4/types.d.ts +965 -0
  35. package/esm/deps/deno.land/x/zod@v3.21.4/types.js +3689 -0
  36. package/esm/errors.d.ts +72 -0
  37. package/esm/errors.js +39 -0
  38. package/esm/game.d.ts +868 -0
  39. package/esm/game.js +868 -0
  40. package/esm/mod.d.ts +3 -0
  41. package/esm/mod.js +3 -0
  42. package/esm/package.json +3 -0
  43. package/esm/tests/basic-tests.d.ts +8 -0
  44. package/esm/tests/draw-tests.d.ts +8 -0
  45. package/esm/tests/non-specific-tests.test.d.ts +1 -0
  46. package/esm/tests/rule-violation-tests.d.ts +8 -0
  47. package/esm/tests/specific-tests.test.d.ts +1 -0
  48. package/esm/tests/test-utils.d.ts +91 -0
  49. package/esm/tests/turn-tests.d.ts +8 -0
  50. package/esm/types.d.ts +2280 -0
  51. package/esm/types.js +152 -0
  52. package/esm/utils.d.ts +19 -0
  53. package/esm/utils.js +44 -0
  54. package/package.json +32 -0
  55. package/script/_dnt.shims.d.ts +4 -0
  56. package/script/_dnt.shims.js +66 -0
  57. package/script/_dnt.test_shims.d.ts +7 -0
  58. package/script/deps/deno.land/std@0.190.0/fmt/colors.d.ts +270 -0
  59. package/script/deps/deno.land/std@0.190.0/testing/_diff.d.ts +26 -0
  60. package/script/deps/deno.land/std@0.190.0/testing/_format.d.ts +1 -0
  61. package/script/deps/deno.land/std@0.190.0/testing/asserts.d.ts +284 -0
  62. package/script/deps/deno.land/x/zod@v3.21.4/ZodError.d.ts +163 -0
  63. package/script/deps/deno.land/x/zod@v3.21.4/ZodError.js +152 -0
  64. package/script/deps/deno.land/x/zod@v3.21.4/errors.d.ts +5 -0
  65. package/script/deps/deno.land/x/zod@v3.21.4/errors.js +17 -0
  66. package/script/deps/deno.land/x/zod@v3.21.4/external.d.ts +6 -0
  67. package/script/deps/deno.land/x/zod@v3.21.4/external.js +22 -0
  68. package/script/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.d.ts +8 -0
  69. package/script/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.js +2 -0
  70. package/script/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.d.ts +9 -0
  71. package/script/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.js +8 -0
  72. package/script/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.d.ts +78 -0
  73. package/script/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.js +119 -0
  74. package/script/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.d.ts +8 -0
  75. package/script/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.js +2 -0
  76. package/script/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.d.ts +2 -0
  77. package/script/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.js +2 -0
  78. package/script/deps/deno.land/x/zod@v3.21.4/helpers/util.d.ts +68 -0
  79. package/script/deps/deno.land/x/zod@v3.21.4/helpers/util.js +142 -0
  80. package/script/deps/deno.land/x/zod@v3.21.4/index.d.ts +4 -0
  81. package/script/deps/deno.land/x/zod@v3.21.4/index.js +33 -0
  82. package/script/deps/deno.land/x/zod@v3.21.4/locales/en.d.ts +3 -0
  83. package/script/deps/deno.land/x/zod@v3.21.4/locales/en.js +129 -0
  84. package/script/deps/deno.land/x/zod@v3.21.4/mod.d.ts +1 -0
  85. package/script/deps/deno.land/x/zod@v3.21.4/mod.js +17 -0
  86. package/script/deps/deno.land/x/zod@v3.21.4/types.d.ts +965 -0
  87. package/script/deps/deno.land/x/zod@v3.21.4/types.js +3739 -0
  88. package/script/errors.d.ts +72 -0
  89. package/script/errors.js +43 -0
  90. package/script/game.d.ts +868 -0
  91. package/script/game.js +895 -0
  92. package/script/mod.d.ts +3 -0
  93. package/script/mod.js +19 -0
  94. package/script/package.json +3 -0
  95. package/script/tests/basic-tests.d.ts +8 -0
  96. package/script/tests/draw-tests.d.ts +8 -0
  97. package/script/tests/non-specific-tests.test.d.ts +1 -0
  98. package/script/tests/rule-violation-tests.d.ts +8 -0
  99. package/script/tests/specific-tests.test.d.ts +1 -0
  100. package/script/tests/test-utils.d.ts +91 -0
  101. package/script/tests/turn-tests.d.ts +8 -0
  102. package/script/types.d.ts +2280 -0
  103. package/script/types.js +155 -0
  104. package/script/utils.d.ts +19 -0
  105. package/script/utils.js +50 -0
@@ -0,0 +1,78 @@
1
+ import type { IssueData, ZodErrorMap, ZodIssue } from "../ZodError.js";
2
+ import type { ZodParsedType } from "./util.js";
3
+ export declare const makeIssue: (params: {
4
+ data: any;
5
+ path: (string | number)[];
6
+ errorMaps: ZodErrorMap[];
7
+ issueData: IssueData;
8
+ }) => ZodIssue;
9
+ export type ParseParams = {
10
+ path: (string | number)[];
11
+ errorMap: ZodErrorMap;
12
+ async: boolean;
13
+ };
14
+ export type ParsePathComponent = string | number;
15
+ export type ParsePath = ParsePathComponent[];
16
+ export declare const EMPTY_PATH: ParsePath;
17
+ export interface ParseContext {
18
+ readonly common: {
19
+ readonly issues: ZodIssue[];
20
+ readonly contextualErrorMap?: ZodErrorMap;
21
+ readonly async: boolean;
22
+ };
23
+ readonly path: ParsePath;
24
+ readonly schemaErrorMap?: ZodErrorMap;
25
+ readonly parent: ParseContext | null;
26
+ readonly data: any;
27
+ readonly parsedType: ZodParsedType;
28
+ }
29
+ export type ParseInput = {
30
+ data: any;
31
+ path: (string | number)[];
32
+ parent: ParseContext;
33
+ };
34
+ export declare function addIssueToContext(ctx: ParseContext, issueData: IssueData): void;
35
+ export type ObjectPair = {
36
+ key: SyncParseReturnType<any>;
37
+ value: SyncParseReturnType<any>;
38
+ };
39
+ export declare class ParseStatus {
40
+ value: "aborted" | "dirty" | "valid";
41
+ dirty(): void;
42
+ abort(): void;
43
+ static mergeArray(status: ParseStatus, results: SyncParseReturnType<any>[]): SyncParseReturnType;
44
+ static mergeObjectAsync(status: ParseStatus, pairs: {
45
+ key: ParseReturnType<any>;
46
+ value: ParseReturnType<any>;
47
+ }[]): Promise<SyncParseReturnType<any>>;
48
+ static mergeObjectSync(status: ParseStatus, pairs: {
49
+ key: SyncParseReturnType<any>;
50
+ value: SyncParseReturnType<any>;
51
+ alwaysSet?: boolean;
52
+ }[]): SyncParseReturnType;
53
+ }
54
+ export interface ParseResult {
55
+ status: "aborted" | "dirty" | "valid";
56
+ data: any;
57
+ }
58
+ export type INVALID = {
59
+ status: "aborted";
60
+ };
61
+ export declare const INVALID: INVALID;
62
+ export type DIRTY<T> = {
63
+ status: "dirty";
64
+ value: T;
65
+ };
66
+ export declare const DIRTY: <T>(value: T) => DIRTY<T>;
67
+ export type OK<T> = {
68
+ status: "valid";
69
+ value: T;
70
+ };
71
+ export declare const OK: <T>(value: T) => OK<T>;
72
+ export type SyncParseReturnType<T = any> = OK<T> | DIRTY<T> | INVALID;
73
+ export type AsyncParseReturnType<T> = Promise<SyncParseReturnType<T>>;
74
+ export type ParseReturnType<T> = SyncParseReturnType<T> | AsyncParseReturnType<T>;
75
+ export declare const isAborted: (x: ParseReturnType<any>) => x is INVALID;
76
+ export declare const isDirty: <T>(x: ParseReturnType<T>) => x is OK<T> | DIRTY<T>;
77
+ export declare const isValid: <T>(x: ParseReturnType<T>) => x is OK<T> | DIRTY<T>;
78
+ export declare const isAsync: <T>(x: ParseReturnType<T>) => x is AsyncParseReturnType<T>;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = void 0;
7
+ const errors_js_1 = require("../errors.js");
8
+ const en_js_1 = __importDefault(require("../locales/en.js"));
9
+ const makeIssue = (params) => {
10
+ const { data, path, errorMaps, issueData } = params;
11
+ const fullPath = [...path, ...(issueData.path || [])];
12
+ const fullIssue = {
13
+ ...issueData,
14
+ path: fullPath,
15
+ };
16
+ let errorMessage = "";
17
+ const maps = errorMaps
18
+ .filter((m) => !!m)
19
+ .slice()
20
+ .reverse();
21
+ for (const map of maps) {
22
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
23
+ }
24
+ return {
25
+ ...issueData,
26
+ path: fullPath,
27
+ message: issueData.message || errorMessage,
28
+ };
29
+ };
30
+ exports.makeIssue = makeIssue;
31
+ exports.EMPTY_PATH = [];
32
+ function addIssueToContext(ctx, issueData) {
33
+ const issue = (0, exports.makeIssue)({
34
+ issueData: issueData,
35
+ data: ctx.data,
36
+ path: ctx.path,
37
+ errorMaps: [
38
+ ctx.common.contextualErrorMap,
39
+ ctx.schemaErrorMap,
40
+ (0, errors_js_1.getErrorMap)(),
41
+ en_js_1.default, // then global default map
42
+ ].filter((x) => !!x),
43
+ });
44
+ ctx.common.issues.push(issue);
45
+ }
46
+ exports.addIssueToContext = addIssueToContext;
47
+ class ParseStatus {
48
+ constructor() {
49
+ Object.defineProperty(this, "value", {
50
+ enumerable: true,
51
+ configurable: true,
52
+ writable: true,
53
+ value: "valid"
54
+ });
55
+ }
56
+ dirty() {
57
+ if (this.value === "valid")
58
+ this.value = "dirty";
59
+ }
60
+ abort() {
61
+ if (this.value !== "aborted")
62
+ this.value = "aborted";
63
+ }
64
+ static mergeArray(status, results) {
65
+ const arrayValue = [];
66
+ for (const s of results) {
67
+ if (s.status === "aborted")
68
+ return exports.INVALID;
69
+ if (s.status === "dirty")
70
+ status.dirty();
71
+ arrayValue.push(s.value);
72
+ }
73
+ return { status: status.value, value: arrayValue };
74
+ }
75
+ static async mergeObjectAsync(status, pairs) {
76
+ const syncPairs = [];
77
+ for (const pair of pairs) {
78
+ syncPairs.push({
79
+ key: await pair.key,
80
+ value: await pair.value,
81
+ });
82
+ }
83
+ return ParseStatus.mergeObjectSync(status, syncPairs);
84
+ }
85
+ static mergeObjectSync(status, pairs) {
86
+ const finalObject = {};
87
+ for (const pair of pairs) {
88
+ const { key, value } = pair;
89
+ if (key.status === "aborted")
90
+ return exports.INVALID;
91
+ if (value.status === "aborted")
92
+ return exports.INVALID;
93
+ if (key.status === "dirty")
94
+ status.dirty();
95
+ if (value.status === "dirty")
96
+ status.dirty();
97
+ if (typeof value.value !== "undefined" || pair.alwaysSet) {
98
+ finalObject[key.value] = value.value;
99
+ }
100
+ }
101
+ return { status: status.value, value: finalObject };
102
+ }
103
+ }
104
+ exports.ParseStatus = ParseStatus;
105
+ exports.INVALID = Object.freeze({
106
+ status: "aborted",
107
+ });
108
+ const DIRTY = (value) => ({ status: "dirty", value });
109
+ exports.DIRTY = DIRTY;
110
+ const OK = (value) => ({ status: "valid", value });
111
+ exports.OK = OK;
112
+ const isAborted = (x) => x.status === "aborted";
113
+ exports.isAborted = isAborted;
114
+ const isDirty = (x) => x.status === "dirty";
115
+ exports.isDirty = isDirty;
116
+ const isValid = (x) => x.status === "valid";
117
+ exports.isValid = isValid;
118
+ const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
119
+ exports.isAsync = isAsync;
@@ -0,0 +1,8 @@
1
+ import type { ZodArray, ZodNullable, ZodObject, ZodOptional, ZodRawShape, ZodTuple, ZodTupleItems, ZodTypeAny } from "../index.js";
2
+ export declare namespace partialUtil {
3
+ type DeepPartial<T extends ZodTypeAny> = T extends ZodObject<ZodRawShape> ? ZodObject<{
4
+ [k in keyof T["shape"]]: ZodOptional<DeepPartial<T["shape"][k]>>;
5
+ }, T["_def"]["unknownKeys"], T["_def"]["catchall"]> : T extends ZodArray<infer Type, infer Card> ? ZodArray<DeepPartial<Type>, Card> : T extends ZodOptional<infer Type> ? ZodOptional<DeepPartial<Type>> : T extends ZodNullable<infer Type> ? ZodNullable<DeepPartial<Type>> : T extends ZodTuple<infer Items> ? {
6
+ [k in keyof Items]: Items[k] extends ZodTypeAny ? DeepPartial<Items[k]> : never;
7
+ } extends infer PI ? PI extends ZodTupleItems ? ZodTuple<PI> : never : never : T;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export type Primitive = string | number | symbol | bigint | boolean | null | undefined;
2
+ export type Scalars = Primitive | Primitive[];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,68 @@
1
+ export declare namespace util {
2
+ type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
3
+ export type isAny<T> = 0 extends 1 & T ? true : false;
4
+ export const assertEqual: <A, B>(val: AssertEqual<A, B>) => AssertEqual<A, B>;
5
+ export function assertIs<T>(_arg: T): void;
6
+ export function assertNever(_x: never): never;
7
+ export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
8
+ export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
9
+ export type MakePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
10
+ export const arrayToEnum: <T extends string, U extends [T, ...T[]]>(items: U) => { [k in U[number]]: k; };
11
+ export const getValidEnumValues: (obj: any) => any[];
12
+ export const objectValues: (obj: any) => any[];
13
+ export const objectKeys: ObjectConstructor["keys"];
14
+ export const find: <T>(arr: T[], checker: (arg: T) => any) => T | undefined;
15
+ export type identity<T> = objectUtil.identity<T>;
16
+ export type flatten<T> = objectUtil.flatten<T>;
17
+ export type noUndefined<T> = T extends undefined ? never : T;
18
+ export const isInteger: NumberConstructor["isInteger"];
19
+ export function joinValues<T extends any[]>(array: T, separator?: string): string;
20
+ export const jsonStringifyReplacer: (_: string, value: any) => any;
21
+ export {};
22
+ }
23
+ export declare namespace objectUtil {
24
+ export type MergeShapes<U, V> = {
25
+ [k in Exclude<keyof U, keyof V>]: U[k];
26
+ } & V;
27
+ type requiredKeys<T extends object> = {
28
+ [k in keyof T]: undefined extends T[k] ? never : k;
29
+ }[keyof T];
30
+ export type addQuestionMarks<T extends object, R extends keyof T = requiredKeys<T>> = Pick<Required<T>, R> & Partial<T>;
31
+ export type identity<T> = T;
32
+ export type flatten<T> = identity<{
33
+ [k in keyof T]: T[k];
34
+ }>;
35
+ export type noNeverKeys<T> = {
36
+ [k in keyof T]: [T[k]] extends [never] ? never : k;
37
+ }[keyof T];
38
+ export type noNever<T> = identity<{
39
+ [k in noNeverKeys<T>]: k extends keyof T ? T[k] : never;
40
+ }>;
41
+ export const mergeShapes: <U, T>(first: U, second: T) => T & U;
42
+ export type extendShape<A, B> = flatten<Omit<A, keyof B> & B>;
43
+ export {};
44
+ }
45
+ export declare const ZodParsedType: {
46
+ string: "string";
47
+ number: "number";
48
+ bigint: "bigint";
49
+ boolean: "boolean";
50
+ symbol: "symbol";
51
+ undefined: "undefined";
52
+ object: "object";
53
+ function: "function";
54
+ map: "map";
55
+ nan: "nan";
56
+ integer: "integer";
57
+ float: "float";
58
+ date: "date";
59
+ null: "null";
60
+ array: "array";
61
+ unknown: "unknown";
62
+ promise: "promise";
63
+ void: "void";
64
+ never: "never";
65
+ set: "set";
66
+ };
67
+ export type ZodParsedType = keyof typeof ZodParsedType;
68
+ export declare const getParsedType: (data: any) => ZodParsedType;
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getParsedType = exports.ZodParsedType = exports.objectUtil = exports.util = void 0;
4
+ var util;
5
+ (function (util) {
6
+ util.assertEqual = (val) => val;
7
+ function assertIs(_arg) { }
8
+ util.assertIs = assertIs;
9
+ function assertNever(_x) {
10
+ throw new Error();
11
+ }
12
+ util.assertNever = assertNever;
13
+ util.arrayToEnum = (items) => {
14
+ const obj = {};
15
+ for (const item of items) {
16
+ obj[item] = item;
17
+ }
18
+ return obj;
19
+ };
20
+ util.getValidEnumValues = (obj) => {
21
+ const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
22
+ const filtered = {};
23
+ for (const k of validKeys) {
24
+ filtered[k] = obj[k];
25
+ }
26
+ return util.objectValues(filtered);
27
+ };
28
+ util.objectValues = (obj) => {
29
+ return util.objectKeys(obj).map(function (e) {
30
+ return obj[e];
31
+ });
32
+ };
33
+ util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
34
+ ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
35
+ : (object) => {
36
+ const keys = [];
37
+ for (const key in object) {
38
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
39
+ keys.push(key);
40
+ }
41
+ }
42
+ return keys;
43
+ };
44
+ util.find = (arr, checker) => {
45
+ for (const item of arr) {
46
+ if (checker(item))
47
+ return item;
48
+ }
49
+ return undefined;
50
+ };
51
+ util.isInteger = typeof Number.isInteger === "function"
52
+ ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
53
+ : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
54
+ function joinValues(array, separator = " | ") {
55
+ return array
56
+ .map((val) => (typeof val === "string" ? `'${val}'` : val))
57
+ .join(separator);
58
+ }
59
+ util.joinValues = joinValues;
60
+ util.jsonStringifyReplacer = (_, value) => {
61
+ if (typeof value === "bigint") {
62
+ return value.toString();
63
+ }
64
+ return value;
65
+ };
66
+ })(util = exports.util || (exports.util = {}));
67
+ var objectUtil;
68
+ (function (objectUtil) {
69
+ objectUtil.mergeShapes = (first, second) => {
70
+ return {
71
+ ...first,
72
+ ...second, // second overwrites first
73
+ };
74
+ };
75
+ })(objectUtil = exports.objectUtil || (exports.objectUtil = {}));
76
+ exports.ZodParsedType = util.arrayToEnum([
77
+ "string",
78
+ "nan",
79
+ "number",
80
+ "integer",
81
+ "float",
82
+ "boolean",
83
+ "date",
84
+ "bigint",
85
+ "symbol",
86
+ "function",
87
+ "undefined",
88
+ "null",
89
+ "array",
90
+ "object",
91
+ "unknown",
92
+ "promise",
93
+ "void",
94
+ "never",
95
+ "map",
96
+ "set",
97
+ ]);
98
+ const getParsedType = (data) => {
99
+ const t = typeof data;
100
+ switch (t) {
101
+ case "undefined":
102
+ return exports.ZodParsedType.undefined;
103
+ case "string":
104
+ return exports.ZodParsedType.string;
105
+ case "number":
106
+ return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number;
107
+ case "boolean":
108
+ return exports.ZodParsedType.boolean;
109
+ case "function":
110
+ return exports.ZodParsedType.function;
111
+ case "bigint":
112
+ return exports.ZodParsedType.bigint;
113
+ case "symbol":
114
+ return exports.ZodParsedType.symbol;
115
+ case "object":
116
+ if (Array.isArray(data)) {
117
+ return exports.ZodParsedType.array;
118
+ }
119
+ if (data === null) {
120
+ return exports.ZodParsedType.null;
121
+ }
122
+ if (data.then &&
123
+ typeof data.then === "function" &&
124
+ data.catch &&
125
+ typeof data.catch === "function") {
126
+ return exports.ZodParsedType.promise;
127
+ }
128
+ if (typeof Map !== "undefined" && data instanceof Map) {
129
+ return exports.ZodParsedType.map;
130
+ }
131
+ if (typeof Set !== "undefined" && data instanceof Set) {
132
+ return exports.ZodParsedType.set;
133
+ }
134
+ if (typeof Date !== "undefined" && data instanceof Date) {
135
+ return exports.ZodParsedType.date;
136
+ }
137
+ return exports.ZodParsedType.object;
138
+ default:
139
+ return exports.ZodParsedType.unknown;
140
+ }
141
+ };
142
+ exports.getParsedType = getParsedType;
@@ -0,0 +1,4 @@
1
+ import * as z from "./external.js";
2
+ export * from "./external.js";
3
+ export { z };
4
+ export default z;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.z = void 0;
30
+ const z = __importStar(require("./external.js"));
31
+ exports.z = z;
32
+ __exportStar(require("./external.js"), exports);
33
+ exports.default = z;
@@ -0,0 +1,3 @@
1
+ import { ZodErrorMap } from "../ZodError.js";
2
+ declare const errorMap: ZodErrorMap;
3
+ export default errorMap;
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const util_js_1 = require("../helpers/util.js");
4
+ const ZodError_js_1 = require("../ZodError.js");
5
+ const errorMap = (issue, _ctx) => {
6
+ let message;
7
+ switch (issue.code) {
8
+ case ZodError_js_1.ZodIssueCode.invalid_type:
9
+ if (issue.received === util_js_1.ZodParsedType.undefined) {
10
+ message = "Required";
11
+ }
12
+ else {
13
+ message = `Expected ${issue.expected}, received ${issue.received}`;
14
+ }
15
+ break;
16
+ case ZodError_js_1.ZodIssueCode.invalid_literal:
17
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util_js_1.util.jsonStringifyReplacer)}`;
18
+ break;
19
+ case ZodError_js_1.ZodIssueCode.unrecognized_keys:
20
+ message = `Unrecognized key(s) in object: ${util_js_1.util.joinValues(issue.keys, ", ")}`;
21
+ break;
22
+ case ZodError_js_1.ZodIssueCode.invalid_union:
23
+ message = `Invalid input`;
24
+ break;
25
+ case ZodError_js_1.ZodIssueCode.invalid_union_discriminator:
26
+ message = `Invalid discriminator value. Expected ${util_js_1.util.joinValues(issue.options)}`;
27
+ break;
28
+ case ZodError_js_1.ZodIssueCode.invalid_enum_value:
29
+ message = `Invalid enum value. Expected ${util_js_1.util.joinValues(issue.options)}, received '${issue.received}'`;
30
+ break;
31
+ case ZodError_js_1.ZodIssueCode.invalid_arguments:
32
+ message = `Invalid function arguments`;
33
+ break;
34
+ case ZodError_js_1.ZodIssueCode.invalid_return_type:
35
+ message = `Invalid function return type`;
36
+ break;
37
+ case ZodError_js_1.ZodIssueCode.invalid_date:
38
+ message = `Invalid date`;
39
+ break;
40
+ case ZodError_js_1.ZodIssueCode.invalid_string:
41
+ if (typeof issue.validation === "object") {
42
+ if ("includes" in issue.validation) {
43
+ message = `Invalid input: must include "${issue.validation.includes}"`;
44
+ if (typeof issue.validation.position === "number") {
45
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
46
+ }
47
+ }
48
+ else if ("startsWith" in issue.validation) {
49
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
50
+ }
51
+ else if ("endsWith" in issue.validation) {
52
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
53
+ }
54
+ else {
55
+ util_js_1.util.assertNever(issue.validation);
56
+ }
57
+ }
58
+ else if (issue.validation !== "regex") {
59
+ message = `Invalid ${issue.validation}`;
60
+ }
61
+ else {
62
+ message = "Invalid";
63
+ }
64
+ break;
65
+ case ZodError_js_1.ZodIssueCode.too_small:
66
+ if (issue.type === "array")
67
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
68
+ else if (issue.type === "string")
69
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
70
+ else if (issue.type === "number")
71
+ message = `Number must be ${issue.exact
72
+ ? `exactly equal to `
73
+ : issue.inclusive
74
+ ? `greater than or equal to `
75
+ : `greater than `}${issue.minimum}`;
76
+ else if (issue.type === "date")
77
+ message = `Date must be ${issue.exact
78
+ ? `exactly equal to `
79
+ : issue.inclusive
80
+ ? `greater than or equal to `
81
+ : `greater than `}${new Date(Number(issue.minimum))}`;
82
+ else
83
+ message = "Invalid input";
84
+ break;
85
+ case ZodError_js_1.ZodIssueCode.too_big:
86
+ if (issue.type === "array")
87
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
88
+ else if (issue.type === "string")
89
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
90
+ else if (issue.type === "number")
91
+ message = `Number must be ${issue.exact
92
+ ? `exactly`
93
+ : issue.inclusive
94
+ ? `less than or equal to`
95
+ : `less than`} ${issue.maximum}`;
96
+ else if (issue.type === "bigint")
97
+ message = `BigInt must be ${issue.exact
98
+ ? `exactly`
99
+ : issue.inclusive
100
+ ? `less than or equal to`
101
+ : `less than`} ${issue.maximum}`;
102
+ else if (issue.type === "date")
103
+ message = `Date must be ${issue.exact
104
+ ? `exactly`
105
+ : issue.inclusive
106
+ ? `smaller than or equal to`
107
+ : `smaller than`} ${new Date(Number(issue.maximum))}`;
108
+ else
109
+ message = "Invalid input";
110
+ break;
111
+ case ZodError_js_1.ZodIssueCode.custom:
112
+ message = `Invalid input`;
113
+ break;
114
+ case ZodError_js_1.ZodIssueCode.invalid_intersection_types:
115
+ message = `Intersection results could not be merged`;
116
+ break;
117
+ case ZodError_js_1.ZodIssueCode.not_multiple_of:
118
+ message = `Number must be a multiple of ${issue.multipleOf}`;
119
+ break;
120
+ case ZodError_js_1.ZodIssueCode.not_finite:
121
+ message = "Number must be finite";
122
+ break;
123
+ default:
124
+ message = _ctx.defaultError;
125
+ util_js_1.util.assertNever(issue);
126
+ }
127
+ return { message };
128
+ };
129
+ exports.default = errorMap;
@@ -0,0 +1 @@
1
+ export * from "./index.js";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./index.js"), exports);