@joe-broadhead/opencode-messaging 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +103 -0
- package/LICENSE +21 -0
- package/NOTICE +12 -0
- package/README.md +256 -2
- package/dist/index.js +13647 -0
- package/dist/messaging.js +14162 -0
- package/dist/messagingd.js +27312 -0
- package/dist/rpc.js +5047 -0
- package/dist/third-party-notices.md +81 -0
- package/dist/tui.js +13446 -0
- package/docs/architecture.md +401 -0
- package/docs/configuration.md +396 -0
- package/docs/security.md +562 -0
- package/package.json +97 -4
- package/skills/opencode-messaging/SKILL.md +203 -0
package/dist/rpc.js
ADDED
|
@@ -0,0 +1,5047 @@
|
|
|
1
|
+
import { Rpc } from "@opencode/plugin/rpc";
|
|
2
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/util.js
|
|
3
|
+
function getEnumValues(entries) {
|
|
4
|
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
5
|
+
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
6
|
+
}
|
|
7
|
+
function joinValues(array, separator = "|") {
|
|
8
|
+
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
|
9
|
+
}
|
|
10
|
+
function jsonStringifyReplacer(_, value) {
|
|
11
|
+
if (typeof value === "bigint") return value.toString();
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
var Cached = class {
|
|
15
|
+
constructor(getter) {
|
|
16
|
+
this._getter = getter;
|
|
17
|
+
this._value = void 0;
|
|
18
|
+
}
|
|
19
|
+
get value() {
|
|
20
|
+
const getter = this._getter;
|
|
21
|
+
if (getter !== void 0) {
|
|
22
|
+
this._value = getter();
|
|
23
|
+
this._getter = void 0;
|
|
24
|
+
}
|
|
25
|
+
return this._value;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function cached(getter) {
|
|
29
|
+
return new Cached(getter);
|
|
30
|
+
}
|
|
31
|
+
function nullish(input) {
|
|
32
|
+
return input === null || input === void 0;
|
|
33
|
+
}
|
|
34
|
+
function cleanRegex(source) {
|
|
35
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
36
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
37
|
+
return source.slice(start, end);
|
|
38
|
+
}
|
|
39
|
+
function floatSafeRemainder(val, step) {
|
|
40
|
+
const ratio = val / step;
|
|
41
|
+
const roundedRatio = Math.round(ratio);
|
|
42
|
+
const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
43
|
+
if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
|
|
44
|
+
return ratio - roundedRatio;
|
|
45
|
+
}
|
|
46
|
+
function assignProp(target, prop, value) {
|
|
47
|
+
Object.defineProperty(target, prop, {
|
|
48
|
+
value,
|
|
49
|
+
writable: true,
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function rawShape(def) {
|
|
55
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
56
|
+
return desc?.get ? desc.get.raw : desc?.value;
|
|
57
|
+
}
|
|
58
|
+
function sourceShape(schema) {
|
|
59
|
+
return rawShape(schema._zod.def) ?? schema._zod.def.shape;
|
|
60
|
+
}
|
|
61
|
+
function deferProp(target, key, getter) {
|
|
62
|
+
Object.defineProperty(target, key, {
|
|
63
|
+
get() {
|
|
64
|
+
const value = getter();
|
|
65
|
+
assignProp(this, key, value);
|
|
66
|
+
return value;
|
|
67
|
+
},
|
|
68
|
+
enumerable: true,
|
|
69
|
+
configurable: true
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function putProp(target, key, value) {
|
|
73
|
+
if (key in target) assignProp(target, key, value);
|
|
74
|
+
else target[key] = value;
|
|
75
|
+
}
|
|
76
|
+
function mirrorShape(target, source, keys, wrap) {
|
|
77
|
+
const raw = sourceShape(source);
|
|
78
|
+
for (const key of keys) {
|
|
79
|
+
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
80
|
+
if (!desc.enumerable) continue;
|
|
81
|
+
if (desc.get) deferProp(target, key, () => {
|
|
82
|
+
const value = source._zod.def.shape[key];
|
|
83
|
+
return wrap ? wrap(value, key) : value;
|
|
84
|
+
});
|
|
85
|
+
else putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function mirrorProps(target, source) {
|
|
89
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
90
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
91
|
+
if (!desc.enumerable) continue;
|
|
92
|
+
if (desc.get) deferProp(target, key, () => source[key]);
|
|
93
|
+
else putProp(target, key, desc.value);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function mergeDefs(...defs) {
|
|
97
|
+
const mergedDescriptors = {};
|
|
98
|
+
for (const def of defs) {
|
|
99
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
100
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
101
|
+
}
|
|
102
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
103
|
+
}
|
|
104
|
+
function esc(str) {
|
|
105
|
+
return JSON.stringify(str);
|
|
106
|
+
}
|
|
107
|
+
function slugify(input) {
|
|
108
|
+
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
109
|
+
}
|
|
110
|
+
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
111
|
+
function isObject(data) {
|
|
112
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
113
|
+
}
|
|
114
|
+
const allowsEval = cached(() => {
|
|
115
|
+
if (globalConfig.jitless) return false;
|
|
116
|
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
|
|
117
|
+
try {
|
|
118
|
+
new Function("");
|
|
119
|
+
return true;
|
|
120
|
+
} catch (_) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
function isPlainObject(o) {
|
|
125
|
+
if (isObject(o) === false) return false;
|
|
126
|
+
const ctor = o.constructor;
|
|
127
|
+
if (ctor === void 0) return true;
|
|
128
|
+
if (typeof ctor !== "function") return true;
|
|
129
|
+
const prot = ctor.prototype;
|
|
130
|
+
if (isObject(prot) === false) return false;
|
|
131
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
function shallowClone(o) {
|
|
135
|
+
if (isPlainObject(o)) return { ...o };
|
|
136
|
+
if (Array.isArray(o)) return [...o];
|
|
137
|
+
if (o instanceof Map) return new Map(o);
|
|
138
|
+
if (o instanceof Set) return new Set(o);
|
|
139
|
+
return o;
|
|
140
|
+
}
|
|
141
|
+
const propertyKeyTypes = new Set([
|
|
142
|
+
"string",
|
|
143
|
+
"number",
|
|
144
|
+
"symbol"
|
|
145
|
+
]);
|
|
146
|
+
function escapeRegex(str) {
|
|
147
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
148
|
+
}
|
|
149
|
+
function clone(inst, def, params) {
|
|
150
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
151
|
+
if (!def || params?.parent) cl._zod.parent = inst;
|
|
152
|
+
return cl;
|
|
153
|
+
}
|
|
154
|
+
function normalizeParams(_params) {
|
|
155
|
+
const params = _params;
|
|
156
|
+
if (!params) return {};
|
|
157
|
+
if (typeof params === "string") return { error: () => params };
|
|
158
|
+
if (params?.message !== void 0) {
|
|
159
|
+
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
|
160
|
+
params.error = params.message;
|
|
161
|
+
}
|
|
162
|
+
delete params.message;
|
|
163
|
+
if (typeof params.error === "string") return {
|
|
164
|
+
...params,
|
|
165
|
+
error: () => params.error
|
|
166
|
+
};
|
|
167
|
+
return params;
|
|
168
|
+
}
|
|
169
|
+
function stringifyPrimitive(value) {
|
|
170
|
+
if (typeof value === "bigint") return value.toString() + "n";
|
|
171
|
+
if (typeof value === "string") return `"${value}"`;
|
|
172
|
+
return `${value}`;
|
|
173
|
+
}
|
|
174
|
+
function optionalKeys(shape) {
|
|
175
|
+
return Object.keys(shape).filter((k) => {
|
|
176
|
+
return shape[k]._zod.optin !== void 0 && shape[k]._zod.optout === "optional";
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
const NUMBER_FORMAT_RANGES = (() => ({
|
|
180
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
181
|
+
int32: [-2147483648, 2147483647],
|
|
182
|
+
uint32: [0, 4294967295],
|
|
183
|
+
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
184
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
185
|
+
}))();
|
|
186
|
+
const BIGINT_FORMAT_RANGES = {
|
|
187
|
+
int64: [BigInt("-9223372036854775808"), BigInt("9223372036854775807")],
|
|
188
|
+
uint64: [BigInt(0), BigInt("18446744073709551615")]
|
|
189
|
+
};
|
|
190
|
+
function pick(schema, mask) {
|
|
191
|
+
const currDef = schema._zod.def;
|
|
192
|
+
const checks = currDef.checks;
|
|
193
|
+
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
194
|
+
const newShape = {};
|
|
195
|
+
mirrorShape(newShape, schema, maskedKeys(schema, mask));
|
|
196
|
+
return clone(schema, mergeDefs(currDef, {
|
|
197
|
+
shape: newShape,
|
|
198
|
+
checks: []
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
function maskedKeys(schema, mask) {
|
|
202
|
+
const raw = sourceShape(schema);
|
|
203
|
+
const keys = [];
|
|
204
|
+
for (const key of Reflect.ownKeys(mask)) {
|
|
205
|
+
if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
206
|
+
if (mask[key]) keys.push(key);
|
|
207
|
+
}
|
|
208
|
+
return keys;
|
|
209
|
+
}
|
|
210
|
+
function omit(schema, mask) {
|
|
211
|
+
const currDef = schema._zod.def;
|
|
212
|
+
const checks = currDef.checks;
|
|
213
|
+
if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
214
|
+
const omitted = new Set(maskedKeys(schema, mask));
|
|
215
|
+
const newShape = {};
|
|
216
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
|
|
217
|
+
return clone(schema, mergeDefs(currDef, {
|
|
218
|
+
shape: newShape,
|
|
219
|
+
checks: []
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
function extend(schema, shape) {
|
|
223
|
+
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
224
|
+
const checks = schema._zod.def.checks;
|
|
225
|
+
if (checks && checks.length > 0) {
|
|
226
|
+
const existingShape = sourceShape(schema);
|
|
227
|
+
for (const key of Reflect.ownKeys(shape)) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
228
|
+
}
|
|
229
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
230
|
+
}
|
|
231
|
+
function extended(schema, shape) {
|
|
232
|
+
const newShape = {};
|
|
233
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
|
|
234
|
+
mirrorProps(newShape, shape);
|
|
235
|
+
return newShape;
|
|
236
|
+
}
|
|
237
|
+
function safeExtend(schema, shape) {
|
|
238
|
+
if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
239
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
240
|
+
}
|
|
241
|
+
function merge(a, b) {
|
|
242
|
+
if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
|
|
243
|
+
if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
244
|
+
const newShape = {};
|
|
245
|
+
mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
|
|
246
|
+
mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
|
|
247
|
+
return clone(a, mergeDefs(a._zod.def, {
|
|
248
|
+
shape: newShape,
|
|
249
|
+
get catchall() {
|
|
250
|
+
return b._zod.def.catchall;
|
|
251
|
+
},
|
|
252
|
+
checks: b._zod.def.checks ?? []
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
function partial(Class, schema, mask, name = "partial") {
|
|
256
|
+
const checks = schema._zod.def.checks;
|
|
257
|
+
if (checks && checks.length > 0) throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
|
|
258
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
|
|
259
|
+
const newShape = {};
|
|
260
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({
|
|
261
|
+
type: "optional",
|
|
262
|
+
innerType: value
|
|
263
|
+
})));
|
|
264
|
+
return clone(schema, mergeDefs(schema._zod.def, {
|
|
265
|
+
shape: newShape,
|
|
266
|
+
checks: []
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
269
|
+
function required(Class, schema, mask) {
|
|
270
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
|
|
271
|
+
const newShape = {};
|
|
272
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({
|
|
273
|
+
type: "nonoptional",
|
|
274
|
+
innerType: value
|
|
275
|
+
}));
|
|
276
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
|
|
277
|
+
}
|
|
278
|
+
function aborted(x, startIndex = 0) {
|
|
279
|
+
if (x.aborted === true) return true;
|
|
280
|
+
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
function explicitlyAborted(x, startIndex = 0) {
|
|
284
|
+
if (x.aborted === true) return true;
|
|
285
|
+
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue === false) return true;
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
function prefixIssues(path, issues) {
|
|
289
|
+
return issues.map((iss) => {
|
|
290
|
+
var _a;
|
|
291
|
+
(_a = iss).path ?? (_a.path = []);
|
|
292
|
+
iss.path.unshift(path);
|
|
293
|
+
return iss;
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
function unwrapMessage(message) {
|
|
297
|
+
return typeof message === "string" ? message : message?.message;
|
|
298
|
+
}
|
|
299
|
+
function sizeCaps(defChecks) {
|
|
300
|
+
const caps = [];
|
|
301
|
+
for (const ch of defChecks ?? []) {
|
|
302
|
+
const d = ch._zod.def;
|
|
303
|
+
if (!/_(length|size)$|_equals$/.test(d.check)) break;
|
|
304
|
+
const max = d.maximum ?? d.length ?? d.size;
|
|
305
|
+
if (max >= 0) caps.push([max, ch]);
|
|
306
|
+
}
|
|
307
|
+
return caps;
|
|
308
|
+
}
|
|
309
|
+
function attachSchema(issues, start, inst) {
|
|
310
|
+
var _a;
|
|
311
|
+
for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
|
|
312
|
+
}
|
|
313
|
+
function finalizeIssue(iss, ctx, config) {
|
|
314
|
+
var _a;
|
|
315
|
+
const traits = iss.inst?._zod?.traits;
|
|
316
|
+
if (traits?.has("$ZodType")) {
|
|
317
|
+
if (traits.has("$ZodCheck")) (_a = iss).schema ?? (_a.schema = iss.inst);
|
|
318
|
+
else iss.schema = iss.inst;
|
|
319
|
+
}
|
|
320
|
+
const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
|
|
321
|
+
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";
|
|
322
|
+
const full = {};
|
|
323
|
+
for (const k of Object.keys(iss)) {
|
|
324
|
+
if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__") continue;
|
|
325
|
+
full[k] = iss[k];
|
|
326
|
+
}
|
|
327
|
+
full.path ?? (full.path = []);
|
|
328
|
+
full.message = message;
|
|
329
|
+
if (ctx?.reportInput) full.input = iss.input;
|
|
330
|
+
return full;
|
|
331
|
+
}
|
|
332
|
+
const highSurrogate = /[\uD800-\uDBFF]/;
|
|
333
|
+
function codePointLength(str) {
|
|
334
|
+
const units = str.length;
|
|
335
|
+
if (!highSurrogate.test(str)) return units;
|
|
336
|
+
let count = units;
|
|
337
|
+
for (let i = 0; i < units - 1; i++) if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
|
338
|
+
count--;
|
|
339
|
+
i++;
|
|
340
|
+
}
|
|
341
|
+
return count;
|
|
342
|
+
}
|
|
343
|
+
function getLengthableOrigin(input) {
|
|
344
|
+
if (Array.isArray(input)) return "array";
|
|
345
|
+
if (typeof input === "string") return "string";
|
|
346
|
+
return "unknown";
|
|
347
|
+
}
|
|
348
|
+
function parsedType(data) {
|
|
349
|
+
const t = typeof data;
|
|
350
|
+
switch (t) {
|
|
351
|
+
case "number": return Number.isNaN(data) ? "nan" : "number";
|
|
352
|
+
case "object": {
|
|
353
|
+
if (data === null) return "null";
|
|
354
|
+
if (Array.isArray(data)) return "array";
|
|
355
|
+
const obj = data;
|
|
356
|
+
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) return obj.constructor.name;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return t;
|
|
360
|
+
}
|
|
361
|
+
function issue(...args) {
|
|
362
|
+
const [iss, input, inst] = args;
|
|
363
|
+
if (typeof iss === "string") return {
|
|
364
|
+
message: iss,
|
|
365
|
+
code: "custom",
|
|
366
|
+
input,
|
|
367
|
+
inst
|
|
368
|
+
};
|
|
369
|
+
return { ...iss };
|
|
370
|
+
}
|
|
371
|
+
function members(proto, table) {
|
|
372
|
+
for (const key in table) {
|
|
373
|
+
const desc = Object.getOwnPropertyDescriptor(table, key);
|
|
374
|
+
if (desc.get) Object.defineProperty(proto, key, {
|
|
375
|
+
...desc,
|
|
376
|
+
enumerable: false
|
|
377
|
+
});
|
|
378
|
+
else defineBound(proto, key, desc.value);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function own(inst, key, value, enumerable = true) {
|
|
382
|
+
Object.defineProperty(inst, key, {
|
|
383
|
+
configurable: true,
|
|
384
|
+
writable: true,
|
|
385
|
+
enumerable,
|
|
386
|
+
value
|
|
387
|
+
});
|
|
388
|
+
return value;
|
|
389
|
+
}
|
|
390
|
+
function hide(inst, key, value) {
|
|
391
|
+
return own(inst, key, value, false);
|
|
392
|
+
}
|
|
393
|
+
function derived(computes, table) {
|
|
394
|
+
for (const key in computes) {
|
|
395
|
+
const compute = computes[key];
|
|
396
|
+
Object.defineProperty(table, key, {
|
|
397
|
+
configurable: true,
|
|
398
|
+
enumerable: true,
|
|
399
|
+
get() {
|
|
400
|
+
return own(this, key, compute(this));
|
|
401
|
+
},
|
|
402
|
+
set(value) {
|
|
403
|
+
own(this, key, value);
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
return table;
|
|
408
|
+
}
|
|
409
|
+
function defineBound(proto, key, fn) {
|
|
410
|
+
Object.defineProperty(proto, key, {
|
|
411
|
+
configurable: true,
|
|
412
|
+
get() {
|
|
413
|
+
return this == null ? fn : own(this, key, fn.bind(this));
|
|
414
|
+
},
|
|
415
|
+
set(value) {
|
|
416
|
+
own(this, key, value);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
function claim(inst, sentinel) {
|
|
421
|
+
const proto = Object.getPrototypeOf(inst);
|
|
422
|
+
return sentinel in proto ? void 0 : proto;
|
|
423
|
+
}
|
|
424
|
+
let installing;
|
|
425
|
+
let broke = false;
|
|
426
|
+
const breaker = {
|
|
427
|
+
configurable: true,
|
|
428
|
+
get() {
|
|
429
|
+
broke = true;
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
function defineLazyInternal(inst, key, compute) {
|
|
433
|
+
const proto = Object.getPrototypeOf(inst._zod);
|
|
434
|
+
if (key in proto && installing !== inst._zod) {
|
|
435
|
+
installing = void 0;
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
installing = inst._zod;
|
|
439
|
+
Object.defineProperty(proto, key, {
|
|
440
|
+
configurable: true,
|
|
441
|
+
get() {
|
|
442
|
+
Object.defineProperty(this, key, breaker);
|
|
443
|
+
const outer = broke;
|
|
444
|
+
broke = false;
|
|
445
|
+
try {
|
|
446
|
+
const value = compute(this);
|
|
447
|
+
if (broke) delete this[key];
|
|
448
|
+
else Object.defineProperty(this, key, {
|
|
449
|
+
configurable: true,
|
|
450
|
+
writable: true,
|
|
451
|
+
value
|
|
452
|
+
});
|
|
453
|
+
broke = broke || outer;
|
|
454
|
+
return value;
|
|
455
|
+
} catch (err) {
|
|
456
|
+
delete this[key];
|
|
457
|
+
broke = broke || outer;
|
|
458
|
+
throw err;
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
set(value) {
|
|
462
|
+
Object.defineProperty(this, key, {
|
|
463
|
+
configurable: true,
|
|
464
|
+
writable: true,
|
|
465
|
+
value
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
function installLazyProp(inst, key, make, enumerable) {
|
|
471
|
+
const proto = claim(inst, key);
|
|
472
|
+
if (!proto) return;
|
|
473
|
+
Object.defineProperty(proto, key, {
|
|
474
|
+
configurable: true,
|
|
475
|
+
get() {
|
|
476
|
+
const desc = {
|
|
477
|
+
configurable: true,
|
|
478
|
+
writable: true,
|
|
479
|
+
enumerable,
|
|
480
|
+
value: void 0
|
|
481
|
+
};
|
|
482
|
+
Object.defineProperty(this, key, desc);
|
|
483
|
+
desc.value = make(this);
|
|
484
|
+
Object.defineProperty(this, key, desc);
|
|
485
|
+
return desc.value;
|
|
486
|
+
},
|
|
487
|
+
set(value) {
|
|
488
|
+
Object.defineProperty(this, key, {
|
|
489
|
+
configurable: true,
|
|
490
|
+
writable: true,
|
|
491
|
+
enumerable,
|
|
492
|
+
value
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
const CONSTANT_CATCH = "~constantCatch";
|
|
498
|
+
function constantCatch(value) {
|
|
499
|
+
const fn = () => value;
|
|
500
|
+
fn[CONSTANT_CATCH] = true;
|
|
501
|
+
return fn;
|
|
502
|
+
}
|
|
503
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/core.js
|
|
504
|
+
var _a$1;
|
|
505
|
+
const _zodDesc = {
|
|
506
|
+
value: void 0,
|
|
507
|
+
enumerable: false
|
|
508
|
+
};
|
|
509
|
+
let _E = "captureStackTrace" in Error ? Error : null;
|
|
510
|
+
function newError(Definition) {
|
|
511
|
+
const E = _E;
|
|
512
|
+
if (E) {
|
|
513
|
+
const saved = E.stackTraceLimit;
|
|
514
|
+
if (typeof saved === "number") {
|
|
515
|
+
try {
|
|
516
|
+
E.stackTraceLimit = 0;
|
|
517
|
+
} catch {
|
|
518
|
+
_E = null;
|
|
519
|
+
return new Definition();
|
|
520
|
+
}
|
|
521
|
+
try {
|
|
522
|
+
return new Definition();
|
|
523
|
+
} finally {
|
|
524
|
+
E.stackTraceLimit = saved;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
return new Definition();
|
|
529
|
+
}
|
|
530
|
+
function $constructor(name, initializer, proto, params) {
|
|
531
|
+
const zodProto = {};
|
|
532
|
+
function Internals(def) {
|
|
533
|
+
this.def = def;
|
|
534
|
+
this.constr = _;
|
|
535
|
+
this.traits = new Set();
|
|
536
|
+
}
|
|
537
|
+
Internals.prototype = zodProto;
|
|
538
|
+
const protoMembers = proto;
|
|
539
|
+
const initialized = protoMembers && new WeakSet();
|
|
540
|
+
function init(inst, def) {
|
|
541
|
+
if (!inst._zod) {
|
|
542
|
+
_zodDesc.value = new Internals(def);
|
|
543
|
+
try {
|
|
544
|
+
Object.defineProperty(inst, "_zod", _zodDesc);
|
|
545
|
+
} finally {
|
|
546
|
+
_zodDesc.value = void 0;
|
|
547
|
+
}
|
|
548
|
+
} else if (inst._zod.traits.has(name)) return;
|
|
549
|
+
inst._zod.traits.add(name);
|
|
550
|
+
initializer(inst, def);
|
|
551
|
+
if (initialized) {
|
|
552
|
+
const own = Object.getPrototypeOf(inst);
|
|
553
|
+
const ctorProto = inst._zod.constr.prototype;
|
|
554
|
+
let up = own;
|
|
555
|
+
while (up && up !== ctorProto) up = Object.getPrototypeOf(up);
|
|
556
|
+
const target = up ?? own;
|
|
557
|
+
if (!initialized.has(target)) {
|
|
558
|
+
initialized.add(target);
|
|
559
|
+
members(target, protoMembers);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
const proto = _.prototype;
|
|
563
|
+
for (const k in proto) {
|
|
564
|
+
if (!Object.prototype.hasOwnProperty.call(proto, k)) continue;
|
|
565
|
+
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
const Parent = params?.Parent ?? Object;
|
|
569
|
+
class Definition extends Parent {}
|
|
570
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
571
|
+
function _(def) {
|
|
572
|
+
const inst = params?.Parent ? newError(Definition) : this;
|
|
573
|
+
init(inst, def);
|
|
574
|
+
const deferred = inst._zod.deferred;
|
|
575
|
+
if (deferred) {
|
|
576
|
+
for (const fn of deferred) fn();
|
|
577
|
+
inst._zod.deferred = void 0;
|
|
578
|
+
}
|
|
579
|
+
const pp = globalThis.__zod_globalConfig?.postProcessor;
|
|
580
|
+
if (pp) pp(inst);
|
|
581
|
+
return inst;
|
|
582
|
+
}
|
|
583
|
+
Object.defineProperty(_, "init", { value: init });
|
|
584
|
+
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
585
|
+
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
586
|
+
return inst?._zod?.traits?.has(name);
|
|
587
|
+
} });
|
|
588
|
+
Object.defineProperty(_, "name", { value: name });
|
|
589
|
+
return _;
|
|
590
|
+
}
|
|
591
|
+
var $ZodAsyncError = class extends Error {
|
|
592
|
+
constructor() {
|
|
593
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
var $ZodEncodeError = class extends Error {
|
|
597
|
+
constructor(name) {
|
|
598
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
599
|
+
this.name = "ZodEncodeError";
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
603
|
+
const globalConfig = globalThis.__zod_globalConfig;
|
|
604
|
+
function config(newConfig) {
|
|
605
|
+
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
606
|
+
return globalConfig;
|
|
607
|
+
}
|
|
608
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/errors.js
|
|
609
|
+
function _getMessage() {
|
|
610
|
+
const internals = this._zod;
|
|
611
|
+
internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
|
|
612
|
+
return internals.message;
|
|
613
|
+
}
|
|
614
|
+
function _setMessage(value) {
|
|
615
|
+
this._zod.message = value;
|
|
616
|
+
}
|
|
617
|
+
const _messageDesc = {
|
|
618
|
+
get: _getMessage,
|
|
619
|
+
set: _setMessage,
|
|
620
|
+
enumerable: true,
|
|
621
|
+
configurable: true
|
|
622
|
+
};
|
|
623
|
+
const _issuesDesc = {
|
|
624
|
+
value: void 0,
|
|
625
|
+
enumerable: false
|
|
626
|
+
};
|
|
627
|
+
const _installedToString = new WeakSet([Object.prototype, Error.prototype]);
|
|
628
|
+
const initializer$1 = (inst, def) => {
|
|
629
|
+
inst.name = "$ZodError";
|
|
630
|
+
_issuesDesc.value = def;
|
|
631
|
+
Object.defineProperty(inst, "issues", _issuesDesc);
|
|
632
|
+
_issuesDesc.value = void 0;
|
|
633
|
+
Object.defineProperty(inst, "message", _messageDesc);
|
|
634
|
+
const proto = Object.getPrototypeOf(inst);
|
|
635
|
+
if (!_installedToString.has(proto)) {
|
|
636
|
+
_installedToString.add(proto);
|
|
637
|
+
Object.defineProperty(proto, "toString", {
|
|
638
|
+
configurable: true,
|
|
639
|
+
enumerable: false,
|
|
640
|
+
get() {
|
|
641
|
+
const value = () => this.message;
|
|
642
|
+
Object.defineProperty(this, "toString", {
|
|
643
|
+
value,
|
|
644
|
+
configurable: true,
|
|
645
|
+
writable: true
|
|
646
|
+
});
|
|
647
|
+
return value;
|
|
648
|
+
},
|
|
649
|
+
set(value) {
|
|
650
|
+
Object.defineProperty(this, "toString", {
|
|
651
|
+
value,
|
|
652
|
+
configurable: true,
|
|
653
|
+
writable: true
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
const $ZodError = $constructor("$ZodError", initializer$1);
|
|
660
|
+
function node(obj, key, make) {
|
|
661
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
662
|
+
if (key === "__proto__") Object.defineProperty(obj, key, {
|
|
663
|
+
value: make(),
|
|
664
|
+
writable: true,
|
|
665
|
+
enumerable: true,
|
|
666
|
+
configurable: true
|
|
667
|
+
});
|
|
668
|
+
else obj[key] = make();
|
|
669
|
+
}
|
|
670
|
+
return obj[key];
|
|
671
|
+
}
|
|
672
|
+
function flattenError(error, mapper = (issue) => issue.message) {
|
|
673
|
+
const fieldErrors = {};
|
|
674
|
+
const formErrors = [];
|
|
675
|
+
for (const sub of error.issues) if (sub.path.length > 0) node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
|
|
676
|
+
else formErrors.push(mapper(sub));
|
|
677
|
+
return {
|
|
678
|
+
formErrors,
|
|
679
|
+
fieldErrors
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
function formatError(error, mapper = (issue) => issue.message) {
|
|
683
|
+
const fieldErrors = { _errors: [] };
|
|
684
|
+
const processError = (error, path = []) => {
|
|
685
|
+
for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
686
|
+
else if (issue.code === "invalid_key") processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
687
|
+
else if (issue.code === "invalid_element") processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
688
|
+
else {
|
|
689
|
+
const fullpath = [...path, ...issue.path];
|
|
690
|
+
if (fullpath.length === 0) fieldErrors._errors.push(mapper(issue));
|
|
691
|
+
else {
|
|
692
|
+
let curr = fieldErrors;
|
|
693
|
+
let i = 0;
|
|
694
|
+
while (i < fullpath.length) {
|
|
695
|
+
const el = fullpath[i];
|
|
696
|
+
const terminal = i === fullpath.length - 1;
|
|
697
|
+
if (el === "_errors") {
|
|
698
|
+
if (terminal) curr._errors.push(mapper(issue));
|
|
699
|
+
i++;
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
if (!Object.prototype.hasOwnProperty.call(curr, el)) Object.defineProperty(curr, el, {
|
|
703
|
+
value: { _errors: [] },
|
|
704
|
+
enumerable: true,
|
|
705
|
+
writable: true,
|
|
706
|
+
configurable: true
|
|
707
|
+
});
|
|
708
|
+
const node = curr[el];
|
|
709
|
+
if (terminal) node._errors.push(mapper(issue));
|
|
710
|
+
curr = node;
|
|
711
|
+
i++;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
processError(error);
|
|
717
|
+
return fieldErrors;
|
|
718
|
+
}
|
|
719
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/parse.js
|
|
720
|
+
function finalizeParams(callee, params) {
|
|
721
|
+
return {
|
|
722
|
+
callee: params?.callee ?? callee,
|
|
723
|
+
Err: params?.Err
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
const _parse = (_Err) => {
|
|
727
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
728
|
+
const ctx = _ctx ? {
|
|
729
|
+
..._ctx,
|
|
730
|
+
async: false
|
|
731
|
+
} : { async: false };
|
|
732
|
+
const result = schema._zod.run({
|
|
733
|
+
value,
|
|
734
|
+
issues: []
|
|
735
|
+
}, ctx);
|
|
736
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
737
|
+
if (result.issues.length) {
|
|
738
|
+
const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
739
|
+
captureStackTrace(e, _params?.callee ?? fn);
|
|
740
|
+
throw e;
|
|
741
|
+
}
|
|
742
|
+
return result.value;
|
|
743
|
+
};
|
|
744
|
+
return fn;
|
|
745
|
+
};
|
|
746
|
+
const _parseAsync = (_Err) => {
|
|
747
|
+
const fn = async (schema, value, _ctx, params) => {
|
|
748
|
+
const ctx = _ctx ? {
|
|
749
|
+
..._ctx,
|
|
750
|
+
async: true
|
|
751
|
+
} : { async: true };
|
|
752
|
+
let result = schema._zod.run({
|
|
753
|
+
value,
|
|
754
|
+
issues: []
|
|
755
|
+
}, ctx);
|
|
756
|
+
if (result instanceof Promise) result = await result;
|
|
757
|
+
if (result.issues.length) {
|
|
758
|
+
const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
759
|
+
captureStackTrace(e, params?.callee ?? fn);
|
|
760
|
+
throw e;
|
|
761
|
+
}
|
|
762
|
+
return result.value;
|
|
763
|
+
};
|
|
764
|
+
return fn;
|
|
765
|
+
};
|
|
766
|
+
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
767
|
+
const ctx = _ctx ? {
|
|
768
|
+
..._ctx,
|
|
769
|
+
async: false
|
|
770
|
+
} : { async: false };
|
|
771
|
+
const result = schema._zod.run({
|
|
772
|
+
value,
|
|
773
|
+
issues: []
|
|
774
|
+
}, ctx);
|
|
775
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
776
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : {
|
|
777
|
+
success: true,
|
|
778
|
+
data: result.value
|
|
779
|
+
};
|
|
780
|
+
};
|
|
781
|
+
function failure(Err, issues, ctx) {
|
|
782
|
+
let error;
|
|
783
|
+
return {
|
|
784
|
+
success: false,
|
|
785
|
+
get error() {
|
|
786
|
+
if (!error) {
|
|
787
|
+
error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
788
|
+
issues = void 0;
|
|
789
|
+
ctx = void 0;
|
|
790
|
+
}
|
|
791
|
+
return error;
|
|
792
|
+
},
|
|
793
|
+
set error(e) {
|
|
794
|
+
error = e;
|
|
795
|
+
issues = void 0;
|
|
796
|
+
ctx = void 0;
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
801
|
+
const ctx = _ctx ? {
|
|
802
|
+
..._ctx,
|
|
803
|
+
async: true
|
|
804
|
+
} : { async: true };
|
|
805
|
+
let result = schema._zod.run({
|
|
806
|
+
value,
|
|
807
|
+
issues: []
|
|
808
|
+
}, ctx);
|
|
809
|
+
if (result instanceof Promise) result = await result;
|
|
810
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : {
|
|
811
|
+
success: true,
|
|
812
|
+
data: result.value
|
|
813
|
+
};
|
|
814
|
+
};
|
|
815
|
+
const COMPILE_INVALID = Symbol.for("zod.compile.invalid");
|
|
816
|
+
const COMPILE_FALLBACK = Symbol.for("zod.compile.fallback");
|
|
817
|
+
const validate = ((schema, value, _ctx) => {
|
|
818
|
+
const validator = schema._zod.bag.validator;
|
|
819
|
+
if (validator !== void 0) {
|
|
820
|
+
if (validator(value) !== COMPILE_INVALID) return true;
|
|
821
|
+
if (validator.definite === true && _ctx === void 0) return false;
|
|
822
|
+
}
|
|
823
|
+
return validateFallback(schema, value, _ctx);
|
|
824
|
+
});
|
|
825
|
+
function validateFallback(schema, value, _ctx) {
|
|
826
|
+
const ctx = _ctx ? {
|
|
827
|
+
..._ctx,
|
|
828
|
+
async: false,
|
|
829
|
+
abortEarly: true
|
|
830
|
+
} : {
|
|
831
|
+
async: false,
|
|
832
|
+
abortEarly: true
|
|
833
|
+
};
|
|
834
|
+
const fallbackRun = schema._zod.bag.fallbackRun;
|
|
835
|
+
let result;
|
|
836
|
+
if (fallbackRun) {
|
|
837
|
+
ctx[COMPILE_FALLBACK] = true;
|
|
838
|
+
result = fallbackRun({
|
|
839
|
+
value,
|
|
840
|
+
issues: []
|
|
841
|
+
}, ctx);
|
|
842
|
+
} else result = schema._zod.run({
|
|
843
|
+
value,
|
|
844
|
+
issues: []
|
|
845
|
+
}, ctx);
|
|
846
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
847
|
+
return result.issues.length === 0;
|
|
848
|
+
}
|
|
849
|
+
const validateAsync$1 = async (schema, value, _ctx) => {
|
|
850
|
+
const ctx = _ctx ? {
|
|
851
|
+
..._ctx,
|
|
852
|
+
async: true,
|
|
853
|
+
abortEarly: true
|
|
854
|
+
} : {
|
|
855
|
+
async: true,
|
|
856
|
+
abortEarly: true
|
|
857
|
+
};
|
|
858
|
+
let result = schema._zod.run({
|
|
859
|
+
value,
|
|
860
|
+
issues: []
|
|
861
|
+
}, ctx);
|
|
862
|
+
if (result instanceof Promise) result = await result;
|
|
863
|
+
return result.issues.length === 0;
|
|
864
|
+
};
|
|
865
|
+
const _encode = (_Err) => {
|
|
866
|
+
const parse = _parse(_Err);
|
|
867
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
868
|
+
const ctx = _ctx ? {
|
|
869
|
+
..._ctx,
|
|
870
|
+
direction: "backward"
|
|
871
|
+
} : { direction: "backward" };
|
|
872
|
+
return parse(schema, value, ctx, finalizeParams(fn, _params));
|
|
873
|
+
};
|
|
874
|
+
return fn;
|
|
875
|
+
};
|
|
876
|
+
const _decode = (_Err) => {
|
|
877
|
+
const parse = _parse(_Err);
|
|
878
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
879
|
+
return parse(schema, value, _ctx, finalizeParams(fn, _params));
|
|
880
|
+
};
|
|
881
|
+
return fn;
|
|
882
|
+
};
|
|
883
|
+
const _encodeAsync = (_Err) => {
|
|
884
|
+
const parseAsync = _parseAsync(_Err);
|
|
885
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
886
|
+
const ctx = _ctx ? {
|
|
887
|
+
..._ctx,
|
|
888
|
+
direction: "backward"
|
|
889
|
+
} : { direction: "backward" };
|
|
890
|
+
return await parseAsync(schema, value, ctx, finalizeParams(fn, _params));
|
|
891
|
+
};
|
|
892
|
+
return fn;
|
|
893
|
+
};
|
|
894
|
+
const _decodeAsync = (_Err) => {
|
|
895
|
+
const parseAsync = _parseAsync(_Err);
|
|
896
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
897
|
+
return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
|
|
898
|
+
};
|
|
899
|
+
return fn;
|
|
900
|
+
};
|
|
901
|
+
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
902
|
+
const ctx = _ctx ? {
|
|
903
|
+
..._ctx,
|
|
904
|
+
direction: "backward"
|
|
905
|
+
} : { direction: "backward" };
|
|
906
|
+
return _safeParse(_Err)(schema, value, ctx);
|
|
907
|
+
};
|
|
908
|
+
const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
909
|
+
return _safeParse(_Err)(schema, value, _ctx);
|
|
910
|
+
};
|
|
911
|
+
const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
912
|
+
const ctx = _ctx ? {
|
|
913
|
+
..._ctx,
|
|
914
|
+
direction: "backward"
|
|
915
|
+
} : { direction: "backward" };
|
|
916
|
+
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
917
|
+
};
|
|
918
|
+
const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
919
|
+
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
920
|
+
};
|
|
921
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/regexes.js
|
|
922
|
+
const cuid = /^[cC][0-9a-z]{6,}$/;
|
|
923
|
+
const cuid2 = /^[0-9a-z]+$/;
|
|
924
|
+
const ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
|
|
925
|
+
const xid = /^[0-9a-vA-V]{20}$/;
|
|
926
|
+
const ksuid = /^[A-Za-z0-9]{27}$/;
|
|
927
|
+
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
928
|
+
function nanoidOfLength(length) {
|
|
929
|
+
return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
|
|
930
|
+
}
|
|
931
|
+
const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
932
|
+
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
933
|
+
const uuid = (version) => {
|
|
934
|
+
if (!version) 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)$/;
|
|
935
|
+
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})$`);
|
|
936
|
+
};
|
|
937
|
+
const 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,}$/;
|
|
938
|
+
const _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
939
|
+
function emoji() {
|
|
940
|
+
return new RegExp(_emoji$1, "u");
|
|
941
|
+
}
|
|
942
|
+
const 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])$/;
|
|
943
|
+
const 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}|:))$/;
|
|
944
|
+
const 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])$/;
|
|
945
|
+
const 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])$/;
|
|
946
|
+
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
947
|
+
const base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
|
|
948
|
+
const httpProtocol = /^https?$/;
|
|
949
|
+
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
950
|
+
const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
951
|
+
function anchor(source) {
|
|
952
|
+
return new RegExp(`^${source}$`);
|
|
953
|
+
}
|
|
954
|
+
const date = anchor(dateSource);
|
|
955
|
+
function timeSource(args) {
|
|
956
|
+
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
957
|
+
return 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+)?)?`;
|
|
958
|
+
}
|
|
959
|
+
function time(args) {
|
|
960
|
+
return new RegExp(`^${timeSource(args)}$`);
|
|
961
|
+
}
|
|
962
|
+
function datetime(args) {
|
|
963
|
+
const opts = ["Z"];
|
|
964
|
+
if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
965
|
+
const qualified = `${timeSource({
|
|
966
|
+
precision: args.precision,
|
|
967
|
+
seconds: true
|
|
968
|
+
})}(?:${opts.join("|")})`;
|
|
969
|
+
const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
|
|
970
|
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
971
|
+
}
|
|
972
|
+
const anyString = /^[\s\S]{0,}$/;
|
|
973
|
+
const number$1 = /^-?\d+(?:\.\d+)?$/;
|
|
974
|
+
const boolean$1 = /^(?:true|false)$/i;
|
|
975
|
+
const lowercase = /^[^A-Z]*$/;
|
|
976
|
+
const uppercase = /^[^a-z]*$/;
|
|
977
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/checks.js
|
|
978
|
+
const $ZodCheck = $constructor("$ZodCheck", (inst, def) => {
|
|
979
|
+
var _a;
|
|
980
|
+
inst._zod ?? (inst._zod = {});
|
|
981
|
+
inst._zod.def = def;
|
|
982
|
+
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
983
|
+
});
|
|
984
|
+
const _whenHasLength = (payload) => {
|
|
985
|
+
const val = payload.value;
|
|
986
|
+
return !nullish(val) && val.length !== void 0;
|
|
987
|
+
};
|
|
988
|
+
const numericOriginMap = {
|
|
989
|
+
number: "number",
|
|
990
|
+
bigint: "bigint",
|
|
991
|
+
object: "date"
|
|
992
|
+
};
|
|
993
|
+
const $ZodCheckLessThan = $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
994
|
+
$ZodCheck.init(inst, def);
|
|
995
|
+
const origin = numericOriginMap[typeof def.value];
|
|
996
|
+
inst._zod.check = (payload) => {
|
|
997
|
+
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
|
|
998
|
+
payload.issues.push({
|
|
999
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
1000
|
+
code: "too_big",
|
|
1001
|
+
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
1002
|
+
input: payload.value,
|
|
1003
|
+
inclusive: def.inclusive,
|
|
1004
|
+
inst,
|
|
1005
|
+
continue: !def.abort
|
|
1006
|
+
});
|
|
1007
|
+
};
|
|
1008
|
+
});
|
|
1009
|
+
const $ZodCheckGreaterThan = $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
1010
|
+
$ZodCheck.init(inst, def);
|
|
1011
|
+
const origin = numericOriginMap[typeof def.value];
|
|
1012
|
+
inst._zod.check = (payload) => {
|
|
1013
|
+
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
|
|
1014
|
+
payload.issues.push({
|
|
1015
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
1016
|
+
code: "too_small",
|
|
1017
|
+
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
1018
|
+
input: payload.value,
|
|
1019
|
+
inclusive: def.inclusive,
|
|
1020
|
+
inst,
|
|
1021
|
+
continue: !def.abort
|
|
1022
|
+
});
|
|
1023
|
+
};
|
|
1024
|
+
});
|
|
1025
|
+
const $ZodCheckMultipleOf = $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
1026
|
+
$ZodCheck.init(inst, def);
|
|
1027
|
+
inst._zod.check = (payload) => {
|
|
1028
|
+
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
1029
|
+
if (typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
|
|
1030
|
+
payload.issues.push({
|
|
1031
|
+
origin: typeof payload.value,
|
|
1032
|
+
code: "not_multiple_of",
|
|
1033
|
+
divisor: def.value,
|
|
1034
|
+
input: payload.value,
|
|
1035
|
+
inst,
|
|
1036
|
+
continue: !def.abort
|
|
1037
|
+
});
|
|
1038
|
+
};
|
|
1039
|
+
});
|
|
1040
|
+
const $ZodCheckNumberFormat = $constructor("$ZodCheckNumberFormat", (inst, def) => {
|
|
1041
|
+
$ZodCheck.init(inst, def);
|
|
1042
|
+
def.format = def.format || "float64";
|
|
1043
|
+
const isInt = def.format?.includes("int");
|
|
1044
|
+
const origin = isInt ? "int" : "number";
|
|
1045
|
+
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
1046
|
+
inst._zod.check = (payload) => {
|
|
1047
|
+
const input = payload.value;
|
|
1048
|
+
if (isInt) {
|
|
1049
|
+
if (!Number.isInteger(input)) {
|
|
1050
|
+
payload.issues.push({
|
|
1051
|
+
expected: origin,
|
|
1052
|
+
format: def.format,
|
|
1053
|
+
code: "invalid_type",
|
|
1054
|
+
continue: false,
|
|
1055
|
+
input,
|
|
1056
|
+
inst
|
|
1057
|
+
});
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
if (!Number.isSafeInteger(input)) {
|
|
1061
|
+
if (input > 0) payload.issues.push({
|
|
1062
|
+
input,
|
|
1063
|
+
code: "too_big",
|
|
1064
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
1065
|
+
note: "Integers must be within the safe integer range.",
|
|
1066
|
+
inst,
|
|
1067
|
+
origin,
|
|
1068
|
+
inclusive: true,
|
|
1069
|
+
continue: !def.abort
|
|
1070
|
+
});
|
|
1071
|
+
else payload.issues.push({
|
|
1072
|
+
input,
|
|
1073
|
+
code: "too_small",
|
|
1074
|
+
minimum: Number.MIN_SAFE_INTEGER,
|
|
1075
|
+
note: "Integers must be within the safe integer range.",
|
|
1076
|
+
inst,
|
|
1077
|
+
origin,
|
|
1078
|
+
inclusive: true,
|
|
1079
|
+
continue: !def.abort
|
|
1080
|
+
});
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
if (input < minimum) payload.issues.push({
|
|
1085
|
+
origin: "number",
|
|
1086
|
+
input,
|
|
1087
|
+
code: "too_small",
|
|
1088
|
+
minimum,
|
|
1089
|
+
inclusive: true,
|
|
1090
|
+
inst,
|
|
1091
|
+
continue: !def.abort
|
|
1092
|
+
});
|
|
1093
|
+
if (input > maximum) payload.issues.push({
|
|
1094
|
+
origin: "number",
|
|
1095
|
+
input,
|
|
1096
|
+
code: "too_big",
|
|
1097
|
+
maximum,
|
|
1098
|
+
inclusive: true,
|
|
1099
|
+
inst,
|
|
1100
|
+
continue: !def.abort
|
|
1101
|
+
});
|
|
1102
|
+
};
|
|
1103
|
+
});
|
|
1104
|
+
const $ZodCheckMaxLength = $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
1105
|
+
var _a;
|
|
1106
|
+
$ZodCheck.init(inst, def);
|
|
1107
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
1108
|
+
inst._zod.check = (payload) => {
|
|
1109
|
+
const input = payload.value;
|
|
1110
|
+
const units = input.length;
|
|
1111
|
+
if ((typeof input === "string" && units > def.maximum ? codePointLength(input) : units) <= def.maximum) return;
|
|
1112
|
+
const origin = getLengthableOrigin(input);
|
|
1113
|
+
payload.issues.push({
|
|
1114
|
+
origin,
|
|
1115
|
+
code: "too_big",
|
|
1116
|
+
maximum: def.maximum,
|
|
1117
|
+
inclusive: true,
|
|
1118
|
+
input,
|
|
1119
|
+
inst,
|
|
1120
|
+
continue: !def.abort
|
|
1121
|
+
});
|
|
1122
|
+
};
|
|
1123
|
+
});
|
|
1124
|
+
const $ZodCheckMinLength = $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
1125
|
+
var _a;
|
|
1126
|
+
$ZodCheck.init(inst, def);
|
|
1127
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
1128
|
+
inst._zod.check = (payload) => {
|
|
1129
|
+
const input = payload.value;
|
|
1130
|
+
const units = input.length;
|
|
1131
|
+
if ((typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units) >= def.minimum) return;
|
|
1132
|
+
const origin = getLengthableOrigin(input);
|
|
1133
|
+
payload.issues.push({
|
|
1134
|
+
origin,
|
|
1135
|
+
code: "too_small",
|
|
1136
|
+
minimum: def.minimum,
|
|
1137
|
+
inclusive: true,
|
|
1138
|
+
input,
|
|
1139
|
+
inst,
|
|
1140
|
+
continue: !def.abort
|
|
1141
|
+
});
|
|
1142
|
+
};
|
|
1143
|
+
});
|
|
1144
|
+
const $ZodCheckLengthEquals = $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
1145
|
+
var _a;
|
|
1146
|
+
$ZodCheck.init(inst, def);
|
|
1147
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
1148
|
+
inst._zod.check = (payload) => {
|
|
1149
|
+
const input = payload.value;
|
|
1150
|
+
const units = input.length;
|
|
1151
|
+
const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
|
|
1152
|
+
if (length === def.length) return;
|
|
1153
|
+
const origin = getLengthableOrigin(input);
|
|
1154
|
+
const tooBig = length > def.length;
|
|
1155
|
+
payload.issues.push({
|
|
1156
|
+
origin,
|
|
1157
|
+
...tooBig ? {
|
|
1158
|
+
code: "too_big",
|
|
1159
|
+
maximum: def.length
|
|
1160
|
+
} : {
|
|
1161
|
+
code: "too_small",
|
|
1162
|
+
minimum: def.length
|
|
1163
|
+
},
|
|
1164
|
+
inclusive: true,
|
|
1165
|
+
exact: true,
|
|
1166
|
+
input: payload.value,
|
|
1167
|
+
inst,
|
|
1168
|
+
continue: !def.abort
|
|
1169
|
+
});
|
|
1170
|
+
};
|
|
1171
|
+
});
|
|
1172
|
+
const $ZodCheckStringFormat = $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
1173
|
+
var _a, _b;
|
|
1174
|
+
$ZodCheck.init(inst, def);
|
|
1175
|
+
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
1176
|
+
def.pattern.lastIndex = 0;
|
|
1177
|
+
if (def.pattern.test(payload.value)) return;
|
|
1178
|
+
payload.issues.push({
|
|
1179
|
+
origin: "string",
|
|
1180
|
+
code: "invalid_format",
|
|
1181
|
+
format: def.format,
|
|
1182
|
+
input: payload.value,
|
|
1183
|
+
...def.pattern ? { pattern: def.pattern.toString() } : {},
|
|
1184
|
+
inst,
|
|
1185
|
+
continue: !def.abort
|
|
1186
|
+
});
|
|
1187
|
+
});
|
|
1188
|
+
else (_b = inst._zod).check ?? (_b.check = () => {});
|
|
1189
|
+
});
|
|
1190
|
+
const $ZodCheckRegex = $constructor("$ZodCheckRegex", (inst, def) => {
|
|
1191
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1192
|
+
inst._zod.check = (payload) => {
|
|
1193
|
+
def.pattern.lastIndex = 0;
|
|
1194
|
+
if (def.pattern.test(payload.value)) return;
|
|
1195
|
+
payload.issues.push({
|
|
1196
|
+
origin: "string",
|
|
1197
|
+
code: "invalid_format",
|
|
1198
|
+
format: "regex",
|
|
1199
|
+
input: payload.value,
|
|
1200
|
+
pattern: def.pattern.toString(),
|
|
1201
|
+
inst,
|
|
1202
|
+
continue: !def.abort
|
|
1203
|
+
});
|
|
1204
|
+
};
|
|
1205
|
+
});
|
|
1206
|
+
const $ZodCheckLowerCase = $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
1207
|
+
def.pattern ?? (def.pattern = lowercase);
|
|
1208
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1209
|
+
});
|
|
1210
|
+
const $ZodCheckUpperCase = $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
1211
|
+
def.pattern ?? (def.pattern = uppercase);
|
|
1212
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1213
|
+
});
|
|
1214
|
+
const $ZodCheckIncludes = $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
1215
|
+
$ZodCheck.init(inst, def);
|
|
1216
|
+
const escapedRegex = escapeRegex(def.includes);
|
|
1217
|
+
def.pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
|
|
1218
|
+
inst._zod.check = (payload) => {
|
|
1219
|
+
if (payload.value.includes(def.includes, def.position)) return;
|
|
1220
|
+
payload.issues.push({
|
|
1221
|
+
origin: "string",
|
|
1222
|
+
code: "invalid_format",
|
|
1223
|
+
format: "includes",
|
|
1224
|
+
includes: def.includes,
|
|
1225
|
+
input: payload.value,
|
|
1226
|
+
inst,
|
|
1227
|
+
continue: !def.abort
|
|
1228
|
+
});
|
|
1229
|
+
};
|
|
1230
|
+
});
|
|
1231
|
+
const $ZodCheckStartsWith = $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
1232
|
+
$ZodCheck.init(inst, def);
|
|
1233
|
+
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
1234
|
+
def.pattern ?? (def.pattern = pattern);
|
|
1235
|
+
inst._zod.check = (payload) => {
|
|
1236
|
+
if (payload.value.startsWith(def.prefix)) return;
|
|
1237
|
+
payload.issues.push({
|
|
1238
|
+
origin: "string",
|
|
1239
|
+
code: "invalid_format",
|
|
1240
|
+
format: "starts_with",
|
|
1241
|
+
prefix: def.prefix,
|
|
1242
|
+
input: payload.value,
|
|
1243
|
+
inst,
|
|
1244
|
+
continue: !def.abort
|
|
1245
|
+
});
|
|
1246
|
+
};
|
|
1247
|
+
});
|
|
1248
|
+
const $ZodCheckEndsWith = $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
1249
|
+
$ZodCheck.init(inst, def);
|
|
1250
|
+
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
1251
|
+
def.pattern ?? (def.pattern = pattern);
|
|
1252
|
+
inst._zod.check = (payload) => {
|
|
1253
|
+
if (payload.value.endsWith(def.suffix)) return;
|
|
1254
|
+
payload.issues.push({
|
|
1255
|
+
origin: "string",
|
|
1256
|
+
code: "invalid_format",
|
|
1257
|
+
format: "ends_with",
|
|
1258
|
+
suffix: def.suffix,
|
|
1259
|
+
input: payload.value,
|
|
1260
|
+
inst,
|
|
1261
|
+
continue: !def.abort
|
|
1262
|
+
});
|
|
1263
|
+
};
|
|
1264
|
+
});
|
|
1265
|
+
const $ZodCheckOverwrite = $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
1266
|
+
$ZodCheck.init(inst, def);
|
|
1267
|
+
inst._zod.check = (payload) => {
|
|
1268
|
+
payload.value = def.tx(payload.value);
|
|
1269
|
+
};
|
|
1270
|
+
});
|
|
1271
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/doc.js
|
|
1272
|
+
var Doc = class {
|
|
1273
|
+
constructor(args = [], closed = {}) {
|
|
1274
|
+
this.content = [];
|
|
1275
|
+
this.indent = 0;
|
|
1276
|
+
this.args = args;
|
|
1277
|
+
this.closed = closed;
|
|
1278
|
+
}
|
|
1279
|
+
indented(fn) {
|
|
1280
|
+
this.indent += 1;
|
|
1281
|
+
try {
|
|
1282
|
+
fn(this);
|
|
1283
|
+
} finally {
|
|
1284
|
+
this.indent -= 1;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
write(arg) {
|
|
1288
|
+
if (typeof arg === "function") {
|
|
1289
|
+
arg(this, { execution: "sync" });
|
|
1290
|
+
arg(this, { execution: "async" });
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
const lines = arg.split("\n").filter((x) => x);
|
|
1294
|
+
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
|
|
1295
|
+
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
|
|
1296
|
+
for (const line of dedented) this.content.push(line);
|
|
1297
|
+
}
|
|
1298
|
+
compile() {
|
|
1299
|
+
const F = Function;
|
|
1300
|
+
const content = this?.content ?? [``];
|
|
1301
|
+
return new F(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${content.join("\n")}\n};`)(...Object.values(this.closed));
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/versions.js
|
|
1305
|
+
const version = {
|
|
1306
|
+
major: 4,
|
|
1307
|
+
minor: 6,
|
|
1308
|
+
patch: 7
|
|
1309
|
+
};
|
|
1310
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/schemas.js
|
|
1311
|
+
const $ZodType = $constructor("$ZodType", (inst, def) => {
|
|
1312
|
+
var _a;
|
|
1313
|
+
inst ?? (inst = {});
|
|
1314
|
+
inst._zod.def = def;
|
|
1315
|
+
inst._zod.bag = inst._zod.bag || {};
|
|
1316
|
+
inst._zod.version = version;
|
|
1317
|
+
const defChecks = inst._zod.def.checks;
|
|
1318
|
+
const checks = inst._zod.traits.has("$ZodCheck") ? [inst, ...defChecks ?? []] : defChecks?.length ? [...defChecks] : [];
|
|
1319
|
+
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
|
|
1320
|
+
if (checks.length === 0) {
|
|
1321
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
1322
|
+
inst._zod.deferred?.push(() => {
|
|
1323
|
+
inst._zod.run = inst._zod.parse;
|
|
1324
|
+
});
|
|
1325
|
+
} else {
|
|
1326
|
+
const runChecks = (payload, checks, ctx) => {
|
|
1327
|
+
if (payload.memo) return payload;
|
|
1328
|
+
let isAborted = aborted(payload);
|
|
1329
|
+
let asyncResult;
|
|
1330
|
+
for (const ch of checks) {
|
|
1331
|
+
if (ch._zod.def.when) {
|
|
1332
|
+
if (explicitlyAborted(payload)) continue;
|
|
1333
|
+
if (!ch._zod.def.when(payload)) continue;
|
|
1334
|
+
} else if (isAborted) continue;
|
|
1335
|
+
const currLen = payload.issues.length;
|
|
1336
|
+
const _ = ch._zod.check(payload);
|
|
1337
|
+
if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
|
|
1338
|
+
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
1339
|
+
await _;
|
|
1340
|
+
if (payload.issues.length === currLen) return;
|
|
1341
|
+
attachSchema(payload.issues, currLen, inst);
|
|
1342
|
+
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1343
|
+
});
|
|
1344
|
+
else {
|
|
1345
|
+
if (payload.issues.length === currLen) continue;
|
|
1346
|
+
attachSchema(payload.issues, currLen, inst);
|
|
1347
|
+
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
if (asyncResult) return asyncResult.then(() => {
|
|
1351
|
+
return payload;
|
|
1352
|
+
});
|
|
1353
|
+
return payload;
|
|
1354
|
+
};
|
|
1355
|
+
const handleCanaryResult = (canary, payload, ctx) => {
|
|
1356
|
+
if (aborted(canary)) {
|
|
1357
|
+
canary.aborted = true;
|
|
1358
|
+
return canary;
|
|
1359
|
+
}
|
|
1360
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
1361
|
+
if (checkResult instanceof Promise) {
|
|
1362
|
+
if (ctx.async === false) throw new $ZodAsyncError();
|
|
1363
|
+
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
|
1364
|
+
}
|
|
1365
|
+
return inst._zod.parse(checkResult, ctx);
|
|
1366
|
+
};
|
|
1367
|
+
inst._zod.run = (payload, ctx) => {
|
|
1368
|
+
if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
|
|
1369
|
+
if (ctx.direction === "backward") {
|
|
1370
|
+
const canary = inst._zod.parse({
|
|
1371
|
+
value: payload.value,
|
|
1372
|
+
issues: []
|
|
1373
|
+
}, {
|
|
1374
|
+
...ctx,
|
|
1375
|
+
skipChecks: true
|
|
1376
|
+
});
|
|
1377
|
+
if (canary instanceof Promise) return canary.then((canary) => {
|
|
1378
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
1379
|
+
});
|
|
1380
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
1381
|
+
}
|
|
1382
|
+
const result = inst._zod.parse(payload, ctx);
|
|
1383
|
+
if (result instanceof Promise) {
|
|
1384
|
+
if (ctx.async === false) throw new $ZodAsyncError();
|
|
1385
|
+
return result.then((result) => runChecks(result, checks, ctx));
|
|
1386
|
+
}
|
|
1387
|
+
return runChecks(result, checks, ctx);
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
}, {
|
|
1391
|
+
get "~standard"() {
|
|
1392
|
+
return hide(this, "~standard", standardProps(this));
|
|
1393
|
+
},
|
|
1394
|
+
set "~standard"(value) {
|
|
1395
|
+
own(this, "~standard", value);
|
|
1396
|
+
}
|
|
1397
|
+
});
|
|
1398
|
+
const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
|
|
1399
|
+
async function validateAsync(inst, value) {
|
|
1400
|
+
const ctx = { async: true };
|
|
1401
|
+
return toStandardResult(await inst._zod.run({
|
|
1402
|
+
value,
|
|
1403
|
+
issues: []
|
|
1404
|
+
}, ctx), ctx);
|
|
1405
|
+
}
|
|
1406
|
+
function standardProps(inst) {
|
|
1407
|
+
return {
|
|
1408
|
+
validate: (value) => {
|
|
1409
|
+
const ctx = { async: false };
|
|
1410
|
+
try {
|
|
1411
|
+
const r = inst._zod.run({
|
|
1412
|
+
value,
|
|
1413
|
+
issues: []
|
|
1414
|
+
}, ctx);
|
|
1415
|
+
if (!(r instanceof Promise)) return toStandardResult(r, ctx);
|
|
1416
|
+
} catch (_) {}
|
|
1417
|
+
return validateAsync(inst, value);
|
|
1418
|
+
},
|
|
1419
|
+
vendor: "zod",
|
|
1420
|
+
version: 1
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
const $ZodString = $constructor("$ZodString", (inst, def) => {
|
|
1424
|
+
$ZodType.init(inst, def);
|
|
1425
|
+
inst._zod.pattern = def.pattern ?? anyString;
|
|
1426
|
+
inst._zod.parse = (payload, _) => {
|
|
1427
|
+
if (def.coerce) try {
|
|
1428
|
+
payload.value = String(payload.value);
|
|
1429
|
+
} catch (_) {}
|
|
1430
|
+
if (typeof payload.value === "string") return payload;
|
|
1431
|
+
payload.issues.push({
|
|
1432
|
+
expected: "string",
|
|
1433
|
+
code: "invalid_type",
|
|
1434
|
+
input: payload.value,
|
|
1435
|
+
inst
|
|
1436
|
+
});
|
|
1437
|
+
return payload;
|
|
1438
|
+
};
|
|
1439
|
+
});
|
|
1440
|
+
const $ZodStringFormat = $constructor("$ZodStringFormat", (inst, def) => {
|
|
1441
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1442
|
+
$ZodString.init(inst, def);
|
|
1443
|
+
});
|
|
1444
|
+
const $ZodGUID = $constructor("$ZodGUID", (inst, def) => {
|
|
1445
|
+
def.pattern ?? (def.pattern = guid);
|
|
1446
|
+
$ZodStringFormat.init(inst, def);
|
|
1447
|
+
});
|
|
1448
|
+
const $ZodUUID = $constructor("$ZodUUID", (inst, def) => {
|
|
1449
|
+
if (def.version) {
|
|
1450
|
+
const v = {
|
|
1451
|
+
v1: 1,
|
|
1452
|
+
v2: 2,
|
|
1453
|
+
v3: 3,
|
|
1454
|
+
v4: 4,
|
|
1455
|
+
v5: 5,
|
|
1456
|
+
v6: 6,
|
|
1457
|
+
v7: 7,
|
|
1458
|
+
v8: 8
|
|
1459
|
+
}[def.version];
|
|
1460
|
+
if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
1461
|
+
def.pattern ?? (def.pattern = uuid(v));
|
|
1462
|
+
} else def.pattern ?? (def.pattern = uuid());
|
|
1463
|
+
$ZodStringFormat.init(inst, def);
|
|
1464
|
+
});
|
|
1465
|
+
const $ZodEmail = $constructor("$ZodEmail", (inst, def) => {
|
|
1466
|
+
def.pattern ?? (def.pattern = email);
|
|
1467
|
+
$ZodStringFormat.init(inst, def);
|
|
1468
|
+
});
|
|
1469
|
+
function canParseURL(input) {
|
|
1470
|
+
try {
|
|
1471
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(input);
|
|
1472
|
+
new URL(input);
|
|
1473
|
+
return true;
|
|
1474
|
+
} catch {
|
|
1475
|
+
return false;
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
function validateURL(trimmed, def) {
|
|
1479
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) return canParseURL(trimmed) || 2;
|
|
1480
|
+
return parseURLObject(trimmed, def);
|
|
1481
|
+
}
|
|
1482
|
+
function parseURLObject(trimmed, def) {
|
|
1483
|
+
if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) return 1;
|
|
1484
|
+
try {
|
|
1485
|
+
if (typeof URL !== "undefined") {
|
|
1486
|
+
const URLStatic = URL;
|
|
1487
|
+
if (typeof URLStatic.parse === "function") return URLStatic.parse(trimmed) ?? 2;
|
|
1488
|
+
}
|
|
1489
|
+
return new URL(trimmed);
|
|
1490
|
+
} catch {
|
|
1491
|
+
return 2;
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
const asciiTabOrNewline = /[\t\n\r]/g;
|
|
1495
|
+
function stripTabAndNewline(value) {
|
|
1496
|
+
return value.replace(asciiTabOrNewline, "");
|
|
1497
|
+
}
|
|
1498
|
+
function urlHostnameOk(url, hostname) {
|
|
1499
|
+
hostname.lastIndex = 0;
|
|
1500
|
+
return hostname.test(url.hostname);
|
|
1501
|
+
}
|
|
1502
|
+
function urlProtocolOk(url, protocol) {
|
|
1503
|
+
protocol.lastIndex = 0;
|
|
1504
|
+
return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
|
|
1505
|
+
}
|
|
1506
|
+
const $ZodURL = $constructor("$ZodURL", (inst, def) => {
|
|
1507
|
+
$ZodStringFormat.init(inst, def);
|
|
1508
|
+
inst._zod.check = (payload) => {
|
|
1509
|
+
try {
|
|
1510
|
+
const trimmed = payload.value.trim();
|
|
1511
|
+
const url = validateURL(trimmed, def);
|
|
1512
|
+
if (url === 1) {
|
|
1513
|
+
payload.issues.push({
|
|
1514
|
+
code: "invalid_format",
|
|
1515
|
+
format: "url",
|
|
1516
|
+
note: "Invalid URL format",
|
|
1517
|
+
input: payload.value,
|
|
1518
|
+
inst,
|
|
1519
|
+
continue: !def.abort
|
|
1520
|
+
});
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
if (url === 2) {
|
|
1524
|
+
payload.issues.push({
|
|
1525
|
+
code: "invalid_format",
|
|
1526
|
+
format: "url",
|
|
1527
|
+
input: payload.value,
|
|
1528
|
+
inst,
|
|
1529
|
+
continue: !def.abort
|
|
1530
|
+
});
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
if (url === true) {
|
|
1534
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
if (def.hostname && !urlHostnameOk(url, def.hostname)) payload.issues.push({
|
|
1538
|
+
code: "invalid_format",
|
|
1539
|
+
format: "url",
|
|
1540
|
+
note: "Invalid hostname",
|
|
1541
|
+
pattern: def.hostname.source,
|
|
1542
|
+
input: payload.value,
|
|
1543
|
+
inst,
|
|
1544
|
+
continue: !def.abort
|
|
1545
|
+
});
|
|
1546
|
+
if (def.protocol && !urlProtocolOk(url, def.protocol)) payload.issues.push({
|
|
1547
|
+
code: "invalid_format",
|
|
1548
|
+
format: "url",
|
|
1549
|
+
note: "Invalid protocol",
|
|
1550
|
+
pattern: def.protocol.source,
|
|
1551
|
+
input: payload.value,
|
|
1552
|
+
inst,
|
|
1553
|
+
continue: !def.abort
|
|
1554
|
+
});
|
|
1555
|
+
payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
|
|
1556
|
+
return;
|
|
1557
|
+
} catch (_) {
|
|
1558
|
+
payload.issues.push({
|
|
1559
|
+
code: "invalid_format",
|
|
1560
|
+
format: "url",
|
|
1561
|
+
input: payload.value,
|
|
1562
|
+
inst,
|
|
1563
|
+
continue: !def.abort
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
};
|
|
1567
|
+
});
|
|
1568
|
+
const $ZodEmoji = $constructor("$ZodEmoji", (inst, def) => {
|
|
1569
|
+
def.pattern ?? (def.pattern = emoji());
|
|
1570
|
+
$ZodStringFormat.init(inst, def);
|
|
1571
|
+
});
|
|
1572
|
+
const $ZodNanoID = $constructor("$ZodNanoID", (inst, def) => {
|
|
1573
|
+
if (def.length !== void 0 && (!Number.isInteger(def.length) || def.length < 1)) throw new Error(`Invalid nanoid length: ${def.length}`);
|
|
1574
|
+
def.pattern ?? (def.pattern = def.length === void 0 ? nanoid : nanoidOfLength(def.length));
|
|
1575
|
+
$ZodStringFormat.init(inst, def);
|
|
1576
|
+
});
|
|
1577
|
+
const $ZodCUID = $constructor("$ZodCUID", (inst, def) => {
|
|
1578
|
+
def.pattern ?? (def.pattern = cuid);
|
|
1579
|
+
$ZodStringFormat.init(inst, def);
|
|
1580
|
+
});
|
|
1581
|
+
const $ZodCUID2 = $constructor("$ZodCUID2", (inst, def) => {
|
|
1582
|
+
def.pattern ?? (def.pattern = cuid2);
|
|
1583
|
+
$ZodStringFormat.init(inst, def);
|
|
1584
|
+
});
|
|
1585
|
+
const $ZodULID = $constructor("$ZodULID", (inst, def) => {
|
|
1586
|
+
def.pattern ?? (def.pattern = ulid);
|
|
1587
|
+
$ZodStringFormat.init(inst, def);
|
|
1588
|
+
});
|
|
1589
|
+
const $ZodXID = $constructor("$ZodXID", (inst, def) => {
|
|
1590
|
+
def.pattern ?? (def.pattern = xid);
|
|
1591
|
+
$ZodStringFormat.init(inst, def);
|
|
1592
|
+
});
|
|
1593
|
+
const $ZodKSUID = $constructor("$ZodKSUID", (inst, def) => {
|
|
1594
|
+
def.pattern ?? (def.pattern = ksuid);
|
|
1595
|
+
$ZodStringFormat.init(inst, def);
|
|
1596
|
+
});
|
|
1597
|
+
const $ZodISODateTime = $constructor("$ZodISODateTime", (inst, def) => {
|
|
1598
|
+
def.pattern ?? (def.pattern = datetime(def));
|
|
1599
|
+
$ZodStringFormat.init(inst, def);
|
|
1600
|
+
});
|
|
1601
|
+
const $ZodISODate = $constructor("$ZodISODate", (inst, def) => {
|
|
1602
|
+
def.pattern ?? (def.pattern = date);
|
|
1603
|
+
$ZodStringFormat.init(inst, def);
|
|
1604
|
+
});
|
|
1605
|
+
const $ZodISOTime = $constructor("$ZodISOTime", (inst, def) => {
|
|
1606
|
+
def.pattern ?? (def.pattern = time(def));
|
|
1607
|
+
$ZodStringFormat.init(inst, def);
|
|
1608
|
+
});
|
|
1609
|
+
const $ZodISODuration = $constructor("$ZodISODuration", (inst, def) => {
|
|
1610
|
+
def.pattern ?? (def.pattern = duration);
|
|
1611
|
+
$ZodStringFormat.init(inst, def);
|
|
1612
|
+
});
|
|
1613
|
+
const $ZodIPv4 = $constructor("$ZodIPv4", (inst, def) => {
|
|
1614
|
+
def.pattern ?? (def.pattern = ipv4);
|
|
1615
|
+
$ZodStringFormat.init(inst, def);
|
|
1616
|
+
});
|
|
1617
|
+
const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
1618
|
+
function isValidIPv6(value) {
|
|
1619
|
+
if (!ipv6Alphabet.test(value)) return false;
|
|
1620
|
+
return canParseURL(`http://[${value}]`);
|
|
1621
|
+
}
|
|
1622
|
+
const $ZodIPv6 = $constructor("$ZodIPv6", (inst, def) => {
|
|
1623
|
+
def.pattern ?? (def.pattern = ipv6);
|
|
1624
|
+
$ZodStringFormat.init(inst, def);
|
|
1625
|
+
inst._zod.check = (payload) => {
|
|
1626
|
+
if (!isValidIPv6(payload.value)) payload.issues.push({
|
|
1627
|
+
code: "invalid_format",
|
|
1628
|
+
format: "ipv6",
|
|
1629
|
+
input: payload.value,
|
|
1630
|
+
inst,
|
|
1631
|
+
continue: !def.abort
|
|
1632
|
+
});
|
|
1633
|
+
};
|
|
1634
|
+
});
|
|
1635
|
+
const $ZodCIDRv4 = $constructor("$ZodCIDRv4", (inst, def) => {
|
|
1636
|
+
def.pattern ?? (def.pattern = cidrv4);
|
|
1637
|
+
$ZodStringFormat.init(inst, def);
|
|
1638
|
+
});
|
|
1639
|
+
function isValidCIDRv6(value) {
|
|
1640
|
+
const parts = value.split("/");
|
|
1641
|
+
if (parts.length !== 2) return false;
|
|
1642
|
+
const [address, prefix] = parts;
|
|
1643
|
+
if (!prefix) return false;
|
|
1644
|
+
const prefixNum = Number(prefix);
|
|
1645
|
+
if (`${prefixNum}` !== prefix) return false;
|
|
1646
|
+
if (prefixNum < 0 || prefixNum > 128) return false;
|
|
1647
|
+
return isValidIPv6(address);
|
|
1648
|
+
}
|
|
1649
|
+
const $ZodCIDRv6 = $constructor("$ZodCIDRv6", (inst, def) => {
|
|
1650
|
+
def.pattern ?? (def.pattern = cidrv6);
|
|
1651
|
+
$ZodStringFormat.init(inst, def);
|
|
1652
|
+
inst._zod.check = (payload) => {
|
|
1653
|
+
if (!isValidCIDRv6(payload.value)) payload.issues.push({
|
|
1654
|
+
code: "invalid_format",
|
|
1655
|
+
format: "cidrv6",
|
|
1656
|
+
input: payload.value,
|
|
1657
|
+
inst,
|
|
1658
|
+
continue: !def.abort
|
|
1659
|
+
});
|
|
1660
|
+
};
|
|
1661
|
+
});
|
|
1662
|
+
function isValidBase64(data) {
|
|
1663
|
+
if (data === "") return true;
|
|
1664
|
+
if (/\s/.test(data)) return false;
|
|
1665
|
+
if (data.length % 4 !== 0) return false;
|
|
1666
|
+
try {
|
|
1667
|
+
atob(data);
|
|
1668
|
+
return true;
|
|
1669
|
+
} catch {
|
|
1670
|
+
return false;
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
1674
|
+
const $ZodBase64 = $constructor("$ZodBase64", (inst, def) => {
|
|
1675
|
+
def.pattern ?? (def.pattern = base64Charset);
|
|
1676
|
+
$ZodStringFormat.init(inst, def);
|
|
1677
|
+
inst._zod.check = (payload) => {
|
|
1678
|
+
if (isValidBase64(payload.value)) return;
|
|
1679
|
+
payload.issues.push({
|
|
1680
|
+
code: "invalid_format",
|
|
1681
|
+
format: "base64",
|
|
1682
|
+
input: payload.value,
|
|
1683
|
+
inst,
|
|
1684
|
+
continue: !def.abort
|
|
1685
|
+
});
|
|
1686
|
+
};
|
|
1687
|
+
});
|
|
1688
|
+
const base64urlCharset = /^[A-Za-z0-9_-]*$/;
|
|
1689
|
+
function isValidBase64URL(data) {
|
|
1690
|
+
if (!base64urlCharset.test(data)) return false;
|
|
1691
|
+
const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
1692
|
+
return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
|
|
1693
|
+
}
|
|
1694
|
+
const $ZodBase64URL = $constructor("$ZodBase64URL", (inst, def) => {
|
|
1695
|
+
def.pattern ?? (def.pattern = base64urlCharset);
|
|
1696
|
+
$ZodStringFormat.init(inst, def);
|
|
1697
|
+
inst._zod.check = (payload) => {
|
|
1698
|
+
if (isValidBase64URL(payload.value)) return;
|
|
1699
|
+
payload.issues.push({
|
|
1700
|
+
code: "invalid_format",
|
|
1701
|
+
format: "base64url",
|
|
1702
|
+
input: payload.value,
|
|
1703
|
+
inst,
|
|
1704
|
+
continue: !def.abort
|
|
1705
|
+
});
|
|
1706
|
+
};
|
|
1707
|
+
});
|
|
1708
|
+
const $ZodE164 = $constructor("$ZodE164", (inst, def) => {
|
|
1709
|
+
def.pattern ?? (def.pattern = e164);
|
|
1710
|
+
$ZodStringFormat.init(inst, def);
|
|
1711
|
+
});
|
|
1712
|
+
function isValidJWT(token, algorithm = null) {
|
|
1713
|
+
try {
|
|
1714
|
+
const tokensParts = token.split(".");
|
|
1715
|
+
if (tokensParts.length !== 3) return false;
|
|
1716
|
+
const [header] = tokensParts;
|
|
1717
|
+
if (!header) return false;
|
|
1718
|
+
const parsedHeader = JSON.parse(atob(header));
|
|
1719
|
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
|
|
1720
|
+
if (!parsedHeader.alg) return false;
|
|
1721
|
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
|
|
1722
|
+
return true;
|
|
1723
|
+
} catch {
|
|
1724
|
+
return false;
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
const $ZodJWT = $constructor("$ZodJWT", (inst, def) => {
|
|
1728
|
+
$ZodStringFormat.init(inst, def);
|
|
1729
|
+
inst._zod.check = (payload) => {
|
|
1730
|
+
if (isValidJWT(payload.value, def.alg)) return;
|
|
1731
|
+
payload.issues.push({
|
|
1732
|
+
code: "invalid_format",
|
|
1733
|
+
format: "jwt",
|
|
1734
|
+
input: payload.value,
|
|
1735
|
+
inst,
|
|
1736
|
+
continue: !def.abort
|
|
1737
|
+
});
|
|
1738
|
+
};
|
|
1739
|
+
});
|
|
1740
|
+
const $ZodNumber = $constructor("$ZodNumber", (inst, def) => {
|
|
1741
|
+
$ZodType.init(inst, def);
|
|
1742
|
+
inst._zod.pattern = number$1;
|
|
1743
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1744
|
+
if (def.coerce) try {
|
|
1745
|
+
payload.value = Number(payload.value);
|
|
1746
|
+
} catch (_) {}
|
|
1747
|
+
const input = payload.value;
|
|
1748
|
+
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
|
|
1749
|
+
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? String(input) : void 0 : void 0;
|
|
1750
|
+
payload.issues.push({
|
|
1751
|
+
expected: "number",
|
|
1752
|
+
code: "invalid_type",
|
|
1753
|
+
input,
|
|
1754
|
+
inst,
|
|
1755
|
+
...received ? { received } : {}
|
|
1756
|
+
});
|
|
1757
|
+
return payload;
|
|
1758
|
+
};
|
|
1759
|
+
});
|
|
1760
|
+
const $ZodNumberFormat = $constructor("$ZodNumberFormat", (inst, def) => {
|
|
1761
|
+
$ZodCheckNumberFormat.init(inst, def);
|
|
1762
|
+
$ZodNumber.init(inst, def);
|
|
1763
|
+
});
|
|
1764
|
+
const $ZodBoolean = $constructor("$ZodBoolean", (inst, def) => {
|
|
1765
|
+
$ZodType.init(inst, def);
|
|
1766
|
+
inst._zod.pattern = boolean$1;
|
|
1767
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1768
|
+
if (def.coerce) try {
|
|
1769
|
+
payload.value = Boolean(payload.value);
|
|
1770
|
+
} catch (_) {}
|
|
1771
|
+
const input = payload.value;
|
|
1772
|
+
if (typeof input === "boolean") return payload;
|
|
1773
|
+
payload.issues.push({
|
|
1774
|
+
expected: "boolean",
|
|
1775
|
+
code: "invalid_type",
|
|
1776
|
+
input,
|
|
1777
|
+
inst
|
|
1778
|
+
});
|
|
1779
|
+
return payload;
|
|
1780
|
+
};
|
|
1781
|
+
});
|
|
1782
|
+
const $ZodUnknown = $constructor("$ZodUnknown", (inst, def) => {
|
|
1783
|
+
$ZodType.init(inst, def);
|
|
1784
|
+
inst._zod.parse = (payload) => payload;
|
|
1785
|
+
});
|
|
1786
|
+
const $ZodNever = $constructor("$ZodNever", (inst, def) => {
|
|
1787
|
+
$ZodType.init(inst, def);
|
|
1788
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1789
|
+
payload.issues.push({
|
|
1790
|
+
expected: "never",
|
|
1791
|
+
code: "invalid_type",
|
|
1792
|
+
input: payload.value,
|
|
1793
|
+
inst
|
|
1794
|
+
});
|
|
1795
|
+
return payload;
|
|
1796
|
+
};
|
|
1797
|
+
});
|
|
1798
|
+
function capSize(inst, size) {
|
|
1799
|
+
const caps = sizeCaps(inst._zod.def.checks);
|
|
1800
|
+
if (!caps.length) return;
|
|
1801
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
1802
|
+
const parse = inst._zod.parse;
|
|
1803
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1804
|
+
const n = size(payload.value);
|
|
1805
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
1806
|
+
for (const [max, ch] of sizeCaps(inst._zod.def.checks)) if (n > max && ch._zod.def.when(payload)) {
|
|
1807
|
+
const start = payload.issues.length;
|
|
1808
|
+
ch._zod.check(payload);
|
|
1809
|
+
payload.issues[start].continue = false;
|
|
1810
|
+
attachSchema(payload.issues, start, inst);
|
|
1811
|
+
return payload;
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
return parse(payload, ctx);
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
const arraySize = (input) => Array.isArray(input) ? input.length : -1;
|
|
1818
|
+
function handleArrayResult(result, final, index) {
|
|
1819
|
+
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
1820
|
+
final.value[index] = result.value;
|
|
1821
|
+
}
|
|
1822
|
+
const $ZodArray = $constructor("$ZodArray", (inst, def) => {
|
|
1823
|
+
$ZodType.init(inst, def);
|
|
1824
|
+
const memo = globalConfig.memoizer;
|
|
1825
|
+
memo?.attach(inst);
|
|
1826
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1827
|
+
const input = payload.value;
|
|
1828
|
+
if (!Array.isArray(input)) {
|
|
1829
|
+
payload.issues.push({
|
|
1830
|
+
expected: "array",
|
|
1831
|
+
code: "invalid_type",
|
|
1832
|
+
input,
|
|
1833
|
+
inst
|
|
1834
|
+
});
|
|
1835
|
+
return payload;
|
|
1836
|
+
}
|
|
1837
|
+
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
1838
|
+
const proms = [];
|
|
1839
|
+
const abortEarly = ctx?.abortEarly;
|
|
1840
|
+
for (let i = 0; i < input.length; i++) {
|
|
1841
|
+
const item = input[i];
|
|
1842
|
+
const result = def.element._zod.run({
|
|
1843
|
+
value: item,
|
|
1844
|
+
issues: []
|
|
1845
|
+
}, ctx);
|
|
1846
|
+
if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
1847
|
+
else {
|
|
1848
|
+
handleArrayResult(result, payload, i);
|
|
1849
|
+
if (abortEarly && result.issues.length !== 0 && aborted(result)) break;
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
1853
|
+
return payload;
|
|
1854
|
+
};
|
|
1855
|
+
capSize(inst, arraySize);
|
|
1856
|
+
});
|
|
1857
|
+
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
1858
|
+
const isPresent = key in input;
|
|
1859
|
+
const isOptionalOut = optout === "optional";
|
|
1860
|
+
if (!isPresent && isOptionalOut && optin === "optional") return;
|
|
1861
|
+
if (result.issues.length) {
|
|
1862
|
+
if (optin !== void 0 && isOptionalOut && !isPresent) return;
|
|
1863
|
+
final.issues.push(...prefixIssues(key, result.issues));
|
|
1864
|
+
}
|
|
1865
|
+
if (!isPresent && optin === void 0) {
|
|
1866
|
+
if (!result.issues.length) final.issues.push({
|
|
1867
|
+
code: "invalid_type",
|
|
1868
|
+
expected: "nonoptional",
|
|
1869
|
+
input: void 0,
|
|
1870
|
+
path: [key]
|
|
1871
|
+
});
|
|
1872
|
+
return;
|
|
1873
|
+
}
|
|
1874
|
+
if (result.value === void 0) {
|
|
1875
|
+
if (isPresent || optin === "defaulted" && !isOptionalOut) final.value[key] = void 0;
|
|
1876
|
+
} else final.value[key] = result.value;
|
|
1877
|
+
}
|
|
1878
|
+
const NO_SYMBOL_KEYS = [];
|
|
1879
|
+
function normalizeDef(def) {
|
|
1880
|
+
const keys = Object.keys(def.shape);
|
|
1881
|
+
const ownSymbols = Object.getOwnPropertySymbols(def.shape);
|
|
1882
|
+
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
|
|
1883
|
+
const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
|
|
1884
|
+
for (const k of allKeys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
|
|
1885
|
+
const okeys = optionalKeys(def.shape);
|
|
1886
|
+
return {
|
|
1887
|
+
...def,
|
|
1888
|
+
allKeys,
|
|
1889
|
+
symbolKeys,
|
|
1890
|
+
keySet: new Set(keys),
|
|
1891
|
+
numKeys: keys.length,
|
|
1892
|
+
optionalKeys: new Set(okeys)
|
|
1893
|
+
};
|
|
1894
|
+
}
|
|
1895
|
+
function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
|
|
1896
|
+
const unrecognized = [];
|
|
1897
|
+
const keySet = def.keySet;
|
|
1898
|
+
const _catchall = def.catchall._zod;
|
|
1899
|
+
const t = _catchall.def.type;
|
|
1900
|
+
const optin = _catchall.optin;
|
|
1901
|
+
const optout = _catchall.optout;
|
|
1902
|
+
let seen = 0;
|
|
1903
|
+
for (const key in input) {
|
|
1904
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1905
|
+
if (aborted(payload, seen)) break;
|
|
1906
|
+
seen = payload.issues.length;
|
|
1907
|
+
}
|
|
1908
|
+
if (keySet.has(key)) continue;
|
|
1909
|
+
if (key === "__proto__") {
|
|
1910
|
+
if (t === "never") unrecognized.push(key);
|
|
1911
|
+
continue;
|
|
1912
|
+
}
|
|
1913
|
+
if (t === "never") {
|
|
1914
|
+
unrecognized.push(key);
|
|
1915
|
+
continue;
|
|
1916
|
+
}
|
|
1917
|
+
const r = _catchall.run({
|
|
1918
|
+
value: input[key],
|
|
1919
|
+
issues: []
|
|
1920
|
+
}, ctx);
|
|
1921
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
1922
|
+
else handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1923
|
+
}
|
|
1924
|
+
if (unrecognized.length) payload.issues.push({
|
|
1925
|
+
code: "unrecognized_keys",
|
|
1926
|
+
keys: unrecognized,
|
|
1927
|
+
input,
|
|
1928
|
+
inst,
|
|
1929
|
+
continue: true
|
|
1930
|
+
});
|
|
1931
|
+
if (!proms.length) return payload;
|
|
1932
|
+
return Promise.all(proms).then(() => {
|
|
1933
|
+
return payload;
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
const $ZodObject = $constructor("$ZodObject", (inst, def) => {
|
|
1937
|
+
$ZodType.init(inst, def);
|
|
1938
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
1939
|
+
const sh = desc?.get ? desc.get.raw : def.shape ?? {};
|
|
1940
|
+
if (sh) {
|
|
1941
|
+
const get = () => {
|
|
1942
|
+
const newSh = { ...sh };
|
|
1943
|
+
Object.defineProperty(def, "shape", { value: newSh });
|
|
1944
|
+
get.raw = newSh;
|
|
1945
|
+
return newSh;
|
|
1946
|
+
};
|
|
1947
|
+
get.raw = sh;
|
|
1948
|
+
Object.defineProperty(def, "shape", { get });
|
|
1949
|
+
}
|
|
1950
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
1951
|
+
defineLazyInternal(inst, "propValues", (zod) => {
|
|
1952
|
+
const shape = zod.def.shape;
|
|
1953
|
+
const propValues = {};
|
|
1954
|
+
for (const key in shape) {
|
|
1955
|
+
const field = shape[key]._zod;
|
|
1956
|
+
if (field.values) {
|
|
1957
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, key)) assignProp(propValues, key, new Set());
|
|
1958
|
+
for (const v of field.values) propValues[key].add(v);
|
|
1959
|
+
if (field.optin !== void 0) propValues[key].add(void 0);
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
return propValues;
|
|
1963
|
+
});
|
|
1964
|
+
const isObject$1 = isObject;
|
|
1965
|
+
const catchall = def.catchall;
|
|
1966
|
+
let value;
|
|
1967
|
+
const memo = globalConfig.memoizer;
|
|
1968
|
+
memo?.attach(inst);
|
|
1969
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1970
|
+
value ?? (value = _normalized.value);
|
|
1971
|
+
const input = payload.value;
|
|
1972
|
+
if (!isObject$1(input)) {
|
|
1973
|
+
payload.issues.push({
|
|
1974
|
+
expected: "object",
|
|
1975
|
+
code: "invalid_type",
|
|
1976
|
+
input,
|
|
1977
|
+
inst
|
|
1978
|
+
});
|
|
1979
|
+
return payload;
|
|
1980
|
+
}
|
|
1981
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1982
|
+
const proms = [];
|
|
1983
|
+
const shape = value.shape;
|
|
1984
|
+
const abortEarly = ctx?.abortEarly;
|
|
1985
|
+
let seen = payload.issues.length;
|
|
1986
|
+
for (const key of value.allKeys) {
|
|
1987
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1988
|
+
if (aborted(payload, seen)) break;
|
|
1989
|
+
seen = payload.issues.length;
|
|
1990
|
+
}
|
|
1991
|
+
if (key === "__proto__") continue;
|
|
1992
|
+
const el = shape[key];
|
|
1993
|
+
const optin = el._zod.optin;
|
|
1994
|
+
const optout = el._zod.optout;
|
|
1995
|
+
const r = el._zod.run({
|
|
1996
|
+
value: input[key],
|
|
1997
|
+
issues: []
|
|
1998
|
+
}, ctx);
|
|
1999
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
2000
|
+
else handlePropertyResult(r, payload, key, input, optin, optout);
|
|
2001
|
+
}
|
|
2002
|
+
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
2003
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
|
|
2004
|
+
};
|
|
2005
|
+
});
|
|
2006
|
+
const $ZodObjectJIT = $constructor("$ZodObjectJIT", (inst, def) => {
|
|
2007
|
+
$ZodObject.init(inst, def);
|
|
2008
|
+
const superParse = inst._zod.parse;
|
|
2009
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
2010
|
+
const memo = globalConfig.memoizer;
|
|
2011
|
+
const generateFastpass = (shape) => {
|
|
2012
|
+
const normalized = _normalized.value;
|
|
2013
|
+
const syms = normalized.symbolKeys;
|
|
2014
|
+
const doc = new Doc(["payload", "ctx"], {
|
|
2015
|
+
shape,
|
|
2016
|
+
inst,
|
|
2017
|
+
memo,
|
|
2018
|
+
syms
|
|
2019
|
+
});
|
|
2020
|
+
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
2021
|
+
const prefixStr = (id, k) => `
|
|
2022
|
+
let ${id}_ab = false;
|
|
2023
|
+
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
2024
|
+
const iss = ${id}.issues[i];
|
|
2025
|
+
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
2026
|
+
payload.issues.push(iss);
|
|
2027
|
+
if (iss.continue !== true) ${id}_ab = true;
|
|
2028
|
+
}
|
|
2029
|
+
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
2030
|
+
payload.value = newResult;
|
|
2031
|
+
return payload;
|
|
2032
|
+
}`;
|
|
2033
|
+
doc.write(`const input = payload.value;`);
|
|
2034
|
+
const ids = Object.create(null);
|
|
2035
|
+
let counter = 0;
|
|
2036
|
+
for (const key of normalized.allKeys) ids[key] = `key_${counter++}`;
|
|
2037
|
+
doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
2038
|
+
for (const key of normalized.allKeys) {
|
|
2039
|
+
if (key === "__proto__") continue;
|
|
2040
|
+
const id = ids[key];
|
|
2041
|
+
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
|
|
2042
|
+
const isPresent = `${k} in input`;
|
|
2043
|
+
const schema = shape[key];
|
|
2044
|
+
const optin = schema?._zod?.optin;
|
|
2045
|
+
const isOptionalIn = optin !== void 0;
|
|
2046
|
+
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
2047
|
+
doc.write(`const ${id} = ${parseStr(k)};`);
|
|
2048
|
+
if (isOptionalIn && isOptionalOut) {
|
|
2049
|
+
const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
|
|
2050
|
+
doc.write(`
|
|
2051
|
+
const ${id}_present = ${isPresent};
|
|
2052
|
+
if (!${id}.issues.length || ${id}_present) {
|
|
2053
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2056
|
+
if (${assign}) {
|
|
2057
|
+
newResult[${k}] = ${id}.value;
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
`);
|
|
2062
|
+
} else if (!isOptionalIn) doc.write(`
|
|
2063
|
+
const ${id}_present = ${isPresent};
|
|
2064
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
2065
|
+
}
|
|
2066
|
+
if (!${id}_present && !${id}.issues.length) {
|
|
2067
|
+
payload.issues.push({
|
|
2068
|
+
code: "invalid_type",
|
|
2069
|
+
expected: "nonoptional",
|
|
2070
|
+
input: undefined,
|
|
2071
|
+
path: [${k}]
|
|
2072
|
+
});
|
|
2073
|
+
if (ctx && ctx.abortEarly) {
|
|
2074
|
+
payload.value = newResult;
|
|
2075
|
+
return payload;
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
if (${id}_present) {
|
|
2080
|
+
newResult[${k}] = ${id}.value;
|
|
2081
|
+
}
|
|
2082
|
+
|
|
2083
|
+
`);
|
|
2084
|
+
else {
|
|
2085
|
+
doc.write(`
|
|
2086
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
2087
|
+
}
|
|
2088
|
+
`);
|
|
2089
|
+
if (optin === "defaulted") doc.write(`newResult[${k}] = ${id}.value;`);
|
|
2090
|
+
else doc.write(`
|
|
2091
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
2092
|
+
newResult[${k}] = ${id}.value;
|
|
2093
|
+
}
|
|
2094
|
+
`);
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
doc.write(`payload.value = newResult;`);
|
|
2098
|
+
doc.write(`return payload;`);
|
|
2099
|
+
return doc.compile();
|
|
2100
|
+
};
|
|
2101
|
+
let fastpass;
|
|
2102
|
+
const isObject$2 = isObject;
|
|
2103
|
+
const jit = !globalConfig.jitless;
|
|
2104
|
+
const fastEnabled = jit && allowsEval.value;
|
|
2105
|
+
const catchall = def.catchall;
|
|
2106
|
+
let value;
|
|
2107
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2108
|
+
value ?? (value = _normalized.value);
|
|
2109
|
+
const input = payload.value;
|
|
2110
|
+
if (!isObject$2(input)) {
|
|
2111
|
+
payload.issues.push({
|
|
2112
|
+
expected: "object",
|
|
2113
|
+
code: "invalid_type",
|
|
2114
|
+
input,
|
|
2115
|
+
inst
|
|
2116
|
+
});
|
|
2117
|
+
return payload;
|
|
2118
|
+
}
|
|
2119
|
+
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
2120
|
+
if (!fastpass) fastpass = generateFastpass(def.shape);
|
|
2121
|
+
payload = fastpass(payload, ctx);
|
|
2122
|
+
if (!catchall) return payload;
|
|
2123
|
+
return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
|
|
2124
|
+
}
|
|
2125
|
+
return superParse(payload, ctx);
|
|
2126
|
+
};
|
|
2127
|
+
});
|
|
2128
|
+
function handleUnionResults(results, final, inst, ctx) {
|
|
2129
|
+
for (const result of results) if (result.issues.length === 0) {
|
|
2130
|
+
final.value = result.value;
|
|
2131
|
+
return final;
|
|
2132
|
+
}
|
|
2133
|
+
const nonaborted = results.filter((r) => !aborted(r));
|
|
2134
|
+
if (nonaborted.length === 1) {
|
|
2135
|
+
final.value = nonaborted[0].value;
|
|
2136
|
+
return nonaborted[0];
|
|
2137
|
+
}
|
|
2138
|
+
final.issues.push({
|
|
2139
|
+
code: "invalid_union",
|
|
2140
|
+
input: final.value,
|
|
2141
|
+
inst,
|
|
2142
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
2143
|
+
});
|
|
2144
|
+
return final;
|
|
2145
|
+
}
|
|
2146
|
+
const $ZodUnion = $constructor("$ZodUnion", (inst, def) => {
|
|
2147
|
+
$ZodType.init(inst, def);
|
|
2148
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted") ? "defaulted" : zod.def.options.some((o) => o._zod.optin !== void 0) ? "optional" : void 0);
|
|
2149
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
2150
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2151
|
+
if (zod.def.options.every((o) => o._zod.values)) return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
2152
|
+
});
|
|
2153
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2154
|
+
if (zod.def.options.every((o) => o._zod.pattern)) {
|
|
2155
|
+
const patterns = zod.def.options.map((o) => o._zod.pattern);
|
|
2156
|
+
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
2157
|
+
}
|
|
2158
|
+
});
|
|
2159
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
2160
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2161
|
+
if (first) return first(payload, ctx);
|
|
2162
|
+
let async = false;
|
|
2163
|
+
const results = [];
|
|
2164
|
+
for (const option of def.options) {
|
|
2165
|
+
const result = option._zod.run({
|
|
2166
|
+
value: payload.value,
|
|
2167
|
+
issues: []
|
|
2168
|
+
}, ctx);
|
|
2169
|
+
if (result instanceof Promise) {
|
|
2170
|
+
results.push(result);
|
|
2171
|
+
async = true;
|
|
2172
|
+
} else {
|
|
2173
|
+
if (result.issues.length === 0) return result;
|
|
2174
|
+
results.push(result);
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
if (!async) return handleUnionResults(results, payload, inst, ctx);
|
|
2178
|
+
return Promise.all(results).then((results) => {
|
|
2179
|
+
return handleUnionResults(results, payload, inst, ctx);
|
|
2180
|
+
});
|
|
2181
|
+
};
|
|
2182
|
+
});
|
|
2183
|
+
const $ZodIntersection = $constructor("$ZodIntersection", (inst, def) => {
|
|
2184
|
+
$ZodType.init(inst, def);
|
|
2185
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2186
|
+
const input = payload.value;
|
|
2187
|
+
const left = def.left._zod.run({
|
|
2188
|
+
value: input,
|
|
2189
|
+
issues: []
|
|
2190
|
+
}, ctx);
|
|
2191
|
+
const right = def.right._zod.run({
|
|
2192
|
+
value: input,
|
|
2193
|
+
issues: []
|
|
2194
|
+
}, ctx);
|
|
2195
|
+
if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
|
|
2196
|
+
return handleIntersectionResults(payload, left, right);
|
|
2197
|
+
});
|
|
2198
|
+
return handleIntersectionResults(payload, left, right);
|
|
2199
|
+
};
|
|
2200
|
+
});
|
|
2201
|
+
function mergeValues(a, b) {
|
|
2202
|
+
if (a === b) return {
|
|
2203
|
+
valid: true,
|
|
2204
|
+
data: a
|
|
2205
|
+
};
|
|
2206
|
+
if (a instanceof Date && b instanceof Date && +a === +b) return {
|
|
2207
|
+
valid: true,
|
|
2208
|
+
data: a
|
|
2209
|
+
};
|
|
2210
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
2211
|
+
const bKeys = Object.keys(b);
|
|
2212
|
+
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
2213
|
+
const newObj = {
|
|
2214
|
+
...a,
|
|
2215
|
+
...b
|
|
2216
|
+
};
|
|
2217
|
+
if (Object.prototype.hasOwnProperty.call(newObj, "__proto__")) delete newObj.__proto__;
|
|
2218
|
+
for (const key of sharedKeys) {
|
|
2219
|
+
if (key === "__proto__") continue;
|
|
2220
|
+
const sharedValue = mergeValues(a[key], b[key]);
|
|
2221
|
+
if (!sharedValue.valid) return {
|
|
2222
|
+
valid: false,
|
|
2223
|
+
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
|
|
2224
|
+
};
|
|
2225
|
+
newObj[key] = sharedValue.data;
|
|
2226
|
+
}
|
|
2227
|
+
return {
|
|
2228
|
+
valid: true,
|
|
2229
|
+
data: newObj
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
2233
|
+
if (a.length !== b.length) return {
|
|
2234
|
+
valid: false,
|
|
2235
|
+
mergeErrorPath: []
|
|
2236
|
+
};
|
|
2237
|
+
const newArray = [];
|
|
2238
|
+
for (let index = 0; index < a.length; index++) {
|
|
2239
|
+
const itemA = a[index];
|
|
2240
|
+
const itemB = b[index];
|
|
2241
|
+
const sharedValue = mergeValues(itemA, itemB);
|
|
2242
|
+
if (!sharedValue.valid) return {
|
|
2243
|
+
valid: false,
|
|
2244
|
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
2245
|
+
};
|
|
2246
|
+
newArray.push(sharedValue.data);
|
|
2247
|
+
}
|
|
2248
|
+
return {
|
|
2249
|
+
valid: true,
|
|
2250
|
+
data: newArray
|
|
2251
|
+
};
|
|
2252
|
+
}
|
|
2253
|
+
return {
|
|
2254
|
+
valid: false,
|
|
2255
|
+
mergeErrorPath: []
|
|
2256
|
+
};
|
|
2257
|
+
}
|
|
2258
|
+
function handleIntersectionResults(result, left, right) {
|
|
2259
|
+
const unrecKeys = new Map();
|
|
2260
|
+
let unrecIssue;
|
|
2261
|
+
const keyIssues = new Map();
|
|
2262
|
+
const collect = (iss, side) => {
|
|
2263
|
+
let keys;
|
|
2264
|
+
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
2265
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
2266
|
+
keys = iss.keys;
|
|
2267
|
+
} else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
|
|
2268
|
+
const k = String(iss.path[0]);
|
|
2269
|
+
if (!keyIssues.has(k)) keyIssues.set(k, iss);
|
|
2270
|
+
keys = [k];
|
|
2271
|
+
} else return false;
|
|
2272
|
+
for (const k of keys) {
|
|
2273
|
+
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
2274
|
+
unrecKeys.get(k)[side] = true;
|
|
2275
|
+
}
|
|
2276
|
+
return true;
|
|
2277
|
+
};
|
|
2278
|
+
for (const iss of left.issues) if (!collect(iss, "l")) result.issues.push(iss);
|
|
2279
|
+
for (const iss of right.issues) if (!collect(iss, "r")) result.issues.push(iss);
|
|
2280
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
2281
|
+
if (bothKeys.length) {
|
|
2282
|
+
const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
|
|
2283
|
+
if (aggregated.length) result.issues.push({
|
|
2284
|
+
...unrecIssue,
|
|
2285
|
+
keys: aggregated
|
|
2286
|
+
});
|
|
2287
|
+
for (const k of bothKeys) if (!aggregated.includes(k) && keyIssues.has(k)) result.issues.push(keyIssues.get(k));
|
|
2288
|
+
}
|
|
2289
|
+
const merged = mergeValues(left.value, right.value);
|
|
2290
|
+
if (!merged.valid) {
|
|
2291
|
+
if (aborted(result)) return result;
|
|
2292
|
+
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
2293
|
+
}
|
|
2294
|
+
result.value = merged.data;
|
|
2295
|
+
return result;
|
|
2296
|
+
}
|
|
2297
|
+
const $ZodEnum = $constructor("$ZodEnum", (inst, def) => {
|
|
2298
|
+
$ZodType.init(inst, def);
|
|
2299
|
+
const values = getEnumValues(def.entries);
|
|
2300
|
+
const valuesSet = new Set(values);
|
|
2301
|
+
inst._zod.values = valuesSet;
|
|
2302
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2303
|
+
const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
|
|
2304
|
+
return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
|
|
2305
|
+
});
|
|
2306
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
2307
|
+
const input = payload.value;
|
|
2308
|
+
if (valuesSet.has(input)) return payload;
|
|
2309
|
+
payload.issues.push({
|
|
2310
|
+
code: "invalid_value",
|
|
2311
|
+
values,
|
|
2312
|
+
input,
|
|
2313
|
+
inst
|
|
2314
|
+
});
|
|
2315
|
+
return payload;
|
|
2316
|
+
};
|
|
2317
|
+
});
|
|
2318
|
+
const $ZodTransform = $constructor("$ZodTransform", (inst, def) => {
|
|
2319
|
+
$ZodType.init(inst, def);
|
|
2320
|
+
inst._zod.optin = "optional";
|
|
2321
|
+
globalConfig.memoizer?.guard(inst);
|
|
2322
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2323
|
+
if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
2324
|
+
const _out = def.transform(payload.value, payload);
|
|
2325
|
+
if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
|
|
2326
|
+
payload.value = output;
|
|
2327
|
+
return payload;
|
|
2328
|
+
});
|
|
2329
|
+
if (_out instanceof Promise) throw new $ZodAsyncError();
|
|
2330
|
+
payload.value = _out;
|
|
2331
|
+
return payload;
|
|
2332
|
+
};
|
|
2333
|
+
});
|
|
2334
|
+
function handleOptionalResult(payload, result) {
|
|
2335
|
+
payload.value = result.issues.length ? void 0 : result.value;
|
|
2336
|
+
return payload;
|
|
2337
|
+
}
|
|
2338
|
+
const $ZodOptional = $constructor("$ZodOptional", (inst, def) => {
|
|
2339
|
+
$ZodType.init(inst, def);
|
|
2340
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2341
|
+
inst._zod.optout = "optional";
|
|
2342
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2343
|
+
const values = zod.def.innerType._zod.values;
|
|
2344
|
+
return values ? new Set([...values, void 0]) : void 0;
|
|
2345
|
+
});
|
|
2346
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2347
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
2348
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
2349
|
+
});
|
|
2350
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2351
|
+
if (payload.value === void 0) {
|
|
2352
|
+
if (def.innerType._zod.optin !== "defaulted") return payload;
|
|
2353
|
+
const result = def.innerType._zod.run({
|
|
2354
|
+
value: payload.value,
|
|
2355
|
+
issues: []
|
|
2356
|
+
}, ctx);
|
|
2357
|
+
if (result instanceof Promise) return result.then((result) => handleOptionalResult(payload, result));
|
|
2358
|
+
return handleOptionalResult(payload, result);
|
|
2359
|
+
}
|
|
2360
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2361
|
+
};
|
|
2362
|
+
});
|
|
2363
|
+
const $ZodExactOptional = $constructor("$ZodExactOptional", (inst, def) => {
|
|
2364
|
+
$ZodOptional.init(inst, def);
|
|
2365
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2366
|
+
defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
|
|
2367
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2368
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2369
|
+
};
|
|
2370
|
+
});
|
|
2371
|
+
const $ZodNullable = $constructor("$ZodNullable", (inst, def) => {
|
|
2372
|
+
$ZodType.init(inst, def);
|
|
2373
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
|
|
2374
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2375
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2376
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
2377
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
2378
|
+
});
|
|
2379
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2380
|
+
return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : void 0;
|
|
2381
|
+
});
|
|
2382
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2383
|
+
if (payload.value === null) return payload;
|
|
2384
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2385
|
+
};
|
|
2386
|
+
});
|
|
2387
|
+
const $ZodDefault = $constructor("$ZodDefault", (inst, def) => {
|
|
2388
|
+
$ZodType.init(inst, def);
|
|
2389
|
+
inst._zod.optin = "defaulted";
|
|
2390
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2391
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2392
|
+
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2393
|
+
if (payload.value === void 0) {
|
|
2394
|
+
payload.value = def.defaultValue;
|
|
2395
|
+
return payload;
|
|
2396
|
+
}
|
|
2397
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2398
|
+
if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
|
|
2399
|
+
return handleDefaultResult(result, def);
|
|
2400
|
+
};
|
|
2401
|
+
});
|
|
2402
|
+
function handleDefaultResult(payload, def) {
|
|
2403
|
+
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
2404
|
+
return payload;
|
|
2405
|
+
}
|
|
2406
|
+
const $ZodPrefault = $constructor("$ZodPrefault", (inst, def) => {
|
|
2407
|
+
$ZodType.init(inst, def);
|
|
2408
|
+
inst._zod.optin = "defaulted";
|
|
2409
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2410
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2411
|
+
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2412
|
+
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
2413
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2414
|
+
};
|
|
2415
|
+
});
|
|
2416
|
+
const $ZodNonOptional = $constructor("$ZodNonOptional", (inst, def) => {
|
|
2417
|
+
$ZodType.init(inst, def);
|
|
2418
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2419
|
+
const v = zod.def.innerType._zod.values;
|
|
2420
|
+
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
2421
|
+
});
|
|
2422
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2423
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2424
|
+
if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
|
|
2425
|
+
return handleNonOptionalResult(result, inst);
|
|
2426
|
+
};
|
|
2427
|
+
});
|
|
2428
|
+
function handleNonOptionalResult(payload, inst) {
|
|
2429
|
+
if (!payload.issues.length && payload.value === void 0) payload.issues.push({
|
|
2430
|
+
code: "invalid_type",
|
|
2431
|
+
expected: "nonoptional",
|
|
2432
|
+
input: payload.value,
|
|
2433
|
+
inst
|
|
2434
|
+
});
|
|
2435
|
+
return payload;
|
|
2436
|
+
}
|
|
2437
|
+
function handleCatchResult(payload, result, def, ctx) {
|
|
2438
|
+
if (!result.issues.length) {
|
|
2439
|
+
payload.value = result.value;
|
|
2440
|
+
if (result.memo) payload.memo = true;
|
|
2441
|
+
return payload;
|
|
2442
|
+
}
|
|
2443
|
+
payload.value = def.catchValue({
|
|
2444
|
+
...result,
|
|
2445
|
+
value: payload.value,
|
|
2446
|
+
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2447
|
+
input: payload.value
|
|
2448
|
+
});
|
|
2449
|
+
return payload;
|
|
2450
|
+
}
|
|
2451
|
+
const $ZodCatch = $constructor("$ZodCatch", (inst, def) => {
|
|
2452
|
+
$ZodType.init(inst, def);
|
|
2453
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2454
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2455
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2456
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2457
|
+
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2458
|
+
const result = def.innerType._zod.run({
|
|
2459
|
+
value: payload.value,
|
|
2460
|
+
issues: []
|
|
2461
|
+
}, ctx);
|
|
2462
|
+
if (result instanceof Promise) return result.then((result) => handleCatchResult(payload, result, def, ctx));
|
|
2463
|
+
return handleCatchResult(payload, result, def, ctx);
|
|
2464
|
+
};
|
|
2465
|
+
});
|
|
2466
|
+
const $ZodPipe = $constructor("$ZodPipe", (inst, def) => {
|
|
2467
|
+
$ZodType.init(inst, def);
|
|
2468
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2469
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2470
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2471
|
+
defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
2472
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2473
|
+
if (ctx.direction === "backward") {
|
|
2474
|
+
const right = def.out._zod.run(payload, ctx);
|
|
2475
|
+
if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
|
|
2476
|
+
return handlePipeResult(right, def.in, ctx);
|
|
2477
|
+
}
|
|
2478
|
+
const left = def.in._zod.run(payload, ctx);
|
|
2479
|
+
if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
|
|
2480
|
+
return handlePipeResult(left, def.out, ctx);
|
|
2481
|
+
};
|
|
2482
|
+
});
|
|
2483
|
+
function handlePipeResult(left, next, ctx) {
|
|
2484
|
+
if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
|
|
2485
|
+
left.aborted = true;
|
|
2486
|
+
return left;
|
|
2487
|
+
}
|
|
2488
|
+
return next._zod.run({
|
|
2489
|
+
value: left.value,
|
|
2490
|
+
issues: left.issues
|
|
2491
|
+
}, ctx);
|
|
2492
|
+
}
|
|
2493
|
+
const $ZodReadonly = $constructor("$ZodReadonly", (inst, def) => {
|
|
2494
|
+
$ZodType.init(inst, def);
|
|
2495
|
+
defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
2496
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2497
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
|
|
2498
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
|
|
2499
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2500
|
+
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2501
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2502
|
+
if (result instanceof Promise) return result.then(handleReadonlyResult);
|
|
2503
|
+
return handleReadonlyResult(result);
|
|
2504
|
+
};
|
|
2505
|
+
});
|
|
2506
|
+
function handleReadonlyResult(payload) {
|
|
2507
|
+
if (!payload.memo) payload.value = Object.freeze(payload.value);
|
|
2508
|
+
return payload;
|
|
2509
|
+
}
|
|
2510
|
+
const $ZodCustom = $constructor("$ZodCustom", (inst, def) => {
|
|
2511
|
+
$ZodCheck.init(inst, def);
|
|
2512
|
+
$ZodType.init(inst, def);
|
|
2513
|
+
inst._zod.parse = (payload, _) => {
|
|
2514
|
+
return payload;
|
|
2515
|
+
};
|
|
2516
|
+
inst._zod.check = (payload) => {
|
|
2517
|
+
const input = payload.value;
|
|
2518
|
+
const r = def.fn(input);
|
|
2519
|
+
if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
|
|
2520
|
+
handleRefineResult(r, payload, input, inst);
|
|
2521
|
+
};
|
|
2522
|
+
});
|
|
2523
|
+
function handleRefineResult(result, payload, input, inst) {
|
|
2524
|
+
if (!result) {
|
|
2525
|
+
const _iss = {
|
|
2526
|
+
code: "custom",
|
|
2527
|
+
input,
|
|
2528
|
+
inst,
|
|
2529
|
+
path: [...inst._zod.def.path ?? []],
|
|
2530
|
+
continue: !inst._zod.def.abort
|
|
2531
|
+
};
|
|
2532
|
+
if (inst._zod.def.params) _iss.params = inst._zod.def.params;
|
|
2533
|
+
payload.issues.push(issue(_iss));
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/memoizer.js
|
|
2537
|
+
var $ZodCyclicError = class extends Error {
|
|
2538
|
+
constructor() {
|
|
2539
|
+
super(`Cannot parse a reference cycle that closes through a transform`);
|
|
2540
|
+
this.name = "ZodCyclicError";
|
|
2541
|
+
}
|
|
2542
|
+
};
|
|
2543
|
+
const STATE = "~memo";
|
|
2544
|
+
const NO_ISSUES = [];
|
|
2545
|
+
function isRef(value) {
|
|
2546
|
+
return value !== null && typeof value === "object";
|
|
2547
|
+
}
|
|
2548
|
+
function cloneIssues(issues) {
|
|
2549
|
+
return issues.map((iss) => iss.path ? {
|
|
2550
|
+
...iss,
|
|
2551
|
+
path: iss.path.slice()
|
|
2552
|
+
} : { ...iss });
|
|
2553
|
+
}
|
|
2554
|
+
const recursive = new WeakMap();
|
|
2555
|
+
const NONE = 0;
|
|
2556
|
+
const ASSUMED = 1;
|
|
2557
|
+
const PROVEN = 2;
|
|
2558
|
+
function isRecursive(inst, stack, resolve) {
|
|
2559
|
+
const cached = recursive.get(inst);
|
|
2560
|
+
if (cached !== void 0) return cached ? PROVEN : NONE;
|
|
2561
|
+
if (stack.has(inst)) return PROVEN;
|
|
2562
|
+
stack.add(inst);
|
|
2563
|
+
let result = NONE;
|
|
2564
|
+
const check = (child) => {
|
|
2565
|
+
if (result !== PROVEN && child?._zod) {
|
|
2566
|
+
const answer = isRecursive(child, stack, resolve);
|
|
2567
|
+
if (answer > result) result = answer;
|
|
2568
|
+
}
|
|
2569
|
+
};
|
|
2570
|
+
const shape = (sh, spread) => {
|
|
2571
|
+
let answer = NONE;
|
|
2572
|
+
for (const key of Reflect.ownKeys(sh)) {
|
|
2573
|
+
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
2574
|
+
if (spread && !desc.enumerable) continue;
|
|
2575
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
|
|
2576
|
+
if (child > answer) answer = child;
|
|
2577
|
+
}
|
|
2578
|
+
return answer;
|
|
2579
|
+
};
|
|
2580
|
+
const merge = (answer) => {
|
|
2581
|
+
if (answer > result) result = answer;
|
|
2582
|
+
};
|
|
2583
|
+
const def = inst._zod.def;
|
|
2584
|
+
switch (def.type) {
|
|
2585
|
+
case "object": {
|
|
2586
|
+
const raw = rawShape(def);
|
|
2587
|
+
merge(raw ? shape(raw, true) : ASSUMED);
|
|
2588
|
+
check(def.catchall);
|
|
2589
|
+
break;
|
|
2590
|
+
}
|
|
2591
|
+
case "array":
|
|
2592
|
+
check(def.element);
|
|
2593
|
+
break;
|
|
2594
|
+
case "tuple":
|
|
2595
|
+
for (const el of def.items) check(el);
|
|
2596
|
+
check(def.rest);
|
|
2597
|
+
break;
|
|
2598
|
+
case "record":
|
|
2599
|
+
case "map":
|
|
2600
|
+
check(def.keyType);
|
|
2601
|
+
check(def.valueType);
|
|
2602
|
+
break;
|
|
2603
|
+
case "set":
|
|
2604
|
+
check(def.valueType);
|
|
2605
|
+
break;
|
|
2606
|
+
case "union":
|
|
2607
|
+
for (const el of def.options) check(el);
|
|
2608
|
+
break;
|
|
2609
|
+
case "intersection":
|
|
2610
|
+
check(def.left);
|
|
2611
|
+
check(def.right);
|
|
2612
|
+
break;
|
|
2613
|
+
case "optional":
|
|
2614
|
+
case "nullable":
|
|
2615
|
+
case "default":
|
|
2616
|
+
case "prefault":
|
|
2617
|
+
case "catch":
|
|
2618
|
+
case "readonly":
|
|
2619
|
+
case "nonoptional":
|
|
2620
|
+
case "promise":
|
|
2621
|
+
case "success":
|
|
2622
|
+
check(def.innerType);
|
|
2623
|
+
break;
|
|
2624
|
+
case "pipe":
|
|
2625
|
+
check(def.in);
|
|
2626
|
+
check(def.out);
|
|
2627
|
+
break;
|
|
2628
|
+
case "function":
|
|
2629
|
+
check(def.input);
|
|
2630
|
+
check(def.output);
|
|
2631
|
+
break;
|
|
2632
|
+
case "lazy": {
|
|
2633
|
+
const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
|
|
2634
|
+
merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
2635
|
+
break;
|
|
2636
|
+
}
|
|
2637
|
+
case "template_literal":
|
|
2638
|
+
case "string":
|
|
2639
|
+
case "number":
|
|
2640
|
+
case "int":
|
|
2641
|
+
case "boolean":
|
|
2642
|
+
case "bigint":
|
|
2643
|
+
case "symbol":
|
|
2644
|
+
case "undefined":
|
|
2645
|
+
case "null":
|
|
2646
|
+
case "void":
|
|
2647
|
+
case "never":
|
|
2648
|
+
case "any":
|
|
2649
|
+
case "unknown":
|
|
2650
|
+
case "date":
|
|
2651
|
+
case "nan":
|
|
2652
|
+
case "enum":
|
|
2653
|
+
case "literal":
|
|
2654
|
+
case "file":
|
|
2655
|
+
case "transform":
|
|
2656
|
+
case "custom": break;
|
|
2657
|
+
default: for (const key in def) {
|
|
2658
|
+
const desc = Object.getOwnPropertyDescriptor(def, key);
|
|
2659
|
+
if (!desc || desc.get) continue;
|
|
2660
|
+
const value = desc.value;
|
|
2661
|
+
if (!value || typeof value !== "object") continue;
|
|
2662
|
+
if (value._zod) check(value);
|
|
2663
|
+
else if (Array.isArray(value)) for (const el of value) check(el);
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
stack.delete(inst);
|
|
2667
|
+
return settle(inst, result);
|
|
2668
|
+
}
|
|
2669
|
+
function settle(inst, answer) {
|
|
2670
|
+
if (answer !== ASSUMED) recursive.set(inst, answer === PROVEN);
|
|
2671
|
+
return answer;
|
|
2672
|
+
}
|
|
2673
|
+
function bucketFor(state, inst) {
|
|
2674
|
+
let bucket = state.buckets.get(inst);
|
|
2675
|
+
if (!bucket) {
|
|
2676
|
+
bucket = new WeakMap();
|
|
2677
|
+
state.buckets.set(inst, bucket);
|
|
2678
|
+
}
|
|
2679
|
+
return bucket;
|
|
2680
|
+
}
|
|
2681
|
+
let handoff;
|
|
2682
|
+
const open = [];
|
|
2683
|
+
const memo = {
|
|
2684
|
+
alloc(_inst, payload, empty) {
|
|
2685
|
+
const bucket = handoff;
|
|
2686
|
+
if (!bucket) return empty;
|
|
2687
|
+
handoff = void 0;
|
|
2688
|
+
const entry = {
|
|
2689
|
+
value: empty,
|
|
2690
|
+
issues: null
|
|
2691
|
+
};
|
|
2692
|
+
bucket.set(payload.value, entry);
|
|
2693
|
+
open.push(entry);
|
|
2694
|
+
return empty;
|
|
2695
|
+
},
|
|
2696
|
+
guard(inst) {
|
|
2697
|
+
var _a;
|
|
2698
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
2699
|
+
inst._zod.deferred.push(() => {
|
|
2700
|
+
const base = inst._zod.parse;
|
|
2701
|
+
const wrapped = (payload, ctx) => {
|
|
2702
|
+
if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value)) throw new $ZodCyclicError();
|
|
2703
|
+
return base(payload, ctx);
|
|
2704
|
+
};
|
|
2705
|
+
inst._zod.parse = wrapped;
|
|
2706
|
+
if (inst._zod.run === base) inst._zod.run = wrapped;
|
|
2707
|
+
});
|
|
2708
|
+
},
|
|
2709
|
+
attach(inst) {
|
|
2710
|
+
var _a;
|
|
2711
|
+
let isRecursiveInst;
|
|
2712
|
+
let rechecked = false;
|
|
2713
|
+
let lastCtx;
|
|
2714
|
+
let lastBucket;
|
|
2715
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
2716
|
+
inst._zod.deferred.push(() => {
|
|
2717
|
+
const base = inst._zod.parse;
|
|
2718
|
+
const wrapped = (payload, ctx) => {
|
|
2719
|
+
if (isRecursiveInst === void 0) {
|
|
2720
|
+
const walked = isRecursive(inst, new Set(), false);
|
|
2721
|
+
if (walked === NONE) {
|
|
2722
|
+
inst._zod.parse = base;
|
|
2723
|
+
if (inst._zod.run === wrapped) inst._zod.run = base;
|
|
2724
|
+
return base(payload, ctx);
|
|
2725
|
+
}
|
|
2726
|
+
if (walked === PROVEN || rechecked) isRecursiveInst = true;
|
|
2727
|
+
else rechecked = true;
|
|
2728
|
+
}
|
|
2729
|
+
const input = payload.value;
|
|
2730
|
+
if (!isRef(input)) return base(payload, ctx);
|
|
2731
|
+
let state = ctx[STATE];
|
|
2732
|
+
if (!state) {
|
|
2733
|
+
state = {
|
|
2734
|
+
buckets: new WeakMap(),
|
|
2735
|
+
backEdges: void 0
|
|
2736
|
+
};
|
|
2737
|
+
ctx[STATE] = state;
|
|
2738
|
+
}
|
|
2739
|
+
let bucket;
|
|
2740
|
+
if (lastCtx === ctx) bucket = lastBucket;
|
|
2741
|
+
else {
|
|
2742
|
+
bucket = bucketFor(state, inst);
|
|
2743
|
+
lastCtx = ctx;
|
|
2744
|
+
lastBucket = bucket;
|
|
2745
|
+
}
|
|
2746
|
+
const hit = bucket.get(input);
|
|
2747
|
+
if (hit) {
|
|
2748
|
+
payload.value = hit.value;
|
|
2749
|
+
if (hit.issues) {
|
|
2750
|
+
if (hit.issues.length) payload.issues.push(...cloneIssues(hit.issues));
|
|
2751
|
+
} else {
|
|
2752
|
+
payload.memo = true;
|
|
2753
|
+
state.backEdges ?? (state.backEdges = new WeakSet());
|
|
2754
|
+
state.backEdges.add(hit.value);
|
|
2755
|
+
}
|
|
2756
|
+
return payload;
|
|
2757
|
+
}
|
|
2758
|
+
handoff = bucket;
|
|
2759
|
+
const depth = open.length;
|
|
2760
|
+
const result = base(payload, ctx);
|
|
2761
|
+
handoff = void 0;
|
|
2762
|
+
const entry = open.length > depth ? open.pop() : void 0;
|
|
2763
|
+
if (result instanceof Promise) return result.then((r) => {
|
|
2764
|
+
if (entry) entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
|
|
2765
|
+
return r;
|
|
2766
|
+
});
|
|
2767
|
+
if (entry) entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
|
|
2768
|
+
return result;
|
|
2769
|
+
};
|
|
2770
|
+
inst._zod.parse = wrapped;
|
|
2771
|
+
if (inst._zod.run === base) inst._zod.run = wrapped;
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
};
|
|
2775
|
+
function memoizer() {
|
|
2776
|
+
return memo;
|
|
2777
|
+
}
|
|
2778
|
+
function isBackEdge(ctx, value) {
|
|
2779
|
+
const backEdges = ctx[STATE]?.backEdges;
|
|
2780
|
+
return backEdges !== void 0 && isRef(value) && backEdges.has(value);
|
|
2781
|
+
}
|
|
2782
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/locales/en.js
|
|
2783
|
+
const error = () => {
|
|
2784
|
+
const Sizable = {
|
|
2785
|
+
string: {
|
|
2786
|
+
unit: "characters",
|
|
2787
|
+
verb: "to have"
|
|
2788
|
+
},
|
|
2789
|
+
file: {
|
|
2790
|
+
unit: "bytes",
|
|
2791
|
+
verb: "to have"
|
|
2792
|
+
},
|
|
2793
|
+
array: {
|
|
2794
|
+
unit: "items",
|
|
2795
|
+
verb: "to have"
|
|
2796
|
+
},
|
|
2797
|
+
set: {
|
|
2798
|
+
unit: "items",
|
|
2799
|
+
verb: "to have"
|
|
2800
|
+
},
|
|
2801
|
+
map: {
|
|
2802
|
+
unit: "entries",
|
|
2803
|
+
verb: "to have"
|
|
2804
|
+
}
|
|
2805
|
+
};
|
|
2806
|
+
function getSizing(origin) {
|
|
2807
|
+
return Sizable[origin] ?? null;
|
|
2808
|
+
}
|
|
2809
|
+
const FormatDictionary = {
|
|
2810
|
+
regex: "input",
|
|
2811
|
+
email: "email address",
|
|
2812
|
+
url: "URL",
|
|
2813
|
+
emoji: "emoji",
|
|
2814
|
+
uuid: "UUID",
|
|
2815
|
+
uuidv4: "UUIDv4",
|
|
2816
|
+
uuidv6: "UUIDv6",
|
|
2817
|
+
nanoid: "nanoid",
|
|
2818
|
+
guid: "GUID",
|
|
2819
|
+
cuid: "cuid",
|
|
2820
|
+
cuid2: "cuid2",
|
|
2821
|
+
ulid: "ULID",
|
|
2822
|
+
xid: "XID",
|
|
2823
|
+
ksuid: "KSUID",
|
|
2824
|
+
datetime: "ISO datetime",
|
|
2825
|
+
date: "ISO date",
|
|
2826
|
+
time: "ISO time",
|
|
2827
|
+
duration: "ISO duration",
|
|
2828
|
+
ipv4: "IPv4 address",
|
|
2829
|
+
ipv6: "IPv6 address",
|
|
2830
|
+
mac: "MAC address",
|
|
2831
|
+
cidrv4: "IPv4 range",
|
|
2832
|
+
cidrv6: "IPv6 range",
|
|
2833
|
+
base64: "base64-encoded string",
|
|
2834
|
+
base64url: "base64url-encoded string",
|
|
2835
|
+
json_string: "JSON string",
|
|
2836
|
+
e164: "E.164 number",
|
|
2837
|
+
currency_code: "currency code",
|
|
2838
|
+
credit_card: "credit card number",
|
|
2839
|
+
iban: "IBAN",
|
|
2840
|
+
jwt: "JWT",
|
|
2841
|
+
template_literal: "input"
|
|
2842
|
+
};
|
|
2843
|
+
const TypeDictionary = { nan: "NaN" };
|
|
2844
|
+
function getTypeName(type, input) {
|
|
2845
|
+
if (type === "number" && typeof input === "number" && !Number.isFinite(input)) return String(input);
|
|
2846
|
+
return TypeDictionary[type] ?? type;
|
|
2847
|
+
}
|
|
2848
|
+
return (issue) => {
|
|
2849
|
+
switch (issue.code) {
|
|
2850
|
+
case "invalid_type": return `Invalid input: expected ${getTypeName(issue.expected)}, received ${getTypeName(parsedType(issue.input), issue.input)}`;
|
|
2851
|
+
case "invalid_value":
|
|
2852
|
+
if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
|
|
2853
|
+
return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
|
|
2854
|
+
case "too_big": {
|
|
2855
|
+
const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
|
|
2856
|
+
const sizing = getSizing(issue.origin);
|
|
2857
|
+
if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
|
2858
|
+
return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
|
|
2859
|
+
}
|
|
2860
|
+
case "too_small": {
|
|
2861
|
+
const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
|
|
2862
|
+
const sizing = getSizing(issue.origin);
|
|
2863
|
+
if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
2864
|
+
return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
|
|
2865
|
+
}
|
|
2866
|
+
case "invalid_format": {
|
|
2867
|
+
const _issue = issue;
|
|
2868
|
+
if (_issue.format === "starts_with") return `Invalid string: must start with "${_issue.prefix}"`;
|
|
2869
|
+
if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
|
|
2870
|
+
if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
|
|
2871
|
+
if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
2872
|
+
return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
|
|
2873
|
+
}
|
|
2874
|
+
case "not_multiple_of": return `Invalid number: must be a multiple of ${issue.divisor}`;
|
|
2875
|
+
case "unrecognized_keys": return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
|
|
2876
|
+
case "invalid_key": return `Invalid key in ${issue.origin}`;
|
|
2877
|
+
case "invalid_union":
|
|
2878
|
+
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) return `Invalid discriminator value. Expected ${issue.options.map((o) => `'${o}'`).join(" | ")}`;
|
|
2879
|
+
if (issue.inclusive === false) return "Invalid input: more than one option matched";
|
|
2880
|
+
return "Invalid input";
|
|
2881
|
+
case "invalid_element": return `Invalid value in ${issue.origin}`;
|
|
2882
|
+
default: return `Invalid input`;
|
|
2883
|
+
}
|
|
2884
|
+
};
|
|
2885
|
+
};
|
|
2886
|
+
function en_default() {
|
|
2887
|
+
return { localeError: error() };
|
|
2888
|
+
}
|
|
2889
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/registries.js
|
|
2890
|
+
var _a;
|
|
2891
|
+
var $ZodRegistry = class {
|
|
2892
|
+
constructor() {
|
|
2893
|
+
this._map = new WeakMap();
|
|
2894
|
+
this._idmap = new Map();
|
|
2895
|
+
}
|
|
2896
|
+
add(schema, ..._meta) {
|
|
2897
|
+
const meta = _meta[0];
|
|
2898
|
+
this._map.set(schema, meta);
|
|
2899
|
+
if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
|
|
2900
|
+
return this;
|
|
2901
|
+
}
|
|
2902
|
+
clear() {
|
|
2903
|
+
this._map = new WeakMap();
|
|
2904
|
+
this._idmap = new Map();
|
|
2905
|
+
return this;
|
|
2906
|
+
}
|
|
2907
|
+
remove(schema) {
|
|
2908
|
+
const meta = this._map.get(schema);
|
|
2909
|
+
if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
|
|
2910
|
+
this._map.delete(schema);
|
|
2911
|
+
return this;
|
|
2912
|
+
}
|
|
2913
|
+
get(schema) {
|
|
2914
|
+
const p = schema._zod.parent;
|
|
2915
|
+
if (p) {
|
|
2916
|
+
const pm = { ...this.get(p) ?? {} };
|
|
2917
|
+
delete pm.id;
|
|
2918
|
+
const f = {
|
|
2919
|
+
...pm,
|
|
2920
|
+
...this._map.get(schema)
|
|
2921
|
+
};
|
|
2922
|
+
return Object.keys(f).length ? f : void 0;
|
|
2923
|
+
}
|
|
2924
|
+
return this._map.get(schema);
|
|
2925
|
+
}
|
|
2926
|
+
has(schema) {
|
|
2927
|
+
return this._map.has(schema);
|
|
2928
|
+
}
|
|
2929
|
+
};
|
|
2930
|
+
function registry() {
|
|
2931
|
+
return new $ZodRegistry();
|
|
2932
|
+
}
|
|
2933
|
+
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
2934
|
+
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
2935
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/api.js
|
|
2936
|
+
function snapshotChecks(def) {
|
|
2937
|
+
if (def.checks) def.checks = [...def.checks];
|
|
2938
|
+
return def;
|
|
2939
|
+
}
|
|
2940
|
+
function _string(Class, params) {
|
|
2941
|
+
return new Class(snapshotChecks({
|
|
2942
|
+
type: "string",
|
|
2943
|
+
...normalizeParams(params)
|
|
2944
|
+
}));
|
|
2945
|
+
}
|
|
2946
|
+
function _email(Class, params) {
|
|
2947
|
+
return new Class({
|
|
2948
|
+
type: "string",
|
|
2949
|
+
format: "email",
|
|
2950
|
+
check: "string_format",
|
|
2951
|
+
abort: false,
|
|
2952
|
+
...normalizeParams(params)
|
|
2953
|
+
});
|
|
2954
|
+
}
|
|
2955
|
+
function _guid(Class, params) {
|
|
2956
|
+
return new Class({
|
|
2957
|
+
type: "string",
|
|
2958
|
+
format: "guid",
|
|
2959
|
+
check: "string_format",
|
|
2960
|
+
abort: false,
|
|
2961
|
+
...normalizeParams(params)
|
|
2962
|
+
});
|
|
2963
|
+
}
|
|
2964
|
+
function _uuid(Class, params) {
|
|
2965
|
+
return new Class({
|
|
2966
|
+
type: "string",
|
|
2967
|
+
format: "uuid",
|
|
2968
|
+
check: "string_format",
|
|
2969
|
+
abort: false,
|
|
2970
|
+
...normalizeParams(params)
|
|
2971
|
+
});
|
|
2972
|
+
}
|
|
2973
|
+
function _uuidv4(Class, params) {
|
|
2974
|
+
return new Class({
|
|
2975
|
+
type: "string",
|
|
2976
|
+
format: "uuid",
|
|
2977
|
+
check: "string_format",
|
|
2978
|
+
abort: false,
|
|
2979
|
+
version: "v4",
|
|
2980
|
+
...normalizeParams(params)
|
|
2981
|
+
});
|
|
2982
|
+
}
|
|
2983
|
+
function _uuidv6(Class, params) {
|
|
2984
|
+
return new Class({
|
|
2985
|
+
type: "string",
|
|
2986
|
+
format: "uuid",
|
|
2987
|
+
check: "string_format",
|
|
2988
|
+
abort: false,
|
|
2989
|
+
version: "v6",
|
|
2990
|
+
...normalizeParams(params)
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2993
|
+
function _uuidv7(Class, params) {
|
|
2994
|
+
return new Class({
|
|
2995
|
+
type: "string",
|
|
2996
|
+
format: "uuid",
|
|
2997
|
+
check: "string_format",
|
|
2998
|
+
abort: false,
|
|
2999
|
+
version: "v7",
|
|
3000
|
+
...normalizeParams(params)
|
|
3001
|
+
});
|
|
3002
|
+
}
|
|
3003
|
+
function _url(Class, params) {
|
|
3004
|
+
return new Class({
|
|
3005
|
+
type: "string",
|
|
3006
|
+
format: "url",
|
|
3007
|
+
check: "string_format",
|
|
3008
|
+
abort: false,
|
|
3009
|
+
...normalizeParams(params)
|
|
3010
|
+
});
|
|
3011
|
+
}
|
|
3012
|
+
function _emoji(Class, params) {
|
|
3013
|
+
return new Class({
|
|
3014
|
+
type: "string",
|
|
3015
|
+
format: "emoji",
|
|
3016
|
+
check: "string_format",
|
|
3017
|
+
abort: false,
|
|
3018
|
+
...normalizeParams(params)
|
|
3019
|
+
});
|
|
3020
|
+
}
|
|
3021
|
+
function _nanoid(Class, params) {
|
|
3022
|
+
return new Class({
|
|
3023
|
+
type: "string",
|
|
3024
|
+
format: "nanoid",
|
|
3025
|
+
check: "string_format",
|
|
3026
|
+
abort: false,
|
|
3027
|
+
...normalizeParams(params)
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
function _cuid(Class, params) {
|
|
3031
|
+
return new Class({
|
|
3032
|
+
type: "string",
|
|
3033
|
+
format: "cuid",
|
|
3034
|
+
check: "string_format",
|
|
3035
|
+
abort: false,
|
|
3036
|
+
...normalizeParams(params)
|
|
3037
|
+
});
|
|
3038
|
+
}
|
|
3039
|
+
function _cuid2(Class, params) {
|
|
3040
|
+
return new Class({
|
|
3041
|
+
type: "string",
|
|
3042
|
+
format: "cuid2",
|
|
3043
|
+
check: "string_format",
|
|
3044
|
+
abort: false,
|
|
3045
|
+
...normalizeParams(params)
|
|
3046
|
+
});
|
|
3047
|
+
}
|
|
3048
|
+
function _ulid(Class, params) {
|
|
3049
|
+
return new Class({
|
|
3050
|
+
type: "string",
|
|
3051
|
+
format: "ulid",
|
|
3052
|
+
check: "string_format",
|
|
3053
|
+
abort: false,
|
|
3054
|
+
...normalizeParams(params)
|
|
3055
|
+
});
|
|
3056
|
+
}
|
|
3057
|
+
function _xid(Class, params) {
|
|
3058
|
+
return new Class({
|
|
3059
|
+
type: "string",
|
|
3060
|
+
format: "xid",
|
|
3061
|
+
check: "string_format",
|
|
3062
|
+
abort: false,
|
|
3063
|
+
...normalizeParams(params)
|
|
3064
|
+
});
|
|
3065
|
+
}
|
|
3066
|
+
function _ksuid(Class, params) {
|
|
3067
|
+
return new Class({
|
|
3068
|
+
type: "string",
|
|
3069
|
+
format: "ksuid",
|
|
3070
|
+
check: "string_format",
|
|
3071
|
+
abort: false,
|
|
3072
|
+
...normalizeParams(params)
|
|
3073
|
+
});
|
|
3074
|
+
}
|
|
3075
|
+
function _ipv4(Class, params) {
|
|
3076
|
+
return new Class({
|
|
3077
|
+
type: "string",
|
|
3078
|
+
format: "ipv4",
|
|
3079
|
+
check: "string_format",
|
|
3080
|
+
abort: false,
|
|
3081
|
+
...normalizeParams(params)
|
|
3082
|
+
});
|
|
3083
|
+
}
|
|
3084
|
+
function _ipv6(Class, params) {
|
|
3085
|
+
return new Class({
|
|
3086
|
+
type: "string",
|
|
3087
|
+
format: "ipv6",
|
|
3088
|
+
check: "string_format",
|
|
3089
|
+
abort: false,
|
|
3090
|
+
...normalizeParams(params)
|
|
3091
|
+
});
|
|
3092
|
+
}
|
|
3093
|
+
function _cidrv4(Class, params) {
|
|
3094
|
+
return new Class({
|
|
3095
|
+
type: "string",
|
|
3096
|
+
format: "cidrv4",
|
|
3097
|
+
check: "string_format",
|
|
3098
|
+
abort: false,
|
|
3099
|
+
...normalizeParams(params)
|
|
3100
|
+
});
|
|
3101
|
+
}
|
|
3102
|
+
function _cidrv6(Class, params) {
|
|
3103
|
+
return new Class({
|
|
3104
|
+
type: "string",
|
|
3105
|
+
format: "cidrv6",
|
|
3106
|
+
check: "string_format",
|
|
3107
|
+
abort: false,
|
|
3108
|
+
...normalizeParams(params)
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
function _base64(Class, params) {
|
|
3112
|
+
return new Class({
|
|
3113
|
+
type: "string",
|
|
3114
|
+
format: "base64",
|
|
3115
|
+
check: "string_format",
|
|
3116
|
+
abort: false,
|
|
3117
|
+
...normalizeParams(params)
|
|
3118
|
+
});
|
|
3119
|
+
}
|
|
3120
|
+
function _base64url(Class, params) {
|
|
3121
|
+
return new Class({
|
|
3122
|
+
type: "string",
|
|
3123
|
+
format: "base64url",
|
|
3124
|
+
check: "string_format",
|
|
3125
|
+
abort: false,
|
|
3126
|
+
...normalizeParams(params)
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
function _e164(Class, params) {
|
|
3130
|
+
return new Class({
|
|
3131
|
+
type: "string",
|
|
3132
|
+
format: "e164",
|
|
3133
|
+
check: "string_format",
|
|
3134
|
+
abort: false,
|
|
3135
|
+
...normalizeParams(params)
|
|
3136
|
+
});
|
|
3137
|
+
}
|
|
3138
|
+
function _jwt(Class, params) {
|
|
3139
|
+
return new Class({
|
|
3140
|
+
type: "string",
|
|
3141
|
+
format: "jwt",
|
|
3142
|
+
check: "string_format",
|
|
3143
|
+
abort: false,
|
|
3144
|
+
...normalizeParams(params)
|
|
3145
|
+
});
|
|
3146
|
+
}
|
|
3147
|
+
function _isoDateTime(Class, params) {
|
|
3148
|
+
return new Class({
|
|
3149
|
+
type: "string",
|
|
3150
|
+
format: "datetime",
|
|
3151
|
+
check: "string_format",
|
|
3152
|
+
offset: false,
|
|
3153
|
+
local: false,
|
|
3154
|
+
precision: null,
|
|
3155
|
+
...normalizeParams(params)
|
|
3156
|
+
});
|
|
3157
|
+
}
|
|
3158
|
+
function _isoDate(Class, params) {
|
|
3159
|
+
return new Class({
|
|
3160
|
+
type: "string",
|
|
3161
|
+
format: "date",
|
|
3162
|
+
check: "string_format",
|
|
3163
|
+
...normalizeParams(params)
|
|
3164
|
+
});
|
|
3165
|
+
}
|
|
3166
|
+
function _isoTime(Class, params) {
|
|
3167
|
+
return new Class({
|
|
3168
|
+
type: "string",
|
|
3169
|
+
format: "time",
|
|
3170
|
+
check: "string_format",
|
|
3171
|
+
precision: null,
|
|
3172
|
+
...normalizeParams(params)
|
|
3173
|
+
});
|
|
3174
|
+
}
|
|
3175
|
+
function _isoDuration(Class, params) {
|
|
3176
|
+
return new Class({
|
|
3177
|
+
type: "string",
|
|
3178
|
+
format: "duration",
|
|
3179
|
+
check: "string_format",
|
|
3180
|
+
...normalizeParams(params)
|
|
3181
|
+
});
|
|
3182
|
+
}
|
|
3183
|
+
function _number(Class, params) {
|
|
3184
|
+
return new Class(snapshotChecks({
|
|
3185
|
+
type: "number",
|
|
3186
|
+
checks: [],
|
|
3187
|
+
...normalizeParams(params)
|
|
3188
|
+
}));
|
|
3189
|
+
}
|
|
3190
|
+
function _int(Class, params) {
|
|
3191
|
+
return new Class({
|
|
3192
|
+
type: "number",
|
|
3193
|
+
check: "number_format",
|
|
3194
|
+
abort: false,
|
|
3195
|
+
format: "safeint",
|
|
3196
|
+
...normalizeParams(params)
|
|
3197
|
+
});
|
|
3198
|
+
}
|
|
3199
|
+
function _boolean(Class, params) {
|
|
3200
|
+
return new Class({
|
|
3201
|
+
type: "boolean",
|
|
3202
|
+
...normalizeParams(params)
|
|
3203
|
+
});
|
|
3204
|
+
}
|
|
3205
|
+
function _unknown(Class) {
|
|
3206
|
+
return new Class({ type: "unknown" });
|
|
3207
|
+
}
|
|
3208
|
+
function _never(Class, params) {
|
|
3209
|
+
return new Class({
|
|
3210
|
+
type: "never",
|
|
3211
|
+
...normalizeParams(params)
|
|
3212
|
+
});
|
|
3213
|
+
}
|
|
3214
|
+
function _lt(value, params) {
|
|
3215
|
+
return new $ZodCheckLessThan({
|
|
3216
|
+
check: "less_than",
|
|
3217
|
+
...normalizeParams(params),
|
|
3218
|
+
value,
|
|
3219
|
+
inclusive: false
|
|
3220
|
+
});
|
|
3221
|
+
}
|
|
3222
|
+
function _lte(value, params) {
|
|
3223
|
+
return new $ZodCheckLessThan({
|
|
3224
|
+
check: "less_than",
|
|
3225
|
+
...normalizeParams(params),
|
|
3226
|
+
value,
|
|
3227
|
+
inclusive: true
|
|
3228
|
+
});
|
|
3229
|
+
}
|
|
3230
|
+
function _gt(value, params) {
|
|
3231
|
+
return new $ZodCheckGreaterThan({
|
|
3232
|
+
check: "greater_than",
|
|
3233
|
+
...normalizeParams(params),
|
|
3234
|
+
value,
|
|
3235
|
+
inclusive: false
|
|
3236
|
+
});
|
|
3237
|
+
}
|
|
3238
|
+
function _gte(value, params) {
|
|
3239
|
+
return new $ZodCheckGreaterThan({
|
|
3240
|
+
check: "greater_than",
|
|
3241
|
+
...normalizeParams(params),
|
|
3242
|
+
value,
|
|
3243
|
+
inclusive: true
|
|
3244
|
+
});
|
|
3245
|
+
}
|
|
3246
|
+
function _multipleOf(value, params) {
|
|
3247
|
+
return new $ZodCheckMultipleOf({
|
|
3248
|
+
check: "multiple_of",
|
|
3249
|
+
...normalizeParams(params),
|
|
3250
|
+
value
|
|
3251
|
+
});
|
|
3252
|
+
}
|
|
3253
|
+
function _maxLength(maximum, params) {
|
|
3254
|
+
return new $ZodCheckMaxLength({
|
|
3255
|
+
check: "max_length",
|
|
3256
|
+
...normalizeParams(params),
|
|
3257
|
+
maximum
|
|
3258
|
+
});
|
|
3259
|
+
}
|
|
3260
|
+
function _minLength(minimum, params) {
|
|
3261
|
+
return new $ZodCheckMinLength({
|
|
3262
|
+
check: "min_length",
|
|
3263
|
+
...normalizeParams(params),
|
|
3264
|
+
minimum
|
|
3265
|
+
});
|
|
3266
|
+
}
|
|
3267
|
+
function _length(length, params) {
|
|
3268
|
+
return new $ZodCheckLengthEquals({
|
|
3269
|
+
check: "length_equals",
|
|
3270
|
+
...normalizeParams(params),
|
|
3271
|
+
length
|
|
3272
|
+
});
|
|
3273
|
+
}
|
|
3274
|
+
function _regex(pattern, params) {
|
|
3275
|
+
return new $ZodCheckRegex({
|
|
3276
|
+
check: "string_format",
|
|
3277
|
+
format: "regex",
|
|
3278
|
+
...normalizeParams(params),
|
|
3279
|
+
pattern
|
|
3280
|
+
});
|
|
3281
|
+
}
|
|
3282
|
+
function _lowercase(params) {
|
|
3283
|
+
return new $ZodCheckLowerCase({
|
|
3284
|
+
check: "string_format",
|
|
3285
|
+
format: "lowercase",
|
|
3286
|
+
...normalizeParams(params)
|
|
3287
|
+
});
|
|
3288
|
+
}
|
|
3289
|
+
function _uppercase(params) {
|
|
3290
|
+
return new $ZodCheckUpperCase({
|
|
3291
|
+
check: "string_format",
|
|
3292
|
+
format: "uppercase",
|
|
3293
|
+
...normalizeParams(params)
|
|
3294
|
+
});
|
|
3295
|
+
}
|
|
3296
|
+
function _includes(includes, params) {
|
|
3297
|
+
return new $ZodCheckIncludes({
|
|
3298
|
+
check: "string_format",
|
|
3299
|
+
format: "includes",
|
|
3300
|
+
...normalizeParams(params),
|
|
3301
|
+
includes
|
|
3302
|
+
});
|
|
3303
|
+
}
|
|
3304
|
+
function _startsWith(prefix, params) {
|
|
3305
|
+
return new $ZodCheckStartsWith({
|
|
3306
|
+
check: "string_format",
|
|
3307
|
+
format: "starts_with",
|
|
3308
|
+
...normalizeParams(params),
|
|
3309
|
+
prefix
|
|
3310
|
+
});
|
|
3311
|
+
}
|
|
3312
|
+
function _endsWith(suffix, params) {
|
|
3313
|
+
return new $ZodCheckEndsWith({
|
|
3314
|
+
check: "string_format",
|
|
3315
|
+
format: "ends_with",
|
|
3316
|
+
...normalizeParams(params),
|
|
3317
|
+
suffix
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
function _overwrite(tx) {
|
|
3321
|
+
return new $ZodCheckOverwrite({
|
|
3322
|
+
check: "overwrite",
|
|
3323
|
+
tx
|
|
3324
|
+
});
|
|
3325
|
+
}
|
|
3326
|
+
function _normalize(form) {
|
|
3327
|
+
return _overwrite((input) => input.normalize(form));
|
|
3328
|
+
}
|
|
3329
|
+
function _trim() {
|
|
3330
|
+
return _overwrite((input) => input.trim());
|
|
3331
|
+
}
|
|
3332
|
+
function _toLowerCase() {
|
|
3333
|
+
return _overwrite((input) => input.toLowerCase());
|
|
3334
|
+
}
|
|
3335
|
+
function _toUpperCase() {
|
|
3336
|
+
return _overwrite((input) => input.toUpperCase());
|
|
3337
|
+
}
|
|
3338
|
+
function _slugify() {
|
|
3339
|
+
return _overwrite((input) => slugify(input));
|
|
3340
|
+
}
|
|
3341
|
+
function _array(Class, element, params) {
|
|
3342
|
+
return new Class({
|
|
3343
|
+
type: "array",
|
|
3344
|
+
element,
|
|
3345
|
+
...normalizeParams(params)
|
|
3346
|
+
});
|
|
3347
|
+
}
|
|
3348
|
+
function _refine(Class, fn, _params) {
|
|
3349
|
+
return new Class({
|
|
3350
|
+
type: "custom",
|
|
3351
|
+
check: "custom",
|
|
3352
|
+
fn,
|
|
3353
|
+
...normalizeParams(_params)
|
|
3354
|
+
});
|
|
3355
|
+
}
|
|
3356
|
+
function _superRefine(fn, params) {
|
|
3357
|
+
const ch = _check((payload) => {
|
|
3358
|
+
payload.addIssue = (issue$2) => {
|
|
3359
|
+
if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
|
|
3360
|
+
else {
|
|
3361
|
+
const _issue = issue$2;
|
|
3362
|
+
if (_issue.fatal) _issue.continue = false;
|
|
3363
|
+
_issue.code ?? (_issue.code = "custom");
|
|
3364
|
+
if (!("input" in _issue)) _issue.input = payload.value;
|
|
3365
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
3366
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
3367
|
+
payload.issues.push(issue(_issue));
|
|
3368
|
+
}
|
|
3369
|
+
};
|
|
3370
|
+
return fn(payload.value, payload);
|
|
3371
|
+
}, params);
|
|
3372
|
+
return ch;
|
|
3373
|
+
}
|
|
3374
|
+
function _check(fn, params) {
|
|
3375
|
+
const ch = new $ZodCheck({
|
|
3376
|
+
check: "custom",
|
|
3377
|
+
...normalizeParams(params)
|
|
3378
|
+
});
|
|
3379
|
+
ch._zod.check = fn;
|
|
3380
|
+
return ch;
|
|
3381
|
+
}
|
|
3382
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/to-json-schema.js
|
|
3383
|
+
function assignProps(target, ...sources) {
|
|
3384
|
+
for (const source of sources) for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProp(target, key, source[key]);
|
|
3385
|
+
return target;
|
|
3386
|
+
}
|
|
3387
|
+
function initializeContext(params) {
|
|
3388
|
+
let target = params?.target ?? "draft-2020-12";
|
|
3389
|
+
if (target === "draft-4") target = "draft-04";
|
|
3390
|
+
if (target === "draft-7") target = "draft-07";
|
|
3391
|
+
return {
|
|
3392
|
+
processors: params.processors ?? {},
|
|
3393
|
+
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
3394
|
+
target,
|
|
3395
|
+
unrepresentable: params?.unrepresentable ?? "throw",
|
|
3396
|
+
override: params?.override ?? (() => {}),
|
|
3397
|
+
io: params?.io ?? "output",
|
|
3398
|
+
counter: 0,
|
|
3399
|
+
seen: new Map(),
|
|
3400
|
+
sharedDefsExtractedFor: void 0,
|
|
3401
|
+
sharedEmitDoneFor: void 0,
|
|
3402
|
+
cycles: params?.cycles ?? "ref",
|
|
3403
|
+
reused: params?.reused ?? "inline",
|
|
3404
|
+
intersections: [],
|
|
3405
|
+
deferred: [],
|
|
3406
|
+
external: params?.external ?? void 0
|
|
3407
|
+
};
|
|
3408
|
+
}
|
|
3409
|
+
function handleUnrepresentable(schema, ctx, json, params, message) {
|
|
3410
|
+
const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({
|
|
3411
|
+
zodSchema: schema,
|
|
3412
|
+
path: params.path,
|
|
3413
|
+
message
|
|
3414
|
+
}) : ctx.unrepresentable;
|
|
3415
|
+
if (result === "any") return false;
|
|
3416
|
+
if (result === void 0 || result === "throw") throw new Error(message);
|
|
3417
|
+
Object.assign(json, result);
|
|
3418
|
+
return true;
|
|
3419
|
+
}
|
|
3420
|
+
function processSchema(schema, ctx, _params = {
|
|
3421
|
+
path: [],
|
|
3422
|
+
schemaPath: []
|
|
3423
|
+
}) {
|
|
3424
|
+
var _a;
|
|
3425
|
+
const def = schema._zod.def;
|
|
3426
|
+
const seen = ctx.seen.get(schema);
|
|
3427
|
+
if (seen) {
|
|
3428
|
+
seen.count++;
|
|
3429
|
+
if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
|
|
3430
|
+
return seen.schema;
|
|
3431
|
+
}
|
|
3432
|
+
const result = {
|
|
3433
|
+
schema: {},
|
|
3434
|
+
count: 1,
|
|
3435
|
+
cycle: void 0,
|
|
3436
|
+
path: _params.path
|
|
3437
|
+
};
|
|
3438
|
+
ctx.seen.set(schema, result);
|
|
3439
|
+
ctx.sharedDefsExtractedFor = void 0;
|
|
3440
|
+
ctx.sharedEmitDoneFor = void 0;
|
|
3441
|
+
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
3442
|
+
if (overrideSchema) result.schema = overrideSchema;
|
|
3443
|
+
else {
|
|
3444
|
+
const params = {
|
|
3445
|
+
..._params,
|
|
3446
|
+
schemaPath: [..._params.schemaPath, schema],
|
|
3447
|
+
path: _params.path
|
|
3448
|
+
};
|
|
3449
|
+
if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
|
|
3450
|
+
else {
|
|
3451
|
+
const _json = result.schema;
|
|
3452
|
+
const processor = ctx.processors[def.type];
|
|
3453
|
+
if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
3454
|
+
processor(schema, ctx, _json, params);
|
|
3455
|
+
}
|
|
3456
|
+
const parent = schema._zod.parent;
|
|
3457
|
+
if (parent) {
|
|
3458
|
+
if (!result.ref) result.ref = parent;
|
|
3459
|
+
processSchema(parent, ctx, params);
|
|
3460
|
+
ctx.seen.get(parent).isParent = true;
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3463
|
+
const meta = ctx.metadataRegistry.get(schema);
|
|
3464
|
+
if (meta) assignProps(result.schema, meta);
|
|
3465
|
+
if (ctx.io === "input" && isTransforming(schema)) {
|
|
3466
|
+
delete result.schema.examples;
|
|
3467
|
+
delete result.schema.default;
|
|
3468
|
+
}
|
|
3469
|
+
if (ctx.io === "input" && "_prefault" in result.schema) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
3470
|
+
delete result.schema._prefault;
|
|
3471
|
+
return ctx.seen.get(schema).schema;
|
|
3472
|
+
}
|
|
3473
|
+
function encodeJSONPointerSegment(segment) {
|
|
3474
|
+
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
3475
|
+
}
|
|
3476
|
+
function extractDefs(ctx, schema) {
|
|
3477
|
+
const root = ctx.seen.get(schema);
|
|
3478
|
+
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3479
|
+
if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external) return;
|
|
3480
|
+
const idToSchema = new Map();
|
|
3481
|
+
for (const entry of ctx.seen.entries()) {
|
|
3482
|
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
3483
|
+
if (id) {
|
|
3484
|
+
const existing = idToSchema.get(id);
|
|
3485
|
+
if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
3486
|
+
idToSchema.set(id, entry[0]);
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
const makeURI = (entry) => {
|
|
3490
|
+
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
3491
|
+
if (ctx.external) {
|
|
3492
|
+
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
3493
|
+
const uriGenerator = ctx.external.uri ?? ((id) => id);
|
|
3494
|
+
if (externalId) return { ref: uriGenerator(externalId) };
|
|
3495
|
+
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
3496
|
+
entry[1].defId = id;
|
|
3497
|
+
return {
|
|
3498
|
+
defId: id,
|
|
3499
|
+
ref: `${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}`
|
|
3500
|
+
};
|
|
3501
|
+
}
|
|
3502
|
+
const uriPrefix = `#`;
|
|
3503
|
+
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
3504
|
+
if (entry[1] === root && !entry[1].schema.id) return { ref: uriPrefix };
|
|
3505
|
+
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
3506
|
+
return {
|
|
3507
|
+
defId,
|
|
3508
|
+
ref: defUriPrefix + encodeJSONPointerSegment(defId)
|
|
3509
|
+
};
|
|
3510
|
+
};
|
|
3511
|
+
const extractToDef = (entry) => {
|
|
3512
|
+
if (entry[1].schema.$ref) return;
|
|
3513
|
+
const seen = entry[1];
|
|
3514
|
+
const { ref, defId } = makeURI(entry);
|
|
3515
|
+
seen.def = { ...seen.schema };
|
|
3516
|
+
if (defId) seen.defId = defId;
|
|
3517
|
+
const schema = seen.schema;
|
|
3518
|
+
for (const key in schema) delete schema[key];
|
|
3519
|
+
schema.$ref = ref;
|
|
3520
|
+
};
|
|
3521
|
+
if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
|
|
3522
|
+
const seen = entry[1];
|
|
3523
|
+
if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
|
|
3524
|
+
|
|
3525
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
3526
|
+
}
|
|
3527
|
+
for (const entry of ctx.seen.entries()) {
|
|
3528
|
+
const seen = entry[1];
|
|
3529
|
+
if (schema === entry[0]) {
|
|
3530
|
+
extractToDef(entry);
|
|
3531
|
+
continue;
|
|
3532
|
+
}
|
|
3533
|
+
if (ctx.external) {
|
|
3534
|
+
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
3535
|
+
if (schema !== entry[0] && ext) {
|
|
3536
|
+
extractToDef(entry);
|
|
3537
|
+
continue;
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
if (ctx.metadataRegistry.get(entry[0])?.id) {
|
|
3541
|
+
extractToDef(entry);
|
|
3542
|
+
continue;
|
|
3543
|
+
}
|
|
3544
|
+
if (seen.cycle) {
|
|
3545
|
+
extractToDef(entry);
|
|
3546
|
+
continue;
|
|
3547
|
+
}
|
|
3548
|
+
if (seen.count > 1) {
|
|
3549
|
+
if (ctx.reused === "ref") extractToDef(entry);
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
if (ctx.external) ctx.sharedDefsExtractedFor = ctx.external;
|
|
3553
|
+
}
|
|
3554
|
+
function compactTypeUnion(schema) {
|
|
3555
|
+
const options = schema.anyOf;
|
|
3556
|
+
if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0) return;
|
|
3557
|
+
const types = [];
|
|
3558
|
+
for (const option of options) {
|
|
3559
|
+
if (!option || typeof option !== "object") return;
|
|
3560
|
+
compactTypeUnion(option);
|
|
3561
|
+
const keys = Object.keys(option);
|
|
3562
|
+
if (keys.length !== 1 || keys[0] !== "type") return;
|
|
3563
|
+
const type = option.type;
|
|
3564
|
+
for (const member of Array.isArray(type) ? type : [type]) {
|
|
3565
|
+
if (typeof member !== "string") return;
|
|
3566
|
+
if (!types.includes(member)) types.push(member);
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
delete schema.anyOf;
|
|
3570
|
+
schema.type = types.length === 1 ? types[0] : types;
|
|
3571
|
+
}
|
|
3572
|
+
const FOLDABLE_KEYS = new Set([
|
|
3573
|
+
"type",
|
|
3574
|
+
"properties",
|
|
3575
|
+
"required",
|
|
3576
|
+
"additionalProperties"
|
|
3577
|
+
]);
|
|
3578
|
+
const UNION_KEYS = ["oneOf", "anyOf"];
|
|
3579
|
+
function undeclaredConstraint(member) {
|
|
3580
|
+
const extra = member.additionalProperties;
|
|
3581
|
+
if (extra === void 0 || extra === false || typeof extra !== "object" || extra === null) return null;
|
|
3582
|
+
return Object.keys(extra).length ? extra : null;
|
|
3583
|
+
}
|
|
3584
|
+
function foldObjects(members) {
|
|
3585
|
+
const objects = [];
|
|
3586
|
+
for (const member of members) {
|
|
3587
|
+
if (typeof member !== "object" || member.type !== "object") return null;
|
|
3588
|
+
for (const key in member) if (!FOLDABLE_KEYS.has(key)) return null;
|
|
3589
|
+
objects.push(member);
|
|
3590
|
+
}
|
|
3591
|
+
const properties = {};
|
|
3592
|
+
const required = new Set();
|
|
3593
|
+
for (const object of objects) {
|
|
3594
|
+
for (const key in object.properties) {
|
|
3595
|
+
if (Object.prototype.hasOwnProperty.call(properties, key)) continue;
|
|
3596
|
+
const parts = [];
|
|
3597
|
+
for (const other of objects) {
|
|
3598
|
+
const part = other.properties?.[key] ?? undeclaredConstraint(other);
|
|
3599
|
+
if (part === null || part === void 0) continue;
|
|
3600
|
+
if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part))) parts.push(part);
|
|
3601
|
+
}
|
|
3602
|
+
assignProp(properties, key, parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts });
|
|
3603
|
+
}
|
|
3604
|
+
for (const key of object.required ?? []) required.add(key);
|
|
3605
|
+
}
|
|
3606
|
+
const folded = {
|
|
3607
|
+
type: "object",
|
|
3608
|
+
properties
|
|
3609
|
+
};
|
|
3610
|
+
if (required.size) folded.required = [...required];
|
|
3611
|
+
if (objects.every((object) => object.additionalProperties === false)) folded.additionalProperties = false;
|
|
3612
|
+
else {
|
|
3613
|
+
const constraints = [];
|
|
3614
|
+
for (const object of objects) {
|
|
3615
|
+
const constraint = undeclaredConstraint(object);
|
|
3616
|
+
if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint))) constraints.push(constraint);
|
|
3617
|
+
}
|
|
3618
|
+
if (constraints.length === 1) folded.additionalProperties = constraints[0];
|
|
3619
|
+
else if (constraints.length > 1) folded.additionalProperties = { allOf: constraints };
|
|
3620
|
+
}
|
|
3621
|
+
return folded;
|
|
3622
|
+
}
|
|
3623
|
+
function foldIntersection(json) {
|
|
3624
|
+
const allOf = json.allOf;
|
|
3625
|
+
if (!Array.isArray(allOf) || allOf.length < 2) return;
|
|
3626
|
+
for (const key of FOLDABLE_KEYS) if (key in json) return;
|
|
3627
|
+
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
3628
|
+
let folded = null;
|
|
3629
|
+
if (!unions.length) folded = foldObjects(allOf);
|
|
3630
|
+
else {
|
|
3631
|
+
const union = unions[0];
|
|
3632
|
+
const keyword = UNION_KEYS.find((k) => Array.isArray(union[k]));
|
|
3633
|
+
if (Object.keys(union).length !== 1) return;
|
|
3634
|
+
const rest = allOf.filter((m) => m !== union);
|
|
3635
|
+
const branches = union[keyword].map((branch) => foldObjects([...rest, branch]));
|
|
3636
|
+
if (branches.some((b) => !b)) return;
|
|
3637
|
+
folded = { [keyword]: branches };
|
|
3638
|
+
}
|
|
3639
|
+
if (!folded) return;
|
|
3640
|
+
delete json.allOf;
|
|
3641
|
+
assignProps(json, folded);
|
|
3642
|
+
}
|
|
3643
|
+
function finalize(ctx, schema) {
|
|
3644
|
+
const root = ctx.seen.get(schema);
|
|
3645
|
+
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3646
|
+
const flattenRef = (zodSchema) => {
|
|
3647
|
+
const seen = ctx.seen.get(zodSchema);
|
|
3648
|
+
if (seen.ref === null) return;
|
|
3649
|
+
const schema = seen.def ?? seen.schema;
|
|
3650
|
+
const _cached = { ...schema };
|
|
3651
|
+
const ref = seen.ref;
|
|
3652
|
+
seen.ref = null;
|
|
3653
|
+
if (ref) {
|
|
3654
|
+
flattenRef(ref);
|
|
3655
|
+
const refSeen = ctx.seen.get(ref);
|
|
3656
|
+
const refSchema = refSeen.schema;
|
|
3657
|
+
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
3658
|
+
schema.allOf = schema.allOf ?? [];
|
|
3659
|
+
schema.allOf.push(refSchema);
|
|
3660
|
+
} else assignProps(schema, refSchema);
|
|
3661
|
+
assignProps(schema, _cached);
|
|
3662
|
+
if (zodSchema._zod.parent === ref) for (const key in schema) {
|
|
3663
|
+
if (key === "$ref" || key === "allOf") continue;
|
|
3664
|
+
if (!(key in _cached)) delete schema[key];
|
|
3665
|
+
}
|
|
3666
|
+
if (refSchema.$ref && refSeen.def) for (const key in schema) {
|
|
3667
|
+
if (key === "$ref" || key === "allOf") continue;
|
|
3668
|
+
if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
const parent = zodSchema._zod.parent;
|
|
3672
|
+
if (parent && parent !== ref) {
|
|
3673
|
+
flattenRef(parent);
|
|
3674
|
+
const parentSeen = ctx.seen.get(parent);
|
|
3675
|
+
if (parentSeen?.schema.$ref) {
|
|
3676
|
+
schema.$ref = parentSeen.schema.$ref;
|
|
3677
|
+
if (parentSeen.def) for (const key in schema) {
|
|
3678
|
+
if (key === "$ref" || key === "allOf") continue;
|
|
3679
|
+
if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
ctx.override({
|
|
3684
|
+
zodSchema,
|
|
3685
|
+
jsonSchema: schema,
|
|
3686
|
+
path: seen.path ?? []
|
|
3687
|
+
});
|
|
3688
|
+
};
|
|
3689
|
+
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
|
|
3690
|
+
for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
|
|
3691
|
+
if (ctx.target !== "openapi-3.0") for (const entry of ctx.seen.entries()) compactTypeUnion(entry[1].def ?? entry[1].schema);
|
|
3692
|
+
for (const rewrite of ctx.deferred) rewrite();
|
|
3693
|
+
if (ctx.intersections.length) {
|
|
3694
|
+
const carriers = new Map();
|
|
3695
|
+
for (const seen of ctx.seen.values()) for (const json of [seen.schema, seen.def]) {
|
|
3696
|
+
const allOf = json?.allOf;
|
|
3697
|
+
if (!Array.isArray(allOf)) continue;
|
|
3698
|
+
const existing = carriers.get(allOf);
|
|
3699
|
+
if (existing) existing.push(json);
|
|
3700
|
+
else carriers.set(allOf, [json]);
|
|
3701
|
+
}
|
|
3702
|
+
for (const allOf of ctx.intersections) for (const json of carriers.get(allOf) ?? []) foldIntersection(json);
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
const result = {};
|
|
3706
|
+
if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
3707
|
+
else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
3708
|
+
else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
3709
|
+
else if (ctx.target === "openapi-3.0") {}
|
|
3710
|
+
if (ctx.external?.uri) {
|
|
3711
|
+
const id = ctx.external.registry.get(schema)?.id;
|
|
3712
|
+
if (!id) throw new Error("Schema is missing an `id` property");
|
|
3713
|
+
result.$id = ctx.external.uri(id);
|
|
3714
|
+
}
|
|
3715
|
+
assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
|
|
3716
|
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
3717
|
+
if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
|
|
3718
|
+
const defs = ctx.external?.defs ?? {};
|
|
3719
|
+
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) for (const entry of ctx.seen.entries()) {
|
|
3720
|
+
const seen = entry[1];
|
|
3721
|
+
if (seen.def && seen.defId) {
|
|
3722
|
+
if (seen.def.id === seen.defId) delete seen.def.id;
|
|
3723
|
+
assignProp(defs, seen.defId, seen.def);
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
if (ctx.external) ctx.sharedEmitDoneFor = ctx.external;
|
|
3727
|
+
if (ctx.external) {} else if (Object.keys(defs).length > 0) {
|
|
3728
|
+
if (ctx.target === "draft-2020-12") result.$defs = defs;
|
|
3729
|
+
else result.definitions = defs;
|
|
3730
|
+
}
|
|
3731
|
+
try {
|
|
3732
|
+
const finalized = JSON.parse(JSON.stringify(result));
|
|
3733
|
+
Object.defineProperty(finalized, "~standard", {
|
|
3734
|
+
value: {
|
|
3735
|
+
...schema["~standard"],
|
|
3736
|
+
jsonSchema: {
|
|
3737
|
+
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
|
|
3738
|
+
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
|
|
3739
|
+
}
|
|
3740
|
+
},
|
|
3741
|
+
enumerable: false,
|
|
3742
|
+
writable: false
|
|
3743
|
+
});
|
|
3744
|
+
return finalized;
|
|
3745
|
+
} catch (_err) {
|
|
3746
|
+
throw new Error("Error converting schema to JSON.");
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3749
|
+
function isTransforming(_schema, _ctx) {
|
|
3750
|
+
const ctx = _ctx ?? { seen: new Set() };
|
|
3751
|
+
if (ctx.seen.has(_schema)) return false;
|
|
3752
|
+
ctx.seen.add(_schema);
|
|
3753
|
+
const def = _schema._zod.def;
|
|
3754
|
+
if (def.type === "transform") return true;
|
|
3755
|
+
if (def.type === "array") return isTransforming(def.element, ctx);
|
|
3756
|
+
if (def.type === "set") return isTransforming(def.valueType, ctx);
|
|
3757
|
+
if (def.type === "lazy") return isTransforming(def.getter(), ctx);
|
|
3758
|
+
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") return isTransforming(def.innerType, ctx);
|
|
3759
|
+
if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
3760
|
+
if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
3761
|
+
if (def.type === "pipe") {
|
|
3762
|
+
if (_schema._zod.traits.has("$ZodCodec")) return true;
|
|
3763
|
+
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
3764
|
+
}
|
|
3765
|
+
if (def.type === "object") {
|
|
3766
|
+
for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
|
|
3767
|
+
return false;
|
|
3768
|
+
}
|
|
3769
|
+
if (def.type === "union") {
|
|
3770
|
+
for (const option of def.options) if (isTransforming(option, ctx)) return true;
|
|
3771
|
+
return false;
|
|
3772
|
+
}
|
|
3773
|
+
if (def.type === "tuple") {
|
|
3774
|
+
for (const item of def.items) if (isTransforming(item, ctx)) return true;
|
|
3775
|
+
if (def.rest && isTransforming(def.rest, ctx)) return true;
|
|
3776
|
+
return false;
|
|
3777
|
+
}
|
|
3778
|
+
return false;
|
|
3779
|
+
}
|
|
3780
|
+
const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
3781
|
+
const ctx = initializeContext({
|
|
3782
|
+
...params,
|
|
3783
|
+
processors
|
|
3784
|
+
});
|
|
3785
|
+
processSchema(schema, ctx);
|
|
3786
|
+
extractDefs(ctx, schema);
|
|
3787
|
+
return finalize(ctx, schema);
|
|
3788
|
+
};
|
|
3789
|
+
const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
3790
|
+
const { libraryOptions, target } = params ?? {};
|
|
3791
|
+
const ctx = initializeContext({
|
|
3792
|
+
...libraryOptions ?? {},
|
|
3793
|
+
target,
|
|
3794
|
+
io,
|
|
3795
|
+
processors
|
|
3796
|
+
});
|
|
3797
|
+
processSchema(schema, ctx);
|
|
3798
|
+
extractDefs(ctx, schema);
|
|
3799
|
+
return finalize(ctx, schema);
|
|
3800
|
+
};
|
|
3801
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/core/json-schema-processors.js
|
|
3802
|
+
const narrowMin = (agg, key, value) => {
|
|
3803
|
+
if (agg[key] === void 0 || value > agg[key]) agg[key] = value;
|
|
3804
|
+
};
|
|
3805
|
+
const narrowMax = (agg, key, value) => {
|
|
3806
|
+
if (agg[key] === void 0 || value < agg[key]) agg[key] = value;
|
|
3807
|
+
};
|
|
3808
|
+
const narrowBoth = (agg, value) => {
|
|
3809
|
+
narrowMin(agg, "minimum", value);
|
|
3810
|
+
narrowMax(agg, "maximum", value);
|
|
3811
|
+
};
|
|
3812
|
+
const addDivisor = (agg, value) => {
|
|
3813
|
+
agg.multipleOf ?? (agg.multipleOf = []);
|
|
3814
|
+
if (!agg.multipleOf.includes(value)) agg.multipleOf.push(value);
|
|
3815
|
+
};
|
|
3816
|
+
const addPattern = (agg, pattern) => {
|
|
3817
|
+
agg.patterns ?? (agg.patterns = new Set());
|
|
3818
|
+
agg.patterns.add(pattern);
|
|
3819
|
+
};
|
|
3820
|
+
const intersectMime = (agg, mime) => {
|
|
3821
|
+
agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
|
|
3822
|
+
};
|
|
3823
|
+
const setFormat = (agg, format) => {
|
|
3824
|
+
agg.format = format;
|
|
3825
|
+
if (format.includes("int")) agg.isInt = true;
|
|
3826
|
+
};
|
|
3827
|
+
const minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
|
|
3828
|
+
const maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
|
|
3829
|
+
const formatContributor = (ranges) => (agg, def) => {
|
|
3830
|
+
setFormat(agg, def.format);
|
|
3831
|
+
const [minimum, maximum] = ranges[def.format];
|
|
3832
|
+
narrowMin(agg, "minimum", minimum);
|
|
3833
|
+
narrowMax(agg, "maximum", maximum);
|
|
3834
|
+
};
|
|
3835
|
+
const contributors = {
|
|
3836
|
+
greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
|
|
3837
|
+
less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
|
|
3838
|
+
multiple_of: (agg, def) => addDivisor(agg, def.value),
|
|
3839
|
+
number_format: formatContributor(NUMBER_FORMAT_RANGES),
|
|
3840
|
+
bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
|
|
3841
|
+
min_length: minContributor,
|
|
3842
|
+
max_length: maxContributor,
|
|
3843
|
+
length_equals: (agg, def) => narrowBoth(agg, def.length),
|
|
3844
|
+
min_size: minContributor,
|
|
3845
|
+
max_size: maxContributor,
|
|
3846
|
+
size_equals: (agg, def) => narrowBoth(agg, def.size),
|
|
3847
|
+
string_format: (agg, def) => {
|
|
3848
|
+
setFormat(agg, def.format);
|
|
3849
|
+
if (def.pattern) addPattern(agg, def.pattern);
|
|
3850
|
+
if (def.format === "base64" || def.format === "base64url") agg.contentEncoding = def.format;
|
|
3851
|
+
if (def.local || def.precision === -1) agg.laxFormat = true;
|
|
3852
|
+
},
|
|
3853
|
+
mime_type: (agg, def) => intersectMime(agg, def.mime)
|
|
3854
|
+
};
|
|
3855
|
+
function aggregateChecks(schema) {
|
|
3856
|
+
const agg = {};
|
|
3857
|
+
const def = schema._zod.def;
|
|
3858
|
+
const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
3859
|
+
for (const ch of list) contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
3860
|
+
const bag = schema._zod.bag;
|
|
3861
|
+
if (bag.minimum !== void 0) narrowMin(agg, "minimum", bag.minimum);
|
|
3862
|
+
if (bag.exclusiveMinimum !== void 0) narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
|
|
3863
|
+
if (bag.maximum !== void 0) narrowMax(agg, "maximum", bag.maximum);
|
|
3864
|
+
if (bag.exclusiveMaximum !== void 0) narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
|
|
3865
|
+
if (bag.multipleOf !== void 0) addDivisor(agg, bag.multipleOf);
|
|
3866
|
+
if (bag.format !== void 0) {
|
|
3867
|
+
agg.format ?? (agg.format = bag.format);
|
|
3868
|
+
if (bag.format.includes("int")) agg.isInt = true;
|
|
3869
|
+
}
|
|
3870
|
+
if (bag.mime) intersectMime(agg, bag.mime);
|
|
3871
|
+
for (const pattern of bag.patterns ?? []) addPattern(agg, pattern);
|
|
3872
|
+
return agg;
|
|
3873
|
+
}
|
|
3874
|
+
const formatMap = {
|
|
3875
|
+
guid: "uuid",
|
|
3876
|
+
url: "uri",
|
|
3877
|
+
datetime: "date-time",
|
|
3878
|
+
json_string: "json-string",
|
|
3879
|
+
regex: ""
|
|
3880
|
+
};
|
|
3881
|
+
const exactPatterns = new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
|
|
3882
|
+
const exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
3883
|
+
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
3884
|
+
const json = _json;
|
|
3885
|
+
json.type = "string";
|
|
3886
|
+
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
3887
|
+
if (typeof minimum === "number") json.minLength = minimum;
|
|
3888
|
+
if (typeof maximum === "number") json.maxLength = maximum;
|
|
3889
|
+
if (format) {
|
|
3890
|
+
json.format = formatMap[format] ?? format;
|
|
3891
|
+
if (json.format === "") delete json.format;
|
|
3892
|
+
if (format === "time" || laxFormat) delete json.format;
|
|
3893
|
+
}
|
|
3894
|
+
if (contentEncoding) json.contentEncoding = contentEncoding;
|
|
3895
|
+
if (patterns && patterns.size > 0) {
|
|
3896
|
+
const patternList = [...patterns].map(exactPattern);
|
|
3897
|
+
if (patternList.length === 1) json.pattern = patternList[0].source;
|
|
3898
|
+
else if (patternList.length > 1) json.allOf = [...patternList.map((regex) => ({
|
|
3899
|
+
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
3900
|
+
pattern: regex.source
|
|
3901
|
+
}))];
|
|
3902
|
+
}
|
|
3903
|
+
};
|
|
3904
|
+
const numberProcessor = (schema, ctx, _json, params) => {
|
|
3905
|
+
const json = _json;
|
|
3906
|
+
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
3907
|
+
json.type = isInt ? "integer" : "number";
|
|
3908
|
+
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
3909
|
+
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
3910
|
+
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
3911
|
+
if (exMin) {
|
|
3912
|
+
if (legacy) {
|
|
3913
|
+
json.minimum = exclusiveMinimum;
|
|
3914
|
+
json.exclusiveMinimum = true;
|
|
3915
|
+
} else json.exclusiveMinimum = exclusiveMinimum;
|
|
3916
|
+
} else if (typeof minimum === "number") json.minimum = minimum;
|
|
3917
|
+
if (exMax) {
|
|
3918
|
+
if (legacy) {
|
|
3919
|
+
json.maximum = exclusiveMaximum;
|
|
3920
|
+
json.exclusiveMaximum = true;
|
|
3921
|
+
} else json.exclusiveMaximum = exclusiveMaximum;
|
|
3922
|
+
} else if (typeof maximum === "number") json.maximum = maximum;
|
|
3923
|
+
if (multipleOf) {
|
|
3924
|
+
const divisors = new Set();
|
|
3925
|
+
for (const divisor of multipleOf) if (Number.isFinite(divisor) && divisor !== 0) divisors.add(Math.abs(divisor));
|
|
3926
|
+
else handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
3927
|
+
const [first, ...rest] = divisors;
|
|
3928
|
+
if (first !== void 0) json.multipleOf = first;
|
|
3929
|
+
if (rest.length) json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
|
|
3930
|
+
}
|
|
3931
|
+
};
|
|
3932
|
+
const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
3933
|
+
json.type = "boolean";
|
|
3934
|
+
};
|
|
3935
|
+
const neverProcessor = (_schema, _ctx, json, _params) => {
|
|
3936
|
+
json.not = {};
|
|
3937
|
+
};
|
|
3938
|
+
const enumProcessor = (schema, _ctx, json, _params) => {
|
|
3939
|
+
const def = schema._zod.def;
|
|
3940
|
+
const values = getEnumValues(def.entries);
|
|
3941
|
+
if (values.length === 0) {
|
|
3942
|
+
json.not = {};
|
|
3943
|
+
return;
|
|
3944
|
+
}
|
|
3945
|
+
if (values.every((v) => typeof v === "number")) json.type = "number";
|
|
3946
|
+
if (values.every((v) => typeof v === "string")) json.type = "string";
|
|
3947
|
+
json.enum = values;
|
|
3948
|
+
};
|
|
3949
|
+
const customProcessor = (schema, ctx, json, params) => {
|
|
3950
|
+
handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
|
|
3951
|
+
};
|
|
3952
|
+
const transformProcessor = (schema, ctx, json, params) => {
|
|
3953
|
+
handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
|
|
3954
|
+
};
|
|
3955
|
+
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
3956
|
+
const json = _json;
|
|
3957
|
+
const def = schema._zod.def;
|
|
3958
|
+
const { minimum, maximum } = aggregateChecks(schema);
|
|
3959
|
+
if (typeof minimum === "number") json.minItems = minimum;
|
|
3960
|
+
if (typeof maximum === "number") json.maxItems = maximum;
|
|
3961
|
+
json.type = "array";
|
|
3962
|
+
json.items = processSchema(def.element, ctx, {
|
|
3963
|
+
...params,
|
|
3964
|
+
path: [...params.path, "items"]
|
|
3965
|
+
});
|
|
3966
|
+
};
|
|
3967
|
+
function inputOptin(schema) {
|
|
3968
|
+
const def = schema._zod.def;
|
|
3969
|
+
if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) return inputOptin(def.out);
|
|
3970
|
+
if (def.type === "catch") return inputOptin(def.innerType);
|
|
3971
|
+
return schema._zod.optin;
|
|
3972
|
+
}
|
|
3973
|
+
const objectProcessor = (schema, ctx, _json, params) => {
|
|
3974
|
+
const json = _json;
|
|
3975
|
+
const def = schema._zod.def;
|
|
3976
|
+
const shape = def.shape;
|
|
3977
|
+
if (Object.getOwnPropertySymbols(shape).length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) return;
|
|
3978
|
+
json.type = "object";
|
|
3979
|
+
json.properties = {};
|
|
3980
|
+
for (const key in shape) assignProp(json.properties, key, processSchema(shape[key], ctx, {
|
|
3981
|
+
...params,
|
|
3982
|
+
path: [
|
|
3983
|
+
...params.path,
|
|
3984
|
+
"properties",
|
|
3985
|
+
key
|
|
3986
|
+
]
|
|
3987
|
+
}));
|
|
3988
|
+
const requiredKeys = [];
|
|
3989
|
+
for (const key of Object.keys(shape)) {
|
|
3990
|
+
const field = def.shape[key];
|
|
3991
|
+
if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) requiredKeys.push(key);
|
|
3992
|
+
}
|
|
3993
|
+
if (requiredKeys.length > 0) json.required = requiredKeys;
|
|
3994
|
+
if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
|
|
3995
|
+
else if (!def.catchall) {
|
|
3996
|
+
if (ctx.io === "output") json.additionalProperties = false;
|
|
3997
|
+
} else if (def.catchall) json.additionalProperties = processSchema(def.catchall, ctx, {
|
|
3998
|
+
...params,
|
|
3999
|
+
path: [...params.path, "additionalProperties"]
|
|
4000
|
+
});
|
|
4001
|
+
};
|
|
4002
|
+
const unionProcessor = (schema, ctx, json, params) => {
|
|
4003
|
+
const def = schema._zod.def;
|
|
4004
|
+
const isExclusive = def.inclusive === false;
|
|
4005
|
+
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
4006
|
+
...params,
|
|
4007
|
+
path: [
|
|
4008
|
+
...params.path,
|
|
4009
|
+
isExclusive ? "oneOf" : "anyOf",
|
|
4010
|
+
i
|
|
4011
|
+
]
|
|
4012
|
+
}));
|
|
4013
|
+
if (isExclusive) json.oneOf = options;
|
|
4014
|
+
else json.anyOf = options;
|
|
4015
|
+
};
|
|
4016
|
+
const intersectionProcessor = (schema, ctx, json, params) => {
|
|
4017
|
+
const def = schema._zod.def;
|
|
4018
|
+
const a = processSchema(def.left, ctx, {
|
|
4019
|
+
...params,
|
|
4020
|
+
path: [
|
|
4021
|
+
...params.path,
|
|
4022
|
+
"allOf",
|
|
4023
|
+
0
|
|
4024
|
+
]
|
|
4025
|
+
});
|
|
4026
|
+
const b = processSchema(def.right, ctx, {
|
|
4027
|
+
...params,
|
|
4028
|
+
path: [
|
|
4029
|
+
...params.path,
|
|
4030
|
+
"allOf",
|
|
4031
|
+
1
|
|
4032
|
+
]
|
|
4033
|
+
});
|
|
4034
|
+
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
4035
|
+
const allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
|
|
4036
|
+
json.allOf = allOf;
|
|
4037
|
+
ctx.intersections.push(allOf);
|
|
4038
|
+
};
|
|
4039
|
+
const nullableProcessor = (schema, ctx, json, params) => {
|
|
4040
|
+
const def = schema._zod.def;
|
|
4041
|
+
const inner = processSchema(def.innerType, ctx, params);
|
|
4042
|
+
const seen = ctx.seen.get(schema);
|
|
4043
|
+
if (ctx.target === "openapi-3.0") {
|
|
4044
|
+
seen.ref = def.innerType;
|
|
4045
|
+
json.nullable = true;
|
|
4046
|
+
} else json.anyOf = [inner, { type: "null" }];
|
|
4047
|
+
};
|
|
4048
|
+
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
4049
|
+
const def = schema._zod.def;
|
|
4050
|
+
processSchema(def.innerType, ctx, params);
|
|
4051
|
+
const seen = ctx.seen.get(schema);
|
|
4052
|
+
seen.ref = def.innerType;
|
|
4053
|
+
};
|
|
4054
|
+
const UNREPRESENTABLE_DEFAULT = Symbol();
|
|
4055
|
+
function serializeDefaultValue(value, schema, ctx, json, params) {
|
|
4056
|
+
let unrepresentable = false;
|
|
4057
|
+
const serialized = JSON.stringify(value, (_, val) => {
|
|
4058
|
+
if (typeof val !== "bigint") return val;
|
|
4059
|
+
unrepresentable = true;
|
|
4060
|
+
return null;
|
|
4061
|
+
});
|
|
4062
|
+
if (!unrepresentable) return JSON.parse(serialized);
|
|
4063
|
+
handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
4064
|
+
return UNREPRESENTABLE_DEFAULT;
|
|
4065
|
+
}
|
|
4066
|
+
const defaultProcessor = (schema, ctx, json, params) => {
|
|
4067
|
+
const def = schema._zod.def;
|
|
4068
|
+
processSchema(def.innerType, ctx, params);
|
|
4069
|
+
const seen = ctx.seen.get(schema);
|
|
4070
|
+
seen.ref = def.innerType;
|
|
4071
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
4072
|
+
if (value !== UNREPRESENTABLE_DEFAULT) json.default = value;
|
|
4073
|
+
};
|
|
4074
|
+
const prefaultProcessor = (schema, ctx, json, params) => {
|
|
4075
|
+
const def = schema._zod.def;
|
|
4076
|
+
processSchema(def.innerType, ctx, params);
|
|
4077
|
+
const seen = ctx.seen.get(schema);
|
|
4078
|
+
seen.ref = def.innerType;
|
|
4079
|
+
if (ctx.io !== "input") return;
|
|
4080
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
4081
|
+
if (value !== UNREPRESENTABLE_DEFAULT) json._prefault = value;
|
|
4082
|
+
};
|
|
4083
|
+
const catchProcessor = (schema, ctx, json, params) => {
|
|
4084
|
+
const def = schema._zod.def;
|
|
4085
|
+
processSchema(def.innerType, ctx, params);
|
|
4086
|
+
const seen = ctx.seen.get(schema);
|
|
4087
|
+
seen.ref = def.innerType;
|
|
4088
|
+
let catchValue;
|
|
4089
|
+
try {
|
|
4090
|
+
catchValue = def.catchValue(void 0);
|
|
4091
|
+
} catch {
|
|
4092
|
+
handleUnrepresentable(schema, ctx, json, params, "Dynamic catch values are not supported in JSON Schema");
|
|
4093
|
+
return;
|
|
4094
|
+
}
|
|
4095
|
+
json.default = catchValue;
|
|
4096
|
+
};
|
|
4097
|
+
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
4098
|
+
const def = schema._zod.def;
|
|
4099
|
+
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
4100
|
+
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
4101
|
+
processSchema(innerType, ctx, params);
|
|
4102
|
+
const seen = ctx.seen.get(schema);
|
|
4103
|
+
seen.ref = innerType;
|
|
4104
|
+
};
|
|
4105
|
+
const readonlyProcessor = (schema, ctx, json, params) => {
|
|
4106
|
+
const def = schema._zod.def;
|
|
4107
|
+
processSchema(def.innerType, ctx, params);
|
|
4108
|
+
const seen = ctx.seen.get(schema);
|
|
4109
|
+
seen.ref = def.innerType;
|
|
4110
|
+
json.readOnly = true;
|
|
4111
|
+
};
|
|
4112
|
+
const optionalProcessor = (schema, ctx, _json, params) => {
|
|
4113
|
+
const def = schema._zod.def;
|
|
4114
|
+
processSchema(def.innerType, ctx, params);
|
|
4115
|
+
const seen = ctx.seen.get(schema);
|
|
4116
|
+
seen.ref = def.innerType;
|
|
4117
|
+
};
|
|
4118
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/classic/errors.js
|
|
4119
|
+
const _installedErrorProtos = new WeakSet([Object.prototype, Error.prototype]);
|
|
4120
|
+
function _lazyMethod(proto, key, make) {
|
|
4121
|
+
Object.defineProperty(proto, key, {
|
|
4122
|
+
configurable: true,
|
|
4123
|
+
enumerable: false,
|
|
4124
|
+
get() {
|
|
4125
|
+
const value = make(this);
|
|
4126
|
+
Object.defineProperty(this, key, {
|
|
4127
|
+
value,
|
|
4128
|
+
configurable: true,
|
|
4129
|
+
writable: true
|
|
4130
|
+
});
|
|
4131
|
+
return value;
|
|
4132
|
+
},
|
|
4133
|
+
set(value) {
|
|
4134
|
+
Object.defineProperty(this, key, {
|
|
4135
|
+
value,
|
|
4136
|
+
configurable: true,
|
|
4137
|
+
writable: true
|
|
4138
|
+
});
|
|
4139
|
+
}
|
|
4140
|
+
});
|
|
4141
|
+
}
|
|
4142
|
+
const initializer = (inst, issues) => {
|
|
4143
|
+
$ZodError.init(inst, issues);
|
|
4144
|
+
inst.name = "ZodError";
|
|
4145
|
+
const proto = Object.getPrototypeOf(inst);
|
|
4146
|
+
if (_installedErrorProtos.has(proto)) return;
|
|
4147
|
+
_installedErrorProtos.add(proto);
|
|
4148
|
+
_lazyMethod(proto, "format", (self) => (mapper) => formatError(self, mapper));
|
|
4149
|
+
_lazyMethod(proto, "flatten", (self) => (mapper) => flattenError(self, mapper));
|
|
4150
|
+
_lazyMethod(proto, "addIssue", (self) => (issue) => {
|
|
4151
|
+
self.issues.push(issue);
|
|
4152
|
+
self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
|
|
4153
|
+
});
|
|
4154
|
+
_lazyMethod(proto, "addIssues", (self) => (issues) => {
|
|
4155
|
+
self.issues.push(...issues);
|
|
4156
|
+
self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
|
|
4157
|
+
});
|
|
4158
|
+
Object.defineProperty(proto, "isEmpty", {
|
|
4159
|
+
configurable: true,
|
|
4160
|
+
enumerable: false,
|
|
4161
|
+
get() {
|
|
4162
|
+
return this.issues.length === 0;
|
|
4163
|
+
}
|
|
4164
|
+
});
|
|
4165
|
+
};
|
|
4166
|
+
const ZodRealError = $constructor("ZodError", initializer, void 0, { Parent: Error });
|
|
4167
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/classic/parse.js
|
|
4168
|
+
const parse = _parse(ZodRealError);
|
|
4169
|
+
const parseAsync = _parseAsync(ZodRealError);
|
|
4170
|
+
const safeParse = _safeParse(ZodRealError);
|
|
4171
|
+
const safeParseAsync = _safeParseAsync(ZodRealError);
|
|
4172
|
+
const encode = _encode(ZodRealError);
|
|
4173
|
+
const decode = _decode(ZodRealError);
|
|
4174
|
+
const encodeAsync = _encodeAsync(ZodRealError);
|
|
4175
|
+
const decodeAsync = _decodeAsync(ZodRealError);
|
|
4176
|
+
const safeEncode = _safeEncode(ZodRealError);
|
|
4177
|
+
const safeDecode = _safeDecode(ZodRealError);
|
|
4178
|
+
const safeEncodeAsync = _safeEncodeAsync(ZodRealError);
|
|
4179
|
+
const safeDecodeAsync = _safeDecodeAsync(ZodRealError);
|
|
4180
|
+
// node_modules/@joe-broadhead/messaging/dist/lib/modules/vendor/zod/v4/classic/schemas.js
|
|
4181
|
+
function _ensureDefaultLocale() {
|
|
4182
|
+
if (!globalConfig.localeError) config(en_default());
|
|
4183
|
+
}
|
|
4184
|
+
function _ensureDefaultMemoizer() {
|
|
4185
|
+
if (!globalConfig.memoizer) config({ memoizer: memoizer() });
|
|
4186
|
+
}
|
|
4187
|
+
const ZodType = $constructor("ZodType", (inst, def) => {
|
|
4188
|
+
_ensureDefaultLocale();
|
|
4189
|
+
$ZodType.init(inst, def);
|
|
4190
|
+
inst.def = def;
|
|
4191
|
+
inst.type = def.type;
|
|
4192
|
+
return inst;
|
|
4193
|
+
}, {
|
|
4194
|
+
check(...chks) {
|
|
4195
|
+
const def = this.def;
|
|
4196
|
+
return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
4197
|
+
check: ch,
|
|
4198
|
+
def: { check: "custom" },
|
|
4199
|
+
onattach: []
|
|
4200
|
+
} } : ch)] }), { parent: true });
|
|
4201
|
+
},
|
|
4202
|
+
with(...chks) {
|
|
4203
|
+
return this.check(...chks);
|
|
4204
|
+
},
|
|
4205
|
+
clone(def, params) {
|
|
4206
|
+
return clone(this, def, params);
|
|
4207
|
+
},
|
|
4208
|
+
brand() {
|
|
4209
|
+
return this;
|
|
4210
|
+
},
|
|
4211
|
+
register(reg, meta) {
|
|
4212
|
+
reg.add(this, meta);
|
|
4213
|
+
return this;
|
|
4214
|
+
},
|
|
4215
|
+
refine(check, params) {
|
|
4216
|
+
return this.check(refine(check, params));
|
|
4217
|
+
},
|
|
4218
|
+
superRefine(refinement, params) {
|
|
4219
|
+
return this.check(superRefine(refinement, params));
|
|
4220
|
+
},
|
|
4221
|
+
overwrite(fn) {
|
|
4222
|
+
return this.check(_overwrite(fn));
|
|
4223
|
+
},
|
|
4224
|
+
optional() {
|
|
4225
|
+
return optional(this);
|
|
4226
|
+
},
|
|
4227
|
+
exactOptional() {
|
|
4228
|
+
return exactOptional(this);
|
|
4229
|
+
},
|
|
4230
|
+
nullable() {
|
|
4231
|
+
return nullable(this);
|
|
4232
|
+
},
|
|
4233
|
+
nullish() {
|
|
4234
|
+
return optional(nullable(this));
|
|
4235
|
+
},
|
|
4236
|
+
nonoptional(params) {
|
|
4237
|
+
return nonoptional(this, params);
|
|
4238
|
+
},
|
|
4239
|
+
array() {
|
|
4240
|
+
return array(this);
|
|
4241
|
+
},
|
|
4242
|
+
or(arg) {
|
|
4243
|
+
return union([this, arg]);
|
|
4244
|
+
},
|
|
4245
|
+
and(arg) {
|
|
4246
|
+
return intersection(this, arg);
|
|
4247
|
+
},
|
|
4248
|
+
transform(tx) {
|
|
4249
|
+
return pipe(this, transform(tx));
|
|
4250
|
+
},
|
|
4251
|
+
default(d) {
|
|
4252
|
+
return _default(this, d);
|
|
4253
|
+
},
|
|
4254
|
+
prefault(d) {
|
|
4255
|
+
return prefault(this, d);
|
|
4256
|
+
},
|
|
4257
|
+
catch(params) {
|
|
4258
|
+
return _catch(this, params);
|
|
4259
|
+
},
|
|
4260
|
+
pipe(target) {
|
|
4261
|
+
return pipe(this, target);
|
|
4262
|
+
},
|
|
4263
|
+
readonly() {
|
|
4264
|
+
return readonly(this);
|
|
4265
|
+
},
|
|
4266
|
+
describe(description) {
|
|
4267
|
+
const cl = this.clone();
|
|
4268
|
+
globalRegistry.add(cl, { description });
|
|
4269
|
+
return cl;
|
|
4270
|
+
},
|
|
4271
|
+
meta(...args) {
|
|
4272
|
+
if (args.length === 0) return globalRegistry.get(this);
|
|
4273
|
+
const cl = this.clone();
|
|
4274
|
+
globalRegistry.add(cl, args[0]);
|
|
4275
|
+
return cl;
|
|
4276
|
+
},
|
|
4277
|
+
isOptional() {
|
|
4278
|
+
return this.safeParse(void 0).success;
|
|
4279
|
+
},
|
|
4280
|
+
isNullable() {
|
|
4281
|
+
return this.safeParse(null).success;
|
|
4282
|
+
},
|
|
4283
|
+
apply(fn, ...args) {
|
|
4284
|
+
return args.length === 0 ? fn(this) : fn(this, ...args);
|
|
4285
|
+
},
|
|
4286
|
+
get "~standard"() {
|
|
4287
|
+
return hide(this, "~standard", {
|
|
4288
|
+
...standardProps(this),
|
|
4289
|
+
jsonSchema: {
|
|
4290
|
+
input: createStandardJSONSchemaMethod(this, "input"),
|
|
4291
|
+
output: createStandardJSONSchemaMethod(this, "output")
|
|
4292
|
+
}
|
|
4293
|
+
});
|
|
4294
|
+
},
|
|
4295
|
+
set "~standard"(value) {
|
|
4296
|
+
own(this, "~standard", value);
|
|
4297
|
+
},
|
|
4298
|
+
parse: function _parse(data, params) {
|
|
4299
|
+
return parse(this, data, params, { callee: _parse });
|
|
4300
|
+
},
|
|
4301
|
+
parseAsync: async function _parseAsync(data, params) {
|
|
4302
|
+
return await parseAsync(this, data, params, { callee: _parseAsync });
|
|
4303
|
+
},
|
|
4304
|
+
safeParse(data, params) {
|
|
4305
|
+
return safeParse(this, data, params);
|
|
4306
|
+
},
|
|
4307
|
+
async safeParseAsync(data, params) {
|
|
4308
|
+
return safeParseAsync(this, data, params);
|
|
4309
|
+
},
|
|
4310
|
+
get spa() {
|
|
4311
|
+
return this?.safeParseAsync;
|
|
4312
|
+
},
|
|
4313
|
+
set spa(value) {
|
|
4314
|
+
own(this, "spa", value);
|
|
4315
|
+
},
|
|
4316
|
+
validate(data, params) {
|
|
4317
|
+
return validate(this, data, params);
|
|
4318
|
+
},
|
|
4319
|
+
validateAsync(data, params) {
|
|
4320
|
+
return validateAsync$1(this, data, params);
|
|
4321
|
+
},
|
|
4322
|
+
encode: function _encode(data, params) {
|
|
4323
|
+
return encode(this, data, params, { callee: _encode });
|
|
4324
|
+
},
|
|
4325
|
+
decode: function _decode(data, params) {
|
|
4326
|
+
return decode(this, data, params, { callee: _decode });
|
|
4327
|
+
},
|
|
4328
|
+
encodeAsync: async function _encodeAsync(data, params) {
|
|
4329
|
+
return await encodeAsync(this, data, params, { callee: _encodeAsync });
|
|
4330
|
+
},
|
|
4331
|
+
decodeAsync: async function _decodeAsync(data, params) {
|
|
4332
|
+
return await decodeAsync(this, data, params, { callee: _decodeAsync });
|
|
4333
|
+
},
|
|
4334
|
+
safeEncode(data, params) {
|
|
4335
|
+
return safeEncode(this, data, params);
|
|
4336
|
+
},
|
|
4337
|
+
safeDecode(data, params) {
|
|
4338
|
+
return safeDecode(this, data, params);
|
|
4339
|
+
},
|
|
4340
|
+
async safeEncodeAsync(data, params) {
|
|
4341
|
+
return safeEncodeAsync(this, data, params);
|
|
4342
|
+
},
|
|
4343
|
+
async safeDecodeAsync(data, params) {
|
|
4344
|
+
return safeDecodeAsync(this, data, params);
|
|
4345
|
+
},
|
|
4346
|
+
toJSONSchema(params) {
|
|
4347
|
+
return createToJSONSchemaMethod(this, {})(params);
|
|
4348
|
+
},
|
|
4349
|
+
get description() {
|
|
4350
|
+
return globalRegistry.get(this)?.description;
|
|
4351
|
+
},
|
|
4352
|
+
get _def() {
|
|
4353
|
+
return this._zod.def;
|
|
4354
|
+
}
|
|
4355
|
+
});
|
|
4356
|
+
const _ZodString = $constructor("_ZodString", (inst, def) => {
|
|
4357
|
+
$ZodString.init(inst, def);
|
|
4358
|
+
ZodType.init(inst, def);
|
|
4359
|
+
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
4360
|
+
}, derived({
|
|
4361
|
+
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
4362
|
+
minLength: (inst) => aggregateChecks(inst).minimum ?? null,
|
|
4363
|
+
maxLength: (inst) => aggregateChecks(inst).maximum ?? null
|
|
4364
|
+
}, {
|
|
4365
|
+
regex(...args) {
|
|
4366
|
+
return this.check(_regex(...args));
|
|
4367
|
+
},
|
|
4368
|
+
includes(...args) {
|
|
4369
|
+
return this.check(_includes(...args));
|
|
4370
|
+
},
|
|
4371
|
+
startsWith(...args) {
|
|
4372
|
+
return this.check(_startsWith(...args));
|
|
4373
|
+
},
|
|
4374
|
+
endsWith(...args) {
|
|
4375
|
+
return this.check(_endsWith(...args));
|
|
4376
|
+
},
|
|
4377
|
+
min(...args) {
|
|
4378
|
+
return this.check(_minLength(...args));
|
|
4379
|
+
},
|
|
4380
|
+
max(...args) {
|
|
4381
|
+
return this.check(_maxLength(...args));
|
|
4382
|
+
},
|
|
4383
|
+
length(...args) {
|
|
4384
|
+
return this.check(_length(...args));
|
|
4385
|
+
},
|
|
4386
|
+
nonempty(...args) {
|
|
4387
|
+
return this.check(_minLength(1, ...args));
|
|
4388
|
+
},
|
|
4389
|
+
lowercase(params) {
|
|
4390
|
+
return this.check(_lowercase(params));
|
|
4391
|
+
},
|
|
4392
|
+
uppercase(params) {
|
|
4393
|
+
return this.check(_uppercase(params));
|
|
4394
|
+
},
|
|
4395
|
+
trim() {
|
|
4396
|
+
return this.check(_trim());
|
|
4397
|
+
},
|
|
4398
|
+
normalize(...args) {
|
|
4399
|
+
return this.check(_normalize(...args));
|
|
4400
|
+
},
|
|
4401
|
+
toLowerCase() {
|
|
4402
|
+
return this.check(_toLowerCase());
|
|
4403
|
+
},
|
|
4404
|
+
toUpperCase() {
|
|
4405
|
+
return this.check(_toUpperCase());
|
|
4406
|
+
},
|
|
4407
|
+
slugify() {
|
|
4408
|
+
return this.check(_slugify());
|
|
4409
|
+
}
|
|
4410
|
+
}));
|
|
4411
|
+
const ZodString = $constructor("ZodString", (inst, def) => {
|
|
4412
|
+
$ZodString.init(inst, def);
|
|
4413
|
+
_ZodString.init(inst, def);
|
|
4414
|
+
}, {
|
|
4415
|
+
email(params) {
|
|
4416
|
+
return this.check(_email(ZodEmail, params));
|
|
4417
|
+
},
|
|
4418
|
+
url(params) {
|
|
4419
|
+
return this.check(_url(ZodURL, params));
|
|
4420
|
+
},
|
|
4421
|
+
jwt(params) {
|
|
4422
|
+
return this.check(_jwt(ZodJWT, params));
|
|
4423
|
+
},
|
|
4424
|
+
emoji(params) {
|
|
4425
|
+
return this.check(_emoji(ZodEmoji, params));
|
|
4426
|
+
},
|
|
4427
|
+
guid(params) {
|
|
4428
|
+
return this.check(_guid(ZodGUID, params));
|
|
4429
|
+
},
|
|
4430
|
+
uuid(params) {
|
|
4431
|
+
return this.check(_uuid(ZodUUID, params));
|
|
4432
|
+
},
|
|
4433
|
+
uuidv4(params) {
|
|
4434
|
+
return this.check(_uuidv4(ZodUUID, params));
|
|
4435
|
+
},
|
|
4436
|
+
uuidv6(params) {
|
|
4437
|
+
return this.check(_uuidv6(ZodUUID, params));
|
|
4438
|
+
},
|
|
4439
|
+
uuidv7(params) {
|
|
4440
|
+
return this.check(_uuidv7(ZodUUID, params));
|
|
4441
|
+
},
|
|
4442
|
+
nanoid(params) {
|
|
4443
|
+
return this.check(_nanoid(ZodNanoID, params));
|
|
4444
|
+
},
|
|
4445
|
+
cuid(params) {
|
|
4446
|
+
return this.check(_cuid(ZodCUID, params));
|
|
4447
|
+
},
|
|
4448
|
+
cuid2(params) {
|
|
4449
|
+
return this.check(_cuid2(ZodCUID2, params));
|
|
4450
|
+
},
|
|
4451
|
+
ulid(params) {
|
|
4452
|
+
return this.check(_ulid(ZodULID, params));
|
|
4453
|
+
},
|
|
4454
|
+
base64(params) {
|
|
4455
|
+
return this.check(_base64(ZodBase64, params));
|
|
4456
|
+
},
|
|
4457
|
+
base64url(params) {
|
|
4458
|
+
return this.check(_base64url(ZodBase64URL, params));
|
|
4459
|
+
},
|
|
4460
|
+
xid(params) {
|
|
4461
|
+
return this.check(_xid(ZodXID, params));
|
|
4462
|
+
},
|
|
4463
|
+
ksuid(params) {
|
|
4464
|
+
return this.check(_ksuid(ZodKSUID, params));
|
|
4465
|
+
},
|
|
4466
|
+
ipv4(params) {
|
|
4467
|
+
return this.check(_ipv4(ZodIPv4, params));
|
|
4468
|
+
},
|
|
4469
|
+
ipv6(params) {
|
|
4470
|
+
return this.check(_ipv6(ZodIPv6, params));
|
|
4471
|
+
},
|
|
4472
|
+
cidrv4(params) {
|
|
4473
|
+
return this.check(_cidrv4(ZodCIDRv4, params));
|
|
4474
|
+
},
|
|
4475
|
+
cidrv6(params) {
|
|
4476
|
+
return this.check(_cidrv6(ZodCIDRv6, params));
|
|
4477
|
+
},
|
|
4478
|
+
e164(params) {
|
|
4479
|
+
return this.check(_e164(ZodE164, params));
|
|
4480
|
+
},
|
|
4481
|
+
datetime(params) {
|
|
4482
|
+
return this.check(_isoDateTime(ZodISODateTime, params));
|
|
4483
|
+
},
|
|
4484
|
+
date(params) {
|
|
4485
|
+
return this.check(_isoDate(ZodISODate, params));
|
|
4486
|
+
},
|
|
4487
|
+
time(params) {
|
|
4488
|
+
return this.check(_isoTime(ZodISOTime, params));
|
|
4489
|
+
},
|
|
4490
|
+
duration(params) {
|
|
4491
|
+
return this.check(_isoDuration(ZodISODuration, params));
|
|
4492
|
+
}
|
|
4493
|
+
});
|
|
4494
|
+
function string(params) {
|
|
4495
|
+
return _string(ZodString, params);
|
|
4496
|
+
}
|
|
4497
|
+
const ZodStringFormat = $constructor("ZodStringFormat", (inst, def) => {
|
|
4498
|
+
$ZodStringFormat.init(inst, def);
|
|
4499
|
+
_ZodString.init(inst, def);
|
|
4500
|
+
});
|
|
4501
|
+
const ZodISODateTime = $constructor("ZodISODateTime", (inst, def) => {
|
|
4502
|
+
$ZodISODateTime.init(inst, def);
|
|
4503
|
+
ZodStringFormat.init(inst, def);
|
|
4504
|
+
});
|
|
4505
|
+
const ZodISODate = $constructor("ZodISODate", (inst, def) => {
|
|
4506
|
+
$ZodISODate.init(inst, def);
|
|
4507
|
+
ZodStringFormat.init(inst, def);
|
|
4508
|
+
});
|
|
4509
|
+
const ZodISOTime = $constructor("ZodISOTime", (inst, def) => {
|
|
4510
|
+
$ZodISOTime.init(inst, def);
|
|
4511
|
+
ZodStringFormat.init(inst, def);
|
|
4512
|
+
});
|
|
4513
|
+
const ZodISODuration = $constructor("ZodISODuration", (inst, def) => {
|
|
4514
|
+
$ZodISODuration.init(inst, def);
|
|
4515
|
+
ZodStringFormat.init(inst, def);
|
|
4516
|
+
});
|
|
4517
|
+
const ZodEmail = $constructor("ZodEmail", (inst, def) => {
|
|
4518
|
+
$ZodEmail.init(inst, def);
|
|
4519
|
+
ZodStringFormat.init(inst, def);
|
|
4520
|
+
});
|
|
4521
|
+
const ZodGUID = $constructor("ZodGUID", (inst, def) => {
|
|
4522
|
+
$ZodGUID.init(inst, def);
|
|
4523
|
+
ZodStringFormat.init(inst, def);
|
|
4524
|
+
});
|
|
4525
|
+
const ZodUUID = $constructor("ZodUUID", (inst, def) => {
|
|
4526
|
+
$ZodUUID.init(inst, def);
|
|
4527
|
+
ZodStringFormat.init(inst, def);
|
|
4528
|
+
});
|
|
4529
|
+
const ZodURL = $constructor("ZodURL", (inst, def) => {
|
|
4530
|
+
$ZodURL.init(inst, def);
|
|
4531
|
+
ZodStringFormat.init(inst, def);
|
|
4532
|
+
});
|
|
4533
|
+
const ZodEmoji = $constructor("ZodEmoji", (inst, def) => {
|
|
4534
|
+
$ZodEmoji.init(inst, def);
|
|
4535
|
+
ZodStringFormat.init(inst, def);
|
|
4536
|
+
});
|
|
4537
|
+
const ZodNanoID = $constructor("ZodNanoID", (inst, def) => {
|
|
4538
|
+
$ZodNanoID.init(inst, def);
|
|
4539
|
+
ZodStringFormat.init(inst, def);
|
|
4540
|
+
});
|
|
4541
|
+
const ZodCUID = $constructor("ZodCUID", (inst, def) => {
|
|
4542
|
+
$ZodCUID.init(inst, def);
|
|
4543
|
+
ZodStringFormat.init(inst, def);
|
|
4544
|
+
});
|
|
4545
|
+
const ZodCUID2 = $constructor("ZodCUID2", (inst, def) => {
|
|
4546
|
+
$ZodCUID2.init(inst, def);
|
|
4547
|
+
ZodStringFormat.init(inst, def);
|
|
4548
|
+
});
|
|
4549
|
+
const ZodULID = $constructor("ZodULID", (inst, def) => {
|
|
4550
|
+
$ZodULID.init(inst, def);
|
|
4551
|
+
ZodStringFormat.init(inst, def);
|
|
4552
|
+
});
|
|
4553
|
+
const ZodXID = $constructor("ZodXID", (inst, def) => {
|
|
4554
|
+
$ZodXID.init(inst, def);
|
|
4555
|
+
ZodStringFormat.init(inst, def);
|
|
4556
|
+
});
|
|
4557
|
+
const ZodKSUID = $constructor("ZodKSUID", (inst, def) => {
|
|
4558
|
+
$ZodKSUID.init(inst, def);
|
|
4559
|
+
ZodStringFormat.init(inst, def);
|
|
4560
|
+
});
|
|
4561
|
+
const ZodIPv4 = $constructor("ZodIPv4", (inst, def) => {
|
|
4562
|
+
$ZodIPv4.init(inst, def);
|
|
4563
|
+
ZodStringFormat.init(inst, def);
|
|
4564
|
+
});
|
|
4565
|
+
const ZodIPv6 = $constructor("ZodIPv6", (inst, def) => {
|
|
4566
|
+
$ZodIPv6.init(inst, def);
|
|
4567
|
+
ZodStringFormat.init(inst, def);
|
|
4568
|
+
});
|
|
4569
|
+
const ZodCIDRv4 = $constructor("ZodCIDRv4", (inst, def) => {
|
|
4570
|
+
$ZodCIDRv4.init(inst, def);
|
|
4571
|
+
ZodStringFormat.init(inst, def);
|
|
4572
|
+
});
|
|
4573
|
+
const ZodCIDRv6 = $constructor("ZodCIDRv6", (inst, def) => {
|
|
4574
|
+
$ZodCIDRv6.init(inst, def);
|
|
4575
|
+
ZodStringFormat.init(inst, def);
|
|
4576
|
+
});
|
|
4577
|
+
const ZodBase64 = $constructor("ZodBase64", (inst, def) => {
|
|
4578
|
+
$ZodBase64.init(inst, def);
|
|
4579
|
+
ZodStringFormat.init(inst, def);
|
|
4580
|
+
});
|
|
4581
|
+
const ZodBase64URL = $constructor("ZodBase64URL", (inst, def) => {
|
|
4582
|
+
$ZodBase64URL.init(inst, def);
|
|
4583
|
+
ZodStringFormat.init(inst, def);
|
|
4584
|
+
});
|
|
4585
|
+
const ZodE164 = $constructor("ZodE164", (inst, def) => {
|
|
4586
|
+
$ZodE164.init(inst, def);
|
|
4587
|
+
ZodStringFormat.init(inst, def);
|
|
4588
|
+
});
|
|
4589
|
+
const ZodJWT = $constructor("ZodJWT", (inst, def) => {
|
|
4590
|
+
$ZodJWT.init(inst, def);
|
|
4591
|
+
ZodStringFormat.init(inst, def);
|
|
4592
|
+
});
|
|
4593
|
+
const ZodNumber = $constructor("ZodNumber", (inst, def) => {
|
|
4594
|
+
$ZodNumber.init(inst, def);
|
|
4595
|
+
ZodType.init(inst, def);
|
|
4596
|
+
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
4597
|
+
inst.isFinite = true;
|
|
4598
|
+
}, derived({
|
|
4599
|
+
minValue: (inst) => {
|
|
4600
|
+
const { minimum, exclusiveMinimum } = aggregateChecks(inst);
|
|
4601
|
+
return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
|
|
4602
|
+
},
|
|
4603
|
+
maxValue: (inst) => {
|
|
4604
|
+
const { maximum, exclusiveMaximum } = aggregateChecks(inst);
|
|
4605
|
+
return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
|
|
4606
|
+
},
|
|
4607
|
+
isInt: (inst) => {
|
|
4608
|
+
const { isInt, multipleOf } = aggregateChecks(inst);
|
|
4609
|
+
return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
|
|
4610
|
+
},
|
|
4611
|
+
format: (inst) => aggregateChecks(inst).format ?? null
|
|
4612
|
+
}, {
|
|
4613
|
+
gt(value, params) {
|
|
4614
|
+
return this.check(_gt(value, params));
|
|
4615
|
+
},
|
|
4616
|
+
gte(value, params) {
|
|
4617
|
+
return this.check(_gte(value, params));
|
|
4618
|
+
},
|
|
4619
|
+
min(value, params) {
|
|
4620
|
+
return this.check(_gte(value, params));
|
|
4621
|
+
},
|
|
4622
|
+
lt(value, params) {
|
|
4623
|
+
return this.check(_lt(value, params));
|
|
4624
|
+
},
|
|
4625
|
+
lte(value, params) {
|
|
4626
|
+
return this.check(_lte(value, params));
|
|
4627
|
+
},
|
|
4628
|
+
max(value, params) {
|
|
4629
|
+
return this.check(_lte(value, params));
|
|
4630
|
+
},
|
|
4631
|
+
int(params) {
|
|
4632
|
+
return this.check(int(params));
|
|
4633
|
+
},
|
|
4634
|
+
safe(params) {
|
|
4635
|
+
return this.check(int(params));
|
|
4636
|
+
},
|
|
4637
|
+
positive(params) {
|
|
4638
|
+
return this.check(_gt(0, params));
|
|
4639
|
+
},
|
|
4640
|
+
nonnegative(params) {
|
|
4641
|
+
return this.check(_gte(0, params));
|
|
4642
|
+
},
|
|
4643
|
+
negative(params) {
|
|
4644
|
+
return this.check(_lt(0, params));
|
|
4645
|
+
},
|
|
4646
|
+
nonpositive(params) {
|
|
4647
|
+
return this.check(_lte(0, params));
|
|
4648
|
+
},
|
|
4649
|
+
multipleOf(value, params) {
|
|
4650
|
+
return this.check(_multipleOf(value, params));
|
|
4651
|
+
},
|
|
4652
|
+
step(value, params) {
|
|
4653
|
+
return this.check(_multipleOf(value, params));
|
|
4654
|
+
},
|
|
4655
|
+
finite() {
|
|
4656
|
+
return this;
|
|
4657
|
+
}
|
|
4658
|
+
}));
|
|
4659
|
+
function number(params) {
|
|
4660
|
+
return _number(ZodNumber, params);
|
|
4661
|
+
}
|
|
4662
|
+
const ZodNumberFormat = $constructor("ZodNumberFormat", (inst, def) => {
|
|
4663
|
+
$ZodNumberFormat.init(inst, def);
|
|
4664
|
+
ZodNumber.init(inst, def);
|
|
4665
|
+
});
|
|
4666
|
+
function int(params) {
|
|
4667
|
+
return _int(ZodNumberFormat, params);
|
|
4668
|
+
}
|
|
4669
|
+
const ZodBoolean = $constructor("ZodBoolean", (inst, def) => {
|
|
4670
|
+
$ZodBoolean.init(inst, def);
|
|
4671
|
+
ZodType.init(inst, def);
|
|
4672
|
+
inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
|
|
4673
|
+
});
|
|
4674
|
+
function boolean(params) {
|
|
4675
|
+
return _boolean(ZodBoolean, params);
|
|
4676
|
+
}
|
|
4677
|
+
const ZodUnknown = $constructor("ZodUnknown", (inst, def) => {
|
|
4678
|
+
$ZodUnknown.init(inst, def);
|
|
4679
|
+
ZodType.init(inst, def);
|
|
4680
|
+
inst._zod.processJSONSchema = (ctx, json, params) => void 0;
|
|
4681
|
+
});
|
|
4682
|
+
function unknown() {
|
|
4683
|
+
return _unknown(ZodUnknown);
|
|
4684
|
+
}
|
|
4685
|
+
const ZodNever = $constructor("ZodNever", (inst, def) => {
|
|
4686
|
+
$ZodNever.init(inst, def);
|
|
4687
|
+
ZodType.init(inst, def);
|
|
4688
|
+
inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
|
|
4689
|
+
});
|
|
4690
|
+
function never(params) {
|
|
4691
|
+
return _never(ZodNever, params);
|
|
4692
|
+
}
|
|
4693
|
+
const ZodArray = $constructor("ZodArray", (inst, def) => {
|
|
4694
|
+
_ensureDefaultMemoizer();
|
|
4695
|
+
$ZodArray.init(inst, def);
|
|
4696
|
+
ZodType.init(inst, def);
|
|
4697
|
+
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
4698
|
+
inst.element = def.element;
|
|
4699
|
+
}, {
|
|
4700
|
+
min(n, params) {
|
|
4701
|
+
return this.check(_minLength(n, params));
|
|
4702
|
+
},
|
|
4703
|
+
nonempty(params) {
|
|
4704
|
+
return this.check(_minLength(1, params));
|
|
4705
|
+
},
|
|
4706
|
+
max(n, params) {
|
|
4707
|
+
return this.check(_maxLength(n, params));
|
|
4708
|
+
},
|
|
4709
|
+
length(n, params) {
|
|
4710
|
+
return this.check(_length(n, params));
|
|
4711
|
+
},
|
|
4712
|
+
unwrap() {
|
|
4713
|
+
return this.element;
|
|
4714
|
+
}
|
|
4715
|
+
});
|
|
4716
|
+
function array(element, params) {
|
|
4717
|
+
return _array(ZodArray, element, params);
|
|
4718
|
+
}
|
|
4719
|
+
const ZodObject = $constructor("ZodObject", (inst, def) => {
|
|
4720
|
+
_ensureDefaultMemoizer();
|
|
4721
|
+
$ZodObjectJIT.init(inst, def);
|
|
4722
|
+
ZodType.init(inst, def);
|
|
4723
|
+
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
4724
|
+
installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
|
|
4725
|
+
}, {
|
|
4726
|
+
keyof() {
|
|
4727
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
4728
|
+
},
|
|
4729
|
+
catchall(catchall) {
|
|
4730
|
+
return this.clone(mergeDefs(this._zod.def, { catchall }));
|
|
4731
|
+
},
|
|
4732
|
+
passthrough() {
|
|
4733
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
4734
|
+
},
|
|
4735
|
+
loose() {
|
|
4736
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
4737
|
+
},
|
|
4738
|
+
strict() {
|
|
4739
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
|
|
4740
|
+
},
|
|
4741
|
+
strip() {
|
|
4742
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
|
|
4743
|
+
},
|
|
4744
|
+
extend(incoming) {
|
|
4745
|
+
return extend(this, incoming);
|
|
4746
|
+
},
|
|
4747
|
+
safeExtend(incoming) {
|
|
4748
|
+
return safeExtend(this, incoming);
|
|
4749
|
+
},
|
|
4750
|
+
merge(other) {
|
|
4751
|
+
return merge(this, other);
|
|
4752
|
+
},
|
|
4753
|
+
pick(mask) {
|
|
4754
|
+
return pick(this, mask);
|
|
4755
|
+
},
|
|
4756
|
+
omit(mask) {
|
|
4757
|
+
return omit(this, mask);
|
|
4758
|
+
},
|
|
4759
|
+
partial(...args) {
|
|
4760
|
+
return partial(ZodOptional, this, args[0]);
|
|
4761
|
+
},
|
|
4762
|
+
exactPartial(...args) {
|
|
4763
|
+
return partial(ZodExactOptional, this, args[0], "exactPartial");
|
|
4764
|
+
},
|
|
4765
|
+
required(...args) {
|
|
4766
|
+
return required(ZodNonOptional, this, args[0]);
|
|
4767
|
+
}
|
|
4768
|
+
});
|
|
4769
|
+
function object(shape, params) {
|
|
4770
|
+
const def = {
|
|
4771
|
+
type: "object",
|
|
4772
|
+
shape: shape ?? {},
|
|
4773
|
+
...normalizeParams(params)
|
|
4774
|
+
};
|
|
4775
|
+
return new ZodObject(def);
|
|
4776
|
+
}
|
|
4777
|
+
function strictObject(shape, params) {
|
|
4778
|
+
return new ZodObject({
|
|
4779
|
+
type: "object",
|
|
4780
|
+
shape,
|
|
4781
|
+
catchall: never(),
|
|
4782
|
+
...normalizeParams(params)
|
|
4783
|
+
});
|
|
4784
|
+
}
|
|
4785
|
+
const ZodUnion = $constructor("ZodUnion", (inst, def) => {
|
|
4786
|
+
$ZodUnion.init(inst, def);
|
|
4787
|
+
ZodType.init(inst, def);
|
|
4788
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
|
|
4789
|
+
inst.options = def.options;
|
|
4790
|
+
});
|
|
4791
|
+
function union(options, params) {
|
|
4792
|
+
return new ZodUnion({
|
|
4793
|
+
type: "union",
|
|
4794
|
+
options,
|
|
4795
|
+
...normalizeParams(params)
|
|
4796
|
+
});
|
|
4797
|
+
}
|
|
4798
|
+
const ZodIntersection = $constructor("ZodIntersection", (inst, def) => {
|
|
4799
|
+
$ZodIntersection.init(inst, def);
|
|
4800
|
+
ZodType.init(inst, def);
|
|
4801
|
+
inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
|
|
4802
|
+
});
|
|
4803
|
+
function intersection(left, right) {
|
|
4804
|
+
return new ZodIntersection({
|
|
4805
|
+
type: "intersection",
|
|
4806
|
+
left,
|
|
4807
|
+
right
|
|
4808
|
+
});
|
|
4809
|
+
}
|
|
4810
|
+
const ZodEnum = $constructor("ZodEnum", (inst, def) => {
|
|
4811
|
+
$ZodEnum.init(inst, def);
|
|
4812
|
+
ZodType.init(inst, def);
|
|
4813
|
+
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
4814
|
+
inst.enum = def.entries;
|
|
4815
|
+
inst.options = [...inst._zod.values];
|
|
4816
|
+
const keys = new Set(Object.keys(def.entries));
|
|
4817
|
+
inst.extract = (values, params) => {
|
|
4818
|
+
const newEntries = {};
|
|
4819
|
+
for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
|
|
4820
|
+
else throw new Error(`Key ${value} not found in enum`);
|
|
4821
|
+
return new ZodEnum({
|
|
4822
|
+
...def,
|
|
4823
|
+
checks: [],
|
|
4824
|
+
...normalizeParams(params),
|
|
4825
|
+
entries: newEntries
|
|
4826
|
+
});
|
|
4827
|
+
};
|
|
4828
|
+
inst.exclude = (values, params) => {
|
|
4829
|
+
const newEntries = { ...def.entries };
|
|
4830
|
+
for (const value of values) if (keys.has(value)) delete newEntries[value];
|
|
4831
|
+
else throw new Error(`Key ${value} not found in enum`);
|
|
4832
|
+
return new ZodEnum({
|
|
4833
|
+
...def,
|
|
4834
|
+
checks: [],
|
|
4835
|
+
...normalizeParams(params),
|
|
4836
|
+
entries: newEntries
|
|
4837
|
+
});
|
|
4838
|
+
};
|
|
4839
|
+
});
|
|
4840
|
+
function _enum(values, params) {
|
|
4841
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
4842
|
+
return new ZodEnum({
|
|
4843
|
+
type: "enum",
|
|
4844
|
+
entries,
|
|
4845
|
+
...normalizeParams(params)
|
|
4846
|
+
});
|
|
4847
|
+
}
|
|
4848
|
+
const ZodTransform = $constructor("ZodTransform", (inst, def) => {
|
|
4849
|
+
_ensureDefaultMemoizer();
|
|
4850
|
+
$ZodTransform.init(inst, def);
|
|
4851
|
+
ZodType.init(inst, def);
|
|
4852
|
+
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
4853
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
4854
|
+
if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
4855
|
+
payload.addIssue = (issue$1) => {
|
|
4856
|
+
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
|
|
4857
|
+
else {
|
|
4858
|
+
const _issue = issue$1;
|
|
4859
|
+
if (_issue.fatal) _issue.continue = false;
|
|
4860
|
+
_issue.code ?? (_issue.code = "custom");
|
|
4861
|
+
if (!("input" in _issue)) _issue.input = payload.value;
|
|
4862
|
+
_issue.inst ?? (_issue.inst = inst);
|
|
4863
|
+
payload.issues.push(issue(_issue));
|
|
4864
|
+
}
|
|
4865
|
+
};
|
|
4866
|
+
const output = def.transform(payload.value, payload);
|
|
4867
|
+
if (output instanceof Promise) return output.then((output) => {
|
|
4868
|
+
payload.value = output;
|
|
4869
|
+
return payload;
|
|
4870
|
+
});
|
|
4871
|
+
payload.value = output;
|
|
4872
|
+
return payload;
|
|
4873
|
+
};
|
|
4874
|
+
});
|
|
4875
|
+
function transform(fn) {
|
|
4876
|
+
return new ZodTransform({
|
|
4877
|
+
type: "transform",
|
|
4878
|
+
transform: fn
|
|
4879
|
+
});
|
|
4880
|
+
}
|
|
4881
|
+
const ZodOptional = $constructor("ZodOptional", (inst, def) => {
|
|
4882
|
+
$ZodOptional.init(inst, def);
|
|
4883
|
+
ZodType.init(inst, def);
|
|
4884
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
4885
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4886
|
+
});
|
|
4887
|
+
function optional(innerType) {
|
|
4888
|
+
return new ZodOptional({
|
|
4889
|
+
type: "optional",
|
|
4890
|
+
innerType
|
|
4891
|
+
});
|
|
4892
|
+
}
|
|
4893
|
+
const ZodExactOptional = $constructor("ZodExactOptional", (inst, def) => {
|
|
4894
|
+
$ZodExactOptional.init(inst, def);
|
|
4895
|
+
ZodType.init(inst, def);
|
|
4896
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
4897
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4898
|
+
});
|
|
4899
|
+
function exactOptional(innerType) {
|
|
4900
|
+
return new ZodExactOptional({
|
|
4901
|
+
type: "optional",
|
|
4902
|
+
innerType
|
|
4903
|
+
});
|
|
4904
|
+
}
|
|
4905
|
+
const ZodNullable = $constructor("ZodNullable", (inst, def) => {
|
|
4906
|
+
$ZodNullable.init(inst, def);
|
|
4907
|
+
ZodType.init(inst, def);
|
|
4908
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
|
|
4909
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4910
|
+
});
|
|
4911
|
+
function nullable(innerType) {
|
|
4912
|
+
return new ZodNullable({
|
|
4913
|
+
type: "nullable",
|
|
4914
|
+
innerType
|
|
4915
|
+
});
|
|
4916
|
+
}
|
|
4917
|
+
const ZodDefault = $constructor("ZodDefault", (inst, def) => {
|
|
4918
|
+
$ZodDefault.init(inst, def);
|
|
4919
|
+
ZodType.init(inst, def);
|
|
4920
|
+
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
|
|
4921
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4922
|
+
inst.removeDefault = inst.unwrap;
|
|
4923
|
+
});
|
|
4924
|
+
function _default(innerType, defaultValue) {
|
|
4925
|
+
return new ZodDefault({
|
|
4926
|
+
type: "default",
|
|
4927
|
+
innerType,
|
|
4928
|
+
get defaultValue() {
|
|
4929
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
4930
|
+
}
|
|
4931
|
+
});
|
|
4932
|
+
}
|
|
4933
|
+
const ZodPrefault = $constructor("ZodPrefault", (inst, def) => {
|
|
4934
|
+
$ZodPrefault.init(inst, def);
|
|
4935
|
+
ZodType.init(inst, def);
|
|
4936
|
+
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
|
|
4937
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4938
|
+
});
|
|
4939
|
+
function prefault(innerType, defaultValue) {
|
|
4940
|
+
return new ZodPrefault({
|
|
4941
|
+
type: "prefault",
|
|
4942
|
+
innerType,
|
|
4943
|
+
get defaultValue() {
|
|
4944
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
4945
|
+
}
|
|
4946
|
+
});
|
|
4947
|
+
}
|
|
4948
|
+
const ZodNonOptional = $constructor("ZodNonOptional", (inst, def) => {
|
|
4949
|
+
$ZodNonOptional.init(inst, def);
|
|
4950
|
+
ZodType.init(inst, def);
|
|
4951
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
|
|
4952
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4953
|
+
});
|
|
4954
|
+
function nonoptional(innerType, params) {
|
|
4955
|
+
return new ZodNonOptional({
|
|
4956
|
+
type: "nonoptional",
|
|
4957
|
+
innerType,
|
|
4958
|
+
...normalizeParams(params)
|
|
4959
|
+
});
|
|
4960
|
+
}
|
|
4961
|
+
const ZodCatch = $constructor("ZodCatch", (inst, def) => {
|
|
4962
|
+
$ZodCatch.init(inst, def);
|
|
4963
|
+
ZodType.init(inst, def);
|
|
4964
|
+
inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
|
|
4965
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4966
|
+
inst.removeCatch = inst.unwrap;
|
|
4967
|
+
});
|
|
4968
|
+
function _catch(innerType, catchValue) {
|
|
4969
|
+
return new ZodCatch({
|
|
4970
|
+
type: "catch",
|
|
4971
|
+
innerType,
|
|
4972
|
+
catchValue: typeof catchValue === "function" ? catchValue : constantCatch(catchValue)
|
|
4973
|
+
});
|
|
4974
|
+
}
|
|
4975
|
+
const ZodPipe = $constructor("ZodPipe", (inst, def) => {
|
|
4976
|
+
$ZodPipe.init(inst, def);
|
|
4977
|
+
ZodType.init(inst, def);
|
|
4978
|
+
inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
|
|
4979
|
+
inst.in = def.in;
|
|
4980
|
+
inst.out = def.out;
|
|
4981
|
+
});
|
|
4982
|
+
function pipe(in_, out) {
|
|
4983
|
+
return new ZodPipe({
|
|
4984
|
+
type: "pipe",
|
|
4985
|
+
in: in_,
|
|
4986
|
+
out
|
|
4987
|
+
});
|
|
4988
|
+
}
|
|
4989
|
+
const ZodReadonly = $constructor("ZodReadonly", (inst, def) => {
|
|
4990
|
+
$ZodReadonly.init(inst, def);
|
|
4991
|
+
ZodType.init(inst, def);
|
|
4992
|
+
inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
|
|
4993
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4994
|
+
});
|
|
4995
|
+
function readonly(innerType) {
|
|
4996
|
+
return new ZodReadonly({
|
|
4997
|
+
type: "readonly",
|
|
4998
|
+
innerType
|
|
4999
|
+
});
|
|
5000
|
+
}
|
|
5001
|
+
const ZodCustom = $constructor("ZodCustom", (inst, def) => {
|
|
5002
|
+
$ZodCustom.init(inst, def);
|
|
5003
|
+
ZodType.init(inst, def);
|
|
5004
|
+
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
|
|
5005
|
+
});
|
|
5006
|
+
function refine(fn, _params = {}) {
|
|
5007
|
+
return _refine(ZodCustom, fn, _params);
|
|
5008
|
+
}
|
|
5009
|
+
function superRefine(fn, params) {
|
|
5010
|
+
return _superRefine(fn, params);
|
|
5011
|
+
}
|
|
5012
|
+
// build/rpc.js
|
|
5013
|
+
const RPC_ID = "messaging.opencode";
|
|
5014
|
+
const WakeInput = strictObject({
|
|
5015
|
+
sessionID: string().min(1).max(200),
|
|
5016
|
+
envelopeIds: array(string().min(1).max(64)).min(1).max(16)
|
|
5017
|
+
});
|
|
5018
|
+
const WakeOutput = object({ accepted: number().int().nonnegative() });
|
|
5019
|
+
const WakeError = object({}).strict();
|
|
5020
|
+
const ConfigInput = strictObject({});
|
|
5021
|
+
const ConfigOutput = strictObject({
|
|
5022
|
+
home: string().min(1).max(4096),
|
|
5023
|
+
daemon: strictObject({
|
|
5024
|
+
autostart: boolean(),
|
|
5025
|
+
bin: string().min(1).max(4096).optional(),
|
|
5026
|
+
node: string().min(1).max(4096).optional()
|
|
5027
|
+
})
|
|
5028
|
+
});
|
|
5029
|
+
const Messaging = Rpc.define({
|
|
5030
|
+
id: RPC_ID,
|
|
5031
|
+
methods: {
|
|
5032
|
+
wake: {
|
|
5033
|
+
input: WakeInput,
|
|
5034
|
+
output: WakeOutput,
|
|
5035
|
+
errors: {
|
|
5036
|
+
not_found: WakeError,
|
|
5037
|
+
unavailable: WakeError
|
|
5038
|
+
}
|
|
5039
|
+
},
|
|
5040
|
+
config: {
|
|
5041
|
+
input: ConfigInput,
|
|
5042
|
+
output: ConfigOutput
|
|
5043
|
+
}
|
|
5044
|
+
},
|
|
5045
|
+
events: {}
|
|
5046
|
+
});
|
|
5047
|
+
export { Messaging, RPC_ID };
|