@spscommerce/asst-api 0.1.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/index.cjs CHANGED
@@ -41,19 +41,22 @@ __export(lib_exports, {
41
41
  createFeatureFlagsApi: () => createFeatureFlagsApi,
42
42
  createImportsApi: () => createImportsApi,
43
43
  createItemsApi: () => createItemsApi,
44
+ createItemsApiV2: () => createItemsApiV2,
44
45
  createLocaleApi: () => createLocaleApi,
45
46
  createProductTypesApi: () => createProductTypesApi,
46
47
  createSpreadsheetTemplateApi: () => createSpreadsheetTemplateApi,
47
48
  createTradingPartnerAccessApi: () => createTradingPartnerAccessApi,
49
+ createTradingPartnerSettingsApi: () => createTradingPartnerSettingsApi,
48
50
  createUniqueCriteriaApi: () => createUniqueCriteriaApi,
49
- createWhoAmIApi: () => createWhoAmIApi
51
+ createWhoAmIApi: () => createWhoAmIApi,
52
+ envSchema: () => envSchema
50
53
  });
51
54
  module.exports = __toCommonJS(lib_exports);
52
55
 
53
56
  // lib/asstClient.ts
54
57
  var import_ky_universal = __toESM(require("ky-universal"), 1);
55
58
 
56
- // ../../node_modules/.pnpm/zod@3.21.4/node_modules/zod/lib/index.mjs
59
+ // ../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
57
60
  var util;
58
61
  (function(util2) {
59
62
  util2.assertEqual = (val) => val;
@@ -207,7 +210,7 @@ var quotelessJson = (obj) => {
207
210
  const json = JSON.stringify(obj, null, 2);
208
211
  return json.replace(/"([^"]+)":/g, "$1:");
209
212
  };
210
- var ZodError = class extends Error {
213
+ var ZodError = class _ZodError extends Error {
211
214
  constructor(issues) {
212
215
  super();
213
216
  this.issues = [];
@@ -265,6 +268,11 @@ var ZodError = class extends Error {
265
268
  processError(this);
266
269
  return fieldErrors;
267
270
  }
271
+ static assert(value) {
272
+ if (!(value instanceof _ZodError)) {
273
+ throw new Error(`Not a ZodError: ${value}`);
274
+ }
275
+ }
268
276
  toString() {
269
277
  return this.message;
270
278
  }
@@ -407,6 +415,13 @@ var makeIssue = (params) => {
407
415
  ...issueData,
408
416
  path: fullPath
409
417
  };
418
+ if (issueData.message !== void 0) {
419
+ return {
420
+ ...issueData,
421
+ path: fullPath,
422
+ message: issueData.message
423
+ };
424
+ }
410
425
  let errorMessage = "";
411
426
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
412
427
  for (const map of maps) {
@@ -415,11 +430,12 @@ var makeIssue = (params) => {
415
430
  return {
416
431
  ...issueData,
417
432
  path: fullPath,
418
- message: issueData.message || errorMessage
433
+ message: errorMessage
419
434
  };
420
435
  };
421
436
  var EMPTY_PATH = [];
422
437
  function addIssueToContext(ctx, issueData) {
438
+ const overrideMap = getErrorMap();
423
439
  const issue = makeIssue({
424
440
  issueData,
425
441
  data: ctx.data,
@@ -427,14 +443,14 @@ function addIssueToContext(ctx, issueData) {
427
443
  errorMaps: [
428
444
  ctx.common.contextualErrorMap,
429
445
  ctx.schemaErrorMap,
430
- getErrorMap(),
431
- errorMap
446
+ overrideMap,
447
+ overrideMap === errorMap ? void 0 : errorMap
432
448
  // then global default map
433
449
  ].filter((x) => !!x)
434
450
  });
435
451
  ctx.common.issues.push(issue);
436
452
  }
437
- var ParseStatus = class {
453
+ var ParseStatus = class _ParseStatus {
438
454
  constructor() {
439
455
  this.value = "valid";
440
456
  }
@@ -460,12 +476,14 @@ var ParseStatus = class {
460
476
  static async mergeObjectAsync(status, pairs) {
461
477
  const syncPairs = [];
462
478
  for (const pair of pairs) {
479
+ const key = await pair.key;
480
+ const value = await pair.value;
463
481
  syncPairs.push({
464
- key: await pair.key,
465
- value: await pair.value
482
+ key,
483
+ value
466
484
  });
467
485
  }
468
- return ParseStatus.mergeObjectSync(status, syncPairs);
486
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
469
487
  }
470
488
  static mergeObjectSync(status, pairs) {
471
489
  const finalObject = {};
@@ -479,7 +497,7 @@ var ParseStatus = class {
479
497
  status.dirty();
480
498
  if (value.status === "dirty")
481
499
  status.dirty();
482
- if (typeof value.value !== "undefined" || pair.alwaysSet) {
500
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
483
501
  finalObject[key.value] = value.value;
484
502
  }
485
503
  }
@@ -495,11 +513,29 @@ var isAborted = (x) => x.status === "aborted";
495
513
  var isDirty = (x) => x.status === "dirty";
496
514
  var isValid = (x) => x.status === "valid";
497
515
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
516
+ function __classPrivateFieldGet(receiver, state, kind, f) {
517
+ if (kind === "a" && !f)
518
+ throw new TypeError("Private accessor was defined without a getter");
519
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
520
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
521
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
522
+ }
523
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
524
+ if (kind === "m")
525
+ throw new TypeError("Private method is not writable");
526
+ if (kind === "a" && !f)
527
+ throw new TypeError("Private accessor was defined without a setter");
528
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
529
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
530
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
531
+ }
498
532
  var errorUtil;
499
533
  (function(errorUtil2) {
500
534
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
501
535
  errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
502
536
  })(errorUtil || (errorUtil = {}));
537
+ var _ZodEnum_cache;
538
+ var _ZodNativeEnum_cache;
503
539
  var ParseInputLazyPath = class {
504
540
  constructor(parent, value, path, key) {
505
541
  this._cachedPath = [];
@@ -548,12 +584,17 @@ function processCreateParams(params) {
548
584
  if (errorMap2)
549
585
  return { errorMap: errorMap2, description };
550
586
  const customMap = (iss, ctx) => {
551
- if (iss.code !== "invalid_type")
552
- return { message: ctx.defaultError };
587
+ var _a, _b;
588
+ const { message } = params;
589
+ if (iss.code === "invalid_enum_value") {
590
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
591
+ }
553
592
  if (typeof ctx.data === "undefined") {
554
- return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
593
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
555
594
  }
556
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
595
+ if (iss.code !== "invalid_type")
596
+ return { message: ctx.defaultError };
597
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
557
598
  };
558
599
  return { errorMap: customMap, description };
559
600
  }
@@ -582,6 +623,7 @@ var ZodType = class {
582
623
  this.catch = this.catch.bind(this);
583
624
  this.describe = this.describe.bind(this);
584
625
  this.pipe = this.pipe.bind(this);
626
+ this.readonly = this.readonly.bind(this);
585
627
  this.isNullable = this.isNullable.bind(this);
586
628
  this.isOptional = this.isOptional.bind(this);
587
629
  }
@@ -789,6 +831,9 @@ var ZodType = class {
789
831
  pipe(target) {
790
832
  return ZodPipeline.create(this, target);
791
833
  }
834
+ readonly() {
835
+ return ZodReadonly.create(this);
836
+ }
792
837
  isOptional() {
793
838
  return this.safeParse(void 0).success;
794
839
  }
@@ -797,34 +842,40 @@ var ZodType = class {
797
842
  }
798
843
  };
799
844
  var cuidRegex = /^c[^\s-]{8,}$/i;
800
- var cuid2Regex = /^[a-z][a-z0-9]*$/;
801
- var ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/;
802
- 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;
803
- 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,})+))$/;
804
- var emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u;
805
- 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}))$/;
845
+ var cuid2Regex = /^[0-9a-z]+$/;
846
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
847
+ 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;
848
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
849
+ 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)?)??$/;
850
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
851
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
852
+ var emojiRegex;
853
+ 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])$/;
806
854
  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})))$/;
