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