@commercetools-frontend-extensions/operations 2.0.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +81 -72
- package/dist/commercetools-frontend-extensions-operations.cjs.dev.js +947 -143
- package/dist/commercetools-frontend-extensions-operations.cjs.prod.js +947 -143
- package/dist/commercetools-frontend-extensions-operations.esm.js +898 -140
- package/dist/declarations/src/@api/file-import-jobs.d.ts +7 -0
- package/dist/declarations/src/@api/index.d.ts +1 -0
- package/dist/declarations/src/@api/test-fixtures.d.ts +8 -1
- package/dist/declarations/src/@api/urls.d.ts +30 -0
- package/dist/declarations/src/@components/uploading-modal/uploading-modal.d.ts +3 -2
- package/dist/declarations/src/@constants/file-import-job.d.ts +1 -0
- package/dist/declarations/src/@constants/import-limits.d.ts +6 -0
- package/dist/declarations/src/@constants/index.d.ts +2 -1
- package/dist/declarations/src/@errors/index.d.ts +5 -4
- package/dist/declarations/src/@errors/polling-aborted-error.d.ts +3 -0
- package/dist/declarations/src/@hooks/index.d.ts +3 -0
- package/dist/declarations/src/@hooks/use-fetch-file-import-job.d.ts +17 -0
- package/dist/declarations/src/@hooks/use-file-import-job-upload.d.ts +18 -0
- package/dist/declarations/src/@hooks/use-file-upload.d.ts +28 -0
- package/dist/declarations/src/@hooks/use-import-container-upload.d.ts +2 -1
- package/dist/declarations/src/@types/export-operation.d.ts +3 -1
- package/dist/declarations/src/@types/file-import-job.d.ts +99 -0
- package/dist/declarations/src/@types/file-upload-result.d.ts +21 -0
- package/dist/declarations/src/@types/file-upload.d.ts +2 -2
- package/dist/declarations/src/@types/index.d.ts +2 -0
- package/dist/declarations/src/@utils/file-import-job-helpers.d.ts +12 -0
- package/dist/declarations/src/@utils/file-upload.d.ts +8 -0
- package/dist/declarations/src/@utils/index.d.ts +2 -0
- package/dist/declarations/src/@utils/poll-job-until-validated.d.ts +11 -0
- package/package.json +12 -13
- package/src/@api/fetcher.ts +10 -0
- package/src/@api/file-import-jobs.ts +217 -0
- package/src/@api/file-upload.spec.ts +4 -2
- package/src/@api/index.ts +1 -0
- package/src/@api/test-fixtures.ts +127 -5
- package/src/@api/urls.ts +77 -1
- package/src/@components/uploading-modal/uploading-modal.tsx +7 -5
- package/src/@constants/file-import-job.ts +1 -0
- package/src/@constants/import-limits.ts +13 -0
- package/src/@constants/index.ts +2 -1
- package/src/@errors/index.ts +5 -4
- package/src/@errors/polling-aborted-error.ts +6 -0
- package/src/@hooks/index.ts +3 -0
- package/src/@hooks/use-fetch-file-import-job.spec.ts +131 -0
- package/src/@hooks/use-fetch-file-import-job.ts +38 -0
- package/src/@hooks/use-fetch.spec.ts +1 -9
- package/src/@hooks/use-fetch.ts +4 -8
- package/src/@hooks/use-file-import-job-upload.spec.ts +273 -0
- package/src/@hooks/use-file-import-job-upload.ts +101 -0
- package/src/@hooks/use-file-upload.ts +223 -0
- package/src/@hooks/use-import-container-upload.spec.ts +16 -13
- package/src/@hooks/use-import-container-upload.ts +6 -2
- package/src/@types/export-operation.ts +3 -0
- package/src/@types/file-import-job.ts +165 -0
- package/src/@types/file-upload-result.ts +23 -0
- package/src/@types/file-upload.ts +2 -2
- package/src/@types/index.ts +2 -0
- package/src/@utils/error-mapping.ts +10 -9
- package/src/@utils/file-import-job-helpers.spec.ts +147 -0
- package/src/@utils/file-import-job-helpers.ts +47 -0
- package/src/@utils/file-upload.ts +39 -0
- package/src/@utils/index.ts +2 -0
- package/src/@utils/poll-job-until-validated.ts +76 -0
- package/dist/declarations/src/@constants/upload-limits.d.ts +0 -10
- package/src/@constants/upload-limits.ts +0 -11
- package/src/@hooks/messages.ts +0 -11
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { MC_API_PROXY_TARGETS } from '@commercetools-frontend/constants'
|
|
2
|
+
import type {
|
|
3
|
+
FileImportJob,
|
|
4
|
+
CreateFileImportJobParameters,
|
|
5
|
+
GetFileImportJobParameters,
|
|
6
|
+
GetFileImportJobRecordsParameters,
|
|
7
|
+
ProcessFileImportJobParameters,
|
|
8
|
+
ProcessFileImportJobResponse,
|
|
9
|
+
DeleteFileImportJobParameters,
|
|
10
|
+
ListFileImportJobsParameters,
|
|
11
|
+
ListFileImportJobsResponse,
|
|
12
|
+
FileImportJobRecordsResponse,
|
|
13
|
+
} from '../@types'
|
|
14
|
+
import {
|
|
15
|
+
assertFileImportJob,
|
|
16
|
+
assertFileImportJobRecordsResponse,
|
|
17
|
+
assertProcessFileImportJobResponse,
|
|
18
|
+
assertListFileImportJobsResponse,
|
|
19
|
+
} from '../@types'
|
|
20
|
+
import { fetcher, fetchUsingXhr } from './fetcher'
|
|
21
|
+
import {
|
|
22
|
+
getFileImportJobsURL,
|
|
23
|
+
getFileImportJobByIdURL,
|
|
24
|
+
getFileImportJobRecordsURL,
|
|
25
|
+
getFileImportJobProcessURL,
|
|
26
|
+
getFileImportJobDeleteURL,
|
|
27
|
+
getFileImportJobsListURL,
|
|
28
|
+
} from './urls'
|
|
29
|
+
import { formatQueryString } from '../@utils'
|
|
30
|
+
|
|
31
|
+
export function createFileImportJob({
|
|
32
|
+
projectKey,
|
|
33
|
+
resourceType,
|
|
34
|
+
importContainerKey,
|
|
35
|
+
payload,
|
|
36
|
+
onProgress,
|
|
37
|
+
abortSignal,
|
|
38
|
+
}: CreateFileImportJobParameters): Promise<FileImportJob> {
|
|
39
|
+
const url = getFileImportJobsURL({
|
|
40
|
+
projectKey,
|
|
41
|
+
resourceType,
|
|
42
|
+
importContainerKey,
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
if ('fileType' in payload) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
const formData = new FormData()
|
|
48
|
+
formData.append('fileType', payload.fileType)
|
|
49
|
+
formData.append('fileName', payload.fileName)
|
|
50
|
+
formData.append('file', payload.file, payload.fileName)
|
|
51
|
+
|
|
52
|
+
fetchUsingXhr({
|
|
53
|
+
url,
|
|
54
|
+
payload: formData,
|
|
55
|
+
config: {
|
|
56
|
+
proxy: MC_API_PROXY_TARGETS.IMPORT,
|
|
57
|
+
method: 'POST',
|
|
58
|
+
headers: {
|
|
59
|
+
'Content-Type': null,
|
|
60
|
+
},
|
|
61
|
+
abortSignal,
|
|
62
|
+
},
|
|
63
|
+
onProgress: onProgress || (() => {}),
|
|
64
|
+
onSuccess: (response: FileImportJob) => {
|
|
65
|
+
assertFileImportJob(response)
|
|
66
|
+
resolve(response)
|
|
67
|
+
},
|
|
68
|
+
onError: reject,
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return fetcher<FileImportJob>({
|
|
74
|
+
url,
|
|
75
|
+
payload: JSON.stringify(payload),
|
|
76
|
+
config: {
|
|
77
|
+
proxy: MC_API_PROXY_TARGETS.IMPORT,
|
|
78
|
+
method: 'POST',
|
|
79
|
+
headers: {
|
|
80
|
+
accept: 'application/json',
|
|
81
|
+
'Content-Type': 'application/json',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
}).then((response) => {
|
|
85
|
+
assertFileImportJob(response)
|
|
86
|
+
return response
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export async function getFileImportJob({
|
|
91
|
+
projectKey,
|
|
92
|
+
importContainerKey,
|
|
93
|
+
jobId,
|
|
94
|
+
}: GetFileImportJobParameters): Promise<FileImportJob> {
|
|
95
|
+
const url = getFileImportJobByIdURL({
|
|
96
|
+
projectKey,
|
|
97
|
+
importContainerKey,
|
|
98
|
+
jobId,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const response = await fetcher<FileImportJob>({
|
|
102
|
+
url,
|
|
103
|
+
config: {
|
|
104
|
+
proxy: MC_API_PROXY_TARGETS.IMPORT,
|
|
105
|
+
method: 'GET',
|
|
106
|
+
},
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
assertFileImportJob(response)
|
|
110
|
+
return response
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export async function getFileImportJobRecords({
|
|
114
|
+
projectKey,
|
|
115
|
+
importContainerKey,
|
|
116
|
+
jobId,
|
|
117
|
+
limit,
|
|
118
|
+
offset,
|
|
119
|
+
isValid,
|
|
120
|
+
}: GetFileImportJobRecordsParameters): Promise<FileImportJobRecordsResponse> {
|
|
121
|
+
const baseUrl = getFileImportJobRecordsURL({
|
|
122
|
+
projectKey,
|
|
123
|
+
importContainerKey,
|
|
124
|
+
jobId,
|
|
125
|
+
})
|
|
126
|
+
const queryString = formatQueryString({ limit, offset, isValid })
|
|
127
|
+
const url = `${baseUrl}${queryString}`
|
|
128
|
+
|
|
129
|
+
const response = await fetcher<FileImportJobRecordsResponse>({
|
|
130
|
+
url,
|
|
131
|
+
config: {
|
|
132
|
+
proxy: MC_API_PROXY_TARGETS.IMPORT,
|
|
133
|
+
method: 'GET',
|
|
134
|
+
},
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
assertFileImportJobRecordsResponse(response)
|
|
138
|
+
return response
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export async function processFileImportJob({
|
|
142
|
+
projectKey,
|
|
143
|
+
resourceType,
|
|
144
|
+
importContainerKey,
|
|
145
|
+
jobId,
|
|
146
|
+
action,
|
|
147
|
+
}: ProcessFileImportJobParameters): Promise<ProcessFileImportJobResponse> {
|
|
148
|
+
const url = getFileImportJobProcessURL({
|
|
149
|
+
projectKey,
|
|
150
|
+
resourceType,
|
|
151
|
+
importContainerKey,
|
|
152
|
+
jobId,
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
const payload = action ? { action } : {}
|
|
156
|
+
|
|
157
|
+
const response = await fetcher<ProcessFileImportJobResponse>({
|
|
158
|
+
url,
|
|
159
|
+
payload: JSON.stringify(payload),
|
|
160
|
+
config: {
|
|
161
|
+
proxy: MC_API_PROXY_TARGETS.IMPORT,
|
|
162
|
+
method: 'POST',
|
|
163
|
+
headers: {
|
|
164
|
+
accept: 'application/json',
|
|
165
|
+
'Content-Type': 'application/json',
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
assertProcessFileImportJobResponse(response)
|
|
171
|
+
return response
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export async function deleteFileImportJob({
|
|
175
|
+
projectKey,
|
|
176
|
+
importContainerKey,
|
|
177
|
+
jobId,
|
|
178
|
+
}: DeleteFileImportJobParameters): Promise<void> {
|
|
179
|
+
const url = getFileImportJobDeleteURL({
|
|
180
|
+
projectKey,
|
|
181
|
+
importContainerKey,
|
|
182
|
+
jobId,
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
await fetcher<void>({
|
|
186
|
+
url,
|
|
187
|
+
config: {
|
|
188
|
+
proxy: MC_API_PROXY_TARGETS.IMPORT,
|
|
189
|
+
method: 'DELETE',
|
|
190
|
+
},
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export async function listFileImportJobs({
|
|
195
|
+
projectKey,
|
|
196
|
+
importContainerKey,
|
|
197
|
+
limit,
|
|
198
|
+
offset,
|
|
199
|
+
}: ListFileImportJobsParameters): Promise<ListFileImportJobsResponse> {
|
|
200
|
+
const baseUrl = getFileImportJobsListURL({
|
|
201
|
+
projectKey,
|
|
202
|
+
importContainerKey,
|
|
203
|
+
})
|
|
204
|
+
const queryString = formatQueryString({ limit, offset })
|
|
205
|
+
const url = `${baseUrl}${queryString}`
|
|
206
|
+
|
|
207
|
+
const response = await fetcher<ListFileImportJobsResponse>({
|
|
208
|
+
url,
|
|
209
|
+
config: {
|
|
210
|
+
proxy: MC_API_PROXY_TARGETS.IMPORT,
|
|
211
|
+
method: 'GET',
|
|
212
|
+
},
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
assertListFileImportJobsResponse(response)
|
|
216
|
+
return response
|
|
217
|
+
}
|
|
@@ -10,10 +10,12 @@ const validFileUploadResponse: FileUploadResponse = {
|
|
|
10
10
|
invalid: 0,
|
|
11
11
|
fileName: 'file.csv',
|
|
12
12
|
itemsCount: 0,
|
|
13
|
+
// TODO: Remove rowsCount and columnsCount once we remove the old flow
|
|
13
14
|
rowsCount: 0,
|
|
14
15
|
columnsCount: 0,
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
//
|
|
17
|
+
fields: ['id', 'name', 'description'],
|
|
18
|
+
ignoredFields: ['id', 'name'],
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
type ResourceTypeEntry = {
|
package/src/@api/index.ts
CHANGED
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
type ExportOperation,
|
|
4
4
|
ImportStates,
|
|
5
5
|
type ImportSummary,
|
|
6
|
-
FileUploadResponse,
|
|
6
|
+
type FileUploadResponse,
|
|
7
|
+
type FileImportJob,
|
|
8
|
+
type FileImportJobRecordsResponse,
|
|
9
|
+
type ProcessFileImportJobResponse,
|
|
7
10
|
} from '../@types'
|
|
8
11
|
import { TAG_KEY_SOURCE_FILE_UPLOAD } from '../@constants'
|
|
9
12
|
|
|
@@ -292,7 +295,7 @@ export const validFileUploadResponse: FileUploadResponse = {
|
|
|
292
295
|
itemsCount: 2,
|
|
293
296
|
rowsCount: 2,
|
|
294
297
|
columnsCount: 11,
|
|
295
|
-
|
|
298
|
+
fields: [
|
|
296
299
|
'id',
|
|
297
300
|
'lastModifiedAt',
|
|
298
301
|
'key',
|
|
@@ -305,7 +308,7 @@ export const validFileUploadResponse: FileUploadResponse = {
|
|
|
305
308
|
'description.en',
|
|
306
309
|
'description.de',
|
|
307
310
|
],
|
|
308
|
-
|
|
311
|
+
ignoredFields: ['id', 'lastModifiedAt'],
|
|
309
312
|
}
|
|
310
313
|
|
|
311
314
|
export const invalidFileUploadResponse: FileUploadResponse = {
|
|
@@ -315,7 +318,7 @@ export const invalidFileUploadResponse: FileUploadResponse = {
|
|
|
315
318
|
itemsCount: 2,
|
|
316
319
|
rowsCount: 2,
|
|
317
320
|
columnsCount: 11,
|
|
318
|
-
|
|
321
|
+
fields: [
|
|
319
322
|
'key',
|
|
320
323
|
'externalId2',
|
|
321
324
|
'orderHint',
|
|
@@ -328,7 +331,7 @@ export const invalidFileUploadResponse: FileUploadResponse = {
|
|
|
328
331
|
'test1',
|
|
329
332
|
'test2',
|
|
330
333
|
],
|
|
331
|
-
|
|
334
|
+
ignoredFields: [],
|
|
332
335
|
results: [
|
|
333
336
|
{
|
|
334
337
|
row: 1,
|
|
@@ -770,3 +773,122 @@ export const exportOperationsProcessing: ExportOperation[] = [
|
|
|
770
773
|
locales: ['en'],
|
|
771
774
|
},
|
|
772
775
|
]
|
|
776
|
+
|
|
777
|
+
export const validFileImportJobQueued: FileImportJob = {
|
|
778
|
+
id: 'job-uuid-12345',
|
|
779
|
+
fileName: 'categories.csv',
|
|
780
|
+
importContainerKey: 'container-key',
|
|
781
|
+
state: 'queued',
|
|
782
|
+
summary: {
|
|
783
|
+
total: 0,
|
|
784
|
+
valid: 0,
|
|
785
|
+
invalid: 0,
|
|
786
|
+
fieldsCount: 0,
|
|
787
|
+
fields: [],
|
|
788
|
+
ignoredFields: [],
|
|
789
|
+
},
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
export const validFileImportJobProcessing: FileImportJob = {
|
|
793
|
+
id: 'job-uuid-12345',
|
|
794
|
+
fileName: 'categories.csv',
|
|
795
|
+
importContainerKey: 'container-key',
|
|
796
|
+
state: 'processing',
|
|
797
|
+
summary: {
|
|
798
|
+
total: 0,
|
|
799
|
+
valid: 0,
|
|
800
|
+
invalid: 0,
|
|
801
|
+
fieldsCount: 0,
|
|
802
|
+
fields: [],
|
|
803
|
+
ignoredFields: [],
|
|
804
|
+
},
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
export const validFileImportJobValidated: FileImportJob = {
|
|
808
|
+
id: 'job-uuid-12345',
|
|
809
|
+
fileName: 'categories.csv',
|
|
810
|
+
importContainerKey: 'container-key',
|
|
811
|
+
state: 'validated',
|
|
812
|
+
summary: {
|
|
813
|
+
total: 2,
|
|
814
|
+
valid: 2,
|
|
815
|
+
invalid: 0,
|
|
816
|
+
fieldsCount: 2,
|
|
817
|
+
fields: ['key', 'name.en'],
|
|
818
|
+
ignoredFields: ['id', 'lastModifiedAt'],
|
|
819
|
+
},
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
export const invalidFileImportJobValidated: FileImportJob = {
|
|
823
|
+
id: 'job-uuid-12345',
|
|
824
|
+
fileName: 'categories.csv',
|
|
825
|
+
importContainerKey: 'container-key',
|
|
826
|
+
state: 'validated',
|
|
827
|
+
summary: {
|
|
828
|
+
total: 2,
|
|
829
|
+
valid: 0,
|
|
830
|
+
invalid: 2,
|
|
831
|
+
fieldsCount: 11,
|
|
832
|
+
fields: [
|
|
833
|
+
'key',
|
|
834
|
+
'externalId2',
|
|
835
|
+
'orderHint',
|
|
836
|
+
'name.de2',
|
|
837
|
+
'description.de2',
|
|
838
|
+
'slug.RU',
|
|
839
|
+
'name.enn',
|
|
840
|
+
'description.en',
|
|
841
|
+
'slug.RU',
|
|
842
|
+
'test1',
|
|
843
|
+
'test2',
|
|
844
|
+
],
|
|
845
|
+
ignoredFields: [],
|
|
846
|
+
},
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
export const validFileImportJobRecordsResponse: FileImportJobRecordsResponse = {
|
|
850
|
+
results: [],
|
|
851
|
+
total: 0,
|
|
852
|
+
limit: 20,
|
|
853
|
+
offset: 0,
|
|
854
|
+
count: 0,
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
export const invalidFileImportJobRecordsResponse: FileImportJobRecordsResponse =
|
|
858
|
+
{
|
|
859
|
+
results: [
|
|
860
|
+
{
|
|
861
|
+
index: 1,
|
|
862
|
+
errors: [
|
|
863
|
+
{
|
|
864
|
+
code: 'InvalidField',
|
|
865
|
+
message: '"externalId2" is not allowed',
|
|
866
|
+
field: 'externalId2',
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
code: 'InvalidField',
|
|
870
|
+
message: '"orderHint" is not allowed',
|
|
871
|
+
field: 'orderHint',
|
|
872
|
+
},
|
|
873
|
+
],
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
index: 2,
|
|
877
|
+
errors: [
|
|
878
|
+
{
|
|
879
|
+
code: 'InvalidField',
|
|
880
|
+
message: '"name.de2" is not allowed',
|
|
881
|
+
field: 'name.de2',
|
|
882
|
+
},
|
|
883
|
+
],
|
|
884
|
+
},
|
|
885
|
+
],
|
|
886
|
+
total: 2,
|
|
887
|
+
limit: 20,
|
|
888
|
+
offset: 0,
|
|
889
|
+
count: 2,
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
export const processFileImportJobResponse: ProcessFileImportJobResponse = {
|
|
893
|
+
message: 'acknowledged',
|
|
894
|
+
}
|
package/src/@api/urls.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ResourceTypeId } from '@commercetools/importapi-sdk'
|
|
2
2
|
import { plural } from 'pluralize'
|
|
3
|
-
import { formatQueryString } from '../@utils'
|
|
3
|
+
import { formatQueryString, toImportApiResourceType } from '../@utils'
|
|
4
4
|
import type {
|
|
5
5
|
ImportContainerQueryParams,
|
|
6
6
|
ExportOperationQueryParams,
|
|
@@ -116,3 +116,79 @@ export function getExportOperationsURL({
|
|
|
116
116
|
const queryString = formatQueryString(queryParams)
|
|
117
117
|
return `/${projectKey}/export-operations${queryString}`
|
|
118
118
|
}
|
|
119
|
+
|
|
120
|
+
export function getFileImportJobsURL({
|
|
121
|
+
projectKey,
|
|
122
|
+
resourceType,
|
|
123
|
+
importContainerKey,
|
|
124
|
+
}: {
|
|
125
|
+
projectKey: string
|
|
126
|
+
resourceType: string
|
|
127
|
+
importContainerKey: string
|
|
128
|
+
}): string {
|
|
129
|
+
return `/${projectKey}/${plural(
|
|
130
|
+
toImportApiResourceType(resourceType)
|
|
131
|
+
)}/import-containers/${importContainerKey}/file-import-jobs`
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function getFileImportJobByIdURL({
|
|
135
|
+
projectKey,
|
|
136
|
+
importContainerKey,
|
|
137
|
+
jobId,
|
|
138
|
+
}: {
|
|
139
|
+
projectKey: string
|
|
140
|
+
importContainerKey: string
|
|
141
|
+
jobId: string
|
|
142
|
+
}): string {
|
|
143
|
+
return `/${projectKey}/import-containers/${importContainerKey}/file-import-jobs/${jobId}`
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function getFileImportJobRecordsURL({
|
|
147
|
+
projectKey,
|
|
148
|
+
importContainerKey,
|
|
149
|
+
jobId,
|
|
150
|
+
}: {
|
|
151
|
+
projectKey: string
|
|
152
|
+
importContainerKey: string
|
|
153
|
+
jobId: string
|
|
154
|
+
}): string {
|
|
155
|
+
return `/${projectKey}/import-containers/${importContainerKey}/file-import-jobs/${jobId}/records`
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function getFileImportJobProcessURL({
|
|
159
|
+
projectKey,
|
|
160
|
+
resourceType,
|
|
161
|
+
importContainerKey,
|
|
162
|
+
jobId,
|
|
163
|
+
}: {
|
|
164
|
+
projectKey: string
|
|
165
|
+
resourceType: string
|
|
166
|
+
importContainerKey: string
|
|
167
|
+
jobId: string
|
|
168
|
+
}): string {
|
|
169
|
+
return `/${projectKey}/${plural(
|
|
170
|
+
toImportApiResourceType(resourceType)
|
|
171
|
+
)}/import-containers/${importContainerKey}/file-import-jobs/${jobId}/process`
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function getFileImportJobDeleteURL({
|
|
175
|
+
projectKey,
|
|
176
|
+
importContainerKey,
|
|
177
|
+
jobId,
|
|
178
|
+
}: {
|
|
179
|
+
projectKey: string
|
|
180
|
+
importContainerKey: string
|
|
181
|
+
jobId: string
|
|
182
|
+
}): string {
|
|
183
|
+
return `/${projectKey}/import-containers/${importContainerKey}/file-import-jobs/${jobId}`
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function getFileImportJobsListURL({
|
|
187
|
+
projectKey,
|
|
188
|
+
importContainerKey,
|
|
189
|
+
}: {
|
|
190
|
+
projectKey: string
|
|
191
|
+
importContainerKey: string
|
|
192
|
+
}): string {
|
|
193
|
+
return `/${projectKey}/import-containers/${importContainerKey}/file-import-jobs`
|
|
194
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useIntl } from 'react-intl'
|
|
2
1
|
import { InfoDialog } from '@commercetools-frontend/application-components'
|
|
3
2
|
import {
|
|
4
3
|
Constraints,
|
|
@@ -15,10 +14,11 @@ type UploadingModalProps = {
|
|
|
15
14
|
title: string
|
|
16
15
|
fileName: string
|
|
17
16
|
fileSize: number
|
|
18
|
-
progress
|
|
17
|
+
progress?: number
|
|
19
18
|
cancelLabel: string
|
|
20
19
|
onCancel: () => void
|
|
21
20
|
onClose: () => void
|
|
21
|
+
statusMessage?: string
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export const UploadingModal = ({
|
|
@@ -30,8 +30,8 @@ export const UploadingModal = ({
|
|
|
30
30
|
cancelLabel,
|
|
31
31
|
onCancel,
|
|
32
32
|
onClose,
|
|
33
|
+
statusMessage,
|
|
33
34
|
}: UploadingModalProps) => {
|
|
34
|
-
const intl = useIntl()
|
|
35
35
|
return (
|
|
36
36
|
<InfoDialog size={16} isOpen={isOpen} title={title} onClose={onClose}>
|
|
37
37
|
<Spacings.Stack scale="m">
|
|
@@ -46,7 +46,7 @@ export const UploadingModal = ({
|
|
|
46
46
|
</Constraints.Horizontal>
|
|
47
47
|
</Spacings.Inline>
|
|
48
48
|
<Text.Body tone="secondary">
|
|
49
|
-
({
|
|
49
|
+
({convertFileSizeToKB(fileSize).toLocaleString()} KB)
|
|
50
50
|
</Text.Body>
|
|
51
51
|
</Spacings.Inline>
|
|
52
52
|
<SecondaryButton
|
|
@@ -57,7 +57,9 @@ export const UploadingModal = ({
|
|
|
57
57
|
/>
|
|
58
58
|
</Spacings.Inline>
|
|
59
59
|
<ProgressBar barWidth="scale" height="10" progress={progress} />
|
|
60
|
-
|
|
60
|
+
{statusMessage && (
|
|
61
|
+
<Text.Detail tone="tertiary">{statusMessage}</Text.Detail>
|
|
62
|
+
)}
|
|
61
63
|
</Spacings.Stack>
|
|
62
64
|
</InfoDialog>
|
|
63
65
|
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const FILE_IMPORT_JOB_POLLING_INTERVAL = 2000
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const IMPORT_MAX_FILE_SIZE_MB = 200
|
|
2
|
+
|
|
3
|
+
export const IMPORT_MAX_ITEM_COUNT = 500_000
|
|
4
|
+
|
|
5
|
+
// =============================================================================
|
|
6
|
+
// Legacy constants (old flow) - Remove after testing and migration is complete
|
|
7
|
+
// =============================================================================
|
|
8
|
+
|
|
9
|
+
/** @deprecated Use IMPORT_MAX_FILE_SIZE_MB instead. Remove after migration. */
|
|
10
|
+
export const IMPORT_LEGACY_MAX_FILE_SIZE_MB = 35
|
|
11
|
+
|
|
12
|
+
/** @deprecated Use IMPORT_MAX_ITEM_COUNT instead. Remove after migration. */
|
|
13
|
+
export const IMPORT_LEGACY_MAX_ROW_COUNT = 80_000
|
package/src/@constants/index.ts
CHANGED
package/src/@errors/index.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export * from './unexpected-column-error'
|
|
2
|
-
export * from './unexpected-operation-state-error'
|
|
3
|
-
export * from './unexpected-resource-type-error'
|
|
4
1
|
export * from './http-error'
|
|
5
2
|
export * from './invalid-response-error'
|
|
6
|
-
export * from './query-predicate-error'
|
|
7
3
|
export * from './no-resources-to-export-error'
|
|
4
|
+
export * from './polling-aborted-error'
|
|
8
5
|
export * from './project-key-not-available-error'
|
|
6
|
+
export * from './query-predicate-error'
|
|
7
|
+
export * from './unexpected-column-error'
|
|
8
|
+
export * from './unexpected-operation-state-error'
|
|
9
|
+
export * from './unexpected-resource-type-error'
|
package/src/@hooks/index.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from './use-fetch-export-operations'
|
|
2
|
+
export * from './use-fetch-file-import-job'
|
|
2
3
|
export * from './use-fetch-import-container-details'
|
|
3
4
|
export * from './use-fetch-import-operations'
|
|
4
5
|
export * from './use-fetch-import-summaries'
|
|
6
|
+
export * from './use-file-import-job-upload'
|
|
7
|
+
export * from './use-file-upload'
|
|
5
8
|
export * from './use-import-container-upload'
|