@webitel/ui-sdk 24.10.3 → 24.10.4

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 (200) hide show
  1. package/dist/ui-sdk.css +1 -1
  2. package/dist/ui-sdk.js +111 -114
  3. package/dist/ui-sdk.umd.cjs +8 -8
  4. package/package.json +6 -4
  5. package/src/api/axios/generateInstance.js +1 -4
  6. package/src/api/clients/agents/agents.js +31 -78
  7. package/src/api/clients/buckets/buckets.js +17 -57
  8. package/src/api/clients/calendars/calendars.js +18 -71
  9. package/src/api/clients/chatGateways/chatGateways.js +23 -61
  10. package/src/api/clients/chatGateways/defaults/webChatGateway.js +6 -8
  11. package/src/api/clients/chatGateways/enums/WebchatAlternativeChannel.enum.js +3 -3
  12. package/src/api/clients/communications/communications.js +20 -62
  13. package/src/api/clients/configurations/configurations.js +18 -3
  14. package/src/api/clients/flows/flow.js +17 -60
  15. package/src/api/clients/gateways/gateways.js +20 -59
  16. package/src/api/clients/index.js +1 -1
  17. package/src/api/clients/lists/blacklists.js +18 -60
  18. package/src/api/clients/media/media.js +13 -43
  19. package/src/api/clients/queues/defaults/processing.js +10 -6
  20. package/src/api/clients/queues/queues.js +21 -69
  21. package/src/api/clients/roles/roles.js +15 -33
  22. package/src/api/clients/users/__tests__/users.spec.js +43 -26
  23. package/src/api/clients/users/users.js +21 -56
  24. package/src/api/crm/contactChatMessagesHistory.js +8 -23
  25. package/src/api/crm/index.js +1 -3
  26. package/src/api/defaults/getDefaultGetParams/getDefaultGetParams.js +1 -4
  27. package/src/api/defaults/getDefaultInstance/getDefaultInstance.js +10 -11
  28. package/src/api/defaults/getDefaultOpenAPIConfig/getDefaultOpenAPIConfig.js +6 -5
  29. package/src/api/defaults/index.js +2 -4
  30. package/src/api/history/index.js +1 -3
  31. package/src/api/history/transcript/callTranscript.js +10 -30
  32. package/src/api/interceptors/request/updateToken.interceptor.js +1 -2
  33. package/src/api/transformers/merge/merge.transformer.js +4 -1
  34. package/src/api/transformers/mergeEach/mergeEach.transformer.js +4 -4
  35. package/src/api/transformers/notify/notify.transformer.js +9 -6
  36. package/src/api/transformers/starToSearch/starToSearch.transformer.js +8 -6
  37. package/src/components/index.js +3 -6
  38. package/src/components/on-demand/wt-cc-agent-status-timers/__tests__/wt-cc-agent-status-timers.spec.js +2 -4
  39. package/src/components/transitions/wt-expand-transition.vue +2 -3
  40. package/src/components/wt-app-header/__tests__/WtAppNavigator.spec.js +1 -2
  41. package/src/components/wt-app-header/__tests__/WtHeaderActions.spec.js +1 -2
  42. package/src/components/wt-app-header/wt-app-navigator.vue +15 -9
  43. package/src/components/wt-avatar/wt-avatar.vue +8 -3
  44. package/src/components/wt-button/wt-button.vue +0 -1
  45. package/src/components/wt-button-select/__tests__/WtButtonSelect.spec.js +4 -5
  46. package/src/components/wt-button-select/wt-button-select.vue +0 -1
  47. package/src/components/wt-context-menu/wt-context-menu.vue +32 -35
  48. package/src/components/wt-dummy/wt-dummy.vue +2 -5
  49. package/src/components/wt-expansion-panel/wt-expansion-panel.vue +10 -7
  50. package/src/components/wt-filters-panel-wrapper/__tests__/WtFiltersPanelWrapper.spec.js +4 -8
  51. package/src/components/wt-icon/wt-icon.vue +0 -1
  52. package/src/components/wt-indicator/__tests__/WtIndicator.spec.js +3 -2
  53. package/src/components/wt-indicator/wt-indicator.vue +10 -1
  54. package/src/components/wt-input/wt-input.vue +7 -10
  55. package/src/components/wt-item-link/wt-item-link.vue +7 -4
  56. package/src/components/wt-navigation-bar/__tests__/WtNavigationBar.spec.js +7 -15
  57. package/src/components/wt-navigation-bar/wt-navigation-bar.vue +7 -7
  58. package/src/components/wt-notification/wt-notification.vue +1 -2
  59. package/src/components/wt-notifications-bar/__tests__/WtNotificationsBar.spec.js +6 -3
  60. package/src/components/wt-notifications-bar/wt-notifications-bar.vue +4 -1
  61. package/src/components/wt-page-wrapper/__tests__/WtPageWrapper.spec.js +1 -2
  62. package/src/components/wt-pagination/wt-pagination.vue +1 -3
  63. package/src/components/wt-player/scripts/__tests__/createPlyrURL.spec.js +4 -8
  64. package/src/components/wt-player/wt-player.vue +13 -4
  65. package/src/components/wt-popup/wt-popup.vue +2 -1
  66. package/src/components/wt-search-bar/wt-search-bar.vue +1 -1
  67. package/src/components/wt-select/mixins/multiselectMixin.js +2 -5
  68. package/src/components/wt-select/wt-select.vue +12 -11
  69. package/src/components/wt-slider/wt-slider.vue +4 -2
  70. package/src/components/wt-status-select/wt-status-select.vue +10 -6
  71. package/src/components/wt-stepper/wt-stepper.vue +6 -4
  72. package/src/components/wt-switcher/wt-switcher.vue +1 -3
  73. package/src/components/wt-table/__tests__/WtTable.spec.js +2 -5
  74. package/src/components/wt-table/wt-table.vue +18 -16
  75. package/src/components/wt-table-column-select/wt-table-column-select.vue +9 -8
  76. package/src/components/wt-tabs/wt-tabs.vue +1 -3
  77. package/src/components/wt-tags-input/mixin/taggableMixin.js +7 -7
  78. package/src/components/wt-textarea/__tests__/WtTextarea.spec.js +2 -4
  79. package/src/components/wt-textarea/wt-textarea.vue +3 -2
  80. package/src/components/wt-timepicker/wt-timepicker.vue +1 -3
  81. package/src/components/wt-tooltip/_internals/useTooltipTriggerSubscriptions.js +1 -3
  82. package/src/components/wt-tooltip/_internals/wt-tooltip-floating.vue +8 -12
  83. package/src/components/wt-tooltip/wt-tooltip.vue +13 -13
  84. package/src/composables/useCachedInterval/__tests__/useCachedInterval.spec.js +6 -4
  85. package/src/composables/useCachedInterval/useCachedInterval.js +3 -8
  86. package/src/composables/useRepresentableAgentPauseCause/__tests__/useRepresentableAgentPauseCause.spec.js +11 -33
  87. package/src/composables/useRepresentableAgentPauseCause/useRepresentableAgentPauseCause.js +11 -9
  88. package/src/enums/WebitelApplications/AdminSections.enum.js +28 -28
  89. package/src/enums/WebitelApplications/CrmSections.enum.js +1 -1
  90. package/src/locale/en/en.js +12 -15
  91. package/src/locale/es/es.js +4 -8
  92. package/src/locale/kz/kz.js +5 -7
  93. package/src/locale/ru/ru.js +7 -11
  94. package/src/locale/ua/ua.js +13 -17
  95. package/src/mixins/dataFilterMixins/__tests__/enumFilterMixin.spec.js +1 -2
  96. package/src/mixins/dataFilterMixins/__tests__/sortFilterMixin.spec.js +4 -2
  97. package/src/mixins/dataFilterMixins/__tests__/urlControllerMixin.spec.js +4 -1
  98. package/src/mixins/dataFilterMixins/_urlControllerMixin/_urlControllerMixin.js +1 -1
  99. package/src/mixins/dataFilterMixins/apiFilterMixin.js +1 -2
  100. package/src/mixins/dataFilterMixins/baseFilterMixin/baseFilterMixin.js +1 -2
  101. package/src/mixins/dataFilterMixins/enumFilterMixin.js +5 -6
  102. package/src/mixins/dataFilterMixins/paginationFilterMixin.js +1 -2
  103. package/src/mixins/dataFilterMixins/sortFilterMixin.js +1 -4
  104. package/src/mixins/validationMixin/__tests__/validationMixin.spec.js +1 -2
  105. package/src/mixins/validationMixin/useValidation.js +25 -19
  106. package/src/mixins/validationMixin/validationMixin.js +22 -10
  107. package/src/modules/AgentStatusSelect/api/pause-cause.js +3 -11
  108. package/src/modules/AgentStatusSelect/components/__tests__/wt-cc-agent-status-select.spec.js +16 -18
  109. package/src/modules/AgentStatusSelect/components/__tests__/wt-cc-pause-cause-popup.spec.js +1 -2
  110. package/src/modules/AgentStatusSelect/components/_internals/wt-cc-pause-cause-popup.vue +12 -12
  111. package/src/modules/AgentStatusSelect/components/_internals/wt-cc-status-select-error-popup.vue +0 -1
  112. package/src/modules/AgentStatusSelect/components/wt-cc-agent-status-select.vue +20 -7
  113. package/src/modules/Appearance/components/__tests__/wt-dark-mode-switcher.spec.js +2 -4
  114. package/src/modules/Appearance/components/wt-dark-mode-switcher.vue +0 -1
  115. package/src/modules/AuditForm/components/__tests__/audit-form-question-read-wrapper.spec.js +1 -2
  116. package/src/modules/AuditForm/components/__tests__/audit-form-question-write-wrapper.spec.js +15 -25
  117. package/src/modules/AuditForm/components/__tests__/audit-form.spec.js +11 -20
  118. package/src/modules/AuditForm/components/audit-form-question-read-wrapper.vue +1 -4
  119. package/src/modules/AuditForm/components/audit-form-question-write-wrapper.vue +4 -7
  120. package/src/modules/AuditForm/components/audit-form-question.vue +18 -17
  121. package/src/modules/AuditForm/components/audit-form.vue +12 -14
  122. package/src/modules/AuditForm/components/questions/options/__tests__/audit-form-question-options-write-row.spec.js +1 -2
  123. package/src/modules/AuditForm/components/questions/options/__tests__/audit-form-question-options.spec.js +1 -3
  124. package/src/modules/AuditForm/components/questions/options/audit-form-question-options-write-row.vue +11 -15
  125. package/src/modules/AuditForm/components/questions/options/audit-form-question-options.vue +1 -4
  126. package/src/modules/AuditForm/components/questions/score/audit-form-question-score.vue +16 -20
  127. package/src/modules/AuditForm/schemas/AuditFormQuestionOptionsSchema.js +1 -3
  128. package/src/modules/CSVExport/CSVExport.js +3 -7
  129. package/src/modules/CSVExport/XLSExport.js +6 -7
  130. package/src/modules/CSVExport/__tests__/CSVExport.spec.js +1 -2
  131. package/src/modules/CSVExport/mixins/exportCSVMixin.js +2 -5
  132. package/src/modules/CSVExport/mixins/exportXLSMixin.js +2 -4
  133. package/src/modules/CardStoreModule/store/CardStoreModule.js +2 -6
  134. package/src/modules/DeleteConfirmationPopup/__tests__/delete-confirmation-popup.spec.js +13 -10
  135. package/src/modules/DeleteConfirmationPopup/components/delete-confirmation-popup.vue +5 -14
  136. package/src/modules/FilesExport/FilesExport.js +4 -3
  137. package/src/modules/FilesExport/__tests__/FilesExport.spec.js +12 -12
  138. package/src/modules/FilesExport/mixins/exportFilesMixin.js +6 -7
  139. package/src/modules/FilesExport/scripts/generateMediaURL.js +1 -2
  140. package/src/modules/Filters/classes/BaseFilterSchema.js +21 -25
  141. package/src/modules/Filters/components/filter-pagination.vue +7 -3
  142. package/src/modules/Filters/components/filter-search.vue +21 -12
  143. package/src/modules/Filters/components/filter-table-fields.vue +1 -3
  144. package/src/modules/Filters/scripts/getters/index.js +1 -5
  145. package/src/modules/Filters/scripts/getters/queryGetter.js +2 -3
  146. package/src/modules/Filters/scripts/restores/index.js +1 -4
  147. package/src/modules/Filters/scripts/setters/index.js +1 -5
  148. package/src/modules/Filters/scripts/setters/querySetter.js +24 -22
  149. package/src/modules/Filters/scripts/utils/changeRouteQuery.js +16 -15
  150. package/src/modules/Filters/store/FiltersStoreModule.js +51 -45
  151. package/src/modules/Filters/store/__tests__/FiltersStoreModule.spec.js +51 -45
  152. package/src/modules/Notifications/store/NotificationsStoreModule.js +41 -38
  153. package/src/modules/Notifications/store/__tests__/NotificationsStoreModule.actions.spec.js +6 -6
  154. package/src/modules/QueryFilters/api/defaults.js +2 -3
  155. package/src/modules/QueryFilters/classes/ApiFilterSchema.js +1 -4
  156. package/src/modules/QueryFilters/classes/EnumFilterSchema.js +1 -4
  157. package/src/modules/QueryFilters/components/__tests__/filter-datetime.spec.js +1 -2
  158. package/src/modules/QueryFilters/components/__tests__/filter-from-to.spec.js +2 -4
  159. package/src/modules/QueryFilters/components/__tests__/filter-search.spec.js +2 -4
  160. package/src/modules/QueryFilters/components/filter-table-fields.vue +1 -5
  161. package/src/modules/QueryFilters/mixins/__tests__/apiFilterMixin.spec.js +4 -3
  162. package/src/modules/QueryFilters/mixins/__tests__/enumFilterMixin.spec.js +2 -4
  163. package/src/modules/QueryFilters/mixins/__tests__/sortFilterMixin.spec.js +4 -2
  164. package/src/modules/QueryFilters/mixins/__tests__/urlControllerMixin.spec.js +4 -1
  165. package/src/modules/QueryFilters/mixins/_urlControllerMixin/_urlControllerMixin.js +1 -1
  166. package/src/modules/QueryFilters/mixins/apiFilterMixin.js +1 -1
  167. package/src/modules/QueryFilters/mixins/baseFilterMixin/baseFilterMixin.js +4 -2
  168. package/src/modules/QueryFilters/mixins/enumFilterMixin.js +9 -11
  169. package/src/modules/QueryFilters/mixins/paginationFilterMixin.js +2 -4
  170. package/src/modules/QueryFilters/mixins/sortFilterMixin.js +2 -5
  171. package/src/modules/QueryFilters/store/QueryFiltersStoreModule.js +13 -17
  172. package/src/modules/QueryFilters/store/__tests__/QueryFiltersStoreModule.spec.js +15 -16
  173. package/src/modules/TableStoreModule/store/TableStoreModule.js +14 -33
  174. package/src/modules/TableStoreModule/store/__tests__/TableStoreModule.spec.js +69 -83
  175. package/src/modules/Userinfo/api/userinfo.js +6 -19
  176. package/src/modules/Userinfo/classes/ApplicationsAccess.js +5 -12
  177. package/src/modules/Userinfo/store/UserinfoStoreModule.js +38 -41
  178. package/src/plugins/breakpoint/breakpoint.plugin.js +11 -16
  179. package/src/scripts/__tests__/caseConverters.spec.js +1 -4
  180. package/src/scripts/__tests__/debounce.spec.js +3 -1
  181. package/src/scripts/__tests__/prettifyFileSize.spec.js +2 -2
  182. package/src/scripts/__tests__/preventHiddenPageCallsDecorator.spec.js +7 -4
  183. package/src/scripts/__tests__/updateObject.spec.js +3 -5
  184. package/src/scripts/caseConverters.js +22 -38
  185. package/src/scripts/debounce.js +1 -5
  186. package/src/scripts/editProxy.js +8 -7
  187. package/src/scripts/prettifyFileSize.js +1 -1
  188. package/src/scripts/preventHiddenPageCallsDecorator.js +3 -6
  189. package/src/store/BaseStoreModules/ApiStoreModule.js +7 -33
  190. package/src/store/BaseStoreModules/BaseStoreModule.js +14 -23
  191. package/src/store/BaseStoreModules/__tests__/BaseStoreModule.spec.js +7 -28
  192. package/src/store/helpers/getNamespacedState.js +2 -4
  193. package/src/store/new/modules/apiStoreModule/apiStoreModule.js +7 -27
  194. package/src/store/new/modules/cardStoreModule/cardStoreModule.js +0 -1
  195. package/src/store/new/modules/tableStoreModule/__tests__/tableStoreModule.spec.js +64 -77
  196. package/src/store/new/modules/tableStoreModule/tableStoreModule.js +12 -29
  197. package/src/tests/mocks/axiosMock.js +25 -19
  198. package/src/validators/decimalValidator.js +5 -4
  199. package/src/validators/websocketValidator/__tests__/websocketValidator.spec.js +1 -2
  200. package/src/validators/websocketValidator/websocketValidator.js +1 -1
