@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
|
@@ -22,8 +22,8 @@ var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
|
22
22
|
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
23
23
|
var constants = require('@commercetools-frontend/constants');
|
|
24
24
|
var _everyInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/every');
|
|
25
|
-
var pluralize = require('pluralize');
|
|
26
25
|
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
26
|
+
var pluralize = require('pluralize');
|
|
27
27
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
28
28
|
var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
|
|
29
29
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
@@ -31,22 +31,25 @@ var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
|
|
|
31
31
|
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
32
32
|
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
33
33
|
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
34
|
+
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
35
|
+
var _findIndexInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find-index');
|
|
36
|
+
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
37
|
+
var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
34
38
|
var Papa = require('papaparse');
|
|
35
39
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
36
40
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
37
|
-
var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
38
41
|
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
42
|
+
var _setTimeout = require('@babel/runtime-corejs3/core-js-stable/set-timeout');
|
|
43
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
39
44
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
40
45
|
var _URLSearchParams = require('@babel/runtime-corejs3/core-js-stable/url-search-params');
|
|
41
46
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
42
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
43
47
|
var uiKit = require('@commercetools-frontend/ui-kit');
|
|
44
48
|
var React = require('react');
|
|
45
49
|
var jsxRuntime = require('react/jsx-runtime');
|
|
46
50
|
var react = require('@emotion/react');
|
|
47
51
|
var _styled = require('@emotion/styled/base');
|
|
48
52
|
var reactDropzone = require('react-dropzone');
|
|
49
|
-
var reactIntl = require('react-intl');
|
|
50
53
|
var applicationComponents = require('@commercetools-frontend/application-components');
|
|
51
54
|
var _setInterval = require('@babel/runtime-corejs3/core-js-stable/set-interval');
|
|
52
55
|
var sentry = require('@commercetools-frontend/sentry');
|
|
@@ -71,100 +74,106 @@ var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
|
71
74
|
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
72
75
|
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
73
76
|
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
77
|
+
var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
78
|
+
var _findIndexInstanceProperty__default = /*#__PURE__*/_interopDefault(_findIndexInstanceProperty);
|
|
79
|
+
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
80
|
+
var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
|
|
74
81
|
var Papa__default = /*#__PURE__*/_interopDefault(Papa);
|
|
75
82
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
76
83
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
77
|
-
var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
|
|
78
84
|
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
85
|
+
var _setTimeout__default = /*#__PURE__*/_interopDefault(_setTimeout);
|
|
86
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
79
87
|
var _URLSearchParams__default = /*#__PURE__*/_interopDefault(_URLSearchParams);
|
|
80
88
|
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
81
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
82
89
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
83
90
|
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
84
91
|
var _setInterval__default = /*#__PURE__*/_interopDefault(_setInterval);
|
|
85
92
|
|
|
93
|
+
function _callSuper$8(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$8() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
94
|
+
function _isNativeReflectConstruct$8() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$8 = function () { return !!t; })(); }
|
|
95
|
+
let HttpError = /*#__PURE__*/function (_Error) {
|
|
96
|
+
function HttpError(statusCode, statusText, errorData) {
|
|
97
|
+
var _this;
|
|
98
|
+
_classCallCheck(this, HttpError);
|
|
99
|
+
_this = _callSuper$8(this, HttpError, [`HTTP Error! Status code: ${statusCode}, message: "${statusText ? statusText : ''}"`]);
|
|
100
|
+
_this.statusCode = void 0;
|
|
101
|
+
_this.errorData = void 0;
|
|
102
|
+
_this.name = 'HttpError';
|
|
103
|
+
_this.statusCode = statusCode;
|
|
104
|
+
_this.errorData = errorData;
|
|
105
|
+
return _this;
|
|
106
|
+
}
|
|
107
|
+
_inherits(HttpError, _Error);
|
|
108
|
+
return _createClass(HttpError);
|
|
109
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
110
|
+
|
|
86
111
|
function _callSuper$7(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$7() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
87
112
|
function _isNativeReflectConstruct$7() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$7 = function () { return !!t; })(); }
|
|
88
|
-
let
|
|
89
|
-
function
|
|
113
|
+
let InvalidResponseError = /*#__PURE__*/function (_Error) {
|
|
114
|
+
function InvalidResponseError(message) {
|
|
90
115
|
var _this;
|
|
91
|
-
_classCallCheck(this,
|
|
92
|
-
_this = _callSuper$7(this,
|
|
93
|
-
_this.name = '
|
|
116
|
+
_classCallCheck(this, InvalidResponseError);
|
|
117
|
+
_this = _callSuper$7(this, InvalidResponseError, [message]);
|
|
118
|
+
_this.name = 'InvalidResponseError';
|
|
94
119
|
return _this;
|
|
95
120
|
}
|
|
96
|
-
_inherits(
|
|
97
|
-
return _createClass(
|
|
121
|
+
_inherits(InvalidResponseError, _Error);
|
|
122
|
+
return _createClass(InvalidResponseError);
|
|
98
123
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
99
124
|
|
|
100
125
|
function _callSuper$6(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$6() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
101
126
|
function _isNativeReflectConstruct$6() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$6 = function () { return !!t; })(); }
|
|
102
|
-
let
|
|
103
|
-
function
|
|
127
|
+
let NoResourcesToExportError = /*#__PURE__*/function (_Error) {
|
|
128
|
+
function NoResourcesToExportError() {
|
|
104
129
|
var _this;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
_this
|
|
130
|
+
let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'There are no resources to export.';
|
|
131
|
+
_classCallCheck(this, NoResourcesToExportError);
|
|
132
|
+
_this = _callSuper$6(this, NoResourcesToExportError, [message]);
|
|
133
|
+
_this.name = 'NoResourcesToExportError';
|
|
108
134
|
return _this;
|
|
109
135
|
}
|
|
110
|
-
_inherits(
|
|
111
|
-
return _createClass(
|
|
136
|
+
_inherits(NoResourcesToExportError, _Error);
|
|
137
|
+
return _createClass(NoResourcesToExportError);
|
|
112
138
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
113
139
|
|
|
114
140
|
function _callSuper$5(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$5() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
115
141
|
function _isNativeReflectConstruct$5() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$5 = function () { return !!t; })(); }
|
|
116
|
-
let
|
|
117
|
-
function
|
|
142
|
+
let PollingAbortedError = /*#__PURE__*/function (_Error) {
|
|
143
|
+
function PollingAbortedError() {
|
|
118
144
|
var _this;
|
|
119
|
-
_classCallCheck(this,
|
|
120
|
-
_this = _callSuper$5(this,
|
|
121
|
-
_this.name = '
|
|
145
|
+
_classCallCheck(this, PollingAbortedError);
|
|
146
|
+
_this = _callSuper$5(this, PollingAbortedError, ['Polling was aborted']);
|
|
147
|
+
_this.name = 'PollingAbortedError';
|
|
122
148
|
return _this;
|
|
123
149
|
}
|
|
124
|
-
_inherits(
|
|
125
|
-
return _createClass(
|
|
150
|
+
_inherits(PollingAbortedError, _Error);
|
|
151
|
+
return _createClass(PollingAbortedError);
|
|
126
152
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
127
153
|
|
|
128
154
|
function _callSuper$4(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$4() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
129
155
|
function _isNativeReflectConstruct$4() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$4 = function () { return !!t; })(); }
|
|
130
|
-
let
|
|
131
|
-
function
|
|
156
|
+
let ProjectKeyNotAvailableError = /*#__PURE__*/function (_Error) {
|
|
157
|
+
function ProjectKeyNotAvailableError() {
|
|
132
158
|
var _this;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
_this
|
|
136
|
-
_this.
|
|
137
|
-
_this.name = 'HttpError';
|
|
138
|
-
_this.statusCode = statusCode;
|
|
139
|
-
_this.errorData = errorData;
|
|
159
|
+
let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Project key is not available';
|
|
160
|
+
_classCallCheck(this, ProjectKeyNotAvailableError);
|
|
161
|
+
_this = _callSuper$4(this, ProjectKeyNotAvailableError, [message]);
|
|
162
|
+
_this.name = 'ProjectKeyNotAvailableError';
|
|
140
163
|
return _this;
|
|
141
164
|
}
|
|
142
|
-
_inherits(
|
|
143
|
-
return _createClass(
|
|
165
|
+
_inherits(ProjectKeyNotAvailableError, _Error);
|
|
166
|
+
return _createClass(ProjectKeyNotAvailableError);
|
|
144
167
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
145
168
|
|
|
146
169
|
function _callSuper$3(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$3() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
147
170
|
function _isNativeReflectConstruct$3() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$3 = function () { return !!t; })(); }
|
|
148
|
-
let InvalidResponseError = /*#__PURE__*/function (_Error) {
|
|
149
|
-
function InvalidResponseError(message) {
|
|
150
|
-
var _this;
|
|
151
|
-
_classCallCheck(this, InvalidResponseError);
|
|
152
|
-
_this = _callSuper$3(this, InvalidResponseError, [message]);
|
|
153
|
-
_this.name = 'InvalidResponseError';
|
|
154
|
-
return _this;
|
|
155
|
-
}
|
|
156
|
-
_inherits(InvalidResponseError, _Error);
|
|
157
|
-
return _createClass(InvalidResponseError);
|
|
158
|
-
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
159
|
-
|
|
160
|
-
function _callSuper$2(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$2() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
161
|
-
function _isNativeReflectConstruct$2() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$2 = function () { return !!t; })(); }
|
|
162
171
|
let QueryPredicateError = /*#__PURE__*/function (_Error) {
|
|
163
172
|
function QueryPredicateError() {
|
|
164
173
|
var _this;
|
|
165
174
|
let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'There is an error with the query predicate. Make sure the syntax is correct.';
|
|
166
175
|
_classCallCheck(this, QueryPredicateError);
|
|
167
|
-
_this = _callSuper$
|
|
176
|
+
_this = _callSuper$3(this, QueryPredicateError, [message]);
|
|
168
177
|
_this.field = 'queryPredicate';
|
|
169
178
|
_this.name = 'QueryPredicateError';
|
|
170
179
|
return _this;
|
|
@@ -173,38 +182,50 @@ let QueryPredicateError = /*#__PURE__*/function (_Error) {
|
|
|
173
182
|
return _createClass(QueryPredicateError);
|
|
174
183
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
175
184
|
|
|
185
|
+
function _callSuper$2(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$2() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
186
|
+
function _isNativeReflectConstruct$2() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$2 = function () { return !!t; })(); }
|
|
187
|
+
let UnexpectedColumnError = /*#__PURE__*/function (_Error) {
|
|
188
|
+
function UnexpectedColumnError(columnName) {
|
|
189
|
+
var _this;
|
|
190
|
+
_classCallCheck(this, UnexpectedColumnError);
|
|
191
|
+
_this = _callSuper$2(this, UnexpectedColumnError, [`Unexpected column "${columnName}"`]);
|
|
192
|
+
_this.name = 'UnexpectedColumnError';
|
|
193
|
+
return _this;
|
|
194
|
+
}
|
|
195
|
+
_inherits(UnexpectedColumnError, _Error);
|
|
196
|
+
return _createClass(UnexpectedColumnError);
|
|
197
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
198
|
+
|
|
176
199
|
function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
177
200
|
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
178
|
-
let
|
|
179
|
-
function
|
|
201
|
+
let UnexpectedOperationStateError = /*#__PURE__*/function (_Error) {
|
|
202
|
+
function UnexpectedOperationStateError(state) {
|
|
180
203
|
var _this;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
_this =
|
|
184
|
-
_this.name = 'NoResourcesToExportError';
|
|
204
|
+
_classCallCheck(this, UnexpectedOperationStateError);
|
|
205
|
+
_this = _callSuper$1(this, UnexpectedOperationStateError, [`Unexpected operation state "${state}"`]);
|
|
206
|
+
_this.name = 'UnexpectedOperationStateError';
|
|
185
207
|
return _this;
|
|
186
208
|
}
|
|
187
|
-
_inherits(
|
|
188
|
-
return _createClass(
|
|
209
|
+
_inherits(UnexpectedOperationStateError, _Error);
|
|
210
|
+
return _createClass(UnexpectedOperationStateError);
|
|
189
211
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
190
212
|
|
|
191
213
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
192
214
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
193
|
-
let
|
|
194
|
-
function
|
|
215
|
+
let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
|
|
216
|
+
function UnexpectedResourceTypeError(resourceType) {
|
|
195
217
|
var _this;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
_this =
|
|
199
|
-
_this.name = 'ProjectKeyNotAvailableError';
|
|
218
|
+
_classCallCheck(this, UnexpectedResourceTypeError);
|
|
219
|
+
_this = _callSuper(this, UnexpectedResourceTypeError, [`Unexpected resource type "${resourceType}"`]);
|
|
220
|
+
_this.name = 'UnexpectedResourceTypeError';
|
|
200
221
|
return _this;
|
|
201
222
|
}
|
|
202
|
-
_inherits(
|
|
203
|
-
return _createClass(
|
|
223
|
+
_inherits(UnexpectedResourceTypeError, _Error);
|
|
224
|
+
return _createClass(UnexpectedResourceTypeError);
|
|
204
225
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
205
226
|
|
|
206
|
-
function ownKeys$
|
|
207
|
-
function _objectSpread$
|
|
227
|
+
function ownKeys$9(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
228
|
+
function _objectSpread$9(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$9(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$9(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
208
229
|
const addProxyPrefixToUrl = (uri, proxy) => {
|
|
209
230
|
return proxy ? `/proxy/${proxy}${uri}` : uri;
|
|
210
231
|
};
|
|
@@ -213,7 +234,7 @@ const fetcher = async _ref => {
|
|
|
213
234
|
payload = _ref.payload,
|
|
214
235
|
config = _ref.config;
|
|
215
236
|
const data = await applicationShell.executeHttpClientRequest(async options => {
|
|
216
|
-
const res = await fetch(applicationShell.buildApiUrl(addProxyPrefixToUrl(url, config?.proxy)), _objectSpread$
|
|
237
|
+
const res = await fetch(applicationShell.buildApiUrl(addProxyPrefixToUrl(url, config?.proxy)), _objectSpread$9(_objectSpread$9({}, options), {}, {
|
|
217
238
|
method: config?.method,
|
|
218
239
|
body: payload,
|
|
219
240
|
signal: config?.abortSignal
|
|
@@ -229,7 +250,7 @@ const fetcher = async _ref => {
|
|
|
229
250
|
getHeader: key => res.headers.get(key)
|
|
230
251
|
};
|
|
231
252
|
}, {
|
|
232
|
-
headers: _objectSpread$
|
|
253
|
+
headers: _objectSpread$9({
|
|
233
254
|
'Content-Type': 'application/json'
|
|
234
255
|
}, config?.headers)
|
|
235
256
|
});
|
|
@@ -243,7 +264,7 @@ const fetchUsingXhr = _ref2 => {
|
|
|
243
264
|
onSuccess = _ref2.onSuccess,
|
|
244
265
|
onError = _ref2.onError;
|
|
245
266
|
const options = applicationShell.createHttpClientOptions({
|
|
246
|
-
headers: _objectSpread$
|
|
267
|
+
headers: _objectSpread$9({
|
|
247
268
|
'Content-Type': 'application/json'
|
|
248
269
|
}, config?.headers)
|
|
249
270
|
});
|
|
@@ -285,6 +306,15 @@ const fetchUsingXhr = _ref2 => {
|
|
|
285
306
|
xhr.onabort = function () {
|
|
286
307
|
onError(new DOMException('Aborted', 'AbortError'));
|
|
287
308
|
};
|
|
309
|
+
if (config.abortSignal) {
|
|
310
|
+
if (config.abortSignal.aborted) {
|
|
311
|
+
xhr.abort();
|
|
312
|
+
} else {
|
|
313
|
+
config.abortSignal.addEventListener('abort', () => xhr.abort(), {
|
|
314
|
+
once: true
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
288
318
|
xhr.send(payload);
|
|
289
319
|
return xhr;
|
|
290
320
|
};
|
|
@@ -324,6 +354,34 @@ function assertExportOperationsDownloadFileResponse(maybeExportOperationDownload
|
|
|
324
354
|
throw new Error('Invalid response');
|
|
325
355
|
}
|
|
326
356
|
|
|
357
|
+
function assertFileImportJob(maybeJob) {
|
|
358
|
+
const requiredFields = ['id', 'fileName', 'importContainerKey', 'state'];
|
|
359
|
+
if (hasRequiredFields(maybeJob, requiredFields)) return;
|
|
360
|
+
throw new Error('Invalid File Import Job response');
|
|
361
|
+
}
|
|
362
|
+
function assertFileImportJobRecordsResponse(maybeRecords) {
|
|
363
|
+
const requiredFields = ['results', 'total', 'limit', 'offset', 'count'];
|
|
364
|
+
if (!hasRequiredFields(maybeRecords, requiredFields)) {
|
|
365
|
+
throw new Error('Invalid File Import Job records response: missing required fields');
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function assertProcessFileImportJobResponse(maybeResponse) {
|
|
369
|
+
const requiredFields = ['message'];
|
|
370
|
+
if (hasRequiredFields(maybeResponse, requiredFields)) return;
|
|
371
|
+
throw new Error('Invalid Process File Import Job response');
|
|
372
|
+
}
|
|
373
|
+
function assertListFileImportJobsResponse(maybeResponse) {
|
|
374
|
+
if (!_Array$isArray__default["default"](maybeResponse)) {
|
|
375
|
+
throw new Error('Invalid List File Import Jobs response: expected an array');
|
|
376
|
+
}
|
|
377
|
+
if (maybeResponse.length > 0) {
|
|
378
|
+
const requiredFields = ['id', 'fileName', 'importContainerKey', 'state'];
|
|
379
|
+
if (!hasRequiredFields(maybeResponse[0], requiredFields)) {
|
|
380
|
+
throw new Error('Invalid List File Import Jobs response: missing required fields');
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
327
385
|
function assertImportContainerPagedResponse(maybeImportContainerPagedResponse) {
|
|
328
386
|
const requiredFields = ['count', 'results'];
|
|
329
387
|
if (hasRequiredFields(maybeImportContainerPagedResponse, requiredFields)) return;
|
|
@@ -372,24 +430,24 @@ let ImportStates = /*#__PURE__*/function (ImportStates) {
|
|
|
372
430
|
return ImportStates;
|
|
373
431
|
}({});
|
|
374
432
|
|
|
375
|
-
function ownKeys$7(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
376
|
-
function _objectSpread$7(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$7(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$7(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
377
433
|
function getFileUploadErrorsCount(errors) {
|
|
378
434
|
if (!errors || !_Array$isArray__default["default"](errors)) return 0;
|
|
379
435
|
return _reduceInstanceProperty__default["default"](errors).call(errors, (acc, curr) => acc += curr.errors.length, 0);
|
|
380
436
|
}
|
|
437
|
+
|
|
438
|
+
// TODO: After fully migrating to new flow, remove `row` and only use `index`
|
|
381
439
|
function mapUploadFileErrorsResponseToUploadFileErrorRows(uploadFileErrorsResponse) {
|
|
382
440
|
if (!uploadFileErrorsResponse || !_Array$isArray__default["default"](uploadFileErrorsResponse)) return [];
|
|
383
441
|
let idCounter = 1;
|
|
384
442
|
return _flatMapInstanceProperty__default["default"](uploadFileErrorsResponse).call(uploadFileErrorsResponse, rowErrorsResponse => {
|
|
385
443
|
var _context;
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
444
|
+
// TODO: use `row` if available, otherwise fall back to `index`
|
|
445
|
+
// Old flow uses `row`, new flow uses `index`
|
|
446
|
+
const rowNumber = rowErrorsResponse.row ?? rowErrorsResponse.index;
|
|
447
|
+
return _mapInstanceProperty__default["default"](_context = rowErrorsResponse.errors).call(_context, rowError => ({
|
|
448
|
+
id: String(idCounter++),
|
|
449
|
+
row: rowNumber,
|
|
450
|
+
index: rowNumber,
|
|
393
451
|
field: rowError.field,
|
|
394
452
|
code: rowError.code,
|
|
395
453
|
validationMessage: rowError.message
|
|
@@ -397,8 +455,40 @@ function mapUploadFileErrorsResponseToUploadFileErrorRows(uploadFileErrorsRespon
|
|
|
397
455
|
});
|
|
398
456
|
}
|
|
399
457
|
|
|
400
|
-
function
|
|
401
|
-
|
|
458
|
+
function getFileImportJobFileType(resourceType) {
|
|
459
|
+
return resourceType === 'custom-object' ? 'json' : 'csv';
|
|
460
|
+
}
|
|
461
|
+
function toImportApiResourceType(resourceType) {
|
|
462
|
+
return resourceType === 'product' ? 'product-draft' : resourceType;
|
|
463
|
+
}
|
|
464
|
+
function isImportJobQueued(job) {
|
|
465
|
+
return job?.state === 'queued';
|
|
466
|
+
}
|
|
467
|
+
function isImportJobProcessing(job) {
|
|
468
|
+
return job?.state === 'processing';
|
|
469
|
+
}
|
|
470
|
+
function isImportJobValidated(job) {
|
|
471
|
+
return job?.state === 'validated';
|
|
472
|
+
}
|
|
473
|
+
function isImportJobInitializing(job) {
|
|
474
|
+
return job?.state === 'initialising';
|
|
475
|
+
}
|
|
476
|
+
function isImportJobReady(job) {
|
|
477
|
+
return job?.state === 'ready';
|
|
478
|
+
}
|
|
479
|
+
function isImportJobRejected(job) {
|
|
480
|
+
return job?.state === 'rejected';
|
|
481
|
+
}
|
|
482
|
+
function isImportJobTerminal(job) {
|
|
483
|
+
return isImportJobValidated(job) || isImportJobRejected(job);
|
|
484
|
+
}
|
|
485
|
+
function shouldContinuePollingForImportValidation(job) {
|
|
486
|
+
if (!job) return true;
|
|
487
|
+
return isImportJobQueued(job) || isImportJobProcessing(job);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function ownKeys$8(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
491
|
+
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys$8(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys$8(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
402
492
|
|
|
403
493
|
/**
|
|
404
494
|
* Convert megabytes to bytes
|
|
@@ -517,6 +607,44 @@ const countJsonFileItems = async file => {
|
|
|
517
607
|
}
|
|
518
608
|
};
|
|
519
609
|
|
|
610
|
+
/**
|
|
611
|
+
* Count unique resources in a CSV file by counting unique values in the "key" column.
|
|
612
|
+
* A single resource can span multiple rows (when it has array fields like variants, assets...),
|
|
613
|
+
* so we count unique keys rather than rows.
|
|
614
|
+
* @param file The CSV file to process
|
|
615
|
+
* @returns A promise that resolves to the number of unique resources
|
|
616
|
+
*/
|
|
617
|
+
const countUniqueResourcesInCsv = file => {
|
|
618
|
+
return new _Promise__default["default"](resolve => {
|
|
619
|
+
const uniqueKeys = new _Set__default["default"]();
|
|
620
|
+
let keyColumnIndex = -1;
|
|
621
|
+
let isFirstRow = true;
|
|
622
|
+
Papa__default["default"].parse(file, {
|
|
623
|
+
step: _ref2 => {
|
|
624
|
+
var _context4, _context5;
|
|
625
|
+
let data = _ref2.data;
|
|
626
|
+
if (!_Array$isArray__default["default"](data)) return;
|
|
627
|
+
if (isFirstRow) {
|
|
628
|
+
keyColumnIndex = _findIndexInstanceProperty__default["default"](data).call(data, col => {
|
|
629
|
+
var _context2, _context3;
|
|
630
|
+
return ((_context2 = col?.toLowerCase()) == null ? void 0 : _bindInstanceProperty__default["default"](_context3 = Function.call).call(_context3, _trimInstanceProperty__default["default"](_context2), _context2))?.() === 'key';
|
|
631
|
+
});
|
|
632
|
+
isFirstRow = false;
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
if (keyColumnIndex === -1) return;
|
|
636
|
+
const keyValue = ((_context4 = data[keyColumnIndex]) == null ? void 0 : _bindInstanceProperty__default["default"](_context5 = Function.call).call(_context5, _trimInstanceProperty__default["default"](_context4), _context4))?.();
|
|
637
|
+
if (keyValue) {
|
|
638
|
+
uniqueKeys.add(keyValue);
|
|
639
|
+
}
|
|
640
|
+
},
|
|
641
|
+
complete: () => {
|
|
642
|
+
resolve(uniqueKeys.size);
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
});
|
|
646
|
+
};
|
|
647
|
+
|
|
520
648
|
/**
|
|
521
649
|
* Map file upload errors to upload file error rows with unique IDs
|
|
522
650
|
* @param uploadFileErrors Array of file upload errors
|
|
@@ -524,13 +652,13 @@ const countJsonFileItems = async file => {
|
|
|
524
652
|
*/
|
|
525
653
|
const mapFileUploadErrorsToUploadFileErrorRows = uploadFileErrors => {
|
|
526
654
|
let idCounter = 1;
|
|
527
|
-
return _mapInstanceProperty__default["default"](uploadFileErrors).call(uploadFileErrors, uploadFileError => _objectSpread$
|
|
655
|
+
return _mapInstanceProperty__default["default"](uploadFileErrors).call(uploadFileErrors, uploadFileError => _objectSpread$8(_objectSpread$8({}, uploadFileError), {}, {
|
|
528
656
|
id: String(idCounter++)
|
|
529
657
|
}));
|
|
530
658
|
};
|
|
531
659
|
|
|
532
|
-
function ownKeys$
|
|
533
|
-
function _objectSpread$
|
|
660
|
+
function ownKeys$7(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
661
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$7(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$7(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
534
662
|
const mapFormikErrors = error => {
|
|
535
663
|
if (typeof error === 'string') {
|
|
536
664
|
return {
|
|
@@ -538,7 +666,7 @@ const mapFormikErrors = error => {
|
|
|
538
666
|
};
|
|
539
667
|
}
|
|
540
668
|
if (_Array$isArray__default["default"](error)) {
|
|
541
|
-
return _reduceInstanceProperty__default["default"](error).call(error, (errorAggregator, currentError) => _objectSpread$
|
|
669
|
+
return _reduceInstanceProperty__default["default"](error).call(error, (errorAggregator, currentError) => _objectSpread$7(_objectSpread$7({}, errorAggregator), {}, {
|
|
542
670
|
[currentError]: true
|
|
543
671
|
}), {});
|
|
544
672
|
}
|
|
@@ -607,6 +735,54 @@ const decodeFileNameFromImportContainerKey = importContainerKey => {
|
|
|
607
735
|
}
|
|
608
736
|
};
|
|
609
737
|
|
|
738
|
+
const pollJobUntilValidated = async _ref => {
|
|
739
|
+
let projectKey = _ref.projectKey,
|
|
740
|
+
jobId = _ref.jobId,
|
|
741
|
+
importContainerKey = _ref.importContainerKey,
|
|
742
|
+
_ref$pollingInterval = _ref.pollingInterval,
|
|
743
|
+
pollingInterval = _ref$pollingInterval === void 0 ? 5000 : _ref$pollingInterval,
|
|
744
|
+
_ref$maxAttempts = _ref.maxAttempts,
|
|
745
|
+
maxAttempts = _ref$maxAttempts === void 0 ? 120 : _ref$maxAttempts,
|
|
746
|
+
onJobUpdate = _ref.onJobUpdate,
|
|
747
|
+
abortSignal = _ref.abortSignal;
|
|
748
|
+
let attempts = 0;
|
|
749
|
+
while (attempts < maxAttempts) {
|
|
750
|
+
if (abortSignal?.aborted) {
|
|
751
|
+
throw new PollingAbortedError();
|
|
752
|
+
}
|
|
753
|
+
const job = await getFileImportJob({
|
|
754
|
+
projectKey,
|
|
755
|
+
importContainerKey,
|
|
756
|
+
jobId
|
|
757
|
+
});
|
|
758
|
+
if (abortSignal?.aborted) {
|
|
759
|
+
throw new PollingAbortedError();
|
|
760
|
+
}
|
|
761
|
+
onJobUpdate?.(job);
|
|
762
|
+
if (isImportJobTerminal(job)) {
|
|
763
|
+
return job;
|
|
764
|
+
}
|
|
765
|
+
await new _Promise__default["default"]((resolve, reject) => {
|
|
766
|
+
let timeoutId;
|
|
767
|
+
const onAbort = () => {
|
|
768
|
+
clearTimeout(timeoutId);
|
|
769
|
+
reject(new PollingAbortedError());
|
|
770
|
+
};
|
|
771
|
+
if (abortSignal?.aborted) {
|
|
772
|
+
reject(new PollingAbortedError());
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
timeoutId = _setTimeout__default["default"](() => {
|
|
776
|
+
abortSignal?.removeEventListener('abort', onAbort);
|
|
777
|
+
resolve();
|
|
778
|
+
}, pollingInterval);
|
|
779
|
+
abortSignal?.addEventListener('abort', onAbort);
|
|
780
|
+
});
|
|
781
|
+
attempts++;
|
|
782
|
+
}
|
|
783
|
+
throw new Error(`Job validation timeout after ${maxAttempts} attempts (${maxAttempts * pollingInterval / 1000}s)`);
|
|
784
|
+
};
|
|
785
|
+
|
|
610
786
|
/**
|
|
611
787
|
* Formats an object into a URL query string
|
|
612
788
|
* @param queryParams - Object containing query parameters
|
|
@@ -685,6 +861,42 @@ function getExportOperationsURL(_ref0) {
|
|
|
685
861
|
const queryString = formatQueryString(queryParams);
|
|
686
862
|
return `/${projectKey}/export-operations${queryString}`;
|
|
687
863
|
}
|
|
864
|
+
function getFileImportJobsURL(_ref1) {
|
|
865
|
+
let projectKey = _ref1.projectKey,
|
|
866
|
+
resourceType = _ref1.resourceType,
|
|
867
|
+
importContainerKey = _ref1.importContainerKey;
|
|
868
|
+
return `/${projectKey}/${pluralize.plural(toImportApiResourceType(resourceType))}/import-containers/${importContainerKey}/file-import-jobs`;
|
|
869
|
+
}
|
|
870
|
+
function getFileImportJobByIdURL(_ref10) {
|
|
871
|
+
let projectKey = _ref10.projectKey,
|
|
872
|
+
importContainerKey = _ref10.importContainerKey,
|
|
873
|
+
jobId = _ref10.jobId;
|
|
874
|
+
return `/${projectKey}/import-containers/${importContainerKey}/file-import-jobs/${jobId}`;
|
|
875
|
+
}
|
|
876
|
+
function getFileImportJobRecordsURL(_ref11) {
|
|
877
|
+
let projectKey = _ref11.projectKey,
|
|
878
|
+
importContainerKey = _ref11.importContainerKey,
|
|
879
|
+
jobId = _ref11.jobId;
|
|
880
|
+
return `/${projectKey}/import-containers/${importContainerKey}/file-import-jobs/${jobId}/records`;
|
|
881
|
+
}
|
|
882
|
+
function getFileImportJobProcessURL(_ref12) {
|
|
883
|
+
let projectKey = _ref12.projectKey,
|
|
884
|
+
resourceType = _ref12.resourceType,
|
|
885
|
+
importContainerKey = _ref12.importContainerKey,
|
|
886
|
+
jobId = _ref12.jobId;
|
|
887
|
+
return `/${projectKey}/${pluralize.plural(toImportApiResourceType(resourceType))}/import-containers/${importContainerKey}/file-import-jobs/${jobId}/process`;
|
|
888
|
+
}
|
|
889
|
+
function getFileImportJobDeleteURL(_ref13) {
|
|
890
|
+
let projectKey = _ref13.projectKey,
|
|
891
|
+
importContainerKey = _ref13.importContainerKey,
|
|
892
|
+
jobId = _ref13.jobId;
|
|
893
|
+
return `/${projectKey}/import-containers/${importContainerKey}/file-import-jobs/${jobId}`;
|
|
894
|
+
}
|
|
895
|
+
function getFileImportJobsListURL(_ref14) {
|
|
896
|
+
let projectKey = _ref14.projectKey,
|
|
897
|
+
importContainerKey = _ref14.importContainerKey;
|
|
898
|
+
return `/${projectKey}/import-containers/${importContainerKey}/file-import-jobs`;
|
|
899
|
+
}
|
|
688
900
|
|
|
689
901
|
function uploadFileForImport(_ref) {
|
|
690
902
|
let projectKey = _ref.projectKey,
|
|
@@ -724,8 +936,181 @@ function assertFileUploadResponse(maybeFileUploadResponse) {
|
|
|
724
936
|
throw new Error('Invalid response');
|
|
725
937
|
}
|
|
726
938
|
|
|
727
|
-
function
|
|
728
|
-
|
|
939
|
+
function createFileImportJob(_ref) {
|
|
940
|
+
let projectKey = _ref.projectKey,
|
|
941
|
+
resourceType = _ref.resourceType,
|
|
942
|
+
importContainerKey = _ref.importContainerKey,
|
|
943
|
+
payload = _ref.payload,
|
|
944
|
+
onProgress = _ref.onProgress,
|
|
945
|
+
abortSignal = _ref.abortSignal;
|
|
946
|
+
const url = getFileImportJobsURL({
|
|
947
|
+
projectKey,
|
|
948
|
+
resourceType,
|
|
949
|
+
importContainerKey
|
|
950
|
+
});
|
|
951
|
+
if ('fileType' in payload) {
|
|
952
|
+
return new _Promise__default["default"]((resolve, reject) => {
|
|
953
|
+
const formData = new FormData();
|
|
954
|
+
formData.append('fileType', payload.fileType);
|
|
955
|
+
formData.append('fileName', payload.fileName);
|
|
956
|
+
formData.append('file', payload.file, payload.fileName);
|
|
957
|
+
fetchUsingXhr({
|
|
958
|
+
url,
|
|
959
|
+
payload: formData,
|
|
960
|
+
config: {
|
|
961
|
+
proxy: constants.MC_API_PROXY_TARGETS.IMPORT,
|
|
962
|
+
method: 'POST',
|
|
963
|
+
headers: {
|
|
964
|
+
'Content-Type': null
|
|
965
|
+
},
|
|
966
|
+
abortSignal
|
|
967
|
+
},
|
|
968
|
+
onProgress: onProgress || (() => {}),
|
|
969
|
+
onSuccess: response => {
|
|
970
|
+
assertFileImportJob(response);
|
|
971
|
+
resolve(response);
|
|
972
|
+
},
|
|
973
|
+
onError: reject
|
|
974
|
+
});
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
return fetcher({
|
|
978
|
+
url,
|
|
979
|
+
payload: _JSON$stringify__default["default"](payload),
|
|
980
|
+
config: {
|
|
981
|
+
proxy: constants.MC_API_PROXY_TARGETS.IMPORT,
|
|
982
|
+
method: 'POST',
|
|
983
|
+
headers: {
|
|
984
|
+
accept: 'application/json',
|
|
985
|
+
'Content-Type': 'application/json'
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
}).then(response => {
|
|
989
|
+
assertFileImportJob(response);
|
|
990
|
+
return response;
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
async function getFileImportJob(_ref2) {
|
|
994
|
+
let projectKey = _ref2.projectKey,
|
|
995
|
+
importContainerKey = _ref2.importContainerKey,
|
|
996
|
+
jobId = _ref2.jobId;
|
|
997
|
+
const url = getFileImportJobByIdURL({
|
|
998
|
+
projectKey,
|
|
999
|
+
importContainerKey,
|
|
1000
|
+
jobId
|
|
1001
|
+
});
|
|
1002
|
+
const response = await fetcher({
|
|
1003
|
+
url,
|
|
1004
|
+
config: {
|
|
1005
|
+
proxy: constants.MC_API_PROXY_TARGETS.IMPORT,
|
|
1006
|
+
method: 'GET'
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
assertFileImportJob(response);
|
|
1010
|
+
return response;
|
|
1011
|
+
}
|
|
1012
|
+
async function getFileImportJobRecords(_ref3) {
|
|
1013
|
+
let projectKey = _ref3.projectKey,
|
|
1014
|
+
importContainerKey = _ref3.importContainerKey,
|
|
1015
|
+
jobId = _ref3.jobId,
|
|
1016
|
+
limit = _ref3.limit,
|
|
1017
|
+
offset = _ref3.offset,
|
|
1018
|
+
isValid = _ref3.isValid;
|
|
1019
|
+
const baseUrl = getFileImportJobRecordsURL({
|
|
1020
|
+
projectKey,
|
|
1021
|
+
importContainerKey,
|
|
1022
|
+
jobId
|
|
1023
|
+
});
|
|
1024
|
+
const queryString = formatQueryString({
|
|
1025
|
+
limit,
|
|
1026
|
+
offset,
|
|
1027
|
+
isValid
|
|
1028
|
+
});
|
|
1029
|
+
const url = `${baseUrl}${queryString}`;
|
|
1030
|
+
const response = await fetcher({
|
|
1031
|
+
url,
|
|
1032
|
+
config: {
|
|
1033
|
+
proxy: constants.MC_API_PROXY_TARGETS.IMPORT,
|
|
1034
|
+
method: 'GET'
|
|
1035
|
+
}
|
|
1036
|
+
});
|
|
1037
|
+
assertFileImportJobRecordsResponse(response);
|
|
1038
|
+
return response;
|
|
1039
|
+
}
|
|
1040
|
+
async function processFileImportJob(_ref4) {
|
|
1041
|
+
let projectKey = _ref4.projectKey,
|
|
1042
|
+
resourceType = _ref4.resourceType,
|
|
1043
|
+
importContainerKey = _ref4.importContainerKey,
|
|
1044
|
+
jobId = _ref4.jobId,
|
|
1045
|
+
action = _ref4.action;
|
|
1046
|
+
const url = getFileImportJobProcessURL({
|
|
1047
|
+
projectKey,
|
|
1048
|
+
resourceType,
|
|
1049
|
+
importContainerKey,
|
|
1050
|
+
jobId
|
|
1051
|
+
});
|
|
1052
|
+
const payload = action ? {
|
|
1053
|
+
action
|
|
1054
|
+
} : {};
|
|
1055
|
+
const response = await fetcher({
|
|
1056
|
+
url,
|
|
1057
|
+
payload: _JSON$stringify__default["default"](payload),
|
|
1058
|
+
config: {
|
|
1059
|
+
proxy: constants.MC_API_PROXY_TARGETS.IMPORT,
|
|
1060
|
+
method: 'POST',
|
|
1061
|
+
headers: {
|
|
1062
|
+
accept: 'application/json',
|
|
1063
|
+
'Content-Type': 'application/json'
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
});
|
|
1067
|
+
assertProcessFileImportJobResponse(response);
|
|
1068
|
+
return response;
|
|
1069
|
+
}
|
|
1070
|
+
async function deleteFileImportJob(_ref5) {
|
|
1071
|
+
let projectKey = _ref5.projectKey,
|
|
1072
|
+
importContainerKey = _ref5.importContainerKey,
|
|
1073
|
+
jobId = _ref5.jobId;
|
|
1074
|
+
const url = getFileImportJobDeleteURL({
|
|
1075
|
+
projectKey,
|
|
1076
|
+
importContainerKey,
|
|
1077
|
+
jobId
|
|
1078
|
+
});
|
|
1079
|
+
await fetcher({
|
|
1080
|
+
url,
|
|
1081
|
+
config: {
|
|
1082
|
+
proxy: constants.MC_API_PROXY_TARGETS.IMPORT,
|
|
1083
|
+
method: 'DELETE'
|
|
1084
|
+
}
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
async function listFileImportJobs(_ref6) {
|
|
1088
|
+
let projectKey = _ref6.projectKey,
|
|
1089
|
+
importContainerKey = _ref6.importContainerKey,
|
|
1090
|
+
limit = _ref6.limit,
|
|
1091
|
+
offset = _ref6.offset;
|
|
1092
|
+
const baseUrl = getFileImportJobsListURL({
|
|
1093
|
+
projectKey,
|
|
1094
|
+
importContainerKey
|
|
1095
|
+
});
|
|
1096
|
+
const queryString = formatQueryString({
|
|
1097
|
+
limit,
|
|
1098
|
+
offset
|
|
1099
|
+
});
|
|
1100
|
+
const url = `${baseUrl}${queryString}`;
|
|
1101
|
+
const response = await fetcher({
|
|
1102
|
+
url,
|
|
1103
|
+
config: {
|
|
1104
|
+
proxy: constants.MC_API_PROXY_TARGETS.IMPORT,
|
|
1105
|
+
method: 'GET'
|
|
1106
|
+
}
|
|
1107
|
+
});
|
|
1108
|
+
assertListFileImportJobsResponse(response);
|
|
1109
|
+
return response;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
function ownKeys$6(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1113
|
+
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; }
|
|
729
1114
|
function getImportState(importSummary) {
|
|
730
1115
|
const processing = importSummary.states.processing > 0;
|
|
731
1116
|
if (processing) return ImportStates.Processing;
|
|
@@ -750,7 +1135,7 @@ function createImportContainerForFileUpload(_ref) {
|
|
|
750
1135
|
url: getCreateImportContainerURL({
|
|
751
1136
|
projectKey
|
|
752
1137
|
}),
|
|
753
|
-
payload: _JSON$stringify__default["default"](_objectSpread$
|
|
1138
|
+
payload: _JSON$stringify__default["default"](_objectSpread$6({
|
|
754
1139
|
retentionPolicy: {
|
|
755
1140
|
strategy: 'ttl',
|
|
756
1141
|
config: {
|
|
@@ -984,6 +1369,21 @@ const DELIMITERS = {
|
|
|
984
1369
|
};
|
|
985
1370
|
const COLUMN_DELIMITERS = [DELIMITERS.COMMA, DELIMITERS.SEMICOLON, DELIMITERS.PIPE, DELIMITERS.TAB];
|
|
986
1371
|
|
|
1372
|
+
const FILE_IMPORT_JOB_POLLING_INTERVAL = 2000;
|
|
1373
|
+
|
|
1374
|
+
const IMPORT_MAX_FILE_SIZE_MB = 200;
|
|
1375
|
+
const IMPORT_MAX_ITEM_COUNT = 500_000;
|
|
1376
|
+
|
|
1377
|
+
// =============================================================================
|
|
1378
|
+
// Legacy constants (old flow) - Remove after testing and migration is complete
|
|
1379
|
+
// =============================================================================
|
|
1380
|
+
|
|
1381
|
+
/** @deprecated Use IMPORT_MAX_FILE_SIZE_MB instead. Remove after migration. */
|
|
1382
|
+
const IMPORT_LEGACY_MAX_FILE_SIZE_MB = 35;
|
|
1383
|
+
|
|
1384
|
+
/** @deprecated Use IMPORT_MAX_ITEM_COUNT instead. Remove after migration. */
|
|
1385
|
+
const IMPORT_LEGACY_MAX_ROW_COUNT = 80_000;
|
|
1386
|
+
|
|
987
1387
|
const IMPORT_TAG_KEYS = {
|
|
988
1388
|
source: 'source'
|
|
989
1389
|
};
|
|
@@ -1027,18 +1427,6 @@ const RESOURCE_TYPE_DOCUMENTATION_LINKS = {
|
|
|
1027
1427
|
'business-unit': 'https://docs.commercetools.com/merchant-center/import-business-units#supported-headers-and-values'
|
|
1028
1428
|
};
|
|
1029
1429
|
|
|
1030
|
-
/**
|
|
1031
|
-
* Maximum file size for imports.
|
|
1032
|
-
* Recommended by backend, enforced in frontend validation.
|
|
1033
|
-
*/
|
|
1034
|
-
const MAX_FILE_SIZE_MB = 35;
|
|
1035
|
-
|
|
1036
|
-
/**
|
|
1037
|
-
* Maximum row count for imports.
|
|
1038
|
-
* Recommended by backend, enforced in frontend validation.
|
|
1039
|
-
*/
|
|
1040
|
-
const MAX_ROW_COUNT = 80_000;
|
|
1041
|
-
|
|
1042
1430
|
const automatedImportContainerKey = 'automated-container-key';
|
|
1043
1431
|
const fileUploadImportContainerKey = 'eyJ0aW1lc3RhbXAiOiAxNzA1MDc0MzIxODY4LCAiZmlsZU5hbWUiOiAiZmlsZS11cGxvYWQtY29udGFpbmVyLWtleS5jc3YifQ';
|
|
1044
1432
|
const manualImports = [{
|
|
@@ -1291,8 +1679,8 @@ const validFileUploadResponse = {
|
|
|
1291
1679
|
itemsCount: 2,
|
|
1292
1680
|
rowsCount: 2,
|
|
1293
1681
|
columnsCount: 11,
|
|
1294
|
-
|
|
1295
|
-
|
|
1682
|
+
fields: ['id', 'lastModifiedAt', 'key', 'name.en', 'name.de', 'slug.en', 'slug.de', 'orderHint', 'externalId', 'description.en', 'description.de'],
|
|
1683
|
+
ignoredFields: ['id', 'lastModifiedAt']
|
|
1296
1684
|
};
|
|
1297
1685
|
const invalidFileUploadResponse = {
|
|
1298
1686
|
invalid: 2,
|
|
@@ -1301,8 +1689,8 @@ const invalidFileUploadResponse = {
|
|
|
1301
1689
|
itemsCount: 2,
|
|
1302
1690
|
rowsCount: 2,
|
|
1303
1691
|
columnsCount: 11,
|
|
1304
|
-
|
|
1305
|
-
|
|
1692
|
+
fields: ['key', 'externalId2', 'orderHint', 'name.de2', 'description.de2', 'slug.RU', 'name.enn', 'description.en', 'slug.RU', 'test1', 'test2'],
|
|
1693
|
+
ignoredFields: [],
|
|
1306
1694
|
results: [{
|
|
1307
1695
|
row: 1,
|
|
1308
1696
|
errors: [{
|
|
@@ -1685,10 +2073,101 @@ const exportOperationsProcessing = [{
|
|
|
1685
2073
|
fields: ['id'],
|
|
1686
2074
|
locales: ['en']
|
|
1687
2075
|
}];
|
|
2076
|
+
const validFileImportJobQueued = {
|
|
2077
|
+
id: 'job-uuid-12345',
|
|
2078
|
+
fileName: 'categories.csv',
|
|
2079
|
+
importContainerKey: 'container-key',
|
|
2080
|
+
state: 'queued',
|
|
2081
|
+
summary: {
|
|
2082
|
+
total: 0,
|
|
2083
|
+
valid: 0,
|
|
2084
|
+
invalid: 0,
|
|
2085
|
+
fieldsCount: 0,
|
|
2086
|
+
fields: [],
|
|
2087
|
+
ignoredFields: []
|
|
2088
|
+
}
|
|
2089
|
+
};
|
|
2090
|
+
const validFileImportJobProcessing = {
|
|
2091
|
+
id: 'job-uuid-12345',
|
|
2092
|
+
fileName: 'categories.csv',
|
|
2093
|
+
importContainerKey: 'container-key',
|
|
2094
|
+
state: 'processing',
|
|
2095
|
+
summary: {
|
|
2096
|
+
total: 0,
|
|
2097
|
+
valid: 0,
|
|
2098
|
+
invalid: 0,
|
|
2099
|
+
fieldsCount: 0,
|
|
2100
|
+
fields: [],
|
|
2101
|
+
ignoredFields: []
|
|
2102
|
+
}
|
|
2103
|
+
};
|
|
2104
|
+
const validFileImportJobValidated = {
|
|
2105
|
+
id: 'job-uuid-12345',
|
|
2106
|
+
fileName: 'categories.csv',
|
|
2107
|
+
importContainerKey: 'container-key',
|
|
2108
|
+
state: 'validated',
|
|
2109
|
+
summary: {
|
|
2110
|
+
total: 2,
|
|
2111
|
+
valid: 2,
|
|
2112
|
+
invalid: 0,
|
|
2113
|
+
fieldsCount: 2,
|
|
2114
|
+
fields: ['key', 'name.en'],
|
|
2115
|
+
ignoredFields: ['id', 'lastModifiedAt']
|
|
2116
|
+
}
|
|
2117
|
+
};
|
|
2118
|
+
const invalidFileImportJobValidated = {
|
|
2119
|
+
id: 'job-uuid-12345',
|
|
2120
|
+
fileName: 'categories.csv',
|
|
2121
|
+
importContainerKey: 'container-key',
|
|
2122
|
+
state: 'validated',
|
|
2123
|
+
summary: {
|
|
2124
|
+
total: 2,
|
|
2125
|
+
valid: 0,
|
|
2126
|
+
invalid: 2,
|
|
2127
|
+
fieldsCount: 11,
|
|
2128
|
+
fields: ['key', 'externalId2', 'orderHint', 'name.de2', 'description.de2', 'slug.RU', 'name.enn', 'description.en', 'slug.RU', 'test1', 'test2'],
|
|
2129
|
+
ignoredFields: []
|
|
2130
|
+
}
|
|
2131
|
+
};
|
|
2132
|
+
const validFileImportJobRecordsResponse = {
|
|
2133
|
+
results: [],
|
|
2134
|
+
total: 0,
|
|
2135
|
+
limit: 20,
|
|
2136
|
+
offset: 0,
|
|
2137
|
+
count: 0
|
|
2138
|
+
};
|
|
2139
|
+
const invalidFileImportJobRecordsResponse = {
|
|
2140
|
+
results: [{
|
|
2141
|
+
index: 1,
|
|
2142
|
+
errors: [{
|
|
2143
|
+
code: 'InvalidField',
|
|
2144
|
+
message: '"externalId2" is not allowed',
|
|
2145
|
+
field: 'externalId2'
|
|
2146
|
+
}, {
|
|
2147
|
+
code: 'InvalidField',
|
|
2148
|
+
message: '"orderHint" is not allowed',
|
|
2149
|
+
field: 'orderHint'
|
|
2150
|
+
}]
|
|
2151
|
+
}, {
|
|
2152
|
+
index: 2,
|
|
2153
|
+
errors: [{
|
|
2154
|
+
code: 'InvalidField',
|
|
2155
|
+
message: '"name.de2" is not allowed',
|
|
2156
|
+
field: 'name.de2'
|
|
2157
|
+
}]
|
|
2158
|
+
}],
|
|
2159
|
+
total: 2,
|
|
2160
|
+
limit: 20,
|
|
2161
|
+
offset: 0,
|
|
2162
|
+
count: 2
|
|
2163
|
+
};
|
|
2164
|
+
const processFileImportJobResponse = {
|
|
2165
|
+
message: 'acknowledged'
|
|
2166
|
+
};
|
|
1688
2167
|
|
|
1689
|
-
function ownKeys$
|
|
1690
|
-
function _objectSpread$
|
|
1691
|
-
const FileIcon = props => /*#__PURE__*/jsxRuntime.jsxs("svg", _objectSpread$
|
|
2168
|
+
function ownKeys$5(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2169
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$5(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$5(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
2170
|
+
const FileIcon = props => /*#__PURE__*/jsxRuntime.jsxs("svg", _objectSpread$5(_objectSpread$5({
|
|
1692
2171
|
width: "32",
|
|
1693
2172
|
height: "32",
|
|
1694
2173
|
viewBox: "0 0 32 32",
|
|
@@ -1790,9 +2269,9 @@ const ActiveDragDropArea = _ref => {
|
|
|
1790
2269
|
});
|
|
1791
2270
|
};
|
|
1792
2271
|
|
|
1793
|
-
function ownKeys$
|
|
1794
|
-
function _objectSpread$
|
|
1795
|
-
const LockIcon = props => /*#__PURE__*/jsxRuntime.jsxs("svg", _objectSpread$
|
|
2272
|
+
function ownKeys$4(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2273
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$4(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$4(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
2274
|
+
const LockIcon = props => /*#__PURE__*/jsxRuntime.jsxs("svg", _objectSpread$4(_objectSpread$4({
|
|
1796
2275
|
width: "87px",
|
|
1797
2276
|
height: "118px",
|
|
1798
2277
|
viewBox: "0 0 87 118",
|
|
@@ -1893,8 +2372,8 @@ function getDefaultDropWrapperStyles(_dropAreaState) {
|
|
|
1893
2372
|
return /*#__PURE__*/react.css("" );
|
|
1894
2373
|
}
|
|
1895
2374
|
|
|
1896
|
-
function ownKeys$
|
|
1897
|
-
function _objectSpread$
|
|
2375
|
+
function ownKeys$3(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2376
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context7 = ownKeys$3(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context8 = ownKeys$3(Object(t))).call(_context8, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
1898
2377
|
const FileDropArea = _ref => {
|
|
1899
2378
|
let onDrop = _ref.onDrop,
|
|
1900
2379
|
disabled = _ref.disabled,
|
|
@@ -1927,11 +2406,11 @@ const FileDropArea = _ref => {
|
|
|
1927
2406
|
getInputProps = _useDropzone.getInputProps,
|
|
1928
2407
|
isDragActive = _useDropzone.isDragActive;
|
|
1929
2408
|
const dropAreaState = getDropAreaState(isDragActive);
|
|
1930
|
-
return /*#__PURE__*/jsxRuntime.jsxs(DropAreaWrapper, _objectSpread$
|
|
2409
|
+
return /*#__PURE__*/jsxRuntime.jsxs(DropAreaWrapper, _objectSpread$3(_objectSpread$3({
|
|
1931
2410
|
role: "presentation"
|
|
1932
2411
|
}, getRootProps()), {}, {
|
|
1933
2412
|
dropAreaState: dropAreaState,
|
|
1934
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("input", _objectSpread$
|
|
2413
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("input", _objectSpread$3({
|
|
1935
2414
|
"data-testid": "file-input"
|
|
1936
2415
|
}, getInputProps())), /*#__PURE__*/jsxRuntime.jsx(uiKit.Constraints.Horizontal, {
|
|
1937
2416
|
children: children(dropAreaState)
|
|
@@ -2031,8 +2510,8 @@ const UploadingModal = _ref => {
|
|
|
2031
2510
|
progress = _ref.progress,
|
|
2032
2511
|
cancelLabel = _ref.cancelLabel,
|
|
2033
2512
|
onCancel = _ref.onCancel,
|
|
2034
|
-
onClose = _ref.onClose
|
|
2035
|
-
|
|
2513
|
+
onClose = _ref.onClose,
|
|
2514
|
+
statusMessage = _ref.statusMessage;
|
|
2036
2515
|
return /*#__PURE__*/jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
2037
2516
|
size: 16,
|
|
2038
2517
|
isOpen: isOpen,
|
|
@@ -2056,7 +2535,7 @@ const UploadingModal = _ref => {
|
|
|
2056
2535
|
})
|
|
2057
2536
|
}), /*#__PURE__*/jsxRuntime.jsxs(uiKit.Text.Body, {
|
|
2058
2537
|
tone: "secondary",
|
|
2059
|
-
children: ["(",
|
|
2538
|
+
children: ["(", convertFileSizeToKB(fileSize).toLocaleString(), " KB)"]
|
|
2060
2539
|
})]
|
|
2061
2540
|
}), /*#__PURE__*/jsxRuntime.jsx(uiKit.SecondaryButton, {
|
|
2062
2541
|
tone: "secondary",
|
|
@@ -2068,22 +2547,16 @@ const UploadingModal = _ref => {
|
|
|
2068
2547
|
barWidth: "scale",
|
|
2069
2548
|
height: "10",
|
|
2070
2549
|
progress: progress
|
|
2071
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
2550
|
+
}), statusMessage && /*#__PURE__*/jsxRuntime.jsx(uiKit.Text.Detail, {
|
|
2551
|
+
tone: "tertiary",
|
|
2552
|
+
children: statusMessage
|
|
2553
|
+
})]
|
|
2072
2554
|
})
|
|
2073
2555
|
});
|
|
2074
2556
|
};
|
|
2075
2557
|
|
|
2076
|
-
var messages = reactIntl.defineMessages({
|
|
2077
|
-
unexpectedError: {
|
|
2078
|
-
id: 'operations.fetch.unexpectedError',
|
|
2079
|
-
description: 'Generic error message displayed when an unexpected error occurs during data fetching',
|
|
2080
|
-
defaultMessage: 'An unexpected error occurred while fetching the data. Please try again. If the problem persists, please contact support.'
|
|
2081
|
-
}
|
|
2082
|
-
});
|
|
2083
|
-
|
|
2084
2558
|
const useFetch = function (fetchFunction) {
|
|
2085
2559
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2086
|
-
const intl = reactIntl.useIntl();
|
|
2087
2560
|
const _React$useState = React__default["default"].useState(null),
|
|
2088
2561
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
2089
2562
|
data = _React$useState2[0],
|
|
@@ -2122,10 +2595,9 @@ const useFetch = function (fetchFunction) {
|
|
|
2122
2595
|
}
|
|
2123
2596
|
}
|
|
2124
2597
|
} catch (err) {
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
setError(new Error(intl.formatMessage(messages.unexpectedError)));
|
|
2598
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
2599
|
+
setError(error);
|
|
2600
|
+
if (!(err instanceof HttpError)) {
|
|
2129
2601
|
sentry.reportErrorToSentry(new Error('An unexpected error occurred in the `useFetch` hook'), {
|
|
2130
2602
|
extra: {
|
|
2131
2603
|
error: err
|
|
@@ -2147,7 +2619,7 @@ const useFetch = function (fetchFunction) {
|
|
|
2147
2619
|
setError(null);
|
|
2148
2620
|
setIsLoading(false);
|
|
2149
2621
|
};
|
|
2150
|
-
}, [fetchFunction, refetchCount,
|
|
2622
|
+
}, [fetchFunction, refetchCount, config.pollingInterval, config.shouldContinuePolling]);
|
|
2151
2623
|
return {
|
|
2152
2624
|
data,
|
|
2153
2625
|
error,
|
|
@@ -2177,6 +2649,28 @@ const useFetchExportOperations = _ref => {
|
|
|
2177
2649
|
});
|
|
2178
2650
|
};
|
|
2179
2651
|
|
|
2652
|
+
const useFetchFileImportJob = _ref => {
|
|
2653
|
+
let projectKey = _ref.projectKey,
|
|
2654
|
+
importContainerKey = _ref.importContainerKey,
|
|
2655
|
+
jobId = _ref.jobId,
|
|
2656
|
+
pollingInterval = _ref.pollingInterval,
|
|
2657
|
+
shouldContinuePolling = _ref.shouldContinuePolling;
|
|
2658
|
+
const fetchData = React__default["default"].useCallback(() => {
|
|
2659
|
+
if (!projectKey) {
|
|
2660
|
+
return _Promise__default["default"].reject(new ProjectKeyNotAvailableError());
|
|
2661
|
+
}
|
|
2662
|
+
return getFileImportJob({
|
|
2663
|
+
projectKey,
|
|
2664
|
+
importContainerKey,
|
|
2665
|
+
jobId
|
|
2666
|
+
});
|
|
2667
|
+
}, [projectKey, importContainerKey, jobId]);
|
|
2668
|
+
return useFetch(fetchData, {
|
|
2669
|
+
pollingInterval,
|
|
2670
|
+
shouldContinuePolling
|
|
2671
|
+
});
|
|
2672
|
+
};
|
|
2673
|
+
|
|
2180
2674
|
const useFetchImportContainerDetails = _ref => {
|
|
2181
2675
|
let projectKey = _ref.projectKey,
|
|
2182
2676
|
importContainerKey = _ref.importContainerKey,
|
|
@@ -2245,8 +2739,78 @@ const useFetchImportSummaries = _ref => {
|
|
|
2245
2739
|
});
|
|
2246
2740
|
};
|
|
2247
2741
|
|
|
2248
|
-
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2249
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
2742
|
+
function ownKeys$2(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2743
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
2744
|
+
const useFileImportJobUpload = _ref => {
|
|
2745
|
+
let projectKey = _ref.projectKey;
|
|
2746
|
+
const _React$useState = React__default["default"].useState(false),
|
|
2747
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
2748
|
+
isUploading = _React$useState2[0],
|
|
2749
|
+
setIsUploading = _React$useState2[1];
|
|
2750
|
+
const _React$useState3 = React__default["default"].useState(0),
|
|
2751
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
2752
|
+
progress = _React$useState4[0],
|
|
2753
|
+
setProgress = _React$useState4[1];
|
|
2754
|
+
const upload = React__default["default"].useCallback(async config => {
|
|
2755
|
+
if (!projectKey) {
|
|
2756
|
+
throw new ProjectKeyNotAvailableError();
|
|
2757
|
+
}
|
|
2758
|
+
setIsUploading(true);
|
|
2759
|
+
setProgress(0);
|
|
2760
|
+
const importContainerKey = encodeFileNameWithTimestampToContainerKey(config.file.name);
|
|
2761
|
+
try {
|
|
2762
|
+
await createImportContainerForFileUpload({
|
|
2763
|
+
importContainerDraft: _objectSpread$2({
|
|
2764
|
+
key: importContainerKey,
|
|
2765
|
+
resourceType: config.resourceType,
|
|
2766
|
+
tags: [TAG_KEY_SOURCE_FILE_UPLOAD]
|
|
2767
|
+
}, config.settings ? {
|
|
2768
|
+
settings: config.settings
|
|
2769
|
+
} : {}),
|
|
2770
|
+
projectKey
|
|
2771
|
+
});
|
|
2772
|
+
const jobResponse = await createFileImportJob({
|
|
2773
|
+
projectKey,
|
|
2774
|
+
resourceType: config.resourceType,
|
|
2775
|
+
importContainerKey,
|
|
2776
|
+
payload: {
|
|
2777
|
+
fileType: getFileImportJobFileType(config.resourceType),
|
|
2778
|
+
fileName: config.file.name,
|
|
2779
|
+
file: config.file
|
|
2780
|
+
},
|
|
2781
|
+
onProgress: uploadProgress => {
|
|
2782
|
+
setProgress(uploadProgress);
|
|
2783
|
+
config.onProgress?.(uploadProgress);
|
|
2784
|
+
},
|
|
2785
|
+
abortSignal: config.abortSignal
|
|
2786
|
+
});
|
|
2787
|
+
setIsUploading(false);
|
|
2788
|
+
setProgress(100);
|
|
2789
|
+
config.onSuccess(jobResponse.id, importContainerKey);
|
|
2790
|
+
} catch (error) {
|
|
2791
|
+
try {
|
|
2792
|
+
await deleteImportContainer({
|
|
2793
|
+
projectKey,
|
|
2794
|
+
importContainerKey
|
|
2795
|
+
});
|
|
2796
|
+
} catch {
|
|
2797
|
+
// Ignore cleanup errors - container will be cleaned up by TTL retention policy
|
|
2798
|
+
// Cleanup errors are unlikely unless there is a network issue or container was removed externally
|
|
2799
|
+
}
|
|
2800
|
+
setIsUploading(false);
|
|
2801
|
+
setProgress(0);
|
|
2802
|
+
config.onError?.(error);
|
|
2803
|
+
}
|
|
2804
|
+
}, [projectKey]);
|
|
2805
|
+
return {
|
|
2806
|
+
upload,
|
|
2807
|
+
isUploading,
|
|
2808
|
+
progress
|
|
2809
|
+
};
|
|
2810
|
+
};
|
|
2811
|
+
|
|
2812
|
+
function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2813
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
2250
2814
|
const useImportContainerUpload = _ref => {
|
|
2251
2815
|
let projectKey = _ref.projectKey;
|
|
2252
2816
|
const _React$useState = React__default["default"].useState(false),
|
|
@@ -2264,7 +2828,8 @@ const useImportContainerUpload = _ref => {
|
|
|
2264
2828
|
settings = _ref2.settings,
|
|
2265
2829
|
onSuccess = _ref2.onSuccess,
|
|
2266
2830
|
onError = _ref2.onError,
|
|
2267
|
-
onProgress = _ref2.onProgress
|
|
2831
|
+
onProgress = _ref2.onProgress,
|
|
2832
|
+
abortSignal = _ref2.abortSignal;
|
|
2268
2833
|
if (!projectKey) {
|
|
2269
2834
|
throw new ProjectKeyNotAvailableError();
|
|
2270
2835
|
}
|
|
@@ -2273,7 +2838,7 @@ const useImportContainerUpload = _ref => {
|
|
|
2273
2838
|
const importContainerKey = encodeFileNameWithTimestampToContainerKey(file.name);
|
|
2274
2839
|
try {
|
|
2275
2840
|
await createImportContainerForFileUpload({
|
|
2276
|
-
importContainerDraft: _objectSpread({
|
|
2841
|
+
importContainerDraft: _objectSpread$1({
|
|
2277
2842
|
key: importContainerKey,
|
|
2278
2843
|
resourceType,
|
|
2279
2844
|
tags: [TAG_KEY_SOURCE_FILE_UPLOAD]
|
|
@@ -2287,6 +2852,7 @@ const useImportContainerUpload = _ref => {
|
|
|
2287
2852
|
importContainerKey,
|
|
2288
2853
|
resourceType,
|
|
2289
2854
|
file,
|
|
2855
|
+
abortSignal,
|
|
2290
2856
|
onSuccess: response => {
|
|
2291
2857
|
setIsUploading(false);
|
|
2292
2858
|
setProgress(100);
|
|
@@ -2325,7 +2891,8 @@ const useImportContainerUpload = _ref => {
|
|
|
2325
2891
|
}
|
|
2326
2892
|
setIsUploading(false);
|
|
2327
2893
|
setProgress(0);
|
|
2328
|
-
|
|
2894
|
+
onError?.(error);
|
|
2895
|
+
return undefined;
|
|
2329
2896
|
}
|
|
2330
2897
|
};
|
|
2331
2898
|
const abort = () => {
|
|
@@ -2341,6 +2908,201 @@ const useImportContainerUpload = _ref => {
|
|
|
2341
2908
|
};
|
|
2342
2909
|
};
|
|
2343
2910
|
|
|
2911
|
+
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2912
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
2913
|
+
const safeDeleteContainer = async _ref => {
|
|
2914
|
+
let projectKey = _ref.projectKey,
|
|
2915
|
+
containerKey = _ref.containerKey;
|
|
2916
|
+
try {
|
|
2917
|
+
await deleteImportContainer({
|
|
2918
|
+
projectKey,
|
|
2919
|
+
importContainerKey: containerKey
|
|
2920
|
+
});
|
|
2921
|
+
} catch {}
|
|
2922
|
+
};
|
|
2923
|
+
const useFileUpload = _ref2 => {
|
|
2924
|
+
let projectKey = _ref2.projectKey,
|
|
2925
|
+
_ref2$useJobBasedFlow = _ref2.useJobBasedFlow,
|
|
2926
|
+
useJobBasedFlow = _ref2$useJobBasedFlow === void 0 ? false : _ref2$useJobBasedFlow,
|
|
2927
|
+
_ref2$pollingInterval = _ref2.pollingInterval,
|
|
2928
|
+
pollingInterval = _ref2$pollingInterval === void 0 ? 5000 : _ref2$pollingInterval,
|
|
2929
|
+
_ref2$maxPollingAttem = _ref2.maxPollingAttempts,
|
|
2930
|
+
maxPollingAttempts = _ref2$maxPollingAttem === void 0 ? 120 : _ref2$maxPollingAttem;
|
|
2931
|
+
const _React$useState = React__default["default"].useState(false),
|
|
2932
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
2933
|
+
isUploading = _React$useState2[0],
|
|
2934
|
+
setIsUploading = _React$useState2[1];
|
|
2935
|
+
const _React$useState3 = React__default["default"].useState(0),
|
|
2936
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
2937
|
+
progress = _React$useState4[0],
|
|
2938
|
+
setProgress = _React$useState4[1];
|
|
2939
|
+
const _React$useState5 = React__default["default"].useState({
|
|
2940
|
+
processed: 0,
|
|
2941
|
+
isValidating: false
|
|
2942
|
+
}),
|
|
2943
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
2944
|
+
validationProgress = _React$useState6[0],
|
|
2945
|
+
setValidationProgress = _React$useState6[1];
|
|
2946
|
+
const containerUpload = useImportContainerUpload({
|
|
2947
|
+
projectKey
|
|
2948
|
+
});
|
|
2949
|
+
const jobUpload = useFileImportJobUpload({
|
|
2950
|
+
projectKey
|
|
2951
|
+
});
|
|
2952
|
+
const resetState = React__default["default"].useCallback(() => {
|
|
2953
|
+
setIsUploading(false);
|
|
2954
|
+
setProgress(0);
|
|
2955
|
+
setValidationProgress({
|
|
2956
|
+
processed: 0,
|
|
2957
|
+
isValidating: false
|
|
2958
|
+
});
|
|
2959
|
+
}, []);
|
|
2960
|
+
const upload = React__default["default"].useCallback(async config => {
|
|
2961
|
+
setIsUploading(true);
|
|
2962
|
+
setProgress(0);
|
|
2963
|
+
try {
|
|
2964
|
+
if (useJobBasedFlow) {
|
|
2965
|
+
await jobUpload.upload({
|
|
2966
|
+
file: config.file,
|
|
2967
|
+
resourceType: config.resourceType,
|
|
2968
|
+
settings: config.settings,
|
|
2969
|
+
abortSignal: config.abortSignal,
|
|
2970
|
+
onSuccess: async (jobId, containerKey) => {
|
|
2971
|
+
try {
|
|
2972
|
+
setValidationProgress({
|
|
2973
|
+
processed: 0,
|
|
2974
|
+
isValidating: true
|
|
2975
|
+
});
|
|
2976
|
+
const validatedJob = await pollJobUntilValidated({
|
|
2977
|
+
projectKey,
|
|
2978
|
+
jobId,
|
|
2979
|
+
importContainerKey: containerKey,
|
|
2980
|
+
pollingInterval,
|
|
2981
|
+
maxAttempts: maxPollingAttempts,
|
|
2982
|
+
abortSignal: config.abortSignal,
|
|
2983
|
+
onJobUpdate: job => {
|
|
2984
|
+
const processed = job.summary?.total ?? 0;
|
|
2985
|
+
setValidationProgress({
|
|
2986
|
+
processed,
|
|
2987
|
+
isValidating: true
|
|
2988
|
+
});
|
|
2989
|
+
config.onValidationProgress?.(job);
|
|
2990
|
+
}
|
|
2991
|
+
});
|
|
2992
|
+
|
|
2993
|
+
// Handle rejected job with jobError for the new flow (like MissingCsvFieldIdentifier error)
|
|
2994
|
+
// We wrap it in HttpError to reuse existing error handling (for the old flow) in consumers until BE supports this error type
|
|
2995
|
+
if (validatedJob.jobError) {
|
|
2996
|
+
throw new HttpError(400, validatedJob.jobError.message, validatedJob.jobError);
|
|
2997
|
+
}
|
|
2998
|
+
let results = [];
|
|
2999
|
+
if (validatedJob.summary.invalid > 0) {
|
|
3000
|
+
const recordsResponse = await getFileImportJobRecords({
|
|
3001
|
+
projectKey,
|
|
3002
|
+
importContainerKey: containerKey,
|
|
3003
|
+
jobId,
|
|
3004
|
+
limit: 500,
|
|
3005
|
+
isValid: false
|
|
3006
|
+
});
|
|
3007
|
+
results = recordsResponse.results;
|
|
3008
|
+
await safeDeleteContainer({
|
|
3009
|
+
projectKey,
|
|
3010
|
+
containerKey
|
|
3011
|
+
});
|
|
3012
|
+
}
|
|
3013
|
+
const result = {
|
|
3014
|
+
containerKey,
|
|
3015
|
+
summary: _objectSpread(_objectSpread({}, validatedJob.summary), {}, {
|
|
3016
|
+
results
|
|
3017
|
+
}),
|
|
3018
|
+
jobId,
|
|
3019
|
+
job: validatedJob
|
|
3020
|
+
};
|
|
3021
|
+
setIsUploading(false);
|
|
3022
|
+
setValidationProgress({
|
|
3023
|
+
processed: 0,
|
|
3024
|
+
isValidating: false
|
|
3025
|
+
});
|
|
3026
|
+
config.onSuccess(result);
|
|
3027
|
+
} catch (error) {
|
|
3028
|
+
await safeDeleteContainer({
|
|
3029
|
+
projectKey,
|
|
3030
|
+
containerKey
|
|
3031
|
+
});
|
|
3032
|
+
resetState();
|
|
3033
|
+
if (!(error instanceof PollingAbortedError)) {
|
|
3034
|
+
config.onError?.(error);
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
},
|
|
3038
|
+
onProgress: prog => {
|
|
3039
|
+
setProgress(prog);
|
|
3040
|
+
config.onProgress?.(prog);
|
|
3041
|
+
},
|
|
3042
|
+
onError: error => {
|
|
3043
|
+
resetState();
|
|
3044
|
+
config.onError?.(error);
|
|
3045
|
+
}
|
|
3046
|
+
});
|
|
3047
|
+
} else {
|
|
3048
|
+
await containerUpload.upload({
|
|
3049
|
+
file: config.file,
|
|
3050
|
+
resourceType: config.resourceType,
|
|
3051
|
+
settings: config.settings,
|
|
3052
|
+
abortSignal: config.abortSignal,
|
|
3053
|
+
onSuccess: async (fileUploadResponse, containerKey) => {
|
|
3054
|
+
if (config.abortSignal?.aborted) {
|
|
3055
|
+
await safeDeleteContainer({
|
|
3056
|
+
projectKey,
|
|
3057
|
+
containerKey
|
|
3058
|
+
});
|
|
3059
|
+
resetState();
|
|
3060
|
+
return;
|
|
3061
|
+
}
|
|
3062
|
+
if (fileUploadResponse.invalid > 0) {
|
|
3063
|
+
await safeDeleteContainer({
|
|
3064
|
+
projectKey,
|
|
3065
|
+
containerKey
|
|
3066
|
+
});
|
|
3067
|
+
}
|
|
3068
|
+
const result = {
|
|
3069
|
+
containerKey,
|
|
3070
|
+
summary: {
|
|
3071
|
+
total: fileUploadResponse.itemsCount,
|
|
3072
|
+
valid: fileUploadResponse.valid,
|
|
3073
|
+
invalid: fileUploadResponse.invalid,
|
|
3074
|
+
fieldsCount: fileUploadResponse.columnsCount,
|
|
3075
|
+
fields: fileUploadResponse.fields || [],
|
|
3076
|
+
ignoredFields: fileUploadResponse.ignoredFields || [],
|
|
3077
|
+
results: fileUploadResponse.results || []
|
|
3078
|
+
}
|
|
3079
|
+
};
|
|
3080
|
+
setIsUploading(false);
|
|
3081
|
+
config.onSuccess(result);
|
|
3082
|
+
},
|
|
3083
|
+
onProgress: prog => {
|
|
3084
|
+
setProgress(prog);
|
|
3085
|
+
config.onProgress?.(prog);
|
|
3086
|
+
},
|
|
3087
|
+
onError: error => {
|
|
3088
|
+
resetState();
|
|
3089
|
+
config.onError?.(error);
|
|
3090
|
+
}
|
|
3091
|
+
});
|
|
3092
|
+
}
|
|
3093
|
+
} catch (error) {
|
|
3094
|
+
resetState();
|
|
3095
|
+
config.onError?.(error);
|
|
3096
|
+
}
|
|
3097
|
+
}, [projectKey, useJobBasedFlow, pollingInterval, maxPollingAttempts, containerUpload, jobUpload]);
|
|
3098
|
+
return {
|
|
3099
|
+
upload,
|
|
3100
|
+
isUploading,
|
|
3101
|
+
progress,
|
|
3102
|
+
validationProgress
|
|
3103
|
+
};
|
|
3104
|
+
};
|
|
3105
|
+
|
|
2344
3106
|
exports.ActiveDragDropArea = ActiveDragDropArea;
|
|
2345
3107
|
exports.COLUMN_DELIMITERS = COLUMN_DELIMITERS;
|
|
2346
3108
|
exports.CT_API_DOCS_URL = CT_API_DOCS_URL;
|
|
@@ -2348,19 +3110,23 @@ exports.DELIMITERS = DELIMITERS;
|
|
|
2348
3110
|
exports.DisabledDropArea = DisabledDropArea;
|
|
2349
3111
|
exports.DropAreaWrapper = DropAreaWrapper;
|
|
2350
3112
|
exports.EnabledDropArea = EnabledDropArea;
|
|
3113
|
+
exports.FILE_IMPORT_JOB_POLLING_INTERVAL = FILE_IMPORT_JOB_POLLING_INTERVAL;
|
|
2351
3114
|
exports.FileDropArea = FileDropArea;
|
|
2352
3115
|
exports.FileDroppedArea = FileDroppedArea;
|
|
2353
3116
|
exports.FileIcon = FileIcon;
|
|
2354
3117
|
exports.HttpError = HttpError;
|
|
3118
|
+
exports.IMPORT_LEGACY_MAX_FILE_SIZE_MB = IMPORT_LEGACY_MAX_FILE_SIZE_MB;
|
|
3119
|
+
exports.IMPORT_LEGACY_MAX_ROW_COUNT = IMPORT_LEGACY_MAX_ROW_COUNT;
|
|
3120
|
+
exports.IMPORT_MAX_FILE_SIZE_MB = IMPORT_MAX_FILE_SIZE_MB;
|
|
3121
|
+
exports.IMPORT_MAX_ITEM_COUNT = IMPORT_MAX_ITEM_COUNT;
|
|
2355
3122
|
exports.IMPORT_TAG_KEYS = IMPORT_TAG_KEYS;
|
|
2356
3123
|
exports.IMPORT_TAG_VALUES = IMPORT_TAG_VALUES;
|
|
2357
3124
|
exports.ImportStates = ImportStates;
|
|
2358
3125
|
exports.InfoBox = InfoBox;
|
|
2359
3126
|
exports.InvalidResponseError = InvalidResponseError;
|
|
2360
3127
|
exports.LockIcon = LockIcon;
|
|
2361
|
-
exports.MAX_FILE_SIZE_MB = MAX_FILE_SIZE_MB;
|
|
2362
|
-
exports.MAX_ROW_COUNT = MAX_ROW_COUNT;
|
|
2363
3128
|
exports.NoResourcesToExportError = NoResourcesToExportError;
|
|
3129
|
+
exports.PollingAbortedError = PollingAbortedError;
|
|
2364
3130
|
exports.ProjectKeyNotAvailableError = ProjectKeyNotAvailableError;
|
|
2365
3131
|
exports.QueryPredicateError = QueryPredicateError;
|
|
2366
3132
|
exports.RESOURCE_TYPE_DOCUMENTATION_LINKS = RESOURCE_TYPE_DOCUMENTATION_LINKS;
|
|
@@ -2379,12 +3145,16 @@ exports.allFileUploadImportOperationsResponse = allFileUploadImportOperationsRes
|
|
|
2379
3145
|
exports.appendCsvOrJsonExtensionIfAbsent = appendCsvOrJsonExtensionIfAbsent;
|
|
2380
3146
|
exports.assertCancelContainerResponse = assertCancelContainerResponse;
|
|
2381
3147
|
exports.assertExportOperationsDownloadFileResponse = assertExportOperationsDownloadFileResponse;
|
|
3148
|
+
exports.assertFileImportJob = assertFileImportJob;
|
|
3149
|
+
exports.assertFileImportJobRecordsResponse = assertFileImportJobRecordsResponse;
|
|
2382
3150
|
exports.assertFileUploadResponse = assertFileUploadResponse;
|
|
2383
3151
|
exports.assertImportContainer = assertImportContainer;
|
|
2384
3152
|
exports.assertImportContainerPagedResponse = assertImportContainerPagedResponse;
|
|
2385
3153
|
exports.assertImportOperationPagedResponse = assertImportOperationPagedResponse;
|
|
2386
3154
|
exports.assertImportSummary = assertImportSummary;
|
|
3155
|
+
exports.assertListFileImportJobsResponse = assertListFileImportJobsResponse;
|
|
2387
3156
|
exports.assertPaginatedExportOperationResponse = assertPaginatedExportOperationResponse;
|
|
3157
|
+
exports.assertProcessFileImportJobResponse = assertProcessFileImportJobResponse;
|
|
2388
3158
|
exports.assertProcessFileResponse = assertProcessFileResponse;
|
|
2389
3159
|
exports.assertResourceType = assertResourceType;
|
|
2390
3160
|
exports.automatedImportContainerKey = automatedImportContainerKey;
|
|
@@ -2393,8 +3163,11 @@ exports.cancelImportContainerByKey = cancelImportContainerByKey;
|
|
|
2393
3163
|
exports.checkIfFileUploadImport = checkIfFileUploadImport;
|
|
2394
3164
|
exports.convertFileSizeToKB = convertFileSizeToKB;
|
|
2395
3165
|
exports.countJsonFileItems = countJsonFileItems;
|
|
3166
|
+
exports.countUniqueResourcesInCsv = countUniqueResourcesInCsv;
|
|
3167
|
+
exports.createFileImportJob = createFileImportJob;
|
|
2396
3168
|
exports.createImportContainerForFileUpload = createImportContainerForFileUpload;
|
|
2397
3169
|
exports.decodeFileNameFromImportContainerKey = decodeFileNameFromImportContainerKey;
|
|
3170
|
+
exports.deleteFileImportJob = deleteFileImportJob;
|
|
2398
3171
|
exports.deleteImportContainer = deleteImportContainer;
|
|
2399
3172
|
exports.dropAreaStyles = dropAreaStyles;
|
|
2400
3173
|
exports.encodeFileNameWithTimestampToContainerKey = encodeFileNameWithTimestampToContainerKey;
|
|
@@ -2418,6 +3191,15 @@ exports.formatQueryString = formatQueryString;
|
|
|
2418
3191
|
exports.getCreateImportContainerURL = getCreateImportContainerURL;
|
|
2419
3192
|
exports.getDeleteImportContainerURL = getDeleteImportContainerURL;
|
|
2420
3193
|
exports.getExportOperationsURL = getExportOperationsURL;
|
|
3194
|
+
exports.getFileImportJob = getFileImportJob;
|
|
3195
|
+
exports.getFileImportJobByIdURL = getFileImportJobByIdURL;
|
|
3196
|
+
exports.getFileImportJobDeleteURL = getFileImportJobDeleteURL;
|
|
3197
|
+
exports.getFileImportJobFileType = getFileImportJobFileType;
|
|
3198
|
+
exports.getFileImportJobProcessURL = getFileImportJobProcessURL;
|
|
3199
|
+
exports.getFileImportJobRecords = getFileImportJobRecords;
|
|
3200
|
+
exports.getFileImportJobRecordsURL = getFileImportJobRecordsURL;
|
|
3201
|
+
exports.getFileImportJobsListURL = getFileImportJobsListURL;
|
|
3202
|
+
exports.getFileImportJobsURL = getFileImportJobsURL;
|
|
2421
3203
|
exports.getFileUploadErrorsCount = getFileUploadErrorsCount;
|
|
2422
3204
|
exports.getFileUploadURL = getFileUploadURL;
|
|
2423
3205
|
exports.getImportContainerByKeyURL = getImportContainerByKeyURL;
|
|
@@ -2436,26 +3218,48 @@ exports.hasSingleKeyColumn = hasSingleKeyColumn;
|
|
|
2436
3218
|
exports.importContainers = importContainers;
|
|
2437
3219
|
exports.importStatesMap = importStatesMap;
|
|
2438
3220
|
exports.importsSummaries = importsSummaries;
|
|
3221
|
+
exports.invalidFileImportJobRecordsResponse = invalidFileImportJobRecordsResponse;
|
|
3222
|
+
exports.invalidFileImportJobValidated = invalidFileImportJobValidated;
|
|
2439
3223
|
exports.invalidFileUploadResponse = invalidFileUploadResponse;
|
|
2440
3224
|
exports.isAbortError = isAbortError;
|
|
2441
3225
|
exports.isError = isError;
|
|
3226
|
+
exports.isImportJobInitializing = isImportJobInitializing;
|
|
3227
|
+
exports.isImportJobProcessing = isImportJobProcessing;
|
|
3228
|
+
exports.isImportJobQueued = isImportJobQueued;
|
|
3229
|
+
exports.isImportJobReady = isImportJobReady;
|
|
3230
|
+
exports.isImportJobRejected = isImportJobRejected;
|
|
3231
|
+
exports.isImportJobTerminal = isImportJobTerminal;
|
|
3232
|
+
exports.isImportJobValidated = isImportJobValidated;
|
|
2442
3233
|
exports.isResourceType = isResourceType;
|
|
3234
|
+
exports.listFileImportJobs = listFileImportJobs;
|
|
2443
3235
|
exports.manualImports = manualImports;
|
|
2444
3236
|
exports.mapFileUploadErrorsToUploadFileErrorRows = mapFileUploadErrorsToUploadFileErrorRows;
|
|
2445
3237
|
exports.mapFormikErrors = mapFormikErrors;
|
|
2446
3238
|
exports.mapUploadFileErrorsResponseToUploadFileErrorRows = mapUploadFileErrorsResponseToUploadFileErrorRows;
|
|
3239
|
+
exports.pollJobUntilValidated = pollJobUntilValidated;
|
|
3240
|
+
exports.processFileImportJob = processFileImportJob;
|
|
3241
|
+
exports.processFileImportJobResponse = processFileImportJobResponse;
|
|
2447
3242
|
exports.processUploadedFile = processUploadedFile;
|
|
3243
|
+
exports.shouldContinuePollingForImportValidation = shouldContinuePollingForImportValidation;
|
|
2448
3244
|
exports.successfulAutomatedImportOperations = successfulAutomatedImportOperations;
|
|
2449
3245
|
exports.successfulAutomatedImportOperationsResponse = successfulAutomatedImportOperationsResponse;
|
|
2450
3246
|
exports.successfulFileUploadImportOperations = successfulFileUploadImportOperations;
|
|
2451
3247
|
exports.successfulFileUploadImportOperationsResponse = successfulFileUploadImportOperationsResponse;
|
|
2452
3248
|
exports.toBytes = toBytes;
|
|
3249
|
+
exports.toImportApiResourceType = toImportApiResourceType;
|
|
2453
3250
|
exports.uploadFileForImport = uploadFileForImport;
|
|
2454
3251
|
exports.useFetchExportOperations = useFetchExportOperations;
|
|
3252
|
+
exports.useFetchFileImportJob = useFetchFileImportJob;
|
|
2455
3253
|
exports.useFetchImportContainerDetails = useFetchImportContainerDetails;
|
|
2456
3254
|
exports.useFetchImportOperations = useFetchImportOperations;
|
|
2457
3255
|
exports.useFetchImportSummaries = useFetchImportSummaries;
|
|
3256
|
+
exports.useFileImportJobUpload = useFileImportJobUpload;
|
|
3257
|
+
exports.useFileUpload = useFileUpload;
|
|
2458
3258
|
exports.useImportContainerUpload = useImportContainerUpload;
|
|
3259
|
+
exports.validFileImportJobProcessing = validFileImportJobProcessing;
|
|
3260
|
+
exports.validFileImportJobQueued = validFileImportJobQueued;
|
|
3261
|
+
exports.validFileImportJobRecordsResponse = validFileImportJobRecordsResponse;
|
|
3262
|
+
exports.validFileImportJobValidated = validFileImportJobValidated;
|
|
2459
3263
|
exports.validFileUploadResponse = validFileUploadResponse;
|
|
2460
3264
|
exports.validProcessFileResponse = validProcessFileResponse;
|
|
2461
3265
|
exports.validateDelimiter = validateDelimiter;
|