@spscommerce/asst-api 0.2.0 → 1.0.1

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,10 +41,12 @@ __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
51
  createWhoAmIApi: () => createWhoAmIApi,
50
52
  envSchema: () => envSchema
@@ -54,7 +56,7 @@ module.exports = __toCommonJS(lib_exports);
54
56
  // lib/asstClient.ts
55
57
  var import_ky_universal = __toESM(require("ky-universal"), 1);
56
58
 
57
- // ../../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
58
60
  var util;
59
61
  (function(util2) {
60
62
  util2.assertEqual = (val) => val;
@@ -208,7 +210,7 @@ var quotelessJson = (obj) => {
208
210
  const json = JSON.stringify(obj, null, 2);
209
211
  return json.replace(/"([^"]+)":/g, "$1:");
210
212
  };
211
- var ZodError = class extends Error {
213
+ var ZodError = class _ZodError extends Error {
212
214
  constructor(issues) {
213
215
  super();
214
216
  this.issues = [];
@@ -266,6 +268,11 @@ var ZodError = class extends Error {
266
268
  processError(this);
267
269
  return fieldErrors;
268
270
  }
271
+ static assert(value) {
272
+ if (!(value instanceof _ZodError)) {
273
+ throw new Error(`Not a ZodError: ${value}`);
274
+ }
275
+ }
269
276
  toString() {
270
277
  return this.message;
271
278
  }
@@ -408,6 +415,13 @@ var makeIssue = (params) => {
408
415
  ...issueData,
409
416
  path: fullPath
410
417
  };
418
+ if (issueData.message !== void 0) {
419
+ return {
420
+ ...issueData,
421
+ path: fullPath,
422
+ message: issueData.message
423
+ };
424
+ }
411
425
  let errorMessage = "";
412
426
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
413
427
  for (const map of maps) {
@@ -416,11 +430,12 @@ var makeIssue = (params) => {
416
430
  return {
417
431
  ...issueData,
418
432
  path: fullPath,
419
- message: issueData.message || errorMessage
433
+ message: errorMessage
420
434
  };
421
435
  };
422
436
  var EMPTY_PATH = [];
423
437
  function addIssueToContext(ctx, issueData) {
438
+ const overrideMap = getErrorMap();
424
439
  const issue = makeIssue({
425
440
  issueData,
426
441
  data: ctx.data,
@@ -428,14 +443,14 @@ function addIssueToContext(ctx, issueData) {
428
443
  errorMaps: [
429
444
  ctx.common.contextualErrorMap,
430
445
  ctx.schemaErrorMap,
431
- getErrorMap(),
432
- errorMap
446
+ overrideMap,
447
+ overrideMap === errorMap ? void 0 : errorMap
433
448
  // then global default map
434
449
  ].filter((x) => !!x)
435
450
  });
436
451
  ctx.common.issues.push(issue);
437
452
  }
438
- var ParseStatus = class {
453
+ var ParseStatus = class _ParseStatus {
439
454
  constructor() {
440
455
  this.value = "valid";
441
456
  }
@@ -461,12 +476,14 @@ var ParseStatus = class {
461
476
  static async mergeObjectAsync(status, pairs) {
462
477
  const syncPairs = [];
463
478
  for (const pair of pairs) {
479
+ const key = await pair.key;
480
+ const value = await pair.value;
464
481
  syncPairs.push({
465
- key: await pair.key,
466
- value: await pair.value
482
+ key,
483
+ value
467
484
  });
468
485
  }
469
- return ParseStatus.mergeObjectSync(status, syncPairs);
486
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
470
487
  }
471
488
  static mergeObjectSync(status, pairs) {
472
489
  const finalObject = {};
@@ -480,7 +497,7 @@ var ParseStatus = class {
480
497
  status.dirty();
481
498
  if (value.status === "dirty")
482
499
  status.dirty();
483
- if (typeof value.value !== "undefined" || pair.alwaysSet) {
500
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
484
501
  finalObject[key.value] = value.value;
485
502
  }
486
503
  }
@@ -496,11 +513,29 @@ var isAborted = (x) => x.status === "aborted";
496
513
  var isDirty = (x) => x.status === "dirty";
497
514
  var isValid = (x) => x.status === "valid";
498
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
+ }
499
532
  var errorUtil;
500
533
  (function(errorUtil2) {
501
534
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
502
535
  errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
503
536
  })(errorUtil || (errorUtil = {}));
537
+ var _ZodEnum_cache;
538
+ var _ZodNativeEnum_cache;
504
539
  var ParseInputLazyPath = class {
505
540
  constructor(parent, value, path, key) {
506
541
  this._cachedPath = [];
@@ -549,12 +584,17 @@ function processCreateParams(params) {
549
584
  if (errorMap2)
550
585
  return { errorMap: errorMap2, description };
551
586
  const customMap = (iss, ctx) => {
552
- if (iss.code !== "invalid_type")
553
- 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
+ }
554
592
  if (typeof ctx.data === "undefined") {
555
- 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 };
556
594
  }
557
- 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 };
558
598
  };
559
599
  return { errorMap: customMap, description };
560
600
  }
@@ -583,6 +623,7 @@ var ZodType = class {
583
623
  this.catch = this.catch.bind(this);
584
624
  this.describe = this.describe.bind(this);
585
625
  this.pipe = this.pipe.bind(this);
626
+ this.readonly = this.readonly.bind(this);
586
627
  this.isNullable = this.isNullable.bind(this);
587
628
  this.isOptional = this.isOptional.bind(this);
588
629
  }
@@ -790,6 +831,9 @@ var ZodType = class {
790
831
  pipe(target) {
791
832
  return ZodPipeline.create(this, target);
792
833
  }
834
+ readonly() {
835
+ return ZodReadonly.create(this);
836
+ }
793
837
  isOptional() {
794
838
  return this.safeParse(void 0).success;
795
839
  }
@@ -798,34 +842,40 @@ var ZodType = class {
798
842
  }
799
843
  };
800
844
  var cuidRegex = /^c[^\s-]{8,}$/i;
801
- var cuid2Regex = /^[a-z][a-z0-9]*$/;
802
- var ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/;
803
- 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;
804
- 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,})+))$/;
805
- var emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u;
806
- 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])$/;
807
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})))$/;
808
- 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`;
809
860
  if (args.precision) {
810
- if (args.offset) {
811
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
812
- } else {
813
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
814
- }
815
- } else if (args.precision === 0) {
816
- if (args.offset) {
817
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
818
- } else {
819
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
820
- }
821
- } else {
822
- if (args.offset) {
823
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
824
- } else {
825
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
826
- }
861
+ regex = `${regex}\\.\\d{${args.precision}}`;
862
+ } else if (args.precision == null) {
863
+ regex = `${regex}(\\.\\d+)?`;
827
864
  }
828
- };
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
+ }
829
879
  function isValidIP(ip, version) {
830
880
  if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
831
881
  return true;
@@ -835,28 +885,7 @@ function isValidIP(ip, version) {
835
885
  }
836
886
  return false;
837
887
  }
838
- var ZodString = class extends ZodType {
839
- constructor() {
840
- super(...arguments);
841
- this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
842
- validation,
843
- code: ZodIssueCode.invalid_string,
844
- ...errorUtil.errToObj(message)
845
- });
846
- this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
847
- this.trim = () => new ZodString({
848
- ...this._def,
849
- checks: [...this._def.checks, { kind: "trim" }]
850
- });
851
- this.toLowerCase = () => new ZodString({
852
- ...this._def,
853
- checks: [...this._def.checks, { kind: "toLowerCase" }]
854
- });
855
- this.toUpperCase = () => new ZodString({
856
- ...this._def,
857
- checks: [...this._def.checks, { kind: "toUpperCase" }]
858
- });
859
- }
888
+ var ZodString = class _ZodString extends ZodType {
860
889
  _parse(input) {
861
890
  if (this._def.coerce) {
862
891
  input.data = String(input.data);
@@ -864,15 +893,11 @@ var ZodString = class extends ZodType {
864
893
  const parsedType = this._getType(input);
865
894
  if (parsedType !== ZodParsedType.string) {
866
895
  const ctx2 = this._getOrReturnCtx(input);
867
- addIssueToContext(
868
- ctx2,
869
- {
870
- code: ZodIssueCode.invalid_type,
871
- expected: ZodParsedType.string,
872
- received: ctx2.parsedType
873
- }
874
- //
875
- );
896
+ addIssueToContext(ctx2, {
897
+ code: ZodIssueCode.invalid_type,
898
+ expected: ZodParsedType.string,
899
+ received: ctx2.parsedType
900
+ });
876
901
  return INVALID;
877
902
  }
878
903
  const status = new ParseStatus();
@@ -941,6 +966,9 @@ var ZodString = class extends ZodType {
941
966
  status.dirty();
942
967
  }
943
968
  } else if (check.kind === "emoji") {
969
+ if (!emojiRegex) {
970
+ emojiRegex = new RegExp(_emojiRegex, "u");
971
+ }
944
972
  if (!emojiRegex.test(input.data)) {
945
973
  ctx = this._getOrReturnCtx(input, ctx);
946
974
  addIssueToContext(ctx, {
@@ -960,6 +988,16 @@ var ZodString = class extends ZodType {
960
988
  });
961
989
  status.dirty();
962
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
+ }
963
1001
  } else if (check.kind === "cuid") {
964
1002
  if (!cuidRegex.test(input.data)) {
965
1003
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1061,6 +1099,38 @@ var ZodString = class extends ZodType {
1061
1099
  });
1062
1100
  status.dirty();
1063
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
+ }
1064
1134
  } else if (check.kind === "ip") {
1065
1135
  if (!isValidIP(input.data, check.version)) {
1066
1136
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1071,14 +1141,31 @@ var ZodString = class extends ZodType {
1071
1141
  });
1072
1142
  status.dirty();
1073
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
+ }
1074
1154
  } else {
1075
1155
  util.assertNever(check);
1076
1156
  }
1077
1157
  }
1078
1158
  return { status: status.value, value: input.data };
1079
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
+ }
1080
1167
  _addCheck(check) {
1081
- return new ZodString({
1168
+ return new _ZodString({
1082
1169
  ...this._def,
1083
1170
  checks: [...this._def.checks, check]
1084
1171
  });
@@ -1095,6 +1182,9 @@ var ZodString = class extends ZodType {
1095
1182
  uuid(message) {
1096
1183
  return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1097
1184
  }
1185
+ nanoid(message) {
1186
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1187
+ }
1098
1188
  cuid(message) {
1099
1189
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1100
1190
  }
@@ -1104,16 +1194,20 @@ var ZodString = class extends ZodType {
1104
1194
  ulid(message) {
1105
1195
  return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1106
1196
  }
1197
+ base64(message) {
1198
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1199
+ }
1107
1200
  ip(options) {
1108
1201
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1109
1202
  }
1110
1203
  datetime(options) {
1111
- var _a;
1204
+ var _a, _b;
1112
1205
  if (typeof options === "string") {
1113
1206
  return this._addCheck({
1114
1207
  kind: "datetime",
1115
1208
  precision: null,
1116
1209
  offset: false,
1210
+ local: false,
1117
1211
  message: options
1118
1212
  });
1119
1213
  }
@@ -1121,9 +1215,30 @@ var ZodString = class extends ZodType {
1121
1215
  kind: "datetime",
1122
1216
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1123
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,
1124
1236
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1125
1237
  });
1126
1238
  }
1239
+ duration(message) {
1240
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1241
+ }
1127
1242
  regex(regex, message) {
1128
1243
  return this._addCheck({
1129
1244
  kind: "regex",
@@ -1174,9 +1289,43 @@ var ZodString = class extends ZodType {
1174
1289
  ...errorUtil.errToObj(message)
1175
1290
  });
1176
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
+ }
1177
1317
  get isDatetime() {
1178
1318
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
1179
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
+ }
1180
1329
  get isEmail() {
1181
1330
  return !!this._def.checks.find((ch) => ch.kind === "email");
1182
1331
  }
@@ -1189,6 +1338,9 @@ var ZodString = class extends ZodType {
1189
1338
  get isUUID() {
1190
1339
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
1191
1340
  }
1341
+ get isNANOID() {
1342
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1343
+ }
1192
1344
  get isCUID() {
1193
1345
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
1194
1346
  }
@@ -1201,6 +1353,9 @@ var ZodString = class extends ZodType {
1201
1353
  get isIP() {
1202
1354
  return !!this._def.checks.find((ch) => ch.kind === "ip");
1203
1355
  }
1356
+ get isBase64() {
1357
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1358
+ }
1204
1359
  get minLength() {
1205
1360
  let min = null;
1206
1361
  for (const ch of this._def.checks) {
@@ -1239,7 +1394,7 @@ function floatSafeRemainder(val, step) {
1239
1394
  const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
1240
1395
  return valInt % stepInt / Math.pow(10, decCount);
1241
1396
  }
1242
- var ZodNumber = class extends ZodType {
1397
+ var ZodNumber = class _ZodNumber extends ZodType {
1243
1398
  constructor() {
1244
1399
  super(...arguments);
1245
1400
  this.min = this.gte;
@@ -1340,7 +1495,7 @@ var ZodNumber = class extends ZodType {
1340
1495
  return this.setLimit("max", value, false, errorUtil.toString(message));
1341
1496
  }
1342
1497
  setLimit(kind, value, inclusive, message) {
1343
- return new ZodNumber({
1498
+ return new _ZodNumber({
1344
1499
  ...this._def,
1345
1500
  checks: [
1346
1501
  ...this._def.checks,
@@ -1354,7 +1509,7 @@ var ZodNumber = class extends ZodType {
1354
1509
  });
1355
1510
  }
1356
1511
  _addCheck(check) {
1357
- return new ZodNumber({
1512
+ return new _ZodNumber({
1358
1513
  ...this._def,
1359
1514
  checks: [...this._def.checks, check]
1360
1515
  });
@@ -1470,7 +1625,7 @@ ZodNumber.create = (params) => {
1470
1625
  ...processCreateParams(params)
1471
1626
  });
1472
1627
  };
1473
- var ZodBigInt = class extends ZodType {
1628
+ var ZodBigInt = class _ZodBigInt extends ZodType {
1474
1629
  constructor() {
1475
1630
  super(...arguments);
1476
1631
  this.min = this.gte;
@@ -1548,7 +1703,7 @@ var ZodBigInt = class extends ZodType {
1548
1703
  return this.setLimit("max", value, false, errorUtil.toString(message));
1549
1704
  }
1550
1705
  setLimit(kind, value, inclusive, message) {
1551
- return new ZodBigInt({
1706
+ return new _ZodBigInt({
1552
1707
  ...this._def,
1553
1708
  checks: [
1554
1709
  ...this._def.checks,
@@ -1562,7 +1717,7 @@ var ZodBigInt = class extends ZodType {
1562
1717
  });
1563
1718
  }
1564
1719
  _addCheck(check) {
1565
- return new ZodBigInt({
1720
+ return new _ZodBigInt({
1566
1721
  ...this._def,
1567
1722
  checks: [...this._def.checks, check]
1568
1723
  });
@@ -1661,7 +1816,7 @@ ZodBoolean.create = (params) => {
1661
1816
  ...processCreateParams(params)
1662
1817
  });
1663
1818
  };
1664
- var ZodDate = class extends ZodType {
1819
+ var ZodDate = class _ZodDate extends ZodType {
1665
1820
  _parse(input) {
1666
1821
  if (this._def.coerce) {
1667
1822
  input.data = new Date(input.data);
@@ -1722,7 +1877,7 @@ var ZodDate = class extends ZodType {
1722
1877
  };
1723
1878
  }
1724
1879
  _addCheck(check) {
1725
- return new ZodDate({
1880
+ return new _ZodDate({
1726
1881
  ...this._def,
1727
1882
  checks: [...this._def.checks, check]
1728
1883
  });
@@ -1901,7 +2056,7 @@ ZodVoid.create = (params) => {
1901
2056
  ...processCreateParams(params)
1902
2057
  });
1903
2058
  };
1904
- var ZodArray = class extends ZodType {
2059
+ var ZodArray = class _ZodArray extends ZodType {
1905
2060
  _parse(input) {
1906
2061
  const { ctx, status } = this._processInputParams(input);
1907
2062
  const def = this._def;
@@ -1971,19 +2126,19 @@ var ZodArray = class extends ZodType {
1971
2126
  return this._def.type;
1972
2127
  }
1973
2128
  min(minLength, message) {
1974
- return new ZodArray({
2129
+ return new _ZodArray({
1975
2130
  ...this._def,
1976
2131
  minLength: { value: minLength, message: errorUtil.toString(message) }
1977
2132
  });
1978
2133
  }
1979
2134
  max(maxLength, message) {
1980
- return new ZodArray({
2135
+ return new _ZodArray({
1981
2136
  ...this._def,
1982
2137
  maxLength: { value: maxLength, message: errorUtil.toString(message) }
1983
2138
  });
1984
2139
  }
1985
2140
  length(len, message) {
1986
- return new ZodArray({
2141
+ return new _ZodArray({
1987
2142
  ...this._def,
1988
2143
  exactLength: { value: len, message: errorUtil.toString(message) }
1989
2144
  });
@@ -2028,7 +2183,7 @@ function deepPartialify(schema) {
2028
2183
  return schema;
2029
2184
  }
2030
2185
  }
2031
- var ZodObject = class extends ZodType {
2186
+ var ZodObject = class _ZodObject extends ZodType {
2032
2187
  constructor() {
2033
2188
  super(...arguments);
2034
2189
  this._cached = null;
@@ -2114,9 +2269,10 @@ var ZodObject = class extends ZodType {
2114
2269
  const syncPairs = [];
2115
2270
  for (const pair of pairs) {
2116
2271
  const key = await pair.key;
2272
+ const value = await pair.value;
2117
2273
  syncPairs.push({
2118
2274
  key,
2119
- value: await pair.value,
2275
+ value,
2120
2276
  alwaysSet: pair.alwaysSet
2121
2277
  });
2122
2278
  }
@@ -2133,7 +2289,7 @@ var ZodObject = class extends ZodType {
2133
2289
  }
2134
2290
  strict(message) {
2135
2291
  errorUtil.errToObj;
2136
- return new ZodObject({
2292
+ return new _ZodObject({
2137
2293
  ...this._def,
2138
2294
  unknownKeys: "strict",
2139
2295
  ...message !== void 0 ? {
@@ -2152,13 +2308,13 @@ var ZodObject = class extends ZodType {
2152
2308
  });
2153
2309
  }
2154
2310
  strip() {
2155
- return new ZodObject({
2311
+ return new _ZodObject({
2156
2312
  ...this._def,
2157
2313
  unknownKeys: "strip"
2158
2314
  });
2159
2315
  }
2160
2316
  passthrough() {
2161
- return new ZodObject({
2317
+ return new _ZodObject({
2162
2318
  ...this._def,
2163
2319
  unknownKeys: "passthrough"
2164
2320
  });
@@ -2181,7 +2337,7 @@ var ZodObject = class extends ZodType {
2181
2337
  // }) as any;
2182
2338
  // };
2183
2339
  extend(augmentation) {
2184
- return new ZodObject({
2340
+ return new _ZodObject({
2185
2341
  ...this._def,
2186
2342
  shape: () => ({
2187
2343
  ...this._def.shape(),
@@ -2195,7 +2351,7 @@ var ZodObject = class extends ZodType {
2195
2351
  * upgrade if you are experiencing issues.
2196
2352
  */
2197
2353
  merge(merging) {
2198
- const merged = new ZodObject({
2354
+ const merged = new _ZodObject({
2199
2355
  unknownKeys: merging._def.unknownKeys,
2200
2356
  catchall: merging._def.catchall,
2201
2357
  shape: () => ({
@@ -2266,7 +2422,7 @@ var ZodObject = class extends ZodType {
2266
2422
  // return merged;
2267
2423
  // }
2268
2424
  catchall(index) {
2269
- return new ZodObject({
2425
+ return new _ZodObject({
2270
2426
  ...this._def,
2271
2427
  catchall: index
2272
2428
  });
@@ -2278,7 +2434,7 @@ var ZodObject = class extends ZodType {
2278
2434
  shape[key] = this.shape[key];
2279
2435
  }
2280
2436
  });
2281
- return new ZodObject({
2437
+ return new _ZodObject({
2282
2438
  ...this._def,
2283
2439
  shape: () => shape
2284
2440
  });
@@ -2290,7 +2446,7 @@ var ZodObject = class extends ZodType {
2290
2446
  shape[key] = this.shape[key];
2291
2447
  }
2292
2448
  });
2293
- return new ZodObject({
2449
+ return new _ZodObject({
2294
2450
  ...this._def,
2295
2451
  shape: () => shape
2296
2452
  });
@@ -2311,7 +2467,7 @@ var ZodObject = class extends ZodType {
2311
2467
  newShape[key] = fieldSchema.optional();
2312
2468
  }
2313
2469
  });
2314
- return new ZodObject({
2470
+ return new _ZodObject({
2315
2471
  ...this._def,
2316
2472
  shape: () => newShape
2317
2473
  });
@@ -2330,7 +2486,7 @@ var ZodObject = class extends ZodType {
2330
2486
  newShape[key] = newField;
2331
2487
  }
2332
2488
  });
2333
- return new ZodObject({
2489
+ return new _ZodObject({
2334
2490
  ...this._def,
2335
2491
  shape: () => newShape
2336
2492
  });
@@ -2467,18 +2623,28 @@ var getDiscriminator = (type) => {
2467
2623
  } else if (type instanceof ZodEnum) {
2468
2624
  return type.options;
2469
2625
  } else if (type instanceof ZodNativeEnum) {
2470
- return Object.keys(type.enum);
2626
+ return util.objectValues(type.enum);
2471
2627
  } else if (type instanceof ZodDefault) {
2472
2628
  return getDiscriminator(type._def.innerType);
2473
2629
  } else if (type instanceof ZodUndefined) {
2474
2630
  return [void 0];
2475
2631
  } else if (type instanceof ZodNull) {
2476
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);
2477
2643
  } else {
2478
- return null;
2644
+ return [];
2479
2645
  }
2480
2646
  };
2481
- var ZodDiscriminatedUnion = class extends ZodType {
2647
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2482
2648
  _parse(input) {
2483
2649
  const { ctx } = this._processInputParams(input);
2484
2650
  if (ctx.parsedType !== ZodParsedType.object) {
@@ -2535,7 +2701,7 @@ var ZodDiscriminatedUnion = class extends ZodType {
2535
2701
  const optionsMap = /* @__PURE__ */ new Map();
2536
2702
  for (const type of options) {
2537
2703
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2538
- if (!discriminatorValues) {
2704
+ if (!discriminatorValues.length) {
2539
2705
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2540
2706
  }
2541
2707
  for (const value of discriminatorValues) {
@@ -2545,7 +2711,7 @@ var ZodDiscriminatedUnion = class extends ZodType {
2545
2711
  optionsMap.set(value, type);
2546
2712
  }
2547
2713
  }
2548
- return new ZodDiscriminatedUnion({
2714
+ return new _ZodDiscriminatedUnion({
2549
2715
  typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2550
2716
  discriminator,
2551
2717
  options,
@@ -2645,7 +2811,7 @@ ZodIntersection.create = (left, right, params) => {
2645
2811
  ...processCreateParams(params)
2646
2812
  });
2647
2813
  };
2648
- var ZodTuple = class extends ZodType {
2814
+ var ZodTuple = class _ZodTuple extends ZodType {
2649
2815
  _parse(input) {
2650
2816
  const { status, ctx } = this._processInputParams(input);
2651
2817
  if (ctx.parsedType !== ZodParsedType.array) {
@@ -2695,7 +2861,7 @@ var ZodTuple = class extends ZodType {
2695
2861
  return this._def.items;
2696
2862
  }
2697
2863
  rest(rest) {
2698
- return new ZodTuple({
2864
+ return new _ZodTuple({
2699
2865
  ...this._def,
2700
2866
  rest
2701
2867
  });
@@ -2712,7 +2878,7 @@ ZodTuple.create = (schemas, params) => {
2712
2878
  ...processCreateParams(params)
2713
2879
  });
2714
2880
  };
2715
- var ZodRecord = class extends ZodType {
2881
+ var ZodRecord = class _ZodRecord extends ZodType {
2716
2882
  get keySchema() {
2717
2883
  return this._def.keyType;
2718
2884
  }
@@ -2735,7 +2901,8 @@ var ZodRecord = class extends ZodType {
2735
2901
  for (const key in ctx.data) {
2736
2902
  pairs.push({
2737
2903
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2738
- 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
2739
2906
  });
2740
2907
  }
2741
2908
  if (ctx.common.async) {
@@ -2749,14 +2916,14 @@ var ZodRecord = class extends ZodType {
2749
2916
  }
2750
2917
  static create(first, second, third) {
2751
2918
  if (second instanceof ZodType) {
2752
- return new ZodRecord({
2919
+ return new _ZodRecord({
2753
2920
  keyType: first,
2754
2921
  valueType: second,
2755
2922
  typeName: ZodFirstPartyTypeKind.ZodRecord,
2756
2923
  ...processCreateParams(third)
2757
2924
  });
2758
2925
  }
2759
- return new ZodRecord({
2926
+ return new _ZodRecord({
2760
2927
  keyType: ZodString.create(),
2761
2928
  valueType: first,
2762
2929
  typeName: ZodFirstPartyTypeKind.ZodRecord,
@@ -2765,6 +2932,12 @@ var ZodRecord = class extends ZodType {
2765
2932
  }
2766
2933
  };
2767
2934
  var ZodMap = class extends ZodType {
2935
+ get keySchema() {
2936
+ return this._def.keyType;
2937
+ }
2938
+ get valueSchema() {
2939
+ return this._def.valueType;
2940
+ }
2768
2941
  _parse(input) {
2769
2942
  const { status, ctx } = this._processInputParams(input);
2770
2943
  if (ctx.parsedType !== ZodParsedType.map) {
@@ -2824,7 +2997,7 @@ ZodMap.create = (keyType, valueType, params) => {
2824
2997
  ...processCreateParams(params)
2825
2998
  });
2826
2999
  };
2827
- var ZodSet = class extends ZodType {
3000
+ var ZodSet = class _ZodSet extends ZodType {
2828
3001
  _parse(input) {
2829
3002
  const { status, ctx } = this._processInputParams(input);
2830
3003
  if (ctx.parsedType !== ZodParsedType.set) {
@@ -2882,13 +3055,13 @@ var ZodSet = class extends ZodType {
2882
3055
  }
2883
3056
  }
2884
3057
  min(minSize, message) {
2885
- return new ZodSet({
3058
+ return new _ZodSet({
2886
3059
  ...this._def,
2887
3060
  minSize: { value: minSize, message: errorUtil.toString(message) }
2888
3061
  });
2889
3062
  }
2890
3063
  max(maxSize, message) {
2891
- return new ZodSet({
3064
+ return new _ZodSet({
2892
3065
  ...this._def,
2893
3066
  maxSize: { value: maxSize, message: errorUtil.toString(message) }
2894
3067
  });
@@ -2909,7 +3082,7 @@ ZodSet.create = (valueType, params) => {
2909
3082
  ...processCreateParams(params)
2910
3083
  });
2911
3084
  };
2912
- var ZodFunction = class extends ZodType {
3085
+ var ZodFunction = class _ZodFunction extends ZodType {
2913
3086
  constructor() {
2914
3087
  super(...arguments);
2915
3088
  this.validate = this.implement;
@@ -2959,27 +3132,29 @@ var ZodFunction = class extends ZodType {
2959
3132
  const params = { errorMap: ctx.common.contextualErrorMap };
2960
3133
  const fn = ctx.data;
2961
3134
  if (this._def.returns instanceof ZodPromise) {
2962
- return OK(async (...args) => {
3135
+ const me = this;
3136
+ return OK(async function(...args) {
2963
3137
  const error = new ZodError([]);
2964
- const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => {
3138
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
2965
3139
  error.addIssue(makeArgsIssue(args, e));
2966
3140
  throw error;
2967
3141
  });
2968
- const result = await fn(...parsedArgs);
2969
- 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) => {
2970
3144
  error.addIssue(makeReturnsIssue(result, e));
2971
3145
  throw error;
2972
3146
  });
2973
3147
  return parsedReturns;
2974
3148
  });
2975
3149
  } else {
2976
- return OK((...args) => {
2977
- 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);
2978
3153
  if (!parsedArgs.success) {
2979
3154
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
2980
3155
  }
2981
- const result = fn(...parsedArgs.data);
2982
- 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);
2983
3158
  if (!parsedReturns.success) {
2984
3159
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
2985
3160
  }
@@ -2994,13 +3169,13 @@ var ZodFunction = class extends ZodType {
2994
3169
  return this._def.returns;
2995
3170
  }
2996
3171
  args(...items) {
2997
- return new ZodFunction({
3172
+ return new _ZodFunction({
2998
3173
  ...this._def,
2999
3174
  args: ZodTuple.create(items).rest(ZodUnknown.create())
3000
3175
  });
3001
3176
  }
3002
3177
  returns(returnType) {
3003
- return new ZodFunction({
3178
+ return new _ZodFunction({
3004
3179
  ...this._def,
3005
3180
  returns: returnType
3006
3181
  });
@@ -3014,7 +3189,7 @@ var ZodFunction = class extends ZodType {
3014
3189
  return validatedFunc;
3015
3190
  }
3016
3191
  static create(args, returns, params) {
3017
- return new ZodFunction({
3192
+ return new _ZodFunction({
3018
3193
  args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3019
3194
  returns: returns || ZodUnknown.create(),
3020
3195
  typeName: ZodFirstPartyTypeKind.ZodFunction,
@@ -3070,7 +3245,11 @@ function createZodEnum(values, params) {
3070
3245
  ...processCreateParams(params)
3071
3246
  });
3072
3247
  }
3073
- 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
+ }
3074
3253
  _parse(input) {
3075
3254
  if (typeof input.data !== "string") {
3076
3255
  const ctx = this._getOrReturnCtx(input);
@@ -3082,7 +3261,10 @@ var ZodEnum = class extends ZodType {
3082
3261
  });
3083
3262
  return INVALID;
3084
3263
  }
3085
- 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)) {
3086
3268
  const ctx = this._getOrReturnCtx(input);
3087
3269
  const expectedValues = this._def.values;
3088
3270
  addIssueToContext(ctx, {
@@ -3118,15 +3300,26 @@ var ZodEnum = class extends ZodType {
3118
3300
  }
3119
3301
  return enumValues;
3120
3302
  }
3121
- extract(values) {
3122
- return ZodEnum.create(values);
3303
+ extract(values, newDef = this._def) {
3304
+ return _ZodEnum.create(values, {
3305
+ ...this._def,
3306
+ ...newDef
3307
+ });
3123
3308
  }
3124
- exclude(values) {
3125
- 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
+ });
3126
3314
  }
3127
3315
  };
3316
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3128
3317
  ZodEnum.create = createZodEnum;
3129
3318
  var ZodNativeEnum = class extends ZodType {
3319
+ constructor() {
3320
+ super(...arguments);
3321
+ _ZodNativeEnum_cache.set(this, void 0);
3322
+ }
3130
3323
  _parse(input) {
3131
3324
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3132
3325
  const ctx = this._getOrReturnCtx(input);
@@ -3139,7 +3332,10 @@ var ZodNativeEnum = class extends ZodType {
3139
3332
  });
3140
3333
  return INVALID;
3141
3334
  }
3142
- 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)) {
3143
3339
  const expectedValues = util.objectValues(nativeEnumValues);
3144
3340
  addIssueToContext(ctx, {
3145
3341
  received: ctx.data,
@@ -3154,6 +3350,7 @@ var ZodNativeEnum = class extends ZodType {
3154
3350
  return this._def.values;
3155
3351
  }
3156
3352
  };
3353
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3157
3354
  ZodNativeEnum.create = (values, params) => {
3158
3355
  return new ZodNativeEnum({
3159
3356
  values,
@@ -3201,24 +3398,6 @@ var ZodEffects = class extends ZodType {
3201
3398
  _parse(input) {
3202
3399
  const { status, ctx } = this._processInputParams(input);
3203
3400
  const effect = this._def.effect || null;
3204
- if (effect.type === "preprocess") {
3205
- const processed = effect.transform(ctx.data);
3206
- if (ctx.common.async) {
3207
- return Promise.resolve(processed).then((processed2) => {
3208
- return this._def.schema._parseAsync({
3209
- data: processed2,
3210
- path: ctx.path,
3211
- parent: ctx
3212
- });
3213
- });
3214
- } else {
3215
- return this._def.schema._parseSync({
3216
- data: processed,
3217
- path: ctx.path,
3218
- parent: ctx
3219
- });
3220
- }
3221
- }
3222
3401
  const checkCtx = {
3223
3402
  addIssue: (arg) => {
3224
3403
  addIssueToContext(ctx, arg);
@@ -3233,6 +3412,42 @@ var ZodEffects = class extends ZodType {
3233
3412
  }
3234
3413
  };
3235
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
+ }
3236
3451
  if (effect.type === "refinement") {
3237
3452
  const executeRefinement = (acc) => {
3238
3453
  const result = effect.refinement(acc, checkCtx);
@@ -3461,7 +3676,7 @@ var ZodBranded = class extends ZodType {
3461
3676
  return this._def.type;
3462
3677
  }
3463
3678
  };
3464
- var ZodPipeline = class extends ZodType {
3679
+ var ZodPipeline = class _ZodPipeline extends ZodType {
3465
3680
  _parse(input) {
3466
3681
  const { status, ctx } = this._processInputParams(input);
3467
3682
  if (ctx.common.async) {
@@ -3509,14 +3724,36 @@ var ZodPipeline = class extends ZodType {
3509
3724
  }
3510
3725
  }
3511
3726
  static create(a, b) {
3512
- return new ZodPipeline({
3727
+ return new _ZodPipeline({
3513
3728
  in: a,
3514
3729
  out: b,
3515
3730
  typeName: ZodFirstPartyTypeKind.ZodPipeline
3516
3731
  });
3517
3732
  }
3518
3733
  };
3519
- 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) {
3520
3757
  if (check)
3521
3758
  return ZodAny.create().superRefine((data, ctx) => {
3522
3759
  var _a, _b;
@@ -3528,7 +3765,7 @@ var custom = (check, params = {}, fatal) => {
3528
3765
  }
3529
3766
  });
3530
3767
  return ZodAny.create();
3531
- };
3768
+ }
3532
3769
  var late = {
3533
3770
  object: ZodObject.lazycreate
3534
3771
  };
@@ -3569,6 +3806,7 @@ var ZodFirstPartyTypeKind;
3569
3806
  ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
3570
3807
  ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
3571
3808
  ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
3809
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
3572
3810
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
3573
3811
  var instanceOfType = (cls, params = {
3574
3812
  message: `Input not instance of ${cls.name}`
@@ -3646,6 +3884,7 @@ var z = /* @__PURE__ */ Object.freeze({
3646
3884
  ZodParsedType,
3647
3885
  getParsedType,
3648
3886
  ZodType,
3887
+ datetimeRegex,
3649
3888
  ZodString,
3650
3889
  ZodNumber,
3651
3890
  ZodBigInt,
@@ -3683,6 +3922,7 @@ var z = /* @__PURE__ */ Object.freeze({
3683
3922
  BRAND,
3684
3923
  ZodBranded,
3685
3924
  ZodPipeline,
3925
+ ZodReadonly,
3686
3926
  custom,
3687
3927
  Schema: ZodType,
3688
3928
  ZodSchema: ZodType,
@@ -4015,7 +4255,7 @@ var companyRelationshipUpsertBodySchema = z.object({
4015
4255
  supplierId: z.number(),
4016
4256
  retailerId: z.number(),
4017
4257
  catalogId: z.number(),
4018
- isActive: z.boolean(),
4258
+ active: z.boolean(),
4019
4259
  applicationType: z.array(z.enum(["ASSORTMENT", "ITEM-XREF"])).default([])
4020
4260
  });
4021
4261
 
@@ -4064,6 +4304,31 @@ function createTradingPartnerAccessApi(client) {
4064
4304
  };
4065
4305
  }
4066
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
4329
+ };
4330
+ }
4331
+
4067
4332
  // lib/categories/models/ItemCategory.ts
4068
4333
  var itemCategorySchema = z.object({
4069
4334
  categoryid: z.number(),
@@ -4086,35 +4351,30 @@ var itemCategoriesSearchSchema = z.object({
4086
4351
  data: z.array(itemCategorySchema)
4087
4352
  });
4088
4353
 
4089
- // lib/categories/models/Hierarchy.ts
4354
+ // lib/categories/models/ItemHierarchyResponse.ts
4090
4355
  var baseHierarchySchema = z.object({
4091
4356
  id: z.string(),
4092
4357
  name: z.string().nullish(),
4093
4358
  description: z.string().nullish(),
4094
4359
  type: z.string().nullish()
4095
4360
  });
4096
- var hierarchySchema = baseHierarchySchema.extend(
4097
- {
4098
- child: z.lazy(() => hierarchySchema).nullable()
4099
- }
4100
- );
4101
-
4102
- // lib/categories/models/ItemHierarchy.ts
4103
- var itemHierarchySchema = z.object({
4104
- itemId: z.string(),
4105
- hierarchies: z.array(hierarchySchema)
4361
+ var hierarchySchema = baseHierarchySchema.extend({
4362
+ child: z.lazy(() => hierarchySchema).nullable()
4106
4363
  });
4107
-
4108
- // lib/categories/models/ItemHierarchyResponse.ts
4109
4364
  var itemHierarchyResponseSchema = z.object({
4110
- itemHierarchies: z.array(itemHierarchySchema)
4365
+ itemHierarchies: z.array(
4366
+ z.object({
4367
+ itemId: z.string(),
4368
+ hierarchies: z.array(hierarchySchema)
4369
+ })
4370
+ )
4111
4371
  });
4112
4372
 
4113
4373
  // lib/categories/index.ts
4114
- var BASE_URL5 = "categories";
4374
+ var BASE_URL6 = "categories";
4115
4375
  function createCategoriesApi(client) {
4116
4376
  async function getCatalogs(params, signal) {
4117
- const data = await client.get(`${BASE_URL5}/search-category`, {
4377
+ const data = await client.get(`${BASE_URL6}/search-category`, {
4118
4378
  searchParams: { ...params, type: "CATALOG" },
4119
4379
  signal
4120
4380
  }).json();
@@ -4134,7 +4394,7 @@ function createCategoriesApi(client) {
4134
4394
  if (params?.orgId) {
4135
4395
  searchParams.orgId = params.orgId;
4136
4396
  }
4137
- const data = await client.get(`${BASE_URL5}/search-category`, {
4397
+ const data = await client.get(`${BASE_URL6}/search-category`, {
4138
4398
  searchParams,
4139
4399
  signal,
4140
4400
  timeout: false
@@ -4152,17 +4412,22 @@ function createCategoriesApi(client) {
4152
4412
  if (params?.orgId) {
4153
4413
  searchParams.orgId = params.orgId;
4154
4414
  }
4155
- const data = await client.get(`${BASE_URL5}/search-category`, {
4415
+ const data = await client.get(`${BASE_URL6}/search-category`, {
4156
4416
  searchParams,
4157
4417
  signal
4158
4418
  }).json();
4159
4419
  return itemCategoriesSearchSchema.parse(data);
4160
4420
  }
4161
4421
  async function getItemHierarchy(itemIds) {
4162
- 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();
4163
4423
  return itemHierarchyResponseSchema.parse(data);
4164
4424
  }
4165
- return { getCatalogs, getProductCodes, getSelectionCodes, getItemHierarchy };
4425
+ return {
4426
+ getCatalogs,
4427
+ getProductCodes,
4428
+ getSelectionCodes,
4429
+ getItemHierarchy
4430
+ };
4166
4431
  }
4167
4432
 
4168
4433
  // lib/attributes/models/AttributeMetaData.ts
@@ -4320,31 +4585,31 @@ var attributeValidValuesSchema = z.object({
4320
4585
  });
4321
4586
 
4322
4587
  // lib/attributes/index.ts
4323
- var BASE_URL6 = "attributes";
4588
+ var BASE_URL7 = "attributes";
4324
4589
  function createAttributesApi(client) {
4325
4590
  async function getAllAttributes(signal) {
4326
- const data = await client.get(`${BASE_URL6}`, { signal }).json();
4591
+ const data = await client.get(`${BASE_URL7}`, { signal }).json();
4327
4592
  return z.array(attributeMetaDataSchema).parse(data);
4328
4593
  }
4329
4594
  async function getAllAttributesByCompany(params, signal) {
4330
- const data = await client.get(`${BASE_URL6}/company`, {
4595
+ const data = await client.get(`${BASE_URL7}/company`, {
4331
4596
  searchParams: params,
4332
4597
  signal
4333
4598
  }).json();
4334
4599
  return attributesByCompanySchema.parse(data);
4335
4600
  }
4336
4601
  async function getAttributesExtensiveInfo(signal) {
4337
- const data = await client.get(`${BASE_URL6}/registry/editui`, { signal }).json();
4602
+ const data = await client.get(`${BASE_URL7}/registry/editui`, { signal }).json();
4338
4603
  return z.array(attributeDefinitionSchema).parse(data);
4339
4604
  }
4340
4605
  async function getAttributeValidValues(attributeDbName, signal) {
4341
- const data = await client.get(`${BASE_URL6}/registry/attribute/${attributeDbName}/values`, {
4606
+ const data = await client.get(`${BASE_URL7}/registry/attribute/${attributeDbName}/values`, {
4342
4607
  signal
4343
4608
  }).json();
4344
4609
  return z.array(attributeValidValuesSchema).parse(data);
4345
4610
  }
4346
4611
  async function getCompanyInterestedAttributes(params, signal) {
4347
- const data = await client.get(`${BASE_URL6}/company/interested-attributes`, {
4612
+ const data = await client.get(`${BASE_URL7}/company/interested-attributes`, {
4348
4613
  searchParams: params,
4349
4614
  signal
4350
4615
  }).json();
@@ -4366,10 +4631,10 @@ var localeSchema = z.object({
4366
4631
  });
4367
4632
 
4368
4633
  // lib/locale/index.ts
4369
- var BASE_URL7 = "locale";
4634
+ var BASE_URL8 = "locale";
4370
4635
  function createLocaleApi(client) {
4371
4636
  async function getLocale(signal) {
4372
- const data = await client.get(`${BASE_URL7}`, { signal }).json();
4637
+ const data = await client.get(`${BASE_URL8}`, { signal }).json();
4373
4638
  return z.array(localeSchema).parse(data);
4374
4639
  }
4375
4640
  return {
@@ -4399,10 +4664,10 @@ var spreadsheetTemplateSchema = z.object({
4399
4664
  });
4400
4665
 
4401
4666
  // lib/spreadsheetTemplate/index.ts
4402
- var BASE_URL8 = "templates";
4667
+ var BASE_URL9 = "templates";
4403
4668
  function createSpreadsheetTemplateApi(client) {
4404
4669
  async function getTemplates(params, signal) {
4405
- const data = await client.get(`${BASE_URL8}`, { searchParams: params, signal }).json();
4670
+ const data = await client.get(`${BASE_URL9}`, { searchParams: params, signal }).json();
4406
4671
  return z.array(spreadsheetTemplateSchema).parse(data);
4407
4672
  }
4408
4673
  return {
@@ -4504,10 +4769,10 @@ var userAccountSchema = z.object({
4504
4769
  });
4505
4770
 
4506
4771
  // lib/whoami/index.ts
4507
- var BASE_URL9 = "whoami";
4772
+ var BASE_URL10 = "whoami";
4508
4773
  function createWhoAmIApi(client) {
4509
4774
  async function whoAmI(signal) {
4510
- const data = await client.get(`${BASE_URL9}`, { signal }).json();
4775
+ const data = await client.get(`${BASE_URL10}`, { signal }).json();
4511
4776
  return userAccountSchema.parse(data);
4512
4777
  }
4513
4778
  return {
@@ -4516,10 +4781,10 @@ function createWhoAmIApi(client) {
4516
4781
  }
4517
4782
 
4518
4783
  // lib/companyFeatures/index.ts
4519
- var BASE_URL10 = "feature";
4784
+ var BASE_URL11 = "feature";
4520
4785
  function createCompanyFeaturesApi(client) {
4521
4786
  async function checkIfStageItemSetupIsEnabled(signal) {
4522
- const data = await client.get(`${BASE_URL10}/isphaseditemsetupenabled`, {
4787
+ const data = await client.get(`${BASE_URL11}/isphaseditemsetupenabled`, {
4523
4788
  signal
4524
4789
  }).json();
4525
4790
  return z.boolean().parse(data);
@@ -4530,27 +4795,20 @@ function createCompanyFeaturesApi(client) {
4530
4795
  }
4531
4796
 
4532
4797
  // lib/featureFlags/index.ts
4533
- var BASE_URL11 = "feature-flag";
4798
+ var BASE_URL12 = "feature-flag";
4534
4799
  function createFeatureFlagsApi(client) {
4535
- async function checkEnableItemsApiEndpointsForImports(signal) {
4536
- const data = await client.get(`${BASE_URL11}/enable-items-api-endpoints-for-imports/`, {
4537
- signal
4538
- }).json();
4539
- return z.boolean().parse(data);
4540
- }
4541
4800
  async function checkEnableItemsLevelMSIS(signal) {
4542
- const data = await client.get(`${BASE_URL11}/enable-item-level-msis/`, {
4801
+ const data = await client.get(`${BASE_URL12}/enable-item-level-msis/`, {
4543
4802
  signal
4544
4803
  }).json();
4545
4804
  return z.boolean().parse(data);
4546
4805
  }
4547
4806
  return {
4548
- checkEnableItemsApiEndpointsForImports,
4549
4807
  checkEnableItemsLevelMSIS
4550
4808
  };
4551
4809
  }
4552
4810
 
4553
- // lib/items/models/ItemHeader.ts
4811
+ // lib/items/v1/models/ItemHeader.ts
4554
4812
  var itemHeaderSchema = z.object({
4555
4813
  status: z.string().optional(),
4556
4814
  catalogName: z.string(),
@@ -4566,7 +4824,7 @@ var itemHeaderSchema = z.object({
4566
4824
  itemInfoId: z.string()
4567
4825
  });
4568
4826
 
4569
- // lib/items/models/PhaseEnum.ts
4827
+ // lib/items/v1/models/PhaseEnum.ts
4570
4828
  var phaseEnumSchema = z.enum([
4571
4829
  "CORE",
4572
4830
  "CORE_PLUS",
@@ -4575,7 +4833,7 @@ var phaseEnumSchema = z.enum([
4575
4833
  "STANDARD_REQUIREMENTS"
4576
4834
  ]);
4577
4835
 
4578
- // lib/items/models/TradingPartnerStage.ts
4836
+ // lib/items/v1/models/TradingPartnerStage.ts
4579
4837
  var tradingPartnerStageSchema = z.object({
4580
4838
  companyId: z.number(),
4581
4839
  companyName: z.string(),
@@ -4583,7 +4841,7 @@ var tradingPartnerStageSchema = z.object({
4583
4841
  isValid: z.boolean()
4584
4842
  });
4585
4843
 
4586
- // lib/items/models/ItemMap.ts
4844
+ // lib/items/v1/models/ItemMap.ts
4587
4845
  var itemMapSchema = z.object({
4588
4846
  rn: z.number().optional(),
4589
4847
  iteminfoid: z.string(),
@@ -4606,13 +4864,13 @@ var itemMapSchema = z.object({
4606
4864
  productsizedescription: z.array(z.string()).nullish()
4607
4865
  }).passthrough();
4608
4866
 
4609
- // lib/items/models/ItemTable.ts
4867
+ // lib/items/v1/models/ItemTable.ts
4610
4868
  var itemTableSchema = z.object({
4611
4869
  headers: itemHeaderSchema,
4612
4870
  itemMaps: z.array(itemMapSchema)
4613
4871
  });
4614
4872
 
4615
- // lib/items/models/ItemSearchView.ts
4873
+ // lib/items/v1/models/ItemSearchView.ts
4616
4874
  var itemSearchViewSchema = z.object({
4617
4875
  itemTable: itemTableSchema,
4618
4876
  hasNext: z.boolean(),
@@ -4708,7 +4966,7 @@ var companyBriefByOrgSchema = z.object({
4708
4966
  dc4Id: z.number()
4709
4967
  });
4710
4968
 
4711
- // lib/items/models/AttributeDetail.ts
4969
+ // lib/items/v1/models/AttributeDetail.ts
4712
4970
  var attributeDetailSchema = z.object({
4713
4971
  type: attrDatatypeNameEnumSchema,
4714
4972
  name: z.string(),
@@ -4718,23 +4976,23 @@ var attributeDetailSchema = z.object({
4718
4976
  orderBy: z.number().or(z.string()).nullish()
4719
4977
  });
4720
4978
 
4721
- // lib/items/models/CategoryEnum.ts
4979
+ // lib/items/v1/models/CategoryEnum.ts
4722
4980
  var categoryEnumSchema = z.enum([
4723
- "AKA",
4981
+ "ALIAS",
4724
4982
  "CATALOG",
4725
4983
  "EXPORT",
4726
- "LABEL",
4727
4984
  "LEGACY_PRODUCT_TYPE",
4728
4985
  "PRODUCT_CLASSIFICATION",
4729
4986
  "PRODUCT_CODE",
4730
4987
  "SELECTION_CODE",
4988
+ "TAG",
4731
4989
  "TAXONOMY_ROOT"
4732
4990
  ]);
4733
4991
 
4734
- // lib/items/models/ComponentDetails.ts
4992
+ // lib/items/v1/models/ComponentDetails.ts
4735
4993
  var componentDetailsSchema = z.object({
4736
4994
  itemInfoId: z.number(),
4737
- description: z.string(),
4995
+ description: z.string().nullish(),
4738
4996
  saleable: z.boolean(),
4739
4997
  valid: z.boolean(),
4740
4998
  uniqueCriteria: z.array(
@@ -4745,43 +5003,43 @@ var componentDetailsSchema = z.object({
4745
5003
  )
4746
5004
  });
4747
5005
 
4748
- // lib/items/models/RepeatableGroup.ts
5006
+ // lib/items/v1/models/RepeatableGroup.ts
4749
5007
  var repeatableGroupSchema = z.object({
4750
5008
  repeatableGroupId: z.string(),
4751
5009
  repeatableNumber: z.number()
4752
5010
  });
4753
5011
 
4754
- // lib/items/models/GroupedAttributeList.ts
5012
+ // lib/items/v1/models/GroupedAttributeList.ts
4755
5013
  var groupedAttributeListSchema = z.object({
4756
5014
  type: z.string(),
4757
5015
  rows: z.array(z.array(attributeDetailSchema)),
4758
5016
  repeatableGroups: z.array(repeatableGroupSchema)
4759
5017
  });
4760
5018
 
4761
- // lib/items/models/GroupedAttributes.ts
5019
+ // lib/items/v1/models/GroupedAttributes.ts
4762
5020
  var groupedAttributesSchema = z.object({
4763
5021
  type: z.string(),
4764
5022
  attributes: z.array(attributeDetailSchema),
4765
5023
  attributeGroups: z.array(groupedAttributeListSchema)
4766
5024
  });
4767
5025
 
4768
- // lib/items/models/HierarchyCategory.ts
5026
+ // lib/items/v1/models/HierarchyCategory.ts
4769
5027
  var hierarchyCategorySchema = z.object({
4770
5028
  name: z.string(),
4771
5029
  description: z.string().nullish(),
4772
5030
  id: z.number(),
4773
- companyId: z.number(),
5031
+ companyId: z.number().nullish(),
4774
5032
  type: categoryEnumSchema
4775
5033
  });
4776
5034
 
4777
- // lib/items/models/HierarchyDetails.ts
5035
+ // lib/items/v1/models/HierarchyDetails.ts
4778
5036
  var hierarchyDetailsSchema = z.object({
4779
5037
  catalogs: z.array(hierarchyCategorySchema),
4780
5038
  selectionCodes: z.array(hierarchyCategorySchema),
4781
5039
  productCodes: z.array(hierarchyCategorySchema)
4782
5040
  });
4783
5041
 
4784
- // lib/items/models/PackComponentItemInfo.ts
5042
+ // lib/items/v1/models/PackComponentItemInfo.ts
4785
5043
  var packComponentItemInfoSchema = z.object({
4786
5044
  companyid: z.number(),
4787
5045
  createddate: z.number(),
@@ -4795,7 +5053,7 @@ var packComponentItemInfoSchema = z.object({
4795
5053
  attributes: z.record(z.string(), z.string().or(z.array(z.string())))
4796
5054
  });
4797
5055
 
4798
- // lib/items/models/ItemPrice.ts
5056
+ // lib/items/v1/models/ItemPrice.ts
4799
5057
  var itemPriceSchema = z.object({
4800
5058
  amount: z.number(),
4801
5059
  currency: z.string(),
@@ -4819,13 +5077,13 @@ var itemPriceSchema = z.object({
4819
5077
  priceUnitQuantityUOM: z.string().nullish()
4820
5078
  });
4821
5079
 
4822
- // lib/items/models/PackComponentDetails.ts
5080
+ // lib/items/v1/models/PackComponentDetails.ts
4823
5081
  var packComponentDetailsSchema = z.object({
4824
5082
  itemInfo: packComponentItemInfoSchema,
4825
5083
  itemPrices: z.array(itemPriceSchema)
4826
5084
  });
4827
5085
 
4828
- // lib/items/models/GroupedItem.ts
5086
+ // lib/items/v1/models/GroupedItem.ts
4829
5087
  var groupedItemSchema = z.object({
4830
5088
  iteminfoid: z.number(),
4831
5089
  companyid: z.number(),
@@ -4841,12 +5099,12 @@ var groupedItemSchema = z.object({
4841
5099
  locales: z.array(z.string())
4842
5100
  });
4843
5101
 
4844
- // lib/items/models/ItemDetailView.ts
5102
+ // lib/items/v1/models/ItemDetailView.ts
4845
5103
  var itemDetailViewSchema = z.object({
4846
5104
  item: groupedItemSchema
4847
5105
  });
4848
5106
 
4849
- // lib/items/models/Bulb.ts
5107
+ // lib/items/v1/models/Bulb.ts
4850
5108
  var bulbSchema = z.object({
4851
5109
  iteminfoid: z.number(),
4852
5110
  id: z.number(),
@@ -4864,14 +5122,14 @@ var bulbSchema = z.object({
4864
5122
  threewaybulb: z.string()
4865
5123
  });
4866
5124
 
4867
- // lib/items/models/PackComponent.ts
5125
+ // lib/items/v1/models/PackComponent.ts
4868
5126
  var packComponentSchema = z.object({
4869
5127
  itemInfoId: z.number().nullish(),
4870
5128
  attributes: z.record(z.string(), z.string().or(z.array(z.string()))),
4871
5129
  prices: z.array(itemPriceSchema)
4872
5130
  });
4873
5131
 
4874
- // lib/items/models/MediaItem.ts
5132
+ // lib/items/v1/models/MediaItem.ts
4875
5133
  var mediaItemSchema = z.object({
4876
5134
  id: z.number(),
4877
5135
  iteminfoid: z.number(),
@@ -4892,7 +5150,7 @@ var mediaItemSchema = z.object({
4892
5150
  thumbnailflag: z.string().nullish()
4893
5151
  });
4894
5152
 
4895
- // lib/items/models/ItemDetail.ts
5153
+ // lib/items/v1/models/ItemDetail.ts
4896
5154
  var itemDetailSchema = z.object({
4897
5155
  attributes: z.record(z.string(), z.any()),
4898
5156
  clusters: z.record(
@@ -4912,13 +5170,13 @@ var itemDetailSchema = z.object({
4912
5170
  packs: z.array(packComponentSchema)
4913
5171
  });
4914
5172
 
4915
- // lib/items/models/SpsItemIdResponse.ts
5173
+ // lib/items/v1/models/SpsItemIdResponse.ts
4916
5174
  var spsItemIdResponseSchema = z.object({
4917
5175
  id: z.string(),
4918
5176
  ref: z.string()
4919
5177
  });
4920
5178
 
4921
- // lib/items/models/ItemOrgStatus.ts
5179
+ // lib/items/v1/models/ItemOrgStatus.ts
4922
5180
  var itemOrgStatusSchema = z.object({
4923
5181
  org: z.object({
4924
5182
  ref: z.string(),
@@ -4929,52 +5187,64 @@ var itemOrgStatusSchema = z.object({
4929
5187
  validForRelationship: z.boolean()
4930
5188
  });
4931
5189
 
4932
- // lib/items/models/ItemStatus.ts
5190
+ // lib/items/v1/models/ItemStatus.ts
4933
5191
  var itemStatusSchema = z.object({
4934
5192
  itemId: z.string(),
4935
5193
  itemOrgStatuses: z.array(itemOrgStatusSchema)
4936
5194
  });
4937
5195
 
4938
- // lib/items/models/ItemStatusResponse.ts
5196
+ // lib/items/v1/models/ItemStatusResponse.ts
4939
5197
  var itemStatusResponseSchema = z.object({
4940
5198
  itemStatuses: z.array(itemStatusSchema)
4941
5199
  });
4942
5200
 
4943
- // lib/items/index.ts
4944
- var BASE_URL12 = "items";
5201
+ // lib/items/v1/index.ts
5202
+ var BASE_URL13 = "items";
4945
5203
  function createItemsApi(client) {
5204
+ function createQueryParameterString(params = {}) {
5205
+ const searchParams = new URLSearchParams();
5206
+ const { limit, offset, applicationType, url } = params ?? {};
5207
+ if (limit)
5208
+ searchParams.append("limit", limit.toString());
5209
+ if (offset)
5210
+ searchParams.append("offset", offset.toString());
5211
+ if (applicationType)
5212
+ searchParams.append("application", applicationType);
5213
+ const queryParameterString = searchParams.toString();
5214
+ return url ? `${queryParameterString}&${url}` : queryParameterString;
5215
+ }
4946
5216
  async function searchItems(params, signal) {
4947
- const searchParams = params ? `limit=${params.limit}&offset=${params.offset}` + (params.url ? `&${params.url}` : "") : void 0;
4948
- const data = await client.get(`${BASE_URL12}`, { searchParams, signal }).json();
5217
+ const searchParams = createQueryParameterString(params);
5218
+ const data = await client.get(`${BASE_URL13}`, { searchParams, signal }).json();
4949
5219
  return itemSearchViewSchema.parse(data);
4950
5220
  }
4951
5221
  async function getItem(itemId, locale = "en-US", signal) {
4952
- const data = await client.get(`${BASE_URL12}/${itemId}`, { searchParams: { locale }, signal }).json();
5222
+ const data = await client.get(`${BASE_URL13}/${itemId}`, { searchParams: { locale }, signal }).json();
4953
5223
  return itemDetailViewSchema.parse(data);
4954
5224
  }
4955
5225
  async function updateItem(itemId, item) {
4956
- await client.put(`${BASE_URL12}/details/${itemId}`, { json: { ...item } }).json();
5226
+ await client.put(`${BASE_URL13}/details/${itemId}`, { json: { ...item } }).json();
4957
5227
  }
4958
5228
  async function deleteItem(itemId) {
4959
- await client.delete(`${BASE_URL12}/${itemId}`);
5229
+ await client.delete(`${BASE_URL13}/${itemId}`);
4960
5230
  }
4961
5231
  async function deleteItems(itemIds) {
4962
5232
  const params = new URLSearchParams();
4963
5233
  itemIds.forEach((id) => {
4964
5234
  params.append("items", id);
4965
5235
  });
4966
- await client.delete(`${BASE_URL12}`, { searchParams: params });
5236
+ await client.delete(`${BASE_URL13}`, { searchParams: params });
4967
5237
  }
4968
5238
  async function getItemInfoId(spsItemId, signal) {
4969
- const data = await client.get(`${BASE_URL12}/${spsItemId}/itemInfoId`, { signal }).json();
5239
+ const data = await client.get(`${BASE_URL13}/${spsItemId}/itemInfoId`, { signal }).json();
4970
5240
  return z.number().parse(data);
4971
5241
  }
4972
5242
  async function getSpsItemId(itemInfoId, signal) {
4973
- const data = await client.get(`${BASE_URL12}/${itemInfoId}/spsItemId`, { signal }).json();
5243
+ const data = await client.get(`${BASE_URL13}/${itemInfoId}/spsItemId`, { signal }).json();
4974
5244
  return spsItemIdResponseSchema.parse(data);
4975
5245
  }
4976
5246
  async function getItemStatus(itemIds) {
4977
- const data = await client.post(`${BASE_URL12}/status`, { json: { itemIds } }).json();
5247
+ const data = await client.post(`${BASE_URL13}/status`, { json: { itemIds } }).json();
4978
5248
  return itemStatusResponseSchema.parse(data);
4979
5249
  }
4980
5250
  return {
@@ -4989,11 +5259,85 @@ function createItemsApi(client) {
4989
5259
  };
4990
5260
  }
4991
5261
 
5262
+ // lib/items/v2/models/Stage.ts
5263
+ var stageSchema = z.enum([
5264
+ "CORE",
5265
+ "CORE_PLUS",
5266
+ "CORE_ADVANCED",
5267
+ "ENRICHED"
5268
+ ]);
5269
+
5270
+ // lib/items/v2/models/OrgSummary.ts
5271
+ var orgSummarySchema = z.object({
5272
+ ref: z.string(),
5273
+ id: z.string(),
5274
+ name: z.string()
5275
+ });
5276
+
5277
+ // lib/items/v2/models/ItemOrgStageDetails.ts
5278
+ var itemOrgStageDetailsSchema = z.object({
5279
+ /**
5280
+ * When called as retailer, the vendor, else when vendor, the retailer.
5281
+ * */
5282
+ orgSummary: orgSummarySchema,
5283
+ /**
5284
+ * The company id of the retailer or vendor used for matching ItemOrgStageDetails to TradingPartnerStage for ErrorService
5285
+ */
5286
+ companyId: z.number().nullish(),
5287
+ /**
5288
+ * "Standard Requirements" (null) UNLESS the retailer of the item is MSIS Enabled
5289
+ * OTHERWISE the retailer default Stage UNLESS there's a currently active vendor-specific Stage defined
5290
+ * OTHERWISE the trading partnership Stage UNLESS there's a currently active Item Level override defined
5291
+ * OTHERWISE the item level override */
5292
+ stage: stageSchema.nullish(),
5293
+ /**
5294
+ * If the item is valid for the active stage. Note that for "Standard Requirements" or
5295
+ * "Enriched" this cam come directly from the item_doc table, but anything else requires validation
5296
+ */
5297
+ isValid: z.boolean(),
5298
+ /**
5299
+ * Not null if there's an item level policy override for this trading partnership
5300
+ */
5301
+ itemPolicyId: z.string().nullish(),
5302
+ /**
5303
+ * Start date for the Item level Stage if applicable
5304
+ */
5305
+ startDate: z.number().pipe(z.coerce.date()).nullish(),
5306
+ /**
5307
+ * End date for the Item level Stage if applicable
5308
+ */
5309
+ endDate: z.number().pipe(z.coerce.date()).nullish()
5310
+ });
5311
+
5312
+ // lib/items/v2/models/ItemStatusV2.ts
5313
+ var itemStatusV2Schema = z.object({
5314
+ itemId: z.string(),
5315
+ mostRestrictiveRetailerStage: stageSchema.nullable(),
5316
+ itemOrgStageDetails: z.array(itemOrgStageDetailsSchema)
5317
+ });
5318
+
5319
+ // lib/items/v2/models/ItemStatusV2Response.ts
5320
+ var itemStatusV2ResponseSchema = z.object({
5321
+ itemStatuses: z.array(itemStatusV2Schema)
5322
+ });
5323
+
5324
+ // lib/items/v2/index.ts
5325
+ var BASE_URL14 = "v2/items";
5326
+ function createItemsApiV2(client) {
5327
+ async function getItemStatus(itemIds) {
5328
+ const data = await client.post(`${BASE_URL14}/status`, { json: { itemIds } }).json();
5329
+ return itemStatusV2ResponseSchema.parse(data);
5330
+ }
5331
+ return {
5332
+ getItemStatus
5333
+ };
5334
+ }
5335
+
4992
5336
  // lib/errors/index.ts
4993
- var BASE_URL13 = "errors";
5337
+ var BASE_URL15 = "errors";
4994
5338
  function createErrorsApi(client) {
4995
5339
  async function getInvalidItemErrorDetails(itemInfoId, signal) {
4996
- const data = await client.get(`${BASE_URL13}/items/${itemInfoId}`, {
5340
+ const data = await client.get(`${BASE_URL15}/items/${itemInfoId}`, {
4997
5341
  signal
4998
5342
  }).json();
4999
5343
  return itemErrorDetailsResultSchema.parse(data);
@@ -5004,10 +5348,10 @@ function createErrorsApi(client) {
5004
5348
  }
5005
5349
 
5006
5350
  // lib/uniqueCriteria/index.ts
5007
- var BASE_URL14 = "uniquecriteria";
5351
+ var BASE_URL16 = "uniquecriteria";
5008
5352
  function createUniqueCriteriaApi(client) {
5009
5353
  async function getUniqueCriteriaByOrg(params, signal) {
5010
- const data = await client.get(`${BASE_URL14}/org`, {
5354
+ const data = await client.get(`${BASE_URL16}/org`, {
5011
5355
  searchParams: params,
5012
5356
  signal
5013
5357
  }).json();
@@ -5017,10 +5361,10 @@ function createUniqueCriteriaApi(client) {
5017
5361
  }
5018
5362
 
5019
5363
  // lib/companies/index.ts
5020
- var BASE_URL15 = "companys";
5364
+ var BASE_URL17 = "companys";
5021
5365
  function createCompaniesApi(client) {
5022
5366
  async function getCompanyBriefInfoByOrg(params, signal) {
5023
- const data = await client.get(`${BASE_URL15}/brief`, {
5367
+ const data = await client.get(`${BASE_URL17}/brief`, {
5024
5368
  searchParams: params,
5025
5369
  signal
5026
5370
  }).json();
@@ -5041,10 +5385,12 @@ function createCompaniesApi(client) {
5041
5385
  createFeatureFlagsApi,
5042
5386
  createImportsApi,
5043
5387
  createItemsApi,
5388
+ createItemsApiV2,
5044
5389
  createLocaleApi,
5045
5390
  createProductTypesApi,
5046
5391
  createSpreadsheetTemplateApi,
5047
5392
  createTradingPartnerAccessApi,
5393
+ createTradingPartnerSettingsApi,
5048
5394
  createUniqueCriteriaApi,
5049
5395
  createWhoAmIApi,
5050
5396
  envSchema