@@ -1,7 +1,7 @@
1
1
  import updateObject from '../updateObject.js';
2
2
 
3
3
  describe('updateObject', () => {
4
- it('doesn\'t mutate original object', () => {
4
+ it("doesn't mutate original object", () => {
5
5
  const original = { jest: 'jest' };
6
6
  updateObject({ obj: original, path: 'jest', value: '123' });
7
7
  expect(original.jest).toBe('jest');
@@ -9,13 +9,11 @@ describe('updateObject', () => {
9
9
  it('changes shallow value', () => {
10
10
  const original = { jest: 'jest' };
11
11
  const result = { jest: 'huest' };
12
- expect(updateObject({ obj: original, path: 'jest', value: 'huest' }))
13
- .toEqual(result);
12
+ expect(updateObject({ obj: original, path: 'jest', value: 'huest' })).toEqual(result);
14
13
  });
15
14
  it('changes deep value', () => {
16
15
  const original = { jest: { deep: 'jest' } };
17
16
  const result = { jest: { deep: 'huest' } };
18
- expect(updateObject({ obj: original, path: 'jest.deep', value: 'huest' }))
19
- .toEqual(result);
17
+ expect(updateObject({ obj: original, path: 'jest.deep', value: 'huest' })).toEqual(result);
20
18
  });
21
19
  });
@@ -1,36 +1,20 @@
1
- export const snakeToCamel = (str) => str.replace(
2
- /([a-z])([_])([a-z])/g,
3
- (group, p1, p2, p3) => [p1, p3.toUpperCase()].join(''),
4
- );
1
+ export const snakeToCamel = (str) =>
2
+ str.replace(/([a-z])([_])([a-z])/g, (group, p1, p2, p3) => [p1, p3.toUpperCase()].join(''));
5
3
 
6
- export const camelToSnake = (str) => str.replace(
7
- /([a-z])([A-Z])/g,
8
- (group, p1, p2) => [p1, '_', p2.toLowerCase()].join(''),
9
- );
4
+ export const camelToSnake = (str) =>
5
+ str.replace(/([a-z])([A-Z])/g, (group, p1, p2) => [p1, '_', p2.toLowerCase()].join(''));
10
6
 
11
- export const kebabToCamel = (str) => str.replace(
12
- /([-_][a-z])/g,
13
- (group) => group.toUpperCase()
14
- .replace('-', ''),
15
- );
7
+ export const kebabToCamel = (str) =>
8
+ str.replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace('-', ''));
16
9
 
17
- export const camelToKebab = (str) => str.replace(
18
- /([A-Z])/g,
19
- (group) => group.toLowerCase()
20
- .replace('', '-'),
21
- );
10
+ export const camelToKebab = (str) =>
11
+ str.replace(/([A-Z])/g, (group) => group.toLowerCase().replace('', '-'));
22
12
 
23
- export const kebabToSnake = (str) => str.replace(
24
- /([-_][a-z])/g,
25
- (group) => group
26
- .replace('-', '_'),
27
- );
13
+ export const kebabToSnake = (str) =>
14
+ str.replace(/([-_][a-z])/g, (group) => group.replace('-', '_'));
28
15
 
29
- export const snakeToKebab = (str) => str.replace(
30
- /([-_][a-z])/g,
31
- (group) => group
32
- .replace('_', '-'),
33
- );
16
+ export const snakeToKebab = (str) =>
17
+ str.replace(/([-_][a-z])/g, (group) => group.replace('_', '-'));
34
18
 
35
19
  export const objSnakeToCamel = (obj, skipKeys = []) => {
36
20
  if (!obj) return obj;
@@ -44,16 +28,16 @@ export const objSnakeToCamel = (obj, skipKeys = []) => {
44
28
  return value; // number
45
29
  });
46
30
  }
47
- Object.keys(obj)
48
- .forEach((oldKey) => {
31
+ Object.keys(obj).forEach((oldKey) => {
49
32
  if (skipKeys.includes(oldKey)) {
50
33
  newObj[oldKey] = obj[oldKey];
51
34
  } else {
52
35
  const newKey = snakeToCamel(oldKey);
53
36
  let value = obj[oldKey];
54
- if (Array.isArray(value) ||
55
- (value !== null && value !== undefined && value.constructor ===
56
- Object)) {
37
+ if (
38
+ Array.isArray(value) ||
39
+ (value !== null && value !== undefined && value.constructor === Object)
40
+ ) {
57
41
  value = objSnakeToCamel(value, skipKeys);
58
42
  }
59
43
  newObj[newKey] = value;
@@ -75,16 +59,16 @@ export const objCamelToSnake = (obj, skipKeys = []) => {
75
59
  return value; // number
76
60
  });
77
61
  }
78
- Object.keys(obj)
79
- .forEach((oldKey) => {
62
+ Object.keys(obj).forEach((oldKey) => {
80
63
  if (skipKeys.includes(oldKey)) {
81
64
  newObj[oldKey] = obj[oldKey];
82
65
  } else {
83
66
  const newKey = camelToSnake(oldKey);
84
67
  let value = obj[oldKey];
85
- if (Array.isArray(value) ||
86
- (value !== null && value !== undefined && value.constructor ===
87
- Object)) {
68
+ if (
69
+ Array.isArray(value) ||
70
+ (value !== null && value !== undefined && value.constructor === Object)
71
+ ) {
88
72
  value = objCamelToSnake(value, skipKeys);
89
73
  }
90
74
  newObj[newKey] = value;
@@ -1,9 +1,5 @@
1
1
  import lodashDebounce from 'lodash/debounce.js';
2
2
 
3
- const debounce = (
4
- fn,
5
- wait = 1000,
6
- options,
7
- ) => lodashDebounce(fn, wait, options);
3
+ const debounce = (fn, options, wait = 1000) => lodashDebounce(fn, wait, options);
8
4
 
9
5
  export default debounce;
@@ -1,9 +1,10 @@
1
- const editProxy = (item) => new Proxy(item, {
2
- set(obj, prop, value) {
3
- obj._dirty = true;
4
- obj[prop] = value;
5
- return obj;
6
- },
7
- });
1
+ const editProxy = (item) =>
2
+ new Proxy(item, {
3
+ set(obj, prop, value) {
4
+ obj._dirty = true;
5
+ obj[prop] = value;
6
+ return obj;
7
+ },
8
+ });
8
9
 
9
10
  export default editProxy;
@@ -5,7 +5,7 @@ const prettifyFileSize = (size) => {
5
5
  const k = 1024;
6
6
  const sizes = ['b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb'];
7
7
  const i = Math.floor(Math.log(size) / Math.log(k));
8
- return `${parseFloat((size / k ** i).toFixed(2))} ${sizes[i]}`;
8
+ return `${Number.parseFloat((size / k ** i).toFixed(2))} ${sizes[i]}`;
9
9
  };
10
10
 
11
11
  export default prettifyFileSize;
@@ -1,8 +1,5 @@
1
- const isPageHidden = () => (
2
- document.hidden || document.msHidden || document.webkitHidden ||
3
- document.mozHidden
4
- );
1
+ const isPageHidden = () =>
2
+ document.hidden || document.msHidden || document.webkitHidden || document.mozHidden;
5
3
 
6
- const preventHiddenPageCallsDecorator = (method) => (args) => isPageHidden() ||
7
- method(args);
4
+ const preventHiddenPageCallsDecorator = (method) => (args) => isPageHidden() || method(args);
8
5
  export default preventHiddenPageCallsDecorator;
@@ -1,17 +1,11 @@
1
1
  import BaseStoreModule from './BaseStoreModule.js';
2
2
 
3
- const getParentIdFromContext = (context) => (
4
- context?.getters?.PARENT_ID || context?.state?.parentId
5
- );
3
+ const getParentIdFromContext = (context) => context?.getters?.PARENT_ID || context?.state?.parentId;
6
4
 
7
5
  export default class ApiStoreModule extends BaseStoreModule {
8
6
  generateAPIActions(api) {
9
7
  if (!api) throw new ReferenceError('pass API module!');
10
- this.actions
11
- .GET_LIST = (
12
- _,
13
- { context: callerContext = {}, params = {} },
14
- ) => {
8
+ this.actions.GET_LIST = (_, { context: callerContext = {}, params = {} }) => {
15
9
  if (!api.getList) throw Error('No API "getList" method provided');
16
10
  return api.getList({
17
11
  ...callerContext.state,
@@ -20,11 +14,7 @@ export default class ApiStoreModule extends BaseStoreModule {
20
14
  });
21
15
  };
22
16
 
23
- this.actions
24
- .GET_ITEM = (
25
- _,
26
- { context: callerContext = {}, params = {} } = {},
27
- ) => {
17
+ this.actions.GET_ITEM = (_, { context: callerContext = {}, params = {} } = {}) => {
28
18
  if (!api.get) throw Error('No API "get" method provided');
29
19
  return api.get({
30
20
  ...callerContext.state,
@@ -33,11 +23,7 @@ export default class ApiStoreModule extends BaseStoreModule {
33
23
  });
34
24
  };
35
25
 
36
- this.actions
37
- .POST_ITEM = (
38
- _,
39
- { context: callerContext = {}, ...rest } = {},
40
- ) => {
26
+ this.actions.POST_ITEM = (_, { context: callerContext = {}, ...rest } = {}) => {
41
27
  if (!api.add) throw Error('No API "add" method provided');
42
28
  return api.add({
43
29
  ...callerContext.state,
@@ -46,11 +32,7 @@ export default class ApiStoreModule extends BaseStoreModule {
46
32
  });
47
33
  };
48
34
 
49
- this.actions
50
- .PATCH_ITEM = (
51
- _,
52
- { context: callerContext = {}, id, changes, ...rest },
53
- ) => {
35
+ this.actions.PATCH_ITEM = (_, { context: callerContext = {}, id, changes, ...rest }) => {
54
36
  if (!api.patch) throw Error('No API "patch" method provided');
55
37
  return api.patch({
56
38
  ...callerContext.state,
@@ -61,11 +43,7 @@ export default class ApiStoreModule extends BaseStoreModule {
61
43
  });
62
44
  };
63
45
 
64
- this.actions
65
- .UPD_ITEM = (
66
- _,
67
- { context: callerContext = {}, ...rest } = {},
68
- ) => {
46
+ this.actions.UPD_ITEM = (_, { context: callerContext = {}, ...rest } = {}) => {
69
47
  if (!api.update) throw Error('No API "update" method provided');
70
48
  return api.update({
71
49
  ...callerContext.state,
@@ -74,11 +52,7 @@ export default class ApiStoreModule extends BaseStoreModule {
74
52
  });
75
53
  };
76
54
 
77
- this.actions
78
- .DELETE_ITEM = (
79
- _,
80
- { context: callerContext = {}, id, ...rest },
81
- ) => {
55
+ this.actions.DELETE_ITEM = (_, { context: callerContext = {}, id, ...rest }) => {
82
56
  if (!api.delete) throw Error('No API "delete" method provided');
83
57
  return api.delete({
84
58
  ...callerContext.state,
@@ -18,24 +18,15 @@ export default class BaseStoreModule {
18
18
 
19
19
  generateAPIActions() {
20
20
  if (!this._APIModule) throw new ReferenceError('attach API module first!');
21
- this.actions.GET_LIST = (
22
- context,
23
- params = {},
24
- ) => this._APIModule.getList({ ...context.state, ...params });
25
- this.actions.GET_ITEM = (
26
- context,
27
- params = {},
28
- ) => this._APIModule.get({ ...context.state, ...params });
21
+ this.actions.GET_LIST = (context, params = {}) =>
22
+ this._APIModule.getList({ ...context.state, ...params });
23
+ this.actions.GET_ITEM = (context, params = {}) =>
24
+ this._APIModule.get({ ...context.state, ...params });
29
25
  this.actions.POST_ITEM = (context) => this._APIModule.add(context.state);
30
- this.actions.PATCH_ITEM = (
31
- context,
32
- { id, changes },
33
- ) => (this._APIModule.patch({ ...context.state, id, changes }));
26
+ this.actions.PATCH_ITEM = (context, { id, changes }) =>
27
+ this._APIModule.patch({ ...context.state, id, changes });
34
28
  this.actions.UPD_ITEM = (context) => this._APIModule.update(context.state);
35
- this.actions.DELETE_ITEM = (
36
- context,
37
- id,
38
- ) => this._APIModule.delete({ ...context.state, id });
29
+ this.actions.DELETE_ITEM = (context, id) => this._APIModule.delete({ ...context.state, id });
39
30
  return this;
40
31
  }
41
32
 
@@ -45,13 +36,13 @@ export default class BaseStoreModule {
45
36
  }
46
37
 
47
38
  getModule({
48
- state = {},
49
- getters = {},
50
- actions = {},
51
- mutations = {},
52
- modules = {},
53
- namespaced = true,
54
- } = {}) {
39
+ state = {},
40
+ getters = {},
41
+ actions = {},
42
+ mutations = {},
43
+ modules = {},
44
+ namespaced = true,
45
+ } = {}) {
55
46
  return {
56
47
  namespaced,
57
48
  state: { ...this.state, ...state },
@@ -15,10 +15,7 @@ describe('Base Store Module', () => {
15
15
  module = new BaseStoreModule();
16
16
  });
17
17
  it('attaches api module and generates API actions from it', () => {
18
- const _module = module
19
- .attachAPIModule(APIModule)
20
- .generateAPIActions()
21
- .getModule();
18
+ const _module = module.attachAPIModule(APIModule).generateAPIActions().getModule();
22
19
  expect(_module.actions.GET_LIST).toBeTruthy();
23
20
  expect(_module.actions.GET_ITEM).toBeTruthy();
24
21
  expect(_module.actions.POST_ITEM).toBeTruthy();
@@ -31,10 +28,7 @@ describe('Base Store Module', () => {
31
28
  const params = { jest2: 'jest1' };
32
29
  const context = { state };
33
30
  const expectedParams = { jest: 'jest', jest2: 'jest1' };
34
- const _module = module
35
- .attachAPIModule(APIModule)
36
- .generateAPIActions()
37
- .getModule();
31
+ const _module = module.attachAPIModule(APIModule).generateAPIActions().getModule();
38
32
  _module.actions.GET_LIST(context, params);
39
33
  expect(APIModule.getList).toHaveBeenCalledWith(expectedParams);
40
34
  });
@@ -43,10 +37,7 @@ describe('Base Store Module', () => {
43
37
  const params = { jest2: 'jest1' };
44
38
  const context = { state };
45
39
  const expectedParams = { jest: 'jest', jest2: 'jest1' };
46
- const _module = module
47
- .attachAPIModule(APIModule)
48
- .generateAPIActions()
49
- .getModule();
40
+ const _module = module.attachAPIModule(APIModule).generateAPIActions().getModule();
50
41
  _module.actions.GET_ITEM(context, params);
51
42
  expect(APIModule.get).toHaveBeenCalledWith(expectedParams);
52
43
  });
@@ -54,10 +45,7 @@ describe('Base Store Module', () => {
54
45
  const state = { jest: 'jest' };
55
46
  const context = { state };
56
47
  const expectedParams = { jest: 'jest' };
57
- const _module = module
58
- .attachAPIModule(APIModule)
59
- .generateAPIActions()
60
- .getModule();
48
+ const _module = module.attachAPIModule(APIModule).generateAPIActions().getModule();
61
49
  _module.actions.POST_ITEM(context);
62
50
  expect(APIModule.add).toHaveBeenCalledWith(expectedParams);
63
51
  });
@@ -70,10 +58,7 @@ describe('Base Store Module', () => {
70
58
  id: '1',
71
59
  changes: { jest: 'my change!' },
72
60
  };
73
- const _module = module
74
- .attachAPIModule(APIModule)
75
- .generateAPIActions()
76
- .getModule();
61
+ const _module = module.attachAPIModule(APIModule).generateAPIActions().getModule();
77
62
  _module.actions.PATCH_ITEM(context, params);
78
63
  expect(APIModule.patch).toHaveBeenCalledWith(expectedParams);
79
64
  });
@@ -81,10 +66,7 @@ describe('Base Store Module', () => {
81
66
  const state = { jest: 'jest' };
82
67
  const context = { state };
83
68
  const expectedParams = { jest: 'jest' };
84
- const _module = module
85
- .attachAPIModule(APIModule)
86
- .generateAPIActions()
87
- .getModule();
69
+ const _module = module.attachAPIModule(APIModule).generateAPIActions().getModule();
88
70
  _module.actions.UPD_ITEM(context);
89
71
  expect(APIModule.update).toHaveBeenCalledWith(expectedParams);
90
72
  });
@@ -93,10 +75,7 @@ describe('Base Store Module', () => {
93
75
  const params = '1';
94
76
  const context = { state };
95
77
  const expectedParams = { jest: 'jest', id: '1' };
96
- const _module = module
97
- .attachAPIModule(APIModule)
98
- .generateAPIActions()
99
- .getModule();
78
+ const _module = module.attachAPIModule(APIModule).generateAPIActions().getModule();
100
79
  _module.actions.DELETE_ITEM(context, params);
101
80
  expect(APIModule.delete).toHaveBeenCalledWith(expectedParams);
102
81
  });
@@ -1,6 +1,4 @@
1
- const getNamespacedState = (state, namespace) => (
2
- namespace.split('/')
3
- .reduce((subState, subNamespace) => subState[subNamespace], state)
4
- );
1
+ const getNamespacedState = (state, namespace) =>
2
+ namespace.split('/').reduce((subState, subNamespace) => subState[subNamespace], state);
5
3
 
6
4
  export default getNamespacedState;
@@ -1,6 +1,4 @@
1
- const getParentIdFromContext = (context) => (
2
- context?.getters?.PARENT_ID || context?.state?.parentId
3
- );
1
+ const getParentIdFromContext = (context) => context?.getters?.PARENT_ID || context?.state?.parentId;
4
2
 
5
3
  const state = () => ({
6
4
  api: null,
@@ -9,10 +7,7 @@ const state = () => ({
9
7
  const getters = {};
10
8
 
11
9
  const actions = {
12
- GET_LIST: (
13
- apiContext,
14
- { context: callerContext = {}, params = {} },
15
- ) => {
10
+ GET_LIST: (apiContext, { context: callerContext = {}, params = {} }) => {
16
11
  if (!apiContext.state.api.getList) throw Error('No API "getList" method provided');
17
12
  return apiContext.state.api.getList({
18
13
  ...callerContext.state,
@@ -21,10 +16,7 @@ const actions = {
21
16
  });
22
17
  },
23
18
 
24
- GET_ITEM: (
25
- apiContext,
26
- { context: callerContext = {}, params = {} } = {},
27
- ) => {
19
+ GET_ITEM: (apiContext, { context: callerContext = {}, params = {} } = {}) => {
28
20
  if (!apiContext.state.api.get) throw Error('No API "get" method provided');
29
21
  return apiContext.state.api.get({
30
22
  ...callerContext.state,
@@ -33,10 +25,7 @@ const actions = {
33
25
  });
34
26
  },
35
27
 
36
- POST_ITEM: (
37
- apiContext,
38
- { context: callerContext = {}, ...rest } = {},
39
- ) => {
28
+ POST_ITEM: (apiContext, { context: callerContext = {}, ...rest } = {}) => {
40
29
  if (!apiContext.state.api.add) throw Error('No API "add" method provided');
41
30
  return apiContext.state.api.add({
42
31
  ...callerContext.state,
@@ -45,10 +34,7 @@ const actions = {
45
34
  });
46
35
  },
47
36
 
48
- UPD_ITEM: (
49
- apiContext,
50
- { context: callerContext = {}, ...rest } = {},
51
- ) => {
37
+ UPD_ITEM: (apiContext, { context: callerContext = {}, ...rest } = {}) => {
52
38
  if (!apiContext.state.api.update) throw Error('No API "update" method provided');
53
39
  return apiContext.state.api.update({
54
40
  ...callerContext.state,
@@ -57,10 +43,7 @@ const actions = {
57
43
  });
58
44
  },
59
45
 
60
- PATCH_ITEM: (
61
- apiContext,
62
- { context: callerContext = {}, id, changes, ...rest },
63
- ) => {
46
+ PATCH_ITEM: (apiContext, { context: callerContext = {}, id, changes, ...rest }) => {
64
47
  if (!apiContext.state.api.patch) throw Error('No API "patch" method provided');
65
48
  return apiContext.state.api.patch({
66
49
  ...callerContext.state,
@@ -71,10 +54,7 @@ const actions = {
71
54
  });
72
55
  },
73
56
 
74
- DELETE_ITEM: (
75
- apiContext,
76
- { context: callerContext = {}, id, ...rest },
77
- ) => {
57
+ DELETE_ITEM: (apiContext, { context: callerContext = {}, id, ...rest }) => {
78
58
  if (!apiContext.state.api.delete) throw Error('No API "delete" method provided');
79
59
  return apiContext.state.api.delete({
80
60
  ...callerContext.state,
@@ -71,4 +71,3 @@ export default () => ({
71
71
  actions,
72
72
  mutations,
73
73
  });
74
-