@ikatec/digisac-api-sdk 4.8.0 → 4.10.0
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/README.md +36 -12
- package/dist/apis/absence/AbsenceApi.cjs +12 -0
- package/dist/apis/absence/AbsenceApi.cjs.map +1 -1
- package/dist/apis/absence/AbsenceApi.d.ts +9 -0
- package/dist/apis/absence/AbsenceApi.d.ts.map +1 -1
- package/dist/apis/absence/AbsenceApi.mjs +12 -0
- package/dist/apis/absence/AbsenceApi.mjs.map +1 -1
- package/dist/apis/acceptanceTerms/AcceptanceTermsApi.cjs +8 -0
- package/dist/apis/acceptanceTerms/AcceptanceTermsApi.cjs.map +1 -1
- package/dist/apis/acceptanceTerms/AcceptanceTermsApi.d.ts +8 -1
- package/dist/apis/acceptanceTerms/AcceptanceTermsApi.d.ts.map +1 -1
- package/dist/apis/acceptanceTerms/AcceptanceTermsApi.mjs +8 -0
- package/dist/apis/acceptanceTerms/AcceptanceTermsApi.mjs.map +1 -1
- package/dist/apis/accounts/AccountsApi.cjs +5 -0
- package/dist/apis/accounts/AccountsApi.cjs.map +1 -1
- package/dist/apis/accounts/AccountsApi.d.ts +5 -0
- package/dist/apis/accounts/AccountsApi.d.ts.map +1 -1
- package/dist/apis/accounts/AccountsApi.mjs +5 -0
- package/dist/apis/accounts/AccountsApi.mjs.map +1 -1
- package/dist/apis/accounts/types.d.ts +2 -0
- package/dist/apis/accounts/types.d.ts.map +1 -1
- package/dist/apis/activityLog/ActivityLogApi.cjs +12 -0
- package/dist/apis/activityLog/ActivityLogApi.cjs.map +1 -1
- package/dist/apis/activityLog/ActivityLogApi.d.ts +8 -0
- package/dist/apis/activityLog/ActivityLogApi.d.ts.map +1 -1
- package/dist/apis/activityLog/ActivityLogApi.mjs +12 -0
- package/dist/apis/activityLog/ActivityLogApi.mjs.map +1 -1
- package/dist/apis/categories/CategoriesApi.cjs +7 -0
- package/dist/apis/categories/CategoriesApi.cjs.map +1 -1
- package/dist/apis/categories/CategoriesApi.d.ts +7 -1
- package/dist/apis/categories/CategoriesApi.d.ts.map +1 -1
- package/dist/apis/categories/CategoriesApi.mjs +7 -0
- package/dist/apis/categories/CategoriesApi.mjs.map +1 -1
- package/dist/apis/clientFeedback/ClientFeedbackApi.cjs +5 -1
- package/dist/apis/clientFeedback/ClientFeedbackApi.cjs.map +1 -1
- package/dist/apis/clientFeedback/ClientFeedbackApi.d.ts +5 -1
- package/dist/apis/clientFeedback/ClientFeedbackApi.d.ts.map +1 -1
- package/dist/apis/clientFeedback/ClientFeedbackApi.mjs +5 -1
- package/dist/apis/clientFeedback/ClientFeedbackApi.mjs.map +1 -1
- package/dist/apis/contactBlockLists/ContactBlockListsApi.cjs +8 -0
- package/dist/apis/contactBlockLists/ContactBlockListsApi.cjs.map +1 -1
- package/dist/apis/contactBlockLists/ContactBlockListsApi.d.ts +8 -1
- package/dist/apis/contactBlockLists/ContactBlockListsApi.d.ts.map +1 -1
- package/dist/apis/contactBlockLists/ContactBlockListsApi.mjs +8 -0
- package/dist/apis/contactBlockLists/ContactBlockListsApi.mjs.map +1 -1
- package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.cjs +7 -0
- package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.cjs.map +1 -1
- package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.d.ts +7 -1
- package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.d.ts.map +1 -1
- package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.mjs +7 -0
- package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.mjs.map +1 -1
- package/dist/apis/contacts/ContactsApi.cjs +16 -3
- package/dist/apis/contacts/ContactsApi.cjs.map +1 -1
- package/dist/apis/contacts/ContactsApi.d.ts +16 -5
- package/dist/apis/contacts/ContactsApi.d.ts.map +1 -1
- package/dist/apis/contacts/ContactsApi.mjs +16 -3
- package/dist/apis/contacts/ContactsApi.mjs.map +1 -1
- package/dist/apis/contacts/types.d.ts +6 -1
- package/dist/apis/contacts/types.d.ts.map +1 -1
- package/dist/apis/creditMovements/CreditMovementsApi.cjs +17 -0
- package/dist/apis/creditMovements/CreditMovementsApi.cjs.map +1 -1
- package/dist/apis/creditMovements/CreditMovementsApi.d.ts +11 -0
- package/dist/apis/creditMovements/CreditMovementsApi.d.ts.map +1 -1
- package/dist/apis/creditMovements/CreditMovementsApi.mjs +17 -0
- package/dist/apis/creditMovements/CreditMovementsApi.mjs.map +1 -1
- package/dist/apis/customFields/CustomFieldsApi.cjs +7 -0
- package/dist/apis/customFields/CustomFieldsApi.cjs.map +1 -1
- package/dist/apis/customFields/CustomFieldsApi.d.ts +7 -1
- package/dist/apis/customFields/CustomFieldsApi.d.ts.map +1 -1
- package/dist/apis/customFields/CustomFieldsApi.mjs +7 -0
- package/dist/apis/customFields/CustomFieldsApi.mjs.map +1 -1
- package/dist/apis/departments/DepartmentsApi.cjs +21 -0
- package/dist/apis/departments/DepartmentsApi.cjs.map +1 -1
- package/dist/apis/departments/DepartmentsApi.d.ts +20 -2
- package/dist/apis/departments/DepartmentsApi.d.ts.map +1 -1
- package/dist/apis/departments/DepartmentsApi.mjs +21 -0
- package/dist/apis/departments/DepartmentsApi.mjs.map +1 -1
- package/dist/apis/departments/types.d.ts +5 -0
- package/dist/apis/departments/types.d.ts.map +1 -1
- package/dist/apis/distribution/DistributionApi.cjs +7 -0
- package/dist/apis/distribution/DistributionApi.cjs.map +1 -1
- package/dist/apis/distribution/DistributionApi.d.ts +7 -1
- package/dist/apis/distribution/DistributionApi.d.ts.map +1 -1
- package/dist/apis/distribution/DistributionApi.mjs +7 -0
- package/dist/apis/distribution/DistributionApi.mjs.map +1 -1
- package/dist/apis/files/FilesApi.cjs +49 -0
- package/dist/apis/files/FilesApi.cjs.map +1 -1
- package/dist/apis/files/FilesApi.d.ts +45 -2
- package/dist/apis/files/FilesApi.d.ts.map +1 -1
- package/dist/apis/files/FilesApi.mjs +49 -0
- package/dist/apis/files/FilesApi.mjs.map +1 -1
- package/dist/apis/files/types.d.ts +45 -7
- package/dist/apis/files/types.d.ts.map +1 -1
- package/dist/apis/holiday/HolidayApi.cjs +7 -0
- package/dist/apis/holiday/HolidayApi.cjs.map +1 -1
- package/dist/apis/holiday/HolidayApi.d.ts +7 -1
- package/dist/apis/holiday/HolidayApi.d.ts.map +1 -1
- package/dist/apis/holiday/HolidayApi.mjs +7 -0
- package/dist/apis/holiday/HolidayApi.mjs.map +1 -1
- package/dist/apis/integrations/IntegrationsApi.cjs +7 -0
- package/dist/apis/integrations/IntegrationsApi.cjs.map +1 -1
- package/dist/apis/integrations/IntegrationsApi.d.ts +7 -1
- package/dist/apis/integrations/IntegrationsApi.d.ts.map +1 -1
- package/dist/apis/integrations/IntegrationsApi.mjs +7 -0
- package/dist/apis/integrations/IntegrationsApi.mjs.map +1 -1
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.cjs +7 -0
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.cjs.map +1 -1
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.d.ts +7 -1
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.d.ts.map +1 -1
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.mjs +7 -0
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.mjs.map +1 -1
- package/dist/apis/interactiveMessages/types.d.ts +61 -3
- package/dist/apis/interactiveMessages/types.d.ts.map +1 -1
- package/dist/apis/kanbanBoards/KanbanBoardsApi.cjs +7 -0
- package/dist/apis/kanbanBoards/KanbanBoardsApi.cjs.map +1 -1
- package/dist/apis/kanbanBoards/KanbanBoardsApi.d.ts +7 -1
- package/dist/apis/kanbanBoards/KanbanBoardsApi.d.ts.map +1 -1
- package/dist/apis/kanbanBoards/KanbanBoardsApi.mjs +7 -0
- package/dist/apis/kanbanBoards/KanbanBoardsApi.mjs.map +1 -1
- package/dist/apis/kanbanCards/KanbanCardsApi.cjs +7 -0
- package/dist/apis/kanbanCards/KanbanCardsApi.cjs.map +1 -1
- package/dist/apis/kanbanCards/KanbanCardsApi.d.ts +7 -1
- package/dist/apis/kanbanCards/KanbanCardsApi.d.ts.map +1 -1
- package/dist/apis/kanbanCards/KanbanCardsApi.mjs +7 -0
- package/dist/apis/kanbanCards/KanbanCardsApi.mjs.map +1 -1
- package/dist/apis/knowledgeBase/KnowledgeBaseApi.cjs +8 -0
- package/dist/apis/knowledgeBase/KnowledgeBaseApi.cjs.map +1 -1
- package/dist/apis/knowledgeBase/KnowledgeBaseApi.d.ts +8 -1
- package/dist/apis/knowledgeBase/KnowledgeBaseApi.d.ts.map +1 -1
- package/dist/apis/knowledgeBase/KnowledgeBaseApi.mjs +8 -0
- package/dist/apis/knowledgeBase/KnowledgeBaseApi.mjs.map +1 -1
- package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.cjs +8 -0
- package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.cjs.map +1 -1
- package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.d.ts +8 -1
- package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.d.ts.map +1 -1
- package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.mjs +8 -0
- package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.mjs.map +1 -1
- package/dist/apis/messages/MessagesApi.cjs +23 -3
- package/dist/apis/messages/MessagesApi.cjs.map +1 -1
- package/dist/apis/messages/MessagesApi.d.ts +19 -3
- package/dist/apis/messages/MessagesApi.d.ts.map +1 -1
- package/dist/apis/messages/MessagesApi.mjs +23 -3
- package/dist/apis/messages/MessagesApi.mjs.map +1 -1
- package/dist/apis/messages/types.d.ts +3 -0
- package/dist/apis/messages/types.d.ts.map +1 -1
- package/dist/apis/notifications/NotificationsApi.cjs +7 -0
- package/dist/apis/notifications/NotificationsApi.cjs.map +1 -1
- package/dist/apis/notifications/NotificationsApi.d.ts +7 -1
- package/dist/apis/notifications/NotificationsApi.d.ts.map +1 -1
- package/dist/apis/notifications/NotificationsApi.mjs +7 -0
- package/dist/apis/notifications/NotificationsApi.mjs.map +1 -1
- package/dist/apis/organizations/OrganizationsApi.cjs +7 -0
- package/dist/apis/organizations/OrganizationsApi.cjs.map +1 -1
- package/dist/apis/organizations/OrganizationsApi.d.ts +7 -1
- package/dist/apis/organizations/OrganizationsApi.d.ts.map +1 -1
- package/dist/apis/organizations/OrganizationsApi.mjs +7 -0
- package/dist/apis/organizations/OrganizationsApi.mjs.map +1 -1
- package/dist/apis/people/PeopleApi.cjs +7 -0
- package/dist/apis/people/PeopleApi.cjs.map +1 -1
- package/dist/apis/people/PeopleApi.d.ts +7 -1
- package/dist/apis/people/PeopleApi.d.ts.map +1 -1
- package/dist/apis/people/PeopleApi.mjs +7 -0
- package/dist/apis/people/PeopleApi.mjs.map +1 -1
- package/dist/apis/planAiHistory/PlanAiHistoryApi.cjs +16 -0
- package/dist/apis/planAiHistory/PlanAiHistoryApi.cjs.map +1 -1
- package/dist/apis/planAiHistory/PlanAiHistoryApi.d.ts +10 -0
- package/dist/apis/planAiHistory/PlanAiHistoryApi.d.ts.map +1 -1
- package/dist/apis/planAiHistory/PlanAiHistoryApi.mjs +16 -0
- package/dist/apis/planAiHistory/PlanAiHistoryApi.mjs.map +1 -1
- package/dist/apis/roles/RolesApi.cjs +7 -0
- package/dist/apis/roles/RolesApi.cjs.map +1 -1
- package/dist/apis/roles/RolesApi.d.ts +6 -1
- package/dist/apis/roles/RolesApi.d.ts.map +1 -1
- package/dist/apis/roles/RolesApi.mjs +7 -0
- package/dist/apis/roles/RolesApi.mjs.map +1 -1
- package/dist/apis/services/ServicesApi.cjs +68 -0
- package/dist/apis/services/ServicesApi.cjs.map +1 -1
- package/dist/apis/services/ServicesApi.d.ts +53 -1
- package/dist/apis/services/ServicesApi.d.ts.map +1 -1
- package/dist/apis/services/ServicesApi.mjs +68 -0
- package/dist/apis/services/ServicesApi.mjs.map +1 -1
- package/dist/apis/services/types.d.ts +68 -1
- package/dist/apis/services/types.d.ts.map +1 -1
- package/dist/apis/stickers/StickersApi.cjs +20 -0
- package/dist/apis/stickers/StickersApi.cjs.map +1 -1
- package/dist/apis/stickers/StickersApi.d.ts +15 -0
- package/dist/apis/stickers/StickersApi.d.ts.map +1 -1
- package/dist/apis/stickers/StickersApi.mjs +20 -0
- package/dist/apis/stickers/StickersApi.mjs.map +1 -1
- package/dist/apis/tags/TagsApi.cjs +7 -0
- package/dist/apis/tags/TagsApi.cjs.map +1 -1
- package/dist/apis/tags/TagsApi.d.ts +7 -1
- package/dist/apis/tags/TagsApi.d.ts.map +1 -1
- package/dist/apis/tags/TagsApi.mjs +7 -0
- package/dist/apis/tags/TagsApi.mjs.map +1 -1
- package/dist/apis/timetable/TimetableApi.cjs +7 -0
- package/dist/apis/timetable/TimetableApi.cjs.map +1 -1
- package/dist/apis/timetable/TimetableApi.d.ts +7 -1
- package/dist/apis/timetable/TimetableApi.d.ts.map +1 -1
- package/dist/apis/timetable/TimetableApi.mjs +7 -0
- package/dist/apis/timetable/TimetableApi.mjs.map +1 -1
- package/dist/apis/users/UsersApi.cjs +8 -0
- package/dist/apis/users/UsersApi.cjs.map +1 -1
- package/dist/apis/users/UsersApi.d.ts +8 -1
- package/dist/apis/users/UsersApi.d.ts.map +1 -1
- package/dist/apis/users/UsersApi.mjs +8 -0
- package/dist/apis/users/UsersApi.mjs.map +1 -1
- package/dist/apis/users/types.d.ts +15 -0
- package/dist/apis/users/types.d.ts.map +1 -1
- package/dist/apis/webhooks/WebhooksApi.cjs +7 -0
- package/dist/apis/webhooks/WebhooksApi.cjs.map +1 -1
- package/dist/apis/webhooks/WebhooksApi.d.ts +7 -1
- package/dist/apis/webhooks/WebhooksApi.d.ts.map +1 -1
- package/dist/apis/webhooks/WebhooksApi.mjs +7 -0
- package/dist/apis/webhooks/WebhooksApi.mjs.map +1 -1
- package/dist/core/ApiClient.d.ts +14 -0
- package/dist/core/ApiClient.d.ts.map +1 -1
- package/dist/core/ArchivableCrudApi.cjs.map +1 -1
- package/dist/core/ArchivableCrudApi.d.ts +1 -1
- package/dist/core/ArchivableCrudApi.d.ts.map +1 -1
- package/dist/core/ArchivableCrudApi.mjs.map +1 -1
- package/dist/core/BaseApiClient.cjs +24 -3
- package/dist/core/BaseApiClient.cjs.map +1 -1
- package/dist/core/BaseApiClient.d.ts +14 -0
- package/dist/core/BaseApiClient.d.ts.map +1 -1
- package/dist/core/BaseApiClient.mjs +24 -3
- package/dist/core/BaseApiClient.mjs.map +1 -1
- package/dist/core/requestExternal.cjs +33 -0
- package/dist/core/requestExternal.cjs.map +1 -0
- package/dist/core/requestExternal.d.ts +9 -0
- package/dist/core/requestExternal.d.ts.map +1 -0
- package/dist/core/requestExternal.mjs +32 -0
- package/dist/core/requestExternal.mjs.map +1 -0
- package/package.json +1 -1
- package/src/apis/absence/AbsenceApi.ts +19 -0
- package/src/apis/acceptanceTerms/AcceptanceTermsApi.ts +13 -1
- package/src/apis/accounts/AccountsApi.ts +5 -0
- package/src/apis/accounts/types.ts +2 -0
- package/src/apis/activityLog/ActivityLogApi.ts +18 -0
- package/src/apis/categories/CategoriesApi.ts +12 -1
- package/src/apis/clientFeedback/ClientFeedbackApi.ts +5 -1
- package/src/apis/contactBlockLists/ContactBlockListsApi.ts +13 -1
- package/src/apis/contactBlockListsControls/ContactBlockListsControlsApi.ts +12 -1
- package/src/apis/contacts/ContactsApi.test.ts +20 -4
- package/src/apis/contacts/ContactsApi.ts +24 -5
- package/src/apis/contacts/types.ts +7 -1
- package/src/apis/creditMovements/CreditMovementsApi.ts +27 -0
- package/src/apis/customFields/CustomFieldsApi.ts +12 -1
- package/src/apis/departments/DepartmentsApi.test.ts +88 -0
- package/src/apis/departments/DepartmentsApi.ts +41 -2
- package/src/apis/departments/types.ts +6 -0
- package/src/apis/distribution/DistributionApi.ts +12 -1
- package/src/apis/files/FilesApi.test.ts +122 -0
- package/src/apis/files/FilesApi.ts +107 -2
- package/src/apis/files/types.ts +48 -7
- package/src/apis/holiday/HolidayApi.ts +16 -1
- package/src/apis/integrations/IntegrationsApi.ts +12 -1
- package/src/apis/interactiveMessages/InteractiveMessagesApi.ts +12 -1
- package/src/apis/interactiveMessages/types.ts +67 -1
- package/src/apis/kanbanBoards/KanbanBoardsApi.ts +12 -1
- package/src/apis/kanbanCards/KanbanCardsApi.ts +12 -1
- package/src/apis/knowledgeBase/KnowledgeBaseApi.ts +13 -1
- package/src/apis/knowledgeBaseItem/KnowledgeBaseItemApi.ts +13 -1
- package/src/apis/messages/MessagesApi.test.ts +13 -7
- package/src/apis/messages/MessagesApi.ts +29 -3
- package/src/apis/messages/types.ts +3 -0
- package/src/apis/notifications/NotificationsApi.ts +12 -1
- package/src/apis/organizations/OrganizationsApi.ts +12 -1
- package/src/apis/payloads.test-d.ts +275 -0
- package/src/apis/payloads.test.ts +41 -0
- package/src/apis/people/PeopleApi.ts +16 -1
- package/src/apis/planAiHistory/PlanAiHistoryApi.ts +26 -0
- package/src/apis/roles/RolesApi.ts +10 -1
- package/src/apis/services/ServicesApi.test.ts +45 -0
- package/src/apis/services/ServicesApi.ts +91 -1
- package/src/apis/services/types.ts +63 -1
- package/src/apis/stickers/StickersApi.ts +32 -0
- package/src/apis/tags/TagsApi.ts +16 -1
- package/src/apis/timetable/TimetableApi.ts +12 -1
- package/src/apis/users/UsersApi.ts +17 -1
- package/src/apis/users/types.ts +11 -0
- package/src/apis/webhooks/WebhooksApi.ts +16 -1
- package/src/core/ApiClient.ts +24 -0
- package/src/core/ArchivableCrudApi.ts +2 -1
- package/src/core/BaseApiClient.test.ts +98 -0
- package/src/core/BaseApiClient.ts +49 -4
- package/src/core/requestExternal.ts +43 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ApiClient } from '../../core/ApiClient'
|
|
2
|
+
import type { ListQuery } from '../../core/types'
|
|
2
3
|
import { BaseCrudApi } from '../../core/BaseCrudApi'
|
|
3
4
|
import type {
|
|
4
5
|
KnowledgeBaseItem,
|
|
@@ -9,9 +10,20 @@ import type {
|
|
|
9
10
|
export class KnowledgeBaseItemApi extends BaseCrudApi<
|
|
10
11
|
KnowledgeBaseItem,
|
|
11
12
|
CreateKnowledgeBaseItemPayload,
|
|
12
|
-
UpdateKnowledgeBaseItemPayload
|
|
13
|
+
UpdateKnowledgeBaseItemPayload,
|
|
14
|
+
ListQuery<KnowledgeBaseItem>,
|
|
15
|
+
false
|
|
13
16
|
> {
|
|
14
17
|
constructor(client: ApiClient) {
|
|
15
18
|
super(client, '/knowledge-base-item')
|
|
16
19
|
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Deletes a knowledge base item (and its documents in the AI service). Resolves `false` even when
|
|
23
|
+
* it deleted (the backend answers nothing from the deletion), so do not read it as the result:
|
|
24
|
+
* check with `getById`.
|
|
25
|
+
*/
|
|
26
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<false> {
|
|
27
|
+
return super.deleteById(id, headers)
|
|
28
|
+
}
|
|
17
29
|
}
|
|
@@ -153,18 +153,24 @@ describe('MessagesApi', () => {
|
|
|
153
153
|
// ── updateById ───────────────────────────────────────────────────
|
|
154
154
|
|
|
155
155
|
describe('updateById', () => {
|
|
156
|
-
it('calls client.
|
|
157
|
-
vi.mocked(client.
|
|
158
|
-
const
|
|
159
|
-
|
|
156
|
+
it('calls client.patch with /messages/:id and body (the backend has no PUT)', async () => {
|
|
157
|
+
vi.mocked(client.patch).mockResolvedValue(message)
|
|
158
|
+
const body = { text: 'Updated', contactId: 'ct-1', mentionedList: ['5511999999999'] }
|
|
159
|
+
const result = await api.updateById('msg-1', body)
|
|
160
|
+
expect(client.patch).toHaveBeenCalledWith('/messages/msg-1', body, undefined)
|
|
161
|
+
expect(client.put).not.toHaveBeenCalled()
|
|
160
162
|
expect(result).toEqual(message)
|
|
161
163
|
})
|
|
162
164
|
|
|
163
165
|
it('forwards custom headers', async () => {
|
|
164
|
-
vi.mocked(client.
|
|
166
|
+
vi.mocked(client.patch).mockResolvedValue(message)
|
|
165
167
|
const headers = { 'If-Match': 'etag' }
|
|
166
|
-
await api.updateById('msg-1', { text: 'x' }, headers)
|
|
167
|
-
expect(client.
|
|
168
|
+
await api.updateById('msg-1', { text: 'x', contactId: 'ct-1' }, headers)
|
|
169
|
+
expect(client.patch).toHaveBeenCalledWith(
|
|
170
|
+
'/messages/msg-1',
|
|
171
|
+
{ text: 'x', contactId: 'ct-1' },
|
|
172
|
+
headers,
|
|
173
|
+
)
|
|
168
174
|
})
|
|
169
175
|
})
|
|
170
176
|
|
|
@@ -23,6 +23,28 @@ export class MessagesApi extends BaseCrudApi<Message, CreateMessagePayload, Upda
|
|
|
23
23
|
super(client, '/messages')
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Edits the text (or the file) of a message sent by the account, up to 15 minutes after it was
|
|
28
|
+
* sent (403 `Cannot edit message` after that). `contactId` is required (without it the route
|
|
29
|
+
* answers 500), and `text` or `file` (400 without both). Sent as `PATCH /messages/:id`.
|
|
30
|
+
* @permissions messages.update
|
|
31
|
+
*/
|
|
32
|
+
override updateById(
|
|
33
|
+
id: string,
|
|
34
|
+
body: UpdateMessagePayload,
|
|
35
|
+
headers?: Record<string, string>,
|
|
36
|
+
): Promise<Message> {
|
|
37
|
+
return this.client.patch<Message, UpdateMessagePayload>(`${this.basePath}/${id}`, body, headers)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Not served: the backend has no DELETE /messages/:id, so this route answers 404.
|
|
42
|
+
* Use {@link bulkDestroy}.
|
|
43
|
+
*/
|
|
44
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<Message> {
|
|
45
|
+
return super.deleteById(id, headers)
|
|
46
|
+
}
|
|
47
|
+
|
|
26
48
|
/** Forwards one or more messages to one or more contacts (max 20 messages to 5 contacts). */
|
|
27
49
|
forward(
|
|
28
50
|
body: ForwardMessagesPayload,
|
|
@@ -102,8 +124,9 @@ export class MessagesApi extends BaseCrudApi<Message, CreateMessagePayload, Upda
|
|
|
102
124
|
}
|
|
103
125
|
|
|
104
126
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
127
|
+
* Regenerates an existing AI summary: `id` is the id of the message of `type: 'summary'`. When
|
|
128
|
+
* there is no such message (or the AI limit was reached) nothing is done and it still resolves
|
|
129
|
+
* `'OK'`. To summarize the open ticket of a contact, use `ContactsApi.summarizeTicket`.
|
|
107
130
|
*/
|
|
108
131
|
summarize(id: string, headers?: Record<string, string>): Promise<string> {
|
|
109
132
|
return this.client.post<string>(`${this.basePath}/${id}/summarize`, undefined, headers)
|
|
@@ -122,7 +145,10 @@ export class MessagesApi extends BaseCrudApi<Message, CreateMessagePayload, Upda
|
|
|
122
145
|
)
|
|
123
146
|
}
|
|
124
147
|
|
|
125
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Re-downloads and syncs the file attachment for a message from the messaging service. Resolves
|
|
150
|
+
* what the driver answers; an unknown message answers 500.
|
|
151
|
+
*/
|
|
126
152
|
syncFile(id: string, headers?: Record<string, string>): Promise<unknown> {
|
|
127
153
|
return this.client.post<unknown>(`${this.basePath}/${id}/sync-file`, undefined, headers)
|
|
128
154
|
}
|
|
@@ -203,7 +203,10 @@ export type UpdateMessagePayload = {
|
|
|
203
203
|
text?: string
|
|
204
204
|
file?: unknown
|
|
205
205
|
fileId?: string
|
|
206
|
+
/** Required by the backend (500 without it), although optional here for compatibility. */
|
|
206
207
|
contactId?: string
|
|
208
|
+
/** `idFromService` of the contacts mentioned in a group message. */
|
|
209
|
+
mentionedList?: string[]
|
|
207
210
|
number?: string
|
|
208
211
|
origin?: 'user' | 'bot'
|
|
209
212
|
hsm?: unknown
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import type { ApiClient } from '../../core/ApiClient'
|
|
2
|
+
import type { ListQuery } from '../../core/types'
|
|
2
3
|
import { BaseCrudApi } from '../../core/BaseCrudApi'
|
|
3
4
|
import type { Notification, CreateNotificationPayload, UpdateNotificationPayload } from './types'
|
|
4
5
|
|
|
5
6
|
export class NotificationsApi extends BaseCrudApi<
|
|
6
7
|
Notification,
|
|
7
8
|
CreateNotificationPayload,
|
|
8
|
-
UpdateNotificationPayload
|
|
9
|
+
UpdateNotificationPayload,
|
|
10
|
+
ListQuery<Notification>,
|
|
11
|
+
'OK'
|
|
9
12
|
> {
|
|
10
13
|
constructor(client: ApiClient) {
|
|
11
14
|
super(client, '/notifications')
|
|
12
15
|
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Deletes a notification. Resolves the text `'OK'`; an unknown id answers 500. The route checks
|
|
19
|
+
* no permission.
|
|
20
|
+
*/
|
|
21
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {
|
|
22
|
+
return super.deleteById(id, headers)
|
|
23
|
+
}
|
|
13
24
|
}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import type { ApiClient } from '../../core/ApiClient'
|
|
2
|
+
import type { ListQuery } from '../../core/types'
|
|
2
3
|
import { BaseCrudApi } from '../../core/BaseCrudApi'
|
|
3
4
|
import type { Organization, CreateOrganizationPayload, UpdateOrganizationPayload } from './types'
|
|
4
5
|
|
|
5
6
|
export class OrganizationsApi extends BaseCrudApi<
|
|
6
7
|
Organization,
|
|
7
8
|
CreateOrganizationPayload,
|
|
8
|
-
UpdateOrganizationPayload
|
|
9
|
+
UpdateOrganizationPayload,
|
|
10
|
+
ListQuery<Organization>,
|
|
11
|
+
'OK'
|
|
9
12
|
> {
|
|
10
13
|
constructor(client: ApiClient) {
|
|
11
14
|
super(client, '/organizations')
|
|
12
15
|
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Deletes an organization. Resolves the text `'OK'`.
|
|
19
|
+
* @permissions organizations.view OR organizations.destroy
|
|
20
|
+
*/
|
|
21
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {
|
|
22
|
+
return super.deleteById(id, headers)
|
|
23
|
+
}
|
|
13
24
|
}
|
|
@@ -17,6 +17,13 @@ import type {
|
|
|
17
17
|
} from './campaigns/types'
|
|
18
18
|
import { CardsApi } from './cards/CardsApi'
|
|
19
19
|
import { ContactsApi } from './contacts/ContactsApi'
|
|
20
|
+
import { InteractiveMessagesApi } from './interactiveMessages/InteractiveMessagesApi'
|
|
21
|
+
import type {
|
|
22
|
+
ChannelRedirect,
|
|
23
|
+
CtaUrlInteractiveMessageContent,
|
|
24
|
+
InteractiveMessage,
|
|
25
|
+
RequestContactInfoInteractiveMessageContent,
|
|
26
|
+
} from './interactiveMessages'
|
|
20
27
|
import { KanbanColumnsApi } from './kanbanColumns/KanbanColumnsApi'
|
|
21
28
|
import { PipelineApi } from './pipeline/PipelineApi'
|
|
22
29
|
import type { PermissionName } from './permissions/types'
|
|
@@ -26,6 +33,12 @@ import { QuickRepliesApi } from './quickReplies/QuickRepliesApi'
|
|
|
26
33
|
import { RolesApi } from './roles/RolesApi'
|
|
27
34
|
import { ScheduleApi } from './schedule/ScheduleApi'
|
|
28
35
|
import type { ScheduleRecord } from './schedule/types'
|
|
36
|
+
import type {
|
|
37
|
+
CreateServicePayload,
|
|
38
|
+
Service,
|
|
39
|
+
UpdateServicePayload,
|
|
40
|
+
WebchatServiceData,
|
|
41
|
+
} from './services'
|
|
29
42
|
import { TagsApi } from './tags/TagsApi'
|
|
30
43
|
import { TicketTopicsApi } from './ticketTopics/TicketTopicsApi'
|
|
31
44
|
import { TicketsApi } from './tickets/TicketsApi'
|
|
@@ -33,6 +46,31 @@ import type { Ticket, TicketTransfer, TicketsCount, TicketsCounts } from './tick
|
|
|
33
46
|
import { TimetableApi } from './timetable/TimetableApi'
|
|
34
47
|
import { UsersApi } from './users/UsersApi'
|
|
35
48
|
|
|
49
|
+
import { AcceptanceTermsApi } from './acceptanceTerms/AcceptanceTermsApi'
|
|
50
|
+
import { CategoriesApi } from './categories/CategoriesApi'
|
|
51
|
+
import { ContactBlockListsApi } from './contactBlockLists/ContactBlockListsApi'
|
|
52
|
+
import { ContactBlockListsControlsApi } from './contactBlockListsControls/ContactBlockListsControlsApi'
|
|
53
|
+
import type { SummarizeTicketResult } from './contacts/types'
|
|
54
|
+
import { CustomFieldsApi } from './customFields/CustomFieldsApi'
|
|
55
|
+
import { DepartmentsApi } from './departments/DepartmentsApi'
|
|
56
|
+
import type { Department } from './departments/types'
|
|
57
|
+
import { DistributionApi } from './distribution/DistributionApi'
|
|
58
|
+
import { FilesApi } from './files/FilesApi'
|
|
59
|
+
import type { CreateToUploadResult, DeleteFileResult, File } from './files/types'
|
|
60
|
+
import { HolidayApi } from './holiday/HolidayApi'
|
|
61
|
+
import { IntegrationsApi } from './integrations/IntegrationsApi'
|
|
62
|
+
import { KanbanBoardsApi } from './kanbanBoards/KanbanBoardsApi'
|
|
63
|
+
import { KanbanCardsApi } from './kanbanCards/KanbanCardsApi'
|
|
64
|
+
import { KnowledgeBaseApi } from './knowledgeBase/KnowledgeBaseApi'
|
|
65
|
+
import { KnowledgeBaseItemApi } from './knowledgeBaseItem/KnowledgeBaseItemApi'
|
|
66
|
+
import { MessagesApi } from './messages/MessagesApi'
|
|
67
|
+
import { NotificationsApi } from './notifications/NotificationsApi'
|
|
68
|
+
import { OrganizationsApi } from './organizations/OrganizationsApi'
|
|
69
|
+
import { PeopleApi } from './people/PeopleApi'
|
|
70
|
+
import { ServicesApi } from './services/ServicesApi'
|
|
71
|
+
import type { UpdateUserPayload } from './users/types'
|
|
72
|
+
import { WebhooksApi } from './webhooks/WebhooksApi'
|
|
73
|
+
|
|
36
74
|
declare const client: ApiClient
|
|
37
75
|
|
|
38
76
|
// ── roles: the backend drops `permissionIds` in silence ─────────────
|
|
@@ -67,6 +105,154 @@ expectError(tokens.create({ name: 'CI', accessTokenExpiresAt: '2030-01-01T00:00:
|
|
|
67
105
|
expectError(tokens.create({ name: 'CI', expiresIn: '7d' }))
|
|
68
106
|
expectError(tokens.updateById('t-1', { scope: '*' }))
|
|
69
107
|
|
|
108
|
+
// ── interactive messages: cta_url and request_contact_info ──────────
|
|
109
|
+
|
|
110
|
+
const interactiveMessages = new InteractiveMessagesApi(client)
|
|
111
|
+
interactiveMessages.create({
|
|
112
|
+
name: 'Boleto',
|
|
113
|
+
interactive: {
|
|
114
|
+
type: 'cta_url',
|
|
115
|
+
header: { type: 'text', text: 'Seu boleto' },
|
|
116
|
+
body: { text: 'Clique para continuar' },
|
|
117
|
+
footer: { text: 'Digisac' },
|
|
118
|
+
action: {
|
|
119
|
+
name: 'cta_url',
|
|
120
|
+
parameters: { display_text: 'Continuar', url: 'https://wa.me/5541999999999' },
|
|
121
|
+
},
|
|
122
|
+
channelRedirect: {
|
|
123
|
+
enabled: true,
|
|
124
|
+
channel: 'whatsapp',
|
|
125
|
+
identifierType: 'phone',
|
|
126
|
+
identifier: '+5541999999999',
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
interactiveMessages.create({
|
|
131
|
+
name: 'Webchat',
|
|
132
|
+
interactive: {
|
|
133
|
+
type: 'cta_url',
|
|
134
|
+
header: { type: 'image' },
|
|
135
|
+
body: { text: 'Fale conosco' },
|
|
136
|
+
action: {
|
|
137
|
+
name: 'cta_url',
|
|
138
|
+
parameters: { display_text: 'Abrir', url: 'https://webchat.digisac.app/w-1' },
|
|
139
|
+
},
|
|
140
|
+
channelRedirect: { enabled: true, channel: 'webchat', serviceId: 's-1' },
|
|
141
|
+
},
|
|
142
|
+
})
|
|
143
|
+
interactiveMessages.updateById('im-1', {
|
|
144
|
+
interactive: {
|
|
145
|
+
type: 'cta_url',
|
|
146
|
+
body: { text: 'Site' },
|
|
147
|
+
action: { name: 'cta_url', parameters: { display_text: 'Abrir', url: 'https://exemplo.com' } },
|
|
148
|
+
},
|
|
149
|
+
})
|
|
150
|
+
interactiveMessages.create({
|
|
151
|
+
name: 'Dados',
|
|
152
|
+
interactive: {
|
|
153
|
+
type: 'request_contact_info',
|
|
154
|
+
body: { text: 'Compartilhe seu contato' },
|
|
155
|
+
action: { name: 'request_contact_info' },
|
|
156
|
+
},
|
|
157
|
+
})
|
|
158
|
+
// `channelRedirect` is a sibling of `action`, never inside `action.parameters`
|
|
159
|
+
expectError(
|
|
160
|
+
interactiveMessages.create({
|
|
161
|
+
name: 'Boleto',
|
|
162
|
+
interactive: {
|
|
163
|
+
type: 'cta_url',
|
|
164
|
+
body: { text: 'Clique' },
|
|
165
|
+
action: {
|
|
166
|
+
name: 'cta_url',
|
|
167
|
+
parameters: {
|
|
168
|
+
display_text: 'Continuar',
|
|
169
|
+
url: 'https://wa.me/5541999999999',
|
|
170
|
+
channelRedirect: { enabled: true },
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
}),
|
|
175
|
+
)
|
|
176
|
+
expectError(
|
|
177
|
+
interactiveMessages.create({
|
|
178
|
+
name: 'Boleto',
|
|
179
|
+
interactive: {
|
|
180
|
+
type: 'cta_url',
|
|
181
|
+
body: { text: 'Clique' },
|
|
182
|
+
action: { name: 'cta_url', parameters: { url: 'https://exemplo.com' } },
|
|
183
|
+
},
|
|
184
|
+
}),
|
|
185
|
+
)
|
|
186
|
+
expectError(
|
|
187
|
+
interactiveMessages.create({
|
|
188
|
+
name: 'Boleto',
|
|
189
|
+
interactive: {
|
|
190
|
+
type: 'cta_url',
|
|
191
|
+
body: { text: 'Clique' },
|
|
192
|
+
action: { name: 'cta_url', parameters: { display_text: 'Abrir', url: 'https://x.com' } },
|
|
193
|
+
channelRedirect: { enabled: true, channel: 'email' },
|
|
194
|
+
},
|
|
195
|
+
}),
|
|
196
|
+
)
|
|
197
|
+
// WhatsApp refuses header and footer on request_contact_info
|
|
198
|
+
expectError(
|
|
199
|
+
interactiveMessages.create({
|
|
200
|
+
name: 'Dados',
|
|
201
|
+
interactive: {
|
|
202
|
+
type: 'request_contact_info',
|
|
203
|
+
header: { type: 'text', text: 'Olá' },
|
|
204
|
+
body: { text: 'Compartilhe seu contato' },
|
|
205
|
+
action: { name: 'request_contact_info' },
|
|
206
|
+
},
|
|
207
|
+
}),
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
declare const interactiveMessage: InteractiveMessage
|
|
211
|
+
expectType<'list' | 'button' | 'cta_url' | 'request_contact_info'>(interactiveMessage.type)
|
|
212
|
+
if (interactiveMessage.interactive.type === 'cta_url') {
|
|
213
|
+
expectType<CtaUrlInteractiveMessageContent>(interactiveMessage.interactive)
|
|
214
|
+
expectType<string>(interactiveMessage.interactive.action.parameters.url)
|
|
215
|
+
expectType<ChannelRedirect | undefined>(interactiveMessage.interactive.channelRedirect)
|
|
216
|
+
}
|
|
217
|
+
if (interactiveMessage.interactive.type === 'request_contact_info') {
|
|
218
|
+
expectType<RequestContactInfoInteractiveMessageContent>(interactiveMessage.interactive)
|
|
219
|
+
}
|
|
220
|
+
expectAssignable<ChannelRedirect>({ enabled: false })
|
|
221
|
+
expectAssignable<ChannelRedirect>({
|
|
222
|
+
enabled: true,
|
|
223
|
+
channel: 'telegram',
|
|
224
|
+
identifierType: 'botName',
|
|
225
|
+
identifier: '@lojabot',
|
|
226
|
+
})
|
|
227
|
+
expectNotAssignable<ChannelRedirect>({ enabled: true, channel: 'telegram', identifierType: 'user' })
|
|
228
|
+
expectNotAssignable<ChannelRedirect>({ channel: 'whatsapp' })
|
|
229
|
+
|
|
230
|
+
// ── services: data.webchat of a Webchat service ─────────────────────
|
|
231
|
+
|
|
232
|
+
declare const service: Service
|
|
233
|
+
expectType<WebchatServiceData | undefined>(service.data.webchat)
|
|
234
|
+
expectType<string | undefined>(service.data.webchat?.id)
|
|
235
|
+
expectType<string | null | undefined>(service.data.webchat?.instagram)
|
|
236
|
+
expectAssignable<WebchatServiceData>({})
|
|
237
|
+
expectAssignable<WebchatServiceData>({ id: 'w-1', phone: '5541999999999', telegram: null })
|
|
238
|
+
expectNotAssignable<WebchatServiceData>({ id: 1 })
|
|
239
|
+
// values the web forms already store: the new form sends `null`, the legacy one `{}`
|
|
240
|
+
expectType<{ id?: string; name?: string } | null | undefined>(service.data.webchat?.customField)
|
|
241
|
+
expectAssignable<WebchatServiceData>({ customField: null })
|
|
242
|
+
expectAssignable<WebchatServiceData>({ customField: {} })
|
|
243
|
+
expectAssignable<WebchatServiceData>({ customField: { id: 'cf-1', name: 'CPF' } })
|
|
244
|
+
expectAssignable<WebchatServiceData>({ name: null, googleId: null, file: {} })
|
|
245
|
+
expectAssignable<WebchatServiceData>({
|
|
246
|
+
file: { base64Url: 'aGVsbG8=', mimetype: 'image/png', fileName: 'perfil.png' },
|
|
247
|
+
})
|
|
248
|
+
expectAssignable<WebchatServiceData>({ custom: { webchatBalloonText: null } })
|
|
249
|
+
expectNotAssignable<WebchatServiceData>({ customField: 'cf-1' })
|
|
250
|
+
// the same shape types the `data` of the create and update payloads
|
|
251
|
+
expectAssignable<CreateServicePayload['data']>({
|
|
252
|
+
webchat: { customField: null, googleId: null, name: null, custom: { webchatBalloonText: null } },
|
|
253
|
+
})
|
|
254
|
+
expectAssignable<UpdateServicePayload['data']>({ webchat: { customField: {}, file: {} } })
|
|
255
|
+
|
|
70
256
|
// ── users: the dedicated archive route takes a boolean, not a date ──
|
|
71
257
|
|
|
72
258
|
const users = new UsersApi(client)
|
|
@@ -336,3 +522,92 @@ expectType<number | string | undefined>(listed.config.minInterval)
|
|
|
336
522
|
expectType<CampaignMessage[] | undefined>(listed.messages)
|
|
337
523
|
declare const campaignContact: CampaignContact
|
|
338
524
|
expectType<string | null>(campaignContact.contactNumber)
|
|
525
|
+
|
|
526
|
+
// ── deleteById: what each route really answers ───────────────────────
|
|
527
|
+
|
|
528
|
+
expectType<Promise<'OK'>>(new DepartmentsApi(client).deleteById('d-1'))
|
|
529
|
+
expectType<Promise<'OK'>>(new UsersApi(client).deleteById('u-1'))
|
|
530
|
+
expectType<Promise<'OK'>>(new TagsApi(client).deleteById('t-1'))
|
|
531
|
+
expectType<Promise<'OK'>>(new KanbanBoardsApi(client).deleteById('b-1'))
|
|
532
|
+
expectType<Promise<'OK'>>(new KanbanCardsApi(client).deleteById('c-1'))
|
|
533
|
+
expectType<Promise<'OK'>>(new WebhooksApi(client).deleteById('w-1'))
|
|
534
|
+
expectType<Promise<'OK'>>(new CategoriesApi(client).deleteById('c-1'))
|
|
535
|
+
expectType<Promise<'OK'>>(new IntegrationsApi(client).deleteById('i-1'))
|
|
536
|
+
expectType<Promise<'OK'>>(new InteractiveMessagesApi(client).deleteById('i-1'))
|
|
537
|
+
expectType<Promise<'OK'>>(new NotificationsApi(client).deleteById('n-1'))
|
|
538
|
+
expectType<Promise<'OK'>>(new CustomFieldsApi(client).deleteById('f-1'))
|
|
539
|
+
expectType<Promise<'OK'>>(new HolidayApi(client).deleteById('h-1'))
|
|
540
|
+
expectType<Promise<'OK'>>(new PeopleApi(client).deleteById('p-1'))
|
|
541
|
+
expectType<Promise<'OK'>>(new OrganizationsApi(client).deleteById('o-1'))
|
|
542
|
+
expectType<Promise<'OK'>>(new TimetableApi(client).deleteById('t-1'))
|
|
543
|
+
expectType<Promise<'OK'>>(new ContactBlockListsApi(client).deleteById('l-1'))
|
|
544
|
+
expectType<Promise<'OK'>>(new ContactBlockListsControlsApi(client).deleteById('c-1'))
|
|
545
|
+
expectType<Promise<boolean>>(new RolesApi(client).deleteById('r-1'))
|
|
546
|
+
expectType<Promise<void>>(new AcceptanceTermsApi(client).deleteById('t-1'))
|
|
547
|
+
expectType<Promise<void>>(new DistributionApi(client).deleteById('d-1'))
|
|
548
|
+
expectType<Promise<false>>(new KnowledgeBaseApi(client).deleteById('k-1'))
|
|
549
|
+
expectType<Promise<false>>(new KnowledgeBaseItemApi(client).deleteById('k-1'))
|
|
550
|
+
expectType<Promise<DeleteFileResult>>(new FilesApi(client).deleteById('f-1'))
|
|
551
|
+
|
|
552
|
+
// ── services: archive through POST /:id/archive, with the type ───────
|
|
553
|
+
|
|
554
|
+
const services = new ServicesApi(client)
|
|
555
|
+
expectType<Promise<Record<string, never>>>(
|
|
556
|
+
services.archiveWithValidation('s-1', { archive: true, type: 'sms-wavy' }),
|
|
557
|
+
)
|
|
558
|
+
expectError(services.archiveWithValidation('s-1', { archive: true }))
|
|
559
|
+
expectType<Promise<'OK'>>(services.takeover('s-1'))
|
|
560
|
+
expectType<Promise<'OK'>>(services.logout('s-1'))
|
|
561
|
+
expectType<Promise<'OK'>>(services.shutdown('s-1'))
|
|
562
|
+
expectType<Promise<'OK'>>(services.start('s-1'))
|
|
563
|
+
expectType<Promise<'OK'>>(services.restart('s-1'))
|
|
564
|
+
expectAssignable<UpdateServicePayload>({ type: 'whatsapp', name: 'x', archivedAt: null })
|
|
565
|
+
|
|
566
|
+
// ── contacts, departments, messages, users ──────────────────────────
|
|
567
|
+
|
|
568
|
+
const contactsApi = new ContactsApi(client)
|
|
569
|
+
expectType<Promise<SummarizeTicketResult>>(contactsApi.summarizeTicket('c-1'))
|
|
570
|
+
expectType<Promise<string>>(contactsApi.exportTemplate({ serviceType: 'whatsapp' }))
|
|
571
|
+
expectType<Promise<Department>>(
|
|
572
|
+
new DepartmentsApi(client).archiveWithValidation('d-1', { archive: true }),
|
|
573
|
+
)
|
|
574
|
+
expectError(new DepartmentsApi(client).archiveWithValidation('d-1', {}))
|
|
575
|
+
new MessagesApi(client).updateById('m-1', { text: 'x', contactId: 'c-1', mentionedList: ['5511'] })
|
|
576
|
+
expectAssignable<UpdateUserPayload>({ restrictedServices: [{ value: 's-1' }], password: 'x' })
|
|
577
|
+
expectNotAssignable<UpdateUserPayload>({ restrictedServices: ['s-1'] })
|
|
578
|
+
|
|
579
|
+
// ── files: upload through a signed URL ──────────────────────────────
|
|
580
|
+
|
|
581
|
+
const files = new FilesApi(client)
|
|
582
|
+
expectType<Promise<CreateToUploadResult>>(
|
|
583
|
+
files.createToUpload({ name: 'a.txt', mimetype: 'text/plain' }),
|
|
584
|
+
)
|
|
585
|
+
expectError(files.createToUpload({ name: 'a.txt' }))
|
|
586
|
+
expectType<Promise<void>>(files.upload('https://storage/x', 'content', 'text/plain'))
|
|
587
|
+
expectAssignable<File>({
|
|
588
|
+
id: 'f-1',
|
|
589
|
+
url: 'https://x',
|
|
590
|
+
name: 'a.txt',
|
|
591
|
+
publicFilename: 'f-1.txt',
|
|
592
|
+
checksum: null,
|
|
593
|
+
mimetype: 'text/plain',
|
|
594
|
+
extension: 'txt',
|
|
595
|
+
data: {},
|
|
596
|
+
accountId: 'a-1',
|
|
597
|
+
createdAt: '2026-01-01T00:00:00Z',
|
|
598
|
+
updatedAt: '2026-01-01T00:00:00Z',
|
|
599
|
+
})
|
|
600
|
+
|
|
601
|
+
// ── a custom ApiClient without requestRaw is still an ApiClient ──────
|
|
602
|
+
|
|
603
|
+
expectAssignable<ApiClient>({
|
|
604
|
+
setAccessToken() {
|
|
605
|
+
return this
|
|
606
|
+
},
|
|
607
|
+
request: async <T>() => undefined as T,
|
|
608
|
+
get: async <T>() => undefined as T,
|
|
609
|
+
post: async <T>() => undefined as T,
|
|
610
|
+
put: async <T>() => undefined as T,
|
|
611
|
+
patch: async <T>() => undefined as T,
|
|
612
|
+
delete: async <T>() => undefined as T,
|
|
613
|
+
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
2
|
import type { ApiClient } from '../core/ApiClient'
|
|
3
|
+
import { InteractiveMessagesApi } from './interactiveMessages/InteractiveMessagesApi'
|
|
3
4
|
import { PersonalAccessTokensApi } from './personalAccessTokens/PersonalAccessTokensApi'
|
|
4
5
|
import { RolesApi } from './roles/RolesApi'
|
|
5
6
|
import { TimetableApi } from './timetable/TimetableApi'
|
|
@@ -78,4 +79,44 @@ describe('payloads sent to the backend', () => {
|
|
|
78
79
|
)
|
|
79
80
|
})
|
|
80
81
|
})
|
|
82
|
+
|
|
83
|
+
describe('InteractiveMessagesApi', () => {
|
|
84
|
+
it('create sends a cta_url with channelRedirect next to action, not inside parameters', async () => {
|
|
85
|
+
const body = {
|
|
86
|
+
name: 'Boleto',
|
|
87
|
+
departments: [{ id: 'd-1' }],
|
|
88
|
+
interactive: {
|
|
89
|
+
type: 'cta_url' as const,
|
|
90
|
+
header: { type: 'text' as const, text: 'Seu boleto' },
|
|
91
|
+
body: { text: 'Clique para continuar' },
|
|
92
|
+
footer: { text: 'Digisac' },
|
|
93
|
+
action: {
|
|
94
|
+
name: 'cta_url' as const,
|
|
95
|
+
parameters: { display_text: 'Continuar', url: 'https://wa.me/5541999999999' },
|
|
96
|
+
},
|
|
97
|
+
channelRedirect: {
|
|
98
|
+
enabled: true,
|
|
99
|
+
channel: 'whatsapp' as const,
|
|
100
|
+
identifierType: 'phone' as const,
|
|
101
|
+
identifier: '+5541999999999',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
await new InteractiveMessagesApi(client).create(body)
|
|
106
|
+
expect(client.post).toHaveBeenCalledWith('/interactive-messages', body, undefined)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('create sends a request_contact_info with only body and action', async () => {
|
|
110
|
+
const body = {
|
|
111
|
+
name: 'Dados',
|
|
112
|
+
interactive: {
|
|
113
|
+
type: 'request_contact_info' as const,
|
|
114
|
+
body: { text: 'Compartilhe seu contato' },
|
|
115
|
+
action: { name: 'request_contact_info' as const },
|
|
116
|
+
},
|
|
117
|
+
}
|
|
118
|
+
await new InteractiveMessagesApi(client).create(body)
|
|
119
|
+
expect(client.post).toHaveBeenCalledWith('/interactive-messages', body, undefined)
|
|
120
|
+
})
|
|
121
|
+
})
|
|
81
122
|
})
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import type { ApiClient } from '../../core/ApiClient'
|
|
2
|
+
import type { ListQuery } from '../../core/types'
|
|
2
3
|
import { BaseCrudApi } from '../../core/BaseCrudApi'
|
|
3
4
|
import type { Person, CreatePersonPayload, UpdatePersonPayload } from './types'
|
|
4
5
|
|
|
5
|
-
export class PeopleApi extends BaseCrudApi<
|
|
6
|
+
export class PeopleApi extends BaseCrudApi<
|
|
7
|
+
Person,
|
|
8
|
+
CreatePersonPayload,
|
|
9
|
+
UpdatePersonPayload,
|
|
10
|
+
ListQuery<Person>,
|
|
11
|
+
'OK'
|
|
12
|
+
> {
|
|
6
13
|
constructor(client: ApiClient) {
|
|
7
14
|
super(client, '/people')
|
|
8
15
|
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Deletes a person. Resolves the text `'OK'`.
|
|
19
|
+
* @permissions people.view OR people.destroy
|
|
20
|
+
*/
|
|
21
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {
|
|
22
|
+
return super.deleteById(id, headers)
|
|
23
|
+
}
|
|
9
24
|
}
|
|
@@ -2,6 +2,10 @@ import type { ApiClient } from '../../core/ApiClient'
|
|
|
2
2
|
import { BaseCrudApi } from '../../core/BaseCrudApi'
|
|
3
3
|
import type { PlanAiHistory, CreatePlanAiHistoryPayload, UpdatePlanAiHistoryPayload } from './types'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* History of the AI products of the plan, only for reading: the records are written by super admin
|
|
7
|
+
* actions. The backend serves only `GET /plan-ai-history` and `GET /plan-ai-history/:id`.
|
|
8
|
+
*/
|
|
5
9
|
export class PlanAiHistoryApi extends BaseCrudApi<
|
|
6
10
|
PlanAiHistory,
|
|
7
11
|
CreatePlanAiHistoryPayload,
|
|
@@ -10,4 +14,26 @@ export class PlanAiHistoryApi extends BaseCrudApi<
|
|
|
10
14
|
constructor(client: ApiClient) {
|
|
11
15
|
super(client, '/plan-ai-history')
|
|
12
16
|
}
|
|
17
|
+
|
|
18
|
+
/** @deprecated Not served: the backend has no POST /plan-ai-history, so this route answers 404. */
|
|
19
|
+
override create(
|
|
20
|
+
body: CreatePlanAiHistoryPayload,
|
|
21
|
+
headers?: Record<string, string>,
|
|
22
|
+
): Promise<PlanAiHistory> {
|
|
23
|
+
return super.create(body, headers)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** @deprecated Not served: the backend has no PUT /plan-ai-history/:id, so this route answers 404. */
|
|
27
|
+
override updateById(
|
|
28
|
+
id: string,
|
|
29
|
+
body: UpdatePlanAiHistoryPayload,
|
|
30
|
+
headers?: Record<string, string>,
|
|
31
|
+
): Promise<PlanAiHistory> {
|
|
32
|
+
return super.updateById(id, body, headers)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** @deprecated Not served: the backend has no DELETE /plan-ai-history/:id, so this route answers 404. */
|
|
36
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<PlanAiHistory> {
|
|
37
|
+
return super.deleteById(id, headers)
|
|
38
|
+
}
|
|
13
39
|
}
|
|
@@ -6,9 +6,18 @@ export class RolesApi extends BaseCrudApi<
|
|
|
6
6
|
Role,
|
|
7
7
|
CreateRolePayload,
|
|
8
8
|
UpdateRolePayload,
|
|
9
|
-
RolesListQuery
|
|
9
|
+
RolesListQuery,
|
|
10
|
+
boolean
|
|
10
11
|
> {
|
|
11
12
|
constructor(client: ApiClient) {
|
|
12
13
|
super(client, '/roles')
|
|
13
14
|
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Deletes a role. Resolves `true`.
|
|
18
|
+
* @permissions roles.destroy
|
|
19
|
+
*/
|
|
20
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<boolean> {
|
|
21
|
+
return super.deleteById(id, headers)
|
|
22
|
+
}
|
|
14
23
|
}
|
|
@@ -46,4 +46,49 @@ describe('ServicesApi', () => {
|
|
|
46
46
|
expect(client.get).toHaveBeenCalledWith('/services/limits', headers)
|
|
47
47
|
})
|
|
48
48
|
})
|
|
49
|
+
|
|
50
|
+
describe('archiveWithValidation', () => {
|
|
51
|
+
it('calls client.post with /services/:id/archive, the archive flag and the type', async () => {
|
|
52
|
+
vi.mocked(client.post).mockResolvedValue({})
|
|
53
|
+
const result = await api.archiveWithValidation('svc-1', { archive: true, type: 'sms-wavy' })
|
|
54
|
+
expect(client.post).toHaveBeenCalledWith(
|
|
55
|
+
'/services/svc-1/archive',
|
|
56
|
+
{ archive: true, type: 'sms-wavy' },
|
|
57
|
+
undefined,
|
|
58
|
+
)
|
|
59
|
+
expect(result).toEqual({})
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('restores with { archive: false } and forwards custom headers', async () => {
|
|
63
|
+
const headers = { 'X-Custom': 'value' }
|
|
64
|
+
await api.archiveWithValidation('svc-1', { archive: false, type: 'whatsapp' }, headers)
|
|
65
|
+
expect(client.post).toHaveBeenCalledWith(
|
|
66
|
+
'/services/svc-1/archive',
|
|
67
|
+
{ archive: false, type: 'whatsapp' },
|
|
68
|
+
headers,
|
|
69
|
+
)
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
describe.each(['takeover', 'logout', 'shutdown', 'start', 'restart'] as const)(
|
|
74
|
+
'%s',
|
|
75
|
+
(operation) => {
|
|
76
|
+
it(`calls client.post with /services/:id/${operation} and resolves 'OK'`, async () => {
|
|
77
|
+
vi.mocked(client.post).mockResolvedValue('OK')
|
|
78
|
+
const result = await api[operation]('svc-1')
|
|
79
|
+
expect(client.post).toHaveBeenCalledWith(
|
|
80
|
+
`/services/svc-1/${operation}`,
|
|
81
|
+
undefined,
|
|
82
|
+
undefined,
|
|
83
|
+
)
|
|
84
|
+
expect(result).toBe('OK')
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('forwards custom headers', async () => {
|
|
88
|
+
const headers = { 'X-Custom': 'value' }
|
|
89
|
+
await api[operation]('svc-1', headers)
|
|
90
|
+
expect(client.post).toHaveBeenCalledWith(`/services/svc-1/${operation}`, undefined, headers)
|
|
91
|
+
})
|
|
92
|
+
},
|
|
93
|
+
)
|
|
49
94
|
})
|