@repome/sdk 0.1.5 → 0.1.6

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