@webitel/api-services 1.0.10 → 1.0.12

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 (102) 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/src/validations/calendar/__tests__/calendar.validations.spec.ts +85 -0
  64. package/src/validations/calendar/calendar.validations.ts +1 -1
  65. package/types/.tsbuildinfo +1 -1
  66. package/types/api/clients/activeCalls/activeCalls.d.ts +7 -0
  67. package/types/api/clients/agentPauseCauses/agentPauseCauses.d.ts +21 -0
  68. package/types/api/clients/agentSkills/agentSkills.d.ts +12 -0
  69. package/types/api/clients/agents/agents.d.ts +23 -2
  70. package/types/api/clients/auditForms/auditForms.d.ts +7 -0
  71. package/types/api/clients/auditForms/auditRates.d.ts +10 -0
  72. package/types/api/clients/backendProfiles/backendProfiles.d.ts +21 -0
  73. package/types/api/clients/callHistory/callAnnotations.d.ts +12 -0
  74. package/types/api/clients/callHistory/callHistory.d.ts +24 -3
  75. package/types/api/clients/chatplans/chatplans.d.ts +21 -0
  76. package/types/api/clients/cognitiveProfiles/cognitiveProfiles.d.ts +21 -0
  77. package/types/api/clients/dialplans/dialplans.d.ts +16 -0
  78. package/types/api/clients/emailProfiles/emailProfiles.d.ts +27 -0
  79. package/types/api/clients/fileServices/fileServices.d.ts +1 -1
  80. package/types/api/clients/fts/fts.d.ts +7 -0
  81. package/types/api/clients/importTemplates/importTemplates.d.ts +21 -0
  82. package/types/api/clients/index.d.ts +30 -0
  83. package/types/api/clients/lists/blacklistNumbers.d.ts +11 -0
  84. package/types/api/clients/logs/logs.d.ts +15 -0
  85. package/types/api/clients/outboundResourceGroups/outboundResourceGroups.d.ts +20 -0
  86. package/types/api/clients/outboundResourceGroups/resourcesInGroup.d.ts +11 -0
  87. package/types/api/clients/outboundResources/outboundResources.d.ts +21 -0
  88. package/types/api/clients/outboundResources/resourceDisplays.d.ts +11 -0
  89. package/types/api/clients/pauseTemplates/pauseTemplates.d.ts +20 -0
  90. package/types/api/clients/queues/queues.d.ts +5 -0
  91. package/types/api/clients/schemaVariables/schemaVariables.d.ts +21 -0
  92. package/types/api/clients/shiftTemplates/shiftTemplates.d.ts +20 -0
  93. package/types/api/clients/skills/skillAgents.d.ts +13 -0
  94. package/types/api/clients/storagePolicies/storagePolicies.d.ts +26 -0
  95. package/types/api/clients/teamHooks/teamHooks.d.ts +12 -0
  96. package/types/api/clients/teamTriggers/agentTriggers.d.ts +23 -0
  97. package/types/api/clients/teamTriggers/teamFlows.d.ts +12 -0
  98. package/types/api/clients/triggers/triggerJobs.d.ts +7 -0
  99. package/types/api/clients/triggers/triggers.d.ts +22 -0
  100. package/types/api/clients/userSettings/userSettings.d.ts +2 -2
  101. package/types/api/clients/workingConditions/workingConditions.d.ts +20 -0
  102. package/types/api/clients/workspaceWidgets/workspaceWidgets.d.ts +3 -0
