@commercetools-frontend-extensions/operations 3.2.0 → 3.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @commercetools-frontend-extensions/operations
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1699](https://github.com/commercetools/merchant-center-operations/pull/1699) [`d93cfd9`](https://github.com/commercetools/merchant-center-operations/commit/d93cfd9c2aa82779ec4c1eafeccde4ca930c143a) Thanks [@Sarah4VT](https://github.com/Sarah4VT)! - Update Jest to v30
8
+
9
+ ## 3.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1690](https://github.com/commercetools/merchant-center-operations/pull/1690) [`4a83020`](https://github.com/commercetools/merchant-center-operations/commit/4a83020117a46aba524ef16df0768b1bcaa42934) Thanks [@yassinejebli](https://github.com/yassinejebli)! - style(import): adjust spacing under Progress bar
14
+
3
15
  ## 3.2.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -33,9 +33,8 @@ const { upload, isUploading, progress, validationProgress } = useFileUpload({
33
33
  - `upload` - Function to start the upload
34
34
  - `isUploading` - Whether upload is in progress
35
35
  - `progress` - Upload progress (0-100)
36
- - `validationProgress` - `{ processed: number, total: number, isValidating: boolean }` (job-based flow only)
36
+ - `validationProgress` - `{ processed: number, isValidating: boolean }` (job-based flow only)
37
37
  - `processed`: Number of resources validated so far (from backend)
38
- - `total`: Total number of unique resources in the file (counted by unique keys in the CSV)
39
38
  - `isValidating`: Whether validation is in progress
40
39
 
41
40
  **Upload config options:**
@@ -31,13 +31,10 @@ var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
31
31
  var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
32
32
  var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
33
33
  var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
34
- var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
35
- var _findIndexInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find-index');
36
- var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
37
- var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
38
34
  var Papa = require('papaparse');
39
35
  var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
40
36
  var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
37
+ var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
41
38
  var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
42
39
  var _setTimeout = require('@babel/runtime-corejs3/core-js-stable/set-timeout');
43
40
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
@@ -74,13 +71,10 @@ var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
74
71
  var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
75
72
  var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
76
73
  var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
77
- var _Set__default = /*#__PURE__*/_interopDefault(_Set);
78
- var _findIndexInstanceProperty__default = /*#__PURE__*/_interopDefault(_findIndexInstanceProperty);
79
- var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
80
- var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
81
74
  var Papa__default = /*#__PURE__*/_interopDefault(Papa);
82
75
  var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
83
76
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
77
+ var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
84
78
  var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
85
79
  var _setTimeout__default = /*#__PURE__*/_interopDefault(_setTimeout);
86
80
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
@@ -486,7 +480,7 @@ function shouldContinuePollingForImportValidation(job) {
486
480
  }
487
481
 
488
482
  function ownKeys$8(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
489
- function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys$8(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys$8(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
483
+ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$8(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$8(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
490
484
 
491
485
  /**
492
486
  * Convert megabytes to bytes
@@ -605,44 +599,6 @@ const countJsonFileItems = async file => {
605
599
  }
606
600
  };
607
601
 
608
- /**
609
- * Count unique resources in a CSV file by counting unique values in the "key" column.
610
- * A single resource can span multiple rows (when it has array fields like variants, assets...),
611
- * so we count unique keys rather than rows.
612
- * @param file The CSV file to process
613
- * @returns A promise that resolves to the number of unique resources
614
- */
615
- const countUniqueResourcesInCsv = file => {
616
- return new _Promise__default["default"](resolve => {
617
- const uniqueKeys = new _Set__default["default"]();
618
- let keyColumnIndex = -1;
619
- let isFirstRow = true;
620
- Papa__default["default"].parse(file, {
621
- step: _ref2 => {
622
- var _context4, _context5;
623
- let data = _ref2.data;
624
- if (!_Array$isArray__default["default"](data)) return;
625
- if (isFirstRow) {
626
- keyColumnIndex = _findIndexInstanceProperty__default["default"](data).call(data, col => {
627
- var _context2, _context3;
628
- return ((_context2 = col?.toLowerCase()) == null ? void 0 : _bindInstanceProperty__default["default"](_context3 = Function.call).call(_context3, _trimInstanceProperty__default["default"](_context2), _context2))?.() === 'key';
629
- });
630
- isFirstRow = false;
631
- return;
632
- }
633
- if (keyColumnIndex === -1) return;
634
- const keyValue = ((_context4 = data[keyColumnIndex]) == null ? void 0 : _bindInstanceProperty__default["default"](_context5 = Function.call).call(_context5, _trimInstanceProperty__default["default"](_context4), _context4))?.();
635
- if (keyValue) {
636
- uniqueKeys.add(keyValue);
637
- }
638
- },
639
- complete: () => {
640
- resolve(uniqueKeys.size);
641
- }
642
- });
643
- });
644
- };
645
-
646
602
  /**
647
603
  * Map file upload errors to upload file error rows with unique IDs
648
604
  * @param uploadFileErrors Array of file upload errors
@@ -1178,10 +1134,12 @@ async function getFileImportJobInfoForContainer(_ref7) {
1178
1134
  limit: 1
1179
1135
  });
1180
1136
  if (response.results.length > 0 && response.results[0].summary?.total != null) {
1137
+ var _context;
1181
1138
  const job = response.results[0];
1139
+ const isInitializing = _includesInstanceProperty__default["default"](_context = ['processing', 'initialising']).call(_context, job.state);
1182
1140
  return {
1183
1141
  total: job.summary.total,
1184
- isInitializing: job.state === 'initialising'
1142
+ isInitializing
1185
1143
  };
1186
1144
  }
1187
1145
  return null;
@@ -2660,13 +2618,16 @@ const UploadingModal = _ref => {
2660
2618
  label: cancelLabel,
2661
2619
  onClick: onCancel
2662
2620
  })]
2663
- }), /*#__PURE__*/jsxRuntime.jsx(uiKit.ProgressBar, {
2664
- barWidth: "scale",
2665
- height: "10",
2666
- progress: progress
2667
- }), statusMessage && /*#__PURE__*/jsxRuntime.jsx(uiKit.Text.Detail, {
2668
- tone: "tertiary",
2669
- children: statusMessage
2621
+ }), /*#__PURE__*/jsxRuntime.jsxs(uiKit.Spacings.Stack, {
2622
+ scale: "xs",
2623
+ children: [/*#__PURE__*/jsxRuntime.jsx(uiKit.ProgressBar, {
2624
+ barWidth: "scale",
2625
+ height: "10",
2626
+ progress: progress
2627
+ }), statusMessage && /*#__PURE__*/jsxRuntime.jsx(uiKit.Text.Detail, {
2628
+ tone: "tertiary",
2629
+ children: statusMessage
2630
+ })]
2670
2631
  })]
2671
2632
  })
2672
2633
  });
@@ -3089,7 +3050,6 @@ const useFileUpload = _ref2 => {
3089
3050
  setProgress = _React$useState4[1];
3090
3051
  const _React$useState5 = React__default["default"].useState({
3091
3052
  processed: 0,
3092
- total: 0,
3093
3053
  isValidating: false
3094
3054
  }),
3095
3055
  _React$useState6 = _slicedToArray(_React$useState5, 2),
@@ -3106,7 +3066,6 @@ const useFileUpload = _ref2 => {
3106
3066
  setProgress(0);
3107
3067
  setValidationProgress({
3108
3068
  processed: 0,
3109
- total: 0,
3110
3069
  isValidating: false
3111
3070
  });
3112
3071
  }, []);
@@ -3115,7 +3074,6 @@ const useFileUpload = _ref2 => {
3115
3074
  setProgress(0);
3116
3075
  try {
3117
3076
  if (useJobBasedFlow) {
3118
- const totalResources = config.skipValidationPolling ? 0 : await countUniqueResourcesInCsv(config.file);
3119
3077
  await jobUpload.upload({
3120
3078
  file: config.file,
3121
3079
  resourceType: config.resourceType,
@@ -3162,7 +3120,6 @@ const useFileUpload = _ref2 => {
3162
3120
  try {
3163
3121
  setValidationProgress({
3164
3122
  processed: 0,
3165
- total: totalResources,
3166
3123
  isValidating: true
3167
3124
  });
3168
3125
  const validatedJob = await pollJobUntilValidated({
@@ -3176,7 +3133,6 @@ const useFileUpload = _ref2 => {
3176
3133
  const processed = job.summary?.total ?? 0;
3177
3134
  setValidationProgress({
3178
3135
  processed,
3179
- total: totalResources,
3180
3136
  isValidating: true
3181
3137
  });
3182
3138
  config.onValidationProgress?.(job);
@@ -3206,7 +3162,6 @@ const useFileUpload = _ref2 => {
3206
3162
  setIsUploading(false);
3207
3163
  setValidationProgress({
3208
3164
  processed: 0,
3209
- total: 0,
3210
3165
  isValidating: false
3211
3166
  });
3212
3167
  config.onSuccess(result);
@@ -3349,7 +3304,6 @@ exports.cancelImportContainerByKey = cancelImportContainerByKey;
3349
3304
  exports.checkIfFileUploadImport = checkIfFileUploadImport;
3350
3305
  exports.convertFileSizeToKB = convertFileSizeToKB;
3351
3306
  exports.countJsonFileItems = countJsonFileItems;
3352
- exports.countUniqueResourcesInCsv = countUniqueResourcesInCsv;
3353
3307
  exports.createFileImportJob = createFileImportJob;
3354
3308
  exports.createImportContainerForFileUpload = createImportContainerForFileUpload;
3355
3309
  exports.decodeFileNameFromImportContainerKey = decodeFileNameFromImportContainerKey;
@@ -31,13 +31,10 @@ var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
31
31
  var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
32
32
  var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
33
33
  var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
34
- var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
35
- var _findIndexInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find-index');
36
- var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
37
- var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
38
34
  var Papa = require('papaparse');
39
35
  var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
40
36
  var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
37
+ var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
41
38
  var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
42
39
  var _setTimeout = require('@babel/runtime-corejs3/core-js-stable/set-timeout');
43
40
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
@@ -74,13 +71,10 @@ var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
74
71
  var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
75
72
  var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
76
73
  var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
77
- var _Set__default = /*#__PURE__*/_interopDefault(_Set);
78
- var _findIndexInstanceProperty__default = /*#__PURE__*/_interopDefault(_findIndexInstanceProperty);
79
- var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
80
- var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
81
74
  var Papa__default = /*#__PURE__*/_interopDefault(Papa);
82
75
  var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
83
76
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
77
+ var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
84
78
  var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
85
79
  var _setTimeout__default = /*#__PURE__*/_interopDefault(_setTimeout);
86
80
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
@@ -486,7 +480,7 @@ function shouldContinuePollingForImportValidation(job) {
486
480
  }
487
481
 
488
482
  function ownKeys$8(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
489
- function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys$8(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys$8(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
483
+ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$8(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$8(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
490
484
 
491
485
  /**
492
486
  * Convert megabytes to bytes
@@ -605,44 +599,6 @@ const countJsonFileItems = async file => {
605
599
  }
606
600
  };
607
601
 
608
- /**
609
- * Count unique resources in a CSV file by counting unique values in the "key" column.
610
- * A single resource can span multiple rows (when it has array fields like variants, assets...),
611
- * so we count unique keys rather than rows.
612
- * @param file The CSV file to process
613
- * @returns A promise that resolves to the number of unique resources
614
- */
615
- const countUniqueResourcesInCsv = file => {
616
- return new _Promise__default["default"](resolve => {
617
- const uniqueKeys = new _Set__default["default"]();
618
- let keyColumnIndex = -1;
619
- let isFirstRow = true;
620
- Papa__default["default"].parse(file, {
621
- step: _ref2 => {
622
- var _context4, _context5;
623
- let data = _ref2.data;
624
- if (!_Array$isArray__default["default"](data)) return;
625
- if (isFirstRow) {
626
- keyColumnIndex = _findIndexInstanceProperty__default["default"](data).call(data, col => {
627
- var _context2, _context3;
628
- return ((_context2 = col?.toLowerCase()) == null ? void 0 : _bindInstanceProperty__default["default"](_context3 = Function.call).call(_context3, _trimInstanceProperty__default["default"](_context2), _context2))?.() === 'key';
629
- });
630
- isFirstRow = false;
631
- return;
632
- }
633
- if (keyColumnIndex === -1) return;
634
- const keyValue = ((_context4 = data[keyColumnIndex]) == null ? void 0 : _bindInstanceProperty__default["default"](_context5 = Function.call).call(_context5, _trimInstanceProperty__default["default"](_context4), _context4))?.();
635
- if (keyValue) {
636
- uniqueKeys.add(keyValue);
637
- }
638
- },
639
- complete: () => {
640
- resolve(uniqueKeys.size);
641
- }
642
- });
643
- });
644
- };
645
-
646
602
  /**
647
603
  * Map file upload errors to upload file error rows with unique IDs
648
604
  * @param uploadFileErrors Array of file upload errors
@@ -1178,10 +1134,12 @@ async function getFileImportJobInfoForContainer(_ref7) {
1178
1134
  limit: 1
1179
1135
  });
1180
1136
  if (response.results.length > 0 && response.results[0].summary?.total != null) {
1137
+ var _context;
1181
1138
  const job = response.results[0];
1139
+ const isInitializing = _includesInstanceProperty__default["default"](_context = ['processing', 'initialising']).call(_context, job.state);
1182
1140
  return {
1183
1141
  total: job.summary.total,
1184
- isInitializing: job.state === 'initialising'
1142
+ isInitializing
1185
1143
  };
1186
1144
  }
1187
1145
  return null;
@@ -2652,13 +2610,16 @@ const UploadingModal = _ref => {
2652
2610
  label: cancelLabel,
2653
2611
  onClick: onCancel
2654
2612
  })]
2655
- }), /*#__PURE__*/jsxRuntime.jsx(uiKit.ProgressBar, {
2656
- barWidth: "scale",
2657
- height: "10",
2658
- progress: progress
2659
- }), statusMessage && /*#__PURE__*/jsxRuntime.jsx(uiKit.Text.Detail, {
2660
- tone: "tertiary",
2661
- children: statusMessage
2613
+ }), /*#__PURE__*/jsxRuntime.jsxs(uiKit.Spacings.Stack, {
2614
+ scale: "xs",
2615
+ children: [/*#__PURE__*/jsxRuntime.jsx(uiKit.ProgressBar, {
2616
+ barWidth: "scale",
2617
+ height: "10",
2618
+ progress: progress
2619
+ }), statusMessage && /*#__PURE__*/jsxRuntime.jsx(uiKit.Text.Detail, {
2620
+ tone: "tertiary",
2621
+ children: statusMessage
2622
+ })]
2662
2623
  })]
2663
2624
  })
2664
2625
  });
@@ -3081,7 +3042,6 @@ const useFileUpload = _ref2 => {
3081
3042
  setProgress = _React$useState4[1];
3082
3043
  const _React$useState5 = React__default["default"].useState({
3083
3044
  processed: 0,
3084
- total: 0,
3085
3045
  isValidating: false
3086
3046
  }),
3087
3047
  _React$useState6 = _slicedToArray(_React$useState5, 2),
@@ -3098,7 +3058,6 @@ const useFileUpload = _ref2 => {
3098
3058
  setProgress(0);
3099
3059
  setValidationProgress({
3100
3060
  processed: 0,
3101
- total: 0,
3102
3061
  isValidating: false
3103
3062
  });
3104
3063
  }, []);
@@ -3107,7 +3066,6 @@ const useFileUpload = _ref2 => {
3107
3066
  setProgress(0);
3108
3067
  try {
3109
3068
  if (useJobBasedFlow) {
3110
- const totalResources = config.skipValidationPolling ? 0 : await countUniqueResourcesInCsv(config.file);
3111
3069
  await jobUpload.upload({
3112
3070
  file: config.file,
3113
3071
  resourceType: config.resourceType,
@@ -3154,7 +3112,6 @@ const useFileUpload = _ref2 => {
3154
3112
  try {
3155
3113
  setValidationProgress({
3156
3114
  processed: 0,
3157
- total: totalResources,
3158
3115
  isValidating: true
3159
3116
  });
3160
3117
  const validatedJob = await pollJobUntilValidated({
@@ -3168,7 +3125,6 @@ const useFileUpload = _ref2 => {
3168
3125
  const processed = job.summary?.total ?? 0;
3169
3126
  setValidationProgress({
3170
3127
  processed,
3171
- total: totalResources,
3172
3128
  isValidating: true
3173
3129
  });
3174
3130
  config.onValidationProgress?.(job);
@@ -3198,7 +3154,6 @@ const useFileUpload = _ref2 => {
3198
3154
  setIsUploading(false);
3199
3155
  setValidationProgress({
3200
3156
  processed: 0,
3201
- total: 0,
3202
3157
  isValidating: false
3203
3158
  });
3204
3159
  config.onSuccess(result);
@@ -3341,7 +3296,6 @@ exports.cancelImportContainerByKey = cancelImportContainerByKey;
3341
3296
  exports.checkIfFileUploadImport = checkIfFileUploadImport;
3342
3297
  exports.convertFileSizeToKB = convertFileSizeToKB;
3343
3298
  exports.countJsonFileItems = countJsonFileItems;
3344
- exports.countUniqueResourcesInCsv = countUniqueResourcesInCsv;
3345
3299
  exports.createFileImportJob = createFileImportJob;
3346
3300
  exports.createImportContainerForFileUpload = createImportContainerForFileUpload;
3347
3301
  exports.decodeFileNameFromImportContainerKey = decodeFileNameFromImportContainerKey;
@@ -27,13 +27,10 @@ import _Promise from '@babel/runtime-corejs3/core-js-stable/promise';
27
27
  import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
28
28
  import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
29
29
  import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
30
- import _Set from '@babel/runtime-corejs3/core-js-stable/set';
31
- import _findIndexInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find-index';
32
- import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
33
- import _bindInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/bind';
34
30
  import Papa from 'papaparse';
35
31
  import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
36
32
  import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
33
+ import _bindInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/bind';
37
34
  import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
38
35
  import _setTimeout from '@babel/runtime-corejs3/core-js-stable/set-timeout';
39
36
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
@@ -446,7 +443,7 @@ function shouldContinuePollingForImportValidation(job) {
446
443
  }
447
444
 
448
445
  function ownKeys$8(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
449
- function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys$8(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys$8(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
446
+ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$8(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$8(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
450
447
 
451
448
  /**
452
449
  * Convert megabytes to bytes
@@ -565,44 +562,6 @@ const countJsonFileItems = async file => {
565
562
  }
566
563
  };
567
564
 
568
- /**
569
- * Count unique resources in a CSV file by counting unique values in the "key" column.
570
- * A single resource can span multiple rows (when it has array fields like variants, assets...),
571
- * so we count unique keys rather than rows.
572
- * @param file The CSV file to process
573
- * @returns A promise that resolves to the number of unique resources
574
- */
575
- const countUniqueResourcesInCsv = file => {
576
- return new _Promise(resolve => {
577
- const uniqueKeys = new _Set();
578
- let keyColumnIndex = -1;
579
- let isFirstRow = true;
580
- Papa.parse(file, {
581
- step: _ref2 => {
582
- var _context4, _context5;
583
- let data = _ref2.data;
584
- if (!_Array$isArray(data)) return;
585
- if (isFirstRow) {
586
- keyColumnIndex = _findIndexInstanceProperty(data).call(data, col => {
587
- var _context2, _context3;
588
- return ((_context2 = col?.toLowerCase()) == null ? void 0 : _bindInstanceProperty(_context3 = Function.call).call(_context3, _trimInstanceProperty(_context2), _context2))?.() === 'key';
589
- });
590
- isFirstRow = false;
591
- return;
592
- }
593
- if (keyColumnIndex === -1) return;
594
- const keyValue = ((_context4 = data[keyColumnIndex]) == null ? void 0 : _bindInstanceProperty(_context5 = Function.call).call(_context5, _trimInstanceProperty(_context4), _context4))?.();
595
- if (keyValue) {
596
- uniqueKeys.add(keyValue);
597
- }
598
- },
599
- complete: () => {
600
- resolve(uniqueKeys.size);
601
- }
602
- });
603
- });
604
- };
605
-
606
565
  /**
607
566
  * Map file upload errors to upload file error rows with unique IDs
608
567
  * @param uploadFileErrors Array of file upload errors
@@ -1138,10 +1097,12 @@ async function getFileImportJobInfoForContainer(_ref7) {
1138
1097
  limit: 1
1139
1098
  });
1140
1099
  if (response.results.length > 0 && response.results[0].summary?.total != null) {
1100
+ var _context;
1141
1101
  const job = response.results[0];
1102
+ const isInitializing = _includesInstanceProperty(_context = ['processing', 'initialising']).call(_context, job.state);
1142
1103
  return {
1143
1104
  total: job.summary.total,
1144
- isInitializing: job.state === 'initialising'
1105
+ isInitializing
1145
1106
  };
1146
1107
  }
1147
1108
  return null;
@@ -2620,13 +2581,16 @@ const UploadingModal = _ref => {
2620
2581
  label: cancelLabel,
2621
2582
  onClick: onCancel
2622
2583
  })]
2623
- }), /*#__PURE__*/jsx(ProgressBar, {
2624
- barWidth: "scale",
2625
- height: "10",
2626
- progress: progress
2627
- }), statusMessage && /*#__PURE__*/jsx(Text.Detail, {
2628
- tone: "tertiary",
2629
- children: statusMessage
2584
+ }), /*#__PURE__*/jsxs(Spacings.Stack, {
2585
+ scale: "xs",
2586
+ children: [/*#__PURE__*/jsx(ProgressBar, {
2587
+ barWidth: "scale",
2588
+ height: "10",
2589
+ progress: progress
2590
+ }), statusMessage && /*#__PURE__*/jsx(Text.Detail, {
2591
+ tone: "tertiary",
2592
+ children: statusMessage
2593
+ })]
2630
2594
  })]
2631
2595
  })
2632
2596
  });
@@ -3049,7 +3013,6 @@ const useFileUpload = _ref2 => {
3049
3013
  setProgress = _React$useState4[1];
3050
3014
  const _React$useState5 = React.useState({
3051
3015
  processed: 0,
3052
- total: 0,
3053
3016
  isValidating: false
3054
3017
  }),
3055
3018
  _React$useState6 = _slicedToArray(_React$useState5, 2),
@@ -3066,7 +3029,6 @@ const useFileUpload = _ref2 => {
3066
3029
  setProgress(0);
3067
3030
  setValidationProgress({
3068
3031
  processed: 0,
3069
- total: 0,
3070
3032
  isValidating: false
3071
3033
  });
3072
3034
  }, []);
@@ -3075,7 +3037,6 @@ const useFileUpload = _ref2 => {
3075
3037
  setProgress(0);
3076
3038
  try {
3077
3039
  if (useJobBasedFlow) {
3078
- const totalResources = config.skipValidationPolling ? 0 : await countUniqueResourcesInCsv(config.file);
3079
3040
  await jobUpload.upload({
3080
3041
  file: config.file,
3081
3042
  resourceType: config.resourceType,
@@ -3122,7 +3083,6 @@ const useFileUpload = _ref2 => {
3122
3083
  try {
3123
3084
  setValidationProgress({
3124
3085
  processed: 0,
3125
- total: totalResources,
3126
3086
  isValidating: true
3127
3087
  });
3128
3088
  const validatedJob = await pollJobUntilValidated({
@@ -3136,7 +3096,6 @@ const useFileUpload = _ref2 => {
3136
3096
  const processed = job.summary?.total ?? 0;
3137
3097
  setValidationProgress({
3138
3098
  processed,
3139
- total: totalResources,
3140
3099
  isValidating: true
3141
3100
  });
3142
3101
  config.onValidationProgress?.(job);
@@ -3166,7 +3125,6 @@ const useFileUpload = _ref2 => {
3166
3125
  setIsUploading(false);
3167
3126
  setValidationProgress({
3168
3127
  processed: 0,
3169
- total: 0,
3170
3128
  isValidating: false
3171
3129
  });
3172
3130
  config.onSuccess(result);
@@ -3249,4 +3207,4 @@ const useFileUpload = _ref2 => {
3249
3207
  };
3250
3208
  };
3251
3209
 
3252
- export { ActiveDragDropArea, COLUMN_DELIMITERS, CT_API_DOCS_URL, DELIMITERS, DisabledDropArea, DropAreaWrapper, EnabledDropArea, FILE_IMPORT_JOB_POLLING_INTERVAL, FileDropArea, FileDroppedArea, FileIcon, HttpError, IMPORT_LEGACY_MAX_FILE_SIZE_MB, IMPORT_LEGACY_MAX_ROW_COUNT, IMPORT_MAX_FILE_SIZE_MB, IMPORT_MAX_ITEM_COUNT, IMPORT_TAG_KEYS, IMPORT_TAG_VALUES, ImportStates, InfoBox, InvalidResponseError, LockIcon, NoResourcesToExportError, PollingAbortedError, ProjectKeyNotAvailableError, QueryPredicateError, RESOURCE_TYPE_DOCUMENTATION_LINKS, RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS, TAG_KEY_SOURCE_FILE_UPLOAD, UnexpectedColumnError, UnexpectedOperationStateError, UnexpectedResourceTypeError, UploadSeparator, UploadSettings, UploadingModal, allAutomatedImportOperations, allAutomatedImportOperationsResponse, allFileUploadImportOperations, allFileUploadImportOperationsResponse, appendCsvOrJsonExtensionIfAbsent, assertCancelContainerResponse, assertExportOperationsDownloadFileResponse, assertFileImportJob, assertFileImportJobRecordsResponse, assertFileUploadResponse, assertImportContainer, assertImportContainerPagedResponse, assertImportOperationPagedResponse, assertImportSummary, assertListFileImportJobsResponse, assertPaginatedExportOperationResponse, assertProcessFileImportJobResponse, assertProcessFileResponse, assertResourceType, automatedImportContainerKey, automatedImports, cancelImportContainerByKey, checkIfFileUploadImport, convertFileSizeToKB, countJsonFileItems, countUniqueResourcesInCsv, createFileImportJob, createImportContainerForFileUpload, decodeFileNameFromImportContainerKey, deleteFileImportJob, deleteImportContainer, dropAreaStyles, encodeFileNameWithTimestampToContainerKey, exportOperationsCompleted, exportOperationsProcessing, extractErrorDescriptionFromValidationMessage, fetchExportOperations, fetchImportContainerByKey, fetchImportContainerDetails, fetchImportContainers, fetchImportOperations, fetchImportSummaries, fetchImportSummary, fetchUsingXhr, fetcher, fileUploadImportContainerKey, fileUploadMissingKeysResponse, formatErrorCode, formatKeys, formatQueryString, getCreateImportContainerURL, getDeleteImportContainerURL, getExportOperationsURL, getFileImportJob, getFileImportJobByIdURL, getFileImportJobDeleteURL, getFileImportJobFileType, getFileImportJobInfoForContainer, getFileImportJobProcessURL, getFileImportJobRecords, getFileImportJobRecordsURL, getFileImportJobsListURL, getFileImportJobsURL, getFileUploadErrorsCount, getFileUploadURL, getImportContainerByKeyURL, getImportContainerTasksURL, getImportContainersURL, getImportOperationsURL, getImportState, getImportSummaryURL, getMissingRequiredFields, getProccessFileURL, getRowCount, getValidatedColumns, hasImportJobStartedProcessing, hasOwnProperty, hasRequiredFields, hasSingleKeyColumn, importContainers, importStatesMap, importsSummaries, invalidFileImportJobRecordsResponse, invalidFileImportJobValidated, invalidFileUploadResponse, isAbortError, isError, isImportJobInitializing, isImportJobProcessing, isImportJobQueued, isImportJobReady, isImportJobRejected, isImportJobTerminal, isImportJobValidated, isResourceType, listFileImportJobs, manualImports, mapFileUploadErrorsToUploadFileErrorRows, mapFormikErrors, mapUploadFileErrorsResponseToUploadFileErrorRows, pollJobUntilProcessing, pollJobUntilValidated, processFileImportJob, processFileImportJobResponse, processUploadedFile, shouldContinuePollingForImportValidation, successfulAutomatedImportOperations, successfulAutomatedImportOperationsResponse, successfulFileUploadImportOperations, successfulFileUploadImportOperationsResponse, toBytes, toImportApiResourceType, uploadFileForImport, useFetchExportOperations, useFetchFileImportJob, useFetchFileImportJobRecords, useFetchImportContainerDetails, useFetchImportOperations, useFetchImportSummaries, useFileImportJobUpload, useFileUpload, useImportContainerUpload, validFileImportJobProcessing, validFileImportJobQueued, validFileImportJobRecordsResponse, validFileImportJobValidated, validFileUploadResponse, validProcessFileResponse, validateDelimiter };
3210
+ export { ActiveDragDropArea, COLUMN_DELIMITERS, CT_API_DOCS_URL, DELIMITERS, DisabledDropArea, DropAreaWrapper, EnabledDropArea, FILE_IMPORT_JOB_POLLING_INTERVAL, FileDropArea, FileDroppedArea, FileIcon, HttpError, IMPORT_LEGACY_MAX_FILE_SIZE_MB, IMPORT_LEGACY_MAX_ROW_COUNT, IMPORT_MAX_FILE_SIZE_MB, IMPORT_MAX_ITEM_COUNT, IMPORT_TAG_KEYS, IMPORT_TAG_VALUES, ImportStates, InfoBox, InvalidResponseError, LockIcon, NoResourcesToExportError, PollingAbortedError, ProjectKeyNotAvailableError, QueryPredicateError, RESOURCE_TYPE_DOCUMENTATION_LINKS, RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS, TAG_KEY_SOURCE_FILE_UPLOAD, UnexpectedColumnError, UnexpectedOperationStateError, UnexpectedResourceTypeError, UploadSeparator, UploadSettings, UploadingModal, allAutomatedImportOperations, allAutomatedImportOperationsResponse, allFileUploadImportOperations, allFileUploadImportOperationsResponse, appendCsvOrJsonExtensionIfAbsent, assertCancelContainerResponse, assertExportOperationsDownloadFileResponse, assertFileImportJob, assertFileImportJobRecordsResponse, assertFileUploadResponse, assertImportContainer, assertImportContainerPagedResponse, assertImportOperationPagedResponse, assertImportSummary, assertListFileImportJobsResponse, assertPaginatedExportOperationResponse, assertProcessFileImportJobResponse, assertProcessFileResponse, assertResourceType, automatedImportContainerKey, automatedImports, cancelImportContainerByKey, checkIfFileUploadImport, convertFileSizeToKB, countJsonFileItems, createFileImportJob, createImportContainerForFileUpload, decodeFileNameFromImportContainerKey, deleteFileImportJob, deleteImportContainer, dropAreaStyles, encodeFileNameWithTimestampToContainerKey, exportOperationsCompleted, exportOperationsProcessing, extractErrorDescriptionFromValidationMessage, fetchExportOperations, fetchImportContainerByKey, fetchImportContainerDetails, fetchImportContainers, fetchImportOperations, fetchImportSummaries, fetchImportSummary, fetchUsingXhr, fetcher, fileUploadImportContainerKey, fileUploadMissingKeysResponse, formatErrorCode, formatKeys, formatQueryString, getCreateImportContainerURL, getDeleteImportContainerURL, getExportOperationsURL, getFileImportJob, getFileImportJobByIdURL, getFileImportJobDeleteURL, getFileImportJobFileType, getFileImportJobInfoForContainer, getFileImportJobProcessURL, getFileImportJobRecords, getFileImportJobRecordsURL, getFileImportJobsListURL, getFileImportJobsURL, getFileUploadErrorsCount, getFileUploadURL, getImportContainerByKeyURL, getImportContainerTasksURL, getImportContainersURL, getImportOperationsURL, getImportState, getImportSummaryURL, getMissingRequiredFields, getProccessFileURL, getRowCount, getValidatedColumns, hasImportJobStartedProcessing, hasOwnProperty, hasRequiredFields, hasSingleKeyColumn, importContainers, importStatesMap, importsSummaries, invalidFileImportJobRecordsResponse, invalidFileImportJobValidated, invalidFileUploadResponse, isAbortError, isError, isImportJobInitializing, isImportJobProcessing, isImportJobQueued, isImportJobReady, isImportJobRejected, isImportJobTerminal, isImportJobValidated, isResourceType, listFileImportJobs, manualImports, mapFileUploadErrorsToUploadFileErrorRows, mapFormikErrors, mapUploadFileErrorsResponseToUploadFileErrorRows, pollJobUntilProcessing, pollJobUntilValidated, processFileImportJob, processFileImportJobResponse, processUploadedFile, shouldContinuePollingForImportValidation, successfulAutomatedImportOperations, successfulAutomatedImportOperationsResponse, successfulFileUploadImportOperations, successfulFileUploadImportOperationsResponse, toBytes, toImportApiResourceType, uploadFileForImport, useFetchExportOperations, useFetchFileImportJob, useFetchFileImportJobRecords, useFetchImportContainerDetails, useFetchImportOperations, useFetchImportSummaries, useFileImportJobUpload, useFileUpload, useImportContainerUpload, validFileImportJobProcessing, validFileImportJobQueued, validFileImportJobRecordsResponse, validFileImportJobValidated, validFileUploadResponse, validProcessFileResponse, validateDelimiter };
@@ -4,12 +4,12 @@ export declare const fetchUsingXhr: ({ url, payload, config, onProgress, onSucce
4
4
  url: string;
5
5
  payload: FormData;
6
6
  config: {
7
- abortSignal?: AbortSignal | undefined;
8
- proxy?: string | undefined;
7
+ abortSignal?: AbortSignal;
8
+ proxy?: string;
9
9
  method: string;
10
10
  headers?: {
11
11
  [key: string]: string | null;
12
- } | undefined;
12
+ };
13
13
  };
14
14
  onProgress: (progress: number) => void;
15
15
  onSuccess: (data: any) => void;
@@ -2,7 +2,6 @@ import type { ResourceTypeId } from '@commercetools/importapi-sdk';
2
2
  import type { ExtendedImportContainerDraft, FileUploadResult, FileImportJob } from "../@types/index.js";
3
3
  export type ValidationProgress = {
4
4
  processed: number;
5
- total: number;
6
5
  isValidating: boolean;
7
6
  };
8
7
  export type FileUploadConfig = {
@@ -36,19 +36,11 @@ export declare const countJsonFileItems: (file: File) => Promise<{
36
36
  isValid: true;
37
37
  itemsCount: number;
38
38
  }>;
39
- /**
40
- * Count unique resources in a CSV file by counting unique values in the "key" column.
41
- * A single resource can span multiple rows (when it has array fields like variants, assets...),
42
- * so we count unique keys rather than rows.
43
- * @param file The CSV file to process
44
- * @returns A promise that resolves to the number of unique resources
45
- */
46
- export declare const countUniqueResourcesInCsv: (file: File) => Promise<number>;
47
39
  /**
48
40
  * Map file upload errors to upload file error rows with unique IDs
49
41
  * @param uploadFileErrors Array of file upload errors
50
42
  * @returns Array of upload file errors with unique id field
51
43
  */
52
- export declare const mapFileUploadErrorsToUploadFileErrorRows: <T extends Record<string, unknown>>(uploadFileErrors: T[]) => (T & {
44
+ export declare const mapFileUploadErrorsToUploadFileErrorRows: <T extends Record<string, unknown>>(uploadFileErrors: T[]) => Array<T & {
53
45
  id: string;
54
- })[];
46
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend-extensions/operations",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "license": "Proprietary",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -18,19 +18,19 @@
18
18
  "react-dropzone": "14.3.8"
19
19
  },
20
20
  "devDependencies": {
21
- "@commercetools-frontend/actions-global": "24.13.0",
22
- "@commercetools-frontend/application-components": "24.13.0",
23
- "@commercetools-frontend/application-shell": "24.13.0",
24
- "@commercetools-frontend/application-shell-connectors": "24.13.0",
25
- "@commercetools-frontend/constants": "24.13.0",
26
- "@commercetools-frontend/jest-preset-mc-app": "24.13.0",
27
- "@commercetools-frontend/permissions": "24.13.0",
28
- "@commercetools-frontend/sentry": "24.13.0",
21
+ "@commercetools-frontend/actions-global": "25.1.0",
22
+ "@commercetools-frontend/application-components": "25.1.0",
23
+ "@commercetools-frontend/application-shell": "25.1.0",
24
+ "@commercetools-frontend/application-shell-connectors": "25.1.0",
25
+ "@commercetools-frontend/constants": "25.1.0",
26
+ "@commercetools-frontend/jest-preset-mc-app": "25.1.0",
27
+ "@commercetools-frontend/permissions": "25.1.0",
28
+ "@commercetools-frontend/sentry": "25.1.0",
29
29
  "@commercetools-frontend/ui-kit": "20.3.0",
30
30
  "@emotion/react": "11.14.0",
31
31
  "@emotion/styled": "11.14.1",
32
32
  "@testing-library/react": "16.1.0",
33
- "@types/jest": "29.5.14",
33
+ "@types/jest": "30.0.0",
34
34
  "@types/papaparse": "5.5.2",
35
35
  "@types/pluralize": "0.0.33",
36
36
  "@types/react": "19.2.0",
@@ -38,16 +38,16 @@
38
38
  "react": "19.2.0",
39
39
  "react-intl": "7.1.4",
40
40
  "rimraf": "6.1.2",
41
- "typescript": "5.2.2"
41
+ "typescript": "5.4.5"
42
42
  },
43
43
  "peerDependencies": {
44
- "@commercetools-frontend/actions-global": "23.x || 24.x",
45
- "@commercetools-frontend/application-components": "23.x || 24.x",
46
- "@commercetools-frontend/application-shell": "23.x || 24.x",
47
- "@commercetools-frontend/application-shell-connectors": "23.x || 24.x",
48
- "@commercetools-frontend/constants": "23.x || 24.x",
49
- "@commercetools-frontend/permissions": "23.x || 24.x",
50
- "@commercetools-frontend/sentry": "23.x || 24.x",
44
+ "@commercetools-frontend/actions-global": "24.x || 25.x",
45
+ "@commercetools-frontend/application-components": "24.x || 25.x",
46
+ "@commercetools-frontend/application-shell": "24.x || 25.x",
47
+ "@commercetools-frontend/application-shell-connectors": "24.x || 25.x",
48
+ "@commercetools-frontend/constants": "24.x || 25.x",
49
+ "@commercetools-frontend/permissions": "24.x || 25.x",
50
+ "@commercetools-frontend/sentry": "24.x || 25.x",
51
51
  "@commercetools-frontend/ui-kit": "19.x || 20.x",
52
52
  "@emotion/react": "11.x",
53
53
  "@emotion/styled": "11.x",
@@ -255,9 +255,11 @@ export async function getFileImportJobInfoForContainer({
255
255
  response.results[0].summary?.total != null
256
256
  ) {
257
257
  const job = response.results[0]
258
+ const isInitializing = ['processing', 'initialising'].includes(job.state)
259
+
258
260
  return {
259
261
  total: job.summary.total,
260
- isInitializing: job.state === 'initialising',
262
+ isInitializing,
261
263
  }
262
264
  }
263
265
 
@@ -56,10 +56,12 @@ export const UploadingModal = ({
56
56
  onClick={onCancel}
57
57
  />
58
58
  </Spacings.Inline>
59
- <ProgressBar barWidth="scale" height="10" progress={progress} />
60
- {statusMessage && (
61
- <Text.Detail tone="tertiary">{statusMessage}</Text.Detail>
62
- )}
59
+ <Spacings.Stack scale="xs">
60
+ <ProgressBar barWidth="scale" height="10" progress={progress} />
61
+ {statusMessage && (
62
+ <Text.Detail tone="tertiary">{statusMessage}</Text.Detail>
63
+ )}
64
+ </Spacings.Stack>
63
65
  </Spacings.Stack>
64
66
  </InfoDialog>
65
67
  )
@@ -4,11 +4,7 @@ import { useImportContainerUpload } from './use-import-container-upload'
4
4
  import { useFileImportJobUpload } from './use-file-import-job-upload'
5
5
  import { deleteImportContainer } from '../@api'
6
6
  import { HttpError, PollingAbortedError } from '../@errors'
7
- import {
8
- pollJobUntilValidated,
9
- pollJobUntilProcessing,
10
- countUniqueResourcesInCsv,
11
- } from '../@utils'
7
+ import { pollJobUntilValidated, pollJobUntilProcessing } from '../@utils'
12
8
  import type {
13
9
  ExtendedImportContainerDraft,
14
10
  FileUploadResult,
@@ -17,7 +13,6 @@ import type {
17
13
 
18
14
  export type ValidationProgress = {
19
15
  processed: number
20
- total: number
21
16
  isValidating: boolean
22
17
  }
23
18
 
@@ -67,7 +62,6 @@ export const useFileUpload = ({
67
62
  const [validationProgress, setValidationProgress] =
68
63
  React.useState<ValidationProgress>({
69
64
  processed: 0,
70
- total: 0,
71
65
  isValidating: false,
72
66
  })
73
67
 
@@ -77,7 +71,7 @@ export const useFileUpload = ({
77
71
  const resetState = React.useCallback(() => {
78
72
  setIsUploading(false)
79
73
  setProgress(0)
80
- setValidationProgress({ processed: 0, total: 0, isValidating: false })
74
+ setValidationProgress({ processed: 0, isValidating: false })
81
75
  }, [])
82
76
 
83
77
  const upload = React.useCallback(
@@ -87,10 +81,6 @@ export const useFileUpload = ({
87
81
 
88
82
  try {
89
83
  if (useJobBasedFlow) {
90
- const totalResources = config.skipValidationPolling
91
- ? 0
92
- : await countUniqueResourcesInCsv(config.file)
93
-
94
84
  await jobUpload.upload({
95
85
  file: config.file,
96
86
  resourceType: config.resourceType,
@@ -136,7 +126,6 @@ export const useFileUpload = ({
136
126
  try {
137
127
  setValidationProgress({
138
128
  processed: 0,
139
- total: totalResources,
140
129
  isValidating: true,
141
130
  })
142
131
 
@@ -151,7 +140,6 @@ export const useFileUpload = ({
151
140
  const processed = job.summary?.total ?? 0
152
141
  setValidationProgress({
153
142
  processed,
154
- total: totalResources,
155
143
  isValidating: true,
156
144
  })
157
145
  config.onValidationProgress?.(job)
@@ -186,7 +174,6 @@ export const useFileUpload = ({
186
174
  setIsUploading(false)
187
175
  setValidationProgress({
188
176
  processed: 0,
189
- total: 0,
190
177
  isValidating: false,
191
178
  })
192
179
  config.onSuccess(result)
@@ -131,45 +131,6 @@ export const countJsonFileItems = async (
131
131
  }
132
132
  }
133
133
 
134
- /**
135
- * Count unique resources in a CSV file by counting unique values in the "key" column.
136
- * A single resource can span multiple rows (when it has array fields like variants, assets...),
137
- * so we count unique keys rather than rows.
138
- * @param file The CSV file to process
139
- * @returns A promise that resolves to the number of unique resources
140
- */
141
- export const countUniqueResourcesInCsv = (file: File): Promise<number> => {
142
- return new Promise((resolve) => {
143
- const uniqueKeys = new Set<string>()
144
- let keyColumnIndex = -1
145
- let isFirstRow = true
146
-
147
- Papa.parse<string[]>(file, {
148
- step: ({ data }) => {
149
- if (!Array.isArray(data)) return
150
-
151
- if (isFirstRow) {
152
- keyColumnIndex = data.findIndex(
153
- (col) => col?.toLowerCase().trim() === 'key'
154
- )
155
- isFirstRow = false
156
- return
157
- }
158
-
159
- if (keyColumnIndex === -1) return
160
-
161
- const keyValue = data[keyColumnIndex]?.trim()
162
- if (keyValue) {
163
- uniqueKeys.add(keyValue)
164
- }
165
- },
166
- complete: () => {
167
- resolve(uniqueKeys.size)
168
- },
169
- })
170
- })
171
- }
172
-
173
134
  /**
174
135
  * Map file upload errors to upload file error rows with unique IDs
175
136
  * @param uploadFileErrors Array of file upload errors