@webitel/ui-sdk 26.8.55 → 26.8.56

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.
@@ -1,4 +1,4 @@
1
- import "./components-DNSY1_s4.js";
1
+ import "./components-CWSUHV29.js";
2
2
  import { t as e } from "./_plugin-vue_export-helper-B3ysoDQm.js";
3
3
  import { l as t } from "./enums-DY3jIXFF.js";
4
4
  import { t as n } from "./wt-button-2_aOV7LX.js";
@@ -1,4 +1,4 @@
1
- import { C as e, i as t } from "./components-DNSY1_s4.js";
1
+ import { C as e, i as t } from "./components-CWSUHV29.js";
2
2
  import { t as n } from "./_plugin-vue_export-helper-B3ysoDQm.js";
3
3
  import { t as r } from "./displayText-CtaxzaBz.js";
4
4
  import { Fragment as i, computed as a, createCommentVNode as o, createElementBlock as s, createTextVNode as c, createVNode as l, defineComponent as u, openBlock as d, renderList as f, renderSlot as p, toDisplayString as m, unref as h, withCtx as g } from "vue";
@@ -1,6 +1,6 @@
1
1
  import { t as e } from "./rolldown-runtime-BEcgMyyN.js";
2
- import { n as t, r as n } from "./clients-Ck0KwDIR.js";
3
- import { T as r, n as i, w as a } from "./components-DNSY1_s4.js";
2
+ import { n as t, r as n } from "./clients-CWSXQd89.js";
3
+ import { T as r, n as i, w as a } from "./components-CWSUHV29.js";
4
4
  import { t as o } from "./vue-i18n-Db_oYfO8.js";
5
5
  import { n as s } from "./useEventBus-B-ZeklLu.js";
6
6
  import { createBlock as c, createTextVNode as l, createVNode as u, defineComponent as d, mergeProps as f, onMounted as p, openBlock as m, ref as h, resolveComponent as g, toDisplayString as _, unref as v, withCtx as y } from "vue";
@@ -1,5 +1,5 @@
1
- import { t as e } from "./clients-Ck0KwDIR.js";
2
- import { a as t, o as n, r, s as i } from "./components-DNSY1_s4.js";
1
+ import { t as e } from "./clients-CWSXQd89.js";
2
+ import { a as t, o as n, r, s as i } from "./components-CWSUHV29.js";
3
3
  import { t as a } from "./enums-DY3jIXFF.js";
4
4
  import { t as o } from "./vue-i18n-Db_oYfO8.js";
5
5
  import { computed as s, createBlock as c, createCommentVNode as l, createVNode as u, defineComponent as d, mergeModels as f, mergeProps as p, openBlock as m, renderSlot as h, resolveComponent as g, unref as _, useModel as v } from "vue";
@@ -1,4 +1,4 @@
1
- import { D as e } from "./components-DNSY1_s4.js";
1
+ import { D as e } from "./components-CWSUHV29.js";
2
2
  import { t } from "./_plugin-vue_export-helper-B3ysoDQm.js";
3
3
  import { l as n } from "./enums-DY3jIXFF.js";
4
4
  import "./wt-button-2_aOV7LX.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "26.8.55",
