@webitel/api-services 1.0.10 → 1.0.11

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 (100) hide show
  1. package/package.json +1 -1
  2. package/src/api/clients/__tests__/wireParamsCoverage.spec.ts +286 -0
  3. package/src/api/clients/activeCalls/activeCalls.ts +72 -0
  4. package/src/api/clients/agentPauseCauses/agentPauseCauses.ts +182 -0
  5. package/src/api/clients/agentSkills/agentSkills.ts +193 -0
  6. package/src/api/clients/agents/__tests__/agents.wireParams.spec.ts +51 -0
  7. package/src/api/clients/agents/agents.ts +203 -18
  8. package/src/api/clients/auditForms/auditForms.ts +6 -2
  9. package/src/api/clients/auditForms/auditRates.ts +91 -0
  10. package/src/api/clients/backendProfiles/backendProfiles.ts +194 -0
  11. package/src/api/clients/buckets/buckets.ts +21 -25
  12. package/src/api/clients/callHistory/callAnnotations.ts +91 -0
  13. package/src/api/clients/callHistory/callHistory.ts +76 -7
  14. package/src/api/clients/casePriorities/__tests__/casePriorities.spec.ts +50 -0
  15. package/src/api/clients/casePriorities/casePriorities.ts +25 -41
  16. package/src/api/clients/caseStatusConditions/caseStatusConditions.ts +19 -29
  17. package/src/api/clients/caseStatuses/caseStatuses.ts +10 -21
  18. package/src/api/clients/catalog/catalog.ts +2 -8
  19. package/src/api/clients/changelogs/changelogs.ts +8 -0
  20. package/src/api/clients/chatplans/chatplans.ts +173 -0
  21. package/src/api/clients/cognitiveProfiles/cognitiveProfiles.ts +209 -0
  22. package/src/api/clients/communications/communications.ts +38 -42
  23. package/src/api/clients/dialplans/dialplans.ts +197 -0
  24. package/src/api/clients/emailProfiles/emailProfiles.ts +222 -0
  25. package/src/api/clients/fileServices/fileServices.ts +7 -2
  26. package/src/api/clients/flows/flow.ts +54 -43
  27. package/src/api/clients/fts/fts.ts +61 -0
  28. package/src/api/clients/history/transcript/callTranscript.ts +10 -20
  29. package/src/api/clients/importTemplates/importTemplates.ts +180 -0
  30. package/src/api/clients/index.ts +30 -0
  31. package/src/api/clients/lists/blacklistNumbers.ts +155 -0
  32. package/src/api/clients/lists/blacklists.ts +20 -25
  33. package/src/api/clients/logs/logs.ts +157 -0
  34. package/src/api/clients/media/media.ts +19 -15
  35. package/src/api/clients/object/object.ts +3 -14
  36. package/src/api/clients/outboundResourceGroups/outboundResourceGroups.ts +187 -0
  37. package/src/api/clients/outboundResourceGroups/resourcesInGroup.ts +169 -0
  38. package/src/api/clients/outboundResources/outboundResources.ts +225 -0
  39. package/src/api/clients/outboundResources/resourceDisplays.ts +165 -0
  40. package/src/api/clients/pauseTemplates/pauseTemplates.ts +203 -0
  41. package/src/api/clients/queues/__tests__/queueLogs.spec.ts +3 -3
  42. package/src/api/clients/queues/__tests__/queueMembers.spec.ts +4 -4
  43. package/src/api/clients/queues/queueLogs.ts +8 -3
  44. package/src/api/clients/queues/queueMembers.ts +3 -3
  45. package/src/api/clients/queues/queues.ts +52 -0
  46. package/src/api/clients/regions/regions.ts +21 -25
  47. package/src/api/clients/schemaVariables/schemaVariables.ts +167 -0
  48. package/src/api/clients/shiftTemplates/shiftTemplates.ts +176 -0
  49. package/src/api/clients/skills/skillAgents.ts +190 -0
  50. package/src/api/clients/skills/skills.ts +21 -25
  51. package/src/api/clients/storagePolicies/storagePolicies.ts +270 -0
  52. package/src/api/clients/teamHooks/teamHooks.ts +195 -0
  53. package/src/api/clients/teamTriggers/agentTriggers.ts +77 -0
  54. package/src/api/clients/teamTriggers/teamFlows.ts +194 -0
  55. package/src/api/clients/teams/teams.ts +31 -31
  56. package/src/api/clients/triggers/triggerJobs.ts +63 -0
  57. package/src/api/clients/triggers/triggers.ts +266 -0
  58. package/src/api/clients/userSettings/userSettings.ts +8 -9
  59. package/src/api/clients/users/users.ts +2 -0
  60. package/src/api/clients/workingConditions/workingConditions.ts +184 -0
  61. package/src/api/clients/workspaceWidgets/workspaceWidgets.ts +73 -0
  62. package/src/api/clients//321/201ontacts/contactChatMessagesHistory.ts +15 -26
  63. package/types/.tsbuildinfo +1 -1
  64. package/types/api/clients/activeCalls/activeCalls.d.ts +7 -0
  65. package/types/api/clients/agentPauseCauses/agentPauseCauses.d.ts +21 -0
  66. package/types/api/clients/agentSkills/agentSkills.d.ts +12 -0
  67. package/types/api/clients/agents/agents.d.ts +23 -2
  68. package/types/api/clients/auditForms/auditForms.d.ts +7 -0
  69. package/types/api/clients/auditForms/auditRates.d.ts +10 -0
  70. package/types/api/clients/backendProfiles/backendProfiles.d.ts +21 -0
  71. package/types/api/clients/callHistory/callAnnotations.d.ts +12 -0
  72. package/types/api/clients/callHistory/callHistory.d.ts +24 -3
  73. package/types/api/clients/chatplans/chatplans.d.ts +21 -0
  74. package/types/api/clients/cognitiveProfiles/cognitiveProfiles.d.ts +21 -0
  75. package/types/api/clients/dialplans/dialplans.d.ts +16 -0
  76. package/types/api/clients/emailProfiles/emailProfiles.d.ts +27 -0
  77. package/types/api/clients/fileServices/fileServices.d.ts +1 -1
  78. package/types/api/clients/fts/fts.d.ts +7 -0
  79. package/types/api/clients/importTemplates/importTemplates.d.ts +21 -0
  80. package/types/api/clients/index.d.ts +30 -0
  81. package/types/api/clients/lists/blacklistNumbers.d.ts +11 -0
  82. package/types/api/clients/logs/logs.d.ts +15 -0
  83. package/types/api/clients/outboundResourceGroups/outboundResourceGroups.d.ts +20 -0
  84. package/types/api/clients/outboundResourceGroups/resourcesInGroup.d.ts +11 -0
  85. package/types/api/clients/outboundResources/outboundResources.d.ts +21 -0
  86. package/types/api/clients/outboundResources/resourceDisplays.d.ts +11 -0
  87. package/types/api/clients/pauseTemplates/pauseTemplates.d.ts +20 -0
  88. package/types/api/clients/queues/queues.d.ts +5 -0
  89. package/types/api/clients/schemaVariables/schemaVariables.d.ts +21 -0
  90. package/types/api/clients/shiftTemplates/shiftTemplates.d.ts +20 -0
  91. package/types/api/clients/skills/skillAgents.d.ts +13 -0
  92. package/types/api/clients/storagePolicies/storagePolicies.d.ts +26 -0
  93. package/types/api/clients/teamHooks/teamHooks.d.ts +12 -0
  94. package/types/api/clients/teamTriggers/agentTriggers.d.ts +23 -0
  95. package/types/api/clients/teamTriggers/teamFlows.d.ts +12 -0
  96. package/types/api/clients/triggers/triggerJobs.d.ts +7 -0
  97. package/types/api/clients/triggers/triggers.d.ts +22 -0
  98. package/types/api/clients/userSettings/userSettings.d.ts +2 -2
  99. package/types/api/clients/workingConditions/workingConditions.d.ts +20 -0
  100. package/types/api/clients/workspaceWidgets/workspaceWidgets.d.ts +3 -0