807
- var datetimeRegex = (args) => {
855
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
856
+ 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])))`;
857
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
858
+ function timeRegexSource(args) {
859
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
808
860
  if (args.precision) {
809
- if (args.offset) {
810
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
811
- } else {
812
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
813
- }
814
- } else if (args.precision === 0) {
815
- if (args.offset) {
816
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
817
- } else {
818
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
819
- }
820
- } else {
821
- if (args.offset) {
822
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
823
- } else {
824
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
825
- }
861
+ regex = `${regex}\\.\\d{${args.precision}}`;
862
+ } else if (args.precision == null) {
863
+ regex = `${regex}(\\.\\d+)?`;
826
864
  }
827
- };
865
+ return regex;
866
+ }
867
+ function timeRegex(args) {
868
+ return new RegExp(`^${timeRegexSource(args)}$`);
869
+ }
870
+ function datetimeRegex(args) {
871
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
872
+ const opts = [];
873
+ opts.push(args.local ? `Z?` : `Z`);
874
+ if (args.offset)
875
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
876
+ regex = `${regex}(${opts.join("|")})`;
877
+ return new RegExp(`^${regex}$`);
878
+ }
828
879
  function isValidIP(ip, version) {
829
880
  if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
830
881
  return true;
@@ -834,28 +885,7 @@ function isValidIP(ip, version) {
834
885
  }
835
886
  return false;
836
887
  }
837
- var ZodString = class extends ZodType {
838
- constructor() {
839
- super(...arguments);
840
- this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
841
- validation,
842
- code: ZodIssueCode.invalid_string,
843
- ...errorUtil.errToObj(message)
844
- });
845
- this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
846
- this.trim = () => new ZodString({
847
- ...this._def,
848
- checks: [...this._def.checks, { kind: "trim" }]
849
- });
850
- this.toLowerCase = () => new ZodString({
851
- ...this._def,
852
- checks: [...this._def.checks, { kind: "toLowerCase" }]
853
- });
854
- this.toUpperCase = () => new ZodString({
855
- ...this._def,
856
- checks: [...this._def.checks, { kind: "toUpperCase" }]
857
- });
858
- }
888
+ var ZodString = class _ZodString extends ZodType {
859
889
  _parse(input) {
860
890
  if (this._def.coerce) {
861
891
  input.data = String(input.data);
@@ -863,15 +893,11 @@ var ZodString = class extends ZodType {
863
893
  const parsedType = this._getType(input);
864
894
  if (parsedType !== ZodParsedType.string) {
865
895
  const ctx2 = this._getOrReturnCtx(input);
866
- addIssueToContext(
867
- ctx2,
868
- {
869
- code: ZodIssueCode.invalid_type,
870
- expected: ZodParsedType.string,
871
- received: ctx2.parsedType
872
- }
873
- //
874
- );
896
+ addIssueToContext(ctx2, {
897
+ code: ZodIssueCode.invalid_type,
898
+ expected: ZodParsedType.string,
899
+ received: ctx2.parsedType
900
+ });
875
901
  return INVALID;
876
902
  }
877
903
  const status = new ParseStatus();
@@ -940,6 +966,9 @@ var ZodString = class extends ZodType {
940
966
  status.dirty();
941
967
  }
942
968
  } else if (check.kind === "emoji") {
969
+ if (!emojiRegex) {
970
+ emojiRegex = new RegExp(_emojiRegex, "u");
971
+ }
943
972
  if (!emojiRegex.test(input.data)) {
944
973
  ctx = this._getOrReturnCtx(input, ctx);
945
974
  addIssueToContext(ctx, {
@@ -959,6 +988,16 @@ var ZodString = class extends ZodType {
959
988
  });
960
989
  status.dirty();
961
990
  }
991
+ } else if (check.kind === "nanoid") {
992
+ if (!nanoidRegex.test(input.data)) {
993
+ ctx = this._getOrReturnCtx(input, ctx);
994
+ addIssueToContext(ctx, {
995
+ validation: "nanoid",
996
+ code: ZodIssueCode.invalid_string,
997
+ message: check.message
998
+ });
999
+ status.dirty();
1000
+ }
962
1001
  } else if (check.kind === "cuid") {
963
1002
  if (!cuidRegex.test(input.data)) {
964
1003
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1060,6 +1099,38 @@ var ZodString = class extends ZodType {
1060
1099
  });
1061
1100
  status.dirty();
1062
1101
  }
1102
+ } else if (check.kind === "date") {
1103
+ const regex = dateRegex;
1104
+ if (!regex.test(input.data)) {
1105
+ ctx = this._getOrReturnCtx(input, ctx);
1106
+ addIssueToContext(ctx, {
1107
+ code: ZodIssueCode.invalid_string,
1108
+ validation: "date",
1109
+ message: check.message
1110
+ });
1111
+ status.dirty();
1112
+ }
1113
+ } else if (check.kind === "time") {
1114
+ const regex = timeRegex(check);
1115
+ if (!regex.test(input.data)) {
1116
+ ctx = this._getOrReturnCtx(input, ctx);
1117
+ addIssueToContext(ctx, {
1118
+ code: ZodIssueCode.invalid_string,
1119
+ validation: "time",
1120
+ message: check.message
1121
+ });
1122
+ status.dirty();
1123
+ }
1124
+ } else if (check.kind === "duration") {
1125
+ if (!durationRegex.test(input.data)) {
1126
+ ctx = this._getOrReturnCtx(input, ctx);
1127
+ addIssueToContext(ctx, {
1128
+ validation: "duration",
1129
+ code: ZodIssueCode.invalid_string,
1130
+ message: check.message
1131
+ });
1132
+ status.dirty();
1133
+ }
1063
1134
  } else if (check.kind === "ip") {
1064
1135
  if (!isValidIP(input.data, check.version)) {
1065
1136
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1070,14 +1141,31 @@ var ZodString = class extends ZodType {
1070
1141
  });
1071
1142
  status.dirty();
1072
1143
  }
1144
+ } else if (check.kind === "base64") {
1145
+ if (!base64Regex.test(input.data)) {
1146
+ ctx = this._getOrReturnCtx(input, ctx);
1147
+ addIssueToContext(ctx, {
1148
+ validation: "base64",
1149
+ code: ZodIssueCode.invalid_string,
1150
+ message: check.message
1151
+ });
1152
+ status.dirty();
1153
+ }
1073
1154
  } else {
1074
1155
  util.assertNever(check);
1075
1156
  }
1076
1157
  }
1077
1158
  return { status: status.value, value: input.data };
1078
1159
  }
1160
+ _regex(regex, validation, message) {
1161
+ return this.refinement((data) => regex.test(data), {
1162
+ validation,
1163
+ code: ZodIssueCode.invalid_string,
1164
+ ...errorUtil.errToObj(message)
1165
+ });
1166
+ }
1079
1167
  _addCheck(check) {
1080
- return new ZodString({
1168
+ return new _ZodString({
1081
1169
  ...this._def,
1082
1170
  checks: [...this._def.checks, check]
1083
1171
  });
@@ -1094,6 +1182,9 @@ var ZodString = class extends ZodType {
1094
1182
  uuid(message) {
1095
1183
  return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1096
1184
  }
1185
+ nanoid(message) {
1186
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1187
+ }
1097
1188
  cuid(message) {
1098
1189
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1099
1190
  }
@@ -1103,16 +1194,20 @@ var ZodString = class extends ZodType {
1103
1194
  ulid(message) {
1104
1195
  return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1105
1196
  }
1197
+ base64(message) {
1198
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1199
+ }
1106
1200
  ip(options) {
1107
1201
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1108
1202
  }
1109
1203
  datetime(options) {
1110
- var _a;
1204
+ var _a, _b;
1111
1205
  if (typeof options === "string") {
1112
1206
  return this._addCheck({
1113
1207
  kind: "datetime",
1114
1208
  precision: null,
1115
1209
  offset: false,
1210
+ local: false,
1116
1211
  message: options
1117
1212
  });
1118
1213
  }
@@ -1120,9 +1215,30 @@ var ZodString = class extends ZodType {
1120
1215
  kind: "datetime",
1121
1216
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1122
1217
  offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1218
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
1219
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1220
+ });
1221
+ }
1222
+ date(message) {
1223
+ return this._addCheck({ kind: "date", message });
1224
+ }
1225
+ time(options) {
1226
+ if (typeof options === "string") {
1227
+ return this._addCheck({
1228
+ kind: "time",
1229
+ precision: null,
1230
+ message: options
1231
+ });
1232
+ }
1233
+ return this._addCheck({
1234
+ kind: "time",
1235
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1123
1236
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1124
1237
  });
1125
1238
  }
1239
+ duration(message) {
1240
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1241
+ }
1126
1242
  regex(regex, message) {
1127
1243
  return this._addCheck({
1128
1244
  kind: "regex",
@@ -1173,9 +1289,43 @@ var ZodString = class extends ZodType {
1173
1289
  ...errorUtil.errToObj(message)
1174
1290
  });
1175
1291
  }
1292
+ /**
1293
+ * @deprecated Use z.string().min(1) instead.
1294
+ * @see {@link ZodString.min}
1295
+ */
1296
+ nonempty(message) {
1297
+ return this.min(1, errorUtil.errToObj(message));
1298
+ }
1299
+ trim() {
1300
+ return new _ZodString({
1301
+ ...this._def,
1302
+ checks: [...this._def.checks, { kind: "trim" }]
1303
+ });
1304
+ }
1305
+ toLowerCase() {
1306
+ return new _ZodString({
1307
+ ...this._def,
1308
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1309
+ });
1310
+ }
1311
+ toUpperCase() {
1312
+ return new _ZodString({
1313
+ ...this._def,
1314
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1315
+ });
1316
+ }
1176
1317
  get isDatetime() {
1177
1318
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
1178
1319
  }
1320
+ get isDate() {
1321
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1322
+ }
1323
+ get isTime() {
1324
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1325
+ }
1326
+ get isDuration() {
1327
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1328
+ }
1179
1329
  get isEmail() {
1180
1330
  return !!this._def.checks.find((ch) => ch.kind === "email");
1181
1331
  }
@@ -1188,6 +1338,9 @@ var ZodString = class extends ZodType {
1188
1338
  get isUUID() {
1189
1339
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
1190
1340
  }
1341
+ get isNANOID() {
1342
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1343
+ }
1191
1344
  get isCUID() {
1192
1345
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
1193
1346
  }
@@ -1200,6 +1353,9 @@ var ZodString = class extends ZodType {
1200
1353
  get isIP() {
1201
1354
  return !!this._def.checks.find((ch) => ch.kind === "ip");
1202
1355
  }
1356
+ get isBase64() {
1357
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1358
+ }
1203
1359
  get minLength() {
1204
1360
  let min = null;
1205
1361
  for (const ch of this._def.checks) {
@@ -1238,7 +1394,7 @@ function floatSafeRemainder(val, step) {
1238
1394
  const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
1239
1395
  return valInt % stepInt / Math.pow(10, decCount);
1240
1396
  }
1241
- var ZodNumber = class extends ZodType {
1397
+ var ZodNumber = class _ZodNumber extends ZodType {
1242
1398
  constructor() {
1243
1399
  super(...arguments);
1244
1400
  this.min = this.gte;
@@ -1339,7 +1495,7 @@ var ZodNumber = class extends ZodType {
1339
1495
  return this.setLimit("max", value, false, errorUtil.toString(message));
1340
1496
  }
1341
1497
  setLimit(kind, value, inclusive, message) {
1342
- return new ZodNumber({
1498
+ return new _ZodNumber({
1343
1499
  ...this._def,
1344
1500
  checks: [
1345
1501
  ...this._def.checks,
@@ -1353,7 +1509,7 @@ var ZodNumber = class extends ZodType {
1353
1509
  });
1354
1510
  }
1355
1511
  _addCheck(check) {
1356
- return new ZodNumber({
1512
+ return new _ZodNumber({
1357
1513
  ...this._def,
1358
1514
  checks: [...this._def.checks, check]
1359
1515
  });
@@ -1469,7 +1625,7 @@ ZodNumber.create = (params) => {
1469
1625
  ...processCreateParams(params)
1470
1626
  });
1471
1627
  };
1472
- var ZodBigInt = class extends ZodType {
1628
+ var ZodBigInt = class _ZodBigInt extends ZodType {
1473
1629
  constructor() {
1474
1630
  super(...arguments);
1475
1631
  this.min = this.gte;
@@ -1547,7 +1703,7 @@ var ZodBigInt = class extends ZodType {
1547
1703
  return this.setLimit("max", value, false, errorUtil.toString(message));
1548
1704
  }
1549
1705
  setLimit(kind, value, inclusive, message) {
1550
- return new ZodBigInt({
1706
+ return new _ZodBigInt({
1551
1707
  ...this._def,
1552
1708
  checks: [
1553
1709
  ...this._def.checks,
@@ -1561,7 +1717,7 @@ var ZodBigInt = class extends ZodType {
1561
1717
  });
1562
1718
  }
1563
1719
  _addCheck(check) {
1564
- return new ZodBigInt({
1720
+ return new _ZodBigInt({
1565
1721
  ...this._def,
1566
1722
  checks: [...this._def.checks, check]
1567
1723
  });
@@ -1660,7 +1816,7 @@ ZodBoolean.create = (params) => {
1660
1816
  ...processCreateParams(params)
1661
1817
  });
1662
1818
  };
1663
- var ZodDate = class extends ZodType {
1819
+ var ZodDate = class _ZodDate extends ZodType {
1664
1820
  _parse(input) {
1665
1821
  if (this._def.coerce) {
1666
1822
  input.data = new Date(input.data);
@@ -1721,7 +1877,7 @@ var ZodDate = class extends ZodType {
1721
1877
  };
1722
1878
  }
1723
1879
  _addCheck(check) {
1724
- return new ZodDate({
1880
+ return new _ZodDate({
1725
1881
  ...this._def,
1726
1882
  checks: [...this._def.checks, check]
1727
1883
  });
@@ -1900,7 +2056,7 @@ ZodVoid.create = (params) => {
1900
2056
  ...processCreateParams(params)
1901
2057
  });
1902
2058
  };
1903
- var ZodArray = class extends ZodType {
2059
+ var ZodArray = class _ZodArray extends ZodType {
1904
2060
  _parse(input) {
1905
2061
  const { ctx, status } = this._processInputParams(input);
1906
2062
  const def = this._def;
@@ -1970,19 +2126,19 @@ var ZodArray = class extends ZodType {
1970
2126
  return this._def.type;
1971
2127
  }
1972
2128
  min(minLength, message) {
1973
- return new ZodArray({
2129
+ return new _ZodArray({
1974
2130
  ...this._def,
1975
2131
  minLength: { value: minLength, message: errorUtil.toString(message) }
1976
2132
  });
1977
2133
  }
1978
2134
  max(maxLength, message) {
1979
- return new ZodArray({
2135
+ return new _ZodArray({
1980
2136
  ...this._def,
1981
2137
  maxLength: { value: maxLength, message: errorUtil.toString(message) }
1982
2138
  });
1983
2139
  }
1984
2140
  length(len, message) {
1985
- return new ZodArray({
2141
+ return new _ZodArray({
1986
2142
  ...this._def,
1987
2143
  exactLength: { value: len, message: errorUtil.toString(message) }
1988
2144
  });
@@ -2027,7 +2183,7 @@ function deepPartialify(schema) {
2027
2183
  return schema;
2028
2184
  }
2029
2185
  }
2030
- var ZodObject = class extends ZodType {
2186
+ var ZodObject = class _ZodObject extends ZodType {
2031
2187
  constructor() {
2032
2188
  super(...arguments);
2033
2189
  this._cached = null;
@@ -2113,9 +2269,10 @@ var ZodObject = class extends ZodType {
2113
2269
  const syncPairs = [];
2114
2270
  for (const pair of pairs) {
2115
2271
  const key = await pair.key;
2272
+ const value = await pair.value;
2116
2273
  syncPairs.push({
2117
2274
  key,
2118
- value: await pair.value,
2275
+ value,
2119
2276
  alwaysSet: pair.alwaysSet
2120
2277
  });
2121
2278
  }
@@ -2132,7 +2289,7 @@ var ZodObject = class extends ZodType {
2132
2289
  }
2133
2290
  strict(message) {
2134
2291
  errorUtil.errToObj;
2135
- return new ZodObject({
2292
+ return new _ZodObject({
2136
2293
  ...this._def,
2137
2294
  unknownKeys: "strict",
2138
2295
  ...message !== void 0 ? {
@@ -2151,13 +2308,13 @@ var ZodObject = class extends ZodType {
2151
2308
  });
2152
2309
  }
2153
2310
  strip() {
2154
- return new ZodObject({
2311
+ return new _ZodObject({
2155
2312
  ...this._def,
2156
2313
  unknownKeys: "strip"
2157
2314
  });
2158
2315
  }
2159
2316
  passthrough() {
2160
- return new ZodObject({
2317
+ return new _ZodObject({
2161
2318
  ...this._def,
2162
2319
  unknownKeys: "passthrough"
2163
2320
  });
@@ -2180,7 +2337,7 @@ var ZodObject = class extends ZodType {
2180
2337
  // }) as any;
2181
2338
  // };
2182
2339
  extend(augmentation) {
2183
- return new ZodObject({
2340
+ return new _ZodObject({
2184
2341
  ...this._def,
2185
2342
  shape: () => ({
2186
2343
  ...this._def.shape(),
@@ -2194,7 +2351,7 @@ var ZodObject = class extends ZodType {
2194
2351
  * upgrade if you are experiencing issues.
2195
2352
  */
2196
2353
  merge(merging) {
2197
- const merged = new ZodObject({
2354
+ const merged = new _ZodObject({
2198
2355
  unknownKeys: merging._def.unknownKeys,
2199
2356
  catchall: merging._def.catchall,
2200
2357
  shape: () => ({
@@ -2265,7 +2422,7 @@ var ZodObject = class extends ZodType {
2265
2422
  // return merged;
2266
2423
  // }
2267
2424
  catchall(index) {
2268
- return new ZodObject({
2425
+ return new _ZodObject({
2269
2426
  ...this._def,
2270
2427
  catchall: index
2271
2428
  });
@@ -2277,7 +2434,7 @@ var ZodObject = class extends ZodType {
2277
2434
  shape[key] = this.shape[key];
2278
2435
  }
2279
2436
  });
2280
- return new ZodObject({
2437
+ return new _ZodObject({
2281
2438
  ...this._def,
2282
2439
  shape: () => shape
2283
2440
  });
@@ -2289,7 +2446,7 @@ var ZodObject = class extends ZodType {
2289
2446
  shape[key] = this.shape[key];
2290
2447
  }
2291
2448
  });
2292
- return new ZodObject({
2449
+ return new _ZodObject({
2293
2450
  ...this._def,
2294
2451
  shape: () => shape
2295
2452
  });
@@ -2310,7 +2467,7 @@ var ZodObject = class extends ZodType {
2310
2467
  newShape[key] = fieldSchema.optional();
2311
2468
  }
2312
2469
  });
2313
- return new ZodObject({
2470
+ return new _ZodObject({
2314
2471
  ...this._def,
2315
2472
  shape: () => newShape
2316
2473
  });
@@ -2329,7 +2486,7 @@ var ZodObject = class extends ZodType {
2329
2486
  newShape[key] = newField;
2330
2487
  }
2331
2488
  });
2332
- return new ZodObject({
2489
+ return new _ZodObject({
2333
2490
  ...this._def,
2334
2491
  shape: () => newShape
2335
2492
  });
@@ -2466,18 +2623,28 @@ var getDiscriminator = (type) => {
2466
2623
  } else if (type instanceof ZodEnum) {
2467
2624
  return type.options;
2468
2625
  } else if (type instanceof ZodNativeEnum) {
2469
- return Object.keys(type.enum);
2626
+ return util.objectValues(type.enum);
2470
2627
  } else if (type instanceof ZodDefault) {
2471
2628
  return getDiscriminator(type._def.innerType);
2472
2629
  } else if (type instanceof ZodUndefined) {
2473
2630
  return [void 0];
2474
2631
  } else if (type instanceof ZodNull) {
2475
2632
  return [null];
2633
+ } else if (type instanceof ZodOptional) {
2634
+ return [void 0, ...getDiscriminator(type.unwrap())];
2635
+ } else if (type instanceof ZodNullable) {
2636
+ return [null, ...getDiscriminator(type.unwrap())];
2637
+ } else if (type instanceof ZodBranded) {
2638
+ return getDiscriminator(type.unwrap());
2639
+ } else if (type instanceof ZodReadonly) {
2640
+ return getDiscriminator(type.unwrap());
2641
+ } else if (type instanceof ZodCatch) {
2642
+ return getDiscriminator(type._def.innerType);
2476
2643
  } else {
2477
- return null;
2644
+ return [];
2478
2645
  }
2479
2646
  };
2480
- var ZodDiscriminatedUnion = class extends ZodType {
2647
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2481
2648
  _parse(input) {
2482
2649
  const { ctx } = this._processInputParams(input);
2483
2650
  if (ctx.parsedType !== ZodParsedType.object) {
@@ -2534,7 +2701,7 @@ var ZodDiscriminatedUnion = class extends ZodType {
2534
2701
  const optionsMap = /* @__PURE__ */ new Map();
2535
2702
  for (const type of options) {
2536
2703
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2537
- if (!discriminatorValues) {
2704
+ if (!discriminatorValues.length) {
2538
2705
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2539
2706
  }
2540
2707
  for (const value of discriminatorValues) {
@@ -2544,7 +2711,7 @@ var ZodDiscriminatedUnion = class extends ZodType {
2544
2711
  optionsMap.set(value, type);
2545
2712
  }
2546
2713
  }
2547
- return new ZodDiscriminatedUnion({
2714
+ return new _ZodDiscriminatedUnion({
2548
2715
  typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2549
2716
  discriminator,
2550
2717
  options,
@@ -2644,7 +2811,7 @@ ZodIntersection.create = (left, right, params) => {
2644
2811
  ...processCreateParams(params)
2645
2812
  });
2646
2813
  };
2647
- var ZodTuple = class extends ZodType {
2814
+ var ZodTuple = class _ZodTuple extends ZodType {
2648
2815
  _parse(input) {
2649
2816
  const { status, ctx } = this._processInputParams(input);
2650
2817
  if (ctx.parsedType !== ZodParsedType.array) {
@@ -2694,7 +2861,7 @@ var ZodTuple = class extends ZodType {
2694
2861
  return this._def.items;
2695
2862
  }
2696
2863
  rest(rest) {
2697
- return new ZodTuple({
2864
+ return new _ZodTuple({
2698
2865
  ...this._def,
2699
2866
  rest
2700
2867
  });
@@ -2711,7 +2878,7 @@ ZodTuple.create = (schemas, params) => {
2711
2878
  ...processCreateParams(params)
2712
2879
  });
2713
2880
  };
2714
- var ZodRecord = class extends ZodType {
2881
+ var ZodRecord = class _ZodRecord extends ZodType {
2715
2882
  get keySchema() {
2716
2883
  return this._def.keyType;
2717
2884
  }
@@ -2734,7 +2901,8 @@ var ZodRecord = class extends ZodType {
2734
2901
  for (const key in ctx.data) {
2735
2902
  pairs.push({
2736
2903
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2737
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
2904
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
2905
+ alwaysSet: key in ctx.data
2738
2906
  });
2739
2907
  }
2740
2908
  if (ctx.common.async) {
@@ -2748,14 +2916,14 @@ var ZodRecord = class extends ZodType {
2748
2916
  }
2749
2917
  static create(first, second, third) {
2750
2918
  if (second instanceof ZodType) {
2751
- return new ZodRecord({
2919
+ return new _ZodRecord({
2752
2920
  keyType: first,
2753
2921
  valueType: second,
2754
2922
  typeName: ZodFirstPartyTypeKind.ZodRecord,
2755
2923
  ...processCreateParams(third)
2756
2924
  });
2757
2925
  }
2758
- return new ZodRecord({
2926
+ return new _ZodRecord({
2759
2927
  keyType: ZodString.create(),
2760
2928
  valueType: first,
2761
2929
  typeName: ZodFirstPartyTypeKind.ZodRecord,
@@ -2764,6 +2932,12 @@ var ZodRecord = class extends ZodType {
2764
2932
  }
2765
2933
  };
2766
2934
  var ZodMap = class extends ZodType {
2935
+ get keySchema() {
2936
+ return this._def.keyType;
2937
+ }
2938
+ get valueSchema() {
2939
+ return this._def.valueType;
2940
+ }
2767
2941
  _parse(input) {
2768
2942
  const { status, ctx } = this._processInputParams(input);
2769
2943
  if (ctx.parsedType !== ZodParsedType.map) {
@@ -2823,7 +2997,7 @@ ZodMap.create = (keyType, valueType, params) => {
2823
2997
  ...processCreateParams(params)
2824
2998
  });
2825
2999
  };
2826
- var ZodSet = class extends ZodType {
3000
+ var ZodSet = class _ZodSet extends ZodType {
2827
3001
  _parse(input) {
2828
3002
  const { status, ctx } = this._processInputParams(input);
2829
3003
  if (ctx.parsedType !== ZodParsedType.set) {
@@ -2881,13 +3055,13 @@ var ZodSet = class extends ZodType {
2881
3055
  }
2882
3056
  }
2883
3057
  min(minSize, message) {
2884
- return new ZodSet({
3058
+ return new _ZodSet({
2885
3059
  ...this._def,
2886
3060
  minSize: { value: minSize, message: errorUtil.toString(message) }
2887
3061
  });
2888
3062
  }
2889
3063
  max(maxSize, message) {
2890
- return new ZodSet({
3064
+ return new _ZodSet({
2891
3065
  ...this._def,
2892
3066
  maxSize: { value: maxSize, message: errorUtil.toString(message) }
2893
3067
  });
@@ -2908,7 +3082,7 @@ ZodSet.create = (valueType, params) => {
2908
3082
  ...processCreateParams(params)
2909
3083
  });
2910
3084
  };
2911
- var ZodFunction = class extends ZodType {
3085
+ var ZodFunction = class _ZodFunction extends ZodType {
2912
3086
  constructor() {
2913
3087
  super(...arguments);
2914
3088
  this.validate = this.implement;
@@ -2958,27 +3132,29 @@ var ZodFunction = class extends ZodType {
2958
3132
  const params = { errorMap: ctx.common.contextualErrorMap };
2959
3133
  const fn = ctx.data;
2960
3134
  if (this._def.returns instanceof ZodPromise) {
2961
- return OK(async (...args) => {
3135
+ const me = this;
3136
+ return OK(async function(...args) {
2962
3137
  const error = new ZodError([]);
2963
- const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => {
3138
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
2964
3139
  error.addIssue(makeArgsIssue(args, e));
2965
3140
  throw error;
2966
3141
  });
2967
- const result = await fn(...parsedArgs);
2968
- const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => {
3142
+ const result = await Reflect.apply(fn, this, parsedArgs);
3143
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
2969
3144
  error.addIssue(makeReturnsIssue(result, e));
2970
3145
  throw error;
2971
3146
  });
2972
3147
  return parsedReturns;
2973
3148
  });
2974
3149
  } else {
2975
- return OK((...args) => {
2976
- const parsedArgs = this._def.args.safeParse(args, params);
3150
+ const me = this;
3151
+ return OK(function(...args) {
3152
+ const parsedArgs = me._def.args.safeParse(args, params);
2977
3153
  if (!parsedArgs.success) {
2978
3154
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
2979
3155
  }
2980
- const result = fn(...parsedArgs.data);
2981
- const parsedReturns = this._def.returns.safeParse(result, params);
3156
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3157
+ const parsedReturns = me._def.returns.safeParse(result, params);
2982
3158
  if (!parsedReturns.success) {
2983
3159
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
2984
3160
  }
@@ -2993,13 +3169,13 @@ var ZodFunction = class extends ZodType {
2993
3169
  return this._def.returns;
2994
3170
  }
2995
3171
  args(...items) {
2996
- return new ZodFunction({
3172
+ return new _ZodFunction({
2997
3173
  ...this._def,
2998
3174
  args: ZodTuple.create(items).rest(ZodUnknown.create())
2999
3175
  });
3000
3176
  }
3001
3177
  returns(returnType) {
3002
- return new ZodFunction({
3178
+ return new _ZodFunction({
3003
3179
  ...this._def,
3004
3180
  returns: returnType
3005
3181
  });
@@ -3013,7 +3189,7 @@ var ZodFunction = class extends ZodType {
3013
3189
  return validatedFunc;
3014
3190
  }
3015
3191
  static create(args, returns, params) {
3016
- return new ZodFunction({
3192
+ return new _ZodFunction({
3017
3193
  args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3018
3194
  returns: returns || ZodUnknown.create(),
3019
3195
  typeName: ZodFirstPartyTypeKind.ZodFunction,
@@ -3069,7 +3245,11 @@ function createZodEnum(values, params) {
3069
3245
  ...processCreateParams(params)
3070
3246
  });
3071
3247
  }
3072
- var ZodEnum = class extends ZodType {
3248
+ var ZodEnum = class _ZodEnum extends ZodType {
3249
+ constructor() {
3250
+ super(...arguments);
3251
+ _ZodEnum_cache.set(this, void 0);
3252
+ }
3073
3253
  _parse(input) {
3074
3254
  if (typeof input.data !== "string") {
3075
3255
  const ctx = this._getOrReturnCtx(input);
@@ -3081,7 +3261,10 @@ var ZodEnum = class extends ZodType {
3081
3261
  });
3082
3262
  return INVALID;
3083
3263
  }
3084
- if (this._def.values.indexOf(input.data) === -1) {
3264
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
3265
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
3266
+ }
3267
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3085
3268
  const ctx = this._getOrReturnCtx(input);
3086
3269
  const expectedValues = this._def.values;
3087
3270
  addIssueToContext(ctx, {
@@ -3117,15 +3300,26 @@ var ZodEnum = class extends ZodType {
3117
3300
  }
3118
3301
  return enumValues;
3119
3302
  }
3120
- extract(values) {
3121
- return ZodEnum.create(values);
3303
+ extract(values, newDef = this._def) {
3304
+ return _ZodEnum.create(values, {
3305
+ ...this._def,
3306
+ ...newDef
3307
+ });
3122
3308
  }
3123
- exclude(values) {
3124
- return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
3309
+ exclude(values, newDef = this._def) {
3310
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3311
+ ...this._def,
3312
+ ...newDef
3313
+ });
3125
3314
  }
3126
3315
  };
3316
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3127
3317
  ZodEnum.create = createZodEnum;
3128
3318
  var ZodNativeEnum = class extends ZodType {
3319
+ constructor() {
3320
+ super(...arguments);
3321
+ _ZodNativeEnum_cache.set(this, void 0);
3322
+ }
3129
3323
  _parse(input) {
3130
3324
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3131
3325
  const ctx = this._getOrReturnCtx(input);
@@ -3138,7 +3332,10 @@ var ZodNativeEnum = class extends ZodType {
3138
3332
  });
3139
3333
  return INVALID;
3140
3334
  }
3141
- if (nativeEnumValues.indexOf(input.data) === -1) {
3335
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
3336
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
3337
+ }
3338
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3142
3339
  const expectedValues = util.objectValues(nativeEnumValues);
3143
3340
  addIssueToContext(ctx, {
3144
3341
  received: ctx.data,
@@ -3153,6 +3350,7 @@ var ZodNativeEnum = class extends ZodType {
3153
3350
  return this._def.values;
3154
3351
  }
3155
3352
  };
3353
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3156
3354
  ZodNativeEnum.create = (values, params) => {
3157
3355
  return new ZodNativeEnum({
3158
3356
  values,
@@ -3200,24 +3398,6 @@ var ZodEffects = class extends ZodType {
3200
3398
  _parse(input) {
3201
3399
  const { status, ctx } = this._processInputParams(input);
3202
3400
  const effect = this._def.effect || null;
3203
- if (effect.type === "preprocess") {
3204
- const processed = effect.transform(ctx.data);
3205
- if (ctx.common.async) {
3206
- return Promise.resolve(processed).then((processed2) => {
3207
- return this._def.schema._parseAsync({
3208
- data: processed2,
3209
- path: ctx.path,
3210
- parent: ctx
3211
- });
3212
- });
3213
- } else {
3214
- return this._def.schema._parseSync({
3215
- data: processed,
3216
- path: ctx.path,
3217
- parent: ctx
3218
- });
3219
- }
3220
- }
3221
3401
  const checkCtx = {
3222
3402
  addIssue: (arg) => {
3223
3403
  addIssueToContext(ctx, arg);
@@ -3232,6 +3412,42 @@ var ZodEffects = class extends ZodType {
3232
3412
  }
3233
3413
  };
3234
3414
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3415
+ if (effect.type === "preprocess") {
3416
+ const processed = effect.transform(ctx.data, checkCtx);
3417
+ if (ctx.common.async) {
3418
+ return Promise.resolve(processed).then(async (processed2) => {
3419
+ if (status.value === "aborted")
3420
+ return INVALID;
3421
+ const result = await this._def.schema._parseAsync({
3422
+ data: processed2,
3423
+ path: ctx.path,
3424
+ parent: ctx
3425
+ });
3426
+ if (result.status === "aborted")
3427
+ return INVALID;
3428
+ if (result.status === "dirty")
3429
+ return DIRTY(result.value);
3430
+ if (status.value === "dirty")
3431
+ return DIRTY(result.value);
3432
+ return result;
3433
+ });
3434
+ } else {
3435
+ if (status.value === "aborted")
3436
+ return INVALID;
3437
+ const result = this._def.schema._parseSync({
3438
+ data: processed,
3439
+ path: ctx.path,
3440
+ parent: ctx
3441
+ });
3442
+ if (result.status === "aborted")
3443
+ return INVALID;
3444
+ if (result.status === "dirty")
3445
+ return DIRTY(result.value);
3446
+ if (status.value === "dirty")
3447
+ return DIRTY(result.value);
3448
+ return result;
3449
+ }
3450
+ }
3235
3451
  if (effect.type === "refinement") {
3236
3452
  const executeRefinement = (acc) => {
3237
3453
  const result = effect.refinement(acc, checkCtx);
@@ -3460,7 +3676,7 @@ var ZodBranded = class extends ZodType {
3460
3676
  return this._def.type;
3461
3677
  }
3462
3678
  };
3463
- var ZodPipeline = class extends ZodType {
3679
+ var ZodPipeline = class _ZodPipeline extends ZodType {
3464
3680
  _parse(input) {
3465
3681
  const { status, ctx } = this._processInputParams(input);
3466
3682
  if (ctx.common.async) {
@@ -3508,14 +3724,36 @@ var ZodPipeline = class extends ZodType {
3508
3724
  }
3509
3725
  }
3510
3726
  static create(a, b) {
3511
- return new ZodPipeline({
3727
+ return new _ZodPipeline({
3512
3728
  in: a,
3513
3729
  out: b,
3514
3730
  typeName: ZodFirstPartyTypeKind.ZodPipeline
3515
3731
  });
3516
3732
  }
3517
3733
  };
3518
- var custom = (check, params = {}, fatal) => {
3734
+ var ZodReadonly = class extends ZodType {
3735
+ _parse(input) {
3736
+ const result = this._def.innerType._parse(input);
3737
+ const freeze = (data) => {
3738
+ if (isValid(data)) {
3739
+ data.value = Object.freeze(data.value);
3740
+ }
3741
+ return data;
3742
+ };
3743
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
3744
+ }
3745
+ unwrap() {
3746
+ return this._def.innerType;
3747
+ }
3748
+ };
3749
+ ZodReadonly.create = (type, params) => {
3750
+ return new ZodReadonly({
3751
+ innerType: type,
3752
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
3753
+ ...processCreateParams(params)
3754
+ });
3755
+ };
3756
+ function custom(check, params = {}, fatal) {
3519
3757
  if (check)
3520
3758
  return ZodAny.create().superRefine((data, ctx) => {
3521
3759
  var _a, _b;
@@ -3527,7 +3765,7 @@ var custom = (check, params = {}, fatal) => {
3527
3765
  }
3528
3766
  });
3529
3767
  return ZodAny.create();
3530
- };
3768
+ }
3531
3769
  var late = {
3532
3770
  object: ZodObject.lazycreate
3533
3771
  };
@@ -3568,6 +3806,7 @@ var ZodFirstPartyTypeKind;
3568
3806
  ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
3569
3807
  ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
3570
3808
  ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
3809
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
3571
3810
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
3572
3811
  var instanceOfType = (cls, params = {
3573
3812
  message: `Input not instance of ${cls.name}`
@@ -3645,6 +3884,7 @@ var z = /* @__PURE__ */ Object.freeze({
3645
3884
  ZodParsedType,
3646
3885
  getParsedType,
3647
3886
  ZodType,
3887
+ datetimeRegex,
3648
3888
  ZodString,
3649
3889
  ZodNumber,
3650
3890
  ZodBigInt,
@@ -3682,6 +3922,7 @@ var z = /* @__PURE__ */ Object.freeze({
3682
3922
  BRAND,
3683
3923
  ZodBranded,
3684
3924
  ZodPipeline,
3925
+ ZodReadonly,
3685
3926
  custom,
3686
3927
  Schema: ZodType,
3687
3928
  ZodSchema: ZodType,
@@ -4009,6 +4250,27 @@ var connectionSchema = z.object({
4009
4250
  partner_org_id: z.string()
4010
4251
  });
4011
4252
 
4253
+ // lib/tradingPartners/models/CompanyRelationshipUpsertBody.ts
4254
+ var companyRelationshipUpsertBodySchema = z.object({
4255
+ supplierId: z.number(),
4256
+ retailerId: z.number(),
4257
+ catalogId: z.number(),
4258
+ active: z.boolean(),
4259
+ applicationType: z.array(z.enum(["ASSORTMENT", "ITEM-XREF"])).default([])
4260
+ });
4261
+
4262
+ // lib/tradingPartners/models/ItemPartner.ts
4263
+ var itemPartnerSchema = z.object({
4264
+ itemPartnerId: z.number(),
4265
+ retailerId: z.number(),
4266
+ supplierId: z.number(),
4267
+ catalogId: z.number(),
4268
+ isActive: z.number(),
4269
+ createdDate: z.string(),
4270
+ modifiedDate: z.string(),
4271
+ applications: z.array(z.enum(["ASSORTMENT", "ITEM-XREF"]))
4272
+ });
4273
+
4012
4274
  // lib/tradingPartners/models/TradingPartnerAccessByCompanyId.ts
4013
4275
  var tradingPartnerAccessByCompanyIdSchema = z.object({
4014
4276
  companyId: z.number(),
@@ -4029,8 +4291,41 @@ function createTradingPartnerAccessApi(client) {
4029
4291
  }).json();
4030
4292
  return tradingPartnerAccessByCompanyIdSchema.parse(data);
4031
4293
  }
4294
+ async function upsertRelationship(data) {
4295
+ return await client.post(`${BASE_URL4}/upsert-relationship`, { json: data }).json();
4296
+ }
4297
+ async function upsertHierarchy(data) {
4298
+ await client.post(`${BASE_URL4}/upsert-hierarchy`, { json: data }).json();
4299
+ }
4032
4300
  return {
4033
- getAllTradingPartners
4301
+ getAllTradingPartners,
4302
+ upsertRelationship,
4303
+ upsertHierarchy
4304
+ };
4305
+ }
4306
+
4307
+ // lib/tradingPartnerSettings/models/RetailerTradingPartnerStages.ts
4308
+ var retailerTradingPartnerStages = z.array(
4309
+ z.enum([
4310
+ "Core",
4311
+ "Core Plus",
4312
+ "Core Advanced",
4313
+ "Enriched",
4314
+ "Standard Requirements"
4315
+ ])
4316
+ );
4317
+
4318
+ // lib/tradingPartnerSettings/index.ts
4319
+ var BASE_URL5 = "trading-partner-settings";
4320
+ function createTradingPartnerSettingsApi(client) {
4321
+ async function getRetailerStages(signal) {
4322
+ const data = await client.get(`${BASE_URL5}/stages/retailer-configured`, {
4323
+ signal
4324
+ }).json();
4325
+ return retailerTradingPartnerStages.parse(data);
4326
+ }
4327
+ return {
4328
+ getRetailerStages
4034
4329
  };
4035
4330
  }
4036
4331
 
@@ -4056,35 +4351,30 @@ var itemCategoriesSearchSchema = z.object({
4056
4351
  data: z.array(itemCategorySchema)
4057
4352
  });
4058
4353
 
4059
- // lib/categories/models/Hierarchy.ts
4354
+ // lib/categories/models/ItemHierarchyResponse.ts
4060
4355
  var baseHierarchySchema = z.object({
4061
4356
  id: z.string(),
4062
4357
  name: z.string().nullish(),
4063
4358
  description: z.string().nullish(),
4064
4359
  type: z.string().nullish()
4065
4360
  });
4066
- var hierarchySchema = baseHierarchySchema.extend(
4067
- {
4068
- child: z.lazy(() => hierarchySchema).nullable()
4069
- }
4070
- );
4071
-
4072
- // lib/categories/models/ItemHierarchy.ts
4073
- var itemHierarchySchema = z.object({
4074
- itemId: z.string(),
4075
- hierarchies: z.array(hierarchySchema)
4361
+ var hierarchySchema = baseHierarchySchema.extend({
4362
+ child: z.lazy(() => hierarchySchema).nullable()
4076
4363
  });
4077
-
4078
- // lib/categories/models/ItemHierarchyResponse.ts
4079
4364
  var itemHierarchyResponseSchema = z.object({
4080
- itemHierarchies: z.array(itemHierarchySchema)
4365
+ itemHierarchies: z.array(
4366
+ z.object({
4367
+ itemId: z.string(),
4368
+ hierarchies: z.array(hierarchySchema)
4369
+ })
4370
+ )
4081
4371
  });
4082
4372
 
4083
4373
  // lib/categories/index.ts
4084
- var BASE_URL5 = "categories";
4374
+ var BASE_URL6 = "categories";
4085
4375
  function createCategoriesApi(client) {
4086
4376
  async function getCatalogs(params, signal) {
4087
- const data = await client.get(`${BASE_URL5}/search-category`, {
4377
+ const data = await client.get(`${BASE_URL6}/search-category`, {
4088
4378
  searchParams: { ...params, type: "CATALOG" },
4089
4379
  signal
4090
4380
  }).json();
@@ -4104,7 +4394,7 @@ function createCategoriesApi(client) {
4104
4394
  if (params?.orgId) {
4105
4395
  searchParams.orgId = params.orgId;
4106
4396
  }
4107
- const data = await client.get(`${BASE_URL5}/search-category`, {
4397
+ const data = await client.get(`${BASE_URL6}/search-category`, {
4108
4398
  searchParams,
4109
4399
  signal,
4110
4400
  timeout: false
@@ -4122,17 +4412,22 @@ function createCategoriesApi(client) {
4122
4412
  if (params?.orgId) {
4123
4413
  searchParams.orgId = params.orgId;
4124
4414
  }
4125
- const data = await client.get(`${BASE_URL5}/search-category`, {
4415
+ const data = await client.get(`${BASE_URL6}/search-category`, {
4126
4416
  searchParams,
4127
4417
  signal
4128
4418
  }).json();
4129
4419
  return itemCategoriesSearchSchema.parse(data);
4130
4420
  }
4131
4421
  async function getItemHierarchy(itemIds) {
4132
- const data = await client.post(`${BASE_URL5}/item-hierarchy`, { json: { itemIds } }).json();
4422
+ const data = await client.post(`${BASE_URL6}/item-hierarchy`, { json: { itemIds } }).json();
4133
4423
  return itemHierarchyResponseSchema.parse(data);
4134
4424
  }
4135
- return { getCatalogs, getProductCodes, getSelectionCodes, getItemHierarchy };
4425
+ return {
4426
+ getCatalogs,
4427
+ getProductCodes,
4428
+ getSelectionCodes,
4429
+ getItemHierarchy
4430
+ };
4136
4431
  }
4137
4432
 
4138
4433
  // lib/attributes/models/AttributeMetaData.ts
@@ -4290,31 +4585,31 @@ var attributeValidValuesSchema = z.object({
4290
4585
  });
4291
4586
 
4292
4587
  // lib/attributes/index.ts
4293
- var BASE_URL6 = "attributes";
4588
+ var BASE_URL7 = "attributes";
4294
4589
  function createAttributesApi(client) {
4295
4590
  async function getAllAttributes(signal) {
4296
- const data = await client.get(`${BASE_URL6}`, { signal }).json();
4591
+ const data = await client.get(`${BASE_URL7}`, { signal }).json();
4297
4592
  return z.array(attributeMetaDataSchema).parse(data);
4298
4593
  }
4299
4594
  async function getAllAttributesByCompany(params, signal) {
4300
- const data = await client.get(`${BASE_URL6}/company`, {
4595
+ const data = await client.get(`${BASE_URL7}/company`, {
4301
4596
  searchParams: params,
4302
4597
  signal
4303
4598
  }).json();
4304
4599
  return attributesByCompanySchema.parse(data);
4305
4600
  }
4306
4601
  async function getAttributesExtensiveInfo(signal) {
4307
- const data = await client.get(`${BASE_URL6}/registry/editui`, { signal }).json();
4602
+ const data = await client.get(`${BASE_URL7}/registry/editui`, { signal }).json();
4308
4603
  return z.array(attributeDefinitionSchema).parse(data);
4309
4604
  }
4310
4605
  async function getAttributeValidValues(attributeDbName, signal) {
4311
- const data = await client.get(`${BASE_URL6}/registry/attribute/${attributeDbName}/values`, {
4606
+ const data = await client.get(`${BASE_URL7}/registry/attribute/${attributeDbName}/values`, {
4312
4607
  signal
4313
4608
  }).json();
4314
4609
  return z.array(attributeValidValuesSchema).parse(data);
4315
4610
  }
4316
4611
  async function getCompanyInterestedAttributes(params, signal) {
4317
- const data = await client.get(`${BASE_URL6}/company/interested-attributes`, {
4612
+ const data = await client.get(`${BASE_URL7}/company/interested-attributes`, {
4318
4613
  searchParams: params,
4319
4614
  signal
4320
4615
  }).json();
@@ -4336,10 +4631,10 @@ var localeSchema = z.object({
4336
4631
  });
4337
4632
 
4338
4633
  // lib/locale/index.ts
4339
- var BASE_URL7 = "locale";
4634
+ var BASE_URL8 = "locale";
4340
4635
  function createLocaleApi(client) {
4341
4636
  async function getLocale(signal) {
4342
- const data = await client.get(`${BASE_URL7}`, { signal }).json();
4637
+ const data = await client.get(`${BASE_URL8}`, { signal }).json();
4343
4638
  return z.array(localeSchema).parse(data);
4344
4639
  }
4345
4640
  return {
@@ -4369,10 +4664,10 @@ var spreadsheetTemplateSchema = z.object({
4369
4664
  });
4370
4665
 
4371
4666
  // lib/spreadsheetTemplate/index.ts
4372
- var BASE_URL8 = "templates";
4667
+ var BASE_URL9 = "templates";
4373
4668
  function createSpreadsheetTemplateApi(client) {
4374
4669
  async function getTemplates(params, signal) {
4375
- const data = await client.get(`${BASE_URL8}`, { searchParams: params, signal }).json();
4670
+ const data = await client.get(`${BASE_URL9}`, { searchParams: params, signal }).json();
4376
4671
  return z.array(spreadsheetTemplateSchema).parse(data);
4377
4672
  }
4378
4673
  return {
@@ -4474,10 +4769,10 @@ var userAccountSchema = z.object({
4474
4769
  });
4475
4770
 
4476
4771
  // lib/whoami/index.ts
4477
- var BASE_URL9 = "whoami";
4772
+ var BASE_URL10 = "whoami";
4478
4773
  function createWhoAmIApi(client) {
4479
4774
  async function whoAmI(signal) {
4480
- const data = await client.get(`${BASE_URL9}`, { signal }).json();
4775
+ const data = await client.get(`${BASE_URL10}`, { signal }).json();
4481
4776
  return userAccountSchema.parse(data);
4482
4777
  }
4483
4778
  return {
@@ -4486,10 +4781,10 @@ function createWhoAmIApi(client) {
4486
4781
  }
4487
4782
 
4488
4783
  // lib/companyFeatures/index.ts
4489
- var BASE_URL10 = "feature";
4784
+ var BASE_URL11 = "feature";
4490
4785
  function createCompanyFeaturesApi(client) {
4491
4786
  async function checkIfStageItemSetupIsEnabled(signal) {
4492
- const data = await client.get(`${BASE_URL10}/isphaseditemsetupenabled`, {
4787
+ const data = await client.get(`${BASE_URL11}/isphaseditemsetupenabled`, {
4493
4788
  signal
4494
4789
  }).json();
4495
4790
  return z.boolean().parse(data);
@@ -4500,16 +4795,16 @@ function createCompanyFeaturesApi(client) {
4500
4795
  }
4501
4796
 
4502
4797
  // lib/featureFlags/index.ts
4503
- var BASE_URL11 = "feature-flag";
4798
+ var BASE_URL12 = "feature-flag";
4504
4799
  function createFeatureFlagsApi(client) {
4505
4800
  async function checkEnableItemsApiEndpointsForImports(signal) {
4506
- const data = await client.get(`${BASE_URL11}/enable-items-api-endpoints-for-imports/`, {
4801
+ const data = await client.get(`${BASE_URL12}/enable-items-api-endpoints-for-imports/`, {
4507
4802
  signal
4508
4803
  }).json();
4509
4804
  return z.boolean().parse(data);
4510
4805
  }
4511
4806
  async function checkEnableItemsLevelMSIS(signal) {
4512
- const data = await client.get(`${BASE_URL11}/enable-item-level-msis/`, {
4807
+ const data = await client.get(`${BASE_URL12}/enable-item-level-msis/`, {
4513
4808
  signal
4514
4809
  }).json();
4515
4810
  return z.boolean().parse(data);
@@ -4520,7 +4815,7 @@ function createFeatureFlagsApi(client) {
4520
4815
  };
4521
4816
  }
4522
4817
 
4523
- // lib/items/models/ItemHeader.ts
4818
+ // lib/items/v1/models/ItemHeader.ts
4524
4819
  var itemHeaderSchema = z.object({
4525
4820
  status: z.string().optional(),
4526
4821
  catalogName: z.string(),
@@ -4536,7 +4831,7 @@ var itemHeaderSchema = z.object({
4536
4831
  itemInfoId: z.string()
4537
4832
  });
4538
4833
 
4539
- // lib/items/models/PhaseEnum.ts
4834
+ // lib/items/v1/models/PhaseEnum.ts
4540
4835
  var phaseEnumSchema = z.enum([
4541
4836
  "CORE",
4542
4837
  "CORE_PLUS",
@@ -4545,7 +4840,7 @@ var phaseEnumSchema = z.enum([
4545
4840
  "STANDARD_REQUIREMENTS"
4546
4841
  ]);
4547
4842
 
4548
- // lib/items/models/TradingPartnerStage.ts
4843
+ // lib/items/v1/models/TradingPartnerStage.ts
4549
4844
  var tradingPartnerStageSchema = z.object({
4550
4845
  companyId: z.number(),
4551
4846
  companyName: z.string(),
@@ -4553,7 +4848,7 @@ var tradingPartnerStageSchema = z.object({
4553
4848
  isValid: z.boolean()
4554
4849
  });
4555
4850
 
4556
- // lib/items/models/ItemMap.ts
4851
+ // lib/items/v1/models/ItemMap.ts
4557
4852
  var itemMapSchema = z.object({
4558
4853
  rn: z.number().optional(),
4559
4854
  iteminfoid: z.string(),
@@ -4576,13 +4871,13 @@ var itemMapSchema = z.object({
4576
4871
  productsizedescription: z.array(z.string()).nullish()
4577
4872
  }).passthrough();
4578
4873
 
4579
- // lib/items/models/ItemTable.ts
4874
+ // lib/items/v1/models/ItemTable.ts
4580
4875
  var itemTableSchema = z.object({
4581
4876
  headers: itemHeaderSchema,
4582
4877
  itemMaps: z.array(itemMapSchema)
4583
4878
  });
4584
4879
 
4585
- // lib/items/models/ItemSearchView.ts
4880
+ // lib/items/v1/models/ItemSearchView.ts
4586
4881
  var itemSearchViewSchema = z.object({
4587
4882
  itemTable: itemTableSchema,
4588
4883
  hasNext: z.boolean(),
@@ -4678,7 +4973,7 @@ var companyBriefByOrgSchema = z.object({
4678
4973
  dc4Id: z.number()
4679
4974
  });
4680
4975
 
4681
- // lib/items/models/AttributeDetail.ts
4976
+ // lib/items/v1/models/AttributeDetail.ts
4682
4977
  var attributeDetailSchema = z.object({
4683
4978
  type: attrDatatypeNameEnumSchema,
4684
4979
  name: z.string(),
@@ -4688,23 +4983,23 @@ var attributeDetailSchema = z.object({
4688
4983
  orderBy: z.number().or(z.string()).nullish()
4689
4984
  });
4690
4985
 
4691
- // lib/items/models/CategoryEnum.ts
4986
+ // lib/items/v1/models/CategoryEnum.ts
4692
4987
  var categoryEnumSchema = z.enum([
4693
- "AKA",
4988
+ "ALIAS",
4694
4989
  "CATALOG",
4695
4990
  "EXPORT",
4696
- "LABEL",
4697
4991
  "LEGACY_PRODUCT_TYPE",
4698
4992
  "PRODUCT_CLASSIFICATION",
4699
4993
  "PRODUCT_CODE",
4700
4994
  "SELECTION_CODE",
4995
+ "TAG",
4701
4996
  "TAXONOMY_ROOT"
4702
4997
  ]);
4703
4998
 
4704
- // lib/items/models/ComponentDetails.ts
4999
+ // lib/items/v1/models/ComponentDetails.ts
4705
5000
  var componentDetailsSchema = z.object({
4706
5001
  itemInfoId: z.number(),
4707
- description: z.string(),
5002
+ description: z.string().nullish(),
4708
5003
  saleable: z.boolean(),
4709
5004
  valid: z.boolean(),
4710
5005
  uniqueCriteria: z.array(
@@ -4715,43 +5010,43 @@ var componentDetailsSchema = z.object({
4715
5010
  )
4716
5011
  });
4717
5012
 
4718
- // lib/items/models/RepeatableGroup.ts
5013
+ // lib/items/v1/models/RepeatableGroup.ts
4719
5014
  var repeatableGroupSchema = z.object({
4720
5015
  repeatableGroupId: z.string(),
4721
5016
  repeatableNumber: z.number()
4722
5017
  });
4723
5018
 
4724
- // lib/items/models/GroupedAttributeList.ts
5019
+ // lib/items/v1/models/GroupedAttributeList.ts
4725
5020
  var groupedAttributeListSchema = z.object({
4726
5021
  type: z.string(),
4727
5022
  rows: z.array(z.array(attributeDetailSchema)),
4728
5023
  repeatableGroups: z.array(repeatableGroupSchema)
4729
5024
  });
4730
5025
 
4731
- // lib/items/models/GroupedAttributes.ts
5026
+ // lib/items/v1/models/GroupedAttributes.ts
4732
5027
  var groupedAttributesSchema = z.object({
4733
5028
  type: z.string(),
4734
5029
  attributes: z.array(attributeDetailSchema),
4735
5030
  attributeGroups: z.array(groupedAttributeListSchema)
4736
5031
  });
4737
5032
 
4738
- // lib/items/models/HierarchyCategory.ts
5033
+ // lib/items/v1/models/HierarchyCategory.ts
4739
5034
  var hierarchyCategorySchema = z.object({
4740
5035
  name: z.string(),
4741
5036
  description: z.string().nullish(),
4742
5037
  id: z.number(),
4743
- companyId: z.number(),
5038
+ companyId: z.number().nullish(),
4744
5039
  type: categoryEnumSchema
4745
5040
  });
4746
5041
 
4747
- // lib/items/models/HierarchyDetails.ts
5042
+ // lib/items/v1/models/HierarchyDetails.ts
4748
5043
  var hierarchyDetailsSchema = z.object({
4749
5044
  catalogs: z.array(hierarchyCategorySchema),
4750
5045
  selectionCodes: z.array(hierarchyCategorySchema),
4751
5046
  productCodes: z.array(hierarchyCategorySchema)
4752
5047
  });
4753
5048
 
4754
- // lib/items/models/PackComponentItemInfo.ts
5049
+ // lib/items/v1/models/PackComponentItemInfo.ts
4755
5050
  var packComponentItemInfoSchema = z.object({
4756
5051
  companyid: z.number(),
4757
5052
  createddate: z.number(),
@@ -4765,7 +5060,7 @@ var packComponentItemInfoSchema = z.object({
4765
5060
  attributes: z.record(z.string(), z.string().or(z.array(z.string())))
4766
5061
  });
4767
5062
 
4768
- // lib/items/models/ItemPrice.ts
5063
+ // lib/items/v1/models/ItemPrice.ts
4769
5064
  var itemPriceSchema = z.object({
4770
5065
  amount: z.number(),
4771
5066
  currency: z.string(),
@@ -4789,13 +5084,13 @@ var itemPriceSchema = z.object({
4789
5084
  priceUnitQuantityUOM: z.string().nullish()
4790
5085
  });
4791
5086
 
4792
- // lib/items/models/PackComponentDetails.ts
5087
+ // lib/items/v1/models/PackComponentDetails.ts
4793
5088
  var packComponentDetailsSchema = z.object({
4794
5089
  itemInfo: packComponentItemInfoSchema,
4795
5090
  itemPrices: z.array(itemPriceSchema)
4796
5091
  });
4797
5092
 
4798
- // lib/items/models/GroupedItem.ts
5093
+ // lib/items/v1/models/GroupedItem.ts
4799
5094
  var groupedItemSchema = z.object({
4800
5095
  iteminfoid: z.number(),
4801
5096
  companyid: z.number(),
@@ -4811,12 +5106,12 @@ var groupedItemSchema = z.object({
4811
5106
  locales: z.array(z.string())
4812
5107
  });
4813
5108
 
4814
- // lib/items/models/ItemDetailView.ts
5109
+ // lib/items/v1/models/ItemDetailView.ts
4815
5110
  var itemDetailViewSchema = z.object({
4816
5111
  item: groupedItemSchema
4817
5112
  });
4818
5113
 
4819
- // lib/items/models/Bulb.ts
5114
+ // lib/items/v1/models/Bulb.ts
4820
5115
  var bulbSchema = z.object({
4821
5116
  iteminfoid: z.number(),
4822
5117
  id: z.number(),
@@ -4834,14 +5129,14 @@ var bulbSchema = z.object({
4834
5129
  threewaybulb: z.string()
4835
5130
  });
4836
5131
 
4837
- // lib/items/models/PackComponent.ts
5132
+ // lib/items/v1/models/PackComponent.ts
4838
5133
  var packComponentSchema = z.object({
4839
5134
  itemInfoId: z.number().nullish(),
4840
5135
  attributes: z.record(z.string(), z.string().or(z.array(z.string()))),
4841
5136
  prices: z.array(itemPriceSchema)
4842
5137
  });
4843
5138
 
4844
- // lib/items/models/MediaItem.ts
5139
+ // lib/items/v1/models/MediaItem.ts
4845
5140
  var mediaItemSchema = z.object({
4846
5141
  id: z.number(),
4847
5142
  iteminfoid: z.number(),
@@ -4862,7 +5157,7 @@ var mediaItemSchema = z.object({
4862
5157
  thumbnailflag: z.string().nullish()
4863
5158
  });
4864
5159
 
4865
- // lib/items/models/ItemDetail.ts
5160
+ // lib/items/v1/models/ItemDetail.ts
4866
5161
  var itemDetailSchema = z.object({
4867
5162
  attributes: z.record(z.string(), z.any()),
4868
5163
  clusters: z.record(
@@ -4882,13 +5177,13 @@ var itemDetailSchema = z.object({
4882
5177
  packs: z.array(packComponentSchema)
4883
5178
  });
4884
5179
 
4885
- // lib/items/models/SpsItemIdResponse.ts
5180
+ // lib/items/v1/models/SpsItemIdResponse.ts
4886
5181
  var spsItemIdResponseSchema = z.object({
4887
5182
  id: z.string(),
4888
5183
  ref: z.string()
4889
5184
  });
4890
5185
 
4891
- // lib/items/models/ItemOrgStatus.ts
5186
+ // lib/items/v1/models/ItemOrgStatus.ts
4892
5187
  var itemOrgStatusSchema = z.object({
4893
5188
  org: z.object({
4894
5189
  ref: z.string(),
@@ -4899,52 +5194,64 @@ var itemOrgStatusSchema = z.object({
4899
5194
  validForRelationship: z.boolean()
4900
5195
  });
4901
5196
 
4902
- // lib/items/models/ItemStatus.ts
5197
+ // lib/items/v1/models/ItemStatus.ts
4903
5198
  var itemStatusSchema = z.object({
4904
5199
  itemId: z.string(),
4905
5200
  itemOrgStatuses: z.array(itemOrgStatusSchema)
4906
5201
  });
4907
5202
 
4908
- // lib/items/models/ItemStatusResponse.ts
5203
+ // lib/items/v1/models/ItemStatusResponse.ts
4909
5204
  var itemStatusResponseSchema = z.object({
4910
5205
  itemStatuses: z.array(itemStatusSchema)
4911
5206
  });
4912
5207
 
4913
- // lib/items/index.ts
4914
- var BASE_URL12 = "items";
5208
+ // lib/items/v1/index.ts
5209
+ var BASE_URL13 = "items";
4915
5210
  function createItemsApi(client) {
5211
+ function createQueryParameterString(params = {}) {
5212
+ const searchParams = new URLSearchParams();
5213
+ const { limit, offset, applicationType, url } = params ?? {};
5214
+ if (limit)
5215
+ searchParams.append("limit", limit.toString());
5216
+ if (offset)
5217
+ searchParams.append("offset", offset.toString());
5218
+ if (applicationType)
5219
+ searchParams.append("application", applicationType);
5220
+ const queryParameterString = searchParams.toString();
5221
+ return url ? `${queryParameterString}&${url}` : queryParameterString;
5222
+ }
4916
5223
  async function searchItems(params, signal) {
4917
- const searchParams = params ? `limit=${params.limit}&offset=${params.offset}` + (params.url ? `&${params.url}` : "") : void 0;
4918
- const data = await client.get(`${BASE_URL12}`, { searchParams, signal }).json();
5224
+ const searchParams = createQueryParameterString(params);
5225
+ const data = await client.get(`${BASE_URL13}`, { searchParams, signal }).json();
4919
5226
  return itemSearchViewSchema.parse(data);
4920
5227
  }
4921
5228
  async function getItem(itemId, locale = "en-US", signal) {
4922
- const data = await client.get(`${BASE_URL12}/${itemId}`, { searchParams: { locale }, signal }).json();
5229
+ const data = await client.get(`${BASE_URL13}/${itemId}`, { searchParams: { locale }, signal }).json();
4923
5230
  return itemDetailViewSchema.parse(data);
4924
5231
  }
4925
5232
  async function updateItem(itemId, item) {
4926
- await client.put(`${BASE_URL12}/details/${itemId}`, { json: { ...item } }).json();
5233
+ await client.put(`${BASE_URL13}/details/${itemId}`, { json: { ...item } }).json();
4927
5234
  }
4928
5235
  async function deleteItem(itemId) {
4929
- await client.delete(`${BASE_URL12}/${itemId}`);
5236
+ await client.delete(`${BASE_URL13}/${itemId}`);
4930
5237
  }
4931
5238
  async function deleteItems(itemIds) {
4932
5239
  const params = new URLSearchParams();
4933
5240
  itemIds.forEach((id) => {
4934
5241
  params.append("items", id);
4935
5242
  });
4936
- await client.delete(`${BASE_URL12}`, { searchParams: params });
5243
+ await client.delete(`${BASE_URL13}`, { searchParams: params });
4937
5244
  }
4938
5245
  async function getItemInfoId(spsItemId, signal) {
4939
- const data = await client.get(`${BASE_URL12}/${spsItemId}/itemInfoId`, { signal }).json();
5246
+ const data = await client.get(`${BASE_URL13}/${spsItemId}/itemInfoId`, { signal }).json();
4940
5247
  return z.number().parse(data);
4941
5248
  }
4942
5249
  async function getSpsItemId(itemInfoId, signal) {
4943
- const data = await client.get(`${BASE_URL12}/${itemInfoId}/spsItemId`, { signal }).json();
5250
+ const data = await client.get(`${BASE_URL13}/${itemInfoId}/spsItemId`, { signal }).json();
4944
5251
  return spsItemIdResponseSchema.parse(data);
4945
5252
  }
4946
5253
  async function getItemStatus(itemIds) {
4947
- const data = await client.post(`${BASE_URL12}/status`, { json: { itemIds } }).json();
5254
+ const data = await client.post(`${BASE_URL13}/status`, { json: { itemIds } }).json();
4948
5255
  return itemStatusResponseSchema.parse(data);
4949
5256
  }
4950
5257
  return {
@@ -4959,11 +5266,85 @@ function createItemsApi(client) {
4959
5266
  };
4960
5267
  }
4961
5268
 
5269
+ // lib/items/v2/models/Stage.ts
5270
+ var stageSchema = z.enum([
5271
+ "CORE",
5272
+ "CORE_PLUS",
5273
+ "CORE_ADVANCED",
5274
+ "ENRICHED"
5275
+ ]);
5276
+
5277
+ // lib/items/v2/models/OrgSummary.ts
5278
+ var orgSummarySchema = z.object({
5279
+ ref: z.string(),
5280
+ id: z.string(),
5281
+ name: z.string()
5282
+ });
5283
+
5284
+ // lib/items/v2/models/ItemOrgStageDetails.ts
5285
+ var itemOrgStageDetailsSchema = z.object({
5286
+ /**
5287
+ * When called as retailer, the vendor, else when vendor, the retailer.
5288
+ * */
5289
+ orgSummary: orgSummarySchema,
5290
+ /**
5291
+ * The company id of the retailer or vendor used for matching ItemOrgStageDetails to TradingPartnerStage for ErrorService
5292
+ */
5293
+ companyId: z.number().nullish(),
5294
+ /**
5295
+ * "Standard Requirements" (null) UNLESS the retailer of the item is MSIS Enabled
5296
+ * OTHERWISE the retailer default Stage UNLESS there's a currently active vendor-specific Stage defined
5297
+ * OTHERWISE the trading partnership Stage UNLESS there's a currently active Item Level override defined
5298
+ * OTHERWISE the item level override */
5299
+ stage: stageSchema.nullish(),
5300
+ /**
5301
+ * If the item is valid for the active stage. Note that for "Standard Requirements" or
5302
+ * "Enriched" this cam come directly from the item_doc table, but anything else requires validation
5303
+ */
5304
+ isValid: z.boolean(),
5305
+ /**
5306
+ * Not null if there's an item level policy override for this trading partnership
5307
+ */
5308
+ itemPolicyId: z.string().nullish(),
5309
+ /**
5310
+ * Start date for the Item level Stage if applicable
5311
+ */
5312
+ startDate: z.number().pipe(z.coerce.date()).nullish(),
5313
+ /**
5314
+ * End date for the Item level Stage if applicable
5315
+ */
5316
+ endDate: z.number().pipe(z.coerce.date()).nullish()
5317
+ });
5318
+
5319
+ // lib/items/v2/models/ItemStatusV2.ts
5320
+ var itemStatusV2Schema = z.object({
5321
+ itemId: z.string(),
5322
+ mostRestrictiveRetailerStage: stageSchema.nullable(),
5323
+ itemOrgStageDetails: z.array(itemOrgStageDetailsSchema)
5324
+ });
5325
+
5326
+ // lib/items/v2/models/ItemStatusV2Response.ts
5327
+ var itemStatusV2ResponseSchema = z.object({
5328
+ itemStatuses: z.array(itemStatusV2Schema)
5329
+ });
5330
+
5331
+ // lib/items/v2/index.ts
5332
+ var BASE_URL14 = "v2/items";
5333
+ function createItemsApiV2(client) {
5334
+ async function getItemStatus(itemIds) {
5335
+ const data = await client.post(`${BASE_URL14}/status`, { json: { itemIds } }).json();
5336
+ return itemStatusV2ResponseSchema.parse(data);
5337
+ }
5338
+ return {
5339
+ getItemStatus
5340
+ };
5341
+ }
5342
+
4962
5343
  // lib/errors/index.ts
4963
- var BASE_URL13 = "errors";
5344
+ var BASE_URL15 = "errors";
4964
5345
  function createErrorsApi(client) {
4965
5346
  async function getInvalidItemErrorDetails(itemInfoId, signal) {
4966
- const data = await client.get(`${BASE_URL13}/items/${itemInfoId}`, {
5347
+ const data = await client.get(`${BASE_URL15}/items/${itemInfoId}`, {
4967
5348
  signal
4968
5349
  }).json();
4969
5350
  return itemErrorDetailsResultSchema.parse(data);
@@ -4974,10 +5355,10 @@ function createErrorsApi(client) {
4974
5355
  }
4975
5356
 
4976
5357
  // lib/uniqueCriteria/index.ts
4977
- var BASE_URL14 = "uniquecriteria";
5358
+ var BASE_URL16 = "uniquecriteria";
4978
5359
  function createUniqueCriteriaApi(client) {
4979
5360
  async function getUniqueCriteriaByOrg(params, signal) {
4980
- const data = await client.get(`${BASE_URL14}/org`, {
5361
+ const data = await client.get(`${BASE_URL16}/org`, {
4981
5362
  searchParams: params,
4982
5363
  signal
4983
5364
  }).json();
@@ -4987,10 +5368,10 @@ function createUniqueCriteriaApi(client) {
4987
5368
  }
4988
5369
 
4989
5370
  // lib/companies/index.ts
4990
- var BASE_URL15 = "companys";
5371
+ var BASE_URL17 = "companys";
4991
5372
  function createCompaniesApi(client) {
4992
5373
  async function getCompanyBriefInfoByOrg(params, signal) {
4993
- const data = await client.get(`${BASE_URL15}/brief`, {
5374
+ const data = await client.get(`${BASE_URL17}/brief`, {
4994
5375
  searchParams: params,
4995
5376
  signal
4996
5377
  }).json();
@@ -5011,10 +5392,13 @@ function createCompaniesApi(client) {
5011
5392
  createFeatureFlagsApi,
5012
5393
  createImportsApi,
5013
5394
  createItemsApi,
5395
+ createItemsApiV2,
5014
5396
  createLocaleApi,
5015
5397
  createProductTypesApi,
5016
5398
  createSpreadsheetTemplateApi,
5017
5399
  createTradingPartnerAccessApi,
5400
+ createTradingPartnerSettingsApi,
5018
5401
  createUniqueCriteriaApi,
5019
- createWhoAmIApi
5402
+ createWhoAmIApi,
5403
+ envSchema
5020
5404
  });