3
+ "version": "26.8.56",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "npm run docs:dev",
@@ -1,151 +1,2 @@
1
- import {
2
- CreateSourceBody,
3
- getSources,
4
- ListSourcesQueryParams,
5
- UpdateSourceBody,
6
- } from '@webitel/api-services/gen';
7
- import {
8
- // getFieldsToSendFromZodSchema,
9
- getShallowFieldsToSendFromZodSchema,
10
- } from '@webitel/api-services/gen/utils';
11
- import {
12
- getDefaultGetListResponse,
13
- getDefaultGetParams,
14
- } from '../../defaults/index';
15
- import applyTransform, {
16
- camelToSnake,
17
- merge,
18
- notify,
19
- sanitize,
20
- snakeToCamel,
21
- } from '../../transformers/index';
22
- import type {
23
- AddItemParams,
24
- ApiParams,
25
- DeleteItemParams,
26
- GetItemParams,
27
- UpdateItemParams,
28
- } from '../_shared/types';
29
-
30
- const sourceService = getSources();
31
-
32
- const getSourcesList = async (params: ApiParams) => {
33
- const fieldsToSend = getShallowFieldsToSendFromZodSchema(
34
- ListSourcesQueryParams,
35
- );
36
-
37
- const { page, size, fields, sort, id, q, type } = applyTransform(params, [
38
- merge(getDefaultGetParams()),
39
- sanitize(fieldsToSend),
40
- camelToSnake(),
41
- ]);
42
-
43
- try {
44
- const response = await sourceService.listSources({
45
- page,
46
- size,
47
- fields,
48
- sort,
49
- id,
50
- q: q || params.search,
51
- type,
52
- });
53
- const { items, next } = applyTransform(response.data, [
54
- merge(getDefaultGetListResponse()),
55
- ]);
56
- return {
57
- items: applyTransform(items, []),
58
- next,
59
- };
60
- } catch (err) {
61
- throw applyTransform(err, [
62
- notify,
63
- ]);
64
- }
65
- };
66
-
67
- const getSource = async ({ itemId: id }: GetItemParams<string>) => {
68
- const itemResponseHandler = (item: ApiParams) => item.source; // TODO wtf??
69
-
70
- try {
71
- const response = await sourceService.locateSource(id);
72
- return applyTransform(response.data, [
73
- snakeToCamel(),
74
- itemResponseHandler,
75
- ]);
76
- } catch (err) {
77
- throw applyTransform(err, [
78
- notify,
79
- ]);
80
- }
81
- };
82
-
83
- const addSource = async ({ itemInstance }: AddItemParams) => {
84
- const item = applyTransform(itemInstance, [
85
- sanitize(getShallowFieldsToSendFromZodSchema(CreateSourceBody)),
86
- camelToSnake(),
87
- ]);
88
- try {
89
- const response = await sourceService.createSource(item);
90
- return applyTransform(response.data, [
91
- snakeToCamel(),
92
- ]);
93
- } catch (err) {
94
- throw applyTransform(err, [
95
- notify,
96
- ]);
97
- }
98
- };
99
-
100
- const updateSource = async ({
101
- itemInstance,
102
- itemId: id,
103
- }: UpdateItemParams<string>) => {
104
- const item = applyTransform(itemInstance, [
105
- camelToSnake(),
106
- sanitize(getShallowFieldsToSendFromZodSchema(UpdateSourceBody)),
107
- ]);
108
-
109
- try {
110
- const response = await sourceService.updateSource(id, item);
111
- return applyTransform(response.data, [
112
- snakeToCamel(),
113
- ]);
114
- } catch (err) {
115
- throw applyTransform(err, [
116
- notify,
117
- ]);
118
- }
119
- };
120
-
121
- const deleteSource = async ({ id }: DeleteItemParams<string>) => {
122
- try {
123
- const response = await sourceService.deleteSource(id);
124
- return applyTransform(response.data, []);
125
- } catch (err) {
126
- throw applyTransform(err, [
127
- notify,
128
- ]);
129
- }
130
- };
131
-
132
- const getLookup = (params: ApiParams) =>
133
- getSourcesList({
134
- ...params,
135
- fields: params.fields || [
136
- 'id',
137
- 'name',
138
- 'type',
139
- ],
140
- });
141
-
142
- const CaseSourcesAPI = {
143
- getList: getSourcesList,
144
- get: getSource,
145
- add: addSource,
146
- update: updateSource,
147
- delete: deleteSource,
148
- getLookup,
149
- };
150
-
151
- export default CaseSourcesAPI;
1
+ /* moved to @webitel/api-services; kept as a re-export for existing importers */
2
+ export { CaseSourcesAPI as default } from '@webitel/api-services/api';
@@ -1,157 +1,2 @@
1
- import { getQuickRepliesService } from '@webitel/api-services/gen';
2
- import {
3
- getDefaultGetListResponse,
4
- getDefaultGetParams,
5
- } from '../../defaults/index';
6
- import applyTransform, {
7
- camelToSnake,
8
- merge,
9
- notify,
10
- sanitize,
11
- snakeToCamel,
12
- starToSearch,
13
- } from '../../transformers/index';
14
- import type {
15
- AddItemParams,
16
- ApiParams,
17
- DeleteItemParams,
18
- GetItemParams,
19
- UpdateItemParams,
20
- } from '../_shared/types';
21
-
22
- const quickReplyService = getQuickRepliesService();
23
-
24
- const fieldsToSend = [
25
- 'name',
26
- 'queues',
27
- 'article',
28
- 'teams',
29
- 'text',
30
- ];
31
-
32
- const getQuickRepliesList = async (params: ApiParams) => {
33
- const fieldsToSend = [
34
- 'page',
35
- 'size',
36
- 'q',
37
- 'sort',
38
- 'fields',
39
- 'id',
40
- ];
41
-
42
- const { page, size, fields, sort, id, q } = applyTransform(params, [
43
- merge(getDefaultGetParams()),
44
- starToSearch('search'),
45
- (params: ApiParams) => ({
46
- ...params,
47
- q: params.search,
48
- }),
49
- sanitize(fieldsToSend),
50
- camelToSnake(),
51
- ]);
52
-
53
- try {
54
- const response = await quickReplyService.searchQuickReplies({
55
- page,
56
- size,
57
- fields,
58
- sort,
59
- id,
60
- q,
61
- });
62
- const { items, next } = applyTransform(response.data, [
63
- merge(getDefaultGetListResponse()),
64
- ]);
65
- return {
66
- items: applyTransform(items, [
67
- snakeToCamel(),
68
- ]),
69
- next,
70
- };
71
- } catch (err) {
72
- throw applyTransform(err, [
73
- notify,
74
- ]);
75
- }
76
- };
77
-
78
- const getQuickReply = async ({ itemId: id }: GetItemParams<number>) => {
79
- try {
80
- const response = await quickReplyService.readQuickReply(id);
81
- return applyTransform(response.data, [
82
- snakeToCamel(),
83
- ]);
84
- } catch (err) {
85
- throw applyTransform(err, [
86
- notify,
87
- ]);
88
- }
89
- };
90
-
91
- const addQuickReply = async ({ itemInstance }: AddItemParams) => {
92
- const item = applyTransform(itemInstance, [
93
- sanitize(fieldsToSend),
94
- camelToSnake(),
95
- ]);
96
- try {
97
- const response = await quickReplyService.createQuickReply(item);
98
- return applyTransform(response.data, [
99
- snakeToCamel(),
100
- ]);
101
- } catch (err) {
102
- throw applyTransform(err, [
103
- notify,
104
- ]);
105
- }
106
- };
107
-
108
- const updateQuickReply = async ({
109
- itemInstance,
110
- itemId: id,
111
- }: UpdateItemParams<number>) => {
112
- const item = applyTransform(itemInstance, [
113
- camelToSnake(),
114
- sanitize(fieldsToSend),
115
- ]);
116
-
117
- try {
118
- const response = await quickReplyService.updateQuickReply(id, item);
119
- return applyTransform(response.data, [
120
- snakeToCamel(),
121
- ]);
122
- } catch (err) {
123
- throw applyTransform(err, [
124
- notify,
125
- ]);
126
- }
127
- };
128
-
129
- const deleteQuickReply = async ({ id }: DeleteItemParams<number>) => {
130
- try {
131
- const response = await quickReplyService.deleteQuickReply(id);
132
- return applyTransform(response.data, []);
133
- } catch (err) {
134
- throw applyTransform(err, [
135
- notify,
136
- ]);
137
- }
138
- };
139
-
140
- const getLookup = (params: ApiParams) =>
141
- getQuickRepliesList({
142
- ...params,
143
- fields: params.fields || [
144
- 'id',
145
- 'name',
146
- ],
147
- });
148
-
149
- const QuickRepliesApi = {
150
- getList: getQuickRepliesList,
151
- get: getQuickReply,
152
- add: addQuickReply,
153
- update: updateQuickReply,
154
- delete: deleteQuickReply,
155
- getLookup,
156
- };
157
- export default QuickRepliesApi;
1
+ /* moved to @webitel/api-services; kept as a re-export for existing importers */
2
+ export { QuickRepliesAPI as default } from '@webitel/api-services/api';
@@ -103,4 +103,64 @@ describe('Enum filter mixin', () => {
103
103
  });
