@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.
@@ -1,7 +1,3 @@
1
- import {
2
- getEntitlementRelationsSchema,
3
- getEntitlementsSchema
4
- } from "./chunk-253RMSB3.js";
5
1
  import {
6
2
  getLessonProgressSchema
7
3
  } from "./chunk-ET3QAIY7.js";
@@ -11,6 +7,10 @@ import {
11
7
  import {
12
8
  getEntitlementTypesSchema
13
9
  } from "./chunk-ORRM7KVW.js";
10
+ import {
11
+ getEntitlementRelationsSchema,
12
+ getEntitlementsSchema
13
+ } from "./chunk-253RMSB3.js";
14
14
  import {
15
15
  getPurchaseUserTransferRelationsSchema,
16
16
  getPurchaseUserTransferSchema
@@ -137,7 +137,7 @@ import { mysqlTable as defaultMySqlTableFn } from "drizzle-orm/mysql-core";
137
137
  import { customAlphabet } from "nanoid";
138
138
  import { v4 } from "uuid";
139
139
 
140
- // ../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
140
+ // ../../node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.mjs
141
141
  var util;
142
142
  (function(util3) {
143
143
  util3.assertEqual = (val) => val;
@@ -295,6 +295,9 @@ var quotelessJson = /* @__PURE__ */ __name((obj) => {
295
295
  return json.replace(/"([^"]+)":/g, "$1:");
296
296
  }, "quotelessJson");
297
297
  var _ZodError = class _ZodError extends Error {
298
+ get errors() {
299
+ return this.issues;
300
+ }
298
301
  constructor(issues) {
299
302
  super();
300
303
  this.issues = [];
@@ -313,9 +316,6 @@ var _ZodError = class _ZodError extends Error {
313
316
  this.name = "ZodError";
314
317
  this.issues = issues;
315
318
  }
316
- get errors() {
317
- return this.issues;
318
- }
319
319
  format(_mapper) {
320
320
  const mapper = _mapper || function(issue) {
321
321
  return issue.message;
@@ -352,6 +352,11 @@ var _ZodError = class _ZodError extends Error {
352
352
  processError(this);
353
353
  return fieldErrors;
354
354
  }
355
+ static assert(value) {
356
+ if (!(value instanceof _ZodError)) {
357
+ throw new Error(`Not a ZodError: ${value}`);
358
+ }
359
+ }
355
360
  toString() {
356
361
  return this.message;
357
362
  }
@@ -498,6 +503,13 @@ var makeIssue = /* @__PURE__ */ __name((params) => {
498
503
  ...issueData,
499
504
  path: fullPath
500
505
  };
506
+ if (issueData.message !== void 0) {
507
+ return {
508
+ ...issueData,
509
+ path: fullPath,
510
+ message: issueData.message
511
+ };
512
+ }
501
513
  let errorMessage = "";
502
514
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
503
515
  for (const map of maps) {
@@ -506,20 +518,24 @@ var makeIssue = /* @__PURE__ */ __name((params) => {
506
518
  return {
507
519
  ...issueData,
508
520
  path: fullPath,
509
- message: issueData.message || errorMessage
521
+ message: errorMessage
510
522
  };
511
523
  }, "makeIssue");
512
524
  var EMPTY_PATH = [];
513
525
  function addIssueToContext(ctx, issueData) {
526
+ const overrideMap = getErrorMap();
514
527
  const issue = makeIssue({
515
528
  issueData,
516
529
  data: ctx.data,
517
530
  path: ctx.path,
518
531
  errorMaps: [
519
532
  ctx.common.contextualErrorMap,
533
+ // contextual error map is first priority
520
534
  ctx.schemaErrorMap,
521
- getErrorMap(),
522
- errorMap
535
+ // then schema-bound map if available
536
+ overrideMap,
537
+ // then global override map
538
+ overrideMap === errorMap ? void 0 : errorMap
523
539
  // then global default map
524
540
  ].filter((x) => !!x)
525
541
  });
@@ -552,9 +568,11 @@ var _ParseStatus = class _ParseStatus {
552
568
  static async mergeObjectAsync(status, pairs) {
553
569
  const syncPairs = [];
554
570
  for (const pair of pairs) {
571
+ const key = await pair.key;
572
+ const value = await pair.value;
555
573
  syncPairs.push({
556
- key: await pair.key,
557
- value: await pair.value
574
+ key,
575
+ value
558
576
  });
559
577
  }
560
578
  return _ParseStatus.mergeObjectSync(status, syncPairs);
@@ -589,11 +607,31 @@ var isAborted = /* @__PURE__ */ __name((x) => x.status === "aborted", "isAborted
589
607
  var isDirty = /* @__PURE__ */ __name((x) => x.status === "dirty", "isDirty");
590
608
  var isValid = /* @__PURE__ */ __name((x) => x.status === "valid", "isValid");
591
609
  var isAsync = /* @__PURE__ */ __name((x) => typeof Promise !== "undefined" && x instanceof Promise, "isAsync");
610
+ function __classPrivateFieldGet(receiver, state, kind, f) {
611
+ if (kind === "a" && !f)
612
+ throw new TypeError("Private accessor was defined without a getter");
613
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
614
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
615
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
616
+ }
617
+ __name(__classPrivateFieldGet, "__classPrivateFieldGet");
618
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
619
+ if (kind === "m")
620
+ throw new TypeError("Private method is not writable");
621
+ if (kind === "a" && !f)
622
+ throw new TypeError("Private accessor was defined without a setter");
623
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
624
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
625
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
626
+ }
627
+ __name(__classPrivateFieldSet, "__classPrivateFieldSet");
592
628
  var errorUtil;
593
629
  (function(errorUtil3) {
594
630
  errorUtil3.errToObj = (message) => typeof message === "string" ? { message } : message || {};
595
631
  errorUtil3.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
596
632
  })(errorUtil || (errorUtil = {}));
633
+ var _ZodEnum_cache;
634
+ var _ZodNativeEnum_cache;
597
635
  var _ParseInputLazyPath = class _ParseInputLazyPath {
598
636
  constructor(parent, value, path, key) {
599
637
  this._cachedPath = [];
@@ -644,45 +682,22 @@ function processCreateParams(params) {
644
682
  if (errorMap3)
645
683
  return { errorMap: errorMap3, description };
646
684
  const customMap = /* @__PURE__ */ __name((iss, ctx) => {
647
- if (iss.code !== "invalid_type")
648
- return { message: ctx.defaultError };
685
+ var _a46, _b;
686
+ const { message } = params;
687
+ if (iss.code === "invalid_enum_value") {
688
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
689
+ }
649
690
  if (typeof ctx.data === "undefined") {
650
- return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
691
+ return { message: (_a46 = message !== null && message !== void 0 ? message : required_error) !== null && _a46 !== void 0 ? _a46 : ctx.defaultError };
651
692
  }
652
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
693
+ if (iss.code !== "invalid_type")
694
+ return { message: ctx.defaultError };
695
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
653
696
  }, "customMap");
654
697
  return { errorMap: customMap, description };
655
698
  }
656
699
  __name(processCreateParams, "processCreateParams");
657
700
  var _ZodType = class _ZodType {
658
- constructor(def) {
659
- this.spa = this.safeParseAsync;
660
- this._def = def;
661
- this.parse = this.parse.bind(this);
662
- this.safeParse = this.safeParse.bind(this);
663
- this.parseAsync = this.parseAsync.bind(this);
664
- this.safeParseAsync = this.safeParseAsync.bind(this);
665
- this.spa = this.spa.bind(this);
666
- this.refine = this.refine.bind(this);
667
- this.refinement = this.refinement.bind(this);
668
- this.superRefine = this.superRefine.bind(this);
669
- this.optional = this.optional.bind(this);
670
- this.nullable = this.nullable.bind(this);
671
- this.nullish = this.nullish.bind(this);
672
- this.array = this.array.bind(this);
673
- this.promise = this.promise.bind(this);
674
- this.or = this.or.bind(this);
675
- this.and = this.and.bind(this);
676
- this.transform = this.transform.bind(this);
677
- this.brand = this.brand.bind(this);
678
- this.default = this.default.bind(this);
679
- this.catch = this.catch.bind(this);
680
- this.describe = this.describe.bind(this);
681
- this.pipe = this.pipe.bind(this);
682
- this.readonly = this.readonly.bind(this);
683
- this.isNullable = this.isNullable.bind(this);
684
- this.isOptional = this.isOptional.bind(this);
685
- }
686
701
  get description() {
687
702
  return this._def.description;
688
703
  }
@@ -746,6 +761,43 @@ var _ZodType = class _ZodType {
746
761
  const result = this._parseSync({ data, path: ctx.path, parent: ctx });
747
762
  return handleResult(ctx, result);
748
763
  }
764
+ "~validate"(data) {
765
+ var _a46, _b;
766
+ const ctx = {
767
+ common: {
768
+ issues: [],
769
+ async: !!this["~standard"].async
770
+ },
771
+ path: [],
772
+ schemaErrorMap: this._def.errorMap,
773
+ parent: null,
774
+ data,
775
+ parsedType: getParsedType(data)
776
+ };
777
+ if (!this["~standard"].async) {
778
+ try {
779
+ const result = this._parseSync({ data, path: [], parent: ctx });
780
+ return isValid(result) ? {
781
+ value: result.value
782
+ } : {
783
+ issues: ctx.common.issues
784
+ };
785
+ } catch (err) {
786
+ 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")) {
787
+ this["~standard"].async = true;
788
+ }
789
+ ctx.common = {
790
+ issues: [],
791
+ async: true
792
+ };
793
+ }
794
+ }
795
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
796
+ value: result.value
797
+ } : {
798
+ issues: ctx.common.issues
799
+ });
800
+ }
749
801
  async parseAsync(data, params) {
750
802
  const result = await this.safeParseAsync(data, params);
751
803
  if (result.success)
@@ -823,6 +875,39 @@ var _ZodType = class _ZodType {
823
875
  superRefine(refinement) {
824
876
  return this._refinement(refinement);
825
877
  }
878
+ constructor(def) {
879
+ this.spa = this.safeParseAsync;
880
+ this._def = def;
881
+ this.parse = this.parse.bind(this);
882
+ this.safeParse = this.safeParse.bind(this);
883
+ this.parseAsync = this.parseAsync.bind(this);
884
+ this.safeParseAsync = this.safeParseAsync.bind(this);
885
+ this.spa = this.spa.bind(this);
886
+ this.refine = this.refine.bind(this);
887
+ this.refinement = this.refinement.bind(this);
888
+ this.superRefine = this.superRefine.bind(this);
889
+ this.optional = this.optional.bind(this);
890
+ this.nullable = this.nullable.bind(this);
891
+ this.nullish = this.nullish.bind(this);
892
+ this.array = this.array.bind(this);
893
+ this.promise = this.promise.bind(this);
894
+ this.or = this.or.bind(this);
895
+ this.and = this.and.bind(this);
896
+ this.transform = this.transform.bind(this);
897
+ this.brand = this.brand.bind(this);
898
+ this.default = this.default.bind(this);
899
+ this.catch = this.catch.bind(this);
900
+ this.describe = this.describe.bind(this);
901
+ this.pipe = this.pipe.bind(this);
902
+ this.readonly = this.readonly.bind(this);
903
+ this.isNullable = this.isNullable.bind(this);
904
+ this.isOptional = this.isOptional.bind(this);
905
+ this["~standard"] = {
906
+ version: 1,
907
+ vendor: "zod",
908
+ validate: (data) => this["~validate"](data)
909
+ };
910
+ }
826
911
  optional() {
827
912
  return ZodOptional.create(this, this._def);
828
913
  }
@@ -833,7 +918,7 @@ var _ZodType = class _ZodType {
833
918
  return this.nullable().optional();
834
919
  }
835
920
  array() {
836
- return ZodArray.create(this, this._def);
921
+ return ZodArray.create(this);
837
922
  }
838
923
  promise() {
839
924
  return ZodPromise.create(this, this._def);
@@ -900,35 +985,47 @@ var _ZodType = class _ZodType {
900
985
  __name(_ZodType, "ZodType");
901
986
  var ZodType = _ZodType;
902
987
  var cuidRegex = /^c[^\s-]{8,}$/i;
903
- var cuid2Regex = /^[a-z][a-z0-9]*$/;
904
- var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
988
+ var cuid2Regex = /^[0-9a-z]+$/;
989
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
905
990
  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;
906
- var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
991
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
992
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
993
+ 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)?)??$/;
994
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
907
995
  var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
908
996
  var emojiRegex;
909
- 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}))$/;
910
- 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})))$/;
911
- var datetimeRegex = /* @__PURE__ */ __name((args) => {
997
+ 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])$/;
998
+ 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])$/;
999
+ 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]))$/;
1000
+ 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])$/;
1001
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1002
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
1003
+ 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])))`;
1004
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
1005
+ function timeRegexSource(args) {
1006
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
912
1007
  if (args.precision) {
913
- if (args.offset) {
914
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
915
- } else {
916
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
917
- }
918
- } else if (args.precision === 0) {
919
- if (args.offset) {
920
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
921
- } else {
922
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
923
- }
924
- } else {
925
- if (args.offset) {
926
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
927
- } else {
928
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
929
- }
1008
+ regex = `${regex}\\.\\d{${args.precision}}`;
1009
+ } else if (args.precision == null) {
1010
+ regex = `${regex}(\\.\\d+)?`;
930
1011
  }
931
- }, "datetimeRegex");
1012
+ return regex;
1013
+ }
1014
+ __name(timeRegexSource, "timeRegexSource");
1015
+ function timeRegex(args) {
1016
+ return new RegExp(`^${timeRegexSource(args)}$`);
1017
+ }
1018
+ __name(timeRegex, "timeRegex");
1019
+ function datetimeRegex(args) {
1020
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
1021
+ const opts = [];
1022
+ opts.push(args.local ? `Z?` : `Z`);
1023
+ if (args.offset)
1024
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
1025
+ regex = `${regex}(${opts.join("|")})`;
1026
+ return new RegExp(`^${regex}$`);
1027
+ }
1028
+ __name(datetimeRegex, "datetimeRegex");
932
1029
  function isValidIP(ip, version) {
933
1030
  if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
934
1031
  return true;
@@ -939,6 +1036,35 @@ function isValidIP(ip, version) {
939
1036
  return false;
940
1037
  }
941
1038
  __name(isValidIP, "isValidIP");
1039
+ function isValidJWT(jwt, alg) {
1040
+ if (!jwtRegex.test(jwt))
1041
+ return false;
1042
+ try {
1043
+ const [header] = jwt.split(".");
1044
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
1045
+ const decoded = JSON.parse(atob(base64));
1046
+ if (typeof decoded !== "object" || decoded === null)
1047
+ return false;
1048
+ if (!decoded.typ || !decoded.alg)
1049
+ return false;
1050
+ if (alg && decoded.alg !== alg)
1051
+ return false;
1052
+ return true;
1053
+ } catch (_a46) {
1054
+ return false;
1055
+ }
1056
+ }
1057
+ __name(isValidJWT, "isValidJWT");
1058
+ function isValidCidr(ip, version) {
1059
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
1060
+ return true;
1061
+ }
1062
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
1063
+ return true;
1064
+ }
1065
+ return false;
1066
+ }
1067
+ __name(isValidCidr, "isValidCidr");
942
1068
  var _ZodString = class _ZodString extends ZodType {
943
1069
  _parse(input) {
944
1070
  if (this._def.coerce) {
@@ -947,15 +1073,11 @@ var _ZodString = class _ZodString extends ZodType {
947
1073
  const parsedType = this._getType(input);
948
1074
  if (parsedType !== ZodParsedType.string) {
949
1075
  const ctx2 = this._getOrReturnCtx(input);
950
- addIssueToContext(
951
- ctx2,
952
- {
953
- code: ZodIssueCode.invalid_type,
954
- expected: ZodParsedType.string,
955
- received: ctx2.parsedType
956
- }
957
- //
958
- );
1076
+ addIssueToContext(ctx2, {
1077
+ code: ZodIssueCode.invalid_type,
1078
+ expected: ZodParsedType.string,
1079
+ received: ctx2.parsedType
1080
+ });
959
1081
  return INVALID;
960
1082
  }
961
1083
  const status = new ParseStatus();
@@ -1046,6 +1168,16 @@ var _ZodString = class _ZodString extends ZodType {
1046
1168
  });
1047
1169
  status.dirty();
1048
1170
  }
1171
+ } else if (check.kind === "nanoid") {
1172
+ if (!nanoidRegex.test(input.data)) {
1173
+ ctx = this._getOrReturnCtx(input, ctx);
1174
+ addIssueToContext(ctx, {
1175
+ validation: "nanoid",
1176
+ code: ZodIssueCode.invalid_string,
1177
+ message: check.message
1178
+ });
1179
+ status.dirty();
1180
+ }
1049
1181
  } else if (check.kind === "cuid") {
1050
1182
  if (!cuidRegex.test(input.data)) {
1051
1183
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1147,6 +1279,38 @@ var _ZodString = class _ZodString extends ZodType {
1147
1279
  });
1148
1280
  status.dirty();
1149
1281
  }
1282
+ } else if (check.kind === "date") {
1283
+ const regex = dateRegex;
1284
+ if (!regex.test(input.data)) {
1285
+ ctx = this._getOrReturnCtx(input, ctx);
1286
+ addIssueToContext(ctx, {
1287
+ code: ZodIssueCode.invalid_string,
1288
+ validation: "date",
1289
+ message: check.message
1290
+ });
1291
+ status.dirty();
1292
+ }
1293
+ } else if (check.kind === "time") {
1294
+ const regex = timeRegex(check);
1295
+ if (!regex.test(input.data)) {
1296
+ ctx = this._getOrReturnCtx(input, ctx);
1297
+ addIssueToContext(ctx, {
1298
+ code: ZodIssueCode.invalid_string,
1299
+ validation: "time",
1300
+ message: check.message
1301
+ });
1302
+ status.dirty();
1303
+ }
1304
+ } else if (check.kind === "duration") {
1305
+ if (!durationRegex.test(input.data)) {
1306
+ ctx = this._getOrReturnCtx(input, ctx);
1307
+ addIssueToContext(ctx, {
1308
+ validation: "duration",
1309
+ code: ZodIssueCode.invalid_string,
1310
+ message: check.message
1311
+ });
1312
+ status.dirty();
1313
+ }
1150
1314
  } else if (check.kind === "ip") {
1151
1315
  if (!isValidIP(input.data, check.version)) {
1152
1316
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1157,6 +1321,46 @@ var _ZodString = class _ZodString extends ZodType {
1157
1321
  });
1158
1322
  status.dirty();
1159
1323
  }
1324
+ } else if (check.kind === "jwt") {
1325
+ if (!isValidJWT(input.data, check.alg)) {
1326
+ ctx = this._getOrReturnCtx(input, ctx);
1327
+ addIssueToContext(ctx, {
1328
+ validation: "jwt",
1329
+ code: ZodIssueCode.invalid_string,
1330
+ message: check.message
1331
+ });
1332
+ status.dirty();
1333
+ }
1334
+ } else if (check.kind === "cidr") {
1335
+ if (!isValidCidr(input.data, check.version)) {
1336
+ ctx = this._getOrReturnCtx(input, ctx);
1337
+ addIssueToContext(ctx, {
1338
+ validation: "cidr",
1339
+ code: ZodIssueCode.invalid_string,
1340
+ message: check.message
1341
+ });
1342
+ status.dirty();
1343
+ }
1344
+ } else if (check.kind === "base64") {
1345
+ if (!base64Regex.test(input.data)) {
1346
+ ctx = this._getOrReturnCtx(input, ctx);
1347
+ addIssueToContext(ctx, {
1348
+ validation: "base64",
1349
+ code: ZodIssueCode.invalid_string,
1350
+ message: check.message
1351
+ });
1352
+ status.dirty();
1353
+ }
1354
+ } else if (check.kind === "base64url") {
1355
+ if (!base64urlRegex.test(input.data)) {
1356
+ ctx = this._getOrReturnCtx(input, ctx);
1357
+ addIssueToContext(ctx, {
1358
+ validation: "base64url",
1359
+ code: ZodIssueCode.invalid_string,
1360
+ message: check.message
1361
+ });
1362
+ status.dirty();
1363
+ }
1160
1364
  } else {
1161
1365
  util.assertNever(check);
1162
1366
  }
@@ -1188,6 +1392,9 @@ var _ZodString = class _ZodString extends ZodType {
1188
1392
  uuid(message) {
1189
1393
  return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1190
1394
  }
1395
+ nanoid(message) {
1396
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1397
+ }
1191
1398
  cuid(message) {
1192
1399
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1193
1400
  }
@@ -1197,16 +1404,32 @@ var _ZodString = class _ZodString extends ZodType {
1197
1404
  ulid(message) {
1198
1405
  return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1199
1406
  }
1407
+ base64(message) {
1408
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1409
+ }
1410
+ base64url(message) {
1411
+ return this._addCheck({
1412
+ kind: "base64url",
1413
+ ...errorUtil.errToObj(message)
1414
+ });
1415
+ }
1416
+ jwt(options) {
1417
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
1418
+ }
1200
1419
  ip(options) {
1201
1420
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1202
1421
  }
1422
+ cidr(options) {
1423
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
1424
+ }
1203
1425
  datetime(options) {
1204
- var _a46;
1426
+ var _a46, _b;
1205
1427
  if (typeof options === "string") {
1206
1428
  return this._addCheck({
1207
1429
  kind: "datetime",
1208
1430
  precision: null,
1209
1431
  offset: false,
1432
+ local: false,
1210
1433
  message: options
1211
1434
  });
1212
1435
  }
@@ -1214,9 +1437,30 @@ var _ZodString = class _ZodString extends ZodType {
1214
1437
  kind: "datetime",
1215
1438
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1216
1439
  offset: (_a46 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a46 !== void 0 ? _a46 : false,
1440
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
1217
1441
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1218
1442
  });
1219
1443
  }
1444
+ date(message) {
1445
+ return this._addCheck({ kind: "date", message });
1446
+ }
1447
+ time(options) {
1448
+ if (typeof options === "string") {
1449
+ return this._addCheck({
1450
+ kind: "time",
1451
+ precision: null,
1452
+ message: options
1453
+ });
1454
+ }
1455
+ return this._addCheck({
1456
+ kind: "time",
1457
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1458
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1459
+ });
1460
+ }
1461
+ duration(message) {
1462
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1463
+ }
1220
1464
  regex(regex, message) {
1221
1465
  return this._addCheck({
1222
1466
  kind: "regex",
@@ -1268,8 +1512,7 @@ var _ZodString = class _ZodString extends ZodType {
1268
1512
  });
1269
1513
  }
1270
1514
  /**
1271
- * @deprecated Use z.string().min(1) instead.
1272
- * @see {@link ZodString.min}
1515
+ * Equivalent to `.min(1)`
1273
1516
  */
1274
1517
  nonempty(message) {
1275
1518
  return this.min(1, errorUtil.errToObj(message));
@@ -1295,6 +1538,15 @@ var _ZodString = class _ZodString extends ZodType {
1295
1538
  get isDatetime() {
1296
1539
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
1297
1540
  }
1541
+ get isDate() {
1542
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1543
+ }
1544
+ get isTime() {
1545
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1546
+ }
1547
+ get isDuration() {
1548
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1549
+ }
1298
1550
  get isEmail() {
1299
1551
  return !!this._def.checks.find((ch) => ch.kind === "email");
1300
1552
  }
@@ -1307,6 +1559,9 @@ var _ZodString = class _ZodString extends ZodType {
1307
1559
  get isUUID() {
1308
1560
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
1309
1561
  }
1562
+ get isNANOID() {
1563
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1564
+ }
1310
1565
  get isCUID() {
1311
1566
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
1312
1567
  }
@@ -1319,6 +1574,15 @@ var _ZodString = class _ZodString extends ZodType {
1319
1574
  get isIP() {
1320
1575
  return !!this._def.checks.find((ch) => ch.kind === "ip");
1321
1576
  }
1577
+ get isCIDR() {
1578
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
1579
+ }
1580
+ get isBase64() {
1581
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1582
+ }
1583
+ get isBase64url() {
1584
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
1585
+ }
1322
1586
  get minLength() {
1323
1587
  let min = null;
1324
1588
  for (const ch of this._def.checks) {
@@ -1601,17 +1865,15 @@ var _ZodBigInt = class _ZodBigInt extends ZodType {
1601
1865
  }
1602
1866
  _parse(input) {
1603
1867
  if (this._def.coerce) {
1604
- input.data = BigInt(input.data);
1868
+ try {
1869
+ input.data = BigInt(input.data);
1870
+ } catch (_a46) {
1871
+ return this._getInvalidInput(input);
1872
+ }
1605
1873
  }
1606
1874
  const parsedType = this._getType(input);
1607
1875
  if (parsedType !== ZodParsedType.bigint) {
1608
- const ctx2 = this._getOrReturnCtx(input);
1609
- addIssueToContext(ctx2, {
1610
- code: ZodIssueCode.invalid_type,
1611
- expected: ZodParsedType.bigint,
1612
- received: ctx2.parsedType
1613
- });
1614
- return INVALID;
1876
+ return this._getInvalidInput(input);
1615
1877
  }
1616
1878
  let ctx = void 0;
1617
1879
  const status = new ParseStatus();
@@ -1658,6 +1920,15 @@ var _ZodBigInt = class _ZodBigInt extends ZodType {
1658
1920
  }
1659
1921
  return { status: status.value, value: input.data };
1660
1922
  }
1923
+ _getInvalidInput(input) {
1924
+ const ctx = this._getOrReturnCtx(input);
1925
+ addIssueToContext(ctx, {
1926
+ code: ZodIssueCode.invalid_type,
1927
+ expected: ZodParsedType.bigint,
1928
+ received: ctx.parsedType
1929
+ });
1930
+ return INVALID;
1931
+ }
1661
1932
  gte(value, message) {
1662
1933
  return this.setLimit("min", value, true, errorUtil.toString(message));
1663
1934
  }
@@ -2260,9 +2531,10 @@ var _ZodObject = class _ZodObject extends ZodType {
2260
2531
  const syncPairs = [];
2261
2532
  for (const pair of pairs) {
2262
2533
  const key = await pair.key;
2534
+ const value = await pair.value;
2263
2535
  syncPairs.push({
2264
2536
  key,
2265
- value: await pair.value,
2537
+ value,
2266
2538
  alwaysSet: pair.alwaysSet
2267
2539
  });
2268
2540
  }
@@ -2618,15 +2890,25 @@ var getDiscriminator = /* @__PURE__ */ __name((type) => {
2618
2890
  } else if (type instanceof ZodEnum) {
2619
2891
  return type.options;
2620
2892
  } else if (type instanceof ZodNativeEnum) {
2621
- return Object.keys(type.enum);
2893
+ return util.objectValues(type.enum);
2622
2894
  } else if (type instanceof ZodDefault) {
2623
2895
  return getDiscriminator(type._def.innerType);
2624
2896
  } else if (type instanceof ZodUndefined) {
2625
2897
  return [void 0];
2626
2898
  } else if (type instanceof ZodNull) {
2627
2899
  return [null];
2900
+ } else if (type instanceof ZodOptional) {
2901
+ return [void 0, ...getDiscriminator(type.unwrap())];
2902
+ } else if (type instanceof ZodNullable) {
2903
+ return [null, ...getDiscriminator(type.unwrap())];
2904
+ } else if (type instanceof ZodBranded) {
2905
+ return getDiscriminator(type.unwrap());
2906
+ } else if (type instanceof ZodReadonly) {
2907
+ return getDiscriminator(type.unwrap());
2908
+ } else if (type instanceof ZodCatch) {
2909
+ return getDiscriminator(type._def.innerType);
2628
2910
  } else {
2629
- return null;
2911
+ return [];
2630
2912
  }
2631
2913
  }, "getDiscriminator");
2632
2914
  var _ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
@@ -2686,7 +2968,7 @@ var _ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2686
2968
  const optionsMap = /* @__PURE__ */ new Map();
2687
2969
  for (const type of options) {
2688
2970
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2689
- if (!discriminatorValues) {
2971
+ if (!discriminatorValues.length) {
2690
2972
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2691
2973
  }
2692
2974
  for (const value of discriminatorValues) {
@@ -2893,7 +3175,8 @@ var _ZodRecord = class _ZodRecord extends ZodType {
2893
3175
  for (const key in ctx.data) {
2894
3176
  pairs.push({
2895
3177
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2896
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
3178
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3179
+ alwaysSet: key in ctx.data
2897
3180
  });
2898
3181
  }
2899
3182
  if (ctx.common.async) {
@@ -3253,6 +3536,10 @@ function createZodEnum(values, params) {
3253
3536
  }
3254
3537
  __name(createZodEnum, "createZodEnum");
3255
3538
  var _ZodEnum = class _ZodEnum extends ZodType {
3539
+ constructor() {
3540
+ super(...arguments);
3541
+ _ZodEnum_cache.set(this, void 0);
3542
+ }
3256
3543
  _parse(input) {
3257
3544
  if (typeof input.data !== "string") {
3258
3545
  const ctx = this._getOrReturnCtx(input);
@@ -3264,7 +3551,10 @@ var _ZodEnum = class _ZodEnum extends ZodType {
3264
3551
  });
3265
3552
  return INVALID;
3266
3553
  }
3267
- if (this._def.values.indexOf(input.data) === -1) {
3554
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
3555
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
3556
+ }
3557
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3268
3558
  const ctx = this._getOrReturnCtx(input);
3269
3559
  const expectedValues = this._def.values;
3270
3560
  addIssueToContext(ctx, {
@@ -3300,17 +3590,28 @@ var _ZodEnum = class _ZodEnum extends ZodType {
3300
3590
  }
3301
3591
  return enumValues;
3302
3592
  }
3303
- extract(values) {
3304
- return _ZodEnum.create(values);
3593
+ extract(values, newDef = this._def) {
3594
+ return _ZodEnum.create(values, {
3595
+ ...this._def,
3596
+ ...newDef
3597
+ });
3305
3598
  }
3306
- exclude(values) {
3307
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
3599
+ exclude(values, newDef = this._def) {
3600
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3601
+ ...this._def,
3602
+ ...newDef
3603
+ });
3308
3604
  }
3309
3605
  };
3310
3606
  __name(_ZodEnum, "ZodEnum");
3311
3607
  var ZodEnum = _ZodEnum;
3608
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3312
3609
  ZodEnum.create = createZodEnum;
3313
3610
  var _ZodNativeEnum = class _ZodNativeEnum extends ZodType {
3611
+ constructor() {
3612
+ super(...arguments);
3613
+ _ZodNativeEnum_cache.set(this, void 0);
3614
+ }
3314
3615
  _parse(input) {
3315
3616
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3316
3617
  const ctx = this._getOrReturnCtx(input);
@@ -3323,7 +3624,10 @@ var _ZodNativeEnum = class _ZodNativeEnum extends ZodType {
3323
3624
  });
3324
3625
  return INVALID;
3325
3626
  }
3326
- if (nativeEnumValues.indexOf(input.data) === -1) {
3627
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
3628
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
3629
+ }
3630
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3327
3631
  const expectedValues = util.objectValues(nativeEnumValues);
3328
3632
  addIssueToContext(ctx, {
3329
3633
  received: ctx.data,
@@ -3340,6 +3644,7 @@ var _ZodNativeEnum = class _ZodNativeEnum extends ZodType {
3340
3644
  };
3341
3645
  __name(_ZodNativeEnum, "ZodNativeEnum");
3342
3646
  var ZodNativeEnum = _ZodNativeEnum;
3647
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3343
3648
  ZodNativeEnum.create = (values, params) => {
3344
3649
  return new ZodNativeEnum({
3345
3650
  values,
@@ -3405,26 +3710,38 @@ var _ZodEffects = class _ZodEffects extends ZodType {
3405
3710
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3406
3711
  if (effect.type === "preprocess") {
3407
3712
  const processed = effect.transform(ctx.data, checkCtx);
3408
- if (ctx.common.issues.length) {
3409
- return {
3410
- status: "dirty",
3411
- value: ctx.data
3412
- };
3413
- }
3414
3713
  if (ctx.common.async) {
3415
- return Promise.resolve(processed).then((processed2) => {
3416
- return this._def.schema._parseAsync({
3714
+ return Promise.resolve(processed).then(async (processed2) => {
3715
+ if (status.value === "aborted")
3716
+ return INVALID;
3717
+ const result = await this._def.schema._parseAsync({
3417
3718
  data: processed2,
3418
3719
  path: ctx.path,
3419
3720
  parent: ctx
3420
3721
  });
3722
+ if (result.status === "aborted")
3723
+ return INVALID;
3724
+ if (result.status === "dirty")
3725
+ return DIRTY(result.value);
3726
+ if (status.value === "dirty")
3727
+ return DIRTY(result.value);
3728
+ return result;
3421
3729
  });
3422
3730
  } else {
3423
- return this._def.schema._parseSync({
3731
+ if (status.value === "aborted")
3732
+ return INVALID;
3733
+ const result = this._def.schema._parseSync({
3424
3734
  data: processed,
3425
3735
  path: ctx.path,
3426
3736
  parent: ctx
3427
3737
  });
3738
+ if (result.status === "aborted")
3739
+ return INVALID;
3740
+ if (result.status === "dirty")
3741
+ return DIRTY(result.value);
3742
+ if (status.value === "dirty")
3743
+ return DIRTY(result.value);
3744
+ return result;
3428
3745
  }
3429
3746
  }
3430
3747
  if (effect.type === "refinement") {
@@ -3729,10 +4046,16 @@ var ZodPipeline = _ZodPipeline;
3729
4046
  var _ZodReadonly = class _ZodReadonly extends ZodType {
3730
4047
  _parse(input) {
3731
4048
  const result = this._def.innerType._parse(input);
3732
- if (isValid(result)) {
3733
- result.value = Object.freeze(result.value);
3734
- }
3735
- return result;
4049
+ const freeze = /* @__PURE__ */ __name((data) => {
4050
+ if (isValid(data)) {
4051
+ data.value = Object.freeze(data.value);
4052
+ }
4053
+ return data;
4054
+ }, "freeze");
4055
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
4056
+ }
4057
+ unwrap() {
4058
+ return this._def.innerType;
3736
4059
  }
3737
4060
  };
3738
4061
  __name(_ZodReadonly, "ZodReadonly");
@@ -3744,19 +4067,37 @@ ZodReadonly.create = (type, params) => {
3744
4067
  ...processCreateParams(params)
3745
4068
  });
3746
4069
  };
3747
- var custom = /* @__PURE__ */ __name((check, params = {}, fatal) => {
4070
+ function cleanParams(params, data) {
4071
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
4072
+ const p2 = typeof p === "string" ? { message: p } : p;
4073
+ return p2;
4074
+ }
4075
+ __name(cleanParams, "cleanParams");
4076
+ function custom(check, _params = {}, fatal) {
3748
4077
  if (check)
3749
4078
  return ZodAny.create().superRefine((data, ctx) => {
3750
4079
  var _a46, _b;
3751
- if (!check(data)) {
3752
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3753
- const _fatal = (_b = (_a46 = p.fatal) !== null && _a46 !== void 0 ? _a46 : fatal) !== null && _b !== void 0 ? _b : true;
3754
- const p2 = typeof p === "string" ? { message: p } : p;
3755
- ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
4080
+ const r = check(data);
4081
+ if (r instanceof Promise) {
4082
+ return r.then((r2) => {
4083
+ var _a47, _b2;
4084
+ if (!r2) {
4085
+ const params = cleanParams(_params, data);
4086
+ const _fatal = (_b2 = (_a47 = params.fatal) !== null && _a47 !== void 0 ? _a47 : fatal) !== null && _b2 !== void 0 ? _b2 : true;
4087
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
4088
+ }
4089
+ });
4090
+ }
4091
+ if (!r) {
4092
+ const params = cleanParams(_params, data);
4093
+ const _fatal = (_b = (_a46 = params.fatal) !== null && _a46 !== void 0 ? _a46 : fatal) !== null && _b !== void 0 ? _b : true;
4094
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3756
4095
  }
4096
+ return;
3757
4097
  });
3758
4098
  return ZodAny.create();
3759
- }, "custom");
4099
+ }
4100
+ __name(custom, "custom");
3760
4101
  var late = {
3761
4102
  object: ZodObject.lazycreate
3762
4103
  };
@@ -3875,6 +4216,7 @@ var z = /* @__PURE__ */ Object.freeze({
3875
4216
  ZodParsedType,
3876
4217
  getParsedType,
3877
4218
  ZodType,
4219
+ datetimeRegex,
3878
4220
  ZodString,
3879
4221
  ZodNumber,
3880
4222
  ZodBigInt,
@@ -3983,7 +4325,7 @@ var __publicField = /* @__PURE__ */ __name((obj, key, value) => {
3983
4325
  return value;
3984
4326
  }, "__publicField");
3985
4327
 
3986
- // ../core/dist/chunk-GH4VK5VM.js
4328
+ // ../core/dist/chunk-JLNB6NRA.js
3987
4329
  var util2;
3988
4330
  (function(util22) {
3989
4331
  util22.assertEqual = (val) => val;
@@ -4144,6 +4486,9 @@ var quotelessJson2 = /* @__PURE__ */ __name2((obj) => {
4144
4486
  }, "quotelessJson");
4145
4487
  var _a;
4146
4488
  var _ZodError2 = (_a = class extends Error {
4489
+ get errors() {
4490
+ return this.issues;
4491
+ }
4147
4492
  constructor(issues) {
4148
4493
  super();
4149
4494
  this.issues = [];
@@ -4168,9 +4513,6 @@ var _ZodError2 = (_a = class extends Error {
4168
4513
  this.name = "ZodError";
4169
4514
  this.issues = issues;
4170
4515
  }
4171
- get errors() {
4172
- return this.issues;
4173
- }
4174
4516
  format(_mapper) {
4175
4517
  const mapper = _mapper || function(issue) {
4176
4518
  return issue.message;
@@ -4213,6 +4555,11 @@ var _ZodError2 = (_a = class extends Error {
4213
4555
  processError(this);
4214
4556
  return fieldErrors;
4215
4557
  }
4558
+ static assert(value) {
4559
+ if (!(value instanceof _a)) {
4560
+ throw new Error(`Not a ZodError: ${value}`);
4561
+ }
4562
+ }
4216
4563
  toString() {
4217
4564
  return this.message;
4218
4565
  }
@@ -4369,6 +4716,13 @@ var makeIssue2 = /* @__PURE__ */ __name2((params) => {
4369
4716
  ...issueData,
4370
4717
  path: fullPath
4371
4718
  };
4719
+ if (issueData.message !== void 0) {
4720
+ return {
4721
+ ...issueData,
4722
+ path: fullPath,
4723
+ message: issueData.message
4724
+ };
4725
+ }
4372
4726
  let errorMessage = "";
4373
4727
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
4374
4728
  for (const map of maps) {
@@ -4380,20 +4734,24 @@ var makeIssue2 = /* @__PURE__ */ __name2((params) => {
4380
4734
  return {
4381
4735
  ...issueData,
4382
4736
  path: fullPath,
4383
- message: issueData.message || errorMessage
4737
+ message: errorMessage
4384
4738
  };
4385
4739
  }, "makeIssue");
4386
4740
  var EMPTY_PATH2 = [];
4387
4741
  function addIssueToContext2(ctx, issueData) {
4742
+ const overrideMap = getErrorMap2();
4388
4743
  const issue = makeIssue2({
4389
4744
  issueData,
4390
4745
  data: ctx.data,
4391
4746
  path: ctx.path,
4392
4747
  errorMaps: [
4393
4748
  ctx.common.contextualErrorMap,
4749
+ // contextual error map is first priority
4394
4750
  ctx.schemaErrorMap,
4395
- getErrorMap2(),
4396
- errorMap2
4751
+ // then schema-bound map if available
4752
+ overrideMap,
4753
+ // then global override map
4754
+ overrideMap === errorMap2 ? void 0 : errorMap2
4397
4755
  ].filter((x) => !!x)
4398
4756
  });
4399
4757
  ctx.common.issues.push(issue);
@@ -4430,9 +4788,11 @@ var _ParseStatus2 = (_a2 = class {
4430
4788
  static async mergeObjectAsync(status, pairs) {
4431
4789
  const syncPairs = [];
4432
4790
  for (const pair of pairs) {
4791
+ const key = await pair.key;
4792
+ const value = await pair.value;
4433
4793
  syncPairs.push({
4434
- key: await pair.key,
4435
- value: await pair.value
4794
+ key,
4795
+ value
4436
4796
  });
4437
4797
  }
4438
4798
  return _a2.mergeObjectSync(status, syncPairs);
@@ -4476,6 +4836,26 @@ var isAborted2 = /* @__PURE__ */ __name2((x) => x.status === "aborted", "isAbort
4476
4836
  var isDirty2 = /* @__PURE__ */ __name2((x) => x.status === "dirty", "isDirty");
4477
4837
  var isValid2 = /* @__PURE__ */ __name2((x) => x.status === "valid", "isValid");
4478
4838
  var isAsync2 = /* @__PURE__ */ __name2((x) => typeof Promise !== "undefined" && x instanceof Promise, "isAsync");
4839
+ function __classPrivateFieldGet2(receiver, state, kind, f) {
4840
+ if (kind === "a" && !f)
4841
+ throw new TypeError("Private accessor was defined without a getter");
4842
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
4843
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
4844
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
4845
+ }
4846
+ __name(__classPrivateFieldGet2, "__classPrivateFieldGet");
4847
+ __name2(__classPrivateFieldGet2, "__classPrivateFieldGet");
4848
+ function __classPrivateFieldSet2(receiver, state, value, kind, f) {
4849
+ if (kind === "m")
4850
+ throw new TypeError("Private method is not writable");
4851
+ if (kind === "a" && !f)
4852
+ throw new TypeError("Private accessor was defined without a setter");
4853
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
4854
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
4855
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
4856
+ }
4857
+ __name(__classPrivateFieldSet2, "__classPrivateFieldSet");
4858
+ __name2(__classPrivateFieldSet2, "__classPrivateFieldSet");
4479
4859
  var errorUtil2;
4480
4860
  (function(errorUtil22) {
4481
4861
  errorUtil22.errToObj = (message) => typeof message === "string" ? {
@@ -4483,6 +4863,8 @@ var errorUtil2;
4483
4863
  } : message || {};
4484
4864
  errorUtil22.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
4485
4865
  })(errorUtil2 || (errorUtil2 = {}));
4866
+ var _ZodEnum_cache2;
4867
+ var _ZodNativeEnum_cache2;
4486
4868
  var _a3;
4487
4869
  var _ParseInputLazyPath2 = (_a3 = class {
4488
4870
  constructor(parent, value, path, key) {
@@ -4540,17 +4922,24 @@ function processCreateParams2(params) {
4540
4922
  description
4541
4923
  };
4542
4924
  const customMap = /* @__PURE__ */ __name2((iss, ctx) => {
4543
- if (iss.code !== "invalid_type")
4925
+ var _a46, _b;
4926
+ const { message } = params;
4927
+ if (iss.code === "invalid_enum_value") {
4544
4928
  return {
4545
- message: ctx.defaultError
4929
+ message: message !== null && message !== void 0 ? message : ctx.defaultError
4546
4930
  };
4931
+ }
4547
4932
  if (typeof ctx.data === "undefined") {
4548
4933
  return {
4549
- message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError
4934
+ message: (_a46 = message !== null && message !== void 0 ? message : required_error) !== null && _a46 !== void 0 ? _a46 : ctx.defaultError
4550
4935
  };
4551
4936
  }
4937
+ if (iss.code !== "invalid_type")
4938
+ return {
4939
+ message: ctx.defaultError
4940
+ };
4552
4941
  return {
4553
- message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError
4942
+ message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError
4554
4943
  };
4555
4944
  }, "customMap");
4556
4945
  return {
@@ -4562,34 +4951,6 @@ __name(processCreateParams2, "processCreateParams");
4562
4951
  __name2(processCreateParams2, "processCreateParams");
4563
4952
  var _a4;
4564
4953
  var _ZodType2 = (_a4 = class {
4565
- constructor(def) {
4566
- this.spa = this.safeParseAsync;
4567
- this._def = def;
4568
- this.parse = this.parse.bind(this);
4569
- this.safeParse = this.safeParse.bind(this);
4570
- this.parseAsync = this.parseAsync.bind(this);
4571
- this.safeParseAsync = this.safeParseAsync.bind(this);
4572
- this.spa = this.spa.bind(this);
4573
- this.refine = this.refine.bind(this);
4574
- this.refinement = this.refinement.bind(this);
4575
- this.superRefine = this.superRefine.bind(this);
4576
- this.optional = this.optional.bind(this);
4577
- this.nullable = this.nullable.bind(this);
4578
- this.nullish = this.nullish.bind(this);
4579
- this.array = this.array.bind(this);
4580
- this.promise = this.promise.bind(this);
4581
- this.or = this.or.bind(this);
4582
- this.and = this.and.bind(this);
4583
- this.transform = this.transform.bind(this);
4584
- this.brand = this.brand.bind(this);
4585
- this.default = this.default.bind(this);
4586
- this.catch = this.catch.bind(this);
4587
- this.describe = this.describe.bind(this);
4588
- this.pipe = this.pipe.bind(this);
4589
- this.readonly = this.readonly.bind(this);
4590
- this.isNullable = this.isNullable.bind(this);
4591
- this.isOptional = this.isOptional.bind(this);
4592
- }
4593
4954
  get description() {
4594
4955
  return this._def.description;
4595
4956
  }
@@ -4657,6 +5018,51 @@ var _ZodType2 = (_a4 = class {
4657
5018
  });
4658
5019
  return handleResult2(ctx, result);
4659
5020
  }
5021
+ "~validate"(data) {
5022
+ var _a46, _b;
5023
+ const ctx = {
5024
+ common: {
5025
+ issues: [],
5026
+ async: !!this["~standard"].async
5027
+ },
5028
+ path: [],
5029
+ schemaErrorMap: this._def.errorMap,
5030
+ parent: null,
5031
+ data,
5032
+ parsedType: getParsedType2(data)
5033
+ };
5034
+ if (!this["~standard"].async) {
5035
+ try {
5036
+ const result = this._parseSync({
5037
+ data,
5038
+ path: [],
5039
+ parent: ctx
5040
+ });
5041
+ return isValid2(result) ? {
5042
+ value: result.value
5043
+ } : {
5044
+ issues: ctx.common.issues
5045
+ };
5046
+ } catch (err) {
5047
+ 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")) {
5048
+ this["~standard"].async = true;
5049
+ }
5050
+ ctx.common = {
5051
+ issues: [],
5052
+ async: true
5053
+ };
5054
+ }
5055
+ }
5056
+ return this._parseAsync({
5057
+ data,
5058
+ path: [],
5059
+ parent: ctx
5060
+ }).then((result) => isValid2(result) ? {
5061
+ value: result.value
5062
+ } : {
5063
+ issues: ctx.common.issues
5064
+ });
5065
+ }
4660
5066
  async parseAsync(data, params) {
4661
5067
  const result = await this.safeParseAsync(data, params);
4662
5068
  if (result.success)
@@ -4743,6 +5149,39 @@ var _ZodType2 = (_a4 = class {
4743
5149
  superRefine(refinement) {
4744
5150
  return this._refinement(refinement);
4745
5151
  }
5152
+ constructor(def) {
5153
+ this.spa = this.safeParseAsync;
5154
+ this._def = def;
5155
+ this.parse = this.parse.bind(this);
5156
+ this.safeParse = this.safeParse.bind(this);
5157
+ this.parseAsync = this.parseAsync.bind(this);
5158
+ this.safeParseAsync = this.safeParseAsync.bind(this);
5159
+ this.spa = this.spa.bind(this);
5160
+ this.refine = this.refine.bind(this);
5161
+ this.refinement = this.refinement.bind(this);
5162
+ this.superRefine = this.superRefine.bind(this);
5163
+ this.optional = this.optional.bind(this);
5164
+ this.nullable = this.nullable.bind(this);
5165
+ this.nullish = this.nullish.bind(this);
5166
+ this.array = this.array.bind(this);
5167
+ this.promise = this.promise.bind(this);
5168
+ this.or = this.or.bind(this);
5169
+ this.and = this.and.bind(this);
5170
+ this.transform = this.transform.bind(this);
5171
+ this.brand = this.brand.bind(this);
5172
+ this.default = this.default.bind(this);
5173
+ this.catch = this.catch.bind(this);
5174
+ this.describe = this.describe.bind(this);
5175
+ this.pipe = this.pipe.bind(this);
5176
+ this.readonly = this.readonly.bind(this);
5177
+ this.isNullable = this.isNullable.bind(this);
5178
+ this.isOptional = this.isOptional.bind(this);
5179
+ this["~standard"] = {
5180
+ version: 1,
5181
+ vendor: "zod",
5182
+ validate: (data) => this["~validate"](data)
5183
+ };
5184
+ }
4746
5185
  optional() {
4747
5186
  return ZodOptional2.create(this, this._def);
4748
5187
  }
@@ -4753,7 +5192,7 @@ var _ZodType2 = (_a4 = class {
4753
5192
  return this.nullable().optional();
4754
5193
  }
4755
5194
  array() {
4756
- return ZodArray2.create(this, this._def);
5195
+ return ZodArray2.create(this);
4757
5196
  }
4758
5197
  promise() {
4759
5198
  return ZodPromise2.create(this, this._def);
@@ -4826,35 +5265,50 @@ var _ZodType2 = (_a4 = class {
4826
5265
  __name2(_ZodType2, "ZodType");
4827
5266
  var ZodType2 = _ZodType2;
4828
5267
  var cuidRegex2 = /^c[^\s-]{8,}$/i;
4829
- var cuid2Regex2 = /^[a-z][a-z0-9]*$/;
4830
- var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/;
5268
+ var cuid2Regex2 = /^[0-9a-z]+$/;
5269
+ var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
4831
5270
  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;
4832
- var emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
5271
+ var nanoidRegex2 = /^[a-z0-9_-]{21}$/i;
5272
+ var jwtRegex2 = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
5273
+ 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)?)??$/;
5274
+ var emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
4833
5275
  var _emojiRegex2 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
4834
5276
  var emojiRegex2;
4835
- 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}))$/;
4836
- 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})))$/;
4837
- var datetimeRegex2 = /* @__PURE__ */ __name2((args) => {
5277
+ 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])$/;
5278
+ 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])$/;
5279
+ 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]))$/;
5280
+ 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])$/;
5281
+ var base64Regex2 = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
5282
+ var base64urlRegex2 = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
5283
+ 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])))`;
5284
+ var dateRegex2 = new RegExp(`^${dateRegexSource2}$`);
5285
+ function timeRegexSource2(args) {
5286
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
4838
5287
  if (args.precision) {
4839
- if (args.offset) {
4840
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
4841
- } else {
4842
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
4843
- }
4844
- } else if (args.precision === 0) {
4845
- if (args.offset) {
4846
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
4847
- } else {
4848
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
4849
- }
4850
- } else {
4851
- if (args.offset) {
4852
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
4853
- } else {
4854
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
4855
- }
5288
+ regex = `${regex}\\.\\d{${args.precision}}`;
5289
+ } else if (args.precision == null) {
5290
+ regex = `${regex}(\\.\\d+)?`;
4856
5291
  }
4857
- }, "datetimeRegex");
5292
+ return regex;
5293
+ }
5294
+ __name(timeRegexSource2, "timeRegexSource");
5295
+ __name2(timeRegexSource2, "timeRegexSource");
5296
+ function timeRegex2(args) {
5297
+ return new RegExp(`^${timeRegexSource2(args)}$`);
5298
+ }
5299
+ __name(timeRegex2, "timeRegex");
5300
+ __name2(timeRegex2, "timeRegex");
5301
+ function datetimeRegex2(args) {
5302
+ let regex = `${dateRegexSource2}T${timeRegexSource2(args)}`;
5303
+ const opts = [];
5304
+ opts.push(args.local ? `Z?` : `Z`);
5305
+ if (args.offset)
5306
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
5307
+ regex = `${regex}(${opts.join("|")})`;
5308
+ return new RegExp(`^${regex}$`);
5309
+ }
5310
+ __name(datetimeRegex2, "datetimeRegex");
5311
+ __name2(datetimeRegex2, "datetimeRegex");
4858
5312
  function isValidIP2(ip, version) {
4859
5313
  if ((version === "v4" || !version) && ipv4Regex2.test(ip)) {
4860
5314
  return true;
@@ -4866,6 +5320,37 @@ function isValidIP2(ip, version) {
4866
5320
  }
4867
5321
  __name(isValidIP2, "isValidIP");
4868
5322
  __name2(isValidIP2, "isValidIP");
5323
+ function isValidJWT2(jwt, alg) {
5324
+ if (!jwtRegex2.test(jwt))
5325
+ return false;
5326
+ try {
5327
+ const [header] = jwt.split(".");
5328
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
5329
+ const decoded = JSON.parse(atob(base64));
5330
+ if (typeof decoded !== "object" || decoded === null)
5331
+ return false;
5332
+ if (!decoded.typ || !decoded.alg)
5333
+ return false;
5334
+ if (alg && decoded.alg !== alg)
5335
+ return false;
5336
+ return true;
5337
+ } catch (_a46) {
5338
+ return false;
5339
+ }
5340
+ }
5341
+ __name(isValidJWT2, "isValidJWT");
5342
+ __name2(isValidJWT2, "isValidJWT");
5343
+ function isValidCidr2(ip, version) {
5344
+ if ((version === "v4" || !version) && ipv4CidrRegex2.test(ip)) {
5345
+ return true;
5346
+ }
5347
+ if ((version === "v6" || !version) && ipv6CidrRegex2.test(ip)) {
5348
+ return true;
5349
+ }
5350
+ return false;
5351
+ }
5352
+ __name(isValidCidr2, "isValidCidr");
5353
+ __name2(isValidCidr2, "isValidCidr");
4869
5354
  var _a5;
4870
5355
  var _ZodString2 = (_a5 = class extends ZodType2 {
4871
5356
  _parse(input) {
@@ -4970,6 +5455,16 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
4970
5455
  });
4971
5456
  status.dirty();
4972
5457
  }
5458
+ } else if (check.kind === "nanoid") {
5459
+ if (!nanoidRegex2.test(input.data)) {
5460
+ ctx = this._getOrReturnCtx(input, ctx);
5461
+ addIssueToContext2(ctx, {
5462
+ validation: "nanoid",
5463
+ code: ZodIssueCode2.invalid_string,
5464
+ message: check.message
5465
+ });
5466
+ status.dirty();
5467
+ }
4973
5468
  } else if (check.kind === "cuid") {
4974
5469
  if (!cuidRegex2.test(input.data)) {
4975
5470
  ctx = this._getOrReturnCtx(input, ctx);
@@ -5078,6 +5573,38 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5078
5573
  });
5079
5574
  status.dirty();
5080
5575
  }
