@commercetools-frontend-extensions/operations 0.0.0-canary-20251209161906

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.
Files changed (180) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +178 -0
  3. package/babel.config.js +6 -0
  4. package/dist/commercetools-frontend-extensions-operations.cjs.d.ts +2 -0
  5. package/dist/commercetools-frontend-extensions-operations.cjs.dev.js +3273 -0
  6. package/dist/commercetools-frontend-extensions-operations.cjs.js +7 -0
  7. package/dist/commercetools-frontend-extensions-operations.cjs.prod.js +3265 -0
  8. package/dist/commercetools-frontend-extensions-operations.esm.js +3074 -0
  9. package/dist/declarations/src/@api/export-operations.d.ts +5 -0
  10. package/dist/declarations/src/@api/fetcher.d.ts +17 -0
  11. package/dist/declarations/src/@api/file-import-jobs.d.ts +7 -0
  12. package/dist/declarations/src/@api/file-upload.d.ts +3 -0
  13. package/dist/declarations/src/@api/import-containers.d.ts +35 -0
  14. package/dist/declarations/src/@api/import-operations.d.ts +6 -0
  15. package/dist/declarations/src/@api/index.d.ts +9 -0
  16. package/dist/declarations/src/@api/process-file.d.ts +3 -0
  17. package/dist/declarations/src/@api/test-fixtures.d.ts +279 -0
  18. package/dist/declarations/src/@api/urls.d.ts +74 -0
  19. package/dist/declarations/src/@components/file-drop-area/active-drag-drop-area.d.ts +10 -0
  20. package/dist/declarations/src/@components/file-drop-area/disabled-drop-area.d.ts +5 -0
  21. package/dist/declarations/src/@components/file-drop-area/drop-area-wrapper.d.ts +11 -0
  22. package/dist/declarations/src/@components/file-drop-area/enabled-drop-area.d.ts +7 -0
  23. package/dist/declarations/src/@components/file-drop-area/file-drop-area.d.ts +14 -0
  24. package/dist/declarations/src/@components/file-drop-area/file-dropped-area.d.ts +6 -0
  25. package/dist/declarations/src/@components/file-drop-area/index.d.ts +7 -0
  26. package/dist/declarations/src/@components/file-drop-area/styles.d.ts +9 -0
  27. package/dist/declarations/src/@components/icons/file-icon.d.ts +2 -0
  28. package/dist/declarations/src/@components/icons/index.d.ts +2 -0
  29. package/dist/declarations/src/@components/icons/lock-icon.d.ts +2 -0
  30. package/dist/declarations/src/@components/index.d.ts +6 -0
  31. package/dist/declarations/src/@components/info-box/index.d.ts +1 -0
  32. package/dist/declarations/src/@components/info-box/info-box.d.ts +7 -0
  33. package/dist/declarations/src/@components/upload-separator/index.d.ts +1 -0
  34. package/dist/declarations/src/@components/upload-separator/upload-separator.d.ts +12 -0
  35. package/dist/declarations/src/@components/upload-settings/index.d.ts +1 -0
  36. package/dist/declarations/src/@components/upload-settings/upload-settings.d.ts +11 -0
  37. package/dist/declarations/src/@components/uploading-modal/index.d.ts +1 -0
  38. package/dist/declarations/src/@components/uploading-modal/uploading-modal.d.ts +13 -0
  39. package/dist/declarations/src/@constants/delimiters.d.ts +8 -0
  40. package/dist/declarations/src/@constants/file-import-job.d.ts +1 -0
  41. package/dist/declarations/src/@constants/import-limits.d.ts +6 -0
  42. package/dist/declarations/src/@constants/import-tags.d.ts +7 -0
  43. package/dist/declarations/src/@constants/index.d.ts +5 -0
  44. package/dist/declarations/src/@constants/resource-links.d.ts +10 -0
  45. package/dist/declarations/src/@errors/http-error.d.ts +6 -0
  46. package/dist/declarations/src/@errors/index.d.ts +9 -0
  47. package/dist/declarations/src/@errors/invalid-response-error.d.ts +3 -0
  48. package/dist/declarations/src/@errors/no-resources-to-export-error.d.ts +3 -0
  49. package/dist/declarations/src/@errors/polling-aborted-error.d.ts +3 -0
  50. package/dist/declarations/src/@errors/project-key-not-available-error.d.ts +3 -0
  51. package/dist/declarations/src/@errors/query-predicate-error.d.ts +4 -0
  52. package/dist/declarations/src/@errors/unexpected-column-error.d.ts +3 -0
  53. package/dist/declarations/src/@errors/unexpected-operation-state-error.d.ts +4 -0
  54. package/dist/declarations/src/@errors/unexpected-resource-type-error.d.ts +3 -0
  55. package/dist/declarations/src/@hooks/index.d.ts +8 -0
  56. package/dist/declarations/src/@hooks/use-fetch-export-operations.d.ts +15 -0
  57. package/dist/declarations/src/@hooks/use-fetch-file-import-job.d.ts +17 -0
  58. package/dist/declarations/src/@hooks/use-fetch-import-container-details.d.ts +15 -0
  59. package/dist/declarations/src/@hooks/use-fetch-import-operations.d.ts +16 -0
  60. package/dist/declarations/src/@hooks/use-fetch-import-summaries.d.ts +20 -0
  61. package/dist/declarations/src/@hooks/use-file-import-job-upload.d.ts +18 -0
  62. package/dist/declarations/src/@hooks/use-file-upload.d.ts +28 -0
  63. package/dist/declarations/src/@hooks/use-import-container-upload.d.ts +19 -0
  64. package/dist/declarations/src/@types/api.d.ts +13 -0
  65. package/dist/declarations/src/@types/basic-error-data-type.d.ts +5 -0
  66. package/dist/declarations/src/@types/export-operation.d.ts +97 -0
  67. package/dist/declarations/src/@types/file-import-job.d.ts +99 -0
  68. package/dist/declarations/src/@types/file-upload-result.d.ts +21 -0
  69. package/dist/declarations/src/@types/file-upload.d.ts +63 -0
  70. package/dist/declarations/src/@types/import-container.d.ts +53 -0
  71. package/dist/declarations/src/@types/import-operation.d.ts +13 -0
  72. package/dist/declarations/src/@types/import-states.d.ts +9 -0
  73. package/dist/declarations/src/@types/import-summary.d.ts +15 -0
  74. package/dist/declarations/src/@types/index.d.ts +11 -0
  75. package/dist/declarations/src/@types/shared.d.ts +7 -0
  76. package/dist/declarations/src/@utils/error-mapping.d.ts +19 -0
  77. package/dist/declarations/src/@utils/file-import-job-helpers.d.ts +12 -0
  78. package/dist/declarations/src/@utils/file-upload.d.ts +54 -0
  79. package/dist/declarations/src/@utils/form.d.ts +1 -0
  80. package/dist/declarations/src/@utils/format.d.ts +5 -0
  81. package/dist/declarations/src/@utils/import-container.d.ts +8 -0
  82. package/dist/declarations/src/@utils/index.d.ts +8 -0
  83. package/dist/declarations/src/@utils/poll-job-until-validated.d.ts +11 -0
  84. package/dist/declarations/src/@utils/url.d.ts +6 -0
  85. package/dist/declarations/src/index.d.ts +26 -0
  86. package/index.js +1 -0
  87. package/jest.test.config.js +11 -0
  88. package/package.json +62 -0
  89. package/src/@api/export-operations.ts +26 -0
  90. package/src/@api/fetcher.spec.ts +51 -0
  91. package/src/@api/fetcher.ts +137 -0
  92. package/src/@api/file-import-jobs.ts +217 -0
  93. package/src/@api/file-upload.spec.ts +85 -0
  94. package/src/@api/file-upload.ts +46 -0
  95. package/src/@api/import-containers.ts +256 -0
  96. package/src/@api/import-operations.ts +33 -0
  97. package/src/@api/index.ts +9 -0
  98. package/src/@api/process-file.spec.ts +74 -0
  99. package/src/@api/process-file.ts +53 -0
  100. package/src/@api/test-fixtures.ts +894 -0
  101. package/src/@api/urls.ts +194 -0
  102. package/src/@components/file-drop-area/active-drag-drop-area.tsx +33 -0
  103. package/src/@components/file-drop-area/disabled-drop-area.tsx +17 -0
  104. package/src/@components/file-drop-area/drop-area-wrapper.tsx +38 -0
  105. package/src/@components/file-drop-area/enabled-drop-area.tsx +27 -0
  106. package/src/@components/file-drop-area/file-drop-area.tsx +74 -0
  107. package/src/@components/file-drop-area/file-dropped-area.tsx +29 -0
  108. package/src/@components/file-drop-area/index.ts +7 -0
  109. package/src/@components/file-drop-area/styles.ts +67 -0
  110. package/src/@components/icons/file-icon.tsx +30 -0
  111. package/src/@components/icons/index.ts +2 -0
  112. package/src/@components/icons/lock-icon.tsx +34 -0
  113. package/src/@components/index.ts +6 -0
  114. package/src/@components/info-box/index.ts +1 -0
  115. package/src/@components/info-box/info-box.tsx +23 -0
  116. package/src/@components/upload-separator/index.ts +1 -0
  117. package/src/@components/upload-separator/upload-separator.tsx +61 -0
  118. package/src/@components/upload-settings/index.ts +1 -0
  119. package/src/@components/upload-settings/upload-settings.tsx +36 -0
  120. package/src/@components/uploading-modal/index.ts +1 -0
  121. package/src/@components/uploading-modal/uploading-modal.tsx +66 -0
  122. package/src/@constants/delimiters.ts +14 -0
  123. package/src/@constants/file-import-job.ts +1 -0
  124. package/src/@constants/import-limits.ts +13 -0
  125. package/src/@constants/import-tags.ts +9 -0
  126. package/src/@constants/index.ts +5 -0
  127. package/src/@constants/resource-links.ts +61 -0
  128. package/src/@errors/http-error.ts +17 -0
  129. package/src/@errors/index.ts +9 -0
  130. package/src/@errors/invalid-response-error.ts +6 -0
  131. package/src/@errors/no-resources-to-export-error.ts +6 -0
  132. package/src/@errors/polling-aborted-error.ts +6 -0
  133. package/src/@errors/project-key-not-available-error.ts +6 -0
  134. package/src/@errors/query-predicate-error.ts +10 -0
  135. package/src/@errors/unexpected-column-error.ts +6 -0
  136. package/src/@errors/unexpected-operation-state-error.ts +8 -0
  137. package/src/@errors/unexpected-resource-type-error.ts +6 -0
  138. package/src/@hooks/index.ts +8 -0
  139. package/src/@hooks/use-fetch-export-operations.ts +34 -0
  140. package/src/@hooks/use-fetch-file-import-job.spec.ts +131 -0
  141. package/src/@hooks/use-fetch-file-import-job.ts +38 -0
  142. package/src/@hooks/use-fetch-import-container-details.ts +31 -0
  143. package/src/@hooks/use-fetch-import-operations.ts +42 -0
  144. package/src/@hooks/use-fetch-import-summaries.ts +47 -0
  145. package/src/@hooks/use-fetch.spec.ts +68 -0
  146. package/src/@hooks/use-fetch.ts +76 -0
  147. package/src/@hooks/use-file-import-job-upload.spec.ts +273 -0
  148. package/src/@hooks/use-file-import-job-upload.ts +101 -0
  149. package/src/@hooks/use-file-upload.ts +223 -0
  150. package/src/@hooks/use-import-container-upload.spec.ts +297 -0
  151. package/src/@hooks/use-import-container-upload.ts +130 -0
  152. package/src/@types/api.ts +14 -0
  153. package/src/@types/basic-error-data-type.ts +5 -0
  154. package/src/@types/export-operation.ts +147 -0
  155. package/src/@types/file-import-job.ts +165 -0
  156. package/src/@types/file-upload-result.ts +23 -0
  157. package/src/@types/file-upload.ts +81 -0
  158. package/src/@types/import-container.ts +104 -0
  159. package/src/@types/import-operation.ts +31 -0
  160. package/src/@types/import-states.ts +9 -0
  161. package/src/@types/import-summary.ts +22 -0
  162. package/src/@types/index.ts +11 -0
  163. package/src/@types/shared.ts +52 -0
  164. package/src/@utils/error-mapping.spec.ts +126 -0
  165. package/src/@utils/error-mapping.ts +40 -0
  166. package/src/@utils/file-import-job-helpers.spec.ts +147 -0
  167. package/src/@utils/file-import-job-helpers.ts +47 -0
  168. package/src/@utils/file-upload.spec.ts +151 -0
  169. package/src/@utils/file-upload.ts +189 -0
  170. package/src/@utils/form.ts +20 -0
  171. package/src/@utils/format.spec.ts +62 -0
  172. package/src/@utils/format.ts +53 -0
  173. package/src/@utils/import-container.spec.ts +26 -0
  174. package/src/@utils/import-container.ts +34 -0
  175. package/src/@utils/index.ts +8 -0
  176. package/src/@utils/poll-job-until-validated.ts +76 -0
  177. package/src/@utils/url.spec.ts +75 -0
  178. package/src/@utils/url.ts +18 -0
  179. package/src/index.ts +27 -0
  180. package/tsconfig.json +9 -0
