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