@webitel/api-services 1.0.9 → 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.
- package/package.json +1 -1
- package/src/api/clients/__tests__/wireParamsCoverage.spec.ts +286 -0
- package/src/api/clients/activeCalls/activeCalls.ts +72 -0
- package/src/api/clients/agentPauseCauses/agentPauseCauses.ts +182 -0
- package/src/api/clients/agentSkills/agentSkills.ts +193 -0
- package/src/api/clients/agents/__tests__/agents.wireParams.spec.ts +51 -0
- package/src/api/clients/agents/agents.ts +203 -18
- package/src/api/clients/auditForms/auditForms.ts +6 -2
- package/src/api/clients/auditForms/auditRates.ts +91 -0
- package/src/api/clients/backendProfiles/backendProfiles.ts +194 -0
- package/src/api/clients/buckets/buckets.ts +21 -25
- package/src/api/clients/callHistory/callAnnotations.ts +91 -0
- package/src/api/clients/callHistory/callHistory.ts +76 -7
- package/src/api/clients/casePriorities/__tests__/casePriorities.spec.ts +50 -0
- package/src/api/clients/casePriorities/casePriorities.ts +25 -41
- package/src/api/clients/caseStatusConditions/caseStatusConditions.ts +21 -31
- package/src/api/clients/caseStatuses/caseStatuses.ts +10 -21
- package/src/api/clients/cases/cases.ts +6 -3
- package/src/api/clients/catalog/catalog.ts +2 -8
- package/src/api/clients/changelogs/changelogs.ts +8 -0
- package/src/api/clients/chatplans/chatplans.ts +173 -0
- package/src/api/clients/cognitiveProfiles/cognitiveProfiles.ts +209 -0
- package/src/api/clients/communications/communications.ts +38 -42
- package/src/api/clients/dialplans/dialplans.ts +197 -0
- package/src/api/clients/emailProfiles/emailProfiles.ts +222 -0
- package/src/api/clients/fileServices/fileServices.ts +7 -2
- package/src/api/clients/flows/flow.ts +54 -43
- package/src/api/clients/fts/fts.ts +61 -0
- package/src/api/clients/history/transcript/callTranscript.ts +10 -20
- package/src/api/clients/importTemplates/importTemplates.ts +180 -0
- package/src/api/clients/index.ts +30 -0
- package/src/api/clients/lists/blacklistNumbers.ts +155 -0
- package/src/api/clients/lists/blacklists.ts +20 -25
- package/src/api/clients/logs/logs.ts +157 -0
- package/src/api/clients/media/media.ts +19 -15
- package/src/api/clients/object/object.ts +3 -14
- package/src/api/clients/outboundResourceGroups/outboundResourceGroups.ts +187 -0
- package/src/api/clients/outboundResourceGroups/resourcesInGroup.ts +169 -0
- package/src/api/clients/outboundResources/outboundResources.ts +225 -0
- package/src/api/clients/outboundResources/resourceDisplays.ts +165 -0
- package/src/api/clients/pauseTemplates/pauseTemplates.ts +203 -0
- package/src/api/clients/queues/__tests__/queueLogs.spec.ts +3 -3
- package/src/api/clients/queues/__tests__/queueMembers.spec.ts +4 -4
- package/src/api/clients/queues/queueLogs.ts +8 -3
- package/src/api/clients/queues/queueMembers.ts +3 -3
- package/src/api/clients/queues/queues.ts +52 -0
- package/src/api/clients/regions/regions.ts +21 -25
- package/src/api/clients/schemaVariables/schemaVariables.ts +167 -0
- package/src/api/clients/shiftTemplates/shiftTemplates.ts +176 -0
- package/src/api/clients/skills/skillAgents.ts +190 -0
- package/src/api/clients/skills/skills.ts +21 -25
- package/src/api/clients/storagePolicies/storagePolicies.ts +270 -0
- package/src/api/clients/teamHooks/teamHooks.ts +195 -0
- package/src/api/clients/teamTriggers/agentTriggers.ts +77 -0
- package/src/api/clients/teamTriggers/teamFlows.ts +194 -0
- package/src/api/clients/teams/teams.ts +31 -31
- package/src/api/clients/triggers/triggerJobs.ts +63 -0
- package/src/api/clients/triggers/triggers.ts +266 -0
- package/src/api/clients/userSettings/userSettings.ts +8 -9
- package/src/api/clients/users/users.ts +2 -0
- package/src/api/clients/workingConditions/workingConditions.ts +184 -0
- package/src/api/clients/workspaceWidgets/workspaceWidgets.ts +73 -0
- package/src/api/clients/wtTypes/adjunctTypeRecords/adjunctTypeRecords.ts +3 -3
- package/src/api/clients/wtTypes/adjunctTypes/adjunctTypes.ts +1 -1
- package/src/api/clients//321/201ontacts/contactChatMessagesHistory.ts +15 -26
- package/types/.tsbuildinfo +1 -1
- package/types/api/clients/activeCalls/activeCalls.d.ts +7 -0
- package/types/api/clients/agentPauseCauses/agentPauseCauses.d.ts +21 -0
- package/types/api/clients/agentSkills/agentSkills.d.ts +12 -0
- package/types/api/clients/agents/agents.d.ts +23 -2
- package/types/api/clients/auditForms/auditForms.d.ts +7 -0
- package/types/api/clients/auditForms/auditRates.d.ts +10 -0
- package/types/api/clients/backendProfiles/backendProfiles.d.ts +21 -0
- package/types/api/clients/callHistory/callAnnotations.d.ts +12 -0
- package/types/api/clients/callHistory/callHistory.d.ts +24 -3
- package/types/api/clients/caseStatusConditions/caseStatusConditions.d.ts +4 -4
- package/types/api/clients/cases/cases.d.ts +5 -2
- package/types/api/clients/chatplans/chatplans.d.ts +21 -0
- package/types/api/clients/cognitiveProfiles/cognitiveProfiles.d.ts +21 -0
- package/types/api/clients/dialplans/dialplans.d.ts +16 -0
- package/types/api/clients/emailProfiles/emailProfiles.d.ts +27 -0
- package/types/api/clients/fileServices/fileServices.d.ts +1 -1
- package/types/api/clients/fts/fts.d.ts +7 -0
- package/types/api/clients/importTemplates/importTemplates.d.ts +21 -0
- package/types/api/clients/index.d.ts +30 -0
- package/types/api/clients/lists/blacklistNumbers.d.ts +11 -0
- package/types/api/clients/logs/logs.d.ts +15 -0
- package/types/api/clients/outboundResourceGroups/outboundResourceGroups.d.ts +20 -0
- package/types/api/clients/outboundResourceGroups/resourcesInGroup.d.ts +11 -0
- package/types/api/clients/outboundResources/outboundResources.d.ts +21 -0
- package/types/api/clients/outboundResources/resourceDisplays.d.ts +11 -0
- package/types/api/clients/pauseTemplates/pauseTemplates.d.ts +20 -0
- package/types/api/clients/queues/queues.d.ts +5 -0
- package/types/api/clients/schemaVariables/schemaVariables.d.ts +21 -0
- package/types/api/clients/shiftTemplates/shiftTemplates.d.ts +20 -0
- package/types/api/clients/skills/skillAgents.d.ts +13 -0
- package/types/api/clients/storagePolicies/storagePolicies.d.ts +26 -0
- package/types/api/clients/teamHooks/teamHooks.d.ts +12 -0
- package/types/api/clients/teamTriggers/agentTriggers.d.ts +23 -0
- package/types/api/clients/teamTriggers/teamFlows.d.ts +12 -0
- package/types/api/clients/triggers/triggerJobs.d.ts +7 -0
- package/types/api/clients/triggers/triggers.d.ts +22 -0
- package/types/api/clients/userSettings/userSettings.d.ts +2 -2
- package/types/api/clients/workingConditions/workingConditions.d.ts +20 -0
- package/types/api/clients/workspaceWidgets/workspaceWidgets.d.ts +3 -0
- package/types/api/clients/wtTypes/adjunctTypeRecords/adjunctTypeRecords.d.ts +2 -2
- package/types/api/clients/wtTypes/adjunctTypes/adjunctTypes.d.ts +2 -2
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
getDefaultGetListResponse,
|
|
4
|
-
getDefaultGetParams,
|
|
5
|
-
getDefaultInstance,
|
|
6
|
-
getDefaultOpenAPIConfig,
|
|
7
|
-
} from '../../defaults';
|
|
1
|
+
import { getStatusConditions } from '../../../gen-wire';
|
|
2
|
+
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
8
3
|
import {
|
|
9
4
|
applyTransform,
|
|
10
5
|
camelToSnake,
|
|
@@ -15,15 +10,6 @@ import {
|
|
|
15
10
|
} from '../../transformers';
|
|
16
11
|
import type { ApiId, ApiParams } from '../_shared/types';
|
|
17
12
|
|
|
18
|
-
const instance = getDefaultInstance();
|
|
19
|
-
const configuration = getDefaultOpenAPIConfig();
|
|
20
|
-
|
|
21
|
-
const statusConditionsService = StatusConditionsApiFactory(
|
|
22
|
-
configuration,
|
|
23
|
-
'',
|
|
24
|
-
instance,
|
|
25
|
-
);
|
|
26
|
-
|
|
27
13
|
const fieldsToSend = [
|
|
28
14
|
'name',
|
|
29
15
|
'description',
|
|
@@ -34,8 +20,8 @@ const getStatusConditionsList = async ({
|
|
|
34
20
|
parentId,
|
|
35
21
|
...rest
|
|
36
22
|
}: {
|
|
37
|
-
statusId
|
|
38
|
-
parentId
|
|
23
|
+
statusId?: ApiId;
|
|
24
|
+
parentId?: ApiId;
|
|
39
25
|
} & ApiParams) => {
|
|
40
26
|
const fieldsToSend = [
|
|
41
27
|
'page',
|
|
@@ -57,14 +43,16 @@ const getStatusConditionsList = async ({
|
|
|
57
43
|
]);
|
|
58
44
|
|
|
59
45
|
try {
|
|
60
|
-
const response = await
|
|
46
|
+
const response = await getStatusConditions().listStatusConditions(
|
|
61
47
|
String(statusId || parentId),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
48
|
+
{
|
|
49
|
+
page,
|
|
50
|
+
size,
|
|
51
|
+
fields,
|
|
52
|
+
sort,
|
|
53
|
+
id,
|
|
54
|
+
q,
|
|
55
|
+
},
|
|
68
56
|
);
|
|
69
57
|
const { items, next } = applyTransform(response.data, [
|
|
70
58
|
merge(getDefaultGetListResponse()),
|
|
@@ -94,10 +82,12 @@ const getStatusCondition = async ({
|
|
|
94
82
|
};
|
|
95
83
|
|
|
96
84
|
try {
|
|
97
|
-
const response = await
|
|
85
|
+
const response = await getStatusConditions().locateStatusCondition(
|
|
98
86
|
String(parentId),
|
|
99
87
|
String(id),
|
|
100
|
-
|
|
88
|
+
{
|
|
89
|
+
fields: fieldsToSend,
|
|
90
|
+
},
|
|
101
91
|
);
|
|
102
92
|
return applyTransform(response.data, [
|
|
103
93
|
snakeToCamel(),
|
|
@@ -125,7 +115,7 @@ const updateStatusCondition = async ({
|
|
|
125
115
|
]);
|
|
126
116
|
|
|
127
117
|
try {
|
|
128
|
-
const response = await
|
|
118
|
+
const response = await getStatusConditions().updateStatusCondition(
|
|
129
119
|
String(parentId),
|
|
130
120
|
String(id),
|
|
131
121
|
item,
|
|
@@ -153,7 +143,7 @@ const addStatusCondition = async ({
|
|
|
153
143
|
]);
|
|
154
144
|
|
|
155
145
|
try {
|
|
156
|
-
const response = await
|
|
146
|
+
const response = await getStatusConditions().createStatusCondition(
|
|
157
147
|
String(parentId),
|
|
158
148
|
item,
|
|
159
149
|
);
|
|
@@ -188,7 +178,7 @@ const patchStatusCondition = async ({
|
|
|
188
178
|
]);
|
|
189
179
|
|
|
190
180
|
try {
|
|
191
|
-
const response = await
|
|
181
|
+
const response = await getStatusConditions().updateStatusCondition2(
|
|
192
182
|
String(parentId),
|
|
193
183
|
String(id),
|
|
194
184
|
input,
|
|
@@ -209,7 +199,7 @@ const deleteStatusCondition = async ({
|
|
|
209
199
|
parentId: ApiId;
|
|
210
200
|
}) => {
|
|
211
201
|
try {
|
|
212
|
-
const response = await
|
|
202
|
+
const response = await getStatusConditions().deleteStatusCondition(
|
|
213
203
|
String(parentId),
|
|
214
204
|
String(id),
|
|
215
205
|
);
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
getDefaultGetListResponse,
|
|
4
|
-
getDefaultGetParams,
|
|
5
|
-
getDefaultInstance,
|
|
6
|
-
getDefaultOpenAPIConfig,
|
|
7
|
-
} from '../../defaults';
|
|
1
|
+
import { getStatuses } 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 statusesService = StatusesApiFactory(configuration, '', instance);
|
|
28
|
-
|
|
29
19
|
const fieldsToSend = [
|
|
30
20
|
'name',
|
|
31
21
|
'description',
|
|
@@ -51,14 +41,14 @@ const getStatusesList = async (params: ApiParams) => {
|
|
|
51
41
|
camelToSnake(),
|
|
52
42
|
]);
|
|
53
43
|
try {
|
|
54
|
-
const response = await
|
|
44
|
+
const response = await getStatuses().listStatuses({
|
|
55
45
|
page,
|
|
56
46
|
size,
|
|
57
47
|
fields,
|
|
58
48
|
sort,
|
|
59
49
|
id,
|
|
60
50
|
q,
|
|
61
|
-
);
|
|
51
|
+
});
|
|
62
52
|
const { items, next } = applyTransform(response.data, [
|
|
63
53
|
merge(getDefaultGetListResponse()),
|
|
64
54
|
]);
|
|
@@ -79,10 +69,9 @@ const getStatus = async ({ itemId: id }: GetItemParams) => {
|
|
|
79
69
|
};
|
|
80
70
|
|
|
81
71
|
try {
|
|
82
|
-
const response = await
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
);
|
|
72
|
+
const response = await getStatuses().locateStatus(String(id), {
|
|
73
|
+
fields: fieldsToSend,
|
|
74
|
+
});
|
|
86
75
|
return applyTransform(response.data, [
|
|
87
76
|
snakeToCamel(),
|
|
88
77
|
itemResponseHandler,
|
|
@@ -101,7 +90,7 @@ const addStatus = async ({ itemInstance }: AddItemParams) => {
|
|
|
101
90
|
]);
|
|
102
91
|
|
|
103
92
|
try {
|
|
104
|
-
const response = await
|
|
93
|
+
const response = await getStatuses().createStatus(item);
|
|
105
94
|
return applyTransform(response.data, [
|
|
106
95
|
snakeToCamel(),
|
|
107
96
|
]);
|
|
@@ -119,7 +108,7 @@ const updateStatus = async ({ itemInstance, itemId: id }: UpdateItemParams) => {
|
|
|
119
108
|
]);
|
|
120
109
|
|
|
121
110
|
try {
|
|
122
|
-
const response = await
|
|
111
|
+
const response = await getStatuses().updateStatus(String(id), item);
|
|
123
112
|
return applyTransform(response.data, [
|
|
124
113
|
snakeToCamel(),
|
|
125
114
|
]);
|
|
@@ -132,7 +121,7 @@ const updateStatus = async ({ itemInstance, itemId: id }: UpdateItemParams) => {
|
|
|
132
121
|
|
|
133
122
|
const deleteStatus = async ({ id }: DeleteItemParams) => {
|
|
134
123
|
try {
|
|
135
|
-
const response = await
|
|
124
|
+
const response = await getStatuses().deleteStatus(String(id));
|
|
136
125
|
return applyTransform(response.data, []);
|
|
137
126
|
} catch (err) {
|
|
138
127
|
throw applyTransform(err, [
|
|
@@ -257,11 +257,14 @@ const addCase = async ({ itemInstance }: AddItemParams) => {
|
|
|
257
257
|
};
|
|
258
258
|
|
|
259
259
|
const patchCase = async ({
|
|
260
|
-
changes,
|
|
260
|
+
changes = {},
|
|
261
261
|
etag,
|
|
262
262
|
}: {
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
id?: ApiId;
|
|
264
|
+
itemId?: ApiId;
|
|
265
|
+
changes?: ApiParams;
|
|
266
|
+
parentId?: ApiId;
|
|
267
|
+
etag?: ApiId;
|
|
265
268
|
}) => {
|
|
266
269
|
const body = applyTransform(changes, [
|
|
267
270
|
sanitizeToWire(getShallowFieldsToSendFromZodSchema(UpdateCase2Body)),
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getDefaultInstance, getDefaultOpenAPIConfig } from '../../defaults';
|
|
1
|
+
import { getMessages } from '../../../gen-wire';
|
|
3
2
|
import { applyTransform, notify, snakeToCamel } from '../../transformers';
|
|
4
3
|
import type { ApiId, ApiParams } from '../_shared/types';
|
|
5
4
|
|
|
6
|
-
const instance = getDefaultInstance();
|
|
7
|
-
const configuration = getDefaultOpenAPIConfig();
|
|
8
|
-
|
|
9
|
-
const catalogService = CatalogApiFactory(configuration, '', instance);
|
|
10
|
-
|
|
11
5
|
const getChatMessagesList = async ({ chatId }: { chatId: ApiId }) => {
|
|
12
6
|
const mergeMessagesData = ({
|
|
13
7
|
messages,
|
|
@@ -26,7 +20,7 @@ const getChatMessagesList = async ({ chatId }: { chatId: ApiId }) => {
|
|
|
26
20
|
};
|
|
27
21
|
|
|
28
22
|
try {
|
|
29
|
-
const response = await
|
|
23
|
+
const response = await getMessages().catalogGetHistory(String(chatId));
|
|
30
24
|
const { messages, peers } = applyTransform(response.data, [
|
|
31
25
|
snakeToCamel(),
|
|
32
26
|
]);
|
|
@@ -2,6 +2,7 @@ import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/u
|
|
|
2
2
|
import {
|
|
3
3
|
ConfigServiceCreateConfigBody,
|
|
4
4
|
ConfigServicePatchConfigBody,
|
|
5
|
+
ConfigServiceReadSystemObjectsQueryParams,
|
|
5
6
|
ConfigServiceSearchConfigQueryParams,
|
|
6
7
|
ConfigServiceUpdateConfigBody,
|
|
7
8
|
getConfigService,
|
|
@@ -168,6 +169,13 @@ const getObjectsList = async (params: ApiParams) => {
|
|
|
168
169
|
...params,
|
|
169
170
|
q: params.search,
|
|
170
171
|
}),
|
|
172
|
+
// without this the caller's `search` rides along beside `q`, and the
|
|
173
|
+
// endpoint declares only `q`
|
|
174
|
+
sanitizeToWire(
|
|
175
|
+
getShallowFieldsToSendFromZodSchema(
|
|
176
|
+
ConfigServiceReadSystemObjectsQueryParams,
|
|
177
|
+
),
|
|
178
|
+
),
|
|
171
179
|
camelToSnake(),
|
|
172
180
|
]);
|
|
173
181
|
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { getRoutingChatPlanService } 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
|
+
const fieldsToSend = [
|
|
23
|
+
'name',
|
|
24
|
+
'schema',
|
|
25
|
+
'description',
|
|
26
|
+
'enabled',
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const getChatplansList = async (params: ApiParams) => {
|
|
30
|
+
const defaultObject = {
|
|
31
|
+
enabled: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const { page, size, search, sort, fields, id, name, enabled } =
|
|
35
|
+
applyTransform(params, [
|
|
36
|
+
merge(getDefaultGetParams()),
|
|
37
|
+
starToSearch('search'),
|
|
38
|
+
camelToSnake(),
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const response = await getRoutingChatPlanService().searchChatPlan({
|
|
43
|
+
page,
|
|
44
|
+
size,
|
|
45
|
+
// the generated param is `q`; `search` is what the datalist store sends
|
|
46
|
+
q: search,
|
|
47
|
+
sort,
|
|
48
|
+
fields,
|
|
49
|
+
id,
|
|
50
|
+
name,
|
|
51
|
+
enabled,
|
|
52
|
+
});
|
|
53
|
+
const { items, next } = applyTransform(response.data, [
|
|
54
|
+
snakeToCamel(),
|
|
55
|
+
merge(getDefaultGetListResponse()),
|
|
56
|
+
]);
|
|
57
|
+
return {
|
|
58
|
+
items: applyTransform(items, [
|
|
59
|
+
mergeEach(defaultObject),
|
|
60
|
+
]),
|
|
61
|
+
next,
|
|
62
|
+
};
|
|
63
|
+
} catch (err) {
|
|
64
|
+
throw applyTransform(err, [
|
|
65
|
+
notify,
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const getChatplan = async ({ itemId: id }: GetItemParams) => {
|
|
71
|
+
try {
|
|
72
|
+
const response = await getRoutingChatPlanService().readChatPlan(Number(id));
|
|
73
|
+
return applyTransform(response.data, [
|
|
74
|
+
snakeToCamel(),
|
|
75
|
+
]);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
throw applyTransform(err, [
|
|
78
|
+
notify,
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const addChatplan = async ({ itemInstance }: AddItemParams) => {
|
|
84
|
+
const item = applyTransform(itemInstance, [
|
|
85
|
+
sanitize(fieldsToSend),
|
|
86
|
+
camelToSnake(),
|
|
87
|
+
]);
|
|
88
|
+
try {
|
|
89
|
+
const response = await getRoutingChatPlanService().createChatPlan(item);
|
|
90
|
+
return applyTransform(response.data, [
|
|
91
|
+
snakeToCamel(),
|
|
92
|
+
]);
|
|
93
|
+
} catch (err) {
|
|
94
|
+
throw applyTransform(err, [
|
|
95
|
+
notify,
|
|
96
|
+
]);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const patchChatplan = async ({ changes, id }: PatchItemParams) => {
|
|
101
|
+
const body = applyTransform(changes, [
|
|
102
|
+
sanitize(fieldsToSend),
|
|
103
|
+
camelToSnake(),
|
|
104
|
+
]);
|
|
105
|
+
try {
|
|
106
|
+
const response = await getRoutingChatPlanService().patchChatPlan(
|
|
107
|
+
Number(id),
|
|
108
|
+
body,
|
|
109
|
+
);
|
|
110
|
+
return applyTransform(response.data, [
|
|
111
|
+
snakeToCamel(),
|
|
112
|
+
]);
|
|
113
|
+
} catch (err) {
|
|
114
|
+
throw applyTransform(err, [
|
|
115
|
+
notify,
|
|
116
|
+
]);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const updateChatplan = async ({
|
|
121
|
+
itemInstance,
|
|
122
|
+
itemId: id,
|
|
123
|
+
}: UpdateItemParams) => {
|
|
124
|
+
const item = applyTransform(itemInstance, [
|
|
125
|
+
sanitize(fieldsToSend),
|
|
126
|
+
camelToSnake(),
|
|
127
|
+
]);
|
|
128
|
+
try {
|
|
129
|
+
const response = await getRoutingChatPlanService().updateChatPlan(
|
|
130
|
+
Number(id),
|
|
131
|
+
item,
|
|
132
|
+
);
|
|
133
|
+
return applyTransform(response.data, [
|
|
134
|
+
snakeToCamel(),
|
|
135
|
+
]);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
throw applyTransform(err, [
|
|
138
|
+
notify,
|
|
139
|
+
]);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const deleteChatplan = async ({ id }: DeleteItemParams) => {
|
|
144
|
+
try {
|
|
145
|
+
const response = await getRoutingChatPlanService().deleteChatPlan(
|
|
146
|
+
Number(id),
|
|
147
|
+
);
|
|
148
|
+
return applyTransform(response.data, []);
|
|
149
|
+
} catch (err) {
|
|
150
|
+
throw applyTransform(err, [
|
|
151
|
+
notify,
|
|
152
|
+
]);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const getChatplansLookup = (params: Parameters<typeof getChatplansList>[0]) =>
|
|
157
|
+
getChatplansList({
|
|
158
|
+
...params,
|
|
159
|
+
fields: params.fields || [
|
|
160
|
+
'id',
|
|
161
|
+
'name',
|
|
162
|
+
],
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
export const ChatplansAPI = {
|
|
166
|
+
getList: getChatplansList,
|
|
167
|
+
get: getChatplan,
|
|
168
|
+
add: addChatplan,
|
|
169
|
+
patch: patchChatplan,
|
|
170
|
+
update: updateChatplan,
|
|
171
|
+
delete: deleteChatplan,
|
|
172
|
+
getLookup: getChatplansLookup,
|
|
173
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { getCognitiveProfileService } 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
|
+
* `service` and `properties.region` are returned as the raw backend values.
|
|
24
|
+
* Mapping them onto the localized service lookup and the Microsoft region
|
|
25
|
+
* option object is the caller's job — those lookups are app-side.
|
|
26
|
+
*/
|
|
27
|
+
const fieldsToSend = [
|
|
28
|
+
'name',
|
|
29
|
+
'default',
|
|
30
|
+
'enabled',
|
|
31
|
+
'provider',
|
|
32
|
+
'service',
|
|
33
|
+
'description',
|
|
34
|
+
'properties',
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
/** The form binds `service` and `properties.region` as option objects. */
|
|
38
|
+
const preRequestHandler = (item: ApiParams) => {
|
|
39
|
+
const result = {
|
|
40
|
+
...item,
|
|
41
|
+
service: item.service?.value ?? item.service,
|
|
42
|
+
properties: {
|
|
43
|
+
...item.properties,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
if (result.properties.region) {
|
|
47
|
+
result.properties.region =
|
|
48
|
+
item.properties.region?.id ?? item.properties.region;
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const getCognitiveProfilesList = async (params: ApiParams) => {
|
|
54
|
+
const defaultObject = {
|
|
55
|
+
default: false,
|
|
56
|
+
enabled: false,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const { page, size, search, sort, fields, id, service, enabled } =
|
|
60
|
+
applyTransform(params, [
|
|
61
|
+
merge(getDefaultGetParams()),
|
|
62
|
+
starToSearch('search'),
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const response = await getCognitiveProfileService().searchCognitiveProfile({
|
|
67
|
+
page,
|
|
68
|
+
size,
|
|
69
|
+
// the generated param is `q`; `search` is what the datalist store sends
|
|
70
|
+
q: search,
|
|
71
|
+
sort,
|
|
72
|
+
fields,
|
|
73
|
+
id,
|
|
74
|
+
service,
|
|
75
|
+
enabled,
|
|
76
|
+
});
|
|
77
|
+
const { items, next } = applyTransform(response.data, [
|
|
78
|
+
snakeToCamel(),
|
|
79
|
+
merge(getDefaultGetListResponse()),
|
|
80
|
+
]);
|
|
81
|
+
return {
|
|
82
|
+
items: applyTransform(items, [
|
|
83
|
+
mergeEach(defaultObject),
|
|
84
|
+
]),
|
|
85
|
+
next,
|
|
86
|
+
};
|
|
87
|
+
} catch (err) {
|
|
88
|
+
throw applyTransform(err, [
|
|
89
|
+
notify,
|
|
90
|
+
]);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const getCognitiveProfile = async ({ itemId: id }: GetItemParams) => {
|
|
95
|
+
const defaultObject = {
|
|
96
|
+
properties: {},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
const response = await getCognitiveProfileService().readCognitiveProfile(
|
|
101
|
+
String(id),
|
|
102
|
+
);
|
|
103
|
+
return applyTransform(response.data, [
|
|
104
|
+
snakeToCamel(),
|
|
105
|
+
merge(defaultObject),
|
|
106
|
+
]);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
throw applyTransform(err, [
|
|
109
|
+
notify,
|
|
110
|
+
]);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const addCognitiveProfile = async ({ itemInstance }: AddItemParams) => {
|
|
115
|
+
const item = applyTransform(itemInstance, [
|
|
116
|
+
preRequestHandler,
|
|
117
|
+
sanitize(fieldsToSend),
|
|
118
|
+
camelToSnake(),
|
|
119
|
+
]);
|
|
120
|
+
try {
|
|
121
|
+
const response =
|
|
122
|
+
await getCognitiveProfileService().createCognitiveProfile(item);
|
|
123
|
+
return applyTransform(response.data, [
|
|
124
|
+
snakeToCamel(),
|
|
125
|
+
]);
|
|
126
|
+
} catch (err) {
|
|
127
|
+
throw applyTransform(err, [
|
|
128
|
+
notify,
|
|
129
|
+
]);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const patchCognitiveProfile = async ({ changes, id }: PatchItemParams) => {
|
|
134
|
+
const body = applyTransform(changes, [
|
|
135
|
+
sanitize(fieldsToSend),
|
|
136
|
+
camelToSnake(),
|
|
137
|
+
]);
|
|
138
|
+
try {
|
|
139
|
+
const response = await getCognitiveProfileService().patchCognitiveProfile(
|
|
140
|
+
String(id),
|
|
141
|
+
body,
|
|
142
|
+
);
|
|
143
|
+
return applyTransform(response.data, [
|
|
144
|
+
snakeToCamel(),
|
|
145
|
+
]);
|
|
146
|
+
} catch (err) {
|
|
147
|
+
throw applyTransform(err, [
|
|
148
|
+
notify,
|
|
149
|
+
]);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const updateCognitiveProfile = async ({
|
|
154
|
+
itemInstance,
|
|
155
|
+
itemId: id,
|
|
156
|
+
}: UpdateItemParams) => {
|
|
157
|
+
const item = applyTransform(itemInstance, [
|
|
158
|
+
preRequestHandler,
|
|
159
|
+
sanitize(fieldsToSend),
|
|
160
|
+
camelToSnake(),
|
|
161
|
+
]);
|
|
162
|
+
try {
|
|
163
|
+
const response = await getCognitiveProfileService().updateCognitiveProfile(
|
|
164
|
+
String(id),
|
|
165
|
+
item,
|
|
166
|
+
);
|
|
167
|
+
return applyTransform(response.data, [
|
|
168
|
+
snakeToCamel(),
|
|
169
|
+
]);
|
|
170
|
+
} catch (err) {
|
|
171
|
+
throw applyTransform(err, [
|
|
172
|
+
notify,
|
|
173
|
+
]);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const deleteCognitiveProfile = async ({ id }: DeleteItemParams) => {
|
|
178
|
+
try {
|
|
179
|
+
const response = await getCognitiveProfileService().deleteCognitiveProfile(
|
|
180
|
+
String(id),
|
|
181
|
+
);
|
|
182
|
+
return applyTransform(response.data, []);
|
|
183
|
+
} catch (err) {
|
|
184
|
+
throw applyTransform(err, [
|
|
185
|
+
notify,
|
|
186
|
+
]);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const getCognitiveProfilesLookup = (
|
|
191
|
+
params: Parameters<typeof getCognitiveProfilesList>[0],
|
|
192
|
+
) =>
|
|
193
|
+
getCognitiveProfilesList({
|
|
194
|
+
...params,
|
|
195
|
+
fields: params.fields || [
|
|
196
|
+
'id',
|
|
197
|
+
'name',
|
|
198
|
+
],
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
export const CognitiveProfilesAPI = {
|
|
202
|
+
getList: getCognitiveProfilesList,
|
|
203
|
+
get: getCognitiveProfile,
|
|
204
|
+
add: addCognitiveProfile,
|
|
205
|
+
patch: patchCognitiveProfile,
|
|
206
|
+
update: updateCognitiveProfile,
|
|
207
|
+
delete: deleteCognitiveProfile,
|
|
208
|
+
getLookup: getCognitiveProfilesLookup,
|
|
209
|
+
};
|