@commercetools-frontend-extensions/operations 3.4.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 +8 -0
- package/dist/commercetools-frontend-extensions-operations.cjs.dev.js +150 -41
- package/dist/commercetools-frontend-extensions-operations.cjs.prod.js +150 -41
- package/dist/commercetools-frontend-extensions-operations.esm.js +141 -42
- 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/package.json +1 -1
- 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/@utils/poll-job-until-processing.ts +3 -6
- package/src/@utils/poll-job-until-validated.ts +3 -6
|
@@ -16,6 +16,7 @@ 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';
|
|
21
22
|
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
@@ -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
|
/**
|
|
@@ -3218,4 +3317,4 @@ const useFileUpload = _ref2 => {
|
|
|
3218
3317
|
};
|
|
3219
3318
|
};
|
|
3220
3319
|
|
|
3221
|
-
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 };
|
|
@@ -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
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const ErrorCode = {
|
|
2
|
+
HTTP_ERROR: 'HTTP_ERROR',
|
|
3
|
+
POLLING_TIMEOUT: 'POLLING_TIMEOUT',
|
|
4
|
+
POLLING_ABORTED: 'POLLING_ABORTED',
|
|
5
|
+
|
|
6
|
+
INVALID_RESPONSE: 'INVALID_RESPONSE',
|
|
7
|
+
UNEXPECTED_COLUMN: 'UNEXPECTED_COLUMN',
|
|
8
|
+
QUERY_PREDICATE_ERROR: 'QUERY_PREDICATE_ERROR',
|
|
9
|
+
|
|
10
|
+
UNEXPECTED_OPERATION_STATE: 'UNEXPECTED_OPERATION_STATE',
|
|
11
|
+
UNEXPECTED_RESOURCE_TYPE: 'UNEXPECTED_RESOURCE_TYPE',
|
|
12
|
+
|
|
13
|
+
PROJECT_KEY_NOT_AVAILABLE: 'PROJECT_KEY_NOT_AVAILABLE',
|
|
14
|
+
|
|
15
|
+
NO_RESOURCES_TO_EXPORT: 'NO_RESOURCES_TO_EXPORT',
|
|
16
|
+
} as const
|
|
17
|
+
|
|
18
|
+
export type ErrorCodeType = (typeof ErrorCode)[keyof typeof ErrorCode]
|
|
19
|
+
|
|
20
|
+
export abstract class OperationsError extends Error {
|
|
21
|
+
abstract readonly code: ErrorCodeType
|
|
22
|
+
abstract readonly isRetryable: boolean
|
|
23
|
+
|
|
24
|
+
readonly timestamp: number
|
|
25
|
+
|
|
26
|
+
constructor(message: string) {
|
|
27
|
+
super(message)
|
|
28
|
+
this.timestamp = Date.now()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ErrorCode, type ErrorCodeType } from './base'
|
|
2
|
+
|
|
3
|
+
type ErrorWithCode = {
|
|
4
|
+
code: ErrorCodeType
|
|
5
|
+
isRetryable: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function hasErrorCode(error: unknown): error is ErrorWithCode {
|
|
9
|
+
return (
|
|
10
|
+
typeof error === 'object' &&
|
|
11
|
+
error !== null &&
|
|
12
|
+
'code' in error &&
|
|
13
|
+
typeof (error as ErrorWithCode).code === 'string'
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isOperationsError(error: unknown): error is ErrorWithCode {
|
|
18
|
+
return hasErrorCode(error)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isRetryableError(error: unknown): boolean {
|
|
22
|
+
return hasErrorCode(error) && error.isRetryable === true
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function isNetworkError(error: unknown): boolean {
|
|
26
|
+
return (
|
|
27
|
+
hasErrorCode(error) &&
|
|
28
|
+
(error.code === ErrorCode.HTTP_ERROR ||
|
|
29
|
+
error.code === ErrorCode.POLLING_TIMEOUT)
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function isPollingAbortedError(error: unknown): boolean {
|
|
34
|
+
return hasErrorCode(error) && error.code === ErrorCode.POLLING_ABORTED
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function isPollingTimeoutError(error: unknown): boolean {
|
|
38
|
+
return hasErrorCode(error) && error.code === ErrorCode.POLLING_TIMEOUT
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function isHttpError(error: unknown): boolean {
|
|
42
|
+
return hasErrorCode(error) && error.code === ErrorCode.HTTP_ERROR
|
|
43
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { BasicErrorDataType } from '../@types'
|
|
2
|
+
import { ErrorCode, OperationsError } from './base'
|
|
2
3
|
|
|
3
|
-
export class HttpError<T = BasicErrorDataType> extends
|
|
4
|
+
export class HttpError<T = BasicErrorDataType> extends OperationsError {
|
|
5
|
+
readonly code = ErrorCode.HTTP_ERROR
|
|
4
6
|
readonly statusCode: number
|
|
5
7
|
readonly errorData?: T
|
|
8
|
+
readonly isRetryable: boolean
|
|
6
9
|
|
|
7
10
|
constructor(statusCode: number, statusText?: string, errorData?: T) {
|
|
8
11
|
super(
|
|
@@ -13,5 +16,6 @@ export class HttpError<T = BasicErrorDataType> extends Error {
|
|
|
13
16
|
this.name = 'HttpError'
|
|
14
17
|
this.statusCode = statusCode
|
|
15
18
|
this.errorData = errorData
|
|
19
|
+
this.isRetryable = statusCode >= 500 || statusCode === 408
|
|
16
20
|
}
|
|
17
21
|
}
|
package/src/@errors/index.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
export * from './base'
|
|
2
|
+
export * from './guards'
|
|
1
3
|
export * from './http-error'
|
|
2
4
|
export * from './invalid-response-error'
|
|
3
5
|
export * from './no-resources-to-export-error'
|
|
4
6
|
export * from './polling-aborted-error'
|
|
7
|
+
export * from './polling-timeout-error'
|
|
5
8
|
export * from './project-key-not-available-error'
|
|
6
9
|
export * from './query-predicate-error'
|
|
7
10
|
export * from './unexpected-column-error'
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { ErrorCode, OperationsError } from './base'
|
|
2
|
+
|
|
3
|
+
export class InvalidResponseError extends OperationsError {
|
|
4
|
+
readonly code = ErrorCode.INVALID_RESPONSE
|
|
5
|
+
readonly isRetryable = false
|
|
6
|
+
|
|
2
7
|
constructor(message: string) {
|
|
3
8
|
super(message)
|
|
4
9
|
this.name = 'InvalidResponseError'
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { ErrorCode, OperationsError } from './base'
|
|
2
|
+
|
|
3
|
+
export class NoResourcesToExportError extends OperationsError {
|
|
4
|
+
readonly code = ErrorCode.NO_RESOURCES_TO_EXPORT
|
|
5
|
+
readonly isRetryable = false
|
|
6
|
+
|
|
2
7
|
constructor(message: string = 'There are no resources to export.') {
|
|
3
8
|
super(message)
|
|
4
9
|
this.name = 'NoResourcesToExportError'
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { ErrorCode, OperationsError } from './base'
|
|
2
|
+
|
|
3
|
+
export class PollingAbortedError extends OperationsError {
|
|
4
|
+
readonly code = ErrorCode.POLLING_ABORTED
|
|
5
|
+
readonly isRetryable = false
|
|
6
|
+
|
|
2
7
|
constructor() {
|
|
3
8
|
super('Polling was aborted')
|
|
4
9
|
this.name = 'PollingAbortedError'
|