@ikatec/digisac-api-sdk 4.15.0 → 4.16.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 +5 -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 +5 -0
  175. package/src/apis/payloads.test-d.ts +206 -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
@@ -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
  }