@webitel/api-services 26.12.21 → 26.12.23
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/_shared/appUrls.ts +11 -0
- package/src/api/clients/chatGateways/__tests__/chatGatewayChannels.spec.ts +84 -0
- package/src/api/clients/chatGateways/__tests__/chatGateways.spec.ts +115 -0
- package/src/api/clients/chatGateways/chatGatewayChannels.ts +162 -0
- package/src/api/clients/chatGateways/chatGateways.ts +66 -25
- package/src/api/clients/chatGateways/defaults/chatGatewayProviderDefaults.ts +91 -0
- package/src/api/clients/chatGateways/defaults/defaultChatGateway.ts +3 -1
- package/src/api/clients/chatGateways/defaults/webChatGateway.ts +8 -5
- package/src/api/clients/cognitiveProfiles/cognitiveProfiles.ts +8 -32
- package/src/api/clients/cognitiveProfiles/defaults/cognitiveProfileDefaults.ts +39 -0
- package/src/api/clients/emailProfiles/emailProfiles.ts +6 -19
- package/src/api/clients/gateways/__tests__/gateways.spec.ts +138 -0
- package/src/api/clients/gateways/gateways.ts +60 -52
- package/src/api/clients/importTemplates/importTemplates.ts +36 -21
- package/src/api/clients/index.ts +2 -0
- package/src/api/clients/storagePolicies/storagePolicies.ts +24 -36
- package/src/api/clients/triggers/triggerJobs.ts +22 -12
- package/src/api/clients/triggers/triggers.ts +12 -37
- package/src/enums/ChatGatewayChannelSetup/ChatGatewayChannelSetup.ts +10 -0
- package/src/enums/GatewayIpAclProtocol/GatewayIpAclProtocol.ts +8 -0
- package/src/enums/GatewayRegisterState/GatewayRegisterState.ts +17 -0
- package/src/enums/StorageType/StorageType.ts +10 -0
- package/src/enums/WebchatAlternativeChannel/WebchatAlternativeChannel.ts +15 -0
- package/src/enums/index.ts +10 -0
- package/src/locale/en/en.ts +8 -0
- package/src/locale/es/es.ts +8 -0
- package/src/locale/kz/kz.ts +8 -0
- package/src/locale/pl/pl.ts +8 -0
- package/src/locale/ro/ro.ts +8 -0
- package/src/locale/ru/ru.ts +8 -0
- package/src/locale/uk/uk.ts +8 -0
- package/src/locale/uz/uz.ts +8 -0
- package/src/locale/vi/vi.ts +8 -0
- package/src/scripts/convertDuration/__tests__/convertDurationWithMilliseconds.spec.ts +19 -0
- package/src/scripts/convertDuration/convertDurationWithMilliseconds.ts +18 -0
- package/src/scripts/index.ts +2 -0
- package/src/validations/_shared/ip.validations.ts +10 -0
- package/src/validations/backendProfile/__tests__/backendProfile.validations.spec.ts +104 -0
- package/src/validations/backendProfile/backendProfile.validations.ts +79 -0
- package/src/validations/chatGateway/__tests__/chatGateway.validations.spec.ts +189 -0
- package/src/validations/chatGateway/chatGateway.validations.ts +452 -0
- package/src/validations/cognitiveProfile/__tests__/cognitiveProfile.validations.spec.ts +83 -0
- package/src/validations/cognitiveProfile/cognitiveProfile.validations.ts +74 -0
- package/src/validations/device/device.validations.ts +2 -8
- package/src/validations/emailProfile/__tests__/emailProfile.validations.spec.ts +105 -0
- package/src/validations/emailProfile/emailProfile.validations.ts +113 -0
- package/src/validations/gateway/__tests__/gateway.validations.spec.ts +168 -0
- package/src/validations/gateway/gateway.validations.ts +138 -0
- package/src/validations/importTemplate/__tests__/importTemplate.validations.spec.ts +77 -0
- package/src/validations/importTemplate/importTemplate.validations.ts +56 -0
- package/src/validations/index.ts +8 -0
- package/src/validations/storagePolicy/__tests__/storagePolicy.validations.spec.ts +52 -0
- package/src/validations/storagePolicy/storagePolicy.validations.ts +36 -0
- package/src/validations/trigger/__tests__/trigger.validations.spec.ts +92 -0
- package/src/validations/trigger/trigger.validations.ts +82 -0
- package/types/.tsbuildinfo +1 -1
- package/types/api/clients/_shared/appUrls.d.ts +11 -0
- package/types/api/clients/chatGateways/chatGatewayChannels.d.ts +62 -0
- package/types/api/clients/chatGateways/chatGateways.d.ts +4 -4
- package/types/api/clients/chatGateways/defaults/chatGatewayProviderDefaults.d.ts +21 -0
- package/types/api/clients/chatGateways/defaults/defaultChatGateway.d.ts +3 -1
- package/types/api/clients/chatGateways/defaults/webChatGateway.d.ts +5 -4
- package/types/api/clients/cognitiveProfiles/cognitiveProfiles.d.ts +1 -1
- package/types/api/clients/cognitiveProfiles/defaults/cognitiveProfileDefaults.d.ts +13 -0
- package/types/api/clients/importTemplates/importTemplates.d.ts +2 -2
- package/types/api/clients/index.d.ts +2 -0
- package/types/enums/ChatGatewayChannelSetup/ChatGatewayChannelSetup.d.ts +8 -0
- package/types/enums/GatewayIpAclProtocol/GatewayIpAclProtocol.d.ts +6 -0
- package/types/enums/GatewayRegisterState/GatewayRegisterState.d.ts +15 -0
- package/types/enums/StorageType/StorageType.d.ts +9 -0
- package/types/enums/WebchatAlternativeChannel/WebchatAlternativeChannel.d.ts +13 -0
- package/types/enums/index.d.ts +6 -1
- package/types/locale/en/en.d.ts +7 -0
- package/types/locale/es/es.d.ts +7 -0
- package/types/locale/index.d.ts +63 -0
- package/types/locale/kz/kz.d.ts +7 -0
- package/types/locale/pl/pl.d.ts +7 -0
- package/types/locale/ro/ro.d.ts +7 -0
- package/types/locale/ru/ru.d.ts +7 -0
- package/types/locale/uk/uk.d.ts +7 -0
- package/types/locale/uz/uz.d.ts +7 -0
- package/types/locale/vi/vi.d.ts +7 -0
- package/types/scripts/convertDuration/convertDurationWithMilliseconds.d.ts +6 -0
- package/types/scripts/index.d.ts +2 -1
- package/types/validations/_shared/ip.validations.d.ts +4 -0
- package/types/validations/backendProfile/backendProfile.validations.d.ts +24 -0
- package/types/validations/chatGateway/chatGateway.validations.d.ts +165 -0
- package/types/validations/cognitiveProfile/cognitiveProfile.validations.d.ts +28 -0
- package/types/validations/emailProfile/emailProfile.validations.d.ts +36 -0
- package/types/validations/gateway/gateway.validations.d.ts +48 -0
- package/types/validations/importTemplate/importTemplate.validations.d.ts +62 -0
- package/types/validations/index.d.ts +8 -0
- package/types/validations/storagePolicy/storagePolicy.validations.d.ts +26 -0
- package/types/validations/trigger/trigger.validations.d.ts +38 -0
- package/src/api/clients/chatGateways/enums/WebchatAlternativeChannel.enum.ts +0 -12
- package/src/api/clients/gateways/defaults/defaultGateway.ts +0 -9
- package/src/api/clients/gateways/defaults/registerGateway.ts +0 -12
- package/src/api/clients/gateways/defaults/trunkingGateway.ts +0 -16
- package/types/api/clients/chatGateways/enums/WebchatAlternativeChannel.enum.d.ts +0 -12
- package/types/api/clients/gateways/defaults/defaultGateway.d.ts +0 -8
- package/types/api/clients/gateways/defaults/registerGateway.d.ts +0 -13
- package/types/api/clients/gateways/defaults/trunkingGateway.d.ts +0 -16
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
2
|
+
import { cognitiveProfileSchema } from '@webitel/api-services/validations';
|
|
1
3
|
import { getCognitiveProfileService } from '../../../gen-wire';
|
|
2
4
|
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
3
5
|
import {
|
|
@@ -22,36 +24,10 @@ import type {
|
|
|
22
24
|
|
|
23
25
|
const baseUrl = '/storage/cognitive_profiles';
|
|
24
26
|
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
const fieldsToSend = [
|
|
31
|
-
'name',
|
|
32
|
-
'default',
|
|
33
|
-
'enabled',
|
|
34
|
-
'provider',
|
|
35
|
-
'service',
|
|
36
|
-
'description',
|
|
37
|
-
'properties',
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
/** The form binds `service` and `properties.region` as option objects. */
|
|
41
|
-
const preRequestHandler = (item: ApiParams) => {
|
|
42
|
-
const result = {
|
|
43
|
-
...item,
|
|
44
|
-
service: item.service?.value ?? item.service,
|
|
45
|
-
properties: {
|
|
46
|
-
...item.properties,
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
if (result.properties.region) {
|
|
50
|
-
result.properties.region =
|
|
51
|
-
item.properties.region?.id ?? item.properties.region;
|
|
52
|
-
}
|
|
53
|
-
return result;
|
|
54
|
-
};
|
|
27
|
+
/** [Claude] the card schema's fields; `id` goes in the url, not the body */
|
|
28
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
29
|
+
cognitiveProfileSchema,
|
|
30
|
+
).filter((field) => field !== 'id');
|
|
55
31
|
|
|
56
32
|
const getCognitiveProfilesList = async (params: ApiParams) => {
|
|
57
33
|
const defaultObject = {
|
|
@@ -116,7 +92,6 @@ const getCognitiveProfile = async ({ itemId: id }: GetItemParams) => {
|
|
|
116
92
|
|
|
117
93
|
const addCognitiveProfile = async ({ itemInstance }: AddItemParams) => {
|
|
118
94
|
const item = applyTransform(itemInstance, [
|
|
119
|
-
preRequestHandler,
|
|
120
95
|
sanitize(fieldsToSend),
|
|
121
96
|
camelToSnake(),
|
|
122
97
|
]);
|
|
@@ -158,7 +133,6 @@ const updateCognitiveProfile = async ({
|
|
|
158
133
|
itemId: id,
|
|
159
134
|
}: UpdateItemParams) => {
|
|
160
135
|
const item = applyTransform(itemInstance, [
|
|
161
|
-
preRequestHandler,
|
|
162
136
|
sanitize(fieldsToSend),
|
|
163
137
|
camelToSnake(),
|
|
164
138
|
]);
|
|
@@ -212,3 +186,5 @@ export const CognitiveProfilesAPI = {
|
|
|
212
186
|
|
|
213
187
|
...generatePermissionsApi(baseUrl),
|
|
214
188
|
};
|
|
189
|
+
|
|
190
|
+
export { getCognitiveProfileDefaults } from './defaults/cognitiveProfileDefaults';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StorageProviderType,
|
|
3
|
+
StorageServiceType,
|
|
4
|
+
} from '@webitel/api-services/gen/models';
|
|
5
|
+
|
|
6
|
+
const DEFAULT_LOCALE = 'en-US';
|
|
7
|
+
|
|
8
|
+
/** [Claude] the settings each provider starts with, in `properties` */
|
|
9
|
+
const providerProperties: Partial<
|
|
10
|
+
Record<StorageProviderType, Record<string, string>>
|
|
11
|
+
> = {
|
|
12
|
+
[StorageProviderType.Microsoft]: {
|
|
13
|
+
key: '',
|
|
14
|
+
region: '',
|
|
15
|
+
locale: DEFAULT_LOCALE,
|
|
16
|
+
},
|
|
17
|
+
[StorageProviderType.Google]: {
|
|
18
|
+
key: '',
|
|
19
|
+
locale: DEFAULT_LOCALE,
|
|
20
|
+
},
|
|
21
|
+
[StorageProviderType.ElevenLabs]: {
|
|
22
|
+
key: '',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** [Claude] a new cognitive profile of the provider chosen in the create popup */
|
|
27
|
+
export const getCognitiveProfileDefaults = (
|
|
28
|
+
provider?: StorageProviderType,
|
|
29
|
+
) => ({
|
|
30
|
+
name: '',
|
|
31
|
+
default: false,
|
|
32
|
+
enabled: true,
|
|
33
|
+
provider,
|
|
34
|
+
service: StorageServiceType.Tts,
|
|
35
|
+
description: '',
|
|
36
|
+
properties: {
|
|
37
|
+
...(provider && providerProperties[provider]),
|
|
38
|
+
},
|
|
39
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
2
|
+
import { emailProfileSchema } from '@webitel/api-services/validations';
|
|
1
3
|
import { EngineEmailAuthType } from '../../../gen/_models';
|
|
2
4
|
import { getEmailProfileService } from '../../../gen-wire';
|
|
3
5
|
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
@@ -21,25 +23,10 @@ import type {
|
|
|
21
23
|
UpdateItemParams,
|
|
22
24
|
} from '../_shared/types';
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
'enabled',
|
|
29
|
-
'imapHost',
|
|
30
|
-
'smtpHost',
|
|
31
|
-
'fetchInterval',
|
|
32
|
-
'imapPort',
|
|
33
|
-
'login',
|
|
34
|
-
'mailbox',
|
|
35
|
-
'password',
|
|
36
|
-
'schema',
|
|
37
|
-
'smtpPort',
|
|
38
|
-
'authType',
|
|
39
|
-
'listen',
|
|
40
|
-
'logged',
|
|
41
|
-
'params',
|
|
42
|
-
];
|
|
26
|
+
/** [Claude] the card schema's fields; `id` goes in the url, not the body */
|
|
27
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
28
|
+
emailProfileSchema,
|
|
29
|
+
).filter((field) => field !== 'id');
|
|
43
30
|
|
|
44
31
|
const getEmailProfilesList = async (params: ApiParams) => {
|
|
45
32
|
const defaultObject = {
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const instance = vi.hoisted(() => ({
|
|
4
|
+
get: vi.fn(),
|
|
5
|
+
post: vi.fn(),
|
|
6
|
+
put: vi.fn(),
|
|
7
|
+
patch: vi.fn(),
|
|
8
|
+
delete: vi.fn(),
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
vi.mock('../../../defaults', async (importOriginal) => ({
|
|
12
|
+
...(await importOriginal<typeof import('../../../defaults')>()),
|
|
13
|
+
getDefaultInstance: () => instance,
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
import { GatewaysAPI } from '../gateways';
|
|
17
|
+
|
|
18
|
+
const common = {
|
|
19
|
+
name: 'gw',
|
|
20
|
+
proxy: 'sip.example.com',
|
|
21
|
+
schema: {
|
|
22
|
+
id: '1',
|
|
23
|
+
name: 'flow',
|
|
24
|
+
},
|
|
25
|
+
usage: '',
|
|
26
|
+
enable: true,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
describe('GatewaysAPI', () => {
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
vi.clearAllMocks();
|
|
32
|
+
for (const method of Object.values(instance)) {
|
|
33
|
+
method.mockResolvedValue({
|
|
34
|
+
data: {},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('sends only registration fields for a register gateway', async () => {
|
|
40
|
+
await GatewaysAPI.add({
|
|
41
|
+
itemInstance: {
|
|
42
|
+
...common,
|
|
43
|
+
register: true,
|
|
44
|
+
account: 'user',
|
|
45
|
+
username: 'auth',
|
|
46
|
+
password: 'secret',
|
|
47
|
+
expires: 600,
|
|
48
|
+
host: 'leftover',
|
|
49
|
+
ipacl: [],
|
|
50
|
+
rState: 3,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
expect(instance.post).toHaveBeenCalledWith('/sip/gateways', {
|
|
55
|
+
...common,
|
|
56
|
+
register: true,
|
|
57
|
+
account: 'user',
|
|
58
|
+
username: 'auth',
|
|
59
|
+
password: 'secret',
|
|
60
|
+
expires: 600,
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('sends only trunking fields for a trunking gateway', async () => {
|
|
65
|
+
await GatewaysAPI.update({
|
|
66
|
+
itemId: '5',
|
|
67
|
+
itemInstance: {
|
|
68
|
+
...common,
|
|
69
|
+
register: false,
|
|
70
|
+
host: '10.0.0.2',
|
|
71
|
+
ipacl: [
|
|
72
|
+
{
|
|
73
|
+
ip: '10.0.0.3',
|
|
74
|
+
proto: 'any',
|
|
75
|
+
port: null,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
account: 'leftover',
|
|
79
|
+
expires: 600,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(instance.put).toHaveBeenCalledWith('/sip/gateways/5', {
|
|
84
|
+
...common,
|
|
85
|
+
register: false,
|
|
86
|
+
host: '10.0.0.2',
|
|
87
|
+
ipacl: [
|
|
88
|
+
{
|
|
89
|
+
ip: '10.0.0.3',
|
|
90
|
+
proto: 'any',
|
|
91
|
+
port: null,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('patches the changed field only', async () => {
|
|
98
|
+
await GatewaysAPI.patch({
|
|
99
|
+
id: '5',
|
|
100
|
+
changes: {
|
|
101
|
+
enable: false,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
expect(instance.patch).toHaveBeenCalledWith('/sip/gateways/5', {
|
|
106
|
+
enable: false,
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('fills trunking defaults on get', async () => {
|
|
111
|
+
instance.get.mockResolvedValue({
|
|
112
|
+
data: {
|
|
113
|
+
id: '5',
|
|
114
|
+
register: false,
|
|
115
|
+
ipacl: [
|
|
116
|
+
{
|
|
117
|
+
ip: '10.0.0.3',
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
expect(
|
|
124
|
+
await GatewaysAPI.get({
|
|
125
|
+
itemId: '5',
|
|
126
|
+
}),
|
|
127
|
+
).toMatchObject({
|
|
128
|
+
host: '',
|
|
129
|
+
ipacl: [
|
|
130
|
+
{
|
|
131
|
+
ip: '10.0.0.3',
|
|
132
|
+
proto: 'any',
|
|
133
|
+
port: null,
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GatewayIpAclProtocol } from '../../../enums/GatewayIpAclProtocol/GatewayIpAclProtocol';
|
|
1
2
|
import {
|
|
2
3
|
getDefaultGetListResponse,
|
|
3
4
|
getDefaultGetParams,
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
sanitize,
|
|
14
15
|
snakeToCamel,
|
|
15
16
|
starToSearch,
|
|
17
|
+
translateError,
|
|
16
18
|
} from '../../transformers';
|
|
17
19
|
import type {
|
|
18
20
|
AddItemParams,
|
|
@@ -22,8 +24,6 @@ import type {
|
|
|
22
24
|
PatchItemParams,
|
|
23
25
|
UpdateItemParams,
|
|
24
26
|
} from '../_shared/types';
|
|
25
|
-
import registerGateway from './defaults/registerGateway';
|
|
26
|
-
import trunkingGateway from './defaults/trunkingGateway';
|
|
27
27
|
|
|
28
28
|
const instance = getDefaultInstance();
|
|
29
29
|
|
|
@@ -78,45 +78,41 @@ const getGatewayList = async (params: ApiParams) => {
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
const getGateway = async ({ itemId: id }: GetItemParams) => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
...acl,
|
|
95
|
-
}));
|
|
96
|
-
return result;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const coerceRegisterResponse = (response: ApiParams) => {
|
|
100
|
-
const result = {
|
|
101
|
-
...registerGateway(),
|
|
102
|
-
...response,
|
|
103
|
-
};
|
|
104
|
-
return result;
|
|
81
|
+
/** [Claude] one set for both types: on save each type sends only its own fields */
|
|
82
|
+
const defaultObject = {
|
|
83
|
+
name: '',
|
|
84
|
+
usage: '',
|
|
85
|
+
proxy: '',
|
|
86
|
+
schema: {},
|
|
87
|
+
enable: true,
|
|
88
|
+
account: '',
|
|
89
|
+
username: '',
|
|
90
|
+
password: '',
|
|
91
|
+
expires: 600,
|
|
92
|
+
host: '',
|
|
93
|
+
ipacl: [],
|
|
105
94
|
};
|
|
106
95
|
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
96
|
+
const defaultIpAcl = {
|
|
97
|
+
ip: '',
|
|
98
|
+
proto: GatewayIpAclProtocol.Any,
|
|
99
|
+
port: null,
|
|
110
100
|
};
|
|
111
101
|
|
|
112
102
|
const url = `${baseUrl}/${id}`;
|
|
113
103
|
|
|
114
104
|
try {
|
|
115
105
|
const response = await instance.get(url);
|
|
116
|
-
|
|
106
|
+
const item = applyTransform(response.data, [
|
|
117
107
|
snakeToCamel(),
|
|
118
|
-
|
|
108
|
+
merge(defaultObject),
|
|
119
109
|
]);
|
|
110
|
+
return {
|
|
111
|
+
...item,
|
|
112
|
+
ipacl: applyTransform(item.ipacl, [
|
|
113
|
+
mergeEach(defaultIpAcl),
|
|
114
|
+
]),
|
|
115
|
+
};
|
|
120
116
|
} catch (err) {
|
|
121
117
|
throw applyTransform(err, [
|
|
122
118
|
notify,
|
|
@@ -124,37 +120,46 @@ const getGateway = async ({ itemId: id }: GetItemParams) => {
|
|
|
124
120
|
}
|
|
125
121
|
};
|
|
126
122
|
|
|
127
|
-
const
|
|
123
|
+
const commonFieldsToSend = [
|
|
128
124
|
'name',
|
|
129
125
|
'proxy',
|
|
130
|
-
'
|
|
131
|
-
'
|
|
132
|
-
'
|
|
126
|
+
'register',
|
|
127
|
+
'schema',
|
|
128
|
+
'usage',
|
|
129
|
+
'enable',
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
const registerFieldsToSend = [
|
|
133
|
+
...commonFieldsToSend,
|
|
133
134
|
'account',
|
|
134
135
|
'username',
|
|
135
136
|
'expires',
|
|
136
|
-
'account',
|
|
137
137
|
'registrar',
|
|
138
|
-
'name',
|
|
139
|
-
'register',
|
|
140
138
|
'password',
|
|
141
|
-
'schema',
|
|
142
|
-
'usage',
|
|
143
|
-
'enable',
|
|
144
139
|
];
|
|
145
140
|
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
const trunkingFieldsToSend = [
|
|
142
|
+
...commonFieldsToSend,
|
|
143
|
+
'host',
|
|
144
|
+
'ipacl',
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
/** [Claude] each gateway type sends only its own fields */
|
|
148
|
+
const toRequestItem = (item: ApiParams) =>
|
|
149
|
+
applyTransform(item, [
|
|
150
|
+
sanitize(item.register ? registerFieldsToSend : trunkingFieldsToSend),
|
|
149
151
|
camelToSnake(),
|
|
150
152
|
]);
|
|
153
|
+
|
|
154
|
+
const addGateway = async ({ itemInstance }: AddItemParams) => {
|
|
151
155
|
try {
|
|
152
|
-
const response = await instance.post(baseUrl,
|
|
156
|
+
const response = await instance.post(baseUrl, toRequestItem(itemInstance));
|
|
153
157
|
return applyTransform(response.data, [
|
|
154
158
|
snakeToCamel(),
|
|
155
159
|
]);
|
|
156
160
|
} catch (err) {
|
|
157
161
|
throw applyTransform(err, [
|
|
162
|
+
translateError,
|
|
158
163
|
notify,
|
|
159
164
|
]);
|
|
160
165
|
}
|
|
@@ -163,27 +168,29 @@ const updateGateway = async ({
|
|
|
163
168
|
itemInstance,
|
|
164
169
|
itemId: id,
|
|
165
170
|
}: UpdateItemParams) => {
|
|
166
|
-
const item = applyTransform(itemInstance, [
|
|
167
|
-
sanitize(fieldsToSend),
|
|
168
|
-
camelToSnake(),
|
|
169
|
-
]);
|
|
170
|
-
|
|
171
171
|
const url = `${baseUrl}/${id}`;
|
|
172
172
|
try {
|
|
173
|
-
const response = await instance.put(url,
|
|
173
|
+
const response = await instance.put(url, toRequestItem(itemInstance));
|
|
174
174
|
return applyTransform(response.data, [
|
|
175
175
|
snakeToCamel(),
|
|
176
176
|
]);
|
|
177
177
|
} catch (err) {
|
|
178
178
|
throw applyTransform(err, [
|
|
179
|
+
translateError,
|
|
179
180
|
notify,
|
|
180
181
|
]);
|
|
181
182
|
}
|
|
182
183
|
};
|
|
183
184
|
|
|
185
|
+
/** [Claude] a patch carries only the changed fields, so the type is unknown here */
|
|
184
186
|
const patchGateway = async ({ changes, id }: PatchItemParams) => {
|
|
185
187
|
const body = applyTransform(changes, [
|
|
186
|
-
sanitize(
|
|
188
|
+
sanitize([
|
|
189
|
+
...new Set([
|
|
190
|
+
...registerFieldsToSend,
|
|
191
|
+
...trunkingFieldsToSend,
|
|
192
|
+
]),
|
|
193
|
+
]),
|
|
187
194
|
camelToSnake(),
|
|
188
195
|
]);
|
|
189
196
|
const url = `${baseUrl}/${id}`;
|
|
@@ -194,6 +201,7 @@ const patchGateway = async ({ changes, id }: PatchItemParams) => {
|
|
|
194
201
|
]);
|
|
195
202
|
} catch (err) {
|
|
196
203
|
throw applyTransform(err, [
|
|
204
|
+
translateError,
|
|
197
205
|
notify,
|
|
198
206
|
]);
|
|
199
207
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
2
|
+
import { importTemplateSchema } from '@webitel/api-services/validations';
|
|
3
|
+
import {
|
|
4
|
+
getImportTemplateService,
|
|
5
|
+
SearchImportTemplateQueryParams,
|
|
6
|
+
} from '../../../gen-wire';
|
|
2
7
|
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
3
8
|
import {
|
|
4
9
|
applyTransform,
|
|
@@ -6,6 +11,7 @@ import {
|
|
|
6
11
|
merge,
|
|
7
12
|
notify,
|
|
8
13
|
sanitize,
|
|
14
|
+
sanitizeToWire,
|
|
9
15
|
snakeToCamel,
|
|
10
16
|
starToSearch,
|
|
11
17
|
} from '../../transformers';
|
|
@@ -29,30 +35,27 @@ const doNotConvertKeys = [
|
|
|
29
35
|
'mappings',
|
|
30
36
|
];
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'name',
|
|
35
|
-
'parameters',
|
|
36
|
-
'source',
|
|
37
|
-
'sourceType',
|
|
38
|
-
];
|
|
38
|
+
/** [Claude] the card schema's fields */
|
|
39
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(importTemplateSchema);
|
|
39
40
|
|
|
40
|
-
const
|
|
41
|
-
const
|
|
41
|
+
const searchImportTemplates = async (params: ApiParams) => {
|
|
42
|
+
const requestParams = applyTransform(params, [
|
|
42
43
|
merge(getDefaultGetParams()),
|
|
43
44
|
starToSearch('search'),
|
|
45
|
+
(params: ApiParams) => ({
|
|
46
|
+
...params,
|
|
47
|
+
// [Claude] the generated param is `q`; `search` is what the datalist store sends
|
|
48
|
+
q: params.q ?? params.search,
|
|
49
|
+
}),
|
|
50
|
+
sanitizeToWire(
|
|
51
|
+
getShallowFieldsToSendFromZodSchema(SearchImportTemplateQueryParams),
|
|
52
|
+
),
|
|
53
|
+
camelToSnake(),
|
|
44
54
|
]);
|
|
45
55
|
|
|
46
56
|
try {
|
|
47
|
-
const response =
|
|
48
|
-
|
|
49
|
-
size,
|
|
50
|
-
// the generated param is `q`; `search` is what the datalist store sends
|
|
51
|
-
q: search,
|
|
52
|
-
sort,
|
|
53
|
-
fields,
|
|
54
|
-
id,
|
|
55
|
-
});
|
|
57
|
+
const response =
|
|
58
|
+
await getImportTemplateService().searchImportTemplate(requestParams);
|
|
56
59
|
const { items, next } = applyTransform(response.data, [
|
|
57
60
|
snakeToCamel(doNotConvertKeys),
|
|
58
61
|
merge(getDefaultGetListResponse()),
|
|
@@ -148,6 +151,18 @@ const updateImportTemplate = async ({
|
|
|
148
151
|
}
|
|
149
152
|
};
|
|
150
153
|
|
|
154
|
+
/** [Claude] a template row is uploaded from, which needs its `parameters` even when no column shows them; without a field list every field comes anyway */
|
|
155
|
+
const getImportTemplatesList = (params: ApiParams) =>
|
|
156
|
+
searchImportTemplates({
|
|
157
|
+
...params,
|
|
158
|
+
fields: params.fields && [
|
|
159
|
+
...new Set([
|
|
160
|
+
...params.fields,
|
|
161
|
+
'parameters',
|
|
162
|
+
]),
|
|
163
|
+
],
|
|
164
|
+
});
|
|
165
|
+
|
|
151
166
|
const deleteImportTemplate = async ({ id }: DeleteItemParams) => {
|
|
152
167
|
try {
|
|
153
168
|
const response = await getImportTemplateService().deleteImportTemplate(
|
|
@@ -162,9 +177,9 @@ const deleteImportTemplate = async ({ id }: DeleteItemParams) => {
|
|
|
162
177
|
};
|
|
163
178
|
|
|
164
179
|
const getImportTemplatesLookup = (
|
|
165
|
-
params: Parameters<typeof
|
|
180
|
+
params: Parameters<typeof searchImportTemplates>[0],
|
|
166
181
|
) =>
|
|
167
|
-
|
|
182
|
+
searchImportTemplates({
|
|
168
183
|
...params,
|
|
169
184
|
fields: params.fields || [
|
|
170
185
|
'id',
|
package/src/api/clients/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './_shared/appUrls';
|
|
1
2
|
export * from './_shared/generatePermissionsApi';
|
|
2
3
|
export * from './activeCalls/activeCalls';
|
|
3
4
|
export * from './agentCalls/agentCalls';
|
|
@@ -32,6 +33,7 @@ export * from './cases/cases';
|
|
|
32
33
|
export * from './catalog/catalog';
|
|
33
34
|
export * from './changelogs/changelogs';
|
|
34
35
|
export * from './chatDialogs/chatDialogs';
|
|
36
|
+
export * from './chatGateways/chatGatewayChannels';
|
|
35
37
|
export * from './chatGateways/chatGateways';
|
|
36
38
|
export * from './chatMessagesHistory/chatMessagesHistory';
|
|
37
39
|
export * from './chatplans/chatplans';
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
2
|
+
import { storagePolicySchema } from '@webitel/api-services/validations';
|
|
3
|
+
import {
|
|
4
|
+
getFilePoliciesService,
|
|
5
|
+
SearchFilePoliciesQueryParams,
|
|
6
|
+
} from '../../../gen-wire';
|
|
3
7
|
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
4
8
|
import {
|
|
5
9
|
applyTransform,
|
|
@@ -8,6 +12,7 @@ import {
|
|
|
8
12
|
mergeEach,
|
|
9
13
|
notify,
|
|
10
14
|
sanitize,
|
|
15
|
+
sanitizeToWire,
|
|
11
16
|
snakeToCamel,
|
|
12
17
|
starToSearch,
|
|
13
18
|
} from '../../transformers';
|
|
@@ -21,18 +26,8 @@ import type {
|
|
|
21
26
|
UpdateItemParams,
|
|
22
27
|
} from '../_shared/types';
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'description',
|
|
27
|
-
'channels',
|
|
28
|
-
'mimeTypes',
|
|
29
|
-
'retentionDays',
|
|
30
|
-
'speedDownload',
|
|
31
|
-
'speedUpload',
|
|
32
|
-
'maxUploadSize',
|
|
33
|
-
'enabled',
|
|
34
|
-
'encrypt',
|
|
35
|
-
];
|
|
29
|
+
/** [Claude] the card schema's fields */
|
|
30
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(storagePolicySchema);
|
|
36
31
|
|
|
37
32
|
/**
|
|
38
33
|
* The list endpoint returns nothing useful without an explicit field list, so
|
|
@@ -53,6 +48,7 @@ const listFields = [
|
|
|
53
48
|
'encrypt',
|
|
54
49
|
];
|
|
55
50
|
|
|
51
|
+
/** [Claude] the api leaves out zero values, a missing `enabled` or `encrypt` is `false` */
|
|
56
52
|
const defaultObject = {
|
|
57
53
|
name: '',
|
|
58
54
|
description: '',
|
|
@@ -64,34 +60,28 @@ const defaultObject = {
|
|
|
64
60
|
maxUploadSize: 0,
|
|
65
61
|
position: 0,
|
|
66
62
|
enabled: false,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const preRequestHandler = (item: ApiParams) => {
|
|
70
|
-
const copy = deepCopy(item);
|
|
71
|
-
return {
|
|
72
|
-
...copy,
|
|
73
|
-
channels: item.channels.map(
|
|
74
|
-
(channel: ApiParams) => channel.value || channel,
|
|
75
|
-
),
|
|
76
|
-
};
|
|
63
|
+
encrypt: false,
|
|
77
64
|
};
|
|
78
65
|
|
|
79
66
|
const getStoragePoliciesList = async (params: ApiParams) => {
|
|
80
|
-
const
|
|
67
|
+
const requestParams = applyTransform(params, [
|
|
81
68
|
merge(getDefaultGetParams()),
|
|
82
69
|
starToSearch('search'),
|
|
70
|
+
(params: ApiParams) => ({
|
|
71
|
+
...params,
|
|
72
|
+
// [Claude] the generated param is `q`; `search` is what the datalist store sends
|
|
73
|
+
q: params.q ?? params.search,
|
|
74
|
+
fields: listFields,
|
|
75
|
+
}),
|
|
76
|
+
sanitizeToWire(
|
|
77
|
+
getShallowFieldsToSendFromZodSchema(SearchFilePoliciesQueryParams),
|
|
78
|
+
),
|
|
79
|
+
camelToSnake(),
|
|
83
80
|
]);
|
|
84
81
|
|
|
85
82
|
try {
|
|
86
|
-
const response =
|
|
87
|
-
|
|
88
|
-
size,
|
|
89
|
-
// the generated param is `q`; `search` is what the datalist store sends
|
|
90
|
-
q: search,
|
|
91
|
-
sort,
|
|
92
|
-
fields: listFields,
|
|
93
|
-
id,
|
|
94
|
-
});
|
|
83
|
+
const response =
|
|
84
|
+
await getFilePoliciesService().searchFilePolicies(requestParams);
|
|
95
85
|
const { items, next } = applyTransform(response.data, [
|
|
96
86
|
snakeToCamel(),
|
|
97
87
|
merge(getDefaultGetListResponse()),
|
|
@@ -125,7 +115,6 @@ const getStoragePolicy = async ({ itemId: id }: GetItemParams) => {
|
|
|
125
115
|
|
|
126
116
|
const addStoragePolicy = async ({ itemInstance }: AddItemParams) => {
|
|
127
117
|
const item = applyTransform(itemInstance, [
|
|
128
|
-
preRequestHandler,
|
|
129
118
|
sanitize(fieldsToSend),
|
|
130
119
|
// `channels` values mirror the StorageUploadFileChannel enum and stay camelCase
|
|
131
120
|
camelToSnake([
|
|
@@ -149,7 +138,6 @@ const updateStoragePolicy = async ({
|
|
|
149
138
|
itemId: id,
|
|
150
139
|
}: UpdateItemParams) => {
|
|
151
140
|
const item = applyTransform(itemInstance, [
|
|
152
|
-
preRequestHandler,
|
|
153
141
|
sanitize(fieldsToSend),
|
|
154
142
|
// `channels` values mirror the StorageUploadFileChannel enum and stay camelCase
|
|
155
143
|
camelToSnake([
|