@webitel/api-services 0.1.53 → 0.1.55
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/axios/generateInstance.ts +1 -1
- package/src/api/clients/chatDialogs/chatDialogs.ts +62 -0
- package/src/api/clients/index.ts +1 -0
- package/src/api/transformers/camelToSnake/camelToSnake.transformer.ts +1 -1
- package/src/api/transformers/notify/notify.transformer.ts +1 -1
- package/src/api/transformers/snakeToCamel/snakeToCamel.transformer.ts +1 -1
- package/src/config/config.ts +5 -4
- package/src/scripts/downloadFile/types/downloadFile.types.ts +1 -1
- package/src/utils/api/caseConverters.ts +2 -2
- package/src/validations/OAuth/OAuth.validations.ts +1 -1
- package/types/.tsbuildinfo +1 -1
- package/types/api/axios/generateInstance.d.ts +1 -2
- package/types/api/clients/chatDialogs/chatDialogs.d.ts +10 -0
- package/types/api/clients/index.d.ts +1 -0
- package/types/api/transformers/camelToSnake/camelToSnake.transformer.d.ts +1 -1
- package/types/api/transformers/snakeToCamel/snakeToCamel.transformer.d.ts +1 -1
- package/types/config/config.d.ts +2 -2
- package/types/scripts/downloadFile/types/downloadFile.types.d.ts +1 -1
- package/types/utils/api/caseConverters.d.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios, { type CreateAxiosDefaults } from 'axios';
|
|
2
2
|
|
|
3
|
-
interface GenerateInstanceOptions extends CreateAxiosDefaults {
|
|
3
|
+
export interface GenerateInstanceOptions extends CreateAxiosDefaults {
|
|
4
4
|
interceptors?: {
|
|
5
5
|
request?: Parameters<
|
|
6
6
|
ReturnType<typeof axios.create>['interceptors']['request']['use']
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CatalogGetDialogsQueryParams,
|
|
3
|
+
getMessages,
|
|
4
|
+
} from '@webitel/api-services/gen';
|
|
5
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
6
|
+
|
|
7
|
+
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
8
|
+
import {
|
|
9
|
+
applyTransform,
|
|
10
|
+
merge,
|
|
11
|
+
notify,
|
|
12
|
+
sanitize,
|
|
13
|
+
snakeToCamel,
|
|
14
|
+
starToSearch,
|
|
15
|
+
} from '../../transformers';
|
|
16
|
+
|
|
17
|
+
const getDialogsList = async (params) => {
|
|
18
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
19
|
+
CatalogGetDialogsQueryParams,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const requestParams = applyTransform(params, [
|
|
23
|
+
merge(getDefaultGetParams()),
|
|
24
|
+
(params) => ({
|
|
25
|
+
...params,
|
|
26
|
+
q: params.search,
|
|
27
|
+
}),
|
|
28
|
+
starToSearch('q'),
|
|
29
|
+
sanitize(fieldsToSend),
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const response = await getMessages().catalogGetDialogs(requestParams);
|
|
34
|
+
const { data, next } = applyTransform(response.data, [
|
|
35
|
+
merge(getDefaultGetListResponse()),
|
|
36
|
+
]);
|
|
37
|
+
return {
|
|
38
|
+
items: applyTransform(data || [], [
|
|
39
|
+
snakeToCamel(),
|
|
40
|
+
]),
|
|
41
|
+
next,
|
|
42
|
+
};
|
|
43
|
+
} catch (err) {
|
|
44
|
+
throw applyTransform(err, [
|
|
45
|
+
notify,
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const getLookup = (params) =>
|
|
51
|
+
getDialogsList({
|
|
52
|
+
...params,
|
|
53
|
+
fields: params.fields || [
|
|
54
|
+
'id',
|
|
55
|
+
'title',
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export const ChatDialogsAPI = {
|
|
60
|
+
getList: getDialogsList,
|
|
61
|
+
getLookup,
|
|
62
|
+
};
|
package/src/api/clients/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from './caseStatusConditions/caseStatusConditions';
|
|
|
15
15
|
export * from './caseStatuses/caseStatuses';
|
|
16
16
|
export * from './catalog/catalog';
|
|
17
17
|
export * from './changelogs/changelogs';
|
|
18
|
+
export * from './chatDialogs/chatDialogs';
|
|
18
19
|
export * from './chatGateways/chatGateways';
|
|
19
20
|
export * from './communications/communications';
|
|
20
21
|
export * from './configurations/configurations';
|
|
@@ -12,7 +12,7 @@ const notifyTransformer = (notificationObject) => {
|
|
|
12
12
|
so, create a callback which will send notification with params, passed to it
|
|
13
13
|
*/
|
|
14
14
|
const callback = ({ type, text }) =>
|
|
15
|
-
apiServicesConfig.eventBus
|
|
15
|
+
apiServicesConfig.eventBus?.$emit('notification', {
|
|
16
16
|
type,
|
|
17
17
|
text,
|
|
18
18
|
});
|
package/src/config/config.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { messages } from '../locale';
|
|
|
4
4
|
export type ApiServicesConfig = {
|
|
5
5
|
eventBus?: {
|
|
6
6
|
$emit: (event: string, payload: unknown) => unknown;
|
|
7
|
-
};
|
|
8
|
-
i18n?: I18n;
|
|
7
|
+
} | null;
|
|
8
|
+
i18n?: I18n | null;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export const config: ApiServicesConfig = {
|
|
@@ -17,9 +17,10 @@ export const setConfig = (conf: ApiServicesConfig) => {
|
|
|
17
17
|
Object.assign(config, conf);
|
|
18
18
|
|
|
19
19
|
// Automatically merge api-services locale messages into the provided i18n instance
|
|
20
|
-
|
|
20
|
+
const i18n = conf.i18n;
|
|
21
|
+
if (i18n?.global) {
|
|
21
22
|
Object.entries(messages).forEach(([locale, localeMessages]) => {
|
|
22
|
-
|
|
23
|
+
i18n.global.mergeLocaleMessage(locale, localeMessages);
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
};
|
|
@@ -62,14 +62,14 @@ const convertObject =
|
|
|
62
62
|
return newObj;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
export const objSnakeToCamel = (obj, skipKeys = []) => {
|
|
65
|
+
export const objSnakeToCamel = (obj, skipKeys: string[] = []) => {
|
|
66
66
|
return convertObject({
|
|
67
67
|
self: objSnakeToCamel,
|
|
68
68
|
converter: snakeToCamel,
|
|
69
69
|
})(obj, skipKeys);
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
export const objCamelToSnake = (obj, skipKeys = []) => {
|
|
72
|
+
export const objCamelToSnake = (obj, skipKeys: string[] = []) => {
|
|
73
73
|
return convertObject({
|
|
74
74
|
self: objCamelToSnake,
|
|
75
75
|
converter: camelToSnake,
|