5576
+ } else if (check.kind === "date") {
5577
+ const regex = dateRegex2;
5578
+ if (!regex.test(input.data)) {
5579
+ ctx = this._getOrReturnCtx(input, ctx);
5580
+ addIssueToContext2(ctx, {
5581
+ code: ZodIssueCode2.invalid_string,
5582
+ validation: "date",
5583
+ message: check.message
5584
+ });
5585
+ status.dirty();
5586
+ }
5587
+ } else if (check.kind === "time") {
5588
+ const regex = timeRegex2(check);
5589
+ if (!regex.test(input.data)) {
5590
+ ctx = this._getOrReturnCtx(input, ctx);
5591
+ addIssueToContext2(ctx, {
5592
+ code: ZodIssueCode2.invalid_string,
5593
+ validation: "time",
5594
+ message: check.message
5595
+ });
5596
+ status.dirty();
5597
+ }
5598
+ } else if (check.kind === "duration") {
5599
+ if (!durationRegex2.test(input.data)) {
5600
+ ctx = this._getOrReturnCtx(input, ctx);
5601
+ addIssueToContext2(ctx, {
5602
+ validation: "duration",
5603
+ code: ZodIssueCode2.invalid_string,
5604
+ message: check.message
5605
+ });
5606
+ status.dirty();
5607
+ }
5081
5608
  } else if (check.kind === "ip") {
5082
5609
  if (!isValidIP2(input.data, check.version)) {
5083
5610
  ctx = this._getOrReturnCtx(input, ctx);
@@ -5088,6 +5615,46 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5088
5615
  });
