@fanvue/builder-sdk 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +284 -0
- package/dist/bridge/index.d.ts +1 -1
- package/dist/bridge/index.js +2 -2
- package/dist/{bridge-CGVtI3hr.js → bridge-QnF7P4Co.js} +2 -2
- package/dist/{bridge-CGVtI3hr.js.map → bridge-QnF7P4Co.js.map} +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +3 -3
- package/dist/{core-BqdYUMrJ.js → core-BhKiA55a.js} +1318 -9
- package/dist/core-BhKiA55a.js.map +1 -0
- package/dist/index-C3CXrRiw.d.ts +1412 -0
- package/dist/index-C3CXrRiw.d.ts.map +1 -0
- package/dist/{index-BRDYLBlc.d.ts → index-CEFYZtlb.d.ts} +2 -2
- package/dist/{index-BRDYLBlc.d.ts.map → index-CEFYZtlb.d.ts.map} +1 -1
- package/dist/{index-Dr-mZ0qP.d.ts → index-cf3ZMnLJ.d.ts} +26 -2
- package/dist/index-cf3ZMnLJ.d.ts.map +1 -0
- package/dist/index-v_6Z4Q0u.d.ts +84 -0
- package/dist/index-v_6Z4Q0u.d.ts.map +1 -0
- package/dist/{schemas-DbyHF7Xi.js → index.cjs-teGsk6HB.js} +1058 -977
- package/dist/index.cjs-teGsk6HB.js.map +1 -0
- package/dist/nextjs/embedded-app/index.d.ts +2 -2
- package/dist/nextjs/embedded-app/index.js +3 -3
- package/dist/nextjs/off-platform/index.d.ts +3 -3
- package/dist/nextjs/off-platform/index.d.ts.map +1 -1
- package/dist/nextjs/off-platform/index.js +4 -4
- package/dist/nextjs/off-platform/index.js.map +1 -1
- package/dist/nextjs-CvVhtMdb.js +144 -0
- package/dist/nextjs-CvVhtMdb.js.map +1 -0
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +3 -3
- package/package.json +1 -1
- package/dist/core-BqdYUMrJ.js.map +0 -1
- package/dist/index-C4ewLil3.d.ts +0 -48
- package/dist/index-C4ewLil3.d.ts.map +0 -1
- package/dist/index-ClbZoV_Z.d.ts +0 -420
- package/dist/index-ClbZoV_Z.d.ts.map +0 -1
- package/dist/index-Dr-mZ0qP.d.ts.map +0 -1
- package/dist/nextjs-B5Tqgt_n.js +0 -80
- package/dist/nextjs-B5Tqgt_n.js.map +0 -1
- package/dist/schemas-DbyHF7Xi.js.map +0 -1
|
@@ -1,730 +1,243 @@
|
|
|
1
1
|
//#region \0rolldown/runtime.js
|
|
2
2
|
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
value: result.value
|
|
12
|
-
} : {
|
|
13
|
-
type: "Err",
|
|
14
|
-
value: result.error
|
|
3
|
+
Object.freeze({ status: "aborted" });
|
|
4
|
+
function $constructor(name, initializer, params) {
|
|
5
|
+
function init(inst, def) {
|
|
6
|
+
if (!inst._zod) Object.defineProperty(inst, "_zod", {
|
|
7
|
+
value: {
|
|
8
|
+
def,
|
|
9
|
+
constr: _,
|
|
10
|
+
traits: /* @__PURE__ */ new Set()
|
|
15
11
|
},
|
|
16
|
-
|
|
17
|
-
stack: config.withStackTrace ? (/* @__PURE__ */ new Error()).stack : void 0
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
/******************************************************************************
|
|
21
|
-
Copyright (c) Microsoft Corporation.
|
|
22
|
-
|
|
23
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
24
|
-
purpose with or without fee is hereby granted.
|
|
25
|
-
|
|
26
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
27
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
28
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
29
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
30
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
31
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
32
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
33
|
-
***************************************************************************** */
|
|
34
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
35
|
-
function adopt(value) {
|
|
36
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
37
|
-
resolve(value);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
41
|
-
function fulfilled(value) {
|
|
42
|
-
try {
|
|
43
|
-
step(generator.next(value));
|
|
44
|
-
} catch (e) {
|
|
45
|
-
reject(e);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function rejected(value) {
|
|
49
|
-
try {
|
|
50
|
-
step(generator["throw"](value));
|
|
51
|
-
} catch (e) {
|
|
52
|
-
reject(e);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function step(result) {
|
|
56
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
57
|
-
}
|
|
58
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
enumerable: false
|
|
59
13
|
});
|
|
14
|
+
if (inst._zod.traits.has(name)) return;
|
|
15
|
+
inst._zod.traits.add(name);
|
|
16
|
+
initializer(inst, def);
|
|
17
|
+
const proto = _.prototype;
|
|
18
|
+
const keys = Object.keys(proto);
|
|
19
|
+
for (let i = 0; i < keys.length; i++) {
|
|
20
|
+
const k = keys[i];
|
|
21
|
+
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
22
|
+
}
|
|
60
23
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
72
|
-
}
|
|
73
|
-
function __await(v) {
|
|
74
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
24
|
+
const Parent = params?.Parent ?? Object;
|
|
25
|
+
class Definition extends Parent {}
|
|
26
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
27
|
+
function _(def) {
|
|
28
|
+
var _a;
|
|
29
|
+
const inst = params?.Parent ? new Definition() : this;
|
|
30
|
+
init(inst, def);
|
|
31
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
32
|
+
for (const fn of inst._zod.deferred) fn();
|
|
33
|
+
return inst;
|
|
75
34
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
function verb(n, f) {
|
|
88
|
-
if (g[n]) {
|
|
89
|
-
i[n] = function(v) {
|
|
90
|
-
return new Promise(function(a, b) {
|
|
91
|
-
q.push([
|
|
92
|
-
n,
|
|
93
|
-
v,
|
|
94
|
-
a,
|
|
95
|
-
b
|
|
96
|
-
]) > 1 || resume(n, v);
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
if (f) i[n] = f(i[n]);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
function resume(n, v) {
|
|
103
|
-
try {
|
|
104
|
-
step(g[n](v));
|
|
105
|
-
} catch (e) {
|
|
106
|
-
settle(q[0][3], e);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function step(r) {
|
|
110
|
-
r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
|
|
111
|
-
}
|
|
112
|
-
function fulfill(value) {
|
|
113
|
-
resume("next", value);
|
|
114
|
-
}
|
|
115
|
-
function reject(value) {
|
|
116
|
-
resume("throw", value);
|
|
117
|
-
}
|
|
118
|
-
function settle(f, v) {
|
|
119
|
-
if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
|
|
120
|
-
}
|
|
35
|
+
Object.defineProperty(_, "init", { value: init });
|
|
36
|
+
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
37
|
+
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
38
|
+
return inst?._zod?.traits?.has(name);
|
|
39
|
+
} });
|
|
40
|
+
Object.defineProperty(_, "name", { value: name });
|
|
41
|
+
return _;
|
|
42
|
+
}
|
|
43
|
+
var $ZodAsyncError = class extends Error {
|
|
44
|
+
constructor() {
|
|
45
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
121
46
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return this;
|
|
128
|
-
}, i;
|
|
129
|
-
function verb(n, f) {
|
|
130
|
-
i[n] = o[n] ? function(v) {
|
|
131
|
-
return (p = !p) ? {
|
|
132
|
-
value: __await(o[n](v)),
|
|
133
|
-
done: false
|
|
134
|
-
} : f ? f(v) : v;
|
|
135
|
-
} : f;
|
|
136
|
-
}
|
|
47
|
+
};
|
|
48
|
+
var $ZodEncodeError = class extends Error {
|
|
49
|
+
constructor(name) {
|
|
50
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
51
|
+
this.name = "ZodEncodeError";
|
|
137
52
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
53
|
+
};
|
|
54
|
+
const globalConfig = {};
|
|
55
|
+
function config(newConfig) {
|
|
56
|
+
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
57
|
+
return globalConfig;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js
|
|
61
|
+
function getEnumValues(entries) {
|
|
62
|
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
63
|
+
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
64
|
+
}
|
|
65
|
+
function jsonStringifyReplacer(_, value) {
|
|
66
|
+
if (typeof value === "bigint") return value.toString();
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
function cached(getter) {
|
|
70
|
+
return { get value() {
|
|
71
|
+
{
|
|
72
|
+
const value = getter();
|
|
73
|
+
Object.defineProperty(this, "value", { value });
|
|
74
|
+
return value;
|
|
158
75
|
}
|
|
76
|
+
throw new Error("cached value already set");
|
|
77
|
+
} };
|
|
78
|
+
}
|
|
79
|
+
function nullish(input) {
|
|
80
|
+
return input === null || input === void 0;
|
|
81
|
+
}
|
|
82
|
+
function cleanRegex(source) {
|
|
83
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
84
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
85
|
+
return source.slice(start, end);
|
|
86
|
+
}
|
|
87
|
+
function floatSafeRemainder(val, step) {
|
|
88
|
+
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
89
|
+
const stepString = step.toString();
|
|
90
|
+
let stepDecCount = (stepString.split(".")[1] || "").length;
|
|
91
|
+
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
|
|
92
|
+
const match = stepString.match(/\d?e-(\d?)/);
|
|
93
|
+
if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
|
|
159
94
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
195
|
-
if (res.isErr()) return new Err(res.error);
|
|
196
|
-
const newRes = yield f(res.value);
|
|
197
|
-
if (newRes.isErr()) return new Err(newRes.error);
|
|
198
|
-
return new Ok(res.value);
|
|
199
|
-
})));
|
|
200
|
-
}
|
|
201
|
-
andTee(f) {
|
|
202
|
-
return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
203
|
-
if (res.isErr()) return new Err(res.error);
|
|
204
|
-
try {
|
|
205
|
-
yield f(res.value);
|
|
206
|
-
} catch (e) {}
|
|
207
|
-
return new Ok(res.value);
|
|
208
|
-
})));
|
|
209
|
-
}
|
|
210
|
-
orTee(f) {
|
|
211
|
-
return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
212
|
-
if (res.isOk()) return new Ok(res.value);
|
|
213
|
-
try {
|
|
214
|
-
yield f(res.error);
|
|
215
|
-
} catch (e) {}
|
|
216
|
-
return new Err(res.error);
|
|
217
|
-
})));
|
|
218
|
-
}
|
|
219
|
-
mapErr(f) {
|
|
220
|
-
return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
221
|
-
if (res.isOk()) return new Ok(res.value);
|
|
222
|
-
return new Err(yield f(res.error));
|
|
223
|
-
})));
|
|
224
|
-
}
|
|
225
|
-
andThen(f) {
|
|
226
|
-
return new ResultAsync(this._promise.then((res) => {
|
|
227
|
-
if (res.isErr()) return new Err(res.error);
|
|
228
|
-
const newValue = f(res.value);
|
|
229
|
-
return newValue instanceof ResultAsync ? newValue._promise : newValue;
|
|
230
|
-
}));
|
|
231
|
-
}
|
|
232
|
-
orElse(f) {
|
|
233
|
-
return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
234
|
-
if (res.isErr()) return f(res.error);
|
|
235
|
-
return new Ok(res.value);
|
|
236
|
-
})));
|
|
237
|
-
}
|
|
238
|
-
match(ok, _err) {
|
|
239
|
-
return this._promise.then((res) => res.match(ok, _err));
|
|
240
|
-
}
|
|
241
|
-
unwrapOr(t) {
|
|
242
|
-
return this._promise.then((res) => res.unwrapOr(t));
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* @deprecated will be removed in 9.0.0.
|
|
246
|
-
*
|
|
247
|
-
* You can use `safeTry` without this method.
|
|
248
|
-
* @example
|
|
249
|
-
* ```typescript
|
|
250
|
-
* safeTry(async function* () {
|
|
251
|
-
* const okValue = yield* yourResult
|
|
252
|
-
* })
|
|
253
|
-
* ```
|
|
254
|
-
* Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
|
|
255
|
-
*/
|
|
256
|
-
safeUnwrap() {
|
|
257
|
-
return __asyncGenerator(this, arguments, function* safeUnwrap_1() {
|
|
258
|
-
return yield __await(yield __await(yield* __asyncDelegator(__asyncValues(yield __await(this._promise.then((res) => res.safeUnwrap()))))));
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
then(successCallback, failureCallback) {
|
|
262
|
-
return this._promise.then(successCallback, failureCallback);
|
|
263
|
-
}
|
|
264
|
-
[Symbol.asyncIterator]() {
|
|
265
|
-
return __asyncGenerator(this, arguments, function* _a() {
|
|
266
|
-
const result = yield __await(this._promise);
|
|
267
|
-
if (result.isErr()) yield yield __await(errAsync(result.error));
|
|
268
|
-
return yield __await(result.value);
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
function okAsync(value) {
|
|
273
|
-
return new ResultAsync(Promise.resolve(new Ok(value)));
|
|
274
|
-
}
|
|
275
|
-
function errAsync(err) {
|
|
276
|
-
return new ResultAsync(Promise.resolve(new Err(err)));
|
|
277
|
-
}
|
|
278
|
-
const fromPromise = ResultAsync.fromPromise;
|
|
279
|
-
const fromSafePromise = ResultAsync.fromSafePromise;
|
|
280
|
-
const fromAsyncThrowable = ResultAsync.fromThrowable;
|
|
281
|
-
/**
|
|
282
|
-
* Short circuits on the FIRST Err value that we find
|
|
283
|
-
*/
|
|
284
|
-
const combineResultList = (resultList) => {
|
|
285
|
-
let acc = ok([]);
|
|
286
|
-
for (const result of resultList) if (result.isErr()) {
|
|
287
|
-
acc = err(result.error);
|
|
288
|
-
break;
|
|
289
|
-
} else acc.map((list) => list.push(result.value));
|
|
290
|
-
return acc;
|
|
291
|
-
};
|
|
292
|
-
const combineResultAsyncList = (asyncResultList) => ResultAsync.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultList);
|
|
293
|
-
/**
|
|
294
|
-
* Give a list of all the errors we find
|
|
295
|
-
*/
|
|
296
|
-
const combineResultListWithAllErrors = (resultList) => {
|
|
297
|
-
let acc = ok([]);
|
|
298
|
-
for (const result of resultList) if (result.isErr() && acc.isErr()) acc.error.push(result.error);
|
|
299
|
-
else if (result.isErr() && acc.isOk()) acc = err([result.error]);
|
|
300
|
-
else if (result.isOk() && acc.isOk()) acc.value.push(result.value);
|
|
301
|
-
return acc;
|
|
302
|
-
};
|
|
303
|
-
const combineResultAsyncListWithAllErrors = (asyncResultList) => ResultAsync.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultListWithAllErrors);
|
|
304
|
-
exports.Result = void 0;
|
|
305
|
-
(function(Result) {
|
|
306
|
-
/**
|
|
307
|
-
* Wraps a function with a try catch, creating a new function with the same
|
|
308
|
-
* arguments but returning `Ok` if successful, `Err` if the function throws
|
|
309
|
-
*
|
|
310
|
-
* @param fn function to wrap with ok on success or err on failure
|
|
311
|
-
* @param errorFn when an error is thrown, this will wrap the error result if provided
|
|
312
|
-
*/
|
|
313
|
-
function fromThrowable(fn, errorFn) {
|
|
314
|
-
return (...args) => {
|
|
315
|
-
try {
|
|
316
|
-
return ok(fn(...args));
|
|
317
|
-
} catch (e) {
|
|
318
|
-
return err(errorFn ? errorFn(e) : e);
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
Result.fromThrowable = fromThrowable;
|
|
323
|
-
function combine(resultList) {
|
|
324
|
-
return combineResultList(resultList);
|
|
325
|
-
}
|
|
326
|
-
Result.combine = combine;
|
|
327
|
-
function combineWithAllErrors(resultList) {
|
|
328
|
-
return combineResultListWithAllErrors(resultList);
|
|
329
|
-
}
|
|
330
|
-
Result.combineWithAllErrors = combineWithAllErrors;
|
|
331
|
-
})(exports.Result || (exports.Result = {}));
|
|
332
|
-
function ok(value) {
|
|
333
|
-
return new Ok(value);
|
|
95
|
+
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
96
|
+
return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
|
|
97
|
+
}
|
|
98
|
+
const EVALUATING = Symbol("evaluating");
|
|
99
|
+
function defineLazy(object, key, getter) {
|
|
100
|
+
let value = void 0;
|
|
101
|
+
Object.defineProperty(object, key, {
|
|
102
|
+
get() {
|
|
103
|
+
if (value === EVALUATING) return;
|
|
104
|
+
if (value === void 0) {
|
|
105
|
+
value = EVALUATING;
|
|
106
|
+
value = getter();
|
|
107
|
+
}
|
|
108
|
+
return value;
|
|
109
|
+
},
|
|
110
|
+
set(v) {
|
|
111
|
+
Object.defineProperty(object, key, { value: v });
|
|
112
|
+
},
|
|
113
|
+
configurable: true
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function assignProp(target, prop, value) {
|
|
117
|
+
Object.defineProperty(target, prop, {
|
|
118
|
+
value,
|
|
119
|
+
writable: true,
|
|
120
|
+
enumerable: true,
|
|
121
|
+
configurable: true
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function mergeDefs(...defs) {
|
|
125
|
+
const mergedDescriptors = {};
|
|
126
|
+
for (const def of defs) {
|
|
127
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
128
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
334
129
|
}
|
|
335
|
-
|
|
336
|
-
|
|
130
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
131
|
+
}
|
|
132
|
+
function esc(str) {
|
|
133
|
+
return JSON.stringify(str);
|
|
134
|
+
}
|
|
135
|
+
function slugify(input) {
|
|
136
|
+
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
137
|
+
}
|
|
138
|
+
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
139
|
+
function isObject(data) {
|
|
140
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
141
|
+
}
|
|
142
|
+
const allowsEval = cached(() => {
|
|
143
|
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
|
|
144
|
+
try {
|
|
145
|
+
new Function("");
|
|
146
|
+
return true;
|
|
147
|
+
} catch (_) {
|
|
148
|
+
return false;
|
|
337
149
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
150
|
+
});
|
|
151
|
+
function isPlainObject(o) {
|
|
152
|
+
if (isObject(o) === false) return false;
|
|
153
|
+
const ctor = o.constructor;
|
|
154
|
+
if (ctor === void 0) return true;
|
|
155
|
+
if (typeof ctor !== "function") return true;
|
|
156
|
+
const prot = ctor.prototype;
|
|
157
|
+
if (isObject(prot) === false) return false;
|
|
158
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
function shallowClone(o) {
|
|
162
|
+
if (isPlainObject(o)) return { ...o };
|
|
163
|
+
if (Array.isArray(o)) return [...o];
|
|
164
|
+
return o;
|
|
165
|
+
}
|
|
166
|
+
const propertyKeyTypes = new Set([
|
|
167
|
+
"string",
|
|
168
|
+
"number",
|
|
169
|
+
"symbol"
|
|
170
|
+
]);
|
|
171
|
+
function escapeRegex(str) {
|
|
172
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
173
|
+
}
|
|
174
|
+
function clone(inst, def, params) {
|
|
175
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
176
|
+
if (!def || params?.parent) cl._zod.parent = inst;
|
|
177
|
+
return cl;
|
|
178
|
+
}
|
|
179
|
+
function normalizeParams(_params) {
|
|
180
|
+
const params = _params;
|
|
181
|
+
if (!params) return {};
|
|
182
|
+
if (typeof params === "string") return { error: () => params };
|
|
183
|
+
if (params?.message !== void 0) {
|
|
184
|
+
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
|
185
|
+
params.error = params.message;
|
|
342
186
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
isOk() {
|
|
348
|
-
return true;
|
|
349
|
-
}
|
|
350
|
-
isErr() {
|
|
351
|
-
return !this.isOk();
|
|
352
|
-
}
|
|
353
|
-
map(f) {
|
|
354
|
-
return ok(f(this.value));
|
|
355
|
-
}
|
|
356
|
-
mapErr(_f) {
|
|
357
|
-
return ok(this.value);
|
|
358
|
-
}
|
|
359
|
-
andThen(f) {
|
|
360
|
-
return f(this.value);
|
|
361
|
-
}
|
|
362
|
-
andThrough(f) {
|
|
363
|
-
return f(this.value).map((_value) => this.value);
|
|
364
|
-
}
|
|
365
|
-
andTee(f) {
|
|
366
|
-
try {
|
|
367
|
-
f(this.value);
|
|
368
|
-
} catch (e) {}
|
|
369
|
-
return ok(this.value);
|
|
370
|
-
}
|
|
371
|
-
orTee(_f) {
|
|
372
|
-
return ok(this.value);
|
|
373
|
-
}
|
|
374
|
-
orElse(_f) {
|
|
375
|
-
return ok(this.value);
|
|
376
|
-
}
|
|
377
|
-
asyncAndThen(f) {
|
|
378
|
-
return f(this.value);
|
|
379
|
-
}
|
|
380
|
-
asyncAndThrough(f) {
|
|
381
|
-
return f(this.value).map(() => this.value);
|
|
382
|
-
}
|
|
383
|
-
asyncMap(f) {
|
|
384
|
-
return ResultAsync.fromSafePromise(f(this.value));
|
|
385
|
-
}
|
|
386
|
-
unwrapOr(_v) {
|
|
387
|
-
return this.value;
|
|
388
|
-
}
|
|
389
|
-
match(ok, _err) {
|
|
390
|
-
return ok(this.value);
|
|
391
|
-
}
|
|
392
|
-
safeUnwrap() {
|
|
393
|
-
const value = this.value;
|
|
394
|
-
return (function* () {
|
|
395
|
-
return value;
|
|
396
|
-
})();
|
|
397
|
-
}
|
|
398
|
-
_unsafeUnwrap(_) {
|
|
399
|
-
return this.value;
|
|
400
|
-
}
|
|
401
|
-
_unsafeUnwrapErr(config) {
|
|
402
|
-
throw createNeverThrowError("Called `_unsafeUnwrapErr` on an Ok", this, config);
|
|
403
|
-
}
|
|
404
|
-
*[Symbol.iterator]() {
|
|
405
|
-
return this.value;
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
var Err = class {
|
|
409
|
-
constructor(error) {
|
|
410
|
-
this.error = error;
|
|
411
|
-
}
|
|
412
|
-
isOk() {
|
|
413
|
-
return false;
|
|
414
|
-
}
|
|
415
|
-
isErr() {
|
|
416
|
-
return !this.isOk();
|
|
417
|
-
}
|
|
418
|
-
map(_f) {
|
|
419
|
-
return err(this.error);
|
|
420
|
-
}
|
|
421
|
-
mapErr(f) {
|
|
422
|
-
return err(f(this.error));
|
|
423
|
-
}
|
|
424
|
-
andThrough(_f) {
|
|
425
|
-
return err(this.error);
|
|
426
|
-
}
|
|
427
|
-
andTee(_f) {
|
|
428
|
-
return err(this.error);
|
|
429
|
-
}
|
|
430
|
-
orTee(f) {
|
|
431
|
-
try {
|
|
432
|
-
f(this.error);
|
|
433
|
-
} catch (e) {}
|
|
434
|
-
return err(this.error);
|
|
435
|
-
}
|
|
436
|
-
andThen(_f) {
|
|
437
|
-
return err(this.error);
|
|
438
|
-
}
|
|
439
|
-
orElse(f) {
|
|
440
|
-
return f(this.error);
|
|
441
|
-
}
|
|
442
|
-
asyncAndThen(_f) {
|
|
443
|
-
return errAsync(this.error);
|
|
444
|
-
}
|
|
445
|
-
asyncAndThrough(_f) {
|
|
446
|
-
return errAsync(this.error);
|
|
447
|
-
}
|
|
448
|
-
asyncMap(_f) {
|
|
449
|
-
return errAsync(this.error);
|
|
450
|
-
}
|
|
451
|
-
unwrapOr(v) {
|
|
452
|
-
return v;
|
|
453
|
-
}
|
|
454
|
-
match(_ok, err) {
|
|
455
|
-
return err(this.error);
|
|
456
|
-
}
|
|
457
|
-
safeUnwrap() {
|
|
458
|
-
const error = this.error;
|
|
459
|
-
return (function* () {
|
|
460
|
-
yield err(error);
|
|
461
|
-
throw new Error("Do not use this generator out of `safeTry`");
|
|
462
|
-
})();
|
|
463
|
-
}
|
|
464
|
-
_unsafeUnwrap(config) {
|
|
465
|
-
throw createNeverThrowError("Called `_unsafeUnwrap` on an Err", this, config);
|
|
466
|
-
}
|
|
467
|
-
_unsafeUnwrapErr(_) {
|
|
468
|
-
return this.error;
|
|
469
|
-
}
|
|
470
|
-
*[Symbol.iterator]() {
|
|
471
|
-
const self = this;
|
|
472
|
-
yield self;
|
|
473
|
-
return self;
|
|
474
|
-
}
|
|
187
|
+
delete params.message;
|
|
188
|
+
if (typeof params.error === "string") return {
|
|
189
|
+
...params,
|
|
190
|
+
error: () => params.error
|
|
475
191
|
};
|
|
476
|
-
|
|
477
|
-
exports.Err = Err;
|
|
478
|
-
exports.Ok = Ok;
|
|
479
|
-
exports.ResultAsync = ResultAsync;
|
|
480
|
-
exports.err = err;
|
|
481
|
-
exports.errAsync = errAsync;
|
|
482
|
-
exports.fromAsyncThrowable = fromAsyncThrowable;
|
|
483
|
-
exports.fromPromise = fromPromise;
|
|
484
|
-
exports.fromSafePromise = fromSafePromise;
|
|
485
|
-
exports.fromThrowable = fromThrowable;
|
|
486
|
-
exports.ok = ok;
|
|
487
|
-
exports.okAsync = okAsync;
|
|
488
|
-
exports.safeTry = safeTry;
|
|
489
|
-
}));
|
|
490
|
-
Object.freeze({ status: "aborted" });
|
|
491
|
-
function $constructor(name, initializer, params) {
|
|
492
|
-
function init(inst, def) {
|
|
493
|
-
if (!inst._zod) Object.defineProperty(inst, "_zod", {
|
|
494
|
-
value: {
|
|
495
|
-
def,
|
|
496
|
-
constr: _,
|
|
497
|
-
traits: /* @__PURE__ */ new Set()
|
|
498
|
-
},
|
|
499
|
-
enumerable: false
|
|
500
|
-
});
|
|
501
|
-
if (inst._zod.traits.has(name)) return;
|
|
502
|
-
inst._zod.traits.add(name);
|
|
503
|
-
initializer(inst, def);
|
|
504
|
-
const proto = _.prototype;
|
|
505
|
-
const keys = Object.keys(proto);
|
|
506
|
-
for (let i = 0; i < keys.length; i++) {
|
|
507
|
-
const k = keys[i];
|
|
508
|
-
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
const Parent = params?.Parent ?? Object;
|
|
512
|
-
class Definition extends Parent {}
|
|
513
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
514
|
-
function _(def) {
|
|
515
|
-
var _a;
|
|
516
|
-
const inst = params?.Parent ? new Definition() : this;
|
|
517
|
-
init(inst, def);
|
|
518
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
519
|
-
for (const fn of inst._zod.deferred) fn();
|
|
520
|
-
return inst;
|
|
521
|
-
}
|
|
522
|
-
Object.defineProperty(_, "init", { value: init });
|
|
523
|
-
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
524
|
-
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
525
|
-
return inst?._zod?.traits?.has(name);
|
|
526
|
-
} });
|
|
527
|
-
Object.defineProperty(_, "name", { value: name });
|
|
528
|
-
return _;
|
|
192
|
+
return params;
|
|
529
193
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
}
|
|
534
|
-
};
|
|
535
|
-
var $ZodEncodeError = class extends Error {
|
|
536
|
-
constructor(name) {
|
|
537
|
-
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
538
|
-
this.name = "ZodEncodeError";
|
|
539
|
-
}
|
|
540
|
-
};
|
|
541
|
-
const globalConfig = {};
|
|
542
|
-
function config(newConfig) {
|
|
543
|
-
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
544
|
-
return globalConfig;
|
|
194
|
+
function optionalKeys(shape) {
|
|
195
|
+
return Object.keys(shape).filter((k) => {
|
|
196
|
+
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
197
|
+
});
|
|
545
198
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
199
|
+
const NUMBER_FORMAT_RANGES = {
|
|
200
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
201
|
+
int32: [-2147483648, 2147483647],
|
|
202
|
+
uint32: [0, 4294967295],
|
|
203
|
+
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
204
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
205
|
+
};
|
|
206
|
+
function pick(schema, mask) {
|
|
207
|
+
const currDef = schema._zod.def;
|
|
208
|
+
const checks = currDef.checks;
|
|
209
|
+
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
210
|
+
return clone(schema, mergeDefs(schema._zod.def, {
|
|
211
|
+
get shape() {
|
|
212
|
+
const newShape = {};
|
|
213
|
+
for (const key in mask) {
|
|
214
|
+
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
215
|
+
if (!mask[key]) continue;
|
|
216
|
+
newShape[key] = currDef.shape[key];
|
|
217
|
+
}
|
|
218
|
+
assignProp(this, "shape", newShape);
|
|
219
|
+
return newShape;
|
|
220
|
+
},
|
|
221
|
+
checks: []
|
|
222
|
+
}));
|
|
551
223
|
}
|
|
552
|
-
function
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
const
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
}
|
|
569
|
-
function cleanRegex(source) {
|
|
570
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
571
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
572
|
-
return source.slice(start, end);
|
|
573
|
-
}
|
|
574
|
-
function floatSafeRemainder(val, step) {
|
|
575
|
-
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
576
|
-
const stepString = step.toString();
|
|
577
|
-
let stepDecCount = (stepString.split(".")[1] || "").length;
|
|
578
|
-
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
|
|
579
|
-
const match = stepString.match(/\d?e-(\d?)/);
|
|
580
|
-
if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
|
|
581
|
-
}
|
|
582
|
-
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
583
|
-
return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
|
|
584
|
-
}
|
|
585
|
-
const EVALUATING = Symbol("evaluating");
|
|
586
|
-
function defineLazy(object, key, getter) {
|
|
587
|
-
let value = void 0;
|
|
588
|
-
Object.defineProperty(object, key, {
|
|
589
|
-
get() {
|
|
590
|
-
if (value === EVALUATING) return;
|
|
591
|
-
if (value === void 0) {
|
|
592
|
-
value = EVALUATING;
|
|
593
|
-
value = getter();
|
|
594
|
-
}
|
|
595
|
-
return value;
|
|
596
|
-
},
|
|
597
|
-
set(v) {
|
|
598
|
-
Object.defineProperty(object, key, { value: v });
|
|
599
|
-
},
|
|
600
|
-
configurable: true
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
function assignProp(target, prop, value) {
|
|
604
|
-
Object.defineProperty(target, prop, {
|
|
605
|
-
value,
|
|
606
|
-
writable: true,
|
|
607
|
-
enumerable: true,
|
|
608
|
-
configurable: true
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
function mergeDefs(...defs) {
|
|
612
|
-
const mergedDescriptors = {};
|
|
613
|
-
for (const def of defs) {
|
|
614
|
-
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
615
|
-
Object.assign(mergedDescriptors, descriptors);
|
|
616
|
-
}
|
|
617
|
-
return Object.defineProperties({}, mergedDescriptors);
|
|
618
|
-
}
|
|
619
|
-
function esc(str) {
|
|
620
|
-
return JSON.stringify(str);
|
|
621
|
-
}
|
|
622
|
-
function slugify(input) {
|
|
623
|
-
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
624
|
-
}
|
|
625
|
-
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
626
|
-
function isObject(data) {
|
|
627
|
-
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
628
|
-
}
|
|
629
|
-
const allowsEval = cached(() => {
|
|
630
|
-
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
|
|
631
|
-
try {
|
|
632
|
-
new Function("");
|
|
633
|
-
return true;
|
|
634
|
-
} catch (_) {
|
|
635
|
-
return false;
|
|
636
|
-
}
|
|
637
|
-
});
|
|
638
|
-
function isPlainObject(o) {
|
|
639
|
-
if (isObject(o) === false) return false;
|
|
640
|
-
const ctor = o.constructor;
|
|
641
|
-
if (ctor === void 0) return true;
|
|
642
|
-
if (typeof ctor !== "function") return true;
|
|
643
|
-
const prot = ctor.prototype;
|
|
644
|
-
if (isObject(prot) === false) return false;
|
|
645
|
-
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
646
|
-
return true;
|
|
647
|
-
}
|
|
648
|
-
function shallowClone(o) {
|
|
649
|
-
if (isPlainObject(o)) return { ...o };
|
|
650
|
-
if (Array.isArray(o)) return [...o];
|
|
651
|
-
return o;
|
|
652
|
-
}
|
|
653
|
-
const propertyKeyTypes = new Set([
|
|
654
|
-
"string",
|
|
655
|
-
"number",
|
|
656
|
-
"symbol"
|
|
657
|
-
]);
|
|
658
|
-
function escapeRegex(str) {
|
|
659
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
660
|
-
}
|
|
661
|
-
function clone(inst, def, params) {
|
|
662
|
-
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
663
|
-
if (!def || params?.parent) cl._zod.parent = inst;
|
|
664
|
-
return cl;
|
|
665
|
-
}
|
|
666
|
-
function normalizeParams(_params) {
|
|
667
|
-
const params = _params;
|
|
668
|
-
if (!params) return {};
|
|
669
|
-
if (typeof params === "string") return { error: () => params };
|
|
670
|
-
if (params?.message !== void 0) {
|
|
671
|
-
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
|
672
|
-
params.error = params.message;
|
|
673
|
-
}
|
|
674
|
-
delete params.message;
|
|
675
|
-
if (typeof params.error === "string") return {
|
|
676
|
-
...params,
|
|
677
|
-
error: () => params.error
|
|
678
|
-
};
|
|
679
|
-
return params;
|
|
680
|
-
}
|
|
681
|
-
function optionalKeys(shape) {
|
|
682
|
-
return Object.keys(shape).filter((k) => {
|
|
683
|
-
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
const NUMBER_FORMAT_RANGES = {
|
|
687
|
-
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
688
|
-
int32: [-2147483648, 2147483647],
|
|
689
|
-
uint32: [0, 4294967295],
|
|
690
|
-
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
691
|
-
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
692
|
-
};
|
|
693
|
-
function pick(schema, mask) {
|
|
694
|
-
const currDef = schema._zod.def;
|
|
695
|
-
const checks = currDef.checks;
|
|
696
|
-
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
697
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
698
|
-
get shape() {
|
|
699
|
-
const newShape = {};
|
|
700
|
-
for (const key in mask) {
|
|
701
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
702
|
-
if (!mask[key]) continue;
|
|
703
|
-
newShape[key] = currDef.shape[key];
|
|
704
|
-
}
|
|
705
|
-
assignProp(this, "shape", newShape);
|
|
706
|
-
return newShape;
|
|
707
|
-
},
|
|
708
|
-
checks: []
|
|
709
|
-
}));
|
|
710
|
-
}
|
|
711
|
-
function omit(schema, mask) {
|
|
712
|
-
const currDef = schema._zod.def;
|
|
713
|
-
const checks = currDef.checks;
|
|
714
|
-
if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
715
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
716
|
-
get shape() {
|
|
717
|
-
const newShape = { ...schema._zod.def.shape };
|
|
718
|
-
for (const key in mask) {
|
|
719
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
720
|
-
if (!mask[key]) continue;
|
|
721
|
-
delete newShape[key];
|
|
722
|
-
}
|
|
723
|
-
assignProp(this, "shape", newShape);
|
|
724
|
-
return newShape;
|
|
725
|
-
},
|
|
726
|
-
checks: []
|
|
727
|
-
}));
|
|
224
|
+
function omit(schema, mask) {
|
|
225
|
+
const currDef = schema._zod.def;
|
|
226
|
+
const checks = currDef.checks;
|
|
227
|
+
if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
228
|
+
return clone(schema, mergeDefs(schema._zod.def, {
|
|
229
|
+
get shape() {
|
|
230
|
+
const newShape = { ...schema._zod.def.shape };
|
|
231
|
+
for (const key in mask) {
|
|
232
|
+
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
233
|
+
if (!mask[key]) continue;
|
|
234
|
+
delete newShape[key];
|
|
235
|
+
}
|
|
236
|
+
assignProp(this, "shape", newShape);
|
|
237
|
+
return newShape;
|
|
238
|
+
},
|
|
239
|
+
checks: []
|
|
240
|
+
}));
|
|
728
241
|
}
|
|
729
242
|
function extend(schema, shape) {
|
|
730
243
|
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
@@ -2211,6 +1724,61 @@ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
|
2211
1724
|
});
|
|
2212
1725
|
};
|
|
2213
1726
|
});
|
|
1727
|
+
const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
1728
|
+
def.inclusive = false;
|
|
1729
|
+
$ZodUnion.init(inst, def);
|
|
1730
|
+
const _super = inst._zod.parse;
|
|
1731
|
+
defineLazy(inst._zod, "propValues", () => {
|
|
1732
|
+
const propValues = {};
|
|
1733
|
+
for (const option of def.options) {
|
|
1734
|
+
const pv = option._zod.propValues;
|
|
1735
|
+
if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
1736
|
+
for (const [k, v] of Object.entries(pv)) {
|
|
1737
|
+
if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
|
|
1738
|
+
for (const val of v) propValues[k].add(val);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
return propValues;
|
|
1742
|
+
});
|
|
1743
|
+
const disc = cached(() => {
|
|
1744
|
+
const opts = def.options;
|
|
1745
|
+
const map = /* @__PURE__ */ new Map();
|
|
1746
|
+
for (const o of opts) {
|
|
1747
|
+
const values = o._zod.propValues?.[def.discriminator];
|
|
1748
|
+
if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
1749
|
+
for (const v of values) {
|
|
1750
|
+
if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
1751
|
+
map.set(v, o);
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
return map;
|
|
1755
|
+
});
|
|
1756
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1757
|
+
const input = payload.value;
|
|
1758
|
+
if (!isObject(input)) {
|
|
1759
|
+
payload.issues.push({
|
|
1760
|
+
code: "invalid_type",
|
|
1761
|
+
expected: "object",
|
|
1762
|
+
input,
|
|
1763
|
+
inst
|
|
1764
|
+
});
|
|
1765
|
+
return payload;
|
|
1766
|
+
}
|
|
1767
|
+
const opt = disc.value.get(input?.[def.discriminator]);
|
|
1768
|
+
if (opt) return opt._zod.run(payload, ctx);
|
|
1769
|
+
if (def.unionFallback) return _super(payload, ctx);
|
|
1770
|
+
payload.issues.push({
|
|
1771
|
+
code: "invalid_union",
|
|
1772
|
+
errors: [],
|
|
1773
|
+
note: "No matching discriminator",
|
|
1774
|
+
discriminator: def.discriminator,
|
|
1775
|
+
input,
|
|
1776
|
+
path: [def.discriminator],
|
|
1777
|
+
inst
|
|
1778
|
+
});
|
|
1779
|
+
return payload;
|
|
1780
|
+
};
|
|
1781
|
+
});
|
|
2214
1782
|
const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
2215
1783
|
$ZodType.init(inst, def);
|
|
2216
1784
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -3981,6 +3549,9 @@ const ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
|
|
|
3981
3549
|
$ZodURL.init(inst, def);
|
|
3982
3550
|
ZodStringFormat.init(inst, def);
|
|
3983
3551
|
});
|
|
3552
|
+
function url(params) {
|
|
3553
|
+
return /* @__PURE__ */ _url(ZodURL, params);
|
|
3554
|
+
}
|
|
3984
3555
|
const ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
|
|
3985
3556
|
$ZodEmoji.init(inst, def);
|
|
3986
3557
|
ZodStringFormat.init(inst, def);
|
|
@@ -4149,277 +3720,787 @@ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
4149
3720
|
inst.safeExtend = (incoming) => {
|
|
4150
3721
|
return safeExtend(inst, incoming);
|
|
4151
3722
|
};
|
|
4152
|
-
inst.merge = (other) => merge(inst, other);
|
|
4153
|
-
inst.pick = (mask) => pick(inst, mask);
|
|
4154
|
-
inst.omit = (mask) => omit(inst, mask);
|
|
4155
|
-
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
4156
|
-
inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
|
|
4157
|
-
});
|
|
4158
|
-
function object(shape, params) {
|
|
4159
|
-
return new ZodObject({
|
|
4160
|
-
type: "object",
|
|
4161
|
-
shape: shape ?? {},
|
|
4162
|
-
...normalizeParams(params)
|
|
4163
|
-
});
|
|
4164
|
-
}
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
}
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
});
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
3723
|
+
inst.merge = (other) => merge(inst, other);
|
|
3724
|
+
inst.pick = (mask) => pick(inst, mask);
|
|
3725
|
+
inst.omit = (mask) => omit(inst, mask);
|
|
3726
|
+
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
3727
|
+
inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
|
|
3728
|
+
});
|
|
3729
|
+
function object(shape, params) {
|
|
3730
|
+
return new ZodObject({
|
|
3731
|
+
type: "object",
|
|
3732
|
+
shape: shape ?? {},
|
|
3733
|
+
...normalizeParams(params)
|
|
3734
|
+
});
|
|
3735
|
+
}
|
|
3736
|
+
function looseObject(shape, params) {
|
|
3737
|
+
return new ZodObject({
|
|
3738
|
+
type: "object",
|
|
3739
|
+
shape,
|
|
3740
|
+
catchall: unknown(),
|
|
3741
|
+
...normalizeParams(params)
|
|
3742
|
+
});
|
|
3743
|
+
}
|
|
3744
|
+
const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
3745
|
+
$ZodUnion.init(inst, def);
|
|
3746
|
+
ZodType.init(inst, def);
|
|
3747
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
|
|
3748
|
+
inst.options = def.options;
|
|
3749
|
+
});
|
|
3750
|
+
function union(options, params) {
|
|
3751
|
+
return new ZodUnion({
|
|
3752
|
+
type: "union",
|
|
3753
|
+
options,
|
|
3754
|
+
...normalizeParams(params)
|
|
3755
|
+
});
|
|
3756
|
+
}
|
|
3757
|
+
const ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
3758
|
+
ZodUnion.init(inst, def);
|
|
3759
|
+
$ZodDiscriminatedUnion.init(inst, def);
|
|
3760
|
+
});
|
|
3761
|
+
function discriminatedUnion(discriminator, options, params) {
|
|
3762
|
+
return new ZodDiscriminatedUnion({
|
|
3763
|
+
type: "union",
|
|
3764
|
+
options,
|
|
3765
|
+
discriminator,
|
|
3766
|
+
...normalizeParams(params)
|
|
3767
|
+
});
|
|
3768
|
+
}
|
|
3769
|
+
const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
3770
|
+
$ZodIntersection.init(inst, def);
|
|
3771
|
+
ZodType.init(inst, def);
|
|
3772
|
+
inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
|
|
3773
|
+
});
|
|
3774
|
+
function intersection(left, right) {
|
|
3775
|
+
return new ZodIntersection({
|
|
3776
|
+
type: "intersection",
|
|
3777
|
+
left,
|
|
3778
|
+
right
|
|
3779
|
+
});
|
|
3780
|
+
}
|
|
3781
|
+
const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
3782
|
+
$ZodRecord.init(inst, def);
|
|
3783
|
+
ZodType.init(inst, def);
|
|
3784
|
+
inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
|
|
3785
|
+
inst.keyType = def.keyType;
|
|
3786
|
+
inst.valueType = def.valueType;
|
|
3787
|
+
});
|
|
3788
|
+
function record(keyType, valueType, params) {
|
|
3789
|
+
return new ZodRecord({
|
|
3790
|
+
type: "record",
|
|
3791
|
+
keyType,
|
|
3792
|
+
valueType,
|
|
3793
|
+
...normalizeParams(params)
|
|
3794
|
+
});
|
|
3795
|
+
}
|
|
3796
|
+
const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
3797
|
+
$ZodEnum.init(inst, def);
|
|
3798
|
+
ZodType.init(inst, def);
|
|
3799
|
+
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
3800
|
+
inst.enum = def.entries;
|
|
3801
|
+
inst.options = Object.values(def.entries);
|
|
3802
|
+
const keys = new Set(Object.keys(def.entries));
|
|
3803
|
+
inst.extract = (values, params) => {
|
|
3804
|
+
const newEntries = {};
|
|
3805
|
+
for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
|
|
3806
|
+
else throw new Error(`Key ${value} not found in enum`);
|
|
3807
|
+
return new ZodEnum({
|
|
3808
|
+
...def,
|
|
3809
|
+
checks: [],
|
|
3810
|
+
...normalizeParams(params),
|
|
3811
|
+
entries: newEntries
|
|
3812
|
+
});
|
|
3813
|
+
};
|
|
3814
|
+
inst.exclude = (values, params) => {
|
|
3815
|
+
const newEntries = { ...def.entries };
|
|
3816
|
+
for (const value of values) if (keys.has(value)) delete newEntries[value];
|
|
3817
|
+
else throw new Error(`Key ${value} not found in enum`);
|
|
3818
|
+
return new ZodEnum({
|
|
3819
|
+
...def,
|
|
3820
|
+
checks: [],
|
|
3821
|
+
...normalizeParams(params),
|
|
3822
|
+
entries: newEntries
|
|
3823
|
+
});
|
|
3824
|
+
};
|
|
3825
|
+
});
|
|
3826
|
+
function _enum(values, params) {
|
|
3827
|
+
return new ZodEnum({
|
|
3828
|
+
type: "enum",
|
|
3829
|
+
entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
|
|
3830
|
+
...normalizeParams(params)
|
|
3831
|
+
});
|
|
3832
|
+
}
|
|
3833
|
+
const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
3834
|
+
$ZodLiteral.init(inst, def);
|
|
3835
|
+
ZodType.init(inst, def);
|
|
3836
|
+
inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
|
|
3837
|
+
inst.values = new Set(def.values);
|
|
3838
|
+
Object.defineProperty(inst, "value", { get() {
|
|
3839
|
+
if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
3840
|
+
return def.values[0];
|
|
3841
|
+
} });
|
|
3842
|
+
});
|
|
3843
|
+
function literal(value, params) {
|
|
3844
|
+
return new ZodLiteral({
|
|
3845
|
+
type: "literal",
|
|
3846
|
+
values: Array.isArray(value) ? value : [value],
|
|
3847
|
+
...normalizeParams(params)
|
|
3848
|
+
});
|
|
3849
|
+
}
|
|
3850
|
+
const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
3851
|
+
$ZodTransform.init(inst, def);
|
|
3852
|
+
ZodType.init(inst, def);
|
|
3853
|
+
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
3854
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
3855
|
+
if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
3856
|
+
payload.addIssue = (issue$1) => {
|
|
3857
|
+
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
|
|
3858
|
+
else {
|
|
3859
|
+
const _issue = issue$1;
|
|
3860
|
+
if (_issue.fatal) _issue.continue = false;
|
|
3861
|
+
_issue.code ?? (_issue.code = "custom");
|
|
3862
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
3863
|
+
_issue.inst ?? (_issue.inst = inst);
|
|
3864
|
+
payload.issues.push(issue(_issue));
|
|
3865
|
+
}
|
|
3866
|
+
};
|
|
3867
|
+
const output = def.transform(payload.value, payload);
|
|
3868
|
+
if (output instanceof Promise) return output.then((output) => {
|
|
3869
|
+
payload.value = output;
|
|
3870
|
+
return payload;
|
|
3871
|
+
});
|
|
3872
|
+
payload.value = output;
|
|
3873
|
+
return payload;
|
|
3874
|
+
};
|
|
3875
|
+
});
|
|
3876
|
+
function transform(fn) {
|
|
3877
|
+
return new ZodTransform({
|
|
3878
|
+
type: "transform",
|
|
3879
|
+
transform: fn
|
|
3880
|
+
});
|
|
3881
|
+
}
|
|
3882
|
+
const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
3883
|
+
$ZodOptional.init(inst, def);
|
|
3884
|
+
ZodType.init(inst, def);
|
|
3885
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
3886
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3887
|
+
});
|
|
3888
|
+
function optional(innerType) {
|
|
3889
|
+
return new ZodOptional({
|
|
3890
|
+
type: "optional",
|
|
3891
|
+
innerType
|
|
3892
|
+
});
|
|
3893
|
+
}
|
|
3894
|
+
const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
3895
|
+
$ZodExactOptional.init(inst, def);
|
|
3896
|
+
ZodType.init(inst, def);
|
|
3897
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
3898
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3899
|
+
});
|
|
3900
|
+
function exactOptional(innerType) {
|
|
3901
|
+
return new ZodExactOptional({
|
|
3902
|
+
type: "optional",
|
|
3903
|
+
innerType
|
|
3904
|
+
});
|
|
3905
|
+
}
|
|
3906
|
+
const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
3907
|
+
$ZodNullable.init(inst, def);
|
|
3908
|
+
ZodType.init(inst, def);
|
|
3909
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
|
|
3910
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3911
|
+
});
|
|
3912
|
+
function nullable(innerType) {
|
|
3913
|
+
return new ZodNullable({
|
|
3914
|
+
type: "nullable",
|
|
3915
|
+
innerType
|
|
3916
|
+
});
|
|
3917
|
+
}
|
|
3918
|
+
const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
3919
|
+
$ZodDefault.init(inst, def);
|
|
3920
|
+
ZodType.init(inst, def);
|
|
3921
|
+
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
|
|
3922
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3923
|
+
inst.removeDefault = inst.unwrap;
|
|
3924
|
+
});
|
|
3925
|
+
function _default(innerType, defaultValue) {
|
|
3926
|
+
return new ZodDefault({
|
|
3927
|
+
type: "default",
|
|
3928
|
+
innerType,
|
|
3929
|
+
get defaultValue() {
|
|
3930
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
3931
|
+
}
|
|
3932
|
+
});
|
|
3933
|
+
}
|
|
3934
|
+
const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
3935
|
+
$ZodPrefault.init(inst, def);
|
|
3936
|
+
ZodType.init(inst, def);
|
|
3937
|
+
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
|
|
3938
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3939
|
+
});
|
|
3940
|
+
function prefault(innerType, defaultValue) {
|
|
3941
|
+
return new ZodPrefault({
|
|
3942
|
+
type: "prefault",
|
|
3943
|
+
innerType,
|
|
3944
|
+
get defaultValue() {
|
|
3945
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
3946
|
+
}
|
|
3947
|
+
});
|
|
3948
|
+
}
|
|
3949
|
+
const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
3950
|
+
$ZodNonOptional.init(inst, def);
|
|
3951
|
+
ZodType.init(inst, def);
|
|
3952
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
|
|
3953
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3954
|
+
});
|
|
3955
|
+
function nonoptional(innerType, params) {
|
|
3956
|
+
return new ZodNonOptional({
|
|
3957
|
+
type: "nonoptional",
|
|
3958
|
+
innerType,
|
|
3959
|
+
...normalizeParams(params)
|
|
3960
|
+
});
|
|
3961
|
+
}
|
|
3962
|
+
const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
3963
|
+
$ZodCatch.init(inst, def);
|
|
3964
|
+
ZodType.init(inst, def);
|
|
3965
|
+
inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
|
|
3966
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3967
|
+
inst.removeCatch = inst.unwrap;
|
|
3968
|
+
});
|
|
3969
|
+
function _catch(innerType, catchValue) {
|
|
3970
|
+
return new ZodCatch({
|
|
3971
|
+
type: "catch",
|
|
3972
|
+
innerType,
|
|
3973
|
+
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
3974
|
+
});
|
|
3975
|
+
}
|
|
3976
|
+
const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
3977
|
+
$ZodPipe.init(inst, def);
|
|
3978
|
+
ZodType.init(inst, def);
|
|
3979
|
+
inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
|
|
3980
|
+
inst.in = def.in;
|
|
3981
|
+
inst.out = def.out;
|
|
3982
|
+
});
|
|
3983
|
+
function pipe(in_, out) {
|
|
3984
|
+
return new ZodPipe({
|
|
3985
|
+
type: "pipe",
|
|
3986
|
+
in: in_,
|
|
3987
|
+
out
|
|
3988
|
+
});
|
|
3989
|
+
}
|
|
3990
|
+
const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
3991
|
+
$ZodReadonly.init(inst, def);
|
|
3992
|
+
ZodType.init(inst, def);
|
|
3993
|
+
inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
|
|
3994
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3995
|
+
});
|
|
3996
|
+
function readonly(innerType) {
|
|
3997
|
+
return new ZodReadonly({
|
|
3998
|
+
type: "readonly",
|
|
3999
|
+
innerType
|
|
4000
|
+
});
|
|
4001
|
+
}
|
|
4002
|
+
const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
4003
|
+
$ZodCustom.init(inst, def);
|
|
4004
|
+
ZodType.init(inst, def);
|
|
4005
|
+
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
|
|
4006
|
+
});
|
|
4007
|
+
function refine(fn, _params = {}) {
|
|
4008
|
+
return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
|
|
4009
|
+
}
|
|
4010
|
+
function superRefine(fn) {
|
|
4011
|
+
return /* @__PURE__ */ _superRefine(fn);
|
|
4012
|
+
}
|
|
4013
|
+
function preprocess(fn, schema) {
|
|
4014
|
+
return pipe(transform(fn), schema);
|
|
4015
|
+
}
|
|
4016
|
+
//#endregion
|
|
4017
|
+
//#region node_modules/.pnpm/neverthrow@8.2.0/node_modules/neverthrow/dist/index.cjs.js
|
|
4018
|
+
var require_index_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4019
|
+
const defaultErrorConfig = { withStackTrace: false };
|
|
4020
|
+
const createNeverThrowError = (message, result, config = defaultErrorConfig) => {
|
|
4021
|
+
return {
|
|
4022
|
+
data: result.isOk() ? {
|
|
4023
|
+
type: "Ok",
|
|
4024
|
+
value: result.value
|
|
4025
|
+
} : {
|
|
4026
|
+
type: "Err",
|
|
4027
|
+
value: result.error
|
|
4028
|
+
},
|
|
4029
|
+
message,
|
|
4030
|
+
stack: config.withStackTrace ? (/* @__PURE__ */ new Error()).stack : void 0
|
|
4031
|
+
};
|
|
4032
|
+
};
|
|
4033
|
+
/******************************************************************************
|
|
4034
|
+
Copyright (c) Microsoft Corporation.
|
|
4035
|
+
|
|
4036
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4037
|
+
purpose with or without fee is hereby granted.
|
|
4038
|
+
|
|
4039
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
4040
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
4041
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
4042
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
4043
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
4044
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
4045
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
4046
|
+
***************************************************************************** */
|
|
4047
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
4048
|
+
function adopt(value) {
|
|
4049
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
4050
|
+
resolve(value);
|
|
4051
|
+
});
|
|
4052
|
+
}
|
|
4053
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
4054
|
+
function fulfilled(value) {
|
|
4055
|
+
try {
|
|
4056
|
+
step(generator.next(value));
|
|
4057
|
+
} catch (e) {
|
|
4058
|
+
reject(e);
|
|
4059
|
+
}
|
|
4060
|
+
}
|
|
4061
|
+
function rejected(value) {
|
|
4062
|
+
try {
|
|
4063
|
+
step(generator["throw"](value));
|
|
4064
|
+
} catch (e) {
|
|
4065
|
+
reject(e);
|
|
4066
|
+
}
|
|
4067
|
+
}
|
|
4068
|
+
function step(result) {
|
|
4069
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
4070
|
+
}
|
|
4071
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
4072
|
+
});
|
|
4073
|
+
}
|
|
4074
|
+
function __values(o) {
|
|
4075
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4076
|
+
if (m) return m.call(o);
|
|
4077
|
+
if (o && typeof o.length === "number") return { next: function() {
|
|
4078
|
+
if (o && i >= o.length) o = void 0;
|
|
4079
|
+
return {
|
|
4080
|
+
value: o && o[i++],
|
|
4081
|
+
done: !o
|
|
4082
|
+
};
|
|
4083
|
+
} };
|
|
4084
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
4085
|
+
}
|
|
4086
|
+
function __await(v) {
|
|
4087
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
4088
|
+
}
|
|
4089
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
4090
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4091
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
4092
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function() {
|
|
4093
|
+
return this;
|
|
4094
|
+
}, i;
|
|
4095
|
+
function awaitReturn(f) {
|
|
4096
|
+
return function(v) {
|
|
4097
|
+
return Promise.resolve(v).then(f, reject);
|
|
4098
|
+
};
|
|
4099
|
+
}
|
|
4100
|
+
function verb(n, f) {
|
|
4101
|
+
if (g[n]) {
|
|
4102
|
+
i[n] = function(v) {
|
|
4103
|
+
return new Promise(function(a, b) {
|
|
4104
|
+
q.push([
|
|
4105
|
+
n,
|
|
4106
|
+
v,
|
|
4107
|
+
a,
|
|
4108
|
+
b
|
|
4109
|
+
]) > 1 || resume(n, v);
|
|
4110
|
+
});
|
|
4111
|
+
};
|
|
4112
|
+
if (f) i[n] = f(i[n]);
|
|
4113
|
+
}
|
|
4114
|
+
}
|
|
4115
|
+
function resume(n, v) {
|
|
4116
|
+
try {
|
|
4117
|
+
step(g[n](v));
|
|
4118
|
+
} catch (e) {
|
|
4119
|
+
settle(q[0][3], e);
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
4122
|
+
function step(r) {
|
|
4123
|
+
r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
|
|
4124
|
+
}
|
|
4125
|
+
function fulfill(value) {
|
|
4126
|
+
resume("next", value);
|
|
4127
|
+
}
|
|
4128
|
+
function reject(value) {
|
|
4129
|
+
resume("throw", value);
|
|
4130
|
+
}
|
|
4131
|
+
function settle(f, v) {
|
|
4132
|
+
if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
function __asyncDelegator(o) {
|
|
4136
|
+
var i, p;
|
|
4137
|
+
return i = {}, verb("next"), verb("throw", function(e) {
|
|
4138
|
+
throw e;
|
|
4139
|
+
}), verb("return"), i[Symbol.iterator] = function() {
|
|
4140
|
+
return this;
|
|
4141
|
+
}, i;
|
|
4142
|
+
function verb(n, f) {
|
|
4143
|
+
i[n] = o[n] ? function(v) {
|
|
4144
|
+
return (p = !p) ? {
|
|
4145
|
+
value: __await(o[n](v)),
|
|
4146
|
+
done: false
|
|
4147
|
+
} : f ? f(v) : v;
|
|
4148
|
+
} : f;
|
|
4149
|
+
}
|
|
4150
|
+
}
|
|
4151
|
+
function __asyncValues(o) {
|
|
4152
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4153
|
+
var m = o[Symbol.asyncIterator], i;
|
|
4154
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
4155
|
+
return this;
|
|
4156
|
+
}, i);
|
|
4157
|
+
function verb(n) {
|
|
4158
|
+
i[n] = o[n] && function(v) {
|
|
4159
|
+
return new Promise(function(resolve, reject) {
|
|
4160
|
+
v = o[n](v), settle(resolve, reject, v.done, v.value);
|
|
4161
|
+
});
|
|
4162
|
+
};
|
|
4163
|
+
}
|
|
4164
|
+
function settle(resolve, reject, d, v) {
|
|
4165
|
+
Promise.resolve(v).then(function(v) {
|
|
4166
|
+
resolve({
|
|
4167
|
+
value: v,
|
|
4168
|
+
done: d
|
|
4169
|
+
});
|
|
4170
|
+
}, reject);
|
|
4171
|
+
}
|
|
4172
|
+
}
|
|
4173
|
+
var ResultAsync = class ResultAsync {
|
|
4174
|
+
constructor(res) {
|
|
4175
|
+
this._promise = res;
|
|
4176
|
+
}
|
|
4177
|
+
static fromSafePromise(promise) {
|
|
4178
|
+
return new ResultAsync(promise.then((value) => new Ok(value)));
|
|
4179
|
+
}
|
|
4180
|
+
static fromPromise(promise, errorFn) {
|
|
4181
|
+
return new ResultAsync(promise.then((value) => new Ok(value)).catch((e) => new Err(errorFn(e))));
|
|
4182
|
+
}
|
|
4183
|
+
static fromThrowable(fn, errorFn) {
|
|
4184
|
+
return (...args) => {
|
|
4185
|
+
return new ResultAsync(__awaiter(this, void 0, void 0, function* () {
|
|
4186
|
+
try {
|
|
4187
|
+
return new Ok(yield fn(...args));
|
|
4188
|
+
} catch (error) {
|
|
4189
|
+
return new Err(errorFn ? errorFn(error) : error);
|
|
4190
|
+
}
|
|
4191
|
+
}));
|
|
4192
|
+
};
|
|
4193
|
+
}
|
|
4194
|
+
static combine(asyncResultList) {
|
|
4195
|
+
return combineResultAsyncList(asyncResultList);
|
|
4196
|
+
}
|
|
4197
|
+
static combineWithAllErrors(asyncResultList) {
|
|
4198
|
+
return combineResultAsyncListWithAllErrors(asyncResultList);
|
|
4199
|
+
}
|
|
4200
|
+
map(f) {
|
|
4201
|
+
return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
4202
|
+
if (res.isErr()) return new Err(res.error);
|
|
4203
|
+
return new Ok(yield f(res.value));
|
|
4204
|
+
})));
|
|
4205
|
+
}
|
|
4206
|
+
andThrough(f) {
|
|
4207
|
+
return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
4208
|
+
if (res.isErr()) return new Err(res.error);
|
|
4209
|
+
const newRes = yield f(res.value);
|
|
4210
|
+
if (newRes.isErr()) return new Err(newRes.error);
|
|
4211
|
+
return new Ok(res.value);
|
|
4212
|
+
})));
|
|
4213
|
+
}
|
|
4214
|
+
andTee(f) {
|
|
4215
|
+
return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
4216
|
+
if (res.isErr()) return new Err(res.error);
|
|
4217
|
+
try {
|
|
4218
|
+
yield f(res.value);
|
|
4219
|
+
} catch (e) {}
|
|
4220
|
+
return new Ok(res.value);
|
|
4221
|
+
})));
|
|
4222
|
+
}
|
|
4223
|
+
orTee(f) {
|
|
4224
|
+
return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
4225
|
+
if (res.isOk()) return new Ok(res.value);
|
|
4226
|
+
try {
|
|
4227
|
+
yield f(res.error);
|
|
4228
|
+
} catch (e) {}
|
|
4229
|
+
return new Err(res.error);
|
|
4230
|
+
})));
|
|
4231
|
+
}
|
|
4232
|
+
mapErr(f) {
|
|
4233
|
+
return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
4234
|
+
if (res.isOk()) return new Ok(res.value);
|
|
4235
|
+
return new Err(yield f(res.error));
|
|
4236
|
+
})));
|
|
4237
|
+
}
|
|
4238
|
+
andThen(f) {
|
|
4239
|
+
return new ResultAsync(this._promise.then((res) => {
|
|
4240
|
+
if (res.isErr()) return new Err(res.error);
|
|
4241
|
+
const newValue = f(res.value);
|
|
4242
|
+
return newValue instanceof ResultAsync ? newValue._promise : newValue;
|
|
4243
|
+
}));
|
|
4244
|
+
}
|
|
4245
|
+
orElse(f) {
|
|
4246
|
+
return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
4247
|
+
if (res.isErr()) return f(res.error);
|
|
4248
|
+
return new Ok(res.value);
|
|
4249
|
+
})));
|
|
4250
|
+
}
|
|
4251
|
+
match(ok, _err) {
|
|
4252
|
+
return this._promise.then((res) => res.match(ok, _err));
|
|
4253
|
+
}
|
|
4254
|
+
unwrapOr(t) {
|
|
4255
|
+
return this._promise.then((res) => res.unwrapOr(t));
|
|
4256
|
+
}
|
|
4257
|
+
/**
|
|
4258
|
+
* @deprecated will be removed in 9.0.0.
|
|
4259
|
+
*
|
|
4260
|
+
* You can use `safeTry` without this method.
|
|
4261
|
+
* @example
|
|
4262
|
+
* ```typescript
|
|
4263
|
+
* safeTry(async function* () {
|
|
4264
|
+
* const okValue = yield* yourResult
|
|
4265
|
+
* })
|
|
4266
|
+
* ```
|
|
4267
|
+
* Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
|
|
4268
|
+
*/
|
|
4269
|
+
safeUnwrap() {
|
|
4270
|
+
return __asyncGenerator(this, arguments, function* safeUnwrap_1() {
|
|
4271
|
+
return yield __await(yield __await(yield* __asyncDelegator(__asyncValues(yield __await(this._promise.then((res) => res.safeUnwrap()))))));
|
|
4272
|
+
});
|
|
4273
|
+
}
|
|
4274
|
+
then(successCallback, failureCallback) {
|
|
4275
|
+
return this._promise.then(successCallback, failureCallback);
|
|
4276
|
+
}
|
|
4277
|
+
[Symbol.asyncIterator]() {
|
|
4278
|
+
return __asyncGenerator(this, arguments, function* _a() {
|
|
4279
|
+
const result = yield __await(this._promise);
|
|
4280
|
+
if (result.isErr()) yield yield __await(errAsync(result.error));
|
|
4281
|
+
return yield __await(result.value);
|
|
4282
|
+
});
|
|
4283
|
+
}
|
|
4284
|
+
};
|
|
4285
|
+
function okAsync(value) {
|
|
4286
|
+
return new ResultAsync(Promise.resolve(new Ok(value)));
|
|
4287
|
+
}
|
|
4288
|
+
function errAsync(err) {
|
|
4289
|
+
return new ResultAsync(Promise.resolve(new Err(err)));
|
|
4290
|
+
}
|
|
4291
|
+
const fromPromise = ResultAsync.fromPromise;
|
|
4292
|
+
const fromSafePromise = ResultAsync.fromSafePromise;
|
|
4293
|
+
const fromAsyncThrowable = ResultAsync.fromThrowable;
|
|
4294
|
+
/**
|
|
4295
|
+
* Short circuits on the FIRST Err value that we find
|
|
4296
|
+
*/
|
|
4297
|
+
const combineResultList = (resultList) => {
|
|
4298
|
+
let acc = ok([]);
|
|
4299
|
+
for (const result of resultList) if (result.isErr()) {
|
|
4300
|
+
acc = err(result.error);
|
|
4301
|
+
break;
|
|
4302
|
+
} else acc.map((list) => list.push(result.value));
|
|
4303
|
+
return acc;
|
|
4222
4304
|
};
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4305
|
+
const combineResultAsyncList = (asyncResultList) => ResultAsync.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultList);
|
|
4306
|
+
/**
|
|
4307
|
+
* Give a list of all the errors we find
|
|
4308
|
+
*/
|
|
4309
|
+
const combineResultListWithAllErrors = (resultList) => {
|
|
4310
|
+
let acc = ok([]);
|
|
4311
|
+
for (const result of resultList) if (result.isErr() && acc.isErr()) acc.error.push(result.error);
|
|
4312
|
+
else if (result.isErr() && acc.isOk()) acc = err([result.error]);
|
|
4313
|
+
else if (result.isOk() && acc.isOk()) acc.value.push(result.value);
|
|
4314
|
+
return acc;
|
|
4233
4315
|
};
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
}
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
return
|
|
4280
|
-
}
|
|
4281
|
-
|
|
4282
|
-
|
|
4316
|
+
const combineResultAsyncListWithAllErrors = (asyncResultList) => ResultAsync.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultListWithAllErrors);
|
|
4317
|
+
exports.Result = void 0;
|
|
4318
|
+
(function(Result) {
|
|
4319
|
+
/**
|
|
4320
|
+
* Wraps a function with a try catch, creating a new function with the same
|
|
4321
|
+
* arguments but returning `Ok` if successful, `Err` if the function throws
|
|
4322
|
+
*
|
|
4323
|
+
* @param fn function to wrap with ok on success or err on failure
|
|
4324
|
+
* @param errorFn when an error is thrown, this will wrap the error result if provided
|
|
4325
|
+
*/
|
|
4326
|
+
function fromThrowable(fn, errorFn) {
|
|
4327
|
+
return (...args) => {
|
|
4328
|
+
try {
|
|
4329
|
+
return ok(fn(...args));
|
|
4330
|
+
} catch (e) {
|
|
4331
|
+
return err(errorFn ? errorFn(e) : e);
|
|
4332
|
+
}
|
|
4333
|
+
};
|
|
4334
|
+
}
|
|
4335
|
+
Result.fromThrowable = fromThrowable;
|
|
4336
|
+
function combine(resultList) {
|
|
4337
|
+
return combineResultList(resultList);
|
|
4338
|
+
}
|
|
4339
|
+
Result.combine = combine;
|
|
4340
|
+
function combineWithAllErrors(resultList) {
|
|
4341
|
+
return combineResultListWithAllErrors(resultList);
|
|
4342
|
+
}
|
|
4343
|
+
Result.combineWithAllErrors = combineWithAllErrors;
|
|
4344
|
+
})(exports.Result || (exports.Result = {}));
|
|
4345
|
+
function ok(value) {
|
|
4346
|
+
return new Ok(value);
|
|
4347
|
+
}
|
|
4348
|
+
function err(err) {
|
|
4349
|
+
return new Err(err);
|
|
4350
|
+
}
|
|
4351
|
+
function safeTry(body) {
|
|
4352
|
+
const n = body().next();
|
|
4353
|
+
if (n instanceof Promise) return new ResultAsync(n.then((r) => r.value));
|
|
4354
|
+
return n.value;
|
|
4355
|
+
}
|
|
4356
|
+
var Ok = class {
|
|
4357
|
+
constructor(value) {
|
|
4358
|
+
this.value = value;
|
|
4359
|
+
}
|
|
4360
|
+
isOk() {
|
|
4361
|
+
return true;
|
|
4362
|
+
}
|
|
4363
|
+
isErr() {
|
|
4364
|
+
return !this.isOk();
|
|
4365
|
+
}
|
|
4366
|
+
map(f) {
|
|
4367
|
+
return ok(f(this.value));
|
|
4368
|
+
}
|
|
4369
|
+
mapErr(_f) {
|
|
4370
|
+
return ok(this.value);
|
|
4371
|
+
}
|
|
4372
|
+
andThen(f) {
|
|
4373
|
+
return f(this.value);
|
|
4374
|
+
}
|
|
4375
|
+
andThrough(f) {
|
|
4376
|
+
return f(this.value).map((_value) => this.value);
|
|
4377
|
+
}
|
|
4378
|
+
andTee(f) {
|
|
4379
|
+
try {
|
|
4380
|
+
f(this.value);
|
|
4381
|
+
} catch (e) {}
|
|
4382
|
+
return ok(this.value);
|
|
4383
|
+
}
|
|
4384
|
+
orTee(_f) {
|
|
4385
|
+
return ok(this.value);
|
|
4386
|
+
}
|
|
4387
|
+
orElse(_f) {
|
|
4388
|
+
return ok(this.value);
|
|
4389
|
+
}
|
|
4390
|
+
asyncAndThen(f) {
|
|
4391
|
+
return f(this.value);
|
|
4392
|
+
}
|
|
4393
|
+
asyncAndThrough(f) {
|
|
4394
|
+
return f(this.value).map(() => this.value);
|
|
4395
|
+
}
|
|
4396
|
+
asyncMap(f) {
|
|
4397
|
+
return ResultAsync.fromSafePromise(f(this.value));
|
|
4398
|
+
}
|
|
4399
|
+
unwrapOr(_v) {
|
|
4400
|
+
return this.value;
|
|
4401
|
+
}
|
|
4402
|
+
match(ok, _err) {
|
|
4403
|
+
return ok(this.value);
|
|
4404
|
+
}
|
|
4405
|
+
safeUnwrap() {
|
|
4406
|
+
const value = this.value;
|
|
4407
|
+
return (function* () {
|
|
4408
|
+
return value;
|
|
4409
|
+
})();
|
|
4410
|
+
}
|
|
4411
|
+
_unsafeUnwrap(_) {
|
|
4412
|
+
return this.value;
|
|
4413
|
+
}
|
|
4414
|
+
_unsafeUnwrapErr(config) {
|
|
4415
|
+
throw createNeverThrowError("Called `_unsafeUnwrapErr` on an Ok", this, config);
|
|
4416
|
+
}
|
|
4417
|
+
*[Symbol.iterator]() {
|
|
4418
|
+
return this.value;
|
|
4419
|
+
}
|
|
4283
4420
|
};
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
type: "transform",
|
|
4288
|
-
transform: fn
|
|
4289
|
-
});
|
|
4290
|
-
}
|
|
4291
|
-
const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
4292
|
-
$ZodOptional.init(inst, def);
|
|
4293
|
-
ZodType.init(inst, def);
|
|
4294
|
-
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
4295
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
4296
|
-
});
|
|
4297
|
-
function optional(innerType) {
|
|
4298
|
-
return new ZodOptional({
|
|
4299
|
-
type: "optional",
|
|
4300
|
-
innerType
|
|
4301
|
-
});
|
|
4302
|
-
}
|
|
4303
|
-
const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
4304
|
-
$ZodExactOptional.init(inst, def);
|
|
4305
|
-
ZodType.init(inst, def);
|
|
4306
|
-
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
4307
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
4308
|
-
});
|
|
4309
|
-
function exactOptional(innerType) {
|
|
4310
|
-
return new ZodExactOptional({
|
|
4311
|
-
type: "optional",
|
|
4312
|
-
innerType
|
|
4313
|
-
});
|
|
4314
|
-
}
|
|
4315
|
-
const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
4316
|
-
$ZodNullable.init(inst, def);
|
|
4317
|
-
ZodType.init(inst, def);
|
|
4318
|
-
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
|
|
4319
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
4320
|
-
});
|
|
4321
|
-
function nullable(innerType) {
|
|
4322
|
-
return new ZodNullable({
|
|
4323
|
-
type: "nullable",
|
|
4324
|
-
innerType
|
|
4325
|
-
});
|
|
4326
|
-
}
|
|
4327
|
-
const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
4328
|
-
$ZodDefault.init(inst, def);
|
|
4329
|
-
ZodType.init(inst, def);
|
|
4330
|
-
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
|
|
4331
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
4332
|
-
inst.removeDefault = inst.unwrap;
|
|
4333
|
-
});
|
|
4334
|
-
function _default(innerType, defaultValue) {
|
|
4335
|
-
return new ZodDefault({
|
|
4336
|
-
type: "default",
|
|
4337
|
-
innerType,
|
|
4338
|
-
get defaultValue() {
|
|
4339
|
-
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
4421
|
+
var Err = class {
|
|
4422
|
+
constructor(error) {
|
|
4423
|
+
this.error = error;
|
|
4340
4424
|
}
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
4344
|
-
$ZodPrefault.init(inst, def);
|
|
4345
|
-
ZodType.init(inst, def);
|
|
4346
|
-
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
|
|
4347
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
4348
|
-
});
|
|
4349
|
-
function prefault(innerType, defaultValue) {
|
|
4350
|
-
return new ZodPrefault({
|
|
4351
|
-
type: "prefault",
|
|
4352
|
-
innerType,
|
|
4353
|
-
get defaultValue() {
|
|
4354
|
-
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
4425
|
+
isOk() {
|
|
4426
|
+
return false;
|
|
4355
4427
|
}
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
}
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
}
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
const
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
}
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
}
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
}
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4428
|
+
isErr() {
|
|
4429
|
+
return !this.isOk();
|
|
4430
|
+
}
|
|
4431
|
+
map(_f) {
|
|
4432
|
+
return err(this.error);
|
|
4433
|
+
}
|
|
4434
|
+
mapErr(f) {
|
|
4435
|
+
return err(f(this.error));
|
|
4436
|
+
}
|
|
4437
|
+
andThrough(_f) {
|
|
4438
|
+
return err(this.error);
|
|
4439
|
+
}
|
|
4440
|
+
andTee(_f) {
|
|
4441
|
+
return err(this.error);
|
|
4442
|
+
}
|
|
4443
|
+
orTee(f) {
|
|
4444
|
+
try {
|
|
4445
|
+
f(this.error);
|
|
4446
|
+
} catch (e) {}
|
|
4447
|
+
return err(this.error);
|
|
4448
|
+
}
|
|
4449
|
+
andThen(_f) {
|
|
4450
|
+
return err(this.error);
|
|
4451
|
+
}
|
|
4452
|
+
orElse(f) {
|
|
4453
|
+
return f(this.error);
|
|
4454
|
+
}
|
|
4455
|
+
asyncAndThen(_f) {
|
|
4456
|
+
return errAsync(this.error);
|
|
4457
|
+
}
|
|
4458
|
+
asyncAndThrough(_f) {
|
|
4459
|
+
return errAsync(this.error);
|
|
4460
|
+
}
|
|
4461
|
+
asyncMap(_f) {
|
|
4462
|
+
return errAsync(this.error);
|
|
4463
|
+
}
|
|
4464
|
+
unwrapOr(v) {
|
|
4465
|
+
return v;
|
|
4466
|
+
}
|
|
4467
|
+
match(_ok, err) {
|
|
4468
|
+
return err(this.error);
|
|
4469
|
+
}
|
|
4470
|
+
safeUnwrap() {
|
|
4471
|
+
const error = this.error;
|
|
4472
|
+
return (function* () {
|
|
4473
|
+
yield err(error);
|
|
4474
|
+
throw new Error("Do not use this generator out of `safeTry`");
|
|
4475
|
+
})();
|
|
4476
|
+
}
|
|
4477
|
+
_unsafeUnwrap(config) {
|
|
4478
|
+
throw createNeverThrowError("Called `_unsafeUnwrap` on an Err", this, config);
|
|
4479
|
+
}
|
|
4480
|
+
_unsafeUnwrapErr(_) {
|
|
4481
|
+
return this.error;
|
|
4482
|
+
}
|
|
4483
|
+
*[Symbol.iterator]() {
|
|
4484
|
+
const self = this;
|
|
4485
|
+
yield self;
|
|
4486
|
+
return self;
|
|
4487
|
+
}
|
|
4488
|
+
};
|
|
4489
|
+
const fromThrowable = exports.Result.fromThrowable;
|
|
4490
|
+
exports.Err = Err;
|
|
4491
|
+
exports.Ok = Ok;
|
|
4492
|
+
exports.ResultAsync = ResultAsync;
|
|
4493
|
+
exports.err = err;
|
|
4494
|
+
exports.errAsync = errAsync;
|
|
4495
|
+
exports.fromAsyncThrowable = fromAsyncThrowable;
|
|
4496
|
+
exports.fromPromise = fromPromise;
|
|
4497
|
+
exports.fromSafePromise = fromSafePromise;
|
|
4498
|
+
exports.fromThrowable = fromThrowable;
|
|
4499
|
+
exports.ok = ok;
|
|
4500
|
+
exports.okAsync = okAsync;
|
|
4501
|
+
exports.safeTry = safeTry;
|
|
4502
|
+
}));
|
|
4422
4503
|
//#endregion
|
|
4423
|
-
export {
|
|
4504
|
+
export { discriminatedUnion as a, number as c, record as d, string as f, prettifyError as g, url as h, boolean as i, object as l, unknown as m, _enum as n, literal as o, union as p, array as r, looseObject as s, require_index_cjs as t, preprocess as u };
|
|
4424
4505
|
|
|
4425
|
-
//# sourceMappingURL=
|
|
4506
|
+
//# sourceMappingURL=index.cjs-teGsk6HB.js.map
|