@spscommerce/asst-api 0.2.0 → 1.0.0

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,7 @@
1
1
  // lib/asstClient.ts
2
2
  import ky from "ky-universal";
3
3
 
4
- // ../../node_modules/.pnpm/zod@3.21.4/node_modules/zod/lib/index.mjs
4
+ // ../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
5
5
  var util;
6
6
  (function(util2) {
7
7
  util2.assertEqual = (val) => val;
@@ -155,7 +155,7 @@ var quotelessJson = (obj) => {
155
155
  const json = JSON.stringify(obj, null, 2);
156
156
  return json.replace(/"([^"]+)":/g, "$1:");
157
157
  };
158
- var ZodError = class extends Error {
158
+ var ZodError = class _ZodError extends Error {
159
159
  constructor(issues) {
160
160
  super();
161
161
  this.issues = [];
@@ -213,6 +213,11 @@ var ZodError = class extends Error {
213
213
  processError(this);
214
214
  return fieldErrors;
215
215
  }
216
+ static assert(value) {
217
+ if (!(value instanceof _ZodError)) {
218
+ throw new Error(`Not a ZodError: ${value}`);
219
+ }
220
+ }
216
221
  toString() {
217
222
  return this.message;
218
223
  }
@@ -355,6 +360,13 @@ var makeIssue = (params) => {
355
360
  ...issueData,
356
361
  path: fullPath
357
362
  };
363
+ if (issueData.message !== void 0) {
364
+ return {
365
+ ...issueData,
366
+ path: fullPath,
367
+ message: issueData.message
368
+ };
369
+ }
358
370
  let errorMessage = "";
359
371
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
360
372
  for (const map of maps) {
@@ -363,11 +375,12 @@ var makeIssue = (params) => {
363
375
  return {
364
376
  ...issueData,
365
377
  path: fullPath,
366
- message: issueData.message || errorMessage
378
+ message: errorMessage
367
379
  };
368
380
  };
369
381
  var EMPTY_PATH = [];
370
382
  function addIssueToContext(ctx, issueData) {
383
+ const overrideMap = getErrorMap();
371
384
  const issue = makeIssue({
372
385
  issueData,
373
386
  data: ctx.data,
@@ -375,14 +388,14 @@ function addIssueToContext(ctx, issueData) {
375
388
  errorMaps: [
376
389
  ctx.common.contextualErrorMap,
377
390
  ctx.schemaErrorMap,
378
- getErrorMap(),
379
- errorMap
391
+ overrideMap,
392
+ overrideMap === errorMap ? void 0 : errorMap
380
393
  // then global default map
381
394
  ].filter((x) => !!x)
382
395
  });
383
396
  ctx.common.issues.push(issue);
384
397
  }
385
- var ParseStatus = class {
398
+ var ParseStatus = class _ParseStatus {
386
399
  constructor() {
387
400
  this.value = "valid";
388
401
  }
@@ -408,12 +421,14 @@ var ParseStatus = class {
408
421
  static async mergeObjectAsync(status, pairs) {
409
422
  const syncPairs = [];
410
423
  for (const pair of pairs) {
424
+ const key = await pair.key;
425
+ const value = await pair.value;
411
426
  syncPairs.push({
412
- key: await pair.key,
413
- value: await pair.value
427
+ key,
428
+ value
414
429
  });
415
430
  }
416
- return ParseStatus.mergeObjectSync(status, syncPairs);
431
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
417
432
  }
418
433
  static mergeObjectSync(status, pairs) {
419
434
  const finalObject = {};
@@ -427,7 +442,7 @@ var ParseStatus = class {
427
442
  status.dirty();
428
443
  if (value.status === "dirty")
429
444
  status.dirty();
430
- if (typeof value.value !== "undefined" || pair.alwaysSet) {
445
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
431
446
  finalObject[key.value] = value.value;
432
447
  }
433
448
  }
@@ -443,11 +458,29 @@ var isAborted = (x) => x.status === "aborted";
443
458
  var isDirty = (x) => x.status === "dirty";
444
459
  var isValid = (x) => x.status === "valid";
445
460
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
461
+ function __classPrivateFieldGet(receiver, state, kind, f) {
462
+ if (kind === "a" && !f)
463
+ throw new TypeError("Private accessor was defined without a getter");
464
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
465
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
466
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
467
+ }
468
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
469
+ if (kind === "m")
470
+ throw new TypeError("Private method is not writable");
471
+ if (kind === "a" && !f)
472
+ throw new TypeError("Private accessor was defined without a setter");
473
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
474
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
475
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
476
+ }
446
477
  var errorUtil;
447
478
  (function(errorUtil2) {
448
479
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
449
480
  errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
450
481
  })(errorUtil || (errorUtil = {}));
482
+ var _ZodEnum_cache;
483
+ var _ZodNativeEnum_cache;
451
484
  var ParseInputLazyPath = class {
452
485
  constructor(parent, value, path, key) {
453
486
  this._cachedPath = [];
@@ -496,12 +529,17 @@ function processCreateParams(params) {
496
529
  if (errorMap2)
497
530
  return { errorMap: errorMap2, description };
498
531
  const customMap = (iss, ctx) => {
499
- if (iss.code !== "invalid_type")
500
- return { message: ctx.defaultError };
532
+ var _a, _b;
533
+ const { message } = params;
534
+ if (iss.code === "invalid_enum_value") {
535
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
536
+ }
501
537
  if (typeof ctx.data === "undefined") {
502
- return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
538
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
503
539
  }
504
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
540
+ if (iss.code !== "invalid_type")
541
+ return { message: ctx.defaultError };
542
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
505
543
  };
506
544
  return { errorMap: customMap, description };
507
545
  }
@@ -530,6 +568,7 @@ var ZodType = class {
530
568
  this.catch = this.catch.bind(this);
531
569
  this.describe = this.describe.bind(this);
532
570
  this.pipe = this.pipe.bind(this);
571
+ this.readonly = this.readonly.bind(this);
533
572
  this.isNullable = this.isNullable.bind(this);
534
573
  this.isOptional = this.isOptional.bind(this);
535
574
  }
@@ -737,6 +776,9 @@ var ZodType = class {
737
776
  pipe(target) {
738
777
  return ZodPipeline.create(this, target);
739
778
  }
779
+ readonly() {
780
+ return ZodReadonly.create(this);
781
+ }
740
782
  isOptional() {
741
783
  return this.safeParse(void 0).success;
742
784
  }
@@ -745,34 +787,40 @@ var ZodType = class {
745
787
  }
746
788
  };
747
789
  var cuidRegex = /^c[^\s-]{8,}$/i;
748
- var cuid2Regex = /^[a-z][a-z0-9]*$/;
749
- var ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/;
750
- var uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
751
- var emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/;
752
- var emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u;
753
- 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}))$/;
790
+ var cuid2Regex = /^[0-9a-z]+$/;
791
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
792
+ 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;
793
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
794
+ 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)?)??$/;
795
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
796
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
797
+ var emojiRegex;
798
+ 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])$/;
754
799
  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})))$/;