5089
5616
  status.dirty();
5090
5617
  }
5618
+ } else if (check.kind === "jwt") {
5619
+ if (!isValidJWT2(input.data, check.alg)) {
5620
+ ctx = this._getOrReturnCtx(input, ctx);
5621
+ addIssueToContext2(ctx, {
5622
+ validation: "jwt",
5623
+ code: ZodIssueCode2.invalid_string,
5624
+ message: check.message
5625
+ });
5626
+ status.dirty();
5627
+ }
5628
+ } else if (check.kind === "cidr") {
5629
+ if (!isValidCidr2(input.data, check.version)) {
5630
+ ctx = this._getOrReturnCtx(input, ctx);
5631
+ addIssueToContext2(ctx, {
5632
+ validation: "cidr",
5633
+ code: ZodIssueCode2.invalid_string,
5634
+ message: check.message
5635
+ });
5636
+ status.dirty();
5637
+ }
5638
+ } else if (check.kind === "base64") {
5639
+ if (!base64Regex2.test(input.data)) {
5640
+ ctx = this._getOrReturnCtx(input, ctx);
5641
+ addIssueToContext2(ctx, {
5642
+ validation: "base64",
5643
+ code: ZodIssueCode2.invalid_string,
5644
+ message: check.message
5645
+ });
5646
+ status.dirty();
5647
+ }
5648
+ } else if (check.kind === "base64url") {
5649
+ if (!base64urlRegex2.test(input.data)) {
5650
+ ctx = this._getOrReturnCtx(input, ctx);
5651
+ addIssueToContext2(ctx, {
5652
+ validation: "base64url",
5653
+ code: ZodIssueCode2.invalid_string,
5654
+ message: check.message
5655
+ });
5656
+ status.dirty();
5657
+ }
5091
5658
  } else {
5092
5659
  util2.assertNever(check);
5093
5660
  }
