@commercetools-frontend-extensions/operations 0.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.
Files changed (158) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +169 -0
  3. package/babel.config.js +6 -0
  4. package/dist/commercetools-frontend-extensions-operations.cjs.d.ts +2 -0
  5. package/dist/commercetools-frontend-extensions-operations.cjs.dev.js +2469 -0
  6. package/dist/commercetools-frontend-extensions-operations.cjs.js +7 -0
  7. package/dist/commercetools-frontend-extensions-operations.cjs.prod.js +2461 -0
  8. package/dist/commercetools-frontend-extensions-operations.esm.js +2316 -0
  9. package/dist/declarations/src/@api/export-operations.d.ts +5 -0
  10. package/dist/declarations/src/@api/fetcher.d.ts +17 -0
  11. package/dist/declarations/src/@api/file-upload.d.ts +3 -0
  12. package/dist/declarations/src/@api/import-containers.d.ts +35 -0
  13. package/dist/declarations/src/@api/import-operations.d.ts +6 -0
  14. package/dist/declarations/src/@api/index.d.ts +8 -0
  15. package/dist/declarations/src/@api/process-file.d.ts +3 -0
  16. package/dist/declarations/src/@api/test-fixtures.d.ts +272 -0
  17. package/dist/declarations/src/@api/urls.d.ts +44 -0
  18. package/dist/declarations/src/@components/file-drop-area/active-drag-drop-area.d.ts +10 -0
  19. package/dist/declarations/src/@components/file-drop-area/disabled-drop-area.d.ts +5 -0
  20. package/dist/declarations/src/@components/file-drop-area/drop-area-wrapper.d.ts +11 -0
  21. package/dist/declarations/src/@components/file-drop-area/enabled-drop-area.d.ts +7 -0
  22. package/dist/declarations/src/@components/file-drop-area/file-drop-area.d.ts +14 -0
  23. package/dist/declarations/src/@components/file-drop-area/file-dropped-area.d.ts +6 -0
  24. package/dist/declarations/src/@components/file-drop-area/index.d.ts +7 -0
  25. package/dist/declarations/src/@components/file-drop-area/styles.d.ts +9 -0
  26. package/dist/declarations/src/@components/icons/file-icon.d.ts +2 -0
  27. package/dist/declarations/src/@components/icons/index.d.ts +2 -0
  28. package/dist/declarations/src/@components/icons/lock-icon.d.ts +2 -0
  29. package/dist/declarations/src/@components/index.d.ts +6 -0
  30. package/dist/declarations/src/@components/info-box/index.d.ts +1 -0
  31. package/dist/declarations/src/@components/info-box/info-box.d.ts +7 -0
  32. package/dist/declarations/src/@components/upload-separator/index.d.ts +1 -0
  33. package/dist/declarations/src/@components/upload-separator/upload-separator.d.ts +12 -0
  34. package/dist/declarations/src/@components/upload-settings/index.d.ts +1 -0
  35. package/dist/declarations/src/@components/upload-settings/upload-settings.d.ts +11 -0
  36. package/dist/declarations/src/@components/uploading-modal/index.d.ts +1 -0
  37. package/dist/declarations/src/@components/uploading-modal/uploading-modal.d.ts +12 -0
  38. package/dist/declarations/src/@constants/delimiters.d.ts +8 -0
  39. package/dist/declarations/src/@constants/import-tags.d.ts +7 -0
  40. package/dist/declarations/src/@constants/index.d.ts +4 -0
  41. package/dist/declarations/src/@constants/resource-links.d.ts +10 -0
  42. package/dist/declarations/src/@constants/upload-limits.d.ts +10 -0
  43. package/dist/declarations/src/@errors/http-error.d.ts +6 -0
  44. package/dist/declarations/src/@errors/index.d.ts +8 -0
  45. package/dist/declarations/src/@errors/invalid-response-error.d.ts +3 -0
  46. package/dist/declarations/src/@errors/no-resources-to-export-error.d.ts +3 -0
  47. package/dist/declarations/src/@errors/project-key-not-available-error.d.ts +3 -0
  48. package/dist/declarations/src/@errors/query-predicate-error.d.ts +4 -0
  49. package/dist/declarations/src/@errors/unexpected-column-error.d.ts +3 -0
  50. package/dist/declarations/src/@errors/unexpected-operation-state-error.d.ts +4 -0
  51. package/dist/declarations/src/@errors/unexpected-resource-type-error.d.ts +3 -0
  52. package/dist/declarations/src/@hooks/index.d.ts +5 -0
  53. package/dist/declarations/src/@hooks/use-fetch-export-operations.d.ts +15 -0
  54. package/dist/declarations/src/@hooks/use-fetch-import-container-details.d.ts +15 -0
  55. package/dist/declarations/src/@hooks/use-fetch-import-operations.d.ts +16 -0
  56. package/dist/declarations/src/@hooks/use-fetch-import-summaries.d.ts +20 -0
  57. package/dist/declarations/src/@hooks/use-import-container-upload.d.ts +18 -0
  58. package/dist/declarations/src/@types/api.d.ts +13 -0
  59. package/dist/declarations/src/@types/basic-error-data-type.d.ts +5 -0
  60. package/dist/declarations/src/@types/export-operation.d.ts +95 -0
  61. package/dist/declarations/src/@types/file-upload.d.ts +63 -0
  62. package/dist/declarations/src/@types/import-container.d.ts +53 -0
  63. package/dist/declarations/src/@types/import-operation.d.ts +13 -0
  64. package/dist/declarations/src/@types/import-states.d.ts +9 -0
  65. package/dist/declarations/src/@types/import-summary.d.ts +15 -0
  66. package/dist/declarations/src/@types/index.d.ts +9 -0
  67. package/dist/declarations/src/@types/shared.d.ts +7 -0
  68. package/dist/declarations/src/@utils/error-mapping.d.ts +19 -0
  69. package/dist/declarations/src/@utils/file-upload.d.ts +46 -0
  70. package/dist/declarations/src/@utils/form.d.ts +1 -0
  71. package/dist/declarations/src/@utils/format.d.ts +5 -0
  72. package/dist/declarations/src/@utils/import-container.d.ts +8 -0
  73. package/dist/declarations/src/@utils/index.d.ts +6 -0
  74. package/dist/declarations/src/@utils/url.d.ts +6 -0
  75. package/dist/declarations/src/index.d.ts +26 -0
  76. package/index.js +1 -0
  77. package/jest.test.config.js +11 -0
  78. package/package.json +63 -0
  79. package/src/@api/export-operations.ts +26 -0
  80. package/src/@api/fetcher.spec.ts +51 -0
  81. package/src/@api/fetcher.ts +127 -0
  82. package/src/@api/file-upload.spec.ts +83 -0
  83. package/src/@api/file-upload.ts +46 -0
  84. package/src/@api/import-containers.ts +256 -0
  85. package/src/@api/import-operations.ts +33 -0
  86. package/src/@api/index.ts +8 -0
  87. package/src/@api/process-file.spec.ts +74 -0
  88. package/src/@api/process-file.ts +53 -0
  89. package/src/@api/test-fixtures.ts +772 -0
  90. package/src/@api/urls.ts +118 -0
  91. package/src/@components/file-drop-area/active-drag-drop-area.tsx +33 -0
  92. package/src/@components/file-drop-area/disabled-drop-area.tsx +17 -0
  93. package/src/@components/file-drop-area/drop-area-wrapper.tsx +38 -0
  94. package/src/@components/file-drop-area/enabled-drop-area.tsx +27 -0
  95. package/src/@components/file-drop-area/file-drop-area.tsx +74 -0
  96. package/src/@components/file-drop-area/file-dropped-area.tsx +29 -0
  97. package/src/@components/file-drop-area/index.ts +7 -0
  98. package/src/@components/file-drop-area/styles.ts +67 -0
  99. package/src/@components/icons/file-icon.tsx +30 -0
  100. package/src/@components/icons/index.ts +2 -0
  101. package/src/@components/icons/lock-icon.tsx +34 -0
  102. package/src/@components/index.ts +6 -0
  103. package/src/@components/info-box/index.ts +1 -0
  104. package/src/@components/info-box/info-box.tsx +23 -0
  105. package/src/@components/upload-separator/index.ts +1 -0
  106. package/src/@components/upload-separator/upload-separator.tsx +61 -0
  107. package/src/@components/upload-settings/index.ts +1 -0
  108. package/src/@components/upload-settings/upload-settings.tsx +36 -0
  109. package/src/@components/uploading-modal/index.ts +1 -0
  110. package/src/@components/uploading-modal/uploading-modal.tsx +64 -0
  111. package/src/@constants/delimiters.ts +14 -0
  112. package/src/@constants/import-tags.ts +9 -0
  113. package/src/@constants/index.ts +4 -0
  114. package/src/@constants/resource-links.ts +61 -0
  115. package/src/@constants/upload-limits.ts +11 -0
  116. package/src/@errors/http-error.ts +17 -0
  117. package/src/@errors/index.ts +8 -0
  118. package/src/@errors/invalid-response-error.ts +6 -0
  119. package/src/@errors/no-resources-to-export-error.ts +6 -0
  120. package/src/@errors/project-key-not-available-error.ts +6 -0
  121. package/src/@errors/query-predicate-error.ts +10 -0
  122. package/src/@errors/unexpected-column-error.ts +6 -0
  123. package/src/@errors/unexpected-operation-state-error.ts +8 -0
  124. package/src/@errors/unexpected-resource-type-error.ts +6 -0
  125. package/src/@hooks/index.ts +5 -0
  126. package/src/@hooks/messages.ts +11 -0
  127. package/src/@hooks/use-fetch-export-operations.ts +34 -0
  128. package/src/@hooks/use-fetch-import-container-details.ts +31 -0
  129. package/src/@hooks/use-fetch-import-operations.ts +42 -0
  130. package/src/@hooks/use-fetch-import-summaries.ts +47 -0
  131. package/src/@hooks/use-fetch.spec.ts +76 -0
  132. package/src/@hooks/use-fetch.ts +80 -0
  133. package/src/@hooks/use-import-container-upload.spec.ts +294 -0
  134. package/src/@hooks/use-import-container-upload.ts +126 -0
  135. package/src/@types/api.ts +14 -0
  136. package/src/@types/basic-error-data-type.ts +5 -0
  137. package/src/@types/export-operation.ts +144 -0
  138. package/src/@types/file-upload.ts +81 -0
  139. package/src/@types/import-container.ts +104 -0
  140. package/src/@types/import-operation.ts +31 -0
  141. package/src/@types/import-states.ts +9 -0
  142. package/src/@types/import-summary.ts +22 -0
  143. package/src/@types/index.ts +9 -0
  144. package/src/@types/shared.ts +52 -0
  145. package/src/@utils/error-mapping.spec.ts +126 -0
  146. package/src/@utils/error-mapping.ts +39 -0
  147. package/src/@utils/file-upload.spec.ts +151 -0
  148. package/src/@utils/file-upload.ts +150 -0
  149. package/src/@utils/form.ts +20 -0
  150. package/src/@utils/format.spec.ts +62 -0
  151. package/src/@utils/format.ts +53 -0
  152. package/src/@utils/import-container.spec.ts +26 -0
  153. package/src/@utils/import-container.ts +34 -0
  154. package/src/@utils/index.ts +6 -0
  155. package/src/@utils/url.spec.ts +75 -0
  156. package/src/@utils/url.ts +18 -0
  157. package/src/index.ts +27 -0
  158. package/tsconfig.json +9 -0
