@commercetools-frontend-extensions/export-resources-modal 4.7.1 → 4.8.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 (26) hide show
  1. package/README.md +7 -2
  2. package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +70 -57
  3. package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +69 -56
  4. package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +69 -58
  5. package/dist/{de-af429e2a.cjs.dev.js → de-3d4cf3d0.cjs.prod.js} +1 -1
  6. package/dist/{de-9746c508.esm.js → de-abc94d19.esm.js} +1 -1
  7. package/dist/{de-f235117b.cjs.prod.js → de-d6a38e9e.cjs.dev.js} +1 -1
  8. package/dist/declarations/src/@types/export-api.d.ts +5 -1
  9. package/dist/declarations/src/@types/export-resources-modal-context.d.ts +6 -2
  10. package/dist/declarations/src/@types/export-resources-modal-types.d.ts +8 -2
  11. package/dist/{en-8b4fee65.cjs.dev.js → en-0ea9f92c.cjs.dev.js} +1 -1
  12. package/dist/{en-b0fc803b.esm.js → en-38313842.esm.js} +1 -1
  13. package/dist/{en-0a4519c0.cjs.prod.js → en-fc0085cc.cjs.prod.js} +1 -1
  14. package/dist/{es-339117ae.cjs.prod.js → es-6360d546.cjs.prod.js} +1 -1
  15. package/dist/{es-ed7a7149.esm.js → es-85c5a396.esm.js} +1 -1
  16. package/dist/{es-1da000fa.cjs.dev.js → es-a4227b21.cjs.dev.js} +1 -1
  17. package/dist/{fr-FR-af05384b.cjs.prod.js → fr-FR-1602d5ff.cjs.dev.js} +1 -1
  18. package/dist/{fr-FR-01c89efe.esm.js → fr-FR-e610590b.esm.js} +1 -1
  19. package/dist/{fr-FR-f6456131.cjs.dev.js → fr-FR-ff7ec057.cjs.prod.js} +1 -1
  20. package/dist/{pt-BR-03e1fb85.cjs.prod.js → pt-BR-7b17be9e.cjs.dev.js} +1 -1
  21. package/dist/{pt-BR-8b9dd081.esm.js → pt-BR-ccc18639.esm.js} +1 -1
  22. package/dist/{pt-BR-bc9a187a.cjs.dev.js → pt-BR-d9b0a36d.cjs.prod.js} +1 -1
  23. package/dist/{zh-CN-e6a19d6d.cjs.dev.js → zh-CN-0126d1d1.cjs.prod.js} +1 -1
  24. package/dist/{zh-CN-1051c1d7.cjs.prod.js → zh-CN-0f473f16.cjs.dev.js} +1 -1
  25. package/dist/{zh-CN-464f6fce.esm.js → zh-CN-9a726ccd.esm.js} +1 -1
  26. package/package.json +1 -1
@@ -44,6 +44,7 @@ var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-arr
44
44
  var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
45
45
  var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
46
46
  var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
47
+ var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
47
48
  var actionsGlobal = require('@commercetools-frontend/actions-global');
48
49
  var constants = require('@commercetools-frontend/constants');
49
50
  var sdk = require('@commercetools-frontend/sdk');
@@ -87,6 +88,7 @@ var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
87
88
  var _Set__default = /*#__PURE__*/_interopDefault(_Set);
88
89
  var _sortInstanceProperty__default = /*#__PURE__*/_interopDefault(_sortInstanceProperty);
89
90
  var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfInstanceProperty);
91
+ var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
90
92
  var sortBy__default = /*#__PURE__*/_interopDefault(sortBy);
91
93
  var _styled__default = /*#__PURE__*/_interopDefault(_styled);
92
94
  var throttle__default = /*#__PURE__*/_interopDefault(throttle);
