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