@webitel/api-services 0.0.71 → 0.0.73
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/changelogs/changelogs.ts +157 -0
- package/src/api/clients/index.ts +2 -0
- package/src/api/clients/regions/regions.ts +111 -0
- package/types/api/clients/changelogs/changelogs.d.ts +31 -0
- package/types/api/clients/index.d.ts +2 -0
- package/types/api/clients/regions/regions.d.ts +23 -0
package/package.json
CHANGED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configServiceCreateConfigBody,
|
|
3
|
+
configServicePatchConfigBody,
|
|
4
|
+
configServiceSearchConfigQueryParams,
|
|
5
|
+
configServiceUpdateConfigBody,
|
|
6
|
+
getConfigService,
|
|
7
|
+
} from '@webitel/api-services/gen';
|
|
8
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
9
|
+
|
|
10
|
+
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
applyTransform,
|
|
14
|
+
camelToSnake,
|
|
15
|
+
merge,
|
|
16
|
+
notify,
|
|
17
|
+
sanitize,
|
|
18
|
+
snakeToCamel,
|
|
19
|
+
} from '../../transformers';
|
|
20
|
+
|
|
21
|
+
const getChangelogsList = async (params) => {
|
|
22
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
23
|
+
configServiceSearchConfigQueryParams,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const transformedParams = applyTransform(params, [
|
|
27
|
+
merge(getDefaultGetParams()),
|
|
28
|
+
(params) => ({ ...params, q: params.search }),
|
|
29
|
+
sanitize(fieldsToSend),
|
|
30
|
+
camelToSnake(),
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const response =
|
|
35
|
+
await getConfigService().configServiceSearchConfig(transformedParams);
|
|
36
|
+
const { items, next } = applyTransform(response.data, [
|
|
37
|
+
snakeToCamel(),
|
|
38
|
+
merge(getDefaultGetListResponse()),
|
|
39
|
+
]);
|
|
40
|
+
return {
|
|
41
|
+
items,
|
|
42
|
+
next,
|
|
43
|
+
};
|
|
44
|
+
} catch (err) {
|
|
45
|
+
throw applyTransform(err, [notify]);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const getChangelog = async ({ itemId: id }) => {
|
|
50
|
+
try {
|
|
51
|
+
const response = await getConfigService().configServiceReadConfig(id);
|
|
52
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
53
|
+
} catch (err) {
|
|
54
|
+
throw applyTransform(err, [notify]);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const addChangelog = async ({ itemInstance }) => {
|
|
59
|
+
const item = applyTransform(itemInstance, [
|
|
60
|
+
sanitize(
|
|
61
|
+
getShallowFieldsToSendFromZodSchema(configServiceCreateConfigBody),
|
|
62
|
+
),
|
|
63
|
+
camelToSnake(),
|
|
64
|
+
]);
|
|
65
|
+
try {
|
|
66
|
+
const response = await getConfigService().configServiceCreateConfig(item);
|
|
67
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
68
|
+
} catch (err) {
|
|
69
|
+
throw applyTransform(err, [notify]);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const updateChangelog = async ({ itemInstance, itemId: id }) => {
|
|
74
|
+
const item = applyTransform(itemInstance, [
|
|
75
|
+
camelToSnake(),
|
|
76
|
+
sanitize(
|
|
77
|
+
getShallowFieldsToSendFromZodSchema(configServiceUpdateConfigBody),
|
|
78
|
+
),
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const response = await getConfigService().configServiceUpdateConfig(
|
|
83
|
+
id,
|
|
84
|
+
item,
|
|
85
|
+
);
|
|
86
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
87
|
+
} catch (err) {
|
|
88
|
+
throw applyTransform(err, [notify]);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const patchChangelog = async ({ id, changes }) => {
|
|
93
|
+
const body = applyTransform(changes, [
|
|
94
|
+
sanitize(getShallowFieldsToSendFromZodSchema(configServicePatchConfigBody)),
|
|
95
|
+
camelToSnake(),
|
|
96
|
+
]);
|
|
97
|
+
try {
|
|
98
|
+
const response = await getConfigService().configServicePatchConfig(
|
|
99
|
+
id,
|
|
100
|
+
body,
|
|
101
|
+
);
|
|
102
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
103
|
+
} catch (err) {
|
|
104
|
+
throw applyTransform(err, [notify]);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const deleteChangelog = async ({ id }) => {
|
|
109
|
+
try {
|
|
110
|
+
const response = await getConfigService().configServiceDeleteConfig(id);
|
|
111
|
+
return applyTransform(response.data, []);
|
|
112
|
+
} catch (err) {
|
|
113
|
+
throw applyTransform(err, [notify]);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const getLookup = (params) =>
|
|
118
|
+
getChangelogsList({
|
|
119
|
+
...params,
|
|
120
|
+
fields: params.fields || ['id', 'object'],
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const getObjectsList = async (params) => {
|
|
124
|
+
const transformedParams = applyTransform(params, [
|
|
125
|
+
merge(getDefaultGetParams()),
|
|
126
|
+
(params) => ({ ...params, q: params.search }),
|
|
127
|
+
camelToSnake(),
|
|
128
|
+
]);
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
const response =
|
|
132
|
+
await getConfigService().configServiceReadSystemObjects(
|
|
133
|
+
transformedParams,
|
|
134
|
+
);
|
|
135
|
+
const { items, next } = applyTransform(response.data, [
|
|
136
|
+
snakeToCamel(),
|
|
137
|
+
merge(getDefaultGetListResponse()),
|
|
138
|
+
]);
|
|
139
|
+
return {
|
|
140
|
+
items,
|
|
141
|
+
next,
|
|
142
|
+
};
|
|
143
|
+
} catch (err) {
|
|
144
|
+
throw applyTransform(err, [notify]);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export const ChangelogsAPI = {
|
|
149
|
+
getList: getChangelogsList,
|
|
150
|
+
get: getChangelog,
|
|
151
|
+
add: addChangelog,
|
|
152
|
+
update: updateChangelog,
|
|
153
|
+
patch: patchChangelog,
|
|
154
|
+
delete: deleteChangelog,
|
|
155
|
+
getLookup,
|
|
156
|
+
getObjectsList,
|
|
157
|
+
};
|
package/src/api/clients/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './caseSources/caseSources';
|
|
|
12
12
|
export * from './caseStatusConditions/caseStatusConditions';
|
|
13
13
|
export * from './caseStatuses/caseStatuses';
|
|
14
14
|
export * from './catalog/catalog';
|
|
15
|
+
export * from './changelogs/changelogs';
|
|
15
16
|
export * from './chatGateways/chatGateways';
|
|
16
17
|
export * from './communications/communications';
|
|
17
18
|
export * from './configurations/configurations';
|
|
@@ -29,6 +30,7 @@ export * from './pdfServices/pdfServices';
|
|
|
29
30
|
export * from './phones/phones';
|
|
30
31
|
export * from './queues/queues';
|
|
31
32
|
export * from './quickReplies/quickReplies';
|
|
33
|
+
export * from './regions/regions';
|
|
32
34
|
// export * from './roles/roles'; fixme: ApplicationAccess import
|
|
33
35
|
export * from './skills/skills';
|
|
34
36
|
export * from './slas/slas';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { RegionServiceApiFactory } from 'webitel-sdk';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getDefaultGetListResponse,
|
|
5
|
+
getDefaultGetParams,
|
|
6
|
+
getDefaultInstance,
|
|
7
|
+
getDefaultOpenAPIConfig,
|
|
8
|
+
} from '../../defaults';
|
|
9
|
+
import {
|
|
10
|
+
applyTransform,
|
|
11
|
+
camelToSnake,
|
|
12
|
+
merge,
|
|
13
|
+
notify,
|
|
14
|
+
sanitize,
|
|
15
|
+
snakeToCamel,
|
|
16
|
+
starToSearch,
|
|
17
|
+
} from '../../transformers';
|
|
18
|
+
|
|
19
|
+
const instance = getDefaultInstance();
|
|
20
|
+
const configuration = getDefaultOpenAPIConfig();
|
|
21
|
+
|
|
22
|
+
const regionService = RegionServiceApiFactory(configuration, '', instance);
|
|
23
|
+
|
|
24
|
+
const getRegionsList = async (params) => {
|
|
25
|
+
const { page, size, search, sort, fields, id } = applyTransform(params, [
|
|
26
|
+
merge(getDefaultGetParams()),
|
|
27
|
+
starToSearch('search'),
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const response = await regionService.searchRegion(
|
|
32
|
+
page,
|
|
33
|
+
size,
|
|
34
|
+
search,
|
|
35
|
+
sort,
|
|
36
|
+
fields,
|
|
37
|
+
id,
|
|
38
|
+
);
|
|
39
|
+
const { items, next } = applyTransform(response.data, [
|
|
40
|
+
snakeToCamel(),
|
|
41
|
+
merge(getDefaultGetListResponse()),
|
|
42
|
+
]);
|
|
43
|
+
return {
|
|
44
|
+
items,
|
|
45
|
+
next,
|
|
46
|
+
};
|
|
47
|
+
} catch (err) {
|
|
48
|
+
throw applyTransform(err, [notify]);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const getRegion = async ({ itemId: id }) => {
|
|
53
|
+
try {
|
|
54
|
+
const response = await regionService.readRegion(id);
|
|
55
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
56
|
+
} catch (err) {
|
|
57
|
+
throw applyTransform(err, [notify]);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const fieldsToSend = ['name', 'timezone', 'description'];
|
|
62
|
+
|
|
63
|
+
const addRegion = async ({ itemInstance }) => {
|
|
64
|
+
const item = applyTransform(itemInstance, [
|
|
65
|
+
sanitize(fieldsToSend),
|
|
66
|
+
camelToSnake(),
|
|
67
|
+
]);
|
|
68
|
+
try {
|
|
69
|
+
const response = await regionService.createRegion(item);
|
|
70
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
71
|
+
} catch (err) {
|
|
72
|
+
throw applyTransform(err, [notify]);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const updateRegion = async ({ itemInstance, itemId: id }) => {
|
|
77
|
+
const item = applyTransform(itemInstance, [
|
|
78
|
+
sanitize(fieldsToSend),
|
|
79
|
+
camelToSnake(),
|
|
80
|
+
]);
|
|
81
|
+
try {
|
|
82
|
+
const response = await regionService.updateRegion(id, item);
|
|
83
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
84
|
+
} catch (err) {
|
|
85
|
+
throw applyTransform(err, [notify]);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const deleteRegion = async ({ id }) => {
|
|
90
|
+
try {
|
|
91
|
+
const response = await regionService.deleteRegion(id);
|
|
92
|
+
return applyTransform(response.data, []);
|
|
93
|
+
} catch (err) {
|
|
94
|
+
throw applyTransform(err, [notify]);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const getRegionsLookup = (params) =>
|
|
99
|
+
getRegionsList({
|
|
100
|
+
...params,
|
|
101
|
+
fields: params.fields || ['id', 'name'],
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export const RegionsAPI = {
|
|
105
|
+
getList: getRegionsList,
|
|
106
|
+
get: getRegion,
|
|
107
|
+
add: addRegion,
|
|
108
|
+
update: updateRegion,
|
|
109
|
+
delete: deleteRegion,
|
|
110
|
+
getLookup: getRegionsLookup,
|
|
111
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const ChangelogsAPI: {
|
|
2
|
+
getList: (params: any) => Promise<{
|
|
3
|
+
items: any;
|
|
4
|
+
next: any;
|
|
5
|
+
}>;
|
|
6
|
+
get: ({ itemId: id }: {
|
|
7
|
+
itemId: any;
|
|
8
|
+
}) => Promise<any>;
|
|
9
|
+
add: ({ itemInstance }: {
|
|
10
|
+
itemInstance: any;
|
|
11
|
+
}) => Promise<any>;
|
|
12
|
+
update: ({ itemInstance, itemId: id }: {
|
|
13
|
+
itemInstance: any;
|
|
14
|
+
itemId: any;
|
|
15
|
+
}) => Promise<any>;
|
|
16
|
+
patch: ({ id, changes }: {
|
|
17
|
+
id: any;
|
|
18
|
+
changes: any;
|
|
19
|
+
}) => Promise<any>;
|
|
20
|
+
delete: ({ id }: {
|
|
21
|
+
id: any;
|
|
22
|
+
}) => Promise<any>;
|
|
23
|
+
getLookup: (params: any) => Promise<{
|
|
24
|
+
items: any;
|
|
25
|
+
next: any;
|
|
26
|
+
}>;
|
|
27
|
+
getObjectsList: (params: any) => Promise<{
|
|
28
|
+
items: any;
|
|
29
|
+
next: any;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
@@ -12,6 +12,7 @@ export * from './caseSources/caseSources';
|
|
|
12
12
|
export * from './caseStatusConditions/caseStatusConditions';
|
|
13
13
|
export * from './caseStatuses/caseStatuses';
|
|
14
14
|
export * from './catalog/catalog';
|
|
15
|
+
export * from './changelogs/changelogs';
|
|
15
16
|
export * from './chatGateways/chatGateways';
|
|
16
17
|
export * from './communications/communications';
|
|
17
18
|
export * from './configurations/configurations';
|
|
@@ -37,3 +38,4 @@ export * from './wtTypes/adjunctTypes/adjunctTypes';
|
|
|
37
38
|
export * from './wtTypes/sysTypes/sysTypes';
|
|
38
39
|
export * from './wtTypes/typeExtensions/typeExtensions';
|
|
39
40
|
export * from './сontacts';
|
|
41
|
+
export * from './regions/regions';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const RegionsAPI: {
|
|
2
|
+
getList: (params: any) => Promise<{
|
|
3
|
+
items: any;
|
|
4
|
+
next: any;
|
|
5
|
+
}>;
|
|
6
|
+
get: ({ itemId: id }: {
|
|
7
|
+
itemId: any;
|
|
8
|
+
}) => Promise<any>;
|
|
9
|
+
add: ({ itemInstance }: {
|
|
10
|
+
itemInstance: any;
|
|
11
|
+
}) => Promise<any>;
|
|
12
|
+
update: ({ itemInstance, itemId: id }: {
|
|
13
|
+
itemInstance: any;
|
|
14
|
+
itemId: any;
|
|
15
|
+
}) => Promise<any>;
|
|
16
|
+
delete: ({ id }: {
|
|
17
|
+
id: any;
|
|
18
|
+
}) => Promise<any>;
|
|
19
|
+
getLookup: (params: any) => Promise<{
|
|
20
|
+
items: any;
|
|
21
|
+
next: any;
|
|
22
|
+
}>;
|
|
23
|
+
};
|