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