unocab 0.8.0 → 0.9.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 (108) hide show
  1. package/README.md +24 -4
  2. package/{script → dist}/errors.d.ts +13 -3
  3. package/dist/game.d.ts +459 -0
  4. package/dist/index.d.ts +3 -0
  5. package/dist/index.js +786 -0
  6. package/dist/types.d.ts +1106 -0
  7. package/{esm → dist}/utils.d.ts +4 -3
  8. package/package.json +17 -11
  9. package/esm/_dnt.shims.d.ts +0 -4
  10. package/esm/_dnt.shims.js +0 -62
  11. package/esm/_dnt.test_shims.d.ts +0 -7
  12. package/esm/deps/deno.land/std@0.190.0/fmt/colors.d.ts +0 -270
  13. package/esm/deps/deno.land/std@0.190.0/testing/_diff.d.ts +0 -26
  14. package/esm/deps/deno.land/std@0.190.0/testing/_format.d.ts +0 -1
  15. package/esm/deps/deno.land/std@0.190.0/testing/asserts.d.ts +0 -284
  16. package/esm/deps/deno.land/x/zod@v3.21.4/ZodError.d.ts +0 -163
  17. package/esm/deps/deno.land/x/zod@v3.21.4/ZodError.js +0 -148
  18. package/esm/deps/deno.land/x/zod@v3.21.4/errors.d.ts +0 -5
  19. package/esm/deps/deno.land/x/zod@v3.21.4/errors.js +0 -9
  20. package/esm/deps/deno.land/x/zod@v3.21.4/external.d.ts +0 -6
  21. package/esm/deps/deno.land/x/zod@v3.21.4/external.js +0 -6
  22. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.d.ts +0 -8
  23. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.js +0 -1
  24. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.d.ts +0 -9
  25. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.js +0 -5
  26. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.d.ts +0 -78
  27. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.js +0 -104
  28. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.d.ts +0 -8
  29. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.js +0 -1
  30. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.d.ts +0 -2
  31. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.js +0 -1
  32. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/util.d.ts +0 -68
  33. package/esm/deps/deno.land/x/zod@v3.21.4/helpers/util.js +0 -138
  34. package/esm/deps/deno.land/x/zod@v3.21.4/index.d.ts +0 -4
  35. package/esm/deps/deno.land/x/zod@v3.21.4/index.js +0 -4
  36. package/esm/deps/deno.land/x/zod@v3.21.4/locales/en.d.ts +0 -3
  37. package/esm/deps/deno.land/x/zod@v3.21.4/locales/en.js +0 -127
  38. package/esm/deps/deno.land/x/zod@v3.21.4/mod.d.ts +0 -1
  39. package/esm/deps/deno.land/x/zod@v3.21.4/mod.js +0 -1
  40. package/esm/deps/deno.land/x/zod@v3.21.4/types.d.ts +0 -965
  41. package/esm/deps/deno.land/x/zod@v3.21.4/types.js +0 -3689
  42. package/esm/errors.d.ts +0 -72
  43. package/esm/errors.js +0 -39
  44. package/esm/game.d.ts +0 -868
  45. package/esm/game.js +0 -868
  46. package/esm/mod.d.ts +0 -3
  47. package/esm/mod.js +0 -3
  48. package/esm/package.json +0 -3
  49. package/esm/tests/basic-tests.d.ts +0 -8
  50. package/esm/tests/draw-tests.d.ts +0 -8
  51. package/esm/tests/non-specific-tests.test.d.ts +0 -1
  52. package/esm/tests/rule-violation-tests.d.ts +0 -8
  53. package/esm/tests/specific-tests.test.d.ts +0 -1
  54. package/esm/tests/test-utils.d.ts +0 -91
  55. package/esm/tests/turn-tests.d.ts +0 -8
  56. package/esm/types.d.ts +0 -2280
  57. package/esm/types.js +0 -152
  58. package/esm/utils.js +0 -44
  59. package/script/_dnt.shims.d.ts +0 -4
  60. package/script/_dnt.shims.js +0 -66
  61. package/script/_dnt.test_shims.d.ts +0 -7
  62. package/script/deps/deno.land/std@0.190.0/fmt/colors.d.ts +0 -270
  63. package/script/deps/deno.land/std@0.190.0/testing/_diff.d.ts +0 -26
  64. package/script/deps/deno.land/std@0.190.0/testing/_format.d.ts +0 -1
  65. package/script/deps/deno.land/std@0.190.0/testing/asserts.d.ts +0 -284
  66. package/script/deps/deno.land/x/zod@v3.21.4/ZodError.d.ts +0 -163
  67. package/script/deps/deno.land/x/zod@v3.21.4/ZodError.js +0 -152
  68. package/script/deps/deno.land/x/zod@v3.21.4/errors.d.ts +0 -5
  69. package/script/deps/deno.land/x/zod@v3.21.4/errors.js +0 -17
  70. package/script/deps/deno.land/x/zod@v3.21.4/external.d.ts +0 -6
  71. package/script/deps/deno.land/x/zod@v3.21.4/external.js +0 -22
  72. package/script/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.d.ts +0 -8
  73. package/script/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.js +0 -2
  74. package/script/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.d.ts +0 -9
  75. package/script/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.js +0 -8
  76. package/script/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.d.ts +0 -78
  77. package/script/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.js +0 -119
  78. package/script/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.d.ts +0 -8
  79. package/script/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.js +0 -2
  80. package/script/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.d.ts +0 -2
  81. package/script/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.js +0 -2
  82. package/script/deps/deno.land/x/zod@v3.21.4/helpers/util.d.ts +0 -68
  83. package/script/deps/deno.land/x/zod@v3.21.4/helpers/util.js +0 -142
  84. package/script/deps/deno.land/x/zod@v3.21.4/index.d.ts +0 -4
  85. package/script/deps/deno.land/x/zod@v3.21.4/index.js +0 -33
  86. package/script/deps/deno.land/x/zod@v3.21.4/locales/en.d.ts +0 -3
  87. package/script/deps/deno.land/x/zod@v3.21.4/locales/en.js +0 -129
  88. package/script/deps/deno.land/x/zod@v3.21.4/mod.d.ts +0 -1
  89. package/script/deps/deno.land/x/zod@v3.21.4/mod.js +0 -17
  90. package/script/deps/deno.land/x/zod@v3.21.4/types.d.ts +0 -965
  91. package/script/deps/deno.land/x/zod@v3.21.4/types.js +0 -3739
  92. package/script/errors.js +0 -43
  93. package/script/game.d.ts +0 -868
  94. package/script/game.js +0 -895
  95. package/script/mod.d.ts +0 -3
  96. package/script/mod.js +0 -19
  97. package/script/package.json +0 -3
  98. package/script/tests/basic-tests.d.ts +0 -8
  99. package/script/tests/draw-tests.d.ts +0 -8
  100. package/script/tests/non-specific-tests.test.d.ts +0 -1
  101. package/script/tests/rule-violation-tests.d.ts +0 -8
  102. package/script/tests/specific-tests.test.d.ts +0 -1
  103. package/script/tests/test-utils.d.ts +0 -91
  104. package/script/tests/turn-tests.d.ts +0 -8
  105. package/script/types.d.ts +0 -2280
  106. package/script/types.js +0 -155
  107. package/script/utils.d.ts +0 -19
  108. package/script/utils.js +0 -50