@@ -0,0 +1,894 @@
1
+ import {
2
+ type ProcessFileResponse,
3
+ type ExportOperation,
4
+ ImportStates,
5
+ type ImportSummary,
6
+ type FileUploadResponse,
7
+ type FileImportJob,
8
+ type FileImportJobRecordsResponse,
9
+ type ProcessFileImportJobResponse,
10
+ } from '../@types'
11
+ import { TAG_KEY_SOURCE_FILE_UPLOAD } from '../@constants'
12
+
13
+ export const automatedImportContainerKey = 'automated-container-key'
14
+ export const fileUploadImportContainerKey =
15
+ 'eyJ0aW1lc3RhbXAiOiAxNzA1MDc0MzIxODY4LCAiZmlsZU5hbWUiOiAiZmlsZS11cGxvYWQtY29udGFpbmVyLWtleS5jc3YifQ'
16
+
17
+ export const manualImports = [
18
+ {
19
+ key: 'eyJ0aW1lc3RhbXAiOjE2MjE0MTM0NzU4MzcsImZpbGVOYW1lIjoiX3ZhbGlkLXByb2R1Y3QuY3N2IiwiaW1wb3J0VHlwZSI6Im1hbnVhbCJ9',
20
+ version: 0,
21
+ resourceType: 'product',
22
+ createdAt: '2021-05-19T08:37:56.021Z',
23
+ lastModifiedAt: '2021-05-19T08:37:56.021Z',
24
+ tags: [TAG_KEY_SOURCE_FILE_UPLOAD],
25
+ },
26
+ {
27
+ key: 'eyJ0aW1lc3RhbXAiOjE2MjE0MTM3Mjc0ODksImZpbGVOYW1lIjoiX3ZhbGlkLWNhdGVnb3J5LmNzdiIsImltcG9ydFR5cGUiOiJtYW51YWwifQ',
28
+ version: 0,
29
+ resourceType: 'category',
30
+ createdAt: '2021-05-19T08:42:07.720Z',
31
+ lastModifiedAt: '2021-05-19T08:42:07.720Z',
32
+ tags: [TAG_KEY_SOURCE_FILE_UPLOAD],
33
+ },
34
+ ]
35
+ export const automatedImports = [
36
+ {
37
+ key: 'product-import-container',
38
+ version: 0,
39
+ resourceType: 'product',
40
+ createdAt: '2021-04-06T06:41:33.622Z',
41
+ lastModifiedAt: '2021-04-06T06:41:33.622Z',
42
+ tags: [],
43
+ },
44
+ {
45
+ key: 'product-import-container-1',
46
+ version: 0,
47
+ resourceType: 'product',
48
+ createdAt: '2021-05-26T14:46:12.673Z',
49
+ lastModifiedAt: '2021-05-26T14:46:12.673Z',
50
+ tags: [],
51
+ },
52
+ ]
53
+
54
+ export const importContainers = {
55
+ count: 4,
56
+ total: 100,
57
+ results: manualImports.concat(automatedImports),
58
+ }
59
+
60
+ export const importsSummaries = {
61
+ eyJ0aW1lc3RhbXAiOjE2MjE0MTM0NzU4MzcsImZpbGVOYW1lIjoiX3ZhbGlkLXByb2R1Y3QuY3N2IiwiaW1wb3J0VHlwZSI6Im1hbnVhbCJ9:
62
+ {
63
+ states: {
64
+ validationFailed: 0,
65
+ unresolved: 3,
66
+ waitForMasterVariant: 0,
67
+ imported: 0,
68
+ rejected: 0,
69
+ },
70
+ total: 3,
71
+ },
72
+ eyJ0aW1lc3RhbXAiOjE2MjE0MTM3Mjc0ODksImZpbGVOYW1lIjoiX3ZhbGlkLWNhdGVnb3J5LmNzdiIsImltcG9ydFR5cGUiOiJtYW51YWwifQ:
73
+ {
74
+ states: {
75
+ validationFailed: 0,
76
+ unresolved: 0,
77
+ waitForMasterVariant: 0,
78
+ imported: 0,
79
+ rejected: 0,
80
+ },
81
+ total: 0,
82
+ },
83
+ 'product-import-container': {
84
+ states: {
85
+ validationFailed: 0,
86
+ unresolved: 0,
87
+ waitForMasterVariant: 0,
88
+ imported: 0,
89
+ rejected: 0,
90
+ },
91
+ total: 0,
92
+ },
93
+ 'product-import-container-1': {
94
+ states: {
95
+ validationFailed: 0,
96
+ unresolved: 0,
97
+ waitForMasterVariant: 0,
98
+ imported: 0,
99
+ rejected: 0,
100
+ },
101
+ total: 0,
102
+ },
103
+ }
104
+
105
+ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
106
+ [ImportStates.Processing]: [
107
+ {
108
+ states: {
109
+ unresolved: 0,
110
+ imported: 0,
111
+ rejected: 0,
112
+ validationFailed: 0,
113
+ waitForMasterVariant: 0,
114
+ processing: 10,
115
+ canceled: 0,
116
+ deleted: 0,
117
+ },
118
+ total: 10,
119
+ },
120
+ ],
121
+ [ImportStates.WaitForUnresolvedReferences]: [
122
+ {
123
+ states: {
124
+ unresolved: 0,
125
+ imported: 0,
126
+ rejected: 0,
127
+ validationFailed: 0,
128
+ waitForMasterVariant: 10,
129
+ processing: 0,
130
+ canceled: 0,
131
+ deleted: 0,
132
+ },
133
+ total: 10,
134
+ },
135
+ {
136
+ states: {
137
+ unresolved: 10,
138
+ imported: 0,
139
+ rejected: 0,
140
+ validationFailed: 0,
141
+ waitForMasterVariant: 0,
142
+ processing: 0,
143
+ canceled: 0,
144
+ deleted: 0,
145
+ },
146
+ total: 10,
147
+ },
148
+ {
149
+ states: {
150
+ unresolved: 10,
151
+ imported: 10,
152
+ rejected: 10,
153
+ validationFailed: 10,
154
+ waitForMasterVariant: 0,
155
+ processing: 0,
156
+ canceled: 0,
157
+ deleted: 0,
158
+ },
159
+ total: 40,
160
+ },
161
+ ],
162
+ [ImportStates.Failed]: [
163
+ {
164
+ states: {
165
+ unresolved: 0,
166
+ imported: 0,
167
+ rejected: 4,
168
+ validationFailed: 4,
169
+ waitForMasterVariant: 0,
170
+ processing: 0,
171
+ canceled: 0,
172
+ deleted: 0,
173
+ },
174
+ total: 8,
175
+ },
176
+ {
177
+ states: {
178
+ unresolved: 0,
179
+ imported: 0,
180
+ rejected: 10,
181
+ validationFailed: 0,
182
+ waitForMasterVariant: 0,
183
+ processing: 0,
184
+ canceled: 0,
185
+ deleted: 0,
186
+ },
187
+ total: 10,
188
+ },
189
+ {
190
+ states: {
191
+ unresolved: 0,
192
+ imported: 0,
193
+ rejected: 0,
194
+ validationFailed: 10,
195
+ waitForMasterVariant: 0,
196
+ processing: 0,
197
+ canceled: 0,
198
+ deleted: 0,
199
+ },
200
+ total: 10,
201
+ },
202
+ ],
203
+ [ImportStates.PartiallyCompleted]: [
204
+ {
205
+ states: {
206
+ unresolved: 0,
207
+ imported: 2,
208
+ rejected: 1,
209
+ validationFailed: 0,
210
+ waitForMasterVariant: 0,
211
+ processing: 0,
212
+ canceled: 0,
213
+ deleted: 0,
214
+ },
215
+ total: 3,
216
+ },
217
+ {
218
+ states: {
219
+ unresolved: 0,
220
+ imported: 10,
221
+ rejected: 10,
222
+ validationFailed: 10,
223
+ waitForMasterVariant: 0,
224
+ processing: 0,
225
+ canceled: 0,
226
+ deleted: 0,
227
+ },
228
+ total: 30,
229
+ },
230
+ ],
231
+ [ImportStates.SuccessfullyCompleted]: [
232
+ {
233
+ states: {
234
+ unresolved: 0,
235
+ imported: 20,
236
+ rejected: 0,
237
+ validationFailed: 0,
238
+ waitForMasterVariant: 0,
239
+ processing: 0,
240
+ canceled: 0,
241
+ deleted: 0,
242
+ },
243
+ total: 20,
244
+ },
245
+ {
246
+ states: {
247
+ unresolved: 0,
248
+ imported: 10,
249
+ rejected: 0,
250
+ validationFailed: 0,
251
+ waitForMasterVariant: 0,
252
+ processing: 0,
253
+ canceled: 0,
254
+ deleted: 0,
255
+ },
256
+ total: 10,
257
+ },
258
+ ],
259
+ [ImportStates.NoRunningImports]: [
260
+ {
261
+ states: {
262
+ unresolved: 0,
263
+ imported: 0,
264
+ rejected: 0,
265
+ validationFailed: 0,
266
+ waitForMasterVariant: 0,
267
+ processing: 0,
268
+ canceled: 0,
269
+ deleted: 0,
270
+ },
271
+ total: 0,
272
+ },
273
+ ],
274
+ [ImportStates.Canceled]: [
275
+ {
276
+ states: {
277
+ unresolved: 0,
278
+ imported: 0,
279
+ rejected: 0,
280
+ validationFailed: 0,
281
+ waitForMasterVariant: 0,
282
+ processing: 0,
283
+ canceled: 10,
284
+ deleted: 0,
285
+ },
286
+ total: 10,
287
+ },
288
+ ],
289
+ }
290
+ export const validFileUploadResponse: FileUploadResponse = {
291
+ results: [],
292
+ invalid: 0,
293
+ valid: 2,
294
+ fileName: 'categories.csv',
295
+ itemsCount: 2,
296
+ rowsCount: 2,
297
+ columnsCount: 11,
298
+ fields: [
299
+ 'id',
300
+ 'lastModifiedAt',
301
+ 'key',
302
+ 'name.en',
303
+ 'name.de',
304
+ 'slug.en',
305
+ 'slug.de',
306
+ 'orderHint',
307
+ 'externalId',
308
+ 'description.en',
309
+ 'description.de',
310
+ ],
311
+ ignoredFields: ['id', 'lastModifiedAt'],
312
+ }
313
+
314
+ export const invalidFileUploadResponse: FileUploadResponse = {
315
+ invalid: 2,
316
+ valid: 0,
317
+ fileName: 'categories.csv',
318
+ itemsCount: 2,
319
+ rowsCount: 2,
320
+ columnsCount: 11,
321
+ fields: [
322
+ 'key',
323
+ 'externalId2',
324
+ 'orderHint',
325
+ 'name.de2',
326
+ 'description.de2',
327
+ 'slug.RU',
328
+ 'name.enn',
329
+ 'description.en',
330
+ 'slug.RU',
331
+ 'test1',
332
+ 'test2',
333
+ ],
334
+ ignoredFields: [],
335
+ results: [
336
+ {
337
+ row: 1,
338
+ errors: [
339
+ {
340
+ code: 'InvalidField',
341
+ message: '"externalId2" is not allowed',
342
+ field: 'externalId2',
343
+ },
344
+ {
345
+ code: 'InvalidField',
346
+ message: '"name.de2" is not allowed',
347
+ field: 'name.de2',
348
+ },
349
+ {
350
+ code: 'InvalidField',
351
+ message: '"name.enn" is not allowed',
352
+ field: 'name.enn',
353
+ },
354
+ {
355
+ code: 'InvalidField',
356
+ message: '"slug.RU" is not allowed',
357
+ field: 'slug.RU',
358
+ },
359
+ {
360
+ code: 'InvalidField',
361
+ message: '"test1" is not allowed',
362
+ field: 'test1',
363
+ },
364
+ {
365
+ code: 'InvalidField',
366
+ message: '"test2" is not allowed',
367
+ field: 'test2',
368
+ },
369
+ ],
370
+ },
371
+ ],
372
+ }
373
+
374
+ export const allAutomatedImportOperations = [
375
+ {
376
+ version: 1,
377
+ importContainerKey: automatedImportContainerKey,
378
+ resourceKey: 'sample-3',
379
+ id: 'fcbdb268-6bf0-4161-82ae-5bcd2c0ca1c3',
380
+ state: 'ValidationFailed',
381
+ errors: [
382
+ {
383
+ code: 'InvalidOperation',
384
+ message:
385
+ "The attributes contain definitions with duplicate names: '[product-ref-attribute]'.",
386
+ },
387
+ ],
388
+ createdAt: '2021-08-03T10:13:52.867Z',
389
+ lastModifiedAt: '2021-08-03T10:13:53.031Z',
390
+ expiresAt: '2021-08-05T10:13:52.867Z',
391
+ },
392
+ {
393
+ version: 1,
394
+ importContainerKey: automatedImportContainerKey,
395
+ resourceKey: 'sample-2',
396
+ id: 'c350f282-af46-44bd-b7fb-7767fe060b5d',
397
+ state: 'imported',
398
+ resourceVersion: 1,
399
+ errors: [],
400
+ createdAt: '2021-08-03T10:13:10.544Z',
401
+ lastModifiedAt: '2021-08-03T10:13:11.056Z',
402
+ expiresAt: '2021-08-05T10:13:10.544Z',
403
+ },
404
+ {
405
+ version: 1,
406
+ importContainerKey: automatedImportContainerKey,
407
+ resourceKey: 'sample',
408
+ id: '50e01254-842a-4a94-9dc5-bd5d907a96f3',
409
+ state: 'imported',
410
+ resourceVersion: 1,
411
+ errors: [],
412
+ createdAt: '2021-08-03T10:12:16.293Z',
413
+ lastModifiedAt: '2021-08-03T10:12:16.352Z',
414
+ expiresAt: '2021-08-05T10:12:16.293Z',
415
+ },
416
+ {
417
+ version: 1,
418
+ importContainerKey: automatedImportContainerKey,
419
+ resourceKey: 'sample',
420
+ id: '5679b11b-e6b2-44e3-bb32-feec7ee4295f',
421
+ state: 'imported',
422
+ resourceVersion: 1,
423
+ errors: [],
424
+ createdAt: '2021-08-03T10:12:13.955Z',
425
+ lastModifiedAt: '2021-08-03T10:12:14.019Z',
426
+ expiresAt: '2021-08-05T10:12:13.955Z',
427
+ },
428
+ {
429
+ version: 1,
430
+ importContainerKey: automatedImportContainerKey,
431
+ resourceKey: 'sample',
432
+ id: '8ed41629-9e00-4779-abd7-ca054102690e',
433
+ state: 'imported',
434
+ resourceVersion: 1,
435
+ errors: [],
436
+ createdAt: '2021-08-03T10:12:07.214Z',
437
+ lastModifiedAt: '2021-08-03T10:12:07.364Z',
438
+ expiresAt: '2021-08-05T10:12:07.214Z',
439
+ },
440
+ {
441
+ version: 3,
442
+ importContainerKey: automatedImportContainerKey,
443
+ resourceKey: 'product-draft-key',
444
+ id: '3f4d0fb6-95c0-444b-8e25-dbe1d6f25a54',
445
+ state: 'imported',
446
+ resourceVersion: 1,
447
+ errors: [],
448
+ createdAt: '2021-08-02T12:25:17.465Z',
449
+ lastModifiedAt: '2021-08-02T12:25:34.673Z',
450
+ expiresAt: '2021-08-04T12:25:17.465Z',
451
+ },
452
+ {
453
+ version: 3,
454
+ importContainerKey: automatedImportContainerKey,
455
+ resourceKey: 'product-draft-key',
456
+ id: 'b3e4e438-3afd-46ed-929c-761286b839b4',
457
+ state: 'imported',
458
+ resourceVersion: 1,
459
+ errors: [],
460
+ createdAt: '2021-08-02T12:25:20.019Z',
461
+ lastModifiedAt: '2021-08-02T12:25:34.657Z',
462
+ expiresAt: '2021-08-04T12:25:20.019Z',
463
+ },
464
+ {
465
+ version: 3,
466
+ importContainerKey: automatedImportContainerKey,
467
+ resourceKey: 'product-draft-key',
468
+ id: '8991ee30-2ad0-4e95-b784-e26e7672b49d',
469
+ state: 'imported',
470
+ resourceVersion: 1,
471
+ errors: [],
472
+ createdAt: '2021-08-02T12:25:20.454Z',
473
+ lastModifiedAt: '2021-08-02T12:25:34.629Z',
474
+ expiresAt: '2021-08-04T12:25:20.454Z',
475
+ },
476
+ {
477
+ version: 3,
478
+ importContainerKey: automatedImportContainerKey,
479
+ resourceKey: 'product-draft-key',
480
+ id: 'd0a97b14-2927-414e-ae66-d20a27048418',
481
+ state: 'imported',
482
+ resourceVersion: 1,
483
+ errors: [],
484
+ createdAt: '2021-08-02T12:25:21.108Z',
485
+ lastModifiedAt: '2021-08-02T12:25:34.570Z',
486
+ expiresAt: '2021-08-04T12:25:21.108Z',
487
+ },
488
+ {
489
+ version: 1,
490
+ importContainerKey: automatedImportContainerKey,
491
+ resourceKey: 'sample',
492
+ id: '702fbe9e-81c2-4daf-abd9-4c3f10ed9431',
493
+ state: 'imported',
494
+ resourceVersion: 1,
495
+ errors: [],
496
+ createdAt: '2021-08-02T12:25:27.585Z',
497
+ lastModifiedAt: '2021-08-02T12:25:32.802Z',
498
+ expiresAt: '2021-08-04T12:25:27.585Z',
499
+ },
500
+ ]
501
+
502
+ export const successfulFileUploadImportOperations = [
503
+ {
504
+ version: 1,
505
+ importContainerKey: fileUploadImportContainerKey,
506
+ resourceKey: 'sample-2',
507
+ id: 'c350f282-af46-44bd-b7fb-7767fe060b5d',
508
+ state: 'imported',
509
+ resourceVersion: 1,
510
+ errors: [],
511
+ createdAt: '2021-08-03T10:13:10.544Z',
512
+ lastModifiedAt: '2021-08-03T10:13:11.056Z',
513
+ expiresAt: '2021-08-05T10:13:10.544Z',
514
+ tags: ['rowStartNumber:1'],
515
+ },
516
+ ]
517
+
518
+ export const allFileUploadImportOperations = [
519
+ {
520
+ version: 1,
521
+ importContainerKey: fileUploadImportContainerKey,
522
+ resourceKey: 'sample-3',
523
+ id: 'fcbdb268-6bf0-4161-82ae-5bcd2c0ca1c3',
524
+ state: 'ValidationFailed',
525
+ errors: [
526
+ {
527
+ code: 'InvalidOperation',
528
+ message:
529
+ "The attributes contain definitions with duplicate names: '[product-ref-attribute]'.",
530
+ },
531
+ ],
532
+ createdAt: '2021-08-03T10:13:52.867Z',
533
+ lastModifiedAt: '2021-08-03T10:13:53.031Z',
534
+ expiresAt: '2021-08-05T10:13:52.867Z',
535
+ tags: ['rowStartNumber:1'],
536
+ },
537
+ {
538
+ version: 1,
539
+ importContainerKey: fileUploadImportContainerKey,
540
+ resourceKey: 'sample-2',
541
+ id: 'c350f282-af46-44bd-b7fb-7767fe060b5d',
542
+ state: 'imported',
543
+ resourceVersion: 1,
544
+ errors: [],
545
+ createdAt: '2021-08-03T10:13:10.544Z',
546
+ lastModifiedAt: '2021-08-03T10:13:11.056Z',
547
+ expiresAt: '2021-08-05T10:13:10.544Z',
548
+ tags: ['rowStartNumber:2'],
549
+ },
550
+ {
551
+ version: 1,
552
+ importContainerKey: fileUploadImportContainerKey,
553
+ resourceKey: 'sample',
554
+ id: '50e01254-842a-4a94-9dc5-bd5d907a96f3',
555
+ state: 'imported',
556
+ resourceVersion: 1,
557
+ errors: [],
558
+ createdAt: '2021-08-03T10:12:16.293Z',
559
+ lastModifiedAt: '2021-08-03T10:12:16.352Z',
560
+ expiresAt: '2021-08-05T10:12:16.293Z',
561
+ tags: ['rowStartNumber:3'],
562
+ },
563
+ {
564
+ version: 1,
565
+ importContainerKey: fileUploadImportContainerKey,
566
+ resourceKey: 'sample',
567
+ id: '5679b11b-e6b2-44e3-bb32-feec7ee4295f',
568
+ state: 'imported',
569
+ resourceVersion: 1,
570
+ errors: [],
571
+ createdAt: '2021-08-03T10:12:13.955Z',
572
+ lastModifiedAt: '2021-08-03T10:12:14.019Z',
573
+ expiresAt: '2021-08-05T10:12:13.955Z',
574
+ tags: ['rowStartNumber:4'],
575
+ },
576
+ {
577
+ version: 1,
578
+ importContainerKey: fileUploadImportContainerKey,
579
+ resourceKey: 'sample',
580
+ id: '8ed41629-9e00-4779-abd7-ca054102690e',
581
+ state: 'imported',
582
+ resourceVersion: 1,
583
+ errors: [],
584
+ createdAt: '2021-08-03T10:12:07.214Z',
585
+ lastModifiedAt: '2021-08-03T10:12:07.364Z',
586
+ expiresAt: '2021-08-05T10:12:07.214Z',
587
+ tags: ['rowStartNumber:5'],
588
+ },
589
+ {
590
+ version: 3,
591
+ importContainerKey: fileUploadImportContainerKey,
592
+ resourceKey: 'product-draft-key',
593
+ id: '3f4d0fb6-95c0-444b-8e25-dbe1d6f25a54',
594
+ state: 'imported',
595
+ resourceVersion: 1,
596
+ errors: [],
597
+ createdAt: '2021-08-02T12:25:17.465Z',
598
+ lastModifiedAt: '2021-08-02T12:25:34.673Z',
599
+ expiresAt: '2021-08-04T12:25:17.465Z',
600
+ tags: ['rowStartNumber:6'],
601
+ },
602
+ {
603
+ version: 3,
604
+ importContainerKey: fileUploadImportContainerKey,
605
+ resourceKey: 'product-draft-key',
606
+ id: 'b3e4e438-3afd-46ed-929c-761286b839b4',
607
+ state: 'imported',
608
+ resourceVersion: 1,
609
+ errors: [],
610
+ createdAt: '2021-08-02T12:25:20.019Z',
611
+ lastModifiedAt: '2021-08-02T12:25:34.657Z',
612
+ expiresAt: '2021-08-04T12:25:20.019Z',
613
+ tags: ['rowStartNumber:7'],
614
+ },
615
+ {
616
+ version: 3,
617
+ importContainerKey: fileUploadImportContainerKey,
618
+ resourceKey: 'product-draft-key',
619
+ id: '8991ee30-2ad0-4e95-b784-e26e7672b49d',
620
+ state: 'imported',
621
+ resourceVersion: 1,
622
+ errors: [],
623
+ createdAt: '2021-08-02T12:25:20.454Z',
624
+ lastModifiedAt: '2021-08-02T12:25:34.629Z',
625
+ expiresAt: '2021-08-04T12:25:20.454Z',
626
+ tags: ['rowStartNumber:8'],
627
+ },
628
+ {
629
+ version: 3,
630
+ importContainerKey: fileUploadImportContainerKey,
631
+ resourceKey: 'product-draft-key',
632
+ id: 'd0a97b14-2927-414e-ae66-d20a27048418',
633
+ state: 'imported',
634
+ resourceVersion: 1,
635
+ errors: [],
636
+ createdAt: '2021-08-02T12:25:21.108Z',
637
+ lastModifiedAt: '2021-08-02T12:25:34.570Z',
638
+ expiresAt: '2021-08-04T12:25:21.108Z',
639
+ tags: ['rowStartNumber:9'],
640
+ },
641
+ {
642
+ version: 1,
643
+ importContainerKey: fileUploadImportContainerKey,
644
+ resourceKey: 'sample',
645
+ id: '702fbe9e-81c2-4daf-abd9-4c3f10ed9431',
646
+ state: 'imported',
647
+ resourceVersion: 1,
648
+ errors: [],
649
+ createdAt: '2021-08-02T12:25:27.585Z',
650
+ lastModifiedAt: '2021-08-02T12:25:32.802Z',
651
+ expiresAt: '2021-08-04T12:25:27.585Z',
652
+ tags: ['rowStartNumber:10'],
653
+ },
654
+ ]
655
+
656
+ export const allFileUploadImportOperationsResponse = {
657
+ limit: 20,
658
+ offset: 0,
659
+ count: 10,
660
+ total: 10,
661
+ results: allFileUploadImportOperations,
662
+ }
663
+
664
+ export const allAutomatedImportOperationsResponse = {
665
+ limit: 20,
666
+ offset: 0,
667
+ count: 10,
668
+ total: 10,
669
+ results: allAutomatedImportOperations,
670
+ }
671
+
672
+ export const successfulAutomatedImportOperations = [
673
+ {
674
+ version: 1,
675
+ importContainerKey: automatedImportContainerKey,
676
+ resourceKey: 'sample-2',
677
+ id: 'c350f282-af46-44bd-b7fb-7767fe060b5d',
678
+ state: 'imported',
679
+ resourceVersion: 1,
680
+ errors: [],
681
+ createdAt: '2021-08-03T10:13:10.544Z',
682
+ lastModifiedAt: '2021-08-03T10:13:11.056Z',
683
+ expiresAt: '2021-08-05T10:13:10.544Z',
684
+ },
685
+ ]
686
+
687
+ export const successfulAutomatedImportOperationsResponse = {
688
+ limit: 1,
689
+ offset: 0,
690
+ count: 1,
691
+ total: 1,
692
+ results: successfulAutomatedImportOperations,
693
+ }
694
+
695
+ export const successfulFileUploadImportOperationsResponse = {
696
+ limit: 1,
697
+ offset: 0,
698
+ count: 1,
699
+ total: 1,
700
+ results: successfulFileUploadImportOperations,
701
+ }
702
+
703
+ export const fileUploadMissingKeysResponse = {
704
+ code: 'MissingCsvFieldIdentifier',
705
+ message: 'Importing a new field without an identifier is not allowed',
706
+ rowValue: {
707
+ uri: 'http://example.com/asset-source-without-key',
708
+ key: undefined,
709
+ },
710
+ metadata: {
711
+ row: 1,
712
+ },
713
+ }
714
+
715
+ export const validProcessFileResponse: ProcessFileResponse = {
716
+ message: 'acknowledged',
717
+ }
718
+
719
+ export const exportOperationsCompleted: ExportOperation[] = [
720
+ {
721
+ id: '10df6fe9252eeb1d54485795',
722
+ fileName: 'test-12345.json',
723
+ fileFormat: 'json',
724
+ resourceType: 'category',
725
+ createdAt: '2023-04-01T12:00:00.000Z',
726
+ state: 'completed',
727
+ query: 'query ExportCategories { categories { id } }',
728
+ completedPercentage: 100,
729
+ resourceCount: 100,
730
+ fields: ['id'],
731
+ locales: ['en'],
732
+ },
733
+ {
734
+ id: '10df6fe9252eeb1d54485796',
735
+ fileName: 'test-123456.csv',
736
+ fileFormat: 'csv',
737
+ resourceType: 'category',
738
+ createdAt: '2023-04-02T12:00:00.000Z',
739
+ state: 'completed',
740
+ query: 'query ExportCategories { categories { id } }',
741
+ completedPercentage: 100,
742
+ resourceCount: 100,
743
+ fields: ['id'],
744
+ locales: ['en'],
745
+ },
746
+ ]
747
+
748
+ export const exportOperationsProcessing: ExportOperation[] = [
749
+ {
750
+ id: '10df6fe9252eeb1d54485797',
751
+ fileName: 'test-1234567.json',
752
+ fileFormat: 'json',
753
+ resourceType: 'category',
754
+ createdAt: '2023-04-01T12:00:00.000Z',
755
+ state: 'processing',
756
+ query: 'query ExportCategories { categories { id } }',
757
+ completedPercentage: 50,
758
+ resourceCount: 100,
759
+ fields: ['id'],
760
+ locales: ['en'],
761
+ },
762
+ {
763
+ id: '10df6fe9252eeb1d54485798',
764
+ fileName: 'test-12345678.csv',
765
+ fileFormat: 'csv',
766
+ resourceType: 'category',
767
+ createdAt: '2023-04-02T12:00:00.000Z',
768
+ state: 'processing',
769
+ query: 'query ExportCategories { categories { id } }',
770
+ completedPercentage: 33,
771
+ resourceCount: 100,
772
+ fields: ['id'],
773
+ locales: ['en'],
774
+ },
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
+ }