@commercetools-frontend-extensions/operations 3.3.0 → 3.5.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 +14 -0
- package/dist/commercetools-frontend-extensions-operations.cjs.dev.js +171 -51
- package/dist/commercetools-frontend-extensions-operations.cjs.prod.js +171 -51
- package/dist/commercetools-frontend-extensions-operations.esm.js +161 -51
- package/dist/declarations/src/@api/file-import-jobs.d.ts +2 -2
- package/dist/declarations/src/@errors/base.d.ts +19 -0
- package/dist/declarations/src/@errors/guards.d.ts +12 -0
- package/dist/declarations/src/@errors/http-error.d.ts +4 -1
- package/dist/declarations/src/@errors/index.d.ts +3 -0
- package/dist/declarations/src/@errors/invalid-response-error.d.ts +4 -1
- package/dist/declarations/src/@errors/no-resources-to-export-error.d.ts +4 -1
- package/dist/declarations/src/@errors/polling-aborted-error.d.ts +4 -1
- package/dist/declarations/src/@errors/polling-timeout-error.d.ts +8 -0
- package/dist/declarations/src/@errors/project-key-not-available-error.d.ts +4 -1
- package/dist/declarations/src/@errors/query-predicate-error.d.ts +5 -2
- package/dist/declarations/src/@errors/unexpected-column-error.d.ts +5 -1
- package/dist/declarations/src/@errors/unexpected-operation-state-error.d.ts +5 -1
- package/dist/declarations/src/@errors/unexpected-resource-type-error.d.ts +5 -1
- package/dist/declarations/src/@hooks/use-fetch-file-import-job.d.ts +0 -1
- package/dist/declarations/src/@hooks/use-file-import-job-upload.d.ts +1 -0
- package/dist/declarations/src/@hooks/use-file-upload.d.ts +1 -0
- package/dist/declarations/src/@types/file-import-job.d.ts +2 -1
- package/package.json +1 -1
- package/src/@api/file-import-jobs.ts +13 -4
- package/src/@api/process-file.ts +0 -1
- package/src/@api/urls.ts +11 -2
- package/src/@errors/base.ts +30 -0
- package/src/@errors/guards.ts +43 -0
- package/src/@errors/http-error.ts +5 -1
- package/src/@errors/index.ts +3 -0
- package/src/@errors/invalid-response-error.ts +6 -1
- package/src/@errors/no-resources-to-export-error.ts +6 -1
- package/src/@errors/polling-aborted-error.ts +6 -1
- package/src/@errors/polling-timeout-error.ts +17 -0
- package/src/@errors/project-key-not-available-error.ts +6 -1
- package/src/@errors/query-predicate-error.ts +6 -2
- package/src/@errors/unexpected-column-error.ts +8 -1
- package/src/@errors/unexpected-operation-state-error.ts +7 -1
- package/src/@errors/unexpected-resource-type-error.ts +8 -1
- package/src/@hooks/use-fetch-file-import-job.spec.ts +0 -7
- package/src/@hooks/use-fetch-file-import-job.ts +0 -1
- package/src/@hooks/use-file-import-job-upload.spec.ts +17 -1
- package/src/@hooks/use-file-import-job-upload.ts +2 -0
- package/src/@hooks/use-file-upload.ts +2 -0
- package/src/@types/file-import-job.ts +2 -1
- package/src/@types/file-upload.ts +1 -1
- package/src/@utils/error-mapping.spec.ts +8 -0
- package/src/@utils/poll-job-until-processing.ts +3 -6
- package/src/@utils/poll-job-until-validated.ts +3 -6
|
@@ -16,8 +16,10 @@ import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possi
|
|
|
16
16
|
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
17
17
|
import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
18
18
|
import _wrapNativeSuper from '@babel/runtime-corejs3/helpers/esm/wrapNativeSuper';
|
|
19
|
+
import _Date$now from '@babel/runtime-corejs3/core-js-stable/date/now';
|
|
19
20
|
import { MC_API_PROXY_TARGETS } from '@commercetools-frontend/constants';
|
|
20
21
|
import _everyInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/every';
|
|
22
|
+
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
21
23
|
import { plural } from 'pluralize';
|
|
22
24
|
import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
|
|
23
25
|
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
@@ -25,7 +27,6 @@ import _flatMapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/inst
|
|
|
25
27
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
26
28
|
import _Promise from '@babel/runtime-corejs3/core-js-stable/promise';
|
|
27
29
|
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
28
|
-
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
29
30
|
import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
|
|
30
31
|
import Papa from 'papaparse';
|
|
31
32
|
import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
|
|
@@ -47,139 +48,235 @@ import { InfoDialog } from '@commercetools-frontend/application-components';
|
|
|
47
48
|
import _setInterval from '@babel/runtime-corejs3/core-js-stable/set-interval';
|
|
48
49
|
import { reportErrorToSentry } from '@commercetools-frontend/sentry';
|
|
49
50
|
|
|
50
|
-
function _callSuper$
|
|
51
|
-
function _isNativeReflectConstruct$
|
|
52
|
-
|
|
51
|
+
function _callSuper$a(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$a() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
52
|
+
function _isNativeReflectConstruct$a() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$a = function () { return !!t; })(); }
|
|
53
|
+
const ErrorCode = {
|
|
54
|
+
HTTP_ERROR: 'HTTP_ERROR',
|
|
55
|
+
POLLING_TIMEOUT: 'POLLING_TIMEOUT',
|
|
56
|
+
POLLING_ABORTED: 'POLLING_ABORTED',
|
|
57
|
+
INVALID_RESPONSE: 'INVALID_RESPONSE',
|
|
58
|
+
UNEXPECTED_COLUMN: 'UNEXPECTED_COLUMN',
|
|
59
|
+
QUERY_PREDICATE_ERROR: 'QUERY_PREDICATE_ERROR',
|
|
60
|
+
UNEXPECTED_OPERATION_STATE: 'UNEXPECTED_OPERATION_STATE',
|
|
61
|
+
UNEXPECTED_RESOURCE_TYPE: 'UNEXPECTED_RESOURCE_TYPE',
|
|
62
|
+
PROJECT_KEY_NOT_AVAILABLE: 'PROJECT_KEY_NOT_AVAILABLE',
|
|
63
|
+
NO_RESOURCES_TO_EXPORT: 'NO_RESOURCES_TO_EXPORT'
|
|
64
|
+
};
|
|
65
|
+
let OperationsError = /*#__PURE__*/function (_Error) {
|
|
66
|
+
function OperationsError(message) {
|
|
67
|
+
var _this;
|
|
68
|
+
_classCallCheck(this, OperationsError);
|
|
69
|
+
_this = _callSuper$a(this, OperationsError, [message]);
|
|
70
|
+
_this.code = void 0;
|
|
71
|
+
_this.isRetryable = void 0;
|
|
72
|
+
_this.timestamp = void 0;
|
|
73
|
+
_this.timestamp = _Date$now();
|
|
74
|
+
return _this;
|
|
75
|
+
}
|
|
76
|
+
_inherits(OperationsError, _Error);
|
|
77
|
+
return _createClass(OperationsError);
|
|
78
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
79
|
+
|
|
80
|
+
function hasErrorCode(error) {
|
|
81
|
+
return typeof error === 'object' && error !== null && 'code' in error && typeof error.code === 'string';
|
|
82
|
+
}
|
|
83
|
+
function isOperationsError(error) {
|
|
84
|
+
return hasErrorCode(error);
|
|
85
|
+
}
|
|
86
|
+
function isRetryableError(error) {
|
|
87
|
+
return hasErrorCode(error) && error.isRetryable === true;
|
|
88
|
+
}
|
|
89
|
+
function isNetworkError(error) {
|
|
90
|
+
return hasErrorCode(error) && (error.code === ErrorCode.HTTP_ERROR || error.code === ErrorCode.POLLING_TIMEOUT);
|
|
91
|
+
}
|
|
92
|
+
function isPollingAbortedError(error) {
|
|
93
|
+
return hasErrorCode(error) && error.code === ErrorCode.POLLING_ABORTED;
|
|
94
|
+
}
|
|
95
|
+
function isPollingTimeoutError(error) {
|
|
96
|
+
return hasErrorCode(error) && error.code === ErrorCode.POLLING_TIMEOUT;
|
|
97
|
+
}
|
|
98
|
+
function isHttpError(error) {
|
|
99
|
+
return hasErrorCode(error) && error.code === ErrorCode.HTTP_ERROR;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function _callSuper$9(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$9() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
103
|
+
function _isNativeReflectConstruct$9() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$9 = function () { return !!t; })(); }
|
|
104
|
+
let HttpError = /*#__PURE__*/function (_OperationsError) {
|
|
53
105
|
function HttpError(statusCode, statusText, errorData) {
|
|
54
106
|
var _this;
|
|
55
107
|
_classCallCheck(this, HttpError);
|
|
56
|
-
_this = _callSuper$
|
|
108
|
+
_this = _callSuper$9(this, HttpError, [`HTTP Error! Status code: ${statusCode}, message: "${statusText ? statusText : ''}"`]);
|
|
109
|
+
_this.code = ErrorCode.HTTP_ERROR;
|
|
57
110
|
_this.statusCode = void 0;
|
|
58
111
|
_this.errorData = void 0;
|
|
112
|
+
_this.isRetryable = void 0;
|
|
59
113
|
_this.name = 'HttpError';
|
|
60
114
|
_this.statusCode = statusCode;
|
|
61
115
|
_this.errorData = errorData;
|
|
116
|
+
_this.isRetryable = statusCode >= 500 || statusCode === 408;
|
|
62
117
|
return _this;
|
|
63
118
|
}
|
|
64
|
-
_inherits(HttpError,
|
|
119
|
+
_inherits(HttpError, _OperationsError);
|
|
65
120
|
return _createClass(HttpError);
|
|
66
|
-
}(
|
|
121
|
+
}(OperationsError);
|
|
67
122
|
|
|
68
|
-
function _callSuper$
|
|
69
|
-
function _isNativeReflectConstruct$
|
|
70
|
-
let InvalidResponseError = /*#__PURE__*/function (
|
|
123
|
+
function _callSuper$8(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$8() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
124
|
+
function _isNativeReflectConstruct$8() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$8 = function () { return !!t; })(); }
|
|
125
|
+
let InvalidResponseError = /*#__PURE__*/function (_OperationsError) {
|
|
71
126
|
function InvalidResponseError(message) {
|
|
72
127
|
var _this;
|
|
73
128
|
_classCallCheck(this, InvalidResponseError);
|
|
74
|
-
_this = _callSuper$
|
|
129
|
+
_this = _callSuper$8(this, InvalidResponseError, [message]);
|
|
130
|
+
_this.code = ErrorCode.INVALID_RESPONSE;
|
|
131
|
+
_this.isRetryable = false;
|
|
75
132
|
_this.name = 'InvalidResponseError';
|
|
76
133
|
return _this;
|
|
77
134
|
}
|
|
78
|
-
_inherits(InvalidResponseError,
|
|
135
|
+
_inherits(InvalidResponseError, _OperationsError);
|
|
79
136
|
return _createClass(InvalidResponseError);
|
|
80
|
-
}(
|
|
137
|
+
}(OperationsError);
|
|
81
138
|
|
|
82
|
-
function _callSuper$
|
|
83
|
-
function _isNativeReflectConstruct$
|
|
84
|
-
let NoResourcesToExportError = /*#__PURE__*/function (
|
|
139
|
+
function _callSuper$7(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$7() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
140
|
+
function _isNativeReflectConstruct$7() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$7 = function () { return !!t; })(); }
|
|
141
|
+
let NoResourcesToExportError = /*#__PURE__*/function (_OperationsError) {
|
|
85
142
|
function NoResourcesToExportError() {
|
|
86
143
|
var _this;
|
|
87
144
|
let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'There are no resources to export.';
|
|
88
145
|
_classCallCheck(this, NoResourcesToExportError);
|
|
89
|
-
_this = _callSuper$
|
|
146
|
+
_this = _callSuper$7(this, NoResourcesToExportError, [message]);
|
|
147
|
+
_this.code = ErrorCode.NO_RESOURCES_TO_EXPORT;
|
|
148
|
+
_this.isRetryable = false;
|
|
90
149
|
_this.name = 'NoResourcesToExportError';
|
|
91
150
|
return _this;
|
|
92
151
|
}
|
|
93
|
-
_inherits(NoResourcesToExportError,
|
|
152
|
+
_inherits(NoResourcesToExportError, _OperationsError);
|
|
94
153
|
return _createClass(NoResourcesToExportError);
|
|
95
|
-
}(
|
|
154
|
+
}(OperationsError);
|
|
96
155
|
|
|
97
|
-
function _callSuper$
|
|
98
|
-
function _isNativeReflectConstruct$
|
|
99
|
-
let PollingAbortedError = /*#__PURE__*/function (
|
|
156
|
+
function _callSuper$6(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$6() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
157
|
+
function _isNativeReflectConstruct$6() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$6 = function () { return !!t; })(); }
|
|
158
|
+
let PollingAbortedError = /*#__PURE__*/function (_OperationsError) {
|
|
100
159
|
function PollingAbortedError() {
|
|
101
160
|
var _this;
|
|
102
161
|
_classCallCheck(this, PollingAbortedError);
|
|
103
|
-
_this = _callSuper$
|
|
162
|
+
_this = _callSuper$6(this, PollingAbortedError, ['Polling was aborted']);
|
|
163
|
+
_this.code = ErrorCode.POLLING_ABORTED;
|
|
164
|
+
_this.isRetryable = false;
|
|
104
165
|
_this.name = 'PollingAbortedError';
|
|
105
166
|
return _this;
|
|
106
167
|
}
|
|
107
|
-
_inherits(PollingAbortedError,
|
|
168
|
+
_inherits(PollingAbortedError, _OperationsError);
|
|
108
169
|
return _createClass(PollingAbortedError);
|
|
109
|
-
}(
|
|
170
|
+
}(OperationsError);
|
|
171
|
+
|
|
172
|
+
function _callSuper$5(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$5() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
173
|
+
function _isNativeReflectConstruct$5() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$5 = function () { return !!t; })(); }
|
|
174
|
+
let PollingTimeoutError = /*#__PURE__*/function (_OperationsError) {
|
|
175
|
+
function PollingTimeoutError(maxAttempts, totalTimeSeconds) {
|
|
176
|
+
var _this;
|
|
177
|
+
_classCallCheck(this, PollingTimeoutError);
|
|
178
|
+
_this = _callSuper$5(this, PollingTimeoutError, [`Polling timeout after ${maxAttempts} attempts (${totalTimeSeconds}s)`]);
|
|
179
|
+
_this.code = ErrorCode.POLLING_TIMEOUT;
|
|
180
|
+
_this.isRetryable = true;
|
|
181
|
+
_this.maxAttempts = void 0;
|
|
182
|
+
_this.totalTimeSeconds = void 0;
|
|
183
|
+
_this.name = 'PollingTimeoutError';
|
|
184
|
+
_this.maxAttempts = maxAttempts;
|
|
185
|
+
_this.totalTimeSeconds = totalTimeSeconds;
|
|
186
|
+
return _this;
|
|
187
|
+
}
|
|
188
|
+
_inherits(PollingTimeoutError, _OperationsError);
|
|
189
|
+
return _createClass(PollingTimeoutError);
|
|
190
|
+
}(OperationsError);
|
|
110
191
|
|
|
111
192
|
function _callSuper$4(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$4() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
112
193
|
function _isNativeReflectConstruct$4() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$4 = function () { return !!t; })(); }
|
|
113
|
-
let ProjectKeyNotAvailableError = /*#__PURE__*/function (
|
|
194
|
+
let ProjectKeyNotAvailableError = /*#__PURE__*/function (_OperationsError) {
|
|
114
195
|
function ProjectKeyNotAvailableError() {
|
|
115
196
|
var _this;
|
|
116
197
|
let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Project key is not available';
|
|
117
198
|
_classCallCheck(this, ProjectKeyNotAvailableError);
|
|
118
199
|
_this = _callSuper$4(this, ProjectKeyNotAvailableError, [message]);
|
|
200
|
+
_this.code = ErrorCode.PROJECT_KEY_NOT_AVAILABLE;
|
|
201
|
+
_this.isRetryable = false;
|
|
119
202
|
_this.name = 'ProjectKeyNotAvailableError';
|
|
120
203
|
return _this;
|
|
121
204
|
}
|
|
122
|
-
_inherits(ProjectKeyNotAvailableError,
|
|
205
|
+
_inherits(ProjectKeyNotAvailableError, _OperationsError);
|
|
123
206
|
return _createClass(ProjectKeyNotAvailableError);
|
|
124
|
-
}(
|
|
207
|
+
}(OperationsError);
|
|
125
208
|
|
|
126
209
|
function _callSuper$3(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$3() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
127
210
|
function _isNativeReflectConstruct$3() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$3 = function () { return !!t; })(); }
|
|
128
|
-
let QueryPredicateError = /*#__PURE__*/function (
|
|
211
|
+
let QueryPredicateError = /*#__PURE__*/function (_OperationsError) {
|
|
129
212
|
function QueryPredicateError() {
|
|
130
213
|
var _this;
|
|
131
214
|
let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'There is an error with the query predicate. Make sure the syntax is correct.';
|
|
132
215
|
_classCallCheck(this, QueryPredicateError);
|
|
133
216
|
_this = _callSuper$3(this, QueryPredicateError, [message]);
|
|
217
|
+
_this.code = ErrorCode.QUERY_PREDICATE_ERROR;
|
|
218
|
+
_this.isRetryable = false;
|
|
134
219
|
_this.field = 'queryPredicate';
|
|
135
220
|
_this.name = 'QueryPredicateError';
|
|
136
221
|
return _this;
|
|
137
222
|
}
|
|
138
|
-
_inherits(QueryPredicateError,
|
|
223
|
+
_inherits(QueryPredicateError, _OperationsError);
|
|
139
224
|
return _createClass(QueryPredicateError);
|
|
140
|
-
}(
|
|
225
|
+
}(OperationsError);
|
|
141
226
|
|
|
142
227
|
function _callSuper$2(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$2() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
143
228
|
function _isNativeReflectConstruct$2() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$2 = function () { return !!t; })(); }
|
|
144
|
-
let UnexpectedColumnError = /*#__PURE__*/function (
|
|
229
|
+
let UnexpectedColumnError = /*#__PURE__*/function (_OperationsError) {
|
|
145
230
|
function UnexpectedColumnError(columnName) {
|
|
146
231
|
var _this;
|
|
147
232
|
_classCallCheck(this, UnexpectedColumnError);
|
|
148
233
|
_this = _callSuper$2(this, UnexpectedColumnError, [`Unexpected column "${columnName}"`]);
|
|
234
|
+
_this.code = ErrorCode.UNEXPECTED_COLUMN;
|
|
235
|
+
_this.isRetryable = false;
|
|
236
|
+
_this.columnName = void 0;
|
|
149
237
|
_this.name = 'UnexpectedColumnError';
|
|
238
|
+
_this.columnName = columnName;
|
|
150
239
|
return _this;
|
|
151
240
|
}
|
|
152
|
-
_inherits(UnexpectedColumnError,
|
|
241
|
+
_inherits(UnexpectedColumnError, _OperationsError);
|
|
153
242
|
return _createClass(UnexpectedColumnError);
|
|
154
|
-
}(
|
|
243
|
+
}(OperationsError);
|
|
155
244
|
|
|
156
245
|
function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
157
246
|
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
|
|
158
|
-
let UnexpectedOperationStateError = /*#__PURE__*/function (
|
|
247
|
+
let UnexpectedOperationStateError = /*#__PURE__*/function (_OperationsError) {
|
|
159
248
|
function UnexpectedOperationStateError(state) {
|
|
160
249
|
var _this;
|
|
161
250
|
_classCallCheck(this, UnexpectedOperationStateError);
|
|
162
251
|
_this = _callSuper$1(this, UnexpectedOperationStateError, [`Unexpected operation state "${state}"`]);
|
|
252
|
+
_this.code = ErrorCode.UNEXPECTED_OPERATION_STATE;
|
|
253
|
+
_this.isRetryable = false;
|
|
254
|
+
_this.state = void 0;
|
|
163
255
|
_this.name = 'UnexpectedOperationStateError';
|
|
256
|
+
_this.state = state;
|
|
164
257
|
return _this;
|
|
165
258
|
}
|
|
166
|
-
_inherits(UnexpectedOperationStateError,
|
|
259
|
+
_inherits(UnexpectedOperationStateError, _OperationsError);
|
|
167
260
|
return _createClass(UnexpectedOperationStateError);
|
|
168
|
-
}(
|
|
261
|
+
}(OperationsError);
|
|
169
262
|
|
|
170
263
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
171
264
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
172
|
-
let UnexpectedResourceTypeError = /*#__PURE__*/function (
|
|
265
|
+
let UnexpectedResourceTypeError = /*#__PURE__*/function (_OperationsError) {
|
|
173
266
|
function UnexpectedResourceTypeError(resourceType) {
|
|
174
267
|
var _this;
|
|
175
268
|
_classCallCheck(this, UnexpectedResourceTypeError);
|
|
176
269
|
_this = _callSuper(this, UnexpectedResourceTypeError, [`Unexpected resource type "${resourceType}"`]);
|
|
270
|
+
_this.code = ErrorCode.UNEXPECTED_RESOURCE_TYPE;
|
|
271
|
+
_this.isRetryable = false;
|
|
272
|
+
_this.resourceType = void 0;
|
|
177
273
|
_this.name = 'UnexpectedResourceTypeError';
|
|
274
|
+
_this.resourceType = resourceType;
|
|
178
275
|
return _this;
|
|
179
276
|
}
|
|
180
|
-
_inherits(UnexpectedResourceTypeError,
|
|
277
|
+
_inherits(UnexpectedResourceTypeError, _OperationsError);
|
|
181
278
|
return _createClass(UnexpectedResourceTypeError);
|
|
182
|
-
}(
|
|
279
|
+
}(OperationsError);
|
|
183
280
|
|
|
184
281
|
function ownKeys$9(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
185
282
|
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(_context2 = ownKeys$9(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$9(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -695,7 +792,8 @@ const pollJobUntilProcessing = async _ref => {
|
|
|
695
792
|
});
|
|
696
793
|
attempts++;
|
|
697
794
|
}
|
|
698
|
-
|
|
795
|
+
const totalTimeSeconds = maxAttempts * pollingInterval / 1000;
|
|
796
|
+
throw new PollingTimeoutError(maxAttempts, totalTimeSeconds);
|
|
699
797
|
};
|
|
700
798
|
|
|
701
799
|
const pollJobUntilValidated = async _ref => {
|
|
@@ -743,7 +841,8 @@ const pollJobUntilValidated = async _ref => {
|
|
|
743
841
|
});
|
|
744
842
|
attempts++;
|
|
745
843
|
}
|
|
746
|
-
|
|
844
|
+
const totalTimeSeconds = maxAttempts * pollingInterval / 1000;
|
|
845
|
+
throw new PollingTimeoutError(maxAttempts, totalTimeSeconds);
|
|
747
846
|
};
|
|
748
847
|
|
|
749
848
|
/**
|
|
@@ -769,6 +868,13 @@ function formatQueryString() {
|
|
|
769
868
|
return queryString.toString() ? `?${queryString.toString()}` : '';
|
|
770
869
|
}
|
|
771
870
|
|
|
871
|
+
const OPERATION_RESOURCE_TYPES = ['product-delete', 'product-unpublish'];
|
|
872
|
+
function pluralizeResourceType(resourceType) {
|
|
873
|
+
if (_includesInstanceProperty(OPERATION_RESOURCE_TYPES).call(OPERATION_RESOURCE_TYPES, resourceType)) {
|
|
874
|
+
return resourceType;
|
|
875
|
+
}
|
|
876
|
+
return plural(resourceType);
|
|
877
|
+
}
|
|
772
878
|
function getImportContainersURL(_ref) {
|
|
773
879
|
let projectKey = _ref.projectKey,
|
|
774
880
|
queryParams = _ref.queryParams;
|
|
@@ -828,7 +934,7 @@ function getFileImportJobsURL(_ref1) {
|
|
|
828
934
|
let projectKey = _ref1.projectKey,
|
|
829
935
|
resourceType = _ref1.resourceType,
|
|
830
936
|
importContainerKey = _ref1.importContainerKey;
|
|
831
|
-
return `/${projectKey}/${
|
|
937
|
+
return `/${projectKey}/${pluralizeResourceType(toImportApiResourceType(resourceType))}/import-containers/${importContainerKey}/file-import-jobs`;
|
|
832
938
|
}
|
|
833
939
|
function getFileImportJobByIdURL(_ref10) {
|
|
834
940
|
let projectKey = _ref10.projectKey,
|
|
@@ -847,7 +953,7 @@ function getFileImportJobProcessURL(_ref12) {
|
|
|
847
953
|
resourceType = _ref12.resourceType,
|
|
848
954
|
importContainerKey = _ref12.importContainerKey,
|
|
849
955
|
jobId = _ref12.jobId;
|
|
850
|
-
return `/${projectKey}/${
|
|
956
|
+
return `/${projectKey}/${pluralizeResourceType(toImportApiResourceType(resourceType))}/import-containers/${importContainerKey}/file-import-jobs/${jobId}/process`;
|
|
851
957
|
}
|
|
852
958
|
function getFileImportJobDeleteURL(_ref13) {
|
|
853
959
|
let projectKey = _ref13.projectKey,
|
|
@@ -906,11 +1012,13 @@ function createFileImportJob(_ref) {
|
|
|
906
1012
|
payload = _ref.payload,
|
|
907
1013
|
_ref$autoProcess = _ref.autoProcess,
|
|
908
1014
|
autoProcess = _ref$autoProcess === void 0 ? false : _ref$autoProcess,
|
|
1015
|
+
operationType = _ref.operationType,
|
|
909
1016
|
onProgress = _ref.onProgress,
|
|
910
1017
|
abortSignal = _ref.abortSignal;
|
|
1018
|
+
const urlResourceType = operationType ? `${resourceType}-${operationType}` : resourceType;
|
|
911
1019
|
const url = getFileImportJobsURL({
|
|
912
1020
|
projectKey,
|
|
913
|
-
resourceType,
|
|
1021
|
+
resourceType: urlResourceType,
|
|
914
1022
|
importContainerKey
|
|
915
1023
|
});
|
|
916
1024
|
if ('fileType' in payload) {
|
|
@@ -1008,15 +1116,16 @@ async function processFileImportJob(_ref4) {
|
|
|
1008
1116
|
resourceType = _ref4.resourceType,
|
|
1009
1117
|
importContainerKey = _ref4.importContainerKey,
|
|
1010
1118
|
jobId = _ref4.jobId,
|
|
1011
|
-
|
|
1119
|
+
operationType = _ref4.operationType;
|
|
1120
|
+
const urlResourceType = operationType ? `${resourceType}-${operationType}` : resourceType;
|
|
1012
1121
|
const url = getFileImportJobProcessURL({
|
|
1013
1122
|
projectKey,
|
|
1014
|
-
resourceType,
|
|
1123
|
+
resourceType: urlResourceType,
|
|
1015
1124
|
importContainerKey,
|
|
1016
1125
|
jobId
|
|
1017
1126
|
});
|
|
1018
|
-
const payload =
|
|
1019
|
-
action
|
|
1127
|
+
const payload = operationType ? {
|
|
1128
|
+
action: operationType
|
|
1020
1129
|
} : {};
|
|
1021
1130
|
const response = await fetcher({
|
|
1022
1131
|
url,
|
|
@@ -1353,7 +1462,6 @@ async function processUploadedFile(_ref) {
|
|
|
1353
1462
|
importContainerKey = _ref.importContainerKey,
|
|
1354
1463
|
resourceType = _ref.resourceType,
|
|
1355
1464
|
action = _ref.action;
|
|
1356
|
-
// For delete operations with action (like 'delete') -> use different URL and payload structure
|
|
1357
1465
|
const uri = action ? getImportContainerTasksURL({
|
|
1358
1466
|
projectKey,
|
|
1359
1467
|
importContainerKey
|
|
@@ -2853,6 +2961,7 @@ const useFileImportJobUpload = _ref => {
|
|
|
2853
2961
|
file: config.file
|
|
2854
2962
|
},
|
|
2855
2963
|
autoProcess: config.autoProcess,
|
|
2964
|
+
operationType: config.operationType,
|
|
2856
2965
|
onProgress: uploadProgress => {
|
|
2857
2966
|
setProgress(uploadProgress);
|
|
2858
2967
|
config.onProgress?.(uploadProgress);
|
|
@@ -3042,6 +3151,7 @@ const useFileUpload = _ref2 => {
|
|
|
3042
3151
|
resourceType: config.resourceType,
|
|
3043
3152
|
settings: config.settings,
|
|
3044
3153
|
autoProcess: config.autoProcess,
|
|
3154
|
+
operationType: config.operationType,
|
|
3045
3155
|
abortSignal: config.abortSignal,
|
|
3046
3156
|
onSuccess: async (jobId, containerKey) => {
|
|
3047
3157
|
if (config.skipValidationPolling) {
|
|
@@ -3207,4 +3317,4 @@ const useFileUpload = _ref2 => {
|
|
|
3207
3317
|
};
|
|
3208
3318
|
};
|
|
3209
3319
|
|
|
3210
|
-
export { ActiveDragDropArea, COLUMN_DELIMITERS, CT_API_DOCS_URL, DELIMITERS, DisabledDropArea, DropAreaWrapper, EnabledDropArea, FILE_IMPORT_JOB_POLLING_INTERVAL, FileDropArea, FileDroppedArea, FileIcon, HttpError, IMPORT_LEGACY_MAX_FILE_SIZE_MB, IMPORT_LEGACY_MAX_ROW_COUNT, IMPORT_MAX_FILE_SIZE_MB, IMPORT_MAX_ITEM_COUNT, IMPORT_TAG_KEYS, IMPORT_TAG_VALUES, ImportStates, InfoBox, InvalidResponseError, LockIcon, NoResourcesToExportError, PollingAbortedError, ProjectKeyNotAvailableError, QueryPredicateError, RESOURCE_TYPE_DOCUMENTATION_LINKS, RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS, TAG_KEY_SOURCE_FILE_UPLOAD, UnexpectedColumnError, UnexpectedOperationStateError, UnexpectedResourceTypeError, UploadSeparator, UploadSettings, UploadingModal, allAutomatedImportOperations, allAutomatedImportOperationsResponse, allFileUploadImportOperations, allFileUploadImportOperationsResponse, appendCsvOrJsonExtensionIfAbsent, assertCancelContainerResponse, assertExportOperationsDownloadFileResponse, assertFileImportJob, assertFileImportJobRecordsResponse, assertFileUploadResponse, assertImportContainer, assertImportContainerPagedResponse, assertImportOperationPagedResponse, assertImportSummary, assertListFileImportJobsResponse, assertPaginatedExportOperationResponse, assertProcessFileImportJobResponse, assertProcessFileResponse, assertResourceType, automatedImportContainerKey, automatedImports, cancelImportContainerByKey, checkIfFileUploadImport, convertFileSizeToKB, countJsonFileItems, createFileImportJob, createImportContainerForFileUpload, decodeFileNameFromImportContainerKey, deleteFileImportJob, deleteImportContainer, dropAreaStyles, encodeFileNameWithTimestampToContainerKey, exportOperationsCompleted, exportOperationsProcessing, extractErrorDescriptionFromValidationMessage, fetchExportOperations, fetchImportContainerByKey, fetchImportContainerDetails, fetchImportContainers, fetchImportOperations, fetchImportSummaries, fetchImportSummary, fetchUsingXhr, fetcher, fileUploadImportContainerKey, fileUploadMissingKeysResponse, formatErrorCode, formatKeys, formatQueryString, getCreateImportContainerURL, getDeleteImportContainerURL, getExportOperationsURL, getFileImportJob, getFileImportJobByIdURL, getFileImportJobDeleteURL, getFileImportJobFileType, getFileImportJobInfoForContainer, getFileImportJobProcessURL, getFileImportJobRecords, getFileImportJobRecordsURL, getFileImportJobsListURL, getFileImportJobsURL, getFileUploadErrorsCount, getFileUploadURL, getImportContainerByKeyURL, getImportContainerTasksURL, getImportContainersURL, getImportOperationsURL, getImportState, getImportSummaryURL, getMissingRequiredFields, getProccessFileURL, getRowCount, getValidatedColumns, hasImportJobStartedProcessing, hasOwnProperty, hasRequiredFields, hasSingleKeyColumn, importContainers, importStatesMap, importsSummaries, invalidFileImportJobRecordsResponse, invalidFileImportJobValidated, invalidFileUploadResponse, isAbortError, isError, isImportJobInitializing, isImportJobProcessing, isImportJobQueued, isImportJobReady, isImportJobRejected, isImportJobTerminal, isImportJobValidated, isResourceType, listFileImportJobs, manualImports, mapFileUploadErrorsToUploadFileErrorRows, mapFormikErrors, mapUploadFileErrorsResponseToUploadFileErrorRows, pollJobUntilProcessing, pollJobUntilValidated, processFileImportJob, processFileImportJobResponse, processUploadedFile, shouldContinuePollingForImportValidation, successfulAutomatedImportOperations, successfulAutomatedImportOperationsResponse, successfulFileUploadImportOperations, successfulFileUploadImportOperationsResponse, toBytes, toImportApiResourceType, uploadFileForImport, useFetchExportOperations, useFetchFileImportJob, useFetchFileImportJobRecords, useFetchImportContainerDetails, useFetchImportOperations, useFetchImportSummaries, useFileImportJobUpload, useFileUpload, useImportContainerUpload, validFileImportJobProcessing, validFileImportJobQueued, validFileImportJobRecordsResponse, validFileImportJobValidated, validFileUploadResponse, validProcessFileResponse, validateDelimiter };
|
|
3320
|
+
export { ActiveDragDropArea, COLUMN_DELIMITERS, CT_API_DOCS_URL, DELIMITERS, DisabledDropArea, DropAreaWrapper, EnabledDropArea, ErrorCode, FILE_IMPORT_JOB_POLLING_INTERVAL, FileDropArea, FileDroppedArea, FileIcon, HttpError, IMPORT_LEGACY_MAX_FILE_SIZE_MB, IMPORT_LEGACY_MAX_ROW_COUNT, IMPORT_MAX_FILE_SIZE_MB, IMPORT_MAX_ITEM_COUNT, IMPORT_TAG_KEYS, IMPORT_TAG_VALUES, ImportStates, InfoBox, InvalidResponseError, LockIcon, NoResourcesToExportError, OperationsError, PollingAbortedError, PollingTimeoutError, ProjectKeyNotAvailableError, QueryPredicateError, RESOURCE_TYPE_DOCUMENTATION_LINKS, RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS, TAG_KEY_SOURCE_FILE_UPLOAD, UnexpectedColumnError, UnexpectedOperationStateError, UnexpectedResourceTypeError, UploadSeparator, UploadSettings, UploadingModal, allAutomatedImportOperations, allAutomatedImportOperationsResponse, allFileUploadImportOperations, allFileUploadImportOperationsResponse, appendCsvOrJsonExtensionIfAbsent, assertCancelContainerResponse, assertExportOperationsDownloadFileResponse, assertFileImportJob, assertFileImportJobRecordsResponse, assertFileUploadResponse, assertImportContainer, assertImportContainerPagedResponse, assertImportOperationPagedResponse, assertImportSummary, assertListFileImportJobsResponse, assertPaginatedExportOperationResponse, assertProcessFileImportJobResponse, assertProcessFileResponse, assertResourceType, automatedImportContainerKey, automatedImports, cancelImportContainerByKey, checkIfFileUploadImport, convertFileSizeToKB, countJsonFileItems, createFileImportJob, createImportContainerForFileUpload, decodeFileNameFromImportContainerKey, deleteFileImportJob, deleteImportContainer, dropAreaStyles, encodeFileNameWithTimestampToContainerKey, exportOperationsCompleted, exportOperationsProcessing, extractErrorDescriptionFromValidationMessage, fetchExportOperations, fetchImportContainerByKey, fetchImportContainerDetails, fetchImportContainers, fetchImportOperations, fetchImportSummaries, fetchImportSummary, fetchUsingXhr, fetcher, fileUploadImportContainerKey, fileUploadMissingKeysResponse, formatErrorCode, formatKeys, formatQueryString, getCreateImportContainerURL, getDeleteImportContainerURL, getExportOperationsURL, getFileImportJob, getFileImportJobByIdURL, getFileImportJobDeleteURL, getFileImportJobFileType, getFileImportJobInfoForContainer, getFileImportJobProcessURL, getFileImportJobRecords, getFileImportJobRecordsURL, getFileImportJobsListURL, getFileImportJobsURL, getFileUploadErrorsCount, getFileUploadURL, getImportContainerByKeyURL, getImportContainerTasksURL, getImportContainersURL, getImportOperationsURL, getImportState, getImportSummaryURL, getMissingRequiredFields, getProccessFileURL, getRowCount, getValidatedColumns, hasImportJobStartedProcessing, hasOwnProperty, hasRequiredFields, hasSingleKeyColumn, importContainers, importStatesMap, importsSummaries, invalidFileImportJobRecordsResponse, invalidFileImportJobValidated, invalidFileUploadResponse, isAbortError, isError, isHttpError, isImportJobInitializing, isImportJobProcessing, isImportJobQueued, isImportJobReady, isImportJobRejected, isImportJobTerminal, isImportJobValidated, isNetworkError, isOperationsError, isPollingAbortedError, isPollingTimeoutError, isResourceType, isRetryableError, listFileImportJobs, manualImports, mapFileUploadErrorsToUploadFileErrorRows, mapFormikErrors, mapUploadFileErrorsResponseToUploadFileErrorRows, pollJobUntilProcessing, pollJobUntilValidated, processFileImportJob, processFileImportJobResponse, processUploadedFile, shouldContinuePollingForImportValidation, successfulAutomatedImportOperations, successfulAutomatedImportOperationsResponse, successfulFileUploadImportOperations, successfulFileUploadImportOperationsResponse, toBytes, toImportApiResourceType, uploadFileForImport, useFetchExportOperations, useFetchFileImportJob, useFetchFileImportJobRecords, useFetchImportContainerDetails, useFetchImportOperations, useFetchImportSummaries, useFileImportJobUpload, useFileUpload, useImportContainerUpload, validFileImportJobProcessing, validFileImportJobQueued, validFileImportJobRecordsResponse, validFileImportJobValidated, validFileUploadResponse, validProcessFileResponse, validateDelimiter };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { FileImportJob, CreateFileImportJobParameters, GetFileImportJobParameters, GetFileImportJobRecordsParameters, ProcessFileImportJobParameters, ProcessFileImportJobResponse, DeleteFileImportJobParameters, ListFileImportJobsParameters, ListFileImportJobsResponse, FileImportJobRecordsResponse } from "../@types/index.js";
|
|
2
|
-
export declare function createFileImportJob({ projectKey, resourceType, importContainerKey, payload, autoProcess, onProgress, abortSignal, }: CreateFileImportJobParameters): Promise<FileImportJob>;
|
|
2
|
+
export declare function createFileImportJob({ projectKey, resourceType, importContainerKey, payload, autoProcess, operationType, onProgress, abortSignal, }: CreateFileImportJobParameters): Promise<FileImportJob>;
|
|
3
3
|
export declare function getFileImportJob({ projectKey, importContainerKey, jobId, }: GetFileImportJobParameters): Promise<FileImportJob>;
|
|
4
4
|
export declare function getFileImportJobRecords({ projectKey, importContainerKey, jobId, limit, offset, isValid, }: GetFileImportJobRecordsParameters): Promise<FileImportJobRecordsResponse>;
|
|
5
|
-
export declare function processFileImportJob({ projectKey, resourceType, importContainerKey, jobId,
|
|
5
|
+
export declare function processFileImportJob({ projectKey, resourceType, importContainerKey, jobId, operationType, }: ProcessFileImportJobParameters): Promise<ProcessFileImportJobResponse>;
|
|
6
6
|
export declare function deleteFileImportJob({ projectKey, importContainerKey, jobId, }: DeleteFileImportJobParameters): Promise<void>;
|
|
7
7
|
export declare function listFileImportJobs({ projectKey, importContainerKey, limit, offset, }: ListFileImportJobsParameters): Promise<ListFileImportJobsResponse>;
|
|
8
8
|
export type FileImportJobInfo = {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const ErrorCode: {
|
|
2
|
+
readonly HTTP_ERROR: "HTTP_ERROR";
|
|
3
|
+
readonly POLLING_TIMEOUT: "POLLING_TIMEOUT";
|
|
4
|
+
readonly POLLING_ABORTED: "POLLING_ABORTED";
|
|
5
|
+
readonly INVALID_RESPONSE: "INVALID_RESPONSE";
|
|
6
|
+
readonly UNEXPECTED_COLUMN: "UNEXPECTED_COLUMN";
|
|
7
|
+
readonly QUERY_PREDICATE_ERROR: "QUERY_PREDICATE_ERROR";
|
|
8
|
+
readonly UNEXPECTED_OPERATION_STATE: "UNEXPECTED_OPERATION_STATE";
|
|
9
|
+
readonly UNEXPECTED_RESOURCE_TYPE: "UNEXPECTED_RESOURCE_TYPE";
|
|
10
|
+
readonly PROJECT_KEY_NOT_AVAILABLE: "PROJECT_KEY_NOT_AVAILABLE";
|
|
11
|
+
readonly NO_RESOURCES_TO_EXPORT: "NO_RESOURCES_TO_EXPORT";
|
|
12
|
+
};
|
|
13
|
+
export type ErrorCodeType = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
14
|
+
export declare abstract class OperationsError extends Error {
|
|
15
|
+
abstract readonly code: ErrorCodeType;
|
|
16
|
+
abstract readonly isRetryable: boolean;
|
|
17
|
+
readonly timestamp: number;
|
|
18
|
+
constructor(message: string);
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ErrorCodeType } from "./base.js";
|
|
2
|
+
type ErrorWithCode = {
|
|
3
|
+
code: ErrorCodeType;
|
|
4
|
+
isRetryable: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function isOperationsError(error: unknown): error is ErrorWithCode;
|
|
7
|
+
export declare function isRetryableError(error: unknown): boolean;
|
|
8
|
+
export declare function isNetworkError(error: unknown): boolean;
|
|
9
|
+
export declare function isPollingAbortedError(error: unknown): boolean;
|
|
10
|
+
export declare function isPollingTimeoutError(error: unknown): boolean;
|
|
11
|
+
export declare function isHttpError(error: unknown): boolean;
|
|
12
|
+
export {};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { BasicErrorDataType } from "../@types/index.js";
|
|
2
|
-
|
|
2
|
+
import { OperationsError } from "./base.js";
|
|
3
|
+
export declare class HttpError<T = BasicErrorDataType> extends OperationsError {
|
|
4
|
+
readonly code: "HTTP_ERROR";
|
|
3
5
|
readonly statusCode: number;
|
|
4
6
|
readonly errorData?: T;
|
|
7
|
+
readonly isRetryable: boolean;
|
|
5
8
|
constructor(statusCode: number, statusText?: string, errorData?: T);
|
|
6
9
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
export * from "./base.js";
|
|
2
|
+
export * from "./guards.js";
|
|
1
3
|
export * from "./http-error.js";
|
|
2
4
|
export * from "./invalid-response-error.js";
|
|
3
5
|
export * from "./no-resources-to-export-error.js";
|
|
4
6
|
export * from "./polling-aborted-error.js";
|
|
7
|
+
export * from "./polling-timeout-error.js";
|
|
5
8
|
export * from "./project-key-not-available-error.js";
|
|
6
9
|
export * from "./query-predicate-error.js";
|
|
7
10
|
export * from "./unexpected-column-error.js";
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { OperationsError } from "./base.js";
|
|
2
|
+
export declare class InvalidResponseError extends OperationsError {
|
|
3
|
+
readonly code: "INVALID_RESPONSE";
|
|
4
|
+
readonly isRetryable = false;
|
|
2
5
|
constructor(message: string);
|
|
3
6
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { OperationsError } from "./base.js";
|
|
2
|
+
export declare class NoResourcesToExportError extends OperationsError {
|
|
3
|
+
readonly code: "NO_RESOURCES_TO_EXPORT";
|
|
4
|
+
readonly isRetryable = false;
|
|
2
5
|
constructor(message?: string);
|
|
3
6
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OperationsError } from "./base.js";
|
|
2
|
+
export declare class PollingTimeoutError extends OperationsError {
|
|
3
|
+
readonly code: "POLLING_TIMEOUT";
|
|
4
|
+
readonly isRetryable = true;
|
|
5
|
+
readonly maxAttempts: number;
|
|
6
|
+
readonly totalTimeSeconds: number;
|
|
7
|
+
constructor(maxAttempts: number, totalTimeSeconds: number);
|
|
8
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { OperationsError } from "./base.js";
|
|
2
|
+
export declare class ProjectKeyNotAvailableError extends OperationsError {
|
|
3
|
+
readonly code: "PROJECT_KEY_NOT_AVAILABLE";
|
|
4
|
+
readonly isRetryable = false;
|
|
2
5
|
constructor(message?: string);
|
|
3
6
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { OperationsError } from "./base.js";
|
|
2
|
+
export declare class QueryPredicateError extends OperationsError {
|
|
3
|
+
readonly code: "QUERY_PREDICATE_ERROR";
|
|
4
|
+
readonly isRetryable = false;
|
|
5
|
+
readonly field = "queryPredicate";
|
|
3
6
|
constructor(message?: string);
|
|
4
7
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { OperationsError } from "./base.js";
|
|
2
|
+
export declare class UnexpectedColumnError extends OperationsError {
|
|
3
|
+
readonly code: "UNEXPECTED_COLUMN";
|
|
4
|
+
readonly isRetryable = false;
|
|
5
|
+
readonly columnName: string;
|
|
2
6
|
constructor(columnName: string);
|
|
3
7
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ProcessingState } from '@commercetools/importapi-sdk';
|
|
2
|
-
|
|
2
|
+
import { OperationsError } from "./base.js";
|
|
3
|
+
export declare class UnexpectedOperationStateError extends OperationsError {
|
|
4
|
+
readonly code: "UNEXPECTED_OPERATION_STATE";
|
|
5
|
+
readonly isRetryable = false;
|
|
6
|
+
readonly state: ProcessingState;
|
|
3
7
|
constructor(state: ProcessingState);
|
|
4
8
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { OperationsError } from "./base.js";
|
|
2
|
+
export declare class UnexpectedResourceTypeError extends OperationsError {
|
|
3
|
+
readonly code: "UNEXPECTED_RESOURCE_TYPE";
|
|
4
|
+
readonly isRetryable = false;
|
|
5
|
+
readonly resourceType: string;
|
|
2
6
|
constructor(resourceType: string);
|
|
3
7
|
}
|
|
@@ -5,6 +5,7 @@ export type UseFileImportJobUploadConfig = {
|
|
|
5
5
|
resourceType: ResourceTypeId;
|
|
6
6
|
settings?: ExtendedImportContainerDraft['settings'];
|
|
7
7
|
autoProcess?: boolean;
|
|
8
|
+
operationType?: 'delete';
|
|
8
9
|
onSuccess: (jobId: string, importContainerKey: string) => void;
|
|
9
10
|
onError?: (error: unknown) => void;
|
|
10
11
|
onProgress?: (progress: number) => void;
|
|
@@ -10,6 +10,7 @@ export type FileUploadConfig = {
|
|
|
10
10
|
settings?: ExtendedImportContainerDraft['settings'];
|
|
11
11
|
autoProcess?: boolean;
|
|
12
12
|
skipValidationPolling?: boolean;
|
|
13
|
+
operationType?: 'delete';
|
|
13
14
|
onSuccess: (result: FileUploadResult) => void;
|
|
14
15
|
onError?: (error: unknown) => void;
|
|
15
16
|
onProgress?: (progress: number) => void;
|
|
@@ -40,6 +40,7 @@ export interface CreateFileImportJobParameters {
|
|
|
40
40
|
importContainerKey: string;
|
|
41
41
|
payload: CreateFileImportJobPayload;
|
|
42
42
|
autoProcess?: boolean;
|
|
43
|
+
operationType?: 'delete';
|
|
43
44
|
onProgress?: (progress: number) => void;
|
|
44
45
|
abortSignal?: AbortSignal;
|
|
45
46
|
}
|
|
@@ -77,7 +78,7 @@ export interface ProcessFileImportJobParameters {
|
|
|
77
78
|
resourceType: string;
|
|
78
79
|
importContainerKey: string;
|
|
79
80
|
jobId: string;
|
|
80
|
-
|
|
81
|
+
operationType?: 'delete';
|
|
81
82
|
}
|
|
82
83
|
export interface ProcessFileImportJobResponse {
|
|
83
84
|
message: string;
|