@@ -0,0 +1,194 @@
1
+ import { getBackendProfileService } 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
+ ApiParams,
16
+ DeleteItemParams,
17
+ GetItemParams,
18
+ PatchItemParams,
19
+ UpdateItemParams,
20
+ } from '../_shared/types';
21
+
22
+ /**
23
+ * File storage backends ("storage profiles" in the admin UI).
24
+ *
25
+ * `type` and `properties.region` are returned as the raw backend strings.
26
+ * Mapping them onto UI enums and region option objects is the caller's job —
27
+ * those lookups are app-side.
28
+ */
29
+ const fieldsToSend = [
30
+ 'name',
31
+ 'maxSize',
32
+ 'priority',
33
+ 'properties',
34
+ 'expireDays',
35
+ 'type',
36
+ 'disabled',
37
+ ];
38
+
39
+ const getBackendProfilesList = async (params: ApiParams) => {
40
+ const defaultObject = {
41
+ disabled: false,
42
+ maxSize: 0,
43
+ expireDays: 0,
44
+ priority: 0,
45
+ };
46
+
47
+ const { page, size, search, sort, fields, id } = applyTransform(params, [
48
+ merge(getDefaultGetParams()),
49
+ starToSearch('search'),
50
+ ]);
51
+
52
+ try {
53
+ const response = await getBackendProfileService().searchBackendProfile({
54
+ page,
55
+ size,
56
+ // the generated param is `q`; `search` is what the datalist store sends
57
+ q: search,
58
+ sort,
59
+ fields,
60
+ id,
61
+ });
62
+ const { items, next } = applyTransform(response.data, [
63
+ snakeToCamel(),
64
+ merge(getDefaultGetListResponse()),
65
+ ]);
66
+ return {
67
+ items: applyTransform(items, [
68
+ mergeEach(defaultObject),
69
+ ]),
70
+ next,
71
+ };
72
+ } catch (err) {
73
+ throw applyTransform(err, [
74
+ notify,
75
+ ]);
76
+ }
77
+ };
78
+
79
+ const getBackendProfile = async ({ itemId: id }: GetItemParams) => {
80
+ const defaultObject = {
81
+ maxSize: 0,
82
+ expireDays: 0,
83
+ priority: 0,
84
+ };
85
+
86
+ try {
87
+ const response = await getBackendProfileService().readBackendProfile(
88
+ String(id),
89
+ );
90
+ return applyTransform(response.data, [
91
+ snakeToCamel(),
92
+ merge(defaultObject),
93
+ ]);
94
+ } catch (err) {
95
+ throw applyTransform(err, [
96
+ notify,
97
+ ]);
98
+ }
99
+ };
100
+
101
+ const addBackendProfile = async ({ itemInstance }: AddItemParams) => {
102
+ const item = applyTransform(itemInstance, [
103
+ sanitize(fieldsToSend),
104
+ camelToSnake(),
105
+ ]);
106
+ try {
107
+ const response =
108
+ await getBackendProfileService().createBackendProfile(item);
109
+ return applyTransform(response.data, [
110
+ snakeToCamel(),
111
+ ]);
112
+ } catch (err) {
113
+ throw applyTransform(err, [
114
+ notify,
115
+ ]);
116
+ }
117
+ };
118
+
119
+ const updateBackendProfile = async ({
120
+ itemInstance,
121
+ itemId: id,
122
+ }: UpdateItemParams) => {
123
+ const item = applyTransform(itemInstance, [
124
+ sanitize(fieldsToSend),
125
+ camelToSnake(),
126
+ ]);
127
+ try {
128
+ const response = await getBackendProfileService().updateBackendProfile(
129
+ String(id),
130
+ item,
131
+ );
132
+ return applyTransform(response.data, [
133
+ snakeToCamel(),
134
+ ]);
135
+ } catch (err) {
136
+ throw applyTransform(err, [
137
+ notify,
138
+ ]);
139
+ }
140
+ };
141
+
142
+ const patchBackendProfile = async ({ changes, id }: PatchItemParams) => {
143
+ const body = applyTransform(changes, [
144
+ sanitize(fieldsToSend),
145
+ camelToSnake(),
146
+ ]);
147
+ try {
148
+ const response = await getBackendProfileService().patchBackendProfile(
149
+ String(id),
150
+ body,
151
+ );
152
+ return applyTransform(response.data, [
153
+ snakeToCamel(),
154
+ ]);
155
+ } catch (err) {
156
+ throw applyTransform(err, [
157
+ notify,
158
+ ]);
159
+ }
160
+ };
161
+
162
+ const deleteBackendProfile = async ({ id }: DeleteItemParams) => {
163
+ try {
164
+ const response = await getBackendProfileService().deleteBackendProfile(
165
+ String(id),
166
+ );
167
+ return applyTransform(response.data, []);
168
+ } catch (err) {
169
+ throw applyTransform(err, [
170
+ notify,
171
+ ]);
172
+ }
173
+ };
174
+
175
+ const getBackendProfilesLookup = (
176
+ params: Parameters<typeof getBackendProfilesList>[0],
177
+ ) =>
178
+ getBackendProfilesList({
179
+ ...params,
180
+ fields: params.fields || [
181
+ 'id',
182
+ 'name',
183
+ ],
184
+ });
185
+
186
+ export const BackendProfilesAPI = {
187
+ getList: getBackendProfilesList,
188
+ get: getBackendProfile,
189
+ add: addBackendProfile,
190
+ patch: patchBackendProfile,
191
+ update: updateBackendProfile,
192
+ delete: deleteBackendProfile,
193
+ getLookup: getBackendProfilesLookup,
194
+ };
@@ -1,10 +1,5 @@
1
- import { BucketServiceApiFactory } from 'webitel-sdk';
2
- import {
3
- getDefaultGetListResponse,
4
- getDefaultGetParams,
5
- getDefaultInstance,
6
- getDefaultOpenAPIConfig,
7
- } from '../../defaults';
1
+ import { getBucketService } from '../../../gen-wire';
2
+ import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
8
3
  import {
9
4
  applyTransform,
10
5
  camelToSnake,
@@ -22,26 +17,27 @@ import type {
22
17
  UpdateItemParams,
23
18
  } from '../_shared/types';
24
19
 
25
- const instance = getDefaultInstance();
26
- const configuration = getDefaultOpenAPIConfig();
27
-
28
- const bucketService = BucketServiceApiFactory(configuration, '', instance);
29
-
30
20
  const getBucketsList = async (params: ApiParams) => {
31
- const { page, size, search, sort, fields, id } = applyTransform(params, [
21
+ const requestParams = applyTransform(params, [
32
22
  merge(getDefaultGetParams()),
33
23
  starToSearch('search'),
24
+ camelToSnake(),
25
+ (params) => ({
26
+ ...params,
27
+ q: params.search,
28
+ }),
29
+ sanitize([
30
+ 'page',
31
+ 'size',
32
+ 'q',
33
+ 'sort',
34
+ 'fields',
35
+ 'id',
36
+ ]),
34
37
  ]);
35
38
 
36
39
  try {
37
- const response = await bucketService.searchBucket(
38
- page,
39
- size,
40
- search,
41
- sort,
42
- fields,
43
- id,
44
- );
40
+ const response = await getBucketService().searchBucket(requestParams);
45
41
  const { items, next } = applyTransform(response.data, [
46
42
  snakeToCamel(),
47
43
  merge(getDefaultGetListResponse()),
@@ -59,7 +55,7 @@ const getBucketsList = async (params: ApiParams) => {
59
55
 
60
56
  const getBucket = async ({ itemId: id }: GetItemParams) => {
61
57
  try {
62
- const response = await bucketService.readBucket(String(id));
58
+ const response = await getBucketService().readBucket(String(id));
63
59
  return applyTransform(response.data, [
64
60
  snakeToCamel(),
65
61
  ]);
@@ -81,7 +77,7 @@ const addBucket = async ({ itemInstance }: AddItemParams) => {
81
77
  camelToSnake(),
82
78
  ]);
83
79
  try {
84
- const response = await bucketService.createBucket(item);
80
+ const response = await getBucketService().createBucket(item);
85
81
  return applyTransform(response.data, [
86
82
  snakeToCamel(),
87
83
  ]);
@@ -98,7 +94,7 @@ const updateBucket = async ({ itemInstance, itemId: id }: UpdateItemParams) => {
98
94
  camelToSnake(),
99
95
  ]);
100
96
  try {
101
- const response = await bucketService.updateBucket(String(id), item);
97
+ const response = await getBucketService().updateBucket(String(id), item);
102
98
  return applyTransform(response.data, [
103
99
  snakeToCamel(),
104
100
  ]);
@@ -111,7 +107,7 @@ const updateBucket = async ({ itemInstance, itemId: id }: UpdateItemParams) => {
111
107
 
112
108
  const deleteBucket = async ({ id }: DeleteItemParams) => {
113
109
  try {
114
- const response = await bucketService.deleteBucket(String(id));
110
+ const response = await getBucketService().deleteBucket(String(id));
115
111
  return applyTransform(response.data, []);
116
112
  } catch (err) {
117
113
  throw applyTransform(err, [
@@ -0,0 +1,91 @@
1
+ import { getCallService } from '../../../gen-wire';
2
+ import {
3
+ applyTransform,
4
+ camelToSnake,
5
+ notify,
6
+ sanitize,
7
+ snakeToCamel,
8
+ } from '../../transformers';
9
+ import type { ApiParams } from '../_shared/types';
10
+
11
+ /** Text notes pinned to a timeframe of a historical call. */
12
+ const fieldsToSend = [
13
+ 'note',
14
+ 'startSec',
15
+ 'endSec',
16
+ 'fileId',
17
+ 'callId',
18
+ ];
19
+
20
+ const addCallAnnotation = async ({
21
+ itemInstance,
22
+ }: {
23
+ itemInstance: ApiParams;
24
+ }) => {
25
+ const item = applyTransform(itemInstance, [
26
+ sanitize(fieldsToSend),
27
+ camelToSnake(),
28
+ ]);
29
+ try {
30
+ const response = await getCallService().createCallAnnotation(
31
+ String(itemInstance.callId),
32
+ item,
33
+ );
34
+ return applyTransform(response.data, [
35
+ snakeToCamel(),
36
+ ]);
37
+ } catch (err) {
38
+ throw applyTransform(err, [
39
+ notify,
40
+ ]);
41
+ }
42
+ };
43
+
44
+ const updateCallAnnotation = async ({
45
+ itemInstance,
46
+ }: {
47
+ itemInstance: ApiParams;
48
+ }) => {
49
+ const item = applyTransform(itemInstance, [
50
+ sanitize(fieldsToSend),
51
+ camelToSnake(),
52
+ ]);
53
+ try {
54
+ const response = await getCallService().updateCallAnnotation(
55
+ String(itemInstance.callId),
56
+ String(itemInstance.id),
57
+ item,
58
+ );
59
+ return applyTransform(response.data, [
60
+ snakeToCamel(),
61
+ ]);
62
+ } catch (err) {
63
+ throw applyTransform(err, [
64
+ notify,
65
+ ]);
66
+ }
67
+ };
68
+
69
+ const deleteCallAnnotation = async ({
70
+ itemInstance,
71
+ }: {
72
+ itemInstance: ApiParams;
73
+ }) => {
74
+ try {
75
+ const response = await getCallService().deleteCallAnnotation(
76
+ String(itemInstance.callId),
77
+ String(itemInstance.id),
78
+ );
79
+ return applyTransform(response.data, []);
80
+ } catch (err) {
81
+ throw applyTransform(err, [
82
+ notify,
83
+ ]);
84
+ }
85
+ };
86
+
87
+ export const CallAnnotationsAPI = {
88
+ add: addCallAnnotation,
89
+ update: updateCallAnnotation,
90
+ delete: deleteCallAnnotation,
91
+ };
@@ -8,7 +8,7 @@ import {
8
8
  snakeToCamel,
9
9
  starToSearch,
10
10
  } from '../../transformers';
11
- import type { ApiParams } from '../_shared/types';
11
+ import type { ApiId, ApiParams } from '../_shared/types';
12
12
 
13
13
  const getCallHistoryList = async ({
14
14
  options,
@@ -43,22 +43,37 @@ const getCallHistoryList = async ({
43
43
  const getCallHistoryListPost = async ({
44
44
  data,
45
45
  options,
46
+ doNotConvertKeys = [],
47
+ responseTransformers,
46
48
  }: {
47
49
  data: ApiParams;
48
- options: ApiParams;
50
+ options?: ApiParams;
51
+ /**
52
+ * Keys whose contents are user data rather than API fields — `variables`,
53
+ * for instance — and must survive both case transformers untouched.
54
+ */
55
+ doNotConvertKeys?: string[];
56
+ /**
57
+ * Replaces the default response pipeline. A CSV export, for one, wants the
58
+ * rows left in snake_case.
59
+ */
60
+ responseTransformers?: Parameters<typeof applyTransform>[1];
49
61
  }) => {
50
62
  const body = applyTransform(data, [
51
- camelToSnake(),
63
+ camelToSnake(doNotConvertKeys),
52
64
  ]);
53
65
  try {
54
66
  const response = await getCallService().searchHistoryCallPost(
55
67
  body,
56
68
  options,
57
69
  );
58
- const { items, next } = applyTransform(response.data, [
59
- snakeToCamel(),
60
- merge(getDefaultGetListResponse()),
61
- ]);
70
+ const { items, next } = applyTransform(
71
+ response.data,
72
+ responseTransformers ?? [
73
+ snakeToCamel(doNotConvertKeys),
74
+ merge(getDefaultGetListResponse()),
75
+ ],
76
+ );
62
77
  return {
63
78
  items,
64
79
  next,
@@ -70,6 +85,57 @@ const getCallHistoryListPost = async ({
70
85
  }
71
86
  };
72
87
 
88
+ /**
89
+ * Aggregation buckets for the history dashboards. The response is returned as
90
+ * camelCase rows; shaping them into chart series is the caller's job.
91
+ */
92
+ const aggregateCallHistory = async ({
93
+ data,
94
+ doNotConvertKeys = [],
95
+ }: {
96
+ data: ApiParams;
97
+ doNotConvertKeys?: string[];
98
+ }) => {
99
+ try {
100
+ const response = await getCallService().aggregateHistoryCall(data);
101
+ return applyTransform(response.data, [
102
+ snakeToCamel(doNotConvertKeys),
103
+ ]);
104
+ } catch (err) {
105
+ throw applyTransform(err, [
106
+ notify,
107
+ ]);
108
+ }
109
+ };
110
+
111
+ /** Calls the caller back on a missed call. */
112
+ const redialCall = async ({ callId }: { callId: ApiId }) => {
113
+ try {
114
+ const response = await getCallService().redialCall(String(callId), {
115
+ callId: String(callId),
116
+ });
117
+ return response.data;
118
+ } catch (err) {
119
+ throw applyTransform(err, [
120
+ notify,
121
+ ]);
122
+ }
123
+ };
124
+
125
+ /** Drops a missed call out of the agent's missed list. */
126
+ const hideMissedCall = async ({ callId }: { callId: ApiId }) => {
127
+ try {
128
+ const response = await getCallService().patchHistoryCall(String(callId), {
129
+ hide_missed: true,
130
+ });
131
+ return response.data;
132
+ } catch (err) {
133
+ throw applyTransform(err, [
134
+ notify,
135
+ ]);
136
+ }
137
+ };
138
+
73
139
  const getCallHistoryLookup = (
74
140
  params: Parameters<typeof getCallHistoryList>[0],
75
141
  ) =>
@@ -86,5 +152,8 @@ const getCallHistoryLookup = (
86
152
  export const CallHistoryAPI = {
87
153
  getList: getCallHistoryList,
88
154
  getListPost: getCallHistoryListPost,
155
+ aggregate: aggregateCallHistory,
156
+ redial: redialCall,
157
+ hideMissed: hideMissedCall,
89
158
  getLookup: getCallHistoryLookup,
90
159
  };
@@ -0,0 +1,50 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
2
+
3
+ const listPriorities = vi.fn(() =>
4
+ Promise.resolve({
5
+ data: {},
6
+ }),
7
+ );
8
+
9
+ vi.mock('../../../../gen-wire', async (importOriginal) => ({
10
+ ...(await importOriginal<Record<string, unknown>>()),
11
+ getPriorities: () => ({
12
+ listPriorities,
13
+ }),
14
+ }));
15
+
16
+ const { ListPrioritiesQueryParams } = await import('../../../../gen-wire');
17
+ const { CasePrioritiesAPI } = await import('../casePriorities');
18
+
19
+ /**
20
+ * `/cases/priorities` is one of eight endpoints out of 441 whose query params
21
+ * are camelCase — `src/gen` and `src/gen-wire` agree on `notInSla` /
22
+ * `inSlaCond`, where every other service is snake. crm passes both from
23
+ * `opened-sla-condition-popup.vue`, so the client must not convert them.
24
+ *
25
+ * This used to run `camelToSnake()` and undo it in the destructure. That was
26
+ * invisible while the call was positional, where argument names never reached
27
+ * the wire; as object keys, deleting the redundant conversion would have made
28
+ * both filters `undefined` with no type error and no failing test.
29
+ */
30
+ describe('CasePrioritiesAPI.getList', () => {
31
+ beforeEach(() => listPriorities.mockClear());
32
+
33
+ it('leaves notInSla and inSlaCond in camelCase', async () => {
34
+ await CasePrioritiesAPI.getList({
35
+ page: 1,
36
+ size: 10,
37
+ notInSla: '7',
38
+ inSlaCond: '3',
39
+ });
40
+
41
+ const [params] = listPriorities.mock.calls[0];
42
+ expect(params).toMatchObject({
43
+ notInSla: '7',
44
+ inSlaCond: '3',
45
+ });
46
+ expect(ListPrioritiesQueryParams.strict().safeParse(params).success).toBe(
47
+ true,
48
+ );
49
+ });
50
+ });
@@ -1,10 +1,5 @@
1
- import { PrioritiesApiFactory } from 'webitel-sdk';
2
- import {
3
- getDefaultGetListResponse,
4
- getDefaultGetParams,
5
- getDefaultInstance,
6
- getDefaultOpenAPIConfig,
7
- } from '../../defaults';
1
+ import { getPriorities } from '../../../gen-wire';
2
+ import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
8
3
  import {
9
4
  applyTransform,
10
5
  camelToSnake,
@@ -21,11 +16,6 @@ import type {
21
16
  UpdateItemParams,
22
17
  } from '../_shared/types';
23
18
 
24
- const instance = getDefaultInstance();
25
- const configuration = getDefaultOpenAPIConfig();
26
-
27
- const priorityService = PrioritiesApiFactory(configuration, '', instance);
28
-
29
19
  const fieldsToSend = [
30
20
  'name',
31
21
  'description',
@@ -33,7 +23,12 @@ const fieldsToSend = [
33
23
  ];
34
24
 
35
25
  const getPrioritiesList = async (params: ApiParams) => {
36
- const fieldsToSend = [
26
+ /*
27
+ * This endpoint spells its filters in camelCase — both `src/gen` and
28
+ * `src/gen-wire` agree — so no case conversion runs here. The object keys
29
+ * below are the wire names.
30
+ */
31
+ const listFieldsToSend = [
37
32
  'page',
38
33
  'size',
39
34
  'q',
@@ -41,29 +36,19 @@ const getPrioritiesList = async (params: ApiParams) => {
41
36
  'fields',
42
37
  'id',
43
38
  'notInSla',
44
- 'inSla',
45
39
  'inSlaCond',
46
40
  ];
47
- const {
48
- page,
49
- size,
50
- fields,
51
- sort,
52
- id,
53
- q,
54
- not_in_sla: notInSla,
55
- in_sla_cond: inSlaCond,
56
- } = applyTransform(params, [
57
- merge(getDefaultGetParams()),
58
- (params) => ({
59
- ...params,
60
- q: params.search,
61
- }),
62
- sanitize(fieldsToSend),
63
- camelToSnake(),
64
- ]);
41
+ const { page, size, fields, sort, id, q, notInSla, inSlaCond } =
42
+ applyTransform(params, [
43
+ merge(getDefaultGetParams()),
44
+ (params) => ({
45
+ ...params,
46
+ q: params.search,
47
+ }),
48
+ sanitize(listFieldsToSend),
49
+ ]);
65
50
  try {
66
- const response = await priorityService.listPriorities(
51
+ const response = await getPriorities().listPriorities({
67
52
  page,
68
53
  size,
69
54
  fields,
@@ -72,7 +57,7 @@ const getPrioritiesList = async (params: ApiParams) => {
72
57
  q,
73
58
  notInSla,
74
59
  inSlaCond,
75
- );
60
+ });
76
61
  const { items, next } = applyTransform(response.data, [
77
62
  merge(getDefaultGetListResponse()),
78
63
  ]);
@@ -93,10 +78,9 @@ const getPriority = async ({ itemId: id }: GetItemParams) => {
93
78
  };
94
79
 
95
80
  try {
96
- const response = await priorityService.locatePriority(
97
- String(id),
98
- fieldsToSend,
99
- );
81
+ const response = await getPriorities().locatePriority(String(id), {
82
+ fields: fieldsToSend,
83
+ });
100
84
  return applyTransform(response.data, [
101
85
  snakeToCamel(),
102
86
  itemResponseHandler,
@@ -115,7 +99,7 @@ const addPriority = async ({ itemInstance }: AddItemParams) => {
115
99
  ]);
116
100
 
117
101
  try {
118
- const response = await priorityService.createPriority(item);
102
+ const response = await getPriorities().createPriority(item);
119
103
  return applyTransform(response.data, [
120
104
  snakeToCamel(),
121
105
  ]);
@@ -136,7 +120,7 @@ const updatePriority = async ({
136
120
  ]);
137
121
 
138
122
  try {
139
- const response = await priorityService.updatePriority(String(id), item);
123
+ const response = await getPriorities().updatePriority(String(id), item);
140
124
  return applyTransform(response.data, [
141
125
  snakeToCamel(),
142
126
  ]);
@@ -149,7 +133,7 @@ const updatePriority = async ({
149
133
 
150
134
  const deletePriority = async ({ id }: DeleteItemParams) => {
151
135
  try {
152
- const response = await priorityService.deletePriority(String(id));
136
+ const response = await getPriorities().deletePriority(String(id));
153
137
  return applyTransform(response.data, []);
154
138
  } catch (err) {
155
139
  throw applyTransform(err, [