@@ -1,10 +1,5 @@
1
- import { CommunicationTypeServiceApiFactory } from 'webitel-sdk';
2
- import {
3
- getDefaultGetListResponse,
4
- getDefaultGetParams,
5
- getDefaultInstance,
6
- getDefaultOpenAPIConfig,
7
- } from '../../defaults';
1
+ import { getCommunicationTypeService } from '../../../gen-wire';
2
+ import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
8
3
  import {
9
4
  applyTransform,
10
5
  camelToSnake,
@@ -24,38 +19,38 @@ import type {
24
19
  UpdateItemParams,
25
20
  } from '../_shared/types';
26
21
 
27
- const instance = getDefaultInstance();
28
- const configuration = getDefaultOpenAPIConfig();
29
-
30
- const communicationService = CommunicationTypeServiceApiFactory(
31
- configuration,
32
- '',
33
- instance,
34
- );
35
-
36
22
  const getCommunicationsList = async (params: ApiParams) => {
37
23
  const defaultObject = {
38
24
  default: false,
39
25
  };
40
26
 
41
- const { page, size, search, sort, fields, id, channel } = applyTransform(
42
- params,
43
- [
44
- merge(getDefaultGetParams()),
45
- starToSearch('search'),
46
- ],
47
- );
27
+ const requestParams = applyTransform(params, [
28
+ merge(getDefaultGetParams()),
29
+ starToSearch('search'),
30
+ camelToSnake(),
31
+ (params) => ({
32
+ ...params,
33
+ q: params.search,
34
+ // the filter is named `defaultValue` in the datalist store
35
+ default: params.default ?? params.default_value,
36
+ }),
37
+ sanitize([
38
+ 'page',
39
+ 'size',
40
+ 'q',
41
+ 'sort',
42
+ 'fields',
43
+ 'id',
44
+ 'channel',
45
+ 'default',
46
+ ]),
47
+ ]);
48
48
 
49
49
  try {
50
- const response = await communicationService.searchCommunicationType(
51
- page,
52
- size,
53
- search,
54
- sort,
55
- fields,
56
- id,
57
- channel,
58
- );
50
+ const response =
51
+ await getCommunicationTypeService().searchCommunicationType(
52
+ requestParams,
53
+ );
59
54
  const { items, next } = applyTransform(response.data, [
60
55
  snakeToCamel(),
61
56
  merge(getDefaultGetListResponse()),
@@ -75,7 +70,7 @@ const getCommunicationsList = async (params: ApiParams) => {
75
70
 
76
71
  const getCommunication = async ({ itemId: id }: GetItemParams) => {
77
72
  try {
78
- const response = await communicationService.readCommunicationType(
73
+ const response = await getCommunicationTypeService().readCommunicationType(
79
74
  String(id),
80
75
  );
81
76
  return applyTransform(response.data, [
@@ -102,7 +97,8 @@ const addCommunication = async ({ itemInstance }: AddItemParams) => {
102
97
  camelToSnake(),
103
98
  ]);
104
99
  try {
105
- const response = await communicationService.createCommunicationType(item);
100
+ const response =
101
+ await getCommunicationTypeService().createCommunicationType(item);
106
102
  return applyTransform(response.data, [
107
103
  snakeToCamel(),
108
104
  ]);
@@ -119,7 +115,7 @@ const patchCommunication = async ({ changes, id }: PatchItemParams) => {
119
115
  camelToSnake(),
120
116
  ]);
121
117
  try {
122
- const response = await communicationService.patchCommunicationType(
118
+ const response = await getCommunicationTypeService().patchCommunicationType(
123
119
  String(id),
124
120
  body,
125
121
  );
@@ -142,10 +138,11 @@ const updateCommunication = async ({
142
138
  camelToSnake(),
143
139
  ]);
144
140
  try {
145
- const response = await communicationService.updateCommunicationType(
146
- String(id),
147
- item,
148
- );
141
+ const response =
142
+ await getCommunicationTypeService().updateCommunicationType(
143
+ String(id),
144
+ item,
145
+ );
149
146
  return applyTransform(response.data, [
150
147
  snakeToCamel(),
151
148
  ]);
@@ -158,9 +155,8 @@ const updateCommunication = async ({
158
155
 
159
156
  const deleteCommunication = async ({ id }: DeleteItemParams) => {
160
157
  try {
161
- const response = await communicationService.deleteCommunicationType(
162
- String(id),
163
- );
158
+ const response =
159
+ await getCommunicationTypeService().deleteCommunicationType(String(id));
164
160
  return applyTransform(response.data, []);
165
161
  } catch (err) {
166
162
  throw applyTransform(err, [
@@ -0,0 +1,197 @@
1
+ import { getRoutingOutboundCallService } from '../../../gen-wire';
2
+ import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
3
+ import {
4
+ applyTransform,
5
+ camelToSnake,
6
+ merge,
7
+ mergeEach,
8
+ notify,
9
+ sanitize,
10
+ snakeToCamel,
11
+ starToSearch,
12
+ } from '../../transformers';
13
+ import type {
14
+ AddItemParams,
15
+ ApiId,
16
+ ApiParams,
17
+ DeleteItemParams,
18
+ GetItemParams,
19
+ PatchItemParams,
20
+ UpdateItemParams,
21
+ } from '../_shared/types';
22
+
23
+ const fieldsToSend = [
24
+ 'name',
25
+ 'schema',
26
+ 'pattern',
27
+ 'description',
28
+ 'disabled',
29
+ ];
30
+
31
+ const getDialplansList = async (params: ApiParams) => {
32
+ const defaultObject = {
33
+ disabled: false,
34
+ };
35
+
36
+ const { page, size, search, sort, fields, id } = applyTransform(params, [
37
+ merge(getDefaultGetParams()),
38
+ starToSearch('search'),
39
+ ]);
40
+
41
+ try {
42
+ const response =
43
+ await getRoutingOutboundCallService().searchRoutingOutboundCall({
44
+ page,
45
+ size,
46
+ // the generated param is `q`; `search` is what the datalist store sends
47
+ q: search,
48
+ sort,
49
+ fields,
50
+ id,
51
+ });
52
+ const { items, next } = applyTransform(response.data, [
53
+ snakeToCamel(),
54
+ merge(getDefaultGetListResponse()),
55
+ ]);
56
+ return {
57
+ items: applyTransform(items, [
58
+ mergeEach(defaultObject),
59
+ ]),
60
+ next,
61
+ };
62
+ } catch (err) {
63
+ throw applyTransform(err, [
64
+ notify,
65
+ ]);
66
+ }
67
+ };
68
+
69
+ const getDialplan = async ({ itemId: id }: GetItemParams) => {
70
+ try {
71
+ const response =
72
+ await getRoutingOutboundCallService().readRoutingOutboundCall(String(id));
73
+ return applyTransform(response.data, [
74
+ snakeToCamel(),
75
+ ]);
76
+ } catch (err) {
77
+ throw applyTransform(err, [
78
+ notify,
79
+ ]);
80
+ }
81
+ };
82
+
83
+ const addDialplan = async ({ itemInstance }: AddItemParams) => {
84
+ const item = applyTransform(itemInstance, [
85
+ sanitize(fieldsToSend),
86
+ camelToSnake(),
87
+ ]);
88
+ try {
89
+ const response =
90
+ await getRoutingOutboundCallService().createRoutingOutboundCall(item);
91
+ return applyTransform(response.data, [
92
+ snakeToCamel(),
93
+ ]);
94
+ } catch (err) {
95
+ throw applyTransform(err, [
96
+ notify,
97
+ ]);
98
+ }
99
+ };
100
+
101
+ const updateDialplan = async ({
102
+ itemInstance,
103
+ itemId: id,
104
+ }: UpdateItemParams) => {
105
+ const item = applyTransform(itemInstance, [
106
+ sanitize(fieldsToSend),
107
+ camelToSnake(),
108
+ ]);
109
+ try {
110
+ const response =
111
+ await getRoutingOutboundCallService().updateRoutingOutboundCall(
112
+ String(id),
113
+ item,
114
+ );
115
+ return applyTransform(response.data, [
116
+ snakeToCamel(),
117
+ ]);
118
+ } catch (err) {
119
+ throw applyTransform(err, [
120
+ notify,
121
+ ]);
122
+ }
123
+ };
124
+
125
+ const patchDialplan = async ({ changes, id }: PatchItemParams) => {
126
+ const body = applyTransform(changes, [
127
+ sanitize(fieldsToSend),
128
+ camelToSnake(),
129
+ ]);
130
+ try {
131
+ const response =
132
+ await getRoutingOutboundCallService().patchRoutingOutboundCall(
133
+ String(id),
134
+ body,
135
+ );
136
+ return applyTransform(response.data, [
137
+ snakeToCamel(),
138
+ ]);
139
+ } catch (err) {
140
+ throw applyTransform(err, [
141
+ notify,
142
+ ]);
143
+ }
144
+ };
145
+
146
+ const deleteDialplan = async ({ id }: DeleteItemParams) => {
147
+ try {
148
+ const response =
149
+ await getRoutingOutboundCallService().deleteRoutingOutboundCall(
150
+ String(id),
151
+ );
152
+ return applyTransform(response.data, []);
153
+ } catch (err) {
154
+ throw applyTransform(err, [
155
+ notify,
156
+ ]);
157
+ }
158
+ };
159
+
160
+ const moveDialplan = async ({
161
+ fromId,
162
+ toId,
163
+ }: {
164
+ fromId: ApiId;
165
+ toId: ApiId;
166
+ }) => {
167
+ try {
168
+ const response =
169
+ await getRoutingOutboundCallService().movePositionRoutingOutboundCall(
170
+ String(fromId),
171
+ String(toId),
172
+ {},
173
+ );
174
+ return applyTransform(response.data, [
175
+ notify(({ callback }) =>
176
+ callback({
177
+ type: 'success',
178
+ text: 'Successfully saved',
179
+ }),
180
+ ),
181
+ ]);
182
+ } catch (err) {
183
+ throw applyTransform(err, [
184
+ notify,
185
+ ]);
186
+ }
187
+ };
188
+
189
+ export const DialplansAPI = {
190
+ getList: getDialplansList,
191
+ get: getDialplan,
192
+ add: addDialplan,
193
+ update: updateDialplan,
194
+ patch: patchDialplan,
195
+ delete: deleteDialplan,
196
+ moveDialplan,
197
+ };
@@ -0,0 +1,222 @@
1
+ import { EngineEmailAuthType } from '../../../gen/_models';
2
+ import { getEmailProfileService } from '../../../gen-wire';
3
+ import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
4
+ import {
5
+ applyTransform,
6
+ camelToSnake,
7
+ merge,
8
+ mergeEach,
9
+ notify,
10
+ sanitize,
11
+ snakeToCamel,
12
+ starToSearch,
13
+ } from '../../transformers';
14
+ import type {
15
+ AddItemParams,
16
+ ApiId,
17
+ ApiParams,
18
+ DeleteItemParams,
19
+ GetItemParams,
20
+ PatchItemParams,
21
+ UpdateItemParams,
22
+ } from '../_shared/types';
23
+
24
+ const fieldsToSend = [
25
+ 'name',
26
+ 'description',
27
+ 'domainId',
28
+ 'enabled',
29
+ 'imapHost',
30
+ 'smtpHost',
31
+ 'fetchInterval',
32
+ 'imapPort',
33
+ 'login',
34
+ 'mailbox',
35
+ 'password',
36
+ 'schema',
37
+ 'smtpPort',
38
+ 'authType',
39
+ 'listen',
40
+ 'logged',
41
+ 'params',
42
+ ];
43
+
44
+ const getEmailProfilesList = async (params: ApiParams) => {
45
+ const defaultObject = {
46
+ enabled: false,
47
+ };
48
+
49
+ const { page, size, search, sort, fields } = applyTransform(params, [
50
+ merge(getDefaultGetParams()),
51
+ starToSearch('search'),
52
+ ]);
53
+
54
+ try {
55
+ const response = await getEmailProfileService().searchEmailProfile({
56
+ page,
57
+ size,
58
+ // the generated param is `q`; `search` is what the datalist store sends
59
+ q: search,
60
+ sort,
61
+ fields,
62
+ });
63
+ const { items, next } = applyTransform(response.data, [
64
+ snakeToCamel(),
65
+ merge(getDefaultGetListResponse()),
66
+ ]);
67
+ return {
68
+ items: applyTransform(items, [
69
+ mergeEach(defaultObject),
70
+ ]),
71
+ next,
72
+ };
73
+ } catch (err) {
74
+ throw applyTransform(err, [
75
+ notify,
76
+ ]);
77
+ }
78
+ };
79
+
80
+ const getEmailProfile = async ({ itemId: id }: GetItemParams) => {
81
+ const defaultObject = {
82
+ imapPort: 0,
83
+ smtpPort: 0,
84
+ authType: EngineEmailAuthType.Plain,
85
+ };
86
+
87
+ try {
88
+ const response = await getEmailProfileService().readEmailProfile(
89
+ String(id),
90
+ );
91
+ return applyTransform(response.data, [
92
+ snakeToCamel(),
93
+ merge(defaultObject),
94
+ ]);
95
+ } catch (err) {
96
+ throw applyTransform(err, [
97
+ notify,
98
+ ]);
99
+ }
100
+ };
101
+
102
+ const addEmailProfile = async ({ itemInstance }: AddItemParams) => {
103
+ const item = applyTransform(itemInstance, [
104
+ sanitize(fieldsToSend),
105
+ camelToSnake(),
106
+ ]);
107
+ try {
108
+ const response = await getEmailProfileService().createEmailProfile(item);
109
+ return applyTransform(response.data, [
110
+ snakeToCamel(),
111
+ ]);
112
+ } catch (err) {
113
+ throw applyTransform(err, [
114
+ notify,
115
+ ]);
116
+ }
117
+ };
118
+
119
+ const patchEmailProfile = async ({ changes, id }: PatchItemParams) => {
120
+ const body = applyTransform(changes, [
121
+ sanitize(fieldsToSend),
122
+ camelToSnake(),
123
+ ]);
124
+ try {
125
+ const response = await getEmailProfileService().patchEmailProfile(
126
+ String(id),
127
+ body,
128
+ );
129
+ return applyTransform(response.data, [
130
+ snakeToCamel(),
131
+ ]);
132
+ } catch (err) {
133
+ throw applyTransform(err, [
134
+ notify,
135
+ ]);
136
+ }
137
+ };
138
+
139
+ const updateEmailProfile = async ({
140
+ itemInstance,
141
+ itemId: id,
142
+ }: UpdateItemParams) => {
143
+ const item = applyTransform(itemInstance, [
144
+ sanitize(fieldsToSend),
145
+ camelToSnake(),
146
+ ]);
147
+ try {
148
+ const response = await getEmailProfileService().updateEmailProfile(
149
+ String(id),
150
+ item,
151
+ );
152
+ return applyTransform(response.data, [
153
+ snakeToCamel(),
154
+ ]);
155
+ } catch (err) {
156
+ throw applyTransform(err, [
157
+ notify,
158
+ ]);
159
+ }
160
+ };
161
+
162
+ const deleteEmailProfile = async ({ id }: DeleteItemParams) => {
163
+ try {
164
+ const response = await getEmailProfileService().deleteEmailProfile(
165
+ String(id),
166
+ );
167
+ return applyTransform(response.data, []);
168
+ } catch (err) {
169
+ throw applyTransform(err, [
170
+ notify,
171
+ ]);
172
+ }
173
+ };
174
+
175
+ const loginEmailProfile = async ({ id }: { id: ApiId }) => {
176
+ try {
177
+ const response = await getEmailProfileService().loginEmailProfile(
178
+ Number(id),
179
+ );
180
+ return applyTransform(response.data, []);
181
+ } catch (err) {
182
+ throw applyTransform(err, [
183
+ notify,
184
+ ]);
185
+ }
186
+ };
187
+
188
+ const logoutEmailProfile = async ({ id }: { id: ApiId }) => {
189
+ try {
190
+ const response = await getEmailProfileService().logoutEmailProfile(
191
+ Number(id),
192
+ );
193
+ return applyTransform(response.data, []);
194
+ } catch (err) {
195
+ throw applyTransform(err, [
196
+ notify,
197
+ ]);
198
+ }
199
+ };
200
+
201
+ const getEmailProfilesLookup = (
202
+ params: Parameters<typeof getEmailProfilesList>[0],
203
+ ) =>
204
+ getEmailProfilesList({
205
+ ...params,
206
+ fields: params.fields || [
207
+ 'id',
208
+ 'name',
209
+ ],
210
+ });
211
+
212
+ export const EmailProfilesAPI = {
213
+ getList: getEmailProfilesList,
214
+ get: getEmailProfile,
215
+ add: addEmailProfile,
216
+ patch: patchEmailProfile,
217
+ update: updateEmailProfile,
218
+ delete: deleteEmailProfile,
219
+ getLookup: getEmailProfilesLookup,
220
+ login: loginEmailProfile,
221
+ logout: logoutEmailProfile,
222
+ };
@@ -63,10 +63,15 @@ const getFilesList = async (
63
63
  }
64
64
  };
65
65
 
66
- const deleteFiles = async (id: string[]) => {
66
+ const deleteFiles = async (id: string | string[]) => {
67
+ const ids = Array.isArray(id)
68
+ ? id
69
+ : [
70
+ id,
71
+ ];
67
72
  try {
68
73
  const response = await getFileService().deleteFiles({
69
- id,
74
+ id: ids,
70
75
  });
71
76
  return applyTransform(response.data, [
72
77
  snakeToCamel(),
@@ -1,11 +1,6 @@
1
1
  import { EngineRoutingSchemaType } from '@webitel/api-services/gen/models';
2
- import { RoutingSchemaServiceApiFactory } from 'webitel-sdk';
3
- import {
4
- getDefaultGetListResponse,
5
- getDefaultGetParams,
6
- getDefaultInstance,
7
- getDefaultOpenAPIConfig,
8
- } from '../../defaults';
2
+ import { getRoutingSchemaService } from '../../../gen-wire';
3
+ import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
9
4
  import {
10
5
  applyTransform,
11
6
  camelToSnake,
@@ -24,11 +19,6 @@ import type {
24
19
  UpdateItemParams,
25
20
  } from '../_shared/types';
26
21
 
27
- const instance = getDefaultInstance();
28
- const configuration = getDefaultOpenAPIConfig();
29
-
30
- const flowService = RoutingSchemaServiceApiFactory(configuration, '', instance);
31
-
32
22
  /*
33
23
  CONVERT "SCHEMA" FIELD TO JSON TO PREVENT ITS CHANGE
34
24
  BY CAMEL-SNAKE TRANSFORMERS
@@ -68,26 +58,30 @@ const getFlowList = async (params: ApiParams) => {
68
58
  paramsCopy.type = _type;
69
59
  }
70
60
 
71
- const { page, size, search, sort, fields, id, name, type, tags } =
72
- applyTransform(paramsCopy, [
73
- merge(getDefaultGetParams()),
74
- starToSearch('search'),
75
- camelToSnake(doNotConvertKeys),
76
- ]);
61
+ const requestParams = applyTransform(paramsCopy, [
62
+ merge(getDefaultGetParams()),
63
+ starToSearch('search'),
64
+ camelToSnake(doNotConvertKeys),
65
+ (params) => ({
66
+ ...params,
67
+ q: params.search,
68
+ }),
69
+ sanitize([
70
+ 'page',
71
+ 'size',
72
+ 'q',
73
+ 'sort',
74
+ 'fields',
75
+ 'id',
76
+ 'name',
77
+ 'type',
78
+ 'tags',
79
+ ]),
80
+ ]);
77
81
 
78
82
  try {
79
- const response = await flowService.searchRoutingSchema(
80
- page,
81
- size,
82
- search,
83
- sort,
84
- fields,
85
- id,
86
- name,
87
- type,
88
- undefined,
89
- tags,
90
- );
83
+ const response =
84
+ await getRoutingSchemaService().searchRoutingSchema(requestParams);
91
85
  const { items, next } = applyTransform(response.data, [
92
86
  snakeToCamel(doNotConvertKeys),
93
87
  merge(getDefaultGetListResponse()),
@@ -117,7 +111,9 @@ const getFlow = async ({ itemId: id }: GetItemParams) => {
117
111
  });
118
112
 
119
113
  try {
120
- const response = await flowService.readRoutingSchema(String(id));
114
+ const response = await getRoutingSchemaService().readRoutingSchema(
115
+ String(id),
116
+ );
121
117
  return applyTransform(response.data, [
122
118
  ({ payload, schema, ...rest }) => ({
123
119
  payload,
@@ -151,7 +147,7 @@ const addFlow = async ({ itemInstance }: AddItemParams) => {
151
147
  }),
152
148
  ]);
153
149
  try {
154
- const response = await flowService.createRoutingSchema(item);
150
+ const response = await getRoutingSchemaService().createRoutingSchema(item);
155
151
  return applyTransform(response.data, [
156
152
  ({ payload, schema, ...rest }) => ({
157
153
  payload,
@@ -176,7 +172,10 @@ const updateFlow = async ({ itemInstance, itemId: id }: UpdateItemParams) => {
176
172
  }),
177
173
  ]);
178
174
  try {
179
- const response = await flowService.updateRoutingSchema(String(id), item);
175
+ const response = await getRoutingSchemaService().updateRoutingSchema(
176
+ String(id),
177
+ item,
178
+ );
180
179
  return applyTransform(response.data, [
181
180
  ({ payload, schema, ...rest }) => ({
182
181
  payload,
@@ -193,7 +192,9 @@ const updateFlow = async ({ itemInstance, itemId: id }: UpdateItemParams) => {
193
192
 
194
193
  const deleteFlow = async ({ id }: DeleteItemParams) => {
195
194
  try {
196
- const response = await flowService.deleteRoutingSchema(String(id));
195
+ const response = await getRoutingSchemaService().deleteRoutingSchema(
196
+ String(id),
197
+ );
197
198
  return applyTransform(response.data, []);
198
199
  } catch (err) {
199
200
  throw applyTransform(err, [
@@ -213,20 +214,30 @@ const getFlowsLookup = (params: Parameters<typeof getFlowList>[0]) =>
213
214
  });
214
215
 
215
216
  const getFlowTags = async (params: ApiParams) => {
216
- const { page, size, search, sort, fields, ids } = applyTransform(params, [
217
+ const requestParams = applyTransform(params, [
217
218
  merge(getDefaultGetParams()),
218
219
  starToSearch(),
219
220
  camelToSnake(doNotConvertKeys),
221
+ (params) => ({
222
+ ...params,
223
+ q: params.search,
224
+ // fixme: `ids` was passed into the `type` positional slot of the
225
+ // webitel-sdk factory; preserved verbatim here. The endpoint has no
226
+ // `id` filter, so this is very likely a latent bug.
227
+ type: params.ids,
228
+ }),
229
+ sanitize([
230
+ 'page',
231
+ 'size',
232
+ 'q',
233
+ 'sort',
234
+ 'fields',
235
+ 'type',
236
+ ]),
220
237
  ]);
221
238
  try {
222
- const response = await flowService.searchRoutingSchemaTags(
223
- page,
224
- size,
225
- search,
226
- sort,
227
- fields,
228
- ids,
229
- );
239
+ const response =
240
+ await getRoutingSchemaService().searchRoutingSchemaTags(requestParams);
230
241
  const { items, next } = applyTransform(response.data, [
231
242
  snakeToCamel(doNotConvertKeys),
232
243
  merge(getDefaultGetListResponse()),