104
104
  expect(wrapper.vm.localizedOptions).toEqual(expectedOptions);
105
105
  });
106
+
107
+ it('Normalizes a snake_case scalar locale and translates using the normalized key', async () => {
108
+ const options = [
109
+ {
110
+ locale: 'vi.snake_case_locale',
111
+ },
112
+ ];
113
+ const expectedOptions = [
114
+ {
115
+ locale: 'vi.snakeCaseLocale',
116
+ name: 'vi.snakeCaseLocale',
117
+ },
118
+ ];
119
+ const wrapper = shallowMount(Component, {
120
+ global: {
121
+ plugins: [
122
+ router,
123
+ ],
124
+ },
125
+ data: () => ({
126
+ options,
127
+ }),
128
+ });
129
+ expect(wrapper.vm.localizedOptions).toEqual(expectedOptions);
130
+ });
131
+
132
+ it('Normalizes only the key element of an array locale, preserving the rest of the translation arguments, and translates using the normalized key', async () => {
133
+ const options = [
134
+ {
135
+ locale: [
136
+ 'vi.snake_case_locale',
137
+ {
138
+ count: 5,
139
+ },
140
+ ],
141
+ },
142
+ ];
143
+ const expectedOptions = [
144
+ {
145
+ locale: [
146
+ 'vi.snakeCaseLocale',
147
+ {
148
+ count: 5,
149
+ },
150
+ ],
151
+ name: 'vi.snakeCaseLocale',
152
+ },
153
+ ];
154
+ const wrapper = shallowMount(Component, {
155
+ global: {
156
+ plugins: [
157
+ router,
158
+ ],
159
+ },
160
+ data: () => ({
161
+ options,
162
+ }),
163
+ });
164
+ expect(wrapper.vm.localizedOptions).toEqual(expectedOptions);
165
+ });
106
166
  });