@@ -1,78 +0,0 @@
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>;
@@ -1,104 +0,0 @@
1
- import { getErrorMap } from "../errors.js";
2
- import defaultErrorMap from "../locales/en.js";
3
- export const makeIssue = (params) => {
4
- const { data, path, errorMaps, issueData } = params;
5
- const fullPath = [...path, ...(issueData.path || [])];
6
- const fullIssue = {
7
- ...issueData,
8
- path: fullPath,
9
- };
10
- let errorMessage = "";
11
- const maps = errorMaps
12
- .filter((m) => !!m)
13
- .slice()
14
- .reverse();
15
- for (const map of maps) {
16
- errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
17
- }
18
- return {
19
- ...issueData,
20
- path: fullPath,
21
- message: issueData.message || errorMessage,
22
- };
23
- };
24
- export const EMPTY_PATH = [];
25
- export function addIssueToContext(ctx, issueData) {
26
- const issue = makeIssue({
27
- issueData: issueData,
28
- data: ctx.data,
29
- path: ctx.path,
30
- errorMaps: [
31
- ctx.common.contextualErrorMap,
32
- ctx.schemaErrorMap,
33
- getErrorMap(),
34
- defaultErrorMap, // then global default map
35
- ].filter((x) => !!x),
36
- });
37
- ctx.common.issues.push(issue);
38
- }
39
- export class ParseStatus {
40
- constructor() {
41
- Object.defineProperty(this, "value", {
42
- enumerable: true,
43
- configurable: true,
44
- writable: true,
45
- value: "valid"
46
- });
47
- }
48
- dirty() {
49
- if (this.value === "valid")
50
- this.value = "dirty";
51
- }
52
- abort() {
53
- if (this.value !== "aborted")
54
- this.value = "aborted";
55
- }
56
- static mergeArray(status, results) {
57
- const arrayValue = [];
58
- for (const s of results) {
59
- if (s.status === "aborted")
60
- return INVALID;
61
- if (s.status === "dirty")
62
- status.dirty();
63
- arrayValue.push(s.value);
64
- }
65
- return { status: status.value, value: arrayValue };
66
- }
67
- static async mergeObjectAsync(status, pairs) {
68
- const syncPairs = [];
69
- for (const pair of pairs) {
70
- syncPairs.push({
71
- key: await pair.key,
72
- value: await pair.value,
73
- });
74
- }
75
- return ParseStatus.mergeObjectSync(status, syncPairs);
76
- }
77
- static mergeObjectSync(status, pairs) {
78
- const finalObject = {};
79
- for (const pair of pairs) {
80
- const { key, value } = pair;
81
- if (key.status === "aborted")
82
- return INVALID;
83
- if (value.status === "aborted")
84
- return INVALID;
85
- if (key.status === "dirty")
86
- status.dirty();
87
- if (value.status === "dirty")
88
- status.dirty();
89
- if (typeof value.value !== "undefined" || pair.alwaysSet) {
90
- finalObject[key.value] = value.value;
91
- }
92
- }
93
- return { status: status.value, value: finalObject };
94
- }
95
- }
96
- export const INVALID = Object.freeze({
97
- status: "aborted",
98
- });
99
- export const DIRTY = (value) => ({ status: "dirty", value });
100
- export const OK = (value) => ({ status: "valid", value });
101
- export const isAborted = (x) => x.status === "aborted";
102
- export const isDirty = (x) => x.status === "dirty";
103
- export const isValid = (x) => x.status === "valid";
104
- export const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
@@ -1,8 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- export type Primitive = string | number | symbol | bigint | boolean | null | undefined;
2
- export type Scalars = Primitive | Primitive[];
@@ -1,68 +0,0 @@
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;
@@ -1,138 +0,0 @@
1
- export var util;
2
- (function (util) {
3
- util.assertEqual = (val) => val;
4
- function assertIs(_arg) { }
5
- util.assertIs = assertIs;
6
- function assertNever(_x) {
7
- throw new Error();
8
- }
9
- util.assertNever = assertNever;
10
- util.arrayToEnum = (items) => {
11
- const obj = {};
12
- for (const item of items) {
13
- obj[item] = item;
14
- }
15
- return obj;
16
- };
17
- util.getValidEnumValues = (obj) => {
18
- const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
19
- const filtered = {};
20
- for (const k of validKeys) {
21
- filtered[k] = obj[k];
22
- }
23
- return util.objectValues(filtered);
24
- };
25
- util.objectValues = (obj) => {
26
- return util.objectKeys(obj).map(function (e) {
27
- return obj[e];
28
- });
29
- };
30
- util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
31
- ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
32
- : (object) => {
33
- const keys = [];
34
- for (const key in object) {
35
- if (Object.prototype.hasOwnProperty.call(object, key)) {
36
- keys.push(key);
37
- }
38
- }
39
- return keys;
40
- };
41
- util.find = (arr, checker) => {
42
- for (const item of arr) {
43
- if (checker(item))
44
- return item;
45
- }
46
- return undefined;
47
- };
48
- util.isInteger = typeof Number.isInteger === "function"
49
- ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
50
- : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
51
- function joinValues(array, separator = " | ") {
52
- return array
53
- .map((val) => (typeof val === "string" ? `'${val}'` : val))
54
- .join(separator);
55
- }
56
- util.joinValues = joinValues;
57
- util.jsonStringifyReplacer = (_, value) => {
58
- if (typeof value === "bigint") {
59
- return value.toString();
60
- }
61
- return value;
62
- };
63
- })(util || (util = {}));
64
- export var objectUtil;
65
- (function (objectUtil) {
66
- objectUtil.mergeShapes = (first, second) => {
67
- return {
68
- ...first,
69
- ...second, // second overwrites first
70
- };
71
- };
72
- })(objectUtil || (objectUtil = {}));
73
- export const ZodParsedType = util.arrayToEnum([
74
- "string",
75
- "nan",
76
- "number",
77
- "integer",
78
- "float",
79
- "boolean",
80
- "date",
81
- "bigint",
82
- "symbol",
83
- "function",
84
- "undefined",
85
- "null",
86
- "array",
87
- "object",
88
- "unknown",
89
- "promise",
90
- "void",
91
- "never",
92
- "map",
93
- "set",
94
- ]);
95
- export const getParsedType = (data) => {
96
- const t = typeof data;
97
- switch (t) {
98
- case "undefined":
99
- return ZodParsedType.undefined;
100
- case "string":
101
- return ZodParsedType.string;
102
- case "number":
103
- return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
104
- case "boolean":
105
- return ZodParsedType.boolean;
106
- case "function":
107
- return ZodParsedType.function;
108
- case "bigint":
109
- return ZodParsedType.bigint;
110
- case "symbol":
111
- return ZodParsedType.symbol;
112
- case "object":
113
- if (Array.isArray(data)) {
114
- return ZodParsedType.array;
115
- }
116
- if (data === null) {
117
- return ZodParsedType.null;
118
- }
119
- if (data.then &&
120
- typeof data.then === "function" &&
121
- data.catch &&
122
- typeof data.catch === "function") {
123
- return ZodParsedType.promise;
124
- }
125
- if (typeof Map !== "undefined" && data instanceof Map) {
126
- return ZodParsedType.map;
127
- }
128
- if (typeof Set !== "undefined" && data instanceof Set) {
129
- return ZodParsedType.set;
130
- }
131
- if (typeof Date !== "undefined" && data instanceof Date) {
132
- return ZodParsedType.date;
133
- }
134
- return ZodParsedType.object;
135
- default:
136
- return ZodParsedType.unknown;
137
- }
138
- };
@@ -1,4 +0,0 @@
1
- import * as z from "./external.js";
2
- export * from "./external.js";
3
- export { z };
4
- export default z;
@@ -1,4 +0,0 @@
1
- import * as z from "./external.js";
2
- export * from "./external.js";
3
- export { z };
4
- export default z;
@@ -1,3 +0,0 @@
1
- import { ZodErrorMap } from "../ZodError.js";
2
- declare const errorMap: ZodErrorMap;
3
- export default errorMap;
@@ -1,127 +0,0 @@
1
- import { util, ZodParsedType } from "../helpers/util.js";
2
- import { ZodIssueCode } from "../ZodError.js";
3
- const errorMap = (issue, _ctx) => {
4
- let message;
5
- switch (issue.code) {
6
- case ZodIssueCode.invalid_type:
7
- if (issue.received === ZodParsedType.undefined) {
8
- message = "Required";
9
- }
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
- if (typeof issue.validation.position === "number") {
43
- message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
44
- }
45
- }
46
- else if ("startsWith" in issue.validation) {
47
- message = `Invalid input: must start with "${issue.validation.startsWith}"`;
48
- }
49
- else if ("endsWith" in issue.validation) {
50
- message = `Invalid input: must end with "${issue.validation.endsWith}"`;
51
- }
52
- else {
53
- util.assertNever(issue.validation);
54
- }
55
- }
56
- else if (issue.validation !== "regex") {
57
- message = `Invalid ${issue.validation}`;
58
- }
59
- else {
60
- message = "Invalid";
61
- }
62
- break;
63
- case ZodIssueCode.too_small:
64
- if (issue.type === "array")
65
- message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
66
- else if (issue.type === "string")
67
- message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
68
- else if (issue.type === "number")
69
- message = `Number must be ${issue.exact
70
- ? `exactly equal to `
71
- : issue.inclusive
72
- ? `greater than or equal to `
73
- : `greater than `}${issue.minimum}`;
74
- else if (issue.type === "date")
75
- message = `Date must be ${issue.exact
76
- ? `exactly equal to `
77
- : issue.inclusive
78
- ? `greater than or equal to `
79
- : `greater than `}${new Date(Number(issue.minimum))}`;
80
- else
81
- message = "Invalid input";
82
- break;
83
- case ZodIssueCode.too_big:
84
- if (issue.type === "array")
85
- message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
86
- else if (issue.type === "string")
87
- message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
88
- else if (issue.type === "number")
89
- message = `Number must be ${issue.exact
90
- ? `exactly`
91
- : issue.inclusive
92
- ? `less than or equal to`
93
- : `less than`} ${issue.maximum}`;
94
- else if (issue.type === "bigint")
95
- message = `BigInt must be ${issue.exact
96
- ? `exactly`
97
- : issue.inclusive
98
- ? `less than or equal to`
99
- : `less than`} ${issue.maximum}`;
100
- else if (issue.type === "date")
101
- message = `Date must be ${issue.exact
102
- ? `exactly`
103
- : issue.inclusive
104
- ? `smaller than or equal to`
105
- : `smaller than`} ${new Date(Number(issue.maximum))}`;
106
- else
107
- message = "Invalid input";
108
- break;
109
- case ZodIssueCode.custom:
110
- message = `Invalid input`;
111
- break;
112
- case ZodIssueCode.invalid_intersection_types:
113
- message = `Intersection results could not be merged`;
114
- break;
115
- case ZodIssueCode.not_multiple_of:
116
- message = `Number must be a multiple of ${issue.multipleOf}`;
117
- break;
118
- case ZodIssueCode.not_finite:
119
- message = "Number must be finite";
120
- break;
121
- default:
122
- message = _ctx.defaultError;
123
- util.assertNever(issue);
124
- }
125
- return { message };
126
- };
127
- export default errorMap;
@@ -1 +0,0 @@
1
- export * from "./index.js";
@@ -1 +0,0 @@
1
- export * from "./index.js";