@coursebuilder/adapter-drizzle 1.0.3 → 1.0.4

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.
@@ -44,7 +44,7 @@ var import_mysql_core49 = require("drizzle-orm/mysql-core");
44
44
  var import_nanoid = require("nanoid");
45
45
  var import_uuid = require("uuid");
46
46
 
47
- // ../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
47
+ // ../../node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.mjs
48
48
  var util;
49
49
  (function(util3) {
50
50
  util3.assertEqual = (val) => val;
@@ -202,6 +202,9 @@ var quotelessJson = /* @__PURE__ */ __name((obj) => {
202
202
  return json21.replace(/"([^"]+)":/g, "$1:");
203
203
  }, "quotelessJson");
204
204
  var _ZodError = class _ZodError extends Error {
205
+ get errors() {
206
+ return this.issues;
207
+ }
205
208
  constructor(issues) {
206
209
  super();
207
210
  this.issues = [];
@@ -220,9 +223,6 @@ var _ZodError = class _ZodError extends Error {
220
223
  this.name = "ZodError";
221
224
  this.issues = issues;
222
225
  }
223
- get errors() {
224
- return this.issues;
225
- }
226
226
  format(_mapper) {
227
227
  const mapper = _mapper || function(issue) {
228
228
  return issue.message;
@@ -259,6 +259,11 @@ var _ZodError = class _ZodError extends Error {
259
259
  processError(this);
260
260
  return fieldErrors;
261
261
  }
262
+ static assert(value) {
263
+ if (!(value instanceof _ZodError)) {
264
+ throw new Error(`Not a ZodError: ${value}`);
265
+ }
266
+ }
262
267
  toString() {
263
268
  return this.message;
264
269
  }
@@ -405,6 +410,13 @@ var makeIssue = /* @__PURE__ */ __name((params) => {
405
410
  ...issueData,
406
411
  path: fullPath
407
412
  };
413
+ if (issueData.message !== void 0) {
414
+ return {
415
+ ...issueData,
416
+ path: fullPath,
417
+ message: issueData.message
418
+ };
419
+ }
408
420
  let errorMessage = "";
409
421
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
410
422
  for (const map of maps) {
@@ -413,20 +425,24 @@ var makeIssue = /* @__PURE__ */ __name((params) => {
413
425
  return {
414
426
  ...issueData,
415
427
  path: fullPath,
416
- message: issueData.message || errorMessage
428
+ message: errorMessage
417
429
  };
418
430
  }, "makeIssue");
419
431
  var EMPTY_PATH = [];
420
432
  function addIssueToContext(ctx, issueData) {
433
+ const overrideMap = getErrorMap();
421
434
  const issue = makeIssue({
422
435
  issueData,
423
436
  data: ctx.data,
424
437
  path: ctx.path,
425
438
  errorMaps: [
426
439
  ctx.common.contextualErrorMap,
440
+ // contextual error map is first priority
427
441
  ctx.schemaErrorMap,
428
- getErrorMap(),
429
- errorMap
442
+ // then schema-bound map if available
443
+ overrideMap,
444
+ // then global override map
445
+ overrideMap === errorMap ? void 0 : errorMap
430
446
  // then global default map
431
447
  ].filter((x) => !!x)
432
448
  });
@@ -459,9 +475,11 @@ var _ParseStatus = class _ParseStatus {
459
475
  static async mergeObjectAsync(status, pairs) {
460
476
  const syncPairs = [];
461
477
  for (const pair of pairs) {
478
+ const key = await pair.key;
479
+ const value = await pair.value;
462
480
  syncPairs.push({
463
- key: await pair.key,
464
- value: await pair.value
481
+ key,
482
+ value
465
483
  });
466
484
  }
467
485
  return _ParseStatus.mergeObjectSync(status, syncPairs);
@@ -496,11 +514,31 @@ var isAborted = /* @__PURE__ */ __name((x) => x.status === "aborted", "isAborted
496
514
  var isDirty = /* @__PURE__ */ __name((x) => x.status === "dirty", "isDirty");
497
515
  var isValid = /* @__PURE__ */ __name((x) => x.status === "valid", "isValid");
498
516
  var isAsync = /* @__PURE__ */ __name((x) => typeof Promise !== "undefined" && x instanceof Promise, "isAsync");
517
+ function __classPrivateFieldGet(receiver, state, kind, f) {
518
+ if (kind === "a" && !f)
519
+ throw new TypeError("Private accessor was defined without a getter");
520
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
521
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
522
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
523
+ }
524
+ __name(__classPrivateFieldGet, "__classPrivateFieldGet");
525
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
526
+ if (kind === "m")
527
+ throw new TypeError("Private method is not writable");
528
+ if (kind === "a" && !f)
529
+ throw new TypeError("Private accessor was defined without a setter");
530
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
531
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
532
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
533
+ }
534
+ __name(__classPrivateFieldSet, "__classPrivateFieldSet");
499
535
  var errorUtil;
500
536
  (function(errorUtil3) {
501
537
  errorUtil3.errToObj = (message) => typeof message === "string" ? { message } : message || {};
502
538
  errorUtil3.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
503
539
  })(errorUtil || (errorUtil = {}));
540
+ var _ZodEnum_cache;
541
+ var _ZodNativeEnum_cache;
504
542
  var _ParseInputLazyPath = class _ParseInputLazyPath {
505
543
  constructor(parent, value, path, key) {
506
544
  this._cachedPath = [];
@@ -551,45 +589,22 @@ function processCreateParams(params) {
551
589
  if (errorMap3)
552
590
  return { errorMap: errorMap3, description };
553
591
  const customMap = /* @__PURE__ */ __name((iss, ctx) => {
554
- if (iss.code !== "invalid_type")
555
- return { message: ctx.defaultError };
592
+ var _a46, _b;
593
+ const { message } = params;
594
+ if (iss.code === "invalid_enum_value") {
595
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
596
+ }
556
597
  if (typeof ctx.data === "undefined") {
557
- return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
598
+ return { message: (_a46 = message !== null && message !== void 0 ? message : required_error) !== null && _a46 !== void 0 ? _a46 : ctx.defaultError };
558
599
  }
559
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
600
+ if (iss.code !== "invalid_type")
601
+ return { message: ctx.defaultError };
602
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
560
603
  }, "customMap");
561
604
  return { errorMap: customMap, description };
562
605
  }
563
606
  __name(processCreateParams, "processCreateParams");
564
607
  var _ZodType = class _ZodType {
565
- constructor(def) {
566
- this.spa = this.safeParseAsync;
567
- this._def = def;
568
- this.parse = this.parse.bind(this);
569
- this.safeParse = this.safeParse.bind(this);
570
- this.parseAsync = this.parseAsync.bind(this);
571
- this.safeParseAsync = this.safeParseAsync.bind(this);
572
- this.spa = this.spa.bind(this);
573
- this.refine = this.refine.bind(this);
574
- this.refinement = this.refinement.bind(this);
575
- this.superRefine = this.superRefine.bind(this);
576
- this.optional = this.optional.bind(this);
577
- this.nullable = this.nullable.bind(this);
578
- this.nullish = this.nullish.bind(this);
579
- this.array = this.array.bind(this);
580
- this.promise = this.promise.bind(this);
581
- this.or = this.or.bind(this);
582
- this.and = this.and.bind(this);
583
- this.transform = this.transform.bind(this);
584
- this.brand = this.brand.bind(this);
585
- this.default = this.default.bind(this);
586
- this.catch = this.catch.bind(this);
587
- this.describe = this.describe.bind(this);
588
- this.pipe = this.pipe.bind(this);
589
- this.readonly = this.readonly.bind(this);
590
- this.isNullable = this.isNullable.bind(this);
591
- this.isOptional = this.isOptional.bind(this);
592
- }
593
608
  get description() {
594
609
  return this._def.description;
595
610
  }
@@ -653,6 +668,43 @@ var _ZodType = class _ZodType {
653
668
  const result = this._parseSync({ data, path: ctx.path, parent: ctx });
654
669
  return handleResult(ctx, result);
655
670
  }
671
+ "~validate"(data) {
672
+ var _a46, _b;
673
+ const ctx = {
674
+ common: {
675
+ issues: [],
676
+ async: !!this["~standard"].async
677
+ },
678
+ path: [],
679
+ schemaErrorMap: this._def.errorMap,
680
+ parent: null,
681
+ data,
682
+ parsedType: getParsedType(data)
683
+ };
684
+ if (!this["~standard"].async) {
685
+ try {
686
+ const result = this._parseSync({ data, path: [], parent: ctx });
687
+ return isValid(result) ? {
688
+ value: result.value
689
+ } : {
690
+ issues: ctx.common.issues
691
+ };
692
+ } catch (err) {
693
+ if ((_b = (_a46 = err === null || err === void 0 ? void 0 : err.message) === null || _a46 === void 0 ? void 0 : _a46.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
694
+ this["~standard"].async = true;
695
+ }
696
+ ctx.common = {
697
+ issues: [],
698
+ async: true
699
+ };
700
+ }
701
+ }
702
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
703
+ value: result.value
704
+ } : {
705
+ issues: ctx.common.issues
706
+ });
707
+ }
656
708
  async parseAsync(data, params) {
657
709
  const result = await this.safeParseAsync(data, params);
658
710
  if (result.success)
@@ -730,6 +782,39 @@ var _ZodType = class _ZodType {
730
782
  superRefine(refinement) {
731
783
  return this._refinement(refinement);
732
784
  }
785
+ constructor(def) {
786
+ this.spa = this.safeParseAsync;
787
+ this._def = def;
788
+ this.parse = this.parse.bind(this);
789
+ this.safeParse = this.safeParse.bind(this);
790
+ this.parseAsync = this.parseAsync.bind(this);
791
+ this.safeParseAsync = this.safeParseAsync.bind(this);
792
+ this.spa = this.spa.bind(this);
793
+ this.refine = this.refine.bind(this);
794
+ this.refinement = this.refinement.bind(this);
795
+ this.superRefine = this.superRefine.bind(this);
796
+ this.optional = this.optional.bind(this);
797
+ this.nullable = this.nullable.bind(this);
798
+ this.nullish = this.nullish.bind(this);
799
+ this.array = this.array.bind(this);
800
+ this.promise = this.promise.bind(this);
801
+ this.or = this.or.bind(this);
802
+ this.and = this.and.bind(this);
803
+ this.transform = this.transform.bind(this);
804
+ this.brand = this.brand.bind(this);
805
+ this.default = this.default.bind(this);
806
+ this.catch = this.catch.bind(this);
807
+ this.describe = this.describe.bind(this);
808
+ this.pipe = this.pipe.bind(this);
809
+ this.readonly = this.readonly.bind(this);
810
+ this.isNullable = this.isNullable.bind(this);
811
+ this.isOptional = this.isOptional.bind(this);
812
+ this["~standard"] = {
813
+ version: 1,
814
+ vendor: "zod",
815
+ validate: (data) => this["~validate"](data)
816
+ };
817
+ }
733
818
  optional() {
734
819
  return ZodOptional.create(this, this._def);
735
820
  }
@@ -740,7 +825,7 @@ var _ZodType = class _ZodType {
740
825
  return this.nullable().optional();
741
826
  }
742
827
  array() {
743
- return ZodArray.create(this, this._def);
828
+ return ZodArray.create(this);
744
829
  }
745
830
  promise() {
746
831
  return ZodPromise.create(this, this._def);
@@ -807,35 +892,47 @@ var _ZodType = class _ZodType {
807
892
  __name(_ZodType, "ZodType");
808
893
  var ZodType = _ZodType;
809
894
  var cuidRegex = /^c[^\s-]{8,}$/i;
810
- var cuid2Regex = /^[a-z][a-z0-9]*$/;
811
- var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
895
+ var cuid2Regex = /^[0-9a-z]+$/;
896
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
812
897
  var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
813
- var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
898
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
899
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
900
+ var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
901
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
814
902
  var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
815
903
  var emojiRegex;
816
- var ipv4Regex = /^(((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}))$/;
817
- var 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})))$/;
818
- var datetimeRegex = /* @__PURE__ */ __name((args) => {
904
+ var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
905
+ var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
906
+ var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
907
+ var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
908
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
909
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
910
+ var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
911
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
912
+ function timeRegexSource(args) {
913
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
819
914
  if (args.precision) {
820
- if (args.offset) {
821
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
822
- } else {
823
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
824
- }
825
- } else if (args.precision === 0) {
826
- if (args.offset) {
827
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
828
- } else {
829
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
830
- }
831
- } else {
832
- if (args.offset) {
833
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
834
- } else {
835
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
836
- }
915
+ regex = `${regex}\\.\\d{${args.precision}}`;
916
+ } else if (args.precision == null) {
917
+ regex = `${regex}(\\.\\d+)?`;
837
918
  }
838
- }, "datetimeRegex");
919
+ return regex;
920
+ }
921
+ __name(timeRegexSource, "timeRegexSource");
922
+ function timeRegex(args) {
923
+ return new RegExp(`^${timeRegexSource(args)}$`);
924
+ }
925
+ __name(timeRegex, "timeRegex");
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
+ __name(datetimeRegex, "datetimeRegex");
839
936
  function isValidIP(ip, version) {
840
937
  if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
841
938
  return true;
@@ -846,6 +943,35 @@ function isValidIP(ip, version) {
846
943
  return false;
847
944
  }
848
945
  __name(isValidIP, "isValidIP");
946
+ function isValidJWT(jwt, alg) {
947
+ if (!jwtRegex.test(jwt))
948
+ return false;
949
+ try {
950
+ const [header] = jwt.split(".");
951
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
952
+ const decoded = JSON.parse(atob(base64));
953
+ if (typeof decoded !== "object" || decoded === null)
954
+ return false;
955
+ if (!decoded.typ || !decoded.alg)
956
+ return false;
957
+ if (alg && decoded.alg !== alg)
958
+ return false;
959
+ return true;
960
+ } catch (_a46) {
961
+ return false;
962
+ }
963
+ }
964
+ __name(isValidJWT, "isValidJWT");
965
+ function isValidCidr(ip, version) {
966
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
967
+ return true;
968
+ }
969
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
970
+ return true;
971
+ }
972
+ return false;
973
+ }
974
+ __name(isValidCidr, "isValidCidr");
849
975
  var _ZodString = class _ZodString extends ZodType {
850
976
  _parse(input) {
851
977
  if (this._def.coerce) {
@@ -854,15 +980,11 @@ var _ZodString = class _ZodString extends ZodType {
854
980
  const parsedType = this._getType(input);
855
981
  if (parsedType !== ZodParsedType.string) {
856
982
  const ctx2 = this._getOrReturnCtx(input);
857
- addIssueToContext(
858
- ctx2,
859
- {
860
- code: ZodIssueCode.invalid_type,
861
- expected: ZodParsedType.string,
862
- received: ctx2.parsedType
863
- }
864
- //
865
- );
983
+ addIssueToContext(ctx2, {
984
+ code: ZodIssueCode.invalid_type,
985
+ expected: ZodParsedType.string,
986
+ received: ctx2.parsedType
987
+ });
866
988
  return INVALID;
867
989
  }
868
990
  const status = new ParseStatus();
@@ -953,6 +1075,16 @@ var _ZodString = class _ZodString extends ZodType {
953
1075
  });
954
1076
  status.dirty();
955
1077
  }
1078
+ } else if (check.kind === "nanoid") {
1079
+ if (!nanoidRegex.test(input.data)) {
1080
+ ctx = this._getOrReturnCtx(input, ctx);
1081
+ addIssueToContext(ctx, {
1082
+ validation: "nanoid",
1083
+ code: ZodIssueCode.invalid_string,
1084
+ message: check.message
1085
+ });
1086
+ status.dirty();
1087
+ }
956
1088
  } else if (check.kind === "cuid") {
957
1089
  if (!cuidRegex.test(input.data)) {
958
1090
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1054,6 +1186,38 @@ var _ZodString = class _ZodString extends ZodType {
1054
1186
  });
1055
1187
  status.dirty();
1056
1188
  }
1189
+ } else if (check.kind === "date") {
1190
+ const regex = dateRegex;
1191
+ if (!regex.test(input.data)) {
1192
+ ctx = this._getOrReturnCtx(input, ctx);
1193
+ addIssueToContext(ctx, {
1194
+ code: ZodIssueCode.invalid_string,
1195
+ validation: "date",
1196
+ message: check.message
1197
+ });
1198
+ status.dirty();
1199
+ }
1200
+ } else if (check.kind === "time") {
1201
+ const regex = timeRegex(check);
1202
+ if (!regex.test(input.data)) {
1203
+ ctx = this._getOrReturnCtx(input, ctx);
1204
+ addIssueToContext(ctx, {
1205
+ code: ZodIssueCode.invalid_string,
1206
+ validation: "time",
1207
+ message: check.message
1208
+ });
1209
+ status.dirty();
1210
+ }
1211
+ } else if (check.kind === "duration") {
1212
+ if (!durationRegex.test(input.data)) {
1213
+ ctx = this._getOrReturnCtx(input, ctx);
1214
+ addIssueToContext(ctx, {
1215
+ validation: "duration",
1216
+ code: ZodIssueCode.invalid_string,
1217
+ message: check.message
1218
+ });
1219
+ status.dirty();
1220
+ }
1057
1221
  } else if (check.kind === "ip") {
1058
1222
  if (!isValidIP(input.data, check.version)) {
1059
1223
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1064,6 +1228,46 @@ var _ZodString = class _ZodString extends ZodType {
1064
1228
  });
1065
1229
  status.dirty();
1066
1230
  }
1231
+ } else if (check.kind === "jwt") {
1232
+ if (!isValidJWT(input.data, check.alg)) {
1233
+ ctx = this._getOrReturnCtx(input, ctx);
1234
+ addIssueToContext(ctx, {
1235
+ validation: "jwt",
1236
+ code: ZodIssueCode.invalid_string,
1237
+ message: check.message
1238
+ });
1239
+ status.dirty();
1240
+ }
1241
+ } else if (check.kind === "cidr") {
1242
+ if (!isValidCidr(input.data, check.version)) {
1243
+ ctx = this._getOrReturnCtx(input, ctx);
1244
+ addIssueToContext(ctx, {
1245
+ validation: "cidr",
1246
+ code: ZodIssueCode.invalid_string,
1247
+ message: check.message
1248
+ });
1249
+ status.dirty();
1250
+ }
1251
+ } else if (check.kind === "base64") {
1252
+ if (!base64Regex.test(input.data)) {
1253
+ ctx = this._getOrReturnCtx(input, ctx);
1254
+ addIssueToContext(ctx, {
1255
+ validation: "base64",
1256
+ code: ZodIssueCode.invalid_string,
1257
+ message: check.message
1258
+ });
1259
+ status.dirty();
1260
+ }
1261
+ } else if (check.kind === "base64url") {
1262
+ if (!base64urlRegex.test(input.data)) {
1263
+ ctx = this._getOrReturnCtx(input, ctx);
1264
+ addIssueToContext(ctx, {
1265
+ validation: "base64url",
1266
+ code: ZodIssueCode.invalid_string,
1267
+ message: check.message
1268
+ });
1269
+ status.dirty();
1270
+ }
1067
1271
  } else {
1068
1272
  util.assertNever(check);
1069
1273
  }
@@ -1095,6 +1299,9 @@ var _ZodString = class _ZodString extends ZodType {
1095
1299
  uuid(message) {
1096
1300
  return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1097
1301
  }
1302
+ nanoid(message) {
1303
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1304
+ }
1098
1305
  cuid(message) {
1099
1306
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1100
1307
  }
@@ -1104,16 +1311,32 @@ var _ZodString = class _ZodString extends ZodType {
1104
1311
  ulid(message) {
1105
1312
  return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1106
1313
  }
1314
+ base64(message) {
1315
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1316
+ }
1317
+ base64url(message) {
1318
+ return this._addCheck({
1319
+ kind: "base64url",
1320
+ ...errorUtil.errToObj(message)
1321
+ });
1322
+ }
1323
+ jwt(options) {
1324
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
1325
+ }
1107
1326
  ip(options) {
1108
1327
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1109
1328
  }
1329
+ cidr(options) {
1330
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
1331
+ }
1110
1332
  datetime(options) {
1111
- var _a46;
1333
+ var _a46, _b;
1112
1334
  if (typeof options === "string") {
1113
1335
  return this._addCheck({
1114
1336
  kind: "datetime",
1115
1337
  precision: null,
1116
1338
  offset: false,
1339
+ local: false,
1117
1340
  message: options
1118
1341
  });
1119
1342
  }
@@ -1121,9 +1344,30 @@ var _ZodString = class _ZodString extends ZodType {
1121
1344
  kind: "datetime",
1122
1345
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1123
1346
  offset: (_a46 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a46 !== void 0 ? _a46 : false,
1347
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
1348
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1349
+ });
1350
+ }
1351
+ date(message) {
1352
+ return this._addCheck({ kind: "date", message });
1353
+ }
1354
+ time(options) {
1355
+ if (typeof options === "string") {
1356
+ return this._addCheck({
1357
+ kind: "time",
1358
+ precision: null,
1359
+ message: options
1360
+ });
1361
+ }
1362
+ return this._addCheck({
1363
+ kind: "time",
1364
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1124
1365
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1125
1366
  });
1126
1367
  }
1368
+ duration(message) {
1369
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1370
+ }
1127
1371
  regex(regex, message) {
1128
1372
  return this._addCheck({
1129
1373
  kind: "regex",
@@ -1175,8 +1419,7 @@ var _ZodString = class _ZodString extends ZodType {
1175
1419
  });
1176
1420
  }
1177
1421
  /**
1178
- * @deprecated Use z.string().min(1) instead.
1179
- * @see {@link ZodString.min}
1422
+ * Equivalent to `.min(1)`
1180
1423
  */
1181
1424
  nonempty(message) {
1182
1425
  return this.min(1, errorUtil.errToObj(message));
@@ -1202,6 +1445,15 @@ var _ZodString = class _ZodString extends ZodType {
1202
1445
  get isDatetime() {
1203
1446
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
1204
1447
  }
1448
+ get isDate() {
1449
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1450
+ }
1451
+ get isTime() {
1452
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1453
+ }
1454
+ get isDuration() {
1455
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1456
+ }
1205
1457
  get isEmail() {
1206
1458
  return !!this._def.checks.find((ch) => ch.kind === "email");
1207
1459
  }
@@ -1214,6 +1466,9 @@ var _ZodString = class _ZodString extends ZodType {
1214
1466
  get isUUID() {
1215
1467
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
1216
1468
  }
1469
+ get isNANOID() {
1470
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1471
+ }
1217
1472
  get isCUID() {
1218
1473
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
1219
1474
  }
@@ -1226,6 +1481,15 @@ var _ZodString = class _ZodString extends ZodType {
1226
1481
  get isIP() {
1227
1482
  return !!this._def.checks.find((ch) => ch.kind === "ip");
1228
1483
  }
1484
+ get isCIDR() {
1485
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
1486
+ }
1487
+ get isBase64() {
1488
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1489
+ }
1490
+ get isBase64url() {
1491
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
1492
+ }
1229
1493
  get minLength() {
1230
1494
  let min = null;
1231
1495
  for (const ch of this._def.checks) {
@@ -1508,17 +1772,15 @@ var _ZodBigInt = class _ZodBigInt extends ZodType {
1508
1772
  }
1509
1773
  _parse(input) {
1510
1774
  if (this._def.coerce) {
1511
- input.data = BigInt(input.data);
1775
+ try {
1776
+ input.data = BigInt(input.data);
1777
+ } catch (_a46) {
1778
+ return this._getInvalidInput(input);
1779
+ }
1512
1780
  }
1513
1781
  const parsedType = this._getType(input);
1514
1782
  if (parsedType !== ZodParsedType.bigint) {
1515
- const ctx2 = this._getOrReturnCtx(input);
1516
- addIssueToContext(ctx2, {
1517
- code: ZodIssueCode.invalid_type,
1518
- expected: ZodParsedType.bigint,
1519
- received: ctx2.parsedType
1520
- });
1521
- return INVALID;
1783
+ return this._getInvalidInput(input);
1522
1784
  }
1523
1785
  let ctx = void 0;
1524
1786
  const status = new ParseStatus();
@@ -1565,6 +1827,15 @@ var _ZodBigInt = class _ZodBigInt extends ZodType {
1565
1827
  }
1566
1828
  return { status: status.value, value: input.data };
1567
1829
  }
1830
+ _getInvalidInput(input) {
1831
+ const ctx = this._getOrReturnCtx(input);
1832
+ addIssueToContext(ctx, {
1833
+ code: ZodIssueCode.invalid_type,
1834
+ expected: ZodParsedType.bigint,
1835
+ received: ctx.parsedType
1836
+ });
1837
+ return INVALID;
1838
+ }
1568
1839
  gte(value, message) {
1569
1840
  return this.setLimit("min", value, true, errorUtil.toString(message));
1570
1841
  }
@@ -2167,9 +2438,10 @@ var _ZodObject = class _ZodObject extends ZodType {
2167
2438
  const syncPairs = [];
2168
2439
  for (const pair of pairs) {
2169
2440
  const key = await pair.key;
2441
+ const value = await pair.value;
2170
2442
  syncPairs.push({
2171
2443
  key,
2172
- value: await pair.value,
2444
+ value,
2173
2445
  alwaysSet: pair.alwaysSet
2174
2446
  });
2175
2447
  }
@@ -2525,15 +2797,25 @@ var getDiscriminator = /* @__PURE__ */ __name((type) => {
2525
2797
  } else if (type instanceof ZodEnum) {
2526
2798
  return type.options;
2527
2799
  } else if (type instanceof ZodNativeEnum) {
2528
- return Object.keys(type.enum);
2800
+ return util.objectValues(type.enum);
2529
2801
  } else if (type instanceof ZodDefault) {
2530
2802
  return getDiscriminator(type._def.innerType);
2531
2803
  } else if (type instanceof ZodUndefined) {
2532
2804
  return [void 0];
2533
2805
  } else if (type instanceof ZodNull) {
2534
2806
  return [null];
2807
+ } else if (type instanceof ZodOptional) {
2808
+ return [void 0, ...getDiscriminator(type.unwrap())];
2809
+ } else if (type instanceof ZodNullable) {
2810
+ return [null, ...getDiscriminator(type.unwrap())];
2811
+ } else if (type instanceof ZodBranded) {
2812
+ return getDiscriminator(type.unwrap());
2813
+ } else if (type instanceof ZodReadonly) {
2814
+ return getDiscriminator(type.unwrap());
2815
+ } else if (type instanceof ZodCatch) {
2816
+ return getDiscriminator(type._def.innerType);
2535
2817
  } else {
2536
- return null;
2818
+ return [];
2537
2819
  }
2538
2820
  }, "getDiscriminator");
2539
2821
  var _ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
@@ -2593,7 +2875,7 @@ var _ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2593
2875
  const optionsMap = /* @__PURE__ */ new Map();
2594
2876
  for (const type of options) {
2595
2877
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2596
- if (!discriminatorValues) {
2878
+ if (!discriminatorValues.length) {
2597
2879
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2598
2880
  }
2599
2881
  for (const value of discriminatorValues) {
@@ -2800,7 +3082,8 @@ var _ZodRecord = class _ZodRecord extends ZodType {
2800
3082
  for (const key in ctx.data) {
2801
3083
  pairs.push({
2802
3084
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2803
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
3085
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3086
+ alwaysSet: key in ctx.data
2804
3087
  });
2805
3088
  }
2806
3089
  if (ctx.common.async) {
@@ -3160,6 +3443,10 @@ function createZodEnum(values, params) {
3160
3443
  }
3161
3444
  __name(createZodEnum, "createZodEnum");
3162
3445
  var _ZodEnum = class _ZodEnum extends ZodType {
3446
+ constructor() {
3447
+ super(...arguments);
3448
+ _ZodEnum_cache.set(this, void 0);
3449
+ }
3163
3450
  _parse(input) {
3164
3451
  if (typeof input.data !== "string") {
3165
3452
  const ctx = this._getOrReturnCtx(input);
@@ -3171,7 +3458,10 @@ var _ZodEnum = class _ZodEnum extends ZodType {
3171
3458
  });
3172
3459
  return INVALID;
3173
3460
  }
3174
- if (this._def.values.indexOf(input.data) === -1) {
3461
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
3462
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
3463
+ }
3464
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3175
3465
  const ctx = this._getOrReturnCtx(input);
3176
3466
  const expectedValues = this._def.values;
3177
3467
  addIssueToContext(ctx, {
@@ -3207,17 +3497,28 @@ var _ZodEnum = class _ZodEnum extends ZodType {
3207
3497
  }
3208
3498
  return enumValues;
3209
3499
  }
3210
- extract(values) {
3211
- return _ZodEnum.create(values);
3500
+ extract(values, newDef = this._def) {
3501
+ return _ZodEnum.create(values, {
3502
+ ...this._def,
3503
+ ...newDef
3504
+ });
3212
3505
  }
3213
- exclude(values) {
3214
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
3506
+ exclude(values, newDef = this._def) {
3507
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3508
+ ...this._def,
3509
+ ...newDef
3510
+ });
3215
3511
  }
3216
3512
  };
3217
3513
  __name(_ZodEnum, "ZodEnum");
3218
3514
  var ZodEnum = _ZodEnum;
3515
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3219
3516
  ZodEnum.create = createZodEnum;
3220
3517
  var _ZodNativeEnum = class _ZodNativeEnum extends ZodType {
3518
+ constructor() {
3519
+ super(...arguments);
3520
+ _ZodNativeEnum_cache.set(this, void 0);
3521
+ }
3221
3522
  _parse(input) {
3222
3523
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3223
3524
  const ctx = this._getOrReturnCtx(input);
@@ -3230,7 +3531,10 @@ var _ZodNativeEnum = class _ZodNativeEnum extends ZodType {
3230
3531
  });
3231
3532
  return INVALID;
3232
3533
  }
3233
- if (nativeEnumValues.indexOf(input.data) === -1) {
3534
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
3535
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
3536
+ }
3537
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3234
3538
  const expectedValues = util.objectValues(nativeEnumValues);
3235
3539
  addIssueToContext(ctx, {
3236
3540
  received: ctx.data,
@@ -3247,6 +3551,7 @@ var _ZodNativeEnum = class _ZodNativeEnum extends ZodType {
3247
3551
  };
3248
3552
  __name(_ZodNativeEnum, "ZodNativeEnum");
3249
3553
  var ZodNativeEnum = _ZodNativeEnum;
3554
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3250
3555
  ZodNativeEnum.create = (values, params) => {
3251
3556
  return new ZodNativeEnum({
3252
3557
  values,
@@ -3312,26 +3617,38 @@ var _ZodEffects = class _ZodEffects extends ZodType {
3312
3617
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3313
3618
  if (effect.type === "preprocess") {
3314
3619
  const processed = effect.transform(ctx.data, checkCtx);
3315
- if (ctx.common.issues.length) {
3316
- return {
3317
- status: "dirty",
3318
- value: ctx.data
3319
- };
3320
- }
3321
3620
  if (ctx.common.async) {
3322
- return Promise.resolve(processed).then((processed2) => {
3323
- return this._def.schema._parseAsync({
3621
+ return Promise.resolve(processed).then(async (processed2) => {
3622
+ if (status.value === "aborted")
3623
+ return INVALID;
3624
+ const result = await this._def.schema._parseAsync({
3324
3625
  data: processed2,
3325
3626
  path: ctx.path,
3326
3627
  parent: ctx
3327
3628
  });
3629
+ if (result.status === "aborted")
3630
+ return INVALID;
3631
+ if (result.status === "dirty")
3632
+ return DIRTY(result.value);
3633
+ if (status.value === "dirty")
3634
+ return DIRTY(result.value);
3635
+ return result;
3328
3636
  });
3329
3637
  } else {
3330
- return this._def.schema._parseSync({
3638
+ if (status.value === "aborted")
3639
+ return INVALID;
3640
+ const result = this._def.schema._parseSync({
3331
3641
  data: processed,
3332
3642
  path: ctx.path,
3333
3643
  parent: ctx
3334
3644
  });
3645
+ if (result.status === "aborted")
3646
+ return INVALID;
3647
+ if (result.status === "dirty")
3648
+ return DIRTY(result.value);
3649
+ if (status.value === "dirty")
3650
+ return DIRTY(result.value);
3651
+ return result;
3335
3652
  }
3336
3653
  }
3337
3654
  if (effect.type === "refinement") {
@@ -3636,10 +3953,16 @@ var ZodPipeline = _ZodPipeline;
3636
3953
  var _ZodReadonly = class _ZodReadonly extends ZodType {
3637
3954
  _parse(input) {
3638
3955
  const result = this._def.innerType._parse(input);
3639
- if (isValid(result)) {
3640
- result.value = Object.freeze(result.value);
3641
- }
3642
- return result;
3956
+ const freeze = /* @__PURE__ */ __name((data) => {
3957
+ if (isValid(data)) {
3958
+ data.value = Object.freeze(data.value);
3959
+ }
3960
+ return data;
3961
+ }, "freeze");
3962
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
3963
+ }
3964
+ unwrap() {
3965
+ return this._def.innerType;
3643
3966
  }
3644
3967
  };
3645
3968
  __name(_ZodReadonly, "ZodReadonly");
@@ -3651,19 +3974,37 @@ ZodReadonly.create = (type, params) => {
3651
3974
  ...processCreateParams(params)
3652
3975
  });
3653
3976
  };
3654
- var custom = /* @__PURE__ */ __name((check, params = {}, fatal) => {
3977
+ function cleanParams(params, data) {
3978
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3979
+ const p2 = typeof p === "string" ? { message: p } : p;
3980
+ return p2;
3981
+ }
3982
+ __name(cleanParams, "cleanParams");
3983
+ function custom(check, _params = {}, fatal) {
3655
3984
  if (check)
3656
3985
  return ZodAny.create().superRefine((data, ctx) => {
3657
3986
  var _a46, _b;
3658
- if (!check(data)) {
3659
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3660
- const _fatal = (_b = (_a46 = p.fatal) !== null && _a46 !== void 0 ? _a46 : fatal) !== null && _b !== void 0 ? _b : true;
3661
- const p2 = typeof p === "string" ? { message: p } : p;
3662
- ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
3987
+ const r = check(data);
3988
+ if (r instanceof Promise) {
3989
+ return r.then((r2) => {
3990
+ var _a47, _b2;
3991
+ if (!r2) {
3992
+ const params = cleanParams(_params, data);
3993
+ const _fatal = (_b2 = (_a47 = params.fatal) !== null && _a47 !== void 0 ? _a47 : fatal) !== null && _b2 !== void 0 ? _b2 : true;
3994
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3995
+ }
3996
+ });
3997
+ }
3998
+ if (!r) {
3999
+ const params = cleanParams(_params, data);
4000
+ const _fatal = (_b = (_a46 = params.fatal) !== null && _a46 !== void 0 ? _a46 : fatal) !== null && _b !== void 0 ? _b : true;
4001
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3663
4002
  }
4003
+ return;
3664
4004
  });
3665
4005
  return ZodAny.create();
3666
- }, "custom");
4006
+ }
4007
+ __name(custom, "custom");
3667
4008
  var late = {
3668
4009
  object: ZodObject.lazycreate
3669
4010
  };
@@ -3782,6 +4123,7 @@ var z = /* @__PURE__ */ Object.freeze({
3782
4123
  ZodParsedType,
3783
4124
  getParsedType,
3784
4125
  ZodType,
4126
+ datetimeRegex,
3785
4127
  ZodString,
3786
4128
  ZodNumber,
3787
4129
  ZodBigInt,
@@ -3890,7 +4232,7 @@ var __publicField = /* @__PURE__ */ __name((obj, key, value) => {
3890
4232
  return value;
3891
4233
  }, "__publicField");
3892
4234
 
3893
- // ../core/dist/chunk-GH4VK5VM.js
4235
+ // ../core/dist/chunk-JLNB6NRA.js
3894
4236
  var util2;
3895
4237
  (function(util22) {
3896
4238
  util22.assertEqual = (val) => val;
@@ -4051,6 +4393,9 @@ var quotelessJson2 = /* @__PURE__ */ __name2((obj) => {
4051
4393
  }, "quotelessJson");
4052
4394
  var _a;
4053
4395
  var _ZodError2 = (_a = class extends Error {
4396
+ get errors() {
4397
+ return this.issues;
4398
+ }
4054
4399
  constructor(issues) {
4055
4400
  super();
4056
4401
  this.issues = [];
@@ -4075,9 +4420,6 @@ var _ZodError2 = (_a = class extends Error {
4075
4420
  this.name = "ZodError";
4076
4421
  this.issues = issues;
4077
4422
  }
4078
- get errors() {
4079
- return this.issues;
4080
- }
4081
4423
  format(_mapper) {
4082
4424
  const mapper = _mapper || function(issue) {
4083
4425
  return issue.message;
@@ -4120,6 +4462,11 @@ var _ZodError2 = (_a = class extends Error {
4120
4462
  processError(this);
4121
4463
  return fieldErrors;
4122
4464
  }
4465
+ static assert(value) {
4466
+ if (!(value instanceof _a)) {
4467
+ throw new Error(`Not a ZodError: ${value}`);
4468
+ }
4469
+ }
4123
4470
  toString() {
4124
4471
  return this.message;
4125
4472
  }
@@ -4276,6 +4623,13 @@ var makeIssue2 = /* @__PURE__ */ __name2((params) => {
4276
4623
  ...issueData,
4277
4624
  path: fullPath
4278
4625
  };
4626
+ if (issueData.message !== void 0) {
4627
+ return {
4628
+ ...issueData,
4629
+ path: fullPath,
4630
+ message: issueData.message
4631
+ };
4632
+ }
4279
4633
  let errorMessage = "";
4280
4634
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
4281
4635
  for (const map of maps) {
@@ -4287,20 +4641,24 @@ var makeIssue2 = /* @__PURE__ */ __name2((params) => {
4287
4641
  return {
4288
4642
  ...issueData,
4289
4643
  path: fullPath,
4290
- message: issueData.message || errorMessage
4644
+ message: errorMessage
4291
4645
  };
4292
4646
  }, "makeIssue");
4293
4647
  var EMPTY_PATH2 = [];
4294
4648
  function addIssueToContext2(ctx, issueData) {
4649
+ const overrideMap = getErrorMap2();
4295
4650
  const issue = makeIssue2({
4296
4651
  issueData,
4297
4652
  data: ctx.data,
4298
4653
  path: ctx.path,
4299
4654
  errorMaps: [
4300
4655
  ctx.common.contextualErrorMap,
4656
+ // contextual error map is first priority
4301
4657
  ctx.schemaErrorMap,
4302
- getErrorMap2(),
4303
- errorMap2
4658
+ // then schema-bound map if available
4659
+ overrideMap,
4660
+ // then global override map
4661
+ overrideMap === errorMap2 ? void 0 : errorMap2
4304
4662
  ].filter((x) => !!x)
4305
4663
  });
4306
4664
  ctx.common.issues.push(issue);
@@ -4337,9 +4695,11 @@ var _ParseStatus2 = (_a2 = class {
4337
4695
  static async mergeObjectAsync(status, pairs) {
4338
4696
  const syncPairs = [];
4339
4697
  for (const pair of pairs) {
4698
+ const key = await pair.key;
4699
+ const value = await pair.value;
4340
4700
  syncPairs.push({
4341
- key: await pair.key,
4342
- value: await pair.value
4701
+ key,
4702
+ value
4343
4703
  });
4344
4704
  }
4345
4705
  return _a2.mergeObjectSync(status, syncPairs);
@@ -4383,6 +4743,26 @@ var isAborted2 = /* @__PURE__ */ __name2((x) => x.status === "aborted", "isAbort
4383
4743
  var isDirty2 = /* @__PURE__ */ __name2((x) => x.status === "dirty", "isDirty");
4384
4744
  var isValid2 = /* @__PURE__ */ __name2((x) => x.status === "valid", "isValid");
4385
4745
  var isAsync2 = /* @__PURE__ */ __name2((x) => typeof Promise !== "undefined" && x instanceof Promise, "isAsync");
4746
+ function __classPrivateFieldGet2(receiver, state, kind, f) {
4747
+ if (kind === "a" && !f)
4748
+ throw new TypeError("Private accessor was defined without a getter");
4749
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
4750
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
4751
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
4752
+ }
4753
+ __name(__classPrivateFieldGet2, "__classPrivateFieldGet");
4754
+ __name2(__classPrivateFieldGet2, "__classPrivateFieldGet");
4755
+ function __classPrivateFieldSet2(receiver, state, value, kind, f) {
4756
+ if (kind === "m")
4757
+ throw new TypeError("Private method is not writable");
4758
+ if (kind === "a" && !f)
4759
+ throw new TypeError("Private accessor was defined without a setter");
4760
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
4761
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
4762
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
4763
+ }
4764
+ __name(__classPrivateFieldSet2, "__classPrivateFieldSet");
4765
+ __name2(__classPrivateFieldSet2, "__classPrivateFieldSet");
4386
4766
  var errorUtil2;
4387
4767
  (function(errorUtil22) {
4388
4768
  errorUtil22.errToObj = (message) => typeof message === "string" ? {
@@ -4390,6 +4770,8 @@ var errorUtil2;
4390
4770
  } : message || {};
4391
4771
  errorUtil22.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
4392
4772
  })(errorUtil2 || (errorUtil2 = {}));
4773
+ var _ZodEnum_cache2;
4774
+ var _ZodNativeEnum_cache2;
4393
4775
  var _a3;
4394
4776
  var _ParseInputLazyPath2 = (_a3 = class {
4395
4777
  constructor(parent, value, path, key) {
@@ -4447,17 +4829,24 @@ function processCreateParams2(params) {
4447
4829
  description
4448
4830
  };
4449
4831
  const customMap = /* @__PURE__ */ __name2((iss, ctx) => {
4450
- if (iss.code !== "invalid_type")
4832
+ var _a46, _b;
4833
+ const { message } = params;
4834
+ if (iss.code === "invalid_enum_value") {
4451
4835
  return {
4452
- message: ctx.defaultError
4836
+ message: message !== null && message !== void 0 ? message : ctx.defaultError
4453
4837
  };
4838
+ }
4454
4839
  if (typeof ctx.data === "undefined") {
4455
4840
  return {
4456
- message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError
4841
+ message: (_a46 = message !== null && message !== void 0 ? message : required_error) !== null && _a46 !== void 0 ? _a46 : ctx.defaultError
4457
4842
  };
4458
4843
  }
4844
+ if (iss.code !== "invalid_type")
4845
+ return {
4846
+ message: ctx.defaultError
4847
+ };
4459
4848
  return {
4460
- message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError
4849
+ message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError
4461
4850
  };
4462
4851
  }, "customMap");
4463
4852
  return {
@@ -4469,34 +4858,6 @@ __name(processCreateParams2, "processCreateParams");
4469
4858
  __name2(processCreateParams2, "processCreateParams");
4470
4859
  var _a4;
4471
4860
  var _ZodType2 = (_a4 = class {
4472
- constructor(def) {
4473
- this.spa = this.safeParseAsync;
4474
- this._def = def;
4475
- this.parse = this.parse.bind(this);
4476
- this.safeParse = this.safeParse.bind(this);
4477
- this.parseAsync = this.parseAsync.bind(this);
4478
- this.safeParseAsync = this.safeParseAsync.bind(this);
4479
- this.spa = this.spa.bind(this);
4480
- this.refine = this.refine.bind(this);
4481
- this.refinement = this.refinement.bind(this);
4482
- this.superRefine = this.superRefine.bind(this);
4483
- this.optional = this.optional.bind(this);
4484
- this.nullable = this.nullable.bind(this);
4485
- this.nullish = this.nullish.bind(this);
4486
- this.array = this.array.bind(this);
4487
- this.promise = this.promise.bind(this);
4488
- this.or = this.or.bind(this);
4489
- this.and = this.and.bind(this);
4490
- this.transform = this.transform.bind(this);
4491
- this.brand = this.brand.bind(this);
4492
- this.default = this.default.bind(this);
4493
- this.catch = this.catch.bind(this);
4494
- this.describe = this.describe.bind(this);
4495
- this.pipe = this.pipe.bind(this);
4496
- this.readonly = this.readonly.bind(this);
4497
- this.isNullable = this.isNullable.bind(this);
4498
- this.isOptional = this.isOptional.bind(this);
4499
- }
4500
4861
  get description() {
4501
4862
  return this._def.description;
4502
4863
  }
@@ -4564,6 +4925,51 @@ var _ZodType2 = (_a4 = class {
4564
4925
  });
4565
4926
  return handleResult2(ctx, result);
4566
4927
  }
4928
+ "~validate"(data) {
4929
+ var _a46, _b;
4930
+ const ctx = {
4931
+ common: {
4932
+ issues: [],
4933
+ async: !!this["~standard"].async
4934
+ },
4935
+ path: [],
4936
+ schemaErrorMap: this._def.errorMap,
4937
+ parent: null,
4938
+ data,
4939
+ parsedType: getParsedType2(data)
4940
+ };
4941
+ if (!this["~standard"].async) {
4942
+ try {
4943
+ const result = this._parseSync({
4944
+ data,
4945
+ path: [],
4946
+ parent: ctx
4947
+ });
4948
+ return isValid2(result) ? {
4949
+ value: result.value
4950
+ } : {
4951
+ issues: ctx.common.issues
4952
+ };
4953
+ } catch (err) {
4954
+ if ((_b = (_a46 = err === null || err === void 0 ? void 0 : err.message) === null || _a46 === void 0 ? void 0 : _a46.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
4955
+ this["~standard"].async = true;
4956
+ }
4957
+ ctx.common = {
4958
+ issues: [],
4959
+ async: true
4960
+ };
4961
+ }
4962
+ }
4963
+ return this._parseAsync({
4964
+ data,
4965
+ path: [],
4966
+ parent: ctx
4967
+ }).then((result) => isValid2(result) ? {
4968
+ value: result.value
4969
+ } : {
4970
+ issues: ctx.common.issues
4971
+ });
4972
+ }
4567
4973
  async parseAsync(data, params) {
4568
4974
  const result = await this.safeParseAsync(data, params);
4569
4975
  if (result.success)
@@ -4650,6 +5056,39 @@ var _ZodType2 = (_a4 = class {
4650
5056
  superRefine(refinement) {
4651
5057
  return this._refinement(refinement);
4652
5058
  }
5059
+ constructor(def) {
5060
+ this.spa = this.safeParseAsync;
5061
+ this._def = def;
5062
+ this.parse = this.parse.bind(this);
5063
+ this.safeParse = this.safeParse.bind(this);
5064
+ this.parseAsync = this.parseAsync.bind(this);
5065
+ this.safeParseAsync = this.safeParseAsync.bind(this);
5066
+ this.spa = this.spa.bind(this);
5067
+ this.refine = this.refine.bind(this);
5068
+ this.refinement = this.refinement.bind(this);
5069
+ this.superRefine = this.superRefine.bind(this);
5070
+ this.optional = this.optional.bind(this);
5071
+ this.nullable = this.nullable.bind(this);
5072
+ this.nullish = this.nullish.bind(this);
5073
+ this.array = this.array.bind(this);
5074
+ this.promise = this.promise.bind(this);
5075
+ this.or = this.or.bind(this);
5076
+ this.and = this.and.bind(this);
5077
+ this.transform = this.transform.bind(this);
5078
+ this.brand = this.brand.bind(this);
5079
+ this.default = this.default.bind(this);
5080
+ this.catch = this.catch.bind(this);
5081
+ this.describe = this.describe.bind(this);
5082
+ this.pipe = this.pipe.bind(this);
5083
+ this.readonly = this.readonly.bind(this);
5084
+ this.isNullable = this.isNullable.bind(this);
5085
+ this.isOptional = this.isOptional.bind(this);
5086
+ this["~standard"] = {
5087
+ version: 1,
5088
+ vendor: "zod",
5089
+ validate: (data) => this["~validate"](data)
5090
+ };
5091
+ }
4653
5092
  optional() {
4654
5093
  return ZodOptional2.create(this, this._def);
4655
5094
  }
@@ -4660,7 +5099,7 @@ var _ZodType2 = (_a4 = class {
4660
5099
  return this.nullable().optional();
4661
5100
  }
4662
5101
  array() {
4663
- return ZodArray2.create(this, this._def);
5102
+ return ZodArray2.create(this);
4664
5103
  }
4665
5104
  promise() {
4666
5105
  return ZodPromise2.create(this, this._def);
@@ -4733,35 +5172,50 @@ var _ZodType2 = (_a4 = class {
4733
5172
  __name2(_ZodType2, "ZodType");
4734
5173
  var ZodType2 = _ZodType2;
4735
5174
  var cuidRegex2 = /^c[^\s-]{8,}$/i;
4736
- var cuid2Regex2 = /^[a-z][a-z0-9]*$/;
4737
- var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/;
5175
+ var cuid2Regex2 = /^[0-9a-z]+$/;
5176
+ var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
4738
5177
  var uuidRegex2 = /^[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;
4739
- var emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
5178
+ var nanoidRegex2 = /^[a-z0-9_-]{21}$/i;
5179
+ var jwtRegex2 = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
5180
+ var durationRegex2 = /^[-+]?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)?)??$/;
5181
+ var emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
4740
5182
  var _emojiRegex2 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
4741
5183
  var emojiRegex2;
4742
- var ipv4Regex2 = /^(((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}))$/;
4743
- var ipv6Regex2 = /^(([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})))$/;
4744
- var datetimeRegex2 = /* @__PURE__ */ __name2((args) => {
5184
+ var ipv4Regex2 = /^(?:(?: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])$/;
5185
+ var ipv4CidrRegex2 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
5186
+ var ipv6Regex2 = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
5187
+ var ipv6CidrRegex2 = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
5188
+ var base64Regex2 = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
5189
+ var base64urlRegex2 = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
5190
+ var dateRegexSource2 = `((\\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])))`;
5191
+ var dateRegex2 = new RegExp(`^${dateRegexSource2}$`);
5192
+ function timeRegexSource2(args) {
5193
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
4745
5194
  if (args.precision) {
4746
- if (args.offset) {
4747
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
4748
- } else {
4749
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
4750
- }
4751
- } else if (args.precision === 0) {
4752
- if (args.offset) {
4753
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
4754
- } else {
4755
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
4756
- }
4757
- } else {
4758
- if (args.offset) {
4759
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
4760
- } else {
4761
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
4762
- }
5195
+ regex = `${regex}\\.\\d{${args.precision}}`;
5196
+ } else if (args.precision == null) {
5197
+ regex = `${regex}(\\.\\d+)?`;
4763
5198
  }
4764
- }, "datetimeRegex");
5199
+ return regex;
5200
+ }
5201
+ __name(timeRegexSource2, "timeRegexSource");
5202
+ __name2(timeRegexSource2, "timeRegexSource");
5203
+ function timeRegex2(args) {
5204
+ return new RegExp(`^${timeRegexSource2(args)}$`);
5205
+ }
5206
+ __name(timeRegex2, "timeRegex");
5207
+ __name2(timeRegex2, "timeRegex");
5208
+ function datetimeRegex2(args) {
5209
+ let regex = `${dateRegexSource2}T${timeRegexSource2(args)}`;
5210
+ const opts = [];
5211
+ opts.push(args.local ? `Z?` : `Z`);
5212
+ if (args.offset)
5213
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
5214
+ regex = `${regex}(${opts.join("|")})`;
5215
+ return new RegExp(`^${regex}$`);
5216
+ }
5217
+ __name(datetimeRegex2, "datetimeRegex");
5218
+ __name2(datetimeRegex2, "datetimeRegex");
4765
5219
  function isValidIP2(ip, version) {
4766
5220
  if ((version === "v4" || !version) && ipv4Regex2.test(ip)) {
4767
5221
  return true;
@@ -4773,6 +5227,37 @@ function isValidIP2(ip, version) {
4773
5227
  }
4774
5228
  __name(isValidIP2, "isValidIP");
4775
5229
  __name2(isValidIP2, "isValidIP");
5230
+ function isValidJWT2(jwt, alg) {
5231
+ if (!jwtRegex2.test(jwt))
5232
+ return false;
5233
+ try {
5234
+ const [header] = jwt.split(".");
5235
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
5236
+ const decoded = JSON.parse(atob(base64));
5237
+ if (typeof decoded !== "object" || decoded === null)
5238
+ return false;
5239
+ if (!decoded.typ || !decoded.alg)
5240
+ return false;
5241
+ if (alg && decoded.alg !== alg)
5242
+ return false;
5243
+ return true;
5244
+ } catch (_a46) {
5245
+ return false;
5246
+ }
5247
+ }
5248
+ __name(isValidJWT2, "isValidJWT");
5249
+ __name2(isValidJWT2, "isValidJWT");
5250
+ function isValidCidr2(ip, version) {
5251
+ if ((version === "v4" || !version) && ipv4CidrRegex2.test(ip)) {
5252
+ return true;
5253
+ }
5254
+ if ((version === "v6" || !version) && ipv6CidrRegex2.test(ip)) {
5255
+ return true;
5256
+ }
5257
+ return false;
5258
+ }
5259
+ __name(isValidCidr2, "isValidCidr");
5260
+ __name2(isValidCidr2, "isValidCidr");
4776
5261
  var _a5;
4777
5262
  var _ZodString2 = (_a5 = class extends ZodType2 {
4778
5263
  _parse(input) {
@@ -4877,6 +5362,16 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
4877
5362
  });
4878
5363
  status.dirty();
4879
5364
  }
5365
+ } else if (check.kind === "nanoid") {
5366
+ if (!nanoidRegex2.test(input.data)) {
5367
+ ctx = this._getOrReturnCtx(input, ctx);
5368
+ addIssueToContext2(ctx, {
5369
+ validation: "nanoid",
5370
+ code: ZodIssueCode2.invalid_string,
5371
+ message: check.message
5372
+ });
5373
+ status.dirty();
5374
+ }
4880
5375
  } else if (check.kind === "cuid") {
4881
5376
  if (!cuidRegex2.test(input.data)) {
4882
5377
  ctx = this._getOrReturnCtx(input, ctx);
@@ -4985,6 +5480,38 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
4985
5480
  });
4986
5481
  status.dirty();
4987
5482
  }
5483
+ } else if (check.kind === "date") {
5484
+ const regex = dateRegex2;
5485
+ if (!regex.test(input.data)) {
5486
+ ctx = this._getOrReturnCtx(input, ctx);
5487
+ addIssueToContext2(ctx, {
5488
+ code: ZodIssueCode2.invalid_string,
5489
+ validation: "date",
5490
+ message: check.message
5491
+ });
5492
+ status.dirty();
5493
+ }
5494
+ } else if (check.kind === "time") {
5495
+ const regex = timeRegex2(check);
5496
+ if (!regex.test(input.data)) {
5497
+ ctx = this._getOrReturnCtx(input, ctx);
5498
+ addIssueToContext2(ctx, {
5499
+ code: ZodIssueCode2.invalid_string,
5500
+ validation: "time",
5501
+ message: check.message
5502
+ });
5503
+ status.dirty();
5504
+ }
5505
+ } else if (check.kind === "duration") {
5506
+ if (!durationRegex2.test(input.data)) {
5507
+ ctx = this._getOrReturnCtx(input, ctx);
5508
+ addIssueToContext2(ctx, {
5509
+ validation: "duration",
5510
+ code: ZodIssueCode2.invalid_string,
5511
+ message: check.message
5512
+ });
5513
+ status.dirty();
5514
+ }
4988
5515
  } else if (check.kind === "ip") {
4989
5516
  if (!isValidIP2(input.data, check.version)) {
4990
5517
  ctx = this._getOrReturnCtx(input, ctx);
@@ -4995,6 +5522,46 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
4995
5522
  });
4996
5523
  status.dirty();
4997
5524
  }
5525
+ } else if (check.kind === "jwt") {
5526
+ if (!isValidJWT2(input.data, check.alg)) {
5527
+ ctx = this._getOrReturnCtx(input, ctx);
5528
+ addIssueToContext2(ctx, {
5529
+ validation: "jwt",
5530
+ code: ZodIssueCode2.invalid_string,
5531
+ message: check.message
5532
+ });
5533
+ status.dirty();
5534
+ }
5535
+ } else if (check.kind === "cidr") {
5536
+ if (!isValidCidr2(input.data, check.version)) {
5537
+ ctx = this._getOrReturnCtx(input, ctx);
5538
+ addIssueToContext2(ctx, {
5539
+ validation: "cidr",
5540
+ code: ZodIssueCode2.invalid_string,
5541
+ message: check.message
5542
+ });
5543
+ status.dirty();
5544
+ }
5545
+ } else if (check.kind === "base64") {
5546
+ if (!base64Regex2.test(input.data)) {
5547
+ ctx = this._getOrReturnCtx(input, ctx);
5548
+ addIssueToContext2(ctx, {
5549
+ validation: "base64",
5550
+ code: ZodIssueCode2.invalid_string,
5551
+ message: check.message
5552
+ });
5553
+ status.dirty();
5554
+ }
5555
+ } else if (check.kind === "base64url") {
5556
+ if (!base64urlRegex2.test(input.data)) {
5557
+ ctx = this._getOrReturnCtx(input, ctx);
5558
+ addIssueToContext2(ctx, {
5559
+ validation: "base64url",
5560
+ code: ZodIssueCode2.invalid_string,
5561
+ message: check.message
5562
+ });
5563
+ status.dirty();
5564
+ }
4998
5565
  } else {
4999
5566
  util2.assertNever(check);
5000
5567
  }
@@ -5044,6 +5611,12 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5044
5611
  ...errorUtil2.errToObj(message)
5045
5612
  });
5046
5613
  }
5614
+ nanoid(message) {
5615
+ return this._addCheck({
5616
+ kind: "nanoid",
5617
+ ...errorUtil2.errToObj(message)
5618
+ });
5619
+ }
5047
5620
  cuid(message) {
5048
5621
  return this._addCheck({
5049
5622
  kind: "cuid",
@@ -5062,19 +5635,44 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5062
5635
  ...errorUtil2.errToObj(message)
5063
5636
  });
5064
5637
  }
5638
+ base64(message) {
5639
+ return this._addCheck({
5640
+ kind: "base64",
5641
+ ...errorUtil2.errToObj(message)
5642
+ });
5643
+ }
5644
+ base64url(message) {
5645
+ return this._addCheck({
5646
+ kind: "base64url",
5647
+ ...errorUtil2.errToObj(message)
5648
+ });
5649
+ }
5650
+ jwt(options) {
5651
+ return this._addCheck({
5652
+ kind: "jwt",
5653
+ ...errorUtil2.errToObj(options)
5654
+ });
5655
+ }
5065
5656
  ip(options) {
5066
5657
  return this._addCheck({
5067
5658
  kind: "ip",
5068
5659
  ...errorUtil2.errToObj(options)
5069
5660
  });
5070
5661
  }
5662
+ cidr(options) {
5663
+ return this._addCheck({
5664
+ kind: "cidr",
5665
+ ...errorUtil2.errToObj(options)
5666
+ });
5667
+ }
5071
5668
  datetime(options) {
5072
- var _a46;
5669
+ var _a46, _b;
5073
5670
  if (typeof options === "string") {
5074
5671
  return this._addCheck({
5075
5672
  kind: "datetime",
5076
5673
  precision: null,
5077
5674
  offset: false,
5675
+ local: false,
5078
5676
  message: options
5079
5677
  });
5080
5678
  }
@@ -5082,9 +5680,36 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5082
5680
  kind: "datetime",
5083
5681
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
5084
5682
  offset: (_a46 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a46 !== void 0 ? _a46 : false,
5683
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
5085
5684
  ...errorUtil2.errToObj(options === null || options === void 0 ? void 0 : options.message)
5086
5685
  });
5087
5686
  }
5687
+ date(message) {
5688
+ return this._addCheck({
5689
+ kind: "date",
5690
+ message
5691
+ });
5692
+ }
5693
+ time(options) {
5694
+ if (typeof options === "string") {
5695
+ return this._addCheck({
5696
+ kind: "time",
5697
+ precision: null,
5698
+ message: options
5699
+ });
5700
+ }
5701
+ return this._addCheck({
5702
+ kind: "time",
5703
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
5704
+ ...errorUtil2.errToObj(options === null || options === void 0 ? void 0 : options.message)
5705
+ });
5706
+ }
5707
+ duration(message) {
5708
+ return this._addCheck({
5709
+ kind: "duration",
5710
+ ...errorUtil2.errToObj(message)
5711
+ });
5712
+ }
5088
5713
  regex(regex, message) {
5089
5714
  return this._addCheck({
5090
5715
  kind: "regex",
@@ -5136,8 +5761,7 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5136
5761
  });
5137
5762
  }
5138
5763
  /**
5139
- * @deprecated Use z.string().min(1) instead.
5140
- * @see {@link ZodString.min}
5764
+ * Equivalent to `.min(1)`
5141
5765
  */
5142
5766
  nonempty(message) {
5143
5767
  return this.min(1, errorUtil2.errToObj(message));
@@ -5178,6 +5802,15 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5178
5802
  get isDatetime() {
5179
5803
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
5180
5804
  }
5805
+ get isDate() {
5806
+ return !!this._def.checks.find((ch) => ch.kind === "date");
5807
+ }
5808
+ get isTime() {
5809
+ return !!this._def.checks.find((ch) => ch.kind === "time");
5810
+ }
5811
+ get isDuration() {
5812
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
5813
+ }
5181
5814
  get isEmail() {
5182
5815
  return !!this._def.checks.find((ch) => ch.kind === "email");
5183
5816
  }
@@ -5190,6 +5823,9 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5190
5823
  get isUUID() {
5191
5824
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
5192
5825
  }
5826
+ get isNANOID() {
5827
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
5828
+ }
5193
5829
  get isCUID() {
5194
5830
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
5195
5831
  }
@@ -5202,6 +5838,15 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5202
5838
  get isIP() {
5203
5839
  return !!this._def.checks.find((ch) => ch.kind === "ip");
5204
5840
  }
5841
+ get isCIDR() {
5842
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
5843
+ }
5844
+ get isBase64() {
5845
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
5846
+ }
5847
+ get isBase64url() {
5848
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
5849
+ }
5205
5850
  get minLength() {
5206
5851
  let min = null;
5207
5852
  for (const ch of this._def.checks) {
@@ -5493,17 +6138,15 @@ var _ZodBigInt2 = (_a7 = class extends ZodType2 {
5493
6138
  }
5494
6139
  _parse(input) {
5495
6140
  if (this._def.coerce) {
5496
- input.data = BigInt(input.data);
6141
+ try {
6142
+ input.data = BigInt(input.data);
6143
+ } catch (_a46) {
6144
+ return this._getInvalidInput(input);
6145
+ }
5497
6146
  }
5498
6147
  const parsedType = this._getType(input);
5499
6148
  if (parsedType !== ZodParsedType2.bigint) {
5500
- const ctx2 = this._getOrReturnCtx(input);
5501
- addIssueToContext2(ctx2, {
5502
- code: ZodIssueCode2.invalid_type,
5503
- expected: ZodParsedType2.bigint,
5504
- received: ctx2.parsedType
5505
- });
5506
- return INVALID2;
6149
+ return this._getInvalidInput(input);
5507
6150
  }
5508
6151
  let ctx = void 0;
5509
6152
  const status = new ParseStatus2();
@@ -5553,6 +6196,15 @@ var _ZodBigInt2 = (_a7 = class extends ZodType2 {
5553
6196
  value: input.data
5554
6197
  };
5555
6198
  }
6199
+ _getInvalidInput(input) {
6200
+ const ctx = this._getOrReturnCtx(input);
6201
+ addIssueToContext2(ctx, {
6202
+ code: ZodIssueCode2.invalid_type,
6203
+ expected: ZodParsedType2.bigint,
6204
+ received: ctx.parsedType
6205
+ });
6206
+ return INVALID2;
6207
+ }
5556
6208
  gte(value, message) {
5557
6209
  return this.setLimit("min", value, true, errorUtil2.toString(message));
5558
6210
  }
@@ -6198,9 +6850,10 @@ var _ZodObject2 = (_a18 = class extends ZodType2 {
6198
6850
  const syncPairs = [];
6199
6851
  for (const pair of pairs) {
6200
6852
  const key = await pair.key;
6853
+ const value = await pair.value;
6201
6854
  syncPairs.push({
6202
6855
  key,
6203
- value: await pair.value,
6856
+ value,
6204
6857
  alwaysSet: pair.alwaysSet
6205
6858
  });
6206
6859
  }
@@ -6565,7 +7218,7 @@ var getDiscriminator2 = /* @__PURE__ */ __name2((type) => {
6565
7218
  } else if (type instanceof ZodEnum2) {
6566
7219
  return type.options;
6567
7220
  } else if (type instanceof ZodNativeEnum2) {
6568
- return Object.keys(type.enum);
7221
+ return util2.objectValues(type.enum);
6569
7222
  } else if (type instanceof ZodDefault2) {
6570
7223
  return getDiscriminator2(type._def.innerType);
6571
7224
  } else if (type instanceof ZodUndefined2) {
@@ -6576,8 +7229,24 @@ var getDiscriminator2 = /* @__PURE__ */ __name2((type) => {
6576
7229
  return [
6577
7230
  null
6578
7231
  ];
7232
+ } else if (type instanceof ZodOptional2) {
7233
+ return [
7234
+ void 0,
7235
+ ...getDiscriminator2(type.unwrap())
7236
+ ];
7237
+ } else if (type instanceof ZodNullable2) {
7238
+ return [
7239
+ null,
7240
+ ...getDiscriminator2(type.unwrap())
7241
+ ];
7242
+ } else if (type instanceof ZodBranded2) {
7243
+ return getDiscriminator2(type.unwrap());
7244
+ } else if (type instanceof ZodReadonly2) {
7245
+ return getDiscriminator2(type.unwrap());
7246
+ } else if (type instanceof ZodCatch2) {
7247
+ return getDiscriminator2(type._def.innerType);
6579
7248
  } else {
6580
- return null;
7249
+ return [];
6581
7250
  }
6582
7251
  }, "getDiscriminator");
6583
7252
  var _a20;
@@ -6640,7 +7309,7 @@ var _ZodDiscriminatedUnion2 = (_a20 = class extends ZodType2 {
6640
7309
  const optionsMap = /* @__PURE__ */ new Map();
6641
7310
  for (const type of options) {
6642
7311
  const discriminatorValues = getDiscriminator2(type.shape[discriminator]);
6643
- if (!discriminatorValues) {
7312
+ if (!discriminatorValues.length) {
6644
7313
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
6645
7314
  }
6646
7315
  for (const value of discriminatorValues) {
@@ -6879,7 +7548,8 @@ var _ZodRecord2 = (_a23 = class extends ZodType2 {
6879
7548
  for (const key in ctx.data) {
6880
7549
  pairs.push({
6881
7550
  key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, key)),
6882
- value: valueType._parse(new ParseInputLazyPath2(ctx, ctx.data[key], ctx.path, key))
7551
+ value: valueType._parse(new ParseInputLazyPath2(ctx, ctx.data[key], ctx.path, key)),
7552
+ alwaysSet: key in ctx.data
6883
7553
  });
6884
7554
  }
6885
7555
  if (ctx.common.async) {
@@ -7287,6 +7957,10 @@ __name(createZodEnum2, "createZodEnum");
7287
7957
  __name2(createZodEnum2, "createZodEnum");
7288
7958
  var _a29;
7289
7959
  var _ZodEnum2 = (_a29 = class extends ZodType2 {
7960
+ constructor() {
7961
+ super(...arguments);
7962
+ _ZodEnum_cache2.set(this, void 0);
7963
+ }
7290
7964
  _parse(input) {
7291
7965
  if (typeof input.data !== "string") {
7292
7966
  const ctx = this._getOrReturnCtx(input);
@@ -7298,7 +7972,10 @@ var _ZodEnum2 = (_a29 = class extends ZodType2 {
7298
7972
  });
7299
7973
  return INVALID2;
7300
7974
  }
7301
- if (this._def.values.indexOf(input.data) === -1) {
7975
+ if (!__classPrivateFieldGet2(this, _ZodEnum_cache2, "f")) {
7976
+ __classPrivateFieldSet2(this, _ZodEnum_cache2, new Set(this._def.values), "f");
7977
+ }
7978
+ if (!__classPrivateFieldGet2(this, _ZodEnum_cache2, "f").has(input.data)) {
7302
7979
  const ctx = this._getOrReturnCtx(input);
7303
7980
  const expectedValues = this._def.values;
7304
7981
  addIssueToContext2(ctx, {
@@ -7334,18 +8011,29 @@ var _ZodEnum2 = (_a29 = class extends ZodType2 {
7334
8011
  }
7335
8012
  return enumValues;
7336
8013
  }
7337
- extract(values) {
7338
- return _a29.create(values);
8014
+ extract(values, newDef = this._def) {
8015
+ return _a29.create(values, {
8016
+ ...this._def,
8017
+ ...newDef
8018
+ });
7339
8019
  }
7340
- exclude(values) {
7341
- return _a29.create(this.options.filter((opt) => !values.includes(opt)));
8020
+ exclude(values, newDef = this._def) {
8021
+ return _a29.create(this.options.filter((opt) => !values.includes(opt)), {
8022
+ ...this._def,
8023
+ ...newDef
8024
+ });
7342
8025
  }
7343
8026
  }, __name(_a29, "_ZodEnum"), _a29);
7344
8027
  __name2(_ZodEnum2, "ZodEnum");
7345
8028
  var ZodEnum2 = _ZodEnum2;
8029
+ _ZodEnum_cache2 = /* @__PURE__ */ new WeakMap();
7346
8030
  ZodEnum2.create = createZodEnum2;
7347
8031
  var _a30;
7348
8032
  var _ZodNativeEnum2 = (_a30 = class extends ZodType2 {
8033
+ constructor() {
8034
+ super(...arguments);
8035
+ _ZodNativeEnum_cache2.set(this, void 0);
8036
+ }
7349
8037
  _parse(input) {
7350
8038
  const nativeEnumValues = util2.getValidEnumValues(this._def.values);
7351
8039
  const ctx = this._getOrReturnCtx(input);
@@ -7358,7 +8046,10 @@ var _ZodNativeEnum2 = (_a30 = class extends ZodType2 {
7358
8046
  });
7359
8047
  return INVALID2;
7360
8048
  }
7361
- if (nativeEnumValues.indexOf(input.data) === -1) {
8049
+ if (!__classPrivateFieldGet2(this, _ZodNativeEnum_cache2, "f")) {
8050
+ __classPrivateFieldSet2(this, _ZodNativeEnum_cache2, new Set(util2.getValidEnumValues(this._def.values)), "f");
8051
+ }
8052
+ if (!__classPrivateFieldGet2(this, _ZodNativeEnum_cache2, "f").has(input.data)) {
7362
8053
  const expectedValues = util2.objectValues(nativeEnumValues);
7363
8054
  addIssueToContext2(ctx, {
7364
8055
  received: ctx.data,
@@ -7375,6 +8066,7 @@ var _ZodNativeEnum2 = (_a30 = class extends ZodType2 {
7375
8066
  }, __name(_a30, "_ZodNativeEnum"), _a30);
7376
8067
  __name2(_ZodNativeEnum2, "ZodNativeEnum");
7377
8068
  var ZodNativeEnum2 = _ZodNativeEnum2;
8069
+ _ZodNativeEnum_cache2 = /* @__PURE__ */ new WeakMap();
7378
8070
  ZodNativeEnum2.create = (values, params) => {
7379
8071
  return new ZodNativeEnum2({
7380
8072
  values,
@@ -7442,26 +8134,38 @@ var _ZodEffects2 = (_a32 = class extends ZodType2 {
7442
8134
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
7443
8135
  if (effect.type === "preprocess") {
7444
8136
  const processed = effect.transform(ctx.data, checkCtx);
7445
- if (ctx.common.issues.length) {
7446
- return {
7447
- status: "dirty",
7448
- value: ctx.data
7449
- };
7450
- }
7451
8137
  if (ctx.common.async) {
7452
- return Promise.resolve(processed).then((processed2) => {
7453
- return this._def.schema._parseAsync({
8138
+ return Promise.resolve(processed).then(async (processed2) => {
8139
+ if (status.value === "aborted")
8140
+ return INVALID2;
8141
+ const result = await this._def.schema._parseAsync({
7454
8142
  data: processed2,
7455
8143
  path: ctx.path,
7456
8144
  parent: ctx
7457
8145
  });
8146
+ if (result.status === "aborted")
8147
+ return INVALID2;
8148
+ if (result.status === "dirty")
8149
+ return DIRTY2(result.value);
8150
+ if (status.value === "dirty")
8151
+ return DIRTY2(result.value);
8152
+ return result;
7458
8153
  });
7459
8154
  } else {
7460
- return this._def.schema._parseSync({
8155
+ if (status.value === "aborted")
8156
+ return INVALID2;
8157
+ const result = this._def.schema._parseSync({
7461
8158
  data: processed,
7462
8159
  path: ctx.path,
7463
8160
  parent: ctx
7464
8161
  });
8162
+ if (result.status === "aborted")
8163
+ return INVALID2;
8164
+ if (result.status === "dirty")
8165
+ return DIRTY2(result.value);
8166
+ if (status.value === "dirty")
8167
+ return DIRTY2(result.value);
8168
+ return result;
7465
8169
  }
7466
8170
  }
7467
8171
  if (effect.type === "refinement") {
@@ -7800,10 +8504,16 @@ var _a40;
7800
8504
  var _ZodReadonly2 = (_a40 = class extends ZodType2 {
7801
8505
  _parse(input) {
7802
8506
  const result = this._def.innerType._parse(input);
7803
- if (isValid2(result)) {
7804
- result.value = Object.freeze(result.value);
7805
- }
7806
- return result;
8507
+ const freeze = /* @__PURE__ */ __name2((data) => {
8508
+ if (isValid2(data)) {
8509
+ data.value = Object.freeze(data.value);
8510
+ }
8511
+ return data;
8512
+ }, "freeze");
8513
+ return isAsync2(result) ? result.then((data) => freeze(data)) : freeze(result);
8514
+ }
8515
+ unwrap() {
8516
+ return this._def.innerType;
7807
8517
  }
7808
8518
  }, __name(_a40, "_ZodReadonly"), _a40);
7809
8519
  __name2(_ZodReadonly2, "ZodReadonly");
@@ -7815,27 +8525,51 @@ ZodReadonly2.create = (type, params) => {
7815
8525
  ...processCreateParams2(params)
7816
8526
  });
7817
8527
  };
7818
- var custom2 = /* @__PURE__ */ __name2((check, params = {}, fatal) => {
8528
+ function cleanParams2(params, data) {
8529
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? {
8530
+ message: params
8531
+ } : params;
8532
+ const p2 = typeof p === "string" ? {
8533
+ message: p
8534
+ } : p;
8535
+ return p2;
8536
+ }
8537
+ __name(cleanParams2, "cleanParams");
8538
+ __name2(cleanParams2, "cleanParams");
8539
+ function custom2(check, _params = {}, fatal) {
7819
8540
  if (check)
7820
8541
  return ZodAny2.create().superRefine((data, ctx) => {
7821
8542
  var _a46, _b;
7822
- if (!check(data)) {
7823
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? {
7824
- message: params
7825
- } : params;
7826
- const _fatal = (_b = (_a46 = p.fatal) !== null && _a46 !== void 0 ? _a46 : fatal) !== null && _b !== void 0 ? _b : true;
7827
- const p2 = typeof p === "string" ? {
7828
- message: p
7829
- } : p;
8543
+ const r = check(data);
8544
+ if (r instanceof Promise) {
8545
+ return r.then((r2) => {
8546
+ var _a210, _b2;
8547
+ if (!r2) {
8548
+ const params = cleanParams2(_params, data);
8549
+ const _fatal = (_b2 = (_a210 = params.fatal) !== null && _a210 !== void 0 ? _a210 : fatal) !== null && _b2 !== void 0 ? _b2 : true;
8550
+ ctx.addIssue({
8551
+ code: "custom",
8552
+ ...params,
8553
+ fatal: _fatal
8554
+ });
8555
+ }
8556
+ });
8557
+ }
8558
+ if (!r) {
8559
+ const params = cleanParams2(_params, data);
8560
+ const _fatal = (_b = (_a46 = params.fatal) !== null && _a46 !== void 0 ? _a46 : fatal) !== null && _b !== void 0 ? _b : true;
7830
8561
  ctx.addIssue({
7831
8562
  code: "custom",
7832
- ...p2,
8563
+ ...params,
7833
8564
  fatal: _fatal
7834
8565
  });
7835
8566
  }
8567
+ return;
7836
8568
  });
7837
8569
  return ZodAny2.create();
7838
- }, "custom");
8570
+ }
8571
+ __name(custom2, "custom");
8572
+ __name2(custom2, "custom");
7839
8573
  var late2 = {
7840
8574
  object: ZodObject2.lazycreate
7841
8575
  };
@@ -7966,6 +8700,7 @@ var z2 = /* @__PURE__ */ Object.freeze({
7966
8700
  ZodParsedType: ZodParsedType2,
7967
8701
  getParsedType: getParsedType2,
7968
8702
  ZodType: ZodType2,
8703
+ datetimeRegex: datetimeRegex2,
7969
8704
  ZodString: ZodString2,
7970
8705
  ZodNumber: ZodNumber2,
7971
8706
  ZodBigInt: ZodBigInt2,
@@ -8057,7 +8792,18 @@ var z2 = /* @__PURE__ */ Object.freeze({
8057
8792
  ZodError: ZodError2
8058
8793
  });
8059
8794
 
8060
- // ../core/dist/chunk-CMH4QQ3R.js
8795
+ // ../core/dist/chunk-U2ZCKMNU.js
8796
+ var upgradableProductSchema = z2.object({
8797
+ upgradableToId: z2.string().max(255),
8798
+ upgradableFromId: z2.string().max(255),
8799
+ position: z2.number().default(0),
8800
+ metadata: z2.record(z2.any()).default({}),
8801
+ createdAt: z2.date().nullable(),
8802
+ updatedAt: z2.date().nullable(),
8803
+ deletedAt: z2.date().nullable()
8804
+ });
8805
+
8806
+ // ../core/dist/chunk-ZXRVZVJR.js
8061
8807
  var VideoResourceSchema = z2.object({
8062
8808
  id: z2.string(),
8063
8809
  updatedAt: z2.coerce.date().optional(),
@@ -8080,29 +8826,22 @@ var VideoResourceSchema = z2.object({
8080
8826
  ])
8081
8827
  });
8082
8828
 
8083
- // ../core/dist/chunk-LMH5A7OR.js
8084
- var purchaseUserTransferSchema = z2.object({
8829
+ // ../core/dist/chunk-CJLUA3NF.js
8830
+ var priceSchema = z2.object({
8085
8831
  id: z2.string().max(191),
8086
- transferState: z2.enum([
8087
- "AVAILABLE",
8088
- "INITIATED",
8089
- "VERIFIED",
8090
- "CANCELED",
8091
- "EXPIRED",
8092
- "CONFIRMED",
8093
- "COMPLETED"
8094
- ]).default("AVAILABLE"),
8095
- purchaseId: z2.string().max(191),
8096
- sourceUserId: z2.string().max(191),
8097
- targetUserId: z2.string().max(191).optional().nullable(),
8832
+ productId: z2.string().max(191).optional().nullable(),
8833
+ organizationId: z2.string().max(191).optional().nullable(),
8834
+ nickname: z2.string().max(191).optional().nullable(),
8835
+ status: z2.number().int().default(0),
8836
+ unitAmount: z2.coerce.number().refine((value) => {
8837
+ const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8838
+ return decimalPlaces <= 2;
8839
+ }),
8098
8840
  createdAt: z2.date().nullable(),
8099
- expiresAt: z2.date().nullable(),
8100
- canceledAt: z2.date().nullable(),
8101
- confirmedAt: z2.date().nullable(),
8102
- completedAt: z2.date().nullable()
8841
+ fields: z2.record(z2.any()).default({})
8103
8842
  });
8104
8843
 
8105
- // ../core/dist/chunk-SCKAG5RT.js
8844
+ // ../core/dist/chunk-IILWNHNS.js
8106
8845
  var ContentResourceResourceSchema = z2.object({
8107
8846
  resourceId: z2.string(),
8108
8847
  resourceOfId: z2.string(),
@@ -8149,84 +8888,7 @@ var ResourceVisibilitySchema = z2.union([
8149
8888
  z2.literal("unlisted")
8150
8889
  ]);
8151
8890
 
8152
- // ../core/dist/chunk-PG6VF2O6.js
8153
- var resourceProgressSchema = z2.object({
8154
- userId: z2.string().max(191),
8155
- resourceId: z2.string().max(191).optional().nullable(),
8156
- completedAt: z2.date().nullable()
8157
- });
8158
- var moduleProgressSchema = z2.object({
8159
- completedLessons: z2.array(resourceProgressSchema),
8160
- nextResource: ContentResourceSchema.partial().nullable(),
8161
- percentCompleted: z2.number().default(0),
8162
- completedLessonsCount: z2.number().default(0),
8163
- totalLessonsCount: z2.number().default(0)
8164
- });
8165
-
8166
- // ../core/dist/chunk-DLQA3JMA.js
8167
- var upgradableProductSchema = z2.object({
8168
- upgradableToId: z2.string().max(255),
8169
- upgradableFromId: z2.string().max(255),
8170
- position: z2.number().default(0),
8171
- metadata: z2.record(z2.any()).default({}),
8172
- createdAt: z2.date().nullable(),
8173
- updatedAt: z2.date().nullable(),
8174
- deletedAt: z2.date().nullable()
8175
- });
8176
-
8177
- // ../core/dist/chunk-JZBK2DS3.js
8178
- var userSchema = z2.object({
8179
- id: z2.string().max(255),
8180
- name: z2.string().max(255).optional().nullable(),
8181
- role: z2.enum([
8182
- "user",
8183
- "admin"
8184
- ]).default("user"),
8185
- email: z2.string().max(255).email(),
8186
- emailVerified: z2.coerce.date().nullish(),
8187
- image: z2.string().max(255).optional().nullable(),
8188
- createdAt: z2.coerce.date().nullish(),
8189
- memberships: z2.array(z2.object({
8190
- id: z2.string(),
8191
- organizationId: z2.string()
8192
- })).nullish().default([]),
8193
- roles: z2.array(z2.object({
8194
- id: z2.string(),
8195
- name: z2.string(),
8196
- description: z2.string().nullable(),
8197
- active: z2.boolean(),
8198
- createdAt: z2.coerce.date().nullish(),
8199
- updatedAt: z2.coerce.date().nullish(),
8200
- deletedAt: z2.coerce.date().nullish()
8201
- })).optional().default([]),
8202
- organizationRoles: z2.array(z2.object({
8203
- id: z2.string(),
8204
- organizationId: z2.string(),
8205
- name: z2.string(),
8206
- description: z2.string().nullable(),
8207
- active: z2.boolean(),
8208
- createdAt: z2.coerce.date().nullish(),
8209
- updatedAt: z2.coerce.date().nullish(),
8210
- deletedAt: z2.coerce.date().nullish()
8211
- })).optional().default([])
8212
- });
8213
-
8214
- // ../core/dist/chunk-M7IDYIVK.js
8215
- var priceSchema = z2.object({
8216
- id: z2.string().max(191),
8217
- productId: z2.string().max(191).optional().nullable(),
8218
- organizationId: z2.string().max(191).optional().nullable(),
8219
- nickname: z2.string().max(191).optional().nullable(),
8220
- status: z2.number().int().default(0),
8221
- unitAmount: z2.coerce.number().refine((value) => {
8222
- const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8223
- return decimalPlaces <= 2;
8224
- }),
8225
- createdAt: z2.date().nullable(),
8226
- fields: z2.record(z2.any()).default({})
8227
- });
8228
-
8229
- // ../core/dist/chunk-FMAXYBP4.js
8891
+ // ../core/dist/chunk-6HESVS2V.js
8230
8892
  var productSchema = z2.object({
8231
8893
  id: z2.string().max(191),
8232
8894
  organizationId: z2.string().max(191).optional().nullable(),
@@ -8270,10 +8932,64 @@ var productSchema = z2.object({
8270
8932
  var NewProductSchema = z2.object({
8271
8933
  name: z2.string().min(2).max(90),
8272
8934
  quantityAvailable: z2.coerce.number().default(-1),
8273
- price: z2.coerce.number().gte(0).default(0)
8935
+ price: z2.coerce.number().gte(0).default(0),
8936
+ type: z2.enum([
8937
+ "live",
8938
+ "self-paced",
8939
+ "membership",
8940
+ "cohort"
8941
+ ]).default("self-paced").optional(),
8942
+ state: z2.enum([
8943
+ "draft",
8944
+ "published",
8945
+ "archived",
8946
+ "deleted"
8947
+ ]).default("draft").optional(),
8948
+ visibility: z2.enum([
8949
+ "public",
8950
+ "private",
8951
+ "unlisted"
8952
+ ]).default("unlisted").optional()
8953
+ });
8954
+
8955
+ // ../core/dist/chunk-K7QQ3LOH.js
8956
+ var userSchema = z2.object({
8957
+ id: z2.string().max(255),
8958
+ name: z2.string().max(255).optional().nullable(),
8959
+ role: z2.enum([
8960
+ "user",
8961
+ "admin"
8962
+ ]).default("user"),
8963
+ email: z2.string().max(255).email(),
8964
+ emailVerified: z2.coerce.date().nullish(),
8965
+ image: z2.string().max(255).optional().nullable(),
8966
+ createdAt: z2.coerce.date().nullish(),
8967
+ memberships: z2.array(z2.object({
8968
+ id: z2.string(),
8969
+ organizationId: z2.string()
8970
+ })).nullish().default([]),
8971
+ roles: z2.array(z2.object({
8972
+ id: z2.string(),
8973
+ name: z2.string(),
8974
+ description: z2.string().nullable(),
8975
+ active: z2.boolean(),
8976
+ createdAt: z2.coerce.date().nullish(),
8977
+ updatedAt: z2.coerce.date().nullish(),
8978
+ deletedAt: z2.coerce.date().nullish()
8979
+ })).optional().default([]),
8980
+ organizationRoles: z2.array(z2.object({
8981
+ id: z2.string(),
8982
+ organizationId: z2.string(),
8983
+ name: z2.string(),
8984
+ description: z2.string().nullable(),
8985
+ active: z2.boolean(),
8986
+ createdAt: z2.coerce.date().nullish(),
8987
+ updatedAt: z2.coerce.date().nullish(),
8988
+ deletedAt: z2.coerce.date().nullish()
8989
+ })).optional().default([])
8274
8990
  });
8275
8991
 
8276
- // ../core/dist/chunk-K4MXE7BY.js
8992
+ // ../core/dist/chunk-U3NTIXIA.js
8277
8993
  var couponSchema = z2.object({
8278
8994
  id: z2.string(),
8279
8995
  code: z2.string().max(191).optional().nullable(),
@@ -8296,7 +9012,7 @@ var couponSchema = z2.object({
8296
9012
  organizationId: z2.string().max(191).optional().nullable()
8297
9013
  });
8298
9014
 
8299
- // ../core/dist/chunk-MDUGHSSW.js
9015
+ // ../core/dist/chunk-HO5SC2MW.js
8300
9016
  var purchaseSchema = z2.object({
8301
9017
  id: z2.string().max(191),
8302
9018
  userId: z2.string().max(191).optional().nullable(),
@@ -8325,19 +9041,43 @@ var purchaseSchema = z2.object({
8325
9041
  organizationId: z2.string().max(191).optional().nullable()
8326
9042
  });
8327
9043
 
8328
- // ../core/dist/chunk-SGE7BCRS.js
8329
- var merchantChargeSchema = z2.object({
9044
+ // ../core/dist/chunk-CAVIZQBE.js
9045
+ var purchaseUserTransferSchema = z2.object({
8330
9046
  id: z2.string().max(191),
8331
- status: z2.number().int().default(0),
8332
- identifier: z2.string().max(191),
8333
- userId: z2.string().max(191),
8334
- merchantAccountId: z2.string().max(191),
8335
- merchantProductId: z2.string().max(191),
9047
+ transferState: z2.enum([
9048
+ "AVAILABLE",
9049
+ "INITIATED",
9050
+ "VERIFIED",
9051
+ "CANCELED",
9052
+ "EXPIRED",
9053
+ "CONFIRMED",
9054
+ "COMPLETED"
9055
+ ]).default("AVAILABLE"),
9056
+ purchaseId: z2.string().max(191),
9057
+ sourceUserId: z2.string().max(191),
9058
+ targetUserId: z2.string().max(191).optional().nullable(),
8336
9059
  createdAt: z2.date().nullable(),
8337
- merchantCustomerId: z2.string().max(191)
9060
+ expiresAt: z2.date().nullable(),
9061
+ canceledAt: z2.date().nullable(),
9062
+ confirmedAt: z2.date().nullable(),
9063
+ completedAt: z2.date().nullable()
9064
+ });
9065
+
9066
+ // ../core/dist/chunk-NHGTCHSG.js
9067
+ var resourceProgressSchema = z2.object({
9068
+ userId: z2.string().max(191),
9069
+ resourceId: z2.string().max(191).optional().nullable(),
9070
+ completedAt: z2.date().nullable()
9071
+ });
9072
+ var moduleProgressSchema = z2.object({
9073
+ completedLessons: z2.array(resourceProgressSchema),
9074
+ nextResource: ContentResourceSchema.partial().nullable(),
9075
+ percentCompleted: z2.number().default(0),
9076
+ completedLessonsCount: z2.number().default(0),
9077
+ totalLessonsCount: z2.number().default(0)
8338
9078
  });
8339
9079
 
8340
- // ../core/dist/chunk-EDDT2FFU.js
9080
+ // ../core/dist/chunk-KDD22EZI.js
8341
9081
  var merchantCustomerSchema = z2.object({
8342
9082
  id: z2.string().max(191),
8343
9083
  userId: z2.string().max(191),
@@ -8347,7 +9087,7 @@ var merchantCustomerSchema = z2.object({
8347
9087
  status: z2.number().int().default(0)
8348
9088
  });
8349
9089
 
8350
- // ../core/dist/chunk-PS6USEN7.js
9090
+ // ../core/dist/chunk-FYIQS5CC.js
8351
9091
  var merchantPriceSchema = z2.object({
8352
9092
  id: z2.string().max(191),
8353
9093
  merchantAccountId: z2.string().max(191),
@@ -8358,7 +9098,7 @@ var merchantPriceSchema = z2.object({
8358
9098
  priceId: z2.string().max(191).optional().nullable()
8359
9099
  });
8360
9100
 
8361
- // ../core/dist/chunk-DAG4HKGL.js
9101
+ // ../core/dist/chunk-RSPJ5FYR.js
8362
9102
  var merchantProductSchema = z2.object({
8363
9103
  id: z2.string().max(191),
8364
9104
  merchantAccountId: z2.string().max(191),
@@ -8368,7 +9108,19 @@ var merchantProductSchema = z2.object({
8368
9108
  createdAt: z2.date().nullable()
8369
9109
  });
8370
9110
 
8371
- // ../core/dist/chunk-256SROW3.js
9111
+ // ../core/dist/chunk-MS7XHKFQ.js
9112
+ var merchantChargeSchema = z2.object({
9113
+ id: z2.string().max(191),
9114
+ status: z2.number().int().default(0),
9115
+ identifier: z2.string().max(191),
9116
+ userId: z2.string().max(191),
9117
+ merchantAccountId: z2.string().max(191),
9118
+ merchantProductId: z2.string().max(191),
9119
+ createdAt: z2.date().nullable(),
9120
+ merchantCustomerId: z2.string().max(191)
9121
+ });
9122
+
9123
+ // ../core/dist/chunk-BMBVNXO6.js
8372
9124
  var merchantCouponSchema = z2.object({
8373
9125
  id: z2.string().max(191),
8374
9126
  identifier: z2.string().max(191).optional().nullable(),
@@ -8398,7 +9150,7 @@ var MerchantSessionSchema = z2.object({
8398
9150
  merchantAccountId: z2.string()
8399
9151
  });
8400
9152
 
8401
- // ../core/dist/chunk-NCUZHHRE.js
9153
+ // ../core/dist/chunk-7JAN7MEC.js
8402
9154
  var MerchantSubscriptionSchema = z2.object({
8403
9155
  id: z2.string(),
8404
9156
  organizationId: z2.string().nullable(),
@@ -8411,7 +9163,7 @@ var MerchantSubscriptionSchema = z2.object({
8411
9163
  merchantProductId: z2.string()
8412
9164
  });
8413
9165
 
8414
- // ../core/dist/chunk-KQ3HQRWM.js
9166
+ // ../core/dist/chunk-U5E6YHTY.js
8415
9167
  var OrganizationSchema = z2.object({
8416
9168
  id: z2.string(),
8417
9169
  name: z2.string().nullable(),
@@ -11697,6 +12449,8 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core49.mysqlTable, p
11697
12449
  throw new Error(errorMessage);
11698
12450
  }
11699
12451
  const purchaseId = `purchase-${(0, import_uuid.v4)()}`;
12452
+ const userMemberships = await adapter.getMembershipsForUser(user.id);
12453
+ const organizationId = coupon2.organizationId || userMemberships.find((m) => m.organization.name?.includes(user.email))?.organizationId;
11700
12454
  await adapter.createPurchase({
11701
12455
  id: purchaseId,
11702
12456
  userId: user.id,
@@ -11704,6 +12458,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core49.mysqlTable, p
11704
12458
  redeemedBulkCouponId: bulkCouponRedemption ? coupon2.id : null,
11705
12459
  productId,
11706
12460
  totalAmount: "0",
12461
+ organizationId,
11707
12462
  metadata: {
11708
12463
  couponUsedId: bulkCouponRedemption ? null : coupon2.id
11709
12464
  }
@@ -12016,6 +12771,9 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core49.mysqlTable, p
12016
12771
  name,
12017
12772
  emailVerified: null
12018
12773
  });
12774
+ console.log("newUser", {
12775
+ newUser
12776
+ });
12019
12777
  if (!newUser) {
12020
12778
  throw new Error("Could not create user");
12021
12779
  }
@@ -12038,6 +12796,16 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core49.mysqlTable, p
12038
12796
  });
12039
12797
  return couponSchema.nullable().parse(loadedCoupon);
12040
12798
  },
12799
+ async getPurchasesForBulkCouponId(bulkCouponId) {
12800
+ return z.array(purchaseSchema.extend({
12801
+ user: userSchema
12802
+ })).parse(await client.query.purchases.findMany({
12803
+ where: (0, import_drizzle_orm43.eq)(purchaseTable.bulkCouponId, bulkCouponId),
12804
+ with: {
12805
+ user: true
12806
+ }
12807
+ }));
12808
+ },
12041
12809
  async getCouponWithBulkPurchases(couponId) {
12042
12810
  logger.debug("getCouponWithBulkPurchases", {
12043
12811
  couponId
@@ -12419,11 +13187,11 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core49.mysqlTable, p
12419
13187
  id: newProductId,
12420
13188
  name: input.name,
12421
13189
  status: 1,
12422
- type: "self-paced",
13190
+ type: input.type || "self-paced",
12423
13191
  quantityAvailable: input.quantityAvailable,
12424
13192
  fields: {
12425
- state: "draft",
12426
- visibility: "unlisted",
13193
+ state: input.state || "draft",
13194
+ visibility: input.visibility || "unlisted",
12427
13195
  slug: (0, import_slugify.default)(`${input.name}-${hash}`)
12428
13196
  }
12429
13197
  };
@@ -12576,7 +13344,8 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core49.mysqlTable, p
12576
13344
  return purchaseUserTransferSchema.merge(z.object({
12577
13345
  sourceUser: userSchema,
12578
13346
  targetUser: userSchema.nullable(),
12579
- purchase: purchaseSchema
13347
+ purchase: purchaseSchema,
13348
+ organizationId: z.string().nullable()
12580
13349
  })).nullable().parse(purchaseTransferData);
12581
13350
  },
12582
13351
  async getPurchaseWithUser(purchaseId) {
@@ -13191,7 +13960,11 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core49.mysqlTable, p
13191
13960
  },
13192
13961
  addMemberToOrganization: async (options) => {
13193
13962
  const currentMembership = await client.query.organizationMemberships.findFirst({
13194
- where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(organizationMembershipTable.organizationId, options.organizationId), (0, import_drizzle_orm43.eq)(organizationMembershipTable.userId, options.userId))
13963
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(organizationMembershipTable.organizationId, options.organizationId), (0, import_drizzle_orm43.eq)(organizationMembershipTable.userId, options.userId)),
13964
+ with: {
13965
+ organization: true,
13966
+ user: true
13967
+ }
13195
13968
  });
13196
13969
  if (currentMembership) {
13197
13970
  return OrganizationMemberSchema.parse(currentMembership);