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