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