@@ -262,107 +264,107 @@ var messages = reactIntl.defineMessages({
262
264
  exportScopeAllCategories: {
263
265
  id: 'ExportResourcesModal.exportScopeAllCategories',
264
266
  description: 'Label for Export All categories',
265
- defaultMessage: 'Export all: {total} categories'
267
+ defaultMessage: 'Export all: {total, plural, one {# category} other {# categories}}'
266
268
  },
267
269
  exportScopeSelectedCategories: {
268
270
  id: 'ExportResourcesModal.exportScopeSelectedCategories',
269
271
  description: 'Label for Export Selected categories',
270
- defaultMessage: 'Export selected: {total} categories'
272
+ defaultMessage: 'Export selected: {total, plural, one {# category} other {# categories}}'
271
273
  },
272
274
  exportScopeFilteredCategories: {
273
275
  id: 'ExportResourcesModal.exportScopeFilteredCategories',
274
276
  description: 'Label for Export Filtered categories',
275
- defaultMessage: 'Export filtered: {total} categories'
277
+ defaultMessage: 'Export filtered: {total, plural, one {# category} other {# categories}}'
276
278
  },
277
279
  exportScopeAllProducts: {
278
280
  id: 'ExportResourcesModal.exportScopeAllProducts',
279
281
  description: 'Label for Export All products',
280
- defaultMessage: 'Export all: {total} products'
282
+ defaultMessage: 'Export all: {total, plural, one {# product} other {# products}}'
281
283
  },
282
284
  exportScopeSelectedProducts: {
283
285
  id: 'ExportResourcesModal.exportScopeSelectedProducts',
284
286
  description: 'Label for Export Selected products',
285
- defaultMessage: 'Export selected: {total} products'
287
+ defaultMessage: 'Export selected: {total, plural, one {# product} other {# products}}'
286
288
  },
287
289
  exportScopeFilteredProducts: {
288
290
  id: 'ExportResourcesModal.exportScopeFilteredProducts',
289
291
  description: 'Label for Export Filtered products',
290
- defaultMessage: 'Export filtered: {total} products'
292
+ defaultMessage: 'Export filtered: {total, plural, one {# product} other {# products}}'
291
293
  },
292
294
  exportScopeAllProductTypes: {
293
295
  id: 'ExportResourcesModal.exportScopeAllProductTypes',
294
296
  description: 'Label for Export All product types',
295
- defaultMessage: 'Export all: {total} product types'
297
+ defaultMessage: 'Export all: {total, plural, one {# product type} other {# product types}}'
296
298
  },
297
299
  exportScopeSelectedProductTypes: {
298
300
  id: 'ExportResourcesModal.exportScopeSelectedProductTypes',
299
301
  description: 'Label for Export Selected product types',
300
- defaultMessage: 'Export selected: {total} product types'
302
+ defaultMessage: 'Export selected: {total, plural, one {# product type} other {# product types}}'
301
303
  },
302
304
  exportScopeFilteredProductTypes: {
303
305
  id: 'ExportResourcesModal.exportScopeFilteredProductTypes',
304
306
  description: 'Label for Export Filtered product types',
305
- defaultMessage: 'Export filtered: {total} product types'
307
+ defaultMessage: 'Export filtered: {total, plural, one {# product type} other {# product types}}'
306
308
  },
307
309
  exportInventoriesForAllProducts: {
308
310
  id: 'ExportResourcesModal.exportInventoriesForAllProducts',
309
311
  description: 'Label for Export All inventories',
310
- defaultMessage: 'Export inventories for all {total} products'
312
+ defaultMessage: 'Export inventories for all {total, plural, one {# product} other {# products}}'
311
313
  },
312
314
  exportInventoriesForSelectedProducts: {
313
315
  id: 'ExportResourcesModal.exportInventoriesForSelectedProducts',
314
316
  description: 'Label for Export Selected inventories',
315
- defaultMessage: 'Export inventories for the {total} selected products'
317
+ defaultMessage: 'Export inventories for the {total, plural, one {# selected product} other {# selected products}}'
316
318
  },
317
319
  exportInventoriesForFilteredProducts: {
318
320
  id: 'ExportResourcesModal.exportInventoriesForFilteredProducts',
319
321
  description: 'Label for Export Filtered inventories',
320
- defaultMessage: 'Export inventories for the {total} filtered products'
322
+ defaultMessage: 'Export inventories for the {total, plural, one {# filtered product} other {# filtered products}}'
321
323
  },
322
324
  exportScopeAllDiscountCodes: {
323
325
  id: 'ExportResourcesModal.exportScopeAllDiscountCodes',
324
326
  description: 'Label for Export All discount codes',
325
- defaultMessage: 'Export all: {total} discount codes'
327
+ defaultMessage: 'Export all: {total, plural, one {# discount code} other {# discount codes}}'
326
328
  },
327
329
  exportScopeSelectedDiscountCodes: {
328
330
  id: 'ExportResourcesModal.exportScopeSelectedDiscountCodes',
329
331
  description: 'Label for Export Selected discount codes',
330
- defaultMessage: 'Export selected: {total} discount codes'
332
+ defaultMessage: 'Export selected: {total, plural, one {# discount code} other {# discount codes}}'
331
333
  },
332
334
  exportScopeFilteredDiscountCodes: {
333
335
  id: 'ExportResourcesModal.exportScopeFilteredDiscountCodes',
334
336
  description: 'Label for Export Filtered discount codes',
335
- defaultMessage: 'Export filtered: {total} discount codes'
337
+ defaultMessage: 'Export filtered: {total, plural, one {# discount code} other {# discount codes}}'
336
338
  },
337
339
  exportScopeAllOrders: {
338
340
  id: 'ExportResourcesModal.exportScopeAllOrders',
339
341
  description: 'Label for Export All orders',
340
- defaultMessage: 'Export all: {total} orders'
342
+ defaultMessage: 'Export all: {total, plural, one {# order} other {# orders}}'
341
343
  },
342
344
  exportScopeSelectedOrders: {
343
345
  id: 'ExportResourcesModal.exportScopeSelectedOrders',
344
346
  description: 'Label for Export Selected orders',
345
- defaultMessage: 'Export selected: {total} orders'
347
+ defaultMessage: 'Export selected: {total, plural, one {# order} other {# orders}}'
346
348
  },
347
349
  exportScopeFilteredOrders: {
348
350
  id: 'ExportResourcesModal.exportScopeFilteredOrders',
349
351
  description: 'Label for Export Filtered orders',
350
- defaultMessage: 'Export filtered: {total} orders'
352
+ defaultMessage: 'Export filtered: {total, plural, one {# order} other {# orders}}'
351
353
  },
352
354
  exportScopeAllCustomers: {
353
355
  id: 'ExportResourcesModal.exportScopeAllCustomers',
354
356
  description: 'Label for Export All customers',
355
- defaultMessage: 'Export all: {total} customers'
357
+ defaultMessage: 'Export all: {total, plural, one {# customer} other {# customers}}'
356
358
  },
357
359
  exportScopeSelectedCustomers: {
358
360
  id: 'ExportResourcesModal.exportScopeSelectedCustomers',
359
361
  description: 'Label for Export Selected customers',
360
- defaultMessage: 'Export selected: {total} customers'
362
+ defaultMessage: 'Export selected: {total, plural, one {# customer} other {# customers}}'
361
363
  },
362
364
  exportScopeFilteredCustomers: {
363
365
  id: 'ExportResourcesModal.exportScopeFilteredCustomers',
364
366
  description: 'Label for Export Filtered customers',
365
- defaultMessage: 'Export filtered: {total} customers'
367
+ defaultMessage: 'Export filtered: {total, plural, one {# customer} other {# customers}}'
366
368
  },
367
369
  exportScopeSelectedWithoutCount: {
368
370
  id: 'ExportResourcesModal.exportScopeSelectedWithoutCount',
@@ -652,6 +654,12 @@ const getTotalCheckedFields = group => {
652
654
  return countCheckedFields(group.fields);
653
655
  };
654
656
 
657
+ let Step = /*#__PURE__*/function (Step) {
658
+ Step["FileSettings"] = "file-settings";
659
+ Step["FieldsSelection"] = "fields-selection";
660
+ return Step;
661
+ }({});
662
+
655
663
  function validate(_ref) {
656
664
  let values = _valuesInstanceProperty__default["default"](_ref),
657
665
  step = _ref.step;
@@ -671,7 +679,7 @@ function validate(_ref) {
671
679
  if (locales.length < 1) {
672
680
  errors.locales.missing = true;
673
681
  }
674
- if (step === 2) {
682
+ if (step === Step.FieldsSelection) {
675
683
  const allFields = _reduceInstanceProperty__default["default"](groups).call(groups, (acc, group) => _concatInstanceProperty__default["default"](acc).call(acc, group.fields), []);
676
684
  const checkedFieldsCount = _filterInstanceProperty__default["default"](allFields).call(allFields, field => {
677
685
  if (field.fields) return isAnyFieldChecked(field.fields);
@@ -770,20 +778,21 @@ function buildSelectedExportFilters(selectedResourceIds) {
770
778
  return `id in (${formattedIds})`;
771
779
  }
772
780
  function validateFilters(filters) {
773
- const hasQueryPredicate = 'queryPredicate' in filters;
774
- const hasSearchQuery = 'searchQuery' in filters;
775
-
776
- // Ensure only one of `queryPredicate` or `searchQuery` is applied but not both or none
777
- const validFilterState = hasQueryPredicate && !hasSearchQuery || !hasQueryPredicate && hasSearchQuery;
781
+ const hasWhere = 'where' in filters;
782
+ const hasFilters = 'filters' in filters;
783
+ const hasFullText = 'fullText' in filters;
784
+ // Ensure only one of `where` or `filters` is applied but not both or none
785
+ const validFilterState = hasWhere && !hasFilters || !hasWhere && hasFilters || hasFullText && filters?.fullText?.text?.trim() !== '';
778
786
  return validFilterState;
779
787
  }
780
- function areFiltersApplied(filters) {
781
- if (!filters) {
788
+ function areFiltersApplied(filterObject) {
789
+ if (!filterObject) {
782
790
  return false;
783
791
  }
784
- const hasQueryPredicate = (filters.queryPredicate?.trim() ?? '') !== '';
785
- const hasSearchQuery = _Object$keys__default["default"](filters.searchQuery ?? {}).length > 0;
786
- return hasQueryPredicate || hasSearchQuery;
792
+ let filters = filterObject.filters,
793
+ where = filterObject.where;
794
+ let hasFilters = where && _trimInstanceProperty__default["default"](where).call(where) !== '' || Boolean(_Array$isArray__default["default"](filters) && filters.length > 0 || typeof filters === 'object' && _Object$keys__default["default"](filters).length > 0);
795
+ return hasFilters;
787
796
  }
788
797
  function getInitialExportType(args) {
789
798
  if (args.selectedResourceIds?.length) {
@@ -968,7 +977,8 @@ async function createExportOperation(_ref, asyncDispatchFn) {
968
977
  locales = _ref.locales,
969
978
  filters = _ref.filters,
970
979
  where = _ref.where,
971
- fillRows = _ref.fillRows;
980
+ fillRows = _ref.fillRows,
981
+ fullText = _ref.fullText;
972
982
  const uri = `/${projectKey}/export-operations`;
973
983
  const response = await asyncDispatchFn(sdk.actions.post({
974
984
  mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.EXPORT,
@@ -985,8 +995,9 @@ async function createExportOperation(_ref, asyncDispatchFn) {
985
995
  fillRows,
986
996
  // Query predicate
987
997
  where,
988
- // Search API filters
989
- filters
998
+ // Search API filters or Category API filters
999
+ filters,
1000
+ fullText
990
1001
  }
991
1002
  }));
992
1003
  if (!response || typeof response !== 'object' || !('state' in response)) {
@@ -1029,16 +1040,16 @@ const useStartExportOperation = props => {
1029
1040
  const fields = extractFieldNamesFromGroups(values.groups);
1030
1041
  let where = undefined;
1031
1042
  let filters = undefined;
1043
+ let fullText = undefined;
1032
1044
  if (exportType === EXPORT_TYPES.SELECTED && props.selectedResourceIds?.length) {
1033
1045
  where = buildSelectedExportFilters(props.selectedResourceIds);
1034
1046
  } else if (exportType === EXPORT_TYPES.FILTERED) {
1035
- if (props.filters?.queryPredicate) {
1036
- where = props.filters.queryPredicate;
1037
- }
1038
- if (props.filters?.searchQuery) {
1039
- filters = {
1040
- query: props.filters.searchQuery
1041
- };
1047
+ if (props.filters) {
1048
+ ;
1049
+ var _props$filters = props.filters;
1050
+ filters = _props$filters.filters;
1051
+ where = _props$filters.where;
1052
+ fullText = _props$filters.fullText;
1042
1053
  }
1043
1054
  }
1044
1055
  const response = await createExportOperation({
@@ -1050,7 +1061,8 @@ const useStartExportOperation = props => {
1050
1061
  fillRows: values.fillRows,
1051
1062
  fields,
1052
1063
  where,
1053
- filters
1064
+ filters,
1065
+ fullText
1054
1066
  }, asyncDispatch);
1055
1067
  switch (response.state) {
1056
1068
  case EXPORT_OPERATION_STATES.QUEUED:
@@ -1825,7 +1837,7 @@ const ExportFieldsSelectionStep = () => {
1825
1837
  onPrimaryButtonClick: formik.submitForm,
1826
1838
  isPrimaryButtonDisabled: !formik.isValid,
1827
1839
  labelSecondary: intl.formatMessage(messages.back),
1828
- onSecondaryButtonClick: () => setCurrentStep(1),
1840
+ onSecondaryButtonClick: () => setCurrentStep(Step.FileSettings),
1829
1841
  onClose: onClose,
1830
1842
  size: 16,
1831
1843
  children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
@@ -1868,7 +1880,7 @@ const ExportResourcesProvider = _ref => {
1868
1880
  let children = _ref.children,
1869
1881
  props = _objectWithoutProperties(_ref, _excluded);
1870
1882
  const initialValues = useInitialValues(props);
1871
- const _React$useState = React__default["default"].useState(1),
1883
+ const _React$useState = React__default["default"].useState(Step.FileSettings),
1872
1884
  _React$useState2 = _slicedToArray(_React$useState, 2),
1873
1885
  currentStep = _React$useState2[0],
1874
1886
  setCurrentStep = _React$useState2[1];
@@ -1882,8 +1894,8 @@ const ExportResourcesProvider = _ref => {
1882
1894
  const _useStartExportOperat = useStartExportOperation(props),
1883
1895
  startExportOperation = _useStartExportOperat.startExportOperation;
1884
1896
  const onSubmit = async values => {
1885
- if (currentStep === 1) {
1886
- setCurrentStep(2);
1897
+ if (currentStep === Step.FileSettings) {
1898
+ setCurrentStep(Step.FieldsSelection);
1887
1899
  } else {
1888
1900
  startExportOperation(values, exportType);
1889
1901
  }
@@ -1922,8 +1934,8 @@ const CurrentStep = () => {
1922
1934
  const _useExportResourcesMo = useExportResourcesModalContext(),
1923
1935
  currentStep = _useExportResourcesMo.currentStep;
1924
1936
  const steps = {
1925
- 1: jsxRuntime.jsx(ExportFileSettingsStep, {}),
1926
- 2: jsxRuntime.jsx(ExportFieldsSelectionStep, {})
1937
+ 'file-settings': jsxRuntime.jsx(ExportFileSettingsStep, {}),
1938
+ 'fields-selection': jsxRuntime.jsx(ExportFieldsSelectionStep, {})
1927
1939
  };
1928
1940
  return steps[currentStep] || null;
1929
1941
  };
@@ -1932,19 +1944,19 @@ const getChunkImport = locale => {
1932
1944
  const intlLocale = i18n.mapLocaleToIntlLocale(locale);
1933
1945
  switch (intlLocale) {
1934
1946
  case 'de':
1935
- return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-de" */'./de-f235117b.cjs.prod.js'); });
1947
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-de" */'./de-3d4cf3d0.cjs.prod.js'); });
1936
1948
  case 'es':
1937
- return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-es" */'./es-339117ae.cjs.prod.js'); });
1949
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-es" */'./es-6360d546.cjs.prod.js'); });
1938
1950
  case 'fr-FR':
1939
- return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-fr-FR" */'./fr-FR-af05384b.cjs.prod.js'); });
1951
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-fr-FR" */'./fr-FR-ff7ec057.cjs.prod.js'); });
1940
1952
  case 'zh-CN':
1941
- return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-zh-CN" */'./zh-CN-1051c1d7.cjs.prod.js'); });
1953
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-zh-CN" */'./zh-CN-0126d1d1.cjs.prod.js'); });
1942
1954
  case 'ja':
1943
1955
  return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-ja" */'./ja-37632763.cjs.prod.js'); });
1944
1956
  case 'pt-BR':
1945
- return Promise.resolve().then(function () { return require(/* webpackChunkName: "change-history-i18n-pt-BR" */'./pt-BR-03e1fb85.cjs.prod.js'); });
1957
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "change-history-i18n-pt-BR" */'./pt-BR-d9b0a36d.cjs.prod.js'); });
1946
1958
  default:
1947
- return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-en" */'./en-0a4519c0.cjs.prod.js'); });
1959
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "export-resources-modal-i18n-en" */'./en-fc0085cc.cjs.prod.js'); });
1948
1960
  }
1949
1961
  };
1950
1962
  const loadMessages = async locale => {
@@ -2023,7 +2035,7 @@ const ExportResourcesModal = props => {
2023
2035
  const messages = useAsyncIntlMessages(locale, loadMessages);
2024
2036
  if (!props.isOpen || messages.isLoading) return null;
2025
2037
  if (props.filters && !validateFilters(props.filters)) {
2026
- console.error('Invalid filters prop:', props.filters, 'Filters must contain either `queryPredicate` or `searchQuery`, but not both, and it cannot be empty');
2038
+ console.error('Invalid filters prop:', props.filters, 'Filters must contain one of these values: `filters` or `where`');
2027
2039
  return null;
2028
2040
  }
2029
2041
  return jsxRuntime.jsx(reactIntl.IntlProvider, {
@@ -2045,5 +2057,6 @@ ExportResourcesModal.defaultProps = {
2045
2057
 
2046
2058
  exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;
2047
2059
  exports.EXPORT_TYPES = EXPORT_TYPES;
2060
+ exports.Step = Step;
2048
2061
  exports["default"] = ExportResourcesModal;
2049
2062
  exports.useConvertFieldDefinitionsForExport = useConvertFieldDefinitionsForExport;