@learncard/react 2.7.88 → 2.7.90
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/cjs/{BoostGenericCard-f31329d3.js → BoostGenericCard-bbe7a765.js} +2 -2
- package/dist/cjs/{BoostGenericCard-f31329d3.js.map → BoostGenericCard-bbe7a765.js.map} +1 -1
- package/dist/cjs/{CertDisplayCardSkillsCount-35295e49.js → CertDisplayCardSkillsCount-c378dceb.js} +2 -2
- package/dist/cjs/{CertDisplayCardSkillsCount-35295e49.js.map → CertDisplayCardSkillsCount-c378dceb.js.map} +1 -1
- package/dist/cjs/{CertificateDisplayCard-4852af08.js → CertificateDisplayCard-46e421f3.js} +15 -15
- package/dist/cjs/{CertificateDisplayCard-4852af08.js.map → CertificateDisplayCard-46e421f3.js.map} +1 -1
- package/dist/cjs/{MeritBadgeDisplayCard-5a95c756.js → MeritBadgeDisplayCard-c361f850.js} +13 -13
- package/dist/{esm/MeritBadgeDisplayCard-281dab67.js.map → cjs/MeritBadgeDisplayCard-c361f850.js.map} +1 -1
- package/dist/cjs/{MeritBadgeSkillsCount-c9088efe.js → MeritBadgeSkillsCount-35cc6c3b.js} +2 -2
- package/dist/cjs/{MeritBadgeSkillsCount-c9088efe.js.map → MeritBadgeSkillsCount-35cc6c3b.js.map} +1 -1
- package/dist/cjs/{VCCard-856ca271.js → VCCard-f3273b0b.js} +3 -3
- package/dist/cjs/{VCCard-856ca271.js.map → VCCard-f3273b0b.js.map} +1 -1
- package/dist/cjs/{VCDisplayBackFace-a33b91a2.js → VCDisplayBackFace-3b7d4a38.js} +3 -3
- package/dist/cjs/{VCDisplayBackFace-a33b91a2.js.map → VCDisplayBackFace-3b7d4a38.js.map} +1 -1
- package/dist/cjs/{VCDisplayCard-04ea222c.js → VCDisplayCard-2d94d58e.js} +3 -3
- package/dist/cjs/{VCDisplayCard-04ea222c.js.map → VCDisplayCard-2d94d58e.js.map} +1 -1
- package/dist/cjs/{VCDisplayCard2-ff8a2f1d.js → VCDisplayCard2-9adb0bb8.js} +5 -5
- package/dist/cjs/{VCDisplayCard2-ff8a2f1d.js.map → VCDisplayCard2-9adb0bb8.js.map} +1 -1
- package/dist/cjs/{VCVerificationPill-d9966b44.js → VCVerificationPill-16778f6f.js} +2 -2
- package/dist/cjs/{VCVerificationPill-d9966b44.js.map → VCVerificationPill-16778f6f.js.map} +1 -1
- package/dist/cjs/{credential.helpers-1936ce50.js → credential.helpers-15e0322f.js} +10 -10
- package/dist/cjs/{credential.helpers-1936ce50.js.map → credential.helpers-15e0322f.js.map} +1 -1
- package/dist/cjs/index.js +12 -12
- package/dist/cjs/index13.js +12 -12
- package/dist/cjs/index21.js +4 -4
- package/dist/cjs/index3.js +4 -4
- package/dist/cjs/index37.js +10 -10
- package/dist/cjs/index38.js +4 -4
- package/dist/cjs/index39.js +5 -5
- package/dist/cjs/index40.js +6 -6
- package/dist/cjs/index41.js +1 -1
- package/dist/cjs/index44.js +2 -2
- package/dist/cjs/index6.js +4 -4
- package/dist/cjs/{types.esm-ced7f0c4.js → types.esm-92a8b372.js} +1618 -786
- package/dist/cjs/types.esm-92a8b372.js.map +1 -0
- package/dist/esm/{BoostGenericCard-b38e84da.js → BoostGenericCard-ce5f829b.js} +2 -2
- package/dist/esm/{BoostGenericCard-b38e84da.js.map → BoostGenericCard-ce5f829b.js.map} +1 -1
- package/dist/esm/{CertDisplayCardSkillsCount-cdd436d9.js → CertDisplayCardSkillsCount-96bf97fa.js} +2 -2
- package/dist/esm/{CertDisplayCardSkillsCount-cdd436d9.js.map → CertDisplayCardSkillsCount-96bf97fa.js.map} +1 -1
- package/dist/esm/{CertificateDisplayCard-51db0038.js → CertificateDisplayCard-e9104336.js} +15 -15
- package/dist/esm/{CertificateDisplayCard-51db0038.js.map → CertificateDisplayCard-e9104336.js.map} +1 -1
- package/dist/esm/{MeritBadgeDisplayCard-281dab67.js → MeritBadgeDisplayCard-7de6bc73.js} +13 -13
- package/dist/{cjs/MeritBadgeDisplayCard-5a95c756.js.map → esm/MeritBadgeDisplayCard-7de6bc73.js.map} +1 -1
- package/dist/esm/{MeritBadgeSkillsCount-6674edbe.js → MeritBadgeSkillsCount-23f4fdb2.js} +2 -2
- package/dist/esm/{MeritBadgeSkillsCount-6674edbe.js.map → MeritBadgeSkillsCount-23f4fdb2.js.map} +1 -1
- package/dist/esm/{VCCard-69ec463e.js → VCCard-670e0f89.js} +3 -3
- package/dist/esm/{VCCard-69ec463e.js.map → VCCard-670e0f89.js.map} +1 -1
- package/dist/esm/{VCDisplayBackFace-aa34749d.js → VCDisplayBackFace-f4229413.js} +3 -3
- package/dist/esm/{VCDisplayBackFace-aa34749d.js.map → VCDisplayBackFace-f4229413.js.map} +1 -1
- package/dist/esm/{VCDisplayCard-d5618577.js → VCDisplayCard-6b3e1a8d.js} +3 -3
- package/dist/esm/{VCDisplayCard-d5618577.js.map → VCDisplayCard-6b3e1a8d.js.map} +1 -1
- package/dist/esm/{VCDisplayCard2-6a25107a.js → VCDisplayCard2-9743094a.js} +5 -5
- package/dist/esm/{VCDisplayCard2-6a25107a.js.map → VCDisplayCard2-9743094a.js.map} +1 -1
- package/dist/esm/{VCVerificationPill-5801d8e6.js → VCVerificationPill-699afb09.js} +2 -2
- package/dist/esm/{VCVerificationPill-5801d8e6.js.map → VCVerificationPill-699afb09.js.map} +1 -1
- package/dist/esm/{credential.helpers-6022957d.js → credential.helpers-8431ac8c.js} +10 -10
- package/dist/esm/{credential.helpers-6022957d.js.map → credential.helpers-8431ac8c.js.map} +1 -1
- package/dist/esm/index.js +12 -12
- package/dist/esm/index13.js +12 -12
- package/dist/esm/index21.js +4 -4
- package/dist/esm/index3.js +4 -4
- package/dist/esm/index37.js +10 -10
- package/dist/esm/index38.js +4 -4
- package/dist/esm/index39.js +5 -5
- package/dist/esm/index40.js +6 -6
- package/dist/esm/index41.js +1 -1
- package/dist/esm/index44.js +2 -2
- package/dist/esm/index6.js +4 -4
- package/dist/esm/{types.esm-7e3862b6.js → types.esm-61ee6e29.js} +1618 -786
- package/dist/esm/types.esm-61ee6e29.js.map +1 -0
- package/dist/main.css +1 -1
- package/dist/main.js +1 -1
- package/package.json +3 -3
- package/dist/cjs/types.esm-ced7f0c4.js.map +0 -1
- package/dist/esm/types.esm-7e3862b6.js.map +0 -1
|
@@ -61,6 +61,15 @@ var util;
|
|
|
61
61
|
return value;
|
|
62
62
|
};
|
|
63
63
|
})(util || (util = {}));
|
|
64
|
+
var objectUtil;
|
|
65
|
+
(function (objectUtil) {
|
|
66
|
+
objectUtil.mergeShapes = (first, second) => {
|
|
67
|
+
return {
|
|
68
|
+
...first,
|
|
69
|
+
...second, // second overwrites first
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
})(objectUtil || (objectUtil = {}));
|
|
64
73
|
const ZodParsedType = util.arrayToEnum([
|
|
65
74
|
"string",
|
|
66
75
|
"nan",
|
|
@@ -223,6 +232,11 @@ class ZodError extends Error {
|
|
|
223
232
|
processError(this);
|
|
224
233
|
return fieldErrors;
|
|
225
234
|
}
|
|
235
|
+
static assert(value) {
|
|
236
|
+
if (!(value instanceof ZodError)) {
|
|
237
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
226
240
|
toString() {
|
|
227
241
|
return this.message;
|
|
228
242
|
}
|
|
@@ -292,7 +306,13 @@ const errorMap = (issue, _ctx) => {
|
|
|
292
306
|
break;
|
|
293
307
|
case ZodIssueCode.invalid_string:
|
|
294
308
|
if (typeof issue.validation === "object") {
|
|
295
|
-
if ("
|
|
309
|
+
if ("includes" in issue.validation) {
|
|
310
|
+
message = `Invalid input: must include "${issue.validation.includes}"`;
|
|
311
|
+
if (typeof issue.validation.position === "number") {
|
|
312
|
+
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
else if ("startsWith" in issue.validation) {
|
|
296
316
|
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
297
317
|
}
|
|
298
318
|
else if ("endsWith" in issue.validation) {
|
|
@@ -325,7 +345,7 @@ const errorMap = (issue, _ctx) => {
|
|
|
325
345
|
? `exactly equal to `
|
|
326
346
|
: issue.inclusive
|
|
327
347
|
? `greater than or equal to `
|
|
328
|
-
: `greater than `}${new Date(issue.minimum)}`;
|
|
348
|
+
: `greater than `}${new Date(Number(issue.minimum))}`;
|
|
329
349
|
else
|
|
330
350
|
message = "Invalid input";
|
|
331
351
|
break;
|
|
@@ -340,12 +360,18 @@ const errorMap = (issue, _ctx) => {
|
|
|
340
360
|
: issue.inclusive
|
|
341
361
|
? `less than or equal to`
|
|
342
362
|
: `less than`} ${issue.maximum}`;
|
|
363
|
+
else if (issue.type === "bigint")
|
|
364
|
+
message = `BigInt must be ${issue.exact
|
|
365
|
+
? `exactly`
|
|
366
|
+
: issue.inclusive
|
|
367
|
+
? `less than or equal to`
|
|
368
|
+
: `less than`} ${issue.maximum}`;
|
|
343
369
|
else if (issue.type === "date")
|
|
344
370
|
message = `Date must be ${issue.exact
|
|
345
371
|
? `exactly`
|
|
346
372
|
: issue.inclusive
|
|
347
373
|
? `smaller than or equal to`
|
|
348
|
-
: `smaller than`} ${new Date(issue.maximum)}`;
|
|
374
|
+
: `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
349
375
|
else
|
|
350
376
|
message = "Invalid input";
|
|
351
377
|
break;
|
|
@@ -383,6 +409,13 @@ const makeIssue = (params) => {
|
|
|
383
409
|
...issueData,
|
|
384
410
|
path: fullPath,
|
|
385
411
|
};
|
|
412
|
+
if (issueData.message !== undefined) {
|
|
413
|
+
return {
|
|
414
|
+
...issueData,
|
|
415
|
+
path: fullPath,
|
|
416
|
+
message: issueData.message,
|
|
417
|
+
};
|
|
418
|
+
}
|
|
386
419
|
let errorMessage = "";
|
|
387
420
|
const maps = errorMaps
|
|
388
421
|
.filter((m) => !!m)
|
|
@@ -394,11 +427,12 @@ const makeIssue = (params) => {
|
|
|
394
427
|
return {
|
|
395
428
|
...issueData,
|
|
396
429
|
path: fullPath,
|
|
397
|
-
message:
|
|
430
|
+
message: errorMessage,
|
|
398
431
|
};
|
|
399
432
|
};
|
|
400
433
|
const EMPTY_PATH = [];
|
|
401
434
|
function addIssueToContext(ctx, issueData) {
|
|
435
|
+
const overrideMap = getErrorMap();
|
|
402
436
|
const issue = makeIssue({
|
|
403
437
|
issueData: issueData,
|
|
404
438
|
data: ctx.data,
|
|
@@ -406,8 +440,8 @@ function addIssueToContext(ctx, issueData) {
|
|
|
406
440
|
errorMaps: [
|
|
407
441
|
ctx.common.contextualErrorMap,
|
|
408
442
|
ctx.schemaErrorMap,
|
|
409
|
-
|
|
410
|
-
errorMap, // then global default map
|
|
443
|
+
overrideMap,
|
|
444
|
+
overrideMap === errorMap ? undefined : errorMap, // then global default map
|
|
411
445
|
].filter((x) => !!x),
|
|
412
446
|
});
|
|
413
447
|
ctx.common.issues.push(issue);
|
|
@@ -438,9 +472,11 @@ class ParseStatus {
|
|
|
438
472
|
static async mergeObjectAsync(status, pairs) {
|
|
439
473
|
const syncPairs = [];
|
|
440
474
|
for (const pair of pairs) {
|
|
475
|
+
const key = await pair.key;
|
|
476
|
+
const value = await pair.value;
|
|
441
477
|
syncPairs.push({
|
|
442
|
-
key
|
|
443
|
-
value
|
|
478
|
+
key,
|
|
479
|
+
value,
|
|
444
480
|
});
|
|
445
481
|
}
|
|
446
482
|
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
@@ -457,7 +493,8 @@ class ParseStatus {
|
|
|
457
493
|
status.dirty();
|
|
458
494
|
if (value.status === "dirty")
|
|
459
495
|
status.dirty();
|
|
460
|
-
if (
|
|
496
|
+
if (key.value !== "__proto__" &&
|
|
497
|
+
(typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
461
498
|
finalObject[key.value] = value.value;
|
|
462
499
|
}
|
|
463
500
|
}
|
|
@@ -472,7 +509,40 @@ const OK = (value) => ({ status: "valid", value });
|
|
|
472
509
|
const isAborted = (x) => x.status === "aborted";
|
|
473
510
|
const isDirty = (x) => x.status === "dirty";
|
|
474
511
|
const isValid = (x) => x.status === "valid";
|
|
475
|
-
const isAsync = (x) => typeof Promise !== undefined && x instanceof Promise;
|
|
512
|
+
const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
513
|
+
|
|
514
|
+
/******************************************************************************
|
|
515
|
+
Copyright (c) Microsoft Corporation.
|
|
516
|
+
|
|
517
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
518
|
+
purpose with or without fee is hereby granted.
|
|
519
|
+
|
|
520
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
521
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
522
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
523
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
524
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
525
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
526
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
527
|
+
***************************************************************************** */
|
|
528
|
+
|
|
529
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
530
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
531
|
+
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");
|
|
532
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
536
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
537
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
538
|
+
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");
|
|
539
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
543
|
+
var e = new Error(message);
|
|
544
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
545
|
+
};
|
|
476
546
|
|
|
477
547
|
var errorUtil;
|
|
478
548
|
(function (errorUtil) {
|
|
@@ -480,15 +550,25 @@ var errorUtil;
|
|
|
480
550
|
errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
481
551
|
})(errorUtil || (errorUtil = {}));
|
|
482
552
|
|
|
553
|
+
var _ZodEnum_cache, _ZodNativeEnum_cache;
|
|
483
554
|
class ParseInputLazyPath {
|
|
484
555
|
constructor(parent, value, path, key) {
|
|
556
|
+
this._cachedPath = [];
|
|
485
557
|
this.parent = parent;
|
|
486
558
|
this.data = value;
|
|
487
559
|
this._path = path;
|
|
488
560
|
this._key = key;
|
|
489
561
|
}
|
|
490
562
|
get path() {
|
|
491
|
-
|
|
563
|
+
if (!this._cachedPath.length) {
|
|
564
|
+
if (this._key instanceof Array) {
|
|
565
|
+
this._cachedPath.push(...this._path, ...this._key);
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
this._cachedPath.push(...this._path, this._key);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
return this._cachedPath;
|
|
492
572
|
}
|
|
493
573
|
}
|
|
494
574
|
const handleResult = (ctx, result) => {
|
|
@@ -499,8 +579,16 @@ const handleResult = (ctx, result) => {
|
|
|
499
579
|
if (!ctx.common.issues.length) {
|
|
500
580
|
throw new Error("Validation failed but no issues detected.");
|
|
501
581
|
}
|
|
502
|
-
|
|
503
|
-
|
|
582
|
+
return {
|
|
583
|
+
success: false,
|
|
584
|
+
get error() {
|
|
585
|
+
if (this._error)
|
|
586
|
+
return this._error;
|
|
587
|
+
const error = new ZodError(ctx.common.issues);
|
|
588
|
+
this._error = error;
|
|
589
|
+
return this._error;
|
|
590
|
+
},
|
|
591
|
+
};
|
|
504
592
|
}
|
|
505
593
|
};
|
|
506
594
|
function processCreateParams(params) {
|
|
@@ -513,12 +601,17 @@ function processCreateParams(params) {
|
|
|
513
601
|
if (errorMap)
|
|
514
602
|
return { errorMap: errorMap, description };
|
|
515
603
|
const customMap = (iss, ctx) => {
|
|
516
|
-
|
|
517
|
-
|
|
604
|
+
var _a, _b;
|
|
605
|
+
const { message } = params;
|
|
606
|
+
if (iss.code === "invalid_enum_value") {
|
|
607
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
|
608
|
+
}
|
|
518
609
|
if (typeof ctx.data === "undefined") {
|
|
519
|
-
return { message:
|
|
610
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
|
520
611
|
}
|
|
521
|
-
|
|
612
|
+
if (iss.code !== "invalid_type")
|
|
613
|
+
return { message: ctx.defaultError };
|
|
614
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
|
522
615
|
};
|
|
523
616
|
return { errorMap: customMap, description };
|
|
524
617
|
}
|
|
@@ -548,6 +641,7 @@ class ZodType {
|
|
|
548
641
|
this.catch = this.catch.bind(this);
|
|
549
642
|
this.describe = this.describe.bind(this);
|
|
550
643
|
this.pipe = this.pipe.bind(this);
|
|
644
|
+
this.readonly = this.readonly.bind(this);
|
|
551
645
|
this.isNullable = this.isNullable.bind(this);
|
|
552
646
|
this.isOptional = this.isOptional.bind(this);
|
|
553
647
|
}
|
|
@@ -701,28 +795,29 @@ class ZodType {
|
|
|
701
795
|
return this._refinement(refinement);
|
|
702
796
|
}
|
|
703
797
|
optional() {
|
|
704
|
-
return ZodOptional.create(this);
|
|
798
|
+
return ZodOptional.create(this, this._def);
|
|
705
799
|
}
|
|
706
800
|
nullable() {
|
|
707
|
-
return ZodNullable.create(this);
|
|
801
|
+
return ZodNullable.create(this, this._def);
|
|
708
802
|
}
|
|
709
803
|
nullish() {
|
|
710
|
-
return this.
|
|
804
|
+
return this.nullable().optional();
|
|
711
805
|
}
|
|
712
806
|
array() {
|
|
713
|
-
return ZodArray.create(this);
|
|
807
|
+
return ZodArray.create(this, this._def);
|
|
714
808
|
}
|
|
715
809
|
promise() {
|
|
716
|
-
return ZodPromise.create(this);
|
|
810
|
+
return ZodPromise.create(this, this._def);
|
|
717
811
|
}
|
|
718
812
|
or(option) {
|
|
719
|
-
return ZodUnion.create([this, option]);
|
|
813
|
+
return ZodUnion.create([this, option], this._def);
|
|
720
814
|
}
|
|
721
815
|
and(incoming) {
|
|
722
|
-
return ZodIntersection.create(this, incoming);
|
|
816
|
+
return ZodIntersection.create(this, incoming, this._def);
|
|
723
817
|
}
|
|
724
818
|
transform(transform) {
|
|
725
819
|
return new ZodEffects({
|
|
820
|
+
...processCreateParams(this._def),
|
|
726
821
|
schema: this,
|
|
727
822
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
728
823
|
effect: { type: "transform", transform },
|
|
@@ -731,6 +826,7 @@ class ZodType {
|
|
|
731
826
|
default(def) {
|
|
732
827
|
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
|
733
828
|
return new ZodDefault({
|
|
829
|
+
...processCreateParams(this._def),
|
|
734
830
|
innerType: this,
|
|
735
831
|
defaultValue: defaultValueFunc,
|
|
736
832
|
typeName: ZodFirstPartyTypeKind.ZodDefault,
|
|
@@ -740,14 +836,15 @@ class ZodType {
|
|
|
740
836
|
return new ZodBranded({
|
|
741
837
|
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
|
742
838
|
type: this,
|
|
743
|
-
...processCreateParams(
|
|
839
|
+
...processCreateParams(this._def),
|
|
744
840
|
});
|
|
745
841
|
}
|
|
746
842
|
catch(def) {
|
|
747
|
-
const
|
|
843
|
+
const catchValueFunc = typeof def === "function" ? def : () => def;
|
|
748
844
|
return new ZodCatch({
|
|
845
|
+
...processCreateParams(this._def),
|
|
749
846
|
innerType: this,
|
|
750
|
-
|
|
847
|
+
catchValue: catchValueFunc,
|
|
751
848
|
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
|
752
849
|
});
|
|
753
850
|
}
|
|
@@ -761,6 +858,9 @@ class ZodType {
|
|
|
761
858
|
pipe(target) {
|
|
762
859
|
return ZodPipeline.create(this, target);
|
|
763
860
|
}
|
|
861
|
+
readonly() {
|
|
862
|
+
return ZodReadonly.create(this);
|
|
863
|
+
}
|
|
764
864
|
isOptional() {
|
|
765
865
|
return this.safeParse(undefined).success;
|
|
766
866
|
}
|
|
@@ -769,63 +869,77 @@ class ZodType {
|
|
|
769
869
|
}
|
|
770
870
|
}
|
|
771
871
|
const cuidRegex = /^c[^\s-]{8,}$/i;
|
|
772
|
-
const
|
|
872
|
+
const cuid2Regex = /^[0-9a-z]+$/;
|
|
873
|
+
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
874
|
+
// const uuidRegex =
|
|
875
|
+
// /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
876
|
+
const 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;
|
|
877
|
+
const nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
878
|
+
const 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)?)??$/;
|
|
773
879
|
// from https://stackoverflow.com/a/46181/1550155
|
|
774
880
|
// old version: too slow, didn't support unicode
|
|
775
881
|
// const emailRegex = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
|
|
882
|
+
//old email regex
|
|
883
|
+
// const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@((?!-)([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{1,})[^-<>()[\].,;:\s@"]$/i;
|
|
776
884
|
// eslint-disable-next-line
|
|
777
|
-
const emailRegex =
|
|
778
|
-
//
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
//
|
|
783
|
-
|
|
784
|
-
//
|
|
785
|
-
|
|
885
|
+
// const emailRegex =
|
|
886
|
+
// /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/;
|
|
887
|
+
// const emailRegex =
|
|
888
|
+
// /^[a-zA-Z0-9\.\!\#\$\%\&\'\*\+\/\=\?\^\_\`\{\|\}\~\-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
889
|
+
// const emailRegex =
|
|
890
|
+
// /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;
|
|
891
|
+
const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
892
|
+
// const emailRegex =
|
|
893
|
+
// /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
|
|
894
|
+
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
|
895
|
+
const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
896
|
+
let emojiRegex;
|
|
897
|
+
// faster, simpler, safer
|
|
898
|
+
const 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])$/;
|
|
899
|
+
const ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
|
|
900
|
+
// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
|
|
901
|
+
const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
902
|
+
// simple
|
|
903
|
+
// const dateRegexSource = `\\d{4}-\\d{2}-\\d{2}`;
|
|
904
|
+
// no leap year validation
|
|
905
|
+
// const dateRegexSource = `\\d{4}-((0[13578]|10|12)-31|(0[13-9]|1[0-2])-30|(0[1-9]|1[0-2])-(0[1-9]|1\\d|2\\d))`;
|
|
906
|
+
// with leap year validation
|
|
907
|
+
const 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])))`;
|
|
908
|
+
const dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
909
|
+
function timeRegexSource(args) {
|
|
910
|
+
// let regex = `\\d{2}:\\d{2}:\\d{2}`;
|
|
911
|
+
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
|
786
912
|
if (args.precision) {
|
|
787
|
-
|
|
788
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}:\\d{2})|Z)$`);
|
|
789
|
-
}
|
|
790
|
-
else {
|
|
791
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
|
|
792
|
-
}
|
|
913
|
+
regex = `${regex}\\.\\d{${args.precision}}`;
|
|
793
914
|
}
|
|
794
|
-
else if (args.precision
|
|
795
|
-
|
|
796
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$`);
|
|
797
|
-
}
|
|
798
|
-
else {
|
|
799
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
|
|
800
|
-
}
|
|
915
|
+
else if (args.precision == null) {
|
|
916
|
+
regex = `${regex}(\\.\\d+)?`;
|
|
801
917
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
918
|
+
return regex;
|
|
919
|
+
}
|
|
920
|
+
function timeRegex(args) {
|
|
921
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
922
|
+
}
|
|
923
|
+
// Adapted from https://stackoverflow.com/a/3143231
|
|
924
|
+
function datetimeRegex(args) {
|
|
925
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
926
|
+
const opts = [];
|
|
927
|
+
opts.push(args.local ? `Z?` : `Z`);
|
|
928
|
+
if (args.offset)
|
|
929
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
930
|
+
regex = `${regex}(${opts.join("|")})`;
|
|
931
|
+
return new RegExp(`^${regex}$`);
|
|
932
|
+
}
|
|
933
|
+
function isValidIP(ip, version) {
|
|
934
|
+
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
|
935
|
+
return true;
|
|
809
936
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
constructor() {
|
|
813
|
-
super(...arguments);
|
|
814
|
-
this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
|
|
815
|
-
validation,
|
|
816
|
-
code: ZodIssueCode.invalid_string,
|
|
817
|
-
...errorUtil.errToObj(message),
|
|
818
|
-
});
|
|
819
|
-
/**
|
|
820
|
-
* @deprecated Use z.string().min(1) instead.
|
|
821
|
-
* @see {@link ZodString.min}
|
|
822
|
-
*/
|
|
823
|
-
this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
|
|
824
|
-
this.trim = () => new ZodString({
|
|
825
|
-
...this._def,
|
|
826
|
-
checks: [...this._def.checks, { kind: "trim" }],
|
|
827
|
-
});
|
|
937
|
+
if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
|
|
938
|
+
return true;
|
|
828
939
|
}
|
|
940
|
+
return false;
|
|
941
|
+
}
|
|
942
|
+
class ZodString extends ZodType {
|
|
829
943
|
_parse(input) {
|
|
830
944
|
if (this._def.coerce) {
|
|
831
945
|
input.data = String(input.data);
|
|
@@ -837,9 +951,7 @@ class ZodString extends ZodType {
|
|
|
837
951
|
code: ZodIssueCode.invalid_type,
|
|
838
952
|
expected: ZodParsedType.string,
|
|
839
953
|
received: ctx.parsedType,
|
|
840
|
-
}
|
|
841
|
-
//
|
|
842
|
-
);
|
|
954
|
+
});
|
|
843
955
|
return INVALID;
|
|
844
956
|
}
|
|
845
957
|
const status = new ParseStatus();
|
|
@@ -912,6 +1024,20 @@ class ZodString extends ZodType {
|
|
|
912
1024
|
status.dirty();
|
|
913
1025
|
}
|
|
914
1026
|
}
|
|
1027
|
+
else if (check.kind === "emoji") {
|
|
1028
|
+
if (!emojiRegex) {
|
|
1029
|
+
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
1030
|
+
}
|
|
1031
|
+
if (!emojiRegex.test(input.data)) {
|
|
1032
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1033
|
+
addIssueToContext(ctx, {
|
|
1034
|
+
validation: "emoji",
|
|
1035
|
+
code: ZodIssueCode.invalid_string,
|
|
1036
|
+
message: check.message,
|
|
1037
|
+
});
|
|
1038
|
+
status.dirty();
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
915
1041
|
else if (check.kind === "uuid") {
|
|
916
1042
|
if (!uuidRegex.test(input.data)) {
|
|
917
1043
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -923,6 +1049,17 @@ class ZodString extends ZodType {
|
|
|
923
1049
|
status.dirty();
|
|
924
1050
|
}
|
|
925
1051
|
}
|
|
1052
|
+
else if (check.kind === "nanoid") {
|
|
1053
|
+
if (!nanoidRegex.test(input.data)) {
|
|
1054
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1055
|
+
addIssueToContext(ctx, {
|
|
1056
|
+
validation: "nanoid",
|
|
1057
|
+
code: ZodIssueCode.invalid_string,
|
|
1058
|
+
message: check.message,
|
|
1059
|
+
});
|
|
1060
|
+
status.dirty();
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
926
1063
|
else if (check.kind === "cuid") {
|
|
927
1064
|
if (!cuidRegex.test(input.data)) {
|
|
928
1065
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -934,6 +1071,28 @@ class ZodString extends ZodType {
|
|
|
934
1071
|
status.dirty();
|
|
935
1072
|
}
|
|
936
1073
|
}
|
|
1074
|
+
else if (check.kind === "cuid2") {
|
|
1075
|
+
if (!cuid2Regex.test(input.data)) {
|
|
1076
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1077
|
+
addIssueToContext(ctx, {
|
|
1078
|
+
validation: "cuid2",
|
|
1079
|
+
code: ZodIssueCode.invalid_string,
|
|
1080
|
+
message: check.message,
|
|
1081
|
+
});
|
|
1082
|
+
status.dirty();
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
else if (check.kind === "ulid") {
|
|
1086
|
+
if (!ulidRegex.test(input.data)) {
|
|
1087
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1088
|
+
addIssueToContext(ctx, {
|
|
1089
|
+
validation: "ulid",
|
|
1090
|
+
code: ZodIssueCode.invalid_string,
|
|
1091
|
+
message: check.message,
|
|
1092
|
+
});
|
|
1093
|
+
status.dirty();
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
937
1096
|
else if (check.kind === "url") {
|
|
938
1097
|
try {
|
|
939
1098
|
new URL(input.data);
|
|
@@ -964,6 +1123,23 @@ class ZodString extends ZodType {
|
|
|
964
1123
|
else if (check.kind === "trim") {
|
|
965
1124
|
input.data = input.data.trim();
|
|
966
1125
|
}
|
|
1126
|
+
else if (check.kind === "includes") {
|
|
1127
|
+
if (!input.data.includes(check.value, check.position)) {
|
|
1128
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1129
|
+
addIssueToContext(ctx, {
|
|
1130
|
+
code: ZodIssueCode.invalid_string,
|
|
1131
|
+
validation: { includes: check.value, position: check.position },
|
|
1132
|
+
message: check.message,
|
|
1133
|
+
});
|
|
1134
|
+
status.dirty();
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
else if (check.kind === "toLowerCase") {
|
|
1138
|
+
input.data = input.data.toLowerCase();
|
|
1139
|
+
}
|
|
1140
|
+
else if (check.kind === "toUpperCase") {
|
|
1141
|
+
input.data = input.data.toUpperCase();
|
|
1142
|
+
}
|
|
967
1143
|
else if (check.kind === "startsWith") {
|
|
968
1144
|
if (!input.data.startsWith(check.value)) {
|
|
969
1145
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -998,12 +1174,76 @@ class ZodString extends ZodType {
|
|
|
998
1174
|
status.dirty();
|
|
999
1175
|
}
|
|
1000
1176
|
}
|
|
1177
|
+
else if (check.kind === "date") {
|
|
1178
|
+
const regex = dateRegex;
|
|
1179
|
+
if (!regex.test(input.data)) {
|
|
1180
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1181
|
+
addIssueToContext(ctx, {
|
|
1182
|
+
code: ZodIssueCode.invalid_string,
|
|
1183
|
+
validation: "date",
|
|
1184
|
+
message: check.message,
|
|
1185
|
+
});
|
|
1186
|
+
status.dirty();
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
else if (check.kind === "time") {
|
|
1190
|
+
const regex = timeRegex(check);
|
|
1191
|
+
if (!regex.test(input.data)) {
|
|
1192
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1193
|
+
addIssueToContext(ctx, {
|
|
1194
|
+
code: ZodIssueCode.invalid_string,
|
|
1195
|
+
validation: "time",
|
|
1196
|
+
message: check.message,
|
|
1197
|
+
});
|
|
1198
|
+
status.dirty();
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
else if (check.kind === "duration") {
|
|
1202
|
+
if (!durationRegex.test(input.data)) {
|
|
1203
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1204
|
+
addIssueToContext(ctx, {
|
|
1205
|
+
validation: "duration",
|
|
1206
|
+
code: ZodIssueCode.invalid_string,
|
|
1207
|
+
message: check.message,
|
|
1208
|
+
});
|
|
1209
|
+
status.dirty();
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
else if (check.kind === "ip") {
|
|
1213
|
+
if (!isValidIP(input.data, check.version)) {
|
|
1214
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1215
|
+
addIssueToContext(ctx, {
|
|
1216
|
+
validation: "ip",
|
|
1217
|
+
code: ZodIssueCode.invalid_string,
|
|
1218
|
+
message: check.message,
|
|
1219
|
+
});
|
|
1220
|
+
status.dirty();
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
else if (check.kind === "base64") {
|
|
1224
|
+
if (!base64Regex.test(input.data)) {
|
|
1225
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1226
|
+
addIssueToContext(ctx, {
|
|
1227
|
+
validation: "base64",
|
|
1228
|
+
code: ZodIssueCode.invalid_string,
|
|
1229
|
+
message: check.message,
|
|
1230
|
+
});
|
|
1231
|
+
status.dirty();
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1001
1234
|
else {
|
|
1002
1235
|
util.assertNever(check);
|
|
1003
1236
|
}
|
|
1004
1237
|
}
|
|
1005
1238
|
return { status: status.value, value: input.data };
|
|
1006
1239
|
}
|
|
1240
|
+
_regex(regex, validation, message) {
|
|
1241
|
+
return this.refinement((data) => regex.test(data), {
|
|
1242
|
+
validation,
|
|
1243
|
+
code: ZodIssueCode.invalid_string,
|
|
1244
|
+
...errorUtil.errToObj(message),
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1007
1247
|
_addCheck(check) {
|
|
1008
1248
|
return new ZodString({
|
|
1009
1249
|
...this._def,
|
|
@@ -1016,19 +1256,38 @@ class ZodString extends ZodType {
|
|
|
1016
1256
|
url(message) {
|
|
1017
1257
|
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
|
|
1018
1258
|
}
|
|
1259
|
+
emoji(message) {
|
|
1260
|
+
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
|
|
1261
|
+
}
|
|
1019
1262
|
uuid(message) {
|
|
1020
1263
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
1021
1264
|
}
|
|
1265
|
+
nanoid(message) {
|
|
1266
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
1267
|
+
}
|
|
1022
1268
|
cuid(message) {
|
|
1023
1269
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
1024
1270
|
}
|
|
1271
|
+
cuid2(message) {
|
|
1272
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
|
1273
|
+
}
|
|
1274
|
+
ulid(message) {
|
|
1275
|
+
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
1276
|
+
}
|
|
1277
|
+
base64(message) {
|
|
1278
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
1279
|
+
}
|
|
1280
|
+
ip(options) {
|
|
1281
|
+
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
1282
|
+
}
|
|
1025
1283
|
datetime(options) {
|
|
1026
|
-
var _a;
|
|
1284
|
+
var _a, _b;
|
|
1027
1285
|
if (typeof options === "string") {
|
|
1028
1286
|
return this._addCheck({
|
|
1029
1287
|
kind: "datetime",
|
|
1030
1288
|
precision: null,
|
|
1031
1289
|
offset: false,
|
|
1290
|
+
local: false,
|
|
1032
1291
|
message: options,
|
|
1033
1292
|
});
|
|
1034
1293
|
}
|
|
@@ -1036,9 +1295,30 @@ class ZodString extends ZodType {
|
|
|
1036
1295
|
kind: "datetime",
|
|
1037
1296
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
1038
1297
|
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
|
1298
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
|
1039
1299
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
|
|
1040
1300
|
});
|
|
1041
1301
|
}
|
|
1302
|
+
date(message) {
|
|
1303
|
+
return this._addCheck({ kind: "date", message });
|
|
1304
|
+
}
|
|
1305
|
+
time(options) {
|
|
1306
|
+
if (typeof options === "string") {
|
|
1307
|
+
return this._addCheck({
|
|
1308
|
+
kind: "time",
|
|
1309
|
+
precision: null,
|
|
1310
|
+
message: options,
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
return this._addCheck({
|
|
1314
|
+
kind: "time",
|
|
1315
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
1316
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
duration(message) {
|
|
1320
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
1321
|
+
}
|
|
1042
1322
|
regex(regex, message) {
|
|
1043
1323
|
return this._addCheck({
|
|
1044
1324
|
kind: "regex",
|
|
@@ -1046,6 +1326,14 @@ class ZodString extends ZodType {
|
|
|
1046
1326
|
...errorUtil.errToObj(message),
|
|
1047
1327
|
});
|
|
1048
1328
|
}
|
|
1329
|
+
includes(value, options) {
|
|
1330
|
+
return this._addCheck({
|
|
1331
|
+
kind: "includes",
|
|
1332
|
+
value: value,
|
|
1333
|
+
position: options === null || options === void 0 ? void 0 : options.position,
|
|
1334
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1049
1337
|
startsWith(value, message) {
|
|
1050
1338
|
return this._addCheck({
|
|
1051
1339
|
kind: "startsWith",
|
|
@@ -1081,21 +1369,73 @@ class ZodString extends ZodType {
|
|
|
1081
1369
|
...errorUtil.errToObj(message),
|
|
1082
1370
|
});
|
|
1083
1371
|
}
|
|
1372
|
+
/**
|
|
1373
|
+
* @deprecated Use z.string().min(1) instead.
|
|
1374
|
+
* @see {@link ZodString.min}
|
|
1375
|
+
*/
|
|
1376
|
+
nonempty(message) {
|
|
1377
|
+
return this.min(1, errorUtil.errToObj(message));
|
|
1378
|
+
}
|
|
1379
|
+
trim() {
|
|
1380
|
+
return new ZodString({
|
|
1381
|
+
...this._def,
|
|
1382
|
+
checks: [...this._def.checks, { kind: "trim" }],
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
toLowerCase() {
|
|
1386
|
+
return new ZodString({
|
|
1387
|
+
...this._def,
|
|
1388
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }],
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
toUpperCase() {
|
|
1392
|
+
return new ZodString({
|
|
1393
|
+
...this._def,
|
|
1394
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }],
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1084
1397
|
get isDatetime() {
|
|
1085
1398
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
1086
1399
|
}
|
|
1400
|
+
get isDate() {
|
|
1401
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
1402
|
+
}
|
|
1403
|
+
get isTime() {
|
|
1404
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
1405
|
+
}
|
|
1406
|
+
get isDuration() {
|
|
1407
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
1408
|
+
}
|
|
1087
1409
|
get isEmail() {
|
|
1088
1410
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
1089
1411
|
}
|
|
1090
1412
|
get isURL() {
|
|
1091
1413
|
return !!this._def.checks.find((ch) => ch.kind === "url");
|
|
1092
1414
|
}
|
|
1415
|
+
get isEmoji() {
|
|
1416
|
+
return !!this._def.checks.find((ch) => ch.kind === "emoji");
|
|
1417
|
+
}
|
|
1093
1418
|
get isUUID() {
|
|
1094
1419
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
1095
1420
|
}
|
|
1421
|
+
get isNANOID() {
|
|
1422
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
1423
|
+
}
|
|
1096
1424
|
get isCUID() {
|
|
1097
1425
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
1098
1426
|
}
|
|
1427
|
+
get isCUID2() {
|
|
1428
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
|
1429
|
+
}
|
|
1430
|
+
get isULID() {
|
|
1431
|
+
return !!this._def.checks.find((ch) => ch.kind === "ulid");
|
|
1432
|
+
}
|
|
1433
|
+
get isIP() {
|
|
1434
|
+
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
1435
|
+
}
|
|
1436
|
+
get isBase64() {
|
|
1437
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
1438
|
+
}
|
|
1099
1439
|
get minLength() {
|
|
1100
1440
|
let min = null;
|
|
1101
1441
|
for (const ch of this._def.checks) {
|
|
@@ -1121,37 +1461,281 @@ ZodString.create = (params) => {
|
|
|
1121
1461
|
var _a;
|
|
1122
1462
|
return new ZodString({
|
|
1123
1463
|
checks: [],
|
|
1124
|
-
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
1125
|
-
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
|
1464
|
+
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
1465
|
+
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
|
1466
|
+
...processCreateParams(params),
|
|
1467
|
+
});
|
|
1468
|
+
};
|
|
1469
|
+
// https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#31711034
|
|
1470
|
+
function floatSafeRemainder(val, step) {
|
|
1471
|
+
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
1472
|
+
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
1473
|
+
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
1474
|
+
const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
|
|
1475
|
+
const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
|
|
1476
|
+
return (valInt % stepInt) / Math.pow(10, decCount);
|
|
1477
|
+
}
|
|
1478
|
+
class ZodNumber extends ZodType {
|
|
1479
|
+
constructor() {
|
|
1480
|
+
super(...arguments);
|
|
1481
|
+
this.min = this.gte;
|
|
1482
|
+
this.max = this.lte;
|
|
1483
|
+
this.step = this.multipleOf;
|
|
1484
|
+
}
|
|
1485
|
+
_parse(input) {
|
|
1486
|
+
if (this._def.coerce) {
|
|
1487
|
+
input.data = Number(input.data);
|
|
1488
|
+
}
|
|
1489
|
+
const parsedType = this._getType(input);
|
|
1490
|
+
if (parsedType !== ZodParsedType.number) {
|
|
1491
|
+
const ctx = this._getOrReturnCtx(input);
|
|
1492
|
+
addIssueToContext(ctx, {
|
|
1493
|
+
code: ZodIssueCode.invalid_type,
|
|
1494
|
+
expected: ZodParsedType.number,
|
|
1495
|
+
received: ctx.parsedType,
|
|
1496
|
+
});
|
|
1497
|
+
return INVALID;
|
|
1498
|
+
}
|
|
1499
|
+
let ctx = undefined;
|
|
1500
|
+
const status = new ParseStatus();
|
|
1501
|
+
for (const check of this._def.checks) {
|
|
1502
|
+
if (check.kind === "int") {
|
|
1503
|
+
if (!util.isInteger(input.data)) {
|
|
1504
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1505
|
+
addIssueToContext(ctx, {
|
|
1506
|
+
code: ZodIssueCode.invalid_type,
|
|
1507
|
+
expected: "integer",
|
|
1508
|
+
received: "float",
|
|
1509
|
+
message: check.message,
|
|
1510
|
+
});
|
|
1511
|
+
status.dirty();
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
else if (check.kind === "min") {
|
|
1515
|
+
const tooSmall = check.inclusive
|
|
1516
|
+
? input.data < check.value
|
|
1517
|
+
: input.data <= check.value;
|
|
1518
|
+
if (tooSmall) {
|
|
1519
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1520
|
+
addIssueToContext(ctx, {
|
|
1521
|
+
code: ZodIssueCode.too_small,
|
|
1522
|
+
minimum: check.value,
|
|
1523
|
+
type: "number",
|
|
1524
|
+
inclusive: check.inclusive,
|
|
1525
|
+
exact: false,
|
|
1526
|
+
message: check.message,
|
|
1527
|
+
});
|
|
1528
|
+
status.dirty();
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
else if (check.kind === "max") {
|
|
1532
|
+
const tooBig = check.inclusive
|
|
1533
|
+
? input.data > check.value
|
|
1534
|
+
: input.data >= check.value;
|
|
1535
|
+
if (tooBig) {
|
|
1536
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1537
|
+
addIssueToContext(ctx, {
|
|
1538
|
+
code: ZodIssueCode.too_big,
|
|
1539
|
+
maximum: check.value,
|
|
1540
|
+
type: "number",
|
|
1541
|
+
inclusive: check.inclusive,
|
|
1542
|
+
exact: false,
|
|
1543
|
+
message: check.message,
|
|
1544
|
+
});
|
|
1545
|
+
status.dirty();
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
else if (check.kind === "multipleOf") {
|
|
1549
|
+
if (floatSafeRemainder(input.data, check.value) !== 0) {
|
|
1550
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1551
|
+
addIssueToContext(ctx, {
|
|
1552
|
+
code: ZodIssueCode.not_multiple_of,
|
|
1553
|
+
multipleOf: check.value,
|
|
1554
|
+
message: check.message,
|
|
1555
|
+
});
|
|
1556
|
+
status.dirty();
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
else if (check.kind === "finite") {
|
|
1560
|
+
if (!Number.isFinite(input.data)) {
|
|
1561
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1562
|
+
addIssueToContext(ctx, {
|
|
1563
|
+
code: ZodIssueCode.not_finite,
|
|
1564
|
+
message: check.message,
|
|
1565
|
+
});
|
|
1566
|
+
status.dirty();
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
else {
|
|
1570
|
+
util.assertNever(check);
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
return { status: status.value, value: input.data };
|
|
1574
|
+
}
|
|
1575
|
+
gte(value, message) {
|
|
1576
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
1577
|
+
}
|
|
1578
|
+
gt(value, message) {
|
|
1579
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
|
1580
|
+
}
|
|
1581
|
+
lte(value, message) {
|
|
1582
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
|
1583
|
+
}
|
|
1584
|
+
lt(value, message) {
|
|
1585
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
1586
|
+
}
|
|
1587
|
+
setLimit(kind, value, inclusive, message) {
|
|
1588
|
+
return new ZodNumber({
|
|
1589
|
+
...this._def,
|
|
1590
|
+
checks: [
|
|
1591
|
+
...this._def.checks,
|
|
1592
|
+
{
|
|
1593
|
+
kind,
|
|
1594
|
+
value,
|
|
1595
|
+
inclusive,
|
|
1596
|
+
message: errorUtil.toString(message),
|
|
1597
|
+
},
|
|
1598
|
+
],
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
_addCheck(check) {
|
|
1602
|
+
return new ZodNumber({
|
|
1603
|
+
...this._def,
|
|
1604
|
+
checks: [...this._def.checks, check],
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
int(message) {
|
|
1608
|
+
return this._addCheck({
|
|
1609
|
+
kind: "int",
|
|
1610
|
+
message: errorUtil.toString(message),
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
positive(message) {
|
|
1614
|
+
return this._addCheck({
|
|
1615
|
+
kind: "min",
|
|
1616
|
+
value: 0,
|
|
1617
|
+
inclusive: false,
|
|
1618
|
+
message: errorUtil.toString(message),
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1621
|
+
negative(message) {
|
|
1622
|
+
return this._addCheck({
|
|
1623
|
+
kind: "max",
|
|
1624
|
+
value: 0,
|
|
1625
|
+
inclusive: false,
|
|
1626
|
+
message: errorUtil.toString(message),
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
nonpositive(message) {
|
|
1630
|
+
return this._addCheck({
|
|
1631
|
+
kind: "max",
|
|
1632
|
+
value: 0,
|
|
1633
|
+
inclusive: true,
|
|
1634
|
+
message: errorUtil.toString(message),
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
nonnegative(message) {
|
|
1638
|
+
return this._addCheck({
|
|
1639
|
+
kind: "min",
|
|
1640
|
+
value: 0,
|
|
1641
|
+
inclusive: true,
|
|
1642
|
+
message: errorUtil.toString(message),
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
multipleOf(value, message) {
|
|
1646
|
+
return this._addCheck({
|
|
1647
|
+
kind: "multipleOf",
|
|
1648
|
+
value: value,
|
|
1649
|
+
message: errorUtil.toString(message),
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
finite(message) {
|
|
1653
|
+
return this._addCheck({
|
|
1654
|
+
kind: "finite",
|
|
1655
|
+
message: errorUtil.toString(message),
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
safe(message) {
|
|
1659
|
+
return this._addCheck({
|
|
1660
|
+
kind: "min",
|
|
1661
|
+
inclusive: true,
|
|
1662
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
1663
|
+
message: errorUtil.toString(message),
|
|
1664
|
+
})._addCheck({
|
|
1665
|
+
kind: "max",
|
|
1666
|
+
inclusive: true,
|
|
1667
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
1668
|
+
message: errorUtil.toString(message),
|
|
1669
|
+
});
|
|
1670
|
+
}
|
|
1671
|
+
get minValue() {
|
|
1672
|
+
let min = null;
|
|
1673
|
+
for (const ch of this._def.checks) {
|
|
1674
|
+
if (ch.kind === "min") {
|
|
1675
|
+
if (min === null || ch.value > min)
|
|
1676
|
+
min = ch.value;
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
return min;
|
|
1680
|
+
}
|
|
1681
|
+
get maxValue() {
|
|
1682
|
+
let max = null;
|
|
1683
|
+
for (const ch of this._def.checks) {
|
|
1684
|
+
if (ch.kind === "max") {
|
|
1685
|
+
if (max === null || ch.value < max)
|
|
1686
|
+
max = ch.value;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
return max;
|
|
1690
|
+
}
|
|
1691
|
+
get isInt() {
|
|
1692
|
+
return !!this._def.checks.find((ch) => ch.kind === "int" ||
|
|
1693
|
+
(ch.kind === "multipleOf" && util.isInteger(ch.value)));
|
|
1694
|
+
}
|
|
1695
|
+
get isFinite() {
|
|
1696
|
+
let max = null, min = null;
|
|
1697
|
+
for (const ch of this._def.checks) {
|
|
1698
|
+
if (ch.kind === "finite" ||
|
|
1699
|
+
ch.kind === "int" ||
|
|
1700
|
+
ch.kind === "multipleOf") {
|
|
1701
|
+
return true;
|
|
1702
|
+
}
|
|
1703
|
+
else if (ch.kind === "min") {
|
|
1704
|
+
if (min === null || ch.value > min)
|
|
1705
|
+
min = ch.value;
|
|
1706
|
+
}
|
|
1707
|
+
else if (ch.kind === "max") {
|
|
1708
|
+
if (max === null || ch.value < max)
|
|
1709
|
+
max = ch.value;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
return Number.isFinite(min) && Number.isFinite(max);
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
ZodNumber.create = (params) => {
|
|
1716
|
+
return new ZodNumber({
|
|
1717
|
+
checks: [],
|
|
1718
|
+
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
1719
|
+
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
|
|
1126
1720
|
...processCreateParams(params),
|
|
1127
1721
|
});
|
|
1128
1722
|
};
|
|
1129
|
-
|
|
1130
|
-
function floatSafeRemainder(val, step) {
|
|
1131
|
-
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
1132
|
-
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
1133
|
-
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
1134
|
-
const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
|
|
1135
|
-
const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
|
|
1136
|
-
return (valInt % stepInt) / Math.pow(10, decCount);
|
|
1137
|
-
}
|
|
1138
|
-
class ZodNumber extends ZodType {
|
|
1723
|
+
class ZodBigInt extends ZodType {
|
|
1139
1724
|
constructor() {
|
|
1140
1725
|
super(...arguments);
|
|
1141
1726
|
this.min = this.gte;
|
|
1142
1727
|
this.max = this.lte;
|
|
1143
|
-
this.step = this.multipleOf;
|
|
1144
1728
|
}
|
|
1145
1729
|
_parse(input) {
|
|
1146
1730
|
if (this._def.coerce) {
|
|
1147
|
-
input.data =
|
|
1731
|
+
input.data = BigInt(input.data);
|
|
1148
1732
|
}
|
|
1149
1733
|
const parsedType = this._getType(input);
|
|
1150
|
-
if (parsedType !== ZodParsedType.
|
|
1734
|
+
if (parsedType !== ZodParsedType.bigint) {
|
|
1151
1735
|
const ctx = this._getOrReturnCtx(input);
|
|
1152
1736
|
addIssueToContext(ctx, {
|
|
1153
1737
|
code: ZodIssueCode.invalid_type,
|
|
1154
|
-
expected: ZodParsedType.
|
|
1738
|
+
expected: ZodParsedType.bigint,
|
|
1155
1739
|
received: ctx.parsedType,
|
|
1156
1740
|
});
|
|
1157
1741
|
return INVALID;
|
|
@@ -1159,19 +1743,7 @@ class ZodNumber extends ZodType {
|
|
|
1159
1743
|
let ctx = undefined;
|
|
1160
1744
|
const status = new ParseStatus();
|
|
1161
1745
|
for (const check of this._def.checks) {
|
|
1162
|
-
if (check.kind === "
|
|
1163
|
-
if (!util.isInteger(input.data)) {
|
|
1164
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
1165
|
-
addIssueToContext(ctx, {
|
|
1166
|
-
code: ZodIssueCode.invalid_type,
|
|
1167
|
-
expected: "integer",
|
|
1168
|
-
received: "float",
|
|
1169
|
-
message: check.message,
|
|
1170
|
-
});
|
|
1171
|
-
status.dirty();
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
else if (check.kind === "min") {
|
|
1746
|
+
if (check.kind === "min") {
|
|
1175
1747
|
const tooSmall = check.inclusive
|
|
1176
1748
|
? input.data < check.value
|
|
1177
1749
|
: input.data <= check.value;
|
|
@@ -1179,10 +1751,9 @@ class ZodNumber extends ZodType {
|
|
|
1179
1751
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
1180
1752
|
addIssueToContext(ctx, {
|
|
1181
1753
|
code: ZodIssueCode.too_small,
|
|
1754
|
+
type: "bigint",
|
|
1182
1755
|
minimum: check.value,
|
|
1183
|
-
type: "number",
|
|
1184
1756
|
inclusive: check.inclusive,
|
|
1185
|
-
exact: false,
|
|
1186
1757
|
message: check.message,
|
|
1187
1758
|
});
|
|
1188
1759
|
status.dirty();
|
|
@@ -1196,17 +1767,16 @@ class ZodNumber extends ZodType {
|
|
|
1196
1767
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
1197
1768
|
addIssueToContext(ctx, {
|
|
1198
1769
|
code: ZodIssueCode.too_big,
|
|
1770
|
+
type: "bigint",
|
|
1199
1771
|
maximum: check.value,
|
|
1200
|
-
type: "number",
|
|
1201
1772
|
inclusive: check.inclusive,
|
|
1202
|
-
exact: false,
|
|
1203
1773
|
message: check.message,
|
|
1204
1774
|
});
|
|
1205
1775
|
status.dirty();
|
|
1206
1776
|
}
|
|
1207
1777
|
}
|
|
1208
1778
|
else if (check.kind === "multipleOf") {
|
|
1209
|
-
if (
|
|
1779
|
+
if (input.data % check.value !== BigInt(0)) {
|
|
1210
1780
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
1211
1781
|
addIssueToContext(ctx, {
|
|
1212
1782
|
code: ZodIssueCode.not_multiple_of,
|
|
@@ -1216,16 +1786,6 @@ class ZodNumber extends ZodType {
|
|
|
1216
1786
|
status.dirty();
|
|
1217
1787
|
}
|
|
1218
1788
|
}
|
|
1219
|
-
else if (check.kind === "finite") {
|
|
1220
|
-
if (!Number.isFinite(input.data)) {
|
|
1221
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
1222
|
-
addIssueToContext(ctx, {
|
|
1223
|
-
code: ZodIssueCode.not_finite,
|
|
1224
|
-
message: check.message,
|
|
1225
|
-
});
|
|
1226
|
-
status.dirty();
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
1789
|
else {
|
|
1230
1790
|
util.assertNever(check);
|
|
1231
1791
|
}
|
|
@@ -1245,7 +1805,7 @@ class ZodNumber extends ZodType {
|
|
|
1245
1805
|
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
1246
1806
|
}
|
|
1247
1807
|
setLimit(kind, value, inclusive, message) {
|
|
1248
|
-
return new
|
|
1808
|
+
return new ZodBigInt({
|
|
1249
1809
|
...this._def,
|
|
1250
1810
|
checks: [
|
|
1251
1811
|
...this._def.checks,
|
|
@@ -1259,21 +1819,15 @@ class ZodNumber extends ZodType {
|
|
|
1259
1819
|
});
|
|
1260
1820
|
}
|
|
1261
1821
|
_addCheck(check) {
|
|
1262
|
-
return new
|
|
1822
|
+
return new ZodBigInt({
|
|
1263
1823
|
...this._def,
|
|
1264
1824
|
checks: [...this._def.checks, check],
|
|
1265
1825
|
});
|
|
1266
1826
|
}
|
|
1267
|
-
int(message) {
|
|
1268
|
-
return this._addCheck({
|
|
1269
|
-
kind: "int",
|
|
1270
|
-
message: errorUtil.toString(message),
|
|
1271
|
-
});
|
|
1272
|
-
}
|
|
1273
1827
|
positive(message) {
|
|
1274
1828
|
return this._addCheck({
|
|
1275
1829
|
kind: "min",
|
|
1276
|
-
value: 0,
|
|
1830
|
+
value: BigInt(0),
|
|
1277
1831
|
inclusive: false,
|
|
1278
1832
|
message: errorUtil.toString(message),
|
|
1279
1833
|
});
|
|
@@ -1281,7 +1835,7 @@ class ZodNumber extends ZodType {
|
|
|
1281
1835
|
negative(message) {
|
|
1282
1836
|
return this._addCheck({
|
|
1283
1837
|
kind: "max",
|
|
1284
|
-
value: 0,
|
|
1838
|
+
value: BigInt(0),
|
|
1285
1839
|
inclusive: false,
|
|
1286
1840
|
message: errorUtil.toString(message),
|
|
1287
1841
|
});
|
|
@@ -1289,7 +1843,7 @@ class ZodNumber extends ZodType {
|
|
|
1289
1843
|
nonpositive(message) {
|
|
1290
1844
|
return this._addCheck({
|
|
1291
1845
|
kind: "max",
|
|
1292
|
-
value: 0,
|
|
1846
|
+
value: BigInt(0),
|
|
1293
1847
|
inclusive: true,
|
|
1294
1848
|
message: errorUtil.toString(message),
|
|
1295
1849
|
});
|
|
@@ -1297,7 +1851,7 @@ class ZodNumber extends ZodType {
|
|
|
1297
1851
|
nonnegative(message) {
|
|
1298
1852
|
return this._addCheck({
|
|
1299
1853
|
kind: "min",
|
|
1300
|
-
value: 0,
|
|
1854
|
+
value: BigInt(0),
|
|
1301
1855
|
inclusive: true,
|
|
1302
1856
|
message: errorUtil.toString(message),
|
|
1303
1857
|
});
|
|
@@ -1305,13 +1859,7 @@ class ZodNumber extends ZodType {
|
|
|
1305
1859
|
multipleOf(value, message) {
|
|
1306
1860
|
return this._addCheck({
|
|
1307
1861
|
kind: "multipleOf",
|
|
1308
|
-
value
|
|
1309
|
-
message: errorUtil.toString(message),
|
|
1310
|
-
});
|
|
1311
|
-
}
|
|
1312
|
-
finite(message) {
|
|
1313
|
-
return this._addCheck({
|
|
1314
|
-
kind: "finite",
|
|
1862
|
+
value,
|
|
1315
1863
|
message: errorUtil.toString(message),
|
|
1316
1864
|
});
|
|
1317
1865
|
}
|
|
@@ -1335,39 +1883,11 @@ class ZodNumber extends ZodType {
|
|
|
1335
1883
|
}
|
|
1336
1884
|
return max;
|
|
1337
1885
|
}
|
|
1338
|
-
get isInt() {
|
|
1339
|
-
return !!this._def.checks.find((ch) => ch.kind === "int");
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
ZodNumber.create = (params) => {
|
|
1343
|
-
return new ZodNumber({
|
|
1344
|
-
checks: [],
|
|
1345
|
-
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
1346
|
-
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
|
|
1347
|
-
...processCreateParams(params),
|
|
1348
|
-
});
|
|
1349
|
-
};
|
|
1350
|
-
class ZodBigInt extends ZodType {
|
|
1351
|
-
_parse(input) {
|
|
1352
|
-
if (this._def.coerce) {
|
|
1353
|
-
input.data = BigInt(input.data);
|
|
1354
|
-
}
|
|
1355
|
-
const parsedType = this._getType(input);
|
|
1356
|
-
if (parsedType !== ZodParsedType.bigint) {
|
|
1357
|
-
const ctx = this._getOrReturnCtx(input);
|
|
1358
|
-
addIssueToContext(ctx, {
|
|
1359
|
-
code: ZodIssueCode.invalid_type,
|
|
1360
|
-
expected: ZodParsedType.bigint,
|
|
1361
|
-
received: ctx.parsedType,
|
|
1362
|
-
});
|
|
1363
|
-
return INVALID;
|
|
1364
|
-
}
|
|
1365
|
-
return OK(input.data);
|
|
1366
|
-
}
|
|
1367
1886
|
}
|
|
1368
1887
|
ZodBigInt.create = (params) => {
|
|
1369
1888
|
var _a;
|
|
1370
1889
|
return new ZodBigInt({
|
|
1890
|
+
checks: [],
|
|
1371
1891
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
1372
1892
|
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
|
1373
1893
|
...processCreateParams(params),
|
|
@@ -1697,13 +2217,13 @@ class ZodArray extends ZodType {
|
|
|
1697
2217
|
}
|
|
1698
2218
|
}
|
|
1699
2219
|
if (ctx.common.async) {
|
|
1700
|
-
return Promise.all(ctx.data.map((item, i) => {
|
|
2220
|
+
return Promise.all([...ctx.data].map((item, i) => {
|
|
1701
2221
|
return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
1702
2222
|
})).then((result) => {
|
|
1703
2223
|
return ParseStatus.mergeArray(status, result);
|
|
1704
2224
|
});
|
|
1705
2225
|
}
|
|
1706
|
-
const result = ctx.data.map((item, i) => {
|
|
2226
|
+
const result = [...ctx.data].map((item, i) => {
|
|
1707
2227
|
return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
1708
2228
|
});
|
|
1709
2229
|
return ParseStatus.mergeArray(status, result);
|
|
@@ -1743,31 +2263,6 @@ ZodArray.create = (schema, params) => {
|
|
|
1743
2263
|
...processCreateParams(params),
|
|
1744
2264
|
});
|
|
1745
2265
|
};
|
|
1746
|
-
/////////////////////////////////////////
|
|
1747
|
-
/////////////////////////////////////////
|
|
1748
|
-
////////// //////////
|
|
1749
|
-
////////// ZodObject //////////
|
|
1750
|
-
////////// //////////
|
|
1751
|
-
/////////////////////////////////////////
|
|
1752
|
-
/////////////////////////////////////////
|
|
1753
|
-
var objectUtil;
|
|
1754
|
-
(function (objectUtil) {
|
|
1755
|
-
objectUtil.mergeShapes = (first, second) => {
|
|
1756
|
-
return {
|
|
1757
|
-
...first,
|
|
1758
|
-
...second, // second overwrites first
|
|
1759
|
-
};
|
|
1760
|
-
};
|
|
1761
|
-
})(objectUtil || (objectUtil = {}));
|
|
1762
|
-
const AugmentFactory = (def) => (augmentation) => {
|
|
1763
|
-
return new ZodObject({
|
|
1764
|
-
...def,
|
|
1765
|
-
shape: () => ({
|
|
1766
|
-
...def.shape(),
|
|
1767
|
-
...augmentation,
|
|
1768
|
-
}),
|
|
1769
|
-
});
|
|
1770
|
-
};
|
|
1771
2266
|
function deepPartialify(schema) {
|
|
1772
2267
|
if (schema instanceof ZodObject) {
|
|
1773
2268
|
const newShape = {};
|
|
@@ -1781,7 +2276,10 @@ function deepPartialify(schema) {
|
|
|
1781
2276
|
});
|
|
1782
2277
|
}
|
|
1783
2278
|
else if (schema instanceof ZodArray) {
|
|
1784
|
-
return ZodArray
|
|
2279
|
+
return new ZodArray({
|
|
2280
|
+
...schema._def,
|
|
2281
|
+
type: deepPartialify(schema.element),
|
|
2282
|
+
});
|
|
1785
2283
|
}
|
|
1786
2284
|
else if (schema instanceof ZodOptional) {
|
|
1787
2285
|
return ZodOptional.create(deepPartialify(schema.unwrap()));
|
|
@@ -1805,8 +2303,43 @@ class ZodObject extends ZodType {
|
|
|
1805
2303
|
* If you want to pass through unknown properties, use `.passthrough()` instead.
|
|
1806
2304
|
*/
|
|
1807
2305
|
this.nonstrict = this.passthrough;
|
|
1808
|
-
|
|
1809
|
-
|
|
2306
|
+
// extend<
|
|
2307
|
+
// Augmentation extends ZodRawShape,
|
|
2308
|
+
// NewOutput extends util.flatten<{
|
|
2309
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
2310
|
+
// ? Augmentation[k]["_output"]
|
|
2311
|
+
// : k extends keyof Output
|
|
2312
|
+
// ? Output[k]
|
|
2313
|
+
// : never;
|
|
2314
|
+
// }>,
|
|
2315
|
+
// NewInput extends util.flatten<{
|
|
2316
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
2317
|
+
// ? Augmentation[k]["_input"]
|
|
2318
|
+
// : k extends keyof Input
|
|
2319
|
+
// ? Input[k]
|
|
2320
|
+
// : never;
|
|
2321
|
+
// }>
|
|
2322
|
+
// >(
|
|
2323
|
+
// augmentation: Augmentation
|
|
2324
|
+
// ): ZodObject<
|
|
2325
|
+
// extendShape<T, Augmentation>,
|
|
2326
|
+
// UnknownKeys,
|
|
2327
|
+
// Catchall,
|
|
2328
|
+
// NewOutput,
|
|
2329
|
+
// NewInput
|
|
2330
|
+
// > {
|
|
2331
|
+
// return new ZodObject({
|
|
2332
|
+
// ...this._def,
|
|
2333
|
+
// shape: () => ({
|
|
2334
|
+
// ...this._def.shape(),
|
|
2335
|
+
// ...augmentation,
|
|
2336
|
+
// }),
|
|
2337
|
+
// }) as any;
|
|
2338
|
+
// }
|
|
2339
|
+
/**
|
|
2340
|
+
* @deprecated Use `.extend` instead
|
|
2341
|
+
* */
|
|
2342
|
+
this.augment = this.extend;
|
|
1810
2343
|
}
|
|
1811
2344
|
_getCached() {
|
|
1812
2345
|
if (this._cached !== null)
|
|
@@ -1890,9 +2423,10 @@ class ZodObject extends ZodType {
|
|
|
1890
2423
|
const syncPairs = [];
|
|
1891
2424
|
for (const pair of pairs) {
|
|
1892
2425
|
const key = await pair.key;
|
|
2426
|
+
const value = await pair.value;
|
|
1893
2427
|
syncPairs.push({
|
|
1894
2428
|
key,
|
|
1895
|
-
value
|
|
2429
|
+
value,
|
|
1896
2430
|
alwaysSet: pair.alwaysSet,
|
|
1897
2431
|
});
|
|
1898
2432
|
}
|
|
@@ -1943,8 +2477,31 @@ class ZodObject extends ZodType {
|
|
|
1943
2477
|
unknownKeys: "passthrough",
|
|
1944
2478
|
});
|
|
1945
2479
|
}
|
|
1946
|
-
|
|
1947
|
-
|
|
2480
|
+
// const AugmentFactory =
|
|
2481
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
2482
|
+
// <Augmentation extends ZodRawShape>(
|
|
2483
|
+
// augmentation: Augmentation
|
|
2484
|
+
// ): ZodObject<
|
|
2485
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
2486
|
+
// Def["unknownKeys"],
|
|
2487
|
+
// Def["catchall"]
|
|
2488
|
+
// > => {
|
|
2489
|
+
// return new ZodObject({
|
|
2490
|
+
// ...def,
|
|
2491
|
+
// shape: () => ({
|
|
2492
|
+
// ...def.shape(),
|
|
2493
|
+
// ...augmentation,
|
|
2494
|
+
// }),
|
|
2495
|
+
// }) as any;
|
|
2496
|
+
// };
|
|
2497
|
+
extend(augmentation) {
|
|
2498
|
+
return new ZodObject({
|
|
2499
|
+
...this._def,
|
|
2500
|
+
shape: () => ({
|
|
2501
|
+
...this._def.shape(),
|
|
2502
|
+
...augmentation,
|
|
2503
|
+
}),
|
|
2504
|
+
});
|
|
1948
2505
|
}
|
|
1949
2506
|
/**
|
|
1950
2507
|
* Prior to zod@1.0.12 there was a bug in the
|
|
@@ -1952,18 +2509,76 @@ class ZodObject extends ZodType {
|
|
|
1952
2509
|
* upgrade if you are experiencing issues.
|
|
1953
2510
|
*/
|
|
1954
2511
|
merge(merging) {
|
|
1955
|
-
// const mergedShape = objectUtil.mergeShapes(
|
|
1956
|
-
// this._def.shape(),
|
|
1957
|
-
// merging._def.shape()
|
|
1958
|
-
// );
|
|
1959
2512
|
const merged = new ZodObject({
|
|
1960
2513
|
unknownKeys: merging._def.unknownKeys,
|
|
1961
2514
|
catchall: merging._def.catchall,
|
|
1962
|
-
shape: () =>
|
|
2515
|
+
shape: () => ({
|
|
2516
|
+
...this._def.shape(),
|
|
2517
|
+
...merging._def.shape(),
|
|
2518
|
+
}),
|
|
1963
2519
|
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
1964
2520
|
});
|
|
1965
2521
|
return merged;
|
|
1966
2522
|
}
|
|
2523
|
+
// merge<
|
|
2524
|
+
// Incoming extends AnyZodObject,
|
|
2525
|
+
// Augmentation extends Incoming["shape"],
|
|
2526
|
+
// NewOutput extends {
|
|
2527
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
2528
|
+
// ? Augmentation[k]["_output"]
|
|
2529
|
+
// : k extends keyof Output
|
|
2530
|
+
// ? Output[k]
|
|
2531
|
+
// : never;
|
|
2532
|
+
// },
|
|
2533
|
+
// NewInput extends {
|
|
2534
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
2535
|
+
// ? Augmentation[k]["_input"]
|
|
2536
|
+
// : k extends keyof Input
|
|
2537
|
+
// ? Input[k]
|
|
2538
|
+
// : never;
|
|
2539
|
+
// }
|
|
2540
|
+
// >(
|
|
2541
|
+
// merging: Incoming
|
|
2542
|
+
// ): ZodObject<
|
|
2543
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
2544
|
+
// Incoming["_def"]["unknownKeys"],
|
|
2545
|
+
// Incoming["_def"]["catchall"],
|
|
2546
|
+
// NewOutput,
|
|
2547
|
+
// NewInput
|
|
2548
|
+
// > {
|
|
2549
|
+
// const merged: any = new ZodObject({
|
|
2550
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
2551
|
+
// catchall: merging._def.catchall,
|
|
2552
|
+
// shape: () =>
|
|
2553
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
2554
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
2555
|
+
// }) as any;
|
|
2556
|
+
// return merged;
|
|
2557
|
+
// }
|
|
2558
|
+
setKey(key, schema) {
|
|
2559
|
+
return this.augment({ [key]: schema });
|
|
2560
|
+
}
|
|
2561
|
+
// merge<Incoming extends AnyZodObject>(
|
|
2562
|
+
// merging: Incoming
|
|
2563
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
2564
|
+
// ZodObject<
|
|
2565
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
2566
|
+
// Incoming["_def"]["unknownKeys"],
|
|
2567
|
+
// Incoming["_def"]["catchall"]
|
|
2568
|
+
// > {
|
|
2569
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
2570
|
+
// // this._def.shape(),
|
|
2571
|
+
// // merging._def.shape()
|
|
2572
|
+
// // );
|
|
2573
|
+
// const merged: any = new ZodObject({
|
|
2574
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
2575
|
+
// catchall: merging._def.catchall,
|
|
2576
|
+
// shape: () =>
|
|
2577
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
2578
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
2579
|
+
// }) as any;
|
|
2580
|
+
// return merged;
|
|
2581
|
+
// }
|
|
1967
2582
|
catchall(index) {
|
|
1968
2583
|
return new ZodObject({
|
|
1969
2584
|
...this._def,
|
|
@@ -1972,10 +2587,10 @@ class ZodObject extends ZodType {
|
|
|
1972
2587
|
}
|
|
1973
2588
|
pick(mask) {
|
|
1974
2589
|
const shape = {};
|
|
1975
|
-
util.objectKeys(mask).
|
|
1976
|
-
|
|
1977
|
-
if (this.shape[key])
|
|
2590
|
+
util.objectKeys(mask).forEach((key) => {
|
|
2591
|
+
if (mask[key] && this.shape[key]) {
|
|
1978
2592
|
shape[key] = this.shape[key];
|
|
2593
|
+
}
|
|
1979
2594
|
});
|
|
1980
2595
|
return new ZodObject({
|
|
1981
2596
|
...this._def,
|
|
@@ -1984,8 +2599,8 @@ class ZodObject extends ZodType {
|
|
|
1984
2599
|
}
|
|
1985
2600
|
omit(mask) {
|
|
1986
2601
|
const shape = {};
|
|
1987
|
-
util.objectKeys(this.shape).
|
|
1988
|
-
if (
|
|
2602
|
+
util.objectKeys(this.shape).forEach((key) => {
|
|
2603
|
+
if (!mask[key]) {
|
|
1989
2604
|
shape[key] = this.shape[key];
|
|
1990
2605
|
}
|
|
1991
2606
|
});
|
|
@@ -1994,31 +2609,23 @@ class ZodObject extends ZodType {
|
|
|
1994
2609
|
shape: () => shape,
|
|
1995
2610
|
});
|
|
1996
2611
|
}
|
|
2612
|
+
/**
|
|
2613
|
+
* @deprecated
|
|
2614
|
+
*/
|
|
1997
2615
|
deepPartial() {
|
|
1998
2616
|
return deepPartialify(this);
|
|
1999
2617
|
}
|
|
2000
2618
|
partial(mask) {
|
|
2001
2619
|
const newShape = {};
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
newShape[key] = this.shape[key].optional();
|
|
2009
|
-
}
|
|
2010
|
-
});
|
|
2011
|
-
return new ZodObject({
|
|
2012
|
-
...this._def,
|
|
2013
|
-
shape: () => newShape,
|
|
2014
|
-
});
|
|
2015
|
-
}
|
|
2016
|
-
else {
|
|
2017
|
-
for (const key in this.shape) {
|
|
2018
|
-
const fieldSchema = this.shape[key];
|
|
2620
|
+
util.objectKeys(this.shape).forEach((key) => {
|
|
2621
|
+
const fieldSchema = this.shape[key];
|
|
2622
|
+
if (mask && !mask[key]) {
|
|
2623
|
+
newShape[key] = fieldSchema;
|
|
2624
|
+
}
|
|
2625
|
+
else {
|
|
2019
2626
|
newShape[key] = fieldSchema.optional();
|
|
2020
2627
|
}
|
|
2021
|
-
}
|
|
2628
|
+
});
|
|
2022
2629
|
return new ZodObject({
|
|
2023
2630
|
...this._def,
|
|
2024
2631
|
shape: () => newShape,
|
|
@@ -2026,23 +2633,11 @@ class ZodObject extends ZodType {
|
|
|
2026
2633
|
}
|
|
2027
2634
|
required(mask) {
|
|
2028
2635
|
const newShape = {};
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
else {
|
|
2035
|
-
const fieldSchema = this.shape[key];
|
|
2036
|
-
let newField = fieldSchema;
|
|
2037
|
-
while (newField instanceof ZodOptional) {
|
|
2038
|
-
newField = newField._def.innerType;
|
|
2039
|
-
}
|
|
2040
|
-
newShape[key] = newField;
|
|
2041
|
-
}
|
|
2042
|
-
});
|
|
2043
|
-
}
|
|
2044
|
-
else {
|
|
2045
|
-
for (const key in this.shape) {
|
|
2636
|
+
util.objectKeys(this.shape).forEach((key) => {
|
|
2637
|
+
if (mask && !mask[key]) {
|
|
2638
|
+
newShape[key] = this.shape[key];
|
|
2639
|
+
}
|
|
2640
|
+
else {
|
|
2046
2641
|
const fieldSchema = this.shape[key];
|
|
2047
2642
|
let newField = fieldSchema;
|
|
2048
2643
|
while (newField instanceof ZodOptional) {
|
|
@@ -2050,7 +2645,7 @@ class ZodObject extends ZodType {
|
|
|
2050
2645
|
}
|
|
2051
2646
|
newShape[key] = newField;
|
|
2052
2647
|
}
|
|
2053
|
-
}
|
|
2648
|
+
});
|
|
2054
2649
|
return new ZodObject({
|
|
2055
2650
|
...this._def,
|
|
2056
2651
|
shape: () => newShape,
|
|
@@ -2205,7 +2800,7 @@ const getDiscriminator = (type) => {
|
|
|
2205
2800
|
}
|
|
2206
2801
|
else if (type instanceof ZodNativeEnum) {
|
|
2207
2802
|
// eslint-disable-next-line ban/ban
|
|
2208
|
-
return
|
|
2803
|
+
return util.objectValues(type.enum);
|
|
2209
2804
|
}
|
|
2210
2805
|
else if (type instanceof ZodDefault) {
|
|
2211
2806
|
return getDiscriminator(type._def.innerType);
|
|
@@ -2216,8 +2811,23 @@ const getDiscriminator = (type) => {
|
|
|
2216
2811
|
else if (type instanceof ZodNull) {
|
|
2217
2812
|
return [null];
|
|
2218
2813
|
}
|
|
2814
|
+
else if (type instanceof ZodOptional) {
|
|
2815
|
+
return [undefined, ...getDiscriminator(type.unwrap())];
|
|
2816
|
+
}
|
|
2817
|
+
else if (type instanceof ZodNullable) {
|
|
2818
|
+
return [null, ...getDiscriminator(type.unwrap())];
|
|
2819
|
+
}
|
|
2820
|
+
else if (type instanceof ZodBranded) {
|
|
2821
|
+
return getDiscriminator(type.unwrap());
|
|
2822
|
+
}
|
|
2823
|
+
else if (type instanceof ZodReadonly) {
|
|
2824
|
+
return getDiscriminator(type.unwrap());
|
|
2825
|
+
}
|
|
2826
|
+
else if (type instanceof ZodCatch) {
|
|
2827
|
+
return getDiscriminator(type._def.innerType);
|
|
2828
|
+
}
|
|
2219
2829
|
else {
|
|
2220
|
-
return
|
|
2830
|
+
return [];
|
|
2221
2831
|
}
|
|
2222
2832
|
};
|
|
2223
2833
|
class ZodDiscriminatedUnion extends ZodType {
|
|
@@ -2280,7 +2890,7 @@ class ZodDiscriminatedUnion extends ZodType {
|
|
|
2280
2890
|
// try {
|
|
2281
2891
|
for (const type of options) {
|
|
2282
2892
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
2283
|
-
if (!discriminatorValues) {
|
|
2893
|
+
if (!discriminatorValues.length) {
|
|
2284
2894
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
2285
2895
|
}
|
|
2286
2896
|
for (const value of discriminatorValues) {
|
|
@@ -2431,7 +3041,7 @@ class ZodTuple extends ZodType {
|
|
|
2431
3041
|
});
|
|
2432
3042
|
status.dirty();
|
|
2433
3043
|
}
|
|
2434
|
-
const items = ctx.data
|
|
3044
|
+
const items = [...ctx.data]
|
|
2435
3045
|
.map((item, itemIndex) => {
|
|
2436
3046
|
const schema = this._def.items[itemIndex] || this._def.rest;
|
|
2437
3047
|
if (!schema)
|
|
@@ -2493,6 +3103,7 @@ class ZodRecord extends ZodType {
|
|
|
2493
3103
|
pairs.push({
|
|
2494
3104
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
2495
3105
|
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
|
3106
|
+
alwaysSet: key in ctx.data,
|
|
2496
3107
|
});
|
|
2497
3108
|
}
|
|
2498
3109
|
if (ctx.common.async) {
|
|
@@ -2523,6 +3134,12 @@ class ZodRecord extends ZodType {
|
|
|
2523
3134
|
}
|
|
2524
3135
|
}
|
|
2525
3136
|
class ZodMap extends ZodType {
|
|
3137
|
+
get keySchema() {
|
|
3138
|
+
return this._def.keyType;
|
|
3139
|
+
}
|
|
3140
|
+
get valueSchema() {
|
|
3141
|
+
return this._def.valueType;
|
|
3142
|
+
}
|
|
2526
3143
|
_parse(input) {
|
|
2527
3144
|
const { status, ctx } = this._processInputParams(input);
|
|
2528
3145
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
@@ -2719,16 +3336,20 @@ class ZodFunction extends ZodType {
|
|
|
2719
3336
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
2720
3337
|
const fn = ctx.data;
|
|
2721
3338
|
if (this._def.returns instanceof ZodPromise) {
|
|
2722
|
-
|
|
3339
|
+
// Would love a way to avoid disabling this rule, but we need
|
|
3340
|
+
// an alias (using an arrow function was what caused 2651).
|
|
3341
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
3342
|
+
const me = this;
|
|
3343
|
+
return OK(async function (...args) {
|
|
2723
3344
|
const error = new ZodError([]);
|
|
2724
|
-
const parsedArgs = await
|
|
3345
|
+
const parsedArgs = await me._def.args
|
|
2725
3346
|
.parseAsync(args, params)
|
|
2726
3347
|
.catch((e) => {
|
|
2727
3348
|
error.addIssue(makeArgsIssue(args, e));
|
|
2728
3349
|
throw error;
|
|
2729
3350
|
});
|
|
2730
|
-
const result = await fn
|
|
2731
|
-
const parsedReturns = await
|
|
3351
|
+
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
3352
|
+
const parsedReturns = await me._def.returns._def.type
|
|
2732
3353
|
.parseAsync(result, params)
|
|
2733
3354
|
.catch((e) => {
|
|
2734
3355
|
error.addIssue(makeReturnsIssue(result, e));
|
|
@@ -2738,13 +3359,17 @@ class ZodFunction extends ZodType {
|
|
|
2738
3359
|
});
|
|
2739
3360
|
}
|
|
2740
3361
|
else {
|
|
2741
|
-
|
|
2742
|
-
|
|
3362
|
+
// Would love a way to avoid disabling this rule, but we need
|
|
3363
|
+
// an alias (using an arrow function was what caused 2651).
|
|
3364
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
3365
|
+
const me = this;
|
|
3366
|
+
return OK(function (...args) {
|
|
3367
|
+
const parsedArgs = me._def.args.safeParse(args, params);
|
|
2743
3368
|
if (!parsedArgs.success) {
|
|
2744
3369
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
2745
3370
|
}
|
|
2746
|
-
const result = fn
|
|
2747
|
-
const parsedReturns =
|
|
3371
|
+
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
3372
|
+
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
2748
3373
|
if (!parsedReturns.success) {
|
|
2749
3374
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
2750
3375
|
}
|
|
@@ -2811,6 +3436,7 @@ class ZodLiteral extends ZodType {
|
|
|
2811
3436
|
if (input.data !== this._def.value) {
|
|
2812
3437
|
const ctx = this._getOrReturnCtx(input);
|
|
2813
3438
|
addIssueToContext(ctx, {
|
|
3439
|
+
received: ctx.data,
|
|
2814
3440
|
code: ZodIssueCode.invalid_literal,
|
|
2815
3441
|
expected: this._def.value,
|
|
2816
3442
|
});
|
|
@@ -2831,12 +3457,16 @@ ZodLiteral.create = (value, params) => {
|
|
|
2831
3457
|
};
|
|
2832
3458
|
function createZodEnum(values, params) {
|
|
2833
3459
|
return new ZodEnum({
|
|
2834
|
-
values
|
|
3460
|
+
values,
|
|
2835
3461
|
typeName: ZodFirstPartyTypeKind.ZodEnum,
|
|
2836
3462
|
...processCreateParams(params),
|
|
2837
3463
|
});
|
|
2838
3464
|
}
|
|
2839
3465
|
class ZodEnum extends ZodType {
|
|
3466
|
+
constructor() {
|
|
3467
|
+
super(...arguments);
|
|
3468
|
+
_ZodEnum_cache.set(this, void 0);
|
|
3469
|
+
}
|
|
2840
3470
|
_parse(input) {
|
|
2841
3471
|
if (typeof input.data !== "string") {
|
|
2842
3472
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -2848,7 +3478,10 @@ class ZodEnum extends ZodType {
|
|
|
2848
3478
|
});
|
|
2849
3479
|
return INVALID;
|
|
2850
3480
|
}
|
|
2851
|
-
if (this
|
|
3481
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
|
|
3482
|
+
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
|
3483
|
+
}
|
|
3484
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
|
2852
3485
|
const ctx = this._getOrReturnCtx(input);
|
|
2853
3486
|
const expectedValues = this._def.values;
|
|
2854
3487
|
addIssueToContext(ctx, {
|
|
@@ -2884,9 +3517,26 @@ class ZodEnum extends ZodType {
|
|
|
2884
3517
|
}
|
|
2885
3518
|
return enumValues;
|
|
2886
3519
|
}
|
|
3520
|
+
extract(values, newDef = this._def) {
|
|
3521
|
+
return ZodEnum.create(values, {
|
|
3522
|
+
...this._def,
|
|
3523
|
+
...newDef,
|
|
3524
|
+
});
|
|
3525
|
+
}
|
|
3526
|
+
exclude(values, newDef = this._def) {
|
|
3527
|
+
return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
3528
|
+
...this._def,
|
|
3529
|
+
...newDef,
|
|
3530
|
+
});
|
|
3531
|
+
}
|
|
2887
3532
|
}
|
|
3533
|
+
_ZodEnum_cache = new WeakMap();
|
|
2888
3534
|
ZodEnum.create = createZodEnum;
|
|
2889
3535
|
class ZodNativeEnum extends ZodType {
|
|
3536
|
+
constructor() {
|
|
3537
|
+
super(...arguments);
|
|
3538
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
|
3539
|
+
}
|
|
2890
3540
|
_parse(input) {
|
|
2891
3541
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
2892
3542
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -2900,7 +3550,10 @@ class ZodNativeEnum extends ZodType {
|
|
|
2900
3550
|
});
|
|
2901
3551
|
return INVALID;
|
|
2902
3552
|
}
|
|
2903
|
-
if (
|
|
3553
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
|
|
3554
|
+
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
|
3555
|
+
}
|
|
3556
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
|
2904
3557
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
2905
3558
|
addIssueToContext(ctx, {
|
|
2906
3559
|
received: ctx.data,
|
|
@@ -2915,6 +3568,7 @@ class ZodNativeEnum extends ZodType {
|
|
|
2915
3568
|
return this._def.values;
|
|
2916
3569
|
}
|
|
2917
3570
|
}
|
|
3571
|
+
_ZodNativeEnum_cache = new WeakMap();
|
|
2918
3572
|
ZodNativeEnum.create = (values, params) => {
|
|
2919
3573
|
return new ZodNativeEnum({
|
|
2920
3574
|
values: values,
|
|
@@ -2923,6 +3577,9 @@ ZodNativeEnum.create = (values, params) => {
|
|
|
2923
3577
|
});
|
|
2924
3578
|
};
|
|
2925
3579
|
class ZodPromise extends ZodType {
|
|
3580
|
+
unwrap() {
|
|
3581
|
+
return this._def.type;
|
|
3582
|
+
}
|
|
2926
3583
|
_parse(input) {
|
|
2927
3584
|
const { ctx } = this._processInputParams(input);
|
|
2928
3585
|
if (ctx.parsedType !== ZodParsedType.promise &&
|
|
@@ -2964,25 +3621,6 @@ class ZodEffects extends ZodType {
|
|
|
2964
3621
|
_parse(input) {
|
|
2965
3622
|
const { status, ctx } = this._processInputParams(input);
|
|
2966
3623
|
const effect = this._def.effect || null;
|
|
2967
|
-
if (effect.type === "preprocess") {
|
|
2968
|
-
const processed = effect.transform(ctx.data);
|
|
2969
|
-
if (ctx.common.async) {
|
|
2970
|
-
return Promise.resolve(processed).then((processed) => {
|
|
2971
|
-
return this._def.schema._parseAsync({
|
|
2972
|
-
data: processed,
|
|
2973
|
-
path: ctx.path,
|
|
2974
|
-
parent: ctx,
|
|
2975
|
-
});
|
|
2976
|
-
});
|
|
2977
|
-
}
|
|
2978
|
-
else {
|
|
2979
|
-
return this._def.schema._parseSync({
|
|
2980
|
-
data: processed,
|
|
2981
|
-
path: ctx.path,
|
|
2982
|
-
parent: ctx,
|
|
2983
|
-
});
|
|
2984
|
-
}
|
|
2985
|
-
}
|
|
2986
3624
|
const checkCtx = {
|
|
2987
3625
|
addIssue: (arg) => {
|
|
2988
3626
|
addIssueToContext(ctx, arg);
|
|
@@ -2998,10 +3636,45 @@ class ZodEffects extends ZodType {
|
|
|
2998
3636
|
},
|
|
2999
3637
|
};
|
|
3000
3638
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3639
|
+
if (effect.type === "preprocess") {
|
|
3640
|
+
const processed = effect.transform(ctx.data, checkCtx);
|
|
3641
|
+
if (ctx.common.async) {
|
|
3642
|
+
return Promise.resolve(processed).then(async (processed) => {
|
|
3643
|
+
if (status.value === "aborted")
|
|
3644
|
+
return INVALID;
|
|
3645
|
+
const result = await this._def.schema._parseAsync({
|
|
3646
|
+
data: processed,
|
|
3647
|
+
path: ctx.path,
|
|
3648
|
+
parent: ctx,
|
|
3649
|
+
});
|
|
3650
|
+
if (result.status === "aborted")
|
|
3651
|
+
return INVALID;
|
|
3652
|
+
if (result.status === "dirty")
|
|
3653
|
+
return DIRTY(result.value);
|
|
3654
|
+
if (status.value === "dirty")
|
|
3655
|
+
return DIRTY(result.value);
|
|
3656
|
+
return result;
|
|
3657
|
+
});
|
|
3658
|
+
}
|
|
3659
|
+
else {
|
|
3660
|
+
if (status.value === "aborted")
|
|
3661
|
+
return INVALID;
|
|
3662
|
+
const result = this._def.schema._parseSync({
|
|
3663
|
+
data: processed,
|
|
3664
|
+
path: ctx.path,
|
|
3665
|
+
parent: ctx,
|
|
3666
|
+
});
|
|
3667
|
+
if (result.status === "aborted")
|
|
3668
|
+
return INVALID;
|
|
3669
|
+
if (result.status === "dirty")
|
|
3670
|
+
return DIRTY(result.value);
|
|
3671
|
+
if (status.value === "dirty")
|
|
3672
|
+
return DIRTY(result.value);
|
|
3673
|
+
return result;
|
|
3674
|
+
}
|
|
3675
|
+
}
|
|
3001
3676
|
if (effect.type === "refinement") {
|
|
3002
|
-
const executeRefinement = (acc
|
|
3003
|
-
// effect: RefinementEffect<any>
|
|
3004
|
-
) => {
|
|
3677
|
+
const executeRefinement = (acc) => {
|
|
3005
3678
|
const result = effect.refinement(acc, checkCtx);
|
|
3006
3679
|
if (ctx.common.async) {
|
|
3007
3680
|
return Promise.resolve(result);
|
|
@@ -3046,10 +3719,6 @@ class ZodEffects extends ZodType {
|
|
|
3046
3719
|
path: ctx.path,
|
|
3047
3720
|
parent: ctx,
|
|
3048
3721
|
});
|
|
3049
|
-
// if (base.status === "aborted") return INVALID;
|
|
3050
|
-
// if (base.status === "dirty") {
|
|
3051
|
-
// return { status: "dirty", value: base.value };
|
|
3052
|
-
// }
|
|
3053
3722
|
if (!isValid(base))
|
|
3054
3723
|
return base;
|
|
3055
3724
|
const result = effect.transform(base.value, checkCtx);
|
|
@@ -3064,10 +3733,6 @@ class ZodEffects extends ZodType {
|
|
|
3064
3733
|
.then((base) => {
|
|
3065
3734
|
if (!isValid(base))
|
|
3066
3735
|
return base;
|
|
3067
|
-
// if (base.status === "aborted") return INVALID;
|
|
3068
|
-
// if (base.status === "dirty") {
|
|
3069
|
-
// return { status: "dirty", value: base.value };
|
|
3070
|
-
// }
|
|
3071
3736
|
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
|
|
3072
3737
|
});
|
|
3073
3738
|
}
|
|
@@ -3159,27 +3824,51 @@ ZodDefault.create = (type, params) => {
|
|
|
3159
3824
|
class ZodCatch extends ZodType {
|
|
3160
3825
|
_parse(input) {
|
|
3161
3826
|
const { ctx } = this._processInputParams(input);
|
|
3827
|
+
// newCtx is used to not collect issues from inner types in ctx
|
|
3828
|
+
const newCtx = {
|
|
3829
|
+
...ctx,
|
|
3830
|
+
common: {
|
|
3831
|
+
...ctx.common,
|
|
3832
|
+
issues: [],
|
|
3833
|
+
},
|
|
3834
|
+
};
|
|
3162
3835
|
const result = this._def.innerType._parse({
|
|
3163
|
-
data:
|
|
3164
|
-
path:
|
|
3165
|
-
parent:
|
|
3836
|
+
data: newCtx.data,
|
|
3837
|
+
path: newCtx.path,
|
|
3838
|
+
parent: {
|
|
3839
|
+
...newCtx,
|
|
3840
|
+
},
|
|
3166
3841
|
});
|
|
3167
3842
|
if (isAsync(result)) {
|
|
3168
3843
|
return result.then((result) => {
|
|
3169
3844
|
return {
|
|
3170
3845
|
status: "valid",
|
|
3171
|
-
value: result.status === "valid"
|
|
3846
|
+
value: result.status === "valid"
|
|
3847
|
+
? result.value
|
|
3848
|
+
: this._def.catchValue({
|
|
3849
|
+
get error() {
|
|
3850
|
+
return new ZodError(newCtx.common.issues);
|
|
3851
|
+
},
|
|
3852
|
+
input: newCtx.data,
|
|
3853
|
+
}),
|
|
3172
3854
|
};
|
|
3173
3855
|
});
|
|
3174
3856
|
}
|
|
3175
3857
|
else {
|
|
3176
3858
|
return {
|
|
3177
3859
|
status: "valid",
|
|
3178
|
-
value: result.status === "valid"
|
|
3860
|
+
value: result.status === "valid"
|
|
3861
|
+
? result.value
|
|
3862
|
+
: this._def.catchValue({
|
|
3863
|
+
get error() {
|
|
3864
|
+
return new ZodError(newCtx.common.issues);
|
|
3865
|
+
},
|
|
3866
|
+
input: newCtx.data,
|
|
3867
|
+
}),
|
|
3179
3868
|
};
|
|
3180
3869
|
}
|
|
3181
3870
|
}
|
|
3182
|
-
|
|
3871
|
+
removeCatch() {
|
|
3183
3872
|
return this._def.innerType;
|
|
3184
3873
|
}
|
|
3185
3874
|
}
|
|
@@ -3187,9 +3876,7 @@ ZodCatch.create = (type, params) => {
|
|
|
3187
3876
|
return new ZodCatch({
|
|
3188
3877
|
innerType: type,
|
|
3189
3878
|
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
|
3190
|
-
|
|
3191
|
-
? params.default
|
|
3192
|
-
: () => params.default,
|
|
3879
|
+
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
|
|
3193
3880
|
...processCreateParams(params),
|
|
3194
3881
|
});
|
|
3195
3882
|
};
|
|
@@ -3287,17 +3974,58 @@ class ZodPipeline extends ZodType {
|
|
|
3287
3974
|
});
|
|
3288
3975
|
}
|
|
3289
3976
|
}
|
|
3290
|
-
|
|
3977
|
+
class ZodReadonly extends ZodType {
|
|
3978
|
+
_parse(input) {
|
|
3979
|
+
const result = this._def.innerType._parse(input);
|
|
3980
|
+
const freeze = (data) => {
|
|
3981
|
+
if (isValid(data)) {
|
|
3982
|
+
data.value = Object.freeze(data.value);
|
|
3983
|
+
}
|
|
3984
|
+
return data;
|
|
3985
|
+
};
|
|
3986
|
+
return isAsync(result)
|
|
3987
|
+
? result.then((data) => freeze(data))
|
|
3988
|
+
: freeze(result);
|
|
3989
|
+
}
|
|
3990
|
+
unwrap() {
|
|
3991
|
+
return this._def.innerType;
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
ZodReadonly.create = (type, params) => {
|
|
3995
|
+
return new ZodReadonly({
|
|
3996
|
+
innerType: type,
|
|
3997
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
|
3998
|
+
...processCreateParams(params),
|
|
3999
|
+
});
|
|
4000
|
+
};
|
|
4001
|
+
function custom(check, params = {},
|
|
4002
|
+
/**
|
|
4003
|
+
* @deprecated
|
|
4004
|
+
*
|
|
4005
|
+
* Pass `fatal` into the params object instead:
|
|
4006
|
+
*
|
|
4007
|
+
* ```ts
|
|
4008
|
+
* z.string().custom((val) => val.length > 5, { fatal: false })
|
|
4009
|
+
* ```
|
|
4010
|
+
*
|
|
4011
|
+
*/
|
|
4012
|
+
fatal) {
|
|
3291
4013
|
if (check)
|
|
3292
4014
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
4015
|
+
var _a, _b;
|
|
3293
4016
|
if (!check(data)) {
|
|
3294
|
-
const p = typeof params === "function"
|
|
4017
|
+
const p = typeof params === "function"
|
|
4018
|
+
? params(data)
|
|
4019
|
+
: typeof params === "string"
|
|
4020
|
+
? { message: params }
|
|
4021
|
+
: params;
|
|
4022
|
+
const _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
|
|
3295
4023
|
const p2 = typeof p === "string" ? { message: p } : p;
|
|
3296
|
-
ctx.addIssue({ code: "custom", ...p2, fatal });
|
|
4024
|
+
ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
|
|
3297
4025
|
}
|
|
3298
4026
|
});
|
|
3299
4027
|
return ZodAny.create();
|
|
3300
|
-
}
|
|
4028
|
+
}
|
|
3301
4029
|
const late = {
|
|
3302
4030
|
object: ZodObject.lazycreate,
|
|
3303
4031
|
};
|
|
@@ -3338,12 +4066,13 @@ var ZodFirstPartyTypeKind;
|
|
|
3338
4066
|
ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
|
|
3339
4067
|
ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
|
|
3340
4068
|
ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
|
|
4069
|
+
ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
|
|
3341
4070
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
3342
4071
|
const instanceOfType = (
|
|
3343
4072
|
// const instanceOfType = <T extends new (...args: any[]) => any>(
|
|
3344
4073
|
cls, params = {
|
|
3345
4074
|
message: `Input not instance of ${cls.name}`,
|
|
3346
|
-
}) => custom((data) => data instanceof cls, params
|
|
4075
|
+
}) => custom((data) => data instanceof cls, params);
|
|
3347
4076
|
const stringType = ZodString.create;
|
|
3348
4077
|
const numberType = ZodNumber.create;
|
|
3349
4078
|
const nanType = ZodNaN.create;
|
|
@@ -3384,13 +4113,16 @@ const oboolean = () => booleanType().optional();
|
|
|
3384
4113
|
const coerce = {
|
|
3385
4114
|
string: ((arg) => ZodString.create({ ...arg, coerce: true })),
|
|
3386
4115
|
number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
|
|
3387
|
-
boolean: ((arg) => ZodBoolean.create({
|
|
4116
|
+
boolean: ((arg) => ZodBoolean.create({
|
|
4117
|
+
...arg,
|
|
4118
|
+
coerce: true,
|
|
4119
|
+
})),
|
|
3388
4120
|
bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
|
|
3389
4121
|
date: ((arg) => ZodDate.create({ ...arg, coerce: true })),
|
|
3390
4122
|
};
|
|
3391
4123
|
const NEVER = INVALID;
|
|
3392
4124
|
|
|
3393
|
-
var
|
|
4125
|
+
var z = /*#__PURE__*/Object.freeze({
|
|
3394
4126
|
__proto__: null,
|
|
3395
4127
|
defaultErrorMap: errorMap,
|
|
3396
4128
|
setErrorMap: setErrorMap,
|
|
@@ -3407,9 +4139,11 @@ var mod = /*#__PURE__*/Object.freeze({
|
|
|
3407
4139
|
isValid: isValid,
|
|
3408
4140
|
isAsync: isAsync,
|
|
3409
4141
|
get util () { return util; },
|
|
4142
|
+
get objectUtil () { return objectUtil; },
|
|
3410
4143
|
ZodParsedType: ZodParsedType,
|
|
3411
4144
|
getParsedType: getParsedType,
|
|
3412
4145
|
ZodType: ZodType,
|
|
4146
|
+
datetimeRegex: datetimeRegex,
|
|
3413
4147
|
ZodString: ZodString,
|
|
3414
4148
|
ZodNumber: ZodNumber,
|
|
3415
4149
|
ZodBigInt: ZodBigInt,
|
|
@@ -3423,7 +4157,6 @@ var mod = /*#__PURE__*/Object.freeze({
|
|
|
3423
4157
|
ZodNever: ZodNever,
|
|
3424
4158
|
ZodVoid: ZodVoid,
|
|
3425
4159
|
ZodArray: ZodArray,
|
|
3426
|
-
get objectUtil () { return objectUtil; },
|
|
3427
4160
|
ZodObject: ZodObject,
|
|
3428
4161
|
ZodUnion: ZodUnion,
|
|
3429
4162
|
ZodDiscriminatedUnion: ZodDiscriminatedUnion,
|
|
@@ -3448,6 +4181,7 @@ var mod = /*#__PURE__*/Object.freeze({
|
|
|
3448
4181
|
BRAND: BRAND,
|
|
3449
4182
|
ZodBranded: ZodBranded,
|
|
3450
4183
|
ZodPipeline: ZodPipeline,
|
|
4184
|
+
ZodReadonly: ZodReadonly,
|
|
3451
4185
|
custom: custom,
|
|
3452
4186
|
Schema: ZodType,
|
|
3453
4187
|
ZodSchema: ZodType,
|
|
@@ -3499,37 +4233,135 @@ var mod = /*#__PURE__*/Object.freeze({
|
|
|
3499
4233
|
ZodError: ZodError
|
|
3500
4234
|
});
|
|
3501
4235
|
|
|
4236
|
+
const currentSymbol = Symbol("current");
|
|
4237
|
+
const previousSymbol = Symbol("previous");
|
|
4238
|
+
|
|
4239
|
+
const mergeOpenApi = (openapi, {
|
|
4240
|
+
ref: _ref,
|
|
4241
|
+
refType: _refType,
|
|
4242
|
+
param: _param,
|
|
4243
|
+
header: _header,
|
|
4244
|
+
...rest
|
|
4245
|
+
} = {}) => ({
|
|
4246
|
+
...rest,
|
|
4247
|
+
...openapi
|
|
4248
|
+
});
|
|
4249
|
+
function extendZodWithOpenApi(zod) {
|
|
4250
|
+
if (typeof zod.ZodType.prototype.openapi !== "undefined") {
|
|
4251
|
+
return;
|
|
4252
|
+
}
|
|
4253
|
+
zod.ZodType.prototype.openapi = function(openapi) {
|
|
4254
|
+
const { zodOpenApi, ...rest } = this._def;
|
|
4255
|
+
const result = new this.constructor({
|
|
4256
|
+
...rest,
|
|
4257
|
+
zodOpenApi: {
|
|
4258
|
+
openapi: mergeOpenApi(
|
|
4259
|
+
openapi,
|
|
4260
|
+
zodOpenApi == null ? void 0 : zodOpenApi.openapi
|
|
4261
|
+
)
|
|
4262
|
+
}
|
|
4263
|
+
});
|
|
4264
|
+
result._def.zodOpenApi[currentSymbol] = result;
|
|
4265
|
+
if (zodOpenApi) {
|
|
4266
|
+
result._def.zodOpenApi[previousSymbol] = this;
|
|
4267
|
+
}
|
|
4268
|
+
return result;
|
|
4269
|
+
};
|
|
4270
|
+
const zodDescribe = zod.ZodType.prototype.describe;
|
|
4271
|
+
zod.ZodType.prototype.describe = function(...args) {
|
|
4272
|
+
const result = zodDescribe.apply(this, args);
|
|
4273
|
+
const def = result._def;
|
|
4274
|
+
if (def.zodOpenApi) {
|
|
4275
|
+
const cloned = { ...def.zodOpenApi };
|
|
4276
|
+
cloned.openapi = mergeOpenApi({ description: args[0] }, cloned.openapi);
|
|
4277
|
+
cloned[previousSymbol] = this;
|
|
4278
|
+
cloned[currentSymbol] = result;
|
|
4279
|
+
def.zodOpenApi = cloned;
|
|
4280
|
+
} else {
|
|
4281
|
+
def.zodOpenApi = {
|
|
4282
|
+
openapi: { description: args[0] },
|
|
4283
|
+
[currentSymbol]: result
|
|
4284
|
+
};
|
|
4285
|
+
}
|
|
4286
|
+
return result;
|
|
4287
|
+
};
|
|
4288
|
+
const zodObjectExtend = zod.ZodObject.prototype.extend;
|
|
4289
|
+
zod.ZodObject.prototype.extend = function(...args) {
|
|
4290
|
+
const extendResult = zodObjectExtend.apply(this, args);
|
|
4291
|
+
const zodOpenApi = extendResult._def.zodOpenApi;
|
|
4292
|
+
if (zodOpenApi) {
|
|
4293
|
+
const cloned = { ...zodOpenApi };
|
|
4294
|
+
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
4295
|
+
cloned[previousSymbol] = this;
|
|
4296
|
+
extendResult._def.zodOpenApi = cloned;
|
|
4297
|
+
} else {
|
|
4298
|
+
extendResult._def.zodOpenApi = {
|
|
4299
|
+
[previousSymbol]: this
|
|
4300
|
+
};
|
|
4301
|
+
}
|
|
4302
|
+
return extendResult;
|
|
4303
|
+
};
|
|
4304
|
+
const zodObjectOmit = zod.ZodObject.prototype.omit;
|
|
4305
|
+
zod.ZodObject.prototype.omit = function(...args) {
|
|
4306
|
+
const omitResult = zodObjectOmit.apply(this, args);
|
|
4307
|
+
const zodOpenApi = omitResult._def.zodOpenApi;
|
|
4308
|
+
if (zodOpenApi) {
|
|
4309
|
+
const cloned = { ...zodOpenApi };
|
|
4310
|
+
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
4311
|
+
delete cloned[previousSymbol];
|
|
4312
|
+
delete cloned[currentSymbol];
|
|
4313
|
+
omitResult._def.zodOpenApi = cloned;
|
|
4314
|
+
}
|
|
4315
|
+
return omitResult;
|
|
4316
|
+
};
|
|
4317
|
+
const zodObjectPick = zod.ZodObject.prototype.pick;
|
|
4318
|
+
zod.ZodObject.prototype.pick = function(...args) {
|
|
4319
|
+
const pickResult = zodObjectPick.apply(this, args);
|
|
4320
|
+
const zodOpenApi = pickResult._def.zodOpenApi;
|
|
4321
|
+
if (zodOpenApi) {
|
|
4322
|
+
const cloned = { ...zodOpenApi };
|
|
4323
|
+
cloned.openapi = mergeOpenApi({}, cloned.openapi);
|
|
4324
|
+
delete cloned[previousSymbol];
|
|
4325
|
+
delete cloned[currentSymbol];
|
|
4326
|
+
pickResult._def.zodOpenApi = cloned;
|
|
4327
|
+
}
|
|
4328
|
+
return pickResult;
|
|
4329
|
+
};
|
|
4330
|
+
}
|
|
4331
|
+
|
|
4332
|
+
extendZodWithOpenApi(z);
|
|
4333
|
+
|
|
3502
4334
|
var __defProp = Object.defineProperty;
|
|
3503
4335
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3504
|
-
var ContextValidator =
|
|
3505
|
-
|
|
3506
|
-
type:
|
|
3507
|
-
narrative:
|
|
4336
|
+
var ContextValidator = z.array(z.string().or(z.record(z.any())));
|
|
4337
|
+
z.object({
|
|
4338
|
+
type: z.string().optional(),
|
|
4339
|
+
narrative: z.string().optional()
|
|
3508
4340
|
});
|
|
3509
|
-
var ImageValidator =
|
|
3510
|
-
|
|
3511
|
-
id:
|
|
3512
|
-
type:
|
|
3513
|
-
caption:
|
|
4341
|
+
var ImageValidator = z.string().or(
|
|
4342
|
+
z.object({
|
|
4343
|
+
id: z.string(),
|
|
4344
|
+
type: z.string(),
|
|
4345
|
+
caption: z.string().optional()
|
|
3514
4346
|
})
|
|
3515
4347
|
);
|
|
3516
|
-
var GeoCoordinatesValidator =
|
|
3517
|
-
type:
|
|
3518
|
-
latitude:
|
|
3519
|
-
longitude:
|
|
4348
|
+
var GeoCoordinatesValidator = z.object({
|
|
4349
|
+
type: z.string().min(1).or(z.string().array().nonempty()),
|
|
4350
|
+
latitude: z.number(),
|
|
4351
|
+
longitude: z.number()
|
|
3520
4352
|
});
|
|
3521
|
-
var AddressValidator =
|
|
3522
|
-
type:
|
|
3523
|
-
addressCountry:
|
|
3524
|
-
addressCountryCode:
|
|
3525
|
-
addressRegion:
|
|
3526
|
-
addressLocality:
|
|
3527
|
-
streetAddress:
|
|
3528
|
-
postOfficeBoxNumber:
|
|
3529
|
-
postalCode:
|
|
4353
|
+
var AddressValidator = z.object({
|
|
4354
|
+
type: z.string().min(1).or(z.string().array().nonempty()),
|
|
4355
|
+
addressCountry: z.string().optional(),
|
|
4356
|
+
addressCountryCode: z.string().optional(),
|
|
4357
|
+
addressRegion: z.string().optional(),
|
|
4358
|
+
addressLocality: z.string().optional(),
|
|
4359
|
+
streetAddress: z.string().optional(),
|
|
4360
|
+
postOfficeBoxNumber: z.string().optional(),
|
|
4361
|
+
postalCode: z.string().optional(),
|
|
3530
4362
|
geo: GeoCoordinatesValidator.optional()
|
|
3531
4363
|
});
|
|
3532
|
-
var IdentifierTypeValidator =
|
|
4364
|
+
var IdentifierTypeValidator = z.enum([
|
|
3533
4365
|
"sourcedId",
|
|
3534
4366
|
"systemId",
|
|
3535
4367
|
"productId",
|
|
@@ -3548,140 +4380,140 @@ var IdentifierTypeValidator = mod.enum([
|
|
|
3548
4380
|
"ltiPlatformId",
|
|
3549
4381
|
"ltiUserId",
|
|
3550
4382
|
"identifier"
|
|
3551
|
-
]).or(
|
|
3552
|
-
var IdentifierEntryValidator =
|
|
3553
|
-
type:
|
|
3554
|
-
identifier:
|
|
4383
|
+
]).or(z.string());
|
|
4384
|
+
var IdentifierEntryValidator = z.object({
|
|
4385
|
+
type: z.string().min(1).or(z.string().array().nonempty()),
|
|
4386
|
+
identifier: z.string(),
|
|
3555
4387
|
identifierType: IdentifierTypeValidator
|
|
3556
4388
|
});
|
|
3557
|
-
var ProfileValidator =
|
|
3558
|
-
|
|
3559
|
-
id:
|
|
3560
|
-
type:
|
|
3561
|
-
name:
|
|
3562
|
-
url:
|
|
3563
|
-
phone:
|
|
3564
|
-
description:
|
|
3565
|
-
endorsement:
|
|
4389
|
+
var ProfileValidator = z.string().or(
|
|
4390
|
+
z.object({
|
|
4391
|
+
id: z.string().optional(),
|
|
4392
|
+
type: z.string().or(z.string().array().nonempty().optional()),
|
|
4393
|
+
name: z.string().optional(),
|
|
4394
|
+
url: z.string().optional(),
|
|
4395
|
+
phone: z.string().optional(),
|
|
4396
|
+
description: z.string().optional(),
|
|
4397
|
+
endorsement: z.any().array().optional(),
|
|
3566
4398
|
image: ImageValidator.optional(),
|
|
3567
|
-
email:
|
|
4399
|
+
email: z.string().email().optional(),
|
|
3568
4400
|
address: AddressValidator.optional(),
|
|
3569
4401
|
otherIdentifier: IdentifierEntryValidator.array().optional(),
|
|
3570
|
-
official:
|
|
3571
|
-
parentOrg:
|
|
3572
|
-
familyName:
|
|
3573
|
-
givenName:
|
|
3574
|
-
additionalName:
|
|
3575
|
-
patronymicName:
|
|
3576
|
-
honorificPrefix:
|
|
3577
|
-
honorificSuffix:
|
|
3578
|
-
familyNamePrefix:
|
|
3579
|
-
dateOfBirth:
|
|
3580
|
-
}).catchall(
|
|
4402
|
+
official: z.string().optional(),
|
|
4403
|
+
parentOrg: z.any().optional(),
|
|
4404
|
+
familyName: z.string().optional(),
|
|
4405
|
+
givenName: z.string().optional(),
|
|
4406
|
+
additionalName: z.string().optional(),
|
|
4407
|
+
patronymicName: z.string().optional(),
|
|
4408
|
+
honorificPrefix: z.string().optional(),
|
|
4409
|
+
honorificSuffix: z.string().optional(),
|
|
4410
|
+
familyNamePrefix: z.string().optional(),
|
|
4411
|
+
dateOfBirth: z.string().optional()
|
|
4412
|
+
}).catchall(z.any())
|
|
3581
4413
|
);
|
|
3582
|
-
var CredentialSubjectValidator =
|
|
3583
|
-
var CredentialStatusValidator =
|
|
3584
|
-
var CredentialSchemaValidator =
|
|
3585
|
-
var RefreshServiceValidator =
|
|
3586
|
-
var TermsOfUseValidator =
|
|
3587
|
-
var VC2EvidenceValidator =
|
|
3588
|
-
var UnsignedVCValidator =
|
|
4414
|
+
var CredentialSubjectValidator = z.object({ id: z.string().optional() }).catchall(z.any());
|
|
4415
|
+
var CredentialStatusValidator = z.object({ type: z.string(), id: z.string() }).catchall(z.any());
|
|
4416
|
+
var CredentialSchemaValidator = z.object({ id: z.string(), type: z.string() }).catchall(z.any());
|
|
4417
|
+
var RefreshServiceValidator = z.object({ id: z.string().optional(), type: z.string() }).catchall(z.any());
|
|
4418
|
+
var TermsOfUseValidator = z.object({ type: z.string(), id: z.string().optional() }).catchall(z.any());
|
|
4419
|
+
var VC2EvidenceValidator = z.object({ type: z.string().or(z.string().array().nonempty()), id: z.string().optional() }).catchall(z.any());
|
|
4420
|
+
var UnsignedVCValidator = z.object({
|
|
3589
4421
|
"@context": ContextValidator,
|
|
3590
|
-
id:
|
|
3591
|
-
type:
|
|
4422
|
+
id: z.string().optional(),
|
|
4423
|
+
type: z.string().array().nonempty(),
|
|
3592
4424
|
issuer: ProfileValidator,
|
|
3593
4425
|
credentialSubject: CredentialSubjectValidator.or(CredentialSubjectValidator.array()),
|
|
3594
4426
|
refreshService: RefreshServiceValidator.or(RefreshServiceValidator.array()).optional(),
|
|
3595
4427
|
credentialSchema: CredentialSchemaValidator.or(
|
|
3596
4428
|
CredentialSchemaValidator.array()
|
|
3597
4429
|
).optional(),
|
|
3598
|
-
issuanceDate:
|
|
3599
|
-
expirationDate:
|
|
4430
|
+
issuanceDate: z.string().optional(),
|
|
4431
|
+
expirationDate: z.string().optional(),
|
|
3600
4432
|
credentialStatus: CredentialStatusValidator.or(
|
|
3601
4433
|
CredentialStatusValidator.array()
|
|
3602
4434
|
).optional(),
|
|
3603
|
-
name:
|
|
3604
|
-
description:
|
|
3605
|
-
validFrom:
|
|
3606
|
-
validUntil:
|
|
4435
|
+
name: z.string().optional(),
|
|
4436
|
+
description: z.string().optional(),
|
|
4437
|
+
validFrom: z.string().optional(),
|
|
4438
|
+
validUntil: z.string().optional(),
|
|
3607
4439
|
status: CredentialStatusValidator.or(CredentialStatusValidator.array()).optional(),
|
|
3608
4440
|
termsOfUse: TermsOfUseValidator.or(TermsOfUseValidator.array()).optional(),
|
|
3609
4441
|
evidence: VC2EvidenceValidator.or(VC2EvidenceValidator.array()).optional()
|
|
3610
|
-
}).catchall(
|
|
3611
|
-
var ProofValidator =
|
|
3612
|
-
type:
|
|
3613
|
-
created:
|
|
3614
|
-
challenge:
|
|
3615
|
-
domain:
|
|
3616
|
-
nonce:
|
|
3617
|
-
proofPurpose:
|
|
3618
|
-
verificationMethod:
|
|
3619
|
-
jws:
|
|
3620
|
-
}).catchall(
|
|
4442
|
+
}).catchall(z.any());
|
|
4443
|
+
var ProofValidator = z.object({
|
|
4444
|
+
type: z.string(),
|
|
4445
|
+
created: z.string(),
|
|
4446
|
+
challenge: z.string().optional(),
|
|
4447
|
+
domain: z.string().optional(),
|
|
4448
|
+
nonce: z.string().optional(),
|
|
4449
|
+
proofPurpose: z.string(),
|
|
4450
|
+
verificationMethod: z.string(),
|
|
4451
|
+
jws: z.string().optional()
|
|
4452
|
+
}).catchall(z.any());
|
|
3621
4453
|
var VCValidator = UnsignedVCValidator.extend({
|
|
3622
4454
|
proof: ProofValidator.or(ProofValidator.array())
|
|
3623
4455
|
});
|
|
3624
|
-
var UnsignedVPValidator =
|
|
4456
|
+
var UnsignedVPValidator = z.object({
|
|
3625
4457
|
"@context": ContextValidator,
|
|
3626
|
-
id:
|
|
3627
|
-
type:
|
|
4458
|
+
id: z.string().optional(),
|
|
4459
|
+
type: z.string().or(z.string().array().nonempty()),
|
|
3628
4460
|
verifiableCredential: VCValidator.or(VCValidator.array()).optional(),
|
|
3629
|
-
holder:
|
|
3630
|
-
}).catchall(
|
|
4461
|
+
holder: z.string().optional()
|
|
4462
|
+
}).catchall(z.any());
|
|
3631
4463
|
UnsignedVPValidator.extend({
|
|
3632
4464
|
proof: ProofValidator.or(ProofValidator.array())
|
|
3633
4465
|
});
|
|
3634
|
-
var JWKValidator =
|
|
3635
|
-
kty:
|
|
3636
|
-
crv:
|
|
3637
|
-
x:
|
|
3638
|
-
y:
|
|
3639
|
-
n:
|
|
3640
|
-
d:
|
|
4466
|
+
var JWKValidator = z.object({
|
|
4467
|
+
kty: z.string(),
|
|
4468
|
+
crv: z.string(),
|
|
4469
|
+
x: z.string(),
|
|
4470
|
+
y: z.string().optional(),
|
|
4471
|
+
n: z.string().optional(),
|
|
4472
|
+
d: z.string().optional()
|
|
3641
4473
|
});
|
|
3642
|
-
JWKValidator.omit({ d: true }).extend({ d:
|
|
3643
|
-
var JWERecipientHeaderValidator =
|
|
3644
|
-
alg:
|
|
3645
|
-
iv:
|
|
3646
|
-
tag:
|
|
4474
|
+
JWKValidator.omit({ d: true }).extend({ d: z.string() });
|
|
4475
|
+
var JWERecipientHeaderValidator = z.object({
|
|
4476
|
+
alg: z.string(),
|
|
4477
|
+
iv: z.string(),
|
|
4478
|
+
tag: z.string(),
|
|
3647
4479
|
epk: JWKValidator.partial().optional(),
|
|
3648
|
-
kid:
|
|
3649
|
-
apv:
|
|
3650
|
-
apu:
|
|
4480
|
+
kid: z.string().optional(),
|
|
4481
|
+
apv: z.string().optional(),
|
|
4482
|
+
apu: z.string().optional()
|
|
3651
4483
|
});
|
|
3652
|
-
var JWERecipientValidator =
|
|
4484
|
+
var JWERecipientValidator = z.object({
|
|
3653
4485
|
header: JWERecipientHeaderValidator,
|
|
3654
|
-
encrypted_key:
|
|
4486
|
+
encrypted_key: z.string()
|
|
3655
4487
|
});
|
|
3656
|
-
var JWEValidator =
|
|
3657
|
-
protected:
|
|
3658
|
-
iv:
|
|
3659
|
-
ciphertext:
|
|
3660
|
-
tag:
|
|
3661
|
-
aad:
|
|
4488
|
+
var JWEValidator = z.object({
|
|
4489
|
+
protected: z.string(),
|
|
4490
|
+
iv: z.string(),
|
|
4491
|
+
ciphertext: z.string(),
|
|
4492
|
+
tag: z.string(),
|
|
4493
|
+
aad: z.string().optional(),
|
|
3662
4494
|
recipients: JWERecipientValidator.array().optional()
|
|
3663
4495
|
});
|
|
3664
|
-
var VerificationMethodValidator =
|
|
3665
|
-
|
|
4496
|
+
var VerificationMethodValidator = z.string().or(
|
|
4497
|
+
z.object({
|
|
3666
4498
|
"@context": ContextValidator.optional(),
|
|
3667
|
-
id:
|
|
3668
|
-
type:
|
|
3669
|
-
controller:
|
|
4499
|
+
id: z.string(),
|
|
4500
|
+
type: z.string(),
|
|
4501
|
+
controller: z.string(),
|
|
3670
4502
|
publicKeyJwk: JWKValidator.optional(),
|
|
3671
|
-
publicKeyBase58:
|
|
3672
|
-
blockChainAccountId:
|
|
3673
|
-
}).catchall(
|
|
4503
|
+
publicKeyBase58: z.string().optional(),
|
|
4504
|
+
blockChainAccountId: z.string().optional()
|
|
4505
|
+
}).catchall(z.any())
|
|
3674
4506
|
);
|
|
3675
|
-
var ServiceValidator =
|
|
3676
|
-
id:
|
|
3677
|
-
type:
|
|
3678
|
-
serviceEndpoint:
|
|
3679
|
-
}).catchall(
|
|
3680
|
-
|
|
4507
|
+
var ServiceValidator = z.object({
|
|
4508
|
+
id: z.string(),
|
|
4509
|
+
type: z.string().or(z.string().array().nonempty()),
|
|
4510
|
+
serviceEndpoint: z.any().or(z.any().array().nonempty())
|
|
4511
|
+
}).catchall(z.any());
|
|
4512
|
+
z.object({
|
|
3681
4513
|
"@context": ContextValidator,
|
|
3682
|
-
id:
|
|
3683
|
-
alsoKnownAs:
|
|
3684
|
-
controller:
|
|
4514
|
+
id: z.string(),
|
|
4515
|
+
alsoKnownAs: z.string().optional(),
|
|
4516
|
+
controller: z.string().or(z.string().array().nonempty()).optional(),
|
|
3685
4517
|
verificationMethod: VerificationMethodValidator.array().optional(),
|
|
3686
4518
|
authentication: VerificationMethodValidator.array().optional(),
|
|
3687
4519
|
assertionMethod: VerificationMethodValidator.array().optional(),
|
|
@@ -3691,8 +4523,8 @@ mod.object({
|
|
|
3691
4523
|
publicKey: VerificationMethodValidator.array().optional(),
|
|
3692
4524
|
service: ServiceValidator.array().optional(),
|
|
3693
4525
|
proof: ProofValidator.or(ProofValidator.array()).optional()
|
|
3694
|
-
}).catchall(
|
|
3695
|
-
var AlignmentTargetTypeValidator =
|
|
4526
|
+
}).catchall(z.any());
|
|
4527
|
+
var AlignmentTargetTypeValidator = z.enum([
|
|
3696
4528
|
"ceasn:Competency",
|
|
3697
4529
|
"ceterms:Credential",
|
|
3698
4530
|
"CFItem",
|
|
@@ -3700,17 +4532,17 @@ var AlignmentTargetTypeValidator = mod.enum([
|
|
|
3700
4532
|
"CFRubricCriterion",
|
|
3701
4533
|
"CFRubricCriterionLevel",
|
|
3702
4534
|
"CTDL"
|
|
3703
|
-
]).or(
|
|
3704
|
-
var AlignmentValidator =
|
|
3705
|
-
type:
|
|
3706
|
-
targetCode:
|
|
3707
|
-
targetDescription:
|
|
3708
|
-
targetName:
|
|
3709
|
-
targetFramework:
|
|
4535
|
+
]).or(z.string());
|
|
4536
|
+
var AlignmentValidator = z.object({
|
|
4537
|
+
type: z.string().array().nonempty(),
|
|
4538
|
+
targetCode: z.string().optional(),
|
|
4539
|
+
targetDescription: z.string().optional(),
|
|
4540
|
+
targetName: z.string(),
|
|
4541
|
+
targetFramework: z.string().optional(),
|
|
3710
4542
|
targetType: AlignmentTargetTypeValidator.optional(),
|
|
3711
|
-
targetUrl:
|
|
4543
|
+
targetUrl: z.string()
|
|
3712
4544
|
});
|
|
3713
|
-
var KnownAchievementTypeValidator =
|
|
4545
|
+
var KnownAchievementTypeValidator = z.enum([
|
|
3714
4546
|
"Achievement",
|
|
3715
4547
|
"ApprenticeshipCertificate",
|
|
3716
4548
|
"Assessment",
|
|
@@ -3743,23 +4575,23 @@ var KnownAchievementTypeValidator = mod.enum([
|
|
|
3743
4575
|
"ResearchDoctorate",
|
|
3744
4576
|
"SecondarySchoolDiploma"
|
|
3745
4577
|
]);
|
|
3746
|
-
var AchievementTypeValidator = KnownAchievementTypeValidator.or(
|
|
3747
|
-
var CriteriaValidator =
|
|
3748
|
-
var EndorsementSubjectValidator =
|
|
3749
|
-
id:
|
|
3750
|
-
type:
|
|
3751
|
-
endorsementComment:
|
|
4578
|
+
var AchievementTypeValidator = KnownAchievementTypeValidator.or(z.string());
|
|
4579
|
+
var CriteriaValidator = z.object({ id: z.string().optional(), narrative: z.string().optional() }).catchall(z.any());
|
|
4580
|
+
var EndorsementSubjectValidator = z.object({
|
|
4581
|
+
id: z.string(),
|
|
4582
|
+
type: z.string().array().nonempty(),
|
|
4583
|
+
endorsementComment: z.string().optional()
|
|
3752
4584
|
});
|
|
3753
4585
|
var EndorsementCredentialValidator = UnsignedVCValidator.extend({
|
|
3754
4586
|
credentialSubject: EndorsementSubjectValidator,
|
|
3755
4587
|
proof: ProofValidator.or(ProofValidator.array()).optional()
|
|
3756
4588
|
});
|
|
3757
|
-
var RelatedValidator =
|
|
3758
|
-
id:
|
|
3759
|
-
"@language":
|
|
3760
|
-
version:
|
|
4589
|
+
var RelatedValidator = z.object({
|
|
4590
|
+
id: z.string(),
|
|
4591
|
+
"@language": z.string().optional(),
|
|
4592
|
+
version: z.string().optional()
|
|
3761
4593
|
});
|
|
3762
|
-
var ResultTypeValidator =
|
|
4594
|
+
var ResultTypeValidator = z.enum([
|
|
3763
4595
|
"GradePointAverage",
|
|
3764
4596
|
"LetterGrade",
|
|
3765
4597
|
"Percent",
|
|
@@ -3772,59 +4604,59 @@ var ResultTypeValidator = mod.enum([
|
|
|
3772
4604
|
"RubricScore",
|
|
3773
4605
|
"ScaledScore",
|
|
3774
4606
|
"Status"
|
|
3775
|
-
]).or(
|
|
3776
|
-
var RubricCriterionValidator =
|
|
3777
|
-
id:
|
|
3778
|
-
type:
|
|
4607
|
+
]).or(z.string());
|
|
4608
|
+
var RubricCriterionValidator = z.object({
|
|
4609
|
+
id: z.string(),
|
|
4610
|
+
type: z.string().array().nonempty(),
|
|
3779
4611
|
alignment: AlignmentValidator.array().optional(),
|
|
3780
|
-
description:
|
|
3781
|
-
level:
|
|
3782
|
-
name:
|
|
3783
|
-
points:
|
|
3784
|
-
}).catchall(
|
|
3785
|
-
var ResultDescriptionValidator =
|
|
3786
|
-
id:
|
|
3787
|
-
type:
|
|
4612
|
+
description: z.string().optional(),
|
|
4613
|
+
level: z.string().optional(),
|
|
4614
|
+
name: z.string(),
|
|
4615
|
+
points: z.string().optional()
|
|
4616
|
+
}).catchall(z.any());
|
|
4617
|
+
var ResultDescriptionValidator = z.object({
|
|
4618
|
+
id: z.string(),
|
|
4619
|
+
type: z.string().array().nonempty(),
|
|
3788
4620
|
alignment: AlignmentValidator.array().optional(),
|
|
3789
|
-
allowedValue:
|
|
3790
|
-
name:
|
|
3791
|
-
requiredLevel:
|
|
3792
|
-
requiredValue:
|
|
4621
|
+
allowedValue: z.string().array().optional(),
|
|
4622
|
+
name: z.string(),
|
|
4623
|
+
requiredLevel: z.string().optional(),
|
|
4624
|
+
requiredValue: z.string().optional(),
|
|
3793
4625
|
resultType: ResultTypeValidator,
|
|
3794
4626
|
rubricCriterionLevel: RubricCriterionValidator.array().optional(),
|
|
3795
|
-
valueMax:
|
|
3796
|
-
valueMin:
|
|
3797
|
-
}).catchall(
|
|
3798
|
-
var AchievementValidator =
|
|
3799
|
-
id:
|
|
3800
|
-
type:
|
|
4627
|
+
valueMax: z.string().optional(),
|
|
4628
|
+
valueMin: z.string().optional()
|
|
4629
|
+
}).catchall(z.any());
|
|
4630
|
+
var AchievementValidator = z.object({
|
|
4631
|
+
id: z.string().optional(),
|
|
4632
|
+
type: z.string().array().nonempty(),
|
|
3801
4633
|
alignment: AlignmentValidator.array().optional(),
|
|
3802
4634
|
achievementType: AchievementTypeValidator.optional(),
|
|
3803
4635
|
creator: ProfileValidator.optional(),
|
|
3804
|
-
creditsAvailable:
|
|
4636
|
+
creditsAvailable: z.number().optional(),
|
|
3805
4637
|
criteria: CriteriaValidator,
|
|
3806
|
-
description:
|
|
4638
|
+
description: z.string(),
|
|
3807
4639
|
endorsement: EndorsementCredentialValidator.array().optional(),
|
|
3808
|
-
fieldOfStudy:
|
|
3809
|
-
humanCode:
|
|
4640
|
+
fieldOfStudy: z.string().optional(),
|
|
4641
|
+
humanCode: z.string().optional(),
|
|
3810
4642
|
image: ImageValidator.optional(),
|
|
3811
|
-
"@language":
|
|
3812
|
-
name:
|
|
4643
|
+
"@language": z.string().optional(),
|
|
4644
|
+
name: z.string(),
|
|
3813
4645
|
otherIdentifier: IdentifierEntryValidator.array().optional(),
|
|
3814
4646
|
related: RelatedValidator.array().optional(),
|
|
3815
4647
|
resultDescription: ResultDescriptionValidator.array().optional(),
|
|
3816
|
-
specialization:
|
|
3817
|
-
tag:
|
|
3818
|
-
version:
|
|
3819
|
-
}).catchall(
|
|
3820
|
-
var IdentityObjectValidator =
|
|
3821
|
-
type:
|
|
3822
|
-
hashed:
|
|
3823
|
-
identityHash:
|
|
3824
|
-
identityType:
|
|
3825
|
-
salt:
|
|
4648
|
+
specialization: z.string().optional(),
|
|
4649
|
+
tag: z.string().array().optional(),
|
|
4650
|
+
version: z.string().optional()
|
|
4651
|
+
}).catchall(z.any());
|
|
4652
|
+
var IdentityObjectValidator = z.object({
|
|
4653
|
+
type: z.string(),
|
|
4654
|
+
hashed: z.boolean(),
|
|
4655
|
+
identityHash: z.string(),
|
|
4656
|
+
identityType: z.string(),
|
|
4657
|
+
salt: z.string().optional()
|
|
3826
4658
|
});
|
|
3827
|
-
var ResultStatusTypeValidator =
|
|
4659
|
+
var ResultStatusTypeValidator = z.enum([
|
|
3828
4660
|
"Completed",
|
|
3829
4661
|
"Enrolled",
|
|
3830
4662
|
"Failed",
|
|
@@ -3832,42 +4664,42 @@ var ResultStatusTypeValidator = mod.enum([
|
|
|
3832
4664
|
"OnHold",
|
|
3833
4665
|
"Withdrew"
|
|
3834
4666
|
]);
|
|
3835
|
-
var ResultValidator =
|
|
3836
|
-
type:
|
|
3837
|
-
achievedLevel:
|
|
4667
|
+
var ResultValidator = z.object({
|
|
4668
|
+
type: z.string().array().nonempty(),
|
|
4669
|
+
achievedLevel: z.string().optional(),
|
|
3838
4670
|
alignment: AlignmentValidator.array().optional(),
|
|
3839
|
-
resultDescription:
|
|
4671
|
+
resultDescription: z.string().optional(),
|
|
3840
4672
|
status: ResultStatusTypeValidator.optional(),
|
|
3841
|
-
value:
|
|
3842
|
-
}).catchall(
|
|
3843
|
-
var AchievementSubjectValidator =
|
|
3844
|
-
id:
|
|
3845
|
-
type:
|
|
3846
|
-
activityEndDate:
|
|
3847
|
-
activityStartDate:
|
|
3848
|
-
creditsEarned:
|
|
4673
|
+
value: z.string().optional()
|
|
4674
|
+
}).catchall(z.any());
|
|
4675
|
+
var AchievementSubjectValidator = z.object({
|
|
4676
|
+
id: z.string().optional(),
|
|
4677
|
+
type: z.string().array().nonempty(),
|
|
4678
|
+
activityEndDate: z.string().optional(),
|
|
4679
|
+
activityStartDate: z.string().optional(),
|
|
4680
|
+
creditsEarned: z.number().optional(),
|
|
3849
4681
|
achievement: AchievementValidator.optional(),
|
|
3850
4682
|
identifier: IdentityObjectValidator.array().optional(),
|
|
3851
4683
|
image: ImageValidator.optional(),
|
|
3852
|
-
licenseNumber:
|
|
3853
|
-
narrative:
|
|
4684
|
+
licenseNumber: z.string().optional(),
|
|
4685
|
+
narrative: z.string().optional(),
|
|
3854
4686
|
result: ResultValidator.array().optional(),
|
|
3855
|
-
role:
|
|
4687
|
+
role: z.string().optional(),
|
|
3856
4688
|
source: ProfileValidator.optional(),
|
|
3857
|
-
term:
|
|
3858
|
-
}).catchall(
|
|
3859
|
-
var EvidenceValidator =
|
|
3860
|
-
id:
|
|
3861
|
-
type:
|
|
3862
|
-
narrative:
|
|
3863
|
-
name:
|
|
3864
|
-
description:
|
|
3865
|
-
genre:
|
|
3866
|
-
audience:
|
|
3867
|
-
}).catchall(
|
|
4689
|
+
term: z.string().optional()
|
|
4690
|
+
}).catchall(z.any());
|
|
4691
|
+
var EvidenceValidator = z.object({
|
|
4692
|
+
id: z.string().optional(),
|
|
4693
|
+
type: z.string().or(z.string().array().nonempty()),
|
|
4694
|
+
narrative: z.string().optional(),
|
|
4695
|
+
name: z.string().optional(),
|
|
4696
|
+
description: z.string().optional(),
|
|
4697
|
+
genre: z.string().optional(),
|
|
4698
|
+
audience: z.string().optional()
|
|
4699
|
+
}).catchall(z.any());
|
|
3868
4700
|
var UnsignedAchievementCredentialValidator = UnsignedVCValidator.extend({
|
|
3869
|
-
name:
|
|
3870
|
-
description:
|
|
4701
|
+
name: z.string().optional(),
|
|
4702
|
+
description: z.string().optional(),
|
|
3871
4703
|
image: ImageValidator.optional(),
|
|
3872
4704
|
credentialSubject: AchievementSubjectValidator.or(
|
|
3873
4705
|
AchievementSubjectValidator.array()
|
|
@@ -3878,42 +4710,42 @@ var UnsignedAchievementCredentialValidator = UnsignedVCValidator.extend({
|
|
|
3878
4710
|
UnsignedAchievementCredentialValidator.extend({
|
|
3879
4711
|
proof: ProofValidator.or(ProofValidator.array())
|
|
3880
4712
|
});
|
|
3881
|
-
|
|
3882
|
-
checks:
|
|
3883
|
-
warnings:
|
|
3884
|
-
errors:
|
|
4713
|
+
z.object({
|
|
4714
|
+
checks: z.string().array(),
|
|
4715
|
+
warnings: z.string().array(),
|
|
4716
|
+
errors: z.string().array()
|
|
3885
4717
|
});
|
|
3886
|
-
var VerificationStatusValidator =
|
|
4718
|
+
var VerificationStatusValidator = z.enum(["Success", "Failed", "Error"]);
|
|
3887
4719
|
var VerificationStatusEnum = VerificationStatusValidator.enum;
|
|
3888
|
-
|
|
3889
|
-
check:
|
|
4720
|
+
z.object({
|
|
4721
|
+
check: z.string(),
|
|
3890
4722
|
status: VerificationStatusValidator,
|
|
3891
|
-
message:
|
|
3892
|
-
details:
|
|
4723
|
+
message: z.string().optional(),
|
|
4724
|
+
details: z.string().optional()
|
|
3893
4725
|
});
|
|
3894
|
-
|
|
3895
|
-
title:
|
|
3896
|
-
createdAt:
|
|
4726
|
+
z.object({
|
|
4727
|
+
title: z.string().optional(),
|
|
4728
|
+
createdAt: z.string().optional(),
|
|
3897
4729
|
issuer: ProfileValidator.optional(),
|
|
3898
4730
|
issuee: ProfileValidator.optional(),
|
|
3899
4731
|
credentialSubject: CredentialSubjectValidator.optional()
|
|
3900
4732
|
});
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
limit:
|
|
3904
|
-
cursor:
|
|
3905
|
-
sort:
|
|
4733
|
+
z.object({ id: z.string(), uri: z.string() }).catchall(z.any());
|
|
4734
|
+
z.object({
|
|
4735
|
+
limit: z.number(),
|
|
4736
|
+
cursor: z.string().optional(),
|
|
4737
|
+
sort: z.string().optional()
|
|
3906
4738
|
});
|
|
3907
|
-
var PaginationResponseValidator =
|
|
3908
|
-
cursor:
|
|
3909
|
-
hasMore:
|
|
4739
|
+
var PaginationResponseValidator = z.object({
|
|
4740
|
+
cursor: z.string().optional(),
|
|
4741
|
+
hasMore: z.boolean()
|
|
3910
4742
|
});
|
|
3911
|
-
var EncryptedRecordValidator =
|
|
4743
|
+
var EncryptedRecordValidator = z.object({ encryptedRecord: JWEValidator, fields: z.string().array() }).catchall(z.any());
|
|
3912
4744
|
PaginationResponseValidator.extend({
|
|
3913
4745
|
records: EncryptedRecordValidator.array()
|
|
3914
4746
|
});
|
|
3915
4747
|
var EncryptedCredentialRecordValidator = EncryptedRecordValidator.extend({
|
|
3916
|
-
id:
|
|
4748
|
+
id: z.string()
|
|
3917
4749
|
});
|
|
3918
4750
|
PaginationResponseValidator.extend({
|
|
3919
4751
|
records: EncryptedCredentialRecordValidator.array()
|
|
@@ -3924,8 +4756,8 @@ var parseRegexString = /* @__PURE__ */ __name((regexStr) => {
|
|
|
3924
4756
|
throw new Error("Invalid RegExp string format");
|
|
3925
4757
|
return { pattern: match[1], flags: match[2] };
|
|
3926
4758
|
}, "parseRegexString");
|
|
3927
|
-
var RegExpValidator =
|
|
3928
|
-
|
|
4759
|
+
var RegExpValidator = z.instanceof(RegExp).or(
|
|
4760
|
+
z.string().refine(
|
|
3929
4761
|
(str) => {
|
|
3930
4762
|
try {
|
|
3931
4763
|
parseRegexString(str);
|
|
@@ -3946,71 +4778,71 @@ var RegExpValidator = mod.instanceof(RegExp).or(
|
|
|
3946
4778
|
}
|
|
3947
4779
|
})
|
|
3948
4780
|
);
|
|
3949
|
-
var StringQuery =
|
|
3950
|
-
var LCNProfileDisplayValidator =
|
|
3951
|
-
backgroundColor:
|
|
3952
|
-
backgroundImage:
|
|
3953
|
-
fadeBackgroundImage:
|
|
3954
|
-
repeatBackgroundImage:
|
|
3955
|
-
fontColor:
|
|
3956
|
-
accentColor:
|
|
3957
|
-
accentFontColor:
|
|
3958
|
-
idBackgroundImage:
|
|
3959
|
-
fadeIdBackgroundImage:
|
|
3960
|
-
idBackgroundColor:
|
|
3961
|
-
repeatIdBackgroundImage:
|
|
4781
|
+
var StringQuery = z.string().or(z.object({ $in: z.string().array() })).or(z.object({ $regex: RegExpValidator }));
|
|
4782
|
+
var LCNProfileDisplayValidator = z.object({
|
|
4783
|
+
backgroundColor: z.string().optional(),
|
|
4784
|
+
backgroundImage: z.string().optional(),
|
|
4785
|
+
fadeBackgroundImage: z.boolean().optional(),
|
|
4786
|
+
repeatBackgroundImage: z.boolean().optional(),
|
|
4787
|
+
fontColor: z.string().optional(),
|
|
4788
|
+
accentColor: z.string().optional(),
|
|
4789
|
+
accentFontColor: z.string().optional(),
|
|
4790
|
+
idBackgroundImage: z.string().optional(),
|
|
4791
|
+
fadeIdBackgroundImage: z.boolean().optional(),
|
|
4792
|
+
idBackgroundColor: z.string().optional(),
|
|
4793
|
+
repeatIdBackgroundImage: z.boolean().optional()
|
|
3962
4794
|
});
|
|
3963
|
-
var LCNProfileValidator =
|
|
3964
|
-
profileId:
|
|
3965
|
-
displayName:
|
|
3966
|
-
shortBio:
|
|
3967
|
-
bio:
|
|
3968
|
-
did:
|
|
3969
|
-
isPrivate:
|
|
3970
|
-
email:
|
|
3971
|
-
image:
|
|
3972
|
-
heroImage:
|
|
3973
|
-
websiteLink:
|
|
3974
|
-
isServiceProfile:
|
|
3975
|
-
type:
|
|
3976
|
-
notificationsWebhook:
|
|
4795
|
+
var LCNProfileValidator = z.object({
|
|
4796
|
+
profileId: z.string().min(3).max(40).describe("Unique, URL-safe identifier for the profile."),
|
|
4797
|
+
displayName: z.string().default("").describe("Human-readable display name for the profile."),
|
|
4798
|
+
shortBio: z.string().default("").describe("Short bio for the profile."),
|
|
4799
|
+
bio: z.string().default("").describe("Longer bio for the profile."),
|
|
4800
|
+
did: z.string().describe("Decentralized Identifier for the profile. (auto-assigned)"),
|
|
4801
|
+
isPrivate: z.boolean().optional().describe("Whether the profile is private or not and shows up in search results."),
|
|
4802
|
+
email: z.string().optional().describe("Contact email address for the profile."),
|
|
4803
|
+
image: z.string().optional().describe("Profile image URL for the profile."),
|
|
4804
|
+
heroImage: z.string().optional().describe("Hero image URL for the profile."),
|
|
4805
|
+
websiteLink: z.string().optional().describe("Website link for the profile."),
|
|
4806
|
+
isServiceProfile: z.boolean().default(false).optional().describe("Whether the profile is a service profile or not."),
|
|
4807
|
+
type: z.string().optional().describe('Profile type: e.g. "person", "organization", "service".'),
|
|
4808
|
+
notificationsWebhook: z.string().url().startsWith("http").optional().describe("URL to send notifications to."),
|
|
3977
4809
|
display: LCNProfileDisplayValidator.optional().describe("Display settings for the profile."),
|
|
3978
|
-
role:
|
|
3979
|
-
dob:
|
|
4810
|
+
role: z.string().default("").optional().describe('Role of the profile: e.g. "teacher", "student".'),
|
|
4811
|
+
dob: z.string().default("").optional().describe('Date of birth of the profile: e.g. "1990-01-01".')
|
|
3980
4812
|
});
|
|
3981
|
-
|
|
4813
|
+
z.object({
|
|
3982
4814
|
profileId: StringQuery,
|
|
3983
4815
|
displayName: StringQuery,
|
|
3984
4816
|
shortBio: StringQuery,
|
|
3985
4817
|
bio: StringQuery,
|
|
3986
4818
|
email: StringQuery,
|
|
3987
4819
|
websiteLink: StringQuery,
|
|
3988
|
-
isServiceProfile:
|
|
4820
|
+
isServiceProfile: z.boolean(),
|
|
3989
4821
|
type: StringQuery
|
|
3990
4822
|
}).partial();
|
|
3991
4823
|
PaginationResponseValidator.extend({
|
|
3992
4824
|
records: LCNProfileValidator.array()
|
|
3993
4825
|
});
|
|
3994
|
-
|
|
4826
|
+
z.enum([
|
|
3995
4827
|
"CONNECTED",
|
|
3996
4828
|
"PENDING_REQUEST_SENT",
|
|
3997
4829
|
"PENDING_REQUEST_RECEIVED",
|
|
3998
4830
|
"NOT_CONNECTED"
|
|
3999
4831
|
]);
|
|
4000
|
-
var LCNProfileManagerValidator =
|
|
4001
|
-
id:
|
|
4002
|
-
created:
|
|
4003
|
-
displayName:
|
|
4004
|
-
shortBio:
|
|
4005
|
-
bio:
|
|
4006
|
-
email:
|
|
4007
|
-
image:
|
|
4008
|
-
heroImage:
|
|
4832
|
+
var LCNProfileManagerValidator = z.object({
|
|
4833
|
+
id: z.string(),
|
|
4834
|
+
created: z.string(),
|
|
4835
|
+
displayName: z.string().default("").optional(),
|
|
4836
|
+
shortBio: z.string().default("").optional(),
|
|
4837
|
+
bio: z.string().default("").optional(),
|
|
4838
|
+
email: z.string().optional(),
|
|
4839
|
+
image: z.string().optional(),
|
|
4840
|
+
heroImage: z.string().optional()
|
|
4009
4841
|
});
|
|
4010
4842
|
PaginationResponseValidator.extend({
|
|
4011
|
-
records: LCNProfileManagerValidator.extend({ did:
|
|
4843
|
+
records: LCNProfileManagerValidator.extend({ did: z.string() }).array()
|
|
4012
4844
|
});
|
|
4013
|
-
|
|
4845
|
+
z.object({
|
|
4014
4846
|
id: StringQuery,
|
|
4015
4847
|
displayName: StringQuery,
|
|
4016
4848
|
shortBio: StringQuery,
|
|
@@ -4018,296 +4850,296 @@ mod.object({
|
|
|
4018
4850
|
email: StringQuery
|
|
4019
4851
|
}).partial();
|
|
4020
4852
|
PaginationResponseValidator.extend({
|
|
4021
|
-
records:
|
|
4853
|
+
records: z.object({
|
|
4022
4854
|
profile: LCNProfileValidator,
|
|
4023
|
-
manager: LCNProfileManagerValidator.extend({ did:
|
|
4855
|
+
manager: LCNProfileManagerValidator.extend({ did: z.string() }).optional()
|
|
4024
4856
|
}).array()
|
|
4025
4857
|
});
|
|
4026
|
-
|
|
4027
|
-
uri:
|
|
4028
|
-
to:
|
|
4029
|
-
from:
|
|
4030
|
-
sent:
|
|
4031
|
-
received:
|
|
4858
|
+
z.object({
|
|
4859
|
+
uri: z.string(),
|
|
4860
|
+
to: z.string(),
|
|
4861
|
+
from: z.string(),
|
|
4862
|
+
sent: z.string().datetime(),
|
|
4863
|
+
received: z.string().datetime().optional()
|
|
4032
4864
|
});
|
|
4033
|
-
var BoostPermissionsValidator =
|
|
4034
|
-
role:
|
|
4035
|
-
canEdit:
|
|
4036
|
-
canIssue:
|
|
4037
|
-
canRevoke:
|
|
4038
|
-
canManagePermissions:
|
|
4039
|
-
canIssueChildren:
|
|
4040
|
-
canCreateChildren:
|
|
4041
|
-
canEditChildren:
|
|
4042
|
-
canRevokeChildren:
|
|
4043
|
-
canManageChildrenPermissions:
|
|
4044
|
-
canManageChildrenProfiles:
|
|
4045
|
-
canViewAnalytics:
|
|
4865
|
+
var BoostPermissionsValidator = z.object({
|
|
4866
|
+
role: z.string(),
|
|
4867
|
+
canEdit: z.boolean(),
|
|
4868
|
+
canIssue: z.boolean(),
|
|
4869
|
+
canRevoke: z.boolean(),
|
|
4870
|
+
canManagePermissions: z.boolean(),
|
|
4871
|
+
canIssueChildren: z.string(),
|
|
4872
|
+
canCreateChildren: z.string(),
|
|
4873
|
+
canEditChildren: z.string(),
|
|
4874
|
+
canRevokeChildren: z.string(),
|
|
4875
|
+
canManageChildrenPermissions: z.string(),
|
|
4876
|
+
canManageChildrenProfiles: z.boolean().default(false).optional(),
|
|
4877
|
+
canViewAnalytics: z.boolean()
|
|
4046
4878
|
});
|
|
4047
|
-
var BoostPermissionsQueryValidator =
|
|
4879
|
+
var BoostPermissionsQueryValidator = z.object({
|
|
4048
4880
|
role: StringQuery,
|
|
4049
|
-
canEdit:
|
|
4050
|
-
canIssue:
|
|
4051
|
-
canRevoke:
|
|
4052
|
-
canManagePermissions:
|
|
4881
|
+
canEdit: z.boolean(),
|
|
4882
|
+
canIssue: z.boolean(),
|
|
4883
|
+
canRevoke: z.boolean(),
|
|
4884
|
+
canManagePermissions: z.boolean(),
|
|
4053
4885
|
canIssueChildren: StringQuery,
|
|
4054
4886
|
canCreateChildren: StringQuery,
|
|
4055
4887
|
canEditChildren: StringQuery,
|
|
4056
4888
|
canRevokeChildren: StringQuery,
|
|
4057
4889
|
canManageChildrenPermissions: StringQuery,
|
|
4058
|
-
canManageChildrenProfiles:
|
|
4059
|
-
canViewAnalytics:
|
|
4890
|
+
canManageChildrenProfiles: z.boolean(),
|
|
4891
|
+
canViewAnalytics: z.boolean()
|
|
4060
4892
|
}).partial();
|
|
4061
|
-
var ClaimHookTypeValidator =
|
|
4062
|
-
var ClaimHookValidator =
|
|
4063
|
-
|
|
4064
|
-
type:
|
|
4065
|
-
data:
|
|
4066
|
-
claimUri:
|
|
4067
|
-
targetUri:
|
|
4893
|
+
var ClaimHookTypeValidator = z.enum(["GRANT_PERMISSIONS", "ADD_ADMIN"]);
|
|
4894
|
+
var ClaimHookValidator = z.discriminatedUnion("type", [
|
|
4895
|
+
z.object({
|
|
4896
|
+
type: z.literal(ClaimHookTypeValidator.Values.GRANT_PERMISSIONS),
|
|
4897
|
+
data: z.object({
|
|
4898
|
+
claimUri: z.string(),
|
|
4899
|
+
targetUri: z.string(),
|
|
4068
4900
|
permissions: BoostPermissionsValidator.partial()
|
|
4069
4901
|
})
|
|
4070
4902
|
}),
|
|
4071
|
-
|
|
4072
|
-
type:
|
|
4073
|
-
data:
|
|
4903
|
+
z.object({
|
|
4904
|
+
type: z.literal(ClaimHookTypeValidator.Values.ADD_ADMIN),
|
|
4905
|
+
data: z.object({ claimUri: z.string(), targetUri: z.string() })
|
|
4074
4906
|
})
|
|
4075
4907
|
]);
|
|
4076
|
-
|
|
4908
|
+
z.object({
|
|
4077
4909
|
type: StringQuery,
|
|
4078
|
-
data:
|
|
4910
|
+
data: z.object({
|
|
4079
4911
|
claimUri: StringQuery,
|
|
4080
4912
|
targetUri: StringQuery,
|
|
4081
4913
|
permissions: BoostPermissionsQueryValidator
|
|
4082
4914
|
})
|
|
4083
4915
|
}).deepPartial();
|
|
4084
|
-
var FullClaimHookValidator =
|
|
4916
|
+
var FullClaimHookValidator = z.object({ id: z.string(), createdAt: z.string(), updatedAt: z.string() }).and(ClaimHookValidator);
|
|
4085
4917
|
PaginationResponseValidator.extend({
|
|
4086
4918
|
records: FullClaimHookValidator.array()
|
|
4087
4919
|
});
|
|
4088
|
-
var LCNBoostStatus =
|
|
4089
|
-
var BoostValidator =
|
|
4090
|
-
uri:
|
|
4091
|
-
name:
|
|
4092
|
-
type:
|
|
4093
|
-
category:
|
|
4920
|
+
var LCNBoostStatus = z.enum(["DRAFT", "LIVE"]);
|
|
4921
|
+
var BoostValidator = z.object({
|
|
4922
|
+
uri: z.string(),
|
|
4923
|
+
name: z.string().optional(),
|
|
4924
|
+
type: z.string().optional(),
|
|
4925
|
+
category: z.string().optional(),
|
|
4094
4926
|
status: LCNBoostStatus.optional(),
|
|
4095
|
-
autoConnectRecipients:
|
|
4096
|
-
meta:
|
|
4927
|
+
autoConnectRecipients: z.boolean().optional(),
|
|
4928
|
+
meta: z.record(z.any()).optional(),
|
|
4097
4929
|
claimPermissions: BoostPermissionsValidator.optional()
|
|
4098
4930
|
});
|
|
4099
|
-
|
|
4931
|
+
z.object({
|
|
4100
4932
|
uri: StringQuery,
|
|
4101
4933
|
name: StringQuery,
|
|
4102
4934
|
type: StringQuery,
|
|
4103
4935
|
category: StringQuery,
|
|
4104
|
-
meta:
|
|
4105
|
-
status: LCNBoostStatus.or(
|
|
4106
|
-
autoConnectRecipients:
|
|
4936
|
+
meta: z.record(StringQuery),
|
|
4937
|
+
status: LCNBoostStatus.or(z.object({ $in: LCNBoostStatus.array() })),
|
|
4938
|
+
autoConnectRecipients: z.boolean()
|
|
4107
4939
|
}).partial();
|
|
4108
4940
|
PaginationResponseValidator.extend({
|
|
4109
4941
|
records: BoostValidator.array()
|
|
4110
4942
|
});
|
|
4111
|
-
var BoostRecipientValidator =
|
|
4943
|
+
var BoostRecipientValidator = z.object({
|
|
4112
4944
|
to: LCNProfileValidator,
|
|
4113
|
-
from:
|
|
4114
|
-
received:
|
|
4115
|
-
uri:
|
|
4945
|
+
from: z.string(),
|
|
4946
|
+
received: z.string().optional(),
|
|
4947
|
+
uri: z.string().optional()
|
|
4116
4948
|
});
|
|
4117
4949
|
PaginationResponseValidator.extend({
|
|
4118
4950
|
records: BoostRecipientValidator.array()
|
|
4119
4951
|
});
|
|
4120
|
-
|
|
4121
|
-
endpoint:
|
|
4122
|
-
name:
|
|
4123
|
-
did:
|
|
4952
|
+
z.object({
|
|
4953
|
+
endpoint: z.string(),
|
|
4954
|
+
name: z.string(),
|
|
4955
|
+
did: z.string().optional()
|
|
4124
4956
|
});
|
|
4125
|
-
|
|
4126
|
-
ttlSeconds:
|
|
4127
|
-
totalUses:
|
|
4957
|
+
z.object({
|
|
4958
|
+
ttlSeconds: z.number().optional(),
|
|
4959
|
+
totalUses: z.number().optional()
|
|
4128
4960
|
});
|
|
4129
|
-
var LCNSigningAuthorityValidator =
|
|
4130
|
-
endpoint:
|
|
4961
|
+
var LCNSigningAuthorityValidator = z.object({
|
|
4962
|
+
endpoint: z.string()
|
|
4131
4963
|
});
|
|
4132
|
-
|
|
4964
|
+
z.object({
|
|
4133
4965
|
signingAuthority: LCNSigningAuthorityValidator,
|
|
4134
|
-
relationship:
|
|
4135
|
-
name:
|
|
4966
|
+
relationship: z.object({
|
|
4967
|
+
name: z.string().max(15).regex(/^[a-z0-9-]+$/, {
|
|
4136
4968
|
message: "The input string must contain only lowercase letters, numbers, and hyphens."
|
|
4137
4969
|
}),
|
|
4138
|
-
did:
|
|
4970
|
+
did: z.string()
|
|
4139
4971
|
})
|
|
4140
4972
|
});
|
|
4141
|
-
|
|
4142
|
-
boostUri:
|
|
4143
|
-
signingAuthority:
|
|
4144
|
-
endpoint:
|
|
4145
|
-
name:
|
|
4973
|
+
z.object({
|
|
4974
|
+
boostUri: z.string(),
|
|
4975
|
+
signingAuthority: z.object({
|
|
4976
|
+
endpoint: z.string(),
|
|
4977
|
+
name: z.string()
|
|
4146
4978
|
})
|
|
4147
4979
|
});
|
|
4148
|
-
var ConsentFlowTermsStatusValidator =
|
|
4149
|
-
var ConsentFlowContractValidator =
|
|
4150
|
-
read:
|
|
4151
|
-
anonymize:
|
|
4152
|
-
credentials:
|
|
4153
|
-
personal:
|
|
4980
|
+
var ConsentFlowTermsStatusValidator = z.enum(["live", "stale", "withdrawn"]);
|
|
4981
|
+
var ConsentFlowContractValidator = z.object({
|
|
4982
|
+
read: z.object({
|
|
4983
|
+
anonymize: z.boolean().optional(),
|
|
4984
|
+
credentials: z.object({ categories: z.record(z.object({ required: z.boolean() })).default({}) }).default({}),
|
|
4985
|
+
personal: z.record(z.object({ required: z.boolean() })).default({})
|
|
4154
4986
|
}).default({}),
|
|
4155
|
-
write:
|
|
4156
|
-
credentials:
|
|
4157
|
-
personal:
|
|
4987
|
+
write: z.object({
|
|
4988
|
+
credentials: z.object({ categories: z.record(z.object({ required: z.boolean() })).default({}) }).default({}),
|
|
4989
|
+
personal: z.record(z.object({ required: z.boolean() })).default({})
|
|
4158
4990
|
}).default({})
|
|
4159
4991
|
});
|
|
4160
|
-
var ConsentFlowContractDetailsValidator =
|
|
4992
|
+
var ConsentFlowContractDetailsValidator = z.object({
|
|
4161
4993
|
contract: ConsentFlowContractValidator,
|
|
4162
4994
|
owner: LCNProfileValidator,
|
|
4163
|
-
name:
|
|
4164
|
-
subtitle:
|
|
4165
|
-
description:
|
|
4166
|
-
reasonForAccessing:
|
|
4167
|
-
image:
|
|
4168
|
-
uri:
|
|
4169
|
-
needsGuardianConsent:
|
|
4170
|
-
redirectUrl:
|
|
4171
|
-
frontDoorBoostUri:
|
|
4172
|
-
createdAt:
|
|
4173
|
-
updatedAt:
|
|
4174
|
-
expiresAt:
|
|
4175
|
-
autoBoosts:
|
|
4176
|
-
writers:
|
|
4995
|
+
name: z.string(),
|
|
4996
|
+
subtitle: z.string().optional(),
|
|
4997
|
+
description: z.string().optional(),
|
|
4998
|
+
reasonForAccessing: z.string().optional(),
|
|
4999
|
+
image: z.string().optional(),
|
|
5000
|
+
uri: z.string(),
|
|
5001
|
+
needsGuardianConsent: z.boolean().optional(),
|
|
5002
|
+
redirectUrl: z.string().optional(),
|
|
5003
|
+
frontDoorBoostUri: z.string().optional(),
|
|
5004
|
+
createdAt: z.string(),
|
|
5005
|
+
updatedAt: z.string(),
|
|
5006
|
+
expiresAt: z.string().optional(),
|
|
5007
|
+
autoBoosts: z.string().array().optional(),
|
|
5008
|
+
writers: z.array(LCNProfileValidator).optional()
|
|
4177
5009
|
});
|
|
4178
5010
|
PaginationResponseValidator.extend({
|
|
4179
5011
|
records: ConsentFlowContractDetailsValidator.omit({ owner: true }).array()
|
|
4180
5012
|
});
|
|
4181
|
-
var ConsentFlowContractDataValidator =
|
|
4182
|
-
credentials:
|
|
4183
|
-
personal:
|
|
4184
|
-
date:
|
|
5013
|
+
var ConsentFlowContractDataValidator = z.object({
|
|
5014
|
+
credentials: z.object({ categories: z.record(z.string().array()).default({}) }),
|
|
5015
|
+
personal: z.record(z.string()).default({}),
|
|
5016
|
+
date: z.string()
|
|
4185
5017
|
});
|
|
4186
5018
|
PaginationResponseValidator.extend({
|
|
4187
5019
|
records: ConsentFlowContractDataValidator.array()
|
|
4188
5020
|
});
|
|
4189
|
-
var ConsentFlowContractDataForDidValidator =
|
|
4190
|
-
credentials:
|
|
4191
|
-
personal:
|
|
4192
|
-
date:
|
|
4193
|
-
contractUri:
|
|
5021
|
+
var ConsentFlowContractDataForDidValidator = z.object({
|
|
5022
|
+
credentials: z.object({ category: z.string(), uri: z.string() }).array(),
|
|
5023
|
+
personal: z.record(z.string()).default({}),
|
|
5024
|
+
date: z.string(),
|
|
5025
|
+
contractUri: z.string()
|
|
4194
5026
|
});
|
|
4195
5027
|
PaginationResponseValidator.extend({
|
|
4196
5028
|
records: ConsentFlowContractDataForDidValidator.array()
|
|
4197
5029
|
});
|
|
4198
|
-
var ConsentFlowTermValidator =
|
|
4199
|
-
sharing:
|
|
4200
|
-
shared:
|
|
4201
|
-
shareAll:
|
|
4202
|
-
shareUntil:
|
|
5030
|
+
var ConsentFlowTermValidator = z.object({
|
|
5031
|
+
sharing: z.boolean().optional(),
|
|
5032
|
+
shared: z.string().array().optional(),
|
|
5033
|
+
shareAll: z.boolean().optional(),
|
|
5034
|
+
shareUntil: z.string().optional()
|
|
4203
5035
|
});
|
|
4204
|
-
var ConsentFlowTermsValidator =
|
|
4205
|
-
read:
|
|
4206
|
-
anonymize:
|
|
4207
|
-
credentials:
|
|
4208
|
-
shareAll:
|
|
4209
|
-
sharing:
|
|
4210
|
-
categories:
|
|
5036
|
+
var ConsentFlowTermsValidator = z.object({
|
|
5037
|
+
read: z.object({
|
|
5038
|
+
anonymize: z.boolean().optional(),
|
|
5039
|
+
credentials: z.object({
|
|
5040
|
+
shareAll: z.boolean().optional(),
|
|
5041
|
+
sharing: z.boolean().optional(),
|
|
5042
|
+
categories: z.record(ConsentFlowTermValidator).default({})
|
|
4211
5043
|
}).default({}),
|
|
4212
|
-
personal:
|
|
5044
|
+
personal: z.record(z.string()).default({})
|
|
4213
5045
|
}).default({}),
|
|
4214
|
-
write:
|
|
4215
|
-
credentials:
|
|
4216
|
-
personal:
|
|
5046
|
+
write: z.object({
|
|
5047
|
+
credentials: z.object({ categories: z.record(z.boolean()).default({}) }).default({}),
|
|
5048
|
+
personal: z.record(z.boolean()).default({})
|
|
4217
5049
|
}).default({}),
|
|
4218
|
-
deniedWriters:
|
|
5050
|
+
deniedWriters: z.array(z.string()).optional()
|
|
4219
5051
|
});
|
|
4220
5052
|
PaginationResponseValidator.extend({
|
|
4221
|
-
records:
|
|
4222
|
-
expiresAt:
|
|
4223
|
-
oneTime:
|
|
5053
|
+
records: z.object({
|
|
5054
|
+
expiresAt: z.string().optional(),
|
|
5055
|
+
oneTime: z.boolean().optional(),
|
|
4224
5056
|
terms: ConsentFlowTermsValidator,
|
|
4225
5057
|
contract: ConsentFlowContractDetailsValidator,
|
|
4226
|
-
uri:
|
|
5058
|
+
uri: z.string(),
|
|
4227
5059
|
consenter: LCNProfileValidator,
|
|
4228
5060
|
status: ConsentFlowTermsStatusValidator
|
|
4229
5061
|
}).array()
|
|
4230
5062
|
});
|
|
4231
|
-
|
|
4232
|
-
read:
|
|
4233
|
-
anonymize:
|
|
4234
|
-
credentials:
|
|
4235
|
-
categories:
|
|
5063
|
+
z.object({
|
|
5064
|
+
read: z.object({
|
|
5065
|
+
anonymize: z.boolean().optional(),
|
|
5066
|
+
credentials: z.object({
|
|
5067
|
+
categories: z.record(z.object({ required: z.boolean().optional() })).optional()
|
|
4236
5068
|
}).optional(),
|
|
4237
|
-
personal:
|
|
5069
|
+
personal: z.record(z.object({ required: z.boolean().optional() })).optional()
|
|
4238
5070
|
}).optional(),
|
|
4239
|
-
write:
|
|
4240
|
-
credentials:
|
|
4241
|
-
categories:
|
|
5071
|
+
write: z.object({
|
|
5072
|
+
credentials: z.object({
|
|
5073
|
+
categories: z.record(z.object({ required: z.boolean().optional() })).optional()
|
|
4242
5074
|
}).optional(),
|
|
4243
|
-
personal:
|
|
5075
|
+
personal: z.record(z.object({ required: z.boolean().optional() })).optional()
|
|
4244
5076
|
}).optional()
|
|
4245
5077
|
});
|
|
4246
|
-
|
|
4247
|
-
anonymize:
|
|
4248
|
-
credentials:
|
|
4249
|
-
personal:
|
|
5078
|
+
z.object({
|
|
5079
|
+
anonymize: z.boolean().optional(),
|
|
5080
|
+
credentials: z.object({ categories: z.record(z.boolean()).optional() }).optional(),
|
|
5081
|
+
personal: z.record(z.boolean()).optional()
|
|
4250
5082
|
});
|
|
4251
|
-
|
|
4252
|
-
credentials:
|
|
4253
|
-
personal:
|
|
5083
|
+
z.object({
|
|
5084
|
+
credentials: z.object({ categories: z.record(z.boolean()).optional() }).optional(),
|
|
5085
|
+
personal: z.record(z.boolean()).optional(),
|
|
4254
5086
|
id: StringQuery.optional()
|
|
4255
5087
|
});
|
|
4256
|
-
var ConsentFlowTermsQueryValidator =
|
|
4257
|
-
read:
|
|
4258
|
-
anonymize:
|
|
4259
|
-
credentials:
|
|
4260
|
-
shareAll:
|
|
4261
|
-
sharing:
|
|
4262
|
-
categories:
|
|
5088
|
+
var ConsentFlowTermsQueryValidator = z.object({
|
|
5089
|
+
read: z.object({
|
|
5090
|
+
anonymize: z.boolean().optional(),
|
|
5091
|
+
credentials: z.object({
|
|
5092
|
+
shareAll: z.boolean().optional(),
|
|
5093
|
+
sharing: z.boolean().optional(),
|
|
5094
|
+
categories: z.record(ConsentFlowTermValidator.optional()).optional()
|
|
4263
5095
|
}).optional(),
|
|
4264
|
-
personal:
|
|
5096
|
+
personal: z.record(z.string()).optional()
|
|
4265
5097
|
}).optional(),
|
|
4266
|
-
write:
|
|
4267
|
-
credentials:
|
|
4268
|
-
personal:
|
|
5098
|
+
write: z.object({
|
|
5099
|
+
credentials: z.object({ categories: z.record(z.boolean()).optional() }).optional(),
|
|
5100
|
+
personal: z.record(z.boolean()).optional()
|
|
4269
5101
|
}).optional()
|
|
4270
5102
|
});
|
|
4271
|
-
var ConsentFlowTransactionActionValidator =
|
|
5103
|
+
var ConsentFlowTransactionActionValidator = z.enum([
|
|
4272
5104
|
"consent",
|
|
4273
5105
|
"update",
|
|
4274
5106
|
"sync",
|
|
4275
5107
|
"withdraw",
|
|
4276
5108
|
"write"
|
|
4277
5109
|
]);
|
|
4278
|
-
|
|
5110
|
+
z.object({
|
|
4279
5111
|
terms: ConsentFlowTermsQueryValidator.optional(),
|
|
4280
5112
|
action: ConsentFlowTransactionActionValidator.or(
|
|
4281
5113
|
ConsentFlowTransactionActionValidator.array()
|
|
4282
5114
|
).optional(),
|
|
4283
|
-
date:
|
|
4284
|
-
expiresAt:
|
|
4285
|
-
oneTime:
|
|
5115
|
+
date: z.object({ $gt: z.string() }).or(z.object({ $lt: z.string() })).or(z.object({ $eq: z.string() })).optional(),
|
|
5116
|
+
expiresAt: z.object({ $gt: z.string() }).or(z.object({ $lt: z.string() })).or(z.object({ $eq: z.string() })).optional(),
|
|
5117
|
+
oneTime: z.boolean().optional()
|
|
4286
5118
|
});
|
|
4287
|
-
var ConsentFlowTransactionValidator =
|
|
4288
|
-
expiresAt:
|
|
4289
|
-
oneTime:
|
|
5119
|
+
var ConsentFlowTransactionValidator = z.object({
|
|
5120
|
+
expiresAt: z.string().optional(),
|
|
5121
|
+
oneTime: z.boolean().optional(),
|
|
4290
5122
|
terms: ConsentFlowTermsValidator.optional(),
|
|
4291
|
-
id:
|
|
5123
|
+
id: z.string(),
|
|
4292
5124
|
action: ConsentFlowTransactionActionValidator,
|
|
4293
|
-
date:
|
|
4294
|
-
uris:
|
|
5125
|
+
date: z.string(),
|
|
5126
|
+
uris: z.string().array().optional()
|
|
4295
5127
|
});
|
|
4296
5128
|
PaginationResponseValidator.extend({
|
|
4297
5129
|
records: ConsentFlowTransactionValidator.array()
|
|
4298
5130
|
});
|
|
4299
|
-
var ContractCredentialValidator =
|
|
4300
|
-
credentialUri:
|
|
4301
|
-
termsUri:
|
|
4302
|
-
contractUri:
|
|
4303
|
-
boostUri:
|
|
4304
|
-
category:
|
|
4305
|
-
date:
|
|
5131
|
+
var ContractCredentialValidator = z.object({
|
|
5132
|
+
credentialUri: z.string(),
|
|
5133
|
+
termsUri: z.string(),
|
|
5134
|
+
contractUri: z.string(),
|
|
5135
|
+
boostUri: z.string(),
|
|
5136
|
+
category: z.string().optional(),
|
|
5137
|
+
date: z.string()
|
|
4306
5138
|
});
|
|
4307
5139
|
PaginationResponseValidator.extend({
|
|
4308
5140
|
records: ContractCredentialValidator.array()
|
|
4309
5141
|
});
|
|
4310
|
-
var LCNNotificationTypeEnumValidator =
|
|
5142
|
+
var LCNNotificationTypeEnumValidator = z.enum([
|
|
4311
5143
|
"CONNECTION_REQUEST",
|
|
4312
5144
|
"CONNECTION_ACCEPTED",
|
|
4313
5145
|
"CREDENTIAL_RECEIVED",
|
|
@@ -4318,40 +5150,40 @@ var LCNNotificationTypeEnumValidator = mod.enum([
|
|
|
4318
5150
|
"PRESENTATION_RECEIVED",
|
|
4319
5151
|
"CONSENT_FLOW_TRANSACTION"
|
|
4320
5152
|
]);
|
|
4321
|
-
var LCNNotificationMessageValidator =
|
|
4322
|
-
title:
|
|
4323
|
-
body:
|
|
5153
|
+
var LCNNotificationMessageValidator = z.object({
|
|
5154
|
+
title: z.string().optional(),
|
|
5155
|
+
body: z.string().optional()
|
|
4324
5156
|
});
|
|
4325
|
-
var LCNNotificationDataValidator =
|
|
4326
|
-
vcUris:
|
|
4327
|
-
vpUris:
|
|
5157
|
+
var LCNNotificationDataValidator = z.object({
|
|
5158
|
+
vcUris: z.array(z.string()).optional(),
|
|
5159
|
+
vpUris: z.array(z.string()).optional(),
|
|
4328
5160
|
transaction: ConsentFlowTransactionValidator.optional()
|
|
4329
5161
|
});
|
|
4330
|
-
|
|
5162
|
+
z.object({
|
|
4331
5163
|
type: LCNNotificationTypeEnumValidator,
|
|
4332
|
-
to: LCNProfileValidator.partial().and(
|
|
4333
|
-
from: LCNProfileValidator.partial().and(
|
|
5164
|
+
to: LCNProfileValidator.partial().and(z.object({ did: z.string() })),
|
|
5165
|
+
from: LCNProfileValidator.partial().and(z.object({ did: z.string() })),
|
|
4334
5166
|
message: LCNNotificationMessageValidator.optional(),
|
|
4335
5167
|
data: LCNNotificationDataValidator.optional(),
|
|
4336
|
-
sent:
|
|
5168
|
+
sent: z.string().datetime().optional()
|
|
4337
5169
|
});
|
|
4338
5170
|
var AUTH_GRANT_AUDIENCE_DOMAIN_PREFIX = "auth-grant:";
|
|
4339
|
-
|
|
4340
|
-
id:
|
|
4341
|
-
name:
|
|
4342
|
-
description:
|
|
4343
|
-
challenge:
|
|
4344
|
-
status:
|
|
5171
|
+
z.object({
|
|
5172
|
+
id: z.string(),
|
|
5173
|
+
name: z.string(),
|
|
5174
|
+
description: z.string().optional(),
|
|
5175
|
+
challenge: z.string().startsWith(AUTH_GRANT_AUDIENCE_DOMAIN_PREFIX).min(10, { message: "Challenge is too short" }).max(100, { message: "Challenge is too long" }),
|
|
5176
|
+
status: z.enum(["revoked", "active"], {
|
|
4345
5177
|
required_error: "Status is required",
|
|
4346
5178
|
invalid_type_error: "Status must be either active or revoked"
|
|
4347
5179
|
}),
|
|
4348
|
-
scope:
|
|
4349
|
-
createdAt:
|
|
4350
|
-
expiresAt:
|
|
5180
|
+
scope: z.string(),
|
|
5181
|
+
createdAt: z.string().datetime({ message: "createdAt must be a valid ISO 8601 datetime string" }),
|
|
5182
|
+
expiresAt: z.string().datetime({ message: "expiresAt must be a valid ISO 8601 datetime string" }).nullish().optional()
|
|
4351
5183
|
});
|
|
4352
|
-
|
|
4353
|
-
var AuthGrantStatusValidator =
|
|
4354
|
-
|
|
5184
|
+
z.object({ id: z.string() }).catchall(z.any());
|
|
5185
|
+
var AuthGrantStatusValidator = z.enum(["active", "revoked"]);
|
|
5186
|
+
z.object({
|
|
4355
5187
|
id: StringQuery,
|
|
4356
5188
|
name: StringQuery,
|
|
4357
5189
|
description: StringQuery,
|
|
@@ -4359,4 +5191,4 @@ mod.object({
|
|
|
4359
5191
|
}).partial();
|
|
4360
5192
|
|
|
4361
5193
|
export { VerificationStatusEnum as V };
|
|
4362
|
-
//# sourceMappingURL=types.esm-
|
|
5194
|
+
//# sourceMappingURL=types.esm-61ee6e29.js.map
|