@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.
package/dist/zod.cjs CHANGED
@@ -57,7 +57,6 @@ __export(zod_exports, {
57
57
  groupedItemSchema: () => groupedItemSchema,
58
58
  hierarchyCategorySchema: () => hierarchyCategorySchema,
59
59
  hierarchyDetailsSchema: () => hierarchyDetailsSchema,
60
- hierarchySchema: () => hierarchySchema,
61
60
  identityServiceDatetimePreferencesSchema: () => identityServiceDatetimePreferencesSchema,
62
61
  identityServiceOrganizationMetadataSchema: () => identityServiceOrganizationMetadataSchema,
63
62
  identityServiceOrganizationSchema: () => identityServiceOrganizationSchema,
@@ -77,7 +76,6 @@ __export(zod_exports, {
77
76
  itemErrorDetailsSchema: () => itemErrorDetailsSchema,
78
77
  itemHeaderSchema: () => itemHeaderSchema,
79
78
  itemHierarchyResponseSchema: () => itemHierarchyResponseSchema,
80
- itemHierarchySchema: () => itemHierarchySchema,
81
79
  itemMapSchema: () => itemMapSchema,
82
80
  itemPartnerSchema: () => itemPartnerSchema,
83
81
  itemPriceSchema: () => itemPriceSchema,
@@ -104,7 +102,7 @@ module.exports = __toCommonJS(zod_exports);
104
102
  // lib/asstClient.ts
105
103
  var import_ky_universal = __toESM(require("ky-universal"), 1);
106
104
 
107
- // ../../node_modules/.pnpm/zod@3.21.4/node_modules/zod/lib/index.mjs
105
+ // ../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
108
106
  var util;
109
107
  (function(util2) {
110
108
  util2.assertEqual = (val) => val;
@@ -258,7 +256,7 @@ var quotelessJson = (obj) => {
258
256
  const json = JSON.stringify(obj, null, 2);
259
257
  return json.replace(/"([^"]+)":/g, "$1:");
260
258
  };
261
- var ZodError = class extends Error {
259
+ var ZodError = class _ZodError extends Error {
262
260
  constructor(issues) {
263
261
  super();
264
262
  this.issues = [];
@@ -316,6 +314,11 @@ var ZodError = class extends Error {
316
314
  processError(this);
317
315
  return fieldErrors;
318
316
  }
317
+ static assert(value) {
318
+ if (!(value instanceof _ZodError)) {
319
+ throw new Error(`Not a ZodError: ${value}`);
320
+ }
321
+ }
319
322
  toString() {
320
323
  return this.message;
321
324
  }
@@ -458,6 +461,13 @@ var makeIssue = (params) => {
458
461
  ...issueData,
459
462
  path: fullPath
460
463
  };
464
+ if (issueData.message !== void 0) {
465
+ return {
466
+ ...issueData,
467
+ path: fullPath,
468
+ message: issueData.message
469
+ };
470
+ }
461
471
  let errorMessage = "";
462
472
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
463
473
  for (const map of maps) {
@@ -466,11 +476,12 @@ var makeIssue = (params) => {
466
476
  return {
467
477
  ...issueData,
468
478
  path: fullPath,
469
- message: issueData.message || errorMessage
479
+ message: errorMessage
470
480
  };
471
481
  };
472
482
  var EMPTY_PATH = [];
473
483
  function addIssueToContext(ctx, issueData) {
484
+ const overrideMap = getErrorMap();
474
485
  const issue = makeIssue({
475
486
  issueData,
476
487
  data: ctx.data,
@@ -478,14 +489,14 @@ function addIssueToContext(ctx, issueData) {
478
489
  errorMaps: [
479
490
  ctx.common.contextualErrorMap,
480
491
  ctx.schemaErrorMap,
481
- getErrorMap(),
482
- errorMap
492
+ overrideMap,
493
+ overrideMap === errorMap ? void 0 : errorMap
483
494
  // then global default map
484
495
  ].filter((x) => !!x)
485
496
  });
486
497
  ctx.common.issues.push(issue);
487
498
  }
488
- var ParseStatus = class {
499
+ var ParseStatus = class _ParseStatus {
489
500
  constructor() {
490
501
  this.value = "valid";
491
502
  }
@@ -511,12 +522,14 @@ var ParseStatus = class {
511
522
  static async mergeObjectAsync(status, pairs) {
512
523
  const syncPairs = [];
513
524
  for (const pair of pairs) {
525
+ const key = await pair.key;
526
+ const value = await pair.value;
514
527
  syncPairs.push({
515
- key: await pair.key,
516
- value: await pair.value
528
+ key,
529
+ value
517
530
  });
518
531
  }
519
- return ParseStatus.mergeObjectSync(status, syncPairs);
532
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
520
533
  }
521
534
  static mergeObjectSync(status, pairs) {
522
535
  const finalObject = {};
@@ -530,7 +543,7 @@ var ParseStatus = class {
530
543
  status.dirty();
531
544
  if (value.status === "dirty")
532
545
  status.dirty();
533
- if (typeof value.value !== "undefined" || pair.alwaysSet) {
546
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
534
547
  finalObject[key.value] = value.value;
535
548
  }
536
549
  }
@@ -546,11 +559,29 @@ var isAborted = (x) => x.status === "aborted";
546
559
  var isDirty = (x) => x.status === "dirty";
547
560
  var isValid = (x) => x.status === "valid";
548
561
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
562
+ function __classPrivateFieldGet(receiver, state, kind, f) {
563
+ if (kind === "a" && !f)
564
+ throw new TypeError("Private accessor was defined without a getter");
565
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
566
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
567
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
568
+ }
569
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
570
+ if (kind === "m")
571
+ throw new TypeError("Private method is not writable");
572
+ if (kind === "a" && !f)
573
+ throw new TypeError("Private accessor was defined without a setter");
574
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
575
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
576
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
577
+ }
549
578
  var errorUtil;
550
579
  (function(errorUtil2) {
551
580
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
552
581
  errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
553
582
  })(errorUtil || (errorUtil = {}));
583
+ var _ZodEnum_cache;
584
+ var _ZodNativeEnum_cache;
554
585
  var ParseInputLazyPath = class {
555
586
  constructor(parent, value, path, key) {
556
587
  this._cachedPath = [];
@@ -599,12 +630,17 @@ function processCreateParams(params) {
599
630
  if (errorMap2)
600
631
  return { errorMap: errorMap2, description };
601
632
  const customMap = (iss, ctx) => {
602
- if (iss.code !== "invalid_type")
603
- return { message: ctx.defaultError };
633
+ var _a, _b;
634
+ const { message } = params;
635
+ if (iss.code === "invalid_enum_value") {
636
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
637
+ }
604
638
  if (typeof ctx.data === "undefined") {
605
- return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
639
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
606
640
  }
607
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
641
+ if (iss.code !== "invalid_type")
642
+ return { message: ctx.defaultError };
643
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
608
644
  };
609
645
  return { errorMap: customMap, description };
610
646
  }
@@ -633,6 +669,7 @@ var ZodType = class {
633
669
  this.catch = this.catch.bind(this);
634
670
  this.describe = this.describe.bind(this);
635
671
  this.pipe = this.pipe.bind(this);
672
+ this.readonly = this.readonly.bind(this);
636
673
  this.isNullable = this.isNullable.bind(this);
637
674
  this.isOptional = this.isOptional.bind(this);
638
675
  }
@@ -840,6 +877,9 @@ var ZodType = class {
840
877
  pipe(target) {
841
878
  return ZodPipeline.create(this, target);
842
879
  }
880
+ readonly() {
881
+ return ZodReadonly.create(this);
882
+ }
843
883
  isOptional() {
844
884
  return this.safeParse(void 0).success;
845
885
  }
@@ -848,34 +888,40 @@ var ZodType = class {
848
888
  }
849
889
  };
850
890
  var cuidRegex = /^c[^\s-]{8,}$/i;
851
- var cuid2Regex = /^[a-z][a-z0-9]*$/;
852
- var ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/;
853
- 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;
854
- 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,})+))$/;
855
- var emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u;
856
- 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}))$/;
891
+ var cuid2Regex = /^[0-9a-z]+$/;
892
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
893
+ 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;
894
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
895
+ 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)?)??$/;
896
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
897
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
898
+ var emojiRegex;
899
+ 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])$/;
857
900
  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})))$/;
