@axium/server 0.22.11 → 0.22.13
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/build/client/_app/immutable/chunks/CiUsfGrc.js +43 -0
- package/build/client/_app/immutable/chunks/CiUsfGrc.js.br +0 -0
- package/build/client/_app/immutable/chunks/CiUsfGrc.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{BMQhMafy.js → D3hk2v8y.js} +1 -1
- package/build/client/_app/immutable/chunks/D3hk2v8y.js.br +2 -0
- package/build/client/_app/immutable/chunks/D3hk2v8y.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{ButWEHh0.js → D4Bce_hb.js} +1 -1
- package/build/client/_app/immutable/chunks/D4Bce_hb.js.br +0 -0
- package/build/client/_app/immutable/chunks/D4Bce_hb.js.gz +0 -0
- package/build/client/_app/immutable/chunks/D9TfJrfD.js +1 -0
- package/build/client/_app/immutable/chunks/D9TfJrfD.js.br +0 -0
- package/build/client/_app/immutable/chunks/D9TfJrfD.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Dext3JFj.js +3 -0
- package/build/client/_app/immutable/chunks/Dext3JFj.js.br +0 -0
- package/build/client/_app/immutable/chunks/Dext3JFj.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Dy1O3iBu.js +2 -0
- package/build/client/_app/immutable/chunks/Dy1O3iBu.js.br +0 -0
- package/build/client/_app/immutable/chunks/Dy1O3iBu.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{DN_VTkOW.js → XdRahthI.js} +1 -1
- package/build/client/_app/immutable/chunks/XdRahthI.js.br +0 -0
- package/build/client/_app/immutable/chunks/XdRahthI.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{Cj9PL7OG.js → pba7IodQ.js} +1 -1
- package/build/client/_app/immutable/chunks/pba7IodQ.js.br +0 -0
- package/build/client/_app/immutable/chunks/pba7IodQ.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.C5LuJT06.js +2 -0
- package/build/client/_app/immutable/entry/app.C5LuJT06.js.br +0 -0
- package/build/client/_app/immutable/entry/app.C5LuJT06.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.BQJupvGE.js +1 -0
- package/build/client/_app/immutable/entry/start.BQJupvGE.js.br +2 -0
- package/build/client/_app/immutable/entry/start.BQJupvGE.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{0.CE0uBbp0.js → 0.DlE8ZTIF.js} +1 -1
- package/build/client/_app/immutable/nodes/0.DlE8ZTIF.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.DlE8ZTIF.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{1.9GlBYpox.js → 1.BAsobPu4.js} +1 -1
- package/build/client/_app/immutable/nodes/1.BAsobPu4.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.BAsobPu4.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{2.B3qXd01D.js → 2.CvEpuMc7.js} +1 -1
- package/build/client/_app/immutable/nodes/2.CvEpuMc7.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.CvEpuMc7.js.gz +0 -0
- package/build/client/_app/immutable/nodes/3.C18mc0nK.js +7 -0
- package/build/client/_app/immutable/nodes/3.C18mc0nK.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.C18mc0nK.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{4.C0wscA_4.js → 4.eINJOagY.js} +1 -1
- package/build/client/_app/immutable/nodes/4.eINJOagY.js.br +0 -0
- package/build/client/_app/immutable/nodes/4.eINJOagY.js.gz +0 -0
- package/build/client/_app/immutable/nodes/5.DITFCLgK.js +1 -0
- package/build/client/_app/immutable/nodes/5.DITFCLgK.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.DITFCLgK.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{6.TEubHotu.js → 6.BbgUOuKV.js} +1 -1
- package/build/client/_app/immutable/nodes/6.BbgUOuKV.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.BbgUOuKV.js.gz +0 -0
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/handler.js +26 -26
- package/build/server/chunks/{0-DJKsK7F_.js → 0-DgHTujtC.js} +2 -2
- package/build/server/chunks/{0-DJKsK7F_.js.map → 0-DgHTujtC.js.map} +1 -1
- package/build/server/chunks/1-5bszWZCQ.js +9 -0
- package/build/server/chunks/{1-D4403Evz.js.map → 1-5bszWZCQ.js.map} +1 -1
- package/build/server/chunks/{2-fj0aW1I0.js → 2-CXlrhpR6.js} +2 -2
- package/build/server/chunks/{2-fj0aW1I0.js.map → 2-CXlrhpR6.js.map} +1 -1
- package/build/server/chunks/3-CGyRgNsB.js +13 -0
- package/build/server/chunks/{3-CCrTqwF9.js.map → 3-CGyRgNsB.js.map} +1 -1
- package/build/server/chunks/4-BuMxaapL.js +9 -0
- package/build/server/chunks/{4-vjHkix88.js.map → 4-BuMxaapL.js.map} +1 -1
- package/build/server/chunks/5-BhHQT7ic.js +9 -0
- package/build/server/chunks/{5-Dc6xvhmU.js.map → 5-BhHQT7ic.js.map} +1 -1
- package/build/server/chunks/6-Do2XsDIk.js +9 -0
- package/build/server/chunks/{6-CvdeNFQU.js.map → 6-Do2XsDIk.js.map} +1 -1
- package/build/server/chunks/{FormDialog-CUzCwBFr.js → FormDialog-BemX_bll.js} +5 -5
- package/build/server/chunks/{FormDialog-CUzCwBFr.js.map → FormDialog-BemX_bll.js.map} +1 -1
- package/build/server/chunks/{Logout-48MBrG2s.js → Logout-BhQS74v2.js} +3 -3
- package/build/server/chunks/{Logout-48MBrG2s.js.map → Logout-BhQS74v2.js.map} +1 -1
- package/build/server/chunks/_page.svelte-BdL0IPY2.js +11 -0
- package/build/server/chunks/{_page.svelte-BHwIILw0.js.map → _page.svelte-BdL0IPY2.js.map} +1 -1
- package/build/server/chunks/{_page.svelte-Yesd_T6C.js → _page.svelte-Cw9An0SZ.js} +4 -4
- package/build/server/chunks/{_page.svelte-Yesd_T6C.js.map → _page.svelte-Cw9An0SZ.js.map} +1 -1
- package/build/server/chunks/{_page.svelte-CNug2JTC.js → _page.svelte-D6BUZio7.js} +5 -5
- package/build/server/chunks/{_page.svelte-CNug2JTC.js.map → _page.svelte-D6BUZio7.js.map} +1 -1
- package/build/server/chunks/{_page.svelte-DSnarRUI.js → _page.svelte-Q_wBpED1.js} +4 -4
- package/build/server/chunks/{_page.svelte-DSnarRUI.js.map → _page.svelte-Q_wBpED1.js.map} +1 -1
- package/build/server/chunks/{error.svelte-DtpUafMU.js → error.svelte-DNQXZmIO.js} +3 -3
- package/build/server/chunks/error.svelte-DNQXZmIO.js.map +1 -0
- package/build/server/chunks/{hooks.server-BJTU7JI4.js → hooks.server-B7iBt6uC.js} +6 -6
- package/build/server/chunks/hooks.server-B7iBt6uC.js.map +1 -0
- package/build/server/chunks/{index-apo9QTc6.js → index-RTKpMYZ1.js} +2 -2
- package/build/server/chunks/{index-apo9QTc6.js.map → index-RTKpMYZ1.js.map} +1 -1
- package/build/server/chunks/{index-iqDDeMM6.js → index-wXTeP1jh.js} +275 -257
- package/build/server/chunks/index-wXTeP1jh.js.map +1 -0
- package/build/server/chunks/{exports-Cy4FWdYs.js → utils-h74ns7K6.js} +39 -2
- package/build/server/chunks/utils-h74ns7K6.js.map +1 -0
- package/build/server/index.js +600 -380
- package/build/server/index.js.map +1 -1
- package/build/server/manifest.js +8 -8
- package/build/server/manifest.js.map +1 -1
- package/dist/cli.js +6 -4
- package/dist/config.d.ts +8 -8
- package/dist/plugins.js +1 -1
- package/dist/requests.js +2 -2
- package/package.json +1 -1
- package/build/client/_app/immutable/chunks/BMQhMafy.js.br +0 -0
- package/build/client/_app/immutable/chunks/BMQhMafy.js.gz +0 -0
- package/build/client/_app/immutable/chunks/ButWEHh0.js.br +0 -0
- package/build/client/_app/immutable/chunks/ButWEHh0.js.gz +0 -0
- package/build/client/_app/immutable/chunks/C8C04JmV.js +0 -1
- package/build/client/_app/immutable/chunks/C8C04JmV.js.br +0 -0
- package/build/client/_app/immutable/chunks/C8C04JmV.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Cj9PL7OG.js.br +0 -0
- package/build/client/_app/immutable/chunks/Cj9PL7OG.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DN_VTkOW.js.br +0 -0
- package/build/client/_app/immutable/chunks/DN_VTkOW.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DwJfO5YS.js +0 -3
- package/build/client/_app/immutable/chunks/DwJfO5YS.js.br +0 -0
- package/build/client/_app/immutable/chunks/DwJfO5YS.js.gz +0 -0
- package/build/client/_app/immutable/chunks/lSbGwHqC.js +0 -51
- package/build/client/_app/immutable/chunks/lSbGwHqC.js.br +0 -0
- package/build/client/_app/immutable/chunks/lSbGwHqC.js.gz +0 -0
- package/build/client/_app/immutable/chunks/x4Pz-wH_.js +0 -1
- package/build/client/_app/immutable/chunks/x4Pz-wH_.js.br +0 -0
- package/build/client/_app/immutable/chunks/x4Pz-wH_.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.DLzwCGBk.js +0 -2
- package/build/client/_app/immutable/entry/app.DLzwCGBk.js.br +0 -0
- package/build/client/_app/immutable/entry/app.DLzwCGBk.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.BoB-G5Ls.js +0 -1
- package/build/client/_app/immutable/entry/start.BoB-G5Ls.js.br +0 -2
- package/build/client/_app/immutable/entry/start.BoB-G5Ls.js.gz +0 -0
- package/build/client/_app/immutable/nodes/0.CE0uBbp0.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.CE0uBbp0.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.9GlBYpox.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.9GlBYpox.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.B3qXd01D.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.B3qXd01D.js.gz +0 -0
- package/build/client/_app/immutable/nodes/3.DuwUIVtX.js +0 -7
- package/build/client/_app/immutable/nodes/3.DuwUIVtX.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.DuwUIVtX.js.gz +0 -0
- package/build/client/_app/immutable/nodes/4.C0wscA_4.js.br +0 -0
- package/build/client/_app/immutable/nodes/4.C0wscA_4.js.gz +0 -0
- package/build/client/_app/immutable/nodes/5.CWS-YJ56.js +0 -1
- package/build/client/_app/immutable/nodes/5.CWS-YJ56.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.CWS-YJ56.js.gz +0 -0
- package/build/client/_app/immutable/nodes/6.TEubHotu.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.TEubHotu.js.gz +0 -0
- package/build/server/chunks/1-D4403Evz.js +0 -9
- package/build/server/chunks/3-CCrTqwF9.js +0 -13
- package/build/server/chunks/4-vjHkix88.js +0 -9
- package/build/server/chunks/5-Dc6xvhmU.js +0 -9
- package/build/server/chunks/6-CvdeNFQU.js +0 -9
- package/build/server/chunks/_page.svelte-BHwIILw0.js +0 -11
- package/build/server/chunks/error.svelte-DtpUafMU.js.map +0 -1
- package/build/server/chunks/exports-Cy4FWdYs.js.map +0 -1
- package/build/server/chunks/hooks.server-BJTU7JI4.js.map +0 -1
- package/build/server/chunks/index-iqDDeMM6.js.map +0 -1
|
@@ -87,20 +87,33 @@ function cleanRegex(source) {
|
|
|
87
87
|
}
|
|
88
88
|
function floatSafeRemainder(val, step) {
|
|
89
89
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
90
|
-
const
|
|
90
|
+
const stepString = step.toString();
|
|
91
|
+
let stepDecCount = (stepString.split(".")[1] || "").length;
|
|
92
|
+
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
|
|
93
|
+
const match = stepString.match(/\d?e-(\d?)/);
|
|
94
|
+
if (match?.[1]) {
|
|
95
|
+
stepDecCount = Number.parseInt(match[1]);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
91
98
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
92
99
|
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
93
100
|
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
94
101
|
return (valInt % stepInt) / 10 ** decCount;
|
|
95
102
|
}
|
|
103
|
+
const EVALUATING = Symbol("evaluating");
|
|
96
104
|
function defineLazy(object, key, getter) {
|
|
105
|
+
let value = undefined;
|
|
97
106
|
Object.defineProperty(object, key, {
|
|
98
107
|
get() {
|
|
99
|
-
{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return value;
|
|
108
|
+
if (value === EVALUATING) {
|
|
109
|
+
// Circular reference detected, return undefined to break the cycle
|
|
110
|
+
return undefined;
|
|
103
111
|
}
|
|
112
|
+
if (value === undefined) {
|
|
113
|
+
value = EVALUATING;
|
|
114
|
+
value = getter();
|
|
115
|
+
}
|
|
116
|
+
return value;
|
|
104
117
|
},
|
|
105
118
|
set(v) {
|
|
106
119
|
Object.defineProperty(object, key, {
|
|
@@ -112,6 +125,9 @@ function defineLazy(object, key, getter) {
|
|
|
112
125
|
configurable: true,
|
|
113
126
|
});
|
|
114
127
|
}
|
|
128
|
+
function objectClone(obj) {
|
|
129
|
+
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
130
|
+
}
|
|
115
131
|
function assignProp(target, prop, value) {
|
|
116
132
|
Object.defineProperty(target, prop, {
|
|
117
133
|
value,
|
|
@@ -120,16 +136,23 @@ function assignProp(target, prop, value) {
|
|
|
120
136
|
configurable: true,
|
|
121
137
|
});
|
|
122
138
|
}
|
|
139
|
+
function mergeDefs(...defs) {
|
|
140
|
+
const mergedDescriptors = {};
|
|
141
|
+
for (const def of defs) {
|
|
142
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
143
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
144
|
+
}
|
|
145
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
146
|
+
}
|
|
123
147
|
function esc(str) {
|
|
124
148
|
return JSON.stringify(str);
|
|
125
149
|
}
|
|
126
|
-
const captureStackTrace = Error.captureStackTrace
|
|
127
|
-
? Error.captureStackTrace
|
|
128
|
-
: (..._args) => { };
|
|
150
|
+
const captureStackTrace = ("captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => { });
|
|
129
151
|
function isObject(data) {
|
|
130
152
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
131
153
|
}
|
|
132
154
|
const allowsEval = cached(() => {
|
|
155
|
+
// @ts-ignore
|
|
133
156
|
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
|
134
157
|
return false;
|
|
135
158
|
}
|
|
@@ -159,6 +182,11 @@ function isPlainObject(o) {
|
|
|
159
182
|
}
|
|
160
183
|
return true;
|
|
161
184
|
}
|
|
185
|
+
function shallowClone(o) {
|
|
186
|
+
if (isPlainObject(o))
|
|
187
|
+
return { ...o };
|
|
188
|
+
return o;
|
|
189
|
+
}
|
|
162
190
|
const propertyKeyTypes = new Set(["string", "number", "symbol"]);
|
|
163
191
|
function escapeRegex(str) {
|
|
164
192
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -199,140 +227,153 @@ const NUMBER_FORMAT_RANGES = {
|
|
|
199
227
|
float64: [-Number.MAX_VALUE, Number.MAX_VALUE],
|
|
200
228
|
};
|
|
201
229
|
function pick(schema, mask) {
|
|
202
|
-
const
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
230
|
+
const currDef = schema._zod.def;
|
|
231
|
+
const def = mergeDefs(schema._zod.def, {
|
|
232
|
+
get shape() {
|
|
233
|
+
const newShape = {};
|
|
234
|
+
for (const key in mask) {
|
|
235
|
+
if (!(key in currDef.shape)) {
|
|
236
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
237
|
+
}
|
|
238
|
+
if (!mask[key])
|
|
239
|
+
continue;
|
|
240
|
+
newShape[key] = currDef.shape[key];
|
|
241
|
+
}
|
|
242
|
+
assignProp(this, "shape", newShape); // self-caching
|
|
243
|
+
return newShape;
|
|
244
|
+
},
|
|
216
245
|
checks: [],
|
|
217
246
|
});
|
|
247
|
+
return clone(schema, def);
|
|
218
248
|
}
|
|
219
249
|
function omit(schema, mask) {
|
|
220
|
-
const
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
250
|
+
const currDef = schema._zod.def;
|
|
251
|
+
const def = mergeDefs(schema._zod.def, {
|
|
252
|
+
get shape() {
|
|
253
|
+
const newShape = { ...schema._zod.def.shape };
|
|
254
|
+
for (const key in mask) {
|
|
255
|
+
if (!(key in currDef.shape)) {
|
|
256
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
257
|
+
}
|
|
258
|
+
if (!mask[key])
|
|
259
|
+
continue;
|
|
260
|
+
delete newShape[key];
|
|
261
|
+
}
|
|
262
|
+
assignProp(this, "shape", newShape); // self-caching
|
|
263
|
+
return newShape;
|
|
264
|
+
},
|
|
233
265
|
checks: [],
|
|
234
266
|
});
|
|
267
|
+
return clone(schema, def);
|
|
235
268
|
}
|
|
236
269
|
function extend(schema, shape) {
|
|
237
270
|
if (!isPlainObject(shape)) {
|
|
238
271
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
239
272
|
}
|
|
240
|
-
const def = {
|
|
241
|
-
...schema._zod.def,
|
|
273
|
+
const def = mergeDefs(schema._zod.def, {
|
|
242
274
|
get shape() {
|
|
243
275
|
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
244
276
|
assignProp(this, "shape", _shape); // self-caching
|
|
245
277
|
return _shape;
|
|
246
278
|
},
|
|
247
|
-
checks: [],
|
|
248
|
-
};
|
|
279
|
+
checks: [],
|
|
280
|
+
});
|
|
249
281
|
return clone(schema, def);
|
|
250
282
|
}
|
|
251
283
|
function merge(a, b) {
|
|
252
|
-
|
|
253
|
-
...a._zod.def,
|
|
284
|
+
const def = mergeDefs(a._zod.def, {
|
|
254
285
|
get shape() {
|
|
255
286
|
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
256
287
|
assignProp(this, "shape", _shape); // self-caching
|
|
257
288
|
return _shape;
|
|
258
289
|
},
|
|
259
|
-
catchall
|
|
290
|
+
get catchall() {
|
|
291
|
+
return b._zod.def.catchall;
|
|
292
|
+
},
|
|
260
293
|
checks: [], // delete existing checks
|
|
261
294
|
});
|
|
295
|
+
return clone(a, def);
|
|
262
296
|
}
|
|
263
297
|
function partial(Class, schema, mask) {
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (
|
|
269
|
-
|
|
298
|
+
const def = mergeDefs(schema._zod.def, {
|
|
299
|
+
get shape() {
|
|
300
|
+
const oldShape = schema._zod.def.shape;
|
|
301
|
+
const shape = { ...oldShape };
|
|
302
|
+
if (mask) {
|
|
303
|
+
for (const key in mask) {
|
|
304
|
+
if (!(key in oldShape)) {
|
|
305
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
306
|
+
}
|
|
307
|
+
if (!mask[key])
|
|
308
|
+
continue;
|
|
309
|
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
|
310
|
+
shape[key] = Class
|
|
311
|
+
? new Class({
|
|
312
|
+
type: "optional",
|
|
313
|
+
innerType: oldShape[key],
|
|
314
|
+
})
|
|
315
|
+
: oldShape[key];
|
|
316
|
+
}
|
|
270
317
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
shape[key] = Class
|
|
286
|
-
? new Class({
|
|
287
|
-
type: "optional",
|
|
288
|
-
innerType: oldShape[key],
|
|
289
|
-
})
|
|
290
|
-
: oldShape[key];
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return clone(schema, {
|
|
294
|
-
...schema._zod.def,
|
|
295
|
-
shape,
|
|
318
|
+
else {
|
|
319
|
+
for (const key in oldShape) {
|
|
320
|
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
|
321
|
+
shape[key] = Class
|
|
322
|
+
? new Class({
|
|
323
|
+
type: "optional",
|
|
324
|
+
innerType: oldShape[key],
|
|
325
|
+
})
|
|
326
|
+
: oldShape[key];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
assignProp(this, "shape", shape); // self-caching
|
|
330
|
+
return shape;
|
|
331
|
+
},
|
|
296
332
|
checks: [],
|
|
297
333
|
});
|
|
334
|
+
return clone(schema, def);
|
|
298
335
|
}
|
|
299
336
|
function required(Class, schema, mask) {
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
if (
|
|
305
|
-
|
|
337
|
+
const def = mergeDefs(schema._zod.def, {
|
|
338
|
+
get shape() {
|
|
339
|
+
const oldShape = schema._zod.def.shape;
|
|
340
|
+
const shape = { ...oldShape };
|
|
341
|
+
if (mask) {
|
|
342
|
+
for (const key in mask) {
|
|
343
|
+
if (!(key in shape)) {
|
|
344
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
345
|
+
}
|
|
346
|
+
if (!mask[key])
|
|
347
|
+
continue;
|
|
348
|
+
// overwrite with non-optional
|
|
349
|
+
shape[key] = new Class({
|
|
350
|
+
type: "nonoptional",
|
|
351
|
+
innerType: oldShape[key],
|
|
352
|
+
});
|
|
353
|
+
}
|
|
306
354
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
shape[key] = new Class({
|
|
320
|
-
type: "nonoptional",
|
|
321
|
-
innerType: oldShape[key],
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return clone(schema, {
|
|
326
|
-
...schema._zod.def,
|
|
327
|
-
shape,
|
|
328
|
-
// optional: [],
|
|
355
|
+
else {
|
|
356
|
+
for (const key in oldShape) {
|
|
357
|
+
// overwrite with non-optional
|
|
358
|
+
shape[key] = new Class({
|
|
359
|
+
type: "nonoptional",
|
|
360
|
+
innerType: oldShape[key],
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
assignProp(this, "shape", shape); // self-caching
|
|
365
|
+
return shape;
|
|
366
|
+
},
|
|
329
367
|
checks: [],
|
|
330
368
|
});
|
|
369
|
+
return clone(schema, def);
|
|
331
370
|
}
|
|
371
|
+
// invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom
|
|
332
372
|
function aborted(x, startIndex = 0) {
|
|
333
373
|
for (let i = startIndex; i < x.issues.length; i++) {
|
|
334
|
-
if (x.issues[i]?.continue !== true)
|
|
374
|
+
if (x.issues[i]?.continue !== true) {
|
|
335
375
|
return true;
|
|
376
|
+
}
|
|
336
377
|
}
|
|
337
378
|
return false;
|
|
338
379
|
}
|
|
@@ -396,13 +437,7 @@ const initializer$1 = (inst, def) => {
|
|
|
396
437
|
value: def,
|
|
397
438
|
enumerable: false,
|
|
398
439
|
});
|
|
399
|
-
|
|
400
|
-
get() {
|
|
401
|
-
return JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
402
|
-
},
|
|
403
|
-
enumerable: true,
|
|
404
|
-
// configurable: false,
|
|
405
|
-
});
|
|
440
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
406
441
|
Object.defineProperty(inst, "toString", {
|
|
407
442
|
value: () => inst.message,
|
|
408
443
|
enumerable: false,
|
|
@@ -498,8 +533,9 @@ function formatError(error, _mapper) {
|
|
|
498
533
|
* ✖ Invalid input: expected number
|
|
499
534
|
* ```
|
|
500
535
|
*/
|
|
501
|
-
function toDotPath(
|
|
536
|
+
function toDotPath(_path) {
|
|
502
537
|
const segs = [];
|
|
538
|
+
const path = _path.map((seg) => (typeof seg === "object" ? seg.key : seg));
|
|
503
539
|
for (const seg of path) {
|
|
504
540
|
if (typeof seg === "number")
|
|
505
541
|
segs.push(`[${seg}]`);
|
|
@@ -518,7 +554,7 @@ function toDotPath(path) {
|
|
|
518
554
|
function prettifyError(error) {
|
|
519
555
|
const lines = [];
|
|
520
556
|
// sort by path length
|
|
521
|
-
const issues = [...error.issues].sort((a, b) => a.path.length - b.path.length);
|
|
557
|
+
const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
|
|
522
558
|
// Process each issue
|
|
523
559
|
for (const issue of issues) {
|
|
524
560
|
lines.push(`✖ ${issue.message}`);
|
|
@@ -594,7 +630,7 @@ const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
|
594
630
|
const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
595
631
|
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
596
632
|
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
597
|
-
/** Returns a regex for validating an RFC 4122 UUID.
|
|
633
|
+
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
598
634
|
*
|
|
599
635
|
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
|
600
636
|
const uuid$1 = (version) => {
|
|
@@ -617,9 +653,8 @@ const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?:
|
|
|
617
653
|
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
618
654
|
const base64url = /^[A-Za-z0-9_-]*$/;
|
|
619
655
|
// based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
|
|
620
|
-
// export const hostname: RegExp =
|
|
621
|
-
|
|
622
|
-
const hostname = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
|
656
|
+
// export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
|
657
|
+
const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
623
658
|
// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
|
|
624
659
|
const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
625
660
|
// const dateSource = `((\\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])))`;
|
|
@@ -645,8 +680,9 @@ function datetime$1(args) {
|
|
|
645
680
|
const opts = ["Z"];
|
|
646
681
|
if (args.local)
|
|
647
682
|
opts.push("");
|
|
683
|
+
// if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
|
|
648
684
|
if (args.offset)
|
|
649
|
-
opts.push(`([+-]\\d
|
|
685
|
+
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
650
686
|
const timeRegex = `${time}(?:${opts.join("|")})`;
|
|
651
687
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
652
688
|
}
|
|
@@ -786,6 +822,7 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
|
|
|
786
822
|
expected: origin,
|
|
787
823
|
format: def.format,
|
|
788
824
|
code: "invalid_type",
|
|
825
|
+
continue: false,
|
|
789
826
|
input,
|
|
790
827
|
inst,
|
|
791
828
|
});
|
|
@@ -1108,7 +1145,7 @@ class Doc {
|
|
|
1108
1145
|
const version = {
|
|
1109
1146
|
major: 4,
|
|
1110
1147
|
minor: 0,
|
|
1111
|
-
patch:
|
|
1148
|
+
patch: 17,
|
|
1112
1149
|
};
|
|
1113
1150
|
|
|
1114
1151
|
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
@@ -1261,9 +1298,10 @@ const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
|
|
|
1261
1298
|
$ZodStringFormat.init(inst, def);
|
|
1262
1299
|
inst._zod.check = (payload) => {
|
|
1263
1300
|
try {
|
|
1264
|
-
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1301
|
+
// Trim whitespace from input
|
|
1302
|
+
const trimmed = payload.value.trim();
|
|
1303
|
+
// @ts-ignore
|
|
1304
|
+
const url = new URL(trimmed);
|
|
1267
1305
|
if (def.hostname) {
|
|
1268
1306
|
def.hostname.lastIndex = 0;
|
|
1269
1307
|
if (!def.hostname.test(url.hostname)) {
|
|
@@ -1292,12 +1330,14 @@ const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
|
|
|
1292
1330
|
});
|
|
1293
1331
|
}
|
|
1294
1332
|
}
|
|
1295
|
-
//
|
|
1296
|
-
if (
|
|
1297
|
-
|
|
1333
|
+
// Set the output value based on normalize flag
|
|
1334
|
+
if (def.normalize) {
|
|
1335
|
+
// Use normalized URL
|
|
1336
|
+
payload.value = url.href;
|
|
1298
1337
|
}
|
|
1299
1338
|
else {
|
|
1300
|
-
|
|
1339
|
+
// Preserve the original input (trimmed)
|
|
1340
|
+
payload.value = trimmed;
|
|
1301
1341
|
}
|
|
1302
1342
|
return;
|
|
1303
1343
|
}
|
|
@@ -1373,6 +1413,7 @@ const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
|
|
|
1373
1413
|
});
|
|
1374
1414
|
inst._zod.check = (payload) => {
|
|
1375
1415
|
try {
|
|
1416
|
+
// @ts-ignore
|
|
1376
1417
|
new URL(`http://[${payload.value}]`);
|
|
1377
1418
|
// return;
|
|
1378
1419
|
}
|
|
@@ -1404,6 +1445,7 @@ const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
|
1404
1445
|
throw new Error();
|
|
1405
1446
|
if (prefixNum < 0 || prefixNum > 128)
|
|
1406
1447
|
throw new Error();
|
|
1448
|
+
// @ts-ignore
|
|
1407
1449
|
new URL(`http://[${address}]`);
|
|
1408
1450
|
}
|
|
1409
1451
|
catch {
|
|
@@ -1424,6 +1466,7 @@ function isValidBase64(data) {
|
|
|
1424
1466
|
if (data.length % 4 !== 0)
|
|
1425
1467
|
return false;
|
|
1426
1468
|
try {
|
|
1469
|
+
// @ts-ignore
|
|
1427
1470
|
atob(data);
|
|
1428
1471
|
return true;
|
|
1429
1472
|
}
|
|
@@ -1488,6 +1531,7 @@ function isValidJWT(token, algorithm = null) {
|
|
|
1488
1531
|
const [header] = tokensParts;
|
|
1489
1532
|
if (!header)
|
|
1490
1533
|
return false;
|
|
1534
|
+
// @ts-ignore
|
|
1491
1535
|
const parsedHeader = JSON.parse(atob(header));
|
|
1492
1536
|
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
|
1493
1537
|
return false;
|
|
@@ -1654,36 +1698,16 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
|
1654
1698
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
1655
1699
|
};
|
|
1656
1700
|
});
|
|
1657
|
-
function
|
|
1658
|
-
// if(isOptional)
|
|
1701
|
+
function handlePropertyResult(result, final, key, input) {
|
|
1659
1702
|
if (result.issues.length) {
|
|
1660
1703
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
1661
1704
|
}
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
function handleOptionalObjectResult(result, final, key, input) {
|
|
1665
|
-
if (result.issues.length) {
|
|
1666
|
-
// validation failed against value schema
|
|
1667
|
-
if (input[key] === undefined) {
|
|
1668
|
-
// if input was undefined, ignore the error
|
|
1669
|
-
if (key in input) {
|
|
1670
|
-
final.value[key] = undefined;
|
|
1671
|
-
}
|
|
1672
|
-
else {
|
|
1673
|
-
final.value[key] = result.value;
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
else {
|
|
1677
|
-
final.issues.push(...prefixIssues(key, result.issues));
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1680
|
-
else if (result.value === undefined) {
|
|
1681
|
-
// validation returned `undefined`
|
|
1682
|
-
if (key in input)
|
|
1705
|
+
if (result.value === undefined) {
|
|
1706
|
+
if (key in input) {
|
|
1683
1707
|
final.value[key] = undefined;
|
|
1708
|
+
}
|
|
1684
1709
|
}
|
|
1685
1710
|
else {
|
|
1686
|
-
// non-undefined value
|
|
1687
1711
|
final.value[key] = result.value;
|
|
1688
1712
|
}
|
|
1689
1713
|
}
|
|
@@ -1693,7 +1717,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
|
1693
1717
|
const _normalized = cached(() => {
|
|
1694
1718
|
const keys = Object.keys(def.shape);
|
|
1695
1719
|
for (const k of keys) {
|
|
1696
|
-
if (!
|
|
1720
|
+
if (!def.shape[k]._zod.traits.has("$ZodType")) {
|
|
1697
1721
|
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
1698
1722
|
}
|
|
1699
1723
|
}
|
|
@@ -1735,42 +1759,25 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
|
1735
1759
|
// A: preserve key order {
|
|
1736
1760
|
doc.write(`const newResult = {}`);
|
|
1737
1761
|
for (const key of normalized.keys) {
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
doc.write(`
|
|
1762
|
+
const id = ids[key];
|
|
1763
|
+
const k = esc(key);
|
|
1764
|
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1765
|
+
doc.write(`
|
|
1743
1766
|
if (${id}.issues.length) {
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
}))
|
|
1754
|
-
);
|
|
1767
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1768
|
+
...iss,
|
|
1769
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1770
|
+
})));
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
if (${id}.value === undefined) {
|
|
1774
|
+
if (${k} in input) {
|
|
1775
|
+
newResult[${k}] = undefined;
|
|
1755
1776
|
}
|
|
1756
|
-
} else if (${id}.value === undefined) {
|
|
1757
|
-
if (${k} in input) newResult[${k}] = undefined;
|
|
1758
1777
|
} else {
|
|
1759
1778
|
newResult[${k}] = ${id}.value;
|
|
1760
1779
|
}
|
|
1761
|
-
|
|
1762
|
-
}
|
|
1763
|
-
else {
|
|
1764
|
-
const id = ids[key];
|
|
1765
|
-
// const id = ids[key];
|
|
1766
|
-
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1767
|
-
doc.write(`
|
|
1768
|
-
if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1769
|
-
...iss,
|
|
1770
|
-
path: iss.path ? [${esc(key)}, ...iss.path] : [${esc(key)}]
|
|
1771
|
-
})));`);
|
|
1772
|
-
doc.write(`newResult[${esc(key)}] = ${id}.value`);
|
|
1773
|
-
}
|
|
1780
|
+
`);
|
|
1774
1781
|
}
|
|
1775
1782
|
doc.write(`payload.value = newResult;`);
|
|
1776
1783
|
doc.write(`return payload;`);
|
|
@@ -1808,33 +1815,16 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
|
1808
1815
|
const shape = value.shape;
|
|
1809
1816
|
for (const key of value.keys) {
|
|
1810
1817
|
const el = shape[key];
|
|
1811
|
-
// do not add omitted optional keys
|
|
1812
|
-
// if (!(key in input)) {
|
|
1813
|
-
// if (optionalKeys.has(key)) continue;
|
|
1814
|
-
// payload.issues.push({
|
|
1815
|
-
// code: "invalid_type",
|
|
1816
|
-
// path: [key],
|
|
1817
|
-
// expected: "nonoptional",
|
|
1818
|
-
// note: `Missing required key: "${key}"`,
|
|
1819
|
-
// input,
|
|
1820
|
-
// inst,
|
|
1821
|
-
// });
|
|
1822
|
-
// }
|
|
1823
1818
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1824
|
-
const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
|
|
1825
1819
|
if (r instanceof Promise) {
|
|
1826
|
-
proms.push(r.then((r) =>
|
|
1827
|
-
}
|
|
1828
|
-
else if (isOptional) {
|
|
1829
|
-
handleOptionalObjectResult(r, payload, key, input);
|
|
1820
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
|
|
1830
1821
|
}
|
|
1831
1822
|
else {
|
|
1832
|
-
|
|
1823
|
+
handlePropertyResult(r, payload, key, input);
|
|
1833
1824
|
}
|
|
1834
1825
|
}
|
|
1835
1826
|
}
|
|
1836
1827
|
if (!catchall) {
|
|
1837
|
-
// return payload;
|
|
1838
1828
|
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1839
1829
|
}
|
|
1840
1830
|
const unrecognized = [];
|
|
@@ -1851,10 +1841,10 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
|
1851
1841
|
}
|
|
1852
1842
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
1853
1843
|
if (r instanceof Promise) {
|
|
1854
|
-
proms.push(r.then((r) =>
|
|
1844
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
|
|
1855
1845
|
}
|
|
1856
1846
|
else {
|
|
1857
|
-
|
|
1847
|
+
handlePropertyResult(r, payload, key, input);
|
|
1858
1848
|
}
|
|
1859
1849
|
}
|
|
1860
1850
|
if (unrecognized.length) {
|
|
@@ -1879,6 +1869,11 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
1879
1869
|
return final;
|
|
1880
1870
|
}
|
|
1881
1871
|
}
|
|
1872
|
+
const nonaborted = results.filter((r) => !aborted(r));
|
|
1873
|
+
if (nonaborted.length === 1) {
|
|
1874
|
+
final.value = nonaborted[0].value;
|
|
1875
|
+
return nonaborted[0];
|
|
1876
|
+
}
|
|
1882
1877
|
final.issues.push({
|
|
1883
1878
|
code: "invalid_union",
|
|
1884
1879
|
input: final.value,
|
|
@@ -1904,7 +1899,12 @@ const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
|
|
|
1904
1899
|
}
|
|
1905
1900
|
return undefined;
|
|
1906
1901
|
});
|
|
1902
|
+
const single = def.options.length === 1;
|
|
1903
|
+
const first = def.options[0]._zod.run;
|
|
1907
1904
|
inst._zod.parse = (payload, ctx) => {
|
|
1905
|
+
if (single) {
|
|
1906
|
+
return first(payload, ctx);
|
|
1907
|
+
}
|
|
1908
1908
|
let async = false;
|
|
1909
1909
|
const results = [];
|
|
1910
1910
|
for (const option of def.options) {
|
|
@@ -2028,10 +2028,10 @@ const $ZodTuple = /*@__PURE__*/ $constructor("$ZodTuple", (inst, def) => {
|
|
|
2028
2028
|
const tooSmall = input.length < optStart - 1;
|
|
2029
2029
|
if (tooBig || tooSmall) {
|
|
2030
2030
|
payload.issues.push({
|
|
2031
|
+
...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
|
|
2031
2032
|
input,
|
|
2032
2033
|
inst,
|
|
2033
2034
|
origin: "array",
|
|
2034
|
-
...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
|
|
2035
2035
|
});
|
|
2036
2036
|
return payload;
|
|
2037
2037
|
}
|
|
@@ -2143,8 +2143,8 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
2143
2143
|
}
|
|
2144
2144
|
if (keyResult.issues.length) {
|
|
2145
2145
|
payload.issues.push({
|
|
2146
|
-
origin: "record",
|
|
2147
2146
|
code: "invalid_key",
|
|
2147
|
+
origin: "record",
|
|
2148
2148
|
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
2149
2149
|
input: key,
|
|
2150
2150
|
path: [key],
|
|
@@ -2179,14 +2179,15 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
2179
2179
|
const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
2180
2180
|
$ZodType.init(inst, def);
|
|
2181
2181
|
const values = getEnumValues(def.entries);
|
|
2182
|
-
|
|
2182
|
+
const valuesSet = new Set(values);
|
|
2183
|
+
inst._zod.values = valuesSet;
|
|
2183
2184
|
inst._zod.pattern = new RegExp(`^(${values
|
|
2184
2185
|
.filter((k) => propertyKeyTypes.has(typeof k))
|
|
2185
2186
|
.map((o) => (typeof o === "string" ? escapeRegex(o) : o.toString()))
|
|
2186
2187
|
.join("|")})$`);
|
|
2187
2188
|
inst._zod.parse = (payload, _ctx) => {
|
|
2188
2189
|
const input = payload.value;
|
|
2189
|
-
if (
|
|
2190
|
+
if (valuesSet.has(input)) {
|
|
2190
2191
|
return payload;
|
|
2191
2192
|
}
|
|
2192
2193
|
payload.issues.push({
|
|
@@ -2200,9 +2201,12 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
|
2200
2201
|
});
|
|
2201
2202
|
const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
|
|
2202
2203
|
$ZodType.init(inst, def);
|
|
2204
|
+
if (def.values.length === 0) {
|
|
2205
|
+
throw new Error("Cannot create literal schema with no valid values");
|
|
2206
|
+
}
|
|
2203
2207
|
inst._zod.values = new Set(def.values);
|
|
2204
2208
|
inst._zod.pattern = new RegExp(`^(${def.values
|
|
2205
|
-
.map((o) => (typeof o === "string" ? escapeRegex(o) : o ? o.toString() : String(o)))
|
|
2209
|
+
.map((o) => (typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)))
|
|
2206
2210
|
.join("|")})$`);
|
|
2207
2211
|
inst._zod.parse = (payload, _ctx) => {
|
|
2208
2212
|
const input = payload.value;
|
|
@@ -2236,6 +2240,12 @@ const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) =>
|
|
|
2236
2240
|
return payload;
|
|
2237
2241
|
};
|
|
2238
2242
|
});
|
|
2243
|
+
function handleOptionalResult(result, input) {
|
|
2244
|
+
if (result.issues.length && input === undefined) {
|
|
2245
|
+
return { issues: [], value: undefined };
|
|
2246
|
+
}
|
|
2247
|
+
return result;
|
|
2248
|
+
}
|
|
2239
2249
|
const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
|
|
2240
2250
|
$ZodType.init(inst, def);
|
|
2241
2251
|
inst._zod.optin = "optional";
|
|
@@ -2249,7 +2259,10 @@ const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
|
|
|
2249
2259
|
});
|
|
2250
2260
|
inst._zod.parse = (payload, ctx) => {
|
|
2251
2261
|
if (def.innerType._zod.optin === "optional") {
|
|
2252
|
-
|
|
2262
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2263
|
+
if (result instanceof Promise)
|
|
2264
|
+
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
2265
|
+
return handleOptionalResult(result, payload.value);
|
|
2253
2266
|
}
|
|
2254
2267
|
if (payload.value === undefined) {
|
|
2255
2268
|
return payload;
|
|
@@ -2338,7 +2351,7 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
2338
2351
|
}
|
|
2339
2352
|
const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
|
|
2340
2353
|
$ZodType.init(inst, def);
|
|
2341
|
-
inst._zod
|
|
2354
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
2342
2355
|
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
2343
2356
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2344
2357
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -2388,7 +2401,7 @@ const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
|
|
|
2388
2401
|
};
|
|
2389
2402
|
});
|
|
2390
2403
|
function handlePipeResult(left, def, ctx) {
|
|
2391
|
-
if (
|
|
2404
|
+
if (left.issues.length) {
|
|
2392
2405
|
return left;
|
|
2393
2406
|
}
|
|
2394
2407
|
return def.out._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
@@ -2479,7 +2492,8 @@ class $ZodRegistry {
|
|
|
2479
2492
|
if (p) {
|
|
2480
2493
|
const pm = { ...(this.get(p) ?? {}) };
|
|
2481
2494
|
delete pm.id; // do not inherit id
|
|
2482
|
-
|
|
2495
|
+
const f = { ...pm, ...this._map.get(schema) };
|
|
2496
|
+
return Object.keys(f).length ? f : undefined;
|
|
2483
2497
|
}
|
|
2484
2498
|
return this._map.get(schema);
|
|
2485
2499
|
}
|
|
@@ -2946,13 +2960,6 @@ function _custom(Class, fn, _params) {
|
|
|
2946
2960
|
});
|
|
2947
2961
|
return schema;
|
|
2948
2962
|
}
|
|
2949
|
-
// export function _refine<T>(
|
|
2950
|
-
// Class: util.SchemaClass<schemas.$ZodCustom>,
|
|
2951
|
-
// fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>,
|
|
2952
|
-
// _params: string | $ZodCustomParams = {}
|
|
2953
|
-
// ): checks.$ZodCheck<T> {
|
|
2954
|
-
// return _custom(Class, fn, _params);
|
|
2955
|
-
// }
|
|
2956
2963
|
// same as _custom but defaults to abort:false
|
|
2957
2964
|
function _refine(Class, fn, _params) {
|
|
2958
2965
|
const schema = new Class({
|
|
@@ -2963,6 +2970,36 @@ function _refine(Class, fn, _params) {
|
|
|
2963
2970
|
});
|
|
2964
2971
|
return schema;
|
|
2965
2972
|
}
|
|
2973
|
+
function _superRefine(fn) {
|
|
2974
|
+
const ch = _check((payload) => {
|
|
2975
|
+
payload.addIssue = (issue$1) => {
|
|
2976
|
+
if (typeof issue$1 === "string") {
|
|
2977
|
+
payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
|
|
2978
|
+
}
|
|
2979
|
+
else {
|
|
2980
|
+
// for Zod 3 backwards compatibility
|
|
2981
|
+
const _issue = issue$1;
|
|
2982
|
+
if (_issue.fatal)
|
|
2983
|
+
_issue.continue = false;
|
|
2984
|
+
_issue.code ?? (_issue.code = "custom");
|
|
2985
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
2986
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
2987
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
2988
|
+
payload.issues.push(issue(_issue));
|
|
2989
|
+
}
|
|
2990
|
+
};
|
|
2991
|
+
return fn(payload.value, payload);
|
|
2992
|
+
});
|
|
2993
|
+
return ch;
|
|
2994
|
+
}
|
|
2995
|
+
function _check(fn, params) {
|
|
2996
|
+
const ch = new $ZodCheck({
|
|
2997
|
+
check: "custom",
|
|
2998
|
+
...normalizeParams(params),
|
|
2999
|
+
});
|
|
3000
|
+
ch._zod.check = fn;
|
|
3001
|
+
return ch;
|
|
3002
|
+
}
|
|
2966
3003
|
function _stringbool(Classes, _params) {
|
|
2967
3004
|
const params = normalizeParams(_params);
|
|
2968
3005
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
@@ -2996,6 +3033,7 @@ function _stringbool(Classes, _params) {
|
|
|
2996
3033
|
values: [...truthySet, ...falsySet],
|
|
2997
3034
|
input: payload.value,
|
|
2998
3035
|
inst: tx,
|
|
3036
|
+
continue: false,
|
|
2999
3037
|
});
|
|
3000
3038
|
return {};
|
|
3001
3039
|
}
|
|
@@ -3063,11 +3101,17 @@ const initializer = (inst, issues) => {
|
|
|
3063
3101
|
// enumerable: false,
|
|
3064
3102
|
},
|
|
3065
3103
|
addIssue: {
|
|
3066
|
-
value: (issue) =>
|
|
3104
|
+
value: (issue) => {
|
|
3105
|
+
inst.issues.push(issue);
|
|
3106
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
3107
|
+
},
|
|
3067
3108
|
// enumerable: false,
|
|
3068
3109
|
},
|
|
3069
3110
|
addIssues: {
|
|
3070
|
-
value: (issues) =>
|
|
3111
|
+
value: (issues) => {
|
|
3112
|
+
inst.issues.push(...issues);
|
|
3113
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
3114
|
+
},
|
|
3071
3115
|
// enumerable: false,
|
|
3072
3116
|
},
|
|
3073
3117
|
isEmpty: {
|
|
@@ -3430,7 +3474,6 @@ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
|
3430
3474
|
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
3431
3475
|
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall });
|
|
3432
3476
|
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
3433
|
-
// inst.nonstrict = () => inst.clone({ ...inst._zod.def, catchall: api.unknown() });
|
|
3434
3477
|
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
3435
3478
|
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
|
3436
3479
|
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
|
|
@@ -3447,7 +3490,7 @@ function object(shape, params) {
|
|
|
3447
3490
|
const def = {
|
|
3448
3491
|
type: "object",
|
|
3449
3492
|
get shape() {
|
|
3450
|
-
assignProp(this, "shape",
|
|
3493
|
+
assignProp(this, "shape", shape ? objectClone(shape) : {});
|
|
3451
3494
|
return this.shape;
|
|
3452
3495
|
},
|
|
3453
3496
|
...normalizeParams(params),
|
|
@@ -3459,7 +3502,7 @@ function looseObject(shape, params) {
|
|
|
3459
3502
|
return new ZodObject({
|
|
3460
3503
|
type: "object",
|
|
3461
3504
|
get shape() {
|
|
3462
|
-
assignProp(this, "shape",
|
|
3505
|
+
assignProp(this, "shape", objectClone(shape));
|
|
3463
3506
|
return this.shape;
|
|
3464
3507
|
},
|
|
3465
3508
|
catchall: unknown(),
|
|
@@ -3505,9 +3548,11 @@ function record(keyType, valueType, params) {
|
|
|
3505
3548
|
}
|
|
3506
3549
|
// type alksjf = core.output<core.$ZodRecordKey>;
|
|
3507
3550
|
function partialRecord(keyType, valueType, params) {
|
|
3551
|
+
const k = clone(keyType);
|
|
3552
|
+
k._zod.values = undefined;
|
|
3508
3553
|
return new ZodRecord({
|
|
3509
3554
|
type: "record",
|
|
3510
|
-
keyType:
|
|
3555
|
+
keyType: k,
|
|
3511
3556
|
valueType: valueType,
|
|
3512
3557
|
...normalizeParams(params),
|
|
3513
3558
|
});
|
|
@@ -3595,7 +3640,7 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
|
3595
3640
|
_issue.code ?? (_issue.code = "custom");
|
|
3596
3641
|
_issue.input ?? (_issue.input = payload.value);
|
|
3597
3642
|
_issue.inst ?? (_issue.inst = inst);
|
|
3598
|
-
|
|
3643
|
+
// _issue.continue ??= true;
|
|
3599
3644
|
payload.issues.push(issue(_issue));
|
|
3600
3645
|
}
|
|
3601
3646
|
};
|
|
@@ -3649,7 +3694,7 @@ function _default(innerType, defaultValue) {
|
|
|
3649
3694
|
type: "default",
|
|
3650
3695
|
innerType: innerType,
|
|
3651
3696
|
get defaultValue() {
|
|
3652
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
3697
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
3653
3698
|
},
|
|
3654
3699
|
});
|
|
3655
3700
|
}
|
|
@@ -3663,7 +3708,7 @@ function prefault(innerType, defaultValue) {
|
|
|
3663
3708
|
type: "prefault",
|
|
3664
3709
|
innerType: innerType,
|
|
3665
3710
|
get defaultValue() {
|
|
3666
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
3711
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
3667
3712
|
},
|
|
3668
3713
|
});
|
|
3669
3714
|
}
|
|
@@ -3709,6 +3754,7 @@ function pipe(in_, out) {
|
|
|
3709
3754
|
const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
|
|
3710
3755
|
$ZodReadonly.init(inst, def);
|
|
3711
3756
|
ZodType.init(inst, def);
|
|
3757
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3712
3758
|
});
|
|
3713
3759
|
function readonly(innerType) {
|
|
3714
3760
|
return new ZodReadonly({
|
|
@@ -3720,15 +3766,6 @@ const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
|
|
|
3720
3766
|
$ZodCustom.init(inst, def);
|
|
3721
3767
|
ZodType.init(inst, def);
|
|
3722
3768
|
});
|
|
3723
|
-
// custom checks
|
|
3724
|
-
function check(fn) {
|
|
3725
|
-
const ch = new $ZodCheck({
|
|
3726
|
-
check: "custom",
|
|
3727
|
-
// ...util.normalizeParams(params),
|
|
3728
|
-
});
|
|
3729
|
-
ch._zod.check = fn;
|
|
3730
|
-
return ch;
|
|
3731
|
-
}
|
|
3732
3769
|
function custom(fn, _params) {
|
|
3733
3770
|
return _custom(ZodCustom, fn ?? (() => true), _params);
|
|
3734
3771
|
}
|
|
@@ -3737,26 +3774,7 @@ function refine(fn, _params = {}) {
|
|
|
3737
3774
|
}
|
|
3738
3775
|
// superRefine
|
|
3739
3776
|
function superRefine(fn) {
|
|
3740
|
-
|
|
3741
|
-
payload.addIssue = (issue$1) => {
|
|
3742
|
-
if (typeof issue$1 === "string") {
|
|
3743
|
-
payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
|
|
3744
|
-
}
|
|
3745
|
-
else {
|
|
3746
|
-
// for Zod 3 backwards compatibility
|
|
3747
|
-
const _issue = issue$1;
|
|
3748
|
-
if (_issue.fatal)
|
|
3749
|
-
_issue.continue = false;
|
|
3750
|
-
_issue.code ?? (_issue.code = "custom");
|
|
3751
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
3752
|
-
_issue.inst ?? (_issue.inst = ch);
|
|
3753
|
-
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
3754
|
-
payload.issues.push(issue(_issue));
|
|
3755
|
-
}
|
|
3756
|
-
};
|
|
3757
|
-
return fn(payload.value, payload);
|
|
3758
|
-
});
|
|
3759
|
-
return ch;
|
|
3777
|
+
return _superRefine(fn);
|
|
3760
3778
|
}
|
|
3761
3779
|
// stringbool
|
|
3762
3780
|
const stringbool = (...args) => _stringbool({
|
|
@@ -4936,5 +4954,5 @@ _Mime_extensionToType = new WeakMap(), _Mime_typeToExtension = new WeakMap(), _M
|
|
|
4936
4954
|
|
|
4937
4955
|
new Mime(types, types$1)._freeze();
|
|
4938
4956
|
|
|
4939
|
-
export { $ZodUnknown as $, _unknown as _, _tuple as a, _array as b, $ZodArray as c, $ZodTuple as d, parseAsync$1 as e, any as f, array as g, _enum as h, email as i, boolean as j, custom as k, literal as l, looseObject as m, number as n, object as o, parse$1 as p, partialRecord as q, record as r, string as s, prettifyError as t, uuid as u,
|
|
4940
|
-
//# sourceMappingURL=index-
|
|
4957
|
+
export { $ZodUnknown as $, _unknown as _, _tuple as a, _array as b, $ZodArray as c, $ZodTuple as d, parseAsync$1 as e, any as f, array as g, _enum as h, email as i, boolean as j, custom as k, literal as l, looseObject as m, number as n, object as o, parse$1 as p, partialRecord as q, record as r, string as s, prettifyError as t, uuid as u, $ZodError as v, stringbool as w, date as x, url as y };
|
|
4958
|
+
//# sourceMappingURL=index-wXTeP1jh.js.map
|