@webitel/api-services 0.1.56 → 0.1.57
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/index.ts +1 -0
- package/src/api/clients/onlineSkills/onlineSkills.ts +172 -0
- package/src/validations/_shared/lookup.validations.ts +11 -0
- package/src/validations/index.ts +1 -0
- package/src/validations/onlineSkill/onlineSkill.validations.ts +10 -0
- package/types/.tsbuildinfo +1 -1
- package/types/api/clients/index.d.ts +1 -0
- package/types/api/clients/onlineSkills/onlineSkills.d.ts +24 -0
- package/types/validations/_shared/lookup.validations.d.ts +9 -0
- package/types/validations/index.d.ts +1 -0
- package/types/validations/onlineSkill/onlineSkill.validations.d.ts +11 -0
package/package.json
CHANGED
package/src/api/clients/index.ts
CHANGED
|
@@ -31,6 +31,7 @@ export * from './media/media';
|
|
|
31
31
|
export * from './messageService/messageService';
|
|
32
32
|
export * from './oauthApps/oauthApps';
|
|
33
33
|
export * from './object/object';
|
|
34
|
+
export * from './onlineSkills/onlineSkills';
|
|
34
35
|
export * from './pdfServices/pdfServices';
|
|
35
36
|
export * from './phones/phones';
|
|
36
37
|
export * from './queues/queues';
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
2
|
+
import {
|
|
3
|
+
getOnlineSkills,
|
|
4
|
+
PatchOnlineSkillsBody,
|
|
5
|
+
SearchOnlineSkillsQueryParams,
|
|
6
|
+
UpdateOnlineSkillsBody,
|
|
7
|
+
} from '../../../gen';
|
|
8
|
+
import { getDefaultGetListResponse } from '../../defaults';
|
|
9
|
+
import {
|
|
10
|
+
applyTransform,
|
|
11
|
+
camelToSnake,
|
|
12
|
+
merge,
|
|
13
|
+
notify,
|
|
14
|
+
sanitize,
|
|
15
|
+
snakeToCamel,
|
|
16
|
+
starToSearch,
|
|
17
|
+
} from '../../transformers';
|
|
18
|
+
import type { ApiId, ApiParams } from '../_shared/types';
|
|
19
|
+
|
|
20
|
+
const itemResponseHandler = (item: ApiParams) => {
|
|
21
|
+
return item.item;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const getOnlineSkillsList = async (params: ApiParams) => {
|
|
25
|
+
const listFieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
26
|
+
SearchOnlineSkillsQueryParams,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const transformedParams = applyTransform(params, [
|
|
30
|
+
sanitize(listFieldsToSend),
|
|
31
|
+
(params) => ({
|
|
32
|
+
...params,
|
|
33
|
+
skipDefault: params.skipDefault || true,
|
|
34
|
+
fields: [
|
|
35
|
+
'id',
|
|
36
|
+
...(params.fields || [
|
|
37
|
+
'name',
|
|
38
|
+
]),
|
|
39
|
+
],
|
|
40
|
+
}),
|
|
41
|
+
camelToSnake(),
|
|
42
|
+
starToSearch('q'),
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
const response =
|
|
47
|
+
await getOnlineSkills().searchOnlineSkills(transformedParams);
|
|
48
|
+
const { items, next } = applyTransform(response.data, [
|
|
49
|
+
snakeToCamel(),
|
|
50
|
+
merge(getDefaultGetListResponse()),
|
|
51
|
+
]);
|
|
52
|
+
return {
|
|
53
|
+
items,
|
|
54
|
+
next,
|
|
55
|
+
};
|
|
56
|
+
} catch (err) {
|
|
57
|
+
throw applyTransform(err, [
|
|
58
|
+
notify,
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const getOnlineSkill = async ({ itemId: id }: { itemId: ApiId }) => {
|
|
64
|
+
try {
|
|
65
|
+
const response = await getOnlineSkills().getOnlineSkills(String(id));
|
|
66
|
+
return applyTransform(response.data, [
|
|
67
|
+
snakeToCamel(),
|
|
68
|
+
itemResponseHandler,
|
|
69
|
+
]);
|
|
70
|
+
} catch (err) {
|
|
71
|
+
throw applyTransform(err, [
|
|
72
|
+
notify,
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const addOnlineSkill = async ({
|
|
78
|
+
itemInstance,
|
|
79
|
+
}: {
|
|
80
|
+
itemInstance: ApiParams;
|
|
81
|
+
}) => {
|
|
82
|
+
const item = applyTransform(itemInstance, [
|
|
83
|
+
camelToSnake(),
|
|
84
|
+
]);
|
|
85
|
+
try {
|
|
86
|
+
const response = await getOnlineSkills().createOnlineSkills(item);
|
|
87
|
+
return applyTransform(response.data, [
|
|
88
|
+
snakeToCamel(),
|
|
89
|
+
itemResponseHandler,
|
|
90
|
+
]);
|
|
91
|
+
} catch (err) {
|
|
92
|
+
throw applyTransform(err, [
|
|
93
|
+
notify,
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const updateOnlineSkill = async ({
|
|
99
|
+
itemInstance,
|
|
100
|
+
itemId: id,
|
|
101
|
+
}: {
|
|
102
|
+
itemInstance: ApiParams;
|
|
103
|
+
itemId: ApiId;
|
|
104
|
+
}) => {
|
|
105
|
+
const changes = applyTransform(itemInstance, [
|
|
106
|
+
sanitize(getShallowFieldsToSendFromZodSchema(UpdateOnlineSkillsBody)),
|
|
107
|
+
camelToSnake(),
|
|
108
|
+
]);
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const response = await getOnlineSkills().updateOnlineSkills(
|
|
112
|
+
String(id),
|
|
113
|
+
changes,
|
|
114
|
+
);
|
|
115
|
+
return applyTransform(response.data, [
|
|
116
|
+
snakeToCamel(),
|
|
117
|
+
itemResponseHandler,
|
|
118
|
+
]);
|
|
119
|
+
} catch (err) {
|
|
120
|
+
throw applyTransform(err, [
|
|
121
|
+
notify,
|
|
122
|
+
]);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const patchOnlineSkill = async ({
|
|
127
|
+
changes,
|
|
128
|
+
id,
|
|
129
|
+
}: {
|
|
130
|
+
changes: ApiParams;
|
|
131
|
+
id: ApiId;
|
|
132
|
+
}) => {
|
|
133
|
+
const changesBody = applyTransform(changes, [
|
|
134
|
+
sanitize(getShallowFieldsToSendFromZodSchema(PatchOnlineSkillsBody)),
|
|
135
|
+
camelToSnake(),
|
|
136
|
+
]);
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
const response = await getOnlineSkills().patchOnlineSkills(
|
|
140
|
+
String(id),
|
|
141
|
+
changesBody,
|
|
142
|
+
);
|
|
143
|
+
return applyTransform(response.data, [
|
|
144
|
+
snakeToCamel(),
|
|
145
|
+
itemResponseHandler,
|
|
146
|
+
]);
|
|
147
|
+
} catch (err) {
|
|
148
|
+
throw applyTransform(err, [
|
|
149
|
+
notify,
|
|
150
|
+
]);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const deleteOnlineSkill = async ({ id }: { id: ApiId }) => {
|
|
155
|
+
try {
|
|
156
|
+
const response = await getOnlineSkills().deleteOnlineSkills(String(id));
|
|
157
|
+
return applyTransform(response.data, []);
|
|
158
|
+
} catch (err) {
|
|
159
|
+
throw applyTransform(err, [
|
|
160
|
+
notify,
|
|
161
|
+
]);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export const OnlineSkillsAPI = {
|
|
166
|
+
getList: getOnlineSkillsList,
|
|
167
|
+
get: getOnlineSkill,
|
|
168
|
+
add: addOnlineSkill,
|
|
169
|
+
update: updateOnlineSkill,
|
|
170
|
+
patch: patchOnlineSkill,
|
|
171
|
+
delete: deleteOnlineSkill,
|
|
172
|
+
};
|
package/src/validations/index.ts
CHANGED
|
@@ -3,4 +3,5 @@ export * from './caseSource/caseSource.validations';
|
|
|
3
3
|
export * from './caseStatus/caseStatus.validations';
|
|
4
4
|
export * from './caseStatusCondition/caseStatusCondition.validations';
|
|
5
5
|
export * from './OAuth/OAuth.validations';
|
|
6
|
+
export * from './onlineSkill/onlineSkill.validations';
|
|
6
7
|
export * from './types';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EngineOnlineSkills } from '@webitel/api-services/gen/models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { lookupSchema } from '../_shared/lookup.validations';
|
|
4
|
+
import type { ZodShape } from '../types';
|
|
5
|
+
|
|
6
|
+
export const onlineSkillSchema = z.object<ZodShape<EngineOnlineSkills>>({
|
|
7
|
+
name: z.string().min(1),
|
|
8
|
+
description: z.string().optional(),
|
|
9
|
+
skills: z.array(lookupSchema).optional(),
|
|
10
|
+
});
|