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