@webitel/api-services 1.0.6 → 1.0.7

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.
Files changed (62) hide show
  1. package/package.json +2 -1
  2. package/src/api/clients/caseComments/caseComments.ts +141 -0
  3. package/src/api/clients/caseFiles/caseFiles.ts +79 -0
  4. package/src/api/clients/caseLinks/caseLinks.ts +150 -0
  5. package/src/api/clients/caseRelatedCases/caseRelatedCases.ts +125 -0
  6. package/src/api/clients/caseServices/services.ts +38 -72
  7. package/src/api/clients/cases/_internals/ftsService.ts +67 -0
  8. package/src/api/clients/cases/_internals/stringifyCaseFilters.ts +156 -0
  9. package/src/api/clients/cases/cases.ts +360 -0
  10. package/src/api/clients/chatMessagesHistory/chatMessagesHistory.ts +64 -0
  11. package/src/api/clients/configurations/configurations.ts +56 -39
  12. package/src/api/clients/contactCases/contactCases.ts +109 -0
  13. package/src/api/clients/emails/emails.ts +11 -7
  14. package/src/api/clients/index.ts +9 -0
  15. package/src/api/clients/labels/labels.ts +24 -29
  16. package/src/api/clients/phones/phones.ts +11 -7
  17. package/src/api/clients/timeline/timeline.ts +124 -0
  18. package/src/api/clients/variables/variables.ts +10 -5
  19. package/src/api/clients/wtTypes/_shared/utils/assignFieldPositions.ts +28 -0
  20. package/src/api/clients/wtTypes/_shared/utils/sortDynamicFields.ts +7 -9
  21. package/src/api/clients/wtTypes/adjunctTypeRecords/adjunctTypeRecords.ts +19 -16
  22. package/src/api/clients/wtTypes/adjunctTypes/adjunctTypes.ts +4 -0
  23. package/src/api/clients/wtTypes/typeExtensions/typeExtensions.ts +21 -31
  24. package/src/api/clients//321/201ontacts/contacts.ts +103 -234
  25. package/src/api/clients//321/201ontacts/getContactAccessFromMode.ts +9 -0
  26. package/src/api/clients//321/201ontacts/index.ts +1 -1
  27. package/src/validations/adjunctType/adjunctType.validations.ts +18 -0
  28. package/src/validations/case/case.validations.ts +33 -0
  29. package/src/validations/caseClose/caseClose.validations.ts +30 -0
  30. package/src/validations/caseExportOptions/caseExportOptions.validations.ts +27 -0
  31. package/src/validations/contact/contact.validations.ts +12 -7
  32. package/src/validations/index.ts +5 -0
  33. package/src/validations/typeExtension/typeExtension.validations.ts +8 -0
  34. package/types/.tsbuildinfo +1 -1
  35. package/types/api/clients/caseComments/caseComments.d.ts +20 -0
  36. package/types/api/clients/caseFiles/caseFiles.d.ts +10 -0
  37. package/types/api/clients/caseLinks/caseLinks.d.ts +22 -0
  38. package/types/api/clients/caseRelatedCases/caseRelatedCases.d.ts +14 -0
  39. package/types/api/clients/caseServices/services.d.ts +3 -12
  40. package/types/api/clients/cases/_internals/ftsService.d.ts +7 -0
  41. package/types/api/clients/cases/_internals/stringifyCaseFilters.d.ts +2 -0
  42. package/types/api/clients/cases/cases.d.ts +35 -0
  43. package/types/api/clients/chatMessagesHistory/chatMessagesHistory.d.ts +15 -0
  44. package/types/api/clients/contactCases/contactCases.d.ts +9 -0
  45. package/types/api/clients/index.d.ts +9 -0
  46. package/types/api/clients/labels/labels.d.ts +2 -2
  47. package/types/api/clients/timeline/timeline.d.ts +16 -0
  48. package/types/api/clients/wtTypes/_shared/utils/assignFieldPositions.d.ts +2 -0
  49. package/types/api/clients/wtTypes/_shared/utils/sortDynamicFields.d.ts +2 -2
  50. package/types/api/clients/wtTypes/adjunctTypeRecords/adjunctTypeRecords.d.ts +11 -11
  51. package/types/api/clients/wtTypes/typeExtensions/typeExtensions.d.ts +1 -1
  52. package/types/api/clients//321/201ontacts/getContactAccessFromMode.d.ts +5 -0
  53. package/types/api/clients//321/201ontacts/index.d.ts +1 -1
  54. package/types/validations/adjunctType/adjunctType.validations.d.ts +11 -0
  55. package/types/validations/case/case.validations.d.ts +31 -0
  56. package/types/validations/caseClose/caseClose.validations.d.ts +8 -0
  57. package/types/validations/caseExportOptions/caseExportOptions.validations.d.ts +9 -0
  58. package/types/validations/contact/contact.validations.d.ts +15 -15
  59. package/types/validations/index.d.ts +5 -0
  60. package/types/validations/typeExtension/typeExtension.validations.d.ts +20 -0
  61. package/src/api/clients//321/201ontacts/types/ContactEntity.types.ts +0 -25
  62. package/types/api/clients//321/201ontacts/types/ContactEntity.types.d.ts +0 -14
