@ikatec/digisac-api-sdk 4.15.0 → 4.17.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.
Files changed (189) hide show
  1. package/README.md +3 -1
  2. package/dist/apis/absence/AbsenceApi.cjs +2 -2
  3. package/dist/apis/absence/AbsenceApi.cjs.map +1 -1
  4. package/dist/apis/absence/AbsenceApi.d.ts +2 -2
  5. package/dist/apis/absence/AbsenceApi.mjs +2 -2
  6. package/dist/apis/absence/AbsenceApi.mjs.map +1 -1
  7. package/dist/apis/absence/types.d.ts +1 -1
  8. package/dist/apis/answers/AnswersApi.cjs +23 -2
  9. package/dist/apis/answers/AnswersApi.cjs.map +1 -1
  10. package/dist/apis/answers/AnswersApi.d.ts +16 -2
  11. package/dist/apis/answers/AnswersApi.d.ts.map +1 -1
  12. package/dist/apis/answers/AnswersApi.mjs +23 -2
  13. package/dist/apis/answers/AnswersApi.mjs.map +1 -1
  14. package/dist/apis/answers/types.d.ts +1 -2
  15. package/dist/apis/answers/types.d.ts.map +1 -1
  16. package/dist/apis/bots/BotsApi.cjs +16 -7
  17. package/dist/apis/bots/BotsApi.cjs.map +1 -1
  18. package/dist/apis/bots/BotsApi.d.ts +13 -7
  19. package/dist/apis/bots/BotsApi.d.ts.map +1 -1
  20. package/dist/apis/bots/BotsApi.mjs +16 -7
  21. package/dist/apis/bots/BotsApi.mjs.map +1 -1
  22. package/dist/apis/bots/types.d.ts +12 -2
  23. package/dist/apis/bots/types.d.ts.map +1 -1
  24. package/dist/apis/campaigns/CampaignsApi.cjs +25 -1
  25. package/dist/apis/campaigns/CampaignsApi.cjs.map +1 -1
  26. package/dist/apis/campaigns/CampaignsApi.d.ts +16 -1
  27. package/dist/apis/campaigns/CampaignsApi.d.ts.map +1 -1
  28. package/dist/apis/campaigns/CampaignsApi.mjs +25 -1
  29. package/dist/apis/campaigns/CampaignsApi.mjs.map +1 -1
  30. package/dist/apis/campaigns/types.d.ts +98 -6
  31. package/dist/apis/campaigns/types.d.ts.map +1 -1
  32. package/dist/apis/cards/types.d.ts +5 -5
  33. package/dist/apis/categories/CategoriesApi.cjs +1 -2
  34. package/dist/apis/categories/CategoriesApi.cjs.map +1 -1
  35. package/dist/apis/categories/CategoriesApi.d.ts +1 -2
  36. package/dist/apis/categories/CategoriesApi.d.ts.map +1 -1
  37. package/dist/apis/categories/CategoriesApi.mjs +1 -2
  38. package/dist/apis/categories/CategoriesApi.mjs.map +1 -1
  39. package/dist/apis/clientFeedback/ClientFeedbackApi.cjs +2 -3
  40. package/dist/apis/clientFeedback/ClientFeedbackApi.cjs.map +1 -1
  41. package/dist/apis/clientFeedback/ClientFeedbackApi.d.ts +2 -3
  42. package/dist/apis/clientFeedback/ClientFeedbackApi.d.ts.map +1 -1
  43. package/dist/apis/clientFeedback/ClientFeedbackApi.mjs +2 -3
  44. package/dist/apis/clientFeedback/ClientFeedbackApi.mjs.map +1 -1
  45. package/dist/apis/contacts/ContactsApi.cjs +10 -6
  46. package/dist/apis/contacts/ContactsApi.cjs.map +1 -1
  47. package/dist/apis/contacts/ContactsApi.d.ts +19 -3
  48. package/dist/apis/contacts/ContactsApi.d.ts.map +1 -1
  49. package/dist/apis/contacts/ContactsApi.mjs +10 -6
  50. package/dist/apis/contacts/ContactsApi.mjs.map +1 -1
  51. package/dist/apis/contacts/types.d.ts +25 -0
  52. package/dist/apis/contacts/types.d.ts.map +1 -1
  53. package/dist/apis/customFields/types.d.ts +4 -4
  54. package/dist/apis/dashboard/DashboardApi.cjs +3 -3
  55. package/dist/apis/dashboard/DashboardApi.cjs.map +1 -1
  56. package/dist/apis/dashboard/DashboardApi.d.ts +3 -3
  57. package/dist/apis/dashboard/DashboardApi.mjs +3 -3
  58. package/dist/apis/dashboard/DashboardApi.mjs.map +1 -1
  59. package/dist/apis/dashboard/types.d.ts +11 -4
  60. package/dist/apis/dashboard/types.d.ts.map +1 -1
  61. package/dist/apis/departments/DepartmentsApi.cjs +5 -5
  62. package/dist/apis/departments/DepartmentsApi.cjs.map +1 -1
  63. package/dist/apis/departments/DepartmentsApi.d.ts +5 -5
  64. package/dist/apis/departments/DepartmentsApi.mjs +5 -5
  65. package/dist/apis/departments/DepartmentsApi.mjs.map +1 -1
  66. package/dist/apis/departments/types.d.ts +6 -0
  67. package/dist/apis/departments/types.d.ts.map +1 -1
  68. package/dist/apis/distribution/DistributionApi.cjs +3 -4
  69. package/dist/apis/distribution/DistributionApi.cjs.map +1 -1
  70. package/dist/apis/distribution/DistributionApi.d.ts +3 -4
  71. package/dist/apis/distribution/DistributionApi.d.ts.map +1 -1
  72. package/dist/apis/distribution/DistributionApi.mjs +3 -4
  73. package/dist/apis/distribution/DistributionApi.mjs.map +1 -1
  74. package/dist/apis/kanbanCards/KanbanCardsApi.cjs +32 -0
  75. package/dist/apis/kanbanCards/KanbanCardsApi.cjs.map +1 -1
  76. package/dist/apis/kanbanCards/KanbanCardsApi.d.ts +27 -1
  77. package/dist/apis/kanbanCards/KanbanCardsApi.d.ts.map +1 -1
  78. package/dist/apis/kanbanCards/KanbanCardsApi.mjs +32 -0
  79. package/dist/apis/kanbanCards/KanbanCardsApi.mjs.map +1 -1
  80. package/dist/apis/kanbanCards/types.d.ts +1 -1
  81. package/dist/apis/kanbanCards/types.d.ts.map +1 -1
  82. package/dist/apis/kanbanColumns/KanbanColumnsApi.cjs +19 -0
  83. package/dist/apis/kanbanColumns/KanbanColumnsApi.cjs.map +1 -1
  84. package/dist/apis/kanbanColumns/KanbanColumnsApi.d.ts +16 -1
  85. package/dist/apis/kanbanColumns/KanbanColumnsApi.d.ts.map +1 -1
  86. package/dist/apis/kanbanColumns/KanbanColumnsApi.mjs +19 -0
  87. package/dist/apis/kanbanColumns/KanbanColumnsApi.mjs.map +1 -1
  88. package/dist/apis/kanbanColumns/types.d.ts +4 -0
  89. package/dist/apis/kanbanColumns/types.d.ts.map +1 -1
  90. package/dist/apis/messages/MessagesApi.cjs +13 -4
  91. package/dist/apis/messages/MessagesApi.cjs.map +1 -1
  92. package/dist/apis/messages/MessagesApi.d.ts +13 -4
  93. package/dist/apis/messages/MessagesApi.d.ts.map +1 -1
  94. package/dist/apis/messages/MessagesApi.mjs +13 -4
  95. package/dist/apis/messages/MessagesApi.mjs.map +1 -1
  96. package/dist/apis/messages/types.d.ts +30 -0
  97. package/dist/apis/messages/types.d.ts.map +1 -1
  98. package/dist/apis/pipeline/types.d.ts +7 -8
  99. package/dist/apis/pipeline/types.d.ts.map +1 -1
  100. package/dist/apis/quickReplies/types.d.ts +4 -1
  101. package/dist/apis/quickReplies/types.d.ts.map +1 -1
  102. package/dist/apis/schedule/types.d.ts +41 -10
  103. package/dist/apis/schedule/types.d.ts.map +1 -1
  104. package/dist/apis/terms/TermsApi.cjs +2 -2
  105. package/dist/apis/terms/TermsApi.cjs.map +1 -1
  106. package/dist/apis/terms/TermsApi.d.ts +2 -2
  107. package/dist/apis/terms/TermsApi.mjs +2 -2
  108. package/dist/apis/terms/TermsApi.mjs.map +1 -1
  109. package/dist/apis/tickets/TicketsApi.cjs +18 -8
  110. package/dist/apis/tickets/TicketsApi.cjs.map +1 -1
  111. package/dist/apis/tickets/TicketsApi.d.ts +15 -8
  112. package/dist/apis/tickets/TicketsApi.d.ts.map +1 -1
  113. package/dist/apis/tickets/TicketsApi.mjs +18 -8
  114. package/dist/apis/tickets/TicketsApi.mjs.map +1 -1
  115. package/dist/apis/tickets/types.d.ts +4 -1
  116. package/dist/apis/tickets/types.d.ts.map +1 -1
  117. package/dist/apis/timetable/TimetableApi.cjs +6 -0
  118. package/dist/apis/timetable/TimetableApi.cjs.map +1 -1
  119. package/dist/apis/timetable/TimetableApi.d.ts +6 -0
  120. package/dist/apis/timetable/TimetableApi.d.ts.map +1 -1
  121. package/dist/apis/timetable/TimetableApi.mjs +6 -0
  122. package/dist/apis/timetable/TimetableApi.mjs.map +1 -1
  123. package/dist/apis/timetable/types.d.ts +8 -0
  124. package/dist/apis/timetable/types.d.ts.map +1 -1
  125. package/dist/apis/users/UsersApi.cjs +11 -3
  126. package/dist/apis/users/UsersApi.cjs.map +1 -1
  127. package/dist/apis/users/UsersApi.d.ts +10 -4
  128. package/dist/apis/users/UsersApi.d.ts.map +1 -1
  129. package/dist/apis/users/UsersApi.mjs +11 -3
  130. package/dist/apis/users/UsersApi.mjs.map +1 -1
  131. package/dist/apis/users/types.d.ts +26 -0
  132. package/dist/apis/users/types.d.ts.map +1 -1
  133. package/dist/apis/webhooks/types.d.ts +51 -6
  134. package/dist/apis/webhooks/types.d.ts.map +1 -1
  135. package/dist/core/errors.cjs +4 -1
  136. package/dist/core/errors.cjs.map +1 -1
  137. package/dist/core/errors.d.ts +4 -1
  138. package/dist/core/errors.d.ts.map +1 -1
  139. package/dist/core/errors.mjs +4 -1
  140. package/dist/core/errors.mjs.map +1 -1
  141. package/package.json +1 -1
  142. package/src/apis/absence/AbsenceApi.ts +2 -2
  143. package/src/apis/absence/types.ts +1 -1
  144. package/src/apis/answers/AnswersApi.test.ts +32 -0
  145. package/src/apis/answers/AnswersApi.ts +38 -2
  146. package/src/apis/answers/types.ts +1 -2
  147. package/src/apis/bots/BotsApi.test.ts +16 -0
  148. package/src/apis/bots/BotsApi.ts +25 -7
  149. package/src/apis/bots/types.ts +12 -2
  150. package/src/apis/campaigns/CampaignsApi.test.ts +48 -0
  151. package/src/apis/campaigns/CampaignsApi.ts +31 -2
  152. package/src/apis/campaigns/types.ts +101 -3
  153. package/src/apis/cards/types.ts +5 -5
  154. package/src/apis/categories/CategoriesApi.ts +1 -2
  155. package/src/apis/clientFeedback/ClientFeedbackApi.ts +2 -3
  156. package/src/apis/contacts/ContactsApi.test.ts +36 -2
  157. package/src/apis/contacts/ContactsApi.ts +41 -3
  158. package/src/apis/contacts/types.ts +28 -0
  159. package/src/apis/creditMovements/CreditMovementsApi.test.ts +1 -1
  160. package/src/apis/customFields/types.ts +4 -4
  161. package/src/apis/dashboard/DashboardApi.test-d.ts +9 -0
  162. package/src/apis/dashboard/DashboardApi.ts +3 -3
  163. package/src/apis/dashboard/types.ts +11 -4
  164. package/src/apis/departments/DepartmentsApi.ts +5 -5
  165. package/src/apis/departments/types.ts +13 -0
  166. package/src/apis/distribution/DistributionApi.ts +3 -4
  167. package/src/apis/kanbanCards/KanbanCardsApi.test.ts +21 -0
  168. package/src/apis/kanbanCards/KanbanCardsApi.ts +47 -1
  169. package/src/apis/kanbanCards/types.ts +1 -1
  170. package/src/apis/kanbanColumns/KanbanColumnsApi.test.ts +26 -0
  171. package/src/apis/kanbanColumns/KanbanColumnsApi.ts +31 -0
  172. package/src/apis/kanbanColumns/types.ts +5 -0
  173. package/src/apis/messages/MessagesApi.ts +13 -4
  174. package/src/apis/messages/types.ts +31 -0
  175. package/src/apis/payloads.test-d.ts +217 -4
  176. package/src/apis/pipeline/types.ts +7 -8
  177. package/src/apis/queryFormat.test.ts +13 -0
  178. package/src/apis/quickReplies/types.ts +4 -1
  179. package/src/apis/schedule/types.ts +42 -10
  180. package/src/apis/terms/TermsApi.ts +2 -2
  181. package/src/apis/tickets/TicketsApi.ts +28 -8
  182. package/src/apis/tickets/types.ts +4 -1
  183. package/src/apis/timetable/TimetableApi.ts +6 -0
  184. package/src/apis/timetable/types.ts +9 -0
  185. package/src/apis/users/UsersApi.test.ts +17 -0
  186. package/src/apis/users/UsersApi.ts +21 -3
  187. package/src/apis/users/types.ts +28 -0
  188. package/src/apis/webhooks/types.ts +53 -6
  189. package/src/core/errors.ts +4 -1
