@toolu/cli 6.8.1
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/LICENSE +21 -0
- package/README.md +55 -0
- package/assets/marketplace.json +147 -0
- package/dist/cli.js +3713 -0
- package/package.json +43 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,3713 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
// src/cli.ts
|
|
6
|
+
import { constants as constants2 } from "node:fs";
|
|
7
|
+
import { access as access2, readFile as readFile2 } from "node:fs/promises";
|
|
8
|
+
import { dirname, resolve } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
|
|
11
|
+
// src/exit.ts
|
|
12
|
+
var EXIT = {
|
|
13
|
+
ok: 0,
|
|
14
|
+
failed: 1,
|
|
15
|
+
usage: 2,
|
|
16
|
+
missingInput: 3,
|
|
17
|
+
cancelled: 130
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
class CliError extends Error {
|
|
21
|
+
name = "CliError";
|
|
22
|
+
code;
|
|
23
|
+
constructor(code, message) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.code = code;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
class UsageError extends CliError {
|
|
30
|
+
name = "UsageError";
|
|
31
|
+
constructor(message) {
|
|
32
|
+
super(EXIT.usage, message);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/core/core.js
|
|
37
|
+
var NEVER = Object.freeze({
|
|
38
|
+
status: "aborted"
|
|
39
|
+
});
|
|
40
|
+
function $constructor(name, initializer, params) {
|
|
41
|
+
function init(inst, def) {
|
|
42
|
+
var _a;
|
|
43
|
+
Object.defineProperty(inst, "_zod", {
|
|
44
|
+
value: inst._zod ?? {},
|
|
45
|
+
enumerable: false
|
|
46
|
+
});
|
|
47
|
+
(_a = inst._zod).traits ?? (_a.traits = new Set);
|
|
48
|
+
inst._zod.traits.add(name);
|
|
49
|
+
initializer(inst, def);
|
|
50
|
+
for (const k in _.prototype) {
|
|
51
|
+
if (!(k in inst))
|
|
52
|
+
Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
|
|
53
|
+
}
|
|
54
|
+
inst._zod.constr = _;
|
|
55
|
+
inst._zod.def = def;
|
|
56
|
+
}
|
|
57
|
+
const Parent = params?.Parent ?? Object;
|
|
58
|
+
|
|
59
|
+
class Definition extends Parent {
|
|
60
|
+
}
|
|
61
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
62
|
+
function _(def) {
|
|
63
|
+
var _a;
|
|
64
|
+
const inst = params?.Parent ? new Definition : this;
|
|
65
|
+
init(inst, def);
|
|
66
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
67
|
+
for (const fn of inst._zod.deferred) {
|
|
68
|
+
fn();
|
|
69
|
+
}
|
|
70
|
+
return inst;
|
|
71
|
+
}
|
|
72
|
+
Object.defineProperty(_, "init", { value: init });
|
|
73
|
+
Object.defineProperty(_, Symbol.hasInstance, {
|
|
74
|
+
value: (inst) => {
|
|
75
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
76
|
+
return true;
|
|
77
|
+
return inst?._zod?.traits?.has(name);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(_, "name", { value: name });
|
|
81
|
+
return _;
|
|
82
|
+
}
|
|
83
|
+
var $brand = Symbol("zod_brand");
|
|
84
|
+
|
|
85
|
+
class $ZodAsyncError extends Error {
|
|
86
|
+
constructor() {
|
|
87
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
class $ZodEncodeError extends Error {
|
|
92
|
+
constructor(name) {
|
|
93
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
94
|
+
this.name = "ZodEncodeError";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
var globalConfig = {};
|
|
98
|
+
function config(newConfig) {
|
|
99
|
+
if (newConfig)
|
|
100
|
+
Object.assign(globalConfig, newConfig);
|
|
101
|
+
return globalConfig;
|
|
102
|
+
}
|
|
103
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/core/util.js
|
|
104
|
+
function getEnumValues(entries) {
|
|
105
|
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
106
|
+
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
107
|
+
return values;
|
|
108
|
+
}
|
|
109
|
+
function jsonStringifyReplacer(_, value) {
|
|
110
|
+
if (typeof value === "bigint")
|
|
111
|
+
return value.toString();
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
function cached(getter) {
|
|
115
|
+
const set = false;
|
|
116
|
+
return {
|
|
117
|
+
get value() {
|
|
118
|
+
if (!set) {
|
|
119
|
+
const value = getter();
|
|
120
|
+
Object.defineProperty(this, "value", { value });
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
throw new Error("cached value already set");
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function nullish(input) {
|
|
128
|
+
return input === null || input === undefined;
|
|
129
|
+
}
|
|
130
|
+
function cleanRegex(source) {
|
|
131
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
132
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
133
|
+
return source.slice(start, end);
|
|
134
|
+
}
|
|
135
|
+
var EVALUATING = Symbol("evaluating");
|
|
136
|
+
function defineLazy(object, key, getter) {
|
|
137
|
+
let value = undefined;
|
|
138
|
+
Object.defineProperty(object, key, {
|
|
139
|
+
get() {
|
|
140
|
+
if (value === EVALUATING) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (value === undefined) {
|
|
144
|
+
value = EVALUATING;
|
|
145
|
+
value = getter();
|
|
146
|
+
}
|
|
147
|
+
return value;
|
|
148
|
+
},
|
|
149
|
+
set(v) {
|
|
150
|
+
Object.defineProperty(object, key, {
|
|
151
|
+
value: v
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
configurable: true
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function objectClone(obj) {
|
|
158
|
+
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
159
|
+
}
|
|
160
|
+
function assignProp(target, prop, value) {
|
|
161
|
+
Object.defineProperty(target, prop, {
|
|
162
|
+
value,
|
|
163
|
+
writable: true,
|
|
164
|
+
enumerable: true,
|
|
165
|
+
configurable: true
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function mergeDefs(...defs) {
|
|
169
|
+
const mergedDescriptors = {};
|
|
170
|
+
for (const def of defs) {
|
|
171
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
172
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
173
|
+
}
|
|
174
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
175
|
+
}
|
|
176
|
+
function esc(str) {
|
|
177
|
+
return JSON.stringify(str);
|
|
178
|
+
}
|
|
179
|
+
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
180
|
+
function isObject(data) {
|
|
181
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
182
|
+
}
|
|
183
|
+
var allowsEval = cached(() => {
|
|
184
|
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
const F = Function;
|
|
189
|
+
new F("");
|
|
190
|
+
return true;
|
|
191
|
+
} catch (_) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
function isPlainObject(o) {
|
|
196
|
+
if (isObject(o) === false)
|
|
197
|
+
return false;
|
|
198
|
+
const ctor = o.constructor;
|
|
199
|
+
if (ctor === undefined)
|
|
200
|
+
return true;
|
|
201
|
+
const prot = ctor.prototype;
|
|
202
|
+
if (isObject(prot) === false)
|
|
203
|
+
return false;
|
|
204
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
function shallowClone(o) {
|
|
210
|
+
if (isPlainObject(o))
|
|
211
|
+
return { ...o };
|
|
212
|
+
return o;
|
|
213
|
+
}
|
|
214
|
+
var propertyKeyTypes = new Set(["string", "number", "symbol"]);
|
|
215
|
+
var primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
|
|
216
|
+
function escapeRegex(str) {
|
|
217
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
218
|
+
}
|
|
219
|
+
function clone(inst, def, params) {
|
|
220
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
221
|
+
if (!def || params?.parent)
|
|
222
|
+
cl._zod.parent = inst;
|
|
223
|
+
return cl;
|
|
224
|
+
}
|
|
225
|
+
function normalizeParams(_params) {
|
|
226
|
+
const params = _params;
|
|
227
|
+
if (!params)
|
|
228
|
+
return {};
|
|
229
|
+
if (typeof params === "string")
|
|
230
|
+
return { error: () => params };
|
|
231
|
+
if (params?.message !== undefined) {
|
|
232
|
+
if (params?.error !== undefined)
|
|
233
|
+
throw new Error("Cannot specify both `message` and `error` params");
|
|
234
|
+
params.error = params.message;
|
|
235
|
+
}
|
|
236
|
+
delete params.message;
|
|
237
|
+
if (typeof params.error === "string")
|
|
238
|
+
return { ...params, error: () => params.error };
|
|
239
|
+
return params;
|
|
240
|
+
}
|
|
241
|
+
function optionalKeys(shape) {
|
|
242
|
+
return Object.keys(shape).filter((k) => {
|
|
243
|
+
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
var NUMBER_FORMAT_RANGES = {
|
|
247
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
248
|
+
int32: [-2147483648, 2147483647],
|
|
249
|
+
uint32: [0, 4294967295],
|
|
250
|
+
float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000],
|
|
251
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
252
|
+
};
|
|
253
|
+
function pick(schema, mask) {
|
|
254
|
+
const currDef = schema._zod.def;
|
|
255
|
+
const def = mergeDefs(schema._zod.def, {
|
|
256
|
+
get shape() {
|
|
257
|
+
const newShape = {};
|
|
258
|
+
for (const key in mask) {
|
|
259
|
+
if (!(key in currDef.shape)) {
|
|
260
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
261
|
+
}
|
|
262
|
+
if (!mask[key])
|
|
263
|
+
continue;
|
|
264
|
+
newShape[key] = currDef.shape[key];
|
|
265
|
+
}
|
|
266
|
+
assignProp(this, "shape", newShape);
|
|
267
|
+
return newShape;
|
|
268
|
+
},
|
|
269
|
+
checks: []
|
|
270
|
+
});
|
|
271
|
+
return clone(schema, def);
|
|
272
|
+
}
|
|
273
|
+
function omit(schema, mask) {
|
|
274
|
+
const currDef = schema._zod.def;
|
|
275
|
+
const def = mergeDefs(schema._zod.def, {
|
|
276
|
+
get shape() {
|
|
277
|
+
const newShape = { ...schema._zod.def.shape };
|
|
278
|
+
for (const key in mask) {
|
|
279
|
+
if (!(key in currDef.shape)) {
|
|
280
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
281
|
+
}
|
|
282
|
+
if (!mask[key])
|
|
283
|
+
continue;
|
|
284
|
+
delete newShape[key];
|
|
285
|
+
}
|
|
286
|
+
assignProp(this, "shape", newShape);
|
|
287
|
+
return newShape;
|
|
288
|
+
},
|
|
289
|
+
checks: []
|
|
290
|
+
});
|
|
291
|
+
return clone(schema, def);
|
|
292
|
+
}
|
|
293
|
+
function extend(schema, shape) {
|
|
294
|
+
if (!isPlainObject(shape)) {
|
|
295
|
+
throw new Error("Invalid input to extend: expected a plain object");
|
|
296
|
+
}
|
|
297
|
+
const checks = schema._zod.def.checks;
|
|
298
|
+
const hasChecks = checks && checks.length > 0;
|
|
299
|
+
if (hasChecks) {
|
|
300
|
+
throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
|
|
301
|
+
}
|
|
302
|
+
const def = mergeDefs(schema._zod.def, {
|
|
303
|
+
get shape() {
|
|
304
|
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
305
|
+
assignProp(this, "shape", _shape);
|
|
306
|
+
return _shape;
|
|
307
|
+
},
|
|
308
|
+
checks: []
|
|
309
|
+
});
|
|
310
|
+
return clone(schema, def);
|
|
311
|
+
}
|
|
312
|
+
function safeExtend(schema, shape) {
|
|
313
|
+
if (!isPlainObject(shape)) {
|
|
314
|
+
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
315
|
+
}
|
|
316
|
+
const def = {
|
|
317
|
+
...schema._zod.def,
|
|
318
|
+
get shape() {
|
|
319
|
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
320
|
+
assignProp(this, "shape", _shape);
|
|
321
|
+
return _shape;
|
|
322
|
+
},
|
|
323
|
+
checks: schema._zod.def.checks
|
|
324
|
+
};
|
|
325
|
+
return clone(schema, def);
|
|
326
|
+
}
|
|
327
|
+
function merge(a, b) {
|
|
328
|
+
const def = mergeDefs(a._zod.def, {
|
|
329
|
+
get shape() {
|
|
330
|
+
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
331
|
+
assignProp(this, "shape", _shape);
|
|
332
|
+
return _shape;
|
|
333
|
+
},
|
|
334
|
+
get catchall() {
|
|
335
|
+
return b._zod.def.catchall;
|
|
336
|
+
},
|
|
337
|
+
checks: []
|
|
338
|
+
});
|
|
339
|
+
return clone(a, def);
|
|
340
|
+
}
|
|
341
|
+
function partial(Class, schema, mask) {
|
|
342
|
+
const def = mergeDefs(schema._zod.def, {
|
|
343
|
+
get shape() {
|
|
344
|
+
const oldShape = schema._zod.def.shape;
|
|
345
|
+
const shape = { ...oldShape };
|
|
346
|
+
if (mask) {
|
|
347
|
+
for (const key in mask) {
|
|
348
|
+
if (!(key in oldShape)) {
|
|
349
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
350
|
+
}
|
|
351
|
+
if (!mask[key])
|
|
352
|
+
continue;
|
|
353
|
+
shape[key] = Class ? new Class({
|
|
354
|
+
type: "optional",
|
|
355
|
+
innerType: oldShape[key]
|
|
356
|
+
}) : oldShape[key];
|
|
357
|
+
}
|
|
358
|
+
} else {
|
|
359
|
+
for (const key in oldShape) {
|
|
360
|
+
shape[key] = Class ? new Class({
|
|
361
|
+
type: "optional",
|
|
362
|
+
innerType: oldShape[key]
|
|
363
|
+
}) : oldShape[key];
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
assignProp(this, "shape", shape);
|
|
367
|
+
return shape;
|
|
368
|
+
},
|
|
369
|
+
checks: []
|
|
370
|
+
});
|
|
371
|
+
return clone(schema, def);
|
|
372
|
+
}
|
|
373
|
+
function required(Class, schema, mask) {
|
|
374
|
+
const def = mergeDefs(schema._zod.def, {
|
|
375
|
+
get shape() {
|
|
376
|
+
const oldShape = schema._zod.def.shape;
|
|
377
|
+
const shape = { ...oldShape };
|
|
378
|
+
if (mask) {
|
|
379
|
+
for (const key in mask) {
|
|
380
|
+
if (!(key in shape)) {
|
|
381
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
382
|
+
}
|
|
383
|
+
if (!mask[key])
|
|
384
|
+
continue;
|
|
385
|
+
shape[key] = new Class({
|
|
386
|
+
type: "nonoptional",
|
|
387
|
+
innerType: oldShape[key]
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
} else {
|
|
391
|
+
for (const key in oldShape) {
|
|
392
|
+
shape[key] = new Class({
|
|
393
|
+
type: "nonoptional",
|
|
394
|
+
innerType: oldShape[key]
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
assignProp(this, "shape", shape);
|
|
399
|
+
return shape;
|
|
400
|
+
},
|
|
401
|
+
checks: []
|
|
402
|
+
});
|
|
403
|
+
return clone(schema, def);
|
|
404
|
+
}
|
|
405
|
+
function aborted(x, startIndex = 0) {
|
|
406
|
+
if (x.aborted === true)
|
|
407
|
+
return true;
|
|
408
|
+
for (let i = startIndex;i < x.issues.length; i++) {
|
|
409
|
+
if (x.issues[i]?.continue !== true) {
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
function prefixIssues(path, issues) {
|
|
416
|
+
return issues.map((iss) => {
|
|
417
|
+
var _a;
|
|
418
|
+
(_a = iss).path ?? (_a.path = []);
|
|
419
|
+
iss.path.unshift(path);
|
|
420
|
+
return iss;
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
function unwrapMessage(message) {
|
|
424
|
+
return typeof message === "string" ? message : message?.message;
|
|
425
|
+
}
|
|
426
|
+
function finalizeIssue(iss, ctx, config) {
|
|
427
|
+
const full = { ...iss, path: iss.path ?? [] };
|
|
428
|
+
if (!iss.message) {
|
|
429
|
+
const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
|
430
|
+
full.message = message;
|
|
431
|
+
}
|
|
432
|
+
delete full.inst;
|
|
433
|
+
delete full.continue;
|
|
434
|
+
if (!ctx?.reportInput) {
|
|
435
|
+
delete full.input;
|
|
436
|
+
}
|
|
437
|
+
return full;
|
|
438
|
+
}
|
|
439
|
+
function getLengthableOrigin(input) {
|
|
440
|
+
if (Array.isArray(input))
|
|
441
|
+
return "array";
|
|
442
|
+
if (typeof input === "string")
|
|
443
|
+
return "string";
|
|
444
|
+
return "unknown";
|
|
445
|
+
}
|
|
446
|
+
function issue(...args) {
|
|
447
|
+
const [iss, input, inst] = args;
|
|
448
|
+
if (typeof iss === "string") {
|
|
449
|
+
return {
|
|
450
|
+
message: iss,
|
|
451
|
+
code: "custom",
|
|
452
|
+
input,
|
|
453
|
+
inst
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
return { ...iss };
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/core/errors.js
|
|
460
|
+
var initializer = (inst, def) => {
|
|
461
|
+
inst.name = "$ZodError";
|
|
462
|
+
Object.defineProperty(inst, "_zod", {
|
|
463
|
+
value: inst._zod,
|
|
464
|
+
enumerable: false
|
|
465
|
+
});
|
|
466
|
+
Object.defineProperty(inst, "issues", {
|
|
467
|
+
value: def,
|
|
468
|
+
enumerable: false
|
|
469
|
+
});
|
|
470
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
471
|
+
Object.defineProperty(inst, "toString", {
|
|
472
|
+
value: () => inst.message,
|
|
473
|
+
enumerable: false
|
|
474
|
+
});
|
|
475
|
+
};
|
|
476
|
+
var $ZodError = $constructor("$ZodError", initializer);
|
|
477
|
+
var $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
|
|
478
|
+
function flattenError(error, mapper = (issue) => issue.message) {
|
|
479
|
+
const fieldErrors = {};
|
|
480
|
+
const formErrors = [];
|
|
481
|
+
for (const sub of error.issues) {
|
|
482
|
+
if (sub.path.length > 0) {
|
|
483
|
+
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
484
|
+
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
485
|
+
} else {
|
|
486
|
+
formErrors.push(mapper(sub));
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return { formErrors, fieldErrors };
|
|
490
|
+
}
|
|
491
|
+
function formatError(error, _mapper) {
|
|
492
|
+
const mapper = _mapper || function(issue) {
|
|
493
|
+
return issue.message;
|
|
494
|
+
};
|
|
495
|
+
const fieldErrors = { _errors: [] };
|
|
496
|
+
const processError = (error) => {
|
|
497
|
+
for (const issue of error.issues) {
|
|
498
|
+
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
499
|
+
issue.errors.map((issues) => processError({ issues }));
|
|
500
|
+
} else if (issue.code === "invalid_key") {
|
|
501
|
+
processError({ issues: issue.issues });
|
|
502
|
+
} else if (issue.code === "invalid_element") {
|
|
503
|
+
processError({ issues: issue.issues });
|
|
504
|
+
} else if (issue.path.length === 0) {
|
|
505
|
+
fieldErrors._errors.push(mapper(issue));
|
|
506
|
+
} else {
|
|
507
|
+
let curr = fieldErrors;
|
|
508
|
+
let i = 0;
|
|
509
|
+
while (i < issue.path.length) {
|
|
510
|
+
const el = issue.path[i];
|
|
511
|
+
const terminal = i === issue.path.length - 1;
|
|
512
|
+
if (!terminal) {
|
|
513
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
514
|
+
} else {
|
|
515
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
516
|
+
curr[el]._errors.push(mapper(issue));
|
|
517
|
+
}
|
|
518
|
+
curr = curr[el];
|
|
519
|
+
i++;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
processError(error);
|
|
525
|
+
return fieldErrors;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/core/parse.js
|
|
529
|
+
var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
530
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
|
531
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
532
|
+
if (result instanceof Promise) {
|
|
533
|
+
throw new $ZodAsyncError;
|
|
534
|
+
}
|
|
535
|
+
if (result.issues.length) {
|
|
536
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
537
|
+
captureStackTrace(e, _params?.callee);
|
|
538
|
+
throw e;
|
|
539
|
+
}
|
|
540
|
+
return result.value;
|
|
541
|
+
};
|
|
542
|
+
var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
543
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
544
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
545
|
+
if (result instanceof Promise)
|
|
546
|
+
result = await result;
|
|
547
|
+
if (result.issues.length) {
|
|
548
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
549
|
+
captureStackTrace(e, params?.callee);
|
|
550
|
+
throw e;
|
|
551
|
+
}
|
|
552
|
+
return result.value;
|
|
553
|
+
};
|
|
554
|
+
var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
555
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
556
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
557
|
+
if (result instanceof Promise) {
|
|
558
|
+
throw new $ZodAsyncError;
|
|
559
|
+
}
|
|
560
|
+
return result.issues.length ? {
|
|
561
|
+
success: false,
|
|
562
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
563
|
+
} : { success: true, data: result.value };
|
|
564
|
+
};
|
|
565
|
+
var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
566
|
+
var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
567
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
568
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
569
|
+
if (result instanceof Promise)
|
|
570
|
+
result = await result;
|
|
571
|
+
return result.issues.length ? {
|
|
572
|
+
success: false,
|
|
573
|
+
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
574
|
+
} : { success: true, data: result.value };
|
|
575
|
+
};
|
|
576
|
+
var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
577
|
+
var _encode = (_Err) => (schema, value, _ctx) => {
|
|
578
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
579
|
+
return _parse(_Err)(schema, value, ctx);
|
|
580
|
+
};
|
|
581
|
+
var _decode = (_Err) => (schema, value, _ctx) => {
|
|
582
|
+
return _parse(_Err)(schema, value, _ctx);
|
|
583
|
+
};
|
|
584
|
+
var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
585
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
586
|
+
return _parseAsync(_Err)(schema, value, ctx);
|
|
587
|
+
};
|
|
588
|
+
var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
589
|
+
return _parseAsync(_Err)(schema, value, _ctx);
|
|
590
|
+
};
|
|
591
|
+
var _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
592
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
593
|
+
return _safeParse(_Err)(schema, value, ctx);
|
|
594
|
+
};
|
|
595
|
+
var _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
596
|
+
return _safeParse(_Err)(schema, value, _ctx);
|
|
597
|
+
};
|
|
598
|
+
var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
599
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
600
|
+
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
601
|
+
};
|
|
602
|
+
var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
603
|
+
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
604
|
+
};
|
|
605
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/core/regexes.js
|
|
606
|
+
var cuid = /^[cC][^\s-]{8,}$/;
|
|
607
|
+
var cuid2 = /^[0-9a-z]+$/;
|
|
608
|
+
var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
609
|
+
var xid = /^[0-9a-vA-V]{20}$/;
|
|
610
|
+
var ksuid = /^[A-Za-z0-9]{27}$/;
|
|
611
|
+
var nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
612
|
+
var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
613
|
+
var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
614
|
+
var uuid = (version) => {
|
|
615
|
+
if (!version)
|
|
616
|
+
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)$/;
|
|
617
|
+
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})$`);
|
|
618
|
+
};
|
|
619
|
+
var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
620
|
+
var _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
621
|
+
function emoji() {
|
|
622
|
+
return new RegExp(_emoji, "u");
|
|
623
|
+
}
|
|
624
|
+
var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
625
|
+
var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/;
|
|
626
|
+
var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
627
|
+
var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
628
|
+
var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
629
|
+
var base64url = /^[A-Za-z0-9_-]*$/;
|
|
630
|
+
var hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
631
|
+
var e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
632
|
+
var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
633
|
+
var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
634
|
+
function timeSource(args) {
|
|
635
|
+
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
636
|
+
const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
637
|
+
return regex;
|
|
638
|
+
}
|
|
639
|
+
function time(args) {
|
|
640
|
+
return new RegExp(`^${timeSource(args)}$`);
|
|
641
|
+
}
|
|
642
|
+
function datetime(args) {
|
|
643
|
+
const time = timeSource({ precision: args.precision });
|
|
644
|
+
const opts = ["Z"];
|
|
645
|
+
if (args.local)
|
|
646
|
+
opts.push("");
|
|
647
|
+
if (args.offset)
|
|
648
|
+
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
649
|
+
const timeRegex = `${time}(?:${opts.join("|")})`;
|
|
650
|
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
651
|
+
}
|
|
652
|
+
var string = (params) => {
|
|
653
|
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
654
|
+
return new RegExp(`^${regex}$`);
|
|
655
|
+
};
|
|
656
|
+
var boolean = /true|false/i;
|
|
657
|
+
var lowercase = /^[^A-Z]*$/;
|
|
658
|
+
var uppercase = /^[^a-z]*$/;
|
|
659
|
+
|
|
660
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/core/checks.js
|
|
661
|
+
var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
662
|
+
var _a;
|
|
663
|
+
inst._zod ?? (inst._zod = {});
|
|
664
|
+
inst._zod.def = def;
|
|
665
|
+
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
666
|
+
});
|
|
667
|
+
var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
668
|
+
var _a;
|
|
669
|
+
$ZodCheck.init(inst, def);
|
|
670
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
671
|
+
const val = payload.value;
|
|
672
|
+
return !nullish(val) && val.length !== undefined;
|
|
673
|
+
});
|
|
674
|
+
inst._zod.onattach.push((inst) => {
|
|
675
|
+
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
676
|
+
if (def.maximum < curr)
|
|
677
|
+
inst._zod.bag.maximum = def.maximum;
|
|
678
|
+
});
|
|
679
|
+
inst._zod.check = (payload) => {
|
|
680
|
+
const input = payload.value;
|
|
681
|
+
const length = input.length;
|
|
682
|
+
if (length <= def.maximum)
|
|
683
|
+
return;
|
|
684
|
+
const origin = getLengthableOrigin(input);
|
|
685
|
+
payload.issues.push({
|
|
686
|
+
origin,
|
|
687
|
+
code: "too_big",
|
|
688
|
+
maximum: def.maximum,
|
|
689
|
+
inclusive: true,
|
|
690
|
+
input,
|
|
691
|
+
inst,
|
|
692
|
+
continue: !def.abort
|
|
693
|
+
});
|
|
694
|
+
};
|
|
695
|
+
});
|
|
696
|
+
var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
697
|
+
var _a;
|
|
698
|
+
$ZodCheck.init(inst, def);
|
|
699
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
700
|
+
const val = payload.value;
|
|
701
|
+
return !nullish(val) && val.length !== undefined;
|
|
702
|
+
});
|
|
703
|
+
inst._zod.onattach.push((inst) => {
|
|
704
|
+
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
705
|
+
if (def.minimum > curr)
|
|
706
|
+
inst._zod.bag.minimum = def.minimum;
|
|
707
|
+
});
|
|
708
|
+
inst._zod.check = (payload) => {
|
|
709
|
+
const input = payload.value;
|
|
710
|
+
const length = input.length;
|
|
711
|
+
if (length >= def.minimum)
|
|
712
|
+
return;
|
|
713
|
+
const origin = getLengthableOrigin(input);
|
|
714
|
+
payload.issues.push({
|
|
715
|
+
origin,
|
|
716
|
+
code: "too_small",
|
|
717
|
+
minimum: def.minimum,
|
|
718
|
+
inclusive: true,
|
|
719
|
+
input,
|
|
720
|
+
inst,
|
|
721
|
+
continue: !def.abort
|
|
722
|
+
});
|
|
723
|
+
};
|
|
724
|
+
});
|
|
725
|
+
var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
726
|
+
var _a;
|
|
727
|
+
$ZodCheck.init(inst, def);
|
|
728
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
729
|
+
const val = payload.value;
|
|
730
|
+
return !nullish(val) && val.length !== undefined;
|
|
731
|
+
});
|
|
732
|
+
inst._zod.onattach.push((inst) => {
|
|
733
|
+
const bag = inst._zod.bag;
|
|
734
|
+
bag.minimum = def.length;
|
|
735
|
+
bag.maximum = def.length;
|
|
736
|
+
bag.length = def.length;
|
|
737
|
+
});
|
|
738
|
+
inst._zod.check = (payload) => {
|
|
739
|
+
const input = payload.value;
|
|
740
|
+
const length = input.length;
|
|
741
|
+
if (length === def.length)
|
|
742
|
+
return;
|
|
743
|
+
const origin = getLengthableOrigin(input);
|
|
744
|
+
const tooBig = length > def.length;
|
|
745
|
+
payload.issues.push({
|
|
746
|
+
origin,
|
|
747
|
+
...tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length },
|
|
748
|
+
inclusive: true,
|
|
749
|
+
exact: true,
|
|
750
|
+
input: payload.value,
|
|
751
|
+
inst,
|
|
752
|
+
continue: !def.abort
|
|
753
|
+
});
|
|
754
|
+
};
|
|
755
|
+
});
|
|
756
|
+
var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
757
|
+
var _a, _b;
|
|
758
|
+
$ZodCheck.init(inst, def);
|
|
759
|
+
inst._zod.onattach.push((inst) => {
|
|
760
|
+
const bag = inst._zod.bag;
|
|
761
|
+
bag.format = def.format;
|
|
762
|
+
if (def.pattern) {
|
|
763
|
+
bag.patterns ?? (bag.patterns = new Set);
|
|
764
|
+
bag.patterns.add(def.pattern);
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
if (def.pattern)
|
|
768
|
+
(_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
769
|
+
def.pattern.lastIndex = 0;
|
|
770
|
+
if (def.pattern.test(payload.value))
|
|
771
|
+
return;
|
|
772
|
+
payload.issues.push({
|
|
773
|
+
origin: "string",
|
|
774
|
+
code: "invalid_format",
|
|
775
|
+
format: def.format,
|
|
776
|
+
input: payload.value,
|
|
777
|
+
...def.pattern ? { pattern: def.pattern.toString() } : {},
|
|
778
|
+
inst,
|
|
779
|
+
continue: !def.abort
|
|
780
|
+
});
|
|
781
|
+
});
|
|
782
|
+
else
|
|
783
|
+
(_b = inst._zod).check ?? (_b.check = () => {});
|
|
784
|
+
});
|
|
785
|
+
var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
786
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
787
|
+
inst._zod.check = (payload) => {
|
|
788
|
+
def.pattern.lastIndex = 0;
|
|
789
|
+
if (def.pattern.test(payload.value))
|
|
790
|
+
return;
|
|
791
|
+
payload.issues.push({
|
|
792
|
+
origin: "string",
|
|
793
|
+
code: "invalid_format",
|
|
794
|
+
format: "regex",
|
|
795
|
+
input: payload.value,
|
|
796
|
+
pattern: def.pattern.toString(),
|
|
797
|
+
inst,
|
|
798
|
+
continue: !def.abort
|
|
799
|
+
});
|
|
800
|
+
};
|
|
801
|
+
});
|
|
802
|
+
var $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
803
|
+
def.pattern ?? (def.pattern = lowercase);
|
|
804
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
805
|
+
});
|
|
806
|
+
var $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
807
|
+
def.pattern ?? (def.pattern = uppercase);
|
|
808
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
809
|
+
});
|
|
810
|
+
var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
811
|
+
$ZodCheck.init(inst, def);
|
|
812
|
+
const escapedRegex = escapeRegex(def.includes);
|
|
813
|
+
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
814
|
+
def.pattern = pattern;
|
|
815
|
+
inst._zod.onattach.push((inst) => {
|
|
816
|
+
const bag = inst._zod.bag;
|
|
817
|
+
bag.patterns ?? (bag.patterns = new Set);
|
|
818
|
+
bag.patterns.add(pattern);
|
|
819
|
+
});
|
|
820
|
+
inst._zod.check = (payload) => {
|
|
821
|
+
if (payload.value.includes(def.includes, def.position))
|
|
822
|
+
return;
|
|
823
|
+
payload.issues.push({
|
|
824
|
+
origin: "string",
|
|
825
|
+
code: "invalid_format",
|
|
826
|
+
format: "includes",
|
|
827
|
+
includes: def.includes,
|
|
828
|
+
input: payload.value,
|
|
829
|
+
inst,
|
|
830
|
+
continue: !def.abort
|
|
831
|
+
});
|
|
832
|
+
};
|
|
833
|
+
});
|
|
834
|
+
var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
835
|
+
$ZodCheck.init(inst, def);
|
|
836
|
+
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
837
|
+
def.pattern ?? (def.pattern = pattern);
|
|
838
|
+
inst._zod.onattach.push((inst) => {
|
|
839
|
+
const bag = inst._zod.bag;
|
|
840
|
+
bag.patterns ?? (bag.patterns = new Set);
|
|
841
|
+
bag.patterns.add(pattern);
|
|
842
|
+
});
|
|
843
|
+
inst._zod.check = (payload) => {
|
|
844
|
+
if (payload.value.startsWith(def.prefix))
|
|
845
|
+
return;
|
|
846
|
+
payload.issues.push({
|
|
847
|
+
origin: "string",
|
|
848
|
+
code: "invalid_format",
|
|
849
|
+
format: "starts_with",
|
|
850
|
+
prefix: def.prefix,
|
|
851
|
+
input: payload.value,
|
|
852
|
+
inst,
|
|
853
|
+
continue: !def.abort
|
|
854
|
+
});
|
|
855
|
+
};
|
|
856
|
+
});
|
|
857
|
+
var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
858
|
+
$ZodCheck.init(inst, def);
|
|
859
|
+
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
860
|
+
def.pattern ?? (def.pattern = pattern);
|
|
861
|
+
inst._zod.onattach.push((inst) => {
|
|
862
|
+
const bag = inst._zod.bag;
|
|
863
|
+
bag.patterns ?? (bag.patterns = new Set);
|
|
864
|
+
bag.patterns.add(pattern);
|
|
865
|
+
});
|
|
866
|
+
inst._zod.check = (payload) => {
|
|
867
|
+
if (payload.value.endsWith(def.suffix))
|
|
868
|
+
return;
|
|
869
|
+
payload.issues.push({
|
|
870
|
+
origin: "string",
|
|
871
|
+
code: "invalid_format",
|
|
872
|
+
format: "ends_with",
|
|
873
|
+
suffix: def.suffix,
|
|
874
|
+
input: payload.value,
|
|
875
|
+
inst,
|
|
876
|
+
continue: !def.abort
|
|
877
|
+
});
|
|
878
|
+
};
|
|
879
|
+
});
|
|
880
|
+
var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
881
|
+
$ZodCheck.init(inst, def);
|
|
882
|
+
inst._zod.check = (payload) => {
|
|
883
|
+
payload.value = def.tx(payload.value);
|
|
884
|
+
};
|
|
885
|
+
});
|
|
886
|
+
|
|
887
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/core/doc.js
|
|
888
|
+
class Doc {
|
|
889
|
+
constructor(args = []) {
|
|
890
|
+
this.content = [];
|
|
891
|
+
this.indent = 0;
|
|
892
|
+
if (this)
|
|
893
|
+
this.args = args;
|
|
894
|
+
}
|
|
895
|
+
indented(fn) {
|
|
896
|
+
this.indent += 1;
|
|
897
|
+
fn(this);
|
|
898
|
+
this.indent -= 1;
|
|
899
|
+
}
|
|
900
|
+
write(arg) {
|
|
901
|
+
if (typeof arg === "function") {
|
|
902
|
+
arg(this, { execution: "sync" });
|
|
903
|
+
arg(this, { execution: "async" });
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
const content = arg;
|
|
907
|
+
const lines = content.split(`
|
|
908
|
+
`).filter((x) => x);
|
|
909
|
+
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
|
|
910
|
+
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
|
|
911
|
+
for (const line of dedented) {
|
|
912
|
+
this.content.push(line);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
compile() {
|
|
916
|
+
const F = Function;
|
|
917
|
+
const args = this?.args;
|
|
918
|
+
const content = this?.content ?? [``];
|
|
919
|
+
const lines = [...content.map((x) => ` ${x}`)];
|
|
920
|
+
return new F(...args, lines.join(`
|
|
921
|
+
`));
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/core/versions.js
|
|
926
|
+
var version = {
|
|
927
|
+
major: 4,
|
|
928
|
+
minor: 1,
|
|
929
|
+
patch: 5
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/core/schemas.js
|
|
933
|
+
var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
934
|
+
var _a;
|
|
935
|
+
inst ?? (inst = {});
|
|
936
|
+
inst._zod.def = def;
|
|
937
|
+
inst._zod.bag = inst._zod.bag || {};
|
|
938
|
+
inst._zod.version = version;
|
|
939
|
+
const checks = [...inst._zod.def.checks ?? []];
|
|
940
|
+
if (inst._zod.traits.has("$ZodCheck")) {
|
|
941
|
+
checks.unshift(inst);
|
|
942
|
+
}
|
|
943
|
+
for (const ch of checks) {
|
|
944
|
+
for (const fn of ch._zod.onattach) {
|
|
945
|
+
fn(inst);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
if (checks.length === 0) {
|
|
949
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
950
|
+
inst._zod.deferred?.push(() => {
|
|
951
|
+
inst._zod.run = inst._zod.parse;
|
|
952
|
+
});
|
|
953
|
+
} else {
|
|
954
|
+
const runChecks = (payload, checks, ctx) => {
|
|
955
|
+
let isAborted = aborted(payload);
|
|
956
|
+
let asyncResult;
|
|
957
|
+
for (const ch of checks) {
|
|
958
|
+
if (ch._zod.def.when) {
|
|
959
|
+
const shouldRun = ch._zod.def.when(payload);
|
|
960
|
+
if (!shouldRun)
|
|
961
|
+
continue;
|
|
962
|
+
} else if (isAborted) {
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
const currLen = payload.issues.length;
|
|
966
|
+
const _ = ch._zod.check(payload);
|
|
967
|
+
if (_ instanceof Promise && ctx?.async === false) {
|
|
968
|
+
throw new $ZodAsyncError;
|
|
969
|
+
}
|
|
970
|
+
if (asyncResult || _ instanceof Promise) {
|
|
971
|
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
972
|
+
await _;
|
|
973
|
+
const nextLen = payload.issues.length;
|
|
974
|
+
if (nextLen === currLen)
|
|
975
|
+
return;
|
|
976
|
+
if (!isAborted)
|
|
977
|
+
isAborted = aborted(payload, currLen);
|
|
978
|
+
});
|
|
979
|
+
} else {
|
|
980
|
+
const nextLen = payload.issues.length;
|
|
981
|
+
if (nextLen === currLen)
|
|
982
|
+
continue;
|
|
983
|
+
if (!isAborted)
|
|
984
|
+
isAborted = aborted(payload, currLen);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
if (asyncResult) {
|
|
988
|
+
return asyncResult.then(() => {
|
|
989
|
+
return payload;
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
return payload;
|
|
993
|
+
};
|
|
994
|
+
const handleCanaryResult = (canary, payload, ctx) => {
|
|
995
|
+
if (aborted(canary)) {
|
|
996
|
+
canary.aborted = true;
|
|
997
|
+
return canary;
|
|
998
|
+
}
|
|
999
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
1000
|
+
if (checkResult instanceof Promise) {
|
|
1001
|
+
if (ctx.async === false)
|
|
1002
|
+
throw new $ZodAsyncError;
|
|
1003
|
+
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
|
1004
|
+
}
|
|
1005
|
+
return inst._zod.parse(checkResult, ctx);
|
|
1006
|
+
};
|
|
1007
|
+
inst._zod.run = (payload, ctx) => {
|
|
1008
|
+
if (ctx.skipChecks) {
|
|
1009
|
+
return inst._zod.parse(payload, ctx);
|
|
1010
|
+
}
|
|
1011
|
+
if (ctx.direction === "backward") {
|
|
1012
|
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
1013
|
+
if (canary instanceof Promise) {
|
|
1014
|
+
return canary.then((canary) => {
|
|
1015
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
1019
|
+
}
|
|
1020
|
+
const result = inst._zod.parse(payload, ctx);
|
|
1021
|
+
if (result instanceof Promise) {
|
|
1022
|
+
if (ctx.async === false)
|
|
1023
|
+
throw new $ZodAsyncError;
|
|
1024
|
+
return result.then((result) => runChecks(result, checks, ctx));
|
|
1025
|
+
}
|
|
1026
|
+
return runChecks(result, checks, ctx);
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
inst["~standard"] = {
|
|
1030
|
+
validate: (value) => {
|
|
1031
|
+
try {
|
|
1032
|
+
const r = safeParse(inst, value);
|
|
1033
|
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
1034
|
+
} catch (_) {
|
|
1035
|
+
return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
1036
|
+
}
|
|
1037
|
+
},
|
|
1038
|
+
vendor: "zod",
|
|
1039
|
+
version: 1
|
|
1040
|
+
};
|
|
1041
|
+
});
|
|
1042
|
+
var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
1043
|
+
$ZodType.init(inst, def);
|
|
1044
|
+
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
|
|
1045
|
+
inst._zod.parse = (payload, _) => {
|
|
1046
|
+
if (def.coerce)
|
|
1047
|
+
try {
|
|
1048
|
+
payload.value = String(payload.value);
|
|
1049
|
+
} catch (_) {}
|
|
1050
|
+
if (typeof payload.value === "string")
|
|
1051
|
+
return payload;
|
|
1052
|
+
payload.issues.push({
|
|
1053
|
+
expected: "string",
|
|
1054
|
+
code: "invalid_type",
|
|
1055
|
+
input: payload.value,
|
|
1056
|
+
inst
|
|
1057
|
+
});
|
|
1058
|
+
return payload;
|
|
1059
|
+
};
|
|
1060
|
+
});
|
|
1061
|
+
var $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
|
|
1062
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1063
|
+
$ZodString.init(inst, def);
|
|
1064
|
+
});
|
|
1065
|
+
var $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
|
|
1066
|
+
def.pattern ?? (def.pattern = guid);
|
|
1067
|
+
$ZodStringFormat.init(inst, def);
|
|
1068
|
+
});
|
|
1069
|
+
var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
1070
|
+
if (def.version) {
|
|
1071
|
+
const versionMap = {
|
|
1072
|
+
v1: 1,
|
|
1073
|
+
v2: 2,
|
|
1074
|
+
v3: 3,
|
|
1075
|
+
v4: 4,
|
|
1076
|
+
v5: 5,
|
|
1077
|
+
v6: 6,
|
|
1078
|
+
v7: 7,
|
|
1079
|
+
v8: 8
|
|
1080
|
+
};
|
|
1081
|
+
const v = versionMap[def.version];
|
|
1082
|
+
if (v === undefined)
|
|
1083
|
+
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
1084
|
+
def.pattern ?? (def.pattern = uuid(v));
|
|
1085
|
+
} else
|
|
1086
|
+
def.pattern ?? (def.pattern = uuid());
|
|
1087
|
+
$ZodStringFormat.init(inst, def);
|
|
1088
|
+
});
|
|
1089
|
+
var $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
|
|
1090
|
+
def.pattern ?? (def.pattern = email);
|
|
1091
|
+
$ZodStringFormat.init(inst, def);
|
|
1092
|
+
});
|
|
1093
|
+
var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
1094
|
+
$ZodStringFormat.init(inst, def);
|
|
1095
|
+
inst._zod.check = (payload) => {
|
|
1096
|
+
try {
|
|
1097
|
+
const trimmed = payload.value.trim();
|
|
1098
|
+
const url = new URL(trimmed);
|
|
1099
|
+
if (def.hostname) {
|
|
1100
|
+
def.hostname.lastIndex = 0;
|
|
1101
|
+
if (!def.hostname.test(url.hostname)) {
|
|
1102
|
+
payload.issues.push({
|
|
1103
|
+
code: "invalid_format",
|
|
1104
|
+
format: "url",
|
|
1105
|
+
note: "Invalid hostname",
|
|
1106
|
+
pattern: hostname.source,
|
|
1107
|
+
input: payload.value,
|
|
1108
|
+
inst,
|
|
1109
|
+
continue: !def.abort
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
if (def.protocol) {
|
|
1114
|
+
def.protocol.lastIndex = 0;
|
|
1115
|
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
|
|
1116
|
+
payload.issues.push({
|
|
1117
|
+
code: "invalid_format",
|
|
1118
|
+
format: "url",
|
|
1119
|
+
note: "Invalid protocol",
|
|
1120
|
+
pattern: def.protocol.source,
|
|
1121
|
+
input: payload.value,
|
|
1122
|
+
inst,
|
|
1123
|
+
continue: !def.abort
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
if (def.normalize) {
|
|
1128
|
+
payload.value = url.href;
|
|
1129
|
+
} else {
|
|
1130
|
+
payload.value = trimmed;
|
|
1131
|
+
}
|
|
1132
|
+
return;
|
|
1133
|
+
} catch (_) {
|
|
1134
|
+
payload.issues.push({
|
|
1135
|
+
code: "invalid_format",
|
|
1136
|
+
format: "url",
|
|
1137
|
+
input: payload.value,
|
|
1138
|
+
inst,
|
|
1139
|
+
continue: !def.abort
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
};
|
|
1143
|
+
});
|
|
1144
|
+
var $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
|
|
1145
|
+
def.pattern ?? (def.pattern = emoji());
|
|
1146
|
+
$ZodStringFormat.init(inst, def);
|
|
1147
|
+
});
|
|
1148
|
+
var $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
|
|
1149
|
+
def.pattern ?? (def.pattern = nanoid);
|
|
1150
|
+
$ZodStringFormat.init(inst, def);
|
|
1151
|
+
});
|
|
1152
|
+
var $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
|
|
1153
|
+
def.pattern ?? (def.pattern = cuid);
|
|
1154
|
+
$ZodStringFormat.init(inst, def);
|
|
1155
|
+
});
|
|
1156
|
+
var $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
|
|
1157
|
+
def.pattern ?? (def.pattern = cuid2);
|
|
1158
|
+
$ZodStringFormat.init(inst, def);
|
|
1159
|
+
});
|
|
1160
|
+
var $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
|
|
1161
|
+
def.pattern ?? (def.pattern = ulid);
|
|
1162
|
+
$ZodStringFormat.init(inst, def);
|
|
1163
|
+
});
|
|
1164
|
+
var $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
|
|
1165
|
+
def.pattern ?? (def.pattern = xid);
|
|
1166
|
+
$ZodStringFormat.init(inst, def);
|
|
1167
|
+
});
|
|
1168
|
+
var $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
|
|
1169
|
+
def.pattern ?? (def.pattern = ksuid);
|
|
1170
|
+
$ZodStringFormat.init(inst, def);
|
|
1171
|
+
});
|
|
1172
|
+
var $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
|
|
1173
|
+
def.pattern ?? (def.pattern = datetime(def));
|
|
1174
|
+
$ZodStringFormat.init(inst, def);
|
|
1175
|
+
});
|
|
1176
|
+
var $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
|
|
1177
|
+
def.pattern ?? (def.pattern = date);
|
|
1178
|
+
$ZodStringFormat.init(inst, def);
|
|
1179
|
+
});
|
|
1180
|
+
var $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
|
|
1181
|
+
def.pattern ?? (def.pattern = time(def));
|
|
1182
|
+
$ZodStringFormat.init(inst, def);
|
|
1183
|
+
});
|
|
1184
|
+
var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
|
|
1185
|
+
def.pattern ?? (def.pattern = duration);
|
|
1186
|
+
$ZodStringFormat.init(inst, def);
|
|
1187
|
+
});
|
|
1188
|
+
var $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
|
|
1189
|
+
def.pattern ?? (def.pattern = ipv4);
|
|
1190
|
+
$ZodStringFormat.init(inst, def);
|
|
1191
|
+
inst._zod.onattach.push((inst) => {
|
|
1192
|
+
const bag = inst._zod.bag;
|
|
1193
|
+
bag.format = `ipv4`;
|
|
1194
|
+
});
|
|
1195
|
+
});
|
|
1196
|
+
var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
1197
|
+
def.pattern ?? (def.pattern = ipv6);
|
|
1198
|
+
$ZodStringFormat.init(inst, def);
|
|
1199
|
+
inst._zod.onattach.push((inst) => {
|
|
1200
|
+
const bag = inst._zod.bag;
|
|
1201
|
+
bag.format = `ipv6`;
|
|
1202
|
+
});
|
|
1203
|
+
inst._zod.check = (payload) => {
|
|
1204
|
+
try {
|
|
1205
|
+
new URL(`http://[${payload.value}]`);
|
|
1206
|
+
} catch {
|
|
1207
|
+
payload.issues.push({
|
|
1208
|
+
code: "invalid_format",
|
|
1209
|
+
format: "ipv6",
|
|
1210
|
+
input: payload.value,
|
|
1211
|
+
inst,
|
|
1212
|
+
continue: !def.abort
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
});
|
|
1217
|
+
var $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
1218
|
+
def.pattern ?? (def.pattern = cidrv4);
|
|
1219
|
+
$ZodStringFormat.init(inst, def);
|
|
1220
|
+
});
|
|
1221
|
+
var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
1222
|
+
def.pattern ?? (def.pattern = cidrv6);
|
|
1223
|
+
$ZodStringFormat.init(inst, def);
|
|
1224
|
+
inst._zod.check = (payload) => {
|
|
1225
|
+
const [address, prefix] = payload.value.split("/");
|
|
1226
|
+
try {
|
|
1227
|
+
if (!prefix)
|
|
1228
|
+
throw new Error;
|
|
1229
|
+
const prefixNum = Number(prefix);
|
|
1230
|
+
if (`${prefixNum}` !== prefix)
|
|
1231
|
+
throw new Error;
|
|
1232
|
+
if (prefixNum < 0 || prefixNum > 128)
|
|
1233
|
+
throw new Error;
|
|
1234
|
+
new URL(`http://[${address}]`);
|
|
1235
|
+
} catch {
|
|
1236
|
+
payload.issues.push({
|
|
1237
|
+
code: "invalid_format",
|
|
1238
|
+
format: "cidrv6",
|
|
1239
|
+
input: payload.value,
|
|
1240
|
+
inst,
|
|
1241
|
+
continue: !def.abort
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
});
|
|
1246
|
+
function isValidBase64(data) {
|
|
1247
|
+
if (data === "")
|
|
1248
|
+
return true;
|
|
1249
|
+
if (data.length % 4 !== 0)
|
|
1250
|
+
return false;
|
|
1251
|
+
try {
|
|
1252
|
+
atob(data);
|
|
1253
|
+
return true;
|
|
1254
|
+
} catch {
|
|
1255
|
+
return false;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
1259
|
+
def.pattern ?? (def.pattern = base64);
|
|
1260
|
+
$ZodStringFormat.init(inst, def);
|
|
1261
|
+
inst._zod.onattach.push((inst) => {
|
|
1262
|
+
inst._zod.bag.contentEncoding = "base64";
|
|
1263
|
+
});
|
|
1264
|
+
inst._zod.check = (payload) => {
|
|
1265
|
+
if (isValidBase64(payload.value))
|
|
1266
|
+
return;
|
|
1267
|
+
payload.issues.push({
|
|
1268
|
+
code: "invalid_format",
|
|
1269
|
+
format: "base64",
|
|
1270
|
+
input: payload.value,
|
|
1271
|
+
inst,
|
|
1272
|
+
continue: !def.abort
|
|
1273
|
+
});
|
|
1274
|
+
};
|
|
1275
|
+
});
|
|
1276
|
+
function isValidBase64URL(data) {
|
|
1277
|
+
if (!base64url.test(data))
|
|
1278
|
+
return false;
|
|
1279
|
+
const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
1280
|
+
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
|
1281
|
+
return isValidBase64(padded);
|
|
1282
|
+
}
|
|
1283
|
+
var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1284
|
+
def.pattern ?? (def.pattern = base64url);
|
|
1285
|
+
$ZodStringFormat.init(inst, def);
|
|
1286
|
+
inst._zod.onattach.push((inst) => {
|
|
1287
|
+
inst._zod.bag.contentEncoding = "base64url";
|
|
1288
|
+
});
|
|
1289
|
+
inst._zod.check = (payload) => {
|
|
1290
|
+
if (isValidBase64URL(payload.value))
|
|
1291
|
+
return;
|
|
1292
|
+
payload.issues.push({
|
|
1293
|
+
code: "invalid_format",
|
|
1294
|
+
format: "base64url",
|
|
1295
|
+
input: payload.value,
|
|
1296
|
+
inst,
|
|
1297
|
+
continue: !def.abort
|
|
1298
|
+
});
|
|
1299
|
+
};
|
|
1300
|
+
});
|
|
1301
|
+
var $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
|
|
1302
|
+
def.pattern ?? (def.pattern = e164);
|
|
1303
|
+
$ZodStringFormat.init(inst, def);
|
|
1304
|
+
});
|
|
1305
|
+
function isValidJWT(token, algorithm = null) {
|
|
1306
|
+
try {
|
|
1307
|
+
const tokensParts = token.split(".");
|
|
1308
|
+
if (tokensParts.length !== 3)
|
|
1309
|
+
return false;
|
|
1310
|
+
const [header] = tokensParts;
|
|
1311
|
+
if (!header)
|
|
1312
|
+
return false;
|
|
1313
|
+
const parsedHeader = JSON.parse(atob(header));
|
|
1314
|
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
|
1315
|
+
return false;
|
|
1316
|
+
if (!parsedHeader.alg)
|
|
1317
|
+
return false;
|
|
1318
|
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
|
|
1319
|
+
return false;
|
|
1320
|
+
return true;
|
|
1321
|
+
} catch {
|
|
1322
|
+
return false;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
1326
|
+
$ZodStringFormat.init(inst, def);
|
|
1327
|
+
inst._zod.check = (payload) => {
|
|
1328
|
+
if (isValidJWT(payload.value, def.alg))
|
|
1329
|
+
return;
|
|
1330
|
+
payload.issues.push({
|
|
1331
|
+
code: "invalid_format",
|
|
1332
|
+
format: "jwt",
|
|
1333
|
+
input: payload.value,
|
|
1334
|
+
inst,
|
|
1335
|
+
continue: !def.abort
|
|
1336
|
+
});
|
|
1337
|
+
};
|
|
1338
|
+
});
|
|
1339
|
+
var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
1340
|
+
$ZodType.init(inst, def);
|
|
1341
|
+
inst._zod.pattern = boolean;
|
|
1342
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1343
|
+
if (def.coerce)
|
|
1344
|
+
try {
|
|
1345
|
+
payload.value = Boolean(payload.value);
|
|
1346
|
+
} catch (_) {}
|
|
1347
|
+
const input = payload.value;
|
|
1348
|
+
if (typeof input === "boolean")
|
|
1349
|
+
return payload;
|
|
1350
|
+
payload.issues.push({
|
|
1351
|
+
expected: "boolean",
|
|
1352
|
+
code: "invalid_type",
|
|
1353
|
+
input,
|
|
1354
|
+
inst
|
|
1355
|
+
});
|
|
1356
|
+
return payload;
|
|
1357
|
+
};
|
|
1358
|
+
});
|
|
1359
|
+
var $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
1360
|
+
$ZodType.init(inst, def);
|
|
1361
|
+
inst._zod.parse = (payload) => payload;
|
|
1362
|
+
});
|
|
1363
|
+
var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
1364
|
+
$ZodType.init(inst, def);
|
|
1365
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1366
|
+
payload.issues.push({
|
|
1367
|
+
expected: "never",
|
|
1368
|
+
code: "invalid_type",
|
|
1369
|
+
input: payload.value,
|
|
1370
|
+
inst
|
|
1371
|
+
});
|
|
1372
|
+
return payload;
|
|
1373
|
+
};
|
|
1374
|
+
});
|
|
1375
|
+
function handleArrayResult(result, final, index) {
|
|
1376
|
+
if (result.issues.length) {
|
|
1377
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
1378
|
+
}
|
|
1379
|
+
final.value[index] = result.value;
|
|
1380
|
+
}
|
|
1381
|
+
var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
1382
|
+
$ZodType.init(inst, def);
|
|
1383
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1384
|
+
const input = payload.value;
|
|
1385
|
+
if (!Array.isArray(input)) {
|
|
1386
|
+
payload.issues.push({
|
|
1387
|
+
expected: "array",
|
|
1388
|
+
code: "invalid_type",
|
|
1389
|
+
input,
|
|
1390
|
+
inst
|
|
1391
|
+
});
|
|
1392
|
+
return payload;
|
|
1393
|
+
}
|
|
1394
|
+
payload.value = Array(input.length);
|
|
1395
|
+
const proms = [];
|
|
1396
|
+
for (let i = 0;i < input.length; i++) {
|
|
1397
|
+
const item = input[i];
|
|
1398
|
+
const result = def.element._zod.run({
|
|
1399
|
+
value: item,
|
|
1400
|
+
issues: []
|
|
1401
|
+
}, ctx);
|
|
1402
|
+
if (result instanceof Promise) {
|
|
1403
|
+
proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
1404
|
+
} else {
|
|
1405
|
+
handleArrayResult(result, payload, i);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
if (proms.length) {
|
|
1409
|
+
return Promise.all(proms).then(() => payload);
|
|
1410
|
+
}
|
|
1411
|
+
return payload;
|
|
1412
|
+
};
|
|
1413
|
+
});
|
|
1414
|
+
function handlePropertyResult(result, final, key, input) {
|
|
1415
|
+
if (result.issues.length) {
|
|
1416
|
+
final.issues.push(...prefixIssues(key, result.issues));
|
|
1417
|
+
}
|
|
1418
|
+
if (result.value === undefined) {
|
|
1419
|
+
if (key in input) {
|
|
1420
|
+
final.value[key] = undefined;
|
|
1421
|
+
}
|
|
1422
|
+
} else {
|
|
1423
|
+
final.value[key] = result.value;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
function normalizeDef(def) {
|
|
1427
|
+
const keys = Object.keys(def.shape);
|
|
1428
|
+
for (const k of keys) {
|
|
1429
|
+
if (!def.shape[k]._zod.traits.has("$ZodType")) {
|
|
1430
|
+
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
const okeys = optionalKeys(def.shape);
|
|
1434
|
+
return {
|
|
1435
|
+
...def,
|
|
1436
|
+
keys,
|
|
1437
|
+
keySet: new Set(keys),
|
|
1438
|
+
numKeys: keys.length,
|
|
1439
|
+
optionalKeys: new Set(okeys)
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
1443
|
+
const unrecognized = [];
|
|
1444
|
+
const keySet = def.keySet;
|
|
1445
|
+
const _catchall = def.catchall._zod;
|
|
1446
|
+
const t = _catchall.def.type;
|
|
1447
|
+
for (const key of Object.keys(input)) {
|
|
1448
|
+
if (keySet.has(key))
|
|
1449
|
+
continue;
|
|
1450
|
+
if (t === "never") {
|
|
1451
|
+
unrecognized.push(key);
|
|
1452
|
+
continue;
|
|
1453
|
+
}
|
|
1454
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
1455
|
+
if (r instanceof Promise) {
|
|
1456
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
|
|
1457
|
+
} else {
|
|
1458
|
+
handlePropertyResult(r, payload, key, input);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
if (unrecognized.length) {
|
|
1462
|
+
payload.issues.push({
|
|
1463
|
+
code: "unrecognized_keys",
|
|
1464
|
+
keys: unrecognized,
|
|
1465
|
+
input,
|
|
1466
|
+
inst
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
if (!proms.length)
|
|
1470
|
+
return payload;
|
|
1471
|
+
return Promise.all(proms).then(() => {
|
|
1472
|
+
return payload;
|
|
1473
|
+
});
|
|
1474
|
+
}
|
|
1475
|
+
var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
1476
|
+
$ZodType.init(inst, def);
|
|
1477
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
1478
|
+
defineLazy(inst._zod, "propValues", () => {
|
|
1479
|
+
const shape = def.shape;
|
|
1480
|
+
const propValues = {};
|
|
1481
|
+
for (const key in shape) {
|
|
1482
|
+
const field = shape[key]._zod;
|
|
1483
|
+
if (field.values) {
|
|
1484
|
+
propValues[key] ?? (propValues[key] = new Set);
|
|
1485
|
+
for (const v of field.values)
|
|
1486
|
+
propValues[key].add(v);
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
return propValues;
|
|
1490
|
+
});
|
|
1491
|
+
const isObject2 = isObject;
|
|
1492
|
+
const catchall = def.catchall;
|
|
1493
|
+
let value;
|
|
1494
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1495
|
+
value ?? (value = _normalized.value);
|
|
1496
|
+
const input = payload.value;
|
|
1497
|
+
if (!isObject2(input)) {
|
|
1498
|
+
payload.issues.push({
|
|
1499
|
+
expected: "object",
|
|
1500
|
+
code: "invalid_type",
|
|
1501
|
+
input,
|
|
1502
|
+
inst
|
|
1503
|
+
});
|
|
1504
|
+
return payload;
|
|
1505
|
+
}
|
|
1506
|
+
payload.value = {};
|
|
1507
|
+
const proms = [];
|
|
1508
|
+
const shape = value.shape;
|
|
1509
|
+
for (const key of value.keys) {
|
|
1510
|
+
const el = shape[key];
|
|
1511
|
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1512
|
+
if (r instanceof Promise) {
|
|
1513
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
|
|
1514
|
+
} else {
|
|
1515
|
+
handlePropertyResult(r, payload, key, input);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
if (!catchall) {
|
|
1519
|
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1520
|
+
}
|
|
1521
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
1522
|
+
};
|
|
1523
|
+
});
|
|
1524
|
+
var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
1525
|
+
$ZodObject.init(inst, def);
|
|
1526
|
+
const superParse = inst._zod.parse;
|
|
1527
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
1528
|
+
const generateFastpass = (shape) => {
|
|
1529
|
+
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
1530
|
+
const normalized = _normalized.value;
|
|
1531
|
+
const parseStr = (key) => {
|
|
1532
|
+
const k = esc(key);
|
|
1533
|
+
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
1534
|
+
};
|
|
1535
|
+
doc.write(`const input = payload.value;`);
|
|
1536
|
+
const ids = Object.create(null);
|
|
1537
|
+
let counter = 0;
|
|
1538
|
+
for (const key of normalized.keys) {
|
|
1539
|
+
ids[key] = `key_${counter++}`;
|
|
1540
|
+
}
|
|
1541
|
+
doc.write(`const newResult = {}`);
|
|
1542
|
+
for (const key of normalized.keys) {
|
|
1543
|
+
const id = ids[key];
|
|
1544
|
+
const k = esc(key);
|
|
1545
|
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1546
|
+
doc.write(`
|
|
1547
|
+
if (${id}.issues.length) {
|
|
1548
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1549
|
+
...iss,
|
|
1550
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1551
|
+
})));
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
if (${id}.value === undefined) {
|
|
1555
|
+
if (${k} in input) {
|
|
1556
|
+
newResult[${k}] = undefined;
|
|
1557
|
+
}
|
|
1558
|
+
} else {
|
|
1559
|
+
newResult[${k}] = ${id}.value;
|
|
1560
|
+
}
|
|
1561
|
+
`);
|
|
1562
|
+
}
|
|
1563
|
+
doc.write(`payload.value = newResult;`);
|
|
1564
|
+
doc.write(`return payload;`);
|
|
1565
|
+
const fn = doc.compile();
|
|
1566
|
+
return (payload, ctx) => fn(shape, payload, ctx);
|
|
1567
|
+
};
|
|
1568
|
+
let fastpass;
|
|
1569
|
+
const isObject2 = isObject;
|
|
1570
|
+
const jit = !globalConfig.jitless;
|
|
1571
|
+
const allowsEval2 = allowsEval;
|
|
1572
|
+
const fastEnabled = jit && allowsEval2.value;
|
|
1573
|
+
const catchall = def.catchall;
|
|
1574
|
+
let value;
|
|
1575
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1576
|
+
value ?? (value = _normalized.value);
|
|
1577
|
+
const input = payload.value;
|
|
1578
|
+
if (!isObject2(input)) {
|
|
1579
|
+
payload.issues.push({
|
|
1580
|
+
expected: "object",
|
|
1581
|
+
code: "invalid_type",
|
|
1582
|
+
input,
|
|
1583
|
+
inst
|
|
1584
|
+
});
|
|
1585
|
+
return payload;
|
|
1586
|
+
}
|
|
1587
|
+
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
1588
|
+
if (!fastpass)
|
|
1589
|
+
fastpass = generateFastpass(def.shape);
|
|
1590
|
+
payload = fastpass(payload, ctx);
|
|
1591
|
+
if (!catchall)
|
|
1592
|
+
return payload;
|
|
1593
|
+
return handleCatchall([], input, payload, ctx, value, inst);
|
|
1594
|
+
}
|
|
1595
|
+
return superParse(payload, ctx);
|
|
1596
|
+
};
|
|
1597
|
+
});
|
|
1598
|
+
function handleUnionResults(results, final, inst, ctx) {
|
|
1599
|
+
for (const result of results) {
|
|
1600
|
+
if (result.issues.length === 0) {
|
|
1601
|
+
final.value = result.value;
|
|
1602
|
+
return final;
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
const nonaborted = results.filter((r) => !aborted(r));
|
|
1606
|
+
if (nonaborted.length === 1) {
|
|
1607
|
+
final.value = nonaborted[0].value;
|
|
1608
|
+
return nonaborted[0];
|
|
1609
|
+
}
|
|
1610
|
+
final.issues.push({
|
|
1611
|
+
code: "invalid_union",
|
|
1612
|
+
input: final.value,
|
|
1613
|
+
inst,
|
|
1614
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
1615
|
+
});
|
|
1616
|
+
return final;
|
|
1617
|
+
}
|
|
1618
|
+
var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
1619
|
+
$ZodType.init(inst, def);
|
|
1620
|
+
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
|
|
1621
|
+
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
|
1622
|
+
defineLazy(inst._zod, "values", () => {
|
|
1623
|
+
if (def.options.every((o) => o._zod.values)) {
|
|
1624
|
+
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
1625
|
+
}
|
|
1626
|
+
return;
|
|
1627
|
+
});
|
|
1628
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
1629
|
+
if (def.options.every((o) => o._zod.pattern)) {
|
|
1630
|
+
const patterns = def.options.map((o) => o._zod.pattern);
|
|
1631
|
+
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
1632
|
+
}
|
|
1633
|
+
return;
|
|
1634
|
+
});
|
|
1635
|
+
const single = def.options.length === 1;
|
|
1636
|
+
const first = def.options[0]._zod.run;
|
|
1637
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1638
|
+
if (single) {
|
|
1639
|
+
return first(payload, ctx);
|
|
1640
|
+
}
|
|
1641
|
+
let async = false;
|
|
1642
|
+
const results = [];
|
|
1643
|
+
for (const option of def.options) {
|
|
1644
|
+
const result = option._zod.run({
|
|
1645
|
+
value: payload.value,
|
|
1646
|
+
issues: []
|
|
1647
|
+
}, ctx);
|
|
1648
|
+
if (result instanceof Promise) {
|
|
1649
|
+
results.push(result);
|
|
1650
|
+
async = true;
|
|
1651
|
+
} else {
|
|
1652
|
+
if (result.issues.length === 0)
|
|
1653
|
+
return result;
|
|
1654
|
+
results.push(result);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
if (!async)
|
|
1658
|
+
return handleUnionResults(results, payload, inst, ctx);
|
|
1659
|
+
return Promise.all(results).then((results) => {
|
|
1660
|
+
return handleUnionResults(results, payload, inst, ctx);
|
|
1661
|
+
});
|
|
1662
|
+
};
|
|
1663
|
+
});
|
|
1664
|
+
var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
1665
|
+
$ZodType.init(inst, def);
|
|
1666
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1667
|
+
const input = payload.value;
|
|
1668
|
+
const left = def.left._zod.run({ value: input, issues: [] }, ctx);
|
|
1669
|
+
const right = def.right._zod.run({ value: input, issues: [] }, ctx);
|
|
1670
|
+
const async = left instanceof Promise || right instanceof Promise;
|
|
1671
|
+
if (async) {
|
|
1672
|
+
return Promise.all([left, right]).then(([left, right]) => {
|
|
1673
|
+
return handleIntersectionResults(payload, left, right);
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
return handleIntersectionResults(payload, left, right);
|
|
1677
|
+
};
|
|
1678
|
+
});
|
|
1679
|
+
function mergeValues(a, b) {
|
|
1680
|
+
if (a === b) {
|
|
1681
|
+
return { valid: true, data: a };
|
|
1682
|
+
}
|
|
1683
|
+
if (a instanceof Date && b instanceof Date && +a === +b) {
|
|
1684
|
+
return { valid: true, data: a };
|
|
1685
|
+
}
|
|
1686
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
1687
|
+
const bKeys = Object.keys(b);
|
|
1688
|
+
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
1689
|
+
const newObj = { ...a, ...b };
|
|
1690
|
+
for (const key of sharedKeys) {
|
|
1691
|
+
const sharedValue = mergeValues(a[key], b[key]);
|
|
1692
|
+
if (!sharedValue.valid) {
|
|
1693
|
+
return {
|
|
1694
|
+
valid: false,
|
|
1695
|
+
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
newObj[key] = sharedValue.data;
|
|
1699
|
+
}
|
|
1700
|
+
return { valid: true, data: newObj };
|
|
1701
|
+
}
|
|
1702
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
1703
|
+
if (a.length !== b.length) {
|
|
1704
|
+
return { valid: false, mergeErrorPath: [] };
|
|
1705
|
+
}
|
|
1706
|
+
const newArray = [];
|
|
1707
|
+
for (let index = 0;index < a.length; index++) {
|
|
1708
|
+
const itemA = a[index];
|
|
1709
|
+
const itemB = b[index];
|
|
1710
|
+
const sharedValue = mergeValues(itemA, itemB);
|
|
1711
|
+
if (!sharedValue.valid) {
|
|
1712
|
+
return {
|
|
1713
|
+
valid: false,
|
|
1714
|
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
newArray.push(sharedValue.data);
|
|
1718
|
+
}
|
|
1719
|
+
return { valid: true, data: newArray };
|
|
1720
|
+
}
|
|
1721
|
+
return { valid: false, mergeErrorPath: [] };
|
|
1722
|
+
}
|
|
1723
|
+
function handleIntersectionResults(result, left, right) {
|
|
1724
|
+
if (left.issues.length) {
|
|
1725
|
+
result.issues.push(...left.issues);
|
|
1726
|
+
}
|
|
1727
|
+
if (right.issues.length) {
|
|
1728
|
+
result.issues.push(...right.issues);
|
|
1729
|
+
}
|
|
1730
|
+
if (aborted(result))
|
|
1731
|
+
return result;
|
|
1732
|
+
const merged = mergeValues(left.value, right.value);
|
|
1733
|
+
if (!merged.valid) {
|
|
1734
|
+
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
|
1735
|
+
}
|
|
1736
|
+
result.value = merged.data;
|
|
1737
|
+
return result;
|
|
1738
|
+
}
|
|
1739
|
+
var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
1740
|
+
$ZodType.init(inst, def);
|
|
1741
|
+
const values = getEnumValues(def.entries);
|
|
1742
|
+
const valuesSet = new Set(values);
|
|
1743
|
+
inst._zod.values = valuesSet;
|
|
1744
|
+
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
1745
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1746
|
+
const input = payload.value;
|
|
1747
|
+
if (valuesSet.has(input)) {
|
|
1748
|
+
return payload;
|
|
1749
|
+
}
|
|
1750
|
+
payload.issues.push({
|
|
1751
|
+
code: "invalid_value",
|
|
1752
|
+
values,
|
|
1753
|
+
input,
|
|
1754
|
+
inst
|
|
1755
|
+
});
|
|
1756
|
+
return payload;
|
|
1757
|
+
};
|
|
1758
|
+
});
|
|
1759
|
+
var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
1760
|
+
$ZodType.init(inst, def);
|
|
1761
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1762
|
+
if (ctx.direction === "backward") {
|
|
1763
|
+
throw new $ZodEncodeError(inst.constructor.name);
|
|
1764
|
+
}
|
|
1765
|
+
const _out = def.transform(payload.value, payload);
|
|
1766
|
+
if (ctx.async) {
|
|
1767
|
+
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
1768
|
+
return output.then((output) => {
|
|
1769
|
+
payload.value = output;
|
|
1770
|
+
return payload;
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
if (_out instanceof Promise) {
|
|
1774
|
+
throw new $ZodAsyncError;
|
|
1775
|
+
}
|
|
1776
|
+
payload.value = _out;
|
|
1777
|
+
return payload;
|
|
1778
|
+
};
|
|
1779
|
+
});
|
|
1780
|
+
function handleOptionalResult(result, input) {
|
|
1781
|
+
if (result.issues.length && input === undefined) {
|
|
1782
|
+
return { issues: [], value: undefined };
|
|
1783
|
+
}
|
|
1784
|
+
return result;
|
|
1785
|
+
}
|
|
1786
|
+
var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
1787
|
+
$ZodType.init(inst, def);
|
|
1788
|
+
inst._zod.optin = "optional";
|
|
1789
|
+
inst._zod.optout = "optional";
|
|
1790
|
+
defineLazy(inst._zod, "values", () => {
|
|
1791
|
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
|
|
1792
|
+
});
|
|
1793
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
1794
|
+
const pattern = def.innerType._zod.pattern;
|
|
1795
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : undefined;
|
|
1796
|
+
});
|
|
1797
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1798
|
+
if (def.innerType._zod.optin === "optional") {
|
|
1799
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1800
|
+
if (result instanceof Promise)
|
|
1801
|
+
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
1802
|
+
return handleOptionalResult(result, payload.value);
|
|
1803
|
+
}
|
|
1804
|
+
if (payload.value === undefined) {
|
|
1805
|
+
return payload;
|
|
1806
|
+
}
|
|
1807
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1808
|
+
};
|
|
1809
|
+
});
|
|
1810
|
+
var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
1811
|
+
$ZodType.init(inst, def);
|
|
1812
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1813
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1814
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
1815
|
+
const pattern = def.innerType._zod.pattern;
|
|
1816
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : undefined;
|
|
1817
|
+
});
|
|
1818
|
+
defineLazy(inst._zod, "values", () => {
|
|
1819
|
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
|
1820
|
+
});
|
|
1821
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1822
|
+
if (payload.value === null)
|
|
1823
|
+
return payload;
|
|
1824
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1825
|
+
};
|
|
1826
|
+
});
|
|
1827
|
+
var $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
1828
|
+
$ZodType.init(inst, def);
|
|
1829
|
+
inst._zod.optin = "optional";
|
|
1830
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1831
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1832
|
+
if (ctx.direction === "backward") {
|
|
1833
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1834
|
+
}
|
|
1835
|
+
if (payload.value === undefined) {
|
|
1836
|
+
payload.value = def.defaultValue;
|
|
1837
|
+
return payload;
|
|
1838
|
+
}
|
|
1839
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1840
|
+
if (result instanceof Promise) {
|
|
1841
|
+
return result.then((result) => handleDefaultResult(result, def));
|
|
1842
|
+
}
|
|
1843
|
+
return handleDefaultResult(result, def);
|
|
1844
|
+
};
|
|
1845
|
+
});
|
|
1846
|
+
function handleDefaultResult(payload, def) {
|
|
1847
|
+
if (payload.value === undefined) {
|
|
1848
|
+
payload.value = def.defaultValue;
|
|
1849
|
+
}
|
|
1850
|
+
return payload;
|
|
1851
|
+
}
|
|
1852
|
+
var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
1853
|
+
$ZodType.init(inst, def);
|
|
1854
|
+
inst._zod.optin = "optional";
|
|
1855
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1856
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1857
|
+
if (ctx.direction === "backward") {
|
|
1858
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1859
|
+
}
|
|
1860
|
+
if (payload.value === undefined) {
|
|
1861
|
+
payload.value = def.defaultValue;
|
|
1862
|
+
}
|
|
1863
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1864
|
+
};
|
|
1865
|
+
});
|
|
1866
|
+
var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
1867
|
+
$ZodType.init(inst, def);
|
|
1868
|
+
defineLazy(inst._zod, "values", () => {
|
|
1869
|
+
const v = def.innerType._zod.values;
|
|
1870
|
+
return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
|
|
1871
|
+
});
|
|
1872
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1873
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1874
|
+
if (result instanceof Promise) {
|
|
1875
|
+
return result.then((result) => handleNonOptionalResult(result, inst));
|
|
1876
|
+
}
|
|
1877
|
+
return handleNonOptionalResult(result, inst);
|
|
1878
|
+
};
|
|
1879
|
+
});
|
|
1880
|
+
function handleNonOptionalResult(payload, inst) {
|
|
1881
|
+
if (!payload.issues.length && payload.value === undefined) {
|
|
1882
|
+
payload.issues.push({
|
|
1883
|
+
code: "invalid_type",
|
|
1884
|
+
expected: "nonoptional",
|
|
1885
|
+
input: payload.value,
|
|
1886
|
+
inst
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
return payload;
|
|
1890
|
+
}
|
|
1891
|
+
var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
1892
|
+
$ZodType.init(inst, def);
|
|
1893
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1894
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1895
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1896
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1897
|
+
if (ctx.direction === "backward") {
|
|
1898
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1899
|
+
}
|
|
1900
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1901
|
+
if (result instanceof Promise) {
|
|
1902
|
+
return result.then((result) => {
|
|
1903
|
+
payload.value = result.value;
|
|
1904
|
+
if (result.issues.length) {
|
|
1905
|
+
payload.value = def.catchValue({
|
|
1906
|
+
...payload,
|
|
1907
|
+
error: {
|
|
1908
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
1909
|
+
},
|
|
1910
|
+
input: payload.value
|
|
1911
|
+
});
|
|
1912
|
+
payload.issues = [];
|
|
1913
|
+
}
|
|
1914
|
+
return payload;
|
|
1915
|
+
});
|
|
1916
|
+
}
|
|
1917
|
+
payload.value = result.value;
|
|
1918
|
+
if (result.issues.length) {
|
|
1919
|
+
payload.value = def.catchValue({
|
|
1920
|
+
...payload,
|
|
1921
|
+
error: {
|
|
1922
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
1923
|
+
},
|
|
1924
|
+
input: payload.value
|
|
1925
|
+
});
|
|
1926
|
+
payload.issues = [];
|
|
1927
|
+
}
|
|
1928
|
+
return payload;
|
|
1929
|
+
};
|
|
1930
|
+
});
|
|
1931
|
+
var $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
1932
|
+
$ZodType.init(inst, def);
|
|
1933
|
+
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
1934
|
+
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
1935
|
+
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
1936
|
+
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
1937
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1938
|
+
if (ctx.direction === "backward") {
|
|
1939
|
+
const right = def.out._zod.run(payload, ctx);
|
|
1940
|
+
if (right instanceof Promise) {
|
|
1941
|
+
return right.then((right) => handlePipeResult(right, def.in, ctx));
|
|
1942
|
+
}
|
|
1943
|
+
return handlePipeResult(right, def.in, ctx);
|
|
1944
|
+
}
|
|
1945
|
+
const left = def.in._zod.run(payload, ctx);
|
|
1946
|
+
if (left instanceof Promise) {
|
|
1947
|
+
return left.then((left) => handlePipeResult(left, def.out, ctx));
|
|
1948
|
+
}
|
|
1949
|
+
return handlePipeResult(left, def.out, ctx);
|
|
1950
|
+
};
|
|
1951
|
+
});
|
|
1952
|
+
function handlePipeResult(left, next, ctx) {
|
|
1953
|
+
if (left.issues.length) {
|
|
1954
|
+
left.aborted = true;
|
|
1955
|
+
return left;
|
|
1956
|
+
}
|
|
1957
|
+
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
1958
|
+
}
|
|
1959
|
+
var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
1960
|
+
$ZodType.init(inst, def);
|
|
1961
|
+
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
1962
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1963
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1964
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1965
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1966
|
+
if (ctx.direction === "backward") {
|
|
1967
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1968
|
+
}
|
|
1969
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1970
|
+
if (result instanceof Promise) {
|
|
1971
|
+
return result.then(handleReadonlyResult);
|
|
1972
|
+
}
|
|
1973
|
+
return handleReadonlyResult(result);
|
|
1974
|
+
};
|
|
1975
|
+
});
|
|
1976
|
+
function handleReadonlyResult(payload) {
|
|
1977
|
+
payload.value = Object.freeze(payload.value);
|
|
1978
|
+
return payload;
|
|
1979
|
+
}
|
|
1980
|
+
var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
1981
|
+
$ZodCheck.init(inst, def);
|
|
1982
|
+
$ZodType.init(inst, def);
|
|
1983
|
+
inst._zod.parse = (payload, _) => {
|
|
1984
|
+
return payload;
|
|
1985
|
+
};
|
|
1986
|
+
inst._zod.check = (payload) => {
|
|
1987
|
+
const input = payload.value;
|
|
1988
|
+
const r = def.fn(input);
|
|
1989
|
+
if (r instanceof Promise) {
|
|
1990
|
+
return r.then((r) => handleRefineResult(r, payload, input, inst));
|
|
1991
|
+
}
|
|
1992
|
+
handleRefineResult(r, payload, input, inst);
|
|
1993
|
+
return;
|
|
1994
|
+
};
|
|
1995
|
+
});
|
|
1996
|
+
function handleRefineResult(result, payload, input, inst) {
|
|
1997
|
+
if (!result) {
|
|
1998
|
+
const _iss = {
|
|
1999
|
+
code: "custom",
|
|
2000
|
+
input,
|
|
2001
|
+
inst,
|
|
2002
|
+
path: [...inst._zod.def.path ?? []],
|
|
2003
|
+
continue: !inst._zod.def.abort
|
|
2004
|
+
};
|
|
2005
|
+
if (inst._zod.def.params)
|
|
2006
|
+
_iss.params = inst._zod.def.params;
|
|
2007
|
+
payload.issues.push(issue(_iss));
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/core/registries.js
|
|
2011
|
+
var $output = Symbol("ZodOutput");
|
|
2012
|
+
var $input = Symbol("ZodInput");
|
|
2013
|
+
|
|
2014
|
+
class $ZodRegistry {
|
|
2015
|
+
constructor() {
|
|
2016
|
+
this._map = new Map;
|
|
2017
|
+
this._idmap = new Map;
|
|
2018
|
+
}
|
|
2019
|
+
add(schema, ..._meta) {
|
|
2020
|
+
const meta = _meta[0];
|
|
2021
|
+
this._map.set(schema, meta);
|
|
2022
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
2023
|
+
if (this._idmap.has(meta.id)) {
|
|
2024
|
+
throw new Error(`ID ${meta.id} already exists in the registry`);
|
|
2025
|
+
}
|
|
2026
|
+
this._idmap.set(meta.id, schema);
|
|
2027
|
+
}
|
|
2028
|
+
return this;
|
|
2029
|
+
}
|
|
2030
|
+
clear() {
|
|
2031
|
+
this._map = new Map;
|
|
2032
|
+
this._idmap = new Map;
|
|
2033
|
+
return this;
|
|
2034
|
+
}
|
|
2035
|
+
remove(schema) {
|
|
2036
|
+
const meta = this._map.get(schema);
|
|
2037
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
2038
|
+
this._idmap.delete(meta.id);
|
|
2039
|
+
}
|
|
2040
|
+
this._map.delete(schema);
|
|
2041
|
+
return this;
|
|
2042
|
+
}
|
|
2043
|
+
get(schema) {
|
|
2044
|
+
const p = schema._zod.parent;
|
|
2045
|
+
if (p) {
|
|
2046
|
+
const pm = { ...this.get(p) ?? {} };
|
|
2047
|
+
delete pm.id;
|
|
2048
|
+
const f = { ...pm, ...this._map.get(schema) };
|
|
2049
|
+
return Object.keys(f).length ? f : undefined;
|
|
2050
|
+
}
|
|
2051
|
+
return this._map.get(schema);
|
|
2052
|
+
}
|
|
2053
|
+
has(schema) {
|
|
2054
|
+
return this._map.has(schema);
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
function registry() {
|
|
2058
|
+
return new $ZodRegistry;
|
|
2059
|
+
}
|
|
2060
|
+
var globalRegistry = /* @__PURE__ */ registry();
|
|
2061
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/core/api.js
|
|
2062
|
+
function _string(Class, params) {
|
|
2063
|
+
return new Class({
|
|
2064
|
+
type: "string",
|
|
2065
|
+
...normalizeParams(params)
|
|
2066
|
+
});
|
|
2067
|
+
}
|
|
2068
|
+
function _email(Class, params) {
|
|
2069
|
+
return new Class({
|
|
2070
|
+
type: "string",
|
|
2071
|
+
format: "email",
|
|
2072
|
+
check: "string_format",
|
|
2073
|
+
abort: false,
|
|
2074
|
+
...normalizeParams(params)
|
|
2075
|
+
});
|
|
2076
|
+
}
|
|
2077
|
+
function _guid(Class, params) {
|
|
2078
|
+
return new Class({
|
|
2079
|
+
type: "string",
|
|
2080
|
+
format: "guid",
|
|
2081
|
+
check: "string_format",
|
|
2082
|
+
abort: false,
|
|
2083
|
+
...normalizeParams(params)
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
function _uuid(Class, params) {
|
|
2087
|
+
return new Class({
|
|
2088
|
+
type: "string",
|
|
2089
|
+
format: "uuid",
|
|
2090
|
+
check: "string_format",
|
|
2091
|
+
abort: false,
|
|
2092
|
+
...normalizeParams(params)
|
|
2093
|
+
});
|
|
2094
|
+
}
|
|
2095
|
+
function _uuidv4(Class, params) {
|
|
2096
|
+
return new Class({
|
|
2097
|
+
type: "string",
|
|
2098
|
+
format: "uuid",
|
|
2099
|
+
check: "string_format",
|
|
2100
|
+
abort: false,
|
|
2101
|
+
version: "v4",
|
|
2102
|
+
...normalizeParams(params)
|
|
2103
|
+
});
|
|
2104
|
+
}
|
|
2105
|
+
function _uuidv6(Class, params) {
|
|
2106
|
+
return new Class({
|
|
2107
|
+
type: "string",
|
|
2108
|
+
format: "uuid",
|
|
2109
|
+
check: "string_format",
|
|
2110
|
+
abort: false,
|
|
2111
|
+
version: "v6",
|
|
2112
|
+
...normalizeParams(params)
|
|
2113
|
+
});
|
|
2114
|
+
}
|
|
2115
|
+
function _uuidv7(Class, params) {
|
|
2116
|
+
return new Class({
|
|
2117
|
+
type: "string",
|
|
2118
|
+
format: "uuid",
|
|
2119
|
+
check: "string_format",
|
|
2120
|
+
abort: false,
|
|
2121
|
+
version: "v7",
|
|
2122
|
+
...normalizeParams(params)
|
|
2123
|
+
});
|
|
2124
|
+
}
|
|
2125
|
+
function _url(Class, params) {
|
|
2126
|
+
return new Class({
|
|
2127
|
+
type: "string",
|
|
2128
|
+
format: "url",
|
|
2129
|
+
check: "string_format",
|
|
2130
|
+
abort: false,
|
|
2131
|
+
...normalizeParams(params)
|
|
2132
|
+
});
|
|
2133
|
+
}
|
|
2134
|
+
function _emoji2(Class, params) {
|
|
2135
|
+
return new Class({
|
|
2136
|
+
type: "string",
|
|
2137
|
+
format: "emoji",
|
|
2138
|
+
check: "string_format",
|
|
2139
|
+
abort: false,
|
|
2140
|
+
...normalizeParams(params)
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
function _nanoid(Class, params) {
|
|
2144
|
+
return new Class({
|
|
2145
|
+
type: "string",
|
|
2146
|
+
format: "nanoid",
|
|
2147
|
+
check: "string_format",
|
|
2148
|
+
abort: false,
|
|
2149
|
+
...normalizeParams(params)
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
function _cuid(Class, params) {
|
|
2153
|
+
return new Class({
|
|
2154
|
+
type: "string",
|
|
2155
|
+
format: "cuid",
|
|
2156
|
+
check: "string_format",
|
|
2157
|
+
abort: false,
|
|
2158
|
+
...normalizeParams(params)
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
function _cuid2(Class, params) {
|
|
2162
|
+
return new Class({
|
|
2163
|
+
type: "string",
|
|
2164
|
+
format: "cuid2",
|
|
2165
|
+
check: "string_format",
|
|
2166
|
+
abort: false,
|
|
2167
|
+
...normalizeParams(params)
|
|
2168
|
+
});
|
|
2169
|
+
}
|
|
2170
|
+
function _ulid(Class, params) {
|
|
2171
|
+
return new Class({
|
|
2172
|
+
type: "string",
|
|
2173
|
+
format: "ulid",
|
|
2174
|
+
check: "string_format",
|
|
2175
|
+
abort: false,
|
|
2176
|
+
...normalizeParams(params)
|
|
2177
|
+
});
|
|
2178
|
+
}
|
|
2179
|
+
function _xid(Class, params) {
|
|
2180
|
+
return new Class({
|
|
2181
|
+
type: "string",
|
|
2182
|
+
format: "xid",
|
|
2183
|
+
check: "string_format",
|
|
2184
|
+
abort: false,
|
|
2185
|
+
...normalizeParams(params)
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2188
|
+
function _ksuid(Class, params) {
|
|
2189
|
+
return new Class({
|
|
2190
|
+
type: "string",
|
|
2191
|
+
format: "ksuid",
|
|
2192
|
+
check: "string_format",
|
|
2193
|
+
abort: false,
|
|
2194
|
+
...normalizeParams(params)
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
function _ipv4(Class, params) {
|
|
2198
|
+
return new Class({
|
|
2199
|
+
type: "string",
|
|
2200
|
+
format: "ipv4",
|
|
2201
|
+
check: "string_format",
|
|
2202
|
+
abort: false,
|
|
2203
|
+
...normalizeParams(params)
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
function _ipv6(Class, params) {
|
|
2207
|
+
return new Class({
|
|
2208
|
+
type: "string",
|
|
2209
|
+
format: "ipv6",
|
|
2210
|
+
check: "string_format",
|
|
2211
|
+
abort: false,
|
|
2212
|
+
...normalizeParams(params)
|
|
2213
|
+
});
|
|
2214
|
+
}
|
|
2215
|
+
function _cidrv4(Class, params) {
|
|
2216
|
+
return new Class({
|
|
2217
|
+
type: "string",
|
|
2218
|
+
format: "cidrv4",
|
|
2219
|
+
check: "string_format",
|
|
2220
|
+
abort: false,
|
|
2221
|
+
...normalizeParams(params)
|
|
2222
|
+
});
|
|
2223
|
+
}
|
|
2224
|
+
function _cidrv6(Class, params) {
|
|
2225
|
+
return new Class({
|
|
2226
|
+
type: "string",
|
|
2227
|
+
format: "cidrv6",
|
|
2228
|
+
check: "string_format",
|
|
2229
|
+
abort: false,
|
|
2230
|
+
...normalizeParams(params)
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2233
|
+
function _base64(Class, params) {
|
|
2234
|
+
return new Class({
|
|
2235
|
+
type: "string",
|
|
2236
|
+
format: "base64",
|
|
2237
|
+
check: "string_format",
|
|
2238
|
+
abort: false,
|
|
2239
|
+
...normalizeParams(params)
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
function _base64url(Class, params) {
|
|
2243
|
+
return new Class({
|
|
2244
|
+
type: "string",
|
|
2245
|
+
format: "base64url",
|
|
2246
|
+
check: "string_format",
|
|
2247
|
+
abort: false,
|
|
2248
|
+
...normalizeParams(params)
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
function _e164(Class, params) {
|
|
2252
|
+
return new Class({
|
|
2253
|
+
type: "string",
|
|
2254
|
+
format: "e164",
|
|
2255
|
+
check: "string_format",
|
|
2256
|
+
abort: false,
|
|
2257
|
+
...normalizeParams(params)
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2260
|
+
function _jwt(Class, params) {
|
|
2261
|
+
return new Class({
|
|
2262
|
+
type: "string",
|
|
2263
|
+
format: "jwt",
|
|
2264
|
+
check: "string_format",
|
|
2265
|
+
abort: false,
|
|
2266
|
+
...normalizeParams(params)
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
function _isoDateTime(Class, params) {
|
|
2270
|
+
return new Class({
|
|
2271
|
+
type: "string",
|
|
2272
|
+
format: "datetime",
|
|
2273
|
+
check: "string_format",
|
|
2274
|
+
offset: false,
|
|
2275
|
+
local: false,
|
|
2276
|
+
precision: null,
|
|
2277
|
+
...normalizeParams(params)
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2280
|
+
function _isoDate(Class, params) {
|
|
2281
|
+
return new Class({
|
|
2282
|
+
type: "string",
|
|
2283
|
+
format: "date",
|
|
2284
|
+
check: "string_format",
|
|
2285
|
+
...normalizeParams(params)
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2288
|
+
function _isoTime(Class, params) {
|
|
2289
|
+
return new Class({
|
|
2290
|
+
type: "string",
|
|
2291
|
+
format: "time",
|
|
2292
|
+
check: "string_format",
|
|
2293
|
+
precision: null,
|
|
2294
|
+
...normalizeParams(params)
|
|
2295
|
+
});
|
|
2296
|
+
}
|
|
2297
|
+
function _isoDuration(Class, params) {
|
|
2298
|
+
return new Class({
|
|
2299
|
+
type: "string",
|
|
2300
|
+
format: "duration",
|
|
2301
|
+
check: "string_format",
|
|
2302
|
+
...normalizeParams(params)
|
|
2303
|
+
});
|
|
2304
|
+
}
|
|
2305
|
+
function _boolean(Class, params) {
|
|
2306
|
+
return new Class({
|
|
2307
|
+
type: "boolean",
|
|
2308
|
+
...normalizeParams(params)
|
|
2309
|
+
});
|
|
2310
|
+
}
|
|
2311
|
+
function _unknown(Class) {
|
|
2312
|
+
return new Class({
|
|
2313
|
+
type: "unknown"
|
|
2314
|
+
});
|
|
2315
|
+
}
|
|
2316
|
+
function _never(Class, params) {
|
|
2317
|
+
return new Class({
|
|
2318
|
+
type: "never",
|
|
2319
|
+
...normalizeParams(params)
|
|
2320
|
+
});
|
|
2321
|
+
}
|
|
2322
|
+
function _maxLength(maximum, params) {
|
|
2323
|
+
const ch = new $ZodCheckMaxLength({
|
|
2324
|
+
check: "max_length",
|
|
2325
|
+
...normalizeParams(params),
|
|
2326
|
+
maximum
|
|
2327
|
+
});
|
|
2328
|
+
return ch;
|
|
2329
|
+
}
|
|
2330
|
+
function _minLength(minimum, params) {
|
|
2331
|
+
return new $ZodCheckMinLength({
|
|
2332
|
+
check: "min_length",
|
|
2333
|
+
...normalizeParams(params),
|
|
2334
|
+
minimum
|
|
2335
|
+
});
|
|
2336
|
+
}
|
|
2337
|
+
function _length(length, params) {
|
|
2338
|
+
return new $ZodCheckLengthEquals({
|
|
2339
|
+
check: "length_equals",
|
|
2340
|
+
...normalizeParams(params),
|
|
2341
|
+
length
|
|
2342
|
+
});
|
|
2343
|
+
}
|
|
2344
|
+
function _regex(pattern, params) {
|
|
2345
|
+
return new $ZodCheckRegex({
|
|
2346
|
+
check: "string_format",
|
|
2347
|
+
format: "regex",
|
|
2348
|
+
...normalizeParams(params),
|
|
2349
|
+
pattern
|
|
2350
|
+
});
|
|
2351
|
+
}
|
|
2352
|
+
function _lowercase(params) {
|
|
2353
|
+
return new $ZodCheckLowerCase({
|
|
2354
|
+
check: "string_format",
|
|
2355
|
+
format: "lowercase",
|
|
2356
|
+
...normalizeParams(params)
|
|
2357
|
+
});
|
|
2358
|
+
}
|
|
2359
|
+
function _uppercase(params) {
|
|
2360
|
+
return new $ZodCheckUpperCase({
|
|
2361
|
+
check: "string_format",
|
|
2362
|
+
format: "uppercase",
|
|
2363
|
+
...normalizeParams(params)
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
function _includes(includes, params) {
|
|
2367
|
+
return new $ZodCheckIncludes({
|
|
2368
|
+
check: "string_format",
|
|
2369
|
+
format: "includes",
|
|
2370
|
+
...normalizeParams(params),
|
|
2371
|
+
includes
|
|
2372
|
+
});
|
|
2373
|
+
}
|
|
2374
|
+
function _startsWith(prefix, params) {
|
|
2375
|
+
return new $ZodCheckStartsWith({
|
|
2376
|
+
check: "string_format",
|
|
2377
|
+
format: "starts_with",
|
|
2378
|
+
...normalizeParams(params),
|
|
2379
|
+
prefix
|
|
2380
|
+
});
|
|
2381
|
+
}
|
|
2382
|
+
function _endsWith(suffix, params) {
|
|
2383
|
+
return new $ZodCheckEndsWith({
|
|
2384
|
+
check: "string_format",
|
|
2385
|
+
format: "ends_with",
|
|
2386
|
+
...normalizeParams(params),
|
|
2387
|
+
suffix
|
|
2388
|
+
});
|
|
2389
|
+
}
|
|
2390
|
+
function _overwrite(tx) {
|
|
2391
|
+
return new $ZodCheckOverwrite({
|
|
2392
|
+
check: "overwrite",
|
|
2393
|
+
tx
|
|
2394
|
+
});
|
|
2395
|
+
}
|
|
2396
|
+
function _normalize(form) {
|
|
2397
|
+
return _overwrite((input) => input.normalize(form));
|
|
2398
|
+
}
|
|
2399
|
+
function _trim() {
|
|
2400
|
+
return _overwrite((input) => input.trim());
|
|
2401
|
+
}
|
|
2402
|
+
function _toLowerCase() {
|
|
2403
|
+
return _overwrite((input) => input.toLowerCase());
|
|
2404
|
+
}
|
|
2405
|
+
function _toUpperCase() {
|
|
2406
|
+
return _overwrite((input) => input.toUpperCase());
|
|
2407
|
+
}
|
|
2408
|
+
function _array(Class, element, params) {
|
|
2409
|
+
return new Class({
|
|
2410
|
+
type: "array",
|
|
2411
|
+
element,
|
|
2412
|
+
...normalizeParams(params)
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2415
|
+
function _refine(Class, fn, _params) {
|
|
2416
|
+
const schema = new Class({
|
|
2417
|
+
type: "custom",
|
|
2418
|
+
check: "custom",
|
|
2419
|
+
fn,
|
|
2420
|
+
...normalizeParams(_params)
|
|
2421
|
+
});
|
|
2422
|
+
return schema;
|
|
2423
|
+
}
|
|
2424
|
+
function _superRefine(fn) {
|
|
2425
|
+
const ch = _check((payload) => {
|
|
2426
|
+
payload.addIssue = (issue2) => {
|
|
2427
|
+
if (typeof issue2 === "string") {
|
|
2428
|
+
payload.issues.push(issue(issue2, payload.value, ch._zod.def));
|
|
2429
|
+
} else {
|
|
2430
|
+
const _issue = issue2;
|
|
2431
|
+
if (_issue.fatal)
|
|
2432
|
+
_issue.continue = false;
|
|
2433
|
+
_issue.code ?? (_issue.code = "custom");
|
|
2434
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
2435
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
2436
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
2437
|
+
payload.issues.push(issue(_issue));
|
|
2438
|
+
}
|
|
2439
|
+
};
|
|
2440
|
+
return fn(payload.value, payload);
|
|
2441
|
+
});
|
|
2442
|
+
return ch;
|
|
2443
|
+
}
|
|
2444
|
+
function _check(fn, params) {
|
|
2445
|
+
const ch = new $ZodCheck({
|
|
2446
|
+
check: "custom",
|
|
2447
|
+
...normalizeParams(params)
|
|
2448
|
+
});
|
|
2449
|
+
ch._zod.check = fn;
|
|
2450
|
+
return ch;
|
|
2451
|
+
}
|
|
2452
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/classic/iso.js
|
|
2453
|
+
var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
2454
|
+
$ZodISODateTime.init(inst, def);
|
|
2455
|
+
ZodStringFormat.init(inst, def);
|
|
2456
|
+
});
|
|
2457
|
+
function datetime2(params) {
|
|
2458
|
+
return _isoDateTime(ZodISODateTime, params);
|
|
2459
|
+
}
|
|
2460
|
+
var ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
|
|
2461
|
+
$ZodISODate.init(inst, def);
|
|
2462
|
+
ZodStringFormat.init(inst, def);
|
|
2463
|
+
});
|
|
2464
|
+
function date2(params) {
|
|
2465
|
+
return _isoDate(ZodISODate, params);
|
|
2466
|
+
}
|
|
2467
|
+
var ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
|
|
2468
|
+
$ZodISOTime.init(inst, def);
|
|
2469
|
+
ZodStringFormat.init(inst, def);
|
|
2470
|
+
});
|
|
2471
|
+
function time2(params) {
|
|
2472
|
+
return _isoTime(ZodISOTime, params);
|
|
2473
|
+
}
|
|
2474
|
+
var ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
|
|
2475
|
+
$ZodISODuration.init(inst, def);
|
|
2476
|
+
ZodStringFormat.init(inst, def);
|
|
2477
|
+
});
|
|
2478
|
+
function duration2(params) {
|
|
2479
|
+
return _isoDuration(ZodISODuration, params);
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/classic/errors.js
|
|
2483
|
+
var initializer2 = (inst, issues) => {
|
|
2484
|
+
$ZodError.init(inst, issues);
|
|
2485
|
+
inst.name = "ZodError";
|
|
2486
|
+
Object.defineProperties(inst, {
|
|
2487
|
+
format: {
|
|
2488
|
+
value: (mapper) => formatError(inst, mapper)
|
|
2489
|
+
},
|
|
2490
|
+
flatten: {
|
|
2491
|
+
value: (mapper) => flattenError(inst, mapper)
|
|
2492
|
+
},
|
|
2493
|
+
addIssue: {
|
|
2494
|
+
value: (issue) => {
|
|
2495
|
+
inst.issues.push(issue);
|
|
2496
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
2497
|
+
}
|
|
2498
|
+
},
|
|
2499
|
+
addIssues: {
|
|
2500
|
+
value: (issues) => {
|
|
2501
|
+
inst.issues.push(...issues);
|
|
2502
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
2503
|
+
}
|
|
2504
|
+
},
|
|
2505
|
+
isEmpty: {
|
|
2506
|
+
get() {
|
|
2507
|
+
return inst.issues.length === 0;
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
});
|
|
2511
|
+
};
|
|
2512
|
+
var ZodError = $constructor("ZodError", initializer2);
|
|
2513
|
+
var ZodRealError = $constructor("ZodError", initializer2, {
|
|
2514
|
+
Parent: Error
|
|
2515
|
+
});
|
|
2516
|
+
|
|
2517
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/classic/parse.js
|
|
2518
|
+
var parse3 = /* @__PURE__ */ _parse(ZodRealError);
|
|
2519
|
+
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
2520
|
+
var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
2521
|
+
var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
2522
|
+
var encode = /* @__PURE__ */ _encode(ZodRealError);
|
|
2523
|
+
var decode = /* @__PURE__ */ _decode(ZodRealError);
|
|
2524
|
+
var encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
2525
|
+
var decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
2526
|
+
var safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
2527
|
+
var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
2528
|
+
var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
2529
|
+
var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
2530
|
+
|
|
2531
|
+
// ../../node_modules/.bun/zod@4.1.5/node_modules/zod/v4/classic/schemas.js
|
|
2532
|
+
var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
2533
|
+
$ZodType.init(inst, def);
|
|
2534
|
+
inst.def = def;
|
|
2535
|
+
inst.type = def.type;
|
|
2536
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
2537
|
+
inst.check = (...checks) => {
|
|
2538
|
+
return inst.clone({
|
|
2539
|
+
...def,
|
|
2540
|
+
checks: [
|
|
2541
|
+
...def.checks ?? [],
|
|
2542
|
+
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
2543
|
+
]
|
|
2544
|
+
});
|
|
2545
|
+
};
|
|
2546
|
+
inst.clone = (def, params) => clone(inst, def, params);
|
|
2547
|
+
inst.brand = () => inst;
|
|
2548
|
+
inst.register = (reg, meta) => {
|
|
2549
|
+
reg.add(inst, meta);
|
|
2550
|
+
return inst;
|
|
2551
|
+
};
|
|
2552
|
+
inst.parse = (data, params) => parse3(inst, data, params, { callee: inst.parse });
|
|
2553
|
+
inst.safeParse = (data, params) => safeParse2(inst, data, params);
|
|
2554
|
+
inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
|
|
2555
|
+
inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
|
|
2556
|
+
inst.spa = inst.safeParseAsync;
|
|
2557
|
+
inst.encode = (data, params) => encode(inst, data, params);
|
|
2558
|
+
inst.decode = (data, params) => decode(inst, data, params);
|
|
2559
|
+
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
2560
|
+
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
2561
|
+
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
2562
|
+
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
2563
|
+
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
2564
|
+
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
2565
|
+
inst.refine = (check, params) => inst.check(refine(check, params));
|
|
2566
|
+
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
2567
|
+
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
2568
|
+
inst.optional = () => optional(inst);
|
|
2569
|
+
inst.nullable = () => nullable(inst);
|
|
2570
|
+
inst.nullish = () => optional(nullable(inst));
|
|
2571
|
+
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
2572
|
+
inst.array = () => array(inst);
|
|
2573
|
+
inst.or = (arg) => union([inst, arg]);
|
|
2574
|
+
inst.and = (arg) => intersection(inst, arg);
|
|
2575
|
+
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
2576
|
+
inst.default = (def) => _default(inst, def);
|
|
2577
|
+
inst.prefault = (def) => prefault(inst, def);
|
|
2578
|
+
inst.catch = (params) => _catch(inst, params);
|
|
2579
|
+
inst.pipe = (target) => pipe(inst, target);
|
|
2580
|
+
inst.readonly = () => readonly(inst);
|
|
2581
|
+
inst.describe = (description) => {
|
|
2582
|
+
const cl = inst.clone();
|
|
2583
|
+
globalRegistry.add(cl, { description });
|
|
2584
|
+
return cl;
|
|
2585
|
+
};
|
|
2586
|
+
Object.defineProperty(inst, "description", {
|
|
2587
|
+
get() {
|
|
2588
|
+
return globalRegistry.get(inst)?.description;
|
|
2589
|
+
},
|
|
2590
|
+
configurable: true
|
|
2591
|
+
});
|
|
2592
|
+
inst.meta = (...args) => {
|
|
2593
|
+
if (args.length === 0) {
|
|
2594
|
+
return globalRegistry.get(inst);
|
|
2595
|
+
}
|
|
2596
|
+
const cl = inst.clone();
|
|
2597
|
+
globalRegistry.add(cl, args[0]);
|
|
2598
|
+
return cl;
|
|
2599
|
+
};
|
|
2600
|
+
inst.isOptional = () => inst.safeParse(undefined).success;
|
|
2601
|
+
inst.isNullable = () => inst.safeParse(null).success;
|
|
2602
|
+
return inst;
|
|
2603
|
+
});
|
|
2604
|
+
var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
2605
|
+
$ZodString.init(inst, def);
|
|
2606
|
+
ZodType.init(inst, def);
|
|
2607
|
+
const bag = inst._zod.bag;
|
|
2608
|
+
inst.format = bag.format ?? null;
|
|
2609
|
+
inst.minLength = bag.minimum ?? null;
|
|
2610
|
+
inst.maxLength = bag.maximum ?? null;
|
|
2611
|
+
inst.regex = (...args) => inst.check(_regex(...args));
|
|
2612
|
+
inst.includes = (...args) => inst.check(_includes(...args));
|
|
2613
|
+
inst.startsWith = (...args) => inst.check(_startsWith(...args));
|
|
2614
|
+
inst.endsWith = (...args) => inst.check(_endsWith(...args));
|
|
2615
|
+
inst.min = (...args) => inst.check(_minLength(...args));
|
|
2616
|
+
inst.max = (...args) => inst.check(_maxLength(...args));
|
|
2617
|
+
inst.length = (...args) => inst.check(_length(...args));
|
|
2618
|
+
inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
|
|
2619
|
+
inst.lowercase = (params) => inst.check(_lowercase(params));
|
|
2620
|
+
inst.uppercase = (params) => inst.check(_uppercase(params));
|
|
2621
|
+
inst.trim = () => inst.check(_trim());
|
|
2622
|
+
inst.normalize = (...args) => inst.check(_normalize(...args));
|
|
2623
|
+
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
2624
|
+
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
2625
|
+
});
|
|
2626
|
+
var ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
2627
|
+
$ZodString.init(inst, def);
|
|
2628
|
+
_ZodString.init(inst, def);
|
|
2629
|
+
inst.email = (params) => inst.check(_email(ZodEmail, params));
|
|
2630
|
+
inst.url = (params) => inst.check(_url(ZodURL, params));
|
|
2631
|
+
inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
|
|
2632
|
+
inst.emoji = (params) => inst.check(_emoji2(ZodEmoji, params));
|
|
2633
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
2634
|
+
inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
|
|
2635
|
+
inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
|
|
2636
|
+
inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
|
|
2637
|
+
inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
|
|
2638
|
+
inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
|
|
2639
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
2640
|
+
inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
|
|
2641
|
+
inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
|
|
2642
|
+
inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
|
|
2643
|
+
inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
|
|
2644
|
+
inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
|
|
2645
|
+
inst.xid = (params) => inst.check(_xid(ZodXID, params));
|
|
2646
|
+
inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
|
|
2647
|
+
inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
|
|
2648
|
+
inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
|
|
2649
|
+
inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
|
|
2650
|
+
inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
|
|
2651
|
+
inst.e164 = (params) => inst.check(_e164(ZodE164, params));
|
|
2652
|
+
inst.datetime = (params) => inst.check(datetime2(params));
|
|
2653
|
+
inst.date = (params) => inst.check(date2(params));
|
|
2654
|
+
inst.time = (params) => inst.check(time2(params));
|
|
2655
|
+
inst.duration = (params) => inst.check(duration2(params));
|
|
2656
|
+
});
|
|
2657
|
+
function string2(params) {
|
|
2658
|
+
return _string(ZodString, params);
|
|
2659
|
+
}
|
|
2660
|
+
var ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
|
|
2661
|
+
$ZodStringFormat.init(inst, def);
|
|
2662
|
+
_ZodString.init(inst, def);
|
|
2663
|
+
});
|
|
2664
|
+
var ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
|
|
2665
|
+
$ZodEmail.init(inst, def);
|
|
2666
|
+
ZodStringFormat.init(inst, def);
|
|
2667
|
+
});
|
|
2668
|
+
var ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
|
|
2669
|
+
$ZodGUID.init(inst, def);
|
|
2670
|
+
ZodStringFormat.init(inst, def);
|
|
2671
|
+
});
|
|
2672
|
+
var ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
|
|
2673
|
+
$ZodUUID.init(inst, def);
|
|
2674
|
+
ZodStringFormat.init(inst, def);
|
|
2675
|
+
});
|
|
2676
|
+
var ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
|
|
2677
|
+
$ZodURL.init(inst, def);
|
|
2678
|
+
ZodStringFormat.init(inst, def);
|
|
2679
|
+
});
|
|
2680
|
+
var ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
|
|
2681
|
+
$ZodEmoji.init(inst, def);
|
|
2682
|
+
ZodStringFormat.init(inst, def);
|
|
2683
|
+
});
|
|
2684
|
+
var ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
|
|
2685
|
+
$ZodNanoID.init(inst, def);
|
|
2686
|
+
ZodStringFormat.init(inst, def);
|
|
2687
|
+
});
|
|
2688
|
+
var ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
|
|
2689
|
+
$ZodCUID.init(inst, def);
|
|
2690
|
+
ZodStringFormat.init(inst, def);
|
|
2691
|
+
});
|
|
2692
|
+
var ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
|
|
2693
|
+
$ZodCUID2.init(inst, def);
|
|
2694
|
+
ZodStringFormat.init(inst, def);
|
|
2695
|
+
});
|
|
2696
|
+
var ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
|
|
2697
|
+
$ZodULID.init(inst, def);
|
|
2698
|
+
ZodStringFormat.init(inst, def);
|
|
2699
|
+
});
|
|
2700
|
+
var ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
|
|
2701
|
+
$ZodXID.init(inst, def);
|
|
2702
|
+
ZodStringFormat.init(inst, def);
|
|
2703
|
+
});
|
|
2704
|
+
var ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
|
|
2705
|
+
$ZodKSUID.init(inst, def);
|
|
2706
|
+
ZodStringFormat.init(inst, def);
|
|
2707
|
+
});
|
|
2708
|
+
var ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
|
|
2709
|
+
$ZodIPv4.init(inst, def);
|
|
2710
|
+
ZodStringFormat.init(inst, def);
|
|
2711
|
+
});
|
|
2712
|
+
var ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
|
|
2713
|
+
$ZodIPv6.init(inst, def);
|
|
2714
|
+
ZodStringFormat.init(inst, def);
|
|
2715
|
+
});
|
|
2716
|
+
var ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
|
|
2717
|
+
$ZodCIDRv4.init(inst, def);
|
|
2718
|
+
ZodStringFormat.init(inst, def);
|
|
2719
|
+
});
|
|
2720
|
+
var ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
|
|
2721
|
+
$ZodCIDRv6.init(inst, def);
|
|
2722
|
+
ZodStringFormat.init(inst, def);
|
|
2723
|
+
});
|
|
2724
|
+
var ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
|
|
2725
|
+
$ZodBase64.init(inst, def);
|
|
2726
|
+
ZodStringFormat.init(inst, def);
|
|
2727
|
+
});
|
|
2728
|
+
var ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
|
|
2729
|
+
$ZodBase64URL.init(inst, def);
|
|
2730
|
+
ZodStringFormat.init(inst, def);
|
|
2731
|
+
});
|
|
2732
|
+
var ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
|
|
2733
|
+
$ZodE164.init(inst, def);
|
|
2734
|
+
ZodStringFormat.init(inst, def);
|
|
2735
|
+
});
|
|
2736
|
+
var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
|
|
2737
|
+
$ZodJWT.init(inst, def);
|
|
2738
|
+
ZodStringFormat.init(inst, def);
|
|
2739
|
+
});
|
|
2740
|
+
var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
2741
|
+
$ZodBoolean.init(inst, def);
|
|
2742
|
+
ZodType.init(inst, def);
|
|
2743
|
+
});
|
|
2744
|
+
function boolean2(params) {
|
|
2745
|
+
return _boolean(ZodBoolean, params);
|
|
2746
|
+
}
|
|
2747
|
+
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
2748
|
+
$ZodUnknown.init(inst, def);
|
|
2749
|
+
ZodType.init(inst, def);
|
|
2750
|
+
});
|
|
2751
|
+
function unknown() {
|
|
2752
|
+
return _unknown(ZodUnknown);
|
|
2753
|
+
}
|
|
2754
|
+
var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
2755
|
+
$ZodNever.init(inst, def);
|
|
2756
|
+
ZodType.init(inst, def);
|
|
2757
|
+
});
|
|
2758
|
+
function never(params) {
|
|
2759
|
+
return _never(ZodNever, params);
|
|
2760
|
+
}
|
|
2761
|
+
var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
2762
|
+
$ZodArray.init(inst, def);
|
|
2763
|
+
ZodType.init(inst, def);
|
|
2764
|
+
inst.element = def.element;
|
|
2765
|
+
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
2766
|
+
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
2767
|
+
inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
|
|
2768
|
+
inst.length = (len, params) => inst.check(_length(len, params));
|
|
2769
|
+
inst.unwrap = () => inst.element;
|
|
2770
|
+
});
|
|
2771
|
+
function array(element, params) {
|
|
2772
|
+
return _array(ZodArray, element, params);
|
|
2773
|
+
}
|
|
2774
|
+
var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
2775
|
+
$ZodObjectJIT.init(inst, def);
|
|
2776
|
+
ZodType.init(inst, def);
|
|
2777
|
+
defineLazy(inst, "shape", () => def.shape);
|
|
2778
|
+
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
2779
|
+
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
|
|
2780
|
+
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
2781
|
+
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
2782
|
+
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
|
2783
|
+
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
|
|
2784
|
+
inst.extend = (incoming) => {
|
|
2785
|
+
return extend(inst, incoming);
|
|
2786
|
+
};
|
|
2787
|
+
inst.safeExtend = (incoming) => {
|
|
2788
|
+
return safeExtend(inst, incoming);
|
|
2789
|
+
};
|
|
2790
|
+
inst.merge = (other) => merge(inst, other);
|
|
2791
|
+
inst.pick = (mask) => pick(inst, mask);
|
|
2792
|
+
inst.omit = (mask) => omit(inst, mask);
|
|
2793
|
+
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
2794
|
+
inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
|
|
2795
|
+
});
|
|
2796
|
+
function object(shape, params) {
|
|
2797
|
+
const def = {
|
|
2798
|
+
type: "object",
|
|
2799
|
+
get shape() {
|
|
2800
|
+
assignProp(this, "shape", shape ? objectClone(shape) : {});
|
|
2801
|
+
return this.shape;
|
|
2802
|
+
},
|
|
2803
|
+
...normalizeParams(params)
|
|
2804
|
+
};
|
|
2805
|
+
return new ZodObject(def);
|
|
2806
|
+
}
|
|
2807
|
+
var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
2808
|
+
$ZodUnion.init(inst, def);
|
|
2809
|
+
ZodType.init(inst, def);
|
|
2810
|
+
inst.options = def.options;
|
|
2811
|
+
});
|
|
2812
|
+
function union(options, params) {
|
|
2813
|
+
return new ZodUnion({
|
|
2814
|
+
type: "union",
|
|
2815
|
+
options,
|
|
2816
|
+
...normalizeParams(params)
|
|
2817
|
+
});
|
|
2818
|
+
}
|
|
2819
|
+
var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
2820
|
+
$ZodIntersection.init(inst, def);
|
|
2821
|
+
ZodType.init(inst, def);
|
|
2822
|
+
});
|
|
2823
|
+
function intersection(left, right) {
|
|
2824
|
+
return new ZodIntersection({
|
|
2825
|
+
type: "intersection",
|
|
2826
|
+
left,
|
|
2827
|
+
right
|
|
2828
|
+
});
|
|
2829
|
+
}
|
|
2830
|
+
var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
2831
|
+
$ZodEnum.init(inst, def);
|
|
2832
|
+
ZodType.init(inst, def);
|
|
2833
|
+
inst.enum = def.entries;
|
|
2834
|
+
inst.options = Object.values(def.entries);
|
|
2835
|
+
const keys = new Set(Object.keys(def.entries));
|
|
2836
|
+
inst.extract = (values, params) => {
|
|
2837
|
+
const newEntries = {};
|
|
2838
|
+
for (const value of values) {
|
|
2839
|
+
if (keys.has(value)) {
|
|
2840
|
+
newEntries[value] = def.entries[value];
|
|
2841
|
+
} else
|
|
2842
|
+
throw new Error(`Key ${value} not found in enum`);
|
|
2843
|
+
}
|
|
2844
|
+
return new ZodEnum({
|
|
2845
|
+
...def,
|
|
2846
|
+
checks: [],
|
|
2847
|
+
...normalizeParams(params),
|
|
2848
|
+
entries: newEntries
|
|
2849
|
+
});
|
|
2850
|
+
};
|
|
2851
|
+
inst.exclude = (values, params) => {
|
|
2852
|
+
const newEntries = { ...def.entries };
|
|
2853
|
+
for (const value of values) {
|
|
2854
|
+
if (keys.has(value)) {
|
|
2855
|
+
delete newEntries[value];
|
|
2856
|
+
} else
|
|
2857
|
+
throw new Error(`Key ${value} not found in enum`);
|
|
2858
|
+
}
|
|
2859
|
+
return new ZodEnum({
|
|
2860
|
+
...def,
|
|
2861
|
+
checks: [],
|
|
2862
|
+
...normalizeParams(params),
|
|
2863
|
+
entries: newEntries
|
|
2864
|
+
});
|
|
2865
|
+
};
|
|
2866
|
+
});
|
|
2867
|
+
function _enum(values, params) {
|
|
2868
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
2869
|
+
return new ZodEnum({
|
|
2870
|
+
type: "enum",
|
|
2871
|
+
entries,
|
|
2872
|
+
...normalizeParams(params)
|
|
2873
|
+
});
|
|
2874
|
+
}
|
|
2875
|
+
var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
2876
|
+
$ZodTransform.init(inst, def);
|
|
2877
|
+
ZodType.init(inst, def);
|
|
2878
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
2879
|
+
if (_ctx.direction === "backward") {
|
|
2880
|
+
throw new $ZodEncodeError(inst.constructor.name);
|
|
2881
|
+
}
|
|
2882
|
+
payload.addIssue = (issue2) => {
|
|
2883
|
+
if (typeof issue2 === "string") {
|
|
2884
|
+
payload.issues.push(issue(issue2, payload.value, def));
|
|
2885
|
+
} else {
|
|
2886
|
+
const _issue = issue2;
|
|
2887
|
+
if (_issue.fatal)
|
|
2888
|
+
_issue.continue = false;
|
|
2889
|
+
_issue.code ?? (_issue.code = "custom");
|
|
2890
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
2891
|
+
_issue.inst ?? (_issue.inst = inst);
|
|
2892
|
+
payload.issues.push(issue(_issue));
|
|
2893
|
+
}
|
|
2894
|
+
};
|
|
2895
|
+
const output = def.transform(payload.value, payload);
|
|
2896
|
+
if (output instanceof Promise) {
|
|
2897
|
+
return output.then((output) => {
|
|
2898
|
+
payload.value = output;
|
|
2899
|
+
return payload;
|
|
2900
|
+
});
|
|
2901
|
+
}
|
|
2902
|
+
payload.value = output;
|
|
2903
|
+
return payload;
|
|
2904
|
+
};
|
|
2905
|
+
});
|
|
2906
|
+
function transform(fn) {
|
|
2907
|
+
return new ZodTransform({
|
|
2908
|
+
type: "transform",
|
|
2909
|
+
transform: fn
|
|
2910
|
+
});
|
|
2911
|
+
}
|
|
2912
|
+
var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
2913
|
+
$ZodOptional.init(inst, def);
|
|
2914
|
+
ZodType.init(inst, def);
|
|
2915
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
2916
|
+
});
|
|
2917
|
+
function optional(innerType) {
|
|
2918
|
+
return new ZodOptional({
|
|
2919
|
+
type: "optional",
|
|
2920
|
+
innerType
|
|
2921
|
+
});
|
|
2922
|
+
}
|
|
2923
|
+
var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
2924
|
+
$ZodNullable.init(inst, def);
|
|
2925
|
+
ZodType.init(inst, def);
|
|
2926
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
2927
|
+
});
|
|
2928
|
+
function nullable(innerType) {
|
|
2929
|
+
return new ZodNullable({
|
|
2930
|
+
type: "nullable",
|
|
2931
|
+
innerType
|
|
2932
|
+
});
|
|
2933
|
+
}
|
|
2934
|
+
var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
2935
|
+
$ZodDefault.init(inst, def);
|
|
2936
|
+
ZodType.init(inst, def);
|
|
2937
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
2938
|
+
inst.removeDefault = inst.unwrap;
|
|
2939
|
+
});
|
|
2940
|
+
function _default(innerType, defaultValue) {
|
|
2941
|
+
return new ZodDefault({
|
|
2942
|
+
type: "default",
|
|
2943
|
+
innerType,
|
|
2944
|
+
get defaultValue() {
|
|
2945
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
2946
|
+
}
|
|
2947
|
+
});
|
|
2948
|
+
}
|
|
2949
|
+
var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
2950
|
+
$ZodPrefault.init(inst, def);
|
|
2951
|
+
ZodType.init(inst, def);
|
|
2952
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
2953
|
+
});
|
|
2954
|
+
function prefault(innerType, defaultValue) {
|
|
2955
|
+
return new ZodPrefault({
|
|
2956
|
+
type: "prefault",
|
|
2957
|
+
innerType,
|
|
2958
|
+
get defaultValue() {
|
|
2959
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
2960
|
+
}
|
|
2961
|
+
});
|
|
2962
|
+
}
|
|
2963
|
+
var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
2964
|
+
$ZodNonOptional.init(inst, def);
|
|
2965
|
+
ZodType.init(inst, def);
|
|
2966
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
2967
|
+
});
|
|
2968
|
+
function nonoptional(innerType, params) {
|
|
2969
|
+
return new ZodNonOptional({
|
|
2970
|
+
type: "nonoptional",
|
|
2971
|
+
innerType,
|
|
2972
|
+
...normalizeParams(params)
|
|
2973
|
+
});
|
|
2974
|
+
}
|
|
2975
|
+
var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
2976
|
+
$ZodCatch.init(inst, def);
|
|
2977
|
+
ZodType.init(inst, def);
|
|
2978
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
2979
|
+
inst.removeCatch = inst.unwrap;
|
|
2980
|
+
});
|
|
2981
|
+
function _catch(innerType, catchValue) {
|
|
2982
|
+
return new ZodCatch({
|
|
2983
|
+
type: "catch",
|
|
2984
|
+
innerType,
|
|
2985
|
+
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
2986
|
+
});
|
|
2987
|
+
}
|
|
2988
|
+
var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
2989
|
+
$ZodPipe.init(inst, def);
|
|
2990
|
+
ZodType.init(inst, def);
|
|
2991
|
+
inst.in = def.in;
|
|
2992
|
+
inst.out = def.out;
|
|
2993
|
+
});
|
|
2994
|
+
function pipe(in_, out) {
|
|
2995
|
+
return new ZodPipe({
|
|
2996
|
+
type: "pipe",
|
|
2997
|
+
in: in_,
|
|
2998
|
+
out
|
|
2999
|
+
});
|
|
3000
|
+
}
|
|
3001
|
+
var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
3002
|
+
$ZodReadonly.init(inst, def);
|
|
3003
|
+
ZodType.init(inst, def);
|
|
3004
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3005
|
+
});
|
|
3006
|
+
function readonly(innerType) {
|
|
3007
|
+
return new ZodReadonly({
|
|
3008
|
+
type: "readonly",
|
|
3009
|
+
innerType
|
|
3010
|
+
});
|
|
3011
|
+
}
|
|
3012
|
+
var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
3013
|
+
$ZodCustom.init(inst, def);
|
|
3014
|
+
ZodType.init(inst, def);
|
|
3015
|
+
});
|
|
3016
|
+
function refine(fn, _params = {}) {
|
|
3017
|
+
return _refine(ZodCustom, fn, _params);
|
|
3018
|
+
}
|
|
3019
|
+
function superRefine(fn) {
|
|
3020
|
+
return _superRefine(fn);
|
|
3021
|
+
}
|
|
3022
|
+
// src/args/types.ts
|
|
3023
|
+
var HOSTS = ["claude", "codex", "opencode"];
|
|
3024
|
+
var SCOPES = ["user", "project", "local"];
|
|
3025
|
+
var NOUNS = ["plugins", "agents"];
|
|
3026
|
+
var PLUGIN_VERBS = ["install", "list", "remove", "update"];
|
|
3027
|
+
var AGENT_VERBS = ["preview", "install", "remove"];
|
|
3028
|
+
var hostSchema = _enum(HOSTS);
|
|
3029
|
+
var scopeSchema = _enum(SCOPES);
|
|
3030
|
+
var nounSchema = _enum(NOUNS);
|
|
3031
|
+
|
|
3032
|
+
// src/args/parse.ts
|
|
3033
|
+
var BOOLEAN_FLAGS = new Set([
|
|
3034
|
+
"--yes",
|
|
3035
|
+
"-y",
|
|
3036
|
+
"--force",
|
|
3037
|
+
"--dry-run",
|
|
3038
|
+
"--no-input",
|
|
3039
|
+
"--json",
|
|
3040
|
+
"--help",
|
|
3041
|
+
"-h",
|
|
3042
|
+
"--version",
|
|
3043
|
+
"-v"
|
|
3044
|
+
]);
|
|
3045
|
+
var VALUE_FLAGS = new Set(["--host", "--scope", "--config"]);
|
|
3046
|
+
function collect(argv) {
|
|
3047
|
+
const positionals = [];
|
|
3048
|
+
const booleans = new Set;
|
|
3049
|
+
const values = new Map;
|
|
3050
|
+
for (let index = 0;index < argv.length; index += 1) {
|
|
3051
|
+
const token = argv[index] ?? "";
|
|
3052
|
+
if (BOOLEAN_FLAGS.has(token)) {
|
|
3053
|
+
booleans.add(token);
|
|
3054
|
+
continue;
|
|
3055
|
+
}
|
|
3056
|
+
if (VALUE_FLAGS.has(token)) {
|
|
3057
|
+
const next = argv[index + 1];
|
|
3058
|
+
if (next === undefined || next.startsWith("-")) {
|
|
3059
|
+
throw new UsageError(`${token} requires a value`);
|
|
3060
|
+
}
|
|
3061
|
+
values.set(token, next);
|
|
3062
|
+
index += 1;
|
|
3063
|
+
continue;
|
|
3064
|
+
}
|
|
3065
|
+
if (token.startsWith("-"))
|
|
3066
|
+
throw new UsageError(`unknown flag: ${token}`);
|
|
3067
|
+
positionals.push(token);
|
|
3068
|
+
}
|
|
3069
|
+
return { positionals, booleans, values };
|
|
3070
|
+
}
|
|
3071
|
+
function readNoun(positionals) {
|
|
3072
|
+
const first = positionals[0];
|
|
3073
|
+
if (first === undefined)
|
|
3074
|
+
return;
|
|
3075
|
+
const parsed = nounSchema.safeParse(first);
|
|
3076
|
+
if (!parsed.success) {
|
|
3077
|
+
throw new UsageError(`unknown command: ${first}. Expected one of: ${NOUNS.join(", ")}`);
|
|
3078
|
+
}
|
|
3079
|
+
return parsed.data;
|
|
3080
|
+
}
|
|
3081
|
+
function readVerb(noun, positionals) {
|
|
3082
|
+
if (noun === undefined)
|
|
3083
|
+
return;
|
|
3084
|
+
const verb = positionals[1];
|
|
3085
|
+
const allowed = noun === "plugins" ? PLUGIN_VERBS : AGENT_VERBS;
|
|
3086
|
+
if (verb === undefined)
|
|
3087
|
+
throw new UsageError(`${noun} requires a verb: ${allowed.join(", ")}`);
|
|
3088
|
+
if (!allowed.includes(verb)) {
|
|
3089
|
+
throw new UsageError(`unknown ${noun} verb: ${verb}. Expected one of: ${allowed.join(", ")}`);
|
|
3090
|
+
}
|
|
3091
|
+
return verb;
|
|
3092
|
+
}
|
|
3093
|
+
function readEnum(values, flag, schema, allowed) {
|
|
3094
|
+
const raw = values.get(flag);
|
|
3095
|
+
if (raw === undefined)
|
|
3096
|
+
return;
|
|
3097
|
+
const parsed = schema.safeParse(raw);
|
|
3098
|
+
if (!parsed.success) {
|
|
3099
|
+
throw new UsageError(`unknown ${flag} value: ${raw}. Expected one of: ${allowed.join(", ")}`);
|
|
3100
|
+
}
|
|
3101
|
+
return parsed.data;
|
|
3102
|
+
}
|
|
3103
|
+
function parseArgs(argv) {
|
|
3104
|
+
const { positionals, booleans, values } = collect(argv);
|
|
3105
|
+
const help = booleans.has("--help") || booleans.has("-h");
|
|
3106
|
+
const version = booleans.has("--version") || booleans.has("-v");
|
|
3107
|
+
const noun = readNoun(positionals);
|
|
3108
|
+
const verb = help || version ? undefined : readVerb(noun, positionals);
|
|
3109
|
+
const host = readEnum(values, "--host", hostSchema, HOSTS);
|
|
3110
|
+
const scope = readEnum(values, "--scope", scopeSchema, SCOPES);
|
|
3111
|
+
if (scope !== undefined && host !== undefined && host !== "claude") {
|
|
3112
|
+
throw new UsageError(scopeRejection(host));
|
|
3113
|
+
}
|
|
3114
|
+
return {
|
|
3115
|
+
noun,
|
|
3116
|
+
verb,
|
|
3117
|
+
names: positionals.slice(2),
|
|
3118
|
+
host,
|
|
3119
|
+
scope,
|
|
3120
|
+
config: values.get("--config"),
|
|
3121
|
+
yes: booleans.has("--yes") || booleans.has("-y"),
|
|
3122
|
+
force: booleans.has("--force"),
|
|
3123
|
+
dryRun: booleans.has("--dry-run"),
|
|
3124
|
+
noInput: booleans.has("--no-input"),
|
|
3125
|
+
json: booleans.has("--json"),
|
|
3126
|
+
help,
|
|
3127
|
+
version
|
|
3128
|
+
};
|
|
3129
|
+
}
|
|
3130
|
+
function scopeRejection(host) {
|
|
3131
|
+
return `--scope is Claude Code only; ${host} has no scope concept`;
|
|
3132
|
+
}
|
|
3133
|
+
function assertScopeAllowed(scope, host) {
|
|
3134
|
+
if (scope !== undefined && host !== "claude")
|
|
3135
|
+
throw new UsageError(scopeRejection(host));
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
// src/catalog/manifest.ts
|
|
3139
|
+
import { readFile } from "node:fs/promises";
|
|
3140
|
+
|
|
3141
|
+
// src/catalog/types.ts
|
|
3142
|
+
var dependencySchema = object({ name: string2(), marketplace: string2().optional() });
|
|
3143
|
+
var catalogEntrySchema = object({
|
|
3144
|
+
name: string2().min(1),
|
|
3145
|
+
description: string2().optional(),
|
|
3146
|
+
dependencies: array(dependencySchema).optional()
|
|
3147
|
+
});
|
|
3148
|
+
var marketplaceSchema = object({
|
|
3149
|
+
name: string2().min(1),
|
|
3150
|
+
plugins: array(catalogEntrySchema).min(1)
|
|
3151
|
+
});
|
|
3152
|
+
|
|
3153
|
+
// src/catalog/manifest.ts
|
|
3154
|
+
async function readMarketplace(path) {
|
|
3155
|
+
let raw;
|
|
3156
|
+
try {
|
|
3157
|
+
raw = await readFile(path, "utf8");
|
|
3158
|
+
} catch {
|
|
3159
|
+
throw new CliError(EXIT.failed, `cannot read marketplace manifest: ${path}`);
|
|
3160
|
+
}
|
|
3161
|
+
let parsed;
|
|
3162
|
+
try {
|
|
3163
|
+
parsed = JSON.parse(raw);
|
|
3164
|
+
} catch (error) {
|
|
3165
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
3166
|
+
throw new UsageError(`marketplace manifest is not valid JSON: ${path}: ${detail}`);
|
|
3167
|
+
}
|
|
3168
|
+
const result = marketplaceSchema.safeParse(parsed);
|
|
3169
|
+
if (!result.success) {
|
|
3170
|
+
throw new UsageError(`marketplace manifest is malformed: ${path}: ${result.error.message}`);
|
|
3171
|
+
}
|
|
3172
|
+
return result.data;
|
|
3173
|
+
}
|
|
3174
|
+
|
|
3175
|
+
// src/host/claude.ts
|
|
3176
|
+
var entrySchema = object({
|
|
3177
|
+
id: string2(),
|
|
3178
|
+
version: string2(),
|
|
3179
|
+
enabled: boolean2().optional(),
|
|
3180
|
+
installPath: string2().optional()
|
|
3181
|
+
});
|
|
3182
|
+
var listSchema = array(entrySchema);
|
|
3183
|
+
function splitId(id) {
|
|
3184
|
+
const at = id.lastIndexOf("@");
|
|
3185
|
+
if (at <= 0)
|
|
3186
|
+
return { name: id, marketplace: "" };
|
|
3187
|
+
return { name: id.slice(0, at), marketplace: id.slice(at + 1) };
|
|
3188
|
+
}
|
|
3189
|
+
var claudeAdapter = {
|
|
3190
|
+
host: "claude",
|
|
3191
|
+
bin: "claude",
|
|
3192
|
+
addMarketplace: (source) => ({
|
|
3193
|
+
argv: ["claude", "plugin", "marketplace", "add", source]
|
|
3194
|
+
}),
|
|
3195
|
+
install: (name, marketplace, scope) => ({
|
|
3196
|
+
argv: [
|
|
3197
|
+
"claude",
|
|
3198
|
+
"plugin",
|
|
3199
|
+
"install",
|
|
3200
|
+
`${name}@${marketplace}`,
|
|
3201
|
+
...scope === undefined ? [] : ["--scope", scope]
|
|
3202
|
+
]
|
|
3203
|
+
}),
|
|
3204
|
+
remove: (name, marketplace) => ({
|
|
3205
|
+
argv: ["claude", "plugin", "uninstall", `${name}@${marketplace}`]
|
|
3206
|
+
}),
|
|
3207
|
+
update: (name, marketplace) => ({
|
|
3208
|
+
argv: ["claude", "plugin", "update", `${name}@${marketplace}`]
|
|
3209
|
+
}),
|
|
3210
|
+
listInstalled: () => ({ argv: ["claude", "plugin", "list", "--json"] }),
|
|
3211
|
+
listAvailable: () => ({
|
|
3212
|
+
argv: ["claude", "plugin", "list", "--available", "--json"]
|
|
3213
|
+
}),
|
|
3214
|
+
parseList: (stdout) => {
|
|
3215
|
+
const parsed = listSchema.safeParse(JSON.parse(stdout));
|
|
3216
|
+
if (!parsed.success)
|
|
3217
|
+
throw new Error(`claude plugin list --json: ${parsed.error.message}`);
|
|
3218
|
+
return parsed.data.map((entry) => {
|
|
3219
|
+
const { name, marketplace } = splitId(entry.id);
|
|
3220
|
+
return {
|
|
3221
|
+
name,
|
|
3222
|
+
marketplace,
|
|
3223
|
+
version: entry.version,
|
|
3224
|
+
enabled: entry.enabled ?? true,
|
|
3225
|
+
path: entry.installPath
|
|
3226
|
+
};
|
|
3227
|
+
});
|
|
3228
|
+
}
|
|
3229
|
+
};
|
|
3230
|
+
|
|
3231
|
+
// src/host/codex.ts
|
|
3232
|
+
var entrySchema2 = object({
|
|
3233
|
+
name: string2(),
|
|
3234
|
+
marketplaceName: string2().optional(),
|
|
3235
|
+
version: string2(),
|
|
3236
|
+
enabled: boolean2().optional(),
|
|
3237
|
+
source: object({ path: string2().optional() }).optional()
|
|
3238
|
+
});
|
|
3239
|
+
var listSchema2 = object({ installed: array(entrySchema2) });
|
|
3240
|
+
var codexAdapter = {
|
|
3241
|
+
host: "codex",
|
|
3242
|
+
bin: "codex",
|
|
3243
|
+
addMarketplace: (source) => ({
|
|
3244
|
+
argv: ["codex", "plugin", "marketplace", "add", source]
|
|
3245
|
+
}),
|
|
3246
|
+
install: (name, marketplace) => ({
|
|
3247
|
+
argv: ["codex", "plugin", "add", `${name}@${marketplace}`]
|
|
3248
|
+
}),
|
|
3249
|
+
remove: (name, marketplace) => ({
|
|
3250
|
+
argv: ["codex", "plugin", "remove", `${name}@${marketplace}`]
|
|
3251
|
+
}),
|
|
3252
|
+
update: (name, marketplace) => ({
|
|
3253
|
+
argv: ["codex", "plugin", "add", `${name}@${marketplace}`]
|
|
3254
|
+
}),
|
|
3255
|
+
listInstalled: () => ({ argv: ["codex", "plugin", "list", "--json"] }),
|
|
3256
|
+
listAvailable: () => ({
|
|
3257
|
+
argv: ["codex", "plugin", "list", "--available", "--json"]
|
|
3258
|
+
}),
|
|
3259
|
+
parseList: (stdout) => {
|
|
3260
|
+
const parsed = listSchema2.safeParse(JSON.parse(stdout));
|
|
3261
|
+
if (!parsed.success)
|
|
3262
|
+
throw new Error(`codex plugin list --json: ${parsed.error.message}`);
|
|
3263
|
+
return parsed.data.installed.map((entry) => ({
|
|
3264
|
+
name: entry.name,
|
|
3265
|
+
marketplace: entry.marketplaceName ?? "",
|
|
3266
|
+
version: entry.version,
|
|
3267
|
+
enabled: entry.enabled ?? true,
|
|
3268
|
+
path: entry.source?.path
|
|
3269
|
+
}));
|
|
3270
|
+
}
|
|
3271
|
+
};
|
|
3272
|
+
|
|
3273
|
+
// src/host/run.ts
|
|
3274
|
+
import { spawn } from "node:child_process";
|
|
3275
|
+
import { constants } from "node:fs";
|
|
3276
|
+
import { access } from "node:fs/promises";
|
|
3277
|
+
import { delimiter, join } from "node:path";
|
|
3278
|
+
function run(argv, env = process.env) {
|
|
3279
|
+
const [command, ...rest] = argv;
|
|
3280
|
+
if (command === undefined)
|
|
3281
|
+
throw new Error("run requires a command");
|
|
3282
|
+
return new Promise((settle) => {
|
|
3283
|
+
const child = spawn(command, rest, { env, stdio: ["ignore", "pipe", "pipe"] });
|
|
3284
|
+
let stdout = "";
|
|
3285
|
+
let stderr = "";
|
|
3286
|
+
child.stdout.on("data", (chunk) => {
|
|
3287
|
+
stdout += chunk.toString("utf8");
|
|
3288
|
+
});
|
|
3289
|
+
child.stderr.on("data", (chunk) => {
|
|
3290
|
+
stderr += chunk.toString("utf8");
|
|
3291
|
+
});
|
|
3292
|
+
child.on("error", (error) => {
|
|
3293
|
+
settle({ code: 127, stdout, stderr: `${stderr}${error.message}` });
|
|
3294
|
+
});
|
|
3295
|
+
child.on("close", (code) => {
|
|
3296
|
+
settle({ code: code ?? 1, stdout, stderr });
|
|
3297
|
+
});
|
|
3298
|
+
});
|
|
3299
|
+
}
|
|
3300
|
+
async function binaryExists(bin, env = process.env) {
|
|
3301
|
+
for (const directory of (env.PATH ?? "").split(delimiter)) {
|
|
3302
|
+
if (directory.length === 0)
|
|
3303
|
+
continue;
|
|
3304
|
+
try {
|
|
3305
|
+
await access(join(directory, bin), constants.X_OK);
|
|
3306
|
+
return true;
|
|
3307
|
+
} catch {
|
|
3308
|
+
continue;
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
return false;
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3314
|
+
// src/host/detect.ts
|
|
3315
|
+
var ADAPTERS = [claudeAdapter, codexAdapter];
|
|
3316
|
+
var OPENCODE_BIN = "opencode";
|
|
3317
|
+
var PROBED = ["claude", "codex", OPENCODE_BIN];
|
|
3318
|
+
function adapterFor(host) {
|
|
3319
|
+
const adapter = ADAPTERS.find((candidate) => candidate.host === host);
|
|
3320
|
+
if (adapter === undefined) {
|
|
3321
|
+
throw new UsageError(`${host} has no adapter yet; see docs/opencode.md`);
|
|
3322
|
+
}
|
|
3323
|
+
return adapter;
|
|
3324
|
+
}
|
|
3325
|
+
async function availableHosts(env) {
|
|
3326
|
+
const found = [];
|
|
3327
|
+
for (const bin of PROBED) {
|
|
3328
|
+
if (await binaryExists(bin, env))
|
|
3329
|
+
found.push(bin === OPENCODE_BIN ? "opencode" : bin);
|
|
3330
|
+
}
|
|
3331
|
+
return found;
|
|
3332
|
+
}
|
|
3333
|
+
async function resolveHost(requested, env) {
|
|
3334
|
+
if (requested !== undefined)
|
|
3335
|
+
return { host: requested, ambiguous: [] };
|
|
3336
|
+
const available = await availableHosts(env);
|
|
3337
|
+
if (available.length === 0) {
|
|
3338
|
+
throw new CliError(EXIT.missingInput, `no host found on PATH (probed ${PROBED.join(", ")}). Choose one with --host.`);
|
|
3339
|
+
}
|
|
3340
|
+
const only = available[0];
|
|
3341
|
+
if (available.length === 1 && only !== undefined)
|
|
3342
|
+
return { host: only, ambiguous: [] };
|
|
3343
|
+
throw new CliError(EXIT.missingInput, `several hosts found (${available.join(", ")}). Choose one with --host.`);
|
|
3344
|
+
}
|
|
3345
|
+
|
|
3346
|
+
// src/catalog/order.ts
|
|
3347
|
+
function catalogNames(marketplace) {
|
|
3348
|
+
return marketplace.plugins.map((plugin) => plugin.name);
|
|
3349
|
+
}
|
|
3350
|
+
function dependencyNames(entry) {
|
|
3351
|
+
return (entry.dependencies ?? []).map((dependency) => dependency.name);
|
|
3352
|
+
}
|
|
3353
|
+
function visit(name, walk) {
|
|
3354
|
+
if (walk.seen.has(name))
|
|
3355
|
+
return;
|
|
3356
|
+
if (walk.active.has(name))
|
|
3357
|
+
throw new UsageError(`circular plugin dependency involving ${name}`);
|
|
3358
|
+
const entry = walk.entries.get(name);
|
|
3359
|
+
if (entry === undefined) {
|
|
3360
|
+
throw new UsageError(`unknown plugin: ${name}. Run \`toolu plugins list\` for the catalog.`);
|
|
3361
|
+
}
|
|
3362
|
+
walk.active.add(name);
|
|
3363
|
+
for (const dependency of dependencyNames(entry)) {
|
|
3364
|
+
if (walk.entries.has(dependency))
|
|
3365
|
+
visit(dependency, walk);
|
|
3366
|
+
}
|
|
3367
|
+
walk.active.delete(name);
|
|
3368
|
+
walk.seen.add(name);
|
|
3369
|
+
walk.ordered.push(name);
|
|
3370
|
+
}
|
|
3371
|
+
function installOrder(marketplace, requested) {
|
|
3372
|
+
const walk = {
|
|
3373
|
+
entries: new Map(marketplace.plugins.map((plugin) => [plugin.name, plugin])),
|
|
3374
|
+
ordered: [],
|
|
3375
|
+
seen: new Set,
|
|
3376
|
+
active: new Set
|
|
3377
|
+
};
|
|
3378
|
+
for (const name of requested.length > 0 ? requested : catalogNames(marketplace)) {
|
|
3379
|
+
visit(name, walk);
|
|
3380
|
+
}
|
|
3381
|
+
return walk.ordered;
|
|
3382
|
+
}
|
|
3383
|
+
function dependentsOf(marketplace, name) {
|
|
3384
|
+
return marketplace.plugins.filter((plugin) => dependencyNames(plugin).includes(name)).map((plugin) => plugin.name);
|
|
3385
|
+
}
|
|
3386
|
+
|
|
3387
|
+
// src/text.ts
|
|
3388
|
+
function firstLine(text, fallback) {
|
|
3389
|
+
return text.split(`
|
|
3390
|
+
`).find((line) => line.trim().length > 0)?.trim() ?? fallback;
|
|
3391
|
+
}
|
|
3392
|
+
|
|
3393
|
+
// src/plugins/install.ts
|
|
3394
|
+
var CORE = "toolu";
|
|
3395
|
+
async function versionsFrom(adapter, argv, env) {
|
|
3396
|
+
const result = await run([...argv], env);
|
|
3397
|
+
if (result.code !== 0)
|
|
3398
|
+
return new Map;
|
|
3399
|
+
try {
|
|
3400
|
+
return new Map(adapter.parseList(result.stdout).map((entry) => [entry.name, entry]));
|
|
3401
|
+
} catch {
|
|
3402
|
+
return new Map;
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
function presentStep(name, present, offered, argv) {
|
|
3406
|
+
if (offered === undefined || offered.version === present.version) {
|
|
3407
|
+
return { name, outcome: "already", detail: `already installed at ${present.version}`, argv };
|
|
3408
|
+
}
|
|
3409
|
+
return {
|
|
3410
|
+
name,
|
|
3411
|
+
outcome: "skew",
|
|
3412
|
+
detail: `installed at ${present.version}, marketplace offers ${offered.version}; left untouched. Run \`toolu plugins update ${name}\` to change it.`,
|
|
3413
|
+
argv
|
|
3414
|
+
};
|
|
3415
|
+
}
|
|
3416
|
+
async function installPlugins(options) {
|
|
3417
|
+
const order = installOrder(options.marketplace, options.requested);
|
|
3418
|
+
if (!options.dryRun) {
|
|
3419
|
+
await run([...options.adapter.addMarketplace(options.marketplaceSource).argv], options.env);
|
|
3420
|
+
}
|
|
3421
|
+
const installed = await versionsFrom(options.adapter, options.adapter.listInstalled().argv, options.env);
|
|
3422
|
+
const offered = await versionsFrom(options.adapter, options.adapter.listAvailable().argv, options.env);
|
|
3423
|
+
const coreDependents = new Set(dependentsOf(options.marketplace, CORE));
|
|
3424
|
+
const steps = [];
|
|
3425
|
+
let coreFailed = false;
|
|
3426
|
+
for (const name of order) {
|
|
3427
|
+
const { argv } = options.adapter.install(name, options.marketplaceName, options.scope);
|
|
3428
|
+
if (coreFailed && coreDependents.has(name)) {
|
|
3429
|
+
steps.push({ name, outcome: "skipped", detail: `skipped: ${CORE} failed`, argv });
|
|
3430
|
+
continue;
|
|
3431
|
+
}
|
|
3432
|
+
const present = installed.get(name);
|
|
3433
|
+
if (present !== undefined) {
|
|
3434
|
+
steps.push(presentStep(name, present, offered.get(name), argv));
|
|
3435
|
+
continue;
|
|
3436
|
+
}
|
|
3437
|
+
if (options.dryRun) {
|
|
3438
|
+
steps.push({ name, outcome: "skipped", detail: "dry run", argv });
|
|
3439
|
+
continue;
|
|
3440
|
+
}
|
|
3441
|
+
const result = await run([...argv], options.env);
|
|
3442
|
+
const ok = result.code === 0;
|
|
3443
|
+
steps.push({
|
|
3444
|
+
name,
|
|
3445
|
+
outcome: ok ? "installed" : "failed",
|
|
3446
|
+
detail: ok ? "installed" : firstLine(result.stderr, "install failed"),
|
|
3447
|
+
argv
|
|
3448
|
+
});
|
|
3449
|
+
if (!ok && name === CORE)
|
|
3450
|
+
coreFailed = true;
|
|
3451
|
+
}
|
|
3452
|
+
return steps;
|
|
3453
|
+
}
|
|
3454
|
+
|
|
3455
|
+
// src/plugins/list.ts
|
|
3456
|
+
async function listPlugins(adapter, marketplace, env) {
|
|
3457
|
+
const result = await run([...adapter.listInstalled().argv], env);
|
|
3458
|
+
const present = result.code === 0 ? new Map(adapter.parseList(result.stdout).map((entry) => [entry.name, entry])) : new Map;
|
|
3459
|
+
return catalogNames(marketplace).map((name) => {
|
|
3460
|
+
const entry = present.get(name);
|
|
3461
|
+
return {
|
|
3462
|
+
name,
|
|
3463
|
+
installed: entry !== undefined,
|
|
3464
|
+
version: entry?.version,
|
|
3465
|
+
enabled: entry?.enabled ?? false
|
|
3466
|
+
};
|
|
3467
|
+
});
|
|
3468
|
+
}
|
|
3469
|
+
|
|
3470
|
+
// src/plugins/remove.ts
|
|
3471
|
+
async function removePlugins(adapter, marketplaceName, names, env) {
|
|
3472
|
+
const steps = [];
|
|
3473
|
+
for (const name of names) {
|
|
3474
|
+
const { argv } = adapter.remove(name, marketplaceName);
|
|
3475
|
+
const result = await run([...argv], env);
|
|
3476
|
+
steps.push({
|
|
3477
|
+
name,
|
|
3478
|
+
removed: result.code === 0,
|
|
3479
|
+
detail: result.code === 0 ? "removed" : firstLine(result.stderr, "remove failed"),
|
|
3480
|
+
argv
|
|
3481
|
+
});
|
|
3482
|
+
}
|
|
3483
|
+
return steps;
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3486
|
+
// src/plugins/update.ts
|
|
3487
|
+
async function versions2(adapter, argv, env) {
|
|
3488
|
+
const result = await run([...argv], env);
|
|
3489
|
+
if (result.code !== 0)
|
|
3490
|
+
return new Map;
|
|
3491
|
+
try {
|
|
3492
|
+
return new Map(adapter.parseList(result.stdout).map((entry) => [entry.name, entry.version]));
|
|
3493
|
+
} catch {
|
|
3494
|
+
return new Map;
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
async function updatePlugins(adapter, marketplaceName, names, env) {
|
|
3498
|
+
const installed = await versions2(adapter, adapter.listInstalled().argv, env);
|
|
3499
|
+
const offered = await versions2(adapter, adapter.listAvailable().argv, env);
|
|
3500
|
+
const targets = names.length > 0 ? names : [...installed.keys()];
|
|
3501
|
+
if (targets.length === 0) {
|
|
3502
|
+
throw new CliError(EXIT.failed, `${adapter.bin} reported no installed plugins, so there is nothing to update`);
|
|
3503
|
+
}
|
|
3504
|
+
const steps = [];
|
|
3505
|
+
for (const name of targets) {
|
|
3506
|
+
const { argv } = adapter.update(name, marketplaceName);
|
|
3507
|
+
const have = installed.get(name);
|
|
3508
|
+
const want = offered.get(name);
|
|
3509
|
+
if (have !== undefined && want !== undefined && have === want) {
|
|
3510
|
+
steps.push({ name, outcome: "current", detail: `current at ${have}`, argv });
|
|
3511
|
+
continue;
|
|
3512
|
+
}
|
|
3513
|
+
const result = await run([...argv], env);
|
|
3514
|
+
steps.push({
|
|
3515
|
+
name,
|
|
3516
|
+
outcome: result.code === 0 ? "updated" : "failed",
|
|
3517
|
+
detail: result.code === 0 ? want === undefined ? "updated" : `updated to ${want}` : "update failed",
|
|
3518
|
+
argv
|
|
3519
|
+
});
|
|
3520
|
+
}
|
|
3521
|
+
return steps;
|
|
3522
|
+
}
|
|
3523
|
+
|
|
3524
|
+
// src/ui/report.ts
|
|
3525
|
+
var MARK = {
|
|
3526
|
+
installed: "+",
|
|
3527
|
+
already: "=",
|
|
3528
|
+
skew: "!",
|
|
3529
|
+
failed: "x",
|
|
3530
|
+
skipped: "-",
|
|
3531
|
+
updated: "+",
|
|
3532
|
+
current: "="
|
|
3533
|
+
};
|
|
3534
|
+
function line(mark, name, detail) {
|
|
3535
|
+
return ` ${mark} ${name.padEnd(16)} ${detail}
|
|
3536
|
+
`;
|
|
3537
|
+
}
|
|
3538
|
+
function reportInstall(steps, dryRun) {
|
|
3539
|
+
const header = dryRun ? `Planned commands (nothing was run):
|
|
3540
|
+
` : "";
|
|
3541
|
+
const body = steps.map((step) => dryRun ? ` ${step.argv.join(" ")}
|
|
3542
|
+
` : line(MARK[step.outcome] ?? "?", step.name, step.detail)).join("");
|
|
3543
|
+
return `${header}${body}`;
|
|
3544
|
+
}
|
|
3545
|
+
function reportList(entries) {
|
|
3546
|
+
return entries.map((entry) => line(entry.installed ? "=" : "-", entry.name, entry.installed ? `${entry.version ?? "?"}${entry.enabled ? "" : " (disabled)"}` : "not installed")).join("");
|
|
3547
|
+
}
|
|
3548
|
+
function reportRemove(steps) {
|
|
3549
|
+
return steps.map((step) => line(step.removed ? "-" : "x", step.name, step.detail)).join("");
|
|
3550
|
+
}
|
|
3551
|
+
function reportUpdate(steps) {
|
|
3552
|
+
return steps.map((step) => line(MARK[step.outcome] ?? "?", step.name, step.detail)).join("");
|
|
3553
|
+
}
|
|
3554
|
+
function anyFailed(steps) {
|
|
3555
|
+
return steps.some((step) => ("removed" in step) ? !step.removed : step.outcome === "failed");
|
|
3556
|
+
}
|
|
3557
|
+
|
|
3558
|
+
// src/plugins/dispatch.ts
|
|
3559
|
+
var MARKETPLACE_NAME = "toolu";
|
|
3560
|
+
var MARKETPLACE_SOURCE = "Falconiere/toolu";
|
|
3561
|
+
async function handleInstall(args, marketplace, context) {
|
|
3562
|
+
const host = await resolvedHost(args);
|
|
3563
|
+
const steps = await installPlugins({
|
|
3564
|
+
adapter: adapterFor(host),
|
|
3565
|
+
marketplace,
|
|
3566
|
+
marketplaceName: MARKETPLACE_NAME,
|
|
3567
|
+
marketplaceSource: MARKETPLACE_SOURCE,
|
|
3568
|
+
requested: args.names,
|
|
3569
|
+
scope: args.scope,
|
|
3570
|
+
dryRun: args.dryRun
|
|
3571
|
+
});
|
|
3572
|
+
context.write(reportInstall(steps, args.dryRun));
|
|
3573
|
+
return anyFailed(steps) ? EXIT.failed : EXIT.ok;
|
|
3574
|
+
}
|
|
3575
|
+
async function resolvedHost(args) {
|
|
3576
|
+
const { host } = await resolveHost(args.host);
|
|
3577
|
+
if (host === "opencode") {
|
|
3578
|
+
throw new UsageError("OpenCode is not wired into the CLI yet. Install the bridge with `opencode plugin add @toolu/opencode`; see docs/opencode.md");
|
|
3579
|
+
}
|
|
3580
|
+
assertScopeAllowed(args.scope, host);
|
|
3581
|
+
return host;
|
|
3582
|
+
}
|
|
3583
|
+
async function handleRemove(args, context) {
|
|
3584
|
+
if (args.names.length === 0)
|
|
3585
|
+
throw new UsageError("plugins remove requires at least one name");
|
|
3586
|
+
if (!args.yes) {
|
|
3587
|
+
throw new CliError(EXIT.missingInput, "plugins remove requires --yes to confirm");
|
|
3588
|
+
}
|
|
3589
|
+
const host = await resolvedHost(args);
|
|
3590
|
+
const steps = await removePlugins(adapterFor(host), MARKETPLACE_NAME, args.names);
|
|
3591
|
+
context.write(reportRemove(steps));
|
|
3592
|
+
return anyFailed(steps) ? EXIT.failed : EXIT.ok;
|
|
3593
|
+
}
|
|
3594
|
+
async function dispatchPlugins(args, context) {
|
|
3595
|
+
const marketplace = await readMarketplace(context.manifestPath);
|
|
3596
|
+
if (args.verb === "install")
|
|
3597
|
+
return handleInstall(args, marketplace, context);
|
|
3598
|
+
if (args.verb === "remove")
|
|
3599
|
+
return handleRemove(args, context);
|
|
3600
|
+
const host = await resolvedHost(args);
|
|
3601
|
+
if (args.verb === "list") {
|
|
3602
|
+
const entries = await listPlugins(adapterFor(host), marketplace);
|
|
3603
|
+
context.write(args.json ? `${JSON.stringify(entries, null, 2)}
|
|
3604
|
+
` : reportList(entries));
|
|
3605
|
+
return EXIT.ok;
|
|
3606
|
+
}
|
|
3607
|
+
const steps = await updatePlugins(adapterFor(host), MARKETPLACE_NAME, args.names);
|
|
3608
|
+
context.write(reportUpdate(steps));
|
|
3609
|
+
return anyFailed(steps) ? EXIT.failed : EXIT.ok;
|
|
3610
|
+
}
|
|
3611
|
+
|
|
3612
|
+
// src/cli.ts
|
|
3613
|
+
var HELP = `toolu <noun> <verb> [options]
|
|
3614
|
+
|
|
3615
|
+
Install toolu plugins and Codex agent profiles.
|
|
3616
|
+
|
|
3617
|
+
Commands:
|
|
3618
|
+
plugins install [name...] Install plugins, core first (no names = all)
|
|
3619
|
+
plugins list Show catalog and installation state
|
|
3620
|
+
plugins remove <name...> Uninstall plugins
|
|
3621
|
+
plugins update [name...] Update plugins to the marketplace version
|
|
3622
|
+
agents preview Show the Codex agent-profile plan, writing nothing
|
|
3623
|
+
agents install Install Codex agent profiles
|
|
3624
|
+
agents remove --yes Remove Codex agent profiles
|
|
3625
|
+
|
|
3626
|
+
Options:
|
|
3627
|
+
--host <id> claude | codex | opencode (detected when omitted)
|
|
3628
|
+
--scope <scope> user | project | local (Claude Code only)
|
|
3629
|
+
--config <path> Replay a .toolu/plugins.json selection
|
|
3630
|
+
--yes, -y Confirm destructive or command-declaring operations
|
|
3631
|
+
--force Replace an unmanaged conflicting file, after backup
|
|
3632
|
+
--dry-run Print the host commands without running them
|
|
3633
|
+
--no-input Never prompt; fail listing what is missing
|
|
3634
|
+
--json Machine-readable output where supported
|
|
3635
|
+
-h, --help Show help
|
|
3636
|
+
-v, --version Show the version
|
|
3637
|
+
`;
|
|
3638
|
+
async function packageVersion() {
|
|
3639
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
3640
|
+
for (const candidate of ["../package.json", "../../package.json"]) {
|
|
3641
|
+
try {
|
|
3642
|
+
const raw = JSON.parse(await readFile2(resolve(here, candidate), "utf8"));
|
|
3643
|
+
if (typeof raw === "object" && raw !== null && "version" in raw) {
|
|
3644
|
+
const { version } = raw;
|
|
3645
|
+
if (typeof version === "string")
|
|
3646
|
+
return version;
|
|
3647
|
+
}
|
|
3648
|
+
} catch {
|
|
3649
|
+
continue;
|
|
3650
|
+
}
|
|
3651
|
+
}
|
|
3652
|
+
throw new Error("package version is missing");
|
|
3653
|
+
}
|
|
3654
|
+
function isInteractive(noInput) {
|
|
3655
|
+
return !noInput && process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
3656
|
+
}
|
|
3657
|
+
async function manifestPath() {
|
|
3658
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
3659
|
+
const candidates = [
|
|
3660
|
+
resolve(here, "../assets/marketplace.json"),
|
|
3661
|
+
resolve(here, "../../assets/marketplace.json"),
|
|
3662
|
+
resolve(here, "../../../.claude-plugin/marketplace.json")
|
|
3663
|
+
];
|
|
3664
|
+
for (const candidate of candidates) {
|
|
3665
|
+
if (await readable(candidate))
|
|
3666
|
+
return candidate;
|
|
3667
|
+
}
|
|
3668
|
+
throw new Error("marketplace manifest not found beside the CLI or in the repository");
|
|
3669
|
+
}
|
|
3670
|
+
async function readable(path) {
|
|
3671
|
+
try {
|
|
3672
|
+
await access2(path, constants2.R_OK);
|
|
3673
|
+
return true;
|
|
3674
|
+
} catch {
|
|
3675
|
+
return false;
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
async function main(argv = process.argv.slice(2)) {
|
|
3679
|
+
try {
|
|
3680
|
+
const args = parseArgs(argv);
|
|
3681
|
+
if (args.version) {
|
|
3682
|
+
process.stdout.write(`${await packageVersion()}
|
|
3683
|
+
`);
|
|
3684
|
+
return EXIT.ok;
|
|
3685
|
+
}
|
|
3686
|
+
if (args.help || args.noun === undefined) {
|
|
3687
|
+
process.stdout.write(HELP);
|
|
3688
|
+
return args.noun === undefined && !args.help ? EXIT.usage : EXIT.ok;
|
|
3689
|
+
}
|
|
3690
|
+
if (args.noun === "plugins") {
|
|
3691
|
+
return await dispatchPlugins(args, {
|
|
3692
|
+
manifestPath: await manifestPath(),
|
|
3693
|
+
interactive: isInteractive(args.noInput),
|
|
3694
|
+
write: (text) => process.stdout.write(text)
|
|
3695
|
+
});
|
|
3696
|
+
}
|
|
3697
|
+
throw new UsageError(`${args.noun} ${args.verb ?? ""} is not implemented yet`.trim());
|
|
3698
|
+
} catch (error) {
|
|
3699
|
+
if (error instanceof CliError) {
|
|
3700
|
+
process.stderr.write(`toolu: ${error.message}
|
|
3701
|
+
`);
|
|
3702
|
+
return error.code;
|
|
3703
|
+
}
|
|
3704
|
+
process.stderr.write(`toolu: ${error instanceof Error ? error.message : String(error)}
|
|
3705
|
+
`);
|
|
3706
|
+
return EXIT.failed;
|
|
3707
|
+
}
|
|
3708
|
+
}
|
|
3709
|
+
if (__require.main == __require.module === true)
|
|
3710
|
+
process.exitCode = await main();
|
|
3711
|
+
export {
|
|
3712
|
+
main
|
|
3713
|
+
};
|