@@ -5137,6 +5704,12 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5137
5704
  ...errorUtil2.errToObj(message)
5138
5705
  });
5139
5706
  }
5707
+ nanoid(message) {
5708
+ return this._addCheck({
5709
+ kind: "nanoid",
5710
+ ...errorUtil2.errToObj(message)
5711
+ });
5712
+ }
5140
5713
  cuid(message) {
5141
5714
  return this._addCheck({
5142
5715
  kind: "cuid",
@@ -5155,19 +5728,44 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5155
5728
  ...errorUtil2.errToObj(message)
5156
5729
  });
5157
5730
  }
5731
+ base64(message) {
5732
+ return this._addCheck({
5733
+ kind: "base64",
5734
+ ...errorUtil2.errToObj(message)
5735
+ });
5736
+ }
5737
+ base64url(message) {
5738
+ return this._addCheck({
5739
+ kind: "base64url",
5740
+ ...errorUtil2.errToObj(message)
5741
+ });
5742
+ }
5743
+ jwt(options) {
5744
+ return this._addCheck({
5745
+ kind: "jwt",
5746
+ ...errorUtil2.errToObj(options)
5747
+ });
5748
+ }
5158
5749
  ip(options) {
5159
5750
  return this._addCheck({
5160
5751
  kind: "ip",
5161
5752
  ...errorUtil2.errToObj(options)
5162
5753
  });
5163
5754
  }
