langwatch 0.1.5 → 0.1.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/{chunk-I5AU3P36.mjs → chunk-FWBCQQYZ.mjs} +5 -48
- package/dist/chunk-FWBCQQYZ.mjs.map +1 -0
- package/dist/index.d.mts +407 -442
- package/dist/index.d.ts +407 -442
- package/dist/index.js +430 -161
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{utils-DJoZVcOA.d.mts → utils-B0pgWcps.d.mts} +12 -10
- package/dist/{utils-DJoZVcOA.d.ts → utils-B0pgWcps.d.ts} +12 -10
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +4 -47
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +1 -1
- package/example/components/header.tsx +6 -6
- package/example/instrumentation.ts +3 -1
- package/example/package-lock.json +511 -65
- package/example/package.json +1 -1
- package/package.json +4 -4
- package/src/index.ts +5 -1
- package/src/types.ts +6 -1
- package/src/utils.ts +3 -0
- package/ts-to-zod.config.js +2 -0
- package/dist/chunk-I5AU3P36.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -20672,7 +20672,7 @@ function fillPool(bytes) {
|
|
|
20672
20672
|
poolOffset += bytes;
|
|
20673
20673
|
}
|
|
20674
20674
|
function nanoid(size = 21) {
|
|
20675
|
-
fillPool(size
|
|
20675
|
+
fillPool(size |= 0);
|
|
20676
20676
|
let id = "";
|
|
20677
20677
|
for (let i = poolOffset - size; i < poolOffset; i++) {
|
|
20678
20678
|
id += urlAlphabet[pool[i] & 63];
|
|
@@ -20834,7 +20834,10 @@ var quotelessJson = (obj) => {
|
|
|
20834
20834
|
const json = JSON.stringify(obj, null, 2);
|
|
20835
20835
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
20836
20836
|
};
|
|
20837
|
-
var ZodError = class extends Error {
|
|
20837
|
+
var ZodError = class _ZodError extends Error {
|
|
20838
|
+
get errors() {
|
|
20839
|
+
return this.issues;
|
|
20840
|
+
}
|
|
20838
20841
|
constructor(issues) {
|
|
20839
20842
|
super();
|
|
20840
20843
|
this.issues = [];
|
|
@@ -20853,9 +20856,6 @@ var ZodError = class extends Error {
|
|
|
20853
20856
|
this.name = "ZodError";
|
|
20854
20857
|
this.issues = issues;
|
|
20855
20858
|
}
|
|
20856
|
-
get errors() {
|
|
20857
|
-
return this.issues;
|
|
20858
|
-
}
|
|
20859
20859
|
format(_mapper) {
|
|
20860
20860
|
const mapper = _mapper || function(issue) {
|
|
20861
20861
|
return issue.message;
|
|
@@ -20892,6 +20892,11 @@ var ZodError = class extends Error {
|
|
|
20892
20892
|
processError(this);
|
|
20893
20893
|
return fieldErrors;
|
|
20894
20894
|
}
|
|
20895
|
+
static assert(value) {
|
|
20896
|
+
if (!(value instanceof _ZodError)) {
|
|
20897
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
20898
|
+
}
|
|
20899
|
+
}
|
|
20895
20900
|
toString() {
|
|
20896
20901
|
return this.message;
|
|
20897
20902
|
}
|
|
@@ -21034,6 +21039,13 @@ var makeIssue = (params) => {
|
|
|
21034
21039
|
...issueData,
|
|
21035
21040
|
path: fullPath
|
|
21036
21041
|
};
|
|
21042
|
+
if (issueData.message !== void 0) {
|
|
21043
|
+
return {
|
|
21044
|
+
...issueData,
|
|
21045
|
+
path: fullPath,
|
|
21046
|
+
message: issueData.message
|
|
21047
|
+
};
|
|
21048
|
+
}
|
|
21037
21049
|
let errorMessage = "";
|
|
21038
21050
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
21039
21051
|
for (const map of maps) {
|
|
@@ -21042,20 +21054,24 @@ var makeIssue = (params) => {
|
|
|
21042
21054
|
return {
|
|
21043
21055
|
...issueData,
|
|
21044
21056
|
path: fullPath,
|
|
21045
|
-
message:
|
|
21057
|
+
message: errorMessage
|
|
21046
21058
|
};
|
|
21047
21059
|
};
|
|
21048
21060
|
var EMPTY_PATH = [];
|
|
21049
21061
|
function addIssueToContext(ctx, issueData) {
|
|
21062
|
+
const overrideMap = getErrorMap();
|
|
21050
21063
|
const issue = makeIssue({
|
|
21051
21064
|
issueData,
|
|
21052
21065
|
data: ctx.data,
|
|
21053
21066
|
path: ctx.path,
|
|
21054
21067
|
errorMaps: [
|
|
21055
21068
|
ctx.common.contextualErrorMap,
|
|
21069
|
+
// contextual error map is first priority
|
|
21056
21070
|
ctx.schemaErrorMap,
|
|
21057
|
-
|
|
21058
|
-
|
|
21071
|
+
// then schema-bound map if available
|
|
21072
|
+
overrideMap,
|
|
21073
|
+
// then global override map
|
|
21074
|
+
overrideMap === errorMap ? void 0 : errorMap
|
|
21059
21075
|
// then global default map
|
|
21060
21076
|
].filter((x) => !!x)
|
|
21061
21077
|
});
|
|
@@ -21087,9 +21103,11 @@ var ParseStatus = class _ParseStatus {
|
|
|
21087
21103
|
static async mergeObjectAsync(status, pairs) {
|
|
21088
21104
|
const syncPairs = [];
|
|
21089
21105
|
for (const pair of pairs) {
|
|
21106
|
+
const key = await pair.key;
|
|
21107
|
+
const value = await pair.value;
|
|
21090
21108
|
syncPairs.push({
|
|
21091
|
-
key
|
|
21092
|
-
value
|
|
21109
|
+
key,
|
|
21110
|
+
value
|
|
21093
21111
|
});
|
|
21094
21112
|
}
|
|
21095
21113
|
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
@@ -21122,11 +21140,24 @@ var isAborted = (x) => x.status === "aborted";
|
|
|
21122
21140
|
var isDirty = (x) => x.status === "dirty";
|
|
21123
21141
|
var isValid = (x) => x.status === "valid";
|
|
21124
21142
|
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
21143
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
21144
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
21145
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
21146
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21147
|
+
}
|
|
21148
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
21149
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
21150
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
21151
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
21152
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
21153
|
+
}
|
|
21125
21154
|
var errorUtil;
|
|
21126
21155
|
(function(errorUtil2) {
|
|
21127
21156
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
21128
21157
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
21129
21158
|
})(errorUtil || (errorUtil = {}));
|
|
21159
|
+
var _ZodEnum_cache;
|
|
21160
|
+
var _ZodNativeEnum_cache;
|
|
21130
21161
|
var ParseInputLazyPath = class {
|
|
21131
21162
|
constructor(parent, value, path, key) {
|
|
21132
21163
|
this._cachedPath = [];
|
|
@@ -21175,44 +21206,21 @@ function processCreateParams(params) {
|
|
|
21175
21206
|
if (errorMap2)
|
|
21176
21207
|
return { errorMap: errorMap2, description };
|
|
21177
21208
|
const customMap = (iss, ctx) => {
|
|
21178
|
-
|
|
21179
|
-
|
|
21209
|
+
var _a, _b;
|
|
21210
|
+
const { message } = params;
|
|
21211
|
+
if (iss.code === "invalid_enum_value") {
|
|
21212
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
|
21213
|
+
}
|
|
21180
21214
|
if (typeof ctx.data === "undefined") {
|
|
21181
|
-
return { message:
|
|
21215
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
|
21182
21216
|
}
|
|
21183
|
-
|
|
21217
|
+
if (iss.code !== "invalid_type")
|
|
21218
|
+
return { message: ctx.defaultError };
|
|
21219
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
|
21184
21220
|
};
|
|
21185
21221
|
return { errorMap: customMap, description };
|
|
21186
21222
|
}
|
|
21187
21223
|
var ZodType = class {
|
|
21188
|
-
constructor(def) {
|
|
21189
|
-
this.spa = this.safeParseAsync;
|
|
21190
|
-
this._def = def;
|
|
21191
|
-
this.parse = this.parse.bind(this);
|
|
21192
|
-
this.safeParse = this.safeParse.bind(this);
|
|
21193
|
-
this.parseAsync = this.parseAsync.bind(this);
|
|
21194
|
-
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
21195
|
-
this.spa = this.spa.bind(this);
|
|
21196
|
-
this.refine = this.refine.bind(this);
|
|
21197
|
-
this.refinement = this.refinement.bind(this);
|
|
21198
|
-
this.superRefine = this.superRefine.bind(this);
|
|
21199
|
-
this.optional = this.optional.bind(this);
|
|
21200
|
-
this.nullable = this.nullable.bind(this);
|
|
21201
|
-
this.nullish = this.nullish.bind(this);
|
|
21202
|
-
this.array = this.array.bind(this);
|
|
21203
|
-
this.promise = this.promise.bind(this);
|
|
21204
|
-
this.or = this.or.bind(this);
|
|
21205
|
-
this.and = this.and.bind(this);
|
|
21206
|
-
this.transform = this.transform.bind(this);
|
|
21207
|
-
this.brand = this.brand.bind(this);
|
|
21208
|
-
this.default = this.default.bind(this);
|
|
21209
|
-
this.catch = this.catch.bind(this);
|
|
21210
|
-
this.describe = this.describe.bind(this);
|
|
21211
|
-
this.pipe = this.pipe.bind(this);
|
|
21212
|
-
this.readonly = this.readonly.bind(this);
|
|
21213
|
-
this.isNullable = this.isNullable.bind(this);
|
|
21214
|
-
this.isOptional = this.isOptional.bind(this);
|
|
21215
|
-
}
|
|
21216
21224
|
get description() {
|
|
21217
21225
|
return this._def.description;
|
|
21218
21226
|
}
|
|
@@ -21276,6 +21284,43 @@ var ZodType = class {
|
|
|
21276
21284
|
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
21277
21285
|
return handleResult(ctx, result);
|
|
21278
21286
|
}
|
|
21287
|
+
"~validate"(data) {
|
|
21288
|
+
var _a, _b;
|
|
21289
|
+
const ctx = {
|
|
21290
|
+
common: {
|
|
21291
|
+
issues: [],
|
|
21292
|
+
async: !!this["~standard"].async
|
|
21293
|
+
},
|
|
21294
|
+
path: [],
|
|
21295
|
+
schemaErrorMap: this._def.errorMap,
|
|
21296
|
+
parent: null,
|
|
21297
|
+
data,
|
|
21298
|
+
parsedType: getParsedType(data)
|
|
21299
|
+
};
|
|
21300
|
+
if (!this["~standard"].async) {
|
|
21301
|
+
try {
|
|
21302
|
+
const result = this._parseSync({ data, path: [], parent: ctx });
|
|
21303
|
+
return isValid(result) ? {
|
|
21304
|
+
value: result.value
|
|
21305
|
+
} : {
|
|
21306
|
+
issues: ctx.common.issues
|
|
21307
|
+
};
|
|
21308
|
+
} catch (err) {
|
|
21309
|
+
if ((_b = (_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
|
|
21310
|
+
this["~standard"].async = true;
|
|
21311
|
+
}
|
|
21312
|
+
ctx.common = {
|
|
21313
|
+
issues: [],
|
|
21314
|
+
async: true
|
|
21315
|
+
};
|
|
21316
|
+
}
|
|
21317
|
+
}
|
|
21318
|
+
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
|
|
21319
|
+
value: result.value
|
|
21320
|
+
} : {
|
|
21321
|
+
issues: ctx.common.issues
|
|
21322
|
+
});
|
|
21323
|
+
}
|
|
21279
21324
|
async parseAsync(data, params) {
|
|
21280
21325
|
const result = await this.safeParseAsync(data, params);
|
|
21281
21326
|
if (result.success)
|
|
@@ -21353,6 +21398,39 @@ var ZodType = class {
|
|
|
21353
21398
|
superRefine(refinement) {
|
|
21354
21399
|
return this._refinement(refinement);
|
|
21355
21400
|
}
|
|
21401
|
+
constructor(def) {
|
|
21402
|
+
this.spa = this.safeParseAsync;
|
|
21403
|
+
this._def = def;
|
|
21404
|
+
this.parse = this.parse.bind(this);
|
|
21405
|
+
this.safeParse = this.safeParse.bind(this);
|
|
21406
|
+
this.parseAsync = this.parseAsync.bind(this);
|
|
21407
|
+
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
21408
|
+
this.spa = this.spa.bind(this);
|
|
21409
|
+
this.refine = this.refine.bind(this);
|
|
21410
|
+
this.refinement = this.refinement.bind(this);
|
|
21411
|
+
this.superRefine = this.superRefine.bind(this);
|
|
21412
|
+
this.optional = this.optional.bind(this);
|
|
21413
|
+
this.nullable = this.nullable.bind(this);
|
|
21414
|
+
this.nullish = this.nullish.bind(this);
|
|
21415
|
+
this.array = this.array.bind(this);
|
|
21416
|
+
this.promise = this.promise.bind(this);
|
|
21417
|
+
this.or = this.or.bind(this);
|
|
21418
|
+
this.and = this.and.bind(this);
|
|
21419
|
+
this.transform = this.transform.bind(this);
|
|
21420
|
+
this.brand = this.brand.bind(this);
|
|
21421
|
+
this.default = this.default.bind(this);
|
|
21422
|
+
this.catch = this.catch.bind(this);
|
|
21423
|
+
this.describe = this.describe.bind(this);
|
|
21424
|
+
this.pipe = this.pipe.bind(this);
|
|
21425
|
+
this.readonly = this.readonly.bind(this);
|
|
21426
|
+
this.isNullable = this.isNullable.bind(this);
|
|
21427
|
+
this.isOptional = this.isOptional.bind(this);
|
|
21428
|
+
this["~standard"] = {
|
|
21429
|
+
version: 1,
|
|
21430
|
+
vendor: "zod",
|
|
21431
|
+
validate: (data) => this["~validate"](data)
|
|
21432
|
+
};
|
|
21433
|
+
}
|
|
21356
21434
|
optional() {
|
|
21357
21435
|
return ZodOptional.create(this, this._def);
|
|
21358
21436
|
}
|
|
@@ -21363,7 +21441,7 @@ var ZodType = class {
|
|
|
21363
21441
|
return this.nullable().optional();
|
|
21364
21442
|
}
|
|
21365
21443
|
array() {
|
|
21366
|
-
return ZodArray.create(this
|
|
21444
|
+
return ZodArray.create(this);
|
|
21367
21445
|
}
|
|
21368
21446
|
promise() {
|
|
21369
21447
|
return ZodPromise.create(this, this._def);
|
|
@@ -21428,35 +21506,44 @@ var ZodType = class {
|
|
|
21428
21506
|
}
|
|
21429
21507
|
};
|
|
21430
21508
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
21431
|
-
var cuid2Regex = /^[
|
|
21432
|
-
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}
|
|
21509
|
+
var cuid2Regex = /^[0-9a-z]+$/;
|
|
21510
|
+
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
|
|
21433
21511
|
var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
|
21434
|
-
var
|
|
21512
|
+
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
21513
|
+
var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
|
21514
|
+
var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
21515
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
21435
21516
|
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
21436
21517
|
var emojiRegex;
|
|
21437
|
-
var ipv4Regex = /^((
|
|
21438
|
-
var
|
|
21439
|
-
var
|
|
21518
|
+
var ipv4Regex = /^(?:(?: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])$/;
|
|
21519
|
+
var ipv4CidrRegex = /^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/;
|
|
21520
|
+
var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
|
21521
|
+
var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
21522
|
+
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
21523
|
+
var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
|
21524
|
+
var dateRegexSource = `((\\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])))`;
|
|
21525
|
+
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
21526
|
+
function timeRegexSource(args) {
|
|
21527
|
+
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
|
21440
21528
|
if (args.precision) {
|
|
21441
|
-
|
|
21442
|
-
|
|
21443
|
-
|
|
21444
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
|
|
21445
|
-
}
|
|
21446
|
-
} else if (args.precision === 0) {
|
|
21447
|
-
if (args.offset) {
|
|
21448
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
21449
|
-
} else {
|
|
21450
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
|
|
21451
|
-
}
|
|
21452
|
-
} else {
|
|
21453
|
-
if (args.offset) {
|
|
21454
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
21455
|
-
} else {
|
|
21456
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
|
|
21457
|
-
}
|
|
21529
|
+
regex = `${regex}\\.\\d{${args.precision}}`;
|
|
21530
|
+
} else if (args.precision == null) {
|
|
21531
|
+
regex = `${regex}(\\.\\d+)?`;
|
|
21458
21532
|
}
|
|
21459
|
-
|
|
21533
|
+
return regex;
|
|
21534
|
+
}
|
|
21535
|
+
function timeRegex(args) {
|
|
21536
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
21537
|
+
}
|
|
21538
|
+
function datetimeRegex(args) {
|
|
21539
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
21540
|
+
const opts = [];
|
|
21541
|
+
opts.push(args.local ? `Z?` : `Z`);
|
|
21542
|
+
if (args.offset)
|
|
21543
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
21544
|
+
regex = `${regex}(${opts.join("|")})`;
|
|
21545
|
+
return new RegExp(`^${regex}$`);
|
|
21546
|
+
}
|
|
21460
21547
|
function isValidIP(ip, version2) {
|
|
21461
21548
|
if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) {
|
|
21462
21549
|
return true;
|
|
@@ -21466,6 +21553,33 @@ function isValidIP(ip, version2) {
|
|
|
21466
21553
|
}
|
|
21467
21554
|
return false;
|
|
21468
21555
|
}
|
|
21556
|
+
function isValidJWT(jwt, alg) {
|
|
21557
|
+
if (!jwtRegex.test(jwt))
|
|
21558
|
+
return false;
|
|
21559
|
+
try {
|
|
21560
|
+
const [header] = jwt.split(".");
|
|
21561
|
+
const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
|
21562
|
+
const decoded = JSON.parse(atob(base64));
|
|
21563
|
+
if (typeof decoded !== "object" || decoded === null)
|
|
21564
|
+
return false;
|
|
21565
|
+
if (!decoded.typ || !decoded.alg)
|
|
21566
|
+
return false;
|
|
21567
|
+
if (alg && decoded.alg !== alg)
|
|
21568
|
+
return false;
|
|
21569
|
+
return true;
|
|
21570
|
+
} catch (_a) {
|
|
21571
|
+
return false;
|
|
21572
|
+
}
|
|
21573
|
+
}
|
|
21574
|
+
function isValidCidr(ip, version2) {
|
|
21575
|
+
if ((version2 === "v4" || !version2) && ipv4CidrRegex.test(ip)) {
|
|
21576
|
+
return true;
|
|
21577
|
+
}
|
|
21578
|
+
if ((version2 === "v6" || !version2) && ipv6CidrRegex.test(ip)) {
|
|
21579
|
+
return true;
|
|
21580
|
+
}
|
|
21581
|
+
return false;
|
|
21582
|
+
}
|
|
21469
21583
|
var ZodString = class _ZodString extends ZodType {
|
|
21470
21584
|
_parse(input) {
|
|
21471
21585
|
if (this._def.coerce) {
|
|
@@ -21474,15 +21588,11 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
21474
21588
|
const parsedType = this._getType(input);
|
|
21475
21589
|
if (parsedType !== ZodParsedType.string) {
|
|
21476
21590
|
const ctx2 = this._getOrReturnCtx(input);
|
|
21477
|
-
addIssueToContext(
|
|
21478
|
-
|
|
21479
|
-
|
|
21480
|
-
|
|
21481
|
-
|
|
21482
|
-
received: ctx2.parsedType
|
|
21483
|
-
}
|
|
21484
|
-
//
|
|
21485
|
-
);
|
|
21591
|
+
addIssueToContext(ctx2, {
|
|
21592
|
+
code: ZodIssueCode.invalid_type,
|
|
21593
|
+
expected: ZodParsedType.string,
|
|
21594
|
+
received: ctx2.parsedType
|
|
21595
|
+
});
|
|
21486
21596
|
return INVALID;
|
|
21487
21597
|
}
|
|
21488
21598
|
const status = new ParseStatus();
|
|
@@ -21573,6 +21683,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
21573
21683
|
});
|
|
21574
21684
|
status.dirty();
|
|
21575
21685
|
}
|
|
21686
|
+
} else if (check.kind === "nanoid") {
|
|
21687
|
+
if (!nanoidRegex.test(input.data)) {
|
|
21688
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
21689
|
+
addIssueToContext(ctx, {
|
|
21690
|
+
validation: "nanoid",
|
|
21691
|
+
code: ZodIssueCode.invalid_string,
|
|
21692
|
+
message: check.message
|
|
21693
|
+
});
|
|
21694
|
+
status.dirty();
|
|
21695
|
+
}
|
|
21576
21696
|
} else if (check.kind === "cuid") {
|
|
21577
21697
|
if (!cuidRegex.test(input.data)) {
|
|
21578
21698
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -21674,6 +21794,38 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
21674
21794
|
});
|
|
21675
21795
|
status.dirty();
|
|
21676
21796
|
}
|
|
21797
|
+
} else if (check.kind === "date") {
|
|
21798
|
+
const regex = dateRegex;
|
|
21799
|
+
if (!regex.test(input.data)) {
|
|
21800
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
21801
|
+
addIssueToContext(ctx, {
|
|
21802
|
+
code: ZodIssueCode.invalid_string,
|
|
21803
|
+
validation: "date",
|
|
21804
|
+
message: check.message
|
|
21805
|
+
});
|
|
21806
|
+
status.dirty();
|
|
21807
|
+
}
|
|
21808
|
+
} else if (check.kind === "time") {
|
|
21809
|
+
const regex = timeRegex(check);
|
|
21810
|
+
if (!regex.test(input.data)) {
|
|
21811
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
21812
|
+
addIssueToContext(ctx, {
|
|
21813
|
+
code: ZodIssueCode.invalid_string,
|
|
21814
|
+
validation: "time",
|
|
21815
|
+
message: check.message
|
|
21816
|
+
});
|
|
21817
|
+
status.dirty();
|
|
21818
|
+
}
|
|
21819
|
+
} else if (check.kind === "duration") {
|
|
21820
|
+
if (!durationRegex.test(input.data)) {
|
|
21821
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
21822
|
+
addIssueToContext(ctx, {
|
|
21823
|
+
validation: "duration",
|
|
21824
|
+
code: ZodIssueCode.invalid_string,
|
|
21825
|
+
message: check.message
|
|
21826
|
+
});
|
|
21827
|
+
status.dirty();
|
|
21828
|
+
}
|
|
21677
21829
|
} else if (check.kind === "ip") {
|
|
21678
21830
|
if (!isValidIP(input.data, check.version)) {
|
|
21679
21831
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -21684,6 +21836,46 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
21684
21836
|
});
|
|
21685
21837
|
status.dirty();
|
|
21686
21838
|
}
|
|
21839
|
+
} else if (check.kind === "jwt") {
|
|
21840
|
+
if (!isValidJWT(input.data, check.alg)) {
|
|
21841
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
21842
|
+
addIssueToContext(ctx, {
|
|
21843
|
+
validation: "jwt",
|
|
21844
|
+
code: ZodIssueCode.invalid_string,
|
|
21845
|
+
message: check.message
|
|
21846
|
+
});
|
|
21847
|
+
status.dirty();
|
|
21848
|
+
}
|
|
21849
|
+
} else if (check.kind === "cidr") {
|
|
21850
|
+
if (!isValidCidr(input.data, check.version)) {
|
|
21851
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
21852
|
+
addIssueToContext(ctx, {
|
|
21853
|
+
validation: "cidr",
|
|
21854
|
+
code: ZodIssueCode.invalid_string,
|
|
21855
|
+
message: check.message
|
|
21856
|
+
});
|
|
21857
|
+
status.dirty();
|
|
21858
|
+
}
|
|
21859
|
+
} else if (check.kind === "base64") {
|
|
21860
|
+
if (!base64Regex.test(input.data)) {
|
|
21861
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
21862
|
+
addIssueToContext(ctx, {
|
|
21863
|
+
validation: "base64",
|
|
21864
|
+
code: ZodIssueCode.invalid_string,
|
|
21865
|
+
message: check.message
|
|
21866
|
+
});
|
|
21867
|
+
status.dirty();
|
|
21868
|
+
}
|
|
21869
|
+
} else if (check.kind === "base64url") {
|
|
21870
|
+
if (!base64urlRegex.test(input.data)) {
|
|
21871
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
21872
|
+
addIssueToContext(ctx, {
|
|
21873
|
+
validation: "base64url",
|
|
21874
|
+
code: ZodIssueCode.invalid_string,
|
|
21875
|
+
message: check.message
|
|
21876
|
+
});
|
|
21877
|
+
status.dirty();
|
|
21878
|
+
}
|
|
21687
21879
|
} else {
|
|
21688
21880
|
util.assertNever(check);
|
|
21689
21881
|
}
|
|
@@ -21715,6 +21907,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
21715
21907
|
uuid(message) {
|
|
21716
21908
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
21717
21909
|
}
|
|
21910
|
+
nanoid(message) {
|
|
21911
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
21912
|
+
}
|
|
21718
21913
|
cuid(message) {
|
|
21719
21914
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
21720
21915
|
}
|
|
@@ -21724,16 +21919,32 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
21724
21919
|
ulid(message) {
|
|
21725
21920
|
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
21726
21921
|
}
|
|
21922
|
+
base64(message) {
|
|
21923
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
21924
|
+
}
|
|
21925
|
+
base64url(message) {
|
|
21926
|
+
return this._addCheck({
|
|
21927
|
+
kind: "base64url",
|
|
21928
|
+
...errorUtil.errToObj(message)
|
|
21929
|
+
});
|
|
21930
|
+
}
|
|
21931
|
+
jwt(options) {
|
|
21932
|
+
return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
|
|
21933
|
+
}
|
|
21727
21934
|
ip(options) {
|
|
21728
21935
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
21729
21936
|
}
|
|
21937
|
+
cidr(options) {
|
|
21938
|
+
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
|
21939
|
+
}
|
|
21730
21940
|
datetime(options) {
|
|
21731
|
-
var _a;
|
|
21941
|
+
var _a, _b;
|
|
21732
21942
|
if (typeof options === "string") {
|
|
21733
21943
|
return this._addCheck({
|
|
21734
21944
|
kind: "datetime",
|
|
21735
21945
|
precision: null,
|
|
21736
21946
|
offset: false,
|
|
21947
|
+
local: false,
|
|
21737
21948
|
message: options
|
|
21738
21949
|
});
|
|
21739
21950
|
}
|
|
@@ -21741,9 +21952,30 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
21741
21952
|
kind: "datetime",
|
|
21742
21953
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
21743
21954
|
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
|
21955
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
|
21744
21956
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
21745
21957
|
});
|
|
21746
21958
|
}
|
|
21959
|
+
date(message) {
|
|
21960
|
+
return this._addCheck({ kind: "date", message });
|
|
21961
|
+
}
|
|
21962
|
+
time(options) {
|
|
21963
|
+
if (typeof options === "string") {
|
|
21964
|
+
return this._addCheck({
|
|
21965
|
+
kind: "time",
|
|
21966
|
+
precision: null,
|
|
21967
|
+
message: options
|
|
21968
|
+
});
|
|
21969
|
+
}
|
|
21970
|
+
return this._addCheck({
|
|
21971
|
+
kind: "time",
|
|
21972
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
21973
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
21974
|
+
});
|
|
21975
|
+
}
|
|
21976
|
+
duration(message) {
|
|
21977
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
21978
|
+
}
|
|
21747
21979
|
regex(regex, message) {
|
|
21748
21980
|
return this._addCheck({
|
|
21749
21981
|
kind: "regex",
|
|
@@ -21795,8 +22027,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
21795
22027
|
});
|
|
21796
22028
|
}
|
|
21797
22029
|
/**
|
|
21798
|
-
*
|
|
21799
|
-
* @see {@link ZodString.min}
|
|
22030
|
+
* Equivalent to `.min(1)`
|
|
21800
22031
|
*/
|
|
21801
22032
|
nonempty(message) {
|
|
21802
22033
|
return this.min(1, errorUtil.errToObj(message));
|
|
@@ -21822,6 +22053,15 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
21822
22053
|
get isDatetime() {
|
|
21823
22054
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
21824
22055
|
}
|
|
22056
|
+
get isDate() {
|
|
22057
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
22058
|
+
}
|
|
22059
|
+
get isTime() {
|
|
22060
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
22061
|
+
}
|
|
22062
|
+
get isDuration() {
|
|
22063
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
22064
|
+
}
|
|
21825
22065
|
get isEmail() {
|
|
21826
22066
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
21827
22067
|
}
|
|
@@ -21834,6 +22074,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
21834
22074
|
get isUUID() {
|
|
21835
22075
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
21836
22076
|
}
|
|
22077
|
+
get isNANOID() {
|
|
22078
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
22079
|
+
}
|
|
21837
22080
|
get isCUID() {
|
|
21838
22081
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
21839
22082
|
}
|
|
@@ -21846,6 +22089,15 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
21846
22089
|
get isIP() {
|
|
21847
22090
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
21848
22091
|
}
|
|
22092
|
+
get isCIDR() {
|
|
22093
|
+
return !!this._def.checks.find((ch) => ch.kind === "cidr");
|
|
22094
|
+
}
|
|
22095
|
+
get isBase64() {
|
|
22096
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
22097
|
+
}
|
|
22098
|
+
get isBase64url() {
|
|
22099
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64url");
|
|
22100
|
+
}
|
|
21849
22101
|
get minLength() {
|
|
21850
22102
|
let min = null;
|
|
21851
22103
|
for (const ch of this._def.checks) {
|
|
@@ -22123,17 +22375,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
22123
22375
|
}
|
|
22124
22376
|
_parse(input) {
|
|
22125
22377
|
if (this._def.coerce) {
|
|
22126
|
-
|
|
22378
|
+
try {
|
|
22379
|
+
input.data = BigInt(input.data);
|
|
22380
|
+
} catch (_a) {
|
|
22381
|
+
return this._getInvalidInput(input);
|
|
22382
|
+
}
|
|
22127
22383
|
}
|
|
22128
22384
|
const parsedType = this._getType(input);
|
|
22129
22385
|
if (parsedType !== ZodParsedType.bigint) {
|
|
22130
|
-
|
|
22131
|
-
addIssueToContext(ctx2, {
|
|
22132
|
-
code: ZodIssueCode.invalid_type,
|
|
22133
|
-
expected: ZodParsedType.bigint,
|
|
22134
|
-
received: ctx2.parsedType
|
|
22135
|
-
});
|
|
22136
|
-
return INVALID;
|
|
22386
|
+
return this._getInvalidInput(input);
|
|
22137
22387
|
}
|
|
22138
22388
|
let ctx = void 0;
|
|
22139
22389
|
const status = new ParseStatus();
|
|
@@ -22180,6 +22430,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
22180
22430
|
}
|
|
22181
22431
|
return { status: status.value, value: input.data };
|
|
22182
22432
|
}
|
|
22433
|
+
_getInvalidInput(input) {
|
|
22434
|
+
const ctx = this._getOrReturnCtx(input);
|
|
22435
|
+
addIssueToContext(ctx, {
|
|
22436
|
+
code: ZodIssueCode.invalid_type,
|
|
22437
|
+
expected: ZodParsedType.bigint,
|
|
22438
|
+
received: ctx.parsedType
|
|
22439
|
+
});
|
|
22440
|
+
return INVALID;
|
|
22441
|
+
}
|
|
22183
22442
|
gte(value, message) {
|
|
22184
22443
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
22185
22444
|
}
|
|
@@ -22758,9 +23017,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
22758
23017
|
const syncPairs = [];
|
|
22759
23018
|
for (const pair of pairs) {
|
|
22760
23019
|
const key = await pair.key;
|
|
23020
|
+
const value = await pair.value;
|
|
22761
23021
|
syncPairs.push({
|
|
22762
23022
|
key,
|
|
22763
|
-
value
|
|
23023
|
+
value,
|
|
22764
23024
|
alwaysSet: pair.alwaysSet
|
|
22765
23025
|
});
|
|
22766
23026
|
}
|
|
@@ -23111,15 +23371,25 @@ var getDiscriminator = (type) => {
|
|
|
23111
23371
|
} else if (type instanceof ZodEnum) {
|
|
23112
23372
|
return type.options;
|
|
23113
23373
|
} else if (type instanceof ZodNativeEnum) {
|
|
23114
|
-
return
|
|
23374
|
+
return util.objectValues(type.enum);
|
|
23115
23375
|
} else if (type instanceof ZodDefault) {
|
|
23116
23376
|
return getDiscriminator(type._def.innerType);
|
|
23117
23377
|
} else if (type instanceof ZodUndefined) {
|
|
23118
23378
|
return [void 0];
|
|
23119
23379
|
} else if (type instanceof ZodNull) {
|
|
23120
23380
|
return [null];
|
|
23381
|
+
} else if (type instanceof ZodOptional) {
|
|
23382
|
+
return [void 0, ...getDiscriminator(type.unwrap())];
|
|
23383
|
+
} else if (type instanceof ZodNullable) {
|
|
23384
|
+
return [null, ...getDiscriminator(type.unwrap())];
|
|
23385
|
+
} else if (type instanceof ZodBranded) {
|
|
23386
|
+
return getDiscriminator(type.unwrap());
|
|
23387
|
+
} else if (type instanceof ZodReadonly) {
|
|
23388
|
+
return getDiscriminator(type.unwrap());
|
|
23389
|
+
} else if (type instanceof ZodCatch) {
|
|
23390
|
+
return getDiscriminator(type._def.innerType);
|
|
23121
23391
|
} else {
|
|
23122
|
-
return
|
|
23392
|
+
return [];
|
|
23123
23393
|
}
|
|
23124
23394
|
};
|
|
23125
23395
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
@@ -23179,7 +23449,7 @@ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
|
23179
23449
|
const optionsMap = /* @__PURE__ */ new Map();
|
|
23180
23450
|
for (const type of options) {
|
|
23181
23451
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
23182
|
-
if (!discriminatorValues) {
|
|
23452
|
+
if (!discriminatorValues.length) {
|
|
23183
23453
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
23184
23454
|
}
|
|
23185
23455
|
for (const value of discriminatorValues) {
|
|
@@ -23379,7 +23649,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
23379
23649
|
for (const key in ctx.data) {
|
|
23380
23650
|
pairs.push({
|
|
23381
23651
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
23382
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
|
23652
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
|
23653
|
+
alwaysSet: key in ctx.data
|
|
23383
23654
|
});
|
|
23384
23655
|
}
|
|
23385
23656
|
if (ctx.common.async) {
|
|
@@ -23723,6 +23994,10 @@ function createZodEnum(values, params) {
|
|
|
23723
23994
|
});
|
|
23724
23995
|
}
|
|
23725
23996
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
23997
|
+
constructor() {
|
|
23998
|
+
super(...arguments);
|
|
23999
|
+
_ZodEnum_cache.set(this, void 0);
|
|
24000
|
+
}
|
|
23726
24001
|
_parse(input) {
|
|
23727
24002
|
if (typeof input.data !== "string") {
|
|
23728
24003
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -23734,7 +24009,10 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
23734
24009
|
});
|
|
23735
24010
|
return INVALID;
|
|
23736
24011
|
}
|
|
23737
|
-
if (this
|
|
24012
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
|
|
24013
|
+
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
|
24014
|
+
}
|
|
24015
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
|
23738
24016
|
const ctx = this._getOrReturnCtx(input);
|
|
23739
24017
|
const expectedValues = this._def.values;
|
|
23740
24018
|
addIssueToContext(ctx, {
|
|
@@ -23770,15 +24048,26 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
23770
24048
|
}
|
|
23771
24049
|
return enumValues;
|
|
23772
24050
|
}
|
|
23773
|
-
extract(values) {
|
|
23774
|
-
return _ZodEnum.create(values
|
|
24051
|
+
extract(values, newDef = this._def) {
|
|
24052
|
+
return _ZodEnum.create(values, {
|
|
24053
|
+
...this._def,
|
|
24054
|
+
...newDef
|
|
24055
|
+
});
|
|
23775
24056
|
}
|
|
23776
|
-
exclude(values) {
|
|
23777
|
-
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt))
|
|
24057
|
+
exclude(values, newDef = this._def) {
|
|
24058
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
24059
|
+
...this._def,
|
|
24060
|
+
...newDef
|
|
24061
|
+
});
|
|
23778
24062
|
}
|
|
23779
24063
|
};
|
|
24064
|
+
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
23780
24065
|
ZodEnum.create = createZodEnum;
|
|
23781
24066
|
var ZodNativeEnum = class extends ZodType {
|
|
24067
|
+
constructor() {
|
|
24068
|
+
super(...arguments);
|
|
24069
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
|
24070
|
+
}
|
|
23782
24071
|
_parse(input) {
|
|
23783
24072
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
23784
24073
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -23791,7 +24080,10 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
23791
24080
|
});
|
|
23792
24081
|
return INVALID;
|
|
23793
24082
|
}
|
|
23794
|
-
if (
|
|
24083
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
|
|
24084
|
+
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
|
24085
|
+
}
|
|
24086
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
|
23795
24087
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
23796
24088
|
addIssueToContext(ctx, {
|
|
23797
24089
|
received: ctx.data,
|
|
@@ -23806,6 +24098,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
23806
24098
|
return this._def.values;
|
|
23807
24099
|
}
|
|
23808
24100
|
};
|
|
24101
|
+
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
23809
24102
|
ZodNativeEnum.create = (values, params) => {
|
|
23810
24103
|
return new ZodNativeEnum({
|
|
23811
24104
|
values,
|
|
@@ -23869,26 +24162,38 @@ var ZodEffects = class extends ZodType {
|
|
|
23869
24162
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
23870
24163
|
if (effect.type === "preprocess") {
|
|
23871
24164
|
const processed = effect.transform(ctx.data, checkCtx);
|
|
23872
|
-
if (ctx.common.issues.length) {
|
|
23873
|
-
return {
|
|
23874
|
-
status: "dirty",
|
|
23875
|
-
value: ctx.data
|
|
23876
|
-
};
|
|
23877
|
-
}
|
|
23878
24165
|
if (ctx.common.async) {
|
|
23879
|
-
return Promise.resolve(processed).then((processed2) => {
|
|
23880
|
-
|
|
24166
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
|
24167
|
+
if (status.value === "aborted")
|
|
24168
|
+
return INVALID;
|
|
24169
|
+
const result = await this._def.schema._parseAsync({
|
|
23881
24170
|
data: processed2,
|
|
23882
24171
|
path: ctx.path,
|
|
23883
24172
|
parent: ctx
|
|
23884
24173
|
});
|
|
24174
|
+
if (result.status === "aborted")
|
|
24175
|
+
return INVALID;
|
|
24176
|
+
if (result.status === "dirty")
|
|
24177
|
+
return DIRTY(result.value);
|
|
24178
|
+
if (status.value === "dirty")
|
|
24179
|
+
return DIRTY(result.value);
|
|
24180
|
+
return result;
|
|
23885
24181
|
});
|
|
23886
24182
|
} else {
|
|
23887
|
-
|
|
24183
|
+
if (status.value === "aborted")
|
|
24184
|
+
return INVALID;
|
|
24185
|
+
const result = this._def.schema._parseSync({
|
|
23888
24186
|
data: processed,
|
|
23889
24187
|
path: ctx.path,
|
|
23890
24188
|
parent: ctx
|
|
23891
24189
|
});
|
|
24190
|
+
if (result.status === "aborted")
|
|
24191
|
+
return INVALID;
|
|
24192
|
+
if (result.status === "dirty")
|
|
24193
|
+
return DIRTY(result.value);
|
|
24194
|
+
if (status.value === "dirty")
|
|
24195
|
+
return DIRTY(result.value);
|
|
24196
|
+
return result;
|
|
23892
24197
|
}
|
|
23893
24198
|
}
|
|
23894
24199
|
if (effect.type === "refinement") {
|
|
@@ -24177,10 +24482,16 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
24177
24482
|
var ZodReadonly = class extends ZodType {
|
|
24178
24483
|
_parse(input) {
|
|
24179
24484
|
const result = this._def.innerType._parse(input);
|
|
24180
|
-
|
|
24181
|
-
|
|
24182
|
-
|
|
24183
|
-
|
|
24485
|
+
const freeze = (data) => {
|
|
24486
|
+
if (isValid(data)) {
|
|
24487
|
+
data.value = Object.freeze(data.value);
|
|
24488
|
+
}
|
|
24489
|
+
return data;
|
|
24490
|
+
};
|
|
24491
|
+
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
|
24492
|
+
}
|
|
24493
|
+
unwrap() {
|
|
24494
|
+
return this._def.innerType;
|
|
24184
24495
|
}
|
|
24185
24496
|
};
|
|
24186
24497
|
ZodReadonly.create = (type, params) => {
|
|
@@ -24190,7 +24501,7 @@ ZodReadonly.create = (type, params) => {
|
|
|
24190
24501
|
...processCreateParams(params)
|
|
24191
24502
|
});
|
|
24192
24503
|
};
|
|
24193
|
-
|
|
24504
|
+
function custom(check, params = {}, fatal) {
|
|
24194
24505
|
if (check)
|
|
24195
24506
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
24196
24507
|
var _a, _b;
|
|
@@ -24202,7 +24513,7 @@ var custom = (check, params = {}, fatal) => {
|
|
|
24202
24513
|
}
|
|
24203
24514
|
});
|
|
24204
24515
|
return ZodAny.create();
|
|
24205
|
-
}
|
|
24516
|
+
}
|
|
24206
24517
|
var late = {
|
|
24207
24518
|
object: ZodObject.lazycreate
|
|
24208
24519
|
};
|
|
@@ -24321,6 +24632,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
24321
24632
|
ZodParsedType,
|
|
24322
24633
|
getParsedType,
|
|
24323
24634
|
ZodType,
|
|
24635
|
+
datetimeRegex,
|
|
24324
24636
|
ZodString,
|
|
24325
24637
|
ZodNumber,
|
|
24326
24638
|
ZodBigInt,
|
|
@@ -24577,7 +24889,7 @@ function fromError(err, options = {}) {
|
|
|
24577
24889
|
}
|
|
24578
24890
|
|
|
24579
24891
|
// package.json
|
|
24580
|
-
var version = "0.1.
|
|
24892
|
+
var version = "0.1.6";
|
|
24581
24893
|
|
|
24582
24894
|
// src/evaluations.ts
|
|
24583
24895
|
var evaluate = async (params) => {
|
|
@@ -26052,18 +26364,10 @@ var spanTypesSchema = z.union([
|
|
|
26052
26364
|
]);
|
|
26053
26365
|
var traceInputSchema = z.object({
|
|
26054
26366
|
value: z.string(),
|
|
26055
|
-
embeddings: z.object({
|
|
26056
|
-
model: z.string(),
|
|
26057
|
-
embeddings: z.array(z.number())
|
|
26058
|
-
}).optional(),
|
|
26059
26367
|
satisfaction_score: z.number().optional()
|
|
26060
26368
|
});
|
|
26061
26369
|
var traceOutputSchema = z.object({
|
|
26062
|
-
value: z.string()
|
|
26063
|
-
embeddings: z.object({
|
|
26064
|
-
model: z.string(),
|
|
26065
|
-
embeddings: z.array(z.number())
|
|
26066
|
-
}).optional()
|
|
26370
|
+
value: z.string()
|
|
26067
26371
|
});
|
|
26068
26372
|
var primitiveTypeSchema = z.union([z.string(), z.number(), z.boolean(), z.undefined()]).nullable();
|
|
26069
26373
|
var reservedTraceMetadataSchema = z.object({
|
|
@@ -26263,44 +26567,6 @@ var collectorRESTParamsSchema = z.object({
|
|
|
26263
26567
|
evaluations: z.array(rESTEvaluationSchema).optional()
|
|
26264
26568
|
});
|
|
26265
26569
|
var collectorRESTParamsValidatorSchema = collectorRESTParamsSchema.omit({ spans: true });
|
|
26266
|
-
var datasetSpanSchema = z.union([
|
|
26267
|
-
baseSpanSchema.omit({
|
|
26268
|
-
project_id: true,
|
|
26269
|
-
trace_id: true,
|
|
26270
|
-
id: true,
|
|
26271
|
-
timestamps: true,
|
|
26272
|
-
metrics: true,
|
|
26273
|
-
params: true
|
|
26274
|
-
}).and(
|
|
26275
|
-
z.object({
|
|
26276
|
-
params: z.record(z.any())
|
|
26277
|
-
})
|
|
26278
|
-
),
|
|
26279
|
-
lLMSpanSchema.omit({
|
|
26280
|
-
project_id: true,
|
|
26281
|
-
trace_id: true,
|
|
26282
|
-
id: true,
|
|
26283
|
-
timestamps: true,
|
|
26284
|
-
metrics: true,
|
|
26285
|
-
params: true
|
|
26286
|
-
}).and(
|
|
26287
|
-
z.object({
|
|
26288
|
-
params: z.record(z.any())
|
|
26289
|
-
})
|
|
26290
|
-
),
|
|
26291
|
-
rAGSpanSchema.omit({
|
|
26292
|
-
project_id: true,
|
|
26293
|
-
trace_id: true,
|
|
26294
|
-
id: true,
|
|
26295
|
-
timestamps: true,
|
|
26296
|
-
metrics: true,
|
|
26297
|
-
params: true
|
|
26298
|
-
}).and(
|
|
26299
|
-
z.object({
|
|
26300
|
-
params: z.record(z.any())
|
|
26301
|
-
})
|
|
26302
|
-
)
|
|
26303
|
-
]);
|
|
26304
26570
|
var traceSchema = z.object({
|
|
26305
26571
|
trace_id: z.string(),
|
|
26306
26572
|
project_id: z.string(),
|
|
@@ -26427,6 +26693,9 @@ function convertFromVercelAIMessages(messages) {
|
|
|
26427
26693
|
}
|
|
26428
26694
|
};
|
|
26429
26695
|
}
|
|
26696
|
+
default: {
|
|
26697
|
+
return part;
|
|
26698
|
+
}
|
|
26430
26699
|
}
|
|
26431
26700
|
}) : content
|
|
26432
26701
|
});
|