858
- var datetimeRegex = (args) => {
901
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
902
+ 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])))`;
903
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
904
+ function timeRegexSource(args) {
905
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
859
906
  if (args.precision) {
860
- if (args.offset) {
861
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
862
- } else {
863
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
864
- }
865
- } else if (args.precision === 0) {
866
- if (args.offset) {
867
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
868
- } else {
869
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
870
- }
871
- } else {
872
- if (args.offset) {
873
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
874
- } else {
875
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
876
- }
907
+ regex = `${regex}\\.\\d{${args.precision}}`;
908
+ } else if (args.precision == null) {
909
+ regex = `${regex}(\\.\\d+)?`;
877
910
  }
878
- };
911
+ return regex;
912
+ }
913
+ function timeRegex(args) {
914
+ return new RegExp(`^${timeRegexSource(args)}$`);
915
+ }
916
+ function datetimeRegex(args) {
917
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
918
+ const opts = [];
919
+ opts.push(args.local ? `Z?` : `Z`);
920
+ if (args.offset)
921
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
922
+ regex = `${regex}(${opts.join("|")})`;
923
+ return new RegExp(`^${regex}$`);
924
+ }
879
925
  function isValidIP(ip, version) {
880
926
  if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
881
927
  return true;
@@ -885,28 +931,7 @@ function isValidIP(ip, version) {
885
931
  }
886
932
  return false;
887
933
  }
888
- var ZodString = class extends ZodType {
889
- constructor() {
890
- super(...arguments);
891
- this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
892
- validation,
893
- code: ZodIssueCode.invalid_string,
894
- ...errorUtil.errToObj(message)
895
- });
896
- this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
897
- this.trim = () => new ZodString({
898
- ...this._def,
899
- checks: [...this._def.checks, { kind: "trim" }]
900
- });
901
- this.toLowerCase = () => new ZodString({
902
- ...this._def,
903
- checks: [...this._def.checks, { kind: "toLowerCase" }]
904
- });
905
- this.toUpperCase = () => new ZodString({
906
- ...this._def,
907
- checks: [...this._def.checks, { kind: "toUpperCase" }]
908
- });
909
- }
934
+ var ZodString = class _ZodString extends ZodType {
910
935
  _parse(input) {
911
936
  if (this._def.coerce) {
912
937
  input.data = String(input.data);
@@ -914,15 +939,11 @@ var ZodString = class extends ZodType {
914
939
  const parsedType = this._getType(input);
915
940
  if (parsedType !== ZodParsedType.string) {
916
941
  const ctx2 = this._getOrReturnCtx(input);
917
- addIssueToContext(
918
- ctx2,
919
- {
920
- code: ZodIssueCode.invalid_type,
921
- expected: ZodParsedType.string,
922
- received: ctx2.parsedType
923
- }
924
- //
925
- );
942
+ addIssueToContext(ctx2, {
943
+ code: ZodIssueCode.invalid_type,
944
+ expected: ZodParsedType.string,
945
+ received: ctx2.parsedType
946
+ });
926
947
  return INVALID;
927
948
  }
928
949
  const status = new ParseStatus();
@@ -991,6 +1012,9 @@ var ZodString = class extends ZodType {
991
1012
  status.dirty();
992
1013
  }
993
1014
  } else if (check.kind === "emoji") {
1015
+ if (!emojiRegex) {
1016
+ emojiRegex = new RegExp(_emojiRegex, "u");
1017
+ }
994
1018
  if (!emojiRegex.test(input.data)) {
995
1019
  ctx = this._getOrReturnCtx(input, ctx);
996
1020
  addIssueToContext(ctx, {
@@ -1010,6 +1034,16 @@ var ZodString = class extends ZodType {
1010
1034
  });
1011
1035
  status.dirty();
1012
1036
  }
1037
+ } else if (check.kind === "nanoid") {
1038
+ if (!nanoidRegex.test(input.data)) {
1039
+ ctx = this._getOrReturnCtx(input, ctx);
1040
+ addIssueToContext(ctx, {
1041
+ validation: "nanoid",
1042
+ code: ZodIssueCode.invalid_string,
1043
+ message: check.message
1044
+ });
1045
+ status.dirty();
1046
+ }
1013
1047
  } else if (check.kind === "cuid") {
1014
1048
  if (!cuidRegex.test(input.data)) {
1015
1049
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1111,6 +1145,38 @@ var ZodString = class extends ZodType {
1111
1145
  });
1112
1146
  status.dirty();
1113
1147
  }
1148
+ } else if (check.kind === "date") {
1149
+ const regex = dateRegex;
1150
+ if (!regex.test(input.data)) {
1151
+ ctx = this._getOrReturnCtx(input, ctx);
1152
+ addIssueToContext(ctx, {
1153
+ code: ZodIssueCode.invalid_string,
1154
+ validation: "date",
1155
+ message: check.message
1156
+ });
1157
+ status.dirty();
1158
+ }
1159
+ } else if (check.kind === "time") {
1160
+ const regex = timeRegex(check);
1161
+ if (!regex.test(input.data)) {
1162
+ ctx = this._getOrReturnCtx(input, ctx);
1163
+ addIssueToContext(ctx, {
1164
+ code: ZodIssueCode.invalid_string,
1165
+ validation: "time",
1166
+ message: check.message
1167
+ });
1168
+ status.dirty();
1169
+ }
1170
+ } else if (check.kind === "duration") {
1171
+ if (!durationRegex.test(input.data)) {
1172
+ ctx = this._getOrReturnCtx(input, ctx);
1173
+ addIssueToContext(ctx, {
1174
+ validation: "duration",
1175
+ code: ZodIssueCode.invalid_string,
1176
+ message: check.message
1177
+ });
1178
+ status.dirty();
1179
+ }
1114
1180
  } else if (check.kind === "ip") {
1115
1181
  if (!isValidIP(input.data, check.version)) {
1116
1182
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1121,14 +1187,31 @@ var ZodString = class extends ZodType {
1121
1187
  });
1122
1188
  status.dirty();
1123
1189
  }
1190
+ } else if (check.kind === "base64") {
1191
+ if (!base64Regex.test(input.data)) {
1192
+ ctx = this._getOrReturnCtx(input, ctx);
1193
+ addIssueToContext(ctx, {
1194
+ validation: "base64",
1195
+ code: ZodIssueCode.invalid_string,
1196
+ message: check.message
1197
+ });
1198
+ status.dirty();
1199
+ }
1124
1200
  } else {
1125
1201
  util.assertNever(check);
1126
1202
  }
1127
1203
  }
1128
1204
  return { status: status.value, value: input.data };
1129
1205
  }
1206
+ _regex(regex, validation, message) {
1207
+ return this.refinement((data) => regex.test(data), {
1208
+ validation,
1209
+ code: ZodIssueCode.invalid_string,
1210
+ ...errorUtil.errToObj(message)
1211
+ });
1212
+ }
1130
1213
  _addCheck(check) {
1131
- return new ZodString({
1214
+ return new _ZodString({
1132
1215
  ...this._def,
1133
1216
  checks: [...this._def.checks, check]
1134
1217
  });
@@ -1145,6 +1228,9 @@ var ZodString = class extends ZodType {
1145
1228
  uuid(message) {
1146
1229
  return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1147
1230
  }
1231
+ nanoid(message) {
1232
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1233
+ }
1148
1234
  cuid(message) {
1149
1235
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1150
1236
  }
@@ -1154,16 +1240,20 @@ var ZodString = class extends ZodType {
1154
1240
  ulid(message) {
1155
1241
  return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1156
1242
  }
1243
+ base64(message) {
1244
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1245
+ }
1157
1246
  ip(options) {
1158
1247
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1159
1248
  }
1160
1249
  datetime(options) {
1161
- var _a;
1250
+ var _a, _b;
1162
1251
  if (typeof options === "string") {
1163
1252
  return this._addCheck({
1164
1253
  kind: "datetime",
1165
1254
  precision: null,
1166
1255
  offset: false,
1256
+ local: false,
1167
1257
  message: options
1168
1258
  });
1169
1259
  }
@@ -1171,9 +1261,30 @@ var ZodString = class extends ZodType {
1171
1261
  kind: "datetime",
1172
1262
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1173
1263
  offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1264
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
1174
1265
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1175
1266
  });
1176
1267
  }
1268
+ date(message) {
1269
+ return this._addCheck({ kind: "date", message });
1270
+ }
1271
+ time(options) {
1272
+ if (typeof options === "string") {
1273
+ return this._addCheck({
1274
+ kind: "time",
1275
+ precision: null,
1276
+ message: options
1277
+ });
1278
+ }
1279
+ return this._addCheck({
1280
+ kind: "time",
1281
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1282
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1283
+ });
1284
+ }
1285
+ duration(message) {
1286
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1287
+ }
1177
1288
  regex(regex, message) {
1178
1289
  return this._addCheck({
1179
1290
  kind: "regex",
@@ -1224,9 +1335,43 @@ var ZodString = class extends ZodType {
1224
1335
  ...errorUtil.errToObj(message)
1225
1336
  });
1226
1337
  }
1338
+ /**
1339
+ * @deprecated Use z.string().min(1) instead.
1340
+ * @see {@link ZodString.min}
1341
+ */
1342
+ nonempty(message) {
1343
+ return this.min(1, errorUtil.errToObj(message));
1344
+ }
1345
+ trim() {
1346
+ return new _ZodString({
1347
+ ...this._def,
1348
+ checks: [...this._def.checks, { kind: "trim" }]
1349
+ });
1350
+ }
1351
+ toLowerCase() {
1352
+ return new _ZodString({
1353
+ ...this._def,
1354
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1355
+ });
1356
+ }
1357
+ toUpperCase() {
1358
+ return new _ZodString({
1359
+ ...this._def,
1360
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1361
+ });
1362
+ }
1227
1363
  get isDatetime() {
1228
1364
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
1229
1365
  }
1366
+ get isDate() {
1367
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1368
+ }
1369
+ get isTime() {
1370
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1371
+ }
1372
+ get isDuration() {
1373
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1374
+ }
1230
1375
  get isEmail() {
1231
1376
  return !!this._def.checks.find((ch) => ch.kind === "email");
1232
1377
  }
@@ -1239,6 +1384,9 @@ var ZodString = class extends ZodType {
1239
1384
  get isUUID() {
1240
1385
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
1241
1386
  }
1387
+ get isNANOID() {
1388
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1389
+ }
1242
1390
  get isCUID() {
1243
1391
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
1244
1392
  }
@@ -1251,6 +1399,9 @@ var ZodString = class extends ZodType {
1251
1399
  get isIP() {
1252
1400
  return !!this._def.checks.find((ch) => ch.kind === "ip");
1253
1401
  }
1402
+ get isBase64() {
1403
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1404
+ }
1254
1405
  get minLength() {
1255
1406
  let min = null;
1256
1407
  for (const ch of this._def.checks) {
@@ -1289,7 +1440,7 @@ function floatSafeRemainder(val, step) {
1289
1440
  const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
1290
1441
  return valInt % stepInt / Math.pow(10, decCount);
1291
1442
  }
1292
- var ZodNumber = class extends ZodType {
1443
+ var ZodNumber = class _ZodNumber extends ZodType {
1293
1444
  constructor() {
1294
1445
  super(...arguments);
1295
1446
  this.min = this.gte;
@@ -1390,7 +1541,7 @@ var ZodNumber = class extends ZodType {
1390
1541
  return this.setLimit("max", value, false, errorUtil.toString(message));
1391
1542
  }
1392
1543
  setLimit(kind, value, inclusive, message) {
1393
- return new ZodNumber({
1544
+ return new _ZodNumber({
1394
1545
  ...this._def,
1395
1546
  checks: [
1396
1547
  ...this._def.checks,
@@ -1404,7 +1555,7 @@ var ZodNumber = class extends ZodType {
1404
1555
  });
1405
1556
  }
1406
1557
  _addCheck(check) {
1407
- return new ZodNumber({
1558
+ return new _ZodNumber({
1408
1559
  ...this._def,
1409
1560
  checks: [...this._def.checks, check]
1410
1561
  });
@@ -1520,7 +1671,7 @@ ZodNumber.create = (params) => {
1520
1671
  ...processCreateParams(params)
1521
1672
  });
1522
1673
  };
1523
- var ZodBigInt = class extends ZodType {
1674
+ var ZodBigInt = class _ZodBigInt extends ZodType {
1524
1675
  constructor() {
1525
1676
  super(...arguments);
1526
1677
  this.min = this.gte;
@@ -1598,7 +1749,7 @@ var ZodBigInt = class extends ZodType {
1598
1749
  return this.setLimit("max", value, false, errorUtil.toString(message));
1599
1750
  }
1600
1751
  setLimit(kind, value, inclusive, message) {
1601
- return new ZodBigInt({
1752
+ return new _ZodBigInt({
1602
1753
  ...this._def,
1603
1754
  checks: [
1604
1755
  ...this._def.checks,
@@ -1612,7 +1763,7 @@ var ZodBigInt = class extends ZodType {
1612
1763
  });
1613
1764
  }
1614
1765
  _addCheck(check) {
1615
- return new ZodBigInt({
1766
+ return new _ZodBigInt({
1616
1767
  ...this._def,
1617
1768
  checks: [...this._def.checks, check]
1618
1769
  });
@@ -1711,7 +1862,7 @@ ZodBoolean.create = (params) => {
1711
1862
  ...processCreateParams(params)
1712
1863
  });
1713
1864
  };
1714
- var ZodDate = class extends ZodType {
1865
+ var ZodDate = class _ZodDate extends ZodType {
1715
1866
  _parse(input) {
1716
1867
  if (this._def.coerce) {
1717
1868
  input.data = new Date(input.data);
@@ -1772,7 +1923,7 @@ var ZodDate = class extends ZodType {
1772
1923
  };
1773
1924
  }
1774
1925
  _addCheck(check) {
1775
- return new ZodDate({
1926
+ return new _ZodDate({
1776
1927
  ...this._def,
1777
1928
  checks: [...this._def.checks, check]
1778
1929
  });
@@ -1951,7 +2102,7 @@ ZodVoid.create = (params) => {
1951
2102
  ...processCreateParams(params)
1952
2103
  });
1953
2104
  };
1954
- var ZodArray = class extends ZodType {
2105
+ var ZodArray = class _ZodArray extends ZodType {
1955
2106
  _parse(input) {
1956
2107
  const { ctx, status } = this._processInputParams(input);
1957
2108
  const def = this._def;
@@ -2021,19 +2172,19 @@ var ZodArray = class extends ZodType {
2021
2172
  return this._def.type;
2022
2173
  }
2023
2174
  min(minLength, message) {
2024
- return new ZodArray({
2175
+ return new _ZodArray({
2025
2176
  ...this._def,
2026
2177
  minLength: { value: minLength, message: errorUtil.toString(message) }
2027
2178
  });
2028
2179
  }
2029
2180
  max(maxLength, message) {
2030
- return new ZodArray({
2181
+ return new _ZodArray({
2031
2182
  ...this._def,
2032
2183
  maxLength: { value: maxLength, message: errorUtil.toString(message) }
2033
2184
  });
2034
2185
  }
2035
2186
  length(len, message) {
2036
- return new ZodArray({
2187
+ return new _ZodArray({
2037
2188
  ...this._def,
2038
2189
  exactLength: { value: len, message: errorUtil.toString(message) }
2039
2190
  });
@@ -2078,7 +2229,7 @@ function deepPartialify(schema) {
2078
2229
  return schema;
2079
2230
  }
2080
2231
  }
2081
- var ZodObject = class extends ZodType {
2232
+ var ZodObject = class _ZodObject extends ZodType {
2082
2233
  constructor() {
2083
2234
  super(...arguments);
2084
2235
  this._cached = null;
@@ -2164,9 +2315,10 @@ var ZodObject = class extends ZodType {
2164
2315
  const syncPairs = [];
2165
2316
  for (const pair of pairs) {
2166
2317
  const key = await pair.key;
2318
+ const value = await pair.value;
2167
2319
  syncPairs.push({
2168
2320
  key,
2169
- value: await pair.value,
2321
+ value,
2170
2322
  alwaysSet: pair.alwaysSet
2171
2323
  });
2172
2324
  }
@@ -2183,7 +2335,7 @@ var ZodObject = class extends ZodType {
2183
2335
  }
2184
2336
  strict(message) {
2185
2337
  errorUtil.errToObj;
2186
- return new ZodObject({
2338
+ return new _ZodObject({
2187
2339
  ...this._def,
2188
2340
  unknownKeys: "strict",
2189
2341
  ...message !== void 0 ? {
@@ -2202,13 +2354,13 @@ var ZodObject = class extends ZodType {
2202
2354
  });
2203
2355
  }
2204
2356
  strip() {
2205
- return new ZodObject({
2357
+ return new _ZodObject({
2206
2358
  ...this._def,
2207
2359
  unknownKeys: "strip"
2208
2360
  });
2209
2361
  }
2210
2362
  passthrough() {
2211
- return new ZodObject({
2363
+ return new _ZodObject({
2212
2364
  ...this._def,
2213
2365
  unknownKeys: "passthrough"
2214
2366
  });
@@ -2231,7 +2383,7 @@ var ZodObject = class extends ZodType {
2231
2383
  // }) as any;
2232
2384
  // };
2233
2385
  extend(augmentation) {
2234
- return new ZodObject({
2386
+ return new _ZodObject({
2235
2387
  ...this._def,
2236
2388
  shape: () => ({
2237
2389
  ...this._def.shape(),
@@ -2245,7 +2397,7 @@ var ZodObject = class extends ZodType {
2245
2397
  * upgrade if you are experiencing issues.
2246
2398
  */
2247
2399
  merge(merging) {
2248
- const merged = new ZodObject({
2400
+ const merged = new _ZodObject({
2249
2401
  unknownKeys: merging._def.unknownKeys,
2250
2402
  catchall: merging._def.catchall,
2251
2403
  shape: () => ({
@@ -2316,7 +2468,7 @@ var ZodObject = class extends ZodType {
2316
2468
  // return merged;
2317
2469
  // }
2318
2470
  catchall(index) {
2319
- return new ZodObject({
2471
+ return new _ZodObject({
2320
2472
  ...this._def,
2321
2473
  catchall: index
2322
2474
  });
@@ -2328,7 +2480,7 @@ var ZodObject = class extends ZodType {
2328
2480
  shape[key] = this.shape[key];
2329
2481
  }
2330
2482
  });
2331
- return new ZodObject({
2483
+ return new _ZodObject({
2332
2484
  ...this._def,
2333
2485
  shape: () => shape
2334
2486
  });
@@ -2340,7 +2492,7 @@ var ZodObject = class extends ZodType {
2340
2492
  shape[key] = this.shape[key];
2341
2493
  }
2342
2494
  });
2343
- return new ZodObject({
2495
+ return new _ZodObject({
2344
2496
  ...this._def,
2345
2497
  shape: () => shape
2346
2498
  });
@@ -2361,7 +2513,7 @@ var ZodObject = class extends ZodType {
2361
2513
  newShape[key] = fieldSchema.optional();
2362
2514
  }
2363
2515
  });
2364
- return new ZodObject({
2516
+ return new _ZodObject({
2365
2517
  ...this._def,
2366
2518
  shape: () => newShape
2367
2519
  });
@@ -2380,7 +2532,7 @@ var ZodObject = class extends ZodType {
2380
2532
  newShape[key] = newField;
2381
2533
  }
2382
2534
  });
2383
- return new ZodObject({
2535
+ return new _ZodObject({
2384
2536
  ...this._def,
2385
2537
  shape: () => newShape
2386
2538
  });
@@ -2517,18 +2669,28 @@ var getDiscriminator = (type) => {
2517
2669
  } else if (type instanceof ZodEnum) {
2518
2670
  return type.options;
2519
2671
  } else if (type instanceof ZodNativeEnum) {
2520
- return Object.keys(type.enum);
2672
+ return util.objectValues(type.enum);
2521
2673
  } else if (type instanceof ZodDefault) {
2522
2674
  return getDiscriminator(type._def.innerType);
2523
2675
  } else if (type instanceof ZodUndefined) {
2524
2676
  return [void 0];
2525
2677
  } else if (type instanceof ZodNull) {
2526
2678
  return [null];
2679
+ } else if (type instanceof ZodOptional) {
2680
+ return [void 0, ...getDiscriminator(type.unwrap())];
2681
+ } else if (type instanceof ZodNullable) {
2682
+ return [null, ...getDiscriminator(type.unwrap())];
2683
+ } else if (type instanceof ZodBranded) {
2684
+ return getDiscriminator(type.unwrap());
2685
+ } else if (type instanceof ZodReadonly) {
2686
+ return getDiscriminator(type.unwrap());
2687
+ } else if (type instanceof ZodCatch) {
2688
+ return getDiscriminator(type._def.innerType);
2527
2689
  } else {
2528
- return null;
2690
+ return [];
2529
2691
  }
2530
2692
  };
2531
- var ZodDiscriminatedUnion = class extends ZodType {
2693
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2532
2694
  _parse(input) {
2533
2695
  const { ctx } = this._processInputParams(input);
2534
2696
  if (ctx.parsedType !== ZodParsedType.object) {
@@ -2585,7 +2747,7 @@ var ZodDiscriminatedUnion = class extends ZodType {
2585
2747
  const optionsMap = /* @__PURE__ */ new Map();
2586
2748
  for (const type of options) {
2587
2749
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2588
- if (!discriminatorValues) {
2750
+ if (!discriminatorValues.length) {
2589
2751
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2590
2752
  }
2591
2753
  for (const value of discriminatorValues) {
@@ -2595,7 +2757,7 @@ var ZodDiscriminatedUnion = class extends ZodType {
2595
2757
  optionsMap.set(value, type);
2596
2758
  }
2597
2759
  }
2598
- return new ZodDiscriminatedUnion({
2760
+ return new _ZodDiscriminatedUnion({
2599
2761
  typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2600
2762
  discriminator,
2601
2763
  options,
@@ -2695,7 +2857,7 @@ ZodIntersection.create = (left, right, params) => {
2695
2857
  ...processCreateParams(params)
2696
2858
  });
2697
2859
  };
2698
- var ZodTuple = class extends ZodType {
2860
+ var ZodTuple = class _ZodTuple extends ZodType {
2699
2861
  _parse(input) {
2700
2862
  const { status, ctx } = this._processInputParams(input);
2701
2863
  if (ctx.parsedType !== ZodParsedType.array) {
@@ -2745,7 +2907,7 @@ var ZodTuple = class extends ZodType {
2745
2907
  return this._def.items;
2746
2908
  }
2747
2909
  rest(rest) {
2748
- return new ZodTuple({
2910
+ return new _ZodTuple({
2749
2911
  ...this._def,
2750
2912
  rest
2751
2913
  });
@@ -2762,7 +2924,7 @@ ZodTuple.create = (schemas, params) => {
2762
2924
  ...processCreateParams(params)
2763
2925
  });
2764
2926
  };
2765
- var ZodRecord = class extends ZodType {
2927
+ var ZodRecord = class _ZodRecord extends ZodType {
2766
2928
  get keySchema() {
2767
2929
  return this._def.keyType;
2768
2930
  }
@@ -2785,7 +2947,8 @@ var ZodRecord = class extends ZodType {
2785
2947
  for (const key in ctx.data) {
2786
2948
  pairs.push({
2787
2949
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2788
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
2950
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
2951
+ alwaysSet: key in ctx.data
2789
2952
  });
2790
2953
  }
2791
2954
  if (ctx.common.async) {
@@ -2799,14 +2962,14 @@ var ZodRecord = class extends ZodType {
2799
2962
  }
2800
2963
  static create(first, second, third) {
2801
2964
  if (second instanceof ZodType) {
2802
- return new ZodRecord({
2965
+ return new _ZodRecord({
2803
2966
  keyType: first,
2804
2967
  valueType: second,
2805
2968
  typeName: ZodFirstPartyTypeKind.ZodRecord,
2806
2969
  ...processCreateParams(third)
2807
2970
  });
2808
2971
  }
2809
- return new ZodRecord({
2972
+ return new _ZodRecord({
2810
2973
  keyType: ZodString.create(),
2811
2974
  valueType: first,
2812
2975
  typeName: ZodFirstPartyTypeKind.ZodRecord,
@@ -2815,6 +2978,12 @@ var ZodRecord = class extends ZodType {
2815
2978
  }
2816
2979
  };
2817
2980
  var ZodMap = class extends ZodType {
2981
+ get keySchema() {
2982
+ return this._def.keyType;
2983
+ }
2984
+ get valueSchema() {
2985
+ return this._def.valueType;
2986
+ }
2818
2987
  _parse(input) {
2819
2988
  const { status, ctx } = this._processInputParams(input);
2820
2989
  if (ctx.parsedType !== ZodParsedType.map) {
@@ -2874,7 +3043,7 @@ ZodMap.create = (keyType, valueType, params) => {
2874
3043
  ...processCreateParams(params)
2875
3044
  });
2876
3045
  };
2877
- var ZodSet = class extends ZodType {
3046
+ var ZodSet = class _ZodSet extends ZodType {
2878
3047
  _parse(input) {
2879
3048
  const { status, ctx } = this._processInputParams(input);
2880
3049
  if (ctx.parsedType !== ZodParsedType.set) {
@@ -2932,13 +3101,13 @@ var ZodSet = class extends ZodType {
2932
3101
  }
2933
3102
  }
2934
3103
  min(minSize, message) {
2935
- return new ZodSet({
3104
+ return new _ZodSet({
2936
3105
  ...this._def,
2937
3106
  minSize: { value: minSize, message: errorUtil.toString(message) }
2938
3107
  });
2939
3108
  }
2940
3109
  max(maxSize, message) {
2941
- return new ZodSet({
3110
+ return new _ZodSet({
2942
3111
  ...this._def,
2943
3112
  maxSize: { value: maxSize, message: errorUtil.toString(message) }
2944
3113
  });
@@ -2959,7 +3128,7 @@ ZodSet.create = (valueType, params) => {
2959
3128
  ...processCreateParams(params)
2960
3129
  });
2961
3130
  };
2962
- var ZodFunction = class extends ZodType {
3131
+ var ZodFunction = class _ZodFunction extends ZodType {
2963
3132
  constructor() {
2964
3133
  super(...arguments);
2965
3134
  this.validate = this.implement;
@@ -3009,27 +3178,29 @@ var ZodFunction = class extends ZodType {
3009
3178
  const params = { errorMap: ctx.common.contextualErrorMap };
3010
3179
  const fn = ctx.data;
3011
3180
  if (this._def.returns instanceof ZodPromise) {
3012
- return OK(async (...args) => {
3181
+ const me = this;
3182
+ return OK(async function(...args) {
3013
3183
  const error = new ZodError([]);
3014
- const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => {
3184
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3015
3185
  error.addIssue(makeArgsIssue(args, e));
3016
3186
  throw error;
3017
3187
  });
3018
- const result = await fn(...parsedArgs);
3019
- const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => {
3188
+ const result = await Reflect.apply(fn, this, parsedArgs);
3189
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3020
3190
  error.addIssue(makeReturnsIssue(result, e));
3021
3191
  throw error;
3022
3192
  });
3023
3193
  return parsedReturns;
3024
3194
  });
3025
3195
  } else {
3026
- return OK((...args) => {
3027
- const parsedArgs = this._def.args.safeParse(args, params);
3196
+ const me = this;
3197
+ return OK(function(...args) {
3198
+ const parsedArgs = me._def.args.safeParse(args, params);
3028
3199
  if (!parsedArgs.success) {
3029
3200
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3030
3201
  }
3031
- const result = fn(...parsedArgs.data);
3032
- const parsedReturns = this._def.returns.safeParse(result, params);
3202
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3203
+ const parsedReturns = me._def.returns.safeParse(result, params);
3033
3204
  if (!parsedReturns.success) {
3034
3205
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3035
3206
  }
@@ -3044,13 +3215,13 @@ var ZodFunction = class extends ZodType {
3044
3215
  return this._def.returns;
3045
3216
  }
3046
3217
  args(...items) {
3047
- return new ZodFunction({
3218
+ return new _ZodFunction({
3048
3219
  ...this._def,
3049
3220
  args: ZodTuple.create(items).rest(ZodUnknown.create())
3050
3221
  });
3051
3222
  }
3052
3223
  returns(returnType) {
3053
- return new ZodFunction({
3224
+ return new _ZodFunction({
3054
3225
  ...this._def,
3055
3226
  returns: returnType
3056
3227
  });
@@ -3064,7 +3235,7 @@ var ZodFunction = class extends ZodType {
3064
3235
  return validatedFunc;
3065
3236
  }
3066
3237
  static create(args, returns, params) {
3067
- return new ZodFunction({
3238
+ return new _ZodFunction({
3068
3239
  args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3069
3240
  returns: returns || ZodUnknown.create(),
3070
3241
  typeName: ZodFirstPartyTypeKind.ZodFunction,
@@ -3120,7 +3291,11 @@ function createZodEnum(values, params) {
3120
3291
  ...processCreateParams(params)
3121
3292
  });
3122
3293
  }
3123
- var ZodEnum = class extends ZodType {
3294
+ var ZodEnum = class _ZodEnum extends ZodType {
3295
+ constructor() {
3296
+ super(...arguments);
3297
+ _ZodEnum_cache.set(this, void 0);
3298
+ }
3124
3299
  _parse(input) {
3125
3300
  if (typeof input.data !== "string") {
3126
3301
  const ctx = this._getOrReturnCtx(input);
@@ -3132,7 +3307,10 @@ var ZodEnum = class extends ZodType {
3132
3307
  });
3133
3308
  return INVALID;
3134
3309
  }
3135
- if (this._def.values.indexOf(input.data) === -1) {
3310
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
3311
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
3312
+ }
3313
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3136
3314
  const ctx = this._getOrReturnCtx(input);
3137
3315
  const expectedValues = this._def.values;
3138
3316
  addIssueToContext(ctx, {
@@ -3168,15 +3346,26 @@ var ZodEnum = class extends ZodType {
3168
3346
  }
3169
3347
  return enumValues;
3170
3348
  }
3171
- extract(values) {
3172
- return ZodEnum.create(values);
3349
+ extract(values, newDef = this._def) {
3350
+ return _ZodEnum.create(values, {
3351
+ ...this._def,
3352
+ ...newDef
3353
+ });
3173
3354
  }
3174
- exclude(values) {
3175
- return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
3355
+ exclude(values, newDef = this._def) {
3356
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3357
+ ...this._def,
3358
+ ...newDef
3359
+ });
3176
3360
  }
3177
3361
  };
3362
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3178
3363
  ZodEnum.create = createZodEnum;
3179
3364
  var ZodNativeEnum = class extends ZodType {
3365
+ constructor() {
3366
+ super(...arguments);
3367
+ _ZodNativeEnum_cache.set(this, void 0);
3368
+ }
3180
3369
  _parse(input) {
3181
3370
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3182
3371
  const ctx = this._getOrReturnCtx(input);
@@ -3189,7 +3378,10 @@ var ZodNativeEnum = class extends ZodType {
3189
3378
  });
3190
3379
  return INVALID;
3191
3380
  }
3192
- if (nativeEnumValues.indexOf(input.data) === -1) {
3381
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
3382
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
3383
+ }
3384
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3193
3385
  const expectedValues = util.objectValues(nativeEnumValues);
3194
3386
  addIssueToContext(ctx, {
3195
3387
  received: ctx.data,
@@ -3204,6 +3396,7 @@ var ZodNativeEnum = class extends ZodType {
3204
3396
  return this._def.values;
3205
3397
  }
3206
3398
  };
3399
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3207
3400
  ZodNativeEnum.create = (values, params) => {
3208
3401
  return new ZodNativeEnum({
3209
3402
  values,
@@ -3251,24 +3444,6 @@ var ZodEffects = class extends ZodType {
3251
3444
  _parse(input) {
3252
3445
  const { status, ctx } = this._processInputParams(input);
3253
3446
  const effect = this._def.effect || null;
3254
- if (effect.type === "preprocess") {
3255
- const processed = effect.transform(ctx.data);
3256
- if (ctx.common.async) {
3257
- return Promise.resolve(processed).then((processed2) => {
3258
- return this._def.schema._parseAsync({
3259
- data: processed2,
3260
- path: ctx.path,
3261
- parent: ctx
3262
- });
3263
- });
3264
- } else {
3265
- return this._def.schema._parseSync({
3266
- data: processed,
3267
- path: ctx.path,
3268
- parent: ctx
3269
- });
3270
- }
3271
- }
3272
3447
  const checkCtx = {
3273
3448
  addIssue: (arg) => {
3274
3449
  addIssueToContext(ctx, arg);
@@ -3283,6 +3458,42 @@ var ZodEffects = class extends ZodType {
3283
3458
  }
3284
3459
  };
3285
3460
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3461
+ if (effect.type === "preprocess") {
3462
+ const processed = effect.transform(ctx.data, checkCtx);
3463
+ if (ctx.common.async) {
3464
+ return Promise.resolve(processed).then(async (processed2) => {
3465
+ if (status.value === "aborted")
3466
+ return INVALID;
3467
+ const result = await this._def.schema._parseAsync({
3468
+ data: processed2,
3469
+ path: ctx.path,
3470
+ parent: ctx
3471
+ });
3472
+ if (result.status === "aborted")
3473
+ return INVALID;
3474
+ if (result.status === "dirty")
3475
+ return DIRTY(result.value);
3476
+ if (status.value === "dirty")
3477
+ return DIRTY(result.value);
3478
+ return result;
3479
+ });
3480
+ } else {
3481
+ if (status.value === "aborted")
3482
+ return INVALID;
3483
+ const result = this._def.schema._parseSync({
3484
+ data: processed,
3485
+ path: ctx.path,
3486
+ parent: ctx
3487
+ });
3488
+ if (result.status === "aborted")
3489
+ return INVALID;
3490
+ if (result.status === "dirty")
3491
+ return DIRTY(result.value);
3492
+ if (status.value === "dirty")
3493
+ return DIRTY(result.value);
3494
+ return result;
3495
+ }
3496
+ }
3286
3497
  if (effect.type === "refinement") {
3287
3498
  const executeRefinement = (acc) => {
3288
3499
  const result = effect.refinement(acc, checkCtx);
@@ -3511,7 +3722,7 @@ var ZodBranded = class extends ZodType {
3511
3722
  return this._def.type;
3512
3723
  }
3513
3724
  };
3514
- var ZodPipeline = class extends ZodType {
3725
+ var ZodPipeline = class _ZodPipeline extends ZodType {
3515
3726
  _parse(input) {
3516
3727
  const { status, ctx } = this._processInputParams(input);
3517
3728
  if (ctx.common.async) {
@@ -3559,14 +3770,36 @@ var ZodPipeline = class extends ZodType {
3559
3770
  }
3560
3771
  }
3561
3772
  static create(a, b) {
3562
- return new ZodPipeline({
3773
+ return new _ZodPipeline({
3563
3774
  in: a,
3564
3775
  out: b,
3565
3776
  typeName: ZodFirstPartyTypeKind.ZodPipeline
3566
3777
  });
3567
3778
  }
3568
3779
  };
3569
- var custom = (check, params = {}, fatal) => {
3780
+ var ZodReadonly = class extends ZodType {
3781
+ _parse(input) {
3782
+ const result = this._def.innerType._parse(input);
3783
+ const freeze = (data) => {
3784
+ if (isValid(data)) {
3785
+ data.value = Object.freeze(data.value);
3786
+ }
3787
+ return data;
3788
+ };
3789
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
3790
+ }
3791
+ unwrap() {
3792
+ return this._def.innerType;
3793
+ }
3794
+ };
3795
+ ZodReadonly.create = (type, params) => {
3796
+ return new ZodReadonly({
3797
+ innerType: type,
3798
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
3799
+ ...processCreateParams(params)
3800
+ });
3801
+ };
3802
+ function custom(check, params = {}, fatal) {
3570
3803
  if (check)
3571
3804
  return ZodAny.create().superRefine((data, ctx) => {
3572
3805
  var _a, _b;
@@ -3578,7 +3811,7 @@ var custom = (check, params = {}, fatal) => {
3578
3811
  }
3579
3812
  });
3580
3813
  return ZodAny.create();
3581
- };
3814
+ }
3582
3815
  var late = {
3583
3816
  object: ZodObject.lazycreate
3584
3817
  };
@@ -3619,6 +3852,7 @@ var ZodFirstPartyTypeKind;
3619
3852
  ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
3620
3853
  ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
3621
3854
  ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
3855
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
3622
3856
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
3623
3857
  var instanceOfType = (cls, params = {
3624
3858
  message: `Input not instance of ${cls.name}`
@@ -3696,6 +3930,7 @@ var z = /* @__PURE__ */ Object.freeze({
3696
3930
  ZodParsedType,
3697
3931
  getParsedType,
3698
3932
  ZodType,
3933
+ datetimeRegex,
3699
3934
  ZodString,
3700
3935
  ZodNumber,
3701
3936
  ZodBigInt,
@@ -3733,6 +3968,7 @@ var z = /* @__PURE__ */ Object.freeze({
3733
3968
  BRAND,
3734
3969
  ZodBranded,
3735
3970
  ZodPipeline,
3971
+ ZodReadonly,
3736
3972
  custom,
3737
3973
  Schema: ZodType,
3738
3974
  ZodSchema: ZodType,
@@ -3953,28 +4189,23 @@ var itemCategoriesSearchSchema = z.object({
3953
4189
  data: z.array(itemCategorySchema)
3954
4190
  });
3955
4191
 
3956
- // lib/categories/models/Hierarchy.ts
4192
+ // lib/categories/models/ItemHierarchyResponse.ts
3957
4193
  var baseHierarchySchema = z.object({
3958
4194
  id: z.string(),
3959
4195
  name: z.string().nullish(),
3960
4196
  description: z.string().nullish(),
3961
4197
  type: z.string().nullish()
3962
4198
  });
3963
- var hierarchySchema = baseHierarchySchema.extend(
3964
- {
3965
- child: z.lazy(() => hierarchySchema).nullable()
3966
- }
3967
- );
3968
-
3969
- // lib/categories/models/ItemHierarchy.ts
3970
- var itemHierarchySchema = z.object({
3971
- itemId: z.string(),
3972
- hierarchies: z.array(hierarchySchema)
4199
+ var hierarchySchema = baseHierarchySchema.extend({
4200
+ child: z.lazy(() => hierarchySchema).nullable()
3973
4201
  });
3974
-
3975
- // lib/categories/models/ItemHierarchyResponse.ts
3976
4202
  var itemHierarchyResponseSchema = z.object({
3977
- itemHierarchies: z.array(itemHierarchySchema)
4203
+ itemHierarchies: z.array(
4204
+ z.object({
4205
+ itemId: z.string(),
4206
+ hierarchies: z.array(hierarchySchema)
4207
+ })
4208
+ )
3978
4209
  });
3979
4210
 
3980
4211
  // lib/attributes/models/AttributeMetaData.ts
@@ -4131,7 +4362,7 @@ var attributeValidValuesSchema = z.object({
4131
4362
  attrKeyPair: z.string()
4132
4363
  });
4133
4364
 
4134
- // lib/items/models/ItemHeader.ts
4365
+ // lib/items/v1/models/ItemHeader.ts
4135
4366
  var itemHeaderSchema = z.object({
4136
4367
  status: z.string().optional(),
4137
4368
  catalogName: z.string(),
@@ -4147,7 +4378,7 @@ var itemHeaderSchema = z.object({
4147
4378
  itemInfoId: z.string()
4148
4379
  });
4149
4380
 
4150
- // lib/items/models/PhaseEnum.ts
4381
+ // lib/items/v1/models/PhaseEnum.ts
4151
4382
  var phaseEnumSchema = z.enum([
4152
4383
  "CORE",
4153
4384
  "CORE_PLUS",
@@ -4156,7 +4387,7 @@ var phaseEnumSchema = z.enum([
4156
4387
  "STANDARD_REQUIREMENTS"
4157
4388
  ]);
4158
4389
 
4159
- // lib/items/models/TradingPartnerStage.ts
4390
+ // lib/items/v1/models/TradingPartnerStage.ts
4160
4391
  var tradingPartnerStageSchema = z.object({
4161
4392
  companyId: z.number(),
4162
4393
  companyName: z.string(),
@@ -4164,7 +4395,7 @@ var tradingPartnerStageSchema = z.object({
4164
4395
  isValid: z.boolean()
4165
4396
  });
4166
4397
 
4167
- // lib/items/models/ItemMap.ts
4398
+ // lib/items/v1/models/ItemMap.ts
4168
4399
  var itemMapSchema = z.object({
4169
4400
  rn: z.number().optional(),
4170
4401
  iteminfoid: z.string(),
@@ -4187,20 +4418,20 @@ var itemMapSchema = z.object({
4187
4418
  productsizedescription: z.array(z.string()).nullish()
4188
4419
  }).passthrough();
4189
4420
 
4190
- // lib/items/models/ItemTable.ts
4421
+ // lib/items/v1/models/ItemTable.ts
4191
4422
  var itemTableSchema = z.object({
4192
4423
  headers: itemHeaderSchema,
4193
4424
  itemMaps: z.array(itemMapSchema)
4194
4425
  });
4195
4426
 
4196
- // lib/items/models/ItemSearchView.ts
4427
+ // lib/items/v1/models/ItemSearchView.ts
4197
4428
  var itemSearchViewSchema = z.object({
4198
4429
  itemTable: itemTableSchema,
4199
4430
  hasNext: z.boolean(),
4200
4431
  count: z.number()
4201
4432
  });
4202
4433
 
4203
- // lib/items/models/AttributeDetail.ts
4434
+ // lib/items/v1/models/AttributeDetail.ts
4204
4435
  var attributeDetailSchema = z.object({
4205
4436
  type: attrDatatypeNameEnumSchema,
4206
4437
  name: z.string(),
@@ -4210,23 +4441,23 @@ var attributeDetailSchema = z.object({
4210
4441
  orderBy: z.number().or(z.string()).nullish()
4211
4442
  });
4212
4443
 
4213
- // lib/items/models/CategoryEnum.ts
4444
+ // lib/items/v1/models/CategoryEnum.ts
4214
4445
  var categoryEnumSchema = z.enum([
4215
- "AKA",
4446
+ "ALIAS",
4216
4447
  "CATALOG",
4217
4448
  "EXPORT",
4218
- "LABEL",
4219
4449
  "LEGACY_PRODUCT_TYPE",
4220
4450
  "PRODUCT_CLASSIFICATION",
4221
4451
  "PRODUCT_CODE",
4222
4452
  "SELECTION_CODE",
4453
+ "TAG",
4223
4454
  "TAXONOMY_ROOT"
4224
4455
  ]);
4225
4456
 
4226
- // lib/items/models/ComponentDetails.ts
4457
+ // lib/items/v1/models/ComponentDetails.ts
4227
4458
  var componentDetailsSchema = z.object({
4228
4459
  itemInfoId: z.number(),
4229
- description: z.string(),
4460
+ description: z.string().nullish(),
4230
4461
  saleable: z.boolean(),
4231
4462
  valid: z.boolean(),
4232
4463
  uniqueCriteria: z.array(
@@ -4237,43 +4468,43 @@ var componentDetailsSchema = z.object({
4237
4468
  )
4238
4469
  });
4239
4470
 
4240
- // lib/items/models/RepeatableGroup.ts
4471
+ // lib/items/v1/models/RepeatableGroup.ts
4241
4472
  var repeatableGroupSchema = z.object({
4242
4473
  repeatableGroupId: z.string(),
4243
4474
  repeatableNumber: z.number()
4244
4475
  });
4245
4476
 
4246
- // lib/items/models/GroupedAttributeList.ts
4477
+ // lib/items/v1/models/GroupedAttributeList.ts
4247
4478
  var groupedAttributeListSchema = z.object({
4248
4479
  type: z.string(),
4249
4480
  rows: z.array(z.array(attributeDetailSchema)),
4250
4481
  repeatableGroups: z.array(repeatableGroupSchema)
4251
4482
  });
4252
4483
 
4253
- // lib/items/models/GroupedAttributes.ts
4484
+ // lib/items/v1/models/GroupedAttributes.ts
4254
4485
  var groupedAttributesSchema = z.object({
4255
4486
  type: z.string(),
4256
4487
  attributes: z.array(attributeDetailSchema),
4257
4488
  attributeGroups: z.array(groupedAttributeListSchema)
4258
4489
  });
4259
4490
 
4260
- // lib/items/models/HierarchyCategory.ts
4491
+ // lib/items/v1/models/HierarchyCategory.ts
4261
4492
  var hierarchyCategorySchema = z.object({
4262
4493
  name: z.string(),
4263
4494
  description: z.string().nullish(),
4264
4495
  id: z.number(),
4265
- companyId: z.number(),
4496
+ companyId: z.number().nullish(),
4266
4497
  type: categoryEnumSchema
4267
4498
  });
4268
4499
 
4269
- // lib/items/models/HierarchyDetails.ts
4500
+ // lib/items/v1/models/HierarchyDetails.ts
4270
4501
  var hierarchyDetailsSchema = z.object({
4271
4502
  catalogs: z.array(hierarchyCategorySchema),
4272
4503
  selectionCodes: z.array(hierarchyCategorySchema),
4273
4504
  productCodes: z.array(hierarchyCategorySchema)
4274
4505
  });
4275
4506
 
4276
- // lib/items/models/PackComponentItemInfo.ts
4507
+ // lib/items/v1/models/PackComponentItemInfo.ts
4277
4508
  var packComponentItemInfoSchema = z.object({
4278
4509
  companyid: z.number(),
4279
4510
  createddate: z.number(),
@@ -4287,7 +4518,7 @@ var packComponentItemInfoSchema = z.object({
4287
4518
  attributes: z.record(z.string(), z.string().or(z.array(z.string())))
4288
4519
  });
4289
4520
 
4290
- // lib/items/models/ItemPrice.ts
4521
+ // lib/items/v1/models/ItemPrice.ts
4291
4522
  var itemPriceSchema = z.object({
4292
4523
  amount: z.number(),
4293
4524
  currency: z.string(),
@@ -4311,13 +4542,13 @@ var itemPriceSchema = z.object({
4311
4542
  priceUnitQuantityUOM: z.string().nullish()
4312
4543
  });
4313
4544
 
4314
- // lib/items/models/PackComponentDetails.ts
4545
+ // lib/items/v1/models/PackComponentDetails.ts
4315
4546
  var packComponentDetailsSchema = z.object({
4316
4547
  itemInfo: packComponentItemInfoSchema,
4317
4548
  itemPrices: z.array(itemPriceSchema)
4318
4549
  });
4319
4550
 
4320
- // lib/items/models/GroupedItem.ts
4551
+ // lib/items/v1/models/GroupedItem.ts
4321
4552
  var groupedItemSchema = z.object({
4322
4553
  iteminfoid: z.number(),
4323
4554
  companyid: z.number(),
@@ -4333,12 +4564,12 @@ var groupedItemSchema = z.object({
4333
4564
  locales: z.array(z.string())
4334
4565
  });
4335
4566
 
4336
- // lib/items/models/ItemDetailView.ts
4567
+ // lib/items/v1/models/ItemDetailView.ts
4337
4568
  var itemDetailViewSchema = z.object({
4338
4569
  item: groupedItemSchema
4339
4570
  });
4340
4571
 
4341
- // lib/items/models/Bulb.ts
4572
+ // lib/items/v1/models/Bulb.ts
4342
4573
  var bulbSchema = z.object({
4343
4574
  iteminfoid: z.number(),
4344
4575
  id: z.number(),
@@ -4356,14 +4587,14 @@ var bulbSchema = z.object({
4356
4587
  threewaybulb: z.string()
4357
4588
  });
4358
4589
 
4359
- // lib/items/models/PackComponent.ts
4590
+ // lib/items/v1/models/PackComponent.ts
4360
4591
  var packComponentSchema = z.object({
4361
4592
  itemInfoId: z.number().nullish(),
4362
4593
  attributes: z.record(z.string(), z.string().or(z.array(z.string()))),
4363
4594
  prices: z.array(itemPriceSchema)
4364
4595
  });
4365
4596
 
4366
- // lib/items/models/MediaItem.ts
4597
+ // lib/items/v1/models/MediaItem.ts
4367
4598
  var mediaItemSchema = z.object({
4368
4599
  id: z.number(),
4369
4600
  iteminfoid: z.number(),
@@ -4384,7 +4615,7 @@ var mediaItemSchema = z.object({
4384
4615
  thumbnailflag: z.string().nullish()
4385
4616
  });
4386
4617
 
4387
- // lib/items/models/ItemDetail.ts
4618
+ // lib/items/v1/models/ItemDetail.ts
4388
4619
  var itemDetailSchema = z.object({
4389
4620
  attributes: z.record(z.string(), z.any()),
4390
4621
  clusters: z.record(
@@ -4404,13 +4635,13 @@ var itemDetailSchema = z.object({
4404
4635
  packs: z.array(packComponentSchema)
4405
4636
  });
4406
4637
 
4407
- // lib/items/models/SpsItemIdResponse.ts
4638
+ // lib/items/v1/models/SpsItemIdResponse.ts
4408
4639
  var spsItemIdResponseSchema = z.object({
4409
4640
  id: z.string(),
4410
4641
  ref: z.string()
4411
4642
  });
4412
4643
 
4413
- // lib/items/models/ItemOrgStatus.ts
4644
+ // lib/items/v1/models/ItemOrgStatus.ts
4414
4645
  var itemOrgStatusSchema = z.object({
4415
4646
  org: z.object({
4416
4647
  ref: z.string(),
@@ -4421,13 +4652,13 @@ var itemOrgStatusSchema = z.object({
4421
4652
  validForRelationship: z.boolean()
4422
4653
  });
4423
4654
 
4424
- // lib/items/models/ItemStatus.ts
4655
+ // lib/items/v1/models/ItemStatus.ts
4425
4656
  var itemStatusSchema = z.object({
4426
4657
  itemId: z.string(),
4427
4658
  itemOrgStatuses: z.array(itemOrgStatusSchema)
4428
4659
  });
4429
4660
 
4430
- // lib/items/models/ItemStatusResponse.ts
4661
+ // lib/items/v1/models/ItemStatusResponse.ts
4431
4662
  var itemStatusResponseSchema = z.object({
4432
4663
  itemStatuses: z.array(itemStatusSchema)
4433
4664
  });
@@ -4485,7 +4716,7 @@ var companyRelationshipUpsertBodySchema = z.object({
4485
4716
  supplierId: z.number(),
4486
4717
  retailerId: z.number(),
4487
4718
  catalogId: z.number(),
4488
- isActive: z.boolean(),
4719
+ active: z.boolean(),
4489
4720
  applicationType: z.array(z.enum(["ASSORTMENT", "ITEM-XREF"])).default([])
4490
4721
  });
4491
4722
 
@@ -4667,7 +4898,6 @@ var companyBriefByOrgSchema = z.object({
4667
4898
  groupedItemSchema,
4668
4899
  hierarchyCategorySchema,
4669
4900
  hierarchyDetailsSchema,
4670
- hierarchySchema,
4671
4901
  identityServiceDatetimePreferencesSchema,
4672
4902
  identityServiceOrganizationMetadataSchema,
4673
4903
  identityServiceOrganizationSchema,
@@ -4687,7 +4917,6 @@ var companyBriefByOrgSchema = z.object({
4687
4917
  itemErrorDetailsSchema,
4688
4918
  itemHeaderSchema,
4689
4919
  itemHierarchyResponseSchema,
4690
- itemHierarchySchema,
4691
4920
  itemMapSchema,
4692
4921
  itemPartnerSchema,
4693
4922
  itemPriceSchema,