5755
+ cidr(options) {
5756
+ return this._addCheck({
5757
+ kind: "cidr",
5758
+ ...errorUtil2.errToObj(options)
5759
+ });
5760
+ }
5164
5761
  datetime(options) {
5165
- var _a46;
5762
+ var _a46, _b;
5166
5763
  if (typeof options === "string") {
5167
5764
  return this._addCheck({
5168
5765
  kind: "datetime",
5169
5766
  precision: null,
5170
5767
  offset: false,
5768
+ local: false,
5171
5769
  message: options
5172
5770
  });
5173
5771
  }
@@ -5175,9 +5773,36 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5175
5773
  kind: "datetime",
5176
5774
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
5177
5775
  offset: (_a46 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a46 !== void 0 ? _a46 : false,
5776
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
5777
+ ...errorUtil2.errToObj(options === null || options === void 0 ? void 0 : options.message)
5778
+ });
5779
+ }
5780
+ date(message) {
5781
+ return this._addCheck({
5782
+ kind: "date",
5783
+ message
5784
+ });
5785
+ }
5786
+ time(options) {
5787
+ if (typeof options === "string") {
5788
+ return this._addCheck({
5789
+ kind: "time",
5790
+ precision: null,
5791
+ message: options
5792
+ });
5793
+ }
5794
+ return this._addCheck({
5795
+ kind: "time",
5796
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
5178
5797
  ...errorUtil2.errToObj(options === null || options === void 0 ? void 0 : options.message)
5179
5798
  });
5180
5799
  }