755
- var datetimeRegex = (args) => {
800
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
801
+ 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])))`;
802
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
803
+ function timeRegexSource(args) {
804
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
756
805
  if (args.precision) {
757
- if (args.offset) {
758
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
759
- } else {
760
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
761
- }
762
- } else if (args.precision === 0) {
763
- if (args.offset) {
764
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
765
- } else {
766
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
767
- }
768
- } else {
769
- if (args.offset) {
770
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
771
- } else {
772
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
773
- }
806
+ regex = `${regex}\\.\\d{${args.precision}}`;
807
+ } else if (args.precision == null) {
808
+ regex = `${regex}(\\.\\d+)?`;
774
809
  }
775
- };
810
+ return regex;
811
+ }
812
+ function timeRegex(args) {
813
+ return new RegExp(`^${timeRegexSource(args)}$`);
814
+ }
815
+ function datetimeRegex(args) {
816
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
817
+ const opts = [];
818
+ opts.push(args.local ? `Z?` : `Z`);
819
+ if (args.offset)
820
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
821
+ regex = `${regex}(${opts.join("|")})`;
822
+ return new RegExp(`^${regex}$`);
823
+ }
776
824
  function isValidIP(ip, version) {
777
825
  if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
778
826
  return true;
@@ -782,28 +830,7 @@ function isValidIP(ip, version) {
782
830
  }
783
831
  return false;
784
832
  }
785
- var ZodString = class extends ZodType {
786
- constructor() {
787
- super(...arguments);
788
- this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
789
- validation,
790
- code: ZodIssueCode.invalid_string,
791
- ...errorUtil.errToObj(message)
792
- });
793
- this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
794
- this.trim = () => new ZodString({
795
- ...this._def,
796
- checks: [...this._def.checks, { kind: "trim" }]
797
- });
798
- this.toLowerCase = () => new ZodString({
799
- ...this._def,
800
- checks: [...this._def.checks, { kind: "toLowerCase" }]
801
- });
802
- this.toUpperCase = () => new ZodString({
803
- ...this._def,
804
- checks: [...this._def.checks, { kind: "toUpperCase" }]
805
- });
806
- }
833
+ var ZodString = class _ZodString extends ZodType {
807
834
  _parse(input) {
808
835
  if (this._def.coerce) {
809
836
  input.data = String(input.data);
@@ -811,15 +838,11 @@ var ZodString = class extends ZodType {
811
838
  const parsedType = this._getType(input);
812
839
  if (parsedType !== ZodParsedType.string) {
813
840
  const ctx2 = this._getOrReturnCtx(input);
814
- addIssueToContext(
815
- ctx2,
816
- {
817
- code: ZodIssueCode.invalid_type,
818
- expected: ZodParsedType.string,
819
- received: ctx2.parsedType
820
- }
821
- //
822
- );
841
+ addIssueToContext(ctx2, {
842
+ code: ZodIssueCode.invalid_type,
843
+ expected: ZodParsedType.string,
844
+ received: ctx2.parsedType
845
+ });
823
846
  return INVALID;
824
847
  }
825
848
  const status = new ParseStatus();
@@ -888,6 +911,9 @@ var ZodString = class extends ZodType {
888
911
  status.dirty();
889
912
  }
890
913
  } else if (check.kind === "emoji") {
914
+ if (!emojiRegex) {
915
+ emojiRegex = new RegExp(_emojiRegex, "u");
916
+ }
891
917
  if (!emojiRegex.test(input.data)) {
892
918
  ctx = this._getOrReturnCtx(input, ctx);
893
919
  addIssueToContext(ctx, {
@@ -907,6 +933,16 @@ var ZodString = class extends ZodType {
907
933
  });
908
934
  status.dirty();
909
935
  }
936
+ } else if (check.kind === "nanoid") {
937
+ if (!nanoidRegex.test(input.data)) {
938
+ ctx = this._getOrReturnCtx(input, ctx);
939
+ addIssueToContext(ctx, {
940
+ validation: "nanoid",
941
+ code: ZodIssueCode.invalid_string,
942
+ message: check.message
943
+ });
944
+ status.dirty();
945
+ }
910
946
  } else if (check.kind === "cuid") {
911
947
  if (!cuidRegex.test(input.data)) {
912
948
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1008,6 +1044,38 @@ var ZodString = class extends ZodType {
1008
1044
  });
1009
1045
  status.dirty();
1010
1046
  }
1047
+ } else if (check.kind === "date") {
1048
+ const regex = dateRegex;
1049
+ if (!regex.test(input.data)) {
1050
+ ctx = this._getOrReturnCtx(input, ctx);
1051
+ addIssueToContext(ctx, {
1052
+ code: ZodIssueCode.invalid_string,
1053
+ validation: "date",
1054
+ message: check.message
1055
+ });
1056
+ status.dirty();
1057
+ }
1058
+ } else if (check.kind === "time") {
1059
+ const regex = timeRegex(check);
1060
+ if (!regex.test(input.data)) {
1061
+ ctx = this._getOrReturnCtx(input, ctx);
1062
+ addIssueToContext(ctx, {
1063
+ code: ZodIssueCode.invalid_string,
1064
+ validation: "time",
1065
+ message: check.message
1066
+ });
1067
+ status.dirty();
1068
+ }
1069
+ } else if (check.kind === "duration") {
1070
+ if (!durationRegex.test(input.data)) {
1071
+ ctx = this._getOrReturnCtx(input, ctx);
1072
+ addIssueToContext(ctx, {
1073
+ validation: "duration",
1074
+ code: ZodIssueCode.invalid_string,
1075
+ message: check.message
1076
+ });
1077
+ status.dirty();
1078
+ }
1011
1079
  } else if (check.kind === "ip") {
1012
1080
  if (!isValidIP(input.data, check.version)) {
1013
1081
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1018,14 +1086,31 @@ var ZodString = class extends ZodType {
1018
1086
  });
1019
1087
  status.dirty();
1020
1088
  }
1089
+ } else if (check.kind === "base64") {
1090
+ if (!base64Regex.test(input.data)) {
1091
+ ctx = this._getOrReturnCtx(input, ctx);
1092
+ addIssueToContext(ctx, {
1093
+ validation: "base64",
1094
+ code: ZodIssueCode.invalid_string,
1095
+ message: check.message
1096
+ });
1097
+ status.dirty();
1098
+ }
1021
1099
  } else {
1022
1100
  util.assertNever(check);
1023
1101
  }
1024
1102
  }
1025
1103
  return { status: status.value, value: input.data };
1026
1104
  }
1105
+ _regex(regex, validation, message) {
1106
+ return this.refinement((data) => regex.test(data), {
1107
+ validation,
1108
+ code: ZodIssueCode.invalid_string,
1109
+ ...errorUtil.errToObj(message)
1110
+ });
1111
+ }
1027
1112
  _addCheck(check) {
1028
- return new ZodString({
1113
+ return new _ZodString({
1029
1114
  ...this._def,
1030
1115
  checks: [...this._def.checks, check]
1031
1116
  });
@@ -1042,6 +1127,9 @@ var ZodString = class extends ZodType {
1042
1127
  uuid(message) {
1043
1128
  return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1044
1129
  }
1130
+ nanoid(message) {
1131
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1132
+ }
1045
1133
  cuid(message) {
1046
1134
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1047
1135
  }
@@ -1051,16 +1139,20 @@ var ZodString = class extends ZodType {
1051
1139
  ulid(message) {
1052
1140
  return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1053
1141
  }
1142
+ base64(message) {
1143
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1144
+ }
1054
1145
  ip(options) {
1055
1146
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1056
1147
  }
1057
1148
  datetime(options) {
1058
- var _a;
1149
+ var _a, _b;
1059
1150
  if (typeof options === "string") {
1060
1151
  return this._addCheck({
1061
1152
  kind: "datetime",
1062
1153
  precision: null,
1063
1154
  offset: false,
1155
+ local: false,
1064
1156
  message: options
1065
1157
  });
1066
1158
  }
@@ -1068,9 +1160,30 @@ var ZodString = class extends ZodType {
1068
1160
  kind: "datetime",
1069
1161
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1070
1162
  offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1163
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
1071
1164
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1072
1165
  });
1073
1166
  }
1167
+ date(message) {
1168
+ return this._addCheck({ kind: "date", message });
1169
+ }
1170
+ time(options) {
1171
+ if (typeof options === "string") {
1172
+ return this._addCheck({
1173
+ kind: "time",
1174
+ precision: null,
1175
+ message: options
1176
+ });
1177
+ }
1178
+ return this._addCheck({
1179
+ kind: "time",
1180
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1181
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1182
+ });
1183
+ }
1184
+ duration(message) {
1185
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1186
+ }
1074
1187
  regex(regex, message) {
1075
1188
  return this._addCheck({
1076
1189
  kind: "regex",
@@ -1121,9 +1234,43 @@ var ZodString = class extends ZodType {
1121
1234
  ...errorUtil.errToObj(message)
1122
1235
  });
1123
1236
  }
1237
+ /**
1238
+ * @deprecated Use z.string().min(1) instead.
1239
+ * @see {@link ZodString.min}
1240
+ */
1241
+ nonempty(message) {
1242
+ return this.min(1, errorUtil.errToObj(message));
1243
+ }
1244
+ trim() {
1245
+ return new _ZodString({
1246
+ ...this._def,
1247
+ checks: [...this._def.checks, { kind: "trim" }]
1248
+ });
1249
+ }
1250
+ toLowerCase() {
1251
+ return new _ZodString({
1252
+ ...this._def,
1253
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1254
+ });
1255
+ }
1256
+ toUpperCase() {
1257
+ return new _ZodString({
1258
+ ...this._def,
1259
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1260
+ });
1261
+ }
1124
1262
  get isDatetime() {
1125
1263
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
1126
1264
  }
1265
+ get isDate() {
1266
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1267
+ }
1268
+ get isTime() {
1269
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1270
+ }
1271
+ get isDuration() {
1272
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1273
+ }
1127
1274
  get isEmail() {
1128
1275
  return !!this._def.checks.find((ch) => ch.kind === "email");
1129
1276
  }
@@ -1136,6 +1283,9 @@ var ZodString = class extends ZodType {
1136
1283
  get isUUID() {
1137
1284
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
1138
1285
  }
1286
+ get isNANOID() {
1287
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1288
+ }
1139
1289
  get isCUID() {
1140
1290
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
1141
1291
  }
@@ -1148,6 +1298,9 @@ var ZodString = class extends ZodType {
1148
1298
  get isIP() {
1149
1299
  return !!this._def.checks.find((ch) => ch.kind === "ip");
1150
1300
  }
1301
+ get isBase64() {
1302
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1303
+ }
1151
1304
  get minLength() {
1152
1305
  let min = null;
1153
1306
  for (const ch of this._def.checks) {
@@ -1186,7 +1339,7 @@ function floatSafeRemainder(val, step) {
1186
1339
  const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
1187
1340
  return valInt % stepInt / Math.pow(10, decCount);
1188
1341
  }
1189
- var ZodNumber = class extends ZodType {
1342
+ var ZodNumber = class _ZodNumber extends ZodType {
1190
1343
  constructor() {
1191
1344
  super(...arguments);
1192
1345
  this.min = this.gte;
@@ -1287,7 +1440,7 @@ var ZodNumber = class extends ZodType {
1287
1440
  return this.setLimit("max", value, false, errorUtil.toString(message));
1288
1441
  }
1289
1442
  setLimit(kind, value, inclusive, message) {
1290
- return new ZodNumber({
1443
+ return new _ZodNumber({
1291
1444
  ...this._def,
1292
1445
  checks: [
1293
1446
  ...this._def.checks,
@@ -1301,7 +1454,7 @@ var ZodNumber = class extends ZodType {
1301
1454
  });
1302
1455
  }
1303
1456
  _addCheck(check) {
1304
- return new ZodNumber({
1457
+ return new _ZodNumber({
1305
1458
  ...this._def,
1306
1459
  checks: [...this._def.checks, check]
1307
1460
  });
@@ -1417,7 +1570,7 @@ ZodNumber.create = (params) => {
1417
1570
  ...processCreateParams(params)
1418
1571
  });
1419
1572
  };
1420
- var ZodBigInt = class extends ZodType {
1573
+ var ZodBigInt = class _ZodBigInt extends ZodType {
1421
1574
  constructor() {
1422
1575
  super(...arguments);
1423
1576
  this.min = this.gte;
@@ -1495,7 +1648,7 @@ var ZodBigInt = class extends ZodType {
1495
1648
  return this.setLimit("max", value, false, errorUtil.toString(message));
1496
1649
  }
1497
1650
  setLimit(kind, value, inclusive, message) {
1498
- return new ZodBigInt({
1651
+ return new _ZodBigInt({
1499
1652
  ...this._def,
1500
1653
  checks: [
1501
1654
  ...this._def.checks,
@@ -1509,7 +1662,7 @@ var ZodBigInt = class extends ZodType {
1509
1662
  });
1510
1663
  }
1511
1664
  _addCheck(check) {
1512
- return new ZodBigInt({
1665
+ return new _ZodBigInt({
1513
1666
  ...this._def,
1514
1667
  checks: [...this._def.checks, check]
1515
1668
  });
@@ -1608,7 +1761,7 @@ ZodBoolean.create = (params) => {
1608
1761
  ...processCreateParams(params)
1609
1762
  });
1610
1763
  };
1611
- var ZodDate = class extends ZodType {
1764
+ var ZodDate = class _ZodDate extends ZodType {
1612
1765
  _parse(input) {
1613
1766
  if (this._def.coerce) {
1614
1767
  input.data = new Date(input.data);
@@ -1669,7 +1822,7 @@ var ZodDate = class extends ZodType {
1669
1822
  };
1670
1823
  }
1671
1824
  _addCheck(check) {
1672
- return new ZodDate({
1825
+ return new _ZodDate({
1673
1826
  ...this._def,
1674
1827
  checks: [...this._def.checks, check]
1675
1828
  });
@@ -1848,7 +2001,7 @@ ZodVoid.create = (params) => {
1848
2001
  ...processCreateParams(params)
1849
2002
  });
1850
2003
  };
1851
- var ZodArray = class extends ZodType {
2004
+ var ZodArray = class _ZodArray extends ZodType {
1852
2005
  _parse(input) {
1853
2006
  const { ctx, status } = this._processInputParams(input);
1854
2007
  const def = this._def;
@@ -1918,19 +2071,19 @@ var ZodArray = class extends ZodType {
1918
2071
  return this._def.type;
1919
2072
  }
1920
2073
  min(minLength, message) {
1921
- return new ZodArray({
2074
+ return new _ZodArray({
1922
2075
  ...this._def,
1923
2076
  minLength: { value: minLength, message: errorUtil.toString(message) }
1924
2077
  });
1925
2078
  }
1926
2079
  max(maxLength, message) {
1927
- return new ZodArray({
2080
+ return new _ZodArray({
1928
2081
  ...this._def,
1929
2082
  maxLength: { value: maxLength, message: errorUtil.toString(message) }
1930
2083
  });
1931
2084
  }
1932
2085
  length(len, message) {
1933
- return new ZodArray({
2086
+ return new _ZodArray({
1934
2087
  ...this._def,
1935
2088
  exactLength: { value: len, message: errorUtil.toString(message) }
1936
2089
  });
@@ -1975,7 +2128,7 @@ function deepPartialify(schema) {
1975
2128
  return schema;
1976
2129
  }
1977
2130
  }
1978
- var ZodObject = class extends ZodType {
2131
+ var ZodObject = class _ZodObject extends ZodType {
1979
2132
  constructor() {
1980
2133
  super(...arguments);
1981
2134
  this._cached = null;
@@ -2061,9 +2214,10 @@ var ZodObject = class extends ZodType {
2061
2214
  const syncPairs = [];
2062
2215
  for (const pair of pairs) {
2063
2216
  const key = await pair.key;
2217
+ const value = await pair.value;
2064
2218
  syncPairs.push({
2065
2219
  key,
2066
- value: await pair.value,
2220
+ value,
2067
2221
  alwaysSet: pair.alwaysSet
2068
2222
  });
2069
2223
  }
@@ -2080,7 +2234,7 @@ var ZodObject = class extends ZodType {
2080
2234
  }
2081
2235
  strict(message) {
2082
2236
  errorUtil.errToObj;
2083
- return new ZodObject({
2237
+ return new _ZodObject({
2084
2238
  ...this._def,
2085
2239
  unknownKeys: "strict",
2086
2240
  ...message !== void 0 ? {
@@ -2099,13 +2253,13 @@ var ZodObject = class extends ZodType {
2099
2253
  });
2100
2254
  }
2101
2255
  strip() {
2102
- return new ZodObject({
2256
+ return new _ZodObject({
2103
2257
  ...this._def,
2104
2258
  unknownKeys: "strip"
2105
2259
  });
2106
2260
  }
2107
2261
  passthrough() {
2108
- return new ZodObject({
2262
+ return new _ZodObject({
2109
2263
  ...this._def,
2110
2264
  unknownKeys: "passthrough"
2111
2265
  });
@@ -2128,7 +2282,7 @@ var ZodObject = class extends ZodType {
2128
2282
  // }) as any;
2129
2283
  // };
2130
2284
  extend(augmentation) {
2131
- return new ZodObject({
2285
+ return new _ZodObject({
2132
2286
  ...this._def,
2133
2287
  shape: () => ({
2134
2288
  ...this._def.shape(),
@@ -2142,7 +2296,7 @@ var ZodObject = class extends ZodType {
2142
2296
  * upgrade if you are experiencing issues.
2143
2297
  */
2144
2298
  merge(merging) {
2145
- const merged = new ZodObject({
2299
+ const merged = new _ZodObject({
2146
2300
  unknownKeys: merging._def.unknownKeys,
2147
2301
  catchall: merging._def.catchall,
2148
2302
  shape: () => ({
@@ -2213,7 +2367,7 @@ var ZodObject = class extends ZodType {
2213
2367
  // return merged;
2214
2368
  // }
2215
2369
  catchall(index) {
2216
- return new ZodObject({
2370
+ return new _ZodObject({
2217
2371
  ...this._def,
2218
2372
  catchall: index
2219
2373
  });
@@ -2225,7 +2379,7 @@ var ZodObject = class extends ZodType {
2225
2379
  shape[key] = this.shape[key];
2226
2380
  }
2227
2381
  });
2228
- return new ZodObject({
2382
+ return new _ZodObject({
2229
2383
  ...this._def,
2230
2384
  shape: () => shape
2231
2385
  });
@@ -2237,7 +2391,7 @@ var ZodObject = class extends ZodType {
2237
2391
  shape[key] = this.shape[key];
2238
2392
  }
2239
2393
  });
2240
- return new ZodObject({
2394
+ return new _ZodObject({
2241
2395
  ...this._def,
2242
2396
  shape: () => shape
2243
2397
  });
@@ -2258,7 +2412,7 @@ var ZodObject = class extends ZodType {
2258
2412
  newShape[key] = fieldSchema.optional();
2259
2413
  }
2260
2414
  });
2261
- return new ZodObject({
2415
+ return new _ZodObject({
2262
2416
  ...this._def,
2263
2417
  shape: () => newShape
2264
2418
  });
@@ -2277,7 +2431,7 @@ var ZodObject = class extends ZodType {
2277
2431
  newShape[key] = newField;
2278
2432
  }
2279
2433
  });
2280
- return new ZodObject({
2434
+ return new _ZodObject({
2281
2435
  ...this._def,
2282
2436
  shape: () => newShape
2283
2437
  });
@@ -2414,18 +2568,28 @@ var getDiscriminator = (type) => {
2414
2568
  } else if (type instanceof ZodEnum) {
2415
2569
  return type.options;
2416
2570
  } else if (type instanceof ZodNativeEnum) {
2417
- return Object.keys(type.enum);
2571
+ return util.objectValues(type.enum);
2418
2572
  } else if (type instanceof ZodDefault) {
2419
2573
  return getDiscriminator(type._def.innerType);
2420
2574
  } else if (type instanceof ZodUndefined) {
2421
2575
  return [void 0];
2422
2576
  } else if (type instanceof ZodNull) {
2423
2577
  return [null];
2578
+ } else if (type instanceof ZodOptional) {
2579
+ return [void 0, ...getDiscriminator(type.unwrap())];
2580
+ } else if (type instanceof ZodNullable) {
2581
+ return [null, ...getDiscriminator(type.unwrap())];
2582
+ } else if (type instanceof ZodBranded) {
2583
+ return getDiscriminator(type.unwrap());
2584
+ } else if (type instanceof ZodReadonly) {
2585
+ return getDiscriminator(type.unwrap());
2586
+ } else if (type instanceof ZodCatch) {
2587
+ return getDiscriminator(type._def.innerType);
2424
2588
  } else {
2425
- return null;
2589
+ return [];
2426
2590
  }
2427
2591
  };
2428
- var ZodDiscriminatedUnion = class extends ZodType {
2592
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2429
2593
  _parse(input) {
2430
2594
  const { ctx } = this._processInputParams(input);
2431
2595
  if (ctx.parsedType !== ZodParsedType.object) {
@@ -2482,7 +2646,7 @@ var ZodDiscriminatedUnion = class extends ZodType {
2482
2646
  const optionsMap = /* @__PURE__ */ new Map();
2483
2647
  for (const type of options) {
2484
2648
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2485
- if (!discriminatorValues) {
2649
+ if (!discriminatorValues.length) {
2486
2650
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2487
2651
  }
2488
2652
  for (const value of discriminatorValues) {
@@ -2492,7 +2656,7 @@ var ZodDiscriminatedUnion = class extends ZodType {
2492
2656
  optionsMap.set(value, type);
2493
2657
  }
2494
2658
  }
2495
- return new ZodDiscriminatedUnion({
2659
+ return new _ZodDiscriminatedUnion({
2496
2660
  typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2497
2661
  discriminator,
2498
2662
  options,
@@ -2592,7 +2756,7 @@ ZodIntersection.create = (left, right, params) => {
2592
2756
  ...processCreateParams(params)
2593
2757
  });
2594
2758
  };
2595
- var ZodTuple = class extends ZodType {
2759
+ var ZodTuple = class _ZodTuple extends ZodType {
2596
2760
  _parse(input) {
2597
2761
  const { status, ctx } = this._processInputParams(input);
2598
2762
  if (ctx.parsedType !== ZodParsedType.array) {
@@ -2642,7 +2806,7 @@ var ZodTuple = class extends ZodType {
2642
2806
  return this._def.items;
2643
2807
  }
2644
2808
  rest(rest) {
2645
- return new ZodTuple({
2809
+ return new _ZodTuple({
2646
2810
  ...this._def,
2647
2811
  rest
2648
2812
  });
@@ -2659,7 +2823,7 @@ ZodTuple.create = (schemas, params) => {
2659
2823
  ...processCreateParams(params)
2660
2824
  });
2661
2825
  };
2662
- var ZodRecord = class extends ZodType {
2826
+ var ZodRecord = class _ZodRecord extends ZodType {
2663
2827
  get keySchema() {
2664
2828
  return this._def.keyType;
2665
2829
  }
@@ -2682,7 +2846,8 @@ var ZodRecord = class extends ZodType {
2682
2846
  for (const key in ctx.data) {
2683
2847
  pairs.push({
2684
2848
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2685
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
2849
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
2850
+ alwaysSet: key in ctx.data
2686
2851
  });
2687
2852
  }
2688
2853
  if (ctx.common.async) {
@@ -2696,14 +2861,14 @@ var ZodRecord = class extends ZodType {
2696
2861
  }
2697
2862
  static create(first, second, third) {
2698
2863
  if (second instanceof ZodType) {
2699
- return new ZodRecord({
2864
+ return new _ZodRecord({
2700
2865
  keyType: first,
2701
2866
  valueType: second,
2702
2867
  typeName: ZodFirstPartyTypeKind.ZodRecord,
2703
2868
  ...processCreateParams(third)
2704
2869
  });
2705
2870
  }
2706
- return new ZodRecord({
2871
+ return new _ZodRecord({
2707
2872
  keyType: ZodString.create(),
2708
2873
  valueType: first,
2709
2874
  typeName: ZodFirstPartyTypeKind.ZodRecord,
@@ -2712,6 +2877,12 @@ var ZodRecord = class extends ZodType {
2712
2877
  }
2713
2878
  };
2714
2879
  var ZodMap = class extends ZodType {
2880
+ get keySchema() {
2881
+ return this._def.keyType;
2882
+ }
2883
+ get valueSchema() {
2884
+ return this._def.valueType;
2885
+ }
2715
2886
  _parse(input) {
2716
2887
  const { status, ctx } = this._processInputParams(input);
2717
2888
  if (ctx.parsedType !== ZodParsedType.map) {
@@ -2771,7 +2942,7 @@ ZodMap.create = (keyType, valueType, params) => {
2771
2942
  ...processCreateParams(params)
2772
2943
  });
2773
2944
  };
2774
- var ZodSet = class extends ZodType {
2945
+ var ZodSet = class _ZodSet extends ZodType {
2775
2946
  _parse(input) {
2776
2947
  const { status, ctx } = this._processInputParams(input);
2777
2948
  if (ctx.parsedType !== ZodParsedType.set) {
@@ -2829,13 +3000,13 @@ var ZodSet = class extends ZodType {
2829
3000
  }
2830
3001
  }
2831
3002
  min(minSize, message) {
2832
- return new ZodSet({
3003
+ return new _ZodSet({
2833
3004
  ...this._def,
2834
3005
  minSize: { value: minSize, message: errorUtil.toString(message) }
2835
3006
  });
2836
3007
  }
2837
3008
  max(maxSize, message) {
2838
- return new ZodSet({
3009
+ return new _ZodSet({
2839
3010
  ...this._def,
2840
3011
  maxSize: { value: maxSize, message: errorUtil.toString(message) }
2841
3012
  });
@@ -2856,7 +3027,7 @@ ZodSet.create = (valueType, params) => {
2856
3027
  ...processCreateParams(params)
2857
3028
  });
2858
3029
  };
2859
- var ZodFunction = class extends ZodType {
3030
+ var ZodFunction = class _ZodFunction extends ZodType {
2860
3031
  constructor() {
2861
3032
  super(...arguments);
2862
3033
  this.validate = this.implement;
@@ -2906,27 +3077,29 @@ var ZodFunction = class extends ZodType {
2906
3077
  const params = { errorMap: ctx.common.contextualErrorMap };
2907
3078
  const fn = ctx.data;
2908
3079
  if (this._def.returns instanceof ZodPromise) {
2909
- return OK(async (...args) => {
3080
+ const me = this;
3081
+ return OK(async function(...args) {
2910
3082
  const error = new ZodError([]);
2911
- const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => {
3083
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
2912
3084
  error.addIssue(makeArgsIssue(args, e));
2913
3085
  throw error;
2914
3086
  });
2915
- const result = await fn(...parsedArgs);
2916
- const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => {
3087
+ const result = await Reflect.apply(fn, this, parsedArgs);
3088
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
2917
3089
  error.addIssue(makeReturnsIssue(result, e));
2918
3090
  throw error;
2919
3091
  });
2920
3092
  return parsedReturns;
2921
3093
  });
2922
3094
  } else {
2923
- return OK((...args) => {
2924
- const parsedArgs = this._def.args.safeParse(args, params);
3095
+ const me = this;
3096
+ return OK(function(...args) {
3097
+ const parsedArgs = me._def.args.safeParse(args, params);
2925
3098
  if (!parsedArgs.success) {
2926
3099
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
2927
3100
  }
2928
- const result = fn(...parsedArgs.data);
2929
- const parsedReturns = this._def.returns.safeParse(result, params);
3101
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3102
+ const parsedReturns = me._def.returns.safeParse(result, params);
2930
3103
  if (!parsedReturns.success) {
2931
3104
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
2932
3105
  }
@@ -2941,13 +3114,13 @@ var ZodFunction = class extends ZodType {
2941
3114
  return this._def.returns;
2942
3115
  }
2943
3116
  args(...items) {
2944
- return new ZodFunction({
3117
+ return new _ZodFunction({
2945
3118
  ...this._def,
2946
3119
  args: ZodTuple.create(items).rest(ZodUnknown.create())
2947
3120
  });
2948
3121
  }
2949
3122
  returns(returnType) {
2950
- return new ZodFunction({
3123
+ return new _ZodFunction({
2951
3124
  ...this._def,
2952
3125
  returns: returnType
2953
3126
  });
@@ -2961,7 +3134,7 @@ var ZodFunction = class extends ZodType {
2961
3134
  return validatedFunc;
2962
3135
  }
2963
3136
  static create(args, returns, params) {
2964
- return new ZodFunction({
3137
+ return new _ZodFunction({
2965
3138
  args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
2966
3139
  returns: returns || ZodUnknown.create(),
2967
3140
  typeName: ZodFirstPartyTypeKind.ZodFunction,
@@ -3017,7 +3190,11 @@ function createZodEnum(values, params) {
3017
3190
  ...processCreateParams(params)
3018
3191
  });
3019
3192
  }
3020
- var ZodEnum = class extends ZodType {
3193
+ var ZodEnum = class _ZodEnum extends ZodType {
3194
+ constructor() {
3195
+ super(...arguments);
3196
+ _ZodEnum_cache.set(this, void 0);
3197
+ }
3021
3198
  _parse(input) {
3022
3199
  if (typeof input.data !== "string") {
3023
3200
  const ctx = this._getOrReturnCtx(input);
@@ -3029,7 +3206,10 @@ var ZodEnum = class extends ZodType {
3029
3206
  });
3030
3207
  return INVALID;
3031
3208
  }
3032
- if (this._def.values.indexOf(input.data) === -1) {
3209
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
3210
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
3211
+ }
3212
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3033
3213
  const ctx = this._getOrReturnCtx(input);
3034
3214
  const expectedValues = this._def.values;
3035
3215
  addIssueToContext(ctx, {
@@ -3065,15 +3245,26 @@ var ZodEnum = class extends ZodType {
3065
3245
  }
3066
3246
  return enumValues;
3067
3247
  }
3068
- extract(values) {
3069
- return ZodEnum.create(values);
3248
+ extract(values, newDef = this._def) {
3249
+ return _ZodEnum.create(values, {
3250
+ ...this._def,
3251
+ ...newDef
3252
+ });
3070
3253
  }
3071
- exclude(values) {
3072
- return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
3254
+ exclude(values, newDef = this._def) {
3255
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3256
+ ...this._def,
3257
+ ...newDef
3258
+ });
3073
3259
  }
3074
3260
  };
3261
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3075
3262
  ZodEnum.create = createZodEnum;
3076
3263
  var ZodNativeEnum = class extends ZodType {
3264
+ constructor() {
3265
+ super(...arguments);
3266
+ _ZodNativeEnum_cache.set(this, void 0);
3267
+ }
3077
3268
  _parse(input) {
3078
3269
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3079
3270
  const ctx = this._getOrReturnCtx(input);
@@ -3086,7 +3277,10 @@ var ZodNativeEnum = class extends ZodType {
3086
3277
  });
3087
3278
  return INVALID;
3088
3279
  }
3089
- if (nativeEnumValues.indexOf(input.data) === -1) {
3280
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
3281
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
3282
+ }
3283
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3090
3284
  const expectedValues = util.objectValues(nativeEnumValues);
3091
3285
  addIssueToContext(ctx, {
3092
3286
  received: ctx.data,
@@ -3101,6 +3295,7 @@ var ZodNativeEnum = class extends ZodType {
3101
3295
  return this._def.values;
3102
3296
  }
3103
3297
  };
3298
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3104
3299
  ZodNativeEnum.create = (values, params) => {
3105
3300
  return new ZodNativeEnum({
3106
3301
  values,
@@ -3148,24 +3343,6 @@ var ZodEffects = class extends ZodType {
3148
3343
  _parse(input) {
3149
3344
  const { status, ctx } = this._processInputParams(input);
3150
3345
  const effect = this._def.effect || null;
3151
- if (effect.type === "preprocess") {
3152
- const processed = effect.transform(ctx.data);
3153
- if (ctx.common.async) {
3154
- return Promise.resolve(processed).then((processed2) => {
3155
- return this._def.schema._parseAsync({
3156
- data: processed2,
3157
- path: ctx.path,
3158
- parent: ctx
3159
- });
3160
- });
3161
- } else {
3162
- return this._def.schema._parseSync({
3163
- data: processed,
3164
- path: ctx.path,
3165
- parent: ctx
3166
- });
3167
- }
3168
- }
3169
3346
  const checkCtx = {
3170
3347
  addIssue: (arg) => {
3171
3348
  addIssueToContext(ctx, arg);
@@ -3180,6 +3357,42 @@ var ZodEffects = class extends ZodType {
3180
3357
  }
3181
3358
  };
3182
3359
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3360
+ if (effect.type === "preprocess") {
3361
+ const processed = effect.transform(ctx.data, checkCtx);
3362
+ if (ctx.common.async) {
3363
+ return Promise.resolve(processed).then(async (processed2) => {
3364
+ if (status.value === "aborted")
3365
+ return INVALID;
3366
+ const result = await this._def.schema._parseAsync({
3367
+ data: processed2,
3368
+ path: ctx.path,
3369
+ parent: ctx
3370
+ });
3371
+ if (result.status === "aborted")
3372
+ return INVALID;
3373
+ if (result.status === "dirty")
3374
+ return DIRTY(result.value);
3375
+ if (status.value === "dirty")
3376
+ return DIRTY(result.value);
3377
+ return result;
3378
+ });
3379
+ } else {
3380
+ if (status.value === "aborted")
3381
+ return INVALID;
3382
+ const result = this._def.schema._parseSync({
3383
+ data: processed,
3384
+ path: ctx.path,
3385
+ parent: ctx
3386
+ });
3387
+ if (result.status === "aborted")
3388
+ return INVALID;
3389
+ if (result.status === "dirty")
3390
+ return DIRTY(result.value);
3391
+ if (status.value === "dirty")
3392
+ return DIRTY(result.value);
3393
+ return result;
3394
+ }
3395
+ }
3183
3396
  if (effect.type === "refinement") {
3184
3397
  const executeRefinement = (acc) => {
3185
3398
  const result = effect.refinement(acc, checkCtx);
@@ -3408,7 +3621,7 @@ var ZodBranded = class extends ZodType {
3408
3621
  return this._def.type;
3409
3622
  }
3410
3623
  };
3411
- var ZodPipeline = class extends ZodType {
3624
+ var ZodPipeline = class _ZodPipeline extends ZodType {
3412
3625
  _parse(input) {
3413
3626
  const { status, ctx } = this._processInputParams(input);
3414
3627
  if (ctx.common.async) {
@@ -3456,14 +3669,36 @@ var ZodPipeline = class extends ZodType {
3456
3669
  }
3457
3670
  }
3458
3671
  static create(a, b) {
3459
- return new ZodPipeline({
3672
+ return new _ZodPipeline({
3460
3673
  in: a,
3461
3674
  out: b,
3462
3675
  typeName: ZodFirstPartyTypeKind.ZodPipeline
3463
3676
  });
3464
3677
  }
3465
3678
  };
3466
- var custom = (check, params = {}, fatal) => {
3679
+ var ZodReadonly = class extends ZodType {
3680
+ _parse(input) {
3681
+ const result = this._def.innerType._parse(input);
3682
+ const freeze = (data) => {
3683
+ if (isValid(data)) {
3684
+ data.value = Object.freeze(data.value);
3685
+ }
3686
+ return data;
3687
+ };
3688
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
3689
+ }
3690
+ unwrap() {
3691
+ return this._def.innerType;
3692
+ }
3693
+ };
3694
+ ZodReadonly.create = (type, params) => {
3695
+ return new ZodReadonly({
3696
+ innerType: type,
3697
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
3698
+ ...processCreateParams(params)
3699
+ });
3700
+ };
3701
+ function custom(check, params = {}, fatal) {
3467
3702
  if (check)
3468
3703
  return ZodAny.create().superRefine((data, ctx) => {
3469
3704
  var _a, _b;
@@ -3475,7 +3710,7 @@ var custom = (check, params = {}, fatal) => {
3475
3710
  }
3476
3711
  });
3477
3712
  return ZodAny.create();
3478
- };
3713
+ }
3479
3714
  var late = {
3480
3715
  object: ZodObject.lazycreate
3481
3716
  };
@@ -3516,6 +3751,7 @@ var ZodFirstPartyTypeKind;
3516
3751
  ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
3517
3752
  ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
3518
3753
  ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
3754
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
3519
3755
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
3520
3756
  var instanceOfType = (cls, params = {
3521
3757
  message: `Input not instance of ${cls.name}`
@@ -3593,6 +3829,7 @@ var z = /* @__PURE__ */ Object.freeze({
3593
3829
  ZodParsedType,
3594
3830
  getParsedType,
3595
3831
  ZodType,
3832
+ datetimeRegex,
3596
3833
  ZodString,
3597
3834
  ZodNumber,
3598
3835
  ZodBigInt,
@@ -3630,6 +3867,7 @@ var z = /* @__PURE__ */ Object.freeze({
3630
3867
  BRAND,
3631
3868
  ZodBranded,
3632
3869
  ZodPipeline,
3870
+ ZodReadonly,
3633
3871
  custom,
3634
3872
  Schema: ZodType,
3635
3873
  ZodSchema: ZodType,
@@ -3900,28 +4138,23 @@ var itemCategoriesSearchSchema = z.object({
3900
4138
  data: z.array(itemCategorySchema)
3901
4139
  });
3902
4140
 
3903
- // lib/categories/models/Hierarchy.ts
4141
+ // lib/categories/models/ItemHierarchyResponse.ts
3904
4142
  var baseHierarchySchema = z.object({
3905
4143
  id: z.string(),
3906
4144
  name: z.string().nullish(),
3907
4145
  description: z.string().nullish(),
3908
4146
  type: z.string().nullish()
3909
4147
  });
3910
- var hierarchySchema = baseHierarchySchema.extend(
3911
- {
3912
- child: z.lazy(() => hierarchySchema).nullable()
3913
- }
3914
- );
3915
-
3916
- // lib/categories/models/ItemHierarchy.ts
3917
- var itemHierarchySchema = z.object({
3918
- itemId: z.string(),
3919
- hierarchies: z.array(hierarchySchema)
4148
+ var hierarchySchema = baseHierarchySchema.extend({
4149
+ child: z.lazy(() => hierarchySchema).nullable()
3920
4150
  });
3921
-
3922
- // lib/categories/models/ItemHierarchyResponse.ts
3923
4151
  var itemHierarchyResponseSchema = z.object({
3924
- itemHierarchies: z.array(itemHierarchySchema)
4152
+ itemHierarchies: z.array(
4153
+ z.object({
4154
+ itemId: z.string(),
4155
+ hierarchies: z.array(hierarchySchema)
4156
+ })
4157
+ )
3925
4158
  });
3926
4159
 
3927
4160
  // lib/attributes/models/AttributeMetaData.ts
@@ -4078,7 +4311,7 @@ var attributeValidValuesSchema = z.object({
4078
4311
  attrKeyPair: z.string()
4079
4312
  });
4080
4313
 
4081
- // lib/items/models/ItemHeader.ts
4314
+ // lib/items/v1/models/ItemHeader.ts
4082
4315
  var itemHeaderSchema = z.object({
4083
4316
  status: z.string().optional(),
4084
4317
  catalogName: z.string(),
@@ -4094,7 +4327,7 @@ var itemHeaderSchema = z.object({
4094
4327
  itemInfoId: z.string()
4095
4328
  });
4096
4329
 
4097
- // lib/items/models/PhaseEnum.ts
4330
+ // lib/items/v1/models/PhaseEnum.ts
4098
4331
  var phaseEnumSchema = z.enum([
4099
4332
  "CORE",
4100
4333
  "CORE_PLUS",
@@ -4103,7 +4336,7 @@ var phaseEnumSchema = z.enum([
4103
4336
  "STANDARD_REQUIREMENTS"
4104
4337
  ]);
4105
4338
 
4106
- // lib/items/models/TradingPartnerStage.ts
4339
+ // lib/items/v1/models/TradingPartnerStage.ts
4107
4340
  var tradingPartnerStageSchema = z.object({
4108
4341
  companyId: z.number(),
4109
4342
  companyName: z.string(),
@@ -4111,7 +4344,7 @@ var tradingPartnerStageSchema = z.object({
4111
4344
  isValid: z.boolean()
4112
4345
  });
4113
4346
 
4114
- // lib/items/models/ItemMap.ts
4347
+ // lib/items/v1/models/ItemMap.ts
4115
4348
  var itemMapSchema = z.object({
4116
4349
  rn: z.number().optional(),
4117
4350
  iteminfoid: z.string(),
@@ -4134,20 +4367,20 @@ var itemMapSchema = z.object({
4134
4367
  productsizedescription: z.array(z.string()).nullish()
4135
4368
  }).passthrough();
4136
4369
 
4137
- // lib/items/models/ItemTable.ts
4370
+ // lib/items/v1/models/ItemTable.ts
4138
4371
  var itemTableSchema = z.object({
4139
4372
  headers: itemHeaderSchema,
4140
4373
  itemMaps: z.array(itemMapSchema)
4141
4374
  });
4142
4375
 
4143
- // lib/items/models/ItemSearchView.ts
4376
+ // lib/items/v1/models/ItemSearchView.ts
4144
4377
  var itemSearchViewSchema = z.object({
4145
4378
  itemTable: itemTableSchema,
4146
4379
  hasNext: z.boolean(),
4147
4380
  count: z.number()
4148
4381
  });
4149
4382
 
4150
- // lib/items/models/AttributeDetail.ts
4383
+ // lib/items/v1/models/AttributeDetail.ts
4151
4384
  var attributeDetailSchema = z.object({
4152
4385
  type: attrDatatypeNameEnumSchema,
4153
4386
  name: z.string(),
@@ -4157,23 +4390,23 @@ var attributeDetailSchema = z.object({
4157
4390
  orderBy: z.number().or(z.string()).nullish()
4158
4391
  });
4159
4392
 
4160
- // lib/items/models/CategoryEnum.ts
4393
+ // lib/items/v1/models/CategoryEnum.ts
4161
4394
  var categoryEnumSchema = z.enum([
4162
- "AKA",
4395
+ "ALIAS",
4163
4396
  "CATALOG",
4164
4397
  "EXPORT",
4165
- "LABEL",
4166
4398
  "LEGACY_PRODUCT_TYPE",
4167
4399
  "PRODUCT_CLASSIFICATION",
4168
4400
  "PRODUCT_CODE",
4169
4401
  "SELECTION_CODE",
4402
+ "TAG",
4170
4403
  "TAXONOMY_ROOT"
4171
4404
  ]);
4172
4405
 
4173
- // lib/items/models/ComponentDetails.ts
4406
+ // lib/items/v1/models/ComponentDetails.ts
4174
4407
  var componentDetailsSchema = z.object({
4175
4408
  itemInfoId: z.number(),
4176
- description: z.string(),
4409
+ description: z.string().nullish(),
4177
4410
  saleable: z.boolean(),
4178
4411
  valid: z.boolean(),
4179
4412
  uniqueCriteria: z.array(
@@ -4184,43 +4417,43 @@ var componentDetailsSchema = z.object({
4184
4417
  )
4185
4418
  });
4186
4419
 
4187
- // lib/items/models/RepeatableGroup.ts
4420
+ // lib/items/v1/models/RepeatableGroup.ts
4188
4421
  var repeatableGroupSchema = z.object({
4189
4422
  repeatableGroupId: z.string(),
4190
4423
  repeatableNumber: z.number()
4191
4424
  });
4192
4425
 
4193
- // lib/items/models/GroupedAttributeList.ts
4426
+ // lib/items/v1/models/GroupedAttributeList.ts
4194
4427
  var groupedAttributeListSchema = z.object({
4195
4428
  type: z.string(),
4196
4429
  rows: z.array(z.array(attributeDetailSchema)),
4197
4430
  repeatableGroups: z.array(repeatableGroupSchema)
4198
4431
  });
4199
4432
 
4200
- // lib/items/models/GroupedAttributes.ts
4433
+ // lib/items/v1/models/GroupedAttributes.ts
4201
4434
  var groupedAttributesSchema = z.object({
4202
4435
  type: z.string(),
4203
4436
  attributes: z.array(attributeDetailSchema),
4204
4437
  attributeGroups: z.array(groupedAttributeListSchema)
4205
4438
  });
4206
4439
 
4207
- // lib/items/models/HierarchyCategory.ts
4440
+ // lib/items/v1/models/HierarchyCategory.ts
4208
4441
  var hierarchyCategorySchema = z.object({
4209
4442
  name: z.string(),
4210
4443
  description: z.string().nullish(),
4211
4444
  id: z.number(),
4212
- companyId: z.number(),
4445
+ companyId: z.number().nullish(),
4213
4446
  type: categoryEnumSchema
4214
4447
  });
4215
4448
 
4216
- // lib/items/models/HierarchyDetails.ts
4449
+ // lib/items/v1/models/HierarchyDetails.ts
4217
4450
  var hierarchyDetailsSchema = z.object({
4218
4451
  catalogs: z.array(hierarchyCategorySchema),
4219
4452
  selectionCodes: z.array(hierarchyCategorySchema),
4220
4453
  productCodes: z.array(hierarchyCategorySchema)
4221
4454
  });
4222
4455
 
4223
- // lib/items/models/PackComponentItemInfo.ts
4456
+ // lib/items/v1/models/PackComponentItemInfo.ts
4224
4457
  var packComponentItemInfoSchema = z.object({
4225
4458
  companyid: z.number(),
4226
4459
  createddate: z.number(),
@@ -4234,7 +4467,7 @@ var packComponentItemInfoSchema = z.object({
4234
4467
  attributes: z.record(z.string(), z.string().or(z.array(z.string())))
4235
4468
  });
4236
4469
 
4237
- // lib/items/models/ItemPrice.ts
4470
+ // lib/items/v1/models/ItemPrice.ts
4238
4471
  var itemPriceSchema = z.object({
4239
4472
  amount: z.number(),
4240
4473
  currency: z.string(),
@@ -4258,13 +4491,13 @@ var itemPriceSchema = z.object({
4258
4491
  priceUnitQuantityUOM: z.string().nullish()
4259
4492
  });
4260
4493
 
4261
- // lib/items/models/PackComponentDetails.ts
4494
+ // lib/items/v1/models/PackComponentDetails.ts
4262
4495
  var packComponentDetailsSchema = z.object({
4263
4496
  itemInfo: packComponentItemInfoSchema,
4264
4497
  itemPrices: z.array(itemPriceSchema)
4265
4498
  });
4266
4499
 
4267
- // lib/items/models/GroupedItem.ts
4500
+ // lib/items/v1/models/GroupedItem.ts
4268
4501
  var groupedItemSchema = z.object({
4269
4502
  iteminfoid: z.number(),
4270
4503
  companyid: z.number(),
@@ -4280,12 +4513,12 @@ var groupedItemSchema = z.object({
4280
4513
  locales: z.array(z.string())
4281
4514
  });
4282
4515
 
4283
- // lib/items/models/ItemDetailView.ts
4516
+ // lib/items/v1/models/ItemDetailView.ts
4284
4517
  var itemDetailViewSchema = z.object({
4285
4518
  item: groupedItemSchema
4286
4519
  });
4287
4520
 
4288
- // lib/items/models/Bulb.ts
4521
+ // lib/items/v1/models/Bulb.ts
4289
4522
  var bulbSchema = z.object({
4290
4523
  iteminfoid: z.number(),
4291
4524
  id: z.number(),
@@ -4303,14 +4536,14 @@ var bulbSchema = z.object({
4303
4536
  threewaybulb: z.string()
4304
4537
  });
4305
4538
 
4306
- // lib/items/models/PackComponent.ts
4539
+ // lib/items/v1/models/PackComponent.ts
4307
4540
  var packComponentSchema = z.object({
4308
4541
  itemInfoId: z.number().nullish(),
4309
4542
  attributes: z.record(z.string(), z.string().or(z.array(z.string()))),
4310
4543
  prices: z.array(itemPriceSchema)
4311
4544
  });
4312
4545
 
4313
- // lib/items/models/MediaItem.ts
4546
+ // lib/items/v1/models/MediaItem.ts
4314
4547
  var mediaItemSchema = z.object({
4315
4548
  id: z.number(),
4316
4549
  iteminfoid: z.number(),
@@ -4331,7 +4564,7 @@ var mediaItemSchema = z.object({
4331
4564
  thumbnailflag: z.string().nullish()
4332
4565
  });
4333
4566
 
4334
- // lib/items/models/ItemDetail.ts
4567
+ // lib/items/v1/models/ItemDetail.ts
4335
4568
  var itemDetailSchema = z.object({
4336
4569
  attributes: z.record(z.string(), z.any()),
4337
4570
  clusters: z.record(
@@ -4351,13 +4584,13 @@ var itemDetailSchema = z.object({
4351
4584
  packs: z.array(packComponentSchema)
4352
4585
  });
4353
4586
 
4354
- // lib/items/models/SpsItemIdResponse.ts
4587
+ // lib/items/v1/models/SpsItemIdResponse.ts
4355
4588
  var spsItemIdResponseSchema = z.object({
4356
4589
  id: z.string(),
4357
4590
  ref: z.string()
4358
4591
  });
4359
4592
 
4360
- // lib/items/models/ItemOrgStatus.ts
4593
+ // lib/items/v1/models/ItemOrgStatus.ts
4361
4594
  var itemOrgStatusSchema = z.object({
4362
4595
  org: z.object({
4363
4596
  ref: z.string(),
@@ -4368,13 +4601,13 @@ var itemOrgStatusSchema = z.object({
4368
4601
  validForRelationship: z.boolean()
4369
4602
  });
4370
4603
 
4371
- // lib/items/models/ItemStatus.ts
4604
+ // lib/items/v1/models/ItemStatus.ts
4372
4605
  var itemStatusSchema = z.object({
4373
4606
  itemId: z.string(),
4374
4607
  itemOrgStatuses: z.array(itemOrgStatusSchema)
4375
4608
  });
4376
4609
 
4377
- // lib/items/models/ItemStatusResponse.ts
4610
+ // lib/items/v1/models/ItemStatusResponse.ts
4378
4611
  var itemStatusResponseSchema = z.object({
4379
4612
  itemStatuses: z.array(itemStatusSchema)
4380
4613
  });
@@ -4442,7 +4675,7 @@ var companyRelationshipUpsertBodySchema = z.object({
4442
4675
  supplierId: z.number(),
4443
4676
  retailerId: z.number(),
4444
4677
  catalogId: z.number(),
4445
- isActive: z.boolean(),
4678
+ active: z.boolean(),
4446
4679
  applicationType: z.array(z.enum(["ASSORTMENT", "ITEM-XREF"])).default([])
4447
4680
  });
4448
4681
 
@@ -4617,8 +4850,6 @@ export {
4617
4850
  tradingPartnerAccessByCompanyIdSchema,
4618
4851
  itemCategorySchema,
4619
4852
  itemCategoriesSearchSchema,
4620
- hierarchySchema,
4621
- itemHierarchySchema,
4622
4853
  itemHierarchyResponseSchema,
4623
4854
  attributeMetaDataSchema,
4624
4855
  attributeSummarySchema,