@marteye/studiojs 1.1.48 → 1.1.49-beta.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.js CHANGED
@@ -592,37 +592,73 @@ function buildMembersQueryParams(options) {
592
592
  }
593
593
  return Object.keys(queryParams).length > 0 ? queryParams : undefined;
594
594
  }
595
+ function getRole(filters) {
596
+ var _a;
597
+ return (_a = filters.role) !== null && _a !== void 0 ? _a : "both";
598
+ }
599
+ function getSourceCustomerType(filters) {
600
+ var _a;
601
+ if (filters.sourceCustomerType) {
602
+ return filters.sourceCustomerType;
603
+ }
604
+ return filters.sourceSaleId || ((_a = filters.sourceCustomerIds) === null || _a === void 0 ? void 0 : _a.length)
605
+ ? "seller"
606
+ : null;
607
+ }
608
+ function getSourceCustomerIdField(sourceCustomerType) {
609
+ return sourceCustomerType === "buyer"
610
+ ? "buyerCustomerId"
611
+ : "sellerCustomerId";
612
+ }
595
613
  function buildPreviewQueryParams(filters) {
596
614
  var _a;
597
615
  let params = {};
598
616
  let filter = buildFilterExpression(filters);
599
617
  let excludeFilters = buildExcludeFilters(filters);
618
+ let sourceCustomerType = getSourceCustomerType(filters);
600
619
  if (filter) {
601
620
  params.filter = filter;
602
621
  }
603
622
  if (excludeFilters.length > 0) {
604
623
  params.excludeFilters = JSON.stringify(excludeFilters);
605
624
  }
606
- params.role = (_a = filters.role) !== null && _a !== void 0 ? _a : "both";
625
+ params.role = getRole(filters);
607
626
  if (filters.geoBounds) {
608
627
  params.bounds = JSON.stringify(filters.geoBounds);
609
628
  }
610
629
  if (filters.secondaryFilter) {
630
+ let secondarySourceCustomerType = getSourceCustomerType(filters.secondaryFilter);
611
631
  params.secondaryFilter = JSON.stringify({
612
- role: filters.secondaryFilter.role,
632
+ role: getRole(filters.secondaryFilter),
613
633
  filter: buildFilterExpression(filters.secondaryFilter),
634
+ ...(secondarySourceCustomerType
635
+ ? { sourceCustomerType: secondarySourceCustomerType }
636
+ : {}),
637
+ ...(((_a = filters.secondaryFilter.sourceCustomerIds) === null || _a === void 0 ? void 0 : _a.length)
638
+ ? { sourceCustomerIds: filters.secondaryFilter.sourceCustomerIds }
639
+ : {}),
614
640
  ...(filters.secondaryFilter.geoBounds
615
641
  ? { bounds: filters.secondaryFilter.geoBounds }
616
642
  : {}),
617
643
  });
618
644
  }
645
+ if (sourceCustomerType) {
646
+ params.sourceCustomerType = sourceCustomerType;
647
+ }
648
+ if (filters.sourceSaleId) {
649
+ params.sourceSaleId = filters.sourceSaleId;
650
+ }
651
+ if (filters.sourceCustomerIds && filters.sourceCustomerIds.length > 0) {
652
+ params.sourceCustomerIds = JSON.stringify(filters.sourceCustomerIds);
653
+ }
619
654
  return params;
620
655
  }
