@commercetools-frontend-extensions/operations 0.0.0 → 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 +19 -20
- 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",
|
|
@@ -1896,8 +2375,8 @@ function getDefaultDropWrapperStyles(_dropAreaState) {
|
|
|
1896
2375
|
return /*#__PURE__*/react.css(process.env.NODE_ENV === "production" ? "" : ";label:getDefaultDropWrapperStyles;");
|
|
1897
2376
|
}
|
|
1898
2377
|
|
|
1899
|
-
function ownKeys$
|
|
1900
|
-
function _objectSpread$
|
|
2378
|
+
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; }
|
|
2379
|
+
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; }
|
|
1901
2380
|
const FileDropArea = _ref => {
|
|
1902
2381
|
let onDrop = _ref.onDrop,
|
|
1903
2382
|
disabled = _ref.disabled,
|
|
@@ -1930,11 +2409,11 @@ const FileDropArea = _ref => {
|
|
|
1930
2409
|
getInputProps = _useDropzone.getInputProps,
|
|
1931
2410
|
isDragActive = _useDropzone.isDragActive;
|
|
1932
2411
|
const dropAreaState = getDropAreaState(isDragActive);
|
|
1933
|
-
return /*#__PURE__*/jsxRuntime.jsxs(DropAreaWrapper, _objectSpread$
|
|
2412
|
+
return /*#__PURE__*/jsxRuntime.jsxs(DropAreaWrapper, _objectSpread$3(_objectSpread$3({
|
|
1934
2413
|
role: "presentation"
|
|
1935
2414
|
}, getRootProps()), {}, {
|
|
1936
2415
|
dropAreaState: dropAreaState,
|
|
1937
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("input", _objectSpread$
|
|
2416
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("input", _objectSpread$3({
|
|
1938
2417
|
"data-testid": "file-input"
|
|
1939
2418
|
}, getInputProps())), /*#__PURE__*/jsxRuntime.jsx(uiKit.Constraints.Horizontal, {
|
|
1940
2419
|
children: children(dropAreaState)
|
|
@@ -2039,8 +2518,8 @@ const UploadingModal = _ref => {
|
|
|
2039
2518
|
progress = _ref.progress,
|
|
2040
2519
|
cancelLabel = _ref.cancelLabel,
|
|
2041
2520
|
onCancel = _ref.onCancel,
|
|
2042
|
-
onClose = _ref.onClose
|
|
2043
|
-
|
|
2521
|
+
onClose = _ref.onClose,
|
|
2522
|
+
statusMessage = _ref.statusMessage;
|
|
2044
2523
|
return /*#__PURE__*/jsxRuntime.jsx(applicationComponents.InfoDialog, {
|
|
2045
2524
|
size: 16,
|
|
2046
2525
|
isOpen: isOpen,
|
|
@@ -2064,7 +2543,7 @@ const UploadingModal = _ref => {
|
|
|
2064
2543
|
})
|
|
2065
2544
|
}), /*#__PURE__*/jsxRuntime.jsxs(uiKit.Text.Body, {
|
|
2066
2545
|
tone: "secondary",
|
|
2067
|
-
children: ["(",
|
|
2546
|
+
children: ["(", convertFileSizeToKB(fileSize).toLocaleString(), " KB)"]
|
|
2068
2547
|
})]
|
|
2069
2548
|
}), /*#__PURE__*/jsxRuntime.jsx(uiKit.SecondaryButton, {
|
|
2070
2549
|
tone: "secondary",
|
|
@@ -2076,22 +2555,16 @@ const UploadingModal = _ref => {
|
|
|
2076
2555
|
barWidth: "scale",
|
|
2077
2556
|
height: "10",
|
|
2078
2557
|
progress: progress
|
|
2079
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
2558
|
+
}), statusMessage && /*#__PURE__*/jsxRuntime.jsx(uiKit.Text.Detail, {
|
|
2559
|
+
tone: "tertiary",
|
|
2560
|
+
children: statusMessage
|
|
2561
|
+
})]
|
|
2080
2562
|
})
|
|
2081
2563
|
});
|
|
2082
2564
|
};
|
|
2083
2565
|
|
|
2084
|
-
var messages = reactIntl.defineMessages({
|
|
2085
|
-
unexpectedError: {
|
|
2086
|
-
id: 'operations.fetch.unexpectedError',
|
|
2087
|
-
description: 'Generic error message displayed when an unexpected error occurs during data fetching',
|
|
2088
|
-
defaultMessage: 'An unexpected error occurred while fetching the data. Please try again. If the problem persists, please contact support.'
|
|
2089
|
-
}
|
|
2090
|
-
});
|
|
2091
|
-
|
|
2092
2566
|
const useFetch = function (fetchFunction) {
|
|
2093
2567
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2094
|
-
const intl = reactIntl.useIntl();
|
|
2095
2568
|
const _React$useState = React__default["default"].useState(null),
|
|
2096
2569
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
2097
2570
|
data = _React$useState2[0],
|
|
@@ -2130,10 +2603,9 @@ const useFetch = function (fetchFunction) {
|
|
|
2130
2603
|
}
|
|
2131
2604
|
}
|
|
2132
2605
|
} catch (err) {
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
setError(new Error(intl.formatMessage(messages.unexpectedError)));
|
|
2606
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
2607
|
+
setError(error);
|
|
2608
|
+
if (!(err instanceof HttpError)) {
|
|
2137
2609
|
sentry.reportErrorToSentry(new Error('An unexpected error occurred in the `useFetch` hook'), {
|
|
2138
2610
|
extra: {
|
|
2139
2611
|
error: err
|
|
@@ -2155,7 +2627,7 @@ const useFetch = function (fetchFunction) {
|
|
|
2155
2627
|
setError(null);
|
|
2156
2628
|
setIsLoading(false);
|
|
2157
2629
|
};
|
|
2158
|
-
}, [fetchFunction, refetchCount,
|
|
2630
|
+
}, [fetchFunction, refetchCount, config.pollingInterval, config.shouldContinuePolling]);
|
|
2159
2631
|
return {
|
|
2160
2632
|
data,
|
|
2161
2633
|
error,
|
|
@@ -2185,6 +2657,28 @@ const useFetchExportOperations = _ref => {
|
|
|
2185
2657
|
});
|
|
2186
2658
|
};
|
|
2187
2659
|
|
|
2660
|
+
const useFetchFileImportJob = _ref => {
|
|
2661
|
+
let projectKey = _ref.projectKey,
|
|
2662
|
+
importContainerKey = _ref.importContainerKey,
|
|
2663
|
+
jobId = _ref.jobId,
|
|
2664
|
+
pollingInterval = _ref.pollingInterval,
|
|
2665
|
+
shouldContinuePolling = _ref.shouldContinuePolling;
|
|
2666
|
+
const fetchData = React__default["default"].useCallback(() => {
|
|
2667
|
+
if (!projectKey) {
|
|
2668
|
+
return _Promise__default["default"].reject(new ProjectKeyNotAvailableError());
|
|
2669
|
+
}
|
|
2670
|
+
return getFileImportJob({
|
|
2671
|
+
projectKey,
|
|
2672
|
+
importContainerKey,
|
|
2673
|
+
jobId
|
|
2674
|
+
});
|
|
2675
|
+
}, [projectKey, importContainerKey, jobId]);
|
|
2676
|
+
return useFetch(fetchData, {
|
|
2677
|
+
pollingInterval,
|
|
2678
|
+
shouldContinuePolling
|
|
2679
|
+
});
|
|
2680
|
+
};
|
|
2681
|
+
|
|
2188
2682
|
const useFetchImportContainerDetails = _ref => {
|
|
2189
2683
|
let projectKey = _ref.projectKey,
|
|
2190
2684
|
importContainerKey = _ref.importContainerKey,
|
|
@@ -2253,8 +2747,78 @@ const useFetchImportSummaries = _ref => {
|
|
|
2253
2747
|
});
|
|
2254
2748
|
};
|
|
2255
2749
|
|
|
2256
|
-
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; }
|
|
2257
|
-
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; }
|
|
2750
|
+
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; }
|
|
2751
|
+
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; }
|
|
2752
|
+
const useFileImportJobUpload = _ref => {
|
|
2753
|
+
let projectKey = _ref.projectKey;
|
|
2754
|
+
const _React$useState = React__default["default"].useState(false),
|
|
2755
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
2756
|
+
isUploading = _React$useState2[0],
|
|
2757
|
+
setIsUploading = _React$useState2[1];
|
|
2758
|
+
const _React$useState3 = React__default["default"].useState(0),
|
|
2759
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
2760
|
+
progress = _React$useState4[0],
|
|
2761
|
+
setProgress = _React$useState4[1];
|
|
2762
|
+
const upload = React__default["default"].useCallback(async config => {
|
|
2763
|
+
if (!projectKey) {
|
|
2764
|
+
throw new ProjectKeyNotAvailableError();
|
|
2765
|
+
}
|
|
2766
|
+
setIsUploading(true);
|
|
2767
|
+
setProgress(0);
|
|
2768
|
+
const importContainerKey = encodeFileNameWithTimestampToContainerKey(config.file.name);
|
|
2769
|
+
try {
|
|
2770
|
+
await createImportContainerForFileUpload({
|
|
2771
|
+
importContainerDraft: _objectSpread$2({
|
|
2772
|
+
key: importContainerKey,
|
|
2773
|
+
resourceType: config.resourceType,
|
|
2774
|
+
tags: [TAG_KEY_SOURCE_FILE_UPLOAD]
|
|
2775
|
+
}, config.settings ? {
|
|
2776
|
+
settings: config.settings
|
|
2777
|
+
} : {}),
|
|
2778
|
+
projectKey
|
|
2779
|
+
});
|
|
2780
|
+
const jobResponse = await createFileImportJob({
|
|
2781
|
+
projectKey,
|
|
2782
|
+
resourceType: config.resourceType,
|
|
2783
|
+
importContainerKey,
|
|
2784
|
+
payload: {
|
|
2785
|
+
fileType: getFileImportJobFileType(config.resourceType),
|
|
2786
|
+
fileName: config.file.name,
|
|
2787
|
+
file: config.file
|
|
2788
|
+
},
|
|
2789
|
+
onProgress: uploadProgress => {
|
|
2790
|
+
setProgress(uploadProgress);
|
|
2791
|
+
config.onProgress?.(uploadProgress);
|
|
2792
|
+
},
|
|
2793
|
+
abortSignal: config.abortSignal
|
|
2794
|
+
});
|
|
2795
|
+
setIsUploading(false);
|
|
2796
|
+
setProgress(100);
|
|
2797
|
+
config.onSuccess(jobResponse.id, importContainerKey);
|
|
2798
|
+
} catch (error) {
|
|
2799
|
+
try {
|
|
2800
|
+
await deleteImportContainer({
|
|
2801
|
+
projectKey,
|
|
2802
|
+
importContainerKey
|
|
2803
|
+
});
|
|
2804
|
+
} catch {
|
|
2805
|
+
// Ignore cleanup errors - container will be cleaned up by TTL retention policy
|
|
2806
|
+
// Cleanup errors are unlikely unless there is a network issue or container was removed externally
|
|
2807
|
+
}
|
|
2808
|
+
setIsUploading(false);
|
|
2809
|
+
setProgress(0);
|
|
2810
|
+
config.onError?.(error);
|
|
2811
|
+
}
|
|
2812
|
+
}, [projectKey]);
|
|
2813
|
+
return {
|
|
2814
|
+
upload,
|
|
2815
|
+
isUploading,
|
|
2816
|
+
progress
|
|
2817
|
+
};
|
|
2818
|
+
};
|
|
2819
|
+
|
|
2820
|
+
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; }
|
|
2821
|
+
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; }
|
|
2258
2822
|
const useImportContainerUpload = _ref => {
|
|
2259
2823
|
let projectKey = _ref.projectKey;
|
|
2260
2824
|
const _React$useState = React__default["default"].useState(false),
|
|
@@ -2272,7 +2836,8 @@ const useImportContainerUpload = _ref => {
|
|
|
2272
2836
|
settings = _ref2.settings,
|
|
2273
2837
|
onSuccess = _ref2.onSuccess,
|
|
2274
2838
|
onError = _ref2.onError,
|
|
2275
|
-
onProgress = _ref2.onProgress
|
|
2839
|
+
onProgress = _ref2.onProgress,
|
|
2840
|
+
abortSignal = _ref2.abortSignal;
|
|
2276
2841
|
if (!projectKey) {
|
|
2277
2842
|
throw new ProjectKeyNotAvailableError();
|
|
2278
2843
|
}
|
|
@@ -2281,7 +2846,7 @@ const useImportContainerUpload = _ref => {
|
|
|
2281
2846
|
const importContainerKey = encodeFileNameWithTimestampToContainerKey(file.name);
|
|
2282
2847
|
try {
|
|
2283
2848
|
await createImportContainerForFileUpload({
|
|
2284
|
-
importContainerDraft: _objectSpread({
|
|
2849
|
+
importContainerDraft: _objectSpread$1({
|
|
2285
2850
|
key: importContainerKey,
|
|
2286
2851
|
resourceType,
|
|
2287
2852
|
tags: [TAG_KEY_SOURCE_FILE_UPLOAD]
|
|
@@ -2295,6 +2860,7 @@ const useImportContainerUpload = _ref => {
|
|
|
2295
2860
|
importContainerKey,
|
|
2296
2861
|
resourceType,
|
|
2297
2862
|
file,
|
|
2863
|
+
abortSignal,
|
|
2298
2864
|
onSuccess: response => {
|
|
2299
2865
|
setIsUploading(false);
|
|
2300
2866
|
setProgress(100);
|
|
@@ -2333,7 +2899,8 @@ const useImportContainerUpload = _ref => {
|
|
|
2333
2899
|
}
|
|
2334
2900
|
setIsUploading(false);
|
|
2335
2901
|
setProgress(0);
|
|
2336
|
-
|
|
2902
|
+
onError?.(error);
|
|
2903
|
+
return undefined;
|
|
2337
2904
|
}
|
|
2338
2905
|
};
|
|
2339
2906
|
const abort = () => {
|
|
@@ -2349,6 +2916,201 @@ const useImportContainerUpload = _ref => {
|
|
|
2349
2916
|
};
|
|
2350
2917
|
};
|
|
2351
2918
|
|
|
2919
|
+
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; }
|
|
2920
|
+
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; }
|
|
2921
|
+
const safeDeleteContainer = async _ref => {
|
|
2922
|
+
let projectKey = _ref.projectKey,
|
|
2923
|
+
containerKey = _ref.containerKey;
|
|
2924
|
+
try {
|
|
2925
|
+
await deleteImportContainer({
|
|
2926
|
+
projectKey,
|
|
2927
|
+
importContainerKey: containerKey
|
|
2928
|
+
});
|
|
2929
|
+
} catch {}
|
|
2930
|
+
};
|
|
2931
|
+
const useFileUpload = _ref2 => {
|
|
2932
|
+
let projectKey = _ref2.projectKey,
|
|
2933
|
+
_ref2$useJobBasedFlow = _ref2.useJobBasedFlow,
|
|
2934
|
+
useJobBasedFlow = _ref2$useJobBasedFlow === void 0 ? false : _ref2$useJobBasedFlow,
|
|
2935
|
+
_ref2$pollingInterval = _ref2.pollingInterval,
|
|
2936
|
+
pollingInterval = _ref2$pollingInterval === void 0 ? 5000 : _ref2$pollingInterval,
|
|
2937
|
+
_ref2$maxPollingAttem = _ref2.maxPollingAttempts,
|
|
2938
|
+
maxPollingAttempts = _ref2$maxPollingAttem === void 0 ? 120 : _ref2$maxPollingAttem;
|
|
2939
|
+
const _React$useState = React__default["default"].useState(false),
|
|
2940
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
2941
|
+
isUploading = _React$useState2[0],
|
|
2942
|
+
setIsUploading = _React$useState2[1];
|
|
2943
|
+
const _React$useState3 = React__default["default"].useState(0),
|
|
2944
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
2945
|
+
progress = _React$useState4[0],
|
|
2946
|
+
setProgress = _React$useState4[1];
|
|
2947
|
+
const _React$useState5 = React__default["default"].useState({
|
|
2948
|
+
processed: 0,
|
|
2949
|
+
isValidating: false
|
|
2950
|
+
}),
|
|
2951
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
2952
|
+
validationProgress = _React$useState6[0],
|
|
2953
|
+
setValidationProgress = _React$useState6[1];
|
|
2954
|
+
const containerUpload = useImportContainerUpload({
|
|
2955
|
+
projectKey
|
|
2956
|
+
});
|
|
2957
|
+
const jobUpload = useFileImportJobUpload({
|
|
2958
|
+
projectKey
|
|
2959
|
+
});
|
|
2960
|
+
const resetState = React__default["default"].useCallback(() => {
|
|
2961
|
+
setIsUploading(false);
|
|
2962
|
+
setProgress(0);
|
|
2963
|
+
setValidationProgress({
|
|
2964
|
+
processed: 0,
|
|
2965
|
+
isValidating: false
|
|
2966
|
+
});
|
|
2967
|
+
}, []);
|
|
2968
|
+
const upload = React__default["default"].useCallback(async config => {
|
|
2969
|
+
setIsUploading(true);
|
|
2970
|
+
setProgress(0);
|
|
2971
|
+
try {
|
|
2972
|
+
if (useJobBasedFlow) {
|
|
2973
|
+
await jobUpload.upload({
|
|
2974
|
+
file: config.file,
|
|
2975
|
+
resourceType: config.resourceType,
|
|
2976
|
+
settings: config.settings,
|
|
2977
|
+
abortSignal: config.abortSignal,
|
|
2978
|
+
onSuccess: async (jobId, containerKey) => {
|
|
2979
|
+
try {
|
|
2980
|
+
setValidationProgress({
|
|
2981
|
+
processed: 0,
|
|
2982
|
+
isValidating: true
|
|
2983
|
+
});
|
|
2984
|
+
const validatedJob = await pollJobUntilValidated({
|
|
2985
|
+
projectKey,
|
|
2986
|
+
jobId,
|
|
2987
|
+
importContainerKey: containerKey,
|
|
2988
|
+
pollingInterval,
|
|
2989
|
+
maxAttempts: maxPollingAttempts,
|
|
2990
|
+
abortSignal: config.abortSignal,
|
|
2991
|
+
onJobUpdate: job => {
|
|
2992
|
+
const processed = job.summary?.total ?? 0;
|
|
2993
|
+
setValidationProgress({
|
|
2994
|
+
processed,
|
|
2995
|
+
isValidating: true
|
|
2996
|
+
});
|
|
2997
|
+
config.onValidationProgress?.(job);
|
|
2998
|
+
}
|
|
2999
|
+
});
|
|
3000
|
+
|
|
3001
|
+
// Handle rejected job with jobError for the new flow (like MissingCsvFieldIdentifier error)
|
|
3002
|
+
// We wrap it in HttpError to reuse existing error handling (for the old flow) in consumers until BE supports this error type
|
|
3003
|
+
if (validatedJob.jobError) {
|
|
3004
|
+
throw new HttpError(400, validatedJob.jobError.message, validatedJob.jobError);
|
|
3005
|
+
}
|
|
3006
|
+
let results = [];
|
|
3007
|
+
if (validatedJob.summary.invalid > 0) {
|
|
3008
|
+
const recordsResponse = await getFileImportJobRecords({
|
|
3009
|
+
projectKey,
|
|
3010
|
+
importContainerKey: containerKey,
|
|
3011
|
+
jobId,
|
|
3012
|
+
limit: 500,
|
|
3013
|
+
isValid: false
|
|
3014
|
+
});
|
|
3015
|
+
results = recordsResponse.results;
|
|
3016
|
+
await safeDeleteContainer({
|
|
3017
|
+
projectKey,
|
|
3018
|
+
containerKey
|
|
3019
|
+
});
|
|
3020
|
+
}
|
|
3021
|
+
const result = {
|
|
3022
|
+
containerKey,
|
|
3023
|
+
summary: _objectSpread(_objectSpread({}, validatedJob.summary), {}, {
|
|
3024
|
+
results
|
|
3025
|
+
}),
|
|
3026
|
+
jobId,
|
|
3027
|
+
job: validatedJob
|
|
3028
|
+
};
|
|
3029
|
+
setIsUploading(false);
|
|
3030
|
+
setValidationProgress({
|
|
3031
|
+
processed: 0,
|
|
3032
|
+
isValidating: false
|
|
3033
|
+
});
|
|
3034
|
+
config.onSuccess(result);
|
|
3035
|
+
} catch (error) {
|
|
3036
|
+
await safeDeleteContainer({
|
|
3037
|
+
projectKey,
|
|
3038
|
+
containerKey
|
|
3039
|
+
});
|
|
3040
|
+
resetState();
|
|
3041
|
+
if (!(error instanceof PollingAbortedError)) {
|
|
3042
|
+
config.onError?.(error);
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
},
|
|
3046
|
+
onProgress: prog => {
|
|
3047
|
+
setProgress(prog);
|
|
3048
|
+
config.onProgress?.(prog);
|
|
3049
|
+
},
|
|
3050
|
+
onError: error => {
|
|
3051
|
+
resetState();
|
|
3052
|
+
config.onError?.(error);
|
|
3053
|
+
}
|
|
3054
|
+
});
|
|
3055
|
+
} else {
|
|
3056
|
+
await containerUpload.upload({
|
|
3057
|
+
file: config.file,
|
|
3058
|
+
resourceType: config.resourceType,
|
|
3059
|
+
settings: config.settings,
|
|
3060
|
+
abortSignal: config.abortSignal,
|
|
3061
|
+
onSuccess: async (fileUploadResponse, containerKey) => {
|
|
3062
|
+
if (config.abortSignal?.aborted) {
|
|
3063
|
+
await safeDeleteContainer({
|
|
3064
|
+
projectKey,
|
|
3065
|
+
containerKey
|
|
3066
|
+
});
|
|
3067
|
+
resetState();
|
|
3068
|
+
return;
|
|
3069
|
+
}
|
|
3070
|
+
if (fileUploadResponse.invalid > 0) {
|
|
3071
|
+
await safeDeleteContainer({
|
|
3072
|
+
projectKey,
|
|
3073
|
+
containerKey
|
|
3074
|
+
});
|
|
3075
|
+
}
|
|
3076
|
+
const result = {
|
|
3077
|
+
containerKey,
|
|
3078
|
+
summary: {
|
|
3079
|
+
total: fileUploadResponse.itemsCount,
|
|
3080
|
+
valid: fileUploadResponse.valid,
|
|
3081
|
+
invalid: fileUploadResponse.invalid,
|
|
3082
|
+
fieldsCount: fileUploadResponse.columnsCount,
|
|
3083
|
+
fields: fileUploadResponse.fields || [],
|
|
3084
|
+
ignoredFields: fileUploadResponse.ignoredFields || [],
|
|
3085
|
+
results: fileUploadResponse.results || []
|
|
3086
|
+
}
|
|
3087
|
+
};
|
|
3088
|
+
setIsUploading(false);
|
|
3089
|
+
config.onSuccess(result);
|
|
3090
|
+
},
|
|
3091
|
+
onProgress: prog => {
|
|
3092
|
+
setProgress(prog);
|
|
3093
|
+
config.onProgress?.(prog);
|
|
3094
|
+
},
|
|
3095
|
+
onError: error => {
|
|
3096
|
+
resetState();
|
|
3097
|
+
config.onError?.(error);
|
|
3098
|
+
}
|
|
3099
|
+
});
|
|
3100
|
+
}
|
|
3101
|
+
} catch (error) {
|
|
3102
|
+
resetState();
|
|
3103
|
+
config.onError?.(error);
|
|
3104
|
+
}
|
|
3105
|
+
}, [projectKey, useJobBasedFlow, pollingInterval, maxPollingAttempts, containerUpload, jobUpload]);
|
|
3106
|
+
return {
|
|
3107
|
+
upload,
|
|
3108
|
+
isUploading,
|
|
3109
|
+
progress,
|
|
3110
|
+
validationProgress
|
|
3111
|
+
};
|
|
3112
|
+
};
|
|
3113
|
+
|
|
2352
3114
|
exports.ActiveDragDropArea = ActiveDragDropArea;
|
|
2353
3115
|
exports.COLUMN_DELIMITERS = COLUMN_DELIMITERS;
|
|
2354
3116
|
exports.CT_API_DOCS_URL = CT_API_DOCS_URL;
|
|
@@ -2356,19 +3118,23 @@ exports.DELIMITERS = DELIMITERS;
|
|
|
2356
3118
|
exports.DisabledDropArea = DisabledDropArea;
|
|
2357
3119
|
exports.DropAreaWrapper = DropAreaWrapper;
|
|
2358
3120
|
exports.EnabledDropArea = EnabledDropArea;
|
|
3121
|
+
exports.FILE_IMPORT_JOB_POLLING_INTERVAL = FILE_IMPORT_JOB_POLLING_INTERVAL;
|
|
2359
3122
|
exports.FileDropArea = FileDropArea;
|
|
2360
3123
|
exports.FileDroppedArea = FileDroppedArea;
|
|
2361
3124
|
exports.FileIcon = FileIcon;
|
|
2362
3125
|
exports.HttpError = HttpError;
|
|
3126
|
+
exports.IMPORT_LEGACY_MAX_FILE_SIZE_MB = IMPORT_LEGACY_MAX_FILE_SIZE_MB;
|
|
3127
|
+
exports.IMPORT_LEGACY_MAX_ROW_COUNT = IMPORT_LEGACY_MAX_ROW_COUNT;
|
|
3128
|
+
exports.IMPORT_MAX_FILE_SIZE_MB = IMPORT_MAX_FILE_SIZE_MB;
|
|
3129
|
+
exports.IMPORT_MAX_ITEM_COUNT = IMPORT_MAX_ITEM_COUNT;
|
|
2363
3130
|
exports.IMPORT_TAG_KEYS = IMPORT_TAG_KEYS;
|
|
2364
3131
|
exports.IMPORT_TAG_VALUES = IMPORT_TAG_VALUES;
|
|
2365
3132
|
exports.ImportStates = ImportStates;
|
|
2366
3133
|
exports.InfoBox = InfoBox;
|
|
2367
3134
|
exports.InvalidResponseError = InvalidResponseError;
|
|
2368
3135
|
exports.LockIcon = LockIcon;
|
|
2369
|
-
exports.MAX_FILE_SIZE_MB = MAX_FILE_SIZE_MB;
|
|
2370
|
-
exports.MAX_ROW_COUNT = MAX_ROW_COUNT;
|
|
2371
3136
|
exports.NoResourcesToExportError = NoResourcesToExportError;
|
|
3137
|
+
exports.PollingAbortedError = PollingAbortedError;
|
|
2372
3138
|
exports.ProjectKeyNotAvailableError = ProjectKeyNotAvailableError;
|
|
2373
3139
|
exports.QueryPredicateError = QueryPredicateError;
|
|
2374
3140
|
exports.RESOURCE_TYPE_DOCUMENTATION_LINKS = RESOURCE_TYPE_DOCUMENTATION_LINKS;
|
|
@@ -2387,12 +3153,16 @@ exports.allFileUploadImportOperationsResponse = allFileUploadImportOperationsRes
|
|
|
2387
3153
|
exports.appendCsvOrJsonExtensionIfAbsent = appendCsvOrJsonExtensionIfAbsent;
|
|
2388
3154
|
exports.assertCancelContainerResponse = assertCancelContainerResponse;
|
|
2389
3155
|
exports.assertExportOperationsDownloadFileResponse = assertExportOperationsDownloadFileResponse;
|
|
3156
|
+
exports.assertFileImportJob = assertFileImportJob;
|
|
3157
|
+
exports.assertFileImportJobRecordsResponse = assertFileImportJobRecordsResponse;
|
|
2390
3158
|
exports.assertFileUploadResponse = assertFileUploadResponse;
|
|
2391
3159
|
exports.assertImportContainer = assertImportContainer;
|
|
2392
3160
|
exports.assertImportContainerPagedResponse = assertImportContainerPagedResponse;
|
|
2393
3161
|
exports.assertImportOperationPagedResponse = assertImportOperationPagedResponse;
|
|
2394
3162
|
exports.assertImportSummary = assertImportSummary;
|
|
3163
|
+
exports.assertListFileImportJobsResponse = assertListFileImportJobsResponse;
|
|
2395
3164
|
exports.assertPaginatedExportOperationResponse = assertPaginatedExportOperationResponse;
|
|
3165
|
+
exports.assertProcessFileImportJobResponse = assertProcessFileImportJobResponse;
|
|
2396
3166
|
exports.assertProcessFileResponse = assertProcessFileResponse;
|
|
2397
3167
|
exports.assertResourceType = assertResourceType;
|
|
2398
3168
|
exports.automatedImportContainerKey = automatedImportContainerKey;
|
|
@@ -2401,8 +3171,11 @@ exports.cancelImportContainerByKey = cancelImportContainerByKey;
|
|
|
2401
3171
|
exports.checkIfFileUploadImport = checkIfFileUploadImport;
|
|
2402
3172
|
exports.convertFileSizeToKB = convertFileSizeToKB;
|
|
2403
3173
|
exports.countJsonFileItems = countJsonFileItems;
|
|
3174
|
+
exports.countUniqueResourcesInCsv = countUniqueResourcesInCsv;
|
|
3175
|
+
exports.createFileImportJob = createFileImportJob;
|
|
2404
3176
|
exports.createImportContainerForFileUpload = createImportContainerForFileUpload;
|
|
2405
3177
|
exports.decodeFileNameFromImportContainerKey = decodeFileNameFromImportContainerKey;
|
|
3178
|
+
exports.deleteFileImportJob = deleteFileImportJob;
|
|
2406
3179
|
exports.deleteImportContainer = deleteImportContainer;
|
|
2407
3180
|
exports.dropAreaStyles = dropAreaStyles;
|
|
2408
3181
|
exports.encodeFileNameWithTimestampToContainerKey = encodeFileNameWithTimestampToContainerKey;
|
|
@@ -2426,6 +3199,15 @@ exports.formatQueryString = formatQueryString;
|
|
|
2426
3199
|
exports.getCreateImportContainerURL = getCreateImportContainerURL;
|
|
2427
3200
|
exports.getDeleteImportContainerURL = getDeleteImportContainerURL;
|
|
2428
3201
|
exports.getExportOperationsURL = getExportOperationsURL;
|
|
3202
|
+
exports.getFileImportJob = getFileImportJob;
|
|
3203
|
+
exports.getFileImportJobByIdURL = getFileImportJobByIdURL;
|
|
3204
|
+
exports.getFileImportJobDeleteURL = getFileImportJobDeleteURL;
|
|
3205
|
+
exports.getFileImportJobFileType = getFileImportJobFileType;
|
|
3206
|
+
exports.getFileImportJobProcessURL = getFileImportJobProcessURL;
|
|
3207
|
+
exports.getFileImportJobRecords = getFileImportJobRecords;
|
|
3208
|
+
exports.getFileImportJobRecordsURL = getFileImportJobRecordsURL;
|
|
3209
|
+
exports.getFileImportJobsListURL = getFileImportJobsListURL;
|
|
3210
|
+
exports.getFileImportJobsURL = getFileImportJobsURL;
|
|
2429
3211
|
exports.getFileUploadErrorsCount = getFileUploadErrorsCount;
|
|
2430
3212
|
exports.getFileUploadURL = getFileUploadURL;
|
|
2431
3213
|
exports.getImportContainerByKeyURL = getImportContainerByKeyURL;
|
|
@@ -2444,26 +3226,48 @@ exports.hasSingleKeyColumn = hasSingleKeyColumn;
|
|
|
2444
3226
|
exports.importContainers = importContainers;
|
|
2445
3227
|
exports.importStatesMap = importStatesMap;
|
|
2446
3228
|
exports.importsSummaries = importsSummaries;
|
|
3229
|
+
exports.invalidFileImportJobRecordsResponse = invalidFileImportJobRecordsResponse;
|
|
3230
|
+
exports.invalidFileImportJobValidated = invalidFileImportJobValidated;
|
|
2447
3231
|
exports.invalidFileUploadResponse = invalidFileUploadResponse;
|
|
2448
3232
|
exports.isAbortError = isAbortError;
|
|
2449
3233
|
exports.isError = isError;
|
|
3234
|
+
exports.isImportJobInitializing = isImportJobInitializing;
|
|
3235
|
+
exports.isImportJobProcessing = isImportJobProcessing;
|
|
3236
|
+
exports.isImportJobQueued = isImportJobQueued;
|
|
3237
|
+
exports.isImportJobReady = isImportJobReady;
|
|
3238
|
+
exports.isImportJobRejected = isImportJobRejected;
|
|
3239
|
+
exports.isImportJobTerminal = isImportJobTerminal;
|
|
3240
|
+
exports.isImportJobValidated = isImportJobValidated;
|
|
2450
3241
|
exports.isResourceType = isResourceType;
|
|
3242
|
+
exports.listFileImportJobs = listFileImportJobs;
|
|
2451
3243
|
exports.manualImports = manualImports;
|
|
2452
3244
|
exports.mapFileUploadErrorsToUploadFileErrorRows = mapFileUploadErrorsToUploadFileErrorRows;
|
|
2453
3245
|
exports.mapFormikErrors = mapFormikErrors;
|
|
2454
3246
|
exports.mapUploadFileErrorsResponseToUploadFileErrorRows = mapUploadFileErrorsResponseToUploadFileErrorRows;
|
|
3247
|
+
exports.pollJobUntilValidated = pollJobUntilValidated;
|
|
3248
|
+
exports.processFileImportJob = processFileImportJob;
|
|
3249
|
+
exports.processFileImportJobResponse = processFileImportJobResponse;
|
|
2455
3250
|
exports.processUploadedFile = processUploadedFile;
|
|
3251
|
+
exports.shouldContinuePollingForImportValidation = shouldContinuePollingForImportValidation;
|
|
2456
3252
|
exports.successfulAutomatedImportOperations = successfulAutomatedImportOperations;
|
|
2457
3253
|
exports.successfulAutomatedImportOperationsResponse = successfulAutomatedImportOperationsResponse;
|
|
2458
3254
|
exports.successfulFileUploadImportOperations = successfulFileUploadImportOperations;
|
|
2459
3255
|
exports.successfulFileUploadImportOperationsResponse = successfulFileUploadImportOperationsResponse;
|
|
2460
3256
|
exports.toBytes = toBytes;
|
|
3257
|
+
exports.toImportApiResourceType = toImportApiResourceType;
|
|
2461
3258
|
exports.uploadFileForImport = uploadFileForImport;
|
|
2462
3259
|
exports.useFetchExportOperations = useFetchExportOperations;
|
|
3260
|
+
exports.useFetchFileImportJob = useFetchFileImportJob;
|
|
2463
3261
|
exports.useFetchImportContainerDetails = useFetchImportContainerDetails;
|
|
2464
3262
|
exports.useFetchImportOperations = useFetchImportOperations;
|
|
2465
3263
|
exports.useFetchImportSummaries = useFetchImportSummaries;
|
|
3264
|
+
exports.useFileImportJobUpload = useFileImportJobUpload;
|
|
3265
|
+
exports.useFileUpload = useFileUpload;
|
|
2466
3266
|
exports.useImportContainerUpload = useImportContainerUpload;
|
|
3267
|
+
exports.validFileImportJobProcessing = validFileImportJobProcessing;
|
|
3268
|
+
exports.validFileImportJobQueued = validFileImportJobQueued;
|
|
3269
|
+
exports.validFileImportJobRecordsResponse = validFileImportJobRecordsResponse;
|
|
3270
|
+
exports.validFileImportJobValidated = validFileImportJobValidated;
|
|
2467
3271
|
exports.validFileUploadResponse = validFileUploadResponse;
|
|
2468
3272
|
exports.validProcessFileResponse = validProcessFileResponse;
|
|
2469
3273
|
exports.validateDelimiter = validateDelimiter;
|