@webitel/api-services 0.0.37 → 0.0.40

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.37",
3
+ "version": "0.0.40",
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",
@@ -71,7 +71,7 @@ const getContactGroupsList = async (params) => {
71
71
  merge(getDefaultGetListResponse()),
72
72
  ]);
73
73
  return {
74
- items: applyTransform(items, [mergeEach(defaultObject)]),
74
+ items: applyTransform(items, [mergeEach(defaultObject), snakeToCamel()]),
75
75
  next,
76
76
  };
77
77
  } catch (err) {
@@ -24,7 +24,7 @@ export * from './media/media';
24
24
  export * from './object/object';
25
25
  export * from './queues/queues';
26
26
  export * from './quickReplies/quickReplies';
27
- export * from './roles/roles';
27
+ // export * from './roles/roles'; fixme: ApplicationAccess import
28
28
  export * from './skills/skills';
29
29
  export * from './slas/slas';
30
30
  export * from './teams/teams';
@@ -5,7 +5,7 @@ import { z } from 'zod/v4';
5
5
  * only depth=1 fields will be returned
6
6
  * */
7
7
  export const getShallowFieldsToSendFromZodSchema = (
8
- schema: z.ZodTypeAny,
8
+ schema: z.ZodObject,
9
9
  ): string[] => {
10
10
  return schema.keyof().options;
11
11
  };
@@ -16,7 +16,7 @@ export const getShallowFieldsToSendFromZodSchema = (
16
16
  */
17
17
 
18
18
  // get zod object keys recursively
19
- export const getFieldsToSendFromZodSchema = <T extends z.ZodTypeAny>(
19
+ export const getFieldsToSendFromZodSchema = <T extends z.ZodObject>(
20
20
  schema: T,
21
21
  ): string[] => {
22
22
  // make sure schema is not null or undefined
@@ -22,7 +22,6 @@ export * from './media/media';
22
22
  export * from './object/object';
23
23
  export * from './queues/queues';
24
24
  export * from './quickReplies/quickReplies';
25
- export * from './roles/roles';
26
25
  export * from './skills/skills';
27
26
  export * from './slas/slas';
28
27
  export * from './teams/teams';
@@ -91,10 +91,10 @@ export declare const dictionariesDeleteDataResponse: zod.ZodObject<{
91
91
  string: "string";
92
92
  lookup: "lookup";
93
93
  binary: "binary";
94
- int: "int";
95
94
  none: "none";
96
95
  list: "list";
97
96
  bool: "bool";
97
+ int: "int";
98
98
  int32: "int32";
99
99
  int64: "int64";
100
100
  uint: "uint";
@@ -259,10 +259,10 @@ export declare const dictionariesSearchDataResponse: zod.ZodObject<{
259
259
  string: "string";
260
260
  lookup: "lookup";
261
261
  binary: "binary";
262
- int: "int";
263
262
  none: "none";
264
263
  list: "list";
265
264
  bool: "bool";
265
+ int: "int";
266
266
  int32: "int32";
267
267
  int64: "int64";
268
268
  uint: "uint";
@@ -441,10 +441,10 @@ export declare const dictionariesImportCSVResponse: zod.ZodObject<{
441
441
  string: "string";
442
442
  lookup: "lookup";
443
443
  binary: "binary";
444
- int: "int";
445
444
  none: "none";
446
445
  list: "list";
447
446
  bool: "bool";
447
+ int: "int";
448
448
  int32: "int32";
449
449
  int64: "int64";
450
450
  uint: "uint";
@@ -602,10 +602,10 @@ export declare const dictionariesDeleteData2Response: zod.ZodObject<{
602
602
  string: "string";
603
603
  lookup: "lookup";
604
604
  binary: "binary";
605
- int: "int";
606
605
  none: "none";
607
606
  list: "list";
608
607
  bool: "bool";
608
+ int: "int";
609
609
  int32: "int32";
610
610
  int64: "int64";
611
611
  uint: "uint";
@@ -797,10 +797,10 @@ export declare const dictionariesDeleteTypeResponse: zod.ZodObject<{
797
797
  string: "string";
798
798
  lookup: "lookup";
799
799
  binary: "binary";
800
- int: "int";
801
800
  none: "none";
802
801
  list: "list";
803
802
  bool: "bool";
803
+ int: "int";
804
804
  int32: "int32";
805
805
  int64: "int64";
806
806
  uint: "uint";
@@ -969,10 +969,10 @@ export declare const dictionariesSearchTypeResponse: zod.ZodObject<{
969
969
  string: "string";
970
970
  lookup: "lookup";
971
971
  binary: "binary";
972
- int: "int";
973
972
  none: "none";
974
973
  list: "list";
975
974
  bool: "bool";
975
+ int: "int";
976
976
  int32: "int32";
977
977
  int64: "int64";
978
978
  uint: "uint";
@@ -1125,10 +1125,10 @@ export declare const dictionariesLocateTypeResponse: zod.ZodObject<{
1125
1125
  string: "string";
1126
1126
  lookup: "lookup";
1127
1127
  binary: "binary";
1128
- int: "int";
1129
1128
  none: "none";
1130
1129
  list: "list";
1131
1130
  bool: "bool";
1131
+ int: "int";
1132
1132
  int32: "int32";
1133
1133
  int64: "int64";
1134
1134
  uint: "uint";
@@ -1271,10 +1271,10 @@ export declare const dictionariesCreateTypeBody: zod.ZodObject<{
1271
1271
  string: "string";
1272
1272
  lookup: "lookup";
1273
1273
  binary: "binary";
1274
- int: "int";
1275
1274
  none: "none";
1276
1275
  list: "list";
1277
1276
  bool: "bool";
1277
+ int: "int";
1278
1278
  int32: "int32";
1279
1279
  int64: "int64";
1280
1280
  uint: "uint";
@@ -1407,10 +1407,10 @@ export declare const dictionariesCreateTypeResponse: zod.ZodObject<{
1407
1407
  string: "string";
1408
1408
  lookup: "lookup";
1409
1409
  binary: "binary";
1410
- int: "int";
1411
1410
  none: "none";
1412
1411
  list: "list";
1413
1412
  bool: "bool";
1413
+ int: "int";
1414
1414
  int32: "int32";
1415
1415
  int64: "int64";
1416
1416
  uint: "uint";
@@ -1556,10 +1556,10 @@ export declare const dictionariesUpdateTypeBody: zod.ZodObject<{
1556
1556
  string: "string";
1557
1557
  lookup: "lookup";
1558
1558
  binary: "binary";
1559
- int: "int";
1560
1559
  none: "none";
1561
1560
  list: "list";
1562
1561
  bool: "bool";
1562
+ int: "int";
1563
1563
  int32: "int32";
1564
1564
  int64: "int64";
1565
1565
  uint: "uint";
@@ -1692,10 +1692,10 @@ export declare const dictionariesUpdateTypeResponse: zod.ZodObject<{
1692
1692
  string: "string";
1693
1693
  lookup: "lookup";
1694
1694
  binary: "binary";
1695
- int: "int";
1696
1695
  none: "none";
1697
1696
  list: "list";
1698
1697
  bool: "bool";
1698
+ int: "int";
1699
1699
  int32: "int32";
1700
1700
  int64: "int64";
1701
1701
  uint: "uint";
@@ -86,10 +86,10 @@ export declare const extensionsDeleteType2Response: zod.ZodObject<{
86
86
  string: "string";
87
87
  lookup: "lookup";
88
88
  binary: "binary";
89
- int: "int";
90
89
  none: "none";
91
90
  list: "list";
92
91
  bool: "bool";
92
+ int: "int";
93
93
  int32: "int32";
94
94
  int64: "int64";
95
95
  uint: "uint";
@@ -251,10 +251,10 @@ export declare const extensionsSearchTypeResponse: zod.ZodObject<{
251
251
  string: "string";
252
252
  lookup: "lookup";
253
253
  binary: "binary";
254
- int: "int";
255
254
  none: "none";
256
255
  list: "list";
257
256
  bool: "bool";
257
+ int: "int";
258
258
  int32: "int32";
259
259
  int64: "int64";
260
260
  uint: "uint";
@@ -411,10 +411,10 @@ export declare const extensionsDeleteTypeResponse: zod.ZodObject<{
411
411
  string: "string";
412
412
  lookup: "lookup";
413
413
  binary: "binary";
414
- int: "int";
415
414
  none: "none";
416
415
  list: "list";
417
416
  bool: "bool";
417
+ int: "int";
418
418
  int32: "int32";
419
419
  int64: "int64";
420
420
  uint: "uint";
@@ -567,10 +567,10 @@ export declare const extensionsLocateTypeResponse: zod.ZodObject<{
567
567
  string: "string";
568
568
  lookup: "lookup";
569
569
  binary: "binary";
570
- int: "int";
571
570
  none: "none";
572
571
  list: "list";
573
572
  bool: "bool";
573
+ int: "int";
574
574
  int32: "int32";
575
575
  int64: "int64";
576
576
  uint: "uint";
@@ -710,10 +710,10 @@ export declare const extensionsCreateTypeBody: zod.ZodObject<{
710
710
  string: "string";
711
711
  lookup: "lookup";
712
712
  binary: "binary";
713
- int: "int";
714
713
  none: "none";
715
714
  list: "list";
716
715
  bool: "bool";
716
+ int: "int";
717
717
  int32: "int32";
718
718
  int64: "int64";
719
719
  uint: "uint";
@@ -843,10 +843,10 @@ export declare const extensionsCreateTypeResponse: zod.ZodObject<{
843
843
  string: "string";
844
844
  lookup: "lookup";
845
845
  binary: "binary";
846
- int: "int";
847
846
  none: "none";
848
847
  list: "list";
849
848
  bool: "bool";
849
+ int: "int";
850
850
  int32: "int32";
851
851
  int64: "int64";
852
852
  uint: "uint";
@@ -986,10 +986,10 @@ export declare const extensionsUpdateTypeBody: zod.ZodObject<{
986
986
  string: "string";
987
987
  lookup: "lookup";
988
988
  binary: "binary";
989
- int: "int";
990
989
  none: "none";
991
990
  list: "list";
992
991
  bool: "bool";
992
+ int: "int";
993
993
  int32: "int32";
994
994
  int64: "int64";
995
995
  uint: "uint";
@@ -1119,10 +1119,10 @@ export declare const extensionsUpdateTypeResponse: zod.ZodObject<{
1119
1119
  string: "string";
1120
1120
  lookup: "lookup";
1121
1121
  binary: "binary";
1122
- int: "int";
1123
1122
  none: "none";
1124
1123
  list: "list";
1125
1124
  bool: "bool";
1125
+ int: "int";
1126
1126
  int32: "int32";
1127
1127
  int64: "int64";
1128
1128
  uint: "uint";
@@ -100,10 +100,10 @@ export declare const typesSearchResponse: zod.ZodObject<{
100
100
  string: "string";
101
101
  lookup: "lookup";
102
102
  binary: "binary";
103
- int: "int";
104
103
  none: "none";
105
104
  list: "list";
106
105
  bool: "bool";
106
+ int: "int";
107
107
  int32: "int32";
108
108
  int64: "int64";
109
109
  uint: "uint";
@@ -255,10 +255,10 @@ export declare const typesLocateResponse: zod.ZodObject<{
255
255
  string: "string";
256
256
  lookup: "lookup";
257
257
  binary: "binary";
258
- int: "int";
259
258
  none: "none";
260
259
  list: "list";
261
260
  bool: "bool";
261
+ int: "int";
262
262
  int32: "int32";
263
263
  int64: "int64";
264
264
  uint: "uint";
@@ -3,8 +3,8 @@ import { z } from 'zod/v4';
3
3
  * @description
4
4
  * only depth=1 fields will be returned
5
5
  * */
6
- export declare const getShallowFieldsToSendFromZodSchema: (schema: z.ZodTypeAny) => string[];
7
- export declare const getFieldsToSendFromZodSchema: <T extends z.ZodTypeAny>(schema: T) => string[];
6
+ export declare const getShallowFieldsToSendFromZodSchema: (schema: z.ZodObject) => string[];
7
+ export declare const getFieldsToSendFromZodSchema: <T extends z.ZodObject>(schema: T) => string[];
8
8
  /**
9
9
  * @author @dlohvinov
10
10
  * @description
@@ -1,186 +0,0 @@
1
- import deepCopy from 'deep-copy';
2
- import { RolesApiFactory } from 'webitel-sdk';
3
-
4
- /**
5
- * @author @Oleksandr Palonnyi
6
- *
7
- * TODO refactor ApplicationsAccess path for @Volodymyr Dekhtyaruk
8
- * */
9
- import ApplicationsAccess from '../../../../../../src/modules/Userinfo/classes/ApplicationsAccess';
10
- import {
11
- getDefaultGetListResponse,
12
- getDefaultGetParams,
13
- getDefaultInstance,
14
- getDefaultOpenAPIConfig,
15
- } from '../../defaults';
16
- import {
17
- applyTransform,
18
- camelToSnake,
19
- generateUrl,
20
- merge,
21
- notify,
22
- sanitize,
23
- snakeToCamel,
24
- starToSearch,
25
- } from '../../transformers';
26
-
27
- const instance = getDefaultInstance();
28
- const configuration = getDefaultOpenAPIConfig();
29
-
30
- const rolesApiFactory = RolesApiFactory(configuration, '', instance);
31
-
32
- const fieldsToSend = ['name', 'description', 'permissions', 'metadata'];
33
-
34
- const preRequestHandler = (item) => {
35
- const copy = deepCopy(item);
36
- copy.metadata.access = ApplicationsAccess.minify(copy.metadata.access);
37
- return copy;
38
- };
39
-
40
- const getRoleList = async (params) => {
41
- const fieldsToSend = ['page', 'size', 'q', 'sort', 'fields', 'id'];
42
-
43
- const { page, size, q, sort, name, fields, id, userId, userName } =
44
- applyTransform(params, [
45
- merge(getDefaultGetParams()),
46
- starToSearch('search'),
47
- (params) => ({ ...params, q: params.search }),
48
- sanitize(fieldsToSend),
49
- camelToSnake(),
50
- ]);
51
-
52
- try {
53
- const response = await rolesApiFactory.searchRoles(
54
- [id],
55
- name,
56
- userId,
57
- userName,
58
- q,
59
- fields,
60
- sort,
61
- page,
62
- size,
63
- );
64
- const { items, next } = applyTransform(response.data, [
65
- snakeToCamel(),
66
- merge(getDefaultGetListResponse()),
67
- ]);
68
- return {
69
- items,
70
- next,
71
- };
72
- } catch (err) {
73
- throw applyTransform(err, [notify]);
74
- }
75
- };
76
-
77
- const getRole = async ({ itemId: id }) => {
78
- const defaultObject = {
79
- name: '',
80
- description: '',
81
- permissions: [],
82
- metadata: {},
83
- };
84
-
85
- const itemResponseHandler = (response) => {
86
- const copy = deepCopy(response);
87
- copy.metadata.access = new ApplicationsAccess({
88
- access: copy.metadata.access,
89
- }).getAccess();
90
- return copy;
91
- };
92
-
93
- try {
94
- const response = await rolesApiFactory.readRole(id, fieldsToSend);
95
- return applyTransform(response.data, [
96
- snakeToCamel(),
97
- merge(defaultObject),
98
- itemResponseHandler,
99
- ]);
100
- } catch (err) {
101
- throw applyTransform(err, [notify]);
102
- }
103
- };
104
-
105
- const addRole = async ({ itemInstance }) => {
106
- const item = applyTransform(itemInstance, [
107
- preRequestHandler,
108
- sanitize(fieldsToSend),
109
- camelToSnake(),
110
- ]);
111
- try {
112
- const response = await rolesApiFactory.createRole(item);
113
- return applyTransform(response.data, [snakeToCamel()]);
114
- } catch (err) {
115
- throw applyTransform(err, [notify]);
116
- }
117
- };
118
-
119
- const updateRole = async ({ itemInstance, itemId: id }) => {
120
- const item = applyTransform(itemInstance, [
121
- preRequestHandler,
122
- sanitize(fieldsToSend),
123
- camelToSnake(),
124
- ]);
125
-
126
- try {
127
- const response = await rolesApiFactory.updateRole(id, item);
128
- return applyTransform(response.data, [snakeToCamel()]);
129
- } catch (err) {
130
- throw applyTransform(err, [notify]);
131
- }
132
- };
133
-
134
- const deleteRole = async ({ id }) => {
135
- try {
136
- const response = await rolesApiFactory.deleteRole(id);
137
- return applyTransform(response.data, []);
138
- } catch (err) {
139
- throw applyTransform(err, [notify]);
140
- }
141
- };
142
-
143
- const getRolesLookup = (params) =>
144
- getRoleList({
145
- ...params,
146
- fields: params.fields || ['id', 'name'],
147
- });
148
-
149
- const PERMISSIONS_LIST_URL = '/permissions';
150
-
151
- const getPermissionsOptions = async (params) => {
152
- const fieldsToSend = ['page', 'size', 'q', 'sort', 'fields', 'id'];
153
-
154
- const url = applyTransform(params, [
155
- merge(getDefaultGetParams()),
156
- starToSearch('search'),
157
- (params) => ({ ...params, q: params.search }),
158
- sanitize(fieldsToSend),
159
- camelToSnake(),
160
- generateUrl(PERMISSIONS_LIST_URL),
161
- ]);
162
- try {
163
- const response = await instance.get(url);
164
- const { items, next } = applyTransform(response.data, [
165
- snakeToCamel(),
166
- merge(getDefaultGetListResponse()),
167
- ]);
168
- return {
169
- items,
170
- next,
171
- };
172
- } catch (err) {
173
- throw applyTransform(err, [notify]);
174
- }
175
- };
176
-
177
- export const RolesAPI = {
178
- getList: getRoleList,
179
- get: getRole,
180
- add: addRole,
181
- update: updateRole,
182
- delete: deleteRole,
183
- getLookup: getRolesLookup,
184
-
185
- getPermissionsOptions,
186
- };
@@ -1,27 +0,0 @@
1
- export declare const RolesAPI: {
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
- getPermissionsOptions: (params: any) => Promise<{
24
- items: any;
25
- next: any;
26
- }>;
27
- };