@@ -0,0 +1,2316 @@
1
+ import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
2
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
3
+ import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
4
+ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
5
+ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
6
+ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
7
+ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
8
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
9
+ import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
10
+ import { executeHttpClientRequest, buildApiUrl, createHttpClientOptions } from '@commercetools-frontend/application-shell';
11
+ import { oidcStorage } from '@commercetools-frontend/application-shell-connectors';
12
+ import _Reflect$construct from '@babel/runtime-corejs3/core-js-stable/reflect/construct';
13
+ import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
14
+ import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
15
+ import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
16
+ import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
17
+ import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
18
+ import _wrapNativeSuper from '@babel/runtime-corejs3/helpers/esm/wrapNativeSuper';
19
+ import { MC_API_PROXY_TARGETS } from '@commercetools-frontend/constants';
20
+ import _everyInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/every';
21
+ import { plural } from 'pluralize';
22
+ import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
23
+ import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
24
+ import _flatMapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/flat-map';
25
+ import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
26
+ import _Promise from '@babel/runtime-corejs3/core-js-stable/promise';
27
+ import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
28
+ import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
29
+ import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
30
+ import Papa from 'papaparse';
31
+ import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
32
+ import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
33
+ import _bindInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/bind';
34
+ import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
35
+ import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
36
+ import _URLSearchParams from '@babel/runtime-corejs3/core-js-stable/url-search-params';
37
+ import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
38
+ import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
39
+ import { Spacings, Text, Link, PaperclipIcon, Constraints, SecondaryButton, customProperties, ContentNotification, SelectField, CheckboxInput, ProgressBar } from '@commercetools-frontend/ui-kit';
40
+ import React from 'react';
41
+ import { jsxs, jsx } from 'react/jsx-runtime';
42
+ import { css } from '@emotion/react';
43
+ import _styled from '@emotion/styled/base';
44
+ import { useDropzone } from 'react-dropzone';
45
+ import { useIntl, defineMessages } from 'react-intl';
46
+ import { InfoDialog } from '@commercetools-frontend/application-components';
47
+ import _setInterval from '@babel/runtime-corejs3/core-js-stable/set-interval';
48
+ import { reportErrorToSentry } from '@commercetools-frontend/sentry';
49
+
50
+ 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)); }
51
+ function _isNativeReflectConstruct$7() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$7 = function () { return !!t; })(); }
52
+ let UnexpectedColumnError = /*#__PURE__*/function (_Error) {
53
+ function UnexpectedColumnError(columnName) {
54
+ var _this;
55
+ _classCallCheck(this, UnexpectedColumnError);
56
+ _this = _callSuper$7(this, UnexpectedColumnError, [`Unexpected column "${columnName}"`]);
57
+ _this.name = 'UnexpectedColumnError';
58
+ return _this;
59
+ }
60
+ _inherits(UnexpectedColumnError, _Error);
61
+ return _createClass(UnexpectedColumnError);
62
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
63
+
64
+ 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)); }
65
+ function _isNativeReflectConstruct$6() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$6 = function () { return !!t; })(); }
66
+ let UnexpectedOperationStateError = /*#__PURE__*/function (_Error) {
67
+ function UnexpectedOperationStateError(state) {
68
+ var _this;
69
+ _classCallCheck(this, UnexpectedOperationStateError);
70
+ _this = _callSuper$6(this, UnexpectedOperationStateError, [`Unexpected operation state "${state}"`]);
71
+ _this.name = 'UnexpectedOperationStateError';
72
+ return _this;
73
+ }
74
+ _inherits(UnexpectedOperationStateError, _Error);
75
+ return _createClass(UnexpectedOperationStateError);
76
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
77
+
78
+ 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)); }
79
+ function _isNativeReflectConstruct$5() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$5 = function () { return !!t; })(); }
80
+ let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
81
+ function UnexpectedResourceTypeError(resourceType) {
82
+ var _this;
83
+ _classCallCheck(this, UnexpectedResourceTypeError);
84
+ _this = _callSuper$5(this, UnexpectedResourceTypeError, [`Unexpected resource type "${resourceType}"`]);
85
+ _this.name = 'UnexpectedResourceTypeError';
86
+ return _this;
87
+ }
88
+ _inherits(UnexpectedResourceTypeError, _Error);
89
+ return _createClass(UnexpectedResourceTypeError);
90
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
91
+
92
+ 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)); }
93
+ function _isNativeReflectConstruct$4() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$4 = function () { return !!t; })(); }
94
+ let HttpError = /*#__PURE__*/function (_Error) {
95
+ function HttpError(statusCode, statusText, errorData) {
96
+ var _this;
97
+ _classCallCheck(this, HttpError);
98
+ _this = _callSuper$4(this, HttpError, [`HTTP Error! Status code: ${statusCode}, message: "${statusText ? statusText : ''}"`]);
99
+ _this.statusCode = void 0;
100
+ _this.errorData = void 0;
101
+ _this.name = 'HttpError';
102
+ _this.statusCode = statusCode;
103
+ _this.errorData = errorData;
104
+ return _this;
105
+ }
106
+ _inherits(HttpError, _Error);
107
+ return _createClass(HttpError);
108
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
109
+
110
+ 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)); }
111
+ function _isNativeReflectConstruct$3() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$3 = function () { return !!t; })(); }
112
+ let InvalidResponseError = /*#__PURE__*/function (_Error) {
113
+ function InvalidResponseError(message) {
114
+ var _this;
115
+ _classCallCheck(this, InvalidResponseError);
116
+ _this = _callSuper$3(this, InvalidResponseError, [message]);
117
+ _this.name = 'InvalidResponseError';
118
+ return _this;
119
+ }
120
+ _inherits(InvalidResponseError, _Error);
121
+ return _createClass(InvalidResponseError);
122
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
123
+
124
+ 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)); }
125
+ function _isNativeReflectConstruct$2() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$2 = function () { return !!t; })(); }
126
+ let QueryPredicateError = /*#__PURE__*/function (_Error) {
127
+ function QueryPredicateError() {
128
+ var _this;
129
+ let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'There is an error with the query predicate. Make sure the syntax is correct.';
130
+ _classCallCheck(this, QueryPredicateError);
131
+ _this = _callSuper$2(this, QueryPredicateError, [message]);
132
+ _this.field = 'queryPredicate';
133
+ _this.name = 'QueryPredicateError';
134
+ return _this;
135
+ }
136
+ _inherits(QueryPredicateError, _Error);
137
+ return _createClass(QueryPredicateError);
138
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
139
+
140
+ 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)); }
141
+ function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
142
+ let NoResourcesToExportError = /*#__PURE__*/function (_Error) {
143
+ function NoResourcesToExportError() {
144
+ var _this;
145
+ let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'There are no resources to export.';
146
+ _classCallCheck(this, NoResourcesToExportError);
147
+ _this = _callSuper$1(this, NoResourcesToExportError, [message]);
148
+ _this.name = 'NoResourcesToExportError';
149
+ return _this;
150
+ }
151
+ _inherits(NoResourcesToExportError, _Error);
152
+ return _createClass(NoResourcesToExportError);
153
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
154
+
155
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
156
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
157
+ let ProjectKeyNotAvailableError = /*#__PURE__*/function (_Error) {
158
+ function ProjectKeyNotAvailableError() {
159
+ var _this;
160
+ let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Project key is not available';
161
+ _classCallCheck(this, ProjectKeyNotAvailableError);
162
+ _this = _callSuper(this, ProjectKeyNotAvailableError, [message]);
163
+ _this.name = 'ProjectKeyNotAvailableError';
164
+ return _this;
165
+ }
166
+ _inherits(ProjectKeyNotAvailableError, _Error);
167
+ return _createClass(ProjectKeyNotAvailableError);
168
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
169
+
170
+ function ownKeys$8(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; }
171
+ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$8(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$8(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
172
+ const addProxyPrefixToUrl = (uri, proxy) => {
173
+ return proxy ? `/proxy/${proxy}${uri}` : uri;
174
+ };
175
+ const fetcher = async _ref => {
176
+ let url = _ref.url,
177
+ payload = _ref.payload,
178
+ config = _ref.config;
179
+ const data = await executeHttpClientRequest(async options => {
180
+ const res = await fetch(buildApiUrl(addProxyPrefixToUrl(url, config?.proxy)), _objectSpread$8(_objectSpread$8({}, options), {}, {
181
+ method: config?.method,
182
+ body: payload,
183
+ signal: config?.abortSignal
184
+ }));
185
+ if (!res.ok) {
186
+ const errorData = await res.json();
187
+ throw new HttpError(res.status, res.statusText, errorData);
188
+ }
189
+ const data = res.json();
190
+ return {
191
+ data,
192
+ statusCode: res.status,
193
+ getHeader: key => res.headers.get(key)
194
+ };
195
+ }, {
196
+ headers: _objectSpread$8({
197
+ 'Content-Type': 'application/json'
198
+ }, config?.headers)
199
+ });
200
+ return data;
201
+ };
202
+ const fetchUsingXhr = _ref2 => {
203
+ let url = _ref2.url,
204
+ payload = _ref2.payload,
205
+ config = _ref2.config,
206
+ onProgress = _ref2.onProgress,
207
+ onSuccess = _ref2.onSuccess,
208
+ onError = _ref2.onError;
209
+ const options = createHttpClientOptions({
210
+ headers: _objectSpread$8({
211
+ 'Content-Type': 'application/json'
212
+ }, config?.headers)
213
+ });
214
+ const xhr = new XMLHttpRequest();
215
+ xhr.open(config?.method, buildApiUrl(addProxyPrefixToUrl(url, config?.proxy)), true);
216
+ xhr.withCredentials = true;
217
+ if (options.headers) {
218
+ var _context;
219
+ _forEachInstanceProperty(_context = _Object$keys(options.headers)).call(_context, key => {
220
+ xhr.setRequestHeader(key, options.headers[key]);
221
+ });
222
+ }
223
+ xhr.upload.onprogress = function (event) {
224
+ if (event.lengthComputable) {
225
+ const percentComplete = event.loaded / event.total * 100;
226
+ onProgress(percentComplete);
227
+ }
228
+ };
229
+ const throwError = errorData => {
230
+ onError(new HttpError(xhr.status, xhr.statusText, errorData));
231
+ };
232
+ xhr.onload = function () {
233
+ const data = JSON.parse(xhr.responseText);
234
+ // Code copied from `executeHttpClientRequest` to replicate the same behavior
235
+ const refreshedSessionToken = xhr.getResponseHeader('x-refreshed-session-token');
236
+ if (refreshedSessionToken) {
237
+ oidcStorage.setActiveSession(refreshedSessionToken);
238
+ }
239
+ if (xhr.status >= 200 && xhr.status < 300) {
240
+ onSuccess(data);
241
+ } else {
242
+ throwError(data);
243
+ }
244
+ };
245
+ xhr.onerror = function () {
246
+ const errorData = JSON.parse(xhr.responseText);
247
+ throwError(errorData);
248
+ };
249
+ xhr.onabort = function () {
250
+ onError(new DOMException('Aborted', 'AbortError'));
251
+ };
252
+ xhr.send(payload);
253
+ return xhr;
254
+ };
255
+
256
+ function hasOwnProperty(obj, prop) {
257
+ return typeof obj === 'object' && obj !== null && obj.hasOwnProperty(prop);
258
+ }
259
+ function hasRequiredFields(maybeValidObject, requiredFields) {
260
+ return typeof maybeValidObject === 'object' && maybeValidObject !== null && _everyInstanceProperty(requiredFields).call(requiredFields, property => hasOwnProperty(maybeValidObject, property));
261
+ }
262
+ function getMissingRequiredFields(maybeValidObject, requiredFields) {
263
+ return typeof maybeValidObject === 'object' && maybeValidObject !== null && _filterInstanceProperty(requiredFields).call(requiredFields, property => !(property in maybeValidObject));
264
+ }
265
+ function isError(maybeError) {
266
+ if (maybeError instanceof Error) return true;
267
+ return false;
268
+ }
269
+ function isAbortError(error) {
270
+ return error instanceof DOMException && error.name === 'AbortError';
271
+ }
272
+ function isResourceType(maybeResourceType) {
273
+ return typeof maybeResourceType === 'string';
274
+ }
275
+ function assertResourceType(maybeResourceType) {
276
+ if (typeof maybeResourceType === 'string') return;
277
+ throw new Error(`Invalid value: ${maybeResourceType}`);
278
+ }
279
+
280
+ function assertPaginatedExportOperationResponse(maybePaginatedExportOperationResponseOrExportOperationsResponse) {
281
+ const requiredFields = ['results', 'total'];
282
+ if (hasRequiredFields(maybePaginatedExportOperationResponseOrExportOperationsResponse, requiredFields)) return;
283
+ throw new Error('Invalid response');
284
+ }
285
+ function assertExportOperationsDownloadFileResponse(maybeExportOperationDownloadFileResponse) {
286
+ const requiredFields = ['uri'];
287
+ if (hasRequiredFields(maybeExportOperationDownloadFileResponse, requiredFields)) return;
288
+ throw new Error('Invalid response');
289
+ }
290
+
291
+ function assertImportContainerPagedResponse(maybeImportContainerPagedResponse) {
292
+ const requiredFields = ['count', 'results'];
293
+ if (hasRequiredFields(maybeImportContainerPagedResponse, requiredFields)) return;
294
+ throw new Error('Invalid response');
295
+ }
296
+ function assertImportSummary(maybeImportSummary) {
297
+ const requiredFields = ['states', 'total'];
298
+ if (hasRequiredFields(maybeImportSummary, requiredFields)) return;
299
+ throw new Error('Invalid response');
300
+ }
301
+ function assertImportContainer(maybeImportContainerResponse) {
302
+ const requiredFields = ['key', 'version'];
303
+ if (hasRequiredFields(maybeImportContainerResponse, requiredFields)) return;
304
+ throw new Error('Invalid response');
305
+ }
306
+ function assertCancelContainerResponse(maybeCancelContainerResponse) {
307
+ if (typeof maybeCancelContainerResponse === 'object' && maybeCancelContainerResponse !== null) {
308
+ const responseData = maybeCancelContainerResponse;
309
+ if (typeof responseData.message === 'string') {
310
+ return;
311
+ }
312
+ }
313
+ throw new Error('Invalid response');
314
+ }
315
+
316
+ // Extended types to support settings that aren't in the base SDK yet
317
+
318
+ // TODO: Remove the temporarily extended ImportOperation when the SDK is updated
319
+
320
+ // TODO: Remove the temporarily extended ImportOperationPagedResponse when the SDK is updated
321
+
322
+ function assertImportOperationPagedResponse(maybeImportOperationPagedResponse) {
323
+ const requiredFields = ['count', 'total', 'results'];
324
+ if (hasRequiredFields(maybeImportOperationPagedResponse, requiredFields)) return;
325
+ throw new Error('Invalid response');
326
+ }
327
+
328
+ let ImportStates = /*#__PURE__*/function (ImportStates) {
329
+ ImportStates["Processing"] = "processing";
330
+ ImportStates["WaitForUnresolvedReferences"] = "wait-for-unresolved-references";
331
+ ImportStates["PartiallyCompleted"] = "partially-completed";
332
+ ImportStates["Failed"] = "failed";
333
+ ImportStates["SuccessfullyCompleted"] = "successfully-completed";
334
+ ImportStates["NoRunningImports"] = "no-running-imports";
335
+ ImportStates["Canceled"] = "canceled";
336
+ return ImportStates;
337
+ }({});
338
+
339
+ function ownKeys$7(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; }
340
+ 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(_context2 = ownKeys$7(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$7(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
341
+ function getFileUploadErrorsCount(errors) {
342
+ if (!errors || !_Array$isArray(errors)) return 0;
343
+ return _reduceInstanceProperty(errors).call(errors, (acc, curr) => acc += curr.errors.length, 0);
344
+ }
345
+ function mapUploadFileErrorsResponseToUploadFileErrorRows(uploadFileErrorsResponse) {
346
+ if (!uploadFileErrorsResponse || !_Array$isArray(uploadFileErrorsResponse)) return [];
347
+ let idCounter = 1;
348
+ return _flatMapInstanceProperty(uploadFileErrorsResponse).call(uploadFileErrorsResponse, rowErrorsResponse => {
349
+ var _context;
350
+ return _mapInstanceProperty(_context = rowErrorsResponse.errors).call(_context, rowError => _objectSpread$7(_objectSpread$7(_objectSpread$7({
351
+ id: String(idCounter++)
352
+ }, rowErrorsResponse.row !== undefined ? {
353
+ row: rowErrorsResponse.row
354
+ } : {}), rowErrorsResponse.index !== undefined ? {
355
+ index: rowErrorsResponse.index
356
+ } : {}), {}, {
357
+ field: rowError.field,
358
+ code: rowError.code,
359
+ validationMessage: rowError.message
360
+ }));
361
+ });
362
+ }
363
+
364
+ function ownKeys$6(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; }
365
+ function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$6(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$6(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
366
+
367
+ /**
368
+ * Convert megabytes to bytes
369
+ */
370
+ const toBytes = megabytes => megabytes * 1024 * 1024;
371
+
372
+ /**
373
+ * Returns the number of rows in a CSV file excluding the header
374
+ * @param file The CSV file to process
375
+ * @returns A promise that resolves to the number of rows
376
+ */
377
+ const getRowCount = file => {
378
+ return new _Promise(resolve => {
379
+ let lineCount = 0;
380
+ Papa.parse(file, {
381
+ step: _ref => {
382
+ let data = _ref.data;
383
+ // empty lines at the end of the file should not be counted
384
+ if (_Array$isArray(data) && _findInstanceProperty(data).call(data, Boolean)) lineCount++;
385
+ },
386
+ complete: () => {
387
+ // Subtract 1 for the header row
388
+ // We use Math.max to make sure the count is not less than 0, this is needed for empty files
389
+ resolve(Math.max(0, lineCount - 1));
390
+ }
391
+ });
392
+ });
393
+ };
394
+
395
+ /**
396
+ * Check if a CSV file has a single key column
397
+ * @param file The CSV file to check
398
+ * @returns A promise that resolves to true if the file has only one column named 'key'
399
+ */
400
+ const hasSingleKeyColumn = file => {
401
+ return new _Promise(resolve => {
402
+ Papa.parse(file, {
403
+ preview: 1,
404
+ complete: result => {
405
+ const headerRow = result.data?.[0];
406
+ const hasSingleColumn = _Array$isArray(headerRow) && headerRow.length === 1;
407
+ const isKeyColumn = hasSingleColumn && headerRow[0].toLowerCase() === 'key';
408
+ resolve(isKeyColumn);
409
+ }
410
+ });
411
+ });
412
+ };
413
+
414
+ /**
415
+ * Validate delimiter in a CSV file
416
+ * @param file The CSV file to validate
417
+ * @param allowedDelimiters Array of allowed delimiters
418
+ * @returns A promise that resolves to false if delimiter is invalid
419
+ */
420
+ const validateDelimiter = (file, allowedDelimiters) => {
421
+ // Delimiters not included in this array may be treated as part of a column content
422
+ // potentially causing the file to be parsed as a single-column CSV and pass this validation
423
+ const NON_ALLOWED_COLUMN_DELIMITERS = ['%', '.', ' '];
424
+ const DELIMITERS_TO_GUESS = [...allowedDelimiters, ...NON_ALLOWED_COLUMN_DELIMITERS];
425
+ return new _Promise(resolve => {
426
+ Papa.parse(file, {
427
+ delimitersToGuess: DELIMITERS_TO_GUESS,
428
+ preview: 10,
429
+ complete: result => {
430
+ const headerRow = result.data?.[0];
431
+ const isOnlyOneColumn = _Array$isArray(headerRow) && headerRow.length === 1;
432
+ if (isOnlyOneColumn) {
433
+ resolve(true);
434
+ return;
435
+ }
436
+ const detectedDelimiter = result.meta.delimiter;
437
+ let isValid = false;
438
+ if (detectedDelimiter !== null && _includesInstanceProperty(allowedDelimiters).call(allowedDelimiters, detectedDelimiter)) {
439
+ var _context;
440
+ const isUndetectableDelimiter = _someInstanceProperty(_context = result.errors).call(_context, error => error.code === 'UndetectableDelimiter');
441
+ if (!isUndetectableDelimiter) {
442
+ isValid = true;
443
+ }
444
+ }
445
+ resolve(isValid);
446
+ }
447
+ });
448
+ });
449
+ };
450
+
451
+ /**
452
+ * Returns columns from the provided `columns` excluding those specified in the `ignoredColumns`
453
+ */
454
+ const getValidatedColumns = (columns, ignoredColumns) => {
455
+ return _filterInstanceProperty(columns).call(columns, column => !_includesInstanceProperty(ignoredColumns).call(ignoredColumns, column));
456
+ };
457
+
458
+ /**
459
+ * Count items in a JSON file
460
+ * @param file The JSON file to process
461
+ * @returns Object with isValid flag and optional itemsCount
462
+ */
463
+ const countJsonFileItems = async file => {
464
+ const jsonContent = await file.text();
465
+ try {
466
+ const content = JSON.parse(jsonContent);
467
+ const isValid = _Array$isArray(content);
468
+ if (isValid) {
469
+ return {
470
+ isValid,
471
+ itemsCount: content.length
472
+ };
473
+ }
474
+ return {
475
+ isValid
476
+ };
477
+ } catch {
478
+ return {
479
+ isValid: false
480
+ };
481
+ }
482
+ };
483
+
484
+ /**
485
+ * Map file upload errors to upload file error rows with unique IDs
486
+ * @param uploadFileErrors Array of file upload errors
487
+ * @returns Array of upload file errors with unique id field
488
+ */
489
+ const mapFileUploadErrorsToUploadFileErrorRows = uploadFileErrors => {
490
+ let idCounter = 1;
491
+ return _mapInstanceProperty(uploadFileErrors).call(uploadFileErrors, uploadFileError => _objectSpread$6(_objectSpread$6({}, uploadFileError), {}, {
492
+ id: String(idCounter++)
493
+ }));
494
+ };
495
+
496
+ function ownKeys$5(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; }
497
+ 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(_context = ownKeys$5(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$5(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
498
+ const mapFormikErrors = error => {
499
+ if (typeof error === 'string') {
500
+ return {
501
+ [error]: true
502
+ };
503
+ }
504
+ if (_Array$isArray(error)) {
505
+ return _reduceInstanceProperty(error).call(error, (errorAggregator, currentError) => _objectSpread$5(_objectSpread$5({}, errorAggregator), {}, {
506
+ [currentError]: true
507
+ }), {});
508
+ }
509
+ if (!error) return {};
510
+ return error;
511
+ };
512
+
513
+ function formatErrorCode(code) {
514
+ try {
515
+ const formattedCode = code.replace(/([a-z])([A-Z])/g, '$1 $2').replace(/([A-Z])([A-Z][a-z])/g, '$1 $2').toLowerCase();
516
+ let result = formattedCode.charAt(0).toUpperCase() + _sliceInstanceProperty(formattedCode).call(formattedCode, 1);
517
+ const specialWords = ['json', 'api', 'http'];
518
+ _forEachInstanceProperty(specialWords).call(specialWords, word => {
519
+ const regex = new RegExp(`\\b${word}\\b`, 'gi');
520
+ result = result.replace(regex, word.toUpperCase());
521
+ });
522
+ return result;
523
+ } catch (error) {
524
+ return code;
525
+ }
526
+ }
527
+ function extractErrorDescriptionFromValidationMessage(message) {
528
+ return message.split('"').pop();
529
+ }
530
+ function formatKeys(obj) {
531
+ var _context;
532
+ let conjunction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'and';
533
+ if (typeof obj !== 'object' || obj === null) return '';
534
+ const keys = _mapInstanceProperty(_context = _Object$keys(obj)).call(_context, key => key.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase());
535
+ if (keys.length === 0) return '';
536
+ if (keys.length === 1) return keys[0];
537
+ return `${_sliceInstanceProperty(keys).call(keys, 0, -1).join(', ')} ${conjunction} ${keys[keys.length - 1]}`;
538
+ }
539
+ function appendCsvOrJsonExtensionIfAbsent(fileName, fileFormat) {
540
+ const extensionRegex = /\.(csv|json)$/i;
541
+ if (!extensionRegex.test(fileName)) return `${fileName}.${fileFormat}`;
542
+ return fileName;
543
+ }
544
+ function convertFileSizeToKB(sizeInBytes) {
545
+ return sizeInBytes / 1000;
546
+ }
547
+
548
+ const encodeFileNameWithTimestampToContainerKey = fileName => {
549
+ return btoa(_JSON$stringify({
550
+ timestamp: new Date().getTime(),
551
+ fileName
552
+ })).replace(/=+$/g, '');
553
+ };
554
+
555
+ /**
556
+ * Check if an import container is a file upload import
557
+ * @param tags - Array of tags from the import container
558
+ * @returns True if the tags indicate this is a file upload import
559
+ */
560
+ const checkIfFileUploadImport = tags => {
561
+ var _context, _context2;
562
+ return ((_context = tags) == null ? void 0 : _bindInstanceProperty(_context2 = Function.call).call(_context2, _someInstanceProperty(_context), _context))?.(tag => _startsWithInstanceProperty(tag).call(tag, 'source:file-upload')) ?? false;
563
+ };
564
+ const decodeFileNameFromImportContainerKey = importContainerKey => {
565
+ try {
566
+ const decodedImportContainerKey = atob(importContainerKey);
567
+ const importInfo = JSON.parse(decodedImportContainerKey);
568
+ return importInfo.fileName;
569
+ } catch {
570
+ return '';
571
+ }
572
+ };
573
+
574
+ /**
575
+ * Formats an object into a URL query string
576
+ * @param queryParams - Object containing query parameters
577
+ * @returns Formatted query string with leading '?' or empty string
578
+ */
579
+ function formatQueryString() {
580
+ let queryParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
581
+ const queryString = new _URLSearchParams();
582
+ for (const _ref of _Object$entries(queryParams)) {
583
+ var _ref2 = _slicedToArray(_ref, 2);
584
+ const key = _ref2[0];
585
+ const value = _ref2[1];
586
+ if (value !== undefined && value !== null) {
587
+ if (_Array$isArray(value)) {
588
+ _forEachInstanceProperty(value).call(value, v => queryString.append(key, String(v)));
589
+ } else {
590
+ queryString.append(key, String(value));
591
+ }
592
+ }
593
+ }
594
+ return queryString.toString() ? `?${queryString.toString()}` : '';
595
+ }
596
+
597
+ function getImportContainersURL(_ref) {
598
+ let projectKey = _ref.projectKey,
599
+ queryParams = _ref.queryParams;
600
+ const queryString = formatQueryString(queryParams);
601
+ return `/${projectKey}/import-containers${queryString}`;
602
+ }
603
+ function getImportOperationsURL(_ref2) {
604
+ let projectKey = _ref2.projectKey,
605
+ importContainerKey = _ref2.importContainerKey,
606
+ queryParams = _ref2.queryParams;
607
+ const queryString = formatQueryString(queryParams);
608
+ return `/${projectKey}/import-containers/${importContainerKey}/import-operations${queryString}&debug=true`;
609
+ }
610
+ function getImportContainerByKeyURL(_ref3) {
611
+ let projectKey = _ref3.projectKey,
612
+ importContainerKey = _ref3.importContainerKey;
613
+ return `/${projectKey}/import-containers/${importContainerKey}`;
614
+ }
615
+ function getCreateImportContainerURL(_ref4) {
616
+ let projectKey = _ref4.projectKey;
617
+ return `/${projectKey}/import-containers`;
618
+ }
619
+ function getImportContainerTasksURL(_ref5) {
620
+ let projectKey = _ref5.projectKey,
621
+ importContainerKey = _ref5.importContainerKey;
622
+ return `/${projectKey}/import-containers/${importContainerKey}/tasks`;
623
+ }
624
+ function getDeleteImportContainerURL(_ref6) {
625
+ let projectKey = _ref6.projectKey,
626
+ importContainerKey = _ref6.importContainerKey;
627
+ return `/${projectKey}/import-containers/${importContainerKey}`;
628
+ }
629
+ function getImportSummaryURL(_ref7) {
630
+ let projectKey = _ref7.projectKey,
631
+ importContainerKey = _ref7.importContainerKey;
632
+ return `/${projectKey}/import-containers/${importContainerKey}/import-summaries`;
633
+ }
634
+ function getFileUploadURL(_ref8) {
635
+ let projectKey = _ref8.projectKey,
636
+ resourceType = _ref8.resourceType,
637
+ importContainerKey = _ref8.importContainerKey;
638
+ return `/${projectKey}/${plural(resourceType)}/import-containers/${importContainerKey}/file-upload`;
639
+ }
640
+ function getProccessFileURL(_ref9) {
641
+ let projectKey = _ref9.projectKey,
642
+ resourceType = _ref9.resourceType,
643
+ importContainerKey = _ref9.importContainerKey;
644
+ return `/${projectKey}/${plural(resourceType)}/import-containers/${importContainerKey}/process-file`;
645
+ }
646
+ function getExportOperationsURL(_ref0) {
647
+ let projectKey = _ref0.projectKey,
648
+ queryParams = _ref0.queryParams;
649
+ const queryString = formatQueryString(queryParams);
650
+ return `/${projectKey}/export-operations${queryString}`;
651
+ }
652
+
653
+ function uploadFileForImport(_ref) {
654
+ let projectKey = _ref.projectKey,
655
+ importContainerKey = _ref.importContainerKey,
656
+ resourceType = _ref.resourceType,
657
+ file = _ref.file,
658
+ abortSignal = _ref.abortSignal,
659
+ onSuccess = _ref.onSuccess,
660
+ onProgress = _ref.onProgress,
661
+ onError = _ref.onError;
662
+ const uri = getFileUploadURL({
663
+ projectKey,
664
+ resourceType,
665
+ importContainerKey
666
+ });
667
+ const formData = new FormData();
668
+ formData.append('file', file, file.name);
669
+ return fetchUsingXhr({
670
+ url: uri,
671
+ payload: formData,
672
+ config: {
673
+ abortSignal,
674
+ proxy: MC_API_PROXY_TARGETS.IMPORT,
675
+ method: 'POST',
676
+ headers: {
677
+ 'Content-Type': null
678
+ }
679
+ },
680
+ onProgress,
681
+ onSuccess,
682
+ onError
683
+ });
684
+ }
685
+ function assertFileUploadResponse(maybeFileUploadResponse) {
686
+ const requiredFields = ['results', 'valid'];
687
+ if (hasRequiredFields(maybeFileUploadResponse, requiredFields)) return;
688
+ throw new Error('Invalid response');
689
+ }
690
+
691
+ function ownKeys$4(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; }
692
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$4(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$4(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
693
+ function getImportState(importSummary) {
694
+ const processing = importSummary.states.processing > 0;
695
+ if (processing) return ImportStates.Processing;
696
+ const waitForUnresolvedReferences = importSummary.states.waitForMasterVariant > 0 || importSummary.states.unresolved > 0;
697
+ if (waitForUnresolvedReferences) return ImportStates.WaitForUnresolvedReferences;
698
+ const partiallyCompleted = importSummary.states.imported > 0 && importSummary.states.imported < importSummary.total || importSummary.states.deleted > 0 && importSummary.states.deleted < importSummary.total;
699
+ if (partiallyCompleted) return ImportStates.PartiallyCompleted;
700
+ const noRunning = importSummary.total === 0;
701
+ if (noRunning) return ImportStates.NoRunningImports;
702
+ const successfullyCompleted = importSummary.states.imported === importSummary.total || importSummary.states.deleted === importSummary.total;
703
+ if (successfullyCompleted) return ImportStates.SuccessfullyCompleted;
704
+ const failed = importSummary.states.rejected + importSummary.states.validationFailed === importSummary.total;
705
+ if (failed) return ImportStates.Failed;
706
+ const canceled = importSummary.states.canceled > 0;
707
+ if (canceled) return ImportStates.Canceled;
708
+ throw new Error(`Unsupported state ${_JSON$stringify(importSummary.states)}`);
709
+ }
710
+ function createImportContainerForFileUpload(_ref) {
711
+ let importContainerDraft = _ref.importContainerDraft,
712
+ projectKey = _ref.projectKey;
713
+ return fetcher({
714
+ url: getCreateImportContainerURL({
715
+ projectKey
716
+ }),
717
+ payload: _JSON$stringify(_objectSpread$4({
718
+ retentionPolicy: {
719
+ strategy: 'ttl',
720
+ config: {
721
+ timeToLive: '54h' // 2 days and 6 hours
722
+ }
723
+ }
724
+ }, importContainerDraft)),
725
+ config: {
726
+ proxy: MC_API_PROXY_TARGETS.IMPORT,
727
+ method: 'POST',
728
+ headers: {
729
+ accept: 'application/json',
730
+ 'Content-Type': 'application/json'
731
+ }
732
+ }
733
+ });
734
+ }
735
+ function deleteImportContainer(_ref2) {
736
+ let projectKey = _ref2.projectKey,
737
+ importContainerKey = _ref2.importContainerKey;
738
+ return fetcher({
739
+ url: getDeleteImportContainerURL({
740
+ projectKey,
741
+ importContainerKey
742
+ }),
743
+ config: {
744
+ proxy: MC_API_PROXY_TARGETS.IMPORT,
745
+ method: 'DELETE',
746
+ headers: {
747
+ accept: 'application/json'
748
+ }
749
+ }
750
+ });
751
+ }
752
+ async function fetchImportSummary(_ref3) {
753
+ let projectKey = _ref3.projectKey,
754
+ importContainerKey = _ref3.importContainerKey;
755
+ const importSummary = await fetcher({
756
+ url: getImportSummaryURL({
757
+ projectKey,
758
+ importContainerKey
759
+ }),
760
+ config: {
761
+ proxy: MC_API_PROXY_TARGETS.IMPORT,
762
+ method: 'GET'
763
+ }
764
+ });
765
+ assertImportSummary(importSummary);
766
+ return importSummary;
767
+ }
768
+ async function fetchImportContainers(_ref4) {
769
+ let projectKey = _ref4.projectKey,
770
+ queryParams = _ref4.queryParams;
771
+ const importContainers = await fetcher({
772
+ url: getImportContainersURL({
773
+ projectKey,
774
+ queryParams
775
+ }),
776
+ config: {
777
+ proxy: MC_API_PROXY_TARGETS.IMPORT,
778
+ method: 'GET'
779
+ }
780
+ });
781
+ assertImportContainerPagedResponse(importContainers);
782
+ return importContainers;
783
+ }
784
+ async function fetchImportSummaries(_ref5) {
785
+ var _context;
786
+ let projectKey = _ref5.projectKey,
787
+ queryParams = _ref5.queryParams;
788
+ const importContainers = await fetchImportContainers({
789
+ projectKey,
790
+ queryParams
791
+ });
792
+ const results = _mapInstanceProperty(_context = importContainers.results).call(_context, async importContainer => {
793
+ return await importContainerToContainerDetails(projectKey, importContainer);
794
+ });
795
+ return {
796
+ results,
797
+ count: importContainers.count,
798
+ total: importContainers.total ?? 0,
799
+ queryParams: {
800
+ limit: importContainers.limit,
801
+ offset: importContainers.offset
802
+ }
803
+ };
804
+ }
805
+ async function fetchImportContainerDetails(_ref6) {
806
+ let projectKey = _ref6.projectKey,
807
+ importContainerKey = _ref6.importContainerKey;
808
+ const importContainer = await fetchImportContainerByKey({
809
+ projectKey,
810
+ importContainerKey
811
+ });
812
+ return await importContainerToContainerDetails(projectKey, importContainer);
813
+ }
814
+ async function fetchImportContainerByKey(_ref7) {
815
+ let projectKey = _ref7.projectKey,
816
+ importContainerKey = _ref7.importContainerKey;
817
+ const importContainer = await fetcher({
818
+ url: getImportContainerByKeyURL({
819
+ projectKey,
820
+ importContainerKey
821
+ }),
822
+ config: {
823
+ proxy: MC_API_PROXY_TARGETS.IMPORT,
824
+ method: 'GET'
825
+ }
826
+ });
827
+ assertImportContainer(importContainer);
828
+ return importContainer;
829
+ }
830
+ async function cancelImportContainerByKey(_ref8) {
831
+ let projectKey = _ref8.projectKey,
832
+ importContainerKey = _ref8.importContainerKey;
833
+ const response = await fetcher({
834
+ url: getImportContainerTasksURL({
835
+ projectKey,
836
+ importContainerKey
837
+ }),
838
+ payload: _JSON$stringify({
839
+ task: 'cancel'
840
+ }),
841
+ config: {
842
+ proxy: MC_API_PROXY_TARGETS.IMPORT,
843
+ method: 'POST'
844
+ }
845
+ });
846
+ assertCancelContainerResponse(response);
847
+ return response;
848
+ }
849
+ async function importContainerToContainerDetails(projectKey, importContainer) {
850
+ const importSummary = await fetchImportSummary({
851
+ projectKey,
852
+ importContainerKey: importContainer.key
853
+ });
854
+ const importState = getImportState(importSummary);
855
+ const isFileUploadImport = checkIfFileUploadImport(importContainer.tags);
856
+ return {
857
+ importContainer: importContainer,
858
+ importState,
859
+ importSummary,
860
+ isFileUploadImport
861
+ };
862
+ }
863
+
864
+ async function fetchImportOperations(_ref) {
865
+ let projectKey = _ref.projectKey,
866
+ importContainerKey = _ref.importContainerKey,
867
+ queryParams = _ref.queryParams;
868
+ const importOperations = await fetcher({
869
+ url: getImportOperationsURL({
870
+ projectKey,
871
+ importContainerKey,
872
+ queryParams
873
+ }),
874
+ config: {
875
+ proxy: MC_API_PROXY_TARGETS.IMPORT,
876
+ method: 'GET'
877
+ }
878
+ });
879
+ assertImportOperationPagedResponse(importOperations);
880
+ return importOperations;
881
+ }
882
+
883
+ async function fetchExportOperations(_ref) {
884
+ let projectKey = _ref.projectKey,
885
+ queryParams = _ref.queryParams;
886
+ const exportOperations = await fetcher({
887
+ url: getExportOperationsURL({
888
+ projectKey,
889
+ queryParams
890
+ }),
891
+ config: {
892
+ proxy: MC_API_PROXY_TARGETS.EXPORT,
893
+ method: 'GET'
894
+ }
895
+ });
896
+ assertPaginatedExportOperationResponse(exportOperations);
897
+ return exportOperations;
898
+ }
899
+
900
+ async function processUploadedFile(_ref) {
901
+ let projectKey = _ref.projectKey,
902
+ importContainerKey = _ref.importContainerKey,
903
+ resourceType = _ref.resourceType,
904
+ action = _ref.action;
905
+ // For delete operations with action (like 'delete') -> use different URL and payload structure
906
+ const uri = action ? getImportContainerTasksURL({
907
+ projectKey,
908
+ importContainerKey
909
+ }) : getProccessFileURL({
910
+ projectKey,
911
+ resourceType,
912
+ importContainerKey
913
+ });
914
+ const payload = action ? {
915
+ task: 'process-file',
916
+ parameter: {
917
+ resourceType,
918
+ action
919
+ }
920
+ } : {};
921
+ const response = await fetcher({
922
+ url: uri,
923
+ payload: _JSON$stringify(payload),
924
+ config: {
925
+ proxy: MC_API_PROXY_TARGETS.IMPORT,
926
+ method: 'POST',
927
+ headers: {
928
+ accept: 'application/json',
929
+ 'Content-Type': 'application/json'
930
+ }
931
+ }
932
+ });
933
+ assertProcessFileResponse(response);
934
+ return response;
935
+ }
936
+ function assertProcessFileResponse(maybeProcessFileResponse) {
937
+ const requiredFields = ['message'];
938
+ if (hasRequiredFields(maybeProcessFileResponse, requiredFields)) return;
939
+ throw new Error('Invalid response');
940
+ }
941
+
942
+ const DELIMITERS = {
943
+ COMMA: ',',
944
+ SEMICOLON: ';',
945
+ POINT: '.',
946
+ TAB: '\t',
947
+ PIPE: '|'
948
+ };
949
+ const COLUMN_DELIMITERS = [DELIMITERS.COMMA, DELIMITERS.SEMICOLON, DELIMITERS.PIPE, DELIMITERS.TAB];
950
+
951
+ const IMPORT_TAG_KEYS = {
952
+ source: 'source'
953
+ };
954
+ const IMPORT_TAG_VALUES = {
955
+ fileUpload: 'file-upload'
956
+ };
957
+ const TAG_KEY_SOURCE_FILE_UPLOAD = `${IMPORT_TAG_KEYS.source}:${IMPORT_TAG_VALUES.fileUpload}`;
958
+
959
+ /**
960
+ * CommerceTools API documentation base URL
961
+ */
962
+ const CT_API_DOCS_URL = 'https://docs.commercetools.com/api/';
963
+
964
+ /**
965
+ * Template download links for each resource type
966
+ */
967
+ const RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS = {
968
+ category: 'https://docs.commercetools.com/merchant-center/downloads/category_import_template.csv',
969
+ 'custom-object': 'https://docs.commercetools.com/merchant-center/downloads/custom_object_import_template.json',
970
+ product: 'https://docs.commercetools.com/merchant-center/import-data#download-a-template',
971
+ 'inventory-entry': 'https://docs.commercetools.com/merchant-center/downloads/inventory_entry_import_template.csv',
972
+ // TODO: remove `inventory` after aligning the resource type names in the Import API and Export API
973
+ inventory: 'https://docs.commercetools.com/merchant-center/downloads/inventory_entry_import_template.csv',
974
+ 'discount-code': 'https://docs.commercetools.com/merchant-center/downloads/discount_code_import_template.csv',
975
+ customer: 'https://docs.commercetools.com/merchant-center/import-data#download-a-template',
976
+ order: 'https://docs.commercetools.com/merchant-center/import-data#download-a-template',
977
+ 'product-type': 'https://docs.commercetools.com/merchant-center/downloads/product_type_import_template.csv',
978
+ 'business-unit': 'https://docs.commercetools.com/merchant-center/downloads/business_unit_import_template.csv'
979
+ };
980
+ const RESOURCE_TYPE_DOCUMENTATION_LINKS = {
981
+ category: 'https://docs.commercetools.com/merchant-center/import-categories#supported-headers-and-values',
982
+ 'custom-object': 'https://docs.commercetools.com/merchant-center/import-custom-objects#supported-fields-and-values',
983
+ product: 'https://docs.commercetools.com/merchant-center/import-products#supported-headers-and-values',
984
+ 'inventory-entry': 'https://docs.commercetools.com/merchant-center/import-inventory#supported-headers-and-values',
985
+ // TODO: remove `inventory` after aligning the resource type names in the Import API and Export API
986
+ inventory: 'https://docs.commercetools.com/merchant-center/import-inventory#supported-headers-and-values',
987
+ 'discount-code': 'https://docs.commercetools.com/merchant-center/import-discount-codes#supported-headers-and-values',
988
+ customer: 'https://docs.commercetools.com/merchant-center/import-customers#supported-headers-and-values',
989
+ order: 'https://docs.commercetools.com/merchant-center/import-orders#supported-headers-and-values',
990
+ 'product-type': 'https://docs.commercetools.com/merchant-center/import-product-types#supported-headers-and-values',
991
+ 'business-unit': 'https://docs.commercetools.com/merchant-center/import-business-units#supported-headers-and-values'
992
+ };
993
+
994
+ /**
995
+ * Maximum file size for imports.
996
+ * Recommended by backend, enforced in frontend validation.
997
+ */
998
+ const MAX_FILE_SIZE_MB = 35;
999
+
1000
+ /**
1001
+ * Maximum row count for imports.
1002
+ * Recommended by backend, enforced in frontend validation.
1003
+ */
1004
+ const MAX_ROW_COUNT = 80_000;
1005
+
1006
+ const automatedImportContainerKey = 'automated-container-key';
1007
+ const fileUploadImportContainerKey = 'eyJ0aW1lc3RhbXAiOiAxNzA1MDc0MzIxODY4LCAiZmlsZU5hbWUiOiAiZmlsZS11cGxvYWQtY29udGFpbmVyLWtleS5jc3YifQ';
1008
+ const manualImports = [{
1009
+ key: 'eyJ0aW1lc3RhbXAiOjE2MjE0MTM0NzU4MzcsImZpbGVOYW1lIjoiX3ZhbGlkLXByb2R1Y3QuY3N2IiwiaW1wb3J0VHlwZSI6Im1hbnVhbCJ9',
1010
+ version: 0,
1011
+ resourceType: 'product',
1012
+ createdAt: '2021-05-19T08:37:56.021Z',
1013
+ lastModifiedAt: '2021-05-19T08:37:56.021Z',
1014
+ tags: [TAG_KEY_SOURCE_FILE_UPLOAD]
1015
+ }, {
1016
+ key: 'eyJ0aW1lc3RhbXAiOjE2MjE0MTM3Mjc0ODksImZpbGVOYW1lIjoiX3ZhbGlkLWNhdGVnb3J5LmNzdiIsImltcG9ydFR5cGUiOiJtYW51YWwifQ',
1017
+ version: 0,
1018
+ resourceType: 'category',
1019
+ createdAt: '2021-05-19T08:42:07.720Z',
1020
+ lastModifiedAt: '2021-05-19T08:42:07.720Z',
1021
+ tags: [TAG_KEY_SOURCE_FILE_UPLOAD]
1022
+ }];
1023
+ const automatedImports = [{
1024
+ key: 'product-import-container',
1025
+ version: 0,
1026
+ resourceType: 'product',
1027
+ createdAt: '2021-04-06T06:41:33.622Z',
1028
+ lastModifiedAt: '2021-04-06T06:41:33.622Z',
1029
+ tags: []
1030
+ }, {
1031
+ key: 'product-import-container-1',
1032
+ version: 0,
1033
+ resourceType: 'product',
1034
+ createdAt: '2021-05-26T14:46:12.673Z',
1035
+ lastModifiedAt: '2021-05-26T14:46:12.673Z',
1036
+ tags: []
1037
+ }];
1038
+ const importContainers = {
1039
+ count: 4,
1040
+ total: 100,
1041
+ results: _concatInstanceProperty(manualImports).call(manualImports, automatedImports)
1042
+ };
1043
+ const importsSummaries = {
1044
+ eyJ0aW1lc3RhbXAiOjE2MjE0MTM0NzU4MzcsImZpbGVOYW1lIjoiX3ZhbGlkLXByb2R1Y3QuY3N2IiwiaW1wb3J0VHlwZSI6Im1hbnVhbCJ9: {
1045
+ states: {
1046
+ validationFailed: 0,
1047
+ unresolved: 3,
1048
+ waitForMasterVariant: 0,
1049
+ imported: 0,
1050
+ rejected: 0
1051
+ },
1052
+ total: 3
1053
+ },
1054
+ eyJ0aW1lc3RhbXAiOjE2MjE0MTM3Mjc0ODksImZpbGVOYW1lIjoiX3ZhbGlkLWNhdGVnb3J5LmNzdiIsImltcG9ydFR5cGUiOiJtYW51YWwifQ: {
1055
+ states: {
1056
+ validationFailed: 0,
1057
+ unresolved: 0,
1058
+ waitForMasterVariant: 0,
1059
+ imported: 0,
1060
+ rejected: 0
1061
+ },
1062
+ total: 0
1063
+ },
1064
+ 'product-import-container': {
1065
+ states: {
1066
+ validationFailed: 0,
1067
+ unresolved: 0,
1068
+ waitForMasterVariant: 0,
1069
+ imported: 0,
1070
+ rejected: 0
1071
+ },
1072
+ total: 0
1073
+ },
1074
+ 'product-import-container-1': {
1075
+ states: {
1076
+ validationFailed: 0,
1077
+ unresolved: 0,
1078
+ waitForMasterVariant: 0,
1079
+ imported: 0,
1080
+ rejected: 0
1081
+ },
1082
+ total: 0
1083
+ }
1084
+ };
1085
+ const importStatesMap = {
1086
+ [ImportStates.Processing]: [{
1087
+ states: {
1088
+ unresolved: 0,
1089
+ imported: 0,
1090
+ rejected: 0,
1091
+ validationFailed: 0,
1092
+ waitForMasterVariant: 0,
1093
+ processing: 10,
1094
+ canceled: 0,
1095
+ deleted: 0
1096
+ },
1097
+ total: 10
1098
+ }],
1099
+ [ImportStates.WaitForUnresolvedReferences]: [{
1100
+ states: {
1101
+ unresolved: 0,
1102
+ imported: 0,
1103
+ rejected: 0,
1104
+ validationFailed: 0,
1105
+ waitForMasterVariant: 10,
1106
+ processing: 0,
1107
+ canceled: 0,
1108
+ deleted: 0
1109
+ },
1110
+ total: 10
1111
+ }, {
1112
+ states: {
1113
+ unresolved: 10,
1114
+ imported: 0,
1115
+ rejected: 0,
1116
+ validationFailed: 0,
1117
+ waitForMasterVariant: 0,
1118
+ processing: 0,
1119
+ canceled: 0,
1120
+ deleted: 0
1121
+ },
1122
+ total: 10
1123
+ }, {
1124
+ states: {
1125
+ unresolved: 10,
1126
+ imported: 10,
1127
+ rejected: 10,
1128
+ validationFailed: 10,
1129
+ waitForMasterVariant: 0,
1130
+ processing: 0,
1131
+ canceled: 0,
1132
+ deleted: 0
1133
+ },
1134
+ total: 40
1135
+ }],
1136
+ [ImportStates.Failed]: [{
1137
+ states: {
1138
+ unresolved: 0,
1139
+ imported: 0,
1140
+ rejected: 4,
1141
+ validationFailed: 4,
1142
+ waitForMasterVariant: 0,
1143
+ processing: 0,
1144
+ canceled: 0,
1145
+ deleted: 0
1146
+ },
1147
+ total: 8
1148
+ }, {
1149
+ states: {
1150
+ unresolved: 0,
1151
+ imported: 0,
1152
+ rejected: 10,
1153
+ validationFailed: 0,
1154
+ waitForMasterVariant: 0,
1155
+ processing: 0,
1156
+ canceled: 0,
1157
+ deleted: 0
1158
+ },
1159
+ total: 10
1160
+ }, {
1161
+ states: {
1162
+ unresolved: 0,
1163
+ imported: 0,
1164
+ rejected: 0,
1165
+ validationFailed: 10,
1166
+ waitForMasterVariant: 0,
1167
+ processing: 0,
1168
+ canceled: 0,
1169
+ deleted: 0
1170
+ },
1171
+ total: 10
1172
+ }],
1173
+ [ImportStates.PartiallyCompleted]: [{
1174
+ states: {
1175
+ unresolved: 0,
1176
+ imported: 2,
1177
+ rejected: 1,
1178
+ validationFailed: 0,
1179
+ waitForMasterVariant: 0,
1180
+ processing: 0,
1181
+ canceled: 0,
1182
+ deleted: 0
1183
+ },
1184
+ total: 3
1185
+ }, {
1186
+ states: {
1187
+ unresolved: 0,
1188
+ imported: 10,
1189
+ rejected: 10,
1190
+ validationFailed: 10,
1191
+ waitForMasterVariant: 0,
1192
+ processing: 0,
1193
+ canceled: 0,
1194
+ deleted: 0
1195
+ },
1196
+ total: 30
1197
+ }],
1198
+ [ImportStates.SuccessfullyCompleted]: [{
1199
+ states: {
1200
+ unresolved: 0,
1201
+ imported: 20,
1202
+ rejected: 0,
1203
+ validationFailed: 0,
1204
+ waitForMasterVariant: 0,
1205
+ processing: 0,
1206
+ canceled: 0,
1207
+ deleted: 0
1208
+ },
1209
+ total: 20
1210
+ }, {
1211
+ states: {
1212
+ unresolved: 0,
1213
+ imported: 10,
1214
+ rejected: 0,
1215
+ validationFailed: 0,
1216
+ waitForMasterVariant: 0,
1217
+ processing: 0,
1218
+ canceled: 0,
1219
+ deleted: 0
1220
+ },
1221
+ total: 10
1222
+ }],
1223
+ [ImportStates.NoRunningImports]: [{
1224
+ states: {
1225
+ unresolved: 0,
1226
+ imported: 0,
1227
+ rejected: 0,
1228
+ validationFailed: 0,
1229
+ waitForMasterVariant: 0,
1230
+ processing: 0,
1231
+ canceled: 0,
1232
+ deleted: 0
1233
+ },
1234
+ total: 0
1235
+ }],
1236
+ [ImportStates.Canceled]: [{
1237
+ states: {
1238
+ unresolved: 0,
1239
+ imported: 0,
1240
+ rejected: 0,
1241
+ validationFailed: 0,
1242
+ waitForMasterVariant: 0,
1243
+ processing: 0,
1244
+ canceled: 10,
1245
+ deleted: 0
1246
+ },
1247
+ total: 10
1248
+ }]
1249
+ };
1250
+ const validFileUploadResponse = {
1251
+ results: [],
1252
+ invalid: 0,
1253
+ valid: 2,
1254
+ fileName: 'categories.csv',
1255
+ itemsCount: 2,
1256
+ rowsCount: 2,
1257
+ columnsCount: 11,
1258
+ columns: ['id', 'lastModifiedAt', 'key', 'name.en', 'name.de', 'slug.en', 'slug.de', 'orderHint', 'externalId', 'description.en', 'description.de'],
1259
+ ignoredColumns: ['id', 'lastModifiedAt']
1260
+ };
1261
+ const invalidFileUploadResponse = {
1262
+ invalid: 2,
1263
+ valid: 0,
1264
+ fileName: 'categories.csv',
1265
+ itemsCount: 2,
1266
+ rowsCount: 2,
1267
+ columnsCount: 11,
1268
+ columns: ['key', 'externalId2', 'orderHint', 'name.de2', 'description.de2', 'slug.RU', 'name.enn', 'description.en', 'slug.RU', 'test1', 'test2'],
1269
+ ignoredColumns: [],
1270
+ results: [{
1271
+ row: 1,
1272
+ errors: [{
1273
+ code: 'InvalidField',
1274
+ message: '"externalId2" is not allowed',
1275
+ field: 'externalId2'
1276
+ }, {
1277
+ code: 'InvalidField',
1278
+ message: '"name.de2" is not allowed',
1279
+ field: 'name.de2'
1280
+ }, {
1281
+ code: 'InvalidField',
1282
+ message: '"name.enn" is not allowed',
1283
+ field: 'name.enn'
1284
+ }, {
1285
+ code: 'InvalidField',
1286
+ message: '"slug.RU" is not allowed',
1287
+ field: 'slug.RU'
1288
+ }, {
1289
+ code: 'InvalidField',
1290
+ message: '"test1" is not allowed',
1291
+ field: 'test1'
1292
+ }, {
1293
+ code: 'InvalidField',
1294
+ message: '"test2" is not allowed',
1295
+ field: 'test2'
1296
+ }]
1297
+ }]
1298
+ };
1299
+ const allAutomatedImportOperations = [{
1300
+ version: 1,
1301
+ importContainerKey: automatedImportContainerKey,
1302
+ resourceKey: 'sample-3',
1303
+ id: 'fcbdb268-6bf0-4161-82ae-5bcd2c0ca1c3',
1304
+ state: 'ValidationFailed',
1305
+ errors: [{
1306
+ code: 'InvalidOperation',
1307
+ message: "The attributes contain definitions with duplicate names: '[product-ref-attribute]'."
1308
+ }],
1309
+ createdAt: '2021-08-03T10:13:52.867Z',
1310
+ lastModifiedAt: '2021-08-03T10:13:53.031Z',
1311
+ expiresAt: '2021-08-05T10:13:52.867Z'
1312
+ }, {
1313
+ version: 1,
1314
+ importContainerKey: automatedImportContainerKey,
1315
+ resourceKey: 'sample-2',
1316
+ id: 'c350f282-af46-44bd-b7fb-7767fe060b5d',
1317
+ state: 'imported',
1318
+ resourceVersion: 1,
1319
+ errors: [],
1320
+ createdAt: '2021-08-03T10:13:10.544Z',
1321
+ lastModifiedAt: '2021-08-03T10:13:11.056Z',
1322
+ expiresAt: '2021-08-05T10:13:10.544Z'
1323
+ }, {
1324
+ version: 1,
1325
+ importContainerKey: automatedImportContainerKey,
1326
+ resourceKey: 'sample',
1327
+ id: '50e01254-842a-4a94-9dc5-bd5d907a96f3',
1328
+ state: 'imported',
1329
+ resourceVersion: 1,
1330
+ errors: [],
1331
+ createdAt: '2021-08-03T10:12:16.293Z',
1332
+ lastModifiedAt: '2021-08-03T10:12:16.352Z',
1333
+ expiresAt: '2021-08-05T10:12:16.293Z'
1334
+ }, {
1335
+ version: 1,
1336
+ importContainerKey: automatedImportContainerKey,
1337
+ resourceKey: 'sample',
1338
+ id: '5679b11b-e6b2-44e3-bb32-feec7ee4295f',
1339
+ state: 'imported',
1340
+ resourceVersion: 1,
1341
+ errors: [],
1342
+ createdAt: '2021-08-03T10:12:13.955Z',
1343
+ lastModifiedAt: '2021-08-03T10:12:14.019Z',
1344
+ expiresAt: '2021-08-05T10:12:13.955Z'
1345
+ }, {
1346
+ version: 1,
1347
+ importContainerKey: automatedImportContainerKey,
1348
+ resourceKey: 'sample',
1349
+ id: '8ed41629-9e00-4779-abd7-ca054102690e',
1350
+ state: 'imported',
1351
+ resourceVersion: 1,
1352
+ errors: [],
1353
+ createdAt: '2021-08-03T10:12:07.214Z',
1354
+ lastModifiedAt: '2021-08-03T10:12:07.364Z',
1355
+ expiresAt: '2021-08-05T10:12:07.214Z'
1356
+ }, {
1357
+ version: 3,
1358
+ importContainerKey: automatedImportContainerKey,
1359
+ resourceKey: 'product-draft-key',
1360
+ id: '3f4d0fb6-95c0-444b-8e25-dbe1d6f25a54',
1361
+ state: 'imported',
1362
+ resourceVersion: 1,
1363
+ errors: [],
1364
+ createdAt: '2021-08-02T12:25:17.465Z',
1365
+ lastModifiedAt: '2021-08-02T12:25:34.673Z',
1366
+ expiresAt: '2021-08-04T12:25:17.465Z'
1367
+ }, {
1368
+ version: 3,
1369
+ importContainerKey: automatedImportContainerKey,
1370
+ resourceKey: 'product-draft-key',
1371
+ id: 'b3e4e438-3afd-46ed-929c-761286b839b4',
1372
+ state: 'imported',
1373
+ resourceVersion: 1,
1374
+ errors: [],
1375
+ createdAt: '2021-08-02T12:25:20.019Z',
1376
+ lastModifiedAt: '2021-08-02T12:25:34.657Z',
1377
+ expiresAt: '2021-08-04T12:25:20.019Z'
1378
+ }, {
1379
+ version: 3,
1380
+ importContainerKey: automatedImportContainerKey,
1381
+ resourceKey: 'product-draft-key',
1382
+ id: '8991ee30-2ad0-4e95-b784-e26e7672b49d',
1383
+ state: 'imported',
1384
+ resourceVersion: 1,
1385
+ errors: [],
1386
+ createdAt: '2021-08-02T12:25:20.454Z',
1387
+ lastModifiedAt: '2021-08-02T12:25:34.629Z',
1388
+ expiresAt: '2021-08-04T12:25:20.454Z'
1389
+ }, {
1390
+ version: 3,
1391
+ importContainerKey: automatedImportContainerKey,
1392
+ resourceKey: 'product-draft-key',
1393
+ id: 'd0a97b14-2927-414e-ae66-d20a27048418',
1394
+ state: 'imported',
1395
+ resourceVersion: 1,
1396
+ errors: [],
1397
+ createdAt: '2021-08-02T12:25:21.108Z',
1398
+ lastModifiedAt: '2021-08-02T12:25:34.570Z',
1399
+ expiresAt: '2021-08-04T12:25:21.108Z'
1400
+ }, {
1401
+ version: 1,
1402
+ importContainerKey: automatedImportContainerKey,
1403
+ resourceKey: 'sample',
1404
+ id: '702fbe9e-81c2-4daf-abd9-4c3f10ed9431',
1405
+ state: 'imported',
1406
+ resourceVersion: 1,
1407
+ errors: [],
1408
+ createdAt: '2021-08-02T12:25:27.585Z',
1409
+ lastModifiedAt: '2021-08-02T12:25:32.802Z',
1410
+ expiresAt: '2021-08-04T12:25:27.585Z'
1411
+ }];
1412
+ const successfulFileUploadImportOperations = [{
1413
+ version: 1,
1414
+ importContainerKey: fileUploadImportContainerKey,
1415
+ resourceKey: 'sample-2',
1416
+ id: 'c350f282-af46-44bd-b7fb-7767fe060b5d',
1417
+ state: 'imported',
1418
+ resourceVersion: 1,
1419
+ errors: [],
1420
+ createdAt: '2021-08-03T10:13:10.544Z',
1421
+ lastModifiedAt: '2021-08-03T10:13:11.056Z',
1422
+ expiresAt: '2021-08-05T10:13:10.544Z',
1423
+ tags: ['rowStartNumber:1']
1424
+ }];
1425
+ const allFileUploadImportOperations = [{
1426
+ version: 1,
1427
+ importContainerKey: fileUploadImportContainerKey,
1428
+ resourceKey: 'sample-3',
1429
+ id: 'fcbdb268-6bf0-4161-82ae-5bcd2c0ca1c3',
1430
+ state: 'ValidationFailed',
1431
+ errors: [{
1432
+ code: 'InvalidOperation',
1433
+ message: "The attributes contain definitions with duplicate names: '[product-ref-attribute]'."
1434
+ }],
1435
+ createdAt: '2021-08-03T10:13:52.867Z',
1436
+ lastModifiedAt: '2021-08-03T10:13:53.031Z',
1437
+ expiresAt: '2021-08-05T10:13:52.867Z',
1438
+ tags: ['rowStartNumber:1']
1439
+ }, {
1440
+ version: 1,
1441
+ importContainerKey: fileUploadImportContainerKey,
1442
+ resourceKey: 'sample-2',
1443
+ id: 'c350f282-af46-44bd-b7fb-7767fe060b5d',
1444
+ state: 'imported',
1445
+ resourceVersion: 1,
1446
+ errors: [],
1447
+ createdAt: '2021-08-03T10:13:10.544Z',
1448
+ lastModifiedAt: '2021-08-03T10:13:11.056Z',
1449
+ expiresAt: '2021-08-05T10:13:10.544Z',
1450
+ tags: ['rowStartNumber:2']
1451
+ }, {
1452
+ version: 1,
1453
+ importContainerKey: fileUploadImportContainerKey,
1454
+ resourceKey: 'sample',
1455
+ id: '50e01254-842a-4a94-9dc5-bd5d907a96f3',
1456
+ state: 'imported',
1457
+ resourceVersion: 1,
1458
+ errors: [],
1459
+ createdAt: '2021-08-03T10:12:16.293Z',
1460
+ lastModifiedAt: '2021-08-03T10:12:16.352Z',
1461
+ expiresAt: '2021-08-05T10:12:16.293Z',
1462
+ tags: ['rowStartNumber:3']
1463
+ }, {
1464
+ version: 1,
1465
+ importContainerKey: fileUploadImportContainerKey,
1466
+ resourceKey: 'sample',
1467
+ id: '5679b11b-e6b2-44e3-bb32-feec7ee4295f',
1468
+ state: 'imported',
1469
+ resourceVersion: 1,
1470
+ errors: [],
1471
+ createdAt: '2021-08-03T10:12:13.955Z',
1472
+ lastModifiedAt: '2021-08-03T10:12:14.019Z',
1473
+ expiresAt: '2021-08-05T10:12:13.955Z',
1474
+ tags: ['rowStartNumber:4']
1475
+ }, {
1476
+ version: 1,
1477
+ importContainerKey: fileUploadImportContainerKey,
1478
+ resourceKey: 'sample',
1479
+ id: '8ed41629-9e00-4779-abd7-ca054102690e',
1480
+ state: 'imported',
1481
+ resourceVersion: 1,
1482
+ errors: [],
1483
+ createdAt: '2021-08-03T10:12:07.214Z',
1484
+ lastModifiedAt: '2021-08-03T10:12:07.364Z',
1485
+ expiresAt: '2021-08-05T10:12:07.214Z',
1486
+ tags: ['rowStartNumber:5']
1487
+ }, {
1488
+ version: 3,
1489
+ importContainerKey: fileUploadImportContainerKey,
1490
+ resourceKey: 'product-draft-key',
1491
+ id: '3f4d0fb6-95c0-444b-8e25-dbe1d6f25a54',
1492
+ state: 'imported',
1493
+ resourceVersion: 1,
1494
+ errors: [],
1495
+ createdAt: '2021-08-02T12:25:17.465Z',
1496
+ lastModifiedAt: '2021-08-02T12:25:34.673Z',
1497
+ expiresAt: '2021-08-04T12:25:17.465Z',
1498
+ tags: ['rowStartNumber:6']
1499
+ }, {
1500
+ version: 3,
1501
+ importContainerKey: fileUploadImportContainerKey,
1502
+ resourceKey: 'product-draft-key',
1503
+ id: 'b3e4e438-3afd-46ed-929c-761286b839b4',
1504
+ state: 'imported',
1505
+ resourceVersion: 1,
1506
+ errors: [],
1507
+ createdAt: '2021-08-02T12:25:20.019Z',
1508
+ lastModifiedAt: '2021-08-02T12:25:34.657Z',
1509
+ expiresAt: '2021-08-04T12:25:20.019Z',
1510
+ tags: ['rowStartNumber:7']
1511
+ }, {
1512
+ version: 3,
1513
+ importContainerKey: fileUploadImportContainerKey,
1514
+ resourceKey: 'product-draft-key',
1515
+ id: '8991ee30-2ad0-4e95-b784-e26e7672b49d',
1516
+ state: 'imported',
1517
+ resourceVersion: 1,
1518
+ errors: [],
1519
+ createdAt: '2021-08-02T12:25:20.454Z',
1520
+ lastModifiedAt: '2021-08-02T12:25:34.629Z',
1521
+ expiresAt: '2021-08-04T12:25:20.454Z',
1522
+ tags: ['rowStartNumber:8']
1523
+ }, {
1524
+ version: 3,
1525
+ importContainerKey: fileUploadImportContainerKey,
1526
+ resourceKey: 'product-draft-key',
1527
+ id: 'd0a97b14-2927-414e-ae66-d20a27048418',
1528
+ state: 'imported',
1529
+ resourceVersion: 1,
1530
+ errors: [],
1531
+ createdAt: '2021-08-02T12:25:21.108Z',
1532
+ lastModifiedAt: '2021-08-02T12:25:34.570Z',
1533
+ expiresAt: '2021-08-04T12:25:21.108Z',
1534
+ tags: ['rowStartNumber:9']
1535
+ }, {
1536
+ version: 1,
1537
+ importContainerKey: fileUploadImportContainerKey,
1538
+ resourceKey: 'sample',
1539
+ id: '702fbe9e-81c2-4daf-abd9-4c3f10ed9431',
1540
+ state: 'imported',
1541
+ resourceVersion: 1,
1542
+ errors: [],
1543
+ createdAt: '2021-08-02T12:25:27.585Z',
1544
+ lastModifiedAt: '2021-08-02T12:25:32.802Z',
1545
+ expiresAt: '2021-08-04T12:25:27.585Z',
1546
+ tags: ['rowStartNumber:10']
1547
+ }];
1548
+ const allFileUploadImportOperationsResponse = {
1549
+ limit: 20,
1550
+ offset: 0,
1551
+ count: 10,
1552
+ total: 10,
1553
+ results: allFileUploadImportOperations
1554
+ };
1555
+ const allAutomatedImportOperationsResponse = {
1556
+ limit: 20,
1557
+ offset: 0,
1558
+ count: 10,
1559
+ total: 10,
1560
+ results: allAutomatedImportOperations
1561
+ };
1562
+ const successfulAutomatedImportOperations = [{
1563
+ version: 1,
1564
+ importContainerKey: automatedImportContainerKey,
1565
+ resourceKey: 'sample-2',
1566
+ id: 'c350f282-af46-44bd-b7fb-7767fe060b5d',
1567
+ state: 'imported',
1568
+ resourceVersion: 1,
1569
+ errors: [],
1570
+ createdAt: '2021-08-03T10:13:10.544Z',
1571
+ lastModifiedAt: '2021-08-03T10:13:11.056Z',
1572
+ expiresAt: '2021-08-05T10:13:10.544Z'
1573
+ }];
1574
+ const successfulAutomatedImportOperationsResponse = {
1575
+ limit: 1,
1576
+ offset: 0,
1577
+ count: 1,
1578
+ total: 1,
1579
+ results: successfulAutomatedImportOperations
1580
+ };
1581
+ const successfulFileUploadImportOperationsResponse = {
1582
+ limit: 1,
1583
+ offset: 0,
1584
+ count: 1,
1585
+ total: 1,
1586
+ results: successfulFileUploadImportOperations
1587
+ };
1588
+ const fileUploadMissingKeysResponse = {
1589
+ code: 'MissingCsvFieldIdentifier',
1590
+ message: 'Importing a new field without an identifier is not allowed',
1591
+ rowValue: {
1592
+ uri: 'http://example.com/asset-source-without-key',
1593
+ key: undefined
1594
+ },
1595
+ metadata: {
1596
+ row: 1
1597
+ }
1598
+ };
1599
+ const validProcessFileResponse = {
1600
+ message: 'acknowledged'
1601
+ };
1602
+ const exportOperationsCompleted = [{
1603
+ id: '10df6fe9252eeb1d54485795',
1604
+ fileName: 'test-12345.json',
1605
+ fileFormat: 'json',
1606
+ resourceType: 'category',
1607
+ createdAt: '2023-04-01T12:00:00.000Z',
1608
+ state: 'completed',
1609
+ query: 'query ExportCategories { categories { id } }',
1610
+ completedPercentage: 100,
1611
+ resourceCount: 100,
1612
+ fields: ['id'],
1613
+ locales: ['en']
1614
+ }, {
1615
+ id: '10df6fe9252eeb1d54485796',
1616
+ fileName: 'test-123456.csv',
1617
+ fileFormat: 'csv',
1618
+ resourceType: 'category',
1619
+ createdAt: '2023-04-02T12:00:00.000Z',
1620
+ state: 'completed',
1621
+ query: 'query ExportCategories { categories { id } }',
1622
+ completedPercentage: 100,
1623
+ resourceCount: 100,
1624
+ fields: ['id'],
1625
+ locales: ['en']
1626
+ }];
1627
+ const exportOperationsProcessing = [{
1628
+ id: '10df6fe9252eeb1d54485797',
1629
+ fileName: 'test-1234567.json',
1630
+ fileFormat: 'json',
1631
+ resourceType: 'category',
1632
+ createdAt: '2023-04-01T12:00:00.000Z',
1633
+ state: 'processing',
1634
+ query: 'query ExportCategories { categories { id } }',
1635
+ completedPercentage: 50,
1636
+ resourceCount: 100,
1637
+ fields: ['id'],
1638
+ locales: ['en']
1639
+ }, {
1640
+ id: '10df6fe9252eeb1d54485798',
1641
+ fileName: 'test-12345678.csv',
1642
+ fileFormat: 'csv',
1643
+ resourceType: 'category',
1644
+ createdAt: '2023-04-02T12:00:00.000Z',
1645
+ state: 'processing',
1646
+ query: 'query ExportCategories { categories { id } }',
1647
+ completedPercentage: 33,
1648
+ resourceCount: 100,
1649
+ fields: ['id'],
1650
+ locales: ['en']
1651
+ }];
1652
+
1653
+ function ownKeys$3(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; }
1654
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$3(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$3(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1655
+ const FileIcon = props => /*#__PURE__*/jsxs("svg", _objectSpread$3(_objectSpread$3({
1656
+ width: "32",
1657
+ height: "32",
1658
+ viewBox: "0 0 32 32",
1659
+ fill: "none",
1660
+ xmlns: "http://www.w3.org/2000/svg"
1661
+ }, props), {}, {
1662
+ children: [/*#__PURE__*/jsx("mask", {
1663
+ id: "mask0_17_6643",
1664
+ style: {
1665
+ maskType: 'alpha'
1666
+ },
1667
+ maskUnits: "userSpaceOnUse",
1668
+ x: "0",
1669
+ y: "0",
1670
+ width: "32",
1671
+ height: "32",
1672
+ children: /*#__PURE__*/jsx("rect", {
1673
+ width: "32",
1674
+ height: "32",
1675
+ fill: "#D9D9D9"
1676
+ })
1677
+ }), /*#__PURE__*/jsx("g", {
1678
+ mask: "url(#mask0_17_6643)",
1679
+ children: /*#__PURE__*/jsx("path", {
1680
+ d: "M14.6667 25.3333H17.3333V19.7667L19.4667 21.9L21.3333 20L16 14.6667L10.6667 20L12.5667 21.8667L14.6667 19.7667V25.3333ZM8 29.3333C7.26667 29.3333 6.63889 29.0722 6.11667 28.55C5.59444 28.0278 5.33333 27.4 5.33333 26.6667V5.33332C5.33333 4.59999 5.59444 3.97221 6.11667 3.44999C6.63889 2.92777 7.26667 2.66666 8 2.66666H18.6667L26.6667 10.6667V26.6667C26.6667 27.4 26.4056 28.0278 25.8833 28.55C25.3611 29.0722 24.7333 29.3333 24 29.3333H8ZM17.3333 12H24L17.3333 5.33332V12Z",
1681
+ fill: "#B1ACFF"
1682
+ })
1683
+ })]
1684
+ }));
1685
+
1686
+ const EnabledDropArea = _ref => {
1687
+ let dragAndDropText = _ref.dragAndDropText,
1688
+ orText = _ref.orText,
1689
+ browseFileText = _ref.browseFileText;
1690
+ return /*#__PURE__*/jsxs(Spacings.Inline, {
1691
+ alignItems: "center",
1692
+ justifyContent: "center",
1693
+ scale: "s",
1694
+ children: [/*#__PURE__*/jsx(FileIcon, {}), /*#__PURE__*/jsxs(Spacings.Inline, {
1695
+ alignItems: "center",
1696
+ scale: "s",
1697
+ children: [/*#__PURE__*/jsx(Text.Subheadline, {
1698
+ as: "h4",
1699
+ children: dragAndDropText
1700
+ }), /*#__PURE__*/jsx(Text.Body, {
1701
+ children: orText
1702
+ }), /*#__PURE__*/jsx(Link, {
1703
+ tone: "secondary",
1704
+ to: "",
1705
+ onClick: ev => ev.preventDefault(),
1706
+ children: browseFileText
1707
+ })]
1708
+ })]
1709
+ });
1710
+ };
1711
+
1712
+ const FileDroppedArea = _ref => {
1713
+ let fileName = _ref.fileName,
1714
+ chooseFileLabel = _ref.chooseFileLabel;
1715
+ return /*#__PURE__*/jsxs(Spacings.Stack, {
1716
+ alignItems: "center",
1717
+ scale: "s",
1718
+ children: [/*#__PURE__*/jsxs(Spacings.Inline, {
1719
+ alignItems: "flex-start",
1720
+ scale: "xs",
1721
+ children: [/*#__PURE__*/jsx(PaperclipIcon, {
1722
+ color: "neutral60"
1723
+ }), /*#__PURE__*/jsx(Constraints.Horizontal, {
1724
+ max: 13,
1725
+ children: /*#__PURE__*/jsx(Text.Body, {
1726
+ children: fileName
1727
+ })
1728
+ })]
1729
+ }), /*#__PURE__*/jsx(SecondaryButton, {
1730
+ tone: "secondary",
1731
+ size: "medium",
1732
+ label: chooseFileLabel
1733
+ })]
1734
+ });
1735
+ };
1736
+
1737
+ const ActiveDragDropArea = _ref => {
1738
+ let isFileDropped = _ref.isFileDropped,
1739
+ fileName = _ref.fileName,
1740
+ chooseFileLabel = _ref.chooseFileLabel,
1741
+ dragAndDropText = _ref.dragAndDropText,
1742
+ orText = _ref.orText,
1743
+ browseFileText = _ref.browseFileText;
1744
+ if (isFileDropped) {
1745
+ return /*#__PURE__*/jsx(FileDroppedArea, {
1746
+ fileName: fileName,
1747
+ chooseFileLabel: chooseFileLabel
1748
+ });
1749
+ }
1750
+ return /*#__PURE__*/jsx(EnabledDropArea, {
1751
+ dragAndDropText: dragAndDropText,
1752
+ orText: orText,
1753
+ browseFileText: browseFileText
1754
+ });
1755
+ };
1756
+
1757
+ function ownKeys$2(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; }
1758
+ 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(_context = ownKeys$2(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$2(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1759
+ const LockIcon = props => /*#__PURE__*/jsxs("svg", _objectSpread$2(_objectSpread$2({
1760
+ width: "87px",
1761
+ height: "118px",
1762
+ viewBox: "0 0 87 118",
1763
+ version: "1.1",
1764
+ xmlns: "http://www.w3.org/2000/svg",
1765
+ xmlnsXlink: "http://www.w3.org/1999/xlink"
1766
+ }, props), {}, {
1767
+ children: [/*#__PURE__*/jsx("title", {
1768
+ children: "Shape"
1769
+ }), /*#__PURE__*/jsx("g", {
1770
+ id: "Final-ImportBoard",
1771
+ stroke: "none",
1772
+ strokeWidth: "1",
1773
+ fill: "none",
1774
+ fillRule: "evenodd",
1775
+ children: /*#__PURE__*/jsx("g", {
1776
+ id: "2-Upload-files---Locked",
1777
+ transform: "translate(-697.000000, -285.000000)",
1778
+ fill: "#999999",
1779
+ fillRule: "nonzero",
1780
+ children: /*#__PURE__*/jsx("path", {
1781
+ d: "M781.167075,334.924997 L774.342717,334.924997 L774.342717,319.039771 C774.342717,300.267972 759.042508,285 740.22093,285 C721.403902,285 706.099143,300.267972 706.099143,319.039771 L706.099143,334.924997 L699.274786,334.924997 C698.019104,334.924997 697,335.941652 697,337.194315 L697,389.184392 C697,389.974114 697.414011,390.709373 698.087348,391.122389 C710.839797,398.892534 725.407525,403 740.22093,403 C755.034335,403 769.602064,398.892534 782.359062,391.122389 C783.027849,390.709373 783.44186,389.974114 783.44186,389.184392 L783.44186,337.194315 C783.44186,335.941652 782.418207,334.924997 781.167075,334.924997 Z M745.590495,368.913821 L745.590495,384.782392 C745.590495,386.353821 744.382343,387.639535 742.905713,387.639535 L737.536148,387.639535 C736.054148,387.639535 734.851365,386.353821 734.851365,384.782392 L734.851365,368.913821 C731.651104,366.930963 729.4818,363.296678 729.4818,359.068106 C729.4818,352.759535 734.29293,347.639535 740.22093,347.639535 C746.14893,347.639535 750.960061,352.759535 750.960061,359.068106 C750.960061,363.285249 748.790756,366.930963 745.590495,368.913821 Z M760.116279,334.395349 L718.953488,334.395349 L718.953488,318.787791 C718.953488,307.724262 728.187674,298.72093 739.534884,298.72093 C750.877519,298.72093 760.116279,307.724262 760.116279,318.787791 L760.116279,334.395349 Z",
1782
+ id: "Shape"
1783
+ })
1784
+ })
1785
+ })]
1786
+ }));
1787
+
1788
+ const DisabledDropArea = _ref => {
1789
+ let disabledMessage = _ref.disabledMessage;
1790
+ return /*#__PURE__*/jsxs(Spacings.Stack, {
1791
+ alignItems: "center",
1792
+ children: [/*#__PURE__*/jsx(LockIcon, {}), disabledMessage && /*#__PURE__*/jsx(Text.Body, {
1793
+ children: disabledMessage
1794
+ })]
1795
+ });
1796
+ };
1797
+
1798
+ const getBorderColor = state => {
1799
+ const borderColors = {
1800
+ default: '#909dbc',
1801
+ error: '#e60050',
1802
+ active: customProperties.colorPrimary
1803
+ };
1804
+ return borderColors[state] || borderColors.default;
1805
+ };
1806
+ const getDashedBorder = function () {
1807
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
1808
+ const color = getBorderColor(state);
1809
+ const svgContent = `
1810
+ <svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
1811
+ <rect width="100%" height="100%" fill="none" stroke="${color}" stroke-width="2px" stroke-dasharray="6,6" stroke-dashoffset="0" stroke-linecap="square"/>
1812
+ </svg>
1813
+ `;
1814
+ return `data:image/svg+xml,${encodeURIComponent(svgContent)}`;
1815
+ };
1816
+ const base = /*#__PURE__*/css("border-radius:", customProperties.borderRadius6, ";min-height:136px;display:flex;justify-content:center;align-items:center;" + (process.env.NODE_ENV === "production" ? "" : ";label:base;"));
1817
+ const disabled = /*#__PURE__*/css(process.env.NODE_ENV === "production" ? "" : ";label:disabled;");
1818
+ const readyForDrop = /*#__PURE__*/css("background-image:url('", getDashedBorder(), "');background-color:", customProperties.colorSurface, ";" + (process.env.NODE_ENV === "production" ? "" : ";label:readyForDrop;"));
1819
+ const activeDrag = /*#__PURE__*/css("background-image:url('", getDashedBorder('active'), "');background-color:", customProperties.colorPrimary95, ";padding:", customProperties.spacing50, " 100px;" + (process.env.NODE_ENV === "production" ? "" : ";label:activeDrag;"));
1820
+ const fileDropped = /*#__PURE__*/css("background-image:url('", getDashedBorder(), "');background-color:", customProperties.colorSurface, ";padding:", customProperties.spacing50, " 100px;" + (process.env.NODE_ENV === "production" ? "" : ";label:fileDropped;"));
1821
+ const invalid = /*#__PURE__*/css("background-image:url('", getDashedBorder('default'), "');background-color:", customProperties.colorSurface, ";padding:", customProperties.spacing70, " 100px;" + (process.env.NODE_ENV === "production" ? "" : ";label:invalid;"));
1822
+ const parsing = /*#__PURE__*/css("background-image:url('", getDashedBorder(), "');background-color:", customProperties.colorSurface, ";padding:", customProperties.spacing50, " 100px;" + (process.env.NODE_ENV === "production" ? "" : ";label:parsing;"));
1823
+ const dropAreaStyles = {
1824
+ base,
1825
+ readyForDrop,
1826
+ fileDropped,
1827
+ disabled,
1828
+ activeDrag,
1829
+ invalid,
1830
+ parsing
1831
+ };
1832
+
1833
+ const DropAreaWrapper = /*#__PURE__*/_styled("div", process.env.NODE_ENV === "production" ? {
1834
+ target: "exmxphg0"
1835
+ } : {
1836
+ target: "exmxphg0",
1837
+ label: "DropAreaWrapper"
1838
+ })(dropAreaStyles.base, " ", props => {
1839
+ if (props.dropAreaState === 'disabled') {
1840
+ return dropAreaStyles.disabled;
1841
+ }
1842
+ if (props.dropAreaState === 'ready-for-drop') {
1843
+ return dropAreaStyles.readyForDrop;
1844
+ }
1845
+ if (props.dropAreaState === 'active-drag') {
1846
+ return dropAreaStyles.activeDrag;
1847
+ }
1848
+ if (props.dropAreaState === 'invalid') {
1849
+ return dropAreaStyles.invalid;
1850
+ }
1851
+ if (props.dropAreaState === 'is-parsing') {
1852
+ return dropAreaStyles.parsing;
1853
+ }
1854
+ if (props.dropAreaState === 'file-dropped') {
1855
+ return dropAreaStyles.fileDropped;
1856
+ }
1857
+ return getDefaultDropWrapperStyles(props.dropAreaState);
1858
+ }, ";");
1859
+ function getDefaultDropWrapperStyles(_dropAreaState) {
1860
+ return /*#__PURE__*/css(process.env.NODE_ENV === "production" ? "" : ";label:getDefaultDropWrapperStyles;");
1861
+ }
1862
+
1863
+ function ownKeys$1(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; }
1864
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context7 = ownKeys$1(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context8 = ownKeys$1(Object(t))).call(_context8, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1865
+ const FileDropArea = _ref => {
1866
+ let onDrop = _ref.onDrop,
1867
+ disabled = _ref.disabled,
1868
+ accept = _ref.accept,
1869
+ getDropAreaState = _ref.getDropAreaState,
1870
+ children = _ref.children,
1871
+ handleDropRejected = _ref.onDropRejected;
1872
+ const _useDropzone = useDropzone({
1873
+ onDrop,
1874
+ multiple: false,
1875
+ disabled,
1876
+ accept,
1877
+ onDropRejected: _ref2 => {
1878
+ var _context, _context2, _context3, _context4, _context5, _context6;
1879
+ let _ref3 = _slicedToArray(_ref2, 1),
1880
+ rejectedFile = _ref3[0];
1881
+ if (!handleDropRejected) return;
1882
+ if (((_context = rejectedFile) == null ? void 0 : _bindInstanceProperty(_context3 = Function.call).call(_context3, _someInstanceProperty(_context2 = _context.errors), _context2))?.(error => error.code === 'too-many-files')) {
1883
+ handleDropRejected('too-many-files');
1884
+ return;
1885
+ }
1886
+ if (((_context4 = rejectedFile) == null ? void 0 : _bindInstanceProperty(_context6 = Function.call).call(_context6, _someInstanceProperty(_context5 = _context4.errors), _context5))?.(error => error.code === 'file-invalid-type')) {
1887
+ handleDropRejected('invalid-type');
1888
+ } else {
1889
+ handleDropRejected('generic');
1890
+ }
1891
+ }
1892
+ }),
1893
+ getRootProps = _useDropzone.getRootProps,
1894
+ getInputProps = _useDropzone.getInputProps,
1895
+ isDragActive = _useDropzone.isDragActive;
1896
+ const dropAreaState = getDropAreaState(isDragActive);
1897
+ return /*#__PURE__*/jsxs(DropAreaWrapper, _objectSpread$1(_objectSpread$1({
1898
+ role: "presentation"
1899
+ }, getRootProps()), {}, {
1900
+ dropAreaState: dropAreaState,
1901
+ children: [/*#__PURE__*/jsx("input", _objectSpread$1({
1902
+ "data-testid": "file-input"
1903
+ }, getInputProps())), /*#__PURE__*/jsx(Constraints.Horizontal, {
1904
+ children: children(dropAreaState)
1905
+ })]
1906
+ }));
1907
+ };
1908
+
1909
+ const InfoBox = _ref => {
1910
+ let title = _ref.title,
1911
+ description = _ref.description;
1912
+ return /*#__PURE__*/jsx(ContentNotification, {
1913
+ type: "info",
1914
+ children: /*#__PURE__*/jsx(Spacings.Inset, {
1915
+ scale: "xs",
1916
+ children: /*#__PURE__*/jsxs(Spacings.Stack, {
1917
+ scale: "xs",
1918
+ children: [/*#__PURE__*/jsx(Text.Subheadline, {
1919
+ as: "h4",
1920
+ children: title
1921
+ }), /*#__PURE__*/jsx(Text.Body, {
1922
+ children: description
1923
+ })]
1924
+ })
1925
+ })
1926
+ });
1927
+ };
1928
+
1929
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
1930
+ var _ref = process.env.NODE_ENV === "production" ? {
1931
+ name: "lt3z56",
1932
+ styles: "width:calc(50% - 16px)"
1933
+ } : {
1934
+ name: "1vfe1dp-UploadSeparator",
1935
+ styles: "width:calc(50% - 16px);label:UploadSeparator;",
1936
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
1937
+ };
1938
+ const UploadSeparator = _ref2 => {
1939
+ let value = _ref2.value,
1940
+ onChange = _ref2.onChange,
1941
+ separatorTitle = _ref2.separatorTitle,
1942
+ decimalsSeparatorDescription = _ref2.decimalsSeparatorDescription,
1943
+ decimalSeparatorPointLabel = _ref2.decimalSeparatorPointLabel,
1944
+ decimalSeparatorCommaLabel = _ref2.decimalSeparatorCommaLabel,
1945
+ decimalsLabel = _ref2.decimalsLabel;
1946
+ const decimalSeparatorOptions = [{
1947
+ label: decimalSeparatorPointLabel,
1948
+ value: DELIMITERS.POINT
1949
+ }, {
1950
+ label: decimalSeparatorCommaLabel,
1951
+ value: DELIMITERS.COMMA
1952
+ }];
1953
+ return /*#__PURE__*/jsxs(Spacings.Stack, {
1954
+ scale: "m",
1955
+ children: [/*#__PURE__*/jsxs("div", {
1956
+ children: [/*#__PURE__*/jsx(Text.Subheadline, {
1957
+ as: "h4",
1958
+ children: separatorTitle
1959
+ }), /*#__PURE__*/jsx(Text.Caption, {
1960
+ tone: "tertiary",
1961
+ children: decimalsSeparatorDescription
1962
+ })]
1963
+ }), /*#__PURE__*/jsx("div", {
1964
+ css: _ref,
1965
+ children: /*#__PURE__*/jsx(SelectField, {
1966
+ title: decimalsLabel,
1967
+ isSearchable: false,
1968
+ options: decimalSeparatorOptions,
1969
+ value: value,
1970
+ onChange: e => {
1971
+ onChange(e.target.value);
1972
+ }
1973
+ })
1974
+ })]
1975
+ });
1976
+ };
1977
+
1978
+ const UploadSettings = _ref => {
1979
+ let resourceType = _ref.resourceType,
1980
+ isPublishChecked = _ref.isPublishChecked,
1981
+ onPublishChange = _ref.onPublishChange,
1982
+ publishProductsLabel = _ref.publishProductsLabel,
1983
+ dataTrackingTarget = _ref.dataTrackingTarget,
1984
+ canPublishProducts = _ref.canPublishProducts;
1985
+ if (resourceType !== 'product' || !canPublishProducts) {
1986
+ return null;
1987
+ }
1988
+ return /*#__PURE__*/jsx(CheckboxInput, {
1989
+ "data-tracking-target": dataTrackingTarget,
1990
+ isChecked: isPublishChecked,
1991
+ onChange: e => {
1992
+ onPublishChange(e.target.checked);
1993
+ },
1994
+ children: publishProductsLabel
1995
+ });
1996
+ };
1997
+
1998
+ const UploadingModal = _ref => {
1999
+ let isOpen = _ref.isOpen,
2000
+ title = _ref.title,
2001
+ fileName = _ref.fileName,
2002
+ fileSize = _ref.fileSize,
2003
+ progress = _ref.progress,
2004
+ cancelLabel = _ref.cancelLabel,
2005
+ onCancel = _ref.onCancel,
2006
+ onClose = _ref.onClose;
2007
+ const intl = useIntl();
2008
+ return /*#__PURE__*/jsx(InfoDialog, {
2009
+ size: 16,
2010
+ isOpen: isOpen,
2011
+ title: title,
2012
+ onClose: onClose,
2013
+ children: /*#__PURE__*/jsxs(Spacings.Stack, {
2014
+ scale: "m",
2015
+ children: [/*#__PURE__*/jsxs(Spacings.Inline, {
2016
+ alignItems: "center",
2017
+ justifyContent: "space-between",
2018
+ children: [/*#__PURE__*/jsxs(Spacings.Inline, {
2019
+ alignItems: "center",
2020
+ children: [/*#__PURE__*/jsx(FileIcon, {}), /*#__PURE__*/jsx(Spacings.Inline, {
2021
+ children: /*#__PURE__*/jsx(Constraints.Horizontal, {
2022
+ max: 10,
2023
+ children: /*#__PURE__*/jsx(Text.Body, {
2024
+ truncate: true,
2025
+ isBold: true,
2026
+ children: fileName
2027
+ })
2028
+ })
2029
+ }), /*#__PURE__*/jsxs(Text.Body, {
2030
+ tone: "secondary",
2031
+ children: ["(", intl.formatNumber(convertFileSizeToKB(fileSize)), " KB)"]
2032
+ })]
2033
+ }), /*#__PURE__*/jsx(SecondaryButton, {
2034
+ tone: "secondary",
2035
+ size: "medium",
2036
+ label: cancelLabel,
2037
+ onClick: onCancel
2038
+ })]
2039
+ }), /*#__PURE__*/jsx(ProgressBar, {
2040
+ barWidth: "scale",
2041
+ height: "10",
2042
+ progress: progress
2043
+ }), /*#__PURE__*/jsx("div", {})]
2044
+ })
2045
+ });
2046
+ };
2047
+
2048
+ var messages = defineMessages({
2049
+ unexpectedError: {
2050
+ id: 'operations.fetch.unexpectedError',
2051
+ description: 'Generic error message displayed when an unexpected error occurs during data fetching',
2052
+ defaultMessage: 'An unexpected error occurred while fetching the data. Please try again. If the problem persists, please contact support.'
2053
+ }
2054
+ });
2055
+
2056
+ const useFetch = function (fetchFunction) {
2057
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2058
+ const intl = useIntl();
2059
+ const _React$useState = React.useState(null),
2060
+ _React$useState2 = _slicedToArray(_React$useState, 2),
2061
+ data = _React$useState2[0],
2062
+ setData = _React$useState2[1];
2063
+ const _React$useState3 = React.useState(null),
2064
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
2065
+ error = _React$useState4[0],
2066
+ setError = _React$useState4[1];
2067
+ const _React$useState5 = React.useState(false),
2068
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
2069
+ isLoading = _React$useState6[0],
2070
+ setIsLoading = _React$useState6[1];
2071
+ const _React$useState7 = React.useState(0),
2072
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
2073
+ refetchCount = _React$useState8[0],
2074
+ setRefetchCount = _React$useState8[1];
2075
+ const _React$useState9 = React.useState(new Date()),
2076
+ _React$useState0 = _slicedToArray(_React$useState9, 2),
2077
+ lastFetchTime = _React$useState0[0],
2078
+ setLastFetchTime = _React$useState0[1];
2079
+ const refetch = React.useCallback(() => {
2080
+ setRefetchCount(count => count + 1);
2081
+ }, []);
2082
+ React.useEffect(() => {
2083
+ let pollingId = null;
2084
+ const fetchData = async () => {
2085
+ setIsLoading(true);
2086
+ try {
2087
+ const response = await fetchFunction();
2088
+ setData(response);
2089
+ setLastFetchTime(new Date());
2090
+ if (config.shouldContinuePolling && !config.shouldContinuePolling(response)) {
2091
+ if (pollingId) {
2092
+ clearInterval(pollingId);
2093
+ pollingId = null;
2094
+ }
2095
+ }
2096
+ } catch (err) {
2097
+ if (err instanceof HttpError) {
2098
+ setError(err);
2099
+ } else {
2100
+ setError(new Error(intl.formatMessage(messages.unexpectedError)));
2101
+ reportErrorToSentry(new Error('An unexpected error occurred in the `useFetch` hook'), {
2102
+ extra: {
2103
+ error: err
2104
+ }
2105
+ });
2106
+ }
2107
+ } finally {
2108
+ setIsLoading(false);
2109
+ }
2110
+ };
2111
+ fetchData();
2112
+ if (config.pollingInterval && config.pollingInterval > 0) {
2113
+ pollingId = _setInterval(fetchData, config.pollingInterval);
2114
+ }
2115
+ return () => {
2116
+ if (pollingId) {
2117
+ clearInterval(pollingId);
2118
+ }
2119
+ setError(null);
2120
+ setIsLoading(false);
2121
+ };
2122
+ }, [fetchFunction, refetchCount, intl, config.pollingInterval, config.shouldContinuePolling]);
2123
+ return {
2124
+ data,
2125
+ error,
2126
+ isLoading,
2127
+ refetch,
2128
+ lastFetchTime
2129
+ };
2130
+ };
2131
+
2132
+ const useFetchExportOperations = _ref => {
2133
+ let projectKey = _ref.projectKey,
2134
+ queryParams = _ref.queryParams,
2135
+ pollingInterval = _ref.pollingInterval,
2136
+ shouldContinuePolling = _ref.shouldContinuePolling;
2137
+ const fetchData = React.useCallback(() => {
2138
+ if (!projectKey) {
2139
+ return _Promise.reject(new ProjectKeyNotAvailableError());
2140
+ }
2141
+ return fetchExportOperations({
2142
+ projectKey,
2143
+ queryParams
2144
+ });
2145
+ }, [projectKey, queryParams]);
2146
+ return useFetch(fetchData, {
2147
+ pollingInterval,
2148
+ shouldContinuePolling
2149
+ });
2150
+ };
2151
+
2152
+ const useFetchImportContainerDetails = _ref => {
2153
+ let projectKey = _ref.projectKey,
2154
+ importContainerKey = _ref.importContainerKey,
2155
+ pollingInterval = _ref.pollingInterval,
2156
+ shouldContinuePolling = _ref.shouldContinuePolling;
2157
+ const fetchData = React.useCallback(() => {
2158
+ if (!projectKey) {
2159
+ return _Promise.reject(new ProjectKeyNotAvailableError());
2160
+ }
2161
+ return fetchImportContainerDetails({
2162
+ projectKey,
2163
+ importContainerKey
2164
+ });
2165
+ }, [projectKey, importContainerKey]);
2166
+ return useFetch(fetchData, {
2167
+ pollingInterval,
2168
+ shouldContinuePolling
2169
+ });
2170
+ };
2171
+
2172
+ const useFetchImportOperations = _ref => {
2173
+ let projectKey = _ref.projectKey,
2174
+ importContainerKey = _ref.importContainerKey,
2175
+ queryParams = _ref.queryParams,
2176
+ pollingInterval = _ref.pollingInterval,
2177
+ shouldContinuePolling = _ref.shouldContinuePolling;
2178
+ const fetchData = React.useCallback(() => {
2179
+ if (!projectKey) {
2180
+ return _Promise.reject(new ProjectKeyNotAvailableError());
2181
+ }
2182
+ return fetchImportOperations({
2183
+ projectKey,
2184
+ importContainerKey,
2185
+ queryParams
2186
+ });
2187
+ }, [projectKey, importContainerKey, queryParams]);
2188
+ return useFetch(fetchData, {
2189
+ pollingInterval,
2190
+ shouldContinuePolling
2191
+ });
2192
+ };
2193
+
2194
+ const useFetchImportSummaries = _ref => {
2195
+ let projectKey = _ref.projectKey,
2196
+ queryParams = _ref.queryParams,
2197
+ pollingInterval = _ref.pollingInterval,
2198
+ shouldContinuePolling = _ref.shouldContinuePolling;
2199
+ const fetchData = React.useCallback(async () => {
2200
+ if (!projectKey) {
2201
+ return _Promise.reject(new ProjectKeyNotAvailableError());
2202
+ }
2203
+ const summary = await fetchImportSummaries({
2204
+ projectKey,
2205
+ queryParams
2206
+ });
2207
+ const resolvedResults = await _Promise.all(summary.results);
2208
+ return {
2209
+ results: resolvedResults,
2210
+ count: summary.count,
2211
+ total: summary.total
2212
+ };
2213
+ }, [projectKey, queryParams]);
2214
+ return useFetch(fetchData, {
2215
+ pollingInterval,
2216
+ shouldContinuePolling
2217
+ });
2218
+ };
2219
+
2220
+ function ownKeys(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; }
2221
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
2222
+ const useImportContainerUpload = _ref => {
2223
+ let projectKey = _ref.projectKey;
2224
+ const _React$useState = React.useState(false),
2225
+ _React$useState2 = _slicedToArray(_React$useState, 2),
2226
+ isUploading = _React$useState2[0],
2227
+ setIsUploading = _React$useState2[1];
2228
+ const _React$useState3 = React.useState(0),
2229
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
2230
+ progress = _React$useState4[0],
2231
+ setProgress = _React$useState4[1];
2232
+ const xhrRef = React.useRef(null);
2233
+ const upload = async _ref2 => {
2234
+ let file = _ref2.file,
2235
+ resourceType = _ref2.resourceType,
2236
+ settings = _ref2.settings,
2237
+ onSuccess = _ref2.onSuccess,
2238
+ onError = _ref2.onError,
2239
+ onProgress = _ref2.onProgress;
2240
+ if (!projectKey) {
2241
+ throw new ProjectKeyNotAvailableError();
2242
+ }
2243
+ setIsUploading(true);
2244
+ setProgress(0);
2245
+ const importContainerKey = encodeFileNameWithTimestampToContainerKey(file.name);
2246
+ try {
2247
+ await createImportContainerForFileUpload({
2248
+ importContainerDraft: _objectSpread({
2249
+ key: importContainerKey,
2250
+ resourceType,
2251
+ tags: [TAG_KEY_SOURCE_FILE_UPLOAD]
2252
+ }, settings ? {
2253
+ settings
2254
+ } : {}),
2255
+ projectKey
2256
+ });
2257
+ const xhr = uploadFileForImport({
2258
+ projectKey,
2259
+ importContainerKey,
2260
+ resourceType,
2261
+ file,
2262
+ onSuccess: response => {
2263
+ setIsUploading(false);
2264
+ setProgress(100);
2265
+ onSuccess(response, importContainerKey);
2266
+ },
2267
+ onProgress: prog => {
2268
+ setProgress(prog);
2269
+ onProgress?.(prog);
2270
+ },
2271
+ onError: async error => {
2272
+ try {
2273
+ await deleteImportContainer({
2274
+ projectKey,
2275
+ importContainerKey
2276
+ });
2277
+ } catch {
2278
+ // Ignore cleanup errors - container will be cleaned up by TTL retention policy
2279
+ // Cleanup errors are unlikely unless there is a network issue or container was removed externally
2280
+ }
2281
+ setIsUploading(false);
2282
+ setProgress(0);
2283
+ onError?.(error);
2284
+ }
2285
+ });
2286
+ xhrRef.current = xhr;
2287
+ return xhr;
2288
+ } catch (error) {
2289
+ try {
2290
+ await deleteImportContainer({
2291
+ projectKey,
2292
+ importContainerKey
2293
+ });
2294
+ } catch {
2295
+ // Ignore cleanup errors - container will be cleaned up by TTL retention policy
2296
+ // Cleanup errors are unlikely unless there is a network issue or container was removed externally
2297
+ }
2298
+ setIsUploading(false);
2299
+ setProgress(0);
2300
+ throw error;
2301
+ }
2302
+ };
2303
+ const abort = () => {
2304
+ xhrRef.current?.abort();
2305
+ setIsUploading(false);
2306
+ setProgress(0);
2307
+ };
2308
+ return {
2309
+ upload,
2310
+ abort,
2311
+ isUploading,
2312
+ progress
2313
+ };
2314
+ };
2315
+
2316
+ export { ActiveDragDropArea, COLUMN_DELIMITERS, CT_API_DOCS_URL, DELIMITERS, DisabledDropArea, DropAreaWrapper, EnabledDropArea, FileDropArea, FileDroppedArea, FileIcon, HttpError, IMPORT_TAG_KEYS, IMPORT_TAG_VALUES, ImportStates, InfoBox, InvalidResponseError, LockIcon, MAX_FILE_SIZE_MB, MAX_ROW_COUNT, NoResourcesToExportError, 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, assertFileUploadResponse, assertImportContainer, assertImportContainerPagedResponse, assertImportOperationPagedResponse, assertImportSummary, assertPaginatedExportOperationResponse, assertProcessFileResponse, assertResourceType, automatedImportContainerKey, automatedImports, cancelImportContainerByKey, checkIfFileUploadImport, convertFileSizeToKB, countJsonFileItems, createImportContainerForFileUpload, decodeFileNameFromImportContainerKey, deleteImportContainer, dropAreaStyles, encodeFileNameWithTimestampToContainerKey, exportOperationsCompleted, exportOperationsProcessing, extractErrorDescriptionFromValidationMessage, fetchExportOperations, fetchImportContainerByKey, fetchImportContainerDetails, fetchImportContainers, fetchImportOperations, fetchImportSummaries, fetchImportSummary, fetchUsingXhr, fetcher, fileUploadImportContainerKey, fileUploadMissingKeysResponse, formatErrorCode, formatKeys, formatQueryString, getCreateImportContainerURL, getDeleteImportContainerURL, getExportOperationsURL, getFileUploadErrorsCount, getFileUploadURL, getImportContainerByKeyURL, getImportContainerTasksURL, getImportContainersURL, getImportOperationsURL, getImportState, getImportSummaryURL, getMissingRequiredFields, getProccessFileURL, getRowCount, getValidatedColumns, hasOwnProperty, hasRequiredFields, hasSingleKeyColumn, importContainers, importStatesMap, importsSummaries, invalidFileUploadResponse, isAbortError, isError, isResourceType, manualImports, mapFileUploadErrorsToUploadFileErrorRows, mapFormikErrors, mapUploadFileErrorsResponseToUploadFileErrorRows, processUploadedFile, successfulAutomatedImportOperations, successfulAutomatedImportOperationsResponse, successfulFileUploadImportOperations, successfulFileUploadImportOperationsResponse, toBytes, uploadFileForImport, useFetchExportOperations, useFetchImportContainerDetails, useFetchImportOperations, useFetchImportSummaries, useImportContainerUpload, validFileUploadResponse, validProcessFileResponse, validateDelimiter };