621
656
  function filtersToCustomerListQuery(filters) {
622
657
  var _a;
623
658
  let excludeFilters = buildExcludeFilters(filters);
659
+ let sourceCustomerType = getSourceCustomerType(filters);
624
660
  let query = {
625
- role: (_a = filters.role) !== null && _a !== void 0 ? _a : "both",
661
+ role: getRole(filters),
626
662
  };
627
663
  let filter = buildFilterExpression(filters);
628
664
  if (filter) {
@@ -637,10 +673,26 @@ function filtersToCustomerListQuery(filters) {
637
673
  if (filters.rollingDateConfig) {
638
674
  query.rollingDateConfig = filters.rollingDateConfig;
639
675
  }
676
+ if (sourceCustomerType) {
677
+ query.sourceCustomerType = sourceCustomerType;
678
+ }
679
+ if (filters.sourceSaleId) {
680
+ query.sourceSaleId = filters.sourceSaleId;
681
+ }
682
+ if (filters.sourceCustomerIds && filters.sourceCustomerIds.length > 0) {
683
+ query.sourceCustomerIds = [...filters.sourceCustomerIds];
684
+ }
640
685
  if (filters.secondaryFilter) {
686
+ let secondarySourceCustomerType = getSourceCustomerType(filters.secondaryFilter);
641
687
  query.secondaryFilter = {
642
- role: filters.secondaryFilter.role,
688
+ role: getRole(filters.secondaryFilter),
643
689
  filter: buildFilterExpression(filters.secondaryFilter),
690
+ ...(secondarySourceCustomerType
691
+ ? { sourceCustomerType: secondarySourceCustomerType }
692
+ : {}),
693
+ ...(((_a = filters.secondaryFilter.sourceCustomerIds) === null || _a === void 0 ? void 0 : _a.length)
694
+ ? { sourceCustomerIds: [...filters.secondaryFilter.sourceCustomerIds] }
695
+ : {}),
644
696
  ...(filters.secondaryFilter.geoBounds
645
697
  ? { bounds: filters.secondaryFilter.geoBounds }
646
698
  : {}),
@@ -652,14 +704,27 @@ function filtersToCustomerListQuery(filters) {
652
704
  return query;
653
705
  }
654
706
  function queryToFilters(query) {
707
+ var _a, _b;
655
708
  if (!query) {
656
709
  return { role: "both", productCodes: [] };
657
710
  }
711
+ let sourceCustomerIds = query.sourceCustomerIds || [];
712
+ let sourceSaleId = query.sourceSaleId || null;
713
+ let sourceCustomerType = getSourceCustomerType({
714
+ sourceCustomerType: query.sourceCustomerType,
715
+ sourceSaleId,
716
+ sourceCustomerIds,
717
+ });
658
718
  let filters = {
659
- role: query.role,
719
+ role: query.role || "both",
660
720
  dateStart: extractDate(query.filter, ">="),
661
721
  dateEnd: extractDate(query.filter, "<="),
662
722
  productCodes: extractProductCodes(query.filter),
723
+ sourceCustomerType,
724
+ sourceCustomerIds: sourceCustomerIds.length > 0
725
+ ? sourceCustomerIds
726
+ : extractSourceCustomerIds(query.filter, sourceCustomerType),
727
+ sourceSaleId,
663
728
  excludedProductCodes: [],
664
729
  geoBounds: query.bounds || null,
665
730
  boughtOnlineOnly: /@boughtOnline\s*=\s*true/.test(query.filter || ""),
@@ -677,11 +742,20 @@ function queryToFilters(query) {
677
742
  filters.excludedProductCodes = uniqueStrings((filters.excludedProductCodes || []).concat(extractProductCodes(excludeFilter)));
678
743
  }
679
744
  if (query.secondaryFilter) {
745
+ let secondarySourceCustomerType = getSourceCustomerType(query.secondaryFilter) ||
746
+ (((_a = query.secondaryFilter.filter) === null || _a === void 0 ? void 0 : _a.includes("sellerCustomerId"))
747
+ ? "seller"
748
+ : ((_b = query.secondaryFilter.filter) === null || _b === void 0 ? void 0 : _b.includes("buyerCustomerId"))
749
+ ? "buyer"
750
+ : null);
680
751
  filters.secondaryFilter = {
681
- role: query.secondaryFilter.role,
752
+ role: query.secondaryFilter.role || "both",
682
753
  dateStart: extractDate(query.secondaryFilter.filter, ">="),
683
754
  dateEnd: extractDate(query.secondaryFilter.filter, "<="),
684
755
  productCodes: extractProductCodes(query.secondaryFilter.filter),
756
+ sourceCustomerType: secondarySourceCustomerType,
757
+ sourceCustomerIds: query.secondaryFilter.sourceCustomerIds ||
758
+ extractSourceCustomerIds(query.secondaryFilter.filter, secondarySourceCustomerType),
685
759
  geoBounds: query.secondaryFilter.bounds || null,
686
760
  rollingDateConfig: query.secondaryFilter.rollingDateConfig,
687
761
  };
@@ -698,6 +772,15 @@ function mergeCustomerListFilters(base, updates) {
698
772
  merged.dateEnd = updates.dateEnd;
699
773
  if (updates.productCodes !== undefined)
700
774
  merged.productCodes = [...updates.productCodes];
775
+ if (updates.sourceCustomerType !== undefined) {
776
+ merged.sourceCustomerType = updates.sourceCustomerType;
777
+ }
778
+ if (updates.sourceCustomerIds !== undefined) {
779
+ merged.sourceCustomerIds = [...updates.sourceCustomerIds];
780
+ }
781
+ if (updates.sourceSaleId !== undefined) {
782
+ merged.sourceSaleId = updates.sourceSaleId;
783
+ }
701
784
  if (updates.excludeDateStart !== undefined) {
702
785
  merged.excludeDateStart = updates.excludeDateStart;
703
786
  }
@@ -728,7 +811,10 @@ function mergeCustomerListFilters(base, updates) {
728
811
  else {
729
812
  let nextSecondary = merged.secondaryFilter
730
813
  ? { ...merged.secondaryFilter }
731
- : { role: updates.secondaryFilter.role || "both", productCodes: [] };
814
+ : {
815
+ role: updates.secondaryFilter.role || "both",
816
+ productCodes: [],
817
+ };
732
818
  if (updates.secondaryFilter.role !== undefined) {
733
819
  nextSecondary.role = updates.secondaryFilter.role;
734
820
  }
@@ -741,6 +827,15 @@ function mergeCustomerListFilters(base, updates) {
741
827
  if (updates.secondaryFilter.productCodes !== undefined) {
742
828
  nextSecondary.productCodes = [...updates.secondaryFilter.productCodes];
743
829
  }
830
+ if (updates.secondaryFilter.sourceCustomerType !== undefined) {
831
+ nextSecondary.sourceCustomerType =
832
+ updates.secondaryFilter.sourceCustomerType;
833
+ }
834
+ if (updates.secondaryFilter.sourceCustomerIds !== undefined) {
835
+ nextSecondary.sourceCustomerIds = [
836
+ ...updates.secondaryFilter.sourceCustomerIds,
837
+ ];
838
+ }
744
839
  if (updates.secondaryFilter.geoBounds !== undefined) {
745
840
  nextSecondary.geoBounds = updates.secondaryFilter.geoBounds;
746
841
  }
@@ -780,6 +875,7 @@ function buildExcludeFilters(filters) {
780
875
  return excludeFilters;
781
876
  }
782
877
  function buildFilterExpression(filters) {
878
+ var _a;
783
879
  let fixedClauses = [];
784
880
  let alternativeGroups = [];
785
881
  if (filters.dateStart)
@@ -789,6 +885,12 @@ function buildFilterExpression(filters) {
789
885
  if (filters.productCodes && filters.productCodes.length > 0) {
790
886
  alternativeGroups.push(filters.productCodes.map((code) => `productCode = "${code}"`));
791
887
  }
888
+ if (!filters.sourceSaleId &&
889
+ filters.sourceCustomerType &&
890
+ ((_a = filters.sourceCustomerIds) === null || _a === void 0 ? void 0 : _a.length)) {
891
+ let sourceCustomerIdField = getSourceCustomerIdField(filters.sourceCustomerType);
892
+ alternativeGroups.push(filters.sourceCustomerIds.map((id) => `${sourceCustomerIdField} = "${id.replace(/"/g, '\\"')}"`));
893
+ }
792
894
  if (filters.boughtOnlineOnly) {
793
895
  fixedClauses.push(`@boughtOnline = true`);
794
896
  }
@@ -930,6 +1032,21 @@ function extractProductCodes(filter) {
930
1032
  }
931
1033
  return uniqueStrings(extractAllMatches(filter, /productCode\s*=\s*"([^"]+)"/g));
932
1034
  }
1035
+ function extractSourceCustomerIds(filter, sourceCustomerType) {
1036
+ if (!filter || !sourceCustomerType) {
1037
+ return [];
1038
+ }
1039
+ let fieldName = getSourceCustomerIdField(sourceCustomerType);
1040
+ let escapedFieldName = fieldName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1041
+ let inMatch = filter.match(new RegExp(`${escapedFieldName}\\s+IN\\s*\\(([^)]+)\\)`));
1042
+ if (inMatch) {
1043
+ return uniqueStrings(inMatch[1]
1044
+ .split(",")
1045
+ .map((value) => value.trim().replace(/^"|"$/g, ""))
1046
+ .filter(Boolean));
1047
+ }
1048
+ return uniqueStrings(extractAllMatches(filter, new RegExp(`${escapedFieldName}\\s*=\\s*"([^"]+)"`, "g")));
1049
+ }
933
1050
  function extractAllMatches(filter, regex) {
934
1051
  if (!filter) {
935
1052
  return [];
@@ -951,7 +1068,7 @@ function isRateLimitError(error) {
951
1068
 
952
1069
  var util;
953
1070
  (function (util) {
954
- util.assertEqual = (val) => val;
1071
+ util.assertEqual = (_) => { };
955
1072
  function assertIs(_arg) { }
956
1073
  util.assertIs = assertIs;
957
1074
  function assertNever(_x) {
@@ -998,11 +1115,9 @@ var util;
998
1115
  };
999
1116
  util.isInteger = typeof Number.isInteger === "function"
1000
1117
  ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
1001
- : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
1118
+ : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
1002
1119
  function joinValues(array, separator = " | ") {
1003
- return array
1004
- .map((val) => (typeof val === "string" ? `'${val}'` : val))
1005
- .join(separator);
1120
+ return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
1006
1121
  }
1007
1122
  util.joinValues = joinValues;
1008
1123
  util.jsonStringifyReplacer = (_, value) => {
@@ -1051,7 +1166,7 @@ const getParsedType = (data) => {
1051
1166
  case "string":
1052
1167
  return ZodParsedType.string;
1053
1168
  case "number":
1054
- return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
1169
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
1055
1170
  case "boolean":
1056
1171
  return ZodParsedType.boolean;
1057
1172
  case "function":
@@ -1067,10 +1182,7 @@ const getParsedType = (data) => {
1067
1182
  if (data === null) {
1068
1183
  return ZodParsedType.null;
1069
1184
  }
1070
- if (data.then &&
1071
- typeof data.then === "function" &&
1072
- data.catch &&
1073
- typeof data.catch === "function") {
1185
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
1074
1186
  return ZodParsedType.promise;
1075
1187
  }
1076
1188
  if (typeof Map !== "undefined" && data instanceof Map) {
@@ -1106,10 +1218,6 @@ const ZodIssueCode = util.arrayToEnum([
1106
1218
  "not_multiple_of",
1107
1219
  "not_finite",
1108
1220
  ]);
1109
- const quotelessJson = (obj) => {
1110
- const json = JSON.stringify(obj, null, 2);
1111
- return json.replace(/"([^"]+)":/g, "$1:");
1112
- };
1113
1221
  class ZodError extends Error {
1114
1222
  get errors() {
1115
1223
  return this.issues;
@@ -1202,8 +1310,9 @@ class ZodError extends Error {
1202
1310
  const formErrors = [];
1203
1311
  for (const sub of this.issues) {
1204
1312
  if (sub.path.length > 0) {
1205
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
1206
- fieldErrors[sub.path[0]].push(mapper(sub));
1313
+ const firstEl = sub.path[0];
1314
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
1315
+ fieldErrors[firstEl].push(mapper(sub));
1207
1316
  }
1208
1317
  else {
1209
1318
  formErrors.push(mapper(sub));
@@ -1286,17 +1395,11 @@ const errorMap = (issue, _ctx) => {
1286
1395
  else if (issue.type === "string")
1287
1396
  message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
1288
1397
  else if (issue.type === "number")
1289
- message = `Number must be ${issue.exact
1290
- ? `exactly equal to `
1291
- : issue.inclusive
1292
- ? `greater than or equal to `
1293
- : `greater than `}${issue.minimum}`;
1398
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1399
+ else if (issue.type === "bigint")
1400
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1294
1401
  else if (issue.type === "date")
1295
- message = `Date must be ${issue.exact
1296
- ? `exactly equal to `
1297
- : issue.inclusive
1298
- ? `greater than or equal to `
1299
- : `greater than `}${new Date(Number(issue.minimum))}`;
1402
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
1300
1403
  else
1301
1404
  message = "Invalid input";
1302
1405
  break;
@@ -1306,23 +1409,11 @@ const errorMap = (issue, _ctx) => {
1306
1409
  else if (issue.type === "string")
1307
1410
  message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
1308
1411
  else if (issue.type === "number")
1309
- message = `Number must be ${issue.exact
1310
- ? `exactly`
1311
- : issue.inclusive
1312
- ? `less than or equal to`
1313
- : `less than`} ${issue.maximum}`;
1412
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1314
1413
  else if (issue.type === "bigint")
1315
- message = `BigInt must be ${issue.exact
1316
- ? `exactly`
1317
- : issue.inclusive
1318
- ? `less than or equal to`
1319
- : `less than`} ${issue.maximum}`;
1414
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1320
1415
  else if (issue.type === "date")
1321
- message = `Date must be ${issue.exact
1322
- ? `exactly`
1323
- : issue.inclusive
1324
- ? `smaller than or equal to`
1325
- : `smaller than`} ${new Date(Number(issue.maximum))}`;
1416
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
1326
1417
  else
1327
1418
  message = "Invalid input";
1328
1419
  break;
@@ -1346,9 +1437,6 @@ const errorMap = (issue, _ctx) => {
1346
1437
  };
1347
1438
 
1348
1439
  let overrideErrorMap = errorMap;
1349
- function setErrorMap(map) {
1350
- overrideErrorMap = map;
1351
- }
1352
1440
  function getErrorMap() {
1353
1441
  return overrideErrorMap;
1354
1442
  }
@@ -1381,7 +1469,6 @@ const makeIssue = (params) => {
1381
1469
  message: errorMessage,
1382
1470
  };
1383
1471
  };
1384
- const EMPTY_PATH = [];
1385
1472
  function addIssueToContext(ctx, issueData) {
1386
1473
  const overrideMap = getErrorMap();
1387
1474
  const issue = makeIssue({
@@ -1444,8 +1531,7 @@ class ParseStatus {
1444
1531
  status.dirty();
1445
1532
  if (value.status === "dirty")
1446
1533
  status.dirty();
1447
- if (key.value !== "__proto__" &&
1448
- (typeof value.value !== "undefined" || pair.alwaysSet)) {
1534
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
1449
1535
  finalObject[key.value] = value.value;
1450
1536
  }
1451
1537
  }
@@ -1462,43 +1548,13 @@ const isDirty = (x) => x.status === "dirty";
1462
1548
  const isValid = (x) => x.status === "valid";
1463
1549
  const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
1464
1550
 
1465
- /******************************************************************************
1466
- Copyright (c) Microsoft Corporation.
1467
-
1468
- Permission to use, copy, modify, and/or distribute this software for any
1469
- purpose with or without fee is hereby granted.
1470
-
1471
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1472
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1473
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1474
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1475
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1476
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1477
- PERFORMANCE OF THIS SOFTWARE.
1478
- ***************************************************************************** */
1479
-
1480
- function __classPrivateFieldGet(receiver, state, kind, f) {
1481
- if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1482
- return state.get(receiver);
1483
- }
1484
-
1485
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
1486
- if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1487
- return (state.set(receiver, value)), value;
1488
- }
1489
-
1490
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1491
- var e = new Error(message);
1492
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1493
- };
1494
-
1495
1551
  var errorUtil;
1496
1552
  (function (errorUtil) {
1497
1553
  errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
1498
- errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
1554
+ // biome-ignore lint:
1555
+ errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
1499
1556
  })(errorUtil || (errorUtil = {}));
1500
1557
 
1501
- var _ZodEnum_cache, _ZodNativeEnum_cache;
1502
1558
  class ParseInputLazyPath {
1503
1559
  constructor(parent, value, path, key) {
1504
1560
  this._cachedPath = [];
@@ -1509,7 +1565,7 @@ class ParseInputLazyPath {
1509
1565
  }
1510
1566
  get path() {
1511
1567
  if (!this._cachedPath.length) {
1512
- if (this._key instanceof Array) {
1568
+ if (Array.isArray(this._key)) {
1513
1569
  this._cachedPath.push(...this._path, ...this._key);
1514
1570
  }
1515
1571
  else {
@@ -1549,17 +1605,16 @@ function processCreateParams(params) {
1549
1605
  if (errorMap)
1550
1606
  return { errorMap: errorMap, description };
1551
1607
  const customMap = (iss, ctx) => {
1552
- var _a, _b;
1553
1608
  const { message } = params;
1554
1609
  if (iss.code === "invalid_enum_value") {
1555
- return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
1610
+ return { message: message ?? ctx.defaultError };
1556
1611
  }
1557
1612
  if (typeof ctx.data === "undefined") {
1558
- return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
1613
+ return { message: message ?? required_error ?? ctx.defaultError };
1559
1614
  }
1560
1615
  if (iss.code !== "invalid_type")
1561
1616
  return { message: ctx.defaultError };
1562
- return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
1617
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
1563
1618
  };
1564
1619
  return { errorMap: customMap, description };
1565
1620
  }
@@ -1611,14 +1666,13 @@ class ZodType {
1611
1666
  throw result.error;
1612
1667
  }
1613
1668
  safeParse(data, params) {
1614
- var _a;
1615
1669
  const ctx = {
1616
1670
  common: {
1617
1671
  issues: [],
1618
- async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
1619
- contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
1672
+ async: params?.async ?? false,
1673
+ contextualErrorMap: params?.errorMap,
1620
1674
  },
1621
- path: (params === null || params === void 0 ? void 0 : params.path) || [],
1675
+ path: params?.path || [],
1622
1676
  schemaErrorMap: this._def.errorMap,
1623
1677
  parent: null,
1624
1678
  data,
@@ -1628,7 +1682,6 @@ class ZodType {
1628
1682
  return handleResult(ctx, result);
1629
1683
  }
1630
1684
  "~validate"(data) {
1631
- var _a, _b;
1632
1685
  const ctx = {
1633
1686
  common: {
1634
1687
  issues: [],
@@ -1652,7 +1705,7 @@ class ZodType {
1652
1705
  };
1653
1706
  }
1654
1707
  catch (err) {
1655
- if ((_b = (_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
1708
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
1656
1709
  this["~standard"].async = true;
1657
1710
  }
1658
1711
  ctx.common = {
@@ -1679,19 +1732,17 @@ class ZodType {
1679
1732
  const ctx = {
1680
1733
  common: {
1681
1734
  issues: [],
1682
- contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
1735
+ contextualErrorMap: params?.errorMap,
1683
1736
  async: true,
1684
1737
  },
1685
- path: (params === null || params === void 0 ? void 0 : params.path) || [],
1738
+ path: params?.path || [],
1686
1739
  schemaErrorMap: this._def.errorMap,
1687
1740
  parent: null,
1688
1741
  data,
1689
1742
  parsedType: getParsedType(data),
1690
1743
  };
1691
1744
  const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
1692
- const result = await (isAsync(maybeAsyncResult)
1693
- ? maybeAsyncResult
1694
- : Promise.resolve(maybeAsyncResult));
1745
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
1695
1746
  return handleResult(ctx, result);
1696
1747
  }
1697
1748
  refine(check, message) {
@@ -1735,9 +1786,7 @@ class ZodType {
1735
1786
  refinement(check, refinementData) {
1736
1787
  return this._refinement((val, ctx) => {
1737
1788
  if (!check(val)) {
1738
- ctx.addIssue(typeof refinementData === "function"
1739
- ? refinementData(val, ctx)
1740
- : refinementData);
1789
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
1741
1790
  return false;
1742
1791
  }
1743
1792
  else {
@@ -1909,15 +1958,15 @@ const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z
1909
1958
  const 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])))`;
1910
1959
  const dateRegex = new RegExp(`^${dateRegexSource}$`);
1911
1960
  function timeRegexSource(args) {
1912
- // let regex = `\\d{2}:\\d{2}:\\d{2}`;
1913
- let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
1961
+ let secondsRegexSource = `[0-5]\\d`;
1914
1962
  if (args.precision) {
1915
- regex = `${regex}\\.\\d{${args.precision}}`;
1963
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
1916
1964
  }
1917
1965
  else if (args.precision == null) {
1918
- regex = `${regex}(\\.\\d+)?`;
1966
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
1919
1967
  }
1920
- return regex;
1968
+ const secondsQuantifier = args.precision ? "+" : "?"; // require seconds if precision is nonzero
1969
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
1921
1970
  }
1922
1971
  function timeRegex(args) {
1923
1972
  return new RegExp(`^${timeRegexSource(args)}$`);
@@ -1946,6 +1995,8 @@ function isValidJWT(jwt, alg) {
1946
1995
  return false;
1947
1996
  try {
1948
1997
  const [header] = jwt.split(".");
1998
+ if (!header)
1999
+ return false;
1949
2000
  // Convert base64url to base64
1950
2001
  const base64 = header
1951
2002
  .replace(/-/g, "+")
@@ -1954,13 +2005,15 @@ function isValidJWT(jwt, alg) {
1954
2005
  const decoded = JSON.parse(atob(base64));
1955
2006
  if (typeof decoded !== "object" || decoded === null)
1956
2007
  return false;
1957
- if (!decoded.typ || !decoded.alg)
2008
+ if ("typ" in decoded && decoded?.typ !== "JWT")
2009
+ return false;
2010
+ if (!decoded.alg)
1958
2011
  return false;
1959
2012
  if (alg && decoded.alg !== alg)
1960
2013
  return false;
1961
2014
  return true;
1962
2015
  }
1963
- catch (_a) {
2016
+ catch {
1964
2017
  return false;
1965
2018
  }
1966
2019
  }
@@ -2131,7 +2184,7 @@ class ZodString extends ZodType {
2131
2184
  try {
2132
2185
  new URL(input.data);
2133
2186
  }
2134
- catch (_a) {
2187
+ catch {
2135
2188
  ctx = this._getOrReturnCtx(input, ctx);
2136
2189
  addIssueToContext(ctx, {
2137
2190
  validation: "url",
@@ -2361,7 +2414,6 @@ class ZodString extends ZodType {
2361
2414
  return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
2362
2415
  }
2363
2416
  datetime(options) {
2364
- var _a, _b;
2365
2417
  if (typeof options === "string") {
2366
2418
  return this._addCheck({
2367
2419
  kind: "datetime",
@@ -2373,10 +2425,10 @@ class ZodString extends ZodType {
2373
2425
  }
2374
2426
  return this._addCheck({
2375
2427
  kind: "datetime",
2376
- precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2377
- offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
2378
- local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
2379
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
2428
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
2429
+ offset: options?.offset ?? false,
2430
+ local: options?.local ?? false,
2431
+ ...errorUtil.errToObj(options?.message),
2380
2432
  });
2381
2433
  }
2382
2434
  date(message) {
@@ -2392,8 +2444,8 @@ class ZodString extends ZodType {
2392
2444
  }
2393
2445
  return this._addCheck({
2394
2446
  kind: "time",
2395
- precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2396
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
2447
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
2448
+ ...errorUtil.errToObj(options?.message),
2397
2449
  });
2398
2450
  }
2399
2451
  duration(message) {
@@ -2410,8 +2462,8 @@ class ZodString extends ZodType {
2410
2462
  return this._addCheck({
2411
2463
  kind: "includes",
2412
2464
  value: value,
2413
- position: options === null || options === void 0 ? void 0 : options.position,
2414
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
2465
+ position: options?.position,
2466
+ ...errorUtil.errToObj(options?.message),
2415
2467
  });
2416
2468
  }
2417
2469
  startsWith(value, message) {
@@ -2544,11 +2596,10 @@ class ZodString extends ZodType {
2544
2596
  }
2545
2597
  }
2546
2598
  ZodString.create = (params) => {
2547
- var _a;
2548
2599
  return new ZodString({
2549
2600
  checks: [],
2550
2601
  typeName: ZodFirstPartyTypeKind.ZodString,
2551
- coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2602
+ coerce: params?.coerce ?? false,
2552
2603
  ...processCreateParams(params),
2553
2604
  });
2554
2605
  };
@@ -2557,9 +2608,9 @@ function floatSafeRemainder(val, step) {
2557
2608
  const valDecCount = (val.toString().split(".")[1] || "").length;
2558
2609
  const stepDecCount = (step.toString().split(".")[1] || "").length;
2559
2610
  const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
2560
- const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
2561
- const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
2562
- return (valInt % stepInt) / Math.pow(10, decCount);
2611
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
2612
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
2613
+ return (valInt % stepInt) / 10 ** decCount;
2563
2614
  }
2564
2615
  class ZodNumber extends ZodType {
2565
2616
  constructor() {
@@ -2598,9 +2649,7 @@ class ZodNumber extends ZodType {
2598
2649
  }
2599
2650
  }
2600
2651
  else if (check.kind === "min") {
2601
- const tooSmall = check.inclusive
2602
- ? input.data < check.value
2603
- : input.data <= check.value;
2652
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2604
2653
  if (tooSmall) {
2605
2654
  ctx = this._getOrReturnCtx(input, ctx);
2606
2655
  addIssueToContext(ctx, {
@@ -2615,9 +2664,7 @@ class ZodNumber extends ZodType {
2615
2664
  }
2616
2665
  }
2617
2666
  else if (check.kind === "max") {
2618
- const tooBig = check.inclusive
2619
- ? input.data > check.value
2620
- : input.data >= check.value;
2667
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2621
2668
  if (tooBig) {
2622
2669
  ctx = this._getOrReturnCtx(input, ctx);
2623
2670
  addIssueToContext(ctx, {
@@ -2775,15 +2822,13 @@ class ZodNumber extends ZodType {
2775
2822
  return max;
2776
2823
  }
2777
2824
  get isInt() {
2778
- return !!this._def.checks.find((ch) => ch.kind === "int" ||
2779
- (ch.kind === "multipleOf" && util.isInteger(ch.value)));
2825
+ return !!this._def.checks.find((ch) => ch.kind === "int" || (ch.kind === "multipleOf" && util.isInteger(ch.value)));
2780
2826
  }
2781
2827
  get isFinite() {
2782
- let max = null, min = null;
2828
+ let max = null;
2829
+ let min = null;
2783
2830
  for (const ch of this._def.checks) {
2784
- if (ch.kind === "finite" ||
2785
- ch.kind === "int" ||
2786
- ch.kind === "multipleOf") {
2831
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
2787
2832
  return true;
2788
2833
  }
2789
2834
  else if (ch.kind === "min") {
@@ -2802,7 +2847,7 @@ ZodNumber.create = (params) => {
2802
2847
  return new ZodNumber({
2803
2848
  checks: [],
2804
2849
  typeName: ZodFirstPartyTypeKind.ZodNumber,
2805
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2850
+ coerce: params?.coerce || false,
2806
2851
  ...processCreateParams(params),
2807
2852
  });
2808
2853
  };
@@ -2817,7 +2862,7 @@ class ZodBigInt extends ZodType {
2817
2862
  try {
2818
2863
  input.data = BigInt(input.data);
2819
2864
  }
2820
- catch (_a) {
2865
+ catch {
2821
2866
  return this._getInvalidInput(input);
2822
2867
  }
2823
2868
  }
@@ -2829,9 +2874,7 @@ class ZodBigInt extends ZodType {
2829
2874
  const status = new ParseStatus();
2830
2875
  for (const check of this._def.checks) {
2831
2876
  if (check.kind === "min") {
2832
- const tooSmall = check.inclusive
2833
- ? input.data < check.value
2834
- : input.data <= check.value;
2877
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2835
2878
  if (tooSmall) {
2836
2879
  ctx = this._getOrReturnCtx(input, ctx);
2837
2880
  addIssueToContext(ctx, {
@@ -2845,9 +2888,7 @@ class ZodBigInt extends ZodType {
2845
2888
  }
2846
2889
  }
2847
2890
  else if (check.kind === "max") {
2848
- const tooBig = check.inclusive
2849
- ? input.data > check.value
2850
- : input.data >= check.value;
2891
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2851
2892
  if (tooBig) {
2852
2893
  ctx = this._getOrReturnCtx(input, ctx);
2853
2894
  addIssueToContext(ctx, {
@@ -2979,11 +3020,10 @@ class ZodBigInt extends ZodType {
2979
3020
  }
2980
3021
  }
2981
3022
  ZodBigInt.create = (params) => {
2982
- var _a;
2983
3023
  return new ZodBigInt({
2984
3024
  checks: [],
2985
3025
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
2986
- coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
3026
+ coerce: params?.coerce ?? false,
2987
3027
  ...processCreateParams(params),
2988
3028
  });
2989
3029
  };
@@ -3008,7 +3048,7 @@ class ZodBoolean extends ZodType {
3008
3048
  ZodBoolean.create = (params) => {
3009
3049
  return new ZodBoolean({
3010
3050
  typeName: ZodFirstPartyTypeKind.ZodBoolean,
3011
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
3051
+ coerce: params?.coerce || false,
3012
3052
  ...processCreateParams(params),
3013
3053
  });
3014
3054
  };
@@ -3027,7 +3067,7 @@ class ZodDate extends ZodType {
3027
3067
  });
3028
3068
  return INVALID;
3029
3069
  }
3030
- if (isNaN(input.data.getTime())) {
3070
+ if (Number.isNaN(input.data.getTime())) {
3031
3071
  const ctx = this._getOrReturnCtx(input);
3032
3072
  addIssueToContext(ctx, {
3033
3073
  code: ZodIssueCode.invalid_date,
@@ -3118,7 +3158,7 @@ class ZodDate extends ZodType {
3118
3158
  ZodDate.create = (params) => {
3119
3159
  return new ZodDate({
3120
3160
  checks: [],
3121
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
3161
+ coerce: params?.coerce || false,
3122
3162
  typeName: ZodFirstPartyTypeKind.ZodDate,
3123
3163
  ...processCreateParams(params),
3124
3164
  });
@@ -3440,7 +3480,8 @@ class ZodObject extends ZodType {
3440
3480
  return this._cached;
3441
3481
  const shape = this._def.shape();
3442
3482
  const keys = util.objectKeys(shape);
3443
- return (this._cached = { shape, keys });
3483
+ this._cached = { shape, keys };
3484
+ return this._cached;
3444
3485
  }
3445
3486
  _parse(input) {
3446
3487
  const parsedType = this._getType(input);
@@ -3456,8 +3497,7 @@ class ZodObject extends ZodType {
3456
3497
  const { status, ctx } = this._processInputParams(input);
3457
3498
  const { shape, keys: shapeKeys } = this._getCached();
3458
3499
  const extraKeys = [];
3459
- if (!(this._def.catchall instanceof ZodNever &&
3460
- this._def.unknownKeys === "strip")) {
3500
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
3461
3501
  for (const key in ctx.data) {
3462
3502
  if (!shapeKeys.includes(key)) {
3463
3503
  extraKeys.push(key);
@@ -3545,11 +3585,10 @@ class ZodObject extends ZodType {
3545
3585
  ...(message !== undefined
3546
3586
  ? {
3547
3587
  errorMap: (issue, ctx) => {
3548
- var _a, _b, _c, _d;
3549
- const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
3588
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
3550
3589
  if (issue.code === "unrecognized_keys")
3551
3590
  return {
3552
- message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError,
3591
+ message: errorUtil.errToObj(message).message ?? defaultError,
3553
3592
  };
3554
3593
  return {
3555
3594
  message: defaultError,
@@ -3681,11 +3720,11 @@ class ZodObject extends ZodType {
3681
3720
  }
3682
3721
  pick(mask) {
3683
3722
  const shape = {};
3684
- util.objectKeys(mask).forEach((key) => {
3723
+ for (const key of util.objectKeys(mask)) {
3685
3724
  if (mask[key] && this.shape[key]) {
3686
3725
  shape[key] = this.shape[key];
3687
3726
  }
3688
- });
3727
+ }
3689
3728
  return new ZodObject({
3690
3729
  ...this._def,
3691
3730
  shape: () => shape,
@@ -3693,11 +3732,11 @@ class ZodObject extends ZodType {
3693
3732
  }
3694
3733
  omit(mask) {
3695
3734
  const shape = {};
3696
- util.objectKeys(this.shape).forEach((key) => {
3735
+ for (const key of util.objectKeys(this.shape)) {
3697
3736
  if (!mask[key]) {
3698
3737
  shape[key] = this.shape[key];
3699
3738
  }
3700
- });
3739
+ }
3701
3740
  return new ZodObject({
3702
3741
  ...this._def,
3703
3742
  shape: () => shape,
@@ -3711,7 +3750,7 @@ class ZodObject extends ZodType {
3711
3750
  }
3712
3751
  partial(mask) {
3713
3752
  const newShape = {};
3714
- util.objectKeys(this.shape).forEach((key) => {
3753
+ for (const key of util.objectKeys(this.shape)) {
3715
3754
  const fieldSchema = this.shape[key];
3716
3755
  if (mask && !mask[key]) {
3717
3756
  newShape[key] = fieldSchema;
@@ -3719,7 +3758,7 @@ class ZodObject extends ZodType {
3719
3758
  else {
3720
3759
  newShape[key] = fieldSchema.optional();
3721
3760
  }
3722
- });
3761
+ }
3723
3762
  return new ZodObject({
3724
3763
  ...this._def,
3725
3764
  shape: () => newShape,
@@ -3727,7 +3766,7 @@ class ZodObject extends ZodType {
3727
3766
  }
3728
3767
  required(mask) {
3729
3768
  const newShape = {};
3730
- util.objectKeys(this.shape).forEach((key) => {
3769
+ for (const key of util.objectKeys(this.shape)) {
3731
3770
  if (mask && !mask[key]) {
3732
3771
  newShape[key] = this.shape[key];
3733
3772
  }
@@ -3739,7 +3778,7 @@ class ZodObject extends ZodType {
3739
3778
  }
3740
3779
  newShape[key] = newField;
3741
3780
  }
3742
- });
3781
+ }
3743
3782
  return new ZodObject({
3744
3783
  ...this._def,
3745
3784
  shape: () => newShape,
@@ -3872,137 +3911,6 @@ ZodUnion.create = (types, params) => {
3872
3911
  ...processCreateParams(params),
3873
3912
  });
3874
3913
  };
3875
- /////////////////////////////////////////////////////
3876
- /////////////////////////////////////////////////////
3877
- ////////// //////////
3878
- ////////// ZodDiscriminatedUnion //////////
3879
- ////////// //////////
3880
- /////////////////////////////////////////////////////
3881
- /////////////////////////////////////////////////////
3882
- const getDiscriminator = (type) => {
3883
- if (type instanceof ZodLazy) {
3884
- return getDiscriminator(type.schema);
3885
- }
3886
- else if (type instanceof ZodEffects) {
3887
- return getDiscriminator(type.innerType());
3888
- }
3889
- else if (type instanceof ZodLiteral) {
3890
- return [type.value];
3891
- }
3892
- else if (type instanceof ZodEnum) {
3893
- return type.options;
3894
- }
3895
- else if (type instanceof ZodNativeEnum) {
3896
- // eslint-disable-next-line ban/ban
3897
- return util.objectValues(type.enum);
3898
- }
3899
- else if (type instanceof ZodDefault) {
3900
- return getDiscriminator(type._def.innerType);
3901
- }
3902
- else if (type instanceof ZodUndefined) {
3903
- return [undefined];
3904
- }
3905
- else if (type instanceof ZodNull) {
3906
- return [null];
3907
- }
3908
- else if (type instanceof ZodOptional) {
3909
- return [undefined, ...getDiscriminator(type.unwrap())];
3910
- }
3911
- else if (type instanceof ZodNullable) {
3912
- return [null, ...getDiscriminator(type.unwrap())];
3913
- }
3914
- else if (type instanceof ZodBranded) {
3915
- return getDiscriminator(type.unwrap());
3916
- }
3917
- else if (type instanceof ZodReadonly) {
3918
- return getDiscriminator(type.unwrap());
3919
- }
3920
- else if (type instanceof ZodCatch) {
3921
- return getDiscriminator(type._def.innerType);
3922
- }
3923
- else {
3924
- return [];
3925
- }
3926
- };
3927
- class ZodDiscriminatedUnion extends ZodType {
3928
- _parse(input) {
3929
- const { ctx } = this._processInputParams(input);
3930
- if (ctx.parsedType !== ZodParsedType.object) {
3931
- addIssueToContext(ctx, {
3932
- code: ZodIssueCode.invalid_type,
3933
- expected: ZodParsedType.object,
3934
- received: ctx.parsedType,
3935
- });
3936
- return INVALID;
3937
- }
3938
- const discriminator = this.discriminator;
3939
- const discriminatorValue = ctx.data[discriminator];
3940
- const option = this.optionsMap.get(discriminatorValue);
3941
- if (!option) {
3942
- addIssueToContext(ctx, {
3943
- code: ZodIssueCode.invalid_union_discriminator,
3944
- options: Array.from(this.optionsMap.keys()),
3945
- path: [discriminator],
3946
- });
3947
- return INVALID;
3948
- }
3949
- if (ctx.common.async) {
3950
- return option._parseAsync({
3951
- data: ctx.data,
3952
- path: ctx.path,
3953
- parent: ctx,
3954
- });
3955
- }
3956
- else {
3957
- return option._parseSync({
3958
- data: ctx.data,
3959
- path: ctx.path,
3960
- parent: ctx,
3961
- });
3962
- }
3963
- }
3964
- get discriminator() {
3965
- return this._def.discriminator;
3966
- }
3967
- get options() {
3968
- return this._def.options;
3969
- }
3970
- get optionsMap() {
3971
- return this._def.optionsMap;
3972
- }
3973
- /**
3974
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
3975
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
3976
- * have a different value for each object in the union.
3977
- * @param discriminator the name of the discriminator property
3978
- * @param types an array of object schemas
3979
- * @param params
3980
- */
3981
- static create(discriminator, options, params) {
3982
- // Get all the valid discriminator values
3983
- const optionsMap = new Map();
3984
- // try {
3985
- for (const type of options) {
3986
- const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3987
- if (!discriminatorValues.length) {
3988
- throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3989
- }
3990
- for (const value of discriminatorValues) {
3991
- if (optionsMap.has(value)) {
3992
- throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
3993
- }
3994
- optionsMap.set(value, type);
3995
- }
3996
- }
3997
- return new ZodDiscriminatedUnion({
3998
- typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
3999
- discriminator,
4000
- options,
4001
- optionsMap,
4002
- ...processCreateParams(params),
4003
- });
4004
- }
4005
- }
4006
3914
  function mergeValues(a, b) {
4007
3915
  const aType = getParsedType(a);
4008
3916
  const bType = getParsedType(b);
@@ -4011,9 +3919,7 @@ function mergeValues(a, b) {
4011
3919
  }
4012
3920
  else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
4013
3921
  const bKeys = util.objectKeys(b);
4014
- const sharedKeys = util
4015
- .objectKeys(a)
4016
- .filter((key) => bKeys.indexOf(key) !== -1);
3922
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
4017
3923
  const newObj = { ...a, ...b };
4018
3924
  for (const key of sharedKeys) {
4019
3925
  const sharedValue = mergeValues(a[key], b[key]);
@@ -4040,9 +3946,7 @@ function mergeValues(a, b) {
4040
3946
  }
4041
3947
  return { valid: true, data: newArray };
4042
3948
  }
4043
- else if (aType === ZodParsedType.date &&
4044
- bType === ZodParsedType.date &&
4045
- +a === +b) {
3949
+ else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
4046
3950
  return { valid: true, data: a };
4047
3951
  }
4048
3952
  else {
@@ -4103,6 +4007,7 @@ ZodIntersection.create = (left, right, params) => {
4103
4007
  ...processCreateParams(params),
4104
4008
  });
4105
4009
  };
4010
+ // type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
4106
4011
  class ZodTuple extends ZodType {
4107
4012
  _parse(input) {
4108
4013
  const { status, ctx } = this._processInputParams(input);
@@ -4173,60 +4078,6 @@ ZodTuple.create = (schemas, params) => {
4173
4078
  ...processCreateParams(params),
4174
4079
  });
4175
4080
  };
4176
- class ZodRecord extends ZodType {
4177
- get keySchema() {
4178
- return this._def.keyType;
4179
- }
4180
- get valueSchema() {
4181
- return this._def.valueType;
4182
- }
4183
- _parse(input) {
4184
- const { status, ctx } = this._processInputParams(input);
4185
- if (ctx.parsedType !== ZodParsedType.object) {
4186
- addIssueToContext(ctx, {
4187
- code: ZodIssueCode.invalid_type,
4188
- expected: ZodParsedType.object,
4189
- received: ctx.parsedType,
4190
- });
4191
- return INVALID;
4192
- }
4193
- const pairs = [];
4194
- const keyType = this._def.keyType;
4195
- const valueType = this._def.valueType;
4196
- for (const key in ctx.data) {
4197
- pairs.push({
4198
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
4199
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
4200
- alwaysSet: key in ctx.data,
4201
- });
4202
- }
4203
- if (ctx.common.async) {
4204
- return ParseStatus.mergeObjectAsync(status, pairs);
4205
- }
4206
- else {
4207
- return ParseStatus.mergeObjectSync(status, pairs);
4208
- }
4209
- }
4210
- get element() {
4211
- return this._def.valueType;
4212
- }
4213
- static create(first, second, third) {
4214
- if (second instanceof ZodType) {
4215
- return new ZodRecord({
4216
- keyType: first,
4217
- valueType: second,
4218
- typeName: ZodFirstPartyTypeKind.ZodRecord,
4219
- ...processCreateParams(third),
4220
- });
4221
- }
4222
- return new ZodRecord({
4223
- keyType: ZodString.create(),
4224
- valueType: first,
4225
- typeName: ZodFirstPartyTypeKind.ZodRecord,
4226
- ...processCreateParams(second),
4227
- });
4228
- }
4229
- }
4230
4081
  class ZodMap extends ZodType {
4231
4082
  get keySchema() {
4232
4083
  return this._def.keyType;
@@ -4380,134 +4231,6 @@ ZodSet.create = (valueType, params) => {
4380
4231
  ...processCreateParams(params),
4381
4232
  });
4382
4233
  };
4383
- class ZodFunction extends ZodType {
4384
- constructor() {
4385
- super(...arguments);
4386
- this.validate = this.implement;
4387
- }
4388
- _parse(input) {
4389
- const { ctx } = this._processInputParams(input);
4390
- if (ctx.parsedType !== ZodParsedType.function) {
4391
- addIssueToContext(ctx, {
4392
- code: ZodIssueCode.invalid_type,
4393
- expected: ZodParsedType.function,
4394
- received: ctx.parsedType,
4395
- });
4396
- return INVALID;
4397
- }
4398
- function makeArgsIssue(args, error) {
4399
- return makeIssue({
4400
- data: args,
4401
- path: ctx.path,
4402
- errorMaps: [
4403
- ctx.common.contextualErrorMap,
4404
- ctx.schemaErrorMap,
4405
- getErrorMap(),
4406
- errorMap,
4407
- ].filter((x) => !!x),
4408
- issueData: {
4409
- code: ZodIssueCode.invalid_arguments,
4410
- argumentsError: error,
4411
- },
4412
- });
4413
- }
4414
- function makeReturnsIssue(returns, error) {
4415
- return makeIssue({
4416
- data: returns,
4417
- path: ctx.path,
4418
- errorMaps: [
4419
- ctx.common.contextualErrorMap,
4420
- ctx.schemaErrorMap,
4421
- getErrorMap(),
4422
- errorMap,
4423
- ].filter((x) => !!x),
4424
- issueData: {
4425
- code: ZodIssueCode.invalid_return_type,
4426
- returnTypeError: error,
4427
- },
4428
- });
4429
- }
4430
- const params = { errorMap: ctx.common.contextualErrorMap };
4431
- const fn = ctx.data;
4432
- if (this._def.returns instanceof ZodPromise) {
4433
- // Would love a way to avoid disabling this rule, but we need
4434
- // an alias (using an arrow function was what caused 2651).
4435
- // eslint-disable-next-line @typescript-eslint/no-this-alias
4436
- const me = this;
4437
- return OK(async function (...args) {
4438
- const error = new ZodError([]);
4439
- const parsedArgs = await me._def.args
4440
- .parseAsync(args, params)
4441
- .catch((e) => {
4442
- error.addIssue(makeArgsIssue(args, e));
4443
- throw error;
4444
- });
4445
- const result = await Reflect.apply(fn, this, parsedArgs);
4446
- const parsedReturns = await me._def.returns._def.type
4447
- .parseAsync(result, params)
4448
- .catch((e) => {
4449
- error.addIssue(makeReturnsIssue(result, e));
4450
- throw error;
4451
- });
4452
- return parsedReturns;
4453
- });
4454
- }
4455
- else {
4456
- // Would love a way to avoid disabling this rule, but we need
4457
- // an alias (using an arrow function was what caused 2651).
4458
- // eslint-disable-next-line @typescript-eslint/no-this-alias
4459
- const me = this;
4460
- return OK(function (...args) {
4461
- const parsedArgs = me._def.args.safeParse(args, params);
4462
- if (!parsedArgs.success) {
4463
- throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
4464
- }
4465
- const result = Reflect.apply(fn, this, parsedArgs.data);
4466
- const parsedReturns = me._def.returns.safeParse(result, params);
4467
- if (!parsedReturns.success) {
4468
- throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
4469
- }
4470
- return parsedReturns.data;
4471
- });
4472
- }
4473
- }
4474
- parameters() {
4475
- return this._def.args;
4476
- }
4477
- returnType() {
4478
- return this._def.returns;
4479
- }
4480
- args(...items) {
4481
- return new ZodFunction({
4482
- ...this._def,
4483
- args: ZodTuple.create(items).rest(ZodUnknown.create()),
4484
- });
4485
- }
4486
- returns(returnType) {
4487
- return new ZodFunction({
4488
- ...this._def,
4489
- returns: returnType,
4490
- });
4491
- }
4492
- implement(func) {
4493
- const validatedFunc = this.parse(func);
4494
- return validatedFunc;
4495
- }
4496
- strictImplement(func) {
4497
- const validatedFunc = this.parse(func);
4498
- return validatedFunc;
4499
- }
4500
- static create(args, returns, params) {
4501
- return new ZodFunction({
4502
- args: (args
4503
- ? args
4504
- : ZodTuple.create([]).rest(ZodUnknown.create())),
4505
- returns: returns || ZodUnknown.create(),
4506
- typeName: ZodFirstPartyTypeKind.ZodFunction,
4507
- ...processCreateParams(params),
4508
- });
4509
- }
4510
- }
4511
4234
  class ZodLazy extends ZodType {
4512
4235
  get schema() {
4513
4236
  return this._def.getter();
@@ -4557,10 +4280,6 @@ function createZodEnum(values, params) {
4557
4280
  });
4558
4281
  }
4559
4282
  class ZodEnum extends ZodType {
4560
- constructor() {
4561
- super(...arguments);
4562
- _ZodEnum_cache.set(this, void 0);
4563
- }
4564
4283
  _parse(input) {
4565
4284
  if (typeof input.data !== "string") {
4566
4285
  const ctx = this._getOrReturnCtx(input);
@@ -4572,10 +4291,10 @@ class ZodEnum extends ZodType {
4572
4291
  });
4573
4292
  return INVALID;
4574
4293
  }
4575
- if (!__classPrivateFieldGet(this, _ZodEnum_cache)) {
4576
- __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values));
4294
+ if (!this._cache) {
4295
+ this._cache = new Set(this._def.values);
4577
4296
  }
4578
- if (!__classPrivateFieldGet(this, _ZodEnum_cache).has(input.data)) {
4297
+ if (!this._cache.has(input.data)) {
4579
4298
  const ctx = this._getOrReturnCtx(input);
4580
4299
  const expectedValues = this._def.values;
4581
4300
  addIssueToContext(ctx, {
@@ -4624,18 +4343,12 @@ class ZodEnum extends ZodType {
4624
4343
  });
4625
4344
  }
4626
4345
  }
4627
- _ZodEnum_cache = new WeakMap();
4628
4346
  ZodEnum.create = createZodEnum;
4629
4347
  class ZodNativeEnum extends ZodType {
4630
- constructor() {
4631
- super(...arguments);
4632
- _ZodNativeEnum_cache.set(this, void 0);
4633
- }
4634
4348
  _parse(input) {
4635
4349
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
4636
4350
  const ctx = this._getOrReturnCtx(input);
4637
- if (ctx.parsedType !== ZodParsedType.string &&
4638
- ctx.parsedType !== ZodParsedType.number) {
4351
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
4639
4352
  const expectedValues = util.objectValues(nativeEnumValues);
4640
4353
  addIssueToContext(ctx, {
4641
4354
  expected: util.joinValues(expectedValues),
@@ -4644,10 +4357,10 @@ class ZodNativeEnum extends ZodType {
4644
4357
  });
4645
4358
  return INVALID;
4646
4359
  }
4647
- if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache)) {
4648
- __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)));
4360
+ if (!this._cache) {
4361
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
4649
4362
  }
4650
- if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache).has(input.data)) {
4363
+ if (!this._cache.has(input.data)) {
4651
4364
  const expectedValues = util.objectValues(nativeEnumValues);
4652
4365
  addIssueToContext(ctx, {
4653
4366
  received: ctx.data,
@@ -4662,7 +4375,6 @@ class ZodNativeEnum extends ZodType {
4662
4375
  return this._def.values;
4663
4376
  }
4664
4377
  }
4665
- _ZodNativeEnum_cache = new WeakMap();
4666
4378
  ZodNativeEnum.create = (values, params) => {
4667
4379
  return new ZodNativeEnum({
4668
4380
  values: values,
@@ -4676,8 +4388,7 @@ class ZodPromise extends ZodType {
4676
4388
  }
4677
4389
  _parse(input) {
4678
4390
  const { ctx } = this._processInputParams(input);
4679
- if (ctx.parsedType !== ZodParsedType.promise &&
4680
- ctx.common.async === false) {
4391
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
4681
4392
  addIssueToContext(ctx, {
4682
4393
  code: ZodIssueCode.invalid_type,
4683
4394
  expected: ZodParsedType.promise,
@@ -4685,9 +4396,7 @@ class ZodPromise extends ZodType {
4685
4396
  });
4686
4397
  return INVALID;
4687
4398
  }
4688
- const promisified = ctx.parsedType === ZodParsedType.promise
4689
- ? ctx.data
4690
- : Promise.resolve(ctx.data);
4399
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
4691
4400
  return OK(promisified.then((data) => {
4692
4401
  return this._def.type.parseAsync(data, {
4693
4402
  path: ctx.path,
@@ -4793,9 +4502,7 @@ class ZodEffects extends ZodType {
4793
4502
  return { status: status.value, value: inner.value };
4794
4503
  }
4795
4504
  else {
4796
- return this._def.schema
4797
- ._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx })
4798
- .then((inner) => {
4505
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
4799
4506
  if (inner.status === "aborted")
4800
4507
  return INVALID;
4801
4508
  if (inner.status === "dirty")
@@ -4814,7 +4521,7 @@ class ZodEffects extends ZodType {
4814
4521
  parent: ctx,
4815
4522
  });
4816
4523
  if (!isValid(base))
4817
- return base;
4524
+ return INVALID;
4818
4525
  const result = effect.transform(base.value, checkCtx);
4819
4526
  if (result instanceof Promise) {
4820
4527
  throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
@@ -4822,12 +4529,13 @@ class ZodEffects extends ZodType {
4822
4529
  return { status: status.value, value: result };
4823
4530
  }
4824
4531
  else {
4825
- return this._def.schema
4826
- ._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx })
4827
- .then((base) => {
4532
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
4828
4533
  if (!isValid(base))
4829
- return base;
4830
- return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
4534
+ return INVALID;
4535
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
4536
+ status: status.value,
4537
+ value: result,
4538
+ }));
4831
4539
  });
4832
4540
  }
4833
4541
  }
@@ -4909,9 +4617,7 @@ ZodDefault.create = (type, params) => {
4909
4617
  return new ZodDefault({
4910
4618
  innerType: type,
4911
4619
  typeName: ZodFirstPartyTypeKind.ZodDefault,
4912
- defaultValue: typeof params.default === "function"
4913
- ? params.default
4914
- : () => params.default,
4620
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
4915
4621
  ...processCreateParams(params),
4916
4622
  });
4917
4623
  };
@@ -4995,7 +4701,6 @@ ZodNaN.create = (params) => {
4995
4701
  ...processCreateParams(params),
4996
4702
  });
4997
4703
  };
4998
- const BRAND = Symbol("zod_brand");
4999
4704
  class ZodBranded extends ZodType {
5000
4705
  _parse(input) {
5001
4706
  const { ctx } = this._processInputParams(input);
@@ -5077,9 +4782,7 @@ class ZodReadonly extends ZodType {
5077
4782
  }
5078
4783
  return data;
5079
4784
  };
5080
- return isAsync(result)
5081
- ? result.then((data) => freeze(data))
5082
- : freeze(result);
4785
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
5083
4786
  }
5084
4787
  unwrap() {
5085
4788
  return this._def.innerType;
@@ -5092,60 +4795,6 @@ ZodReadonly.create = (type, params) => {
5092
4795
  ...processCreateParams(params),
5093
4796
  });
5094
4797
  };
5095
- ////////////////////////////////////////
5096
- ////////////////////////////////////////
5097
- ////////// //////////
5098
- ////////// z.custom //////////
5099
- ////////// //////////
5100
- ////////////////////////////////////////
5101
- ////////////////////////////////////////
5102
- function cleanParams(params, data) {
5103
- const p = typeof params === "function"
5104
- ? params(data)
5105
- : typeof params === "string"
5106
- ? { message: params }
5107
- : params;
5108
- const p2 = typeof p === "string" ? { message: p } : p;
5109
- return p2;
5110
- }
5111
- function custom(check, _params = {},
5112
- /**
5113
- * @deprecated
5114
- *
5115
- * Pass `fatal` into the params object instead:
5116
- *
5117
- * ```ts
5118
- * z.string().custom((val) => val.length > 5, { fatal: false })
5119
- * ```
5120
- *
5121
- */
5122
- fatal) {
5123
- if (check)
5124
- return ZodAny.create().superRefine((data, ctx) => {
5125
- var _a, _b;
5126
- const r = check(data);
5127
- if (r instanceof Promise) {
5128
- return r.then((r) => {
5129
- var _a, _b;
5130
- if (!r) {
5131
- const params = cleanParams(_params, data);
5132
- const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
5133
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
5134
- }
5135
- });
5136
- }
5137
- if (!r) {
5138
- const params = cleanParams(_params, data);
5139
- const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
5140
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
5141
- }
5142
- return;
5143
- });
5144
- return ZodAny.create();
5145
- }
5146
- const late = {
5147
- object: ZodObject.lazycreate,
5148
- };
5149
4798
  var ZodFirstPartyTypeKind;
5150
4799
  (function (ZodFirstPartyTypeKind) {
5151
4800
  ZodFirstPartyTypeKind["ZodString"] = "ZodString";
@@ -5185,170 +4834,17 @@ var ZodFirstPartyTypeKind;
5185
4834
  ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
5186
4835
  ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
5187
4836
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
5188
- const instanceOfType = (
5189
- // const instanceOfType = <T extends new (...args: any[]) => any>(
5190
- cls, params = {
5191
- message: `Input not instance of ${cls.name}`,
5192
- }) => custom((data) => data instanceof cls, params);
5193
4837
  const stringType = ZodString.create;
5194
- const numberType = ZodNumber.create;
5195
- const nanType = ZodNaN.create;
5196
- const bigIntType = ZodBigInt.create;
5197
- const booleanType = ZodBoolean.create;
5198
- const dateType = ZodDate.create;
5199
- const symbolType = ZodSymbol.create;
5200
- const undefinedType = ZodUndefined.create;
5201
- const nullType = ZodNull.create;
5202
- const anyType = ZodAny.create;
5203
- const unknownType = ZodUnknown.create;
5204
- const neverType = ZodNever.create;
5205
- const voidType = ZodVoid.create;
5206
- const arrayType = ZodArray.create;
4838
+ ZodNever.create;
4839
+ ZodArray.create;
5207
4840
  const objectType = ZodObject.create;
5208
- const strictObjectType = ZodObject.strictCreate;
5209
- const unionType = ZodUnion.create;
5210
- const discriminatedUnionType = ZodDiscriminatedUnion.create;
5211
- const intersectionType = ZodIntersection.create;
5212
- const tupleType = ZodTuple.create;
5213
- const recordType = ZodRecord.create;
5214
- const mapType = ZodMap.create;
5215
- const setType = ZodSet.create;
5216
- const functionType = ZodFunction.create;
5217
- const lazyType = ZodLazy.create;
5218
- const literalType = ZodLiteral.create;
4841
+ ZodUnion.create;
4842
+ ZodIntersection.create;
4843
+ ZodTuple.create;
5219
4844
  const enumType = ZodEnum.create;
5220
- const nativeEnumType = ZodNativeEnum.create;
5221
- const promiseType = ZodPromise.create;
5222
- const effectsType = ZodEffects.create;
5223
- const optionalType = ZodOptional.create;
5224
- const nullableType = ZodNullable.create;
5225
- const preprocessType = ZodEffects.createWithPreprocess;
5226
- const pipelineType = ZodPipeline.create;
5227
- const ostring = () => stringType().optional();
5228
- const onumber = () => numberType().optional();
5229
- const oboolean = () => booleanType().optional();
5230
- const coerce = {
5231
- string: ((arg) => ZodString.create({ ...arg, coerce: true })),
5232
- number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
5233
- boolean: ((arg) => ZodBoolean.create({
5234
- ...arg,
5235
- coerce: true,
5236
- })),
5237
- bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
5238
- date: ((arg) => ZodDate.create({ ...arg, coerce: true })),
5239
- };
5240
- const NEVER = INVALID;
5241
-
5242
- var z = /*#__PURE__*/Object.freeze({
5243
- __proto__: null,
5244
- defaultErrorMap: errorMap,
5245
- setErrorMap: setErrorMap,
5246
- getErrorMap: getErrorMap,
5247
- makeIssue: makeIssue,
5248
- EMPTY_PATH: EMPTY_PATH,
5249
- addIssueToContext: addIssueToContext,
5250
- ParseStatus: ParseStatus,
5251
- INVALID: INVALID,
5252
- DIRTY: DIRTY,
5253
- OK: OK,
5254
- isAborted: isAborted,
5255
- isDirty: isDirty,
5256
- isValid: isValid,
5257
- isAsync: isAsync,
5258
- get util () { return util; },
5259
- get objectUtil () { return objectUtil; },
5260
- ZodParsedType: ZodParsedType,
5261
- getParsedType: getParsedType,
5262
- ZodType: ZodType,
5263
- datetimeRegex: datetimeRegex,
5264
- ZodString: ZodString,
5265
- ZodNumber: ZodNumber,
5266
- ZodBigInt: ZodBigInt,
5267
- ZodBoolean: ZodBoolean,
5268
- ZodDate: ZodDate,
5269
- ZodSymbol: ZodSymbol,
5270
- ZodUndefined: ZodUndefined,
5271
- ZodNull: ZodNull,
5272
- ZodAny: ZodAny,
5273
- ZodUnknown: ZodUnknown,
5274
- ZodNever: ZodNever,
5275
- ZodVoid: ZodVoid,
5276
- ZodArray: ZodArray,
5277
- ZodObject: ZodObject,
5278
- ZodUnion: ZodUnion,
5279
- ZodDiscriminatedUnion: ZodDiscriminatedUnion,
5280
- ZodIntersection: ZodIntersection,
5281
- ZodTuple: ZodTuple,
5282
- ZodRecord: ZodRecord,
5283
- ZodMap: ZodMap,
5284
- ZodSet: ZodSet,
5285
- ZodFunction: ZodFunction,
5286
- ZodLazy: ZodLazy,
5287
- ZodLiteral: ZodLiteral,
5288
- ZodEnum: ZodEnum,
5289
- ZodNativeEnum: ZodNativeEnum,
5290
- ZodPromise: ZodPromise,
5291
- ZodEffects: ZodEffects,
5292
- ZodTransformer: ZodEffects,
5293
- ZodOptional: ZodOptional,
5294
- ZodNullable: ZodNullable,
5295
- ZodDefault: ZodDefault,
5296
- ZodCatch: ZodCatch,
5297
- ZodNaN: ZodNaN,
5298
- BRAND: BRAND,
5299
- ZodBranded: ZodBranded,
5300
- ZodPipeline: ZodPipeline,
5301
- ZodReadonly: ZodReadonly,
5302
- custom: custom,
5303
- Schema: ZodType,
5304
- ZodSchema: ZodType,
5305
- late: late,
5306
- get ZodFirstPartyTypeKind () { return ZodFirstPartyTypeKind; },
5307
- coerce: coerce,
5308
- any: anyType,
5309
- array: arrayType,
5310
- bigint: bigIntType,
5311
- boolean: booleanType,
5312
- date: dateType,
5313
- discriminatedUnion: discriminatedUnionType,
5314
- effect: effectsType,
5315
- 'enum': enumType,
5316
- 'function': functionType,
5317
- 'instanceof': instanceOfType,
5318
- intersection: intersectionType,
5319
- lazy: lazyType,
5320
- literal: literalType,
5321
- map: mapType,
5322
- nan: nanType,
5323
- nativeEnum: nativeEnumType,
5324
- never: neverType,
5325
- 'null': nullType,
5326
- nullable: nullableType,
5327
- number: numberType,
5328
- object: objectType,
5329
- oboolean: oboolean,
5330
- onumber: onumber,
5331
- optional: optionalType,
5332
- ostring: ostring,
5333
- pipeline: pipelineType,
5334
- preprocess: preprocessType,
5335
- promise: promiseType,
5336
- record: recordType,
5337
- set: setType,
5338
- strictObject: strictObjectType,
5339
- string: stringType,
5340
- symbol: symbolType,
5341
- transformer: effectsType,
5342
- tuple: tupleType,
5343
- 'undefined': undefinedType,
5344
- union: unionType,
5345
- unknown: unknownType,
5346
- 'void': voidType,
5347
- NEVER: NEVER,
5348
- ZodIssueCode: ZodIssueCode,
5349
- quotelessJson: quotelessJson,
5350
- ZodError: ZodError
5351
- });
4845
+ ZodPromise.create;
4846
+ ZodOptional.create;
4847
+ ZodNullable.create;
5352
4848
 
5353
4849
  const BASE_CF_URL = "https://mediacrate.marteye.ie";
5354
4850
  /**
@@ -5356,9 +4852,9 @@ const BASE_CF_URL = "https://mediacrate.marteye.ie";
5356
4852
  | START OF MEDIA CRATE CODE
5357
4853
  |--------------------------------------------------
5358
4854
  */
5359
- z.object({
5360
- assetPath: z.string().url({ message: "URL is required" }),
5361
- suffix: z.string().min(1, { message: "Suffix Type is required" }),
4855
+ objectType({
4856
+ assetPath: stringType().url({ message: "URL is required" }),
4857
+ suffix: stringType().min(1, { message: "Suffix Type is required" }),
5362
4858
  });
5363
4859
  // Adding Sizes here will make more end points in the mainConfig object
5364
4860
  const IMAGE_SIZES_VALUES$1 = [
@@ -5368,8 +4864,8 @@ const IMAGE_SIZES_VALUES$1 = [
5368
4864
  "large",
5369
4865
  ];
5370
4866
  const VIDEO_TASKS_VALUES$1 = ["compressed", "thumbnail"];
5371
- z.enum(VIDEO_TASKS_VALUES$1);
5372
- z.enum(IMAGE_SIZES_VALUES$1);
4867
+ enumType(VIDEO_TASKS_VALUES$1);
4868
+ enumType(IMAGE_SIZES_VALUES$1);
5373
4869
  const UPLOAD_PATHS = {
5374
4870
  START_UPLOAD: "startMultipartUpload",
5375
4871
  UPLOAD_PART: "uploadChunk",
@@ -5950,8 +5446,8 @@ function create$a(httpClient) {
5950
5446
 
5951
5447
  function create$9(httpClient) {
5952
5448
  return {
5953
- list: async (marketId) => {
5954
- return httpClient.get(`/${marketId}/product-codes`);
5449
+ list: async (marketId, options) => {
5450
+ return httpClient.get(`/${marketId}/product-codes`, (options === null || options === void 0 ? void 0 : options.includeArchived) ? { includeArchived: "true" } : undefined);
5955
5451
  },
5956
5452
  get: async (marketId, id, options) => {
5957
5453
  return httpClient.get(`/${marketId}/product-codes/${id}`, (options === null || options === void 0 ? void 0 : options.at) ? { at: options.at } : undefined);
@@ -6223,6 +5719,7 @@ const SupportedSuperTypes = [
6223
5719
  "Cattle",
6224
5720
  "Pigs",
6225
5721
  "Horses",
5722
+ "Dogs",
6226
5723
  "Deer",
6227
5724
  "Poultry",
6228
5725
  "Machinery",
@@ -6239,6 +5736,12 @@ const LivestockSuperTypes = [
6239
5736
  "Poultry",
6240
5737
  ];
6241
5738
  const SupportedCurrencyCodes = ["GBP", "EUR", "USD"];
5739
+ const AccountTiers = {
5740
+ free: 0,
5741
+ basic: 1,
5742
+ standard: 2,
5743
+ premium: 3,
5744
+ };
6242
5745
  const SupportedUnitsOfSale = [
6243
5746
  "Per KG",
6244
5747
  "Per Item",
@@ -6290,6 +5793,7 @@ const supportedWebhookEvents = [
6290
5793
 
6291
5794
  var types = /*#__PURE__*/Object.freeze({
6292
5795
  __proto__: null,
5796
+ AccountTiers: AccountTiers,
6293
5797
  IMAGE_SIZES_VALUES: IMAGE_SIZES_VALUES,
6294
5798
  LivestockSuperTypes: LivestockSuperTypes,
6295
5799
  SupportedCurrencyCodes: SupportedCurrencyCodes,
@@ -6361,6 +5865,913 @@ function createAppManifest(appConfig) {
6361
5865
  };
6362
5866
  }
6363
5867
 
5868
+ const MEDIA_CRATE_V2_BASE_URL_ENV_VARS = [
5869
+ "MEDIA_CRATE_V2_BASE_URL",
5870
+ "NEXT_PUBLIC_MEDIA_CRATE_BASE_URL",
5871
+ ];
5872
+ const MEDIA_CRATE_SINGLE_UPLOAD_MAX_BYTES = 25 * 1024 * 1024;
5873
+ const MEDIA_CRATE_MULTIPART_MAX_CHUNK_BYTES = 100 * 1024 * 1024;
5874
+ const MEDIA_CRATE_DEFAULT_CHUNK_BYTES = 5 * 1024 * 1024;
5875
+ const MEDIA_CRATE_MEDIA_STATUSES = [
5876
+ "uploading",
5877
+ "processing",
5878
+ "done",
5879
+ "error",
5880
+ "deleted",
5881
+ "partial",
5882
+ "expired",
5883
+ "indeterminate",
5884
+ ];
5885
+ /** @deprecated Use MEDIA_CRATE_MEDIA_STATUSES. */
5886
+ const MEDIA_CRATE_ASSET_STATUSES = MEDIA_CRATE_MEDIA_STATUSES;
5887
+ function getMediaCrateVariant(source, variantName, opts = {}) {
5888
+ var _a, _b;
5889
+ const urls = getMediaCrateUrls(source);
5890
+ const variant = variantName === "original"
5891
+ ? urls.original
5892
+ : ((_b = (_a = urls.variants) === null || _a === void 0 ? void 0 : _a[variantName]) !== null && _b !== void 0 ? _b : (opts.fallbackToOriginal ? urls.original : undefined));
5893
+ if (!variant) {
5894
+ return undefined;
5895
+ }
5896
+ if (opts.requireReady && !variant.ready) {
5897
+ return undefined;
5898
+ }
5899
+ return variant;
5900
+ }
5901
+ function getMediaCrateVariantUrl(source, variantName, opts = {}) {
5902
+ var _a;
5903
+ return (_a = getMediaCrateVariant(source, variantName, opts)) === null || _a === void 0 ? void 0 : _a.url;
5904
+ }
5905
+ function requireMediaCrateVariantUrl(source, variantName, opts = {}) {
5906
+ const url = getMediaCrateVariantUrl(source, variantName, opts);
5907
+ if (!url) {
5908
+ const readyMessage = opts.requireReady ? " ready" : "";
5909
+ throw new Error(`Media Crate did not return a${readyMessage} ${variantName} variant`);
5910
+ }
5911
+ return url;
5912
+ }
5913
+ class MediaCrateHttpError extends Error {
5914
+ constructor(args) {
5915
+ super(args.message);
5916
+ this.name = "MediaCrateHttpError";
5917
+ this.status = args.status;
5918
+ this.method = args.method;
5919
+ this.url = args.url;
5920
+ this.body = args.body;
5921
+ this.collidingKeys = args.collidingKeys;
5922
+ }
5923
+ }
5924
+ class MediaCrateUploadSourceError extends Error {
5925
+ constructor(message) {
5926
+ super(message);
5927
+ this.name = "MediaCrateUploadSourceError";
5928
+ }
5929
+ }
5930
+ class InMemoryMediaCrateMultipartSessionStore {
5931
+ constructor() {
5932
+ this.sessions = new Map();
5933
+ }
5934
+ async get(key) {
5935
+ const session = this.sessions.get(key);
5936
+ return session ? copySession(session) : null;
5937
+ }
5938
+ async set(key, session) {
5939
+ this.sessions.set(key, copySession(session));
5940
+ }
5941
+ async delete(key) {
5942
+ this.sessions.delete(key);
5943
+ }
5944
+ }
5945
+ function createWebUploadSource(file, opts = {}) {
5946
+ var _a, _b, _c, _d, _e;
5947
+ const fileWithMetadata = file;
5948
+ const name = (_b = (_a = opts.name) !== null && _a !== void 0 ? _a : fileWithMetadata.name) !== null && _b !== void 0 ? _b : "asset";
5949
+ const type = (_d = (_c = opts.type) !== null && _c !== void 0 ? _c : file.type) !== null && _d !== void 0 ? _d : "application/octet-stream";
5950
+ const lastModified = (_e = opts.lastModified) !== null && _e !== void 0 ? _e : fileWithMetadata.lastModified;
5951
+ return {
5952
+ name,
5953
+ type,
5954
+ size: file.size,
5955
+ lastModified,
5956
+ fingerprint: opts.fingerprint,
5957
+ canUseSingleUpload: true,
5958
+ async getPart({ start, end }) {
5959
+ return file.slice(start, end, type);
5960
+ },
5961
+ };
5962
+ }
5963
+ class MediaCrateClient {
5964
+ constructor(opts) {
5965
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
5966
+ this.baseUrl = resolveMediaCrateBaseUrl(opts);
5967
+ this.marketId = opts.marketId;
5968
+ this.getFirebaseToken = opts.getFirebaseToken;
5969
+ this.fetchImpl = (_a = opts.fetchImpl) !== null && _a !== void 0 ? _a : getGlobalFetch();
5970
+ this.sessionStore =
5971
+ (_b = opts.sessionStore) !== null && _b !== void 0 ? _b : new InMemoryMediaCrateMultipartSessionStore();
5972
+ this.chunkSizeBytes =
5973
+ (_c = opts.chunkSizeBytes) !== null && _c !== void 0 ? _c : MEDIA_CRATE_DEFAULT_CHUNK_BYTES;
5974
+ this.maxPartAttempts = (_d = opts.maxPartAttempts) !== null && _d !== void 0 ? _d : 3;
5975
+ this.maxFinishAttempts = (_e = opts.maxFinishAttempts) !== null && _e !== void 0 ? _e : 3;
5976
+ this.retryBaseDelayMs = (_f = opts.retryBaseDelayMs) !== null && _f !== void 0 ? _f : 500;
5977
+ this.maxConcurrentParts = (_g = opts.maxConcurrentParts) !== null && _g !== void 0 ? _g : 3;
5978
+ this.defaultUploadStrategy = (_h = opts.defaultUploadStrategy) !== null && _h !== void 0 ? _h : "auto";
5979
+ this.sleep = (_j = opts.sleep) !== null && _j !== void 0 ? _j : defaultSleep;
5980
+ this.now = (_k = opts.now) !== null && _k !== void 0 ? _k : Date.now;
5981
+ this.random = (_l = opts.random) !== null && _l !== void 0 ? _l : Math.random;
5982
+ }
5983
+ createMediaPath(...segments) {
5984
+ if (segments.length === 0) {
5985
+ throw new Error("At least one media path segment is required");
5986
+ }
5987
+ return normalizeUploadPath([
5988
+ normalizeUploadPathSegment(this.marketId, "marketId"),
5989
+ ...segments.map((segment, index) => normalizeUploadPathSegment(segment, `path segment ${index + 1}`)),
5990
+ ].join("/"));
5991
+ }
5992
+ createLotMediaPath(args) {
5993
+ return this.createMediaPath(args.saleId, args.lotId, args.attributeId, args.fileName);
5994
+ }
5995
+ uploadLotMedia(opts) {
5996
+ var _a;
5997
+ const path = this.createLotMediaPath({
5998
+ saleId: opts.saleId,
5999
+ lotId: opts.lotId,
6000
+ attributeId: opts.attributeId,
6001
+ fileName: (_a = opts.fileName) !== null && _a !== void 0 ? _a : opts.source.name,
6002
+ });
6003
+ return this.upload({
6004
+ ...opts,
6005
+ mode: "lot",
6006
+ path,
6007
+ });
6008
+ }
6009
+ uploadMedia(opts) {
6010
+ return this.upload(opts);
6011
+ }
6012
+ async upload(opts) {
6013
+ const path = normalizeUploadPath(opts.path);
6014
+ this.assertPathMatchesMarket(path);
6015
+ const strategy = this.resolveUploadStrategy(opts.strategy, opts.source);
6016
+ if (strategy === "single") {
6017
+ return this.uploadSingle({ ...opts, path });
6018
+ }
6019
+ return this.uploadMultipart({ ...opts, path });
6020
+ }
6021
+ async getStatus(statusUrl) {
6022
+ const headers = await this.createBaseHeaders();
6023
+ const response = await this.fetchImpl(statusUrl, {
6024
+ method: "GET",
6025
+ headers,
6026
+ });
6027
+ await throwIfNotOk(response, "GET", statusUrl);
6028
+ return (await response.json());
6029
+ }
6030
+ async delete(opts) {
6031
+ const url = this.urlFor("/delete");
6032
+ const headers = await this.createBaseHeaders();
6033
+ headers.set("X-Market-Id", this.marketId);
6034
+ headers.set("Content-Type", "application/x-www-form-urlencoded");
6035
+ const body = new URLSearchParams({ fileUrl: opts.fileUrl });
6036
+ const response = await this.fetchImpl(url.toString(), {
6037
+ method: "DELETE",
6038
+ headers,
6039
+ body,
6040
+ });
6041
+ await throwIfNotOk(response, "DELETE", url.toString());
6042
+ }
6043
+ async duplicate(opts) {
6044
+ var _a;
6045
+ const url = this.urlFor("/duplicate");
6046
+ const targetFilePath = normalizeUploadPath(opts.targetFilePath);
6047
+ this.assertPathMatchesMarket(targetFilePath);
6048
+ const headers = await this.createBaseHeaders();
6049
+ headers.set("X-Market-Id", this.marketId);
6050
+ headers.set("Content-Type", "application/json");
6051
+ const response = await this.fetchImpl(url.toString(), {
6052
+ method: "POST",
6053
+ headers,
6054
+ body: JSON.stringify({
6055
+ sourceUrl: opts.sourceUrl,
6056
+ targetFilePath,
6057
+ targetFileName: opts.targetFileName,
6058
+ overwrite: (_a = opts.overwrite) !== null && _a !== void 0 ? _a : true,
6059
+ }),
6060
+ });
6061
+ await throwIfNotOk(response, "POST", url.toString());
6062
+ return (await response.json());
6063
+ }
6064
+ async cancelMultipartUpload(args) {
6065
+ const path = normalizeUploadPath(args.path);
6066
+ this.assertPathMatchesMarket(path);
6067
+ if (args.mode === "direct") {
6068
+ await this.cancelDirectMultipartUpload({ ...args, path });
6069
+ }
6070
+ else {
6071
+ await this.cancelProcessedMultipartUpload({ ...args, path });
6072
+ }
6073
+ if (args.sessionKey) {
6074
+ await this.sessionStore.delete(args.sessionKey);
6075
+ }
6076
+ }
6077
+ resolveUploadStrategy(strategy, source) {
6078
+ const resolved = strategy !== null && strategy !== void 0 ? strategy : this.defaultUploadStrategy;
6079
+ if (resolved === "single") {
6080
+ return "single";
6081
+ }
6082
+ if (resolved === "multipart") {
6083
+ return "multipart";
6084
+ }
6085
+ if (source.size <= MEDIA_CRATE_SINGLE_UPLOAD_MAX_BYTES &&
6086
+ source.canUseSingleUpload !== false) {
6087
+ return "single";
6088
+ }
6089
+ return "multipart";
6090
+ }
6091
+ async uploadSingle(opts) {
6092
+ var _a, _b, _c, _d;
6093
+ if (opts.source.canUseSingleUpload === false) {
6094
+ throw new MediaCrateUploadSourceError("This upload source cannot be used for single binary uploads. Use multipart instead.");
6095
+ }
6096
+ (_a = opts.onProgress) === null || _a === void 0 ? void 0 : _a.call(opts, {
6097
+ phase: "starting",
6098
+ bytesUploaded: 0,
6099
+ totalBytes: opts.source.size,
6100
+ totalParts: 1,
6101
+ partNumber: 1,
6102
+ });
6103
+ const body = await opts.source.getPart({
6104
+ start: 0,
6105
+ end: opts.source.size,
6106
+ partNumber: 1,
6107
+ });
6108
+ if (isReactNativeFormDataFile(body)) {
6109
+ throw new MediaCrateUploadSourceError("Single binary uploads require raw bytes. Use multipart for URI-backed sources.");
6110
+ }
6111
+ const url = this.urlFor(opts.mode === "direct" ? "/standalone/upload" : "/upload");
6112
+ url.searchParams.set("filePath", opts.path);
6113
+ const headers = await this.createUploadHeaders({
6114
+ mode: opts.mode,
6115
+ overwrite: opts.overwrite,
6116
+ contentType: (_b = opts.source.type) !== null && _b !== void 0 ? _b : "application/octet-stream",
6117
+ });
6118
+ try {
6119
+ const response = await this.fetchImpl(url.toString(), {
6120
+ method: "POST",
6121
+ headers,
6122
+ body: body,
6123
+ });
6124
+ await throwIfNotOk(response, "POST", url.toString());
6125
+ const result = (await response.json());
6126
+ (_c = opts.onProgress) === null || _c === void 0 ? void 0 : _c.call(opts, {
6127
+ phase: "uploaded",
6128
+ bytesUploaded: opts.source.size,
6129
+ totalBytes: opts.source.size,
6130
+ totalParts: 1,
6131
+ partNumber: 1,
6132
+ });
6133
+ return result;
6134
+ }
6135
+ catch (error) {
6136
+ (_d = opts.onProgress) === null || _d === void 0 ? void 0 : _d.call(opts, {
6137
+ phase: "error",
6138
+ bytesUploaded: 0,
6139
+ totalBytes: opts.source.size,
6140
+ totalParts: 1,
6141
+ partNumber: 1,
6142
+ });
6143
+ throw error;
6144
+ }
6145
+ }
6146
+ async uploadMultipart(opts) {
6147
+ var _a, _b, _c, _d, _e, _f, _g, _h;
6148
+ const chunkSize = (_a = opts.chunkSizeBytes) !== null && _a !== void 0 ? _a : this.chunkSizeBytes;
6149
+ assertValidChunkSize(chunkSize);
6150
+ const totalParts = Math.ceil(opts.source.size / chunkSize);
6151
+ const sessionKey = (_b = opts.sessionKey) !== null && _b !== void 0 ? _b : createMultipartSessionKey({
6152
+ baseUrl: this.baseUrl,
6153
+ marketId: this.marketId,
6154
+ mode: opts.mode,
6155
+ path: opts.path,
6156
+ source: opts.source,
6157
+ chunkSize,
6158
+ overwrite: (_c = opts.overwrite) !== null && _c !== void 0 ? _c : false,
6159
+ });
6160
+ let session = await this.getOrStartMultipartSession({
6161
+ ...opts,
6162
+ chunkSize,
6163
+ totalParts,
6164
+ sessionKey,
6165
+ });
6166
+ const completedPartNumbers = new Set(session.sections.map((section) => Number(section.partNumber)));
6167
+ let bytesUploaded = getCompletedBytes({
6168
+ completedPartNumbers,
6169
+ sourceSize: opts.source.size,
6170
+ chunkSize,
6171
+ });
6172
+ if (completedPartNumbers.size > 0) {
6173
+ (_d = opts.onProgress) === null || _d === void 0 ? void 0 : _d.call(opts, {
6174
+ phase: "resuming",
6175
+ bytesUploaded,
6176
+ totalBytes: opts.source.size,
6177
+ totalParts,
6178
+ uploadId: session.uploadId,
6179
+ });
6180
+ }
6181
+ try {
6182
+ const pendingParts = createPendingPartNumbers(totalParts, completedPartNumbers);
6183
+ let nextPendingIndex = 0;
6184
+ const concurrency = Math.max(1, Math.min((_e = opts.maxConcurrentParts) !== null && _e !== void 0 ? _e : this.maxConcurrentParts, pendingParts.length || 1));
6185
+ const uploadNextPart = async () => {
6186
+ var _a;
6187
+ while (nextPendingIndex < pendingParts.length) {
6188
+ const partNumber = pendingParts[nextPendingIndex];
6189
+ nextPendingIndex++;
6190
+ const section = await this.uploadPartWithRetry({
6191
+ mode: opts.mode,
6192
+ path: opts.path,
6193
+ source: opts.source,
6194
+ uploadId: session.uploadId,
6195
+ chunkSize,
6196
+ partNumber,
6197
+ totalParts,
6198
+ onProgress: (progress) => {
6199
+ var _a;
6200
+ (_a = opts.onProgress) === null || _a === void 0 ? void 0 : _a.call(opts, {
6201
+ ...progress,
6202
+ bytesUploaded,
6203
+ totalBytes: opts.source.size,
6204
+ uploadId: session.uploadId,
6205
+ });
6206
+ },
6207
+ });
6208
+ if (!completedPartNumbers.has(partNumber)) {
6209
+ completedPartNumbers.add(partNumber);
6210
+ session = {
6211
+ ...session,
6212
+ sections: [...session.sections, section],
6213
+ updatedAt: this.now(),
6214
+ };
6215
+ await this.sessionStore.set(sessionKey, session);
6216
+ bytesUploaded += getPartSize({
6217
+ partNumber,
6218
+ sourceSize: opts.source.size,
6219
+ chunkSize,
6220
+ });
6221
+ }
6222
+ (_a = opts.onProgress) === null || _a === void 0 ? void 0 : _a.call(opts, {
6223
+ phase: "uploading",
6224
+ bytesUploaded,
6225
+ totalBytes: opts.source.size,
6226
+ partNumber,
6227
+ totalParts,
6228
+ uploadId: session.uploadId,
6229
+ });
6230
+ }
6231
+ };
6232
+ await Promise.all(Array.from({ length: concurrency }, () => uploadNextPart()));
6233
+ (_f = opts.onProgress) === null || _f === void 0 ? void 0 : _f.call(opts, {
6234
+ phase: "finishing",
6235
+ bytesUploaded: opts.source.size,
6236
+ totalBytes: opts.source.size,
6237
+ totalParts,
6238
+ uploadId: session.uploadId,
6239
+ });
6240
+ const result = await this.finishMultipartUploadWithRetry({
6241
+ mode: opts.mode,
6242
+ path: opts.path,
6243
+ fileName: opts.source.name,
6244
+ uploadId: session.uploadId,
6245
+ sections: sortSections(session.sections),
6246
+ });
6247
+ await this.sessionStore.delete(sessionKey);
6248
+ (_g = opts.onProgress) === null || _g === void 0 ? void 0 : _g.call(opts, {
6249
+ phase: "uploaded",
6250
+ bytesUploaded: opts.source.size,
6251
+ totalBytes: opts.source.size,
6252
+ totalParts,
6253
+ uploadId: session.uploadId,
6254
+ });
6255
+ return result;
6256
+ }
6257
+ catch (error) {
6258
+ if (shouldForgetMultipartSession(error)) {
6259
+ await this.sessionStore.delete(sessionKey);
6260
+ }
6261
+ (_h = opts.onProgress) === null || _h === void 0 ? void 0 : _h.call(opts, {
6262
+ phase: "error",
6263
+ bytesUploaded,
6264
+ totalBytes: opts.source.size,
6265
+ totalParts,
6266
+ uploadId: session.uploadId,
6267
+ });
6268
+ throw error;
6269
+ }
6270
+ }
6271
+ async getOrStartMultipartSession(opts) {
6272
+ var _a, _b, _c;
6273
+ const existingSession = await this.sessionStore.get(opts.sessionKey);
6274
+ const sourceFingerprint = getSourceFingerprint(opts.source);
6275
+ if (existingSession &&
6276
+ existingSession.mode === opts.mode &&
6277
+ existingSession.path === opts.path &&
6278
+ existingSession.marketId === this.marketId &&
6279
+ existingSession.chunkSize === opts.chunkSize &&
6280
+ existingSession.totalBytes === opts.source.size &&
6281
+ existingSession.sourceFingerprint === sourceFingerprint &&
6282
+ existingSession.overwrite === ((_a = opts.overwrite) !== null && _a !== void 0 ? _a : false)) {
6283
+ return existingSession;
6284
+ }
6285
+ (_b = opts.onProgress) === null || _b === void 0 ? void 0 : _b.call(opts, {
6286
+ phase: "starting",
6287
+ bytesUploaded: 0,
6288
+ totalBytes: opts.source.size,
6289
+ totalParts: opts.totalParts,
6290
+ });
6291
+ const startResponse = await this.startMultipartUpload({
6292
+ mode: opts.mode,
6293
+ path: opts.path,
6294
+ fileName: opts.source.name,
6295
+ overwrite: opts.overwrite,
6296
+ });
6297
+ const uploadId = getMultipartUploadId(startResponse);
6298
+ if (!uploadId) {
6299
+ throw new Error("Media Crate did not return an uploadId");
6300
+ }
6301
+ const now = this.now();
6302
+ const startResult = hasUploadResultShape(startResponse)
6303
+ ? startResponse
6304
+ : undefined;
6305
+ const session = {
6306
+ key: opts.sessionKey,
6307
+ mode: opts.mode,
6308
+ path: opts.path,
6309
+ marketId: this.marketId,
6310
+ uploadId,
6311
+ chunkSize: opts.chunkSize,
6312
+ totalBytes: opts.source.size,
6313
+ totalParts: opts.totalParts,
6314
+ sourceFingerprint,
6315
+ overwrite: (_c = opts.overwrite) !== null && _c !== void 0 ? _c : false,
6316
+ sections: [],
6317
+ targetKey: getMultipartTargetKey(startResponse),
6318
+ startResult,
6319
+ createdAt: now,
6320
+ updatedAt: now,
6321
+ };
6322
+ await this.sessionStore.set(opts.sessionKey, session);
6323
+ return session;
6324
+ }
6325
+ async startMultipartUpload(args) {
6326
+ if (args.mode === "direct") {
6327
+ const url = this.urlFor("/standalone/multipart/start");
6328
+ const headers = await this.createUploadHeaders({
6329
+ mode: args.mode,
6330
+ overwrite: args.overwrite,
6331
+ contentType: "application/json",
6332
+ });
6333
+ const response = await this.fetchImpl(url.toString(), {
6334
+ method: "POST",
6335
+ headers,
6336
+ body: JSON.stringify({
6337
+ filePath: args.path,
6338
+ fileName: args.fileName,
6339
+ }),
6340
+ });
6341
+ await throwIfNotOk(response, "POST", url.toString());
6342
+ return (await response.json());
6343
+ }
6344
+ const url = this.urlFor("/startMultipartUpload");
6345
+ const headers = await this.createUploadHeaders({
6346
+ mode: args.mode,
6347
+ overwrite: args.overwrite,
6348
+ });
6349
+ const formData = new FormData();
6350
+ formData.append("filePath", args.path);
6351
+ formData.append("fileName", args.fileName);
6352
+ const response = await this.fetchImpl(url.toString(), {
6353
+ method: "POST",
6354
+ headers,
6355
+ body: formData,
6356
+ });
6357
+ await throwIfNotOk(response, "POST", url.toString());
6358
+ return (await response.json());
6359
+ }
6360
+ async uploadPartWithRetry(args) {
6361
+ return this.runWithRetry({
6362
+ attempts: this.maxPartAttempts,
6363
+ onRetry: (attempt) => {
6364
+ args.onProgress({
6365
+ phase: "retrying",
6366
+ partNumber: args.partNumber,
6367
+ totalParts: args.totalParts,
6368
+ attempt,
6369
+ uploadId: args.uploadId,
6370
+ });
6371
+ },
6372
+ operation: () => this.uploadMultipartPart(args),
6373
+ });
6374
+ }
6375
+ async uploadMultipartPart(args) {
6376
+ var _a;
6377
+ const start = args.chunkSize * (args.partNumber - 1);
6378
+ const end = Math.min(args.source.size, start + args.chunkSize);
6379
+ const partBody = await args.source.getPart({
6380
+ start,
6381
+ end,
6382
+ partNumber: args.partNumber,
6383
+ });
6384
+ const url = this.urlFor(args.mode === "direct" ? "/standalone/multipart/chunk" : "/uploadChunk");
6385
+ const headers = await this.createUploadHeaders({ mode: args.mode });
6386
+ const formData = new FormData();
6387
+ formData.append("filePath", args.path);
6388
+ formData.append("fileName", args.source.name);
6389
+ formData.append("uploadId", args.uploadId);
6390
+ formData.append("partNumber", String(args.partNumber));
6391
+ appendUploadPart(formData, "file", partBody, args.source.name, args.source.type);
6392
+ const response = await this.fetchImpl(url.toString(), {
6393
+ method: "POST",
6394
+ headers,
6395
+ body: formData,
6396
+ });
6397
+ await throwIfNotOk(response, "POST", url.toString());
6398
+ const json = (await response.json());
6399
+ const eTag = getMultipartPartEtag(json);
6400
+ const partNumber = (_a = getMultipartPartNumber(json)) !== null && _a !== void 0 ? _a : args.partNumber;
6401
+ if (typeof eTag !== "string" || !eTag) {
6402
+ throw new Error(`Media Crate did not return a valid eTag for part ${args.partNumber}`);
6403
+ }
6404
+ return {
6405
+ partNumber: String(partNumber),
6406
+ eTag,
6407
+ };
6408
+ }
6409
+ async finishMultipartUploadWithRetry(args) {
6410
+ return this.runWithRetry({
6411
+ attempts: this.maxFinishAttempts,
6412
+ operation: () => this.finishMultipartUpload(args),
6413
+ });
6414
+ }
6415
+ async finishMultipartUpload(args) {
6416
+ if (args.mode === "direct") {
6417
+ const url = this.urlFor("/standalone/multipart/finish");
6418
+ const headers = await this.createUploadHeaders({
6419
+ mode: args.mode,
6420
+ contentType: "application/json",
6421
+ });
6422
+ const response = await this.fetchImpl(url.toString(), {
6423
+ method: "POST",
6424
+ headers,
6425
+ body: JSON.stringify({
6426
+ filePath: args.path,
6427
+ fileName: args.fileName,
6428
+ uploadId: args.uploadId,
6429
+ sections: JSON.stringify(args.sections),
6430
+ }),
6431
+ });
6432
+ await throwIfNotOk(response, "POST", url.toString());
6433
+ return (await response.json());
6434
+ }
6435
+ const url = this.urlFor("/finishMultipartUpload");
6436
+ const headers = await this.createUploadHeaders({ mode: args.mode });
6437
+ const formData = new FormData();
6438
+ formData.append("filePath", args.path);
6439
+ formData.append("fileName", args.fileName);
6440
+ formData.append("uploadId", args.uploadId);
6441
+ formData.append("sections", JSON.stringify(args.sections));
6442
+ const response = await this.fetchImpl(url.toString(), {
6443
+ method: "POST",
6444
+ headers,
6445
+ body: formData,
6446
+ });
6447
+ await throwIfNotOk(response, "POST", url.toString());
6448
+ return (await response.json());
6449
+ }
6450
+ async cancelDirectMultipartUpload(args) {
6451
+ const url = this.urlFor("/standalone/multipart/cancel");
6452
+ const headers = await this.createUploadHeaders({
6453
+ mode: args.mode,
6454
+ contentType: "application/json",
6455
+ });
6456
+ const response = await this.fetchImpl(url.toString(), {
6457
+ method: "POST",
6458
+ headers,
6459
+ body: JSON.stringify({
6460
+ filePath: args.path,
6461
+ fileName: args.fileName,
6462
+ uploadId: args.uploadId,
6463
+ }),
6464
+ });
6465
+ await throwIfNotOk(response, "POST", url.toString());
6466
+ }
6467
+ async cancelProcessedMultipartUpload(args) {
6468
+ const url = this.urlFor("/cancelUpload");
6469
+ const headers = await this.createUploadHeaders({ mode: args.mode });
6470
+ const formData = new FormData();
6471
+ formData.append("filePath", args.path);
6472
+ formData.append("uploadId", args.uploadId);
6473
+ const response = await this.fetchImpl(url.toString(), {
6474
+ method: "POST",
6475
+ headers,
6476
+ body: formData,
6477
+ });
6478
+ await throwIfNotOk(response, "POST", url.toString());
6479
+ }
6480
+ async runWithRetry(args) {
6481
+ var _a;
6482
+ let lastError;
6483
+ for (let attempt = 1; attempt <= args.attempts; attempt++) {
6484
+ try {
6485
+ return await args.operation();
6486
+ }
6487
+ catch (error) {
6488
+ lastError = error;
6489
+ if (attempt >= args.attempts || !isRetryableError(error)) {
6490
+ break;
6491
+ }
6492
+ const nextAttempt = attempt + 1;
6493
+ (_a = args.onRetry) === null || _a === void 0 ? void 0 : _a.call(args, nextAttempt, error);
6494
+ await this.sleep(this.getRetryDelay(attempt));
6495
+ }
6496
+ }
6497
+ throw lastError instanceof Error ? lastError : new Error(String(lastError));
6498
+ }
6499
+ getRetryDelay(attempt) {
6500
+ const exponentialDelay = this.retryBaseDelayMs * Math.pow(2, attempt - 1);
6501
+ const jitter = Math.floor(this.random() * this.retryBaseDelayMs);
6502
+ return exponentialDelay + jitter;
6503
+ }
6504
+ async createBaseHeaders() {
6505
+ const token = await this.getFirebaseToken();
6506
+ const headers = new Headers();
6507
+ headers.set("Authorization", `Bearer ${token}`);
6508
+ return headers;
6509
+ }
6510
+ async createUploadHeaders(args) {
6511
+ const headers = await this.createBaseHeaders();
6512
+ headers.set("X-Market-Id", this.marketId);
6513
+ headers.set("X-Asset-Mode", args.mode);
6514
+ if (typeof args.overwrite === "boolean") {
6515
+ headers.set("X-Overwrite", String(args.overwrite));
6516
+ }
6517
+ if (args.contentType) {
6518
+ headers.set("Content-Type", args.contentType);
6519
+ }
6520
+ return headers;
6521
+ }
6522
+ assertPathMatchesMarket(path) {
6523
+ const pathMarketId = path.split("/")[0];
6524
+ if (pathMarketId !== this.marketId) {
6525
+ throw new Error(`Upload path must start with marketId "${this.marketId}". Received "${pathMarketId}".`);
6526
+ }
6527
+ }
6528
+ urlFor(path) {
6529
+ return new URL(path.replace(/^\/+/, ""), `${this.baseUrl}/`);
6530
+ }
6531
+ }
6532
+ function resolveMediaCrateBaseUrl(opts) {
6533
+ if (typeof opts.baseUrl === "string") {
6534
+ return normalizeBaseUrl(opts.baseUrl, "baseUrl");
6535
+ }
6536
+ return getMediaCrateBaseUrlFromEnv();
6537
+ }
6538
+ function getMediaCrateBaseUrlFromEnv(env = getProjectEnv()) {
6539
+ for (const envVarName of MEDIA_CRATE_V2_BASE_URL_ENV_VARS) {
6540
+ const value = env[envVarName];
6541
+ if (typeof value !== "undefined") {
6542
+ return normalizeBaseUrl(value, envVarName);
6543
+ }
6544
+ }
6545
+ throw new Error(`Media Crate base URL is required. Pass baseUrl to MediaCrateClient or set one of these environment variables in the host project: ${MEDIA_CRATE_V2_BASE_URL_ENV_VARS.join(", ")}.`);
6546
+ }
6547
+ function getProjectEnv() {
6548
+ var _a;
6549
+ const globalWithProcess = globalThis;
6550
+ const processEnv = (_a = globalWithProcess.process) === null || _a === void 0 ? void 0 : _a.env;
6551
+ const env = {};
6552
+ for (const envVarName of MEDIA_CRATE_V2_BASE_URL_ENV_VARS) {
6553
+ env[envVarName] = processEnv === null || processEnv === void 0 ? void 0 : processEnv[envVarName];
6554
+ }
6555
+ return env;
6556
+ }
6557
+ function normalizeBaseUrl(baseUrl, sourceLabel) {
6558
+ const trimmedBaseUrl = baseUrl.trim();
6559
+ if (!trimmedBaseUrl) {
6560
+ throw new Error(`Media Crate ${sourceLabel} must not be empty`);
6561
+ }
6562
+ return trimmedBaseUrl.replace(/\/+$/, "");
6563
+ }
6564
+ function normalizeUploadPath(path) {
6565
+ const normalizedPath = path.trim().replace(/^\/+/, "");
6566
+ if (!normalizedPath) {
6567
+ throw new Error("Upload path is required");
6568
+ }
6569
+ return normalizedPath;
6570
+ }
6571
+ function normalizeUploadPathSegment(segment, label) {
6572
+ const normalizedSegment = segment.trim().replace(/^\/+|\/+$/g, "");
6573
+ if (!normalizedSegment) {
6574
+ throw new Error(`${label} is required`);
6575
+ }
6576
+ if (normalizedSegment.includes("/")) {
6577
+ throw new Error(`${label} must not contain slashes`);
6578
+ }
6579
+ return normalizedSegment;
6580
+ }
6581
+ function assertValidChunkSize(chunkSize) {
6582
+ if (!Number.isFinite(chunkSize) || chunkSize <= 0) {
6583
+ throw new Error("Multipart chunk size must be greater than zero");
6584
+ }
6585
+ if (chunkSize > MEDIA_CRATE_MULTIPART_MAX_CHUNK_BYTES) {
6586
+ throw new Error(`Multipart chunk size must be <= ${MEDIA_CRATE_MULTIPART_MAX_CHUNK_BYTES} bytes`);
6587
+ }
6588
+ }
6589
+ function getGlobalFetch() {
6590
+ if (typeof fetch === "undefined") {
6591
+ throw new Error("fetch is not defined. Please provide fetchImpl.");
6592
+ }
6593
+ return fetch;
6594
+ }
6595
+ function defaultSleep(durationMs) {
6596
+ return new Promise((resolve) => setTimeout(resolve, durationMs));
6597
+ }
6598
+ function copySession(session) {
6599
+ return {
6600
+ ...session,
6601
+ sections: [...session.sections],
6602
+ startResult: session.startResult ? { ...session.startResult } : undefined,
6603
+ };
6604
+ }
6605
+ function getSourceFingerprint(source) {
6606
+ var _a, _b, _c;
6607
+ return [
6608
+ (_a = source.fingerprint) !== null && _a !== void 0 ? _a : "",
6609
+ source.name,
6610
+ source.size,
6611
+ (_b = source.type) !== null && _b !== void 0 ? _b : "",
6612
+ (_c = source.lastModified) !== null && _c !== void 0 ? _c : "",
6613
+ ].join("|");
6614
+ }
6615
+ function createMultipartSessionKey(args) {
6616
+ return [
6617
+ args.baseUrl,
6618
+ args.marketId,
6619
+ args.mode,
6620
+ args.path,
6621
+ getSourceFingerprint(args.source),
6622
+ args.chunkSize,
6623
+ args.overwrite,
6624
+ ].join("|");
6625
+ }
6626
+ function createPendingPartNumbers(totalParts, completedPartNumbers) {
6627
+ const pending = [];
6628
+ for (let partNumber = 1; partNumber <= totalParts; partNumber++) {
6629
+ if (!completedPartNumbers.has(partNumber)) {
6630
+ pending.push(partNumber);
6631
+ }
6632
+ }
6633
+ return pending;
6634
+ }
6635
+ function getPartSize(args) {
6636
+ const start = args.chunkSize * (args.partNumber - 1);
6637
+ const end = Math.min(args.sourceSize, start + args.chunkSize);
6638
+ return Math.max(0, end - start);
6639
+ }
6640
+ function getCompletedBytes(args) {
6641
+ let bytes = 0;
6642
+ for (let partNumber of args.completedPartNumbers) {
6643
+ bytes += getPartSize({
6644
+ partNumber,
6645
+ sourceSize: args.sourceSize,
6646
+ chunkSize: args.chunkSize,
6647
+ });
6648
+ }
6649
+ return bytes;
6650
+ }
6651
+ function sortSections(sections) {
6652
+ return [...sections].sort((a, b) => Number(a.partNumber) - Number(b.partNumber));
6653
+ }
6654
+ function appendUploadPart(formData, fieldName, partBody, fileName, mimeType) {
6655
+ if (isReactNativeFormDataFile(partBody)) {
6656
+ formData.append(fieldName, partBody);
6657
+ return;
6658
+ }
6659
+ if (typeof Blob !== "undefined" && partBody instanceof Blob) {
6660
+ formData.append(fieldName, partBody, fileName);
6661
+ return;
6662
+ }
6663
+ if (partBody instanceof ArrayBuffer || partBody instanceof Uint8Array) {
6664
+ formData.append(fieldName, new Blob([partBody], {
6665
+ type: mimeType !== null && mimeType !== void 0 ? mimeType : "application/octet-stream",
6666
+ }), fileName);
6667
+ return;
6668
+ }
6669
+ formData.append(fieldName, partBody);
6670
+ }
6671
+ function isReactNativeFormDataFile(value) {
6672
+ return (typeof value === "object" &&
6673
+ value !== null &&
6674
+ !(typeof Blob !== "undefined" && value instanceof Blob) &&
6675
+ !(value instanceof ArrayBuffer) &&
6676
+ !(value instanceof Uint8Array) &&
6677
+ typeof value.uri === "string");
6678
+ }
6679
+ function getMediaCrateUrls(source) {
6680
+ if ("expected" in source) {
6681
+ return source.expected;
6682
+ }
6683
+ if ("urls" in source) {
6684
+ return source.urls;
6685
+ }
6686
+ return source;
6687
+ }
6688
+ function getMultipartUploadId(response) {
6689
+ if ("uploadId" in response && typeof response.uploadId === "string") {
6690
+ return response.uploadId;
6691
+ }
6692
+ if ("data" in response &&
6693
+ response.data &&
6694
+ typeof response.data.uploadId === "string") {
6695
+ return response.data.uploadId;
6696
+ }
6697
+ return undefined;
6698
+ }
6699
+ function getMultipartTargetKey(response) {
6700
+ if ("targetKey" in response && typeof response.targetKey === "string") {
6701
+ return response.targetKey;
6702
+ }
6703
+ if ("data" in response &&
6704
+ response.data &&
6705
+ typeof response.data.key === "string") {
6706
+ return response.data.key;
6707
+ }
6708
+ return undefined;
6709
+ }
6710
+ function getMultipartPartEtag(response) {
6711
+ if ("data" in response) {
6712
+ return response.data.eTag;
6713
+ }
6714
+ return response.eTag;
6715
+ }
6716
+ function getMultipartPartNumber(response) {
6717
+ if ("data" in response) {
6718
+ return response.data.partNumber;
6719
+ }
6720
+ return response.partNumber;
6721
+ }
6722
+ function hasUploadResultShape(value) {
6723
+ if (!value || typeof value !== "object") {
6724
+ return false;
6725
+ }
6726
+ const maybeUploadResult = value;
6727
+ return (typeof maybeUploadResult.assetId === "string" &&
6728
+ typeof maybeUploadResult.statusUrl === "string" &&
6729
+ typeof maybeUploadResult.status === "string" &&
6730
+ typeof maybeUploadResult.expected === "object" &&
6731
+ maybeUploadResult.expected !== null);
6732
+ }
6733
+ async function throwIfNotOk(response, method, url) {
6734
+ if (response.ok) {
6735
+ return;
6736
+ }
6737
+ const responseText = await response.text().catch(() => "");
6738
+ let body = responseText || null;
6739
+ if (responseText) {
6740
+ try {
6741
+ body = JSON.parse(responseText);
6742
+ }
6743
+ catch (_error) {
6744
+ body = responseText;
6745
+ }
6746
+ }
6747
+ const message = typeof body === "object" && body !== null && "message" in body
6748
+ ? String(body.message)
6749
+ : responseText || response.statusText || `Media Crate request failed`;
6750
+ const collidingKeys = typeof body === "object" &&
6751
+ body !== null &&
6752
+ Array.isArray(body.collidingKeys)
6753
+ ? body.collidingKeys
6754
+ : undefined;
6755
+ throw new MediaCrateHttpError({
6756
+ status: response.status,
6757
+ method,
6758
+ url,
6759
+ message,
6760
+ body,
6761
+ collidingKeys,
6762
+ });
6763
+ }
6764
+ function isRetryableError(error) {
6765
+ if (error instanceof MediaCrateHttpError) {
6766
+ return error.status === 429 || error.status >= 500;
6767
+ }
6768
+ return true;
6769
+ }
6770
+ function shouldForgetMultipartSession(error) {
6771
+ return (error instanceof MediaCrateHttpError &&
6772
+ (error.status === 404 || error.status === 409));
6773
+ }
6774
+
6364
6775
  class EarTag {
6365
6776
  static get countryCodesByNumber() {
6366
6777
  let reversed = {};
@@ -6811,11 +7222,26 @@ function incrementAlphaSequence(alpha) {
6811
7222
 
6812
7223
  exports.CattlePassport = CattlePassport;
6813
7224
  exports.EarTag = EarTag;
7225
+ exports.InMemoryMediaCrateMultipartSessionStore = InMemoryMediaCrateMultipartSessionStore;
7226
+ exports.MEDIA_CRATE_ASSET_STATUSES = MEDIA_CRATE_ASSET_STATUSES;
7227
+ exports.MEDIA_CRATE_DEFAULT_CHUNK_BYTES = MEDIA_CRATE_DEFAULT_CHUNK_BYTES;
7228
+ exports.MEDIA_CRATE_MEDIA_STATUSES = MEDIA_CRATE_MEDIA_STATUSES;
7229
+ exports.MEDIA_CRATE_MULTIPART_MAX_CHUNK_BYTES = MEDIA_CRATE_MULTIPART_MAX_CHUNK_BYTES;
7230
+ exports.MEDIA_CRATE_SINGLE_UPLOAD_MAX_BYTES = MEDIA_CRATE_SINGLE_UPLOAD_MAX_BYTES;
7231
+ exports.MEDIA_CRATE_V2_BASE_URL_ENV_VARS = MEDIA_CRATE_V2_BASE_URL_ENV_VARS;
7232
+ exports.MediaCrateClient = MediaCrateClient;
7233
+ exports.MediaCrateHttpError = MediaCrateHttpError;
7234
+ exports.MediaCrateUploadSourceError = MediaCrateUploadSourceError;
6814
7235
  exports.Studio = Studio;
6815
7236
  exports.StudioHeaders = StudioHeaders;
6816
7237
  exports.StudioTypes = types;
6817
7238
  exports.createAppManifest = createAppManifest;
7239
+ exports.createWebUploadSource = createWebUploadSource;
6818
7240
  exports.default = Studio;
7241
+ exports.getMediaCrateBaseUrlFromEnv = getMediaCrateBaseUrlFromEnv;
7242
+ exports.getMediaCrateVariant = getMediaCrateVariant;
7243
+ exports.getMediaCrateVariantUrl = getMediaCrateVariantUrl;
6819
7244
  exports.lotComparator = lotComparator;
6820
7245
  exports.nextLotNumber = nextLotNumber;
7246
+ exports.requireMediaCrateVariantUrl = requireMediaCrateVariantUrl;
6821
7247
  exports.sortByLotNumber = sortByLotNumber;