@@ -20,10 +20,10 @@ import type { ApiId, ApiParams } from '../../_shared/types';
20
20
  const instance = getDefaultInstance();
21
21
 
22
22
  const getAdjunctTypeRecordsList = async ({
23
- repo,
23
+ parentId,
24
24
  ...params
25
25
  }: {
26
- repo: string;
26
+ parentId: string;
27
27
  } & ApiParams) => {
28
28
  const fieldsToSend = [
29
29
  'page',
@@ -45,7 +45,7 @@ const getAdjunctTypeRecordsList = async ({
45
45
  camelToSnake(),
46
46
  ]);
47
47
  try {
48
- const response = await getDictionaries().searchData(repo, {
48
+ const response = await getDictionaries().searchData(parentId, {
49
49
  size,
50
50
  page,
51
51
  sort,
@@ -69,13 +69,13 @@ const getAdjunctTypeRecordsList = async ({
69
69
 
70
70
  const getAdjunctTypeRecord = async ({
71
71
  itemId: id,
72
- repo,
72
+ parentId,
73
73
  }: {
74
74
  itemId: ApiId;
75
- repo: string;
75
+ parentId: string;
76
76
  }) => {
77
77
  try {
78
- const response = await getDictionaries().locateData(repo, String(id));
78
+ const response = await getDictionaries().locateData(parentId, String(id));
79
79
  return response.data;
80
80
  } catch (err) {
81
81
  throw applyTransform(err, [
@@ -87,18 +87,18 @@ const getAdjunctTypeRecord = async ({
87
87
  const addAdjunctTypeRecord = async ({
88
88
  itemInstance,
89
89
  fieldsToSend,
90
- repo,
90
+ parentId,
91
91
  }: {
92
92
  itemInstance: ApiParams;
93
93
  fieldsToSend: string[];
94
- repo: string;
94
+ parentId: string;
95
95
  }) => {
96
96
  const item = applyTransform(itemInstance, [
97
97
  camelToSnake(),
98
98
  sanitize(fieldsToSend),
99
99
  ]);
100
100
  try {
101
- const response = await getDictionaries().createData(repo, item);
101
+ const response = await getDictionaries().createData(parentId, item);
102
102
  return applyTransform(response.data, [
103
103
  snakeToCamel(),
104
104
  ]);
@@ -113,19 +113,23 @@ const updateAdjunctTypeRecord = async ({
113
113
  itemInstance,
114
114
  fieldsToSend,
115
115
  itemId: id,
116
- repo,
116
+ parentId,
117
117
  }: {
118
118
  itemInstance: ApiParams;
119
119
  fieldsToSend: string[];
120
120
  itemId: ApiId;
121
- repo: string;
121
+ parentId: string;
122
122
  }) => {
123
123
  const item = applyTransform(itemInstance, [
124
124
  camelToSnake(),
125
125
  sanitize(fieldsToSend),
126
126
  ]);
127
127
  try {
128
- const response = await getDictionaries().updateData(repo, String(id), item);
128
+ const response = await getDictionaries().updateData(
129
+ parentId,
130
+ String(id),
131
+ item,
132
+ );
129
133
  return applyTransform(response.data, [
130
134
  snakeToCamel(),
131
135
  ]);
@@ -137,10 +141,10 @@ const updateAdjunctTypeRecord = async ({
137
141
  };
138
142
 
139
143
  const deleteAdjunctTypeRecord = async ({
140
- repo,
144
+ parentId,
141
145
  id,
142
146
  }: {
143
- repo: string;
147
+ parentId: string;
144
148
  id: ApiId | ApiId[];
145
149
  }) => {
146
150
  const ids = (
@@ -151,8 +155,7 @@ const deleteAdjunctTypeRecord = async ({
151
155
  ]
152
156
  ).map(String);
153
157
  try {
154
- const response = await getDictionaries().deleteData2(repo, ids);
155
- return response.data;
158
+ await getDictionaries().deleteData2(parentId, ids);
156
159
  } catch (err) {
157
160
  throw applyTransform(err, [
158
161
  notify,
@@ -18,6 +18,8 @@ import type {
18
18
  ApiParams,
19
19
  UpdateItemParams,
20
20
  } from '../../_shared/types';
21
+ import { assignFieldPositions } from '../_shared/utils/assignFieldPositions';
22
+ import { sortDynamicFields } from '../_shared/utils/sortDynamicFields';
21
23
 
22
24
  const fieldsToSend = [
23
25
  'name',
@@ -102,6 +104,7 @@ const getAdjunctType = async ({ itemId: itemRepo }: { itemId: string }) => {
102
104
  return applyTransform(response.data, [
103
105
  snakeToCamel(),
104
106
  itemResponseHandler,
107
+ assignFieldPositions,
105
108
  ]);
106
109
  } catch (err) {
107
110
  throw applyTransform(err, [
@@ -134,6 +137,7 @@ const updateAdjunctType = async ({
134
137
  itemId: id,
135
138
  }: UpdateItemParams) => {
136
139
  const item = applyTransform(itemInstance, [
140
+ sortDynamicFields,
137
141
  camelToSnake(),
138
142
  sanitize(fieldsToSend),
139
143
  ]);
@@ -1,19 +1,17 @@
1
- import { ExtensionsApiFactory, type WebitelProtoDataStruct } from 'webitel-sdk';
2
- import { getDefaultInstance, getDefaultOpenAPIConfig } from '../../../defaults';
1
+ import type { ProtoDataStruct } from '@webitel/api-services/gen/models';
2
+ import { getExtensions } from '../../../../gen-wire';
3
3
  import {
4
4
  applyTransform,
5
5
  camelToSnake,
6
6
  notify,
7
- sanitize,
7
+ sanitizeToWire,
8
8
  snakeToCamel,
9
9
  } from '../../../transformers';
10
10
  import type { ApiId, ApiParams } from '../../_shared/types';
11
+ import { assignFieldPositions } from '../_shared/utils/assignFieldPositions';
11
12
  import { sortDynamicFields } from '../_shared/utils/sortDynamicFields';
12
13
 
13
- const instance = getDefaultInstance();
14
- const configuration = getDefaultOpenAPIConfig();
15
-
16
- const typeExtensionsService = ExtensionsApiFactory(configuration, '', instance);
14
+ const typeExtensionsService = getExtensions();
17
15
 
18
16
  const fieldsToSend = [
19
17
  'fields',
@@ -21,33 +19,19 @@ const fieldsToSend = [
21
19
  'path',
22
20
  ];
23
21
 
24
- const generateIdsFromRepos = (item: WebitelProtoDataStruct) => ({
22
+ const generateIdsFromRepos = (item: ProtoDataStruct) => ({
25
23
  ...item,
26
24
  id: item.repo,
27
25
  });
28
26
 
29
27
  const getTypeExtension = async ({ itemId: typeRepo }: { itemId: string }) => {
30
- const createPositionGenerator = () => {
31
- let position = 1;
32
- return (item: ApiParams) => (item.readonly ? null : position++);
33
- };
34
- const getPosition = createPositionGenerator();
35
-
36
- const itemResponseHandler = (item: ApiParams) => ({
37
- ...item,
38
- fields: item.fields.map((field: ApiParams) => ({
39
- ...field,
40
- position: getPosition(field),
41
- })),
42
- });
43
-
44
28
  try {
45
- const response = await typeExtensionsService.locateType(typeRepo);
29
+ const response = await typeExtensionsService.locateTypeExtensions(typeRepo);
46
30
 
47
31
  return applyTransform(response.data, [
48
32
  snakeToCamel(),
49
33
  generateIdsFromRepos,
50
- itemResponseHandler,
34
+ assignFieldPositions,
51
35
  ]);
52
36
  } catch {
53
37
  return {
@@ -67,11 +51,11 @@ const addTypeExtension = async ({
67
51
  }) => {
68
52
  const item = applyTransform(itemInstance, [
69
53
  sortDynamicFields,
54
+ sanitizeToWire(fieldsToSend),
70
55
  camelToSnake(),
71
- sanitize(fieldsToSend),
72
56
  ]);
73
57
  try {
74
- const response = await typeExtensionsService.createType(
58
+ const response = await typeExtensionsService.createTypeExtensions(
75
59
  String(typeRepo),
76
60
  item,
77
61
  );
@@ -88,7 +72,7 @@ const addTypeExtension = async ({
88
72
 
89
73
  const deleteTypeExtension = async ({ itemId: typeRepo }: { itemId: ApiId }) => {
90
74
  try {
91
- await typeExtensionsService.deleteType([
75
+ await typeExtensionsService.deleteTypeExtensions([
92
76
  String(typeRepo),
93
77
  ]);
94
78
  } catch (err) {
@@ -116,18 +100,24 @@ const updateTypeExtension = async ({
116
100
  }
117
101
 
118
102
  if (!itemInstance.fields.length && !itemInstance.isNew) {
119
- return deleteTypeExtension({
103
+ await deleteTypeExtension({
120
104
  itemId: typeRepo,
121
105
  });
106
+
107
+ return {
108
+ id: typeRepo,
109
+ fields: [],
110
+ isNew: true,
111
+ };
122
112
  }
123
113
 
124
114
  const item = applyTransform(itemInstance, [
125
115
  sortDynamicFields,
116
+ sanitizeToWire(fieldsToSend),
126
117
  camelToSnake(),
127
- sanitize(fieldsToSend),
128
118
  ]);
129
119
  try {
130
- const response = await typeExtensionsService.updateType(
120
+ const response = await typeExtensionsService.updateTypeExtensions(
131
121
  String(typeRepo),
132
122
  item,
133
123
  );
@@ -143,7 +133,7 @@ const updateTypeExtension = async ({
143
133
  };
144
134
 
145
135
  export const WtTypeExtensionAPI = {
146
- getList: getTypeExtension,
136
+ get: getTypeExtension,
147
137
  add: addTypeExtension,
148
138
  update: updateTypeExtension,
149
139
  delete: deleteTypeExtension,