@@ -1,5 +1,6 @@
1
1
  import type { ApiClient } from '../../core/ApiClient'
2
2
  import { BaseCrudApi } from '../../core/BaseCrudApi'
3
+ import type { GetByIdQuery } from '../../core/types'
3
4
  import type {
4
5
  Ticket,
5
6
  CreateTicketPayload,
@@ -15,23 +16,42 @@ import type {
15
16
  /**
16
17
  * Tickets. The backend only serves them for reading (`getMany`, `getOne`, `getById`, the counts,
17
18
  * the first waiting time and the exports) plus `closeMany`: a ticket is opened and transferred by
18
- * `ContactsApi.transferTicket`. The reads check no permission (any authenticated user): the
19
- * `@permissions` of the inherited `getMany`, `getOne` and `getById` do not apply here. `getById`
20
- * of an unknown id resolves `null`. For a user who is not an admin, `getMany` leaves out the
21
- * tickets of the contacts of the connections restricted to that user; the counts and `getById`
22
- * do not.
19
+ * `ContactsApi.transferTicket`, and the ticket of one contact is closed by
20
+ * `ContactsApi.closeTicket`. `getById` of an unknown id resolves `null`. For a user who is not an
21
+ * admin, `getMany` leaves out the tickets of the contacts of the connections restricted to that
22
+ * user.
23
23
  */
24
24
  export class TicketsApi extends BaseCrudApi<Ticket, CreateTicketPayload, UpdateTicketPayload> {
25
25
  constructor(client: ApiClient) {
26
26
  super(client, '/tickets')
27
27
  }
28
28
 
29
+ /** Returns the first ticket matching the query, or `null` when none match. */
30
+ override getOne(
31
+ query?: TicketsListQuery,
32
+ headers?: Record<string, string>,
33
+ ): Promise<Ticket | null> {
34
+ return super.getOne(query, headers)
35
+ }
36
+
37
+ /** Returns a ticket by ID; an unknown id resolves `null`. */
38
+ override getById(
39
+ id: string,
40
+ query?: GetByIdQuery<Ticket>,
41
+ headers?: Record<string, string>,
42
+ ): Promise<Ticket> {
43
+ return super.getById(id, query, headers)
44
+ }
45
+
29
46
  /** @deprecated Not served: `POST /tickets` answers 404 `Route not found.`. Open a ticket through `ContactsApi.transferTicket`. */
30
47
  override create(body: CreateTicketPayload, headers?: Record<string, string>): Promise<Ticket> {
31
48
  return super.create(body, headers)
32
49
  }
33
50
 
34
- /** @deprecated Not served: `PUT /tickets/{id}` answers 404 `Route not found.`. Transfer through `ContactsApi.transferTicket`, close through `closeMany`. */
51
+ /**
52
+ * @deprecated Not served: `PUT /tickets/{id}` answers 404 `Route not found.`. Transfer through
53
+ * `ContactsApi.transferTicket`, close through `ContactsApi.closeTicket` or `closeMany`.
54
+ */
35
55
  override updateById(
36
56
  id: string,
37
57
  body: UpdateTicketPayload,
@@ -46,8 +66,8 @@ export class TicketsApi extends BaseCrudApi<Ticket, CreateTicketPayload, UpdateT
46
66
  }
47
67
 
48
68
  /**
49
- * Closes multiple tickets in a single request. This is the only ticket-close
50
- * endpoint exposed by the API — there is no per-ticket close/update route.
69
+ * Closes multiple tickets in a single request. `ContactsApi.closeTicket` closes the ticket of one
70
+ * contact by the contact id, and also takes the rating of the AI summary.
51
71
  *
52
72
  * Pass `{ ids }` to close specific tickets, or `{ allContactsSelected: true, query }`
53
73
  * to close every OPEN ticket matching `query` (the backend forces `isOpen: true`): an empty
@@ -142,7 +142,10 @@ export type CreateTicketPayload = {
142
142
  origin?: TicketOrigin
143
143
  }
144
144
 
145
- /** @deprecated Not served: the backend has no `PUT /tickets/{id}`. Transfer through `ContactsApi.transferTicket`, close through `TicketsApi.closeMany`. */
145
+ /**
146
+ * @deprecated Not served: the backend has no `PUT /tickets/{id}`. Transfer through
147
+ * `ContactsApi.transferTicket`, close through `ContactsApi.closeTicket` or `TicketsApi.closeMany`.
148
+ */
146
149
  export type UpdateTicketPayload = {
147
150
  departmentId?: string
148
151
  userId?: string | null
@@ -3,6 +3,12 @@ import type { ListQuery } from '../../core/types'
3
3
  import { BaseCrudApi } from '../../core/BaseCrudApi'
4
4
  import type { Timetable, CreateTimetablePayload, UpdateTimetablePayload } from './types'
5
5
 
6
+ /**
7
+ * Timetables (work hours) of the users. Out of the timetable of the user, most authenticated routes
8
+ * answer 403 `Is out of office hours`, with the `workPlan` of the timetable in the `extra` of the
9
+ * error body (see `OutOfOfficeHoursErrorExtra`). Logging in (`POST /oauth/token`) and setting
10
+ * the status to `offline` still work.
11
+ */
6
12
  export class TimetableApi extends BaseCrudApi<
7
13
  Timetable,
8
14
  CreateTimetablePayload,
@@ -32,3 +32,12 @@ export type CreateTimetablePayload = {
32
32
 
33
33
  /** The backend requires the three fields on every update (400 `required` otherwise). */
34
34
  export type UpdateTimetablePayload = CreateTimetablePayload
35
+
36
+ /**
37
+ * The `extra` of the 403 `Is out of office hours` error body: the timetable of the user. The error
38
+ * is a `PermissionDeniedError` with that `message`; read it as
39
+ * `(error.body as { extra?: OutOfOfficeHoursErrorExtra }).extra?.workPlan`.
40
+ */
41
+ export type OutOfOfficeHoursErrorExtra = {
42
+ workPlan: TimetableWorkSlot[]
43
+ }
@@ -3,6 +3,7 @@ import { UsersApi } from './UsersApi'
3
3
  import type { ApiClient } from '../../core/ApiClient'
4
4
  import type {
5
5
  BulkUsersStatusPreview,
6
+ BulkUpdateUsersLinksResult,
6
7
  BulkUsersStatusResult,
7
8
  ImportUsersResult,
8
9
  User,
@@ -109,6 +110,22 @@ describe('UsersApi', () => {
109
110
  })
110
111
  })
111
112
 
113
+ describe('bulkUpdateLinks', () => {
114
+ it('calls client.put with /users/v2/bulk-update and body', async () => {
115
+ const response: BulkUpdateUsersLinksResult = {
116
+ changed: 1,
117
+ failed: 0,
118
+ changedIds: ['usr-1'],
119
+ missingIds: ['usr-2'],
120
+ }
121
+ vi.mocked(client.put).mockResolvedValue(response)
122
+ const body = { ids: ['usr-1', 'usr-2'], timetableId: null, departmentIds: ['dep-1'] }
123
+ const result = await api.bulkUpdateLinks(body, headers)
124
+ expect(client.put).toHaveBeenCalledWith('/users/v2/bulk-update', body, headers)
125
+ expect(result).toEqual(response)
126
+ })
127
+ })
128
+
112
129
  describe('bulkStatus', () => {
113
130
  it('calls client.post with /users/bulk-status and body', async () => {
114
131
  const response: BulkUsersStatusResult = {
@@ -7,6 +7,8 @@ import type {
7
7
  BulkUsersStatusPayload,
8
8
  BulkUsersStatusPreview,
9
9
  BulkUsersStatusResult,
10
+ BulkUpdateUsersLinksPayload,
11
+ BulkUpdateUsersLinksResult,
10
12
  CreateUserPayload,
11
13
  EnableUserAccessResult,
12
14
  ExportUsersPayload,
@@ -41,9 +43,8 @@ export class UsersApi extends ArchivableCrudApi<
41
43
  }
42
44
 
43
45
  /**
44
- * Archives or restores a user through the dedicated route used by the UI, which also
45
- * sets the user offline and ends its sessions. The route enforces the business rules that
46
- * {@link archive}/{@link unarchive} (a plain `PUT { archivedAt }`) skip:
46
+ * Archives or restores a user through the route used by the UI, which also sets the user
47
+ * offline and ends its sessions:
47
48
  * - archiving refuses (403) a user referenced by a bot or with open tickets;
48
49
  * - restoring refuses (402) when the plan has no free user slot.
49
50
  * @permissions users.view OR users.archive
@@ -75,6 +76,23 @@ export class UsersApi extends ArchivableCrudApi<
75
76
  )
76
77
  }
77
78
 
79
+ /**
80
+ * Links up to 100 users at once to a timetable, departments or roles (see
81
+ * {@link BulkUpdateUsersLinksPayload}). The timetable is written for the whole batch at once; the
82
+ * departments and roles user by user, so the result may be partial (`failed`).
83
+ * @permissions users.update
84
+ */
85
+ bulkUpdateLinks(
86
+ body: BulkUpdateUsersLinksPayload,
87
+ headers?: Record<string, string>,
88
+ ): Promise<BulkUpdateUsersLinksResult> {
89
+ return this.client.put<BulkUpdateUsersLinksResult, BulkUpdateUsersLinksPayload>(
90
+ `${this.basePath}/v2/bulk-update`,
91
+ body,
92
+ headers,
93
+ )
94
+ }
95
+
78
96
  /**
79
97
  * Archives or unarchives up to 100 users at once.
80
98
  * @permissions users.archive
@@ -145,6 +145,34 @@ export type BulkUsersStatusResult = {
145
145
  missingIds: string[]
146
146
  }
147
147
 
148
+ /**
149
+ * Body for `PUT /users/v2/bulk-update` (1 to 100 user IDs). Send at least one of `timetableId`,
150
+ * `departmentIds` and `roleIds` (400 otherwise). A link id of another account, or unknown, refuses
151
+ * the whole batch with 400 (`<field> contains ids that do not belong to the account.`).
152
+ */
153
+ export type BulkUpdateUsersLinksPayload = {
154
+ ids: string[]
155
+ /** Sets the timetable of every user; `null` removes it. */
156
+ timetableId?: string | null
157
+ /** Adds the departments to every user (the current ones are kept). At least one id. */
158
+ departmentIds?: string[]
159
+ /** Adds the roles to every user (the current ones are kept). At least one id. */
160
+ roleIds?: string[]
161
+ }
162
+
163
+ export type BulkUpdateUsersLinksResult = {
164
+ /**
165
+ * Users of the batch written by at least one of the steps (with `timetableId`, `null` included,
166
+ * every user found; with `departmentIds`/`roleIds`, also those that already had them).
167
+ */
168
+ changed: number
169
+ /** Failures of the per-user writes (departments and roles), one per user and field. */
170
+ failed: number
171
+ changedIds: string[]
172
+ /** IDs of the batch that are not users of the account (they are skipped). */
173
+ missingIds: string[]
174
+ }
175
+
148
176
  /** Body for `POST /users/export`. */
149
177
  export type ExportUsersPayload = {
150
178
  filter: 'all' | 'active' | 'archived'
@@ -1,14 +1,46 @@
1
1
  import type { Service } from '../services/types'
2
2
 
3
+ /**
4
+ * `by_service` and `whatsapp_low_level` only get the events of the connections in `services`.
5
+ * Events not tied to a connection (users, departments, tags...) reach `by_service` too. A webhook
6
+ * with `services`, whatever its type, only gets the events of those connections (events not tied
7
+ * to a connection reach it too); a `general` webhook is meant to have none.
8
+ */
9
+ export type WebhookType = 'general' | 'by_service' | 'whatsapp_low_level'
10
+
11
+ /**
12
+ * The categories of message the `message.created` event delivers. Only `false` leaves a category
13
+ * out (an absent key keeps it); `null`, or no filter, delivers every message. The other events are
14
+ * not filtered. A key outside these answers 400.
15
+ */
16
+ export type WebhookMessageFilters = {
17
+ /** Messages of the contact (not their reactions). */
18
+ received?: boolean
19
+ /** Messages sent through the connection, except the bot's (and the reactions). */
20
+ sent?: boolean
21
+ /** Messages sent by the bot. */
22
+ bot?: boolean
23
+ /**
24
+ * Internal comments, ticket events, reactions, summaries, schedules, AI evaluations, the notices
25
+ * of the message block rule and the message types the platform does not know.
26
+ */
27
+ system?: boolean
28
+ }
29
+
3
30
  export type Webhook = {
4
31
  id: string
5
32
  name: string
6
33
  url: string
7
- type: string
34
+ /** A webhook created before the type was validated may hold another value. */
35
+ type: WebhookType
8
36
  active: boolean
9
37
  events: string[]
38
+ /** `null` when `events` has no `message.created` (the backend clears it on every write). */
39
+ messageFilters?: WebhookMessageFilters | null
10
40
  errorAt: string | null
11
41
  errorNotifiedAt: string | null
42
+ /** The average delivery latency, in ms (shown in the list of webhooks); `null` until measured. */
43
+ avgLatencyMs?: number | null
12
44
  userId: string
13
45
  accountId: string
14
46
  createdAt: string
@@ -23,15 +55,30 @@ export type WebhookRelationships = 'services'
23
55
  export type CreateWebhookPayload = {
24
56
  name: string
25
57
  url: string
26
- type: string
58
+ type: WebhookType
27
59
  events: string[]
28
60
  active?: boolean
61
+ /** The connections of a `by_service` or `whatsapp_low_level` webhook (none for `general`). */
62
+ services?: string[]
63
+ /** Only kept with the `message.created` event. */
64
+ messageFilters?: WebhookMessageFilters | null
29
65
  }
30
66
 
67
+ /**
68
+ * `updateById` sends a `PUT`: `name`, `url`, `type` and `events` are required (400 without them),
69
+ * as in the create.
70
+ */
31
71
  export type UpdateWebhookPayload = {
32
- name?: string
33
- url?: string
34
- type?: string
35
- events?: string[]
72
+ name: string
73
+ url: string
74
+ type: WebhookType
75
+ events: string[]
36
76
  active?: boolean
77
+ /**
78
+ * Replaces the connections of the webhook; omitted keeps them. Send `[]` when the type becomes
79
+ * `general`: the connections kept also filter a `general` webhook.
80
+ */
81
+ services?: string[]
82
+ /** Only kept with the `message.created` event. */
83
+ messageFilters?: WebhookMessageFilters | null
37
84
  }
@@ -181,7 +181,10 @@ export class PaymentRequiredError extends ApiError {
181
181
  override name = 'PaymentRequiredError'
182
182
  }
183
183
 
184
- /** 403 — the user lacks the permission for this action. */
184
+ /**
185
+ * 403 — the user lacks the permission for this action, or the action is refused (e.g. out of
186
+ * office hours, see `OutOfOfficeHoursErrorExtra`).
187
+ */
185
188
  export class PermissionDeniedError extends ApiError {
186
189
  override name = 'PermissionDeniedError'
187
190
  }