@webitel/ui-sdk 3.2.2 → 3.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "3.2.2",
3
+ "version": "3.2.4",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -8,6 +8,7 @@ import handleUnauthorized from './handleUnauthorized/handleUnauthorized.transfor
8
8
  import notify from './notify/notify.transformer';
9
9
  import sanitize from './sanitize/sanitize.transformer';
10
10
  import generateUrl from './generateUrl/generateUrl.transformer';
11
+ import mergeEach from './mergeEach/mergeEach.transformer';
11
12
 
12
13
  export default applyTransform;
13
14
  export {
@@ -20,4 +21,5 @@ export {
20
21
  handleUnauthorized,
21
22
  sanitize,
22
23
  generateUrl,
24
+ mergeEach,
23
25
  };
@@ -0,0 +1,8 @@
1
+ import merge from 'deepmerge';
2
+
3
+ const mergeEachTransformer = (...args) => (main) => main.map((item) => merge.all([
4
+ ...args,
5
+ item,
6
+ ]));
7
+
8
+ export default mergeEachTransformer;
@@ -1,13 +1,32 @@
1
1
  import eventBus from '../../../scripts/eventBus';
2
2
 
3
- const notifyTransformer = (payload) => {
4
- if (payload instanceof Error) {
3
+ const notifyTransformer = (notificationObject) => {
4
+ /*
5
+ if passed arg is function, then this notification - static content,
6
+ predefined before actual transformer is called in applyTransform flow
7
+ */
8
+ if (typeof notificationObject === 'function') {
9
+ /*
10
+ so, create a callback which will send notification with params, passed to it
11
+ */
12
+ const callback = ({ type, text }) => eventBus.$emit('notification', { type, text });
13
+
14
+ /*
15
+ and, then, return a function, which will be called in main applyTransform flow,
16
+ calling passed arg function with callback, and returning actual notify payload
17
+ */
18
+ return (payload) => {
19
+ notificationObject({ callback });
20
+ return payload;
21
+ };
22
+ }
23
+ if (notificationObject instanceof Error) {
5
24
  eventBus.$emit('notification', {
6
25
  type: 'error',
7
- text: payload.response?.data?.detail || payload.response?.data?.message,
26
+ text: notificationObject.response?.data?.detail || notificationObject.response?.data?.message,
8
27
  });
9
28
  }
10
- return payload;
29
+ return notificationObject;
11
30
  };
12
31
 
13
32
  export default notifyTransformer;