@cortexkit/pi-magic-context 0.49.20 → 0.49.21
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/auto-search-worker.js +6 -6
- package/dist/chunk-embedding-write-worker.js +9 -9
- package/dist/{compaction-marker-candidates-fnm47jat.js → compaction-marker-candidates-p1kqkqhq.js} +2 -2
- package/dist/compaction-marker-candidates-worker.js +2 -2
- package/dist/{compartment-chunk-embedding-81qesfjs.js → compartment-chunk-embedding-y01m95c2.js} +5 -5
- package/dist/{embedding-backfill-56e871c6.js → embedding-backfill-2vh6m3bg.js} +11 -11
- package/dist/embedding-worker-process.js +1 -1
- package/dist/embedding-worker.js +4 -4
- package/dist/{index-dzem6gn9.js → index-29nw7n1r.js} +1 -1
- package/dist/{index-hws5f0z9.js → index-2qtx0q6h.js} +213 -4
- package/dist/{index-5vgt1zeh.js → index-3c3ztwgc.js} +2 -2
- package/dist/{index-rgfb753z.js → index-579m1751.js} +2 -2
- package/dist/{index-kqb3d8bs.js → index-5j6vwg4z.js} +148 -11
- package/dist/{index-6kb2xpw7.js → index-6wdwv3a6.js} +1 -1
- package/dist/{index-rfyvax95.js → index-at6py2k3.js} +1 -1
- package/dist/{index-bxmf4dhr.js → index-ccanzg8p.js} +2367 -1243
- package/dist/{index-mtvvhcw4.js → index-dbgg6hsf.js} +24 -10
- package/dist/{index-af9t637y.js → index-ftvm2acc.js} +121 -38
- package/dist/{index-zhwwp8zz.js → index-gqjxy2p7.js} +14 -4
- package/dist/{index-jxjr7kz9.js → index-gwxaz0z5.js} +2 -4
- package/dist/{index-p63nwn5v.js → index-hxp6q5f8.js} +1 -1
- package/dist/{index-qerzchrs.js → index-j3pz3a1b.js} +1 -1
- package/dist/{index-bttctq07.js → index-n8e5e9fp.js} +6 -3
- package/dist/{index-b8am7tns.js → index-pe5gz5c4.js} +4 -4
- package/dist/{index-tb3d9trm.js → index-st4gwt64.js} +1 -1
- package/dist/{index-5n5zxs8e.js → index-vx6f7wff.js} +2 -2
- package/dist/{index-v2epyzbm.js → index-w1twp2kp.js} +9 -7
- package/dist/{index-jt0g3hn0.js → index-w6r3ggnp.js} +35 -17
- package/dist/{index-vdy273xw.js → index-wgmhk91m.js} +10 -4
- package/dist/{index-e19qtjj0.js → index-wqpjhx1p.js} +35 -4
- package/dist/index.js +224 -206
- package/dist/{message-fts-rowid-map-bpexnsdj.js → message-fts-rowid-map-59y476bk.js} +3 -3
- package/dist/{message-index-mvag9crh.js → message-index-3snxf11x.js} +9 -9
- package/dist/{message-index-bounded-d4r3weh0.js → message-index-bounded-4ngt600v.js} +9 -9
- package/dist/{message-time-backfill-kc10yrcj.js → message-time-backfill-e3r8ddh1.js} +1 -1
- package/dist/migration-worker.js +6 -6
- package/dist/{project-embedding-registry-cfrg952x.js → project-embedding-registry-hfyzs654.js} +10 -10
- package/dist/raw-ordinal-warmup-worker.js +8 -8
- package/dist/{read-session-chunk-7g4zvpd8.js → read-session-chunk-5dmc77q2.js} +5 -5
- package/dist/{read-session-raw-0fsjh10f.js → read-session-raw-yxv2fv34.js} +2 -2
- package/dist/{search-archive-qbhp7e89.js → search-archive-3daj5ttc.js} +6 -6
- package/dist/{search-hp4g3g9v.js → search-jhfh3tsj.js} +17 -17
- package/dist/{sqlite-d67n6dtr.js → sqlite-v89bj0yy.js} +7 -1
- package/dist/{storage-memory-9g882j7a.js → storage-memory-0ndn65fm.js} +2 -2
- package/dist/{storage-tags-m2qcp1g2.js → storage-tags-r48vxthe.js} +2 -2
- package/dist/subagent-entry.js +22 -21
- package/dist/tag-snapshot-worker-pi.js +8 -8
- package/package.json +5 -2
|
@@ -67,82 +67,7 @@ function resolveModelRefForOmp(ref) {
|
|
|
67
67
|
// ../plugin/src/config/schema/magic-context.ts
|
|
68
68
|
import { homedir } from "node:os";
|
|
69
69
|
|
|
70
|
-
// ../../node_modules/.bun/zod@4.
|
|
71
|
-
var _a;
|
|
72
|
-
function $constructor(name, initializer, params) {
|
|
73
|
-
function init(inst, def) {
|
|
74
|
-
if (!inst._zod) {
|
|
75
|
-
Object.defineProperty(inst, "_zod", {
|
|
76
|
-
value: {
|
|
77
|
-
def,
|
|
78
|
-
constr: _,
|
|
79
|
-
traits: new Set
|
|
80
|
-
},
|
|
81
|
-
enumerable: false
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
if (inst._zod.traits.has(name)) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
inst._zod.traits.add(name);
|
|
88
|
-
initializer(inst, def);
|
|
89
|
-
const proto = _.prototype;
|
|
90
|
-
const keys = Object.keys(proto);
|
|
91
|
-
for (let i = 0;i < keys.length; i++) {
|
|
92
|
-
const k = keys[i];
|
|
93
|
-
if (!(k in inst)) {
|
|
94
|
-
inst[k] = proto[k].bind(inst);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
const Parent = params?.Parent ?? Object;
|
|
99
|
-
|
|
100
|
-
class Definition extends Parent {
|
|
101
|
-
}
|
|
102
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
103
|
-
function _(def) {
|
|
104
|
-
var _a;
|
|
105
|
-
const inst = params?.Parent ? new Definition : this;
|
|
106
|
-
init(inst, def);
|
|
107
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
108
|
-
for (const fn of inst._zod.deferred) {
|
|
109
|
-
fn();
|
|
110
|
-
}
|
|
111
|
-
return inst;
|
|
112
|
-
}
|
|
113
|
-
Object.defineProperty(_, "init", { value: init });
|
|
114
|
-
Object.defineProperty(_, Symbol.hasInstance, {
|
|
115
|
-
value: (inst) => {
|
|
116
|
-
if (params?.Parent && inst instanceof params.Parent)
|
|
117
|
-
return true;
|
|
118
|
-
return inst?._zod?.traits?.has(name);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
Object.defineProperty(_, "name", { value: name });
|
|
122
|
-
return _;
|
|
123
|
-
}
|
|
124
|
-
var $brand = Symbol("zod_brand");
|
|
125
|
-
|
|
126
|
-
class $ZodAsyncError extends Error {
|
|
127
|
-
constructor() {
|
|
128
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
class $ZodEncodeError extends Error {
|
|
133
|
-
constructor(name) {
|
|
134
|
-
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
135
|
-
this.name = "ZodEncodeError";
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
139
|
-
var globalConfig = globalThis.__zod_globalConfig;
|
|
140
|
-
function config(newConfig) {
|
|
141
|
-
if (newConfig)
|
|
142
|
-
Object.assign(globalConfig, newConfig);
|
|
143
|
-
return globalConfig;
|
|
144
|
-
}
|
|
145
|
-
// ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/util.js
|
|
70
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/util.js
|
|
146
71
|
function getEnumValues(entries) {
|
|
147
72
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
148
73
|
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
@@ -156,18 +81,23 @@ function jsonStringifyReplacer(_, value) {
|
|
|
156
81
|
return value.toString();
|
|
157
82
|
return value;
|
|
158
83
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
84
|
+
|
|
85
|
+
class Cached {
|
|
86
|
+
constructor(getter) {
|
|
87
|
+
this._getter = getter;
|
|
88
|
+
this._value = undefined;
|
|
89
|
+
}
|
|
90
|
+
get value() {
|
|
91
|
+
const getter = this._getter;
|
|
92
|
+
if (getter !== undefined) {
|
|
93
|
+
this._value = getter();
|
|
94
|
+
this._getter = undefined;
|
|
169
95
|
}
|
|
170
|
-
|
|
96
|
+
return this._value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function cached(getter) {
|
|
100
|
+
return new Cached(getter);
|
|
171
101
|
}
|
|
172
102
|
function nullish(input) {
|
|
173
103
|
return input === null || input === undefined;
|
|
@@ -180,33 +110,11 @@ function cleanRegex(source) {
|
|
|
180
110
|
function floatSafeRemainder(val, step) {
|
|
181
111
|
const ratio = val / step;
|
|
182
112
|
const roundedRatio = Math.round(ratio);
|
|
183
|
-
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
113
|
+
const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
184
114
|
if (Math.abs(ratio - roundedRatio) < tolerance)
|
|
185
115
|
return 0;
|
|
186
116
|
return ratio - roundedRatio;
|
|
187
117
|
}
|
|
188
|
-
var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
|
|
189
|
-
function defineLazy(object, key, getter) {
|
|
190
|
-
let value = undefined;
|
|
191
|
-
Object.defineProperty(object, key, {
|
|
192
|
-
get() {
|
|
193
|
-
if (value === EVALUATING) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
if (value === undefined) {
|
|
197
|
-
value = EVALUATING;
|
|
198
|
-
value = getter();
|
|
199
|
-
}
|
|
200
|
-
return value;
|
|
201
|
-
},
|
|
202
|
-
set(v) {
|
|
203
|
-
Object.defineProperty(object, key, {
|
|
204
|
-
value: v
|
|
205
|
-
});
|
|
206
|
-
},
|
|
207
|
-
configurable: true
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
118
|
function assignProp(target, prop, value) {
|
|
211
119
|
Object.defineProperty(target, prop, {
|
|
212
120
|
value,
|
|
@@ -215,6 +123,56 @@ function assignProp(target, prop, value) {
|
|
|
215
123
|
configurable: true
|
|
216
124
|
});
|
|
217
125
|
}
|
|
126
|
+
function rawShape(def) {
|
|
127
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
128
|
+
return desc?.get ? desc.get.raw : desc?.value;
|
|
129
|
+
}
|
|
130
|
+
function sourceShape(schema) {
|
|
131
|
+
return rawShape(schema._zod.def) ?? schema._zod.def.shape;
|
|
132
|
+
}
|
|
133
|
+
function deferProp(target, key, getter) {
|
|
134
|
+
Object.defineProperty(target, key, {
|
|
135
|
+
get() {
|
|
136
|
+
const value = getter();
|
|
137
|
+
assignProp(this, key, value);
|
|
138
|
+
return value;
|
|
139
|
+
},
|
|
140
|
+
enumerable: true,
|
|
141
|
+
configurable: true
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function putProp(target, key, value) {
|
|
145
|
+
if (key in target)
|
|
146
|
+
assignProp(target, key, value);
|
|
147
|
+
else
|
|
148
|
+
target[key] = value;
|
|
149
|
+
}
|
|
150
|
+
function mirrorShape(target, source, keys, wrap) {
|
|
151
|
+
const raw = sourceShape(source);
|
|
152
|
+
for (const key of keys) {
|
|
153
|
+
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
154
|
+
if (!desc.enumerable)
|
|
155
|
+
continue;
|
|
156
|
+
if (desc.get) {
|
|
157
|
+
deferProp(target, key, () => {
|
|
158
|
+
const value = source._zod.def.shape[key];
|
|
159
|
+
return wrap ? wrap(value, key) : value;
|
|
160
|
+
});
|
|
161
|
+
} else
|
|
162
|
+
putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function mirrorProps(target, source) {
|
|
166
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
167
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
168
|
+
if (!desc.enumerable)
|
|
169
|
+
continue;
|
|
170
|
+
if (desc.get)
|
|
171
|
+
deferProp(target, key, () => source[key]);
|
|
172
|
+
else
|
|
173
|
+
putProp(target, key, desc.value);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
218
176
|
function mergeDefs(...defs) {
|
|
219
177
|
const mergedDescriptors = {};
|
|
220
178
|
for (const def of defs) {
|
|
@@ -310,15 +268,19 @@ function stringifyPrimitive(value) {
|
|
|
310
268
|
}
|
|
311
269
|
function optionalKeys(shape) {
|
|
312
270
|
return Object.keys(shape).filter((k) => {
|
|
313
|
-
return shape[k]._zod.optin
|
|
271
|
+
return shape[k]._zod.optin !== undefined && shape[k]._zod.optout === "optional";
|
|
314
272
|
});
|
|
315
273
|
}
|
|
316
|
-
var NUMBER_FORMAT_RANGES = {
|
|
274
|
+
var NUMBER_FORMAT_RANGES = /* @__PURE__ */ (() => ({
|
|
317
275
|
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
318
276
|
int32: [-2147483648, 2147483647],
|
|
319
277
|
uint32: [0, 4294967295],
|
|
320
278
|
float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000],
|
|
321
279
|
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
280
|
+
}))();
|
|
281
|
+
var BIGINT_FORMAT_RANGES = {
|
|
282
|
+
int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
|
|
283
|
+
uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
|
|
322
284
|
};
|
|
323
285
|
function pick(schema, mask) {
|
|
324
286
|
const currDef = schema._zod.def;
|
|
@@ -327,23 +289,21 @@ function pick(schema, mask) {
|
|
|
327
289
|
if (hasChecks) {
|
|
328
290
|
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
329
291
|
}
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
});
|
|
346
|
-
return clone(schema, def);
|
|
292
|
+
const newShape = {};
|
|
293
|
+
mirrorShape(newShape, schema, maskedKeys(schema, mask));
|
|
294
|
+
return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
295
|
+
}
|
|
296
|
+
function maskedKeys(schema, mask) {
|
|
297
|
+
const raw = sourceShape(schema);
|
|
298
|
+
const keys = [];
|
|
299
|
+
for (const key of Reflect.ownKeys(mask)) {
|
|
300
|
+
if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) {
|
|
301
|
+
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
302
|
+
}
|
|
303
|
+
if (mask[key])
|
|
304
|
+
keys.push(key);
|
|
305
|
+
}
|
|
306
|
+
return keys;
|
|
347
307
|
}
|
|
348
308
|
function omit(schema, mask) {
|
|
349
309
|
const currDef = schema._zod.def;
|
|
@@ -352,23 +312,10 @@ function omit(schema, mask) {
|
|
|
352
312
|
if (hasChecks) {
|
|
353
313
|
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
354
314
|
}
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
if (!(key in currDef.shape)) {
|
|
360
|
-
throw new Error(`Unrecognized key: "${key}"`);
|
|
361
|
-
}
|
|
362
|
-
if (!mask[key])
|
|
363
|
-
continue;
|
|
364
|
-
delete newShape[key];
|
|
365
|
-
}
|
|
366
|
-
assignProp(this, "shape", newShape);
|
|
367
|
-
return newShape;
|
|
368
|
-
},
|
|
369
|
-
checks: []
|
|
370
|
-
});
|
|
371
|
-
return clone(schema, def);
|
|
315
|
+
const omitted = new Set(maskedKeys(schema, mask));
|
|
316
|
+
const newShape = {};
|
|
317
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
|
|
318
|
+
return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
372
319
|
}
|
|
373
320
|
function extend(schema, shape) {
|
|
374
321
|
if (!isPlainObject(shape)) {
|
|
@@ -377,45 +324,39 @@ function extend(schema, shape) {
|
|
|
377
324
|
const checks = schema._zod.def.checks;
|
|
378
325
|
const hasChecks = checks && checks.length > 0;
|
|
379
326
|
if (hasChecks) {
|
|
380
|
-
const existingShape = schema
|
|
381
|
-
for (const key
|
|
327
|
+
const existingShape = sourceShape(schema);
|
|
328
|
+
for (const key of Reflect.ownKeys(shape)) {
|
|
382
329
|
if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
|
|
383
330
|
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
384
331
|
}
|
|
385
332
|
}
|
|
386
333
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
return clone(schema, def);
|
|
334
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
335
|
+
}
|
|
336
|
+
function extended(schema, shape) {
|
|
337
|
+
const newShape = {};
|
|
338
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
|
|
339
|
+
mirrorProps(newShape, shape);
|
|
340
|
+
return newShape;
|
|
395
341
|
}
|
|
396
342
|
function safeExtend(schema, shape) {
|
|
397
343
|
if (!isPlainObject(shape)) {
|
|
398
344
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
399
345
|
}
|
|
400
|
-
|
|
401
|
-
get shape() {
|
|
402
|
-
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
403
|
-
assignProp(this, "shape", _shape);
|
|
404
|
-
return _shape;
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
return clone(schema, def);
|
|
346
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
408
347
|
}
|
|
409
348
|
function merge(a, b) {
|
|
349
|
+
if (!b?._zod?.def) {
|
|
350
|
+
throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
|
|
351
|
+
}
|
|
410
352
|
if (a._zod.def.checks?.length) {
|
|
411
353
|
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
412
354
|
}
|
|
355
|
+
const newShape = {};
|
|
356
|
+
mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
|
|
357
|
+
mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
|
|
413
358
|
const def = mergeDefs(a._zod.def, {
|
|
414
|
-
|
|
415
|
-
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
416
|
-
assignProp(this, "shape", _shape);
|
|
417
|
-
return _shape;
|
|
418
|
-
},
|
|
359
|
+
shape: newShape,
|
|
419
360
|
get catchall() {
|
|
420
361
|
return b._zod.def.catchall;
|
|
421
362
|
},
|
|
@@ -423,74 +364,23 @@ function merge(a, b) {
|
|
|
423
364
|
});
|
|
424
365
|
return clone(a, def);
|
|
425
366
|
}
|
|
426
|
-
function partial(Class, schema, mask) {
|
|
367
|
+
function partial(Class, schema, mask, name = "partial") {
|
|
427
368
|
const currDef = schema._zod.def;
|
|
428
369
|
const checks = currDef.checks;
|
|
429
370
|
const hasChecks = checks && checks.length > 0;
|
|
430
371
|
if (hasChecks) {
|
|
431
|
-
throw new Error(
|
|
432
|
-
}
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
if (mask) {
|
|
438
|
-
for (const key in mask) {
|
|
439
|
-
if (!(key in oldShape)) {
|
|
440
|
-
throw new Error(`Unrecognized key: "${key}"`);
|
|
441
|
-
}
|
|
442
|
-
if (!mask[key])
|
|
443
|
-
continue;
|
|
444
|
-
shape[key] = Class ? new Class({
|
|
445
|
-
type: "optional",
|
|
446
|
-
innerType: oldShape[key]
|
|
447
|
-
}) : oldShape[key];
|
|
448
|
-
}
|
|
449
|
-
} else {
|
|
450
|
-
for (const key in oldShape) {
|
|
451
|
-
shape[key] = Class ? new Class({
|
|
452
|
-
type: "optional",
|
|
453
|
-
innerType: oldShape[key]
|
|
454
|
-
}) : oldShape[key];
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
assignProp(this, "shape", shape);
|
|
458
|
-
return shape;
|
|
459
|
-
},
|
|
460
|
-
checks: []
|
|
461
|
-
});
|
|
462
|
-
return clone(schema, def);
|
|
372
|
+
throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
|
|
373
|
+
}
|
|
374
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;
|
|
375
|
+
const newShape = {};
|
|
376
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({ type: "optional", innerType: value })));
|
|
377
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: newShape, checks: [] }));
|
|
463
378
|
}
|
|
464
379
|
function required(Class, schema, mask) {
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
if (mask) {
|
|
470
|
-
for (const key in mask) {
|
|
471
|
-
if (!(key in shape)) {
|
|
472
|
-
throw new Error(`Unrecognized key: "${key}"`);
|
|
473
|
-
}
|
|
474
|
-
if (!mask[key])
|
|
475
|
-
continue;
|
|
476
|
-
shape[key] = new Class({
|
|
477
|
-
type: "nonoptional",
|
|
478
|
-
innerType: oldShape[key]
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
} else {
|
|
482
|
-
for (const key in oldShape) {
|
|
483
|
-
shape[key] = new Class({
|
|
484
|
-
type: "nonoptional",
|
|
485
|
-
innerType: oldShape[key]
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
assignProp(this, "shape", shape);
|
|
490
|
-
return shape;
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
return clone(schema, def);
|
|
380
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;
|
|
381
|
+
const newShape = {};
|
|
382
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({ type: "nonoptional", innerType: value }));
|
|
383
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
|
|
494
384
|
}
|
|
495
385
|
function aborted(x, startIndex = 0) {
|
|
496
386
|
if (x.aborted === true)
|
|
@@ -523,15 +413,61 @@ function prefixIssues(path, issues) {
|
|
|
523
413
|
function unwrapMessage(message) {
|
|
524
414
|
return typeof message === "string" ? message : message?.message;
|
|
525
415
|
}
|
|
416
|
+
function sizeCaps(defChecks) {
|
|
417
|
+
const caps = [];
|
|
418
|
+
for (const ch of defChecks ?? []) {
|
|
419
|
+
const d = ch._zod.def;
|
|
420
|
+
if (!/_(length|size)$|_equals$/.test(d.check))
|
|
421
|
+
break;
|
|
422
|
+
const max = d.maximum ?? d.length ?? d.size;
|
|
423
|
+
if (max >= 0)
|
|
424
|
+
caps.push([max, ch]);
|
|
425
|
+
}
|
|
426
|
+
return caps;
|
|
427
|
+
}
|
|
428
|
+
function attachSchema(issues, start, inst) {
|
|
429
|
+
var _a;
|
|
430
|
+
for (let i = start;i < issues.length; i++) {
|
|
431
|
+
(_a = issues[i]).schema ?? (_a.schema = inst);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
526
434
|
function finalizeIssue(iss, ctx, config) {
|
|
527
|
-
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
435
|
+
var _a;
|
|
436
|
+
const traits = iss.inst?._zod?.traits;
|
|
437
|
+
if (traits?.has("$ZodType")) {
|
|
438
|
+
if (traits.has("$ZodCheck"))
|
|
439
|
+
(_a = iss).schema ?? (_a.schema = iss.inst);
|
|
440
|
+
else
|
|
441
|
+
iss.schema = iss.inst;
|
|
442
|
+
}
|
|
443
|
+
const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : undefined;
|
|
444
|
+
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";
|
|
445
|
+
const full = {};
|
|
446
|
+
for (const k of Object.keys(iss)) {
|
|
447
|
+
if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__")
|
|
448
|
+
continue;
|
|
449
|
+
full[k] = iss[k];
|
|
450
|
+
}
|
|
451
|
+
full.path ?? (full.path = []);
|
|
452
|
+
full.message = message;
|
|
531
453
|
if (ctx?.reportInput) {
|
|
532
|
-
|
|
454
|
+
full.input = iss.input;
|
|
533
455
|
}
|
|
534
|
-
return
|
|
456
|
+
return full;
|
|
457
|
+
}
|
|
458
|
+
var highSurrogate = /[\uD800-\uDBFF]/;
|
|
459
|
+
function codePointLength(str) {
|
|
460
|
+
const units = str.length;
|
|
461
|
+
if (!highSurrogate.test(str))
|
|
462
|
+
return units;
|
|
463
|
+
let count = units;
|
|
464
|
+
for (let i = 0;i < units - 1; i++) {
|
|
465
|
+
if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
|
466
|
+
count--;
|
|
467
|
+
i++;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return count;
|
|
535
471
|
}
|
|
536
472
|
function getLengthableOrigin(input) {
|
|
537
473
|
if (Array.isArray(input))
|
|
@@ -573,33 +509,297 @@ function issue(...args) {
|
|
|
573
509
|
}
|
|
574
510
|
return { ...iss };
|
|
575
511
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
512
|
+
function members(proto, table) {
|
|
513
|
+
for (const key in table) {
|
|
514
|
+
const desc = Object.getOwnPropertyDescriptor(table, key);
|
|
515
|
+
if (desc.get)
|
|
516
|
+
Object.defineProperty(proto, key, { ...desc, enumerable: false });
|
|
517
|
+
else
|
|
518
|
+
defineBound(proto, key, desc.value);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
function own(inst, key, value, enumerable = true) {
|
|
522
|
+
Object.defineProperty(inst, key, { configurable: true, writable: true, enumerable, value });
|
|
523
|
+
return value;
|
|
524
|
+
}
|
|
525
|
+
function hide(inst, key, value) {
|
|
526
|
+
return own(inst, key, value, false);
|
|
527
|
+
}
|
|
528
|
+
function derived(computes, table) {
|
|
529
|
+
for (const key in computes) {
|
|
530
|
+
const compute = computes[key];
|
|
531
|
+
Object.defineProperty(table, key, {
|
|
532
|
+
configurable: true,
|
|
533
|
+
enumerable: true,
|
|
534
|
+
get() {
|
|
535
|
+
return own(this, key, compute(this));
|
|
536
|
+
},
|
|
537
|
+
set(value) {
|
|
538
|
+
own(this, key, value);
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
return table;
|
|
543
|
+
}
|
|
544
|
+
function defineBound(proto, key, fn) {
|
|
545
|
+
Object.defineProperty(proto, key, {
|
|
546
|
+
configurable: true,
|
|
547
|
+
get() {
|
|
548
|
+
return this == null ? fn : own(this, key, fn.bind(this));
|
|
549
|
+
},
|
|
550
|
+
set(value) {
|
|
551
|
+
own(this, key, value);
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
function claim(inst, sentinel) {
|
|
556
|
+
const proto = Object.getPrototypeOf(inst);
|
|
557
|
+
return sentinel in proto ? undefined : proto;
|
|
558
|
+
}
|
|
559
|
+
var installing;
|
|
560
|
+
var broke = false;
|
|
561
|
+
var breaker = {
|
|
562
|
+
configurable: true,
|
|
563
|
+
get() {
|
|
564
|
+
broke = true;
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
function defineLazyInternal(inst, key, compute) {
|
|
569
|
+
const proto = Object.getPrototypeOf(inst._zod);
|
|
570
|
+
if (key in proto && installing !== inst._zod) {
|
|
571
|
+
installing = undefined;
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
installing = inst._zod;
|
|
575
|
+
Object.defineProperty(proto, key, {
|
|
576
|
+
configurable: true,
|
|
577
|
+
get() {
|
|
578
|
+
Object.defineProperty(this, key, breaker);
|
|
579
|
+
const outer = broke;
|
|
580
|
+
broke = false;
|
|
581
|
+
try {
|
|
582
|
+
const value = compute(this);
|
|
583
|
+
if (broke)
|
|
584
|
+
delete this[key];
|
|
585
|
+
else
|
|
586
|
+
Object.defineProperty(this, key, { configurable: true, writable: true, value });
|
|
587
|
+
broke = broke || outer;
|
|
588
|
+
return value;
|
|
589
|
+
} catch (err) {
|
|
590
|
+
delete this[key];
|
|
591
|
+
broke = broke || outer;
|
|
592
|
+
throw err;
|
|
593
|
+
}
|
|
594
|
+
},
|
|
595
|
+
set(value) {
|
|
596
|
+
Object.defineProperty(this, key, { configurable: true, writable: true, value });
|
|
597
|
+
}
|
|
583
598
|
});
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
599
|
+
}
|
|
600
|
+
function installLazyProp(inst, key, make, enumerable) {
|
|
601
|
+
const proto = claim(inst, key);
|
|
602
|
+
if (!proto)
|
|
603
|
+
return;
|
|
604
|
+
Object.defineProperty(proto, key, {
|
|
605
|
+
configurable: true,
|
|
606
|
+
get() {
|
|
607
|
+
const desc = { configurable: true, writable: true, enumerable, value: undefined };
|
|
608
|
+
Object.defineProperty(this, key, desc);
|
|
609
|
+
desc.value = make(this);
|
|
610
|
+
Object.defineProperty(this, key, desc);
|
|
611
|
+
return desc.value;
|
|
612
|
+
},
|
|
613
|
+
set(value) {
|
|
614
|
+
Object.defineProperty(this, key, { configurable: true, writable: true, enumerable, value });
|
|
615
|
+
}
|
|
587
616
|
});
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
617
|
+
}
|
|
618
|
+
var CONSTANT_CATCH = "~constantCatch";
|
|
619
|
+
function constantCatch(value) {
|
|
620
|
+
const fn = () => value;
|
|
621
|
+
fn[CONSTANT_CATCH] = true;
|
|
622
|
+
return fn;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/core.js
|
|
626
|
+
var _a;
|
|
627
|
+
var _zodDesc = { value: undefined, enumerable: false };
|
|
628
|
+
var _E = "captureStackTrace" in Error ? Error : null;
|
|
629
|
+
function newError(Definition) {
|
|
630
|
+
const E = _E;
|
|
631
|
+
if (E) {
|
|
632
|
+
const saved = E.stackTraceLimit;
|
|
633
|
+
if (typeof saved === "number") {
|
|
634
|
+
try {
|
|
635
|
+
E.stackTraceLimit = 0;
|
|
636
|
+
} catch {
|
|
637
|
+
_E = null;
|
|
638
|
+
return new Definition;
|
|
639
|
+
}
|
|
640
|
+
try {
|
|
641
|
+
return new Definition;
|
|
642
|
+
} finally {
|
|
643
|
+
E.stackTraceLimit = saved;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
return new Definition;
|
|
648
|
+
}
|
|
649
|
+
function $constructor(name, initializer, proto, params) {
|
|
650
|
+
const zodProto = {};
|
|
651
|
+
function Internals(def) {
|
|
652
|
+
this.def = def;
|
|
653
|
+
this.constr = _;
|
|
654
|
+
this.traits = new Set;
|
|
655
|
+
}
|
|
656
|
+
Internals.prototype = zodProto;
|
|
657
|
+
const protoMembers = proto;
|
|
658
|
+
const initialized = protoMembers && new WeakSet;
|
|
659
|
+
function init(inst, def) {
|
|
660
|
+
if (!inst._zod) {
|
|
661
|
+
_zodDesc.value = new Internals(def);
|
|
662
|
+
try {
|
|
663
|
+
Object.defineProperty(inst, "_zod", _zodDesc);
|
|
664
|
+
} finally {
|
|
665
|
+
_zodDesc.value = undefined;
|
|
666
|
+
}
|
|
667
|
+
} else if (inst._zod.traits.has(name)) {
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
inst._zod.traits.add(name);
|
|
671
|
+
initializer(inst, def);
|
|
672
|
+
if (initialized) {
|
|
673
|
+
const own = Object.getPrototypeOf(inst);
|
|
674
|
+
const ctorProto = inst._zod.constr.prototype;
|
|
675
|
+
let up = own;
|
|
676
|
+
while (up && up !== ctorProto)
|
|
677
|
+
up = Object.getPrototypeOf(up);
|
|
678
|
+
const target = up ?? own;
|
|
679
|
+
if (!initialized.has(target)) {
|
|
680
|
+
initialized.add(target);
|
|
681
|
+
members(target, protoMembers);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
const proto = _.prototype;
|
|
685
|
+
for (const k in proto) {
|
|
686
|
+
if (!Object.prototype.hasOwnProperty.call(proto, k))
|
|
687
|
+
continue;
|
|
688
|
+
if (!(k in inst)) {
|
|
689
|
+
inst[k] = proto[k].bind(inst);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
const Parent = params?.Parent ?? Object;
|
|
694
|
+
|
|
695
|
+
class Definition extends Parent {
|
|
696
|
+
}
|
|
697
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
698
|
+
function _(def) {
|
|
699
|
+
const inst = params?.Parent ? newError(Definition) : this;
|
|
700
|
+
init(inst, def);
|
|
701
|
+
const deferred = inst._zod.deferred;
|
|
702
|
+
if (deferred) {
|
|
703
|
+
for (const fn of deferred) {
|
|
704
|
+
fn();
|
|
705
|
+
}
|
|
706
|
+
inst._zod.deferred = undefined;
|
|
707
|
+
}
|
|
708
|
+
const pp = globalThis.__zod_globalConfig?.postProcessor;
|
|
709
|
+
if (pp)
|
|
710
|
+
pp(inst);
|
|
711
|
+
return inst;
|
|
712
|
+
}
|
|
713
|
+
Object.defineProperty(_, "init", { value: init });
|
|
714
|
+
Object.defineProperty(_, Symbol.hasInstance, {
|
|
715
|
+
value: (inst) => {
|
|
716
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
717
|
+
return true;
|
|
718
|
+
return inst?._zod?.traits?.has(name);
|
|
719
|
+
}
|
|
592
720
|
});
|
|
721
|
+
Object.defineProperty(_, "name", { value: name });
|
|
722
|
+
return _;
|
|
723
|
+
}
|
|
724
|
+
class $ZodAsyncError extends Error {
|
|
725
|
+
constructor() {
|
|
726
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
class $ZodEncodeError extends Error {
|
|
731
|
+
constructor(name) {
|
|
732
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
733
|
+
this.name = "ZodEncodeError";
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
737
|
+
var globalConfig = globalThis.__zod_globalConfig;
|
|
738
|
+
function config(newConfig) {
|
|
739
|
+
if (newConfig)
|
|
740
|
+
Object.assign(globalConfig, newConfig);
|
|
741
|
+
return globalConfig;
|
|
742
|
+
}
|
|
743
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/errors.js
|
|
744
|
+
function _getMessage() {
|
|
745
|
+
const internals = this._zod;
|
|
746
|
+
internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
|
|
747
|
+
return internals.message;
|
|
748
|
+
}
|
|
749
|
+
function _setMessage(value) {
|
|
750
|
+
this._zod.message = value;
|
|
751
|
+
}
|
|
752
|
+
var _messageDesc = {
|
|
753
|
+
get: _getMessage,
|
|
754
|
+
set: _setMessage,
|
|
755
|
+
enumerable: true,
|
|
756
|
+
configurable: true
|
|
757
|
+
};
|
|
758
|
+
var _issuesDesc = { value: undefined, enumerable: false };
|
|
759
|
+
var _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
760
|
+
var initializer = (inst, def) => {
|
|
761
|
+
inst.name = "$ZodError";
|
|
762
|
+
_issuesDesc.value = def;
|
|
763
|
+
Object.defineProperty(inst, "issues", _issuesDesc);
|
|
764
|
+
_issuesDesc.value = undefined;
|
|
765
|
+
Object.defineProperty(inst, "message", _messageDesc);
|
|
766
|
+
const proto = Object.getPrototypeOf(inst);
|
|
767
|
+
if (!_installedToString.has(proto)) {
|
|
768
|
+
_installedToString.add(proto);
|
|
769
|
+
Object.defineProperty(proto, "toString", {
|
|
770
|
+
configurable: true,
|
|
771
|
+
enumerable: false,
|
|
772
|
+
get() {
|
|
773
|
+
const value = () => this.message;
|
|
774
|
+
Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
|
|
775
|
+
return value;
|
|
776
|
+
},
|
|
777
|
+
set(value) {
|
|
778
|
+
Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
|
|
779
|
+
}
|
|
780
|
+
});
|
|
781
|
+
}
|
|
593
782
|
};
|
|
594
783
|
var $ZodError = $constructor("$ZodError", initializer);
|
|
595
|
-
var $ZodRealError = $constructor("$ZodError", initializer, {
|
|
784
|
+
var $ZodRealError = $constructor("$ZodError", initializer, undefined, {
|
|
785
|
+
Parent: Error
|
|
786
|
+
});
|
|
787
|
+
function node(obj, key, make) {
|
|
788
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
789
|
+
if (key === "__proto__") {
|
|
790
|
+
Object.defineProperty(obj, key, { value: make(), writable: true, enumerable: true, configurable: true });
|
|
791
|
+
} else {
|
|
792
|
+
obj[key] = make();
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
return obj[key];
|
|
796
|
+
}
|
|
596
797
|
function flattenError(error, mapper = (issue) => issue.message) {
|
|
597
798
|
const fieldErrors = {};
|
|
598
799
|
const formErrors = [];
|
|
599
800
|
for (const sub of error.issues) {
|
|
600
801
|
if (sub.path.length > 0) {
|
|
601
|
-
fieldErrors
|
|
602
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
802
|
+
node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
|
|
603
803
|
} else {
|
|
604
804
|
formErrors.push(mapper(sub));
|
|
605
805
|
}
|
|
@@ -626,13 +826,25 @@ function formatError(error, mapper = (issue) => issue.message) {
|
|
|
626
826
|
while (i < fullpath.length) {
|
|
627
827
|
const el = fullpath[i];
|
|
628
828
|
const terminal = i === fullpath.length - 1;
|
|
629
|
-
if (
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
829
|
+
if (el === "_errors") {
|
|
830
|
+
if (terminal)
|
|
831
|
+
curr._errors.push(mapper(issue));
|
|
832
|
+
i++;
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
if (!Object.prototype.hasOwnProperty.call(curr, el)) {
|
|
836
|
+
Object.defineProperty(curr, el, {
|
|
837
|
+
value: { _errors: [] },
|
|
838
|
+
enumerable: true,
|
|
839
|
+
writable: true,
|
|
840
|
+
configurable: true
|
|
841
|
+
});
|
|
634
842
|
}
|
|
635
|
-
|
|
843
|
+
const node = curr[el];
|
|
844
|
+
if (terminal) {
|
|
845
|
+
node._errors.push(mapper(issue));
|
|
846
|
+
}
|
|
847
|
+
curr = node;
|
|
636
848
|
i++;
|
|
637
849
|
}
|
|
638
850
|
}
|
|
@@ -643,68 +855,138 @@ function formatError(error, mapper = (issue) => issue.message) {
|
|
|
643
855
|
return fieldErrors;
|
|
644
856
|
}
|
|
645
857
|
|
|
646
|
-
// ../../node_modules/.bun/zod@4.
|
|
647
|
-
|
|
858
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/parse.js
|
|
859
|
+
function finalizeParams(callee, params) {
|
|
860
|
+
return { callee: params?.callee ?? callee, Err: params?.Err };
|
|
861
|
+
}
|
|
862
|
+
var _parse = (_Err) => {
|
|
863
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
864
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
865
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
866
|
+
if (result instanceof Promise) {
|
|
867
|
+
throw new $ZodAsyncError;
|
|
868
|
+
}
|
|
869
|
+
if (result.issues.length) {
|
|
870
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
871
|
+
captureStackTrace(e, _params?.callee ?? fn);
|
|
872
|
+
throw e;
|
|
873
|
+
}
|
|
874
|
+
return result.value;
|
|
875
|
+
};
|
|
876
|
+
return fn;
|
|
877
|
+
};
|
|
878
|
+
var _parseAsync = (_Err) => {
|
|
879
|
+
const fn = async (schema, value, _ctx, params) => {
|
|
880
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
881
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
882
|
+
if (result instanceof Promise)
|
|
883
|
+
result = await result;
|
|
884
|
+
if (result.issues.length) {
|
|
885
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
886
|
+
captureStackTrace(e, params?.callee ?? fn);
|
|
887
|
+
throw e;
|
|
888
|
+
}
|
|
889
|
+
return result.value;
|
|
890
|
+
};
|
|
891
|
+
return fn;
|
|
892
|
+
};
|
|
893
|
+
var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
648
894
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
649
895
|
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
650
896
|
if (result instanceof Promise) {
|
|
651
897
|
throw new $ZodAsyncError;
|
|
652
898
|
}
|
|
653
|
-
|
|
654
|
-
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
655
|
-
captureStackTrace(e, _params?.callee);
|
|
656
|
-
throw e;
|
|
657
|
-
}
|
|
658
|
-
return result.value;
|
|
899
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
|
|
659
900
|
};
|
|
660
|
-
|
|
901
|
+
function failure(Err, issues, ctx) {
|
|
902
|
+
let error;
|
|
903
|
+
return {
|
|
904
|
+
success: false,
|
|
905
|
+
get error() {
|
|
906
|
+
if (!error) {
|
|
907
|
+
error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
908
|
+
issues = undefined;
|
|
909
|
+
ctx = undefined;
|
|
910
|
+
}
|
|
911
|
+
return error;
|
|
912
|
+
},
|
|
913
|
+
set error(e) {
|
|
914
|
+
error = e;
|
|
915
|
+
issues = undefined;
|
|
916
|
+
ctx = undefined;
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
661
921
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
662
922
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
663
923
|
if (result instanceof Promise)
|
|
664
924
|
result = await result;
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
925
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
|
|
926
|
+
};
|
|
927
|
+
var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
|
|
928
|
+
var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
|
|
929
|
+
var validate = (schema, value, _ctx) => {
|
|
930
|
+
const validator = schema._zod.bag.validator;
|
|
931
|
+
if (validator !== undefined) {
|
|
932
|
+
if (validator(value) !== COMPILE_INVALID)
|
|
933
|
+
return true;
|
|
934
|
+
if (validator.definite === true && _ctx === undefined)
|
|
935
|
+
return false;
|
|
669
936
|
}
|
|
670
|
-
return
|
|
937
|
+
return validateFallback(schema, value, _ctx);
|
|
671
938
|
};
|
|
672
|
-
|
|
673
|
-
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
674
|
-
const
|
|
939
|
+
function validateFallback(schema, value, _ctx) {
|
|
940
|
+
const ctx = _ctx ? { ..._ctx, async: false, abortEarly: true } : { async: false, abortEarly: true };
|
|
941
|
+
const fallbackRun = schema._zod.bag.fallbackRun;
|
|
942
|
+
let result;
|
|
943
|
+
if (fallbackRun) {
|
|
944
|
+
ctx[COMPILE_FALLBACK] = true;
|
|
945
|
+
result = fallbackRun({ value, issues: [] }, ctx);
|
|
946
|
+
} else {
|
|
947
|
+
result = schema._zod.run({ value, issues: [] }, ctx);
|
|
948
|
+
}
|
|
675
949
|
if (result instanceof Promise) {
|
|
676
950
|
throw new $ZodAsyncError;
|
|
677
951
|
}
|
|
678
|
-
return result.issues.length
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
} : {
|
|
682
|
-
};
|
|
683
|
-
var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
684
|
-
var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
685
|
-
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
952
|
+
return result.issues.length === 0;
|
|
953
|
+
}
|
|
954
|
+
var validateAsync = async (schema, value, _ctx) => {
|
|
955
|
+
const ctx = _ctx ? { ..._ctx, async: true, abortEarly: true } : { async: true, abortEarly: true };
|
|
686
956
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
687
957
|
if (result instanceof Promise)
|
|
688
958
|
result = await result;
|
|
689
|
-
return result.issues.length
|
|
690
|
-
success: false,
|
|
691
|
-
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
692
|
-
} : { success: true, data: result.value };
|
|
959
|
+
return result.issues.length === 0;
|
|
693
960
|
};
|
|
694
|
-
var
|
|
695
|
-
|
|
696
|
-
const
|
|
697
|
-
|
|
961
|
+
var _encode = (_Err) => {
|
|
962
|
+
const parse = _parse(_Err);
|
|
963
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
964
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
965
|
+
return parse(schema, value, ctx, finalizeParams(fn, _params));
|
|
966
|
+
};
|
|
967
|
+
return fn;
|
|
698
968
|
};
|
|
699
|
-
var _decode = (_Err) =>
|
|
700
|
-
|
|
969
|
+
var _decode = (_Err) => {
|
|
970
|
+
const parse = _parse(_Err);
|
|
971
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
972
|
+
return parse(schema, value, _ctx, finalizeParams(fn, _params));
|
|
973
|
+
};
|
|
974
|
+
return fn;
|
|
701
975
|
};
|
|
702
|
-
var _encodeAsync = (_Err) =>
|
|
703
|
-
const
|
|
704
|
-
|
|
976
|
+
var _encodeAsync = (_Err) => {
|
|
977
|
+
const parseAsync = _parseAsync(_Err);
|
|
978
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
979
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
980
|
+
return await parseAsync(schema, value, ctx, finalizeParams(fn, _params));
|
|
981
|
+
};
|
|
982
|
+
return fn;
|
|
705
983
|
};
|
|
706
|
-
var _decodeAsync = (_Err) =>
|
|
707
|
-
|
|
984
|
+
var _decodeAsync = (_Err) => {
|
|
985
|
+
const parseAsync = _parseAsync(_Err);
|
|
986
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
987
|
+
return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
|
|
988
|
+
};
|
|
989
|
+
return fn;
|
|
708
990
|
};
|
|
709
991
|
var _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
710
992
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
@@ -720,13 +1002,16 @@ var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
720
1002
|
var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
721
1003
|
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
722
1004
|
};
|
|
723
|
-
// ../../node_modules/.bun/zod@4.
|
|
1005
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/regexes.js
|
|
724
1006
|
var cuid = /^[cC][0-9a-z]{6,}$/;
|
|
725
1007
|
var cuid2 = /^[0-9a-z]+$/;
|
|
726
|
-
var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{
|
|
1008
|
+
var ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
|
|
727
1009
|
var xid = /^[0-9a-vA-V]{20}$/;
|
|
728
1010
|
var ksuid = /^[A-Za-z0-9]{27}$/;
|
|
729
1011
|
var nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
1012
|
+
function nanoidOfLength(length) {
|
|
1013
|
+
return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
|
|
1014
|
+
}
|
|
730
1015
|
var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
731
1016
|
var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
732
1017
|
var uuid = (version) => {
|
|
@@ -734,56 +1019,58 @@ var uuid = (version) => {
|
|
|
734
1019
|
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)$/;
|
|
735
1020
|
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})$`);
|
|
736
1021
|
};
|
|
737
|
-
var email = /^(
|
|
738
|
-
var _emoji = `^(\\p{Extended_Pictographic}
|
|
1022
|
+
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,}$/;
|
|
1023
|
+
var _emoji = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
739
1024
|
function emoji() {
|
|
740
1025
|
return new RegExp(_emoji, "u");
|
|
741
1026
|
}
|
|
742
1027
|
var ipv4 = /^(?:(?: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])$/;
|
|
743
1028
|
var ipv6 = /^(([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}|:))$/;
|
|
744
1029
|
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])$/;
|
|
745
|
-
var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}
|
|
1030
|
+
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])$/;
|
|
746
1031
|
var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
747
|
-
var base64url = /^[A-Za-z0-9_-]
|
|
1032
|
+
var base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
|
|
748
1033
|
var httpProtocol = /^https?$/;
|
|
749
1034
|
var e164 = /^\+[1-9]\d{6,14}$/;
|
|
750
1035
|
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])))`;
|
|
751
|
-
|
|
1036
|
+
function anchor(source) {
|
|
1037
|
+
return new RegExp(`^${source}$`);
|
|
1038
|
+
}
|
|
1039
|
+
var date = /* @__PURE__ */ anchor(dateSource);
|
|
752
1040
|
function timeSource(args) {
|
|
753
1041
|
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
754
|
-
const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
1042
|
+
const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : args.seconds ? `${hhmm}:[0-5]\\d(?:\\.\\d+)?` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
755
1043
|
return regex;
|
|
756
1044
|
}
|
|
757
1045
|
function time(args) {
|
|
758
1046
|
return new RegExp(`^${timeSource(args)}$`);
|
|
759
1047
|
}
|
|
760
1048
|
function datetime(args) {
|
|
761
|
-
const time = timeSource({ precision: args.precision });
|
|
762
1049
|
const opts = ["Z"];
|
|
763
|
-
if (args.local)
|
|
764
|
-
opts.push("");
|
|
765
1050
|
if (args.offset)
|
|
766
1051
|
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
767
|
-
const
|
|
1052
|
+
const qualified = `${timeSource({ precision: args.precision, seconds: true })}(?:${opts.join("|")})`;
|
|
1053
|
+
const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
|
|
768
1054
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
769
1055
|
}
|
|
770
|
-
var
|
|
771
|
-
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
772
|
-
return new RegExp(`^${regex}$`);
|
|
773
|
-
};
|
|
1056
|
+
var anyString = /^[\s\S]{0,}$/;
|
|
774
1057
|
var integer = /^-?\d+$/;
|
|
775
1058
|
var number = /^-?\d+(?:\.\d+)?$/;
|
|
776
1059
|
var boolean = /^(?:true|false)$/i;
|
|
777
1060
|
var lowercase = /^[^A-Z]*$/;
|
|
778
1061
|
var uppercase = /^[^a-z]*$/;
|
|
779
1062
|
|
|
780
|
-
// ../../node_modules/.bun/zod@4.
|
|
1063
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/checks.js
|
|
781
1064
|
var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
782
1065
|
var _a;
|
|
783
1066
|
inst._zod ?? (inst._zod = {});
|
|
784
1067
|
inst._zod.def = def;
|
|
785
1068
|
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
786
1069
|
});
|
|
1070
|
+
var _whenHasLength = (payload) => {
|
|
1071
|
+
const val = payload.value;
|
|
1072
|
+
return !nullish(val) && val.length !== undefined;
|
|
1073
|
+
};
|
|
787
1074
|
var numericOriginMap = {
|
|
788
1075
|
number: "number",
|
|
789
1076
|
bigint: "bigint",
|
|
@@ -792,22 +1079,12 @@ var numericOriginMap = {
|
|
|
792
1079
|
var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
793
1080
|
$ZodCheck.init(inst, def);
|
|
794
1081
|
const origin = numericOriginMap[typeof def.value];
|
|
795
|
-
inst._zod.onattach.push((inst) => {
|
|
796
|
-
const bag = inst._zod.bag;
|
|
797
|
-
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
798
|
-
if (def.value < curr) {
|
|
799
|
-
if (def.inclusive)
|
|
800
|
-
bag.maximum = def.value;
|
|
801
|
-
else
|
|
802
|
-
bag.exclusiveMaximum = def.value;
|
|
803
|
-
}
|
|
804
|
-
});
|
|
805
1082
|
inst._zod.check = (payload) => {
|
|
806
1083
|
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
|
|
807
1084
|
return;
|
|
808
1085
|
}
|
|
809
1086
|
payload.issues.push({
|
|
810
|
-
origin,
|
|
1087
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
811
1088
|
code: "too_big",
|
|
812
1089
|
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
813
1090
|
input: payload.value,
|
|
@@ -820,22 +1097,12 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
|
|
|
820
1097
|
var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
821
1098
|
$ZodCheck.init(inst, def);
|
|
822
1099
|
const origin = numericOriginMap[typeof def.value];
|
|
823
|
-
inst._zod.onattach.push((inst) => {
|
|
824
|
-
const bag = inst._zod.bag;
|
|
825
|
-
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
826
|
-
if (def.value > curr) {
|
|
827
|
-
if (def.inclusive)
|
|
828
|
-
bag.minimum = def.value;
|
|
829
|
-
else
|
|
830
|
-
bag.exclusiveMinimum = def.value;
|
|
831
|
-
}
|
|
832
|
-
});
|
|
833
1100
|
inst._zod.check = (payload) => {
|
|
834
1101
|
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
|
|
835
1102
|
return;
|
|
836
1103
|
}
|
|
837
1104
|
payload.issues.push({
|
|
838
|
-
origin,
|
|
1105
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
839
1106
|
code: "too_small",
|
|
840
1107
|
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
841
1108
|
input: payload.value,
|
|
@@ -847,14 +1114,10 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
|
|
|
847
1114
|
});
|
|
848
1115
|
var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
849
1116
|
$ZodCheck.init(inst, def);
|
|
850
|
-
inst._zod.onattach.push((inst) => {
|
|
851
|
-
var _a;
|
|
852
|
-
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
|
853
|
-
});
|
|
854
1117
|
inst._zod.check = (payload) => {
|
|
855
1118
|
if (typeof payload.value !== typeof def.value)
|
|
856
1119
|
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
857
|
-
const isMultiple = typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0;
|
|
1120
|
+
const isMultiple = typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0;
|
|
858
1121
|
if (isMultiple)
|
|
859
1122
|
return;
|
|
860
1123
|
payload.issues.push({
|
|
@@ -873,14 +1136,6 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
873
1136
|
const isInt = def.format?.includes("int");
|
|
874
1137
|
const origin = isInt ? "int" : "number";
|
|
875
1138
|
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
876
|
-
inst._zod.onattach.push((inst) => {
|
|
877
|
-
const bag = inst._zod.bag;
|
|
878
|
-
bag.format = def.format;
|
|
879
|
-
bag.minimum = minimum;
|
|
880
|
-
bag.maximum = maximum;
|
|
881
|
-
if (isInt)
|
|
882
|
-
bag.pattern = integer;
|
|
883
|
-
});
|
|
884
1139
|
inst._zod.check = (payload) => {
|
|
885
1140
|
const input = payload.value;
|
|
886
1141
|
if (isInt) {
|
|
@@ -949,18 +1204,11 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
949
1204
|
var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
950
1205
|
var _a;
|
|
951
1206
|
$ZodCheck.init(inst, def);
|
|
952
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
953
|
-
const val = payload.value;
|
|
954
|
-
return !nullish(val) && val.length !== undefined;
|
|
955
|
-
});
|
|
956
|
-
inst._zod.onattach.push((inst) => {
|
|
957
|
-
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
958
|
-
if (def.maximum < curr)
|
|
959
|
-
inst._zod.bag.maximum = def.maximum;
|
|
960
|
-
});
|
|
1207
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
961
1208
|
inst._zod.check = (payload) => {
|
|
962
1209
|
const input = payload.value;
|
|
963
|
-
const
|
|
1210
|
+
const units = input.length;
|
|
1211
|
+
const length = typeof input === "string" && units > def.maximum ? codePointLength(input) : units;
|
|
964
1212
|
if (length <= def.maximum)
|
|
965
1213
|
return;
|
|
966
1214
|
const origin = getLengthableOrigin(input);
|
|
@@ -978,18 +1226,11 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
|
|
|
978
1226
|
var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
979
1227
|
var _a;
|
|
980
1228
|
$ZodCheck.init(inst, def);
|
|
981
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
982
|
-
const val = payload.value;
|
|
983
|
-
return !nullish(val) && val.length !== undefined;
|
|
984
|
-
});
|
|
985
|
-
inst._zod.onattach.push((inst) => {
|
|
986
|
-
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
987
|
-
if (def.minimum > curr)
|
|
988
|
-
inst._zod.bag.minimum = def.minimum;
|
|
989
|
-
});
|
|
1229
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
990
1230
|
inst._zod.check = (payload) => {
|
|
991
1231
|
const input = payload.value;
|
|
992
|
-
const
|
|
1232
|
+
const units = input.length;
|
|
1233
|
+
const length = typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units;
|
|
993
1234
|
if (length >= def.minimum)
|
|
994
1235
|
return;
|
|
995
1236
|
const origin = getLengthableOrigin(input);
|
|
@@ -1007,19 +1248,11 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
|
|
|
1007
1248
|
var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
1008
1249
|
var _a;
|
|
1009
1250
|
$ZodCheck.init(inst, def);
|
|
1010
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
1011
|
-
const val = payload.value;
|
|
1012
|
-
return !nullish(val) && val.length !== undefined;
|
|
1013
|
-
});
|
|
1014
|
-
inst._zod.onattach.push((inst) => {
|
|
1015
|
-
const bag = inst._zod.bag;
|
|
1016
|
-
bag.minimum = def.length;
|
|
1017
|
-
bag.maximum = def.length;
|
|
1018
|
-
bag.length = def.length;
|
|
1019
|
-
});
|
|
1251
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
1020
1252
|
inst._zod.check = (payload) => {
|
|
1021
1253
|
const input = payload.value;
|
|
1022
|
-
const
|
|
1254
|
+
const units = input.length;
|
|
1255
|
+
const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
|
|
1023
1256
|
if (length === def.length)
|
|
1024
1257
|
return;
|
|
1025
1258
|
const origin = getLengthableOrigin(input);
|
|
@@ -1038,14 +1271,6 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
|
|
|
1038
1271
|
var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
1039
1272
|
var _a, _b;
|
|
1040
1273
|
$ZodCheck.init(inst, def);
|
|
1041
|
-
inst._zod.onattach.push((inst) => {
|
|
1042
|
-
const bag = inst._zod.bag;
|
|
1043
|
-
bag.format = def.format;
|
|
1044
|
-
if (def.pattern) {
|
|
1045
|
-
bag.patterns ?? (bag.patterns = new Set);
|
|
1046
|
-
bag.patterns.add(def.pattern);
|
|
1047
|
-
}
|
|
1048
|
-
});
|
|
1049
1274
|
if (def.pattern)
|
|
1050
1275
|
(_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
1051
1276
|
def.pattern.lastIndex = 0;
|
|
@@ -1092,13 +1317,8 @@ var $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (ins
|
|
|
1092
1317
|
var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
1093
1318
|
$ZodCheck.init(inst, def);
|
|
1094
1319
|
const escapedRegex = escapeRegex(def.includes);
|
|
1095
|
-
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
1320
|
+
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
|
|
1096
1321
|
def.pattern = pattern;
|
|
1097
|
-
inst._zod.onattach.push((inst) => {
|
|
1098
|
-
const bag = inst._zod.bag;
|
|
1099
|
-
bag.patterns ?? (bag.patterns = new Set);
|
|
1100
|
-
bag.patterns.add(pattern);
|
|
1101
|
-
});
|
|
1102
1322
|
inst._zod.check = (payload) => {
|
|
1103
1323
|
if (payload.value.includes(def.includes, def.position))
|
|
1104
1324
|
return;
|
|
@@ -1117,11 +1337,6 @@ var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (i
|
|
|
1117
1337
|
$ZodCheck.init(inst, def);
|
|
1118
1338
|
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
1119
1339
|
def.pattern ?? (def.pattern = pattern);
|
|
1120
|
-
inst._zod.onattach.push((inst) => {
|
|
1121
|
-
const bag = inst._zod.bag;
|
|
1122
|
-
bag.patterns ?? (bag.patterns = new Set);
|
|
1123
|
-
bag.patterns.add(pattern);
|
|
1124
|
-
});
|
|
1125
1340
|
inst._zod.check = (payload) => {
|
|
1126
1341
|
if (payload.value.startsWith(def.prefix))
|
|
1127
1342
|
return;
|
|
@@ -1140,11 +1355,6 @@ var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst,
|
|
|
1140
1355
|
$ZodCheck.init(inst, def);
|
|
1141
1356
|
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
1142
1357
|
def.pattern ?? (def.pattern = pattern);
|
|
1143
|
-
inst._zod.onattach.push((inst) => {
|
|
1144
|
-
const bag = inst._zod.bag;
|
|
1145
|
-
bag.patterns ?? (bag.patterns = new Set);
|
|
1146
|
-
bag.patterns.add(pattern);
|
|
1147
|
-
});
|
|
1148
1358
|
inst._zod.check = (payload) => {
|
|
1149
1359
|
if (payload.value.endsWith(def.suffix))
|
|
1150
1360
|
return;
|
|
@@ -1166,18 +1376,21 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
|
|
|
1166
1376
|
};
|
|
1167
1377
|
});
|
|
1168
1378
|
|
|
1169
|
-
// ../../node_modules/.bun/zod@4.
|
|
1379
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/doc.js
|
|
1170
1380
|
class Doc {
|
|
1171
|
-
constructor(args = []) {
|
|
1381
|
+
constructor(args = [], closed = {}) {
|
|
1172
1382
|
this.content = [];
|
|
1173
1383
|
this.indent = 0;
|
|
1174
|
-
|
|
1175
|
-
|
|
1384
|
+
this.args = args;
|
|
1385
|
+
this.closed = closed;
|
|
1176
1386
|
}
|
|
1177
1387
|
indented(fn) {
|
|
1178
1388
|
this.indent += 1;
|
|
1179
|
-
|
|
1180
|
-
|
|
1389
|
+
try {
|
|
1390
|
+
fn(this);
|
|
1391
|
+
} finally {
|
|
1392
|
+
this.indent -= 1;
|
|
1393
|
+
}
|
|
1181
1394
|
}
|
|
1182
1395
|
write(arg) {
|
|
1183
1396
|
if (typeof arg === "function") {
|
|
@@ -1196,32 +1409,31 @@ class Doc {
|
|
|
1196
1409
|
}
|
|
1197
1410
|
compile() {
|
|
1198
1411
|
const F = Function;
|
|
1199
|
-
const args = this?.args;
|
|
1200
1412
|
const content = this?.content ?? [``];
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1203
|
-
`)
|
|
1413
|
+
const factory = new F(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {
|
|
1414
|
+
${content.join(`
|
|
1415
|
+
`)}
|
|
1416
|
+
};`);
|
|
1417
|
+
return factory(...Object.values(this.closed));
|
|
1204
1418
|
}
|
|
1205
1419
|
}
|
|
1206
1420
|
|
|
1207
|
-
// ../../node_modules/.bun/zod@4.
|
|
1421
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/versions.js
|
|
1208
1422
|
var version = {
|
|
1209
1423
|
major: 4,
|
|
1210
|
-
minor:
|
|
1211
|
-
patch:
|
|
1424
|
+
minor: 6,
|
|
1425
|
+
patch: 7
|
|
1212
1426
|
};
|
|
1213
1427
|
|
|
1214
|
-
// ../../node_modules/.bun/zod@4.
|
|
1428
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/schemas.js
|
|
1215
1429
|
var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
1216
1430
|
var _a;
|
|
1217
1431
|
inst ?? (inst = {});
|
|
1218
1432
|
inst._zod.def = def;
|
|
1219
1433
|
inst._zod.bag = inst._zod.bag || {};
|
|
1220
1434
|
inst._zod.version = version;
|
|
1221
|
-
const
|
|
1222
|
-
|
|
1223
|
-
checks.unshift(inst);
|
|
1224
|
-
}
|
|
1435
|
+
const defChecks = inst._zod.def.checks;
|
|
1436
|
+
const checks = inst._zod.traits.has("$ZodCheck") ? [inst, ...defChecks ?? []] : defChecks?.length ? [...defChecks] : [];
|
|
1225
1437
|
for (const ch of checks) {
|
|
1226
1438
|
for (const fn of ch._zod.onattach) {
|
|
1227
1439
|
fn(inst);
|
|
@@ -1234,6 +1446,8 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
1234
1446
|
});
|
|
1235
1447
|
} else {
|
|
1236
1448
|
const runChecks = (payload, checks, ctx) => {
|
|
1449
|
+
if (payload.memo)
|
|
1450
|
+
return payload;
|
|
1237
1451
|
let isAborted = aborted(payload);
|
|
1238
1452
|
let asyncResult;
|
|
1239
1453
|
for (const ch of checks) {
|
|
@@ -1257,6 +1471,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
1257
1471
|
const nextLen = payload.issues.length;
|
|
1258
1472
|
if (nextLen === currLen)
|
|
1259
1473
|
return;
|
|
1474
|
+
attachSchema(payload.issues, currLen, inst);
|
|
1260
1475
|
if (!isAborted)
|
|
1261
1476
|
isAborted = aborted(payload, currLen);
|
|
1262
1477
|
});
|
|
@@ -1264,6 +1479,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
1264
1479
|
const nextLen = payload.issues.length;
|
|
1265
1480
|
if (nextLen === currLen)
|
|
1266
1481
|
continue;
|
|
1482
|
+
attachSchema(payload.issues, currLen, inst);
|
|
1267
1483
|
if (!isAborted)
|
|
1268
1484
|
isAborted = aborted(payload, currLen);
|
|
1269
1485
|
}
|
|
@@ -1310,22 +1526,37 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
1310
1526
|
return runChecks(result, checks, ctx);
|
|
1311
1527
|
};
|
|
1312
1528
|
}
|
|
1313
|
-
|
|
1529
|
+
}, {
|
|
1530
|
+
get "~standard"() {
|
|
1531
|
+
return hide(this, "~standard", standardProps(this));
|
|
1532
|
+
},
|
|
1533
|
+
set "~standard"(value) {
|
|
1534
|
+
own(this, "~standard", value);
|
|
1535
|
+
}
|
|
1536
|
+
});
|
|
1537
|
+
var toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
|
|
1538
|
+
async function validateAsync2(inst, value) {
|
|
1539
|
+
const ctx = { async: true };
|
|
1540
|
+
return toStandardResult(await inst._zod.run({ value, issues: [] }, ctx), ctx);
|
|
1541
|
+
}
|
|
1542
|
+
function standardProps(inst) {
|
|
1543
|
+
return {
|
|
1314
1544
|
validate: (value) => {
|
|
1545
|
+
const ctx = { async: false };
|
|
1315
1546
|
try {
|
|
1316
|
-
const r =
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1547
|
+
const r = inst._zod.run({ value, issues: [] }, ctx);
|
|
1548
|
+
if (!(r instanceof Promise))
|
|
1549
|
+
return toStandardResult(r, ctx);
|
|
1550
|
+
} catch (_) {}
|
|
1551
|
+
return validateAsync2(inst, value);
|
|
1321
1552
|
},
|
|
1322
1553
|
vendor: "zod",
|
|
1323
1554
|
version: 1
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1555
|
+
};
|
|
1556
|
+
}
|
|
1326
1557
|
var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
1327
1558
|
$ZodType.init(inst, def);
|
|
1328
|
-
inst._zod.pattern =
|
|
1559
|
+
inst._zod.pattern = def.pattern ?? anyString;
|
|
1329
1560
|
inst._zod.parse = (payload, _) => {
|
|
1330
1561
|
if (def.coerce)
|
|
1331
1562
|
try {
|
|
@@ -1374,58 +1605,105 @@ var $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
|
|
|
1374
1605
|
def.pattern ?? (def.pattern = email);
|
|
1375
1606
|
$ZodStringFormat.init(inst, def);
|
|
1376
1607
|
});
|
|
1608
|
+
var URL_BAD_FORMAT = 1;
|
|
1609
|
+
var URL_UNPARSEABLE = 2;
|
|
1610
|
+
function canParseURL(input) {
|
|
1611
|
+
try {
|
|
1612
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function")
|
|
1613
|
+
return URL.canParse(input);
|
|
1614
|
+
new URL(input);
|
|
1615
|
+
return true;
|
|
1616
|
+
} catch {
|
|
1617
|
+
return false;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
function validateURL(trimmed, def) {
|
|
1621
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
|
|
1622
|
+
return canParseURL(trimmed) || URL_UNPARSEABLE;
|
|
1623
|
+
}
|
|
1624
|
+
return parseURLObject(trimmed, def);
|
|
1625
|
+
}
|
|
1626
|
+
function parseURLObject(trimmed, def) {
|
|
1627
|
+
if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
|
|
1628
|
+
return URL_BAD_FORMAT;
|
|
1629
|
+
}
|
|
1630
|
+
try {
|
|
1631
|
+
if (typeof URL !== "undefined") {
|
|
1632
|
+
const URLStatic = URL;
|
|
1633
|
+
if (typeof URLStatic.parse === "function")
|
|
1634
|
+
return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
|
|
1635
|
+
}
|
|
1636
|
+
return new URL(trimmed);
|
|
1637
|
+
} catch {
|
|
1638
|
+
return URL_UNPARSEABLE;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
var asciiTabOrNewline = /[\t\n\r]/g;
|
|
1642
|
+
function stripTabAndNewline(value) {
|
|
1643
|
+
return value.replace(asciiTabOrNewline, "");
|
|
1644
|
+
}
|
|
1645
|
+
function urlHostnameOk(url, hostname) {
|
|
1646
|
+
hostname.lastIndex = 0;
|
|
1647
|
+
return hostname.test(url.hostname);
|
|
1648
|
+
}
|
|
1649
|
+
function urlProtocolOk(url, protocol) {
|
|
1650
|
+
protocol.lastIndex = 0;
|
|
1651
|
+
return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
|
|
1652
|
+
}
|
|
1377
1653
|
var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
1378
1654
|
$ZodStringFormat.init(inst, def);
|
|
1379
1655
|
inst._zod.check = (payload) => {
|
|
1380
1656
|
try {
|
|
1381
1657
|
const trimmed = payload.value.trim();
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
}
|
|
1658
|
+
const url = validateURL(trimmed, def);
|
|
1659
|
+
if (url === URL_BAD_FORMAT) {
|
|
1660
|
+
payload.issues.push({
|
|
1661
|
+
code: "invalid_format",
|
|
1662
|
+
format: "url",
|
|
1663
|
+
note: "Invalid URL format",
|
|
1664
|
+
input: payload.value,
|
|
1665
|
+
inst,
|
|
1666
|
+
continue: !def.abort
|
|
1667
|
+
});
|
|
1668
|
+
return;
|
|
1394
1669
|
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
payload.
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
input: payload.value,
|
|
1405
|
-
inst,
|
|
1406
|
-
continue: !def.abort
|
|
1407
|
-
});
|
|
1408
|
-
}
|
|
1670
|
+
if (url === URL_UNPARSEABLE) {
|
|
1671
|
+
payload.issues.push({
|
|
1672
|
+
code: "invalid_format",
|
|
1673
|
+
format: "url",
|
|
1674
|
+
input: payload.value,
|
|
1675
|
+
inst,
|
|
1676
|
+
continue: !def.abort
|
|
1677
|
+
});
|
|
1678
|
+
return;
|
|
1409
1679
|
}
|
|
1410
|
-
if (
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
payload.issues.push({
|
|
1414
|
-
code: "invalid_format",
|
|
1415
|
-
format: "url",
|
|
1416
|
-
note: "Invalid protocol",
|
|
1417
|
-
pattern: def.protocol.source,
|
|
1418
|
-
input: payload.value,
|
|
1419
|
-
inst,
|
|
1420
|
-
continue: !def.abort
|
|
1421
|
-
});
|
|
1422
|
-
}
|
|
1680
|
+
if (url === true) {
|
|
1681
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
1682
|
+
return;
|
|
1423
1683
|
}
|
|
1424
|
-
if (def.
|
|
1425
|
-
payload.
|
|
1426
|
-
|
|
1427
|
-
|
|
1684
|
+
if (def.hostname && !urlHostnameOk(url, def.hostname)) {
|
|
1685
|
+
payload.issues.push({
|
|
1686
|
+
code: "invalid_format",
|
|
1687
|
+
format: "url",
|
|
1688
|
+
note: "Invalid hostname",
|
|
1689
|
+
pattern: def.hostname.source,
|
|
1690
|
+
input: payload.value,
|
|
1691
|
+
inst,
|
|
1692
|
+
continue: !def.abort
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
if (def.protocol && !urlProtocolOk(url, def.protocol)) {
|
|
1696
|
+
payload.issues.push({
|
|
1697
|
+
code: "invalid_format",
|
|
1698
|
+
format: "url",
|
|
1699
|
+
note: "Invalid protocol",
|
|
1700
|
+
pattern: def.protocol.source,
|
|
1701
|
+
input: payload.value,
|
|
1702
|
+
inst,
|
|
1703
|
+
continue: !def.abort
|
|
1704
|
+
});
|
|
1428
1705
|
}
|
|
1706
|
+
payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
|
|
1429
1707
|
return;
|
|
1430
1708
|
} catch (_) {
|
|
1431
1709
|
payload.issues.push({
|
|
@@ -1443,7 +1721,9 @@ var $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
|
|
|
1443
1721
|
$ZodStringFormat.init(inst, def);
|
|
1444
1722
|
});
|
|
1445
1723
|
var $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
|
|
1446
|
-
def.
|
|
1724
|
+
if (def.length !== undefined && (!Number.isInteger(def.length) || def.length < 1))
|
|
1725
|
+
throw new Error(`Invalid nanoid length: ${def.length}`);
|
|
1726
|
+
def.pattern ?? (def.pattern = def.length === undefined ? nanoid : nanoidOfLength(def.length));
|
|
1447
1727
|
$ZodStringFormat.init(inst, def);
|
|
1448
1728
|
});
|
|
1449
1729
|
var $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
|
|
@@ -1485,16 +1765,18 @@ var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def
|
|
|
1485
1765
|
var $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
|
|
1486
1766
|
def.pattern ?? (def.pattern = ipv4);
|
|
1487
1767
|
$ZodStringFormat.init(inst, def);
|
|
1488
|
-
inst._zod.bag.format = `ipv4`;
|
|
1489
1768
|
});
|
|
1769
|
+
var ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
1770
|
+
function isValidIPv6(value) {
|
|
1771
|
+
if (!ipv6Alphabet.test(value))
|
|
1772
|
+
return false;
|
|
1773
|
+
return canParseURL(`http://[${value}]`);
|
|
1774
|
+
}
|
|
1490
1775
|
var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
1491
1776
|
def.pattern ?? (def.pattern = ipv6);
|
|
1492
1777
|
$ZodStringFormat.init(inst, def);
|
|
1493
|
-
inst._zod.bag.format = `ipv6`;
|
|
1494
1778
|
inst._zod.check = (payload) => {
|
|
1495
|
-
|
|
1496
|
-
new URL(`http://[${payload.value}]`);
|
|
1497
|
-
} catch {
|
|
1779
|
+
if (!isValidIPv6(payload.value)) {
|
|
1498
1780
|
payload.issues.push({
|
|
1499
1781
|
code: "invalid_format",
|
|
1500
1782
|
format: "ipv6",
|
|
@@ -1509,24 +1791,25 @@ var $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
|
1509
1791
|
def.pattern ?? (def.pattern = cidrv4);
|
|
1510
1792
|
$ZodStringFormat.init(inst, def);
|
|
1511
1793
|
});
|
|
1794
|
+
function isValidCIDRv6(value) {
|
|
1795
|
+
const parts = value.split("/");
|
|
1796
|
+
if (parts.length !== 2)
|
|
1797
|
+
return false;
|
|
1798
|
+
const [address, prefix] = parts;
|
|
1799
|
+
if (!prefix)
|
|
1800
|
+
return false;
|
|
1801
|
+
const prefixNum = Number(prefix);
|
|
1802
|
+
if (`${prefixNum}` !== prefix)
|
|
1803
|
+
return false;
|
|
1804
|
+
if (prefixNum < 0 || prefixNum > 128)
|
|
1805
|
+
return false;
|
|
1806
|
+
return isValidIPv6(address);
|
|
1807
|
+
}
|
|
1512
1808
|
var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
1513
1809
|
def.pattern ?? (def.pattern = cidrv6);
|
|
1514
1810
|
$ZodStringFormat.init(inst, def);
|
|
1515
1811
|
inst._zod.check = (payload) => {
|
|
1516
|
-
|
|
1517
|
-
try {
|
|
1518
|
-
if (parts.length !== 2)
|
|
1519
|
-
throw new Error;
|
|
1520
|
-
const [address, prefix] = parts;
|
|
1521
|
-
if (!prefix)
|
|
1522
|
-
throw new Error;
|
|
1523
|
-
const prefixNum = Number(prefix);
|
|
1524
|
-
if (`${prefixNum}` !== prefix)
|
|
1525
|
-
throw new Error;
|
|
1526
|
-
if (prefixNum < 0 || prefixNum > 128)
|
|
1527
|
-
throw new Error;
|
|
1528
|
-
new URL(`http://[${address}]`);
|
|
1529
|
-
} catch {
|
|
1812
|
+
if (!isValidCIDRv6(payload.value)) {
|
|
1530
1813
|
payload.issues.push({
|
|
1531
1814
|
code: "invalid_format",
|
|
1532
1815
|
format: "cidrv6",
|
|
@@ -1551,10 +1834,10 @@ function isValidBase64(data) {
|
|
|
1551
1834
|
return false;
|
|
1552
1835
|
}
|
|
1553
1836
|
}
|
|
1837
|
+
var base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
1554
1838
|
var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
1555
|
-
def.pattern ?? (def.pattern =
|
|
1839
|
+
def.pattern ?? (def.pattern = base64Charset);
|
|
1556
1840
|
$ZodStringFormat.init(inst, def);
|
|
1557
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
1558
1841
|
inst._zod.check = (payload) => {
|
|
1559
1842
|
if (isValidBase64(payload.value))
|
|
1560
1843
|
return;
|
|
@@ -1567,17 +1850,17 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
|
1567
1850
|
});
|
|
1568
1851
|
};
|
|
1569
1852
|
});
|
|
1853
|
+
var base64urlCharset = /^[A-Za-z0-9_-]*$/;
|
|
1570
1854
|
function isValidBase64URL(data) {
|
|
1571
|
-
if (!
|
|
1855
|
+
if (!base64urlCharset.test(data))
|
|
1572
1856
|
return false;
|
|
1573
1857
|
const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
1574
1858
|
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
|
1575
1859
|
return isValidBase64(padded);
|
|
1576
1860
|
}
|
|
1577
1861
|
var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1578
|
-
def.pattern ?? (def.pattern =
|
|
1862
|
+
def.pattern ?? (def.pattern = base64urlCharset);
|
|
1579
1863
|
$ZodStringFormat.init(inst, def);
|
|
1580
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
1581
1864
|
inst._zod.check = (payload) => {
|
|
1582
1865
|
if (isValidBase64URL(payload.value))
|
|
1583
1866
|
return;
|
|
@@ -1630,7 +1913,7 @@ var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
|
1630
1913
|
});
|
|
1631
1914
|
var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
1632
1915
|
$ZodType.init(inst, def);
|
|
1633
|
-
inst._zod.pattern =
|
|
1916
|
+
inst._zod.pattern = number;
|
|
1634
1917
|
inst._zod.parse = (payload, _ctx) => {
|
|
1635
1918
|
if (def.coerce)
|
|
1636
1919
|
try {
|
|
@@ -1640,7 +1923,7 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
|
1640
1923
|
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
|
|
1641
1924
|
return payload;
|
|
1642
1925
|
}
|
|
1643
|
-
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ?
|
|
1926
|
+
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? String(input) : undefined : undefined;
|
|
1644
1927
|
payload.issues.push({
|
|
1645
1928
|
expected: "number",
|
|
1646
1929
|
code: "invalid_type",
|
|
@@ -1691,6 +1974,29 @@ var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
|
1691
1974
|
return payload;
|
|
1692
1975
|
};
|
|
1693
1976
|
});
|
|
1977
|
+
function capSize(inst, size) {
|
|
1978
|
+
const caps = sizeCaps(inst._zod.def.checks);
|
|
1979
|
+
if (!caps.length)
|
|
1980
|
+
return;
|
|
1981
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
1982
|
+
const parse = inst._zod.parse;
|
|
1983
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1984
|
+
const n = size(payload.value);
|
|
1985
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
1986
|
+
for (const [max, ch] of sizeCaps(inst._zod.def.checks)) {
|
|
1987
|
+
if (n > max && ch._zod.def.when(payload)) {
|
|
1988
|
+
const start = payload.issues.length;
|
|
1989
|
+
ch._zod.check(payload);
|
|
1990
|
+
payload.issues[start].continue = false;
|
|
1991
|
+
attachSchema(payload.issues, start, inst);
|
|
1992
|
+
return payload;
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
return parse(payload, ctx);
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1999
|
+
var arraySize = (input) => Array.isArray(input) ? input.length : -1;
|
|
1694
2000
|
function handleArrayResult(result, final, index) {
|
|
1695
2001
|
if (result.issues.length) {
|
|
1696
2002
|
final.issues.push(...prefixIssues(index, result.issues));
|
|
@@ -1699,6 +2005,8 @@ function handleArrayResult(result, final, index) {
|
|
|
1699
2005
|
}
|
|
1700
2006
|
var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
1701
2007
|
$ZodType.init(inst, def);
|
|
2008
|
+
const memo = globalConfig.memoizer;
|
|
2009
|
+
memo?.attach(inst);
|
|
1702
2010
|
inst._zod.parse = (payload, ctx) => {
|
|
1703
2011
|
const input = payload.value;
|
|
1704
2012
|
if (!Array.isArray(input)) {
|
|
@@ -1710,8 +2018,9 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
1710
2018
|
});
|
|
1711
2019
|
return payload;
|
|
1712
2020
|
}
|
|
1713
|
-
payload.value = Array(input.length);
|
|
2021
|
+
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
1714
2022
|
const proms = [];
|
|
2023
|
+
const abortEarly = ctx?.abortEarly;
|
|
1715
2024
|
for (let i = 0;i < input.length; i++) {
|
|
1716
2025
|
const item = input[i];
|
|
1717
2026
|
const result = def.element._zod.run({
|
|
@@ -1722,6 +2031,8 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
1722
2031
|
proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
1723
2032
|
} else {
|
|
1724
2033
|
handleArrayResult(result, payload, i);
|
|
2034
|
+
if (abortEarly && result.issues.length !== 0 && aborted(result))
|
|
2035
|
+
break;
|
|
1725
2036
|
}
|
|
1726
2037
|
}
|
|
1727
2038
|
if (proms.length) {
|
|
@@ -1729,16 +2040,21 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
1729
2040
|
}
|
|
1730
2041
|
return payload;
|
|
1731
2042
|
};
|
|
2043
|
+
capSize(inst, arraySize);
|
|
1732
2044
|
});
|
|
1733
|
-
function handlePropertyResult(result, final, key, input,
|
|
2045
|
+
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
1734
2046
|
const isPresent = key in input;
|
|
2047
|
+
const isOptionalOut = optout === "optional";
|
|
2048
|
+
if (!isPresent && isOptionalOut && optin === "optional") {
|
|
2049
|
+
return;
|
|
2050
|
+
}
|
|
1735
2051
|
if (result.issues.length) {
|
|
1736
|
-
if (
|
|
2052
|
+
if (optin !== undefined && isOptionalOut && !isPresent) {
|
|
1737
2053
|
return;
|
|
1738
2054
|
}
|
|
1739
2055
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
1740
2056
|
}
|
|
1741
|
-
if (!isPresent &&
|
|
2057
|
+
if (!isPresent && optin === undefined) {
|
|
1742
2058
|
if (!result.issues.length) {
|
|
1743
2059
|
final.issues.push({
|
|
1744
2060
|
code: "invalid_type",
|
|
@@ -1750,50 +2066,64 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
|
|
|
1750
2066
|
return;
|
|
1751
2067
|
}
|
|
1752
2068
|
if (result.value === undefined) {
|
|
1753
|
-
if (isPresent) {
|
|
2069
|
+
if (isPresent || optin === "defaulted" && !isOptionalOut) {
|
|
1754
2070
|
final.value[key] = undefined;
|
|
1755
2071
|
}
|
|
1756
2072
|
} else {
|
|
1757
2073
|
final.value[key] = result.value;
|
|
1758
2074
|
}
|
|
1759
2075
|
}
|
|
2076
|
+
var NO_SYMBOL_KEYS = [];
|
|
1760
2077
|
function normalizeDef(def) {
|
|
1761
2078
|
const keys = Object.keys(def.shape);
|
|
1762
|
-
|
|
2079
|
+
const ownSymbols = Object.getOwnPropertySymbols(def.shape);
|
|
2080
|
+
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
|
|
2081
|
+
const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
|
|
2082
|
+
for (const k of allKeys) {
|
|
1763
2083
|
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
1764
|
-
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
2084
|
+
throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
|
|
1765
2085
|
}
|
|
1766
2086
|
}
|
|
1767
2087
|
const okeys = optionalKeys(def.shape);
|
|
1768
2088
|
return {
|
|
1769
2089
|
...def,
|
|
1770
|
-
|
|
2090
|
+
allKeys,
|
|
2091
|
+
symbolKeys,
|
|
1771
2092
|
keySet: new Set(keys),
|
|
1772
2093
|
numKeys: keys.length,
|
|
1773
2094
|
optionalKeys: new Set(okeys)
|
|
1774
2095
|
};
|
|
1775
2096
|
}
|
|
1776
|
-
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
2097
|
+
function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
|
|
1777
2098
|
const unrecognized = [];
|
|
1778
2099
|
const keySet = def.keySet;
|
|
1779
2100
|
const _catchall = def.catchall._zod;
|
|
1780
2101
|
const t = _catchall.def.type;
|
|
1781
|
-
const
|
|
1782
|
-
const
|
|
2102
|
+
const optin = _catchall.optin;
|
|
2103
|
+
const optout = _catchall.optout;
|
|
2104
|
+
let seen = 0;
|
|
1783
2105
|
for (const key in input) {
|
|
1784
|
-
if (
|
|
1785
|
-
|
|
2106
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
2107
|
+
if (aborted(payload, seen))
|
|
2108
|
+
break;
|
|
2109
|
+
seen = payload.issues.length;
|
|
2110
|
+
}
|
|
1786
2111
|
if (keySet.has(key))
|
|
1787
2112
|
continue;
|
|
2113
|
+
if (key === "__proto__") {
|
|
2114
|
+
if (t === "never")
|
|
2115
|
+
unrecognized.push(key);
|
|
2116
|
+
continue;
|
|
2117
|
+
}
|
|
1788
2118
|
if (t === "never") {
|
|
1789
2119
|
unrecognized.push(key);
|
|
1790
2120
|
continue;
|
|
1791
2121
|
}
|
|
1792
2122
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
1793
2123
|
if (r instanceof Promise) {
|
|
1794
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
2124
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
1795
2125
|
} else {
|
|
1796
|
-
handlePropertyResult(r, payload, key, input,
|
|
2126
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1797
2127
|
}
|
|
1798
2128
|
}
|
|
1799
2129
|
if (unrecognized.length) {
|
|
@@ -1801,7 +2131,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1801
2131
|
code: "unrecognized_keys",
|
|
1802
2132
|
keys: unrecognized,
|
|
1803
2133
|
input,
|
|
1804
|
-
inst
|
|
2134
|
+
inst,
|
|
2135
|
+
continue: true
|
|
1805
2136
|
});
|
|
1806
2137
|
}
|
|
1807
2138
|
if (!proms.length)
|
|
@@ -1813,28 +2144,31 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1813
2144
|
var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
1814
2145
|
$ZodType.init(inst, def);
|
|
1815
2146
|
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
});
|
|
2147
|
+
const sh = desc?.get ? desc.get.raw : def.shape ?? {};
|
|
2148
|
+
if (sh) {
|
|
2149
|
+
const get = () => {
|
|
2150
|
+
const newSh = { ...sh };
|
|
2151
|
+
Object.defineProperty(def, "shape", { value: newSh });
|
|
2152
|
+
get.raw = newSh;
|
|
2153
|
+
return newSh;
|
|
2154
|
+
};
|
|
2155
|
+
get.raw = sh;
|
|
2156
|
+
Object.defineProperty(def, "shape", { get });
|
|
1827
2157
|
}
|
|
1828
2158
|
const _normalized = cached(() => normalizeDef(def));
|
|
1829
|
-
|
|
1830
|
-
const shape = def.shape;
|
|
2159
|
+
defineLazyInternal(inst, "propValues", (zod) => {
|
|
2160
|
+
const shape = zod.def.shape;
|
|
1831
2161
|
const propValues = {};
|
|
1832
2162
|
for (const key in shape) {
|
|
1833
2163
|
const field = shape[key]._zod;
|
|
1834
2164
|
if (field.values) {
|
|
1835
|
-
|
|
2165
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
|
|
2166
|
+
assignProp(propValues, key, new Set);
|
|
2167
|
+
}
|
|
1836
2168
|
for (const v of field.values)
|
|
1837
2169
|
propValues[key].add(v);
|
|
2170
|
+
if (field.optin !== undefined)
|
|
2171
|
+
propValues[key].add(undefined);
|
|
1838
2172
|
}
|
|
1839
2173
|
}
|
|
1840
2174
|
return propValues;
|
|
@@ -1842,6 +2176,8 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
1842
2176
|
const isObject2 = isObject;
|
|
1843
2177
|
const catchall = def.catchall;
|
|
1844
2178
|
let value;
|
|
2179
|
+
const memo = globalConfig.memoizer;
|
|
2180
|
+
memo?.attach(inst);
|
|
1845
2181
|
inst._zod.parse = (payload, ctx) => {
|
|
1846
2182
|
value ?? (value = _normalized.value);
|
|
1847
2183
|
const input = payload.value;
|
|
@@ -1854,79 +2190,93 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
1854
2190
|
});
|
|
1855
2191
|
return payload;
|
|
1856
2192
|
}
|
|
1857
|
-
payload.value = {};
|
|
2193
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1858
2194
|
const proms = [];
|
|
1859
2195
|
const shape = value.shape;
|
|
1860
|
-
|
|
2196
|
+
const abortEarly = ctx?.abortEarly;
|
|
2197
|
+
let seen = payload.issues.length;
|
|
2198
|
+
for (const key of value.allKeys) {
|
|
2199
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
2200
|
+
if (aborted(payload, seen))
|
|
2201
|
+
break;
|
|
2202
|
+
seen = payload.issues.length;
|
|
2203
|
+
}
|
|
2204
|
+
if (key === "__proto__")
|
|
2205
|
+
continue;
|
|
1861
2206
|
const el = shape[key];
|
|
1862
|
-
const
|
|
1863
|
-
const
|
|
2207
|
+
const optin = el._zod.optin;
|
|
2208
|
+
const optout = el._zod.optout;
|
|
1864
2209
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1865
2210
|
if (r instanceof Promise) {
|
|
1866
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
2211
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
1867
2212
|
} else {
|
|
1868
|
-
handlePropertyResult(r, payload, key, input,
|
|
2213
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1869
2214
|
}
|
|
1870
2215
|
}
|
|
1871
2216
|
if (!catchall) {
|
|
1872
2217
|
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1873
2218
|
}
|
|
1874
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
2219
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
|
|
1875
2220
|
};
|
|
1876
2221
|
});
|
|
1877
2222
|
var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
1878
2223
|
$ZodObject.init(inst, def);
|
|
1879
2224
|
const superParse = inst._zod.parse;
|
|
1880
2225
|
const _normalized = cached(() => normalizeDef(def));
|
|
2226
|
+
const memo = globalConfig.memoizer;
|
|
1881
2227
|
const generateFastpass = (shape) => {
|
|
1882
|
-
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
1883
2228
|
const normalized = _normalized.value;
|
|
1884
|
-
const
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
2229
|
+
const syms = normalized.symbolKeys;
|
|
2230
|
+
const doc = new Doc(["payload", "ctx"], { shape, inst, memo, syms });
|
|
2231
|
+
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
2232
|
+
const prefixStr = (id, k) => `
|
|
2233
|
+
let ${id}_ab = false;
|
|
2234
|
+
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
2235
|
+
const iss = ${id}.issues[i];
|
|
2236
|
+
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
2237
|
+
payload.issues.push(iss);
|
|
2238
|
+
if (iss.continue !== true) ${id}_ab = true;
|
|
2239
|
+
}
|
|
2240
|
+
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
2241
|
+
payload.value = newResult;
|
|
2242
|
+
return payload;
|
|
2243
|
+
}`;
|
|
1888
2244
|
doc.write(`const input = payload.value;`);
|
|
1889
2245
|
const ids = Object.create(null);
|
|
1890
2246
|
let counter = 0;
|
|
1891
|
-
for (const key of normalized.
|
|
2247
|
+
for (const key of normalized.allKeys) {
|
|
1892
2248
|
ids[key] = `key_${counter++}`;
|
|
1893
2249
|
}
|
|
1894
|
-
doc.write(`const newResult = {};`);
|
|
1895
|
-
for (const key of normalized.
|
|
2250
|
+
doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
2251
|
+
for (const key of normalized.allKeys) {
|
|
2252
|
+
if (key === "__proto__")
|
|
2253
|
+
continue;
|
|
1896
2254
|
const id = ids[key];
|
|
1897
|
-
const k = esc(key);
|
|
2255
|
+
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
|
|
2256
|
+
const isPresent = `${k} in input`;
|
|
1898
2257
|
const schema = shape[key];
|
|
1899
|
-
const
|
|
2258
|
+
const optin = schema?._zod?.optin;
|
|
2259
|
+
const isOptionalIn = optin !== undefined;
|
|
1900
2260
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
1901
|
-
doc.write(`const ${id} = ${parseStr(
|
|
2261
|
+
doc.write(`const ${id} = ${parseStr(k)};`);
|
|
1902
2262
|
if (isOptionalIn && isOptionalOut) {
|
|
2263
|
+
const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
|
|
1903
2264
|
doc.write(`
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
...iss,
|
|
1908
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1909
|
-
})));
|
|
2265
|
+
const ${id}_present = ${isPresent};
|
|
2266
|
+
if (!${id}.issues.length || ${id}_present) {
|
|
2267
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1910
2268
|
}
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
if (${k} in input) {
|
|
1915
|
-
newResult[${k}] = undefined;
|
|
2269
|
+
|
|
2270
|
+
if (${assign}) {
|
|
2271
|
+
newResult[${k}] = ${id}.value;
|
|
1916
2272
|
}
|
|
1917
|
-
} else {
|
|
1918
|
-
newResult[${k}] = ${id}.value;
|
|
1919
2273
|
}
|
|
1920
|
-
|
|
2274
|
+
|
|
1921
2275
|
`);
|
|
1922
2276
|
} else if (!isOptionalIn) {
|
|
1923
2277
|
doc.write(`
|
|
1924
|
-
const ${id}_present = ${
|
|
1925
|
-
if (${id}.issues.length) {
|
|
1926
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1927
|
-
...iss,
|
|
1928
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1929
|
-
})));
|
|
2278
|
+
const ${id}_present = ${isPresent};
|
|
2279
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1930
2280
|
}
|
|
1931
2281
|
if (!${id}_present && !${id}.issues.length) {
|
|
1932
2282
|
payload.issues.push({
|
|
@@ -1935,41 +2285,36 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
1935
2285
|
input: undefined,
|
|
1936
2286
|
path: [${k}]
|
|
1937
2287
|
});
|
|
2288
|
+
if (ctx && ctx.abortEarly) {
|
|
2289
|
+
payload.value = newResult;
|
|
2290
|
+
return payload;
|
|
2291
|
+
}
|
|
1938
2292
|
}
|
|
1939
2293
|
|
|
1940
2294
|
if (${id}_present) {
|
|
1941
|
-
|
|
1942
|
-
newResult[${k}] = undefined;
|
|
1943
|
-
} else {
|
|
1944
|
-
newResult[${k}] = ${id}.value;
|
|
1945
|
-
}
|
|
2295
|
+
newResult[${k}] = ${id}.value;
|
|
1946
2296
|
}
|
|
1947
2297
|
|
|
1948
2298
|
`);
|
|
1949
2299
|
} else {
|
|
1950
2300
|
doc.write(`
|
|
1951
|
-
if (${id}.issues.length) {
|
|
1952
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1953
|
-
...iss,
|
|
1954
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1955
|
-
})));
|
|
2301
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1956
2302
|
}
|
|
1957
|
-
|
|
1958
|
-
if (
|
|
1959
|
-
|
|
1960
|
-
newResult[${k}] = undefined;
|
|
1961
|
-
}
|
|
2303
|
+
`);
|
|
2304
|
+
if (optin === "defaulted") {
|
|
2305
|
+
doc.write(`newResult[${k}] = ${id}.value;`);
|
|
1962
2306
|
} else {
|
|
2307
|
+
doc.write(`
|
|
2308
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
1963
2309
|
newResult[${k}] = ${id}.value;
|
|
1964
2310
|
}
|
|
1965
|
-
|
|
1966
2311
|
`);
|
|
2312
|
+
}
|
|
1967
2313
|
}
|
|
1968
2314
|
}
|
|
1969
2315
|
doc.write(`payload.value = newResult;`);
|
|
1970
2316
|
doc.write(`return payload;`);
|
|
1971
|
-
|
|
1972
|
-
return (payload, ctx) => fn(shape, payload, ctx);
|
|
2317
|
+
return doc.compile();
|
|
1973
2318
|
};
|
|
1974
2319
|
let fastpass;
|
|
1975
2320
|
const isObject2 = isObject;
|
|
@@ -1996,7 +2341,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
1996
2341
|
payload = fastpass(payload, ctx);
|
|
1997
2342
|
if (!catchall)
|
|
1998
2343
|
return payload;
|
|
1999
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
2344
|
+
return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
|
|
2000
2345
|
}
|
|
2001
2346
|
return superParse(payload, ctx);
|
|
2002
2347
|
};
|
|
@@ -2023,17 +2368,17 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
2023
2368
|
}
|
|
2024
2369
|
var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
2025
2370
|
$ZodType.init(inst, def);
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
if (def.options.every((o) => o._zod.values)) {
|
|
2030
|
-
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
2371
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted") ? "defaulted" : zod.def.options.some((o) => o._zod.optin !== undefined) ? "optional" : undefined);
|
|
2372
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
|
2373
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2374
|
+
if (zod.def.options.every((o) => o._zod.values)) {
|
|
2375
|
+
return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
2031
2376
|
}
|
|
2032
2377
|
return;
|
|
2033
2378
|
});
|
|
2034
|
-
|
|
2035
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
2036
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
2379
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2380
|
+
if (zod.def.options.every((o) => o._zod.pattern)) {
|
|
2381
|
+
const patterns = zod.def.options.map((o) => o._zod.pattern);
|
|
2037
2382
|
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
2038
2383
|
}
|
|
2039
2384
|
return;
|
|
@@ -2092,7 +2437,11 @@ function mergeValues(a, b) {
|
|
|
2092
2437
|
const bKeys = Object.keys(b);
|
|
2093
2438
|
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
2094
2439
|
const newObj = { ...a, ...b };
|
|
2440
|
+
if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
|
|
2441
|
+
delete newObj.__proto__;
|
|
2095
2442
|
for (const key of sharedKeys) {
|
|
2443
|
+
if (key === "__proto__")
|
|
2444
|
+
continue;
|
|
2096
2445
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
2097
2446
|
if (!sharedValue.valid) {
|
|
2098
2447
|
return {
|
|
@@ -2128,37 +2477,49 @@ function mergeValues(a, b) {
|
|
|
2128
2477
|
function handleIntersectionResults(result, left, right) {
|
|
2129
2478
|
const unrecKeys = new Map;
|
|
2130
2479
|
let unrecIssue;
|
|
2131
|
-
|
|
2132
|
-
|
|
2480
|
+
const keyIssues = new Map;
|
|
2481
|
+
const collect = (iss, side) => {
|
|
2482
|
+
let keys;
|
|
2483
|
+
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
2133
2484
|
unrecIssue ?? (unrecIssue = iss);
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2485
|
+
keys = iss.keys;
|
|
2486
|
+
} else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
|
|
2487
|
+
const k = String(iss.path[0]);
|
|
2488
|
+
if (!keyIssues.has(k))
|
|
2489
|
+
keyIssues.set(k, iss);
|
|
2490
|
+
keys = [k];
|
|
2139
2491
|
} else {
|
|
2140
|
-
|
|
2492
|
+
return false;
|
|
2141
2493
|
}
|
|
2494
|
+
for (const k of keys) {
|
|
2495
|
+
if (!unrecKeys.has(k))
|
|
2496
|
+
unrecKeys.set(k, {});
|
|
2497
|
+
unrecKeys.get(k)[side] = true;
|
|
2498
|
+
}
|
|
2499
|
+
return true;
|
|
2500
|
+
};
|
|
2501
|
+
for (const iss of left.issues) {
|
|
2502
|
+
if (!collect(iss, "l"))
|
|
2503
|
+
result.issues.push(iss);
|
|
2142
2504
|
}
|
|
2143
2505
|
for (const iss of right.issues) {
|
|
2144
|
-
if (iss
|
|
2145
|
-
for (const k of iss.keys) {
|
|
2146
|
-
if (!unrecKeys.has(k))
|
|
2147
|
-
unrecKeys.set(k, {});
|
|
2148
|
-
unrecKeys.get(k).r = true;
|
|
2149
|
-
}
|
|
2150
|
-
} else {
|
|
2506
|
+
if (!collect(iss, "r"))
|
|
2151
2507
|
result.issues.push(iss);
|
|
2152
|
-
}
|
|
2153
2508
|
}
|
|
2154
2509
|
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
2155
|
-
if (bothKeys.length
|
|
2156
|
-
|
|
2510
|
+
if (bothKeys.length) {
|
|
2511
|
+
const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
|
|
2512
|
+
if (aggregated.length)
|
|
2513
|
+
result.issues.push({ ...unrecIssue, keys: aggregated });
|
|
2514
|
+
for (const k of bothKeys) {
|
|
2515
|
+
if (!aggregated.includes(k) && keyIssues.has(k))
|
|
2516
|
+
result.issues.push(keyIssues.get(k));
|
|
2517
|
+
}
|
|
2157
2518
|
}
|
|
2158
|
-
if (aborted(result))
|
|
2159
|
-
return result;
|
|
2160
2519
|
const merged = mergeValues(left.value, right.value);
|
|
2161
2520
|
if (!merged.valid) {
|
|
2521
|
+
if (aborted(result))
|
|
2522
|
+
return result;
|
|
2162
2523
|
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
|
2163
2524
|
}
|
|
2164
2525
|
result.value = merged.data;
|
|
@@ -2166,6 +2527,8 @@ function handleIntersectionResults(result, left, right) {
|
|
|
2166
2527
|
}
|
|
2167
2528
|
var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
2168
2529
|
$ZodType.init(inst, def);
|
|
2530
|
+
const memo = globalConfig.memoizer;
|
|
2531
|
+
memo?.attach(inst);
|
|
2169
2532
|
inst._zod.parse = (payload, ctx) => {
|
|
2170
2533
|
const input = payload.value;
|
|
2171
2534
|
if (!isPlainObject(input)) {
|
|
@@ -2179,12 +2542,14 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
2179
2542
|
}
|
|
2180
2543
|
const proms = [];
|
|
2181
2544
|
const values = def.keyType._zod.values;
|
|
2182
|
-
if (values) {
|
|
2183
|
-
payload.value = {};
|
|
2545
|
+
if (values && !def.partial) {
|
|
2546
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
2184
2547
|
const recordKeys = new Set;
|
|
2185
2548
|
for (const key of values) {
|
|
2186
2549
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
2187
2550
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
2551
|
+
if (key === "__proto__")
|
|
2552
|
+
continue;
|
|
2188
2553
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
2189
2554
|
if (keyResult instanceof Promise) {
|
|
2190
2555
|
throw new Error("Async schemas not supported in object keys currently");
|
|
@@ -2201,6 +2566,8 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
2201
2566
|
continue;
|
|
2202
2567
|
}
|
|
2203
2568
|
const outKey = keyResult.value;
|
|
2569
|
+
if (outKey === "__proto__")
|
|
2570
|
+
continue;
|
|
2204
2571
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2205
2572
|
if (result instanceof Promise) {
|
|
2206
2573
|
proms.push(result.then((result) => {
|
|
@@ -2220,8 +2587,14 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
2220
2587
|
let unrecognized;
|
|
2221
2588
|
for (const key in input) {
|
|
2222
2589
|
if (!recordKeys.has(key)) {
|
|
2223
|
-
|
|
2224
|
-
|
|
2590
|
+
if (def.mode === "loose") {
|
|
2591
|
+
if (key === "__proto__")
|
|
2592
|
+
continue;
|
|
2593
|
+
payload.value[key] = input[key];
|
|
2594
|
+
} else {
|
|
2595
|
+
unrecognized = unrecognized ?? [];
|
|
2596
|
+
unrecognized.push(key);
|
|
2597
|
+
}
|
|
2225
2598
|
}
|
|
2226
2599
|
}
|
|
2227
2600
|
if (unrecognized && unrecognized.length > 0) {
|
|
@@ -2229,11 +2602,13 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
2229
2602
|
code: "unrecognized_keys",
|
|
2230
2603
|
input,
|
|
2231
2604
|
inst,
|
|
2232
|
-
keys: unrecognized
|
|
2605
|
+
keys: unrecognized,
|
|
2606
|
+
continue: true
|
|
2233
2607
|
});
|
|
2234
2608
|
}
|
|
2235
2609
|
} else {
|
|
2236
|
-
payload.value = {};
|
|
2610
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
2611
|
+
let unrecognized;
|
|
2237
2612
|
for (const key of Reflect.ownKeys(input)) {
|
|
2238
2613
|
if (key === "__proto__")
|
|
2239
2614
|
continue;
|
|
@@ -2256,6 +2631,9 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
2256
2631
|
if (keyResult.issues.length) {
|
|
2257
2632
|
if (def.mode === "loose") {
|
|
2258
2633
|
payload.value[key] = input[key];
|
|
2634
|
+
} else if (values) {
|
|
2635
|
+
unrecognized = unrecognized ?? [];
|
|
2636
|
+
unrecognized.push(key);
|
|
2259
2637
|
} else {
|
|
2260
2638
|
payload.issues.push({
|
|
2261
2639
|
code: "invalid_key",
|
|
@@ -2268,21 +2646,33 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
2268
2646
|
}
|
|
2269
2647
|
continue;
|
|
2270
2648
|
}
|
|
2649
|
+
const outKey = keyResult.value;
|
|
2650
|
+
if (outKey === "__proto__")
|
|
2651
|
+
continue;
|
|
2271
2652
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2272
2653
|
if (result instanceof Promise) {
|
|
2273
2654
|
proms.push(result.then((result) => {
|
|
2274
2655
|
if (result.issues.length) {
|
|
2275
2656
|
payload.issues.push(...prefixIssues(key, result.issues));
|
|
2276
2657
|
}
|
|
2277
|
-
payload.value[
|
|
2658
|
+
payload.value[outKey] = result.value;
|
|
2278
2659
|
}));
|
|
2279
2660
|
} else {
|
|
2280
2661
|
if (result.issues.length) {
|
|
2281
2662
|
payload.issues.push(...prefixIssues(key, result.issues));
|
|
2282
2663
|
}
|
|
2283
|
-
payload.value[
|
|
2664
|
+
payload.value[outKey] = result.value;
|
|
2284
2665
|
}
|
|
2285
2666
|
}
|
|
2667
|
+
if (unrecognized && unrecognized.length > 0) {
|
|
2668
|
+
payload.issues.push({
|
|
2669
|
+
code: "unrecognized_keys",
|
|
2670
|
+
input,
|
|
2671
|
+
inst,
|
|
2672
|
+
keys: unrecognized,
|
|
2673
|
+
continue: true
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2286
2676
|
}
|
|
2287
2677
|
if (proms.length) {
|
|
2288
2678
|
return Promise.all(proms).then(() => payload);
|
|
@@ -2295,7 +2685,10 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
2295
2685
|
const values = getEnumValues(def.entries);
|
|
2296
2686
|
const valuesSet = new Set(values);
|
|
2297
2687
|
inst._zod.values = valuesSet;
|
|
2298
|
-
inst
|
|
2688
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2689
|
+
const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
|
|
2690
|
+
return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
|
|
2691
|
+
});
|
|
2299
2692
|
inst._zod.parse = (payload, _ctx) => {
|
|
2300
2693
|
const input = payload.value;
|
|
2301
2694
|
if (valuesSet.has(input)) {
|
|
@@ -2312,12 +2705,12 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
2312
2705
|
});
|
|
2313
2706
|
var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
2314
2707
|
$ZodType.init(inst, def);
|
|
2315
|
-
if (def.values.length === 0) {
|
|
2316
|
-
throw new Error("Cannot create literal schema with no valid values");
|
|
2317
|
-
}
|
|
2318
2708
|
const values = new Set(def.values);
|
|
2319
2709
|
inst._zod.values = values;
|
|
2320
|
-
inst
|
|
2710
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2711
|
+
const vals = zod.def.values;
|
|
2712
|
+
return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
|
|
2713
|
+
});
|
|
2321
2714
|
inst._zod.parse = (payload, _ctx) => {
|
|
2322
2715
|
const input = payload.value;
|
|
2323
2716
|
if (values.has(input)) {
|
|
@@ -2335,6 +2728,7 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
2335
2728
|
var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
2336
2729
|
$ZodType.init(inst, def);
|
|
2337
2730
|
inst._zod.optin = "optional";
|
|
2731
|
+
globalConfig.memoizer?.guard(inst);
|
|
2338
2732
|
inst._zod.parse = (payload, ctx) => {
|
|
2339
2733
|
if (ctx.direction === "backward") {
|
|
2340
2734
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -2344,7 +2738,6 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
|
|
|
2344
2738
|
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
2345
2739
|
return output.then((output) => {
|
|
2346
2740
|
payload.value = output;
|
|
2347
|
-
payload.fallback = true;
|
|
2348
2741
|
return payload;
|
|
2349
2742
|
});
|
|
2350
2743
|
}
|
|
@@ -2352,59 +2745,55 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
|
|
|
2352
2745
|
throw new $ZodAsyncError;
|
|
2353
2746
|
}
|
|
2354
2747
|
payload.value = _out;
|
|
2355
|
-
payload.fallback = true;
|
|
2356
2748
|
return payload;
|
|
2357
2749
|
};
|
|
2358
2750
|
});
|
|
2359
|
-
function handleOptionalResult(
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
}
|
|
2363
|
-
return result;
|
|
2751
|
+
function handleOptionalResult(payload, result) {
|
|
2752
|
+
payload.value = result.issues.length ? undefined : result.value;
|
|
2753
|
+
return payload;
|
|
2364
2754
|
}
|
|
2365
2755
|
var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
2366
2756
|
$ZodType.init(inst, def);
|
|
2367
|
-
inst._zod.optin
|
|
2757
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2368
2758
|
inst._zod.optout = "optional";
|
|
2369
|
-
|
|
2370
|
-
|
|
2759
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2760
|
+
const values = zod.def.innerType._zod.values;
|
|
2761
|
+
return values ? new Set([...values, undefined]) : undefined;
|
|
2371
2762
|
});
|
|
2372
|
-
|
|
2373
|
-
const pattern = def.innerType._zod.pattern;
|
|
2763
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2764
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
2374
2765
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : undefined;
|
|
2375
2766
|
});
|
|
2376
2767
|
inst._zod.parse = (payload, ctx) => {
|
|
2377
|
-
if (def.innerType._zod.optin === "optional") {
|
|
2378
|
-
const input = payload.value;
|
|
2379
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2380
|
-
if (result instanceof Promise)
|
|
2381
|
-
return result.then((r) => handleOptionalResult(r, input));
|
|
2382
|
-
return handleOptionalResult(result, input);
|
|
2383
|
-
}
|
|
2384
2768
|
if (payload.value === undefined) {
|
|
2385
|
-
|
|
2769
|
+
if (def.innerType._zod.optin !== "defaulted")
|
|
2770
|
+
return payload;
|
|
2771
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
2772
|
+
if (result instanceof Promise)
|
|
2773
|
+
return result.then((result) => handleOptionalResult(payload, result));
|
|
2774
|
+
return handleOptionalResult(payload, result);
|
|
2386
2775
|
}
|
|
2387
2776
|
return def.innerType._zod.run(payload, ctx);
|
|
2388
2777
|
};
|
|
2389
2778
|
});
|
|
2390
2779
|
var $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
2391
2780
|
$ZodOptional.init(inst, def);
|
|
2392
|
-
|
|
2393
|
-
|
|
2781
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2782
|
+
defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
|
|
2394
2783
|
inst._zod.parse = (payload, ctx) => {
|
|
2395
2784
|
return def.innerType._zod.run(payload, ctx);
|
|
2396
2785
|
};
|
|
2397
2786
|
});
|
|
2398
2787
|
var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
2399
2788
|
$ZodType.init(inst, def);
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
const pattern = def.innerType._zod.pattern;
|
|
2789
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
|
|
2790
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2791
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2792
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
2404
2793
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : undefined;
|
|
2405
2794
|
});
|
|
2406
|
-
|
|
2407
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
|
2795
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2796
|
+
return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : undefined;
|
|
2408
2797
|
});
|
|
2409
2798
|
inst._zod.parse = (payload, ctx) => {
|
|
2410
2799
|
if (payload.value === null)
|
|
@@ -2414,8 +2803,8 @@ var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
|
2414
2803
|
});
|
|
2415
2804
|
var $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
2416
2805
|
$ZodType.init(inst, def);
|
|
2417
|
-
inst._zod.optin = "
|
|
2418
|
-
|
|
2806
|
+
inst._zod.optin = "defaulted";
|
|
2807
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2419
2808
|
inst._zod.parse = (payload, ctx) => {
|
|
2420
2809
|
if (ctx.direction === "backward") {
|
|
2421
2810
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -2439,8 +2828,8 @@ function handleDefaultResult(payload, def) {
|
|
|
2439
2828
|
}
|
|
2440
2829
|
var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
2441
2830
|
$ZodType.init(inst, def);
|
|
2442
|
-
inst._zod.optin = "
|
|
2443
|
-
|
|
2831
|
+
inst._zod.optin = "defaulted";
|
|
2832
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2444
2833
|
inst._zod.parse = (payload, ctx) => {
|
|
2445
2834
|
if (ctx.direction === "backward") {
|
|
2446
2835
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -2453,8 +2842,8 @@ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
|
2453
2842
|
});
|
|
2454
2843
|
var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
2455
2844
|
$ZodType.init(inst, def);
|
|
2456
|
-
|
|
2457
|
-
const v = def.innerType._zod.values;
|
|
2845
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2846
|
+
const v = zod.def.innerType._zod.values;
|
|
2458
2847
|
return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
|
|
2459
2848
|
});
|
|
2460
2849
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -2476,54 +2865,45 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
2476
2865
|
}
|
|
2477
2866
|
return payload;
|
|
2478
2867
|
}
|
|
2868
|
+
function handleCatchResult(payload, result, def, ctx) {
|
|
2869
|
+
if (!result.issues.length) {
|
|
2870
|
+
payload.value = result.value;
|
|
2871
|
+
if (result.memo)
|
|
2872
|
+
payload.memo = true;
|
|
2873
|
+
return payload;
|
|
2874
|
+
}
|
|
2875
|
+
payload.value = def.catchValue({
|
|
2876
|
+
...result,
|
|
2877
|
+
value: payload.value,
|
|
2878
|
+
error: {
|
|
2879
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
2880
|
+
},
|
|
2881
|
+
input: payload.value
|
|
2882
|
+
});
|
|
2883
|
+
return payload;
|
|
2884
|
+
}
|
|
2479
2885
|
var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
2480
2886
|
$ZodType.init(inst, def);
|
|
2481
|
-
inst._zod.optin
|
|
2482
|
-
|
|
2483
|
-
|
|
2887
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2888
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2889
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2484
2890
|
inst._zod.parse = (payload, ctx) => {
|
|
2485
2891
|
if (ctx.direction === "backward") {
|
|
2486
2892
|
return def.innerType._zod.run(payload, ctx);
|
|
2487
2893
|
}
|
|
2488
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2894
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
2489
2895
|
if (result instanceof Promise) {
|
|
2490
|
-
return result.then((result) =>
|
|
2491
|
-
payload.value = result.value;
|
|
2492
|
-
if (result.issues.length) {
|
|
2493
|
-
payload.value = def.catchValue({
|
|
2494
|
-
...payload,
|
|
2495
|
-
error: {
|
|
2496
|
-
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
2497
|
-
},
|
|
2498
|
-
input: payload.value
|
|
2499
|
-
});
|
|
2500
|
-
payload.issues = [];
|
|
2501
|
-
payload.fallback = true;
|
|
2502
|
-
}
|
|
2503
|
-
return payload;
|
|
2504
|
-
});
|
|
2505
|
-
}
|
|
2506
|
-
payload.value = result.value;
|
|
2507
|
-
if (result.issues.length) {
|
|
2508
|
-
payload.value = def.catchValue({
|
|
2509
|
-
...payload,
|
|
2510
|
-
error: {
|
|
2511
|
-
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
2512
|
-
},
|
|
2513
|
-
input: payload.value
|
|
2514
|
-
});
|
|
2515
|
-
payload.issues = [];
|
|
2516
|
-
payload.fallback = true;
|
|
2896
|
+
return result.then((result) => handleCatchResult(payload, result, def, ctx));
|
|
2517
2897
|
}
|
|
2518
|
-
return payload;
|
|
2898
|
+
return handleCatchResult(payload, result, def, ctx);
|
|
2519
2899
|
};
|
|
2520
2900
|
});
|
|
2521
2901
|
var $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
2522
2902
|
$ZodType.init(inst, def);
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2903
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2904
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2905
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2906
|
+
defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
2527
2907
|
inst._zod.parse = (payload, ctx) => {
|
|
2528
2908
|
if (ctx.direction === "backward") {
|
|
2529
2909
|
const right = def.out._zod.run(payload, ctx);
|
|
@@ -2540,18 +2920,18 @@ var $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
|
2540
2920
|
};
|
|
2541
2921
|
});
|
|
2542
2922
|
function handlePipeResult(left, next, ctx) {
|
|
2543
|
-
if (left.issues.
|
|
2923
|
+
if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
|
|
2544
2924
|
left.aborted = true;
|
|
2545
2925
|
return left;
|
|
2546
2926
|
}
|
|
2547
|
-
return next._zod.run({ value: left.value, issues: left.issues
|
|
2927
|
+
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
2548
2928
|
}
|
|
2549
2929
|
var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
2550
2930
|
$ZodType.init(inst, def);
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2931
|
+
defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
2932
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2933
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
|
|
2934
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
|
|
2555
2935
|
inst._zod.parse = (payload, ctx) => {
|
|
2556
2936
|
if (ctx.direction === "backward") {
|
|
2557
2937
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -2564,7 +2944,8 @@ var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
|
2564
2944
|
};
|
|
2565
2945
|
});
|
|
2566
2946
|
function handleReadonlyResult(payload) {
|
|
2567
|
-
|
|
2947
|
+
if (!payload.memo)
|
|
2948
|
+
payload.value = Object.freeze(payload.value);
|
|
2568
2949
|
return payload;
|
|
2569
2950
|
}
|
|
2570
2951
|
var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
@@ -2597,7 +2978,276 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
2597
2978
|
payload.issues.push(issue(_iss));
|
|
2598
2979
|
}
|
|
2599
2980
|
}
|
|
2600
|
-
// ../../node_modules/.bun/zod@4.
|
|
2981
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/memoizer.js
|
|
2982
|
+
class $ZodCyclicError extends Error {
|
|
2983
|
+
constructor() {
|
|
2984
|
+
super(`Cannot parse a reference cycle that closes through a transform`);
|
|
2985
|
+
this.name = "ZodCyclicError";
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
var STATE = "~memo";
|
|
2989
|
+
var NO_ISSUES = [];
|
|
2990
|
+
function isRef(value) {
|
|
2991
|
+
return value !== null && typeof value === "object";
|
|
2992
|
+
}
|
|
2993
|
+
function cloneIssues(issues) {
|
|
2994
|
+
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
2995
|
+
}
|
|
2996
|
+
var recursive = /* @__PURE__ */ new WeakMap;
|
|
2997
|
+
var NONE = 0;
|
|
2998
|
+
var ASSUMED = 1;
|
|
2999
|
+
var PROVEN = 2;
|
|
3000
|
+
function isRecursive(inst, stack, resolve) {
|
|
3001
|
+
const cached = recursive.get(inst);
|
|
3002
|
+
if (cached !== undefined)
|
|
3003
|
+
return cached ? PROVEN : NONE;
|
|
3004
|
+
if (stack.has(inst))
|
|
3005
|
+
return PROVEN;
|
|
3006
|
+
stack.add(inst);
|
|
3007
|
+
let result = NONE;
|
|
3008
|
+
const check = (child) => {
|
|
3009
|
+
if (result !== PROVEN && child?._zod) {
|
|
3010
|
+
const answer = isRecursive(child, stack, resolve);
|
|
3011
|
+
if (answer > result)
|
|
3012
|
+
result = answer;
|
|
3013
|
+
}
|
|
3014
|
+
};
|
|
3015
|
+
const shape = (sh, spread) => {
|
|
3016
|
+
let answer = NONE;
|
|
3017
|
+
for (const key of Reflect.ownKeys(sh)) {
|
|
3018
|
+
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
3019
|
+
if (spread && !desc.enumerable)
|
|
3020
|
+
continue;
|
|
3021
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
|
|
3022
|
+
if (child > answer)
|
|
3023
|
+
answer = child;
|
|
3024
|
+
}
|
|
3025
|
+
return answer;
|
|
3026
|
+
};
|
|
3027
|
+
const merge = (answer) => {
|
|
3028
|
+
if (answer > result)
|
|
3029
|
+
result = answer;
|
|
3030
|
+
};
|
|
3031
|
+
const def = inst._zod.def;
|
|
3032
|
+
const kind = def.type;
|
|
3033
|
+
switch (kind) {
|
|
3034
|
+
case "object": {
|
|
3035
|
+
const raw = rawShape(def);
|
|
3036
|
+
merge(raw ? shape(raw, true) : ASSUMED);
|
|
3037
|
+
check(def.catchall);
|
|
3038
|
+
break;
|
|
3039
|
+
}
|
|
3040
|
+
case "array":
|
|
3041
|
+
check(def.element);
|
|
3042
|
+
break;
|
|
3043
|
+
case "tuple":
|
|
3044
|
+
for (const el of def.items)
|
|
3045
|
+
check(el);
|
|
3046
|
+
check(def.rest);
|
|
3047
|
+
break;
|
|
3048
|
+
case "record":
|
|
3049
|
+
case "map":
|
|
3050
|
+
check(def.keyType);
|
|
3051
|
+
check(def.valueType);
|
|
3052
|
+
break;
|
|
3053
|
+
case "set":
|
|
3054
|
+
check(def.valueType);
|
|
3055
|
+
break;
|
|
3056
|
+
case "union":
|
|
3057
|
+
for (const el of def.options)
|
|
3058
|
+
check(el);
|
|
3059
|
+
break;
|
|
3060
|
+
case "intersection":
|
|
3061
|
+
check(def.left);
|
|
3062
|
+
check(def.right);
|
|
3063
|
+
break;
|
|
3064
|
+
case "optional":
|
|
3065
|
+
case "nullable":
|
|
3066
|
+
case "default":
|
|
3067
|
+
case "prefault":
|
|
3068
|
+
case "catch":
|
|
3069
|
+
case "readonly":
|
|
3070
|
+
case "nonoptional":
|
|
3071
|
+
case "promise":
|
|
3072
|
+
case "success":
|
|
3073
|
+
check(def.innerType);
|
|
3074
|
+
break;
|
|
3075
|
+
case "pipe":
|
|
3076
|
+
check(def.in);
|
|
3077
|
+
check(def.out);
|
|
3078
|
+
break;
|
|
3079
|
+
case "function":
|
|
3080
|
+
check(def.input);
|
|
3081
|
+
check(def.output);
|
|
3082
|
+
break;
|
|
3083
|
+
case "lazy": {
|
|
3084
|
+
const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : undefined);
|
|
3085
|
+
merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
3086
|
+
break;
|
|
3087
|
+
}
|
|
3088
|
+
case "template_literal":
|
|
3089
|
+
case "string":
|
|
3090
|
+
case "number":
|
|
3091
|
+
case "int":
|
|
3092
|
+
case "boolean":
|
|
3093
|
+
case "bigint":
|
|
3094
|
+
case "symbol":
|
|
3095
|
+
case "undefined":
|
|
3096
|
+
case "null":
|
|
3097
|
+
case "void":
|
|
3098
|
+
case "never":
|
|
3099
|
+
case "any":
|
|
3100
|
+
case "unknown":
|
|
3101
|
+
case "date":
|
|
3102
|
+
case "nan":
|
|
3103
|
+
case "enum":
|
|
3104
|
+
case "literal":
|
|
3105
|
+
case "file":
|
|
3106
|
+
case "transform":
|
|
3107
|
+
case "custom":
|
|
3108
|
+
break;
|
|
3109
|
+
default: {
|
|
3110
|
+
for (const key in def) {
|
|
3111
|
+
const desc = Object.getOwnPropertyDescriptor(def, key);
|
|
3112
|
+
if (!desc || desc.get)
|
|
3113
|
+
continue;
|
|
3114
|
+
const value = desc.value;
|
|
3115
|
+
if (!value || typeof value !== "object")
|
|
3116
|
+
continue;
|
|
3117
|
+
if (value._zod)
|
|
3118
|
+
check(value);
|
|
3119
|
+
else if (Array.isArray(value))
|
|
3120
|
+
for (const el of value)
|
|
3121
|
+
check(el);
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
stack.delete(inst);
|
|
3126
|
+
return settle(inst, result);
|
|
3127
|
+
}
|
|
3128
|
+
function settle(inst, answer) {
|
|
3129
|
+
if (answer !== ASSUMED)
|
|
3130
|
+
recursive.set(inst, answer === PROVEN);
|
|
3131
|
+
return answer;
|
|
3132
|
+
}
|
|
3133
|
+
function bucketFor(state, inst) {
|
|
3134
|
+
let bucket = state.buckets.get(inst);
|
|
3135
|
+
if (!bucket) {
|
|
3136
|
+
bucket = new WeakMap;
|
|
3137
|
+
state.buckets.set(inst, bucket);
|
|
3138
|
+
}
|
|
3139
|
+
return bucket;
|
|
3140
|
+
}
|
|
3141
|
+
var handoff;
|
|
3142
|
+
var open = [];
|
|
3143
|
+
var memo = {
|
|
3144
|
+
alloc(_inst, payload, empty) {
|
|
3145
|
+
const bucket = handoff;
|
|
3146
|
+
if (!bucket)
|
|
3147
|
+
return empty;
|
|
3148
|
+
handoff = undefined;
|
|
3149
|
+
const entry = { value: empty, issues: null };
|
|
3150
|
+
bucket.set(payload.value, entry);
|
|
3151
|
+
open.push(entry);
|
|
3152
|
+
return empty;
|
|
3153
|
+
},
|
|
3154
|
+
guard(inst) {
|
|
3155
|
+
var _a;
|
|
3156
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
3157
|
+
inst._zod.deferred.push(() => {
|
|
3158
|
+
const base = inst._zod.parse;
|
|
3159
|
+
const wrapped = (payload, ctx) => {
|
|
3160
|
+
if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value))
|
|
3161
|
+
throw new $ZodCyclicError;
|
|
3162
|
+
return base(payload, ctx);
|
|
3163
|
+
};
|
|
3164
|
+
inst._zod.parse = wrapped;
|
|
3165
|
+
if (inst._zod.run === base)
|
|
3166
|
+
inst._zod.run = wrapped;
|
|
3167
|
+
});
|
|
3168
|
+
},
|
|
3169
|
+
attach(inst) {
|
|
3170
|
+
var _a;
|
|
3171
|
+
let isRecursiveInst;
|
|
3172
|
+
let rechecked = false;
|
|
3173
|
+
let lastCtx;
|
|
3174
|
+
let lastBucket;
|
|
3175
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
3176
|
+
inst._zod.deferred.push(() => {
|
|
3177
|
+
const base = inst._zod.parse;
|
|
3178
|
+
const wrapped = (payload, ctx) => {
|
|
3179
|
+
if (isRecursiveInst === undefined) {
|
|
3180
|
+
const walked = isRecursive(inst, new Set, false);
|
|
3181
|
+
if (walked === NONE) {
|
|
3182
|
+
inst._zod.parse = base;
|
|
3183
|
+
if (inst._zod.run === wrapped)
|
|
3184
|
+
inst._zod.run = base;
|
|
3185
|
+
return base(payload, ctx);
|
|
3186
|
+
}
|
|
3187
|
+
if (walked === PROVEN || rechecked)
|
|
3188
|
+
isRecursiveInst = true;
|
|
3189
|
+
else
|
|
3190
|
+
rechecked = true;
|
|
3191
|
+
}
|
|
3192
|
+
const input = payload.value;
|
|
3193
|
+
if (!isRef(input))
|
|
3194
|
+
return base(payload, ctx);
|
|
3195
|
+
let state = ctx[STATE];
|
|
3196
|
+
if (!state) {
|
|
3197
|
+
state = { buckets: new WeakMap, backEdges: undefined };
|
|
3198
|
+
ctx[STATE] = state;
|
|
3199
|
+
}
|
|
3200
|
+
let bucket;
|
|
3201
|
+
if (lastCtx === ctx) {
|
|
3202
|
+
bucket = lastBucket;
|
|
3203
|
+
} else {
|
|
3204
|
+
bucket = bucketFor(state, inst);
|
|
3205
|
+
lastCtx = ctx;
|
|
3206
|
+
lastBucket = bucket;
|
|
3207
|
+
}
|
|
3208
|
+
const hit = bucket.get(input);
|
|
3209
|
+
if (hit) {
|
|
3210
|
+
payload.value = hit.value;
|
|
3211
|
+
if (hit.issues) {
|
|
3212
|
+
if (hit.issues.length)
|
|
3213
|
+
payload.issues.push(...cloneIssues(hit.issues));
|
|
3214
|
+
} else {
|
|
3215
|
+
payload.memo = true;
|
|
3216
|
+
state.backEdges ?? (state.backEdges = new WeakSet);
|
|
3217
|
+
state.backEdges.add(hit.value);
|
|
3218
|
+
}
|
|
3219
|
+
return payload;
|
|
3220
|
+
}
|
|
3221
|
+
handoff = bucket;
|
|
3222
|
+
const depth = open.length;
|
|
3223
|
+
const result = base(payload, ctx);
|
|
3224
|
+
handoff = undefined;
|
|
3225
|
+
const entry = open.length > depth ? open.pop() : undefined;
|
|
3226
|
+
if (result instanceof Promise) {
|
|
3227
|
+
return result.then((r) => {
|
|
3228
|
+
if (entry)
|
|
3229
|
+
entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
|
|
3230
|
+
return r;
|
|
3231
|
+
});
|
|
3232
|
+
}
|
|
3233
|
+
if (entry)
|
|
3234
|
+
entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
|
|
3235
|
+
return result;
|
|
3236
|
+
};
|
|
3237
|
+
inst._zod.parse = wrapped;
|
|
3238
|
+
if (inst._zod.run === base)
|
|
3239
|
+
inst._zod.run = wrapped;
|
|
3240
|
+
});
|
|
3241
|
+
}
|
|
3242
|
+
};
|
|
3243
|
+
function memoizer() {
|
|
3244
|
+
return memo;
|
|
3245
|
+
}
|
|
3246
|
+
function isBackEdge(ctx, value) {
|
|
3247
|
+
const backEdges = ctx[STATE]?.backEdges;
|
|
3248
|
+
return backEdges !== undefined && isRef(value) && backEdges.has(value);
|
|
3249
|
+
}
|
|
3250
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/locales/en.js
|
|
2601
3251
|
var error = () => {
|
|
2602
3252
|
const Sizable = {
|
|
2603
3253
|
string: { unit: "characters", verb: "to have" },
|
|
@@ -2637,18 +3287,27 @@ var error = () => {
|
|
|
2637
3287
|
base64url: "base64url-encoded string",
|
|
2638
3288
|
json_string: "JSON string",
|
|
2639
3289
|
e164: "E.164 number",
|
|
3290
|
+
currency_code: "currency code",
|
|
3291
|
+
credit_card: "credit card number",
|
|
3292
|
+
iban: "IBAN",
|
|
2640
3293
|
jwt: "JWT",
|
|
2641
3294
|
template_literal: "input"
|
|
2642
3295
|
};
|
|
2643
3296
|
const TypeDictionary = {
|
|
2644
3297
|
nan: "NaN"
|
|
2645
3298
|
};
|
|
3299
|
+
function getTypeName(type, input) {
|
|
3300
|
+
if (type === "number" && typeof input === "number" && !Number.isFinite(input)) {
|
|
3301
|
+
return String(input);
|
|
3302
|
+
}
|
|
3303
|
+
return TypeDictionary[type] ?? type;
|
|
3304
|
+
}
|
|
2646
3305
|
return (issue) => {
|
|
2647
3306
|
switch (issue.code) {
|
|
2648
3307
|
case "invalid_type": {
|
|
2649
|
-
const expected =
|
|
3308
|
+
const expected = getTypeName(issue.expected);
|
|
2650
3309
|
const receivedType = parsedType(issue.input);
|
|
2651
|
-
const received =
|
|
3310
|
+
const received = getTypeName(receivedType, issue.input);
|
|
2652
3311
|
return `Invalid input: expected ${expected}, received ${received}`;
|
|
2653
3312
|
}
|
|
2654
3313
|
case "invalid_value":
|
|
@@ -2656,14 +3315,14 @@ var error = () => {
|
|
|
2656
3315
|
return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
|
|
2657
3316
|
return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
|
|
2658
3317
|
case "too_big": {
|
|
2659
|
-
const adj = issue.inclusive ? "<=" : "<";
|
|
3318
|
+
const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
|
|
2660
3319
|
const sizing = getSizing(issue.origin);
|
|
2661
3320
|
if (sizing)
|
|
2662
3321
|
return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
|
2663
3322
|
return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
|
|
2664
3323
|
}
|
|
2665
3324
|
case "too_small": {
|
|
2666
|
-
const adj = issue.inclusive ? ">=" : ">";
|
|
3325
|
+
const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
|
|
2667
3326
|
const sizing = getSizing(issue.origin);
|
|
2668
3327
|
if (sizing) {
|
|
2669
3328
|
return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
@@ -2694,6 +3353,9 @@ var error = () => {
|
|
|
2694
3353
|
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
|
2695
3354
|
return `Invalid discriminator value. Expected ${opts}`;
|
|
2696
3355
|
}
|
|
3356
|
+
if (issue.inclusive === false) {
|
|
3357
|
+
return "Invalid input: more than one option matched";
|
|
3358
|
+
}
|
|
2697
3359
|
return "Invalid input";
|
|
2698
3360
|
case "invalid_element":
|
|
2699
3361
|
return `Invalid value in ${issue.origin}`;
|
|
@@ -2707,11 +3369,8 @@ function en_default() {
|
|
|
2707
3369
|
localeError: error()
|
|
2708
3370
|
};
|
|
2709
3371
|
}
|
|
2710
|
-
// ../../node_modules/.bun/zod@4.
|
|
3372
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/registries.js
|
|
2711
3373
|
var _a2;
|
|
2712
|
-
var $output = Symbol("ZodOutput");
|
|
2713
|
-
var $input = Symbol("ZodInput");
|
|
2714
|
-
|
|
2715
3374
|
class $ZodRegistry {
|
|
2716
3375
|
constructor() {
|
|
2717
3376
|
this._map = new WeakMap;
|
|
@@ -2757,12 +3416,14 @@ function registry() {
|
|
|
2757
3416
|
}
|
|
2758
3417
|
(_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
|
|
2759
3418
|
var globalRegistry = globalThis.__zod_globalRegistry;
|
|
2760
|
-
// ../../node_modules/.bun/zod@4.
|
|
3419
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/api.js
|
|
3420
|
+
function snapshotChecks(def) {
|
|
3421
|
+
if (def.checks)
|
|
3422
|
+
def.checks = [...def.checks];
|
|
3423
|
+
return def;
|
|
3424
|
+
}
|
|
2761
3425
|
function _string(Class, params) {
|
|
2762
|
-
return new Class({
|
|
2763
|
-
type: "string",
|
|
2764
|
-
...normalizeParams(params)
|
|
2765
|
-
});
|
|
3426
|
+
return new Class(snapshotChecks({ type: "string", ...normalizeParams(params) }));
|
|
2766
3427
|
}
|
|
2767
3428
|
function _email(Class, params) {
|
|
2768
3429
|
return new Class({
|
|
@@ -3002,11 +3663,7 @@ function _isoDuration(Class, params) {
|
|
|
3002
3663
|
});
|
|
3003
3664
|
}
|
|
3004
3665
|
function _number(Class, params) {
|
|
3005
|
-
return new Class({
|
|
3006
|
-
type: "number",
|
|
3007
|
-
checks: [],
|
|
3008
|
-
...normalizeParams(params)
|
|
3009
|
-
});
|
|
3666
|
+
return new Class(snapshotChecks({ type: "number", checks: [], ...normalizeParams(params) }));
|
|
3010
3667
|
}
|
|
3011
3668
|
function _int(Class, params) {
|
|
3012
3669
|
return new Class({
|
|
@@ -3188,7 +3845,8 @@ function _superRefine(fn, params) {
|
|
|
3188
3845
|
if (_issue.fatal)
|
|
3189
3846
|
_issue.continue = false;
|
|
3190
3847
|
_issue.code ?? (_issue.code = "custom");
|
|
3191
|
-
|
|
3848
|
+
if (!("input" in _issue))
|
|
3849
|
+
_issue.input = payload.value;
|
|
3192
3850
|
_issue.inst ?? (_issue.inst = ch);
|
|
3193
3851
|
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
3194
3852
|
payload.issues.push(issue(_issue));
|
|
@@ -3206,7 +3864,17 @@ function _check(fn, params) {
|
|
|
3206
3864
|
ch._zod.check = fn;
|
|
3207
3865
|
return ch;
|
|
3208
3866
|
}
|
|
3209
|
-
// ../../node_modules/.bun/zod@4.
|
|
3867
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/to-json-schema.js
|
|
3868
|
+
function assignProps(target, ...sources) {
|
|
3869
|
+
for (const source of sources) {
|
|
3870
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
3871
|
+
if (Object.prototype.propertyIsEnumerable.call(source, key)) {
|
|
3872
|
+
assignProp(target, key, source[key]);
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
return target;
|
|
3877
|
+
}
|
|
3210
3878
|
function initializeContext(params) {
|
|
3211
3879
|
let target = params?.target ?? "draft-2020-12";
|
|
3212
3880
|
if (target === "draft-4")
|
|
@@ -3222,12 +3890,25 @@ function initializeContext(params) {
|
|
|
3222
3890
|
io: params?.io ?? "output",
|
|
3223
3891
|
counter: 0,
|
|
3224
3892
|
seen: new Map,
|
|
3893
|
+
sharedDefsExtractedFor: undefined,
|
|
3894
|
+
sharedEmitDoneFor: undefined,
|
|
3225
3895
|
cycles: params?.cycles ?? "ref",
|
|
3226
3896
|
reused: params?.reused ?? "inline",
|
|
3897
|
+
intersections: [],
|
|
3898
|
+
deferred: [],
|
|
3227
3899
|
external: params?.external ?? undefined
|
|
3228
3900
|
};
|
|
3229
3901
|
}
|
|
3230
|
-
function
|
|
3902
|
+
function handleUnrepresentable(schema, ctx, json, params, message) {
|
|
3903
|
+
const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({ zodSchema: schema, path: params.path, message }) : ctx.unrepresentable;
|
|
3904
|
+
if (result === "any")
|
|
3905
|
+
return false;
|
|
3906
|
+
if (result === undefined || result === "throw")
|
|
3907
|
+
throw new Error(message);
|
|
3908
|
+
Object.assign(json, result);
|
|
3909
|
+
return true;
|
|
3910
|
+
}
|
|
3911
|
+
function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
3231
3912
|
var _a;
|
|
3232
3913
|
const def = schema._zod.def;
|
|
3233
3914
|
const seen = ctx.seen.get(schema);
|
|
@@ -3241,6 +3922,8 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
3241
3922
|
}
|
|
3242
3923
|
const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
|
|
3243
3924
|
ctx.seen.set(schema, result);
|
|
3925
|
+
ctx.sharedDefsExtractedFor = undefined;
|
|
3926
|
+
ctx.sharedEmitDoneFor = undefined;
|
|
3244
3927
|
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
3245
3928
|
if (overrideSchema) {
|
|
3246
3929
|
result.schema = overrideSchema;
|
|
@@ -3264,13 +3947,13 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
3264
3947
|
if (parent) {
|
|
3265
3948
|
if (!result.ref)
|
|
3266
3949
|
result.ref = parent;
|
|
3267
|
-
|
|
3950
|
+
processSchema(parent, ctx, params);
|
|
3268
3951
|
ctx.seen.get(parent).isParent = true;
|
|
3269
3952
|
}
|
|
3270
3953
|
}
|
|
3271
3954
|
const meta = ctx.metadataRegistry.get(schema);
|
|
3272
3955
|
if (meta)
|
|
3273
|
-
|
|
3956
|
+
assignProps(result.schema, meta);
|
|
3274
3957
|
if (ctx.io === "input" && isTransforming(schema)) {
|
|
3275
3958
|
delete result.schema.examples;
|
|
3276
3959
|
delete result.schema.default;
|
|
@@ -3281,10 +3964,15 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
3281
3964
|
const _result = ctx.seen.get(schema);
|
|
3282
3965
|
return _result.schema;
|
|
3283
3966
|
}
|
|
3967
|
+
function encodeJSONPointerSegment(segment) {
|
|
3968
|
+
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
3969
|
+
}
|
|
3284
3970
|
function extractDefs(ctx, schema) {
|
|
3285
3971
|
const root = ctx.seen.get(schema);
|
|
3286
3972
|
if (!root)
|
|
3287
3973
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3974
|
+
if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external)
|
|
3975
|
+
return;
|
|
3288
3976
|
const idToSchema = new Map;
|
|
3289
3977
|
for (const entry of ctx.seen.entries()) {
|
|
3290
3978
|
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
@@ -3306,15 +3994,15 @@ function extractDefs(ctx, schema) {
|
|
|
3306
3994
|
}
|
|
3307
3995
|
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
3308
3996
|
entry[1].defId = id;
|
|
3309
|
-
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
|
3310
|
-
}
|
|
3311
|
-
if (entry[1] === root) {
|
|
3312
|
-
return { ref: "#" };
|
|
3997
|
+
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}` };
|
|
3313
3998
|
}
|
|
3314
3999
|
const uriPrefix = `#`;
|
|
3315
4000
|
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
4001
|
+
if (entry[1] === root && !entry[1].schema.id) {
|
|
4002
|
+
return { ref: uriPrefix };
|
|
4003
|
+
}
|
|
3316
4004
|
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
3317
|
-
return { defId, ref: defUriPrefix + defId };
|
|
4005
|
+
return { defId, ref: defUriPrefix + encodeJSONPointerSegment(defId) };
|
|
3318
4006
|
};
|
|
3319
4007
|
const extractToDef = (entry) => {
|
|
3320
4008
|
if (entry[1].schema.$ref) {
|
|
@@ -3364,10 +4052,119 @@ function extractDefs(ctx, schema) {
|
|
|
3364
4052
|
if (seen.count > 1) {
|
|
3365
4053
|
if (ctx.reused === "ref") {
|
|
3366
4054
|
extractToDef(entry);
|
|
4055
|
+
}
|
|
4056
|
+
}
|
|
4057
|
+
}
|
|
4058
|
+
if (ctx.external)
|
|
4059
|
+
ctx.sharedDefsExtractedFor = ctx.external;
|
|
4060
|
+
}
|
|
4061
|
+
function compactTypeUnion(schema) {
|
|
4062
|
+
const options = schema.anyOf;
|
|
4063
|
+
if (!Array.isArray(options) || options.length === 0 || schema.type !== undefined)
|
|
4064
|
+
return;
|
|
4065
|
+
const types = [];
|
|
4066
|
+
for (const option of options) {
|
|
4067
|
+
if (!option || typeof option !== "object")
|
|
4068
|
+
return;
|
|
4069
|
+
compactTypeUnion(option);
|
|
4070
|
+
const keys = Object.keys(option);
|
|
4071
|
+
if (keys.length !== 1 || keys[0] !== "type")
|
|
4072
|
+
return;
|
|
4073
|
+
const type = option.type;
|
|
4074
|
+
for (const member of Array.isArray(type) ? type : [type]) {
|
|
4075
|
+
if (typeof member !== "string")
|
|
4076
|
+
return;
|
|
4077
|
+
if (!types.includes(member))
|
|
4078
|
+
types.push(member);
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
4081
|
+
delete schema.anyOf;
|
|
4082
|
+
schema.type = types.length === 1 ? types[0] : types;
|
|
4083
|
+
}
|
|
4084
|
+
var FOLDABLE_KEYS = new Set(["type", "properties", "required", "additionalProperties"]);
|
|
4085
|
+
var UNION_KEYS = ["oneOf", "anyOf"];
|
|
4086
|
+
function undeclaredConstraint(member) {
|
|
4087
|
+
const extra = member.additionalProperties;
|
|
4088
|
+
if (extra === undefined || extra === false || typeof extra !== "object" || extra === null)
|
|
4089
|
+
return null;
|
|
4090
|
+
return Object.keys(extra).length ? extra : null;
|
|
4091
|
+
}
|
|
4092
|
+
function foldObjects(members) {
|
|
4093
|
+
const objects = [];
|
|
4094
|
+
for (const member of members) {
|
|
4095
|
+
if (typeof member !== "object" || member.type !== "object")
|
|
4096
|
+
return null;
|
|
4097
|
+
for (const key in member) {
|
|
4098
|
+
if (!FOLDABLE_KEYS.has(key))
|
|
4099
|
+
return null;
|
|
4100
|
+
}
|
|
4101
|
+
objects.push(member);
|
|
4102
|
+
}
|
|
4103
|
+
const properties = {};
|
|
4104
|
+
const required = new Set;
|
|
4105
|
+
for (const object of objects) {
|
|
4106
|
+
for (const key in object.properties) {
|
|
4107
|
+
if (Object.prototype.hasOwnProperty.call(properties, key))
|
|
3367
4108
|
continue;
|
|
4109
|
+
const parts = [];
|
|
4110
|
+
for (const other of objects) {
|
|
4111
|
+
const part = other.properties?.[key] ?? undeclaredConstraint(other);
|
|
4112
|
+
if (part === null || part === undefined)
|
|
4113
|
+
continue;
|
|
4114
|
+
if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part)))
|
|
4115
|
+
parts.push(part);
|
|
3368
4116
|
}
|
|
4117
|
+
const merged = parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts };
|
|
4118
|
+
assignProp(properties, key, merged);
|
|
3369
4119
|
}
|
|
4120
|
+
for (const key of object.required ?? [])
|
|
4121
|
+
required.add(key);
|
|
4122
|
+
}
|
|
4123
|
+
const folded = { type: "object", properties };
|
|
4124
|
+
if (required.size)
|
|
4125
|
+
folded.required = [...required];
|
|
4126
|
+
if (objects.every((object) => object.additionalProperties === false)) {
|
|
4127
|
+
folded.additionalProperties = false;
|
|
4128
|
+
} else {
|
|
4129
|
+
const constraints = [];
|
|
4130
|
+
for (const object of objects) {
|
|
4131
|
+
const constraint = undeclaredConstraint(object);
|
|
4132
|
+
if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint)))
|
|
4133
|
+
constraints.push(constraint);
|
|
4134
|
+
}
|
|
4135
|
+
if (constraints.length === 1)
|
|
4136
|
+
folded.additionalProperties = constraints[0];
|
|
4137
|
+
else if (constraints.length > 1)
|
|
4138
|
+
folded.additionalProperties = { allOf: constraints };
|
|
4139
|
+
}
|
|
4140
|
+
return folded;
|
|
4141
|
+
}
|
|
4142
|
+
function foldIntersection(json) {
|
|
4143
|
+
const allOf = json.allOf;
|
|
4144
|
+
if (!Array.isArray(allOf) || allOf.length < 2)
|
|
4145
|
+
return;
|
|
4146
|
+
for (const key of FOLDABLE_KEYS)
|
|
4147
|
+
if (key in json)
|
|
4148
|
+
return;
|
|
4149
|
+
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
4150
|
+
let folded = null;
|
|
4151
|
+
if (!unions.length) {
|
|
4152
|
+
folded = foldObjects(allOf);
|
|
4153
|
+
} else {
|
|
4154
|
+
const union = unions[0];
|
|
4155
|
+
const keyword = UNION_KEYS.find((k) => Array.isArray(union[k]));
|
|
4156
|
+
if (Object.keys(union).length !== 1)
|
|
4157
|
+
return;
|
|
4158
|
+
const rest = allOf.filter((m) => m !== union);
|
|
4159
|
+
const branches = union[keyword].map((branch) => foldObjects([...rest, branch]));
|
|
4160
|
+
if (branches.some((b) => !b))
|
|
4161
|
+
return;
|
|
4162
|
+
folded = { [keyword]: branches };
|
|
3370
4163
|
}
|
|
4164
|
+
if (!folded)
|
|
4165
|
+
return;
|
|
4166
|
+
delete json.allOf;
|
|
4167
|
+
assignProps(json, folded);
|
|
3371
4168
|
}
|
|
3372
4169
|
function finalize(ctx, schema) {
|
|
3373
4170
|
const root = ctx.seen.get(schema);
|
|
@@ -3389,9 +4186,9 @@ function finalize(ctx, schema) {
|
|
|
3389
4186
|
schema.allOf = schema.allOf ?? [];
|
|
3390
4187
|
schema.allOf.push(refSchema);
|
|
3391
4188
|
} else {
|
|
3392
|
-
|
|
4189
|
+
assignProps(schema, refSchema);
|
|
3393
4190
|
}
|
|
3394
|
-
|
|
4191
|
+
assignProps(schema, _cached);
|
|
3395
4192
|
const isParentRef = zodSchema._zod.parent === ref;
|
|
3396
4193
|
if (isParentRef) {
|
|
3397
4194
|
for (const key in schema) {
|
|
@@ -3435,8 +4232,36 @@ function finalize(ctx, schema) {
|
|
|
3435
4232
|
path: seen.path ?? []
|
|
3436
4233
|
});
|
|
3437
4234
|
};
|
|
3438
|
-
|
|
3439
|
-
|
|
4235
|
+
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
|
|
4236
|
+
for (const entry of [...ctx.seen.entries()].reverse()) {
|
|
4237
|
+
flattenRef(entry[0]);
|
|
4238
|
+
}
|
|
4239
|
+
if (ctx.target !== "openapi-3.0") {
|
|
4240
|
+
for (const entry of ctx.seen.entries()) {
|
|
4241
|
+
compactTypeUnion(entry[1].def ?? entry[1].schema);
|
|
4242
|
+
}
|
|
4243
|
+
}
|
|
4244
|
+
for (const rewrite of ctx.deferred)
|
|
4245
|
+
rewrite();
|
|
4246
|
+
if (ctx.intersections.length) {
|
|
4247
|
+
const carriers = new Map;
|
|
4248
|
+
for (const seen of ctx.seen.values()) {
|
|
4249
|
+
for (const json of [seen.schema, seen.def]) {
|
|
4250
|
+
const allOf = json?.allOf;
|
|
4251
|
+
if (!Array.isArray(allOf))
|
|
4252
|
+
continue;
|
|
4253
|
+
const existing = carriers.get(allOf);
|
|
4254
|
+
if (existing)
|
|
4255
|
+
existing.push(json);
|
|
4256
|
+
else
|
|
4257
|
+
carriers.set(allOf, [json]);
|
|
4258
|
+
}
|
|
4259
|
+
}
|
|
4260
|
+
for (const allOf of ctx.intersections) {
|
|
4261
|
+
for (const json of carriers.get(allOf) ?? [])
|
|
4262
|
+
foldIntersection(json);
|
|
4263
|
+
}
|
|
4264
|
+
}
|
|
3440
4265
|
}
|
|
3441
4266
|
const result = {};
|
|
3442
4267
|
if (ctx.target === "draft-2020-12") {
|
|
@@ -3452,19 +4277,23 @@ function finalize(ctx, schema) {
|
|
|
3452
4277
|
throw new Error("Schema is missing an `id` property");
|
|
3453
4278
|
result.$id = ctx.external.uri(id);
|
|
3454
4279
|
}
|
|
3455
|
-
|
|
4280
|
+
assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
|
|
3456
4281
|
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
3457
4282
|
if (rootMetaId !== undefined && result.id === rootMetaId)
|
|
3458
4283
|
delete result.id;
|
|
3459
4284
|
const defs = ctx.external?.defs ?? {};
|
|
3460
|
-
|
|
3461
|
-
const seen
|
|
3462
|
-
|
|
3463
|
-
if (seen.def
|
|
3464
|
-
|
|
3465
|
-
|
|
4285
|
+
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
|
|
4286
|
+
for (const entry of ctx.seen.entries()) {
|
|
4287
|
+
const seen = entry[1];
|
|
4288
|
+
if (seen.def && seen.defId) {
|
|
4289
|
+
if (seen.def.id === seen.defId)
|
|
4290
|
+
delete seen.def.id;
|
|
4291
|
+
assignProp(defs, seen.defId, seen.def);
|
|
4292
|
+
}
|
|
3466
4293
|
}
|
|
3467
4294
|
}
|
|
4295
|
+
if (ctx.external)
|
|
4296
|
+
ctx.sharedEmitDoneFor = ctx.external;
|
|
3468
4297
|
if (ctx.external) {} else {
|
|
3469
4298
|
if (Object.keys(defs).length > 0) {
|
|
3470
4299
|
if (ctx.target === "draft-2020-12") {
|
|
@@ -3506,7 +4335,7 @@ function isTransforming(_schema, _ctx) {
|
|
|
3506
4335
|
return isTransforming(def.valueType, ctx);
|
|
3507
4336
|
if (def.type === "lazy")
|
|
3508
4337
|
return isTransforming(def.getter(), ctx);
|
|
3509
|
-
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") {
|
|
4338
|
+
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault" || def.type === "catch") {
|
|
3510
4339
|
return isTransforming(def.innerType, ctx);
|
|
3511
4340
|
}
|
|
3512
4341
|
if (def.type === "intersection") {
|
|
@@ -3547,18 +4376,106 @@ function isTransforming(_schema, _ctx) {
|
|
|
3547
4376
|
}
|
|
3548
4377
|
var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
3549
4378
|
const ctx = initializeContext({ ...params, processors });
|
|
3550
|
-
|
|
4379
|
+
processSchema(schema, ctx);
|
|
3551
4380
|
extractDefs(ctx, schema);
|
|
3552
4381
|
return finalize(ctx, schema);
|
|
3553
4382
|
};
|
|
3554
4383
|
var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
3555
4384
|
const { libraryOptions, target } = params ?? {};
|
|
3556
4385
|
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
3557
|
-
|
|
4386
|
+
processSchema(schema, ctx);
|
|
3558
4387
|
extractDefs(ctx, schema);
|
|
3559
4388
|
return finalize(ctx, schema);
|
|
3560
4389
|
};
|
|
3561
|
-
// ../../node_modules/.bun/zod@4.
|
|
4390
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/core/json-schema-processors.js
|
|
4391
|
+
var narrowMin = (agg, key, value) => {
|
|
4392
|
+
if (agg[key] === undefined || value > agg[key])
|
|
4393
|
+
agg[key] = value;
|
|
4394
|
+
};
|
|
4395
|
+
var narrowMax = (agg, key, value) => {
|
|
4396
|
+
if (agg[key] === undefined || value < agg[key])
|
|
4397
|
+
agg[key] = value;
|
|
4398
|
+
};
|
|
4399
|
+
var narrowBoth = (agg, value) => {
|
|
4400
|
+
narrowMin(agg, "minimum", value);
|
|
4401
|
+
narrowMax(agg, "maximum", value);
|
|
4402
|
+
};
|
|
4403
|
+
var addDivisor = (agg, value) => {
|
|
4404
|
+
agg.multipleOf ?? (agg.multipleOf = []);
|
|
4405
|
+
if (!agg.multipleOf.includes(value))
|
|
4406
|
+
agg.multipleOf.push(value);
|
|
4407
|
+
};
|
|
4408
|
+
var addPattern = (agg, pattern) => {
|
|
4409
|
+
agg.patterns ?? (agg.patterns = new Set);
|
|
4410
|
+
agg.patterns.add(pattern);
|
|
4411
|
+
};
|
|
4412
|
+
var intersectMime = (agg, mime) => {
|
|
4413
|
+
agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
|
|
4414
|
+
};
|
|
4415
|
+
var setFormat = (agg, format) => {
|
|
4416
|
+
agg.format = format;
|
|
4417
|
+
if (format.includes("int"))
|
|
4418
|
+
agg.isInt = true;
|
|
4419
|
+
};
|
|
4420
|
+
var minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
|
|
4421
|
+
var maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
|
|
4422
|
+
var formatContributor = (ranges) => (agg, def) => {
|
|
4423
|
+
setFormat(agg, def.format);
|
|
4424
|
+
const [minimum, maximum] = ranges[def.format];
|
|
4425
|
+
narrowMin(agg, "minimum", minimum);
|
|
4426
|
+
narrowMax(agg, "maximum", maximum);
|
|
4427
|
+
};
|
|
4428
|
+
var contributors = {
|
|
4429
|
+
greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
|
|
4430
|
+
less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
|
|
4431
|
+
multiple_of: (agg, def) => addDivisor(agg, def.value),
|
|
4432
|
+
number_format: formatContributor(NUMBER_FORMAT_RANGES),
|
|
4433
|
+
bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
|
|
4434
|
+
min_length: minContributor,
|
|
4435
|
+
max_length: maxContributor,
|
|
4436
|
+
length_equals: (agg, def) => narrowBoth(agg, def.length),
|
|
4437
|
+
min_size: minContributor,
|
|
4438
|
+
max_size: maxContributor,
|
|
4439
|
+
size_equals: (agg, def) => narrowBoth(agg, def.size),
|
|
4440
|
+
string_format: (agg, def) => {
|
|
4441
|
+
setFormat(agg, def.format);
|
|
4442
|
+
if (def.pattern)
|
|
4443
|
+
addPattern(agg, def.pattern);
|
|
4444
|
+
if (def.format === "base64" || def.format === "base64url")
|
|
4445
|
+
agg.contentEncoding = def.format;
|
|
4446
|
+
if (def.local || def.precision === -1)
|
|
4447
|
+
agg.laxFormat = true;
|
|
4448
|
+
},
|
|
4449
|
+
mime_type: (agg, def) => intersectMime(agg, def.mime)
|
|
4450
|
+
};
|
|
4451
|
+
function aggregateChecks(schema) {
|
|
4452
|
+
const agg = {};
|
|
4453
|
+
const def = schema._zod.def;
|
|
4454
|
+
const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
4455
|
+
for (const ch of list)
|
|
4456
|
+
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
4457
|
+
const bag = schema._zod.bag;
|
|
4458
|
+
if (bag.minimum !== undefined)
|
|
4459
|
+
narrowMin(agg, "minimum", bag.minimum);
|
|
4460
|
+
if (bag.exclusiveMinimum !== undefined)
|
|
4461
|
+
narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
|
|
4462
|
+
if (bag.maximum !== undefined)
|
|
4463
|
+
narrowMax(agg, "maximum", bag.maximum);
|
|
4464
|
+
if (bag.exclusiveMaximum !== undefined)
|
|
4465
|
+
narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
|
|
4466
|
+
if (bag.multipleOf !== undefined)
|
|
4467
|
+
addDivisor(agg, bag.multipleOf);
|
|
4468
|
+
if (bag.format !== undefined) {
|
|
4469
|
+
agg.format ?? (agg.format = bag.format);
|
|
4470
|
+
if (bag.format.includes("int"))
|
|
4471
|
+
agg.isInt = true;
|
|
4472
|
+
}
|
|
4473
|
+
if (bag.mime)
|
|
4474
|
+
intersectMime(agg, bag.mime);
|
|
4475
|
+
for (const pattern of bag.patterns ?? [])
|
|
4476
|
+
addPattern(agg, pattern);
|
|
4477
|
+
return agg;
|
|
4478
|
+
}
|
|
3562
4479
|
var formatMap = {
|
|
3563
4480
|
guid: "uuid",
|
|
3564
4481
|
url: "uri",
|
|
@@ -3566,10 +4483,15 @@ var formatMap = {
|
|
|
3566
4483
|
json_string: "json-string",
|
|
3567
4484
|
regex: ""
|
|
3568
4485
|
};
|
|
4486
|
+
var exactPatterns = new Map([
|
|
4487
|
+
[base64Charset, base64],
|
|
4488
|
+
[base64urlCharset, base64url]
|
|
4489
|
+
]);
|
|
4490
|
+
var exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
3569
4491
|
var stringProcessor = (schema, ctx, _json, _params) => {
|
|
3570
4492
|
const json = _json;
|
|
3571
4493
|
json.type = "string";
|
|
3572
|
-
const { minimum, maximum, format, patterns, contentEncoding } = schema
|
|
4494
|
+
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
3573
4495
|
if (typeof minimum === "number")
|
|
3574
4496
|
json.minLength = minimum;
|
|
3575
4497
|
if (typeof maximum === "number")
|
|
@@ -3578,19 +4500,19 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
3578
4500
|
json.format = formatMap[format] ?? format;
|
|
3579
4501
|
if (json.format === "")
|
|
3580
4502
|
delete json.format;
|
|
3581
|
-
if (format === "time") {
|
|
4503
|
+
if (format === "time" || laxFormat) {
|
|
3582
4504
|
delete json.format;
|
|
3583
4505
|
}
|
|
3584
4506
|
}
|
|
3585
4507
|
if (contentEncoding)
|
|
3586
4508
|
json.contentEncoding = contentEncoding;
|
|
3587
4509
|
if (patterns && patterns.size > 0) {
|
|
3588
|
-
const
|
|
3589
|
-
if (
|
|
3590
|
-
json.pattern =
|
|
3591
|
-
else if (
|
|
4510
|
+
const patternList = [...patterns].map(exactPattern);
|
|
4511
|
+
if (patternList.length === 1)
|
|
4512
|
+
json.pattern = patternList[0].source;
|
|
4513
|
+
else if (patternList.length > 1) {
|
|
3592
4514
|
json.allOf = [
|
|
3593
|
-
...
|
|
4515
|
+
...patternList.map((regex) => ({
|
|
3594
4516
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
3595
4517
|
pattern: regex.source
|
|
3596
4518
|
}))
|
|
@@ -3598,13 +4520,10 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
3598
4520
|
}
|
|
3599
4521
|
}
|
|
3600
4522
|
};
|
|
3601
|
-
var numberProcessor = (schema, ctx, _json,
|
|
4523
|
+
var numberProcessor = (schema, ctx, _json, params) => {
|
|
3602
4524
|
const json = _json;
|
|
3603
|
-
const { minimum, maximum,
|
|
3604
|
-
|
|
3605
|
-
json.type = "integer";
|
|
3606
|
-
else
|
|
3607
|
-
json.type = "number";
|
|
4525
|
+
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
4526
|
+
json.type = isInt ? "integer" : "number";
|
|
3608
4527
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
3609
4528
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
3610
4529
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
@@ -3628,8 +4547,20 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
3628
4547
|
} else if (typeof maximum === "number") {
|
|
3629
4548
|
json.maximum = maximum;
|
|
3630
4549
|
}
|
|
3631
|
-
if (
|
|
3632
|
-
|
|
4550
|
+
if (multipleOf) {
|
|
4551
|
+
const divisors = new Set;
|
|
4552
|
+
for (const divisor of multipleOf) {
|
|
4553
|
+
if (Number.isFinite(divisor) && divisor !== 0)
|
|
4554
|
+
divisors.add(Math.abs(divisor));
|
|
4555
|
+
else
|
|
4556
|
+
handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
4557
|
+
}
|
|
4558
|
+
const [first, ...rest] = divisors;
|
|
4559
|
+
if (first !== undefined)
|
|
4560
|
+
json.multipleOf = first;
|
|
4561
|
+
if (rest.length)
|
|
4562
|
+
json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
|
|
4563
|
+
}
|
|
3633
4564
|
};
|
|
3634
4565
|
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
3635
4566
|
json.type = "boolean";
|
|
@@ -3641,26 +4572,31 @@ var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
|
3641
4572
|
var enumProcessor = (schema, _ctx, json, _params) => {
|
|
3642
4573
|
const def = schema._zod.def;
|
|
3643
4574
|
const values = getEnumValues(def.entries);
|
|
4575
|
+
if (values.length === 0) {
|
|
4576
|
+
json.not = {};
|
|
4577
|
+
return;
|
|
4578
|
+
}
|
|
3644
4579
|
if (values.every((v) => typeof v === "number"))
|
|
3645
4580
|
json.type = "number";
|
|
3646
4581
|
if (values.every((v) => typeof v === "string"))
|
|
3647
4582
|
json.type = "string";
|
|
3648
4583
|
json.enum = values;
|
|
3649
4584
|
};
|
|
3650
|
-
var literalProcessor = (schema, ctx, json,
|
|
4585
|
+
var literalProcessor = (schema, ctx, json, params) => {
|
|
3651
4586
|
const def = schema._zod.def;
|
|
4587
|
+
if (def.values.length === 0) {
|
|
4588
|
+
json.not = {};
|
|
4589
|
+
return;
|
|
4590
|
+
}
|
|
3652
4591
|
const vals = [];
|
|
3653
4592
|
for (const val of def.values) {
|
|
3654
4593
|
if (val === undefined) {
|
|
3655
|
-
if (ctx
|
|
3656
|
-
|
|
3657
|
-
}
|
|
4594
|
+
if (handleUnrepresentable(schema, ctx, json, params, "Literal `undefined` cannot be represented in JSON Schema"))
|
|
4595
|
+
return;
|
|
3658
4596
|
} else if (typeof val === "bigint") {
|
|
3659
|
-
if (ctx
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
vals.push(Number(val));
|
|
3663
|
-
}
|
|
4597
|
+
if (handleUnrepresentable(schema, ctx, json, params, "BigInt literals cannot be represented in JSON Schema"))
|
|
4598
|
+
return;
|
|
4599
|
+
vals.push(Number(val));
|
|
3664
4600
|
} else {
|
|
3665
4601
|
vals.push(val);
|
|
3666
4602
|
}
|
|
@@ -3685,53 +4621,61 @@ var literalProcessor = (schema, ctx, json, _params) => {
|
|
|
3685
4621
|
json.enum = vals;
|
|
3686
4622
|
}
|
|
3687
4623
|
};
|
|
3688
|
-
var customProcessor = (
|
|
3689
|
-
|
|
3690
|
-
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
3691
|
-
}
|
|
4624
|
+
var customProcessor = (schema, ctx, json, params) => {
|
|
4625
|
+
handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
|
|
3692
4626
|
};
|
|
3693
|
-
var transformProcessor = (
|
|
3694
|
-
|
|
3695
|
-
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
3696
|
-
}
|
|
4627
|
+
var transformProcessor = (schema, ctx, json, params) => {
|
|
4628
|
+
handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
|
|
3697
4629
|
};
|
|
3698
4630
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
3699
4631
|
const json = _json;
|
|
3700
4632
|
const def = schema._zod.def;
|
|
3701
|
-
const { minimum, maximum } = schema
|
|
4633
|
+
const { minimum, maximum } = aggregateChecks(schema);
|
|
3702
4634
|
if (typeof minimum === "number")
|
|
3703
4635
|
json.minItems = minimum;
|
|
3704
4636
|
if (typeof maximum === "number")
|
|
3705
4637
|
json.maxItems = maximum;
|
|
3706
4638
|
json.type = "array";
|
|
3707
|
-
json.items =
|
|
4639
|
+
json.items = processSchema(def.element, ctx, {
|
|
3708
4640
|
...params,
|
|
3709
4641
|
path: [...params.path, "items"]
|
|
3710
4642
|
});
|
|
3711
4643
|
};
|
|
4644
|
+
function inputOptin(schema) {
|
|
4645
|
+
const def = schema._zod.def;
|
|
4646
|
+
if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) {
|
|
4647
|
+
return inputOptin(def.out);
|
|
4648
|
+
}
|
|
4649
|
+
if (def.type === "catch") {
|
|
4650
|
+
return inputOptin(def.innerType);
|
|
4651
|
+
}
|
|
4652
|
+
return schema._zod.optin;
|
|
4653
|
+
}
|
|
3712
4654
|
var objectProcessor = (schema, ctx, _json, params) => {
|
|
3713
4655
|
const json = _json;
|
|
3714
4656
|
const def = schema._zod.def;
|
|
4657
|
+
const shape = def.shape;
|
|
4658
|
+
const symbolKeys = Object.getOwnPropertySymbols(shape);
|
|
4659
|
+
if (symbolKeys.length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) {
|
|
4660
|
+
return;
|
|
4661
|
+
}
|
|
3715
4662
|
json.type = "object";
|
|
3716
4663
|
json.properties = {};
|
|
3717
|
-
const shape = def.shape;
|
|
3718
4664
|
for (const key in shape) {
|
|
3719
|
-
json.properties
|
|
4665
|
+
assignProp(json.properties, key, processSchema(shape[key], ctx, {
|
|
3720
4666
|
...params,
|
|
3721
4667
|
path: [...params.path, "properties", key]
|
|
3722
|
-
});
|
|
4668
|
+
}));
|
|
3723
4669
|
}
|
|
3724
|
-
const
|
|
3725
|
-
const
|
|
3726
|
-
const
|
|
3727
|
-
if (ctx.io === "input") {
|
|
3728
|
-
|
|
3729
|
-
} else {
|
|
3730
|
-
return v.optout === undefined;
|
|
4670
|
+
const requiredKeys = [];
|
|
4671
|
+
for (const key of Object.keys(shape)) {
|
|
4672
|
+
const field = def.shape[key];
|
|
4673
|
+
if (ctx.io === "input" ? inputOptin(field) === undefined : field._zod.optout === undefined) {
|
|
4674
|
+
requiredKeys.push(key);
|
|
3731
4675
|
}
|
|
3732
|
-
}
|
|
3733
|
-
if (requiredKeys.
|
|
3734
|
-
json.required =
|
|
4676
|
+
}
|
|
4677
|
+
if (requiredKeys.length > 0) {
|
|
4678
|
+
json.required = requiredKeys;
|
|
3735
4679
|
}
|
|
3736
4680
|
if (def.catchall?._zod.def.type === "never") {
|
|
3737
4681
|
json.additionalProperties = false;
|
|
@@ -3739,7 +4683,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
3739
4683
|
if (ctx.io === "output")
|
|
3740
4684
|
json.additionalProperties = false;
|
|
3741
4685
|
} else if (def.catchall) {
|
|
3742
|
-
json.additionalProperties =
|
|
4686
|
+
json.additionalProperties = processSchema(def.catchall, ctx, {
|
|
3743
4687
|
...params,
|
|
3744
4688
|
path: [...params.path, "additionalProperties"]
|
|
3745
4689
|
});
|
|
@@ -3748,7 +4692,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
3748
4692
|
var unionProcessor = (schema, ctx, json, params) => {
|
|
3749
4693
|
const def = schema._zod.def;
|
|
3750
4694
|
const isExclusive = def.inclusive === false;
|
|
3751
|
-
const options = def.options.map((x, i) =>
|
|
4695
|
+
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
3752
4696
|
...params,
|
|
3753
4697
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
3754
4698
|
}));
|
|
@@ -3760,11 +4704,11 @@ var unionProcessor = (schema, ctx, json, params) => {
|
|
|
3760
4704
|
};
|
|
3761
4705
|
var intersectionProcessor = (schema, ctx, json, params) => {
|
|
3762
4706
|
const def = schema._zod.def;
|
|
3763
|
-
const a =
|
|
4707
|
+
const a = processSchema(def.left, ctx, {
|
|
3764
4708
|
...params,
|
|
3765
4709
|
path: [...params.path, "allOf", 0]
|
|
3766
4710
|
});
|
|
3767
|
-
const b =
|
|
4711
|
+
const b = processSchema(def.right, ctx, {
|
|
3768
4712
|
...params,
|
|
3769
4713
|
path: [...params.path, "allOf", 1]
|
|
3770
4714
|
});
|
|
@@ -3774,46 +4718,117 @@ var intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
3774
4718
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
3775
4719
|
];
|
|
3776
4720
|
json.allOf = allOf;
|
|
4721
|
+
ctx.intersections.push(allOf);
|
|
3777
4722
|
};
|
|
4723
|
+
function stringifyKeyNames(bySchema, json, visited) {
|
|
4724
|
+
if (json.$ref) {
|
|
4725
|
+
if (visited.has(json))
|
|
4726
|
+
return json;
|
|
4727
|
+
visited.add(json);
|
|
4728
|
+
const def = bySchema.get(json)?.def;
|
|
4729
|
+
if (!def)
|
|
4730
|
+
return json;
|
|
4731
|
+
const inlined = stringifyKeyNames(bySchema, def, visited);
|
|
4732
|
+
return inlined === def ? json : inlined;
|
|
4733
|
+
}
|
|
4734
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
4735
|
+
const branches = json[keyword];
|
|
4736
|
+
if (!Array.isArray(branches))
|
|
4737
|
+
continue;
|
|
4738
|
+
const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
|
|
4739
|
+
if (mapped.some((branch, i) => branch !== branches[i]))
|
|
4740
|
+
json = { ...json, [keyword]: mapped };
|
|
4741
|
+
}
|
|
4742
|
+
const types = Array.isArray(json.type) ? json.type : [json.type];
|
|
4743
|
+
const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
|
|
4744
|
+
const values = json.enum ?? (json.const !== undefined ? [json.const] : undefined);
|
|
4745
|
+
if (!numericType && !values?.some((v) => typeof v === "number"))
|
|
4746
|
+
return json;
|
|
4747
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json;
|
|
4748
|
+
if (rest.enum)
|
|
4749
|
+
rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
|
|
4750
|
+
else if (typeof rest.const === "number")
|
|
4751
|
+
rest.const = String(rest.const);
|
|
4752
|
+
if (!numericType)
|
|
4753
|
+
return rest;
|
|
4754
|
+
rest.type = "string";
|
|
4755
|
+
if (!values)
|
|
4756
|
+
rest.pattern = (types.includes("number") ? number : integer).source;
|
|
4757
|
+
return rest;
|
|
4758
|
+
}
|
|
4759
|
+
var pendingRecords = new WeakMap;
|
|
4760
|
+
function rewriteKeyNames(ctx) {
|
|
4761
|
+
const bySchema = new Map;
|
|
4762
|
+
for (const entry of ctx.seen.values()) {
|
|
4763
|
+
if (entry.def && !bySchema.has(entry.schema))
|
|
4764
|
+
bySchema.set(entry.schema, entry);
|
|
4765
|
+
}
|
|
4766
|
+
const rewrites = new Map;
|
|
4767
|
+
for (const record of pendingRecords.get(ctx) ?? []) {
|
|
4768
|
+
const seen = ctx.seen.get(record);
|
|
4769
|
+
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
4770
|
+
if (!names || names === true || rewrites.has(names))
|
|
4771
|
+
continue;
|
|
4772
|
+
const rewritten = stringifyKeyNames(bySchema, names, new Set);
|
|
4773
|
+
if (rewritten !== names)
|
|
4774
|
+
rewrites.set(names, rewritten);
|
|
4775
|
+
}
|
|
4776
|
+
if (!rewrites.size)
|
|
4777
|
+
return;
|
|
4778
|
+
for (const entry of ctx.seen.values()) {
|
|
4779
|
+
for (const carrier of [entry.schema, entry.def]) {
|
|
4780
|
+
const rewritten = carrier && rewrites.get(carrier.propertyNames);
|
|
4781
|
+
if (rewritten)
|
|
4782
|
+
carrier.propertyNames = rewritten;
|
|
4783
|
+
}
|
|
4784
|
+
}
|
|
4785
|
+
}
|
|
3778
4786
|
var recordProcessor = (schema, ctx, _json, params) => {
|
|
3779
4787
|
const json = _json;
|
|
3780
4788
|
const def = schema._zod.def;
|
|
3781
4789
|
json.type = "object";
|
|
3782
4790
|
const keyType = def.keyType;
|
|
3783
|
-
const
|
|
3784
|
-
const patterns = keyBag?.patterns;
|
|
4791
|
+
const patterns = aggregateChecks(keyType).patterns;
|
|
3785
4792
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
3786
|
-
const valueSchema =
|
|
4793
|
+
const valueSchema = processSchema(def.valueType, ctx, {
|
|
3787
4794
|
...params,
|
|
3788
4795
|
path: [...params.path, "patternProperties", "*"]
|
|
3789
4796
|
});
|
|
3790
4797
|
json.patternProperties = {};
|
|
3791
4798
|
for (const pattern of patterns) {
|
|
3792
|
-
json.patternProperties
|
|
4799
|
+
assignProp(json.patternProperties, exactPattern(pattern).source, valueSchema);
|
|
3793
4800
|
}
|
|
3794
4801
|
} else {
|
|
3795
4802
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
3796
|
-
json.propertyNames =
|
|
4803
|
+
json.propertyNames = processSchema(def.keyType, ctx, {
|
|
3797
4804
|
...params,
|
|
3798
4805
|
path: [...params.path, "propertyNames"]
|
|
3799
4806
|
});
|
|
4807
|
+
let pending = pendingRecords.get(ctx);
|
|
4808
|
+
if (!pending) {
|
|
4809
|
+
pending = [];
|
|
4810
|
+
pendingRecords.set(ctx, pending);
|
|
4811
|
+
ctx.deferred.push(() => rewriteKeyNames(ctx));
|
|
4812
|
+
}
|
|
4813
|
+
pending.push(schema);
|
|
3800
4814
|
}
|
|
3801
|
-
json.additionalProperties =
|
|
4815
|
+
json.additionalProperties = processSchema(def.valueType, ctx, {
|
|
3802
4816
|
...params,
|
|
3803
4817
|
path: [...params.path, "additionalProperties"]
|
|
3804
4818
|
});
|
|
3805
4819
|
}
|
|
3806
4820
|
const keyValues = keyType._zod.values;
|
|
3807
|
-
|
|
4821
|
+
const omittableOnInput = ctx.io === "input" && inputOptin(def.valueType) !== undefined;
|
|
4822
|
+
if (keyValues && !def.partial && !omittableOnInput) {
|
|
3808
4823
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
3809
4824
|
if (validKeyValues.length > 0) {
|
|
3810
|
-
json.required = validKeyValues;
|
|
4825
|
+
json.required = validKeyValues.map(String);
|
|
3811
4826
|
}
|
|
3812
4827
|
}
|
|
3813
4828
|
};
|
|
3814
4829
|
var nullableProcessor = (schema, ctx, json, params) => {
|
|
3815
4830
|
const def = schema._zod.def;
|
|
3816
|
-
const inner =
|
|
4831
|
+
const inner = processSchema(def.innerType, ctx, params);
|
|
3817
4832
|
const seen = ctx.seen.get(schema);
|
|
3818
4833
|
if (ctx.target === "openapi-3.0") {
|
|
3819
4834
|
seen.ref = def.innerType;
|
|
@@ -3824,35 +4839,55 @@ var nullableProcessor = (schema, ctx, json, params) => {
|
|
|
3824
4839
|
};
|
|
3825
4840
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
3826
4841
|
const def = schema._zod.def;
|
|
3827
|
-
|
|
4842
|
+
processSchema(def.innerType, ctx, params);
|
|
3828
4843
|
const seen = ctx.seen.get(schema);
|
|
3829
4844
|
seen.ref = def.innerType;
|
|
3830
4845
|
};
|
|
4846
|
+
var UNREPRESENTABLE_DEFAULT = Symbol();
|
|
4847
|
+
function serializeDefaultValue(value, schema, ctx, json, params) {
|
|
4848
|
+
let unrepresentable = false;
|
|
4849
|
+
const serialized = JSON.stringify(value, (_, val) => {
|
|
4850
|
+
if (typeof val !== "bigint")
|
|
4851
|
+
return val;
|
|
4852
|
+
unrepresentable = true;
|
|
4853
|
+
return null;
|
|
4854
|
+
});
|
|
4855
|
+
if (!unrepresentable)
|
|
4856
|
+
return JSON.parse(serialized);
|
|
4857
|
+
handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
4858
|
+
return UNREPRESENTABLE_DEFAULT;
|
|
4859
|
+
}
|
|
3831
4860
|
var defaultProcessor = (schema, ctx, json, params) => {
|
|
3832
4861
|
const def = schema._zod.def;
|
|
3833
|
-
|
|
4862
|
+
processSchema(def.innerType, ctx, params);
|
|
3834
4863
|
const seen = ctx.seen.get(schema);
|
|
3835
4864
|
seen.ref = def.innerType;
|
|
3836
|
-
|
|
4865
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
4866
|
+
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
4867
|
+
json.default = value;
|
|
3837
4868
|
};
|
|
3838
4869
|
var prefaultProcessor = (schema, ctx, json, params) => {
|
|
3839
4870
|
const def = schema._zod.def;
|
|
3840
|
-
|
|
4871
|
+
processSchema(def.innerType, ctx, params);
|
|
3841
4872
|
const seen = ctx.seen.get(schema);
|
|
3842
4873
|
seen.ref = def.innerType;
|
|
3843
|
-
if (ctx.io
|
|
3844
|
-
|
|
4874
|
+
if (ctx.io !== "input")
|
|
4875
|
+
return;
|
|
4876
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
4877
|
+
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
4878
|
+
json._prefault = value;
|
|
3845
4879
|
};
|
|
3846
4880
|
var catchProcessor = (schema, ctx, json, params) => {
|
|
3847
4881
|
const def = schema._zod.def;
|
|
3848
|
-
|
|
4882
|
+
processSchema(def.innerType, ctx, params);
|
|
3849
4883
|
const seen = ctx.seen.get(schema);
|
|
3850
4884
|
seen.ref = def.innerType;
|
|
3851
4885
|
let catchValue;
|
|
3852
4886
|
try {
|
|
3853
4887
|
catchValue = def.catchValue(undefined);
|
|
3854
4888
|
} catch {
|
|
3855
|
-
|
|
4889
|
+
handleUnrepresentable(schema, ctx, json, params, "Dynamic catch values are not supported in JSON Schema");
|
|
4890
|
+
return;
|
|
3856
4891
|
}
|
|
3857
4892
|
json.default = catchValue;
|
|
3858
4893
|
};
|
|
@@ -3860,92 +4895,73 @@ var pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
3860
4895
|
const def = schema._zod.def;
|
|
3861
4896
|
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
3862
4897
|
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
3863
|
-
|
|
4898
|
+
processSchema(innerType, ctx, params);
|
|
3864
4899
|
const seen = ctx.seen.get(schema);
|
|
3865
4900
|
seen.ref = innerType;
|
|
3866
4901
|
};
|
|
3867
4902
|
var readonlyProcessor = (schema, ctx, json, params) => {
|
|
3868
4903
|
const def = schema._zod.def;
|
|
3869
|
-
|
|
4904
|
+
processSchema(def.innerType, ctx, params);
|
|
3870
4905
|
const seen = ctx.seen.get(schema);
|
|
3871
4906
|
seen.ref = def.innerType;
|
|
3872
4907
|
json.readOnly = true;
|
|
3873
4908
|
};
|
|
3874
4909
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
3875
4910
|
const def = schema._zod.def;
|
|
3876
|
-
|
|
4911
|
+
processSchema(def.innerType, ctx, params);
|
|
3877
4912
|
const seen = ctx.seen.get(schema);
|
|
3878
4913
|
seen.ref = def.innerType;
|
|
3879
4914
|
};
|
|
3880
|
-
// ../../node_modules/.bun/zod@4.
|
|
3881
|
-
var
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
}
|
|
3895
|
-
var ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
|
|
3896
|
-
$ZodISOTime.init(inst, def);
|
|
3897
|
-
ZodStringFormat.init(inst, def);
|
|
3898
|
-
});
|
|
3899
|
-
function time2(params) {
|
|
3900
|
-
return _isoTime(ZodISOTime, params);
|
|
3901
|
-
}
|
|
3902
|
-
var ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
|
|
3903
|
-
$ZodISODuration.init(inst, def);
|
|
3904
|
-
ZodStringFormat.init(inst, def);
|
|
3905
|
-
});
|
|
3906
|
-
function duration2(params) {
|
|
3907
|
-
return _isoDuration(ZodISODuration, params);
|
|
4915
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/errors.js
|
|
4916
|
+
var _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
4917
|
+
function _lazyMethod(proto, key, make) {
|
|
4918
|
+
Object.defineProperty(proto, key, {
|
|
4919
|
+
configurable: true,
|
|
4920
|
+
enumerable: false,
|
|
4921
|
+
get() {
|
|
4922
|
+
const value = make(this);
|
|
4923
|
+
Object.defineProperty(this, key, { value, configurable: true, writable: true });
|
|
4924
|
+
return value;
|
|
4925
|
+
},
|
|
4926
|
+
set(value) {
|
|
4927
|
+
Object.defineProperty(this, key, { value, configurable: true, writable: true });
|
|
4928
|
+
}
|
|
4929
|
+
});
|
|
3908
4930
|
}
|
|
3909
|
-
|
|
3910
|
-
// ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/errors.js
|
|
3911
4931
|
var initializer2 = (inst, issues) => {
|
|
3912
4932
|
$ZodError.init(inst, issues);
|
|
3913
4933
|
inst.name = "ZodError";
|
|
3914
|
-
Object.
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
isEmpty: {
|
|
3934
|
-
get() {
|
|
3935
|
-
return inst.issues.length === 0;
|
|
3936
|
-
}
|
|
4934
|
+
const proto = Object.getPrototypeOf(inst);
|
|
4935
|
+
if (_installedErrorProtos.has(proto))
|
|
4936
|
+
return;
|
|
4937
|
+
_installedErrorProtos.add(proto);
|
|
4938
|
+
_lazyMethod(proto, "format", (self) => (mapper) => formatError(self, mapper));
|
|
4939
|
+
_lazyMethod(proto, "flatten", (self) => (mapper) => flattenError(self, mapper));
|
|
4940
|
+
_lazyMethod(proto, "addIssue", (self) => (issue) => {
|
|
4941
|
+
self.issues.push(issue);
|
|
4942
|
+
self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
|
|
4943
|
+
});
|
|
4944
|
+
_lazyMethod(proto, "addIssues", (self) => (issues) => {
|
|
4945
|
+
self.issues.push(...issues);
|
|
4946
|
+
self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
|
|
4947
|
+
});
|
|
4948
|
+
Object.defineProperty(proto, "isEmpty", {
|
|
4949
|
+
configurable: true,
|
|
4950
|
+
enumerable: false,
|
|
4951
|
+
get() {
|
|
4952
|
+
return this.issues.length === 0;
|
|
3937
4953
|
}
|
|
3938
4954
|
});
|
|
3939
4955
|
};
|
|
3940
|
-
var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, {
|
|
4956
|
+
var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, undefined, {
|
|
3941
4957
|
Parent: Error
|
|
3942
4958
|
});
|
|
3943
4959
|
|
|
3944
|
-
// ../../node_modules/.bun/zod@4.
|
|
3945
|
-
var
|
|
3946
|
-
var
|
|
3947
|
-
var
|
|
3948
|
-
var
|
|
4960
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/parse.js
|
|
4961
|
+
var parse2 = /* @__PURE__ */ _parse(ZodRealError);
|
|
4962
|
+
var parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
4963
|
+
var safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
4964
|
+
var safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
3949
4965
|
var encode = /* @__PURE__ */ _encode(ZodRealError);
|
|
3950
4966
|
var decode = /* @__PURE__ */ _decode(ZodRealError);
|
|
3951
4967
|
var encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
@@ -3955,259 +4971,323 @@ var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
|
3955
4971
|
var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
3956
4972
|
var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
3957
4973
|
|
|
3958
|
-
// ../../node_modules/.bun/zod@4.
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
}
|
|
3967
|
-
if (installed.has(group))
|
|
3968
|
-
return;
|
|
3969
|
-
installed.add(group);
|
|
3970
|
-
for (const key in methods) {
|
|
3971
|
-
const fn = methods[key];
|
|
3972
|
-
Object.defineProperty(proto, key, {
|
|
3973
|
-
configurable: true,
|
|
3974
|
-
enumerable: false,
|
|
3975
|
-
get() {
|
|
3976
|
-
const bound = fn.bind(this);
|
|
3977
|
-
Object.defineProperty(this, key, {
|
|
3978
|
-
configurable: true,
|
|
3979
|
-
writable: true,
|
|
3980
|
-
enumerable: true,
|
|
3981
|
-
value: bound
|
|
3982
|
-
});
|
|
3983
|
-
return bound;
|
|
3984
|
-
},
|
|
3985
|
-
set(v) {
|
|
3986
|
-
Object.defineProperty(this, key, {
|
|
3987
|
-
configurable: true,
|
|
3988
|
-
writable: true,
|
|
3989
|
-
enumerable: true,
|
|
3990
|
-
value: v
|
|
3991
|
-
});
|
|
3992
|
-
}
|
|
3993
|
-
});
|
|
3994
|
-
}
|
|
4974
|
+
// ../../node_modules/.bun/zod@4.6.7/node_modules/zod/v4/classic/schemas.js
|
|
4975
|
+
function _ensureDefaultLocale() {
|
|
4976
|
+
if (!globalConfig.localeError)
|
|
4977
|
+
config(en_default());
|
|
4978
|
+
}
|
|
4979
|
+
function _ensureDefaultMemoizer() {
|
|
4980
|
+
if (!globalConfig.memoizer)
|
|
4981
|
+
config({ memoizer: memoizer() });
|
|
3995
4982
|
}
|
|
3996
4983
|
var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
4984
|
+
_ensureDefaultLocale();
|
|
3997
4985
|
$ZodType.init(inst, def);
|
|
3998
|
-
Object.assign(inst["~standard"], {
|
|
3999
|
-
jsonSchema: {
|
|
4000
|
-
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
4001
|
-
output: createStandardJSONSchemaMethod(inst, "output")
|
|
4002
|
-
}
|
|
4003
|
-
});
|
|
4004
|
-
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
4005
4986
|
inst.def = def;
|
|
4006
4987
|
inst.type = def.type;
|
|
4007
|
-
Object.defineProperty(inst, "_def", { value: def });
|
|
4008
|
-
inst.parse = (data, params) => parse3(inst, data, params, { callee: inst.parse });
|
|
4009
|
-
inst.safeParse = (data, params) => safeParse2(inst, data, params);
|
|
4010
|
-
inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
|
|
4011
|
-
inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
|
|
4012
|
-
inst.spa = inst.safeParseAsync;
|
|
4013
|
-
inst.encode = (data, params) => encode(inst, data, params);
|
|
4014
|
-
inst.decode = (data, params) => decode(inst, data, params);
|
|
4015
|
-
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
4016
|
-
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
4017
|
-
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
4018
|
-
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
4019
|
-
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
4020
|
-
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
4021
|
-
_installLazyMethods(inst, "ZodType", {
|
|
4022
|
-
check(...chks) {
|
|
4023
|
-
const def = this.def;
|
|
4024
|
-
return this.clone(mergeDefs(def, {
|
|
4025
|
-
checks: [
|
|
4026
|
-
...def.checks ?? [],
|
|
4027
|
-
...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
4028
|
-
]
|
|
4029
|
-
}), { parent: true });
|
|
4030
|
-
},
|
|
4031
|
-
with(...chks) {
|
|
4032
|
-
return this.check(...chks);
|
|
4033
|
-
},
|
|
4034
|
-
clone(def, params) {
|
|
4035
|
-
return clone(this, def, params);
|
|
4036
|
-
},
|
|
4037
|
-
brand() {
|
|
4038
|
-
return this;
|
|
4039
|
-
},
|
|
4040
|
-
register(reg, meta) {
|
|
4041
|
-
reg.add(this, meta);
|
|
4042
|
-
return this;
|
|
4043
|
-
},
|
|
4044
|
-
refine(check, params) {
|
|
4045
|
-
return this.check(refine(check, params));
|
|
4046
|
-
},
|
|
4047
|
-
superRefine(refinement, params) {
|
|
4048
|
-
return this.check(superRefine(refinement, params));
|
|
4049
|
-
},
|
|
4050
|
-
overwrite(fn) {
|
|
4051
|
-
return this.check(_overwrite(fn));
|
|
4052
|
-
},
|
|
4053
|
-
optional() {
|
|
4054
|
-
return optional(this);
|
|
4055
|
-
},
|
|
4056
|
-
exactOptional() {
|
|
4057
|
-
return exactOptional(this);
|
|
4058
|
-
},
|
|
4059
|
-
nullable() {
|
|
4060
|
-
return nullable(this);
|
|
4061
|
-
},
|
|
4062
|
-
nullish() {
|
|
4063
|
-
return optional(nullable(this));
|
|
4064
|
-
},
|
|
4065
|
-
nonoptional(params) {
|
|
4066
|
-
return nonoptional(this, params);
|
|
4067
|
-
},
|
|
4068
|
-
array() {
|
|
4069
|
-
return array(this);
|
|
4070
|
-
},
|
|
4071
|
-
or(arg) {
|
|
4072
|
-
return union([this, arg]);
|
|
4073
|
-
},
|
|
4074
|
-
and(arg) {
|
|
4075
|
-
return intersection(this, arg);
|
|
4076
|
-
},
|
|
4077
|
-
transform(tx) {
|
|
4078
|
-
return pipe(this, transform(tx));
|
|
4079
|
-
},
|
|
4080
|
-
default(d) {
|
|
4081
|
-
return _default(this, d);
|
|
4082
|
-
},
|
|
4083
|
-
prefault(d) {
|
|
4084
|
-
return prefault(this, d);
|
|
4085
|
-
},
|
|
4086
|
-
catch(params) {
|
|
4087
|
-
return _catch(this, params);
|
|
4088
|
-
},
|
|
4089
|
-
pipe(target) {
|
|
4090
|
-
return pipe(this, target);
|
|
4091
|
-
},
|
|
4092
|
-
readonly() {
|
|
4093
|
-
return readonly(this);
|
|
4094
|
-
},
|
|
4095
|
-
describe(description) {
|
|
4096
|
-
const cl = this.clone();
|
|
4097
|
-
globalRegistry.add(cl, { description });
|
|
4098
|
-
return cl;
|
|
4099
|
-
},
|
|
4100
|
-
meta(...args) {
|
|
4101
|
-
if (args.length === 0)
|
|
4102
|
-
return globalRegistry.get(this);
|
|
4103
|
-
const cl = this.clone();
|
|
4104
|
-
globalRegistry.add(cl, args[0]);
|
|
4105
|
-
return cl;
|
|
4106
|
-
},
|
|
4107
|
-
isOptional() {
|
|
4108
|
-
return this.safeParse(undefined).success;
|
|
4109
|
-
},
|
|
4110
|
-
isNullable() {
|
|
4111
|
-
return this.safeParse(null).success;
|
|
4112
|
-
},
|
|
4113
|
-
apply(fn) {
|
|
4114
|
-
return fn(this);
|
|
4115
|
-
}
|
|
4116
|
-
});
|
|
4117
|
-
Object.defineProperty(inst, "description", {
|
|
4118
|
-
get() {
|
|
4119
|
-
return globalRegistry.get(inst)?.description;
|
|
4120
|
-
},
|
|
4121
|
-
configurable: true
|
|
4122
|
-
});
|
|
4123
4988
|
return inst;
|
|
4989
|
+
}, {
|
|
4990
|
+
check(...chks) {
|
|
4991
|
+
const def = this.def;
|
|
4992
|
+
return this.clone(mergeDefs(def, {
|
|
4993
|
+
checks: [
|
|
4994
|
+
...def.checks ?? [],
|
|
4995
|
+
...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
4996
|
+
]
|
|
4997
|
+
}), { parent: true });
|
|
4998
|
+
},
|
|
4999
|
+
with(...chks) {
|
|
5000
|
+
return this.check(...chks);
|
|
5001
|
+
},
|
|
5002
|
+
clone(def, params) {
|
|
5003
|
+
return clone(this, def, params);
|
|
5004
|
+
},
|
|
5005
|
+
brand() {
|
|
5006
|
+
return this;
|
|
5007
|
+
},
|
|
5008
|
+
register(reg, meta) {
|
|
5009
|
+
reg.add(this, meta);
|
|
5010
|
+
return this;
|
|
5011
|
+
},
|
|
5012
|
+
refine(check, params) {
|
|
5013
|
+
return this.check(refine(check, params));
|
|
5014
|
+
},
|
|
5015
|
+
superRefine(refinement, params) {
|
|
5016
|
+
return this.check(superRefine(refinement, params));
|
|
5017
|
+
},
|
|
5018
|
+
overwrite(fn) {
|
|
5019
|
+
return this.check(_overwrite(fn));
|
|
5020
|
+
},
|
|
5021
|
+
optional() {
|
|
5022
|
+
return optional(this);
|
|
5023
|
+
},
|
|
5024
|
+
exactOptional() {
|
|
5025
|
+
return exactOptional(this);
|
|
5026
|
+
},
|
|
5027
|
+
nullable() {
|
|
5028
|
+
return nullable(this);
|
|
5029
|
+
},
|
|
5030
|
+
nullish() {
|
|
5031
|
+
return optional(nullable(this));
|
|
5032
|
+
},
|
|
5033
|
+
nonoptional(params) {
|
|
5034
|
+
return nonoptional(this, params);
|
|
5035
|
+
},
|
|
5036
|
+
array() {
|
|
5037
|
+
return array(this);
|
|
5038
|
+
},
|
|
5039
|
+
or(arg) {
|
|
5040
|
+
return union([this, arg]);
|
|
5041
|
+
},
|
|
5042
|
+
and(arg) {
|
|
5043
|
+
return intersection(this, arg);
|
|
5044
|
+
},
|
|
5045
|
+
transform(tx) {
|
|
5046
|
+
return pipe(this, transform(tx));
|
|
5047
|
+
},
|
|
5048
|
+
default(d) {
|
|
5049
|
+
return _default(this, d);
|
|
5050
|
+
},
|
|
5051
|
+
prefault(d) {
|
|
5052
|
+
return prefault(this, d);
|
|
5053
|
+
},
|
|
5054
|
+
catch(params) {
|
|
5055
|
+
return _catch(this, params);
|
|
5056
|
+
},
|
|
5057
|
+
pipe(target) {
|
|
5058
|
+
return pipe(this, target);
|
|
5059
|
+
},
|
|
5060
|
+
readonly() {
|
|
5061
|
+
return readonly(this);
|
|
5062
|
+
},
|
|
5063
|
+
describe(description) {
|
|
5064
|
+
const cl = this.clone();
|
|
5065
|
+
globalRegistry.add(cl, { description });
|
|
5066
|
+
return cl;
|
|
5067
|
+
},
|
|
5068
|
+
meta(...args) {
|
|
5069
|
+
if (args.length === 0)
|
|
5070
|
+
return globalRegistry.get(this);
|
|
5071
|
+
const cl = this.clone();
|
|
5072
|
+
globalRegistry.add(cl, args[0]);
|
|
5073
|
+
return cl;
|
|
5074
|
+
},
|
|
5075
|
+
isOptional() {
|
|
5076
|
+
return this.safeParse(undefined).success;
|
|
5077
|
+
},
|
|
5078
|
+
isNullable() {
|
|
5079
|
+
return this.safeParse(null).success;
|
|
5080
|
+
},
|
|
5081
|
+
apply(fn, ...args) {
|
|
5082
|
+
return args.length === 0 ? fn(this) : fn(this, ...args);
|
|
5083
|
+
},
|
|
5084
|
+
get "~standard"() {
|
|
5085
|
+
return hide(this, "~standard", {
|
|
5086
|
+
...standardProps(this),
|
|
5087
|
+
jsonSchema: {
|
|
5088
|
+
input: createStandardJSONSchemaMethod(this, "input"),
|
|
5089
|
+
output: createStandardJSONSchemaMethod(this, "output")
|
|
5090
|
+
}
|
|
5091
|
+
});
|
|
5092
|
+
},
|
|
5093
|
+
set "~standard"(value) {
|
|
5094
|
+
own(this, "~standard", value);
|
|
5095
|
+
},
|
|
5096
|
+
parse: function _parse(data, params) {
|
|
5097
|
+
return parse2(this, data, params, { callee: _parse });
|
|
5098
|
+
},
|
|
5099
|
+
parseAsync: async function _parseAsync(data, params) {
|
|
5100
|
+
return await parseAsync(this, data, params, { callee: _parseAsync });
|
|
5101
|
+
},
|
|
5102
|
+
safeParse(data, params) {
|
|
5103
|
+
return safeParse(this, data, params);
|
|
5104
|
+
},
|
|
5105
|
+
async safeParseAsync(data, params) {
|
|
5106
|
+
return safeParseAsync(this, data, params);
|
|
5107
|
+
},
|
|
5108
|
+
get spa() {
|
|
5109
|
+
return this?.safeParseAsync;
|
|
5110
|
+
},
|
|
5111
|
+
set spa(value) {
|
|
5112
|
+
own(this, "spa", value);
|
|
5113
|
+
},
|
|
5114
|
+
validate(data, params) {
|
|
5115
|
+
return validate(this, data, params);
|
|
5116
|
+
},
|
|
5117
|
+
validateAsync(data, params) {
|
|
5118
|
+
return validateAsync(this, data, params);
|
|
5119
|
+
},
|
|
5120
|
+
encode: function _encode(data, params) {
|
|
5121
|
+
return encode(this, data, params, { callee: _encode });
|
|
5122
|
+
},
|
|
5123
|
+
decode: function _decode(data, params) {
|
|
5124
|
+
return decode(this, data, params, { callee: _decode });
|
|
5125
|
+
},
|
|
5126
|
+
encodeAsync: async function _encodeAsync(data, params) {
|
|
5127
|
+
return await encodeAsync(this, data, params, { callee: _encodeAsync });
|
|
5128
|
+
},
|
|
5129
|
+
decodeAsync: async function _decodeAsync(data, params) {
|
|
5130
|
+
return await decodeAsync(this, data, params, { callee: _decodeAsync });
|
|
5131
|
+
},
|
|
5132
|
+
safeEncode(data, params) {
|
|
5133
|
+
return safeEncode(this, data, params);
|
|
5134
|
+
},
|
|
5135
|
+
safeDecode(data, params) {
|
|
5136
|
+
return safeDecode(this, data, params);
|
|
5137
|
+
},
|
|
5138
|
+
async safeEncodeAsync(data, params) {
|
|
5139
|
+
return safeEncodeAsync(this, data, params);
|
|
5140
|
+
},
|
|
5141
|
+
async safeDecodeAsync(data, params) {
|
|
5142
|
+
return safeDecodeAsync(this, data, params);
|
|
5143
|
+
},
|
|
5144
|
+
toJSONSchema(params) {
|
|
5145
|
+
return createToJSONSchemaMethod(this, {})(params);
|
|
5146
|
+
},
|
|
5147
|
+
get description() {
|
|
5148
|
+
return globalRegistry.get(this)?.description;
|
|
5149
|
+
},
|
|
5150
|
+
get _def() {
|
|
5151
|
+
return this._zod.def;
|
|
5152
|
+
}
|
|
4124
5153
|
});
|
|
4125
5154
|
var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
4126
5155
|
$ZodString.init(inst, def);
|
|
4127
5156
|
ZodType.init(inst, def);
|
|
4128
5157
|
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
});
|
|
5158
|
+
}, /* @__PURE__ */ derived({
|
|
5159
|
+
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
5160
|
+
minLength: (inst) => aggregateChecks(inst).minimum ?? null,
|
|
5161
|
+
maxLength: (inst) => aggregateChecks(inst).maximum ?? null
|
|
5162
|
+
}, {
|
|
5163
|
+
regex(...args) {
|
|
5164
|
+
return this.check(_regex(...args));
|
|
5165
|
+
},
|
|
5166
|
+
includes(...args) {
|
|
5167
|
+
return this.check(_includes(...args));
|
|
5168
|
+
},
|
|
5169
|
+
startsWith(...args) {
|
|
5170
|
+
return this.check(_startsWith(...args));
|
|
5171
|
+
},
|
|
5172
|
+
endsWith(...args) {
|
|
5173
|
+
return this.check(_endsWith(...args));
|
|
5174
|
+
},
|
|
5175
|
+
min(...args) {
|
|
5176
|
+
return this.check(_minLength(...args));
|
|
5177
|
+
},
|
|
5178
|
+
max(...args) {
|
|
5179
|
+
return this.check(_maxLength(...args));
|
|
5180
|
+
},
|
|
5181
|
+
length(...args) {
|
|
5182
|
+
return this.check(_length(...args));
|
|
5183
|
+
},
|
|
5184
|
+
nonempty(...args) {
|
|
5185
|
+
return this.check(_minLength(1, ...args));
|
|
5186
|
+
},
|
|
5187
|
+
lowercase(params) {
|
|
5188
|
+
return this.check(_lowercase(params));
|
|
5189
|
+
},
|
|
5190
|
+
uppercase(params) {
|
|
5191
|
+
return this.check(_uppercase(params));
|
|
5192
|
+
},
|
|
5193
|
+
trim() {
|
|
5194
|
+
return this.check(_trim());
|
|
5195
|
+
},
|
|
5196
|
+
normalize(...args) {
|
|
5197
|
+
return this.check(_normalize(...args));
|
|
5198
|
+
},
|
|
5199
|
+
toLowerCase() {
|
|
5200
|
+
return this.check(_toLowerCase());
|
|
5201
|
+
},
|
|
5202
|
+
toUpperCase() {
|
|
5203
|
+
return this.check(_toUpperCase());
|
|
5204
|
+
},
|
|
5205
|
+
slugify() {
|
|
5206
|
+
return this.check(_slugify());
|
|
5207
|
+
}
|
|
5208
|
+
}));
|
|
4181
5209
|
var ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
4182
5210
|
$ZodString.init(inst, def);
|
|
4183
5211
|
_ZodString.init(inst, def);
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
5212
|
+
}, {
|
|
5213
|
+
email(params) {
|
|
5214
|
+
return this.check(_email(ZodEmail, params));
|
|
5215
|
+
},
|
|
5216
|
+
url(params) {
|
|
5217
|
+
return this.check(_url(ZodURL, params));
|
|
5218
|
+
},
|
|
5219
|
+
jwt(params) {
|
|
5220
|
+
return this.check(_jwt(ZodJWT, params));
|
|
5221
|
+
},
|
|
5222
|
+
emoji(params) {
|
|
5223
|
+
return this.check(_emoji2(ZodEmoji, params));
|
|
5224
|
+
},
|
|
5225
|
+
guid(params) {
|
|
5226
|
+
return this.check(_guid(ZodGUID, params));
|
|
5227
|
+
},
|
|
5228
|
+
uuid(params) {
|
|
5229
|
+
return this.check(_uuid(ZodUUID, params));
|
|
5230
|
+
},
|
|
5231
|
+
uuidv4(params) {
|
|
5232
|
+
return this.check(_uuidv4(ZodUUID, params));
|
|
5233
|
+
},
|
|
5234
|
+
uuidv6(params) {
|
|
5235
|
+
return this.check(_uuidv6(ZodUUID, params));
|
|
5236
|
+
},
|
|
5237
|
+
uuidv7(params) {
|
|
5238
|
+
return this.check(_uuidv7(ZodUUID, params));
|
|
5239
|
+
},
|
|
5240
|
+
nanoid(params) {
|
|
5241
|
+
return this.check(_nanoid(ZodNanoID, params));
|
|
5242
|
+
},
|
|
5243
|
+
cuid(params) {
|
|
5244
|
+
return this.check(_cuid(ZodCUID, params));
|
|
5245
|
+
},
|
|
5246
|
+
cuid2(params) {
|
|
5247
|
+
return this.check(_cuid2(ZodCUID2, params));
|
|
5248
|
+
},
|
|
5249
|
+
ulid(params) {
|
|
5250
|
+
return this.check(_ulid(ZodULID, params));
|
|
5251
|
+
},
|
|
5252
|
+
base64(params) {
|
|
5253
|
+
return this.check(_base64(ZodBase64, params));
|
|
5254
|
+
},
|
|
5255
|
+
base64url(params) {
|
|
5256
|
+
return this.check(_base64url(ZodBase64URL, params));
|
|
5257
|
+
},
|
|
5258
|
+
xid(params) {
|
|
5259
|
+
return this.check(_xid(ZodXID, params));
|
|
5260
|
+
},
|
|
5261
|
+
ksuid(params) {
|
|
5262
|
+
return this.check(_ksuid(ZodKSUID, params));
|
|
5263
|
+
},
|
|
5264
|
+
ipv4(params) {
|
|
5265
|
+
return this.check(_ipv4(ZodIPv4, params));
|
|
5266
|
+
},
|
|
5267
|
+
ipv6(params) {
|
|
5268
|
+
return this.check(_ipv6(ZodIPv6, params));
|
|
5269
|
+
},
|
|
5270
|
+
cidrv4(params) {
|
|
5271
|
+
return this.check(_cidrv4(ZodCIDRv4, params));
|
|
5272
|
+
},
|
|
5273
|
+
cidrv6(params) {
|
|
5274
|
+
return this.check(_cidrv6(ZodCIDRv6, params));
|
|
5275
|
+
},
|
|
5276
|
+
e164(params) {
|
|
5277
|
+
return this.check(_e164(ZodE164, params));
|
|
5278
|
+
},
|
|
5279
|
+
datetime(params) {
|
|
5280
|
+
return this.check(_isoDateTime(ZodISODateTime, params));
|
|
5281
|
+
},
|
|
5282
|
+
date(params) {
|
|
5283
|
+
return this.check(_isoDate(ZodISODate, params));
|
|
5284
|
+
},
|
|
5285
|
+
time(params) {
|
|
5286
|
+
return this.check(_isoTime(ZodISOTime, params));
|
|
5287
|
+
},
|
|
5288
|
+
duration(params) {
|
|
5289
|
+
return this.check(_isoDuration(ZodISODuration, params));
|
|
5290
|
+
}
|
|
4211
5291
|
});
|
|
4212
5292
|
function string2(params) {
|
|
4213
5293
|
return _string(ZodString, params);
|
|
@@ -4216,6 +5296,22 @@ var ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def
|
|
|
4216
5296
|
$ZodStringFormat.init(inst, def);
|
|
4217
5297
|
_ZodString.init(inst, def);
|
|
4218
5298
|
});
|
|
5299
|
+
var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
5300
|
+
$ZodISODateTime.init(inst, def);
|
|
5301
|
+
ZodStringFormat.init(inst, def);
|
|
5302
|
+
});
|
|
5303
|
+
var ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
|
|
5304
|
+
$ZodISODate.init(inst, def);
|
|
5305
|
+
ZodStringFormat.init(inst, def);
|
|
5306
|
+
});
|
|
5307
|
+
var ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
|
|
5308
|
+
$ZodISOTime.init(inst, def);
|
|
5309
|
+
ZodStringFormat.init(inst, def);
|
|
5310
|
+
});
|
|
5311
|
+
var ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
|
|
5312
|
+
$ZodISODuration.init(inst, def);
|
|
5313
|
+
ZodStringFormat.init(inst, def);
|
|
5314
|
+
});
|
|
4219
5315
|
var ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
|
|
4220
5316
|
$ZodEmail.init(inst, def);
|
|
4221
5317
|
ZodStringFormat.init(inst, def);
|
|
@@ -4296,60 +5392,68 @@ var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
|
4296
5392
|
$ZodNumber.init(inst, def);
|
|
4297
5393
|
ZodType.init(inst, def);
|
|
4298
5394
|
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
4299
|
-
_installLazyMethods(inst, "ZodNumber", {
|
|
4300
|
-
gt(value, params) {
|
|
4301
|
-
return this.check(_gt(value, params));
|
|
4302
|
-
},
|
|
4303
|
-
gte(value, params) {
|
|
4304
|
-
return this.check(_gte(value, params));
|
|
4305
|
-
},
|
|
4306
|
-
min(value, params) {
|
|
4307
|
-
return this.check(_gte(value, params));
|
|
4308
|
-
},
|
|
4309
|
-
lt(value, params) {
|
|
4310
|
-
return this.check(_lt(value, params));
|
|
4311
|
-
},
|
|
4312
|
-
lte(value, params) {
|
|
4313
|
-
return this.check(_lte(value, params));
|
|
4314
|
-
},
|
|
4315
|
-
max(value, params) {
|
|
4316
|
-
return this.check(_lte(value, params));
|
|
4317
|
-
},
|
|
4318
|
-
int(params) {
|
|
4319
|
-
return this.check(int(params));
|
|
4320
|
-
},
|
|
4321
|
-
safe(params) {
|
|
4322
|
-
return this.check(int(params));
|
|
4323
|
-
},
|
|
4324
|
-
positive(params) {
|
|
4325
|
-
return this.check(_gt(0, params));
|
|
4326
|
-
},
|
|
4327
|
-
nonnegative(params) {
|
|
4328
|
-
return this.check(_gte(0, params));
|
|
4329
|
-
},
|
|
4330
|
-
negative(params) {
|
|
4331
|
-
return this.check(_lt(0, params));
|
|
4332
|
-
},
|
|
4333
|
-
nonpositive(params) {
|
|
4334
|
-
return this.check(_lte(0, params));
|
|
4335
|
-
},
|
|
4336
|
-
multipleOf(value, params) {
|
|
4337
|
-
return this.check(_multipleOf(value, params));
|
|
4338
|
-
},
|
|
4339
|
-
step(value, params) {
|
|
4340
|
-
return this.check(_multipleOf(value, params));
|
|
4341
|
-
},
|
|
4342
|
-
finite() {
|
|
4343
|
-
return this;
|
|
4344
|
-
}
|
|
4345
|
-
});
|
|
4346
|
-
const bag = inst._zod.bag;
|
|
4347
|
-
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
4348
|
-
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
4349
|
-
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
4350
5395
|
inst.isFinite = true;
|
|
4351
|
-
|
|
4352
|
-
|
|
5396
|
+
}, /* @__PURE__ */ derived({
|
|
5397
|
+
minValue: (inst) => {
|
|
5398
|
+
const { minimum, exclusiveMinimum } = aggregateChecks(inst);
|
|
5399
|
+
return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
|
|
5400
|
+
},
|
|
5401
|
+
maxValue: (inst) => {
|
|
5402
|
+
const { maximum, exclusiveMaximum } = aggregateChecks(inst);
|
|
5403
|
+
return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
|
|
5404
|
+
},
|
|
5405
|
+
isInt: (inst) => {
|
|
5406
|
+
const { isInt, multipleOf } = aggregateChecks(inst);
|
|
5407
|
+
return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
|
|
5408
|
+
},
|
|
5409
|
+
format: (inst) => aggregateChecks(inst).format ?? null
|
|
5410
|
+
}, {
|
|
5411
|
+
gt(value, params) {
|
|
5412
|
+
return this.check(_gt(value, params));
|
|
5413
|
+
},
|
|
5414
|
+
gte(value, params) {
|
|
5415
|
+
return this.check(_gte(value, params));
|
|
5416
|
+
},
|
|
5417
|
+
min(value, params) {
|
|
5418
|
+
return this.check(_gte(value, params));
|
|
5419
|
+
},
|
|
5420
|
+
lt(value, params) {
|
|
5421
|
+
return this.check(_lt(value, params));
|
|
5422
|
+
},
|
|
5423
|
+
lte(value, params) {
|
|
5424
|
+
return this.check(_lte(value, params));
|
|
5425
|
+
},
|
|
5426
|
+
max(value, params) {
|
|
5427
|
+
return this.check(_lte(value, params));
|
|
5428
|
+
},
|
|
5429
|
+
int(params) {
|
|
5430
|
+
return this.check(int(params));
|
|
5431
|
+
},
|
|
5432
|
+
safe(params) {
|
|
5433
|
+
return this.check(int(params));
|
|
5434
|
+
},
|
|
5435
|
+
positive(params) {
|
|
5436
|
+
return this.check(_gt(0, params));
|
|
5437
|
+
},
|
|
5438
|
+
nonnegative(params) {
|
|
5439
|
+
return this.check(_gte(0, params));
|
|
5440
|
+
},
|
|
5441
|
+
negative(params) {
|
|
5442
|
+
return this.check(_lt(0, params));
|
|
5443
|
+
},
|
|
5444
|
+
nonpositive(params) {
|
|
5445
|
+
return this.check(_lte(0, params));
|
|
5446
|
+
},
|
|
5447
|
+
multipleOf(value, params) {
|
|
5448
|
+
return this.check(_multipleOf(value, params));
|
|
5449
|
+
},
|
|
5450
|
+
step(value, params) {
|
|
5451
|
+
return this.check(_multipleOf(value, params));
|
|
5452
|
+
},
|
|
5453
|
+
finite() {
|
|
5454
|
+
return this;
|
|
5455
|
+
}
|
|
5456
|
+
}));
|
|
4353
5457
|
function number2(params) {
|
|
4354
5458
|
return _number(ZodNumber, params);
|
|
4355
5459
|
}
|
|
@@ -4385,79 +5489,80 @@ function never(params) {
|
|
|
4385
5489
|
return _never(ZodNever, params);
|
|
4386
5490
|
}
|
|
4387
5491
|
var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
5492
|
+
_ensureDefaultMemoizer();
|
|
4388
5493
|
$ZodArray.init(inst, def);
|
|
4389
5494
|
ZodType.init(inst, def);
|
|
4390
5495
|
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
4391
5496
|
inst.element = def.element;
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
});
|
|
5497
|
+
}, {
|
|
5498
|
+
min(n, params) {
|
|
5499
|
+
return this.check(_minLength(n, params));
|
|
5500
|
+
},
|
|
5501
|
+
nonempty(params) {
|
|
5502
|
+
return this.check(_minLength(1, params));
|
|
5503
|
+
},
|
|
5504
|
+
max(n, params) {
|
|
5505
|
+
return this.check(_maxLength(n, params));
|
|
5506
|
+
},
|
|
5507
|
+
length(n, params) {
|
|
5508
|
+
return this.check(_length(n, params));
|
|
5509
|
+
},
|
|
5510
|
+
unwrap() {
|
|
5511
|
+
return this.element;
|
|
5512
|
+
}
|
|
4409
5513
|
});
|
|
4410
5514
|
function array(element, params) {
|
|
4411
5515
|
return _array(ZodArray, element, params);
|
|
4412
5516
|
}
|
|
4413
5517
|
var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
5518
|
+
_ensureDefaultMemoizer();
|
|
4414
5519
|
$ZodObjectJIT.init(inst, def);
|
|
4415
5520
|
ZodType.init(inst, def);
|
|
4416
5521
|
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
}
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
}
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
}
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
}
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
}
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
}
|
|
5522
|
+
installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
|
|
5523
|
+
}, {
|
|
5524
|
+
keyof() {
|
|
5525
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
5526
|
+
},
|
|
5527
|
+
catchall(catchall) {
|
|
5528
|
+
return this.clone(mergeDefs(this._zod.def, { catchall }));
|
|
5529
|
+
},
|
|
5530
|
+
passthrough() {
|
|
5531
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
5532
|
+
},
|
|
5533
|
+
loose() {
|
|
5534
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
5535
|
+
},
|
|
5536
|
+
strict() {
|
|
5537
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
|
|
5538
|
+
},
|
|
5539
|
+
strip() {
|
|
5540
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: undefined }));
|
|
5541
|
+
},
|
|
5542
|
+
extend(incoming) {
|
|
5543
|
+
return extend(this, incoming);
|
|
5544
|
+
},
|
|
5545
|
+
safeExtend(incoming) {
|
|
5546
|
+
return safeExtend(this, incoming);
|
|
5547
|
+
},
|
|
5548
|
+
merge(other) {
|
|
5549
|
+
return merge(this, other);
|
|
5550
|
+
},
|
|
5551
|
+
pick(mask) {
|
|
5552
|
+
return pick(this, mask);
|
|
5553
|
+
},
|
|
5554
|
+
omit(mask) {
|
|
5555
|
+
return omit(this, mask);
|
|
5556
|
+
},
|
|
5557
|
+
partial(...args) {
|
|
5558
|
+
return partial(ZodOptional, this, args[0]);
|
|
5559
|
+
},
|
|
5560
|
+
exactPartial(...args) {
|
|
5561
|
+
return partial(ZodExactOptional, this, args[0], "exactPartial");
|
|
5562
|
+
},
|
|
5563
|
+
required(...args) {
|
|
5564
|
+
return required(ZodNonOptional, this, args[0]);
|
|
5565
|
+
}
|
|
4461
5566
|
});
|
|
4462
5567
|
function object(shape, params) {
|
|
4463
5568
|
const def = {
|
|
@@ -4493,6 +5598,7 @@ function intersection(left, right) {
|
|
|
4493
5598
|
});
|
|
4494
5599
|
}
|
|
4495
5600
|
var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
5601
|
+
_ensureDefaultMemoizer();
|
|
4496
5602
|
$ZodRecord.init(inst, def);
|
|
4497
5603
|
ZodType.init(inst, def);
|
|
4498
5604
|
inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
|
|
@@ -4520,7 +5626,7 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
4520
5626
|
ZodType.init(inst, def);
|
|
4521
5627
|
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
4522
5628
|
inst.enum = def.entries;
|
|
4523
|
-
inst.options =
|
|
5629
|
+
inst.options = [...inst._zod.values];
|
|
4524
5630
|
const keys = new Set(Object.keys(def.entries));
|
|
4525
5631
|
inst.extract = (values, params) => {
|
|
4526
5632
|
const newEntries = {};
|
|
@@ -4583,6 +5689,7 @@ function literal(value, params) {
|
|
|
4583
5689
|
});
|
|
4584
5690
|
}
|
|
4585
5691
|
var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
5692
|
+
_ensureDefaultMemoizer();
|
|
4586
5693
|
$ZodTransform.init(inst, def);
|
|
4587
5694
|
ZodType.init(inst, def);
|
|
4588
5695
|
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
@@ -4598,7 +5705,8 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
|
4598
5705
|
if (_issue.fatal)
|
|
4599
5706
|
_issue.continue = false;
|
|
4600
5707
|
_issue.code ?? (_issue.code = "custom");
|
|
4601
|
-
|
|
5708
|
+
if (!("input" in _issue))
|
|
5709
|
+
_issue.input = payload.value;
|
|
4602
5710
|
_issue.inst ?? (_issue.inst = inst);
|
|
4603
5711
|
payload.issues.push(issue(_issue));
|
|
4604
5712
|
}
|
|
@@ -4607,12 +5715,10 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
|
4607
5715
|
if (output instanceof Promise) {
|
|
4608
5716
|
return output.then((output) => {
|
|
4609
5717
|
payload.value = output;
|
|
4610
|
-
payload.fallback = true;
|
|
4611
5718
|
return payload;
|
|
4612
5719
|
});
|
|
4613
5720
|
}
|
|
4614
5721
|
payload.value = output;
|
|
4615
|
-
payload.fallback = true;
|
|
4616
5722
|
return payload;
|
|
4617
5723
|
};
|
|
4618
5724
|
});
|
|
@@ -4713,7 +5819,7 @@ function _catch(innerType, catchValue) {
|
|
|
4713
5819
|
return new ZodCatch({
|
|
4714
5820
|
type: "catch",
|
|
4715
5821
|
innerType,
|
|
4716
|
-
catchValue: typeof catchValue === "function" ? catchValue : ()
|
|
5822
|
+
catchValue: typeof catchValue === "function" ? catchValue : constantCatch(catchValue)
|
|
4717
5823
|
});
|
|
4718
5824
|
}
|
|
4719
5825
|
var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
@@ -4753,8 +5859,6 @@ function refine(fn, _params = {}) {
|
|
|
4753
5859
|
function superRefine(fn, params) {
|
|
4754
5860
|
return _superRefine(fn, params);
|
|
4755
5861
|
}
|
|
4756
|
-
// ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
4757
|
-
config(en_default());
|
|
4758
5862
|
// ../plugin/src/agents/language-directive.ts
|
|
4759
5863
|
var ENGLISH_LANGUAGE_NAMES = new Intl.DisplayNames(["en"], {
|
|
4760
5864
|
type: "language",
|
|
@@ -5691,6 +6795,25 @@ var EmbeddingConfigSchema = BaseEmbeddingConfigSchema.transform((data) => {
|
|
|
5691
6795
|
}
|
|
5692
6796
|
return { provider: "off" };
|
|
5693
6797
|
});
|
|
6798
|
+
var RerankConfigSchema = object({
|
|
6799
|
+
provider: _enum(["synapse", "remote", "off"]).default("synapse").describe("Explicit ctx_search reranker: local Synapse by default, remote for hosted scoring, or off. Projects may only select off."),
|
|
6800
|
+
endpoint: string2().trim().optional().describe("User-level rerank API base URL; prefix with tei+ for Hugging Face TEI."),
|
|
6801
|
+
model: string2().trim().optional().describe("Hosted reranker model name."),
|
|
6802
|
+
api_key: string2().optional().describe("Bearer API key; supports {env:NAME} in user config, like embedding.api_key."),
|
|
6803
|
+
timeout_ms: number2().int().transform((n) => Math.max(50, Math.min(15000, n))).default(1500).describe("Hosted request timeout in milliseconds, clamped to 50–15000; also cancelled by ctx_search's abort signal."),
|
|
6804
|
+
top_n: number2().int().min(1).max(20).default(20).describe("Maximum fused candidates sent to the hosted reranker (1–20). Requests ask for a score for every submitted document; partial replies are rejected.")
|
|
6805
|
+
}).superRefine((data, ctx) => {
|
|
6806
|
+
if (data.provider !== "remote")
|
|
6807
|
+
return;
|
|
6808
|
+
for (const field of ["endpoint", "model"]) {
|
|
6809
|
+
if (!data[field])
|
|
6810
|
+
ctx.addIssue({
|
|
6811
|
+
code: "custom",
|
|
6812
|
+
path: [field],
|
|
6813
|
+
message: `${field} is required when rerank.provider is remote`
|
|
6814
|
+
});
|
|
6815
|
+
}
|
|
6816
|
+
}).describe("Explicit ctx_search reranking only. Defaults to local Synapse. Hosted settings are user-level only; projects may only select off.");
|
|
5694
6817
|
var MagicContextConfigSchema = object({
|
|
5695
6818
|
enabled: boolean2().default(true).describe("Enable magic context (default: true)"),
|
|
5696
6819
|
allow_home_project: boolean2().default(false).describe("Allow Magic Context sessions launched from the exact canonical home directory. A non-git home uses its deterministic dir: identity; a home repository uses its git: identity. USER-LEVEL ONLY: project config is ignored. The home identity is excluded from registry seed exports, never resolves descendants by containment, and cannot join a workspace."),
|
|
@@ -5753,6 +6876,7 @@ var MagicContextConfigSchema = object({
|
|
|
5753
6876
|
storage: object({
|
|
5754
6877
|
enforce_private_permissions: boolean2().default(true).describe("When true (default), Magic Context creates and re-tightens its TypeScript-mode storage directories to owner-only 0700 and storage files to owner-only 0600. Set false only for a deliberate trusted-group deployment whose operator manages those files externally; in TypeScript mode Magic Context then skips its own creation modes and recursive tightening. In Rust transform mode, ck-mc's store library always keeps the shared data directory owner-only 0700, regardless of this setting. USER-LEVEL ONLY — ignored in project config for security. On Windows, POSIX chmod modes are already meaningless, so this setting is a no-op.")
|
|
5755
6878
|
}).default({ enforce_private_permissions: true }).describe("Storage permission policy. The default keeps session content and memories owner-private. Disabling enforcement is for trusted shared-group storage managed externally; TypeScript mode follows that policy, but Rust transform mode always keeps its shared data directory owner-only because ck-mc's store library enforces it."),
|
|
6879
|
+
rerank: RerankConfigSchema.optional(),
|
|
5756
6880
|
embedding: EmbeddingConfigSchema.default({
|
|
5757
6881
|
provider: "local",
|
|
5758
6882
|
model: DEFAULT_LOCAL_EMBEDDING_MODEL,
|