@@ -1,3 +1,4 @@
1
+ import { snakeToCamel } from '../../../scripts';
1
2
  import baseFilterMixin from './baseFilterMixin/baseFilterMixin.js';
2
3
 
3
4
  export default {
@@ -33,12 +34,26 @@ export default {
33
34
  localizedOptions() {
34
35
  const optsHaveLocale = this.options.length && this.options[0].locale; // just check 1st el
35
36
  if (optsHaveLocale) {
36
- return this.options.map((opt) => ({
37
- ...opt,
38
- name: Array.isArray(opt.locale)
39
- ? this.$t(...opt.locale)
40
- : this.$t(opt.locale),
41
- }));
37
+ return this.options.map((opt) => {
38
+ const isLocaleArray = Array.isArray(opt.locale);
39
+ const normalizedLocale = isLocaleArray
40
+ ? [
41
+ typeof opt.locale[0] === 'string'
42
+ ? snakeToCamel(opt.locale[0])
43
+ : opt.locale[0],
44
+ ...opt.locale.slice(1),
45
+ ]
46
+ : typeof opt.locale === 'string'
47
+ ? snakeToCamel(opt.locale)
48
+ : opt.locale;
49
+ return {
50
+ ...opt,
51
+ locale: normalizedLocale,
52
+ name: isLocaleArray
53
+ ? this.$t(...normalizedLocale)
54
+ : this.$t(normalizedLocale),
55
+ };
56
+ });
42
57
  }
43
58
  return this.options;
44
59
  },
@@ -2,7 +2,7 @@ import {
2
2
  applyTransform,
3
3
  snakeToCamel,
4
4
  } from '@webitel/api-services/api/transformers';
5
- import { getUsers } from '@webitel/api-services/gen';
5
+ import { getUsers } from '@webitel/api-services/gen-wire';
6
6
 
7
7
  const getUserWarnings = async () => {
8
8
  try {