@commercetools-frontend-extensions/operations 3.5.0 → 3.6.1
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 +12 -0
- package/README.md +2 -0
- package/dist/commercetools-frontend-extensions-operations.cjs.dev.js +59 -14
- package/dist/commercetools-frontend-extensions-operations.cjs.prod.js +59 -14
- package/dist/commercetools-frontend-extensions-operations.esm.js +59 -14
- package/dist/declarations/src/@hooks/use-file-import-job-upload.d.ts +1 -0
- package/dist/declarations/src/@hooks/use-file-upload.d.ts +1 -0
- package/dist/declarations/src/@types/import-states.d.ts +1 -0
- package/dist/declarations/src/@types/import-summary.d.ts +4 -0
- package/package.json +16 -16
- package/src/@api/import-containers.ts +4 -0
- package/src/@api/test-fixtures.ts +43 -0
- package/src/@hooks/use-file-import-job-upload.spec.ts +49 -0
- package/src/@hooks/use-file-import-job-upload.ts +5 -1
- package/src/@hooks/use-file-upload.ts +2 -0
- package/src/@types/import-states.ts +1 -0
- package/src/@types/import-summary.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @commercetools-frontend-extensions/operations
|
|
2
2
|
|
|
3
|
+
## 3.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1739](https://github.com/commercetools/merchant-center-operations/pull/1739) [`6bf3e25`](https://github.com/commercetools/merchant-center-operations/commit/6bf3e259e9f9b982039d972c728b579fe4df9bec) Thanks [@valoriecarli](https://github.com/valoriecarli)! - Upgrade merchant-center-application-kit packages from v25 to v27, migrate ESLint config from legacy .eslintrc.js to ESLint 9 flat config (eslint.config.js). Replaced abandoned eslint-plugin-graphql with @graphql-eslint/eslint-plugin in the playground to restore .ctp.graphql linting under ESLint 9.
|
|
8
|
+
|
|
9
|
+
## 3.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#1734](https://github.com/commercetools/merchant-center-operations/pull/1734) [`59d43ea`](https://github.com/commercetools/merchant-center-operations/commit/59d43ea4a4ffb929a970e3094881777639d6631f) Thanks [@yassinejebli](https://github.com/yassinejebli)! - feat: add optional `fileType` override to `useFileUpload` hook
|
|
14
|
+
|
|
3
15
|
## 3.5.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -40,6 +40,7 @@ const { upload, isUploading, progress, validationProgress } = useFileUpload({
|
|
|
40
40
|
**Upload config options:**
|
|
41
41
|
- `file` (required): The file to upload
|
|
42
42
|
- `resourceType` (required): The resource type
|
|
43
|
+
- `fileType` (optional): File type (`'csv'` or `'json'`) sent to the API.
|
|
43
44
|
- `settings` (optional): Import settings (format, decimal separator...)
|
|
44
45
|
- `autoProcess` (optional): When `true`, the backend automatically starts processing after validation completes (job-based flow only). Default: `false`
|
|
45
46
|
- `skipValidationPolling` (optional): When `true`, skips full validation polling and returns once the job reaches `processing` state. Useful for fire-and-forget uploads with `autoProcess: true` (job-based flow only). Default: `false`
|
|
@@ -63,6 +64,7 @@ const abortController = new AbortController()
|
|
|
63
64
|
await upload({
|
|
64
65
|
file: File,
|
|
65
66
|
resourceType: 'product' | 'category' | ...,
|
|
67
|
+
fileType?: 'csv' | 'json', // override derived file type (job-based flow only)
|
|
66
68
|
settings?: {
|
|
67
69
|
format?: 'CSV' | 'JSON',
|
|
68
70
|
decimalSeparator?: '.' | ',',
|
|
@@ -510,6 +510,7 @@ let ImportStates = /*#__PURE__*/function (ImportStates) {
|
|
|
510
510
|
ImportStates["Processing"] = "processing";
|
|
511
511
|
ImportStates["WaitForUnresolvedReferences"] = "wait-for-unresolved-references";
|
|
512
512
|
ImportStates["PartiallyCompleted"] = "partially-completed";
|
|
513
|
+
ImportStates["PartiallyImported"] = "partially-imported";
|
|
513
514
|
ImportStates["Failed"] = "failed";
|
|
514
515
|
ImportStates["SuccessfullyCompleted"] = "successfully-completed";
|
|
515
516
|
ImportStates["NoRunningImports"] = "no-running-imports";
|
|
@@ -1263,10 +1264,12 @@ function ownKeys$6(e, r) { var t = _Object$keys__default["default"](e); if (_Obj
|
|
|
1263
1264
|
function _objectSpread$6(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$6(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$6(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1264
1265
|
function getImportState(importSummary) {
|
|
1265
1266
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1267
|
+
const partiallyImported = importSummary.states.partiallyImported ?? 0;
|
|
1266
1268
|
const processing = importSummary.states.processing > 0;
|
|
1267
1269
|
if (processing) return ImportStates.Processing;
|
|
1268
1270
|
const waitForUnresolvedReferences = importSummary.states.waitForMasterVariant > 0 || importSummary.states.unresolved > 0;
|
|
1269
1271
|
if (waitForUnresolvedReferences) return ImportStates.WaitForUnresolvedReferences;
|
|
1272
|
+
if (partiallyImported > 0) return ImportStates.PartiallyImported;
|
|
1270
1273
|
const partiallyCompleted = importSummary.states.imported > 0 && importSummary.states.imported < importSummary.total || importSummary.states.deleted > 0 && importSummary.states.deleted < importSummary.total;
|
|
1271
1274
|
if (partiallyCompleted) return ImportStates.PartiallyCompleted;
|
|
1272
1275
|
const noRunning = importSummary.total === 0;
|
|
@@ -1692,7 +1695,8 @@ const importStatesMap = {
|
|
|
1692
1695
|
waitForMasterVariant: 0,
|
|
1693
1696
|
processing: 10,
|
|
1694
1697
|
canceled: 0,
|
|
1695
|
-
deleted: 0
|
|
1698
|
+
deleted: 0,
|
|
1699
|
+
partiallyImported: 0
|
|
1696
1700
|
},
|
|
1697
1701
|
total: 10
|
|
1698
1702
|
}],
|
|
@@ -1705,7 +1709,8 @@ const importStatesMap = {
|
|
|
1705
1709
|
waitForMasterVariant: 10,
|
|
1706
1710
|
processing: 0,
|
|
1707
1711
|
canceled: 0,
|
|
1708
|
-
deleted: 0
|
|
1712
|
+
deleted: 0,
|
|
1713
|
+
partiallyImported: 0
|
|
1709
1714
|
},
|
|
1710
1715
|
total: 10
|
|
1711
1716
|
}, {
|
|
@@ -1717,7 +1722,8 @@ const importStatesMap = {
|
|
|
1717
1722
|
waitForMasterVariant: 0,
|
|
1718
1723
|
processing: 0,
|
|
1719
1724
|
canceled: 0,
|
|
1720
|
-
deleted: 0
|
|
1725
|
+
deleted: 0,
|
|
1726
|
+
partiallyImported: 0
|
|
1721
1727
|
},
|
|
1722
1728
|
total: 10
|
|
1723
1729
|
}, {
|
|
@@ -1729,7 +1735,8 @@ const importStatesMap = {
|
|
|
1729
1735
|
waitForMasterVariant: 0,
|
|
1730
1736
|
processing: 0,
|
|
1731
1737
|
canceled: 0,
|
|
1732
|
-
deleted: 0
|
|
1738
|
+
deleted: 0,
|
|
1739
|
+
partiallyImported: 0
|
|
1733
1740
|
},
|
|
1734
1741
|
total: 40
|
|
1735
1742
|
}],
|
|
@@ -1742,7 +1749,8 @@ const importStatesMap = {
|
|
|
1742
1749
|
waitForMasterVariant: 0,
|
|
1743
1750
|
processing: 0,
|
|
1744
1751
|
canceled: 0,
|
|
1745
|
-
deleted: 0
|
|
1752
|
+
deleted: 0,
|
|
1753
|
+
partiallyImported: 0
|
|
1746
1754
|
},
|
|
1747
1755
|
total: 8
|
|
1748
1756
|
}, {
|
|
@@ -1754,7 +1762,8 @@ const importStatesMap = {
|
|
|
1754
1762
|
waitForMasterVariant: 0,
|
|
1755
1763
|
processing: 0,
|
|
1756
1764
|
canceled: 0,
|
|
1757
|
-
deleted: 0
|
|
1765
|
+
deleted: 0,
|
|
1766
|
+
partiallyImported: 0
|
|
1758
1767
|
},
|
|
1759
1768
|
total: 10
|
|
1760
1769
|
}, {
|
|
@@ -1766,7 +1775,8 @@ const importStatesMap = {
|
|
|
1766
1775
|
waitForMasterVariant: 0,
|
|
1767
1776
|
processing: 0,
|
|
1768
1777
|
canceled: 0,
|
|
1769
|
-
deleted: 0
|
|
1778
|
+
deleted: 0,
|
|
1779
|
+
partiallyImported: 0
|
|
1770
1780
|
},
|
|
1771
1781
|
total: 10
|
|
1772
1782
|
}],
|
|
@@ -1779,7 +1789,8 @@ const importStatesMap = {
|
|
|
1779
1789
|
waitForMasterVariant: 0,
|
|
1780
1790
|
processing: 0,
|
|
1781
1791
|
canceled: 0,
|
|
1782
|
-
deleted: 0
|
|
1792
|
+
deleted: 0,
|
|
1793
|
+
partiallyImported: 0
|
|
1783
1794
|
},
|
|
1784
1795
|
total: 3
|
|
1785
1796
|
}, {
|
|
@@ -1791,7 +1802,8 @@ const importStatesMap = {
|
|
|
1791
1802
|
waitForMasterVariant: 0,
|
|
1792
1803
|
processing: 0,
|
|
1793
1804
|
canceled: 0,
|
|
1794
|
-
deleted: 0
|
|
1805
|
+
deleted: 0,
|
|
1806
|
+
partiallyImported: 0
|
|
1795
1807
|
},
|
|
1796
1808
|
total: 30
|
|
1797
1809
|
}],
|
|
@@ -1804,7 +1816,8 @@ const importStatesMap = {
|
|
|
1804
1816
|
waitForMasterVariant: 0,
|
|
1805
1817
|
processing: 0,
|
|
1806
1818
|
canceled: 0,
|
|
1807
|
-
deleted: 0
|
|
1819
|
+
deleted: 0,
|
|
1820
|
+
partiallyImported: 0
|
|
1808
1821
|
},
|
|
1809
1822
|
total: 20
|
|
1810
1823
|
}, {
|
|
@@ -1816,7 +1829,8 @@ const importStatesMap = {
|
|
|
1816
1829
|
waitForMasterVariant: 0,
|
|
1817
1830
|
processing: 0,
|
|
1818
1831
|
canceled: 0,
|
|
1819
|
-
deleted: 0
|
|
1832
|
+
deleted: 0,
|
|
1833
|
+
partiallyImported: 0
|
|
1820
1834
|
},
|
|
1821
1835
|
total: 10
|
|
1822
1836
|
}],
|
|
@@ -1829,7 +1843,8 @@ const importStatesMap = {
|
|
|
1829
1843
|
waitForMasterVariant: 0,
|
|
1830
1844
|
processing: 0,
|
|
1831
1845
|
canceled: 0,
|
|
1832
|
-
deleted: 0
|
|
1846
|
+
deleted: 0,
|
|
1847
|
+
partiallyImported: 0
|
|
1833
1848
|
},
|
|
1834
1849
|
total: 0
|
|
1835
1850
|
}],
|
|
@@ -1842,9 +1857,37 @@ const importStatesMap = {
|
|
|
1842
1857
|
waitForMasterVariant: 0,
|
|
1843
1858
|
processing: 0,
|
|
1844
1859
|
canceled: 10,
|
|
1845
|
-
deleted: 0
|
|
1860
|
+
deleted: 0,
|
|
1861
|
+
partiallyImported: 0
|
|
1846
1862
|
},
|
|
1847
1863
|
total: 10
|
|
1864
|
+
}],
|
|
1865
|
+
[ImportStates.PartiallyImported]: [{
|
|
1866
|
+
states: {
|
|
1867
|
+
unresolved: 0,
|
|
1868
|
+
imported: 0,
|
|
1869
|
+
rejected: 0,
|
|
1870
|
+
validationFailed: 0,
|
|
1871
|
+
waitForMasterVariant: 0,
|
|
1872
|
+
processing: 0,
|
|
1873
|
+
canceled: 0,
|
|
1874
|
+
deleted: 0,
|
|
1875
|
+
partiallyImported: 2
|
|
1876
|
+
},
|
|
1877
|
+
total: 2
|
|
1878
|
+
}, {
|
|
1879
|
+
states: {
|
|
1880
|
+
unresolved: 0,
|
|
1881
|
+
imported: 1,
|
|
1882
|
+
rejected: 0,
|
|
1883
|
+
validationFailed: 0,
|
|
1884
|
+
waitForMasterVariant: 0,
|
|
1885
|
+
processing: 0,
|
|
1886
|
+
canceled: 0,
|
|
1887
|
+
deleted: 0,
|
|
1888
|
+
partiallyImported: 1
|
|
1889
|
+
},
|
|
1890
|
+
total: 2
|
|
1848
1891
|
}]
|
|
1849
1892
|
};
|
|
1850
1893
|
const validFileUploadResponse = {
|
|
@@ -2989,12 +3032,13 @@ const useFileImportJobUpload = _ref => {
|
|
|
2989
3032
|
} : {}),
|
|
2990
3033
|
projectKey
|
|
2991
3034
|
});
|
|
3035
|
+
const fileType = config.fileType ?? getFileImportJobFileType(config.resourceType);
|
|
2992
3036
|
const jobResponse = await createFileImportJob({
|
|
2993
3037
|
projectKey,
|
|
2994
3038
|
resourceType: config.resourceType,
|
|
2995
3039
|
importContainerKey,
|
|
2996
3040
|
payload: {
|
|
2997
|
-
fileType
|
|
3041
|
+
fileType,
|
|
2998
3042
|
fileName: config.file.name,
|
|
2999
3043
|
file: config.file
|
|
3000
3044
|
},
|
|
@@ -3187,6 +3231,7 @@ const useFileUpload = _ref2 => {
|
|
|
3187
3231
|
await jobUpload.upload({
|
|
3188
3232
|
file: config.file,
|
|
3189
3233
|
resourceType: config.resourceType,
|
|
3234
|
+
fileType: config.fileType,
|
|
3190
3235
|
settings: config.settings,
|
|
3191
3236
|
autoProcess: config.autoProcess,
|
|
3192
3237
|
operationType: config.operationType,
|
|
@@ -510,6 +510,7 @@ let ImportStates = /*#__PURE__*/function (ImportStates) {
|
|
|
510
510
|
ImportStates["Processing"] = "processing";
|
|
511
511
|
ImportStates["WaitForUnresolvedReferences"] = "wait-for-unresolved-references";
|
|
512
512
|
ImportStates["PartiallyCompleted"] = "partially-completed";
|
|
513
|
+
ImportStates["PartiallyImported"] = "partially-imported";
|
|
513
514
|
ImportStates["Failed"] = "failed";
|
|
514
515
|
ImportStates["SuccessfullyCompleted"] = "successfully-completed";
|
|
515
516
|
ImportStates["NoRunningImports"] = "no-running-imports";
|
|
@@ -1263,10 +1264,12 @@ function ownKeys$6(e, r) { var t = _Object$keys__default["default"](e); if (_Obj
|
|
|
1263
1264
|
function _objectSpread$6(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$6(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$6(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1264
1265
|
function getImportState(importSummary) {
|
|
1265
1266
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1267
|
+
const partiallyImported = importSummary.states.partiallyImported ?? 0;
|
|
1266
1268
|
const processing = importSummary.states.processing > 0;
|
|
1267
1269
|
if (processing) return ImportStates.Processing;
|
|
1268
1270
|
const waitForUnresolvedReferences = importSummary.states.waitForMasterVariant > 0 || importSummary.states.unresolved > 0;
|
|
1269
1271
|
if (waitForUnresolvedReferences) return ImportStates.WaitForUnresolvedReferences;
|
|
1272
|
+
if (partiallyImported > 0) return ImportStates.PartiallyImported;
|
|
1270
1273
|
const partiallyCompleted = importSummary.states.imported > 0 && importSummary.states.imported < importSummary.total || importSummary.states.deleted > 0 && importSummary.states.deleted < importSummary.total;
|
|
1271
1274
|
if (partiallyCompleted) return ImportStates.PartiallyCompleted;
|
|
1272
1275
|
const noRunning = importSummary.total === 0;
|
|
@@ -1692,7 +1695,8 @@ const importStatesMap = {
|
|
|
1692
1695
|
waitForMasterVariant: 0,
|
|
1693
1696
|
processing: 10,
|
|
1694
1697
|
canceled: 0,
|
|
1695
|
-
deleted: 0
|
|
1698
|
+
deleted: 0,
|
|
1699
|
+
partiallyImported: 0
|
|
1696
1700
|
},
|
|
1697
1701
|
total: 10
|
|
1698
1702
|
}],
|
|
@@ -1705,7 +1709,8 @@ const importStatesMap = {
|
|
|
1705
1709
|
waitForMasterVariant: 10,
|
|
1706
1710
|
processing: 0,
|
|
1707
1711
|
canceled: 0,
|
|
1708
|
-
deleted: 0
|
|
1712
|
+
deleted: 0,
|
|
1713
|
+
partiallyImported: 0
|
|
1709
1714
|
},
|
|
1710
1715
|
total: 10
|
|
1711
1716
|
}, {
|
|
@@ -1717,7 +1722,8 @@ const importStatesMap = {
|
|
|
1717
1722
|
waitForMasterVariant: 0,
|
|
1718
1723
|
processing: 0,
|
|
1719
1724
|
canceled: 0,
|
|
1720
|
-
deleted: 0
|
|
1725
|
+
deleted: 0,
|
|
1726
|
+
partiallyImported: 0
|
|
1721
1727
|
},
|
|
1722
1728
|
total: 10
|
|
1723
1729
|
}, {
|
|
@@ -1729,7 +1735,8 @@ const importStatesMap = {
|
|
|
1729
1735
|
waitForMasterVariant: 0,
|
|
1730
1736
|
processing: 0,
|
|
1731
1737
|
canceled: 0,
|
|
1732
|
-
deleted: 0
|
|
1738
|
+
deleted: 0,
|
|
1739
|
+
partiallyImported: 0
|
|
1733
1740
|
},
|
|
1734
1741
|
total: 40
|
|
1735
1742
|
}],
|
|
@@ -1742,7 +1749,8 @@ const importStatesMap = {
|
|
|
1742
1749
|
waitForMasterVariant: 0,
|
|
1743
1750
|
processing: 0,
|
|
1744
1751
|
canceled: 0,
|
|
1745
|
-
deleted: 0
|
|
1752
|
+
deleted: 0,
|
|
1753
|
+
partiallyImported: 0
|
|
1746
1754
|
},
|
|
1747
1755
|
total: 8
|
|
1748
1756
|
}, {
|
|
@@ -1754,7 +1762,8 @@ const importStatesMap = {
|
|
|
1754
1762
|
waitForMasterVariant: 0,
|
|
1755
1763
|
processing: 0,
|
|
1756
1764
|
canceled: 0,
|
|
1757
|
-
deleted: 0
|
|
1765
|
+
deleted: 0,
|
|
1766
|
+
partiallyImported: 0
|
|
1758
1767
|
},
|
|
1759
1768
|
total: 10
|
|
1760
1769
|
}, {
|
|
@@ -1766,7 +1775,8 @@ const importStatesMap = {
|
|
|
1766
1775
|
waitForMasterVariant: 0,
|
|
1767
1776
|
processing: 0,
|
|
1768
1777
|
canceled: 0,
|
|
1769
|
-
deleted: 0
|
|
1778
|
+
deleted: 0,
|
|
1779
|
+
partiallyImported: 0
|
|
1770
1780
|
},
|
|
1771
1781
|
total: 10
|
|
1772
1782
|
}],
|
|
@@ -1779,7 +1789,8 @@ const importStatesMap = {
|
|
|
1779
1789
|
waitForMasterVariant: 0,
|
|
1780
1790
|
processing: 0,
|
|
1781
1791
|
canceled: 0,
|
|
1782
|
-
deleted: 0
|
|
1792
|
+
deleted: 0,
|
|
1793
|
+
partiallyImported: 0
|
|
1783
1794
|
},
|
|
1784
1795
|
total: 3
|
|
1785
1796
|
}, {
|
|
@@ -1791,7 +1802,8 @@ const importStatesMap = {
|
|
|
1791
1802
|
waitForMasterVariant: 0,
|
|
1792
1803
|
processing: 0,
|
|
1793
1804
|
canceled: 0,
|
|
1794
|
-
deleted: 0
|
|
1805
|
+
deleted: 0,
|
|
1806
|
+
partiallyImported: 0
|
|
1795
1807
|
},
|
|
1796
1808
|
total: 30
|
|
1797
1809
|
}],
|
|
@@ -1804,7 +1816,8 @@ const importStatesMap = {
|
|
|
1804
1816
|
waitForMasterVariant: 0,
|
|
1805
1817
|
processing: 0,
|
|
1806
1818
|
canceled: 0,
|
|
1807
|
-
deleted: 0
|
|
1819
|
+
deleted: 0,
|
|
1820
|
+
partiallyImported: 0
|
|
1808
1821
|
},
|
|
1809
1822
|
total: 20
|
|
1810
1823
|
}, {
|
|
@@ -1816,7 +1829,8 @@ const importStatesMap = {
|
|
|
1816
1829
|
waitForMasterVariant: 0,
|
|
1817
1830
|
processing: 0,
|
|
1818
1831
|
canceled: 0,
|
|
1819
|
-
deleted: 0
|
|
1832
|
+
deleted: 0,
|
|
1833
|
+
partiallyImported: 0
|
|
1820
1834
|
},
|
|
1821
1835
|
total: 10
|
|
1822
1836
|
}],
|
|
@@ -1829,7 +1843,8 @@ const importStatesMap = {
|
|
|
1829
1843
|
waitForMasterVariant: 0,
|
|
1830
1844
|
processing: 0,
|
|
1831
1845
|
canceled: 0,
|
|
1832
|
-
deleted: 0
|
|
1846
|
+
deleted: 0,
|
|
1847
|
+
partiallyImported: 0
|
|
1833
1848
|
},
|
|
1834
1849
|
total: 0
|
|
1835
1850
|
}],
|
|
@@ -1842,9 +1857,37 @@ const importStatesMap = {
|
|
|
1842
1857
|
waitForMasterVariant: 0,
|
|
1843
1858
|
processing: 0,
|
|
1844
1859
|
canceled: 10,
|
|
1845
|
-
deleted: 0
|
|
1860
|
+
deleted: 0,
|
|
1861
|
+
partiallyImported: 0
|
|
1846
1862
|
},
|
|
1847
1863
|
total: 10
|
|
1864
|
+
}],
|
|
1865
|
+
[ImportStates.PartiallyImported]: [{
|
|
1866
|
+
states: {
|
|
1867
|
+
unresolved: 0,
|
|
1868
|
+
imported: 0,
|
|
1869
|
+
rejected: 0,
|
|
1870
|
+
validationFailed: 0,
|
|
1871
|
+
waitForMasterVariant: 0,
|
|
1872
|
+
processing: 0,
|
|
1873
|
+
canceled: 0,
|
|
1874
|
+
deleted: 0,
|
|
1875
|
+
partiallyImported: 2
|
|
1876
|
+
},
|
|
1877
|
+
total: 2
|
|
1878
|
+
}, {
|
|
1879
|
+
states: {
|
|
1880
|
+
unresolved: 0,
|
|
1881
|
+
imported: 1,
|
|
1882
|
+
rejected: 0,
|
|
1883
|
+
validationFailed: 0,
|
|
1884
|
+
waitForMasterVariant: 0,
|
|
1885
|
+
processing: 0,
|
|
1886
|
+
canceled: 0,
|
|
1887
|
+
deleted: 0,
|
|
1888
|
+
partiallyImported: 1
|
|
1889
|
+
},
|
|
1890
|
+
total: 2
|
|
1848
1891
|
}]
|
|
1849
1892
|
};
|
|
1850
1893
|
const validFileUploadResponse = {
|
|
@@ -2981,12 +3024,13 @@ const useFileImportJobUpload = _ref => {
|
|
|
2981
3024
|
} : {}),
|
|
2982
3025
|
projectKey
|
|
2983
3026
|
});
|
|
3027
|
+
const fileType = config.fileType ?? getFileImportJobFileType(config.resourceType);
|
|
2984
3028
|
const jobResponse = await createFileImportJob({
|
|
2985
3029
|
projectKey,
|
|
2986
3030
|
resourceType: config.resourceType,
|
|
2987
3031
|
importContainerKey,
|
|
2988
3032
|
payload: {
|
|
2989
|
-
fileType
|
|
3033
|
+
fileType,
|
|
2990
3034
|
fileName: config.file.name,
|
|
2991
3035
|
file: config.file
|
|
2992
3036
|
},
|
|
@@ -3179,6 +3223,7 @@ const useFileUpload = _ref2 => {
|
|
|
3179
3223
|
await jobUpload.upload({
|
|
3180
3224
|
file: config.file,
|
|
3181
3225
|
resourceType: config.resourceType,
|
|
3226
|
+
fileType: config.fileType,
|
|
3182
3227
|
settings: config.settings,
|
|
3183
3228
|
autoProcess: config.autoProcess,
|
|
3184
3229
|
operationType: config.operationType,
|
|
@@ -472,6 +472,7 @@ let ImportStates = /*#__PURE__*/function (ImportStates) {
|
|
|
472
472
|
ImportStates["Processing"] = "processing";
|
|
473
473
|
ImportStates["WaitForUnresolvedReferences"] = "wait-for-unresolved-references";
|
|
474
474
|
ImportStates["PartiallyCompleted"] = "partially-completed";
|
|
475
|
+
ImportStates["PartiallyImported"] = "partially-imported";
|
|
475
476
|
ImportStates["Failed"] = "failed";
|
|
476
477
|
ImportStates["SuccessfullyCompleted"] = "successfully-completed";
|
|
477
478
|
ImportStates["NoRunningImports"] = "no-running-imports";
|
|
@@ -1225,10 +1226,12 @@ function ownKeys$6(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySy
|
|
|
1225
1226
|
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$6(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$6(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1226
1227
|
function getImportState(importSummary) {
|
|
1227
1228
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1229
|
+
const partiallyImported = importSummary.states.partiallyImported ?? 0;
|
|
1228
1230
|
const processing = importSummary.states.processing > 0;
|
|
1229
1231
|
if (processing) return ImportStates.Processing;
|
|
1230
1232
|
const waitForUnresolvedReferences = importSummary.states.waitForMasterVariant > 0 || importSummary.states.unresolved > 0;
|
|
1231
1233
|
if (waitForUnresolvedReferences) return ImportStates.WaitForUnresolvedReferences;
|
|
1234
|
+
if (partiallyImported > 0) return ImportStates.PartiallyImported;
|
|
1232
1235
|
const partiallyCompleted = importSummary.states.imported > 0 && importSummary.states.imported < importSummary.total || importSummary.states.deleted > 0 && importSummary.states.deleted < importSummary.total;
|
|
1233
1236
|
if (partiallyCompleted) return ImportStates.PartiallyCompleted;
|
|
1234
1237
|
const noRunning = importSummary.total === 0;
|
|
@@ -1654,7 +1657,8 @@ const importStatesMap = {
|
|
|
1654
1657
|
waitForMasterVariant: 0,
|
|
1655
1658
|
processing: 10,
|
|
1656
1659
|
canceled: 0,
|
|
1657
|
-
deleted: 0
|
|
1660
|
+
deleted: 0,
|
|
1661
|
+
partiallyImported: 0
|
|
1658
1662
|
},
|
|
1659
1663
|
total: 10
|
|
1660
1664
|
}],
|
|
@@ -1667,7 +1671,8 @@ const importStatesMap = {
|
|
|
1667
1671
|
waitForMasterVariant: 10,
|
|
1668
1672
|
processing: 0,
|
|
1669
1673
|
canceled: 0,
|
|
1670
|
-
deleted: 0
|
|
1674
|
+
deleted: 0,
|
|
1675
|
+
partiallyImported: 0
|
|
1671
1676
|
},
|
|
1672
1677
|
total: 10
|
|
1673
1678
|
}, {
|
|
@@ -1679,7 +1684,8 @@ const importStatesMap = {
|
|
|
1679
1684
|
waitForMasterVariant: 0,
|
|
1680
1685
|
processing: 0,
|
|
1681
1686
|
canceled: 0,
|
|
1682
|
-
deleted: 0
|
|
1687
|
+
deleted: 0,
|
|
1688
|
+
partiallyImported: 0
|
|
1683
1689
|
},
|
|
1684
1690
|
total: 10
|
|
1685
1691
|
}, {
|
|
@@ -1691,7 +1697,8 @@ const importStatesMap = {
|
|
|
1691
1697
|
waitForMasterVariant: 0,
|
|
1692
1698
|
processing: 0,
|
|
1693
1699
|
canceled: 0,
|
|
1694
|
-
deleted: 0
|
|
1700
|
+
deleted: 0,
|
|
1701
|
+
partiallyImported: 0
|
|
1695
1702
|
},
|
|
1696
1703
|
total: 40
|
|
1697
1704
|
}],
|
|
@@ -1704,7 +1711,8 @@ const importStatesMap = {
|
|
|
1704
1711
|
waitForMasterVariant: 0,
|
|
1705
1712
|
processing: 0,
|
|
1706
1713
|
canceled: 0,
|
|
1707
|
-
deleted: 0
|
|
1714
|
+
deleted: 0,
|
|
1715
|
+
partiallyImported: 0
|
|
1708
1716
|
},
|
|
1709
1717
|
total: 8
|
|
1710
1718
|
}, {
|
|
@@ -1716,7 +1724,8 @@ const importStatesMap = {
|
|
|
1716
1724
|
waitForMasterVariant: 0,
|
|
1717
1725
|
processing: 0,
|
|
1718
1726
|
canceled: 0,
|
|
1719
|
-
deleted: 0
|
|
1727
|
+
deleted: 0,
|
|
1728
|
+
partiallyImported: 0
|
|
1720
1729
|
},
|
|
1721
1730
|
total: 10
|
|
1722
1731
|
}, {
|
|
@@ -1728,7 +1737,8 @@ const importStatesMap = {
|
|
|
1728
1737
|
waitForMasterVariant: 0,
|
|
1729
1738
|
processing: 0,
|
|
1730
1739
|
canceled: 0,
|
|
1731
|
-
deleted: 0
|
|
1740
|
+
deleted: 0,
|
|
1741
|
+
partiallyImported: 0
|
|
1732
1742
|
},
|
|
1733
1743
|
total: 10
|
|
1734
1744
|
}],
|
|
@@ -1741,7 +1751,8 @@ const importStatesMap = {
|
|
|
1741
1751
|
waitForMasterVariant: 0,
|
|
1742
1752
|
processing: 0,
|
|
1743
1753
|
canceled: 0,
|
|
1744
|
-
deleted: 0
|
|
1754
|
+
deleted: 0,
|
|
1755
|
+
partiallyImported: 0
|
|
1745
1756
|
},
|
|
1746
1757
|
total: 3
|
|
1747
1758
|
}, {
|
|
@@ -1753,7 +1764,8 @@ const importStatesMap = {
|
|
|
1753
1764
|
waitForMasterVariant: 0,
|
|
1754
1765
|
processing: 0,
|
|
1755
1766
|
canceled: 0,
|
|
1756
|
-
deleted: 0
|
|
1767
|
+
deleted: 0,
|
|
1768
|
+
partiallyImported: 0
|
|
1757
1769
|
},
|
|
1758
1770
|
total: 30
|
|
1759
1771
|
}],
|
|
@@ -1766,7 +1778,8 @@ const importStatesMap = {
|
|
|
1766
1778
|
waitForMasterVariant: 0,
|
|
1767
1779
|
processing: 0,
|
|
1768
1780
|
canceled: 0,
|
|
1769
|
-
deleted: 0
|
|
1781
|
+
deleted: 0,
|
|
1782
|
+
partiallyImported: 0
|
|
1770
1783
|
},
|
|
1771
1784
|
total: 20
|
|
1772
1785
|
}, {
|
|
@@ -1778,7 +1791,8 @@ const importStatesMap = {
|
|
|
1778
1791
|
waitForMasterVariant: 0,
|
|
1779
1792
|
processing: 0,
|
|
1780
1793
|
canceled: 0,
|
|
1781
|
-
deleted: 0
|
|
1794
|
+
deleted: 0,
|
|
1795
|
+
partiallyImported: 0
|
|
1782
1796
|
},
|
|
1783
1797
|
total: 10
|
|
1784
1798
|
}],
|
|
@@ -1791,7 +1805,8 @@ const importStatesMap = {
|
|
|
1791
1805
|
waitForMasterVariant: 0,
|
|
1792
1806
|
processing: 0,
|
|
1793
1807
|
canceled: 0,
|
|
1794
|
-
deleted: 0
|
|
1808
|
+
deleted: 0,
|
|
1809
|
+
partiallyImported: 0
|
|
1795
1810
|
},
|
|
1796
1811
|
total: 0
|
|
1797
1812
|
}],
|
|
@@ -1804,9 +1819,37 @@ const importStatesMap = {
|
|
|
1804
1819
|
waitForMasterVariant: 0,
|
|
1805
1820
|
processing: 0,
|
|
1806
1821
|
canceled: 10,
|
|
1807
|
-
deleted: 0
|
|
1822
|
+
deleted: 0,
|
|
1823
|
+
partiallyImported: 0
|
|
1808
1824
|
},
|
|
1809
1825
|
total: 10
|
|
1826
|
+
}],
|
|
1827
|
+
[ImportStates.PartiallyImported]: [{
|
|
1828
|
+
states: {
|
|
1829
|
+
unresolved: 0,
|
|
1830
|
+
imported: 0,
|
|
1831
|
+
rejected: 0,
|
|
1832
|
+
validationFailed: 0,
|
|
1833
|
+
waitForMasterVariant: 0,
|
|
1834
|
+
processing: 0,
|
|
1835
|
+
canceled: 0,
|
|
1836
|
+
deleted: 0,
|
|
1837
|
+
partiallyImported: 2
|
|
1838
|
+
},
|
|
1839
|
+
total: 2
|
|
1840
|
+
}, {
|
|
1841
|
+
states: {
|
|
1842
|
+
unresolved: 0,
|
|
1843
|
+
imported: 1,
|
|
1844
|
+
rejected: 0,
|
|
1845
|
+
validationFailed: 0,
|
|
1846
|
+
waitForMasterVariant: 0,
|
|
1847
|
+
processing: 0,
|
|
1848
|
+
canceled: 0,
|
|
1849
|
+
deleted: 0,
|
|
1850
|
+
partiallyImported: 1
|
|
1851
|
+
},
|
|
1852
|
+
total: 2
|
|
1810
1853
|
}]
|
|
1811
1854
|
};
|
|
1812
1855
|
const validFileUploadResponse = {
|
|
@@ -2951,12 +2994,13 @@ const useFileImportJobUpload = _ref => {
|
|
|
2951
2994
|
} : {}),
|
|
2952
2995
|
projectKey
|
|
2953
2996
|
});
|
|
2997
|
+
const fileType = config.fileType ?? getFileImportJobFileType(config.resourceType);
|
|
2954
2998
|
const jobResponse = await createFileImportJob({
|
|
2955
2999
|
projectKey,
|
|
2956
3000
|
resourceType: config.resourceType,
|
|
2957
3001
|
importContainerKey,
|
|
2958
3002
|
payload: {
|
|
2959
|
-
fileType
|
|
3003
|
+
fileType,
|
|
2960
3004
|
fileName: config.file.name,
|
|
2961
3005
|
file: config.file
|
|
2962
3006
|
},
|
|
@@ -3149,6 +3193,7 @@ const useFileUpload = _ref2 => {
|
|
|
3149
3193
|
await jobUpload.upload({
|
|
3150
3194
|
file: config.file,
|
|
3151
3195
|
resourceType: config.resourceType,
|
|
3196
|
+
fileType: config.fileType,
|
|
3152
3197
|
settings: config.settings,
|
|
3153
3198
|
autoProcess: config.autoProcess,
|
|
3154
3199
|
operationType: config.operationType,
|
|
@@ -3,6 +3,7 @@ import type { ExtendedImportContainerDraft } from "../@types/index.js";
|
|
|
3
3
|
export type UseFileImportJobUploadConfig = {
|
|
4
4
|
file: File;
|
|
5
5
|
resourceType: ResourceTypeId;
|
|
6
|
+
fileType?: 'csv' | 'json';
|
|
6
7
|
settings?: ExtendedImportContainerDraft['settings'];
|
|
7
8
|
autoProcess?: boolean;
|
|
8
9
|
operationType?: 'delete';
|
|
@@ -2,6 +2,7 @@ export declare enum ImportStates {
|
|
|
2
2
|
Processing = "processing",
|
|
3
3
|
WaitForUnresolvedReferences = "wait-for-unresolved-references",
|
|
4
4
|
PartiallyCompleted = "partially-completed",
|
|
5
|
+
PartiallyImported = "partially-imported",
|
|
5
6
|
Failed = "failed",
|
|
6
7
|
SuccessfullyCompleted = "successfully-completed",
|
|
7
8
|
NoRunningImports = "no-running-imports",
|
|
@@ -8,6 +8,10 @@ interface ExtendedOperationStates extends OperationStates {
|
|
|
8
8
|
* The number of resources in the `deleted` state.
|
|
9
9
|
*/
|
|
10
10
|
readonly deleted: number;
|
|
11
|
+
/**
|
|
12
|
+
* The number of resources in the `partiallyImported` state.
|
|
13
|
+
*/
|
|
14
|
+
readonly partiallyImported: number;
|
|
11
15
|
}
|
|
12
16
|
export interface ExtendedImportSummary extends ImportSummary {
|
|
13
17
|
readonly states: ExtendedOperationStates;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend-extensions/operations",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"license": "Proprietary",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"react-dropzone": "14.3.8"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@commercetools-frontend/actions-global": "
|
|
22
|
-
"@commercetools-frontend/application-components": "
|
|
23
|
-
"@commercetools-frontend/application-shell": "
|
|
24
|
-
"@commercetools-frontend/application-shell-connectors": "
|
|
25
|
-
"@commercetools-frontend/constants": "
|
|
26
|
-
"@commercetools-frontend/jest-preset-mc-app": "
|
|
27
|
-
"@commercetools-frontend/permissions": "
|
|
28
|
-
"@commercetools-frontend/sentry": "
|
|
21
|
+
"@commercetools-frontend/actions-global": "27.0.0",
|
|
22
|
+
"@commercetools-frontend/application-components": "27.0.0",
|
|
23
|
+
"@commercetools-frontend/application-shell": "27.0.0",
|
|
24
|
+
"@commercetools-frontend/application-shell-connectors": "27.0.0",
|
|
25
|
+
"@commercetools-frontend/constants": "27.0.0",
|
|
26
|
+
"@commercetools-frontend/jest-preset-mc-app": "27.0.0",
|
|
27
|
+
"@commercetools-frontend/permissions": "27.0.0",
|
|
28
|
+
"@commercetools-frontend/sentry": "27.0.0",
|
|
29
29
|
"@commercetools-frontend/ui-kit": "20.3.0",
|
|
30
30
|
"@emotion/react": "11.14.0",
|
|
31
31
|
"@emotion/styled": "11.14.1",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"typescript": "5.4.5"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
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",
|
|
44
|
+
"@commercetools-frontend/actions-global": "24.x || 25.x || 27.x",
|
|
45
|
+
"@commercetools-frontend/application-components": "24.x || 25.x || 27.x",
|
|
46
|
+
"@commercetools-frontend/application-shell": "24.x || 25.x || 27.x",
|
|
47
|
+
"@commercetools-frontend/application-shell-connectors": "24.x || 25.x || 27.x",
|
|
48
|
+
"@commercetools-frontend/constants": "24.x || 25.x || 27.x",
|
|
49
|
+
"@commercetools-frontend/permissions": "24.x || 25.x || 27.x",
|
|
50
|
+
"@commercetools-frontend/sentry": "24.x || 25.x || 27.x",
|
|
51
51
|
"@commercetools-frontend/ui-kit": "19.x || 20.x",
|
|
52
52
|
"@emotion/react": "11.x",
|
|
53
53
|
"@emotion/styled": "11.x",
|
|
@@ -37,6 +37,8 @@ export function getImportState(
|
|
|
37
37
|
importSummary: ImportSummary,
|
|
38
38
|
options: GetImportStateOptions = {}
|
|
39
39
|
): ImportStates {
|
|
40
|
+
const partiallyImported = importSummary.states.partiallyImported ?? 0
|
|
41
|
+
|
|
40
42
|
const processing = importSummary.states.processing > 0
|
|
41
43
|
if (processing) return ImportStates.Processing
|
|
42
44
|
|
|
@@ -46,6 +48,8 @@ export function getImportState(
|
|
|
46
48
|
if (waitForUnresolvedReferences)
|
|
47
49
|
return ImportStates.WaitForUnresolvedReferences
|
|
48
50
|
|
|
51
|
+
if (partiallyImported > 0) return ImportStates.PartiallyImported
|
|
52
|
+
|
|
49
53
|
const partiallyCompleted =
|
|
50
54
|
(importSummary.states.imported > 0 &&
|
|
51
55
|
importSummary.states.imported < importSummary.total) ||
|
|
@@ -114,6 +114,7 @@ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
|
|
|
114
114
|
processing: 10,
|
|
115
115
|
canceled: 0,
|
|
116
116
|
deleted: 0,
|
|
117
|
+
partiallyImported: 0,
|
|
117
118
|
},
|
|
118
119
|
total: 10,
|
|
119
120
|
},
|
|
@@ -129,6 +130,7 @@ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
|
|
|
129
130
|
processing: 0,
|
|
130
131
|
canceled: 0,
|
|
131
132
|
deleted: 0,
|
|
133
|
+
partiallyImported: 0,
|
|
132
134
|
},
|
|
133
135
|
total: 10,
|
|
134
136
|
},
|
|
@@ -142,6 +144,7 @@ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
|
|
|
142
144
|
processing: 0,
|
|
143
145
|
canceled: 0,
|
|
144
146
|
deleted: 0,
|
|
147
|
+
partiallyImported: 0,
|
|
145
148
|
},
|
|
146
149
|
total: 10,
|
|
147
150
|
},
|
|
@@ -155,6 +158,7 @@ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
|
|
|
155
158
|
processing: 0,
|
|
156
159
|
canceled: 0,
|
|
157
160
|
deleted: 0,
|
|
161
|
+
partiallyImported: 0,
|
|
158
162
|
},
|
|
159
163
|
total: 40,
|
|
160
164
|
},
|
|
@@ -170,6 +174,7 @@ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
|
|
|
170
174
|
processing: 0,
|
|
171
175
|
canceled: 0,
|
|
172
176
|
deleted: 0,
|
|
177
|
+
partiallyImported: 0,
|
|
173
178
|
},
|
|
174
179
|
total: 8,
|
|
175
180
|
},
|
|
@@ -183,6 +188,7 @@ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
|
|
|
183
188
|
processing: 0,
|
|
184
189
|
canceled: 0,
|
|
185
190
|
deleted: 0,
|
|
191
|
+
partiallyImported: 0,
|
|
186
192
|
},
|
|
187
193
|
total: 10,
|
|
188
194
|
},
|
|
@@ -196,6 +202,7 @@ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
|
|
|
196
202
|
processing: 0,
|
|
197
203
|
canceled: 0,
|
|
198
204
|
deleted: 0,
|
|
205
|
+
partiallyImported: 0,
|
|
199
206
|
},
|
|
200
207
|
total: 10,
|
|
201
208
|
},
|
|
@@ -211,6 +218,7 @@ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
|
|
|
211
218
|
processing: 0,
|
|
212
219
|
canceled: 0,
|
|
213
220
|
deleted: 0,
|
|
221
|
+
partiallyImported: 0,
|
|
214
222
|
},
|
|
215
223
|
total: 3,
|
|
216
224
|
},
|
|
@@ -224,6 +232,7 @@ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
|
|
|
224
232
|
processing: 0,
|
|
225
233
|
canceled: 0,
|
|
226
234
|
deleted: 0,
|
|
235
|
+
partiallyImported: 0,
|
|
227
236
|
},
|
|
228
237
|
total: 30,
|
|
229
238
|
},
|
|
@@ -239,6 +248,7 @@ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
|
|
|
239
248
|
processing: 0,
|
|
240
249
|
canceled: 0,
|
|
241
250
|
deleted: 0,
|
|
251
|
+
partiallyImported: 0,
|
|
242
252
|
},
|
|
243
253
|
total: 20,
|
|
244
254
|
},
|
|
@@ -252,6 +262,7 @@ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
|
|
|
252
262
|
processing: 0,
|
|
253
263
|
canceled: 0,
|
|
254
264
|
deleted: 0,
|
|
265
|
+
partiallyImported: 0,
|
|
255
266
|
},
|
|
256
267
|
total: 10,
|
|
257
268
|
},
|
|
@@ -267,6 +278,7 @@ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
|
|
|
267
278
|
processing: 0,
|
|
268
279
|
canceled: 0,
|
|
269
280
|
deleted: 0,
|
|
281
|
+
partiallyImported: 0,
|
|
270
282
|
},
|
|
271
283
|
total: 0,
|
|
272
284
|
},
|
|
@@ -282,10 +294,41 @@ export const importStatesMap: Record<ImportStates, Array<ImportSummary>> = {
|
|
|
282
294
|
processing: 0,
|
|
283
295
|
canceled: 10,
|
|
284
296
|
deleted: 0,
|
|
297
|
+
partiallyImported: 0,
|
|
285
298
|
},
|
|
286
299
|
total: 10,
|
|
287
300
|
},
|
|
288
301
|
],
|
|
302
|
+
[ImportStates.PartiallyImported]: [
|
|
303
|
+
{
|
|
304
|
+
states: {
|
|
305
|
+
unresolved: 0,
|
|
306
|
+
imported: 0,
|
|
307
|
+
rejected: 0,
|
|
308
|
+
validationFailed: 0,
|
|
309
|
+
waitForMasterVariant: 0,
|
|
310
|
+
processing: 0,
|
|
311
|
+
canceled: 0,
|
|
312
|
+
deleted: 0,
|
|
313
|
+
partiallyImported: 2,
|
|
314
|
+
},
|
|
315
|
+
total: 2,
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
states: {
|
|
319
|
+
unresolved: 0,
|
|
320
|
+
imported: 1,
|
|
321
|
+
rejected: 0,
|
|
322
|
+
validationFailed: 0,
|
|
323
|
+
waitForMasterVariant: 0,
|
|
324
|
+
processing: 0,
|
|
325
|
+
canceled: 0,
|
|
326
|
+
deleted: 0,
|
|
327
|
+
partiallyImported: 1,
|
|
328
|
+
},
|
|
329
|
+
total: 2,
|
|
330
|
+
},
|
|
331
|
+
],
|
|
289
332
|
}
|
|
290
333
|
export const validFileUploadResponse: FileUploadResponse = {
|
|
291
334
|
results: [],
|
|
@@ -262,6 +262,55 @@ describe('useFileImportJobUpload', () => {
|
|
|
262
262
|
expect(result.current.progress).toBe(100)
|
|
263
263
|
})
|
|
264
264
|
|
|
265
|
+
it('should use explicit fileType override instead of deriving from resourceType', async () => {
|
|
266
|
+
const onSuccess = jest.fn()
|
|
267
|
+
|
|
268
|
+
const { result } = renderHook(() => useFileImportJobUpload({ projectKey }))
|
|
269
|
+
|
|
270
|
+
await act(async () => {
|
|
271
|
+
await result.current.upload({
|
|
272
|
+
file: mockFile,
|
|
273
|
+
resourceType: 'product',
|
|
274
|
+
fileType: 'json',
|
|
275
|
+
onSuccess,
|
|
276
|
+
})
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
expect(mockCreateFileImportJob).toHaveBeenCalledWith(
|
|
280
|
+
expect.objectContaining({
|
|
281
|
+
payload: expect.objectContaining({
|
|
282
|
+
fileType: 'json',
|
|
283
|
+
}),
|
|
284
|
+
})
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
expect(mockGetFileImportJobFileType).not.toHaveBeenCalled()
|
|
288
|
+
expect(onSuccess).toHaveBeenCalledWith('job-123', importContainerKey)
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
it('should fall back to derived fileType when fileType override is not provided', async () => {
|
|
292
|
+
const onSuccess = jest.fn()
|
|
293
|
+
|
|
294
|
+
const { result } = renderHook(() => useFileImportJobUpload({ projectKey }))
|
|
295
|
+
|
|
296
|
+
await act(async () => {
|
|
297
|
+
await result.current.upload({
|
|
298
|
+
file: mockFile,
|
|
299
|
+
resourceType: 'product',
|
|
300
|
+
onSuccess,
|
|
301
|
+
})
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
expect(mockGetFileImportJobFileType).toHaveBeenCalledWith('product')
|
|
305
|
+
expect(mockCreateFileImportJob).toHaveBeenCalledWith(
|
|
306
|
+
expect.objectContaining({
|
|
307
|
+
payload: expect.objectContaining({
|
|
308
|
+
fileType: 'csv',
|
|
309
|
+
}),
|
|
310
|
+
})
|
|
311
|
+
)
|
|
312
|
+
})
|
|
313
|
+
|
|
265
314
|
it('should work without optional settings', async () => {
|
|
266
315
|
const onSuccess = jest.fn()
|
|
267
316
|
|
|
@@ -16,6 +16,7 @@ import type { ExtendedImportContainerDraft } from '../@types'
|
|
|
16
16
|
export type UseFileImportJobUploadConfig = {
|
|
17
17
|
file: File
|
|
18
18
|
resourceType: ResourceTypeId
|
|
19
|
+
fileType?: 'csv' | 'json'
|
|
19
20
|
settings?: ExtendedImportContainerDraft['settings']
|
|
20
21
|
autoProcess?: boolean
|
|
21
22
|
operationType?: 'delete'
|
|
@@ -57,12 +58,15 @@ export const useFileImportJobUpload = ({
|
|
|
57
58
|
projectKey,
|
|
58
59
|
})
|
|
59
60
|
|
|
61
|
+
const fileType =
|
|
62
|
+
config.fileType ?? getFileImportJobFileType(config.resourceType)
|
|
63
|
+
|
|
60
64
|
const jobResponse = await createFileImportJob({
|
|
61
65
|
projectKey,
|
|
62
66
|
resourceType: config.resourceType,
|
|
63
67
|
importContainerKey,
|
|
64
68
|
payload: {
|
|
65
|
-
fileType
|
|
69
|
+
fileType,
|
|
66
70
|
fileName: config.file.name,
|
|
67
71
|
file: config.file,
|
|
68
72
|
},
|
|
@@ -19,6 +19,7 @@ export type ValidationProgress = {
|
|
|
19
19
|
export type FileUploadConfig = {
|
|
20
20
|
file: File
|
|
21
21
|
resourceType: ResourceTypeId
|
|
22
|
+
fileType?: 'csv' | 'json'
|
|
22
23
|
settings?: ExtendedImportContainerDraft['settings']
|
|
23
24
|
autoProcess?: boolean
|
|
24
25
|
skipValidationPolling?: boolean
|
|
@@ -85,6 +86,7 @@ export const useFileUpload = ({
|
|
|
85
86
|
await jobUpload.upload({
|
|
86
87
|
file: config.file,
|
|
87
88
|
resourceType: config.resourceType,
|
|
89
|
+
fileType: config.fileType,
|
|
88
90
|
settings: config.settings,
|
|
89
91
|
autoProcess: config.autoProcess,
|
|
90
92
|
operationType: config.operationType,
|
|
@@ -2,6 +2,7 @@ export enum ImportStates {
|
|
|
2
2
|
Processing = 'processing',
|
|
3
3
|
WaitForUnresolvedReferences = 'wait-for-unresolved-references',
|
|
4
4
|
PartiallyCompleted = 'partially-completed',
|
|
5
|
+
PartiallyImported = 'partially-imported',
|
|
5
6
|
Failed = 'failed',
|
|
6
7
|
SuccessfullyCompleted = 'successfully-completed',
|
|
7
8
|
NoRunningImports = 'no-running-imports',
|
|
@@ -12,6 +12,10 @@ interface ExtendedOperationStates extends OperationStates {
|
|
|
12
12
|
* The number of resources in the `deleted` state.
|
|
13
13
|
*/
|
|
14
14
|
readonly deleted: number
|
|
15
|
+
/**
|
|
16
|
+
* The number of resources in the `partiallyImported` state.
|
|
17
|
+
*/
|
|
18
|
+
readonly partiallyImported: number
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
export interface ExtendedImportSummary extends ImportSummary {
|