@commercetools-frontend-extensions/operations 0.0.0-canary-20251211142708 → 0.0.0-canary-20251212163045

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,6 +1,14 @@
1
1
  # @commercetools-frontend-extensions/operations
2
2
 
3
- ## 0.0.0-canary-20251211142708
3
+ ## 0.0.0-canary-20251212163045
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1673](https://github.com/commercetools/merchant-center-operations/pull/1673) [`fda98c9`](https://github.com/commercetools/merchant-center-operations/commit/fda98c935fc45adfffe1247e30bea8c13df2abc8) Thanks [@yassinejebli](https://github.com/yassinejebli)! - feat: add `autoProcess` option for file import job flow
8
+
9
+ - [#1673](https://github.com/commercetools/merchant-center-operations/pull/1673) [`fda98c9`](https://github.com/commercetools/merchant-center-operations/commit/fda98c935fc45adfffe1247e30bea8c13df2abc8) Thanks [@yassinejebli](https://github.com/yassinejebli)! - feat: adjust the max file size for the new Import flow
10
+
11
+ ## 3.1.0
4
12
 
5
13
  ### Minor Changes
6
14
 
package/README.md CHANGED
@@ -27,7 +27,7 @@ const { upload, isUploading, progress, validationProgress } = useFileUpload({
27
27
  - `projectKey` (required): The commercetools project key
28
28
  - `useJobBasedFlow` (optional): Whether to use the job-based flow. Default: `false`
29
29
  - `pollingInterval` (optional): Polling interval in ms for job-based flow. Default: `5000`
30
- - `maxPollingAttempts` (optional): Maximum polling attempts. Default: `120`
30
+ - `maxPollingAttempts` (optional): Maximum polling attempts. Default: `200`
31
31
 
32
32
  **Returns:**
33
33
  - `upload` - Function to start the upload
@@ -38,6 +38,17 @@ const { upload, isUploading, progress, validationProgress } = useFileUpload({
38
38
  - `total`: Total number of unique resources in the file (counted by unique keys in the CSV)
39
39
  - `isValidating`: Whether validation is in progress
40
40
 
41
+ **Upload config options:**
42
+ - `file` (required): The file to upload
43
+ - `resourceType` (required): The resource type
44
+ - `settings` (optional): Import settings (format, decimal separator...)
45
+ - `autoProcess` (optional): When `true`, the backend automatically starts processing after validation completes (job-based flow only). Default: `false`
46
+ - `abortSignal` (optional): AbortSignal for cancellation
47
+ - `onSuccess` (required): Callback when upload completes
48
+ - `onError` (optional): Callback for errors
49
+ - `onProgress` (optional): Callback for upload progress (0-100)
50
+ - `onValidationProgress` (optional): Callback for validation progress (job-based flow only)
51
+
41
52
  **Usage:**
42
53
  ```typescript
43
54
  import { useFileUpload } from '@commercetools-frontend-extensions/operations'
@@ -61,6 +72,7 @@ await upload({
61
72
  unpublishAllChanges?: boolean
62
73
  }
63
74
  },
75
+ autoProcess?: boolean, // job-based flow only, default: false
64
76
  abortSignal: abortController.signal,
65
77
  onSuccess: (result) => {
66
78
  // result.containerKey - Import container key
@@ -742,7 +742,7 @@ const pollJobUntilValidated = async _ref => {
742
742
  _ref$pollingInterval = _ref.pollingInterval,
743
743
  pollingInterval = _ref$pollingInterval === void 0 ? 5000 : _ref$pollingInterval,
744
744
  _ref$maxAttempts = _ref.maxAttempts,
745
- maxAttempts = _ref$maxAttempts === void 0 ? 120 : _ref$maxAttempts,
745
+ maxAttempts = _ref$maxAttempts === void 0 ? 200 : _ref$maxAttempts,
746
746
  onJobUpdate = _ref.onJobUpdate,
747
747
  abortSignal = _ref.abortSignal;
748
748
  let attempts = 0;
@@ -941,6 +941,8 @@ function createFileImportJob(_ref) {
941
941
  resourceType = _ref.resourceType,
942
942
  importContainerKey = _ref.importContainerKey,
943
943
  payload = _ref.payload,
944
+ _ref$autoProcess = _ref.autoProcess,
945
+ autoProcess = _ref$autoProcess === void 0 ? false : _ref$autoProcess,
944
946
  onProgress = _ref.onProgress,
945
947
  abortSignal = _ref.abortSignal;
946
948
  const url = getFileImportJobsURL({
@@ -954,6 +956,7 @@ function createFileImportJob(_ref) {
954
956
  formData.append('fileType', payload.fileType);
955
957
  formData.append('fileName', payload.fileName);
956
958
  formData.append('file', payload.file, payload.fileName);
959
+ formData.append('autoProcess', autoProcess ? 'true' : 'false');
957
960
  fetchUsingXhr({
958
961
  url,
959
962
  payload: formData,
@@ -1371,7 +1374,7 @@ const COLUMN_DELIMITERS = [DELIMITERS.COMMA, DELIMITERS.SEMICOLON, DELIMITERS.PI
1371
1374
 
1372
1375
  const FILE_IMPORT_JOB_POLLING_INTERVAL = 2000;
1373
1376
 
1374
- const IMPORT_MAX_FILE_SIZE_MB = 200;
1377
+ const IMPORT_MAX_FILE_SIZE_MB = 100;
1375
1378
  const IMPORT_MAX_ITEM_COUNT = 500_000;
1376
1379
 
1377
1380
  // =============================================================================
@@ -2819,6 +2822,7 @@ const useFileImportJobUpload = _ref => {
2819
2822
  fileName: config.file.name,
2820
2823
  file: config.file
2821
2824
  },
2825
+ autoProcess: config.autoProcess,
2822
2826
  onProgress: uploadProgress => {
2823
2827
  setProgress(uploadProgress);
2824
2828
  config.onProgress?.(uploadProgress);
@@ -2968,7 +2972,7 @@ const useFileUpload = _ref2 => {
2968
2972
  _ref2$pollingInterval = _ref2.pollingInterval,
2969
2973
  pollingInterval = _ref2$pollingInterval === void 0 ? 5000 : _ref2$pollingInterval,
2970
2974
  _ref2$maxPollingAttem = _ref2.maxPollingAttempts,
2971
- maxPollingAttempts = _ref2$maxPollingAttem === void 0 ? 120 : _ref2$maxPollingAttem;
2975
+ maxPollingAttempts = _ref2$maxPollingAttem === void 0 ? 200 : _ref2$maxPollingAttem;
2972
2976
  const _React$useState = React__default["default"].useState(false),
2973
2977
  _React$useState2 = _slicedToArray(_React$useState, 2),
2974
2978
  isUploading = _React$useState2[0],
@@ -3010,6 +3014,7 @@ const useFileUpload = _ref2 => {
3010
3014
  file: config.file,
3011
3015
  resourceType: config.resourceType,
3012
3016
  settings: config.settings,
3017
+ autoProcess: config.autoProcess,
3013
3018
  abortSignal: config.abortSignal,
3014
3019
  onSuccess: async (jobId, containerKey) => {
3015
3020
  try {
@@ -742,7 +742,7 @@ const pollJobUntilValidated = async _ref => {
742
742
  _ref$pollingInterval = _ref.pollingInterval,
743
743
  pollingInterval = _ref$pollingInterval === void 0 ? 5000 : _ref$pollingInterval,
744
744
  _ref$maxAttempts = _ref.maxAttempts,
745
- maxAttempts = _ref$maxAttempts === void 0 ? 120 : _ref$maxAttempts,
745
+ maxAttempts = _ref$maxAttempts === void 0 ? 200 : _ref$maxAttempts,
746
746
  onJobUpdate = _ref.onJobUpdate,
747
747
  abortSignal = _ref.abortSignal;
748
748
  let attempts = 0;
@@ -941,6 +941,8 @@ function createFileImportJob(_ref) {
941
941
  resourceType = _ref.resourceType,
942
942
  importContainerKey = _ref.importContainerKey,
943
943
  payload = _ref.payload,
944
+ _ref$autoProcess = _ref.autoProcess,
945
+ autoProcess = _ref$autoProcess === void 0 ? false : _ref$autoProcess,
944
946
  onProgress = _ref.onProgress,
945
947
  abortSignal = _ref.abortSignal;
946
948
  const url = getFileImportJobsURL({
@@ -954,6 +956,7 @@ function createFileImportJob(_ref) {
954
956
  formData.append('fileType', payload.fileType);
955
957
  formData.append('fileName', payload.fileName);
956
958
  formData.append('file', payload.file, payload.fileName);
959
+ formData.append('autoProcess', autoProcess ? 'true' : 'false');
957
960
  fetchUsingXhr({
958
961
  url,
959
962
  payload: formData,
@@ -1371,7 +1374,7 @@ const COLUMN_DELIMITERS = [DELIMITERS.COMMA, DELIMITERS.SEMICOLON, DELIMITERS.PI
1371
1374
 
1372
1375
  const FILE_IMPORT_JOB_POLLING_INTERVAL = 2000;
1373
1376
 
1374
- const IMPORT_MAX_FILE_SIZE_MB = 200;
1377
+ const IMPORT_MAX_FILE_SIZE_MB = 100;
1375
1378
  const IMPORT_MAX_ITEM_COUNT = 500_000;
1376
1379
 
1377
1380
  // =============================================================================
@@ -2811,6 +2814,7 @@ const useFileImportJobUpload = _ref => {
2811
2814
  fileName: config.file.name,
2812
2815
  file: config.file
2813
2816
  },
2817
+ autoProcess: config.autoProcess,
2814
2818
  onProgress: uploadProgress => {
2815
2819
  setProgress(uploadProgress);
2816
2820
  config.onProgress?.(uploadProgress);
@@ -2960,7 +2964,7 @@ const useFileUpload = _ref2 => {
2960
2964
  _ref2$pollingInterval = _ref2.pollingInterval,
2961
2965
  pollingInterval = _ref2$pollingInterval === void 0 ? 5000 : _ref2$pollingInterval,
2962
2966
  _ref2$maxPollingAttem = _ref2.maxPollingAttempts,
2963
- maxPollingAttempts = _ref2$maxPollingAttem === void 0 ? 120 : _ref2$maxPollingAttem;
2967
+ maxPollingAttempts = _ref2$maxPollingAttem === void 0 ? 200 : _ref2$maxPollingAttem;
2964
2968
  const _React$useState = React__default["default"].useState(false),
2965
2969
  _React$useState2 = _slicedToArray(_React$useState, 2),
2966
2970
  isUploading = _React$useState2[0],
@@ -3002,6 +3006,7 @@ const useFileUpload = _ref2 => {
3002
3006
  file: config.file,
3003
3007
  resourceType: config.resourceType,
3004
3008
  settings: config.settings,
3009
+ autoProcess: config.autoProcess,
3005
3010
  abortSignal: config.abortSignal,
3006
3011
  onSuccess: async (jobId, containerKey) => {
3007
3012
  try {
@@ -702,7 +702,7 @@ const pollJobUntilValidated = async _ref => {
702
702
  _ref$pollingInterval = _ref.pollingInterval,
703
703
  pollingInterval = _ref$pollingInterval === void 0 ? 5000 : _ref$pollingInterval,
704
704
  _ref$maxAttempts = _ref.maxAttempts,
705
- maxAttempts = _ref$maxAttempts === void 0 ? 120 : _ref$maxAttempts,
705
+ maxAttempts = _ref$maxAttempts === void 0 ? 200 : _ref$maxAttempts,
706
706
  onJobUpdate = _ref.onJobUpdate,
707
707
  abortSignal = _ref.abortSignal;
708
708
  let attempts = 0;
@@ -901,6 +901,8 @@ function createFileImportJob(_ref) {
901
901
  resourceType = _ref.resourceType,
902
902
  importContainerKey = _ref.importContainerKey,
903
903
  payload = _ref.payload,
904
+ _ref$autoProcess = _ref.autoProcess,
905
+ autoProcess = _ref$autoProcess === void 0 ? false : _ref$autoProcess,
904
906
  onProgress = _ref.onProgress,
905
907
  abortSignal = _ref.abortSignal;
906
908
  const url = getFileImportJobsURL({
@@ -914,6 +916,7 @@ function createFileImportJob(_ref) {
914
916
  formData.append('fileType', payload.fileType);
915
917
  formData.append('fileName', payload.fileName);
916
918
  formData.append('file', payload.file, payload.fileName);
919
+ formData.append('autoProcess', autoProcess ? 'true' : 'false');
917
920
  fetchUsingXhr({
918
921
  url,
919
922
  payload: formData,
@@ -1331,7 +1334,7 @@ const COLUMN_DELIMITERS = [DELIMITERS.COMMA, DELIMITERS.SEMICOLON, DELIMITERS.PI
1331
1334
 
1332
1335
  const FILE_IMPORT_JOB_POLLING_INTERVAL = 2000;
1333
1336
 
1334
- const IMPORT_MAX_FILE_SIZE_MB = 200;
1337
+ const IMPORT_MAX_FILE_SIZE_MB = 100;
1335
1338
  const IMPORT_MAX_ITEM_COUNT = 500_000;
1336
1339
 
1337
1340
  // =============================================================================
@@ -2779,6 +2782,7 @@ const useFileImportJobUpload = _ref => {
2779
2782
  fileName: config.file.name,
2780
2783
  file: config.file
2781
2784
  },
2785
+ autoProcess: config.autoProcess,
2782
2786
  onProgress: uploadProgress => {
2783
2787
  setProgress(uploadProgress);
2784
2788
  config.onProgress?.(uploadProgress);
@@ -2928,7 +2932,7 @@ const useFileUpload = _ref2 => {
2928
2932
  _ref2$pollingInterval = _ref2.pollingInterval,
2929
2933
  pollingInterval = _ref2$pollingInterval === void 0 ? 5000 : _ref2$pollingInterval,
2930
2934
  _ref2$maxPollingAttem = _ref2.maxPollingAttempts,
2931
- maxPollingAttempts = _ref2$maxPollingAttem === void 0 ? 120 : _ref2$maxPollingAttem;
2935
+ maxPollingAttempts = _ref2$maxPollingAttem === void 0 ? 200 : _ref2$maxPollingAttem;
2932
2936
  const _React$useState = React.useState(false),
2933
2937
  _React$useState2 = _slicedToArray(_React$useState, 2),
2934
2938
  isUploading = _React$useState2[0],
@@ -2970,6 +2974,7 @@ const useFileUpload = _ref2 => {
2970
2974
  file: config.file,
2971
2975
  resourceType: config.resourceType,
2972
2976
  settings: config.settings,
2977
+ autoProcess: config.autoProcess,
2973
2978
  abortSignal: config.abortSignal,
2974
2979
  onSuccess: async (jobId, containerKey) => {
2975
2980
  try {
@@ -1,5 +1,5 @@
1
1
  import type { FileImportJob, CreateFileImportJobParameters, GetFileImportJobParameters, GetFileImportJobRecordsParameters, ProcessFileImportJobParameters, ProcessFileImportJobResponse, DeleteFileImportJobParameters, ListFileImportJobsParameters, ListFileImportJobsResponse, FileImportJobRecordsResponse } from "../@types/index.js";
2
- export declare function createFileImportJob({ projectKey, resourceType, importContainerKey, payload, onProgress, abortSignal, }: CreateFileImportJobParameters): Promise<FileImportJob>;
2
+ export declare function createFileImportJob({ projectKey, resourceType, importContainerKey, payload, autoProcess, onProgress, abortSignal, }: CreateFileImportJobParameters): Promise<FileImportJob>;
3
3
  export declare function getFileImportJob({ projectKey, importContainerKey, jobId, }: GetFileImportJobParameters): Promise<FileImportJob>;
4
4
  export declare function getFileImportJobRecords({ projectKey, importContainerKey, jobId, limit, offset, isValid, }: GetFileImportJobRecordsParameters): Promise<FileImportJobRecordsResponse>;
5
5
  export declare function processFileImportJob({ projectKey, resourceType, importContainerKey, jobId, action, }: ProcessFileImportJobParameters): Promise<ProcessFileImportJobResponse>;
@@ -1,4 +1,4 @@
1
- export declare const IMPORT_MAX_FILE_SIZE_MB = 200;
1
+ export declare const IMPORT_MAX_FILE_SIZE_MB = 100;
2
2
  export declare const IMPORT_MAX_ITEM_COUNT = 500000;
3
3
  /** @deprecated Use IMPORT_MAX_FILE_SIZE_MB instead. Remove after migration. */
4
4
  export declare const IMPORT_LEGACY_MAX_FILE_SIZE_MB = 35;
@@ -4,6 +4,7 @@ export type UseFileImportJobUploadConfig = {
4
4
  file: File;
5
5
  resourceType: ResourceTypeId;
6
6
  settings?: ExtendedImportContainerDraft['settings'];
7
+ autoProcess?: boolean;
7
8
  onSuccess: (jobId: string, importContainerKey: string) => void;
8
9
  onError?: (error: unknown) => void;
9
10
  onProgress?: (progress: number) => void;
@@ -9,6 +9,7 @@ export type FileUploadConfig = {
9
9
  file: File;
10
10
  resourceType: ResourceTypeId;
11
11
  settings?: ExtendedImportContainerDraft['settings'];
12
+ autoProcess?: boolean;
12
13
  onSuccess: (result: FileUploadResult) => void;
13
14
  onError?: (error: unknown) => void;
14
15
  onProgress?: (progress: number) => void;
@@ -39,6 +39,7 @@ export interface CreateFileImportJobParameters {
39
39
  resourceType: string;
40
40
  importContainerKey: string;
41
41
  payload: CreateFileImportJobPayload;
42
+ autoProcess?: boolean;
42
43
  onProgress?: (progress: number) => void;
43
44
  abortSignal?: AbortSignal;
44
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend-extensions/operations",
3
- "version": "0.0.0-canary-20251211142708",
3
+ "version": "0.0.0-canary-20251212163045",
4
4
  "license": "Proprietary",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -33,6 +33,7 @@ export function createFileImportJob({
33
33
  resourceType,
34
34
  importContainerKey,
35
35
  payload,
36
+ autoProcess = false,
36
37
  onProgress,
37
38
  abortSignal,
38
39
  }: CreateFileImportJobParameters): Promise<FileImportJob> {
@@ -48,6 +49,7 @@ export function createFileImportJob({
48
49
  formData.append('fileType', payload.fileType)
49
50
  formData.append('fileName', payload.fileName)
50
51
  formData.append('file', payload.file, payload.fileName)
52
+ formData.append('autoProcess', autoProcess ? 'true' : 'false')
51
53
 
52
54
  fetchUsingXhr({
53
55
  url,
@@ -1,4 +1,4 @@
1
- export const IMPORT_MAX_FILE_SIZE_MB = 200
1
+ export const IMPORT_MAX_FILE_SIZE_MB = 100
2
2
 
3
3
  export const IMPORT_MAX_ITEM_COUNT = 500_000
4
4
 
@@ -17,6 +17,7 @@ export type UseFileImportJobUploadConfig = {
17
17
  file: File
18
18
  resourceType: ResourceTypeId
19
19
  settings?: ExtendedImportContainerDraft['settings']
20
+ autoProcess?: boolean
20
21
  onSuccess: (jobId: string, importContainerKey: string) => void
21
22
  onError?: (error: unknown) => void
22
23
  onProgress?: (progress: number) => void
@@ -64,6 +65,7 @@ export const useFileImportJobUpload = ({
64
65
  fileName: config.file.name,
65
66
  file: config.file,
66
67
  },
68
+ autoProcess: config.autoProcess,
67
69
  onProgress: (uploadProgress) => {
68
70
  setProgress(uploadProgress)
69
71
  config.onProgress?.(uploadProgress)
@@ -21,6 +21,7 @@ export type FileUploadConfig = {
21
21
  file: File
22
22
  resourceType: ResourceTypeId
23
23
  settings?: ExtendedImportContainerDraft['settings']
24
+ autoProcess?: boolean
24
25
  onSuccess: (result: FileUploadResult) => void
25
26
  onError?: (error: unknown) => void
26
27
  onProgress?: (progress: number) => void
@@ -54,7 +55,7 @@ export const useFileUpload = ({
54
55
  projectKey,
55
56
  useJobBasedFlow = false,
56
57
  pollingInterval = 5000,
57
- maxPollingAttempts = 120,
58
+ maxPollingAttempts = 200,
58
59
  }: FileUploadOptions) => {
59
60
  const [isUploading, setIsUploading] = React.useState(false)
60
61
  const [progress, setProgress] = React.useState(0)
@@ -87,6 +88,7 @@ export const useFileUpload = ({
87
88
  file: config.file,
88
89
  resourceType: config.resourceType,
89
90
  settings: config.settings,
91
+ autoProcess: config.autoProcess,
90
92
  abortSignal: config.abortSignal,
91
93
  onSuccess: async (jobId, containerKey) => {
92
94
  try {
@@ -56,6 +56,7 @@ export interface CreateFileImportJobParameters {
56
56
  resourceType: string
57
57
  importContainerKey: string
58
58
  payload: CreateFileImportJobPayload
59
+ autoProcess?: boolean
59
60
  onProgress?: (progress: number) => void
60
61
  abortSignal?: AbortSignal
61
62
  }
@@ -18,7 +18,7 @@ export const pollJobUntilValidated = async ({
18
18
  jobId,
19
19
  importContainerKey,
20
20
  pollingInterval = 5000,
21
- maxAttempts = 120,
21
+ maxAttempts = 200,
22
22
  onJobUpdate,
23
23
  abortSignal,
24
24
  }: PollJobUntilValidatedConfig): Promise<FileImportJob> => {