5800
+ duration(message) {
5801
+ return this._addCheck({
5802
+ kind: "duration",
5803
+ ...errorUtil2.errToObj(message)
5804
+ });
5805
+ }
5181
5806
  regex(regex, message) {
5182
5807
  return this._addCheck({
5183
5808
  kind: "regex",
@@ -5229,8 +5854,7 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5229
5854
  });
5230
5855
  }
5231
5856
  /**
5232
- * @deprecated Use z.string().min(1) instead.
5233
- * @see {@link ZodString.min}
5857
+ * Equivalent to `.min(1)`
5234
5858
  */
5235
5859
  nonempty(message) {
5236
5860
  return this.min(1, errorUtil2.errToObj(message));
@@ -5271,6 +5895,15 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5271
5895
  get isDatetime() {
5272
5896
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
5273
5897
  }
5898
+ get isDate() {
5899
+ return !!this._def.checks.find((ch) => ch.kind === "date");
5900
+ }
5901
+ get isTime() {
5902
+ return !!this._def.checks.find((ch) => ch.kind === "time");
5903
+ }
5904
+ get isDuration() {
5905
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
5906
+ }
5274
5907
  get isEmail() {
5275
5908
  return !!this._def.checks.find((ch) => ch.kind === "email");
5276
5909
  }
@@ -5283,6 +5916,9 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5283
5916
  get isUUID() {
5284
5917
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
5285
5918
  }
5919
+ get isNANOID() {
5920
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
5921
+ }
5286
5922
  get isCUID() {
5287
5923
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
5288
5924
  }
@@ -5295,6 +5931,15 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5295
5931
  get isIP() {
5296
5932
  return !!this._def.checks.find((ch) => ch.kind === "ip");
5297
5933
  }
5934
+ get isCIDR() {
5935
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
5936
+ }
5937
+ get isBase64() {
5938
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
5939
+ }
5940
+ get isBase64url() {
5941
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
5942
+ }
5298
5943
  get minLength() {
5299
5944
  let min = null;
5300
5945
  for (const ch of this._def.checks) {
@@ -5586,17 +6231,15 @@ var _ZodBigInt2 = (_a7 = class extends ZodType2 {
5586
6231
  }
5587
6232
  _parse(input) {
5588
6233
  if (this._def.coerce) {
5589
- input.data = BigInt(input.data);
6234
+ try {
6235
+ input.data = BigInt(input.data);
6236
+ } catch (_a46) {
6237
+ return this._getInvalidInput(input);
6238
+ }
5590
6239
  }
5591
6240
  const parsedType = this._getType(input);
5592
6241
  if (parsedType !== ZodParsedType2.bigint) {
5593
- const ctx2 = this._getOrReturnCtx(input);
5594
- addIssueToContext2(ctx2, {
5595
- code: ZodIssueCode2.invalid_type,
5596
- expected: ZodParsedType2.bigint,
5597
- received: ctx2.parsedType
5598
- });
5599
- return INVALID2;
6242
+ return this._getInvalidInput(input);
5600
6243
  }
5601
6244
  let ctx = void 0;
5602
6245
  const status = new ParseStatus2();
@@ -5646,6 +6289,15 @@ var _ZodBigInt2 = (_a7 = class extends ZodType2 {
5646
6289
  value: input.data
5647
6290
  };
5648
6291
  }
6292
+ _getInvalidInput(input) {
6293
+ const ctx = this._getOrReturnCtx(input);
6294
+ addIssueToContext2(ctx, {
6295
+ code: ZodIssueCode2.invalid_type,
6296
+ expected: ZodParsedType2.bigint,
6297
+ received: ctx.parsedType
6298
+ });
6299
+ return INVALID2;
6300
+ }
5649
6301
  gte(value, message) {
5650
6302
  return this.setLimit("min", value, true, errorUtil2.toString(message));
5651
6303
  }
@@ -6291,9 +6943,10 @@ var _ZodObject2 = (_a18 = class extends ZodType2 {
6291
6943
  const syncPairs = [];
6292
6944
  for (const pair of pairs) {
6293
6945
  const key = await pair.key;
6946
+ const value = await pair.value;
6294
6947
  syncPairs.push({
6295
6948
  key,
6296
- value: await pair.value,
6949
+ value,
6297
6950
  alwaysSet: pair.alwaysSet
6298
6951
  });
6299
6952
  }
@@ -6658,7 +7311,7 @@ var getDiscriminator2 = /* @__PURE__ */ __name2((type) => {
6658
7311
  } else if (type instanceof ZodEnum2) {
6659
7312
  return type.options;
6660
7313
  } else if (type instanceof ZodNativeEnum2) {
6661
- return Object.keys(type.enum);
7314
+ return util2.objectValues(type.enum);
6662
7315
  } else if (type instanceof ZodDefault2) {
6663
7316
  return getDiscriminator2(type._def.innerType);
6664
7317
  } else if (type instanceof ZodUndefined2) {
@@ -6669,8 +7322,24 @@ var getDiscriminator2 = /* @__PURE__ */ __name2((type) => {
6669
7322
  return [
6670
7323
  null
6671
7324
  ];
7325
+ } else if (type instanceof ZodOptional2) {
7326
+ return [
7327
+ void 0,
7328
+ ...getDiscriminator2(type.unwrap())
7329
+ ];
7330
+ } else if (type instanceof ZodNullable2) {
7331
+ return [
7332
+ null,
7333
+ ...getDiscriminator2(type.unwrap())
7334
+ ];
7335
+ } else if (type instanceof ZodBranded2) {
7336
+ return getDiscriminator2(type.unwrap());
7337
+ } else if (type instanceof ZodReadonly2) {
7338
+ return getDiscriminator2(type.unwrap());
7339
+ } else if (type instanceof ZodCatch2) {
7340
+ return getDiscriminator2(type._def.innerType);
6672
7341
  } else {
6673
- return null;
7342
+ return [];
6674
7343
  }
6675
7344
  }, "getDiscriminator");
6676
7345
  var _a20;
@@ -6733,7 +7402,7 @@ var _ZodDiscriminatedUnion2 = (_a20 = class extends ZodType2 {
6733
7402
  const optionsMap = /* @__PURE__ */ new Map();
6734
7403
  for (const type of options) {
6735
7404
  const discriminatorValues = getDiscriminator2(type.shape[discriminator]);
6736
- if (!discriminatorValues) {
7405
+ if (!discriminatorValues.length) {
6737
7406
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
6738
7407
  }
6739
7408
  for (const value of discriminatorValues) {
@@ -6972,7 +7641,8 @@ var _ZodRecord2 = (_a23 = class extends ZodType2 {
6972
7641
  for (const key in ctx.data) {
6973
7642
  pairs.push({
6974
7643
  key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, key)),
6975
- value: valueType._parse(new ParseInputLazyPath2(ctx, ctx.data[key], ctx.path, key))
7644
+ value: valueType._parse(new ParseInputLazyPath2(ctx, ctx.data[key], ctx.path, key)),
7645
+ alwaysSet: key in ctx.data
6976
7646
  });
6977
7647
  }
6978
7648
  if (ctx.common.async) {
@@ -7380,6 +8050,10 @@ __name(createZodEnum2, "createZodEnum");
7380
8050
  __name2(createZodEnum2, "createZodEnum");
7381
8051
  var _a29;
7382
8052
  var _ZodEnum2 = (_a29 = class extends ZodType2 {
8053
+ constructor() {
8054
+ super(...arguments);
8055
+ _ZodEnum_cache2.set(this, void 0);
8056
+ }
7383
8057
  _parse(input) {
7384
8058
  if (typeof input.data !== "string") {
7385
8059
  const ctx = this._getOrReturnCtx(input);
@@ -7391,7 +8065,10 @@ var _ZodEnum2 = (_a29 = class extends ZodType2 {
7391
8065
  });
7392
8066
  return INVALID2;
7393
8067
  }
7394
- if (this._def.values.indexOf(input.data) === -1) {
8068
+ if (!__classPrivateFieldGet2(this, _ZodEnum_cache2, "f")) {
8069
+ __classPrivateFieldSet2(this, _ZodEnum_cache2, new Set(this._def.values), "f");
8070
+ }
8071
+ if (!__classPrivateFieldGet2(this, _ZodEnum_cache2, "f").has(input.data)) {
7395
8072
  const ctx = this._getOrReturnCtx(input);
7396
8073
  const expectedValues = this._def.values;
7397
8074
  addIssueToContext2(ctx, {
@@ -7427,18 +8104,29 @@ var _ZodEnum2 = (_a29 = class extends ZodType2 {
7427
8104
  }
7428
8105
  return enumValues;
7429
8106
  }
7430
- extract(values) {
7431
- return _a29.create(values);
8107
+ extract(values, newDef = this._def) {
8108
+ return _a29.create(values, {
8109
+ ...this._def,
8110
+ ...newDef
8111
+ });
7432
8112
  }
7433
- exclude(values) {
7434
- return _a29.create(this.options.filter((opt) => !values.includes(opt)));
8113
+ exclude(values, newDef = this._def) {
8114
+ return _a29.create(this.options.filter((opt) => !values.includes(opt)), {
8115
+ ...this._def,
8116
+ ...newDef
8117
+ });
7435
8118
  }
7436
8119
  }, __name(_a29, "_ZodEnum"), _a29);
7437
8120
  __name2(_ZodEnum2, "ZodEnum");
7438
8121
  var ZodEnum2 = _ZodEnum2;
8122
+ _ZodEnum_cache2 = /* @__PURE__ */ new WeakMap();
7439
8123
  ZodEnum2.create = createZodEnum2;
7440
8124
  var _a30;
7441
8125
  var _ZodNativeEnum2 = (_a30 = class extends ZodType2 {
8126
+ constructor() {
8127
+ super(...arguments);
8128
+ _ZodNativeEnum_cache2.set(this, void 0);
8129
+ }
7442
8130
  _parse(input) {
7443
8131
  const nativeEnumValues = util2.getValidEnumValues(this._def.values);
7444
8132
  const ctx = this._getOrReturnCtx(input);
@@ -7451,7 +8139,10 @@ var _ZodNativeEnum2 = (_a30 = class extends ZodType2 {
7451
8139
  });
7452
8140
  return INVALID2;
7453
8141
  }
7454
- if (nativeEnumValues.indexOf(input.data) === -1) {
8142
+ if (!__classPrivateFieldGet2(this, _ZodNativeEnum_cache2, "f")) {
8143
+ __classPrivateFieldSet2(this, _ZodNativeEnum_cache2, new Set(util2.getValidEnumValues(this._def.values)), "f");
8144
+ }
8145
+ if (!__classPrivateFieldGet2(this, _ZodNativeEnum_cache2, "f").has(input.data)) {
7455
8146
  const expectedValues = util2.objectValues(nativeEnumValues);
7456
8147
  addIssueToContext2(ctx, {
7457
8148
  received: ctx.data,
@@ -7468,6 +8159,7 @@ var _ZodNativeEnum2 = (_a30 = class extends ZodType2 {
7468
8159
  }, __name(_a30, "_ZodNativeEnum"), _a30);
7469
8160
  __name2(_ZodNativeEnum2, "ZodNativeEnum");
7470
8161
  var ZodNativeEnum2 = _ZodNativeEnum2;
8162
+ _ZodNativeEnum_cache2 = /* @__PURE__ */ new WeakMap();
7471
8163
  ZodNativeEnum2.create = (values, params) => {
7472
8164
  return new ZodNativeEnum2({
7473
8165
  values,
@@ -7535,26 +8227,38 @@ var _ZodEffects2 = (_a32 = class extends ZodType2 {
7535
8227
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
7536
8228
  if (effect.type === "preprocess") {
7537
8229
  const processed = effect.transform(ctx.data, checkCtx);
7538
- if (ctx.common.issues.length) {
7539
- return {
7540
- status: "dirty",
7541
- value: ctx.data
7542
- };
7543
- }
7544
8230
  if (ctx.common.async) {
7545
- return Promise.resolve(processed).then((processed2) => {
7546
- return this._def.schema._parseAsync({
8231
+ return Promise.resolve(processed).then(async (processed2) => {
8232
+ if (status.value === "aborted")
8233
+ return INVALID2;
8234
+ const result = await this._def.schema._parseAsync({
7547
8235
  data: processed2,
7548
8236
  path: ctx.path,
7549
8237
  parent: ctx
7550
8238
  });
8239
+ if (result.status === "aborted")
8240
+ return INVALID2;
8241
+ if (result.status === "dirty")
8242
+ return DIRTY2(result.value);
8243
+ if (status.value === "dirty")
8244
+ return DIRTY2(result.value);
8245
+ return result;
7551
8246
  });
7552
8247
  } else {
7553
- return this._def.schema._parseSync({
8248
+ if (status.value === "aborted")
8249
+ return INVALID2;
8250
+ const result = this._def.schema._parseSync({
7554
8251
  data: processed,
7555
8252
  path: ctx.path,
7556
8253
  parent: ctx
7557
8254
  });
8255
+ if (result.status === "aborted")
8256
+ return INVALID2;
8257
+ if (result.status === "dirty")
8258
+ return DIRTY2(result.value);
8259
+ if (status.value === "dirty")
8260
+ return DIRTY2(result.value);
8261
+ return result;
7558
8262
  }
7559
8263
  }
7560
8264
  if (effect.type === "refinement") {
@@ -7893,10 +8597,16 @@ var _a40;
7893
8597
  var _ZodReadonly2 = (_a40 = class extends ZodType2 {
7894
8598
  _parse(input) {
7895
8599
  const result = this._def.innerType._parse(input);
7896
- if (isValid2(result)) {
7897
- result.value = Object.freeze(result.value);
7898
- }
7899
- return result;
8600
+ const freeze = /* @__PURE__ */ __name2((data) => {
8601
+ if (isValid2(data)) {
8602
+ data.value = Object.freeze(data.value);
8603
+ }
8604
+ return data;
8605
+ }, "freeze");
8606
+ return isAsync2(result) ? result.then((data) => freeze(data)) : freeze(result);
8607
+ }
8608
+ unwrap() {
8609
+ return this._def.innerType;
7900
8610
  }
7901
8611
  }, __name(_a40, "_ZodReadonly"), _a40);
7902
8612
  __name2(_ZodReadonly2, "ZodReadonly");
@@ -7908,27 +8618,51 @@ ZodReadonly2.create = (type, params) => {
7908
8618
  ...processCreateParams2(params)
7909
8619
  });
7910
8620
  };
7911
- var custom2 = /* @__PURE__ */ __name2((check, params = {}, fatal) => {
8621
+ function cleanParams2(params, data) {
8622
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? {
8623
+ message: params
8624
+ } : params;
8625
+ const p2 = typeof p === "string" ? {
8626
+ message: p
8627
+ } : p;
8628
+ return p2;
8629
+ }
8630
+ __name(cleanParams2, "cleanParams");
8631
+ __name2(cleanParams2, "cleanParams");
8632
+ function custom2(check, _params = {}, fatal) {
7912
8633
  if (check)
7913
8634
  return ZodAny2.create().superRefine((data, ctx) => {
7914
8635
  var _a46, _b;
7915
- if (!check(data)) {
7916
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? {
7917
- message: params
7918
- } : params;
7919
- const _fatal = (_b = (_a46 = p.fatal) !== null && _a46 !== void 0 ? _a46 : fatal) !== null && _b !== void 0 ? _b : true;
7920
- const p2 = typeof p === "string" ? {
7921
- message: p
7922
- } : p;
8636
+ const r = check(data);
8637
+ if (r instanceof Promise) {
8638
+ return r.then((r2) => {
8639
+ var _a210, _b2;
8640
+ if (!r2) {
8641
+ const params = cleanParams2(_params, data);
8642
+ const _fatal = (_b2 = (_a210 = params.fatal) !== null && _a210 !== void 0 ? _a210 : fatal) !== null && _b2 !== void 0 ? _b2 : true;
8643
+ ctx.addIssue({
8644
+ code: "custom",
8645
+ ...params,
8646
+ fatal: _fatal
8647
+ });
8648
+ }
8649
+ });
8650
+ }
8651
+ if (!r) {
8652
+ const params = cleanParams2(_params, data);
8653
+ const _fatal = (_b = (_a46 = params.fatal) !== null && _a46 !== void 0 ? _a46 : fatal) !== null && _b !== void 0 ? _b : true;
7923
8654
  ctx.addIssue({
7924
8655
  code: "custom",
7925
- ...p2,
8656
+ ...params,
7926
8657
  fatal: _fatal
7927
8658
  });
7928
8659
  }
8660
+ return;
7929
8661
  });
7930
8662
  return ZodAny2.create();
7931
- }, "custom");
8663
+ }
8664
+ __name(custom2, "custom");
8665
+ __name2(custom2, "custom");
7932
8666
  var late2 = {
7933
8667
  object: ZodObject2.lazycreate
7934
8668
  };
@@ -8059,6 +8793,7 @@ var z2 = /* @__PURE__ */ Object.freeze({
8059
8793
  ZodParsedType: ZodParsedType2,
8060
8794
  getParsedType: getParsedType2,
8061
8795
  ZodType: ZodType2,
8796
+ datetimeRegex: datetimeRegex2,
8062
8797
  ZodString: ZodString2,
8063
8798
  ZodNumber: ZodNumber2,
8064
8799
  ZodBigInt: ZodBigInt2,
@@ -8150,7 +8885,18 @@ var z2 = /* @__PURE__ */ Object.freeze({
8150
8885
  ZodError: ZodError2
8151
8886
  });
8152
8887
 
8153
- // ../core/dist/chunk-CMH4QQ3R.js
8888
+ // ../core/dist/chunk-U2ZCKMNU.js
8889
+ var upgradableProductSchema = z2.object({
8890
+ upgradableToId: z2.string().max(255),
8891
+ upgradableFromId: z2.string().max(255),
8892
+ position: z2.number().default(0),
8893
+ metadata: z2.record(z2.any()).default({}),
8894
+ createdAt: z2.date().nullable(),
8895
+ updatedAt: z2.date().nullable(),
8896
+ deletedAt: z2.date().nullable()
8897
+ });
8898
+
8899
+ // ../core/dist/chunk-ZXRVZVJR.js
8154
8900
  var VideoResourceSchema = z2.object({
8155
8901
  id: z2.string(),
8156
8902
  updatedAt: z2.coerce.date().optional(),
@@ -8173,29 +8919,22 @@ var VideoResourceSchema = z2.object({
8173
8919
  ])
8174
8920
  });
8175
8921
 
8176
- // ../core/dist/chunk-LMH5A7OR.js
8177
- var purchaseUserTransferSchema = z2.object({
8922
+ // ../core/dist/chunk-CJLUA3NF.js
8923
+ var priceSchema = z2.object({
8178
8924
  id: z2.string().max(191),
8179
- transferState: z2.enum([
8180
- "AVAILABLE",
8181
- "INITIATED",
8182
- "VERIFIED",
8183
- "CANCELED",
8184
- "EXPIRED",
8185
- "CONFIRMED",
8186
- "COMPLETED"
8187
- ]).default("AVAILABLE"),
8188
- purchaseId: z2.string().max(191),
8189
- sourceUserId: z2.string().max(191),
8190
- targetUserId: z2.string().max(191).optional().nullable(),
8925
+ productId: z2.string().max(191).optional().nullable(),
8926
+ organizationId: z2.string().max(191).optional().nullable(),
8927
+ nickname: z2.string().max(191).optional().nullable(),
8928
+ status: z2.number().int().default(0),
8929
+ unitAmount: z2.coerce.number().refine((value) => {
8930
+ const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8931
+ return decimalPlaces <= 2;
8932
+ }),
8191
8933
  createdAt: z2.date().nullable(),
8192
- expiresAt: z2.date().nullable(),
8193
- canceledAt: z2.date().nullable(),
8194
- confirmedAt: z2.date().nullable(),
8195
- completedAt: z2.date().nullable()
8934
+ fields: z2.record(z2.any()).default({})
8196
8935
  });
8197
8936
 
8198
- // ../core/dist/chunk-SCKAG5RT.js
8937
+ // ../core/dist/chunk-IILWNHNS.js
8199
8938
  var ContentResourceResourceSchema = z2.object({
8200
8939
  resourceId: z2.string(),
8201
8940
  resourceOfId: z2.string(),
@@ -8242,84 +8981,7 @@ var ResourceVisibilitySchema = z2.union([
8242
8981
  z2.literal("unlisted")
8243
8982
  ]);
8244
8983
 
8245
- // ../core/dist/chunk-PG6VF2O6.js
8246
- var resourceProgressSchema = z2.object({
8247
- userId: z2.string().max(191),
8248
- resourceId: z2.string().max(191).optional().nullable(),
8249
- completedAt: z2.date().nullable()
8250
- });
8251
- var moduleProgressSchema = z2.object({
8252
- completedLessons: z2.array(resourceProgressSchema),
8253
- nextResource: ContentResourceSchema.partial().nullable(),
8254
- percentCompleted: z2.number().default(0),
8255
- completedLessonsCount: z2.number().default(0),
8256
- totalLessonsCount: z2.number().default(0)
8257
- });
8258
-
8259
- // ../core/dist/chunk-DLQA3JMA.js
8260
- var upgradableProductSchema = z2.object({
8261
- upgradableToId: z2.string().max(255),
8262
- upgradableFromId: z2.string().max(255),
8263
- position: z2.number().default(0),
8264
- metadata: z2.record(z2.any()).default({}),
8265
- createdAt: z2.date().nullable(),
8266
- updatedAt: z2.date().nullable(),
8267
- deletedAt: z2.date().nullable()
8268
- });
8269
-
8270
- // ../core/dist/chunk-JZBK2DS3.js
8271
- var userSchema = z2.object({
8272
- id: z2.string().max(255),
8273
- name: z2.string().max(255).optional().nullable(),
8274
- role: z2.enum([
8275
- "user",
8276
- "admin"
8277
- ]).default("user"),
8278
- email: z2.string().max(255).email(),
8279
- emailVerified: z2.coerce.date().nullish(),
8280
- image: z2.string().max(255).optional().nullable(),
8281
- createdAt: z2.coerce.date().nullish(),
8282
- memberships: z2.array(z2.object({
8283
- id: z2.string(),
8284
- organizationId: z2.string()
8285
- })).nullish().default([]),
8286
- roles: z2.array(z2.object({
8287
- id: z2.string(),
8288
- name: z2.string(),
8289
- description: z2.string().nullable(),
8290
- active: z2.boolean(),
8291
- createdAt: z2.coerce.date().nullish(),
8292
- updatedAt: z2.coerce.date().nullish(),
8293
- deletedAt: z2.coerce.date().nullish()
8294
- })).optional().default([]),
8295
- organizationRoles: z2.array(z2.object({
8296
- id: z2.string(),
8297
- organizationId: z2.string(),
8298
- name: z2.string(),
8299
- description: z2.string().nullable(),
8300
- active: z2.boolean(),
8301
- createdAt: z2.coerce.date().nullish(),
8302
- updatedAt: z2.coerce.date().nullish(),
8303
- deletedAt: z2.coerce.date().nullish()
8304
- })).optional().default([])
8305
- });
8306
-
8307
- // ../core/dist/chunk-M7IDYIVK.js
8308
- var priceSchema = z2.object({
8309
- id: z2.string().max(191),
8310
- productId: z2.string().max(191).optional().nullable(),
8311
- organizationId: z2.string().max(191).optional().nullable(),
8312
- nickname: z2.string().max(191).optional().nullable(),
8313
- status: z2.number().int().default(0),
8314
- unitAmount: z2.coerce.number().refine((value) => {
8315
- const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8316
- return decimalPlaces <= 2;
8317
- }),
8318
- createdAt: z2.date().nullable(),
8319
- fields: z2.record(z2.any()).default({})
8320
- });
8321
-
8322
- // ../core/dist/chunk-FMAXYBP4.js
8984
+ // ../core/dist/chunk-6HESVS2V.js
8323
8985
  var productSchema = z2.object({
8324
8986
  id: z2.string().max(191),
8325
8987
  organizationId: z2.string().max(191).optional().nullable(),
@@ -8363,10 +9025,64 @@ var productSchema = z2.object({
8363
9025
  var NewProductSchema = z2.object({
8364
9026
  name: z2.string().min(2).max(90),
8365
9027
  quantityAvailable: z2.coerce.number().default(-1),
8366
- price: z2.coerce.number().gte(0).default(0)
9028
+ price: z2.coerce.number().gte(0).default(0),
9029
+ type: z2.enum([
9030
+ "live",
9031
+ "self-paced",
9032
+ "membership",
9033
+ "cohort"
9034
+ ]).default("self-paced").optional(),
9035
+ state: z2.enum([
9036
+ "draft",
9037
+ "published",
9038
+ "archived",
9039
+ "deleted"
9040
+ ]).default("draft").optional(),
9041
+ visibility: z2.enum([
9042
+ "public",
9043
+ "private",
9044
+ "unlisted"
9045
+ ]).default("unlisted").optional()
9046
+ });
9047
+
9048
+ // ../core/dist/chunk-K7QQ3LOH.js
9049
+ var userSchema = z2.object({
9050
+ id: z2.string().max(255),
9051
+ name: z2.string().max(255).optional().nullable(),
9052
+ role: z2.enum([
9053
+ "user",
9054
+ "admin"
9055
+ ]).default("user"),
9056
+ email: z2.string().max(255).email(),
9057
+ emailVerified: z2.coerce.date().nullish(),
9058
+ image: z2.string().max(255).optional().nullable(),
9059
+ createdAt: z2.coerce.date().nullish(),
9060
+ memberships: z2.array(z2.object({
9061
+ id: z2.string(),
9062
+ organizationId: z2.string()
9063
+ })).nullish().default([]),
9064
+ roles: z2.array(z2.object({
9065
+ id: z2.string(),
9066
+ name: z2.string(),
9067
+ description: z2.string().nullable(),
9068
+ active: z2.boolean(),
9069
+ createdAt: z2.coerce.date().nullish(),
9070
+ updatedAt: z2.coerce.date().nullish(),
9071
+ deletedAt: z2.coerce.date().nullish()
9072
+ })).optional().default([]),
9073
+ organizationRoles: z2.array(z2.object({
9074
+ id: z2.string(),
9075
+ organizationId: z2.string(),
9076
+ name: z2.string(),
9077
+ description: z2.string().nullable(),
9078
+ active: z2.boolean(),
9079
+ createdAt: z2.coerce.date().nullish(),
9080
+ updatedAt: z2.coerce.date().nullish(),
9081
+ deletedAt: z2.coerce.date().nullish()
9082
+ })).optional().default([])
8367
9083
  });
8368
9084
 
8369
- // ../core/dist/chunk-K4MXE7BY.js
9085
+ // ../core/dist/chunk-U3NTIXIA.js
8370
9086
  var couponSchema = z2.object({
8371
9087
  id: z2.string(),
8372
9088
  code: z2.string().max(191).optional().nullable(),
@@ -8389,7 +9105,7 @@ var couponSchema = z2.object({
8389
9105
  organizationId: z2.string().max(191).optional().nullable()
8390
9106
  });
8391
9107
 
8392
- // ../core/dist/chunk-MDUGHSSW.js
9108
+ // ../core/dist/chunk-HO5SC2MW.js
8393
9109
  var purchaseSchema = z2.object({
8394
9110
  id: z2.string().max(191),
8395
9111
  userId: z2.string().max(191).optional().nullable(),
@@ -8418,19 +9134,43 @@ var purchaseSchema = z2.object({
8418
9134
  organizationId: z2.string().max(191).optional().nullable()
8419
9135
  });
8420
9136
 
8421
- // ../core/dist/chunk-SGE7BCRS.js
8422
- var merchantChargeSchema = z2.object({
9137
+ // ../core/dist/chunk-CAVIZQBE.js
9138
+ var purchaseUserTransferSchema = z2.object({
8423
9139
  id: z2.string().max(191),
8424
- status: z2.number().int().default(0),
8425
- identifier: z2.string().max(191),
8426
- userId: z2.string().max(191),
8427
- merchantAccountId: z2.string().max(191),
8428
- merchantProductId: z2.string().max(191),
9140
+ transferState: z2.enum([
9141
+ "AVAILABLE",
9142
+ "INITIATED",
9143
+ "VERIFIED",
9144
+ "CANCELED",
9145
+ "EXPIRED",
9146
+ "CONFIRMED",
9147
+ "COMPLETED"
9148
+ ]).default("AVAILABLE"),
9149
+ purchaseId: z2.string().max(191),
9150
+ sourceUserId: z2.string().max(191),
9151
+ targetUserId: z2.string().max(191).optional().nullable(),
8429
9152
  createdAt: z2.date().nullable(),
8430
- merchantCustomerId: z2.string().max(191)
9153
+ expiresAt: z2.date().nullable(),
9154
+ canceledAt: z2.date().nullable(),
9155
+ confirmedAt: z2.date().nullable(),
9156
+ completedAt: z2.date().nullable()
9157
+ });
9158
+
9159
+ // ../core/dist/chunk-NHGTCHSG.js
9160
+ var resourceProgressSchema = z2.object({
9161
+ userId: z2.string().max(191),
9162
+ resourceId: z2.string().max(191).optional().nullable(),
9163
+ completedAt: z2.date().nullable()
9164
+ });
9165
+ var moduleProgressSchema = z2.object({
9166
+ completedLessons: z2.array(resourceProgressSchema),
9167
+ nextResource: ContentResourceSchema.partial().nullable(),
9168
+ percentCompleted: z2.number().default(0),
9169
+ completedLessonsCount: z2.number().default(0),
9170
+ totalLessonsCount: z2.number().default(0)
8431
9171
  });
8432
9172
 
8433
- // ../core/dist/chunk-EDDT2FFU.js
9173
+ // ../core/dist/chunk-KDD22EZI.js
8434
9174
  var merchantCustomerSchema = z2.object({
8435
9175
  id: z2.string().max(191),
8436
9176
  userId: z2.string().max(191),
@@ -8440,7 +9180,7 @@ var merchantCustomerSchema = z2.object({
8440
9180
  status: z2.number().int().default(0)
8441
9181
  });
8442
9182
 
8443
- // ../core/dist/chunk-PS6USEN7.js
9183
+ // ../core/dist/chunk-FYIQS5CC.js
8444
9184
  var merchantPriceSchema = z2.object({
8445
9185
  id: z2.string().max(191),
8446
9186
  merchantAccountId: z2.string().max(191),
@@ -8451,7 +9191,7 @@ var merchantPriceSchema = z2.object({
8451
9191
  priceId: z2.string().max(191).optional().nullable()
8452
9192
  });
8453
9193
 
8454
- // ../core/dist/chunk-DAG4HKGL.js
9194
+ // ../core/dist/chunk-RSPJ5FYR.js
8455
9195
  var merchantProductSchema = z2.object({
8456
9196
  id: z2.string().max(191),
8457
9197
  merchantAccountId: z2.string().max(191),
@@ -8461,7 +9201,19 @@ var merchantProductSchema = z2.object({
8461
9201
  createdAt: z2.date().nullable()
8462
9202
  });
8463
9203
 
8464
- // ../core/dist/chunk-256SROW3.js
9204
+ // ../core/dist/chunk-MS7XHKFQ.js
9205
+ var merchantChargeSchema = z2.object({
9206
+ id: z2.string().max(191),
9207
+ status: z2.number().int().default(0),
9208
+ identifier: z2.string().max(191),
9209
+ userId: z2.string().max(191),
9210
+ merchantAccountId: z2.string().max(191),
9211
+ merchantProductId: z2.string().max(191),
9212
+ createdAt: z2.date().nullable(),
9213
+ merchantCustomerId: z2.string().max(191)
9214
+ });
9215
+
9216
+ // ../core/dist/chunk-BMBVNXO6.js
8465
9217
  var merchantCouponSchema = z2.object({
8466
9218
  id: z2.string().max(191),
8467
9219
  identifier: z2.string().max(191).optional().nullable(),
@@ -8491,7 +9243,7 @@ var MerchantSessionSchema = z2.object({
8491
9243
  merchantAccountId: z2.string()
8492
9244
  });
8493
9245
 
8494
- // ../core/dist/chunk-NCUZHHRE.js
9246
+ // ../core/dist/chunk-7JAN7MEC.js
8495
9247
  var MerchantSubscriptionSchema = z2.object({
8496
9248
  id: z2.string(),
8497
9249
  organizationId: z2.string().nullable(),
@@ -8504,7 +9256,7 @@ var MerchantSubscriptionSchema = z2.object({
8504
9256
  merchantProductId: z2.string()
8505
9257
  });
8506
9258
 
8507
- // ../core/dist/chunk-KQ3HQRWM.js
9259
+ // ../core/dist/chunk-U5E6YHTY.js
8508
9260
  var OrganizationSchema = z2.object({
8509
9261
  id: z2.string(),
8510
9262
  name: z2.string().nullable(),
@@ -8807,6 +9559,8 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
8807
9559
  throw new Error(errorMessage);
8808
9560
  }
8809
9561
  const purchaseId = `purchase-${v4()}`;
9562
+ const userMemberships = await adapter.getMembershipsForUser(user.id);
9563
+ const organizationId = coupon2.organizationId || userMemberships.find((m) => m.organization.name?.includes(user.email))?.organizationId;
8810
9564
  await adapter.createPurchase({
8811
9565
  id: purchaseId,
8812
9566
  userId: user.id,
@@ -8814,6 +9568,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
8814
9568
  redeemedBulkCouponId: bulkCouponRedemption ? coupon2.id : null,
8815
9569
  productId,
8816
9570
  totalAmount: "0",
9571
+ organizationId,
8817
9572
  metadata: {
8818
9573
  couponUsedId: bulkCouponRedemption ? null : coupon2.id
8819
9574
  }
@@ -9126,6 +9881,9 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
9126
9881
  name,
9127
9882
  emailVerified: null
9128
9883
  });
9884
+ console.log("newUser", {
9885
+ newUser
9886
+ });
9129
9887
  if (!newUser) {
9130
9888
  throw new Error("Could not create user");
9131
9889
  }
@@ -9148,6 +9906,16 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
9148
9906
  });
9149
9907
  return couponSchema.nullable().parse(loadedCoupon);
9150
9908
  },
9909
+ async getPurchasesForBulkCouponId(bulkCouponId) {
9910
+ return z.array(purchaseSchema.extend({
9911
+ user: userSchema
9912
+ })).parse(await client.query.purchases.findMany({
9913
+ where: eq(purchaseTable.bulkCouponId, bulkCouponId),
9914
+ with: {
9915
+ user: true
9916
+ }
9917
+ }));
9918
+ },
9151
9919
  async getCouponWithBulkPurchases(couponId) {
9152
9920
  logger.debug("getCouponWithBulkPurchases", {
9153
9921
  couponId
@@ -9529,11 +10297,11 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
9529
10297
  id: newProductId,
9530
10298
  name: input.name,
9531
10299
  status: 1,
9532
- type: "self-paced",
10300
+ type: input.type || "self-paced",
9533
10301
  quantityAvailable: input.quantityAvailable,
9534
10302
  fields: {
9535
- state: "draft",
9536
- visibility: "unlisted",
10303
+ state: input.state || "draft",
10304
+ visibility: input.visibility || "unlisted",
9537
10305
  slug: slugify(`${input.name}-${hash}`)
9538
10306
  }
9539
10307
  };
@@ -9686,7 +10454,8 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
9686
10454
  return purchaseUserTransferSchema.merge(z.object({
9687
10455
  sourceUser: userSchema,
9688
10456
  targetUser: userSchema.nullable(),
9689
- purchase: purchaseSchema
10457
+ purchase: purchaseSchema,
10458
+ organizationId: z.string().nullable()
9690
10459
  })).nullable().parse(purchaseTransferData);
9691
10460
  },
9692
10461
  async getPurchaseWithUser(purchaseId) {
@@ -10301,7 +11070,11 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
10301
11070
  },
10302
11071
  addMemberToOrganization: async (options) => {
10303
11072
  const currentMembership = await client.query.organizationMemberships.findFirst({
10304
- where: and(eq(organizationMembershipTable.organizationId, options.organizationId), eq(organizationMembershipTable.userId, options.userId))
11073
+ where: and(eq(organizationMembershipTable.organizationId, options.organizationId), eq(organizationMembershipTable.userId, options.userId)),
11074
+ with: {
11075
+ organization: true,
11076
+ user: true
11077
+ }
10305
11078
  });
10306
11079
  if (currentMembership) {
10307
11080
  return OrganizationMemberSchema.parse(currentMembership);
@@ -10436,4 +11209,4 @@ export {
10436
11209
  createTables,
10437
11210
  mySqlDrizzleAdapter
10438
11211
  };
10439
- //# sourceMappingURL=chunk-5QEGBX2O.js.map
11212
+ //# sourceMappingURL=chunk-ARHWIBFG.js.map