@stackone/connect-sdk 1.36.0 → 1.37.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/dist/index.js +17 -4231
- package/dist/index.mjs +17 -4200
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,4241 +1,27 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
const __stackone_transport = __toESM(require("@stackone/transport"));
|
|
25
|
-
const path_to_regexp = __toESM(require("path-to-regexp"));
|
|
26
|
-
const __stackone_core = __toESM(require("@stackone/core"));
|
|
27
|
-
const __stackone_utils = __toESM(require("@stackone/utils"));
|
|
28
|
-
const yaml = __toESM(require("yaml"));
|
|
29
|
-
const __stackone_expressions = __toESM(require("@stackone/expressions"));
|
|
30
|
-
|
|
31
|
-
//#region src/blocks/createBlock.ts
|
|
32
|
-
const createBlock = async ({ inputs, context, operation, credentials, nextCursor, logger, getHttpClient = async () => __stackone_transport.HttpClientManager.getInstance() }) => {
|
|
33
|
-
const httpClient = await getHttpClient();
|
|
34
|
-
return {
|
|
35
|
-
inputs,
|
|
36
|
-
fieldConfigs: [],
|
|
37
|
-
context,
|
|
38
|
-
operation,
|
|
39
|
-
credentials,
|
|
40
|
-
nextCursor,
|
|
41
|
-
httpClient,
|
|
42
|
-
logger
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region src/connectors/operations.ts
|
|
48
|
-
const getOperationFromUrl = (connector, url, method) => {
|
|
49
|
-
const httpMethod = method.toUpperCase();
|
|
50
|
-
if (!connector.operations) return void 0;
|
|
51
|
-
const validOperationUrls = Object.keys(connector.operations);
|
|
52
|
-
const test = testMatcher(url, httpMethod, validOperationUrls);
|
|
53
|
-
if (!test) return void 0;
|
|
54
|
-
return {
|
|
55
|
-
operation: connector.operations?.[test.path],
|
|
56
|
-
params: test.params
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
const removeLeadingAndTrailingSlashes = (path) => {
|
|
60
|
-
const withoutLeadingSlash = path.startsWith("/") ? path.slice(1) : path;
|
|
61
|
-
const withoutTrailingSlash = withoutLeadingSlash.endsWith("/") ? withoutLeadingSlash.slice(0, -1) : withoutLeadingSlash;
|
|
62
|
-
return withoutTrailingSlash;
|
|
63
|
-
};
|
|
64
|
-
const testMatcher = (url, method, routes) => {
|
|
65
|
-
const path = removeLeadingAndTrailingSlashes(url);
|
|
66
|
-
for (const r of routes) if (r.startsWith(method)) {
|
|
67
|
-
const cleanRoute = r.replace(`${method} `, "").trim();
|
|
68
|
-
const fn = (0, path_to_regexp.match)(removeLeadingAndTrailingSlashes(cleanRoute));
|
|
69
|
-
const res = fn(removeLeadingAndTrailingSlashes(path));
|
|
70
|
-
if (res !== false) return {
|
|
71
|
-
path: r,
|
|
72
|
-
params: res.params
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
return void 0;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region ../../node_modules/zod/v4/core/core.js
|
|
80
|
-
/** A special constant with type `never` */
|
|
81
|
-
const NEVER = Object.freeze({ status: "aborted" });
|
|
82
|
-
function $constructor(name, initializer$2, params) {
|
|
83
|
-
function init(inst, def) {
|
|
84
|
-
var _a;
|
|
85
|
-
Object.defineProperty(inst, "_zod", {
|
|
86
|
-
value: inst._zod ?? {},
|
|
87
|
-
enumerable: false
|
|
88
|
-
});
|
|
89
|
-
(_a = inst._zod).traits ?? (_a.traits = /* @__PURE__ */ new Set());
|
|
90
|
-
inst._zod.traits.add(name);
|
|
91
|
-
initializer$2(inst, def);
|
|
92
|
-
for (const k in _.prototype) if (!(k in inst)) Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
|
|
93
|
-
inst._zod.constr = _;
|
|
94
|
-
inst._zod.def = def;
|
|
95
|
-
}
|
|
96
|
-
const Parent = params?.Parent ?? Object;
|
|
97
|
-
class Definition extends Parent {}
|
|
98
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
99
|
-
function _(def) {
|
|
100
|
-
var _a;
|
|
101
|
-
const inst = params?.Parent ? new Definition() : this;
|
|
102
|
-
init(inst, def);
|
|
103
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
104
|
-
for (const fn of inst._zod.deferred) fn();
|
|
105
|
-
return inst;
|
|
106
|
-
}
|
|
107
|
-
Object.defineProperty(_, "init", { value: init });
|
|
108
|
-
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
109
|
-
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
110
|
-
return inst?._zod?.traits?.has(name);
|
|
111
|
-
} });
|
|
112
|
-
Object.defineProperty(_, "name", { value: name });
|
|
113
|
-
return _;
|
|
114
|
-
}
|
|
115
|
-
const $brand = Symbol("zod_brand");
|
|
116
|
-
var $ZodAsyncError = class extends Error {
|
|
117
|
-
constructor() {
|
|
118
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
const globalConfig = {};
|
|
122
|
-
function config(newConfig) {
|
|
123
|
-
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
124
|
-
return globalConfig;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region ../../node_modules/zod/v4/core/util.js
|
|
129
|
-
function getEnumValues(entries) {
|
|
130
|
-
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
131
|
-
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
132
|
-
return values;
|
|
133
|
-
}
|
|
134
|
-
function jsonStringifyReplacer(_, value) {
|
|
135
|
-
if (typeof value === "bigint") return value.toString();
|
|
136
|
-
return value;
|
|
137
|
-
}
|
|
138
|
-
function cached(getter) {
|
|
139
|
-
const set = false;
|
|
140
|
-
return { get value() {
|
|
141
|
-
{
|
|
142
|
-
const value = getter();
|
|
143
|
-
Object.defineProperty(this, "value", { value });
|
|
144
|
-
return value;
|
|
145
|
-
}
|
|
146
|
-
} };
|
|
147
|
-
}
|
|
148
|
-
function nullish(input) {
|
|
149
|
-
return input === null || input === void 0;
|
|
150
|
-
}
|
|
151
|
-
function cleanRegex(source) {
|
|
152
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
153
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
154
|
-
return source.slice(start, end);
|
|
155
|
-
}
|
|
156
|
-
function floatSafeRemainder(val, step) {
|
|
157
|
-
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
158
|
-
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
159
|
-
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
160
|
-
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
161
|
-
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
162
|
-
return valInt % stepInt / 10 ** decCount;
|
|
163
|
-
}
|
|
164
|
-
function defineLazy(object$1, key, getter) {
|
|
165
|
-
const set = false;
|
|
166
|
-
Object.defineProperty(object$1, key, {
|
|
167
|
-
get() {
|
|
168
|
-
{
|
|
169
|
-
const value = getter();
|
|
170
|
-
object$1[key] = value;
|
|
171
|
-
return value;
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
set(v) {
|
|
175
|
-
Object.defineProperty(object$1, key, { value: v });
|
|
176
|
-
},
|
|
177
|
-
configurable: true
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
function assignProp(target, prop, value) {
|
|
181
|
-
Object.defineProperty(target, prop, {
|
|
182
|
-
value,
|
|
183
|
-
writable: true,
|
|
184
|
-
enumerable: true,
|
|
185
|
-
configurable: true
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
function esc(str) {
|
|
189
|
-
return JSON.stringify(str);
|
|
190
|
-
}
|
|
191
|
-
const captureStackTrace = Error.captureStackTrace ? Error.captureStackTrace : (..._args) => {};
|
|
192
|
-
function isObject$3(data) {
|
|
193
|
-
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
194
|
-
}
|
|
195
|
-
const allowsEval = cached(() => {
|
|
196
|
-
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
|
|
197
|
-
try {
|
|
198
|
-
const F = Function;
|
|
199
|
-
new F("");
|
|
200
|
-
return true;
|
|
201
|
-
} catch (_) {
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
function isPlainObject(o) {
|
|
206
|
-
if (isObject$3(o) === false) return false;
|
|
207
|
-
const ctor = o.constructor;
|
|
208
|
-
if (ctor === void 0) return true;
|
|
209
|
-
const prot = ctor.prototype;
|
|
210
|
-
if (isObject$3(prot) === false) return false;
|
|
211
|
-
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
212
|
-
return true;
|
|
213
|
-
}
|
|
214
|
-
const propertyKeyTypes = new Set([
|
|
215
|
-
"string",
|
|
216
|
-
"number",
|
|
217
|
-
"symbol"
|
|
218
|
-
]);
|
|
219
|
-
function escapeRegex(str) {
|
|
220
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
221
|
-
}
|
|
222
|
-
function clone(inst, def, params) {
|
|
223
|
-
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
224
|
-
if (!def || params?.parent) cl._zod.parent = inst;
|
|
225
|
-
return cl;
|
|
226
|
-
}
|
|
227
|
-
function normalizeParams(_params) {
|
|
228
|
-
const params = _params;
|
|
229
|
-
if (!params) return {};
|
|
230
|
-
if (typeof params === "string") return { error: () => params };
|
|
231
|
-
if (params?.message !== void 0) {
|
|
232
|
-
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
|
233
|
-
params.error = params.message;
|
|
234
|
-
}
|
|
235
|
-
delete params.message;
|
|
236
|
-
if (typeof params.error === "string") return {
|
|
237
|
-
...params,
|
|
238
|
-
error: () => params.error
|
|
239
|
-
};
|
|
240
|
-
return params;
|
|
241
|
-
}
|
|
242
|
-
function optionalKeys(shape) {
|
|
243
|
-
return Object.keys(shape).filter((k) => {
|
|
244
|
-
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
const NUMBER_FORMAT_RANGES = {
|
|
248
|
-
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
249
|
-
int32: [-2147483648, 2147483647],
|
|
250
|
-
uint32: [0, 4294967295],
|
|
251
|
-
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
252
|
-
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
253
|
-
};
|
|
254
|
-
function pick(schema, mask) {
|
|
255
|
-
const newShape = {};
|
|
256
|
-
const currDef = schema._zod.def;
|
|
257
|
-
for (const key in mask) {
|
|
258
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
259
|
-
if (!mask[key]) continue;
|
|
260
|
-
newShape[key] = currDef.shape[key];
|
|
261
|
-
}
|
|
262
|
-
return clone(schema, {
|
|
263
|
-
...schema._zod.def,
|
|
264
|
-
shape: newShape,
|
|
265
|
-
checks: []
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
function omit(schema, mask) {
|
|
269
|
-
const newShape = { ...schema._zod.def.shape };
|
|
270
|
-
const currDef = schema._zod.def;
|
|
271
|
-
for (const key in mask) {
|
|
272
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
273
|
-
if (!mask[key]) continue;
|
|
274
|
-
delete newShape[key];
|
|
275
|
-
}
|
|
276
|
-
return clone(schema, {
|
|
277
|
-
...schema._zod.def,
|
|
278
|
-
shape: newShape,
|
|
279
|
-
checks: []
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
function extend(schema, shape) {
|
|
283
|
-
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
284
|
-
const def = {
|
|
285
|
-
...schema._zod.def,
|
|
286
|
-
get shape() {
|
|
287
|
-
const _shape = {
|
|
288
|
-
...schema._zod.def.shape,
|
|
289
|
-
...shape
|
|
290
|
-
};
|
|
291
|
-
assignProp(this, "shape", _shape);
|
|
292
|
-
return _shape;
|
|
293
|
-
},
|
|
294
|
-
checks: []
|
|
295
|
-
};
|
|
296
|
-
return clone(schema, def);
|
|
297
|
-
}
|
|
298
|
-
function merge(a, b) {
|
|
299
|
-
return clone(a, {
|
|
300
|
-
...a._zod.def,
|
|
301
|
-
get shape() {
|
|
302
|
-
const _shape = {
|
|
303
|
-
...a._zod.def.shape,
|
|
304
|
-
...b._zod.def.shape
|
|
305
|
-
};
|
|
306
|
-
assignProp(this, "shape", _shape);
|
|
307
|
-
return _shape;
|
|
308
|
-
},
|
|
309
|
-
catchall: b._zod.def.catchall,
|
|
310
|
-
checks: []
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
function partial(Class, schema, mask) {
|
|
314
|
-
const oldShape = schema._zod.def.shape;
|
|
315
|
-
const shape = { ...oldShape };
|
|
316
|
-
if (mask) for (const key in mask) {
|
|
317
|
-
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
318
|
-
if (!mask[key]) continue;
|
|
319
|
-
shape[key] = Class ? new Class({
|
|
320
|
-
type: "optional",
|
|
321
|
-
innerType: oldShape[key]
|
|
322
|
-
}) : oldShape[key];
|
|
323
|
-
}
|
|
324
|
-
else for (const key in oldShape) shape[key] = Class ? new Class({
|
|
325
|
-
type: "optional",
|
|
326
|
-
innerType: oldShape[key]
|
|
327
|
-
}) : oldShape[key];
|
|
328
|
-
return clone(schema, {
|
|
329
|
-
...schema._zod.def,
|
|
330
|
-
shape,
|
|
331
|
-
checks: []
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
function required(Class, schema, mask) {
|
|
335
|
-
const oldShape = schema._zod.def.shape;
|
|
336
|
-
const shape = { ...oldShape };
|
|
337
|
-
if (mask) for (const key in mask) {
|
|
338
|
-
if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
339
|
-
if (!mask[key]) continue;
|
|
340
|
-
shape[key] = new Class({
|
|
341
|
-
type: "nonoptional",
|
|
342
|
-
innerType: oldShape[key]
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
else for (const key in oldShape) shape[key] = new Class({
|
|
346
|
-
type: "nonoptional",
|
|
347
|
-
innerType: oldShape[key]
|
|
348
|
-
});
|
|
349
|
-
return clone(schema, {
|
|
350
|
-
...schema._zod.def,
|
|
351
|
-
shape,
|
|
352
|
-
checks: []
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
function aborted(x, startIndex = 0) {
|
|
356
|
-
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
|
|
357
|
-
return false;
|
|
358
|
-
}
|
|
359
|
-
function prefixIssues(path, issues) {
|
|
360
|
-
return issues.map((iss) => {
|
|
361
|
-
var _a;
|
|
362
|
-
(_a = iss).path ?? (_a.path = []);
|
|
363
|
-
iss.path.unshift(path);
|
|
364
|
-
return iss;
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
function unwrapMessage(message) {
|
|
368
|
-
return typeof message === "string" ? message : message?.message;
|
|
369
|
-
}
|
|
370
|
-
function finalizeIssue(iss, ctx, config$1) {
|
|
371
|
-
const full = {
|
|
372
|
-
...iss,
|
|
373
|
-
path: iss.path ?? []
|
|
374
|
-
};
|
|
375
|
-
if (!iss.message) {
|
|
376
|
-
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";
|
|
377
|
-
full.message = message;
|
|
378
|
-
}
|
|
379
|
-
delete full.inst;
|
|
380
|
-
delete full.continue;
|
|
381
|
-
if (!ctx?.reportInput) delete full.input;
|
|
382
|
-
return full;
|
|
383
|
-
}
|
|
384
|
-
function getLengthableOrigin(input) {
|
|
385
|
-
if (Array.isArray(input)) return "array";
|
|
386
|
-
if (typeof input === "string") return "string";
|
|
387
|
-
return "unknown";
|
|
388
|
-
}
|
|
389
|
-
function issue(...args) {
|
|
390
|
-
const [iss, input, inst] = args;
|
|
391
|
-
if (typeof iss === "string") return {
|
|
392
|
-
message: iss,
|
|
393
|
-
code: "custom",
|
|
394
|
-
input,
|
|
395
|
-
inst
|
|
396
|
-
};
|
|
397
|
-
return { ...iss };
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
//#endregion
|
|
401
|
-
//#region ../../node_modules/zod/v4/core/errors.js
|
|
402
|
-
const initializer$1 = (inst, def) => {
|
|
403
|
-
inst.name = "$ZodError";
|
|
404
|
-
Object.defineProperty(inst, "_zod", {
|
|
405
|
-
value: inst._zod,
|
|
406
|
-
enumerable: false
|
|
407
|
-
});
|
|
408
|
-
Object.defineProperty(inst, "issues", {
|
|
409
|
-
value: def,
|
|
410
|
-
enumerable: false
|
|
411
|
-
});
|
|
412
|
-
Object.defineProperty(inst, "message", {
|
|
413
|
-
get() {
|
|
414
|
-
return JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
415
|
-
},
|
|
416
|
-
enumerable: true
|
|
417
|
-
});
|
|
418
|
-
};
|
|
419
|
-
const $ZodError = $constructor("$ZodError", initializer$1);
|
|
420
|
-
const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
|
|
421
|
-
function flattenError(error, mapper = (issue$1) => issue$1.message) {
|
|
422
|
-
const fieldErrors = {};
|
|
423
|
-
const formErrors = [];
|
|
424
|
-
for (const sub of error.issues) if (sub.path.length > 0) {
|
|
425
|
-
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
426
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
427
|
-
} else formErrors.push(mapper(sub));
|
|
428
|
-
return {
|
|
429
|
-
formErrors,
|
|
430
|
-
fieldErrors
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
function formatError(error, _mapper) {
|
|
434
|
-
const mapper = _mapper || function(issue$1) {
|
|
435
|
-
return issue$1.message;
|
|
436
|
-
};
|
|
437
|
-
const fieldErrors = { _errors: [] };
|
|
438
|
-
const processError = (error$1) => {
|
|
439
|
-
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 }));
|
|
440
|
-
else if (issue$1.code === "invalid_key") processError({ issues: issue$1.issues });
|
|
441
|
-
else if (issue$1.code === "invalid_element") processError({ issues: issue$1.issues });
|
|
442
|
-
else if (issue$1.path.length === 0) fieldErrors._errors.push(mapper(issue$1));
|
|
443
|
-
else {
|
|
444
|
-
let curr = fieldErrors;
|
|
445
|
-
let i = 0;
|
|
446
|
-
while (i < issue$1.path.length) {
|
|
447
|
-
const el = issue$1.path[i];
|
|
448
|
-
const terminal = i === issue$1.path.length - 1;
|
|
449
|
-
if (!terminal) curr[el] = curr[el] || { _errors: [] };
|
|
450
|
-
else {
|
|
451
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
452
|
-
curr[el]._errors.push(mapper(issue$1));
|
|
453
|
-
}
|
|
454
|
-
curr = curr[el];
|
|
455
|
-
i++;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
processError(error);
|
|
460
|
-
return fieldErrors;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
//#endregion
|
|
464
|
-
//#region ../../node_modules/zod/v4/core/parse.js
|
|
465
|
-
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
466
|
-
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
|
467
|
-
const result = schema._zod.run({
|
|
468
|
-
value,
|
|
469
|
-
issues: []
|
|
470
|
-
}, ctx);
|
|
471
|
-
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
472
|
-
if (result.issues.length) {
|
|
473
|
-
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
474
|
-
captureStackTrace(e, _params?.callee);
|
|
475
|
-
throw e;
|
|
476
|
-
}
|
|
477
|
-
return result.value;
|
|
478
|
-
};
|
|
479
|
-
const parse$3 = /* @__PURE__ */ _parse($ZodRealError);
|
|
480
|
-
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
481
|
-
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
482
|
-
let result = schema._zod.run({
|
|
483
|
-
value,
|
|
484
|
-
issues: []
|
|
485
|
-
}, ctx);
|
|
486
|
-
if (result instanceof Promise) result = await result;
|
|
487
|
-
if (result.issues.length) {
|
|
488
|
-
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
489
|
-
captureStackTrace(e, params?.callee);
|
|
490
|
-
throw e;
|
|
491
|
-
}
|
|
492
|
-
return result.value;
|
|
493
|
-
};
|
|
494
|
-
const parseAsync$1 = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
495
|
-
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
496
|
-
const ctx = _ctx ? {
|
|
497
|
-
..._ctx,
|
|
498
|
-
async: false
|
|
499
|
-
} : { async: false };
|
|
500
|
-
const result = schema._zod.run({
|
|
501
|
-
value,
|
|
502
|
-
issues: []
|
|
503
|
-
}, ctx);
|
|
504
|
-
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
505
|
-
return result.issues.length ? {
|
|
506
|
-
success: false,
|
|
507
|
-
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
508
|
-
} : {
|
|
509
|
-
success: true,
|
|
510
|
-
data: result.value
|
|
511
|
-
};
|
|
512
|
-
};
|
|
513
|
-
const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
514
|
-
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
515
|
-
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
516
|
-
let result = schema._zod.run({
|
|
517
|
-
value,
|
|
518
|
-
issues: []
|
|
519
|
-
}, ctx);
|
|
520
|
-
if (result instanceof Promise) result = await result;
|
|
521
|
-
return result.issues.length ? {
|
|
522
|
-
success: false,
|
|
523
|
-
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
524
|
-
} : {
|
|
525
|
-
success: true,
|
|
526
|
-
data: result.value
|
|
527
|
-
};
|
|
528
|
-
};
|
|
529
|
-
const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
530
|
-
|
|
531
|
-
//#endregion
|
|
532
|
-
//#region ../../node_modules/zod/v4/core/regexes.js
|
|
533
|
-
const cuid = /^[cC][^\s-]{8,}$/;
|
|
534
|
-
const cuid2 = /^[0-9a-z]+$/;
|
|
535
|
-
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
536
|
-
const xid = /^[0-9a-vA-V]{20}$/;
|
|
537
|
-
const ksuid = /^[A-Za-z0-9]{27}$/;
|
|
538
|
-
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
539
|
-
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
|
540
|
-
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)?)?)$/;
|
|
541
|
-
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
542
|
-
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})$/;
|
|
543
|
-
/** Returns a regex for validating an RFC 4122 UUID.
|
|
544
|
-
*
|
|
545
|
-
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
|
546
|
-
const uuid = (version$1) => {
|
|
547
|
-
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)$/;
|
|
548
|
-
return /* @__PURE__ */ 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})$`);
|
|
549
|
-
};
|
|
550
|
-
/** Practical email validation */
|
|
551
|
-
const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
552
|
-
const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
553
|
-
function emoji() {
|
|
554
|
-
return new RegExp(_emoji$1, "u");
|
|
555
|
-
}
|
|
556
|
-
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])$/;
|
|
557
|
-
const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/;
|
|
558
|
-
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])$/;
|
|
559
|
-
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])$/;
|
|
560
|
-
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
561
|
-
const base64url = /^[A-Za-z0-9_-]*$/;
|
|
562
|
-
const hostname = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
|
563
|
-
const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
564
|
-
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])))`;
|
|
565
|
-
const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
566
|
-
function timeSource(args) {
|
|
567
|
-
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
568
|
-
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+)?)?`;
|
|
569
|
-
return regex;
|
|
570
|
-
}
|
|
571
|
-
function time$1(args) {
|
|
572
|
-
return /* @__PURE__ */ new RegExp(`^${timeSource(args)}$`);
|
|
573
|
-
}
|
|
574
|
-
function datetime$1(args) {
|
|
575
|
-
const time$2 = timeSource({ precision: args.precision });
|
|
576
|
-
const opts = ["Z"];
|
|
577
|
-
if (args.local) opts.push("");
|
|
578
|
-
if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
|
|
579
|
-
const timeRegex = `${time$2}(?:${opts.join("|")})`;
|
|
580
|
-
return /* @__PURE__ */ new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
581
|
-
}
|
|
582
|
-
const string$1 = (params) => {
|
|
583
|
-
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
584
|
-
return /* @__PURE__ */ new RegExp(`^${regex}$`);
|
|
585
|
-
};
|
|
586
|
-
const integer = /^\d+$/;
|
|
587
|
-
const number$1 = /^-?\d+(?:\.\d+)?/i;
|
|
588
|
-
const boolean$1 = /true|false/i;
|
|
589
|
-
const lowercase = /^[^A-Z]*$/;
|
|
590
|
-
const uppercase = /^[^a-z]*$/;
|
|
591
|
-
|
|
592
|
-
//#endregion
|
|
593
|
-
//#region ../../node_modules/zod/v4/core/checks.js
|
|
594
|
-
const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
595
|
-
var _a;
|
|
596
|
-
inst._zod ?? (inst._zod = {});
|
|
597
|
-
inst._zod.def = def;
|
|
598
|
-
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
599
|
-
});
|
|
600
|
-
const numericOriginMap = {
|
|
601
|
-
number: "number",
|
|
602
|
-
bigint: "bigint",
|
|
603
|
-
object: "date"
|
|
604
|
-
};
|
|
605
|
-
const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
606
|
-
$ZodCheck.init(inst, def);
|
|
607
|
-
const origin = numericOriginMap[typeof def.value];
|
|
608
|
-
inst._zod.onattach.push((inst$1) => {
|
|
609
|
-
const bag = inst$1._zod.bag;
|
|
610
|
-
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
611
|
-
if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
|
|
612
|
-
else bag.exclusiveMaximum = def.value;
|
|
613
|
-
});
|
|
614
|
-
inst._zod.check = (payload) => {
|
|
615
|
-
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
|
|
616
|
-
payload.issues.push({
|
|
617
|
-
origin,
|
|
618
|
-
code: "too_big",
|
|
619
|
-
maximum: def.value,
|
|
620
|
-
input: payload.value,
|
|
621
|
-
inclusive: def.inclusive,
|
|
622
|
-
inst,
|
|
623
|
-
continue: !def.abort
|
|
624
|
-
});
|
|
625
|
-
};
|
|
626
|
-
});
|
|
627
|
-
const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
628
|
-
$ZodCheck.init(inst, def);
|
|
629
|
-
const origin = numericOriginMap[typeof def.value];
|
|
630
|
-
inst._zod.onattach.push((inst$1) => {
|
|
631
|
-
const bag = inst$1._zod.bag;
|
|
632
|
-
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
633
|
-
if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
|
|
634
|
-
else bag.exclusiveMinimum = def.value;
|
|
635
|
-
});
|
|
636
|
-
inst._zod.check = (payload) => {
|
|
637
|
-
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
|
|
638
|
-
payload.issues.push({
|
|
639
|
-
origin,
|
|
640
|
-
code: "too_small",
|
|
641
|
-
minimum: def.value,
|
|
642
|
-
input: payload.value,
|
|
643
|
-
inclusive: def.inclusive,
|
|
644
|
-
inst,
|
|
645
|
-
continue: !def.abort
|
|
646
|
-
});
|
|
647
|
-
};
|
|
648
|
-
});
|
|
649
|
-
const $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
650
|
-
$ZodCheck.init(inst, def);
|
|
651
|
-
inst._zod.onattach.push((inst$1) => {
|
|
652
|
-
var _a;
|
|
653
|
-
(_a = inst$1._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
|
654
|
-
});
|
|
655
|
-
inst._zod.check = (payload) => {
|
|
656
|
-
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
657
|
-
const isMultiple = typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0;
|
|
658
|
-
if (isMultiple) return;
|
|
659
|
-
payload.issues.push({
|
|
660
|
-
origin: typeof payload.value,
|
|
661
|
-
code: "not_multiple_of",
|
|
662
|
-
divisor: def.value,
|
|
663
|
-
input: payload.value,
|
|
664
|
-
inst,
|
|
665
|
-
continue: !def.abort
|
|
666
|
-
});
|
|
667
|
-
};
|
|
668
|
-
});
|
|
669
|
-
const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
|
|
670
|
-
$ZodCheck.init(inst, def);
|
|
671
|
-
def.format = def.format || "float64";
|
|
672
|
-
const isInt = def.format?.includes("int");
|
|
673
|
-
const origin = isInt ? "int" : "number";
|
|
674
|
-
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
675
|
-
inst._zod.onattach.push((inst$1) => {
|
|
676
|
-
const bag = inst$1._zod.bag;
|
|
677
|
-
bag.format = def.format;
|
|
678
|
-
bag.minimum = minimum;
|
|
679
|
-
bag.maximum = maximum;
|
|
680
|
-
if (isInt) bag.pattern = integer;
|
|
681
|
-
});
|
|
682
|
-
inst._zod.check = (payload) => {
|
|
683
|
-
const input = payload.value;
|
|
684
|
-
if (isInt) {
|
|
685
|
-
if (!Number.isInteger(input)) {
|
|
686
|
-
payload.issues.push({
|
|
687
|
-
expected: origin,
|
|
688
|
-
format: def.format,
|
|
689
|
-
code: "invalid_type",
|
|
690
|
-
input,
|
|
691
|
-
inst
|
|
692
|
-
});
|
|
693
|
-
return;
|
|
694
|
-
}
|
|
695
|
-
if (!Number.isSafeInteger(input)) {
|
|
696
|
-
if (input > 0) payload.issues.push({
|
|
697
|
-
input,
|
|
698
|
-
code: "too_big",
|
|
699
|
-
maximum: Number.MAX_SAFE_INTEGER,
|
|
700
|
-
note: "Integers must be within the safe integer range.",
|
|
701
|
-
inst,
|
|
702
|
-
origin,
|
|
703
|
-
continue: !def.abort
|
|
704
|
-
});
|
|
705
|
-
else payload.issues.push({
|
|
706
|
-
input,
|
|
707
|
-
code: "too_small",
|
|
708
|
-
minimum: Number.MIN_SAFE_INTEGER,
|
|
709
|
-
note: "Integers must be within the safe integer range.",
|
|
710
|
-
inst,
|
|
711
|
-
origin,
|
|
712
|
-
continue: !def.abort
|
|
713
|
-
});
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
if (input < minimum) payload.issues.push({
|
|
718
|
-
origin: "number",
|
|
719
|
-
input,
|
|
720
|
-
code: "too_small",
|
|
721
|
-
minimum,
|
|
722
|
-
inclusive: true,
|
|
723
|
-
inst,
|
|
724
|
-
continue: !def.abort
|
|
725
|
-
});
|
|
726
|
-
if (input > maximum) payload.issues.push({
|
|
727
|
-
origin: "number",
|
|
728
|
-
input,
|
|
729
|
-
code: "too_big",
|
|
730
|
-
maximum,
|
|
731
|
-
inst
|
|
732
|
-
});
|
|
733
|
-
};
|
|
734
|
-
});
|
|
735
|
-
const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
736
|
-
$ZodCheck.init(inst, def);
|
|
737
|
-
inst._zod.when = (payload) => {
|
|
738
|
-
const val = payload.value;
|
|
739
|
-
return !nullish(val) && val.length !== void 0;
|
|
740
|
-
};
|
|
741
|
-
inst._zod.onattach.push((inst$1) => {
|
|
742
|
-
const curr = inst$1._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
743
|
-
if (def.maximum < curr) inst$1._zod.bag.maximum = def.maximum;
|
|
744
|
-
});
|
|
745
|
-
inst._zod.check = (payload) => {
|
|
746
|
-
const input = payload.value;
|
|
747
|
-
const length = input.length;
|
|
748
|
-
if (length <= def.maximum) return;
|
|
749
|
-
const origin = getLengthableOrigin(input);
|
|
750
|
-
payload.issues.push({
|
|
751
|
-
origin,
|
|
752
|
-
code: "too_big",
|
|
753
|
-
maximum: def.maximum,
|
|
754
|
-
inclusive: true,
|
|
755
|
-
input,
|
|
756
|
-
inst,
|
|
757
|
-
continue: !def.abort
|
|
758
|
-
});
|
|
759
|
-
};
|
|
760
|
-
});
|
|
761
|
-
const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
762
|
-
$ZodCheck.init(inst, def);
|
|
763
|
-
inst._zod.when = (payload) => {
|
|
764
|
-
const val = payload.value;
|
|
765
|
-
return !nullish(val) && val.length !== void 0;
|
|
766
|
-
};
|
|
767
|
-
inst._zod.onattach.push((inst$1) => {
|
|
768
|
-
const curr = inst$1._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
769
|
-
if (def.minimum > curr) inst$1._zod.bag.minimum = def.minimum;
|
|
770
|
-
});
|
|
771
|
-
inst._zod.check = (payload) => {
|
|
772
|
-
const input = payload.value;
|
|
773
|
-
const length = input.length;
|
|
774
|
-
if (length >= def.minimum) return;
|
|
775
|
-
const origin = getLengthableOrigin(input);
|
|
776
|
-
payload.issues.push({
|
|
777
|
-
origin,
|
|
778
|
-
code: "too_small",
|
|
779
|
-
minimum: def.minimum,
|
|
780
|
-
inclusive: true,
|
|
781
|
-
input,
|
|
782
|
-
inst,
|
|
783
|
-
continue: !def.abort
|
|
784
|
-
});
|
|
785
|
-
};
|
|
786
|
-
});
|
|
787
|
-
const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
788
|
-
$ZodCheck.init(inst, def);
|
|
789
|
-
inst._zod.when = (payload) => {
|
|
790
|
-
const val = payload.value;
|
|
791
|
-
return !nullish(val) && val.length !== void 0;
|
|
792
|
-
};
|
|
793
|
-
inst._zod.onattach.push((inst$1) => {
|
|
794
|
-
const bag = inst$1._zod.bag;
|
|
795
|
-
bag.minimum = def.length;
|
|
796
|
-
bag.maximum = def.length;
|
|
797
|
-
bag.length = def.length;
|
|
798
|
-
});
|
|
799
|
-
inst._zod.check = (payload) => {
|
|
800
|
-
const input = payload.value;
|
|
801
|
-
const length = input.length;
|
|
802
|
-
if (length === def.length) return;
|
|
803
|
-
const origin = getLengthableOrigin(input);
|
|
804
|
-
const tooBig = length > def.length;
|
|
805
|
-
payload.issues.push({
|
|
806
|
-
origin,
|
|
807
|
-
...tooBig ? {
|
|
808
|
-
code: "too_big",
|
|
809
|
-
maximum: def.length
|
|
810
|
-
} : {
|
|
811
|
-
code: "too_small",
|
|
812
|
-
minimum: def.length
|
|
813
|
-
},
|
|
814
|
-
inclusive: true,
|
|
815
|
-
exact: true,
|
|
816
|
-
input: payload.value,
|
|
817
|
-
inst,
|
|
818
|
-
continue: !def.abort
|
|
819
|
-
});
|
|
820
|
-
};
|
|
821
|
-
});
|
|
822
|
-
const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
823
|
-
var _a, _b;
|
|
824
|
-
$ZodCheck.init(inst, def);
|
|
825
|
-
inst._zod.onattach.push((inst$1) => {
|
|
826
|
-
const bag = inst$1._zod.bag;
|
|
827
|
-
bag.format = def.format;
|
|
828
|
-
if (def.pattern) {
|
|
829
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
830
|
-
bag.patterns.add(def.pattern);
|
|
831
|
-
}
|
|
832
|
-
});
|
|
833
|
-
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
834
|
-
def.pattern.lastIndex = 0;
|
|
835
|
-
if (def.pattern.test(payload.value)) return;
|
|
836
|
-
payload.issues.push({
|
|
837
|
-
origin: "string",
|
|
838
|
-
code: "invalid_format",
|
|
839
|
-
format: def.format,
|
|
840
|
-
input: payload.value,
|
|
841
|
-
...def.pattern ? { pattern: def.pattern.toString() } : {},
|
|
842
|
-
inst,
|
|
843
|
-
continue: !def.abort
|
|
844
|
-
});
|
|
845
|
-
});
|
|
846
|
-
else (_b = inst._zod).check ?? (_b.check = () => {});
|
|
847
|
-
});
|
|
848
|
-
const $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
849
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
850
|
-
inst._zod.check = (payload) => {
|
|
851
|
-
def.pattern.lastIndex = 0;
|
|
852
|
-
if (def.pattern.test(payload.value)) return;
|
|
853
|
-
payload.issues.push({
|
|
854
|
-
origin: "string",
|
|
855
|
-
code: "invalid_format",
|
|
856
|
-
format: "regex",
|
|
857
|
-
input: payload.value,
|
|
858
|
-
pattern: def.pattern.toString(),
|
|
859
|
-
inst,
|
|
860
|
-
continue: !def.abort
|
|
861
|
-
});
|
|
862
|
-
};
|
|
863
|
-
});
|
|
864
|
-
const $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
865
|
-
def.pattern ?? (def.pattern = lowercase);
|
|
866
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
867
|
-
});
|
|
868
|
-
const $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
869
|
-
def.pattern ?? (def.pattern = uppercase);
|
|
870
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
871
|
-
});
|
|
872
|
-
const $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
873
|
-
$ZodCheck.init(inst, def);
|
|
874
|
-
const escapedRegex = escapeRegex(def.includes);
|
|
875
|
-
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
876
|
-
def.pattern = pattern;
|
|
877
|
-
inst._zod.onattach.push((inst$1) => {
|
|
878
|
-
const bag = inst$1._zod.bag;
|
|
879
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
880
|
-
bag.patterns.add(pattern);
|
|
881
|
-
});
|
|
882
|
-
inst._zod.check = (payload) => {
|
|
883
|
-
if (payload.value.includes(def.includes, def.position)) return;
|
|
884
|
-
payload.issues.push({
|
|
885
|
-
origin: "string",
|
|
886
|
-
code: "invalid_format",
|
|
887
|
-
format: "includes",
|
|
888
|
-
includes: def.includes,
|
|
889
|
-
input: payload.value,
|
|
890
|
-
inst,
|
|
891
|
-
continue: !def.abort
|
|
892
|
-
});
|
|
893
|
-
};
|
|
894
|
-
});
|
|
895
|
-
const $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
896
|
-
$ZodCheck.init(inst, def);
|
|
897
|
-
const pattern = /* @__PURE__ */ new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
898
|
-
def.pattern ?? (def.pattern = pattern);
|
|
899
|
-
inst._zod.onattach.push((inst$1) => {
|
|
900
|
-
const bag = inst$1._zod.bag;
|
|
901
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
902
|
-
bag.patterns.add(pattern);
|
|
903
|
-
});
|
|
904
|
-
inst._zod.check = (payload) => {
|
|
905
|
-
if (payload.value.startsWith(def.prefix)) return;
|
|
906
|
-
payload.issues.push({
|
|
907
|
-
origin: "string",
|
|
908
|
-
code: "invalid_format",
|
|
909
|
-
format: "starts_with",
|
|
910
|
-
prefix: def.prefix,
|
|
911
|
-
input: payload.value,
|
|
912
|
-
inst,
|
|
913
|
-
continue: !def.abort
|
|
914
|
-
});
|
|
915
|
-
};
|
|
916
|
-
});
|
|
917
|
-
const $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
918
|
-
$ZodCheck.init(inst, def);
|
|
919
|
-
const pattern = /* @__PURE__ */ new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
920
|
-
def.pattern ?? (def.pattern = pattern);
|
|
921
|
-
inst._zod.onattach.push((inst$1) => {
|
|
922
|
-
const bag = inst$1._zod.bag;
|
|
923
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
924
|
-
bag.patterns.add(pattern);
|
|
925
|
-
});
|
|
926
|
-
inst._zod.check = (payload) => {
|
|
927
|
-
if (payload.value.endsWith(def.suffix)) return;
|
|
928
|
-
payload.issues.push({
|
|
929
|
-
origin: "string",
|
|
930
|
-
code: "invalid_format",
|
|
931
|
-
format: "ends_with",
|
|
932
|
-
suffix: def.suffix,
|
|
933
|
-
input: payload.value,
|
|
934
|
-
inst,
|
|
935
|
-
continue: !def.abort
|
|
936
|
-
});
|
|
937
|
-
};
|
|
938
|
-
});
|
|
939
|
-
const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
940
|
-
$ZodCheck.init(inst, def);
|
|
941
|
-
inst._zod.check = (payload) => {
|
|
942
|
-
payload.value = def.tx(payload.value);
|
|
943
|
-
};
|
|
944
|
-
});
|
|
945
|
-
|
|
946
|
-
//#endregion
|
|
947
|
-
//#region ../../node_modules/zod/v4/core/doc.js
|
|
948
|
-
var Doc = class {
|
|
949
|
-
constructor(args = []) {
|
|
950
|
-
this.content = [];
|
|
951
|
-
this.indent = 0;
|
|
952
|
-
if (this) this.args = args;
|
|
953
|
-
}
|
|
954
|
-
indented(fn) {
|
|
955
|
-
this.indent += 1;
|
|
956
|
-
fn(this);
|
|
957
|
-
this.indent -= 1;
|
|
958
|
-
}
|
|
959
|
-
write(arg) {
|
|
960
|
-
if (typeof arg === "function") {
|
|
961
|
-
arg(this, { execution: "sync" });
|
|
962
|
-
arg(this, { execution: "async" });
|
|
963
|
-
return;
|
|
964
|
-
}
|
|
965
|
-
const content = arg;
|
|
966
|
-
const lines = content.split("\n").filter((x) => x);
|
|
967
|
-
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
|
|
968
|
-
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
|
|
969
|
-
for (const line of dedented) this.content.push(line);
|
|
970
|
-
}
|
|
971
|
-
compile() {
|
|
972
|
-
const F = Function;
|
|
973
|
-
const args = this?.args;
|
|
974
|
-
const content = this?.content ?? [``];
|
|
975
|
-
const lines = [...content.map((x) => ` ${x}`)];
|
|
976
|
-
return new F(...args, lines.join("\n"));
|
|
977
|
-
}
|
|
978
|
-
};
|
|
979
|
-
|
|
980
|
-
//#endregion
|
|
981
|
-
//#region ../../node_modules/zod/v4/core/versions.js
|
|
982
|
-
const version = {
|
|
983
|
-
major: 4,
|
|
984
|
-
minor: 0,
|
|
985
|
-
patch: 0
|
|
986
|
-
};
|
|
987
|
-
|
|
988
|
-
//#endregion
|
|
989
|
-
//#region ../../node_modules/zod/v4/core/schemas.js
|
|
990
|
-
const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
991
|
-
var _a;
|
|
992
|
-
inst ?? (inst = {});
|
|
993
|
-
inst._zod.def = def;
|
|
994
|
-
inst._zod.bag = inst._zod.bag || {};
|
|
995
|
-
inst._zod.version = version;
|
|
996
|
-
const checks = [...inst._zod.def.checks ?? []];
|
|
997
|
-
if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
|
|
998
|
-
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
|
|
999
|
-
if (checks.length === 0) {
|
|
1000
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
1001
|
-
inst._zod.deferred?.push(() => {
|
|
1002
|
-
inst._zod.run = inst._zod.parse;
|
|
1003
|
-
});
|
|
1004
|
-
} else {
|
|
1005
|
-
const runChecks = (payload, checks$1, ctx) => {
|
|
1006
|
-
let isAborted = aborted(payload);
|
|
1007
|
-
let asyncResult;
|
|
1008
|
-
for (const ch of checks$1) {
|
|
1009
|
-
if (ch._zod.when) {
|
|
1010
|
-
const shouldRun = ch._zod.when(payload);
|
|
1011
|
-
if (!shouldRun) continue;
|
|
1012
|
-
} else if (isAborted) continue;
|
|
1013
|
-
const currLen = payload.issues.length;
|
|
1014
|
-
const _ = ch._zod.check(payload);
|
|
1015
|
-
if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
|
|
1016
|
-
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
1017
|
-
await _;
|
|
1018
|
-
const nextLen = payload.issues.length;
|
|
1019
|
-
if (nextLen === currLen) return;
|
|
1020
|
-
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1021
|
-
});
|
|
1022
|
-
else {
|
|
1023
|
-
const nextLen = payload.issues.length;
|
|
1024
|
-
if (nextLen === currLen) continue;
|
|
1025
|
-
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
if (asyncResult) return asyncResult.then(() => {
|
|
1029
|
-
return payload;
|
|
1030
|
-
});
|
|
1031
|
-
return payload;
|
|
1032
|
-
};
|
|
1033
|
-
inst._zod.run = (payload, ctx) => {
|
|
1034
|
-
const result = inst._zod.parse(payload, ctx);
|
|
1035
|
-
if (result instanceof Promise) {
|
|
1036
|
-
if (ctx.async === false) throw new $ZodAsyncError();
|
|
1037
|
-
return result.then((result$1) => runChecks(result$1, checks, ctx));
|
|
1038
|
-
}
|
|
1039
|
-
return runChecks(result, checks, ctx);
|
|
1040
|
-
};
|
|
1041
|
-
}
|
|
1042
|
-
inst["~standard"] = {
|
|
1043
|
-
validate: (value) => {
|
|
1044
|
-
try {
|
|
1045
|
-
const r = safeParse$1(inst, value);
|
|
1046
|
-
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
1047
|
-
} catch (_) {
|
|
1048
|
-
return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
1049
|
-
}
|
|
1050
|
-
},
|
|
1051
|
-
vendor: "zod",
|
|
1052
|
-
version: 1
|
|
1053
|
-
};
|
|
1054
|
-
});
|
|
1055
|
-
const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
1056
|
-
$ZodType.init(inst, def);
|
|
1057
|
-
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
|
|
1058
|
-
inst._zod.parse = (payload, _) => {
|
|
1059
|
-
if (def.coerce) try {
|
|
1060
|
-
payload.value = String(payload.value);
|
|
1061
|
-
} catch (_$1) {}
|
|
1062
|
-
if (typeof payload.value === "string") return payload;
|
|
1063
|
-
payload.issues.push({
|
|
1064
|
-
expected: "string",
|
|
1065
|
-
code: "invalid_type",
|
|
1066
|
-
input: payload.value,
|
|
1067
|
-
inst
|
|
1068
|
-
});
|
|
1069
|
-
return payload;
|
|
1070
|
-
};
|
|
1071
|
-
});
|
|
1072
|
-
const $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
|
|
1073
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
1074
|
-
$ZodString.init(inst, def);
|
|
1075
|
-
});
|
|
1076
|
-
const $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
|
|
1077
|
-
def.pattern ?? (def.pattern = guid);
|
|
1078
|
-
$ZodStringFormat.init(inst, def);
|
|
1079
|
-
});
|
|
1080
|
-
const $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
1081
|
-
if (def.version) {
|
|
1082
|
-
const versionMap = {
|
|
1083
|
-
v1: 1,
|
|
1084
|
-
v2: 2,
|
|
1085
|
-
v3: 3,
|
|
1086
|
-
v4: 4,
|
|
1087
|
-
v5: 5,
|
|
1088
|
-
v6: 6,
|
|
1089
|
-
v7: 7,
|
|
1090
|
-
v8: 8
|
|
1091
|
-
};
|
|
1092
|
-
const v = versionMap[def.version];
|
|
1093
|
-
if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
1094
|
-
def.pattern ?? (def.pattern = uuid(v));
|
|
1095
|
-
} else def.pattern ?? (def.pattern = uuid());
|
|
1096
|
-
$ZodStringFormat.init(inst, def);
|
|
1097
|
-
});
|
|
1098
|
-
const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
|
|
1099
|
-
def.pattern ?? (def.pattern = email);
|
|
1100
|
-
$ZodStringFormat.init(inst, def);
|
|
1101
|
-
});
|
|
1102
|
-
const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
1103
|
-
$ZodStringFormat.init(inst, def);
|
|
1104
|
-
inst._zod.check = (payload) => {
|
|
1105
|
-
try {
|
|
1106
|
-
const orig = payload.value;
|
|
1107
|
-
const url = new URL(orig);
|
|
1108
|
-
const href = url.href;
|
|
1109
|
-
if (def.hostname) {
|
|
1110
|
-
def.hostname.lastIndex = 0;
|
|
1111
|
-
if (!def.hostname.test(url.hostname)) payload.issues.push({
|
|
1112
|
-
code: "invalid_format",
|
|
1113
|
-
format: "url",
|
|
1114
|
-
note: "Invalid hostname",
|
|
1115
|
-
pattern: hostname.source,
|
|
1116
|
-
input: payload.value,
|
|
1117
|
-
inst,
|
|
1118
|
-
continue: !def.abort
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
1121
|
-
if (def.protocol) {
|
|
1122
|
-
def.protocol.lastIndex = 0;
|
|
1123
|
-
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
|
|
1124
|
-
code: "invalid_format",
|
|
1125
|
-
format: "url",
|
|
1126
|
-
note: "Invalid protocol",
|
|
1127
|
-
pattern: def.protocol.source,
|
|
1128
|
-
input: payload.value,
|
|
1129
|
-
inst,
|
|
1130
|
-
continue: !def.abort
|
|
1131
|
-
});
|
|
1132
|
-
}
|
|
1133
|
-
if (!orig.endsWith("/") && href.endsWith("/")) payload.value = href.slice(0, -1);
|
|
1134
|
-
else payload.value = href;
|
|
1135
|
-
return;
|
|
1136
|
-
} catch (_) {
|
|
1137
|
-
payload.issues.push({
|
|
1138
|
-
code: "invalid_format",
|
|
1139
|
-
format: "url",
|
|
1140
|
-
input: payload.value,
|
|
1141
|
-
inst,
|
|
1142
|
-
continue: !def.abort
|
|
1143
|
-
});
|
|
1144
|
-
}
|
|
1145
|
-
};
|
|
1146
|
-
});
|
|
1147
|
-
const $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
|
|
1148
|
-
def.pattern ?? (def.pattern = emoji());
|
|
1149
|
-
$ZodStringFormat.init(inst, def);
|
|
1150
|
-
});
|
|
1151
|
-
const $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
|
|
1152
|
-
def.pattern ?? (def.pattern = nanoid);
|
|
1153
|
-
$ZodStringFormat.init(inst, def);
|
|
1154
|
-
});
|
|
1155
|
-
const $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
|
|
1156
|
-
def.pattern ?? (def.pattern = cuid);
|
|
1157
|
-
$ZodStringFormat.init(inst, def);
|
|
1158
|
-
});
|
|
1159
|
-
const $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
|
|
1160
|
-
def.pattern ?? (def.pattern = cuid2);
|
|
1161
|
-
$ZodStringFormat.init(inst, def);
|
|
1162
|
-
});
|
|
1163
|
-
const $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
|
|
1164
|
-
def.pattern ?? (def.pattern = ulid);
|
|
1165
|
-
$ZodStringFormat.init(inst, def);
|
|
1166
|
-
});
|
|
1167
|
-
const $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
|
|
1168
|
-
def.pattern ?? (def.pattern = xid);
|
|
1169
|
-
$ZodStringFormat.init(inst, def);
|
|
1170
|
-
});
|
|
1171
|
-
const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
|
|
1172
|
-
def.pattern ?? (def.pattern = ksuid);
|
|
1173
|
-
$ZodStringFormat.init(inst, def);
|
|
1174
|
-
});
|
|
1175
|
-
const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
|
|
1176
|
-
def.pattern ?? (def.pattern = datetime$1(def));
|
|
1177
|
-
$ZodStringFormat.init(inst, def);
|
|
1178
|
-
});
|
|
1179
|
-
const $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
|
|
1180
|
-
def.pattern ?? (def.pattern = date$1);
|
|
1181
|
-
$ZodStringFormat.init(inst, def);
|
|
1182
|
-
});
|
|
1183
|
-
const $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
|
|
1184
|
-
def.pattern ?? (def.pattern = time$1(def));
|
|
1185
|
-
$ZodStringFormat.init(inst, def);
|
|
1186
|
-
});
|
|
1187
|
-
const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
|
|
1188
|
-
def.pattern ?? (def.pattern = duration$1);
|
|
1189
|
-
$ZodStringFormat.init(inst, def);
|
|
1190
|
-
});
|
|
1191
|
-
const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
|
|
1192
|
-
def.pattern ?? (def.pattern = ipv4);
|
|
1193
|
-
$ZodStringFormat.init(inst, def);
|
|
1194
|
-
inst._zod.onattach.push((inst$1) => {
|
|
1195
|
-
const bag = inst$1._zod.bag;
|
|
1196
|
-
bag.format = `ipv4`;
|
|
1197
|
-
});
|
|
1198
|
-
});
|
|
1199
|
-
const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
1200
|
-
def.pattern ?? (def.pattern = ipv6);
|
|
1201
|
-
$ZodStringFormat.init(inst, def);
|
|
1202
|
-
inst._zod.onattach.push((inst$1) => {
|
|
1203
|
-
const bag = inst$1._zod.bag;
|
|
1204
|
-
bag.format = `ipv6`;
|
|
1205
|
-
});
|
|
1206
|
-
inst._zod.check = (payload) => {
|
|
1207
|
-
try {
|
|
1208
|
-
new URL(`http://[${payload.value}]`);
|
|
1209
|
-
} catch {
|
|
1210
|
-
payload.issues.push({
|
|
1211
|
-
code: "invalid_format",
|
|
1212
|
-
format: "ipv6",
|
|
1213
|
-
input: payload.value,
|
|
1214
|
-
inst,
|
|
1215
|
-
continue: !def.abort
|
|
1216
|
-
});
|
|
1217
|
-
}
|
|
1218
|
-
};
|
|
1219
|
-
});
|
|
1220
|
-
const $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
1221
|
-
def.pattern ?? (def.pattern = cidrv4);
|
|
1222
|
-
$ZodStringFormat.init(inst, def);
|
|
1223
|
-
});
|
|
1224
|
-
const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
1225
|
-
def.pattern ?? (def.pattern = cidrv6);
|
|
1226
|
-
$ZodStringFormat.init(inst, def);
|
|
1227
|
-
inst._zod.check = (payload) => {
|
|
1228
|
-
const [address, prefix] = payload.value.split("/");
|
|
1229
|
-
try {
|
|
1230
|
-
if (!prefix) throw new Error();
|
|
1231
|
-
const prefixNum = Number(prefix);
|
|
1232
|
-
if (`${prefixNum}` !== prefix) throw new Error();
|
|
1233
|
-
if (prefixNum < 0 || prefixNum > 128) throw new Error();
|
|
1234
|
-
new URL(`http://[${address}]`);
|
|
1235
|
-
} catch {
|
|
1236
|
-
payload.issues.push({
|
|
1237
|
-
code: "invalid_format",
|
|
1238
|
-
format: "cidrv6",
|
|
1239
|
-
input: payload.value,
|
|
1240
|
-
inst,
|
|
1241
|
-
continue: !def.abort
|
|
1242
|
-
});
|
|
1243
|
-
}
|
|
1244
|
-
};
|
|
1245
|
-
});
|
|
1246
|
-
function isValidBase64(data) {
|
|
1247
|
-
if (data === "") return true;
|
|
1248
|
-
if (data.length % 4 !== 0) return false;
|
|
1249
|
-
try {
|
|
1250
|
-
atob(data);
|
|
1251
|
-
return true;
|
|
1252
|
-
} catch {
|
|
1253
|
-
return false;
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
1257
|
-
def.pattern ?? (def.pattern = base64);
|
|
1258
|
-
$ZodStringFormat.init(inst, def);
|
|
1259
|
-
inst._zod.onattach.push((inst$1) => {
|
|
1260
|
-
inst$1._zod.bag.contentEncoding = "base64";
|
|
1261
|
-
});
|
|
1262
|
-
inst._zod.check = (payload) => {
|
|
1263
|
-
if (isValidBase64(payload.value)) return;
|
|
1264
|
-
payload.issues.push({
|
|
1265
|
-
code: "invalid_format",
|
|
1266
|
-
format: "base64",
|
|
1267
|
-
input: payload.value,
|
|
1268
|
-
inst,
|
|
1269
|
-
continue: !def.abort
|
|
1270
|
-
});
|
|
1271
|
-
};
|
|
1272
|
-
});
|
|
1273
|
-
function isValidBase64URL(data) {
|
|
1274
|
-
if (!base64url.test(data)) return false;
|
|
1275
|
-
const base64$1 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
1276
|
-
const padded = base64$1.padEnd(Math.ceil(base64$1.length / 4) * 4, "=");
|
|
1277
|
-
return isValidBase64(padded);
|
|
1278
|
-
}
|
|
1279
|
-
const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1280
|
-
def.pattern ?? (def.pattern = base64url);
|
|
1281
|
-
$ZodStringFormat.init(inst, def);
|
|
1282
|
-
inst._zod.onattach.push((inst$1) => {
|
|
1283
|
-
inst$1._zod.bag.contentEncoding = "base64url";
|
|
1284
|
-
});
|
|
1285
|
-
inst._zod.check = (payload) => {
|
|
1286
|
-
if (isValidBase64URL(payload.value)) return;
|
|
1287
|
-
payload.issues.push({
|
|
1288
|
-
code: "invalid_format",
|
|
1289
|
-
format: "base64url",
|
|
1290
|
-
input: payload.value,
|
|
1291
|
-
inst,
|
|
1292
|
-
continue: !def.abort
|
|
1293
|
-
});
|
|
1294
|
-
};
|
|
1295
|
-
});
|
|
1296
|
-
const $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
|
|
1297
|
-
def.pattern ?? (def.pattern = e164);
|
|
1298
|
-
$ZodStringFormat.init(inst, def);
|
|
1299
|
-
});
|
|
1300
|
-
function isValidJWT(token, algorithm = null) {
|
|
1301
|
-
try {
|
|
1302
|
-
const tokensParts = token.split(".");
|
|
1303
|
-
if (tokensParts.length !== 3) return false;
|
|
1304
|
-
const [header] = tokensParts;
|
|
1305
|
-
if (!header) return false;
|
|
1306
|
-
const parsedHeader = JSON.parse(atob(header));
|
|
1307
|
-
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
|
|
1308
|
-
if (!parsedHeader.alg) return false;
|
|
1309
|
-
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
|
|
1310
|
-
return true;
|
|
1311
|
-
} catch {
|
|
1312
|
-
return false;
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
1316
|
-
$ZodStringFormat.init(inst, def);
|
|
1317
|
-
inst._zod.check = (payload) => {
|
|
1318
|
-
if (isValidJWT(payload.value, def.alg)) return;
|
|
1319
|
-
payload.issues.push({
|
|
1320
|
-
code: "invalid_format",
|
|
1321
|
-
format: "jwt",
|
|
1322
|
-
input: payload.value,
|
|
1323
|
-
inst,
|
|
1324
|
-
continue: !def.abort
|
|
1325
|
-
});
|
|
1326
|
-
};
|
|
1327
|
-
});
|
|
1328
|
-
const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
1329
|
-
$ZodType.init(inst, def);
|
|
1330
|
-
inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
|
|
1331
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1332
|
-
if (def.coerce) try {
|
|
1333
|
-
payload.value = Number(payload.value);
|
|
1334
|
-
} catch (_) {}
|
|
1335
|
-
const input = payload.value;
|
|
1336
|
-
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
|
|
1337
|
-
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
|
|
1338
|
-
payload.issues.push({
|
|
1339
|
-
expected: "number",
|
|
1340
|
-
code: "invalid_type",
|
|
1341
|
-
input,
|
|
1342
|
-
inst,
|
|
1343
|
-
...received ? { received } : {}
|
|
1344
|
-
});
|
|
1345
|
-
return payload;
|
|
1346
|
-
};
|
|
1347
|
-
});
|
|
1348
|
-
const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
1349
|
-
$ZodCheckNumberFormat.init(inst, def);
|
|
1350
|
-
$ZodNumber.init(inst, def);
|
|
1351
|
-
});
|
|
1352
|
-
const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
1353
|
-
$ZodType.init(inst, def);
|
|
1354
|
-
inst._zod.pattern = boolean$1;
|
|
1355
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1356
|
-
if (def.coerce) try {
|
|
1357
|
-
payload.value = Boolean(payload.value);
|
|
1358
|
-
} catch (_) {}
|
|
1359
|
-
const input = payload.value;
|
|
1360
|
-
if (typeof input === "boolean") return payload;
|
|
1361
|
-
payload.issues.push({
|
|
1362
|
-
expected: "boolean",
|
|
1363
|
-
code: "invalid_type",
|
|
1364
|
-
input,
|
|
1365
|
-
inst
|
|
1366
|
-
});
|
|
1367
|
-
return payload;
|
|
1368
|
-
};
|
|
1369
|
-
});
|
|
1370
|
-
const $ZodAny = /* @__PURE__ */ $constructor("$ZodAny", (inst, def) => {
|
|
1371
|
-
$ZodType.init(inst, def);
|
|
1372
|
-
inst._zod.parse = (payload) => payload;
|
|
1373
|
-
});
|
|
1374
|
-
const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
1375
|
-
$ZodType.init(inst, def);
|
|
1376
|
-
inst._zod.parse = (payload) => payload;
|
|
1377
|
-
});
|
|
1378
|
-
const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
1379
|
-
$ZodType.init(inst, def);
|
|
1380
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1381
|
-
payload.issues.push({
|
|
1382
|
-
expected: "never",
|
|
1383
|
-
code: "invalid_type",
|
|
1384
|
-
input: payload.value,
|
|
1385
|
-
inst
|
|
1386
|
-
});
|
|
1387
|
-
return payload;
|
|
1388
|
-
};
|
|
1389
|
-
});
|
|
1390
|
-
function handleArrayResult(result, final, index) {
|
|
1391
|
-
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
1392
|
-
final.value[index] = result.value;
|
|
1393
|
-
}
|
|
1394
|
-
const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
1395
|
-
$ZodType.init(inst, def);
|
|
1396
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1397
|
-
const input = payload.value;
|
|
1398
|
-
if (!Array.isArray(input)) {
|
|
1399
|
-
payload.issues.push({
|
|
1400
|
-
expected: "array",
|
|
1401
|
-
code: "invalid_type",
|
|
1402
|
-
input,
|
|
1403
|
-
inst
|
|
1404
|
-
});
|
|
1405
|
-
return payload;
|
|
1406
|
-
}
|
|
1407
|
-
payload.value = Array(input.length);
|
|
1408
|
-
const proms = [];
|
|
1409
|
-
for (let i = 0; i < input.length; i++) {
|
|
1410
|
-
const item = input[i];
|
|
1411
|
-
const result = def.element._zod.run({
|
|
1412
|
-
value: item,
|
|
1413
|
-
issues: []
|
|
1414
|
-
}, ctx);
|
|
1415
|
-
if (result instanceof Promise) proms.push(result.then((result$1) => handleArrayResult(result$1, payload, i)));
|
|
1416
|
-
else handleArrayResult(result, payload, i);
|
|
1417
|
-
}
|
|
1418
|
-
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
1419
|
-
return payload;
|
|
1420
|
-
};
|
|
1421
|
-
});
|
|
1422
|
-
function handleObjectResult(result, final, key) {
|
|
1423
|
-
if (result.issues.length) final.issues.push(...prefixIssues(key, result.issues));
|
|
1424
|
-
final.value[key] = result.value;
|
|
1425
|
-
}
|
|
1426
|
-
function handleOptionalObjectResult(result, final, key, input) {
|
|
1427
|
-
if (result.issues.length) if (input[key] === void 0) if (key in input) final.value[key] = void 0;
|
|
1428
|
-
else final.value[key] = result.value;
|
|
1429
|
-
else final.issues.push(...prefixIssues(key, result.issues));
|
|
1430
|
-
else if (result.value === void 0) {
|
|
1431
|
-
if (key in input) final.value[key] = void 0;
|
|
1432
|
-
} else final.value[key] = result.value;
|
|
1433
|
-
}
|
|
1434
|
-
const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
1435
|
-
$ZodType.init(inst, def);
|
|
1436
|
-
const _normalized = cached(() => {
|
|
1437
|
-
const keys = Object.keys(def.shape);
|
|
1438
|
-
for (const k of keys) if (!(def.shape[k] instanceof $ZodType)) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
1439
|
-
const okeys = optionalKeys(def.shape);
|
|
1440
|
-
return {
|
|
1441
|
-
shape: def.shape,
|
|
1442
|
-
keys,
|
|
1443
|
-
keySet: new Set(keys),
|
|
1444
|
-
numKeys: keys.length,
|
|
1445
|
-
optionalKeys: new Set(okeys)
|
|
1446
|
-
};
|
|
1447
|
-
});
|
|
1448
|
-
defineLazy(inst._zod, "propValues", () => {
|
|
1449
|
-
const shape = def.shape;
|
|
1450
|
-
const propValues = {};
|
|
1451
|
-
for (const key in shape) {
|
|
1452
|
-
const field = shape[key]._zod;
|
|
1453
|
-
if (field.values) {
|
|
1454
|
-
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
1455
|
-
for (const v of field.values) propValues[key].add(v);
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
return propValues;
|
|
1459
|
-
});
|
|
1460
|
-
const generateFastpass = (shape) => {
|
|
1461
|
-
const doc = new Doc([
|
|
1462
|
-
"shape",
|
|
1463
|
-
"payload",
|
|
1464
|
-
"ctx"
|
|
1465
|
-
]);
|
|
1466
|
-
const normalized = _normalized.value;
|
|
1467
|
-
const parseStr = (key) => {
|
|
1468
|
-
const k = esc(key);
|
|
1469
|
-
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
1470
|
-
};
|
|
1471
|
-
doc.write(`const input = payload.value;`);
|
|
1472
|
-
const ids = Object.create(null);
|
|
1473
|
-
let counter = 0;
|
|
1474
|
-
for (const key of normalized.keys) ids[key] = `key_${counter++}`;
|
|
1475
|
-
doc.write(`const newResult = {}`);
|
|
1476
|
-
for (const key of normalized.keys) if (normalized.optionalKeys.has(key)) {
|
|
1477
|
-
const id = ids[key];
|
|
1478
|
-
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1479
|
-
const k = esc(key);
|
|
1480
|
-
doc.write(`
|
|
1481
|
-
if (${id}.issues.length) {
|
|
1482
|
-
if (input[${k}] === undefined) {
|
|
1483
|
-
if (${k} in input) {
|
|
1484
|
-
newResult[${k}] = undefined;
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=s(require(`@stackone/transport`)),l=s(require(`path-to-regexp`)),u=s(require(`@stackone/core`)),d=s(require(`@stackone/utils`)),f=s(require(`yaml`)),p=s(require(`@stackone/expressions`)),m=async({inputs:e,context:t,operation:n,credentials:r,nextCursor:i,logger:a,getHttpClient:o=async()=>c.HttpClientManager.getInstance()})=>{let s=await o();return{inputs:e,fieldConfigs:[],context:t,operation:n,credentials:r,nextCursor:i,httpClient:s,logger:a}},ee=(e,t,n)=>{let r=n.toUpperCase();if(!e.operations)return;let i=Object.keys(e.operations),a=te(t,r,i);if(a)return{operation:e.operations?.[a.path],params:a.params}},h=e=>{let t=e.startsWith(`/`)?e.slice(1):e,n=t.endsWith(`/`)?t.slice(0,-1):t;return n},te=(e,t,n)=>{let r=h(e);for(let e of n)if(e.startsWith(t)){let n=e.replace(`${t} `,``).trim(),i=(0,l.match)(h(n)),a=i(h(r));if(a!==!1)return{path:e,params:a.params}}},ne=Object.freeze({status:`aborted`});function g(e,t,n){function r(n,r){var i;for(let a in Object.defineProperty(n,`_zod`,{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r),o.prototype)a in n||Object.defineProperty(n,a,{value:o.prototype[a].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}const re=Symbol(`zod_brand`);var _=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};const ie={};function v(e){return e&&Object.assign(ie,e),ie}function ae(e){let t=Object.values(e).filter(e=>typeof e==`number`),n=Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t);return n}function y(e,t){return typeof t==`bigint`?t.toString():t}function b(e){let t=!1;return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}}}}function x(e){return e==null}function S(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function oe(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r,a=Number.parseInt(e.toFixed(i).replace(`.`,``)),o=Number.parseInt(t.toFixed(i).replace(`.`,``));return a%o/10**i}function C(e,t,n){let r=!1;Object.defineProperty(e,t,{get(){{let r=n();return e[t]=r,r}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function se(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function w(e){return JSON.stringify(e)}const ce=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function T(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const le=b(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{let e=Function;return new e(``),!0}catch{return!1}});function E(e){if(T(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(T(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}const ue=new Set([`string`,`number`,`symbol`]);function D(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function O(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function k(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function de(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const fe={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function pe(e,t){let n={},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);if(!t[e])continue;n[e]=r.shape[e]}return O(e,{...e._zod.def,shape:n,checks:[]})}function me(e,t){let n={...e._zod.def.shape},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);if(!t[e])continue;delete n[e]}return O(e,{...e._zod.def,shape:n,checks:[]})}function he(e,t){if(!E(t))throw Error(`Invalid input to extend: expected a plain object`);let n={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return se(this,`shape`,n),n},checks:[]};return O(e,n)}function ge(e,t){return O(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return se(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function _e(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);if(!n[t])continue;i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t]}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return O(t,{...t._zod.def,shape:i,checks:[]})}function ve(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);if(!n[t])continue;i[t]=new e({type:`nonoptional`,innerType:r[t]})}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return O(t,{...t._zod.def,shape:i,checks:[]})}function A(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function j(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ye(e){return typeof e==`string`?e:e?.message}function M(e,t,n){let r={...e,path:e.path??[]};if(!e.message){let i=ye(e.inst?._zod.def?.error?.(e))??ye(t?.error?.(e))??ye(n.customError?.(e))??ye(n.localeError?.(e))??`Invalid input`;r.message=i}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function be(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function N(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const xe=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),Object.defineProperty(e,`message`,{get(){return JSON.stringify(t,y,2)},enumerable:!0})},Se=g(`$ZodError`,xe),P=g(`$ZodError`,xe,{Parent:Error});function Ce(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function we(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i],a=i===t.path.length-1;a?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}const Te=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new _;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>M(e,a,v())));throw ce(t,i?.callee),t}return o.value},Ee=Te(P),De=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>M(e,a,v())));throw ce(t,i?.callee),t}return o.value},Oe=De(P),ke=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new _;return a.issues.length?{success:!1,error:new(e??Se)(a.issues.map(e=>M(e,i,v())))}:{success:!0,data:a.value}},Ae=ke(P),je=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>M(e,i,v())))}:{success:!0,data:a.value}},Me=je(P),Ne=/^[cC][^\s-]{8,}$/,Pe=/^[0-9a-z]+$/,Fe=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ie=/^[0-9a-vA-V]{20}$/,Le=/^[A-Za-z0-9]{27}$/,Re=/^[a-zA-Z0-9_-]{21}$/,ze=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Be=/^([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})$/,Ve=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([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)$/,He=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ue=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function We(){return new RegExp(Ue,`u`)}const Ge=/^(?:(?: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])$/,Ke=/^(([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})$/,qe=/^((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])$/,Je=/^(([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])$/,Ye=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Xe=/^[A-Za-z0-9_-]*$/,Ze=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Qe=/^\+(?:[0-9]){6,14}[0-9]$/,$e=`(?:(?:\\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])))`,et=RegExp(`^${$e}$`);function tt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`,n=typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;return n}function nt(e){return RegExp(`^${tt(e)}$`)}function rt(e){let t=tt({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${$e}T(?:${r})$`)}const it=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},at=/^\d+$/,ot=/^-?\d+(?:\.\d+)?/i,st=/true|false/i,ct=/^[^A-Z]*$/,lt=/^[^a-z]*$/,F=g(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ut={number:`number`,bigint:`bigint`,object:`date`},dt=g(`$ZodCheckLessThan`,(e,t)=>{F.init(e,t);let n=ut[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ft=g(`$ZodCheckGreaterThan`,(e,t)=>{F.init(e,t);let n=ut[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),pt=g(`$ZodCheckMultipleOf`,(e,t)=>{F.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);let r=typeof n.value==`bigint`?n.value%t.value===BigInt(0):oe(n.value,t.value)===0;r||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),mt=g(`$ZodCheckNumberFormat`,(e,t)=>{F.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=fe[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=at)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),ht=g(`$ZodCheckMaxLength`,(e,t)=>{F.init(e,t),e._zod.when=e=>{let t=e.value;return!x(t)&&t.length!==void 0},e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value,i=r.length;if(i<=t.maximum)return;let a=be(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gt=g(`$ZodCheckMinLength`,(e,t)=>{F.init(e,t),e._zod.when=e=>{let t=e.value;return!x(t)&&t.length!==void 0},e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value,i=r.length;if(i>=t.minimum)return;let a=be(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),_t=g(`$ZodCheckLengthEquals`,(e,t)=>{F.init(e,t),e._zod.when=e=>{let t=e.value;return!x(t)&&t.length!==void 0},e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=be(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),vt=g(`$ZodCheckStringFormat`,(e,t)=>{var n,r;F.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),yt=g(`$ZodCheckRegex`,(e,t)=>{vt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),bt=g(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ct,vt.init(e,t)}),xt=g(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=lt,vt.init(e,t)}),St=g(`$ZodCheckIncludes`,(e,t)=>{F.init(e,t);let n=D(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ct=g(`$ZodCheckStartsWith`,(e,t)=>{F.init(e,t);let n=RegExp(`^${D(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),wt=g(`$ZodCheckEndsWith`,(e,t)=>{F.init(e,t);let n=RegExp(`.*${D(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Tt=g(`$ZodCheckOverwrite`,(e,t)=>{F.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Et=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e,n=t.split(`
|
|
2
|
+
`).filter(e=>e),r=Math.min(...n.map(e=>e.length-e.trimStart().length)),i=n.map(e=>e.slice(r)).map(e=>` `.repeat(this.indent*2)+e);for(let e of i)this.content.push(e)}compile(){let e=Function,t=this?.args,n=this?.content??[``],r=[...n.map(e=>` ${e}`)];return new e(...t,r.join(`
|
|
3
|
+
`))}};const Dt={major:4,minor:0,patch:0},I=g(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Dt;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=A(e),i;for(let a of t){if(a._zod.when){let t=a._zod.when(e);if(!t)continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new _;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o;let n=e.issues.length;n!==t&&(r||=A(e,t))});else{let n=e.issues.length;if(n===t)continue;r||=A(e,t)}}return i?i.then(()=>e):e};e._zod.run=(n,i)=>{let a=e._zod.parse(n,i);if(a instanceof Promise){if(i.async===!1)throw new _;return a.then(e=>t(e,r,i))}return t(a,r,i)}}e[`~standard`]={validate:t=>{try{let n=Ae(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Me(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Ot=g(`$ZodString`,(e,t)=>{I.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??it(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),L=g(`$ZodStringFormat`,(e,t)=>{vt.init(e,t),Ot.init(e,t)}),kt=g(`$ZodGUID`,(e,t)=>{t.pattern??=Be,L.init(e,t)}),At=g(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8},n=e[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Ve(n)}else t.pattern??=Ve();L.init(e,t)}),jt=g(`$ZodEmail`,(e,t)=>{t.pattern??=He,L.init(e,t)}),Mt=g(`$ZodURL`,(e,t)=>{L.init(e,t),e._zod.check=n=>{try{let r=n.value,i=new URL(r),a=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:Ze.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),!r.endsWith(`/`)&&a.endsWith(`/`)?n.value=a.slice(0,-1):n.value=a;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Nt=g(`$ZodEmoji`,(e,t)=>{t.pattern??=We(),L.init(e,t)}),Pt=g(`$ZodNanoID`,(e,t)=>{t.pattern??=Re,L.init(e,t)}),Ft=g(`$ZodCUID`,(e,t)=>{t.pattern??=Ne,L.init(e,t)}),It=g(`$ZodCUID2`,(e,t)=>{t.pattern??=Pe,L.init(e,t)}),Lt=g(`$ZodULID`,(e,t)=>{t.pattern??=Fe,L.init(e,t)}),Rt=g(`$ZodXID`,(e,t)=>{t.pattern??=Ie,L.init(e,t)}),zt=g(`$ZodKSUID`,(e,t)=>{t.pattern??=Le,L.init(e,t)}),Bt=g(`$ZodISODateTime`,(e,t)=>{t.pattern??=rt(t),L.init(e,t)}),Vt=g(`$ZodISODate`,(e,t)=>{t.pattern??=et,L.init(e,t)}),Ht=g(`$ZodISOTime`,(e,t)=>{t.pattern??=nt(t),L.init(e,t)}),Ut=g(`$ZodISODuration`,(e,t)=>{t.pattern??=ze,L.init(e,t)}),Wt=g(`$ZodIPv4`,(e,t)=>{t.pattern??=Ge,L.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),Gt=g(`$ZodIPv6`,(e,t)=>{t.pattern??=Ke,L.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Kt=g(`$ZodCIDRv4`,(e,t)=>{t.pattern??=qe,L.init(e,t)}),qt=g(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Je,L.init(e,t),e._zod.check=n=>{let[r,i]=n.value.split(`/`);try{if(!i)throw Error();let e=Number(i);if(`${e}`!==i||e<0||e>128)throw Error();new URL(`http://[${r}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Jt(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Yt=g(`$ZodBase64`,(e,t)=>{t.pattern??=Ye,L.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{Jt(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Xt(e){if(!Xe.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`),n=t.padEnd(Math.ceil(t.length/4)*4,`=`);return Jt(n)}const Zt=g(`$ZodBase64URL`,(e,t)=>{t.pattern??=Xe,L.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{Xt(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Qt=g(`$ZodE164`,(e,t)=>{t.pattern??=Qe,L.init(e,t)});function $t(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const en=g(`$ZodJWT`,(e,t)=>{L.init(e,t),e._zod.check=n=>{$t(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),tn=g(`$ZodNumber`,(e,t)=>{I.init(e,t),e._zod.pattern=e._zod.bag.pattern??ot,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),nn=g(`$ZodNumber`,(e,t)=>{mt.init(e,t),tn.init(e,t)}),rn=g(`$ZodBoolean`,(e,t)=>{I.init(e,t),e._zod.pattern=st,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),an=g(`$ZodAny`,(e,t)=>{I.init(e,t),e._zod.parse=e=>e}),on=g(`$ZodUnknown`,(e,t)=>{I.init(e,t),e._zod.parse=e=>e}),sn=g(`$ZodNever`,(e,t)=>{I.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function cn(e,t,n){e.issues.length&&t.issues.push(...j(n,e.issues)),t.value[n]=e.value}const ln=g(`$ZodArray`,(e,t)=>{I.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>cn(t,n,e))):cn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function R(e,t,n){e.issues.length&&t.issues.push(...j(n,e.issues)),t.value[n]=e.value}function un(e,t,n,r){e.issues.length?r[n]===void 0?n in r?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...j(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}const dn=g(`$ZodObject`,(e,t)=>{I.init(e,t);let n=b(()=>{let e=Object.keys(t.shape);for(let n of e)if(!(t.shape[n]instanceof I))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=de(t.shape);return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}});C(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=e=>{let t=new Et([`shape`,`payload`,`ctx`]),r=n.value,i=e=>{let t=w(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of r.keys)a[e]=`key_${o++}`;t.write(`const newResult = {}`);for(let e of r.keys)if(r.optionalKeys.has(e)){let n=a[e];t.write(`const ${n} = ${i(e)};`);let r=w(e);t.write(`
|
|
4
|
+
if (${n}.issues.length) {
|
|
5
|
+
if (input[${r}] === undefined) {
|
|
6
|
+
if (${r} in input) {
|
|
7
|
+
newResult[${r}] = undefined;
|
|
1485
8
|
}
|
|
1486
9
|
} else {
|
|
1487
10
|
payload.issues = payload.issues.concat(
|
|
1488
|
-
${
|
|
11
|
+
${n}.issues.map((iss) => ({
|
|
1489
12
|
...iss,
|
|
1490
|
-
path: iss.path ? [${
|
|
13
|
+
path: iss.path ? [${r}, ...iss.path] : [${r}],
|
|
1491
14
|
}))
|
|
1492
15
|
);
|
|
1493
16
|
}
|
|
1494
|
-
} else if (${
|
|
1495
|
-
if (${
|
|
17
|
+
} else if (${n}.value === undefined) {
|
|
18
|
+
if (${r} in input) newResult[${r}] = undefined;
|
|
1496
19
|
} else {
|
|
1497
|
-
newResult[${
|
|
20
|
+
newResult[${r}] = ${n}.value;
|
|
1498
21
|
}
|
|
1499
|
-
`);
|
|
1500
|
-
|
|
1501
|
-
const id = ids[key];
|
|
1502
|
-
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1503
|
-
doc.write(`
|
|
1504
|
-
if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
22
|
+
`)}else{let n=a[e];t.write(`const ${n} = ${i(e)};`),t.write(`
|
|
23
|
+
if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
1505
24
|
...iss,
|
|
1506
|
-
path: iss.path ? [${
|
|
1507
|
-
})));`);
|
|
1508
|
-
|
|
1509
|
-
}
|
|
1510
|
-
doc.write(`payload.value = newResult;`);
|
|
1511
|
-
doc.write(`return payload;`);
|
|
1512
|
-
const fn = doc.compile();
|
|
1513
|
-
return (payload, ctx) => fn(shape, payload, ctx);
|
|
1514
|
-
};
|
|
1515
|
-
let fastpass;
|
|
1516
|
-
const isObject$4 = isObject$3;
|
|
1517
|
-
const jit = !globalConfig.jitless;
|
|
1518
|
-
const allowsEval$1 = allowsEval;
|
|
1519
|
-
const fastEnabled = jit && allowsEval$1.value;
|
|
1520
|
-
const catchall = def.catchall;
|
|
1521
|
-
let value;
|
|
1522
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1523
|
-
value ?? (value = _normalized.value);
|
|
1524
|
-
const input = payload.value;
|
|
1525
|
-
if (!isObject$4(input)) {
|
|
1526
|
-
payload.issues.push({
|
|
1527
|
-
expected: "object",
|
|
1528
|
-
code: "invalid_type",
|
|
1529
|
-
input,
|
|
1530
|
-
inst
|
|
1531
|
-
});
|
|
1532
|
-
return payload;
|
|
1533
|
-
}
|
|
1534
|
-
const proms = [];
|
|
1535
|
-
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
1536
|
-
if (!fastpass) fastpass = generateFastpass(def.shape);
|
|
1537
|
-
payload = fastpass(payload, ctx);
|
|
1538
|
-
} else {
|
|
1539
|
-
payload.value = {};
|
|
1540
|
-
const shape = value.shape;
|
|
1541
|
-
for (const key of value.keys) {
|
|
1542
|
-
const el = shape[key];
|
|
1543
|
-
const r = el._zod.run({
|
|
1544
|
-
value: input[key],
|
|
1545
|
-
issues: []
|
|
1546
|
-
}, ctx);
|
|
1547
|
-
const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
|
|
1548
|
-
if (r instanceof Promise) proms.push(r.then((r$1) => isOptional ? handleOptionalObjectResult(r$1, payload, key, input) : handleObjectResult(r$1, payload, key)));
|
|
1549
|
-
else if (isOptional) handleOptionalObjectResult(r, payload, key, input);
|
|
1550
|
-
else handleObjectResult(r, payload, key);
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1554
|
-
const unrecognized = [];
|
|
1555
|
-
const keySet = value.keySet;
|
|
1556
|
-
const _catchall = catchall._zod;
|
|
1557
|
-
const t = _catchall.def.type;
|
|
1558
|
-
for (const key of Object.keys(input)) {
|
|
1559
|
-
if (keySet.has(key)) continue;
|
|
1560
|
-
if (t === "never") {
|
|
1561
|
-
unrecognized.push(key);
|
|
1562
|
-
continue;
|
|
1563
|
-
}
|
|
1564
|
-
const r = _catchall.run({
|
|
1565
|
-
value: input[key],
|
|
1566
|
-
issues: []
|
|
1567
|
-
}, ctx);
|
|
1568
|
-
if (r instanceof Promise) proms.push(r.then((r$1) => handleObjectResult(r$1, payload, key)));
|
|
1569
|
-
else handleObjectResult(r, payload, key);
|
|
1570
|
-
}
|
|
1571
|
-
if (unrecognized.length) payload.issues.push({
|
|
1572
|
-
code: "unrecognized_keys",
|
|
1573
|
-
keys: unrecognized,
|
|
1574
|
-
input,
|
|
1575
|
-
inst
|
|
1576
|
-
});
|
|
1577
|
-
if (!proms.length) return payload;
|
|
1578
|
-
return Promise.all(proms).then(() => {
|
|
1579
|
-
return payload;
|
|
1580
|
-
});
|
|
1581
|
-
};
|
|
1582
|
-
});
|
|
1583
|
-
function handleUnionResults(results, final, inst, ctx) {
|
|
1584
|
-
for (const result of results) if (result.issues.length === 0) {
|
|
1585
|
-
final.value = result.value;
|
|
1586
|
-
return final;
|
|
1587
|
-
}
|
|
1588
|
-
final.issues.push({
|
|
1589
|
-
code: "invalid_union",
|
|
1590
|
-
input: final.value,
|
|
1591
|
-
inst,
|
|
1592
|
-
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
1593
|
-
});
|
|
1594
|
-
return final;
|
|
1595
|
-
}
|
|
1596
|
-
const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
1597
|
-
$ZodType.init(inst, def);
|
|
1598
|
-
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
|
|
1599
|
-
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
1600
|
-
defineLazy(inst._zod, "values", () => {
|
|
1601
|
-
if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
1602
|
-
return void 0;
|
|
1603
|
-
});
|
|
1604
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
1605
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
1606
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
1607
|
-
return /* @__PURE__ */ new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
1608
|
-
}
|
|
1609
|
-
return void 0;
|
|
1610
|
-
});
|
|
1611
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1612
|
-
let async = false;
|
|
1613
|
-
const results = [];
|
|
1614
|
-
for (const option of def.options) {
|
|
1615
|
-
const result = option._zod.run({
|
|
1616
|
-
value: payload.value,
|
|
1617
|
-
issues: []
|
|
1618
|
-
}, ctx);
|
|
1619
|
-
if (result instanceof Promise) {
|
|
1620
|
-
results.push(result);
|
|
1621
|
-
async = true;
|
|
1622
|
-
} else {
|
|
1623
|
-
if (result.issues.length === 0) return result;
|
|
1624
|
-
results.push(result);
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
if (!async) return handleUnionResults(results, payload, inst, ctx);
|
|
1628
|
-
return Promise.all(results).then((results$1) => {
|
|
1629
|
-
return handleUnionResults(results$1, payload, inst, ctx);
|
|
1630
|
-
});
|
|
1631
|
-
};
|
|
1632
|
-
});
|
|
1633
|
-
const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
1634
|
-
$ZodUnion.init(inst, def);
|
|
1635
|
-
const _super = inst._zod.parse;
|
|
1636
|
-
defineLazy(inst._zod, "propValues", () => {
|
|
1637
|
-
const propValues = {};
|
|
1638
|
-
for (const option of def.options) {
|
|
1639
|
-
const pv = option._zod.propValues;
|
|
1640
|
-
if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
1641
|
-
for (const [k, v] of Object.entries(pv)) {
|
|
1642
|
-
if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
|
|
1643
|
-
for (const val of v) propValues[k].add(val);
|
|
1644
|
-
}
|
|
1645
|
-
}
|
|
1646
|
-
return propValues;
|
|
1647
|
-
});
|
|
1648
|
-
const disc = cached(() => {
|
|
1649
|
-
const opts = def.options;
|
|
1650
|
-
const map = /* @__PURE__ */ new Map();
|
|
1651
|
-
for (const o of opts) {
|
|
1652
|
-
const values = o._zod.propValues[def.discriminator];
|
|
1653
|
-
if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
1654
|
-
for (const v of values) {
|
|
1655
|
-
if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
1656
|
-
map.set(v, o);
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1659
|
-
return map;
|
|
1660
|
-
});
|
|
1661
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1662
|
-
const input = payload.value;
|
|
1663
|
-
if (!isObject$3(input)) {
|
|
1664
|
-
payload.issues.push({
|
|
1665
|
-
code: "invalid_type",
|
|
1666
|
-
expected: "object",
|
|
1667
|
-
input,
|
|
1668
|
-
inst
|
|
1669
|
-
});
|
|
1670
|
-
return payload;
|
|
1671
|
-
}
|
|
1672
|
-
const opt = disc.value.get(input?.[def.discriminator]);
|
|
1673
|
-
if (opt) return opt._zod.run(payload, ctx);
|
|
1674
|
-
if (def.unionFallback) return _super(payload, ctx);
|
|
1675
|
-
payload.issues.push({
|
|
1676
|
-
code: "invalid_union",
|
|
1677
|
-
errors: [],
|
|
1678
|
-
note: "No matching discriminator",
|
|
1679
|
-
input,
|
|
1680
|
-
path: [def.discriminator],
|
|
1681
|
-
inst
|
|
1682
|
-
});
|
|
1683
|
-
return payload;
|
|
1684
|
-
};
|
|
1685
|
-
});
|
|
1686
|
-
const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
1687
|
-
$ZodType.init(inst, def);
|
|
1688
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1689
|
-
const input = payload.value;
|
|
1690
|
-
const left = def.left._zod.run({
|
|
1691
|
-
value: input,
|
|
1692
|
-
issues: []
|
|
1693
|
-
}, ctx);
|
|
1694
|
-
const right = def.right._zod.run({
|
|
1695
|
-
value: input,
|
|
1696
|
-
issues: []
|
|
1697
|
-
}, ctx);
|
|
1698
|
-
const async = left instanceof Promise || right instanceof Promise;
|
|
1699
|
-
if (async) return Promise.all([left, right]).then(([left$1, right$1]) => {
|
|
1700
|
-
return handleIntersectionResults(payload, left$1, right$1);
|
|
1701
|
-
});
|
|
1702
|
-
return handleIntersectionResults(payload, left, right);
|
|
1703
|
-
};
|
|
1704
|
-
});
|
|
1705
|
-
function mergeValues(a, b) {
|
|
1706
|
-
if (a === b) return {
|
|
1707
|
-
valid: true,
|
|
1708
|
-
data: a
|
|
1709
|
-
};
|
|
1710
|
-
if (a instanceof Date && b instanceof Date && +a === +b) return {
|
|
1711
|
-
valid: true,
|
|
1712
|
-
data: a
|
|
1713
|
-
};
|
|
1714
|
-
if (isPlainObject(a) && isPlainObject(b)) {
|
|
1715
|
-
const bKeys = Object.keys(b);
|
|
1716
|
-
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
1717
|
-
const newObj = {
|
|
1718
|
-
...a,
|
|
1719
|
-
...b
|
|
1720
|
-
};
|
|
1721
|
-
for (const key of sharedKeys) {
|
|
1722
|
-
const sharedValue = mergeValues(a[key], b[key]);
|
|
1723
|
-
if (!sharedValue.valid) return {
|
|
1724
|
-
valid: false,
|
|
1725
|
-
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
|
|
1726
|
-
};
|
|
1727
|
-
newObj[key] = sharedValue.data;
|
|
1728
|
-
}
|
|
1729
|
-
return {
|
|
1730
|
-
valid: true,
|
|
1731
|
-
data: newObj
|
|
1732
|
-
};
|
|
1733
|
-
}
|
|
1734
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
1735
|
-
if (a.length !== b.length) return {
|
|
1736
|
-
valid: false,
|
|
1737
|
-
mergeErrorPath: []
|
|
1738
|
-
};
|
|
1739
|
-
const newArray = [];
|
|
1740
|
-
for (let index = 0; index < a.length; index++) {
|
|
1741
|
-
const itemA = a[index];
|
|
1742
|
-
const itemB = b[index];
|
|
1743
|
-
const sharedValue = mergeValues(itemA, itemB);
|
|
1744
|
-
if (!sharedValue.valid) return {
|
|
1745
|
-
valid: false,
|
|
1746
|
-
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
1747
|
-
};
|
|
1748
|
-
newArray.push(sharedValue.data);
|
|
1749
|
-
}
|
|
1750
|
-
return {
|
|
1751
|
-
valid: true,
|
|
1752
|
-
data: newArray
|
|
1753
|
-
};
|
|
1754
|
-
}
|
|
1755
|
-
return {
|
|
1756
|
-
valid: false,
|
|
1757
|
-
mergeErrorPath: []
|
|
1758
|
-
};
|
|
1759
|
-
}
|
|
1760
|
-
function handleIntersectionResults(result, left, right) {
|
|
1761
|
-
if (left.issues.length) result.issues.push(...left.issues);
|
|
1762
|
-
if (right.issues.length) result.issues.push(...right.issues);
|
|
1763
|
-
if (aborted(result)) return result;
|
|
1764
|
-
const merged = mergeValues(left.value, right.value);
|
|
1765
|
-
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
1766
|
-
result.value = merged.data;
|
|
1767
|
-
return result;
|
|
1768
|
-
}
|
|
1769
|
-
const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
1770
|
-
$ZodType.init(inst, def);
|
|
1771
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1772
|
-
const input = payload.value;
|
|
1773
|
-
if (!isPlainObject(input)) {
|
|
1774
|
-
payload.issues.push({
|
|
1775
|
-
expected: "record",
|
|
1776
|
-
code: "invalid_type",
|
|
1777
|
-
input,
|
|
1778
|
-
inst
|
|
1779
|
-
});
|
|
1780
|
-
return payload;
|
|
1781
|
-
}
|
|
1782
|
-
const proms = [];
|
|
1783
|
-
if (def.keyType._zod.values) {
|
|
1784
|
-
const values = def.keyType._zod.values;
|
|
1785
|
-
payload.value = {};
|
|
1786
|
-
for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
1787
|
-
const result = def.valueType._zod.run({
|
|
1788
|
-
value: input[key],
|
|
1789
|
-
issues: []
|
|
1790
|
-
}, ctx);
|
|
1791
|
-
if (result instanceof Promise) proms.push(result.then((result$1) => {
|
|
1792
|
-
if (result$1.issues.length) payload.issues.push(...prefixIssues(key, result$1.issues));
|
|
1793
|
-
payload.value[key] = result$1.value;
|
|
1794
|
-
}));
|
|
1795
|
-
else {
|
|
1796
|
-
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
1797
|
-
payload.value[key] = result.value;
|
|
1798
|
-
}
|
|
1799
|
-
}
|
|
1800
|
-
let unrecognized;
|
|
1801
|
-
for (const key in input) if (!values.has(key)) {
|
|
1802
|
-
unrecognized = unrecognized ?? [];
|
|
1803
|
-
unrecognized.push(key);
|
|
1804
|
-
}
|
|
1805
|
-
if (unrecognized && unrecognized.length > 0) payload.issues.push({
|
|
1806
|
-
code: "unrecognized_keys",
|
|
1807
|
-
input,
|
|
1808
|
-
inst,
|
|
1809
|
-
keys: unrecognized
|
|
1810
|
-
});
|
|
1811
|
-
} else {
|
|
1812
|
-
payload.value = {};
|
|
1813
|
-
for (const key of Reflect.ownKeys(input)) {
|
|
1814
|
-
if (key === "__proto__") continue;
|
|
1815
|
-
const keyResult = def.keyType._zod.run({
|
|
1816
|
-
value: key,
|
|
1817
|
-
issues: []
|
|
1818
|
-
}, ctx);
|
|
1819
|
-
if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
|
|
1820
|
-
if (keyResult.issues.length) {
|
|
1821
|
-
payload.issues.push({
|
|
1822
|
-
origin: "record",
|
|
1823
|
-
code: "invalid_key",
|
|
1824
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
1825
|
-
input: key,
|
|
1826
|
-
path: [key],
|
|
1827
|
-
inst
|
|
1828
|
-
});
|
|
1829
|
-
payload.value[keyResult.value] = keyResult.value;
|
|
1830
|
-
continue;
|
|
1831
|
-
}
|
|
1832
|
-
const result = def.valueType._zod.run({
|
|
1833
|
-
value: input[key],
|
|
1834
|
-
issues: []
|
|
1835
|
-
}, ctx);
|
|
1836
|
-
if (result instanceof Promise) proms.push(result.then((result$1) => {
|
|
1837
|
-
if (result$1.issues.length) payload.issues.push(...prefixIssues(key, result$1.issues));
|
|
1838
|
-
payload.value[keyResult.value] = result$1.value;
|
|
1839
|
-
}));
|
|
1840
|
-
else {
|
|
1841
|
-
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
1842
|
-
payload.value[keyResult.value] = result.value;
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1845
|
-
}
|
|
1846
|
-
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
1847
|
-
return payload;
|
|
1848
|
-
};
|
|
1849
|
-
});
|
|
1850
|
-
const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
1851
|
-
$ZodType.init(inst, def);
|
|
1852
|
-
const values = getEnumValues(def.entries);
|
|
1853
|
-
inst._zod.values = new Set(values);
|
|
1854
|
-
inst._zod.pattern = /* @__PURE__ */ new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
1855
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1856
|
-
const input = payload.value;
|
|
1857
|
-
if (inst._zod.values.has(input)) return payload;
|
|
1858
|
-
payload.issues.push({
|
|
1859
|
-
code: "invalid_value",
|
|
1860
|
-
values,
|
|
1861
|
-
input,
|
|
1862
|
-
inst
|
|
1863
|
-
});
|
|
1864
|
-
return payload;
|
|
1865
|
-
};
|
|
1866
|
-
});
|
|
1867
|
-
const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
1868
|
-
$ZodType.init(inst, def);
|
|
1869
|
-
inst._zod.values = new Set(def.values);
|
|
1870
|
-
inst._zod.pattern = /* @__PURE__ */ new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? o.toString() : String(o)).join("|")})$`);
|
|
1871
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1872
|
-
const input = payload.value;
|
|
1873
|
-
if (inst._zod.values.has(input)) return payload;
|
|
1874
|
-
payload.issues.push({
|
|
1875
|
-
code: "invalid_value",
|
|
1876
|
-
values: def.values,
|
|
1877
|
-
input,
|
|
1878
|
-
inst
|
|
1879
|
-
});
|
|
1880
|
-
return payload;
|
|
1881
|
-
};
|
|
1882
|
-
});
|
|
1883
|
-
const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
1884
|
-
$ZodType.init(inst, def);
|
|
1885
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1886
|
-
const _out = def.transform(payload.value, payload);
|
|
1887
|
-
if (_ctx.async) {
|
|
1888
|
-
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
1889
|
-
return output.then((output$1) => {
|
|
1890
|
-
payload.value = output$1;
|
|
1891
|
-
return payload;
|
|
1892
|
-
});
|
|
1893
|
-
}
|
|
1894
|
-
if (_out instanceof Promise) throw new $ZodAsyncError();
|
|
1895
|
-
payload.value = _out;
|
|
1896
|
-
return payload;
|
|
1897
|
-
};
|
|
1898
|
-
});
|
|
1899
|
-
const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
1900
|
-
$ZodType.init(inst, def);
|
|
1901
|
-
inst._zod.optin = "optional";
|
|
1902
|
-
inst._zod.optout = "optional";
|
|
1903
|
-
defineLazy(inst._zod, "values", () => {
|
|
1904
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
1905
|
-
});
|
|
1906
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
1907
|
-
const pattern = def.innerType._zod.pattern;
|
|
1908
|
-
return pattern ? /* @__PURE__ */ new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
1909
|
-
});
|
|
1910
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1911
|
-
if (def.innerType._zod.optin === "optional") return def.innerType._zod.run(payload, ctx);
|
|
1912
|
-
if (payload.value === void 0) return payload;
|
|
1913
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1914
|
-
};
|
|
1915
|
-
});
|
|
1916
|
-
const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
1917
|
-
$ZodType.init(inst, def);
|
|
1918
|
-
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1919
|
-
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1920
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
1921
|
-
const pattern = def.innerType._zod.pattern;
|
|
1922
|
-
return pattern ? /* @__PURE__ */ new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
1923
|
-
});
|
|
1924
|
-
defineLazy(inst._zod, "values", () => {
|
|
1925
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
|
|
1926
|
-
});
|
|
1927
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1928
|
-
if (payload.value === null) return payload;
|
|
1929
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1930
|
-
};
|
|
1931
|
-
});
|
|
1932
|
-
const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
1933
|
-
$ZodType.init(inst, def);
|
|
1934
|
-
inst._zod.optin = "optional";
|
|
1935
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1936
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1937
|
-
if (payload.value === void 0) {
|
|
1938
|
-
payload.value = def.defaultValue;
|
|
1939
|
-
/**
|
|
1940
|
-
* $ZodDefault always returns the default value immediately.
|
|
1941
|
-
* 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. */
|
|
1942
|
-
return payload;
|
|
1943
|
-
}
|
|
1944
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1945
|
-
if (result instanceof Promise) return result.then((result$1) => handleDefaultResult(result$1, def));
|
|
1946
|
-
return handleDefaultResult(result, def);
|
|
1947
|
-
};
|
|
1948
|
-
});
|
|
1949
|
-
function handleDefaultResult(payload, def) {
|
|
1950
|
-
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
1951
|
-
return payload;
|
|
1952
|
-
}
|
|
1953
|
-
const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
1954
|
-
$ZodType.init(inst, def);
|
|
1955
|
-
inst._zod.optin = "optional";
|
|
1956
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1957
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1958
|
-
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
1959
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1960
|
-
};
|
|
1961
|
-
});
|
|
1962
|
-
const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
1963
|
-
$ZodType.init(inst, def);
|
|
1964
|
-
defineLazy(inst._zod, "values", () => {
|
|
1965
|
-
const v = def.innerType._zod.values;
|
|
1966
|
-
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
1967
|
-
});
|
|
1968
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1969
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1970
|
-
if (result instanceof Promise) return result.then((result$1) => handleNonOptionalResult(result$1, inst));
|
|
1971
|
-
return handleNonOptionalResult(result, inst);
|
|
1972
|
-
};
|
|
1973
|
-
});
|
|
1974
|
-
function handleNonOptionalResult(payload, inst) {
|
|
1975
|
-
if (!payload.issues.length && payload.value === void 0) payload.issues.push({
|
|
1976
|
-
code: "invalid_type",
|
|
1977
|
-
expected: "nonoptional",
|
|
1978
|
-
input: payload.value,
|
|
1979
|
-
inst
|
|
1980
|
-
});
|
|
1981
|
-
return payload;
|
|
1982
|
-
}
|
|
1983
|
-
const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
1984
|
-
$ZodType.init(inst, def);
|
|
1985
|
-
inst._zod.optin = "optional";
|
|
1986
|
-
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1987
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1988
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1989
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1990
|
-
if (result instanceof Promise) return result.then((result$1) => {
|
|
1991
|
-
payload.value = result$1.value;
|
|
1992
|
-
if (result$1.issues.length) {
|
|
1993
|
-
payload.value = def.catchValue({
|
|
1994
|
-
...payload,
|
|
1995
|
-
error: { issues: result$1.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
1996
|
-
input: payload.value
|
|
1997
|
-
});
|
|
1998
|
-
payload.issues = [];
|
|
1999
|
-
}
|
|
2000
|
-
return payload;
|
|
2001
|
-
});
|
|
2002
|
-
payload.value = result.value;
|
|
2003
|
-
if (result.issues.length) {
|
|
2004
|
-
payload.value = def.catchValue({
|
|
2005
|
-
...payload,
|
|
2006
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2007
|
-
input: payload.value
|
|
2008
|
-
});
|
|
2009
|
-
payload.issues = [];
|
|
2010
|
-
}
|
|
2011
|
-
return payload;
|
|
2012
|
-
};
|
|
2013
|
-
});
|
|
2014
|
-
const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
2015
|
-
$ZodType.init(inst, def);
|
|
2016
|
-
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
2017
|
-
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
2018
|
-
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
2019
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2020
|
-
const left = def.in._zod.run(payload, ctx);
|
|
2021
|
-
if (left instanceof Promise) return left.then((left$1) => handlePipeResult(left$1, def, ctx));
|
|
2022
|
-
return handlePipeResult(left, def, ctx);
|
|
2023
|
-
};
|
|
2024
|
-
});
|
|
2025
|
-
function handlePipeResult(left, def, ctx) {
|
|
2026
|
-
if (aborted(left)) return left;
|
|
2027
|
-
return def.out._zod.run({
|
|
2028
|
-
value: left.value,
|
|
2029
|
-
issues: left.issues
|
|
2030
|
-
}, ctx);
|
|
2031
|
-
}
|
|
2032
|
-
const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
2033
|
-
$ZodType.init(inst, def);
|
|
2034
|
-
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
2035
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2036
|
-
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
2037
|
-
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
2038
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2039
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2040
|
-
if (result instanceof Promise) return result.then(handleReadonlyResult);
|
|
2041
|
-
return handleReadonlyResult(result);
|
|
2042
|
-
};
|
|
2043
|
-
});
|
|
2044
|
-
function handleReadonlyResult(payload) {
|
|
2045
|
-
payload.value = Object.freeze(payload.value);
|
|
2046
|
-
return payload;
|
|
2047
|
-
}
|
|
2048
|
-
const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
2049
|
-
$ZodCheck.init(inst, def);
|
|
2050
|
-
$ZodType.init(inst, def);
|
|
2051
|
-
inst._zod.parse = (payload, _) => {
|
|
2052
|
-
return payload;
|
|
2053
|
-
};
|
|
2054
|
-
inst._zod.check = (payload) => {
|
|
2055
|
-
const input = payload.value;
|
|
2056
|
-
const r = def.fn(input);
|
|
2057
|
-
if (r instanceof Promise) return r.then((r$1) => handleRefineResult(r$1, payload, input, inst));
|
|
2058
|
-
handleRefineResult(r, payload, input, inst);
|
|
2059
|
-
return;
|
|
2060
|
-
};
|
|
2061
|
-
});
|
|
2062
|
-
function handleRefineResult(result, payload, input, inst) {
|
|
2063
|
-
if (!result) {
|
|
2064
|
-
const _iss = {
|
|
2065
|
-
code: "custom",
|
|
2066
|
-
input,
|
|
2067
|
-
inst,
|
|
2068
|
-
path: [...inst._zod.def.path ?? []],
|
|
2069
|
-
continue: !inst._zod.def.abort
|
|
2070
|
-
};
|
|
2071
|
-
if (inst._zod.def.params) _iss.params = inst._zod.def.params;
|
|
2072
|
-
payload.issues.push(issue(_iss));
|
|
2073
|
-
}
|
|
2074
|
-
}
|
|
2075
|
-
|
|
2076
|
-
//#endregion
|
|
2077
|
-
//#region ../../node_modules/zod/v4/core/registries.js
|
|
2078
|
-
const $output = Symbol("ZodOutput");
|
|
2079
|
-
const $input = Symbol("ZodInput");
|
|
2080
|
-
var $ZodRegistry = class {
|
|
2081
|
-
constructor() {
|
|
2082
|
-
this._map = /* @__PURE__ */ new WeakMap();
|
|
2083
|
-
this._idmap = /* @__PURE__ */ new Map();
|
|
2084
|
-
}
|
|
2085
|
-
add(schema, ..._meta) {
|
|
2086
|
-
const meta = _meta[0];
|
|
2087
|
-
this._map.set(schema, meta);
|
|
2088
|
-
if (meta && typeof meta === "object" && "id" in meta) {
|
|
2089
|
-
if (this._idmap.has(meta.id)) throw new Error(`ID ${meta.id} already exists in the registry`);
|
|
2090
|
-
this._idmap.set(meta.id, schema);
|
|
2091
|
-
}
|
|
2092
|
-
return this;
|
|
2093
|
-
}
|
|
2094
|
-
remove(schema) {
|
|
2095
|
-
this._map.delete(schema);
|
|
2096
|
-
return this;
|
|
2097
|
-
}
|
|
2098
|
-
get(schema) {
|
|
2099
|
-
const p = schema._zod.parent;
|
|
2100
|
-
if (p) {
|
|
2101
|
-
const pm = { ...this.get(p) ?? {} };
|
|
2102
|
-
delete pm.id;
|
|
2103
|
-
return {
|
|
2104
|
-
...pm,
|
|
2105
|
-
...this._map.get(schema)
|
|
2106
|
-
};
|
|
2107
|
-
}
|
|
2108
|
-
return this._map.get(schema);
|
|
2109
|
-
}
|
|
2110
|
-
has(schema) {
|
|
2111
|
-
return this._map.has(schema);
|
|
2112
|
-
}
|
|
2113
|
-
};
|
|
2114
|
-
function registry() {
|
|
2115
|
-
return new $ZodRegistry();
|
|
2116
|
-
}
|
|
2117
|
-
const globalRegistry = /* @__PURE__ */ registry();
|
|
2118
|
-
|
|
2119
|
-
//#endregion
|
|
2120
|
-
//#region ../../node_modules/zod/v4/core/api.js
|
|
2121
|
-
function _string(Class, params) {
|
|
2122
|
-
return new Class({
|
|
2123
|
-
type: "string",
|
|
2124
|
-
...normalizeParams(params)
|
|
2125
|
-
});
|
|
2126
|
-
}
|
|
2127
|
-
function _email(Class, params) {
|
|
2128
|
-
return new Class({
|
|
2129
|
-
type: "string",
|
|
2130
|
-
format: "email",
|
|
2131
|
-
check: "string_format",
|
|
2132
|
-
abort: false,
|
|
2133
|
-
...normalizeParams(params)
|
|
2134
|
-
});
|
|
2135
|
-
}
|
|
2136
|
-
function _guid(Class, params) {
|
|
2137
|
-
return new Class({
|
|
2138
|
-
type: "string",
|
|
2139
|
-
format: "guid",
|
|
2140
|
-
check: "string_format",
|
|
2141
|
-
abort: false,
|
|
2142
|
-
...normalizeParams(params)
|
|
2143
|
-
});
|
|
2144
|
-
}
|
|
2145
|
-
function _uuid(Class, params) {
|
|
2146
|
-
return new Class({
|
|
2147
|
-
type: "string",
|
|
2148
|
-
format: "uuid",
|
|
2149
|
-
check: "string_format",
|
|
2150
|
-
abort: false,
|
|
2151
|
-
...normalizeParams(params)
|
|
2152
|
-
});
|
|
2153
|
-
}
|
|
2154
|
-
function _uuidv4(Class, params) {
|
|
2155
|
-
return new Class({
|
|
2156
|
-
type: "string",
|
|
2157
|
-
format: "uuid",
|
|
2158
|
-
check: "string_format",
|
|
2159
|
-
abort: false,
|
|
2160
|
-
version: "v4",
|
|
2161
|
-
...normalizeParams(params)
|
|
2162
|
-
});
|
|
2163
|
-
}
|
|
2164
|
-
function _uuidv6(Class, params) {
|
|
2165
|
-
return new Class({
|
|
2166
|
-
type: "string",
|
|
2167
|
-
format: "uuid",
|
|
2168
|
-
check: "string_format",
|
|
2169
|
-
abort: false,
|
|
2170
|
-
version: "v6",
|
|
2171
|
-
...normalizeParams(params)
|
|
2172
|
-
});
|
|
2173
|
-
}
|
|
2174
|
-
function _uuidv7(Class, params) {
|
|
2175
|
-
return new Class({
|
|
2176
|
-
type: "string",
|
|
2177
|
-
format: "uuid",
|
|
2178
|
-
check: "string_format",
|
|
2179
|
-
abort: false,
|
|
2180
|
-
version: "v7",
|
|
2181
|
-
...normalizeParams(params)
|
|
2182
|
-
});
|
|
2183
|
-
}
|
|
2184
|
-
function _url(Class, params) {
|
|
2185
|
-
return new Class({
|
|
2186
|
-
type: "string",
|
|
2187
|
-
format: "url",
|
|
2188
|
-
check: "string_format",
|
|
2189
|
-
abort: false,
|
|
2190
|
-
...normalizeParams(params)
|
|
2191
|
-
});
|
|
2192
|
-
}
|
|
2193
|
-
function _emoji(Class, params) {
|
|
2194
|
-
return new Class({
|
|
2195
|
-
type: "string",
|
|
2196
|
-
format: "emoji",
|
|
2197
|
-
check: "string_format",
|
|
2198
|
-
abort: false,
|
|
2199
|
-
...normalizeParams(params)
|
|
2200
|
-
});
|
|
2201
|
-
}
|
|
2202
|
-
function _nanoid(Class, params) {
|
|
2203
|
-
return new Class({
|
|
2204
|
-
type: "string",
|
|
2205
|
-
format: "nanoid",
|
|
2206
|
-
check: "string_format",
|
|
2207
|
-
abort: false,
|
|
2208
|
-
...normalizeParams(params)
|
|
2209
|
-
});
|
|
2210
|
-
}
|
|
2211
|
-
function _cuid(Class, params) {
|
|
2212
|
-
return new Class({
|
|
2213
|
-
type: "string",
|
|
2214
|
-
format: "cuid",
|
|
2215
|
-
check: "string_format",
|
|
2216
|
-
abort: false,
|
|
2217
|
-
...normalizeParams(params)
|
|
2218
|
-
});
|
|
2219
|
-
}
|
|
2220
|
-
function _cuid2(Class, params) {
|
|
2221
|
-
return new Class({
|
|
2222
|
-
type: "string",
|
|
2223
|
-
format: "cuid2",
|
|
2224
|
-
check: "string_format",
|
|
2225
|
-
abort: false,
|
|
2226
|
-
...normalizeParams(params)
|
|
2227
|
-
});
|
|
2228
|
-
}
|
|
2229
|
-
function _ulid(Class, params) {
|
|
2230
|
-
return new Class({
|
|
2231
|
-
type: "string",
|
|
2232
|
-
format: "ulid",
|
|
2233
|
-
check: "string_format",
|
|
2234
|
-
abort: false,
|
|
2235
|
-
...normalizeParams(params)
|
|
2236
|
-
});
|
|
2237
|
-
}
|
|
2238
|
-
function _xid(Class, params) {
|
|
2239
|
-
return new Class({
|
|
2240
|
-
type: "string",
|
|
2241
|
-
format: "xid",
|
|
2242
|
-
check: "string_format",
|
|
2243
|
-
abort: false,
|
|
2244
|
-
...normalizeParams(params)
|
|
2245
|
-
});
|
|
2246
|
-
}
|
|
2247
|
-
function _ksuid(Class, params) {
|
|
2248
|
-
return new Class({
|
|
2249
|
-
type: "string",
|
|
2250
|
-
format: "ksuid",
|
|
2251
|
-
check: "string_format",
|
|
2252
|
-
abort: false,
|
|
2253
|
-
...normalizeParams(params)
|
|
2254
|
-
});
|
|
2255
|
-
}
|
|
2256
|
-
function _ipv4(Class, params) {
|
|
2257
|
-
return new Class({
|
|
2258
|
-
type: "string",
|
|
2259
|
-
format: "ipv4",
|
|
2260
|
-
check: "string_format",
|
|
2261
|
-
abort: false,
|
|
2262
|
-
...normalizeParams(params)
|
|
2263
|
-
});
|
|
2264
|
-
}
|
|
2265
|
-
function _ipv6(Class, params) {
|
|
2266
|
-
return new Class({
|
|
2267
|
-
type: "string",
|
|
2268
|
-
format: "ipv6",
|
|
2269
|
-
check: "string_format",
|
|
2270
|
-
abort: false,
|
|
2271
|
-
...normalizeParams(params)
|
|
2272
|
-
});
|
|
2273
|
-
}
|
|
2274
|
-
function _cidrv4(Class, params) {
|
|
2275
|
-
return new Class({
|
|
2276
|
-
type: "string",
|
|
2277
|
-
format: "cidrv4",
|
|
2278
|
-
check: "string_format",
|
|
2279
|
-
abort: false,
|
|
2280
|
-
...normalizeParams(params)
|
|
2281
|
-
});
|
|
2282
|
-
}
|
|
2283
|
-
function _cidrv6(Class, params) {
|
|
2284
|
-
return new Class({
|
|
2285
|
-
type: "string",
|
|
2286
|
-
format: "cidrv6",
|
|
2287
|
-
check: "string_format",
|
|
2288
|
-
abort: false,
|
|
2289
|
-
...normalizeParams(params)
|
|
2290
|
-
});
|
|
2291
|
-
}
|
|
2292
|
-
function _base64(Class, params) {
|
|
2293
|
-
return new Class({
|
|
2294
|
-
type: "string",
|
|
2295
|
-
format: "base64",
|
|
2296
|
-
check: "string_format",
|
|
2297
|
-
abort: false,
|
|
2298
|
-
...normalizeParams(params)
|
|
2299
|
-
});
|
|
2300
|
-
}
|
|
2301
|
-
function _base64url(Class, params) {
|
|
2302
|
-
return new Class({
|
|
2303
|
-
type: "string",
|
|
2304
|
-
format: "base64url",
|
|
2305
|
-
check: "string_format",
|
|
2306
|
-
abort: false,
|
|
2307
|
-
...normalizeParams(params)
|
|
2308
|
-
});
|
|
2309
|
-
}
|
|
2310
|
-
function _e164(Class, params) {
|
|
2311
|
-
return new Class({
|
|
2312
|
-
type: "string",
|
|
2313
|
-
format: "e164",
|
|
2314
|
-
check: "string_format",
|
|
2315
|
-
abort: false,
|
|
2316
|
-
...normalizeParams(params)
|
|
2317
|
-
});
|
|
2318
|
-
}
|
|
2319
|
-
function _jwt(Class, params) {
|
|
2320
|
-
return new Class({
|
|
2321
|
-
type: "string",
|
|
2322
|
-
format: "jwt",
|
|
2323
|
-
check: "string_format",
|
|
2324
|
-
abort: false,
|
|
2325
|
-
...normalizeParams(params)
|
|
2326
|
-
});
|
|
2327
|
-
}
|
|
2328
|
-
function _isoDateTime(Class, params) {
|
|
2329
|
-
return new Class({
|
|
2330
|
-
type: "string",
|
|
2331
|
-
format: "datetime",
|
|
2332
|
-
check: "string_format",
|
|
2333
|
-
offset: false,
|
|
2334
|
-
local: false,
|
|
2335
|
-
precision: null,
|
|
2336
|
-
...normalizeParams(params)
|
|
2337
|
-
});
|
|
2338
|
-
}
|
|
2339
|
-
function _isoDate(Class, params) {
|
|
2340
|
-
return new Class({
|
|
2341
|
-
type: "string",
|
|
2342
|
-
format: "date",
|
|
2343
|
-
check: "string_format",
|
|
2344
|
-
...normalizeParams(params)
|
|
2345
|
-
});
|
|
2346
|
-
}
|
|
2347
|
-
function _isoTime(Class, params) {
|
|
2348
|
-
return new Class({
|
|
2349
|
-
type: "string",
|
|
2350
|
-
format: "time",
|
|
2351
|
-
check: "string_format",
|
|
2352
|
-
precision: null,
|
|
2353
|
-
...normalizeParams(params)
|
|
2354
|
-
});
|
|
2355
|
-
}
|
|
2356
|
-
function _isoDuration(Class, params) {
|
|
2357
|
-
return new Class({
|
|
2358
|
-
type: "string",
|
|
2359
|
-
format: "duration",
|
|
2360
|
-
check: "string_format",
|
|
2361
|
-
...normalizeParams(params)
|
|
2362
|
-
});
|
|
2363
|
-
}
|
|
2364
|
-
function _number(Class, params) {
|
|
2365
|
-
return new Class({
|
|
2366
|
-
type: "number",
|
|
2367
|
-
checks: [],
|
|
2368
|
-
...normalizeParams(params)
|
|
2369
|
-
});
|
|
2370
|
-
}
|
|
2371
|
-
function _int(Class, params) {
|
|
2372
|
-
return new Class({
|
|
2373
|
-
type: "number",
|
|
2374
|
-
check: "number_format",
|
|
2375
|
-
abort: false,
|
|
2376
|
-
format: "safeint",
|
|
2377
|
-
...normalizeParams(params)
|
|
2378
|
-
});
|
|
2379
|
-
}
|
|
2380
|
-
function _boolean(Class, params) {
|
|
2381
|
-
return new Class({
|
|
2382
|
-
type: "boolean",
|
|
2383
|
-
...normalizeParams(params)
|
|
2384
|
-
});
|
|
2385
|
-
}
|
|
2386
|
-
function _any(Class) {
|
|
2387
|
-
return new Class({ type: "any" });
|
|
2388
|
-
}
|
|
2389
|
-
function _unknown(Class) {
|
|
2390
|
-
return new Class({ type: "unknown" });
|
|
2391
|
-
}
|
|
2392
|
-
function _never(Class, params) {
|
|
2393
|
-
return new Class({
|
|
2394
|
-
type: "never",
|
|
2395
|
-
...normalizeParams(params)
|
|
2396
|
-
});
|
|
2397
|
-
}
|
|
2398
|
-
function _lt(value, params) {
|
|
2399
|
-
return new $ZodCheckLessThan({
|
|
2400
|
-
check: "less_than",
|
|
2401
|
-
...normalizeParams(params),
|
|
2402
|
-
value,
|
|
2403
|
-
inclusive: false
|
|
2404
|
-
});
|
|
2405
|
-
}
|
|
2406
|
-
function _lte(value, params) {
|
|
2407
|
-
return new $ZodCheckLessThan({
|
|
2408
|
-
check: "less_than",
|
|
2409
|
-
...normalizeParams(params),
|
|
2410
|
-
value,
|
|
2411
|
-
inclusive: true
|
|
2412
|
-
});
|
|
2413
|
-
}
|
|
2414
|
-
function _gt(value, params) {
|
|
2415
|
-
return new $ZodCheckGreaterThan({
|
|
2416
|
-
check: "greater_than",
|
|
2417
|
-
...normalizeParams(params),
|
|
2418
|
-
value,
|
|
2419
|
-
inclusive: false
|
|
2420
|
-
});
|
|
2421
|
-
}
|
|
2422
|
-
function _gte(value, params) {
|
|
2423
|
-
return new $ZodCheckGreaterThan({
|
|
2424
|
-
check: "greater_than",
|
|
2425
|
-
...normalizeParams(params),
|
|
2426
|
-
value,
|
|
2427
|
-
inclusive: true
|
|
2428
|
-
});
|
|
2429
|
-
}
|
|
2430
|
-
function _multipleOf(value, params) {
|
|
2431
|
-
return new $ZodCheckMultipleOf({
|
|
2432
|
-
check: "multiple_of",
|
|
2433
|
-
...normalizeParams(params),
|
|
2434
|
-
value
|
|
2435
|
-
});
|
|
2436
|
-
}
|
|
2437
|
-
function _maxLength(maximum, params) {
|
|
2438
|
-
const ch = new $ZodCheckMaxLength({
|
|
2439
|
-
check: "max_length",
|
|
2440
|
-
...normalizeParams(params),
|
|
2441
|
-
maximum
|
|
2442
|
-
});
|
|
2443
|
-
return ch;
|
|
2444
|
-
}
|
|
2445
|
-
function _minLength(minimum, params) {
|
|
2446
|
-
return new $ZodCheckMinLength({
|
|
2447
|
-
check: "min_length",
|
|
2448
|
-
...normalizeParams(params),
|
|
2449
|
-
minimum
|
|
2450
|
-
});
|
|
2451
|
-
}
|
|
2452
|
-
function _length(length, params) {
|
|
2453
|
-
return new $ZodCheckLengthEquals({
|
|
2454
|
-
check: "length_equals",
|
|
2455
|
-
...normalizeParams(params),
|
|
2456
|
-
length
|
|
2457
|
-
});
|
|
2458
|
-
}
|
|
2459
|
-
function _regex(pattern, params) {
|
|
2460
|
-
return new $ZodCheckRegex({
|
|
2461
|
-
check: "string_format",
|
|
2462
|
-
format: "regex",
|
|
2463
|
-
...normalizeParams(params),
|
|
2464
|
-
pattern
|
|
2465
|
-
});
|
|
2466
|
-
}
|
|
2467
|
-
function _lowercase(params) {
|
|
2468
|
-
return new $ZodCheckLowerCase({
|
|
2469
|
-
check: "string_format",
|
|
2470
|
-
format: "lowercase",
|
|
2471
|
-
...normalizeParams(params)
|
|
2472
|
-
});
|
|
2473
|
-
}
|
|
2474
|
-
function _uppercase(params) {
|
|
2475
|
-
return new $ZodCheckUpperCase({
|
|
2476
|
-
check: "string_format",
|
|
2477
|
-
format: "uppercase",
|
|
2478
|
-
...normalizeParams(params)
|
|
2479
|
-
});
|
|
2480
|
-
}
|
|
2481
|
-
function _includes(includes, params) {
|
|
2482
|
-
return new $ZodCheckIncludes({
|
|
2483
|
-
check: "string_format",
|
|
2484
|
-
format: "includes",
|
|
2485
|
-
...normalizeParams(params),
|
|
2486
|
-
includes
|
|
2487
|
-
});
|
|
2488
|
-
}
|
|
2489
|
-
function _startsWith(prefix, params) {
|
|
2490
|
-
return new $ZodCheckStartsWith({
|
|
2491
|
-
check: "string_format",
|
|
2492
|
-
format: "starts_with",
|
|
2493
|
-
...normalizeParams(params),
|
|
2494
|
-
prefix
|
|
2495
|
-
});
|
|
2496
|
-
}
|
|
2497
|
-
function _endsWith(suffix, params) {
|
|
2498
|
-
return new $ZodCheckEndsWith({
|
|
2499
|
-
check: "string_format",
|
|
2500
|
-
format: "ends_with",
|
|
2501
|
-
...normalizeParams(params),
|
|
2502
|
-
suffix
|
|
2503
|
-
});
|
|
2504
|
-
}
|
|
2505
|
-
function _overwrite(tx) {
|
|
2506
|
-
return new $ZodCheckOverwrite({
|
|
2507
|
-
check: "overwrite",
|
|
2508
|
-
tx
|
|
2509
|
-
});
|
|
2510
|
-
}
|
|
2511
|
-
function _normalize(form) {
|
|
2512
|
-
return _overwrite((input) => input.normalize(form));
|
|
2513
|
-
}
|
|
2514
|
-
function _trim() {
|
|
2515
|
-
return _overwrite((input) => input.trim());
|
|
2516
|
-
}
|
|
2517
|
-
function _toLowerCase() {
|
|
2518
|
-
return _overwrite((input) => input.toLowerCase());
|
|
2519
|
-
}
|
|
2520
|
-
function _toUpperCase() {
|
|
2521
|
-
return _overwrite((input) => input.toUpperCase());
|
|
2522
|
-
}
|
|
2523
|
-
function _array(Class, element, params) {
|
|
2524
|
-
return new Class({
|
|
2525
|
-
type: "array",
|
|
2526
|
-
element,
|
|
2527
|
-
...normalizeParams(params)
|
|
2528
|
-
});
|
|
2529
|
-
}
|
|
2530
|
-
function _refine(Class, fn, _params) {
|
|
2531
|
-
const schema = new Class({
|
|
2532
|
-
type: "custom",
|
|
2533
|
-
check: "custom",
|
|
2534
|
-
fn,
|
|
2535
|
-
...normalizeParams(_params)
|
|
2536
|
-
});
|
|
2537
|
-
return schema;
|
|
2538
|
-
}
|
|
2539
|
-
|
|
2540
|
-
//#endregion
|
|
2541
|
-
//#region ../../node_modules/zod/v4/classic/iso.js
|
|
2542
|
-
const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
2543
|
-
$ZodISODateTime.init(inst, def);
|
|
2544
|
-
ZodStringFormat.init(inst, def);
|
|
2545
|
-
});
|
|
2546
|
-
function datetime(params) {
|
|
2547
|
-
return _isoDateTime(ZodISODateTime, params);
|
|
2548
|
-
}
|
|
2549
|
-
const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
|
|
2550
|
-
$ZodISODate.init(inst, def);
|
|
2551
|
-
ZodStringFormat.init(inst, def);
|
|
2552
|
-
});
|
|
2553
|
-
function date(params) {
|
|
2554
|
-
return _isoDate(ZodISODate, params);
|
|
2555
|
-
}
|
|
2556
|
-
const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
|
|
2557
|
-
$ZodISOTime.init(inst, def);
|
|
2558
|
-
ZodStringFormat.init(inst, def);
|
|
2559
|
-
});
|
|
2560
|
-
function time(params) {
|
|
2561
|
-
return _isoTime(ZodISOTime, params);
|
|
2562
|
-
}
|
|
2563
|
-
const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
|
|
2564
|
-
$ZodISODuration.init(inst, def);
|
|
2565
|
-
ZodStringFormat.init(inst, def);
|
|
2566
|
-
});
|
|
2567
|
-
function duration(params) {
|
|
2568
|
-
return _isoDuration(ZodISODuration, params);
|
|
2569
|
-
}
|
|
2570
|
-
|
|
2571
|
-
//#endregion
|
|
2572
|
-
//#region ../../node_modules/zod/v4/classic/errors.js
|
|
2573
|
-
const initializer = (inst, issues) => {
|
|
2574
|
-
$ZodError.init(inst, issues);
|
|
2575
|
-
inst.name = "ZodError";
|
|
2576
|
-
Object.defineProperties(inst, {
|
|
2577
|
-
format: { value: (mapper) => formatError(inst, mapper) },
|
|
2578
|
-
flatten: { value: (mapper) => flattenError(inst, mapper) },
|
|
2579
|
-
addIssue: { value: (issue$1) => inst.issues.push(issue$1) },
|
|
2580
|
-
addIssues: { value: (issues$1) => inst.issues.push(...issues$1) },
|
|
2581
|
-
isEmpty: { get() {
|
|
2582
|
-
return inst.issues.length === 0;
|
|
2583
|
-
} }
|
|
2584
|
-
});
|
|
2585
|
-
};
|
|
2586
|
-
const ZodError = $constructor("ZodError", initializer);
|
|
2587
|
-
const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
|
|
2588
|
-
|
|
2589
|
-
//#endregion
|
|
2590
|
-
//#region ../../node_modules/zod/v4/classic/parse.js
|
|
2591
|
-
const parse$2 = /* @__PURE__ */ _parse(ZodRealError);
|
|
2592
|
-
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
2593
|
-
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
2594
|
-
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
2595
|
-
|
|
2596
|
-
//#endregion
|
|
2597
|
-
//#region ../../node_modules/zod/v4/classic/schemas.js
|
|
2598
|
-
const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
2599
|
-
$ZodType.init(inst, def);
|
|
2600
|
-
inst.def = def;
|
|
2601
|
-
Object.defineProperty(inst, "_def", { value: def });
|
|
2602
|
-
inst.check = (...checks) => {
|
|
2603
|
-
return inst.clone({
|
|
2604
|
-
...def,
|
|
2605
|
-
checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
2606
|
-
check: ch,
|
|
2607
|
-
def: { check: "custom" },
|
|
2608
|
-
onattach: []
|
|
2609
|
-
} } : ch)]
|
|
2610
|
-
});
|
|
2611
|
-
};
|
|
2612
|
-
inst.clone = (def$1, params) => clone(inst, def$1, params);
|
|
2613
|
-
inst.brand = () => inst;
|
|
2614
|
-
inst.register = (reg, meta) => {
|
|
2615
|
-
reg.add(inst, meta);
|
|
2616
|
-
return inst;
|
|
2617
|
-
};
|
|
2618
|
-
inst.parse = (data, params) => parse$2(inst, data, params, { callee: inst.parse });
|
|
2619
|
-
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
2620
|
-
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
2621
|
-
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
2622
|
-
inst.spa = inst.safeParseAsync;
|
|
2623
|
-
inst.refine = (check$1, params) => inst.check(refine(check$1, params));
|
|
2624
|
-
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
2625
|
-
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
2626
|
-
inst.optional = () => optional(inst);
|
|
2627
|
-
inst.nullable = () => nullable(inst);
|
|
2628
|
-
inst.nullish = () => optional(nullable(inst));
|
|
2629
|
-
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
2630
|
-
inst.array = () => array(inst);
|
|
2631
|
-
inst.or = (arg) => union([inst, arg]);
|
|
2632
|
-
inst.and = (arg) => intersection(inst, arg);
|
|
2633
|
-
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
2634
|
-
inst.default = (def$1) => _default(inst, def$1);
|
|
2635
|
-
inst.prefault = (def$1) => prefault(inst, def$1);
|
|
2636
|
-
inst.catch = (params) => _catch(inst, params);
|
|
2637
|
-
inst.pipe = (target) => pipe(inst, target);
|
|
2638
|
-
inst.readonly = () => readonly(inst);
|
|
2639
|
-
inst.describe = (description) => {
|
|
2640
|
-
const cl = inst.clone();
|
|
2641
|
-
globalRegistry.add(cl, { description });
|
|
2642
|
-
return cl;
|
|
2643
|
-
};
|
|
2644
|
-
Object.defineProperty(inst, "description", {
|
|
2645
|
-
get() {
|
|
2646
|
-
return globalRegistry.get(inst)?.description;
|
|
2647
|
-
},
|
|
2648
|
-
configurable: true
|
|
2649
|
-
});
|
|
2650
|
-
inst.meta = (...args) => {
|
|
2651
|
-
if (args.length === 0) return globalRegistry.get(inst);
|
|
2652
|
-
const cl = inst.clone();
|
|
2653
|
-
globalRegistry.add(cl, args[0]);
|
|
2654
|
-
return cl;
|
|
2655
|
-
};
|
|
2656
|
-
inst.isOptional = () => inst.safeParse(void 0).success;
|
|
2657
|
-
inst.isNullable = () => inst.safeParse(null).success;
|
|
2658
|
-
return inst;
|
|
2659
|
-
});
|
|
2660
|
-
/** @internal */
|
|
2661
|
-
const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
2662
|
-
$ZodString.init(inst, def);
|
|
2663
|
-
ZodType.init(inst, def);
|
|
2664
|
-
const bag = inst._zod.bag;
|
|
2665
|
-
inst.format = bag.format ?? null;
|
|
2666
|
-
inst.minLength = bag.minimum ?? null;
|
|
2667
|
-
inst.maxLength = bag.maximum ?? null;
|
|
2668
|
-
inst.regex = (...args) => inst.check(_regex(...args));
|
|
2669
|
-
inst.includes = (...args) => inst.check(_includes(...args));
|
|
2670
|
-
inst.startsWith = (...args) => inst.check(_startsWith(...args));
|
|
2671
|
-
inst.endsWith = (...args) => inst.check(_endsWith(...args));
|
|
2672
|
-
inst.min = (...args) => inst.check(_minLength(...args));
|
|
2673
|
-
inst.max = (...args) => inst.check(_maxLength(...args));
|
|
2674
|
-
inst.length = (...args) => inst.check(_length(...args));
|
|
2675
|
-
inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
|
|
2676
|
-
inst.lowercase = (params) => inst.check(_lowercase(params));
|
|
2677
|
-
inst.uppercase = (params) => inst.check(_uppercase(params));
|
|
2678
|
-
inst.trim = () => inst.check(_trim());
|
|
2679
|
-
inst.normalize = (...args) => inst.check(_normalize(...args));
|
|
2680
|
-
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
2681
|
-
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
2682
|
-
});
|
|
2683
|
-
const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
2684
|
-
$ZodString.init(inst, def);
|
|
2685
|
-
_ZodString.init(inst, def);
|
|
2686
|
-
inst.email = (params) => inst.check(_email(ZodEmail, params));
|
|
2687
|
-
inst.url = (params) => inst.check(_url(ZodURL, params));
|
|
2688
|
-
inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
|
|
2689
|
-
inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
|
|
2690
|
-
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
2691
|
-
inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
|
|
2692
|
-
inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
|
|
2693
|
-
inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
|
|
2694
|
-
inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
|
|
2695
|
-
inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
|
|
2696
|
-
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
2697
|
-
inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
|
|
2698
|
-
inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
|
|
2699
|
-
inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
|
|
2700
|
-
inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
|
|
2701
|
-
inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
|
|
2702
|
-
inst.xid = (params) => inst.check(_xid(ZodXID, params));
|
|
2703
|
-
inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
|
|
2704
|
-
inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
|
|
2705
|
-
inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
|
|
2706
|
-
inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
|
|
2707
|
-
inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
|
|
2708
|
-
inst.e164 = (params) => inst.check(_e164(ZodE164, params));
|
|
2709
|
-
inst.datetime = (params) => inst.check(datetime(params));
|
|
2710
|
-
inst.date = (params) => inst.check(date(params));
|
|
2711
|
-
inst.time = (params) => inst.check(time(params));
|
|
2712
|
-
inst.duration = (params) => inst.check(duration(params));
|
|
2713
|
-
});
|
|
2714
|
-
function string(params) {
|
|
2715
|
-
return _string(ZodString, params);
|
|
2716
|
-
}
|
|
2717
|
-
const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
|
|
2718
|
-
$ZodStringFormat.init(inst, def);
|
|
2719
|
-
_ZodString.init(inst, def);
|
|
2720
|
-
});
|
|
2721
|
-
const ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
|
|
2722
|
-
$ZodEmail.init(inst, def);
|
|
2723
|
-
ZodStringFormat.init(inst, def);
|
|
2724
|
-
});
|
|
2725
|
-
const ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
|
|
2726
|
-
$ZodGUID.init(inst, def);
|
|
2727
|
-
ZodStringFormat.init(inst, def);
|
|
2728
|
-
});
|
|
2729
|
-
const ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
|
|
2730
|
-
$ZodUUID.init(inst, def);
|
|
2731
|
-
ZodStringFormat.init(inst, def);
|
|
2732
|
-
});
|
|
2733
|
-
const ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
|
|
2734
|
-
$ZodURL.init(inst, def);
|
|
2735
|
-
ZodStringFormat.init(inst, def);
|
|
2736
|
-
});
|
|
2737
|
-
const ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
|
|
2738
|
-
$ZodEmoji.init(inst, def);
|
|
2739
|
-
ZodStringFormat.init(inst, def);
|
|
2740
|
-
});
|
|
2741
|
-
const ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
|
|
2742
|
-
$ZodNanoID.init(inst, def);
|
|
2743
|
-
ZodStringFormat.init(inst, def);
|
|
2744
|
-
});
|
|
2745
|
-
const ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
|
|
2746
|
-
$ZodCUID.init(inst, def);
|
|
2747
|
-
ZodStringFormat.init(inst, def);
|
|
2748
|
-
});
|
|
2749
|
-
const ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
|
|
2750
|
-
$ZodCUID2.init(inst, def);
|
|
2751
|
-
ZodStringFormat.init(inst, def);
|
|
2752
|
-
});
|
|
2753
|
-
const ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
|
|
2754
|
-
$ZodULID.init(inst, def);
|
|
2755
|
-
ZodStringFormat.init(inst, def);
|
|
2756
|
-
});
|
|
2757
|
-
const ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
|
|
2758
|
-
$ZodXID.init(inst, def);
|
|
2759
|
-
ZodStringFormat.init(inst, def);
|
|
2760
|
-
});
|
|
2761
|
-
const ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
|
|
2762
|
-
$ZodKSUID.init(inst, def);
|
|
2763
|
-
ZodStringFormat.init(inst, def);
|
|
2764
|
-
});
|
|
2765
|
-
const ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
|
|
2766
|
-
$ZodIPv4.init(inst, def);
|
|
2767
|
-
ZodStringFormat.init(inst, def);
|
|
2768
|
-
});
|
|
2769
|
-
const ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
|
|
2770
|
-
$ZodIPv6.init(inst, def);
|
|
2771
|
-
ZodStringFormat.init(inst, def);
|
|
2772
|
-
});
|
|
2773
|
-
const ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
|
|
2774
|
-
$ZodCIDRv4.init(inst, def);
|
|
2775
|
-
ZodStringFormat.init(inst, def);
|
|
2776
|
-
});
|
|
2777
|
-
const ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
|
|
2778
|
-
$ZodCIDRv6.init(inst, def);
|
|
2779
|
-
ZodStringFormat.init(inst, def);
|
|
2780
|
-
});
|
|
2781
|
-
const ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
|
|
2782
|
-
$ZodBase64.init(inst, def);
|
|
2783
|
-
ZodStringFormat.init(inst, def);
|
|
2784
|
-
});
|
|
2785
|
-
const ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
|
|
2786
|
-
$ZodBase64URL.init(inst, def);
|
|
2787
|
-
ZodStringFormat.init(inst, def);
|
|
2788
|
-
});
|
|
2789
|
-
const ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
|
|
2790
|
-
$ZodE164.init(inst, def);
|
|
2791
|
-
ZodStringFormat.init(inst, def);
|
|
2792
|
-
});
|
|
2793
|
-
const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
|
|
2794
|
-
$ZodJWT.init(inst, def);
|
|
2795
|
-
ZodStringFormat.init(inst, def);
|
|
2796
|
-
});
|
|
2797
|
-
const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
2798
|
-
$ZodNumber.init(inst, def);
|
|
2799
|
-
ZodType.init(inst, def);
|
|
2800
|
-
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
2801
|
-
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
2802
|
-
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
2803
|
-
inst.lt = (value, params) => inst.check(_lt(value, params));
|
|
2804
|
-
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
2805
|
-
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
2806
|
-
inst.int = (params) => inst.check(int(params));
|
|
2807
|
-
inst.safe = (params) => inst.check(int(params));
|
|
2808
|
-
inst.positive = (params) => inst.check(_gt(0, params));
|
|
2809
|
-
inst.nonnegative = (params) => inst.check(_gte(0, params));
|
|
2810
|
-
inst.negative = (params) => inst.check(_lt(0, params));
|
|
2811
|
-
inst.nonpositive = (params) => inst.check(_lte(0, params));
|
|
2812
|
-
inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
|
|
2813
|
-
inst.step = (value, params) => inst.check(_multipleOf(value, params));
|
|
2814
|
-
inst.finite = () => inst;
|
|
2815
|
-
const bag = inst._zod.bag;
|
|
2816
|
-
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
2817
|
-
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
2818
|
-
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
|
|
2819
|
-
inst.isFinite = true;
|
|
2820
|
-
inst.format = bag.format ?? null;
|
|
2821
|
-
});
|
|
2822
|
-
function number(params) {
|
|
2823
|
-
return _number(ZodNumber, params);
|
|
2824
|
-
}
|
|
2825
|
-
const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
|
|
2826
|
-
$ZodNumberFormat.init(inst, def);
|
|
2827
|
-
ZodNumber.init(inst, def);
|
|
2828
|
-
});
|
|
2829
|
-
function int(params) {
|
|
2830
|
-
return _int(ZodNumberFormat, params);
|
|
2831
|
-
}
|
|
2832
|
-
const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
2833
|
-
$ZodBoolean.init(inst, def);
|
|
2834
|
-
ZodType.init(inst, def);
|
|
2835
|
-
});
|
|
2836
|
-
function boolean(params) {
|
|
2837
|
-
return _boolean(ZodBoolean, params);
|
|
2838
|
-
}
|
|
2839
|
-
const ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
2840
|
-
$ZodAny.init(inst, def);
|
|
2841
|
-
ZodType.init(inst, def);
|
|
2842
|
-
});
|
|
2843
|
-
function any() {
|
|
2844
|
-
return _any(ZodAny);
|
|
2845
|
-
}
|
|
2846
|
-
const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
2847
|
-
$ZodUnknown.init(inst, def);
|
|
2848
|
-
ZodType.init(inst, def);
|
|
2849
|
-
});
|
|
2850
|
-
function unknown() {
|
|
2851
|
-
return _unknown(ZodUnknown);
|
|
2852
|
-
}
|
|
2853
|
-
const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
2854
|
-
$ZodNever.init(inst, def);
|
|
2855
|
-
ZodType.init(inst, def);
|
|
2856
|
-
});
|
|
2857
|
-
function never(params) {
|
|
2858
|
-
return _never(ZodNever, params);
|
|
2859
|
-
}
|
|
2860
|
-
const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
2861
|
-
$ZodArray.init(inst, def);
|
|
2862
|
-
ZodType.init(inst, def);
|
|
2863
|
-
inst.element = def.element;
|
|
2864
|
-
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
2865
|
-
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
2866
|
-
inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
|
|
2867
|
-
inst.length = (len, params) => inst.check(_length(len, params));
|
|
2868
|
-
inst.unwrap = () => inst.element;
|
|
2869
|
-
});
|
|
2870
|
-
function array(element, params) {
|
|
2871
|
-
return _array(ZodArray, element, params);
|
|
2872
|
-
}
|
|
2873
|
-
const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
2874
|
-
$ZodObject.init(inst, def);
|
|
2875
|
-
ZodType.init(inst, def);
|
|
2876
|
-
defineLazy(inst, "shape", () => def.shape);
|
|
2877
|
-
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
2878
|
-
inst.catchall = (catchall) => inst.clone({
|
|
2879
|
-
...inst._zod.def,
|
|
2880
|
-
catchall
|
|
2881
|
-
});
|
|
2882
|
-
inst.passthrough = () => inst.clone({
|
|
2883
|
-
...inst._zod.def,
|
|
2884
|
-
catchall: unknown()
|
|
2885
|
-
});
|
|
2886
|
-
inst.loose = () => inst.clone({
|
|
2887
|
-
...inst._zod.def,
|
|
2888
|
-
catchall: unknown()
|
|
2889
|
-
});
|
|
2890
|
-
inst.strict = () => inst.clone({
|
|
2891
|
-
...inst._zod.def,
|
|
2892
|
-
catchall: never()
|
|
2893
|
-
});
|
|
2894
|
-
inst.strip = () => inst.clone({
|
|
2895
|
-
...inst._zod.def,
|
|
2896
|
-
catchall: void 0
|
|
2897
|
-
});
|
|
2898
|
-
inst.extend = (incoming) => {
|
|
2899
|
-
return extend(inst, incoming);
|
|
2900
|
-
};
|
|
2901
|
-
inst.merge = (other) => merge(inst, other);
|
|
2902
|
-
inst.pick = (mask) => pick(inst, mask);
|
|
2903
|
-
inst.omit = (mask) => omit(inst, mask);
|
|
2904
|
-
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
2905
|
-
inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
|
|
2906
|
-
});
|
|
2907
|
-
function object(shape, params) {
|
|
2908
|
-
const def = {
|
|
2909
|
-
type: "object",
|
|
2910
|
-
get shape() {
|
|
2911
|
-
assignProp(this, "shape", { ...shape });
|
|
2912
|
-
return this.shape;
|
|
2913
|
-
},
|
|
2914
|
-
...normalizeParams(params)
|
|
2915
|
-
};
|
|
2916
|
-
return new ZodObject(def);
|
|
2917
|
-
}
|
|
2918
|
-
const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
2919
|
-
$ZodUnion.init(inst, def);
|
|
2920
|
-
ZodType.init(inst, def);
|
|
2921
|
-
inst.options = def.options;
|
|
2922
|
-
});
|
|
2923
|
-
function union(options, params) {
|
|
2924
|
-
return new ZodUnion({
|
|
2925
|
-
type: "union",
|
|
2926
|
-
options,
|
|
2927
|
-
...normalizeParams(params)
|
|
2928
|
-
});
|
|
2929
|
-
}
|
|
2930
|
-
const ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
2931
|
-
ZodUnion.init(inst, def);
|
|
2932
|
-
$ZodDiscriminatedUnion.init(inst, def);
|
|
2933
|
-
});
|
|
2934
|
-
function discriminatedUnion(discriminator, options, params) {
|
|
2935
|
-
return new ZodDiscriminatedUnion({
|
|
2936
|
-
type: "union",
|
|
2937
|
-
options,
|
|
2938
|
-
discriminator,
|
|
2939
|
-
...normalizeParams(params)
|
|
2940
|
-
});
|
|
2941
|
-
}
|
|
2942
|
-
const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
2943
|
-
$ZodIntersection.init(inst, def);
|
|
2944
|
-
ZodType.init(inst, def);
|
|
2945
|
-
});
|
|
2946
|
-
function intersection(left, right) {
|
|
2947
|
-
return new ZodIntersection({
|
|
2948
|
-
type: "intersection",
|
|
2949
|
-
left,
|
|
2950
|
-
right
|
|
2951
|
-
});
|
|
2952
|
-
}
|
|
2953
|
-
const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
2954
|
-
$ZodRecord.init(inst, def);
|
|
2955
|
-
ZodType.init(inst, def);
|
|
2956
|
-
inst.keyType = def.keyType;
|
|
2957
|
-
inst.valueType = def.valueType;
|
|
2958
|
-
});
|
|
2959
|
-
function record(keyType, valueType, params) {
|
|
2960
|
-
return new ZodRecord({
|
|
2961
|
-
type: "record",
|
|
2962
|
-
keyType,
|
|
2963
|
-
valueType,
|
|
2964
|
-
...normalizeParams(params)
|
|
2965
|
-
});
|
|
2966
|
-
}
|
|
2967
|
-
const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
2968
|
-
$ZodEnum.init(inst, def);
|
|
2969
|
-
ZodType.init(inst, def);
|
|
2970
|
-
inst.enum = def.entries;
|
|
2971
|
-
inst.options = Object.values(def.entries);
|
|
2972
|
-
const keys = new Set(Object.keys(def.entries));
|
|
2973
|
-
inst.extract = (values, params) => {
|
|
2974
|
-
const newEntries = {};
|
|
2975
|
-
for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
|
|
2976
|
-
else throw new Error(`Key ${value} not found in enum`);
|
|
2977
|
-
return new ZodEnum({
|
|
2978
|
-
...def,
|
|
2979
|
-
checks: [],
|
|
2980
|
-
...normalizeParams(params),
|
|
2981
|
-
entries: newEntries
|
|
2982
|
-
});
|
|
2983
|
-
};
|
|
2984
|
-
inst.exclude = (values, params) => {
|
|
2985
|
-
const newEntries = { ...def.entries };
|
|
2986
|
-
for (const value of values) if (keys.has(value)) delete newEntries[value];
|
|
2987
|
-
else throw new Error(`Key ${value} not found in enum`);
|
|
2988
|
-
return new ZodEnum({
|
|
2989
|
-
...def,
|
|
2990
|
-
checks: [],
|
|
2991
|
-
...normalizeParams(params),
|
|
2992
|
-
entries: newEntries
|
|
2993
|
-
});
|
|
2994
|
-
};
|
|
2995
|
-
});
|
|
2996
|
-
function _enum(values, params) {
|
|
2997
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
2998
|
-
return new ZodEnum({
|
|
2999
|
-
type: "enum",
|
|
3000
|
-
entries,
|
|
3001
|
-
...normalizeParams(params)
|
|
3002
|
-
});
|
|
3003
|
-
}
|
|
3004
|
-
const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
3005
|
-
$ZodLiteral.init(inst, def);
|
|
3006
|
-
ZodType.init(inst, def);
|
|
3007
|
-
inst.values = new Set(def.values);
|
|
3008
|
-
Object.defineProperty(inst, "value", { get() {
|
|
3009
|
-
if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
3010
|
-
return def.values[0];
|
|
3011
|
-
} });
|
|
3012
|
-
});
|
|
3013
|
-
function literal(value, params) {
|
|
3014
|
-
return new ZodLiteral({
|
|
3015
|
-
type: "literal",
|
|
3016
|
-
values: Array.isArray(value) ? value : [value],
|
|
3017
|
-
...normalizeParams(params)
|
|
3018
|
-
});
|
|
3019
|
-
}
|
|
3020
|
-
const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
3021
|
-
$ZodTransform.init(inst, def);
|
|
3022
|
-
ZodType.init(inst, def);
|
|
3023
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
3024
|
-
payload.addIssue = (issue$1) => {
|
|
3025
|
-
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
|
|
3026
|
-
else {
|
|
3027
|
-
const _issue = issue$1;
|
|
3028
|
-
if (_issue.fatal) _issue.continue = false;
|
|
3029
|
-
_issue.code ?? (_issue.code = "custom");
|
|
3030
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
3031
|
-
_issue.inst ?? (_issue.inst = inst);
|
|
3032
|
-
_issue.continue ?? (_issue.continue = true);
|
|
3033
|
-
payload.issues.push(issue(_issue));
|
|
3034
|
-
}
|
|
3035
|
-
};
|
|
3036
|
-
const output = def.transform(payload.value, payload);
|
|
3037
|
-
if (output instanceof Promise) return output.then((output$1) => {
|
|
3038
|
-
payload.value = output$1;
|
|
3039
|
-
return payload;
|
|
3040
|
-
});
|
|
3041
|
-
payload.value = output;
|
|
3042
|
-
return payload;
|
|
3043
|
-
};
|
|
3044
|
-
});
|
|
3045
|
-
function transform(fn) {
|
|
3046
|
-
return new ZodTransform({
|
|
3047
|
-
type: "transform",
|
|
3048
|
-
transform: fn
|
|
3049
|
-
});
|
|
3050
|
-
}
|
|
3051
|
-
const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
3052
|
-
$ZodOptional.init(inst, def);
|
|
3053
|
-
ZodType.init(inst, def);
|
|
3054
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3055
|
-
});
|
|
3056
|
-
function optional(innerType) {
|
|
3057
|
-
return new ZodOptional({
|
|
3058
|
-
type: "optional",
|
|
3059
|
-
innerType
|
|
3060
|
-
});
|
|
3061
|
-
}
|
|
3062
|
-
const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
3063
|
-
$ZodNullable.init(inst, def);
|
|
3064
|
-
ZodType.init(inst, def);
|
|
3065
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3066
|
-
});
|
|
3067
|
-
function nullable(innerType) {
|
|
3068
|
-
return new ZodNullable({
|
|
3069
|
-
type: "nullable",
|
|
3070
|
-
innerType
|
|
3071
|
-
});
|
|
3072
|
-
}
|
|
3073
|
-
const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
3074
|
-
$ZodDefault.init(inst, def);
|
|
3075
|
-
ZodType.init(inst, def);
|
|
3076
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3077
|
-
inst.removeDefault = inst.unwrap;
|
|
3078
|
-
});
|
|
3079
|
-
function _default(innerType, defaultValue) {
|
|
3080
|
-
return new ZodDefault({
|
|
3081
|
-
type: "default",
|
|
3082
|
-
innerType,
|
|
3083
|
-
get defaultValue() {
|
|
3084
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
3085
|
-
}
|
|
3086
|
-
});
|
|
3087
|
-
}
|
|
3088
|
-
const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
3089
|
-
$ZodPrefault.init(inst, def);
|
|
3090
|
-
ZodType.init(inst, def);
|
|
3091
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3092
|
-
});
|
|
3093
|
-
function prefault(innerType, defaultValue) {
|
|
3094
|
-
return new ZodPrefault({
|
|
3095
|
-
type: "prefault",
|
|
3096
|
-
innerType,
|
|
3097
|
-
get defaultValue() {
|
|
3098
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
3099
|
-
}
|
|
3100
|
-
});
|
|
3101
|
-
}
|
|
3102
|
-
const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
3103
|
-
$ZodNonOptional.init(inst, def);
|
|
3104
|
-
ZodType.init(inst, def);
|
|
3105
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3106
|
-
});
|
|
3107
|
-
function nonoptional(innerType, params) {
|
|
3108
|
-
return new ZodNonOptional({
|
|
3109
|
-
type: "nonoptional",
|
|
3110
|
-
innerType,
|
|
3111
|
-
...normalizeParams(params)
|
|
3112
|
-
});
|
|
3113
|
-
}
|
|
3114
|
-
const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
3115
|
-
$ZodCatch.init(inst, def);
|
|
3116
|
-
ZodType.init(inst, def);
|
|
3117
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3118
|
-
inst.removeCatch = inst.unwrap;
|
|
3119
|
-
});
|
|
3120
|
-
function _catch(innerType, catchValue) {
|
|
3121
|
-
return new ZodCatch({
|
|
3122
|
-
type: "catch",
|
|
3123
|
-
innerType,
|
|
3124
|
-
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
3125
|
-
});
|
|
3126
|
-
}
|
|
3127
|
-
const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
3128
|
-
$ZodPipe.init(inst, def);
|
|
3129
|
-
ZodType.init(inst, def);
|
|
3130
|
-
inst.in = def.in;
|
|
3131
|
-
inst.out = def.out;
|
|
3132
|
-
});
|
|
3133
|
-
function pipe(in_, out) {
|
|
3134
|
-
return new ZodPipe({
|
|
3135
|
-
type: "pipe",
|
|
3136
|
-
in: in_,
|
|
3137
|
-
out
|
|
3138
|
-
});
|
|
3139
|
-
}
|
|
3140
|
-
const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
3141
|
-
$ZodReadonly.init(inst, def);
|
|
3142
|
-
ZodType.init(inst, def);
|
|
3143
|
-
});
|
|
3144
|
-
function readonly(innerType) {
|
|
3145
|
-
return new ZodReadonly({
|
|
3146
|
-
type: "readonly",
|
|
3147
|
-
innerType
|
|
3148
|
-
});
|
|
3149
|
-
}
|
|
3150
|
-
const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
3151
|
-
$ZodCustom.init(inst, def);
|
|
3152
|
-
ZodType.init(inst, def);
|
|
3153
|
-
});
|
|
3154
|
-
function check(fn, params) {
|
|
3155
|
-
const ch = new $ZodCheck({
|
|
3156
|
-
check: "custom",
|
|
3157
|
-
...normalizeParams(params)
|
|
3158
|
-
});
|
|
3159
|
-
ch._zod.check = fn;
|
|
3160
|
-
return ch;
|
|
3161
|
-
}
|
|
3162
|
-
function refine(fn, _params = {}) {
|
|
3163
|
-
return _refine(ZodCustom, fn, _params);
|
|
3164
|
-
}
|
|
3165
|
-
function superRefine(fn, params) {
|
|
3166
|
-
const ch = check((payload) => {
|
|
3167
|
-
payload.addIssue = (issue$1) => {
|
|
3168
|
-
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
|
|
3169
|
-
else {
|
|
3170
|
-
const _issue = issue$1;
|
|
3171
|
-
if (_issue.fatal) _issue.continue = false;
|
|
3172
|
-
_issue.code ?? (_issue.code = "custom");
|
|
3173
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
3174
|
-
_issue.inst ?? (_issue.inst = ch);
|
|
3175
|
-
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
3176
|
-
payload.issues.push(issue(_issue));
|
|
3177
|
-
}
|
|
3178
|
-
};
|
|
3179
|
-
return fn(payload.value, payload);
|
|
3180
|
-
}, params);
|
|
3181
|
-
return ch;
|
|
3182
|
-
}
|
|
3183
|
-
|
|
3184
|
-
//#endregion
|
|
3185
|
-
//#region src/connectors/constants.ts
|
|
3186
|
-
const DEFAULT_PAGE_SIZE = 25;
|
|
3187
|
-
|
|
3188
|
-
//#endregion
|
|
3189
|
-
//#region src/connectors/responses.ts
|
|
3190
|
-
const getDefaultSuccessOperationResponse = (operationType) => {
|
|
3191
|
-
switch (operationType) {
|
|
3192
|
-
case "list": return {
|
|
3193
|
-
statusCode: 200,
|
|
3194
|
-
description: "The list of records was retrieved."
|
|
3195
|
-
};
|
|
3196
|
-
case "get": return {
|
|
3197
|
-
statusCode: 200,
|
|
3198
|
-
description: "The record with the given identifier was retrieved."
|
|
3199
|
-
};
|
|
3200
|
-
case "create": return {
|
|
3201
|
-
statusCode: 201,
|
|
3202
|
-
description: "The record was created successfully."
|
|
3203
|
-
};
|
|
3204
|
-
case "update": return {
|
|
3205
|
-
statusCode: 200,
|
|
3206
|
-
description: "The record was updated successfully."
|
|
3207
|
-
};
|
|
3208
|
-
case "delete": return {
|
|
3209
|
-
statusCode: 204,
|
|
3210
|
-
description: "The record was deleted successfully."
|
|
3211
|
-
};
|
|
3212
|
-
case "custom": return {
|
|
3213
|
-
statusCode: 200,
|
|
3214
|
-
description: "The operation was executed successfully."
|
|
3215
|
-
};
|
|
3216
|
-
case "unknown": return { statusCode: 200 };
|
|
3217
|
-
default: throw new Error(`Unknown operation type: ${operationType}`);
|
|
3218
|
-
}
|
|
3219
|
-
};
|
|
3220
|
-
const getDefaultErrorOperationResponses = () => {
|
|
3221
|
-
const defaultErrorStatusCodes = {
|
|
3222
|
-
400: {
|
|
3223
|
-
statusCode: 400,
|
|
3224
|
-
description: "Invalid request."
|
|
3225
|
-
},
|
|
3226
|
-
401: {
|
|
3227
|
-
statusCode: 401,
|
|
3228
|
-
description: "Unauthorized access."
|
|
3229
|
-
},
|
|
3230
|
-
403: {
|
|
3231
|
-
statusCode: 403,
|
|
3232
|
-
description: "Forbidden."
|
|
3233
|
-
},
|
|
3234
|
-
404: {
|
|
3235
|
-
statusCode: 404,
|
|
3236
|
-
description: "Resource not found."
|
|
3237
|
-
},
|
|
3238
|
-
500: {
|
|
3239
|
-
statusCode: 500,
|
|
3240
|
-
description: "Server error while executing the request."
|
|
3241
|
-
}
|
|
3242
|
-
};
|
|
3243
|
-
return defaultErrorStatusCodes;
|
|
3244
|
-
};
|
|
3245
|
-
|
|
3246
|
-
//#endregion
|
|
3247
|
-
//#region src/connectors/schemas.ts
|
|
3248
|
-
const BASE_AUTH_FIELD = {
|
|
3249
|
-
key: string(),
|
|
3250
|
-
label: string(),
|
|
3251
|
-
required: boolean().optional().default(false),
|
|
3252
|
-
secret: boolean().optional().default(false),
|
|
3253
|
-
readOnly: boolean().optional().default(false),
|
|
3254
|
-
placeholder: string().optional(),
|
|
3255
|
-
description: string().optional(),
|
|
3256
|
-
tooltip: string().optional()
|
|
3257
|
-
};
|
|
3258
|
-
const AUTHENTICATION_FIELD_SCHEMA = discriminatedUnion("type", [object({
|
|
3259
|
-
...BASE_AUTH_FIELD,
|
|
3260
|
-
type: _enum(["text", "password"])
|
|
3261
|
-
}), object({
|
|
3262
|
-
...BASE_AUTH_FIELD,
|
|
3263
|
-
type: literal("select"),
|
|
3264
|
-
options: object({
|
|
3265
|
-
value: string(),
|
|
3266
|
-
label: string()
|
|
3267
|
-
}).array()
|
|
3268
|
-
})]);
|
|
3269
|
-
const OPERATION_SCHEMA = object({
|
|
3270
|
-
operationId: string(),
|
|
3271
|
-
categories: string().array(),
|
|
3272
|
-
operationType: _enum([
|
|
3273
|
-
"list",
|
|
3274
|
-
"get",
|
|
3275
|
-
"create",
|
|
3276
|
-
"update",
|
|
3277
|
-
"delete",
|
|
3278
|
-
"custom",
|
|
3279
|
-
"unknown"
|
|
3280
|
-
]),
|
|
3281
|
-
schema: string().optional(),
|
|
3282
|
-
entrypointUrl: string().optional(),
|
|
3283
|
-
entrypointHttpMethod: string().optional(),
|
|
3284
|
-
description: string(),
|
|
3285
|
-
responses: object({
|
|
3286
|
-
statusCode: number(),
|
|
3287
|
-
description: string()
|
|
3288
|
-
}).array().optional(),
|
|
3289
|
-
inputs: object({
|
|
3290
|
-
name: string(),
|
|
3291
|
-
type: string(),
|
|
3292
|
-
required: boolean(),
|
|
3293
|
-
description: string(),
|
|
3294
|
-
in: string()
|
|
3295
|
-
}).array().optional(),
|
|
3296
|
-
cursor: object({
|
|
3297
|
-
enabled: boolean(),
|
|
3298
|
-
pageSize: number()
|
|
3299
|
-
}).optional(),
|
|
3300
|
-
compositeIdentifiers: object({
|
|
3301
|
-
enabled: boolean(),
|
|
3302
|
-
version: number().optional(),
|
|
3303
|
-
fields: object({
|
|
3304
|
-
targetFieldKey: string(),
|
|
3305
|
-
remote: string().optional(),
|
|
3306
|
-
components: string().array()
|
|
3307
|
-
}).array().optional()
|
|
3308
|
-
}).optional(),
|
|
3309
|
-
scheduledJobs: object({
|
|
3310
|
-
enabled: boolean(),
|
|
3311
|
-
type: _enum(["data_sync"]),
|
|
3312
|
-
schedule: string(),
|
|
3313
|
-
description: string(),
|
|
3314
|
-
requestParams: object({
|
|
3315
|
-
fields: string().array().optional(),
|
|
3316
|
-
expand: string().array().optional(),
|
|
3317
|
-
filter: record(string(), string()).optional()
|
|
3318
|
-
}).optional(),
|
|
3319
|
-
syncFilter: object({
|
|
3320
|
-
name: _enum(["updated_after", "created_after"]),
|
|
3321
|
-
initialLoopbackPeriod: string(),
|
|
3322
|
-
incrementalLoopbackPeriod: string()
|
|
3323
|
-
}).optional()
|
|
3324
|
-
}).array().optional(),
|
|
3325
|
-
fieldConfigs: object({
|
|
3326
|
-
targetFieldKey: string(),
|
|
3327
|
-
alias: string().optional(),
|
|
3328
|
-
expression: string(),
|
|
3329
|
-
type: _enum([
|
|
3330
|
-
"string",
|
|
3331
|
-
"number",
|
|
3332
|
-
"boolean",
|
|
3333
|
-
"datetime_string",
|
|
3334
|
-
"enum"
|
|
3335
|
-
]),
|
|
3336
|
-
custom: boolean().default(false),
|
|
3337
|
-
hidden: boolean().default(false),
|
|
3338
|
-
enumMapper: object({ matcher: _enum([
|
|
3339
|
-
"country_alpha2code_by_alpha2code",
|
|
3340
|
-
"country_alpha3code_by_alpha3code",
|
|
3341
|
-
"country_code_by_country_code",
|
|
3342
|
-
"country_name_by_country_name",
|
|
3343
|
-
"country_name_by_alpha3code",
|
|
3344
|
-
"country_name_by_alpha2code",
|
|
3345
|
-
"country_name_by_country_code",
|
|
3346
|
-
"country_alpha3code_by_alpha2code",
|
|
3347
|
-
"country_alpha3code_by_country_name",
|
|
3348
|
-
"country_alpha3code_by_country_code",
|
|
3349
|
-
"country_alpha2code_by_alpha3code",
|
|
3350
|
-
"country_alpha2code_by_country_name",
|
|
3351
|
-
"country_alpha2code_by_country_code",
|
|
3352
|
-
"country_code_by_alpha2code",
|
|
3353
|
-
"country_code_by_alpha3code",
|
|
3354
|
-
"country_code_by_country_name",
|
|
3355
|
-
"country_subdivisions_by_alpha2code",
|
|
3356
|
-
"country_subdivision_code_by_subdivision_name",
|
|
3357
|
-
"country_alpha2code_by_citizenship",
|
|
3358
|
-
"country_subdivision_name_by_subdivision_code"
|
|
3359
|
-
]).or(object({
|
|
3360
|
-
matchExpression: string(),
|
|
3361
|
-
value: string()
|
|
3362
|
-
}).array()) }).optional()
|
|
3363
|
-
}).array().optional(),
|
|
3364
|
-
steps: object({
|
|
3365
|
-
stepId: string(),
|
|
3366
|
-
description: string(),
|
|
3367
|
-
stepFunction: object({
|
|
3368
|
-
functionName: string(),
|
|
3369
|
-
version: string().optional(),
|
|
3370
|
-
parameters: record(string(), unknown())
|
|
3371
|
-
}),
|
|
3372
|
-
condition: string().optional(),
|
|
3373
|
-
ignoreError: boolean().optional()
|
|
3374
|
-
}).array(),
|
|
3375
|
-
result: string().or(record(string(), unknown())).optional()
|
|
3376
|
-
});
|
|
3377
|
-
const CONNECTOR_YAML_SCHEMA = object({
|
|
3378
|
-
StackOne: string(),
|
|
3379
|
-
info: object({
|
|
3380
|
-
title: string(),
|
|
3381
|
-
version: string(),
|
|
3382
|
-
key: string(),
|
|
3383
|
-
description: string().optional()
|
|
3384
|
-
}),
|
|
3385
|
-
baseUrl: string(),
|
|
3386
|
-
authentication: record(string(), object({
|
|
3387
|
-
type: string(),
|
|
3388
|
-
label: string(),
|
|
3389
|
-
authorization: __stackone_core.AUTHENTICATION_SCHEMA,
|
|
3390
|
-
environments: object({
|
|
3391
|
-
key: string(),
|
|
3392
|
-
name: string()
|
|
3393
|
-
}).array(),
|
|
3394
|
-
support: object({
|
|
3395
|
-
link: string(),
|
|
3396
|
-
description: string().optional()
|
|
3397
|
-
}),
|
|
3398
|
-
configFields: AUTHENTICATION_FIELD_SCHEMA.array().optional(),
|
|
3399
|
-
setupFields: AUTHENTICATION_FIELD_SCHEMA.array().optional(),
|
|
3400
|
-
testOperationsIds: string().array().optional()
|
|
3401
|
-
})).array().optional(),
|
|
3402
|
-
operations: OPERATION_SCHEMA.array().optional()
|
|
3403
|
-
});
|
|
3404
|
-
|
|
3405
|
-
//#endregion
|
|
3406
|
-
//#region src/connectors/parsers.ts
|
|
3407
|
-
function parseYamlConnector(yamlFileContents) {
|
|
3408
|
-
try {
|
|
3409
|
-
const yamlConnector = (0, yaml.parse)(yamlFileContents);
|
|
3410
|
-
const parsedYamlConnector = CONNECTOR_YAML_SCHEMA.parse(yamlConnector);
|
|
3411
|
-
const newJsonConnector = {
|
|
3412
|
-
title: parsedYamlConnector.info.title,
|
|
3413
|
-
version: parsedYamlConnector.info.version,
|
|
3414
|
-
key: parsedYamlConnector.info.key,
|
|
3415
|
-
description: parsedYamlConnector.info.description
|
|
3416
|
-
};
|
|
3417
|
-
const authentication = buildAuthenticationFromYaml(parsedYamlConnector);
|
|
3418
|
-
const baseRequestParams = {
|
|
3419
|
-
baseUrl: parsedYamlConnector.baseUrl,
|
|
3420
|
-
authentication: stripAuthenticationSetup(authentication)
|
|
3421
|
-
};
|
|
3422
|
-
const newOperations = buildOperationsFromYaml(parsedYamlConnector, baseRequestParams);
|
|
3423
|
-
newJsonConnector.operations = newOperations;
|
|
3424
|
-
newJsonConnector.authentication = authentication;
|
|
3425
|
-
if ((0, __stackone_utils.notMissing)(newOperations)) newJsonConnector.categories = getConnectorCategoriesFromOperations(Object.values(newOperations));
|
|
3426
|
-
return newJsonConnector;
|
|
3427
|
-
} catch (error) {
|
|
3428
|
-
throw new Error(`Error parsing YAML file: ${error.message}`);
|
|
3429
|
-
}
|
|
3430
|
-
}
|
|
3431
|
-
const stripAuthenticationSetup = (authentication) => {
|
|
3432
|
-
const result = {};
|
|
3433
|
-
for (const [key, value] of Object.entries(authentication)) if (value && typeof value === "object") {
|
|
3434
|
-
const { setupFields: _setupFields, configFields: _configFields, support: _support, testOperationsIds: _testOperationsIds,...rest } = value;
|
|
3435
|
-
result[key] = stripAuthenticationSetup(rest);
|
|
3436
|
-
} else result[key] = value;
|
|
3437
|
-
return result;
|
|
3438
|
-
};
|
|
3439
|
-
const getConnectorCategoriesFromOperations = (operations) => {
|
|
3440
|
-
const categoriesSet = operations.reduce((acc, op) => {
|
|
3441
|
-
for (const category of op.categories) acc.add(category);
|
|
3442
|
-
return acc;
|
|
3443
|
-
}, /* @__PURE__ */ new Set());
|
|
3444
|
-
return Array.from(categoriesSet);
|
|
3445
|
-
};
|
|
3446
|
-
const buildAuthenticationFromYaml = (parsedYamlConnector) => {
|
|
3447
|
-
const authentication = {};
|
|
3448
|
-
for (const auth of parsedYamlConnector.authentication ?? []) {
|
|
3449
|
-
const [authKey] = Object.keys(auth);
|
|
3450
|
-
const authConfig = auth[authKey].environments.reduce((acc, env) => {
|
|
3451
|
-
const { key, name } = env;
|
|
3452
|
-
const { environments: _envs,...authConfig$1 } = auth[authKey];
|
|
3453
|
-
acc[key] = {
|
|
3454
|
-
...authConfig$1,
|
|
3455
|
-
envKey: key,
|
|
3456
|
-
envName: name
|
|
3457
|
-
};
|
|
3458
|
-
return acc;
|
|
3459
|
-
}, {});
|
|
3460
|
-
authentication[authKey] = authConfig;
|
|
3461
|
-
}
|
|
3462
|
-
return authentication;
|
|
3463
|
-
};
|
|
3464
|
-
const buildOperationKey = (op) => {
|
|
3465
|
-
return op.entrypointUrl && op.entrypointHttpMethod ? `${op.entrypointHttpMethod.toUpperCase()} ${op.entrypointUrl}` : void 0;
|
|
3466
|
-
};
|
|
3467
|
-
const inferOperationKey = (op) => {
|
|
3468
|
-
return op.operationType === "list" ? `GET /${op.schema}` : `GET /${op.schema}/:id`;
|
|
3469
|
-
};
|
|
3470
|
-
const inferEntrypointUrl = (op) => {
|
|
3471
|
-
return op.operationType === "list" ? `/${op.schema}` : `/${op.schema}/:id`;
|
|
3472
|
-
};
|
|
3473
|
-
const buildOperationResponses = (op) => {
|
|
3474
|
-
const defaultOperationResponses = {
|
|
3475
|
-
success: getDefaultSuccessOperationResponse(op.operationType),
|
|
3476
|
-
errors: getDefaultErrorOperationResponses()
|
|
3477
|
-
};
|
|
3478
|
-
const operationResponses = op.responses?.reduce((acc, response) => {
|
|
3479
|
-
const isSuccess = (0, __stackone_transport.isSuccessStatusCode)(response.statusCode);
|
|
3480
|
-
if (isSuccess) acc.success = {
|
|
3481
|
-
statusCode: response.statusCode,
|
|
3482
|
-
description: response.description
|
|
3483
|
-
};
|
|
3484
|
-
else acc.errors[response.statusCode] = {
|
|
3485
|
-
statusCode: response.statusCode,
|
|
3486
|
-
description: response.description
|
|
3487
|
-
};
|
|
3488
|
-
return acc;
|
|
3489
|
-
}, defaultOperationResponses);
|
|
3490
|
-
return operationResponses ?? defaultOperationResponses;
|
|
3491
|
-
};
|
|
3492
|
-
const buildOperationsFromYaml = (parsedYamlConnector, baseRequestParams) => {
|
|
3493
|
-
const newOperations = parsedYamlConnector.operations?.reduce((acc, op) => {
|
|
3494
|
-
const operationKey = buildOperationKey(op);
|
|
3495
|
-
const inferredOperationKey = inferOperationKey(op);
|
|
3496
|
-
const inferredEntrypointUrl = inferEntrypointUrl(op);
|
|
3497
|
-
const operationResponses = buildOperationResponses(op);
|
|
3498
|
-
const cursorConfig = buildCursorConfig(op);
|
|
3499
|
-
const inputs = op.inputs || [];
|
|
3500
|
-
if (cursorConfig.enabled) inputs?.push({
|
|
3501
|
-
type: "string",
|
|
3502
|
-
name: "page_size",
|
|
3503
|
-
in: "query",
|
|
3504
|
-
required: false,
|
|
3505
|
-
description: "Number of items to return per page"
|
|
3506
|
-
});
|
|
3507
|
-
acc[operationKey ?? inferredOperationKey] = {
|
|
3508
|
-
id: op.operationId,
|
|
3509
|
-
categories: op.categories,
|
|
3510
|
-
description: op.description,
|
|
3511
|
-
operationType: op.operationType,
|
|
3512
|
-
entrypointUrl: op.entrypointUrl ?? inferredEntrypointUrl,
|
|
3513
|
-
entrypointHttpMethod: op.entrypointHttpMethod ?? "get",
|
|
3514
|
-
responses: operationResponses,
|
|
3515
|
-
cursor: cursorConfig,
|
|
3516
|
-
compositeIdentifiers: parseCompositeIdentifiersConfig(op),
|
|
3517
|
-
scheduledJobs: parseScheduledJobConfig(op),
|
|
3518
|
-
inputs,
|
|
3519
|
-
steps: op.steps.reduce((acc$1, step) => {
|
|
3520
|
-
acc$1[step.stepId] = {
|
|
3521
|
-
id: step.stepId,
|
|
3522
|
-
description: step.description,
|
|
3523
|
-
condition: step.condition,
|
|
3524
|
-
ignoreError: step.ignoreError,
|
|
3525
|
-
stepFunction: {
|
|
3526
|
-
functionName: step.stepFunction.functionName,
|
|
3527
|
-
version: step.stepFunction.version,
|
|
3528
|
-
params: {
|
|
3529
|
-
...step.stepFunction.parameters,
|
|
3530
|
-
...getDefaultRequestStepFunctionsParams(step.stepFunction.functionName, baseRequestParams, step.stepFunction.parameters),
|
|
3531
|
-
...step.stepFunction.functionName === "map_fields" || step.stepFunction.functionName === "typecast" ? { fields: op.fieldConfigs } : {}
|
|
3532
|
-
}
|
|
3533
|
-
}
|
|
3534
|
-
};
|
|
3535
|
-
return acc$1;
|
|
3536
|
-
}, {}),
|
|
3537
|
-
result: op.result
|
|
3538
|
-
};
|
|
3539
|
-
return acc;
|
|
3540
|
-
}, {});
|
|
3541
|
-
return newOperations;
|
|
3542
|
-
};
|
|
3543
|
-
const parseOperationInputs = (operation, inputs) => {
|
|
3544
|
-
if (!operation.inputs) return {};
|
|
3545
|
-
const inputSchema = createSchemaByFieldLocation(operation.inputs);
|
|
3546
|
-
const parsedInputs = inputSchema.parse(inputs);
|
|
3547
|
-
return {
|
|
3548
|
-
...parsedInputs.headers ?? {},
|
|
3549
|
-
...parsedInputs.query ?? {},
|
|
3550
|
-
...parsedInputs.path ?? {},
|
|
3551
|
-
...parsedInputs.body ?? {}
|
|
3552
|
-
};
|
|
3553
|
-
};
|
|
3554
|
-
const createDynamicSchema = (fields) => {
|
|
3555
|
-
const schemaObj = {};
|
|
3556
|
-
fields.forEach((field) => {
|
|
3557
|
-
let fieldSchema;
|
|
3558
|
-
switch (field.type.toLowerCase()) {
|
|
3559
|
-
case "string":
|
|
3560
|
-
fieldSchema = string();
|
|
3561
|
-
break;
|
|
3562
|
-
case "number":
|
|
3563
|
-
fieldSchema = number();
|
|
3564
|
-
break;
|
|
3565
|
-
case "boolean":
|
|
3566
|
-
fieldSchema = boolean();
|
|
3567
|
-
break;
|
|
3568
|
-
default: fieldSchema = any();
|
|
3569
|
-
}
|
|
3570
|
-
schemaObj[field.name] = field.required ? fieldSchema : fieldSchema.optional();
|
|
3571
|
-
});
|
|
3572
|
-
return object(schemaObj);
|
|
3573
|
-
};
|
|
3574
|
-
const createSchemaByFieldLocation = (fields) => {
|
|
3575
|
-
const pathFields = fields.filter((field) => field.in === "path");
|
|
3576
|
-
const queryFields = fields.filter((field) => field.in === "query");
|
|
3577
|
-
const bodyFields = fields.filter((field) => field.in === "body");
|
|
3578
|
-
const headersFields = fields.filter((field) => field.in === "headers");
|
|
3579
|
-
return object({
|
|
3580
|
-
path: createDynamicSchema(pathFields).optional(),
|
|
3581
|
-
query: createDynamicSchema(queryFields).optional(),
|
|
3582
|
-
body: createDynamicSchema(bodyFields).optional(),
|
|
3583
|
-
headers: createDynamicSchema(headersFields).optional()
|
|
3584
|
-
});
|
|
3585
|
-
};
|
|
3586
|
-
const buildCursorConfig = (op) => {
|
|
3587
|
-
const isListOperation = op.operationType === "list";
|
|
3588
|
-
const cursorConfig = op.cursor ?? {
|
|
3589
|
-
enabled: isListOperation,
|
|
3590
|
-
pageSize: DEFAULT_PAGE_SIZE
|
|
3591
|
-
};
|
|
3592
|
-
return {
|
|
3593
|
-
enabled: cursorConfig.enabled && isListOperation,
|
|
3594
|
-
pageSize: cursorConfig.pageSize
|
|
3595
|
-
};
|
|
3596
|
-
};
|
|
3597
|
-
const parseCompositeIdentifiersConfig = (op) => {
|
|
3598
|
-
if ((0, __stackone_utils.isMissing)(op.compositeIdentifiers)) {
|
|
3599
|
-
const identifierFieldConfig = op.fieldConfigs?.find((fieldConfig) => fieldConfig.targetFieldKey === "id");
|
|
3600
|
-
const defaultIdentifierFields = (0, __stackone_utils.notMissing)(identifierFieldConfig) ? [{
|
|
3601
|
-
targetFieldKey: identifierFieldConfig.targetFieldKey,
|
|
3602
|
-
remote: "id",
|
|
3603
|
-
components: [{
|
|
3604
|
-
name: identifierFieldConfig.targetFieldKey,
|
|
3605
|
-
alias: identifierFieldConfig.alias
|
|
3606
|
-
}]
|
|
3607
|
-
}] : void 0;
|
|
3608
|
-
return {
|
|
3609
|
-
enabled: true,
|
|
3610
|
-
version: __stackone_core.COMPOSITE_ID_LATEST_VERSION,
|
|
3611
|
-
fields: defaultIdentifierFields
|
|
3612
|
-
};
|
|
3613
|
-
}
|
|
3614
|
-
const mappedFields = [];
|
|
3615
|
-
for (const field of op.compositeIdentifiers?.fields ?? []) {
|
|
3616
|
-
const fieldComponents = field.components.map((component) => {
|
|
3617
|
-
const componentDetail = op.fieldConfigs?.find((fieldConfig) => fieldConfig.targetFieldKey === component);
|
|
3618
|
-
return {
|
|
3619
|
-
name: component,
|
|
3620
|
-
alias: componentDetail?.alias
|
|
3621
|
-
};
|
|
3622
|
-
});
|
|
3623
|
-
mappedFields.push({
|
|
3624
|
-
targetFieldKey: field.targetFieldKey,
|
|
3625
|
-
remote: field.remote,
|
|
3626
|
-
components: fieldComponents
|
|
3627
|
-
});
|
|
3628
|
-
}
|
|
3629
|
-
return {
|
|
3630
|
-
enabled: op.compositeIdentifiers.enabled,
|
|
3631
|
-
version: op.compositeIdentifiers.version,
|
|
3632
|
-
fields: mappedFields.length > 0 ? mappedFields : void 0
|
|
3633
|
-
};
|
|
3634
|
-
};
|
|
3635
|
-
const parseScheduledJobConfig = (op) => {
|
|
3636
|
-
if ((0, __stackone_utils.isMissing)(op.scheduledJobs)) return void 0;
|
|
3637
|
-
return op.scheduledJobs;
|
|
3638
|
-
};
|
|
3639
|
-
const getDefaultRequestStepFunctionsParams = (stepFunctionName, baseRequestParams, functionParams = {}) => {
|
|
3640
|
-
if (stepFunctionName === "request" || stepFunctionName === "paginated_request") {
|
|
3641
|
-
const defaultCustomErrors = [{
|
|
3642
|
-
receivedStatus: 500,
|
|
3643
|
-
targetStatus: 502
|
|
3644
|
-
}];
|
|
3645
|
-
const functionCustomErrors = functionParams.customErrors && Array.isArray(functionParams.customErrors) ? functionParams.customErrors : [];
|
|
3646
|
-
const mergedCustomErrors = [...functionCustomErrors, ...defaultCustomErrors];
|
|
3647
|
-
return {
|
|
3648
|
-
...baseRequestParams,
|
|
3649
|
-
customErrors: mergedCustomErrors
|
|
3650
|
-
};
|
|
3651
|
-
} else return {};
|
|
3652
|
-
};
|
|
3653
|
-
|
|
3654
|
-
//#endregion
|
|
3655
|
-
//#region src/connectors/validators.ts
|
|
3656
|
-
const validateYamlConnector = (yamlFileContents) => {
|
|
3657
|
-
try {
|
|
3658
|
-
const errors = [];
|
|
3659
|
-
const yamlConnector = (0, yaml.parse)(yamlFileContents);
|
|
3660
|
-
const parsedYamlConnector = CONNECTOR_YAML_SCHEMA.safeParse(yamlConnector);
|
|
3661
|
-
if (!parsedYamlConnector.success) parsedYamlConnector.error.issues.forEach((issue$1) => {
|
|
3662
|
-
const lineNumber = getErrorLineNumber(issue$1.path, yamlFileContents);
|
|
3663
|
-
errors.push({
|
|
3664
|
-
line: lineNumber,
|
|
3665
|
-
message: issue$1.message,
|
|
3666
|
-
field: issue$1.path.join(".")
|
|
3667
|
-
});
|
|
3668
|
-
});
|
|
3669
|
-
return errors.length > 0 ? {
|
|
3670
|
-
success: false,
|
|
3671
|
-
errors
|
|
3672
|
-
} : { success: true };
|
|
3673
|
-
} catch (error) {
|
|
3674
|
-
const errorMsg = error.message;
|
|
3675
|
-
const lineMatch = errorMsg.match(/at line (\d+)/);
|
|
3676
|
-
const lineNumber = lineMatch ? parseInt(lineMatch[1], 10) : 1;
|
|
3677
|
-
return {
|
|
3678
|
-
success: false,
|
|
3679
|
-
errors: [{
|
|
3680
|
-
line: lineNumber,
|
|
3681
|
-
message: "The YAML connector file is not valid. Please check the syntax and structure.",
|
|
3682
|
-
field: void 0
|
|
3683
|
-
}]
|
|
3684
|
-
};
|
|
3685
|
-
}
|
|
3686
|
-
};
|
|
3687
|
-
const getErrorLineNumber = (path, yamlFileContents) => {
|
|
3688
|
-
const yamlLines = yamlFileContents.split("\n");
|
|
3689
|
-
let pathIdx = 0;
|
|
3690
|
-
let lastIndentationLevel = -1;
|
|
3691
|
-
let lastLine = 0;
|
|
3692
|
-
for (let lineNumber = 0; lineNumber < yamlLines.length; lineNumber++) {
|
|
3693
|
-
const line = yamlLines[lineNumber];
|
|
3694
|
-
const indentationLevel = line.match(/^(\s*)/)?.[1]?.length || 0;
|
|
3695
|
-
const trimmedLine = line.replace("- ", "").trim();
|
|
3696
|
-
if (trimmedLine.startsWith("#") || trimmedLine === "") continue;
|
|
3697
|
-
if (indentationLevel <= lastIndentationLevel) continue;
|
|
3698
|
-
const currentPathText = (0, __stackone_utils.notMissing)(path[pathIdx]) ? `${String(path[pathIdx])}` : "";
|
|
3699
|
-
if ((0, __stackone_utils.isMissing)(currentPathText)) return lastLine + 1;
|
|
3700
|
-
if (!isNaN(Number(currentPathText))) {
|
|
3701
|
-
const posToFind = parseInt(currentPathText, 10);
|
|
3702
|
-
let currentPos = -1;
|
|
3703
|
-
for (let lineNumber2 = lineNumber; lineNumber2 < yamlLines.length; lineNumber2++) {
|
|
3704
|
-
const line$1 = yamlLines[lineNumber2];
|
|
3705
|
-
const trimmedLine$1 = line$1.trim();
|
|
3706
|
-
if (trimmedLine$1.startsWith("-")) currentPos++;
|
|
3707
|
-
if (currentPos === posToFind) {
|
|
3708
|
-
pathIdx++;
|
|
3709
|
-
lastLine = lineNumber;
|
|
3710
|
-
lineNumber--;
|
|
3711
|
-
break;
|
|
3712
|
-
} else lineNumber++;
|
|
3713
|
-
}
|
|
3714
|
-
} else if (trimmedLine.startsWith(`${currentPathText}:`)) if (pathIdx === path.length - 1) return lineNumber + 1;
|
|
3715
|
-
else {
|
|
3716
|
-
lastIndentationLevel = indentationLevel;
|
|
3717
|
-
lastLine = lineNumber;
|
|
3718
|
-
pathIdx++;
|
|
3719
|
-
}
|
|
3720
|
-
}
|
|
3721
|
-
return lastLine + 1;
|
|
3722
|
-
};
|
|
3723
|
-
|
|
3724
|
-
//#endregion
|
|
3725
|
-
//#region src/errors/connectSDKErrors.ts
|
|
3726
|
-
var ConnectSDKError = class ConnectSDKError extends Error {
|
|
3727
|
-
errorType;
|
|
3728
|
-
context;
|
|
3729
|
-
constructor(errorType, context, message) {
|
|
3730
|
-
super(message);
|
|
3731
|
-
this.name = "ConnectSDKError";
|
|
3732
|
-
this.errorType = errorType;
|
|
3733
|
-
this.context = context;
|
|
3734
|
-
if (Error.captureStackTrace) Error.captureStackTrace(this, ConnectSDKError);
|
|
3735
|
-
}
|
|
3736
|
-
toString() {
|
|
3737
|
-
return `${this.name} [${this.errorType}]: ${this.message}`;
|
|
3738
|
-
}
|
|
3739
|
-
};
|
|
3740
|
-
var ConnectorParseError = class extends ConnectSDKError {
|
|
3741
|
-
constructor(context, message) {
|
|
3742
|
-
super("CONNECTOR_PARSE_ERROR", context, message);
|
|
3743
|
-
this.name = "ConnectorParseError";
|
|
3744
|
-
}
|
|
3745
|
-
};
|
|
3746
|
-
var MissingOperationError = class extends ConnectSDKError {
|
|
3747
|
-
constructor(context, message) {
|
|
3748
|
-
super("MISSING_OPERATION_ERROR", context, message);
|
|
3749
|
-
this.name = "MissingOperationError";
|
|
3750
|
-
}
|
|
3751
|
-
};
|
|
3752
|
-
var InvalidOperationInputsError = class extends ConnectSDKError {
|
|
3753
|
-
constructor(context, message) {
|
|
3754
|
-
super("INVALID_OPERATION_INPUTS_ERROR", context, message);
|
|
3755
|
-
this.name = "InvalidOperationInputsError";
|
|
3756
|
-
}
|
|
3757
|
-
};
|
|
3758
|
-
var InvalidCursorError = class extends ConnectSDKError {
|
|
3759
|
-
constructor(context, message) {
|
|
3760
|
-
super("INVALID_CURSOR_ERROR", context, message);
|
|
3761
|
-
this.name = "InvalidCursorError";
|
|
3762
|
-
}
|
|
3763
|
-
};
|
|
3764
|
-
|
|
3765
|
-
//#endregion
|
|
3766
|
-
//#region src/runners/executeStepFunctions.ts
|
|
3767
|
-
const executeStepFunction = async ({ block, stepFunctionName, params, buildStepFunction = __stackone_core.StepFunctionsFactory.build }) => {
|
|
3768
|
-
const stepFunction = buildStepFunction({ functionName: stepFunctionName }).fn;
|
|
3769
|
-
const result = await stepFunction({
|
|
3770
|
-
block,
|
|
3771
|
-
params
|
|
3772
|
-
});
|
|
3773
|
-
const stepSnaphot = stepFunctionName === __stackone_core.StepFunctionName.MAP_FIELDS ? { [__stackone_core.StepFunctionName.MAP_FIELDS.toString()]: {
|
|
3774
|
-
output: { data: result.block.result },
|
|
3775
|
-
errors: result.errors,
|
|
3776
|
-
successful: result.successful
|
|
3777
|
-
} } : {};
|
|
3778
|
-
return {
|
|
3779
|
-
...result.block,
|
|
3780
|
-
steps: {
|
|
3781
|
-
...result?.block?.steps ?? {},
|
|
3782
|
-
...stepSnaphot
|
|
3783
|
-
}
|
|
3784
|
-
};
|
|
3785
|
-
};
|
|
3786
|
-
|
|
3787
|
-
//#endregion
|
|
3788
|
-
//#region src/blocks/createBlockContext.ts
|
|
3789
|
-
const createBlockContext = ({ category, connectorKey, connectorVersion, authConfigKey, environment = "production", operation, accountSecureId, projectSecureId }) => {
|
|
3790
|
-
return {
|
|
3791
|
-
projectSecureId,
|
|
3792
|
-
accountSecureId,
|
|
3793
|
-
connectorKey,
|
|
3794
|
-
connectorVersion,
|
|
3795
|
-
category,
|
|
3796
|
-
service: "",
|
|
3797
|
-
resource: "",
|
|
3798
|
-
schema: operation?.schema?.key,
|
|
3799
|
-
operationType: operation?.operationType ?? "unknown",
|
|
3800
|
-
authenticationType: authConfigKey,
|
|
3801
|
-
environment
|
|
3802
|
-
};
|
|
3803
|
-
};
|
|
3804
|
-
|
|
3805
|
-
//#endregion
|
|
3806
|
-
//#region src/compositeIds/inputs.ts
|
|
3807
|
-
const decodeInputCompositeIdentifiers = (block) => {
|
|
3808
|
-
const compositeIdsConfig = block.operation?.compositeIdentifiers;
|
|
3809
|
-
const blockInputs = { ...block.inputs ?? {} };
|
|
3810
|
-
if (!compositeIdsConfig?.enabled || (0, __stackone_utils.isMissing)(blockInputs)) return block;
|
|
3811
|
-
const aliases = compositeIdsConfig.fields?.reduce((acc, field) => {
|
|
3812
|
-
field.components.forEach((component) => {
|
|
3813
|
-
if (component.alias) acc[component.name] = component.alias;
|
|
3814
|
-
});
|
|
3815
|
-
return acc;
|
|
3816
|
-
}, {});
|
|
3817
|
-
const identifierConfig = {
|
|
3818
|
-
version: compositeIdsConfig.version ?? __stackone_core.COMPOSITE_ID_LATEST_VERSION,
|
|
3819
|
-
aliases
|
|
3820
|
-
};
|
|
3821
|
-
processLevel(blockInputs, identifierConfig, block.logger);
|
|
3822
|
-
return {
|
|
3823
|
-
...block,
|
|
3824
|
-
inputs: blockInputs
|
|
3825
|
-
};
|
|
3826
|
-
};
|
|
3827
|
-
const processLevel = (input, compositeIdentifierConfig, logger) => {
|
|
3828
|
-
for (const key in input) {
|
|
3829
|
-
const value = input[key];
|
|
3830
|
-
if (typeof value === "string" || Array.isArray(value) && value.every((item) => typeof item === "string")) processCompositeId(value, key, input, compositeIdentifierConfig, logger);
|
|
3831
|
-
else if (Array.isArray(value)) for (const item of value) processLevel(item, compositeIdentifierConfig, logger);
|
|
3832
|
-
else if (typeof value === "object" && value !== null) processLevel(value, compositeIdentifierConfig, logger);
|
|
3833
|
-
}
|
|
3834
|
-
};
|
|
3835
|
-
const processInputElements = (inputArray, key, compositeIdentifierConfig, logger) => {
|
|
3836
|
-
const compositeIdComponents = [];
|
|
3837
|
-
const nonCompositeIds = [];
|
|
3838
|
-
for (const inputElement of inputArray) try {
|
|
3839
|
-
const extractedComponents = (0, __stackone_core.decodeCompositeId)(inputElement, compositeIdentifierConfig);
|
|
3840
|
-
compositeIdComponents.push(extractedComponents);
|
|
3841
|
-
} catch (e) {
|
|
3842
|
-
logger?.debug({
|
|
3843
|
-
message: `Received ${key} with invalid composite ID, assuming it is not a composite ID`,
|
|
3844
|
-
category: "processCompositeId",
|
|
3845
|
-
context: {
|
|
3846
|
-
key,
|
|
3847
|
-
inputElement,
|
|
3848
|
-
compositeIdentifierConfig,
|
|
3849
|
-
error: e
|
|
3850
|
-
}
|
|
3851
|
-
});
|
|
3852
|
-
nonCompositeIds.push(inputElement);
|
|
3853
|
-
}
|
|
3854
|
-
return {
|
|
3855
|
-
compositeIdComponents,
|
|
3856
|
-
nonCompositeIds
|
|
3857
|
-
};
|
|
3858
|
-
};
|
|
3859
|
-
const setDecodedIds = (parentRecord, key, compositeIdComponents, isInputArray) => {
|
|
3860
|
-
const multipleIdsComponents = compositeIdComponents.filter((component) => Object.keys(component).length > 1);
|
|
3861
|
-
if (multipleIdsComponents.length > 0) parentRecord.decoded_ids = {
|
|
3862
|
-
...parentRecord.decoded_ids ?? {},
|
|
3863
|
-
[key]: isInputArray ? multipleIdsComponents : multipleIdsComponents[0]
|
|
3864
|
-
};
|
|
3865
|
-
};
|
|
3866
|
-
const shouldSimplifyComponent = (component) => {
|
|
3867
|
-
const values = Object.values(component);
|
|
3868
|
-
return values.length === 1 && (typeof values[0] === "string" || typeof values[0] === "number");
|
|
3869
|
-
};
|
|
3870
|
-
const setSimplifiedIds = (parentRecord, key, compositeIdComponents, nonCompositeIds, isInputArray) => {
|
|
3871
|
-
if (!compositeIdComponents.every(shouldSimplifyComponent)) return;
|
|
3872
|
-
if (isInputArray) parentRecord[key] = [...compositeIdComponents.map((component) => Object.values(component)[0]), ...nonCompositeIds];
|
|
3873
|
-
else if (compositeIdComponents.length > 0) parentRecord[key] = Object.values(compositeIdComponents[0])[0];
|
|
3874
|
-
};
|
|
3875
|
-
const handleCompositeIdError = (error, key, logger) => {
|
|
3876
|
-
if (error instanceof __stackone_core.CoreError && error.type === "COMPOSITE_ID_MISSING_HEADER_ERROR") logger?.debug({ message: `Received ${key} with no composite ID header, assuming it is not a composite ID` });
|
|
3877
|
-
else logger?.warning({
|
|
3878
|
-
message: `Error processing composite ID for ${key}, ignoring it`,
|
|
3879
|
-
error
|
|
3880
|
-
});
|
|
3881
|
-
};
|
|
3882
|
-
const processCompositeId = (input, key, parentRecord, compositeIdentifierConfig, logger) => {
|
|
3883
|
-
try {
|
|
3884
|
-
const isInputArray = Array.isArray(input);
|
|
3885
|
-
const inputArray = isInputArray ? input : [input];
|
|
3886
|
-
if (inputArray.length === 0) return;
|
|
3887
|
-
const { compositeIdComponents, nonCompositeIds } = processInputElements(inputArray, key, compositeIdentifierConfig, logger);
|
|
3888
|
-
setDecodedIds(parentRecord, key, compositeIdComponents, isInputArray);
|
|
3889
|
-
setSimplifiedIds(parentRecord, key, compositeIdComponents, nonCompositeIds, isInputArray);
|
|
3890
|
-
} catch (e) {
|
|
3891
|
-
handleCompositeIdError(e, key, logger);
|
|
3892
|
-
}
|
|
3893
|
-
};
|
|
3894
|
-
|
|
3895
|
-
//#endregion
|
|
3896
|
-
//#region src/compositeIds/outputs.ts
|
|
3897
|
-
const REMOTE_FIELD_PREFIX = "remote_";
|
|
3898
|
-
const encodeResultCompositeIdentifiers = (block) => {
|
|
3899
|
-
const compositeIdsConfig = block.operation?.compositeIdentifiers;
|
|
3900
|
-
if (!compositeIdsConfig?.enabled) return block;
|
|
3901
|
-
const outputDataKey = "data";
|
|
3902
|
-
const dataOutput = block.outputs?.[outputDataKey];
|
|
3903
|
-
if ((0, __stackone_utils.isMissing)(dataOutput)) return block;
|
|
3904
|
-
const newData = Array.isArray(dataOutput) ? dataOutput.map((item) => mapCompositeIds(item, compositeIdsConfig)) : mapCompositeIds(dataOutput, compositeIdsConfig);
|
|
3905
|
-
return {
|
|
3906
|
-
...block,
|
|
3907
|
-
outputs: {
|
|
3908
|
-
...block.outputs ?? {},
|
|
3909
|
-
[outputDataKey]: newData
|
|
3910
|
-
}
|
|
3911
|
-
};
|
|
3912
|
-
};
|
|
3913
|
-
const mapCompositeIds = (data, config$1) => {
|
|
3914
|
-
const dataEncodedFromConfig = mapConfiguredCompositeIds(data, config$1);
|
|
3915
|
-
const encodedData = mapCompositeIdsFromInference(dataEncodedFromConfig);
|
|
3916
|
-
return {
|
|
3917
|
-
...data,
|
|
3918
|
-
...(0, __stackone_utils.isObject)(encodedData) ? encodedData : {}
|
|
3919
|
-
};
|
|
3920
|
-
};
|
|
3921
|
-
const mapConfiguredCompositeIds = (data, config$1) => {
|
|
3922
|
-
const version$1 = config$1.version ?? __stackone_core.COMPOSITE_ID_LATEST_VERSION;
|
|
3923
|
-
const newData = {};
|
|
3924
|
-
config$1.fields?.forEach((field) => {
|
|
3925
|
-
const aliasesMap = {};
|
|
3926
|
-
const components = [];
|
|
3927
|
-
field.components.forEach((component) => {
|
|
3928
|
-
if (component.alias) aliasesMap[component.name] = component.alias;
|
|
3929
|
-
components.push({
|
|
3930
|
-
key: component.name,
|
|
3931
|
-
value: data[component.name]
|
|
3932
|
-
});
|
|
3933
|
-
});
|
|
3934
|
-
const identifier = components.length === 1 ? components[0] : { identifiers: components };
|
|
3935
|
-
const idConfig = {
|
|
3936
|
-
version: version$1,
|
|
3937
|
-
aliases: Object.keys(aliasesMap).length > 0 ? aliasesMap : void 0
|
|
3938
|
-
};
|
|
3939
|
-
const compositeId = (0, __stackone_core.encodeCompositeId)(identifier, idConfig);
|
|
3940
|
-
newData[field.targetFieldKey] = compositeId;
|
|
3941
|
-
if (field.remote) newData[`${REMOTE_FIELD_PREFIX}${field.remote}`] = data[field.remote];
|
|
3942
|
-
});
|
|
3943
|
-
return {
|
|
3944
|
-
...data,
|
|
3945
|
-
...newData
|
|
3946
|
-
};
|
|
3947
|
-
};
|
|
3948
|
-
const isIdField = (key) => {
|
|
3949
|
-
return key === "id" || /.+_id(s)?$/.test(key);
|
|
3950
|
-
};
|
|
3951
|
-
const isValidStringArray = (value) => {
|
|
3952
|
-
return Array.isArray(value) && value.every((v) => (0, __stackone_utils.isString)(v) && v.length > 0);
|
|
3953
|
-
};
|
|
3954
|
-
const shouldSkipEncoding = (value, key) => {
|
|
3955
|
-
return (0, __stackone_core.isCompositeId)(value) || key.startsWith(REMOTE_FIELD_PREFIX);
|
|
3956
|
-
};
|
|
3957
|
-
const encodeStringValue = (key, value) => {
|
|
3958
|
-
try {
|
|
3959
|
-
return (0, __stackone_core.encodeCompositeId)({
|
|
3960
|
-
key,
|
|
3961
|
-
value
|
|
3962
|
-
}, { version: __stackone_core.COMPOSITE_ID_LATEST_VERSION });
|
|
3963
|
-
} catch {
|
|
3964
|
-
return value;
|
|
3965
|
-
}
|
|
3966
|
-
};
|
|
3967
|
-
const processStringArrayField = (key, value, result) => {
|
|
3968
|
-
const encodedArray = value.map((v) => {
|
|
3969
|
-
if ((0, __stackone_utils.isString)(v) && v.length > 0 && !(0, __stackone_core.isCompositeId)(v)) return encodeStringValue(key, v);
|
|
3970
|
-
return v;
|
|
3971
|
-
});
|
|
3972
|
-
result[key] = encodedArray;
|
|
3973
|
-
result[`${REMOTE_FIELD_PREFIX}${key}`] = value;
|
|
3974
|
-
};
|
|
3975
|
-
const processStringField = (key, value, result) => {
|
|
3976
|
-
if (shouldSkipEncoding(value, key)) return;
|
|
3977
|
-
const compositeId = (0, __stackone_core.encodeCompositeId)({
|
|
3978
|
-
key,
|
|
3979
|
-
value
|
|
3980
|
-
}, { version: __stackone_core.COMPOSITE_ID_LATEST_VERSION });
|
|
3981
|
-
result[key] = compositeId;
|
|
3982
|
-
result[`remote_${key}`] = value;
|
|
3983
|
-
};
|
|
3984
|
-
const processIdField = (key, value, result) => {
|
|
3985
|
-
if (isValidStringArray(value)) processStringArrayField(key, value, result);
|
|
3986
|
-
else if ((0, __stackone_utils.isString)(value) && value.length > 0) processStringField(key, value, result);
|
|
3987
|
-
};
|
|
3988
|
-
const mapCompositeIdsFromInference = (data) => {
|
|
3989
|
-
if (Array.isArray(data)) return data.map((item) => mapCompositeIdsFromInference(item));
|
|
3990
|
-
if (!(0, __stackone_utils.isObject)(data)) return data;
|
|
3991
|
-
const result = { ...data };
|
|
3992
|
-
for (const [key, value] of Object.entries(data)) {
|
|
3993
|
-
if ((0, __stackone_utils.isObject)(value) || Array.isArray(value) && value.length > 0 && (0, __stackone_utils.isObject)(value[0])) result[key] = mapCompositeIdsFromInference(value);
|
|
3994
|
-
if (isIdField(key)) processIdField(key, value, result);
|
|
3995
|
-
}
|
|
3996
|
-
return result;
|
|
3997
|
-
};
|
|
3998
|
-
|
|
3999
|
-
//#endregion
|
|
4000
|
-
//#region src/pagination/utils.ts
|
|
4001
|
-
const getPageSize = (block, defaultValue) => {
|
|
4002
|
-
const inputPageSize = Number(block.inputs?.page_size);
|
|
4003
|
-
const pageSize = (0, __stackone_utils.notMissing)(block.inputs?.page_size) && (0, __stackone_utils.isNumber)(inputPageSize) && !Number.isNaN(inputPageSize) ? inputPageSize : block.operation?.cursor?.pageSize ?? defaultValue;
|
|
4004
|
-
return pageSize;
|
|
4005
|
-
};
|
|
4006
|
-
|
|
4007
|
-
//#endregion
|
|
4008
|
-
//#region src/pagination/virtualPagination.ts
|
|
4009
|
-
const virtualPaginateResult = (result, pageSize, steps, cursor) => {
|
|
4010
|
-
const data = (0, __stackone_utils.isMissing)(result) ? void 0 : result.data;
|
|
4011
|
-
const resultStepIndex = Object.keys(steps).length + 1;
|
|
4012
|
-
const emptyCursor = (0, __stackone_core.isCursorEmpty)({
|
|
4013
|
-
cursor,
|
|
4014
|
-
ignoreStepIndex: resultStepIndex
|
|
4015
|
-
});
|
|
4016
|
-
if (!(0, __stackone_utils.isObject)(result) || (0, __stackone_utils.isMissing)(data) || (data?.length ?? 0) <= pageSize) return {
|
|
4017
|
-
result,
|
|
4018
|
-
next: (0, __stackone_utils.notMissing)(cursor) && !emptyCursor ? (0, __stackone_core.minifyCursor)(cursor) : null
|
|
4019
|
-
};
|
|
4020
|
-
const pageNumber = cursor?.remote?.[resultStepIndex]?.pageNumber ?? 1;
|
|
4021
|
-
const startIndex = (pageNumber - 1) * pageSize;
|
|
4022
|
-
const endIndex = startIndex + pageSize;
|
|
4023
|
-
const slicedData = data.slice(startIndex, endIndex);
|
|
4024
|
-
const hasMorePages = data.length > endIndex || !emptyCursor;
|
|
4025
|
-
const pageCursor = (0, __stackone_core.updateCursor)({
|
|
4026
|
-
cursor,
|
|
4027
|
-
stepIndex: resultStepIndex,
|
|
4028
|
-
pageNumber: pageNumber + 1
|
|
4029
|
-
});
|
|
4030
|
-
return {
|
|
4031
|
-
result: {
|
|
4032
|
-
...result,
|
|
4033
|
-
data: slicedData
|
|
4034
|
-
},
|
|
4035
|
-
next: hasMorePages ? (0, __stackone_core.minifyCursor)(pageCursor) : null
|
|
4036
|
-
};
|
|
4037
|
-
};
|
|
4038
|
-
|
|
4039
|
-
//#endregion
|
|
4040
|
-
//#region src/runners/runStepOperation.ts
|
|
4041
|
-
const runStepOperation = async ({ block, buildStepFunction = __stackone_core.StepFunctionsFactory.build, virtualPaginateResultFn = virtualPaginateResult, encodeResultCompositeIds = encodeResultCompositeIdentifiers, decodeInputCompositeIds = decodeInputCompositeIdentifiers }) => {
|
|
4042
|
-
const decodeBlock = decodeInputCompositeIds(block);
|
|
4043
|
-
const resultBlock = await executeStepsWorkflow({
|
|
4044
|
-
block: decodeBlock,
|
|
4045
|
-
buildStepFunction,
|
|
4046
|
-
virtualPaginateResultFn
|
|
4047
|
-
});
|
|
4048
|
-
return encodeResultCompositeIds(resultBlock);
|
|
4049
|
-
};
|
|
4050
|
-
const shouldSkipStepDueToCondition = (step, block) => {
|
|
4051
|
-
return step.condition ? !(0, __stackone_expressions.safeEvaluate)(step.condition, block) : false;
|
|
4052
|
-
};
|
|
4053
|
-
const buildStepParams = (step, blockAcc, stepIndex) => {
|
|
4054
|
-
const fn = step.stepFunction;
|
|
4055
|
-
return blockAcc.operation?.cursor.enabled ? {
|
|
4056
|
-
...fn.params ?? {},
|
|
4057
|
-
cursor: {
|
|
4058
|
-
token: blockAcc.nextCursor?.remote?.[stepIndex]?.providerPageCursor,
|
|
4059
|
-
position: blockAcc.nextCursor?.remote?.[stepIndex]?.position
|
|
4060
|
-
}
|
|
4061
|
-
} : fn.params ?? {};
|
|
4062
|
-
};
|
|
4063
|
-
const handleStepFailure = (blockAcc, stepId, functionOutput, step, state) => {
|
|
4064
|
-
const updatedBlock = addStepResultToBlock({
|
|
4065
|
-
block: blockAcc,
|
|
4066
|
-
stepId,
|
|
4067
|
-
successful: false,
|
|
4068
|
-
functionOutput
|
|
4069
|
-
});
|
|
4070
|
-
const ignoreError = step.ignoreError ?? false;
|
|
4071
|
-
if (!ignoreError) {
|
|
4072
|
-
state.hasFatalError = true;
|
|
4073
|
-
state.errorStatusCode ??= functionOutput.output?.statusCode ?? 500;
|
|
4074
|
-
}
|
|
4075
|
-
return updatedBlock;
|
|
4076
|
-
};
|
|
4077
|
-
const executeStep = async (stepId, stepIndex, stepsToExecute, blockAcc, state, context) => {
|
|
4078
|
-
const step = stepsToExecute[stepId];
|
|
4079
|
-
const fn = step.stepFunction;
|
|
4080
|
-
const stepFunction = context.buildStepFunction({
|
|
4081
|
-
functionName: fn.functionName,
|
|
4082
|
-
version: fn.version,
|
|
4083
|
-
validateSchemas: true
|
|
4084
|
-
}).fn;
|
|
4085
|
-
if (shouldSkipStepDueToCondition(step, blockAcc)) return addStepResultToBlock({
|
|
4086
|
-
block: blockAcc,
|
|
4087
|
-
stepId,
|
|
4088
|
-
successful: true,
|
|
4089
|
-
skipped: true,
|
|
4090
|
-
message: "Step skipped due to condition not met."
|
|
4091
|
-
});
|
|
4092
|
-
if (state.hasFatalError) return addStepResultToBlock({
|
|
4093
|
-
block: blockAcc,
|
|
4094
|
-
stepId,
|
|
4095
|
-
successful: false,
|
|
4096
|
-
skipped: true,
|
|
4097
|
-
message: "Step skipped due to previous error."
|
|
4098
|
-
});
|
|
4099
|
-
const fnParams = buildStepParams(step, blockAcc, stepIndex);
|
|
4100
|
-
const functionOutput = await stepFunction({
|
|
4101
|
-
block: blockAcc,
|
|
4102
|
-
params: fnParams
|
|
4103
|
-
});
|
|
4104
|
-
if (functionOutput.successful === false) return handleStepFailure(blockAcc, stepId, functionOutput, step, state);
|
|
4105
|
-
const updatedCursor = blockAcc.operation?.cursor.enabled ? (0, __stackone_core.updateCursor)({
|
|
4106
|
-
cursor: blockAcc.nextCursor,
|
|
4107
|
-
stepIndex,
|
|
4108
|
-
providerPageCursor: functionOutput.output?.next,
|
|
4109
|
-
position: functionOutput.output?.position
|
|
4110
|
-
}) : void 0;
|
|
4111
|
-
return addStepResultToBlock({
|
|
4112
|
-
block: {
|
|
4113
|
-
...functionOutput.block,
|
|
4114
|
-
nextCursor: updatedCursor
|
|
4115
|
-
},
|
|
4116
|
-
stepId,
|
|
4117
|
-
functionOutput
|
|
4118
|
-
});
|
|
4119
|
-
};
|
|
4120
|
-
const buildFinalResponse = (block, blockAcc, state, result, finalData) => {
|
|
4121
|
-
const isSuccessful = !state.hasFatalError;
|
|
4122
|
-
const finalStatusCode = isSuccessful ? block.operation?.responses.success.statusCode ?? 200 : state.errorStatusCode ?? 500;
|
|
4123
|
-
const outputs = (0, __stackone_utils.notMissing)(finalData) && (0, __stackone_utils.isObject)(finalData.result) ? {
|
|
4124
|
-
next: finalData.next,
|
|
4125
|
-
...finalData.result
|
|
4126
|
-
} : result;
|
|
4127
|
-
return {
|
|
4128
|
-
...blockAcc,
|
|
4129
|
-
outputs,
|
|
4130
|
-
response: {
|
|
4131
|
-
successful: isSuccessful,
|
|
4132
|
-
statusCode: finalStatusCode,
|
|
4133
|
-
message: !isSuccessful ? block.operation?.responses?.errors?.[finalStatusCode]?.description ?? __stackone_transport.HttpErrorMessages?.[finalStatusCode] ?? "Error while processing the request" : void 0
|
|
4134
|
-
}
|
|
4135
|
-
};
|
|
4136
|
-
};
|
|
4137
|
-
const executeStepsWorkflow = async ({ block, buildStepFunction = __stackone_core.StepFunctionsFactory.build, virtualPaginateResultFn = virtualPaginateResult }) => {
|
|
4138
|
-
const stepsToExecute = block.operation?.steps || {};
|
|
4139
|
-
let blockAcc = { ...block };
|
|
4140
|
-
const stepsIds = Object.keys(stepsToExecute);
|
|
4141
|
-
const pageSize = getPageSize(block, DEFAULT_PAGE_SIZE);
|
|
4142
|
-
const state = {
|
|
4143
|
-
hasFatalError: false,
|
|
4144
|
-
errorStatusCode: null
|
|
4145
|
-
};
|
|
4146
|
-
const context = {
|
|
4147
|
-
block,
|
|
4148
|
-
buildStepFunction,
|
|
4149
|
-
virtualPaginateResultFn
|
|
4150
|
-
};
|
|
4151
|
-
for (const [stepIndex, stepId] of stepsIds.entries()) blockAcc = await executeStep(stepId, stepIndex, stepsToExecute, blockAcc, state, context);
|
|
4152
|
-
const result = block.operation?.result ? evaluateResult(block.operation.result, blockAcc) : void 0;
|
|
4153
|
-
const finalData = block.operation?.cursor.enabled ? virtualPaginateResultFn(result, pageSize, stepsToExecute, blockAcc.nextCursor) : void 0;
|
|
4154
|
-
return buildFinalResponse(block, blockAcc, state, result, finalData);
|
|
4155
|
-
};
|
|
4156
|
-
const evaluateResult = (result, block) => {
|
|
4157
|
-
if ((0, __stackone_utils.isObject)(result)) return (0, __stackone_expressions.safeEvaluateRecord)(result, block);
|
|
4158
|
-
return (0, __stackone_expressions.safeEvaluate)(result, block);
|
|
4159
|
-
};
|
|
4160
|
-
const addStepResultToBlock = ({ block, stepId, successful, functionOutput, skipped, message }) => {
|
|
4161
|
-
return {
|
|
4162
|
-
...block,
|
|
4163
|
-
steps: {
|
|
4164
|
-
...block.steps,
|
|
4165
|
-
[stepId]: {
|
|
4166
|
-
successful: successful ?? functionOutput?.successful ?? false,
|
|
4167
|
-
errors: functionOutput?.errors,
|
|
4168
|
-
output: functionOutput?.output,
|
|
4169
|
-
skipped,
|
|
4170
|
-
message
|
|
4171
|
-
}
|
|
4172
|
-
}
|
|
4173
|
-
};
|
|
4174
|
-
};
|
|
4175
|
-
|
|
4176
|
-
//#endregion
|
|
4177
|
-
//#region src/runners/runConnectorOperation.ts
|
|
4178
|
-
const runConnectorOperation = async ({ account, connector, category, path, method = "get", queryParams, body, headers, logger, parseConnector = parseYamlConnector, getOperationFromUrlFn = getOperationFromUrl, parseOperationInputsFn = parseOperationInputs, createBlockContextFn = createBlockContext, createBlockFn = createBlock, runStepOperationFn = runStepOperation }) => {
|
|
4179
|
-
const authConfigKey = account.authConfigKey;
|
|
4180
|
-
const environment = account.environment ?? "production";
|
|
4181
|
-
const accountSecureId = account.secureId;
|
|
4182
|
-
const projectSecureId = account.projectSecureId;
|
|
4183
|
-
const credentials = account.credentials;
|
|
4184
|
-
const blockContext = createBlockContextFn({
|
|
4185
|
-
category,
|
|
4186
|
-
connectorKey: account.providerKey,
|
|
4187
|
-
connectorVersion: account.providerVersion,
|
|
4188
|
-
authConfigKey,
|
|
4189
|
-
environment,
|
|
4190
|
-
accountSecureId,
|
|
4191
|
-
projectSecureId
|
|
4192
|
-
});
|
|
4193
|
-
let parsedConnector;
|
|
4194
|
-
try {
|
|
4195
|
-
parsedConnector = (0, __stackone_utils.isString)(connector) ? parseConnector(connector) : connector;
|
|
4196
|
-
} catch {
|
|
4197
|
-
throw new ConnectorParseError(blockContext, "Error while parsing connector");
|
|
4198
|
-
}
|
|
4199
|
-
const matchingOperation = getOperationFromUrlFn(parsedConnector, path, method);
|
|
4200
|
-
if ((0, __stackone_utils.isMissing)(matchingOperation)) throw new MissingOperationError(blockContext, "No matching operation found");
|
|
4201
|
-
blockContext.operationType = matchingOperation.operation.operationType;
|
|
4202
|
-
blockContext.schema = matchingOperation.operation.schema?.key;
|
|
4203
|
-
const expandedCursor = processCursor(queryParams, blockContext);
|
|
4204
|
-
let operationInputs;
|
|
4205
|
-
try {
|
|
4206
|
-
operationInputs = parseOperationInputsFn(matchingOperation.operation, {
|
|
4207
|
-
query: queryParams,
|
|
4208
|
-
body,
|
|
4209
|
-
headers,
|
|
4210
|
-
path: matchingOperation.params
|
|
4211
|
-
});
|
|
4212
|
-
} catch {
|
|
4213
|
-
throw new InvalidOperationInputsError(blockContext, "Error while parsing operation inputs");
|
|
4214
|
-
}
|
|
4215
|
-
const block = await createBlockFn({
|
|
4216
|
-
inputs: operationInputs,
|
|
4217
|
-
context: blockContext,
|
|
4218
|
-
operation: matchingOperation.operation,
|
|
4219
|
-
credentials,
|
|
4220
|
-
nextCursor: expandedCursor,
|
|
4221
|
-
logger
|
|
4222
|
-
});
|
|
4223
|
-
return await runStepOperationFn({ block });
|
|
4224
|
-
};
|
|
4225
|
-
const processCursor = (queryParams, blockContext) => {
|
|
4226
|
-
const nextCursor = queryParams?.["next"];
|
|
4227
|
-
const expandedCursor = (0, __stackone_utils.notMissing)(nextCursor) && blockContext.operationType === "list" ? (0, __stackone_core.expandCursor)(nextCursor) : void 0;
|
|
4228
|
-
if (expandedCursor === null) throw new InvalidCursorError(blockContext, `Invalid cursor.`);
|
|
4229
|
-
return expandedCursor;
|
|
4230
|
-
};
|
|
4231
|
-
|
|
4232
|
-
//#endregion
|
|
4233
|
-
exports.ConnectSDKError = ConnectSDKError;
|
|
4234
|
-
exports.createBlock = createBlock;
|
|
4235
|
-
exports.executeStepFunction = executeStepFunction;
|
|
4236
|
-
exports.getOperationFromUrl = getOperationFromUrl;
|
|
4237
|
-
exports.parseOperationInputs = parseOperationInputs;
|
|
4238
|
-
exports.parseYamlConnector = parseYamlConnector;
|
|
4239
|
-
exports.runConnectorOperation = runConnectorOperation;
|
|
4240
|
-
exports.runStepOperation = runStepOperation;
|
|
4241
|
-
exports.validateYamlConnector = validateYamlConnector;
|
|
25
|
+
path: iss.path ? [${w(e)}, ...iss.path] : [${w(e)}]
|
|
26
|
+
})));`),t.write(`newResult[${w(e)}] = ${n}.value`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},i,a=T,o=!ie.jitless,s=le,c=o&&s.value,l=t.catchall,u;e._zod.parse=(s,d)=>{u??=n.value;let f=s.value;if(!a(f))return s.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),s;let p=[];if(o&&c&&d?.async===!1&&d.jitless!==!0)i||=r(t.shape),s=i(s,d);else{s.value={};let e=u.shape;for(let t of u.keys){let n=e[t],r=n._zod.run({value:f[t],issues:[]},d),i=n._zod.optin===`optional`&&n._zod.optout===`optional`;r instanceof Promise?p.push(r.then(e=>i?un(e,s,t,f):R(e,s,t))):i?un(r,s,t,f):R(r,s,t)}}if(!l)return p.length?Promise.all(p).then(()=>s):s;let m=[],ee=u.keySet,h=l._zod,te=h.def.type;for(let e of Object.keys(f)){if(ee.has(e))continue;if(te===`never`){m.push(e);continue}let t=h.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>R(t,s,e))):R(t,s,e)}return m.length&&s.issues.push({code:`unrecognized_keys`,keys:m,input:f,inst:e}),p.length?Promise.all(p).then(()=>s):s}});function fn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;return t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>M(e,r,v())))}),t}const pn=g(`$ZodUnion`,(e,t)=>{I.init(e,t),C(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),C(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),C(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),C(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>S(e.source)).join(`|`)})$`)}}),e._zod.parse=(n,r)=>{let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(t.issues.length===0)return t;a.push(t)}}return i?Promise.all(a).then(t=>fn(t,n,e,r)):fn(a,n,e,r)}}),mn=g(`$ZodDiscriminatedUnion`,(e,t)=>{pn.init(e,t);let n=e._zod.parse;C(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=b(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!T(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,input:o,path:[t.discriminator],inst:e}),i)}}),hn=g(`$ZodIntersection`,(e,t)=>{I.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n),o=i instanceof Promise||a instanceof Promise;return o?Promise.all([i,a]).then(([t,n])=>_n(e,t,n)):_n(e,i,a)}});function gn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(E(e)&&E(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=gn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=gn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function _n(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),A(e))return e;let r=gn(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const vn=g(`$ZodRecord`,(e,t)=>{I.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!E(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...j(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...j(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({origin:`record`,code:`invalid_key`,issues:s.issues.map(e=>M(e,r,v())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...j(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...j(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),yn=g(`$ZodEnum`,(e,t)=>{I.init(e,t);let n=ae(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>ue.has(typeof e)).map(e=>typeof e==`string`?D(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,r)=>{let i=t.value;return e._zod.values.has(i)||t.issues.push({code:`invalid_value`,values:n,input:i,inst:e}),t}}),bn=g(`$ZodLiteral`,(e,t)=>{I.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?D(e):e?e.toString():String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),xn=g(`$ZodTransform`,(e,t)=>{I.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async){let t=r instanceof Promise?r:Promise.resolve(r);return t.then(t=>(e.value=t,e))}if(r instanceof Promise)throw new _;return e.value=r,e}}),Sn=g(`$ZodOptional`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,C(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),C(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${S(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>t.innerType._zod.optin===`optional`?t.innerType._zod.run(e,n):e.value===void 0?e:t.innerType._zod.run(e,n)}),Cn=g(`$ZodNullable`,(e,t)=>{I.init(e,t),C(e._zod,`optin`,()=>t.innerType._zod.optin),C(e._zod,`optout`,()=>t.innerType._zod.optout),C(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${S(e.source)}|null)$`):void 0}),C(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),wn=g(`$ZodDefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,C(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Tn(e,t)):Tn(r,t)}});function Tn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const En=g(`$ZodPrefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,C(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Dn=g(`$ZodNonOptional`,(e,t)=>{I.init(e,t),C(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>On(t,e)):On(i,e)}});function On(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const kn=g(`$ZodCatch`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,C(e._zod,`optout`,()=>t.innerType._zod.optout),C(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>M(e,n,v()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>M(e,n,v()))},input:e.value}),e.issues=[]),e)}}),An=g(`$ZodPipe`,(e,t)=>{I.init(e,t),C(e._zod,`values`,()=>t.in._zod.values),C(e._zod,`optin`,()=>t.in._zod.optin),C(e._zod,`optout`,()=>t.out._zod.optout),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>jn(e,t,n)):jn(r,t,n)}});function jn(e,t,n){return A(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const Mn=g(`$ZodReadonly`,(e,t)=>{I.init(e,t),C(e._zod,`propValues`,()=>t.innerType._zod.propValues),C(e._zod,`values`,()=>t.innerType._zod.values),C(e._zod,`optin`,()=>t.innerType._zod.optin),C(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Nn):Nn(r)}});function Nn(e){return e.value=Object.freeze(e.value),e}const Pn=g(`$ZodCustom`,(e,t)=>{F.init(e,t),I.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Fn(t,n,r,e));Fn(i,n,r,e)}});function Fn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(N(e))}}const In=Symbol(`ZodOutput`),Ln=Symbol(`ZodInput`);var Rn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}remove(e){return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function zn(){return new Rn}const z=zn();function Bn(e,t){return new e({type:`string`,...k(t)})}function Vn(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...k(t)})}function Hn(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...k(t)})}function Un(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...k(t)})}function Wn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...k(t)})}function Gn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...k(t)})}function Kn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...k(t)})}function qn(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...k(t)})}function Jn(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...k(t)})}function Yn(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...k(t)})}function Xn(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...k(t)})}function Zn(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...k(t)})}function Qn(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...k(t)})}function $n(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...k(t)})}function er(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...k(t)})}function tr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...k(t)})}function nr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...k(t)})}function rr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...k(t)})}function ir(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...k(t)})}function ar(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...k(t)})}function or(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...k(t)})}function sr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...k(t)})}function cr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...k(t)})}function lr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...k(t)})}function ur(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...k(t)})}function dr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...k(t)})}function fr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...k(t)})}function pr(e,t){return new e({type:`number`,checks:[],...k(t)})}function mr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...k(t)})}function hr(e,t){return new e({type:`boolean`,...k(t)})}function gr(e){return new e({type:`any`})}function _r(e){return new e({type:`unknown`})}function vr(e,t){return new e({type:`never`,...k(t)})}function yr(e,t){return new dt({check:`less_than`,...k(t),value:e,inclusive:!1})}function br(e,t){return new dt({check:`less_than`,...k(t),value:e,inclusive:!0})}function xr(e,t){return new ft({check:`greater_than`,...k(t),value:e,inclusive:!1})}function Sr(e,t){return new ft({check:`greater_than`,...k(t),value:e,inclusive:!0})}function Cr(e,t){return new pt({check:`multiple_of`,...k(t),value:e})}function wr(e,t){let n=new ht({check:`max_length`,...k(t),maximum:e});return n}function B(e,t){return new gt({check:`min_length`,...k(t),minimum:e})}function Tr(e,t){return new _t({check:`length_equals`,...k(t),length:e})}function Er(e,t){return new yt({check:`string_format`,format:`regex`,...k(t),pattern:e})}function Dr(e){return new bt({check:`string_format`,format:`lowercase`,...k(e)})}function Or(e){return new xt({check:`string_format`,format:`uppercase`,...k(e)})}function kr(e,t){return new St({check:`string_format`,format:`includes`,...k(t),includes:e})}function Ar(e,t){return new Ct({check:`string_format`,format:`starts_with`,...k(t),prefix:e})}function jr(e,t){return new wt({check:`string_format`,format:`ends_with`,...k(t),suffix:e})}function V(e){return new Tt({check:`overwrite`,tx:e})}function Mr(e){return V(t=>t.normalize(e))}function Nr(){return V(e=>e.trim())}function Pr(){return V(e=>e.toLowerCase())}function Fr(){return V(e=>e.toUpperCase())}function Ir(e,t,n){return new e({type:`array`,element:t,...k(n)})}function Lr(e,t,n){let r=new e({type:`custom`,check:`custom`,fn:t,...k(n)});return r}const Rr=g(`ZodISODateTime`,(e,t)=>{Bt.init(e,t),G.init(e,t)});function zr(e){return lr(Rr,e)}const Br=g(`ZodISODate`,(e,t)=>{Vt.init(e,t),G.init(e,t)});function Vr(e){return ur(Br,e)}const Hr=g(`ZodISOTime`,(e,t)=>{Ht.init(e,t),G.init(e,t)});function Ur(e){return dr(Hr,e)}const Wr=g(`ZodISODuration`,(e,t)=>{Ut.init(e,t),G.init(e,t)});function Gr(e){return fr(Wr,e)}const Kr=(e,t)=>{Se.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>we(e,t)},flatten:{value:t=>Ce(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})},qr=g(`ZodError`,Kr),H=g(`ZodError`,Kr,{Parent:Error}),Jr=Te(H),Yr=De(H),Xr=ke(H),Zr=je(H),U=g(`ZodType`,(e,t)=>(I.init(e,t),e.def=t,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>O(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>Jr(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Xr(e,t,n),e.parseAsync=async(t,n)=>Yr(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Zr(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(oa(t,n)),e.superRefine=t=>e.check(sa(t)),e.overwrite=t=>e.check(V(t)),e.optional=()=>Ui(e),e.nullable=()=>Gi(e),e.nullish=()=>Ui(Gi(e)),e.nonoptional=t=>Zi(e,t),e.array=()=>Oi(e),e.or=t=>ji([e,t]),e.and=t=>Fi(e,t),e.transform=t=>ta(e,Vi(t)),e.default=t=>qi(e,t),e.prefault=t=>Yi(e,t),e.catch=t=>$i(e,t),e.pipe=t=>ta(e,t),e.readonly=()=>ra(e),e.describe=t=>{let n=e.clone();return z.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return z.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return z.get(e);let n=e.clone();return z.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Qr=g(`_ZodString`,(e,t)=>{Ot.init(e,t),U.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Er(...t)),e.includes=(...t)=>e.check(kr(...t)),e.startsWith=(...t)=>e.check(Ar(...t)),e.endsWith=(...t)=>e.check(jr(...t)),e.min=(...t)=>e.check(B(...t)),e.max=(...t)=>e.check(wr(...t)),e.length=(...t)=>e.check(Tr(...t)),e.nonempty=(...t)=>e.check(B(1,...t)),e.lowercase=t=>e.check(Dr(t)),e.uppercase=t=>e.check(Or(t)),e.trim=()=>e.check(Nr()),e.normalize=(...t)=>e.check(Mr(...t)),e.toLowerCase=()=>e.check(Pr()),e.toUpperCase=()=>e.check(Fr())}),$r=g(`ZodString`,(e,t)=>{Ot.init(e,t),Qr.init(e,t),e.email=t=>e.check(Vn(ei,t)),e.url=t=>e.check(qn(ni,t)),e.jwt=t=>e.check(cr(_i,t)),e.emoji=t=>e.check(Jn(ri,t)),e.guid=t=>e.check(Hn(ti,t)),e.uuid=t=>e.check(Un(K,t)),e.uuidv4=t=>e.check(Wn(K,t)),e.uuidv6=t=>e.check(Gn(K,t)),e.uuidv7=t=>e.check(Kn(K,t)),e.nanoid=t=>e.check(Yn(ii,t)),e.guid=t=>e.check(Hn(ti,t)),e.cuid=t=>e.check(Xn(ai,t)),e.cuid2=t=>e.check(Zn(oi,t)),e.ulid=t=>e.check(Qn(si,t)),e.base64=t=>e.check(ar(mi,t)),e.base64url=t=>e.check(or(hi,t)),e.xid=t=>e.check($n(ci,t)),e.ksuid=t=>e.check(er(li,t)),e.ipv4=t=>e.check(tr(ui,t)),e.ipv6=t=>e.check(nr(di,t)),e.cidrv4=t=>e.check(rr(fi,t)),e.cidrv6=t=>e.check(ir(pi,t)),e.e164=t=>e.check(sr(gi,t)),e.datetime=t=>e.check(zr(t)),e.date=t=>e.check(Vr(t)),e.time=t=>e.check(Ur(t)),e.duration=t=>e.check(Gr(t))});function W(e){return Bn($r,e)}const G=g(`ZodStringFormat`,(e,t)=>{L.init(e,t),Qr.init(e,t)}),ei=g(`ZodEmail`,(e,t)=>{jt.init(e,t),G.init(e,t)}),ti=g(`ZodGUID`,(e,t)=>{kt.init(e,t),G.init(e,t)}),K=g(`ZodUUID`,(e,t)=>{At.init(e,t),G.init(e,t)}),ni=g(`ZodURL`,(e,t)=>{Mt.init(e,t),G.init(e,t)}),ri=g(`ZodEmoji`,(e,t)=>{Nt.init(e,t),G.init(e,t)}),ii=g(`ZodNanoID`,(e,t)=>{Pt.init(e,t),G.init(e,t)}),ai=g(`ZodCUID`,(e,t)=>{Ft.init(e,t),G.init(e,t)}),oi=g(`ZodCUID2`,(e,t)=>{It.init(e,t),G.init(e,t)}),si=g(`ZodULID`,(e,t)=>{Lt.init(e,t),G.init(e,t)}),ci=g(`ZodXID`,(e,t)=>{Rt.init(e,t),G.init(e,t)}),li=g(`ZodKSUID`,(e,t)=>{zt.init(e,t),G.init(e,t)}),ui=g(`ZodIPv4`,(e,t)=>{Wt.init(e,t),G.init(e,t)}),di=g(`ZodIPv6`,(e,t)=>{Gt.init(e,t),G.init(e,t)}),fi=g(`ZodCIDRv4`,(e,t)=>{Kt.init(e,t),G.init(e,t)}),pi=g(`ZodCIDRv6`,(e,t)=>{qt.init(e,t),G.init(e,t)}),mi=g(`ZodBase64`,(e,t)=>{Yt.init(e,t),G.init(e,t)}),hi=g(`ZodBase64URL`,(e,t)=>{Zt.init(e,t),G.init(e,t)}),gi=g(`ZodE164`,(e,t)=>{Qt.init(e,t),G.init(e,t)}),_i=g(`ZodJWT`,(e,t)=>{en.init(e,t),G.init(e,t)}),vi=g(`ZodNumber`,(e,t)=>{tn.init(e,t),U.init(e,t),e.gt=(t,n)=>e.check(xr(t,n)),e.gte=(t,n)=>e.check(Sr(t,n)),e.min=(t,n)=>e.check(Sr(t,n)),e.lt=(t,n)=>e.check(yr(t,n)),e.lte=(t,n)=>e.check(br(t,n)),e.max=(t,n)=>e.check(br(t,n)),e.int=t=>e.check(bi(t)),e.safe=t=>e.check(bi(t)),e.positive=t=>e.check(xr(0,t)),e.nonnegative=t=>e.check(Sr(0,t)),e.negative=t=>e.check(yr(0,t)),e.nonpositive=t=>e.check(br(0,t)),e.multipleOf=(t,n)=>e.check(Cr(t,n)),e.step=(t,n)=>e.check(Cr(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function q(e){return pr(vi,e)}const yi=g(`ZodNumberFormat`,(e,t)=>{nn.init(e,t),vi.init(e,t)});function bi(e){return mr(yi,e)}const xi=g(`ZodBoolean`,(e,t)=>{rn.init(e,t),U.init(e,t)});function J(e){return hr(xi,e)}const Si=g(`ZodAny`,(e,t)=>{an.init(e,t),U.init(e,t)});function Ci(){return gr(Si)}const wi=g(`ZodUnknown`,(e,t)=>{on.init(e,t),U.init(e,t)});function Y(){return _r(wi)}const Ti=g(`ZodNever`,(e,t)=>{sn.init(e,t),U.init(e,t)});function Ei(e){return vr(Ti,e)}const Di=g(`ZodArray`,(e,t)=>{ln.init(e,t),U.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(B(t,n)),e.nonempty=t=>e.check(B(1,t)),e.max=(t,n)=>e.check(wr(t,n)),e.length=(t,n)=>e.check(Tr(t,n)),e.unwrap=()=>e.element});function Oi(e,t){return Ir(Di,e,t)}const ki=g(`ZodObject`,(e,t)=>{dn.init(e,t),U.init(e,t),C(e,`shape`,()=>t.shape),e.keyof=()=>Q(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Y()}),e.loose=()=>e.clone({...e._zod.def,catchall:Y()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ei()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>he(e,t),e.merge=t=>ge(e,t),e.pick=t=>pe(e,t),e.omit=t=>me(e,t),e.partial=(...t)=>_e(Hi,e,t[0]),e.required=(...t)=>ve(Xi,e,t[0])});function X(e,t){let n={type:`object`,get shape(){return se(this,`shape`,{...e}),this.shape},...k(t)};return new ki(n)}const Ai=g(`ZodUnion`,(e,t)=>{pn.init(e,t),U.init(e,t),e.options=t.options});function ji(e,t){return new Ai({type:`union`,options:e,...k(t)})}const Mi=g(`ZodDiscriminatedUnion`,(e,t)=>{Ai.init(e,t),mn.init(e,t)});function Ni(e,t,n){return new Mi({type:`union`,options:t,discriminator:e,...k(n)})}const Pi=g(`ZodIntersection`,(e,t)=>{hn.init(e,t),U.init(e,t)});function Fi(e,t){return new Pi({type:`intersection`,left:e,right:t})}const Ii=g(`ZodRecord`,(e,t)=>{vn.init(e,t),U.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Z(e,t,n){return new Ii({type:`record`,keyType:e,valueType:t,...k(n)})}const Li=g(`ZodEnum`,(e,t)=>{yn.init(e,t),U.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Li({...t,checks:[],...k(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Li({...t,checks:[],...k(r),entries:i})}});function Q(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Li({type:`enum`,entries:n,...k(t)})}const Ri=g(`ZodLiteral`,(e,t)=>{bn.init(e,t),U.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function zi(e,t){return new Ri({type:`literal`,values:Array.isArray(e)?e:[e],...k(t)})}const Bi=g(`ZodTransform`,(e,t)=>{xn.init(e,t),U.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(N(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,t.continue??=!0,n.issues.push(N(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Vi(e){return new Bi({type:`transform`,transform:e})}const Hi=g(`ZodOptional`,(e,t)=>{Sn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ui(e){return new Hi({type:`optional`,innerType:e})}const Wi=g(`ZodNullable`,(e,t)=>{Cn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Gi(e){return new Wi({type:`nullable`,innerType:e})}const Ki=g(`ZodDefault`,(e,t)=>{wn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qi(e,t){return new Ki({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const Ji=g(`ZodPrefault`,(e,t)=>{En.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Yi(e,t){return new Ji({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const Xi=g(`ZodNonOptional`,(e,t)=>{Dn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Zi(e,t){return new Xi({type:`nonoptional`,innerType:e,...k(t)})}const Qi=g(`ZodCatch`,(e,t)=>{kn.init(e,t),U.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $i(e,t){return new Qi({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const ea=g(`ZodPipe`,(e,t)=>{An.init(e,t),U.init(e,t),e.in=t.in,e.out=t.out});function ta(e,t){return new ea({type:`pipe`,in:e,out:t})}const na=g(`ZodReadonly`,(e,t)=>{Mn.init(e,t),U.init(e,t)});function ra(e){return new na({type:`readonly`,innerType:e})}const ia=g(`ZodCustom`,(e,t)=>{Pn.init(e,t),U.init(e,t)});function aa(e,t){let n=new F({check:`custom`,...k(t)});return n._zod.check=e,n}function oa(e,t={}){return Lr(ia,e,t)}function sa(e,t){let n=aa(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(N(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(N(r))}},e(t.value,t)),t);return n}const ca=25,la=e=>{switch(e){case`list`:return{statusCode:200,description:`The list of records was retrieved.`};case`get`:return{statusCode:200,description:`The record with the given identifier was retrieved.`};case`create`:return{statusCode:201,description:`The record was created successfully.`};case`update`:return{statusCode:200,description:`The record was updated successfully.`};case`delete`:return{statusCode:204,description:`The record was deleted successfully.`};case`custom`:return{statusCode:200,description:`The operation was executed successfully.`};case`unknown`:return{statusCode:200};default:throw Error(`Unknown operation type: ${e}`)}},ua=()=>{let e={400:{statusCode:400,description:`Invalid request.`},401:{statusCode:401,description:`Unauthorized access.`},403:{statusCode:403,description:`Forbidden.`},404:{statusCode:404,description:`Resource not found.`},500:{statusCode:500,description:`Server error while executing the request.`}};return e},da={key:W(),label:W(),required:J().optional().default(!1),secret:J().optional().default(!1),readOnly:J().optional().default(!1),placeholder:W().optional(),description:W().optional(),tooltip:W().optional()},fa=Ni(`type`,[X({...da,type:Q([`text`,`password`])}),X({...da,type:zi(`select`),options:X({value:W(),label:W()}).array()})]),pa=X({operationId:W(),categories:W().array(),operationType:Q([`list`,`get`,`create`,`update`,`delete`,`custom`,`unknown`]),schema:W().optional(),entrypointUrl:W().optional(),entrypointHttpMethod:W().optional(),description:W(),responses:X({statusCode:q(),description:W()}).array().optional(),inputs:X({name:W(),type:W(),required:J(),description:W(),in:W()}).array().optional(),cursor:X({enabled:J(),pageSize:q()}).optional(),compositeIdentifiers:X({enabled:J(),version:q().optional(),fields:X({targetFieldKey:W(),remote:W().optional(),components:W().array()}).array().optional()}).optional(),scheduledJobs:X({enabled:J(),type:Q([`data_sync`]),schedule:W(),description:W(),requestParams:X({fields:W().array().optional(),expand:W().array().optional(),filter:Z(W(),W()).optional()}).optional(),syncFilter:X({name:Q([`updated_after`,`created_after`]),initialLoopbackPeriod:W(),incrementalLoopbackPeriod:W()}).optional()}).array().optional(),fieldConfigs:X({targetFieldKey:W(),alias:W().optional(),expression:W(),type:Q([`string`,`number`,`boolean`,`datetime_string`,`enum`]),custom:J().default(!1),hidden:J().default(!1),enumMapper:X({matcher:Q([`country_alpha2code_by_alpha2code`,`country_alpha3code_by_alpha3code`,`country_code_by_country_code`,`country_name_by_country_name`,`country_name_by_alpha3code`,`country_name_by_alpha2code`,`country_name_by_country_code`,`country_alpha3code_by_alpha2code`,`country_alpha3code_by_country_name`,`country_alpha3code_by_country_code`,`country_alpha2code_by_alpha3code`,`country_alpha2code_by_country_name`,`country_alpha2code_by_country_code`,`country_code_by_alpha2code`,`country_code_by_alpha3code`,`country_code_by_country_name`,`country_subdivisions_by_alpha2code`,`country_subdivision_code_by_subdivision_name`,`country_alpha2code_by_citizenship`,`country_subdivision_name_by_subdivision_code`]).or(X({matchExpression:W(),value:W()}).array())}).optional()}).array().optional(),steps:X({stepId:W(),description:W(),stepFunction:X({functionName:W(),version:W().optional(),parameters:Z(W(),Y())}),condition:W().optional(),ignoreError:J().optional()}).array(),result:W().or(Z(W(),Y())).optional()}),ma=X({StackOne:W(),info:X({title:W(),version:W(),key:W(),assets:X({icon:W()}),description:W().optional()}),baseUrl:W(),authentication:Z(W(),X({type:W(),label:W(),authorization:u.AUTHENTICATION_SCHEMA,environments:X({key:W(),name:W()}).array(),support:X({link:W(),description:W().optional()}),configFields:fa.array().optional(),setupFields:fa.array().optional(),testOperationsIds:W().array().optional()})).array().optional(),operations:pa.array().optional()});function ha(e){try{let t=(0,f.parse)(e),n=ma.parse(t),r={title:n.info.title,version:n.info.version,key:n.info.key,assets:n.info.assets,description:n.info.description},i=va(n),a={baseUrl:n.baseUrl,authentication:ga(i)},o=Ca(n,a);return r.operations=o,r.authentication=i,(0,d.notMissing)(o)&&(r.categories=_a(Object.values(o))),r}catch(e){throw Error(`Error parsing YAML file: ${e.message}`)}}const ga=e=>{let t={};for(let[n,r]of Object.entries(e))if(r&&typeof r==`object`){let{setupFields:e,configFields:i,support:a,testOperationsIds:o,...s}=r;t[n]=ga(s)}else t[n]=r;return t},_a=e=>{let t=e.reduce((e,t)=>{for(let n of t.categories)e.add(n);return e},new Set);return Array.from(t)},va=e=>{let t={};for(let n of e.authentication??[]){let[e]=Object.keys(n),r=n[e].environments.reduce((t,r)=>{let{key:i,name:a}=r,{environments:o,...s}=n[e];return t[i]={...s,envKey:i,envName:a},t},{});t[e]=r}return t},ya=e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0,ba=e=>e.operationType===`list`?`GET /${e.schema}`:`GET /${e.schema}/:id`,xa=e=>e.operationType===`list`?`/${e.schema}`:`/${e.schema}/:id`,Sa=e=>{let t={success:la(e.operationType),errors:ua()},n=e.responses?.reduce((e,t)=>{let n=(0,c.isSuccessStatusCode)(t.statusCode);return n?e.success={statusCode:t.statusCode,description:t.description}:e.errors[t.statusCode]={statusCode:t.statusCode,description:t.description},e},t);return n??t},Ca=(e,t)=>{let n=e.operations?.reduce((e,n)=>{let r=ya(n),i=ba(n),a=xa(n),o=Sa(n),s=Da(n),c=n.inputs||[];return s.enabled&&c?.push({type:`string`,name:`page_size`,in:`query`,required:!1,description:`Number of items to return per page`}),e[r??i]={id:n.operationId,categories:n.categories,description:n.description,operationType:n.operationType,entrypointUrl:n.entrypointUrl??a,entrypointHttpMethod:n.entrypointHttpMethod??`get`,responses:o,cursor:s,compositeIdentifiers:Oa(n),scheduledJobs:ka(n),inputs:c,steps:n.steps.reduce((e,r)=>(e[r.stepId]={id:r.stepId,description:r.description,condition:r.condition,ignoreError:r.ignoreError,stepFunction:{functionName:r.stepFunction.functionName,version:r.stepFunction.version,params:{...r.stepFunction.parameters,...Aa(r.stepFunction.functionName,t,r.stepFunction.parameters),...r.stepFunction.functionName===`map_fields`||r.stepFunction.functionName===`typecast`?{fields:n.fieldConfigs}:{}}}},e),{}),result:n.result},e},{});return n},wa=(e,t)=>{if(!e.inputs)return{};let n=Ea(e.inputs),r=n.parse(t);return{...r.headers??{},...r.query??{},...r.path??{},...r.body??{}}},Ta=e=>{let t={};return e.forEach(e=>{let n;switch(e.type.toLowerCase()){case`string`:n=W();break;case`number`:n=q();break;case`boolean`:n=J();break;default:n=Ci()}t[e.name]=e.required?n:n.optional()}),X(t)},Ea=e=>{let t=e.filter(e=>e.in===`path`),n=e.filter(e=>e.in===`query`),r=e.filter(e=>e.in===`body`),i=e.filter(e=>e.in===`headers`);return X({path:Ta(t).optional(),query:Ta(n).optional(),body:Ta(r).optional(),headers:Ta(i).optional()})},Da=e=>{let t=e.operationType===`list`,n=e.cursor??{enabled:t,pageSize:ca};return{enabled:n.enabled&&t,pageSize:n.pageSize}},Oa=e=>{if((0,d.isMissing)(e.compositeIdentifiers)){let t=e.fieldConfigs?.find(e=>e.targetFieldKey===`id`),n=(0,d.notMissing)(t)?[{targetFieldKey:t.targetFieldKey,remote:`id`,components:[{name:t.targetFieldKey,alias:t.alias}]}]:void 0;return{enabled:!0,version:u.COMPOSITE_ID_LATEST_VERSION,fields:n}}let t=[];for(let n of e.compositeIdentifiers?.fields??[]){let r=n.components.map(t=>{let n=e.fieldConfigs?.find(e=>e.targetFieldKey===t);return{name:t,alias:n?.alias}});t.push({targetFieldKey:n.targetFieldKey,remote:n.remote,components:r})}return{enabled:e.compositeIdentifiers.enabled,version:e.compositeIdentifiers.version,fields:t.length>0?t:void 0}},ka=e=>{if(!(0,d.isMissing)(e.scheduledJobs))return e.scheduledJobs},Aa=(e,t,n={})=>{if(e===`request`||e===`paginated_request`){let e=[{receivedStatus:500,targetStatus:502}],r=n.customErrors&&Array.isArray(n.customErrors)?n.customErrors:[],i=[...r,...e];return{...t,customErrors:i}}else return{}},ja=e=>{try{let t=[],n=(0,f.parse)(e),r=ma.safeParse(n);return r.success||r.error.issues.forEach(n=>{let r=Ma(n.path,e);t.push({line:r,message:n.message,field:n.path.join(`.`)})}),t.length>0?{success:!1,errors:t}:{success:!0}}catch(e){let t=e.message,n=t.match(/at line (\d+)/),r=n?parseInt(n[1],10):1;return{success:!1,errors:[{line:r,message:`The YAML connector file is not valid. Please check the syntax and structure.`,field:void 0}]}}},Ma=(e,t)=>{let n=t.split(`
|
|
27
|
+
`),r=0,i=-1,a=0;for(let t=0;t<n.length;t++){let o=n[t],s=o.match(/^(\s*)/)?.[1]?.length||0,c=o.replace(`- `,``).trim();if(c.startsWith(`#`)||c===``||s<=i)continue;let l=(0,d.notMissing)(e[r])?`${String(e[r])}`:``;if((0,d.isMissing)(l))return a+1;if(isNaN(Number(l))){if(c.startsWith(`${l}:`)){if(r===e.length-1)return t+1;i=s,a=t,r++}}else{let e=parseInt(l,10),i=-1;for(let o=t;o<n.length;o++){let s=n[o],c=s.trim();if(c.startsWith(`-`)&&i++,i===e){r++,a=t,t--;break}else t++}}}return a+1};var $=class e extends Error{errorType;context;constructor(t,n,r){super(r),this.name=`ConnectSDKError`,this.errorType=t,this.context=n,Error.captureStackTrace&&Error.captureStackTrace(this,e)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}},Na=class extends ${constructor(e,t){super(`CONNECTOR_PARSE_ERROR`,e,t),this.name=`ConnectorParseError`}},Pa=class extends ${constructor(e,t){super(`MISSING_OPERATION_ERROR`,e,t),this.name=`MissingOperationError`}},Fa=class extends ${constructor(e,t){super(`INVALID_OPERATION_INPUTS_ERROR`,e,t),this.name=`InvalidOperationInputsError`}},Ia=class extends ${constructor(e,t){super(`INVALID_CURSOR_ERROR`,e,t),this.name=`InvalidCursorError`}};const La=async({block:e,stepFunctionName:t,params:n,buildStepFunction:r=u.StepFunctionsFactory.build})=>{let i=r({functionName:t}).fn,a=await i({block:e,params:n}),o=t===u.StepFunctionName.MAP_FIELDS?{[u.StepFunctionName.MAP_FIELDS.toString()]:{output:{data:a.block.result},errors:a.errors,successful:a.successful}}:{};return{...a.block,steps:{...a?.block?.steps??{},...o}}},Ra=({category:e,connectorKey:t,connectorVersion:n,authConfigKey:r,environment:i=`production`,operation:a,accountSecureId:o,projectSecureId:s})=>({projectSecureId:s,accountSecureId:o,connectorKey:t,connectorVersion:n,category:e,service:``,resource:``,schema:a?.schema?.key,operationType:a?.operationType??`unknown`,authenticationType:r,environment:i}),za=e=>{let t=e.operation?.compositeIdentifiers,n={...e.inputs??{}};if(!t?.enabled||(0,d.isMissing)(n))return e;let r=t.fields?.reduce((e,t)=>(t.components.forEach(t=>{t.alias&&(e[t.name]=t.alias)}),e),{}),i={version:t.version??u.COMPOSITE_ID_LATEST_VERSION,aliases:r};return Ba(n,i,e.logger),{...e,inputs:n}},Ba=(e,t,n)=>{for(let r in e){let i=e[r];if(typeof i==`string`||Array.isArray(i)&&i.every(e=>typeof e==`string`))Ka(i,r,e,t,n);else if(Array.isArray(i))for(let e of i)Ba(e,t,n);else typeof i==`object`&&i&&Ba(i,t,n)}},Va=(e,t,n,r)=>{let i=[],a=[];for(let o of e)try{let e=(0,u.decodeCompositeId)(o,n);i.push(e)}catch(e){r?.debug({message:`Received ${t} with invalid composite ID, assuming it is not a composite ID`,category:`processCompositeId`,context:{key:t,inputElement:o,compositeIdentifierConfig:n,error:e}}),a.push(o)}return{compositeIdComponents:i,nonCompositeIds:a}},Ha=(e,t,n,r)=>{let i=n.filter(e=>Object.keys(e).length>1);i.length>0&&(e.decoded_ids={...e.decoded_ids??{},[t]:r?i:i[0]})},Ua=e=>{let t=Object.values(e);return t.length===1&&(typeof t[0]==`string`||typeof t[0]==`number`)},Wa=(e,t,n,r,i)=>{n.every(Ua)&&(i?e[t]=[...n.map(e=>Object.values(e)[0]),...r]:n.length>0&&(e[t]=Object.values(n[0])[0]))},Ga=(e,t,n)=>{e instanceof u.CoreError&&e.type===`COMPOSITE_ID_MISSING_HEADER_ERROR`?n?.debug({message:`Received ${t} with no composite ID header, assuming it is not a composite ID`}):n?.warning({message:`Error processing composite ID for ${t}, ignoring it`,error:e})},Ka=(e,t,n,r,i)=>{try{let a=Array.isArray(e),o=a?e:[e];if(o.length===0)return;let{compositeIdComponents:s,nonCompositeIds:c}=Va(o,t,r,i);Ha(n,t,s,a),Wa(n,t,s,c,a)}catch(e){Ga(e,t,i)}},qa=`remote_`,Ja=e=>{let t=e.operation?.compositeIdentifiers;if(!t?.enabled)return e;let n=`data`,r=e.outputs?.[n];if((0,d.isMissing)(r))return e;let i=Array.isArray(r)?r.map(e=>Ya(e,t)):Ya(r,t);return{...e,outputs:{...e.outputs??{},[n]:i}}},Ya=(e,t)=>{let n=Xa(e,t),r=io(n);return{...e,...(0,d.isObject)(r)?r:{}}},Xa=(e,t)=>{let n=t.version??u.COMPOSITE_ID_LATEST_VERSION,r={};return t.fields?.forEach(t=>{let i={},a=[];t.components.forEach(t=>{t.alias&&(i[t.name]=t.alias),a.push({key:t.name,value:e[t.name]})});let o=a.length===1?a[0]:{identifiers:a},s={version:n,aliases:Object.keys(i).length>0?i:void 0},c=(0,u.encodeCompositeId)(o,s);r[t.targetFieldKey]=c,t.remote&&(r[`${qa}${t.remote}`]=e[t.remote])}),{...e,...r}},Za=e=>e===`id`||/.+_id(s)?$/.test(e),Qa=e=>Array.isArray(e)&&e.every(e=>(0,d.isString)(e)&&e.length>0),$a=(e,t)=>(0,u.isCompositeId)(e)||t.startsWith(qa),eo=(e,t)=>{try{return(0,u.encodeCompositeId)({key:e,value:t},{version:u.COMPOSITE_ID_LATEST_VERSION})}catch{return t}},to=(e,t,n)=>{let r=t.map(t=>(0,d.isString)(t)&&t.length>0&&!(0,u.isCompositeId)(t)?eo(e,t):t);n[e]=r,n[`${qa}${e}`]=t},no=(e,t,n)=>{if($a(t,e))return;let r=(0,u.encodeCompositeId)({key:e,value:t},{version:u.COMPOSITE_ID_LATEST_VERSION});n[e]=r,n[`remote_${e}`]=t},ro=(e,t,n)=>{Qa(t)?to(e,t,n):(0,d.isString)(t)&&t.length>0&&no(e,t,n)},io=e=>{if(Array.isArray(e))return e.map(e=>io(e));if(!(0,d.isObject)(e))return e;let t={...e};for(let[n,r]of Object.entries(e))((0,d.isObject)(r)||Array.isArray(r)&&r.length>0&&(0,d.isObject)(r[0]))&&(t[n]=io(r)),Za(n)&&ro(n,r,t);return t},ao=(e,t)=>{let n=Number(e.inputs?.page_size),r=(0,d.notMissing)(e.inputs?.page_size)&&(0,d.isNumber)(n)&&!Number.isNaN(n)?n:e.operation?.cursor?.pageSize??t;return r},oo=(e,t,n,r)=>{let i=(0,d.isMissing)(e)?void 0:e.data,a=Object.keys(n).length+1,o=(0,u.isCursorEmpty)({cursor:r,ignoreStepIndex:a});if(!(0,d.isObject)(e)||(0,d.isMissing)(i)||(i?.length??0)<=t)return{result:e,next:(0,d.notMissing)(r)&&!o?(0,u.minifyCursor)(r):null};let s=r?.remote?.[a]?.pageNumber??1,c=(s-1)*t,l=c+t,f=i.slice(c,l),p=i.length>l||!o,m=(0,u.updateCursor)({cursor:r,stepIndex:a,pageNumber:s+1});return{result:{...e,data:f},next:p?(0,u.minifyCursor)(m):null}},so=async({block:e,buildStepFunction:t=u.StepFunctionsFactory.build,virtualPaginateResultFn:n=oo,encodeResultCompositeIds:r=Ja,decodeInputCompositeIds:i=za})=>{let a=i(e),o=await mo({block:a,buildStepFunction:t,virtualPaginateResultFn:n});return r(o)},co=(e,t)=>e.condition?!(0,p.safeEvaluate)(e.condition,t):!1,lo=(e,t,n)=>{let r=e.stepFunction;return t.operation?.cursor.enabled?{...r.params??{},cursor:{token:t.nextCursor?.remote?.[n]?.providerPageCursor,position:t.nextCursor?.remote?.[n]?.position}}:r.params??{}},uo=(e,t,n,r,i)=>{let a=go({block:e,stepId:t,successful:!1,functionOutput:n}),o=r.ignoreError??!1;return o||(i.hasFatalError=!0,i.errorStatusCode??=n.output?.statusCode??500),a},fo=async(e,t,n,r,i,a)=>{let o=n[e],s=o.stepFunction,c=a.buildStepFunction({functionName:s.functionName,version:s.version,validateSchemas:!0}).fn;if(co(o,r))return go({block:r,stepId:e,successful:!0,skipped:!0,message:`Step skipped due to condition not met.`});if(i.hasFatalError)return go({block:r,stepId:e,successful:!1,skipped:!0,message:`Step skipped due to previous error.`});let l=lo(o,r,t),d=await c({block:r,params:l});if(d.successful===!1)return uo(r,e,d,o,i);let f=r.operation?.cursor.enabled?(0,u.updateCursor)({cursor:r.nextCursor,stepIndex:t,providerPageCursor:d.output?.next,position:d.output?.position}):void 0;return go({block:{...d.block,nextCursor:f},stepId:e,functionOutput:d})},po=(e,t,n,r,i)=>{let a=!n.hasFatalError,o=a?e.operation?.responses.success.statusCode??200:n.errorStatusCode??500,s=(0,d.notMissing)(i)&&(0,d.isObject)(i.result)?{next:i.next,...i.result}:r;return{...t,outputs:s,response:{successful:a,statusCode:o,message:a?void 0:e.operation?.responses?.errors?.[o]?.description??c.HttpErrorMessages?.[o]??`Error while processing the request`}}},mo=async({block:e,buildStepFunction:t=u.StepFunctionsFactory.build,virtualPaginateResultFn:n=oo})=>{let r=e.operation?.steps||{},i={...e},a=Object.keys(r),o=ao(e,ca),s={hasFatalError:!1,errorStatusCode:null},c={block:e,buildStepFunction:t,virtualPaginateResultFn:n};for(let[e,t]of a.entries())i=await fo(t,e,r,i,s,c);let l=e.operation?.result?ho(e.operation.result,i):void 0,d=e.operation?.cursor.enabled?n(l,o,r,i.nextCursor):void 0;return po(e,i,s,l,d)},ho=(e,t)=>(0,d.isObject)(e)?(0,p.safeEvaluateRecord)(e,t):(0,p.safeEvaluate)(e,t),go=({block:e,stepId:t,successful:n,functionOutput:r,skipped:i,message:a})=>({...e,steps:{...e.steps,[t]:{successful:n??r?.successful??!1,errors:r?.errors,output:r?.output,skipped:i,message:a}}}),_o=async({account:e,connector:t,category:n,path:r,method:i=`get`,queryParams:a,body:o,headers:s,logger:c,parseConnector:l=ha,getOperationFromUrlFn:u=ee,parseOperationInputsFn:f=wa,createBlockContextFn:p=Ra,createBlockFn:h=m,runStepOperationFn:te=so})=>{let ne=e.authConfigKey,g=e.environment??`production`,re=e.secureId,_=e.projectSecureId,ie=e.credentials,v=p({category:n,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:ne,environment:g,accountSecureId:re,projectSecureId:_}),ae;try{ae=(0,d.isString)(t)?l(t):t}catch{throw new Na(v,`Error while parsing connector`)}let y=u(ae,r,i);if((0,d.isMissing)(y))throw new Pa(v,`No matching operation found`);v.operationType=y.operation.operationType,v.schema=y.operation.schema?.key;let b=vo(a,v),x;try{x=f(y.operation,{query:a,body:o,headers:s,path:y.params})}catch{throw new Fa(v,`Error while parsing operation inputs`)}let S=await h({inputs:x,context:v,operation:y.operation,credentials:ie,nextCursor:b,logger:c});return await te({block:S})},vo=(e,t)=>{let n=e?.next,r=(0,d.notMissing)(n)&&t.operationType===`list`?(0,u.expandCursor)(n):void 0;if(r===null)throw new Ia(t,`Invalid cursor.`);return r};exports.ConnectSDKError=$,exports.createBlock=m,exports.executeStepFunction=La,exports.getOperationFromUrl=ee,exports.parseOperationInputs=wa,exports.parseYamlConnector=ha,exports.runConnectorOperation=_o,exports.runStepOperation=so,exports.validateYamlConnector=ja;
|