@webitel/api-services 0.0.70 → 0.0.72

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/api-services",
3
- "version": "0.0.70",
3
+ "version": "0.0.72",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "make-all": "npm run gen:api && npm version patch && (npm run build:types || true) && (npm run format:all || true) && npm run publish-lib",
@@ -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
+ };
@@ -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';
@@ -14,15 +14,26 @@ import {
14
14
  const fieldsToSend = ['name', 'queues', 'article', 'teams', 'text'];
15
15
 
16
16
  const getQuickRepliesList = async (params) => {
17
- const fieldsToSend = ['page', 'size', 'q', 'sort', 'fields', 'id'];
17
+ const fieldsToSend = [
18
+ 'page',
19
+ 'size',
20
+ 'q',
21
+ 'sort',
22
+ 'fields',
23
+ 'id',
24
+ 'restrictToAgent',
25
+ ];
18
26
 
19
- const { page, size, fields, sort, id, q } = applyTransform(params, [
20
- merge(getDefaultGetParams()),
21
- (params) => ({ ...params, q: params.search }),
22
- sanitize(fieldsToSend),
23
- starToSearch('q'),
24
- camelToSnake(),
25
- ]);
27
+ const { page, size, fields, sort, id, q, restrict_to_agent } = applyTransform(
28
+ params,
29
+ [
30
+ merge(getDefaultGetParams()),
31
+ (params) => ({ ...params, q: params.search }),
32
+ sanitize(fieldsToSend),
33
+ starToSearch('q'),
34
+ camelToSnake(),
35
+ ],
36
+ );
26
37
 
27
38
  try {
28
39
  const response = await getQuickRepliesService().searchQuickReplies({
@@ -32,6 +43,7 @@ const getQuickRepliesList = async (params) => {
32
43
  sort,
33
44
  id,
34
45
  q,
46
+ restrict_to_agent,
35
47
  });
36
48
  const { items, next } = applyTransform(response.data, [
37
49
  merge(getDefaultGetListResponse()),
@@ -13,4 +13,5 @@ export type SearchQuickRepliesParams = {
13
13
  fields?: string[];
14
14
  id?: number[];
15
15
  queue?: number[];
16
+ restrictToAgent?: boolean;
16
17
  };
@@ -14,6 +14,7 @@ export const searchQuickRepliesQueryParams = zod.object({
14
14
  fields: zod.array(zod.string()).optional(),
15
15
  id: zod.array(zod.number()).optional(),
16
16
  queue: zod.array(zod.number()).optional(),
17
+ restrictToAgent: zod.boolean().optional(),
17
18
  });
18
19
 
19
20
  export const searchQuickRepliesResponse = zod.object({
@@ -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';
@@ -12,4 +12,5 @@ export type SearchQuickRepliesParams = {
12
12
  fields?: string[];
13
13
  id?: number[];
14
14
  queue?: number[];
15
+ restrictToAgent?: boolean;
15
16
  };
@@ -13,6 +13,7 @@ export declare const searchQuickRepliesQueryParams: zod.ZodObject<{
13
13
  fields: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
14
14
  id: zod.ZodOptional<zod.ZodArray<zod.ZodNumber>>;
15
15
  queue: zod.ZodOptional<zod.ZodArray<zod.ZodNumber>>;
16
+ restrictToAgent: zod.ZodOptional<zod.ZodBoolean>;
16
17
  }, zod.core.$strip>;
17
18
  export declare const searchQuickRepliesResponse: zod.ZodObject<{
18
19
  items: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{