@brainervirus/workit-pi 2.1.3 → 2.1.5
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/dist/worker.js +724 -473
- package/dist/workit.js +1331 -1085
- package/package.json +1 -1
package/dist/worker.js
CHANGED
|
@@ -19,18 +19,23 @@ function jsonStringifyReplacer(_, value) {
|
|
|
19
19
|
return value.toString();
|
|
20
20
|
return value;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
|
|
23
|
+
class Cached {
|
|
24
|
+
constructor(getter) {
|
|
25
|
+
this._getter = getter;
|
|
26
|
+
this._value = undefined;
|
|
27
|
+
}
|
|
28
|
+
get value() {
|
|
29
|
+
const getter = this._getter;
|
|
30
|
+
if (getter !== undefined) {
|
|
31
|
+
this._value = getter();
|
|
32
|
+
this._getter = undefined;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
return this._value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function cached(getter) {
|
|
38
|
+
return new Cached(getter);
|
|
34
39
|
}
|
|
35
40
|
function nullish(input) {
|
|
36
41
|
return input === null || input === undefined;
|
|
@@ -56,6 +61,56 @@ function assignProp(target, prop, value) {
|
|
|
56
61
|
configurable: true
|
|
57
62
|
});
|
|
58
63
|
}
|
|
64
|
+
function rawShape(def) {
|
|
65
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
66
|
+
return desc?.get ? desc.get.raw : desc?.value;
|
|
67
|
+
}
|
|
68
|
+
function sourceShape(schema) {
|
|
69
|
+
return rawShape(schema._zod.def) ?? schema._zod.def.shape;
|
|
70
|
+
}
|
|
71
|
+
function deferProp(target, key, getter) {
|
|
72
|
+
Object.defineProperty(target, key, {
|
|
73
|
+
get() {
|
|
74
|
+
const value = getter();
|
|
75
|
+
assignProp(this, key, value);
|
|
76
|
+
return value;
|
|
77
|
+
},
|
|
78
|
+
enumerable: true,
|
|
79
|
+
configurable: true
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function putProp(target, key, value) {
|
|
83
|
+
if (key in target)
|
|
84
|
+
assignProp(target, key, value);
|
|
85
|
+
else
|
|
86
|
+
target[key] = value;
|
|
87
|
+
}
|
|
88
|
+
function mirrorShape(target, source, keys, wrap) {
|
|
89
|
+
const raw = sourceShape(source);
|
|
90
|
+
for (const key of keys) {
|
|
91
|
+
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
92
|
+
if (!desc.enumerable)
|
|
93
|
+
continue;
|
|
94
|
+
if (desc.get) {
|
|
95
|
+
deferProp(target, key, () => {
|
|
96
|
+
const value = source._zod.def.shape[key];
|
|
97
|
+
return wrap ? wrap(value, key) : value;
|
|
98
|
+
});
|
|
99
|
+
} else
|
|
100
|
+
putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function mirrorProps(target, source) {
|
|
104
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
105
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
106
|
+
if (!desc.enumerable)
|
|
107
|
+
continue;
|
|
108
|
+
if (desc.get)
|
|
109
|
+
deferProp(target, key, () => source[key]);
|
|
110
|
+
else
|
|
111
|
+
putProp(target, key, desc.value);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
59
114
|
function mergeDefs(...defs) {
|
|
60
115
|
const mergedDescriptors = {};
|
|
61
116
|
for (const def of defs) {
|
|
@@ -161,6 +216,10 @@ var NUMBER_FORMAT_RANGES = /* @__PURE__ */ (() => ({
|
|
|
161
216
|
float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000],
|
|
162
217
|
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
163
218
|
}))();
|
|
219
|
+
var BIGINT_FORMAT_RANGES = {
|
|
220
|
+
int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
|
|
221
|
+
uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
|
|
222
|
+
};
|
|
164
223
|
function pick(schema, mask) {
|
|
165
224
|
const currDef = schema._zod.def;
|
|
166
225
|
const checks = currDef.checks;
|
|
@@ -168,23 +227,21 @@ function pick(schema, mask) {
|
|
|
168
227
|
if (hasChecks) {
|
|
169
228
|
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
170
229
|
}
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
});
|
|
187
|
-
return clone(schema, def);
|
|
230
|
+
const newShape = {};
|
|
231
|
+
mirrorShape(newShape, schema, maskedKeys(schema, mask));
|
|
232
|
+
return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
233
|
+
}
|
|
234
|
+
function maskedKeys(schema, mask) {
|
|
235
|
+
const raw = sourceShape(schema);
|
|
236
|
+
const keys = [];
|
|
237
|
+
for (const key of Reflect.ownKeys(mask)) {
|
|
238
|
+
if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) {
|
|
239
|
+
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
240
|
+
}
|
|
241
|
+
if (mask[key])
|
|
242
|
+
keys.push(key);
|
|
243
|
+
}
|
|
244
|
+
return keys;
|
|
188
245
|
}
|
|
189
246
|
function omit(schema, mask) {
|
|
190
247
|
const currDef = schema._zod.def;
|
|
@@ -193,23 +250,10 @@ function omit(schema, mask) {
|
|
|
193
250
|
if (hasChecks) {
|
|
194
251
|
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
195
252
|
}
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) {
|
|
201
|
-
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
202
|
-
}
|
|
203
|
-
if (!mask[key])
|
|
204
|
-
continue;
|
|
205
|
-
delete newShape[key];
|
|
206
|
-
}
|
|
207
|
-
assignProp(this, "shape", newShape);
|
|
208
|
-
return newShape;
|
|
209
|
-
},
|
|
210
|
-
checks: []
|
|
211
|
-
});
|
|
212
|
-
return clone(schema, def);
|
|
253
|
+
const omitted = new Set(maskedKeys(schema, mask));
|
|
254
|
+
const newShape = {};
|
|
255
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
|
|
256
|
+
return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
213
257
|
}
|
|
214
258
|
function extend(schema, shape) {
|
|
215
259
|
if (!isPlainObject(shape)) {
|
|
@@ -218,34 +262,26 @@ function extend(schema, shape) {
|
|
|
218
262
|
const checks = schema._zod.def.checks;
|
|
219
263
|
const hasChecks = checks && checks.length > 0;
|
|
220
264
|
if (hasChecks) {
|
|
221
|
-
const existingShape = schema
|
|
265
|
+
const existingShape = sourceShape(schema);
|
|
222
266
|
for (const key of Reflect.ownKeys(shape)) {
|
|
223
267
|
if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
|
|
224
268
|
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
225
269
|
}
|
|
226
270
|
}
|
|
227
271
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return clone(schema, def);
|
|
272
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
273
|
+
}
|
|
274
|
+
function extended(schema, shape) {
|
|
275
|
+
const newShape = {};
|
|
276
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
|
|
277
|
+
mirrorProps(newShape, shape);
|
|
278
|
+
return newShape;
|
|
236
279
|
}
|
|
237
280
|
function safeExtend(schema, shape) {
|
|
238
281
|
if (!isPlainObject(shape)) {
|
|
239
282
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
240
283
|
}
|
|
241
|
-
|
|
242
|
-
get shape() {
|
|
243
|
-
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
244
|
-
assignProp(this, "shape", _shape);
|
|
245
|
-
return _shape;
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
return clone(schema, def);
|
|
284
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
249
285
|
}
|
|
250
286
|
function merge(a, b) {
|
|
251
287
|
if (!b?._zod?.def) {
|
|
@@ -254,12 +290,11 @@ function merge(a, b) {
|
|
|
254
290
|
if (a._zod.def.checks?.length) {
|
|
255
291
|
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
256
292
|
}
|
|
293
|
+
const newShape = {};
|
|
294
|
+
mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
|
|
295
|
+
mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
|
|
257
296
|
const def = mergeDefs(a._zod.def, {
|
|
258
|
-
|
|
259
|
-
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
260
|
-
assignProp(this, "shape", _shape);
|
|
261
|
-
return _shape;
|
|
262
|
-
},
|
|
297
|
+
shape: newShape,
|
|
263
298
|
get catchall() {
|
|
264
299
|
return b._zod.def.catchall;
|
|
265
300
|
},
|
|
@@ -274,67 +309,16 @@ function partial(Class, schema, mask, name = "partial") {
|
|
|
274
309
|
if (hasChecks) {
|
|
275
310
|
throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
|
|
276
311
|
}
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
if (mask) {
|
|
282
|
-
for (const key of Reflect.ownKeys(mask)) {
|
|
283
|
-
if (!Object.prototype.hasOwnProperty.call(oldShape, key)) {
|
|
284
|
-
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
285
|
-
}
|
|
286
|
-
if (!mask[key])
|
|
287
|
-
continue;
|
|
288
|
-
shape[key] = Class ? new Class({
|
|
289
|
-
type: "optional",
|
|
290
|
-
innerType: oldShape[key]
|
|
291
|
-
}) : oldShape[key];
|
|
292
|
-
}
|
|
293
|
-
} else {
|
|
294
|
-
for (const key of Reflect.ownKeys(oldShape)) {
|
|
295
|
-
shape[key] = Class ? new Class({
|
|
296
|
-
type: "optional",
|
|
297
|
-
innerType: oldShape[key]
|
|
298
|
-
}) : oldShape[key];
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
assignProp(this, "shape", shape);
|
|
302
|
-
return shape;
|
|
303
|
-
},
|
|
304
|
-
checks: []
|
|
305
|
-
});
|
|
306
|
-
return clone(schema, def);
|
|
312
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;
|
|
313
|
+
const newShape = {};
|
|
314
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({ type: "optional", innerType: value })));
|
|
315
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: newShape, checks: [] }));
|
|
307
316
|
}
|
|
308
317
|
function required(Class, schema, mask) {
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if (mask) {
|
|
314
|
-
for (const key of Reflect.ownKeys(mask)) {
|
|
315
|
-
if (!Object.prototype.hasOwnProperty.call(shape, key)) {
|
|
316
|
-
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
317
|
-
}
|
|
318
|
-
if (!mask[key])
|
|
319
|
-
continue;
|
|
320
|
-
shape[key] = new Class({
|
|
321
|
-
type: "nonoptional",
|
|
322
|
-
innerType: oldShape[key]
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
} else {
|
|
326
|
-
for (const key of Reflect.ownKeys(oldShape)) {
|
|
327
|
-
shape[key] = new Class({
|
|
328
|
-
type: "nonoptional",
|
|
329
|
-
innerType: oldShape[key]
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
assignProp(this, "shape", shape);
|
|
334
|
-
return shape;
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
return clone(schema, def);
|
|
318
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;
|
|
319
|
+
const newShape = {};
|
|
320
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({ type: "nonoptional", innerType: value }));
|
|
321
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
|
|
338
322
|
}
|
|
339
323
|
function aborted(x, startIndex = 0) {
|
|
340
324
|
if (x.aborted === true)
|
|
@@ -384,13 +368,18 @@ function finalizeIssue(iss, ctx, config) {
|
|
|
384
368
|
}
|
|
385
369
|
const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : undefined;
|
|
386
370
|
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
|
387
|
-
const
|
|
388
|
-
|
|
389
|
-
|
|
371
|
+
const full = {};
|
|
372
|
+
for (const k of Object.keys(iss)) {
|
|
373
|
+
if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__")
|
|
374
|
+
continue;
|
|
375
|
+
full[k] = iss[k];
|
|
376
|
+
}
|
|
377
|
+
full.path ?? (full.path = []);
|
|
378
|
+
full.message = message;
|
|
390
379
|
if (ctx?.reportInput) {
|
|
391
|
-
|
|
380
|
+
full.input = iss.input;
|
|
392
381
|
}
|
|
393
|
-
return
|
|
382
|
+
return full;
|
|
394
383
|
}
|
|
395
384
|
var highSurrogate = /[\uD800-\uDBFF]/;
|
|
396
385
|
function codePointLength(str) {
|
|
@@ -462,6 +451,22 @@ function own(inst, key, value, enumerable = true) {
|
|
|
462
451
|
function hide(inst, key, value) {
|
|
463
452
|
return own(inst, key, value, false);
|
|
464
453
|
}
|
|
454
|
+
function derived(computes, table) {
|
|
455
|
+
for (const key in computes) {
|
|
456
|
+
const compute = computes[key];
|
|
457
|
+
Object.defineProperty(table, key, {
|
|
458
|
+
configurable: true,
|
|
459
|
+
enumerable: true,
|
|
460
|
+
get() {
|
|
461
|
+
return own(this, key, compute(this));
|
|
462
|
+
},
|
|
463
|
+
set(value) {
|
|
464
|
+
own(this, key, value);
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
return table;
|
|
469
|
+
}
|
|
465
470
|
function defineBound(proto, key, fn) {
|
|
466
471
|
Object.defineProperty(proto, key, {
|
|
467
472
|
configurable: true,
|
|
@@ -585,8 +590,7 @@ function $constructor(name, initializer, proto, params) {
|
|
|
585
590
|
} finally {
|
|
586
591
|
_zodDesc.value = undefined;
|
|
587
592
|
}
|
|
588
|
-
}
|
|
589
|
-
if (inst._zod.traits.has(name)) {
|
|
593
|
+
} else if (inst._zod.traits.has(name)) {
|
|
590
594
|
return;
|
|
591
595
|
}
|
|
592
596
|
inst._zod.traits.add(name);
|
|
@@ -677,16 +681,12 @@ var _messageDesc = {
|
|
|
677
681
|
enumerable: true,
|
|
678
682
|
configurable: true
|
|
679
683
|
};
|
|
680
|
-
var _zodDesc2 = { value: undefined, enumerable: false };
|
|
681
684
|
var _issuesDesc = { value: undefined, enumerable: false };
|
|
682
685
|
var _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
683
686
|
var initializer = (inst, def) => {
|
|
684
687
|
inst.name = "$ZodError";
|
|
685
|
-
_zodDesc2.value = inst._zod;
|
|
686
|
-
Object.defineProperty(inst, "_zod", _zodDesc2);
|
|
687
688
|
_issuesDesc.value = def;
|
|
688
689
|
Object.defineProperty(inst, "issues", _issuesDesc);
|
|
689
|
-
_zodDesc2.value = undefined;
|
|
690
690
|
_issuesDesc.value = undefined;
|
|
691
691
|
Object.defineProperty(inst, "message", _messageDesc);
|
|
692
692
|
const proto = Object.getPrototypeOf(inst);
|
|
@@ -822,23 +822,68 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
|
822
822
|
if (result instanceof Promise) {
|
|
823
823
|
throw new $ZodAsyncError;
|
|
824
824
|
}
|
|
825
|
-
return result.issues.length ? {
|
|
826
|
-
success: false,
|
|
827
|
-
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
828
|
-
} : { success: true, data: result.value };
|
|
825
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
|
|
829
826
|
};
|
|
830
|
-
|
|
827
|
+
function failure(Err, issues, ctx) {
|
|
828
|
+
let error;
|
|
829
|
+
return {
|
|
830
|
+
success: false,
|
|
831
|
+
get error() {
|
|
832
|
+
if (!error) {
|
|
833
|
+
error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
834
|
+
issues = undefined;
|
|
835
|
+
ctx = undefined;
|
|
836
|
+
}
|
|
837
|
+
return error;
|
|
838
|
+
},
|
|
839
|
+
set error(e) {
|
|
840
|
+
error = e;
|
|
841
|
+
issues = undefined;
|
|
842
|
+
ctx = undefined;
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
}
|
|
831
846
|
var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
832
847
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
833
848
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
834
849
|
if (result instanceof Promise)
|
|
835
850
|
result = await result;
|
|
836
|
-
return result.issues.length ? {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
851
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
|
|
852
|
+
};
|
|
853
|
+
var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
|
|
854
|
+
var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
|
|
855
|
+
var validate = (schema, value, _ctx) => {
|
|
856
|
+
const validator = schema._zod.bag.validator;
|
|
857
|
+
if (validator !== undefined) {
|
|
858
|
+
if (validator(value) !== COMPILE_INVALID)
|
|
859
|
+
return true;
|
|
860
|
+
if (validator.definite === true && _ctx === undefined)
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
return validateFallback(schema, value, _ctx);
|
|
864
|
+
};
|
|
865
|
+
function validateFallback(schema, value, _ctx) {
|
|
866
|
+
const ctx = _ctx ? { ..._ctx, async: false, abortEarly: true } : { async: false, abortEarly: true };
|
|
867
|
+
const fallbackRun = schema._zod.bag.fallbackRun;
|
|
868
|
+
let result;
|
|
869
|
+
if (fallbackRun) {
|
|
870
|
+
ctx[COMPILE_FALLBACK] = true;
|
|
871
|
+
result = fallbackRun({ value, issues: [] }, ctx);
|
|
872
|
+
} else {
|
|
873
|
+
result = schema._zod.run({ value, issues: [] }, ctx);
|
|
874
|
+
}
|
|
875
|
+
if (result instanceof Promise) {
|
|
876
|
+
throw new $ZodAsyncError;
|
|
877
|
+
}
|
|
878
|
+
return result.issues.length === 0;
|
|
879
|
+
}
|
|
880
|
+
var validateAsync = async (schema, value, _ctx) => {
|
|
881
|
+
const ctx = _ctx ? { ..._ctx, async: true, abortEarly: true } : { async: true, abortEarly: true };
|
|
882
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
883
|
+
if (result instanceof Promise)
|
|
884
|
+
result = await result;
|
|
885
|
+
return result.issues.length === 0;
|
|
840
886
|
};
|
|
841
|
-
var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
842
887
|
var _encode = (_Err) => {
|
|
843
888
|
const parse = _parse(_Err);
|
|
844
889
|
const fn = (schema, value, _ctx, _params) => {
|
|
@@ -900,8 +945,8 @@ var uuid = (version) => {
|
|
|
900
945
|
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
901
946
|
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
902
947
|
};
|
|
903
|
-
var email = /^(
|
|
904
|
-
var _emoji = `^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
948
|
+
var email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
949
|
+
var _emoji = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
905
950
|
function emoji() {
|
|
906
951
|
return new RegExp(_emoji, "u");
|
|
907
952
|
}
|
|
@@ -910,10 +955,11 @@ var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|(
|
|
|
910
955
|
var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
911
956
|
var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
912
957
|
var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
913
|
-
var base64url = /^[A-Za-z0-9_-]
|
|
958
|
+
var base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
|
|
914
959
|
var httpProtocol = /^https?$/;
|
|
915
960
|
var e164 = /^\+[1-9]\d{6,14}$/;
|
|
916
961
|
var creditCard = /^\d(?:[ -]?\d){11,18}$/;
|
|
962
|
+
var iban = /^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/;
|
|
917
963
|
var 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])))`;
|
|
918
964
|
function anchor(source) {
|
|
919
965
|
return new RegExp(`^${source}$`);
|
|
@@ -935,10 +981,7 @@ function datetime(args) {
|
|
|
935
981
|
const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
|
|
936
982
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
937
983
|
}
|
|
938
|
-
var
|
|
939
|
-
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
940
|
-
return new RegExp(`^${regex}$`);
|
|
941
|
-
};
|
|
984
|
+
var anyString = /^[\s\S]{0,}$/;
|
|
942
985
|
var integer = /^-?\d+$/;
|
|
943
986
|
var number = /^-?\d+(?:\.\d+)?$/;
|
|
944
987
|
var boolean = /^(?:true|false)$/i;
|
|
@@ -964,16 +1007,6 @@ var numericOriginMap = {
|
|
|
964
1007
|
var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
965
1008
|
$ZodCheck.init(inst, def);
|
|
966
1009
|
const origin = numericOriginMap[typeof def.value];
|
|
967
|
-
inst._zod.onattach.push((inst) => {
|
|
968
|
-
const bag = inst._zod.bag;
|
|
969
|
-
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
970
|
-
if (def.value < curr) {
|
|
971
|
-
if (def.inclusive)
|
|
972
|
-
bag.maximum = def.value;
|
|
973
|
-
else
|
|
974
|
-
bag.exclusiveMaximum = def.value;
|
|
975
|
-
}
|
|
976
|
-
});
|
|
977
1010
|
inst._zod.check = (payload) => {
|
|
978
1011
|
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
|
|
979
1012
|
return;
|
|
@@ -992,16 +1025,6 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
|
|
|
992
1025
|
var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
993
1026
|
$ZodCheck.init(inst, def);
|
|
994
1027
|
const origin = numericOriginMap[typeof def.value];
|
|
995
|
-
inst._zod.onattach.push((inst) => {
|
|
996
|
-
const bag = inst._zod.bag;
|
|
997
|
-
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
998
|
-
if (def.value > curr) {
|
|
999
|
-
if (def.inclusive)
|
|
1000
|
-
bag.minimum = def.value;
|
|
1001
|
-
else
|
|
1002
|
-
bag.exclusiveMinimum = def.value;
|
|
1003
|
-
}
|
|
1004
|
-
});
|
|
1005
1028
|
inst._zod.check = (payload) => {
|
|
1006
1029
|
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
|
|
1007
1030
|
return;
|
|
@@ -1019,10 +1042,6 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
|
|
|
1019
1042
|
});
|
|
1020
1043
|
var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
1021
1044
|
$ZodCheck.init(inst, def);
|
|
1022
|
-
inst._zod.onattach.push((inst) => {
|
|
1023
|
-
var _a;
|
|
1024
|
-
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
|
1025
|
-
});
|
|
1026
1045
|
inst._zod.check = (payload) => {
|
|
1027
1046
|
if (typeof payload.value !== typeof def.value)
|
|
1028
1047
|
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
@@ -1045,14 +1064,6 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
1045
1064
|
const isInt = def.format?.includes("int");
|
|
1046
1065
|
const origin = isInt ? "int" : "number";
|
|
1047
1066
|
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
1048
|
-
inst._zod.onattach.push((inst) => {
|
|
1049
|
-
const bag = inst._zod.bag;
|
|
1050
|
-
bag.format = def.format;
|
|
1051
|
-
bag.minimum = minimum;
|
|
1052
|
-
bag.maximum = maximum;
|
|
1053
|
-
if (isInt)
|
|
1054
|
-
bag.pattern = integer;
|
|
1055
|
-
});
|
|
1056
1067
|
inst._zod.check = (payload) => {
|
|
1057
1068
|
const input = payload.value;
|
|
1058
1069
|
if (isInt) {
|
|
@@ -1122,11 +1133,6 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
|
|
|
1122
1133
|
var _a;
|
|
1123
1134
|
$ZodCheck.init(inst, def);
|
|
1124
1135
|
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
1125
|
-
inst._zod.onattach.push((inst) => {
|
|
1126
|
-
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
1127
|
-
if (def.maximum < curr)
|
|
1128
|
-
inst._zod.bag.maximum = def.maximum;
|
|
1129
|
-
});
|
|
1130
1136
|
inst._zod.check = (payload) => {
|
|
1131
1137
|
const input = payload.value;
|
|
1132
1138
|
const units = input.length;
|
|
@@ -1149,11 +1155,6 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
|
|
|
1149
1155
|
var _a;
|
|
1150
1156
|
$ZodCheck.init(inst, def);
|
|
1151
1157
|
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
1152
|
-
inst._zod.onattach.push((inst) => {
|
|
1153
|
-
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
1154
|
-
if (def.minimum > curr)
|
|
1155
|
-
inst._zod.bag.minimum = def.minimum;
|
|
1156
|
-
});
|
|
1157
1158
|
inst._zod.check = (payload) => {
|
|
1158
1159
|
const input = payload.value;
|
|
1159
1160
|
const units = input.length;
|
|
@@ -1176,12 +1177,6 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
|
|
|
1176
1177
|
var _a;
|
|
1177
1178
|
$ZodCheck.init(inst, def);
|
|
1178
1179
|
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
1179
|
-
inst._zod.onattach.push((inst) => {
|
|
1180
|
-
const bag = inst._zod.bag;
|
|
1181
|
-
bag.minimum = def.length;
|
|
1182
|
-
bag.maximum = def.length;
|
|
1183
|
-
bag.length = def.length;
|
|
1184
|
-
});
|
|
1185
1180
|
inst._zod.check = (payload) => {
|
|
1186
1181
|
const input = payload.value;
|
|
1187
1182
|
const units = input.length;
|
|
@@ -1204,14 +1199,6 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
|
|
|
1204
1199
|
var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
1205
1200
|
var _a, _b;
|
|
1206
1201
|
$ZodCheck.init(inst, def);
|
|
1207
|
-
inst._zod.onattach.push((inst) => {
|
|
1208
|
-
const bag = inst._zod.bag;
|
|
1209
|
-
bag.format = def.format;
|
|
1210
|
-
if (def.pattern) {
|
|
1211
|
-
bag.patterns ?? (bag.patterns = new Set);
|
|
1212
|
-
bag.patterns.add(def.pattern);
|
|
1213
|
-
}
|
|
1214
|
-
});
|
|
1215
1202
|
if (def.pattern)
|
|
1216
1203
|
(_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
1217
1204
|
def.pattern.lastIndex = 0;
|
|
@@ -1260,11 +1247,6 @@ var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst,
|
|
|
1260
1247
|
const escapedRegex = escapeRegex(def.includes);
|
|
1261
1248
|
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
|
|
1262
1249
|
def.pattern = pattern;
|
|
1263
|
-
inst._zod.onattach.push((inst) => {
|
|
1264
|
-
const bag = inst._zod.bag;
|
|
1265
|
-
bag.patterns ?? (bag.patterns = new Set);
|
|
1266
|
-
bag.patterns.add(pattern);
|
|
1267
|
-
});
|
|
1268
1250
|
inst._zod.check = (payload) => {
|
|
1269
1251
|
if (payload.value.includes(def.includes, def.position))
|
|
1270
1252
|
return;
|
|
@@ -1283,11 +1265,6 @@ var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (i
|
|
|
1283
1265
|
$ZodCheck.init(inst, def);
|
|
1284
1266
|
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
1285
1267
|
def.pattern ?? (def.pattern = pattern);
|
|
1286
|
-
inst._zod.onattach.push((inst) => {
|
|
1287
|
-
const bag = inst._zod.bag;
|
|
1288
|
-
bag.patterns ?? (bag.patterns = new Set);
|
|
1289
|
-
bag.patterns.add(pattern);
|
|
1290
|
-
});
|
|
1291
1268
|
inst._zod.check = (payload) => {
|
|
1292
1269
|
if (payload.value.startsWith(def.prefix))
|
|
1293
1270
|
return;
|
|
@@ -1306,11 +1283,6 @@ var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst,
|
|
|
1306
1283
|
$ZodCheck.init(inst, def);
|
|
1307
1284
|
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
1308
1285
|
def.pattern ?? (def.pattern = pattern);
|
|
1309
|
-
inst._zod.onattach.push((inst) => {
|
|
1310
|
-
const bag = inst._zod.bag;
|
|
1311
|
-
bag.patterns ?? (bag.patterns = new Set);
|
|
1312
|
-
bag.patterns.add(pattern);
|
|
1313
|
-
});
|
|
1314
1286
|
inst._zod.check = (payload) => {
|
|
1315
1287
|
if (payload.value.endsWith(def.suffix))
|
|
1316
1288
|
return;
|
|
@@ -1342,8 +1314,11 @@ class Doc {
|
|
|
1342
1314
|
}
|
|
1343
1315
|
indented(fn) {
|
|
1344
1316
|
this.indent += 1;
|
|
1345
|
-
|
|
1346
|
-
|
|
1317
|
+
try {
|
|
1318
|
+
fn(this);
|
|
1319
|
+
} finally {
|
|
1320
|
+
this.indent -= 1;
|
|
1321
|
+
}
|
|
1347
1322
|
}
|
|
1348
1323
|
write(arg) {
|
|
1349
1324
|
if (typeof arg === "function") {
|
|
@@ -1374,8 +1349,8 @@ ${content.join(`
|
|
|
1374
1349
|
// node_modules/zod/v4/core/versions.js
|
|
1375
1350
|
var version = {
|
|
1376
1351
|
major: 4,
|
|
1377
|
-
minor:
|
|
1378
|
-
patch:
|
|
1352
|
+
minor: 6,
|
|
1353
|
+
patch: 5
|
|
1379
1354
|
};
|
|
1380
1355
|
|
|
1381
1356
|
// node_modules/zod/v4/core/schemas.js
|
|
@@ -1487,15 +1462,21 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
1487
1462
|
own(this, "~standard", value);
|
|
1488
1463
|
}
|
|
1489
1464
|
});
|
|
1490
|
-
var toStandardResult = (r) => r.
|
|
1465
|
+
var toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
|
|
1466
|
+
async function validateAsync2(inst, value) {
|
|
1467
|
+
const ctx = { async: true };
|
|
1468
|
+
return toStandardResult(await inst._zod.run({ value, issues: [] }, ctx), ctx);
|
|
1469
|
+
}
|
|
1491
1470
|
function standardProps(inst) {
|
|
1492
1471
|
return {
|
|
1493
1472
|
validate: (value) => {
|
|
1473
|
+
const ctx = { async: false };
|
|
1494
1474
|
try {
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
}
|
|
1475
|
+
const r = inst._zod.run({ value, issues: [] }, ctx);
|
|
1476
|
+
if (!(r instanceof Promise))
|
|
1477
|
+
return toStandardResult(r, ctx);
|
|
1478
|
+
} catch (_) {}
|
|
1479
|
+
return validateAsync2(inst, value);
|
|
1499
1480
|
},
|
|
1500
1481
|
vendor: "zod",
|
|
1501
1482
|
version: 1
|
|
@@ -1503,7 +1484,7 @@ function standardProps(inst) {
|
|
|
1503
1484
|
}
|
|
1504
1485
|
var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
1505
1486
|
$ZodType.init(inst, def);
|
|
1506
|
-
inst._zod.pattern =
|
|
1487
|
+
inst._zod.pattern = def.pattern ?? anyString;
|
|
1507
1488
|
inst._zod.parse = (payload, _) => {
|
|
1508
1489
|
if (def.coerce)
|
|
1509
1490
|
try {
|
|
@@ -1554,11 +1535,32 @@ var $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
|
|
|
1554
1535
|
});
|
|
1555
1536
|
var URL_BAD_FORMAT = 1;
|
|
1556
1537
|
var URL_UNPARSEABLE = 2;
|
|
1538
|
+
function canParseURL(input) {
|
|
1539
|
+
try {
|
|
1540
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function")
|
|
1541
|
+
return URL.canParse(input);
|
|
1542
|
+
new URL(input);
|
|
1543
|
+
return true;
|
|
1544
|
+
} catch {
|
|
1545
|
+
return false;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
function validateURL(trimmed, def) {
|
|
1549
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
|
|
1550
|
+
return canParseURL(trimmed) || URL_UNPARSEABLE;
|
|
1551
|
+
}
|
|
1552
|
+
return parseURLObject(trimmed, def);
|
|
1553
|
+
}
|
|
1557
1554
|
function parseURLObject(trimmed, def) {
|
|
1558
1555
|
if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
|
|
1559
1556
|
return URL_BAD_FORMAT;
|
|
1560
1557
|
}
|
|
1561
1558
|
try {
|
|
1559
|
+
if (typeof URL !== "undefined") {
|
|
1560
|
+
const URLStatic = URL;
|
|
1561
|
+
if (typeof URLStatic.parse === "function")
|
|
1562
|
+
return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
|
|
1563
|
+
}
|
|
1562
1564
|
return new URL(trimmed);
|
|
1563
1565
|
} catch {
|
|
1564
1566
|
return URL_UNPARSEABLE;
|
|
@@ -1581,7 +1583,7 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
|
1581
1583
|
inst._zod.check = (payload) => {
|
|
1582
1584
|
try {
|
|
1583
1585
|
const trimmed = payload.value.trim();
|
|
1584
|
-
const url =
|
|
1586
|
+
const url = validateURL(trimmed, def);
|
|
1585
1587
|
if (url === URL_BAD_FORMAT) {
|
|
1586
1588
|
payload.issues.push({
|
|
1587
1589
|
code: "invalid_format",
|
|
@@ -1603,6 +1605,10 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
|
1603
1605
|
});
|
|
1604
1606
|
return;
|
|
1605
1607
|
}
|
|
1608
|
+
if (url === true) {
|
|
1609
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1606
1612
|
if (def.hostname && !urlHostnameOk(url, def.hostname)) {
|
|
1607
1613
|
payload.issues.push({
|
|
1608
1614
|
code: "invalid_format",
|
|
@@ -1671,12 +1677,6 @@ var $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
|
|
|
1671
1677
|
var $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
|
|
1672
1678
|
def.pattern ?? (def.pattern = datetime(def));
|
|
1673
1679
|
$ZodStringFormat.init(inst, def);
|
|
1674
|
-
if (def.local || def.precision === -1) {
|
|
1675
|
-
inst._zod.bag.laxFormat = true;
|
|
1676
|
-
inst._zod.onattach.push((s) => {
|
|
1677
|
-
s._zod.bag.laxFormat = true;
|
|
1678
|
-
});
|
|
1679
|
-
}
|
|
1680
1680
|
});
|
|
1681
1681
|
var $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
|
|
1682
1682
|
def.pattern ?? (def.pattern = date);
|
|
@@ -1693,23 +1693,16 @@ var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def
|
|
|
1693
1693
|
var $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
|
|
1694
1694
|
def.pattern ?? (def.pattern = ipv4);
|
|
1695
1695
|
$ZodStringFormat.init(inst, def);
|
|
1696
|
-
inst._zod.bag.format = `ipv4`;
|
|
1697
1696
|
});
|
|
1698
1697
|
var ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
1699
1698
|
function isValidIPv6(value) {
|
|
1700
1699
|
if (!ipv6Alphabet.test(value))
|
|
1701
1700
|
return false;
|
|
1702
|
-
|
|
1703
|
-
new URL(`http://[${value}]`);
|
|
1704
|
-
return true;
|
|
1705
|
-
} catch {
|
|
1706
|
-
return false;
|
|
1707
|
-
}
|
|
1701
|
+
return canParseURL(`http://[${value}]`);
|
|
1708
1702
|
}
|
|
1709
1703
|
var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
1710
1704
|
def.pattern ?? (def.pattern = ipv6);
|
|
1711
1705
|
$ZodStringFormat.init(inst, def);
|
|
1712
|
-
inst._zod.bag.format = `ipv6`;
|
|
1713
1706
|
inst._zod.check = (payload) => {
|
|
1714
1707
|
if (!isValidIPv6(payload.value)) {
|
|
1715
1708
|
payload.issues.push({
|
|
@@ -1769,10 +1762,10 @@ function isValidBase64(data) {
|
|
|
1769
1762
|
return false;
|
|
1770
1763
|
}
|
|
1771
1764
|
}
|
|
1765
|
+
var base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
1772
1766
|
var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
1773
|
-
def.pattern ?? (def.pattern =
|
|
1767
|
+
def.pattern ?? (def.pattern = base64Charset);
|
|
1774
1768
|
$ZodStringFormat.init(inst, def);
|
|
1775
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
1776
1769
|
inst._zod.check = (payload) => {
|
|
1777
1770
|
if (isValidBase64(payload.value))
|
|
1778
1771
|
return;
|
|
@@ -1785,17 +1778,17 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
|
1785
1778
|
});
|
|
1786
1779
|
};
|
|
1787
1780
|
});
|
|
1781
|
+
var base64urlCharset = /^[A-Za-z0-9_-]*$/;
|
|
1788
1782
|
function isValidBase64URL(data) {
|
|
1789
|
-
if (!
|
|
1783
|
+
if (!base64urlCharset.test(data))
|
|
1790
1784
|
return false;
|
|
1791
1785
|
const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
1792
1786
|
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
|
1793
1787
|
return isValidBase64(padded);
|
|
1794
1788
|
}
|
|
1795
1789
|
var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1796
|
-
def.pattern ?? (def.pattern =
|
|
1790
|
+
def.pattern ?? (def.pattern = base64urlCharset);
|
|
1797
1791
|
$ZodStringFormat.init(inst, def);
|
|
1798
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
1799
1792
|
inst._zod.check = (payload) => {
|
|
1800
1793
|
if (isValidBase64URL(payload.value))
|
|
1801
1794
|
return;
|
|
@@ -1818,7 +1811,7 @@ function isLuhnAlgo(digits) {
|
|
|
1818
1811
|
let bit = 1;
|
|
1819
1812
|
let sum = 0;
|
|
1820
1813
|
while (length) {
|
|
1821
|
-
const value =
|
|
1814
|
+
const value = digits.charCodeAt(--length) - 48;
|
|
1822
1815
|
bit ^= 1;
|
|
1823
1816
|
sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value] : value;
|
|
1824
1817
|
}
|
|
@@ -1829,6 +1822,24 @@ function isValidCreditCard(input) {
|
|
|
1829
1822
|
return false;
|
|
1830
1823
|
return isLuhnAlgo(input.replace(CC_SANITIZE, ""));
|
|
1831
1824
|
}
|
|
1825
|
+
function isIso7064Mod97(iban2) {
|
|
1826
|
+
let remainder = 0;
|
|
1827
|
+
const len = iban2.length;
|
|
1828
|
+
for (let i = 4;i < len; i++) {
|
|
1829
|
+
const code = iban2.charCodeAt(i);
|
|
1830
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
1831
|
+
}
|
|
1832
|
+
for (let i = 0;i < 4; i++) {
|
|
1833
|
+
const code = iban2.charCodeAt(i);
|
|
1834
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
1835
|
+
}
|
|
1836
|
+
return remainder === 1;
|
|
1837
|
+
}
|
|
1838
|
+
function isValidIBAN(input) {
|
|
1839
|
+
if (!iban.test(input))
|
|
1840
|
+
return false;
|
|
1841
|
+
return isIso7064Mod97(input);
|
|
1842
|
+
}
|
|
1832
1843
|
function isValidJWT(token, algorithm = null) {
|
|
1833
1844
|
try {
|
|
1834
1845
|
const tokensParts = token.split(".");
|
|
@@ -1865,7 +1876,7 @@ var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
|
1865
1876
|
});
|
|
1866
1877
|
var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
1867
1878
|
$ZodType.init(inst, def);
|
|
1868
|
-
inst._zod.pattern =
|
|
1879
|
+
inst._zod.pattern = number;
|
|
1869
1880
|
inst._zod.parse = (payload, _ctx) => {
|
|
1870
1881
|
if (def.coerce)
|
|
1871
1882
|
try {
|
|
@@ -1949,6 +1960,7 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
1949
1960
|
}
|
|
1950
1961
|
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
1951
1962
|
const proms = [];
|
|
1963
|
+
const abortEarly = ctx?.abortEarly;
|
|
1952
1964
|
for (let i = 0;i < input.length; i++) {
|
|
1953
1965
|
const item = input[i];
|
|
1954
1966
|
const result = def.element._zod.run({
|
|
@@ -1959,6 +1971,8 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
1959
1971
|
proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
1960
1972
|
} else {
|
|
1961
1973
|
handleArrayResult(result, payload, i);
|
|
1974
|
+
if (abortEarly && result.issues.length !== 0 && aborted(result))
|
|
1975
|
+
break;
|
|
1962
1976
|
}
|
|
1963
1977
|
}
|
|
1964
1978
|
if (proms.length) {
|
|
@@ -1991,7 +2005,7 @@ function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
|
1991
2005
|
return;
|
|
1992
2006
|
}
|
|
1993
2007
|
if (result.value === undefined) {
|
|
1994
|
-
if (isPresent) {
|
|
2008
|
+
if (isPresent || optin === "defaulted" && !isOptionalOut) {
|
|
1995
2009
|
final.value[key] = undefined;
|
|
1996
2010
|
}
|
|
1997
2011
|
} else {
|
|
@@ -2019,14 +2033,20 @@ function normalizeDef(def) {
|
|
|
2019
2033
|
optionalKeys: new Set(okeys)
|
|
2020
2034
|
};
|
|
2021
2035
|
}
|
|
2022
|
-
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
2036
|
+
function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
|
|
2023
2037
|
const unrecognized = [];
|
|
2024
2038
|
const keySet = def.keySet;
|
|
2025
2039
|
const _catchall = def.catchall._zod;
|
|
2026
2040
|
const t = _catchall.def.type;
|
|
2027
2041
|
const optin = _catchall.optin;
|
|
2028
2042
|
const optout = _catchall.optout;
|
|
2043
|
+
let seen = 0;
|
|
2029
2044
|
for (const key in input) {
|
|
2045
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
2046
|
+
if (aborted(payload, seen))
|
|
2047
|
+
break;
|
|
2048
|
+
seen = payload.issues.length;
|
|
2049
|
+
}
|
|
2030
2050
|
if (keySet.has(key))
|
|
2031
2051
|
continue;
|
|
2032
2052
|
if (key === "__proto__") {
|
|
@@ -2060,23 +2080,19 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
2060
2080
|
return payload;
|
|
2061
2081
|
});
|
|
2062
2082
|
}
|
|
2063
|
-
var propShapes = new WeakMap;
|
|
2064
2083
|
var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
2065
2084
|
$ZodType.init(inst, def);
|
|
2066
2085
|
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
return newSh;
|
|
2078
|
-
}
|
|
2079
|
-
});
|
|
2086
|
+
const sh = desc?.get ? desc.get.raw : def.shape ?? {};
|
|
2087
|
+
if (sh) {
|
|
2088
|
+
const get = () => {
|
|
2089
|
+
const newSh = { ...sh };
|
|
2090
|
+
Object.defineProperty(def, "shape", { value: newSh });
|
|
2091
|
+
get.raw = newSh;
|
|
2092
|
+
return newSh;
|
|
2093
|
+
};
|
|
2094
|
+
get.raw = sh;
|
|
2095
|
+
Object.defineProperty(def, "shape", { get });
|
|
2080
2096
|
}
|
|
2081
2097
|
const _normalized = cached(() => normalizeDef(def));
|
|
2082
2098
|
defineLazyInternal(inst, "propValues", (zod) => {
|
|
@@ -2116,7 +2132,14 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
2116
2132
|
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
2117
2133
|
const proms = [];
|
|
2118
2134
|
const shape = value.shape;
|
|
2135
|
+
const abortEarly = ctx?.abortEarly;
|
|
2136
|
+
let seen = payload.issues.length;
|
|
2119
2137
|
for (const key of value.allKeys) {
|
|
2138
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
2139
|
+
if (aborted(payload, seen))
|
|
2140
|
+
break;
|
|
2141
|
+
seen = payload.issues.length;
|
|
2142
|
+
}
|
|
2120
2143
|
if (key === "__proto__")
|
|
2121
2144
|
continue;
|
|
2122
2145
|
const el = shape[key];
|
|
@@ -2132,7 +2155,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
2132
2155
|
if (!catchall) {
|
|
2133
2156
|
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
2134
2157
|
}
|
|
2135
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
2158
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
|
|
2136
2159
|
};
|
|
2137
2160
|
});
|
|
2138
2161
|
var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
@@ -2146,10 +2169,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2146
2169
|
const doc = new Doc(["payload", "ctx"], { shape, inst, memo, syms });
|
|
2147
2170
|
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
2148
2171
|
const prefixStr = (id, k) => `
|
|
2172
|
+
let ${id}_ab = false;
|
|
2149
2173
|
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
2150
2174
|
const iss = ${id}.issues[i];
|
|
2151
2175
|
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
2152
2176
|
payload.issues.push(iss);
|
|
2177
|
+
if (iss.continue !== true) ${id}_ab = true;
|
|
2178
|
+
}
|
|
2179
|
+
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
2180
|
+
payload.value = newResult;
|
|
2181
|
+
return payload;
|
|
2153
2182
|
}`;
|
|
2154
2183
|
doc.write(`const input = payload.value;`);
|
|
2155
2184
|
const ids = Object.create(null);
|
|
@@ -2195,6 +2224,10 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2195
2224
|
input: undefined,
|
|
2196
2225
|
path: [${k}]
|
|
2197
2226
|
});
|
|
2227
|
+
if (ctx && ctx.abortEarly) {
|
|
2228
|
+
payload.value = newResult;
|
|
2229
|
+
return payload;
|
|
2230
|
+
}
|
|
2198
2231
|
}
|
|
2199
2232
|
|
|
2200
2233
|
if (${id}_present) {
|
|
@@ -2206,16 +2239,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2206
2239
|
doc.write(`
|
|
2207
2240
|
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
2208
2241
|
}
|
|
2209
|
-
|
|
2210
|
-
if (
|
|
2211
|
-
|
|
2212
|
-
newResult[${k}] = undefined;
|
|
2213
|
-
}
|
|
2242
|
+
`);
|
|
2243
|
+
if (optin === "defaulted") {
|
|
2244
|
+
doc.write(`newResult[${k}] = ${id}.value;`);
|
|
2214
2245
|
} else {
|
|
2246
|
+
doc.write(`
|
|
2247
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
2215
2248
|
newResult[${k}] = ${id}.value;
|
|
2216
2249
|
}
|
|
2217
|
-
|
|
2218
2250
|
`);
|
|
2251
|
+
}
|
|
2219
2252
|
}
|
|
2220
2253
|
}
|
|
2221
2254
|
doc.write(`payload.value = newResult;`);
|
|
@@ -2247,7 +2280,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2247
2280
|
payload = fastpass(payload, ctx);
|
|
2248
2281
|
if (!catchall)
|
|
2249
2282
|
return payload;
|
|
2250
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
2283
|
+
return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
|
|
2251
2284
|
}
|
|
2252
2285
|
return superParse(payload, ctx);
|
|
2253
2286
|
};
|
|
@@ -2317,16 +2350,37 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
|
2317
2350
|
});
|
|
2318
2351
|
};
|
|
2319
2352
|
});
|
|
2353
|
+
function discriminatorMap(def) {
|
|
2354
|
+
const map = new Map;
|
|
2355
|
+
for (const option of def.options) {
|
|
2356
|
+
const values = option._zod.propValues?.[def.discriminator];
|
|
2357
|
+
if (!values || values.size === 0)
|
|
2358
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
2359
|
+
for (const value of values) {
|
|
2360
|
+
if (map.has(value)) {
|
|
2361
|
+
if (value !== undefined)
|
|
2362
|
+
throw new Error(`Duplicate discriminator value "${String(value)}"`);
|
|
2363
|
+
map.set(value, null);
|
|
2364
|
+
} else {
|
|
2365
|
+
map.set(value, option);
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
return map;
|
|
2370
|
+
}
|
|
2320
2371
|
var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
2321
2372
|
def.inclusive = false;
|
|
2322
2373
|
$ZodUnion.init(inst, def);
|
|
2323
2374
|
const _super = inst._zod.parse;
|
|
2324
2375
|
defineLazyInternal(inst, "propValues", (zod) => {
|
|
2325
2376
|
const propValues = {};
|
|
2377
|
+
let undefinedCount = 0;
|
|
2326
2378
|
for (const option of zod.def.options) {
|
|
2327
2379
|
const pv = option._zod.propValues;
|
|
2328
2380
|
if (!pv || Object.keys(pv).length === 0)
|
|
2329
2381
|
throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
2382
|
+
if (pv[zod.def.discriminator]?.has(undefined))
|
|
2383
|
+
undefinedCount++;
|
|
2330
2384
|
for (const [k, v] of Object.entries(pv)) {
|
|
2331
2385
|
if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
|
|
2332
2386
|
assignProp(propValues, k, new Set);
|
|
@@ -2336,30 +2390,17 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
2336
2390
|
}
|
|
2337
2391
|
}
|
|
2338
2392
|
}
|
|
2393
|
+
if (!zod.def.unionFallback && undefinedCount > 1)
|
|
2394
|
+
propValues[zod.def.discriminator]?.delete(undefined);
|
|
2339
2395
|
return propValues;
|
|
2340
2396
|
});
|
|
2341
2397
|
def.options.forEach((option, i) => {
|
|
2342
|
-
const propShape =
|
|
2398
|
+
const propShape = rawShape(option._zod.def);
|
|
2343
2399
|
if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
|
|
2344
2400
|
throw new Error(`Invalid discriminated union option at index "${i}"`);
|
|
2345
2401
|
}
|
|
2346
2402
|
});
|
|
2347
|
-
const disc = cached(() =>
|
|
2348
|
-
const opts = def.options;
|
|
2349
|
-
const map = new Map;
|
|
2350
|
-
for (const o of opts) {
|
|
2351
|
-
const values = o._zod.propValues?.[def.discriminator];
|
|
2352
|
-
if (!values || values.size === 0)
|
|
2353
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
2354
|
-
for (const v of values) {
|
|
2355
|
-
if (map.has(v)) {
|
|
2356
|
-
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
2357
|
-
}
|
|
2358
|
-
map.set(v, o);
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
return map;
|
|
2362
|
-
});
|
|
2403
|
+
const disc = cached(() => discriminatorMap(def));
|
|
2363
2404
|
inst._zod.parse = (payload, ctx) => {
|
|
2364
2405
|
const input = payload.value;
|
|
2365
2406
|
if (!isObject(input)) {
|
|
@@ -2371,8 +2412,9 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
2371
2412
|
});
|
|
2372
2413
|
return payload;
|
|
2373
2414
|
}
|
|
2374
|
-
const
|
|
2375
|
-
|
|
2415
|
+
const value = input?.[def.discriminator];
|
|
2416
|
+
const opt = disc.value.get(value);
|
|
2417
|
+
if (opt && (value !== undefined || ctx.direction !== "backward")) {
|
|
2376
2418
|
return opt._zod.run(payload, ctx);
|
|
2377
2419
|
}
|
|
2378
2420
|
if (def.unionFallback || ctx.direction === "backward") {
|
|
@@ -2383,7 +2425,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
2383
2425
|
errors: [],
|
|
2384
2426
|
note: "No matching discriminator",
|
|
2385
2427
|
discriminator: def.discriminator,
|
|
2386
|
-
options: Array.from(disc.value.keys()),
|
|
2428
|
+
options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
|
|
2387
2429
|
input,
|
|
2388
2430
|
path: [def.discriminator],
|
|
2389
2431
|
inst
|
|
@@ -2665,8 +2707,10 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
2665
2707
|
const values = getEnumValues(def.entries);
|
|
2666
2708
|
const valuesSet = new Set(values);
|
|
2667
2709
|
inst._zod.values = valuesSet;
|
|
2668
|
-
|
|
2669
|
-
|
|
2710
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2711
|
+
const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
|
|
2712
|
+
return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
|
|
2713
|
+
});
|
|
2670
2714
|
inst._zod.parse = (payload, _ctx) => {
|
|
2671
2715
|
const input = payload.value;
|
|
2672
2716
|
if (valuesSet.has(input)) {
|
|
@@ -2685,7 +2729,10 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
2685
2729
|
$ZodType.init(inst, def);
|
|
2686
2730
|
const values = new Set(def.values);
|
|
2687
2731
|
inst._zod.values = values;
|
|
2688
|
-
inst
|
|
2732
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2733
|
+
const vals = zod.def.values;
|
|
2734
|
+
return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
|
|
2735
|
+
});
|
|
2689
2736
|
inst._zod.parse = (payload, _ctx) => {
|
|
2690
2737
|
const input = payload.value;
|
|
2691
2738
|
if (values.has(input)) {
|
|
@@ -2962,28 +3009,53 @@ class $ZodCyclicError extends Error {
|
|
|
2962
3009
|
}
|
|
2963
3010
|
var STATE = "~memo";
|
|
2964
3011
|
var NO_ISSUES = [];
|
|
3012
|
+
function isRef(value) {
|
|
3013
|
+
return value !== null && typeof value === "object";
|
|
3014
|
+
}
|
|
2965
3015
|
function cloneIssues(issues) {
|
|
2966
3016
|
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
2967
3017
|
}
|
|
2968
3018
|
var recursive = /* @__PURE__ */ new WeakMap;
|
|
2969
|
-
|
|
3019
|
+
var NONE = 0;
|
|
3020
|
+
var ASSUMED = 1;
|
|
3021
|
+
var PROVEN = 2;
|
|
3022
|
+
function isRecursive(inst, stack, resolve) {
|
|
2970
3023
|
const cached = recursive.get(inst);
|
|
2971
3024
|
if (cached !== undefined)
|
|
2972
|
-
return cached;
|
|
3025
|
+
return cached ? PROVEN : NONE;
|
|
2973
3026
|
if (stack.has(inst))
|
|
2974
|
-
return
|
|
3027
|
+
return PROVEN;
|
|
2975
3028
|
stack.add(inst);
|
|
2976
|
-
let result =
|
|
3029
|
+
let result = NONE;
|
|
2977
3030
|
const check = (child) => {
|
|
2978
|
-
if (
|
|
2979
|
-
|
|
3031
|
+
if (result !== PROVEN && child?._zod) {
|
|
3032
|
+
const answer = isRecursive(child, stack, resolve);
|
|
3033
|
+
if (answer > result)
|
|
3034
|
+
result = answer;
|
|
3035
|
+
}
|
|
3036
|
+
};
|
|
3037
|
+
const shape = (sh, spread) => {
|
|
3038
|
+
let answer = NONE;
|
|
3039
|
+
for (const key of Reflect.ownKeys(sh)) {
|
|
3040
|
+
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
3041
|
+
if (spread && !desc.enumerable)
|
|
3042
|
+
continue;
|
|
3043
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
|
|
3044
|
+
if (child > answer)
|
|
3045
|
+
answer = child;
|
|
3046
|
+
}
|
|
3047
|
+
return answer;
|
|
3048
|
+
};
|
|
3049
|
+
const merge = (answer) => {
|
|
3050
|
+
if (answer > result)
|
|
3051
|
+
result = answer;
|
|
2980
3052
|
};
|
|
2981
3053
|
const def = inst._zod.def;
|
|
2982
3054
|
const kind = def.type;
|
|
2983
3055
|
switch (kind) {
|
|
2984
3056
|
case "object": {
|
|
2985
|
-
|
|
2986
|
-
|
|
3057
|
+
const raw = rawShape(def);
|
|
3058
|
+
merge(raw ? shape(raw, true) : ASSUMED);
|
|
2987
3059
|
check(def.catchall);
|
|
2988
3060
|
break;
|
|
2989
3061
|
}
|
|
@@ -3030,9 +3102,11 @@ function isRecursive(inst, stack) {
|
|
|
3030
3102
|
check(def.input);
|
|
3031
3103
|
check(def.output);
|
|
3032
3104
|
break;
|
|
3033
|
-
case "lazy":
|
|
3034
|
-
|
|
3105
|
+
case "lazy": {
|
|
3106
|
+
const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : undefined);
|
|
3107
|
+
merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
3035
3108
|
break;
|
|
3109
|
+
}
|
|
3036
3110
|
case "template_literal":
|
|
3037
3111
|
case "string":
|
|
3038
3112
|
case "number":
|
|
@@ -3071,16 +3145,20 @@ function isRecursive(inst, stack) {
|
|
|
3071
3145
|
}
|
|
3072
3146
|
}
|
|
3073
3147
|
stack.delete(inst);
|
|
3074
|
-
|
|
3075
|
-
|
|
3148
|
+
return settle(inst, result);
|
|
3149
|
+
}
|
|
3150
|
+
function settle(inst, answer) {
|
|
3151
|
+
if (answer !== ASSUMED)
|
|
3152
|
+
recursive.set(inst, answer === PROVEN);
|
|
3153
|
+
return answer;
|
|
3076
3154
|
}
|
|
3077
3155
|
function isRecursiveSchema(inst) {
|
|
3078
|
-
return isRecursive(inst, new Set);
|
|
3156
|
+
return isRecursive(inst, new Set, true) !== NONE;
|
|
3079
3157
|
}
|
|
3080
3158
|
function bucketFor(state, inst) {
|
|
3081
3159
|
let bucket = state.buckets.get(inst);
|
|
3082
3160
|
if (!bucket) {
|
|
3083
|
-
bucket = new
|
|
3161
|
+
bucket = new WeakMap;
|
|
3084
3162
|
state.buckets.set(inst, bucket);
|
|
3085
3163
|
}
|
|
3086
3164
|
return bucket;
|
|
@@ -3116,6 +3194,7 @@ var memo = {
|
|
|
3116
3194
|
attach(inst) {
|
|
3117
3195
|
var _a;
|
|
3118
3196
|
let isRecursiveInst;
|
|
3197
|
+
let rechecked = false;
|
|
3119
3198
|
let lastCtx;
|
|
3120
3199
|
let lastBucket;
|
|
3121
3200
|
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
@@ -3123,20 +3202,24 @@ var memo = {
|
|
|
3123
3202
|
const base = inst._zod.parse;
|
|
3124
3203
|
const wrapped = (payload, ctx) => {
|
|
3125
3204
|
if (isRecursiveInst === undefined) {
|
|
3126
|
-
|
|
3127
|
-
if (
|
|
3205
|
+
const walked = isRecursive(inst, new Set, false);
|
|
3206
|
+
if (walked === NONE) {
|
|
3128
3207
|
inst._zod.parse = base;
|
|
3129
3208
|
if (inst._zod.run === wrapped)
|
|
3130
3209
|
inst._zod.run = base;
|
|
3131
3210
|
return base(payload, ctx);
|
|
3132
3211
|
}
|
|
3212
|
+
if (walked === PROVEN || rechecked)
|
|
3213
|
+
isRecursiveInst = true;
|
|
3214
|
+
else
|
|
3215
|
+
rechecked = true;
|
|
3133
3216
|
}
|
|
3134
3217
|
const input = payload.value;
|
|
3135
|
-
if (input
|
|
3218
|
+
if (!isRef(input))
|
|
3136
3219
|
return base(payload, ctx);
|
|
3137
3220
|
let state = ctx[STATE];
|
|
3138
3221
|
if (!state) {
|
|
3139
|
-
state = { buckets: new
|
|
3222
|
+
state = { buckets: new WeakMap, backEdges: undefined };
|
|
3140
3223
|
ctx[STATE] = state;
|
|
3141
3224
|
}
|
|
3142
3225
|
let bucket;
|
|
@@ -3155,7 +3238,7 @@ var memo = {
|
|
|
3155
3238
|
payload.issues.push(...cloneIssues(hit.issues));
|
|
3156
3239
|
} else {
|
|
3157
3240
|
payload.memo = true;
|
|
3158
|
-
state.backEdges ?? (state.backEdges = new
|
|
3241
|
+
state.backEdges ?? (state.backEdges = new WeakSet);
|
|
3159
3242
|
state.backEdges.add(hit.value);
|
|
3160
3243
|
}
|
|
3161
3244
|
return payload;
|
|
@@ -3187,7 +3270,7 @@ function memoizer() {
|
|
|
3187
3270
|
}
|
|
3188
3271
|
function isBackEdge(ctx, value) {
|
|
3189
3272
|
const backEdges = ctx[STATE]?.backEdges;
|
|
3190
|
-
return backEdges !== undefined && value
|
|
3273
|
+
return backEdges !== undefined && isRef(value) && backEdges.has(value);
|
|
3191
3274
|
}
|
|
3192
3275
|
// node_modules/zod/v4/locales/en.js
|
|
3193
3276
|
var error = () => {
|
|
@@ -3229,7 +3312,9 @@ var error = () => {
|
|
|
3229
3312
|
base64url: "base64url-encoded string",
|
|
3230
3313
|
json_string: "JSON string",
|
|
3231
3314
|
e164: "E.164 number",
|
|
3315
|
+
currency_code: "currency code",
|
|
3232
3316
|
credit_card: "credit card number",
|
|
3317
|
+
iban: "IBAN",
|
|
3233
3318
|
jwt: "JWT",
|
|
3234
3319
|
template_literal: "input"
|
|
3235
3320
|
};
|
|
@@ -3384,38 +3469,46 @@ function compileValidator(schema, parser) {
|
|
|
3384
3469
|
function compile(schema, options) {
|
|
3385
3470
|
try {
|
|
3386
3471
|
const parser = compileFn(schema);
|
|
3387
|
-
const
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
const wrapped = (payload, ctx) => {
|
|
3391
|
-
if (ctx?.async || ctx?.direction === "backward" || ctx?.skipChecks || ctx?.[FALLBACK_FLAG]) {
|
|
3392
|
-
return originalRun(payload, ctx);
|
|
3393
|
-
}
|
|
3394
|
-
if (ctx && isBackEdge(ctx, payload.value)) {
|
|
3395
|
-
return originalRun(payload, ctx);
|
|
3396
|
-
}
|
|
3397
|
-
const out = parser(payload.value);
|
|
3398
|
-
if (out !== INVALID) {
|
|
3399
|
-
payload.value = out;
|
|
3400
|
-
return payload;
|
|
3401
|
-
}
|
|
3402
|
-
if (ctx)
|
|
3403
|
-
ctx[FALLBACK_FLAG] = true;
|
|
3404
|
-
return originalRun(payload, ctx);
|
|
3405
|
-
};
|
|
3406
|
-
wrapped.__originalRun = originalRun;
|
|
3407
|
-
clone2._zod.bag.fallbackRun = originalRun;
|
|
3408
|
-
clone2._zod.bag.validator = compileValidator(schema, parser);
|
|
3409
|
-
clone2._zod.run = wrapped;
|
|
3410
|
-
if (!liveRun.__originalRun)
|
|
3411
|
-
installCompiledUserMethods(clone2, schema, parser);
|
|
3412
|
-
return clone2;
|
|
3472
|
+
const clone = withParser(schema, parser);
|
|
3473
|
+
clone._zod.bag.validator = compileValidator(schema, parser);
|
|
3474
|
+
return clone;
|
|
3413
3475
|
} catch (err) {
|
|
3414
3476
|
if (options?.strict)
|
|
3415
3477
|
throw err;
|
|
3416
3478
|
return schema;
|
|
3417
3479
|
}
|
|
3418
3480
|
}
|
|
3481
|
+
function withParser(schema, parser) {
|
|
3482
|
+
if (isRecursiveSchema(schema)) {
|
|
3483
|
+
throw new ZodCompileUnsupportedError("a schema whose subtree contains a reference cycle");
|
|
3484
|
+
}
|
|
3485
|
+
const clone2 = clone(schema);
|
|
3486
|
+
const liveRun = schema._zod.run;
|
|
3487
|
+
const originalRun = liveRun.__originalRun ?? liveRun;
|
|
3488
|
+
const wrapped = (payload, ctx) => {
|
|
3489
|
+
if (ctx?.async || ctx?.direction === "backward" || ctx?.skipChecks || ctx?.[FALLBACK_FLAG]) {
|
|
3490
|
+
return originalRun(payload, ctx);
|
|
3491
|
+
}
|
|
3492
|
+
if (ctx && isBackEdge(ctx, payload.value)) {
|
|
3493
|
+
return originalRun(payload, ctx);
|
|
3494
|
+
}
|
|
3495
|
+
const out = parser(payload.value);
|
|
3496
|
+
if (out !== INVALID) {
|
|
3497
|
+
payload.value = out;
|
|
3498
|
+
return payload;
|
|
3499
|
+
}
|
|
3500
|
+
if (ctx)
|
|
3501
|
+
ctx[FALLBACK_FLAG] = true;
|
|
3502
|
+
return originalRun(payload, ctx);
|
|
3503
|
+
};
|
|
3504
|
+
wrapped.__originalRun = originalRun;
|
|
3505
|
+
clone2._zod.bag.fallbackRun = originalRun;
|
|
3506
|
+
clone2._zod.bag.validator = parser;
|
|
3507
|
+
clone2._zod.run = wrapped;
|
|
3508
|
+
if (!liveRun.__originalRun)
|
|
3509
|
+
installCompiledUserMethods(clone2, schema, parser);
|
|
3510
|
+
return clone2;
|
|
3511
|
+
}
|
|
3419
3512
|
function installCompiledUserMethods(target, source, parser) {
|
|
3420
3513
|
const targetAny = target;
|
|
3421
3514
|
const sourceAny = source;
|
|
@@ -3451,7 +3544,8 @@ function compileFn(schema, options) {
|
|
|
3451
3544
|
const ctx = {
|
|
3452
3545
|
constants: new Map,
|
|
3453
3546
|
constantCounter: 0,
|
|
3454
|
-
varCounter: 0
|
|
3547
|
+
varCounter: 0,
|
|
3548
|
+
definite: true
|
|
3455
3549
|
};
|
|
3456
3550
|
const doc = new Doc(["input"]);
|
|
3457
3551
|
const outputAccessor = generateCheck(doc, ctx, schema, "input", !options?.assertOnly);
|
|
@@ -3476,6 +3570,7 @@ ${code}
|
|
|
3476
3570
|
if (options?.debug) {
|
|
3477
3571
|
fn.code = fullCode;
|
|
3478
3572
|
}
|
|
3573
|
+
fn.definite = ctx.definite;
|
|
3479
3574
|
return fn;
|
|
3480
3575
|
}
|
|
3481
3576
|
function addConstant(ctx, value) {
|
|
@@ -3487,6 +3582,10 @@ function addConstant(ctx, value) {
|
|
|
3487
3582
|
ctx.constants.set(name, value);
|
|
3488
3583
|
return name;
|
|
3489
3584
|
}
|
|
3585
|
+
function addUserConstant(ctx, fn) {
|
|
3586
|
+
ctx.definite = false;
|
|
3587
|
+
return addConstant(ctx, fn);
|
|
3588
|
+
}
|
|
3490
3589
|
function newVar(ctx) {
|
|
3491
3590
|
return `v${ctx.varCounter++}`;
|
|
3492
3591
|
}
|
|
@@ -3519,6 +3618,7 @@ function compileChild(doc, ctx, schema, accessor, needsValue = true) {
|
|
|
3519
3618
|
}
|
|
3520
3619
|
}
|
|
3521
3620
|
function emitRuntimeIsland(doc, ctx, schema, accessor) {
|
|
3621
|
+
ctx.definite = false;
|
|
3522
3622
|
const schemaConst = addConstant(ctx, schema);
|
|
3523
3623
|
const runConst = addConstant(ctx, runtimeRun);
|
|
3524
3624
|
const outVar = newVar(ctx);
|
|
@@ -3599,6 +3699,9 @@ function generateChecks(doc, ctx, schema, accessor) {
|
|
|
3599
3699
|
case "property":
|
|
3600
3700
|
generatePropertyCheck(doc, ctx, def, currentAccessor);
|
|
3601
3701
|
break;
|
|
3702
|
+
case "properties":
|
|
3703
|
+
generatePropertiesChecks(doc, ctx, def, currentAccessor);
|
|
3704
|
+
break;
|
|
3602
3705
|
case "overwrite": {
|
|
3603
3706
|
const newAccessor = newVar(ctx);
|
|
3604
3707
|
generateOverwriteCheck(doc, ctx, check, currentAccessor, newAccessor);
|
|
@@ -3704,6 +3807,19 @@ function generateMimeTypeCheck(doc, ctx, def, accessor) {
|
|
|
3704
3807
|
doc.write(`if (!${mimeSet}.has(${accessor}.type)) return INVALID;`);
|
|
3705
3808
|
}
|
|
3706
3809
|
}
|
|
3810
|
+
function generatePropertiesChecks(doc, ctx, def, accessor) {
|
|
3811
|
+
if (def.when) {
|
|
3812
|
+
throw new ZodCompileUnsupportedError(`check with a custom "when" condition`);
|
|
3813
|
+
}
|
|
3814
|
+
doc.write(`if (${accessor} == null) return INVALID;`);
|
|
3815
|
+
const shape = def.shape;
|
|
3816
|
+
for (const key of Reflect.ownKeys(shape)) {
|
|
3817
|
+
const keyExpr = typeof key === "symbol" ? addConstant(ctx, key) : esc(key);
|
|
3818
|
+
const inputVar = newVar(ctx);
|
|
3819
|
+
doc.write(`const ${inputVar} = ${accessor}[${keyExpr}];`);
|
|
3820
|
+
compileChild(doc, ctx, shape[key], inputVar, false);
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3707
3823
|
function generatePropertyCheck(doc, ctx, def, accessor) {
|
|
3708
3824
|
const propAccessor = `${accessor}[${JSON.stringify(def.property)}]`;
|
|
3709
3825
|
generateCheck(doc, ctx, def.schema, propAccessor);
|
|
@@ -3731,7 +3847,7 @@ function generateCustomRefineCheck(doc, ctx, check, accessor) {
|
|
|
3731
3847
|
if (isAsyncFunction(def.fn)) {
|
|
3732
3848
|
throw new ZodCompileAsyncError("z.compile: async .refine() predicates are not supported");
|
|
3733
3849
|
}
|
|
3734
|
-
const fnConst =
|
|
3850
|
+
const fnConst = addUserConstant(ctx, def.fn);
|
|
3735
3851
|
const throwAsyncConst = addConstant(ctx, throwAsync);
|
|
3736
3852
|
const resVar = newVar(ctx);
|
|
3737
3853
|
doc.write(`const ${resVar} = ${fnConst}(${accessor});`);
|
|
@@ -3751,7 +3867,7 @@ function generateCustomRefineCheck(doc, ctx, check, accessor) {
|
|
|
3751
3867
|
throwAsync();
|
|
3752
3868
|
return fakePayload.issues.length === 0 ? fakePayload.value : INVALID;
|
|
3753
3869
|
};
|
|
3754
|
-
const helperConst =
|
|
3870
|
+
const helperConst = addUserConstant(ctx, helperFn);
|
|
3755
3871
|
const outVar = newVar(ctx);
|
|
3756
3872
|
doc.write(`const ${outVar} = ${helperConst}(${accessor});`);
|
|
3757
3873
|
doc.write(`if (${outVar} === INVALID) return INVALID;`);
|
|
@@ -3785,7 +3901,7 @@ var PATTERN_IS_COMPLETE = new Set([
|
|
|
3785
3901
|
"uuid",
|
|
3786
3902
|
"xid"
|
|
3787
3903
|
]);
|
|
3788
|
-
function generateStringFormatCheck(doc, ctx, def, accessor) {
|
|
3904
|
+
function generateStringFormatCheck(doc, ctx, def, accessor, needsValue = true) {
|
|
3789
3905
|
const fmt = def.format;
|
|
3790
3906
|
if (fmt === "base64") {
|
|
3791
3907
|
const validator = addConstant(ctx, isValidBase64);
|
|
@@ -3818,9 +3934,14 @@ function generateStringFormatCheck(doc, ctx, def, accessor) {
|
|
|
3818
3934
|
doc.write(`if (!${validator}(${accessor})) return INVALID;`);
|
|
3819
3935
|
return accessor;
|
|
3820
3936
|
}
|
|
3937
|
+
if (fmt === "iban") {
|
|
3938
|
+
const validator = addConstant(ctx, isValidIBAN);
|
|
3939
|
+
doc.write(`if (!${validator}(${accessor})) return INVALID;`);
|
|
3940
|
+
return accessor;
|
|
3941
|
+
}
|
|
3821
3942
|
const formatDef = def;
|
|
3822
3943
|
if (fmt === "url" || fmt === "httpurl" || formatDef.normalize || formatDef.hostname !== undefined || formatDef.protocol !== undefined) {
|
|
3823
|
-
const parseConst = addConstant(ctx,
|
|
3944
|
+
const parseConst = addConstant(ctx, validateURL);
|
|
3824
3945
|
const defConst = addConstant(ctx, def);
|
|
3825
3946
|
const trimVar = newVar(ctx);
|
|
3826
3947
|
const urlVar = newVar(ctx);
|
|
@@ -3835,6 +3956,8 @@ function generateStringFormatCheck(doc, ctx, def, accessor) {
|
|
|
3835
3956
|
const protocolConst = addConstant(ctx, urlProtocolOk);
|
|
3836
3957
|
doc.write(`if (!${protocolConst}(${urlVar}, ${defConst}.protocol)) return INVALID;`);
|
|
3837
3958
|
}
|
|
3959
|
+
if (!needsValue)
|
|
3960
|
+
return null;
|
|
3838
3961
|
const outputVar = newVar(ctx);
|
|
3839
3962
|
const outputExpr = formatDef.normalize ? `${urlVar}.href` : `${addConstant(ctx, stripTabAndNewline)}(${trimVar})`;
|
|
3840
3963
|
doc.write(`const ${outputVar} = ${outputExpr};`);
|
|
@@ -3893,7 +4016,7 @@ function generateCheck(doc, ctx, schema, accessor, needsValue = true) {
|
|
|
3893
4016
|
let typeAccessor;
|
|
3894
4017
|
switch (type) {
|
|
3895
4018
|
case "string":
|
|
3896
|
-
typeAccessor = generateStringCheck(doc, ctx, schema, accessor);
|
|
4019
|
+
typeAccessor = generateStringCheck(doc, ctx, schema, accessor, buildsValue);
|
|
3897
4020
|
break;
|
|
3898
4021
|
case "number":
|
|
3899
4022
|
typeAccessor = generateNumberCheck(doc, schema, accessor);
|
|
@@ -4013,12 +4136,12 @@ function generateCheck(doc, ctx, schema, accessor, needsValue = true) {
|
|
|
4013
4136
|
return null;
|
|
4014
4137
|
return generateChecks(doc, ctx, schema, typeAccessor);
|
|
4015
4138
|
}
|
|
4016
|
-
function generateStringCheck(doc, ctx, schema, accessor) {
|
|
4139
|
+
function generateStringCheck(doc, ctx, schema, accessor, needsValue = true) {
|
|
4017
4140
|
doc.write(`if (typeof ${accessor} !== "string") return INVALID;`);
|
|
4018
4141
|
const def = schema._zod.def;
|
|
4019
4142
|
if (def.format === undefined)
|
|
4020
4143
|
return accessor;
|
|
4021
|
-
return generateStringFormatCheck(doc, ctx, def, accessor);
|
|
4144
|
+
return generateStringFormatCheck(doc, ctx, def, accessor, needsValue);
|
|
4022
4145
|
}
|
|
4023
4146
|
function generateNumberCheck(doc, schema, accessor) {
|
|
4024
4147
|
doc.write(`if (typeof ${accessor} !== "number" || !Number.isFinite(${accessor})) return INVALID;`);
|
|
@@ -4136,7 +4259,7 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
4136
4259
|
}
|
|
4137
4260
|
}
|
|
4138
4261
|
const outputVar = newVar(ctx);
|
|
4139
|
-
const hasConditionalKeys = allKeys.some((k) =>
|
|
4262
|
+
const hasConditionalKeys = allKeys.some((k) => mayOmitUndefined(propShape[k]) || dropsWhenAbsent(propShape[k]));
|
|
4140
4263
|
if (!buildsValue) {
|
|
4141
4264
|
if (unknownKeysMode === "schema") {
|
|
4142
4265
|
const knownSet = keys.length > 0 ? addConstant(ctx, new Set(keys)) : null;
|
|
@@ -4163,7 +4286,7 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
4163
4286
|
const out = propOutputs.get(k);
|
|
4164
4287
|
if (dropsWhenAbsent(propShape[k])) {
|
|
4165
4288
|
doc.write(`if (${kx} in ${accessor}) ${outputVar}[${kx}] = ${out};`);
|
|
4166
|
-
} else if (
|
|
4289
|
+
} else if (mayOmitUndefined(propShape[k])) {
|
|
4167
4290
|
doc.write(`if (${out} !== undefined || ${kx} in ${accessor}) ${outputVar}[${kx}] = ${out};`);
|
|
4168
4291
|
} else {
|
|
4169
4292
|
doc.write(`${outputVar}[${kx}] = ${out};`);
|
|
@@ -4296,6 +4419,9 @@ function fastPathAcceptsAbsence(schema) {
|
|
|
4296
4419
|
function dropsWhenAbsent(schema) {
|
|
4297
4420
|
return schema._zod.optin === "optional" && schema._zod.optout === "optional";
|
|
4298
4421
|
}
|
|
4422
|
+
function mayOmitUndefined(schema) {
|
|
4423
|
+
return (schema._zod.optin !== "defaulted" || schema._zod.optout === "optional") && mayOutputUndefined(schema);
|
|
4424
|
+
}
|
|
4299
4425
|
function mayOutputUndefined(schema) {
|
|
4300
4426
|
const def = schema._zod.def;
|
|
4301
4427
|
switch (def.type) {
|
|
@@ -4638,6 +4764,7 @@ function literalEquality(ctx, accessor, value) {
|
|
|
4638
4764
|
}
|
|
4639
4765
|
function generateIntersectionCheck(doc, ctx, schema, accessor) {
|
|
4640
4766
|
const def = schema._zod.def;
|
|
4767
|
+
ctx.definite = false;
|
|
4641
4768
|
const leftOutput = compileChild(doc, ctx, def.left, accessor);
|
|
4642
4769
|
const rightOutput = compileChild(doc, ctx, def.right, accessor);
|
|
4643
4770
|
const mergeConst = addConstant(ctx, mergeValues);
|
|
@@ -4691,14 +4818,13 @@ function generateRecordCheck(doc, ctx, schema, accessor) {
|
|
|
4691
4818
|
const keyIsBareString = keyDef.type === "string" && keyDef.format === undefined && !keyDef.coerce && (keyDef.checks?.length ?? 0) === 0;
|
|
4692
4819
|
if (!keyIsBareString) {
|
|
4693
4820
|
const isLoose = def.mode === "loose";
|
|
4694
|
-
const
|
|
4821
|
+
const keyFn = compileFn(def.keyType);
|
|
4822
|
+
if (keyFn.definite === false)
|
|
4823
|
+
ctx.definite = false;
|
|
4824
|
+
const keyFast = addConstant(ctx, keyFn);
|
|
4695
4825
|
const numericConst = addConstant(ctx, number);
|
|
4696
|
-
const propIsEnumerableConst = addConstant(ctx, Object.prototype.propertyIsEnumerable);
|
|
4697
4826
|
const outKeyVar = newVar(ctx);
|
|
4698
|
-
doc
|
|
4699
|
-
doc.indented((d) => {
|
|
4700
|
-
d.write(`if (${kVar} === "__proto__") continue;`);
|
|
4701
|
-
d.write(`if (!${propIsEnumerableConst}.call(${accessor}, ${kVar})) continue;`);
|
|
4827
|
+
emitOwnKeys(doc, ctx, accessor, kVar, (d) => {
|
|
4702
4828
|
d.write(`let ${outKeyVar} = ${keyFast}(${kVar});`);
|
|
4703
4829
|
d.write(`if (${outKeyVar} === INVALID && typeof ${kVar} === "string" && ${numericConst}.test(${kVar})) ${outKeyVar} = ${keyFast}(Number(${kVar}));`);
|
|
4704
4830
|
if (isLoose) {
|
|
@@ -4712,21 +4838,39 @@ function generateRecordCheck(doc, ctx, schema, accessor) {
|
|
|
4712
4838
|
const valOutput = compileChild(d, ctx, def.valueType, valueVar);
|
|
4713
4839
|
d.write(`${outputVar}[${outKeyVar}] = ${valOutput};`);
|
|
4714
4840
|
});
|
|
4715
|
-
doc.write(`}`);
|
|
4716
4841
|
return outputVar;
|
|
4717
4842
|
}
|
|
4718
|
-
|
|
4719
|
-
doc.write(`for (const ${kVar} of Reflect.ownKeys(${accessor})) {`);
|
|
4720
|
-
doc.indented((d) => {
|
|
4721
|
-
d.write(`if (${kVar} === "__proto__") continue;`);
|
|
4722
|
-
d.write(`if (!${propIsEnumerable}.call(${accessor}, ${kVar})) continue;`);
|
|
4723
|
-
d.write(`if (typeof ${kVar} !== "string") return INVALID;`);
|
|
4843
|
+
emitOwnKeys(doc, ctx, accessor, kVar, (d) => {
|
|
4724
4844
|
d.write(`const ${valVar} = ${accessor}[${kVar}];`);
|
|
4725
4845
|
const valOutput = compileChild(d, ctx, def.valueType, valVar);
|
|
4726
4846
|
d.write(`${outputVar}[${kVar}] = ${valOutput};`);
|
|
4847
|
+
}, `return INVALID;`);
|
|
4848
|
+
return outputVar;
|
|
4849
|
+
}
|
|
4850
|
+
function emitOwnKeys(doc, ctx, accessor, kVar, body, onSymbol) {
|
|
4851
|
+
const propIsEnumerableConst = addConstant(ctx, Object.prototype.propertyIsEnumerable);
|
|
4852
|
+
const symsVar = newVar(ctx);
|
|
4853
|
+
const keysVar = newVar(ctx);
|
|
4854
|
+
const iVar = newVar(ctx);
|
|
4855
|
+
doc.write(`const ${symsVar} = Object.getOwnPropertySymbols(${accessor});`);
|
|
4856
|
+
doc.write(`const ${keysVar} = Object.getOwnPropertyNames(${accessor});`);
|
|
4857
|
+
doc.write(`for (let ${iVar} = 0; ${iVar} < ${keysVar}.length; ${iVar}++) {`);
|
|
4858
|
+
doc.indented((d) => {
|
|
4859
|
+
d.write(`const ${kVar} = ${keysVar}[${iVar}];`);
|
|
4860
|
+
d.write(`if (${kVar} === "__proto__" || !${propIsEnumerableConst}.call(${accessor}, ${kVar})) continue;`);
|
|
4861
|
+
body(d);
|
|
4862
|
+
});
|
|
4863
|
+
doc.write(`}`);
|
|
4864
|
+
doc.write(`for (let ${iVar} = 0; ${iVar} < ${symsVar}.length; ${iVar}++) {`);
|
|
4865
|
+
doc.indented((d) => {
|
|
4866
|
+
d.write(`const ${kVar} = ${symsVar}[${iVar}];`);
|
|
4867
|
+
d.write(`if (!${propIsEnumerableConst}.call(${accessor}, ${kVar})) continue;`);
|
|
4868
|
+
if (onSymbol)
|
|
4869
|
+
d.write(onSymbol);
|
|
4870
|
+
else
|
|
4871
|
+
body(d);
|
|
4727
4872
|
});
|
|
4728
4873
|
doc.write(`}`);
|
|
4729
|
-
return outputVar;
|
|
4730
4874
|
}
|
|
4731
4875
|
function literalPropertyKey(ctx, key) {
|
|
4732
4876
|
if (typeof key === "string")
|
|
@@ -4779,7 +4923,7 @@ function generateTemplateLiteralCheck(doc, ctx, schema, accessor) {
|
|
|
4779
4923
|
}
|
|
4780
4924
|
function generateLazyCheck(doc, ctx, schema, accessor) {
|
|
4781
4925
|
const def = schema._zod.def;
|
|
4782
|
-
const getterConst =
|
|
4926
|
+
const getterConst = addUserConstant(ctx, def.getter);
|
|
4783
4927
|
const cacheConst = addConstant(ctx, { parser: null });
|
|
4784
4928
|
doc.write(`if (!${cacheConst}.parser) {`);
|
|
4785
4929
|
doc.indented((d) => {
|
|
@@ -4812,7 +4956,7 @@ function generatePipeCheck(doc, ctx, schema, accessor) {
|
|
|
4812
4956
|
return INVALID;
|
|
4813
4957
|
return fakePayload.issues.length === 0 ? result : INVALID;
|
|
4814
4958
|
};
|
|
4815
|
-
const helperConst =
|
|
4959
|
+
const helperConst = addUserConstant(ctx, helperFn);
|
|
4816
4960
|
const transformedVar = newVar(ctx);
|
|
4817
4961
|
doc.write(`const ${transformedVar} = ${helperConst}(${inputOutput});`);
|
|
4818
4962
|
doc.write(`if (${transformedVar} === INVALID) return INVALID;`);
|
|
@@ -4830,7 +4974,7 @@ function generateCustomCheck(doc, ctx, schema, accessor) {
|
|
|
4830
4974
|
if (isAsyncFunction(def.fn)) {
|
|
4831
4975
|
throw new ZodCompileAsyncError("z.compile: async custom predicates are not supported");
|
|
4832
4976
|
}
|
|
4833
|
-
const fnConst =
|
|
4977
|
+
const fnConst = addUserConstant(ctx, def.fn);
|
|
4834
4978
|
const throwAsyncConst = addConstant(ctx, throwAsync);
|
|
4835
4979
|
const resVar = newVar(ctx);
|
|
4836
4980
|
doc.write(`const ${resVar} = ${fnConst}(${accessor});`);
|
|
@@ -4863,7 +5007,7 @@ function generateCatchCheck(doc, ctx, schema, accessor) {
|
|
|
4863
5007
|
});
|
|
4864
5008
|
doc.write(`})();`);
|
|
4865
5009
|
const innerConst = addConstant(ctx, def.innerType);
|
|
4866
|
-
const catchConst =
|
|
5010
|
+
const catchConst = addUserConstant(ctx, def.catchValue);
|
|
4867
5011
|
const catchHelperConst = addConstant(ctx, runtimeCatch);
|
|
4868
5012
|
doc.write(`if (${outputVar} === INVALID) {`);
|
|
4869
5013
|
doc.indented((d) => {
|
|
@@ -4887,7 +5031,7 @@ function generateTransformCheck(doc, ctx, schema, accessor) {
|
|
|
4887
5031
|
return INVALID;
|
|
4888
5032
|
return fakePayload.issues.length === 0 ? result : INVALID;
|
|
4889
5033
|
};
|
|
4890
|
-
const helperConst =
|
|
5034
|
+
const helperConst = addUserConstant(ctx, helperFn);
|
|
4891
5035
|
const outputVar = newVar(ctx);
|
|
4892
5036
|
doc.write(`const ${outputVar} = ${helperConst}(${accessor});`);
|
|
4893
5037
|
doc.write(`if (${outputVar} === INVALID) return INVALID;`);
|
|
@@ -4896,11 +5040,13 @@ function generateTransformCheck(doc, ctx, schema, accessor) {
|
|
|
4896
5040
|
return accessor;
|
|
4897
5041
|
}
|
|
4898
5042
|
// node_modules/zod/v4/core/api.js
|
|
5043
|
+
function snapshotChecks(def) {
|
|
5044
|
+
if (def.checks)
|
|
5045
|
+
def.checks = [...def.checks];
|
|
5046
|
+
return def;
|
|
5047
|
+
}
|
|
4899
5048
|
function _string(Class, params) {
|
|
4900
|
-
return new Class({
|
|
4901
|
-
type: "string",
|
|
4902
|
-
...normalizeParams(params)
|
|
4903
|
-
});
|
|
5049
|
+
return new Class(snapshotChecks({ type: "string", ...normalizeParams(params) }));
|
|
4904
5050
|
}
|
|
4905
5051
|
function _email(Class, params) {
|
|
4906
5052
|
return new Class({
|
|
@@ -5140,11 +5286,7 @@ function _isoDuration(Class, params) {
|
|
|
5140
5286
|
});
|
|
5141
5287
|
}
|
|
5142
5288
|
function _number(Class, params) {
|
|
5143
|
-
return new Class({
|
|
5144
|
-
type: "number",
|
|
5145
|
-
checks: [],
|
|
5146
|
-
...normalizeParams(params)
|
|
5147
|
-
});
|
|
5289
|
+
return new Class(snapshotChecks({ type: "number", checks: [], ...normalizeParams(params) }));
|
|
5148
5290
|
}
|
|
5149
5291
|
function _int(Class, params) {
|
|
5150
5292
|
return new Class({
|
|
@@ -5400,7 +5542,7 @@ function handleUnrepresentable(schema, ctx, json, params, message) {
|
|
|
5400
5542
|
Object.assign(json, result);
|
|
5401
5543
|
return true;
|
|
5402
5544
|
}
|
|
5403
|
-
function
|
|
5545
|
+
function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
5404
5546
|
var _a;
|
|
5405
5547
|
const def = schema._zod.def;
|
|
5406
5548
|
const seen = ctx.seen.get(schema);
|
|
@@ -5439,7 +5581,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
5439
5581
|
if (parent) {
|
|
5440
5582
|
if (!result.ref)
|
|
5441
5583
|
result.ref = parent;
|
|
5442
|
-
|
|
5584
|
+
processSchema(parent, ctx, params);
|
|
5443
5585
|
ctx.seen.get(parent).isParent = true;
|
|
5444
5586
|
}
|
|
5445
5587
|
}
|
|
@@ -5544,7 +5686,6 @@ function extractDefs(ctx, schema) {
|
|
|
5544
5686
|
if (seen.count > 1) {
|
|
5545
5687
|
if (ctx.reused === "ref") {
|
|
5546
5688
|
extractToDef(entry);
|
|
5547
|
-
continue;
|
|
5548
5689
|
}
|
|
5549
5690
|
}
|
|
5550
5691
|
}
|
|
@@ -5869,18 +6010,106 @@ function isTransforming(_schema, _ctx) {
|
|
|
5869
6010
|
}
|
|
5870
6011
|
var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
5871
6012
|
const ctx = initializeContext({ ...params, processors });
|
|
5872
|
-
|
|
6013
|
+
processSchema(schema, ctx);
|
|
5873
6014
|
extractDefs(ctx, schema);
|
|
5874
6015
|
return finalize(ctx, schema);
|
|
5875
6016
|
};
|
|
5876
6017
|
var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
5877
6018
|
const { libraryOptions, target } = params ?? {};
|
|
5878
6019
|
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
5879
|
-
|
|
6020
|
+
processSchema(schema, ctx);
|
|
5880
6021
|
extractDefs(ctx, schema);
|
|
5881
6022
|
return finalize(ctx, schema);
|
|
5882
6023
|
};
|
|
5883
6024
|
// node_modules/zod/v4/core/json-schema-processors.js
|
|
6025
|
+
var narrowMin = (agg, key, value) => {
|
|
6026
|
+
if (agg[key] === undefined || value > agg[key])
|
|
6027
|
+
agg[key] = value;
|
|
6028
|
+
};
|
|
6029
|
+
var narrowMax = (agg, key, value) => {
|
|
6030
|
+
if (agg[key] === undefined || value < agg[key])
|
|
6031
|
+
agg[key] = value;
|
|
6032
|
+
};
|
|
6033
|
+
var narrowBoth = (agg, value) => {
|
|
6034
|
+
narrowMin(agg, "minimum", value);
|
|
6035
|
+
narrowMax(agg, "maximum", value);
|
|
6036
|
+
};
|
|
6037
|
+
var addDivisor = (agg, value) => {
|
|
6038
|
+
agg.multipleOf ?? (agg.multipleOf = []);
|
|
6039
|
+
if (!agg.multipleOf.includes(value))
|
|
6040
|
+
agg.multipleOf.push(value);
|
|
6041
|
+
};
|
|
6042
|
+
var addPattern = (agg, pattern) => {
|
|
6043
|
+
agg.patterns ?? (agg.patterns = new Set);
|
|
6044
|
+
agg.patterns.add(pattern);
|
|
6045
|
+
};
|
|
6046
|
+
var intersectMime = (agg, mime) => {
|
|
6047
|
+
agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
|
|
6048
|
+
};
|
|
6049
|
+
var setFormat = (agg, format) => {
|
|
6050
|
+
agg.format = format;
|
|
6051
|
+
if (format.includes("int"))
|
|
6052
|
+
agg.isInt = true;
|
|
6053
|
+
};
|
|
6054
|
+
var minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
|
|
6055
|
+
var maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
|
|
6056
|
+
var formatContributor = (ranges) => (agg, def) => {
|
|
6057
|
+
setFormat(agg, def.format);
|
|
6058
|
+
const [minimum, maximum] = ranges[def.format];
|
|
6059
|
+
narrowMin(agg, "minimum", minimum);
|
|
6060
|
+
narrowMax(agg, "maximum", maximum);
|
|
6061
|
+
};
|
|
6062
|
+
var contributors = {
|
|
6063
|
+
greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
|
|
6064
|
+
less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
|
|
6065
|
+
multiple_of: (agg, def) => addDivisor(agg, def.value),
|
|
6066
|
+
number_format: formatContributor(NUMBER_FORMAT_RANGES),
|
|
6067
|
+
bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
|
|
6068
|
+
min_length: minContributor,
|
|
6069
|
+
max_length: maxContributor,
|
|
6070
|
+
length_equals: (agg, def) => narrowBoth(agg, def.length),
|
|
6071
|
+
min_size: minContributor,
|
|
6072
|
+
max_size: maxContributor,
|
|
6073
|
+
size_equals: (agg, def) => narrowBoth(agg, def.size),
|
|
6074
|
+
string_format: (agg, def) => {
|
|
6075
|
+
setFormat(agg, def.format);
|
|
6076
|
+
if (def.pattern)
|
|
6077
|
+
addPattern(agg, def.pattern);
|
|
6078
|
+
if (def.format === "base64" || def.format === "base64url")
|
|
6079
|
+
agg.contentEncoding = def.format;
|
|
6080
|
+
if (def.local || def.precision === -1)
|
|
6081
|
+
agg.laxFormat = true;
|
|
6082
|
+
},
|
|
6083
|
+
mime_type: (agg, def) => intersectMime(agg, def.mime)
|
|
6084
|
+
};
|
|
6085
|
+
function aggregateChecks(schema) {
|
|
6086
|
+
const agg = {};
|
|
6087
|
+
const def = schema._zod.def;
|
|
6088
|
+
const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
6089
|
+
for (const ch of list)
|
|
6090
|
+
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
6091
|
+
const bag = schema._zod.bag;
|
|
6092
|
+
if (bag.minimum !== undefined)
|
|
6093
|
+
narrowMin(agg, "minimum", bag.minimum);
|
|
6094
|
+
if (bag.exclusiveMinimum !== undefined)
|
|
6095
|
+
narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
|
|
6096
|
+
if (bag.maximum !== undefined)
|
|
6097
|
+
narrowMax(agg, "maximum", bag.maximum);
|
|
6098
|
+
if (bag.exclusiveMaximum !== undefined)
|
|
6099
|
+
narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
|
|
6100
|
+
if (bag.multipleOf !== undefined)
|
|
6101
|
+
addDivisor(agg, bag.multipleOf);
|
|
6102
|
+
if (bag.format !== undefined) {
|
|
6103
|
+
agg.format ?? (agg.format = bag.format);
|
|
6104
|
+
if (bag.format.includes("int"))
|
|
6105
|
+
agg.isInt = true;
|
|
6106
|
+
}
|
|
6107
|
+
if (bag.mime)
|
|
6108
|
+
intersectMime(agg, bag.mime);
|
|
6109
|
+
for (const pattern of bag.patterns ?? [])
|
|
6110
|
+
addPattern(agg, pattern);
|
|
6111
|
+
return agg;
|
|
6112
|
+
}
|
|
5884
6113
|
var formatMap = {
|
|
5885
6114
|
guid: "uuid",
|
|
5886
6115
|
url: "uri",
|
|
@@ -5888,10 +6117,15 @@ var formatMap = {
|
|
|
5888
6117
|
json_string: "json-string",
|
|
5889
6118
|
regex: ""
|
|
5890
6119
|
};
|
|
6120
|
+
var exactPatterns = new Map([
|
|
6121
|
+
[base64Charset, base64],
|
|
6122
|
+
[base64urlCharset, base64url]
|
|
6123
|
+
]);
|
|
6124
|
+
var exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
5891
6125
|
var stringProcessor = (schema, ctx, _json, _params) => {
|
|
5892
6126
|
const json = _json;
|
|
5893
6127
|
json.type = "string";
|
|
5894
|
-
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = schema
|
|
6128
|
+
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
5895
6129
|
if (typeof minimum === "number")
|
|
5896
6130
|
json.minLength = minimum;
|
|
5897
6131
|
if (typeof maximum === "number")
|
|
@@ -5907,7 +6141,7 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
5907
6141
|
if (contentEncoding)
|
|
5908
6142
|
json.contentEncoding = contentEncoding;
|
|
5909
6143
|
if (patterns && patterns.size > 0) {
|
|
5910
|
-
const patternList = [...patterns];
|
|
6144
|
+
const patternList = [...patterns].map(exactPattern);
|
|
5911
6145
|
if (patternList.length === 1)
|
|
5912
6146
|
json.pattern = patternList[0].source;
|
|
5913
6147
|
else if (patternList.length > 1) {
|
|
@@ -5922,11 +6156,8 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
5922
6156
|
};
|
|
5923
6157
|
var numberProcessor = (schema, ctx, _json, params) => {
|
|
5924
6158
|
const json = _json;
|
|
5925
|
-
const { minimum, maximum,
|
|
5926
|
-
|
|
5927
|
-
json.type = "integer";
|
|
5928
|
-
else
|
|
5929
|
-
json.type = "number";
|
|
6159
|
+
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
6160
|
+
json.type = isInt ? "integer" : "number";
|
|
5930
6161
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
5931
6162
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
5932
6163
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
@@ -5950,11 +6181,19 @@ var numberProcessor = (schema, ctx, _json, params) => {
|
|
|
5950
6181
|
} else if (typeof maximum === "number") {
|
|
5951
6182
|
json.maximum = maximum;
|
|
5952
6183
|
}
|
|
5953
|
-
if (
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
6184
|
+
if (multipleOf) {
|
|
6185
|
+
const divisors = new Set;
|
|
6186
|
+
for (const divisor of multipleOf) {
|
|
6187
|
+
if (Number.isFinite(divisor) && divisor !== 0)
|
|
6188
|
+
divisors.add(Math.abs(divisor));
|
|
6189
|
+
else
|
|
6190
|
+
handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
6191
|
+
}
|
|
6192
|
+
const [first, ...rest] = divisors;
|
|
6193
|
+
if (first !== undefined)
|
|
6194
|
+
json.multipleOf = first;
|
|
6195
|
+
if (rest.length)
|
|
6196
|
+
json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
|
|
5958
6197
|
}
|
|
5959
6198
|
};
|
|
5960
6199
|
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
@@ -6025,13 +6264,13 @@ var transformProcessor = (schema, ctx, json, params) => {
|
|
|
6025
6264
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
6026
6265
|
const json = _json;
|
|
6027
6266
|
const def = schema._zod.def;
|
|
6028
|
-
const { minimum, maximum } = schema
|
|
6267
|
+
const { minimum, maximum } = aggregateChecks(schema);
|
|
6029
6268
|
if (typeof minimum === "number")
|
|
6030
6269
|
json.minItems = minimum;
|
|
6031
6270
|
if (typeof maximum === "number")
|
|
6032
6271
|
json.maxItems = maximum;
|
|
6033
6272
|
json.type = "array";
|
|
6034
|
-
json.items =
|
|
6273
|
+
json.items = processSchema(def.element, ctx, {
|
|
6035
6274
|
...params,
|
|
6036
6275
|
path: [...params.path, "items"]
|
|
6037
6276
|
});
|
|
@@ -6057,22 +6296,20 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
6057
6296
|
json.type = "object";
|
|
6058
6297
|
json.properties = {};
|
|
6059
6298
|
for (const key in shape) {
|
|
6060
|
-
assignProp(json.properties, key,
|
|
6299
|
+
assignProp(json.properties, key, processSchema(shape[key], ctx, {
|
|
6061
6300
|
...params,
|
|
6062
6301
|
path: [...params.path, "properties", key]
|
|
6063
6302
|
}));
|
|
6064
6303
|
}
|
|
6065
|
-
const
|
|
6066
|
-
const
|
|
6304
|
+
const requiredKeys = [];
|
|
6305
|
+
for (const key of Object.keys(shape)) {
|
|
6067
6306
|
const field = def.shape[key];
|
|
6068
|
-
if (ctx.io === "input") {
|
|
6069
|
-
|
|
6070
|
-
} else {
|
|
6071
|
-
return field._zod.optout === undefined;
|
|
6307
|
+
if (ctx.io === "input" ? inputOptin(field) === undefined : field._zod.optout === undefined) {
|
|
6308
|
+
requiredKeys.push(key);
|
|
6072
6309
|
}
|
|
6073
|
-
}
|
|
6074
|
-
if (requiredKeys.
|
|
6075
|
-
json.required =
|
|
6310
|
+
}
|
|
6311
|
+
if (requiredKeys.length > 0) {
|
|
6312
|
+
json.required = requiredKeys;
|
|
6076
6313
|
}
|
|
6077
6314
|
if (def.catchall?._zod.def.type === "never") {
|
|
6078
6315
|
json.additionalProperties = false;
|
|
@@ -6080,7 +6317,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
6080
6317
|
if (ctx.io === "output")
|
|
6081
6318
|
json.additionalProperties = false;
|
|
6082
6319
|
} else if (def.catchall) {
|
|
6083
|
-
json.additionalProperties =
|
|
6320
|
+
json.additionalProperties = processSchema(def.catchall, ctx, {
|
|
6084
6321
|
...params,
|
|
6085
6322
|
path: [...params.path, "additionalProperties"]
|
|
6086
6323
|
});
|
|
@@ -6089,7 +6326,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
6089
6326
|
var unionProcessor = (schema, ctx, json, params) => {
|
|
6090
6327
|
const def = schema._zod.def;
|
|
6091
6328
|
const isExclusive = def.inclusive === false;
|
|
6092
|
-
const options = def.options.map((x, i) =>
|
|
6329
|
+
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
6093
6330
|
...params,
|
|
6094
6331
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
6095
6332
|
}));
|
|
@@ -6101,11 +6338,11 @@ var unionProcessor = (schema, ctx, json, params) => {
|
|
|
6101
6338
|
};
|
|
6102
6339
|
var intersectionProcessor = (schema, ctx, json, params) => {
|
|
6103
6340
|
const def = schema._zod.def;
|
|
6104
|
-
const a =
|
|
6341
|
+
const a = processSchema(def.left, ctx, {
|
|
6105
6342
|
...params,
|
|
6106
6343
|
path: [...params.path, "allOf", 0]
|
|
6107
6344
|
});
|
|
6108
|
-
const b =
|
|
6345
|
+
const b = processSchema(def.right, ctx, {
|
|
6109
6346
|
...params,
|
|
6110
6347
|
path: [...params.path, "allOf", 1]
|
|
6111
6348
|
});
|
|
@@ -6185,20 +6422,19 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
6185
6422
|
const def = schema._zod.def;
|
|
6186
6423
|
json.type = "object";
|
|
6187
6424
|
const keyType = def.keyType;
|
|
6188
|
-
const
|
|
6189
|
-
const patterns = keyBag?.patterns;
|
|
6425
|
+
const patterns = aggregateChecks(keyType).patterns;
|
|
6190
6426
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
6191
|
-
const valueSchema =
|
|
6427
|
+
const valueSchema = processSchema(def.valueType, ctx, {
|
|
6192
6428
|
...params,
|
|
6193
6429
|
path: [...params.path, "patternProperties", "*"]
|
|
6194
6430
|
});
|
|
6195
6431
|
json.patternProperties = {};
|
|
6196
6432
|
for (const pattern of patterns) {
|
|
6197
|
-
assignProp(json.patternProperties, pattern.source, valueSchema);
|
|
6433
|
+
assignProp(json.patternProperties, exactPattern(pattern).source, valueSchema);
|
|
6198
6434
|
}
|
|
6199
6435
|
} else {
|
|
6200
6436
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
6201
|
-
json.propertyNames =
|
|
6437
|
+
json.propertyNames = processSchema(def.keyType, ctx, {
|
|
6202
6438
|
...params,
|
|
6203
6439
|
path: [...params.path, "propertyNames"]
|
|
6204
6440
|
});
|
|
@@ -6210,7 +6446,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
6210
6446
|
}
|
|
6211
6447
|
pending.push(schema);
|
|
6212
6448
|
}
|
|
6213
|
-
json.additionalProperties =
|
|
6449
|
+
json.additionalProperties = processSchema(def.valueType, ctx, {
|
|
6214
6450
|
...params,
|
|
6215
6451
|
path: [...params.path, "additionalProperties"]
|
|
6216
6452
|
});
|
|
@@ -6226,7 +6462,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
6226
6462
|
};
|
|
6227
6463
|
var nullableProcessor = (schema, ctx, json, params) => {
|
|
6228
6464
|
const def = schema._zod.def;
|
|
6229
|
-
const inner =
|
|
6465
|
+
const inner = processSchema(def.innerType, ctx, params);
|
|
6230
6466
|
const seen = ctx.seen.get(schema);
|
|
6231
6467
|
if (ctx.target === "openapi-3.0") {
|
|
6232
6468
|
seen.ref = def.innerType;
|
|
@@ -6237,7 +6473,7 @@ var nullableProcessor = (schema, ctx, json, params) => {
|
|
|
6237
6473
|
};
|
|
6238
6474
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
6239
6475
|
const def = schema._zod.def;
|
|
6240
|
-
|
|
6476
|
+
processSchema(def.innerType, ctx, params);
|
|
6241
6477
|
const seen = ctx.seen.get(schema);
|
|
6242
6478
|
seen.ref = def.innerType;
|
|
6243
6479
|
};
|
|
@@ -6257,7 +6493,7 @@ function serializeDefaultValue(value, schema, ctx, json, params) {
|
|
|
6257
6493
|
}
|
|
6258
6494
|
var defaultProcessor = (schema, ctx, json, params) => {
|
|
6259
6495
|
const def = schema._zod.def;
|
|
6260
|
-
|
|
6496
|
+
processSchema(def.innerType, ctx, params);
|
|
6261
6497
|
const seen = ctx.seen.get(schema);
|
|
6262
6498
|
seen.ref = def.innerType;
|
|
6263
6499
|
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
@@ -6266,7 +6502,7 @@ var defaultProcessor = (schema, ctx, json, params) => {
|
|
|
6266
6502
|
};
|
|
6267
6503
|
var prefaultProcessor = (schema, ctx, json, params) => {
|
|
6268
6504
|
const def = schema._zod.def;
|
|
6269
|
-
|
|
6505
|
+
processSchema(def.innerType, ctx, params);
|
|
6270
6506
|
const seen = ctx.seen.get(schema);
|
|
6271
6507
|
seen.ref = def.innerType;
|
|
6272
6508
|
if (ctx.io !== "input")
|
|
@@ -6277,7 +6513,7 @@ var prefaultProcessor = (schema, ctx, json, params) => {
|
|
|
6277
6513
|
};
|
|
6278
6514
|
var catchProcessor = (schema, ctx, json, params) => {
|
|
6279
6515
|
const def = schema._zod.def;
|
|
6280
|
-
|
|
6516
|
+
processSchema(def.innerType, ctx, params);
|
|
6281
6517
|
const seen = ctx.seen.get(schema);
|
|
6282
6518
|
seen.ref = def.innerType;
|
|
6283
6519
|
let catchValue;
|
|
@@ -6293,20 +6529,20 @@ var pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
6293
6529
|
const def = schema._zod.def;
|
|
6294
6530
|
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
6295
6531
|
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
6296
|
-
|
|
6532
|
+
processSchema(innerType, ctx, params);
|
|
6297
6533
|
const seen = ctx.seen.get(schema);
|
|
6298
6534
|
seen.ref = innerType;
|
|
6299
6535
|
};
|
|
6300
6536
|
var readonlyProcessor = (schema, ctx, json, params) => {
|
|
6301
6537
|
const def = schema._zod.def;
|
|
6302
|
-
|
|
6538
|
+
processSchema(def.innerType, ctx, params);
|
|
6303
6539
|
const seen = ctx.seen.get(schema);
|
|
6304
6540
|
seen.ref = def.innerType;
|
|
6305
6541
|
json.readOnly = true;
|
|
6306
6542
|
};
|
|
6307
6543
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
6308
6544
|
const def = schema._zod.def;
|
|
6309
|
-
|
|
6545
|
+
processSchema(def.innerType, ctx, params);
|
|
6310
6546
|
const seen = ctx.seen.get(schema);
|
|
6311
6547
|
seen.ref = def.innerType;
|
|
6312
6548
|
};
|
|
@@ -6356,10 +6592,10 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, undefi
|
|
|
6356
6592
|
});
|
|
6357
6593
|
|
|
6358
6594
|
// node_modules/zod/v4/classic/parse.js
|
|
6359
|
-
var
|
|
6360
|
-
var
|
|
6361
|
-
var
|
|
6362
|
-
var
|
|
6595
|
+
var parse2 = /* @__PURE__ */ _parse(ZodRealError);
|
|
6596
|
+
var parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
6597
|
+
var safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
6598
|
+
var safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
6363
6599
|
var encode = /* @__PURE__ */ _encode(ZodRealError);
|
|
6364
6600
|
var decode = /* @__PURE__ */ _decode(ZodRealError);
|
|
6365
6601
|
var encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
@@ -6492,16 +6728,16 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
6492
6728
|
own(this, "~standard", value);
|
|
6493
6729
|
},
|
|
6494
6730
|
parse: function _parse(data, params) {
|
|
6495
|
-
return
|
|
6731
|
+
return parse2(this, data, params, { callee: _parse });
|
|
6496
6732
|
},
|
|
6497
6733
|
parseAsync: async function _parseAsync(data, params) {
|
|
6498
|
-
return await
|
|
6734
|
+
return await parseAsync(this, data, params, { callee: _parseAsync });
|
|
6499
6735
|
},
|
|
6500
6736
|
safeParse(data, params) {
|
|
6501
|
-
return
|
|
6737
|
+
return safeParse(this, data, params);
|
|
6502
6738
|
},
|
|
6503
6739
|
async safeParseAsync(data, params) {
|
|
6504
|
-
return
|
|
6740
|
+
return safeParseAsync(this, data, params);
|
|
6505
6741
|
},
|
|
6506
6742
|
get spa() {
|
|
6507
6743
|
return this?.safeParseAsync;
|
|
@@ -6509,6 +6745,12 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
6509
6745
|
set spa(value) {
|
|
6510
6746
|
own(this, "spa", value);
|
|
6511
6747
|
},
|
|
6748
|
+
validate(data, params) {
|
|
6749
|
+
return validate(this, data, params);
|
|
6750
|
+
},
|
|
6751
|
+
validateAsync(data, params) {
|
|
6752
|
+
return validateAsync(this, data, params);
|
|
6753
|
+
},
|
|
6512
6754
|
encode: function _encode(data, params) {
|
|
6513
6755
|
return encode(this, data, params, { callee: _encode });
|
|
6514
6756
|
},
|
|
@@ -6547,10 +6789,10 @@ var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
|
6547
6789
|
$ZodString.init(inst, def);
|
|
6548
6790
|
ZodType.init(inst, def);
|
|
6549
6791
|
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6792
|
+
}, /* @__PURE__ */ derived({
|
|
6793
|
+
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
6794
|
+
minLength: (inst) => aggregateChecks(inst).minimum ?? null,
|
|
6795
|
+
maxLength: (inst) => aggregateChecks(inst).maximum ?? null
|
|
6554
6796
|
}, {
|
|
6555
6797
|
regex(...args) {
|
|
6556
6798
|
return this.check(_regex(...args));
|
|
@@ -6597,7 +6839,7 @@ var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
|
6597
6839
|
slugify() {
|
|
6598
6840
|
return this.check(_slugify());
|
|
6599
6841
|
}
|
|
6600
|
-
});
|
|
6842
|
+
}));
|
|
6601
6843
|
var ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
6602
6844
|
$ZodString.init(inst, def);
|
|
6603
6845
|
_ZodString.init(inst, def);
|
|
@@ -6784,12 +7026,21 @@ var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
|
6784
7026
|
$ZodNumber.init(inst, def);
|
|
6785
7027
|
ZodType.init(inst, def);
|
|
6786
7028
|
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
6787
|
-
const bag = inst._zod.bag;
|
|
6788
|
-
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
6789
|
-
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
6790
|
-
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
6791
7029
|
inst.isFinite = true;
|
|
6792
|
-
|
|
7030
|
+
}, /* @__PURE__ */ derived({
|
|
7031
|
+
minValue: (inst) => {
|
|
7032
|
+
const { minimum, exclusiveMinimum } = aggregateChecks(inst);
|
|
7033
|
+
return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
|
|
7034
|
+
},
|
|
7035
|
+
maxValue: (inst) => {
|
|
7036
|
+
const { maximum, exclusiveMaximum } = aggregateChecks(inst);
|
|
7037
|
+
return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
|
|
7038
|
+
},
|
|
7039
|
+
isInt: (inst) => {
|
|
7040
|
+
const { isInt, multipleOf } = aggregateChecks(inst);
|
|
7041
|
+
return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
|
|
7042
|
+
},
|
|
7043
|
+
format: (inst) => aggregateChecks(inst).format ?? null
|
|
6793
7044
|
}, {
|
|
6794
7045
|
gt(value, params) {
|
|
6795
7046
|
return this.check(_gt(value, params));
|
|
@@ -6836,7 +7087,7 @@ var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
|
6836
7087
|
finite() {
|
|
6837
7088
|
return this;
|
|
6838
7089
|
}
|
|
6839
|
-
});
|
|
7090
|
+
}));
|
|
6840
7091
|
function number2(params) {
|
|
6841
7092
|
return _number(ZodNumber, params);
|
|
6842
7093
|
}
|
|
@@ -6908,19 +7159,19 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
6908
7159
|
return _enum(Object.keys(this._zod.def.shape));
|
|
6909
7160
|
},
|
|
6910
7161
|
catchall(catchall) {
|
|
6911
|
-
return this.clone(
|
|
7162
|
+
return this.clone(mergeDefs(this._zod.def, { catchall }));
|
|
6912
7163
|
},
|
|
6913
7164
|
passthrough() {
|
|
6914
|
-
return this.clone(
|
|
7165
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
6915
7166
|
},
|
|
6916
7167
|
loose() {
|
|
6917
|
-
return this.clone(
|
|
7168
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
6918
7169
|
},
|
|
6919
7170
|
strict() {
|
|
6920
|
-
return this.clone(
|
|
7171
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
|
|
6921
7172
|
},
|
|
6922
7173
|
strip() {
|
|
6923
|
-
return this.clone(
|
|
7174
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: undefined }));
|
|
6924
7175
|
},
|
|
6925
7176
|
extend(incoming) {
|
|
6926
7177
|
return extend(this, incoming);
|
|
@@ -7021,7 +7272,7 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
7021
7272
|
ZodType.init(inst, def);
|
|
7022
7273
|
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
7023
7274
|
inst.enum = def.entries;
|
|
7024
|
-
inst.options =
|
|
7275
|
+
inst.options = [...inst._zod.values];
|
|
7025
7276
|
const keys = new Set(Object.keys(def.entries));
|
|
7026
7277
|
inst.extract = (values, params) => {
|
|
7027
7278
|
const newEntries = {};
|
|
@@ -7937,7 +8188,7 @@ var success = (revisionValue, workspaceRevisionValue, data) => ({
|
|
|
7937
8188
|
workspaceRevision: workspaceRevisionValue,
|
|
7938
8189
|
data
|
|
7939
8190
|
});
|
|
7940
|
-
var
|
|
8191
|
+
var failure2 = (code, error, details = {}) => ({ ok: false, schemaVersion: 1, code, error, details });
|
|
7941
8192
|
function canonical(value, seen) {
|
|
7942
8193
|
if (value === null || typeof value === "boolean" || typeof value === "string") {
|
|
7943
8194
|
if (typeof value === "string" && invalidUnicode(value))
|
|
@@ -7968,7 +8219,7 @@ function canonical(value, seen) {
|
|
|
7968
8219
|
throw new TypeError("symbol key is not JSON");
|
|
7969
8220
|
if (Object.keys(value).some((key) => invalidUnicode(key)))
|
|
7970
8221
|
throw new TypeError("invalid Unicode");
|
|
7971
|
-
result = Object.fromEntries(Object.keys(value).
|
|
8222
|
+
result = Object.fromEntries(Object.keys(value).toSorted().map((key) => [key, canonical(value[key], seen)]));
|
|
7972
8223
|
}
|
|
7973
8224
|
seen.delete(value);
|
|
7974
8225
|
return result;
|
|
@@ -7995,14 +8246,14 @@ var compareBooleanNullable = (left, right) => left === right ? 0 : left === null
|
|
|
7995
8246
|
function candidateDigest(input) {
|
|
7996
8247
|
const normalizedScope = {
|
|
7997
8248
|
description: input.scope.description,
|
|
7998
|
-
paths: [...input.scope.paths].
|
|
7999
|
-
exclusions: [...input.scope.exclusions].
|
|
8249
|
+
paths: [...input.scope.paths].toSorted(compareCodeUnits),
|
|
8250
|
+
exclusions: [...input.scope.exclusions].toSorted(compareCodeUnits)
|
|
8000
8251
|
};
|
|
8001
8252
|
return sha256({
|
|
8002
8253
|
scope: normalizedScope,
|
|
8003
8254
|
completeness: input.completeness,
|
|
8004
|
-
files: [...input.files].
|
|
8005
|
-
environment: input.environment.map(({ name, value }) => ({ name, value })).
|
|
8255
|
+
files: [...input.files].toSorted((left, right) => compareCodeUnits(left.path, right.path) || compareCodeUnits(left.kind, right.kind) || compareNullableText(left.digest, right.digest) || compareBooleanNullable(left.executable, right.executable)),
|
|
8256
|
+
environment: input.environment.map(({ name, value }) => ({ name, value })).toSorted((left, right) => compareCodeUnits(left.name, right.name) || compareNullableText(left.value, right.value)),
|
|
8006
8257
|
head: input.head
|
|
8007
8258
|
});
|
|
8008
8259
|
}
|
|
@@ -8340,10 +8591,10 @@ var parseWorkerResult = (events) => {
|
|
|
8340
8591
|
if (!parsed || parsed.type !== "workit_worker_result")
|
|
8341
8592
|
continue;
|
|
8342
8593
|
if (result)
|
|
8343
|
-
return
|
|
8594
|
+
return failure2("invalid_input", "worker emitted multiple results");
|
|
8344
8595
|
result = parsed.report;
|
|
8345
8596
|
}
|
|
8346
|
-
return result ? success(null, null, result) :
|
|
8597
|
+
return result ? success(null, null, result) : failure2("invalid_input", "worker result was not observed");
|
|
8347
8598
|
};
|
|
8348
8599
|
var appendBoundedStderr = (current, chunk) => {
|
|
8349
8600
|
const next = current + chunk;
|
|
@@ -8593,7 +8844,7 @@ var prepareWorkerLaunch = (binding, handle) => {
|
|
|
8593
8844
|
var commitWorkerNotStarted = (binding, handle) => {
|
|
8594
8845
|
const dispatch = handle.dispatch;
|
|
8595
8846
|
if (!dispatch)
|
|
8596
|
-
return
|
|
8847
|
+
return failure2("recovery_required", "worker launch reservation is not live");
|
|
8597
8848
|
const result = binding.core.commitWorkerDispatch({
|
|
8598
8849
|
dispatch,
|
|
8599
8850
|
taskId: binding.taskId,
|
|
@@ -8751,7 +9002,7 @@ var nativeWorkerForEvidence = (getHandle) => ({
|
|
|
8751
9002
|
const handle = getHandle();
|
|
8752
9003
|
const observed = observation;
|
|
8753
9004
|
if (!handle || caller.host !== "pi" || expected.workerId !== handle.workerId || typeof observed !== "object" || observed === null || observed.stage !== expected.stage || observed.sessionId !== handle.sessionId || handle.spawned || handle.child !== null || handle.exit !== null)
|
|
8754
|
-
return
|
|
9005
|
+
return failure2("permission_denied", "Pi worker dispatch was not observed by the host");
|
|
8755
9006
|
return success(null, null, {
|
|
8756
9007
|
kind: "host_observed",
|
|
8757
9008
|
host: "pi",
|
|
@@ -8763,7 +9014,7 @@ var nativeWorkerForEvidence = (getHandle) => ({
|
|
|
8763
9014
|
verifyWorker: ({ expected, caller, observation }) => {
|
|
8764
9015
|
const handle = getHandle();
|
|
8765
9016
|
if (!handle || caller.host !== "pi" || expected.workerId !== handle.workerId || expected.session?.kind !== "host" || expected.session.host !== "pi" || expected.session.handle !== handle.sessionId || typeof observation !== "object" || observation === null || observation.pid !== handle.pid)
|
|
8766
|
-
return
|
|
9017
|
+
return failure2("permission_denied", "Pi worker identity was not observed");
|
|
8767
9018
|
return {
|
|
8768
9019
|
ok: true,
|
|
8769
9020
|
schemaVersion: 1,
|
|
@@ -8782,7 +9033,7 @@ var nativeWorkerForEvidence = (getHandle) => ({
|
|
|
8782
9033
|
var nativeLostWorker = () => ({
|
|
8783
9034
|
verifyWorker: ({ expected, caller, observation }) => {
|
|
8784
9035
|
if (caller.host !== "pi" || expected.session?.kind !== "host" || expected.session.host !== "pi" || typeof observation !== "object" || observation === null || observation.lost !== true || observation.sessionId !== expected.session.handle)
|
|
8785
|
-
return
|
|
9036
|
+
return failure2("permission_denied", "Pi worker loss was not observed by the host");
|
|
8786
9037
|
return {
|
|
8787
9038
|
ok: true,
|
|
8788
9039
|
schemaVersion: 1,
|
|
@@ -8850,7 +9101,7 @@ var reconcileWorker = (handle) => {
|
|
|
8850
9101
|
stderr: handle.stderr
|
|
8851
9102
|
};
|
|
8852
9103
|
}
|
|
8853
|
-
return
|
|
9104
|
+
return failure2("recovery_required", "worker exit has not been observed");
|
|
8854
9105
|
};
|
|
8855
9106
|
var workerCanLaunchNested = () => !process.env.WORKIT_PI_WORKER_ID;
|
|
8856
9107
|
export {
|