@webitel/api-services 0.0.53 → 0.0.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/clients/fileServices/fileServices.ts +222 -0
- package/src/api/clients/index.ts +1 -0
- package/src/api/clients/media/media.ts +10 -0
- package/types/api/clients/fileServices/fileServices.d.ts +23 -0
- package/types/api/clients/index.d.ts +1 -0
- package/types/api/clients/media/media.d.ts +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getFileService,
|
|
3
|
+
searchFilesQueryParams,
|
|
4
|
+
searchScreenRecordingsByAgentQueryParams,
|
|
5
|
+
searchScreenRecordingsQueryParams,
|
|
6
|
+
} from '@webitel/api-services/gen';
|
|
7
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
8
|
+
|
|
9
|
+
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
10
|
+
import {
|
|
11
|
+
applyTransform,
|
|
12
|
+
camelToSnake,
|
|
13
|
+
merge,
|
|
14
|
+
notify,
|
|
15
|
+
sanitize,
|
|
16
|
+
snakeToCamel,
|
|
17
|
+
} from '../../transformers';
|
|
18
|
+
|
|
19
|
+
const getFilesList = async (params: any) => {
|
|
20
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
21
|
+
searchFilesQueryParams,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const {
|
|
25
|
+
page,
|
|
26
|
+
size,
|
|
27
|
+
q,
|
|
28
|
+
sort,
|
|
29
|
+
fields,
|
|
30
|
+
id,
|
|
31
|
+
uploaded_at_from: uploadedAtFrom,
|
|
32
|
+
uploaded_at_to: uploadedAtTo,
|
|
33
|
+
uploadedBy,
|
|
34
|
+
referenceId,
|
|
35
|
+
channel,
|
|
36
|
+
retentionUntilFrom,
|
|
37
|
+
retentionUntilTo,
|
|
38
|
+
} = applyTransform(params, [
|
|
39
|
+
merge(getDefaultGetParams()),
|
|
40
|
+
sanitize(fieldsToSend),
|
|
41
|
+
camelToSnake(),
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const response = await getFileService().searchFiles({
|
|
46
|
+
page,
|
|
47
|
+
size,
|
|
48
|
+
q: q || params.search,
|
|
49
|
+
sort,
|
|
50
|
+
fields,
|
|
51
|
+
id,
|
|
52
|
+
'uploaded_at.from': uploadedAtFrom,
|
|
53
|
+
'uploaded_at.to': uploadedAtTo,
|
|
54
|
+
uploadedBy,
|
|
55
|
+
referenceId,
|
|
56
|
+
channel,
|
|
57
|
+
retentionUntilFrom,
|
|
58
|
+
retentionUntilTo,
|
|
59
|
+
});
|
|
60
|
+
const { items, next } = applyTransform(response.data, [
|
|
61
|
+
merge(getDefaultGetListResponse()),
|
|
62
|
+
]);
|
|
63
|
+
return {
|
|
64
|
+
items,
|
|
65
|
+
next,
|
|
66
|
+
};
|
|
67
|
+
} catch (err) {
|
|
68
|
+
throw applyTransform(err, [notify]);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const deleteFiles = async (id) => {
|
|
73
|
+
try {
|
|
74
|
+
const response = await getFileService().deleteFiles({ id });
|
|
75
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
throw applyTransform(err, [notify]);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const getScreenRecordingsByUser = async (params: any) => {
|
|
82
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
83
|
+
searchScreenRecordingsQueryParams,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const {
|
|
87
|
+
page,
|
|
88
|
+
size,
|
|
89
|
+
q,
|
|
90
|
+
sort,
|
|
91
|
+
fields,
|
|
92
|
+
id,
|
|
93
|
+
uploaded_at_from: uploadedAtFrom,
|
|
94
|
+
uploaded_at_to: uploadedAtTo,
|
|
95
|
+
referenceId,
|
|
96
|
+
retentionUntilFrom,
|
|
97
|
+
retentionUntilTo,
|
|
98
|
+
channel,
|
|
99
|
+
} = applyTransform(params, [
|
|
100
|
+
merge(getDefaultGetParams()),
|
|
101
|
+
sanitize(fieldsToSend),
|
|
102
|
+
camelToSnake(),
|
|
103
|
+
]);
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const response = await getFileService().searchScreenRecordings(
|
|
107
|
+
params.userId,
|
|
108
|
+
{
|
|
109
|
+
page,
|
|
110
|
+
size,
|
|
111
|
+
q: q || params.search,
|
|
112
|
+
sort,
|
|
113
|
+
fields: ['id', ...fields],
|
|
114
|
+
id,
|
|
115
|
+
'uploaded_at.from': uploadedAtFrom,
|
|
116
|
+
'uploaded_at.to': uploadedAtTo,
|
|
117
|
+
referenceId,
|
|
118
|
+
retentionUntilFrom,
|
|
119
|
+
retentionUntilTo,
|
|
120
|
+
channel,
|
|
121
|
+
},
|
|
122
|
+
);
|
|
123
|
+
const { items, next } = applyTransform(response.data, [
|
|
124
|
+
merge(getDefaultGetListResponse()),
|
|
125
|
+
]);
|
|
126
|
+
return {
|
|
127
|
+
items,
|
|
128
|
+
next,
|
|
129
|
+
};
|
|
130
|
+
} catch (err) {
|
|
131
|
+
throw applyTransform(err, [notify]);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const deleteScreenRecordingsByUser = async ({ userId, id }) => {
|
|
136
|
+
try {
|
|
137
|
+
const response = await getFileService().deleteScreenRecordings(
|
|
138
|
+
userId,
|
|
139
|
+
id,
|
|
140
|
+
{},
|
|
141
|
+
);
|
|
142
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
throw applyTransform(err, [notify]);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const getScreenRecordingsByAgent = async (params: any) => {
|
|
149
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
150
|
+
searchScreenRecordingsByAgentQueryParams,
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
const {
|
|
154
|
+
page,
|
|
155
|
+
size,
|
|
156
|
+
q,
|
|
157
|
+
sort,
|
|
158
|
+
fields,
|
|
159
|
+
id,
|
|
160
|
+
uploaded_at_from: uploadedAtFrom,
|
|
161
|
+
uploaded_at_to: uploadedAtTo,
|
|
162
|
+
referenceId,
|
|
163
|
+
retentionUntilFrom,
|
|
164
|
+
retentionUntilTo,
|
|
165
|
+
channel,
|
|
166
|
+
} = applyTransform(params, [
|
|
167
|
+
merge(getDefaultGetParams()),
|
|
168
|
+
sanitize(fieldsToSend),
|
|
169
|
+
camelToSnake(),
|
|
170
|
+
]);
|
|
171
|
+
|
|
172
|
+
try {
|
|
173
|
+
const response = await getFileService().searchScreenRecordingsByAgent(
|
|
174
|
+
params.agentId,
|
|
175
|
+
{
|
|
176
|
+
page,
|
|
177
|
+
size,
|
|
178
|
+
q: q || params.search,
|
|
179
|
+
sort,
|
|
180
|
+
fields: ['id', ...fields],
|
|
181
|
+
id,
|
|
182
|
+
'uploaded_at.from': uploadedAtFrom,
|
|
183
|
+
'uploaded_at.to': uploadedAtTo,
|
|
184
|
+
referenceId,
|
|
185
|
+
retentionUntilFrom,
|
|
186
|
+
retentionUntilTo,
|
|
187
|
+
channel,
|
|
188
|
+
},
|
|
189
|
+
);
|
|
190
|
+
const { items, next } = applyTransform(response.data, [
|
|
191
|
+
merge(getDefaultGetListResponse()),
|
|
192
|
+
]);
|
|
193
|
+
return {
|
|
194
|
+
items,
|
|
195
|
+
next,
|
|
196
|
+
};
|
|
197
|
+
} catch (err) {
|
|
198
|
+
throw applyTransform(err, [notify]);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const deleteScreenRecordingsByAgent = async ({ agentId, id }) => {
|
|
203
|
+
try {
|
|
204
|
+
const response = await getFileService().deleteScreenRecordingsByAgent(
|
|
205
|
+
agentId,
|
|
206
|
+
id,
|
|
207
|
+
{},
|
|
208
|
+
);
|
|
209
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
210
|
+
} catch (err) {
|
|
211
|
+
throw applyTransform(err, [notify]);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export const FileServicesAPI = {
|
|
216
|
+
getList: getFilesList,
|
|
217
|
+
delete: deleteFiles,
|
|
218
|
+
getScreenRecordingsByUser,
|
|
219
|
+
deleteScreenRecordingsByUser,
|
|
220
|
+
getScreenRecordingsByAgent,
|
|
221
|
+
deleteScreenRecordingsByAgent,
|
|
222
|
+
};
|
package/src/api/clients/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from './catalog/catalog';
|
|
|
15
15
|
export * from './communications/communications';
|
|
16
16
|
export * from './configurations/configurations';
|
|
17
17
|
export * from './contactGroups/contactGroups';
|
|
18
|
+
export * from './fileServices/fileServices';
|
|
18
19
|
export * from './flows/flow';
|
|
19
20
|
export * from './gateways/gateways';
|
|
20
21
|
export * from './history/transcript/callTranscript';
|
|
@@ -69,6 +69,16 @@ export const downloadMedia = async (id) => {
|
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
export const downloadFile = (id) => {
|
|
73
|
+
const url = `${baseUrl}/storage/file/${id}/download?access_token=${token}`;
|
|
74
|
+
window.open(url, '_blank');
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const getScreenRecordingMediaUrl = (id, isThumb = false) => {
|
|
78
|
+
const url = `${baseUrl}/storage/file/${id}/stream?access_token=${token}&fetch_thumbnail=${isThumb}`;
|
|
79
|
+
return url;
|
|
80
|
+
};
|
|
81
|
+
|
|
72
82
|
const addMediaInstance = axios.create({
|
|
73
83
|
headers: {
|
|
74
84
|
'content-type': 'multipart/form-data',
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const FileServicesAPI: {
|
|
2
|
+
getList: (params: any) => Promise<{
|
|
3
|
+
items: any;
|
|
4
|
+
next: any;
|
|
5
|
+
}>;
|
|
6
|
+
delete: (id: any) => Promise<any>;
|
|
7
|
+
getScreenRecordingsByUser: (params: any) => Promise<{
|
|
8
|
+
items: any;
|
|
9
|
+
next: any;
|
|
10
|
+
}>;
|
|
11
|
+
deleteScreenRecordingsByUser: ({ userId, id }: {
|
|
12
|
+
userId: any;
|
|
13
|
+
id: any;
|
|
14
|
+
}) => Promise<any>;
|
|
15
|
+
getScreenRecordingsByAgent: (params: any) => Promise<{
|
|
16
|
+
items: any;
|
|
17
|
+
next: any;
|
|
18
|
+
}>;
|
|
19
|
+
deleteScreenRecordingsByAgent: ({ agentId, id }: {
|
|
20
|
+
agentId: any;
|
|
21
|
+
id: any;
|
|
22
|
+
}) => Promise<any>;
|
|
23
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare const downloadMedia: (id: any) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
2
|
+
export declare const downloadFile: (id: any) => void;
|
|
3
|
+
export declare const getScreenRecordingMediaUrl: (id: any, isThumb?: boolean) => string;
|
|
2
4
|
export declare const MediaAPI: {
|
|
3
5
|
getList: (params: any) => Promise<{
|
|
4
6
|
items: any;
|