@rpgjs/client 5.0.0-beta.16 → 5.0.0-beta.18
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.
- package/CHANGELOG.md +10 -0
- package/dist/Game/Map.js +3 -3
- package/dist/Gui/Gui.js +1 -1
- package/dist/RpgClientEngine.js +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.130.0/helpers → _@oxc-project_runtime@0.133.0/helpers/esm}/decorate.js +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.130.0/helpers → _@oxc-project_runtime@0.133.0/helpers/esm}/decorateMetadata.js +1 -1
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/components/animations/animation.ce.js +4 -2
- package/dist/components/animations/animation.ce.js.map +1 -1
- package/dist/components/animations/fx.ce.js +4 -2
- package/dist/components/animations/fx.ce.js.map +1 -1
- package/dist/components/animations/hit.ce.js +6 -4
- package/dist/components/animations/hit.ce.js.map +1 -1
- package/dist/components/character.ce.js +6 -3
- package/dist/components/character.ce.js.map +1 -1
- package/dist/components/dynamics/bar.ce.js +4 -2
- package/dist/components/dynamics/bar.ce.js.map +1 -1
- package/dist/components/dynamics/image.ce.js +4 -2
- package/dist/components/dynamics/image.ce.js.map +1 -1
- package/dist/components/dynamics/shape.ce.js +4 -2
- package/dist/components/dynamics/shape.ce.js.map +1 -1
- package/dist/components/dynamics/text.ce.js +4 -2
- package/dist/components/dynamics/text.ce.js.map +1 -1
- package/dist/components/gui/box.ce.js +4 -2
- package/dist/components/gui/box.ce.js.map +1 -1
- package/dist/components/gui/dialogbox/index.ce.js +2 -1
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
- package/dist/components/gui/gameover.ce.js +2 -1
- package/dist/components/gui/gameover.ce.js.map +1 -1
- package/dist/components/gui/hud/hud.ce.js +2 -1
- package/dist/components/gui/hud/hud.ce.js.map +1 -1
- package/dist/components/gui/menu/equip-menu.ce.js +2 -1
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/exit-menu.ce.js +2 -1
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/items-menu.ce.js +2 -1
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/main-menu.ce.js +2 -1
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/options-menu.ce.js +2 -1
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/skills-menu.ce.js +2 -1
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
- package/dist/components/gui/mobile/mobile.ce.js +2 -1
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
- package/dist/components/gui/notification/notification.ce.js +2 -1
- package/dist/components/gui/notification/notification.ce.js.map +1 -1
- package/dist/components/gui/save-load.ce.js +2 -1
- package/dist/components/gui/save-load.ce.js.map +1 -1
- package/dist/components/gui/shop/shop.ce.js +2 -1
- package/dist/components/gui/shop/shop.ce.js.map +1 -1
- package/dist/components/gui/title-screen.ce.js +2 -1
- package/dist/components/gui/title-screen.ce.js.map +1 -1
- package/dist/components/interaction-components.ce.js +4 -2
- package/dist/components/interaction-components.ce.js.map +1 -1
- package/dist/components/player-components.ce.js +4 -2
- package/dist/components/player-components.ce.js.map +1 -1
- package/dist/components/prebuilt/hp-bar.ce.js +5 -3
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
- package/dist/components/prebuilt/light-halo.ce.js +4 -2
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
- package/dist/components/scenes/canvas.ce.js +2 -1
- package/dist/components/scenes/canvas.ce.js.map +1 -1
- package/dist/components/scenes/draw-map.ce.js +4 -2
- package/dist/components/scenes/draw-map.ce.js.map +1 -1
- package/dist/components/scenes/event-layer.ce.js +2 -1
- package/dist/components/scenes/event-layer.ce.js.map +1 -1
- package/dist/core/inject.js +1 -1
- package/dist/core/setup.js +1 -1
- package/dist/index.js +1 -1
- package/dist/module.js +1 -1
- package/dist/node_modules/.pnpm/{@signe_di@3.0.1 → @signe_di@3.1.0}/node_modules/@signe/di/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@signe_di@3.0.1 → @signe_di@3.1.0}/node_modules/@signe/di/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/{@signe_reactive@3.0.1 → @signe_reactive@3.1.0}/node_modules/@signe/reactive/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@signe_reactive@3.0.1 → @signe_reactive@3.1.0}/node_modules/@signe/reactive/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/{@signe_room@3.0.1 → @signe_room@3.1.0_react@19.2.7}/node_modules/@signe/room/dist/chunk-EUXUH3YW.js +1 -1
- package/dist/node_modules/.pnpm/@signe_room@3.1.0_react@19.2.7/node_modules/@signe/room/dist/chunk-EUXUH3YW.js.map +1 -0
- package/dist/node_modules/.pnpm/{@signe_room@3.0.1 → @signe_room@3.1.0_react@19.2.7}/node_modules/@signe/room/dist/index.js +33 -31
- package/dist/node_modules/.pnpm/@signe_room@3.1.0_react@19.2.7/node_modules/@signe/room/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/{@signe_sync@3.0.1 → @signe_sync@3.1.0_react@19.2.7}/node_modules/@signe/sync/dist/client/index.js +2 -3
- package/dist/node_modules/.pnpm/@signe_sync@3.1.0_react@19.2.7/node_modules/@signe/sync/dist/client/index.js.map +1 -0
- package/dist/node_modules/.pnpm/{@signe_sync@3.0.1 → @signe_sync@3.1.0_react@19.2.7}/node_modules/@signe/sync/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@signe_sync@3.1.0_react@19.2.7/node_modules/@signe/sync/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/{partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js → partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/index.js} +30 -17
- package/dist/node_modules/.pnpm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/{partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js → partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/ws.js} +65 -34
- package/dist/node_modules/.pnpm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/ws.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/index.js +13 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/index.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js +106 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js +13 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js +121 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js +10 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js +110 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js +99 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js +82 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js.map +1 -0
- package/dist/node_modules/.pnpm/{zod@3.24.2/node_modules/zod/lib/index.js → zod@3.25.76/node_modules/zod/v3/types.js} +93 -630
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js.map +1 -0
- package/dist/services/loadMap.js +1 -1
- package/dist/services/mmorpg.js +1 -1
- package/dist/services/standalone.js +1 -1
- package/package.json +13 -13
- package/src/components/character.ce +2 -1
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +0 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +0 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +0 -2
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +0 -1
|
@@ -1,412 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
throw new Error();
|
|
9
|
-
}
|
|
10
|
-
util.assertNever = assertNever;
|
|
11
|
-
util.arrayToEnum = (items) => {
|
|
12
|
-
const obj = {};
|
|
13
|
-
for (const item of items) obj[item] = item;
|
|
14
|
-
return obj;
|
|
15
|
-
};
|
|
16
|
-
util.getValidEnumValues = (obj) => {
|
|
17
|
-
const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
18
|
-
const filtered = {};
|
|
19
|
-
for (const k of validKeys) filtered[k] = obj[k];
|
|
20
|
-
return util.objectValues(filtered);
|
|
21
|
-
};
|
|
22
|
-
util.objectValues = (obj) => {
|
|
23
|
-
return util.objectKeys(obj).map(function(e) {
|
|
24
|
-
return obj[e];
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
util.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
28
|
-
const keys = [];
|
|
29
|
-
for (const key in object) if (Object.prototype.hasOwnProperty.call(object, key)) keys.push(key);
|
|
30
|
-
return keys;
|
|
31
|
-
};
|
|
32
|
-
util.find = (arr, checker) => {
|
|
33
|
-
for (const item of arr) if (checker(item)) return item;
|
|
34
|
-
};
|
|
35
|
-
util.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
|
|
36
|
-
function joinValues(array, separator = " | ") {
|
|
37
|
-
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
38
|
-
}
|
|
39
|
-
util.joinValues = joinValues;
|
|
40
|
-
util.jsonStringifyReplacer = (_, value) => {
|
|
41
|
-
if (typeof value === "bigint") return value.toString();
|
|
42
|
-
return value;
|
|
43
|
-
};
|
|
44
|
-
})(util || (util = {}));
|
|
45
|
-
var objectUtil;
|
|
46
|
-
(function(objectUtil) {
|
|
47
|
-
objectUtil.mergeShapes = (first, second) => {
|
|
48
|
-
return {
|
|
49
|
-
...first,
|
|
50
|
-
...second
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
})(objectUtil || (objectUtil = {}));
|
|
54
|
-
var ZodParsedType = util.arrayToEnum([
|
|
55
|
-
"string",
|
|
56
|
-
"nan",
|
|
57
|
-
"number",
|
|
58
|
-
"integer",
|
|
59
|
-
"float",
|
|
60
|
-
"boolean",
|
|
61
|
-
"date",
|
|
62
|
-
"bigint",
|
|
63
|
-
"symbol",
|
|
64
|
-
"function",
|
|
65
|
-
"undefined",
|
|
66
|
-
"null",
|
|
67
|
-
"array",
|
|
68
|
-
"object",
|
|
69
|
-
"unknown",
|
|
70
|
-
"promise",
|
|
71
|
-
"void",
|
|
72
|
-
"never",
|
|
73
|
-
"map",
|
|
74
|
-
"set"
|
|
75
|
-
]);
|
|
76
|
-
var getParsedType = (data) => {
|
|
77
|
-
switch (typeof data) {
|
|
78
|
-
case "undefined": return ZodParsedType.undefined;
|
|
79
|
-
case "string": return ZodParsedType.string;
|
|
80
|
-
case "number": return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
81
|
-
case "boolean": return ZodParsedType.boolean;
|
|
82
|
-
case "function": return ZodParsedType.function;
|
|
83
|
-
case "bigint": return ZodParsedType.bigint;
|
|
84
|
-
case "symbol": return ZodParsedType.symbol;
|
|
85
|
-
case "object":
|
|
86
|
-
if (Array.isArray(data)) return ZodParsedType.array;
|
|
87
|
-
if (data === null) return ZodParsedType.null;
|
|
88
|
-
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") return ZodParsedType.promise;
|
|
89
|
-
if (typeof Map !== "undefined" && data instanceof Map) return ZodParsedType.map;
|
|
90
|
-
if (typeof Set !== "undefined" && data instanceof Set) return ZodParsedType.set;
|
|
91
|
-
if (typeof Date !== "undefined" && data instanceof Date) return ZodParsedType.date;
|
|
92
|
-
return ZodParsedType.object;
|
|
93
|
-
default: return ZodParsedType.unknown;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
var ZodIssueCode = util.arrayToEnum([
|
|
97
|
-
"invalid_type",
|
|
98
|
-
"invalid_literal",
|
|
99
|
-
"custom",
|
|
100
|
-
"invalid_union",
|
|
101
|
-
"invalid_union_discriminator",
|
|
102
|
-
"invalid_enum_value",
|
|
103
|
-
"unrecognized_keys",
|
|
104
|
-
"invalid_arguments",
|
|
105
|
-
"invalid_return_type",
|
|
106
|
-
"invalid_date",
|
|
107
|
-
"invalid_string",
|
|
108
|
-
"too_small",
|
|
109
|
-
"too_big",
|
|
110
|
-
"invalid_intersection_types",
|
|
111
|
-
"not_multiple_of",
|
|
112
|
-
"not_finite"
|
|
113
|
-
]);
|
|
114
|
-
var quotelessJson = (obj) => {
|
|
115
|
-
return JSON.stringify(obj, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
116
|
-
};
|
|
117
|
-
var ZodError = class ZodError extends Error {
|
|
118
|
-
get errors() {
|
|
119
|
-
return this.issues;
|
|
120
|
-
}
|
|
121
|
-
constructor(issues) {
|
|
122
|
-
super();
|
|
123
|
-
this.issues = [];
|
|
124
|
-
this.addIssue = (sub) => {
|
|
125
|
-
this.issues = [...this.issues, sub];
|
|
126
|
-
};
|
|
127
|
-
this.addIssues = (subs = []) => {
|
|
128
|
-
this.issues = [...this.issues, ...subs];
|
|
129
|
-
};
|
|
130
|
-
const actualProto = new.target.prototype;
|
|
131
|
-
if (Object.setPrototypeOf) Object.setPrototypeOf(this, actualProto);
|
|
132
|
-
else this.__proto__ = actualProto;
|
|
133
|
-
this.name = "ZodError";
|
|
134
|
-
this.issues = issues;
|
|
135
|
-
}
|
|
136
|
-
format(_mapper) {
|
|
137
|
-
const mapper = _mapper || function(issue) {
|
|
138
|
-
return issue.message;
|
|
139
|
-
};
|
|
140
|
-
const fieldErrors = { _errors: [] };
|
|
141
|
-
const processError = (error) => {
|
|
142
|
-
for (const issue of error.issues) if (issue.code === "invalid_union") issue.unionErrors.map(processError);
|
|
143
|
-
else if (issue.code === "invalid_return_type") processError(issue.returnTypeError);
|
|
144
|
-
else if (issue.code === "invalid_arguments") processError(issue.argumentsError);
|
|
145
|
-
else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
|
|
146
|
-
else {
|
|
147
|
-
let curr = fieldErrors;
|
|
148
|
-
let i = 0;
|
|
149
|
-
while (i < issue.path.length) {
|
|
150
|
-
const el = issue.path[i];
|
|
151
|
-
if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
|
|
152
|
-
else {
|
|
153
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
154
|
-
curr[el]._errors.push(mapper(issue));
|
|
155
|
-
}
|
|
156
|
-
curr = curr[el];
|
|
157
|
-
i++;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
processError(this);
|
|
162
|
-
return fieldErrors;
|
|
163
|
-
}
|
|
164
|
-
static assert(value) {
|
|
165
|
-
if (!(value instanceof ZodError)) throw new Error(`Not a ZodError: ${value}`);
|
|
166
|
-
}
|
|
167
|
-
toString() {
|
|
168
|
-
return this.message;
|
|
169
|
-
}
|
|
170
|
-
get message() {
|
|
171
|
-
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
|
|
172
|
-
}
|
|
173
|
-
get isEmpty() {
|
|
174
|
-
return this.issues.length === 0;
|
|
175
|
-
}
|
|
176
|
-
flatten(mapper = (issue) => issue.message) {
|
|
177
|
-
const fieldErrors = {};
|
|
178
|
-
const formErrors = [];
|
|
179
|
-
for (const sub of this.issues) if (sub.path.length > 0) {
|
|
180
|
-
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
181
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
182
|
-
} else formErrors.push(mapper(sub));
|
|
183
|
-
return {
|
|
184
|
-
formErrors,
|
|
185
|
-
fieldErrors
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
get formErrors() {
|
|
189
|
-
return this.flatten();
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
ZodError.create = (issues) => {
|
|
193
|
-
return new ZodError(issues);
|
|
194
|
-
};
|
|
195
|
-
var errorMap = (issue, _ctx) => {
|
|
196
|
-
let message;
|
|
197
|
-
switch (issue.code) {
|
|
198
|
-
case ZodIssueCode.invalid_type:
|
|
199
|
-
if (issue.received === ZodParsedType.undefined) message = "Required";
|
|
200
|
-
else message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
201
|
-
break;
|
|
202
|
-
case ZodIssueCode.invalid_literal:
|
|
203
|
-
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
|
|
204
|
-
break;
|
|
205
|
-
case ZodIssueCode.unrecognized_keys:
|
|
206
|
-
message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
|
|
207
|
-
break;
|
|
208
|
-
case ZodIssueCode.invalid_union:
|
|
209
|
-
message = `Invalid input`;
|
|
210
|
-
break;
|
|
211
|
-
case ZodIssueCode.invalid_union_discriminator:
|
|
212
|
-
message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
|
|
213
|
-
break;
|
|
214
|
-
case ZodIssueCode.invalid_enum_value:
|
|
215
|
-
message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
|
|
216
|
-
break;
|
|
217
|
-
case ZodIssueCode.invalid_arguments:
|
|
218
|
-
message = `Invalid function arguments`;
|
|
219
|
-
break;
|
|
220
|
-
case ZodIssueCode.invalid_return_type:
|
|
221
|
-
message = `Invalid function return type`;
|
|
222
|
-
break;
|
|
223
|
-
case ZodIssueCode.invalid_date:
|
|
224
|
-
message = `Invalid date`;
|
|
225
|
-
break;
|
|
226
|
-
case ZodIssueCode.invalid_string:
|
|
227
|
-
if (typeof issue.validation === "object") if ("includes" in issue.validation) {
|
|
228
|
-
message = `Invalid input: must include "${issue.validation.includes}"`;
|
|
229
|
-
if (typeof issue.validation.position === "number") message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
230
|
-
} else if ("startsWith" in issue.validation) message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
231
|
-
else if ("endsWith" in issue.validation) message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
232
|
-
else util.assertNever(issue.validation);
|
|
233
|
-
else if (issue.validation !== "regex") message = `Invalid ${issue.validation}`;
|
|
234
|
-
else message = "Invalid";
|
|
235
|
-
break;
|
|
236
|
-
case ZodIssueCode.too_small:
|
|
237
|
-
if (issue.type === "array") message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
|
|
238
|
-
else if (issue.type === "string") message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
239
|
-
else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
240
|
-
else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
241
|
-
else message = "Invalid input";
|
|
242
|
-
break;
|
|
243
|
-
case ZodIssueCode.too_big:
|
|
244
|
-
if (issue.type === "array") message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
|
|
245
|
-
else if (issue.type === "string") message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
246
|
-
else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
247
|
-
else if (issue.type === "bigint") message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
248
|
-
else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
249
|
-
else message = "Invalid input";
|
|
250
|
-
break;
|
|
251
|
-
case ZodIssueCode.custom:
|
|
252
|
-
message = `Invalid input`;
|
|
253
|
-
break;
|
|
254
|
-
case ZodIssueCode.invalid_intersection_types:
|
|
255
|
-
message = `Intersection results could not be merged`;
|
|
256
|
-
break;
|
|
257
|
-
case ZodIssueCode.not_multiple_of:
|
|
258
|
-
message = `Number must be a multiple of ${issue.multipleOf}`;
|
|
259
|
-
break;
|
|
260
|
-
case ZodIssueCode.not_finite:
|
|
261
|
-
message = "Number must be finite";
|
|
262
|
-
break;
|
|
263
|
-
default:
|
|
264
|
-
message = _ctx.defaultError;
|
|
265
|
-
util.assertNever(issue);
|
|
266
|
-
}
|
|
267
|
-
return { message };
|
|
268
|
-
};
|
|
269
|
-
var overrideErrorMap = errorMap;
|
|
270
|
-
function setErrorMap(map) {
|
|
271
|
-
overrideErrorMap = map;
|
|
272
|
-
}
|
|
273
|
-
function getErrorMap() {
|
|
274
|
-
return overrideErrorMap;
|
|
275
|
-
}
|
|
276
|
-
var makeIssue = (params) => {
|
|
277
|
-
const { data, path, errorMaps, issueData } = params;
|
|
278
|
-
const fullPath = [...path, ...issueData.path || []];
|
|
279
|
-
const fullIssue = {
|
|
280
|
-
...issueData,
|
|
281
|
-
path: fullPath
|
|
282
|
-
};
|
|
283
|
-
if (issueData.message !== void 0) return {
|
|
284
|
-
...issueData,
|
|
285
|
-
path: fullPath,
|
|
286
|
-
message: issueData.message
|
|
287
|
-
};
|
|
288
|
-
let errorMessage = "";
|
|
289
|
-
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
290
|
-
for (const map of maps) errorMessage = map(fullIssue, {
|
|
291
|
-
data,
|
|
292
|
-
defaultError: errorMessage
|
|
293
|
-
}).message;
|
|
294
|
-
return {
|
|
295
|
-
...issueData,
|
|
296
|
-
path: fullPath,
|
|
297
|
-
message: errorMessage
|
|
298
|
-
};
|
|
299
|
-
};
|
|
300
|
-
var EMPTY_PATH = [];
|
|
301
|
-
function addIssueToContext(ctx, issueData) {
|
|
302
|
-
const overrideMap = getErrorMap();
|
|
303
|
-
const issue = makeIssue({
|
|
304
|
-
issueData,
|
|
305
|
-
data: ctx.data,
|
|
306
|
-
path: ctx.path,
|
|
307
|
-
errorMaps: [
|
|
308
|
-
ctx.common.contextualErrorMap,
|
|
309
|
-
ctx.schemaErrorMap,
|
|
310
|
-
overrideMap,
|
|
311
|
-
overrideMap === errorMap ? void 0 : errorMap
|
|
312
|
-
].filter((x) => !!x)
|
|
313
|
-
});
|
|
314
|
-
ctx.common.issues.push(issue);
|
|
315
|
-
}
|
|
316
|
-
var ParseStatus = class ParseStatus {
|
|
317
|
-
constructor() {
|
|
318
|
-
this.value = "valid";
|
|
319
|
-
}
|
|
320
|
-
dirty() {
|
|
321
|
-
if (this.value === "valid") this.value = "dirty";
|
|
322
|
-
}
|
|
323
|
-
abort() {
|
|
324
|
-
if (this.value !== "aborted") this.value = "aborted";
|
|
325
|
-
}
|
|
326
|
-
static mergeArray(status, results) {
|
|
327
|
-
const arrayValue = [];
|
|
328
|
-
for (const s of results) {
|
|
329
|
-
if (s.status === "aborted") return INVALID;
|
|
330
|
-
if (s.status === "dirty") status.dirty();
|
|
331
|
-
arrayValue.push(s.value);
|
|
332
|
-
}
|
|
333
|
-
return {
|
|
334
|
-
status: status.value,
|
|
335
|
-
value: arrayValue
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
static async mergeObjectAsync(status, pairs) {
|
|
339
|
-
const syncPairs = [];
|
|
340
|
-
for (const pair of pairs) {
|
|
341
|
-
const key = await pair.key;
|
|
342
|
-
const value = await pair.value;
|
|
343
|
-
syncPairs.push({
|
|
344
|
-
key,
|
|
345
|
-
value
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
349
|
-
}
|
|
350
|
-
static mergeObjectSync(status, pairs) {
|
|
351
|
-
const finalObject = {};
|
|
352
|
-
for (const pair of pairs) {
|
|
353
|
-
const { key, value } = pair;
|
|
354
|
-
if (key.status === "aborted") return INVALID;
|
|
355
|
-
if (value.status === "aborted") return INVALID;
|
|
356
|
-
if (key.status === "dirty") status.dirty();
|
|
357
|
-
if (value.status === "dirty") status.dirty();
|
|
358
|
-
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) finalObject[key.value] = value.value;
|
|
359
|
-
}
|
|
360
|
-
return {
|
|
361
|
-
status: status.value,
|
|
362
|
-
value: finalObject
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
var INVALID = Object.freeze({ status: "aborted" });
|
|
367
|
-
var DIRTY = (value) => ({
|
|
368
|
-
status: "dirty",
|
|
369
|
-
value
|
|
370
|
-
});
|
|
371
|
-
var OK = (value) => ({
|
|
372
|
-
status: "valid",
|
|
373
|
-
value
|
|
374
|
-
});
|
|
375
|
-
var isAborted = (x) => x.status === "aborted";
|
|
376
|
-
var isDirty = (x) => x.status === "dirty";
|
|
377
|
-
var isValid = (x) => x.status === "valid";
|
|
378
|
-
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
379
|
-
/******************************************************************************
|
|
380
|
-
Copyright (c) Microsoft Corporation.
|
|
381
|
-
|
|
382
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
383
|
-
purpose with or without fee is hereby granted.
|
|
384
|
-
|
|
385
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
386
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
387
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
388
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
389
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
390
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
391
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
392
|
-
***************************************************************************** */
|
|
393
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
394
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
395
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
396
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
397
|
-
}
|
|
398
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
399
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
400
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
401
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
402
|
-
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
403
|
-
}
|
|
404
|
-
var errorUtil;
|
|
405
|
-
(function(errorUtil) {
|
|
406
|
-
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
407
|
-
errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
408
|
-
})(errorUtil || (errorUtil = {}));
|
|
409
|
-
var _ZodEnum_cache, _ZodNativeEnum_cache;
|
|
1
|
+
import { ZodParsedType, getParsedType, util } from "./helpers/util.js";
|
|
2
|
+
import { ZodError, ZodIssueCode } from "./ZodError.js";
|
|
3
|
+
import errorMap from "./locales/en.js";
|
|
4
|
+
import { getErrorMap } from "./errors.js";
|
|
5
|
+
import { DIRTY, INVALID, OK, ParseStatus, addIssueToContext, isAborted, isAsync, isDirty, isValid, makeIssue } from "./helpers/parseUtil.js";
|
|
6
|
+
import { errorUtil } from "./helpers/errorUtil.js";
|
|
7
|
+
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
410
8
|
var ParseInputLazyPath = class {
|
|
411
9
|
constructor(parent, value, path, key) {
|
|
412
10
|
this._cachedPath = [];
|
|
@@ -416,7 +14,7 @@ var ParseInputLazyPath = class {
|
|
|
416
14
|
this._key = key;
|
|
417
15
|
}
|
|
418
16
|
get path() {
|
|
419
|
-
if (!this._cachedPath.length) if (this._key
|
|
17
|
+
if (!this._cachedPath.length) if (Array.isArray(this._key)) this._cachedPath.push(...this._path, ...this._key);
|
|
420
18
|
else this._cachedPath.push(...this._path, this._key);
|
|
421
19
|
return this._cachedPath;
|
|
422
20
|
}
|
|
@@ -448,12 +46,11 @@ function processCreateParams(params) {
|
|
|
448
46
|
description
|
|
449
47
|
};
|
|
450
48
|
const customMap = (iss, ctx) => {
|
|
451
|
-
var _a, _b;
|
|
452
49
|
const { message } = params;
|
|
453
|
-
if (iss.code === "invalid_enum_value") return { message: message
|
|
454
|
-
if (typeof ctx.data === "undefined") return { message:
|
|
50
|
+
if (iss.code === "invalid_enum_value") return { message: message ?? ctx.defaultError };
|
|
51
|
+
if (typeof ctx.data === "undefined") return { message: message ?? required_error ?? ctx.defaultError };
|
|
455
52
|
if (iss.code !== "invalid_type") return { message: ctx.defaultError };
|
|
456
|
-
return { message:
|
|
53
|
+
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
|
457
54
|
};
|
|
458
55
|
return {
|
|
459
56
|
errorMap: customMap,
|
|
@@ -505,14 +102,13 @@ var ZodType = class {
|
|
|
505
102
|
throw result.error;
|
|
506
103
|
}
|
|
507
104
|
safeParse(data, params) {
|
|
508
|
-
var _a;
|
|
509
105
|
const ctx = {
|
|
510
106
|
common: {
|
|
511
107
|
issues: [],
|
|
512
|
-
async:
|
|
513
|
-
contextualErrorMap: params
|
|
108
|
+
async: params?.async ?? false,
|
|
109
|
+
contextualErrorMap: params?.errorMap
|
|
514
110
|
},
|
|
515
|
-
path:
|
|
111
|
+
path: params?.path || [],
|
|
516
112
|
schemaErrorMap: this._def.errorMap,
|
|
517
113
|
parent: null,
|
|
518
114
|
data,
|
|
@@ -525,7 +121,6 @@ var ZodType = class {
|
|
|
525
121
|
}));
|
|
526
122
|
}
|
|
527
123
|
"~validate"(data) {
|
|
528
|
-
var _a, _b;
|
|
529
124
|
const ctx = {
|
|
530
125
|
common: {
|
|
531
126
|
issues: [],
|
|
@@ -545,7 +140,7 @@ var ZodType = class {
|
|
|
545
140
|
});
|
|
546
141
|
return isValid(result) ? { value: result.value } : { issues: ctx.common.issues };
|
|
547
142
|
} catch (err) {
|
|
548
|
-
if (
|
|
143
|
+
if (err?.message?.toLowerCase()?.includes("encountered")) this["~standard"].async = true;
|
|
549
144
|
ctx.common = {
|
|
550
145
|
issues: [],
|
|
551
146
|
async: true
|
|
@@ -566,10 +161,10 @@ var ZodType = class {
|
|
|
566
161
|
const ctx = {
|
|
567
162
|
common: {
|
|
568
163
|
issues: [],
|
|
569
|
-
contextualErrorMap: params
|
|
164
|
+
contextualErrorMap: params?.errorMap,
|
|
570
165
|
async: true
|
|
571
166
|
},
|
|
572
|
-
path:
|
|
167
|
+
path: params?.path || [],
|
|
573
168
|
schemaErrorMap: this._def.errorMap,
|
|
574
169
|
parent: null,
|
|
575
170
|
data,
|
|
@@ -757,10 +352,11 @@ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_
|
|
|
757
352
|
var dateRegexSource = `((\\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])))`;
|
|
758
353
|
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
759
354
|
function timeRegexSource(args) {
|
|
760
|
-
let
|
|
761
|
-
if (args.precision)
|
|
762
|
-
else if (args.precision == null)
|
|
763
|
-
|
|
355
|
+
let secondsRegexSource = `[0-5]\\d`;
|
|
356
|
+
if (args.precision) secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
|
|
357
|
+
else if (args.precision == null) secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
|
|
358
|
+
const secondsQuantifier = args.precision ? "+" : "?";
|
|
359
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
|
764
360
|
}
|
|
765
361
|
function timeRegex(args) {
|
|
766
362
|
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
@@ -782,13 +378,15 @@ function isValidJWT(jwt, alg) {
|
|
|
782
378
|
if (!jwtRegex.test(jwt)) return false;
|
|
783
379
|
try {
|
|
784
380
|
const [header] = jwt.split(".");
|
|
381
|
+
if (!header) return false;
|
|
785
382
|
const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
|
786
383
|
const decoded = JSON.parse(atob(base64));
|
|
787
384
|
if (typeof decoded !== "object" || decoded === null) return false;
|
|
788
|
-
if (
|
|
385
|
+
if ("typ" in decoded && decoded?.typ !== "JWT") return false;
|
|
386
|
+
if (!decoded.alg) return false;
|
|
789
387
|
if (alg && decoded.alg !== alg) return false;
|
|
790
388
|
return true;
|
|
791
|
-
} catch
|
|
389
|
+
} catch {
|
|
792
390
|
return false;
|
|
793
391
|
}
|
|
794
392
|
}
|
|
@@ -933,7 +531,7 @@ var ZodString = class ZodString extends ZodType {
|
|
|
933
531
|
}
|
|
934
532
|
} else if (check.kind === "url") try {
|
|
935
533
|
new URL(input.data);
|
|
936
|
-
} catch
|
|
534
|
+
} catch {
|
|
937
535
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
938
536
|
addIssueToContext(ctx, {
|
|
939
537
|
validation: "url",
|
|
@@ -1177,7 +775,6 @@ var ZodString = class ZodString extends ZodType {
|
|
|
1177
775
|
});
|
|
1178
776
|
}
|
|
1179
777
|
datetime(options) {
|
|
1180
|
-
var _a, _b;
|
|
1181
778
|
if (typeof options === "string") return this._addCheck({
|
|
1182
779
|
kind: "datetime",
|
|
1183
780
|
precision: null,
|
|
@@ -1187,10 +784,10 @@ var ZodString = class ZodString extends ZodType {
|
|
|
1187
784
|
});
|
|
1188
785
|
return this._addCheck({
|
|
1189
786
|
kind: "datetime",
|
|
1190
|
-
precision: typeof
|
|
1191
|
-
offset:
|
|
1192
|
-
local:
|
|
1193
|
-
...errorUtil.errToObj(options
|
|
787
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
788
|
+
offset: options?.offset ?? false,
|
|
789
|
+
local: options?.local ?? false,
|
|
790
|
+
...errorUtil.errToObj(options?.message)
|
|
1194
791
|
});
|
|
1195
792
|
}
|
|
1196
793
|
date(message) {
|
|
@@ -1207,8 +804,8 @@ var ZodString = class ZodString extends ZodType {
|
|
|
1207
804
|
});
|
|
1208
805
|
return this._addCheck({
|
|
1209
806
|
kind: "time",
|
|
1210
|
-
precision: typeof
|
|
1211
|
-
...errorUtil.errToObj(options
|
|
807
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
808
|
+
...errorUtil.errToObj(options?.message)
|
|
1212
809
|
});
|
|
1213
810
|
}
|
|
1214
811
|
duration(message) {
|
|
@@ -1228,8 +825,8 @@ var ZodString = class ZodString extends ZodType {
|
|
|
1228
825
|
return this._addCheck({
|
|
1229
826
|
kind: "includes",
|
|
1230
827
|
value,
|
|
1231
|
-
position: options
|
|
1232
|
-
...errorUtil.errToObj(options
|
|
828
|
+
position: options?.position,
|
|
829
|
+
...errorUtil.errToObj(options?.message)
|
|
1233
830
|
});
|
|
1234
831
|
}
|
|
1235
832
|
startsWith(value, message) {
|
|
@@ -1355,11 +952,10 @@ var ZodString = class ZodString extends ZodType {
|
|
|
1355
952
|
}
|
|
1356
953
|
};
|
|
1357
954
|
ZodString.create = (params) => {
|
|
1358
|
-
var _a;
|
|
1359
955
|
return new ZodString({
|
|
1360
956
|
checks: [],
|
|
1361
957
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
1362
|
-
coerce:
|
|
958
|
+
coerce: params?.coerce ?? false,
|
|
1363
959
|
...processCreateParams(params)
|
|
1364
960
|
});
|
|
1365
961
|
};
|
|
@@ -1367,7 +963,7 @@ function floatSafeRemainder(val, step) {
|
|
|
1367
963
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
1368
964
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
1369
965
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
1370
|
-
return parseInt(val.toFixed(decCount).replace(".", "")) % parseInt(step.toFixed(decCount).replace(".", "")) /
|
|
966
|
+
return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
|
|
1371
967
|
}
|
|
1372
968
|
var ZodNumber = class ZodNumber extends ZodType {
|
|
1373
969
|
constructor() {
|
|
@@ -1562,7 +1158,8 @@ var ZodNumber = class ZodNumber extends ZodType {
|
|
|
1562
1158
|
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
|
1563
1159
|
}
|
|
1564
1160
|
get isFinite() {
|
|
1565
|
-
let max = null
|
|
1161
|
+
let max = null;
|
|
1162
|
+
let min = null;
|
|
1566
1163
|
for (const ch of this._def.checks) if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") return true;
|
|
1567
1164
|
else if (ch.kind === "min") {
|
|
1568
1165
|
if (min === null || ch.value > min) min = ch.value;
|
|
@@ -1576,7 +1173,7 @@ ZodNumber.create = (params) => {
|
|
|
1576
1173
|
return new ZodNumber({
|
|
1577
1174
|
checks: [],
|
|
1578
1175
|
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
1579
|
-
coerce:
|
|
1176
|
+
coerce: params?.coerce || false,
|
|
1580
1177
|
...processCreateParams(params)
|
|
1581
1178
|
});
|
|
1582
1179
|
};
|
|
@@ -1589,7 +1186,7 @@ var ZodBigInt = class ZodBigInt extends ZodType {
|
|
|
1589
1186
|
_parse(input) {
|
|
1590
1187
|
if (this._def.coerce) try {
|
|
1591
1188
|
input.data = BigInt(input.data);
|
|
1592
|
-
} catch
|
|
1189
|
+
} catch {
|
|
1593
1190
|
return this._getInvalidInput(input);
|
|
1594
1191
|
}
|
|
1595
1192
|
if (this._getType(input) !== ZodParsedType.bigint) return this._getInvalidInput(input);
|
|
@@ -1728,11 +1325,10 @@ var ZodBigInt = class ZodBigInt extends ZodType {
|
|
|
1728
1325
|
}
|
|
1729
1326
|
};
|
|
1730
1327
|
ZodBigInt.create = (params) => {
|
|
1731
|
-
var _a;
|
|
1732
1328
|
return new ZodBigInt({
|
|
1733
1329
|
checks: [],
|
|
1734
1330
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
1735
|
-
coerce:
|
|
1331
|
+
coerce: params?.coerce ?? false,
|
|
1736
1332
|
...processCreateParams(params)
|
|
1737
1333
|
});
|
|
1738
1334
|
};
|
|
@@ -1754,7 +1350,7 @@ var ZodBoolean = class extends ZodType {
|
|
|
1754
1350
|
ZodBoolean.create = (params) => {
|
|
1755
1351
|
return new ZodBoolean({
|
|
1756
1352
|
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
1757
|
-
coerce:
|
|
1353
|
+
coerce: params?.coerce || false,
|
|
1758
1354
|
...processCreateParams(params)
|
|
1759
1355
|
});
|
|
1760
1356
|
};
|
|
@@ -1770,7 +1366,7 @@ var ZodDate = class ZodDate extends ZodType {
|
|
|
1770
1366
|
});
|
|
1771
1367
|
return INVALID;
|
|
1772
1368
|
}
|
|
1773
|
-
if (isNaN(input.data.getTime())) {
|
|
1369
|
+
if (Number.isNaN(input.data.getTime())) {
|
|
1774
1370
|
addIssueToContext(this._getOrReturnCtx(input), { code: ZodIssueCode.invalid_date });
|
|
1775
1371
|
return INVALID;
|
|
1776
1372
|
}
|
|
@@ -1846,7 +1442,7 @@ var ZodDate = class ZodDate extends ZodType {
|
|
|
1846
1442
|
ZodDate.create = (params) => {
|
|
1847
1443
|
return new ZodDate({
|
|
1848
1444
|
checks: [],
|
|
1849
|
-
coerce:
|
|
1445
|
+
coerce: params?.coerce || false,
|
|
1850
1446
|
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
1851
1447
|
...processCreateParams(params)
|
|
1852
1448
|
});
|
|
@@ -2124,10 +1720,11 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2124
1720
|
if (this._cached !== null) return this._cached;
|
|
2125
1721
|
const shape = this._def.shape();
|
|
2126
1722
|
const keys = util.objectKeys(shape);
|
|
2127
|
-
|
|
1723
|
+
this._cached = {
|
|
2128
1724
|
shape,
|
|
2129
1725
|
keys
|
|
2130
1726
|
};
|
|
1727
|
+
return this._cached;
|
|
2131
1728
|
}
|
|
2132
1729
|
_parse(input) {
|
|
2133
1730
|
if (this._getType(input) !== ZodParsedType.object) {
|
|
@@ -2178,8 +1775,7 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2178
1775
|
});
|
|
2179
1776
|
status.dirty();
|
|
2180
1777
|
}
|
|
2181
|
-
} else if (unknownKeys === "strip");
|
|
2182
|
-
else throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
|
1778
|
+
} else if (unknownKeys === "strip") {} else throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
|
2183
1779
|
} else {
|
|
2184
1780
|
const catchall = this._def.catchall;
|
|
2185
1781
|
for (const key of extraKeys) {
|
|
@@ -2220,9 +1816,8 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2220
1816
|
...this._def,
|
|
2221
1817
|
unknownKeys: "strict",
|
|
2222
1818
|
...message !== void 0 ? { errorMap: (issue, ctx) => {
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
if (issue.code === "unrecognized_keys") return { message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError };
|
|
1819
|
+
const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
|
|
1820
|
+
if (issue.code === "unrecognized_keys") return { message: errorUtil.errToObj(message).message ?? defaultError };
|
|
2226
1821
|
return { message: defaultError };
|
|
2227
1822
|
} } : {}
|
|
2228
1823
|
});
|
|
@@ -2275,9 +1870,7 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2275
1870
|
}
|
|
2276
1871
|
pick(mask) {
|
|
2277
1872
|
const shape = {};
|
|
2278
|
-
util.objectKeys(mask)
|
|
2279
|
-
if (mask[key] && this.shape[key]) shape[key] = this.shape[key];
|
|
2280
|
-
});
|
|
1873
|
+
for (const key of util.objectKeys(mask)) if (mask[key] && this.shape[key]) shape[key] = this.shape[key];
|
|
2281
1874
|
return new ZodObject({
|
|
2282
1875
|
...this._def,
|
|
2283
1876
|
shape: () => shape
|
|
@@ -2285,9 +1878,7 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2285
1878
|
}
|
|
2286
1879
|
omit(mask) {
|
|
2287
1880
|
const shape = {};
|
|
2288
|
-
util.objectKeys(this.shape)
|
|
2289
|
-
if (!mask[key]) shape[key] = this.shape[key];
|
|
2290
|
-
});
|
|
1881
|
+
for (const key of util.objectKeys(this.shape)) if (!mask[key]) shape[key] = this.shape[key];
|
|
2291
1882
|
return new ZodObject({
|
|
2292
1883
|
...this._def,
|
|
2293
1884
|
shape: () => shape
|
|
@@ -2301,11 +1892,11 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2301
1892
|
}
|
|
2302
1893
|
partial(mask) {
|
|
2303
1894
|
const newShape = {};
|
|
2304
|
-
util.objectKeys(this.shape)
|
|
1895
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
2305
1896
|
const fieldSchema = this.shape[key];
|
|
2306
1897
|
if (mask && !mask[key]) newShape[key] = fieldSchema;
|
|
2307
1898
|
else newShape[key] = fieldSchema.optional();
|
|
2308
|
-
}
|
|
1899
|
+
}
|
|
2309
1900
|
return new ZodObject({
|
|
2310
1901
|
...this._def,
|
|
2311
1902
|
shape: () => newShape
|
|
@@ -2313,14 +1904,12 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2313
1904
|
}
|
|
2314
1905
|
required(mask) {
|
|
2315
1906
|
const newShape = {};
|
|
2316
|
-
util.objectKeys(this.shape)
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
}
|
|
2323
|
-
});
|
|
1907
|
+
for (const key of util.objectKeys(this.shape)) if (mask && !mask[key]) newShape[key] = this.shape[key];
|
|
1908
|
+
else {
|
|
1909
|
+
let newField = this.shape[key];
|
|
1910
|
+
while (newField instanceof ZodOptional) newField = newField._def.innerType;
|
|
1911
|
+
newShape[key] = newField;
|
|
1912
|
+
}
|
|
2324
1913
|
return new ZodObject({
|
|
2325
1914
|
...this._def,
|
|
2326
1915
|
shape: () => newShape
|
|
@@ -3033,10 +2622,6 @@ function createZodEnum(values, params) {
|
|
|
3033
2622
|
});
|
|
3034
2623
|
}
|
|
3035
2624
|
var ZodEnum = class ZodEnum extends ZodType {
|
|
3036
|
-
constructor() {
|
|
3037
|
-
super(...arguments);
|
|
3038
|
-
_ZodEnum_cache.set(this, void 0);
|
|
3039
|
-
}
|
|
3040
2625
|
_parse(input) {
|
|
3041
2626
|
if (typeof input.data !== "string") {
|
|
3042
2627
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3048,8 +2633,8 @@ var ZodEnum = class ZodEnum extends ZodType {
|
|
|
3048
2633
|
});
|
|
3049
2634
|
return INVALID;
|
|
3050
2635
|
}
|
|
3051
|
-
if (!
|
|
3052
|
-
if (!
|
|
2636
|
+
if (!this._cache) this._cache = new Set(this._def.values);
|
|
2637
|
+
if (!this._cache.has(input.data)) {
|
|
3053
2638
|
const ctx = this._getOrReturnCtx(input);
|
|
3054
2639
|
const expectedValues = this._def.values;
|
|
3055
2640
|
addIssueToContext(ctx, {
|
|
@@ -3092,13 +2677,8 @@ var ZodEnum = class ZodEnum extends ZodType {
|
|
|
3092
2677
|
});
|
|
3093
2678
|
}
|
|
3094
2679
|
};
|
|
3095
|
-
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3096
2680
|
ZodEnum.create = createZodEnum;
|
|
3097
2681
|
var ZodNativeEnum = class extends ZodType {
|
|
3098
|
-
constructor() {
|
|
3099
|
-
super(...arguments);
|
|
3100
|
-
_ZodNativeEnum_cache.set(this, void 0);
|
|
3101
|
-
}
|
|
3102
2682
|
_parse(input) {
|
|
3103
2683
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3104
2684
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3111,8 +2691,8 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3111
2691
|
});
|
|
3112
2692
|
return INVALID;
|
|
3113
2693
|
}
|
|
3114
|
-
if (!
|
|
3115
|
-
if (!
|
|
2694
|
+
if (!this._cache) this._cache = new Set(util.getValidEnumValues(this._def.values));
|
|
2695
|
+
if (!this._cache.has(input.data)) {
|
|
3116
2696
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3117
2697
|
addIssueToContext(ctx, {
|
|
3118
2698
|
received: ctx.data,
|
|
@@ -3127,7 +2707,6 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3127
2707
|
return this._def.values;
|
|
3128
2708
|
}
|
|
3129
2709
|
};
|
|
3130
|
-
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3131
2710
|
ZodNativeEnum.create = (values, params) => {
|
|
3132
2711
|
return new ZodNativeEnum({
|
|
3133
2712
|
values,
|
|
@@ -3253,7 +2832,7 @@ var ZodEffects = class extends ZodType {
|
|
|
3253
2832
|
path: ctx.path,
|
|
3254
2833
|
parent: ctx
|
|
3255
2834
|
});
|
|
3256
|
-
if (!isValid(base)) return
|
|
2835
|
+
if (!isValid(base)) return INVALID;
|
|
3257
2836
|
const result = effect.transform(base.value, checkCtx);
|
|
3258
2837
|
if (result instanceof Promise) throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
3259
2838
|
return {
|
|
@@ -3265,7 +2844,7 @@ var ZodEffects = class extends ZodType {
|
|
|
3265
2844
|
path: ctx.path,
|
|
3266
2845
|
parent: ctx
|
|
3267
2846
|
}).then((base) => {
|
|
3268
|
-
if (!isValid(base)) return
|
|
2847
|
+
if (!isValid(base)) return INVALID;
|
|
3269
2848
|
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
3270
2849
|
status: status.value,
|
|
3271
2850
|
value: result
|
|
@@ -3509,13 +3088,11 @@ function cleanParams(params, data) {
|
|
|
3509
3088
|
}
|
|
3510
3089
|
function custom(check, _params = {}, fatal) {
|
|
3511
3090
|
if (check) return ZodAny.create().superRefine((data, ctx) => {
|
|
3512
|
-
var _a, _b;
|
|
3513
3091
|
const r = check(data);
|
|
3514
3092
|
if (r instanceof Promise) return r.then((r) => {
|
|
3515
|
-
var _a, _b;
|
|
3516
3093
|
if (!r) {
|
|
3517
3094
|
const params = cleanParams(_params, data);
|
|
3518
|
-
const _fatal =
|
|
3095
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
3519
3096
|
ctx.addIssue({
|
|
3520
3097
|
code: "custom",
|
|
3521
3098
|
...params,
|
|
@@ -3525,7 +3102,7 @@ function custom(check, _params = {}, fatal) {
|
|
|
3525
3102
|
});
|
|
3526
3103
|
if (!r) {
|
|
3527
3104
|
const params = cleanParams(_params, data);
|
|
3528
|
-
const _fatal =
|
|
3105
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
3529
3106
|
ctx.addIssue({
|
|
3530
3107
|
code: "custom",
|
|
3531
3108
|
...params,
|
|
@@ -3613,144 +3190,30 @@ var pipelineType = ZodPipeline.create;
|
|
|
3613
3190
|
var ostring = () => stringType().optional();
|
|
3614
3191
|
var onumber = () => numberType().optional();
|
|
3615
3192
|
var oboolean = () => booleanType().optional();
|
|
3616
|
-
var
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
getParsedType,
|
|
3640
|
-
ZodType,
|
|
3641
|
-
datetimeRegex,
|
|
3642
|
-
ZodString,
|
|
3643
|
-
ZodNumber,
|
|
3644
|
-
ZodBigInt,
|
|
3645
|
-
ZodBoolean,
|
|
3646
|
-
ZodDate,
|
|
3647
|
-
ZodSymbol,
|
|
3648
|
-
ZodUndefined,
|
|
3649
|
-
ZodNull,
|
|
3650
|
-
ZodAny,
|
|
3651
|
-
ZodUnknown,
|
|
3652
|
-
ZodNever,
|
|
3653
|
-
ZodVoid,
|
|
3654
|
-
ZodArray,
|
|
3655
|
-
ZodObject,
|
|
3656
|
-
ZodUnion,
|
|
3657
|
-
ZodDiscriminatedUnion,
|
|
3658
|
-
ZodIntersection,
|
|
3659
|
-
ZodTuple,
|
|
3660
|
-
ZodRecord,
|
|
3661
|
-
ZodMap,
|
|
3662
|
-
ZodSet,
|
|
3663
|
-
ZodFunction,
|
|
3664
|
-
ZodLazy,
|
|
3665
|
-
ZodLiteral,
|
|
3666
|
-
ZodEnum,
|
|
3667
|
-
ZodNativeEnum,
|
|
3668
|
-
ZodPromise,
|
|
3669
|
-
ZodEffects,
|
|
3670
|
-
ZodTransformer: ZodEffects,
|
|
3671
|
-
ZodOptional,
|
|
3672
|
-
ZodNullable,
|
|
3673
|
-
ZodDefault,
|
|
3674
|
-
ZodCatch,
|
|
3675
|
-
ZodNaN,
|
|
3676
|
-
BRAND,
|
|
3677
|
-
ZodBranded,
|
|
3678
|
-
ZodPipeline,
|
|
3679
|
-
ZodReadonly,
|
|
3680
|
-
custom,
|
|
3681
|
-
Schema: ZodType,
|
|
3682
|
-
ZodSchema: ZodType,
|
|
3683
|
-
late,
|
|
3684
|
-
get ZodFirstPartyTypeKind() {
|
|
3685
|
-
return ZodFirstPartyTypeKind;
|
|
3686
|
-
},
|
|
3687
|
-
coerce: {
|
|
3688
|
-
string: ((arg) => ZodString.create({
|
|
3689
|
-
...arg,
|
|
3690
|
-
coerce: true
|
|
3691
|
-
})),
|
|
3692
|
-
number: ((arg) => ZodNumber.create({
|
|
3693
|
-
...arg,
|
|
3694
|
-
coerce: true
|
|
3695
|
-
})),
|
|
3696
|
-
boolean: ((arg) => ZodBoolean.create({
|
|
3697
|
-
...arg,
|
|
3698
|
-
coerce: true
|
|
3699
|
-
})),
|
|
3700
|
-
bigint: ((arg) => ZodBigInt.create({
|
|
3701
|
-
...arg,
|
|
3702
|
-
coerce: true
|
|
3703
|
-
})),
|
|
3704
|
-
date: ((arg) => ZodDate.create({
|
|
3705
|
-
...arg,
|
|
3706
|
-
coerce: true
|
|
3707
|
-
}))
|
|
3708
|
-
},
|
|
3709
|
-
any: anyType,
|
|
3710
|
-
array: arrayType,
|
|
3711
|
-
bigint: bigIntType,
|
|
3712
|
-
boolean: booleanType,
|
|
3713
|
-
date: dateType,
|
|
3714
|
-
discriminatedUnion: discriminatedUnionType,
|
|
3715
|
-
effect: effectsType,
|
|
3716
|
-
"enum": enumType,
|
|
3717
|
-
"function": functionType,
|
|
3718
|
-
"instanceof": instanceOfType,
|
|
3719
|
-
intersection: intersectionType,
|
|
3720
|
-
lazy: lazyType,
|
|
3721
|
-
literal: literalType,
|
|
3722
|
-
map: mapType,
|
|
3723
|
-
nan: nanType,
|
|
3724
|
-
nativeEnum: nativeEnumType,
|
|
3725
|
-
never: neverType,
|
|
3726
|
-
"null": nullType,
|
|
3727
|
-
nullable: nullableType,
|
|
3728
|
-
number: numberType,
|
|
3729
|
-
object: objectType,
|
|
3730
|
-
oboolean,
|
|
3731
|
-
onumber,
|
|
3732
|
-
optional: optionalType,
|
|
3733
|
-
ostring,
|
|
3734
|
-
pipeline: pipelineType,
|
|
3735
|
-
preprocess: preprocessType,
|
|
3736
|
-
promise: promiseType,
|
|
3737
|
-
record: recordType,
|
|
3738
|
-
set: setType,
|
|
3739
|
-
strictObject: strictObjectType,
|
|
3740
|
-
string: stringType,
|
|
3741
|
-
symbol: symbolType,
|
|
3742
|
-
transformer: effectsType,
|
|
3743
|
-
tuple: tupleType,
|
|
3744
|
-
"undefined": undefinedType,
|
|
3745
|
-
union: unionType,
|
|
3746
|
-
unknown: unknownType,
|
|
3747
|
-
"void": voidType,
|
|
3748
|
-
NEVER: INVALID,
|
|
3749
|
-
ZodIssueCode,
|
|
3750
|
-
quotelessJson,
|
|
3751
|
-
ZodError
|
|
3752
|
-
});
|
|
3193
|
+
var coerce = {
|
|
3194
|
+
string: ((arg) => ZodString.create({
|
|
3195
|
+
...arg,
|
|
3196
|
+
coerce: true
|
|
3197
|
+
})),
|
|
3198
|
+
number: ((arg) => ZodNumber.create({
|
|
3199
|
+
...arg,
|
|
3200
|
+
coerce: true
|
|
3201
|
+
})),
|
|
3202
|
+
boolean: ((arg) => ZodBoolean.create({
|
|
3203
|
+
...arg,
|
|
3204
|
+
coerce: true
|
|
3205
|
+
})),
|
|
3206
|
+
bigint: ((arg) => ZodBigInt.create({
|
|
3207
|
+
...arg,
|
|
3208
|
+
coerce: true
|
|
3209
|
+
})),
|
|
3210
|
+
date: ((arg) => ZodDate.create({
|
|
3211
|
+
...arg,
|
|
3212
|
+
coerce: true
|
|
3213
|
+
}))
|
|
3214
|
+
};
|
|
3215
|
+
var NEVER = INVALID;
|
|
3753
3216
|
//#endregion
|
|
3754
|
-
export {
|
|
3217
|
+
export { BRAND, NEVER, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodSet, ZodString, ZodSymbol, ZodTuple, ZodType, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, anyType, arrayType, bigIntType, booleanType, coerce, custom, dateType, datetimeRegex, discriminatedUnionType, effectsType, enumType, functionType, instanceOfType, intersectionType, late, lazyType, literalType, mapType, nanType, nativeEnumType, neverType, nullType, nullableType, numberType, objectType, oboolean, onumber, optionalType, ostring, pipelineType, preprocessType, promiseType, recordType, setType, strictObjectType, stringType, symbolType, tupleType, undefinedType, unionType, unknownType, voidType };
|
|
3755
3218
|
|
|
3756
|
-
//# sourceMappingURL=
|
|
3219
|
+
//# sourceMappingURL=types.js.map
|