@webitel/api-services 1.0.5 → 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.
- package/package.json +2 -1
- package/src/api/clients/caseComments/caseComments.ts +141 -0
- package/src/api/clients/caseFiles/caseFiles.ts +79 -0
- package/src/api/clients/caseLinks/caseLinks.ts +150 -0
- package/src/api/clients/caseRelatedCases/caseRelatedCases.ts +125 -0
- package/src/api/clients/caseServices/services.ts +38 -72
- package/src/api/clients/cases/_internals/ftsService.ts +67 -0
- package/src/api/clients/cases/_internals/stringifyCaseFilters.ts +156 -0
- package/src/api/clients/cases/cases.ts +360 -0
- package/src/api/clients/chatMessagesHistory/chatMessagesHistory.ts +64 -0
- package/src/api/clients/configurations/configurations.ts +56 -39
- package/src/api/clients/contactCases/contactCases.ts +109 -0
- package/src/api/clients/emails/emails.ts +11 -7
- package/src/api/clients/index.ts +9 -0
- package/src/api/clients/labels/labels.ts +24 -29
- package/src/api/clients/phones/phones.ts +11 -7
- package/src/api/clients/timeline/timeline.ts +124 -0
- package/src/api/clients/variables/variables.ts +10 -5
- package/src/api/clients/wtTypes/_shared/utils/assignFieldPositions.ts +28 -0
- package/src/api/clients/wtTypes/_shared/utils/sortDynamicFields.ts +7 -9
- package/src/api/clients/wtTypes/adjunctTypeRecords/adjunctTypeRecords.ts +19 -16
- package/src/api/clients/wtTypes/adjunctTypes/adjunctTypes.ts +4 -0
- package/src/api/clients/wtTypes/typeExtensions/typeExtensions.ts +21 -31
- package/src/api/clients//321/201ontacts/contacts.ts +103 -234
- package/src/api/clients//321/201ontacts/getContactAccessFromMode.ts +9 -0
- package/src/api/clients//321/201ontacts/index.ts +1 -1
- package/src/gen/_models/contactsCallFile.ts +3 -0
- package/src/gen/_models/contactsCallFileType.ts +18 -0
- package/src/gen/_models/index.ts +9 -0
- package/src/gen/_models/webitelCasesCallFile.ts +3 -0
- package/src/gen/_models/webitelCasesCallFileType.ts +18 -0
- package/src/gen-wire/_models/contactsCallFile.ts +3 -0
- package/src/gen-wire/_models/contactsCallFileType.ts +18 -0
- package/src/gen-wire/_models/index.ts +2 -0
- package/src/gen-wire/_models/webitelCasesCallFile.ts +3 -0
- package/src/gen-wire/_models/webitelCasesCallFileType.ts +18 -0
- package/src/gen-wire/access-store/access-store.ts +1 -1
- package/src/gen-wire/agent-absence-service/agent-absence-service.ts +1 -1
- package/src/gen-wire/agent-chat-service/agent-chat-service.ts +1 -1
- package/src/gen-wire/agent-pause-cause-service/agent-pause-cause-service.ts +1 -1
- package/src/gen-wire/agent-service/agent-service.ts +1 -1
- package/src/gen-wire/agent-skill-service/agent-skill-service.ts +1 -1
- package/src/gen-wire/agent-team-service/agent-team-service.ts +1 -1
- package/src/gen-wire/agent-working-conditions-service/agent-working-conditions-service.ts +1 -1
- package/src/gen-wire/agent-working-schedule-service/agent-working-schedule-service.ts +1 -1
- package/src/gen-wire/articles/articles.ts +1 -1
- package/src/gen-wire/attachments/attachments.ts +1 -1
- package/src/gen-wire/audit-form-service/audit-form-service.ts +1 -1
- package/src/gen-wire/auth/auth.ts +1 -1
- package/src/gen-wire/backend-profile-service/backend-profile-service.ts +1 -1
- package/src/gen-wire/bucket-service/bucket-service.ts +1 -1
- package/src/gen-wire/calendar-service/calendar-service.ts +1 -1
- package/src/gen-wire/call-service/call-service.ts +1 -1
- package/src/gen-wire/case-comments/case-comments.ts +1 -1
- package/src/gen-wire/case-communications/case-communications.ts +1 -1
- package/src/gen-wire/case-files/case-files.ts +1 -1
- package/src/gen-wire/case-links/case-links.ts +1 -1
- package/src/gen-wire/case-timeline/case-timeline.ts +1 -1
- package/src/gen-wire/case-timeline/case-timeline.zod.ts +14 -0
- package/src/gen-wire/cases/cases.ts +1 -1
- package/src/gen-wire/cases-chat-catalog/cases-chat-catalog.ts +1 -1
- package/src/gen-wire/catalogs/catalogs.ts +1 -1
- package/src/gen-wire/classes/classes.ts +1 -1
- package/src/gen-wire/close-reason-groups/close-reason-groups.ts +1 -1
- package/src/gen-wire/close-reasons/close-reasons.ts +1 -1
- package/src/gen-wire/cognitive-profile-service/cognitive-profile-service.ts +1 -1
- package/src/gen-wire/comments/comments.ts +1 -1
- package/src/gen-wire/communication-type-service/communication-type-service.ts +1 -1
- package/src/gen-wire/config-service/config-service.ts +1 -1
- package/src/gen-wire/contact-groups/contact-groups.ts +1 -1
- package/src/gen-wire/contact-linking-service/contact-linking-service.ts +1 -1
- package/src/gen-wire/contacts/contacts.ts +1 -1
- package/src/gen-wire/contacts-chat-catalog/contacts-chat-catalog.ts +1 -1
- package/src/gen-wire/customer/customer.ts +1 -1
- package/src/gen-wire/customers/customers.ts +1 -1
- package/src/gen-wire/devices/devices.ts +1 -1
- package/src/gen-wire/dictionaries/dictionaries.ts +1 -1
- package/src/gen-wire/domains/domains.ts +1 -1
- package/src/gen-wire/dynamic-conditions/dynamic-conditions.ts +1 -1
- package/src/gen-wire/dynamic-groups/dynamic-groups.ts +1 -1
- package/src/gen-wire/email-profile-service/email-profile-service.ts +1 -1
- package/src/gen-wire/emails/emails.ts +1 -1
- package/src/gen-wire/embedding-models/embedding-models.ts +1 -1
- package/src/gen-wire/extensions/extensions.ts +1 -1
- package/src/gen-wire/feedback-service/feedback-service.ts +1 -1
- package/src/gen-wire/file-policies-service/file-policies-service.ts +1 -1
- package/src/gen-wire/file-service/file-service.ts +1 -1
- package/src/gen-wire/file-transcript-service/file-transcript-service.ts +1 -1
- package/src/gen-wire/forecast-calculation-service/forecast-calculation-service.ts +1 -1
- package/src/gen-wire/ftsservice/ftsservice.ts +1 -1
- package/src/gen-wire/groups/groups.ts +1 -1
- package/src/gen-wire/im-service-provider-v1-telegrambotservice/im-service-provider-v1-telegrambotservice.ts +1 -1
- package/src/gen-wire/imclients/imclients.ts +1 -1
- package/src/gen-wire/import-template-service/import-template-service.ts +1 -1
- package/src/gen-wire/index.ts +2 -0
- package/src/gen-wire/knowledgebase-search/knowledgebase-search.ts +1 -1
- package/src/gen-wire/labels/labels.ts +1 -1
- package/src/gen-wire/languages/languages.ts +1 -1
- package/src/gen-wire/ldap/ldap.ts +1 -1
- package/src/gen-wire/list-service/list-service.ts +1 -1
- package/src/gen-wire/logger-service/logger-service.ts +1 -1
- package/src/gen-wire/managers/managers.ts +1 -1
- package/src/gen-wire/media-file-service/media-file-service.ts +1 -1
- package/src/gen-wire/meeting-service/meeting-service.ts +1 -1
- package/src/gen-wire/member-service/member-service.ts +1 -1
- package/src/gen-wire/messages/messages.ts +1 -1
- package/src/gen-wire/oauth2-federation/oauth2-federation.ts +1 -1
- package/src/gen-wire/online-skills/online-skills.ts +1 -1
- package/src/gen-wire/outbound-resource-group-service/outbound-resource-group-service.ts +1 -1
- package/src/gen-wire/outbound-resource-service/outbound-resource-service.ts +1 -1
- package/src/gen-wire/pause-template-service/pause-template-service.ts +1 -1
- package/src/gen-wire/pdf-service/pdf-service.ts +1 -1
- package/src/gen-wire/permissions/permissions.ts +1 -1
- package/src/gen-wire/phones/phones.ts +1 -1
- package/src/gen-wire/photos/photos.ts +1 -1
- package/src/gen-wire/presence/presence.ts +1 -1
- package/src/gen-wire/preset-query-service/preset-query-service.ts +1 -1
- package/src/gen-wire/priorities/priorities.ts +1 -1
- package/src/gen-wire/queue-bucket-service/queue-bucket-service.ts +1 -1
- package/src/gen-wire/queue-hook-service/queue-hook-service.ts +1 -1
- package/src/gen-wire/queue-resources-service/queue-resources-service.ts +1 -1
- package/src/gen-wire/queue-service/queue-service.ts +1 -1
- package/src/gen-wire/queue-skill-service/queue-skill-service.ts +1 -1
- package/src/gen-wire/quick-replies-service/quick-replies-service.ts +1 -1
- package/src/gen-wire/records/records.ts +1 -1
- package/src/gen-wire/region-service/region-service.ts +1 -1
- package/src/gen-wire/related-cases/related-cases.ts +1 -1
- package/src/gen-wire/retrieval/retrieval.ts +1 -1
- package/src/gen-wire/routing-chat-plan-service/routing-chat-plan-service.ts +1 -1
- package/src/gen-wire/routing-outbound-call-service/routing-outbound-call-service.ts +1 -1
- package/src/gen-wire/routing-schema-service/routing-schema-service.ts +1 -1
- package/src/gen-wire/routing-variable-service/routing-variable-service.ts +1 -1
- package/src/gen-wire/schema-variables-service/schema-variables-service.ts +1 -1
- package/src/gen-wire/schema-version-service/schema-version-service.ts +1 -1
- package/src/gen-wire/services/services.ts +1 -1
- package/src/gen-wire/shift-template-service/shift-template-service.ts +1 -1
- package/src/gen-wire/skill-service/skill-service.ts +1 -1
- package/src/gen-wire/slaconditions/slaconditions.ts +1 -1
- package/src/gen-wire/slas/slas.ts +1 -1
- package/src/gen-wire/sources/sources.ts +1 -1
- package/src/gen-wire/spaces/spaces.ts +1 -1
- package/src/gen-wire/status-conditions/status-conditions.ts +1 -1
- package/src/gen-wire/statuses/statuses.ts +1 -1
- package/src/gen-wire/system-setting-service/system-setting-service.ts +1 -1
- package/src/gen-wire/tags/tags.ts +1 -1
- package/src/gen-wire/team-hook-service/team-hook-service.ts +1 -1
- package/src/gen-wire/team-trigger-service/team-trigger-service.ts +1 -1
- package/src/gen-wire/timeline/timeline.ts +1 -1
- package/src/gen-wire/timeline/timeline.zod.ts +14 -0
- package/src/gen-wire/timezones/timezones.ts +1 -1
- package/src/gen-wire/trigger-service/trigger-service.ts +1 -1
- package/src/gen-wire/two-factor-authentication/two-factor-authentication.ts +1 -1
- package/src/gen-wire/types/types.ts +1 -1
- package/src/gen-wire/user-access-tokens/user-access-tokens.ts +1 -1
- package/src/gen-wire/user-helper-service/user-helper-service.ts +1 -1
- package/src/gen-wire/users/users.ts +1 -1
- package/src/gen-wire/variables/variables.ts +1 -1
- package/src/gen-wire/versions/versions.ts +1 -1
- package/src/gen-wire/web-hook-service/web-hook-service.ts +1 -1
- package/src/gen-wire/webitel-im-api-gateway-v1-account/webitel-im-api-gateway-v1-account.ts +1 -1
- package/src/gen-wire/webitel-im-api-gateway-v1-bots/webitel-im-api-gateway-v1-bots.ts +1 -1
- package/src/gen-wire/webitel-im-api-gateway-v1-contacts/webitel-im-api-gateway-v1-contacts.ts +1 -1
- package/src/gen-wire/webitel-im-api-gateway-v1-contactsettingsmanagement/webitel-im-api-gateway-v1-contactsettingsmanagement.ts +1 -1
- package/src/gen-wire/webitel-im-api-gateway-v1-message/webitel-im-api-gateway-v1-message.ts +1 -1
- package/src/gen-wire/webitel-im-api-gateway-v1-messagehistory/webitel-im-api-gateway-v1-messagehistory.ts +1 -1
- package/src/gen-wire/webitel-im-api-gateway-v1-threadmanagement/webitel-im-api-gateway-v1-threadmanagement.ts +1 -1
- package/src/gen-wire/webitel-im-api-gateway-v1-threadpermission/webitel-im-api-gateway-v1-threadpermission.ts +1 -1
- package/src/gen-wire/webitel-im-api-provider-v1-facebookservice/webitel-im-api-provider-v1-facebookservice.ts +1 -1
- package/src/gen-wire/webitel-im-api-provider-v1-instagramservice/webitel-im-api-provider-v1-instagramservice.ts +1 -1
- package/src/gen-wire/webitel-im-api-provider-v1-metaappservice/webitel-im-api-provider-v1-metaappservice.ts +1 -1
- package/src/gen-wire/webitel-im-api-provider-v1-metaoauthservice/webitel-im-api-provider-v1-metaoauthservice.ts +1 -1
- package/src/gen-wire/webitel-im-api-provider-v1-whatsappservice/webitel-im-api-provider-v1-whatsappservice.ts +1 -1
- package/src/gen-wire/webitel-im-provider-v1-facebookservice/webitel-im-provider-v1-facebookservice.ts +1 -1
- package/src/gen-wire/webitel-im-provider-v1-gateservice/webitel-im-provider-v1-gateservice.ts +1 -1
- package/src/gen-wire/webitel-im-provider-v1-gatetemplateservice/webitel-im-provider-v1-gatetemplateservice.ts +1 -1
- package/src/gen-wire/webitel-im-provider-v1-instagramservice/webitel-im-provider-v1-instagramservice.ts +1 -1
- package/src/gen-wire/webitel-im-provider-v1-metaappservice/webitel-im-provider-v1-metaappservice.ts +1 -1
- package/src/gen-wire/webitel-im-provider-v1-metaoauthservice/webitel-im-provider-v1-metaoauthservice.ts +1 -1
- package/src/gen-wire/webitel-im-provider-v1-providermessageservice/webitel-im-provider-v1-providermessageservice.ts +1 -1
- package/src/gen-wire/webitel-im-provider-v1-viberservice/webitel-im-provider-v1-viberservice.ts +1 -1
- package/src/gen-wire/webitel-im-provider-v1-whatsappservice/webitel-im-provider-v1-whatsappservice.ts +1 -1
- package/src/gen-wire/working-condition-service/working-condition-service.ts +1 -1
- package/src/gen-wire/working-schedule-service/working-schedule-service.ts +1 -1
- package/src/validations/adjunctType/adjunctType.validations.ts +18 -0
- package/src/validations/case/case.validations.ts +33 -0
- package/src/validations/caseClose/caseClose.validations.ts +30 -0
- package/src/validations/caseExportOptions/caseExportOptions.validations.ts +27 -0
- package/src/validations/contact/contact.validations.ts +12 -7
- package/src/validations/index.ts +5 -0
- package/src/validations/typeExtension/typeExtension.validations.ts +8 -0
- package/types/.tsbuildinfo +1 -1
- package/types/api/clients/caseComments/caseComments.d.ts +20 -0
- package/types/api/clients/caseFiles/caseFiles.d.ts +10 -0
- package/types/api/clients/caseLinks/caseLinks.d.ts +22 -0
- package/types/api/clients/caseRelatedCases/caseRelatedCases.d.ts +14 -0
- package/types/api/clients/caseServices/services.d.ts +3 -12
- package/types/api/clients/cases/_internals/ftsService.d.ts +7 -0
- package/types/api/clients/cases/_internals/stringifyCaseFilters.d.ts +2 -0
- package/types/api/clients/cases/cases.d.ts +35 -0
- package/types/api/clients/chatMessagesHistory/chatMessagesHistory.d.ts +15 -0
- package/types/api/clients/contactCases/contactCases.d.ts +9 -0
- package/types/api/clients/index.d.ts +9 -0
- package/types/api/clients/labels/labels.d.ts +2 -2
- package/types/api/clients/timeline/timeline.d.ts +16 -0
- package/types/api/clients/wtTypes/_shared/utils/assignFieldPositions.d.ts +2 -0
- package/types/api/clients/wtTypes/_shared/utils/sortDynamicFields.d.ts +2 -2
- package/types/api/clients/wtTypes/adjunctTypeRecords/adjunctTypeRecords.d.ts +11 -11
- package/types/api/clients/wtTypes/typeExtensions/typeExtensions.d.ts +1 -1
- package/types/api/clients//321/201ontacts/getContactAccessFromMode.d.ts +5 -0
- package/types/api/clients//321/201ontacts/index.d.ts +1 -1
- package/types/gen/_models/contactsCallFile.d.ts +3 -0
- package/types/gen/_models/contactsCallFileType.d.ts +15 -0
- package/types/gen/_models/index.d.ts +8 -0
- package/types/gen/_models/webitelCasesCallFile.d.ts +3 -0
- package/types/gen/_models/webitelCasesCallFileType.d.ts +15 -0
- package/types/gen-wire/_models/contactsCallFile.d.ts +3 -0
- package/types/gen-wire/_models/contactsCallFileType.d.ts +15 -0
- package/types/gen-wire/_models/index.d.ts +2 -0
- package/types/gen-wire/_models/webitelCasesCallFile.d.ts +3 -0
- package/types/gen-wire/_models/webitelCasesCallFileType.d.ts +15 -0
- package/types/gen-wire/case-timeline/case-timeline.zod.d.ts +10 -0
- package/types/gen-wire/index.d.ts +2 -2
- package/types/gen-wire/timeline/timeline.zod.d.ts +10 -0
- package/types/validations/adjunctType/adjunctType.validations.d.ts +11 -0
- package/types/validations/case/case.validations.d.ts +31 -0
- package/types/validations/caseClose/caseClose.validations.d.ts +8 -0
- package/types/validations/caseExportOptions/caseExportOptions.validations.d.ts +9 -0
- package/types/validations/contact/contact.validations.d.ts +15 -15
- package/types/validations/index.d.ts +5 -0
- package/types/validations/typeExtension/typeExtension.validations.d.ts +20 -0
- package/src/api/clients//321/201ontacts/types/ContactEntity.types.ts +0 -25
- 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
|
-
|
|
23
|
+
parentId,
|
|
24
24
|
...params
|
|
25
25
|
}: {
|
|
26
|
-
|
|
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(
|
|
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
|
-
|
|
72
|
+
parentId,
|
|
73
73
|
}: {
|
|
74
74
|
itemId: ApiId;
|
|
75
|
-
|
|
75
|
+
parentId: string;
|
|
76
76
|
}) => {
|
|
77
77
|
try {
|
|
78
|
-
const response = await getDictionaries().locateData(
|
|
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
|
-
|
|
90
|
+
parentId,
|
|
91
91
|
}: {
|
|
92
92
|
itemInstance: ApiParams;
|
|
93
93
|
fieldsToSend: string[];
|
|
94
|
-
|
|
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(
|
|
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
|
-
|
|
116
|
+
parentId,
|
|
117
117
|
}: {
|
|
118
118
|
itemInstance: ApiParams;
|
|
119
119
|
fieldsToSend: string[];
|
|
120
120
|
itemId: ApiId;
|
|
121
|
-
|
|
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(
|
|
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
|
-
|
|
144
|
+
parentId,
|
|
141
145
|
id,
|
|
142
146
|
}: {
|
|
143
|
-
|
|
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
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
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
|
-
|
|
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
|
|
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:
|
|
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.
|
|
29
|
+
const response = await typeExtensionsService.locateTypeExtensions(typeRepo);
|
|
46
30
|
|
|
47
31
|
return applyTransform(response.data, [
|
|
48
32
|
snakeToCamel(),
|
|
49
33
|
generateIdsFromRepos,
|
|
50
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
136
|
+
get: getTypeExtension,
|
|
147
137
|
add: addTypeExtension,
|
|
148
138
|
update: updateTypeExtension,
|
|
149
139
|
delete: deleteTypeExtension,
|