@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
package/README.md CHANGED
@@ -91,7 +91,7 @@ Available resources:
91
91
  | Campaigns | `CampaignsApi` | `/campaigns` |
92
92
  | Cards | `CardsApi` | `/cards` |
93
93
  | Categories | `CategoriesApi` | `/categories` |
94
- | Client Feedback (deprecated: the route is broken in the backend) | `ClientFeedbackApi` | `/client-feedback` |
94
+ | Client Feedback (deprecated: send the rating of the AI summary with `ContactsApi.closeTicket`) | `ClientFeedbackApi` | `/client-feedback` |
95
95
  | Contact Block Lists | `ContactBlockListsApi` | `/contact-block-lists` |
96
96
  | Contact Block Lists Controls | `ContactBlockListsControlsApi` | `/contact-block-lists-controls` |
97
97
  | Contacts | `ContactsApi` | `/contacts` |
@@ -365,6 +365,8 @@ response.headers.get('Content-Type') // 'application/pdf'
365
365
  const pdf = await response.arrayBuffer()
366
366
  ```
367
367
 
368
+ The methods built on it need a client that implements `requestRaw`: `CreditMovementsApi.exportXlsx` and `BotsApi.exportErrors` (xlsx as an `ArrayBuffer`), and `AnswersApi.exportCsvRaw` / `exportTxtRaw` (the whole `Response`).
369
+
368
370
  ## Uploading files
369
371
 
370
372
  The content of a file goes straight to the storage, through a signed URL. `upload` sends it with `client.requestExternal`, which leaves out the base URL and the access token (the storage refuses an `Authorization` header), so a `BaseApiClient` subclass can intercept it by overriding that method:
@@ -13,8 +13,8 @@ var AbsenceApi = class extends require_core_BaseCrudApi.BaseCrudApi {
13
13
  super(client, "/absence");
14
14
  }
15
15
  /**
16
- * The absence report of the account (`GET /absence`), always paginated, with its own query (the rows are
17
- * raw: see `AbsenceReportItem`). Prefer it to `getMany`, whose `where`/`include`/`paginate` the backend
16
+ * The absence report of the account (`GET /absence`), always paginated, with its own query (see
17
+ * `AbsenceReportItem`). Prefer it to `getMany`, whose `where`/`include`/`paginate` the backend
18
18
  * ignores. Requires both permissions, always: without them it answers 403
19
19
  * `MISSING_ABSENCE_REPORT_PERMISSION`.
20
20
  * @permissions overview.absence.view AND myAccount.absence
@@ -1 +1 @@
1
- {"version":3,"file":"AbsenceApi.cjs","names":["BaseCrudApi"],"sources":["../../../src/apis/absence/AbsenceApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type { GetByIdQuery, Paginated } from '../../core/types'\nimport type {\n Absence,\n AbsenceReportItem,\n AbsenceReportQuery,\n CreateAbsencePayload,\n UnlockAbsencePayload,\n UnlockAbsenceResponse,\n UpdateAbsencePayload,\n} from './types'\n\n/**\n * Absences of the users. The backend serves the report (`GET /absence`, `GET /absence/export-csv`),\n * `GET /absence/find-open-absence`, `POST /absence`, `POST /absence/unlock` and `PUT /absence/:id`; there is\n * no read by id nor delete. Creating an absence sets the status of the user to `away` and `unlock` sets it\n * back to `online` (both emit `user.updated` to the webhooks).\n */\nexport class AbsenceApi extends BaseCrudApi<Absence, CreateAbsencePayload, UpdateAbsencePayload> {\n constructor(client: ApiClient) {\n super(client, '/absence')\n }\n\n /**\n * The absence report of the account (`GET /absence`), always paginated, with its own query (the rows are\n * raw: see `AbsenceReportItem`). Prefer it to `getMany`, whose `where`/`include`/`paginate` the backend\n * ignores. Requires both permissions, always: without them it answers 403\n * `MISSING_ABSENCE_REPORT_PERMISSION`.\n * @permissions overview.absence.view AND myAccount.absence\n */\n report(\n query?: AbsenceReportQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<AbsenceReportItem>> {\n return this.client.get<Paginated<AbsenceReportItem>>(\n `${this.basePath}${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Creates an absence for the current user (whatever `userId` says) and sets the user `away`. Resolves the\n * stored absence (raw, without `user`).\n * @permissions myAccount.absence\n */\n override create(body: CreateAbsencePayload, headers?: Record<string, string>): Promise<Absence> {\n return super.create(body, headers)\n }\n\n /**\n * The open absence of the current user, or `null` — also `null` while `settings.absence.enabled` is off.\n * @permissions myAccount.absence\n */\n findOpenAbsence(headers?: Record<string, string>): Promise<AbsenceReportItem | null> {\n return this.client.get<AbsenceReportItem | null>(`${this.basePath}/find-open-absence`, headers)\n }\n\n /**\n * Ends an absence (the open one of the user when `id` is absent) and sets the user `online`. The refusals\n * of `settings.absence` come with status 200 (`INVALID_REASON`, `INVALID_PASSWORD`); without an open\n * absence it answers 500.\n * @permissions myAccount.absence\n */\n unlock(\n body: UnlockAbsencePayload,\n headers?: Record<string, string>,\n ): Promise<UnlockAbsenceResponse> {\n return this.client.post<UnlockAbsenceResponse, UnlockAbsencePayload>(\n `${this.basePath}/unlock`,\n body,\n headers,\n )\n }\n\n /**\n * Exports the report as CSV (`Usuário, De, Até, Motivo`; an open absence shows `Em andamento`), sent as\n * the attachment `<yyyy-MM-dd>_absence-control.csv`.\n * @permissions overview.absence.view AND myAccount.absence\n */\n exportCsv(query?: AbsenceReportQuery, headers?: Record<string, string>): Promise<string> {\n return this.client.get<string>(\n `${this.basePath}/export-csv${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /** @deprecated Not served: the backend has no GET /absence/:id, so this route answers 404. */\n override getById(\n id: string,\n query?: GetByIdQuery<Absence>,\n headers?: Record<string, string>,\n ): Promise<Absence> {\n return super.getById(id, query, headers)\n }\n\n /** @deprecated Not served: the backend has no DELETE /absence/:id, so this route answers 404. */\n override deleteById(id: string, headers?: Record<string, string>): Promise<Absence> {\n return super.deleteById(id, headers)\n }\n}\n"],"mappings":";;;;;;;;;;AAmBA,IAAa,aAAb,cAAgCA,qCAAiE;CAC/F,YAAY,QAAmB;AAC7B,QAAM,QAAQ,WAAW;;;;;;;;;CAU3B,OACE,OACA,SACuC;AACvC,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,WAAW,KAAK,cAAc,MAAM,IAC5C,QACD;;;;;;;CAQH,AAAS,OAAO,MAA4B,SAAoD;AAC9F,SAAO,MAAM,OAAO,MAAM,QAAQ;;;;;;CAOpC,gBAAgB,SAAqE;AACnF,SAAO,KAAK,OAAO,IAA8B,GAAG,KAAK,SAAS,qBAAqB,QAAQ;;;;;;;;CASjG,OACE,MACA,SACgC;AAChC,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,UACjB,MACA,QACD;;;;;;;CAQH,UAAU,OAA4B,SAAmD;AACvF,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,aAAa,KAAK,cAAc,MAAM,IACvD,QACD;;;CAIH,AAAS,QACP,IACA,OACA,SACkB;AAClB,SAAO,MAAM,QAAQ,IAAI,OAAO,QAAQ;;;CAI1C,AAAS,WAAW,IAAY,SAAoD;AAClF,SAAO,MAAM,WAAW,IAAI,QAAQ"}
1
+ {"version":3,"file":"AbsenceApi.cjs","names":["BaseCrudApi"],"sources":["../../../src/apis/absence/AbsenceApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type { GetByIdQuery, Paginated } from '../../core/types'\nimport type {\n Absence,\n AbsenceReportItem,\n AbsenceReportQuery,\n CreateAbsencePayload,\n UnlockAbsencePayload,\n UnlockAbsenceResponse,\n UpdateAbsencePayload,\n} from './types'\n\n/**\n * Absences of the users. The backend serves the report (`GET /absence`, `GET /absence/export-csv`),\n * `GET /absence/find-open-absence`, `POST /absence`, `POST /absence/unlock` and `PUT /absence/:id`; there is\n * no read by id nor delete. Creating an absence sets the status of the user to `away` and `unlock` sets it\n * back to `online` (both emit `user.updated` to the webhooks).\n */\nexport class AbsenceApi extends BaseCrudApi<Absence, CreateAbsencePayload, UpdateAbsencePayload> {\n constructor(client: ApiClient) {\n super(client, '/absence')\n }\n\n /**\n * The absence report of the account (`GET /absence`), always paginated, with its own query (see\n * `AbsenceReportItem`). Prefer it to `getMany`, whose `where`/`include`/`paginate` the backend\n * ignores. Requires both permissions, always: without them it answers 403\n * `MISSING_ABSENCE_REPORT_PERMISSION`.\n * @permissions overview.absence.view AND myAccount.absence\n */\n report(\n query?: AbsenceReportQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<AbsenceReportItem>> {\n return this.client.get<Paginated<AbsenceReportItem>>(\n `${this.basePath}${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Creates an absence for the current user (whatever `userId` says) and sets the user `away`. Resolves the\n * stored absence (raw, without `user`).\n * @permissions myAccount.absence\n */\n override create(body: CreateAbsencePayload, headers?: Record<string, string>): Promise<Absence> {\n return super.create(body, headers)\n }\n\n /**\n * The open absence of the current user, or `null` — also `null` while `settings.absence.enabled` is off.\n * @permissions myAccount.absence\n */\n findOpenAbsence(headers?: Record<string, string>): Promise<AbsenceReportItem | null> {\n return this.client.get<AbsenceReportItem | null>(`${this.basePath}/find-open-absence`, headers)\n }\n\n /**\n * Ends an absence (the open one of the user when `id` is absent) and sets the user `online`. The refusals\n * of `settings.absence` come with status 200 (`INVALID_REASON`, `INVALID_PASSWORD`); without an open\n * absence it answers 500.\n * @permissions myAccount.absence\n */\n unlock(\n body: UnlockAbsencePayload,\n headers?: Record<string, string>,\n ): Promise<UnlockAbsenceResponse> {\n return this.client.post<UnlockAbsenceResponse, UnlockAbsencePayload>(\n `${this.basePath}/unlock`,\n body,\n headers,\n )\n }\n\n /**\n * Exports the report as CSV (`Usuário, De, Até, Motivo`; an open absence shows `Em andamento`), sent as\n * the attachment `<yyyy-MM-dd>_absence-control.csv`.\n * @permissions overview.absence.view AND myAccount.absence\n */\n exportCsv(query?: AbsenceReportQuery, headers?: Record<string, string>): Promise<string> {\n return this.client.get<string>(\n `${this.basePath}/export-csv${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /** @deprecated Not served: the backend has no GET /absence/:id, so this route answers 404. */\n override getById(\n id: string,\n query?: GetByIdQuery<Absence>,\n headers?: Record<string, string>,\n ): Promise<Absence> {\n return super.getById(id, query, headers)\n }\n\n /** @deprecated Not served: the backend has no DELETE /absence/:id, so this route answers 404. */\n override deleteById(id: string, headers?: Record<string, string>): Promise<Absence> {\n return super.deleteById(id, headers)\n }\n}\n"],"mappings":";;;;;;;;;;AAmBA,IAAa,aAAb,cAAgCA,qCAAiE;CAC/F,YAAY,QAAmB;AAC7B,QAAM,QAAQ,WAAW;;;;;;;;;CAU3B,OACE,OACA,SACuC;AACvC,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,WAAW,KAAK,cAAc,MAAM,IAC5C,QACD;;;;;;;CAQH,AAAS,OAAO,MAA4B,SAAoD;AAC9F,SAAO,MAAM,OAAO,MAAM,QAAQ;;;;;;CAOpC,gBAAgB,SAAqE;AACnF,SAAO,KAAK,OAAO,IAA8B,GAAG,KAAK,SAAS,qBAAqB,QAAQ;;;;;;;;CASjG,OACE,MACA,SACgC;AAChC,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,UACjB,MACA,QACD;;;;;;;CAQH,UAAU,OAA4B,SAAmD;AACvF,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,aAAa,KAAK,cAAc,MAAM,IACvD,QACD;;;CAIH,AAAS,QACP,IACA,OACA,SACkB;AAClB,SAAO,MAAM,QAAQ,IAAI,OAAO,QAAQ;;;CAI1C,AAAS,WAAW,IAAY,SAAoD;AAClF,SAAO,MAAM,WAAW,IAAI,QAAQ"}
@@ -11,8 +11,8 @@ import type { Absence, AbsenceReportItem, AbsenceReportQuery, CreateAbsencePaylo
11
11
  export declare class AbsenceApi extends BaseCrudApi<Absence, CreateAbsencePayload, UpdateAbsencePayload> {
12
12
  constructor(client: ApiClient);
13
13
  /**
14
- * The absence report of the account (`GET /absence`), always paginated, with its own query (the rows are
15
- * raw: see `AbsenceReportItem`). Prefer it to `getMany`, whose `where`/`include`/`paginate` the backend
14
+ * The absence report of the account (`GET /absence`), always paginated, with its own query (see
15
+ * `AbsenceReportItem`). Prefer it to `getMany`, whose `where`/`include`/`paginate` the backend
16
16
  * ignores. Requires both permissions, always: without them it answers 403
17
17
  * `MISSING_ABSENCE_REPORT_PERMISSION`.
18
18
  * @permissions overview.absence.view AND myAccount.absence
@@ -12,8 +12,8 @@ var AbsenceApi = class extends BaseCrudApi {
12
12
  super(client, "/absence");
13
13
  }
14
14
  /**
15
- * The absence report of the account (`GET /absence`), always paginated, with its own query (the rows are
16
- * raw: see `AbsenceReportItem`). Prefer it to `getMany`, whose `where`/`include`/`paginate` the backend
15
+ * The absence report of the account (`GET /absence`), always paginated, with its own query (see
16
+ * `AbsenceReportItem`). Prefer it to `getMany`, whose `where`/`include`/`paginate` the backend
17
17
  * ignores. Requires both permissions, always: without them it answers 403
18
18
  * `MISSING_ABSENCE_REPORT_PERMISSION`.
19
19
  * @permissions overview.absence.view AND myAccount.absence
@@ -1 +1 @@
1
- {"version":3,"file":"AbsenceApi.mjs","names":[],"sources":["../../../src/apis/absence/AbsenceApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type { GetByIdQuery, Paginated } from '../../core/types'\nimport type {\n Absence,\n AbsenceReportItem,\n AbsenceReportQuery,\n CreateAbsencePayload,\n UnlockAbsencePayload,\n UnlockAbsenceResponse,\n UpdateAbsencePayload,\n} from './types'\n\n/**\n * Absences of the users. The backend serves the report (`GET /absence`, `GET /absence/export-csv`),\n * `GET /absence/find-open-absence`, `POST /absence`, `POST /absence/unlock` and `PUT /absence/:id`; there is\n * no read by id nor delete. Creating an absence sets the status of the user to `away` and `unlock` sets it\n * back to `online` (both emit `user.updated` to the webhooks).\n */\nexport class AbsenceApi extends BaseCrudApi<Absence, CreateAbsencePayload, UpdateAbsencePayload> {\n constructor(client: ApiClient) {\n super(client, '/absence')\n }\n\n /**\n * The absence report of the account (`GET /absence`), always paginated, with its own query (the rows are\n * raw: see `AbsenceReportItem`). Prefer it to `getMany`, whose `where`/`include`/`paginate` the backend\n * ignores. Requires both permissions, always: without them it answers 403\n * `MISSING_ABSENCE_REPORT_PERMISSION`.\n * @permissions overview.absence.view AND myAccount.absence\n */\n report(\n query?: AbsenceReportQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<AbsenceReportItem>> {\n return this.client.get<Paginated<AbsenceReportItem>>(\n `${this.basePath}${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Creates an absence for the current user (whatever `userId` says) and sets the user `away`. Resolves the\n * stored absence (raw, without `user`).\n * @permissions myAccount.absence\n */\n override create(body: CreateAbsencePayload, headers?: Record<string, string>): Promise<Absence> {\n return super.create(body, headers)\n }\n\n /**\n * The open absence of the current user, or `null` — also `null` while `settings.absence.enabled` is off.\n * @permissions myAccount.absence\n */\n findOpenAbsence(headers?: Record<string, string>): Promise<AbsenceReportItem | null> {\n return this.client.get<AbsenceReportItem | null>(`${this.basePath}/find-open-absence`, headers)\n }\n\n /**\n * Ends an absence (the open one of the user when `id` is absent) and sets the user `online`. The refusals\n * of `settings.absence` come with status 200 (`INVALID_REASON`, `INVALID_PASSWORD`); without an open\n * absence it answers 500.\n * @permissions myAccount.absence\n */\n unlock(\n body: UnlockAbsencePayload,\n headers?: Record<string, string>,\n ): Promise<UnlockAbsenceResponse> {\n return this.client.post<UnlockAbsenceResponse, UnlockAbsencePayload>(\n `${this.basePath}/unlock`,\n body,\n headers,\n )\n }\n\n /**\n * Exports the report as CSV (`Usuário, De, Até, Motivo`; an open absence shows `Em andamento`), sent as\n * the attachment `<yyyy-MM-dd>_absence-control.csv`.\n * @permissions overview.absence.view AND myAccount.absence\n */\n exportCsv(query?: AbsenceReportQuery, headers?: Record<string, string>): Promise<string> {\n return this.client.get<string>(\n `${this.basePath}/export-csv${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /** @deprecated Not served: the backend has no GET /absence/:id, so this route answers 404. */\n override getById(\n id: string,\n query?: GetByIdQuery<Absence>,\n headers?: Record<string, string>,\n ): Promise<Absence> {\n return super.getById(id, query, headers)\n }\n\n /** @deprecated Not served: the backend has no DELETE /absence/:id, so this route answers 404. */\n override deleteById(id: string, headers?: Record<string, string>): Promise<Absence> {\n return super.deleteById(id, headers)\n }\n}\n"],"mappings":";;;;;;;;;AAmBA,IAAa,aAAb,cAAgC,YAAiE;CAC/F,YAAY,QAAmB;AAC7B,QAAM,QAAQ,WAAW;;;;;;;;;CAU3B,OACE,OACA,SACuC;AACvC,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,WAAW,KAAK,cAAc,MAAM,IAC5C,QACD;;;;;;;CAQH,AAAS,OAAO,MAA4B,SAAoD;AAC9F,SAAO,MAAM,OAAO,MAAM,QAAQ;;;;;;CAOpC,gBAAgB,SAAqE;AACnF,SAAO,KAAK,OAAO,IAA8B,GAAG,KAAK,SAAS,qBAAqB,QAAQ;;;;;;;;CASjG,OACE,MACA,SACgC;AAChC,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,UACjB,MACA,QACD;;;;;;;CAQH,UAAU,OAA4B,SAAmD;AACvF,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,aAAa,KAAK,cAAc,MAAM,IACvD,QACD;;;CAIH,AAAS,QACP,IACA,OACA,SACkB;AAClB,SAAO,MAAM,QAAQ,IAAI,OAAO,QAAQ;;;CAI1C,AAAS,WAAW,IAAY,SAAoD;AAClF,SAAO,MAAM,WAAW,IAAI,QAAQ"}
1
+ {"version":3,"file":"AbsenceApi.mjs","names":[],"sources":["../../../src/apis/absence/AbsenceApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type { GetByIdQuery, Paginated } from '../../core/types'\nimport type {\n Absence,\n AbsenceReportItem,\n AbsenceReportQuery,\n CreateAbsencePayload,\n UnlockAbsencePayload,\n UnlockAbsenceResponse,\n UpdateAbsencePayload,\n} from './types'\n\n/**\n * Absences of the users. The backend serves the report (`GET /absence`, `GET /absence/export-csv`),\n * `GET /absence/find-open-absence`, `POST /absence`, `POST /absence/unlock` and `PUT /absence/:id`; there is\n * no read by id nor delete. Creating an absence sets the status of the user to `away` and `unlock` sets it\n * back to `online` (both emit `user.updated` to the webhooks).\n */\nexport class AbsenceApi extends BaseCrudApi<Absence, CreateAbsencePayload, UpdateAbsencePayload> {\n constructor(client: ApiClient) {\n super(client, '/absence')\n }\n\n /**\n * The absence report of the account (`GET /absence`), always paginated, with its own query (see\n * `AbsenceReportItem`). Prefer it to `getMany`, whose `where`/`include`/`paginate` the backend\n * ignores. Requires both permissions, always: without them it answers 403\n * `MISSING_ABSENCE_REPORT_PERMISSION`.\n * @permissions overview.absence.view AND myAccount.absence\n */\n report(\n query?: AbsenceReportQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<AbsenceReportItem>> {\n return this.client.get<Paginated<AbsenceReportItem>>(\n `${this.basePath}${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Creates an absence for the current user (whatever `userId` says) and sets the user `away`. Resolves the\n * stored absence (raw, without `user`).\n * @permissions myAccount.absence\n */\n override create(body: CreateAbsencePayload, headers?: Record<string, string>): Promise<Absence> {\n return super.create(body, headers)\n }\n\n /**\n * The open absence of the current user, or `null` — also `null` while `settings.absence.enabled` is off.\n * @permissions myAccount.absence\n */\n findOpenAbsence(headers?: Record<string, string>): Promise<AbsenceReportItem | null> {\n return this.client.get<AbsenceReportItem | null>(`${this.basePath}/find-open-absence`, headers)\n }\n\n /**\n * Ends an absence (the open one of the user when `id` is absent) and sets the user `online`. The refusals\n * of `settings.absence` come with status 200 (`INVALID_REASON`, `INVALID_PASSWORD`); without an open\n * absence it answers 500.\n * @permissions myAccount.absence\n */\n unlock(\n body: UnlockAbsencePayload,\n headers?: Record<string, string>,\n ): Promise<UnlockAbsenceResponse> {\n return this.client.post<UnlockAbsenceResponse, UnlockAbsencePayload>(\n `${this.basePath}/unlock`,\n body,\n headers,\n )\n }\n\n /**\n * Exports the report as CSV (`Usuário, De, Até, Motivo`; an open absence shows `Em andamento`), sent as\n * the attachment `<yyyy-MM-dd>_absence-control.csv`.\n * @permissions overview.absence.view AND myAccount.absence\n */\n exportCsv(query?: AbsenceReportQuery, headers?: Record<string, string>): Promise<string> {\n return this.client.get<string>(\n `${this.basePath}/export-csv${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /** @deprecated Not served: the backend has no GET /absence/:id, so this route answers 404. */\n override getById(\n id: string,\n query?: GetByIdQuery<Absence>,\n headers?: Record<string, string>,\n ): Promise<Absence> {\n return super.getById(id, query, headers)\n }\n\n /** @deprecated Not served: the backend has no DELETE /absence/:id, so this route answers 404. */\n override deleteById(id: string, headers?: Record<string, string>): Promise<Absence> {\n return super.deleteById(id, headers)\n }\n}\n"],"mappings":";;;;;;;;;AAmBA,IAAa,aAAb,cAAgC,YAAiE;CAC/F,YAAY,QAAmB;AAC7B,QAAM,QAAQ,WAAW;;;;;;;;;CAU3B,OACE,OACA,SACuC;AACvC,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,WAAW,KAAK,cAAc,MAAM,IAC5C,QACD;;;;;;;CAQH,AAAS,OAAO,MAA4B,SAAoD;AAC9F,SAAO,MAAM,OAAO,MAAM,QAAQ;;;;;;CAOpC,gBAAgB,SAAqE;AACnF,SAAO,KAAK,OAAO,IAA8B,GAAG,KAAK,SAAS,qBAAqB,QAAQ;;;;;;;;CASjG,OACE,MACA,SACgC;AAChC,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,UACjB,MACA,QACD;;;;;;;CAQH,UAAU,OAA4B,SAAmD;AACvF,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,aAAa,KAAK,cAAc,MAAM,IACvD,QACD;;;CAIH,AAAS,QACP,IACA,OACA,SACkB;AAClB,SAAO,MAAM,QAAQ,IAAI,OAAO,QAAQ;;;CAI1C,AAAS,WAAW,IAAY,SAAoD;AAClF,SAAO,MAAM,WAAW,IAAI,QAAQ"}
@@ -48,7 +48,7 @@ export type AbsenceReportQuery = {
48
48
  timezone?: string;
49
49
  };
50
50
  /**
51
- * A row of the report: the stored absence with its user, both raw (not transformed).
51
+ * A row of the report: the stored absence with its `user`.
52
52
  */
53
53
  export type AbsenceReportItem = Omit<Absence, 'deletedAt' | 'user'> & {
54
54
  user?: Record<string, unknown>;
@@ -3,8 +3,7 @@ const require_core_BaseCrudApi = require('../../core/BaseCrudApi.cjs');
3
3
 
4
4
  //#region src/apis/answers/AnswersApi.ts
5
5
  /**
6
- * Answers of the evaluation questions. They are written by the bot flow (`SEND_QUESTION`); the
7
- * CRUD routes exist but validate nothing.
6
+ * Answers of the evaluation questions. They are written by the bot flow (`SEND_QUESTION`).
8
7
  *
9
8
  * Permissions: `evaluation.view` to read, `evaluation.create`/`update`/`destroy` to write.
10
9
  */
@@ -44,6 +43,28 @@ var AnswersApi = class extends require_core_BaseCrudApi.BaseCrudApi {
44
43
  exportTxt(query, headers) {
45
44
  return this.client.get(`${this.basePath}/exportation-txt${this.toQueryString(query)}`, headers);
46
45
  }
46
+ /**
47
+ * The {@link exportCsv} export as the whole `Response`, to read its headers (`Content-Type`,
48
+ * `Content-Disposition`) as well as the body. Needs a client with `requestRaw`. Errors are thrown
49
+ * as in `exportCsv`.
50
+ * @permissions overview.evaluation.view
51
+ */
52
+ exportCsvRaw(query, headers) {
53
+ return this.exportResponse("exportation-csv", "exportCsvRaw", query, headers);
54
+ }
55
+ /**
56
+ * The {@link exportTxt} export as the whole `Response`, to read its headers (`Content-Type`,
57
+ * `Content-Disposition`) as well as the body. The Content-Type is `plain/text` (not
58
+ * `text/plain`). Needs a client with `requestRaw`. Errors are thrown as in `exportTxt`.
59
+ * @permissions overview.evaluation.view
60
+ */
61
+ exportTxtRaw(query, headers) {
62
+ return this.exportResponse("exportation-txt", "exportTxtRaw", query, headers);
63
+ }
64
+ async exportResponse(route, method, query, headers) {
65
+ if (!this.client.requestRaw) throw new Error(`${method} needs a client with requestRaw (the answer is read as a Response)`);
66
+ return this.client.requestRaw("GET", `${this.basePath}/${route}${this.toQueryString(query)}`, void 0, headers);
67
+ }
47
68
  };
48
69
 
49
70
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"AnswersApi.cjs","names":["BaseCrudApi"],"sources":["../../../src/apis/answers/AnswersApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type { ListQuery } from '../../core/types'\nimport type {\n Answer,\n AnswersOverview,\n AnswersReportQuery,\n CreateAnswerPayload,\n UpdateAnswerPayload,\n} from './types'\n\n/**\n * Answers of the evaluation questions. They are written by the bot flow (`SEND_QUESTION`); the\n * CRUD routes exist but validate nothing.\n *\n * Permissions: `evaluation.view` to read, `evaluation.create`/`update`/`destroy` to write.\n */\nexport class AnswersApi extends BaseCrudApi<\n Answer,\n CreateAnswerPayload,\n UpdateAnswerPayload,\n ListQuery<Answer>,\n 'OK'\n> {\n constructor(client: ApiClient) {\n super(client, '/answers')\n }\n\n /**\n * Deletes an answer (soft delete). Resolves to `'OK'`.\n * @permissions evaluation.destroy\n */\n override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {\n return super.deleteById(id, headers)\n }\n\n /**\n * Counts the NPS and CSAT answers of closed tickets. An error answers 500 with a string body.\n * @permissions overview.evaluation.view\n */\n overview(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<AnswersOverview> {\n return this.client.get<AnswersOverview>(\n `${this.basePath}/overview${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Exports the answers as CSV (`,`, header in the language of the user, dates in the timezone of\n * the account), sent as the attachment `evaluation-reports.csv`. An unknown `type` answers 400\n * `{ error: 'Tipo de consulta inválido' }`.\n * @permissions overview.evaluation.view\n */\n exportCsv(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<string> {\n return this.client.get<string>(\n `${this.basePath}/exportation-csv${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Exports the answers as text, one block per answer and the count of unanswered ones at the\n * end, sent as the attachment `evaluation-reports.txt` (Content-Type `plain/text`). An unknown\n * `type` answers 400 `{ error: 'Tipo de consulta inválido' }`.\n * @permissions overview.evaluation.view\n */\n exportTxt(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<string> {\n return this.client.get<string>(\n `${this.basePath}/exportation-txt${this.toQueryString(query)}`,\n headers,\n )\n }\n}\n"],"mappings":";;;;;;;;;;AAiBA,IAAa,aAAb,cAAgCA,qCAM9B;CACA,YAAY,QAAmB;AAC7B,QAAM,QAAQ,WAAW;;;;;;CAO3B,AAAS,WAAW,IAAY,SAAiD;AAC/E,SAAO,MAAM,WAAW,IAAI,QAAQ;;;;;;CAOtC,SAAS,OAA4B,SAA4D;AAC/F,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,WAAW,KAAK,cAAc,MAAM,IACrD,QACD;;;;;;;;CASH,UAAU,OAA4B,SAAmD;AACvF,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,kBAAkB,KAAK,cAAc,MAAM,IAC5D,QACD;;;;;;;;CASH,UAAU,OAA4B,SAAmD;AACvF,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,kBAAkB,KAAK,cAAc,MAAM,IAC5D,QACD"}
1
+ {"version":3,"file":"AnswersApi.cjs","names":["BaseCrudApi"],"sources":["../../../src/apis/answers/AnswersApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type { ListQuery } from '../../core/types'\nimport type {\n Answer,\n AnswersOverview,\n AnswersReportQuery,\n CreateAnswerPayload,\n UpdateAnswerPayload,\n} from './types'\n\n/**\n * Answers of the evaluation questions. They are written by the bot flow (`SEND_QUESTION`).\n *\n * Permissions: `evaluation.view` to read, `evaluation.create`/`update`/`destroy` to write.\n */\nexport class AnswersApi extends BaseCrudApi<\n Answer,\n CreateAnswerPayload,\n UpdateAnswerPayload,\n ListQuery<Answer>,\n 'OK'\n> {\n constructor(client: ApiClient) {\n super(client, '/answers')\n }\n\n /**\n * Deletes an answer (soft delete). Resolves to `'OK'`.\n * @permissions evaluation.destroy\n */\n override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {\n return super.deleteById(id, headers)\n }\n\n /**\n * Counts the NPS and CSAT answers of closed tickets. An error answers 500 with a string body.\n * @permissions overview.evaluation.view\n */\n overview(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<AnswersOverview> {\n return this.client.get<AnswersOverview>(\n `${this.basePath}/overview${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Exports the answers as CSV (`,`, header in the language of the user, dates in the timezone of\n * the account), sent as the attachment `evaluation-reports.csv`. An unknown `type` answers 400\n * `{ error: 'Tipo de consulta inválido' }`.\n * @permissions overview.evaluation.view\n */\n exportCsv(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<string> {\n return this.client.get<string>(\n `${this.basePath}/exportation-csv${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Exports the answers as text, one block per answer and the count of unanswered ones at the\n * end, sent as the attachment `evaluation-reports.txt` (Content-Type `plain/text`). An unknown\n * `type` answers 400 `{ error: 'Tipo de consulta inválido' }`.\n * @permissions overview.evaluation.view\n */\n exportTxt(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<string> {\n return this.client.get<string>(\n `${this.basePath}/exportation-txt${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * The {@link exportCsv} export as the whole `Response`, to read its headers (`Content-Type`,\n * `Content-Disposition`) as well as the body. Needs a client with `requestRaw`. Errors are thrown\n * as in `exportCsv`.\n * @permissions overview.evaluation.view\n */\n exportCsvRaw(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<Response> {\n return this.exportResponse('exportation-csv', 'exportCsvRaw', query, headers)\n }\n\n /**\n * The {@link exportTxt} export as the whole `Response`, to read its headers (`Content-Type`,\n * `Content-Disposition`) as well as the body. The Content-Type is `plain/text` (not\n * `text/plain`). Needs a client with `requestRaw`. Errors are thrown as in `exportTxt`.\n * @permissions overview.evaluation.view\n */\n exportTxtRaw(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<Response> {\n return this.exportResponse('exportation-txt', 'exportTxtRaw', query, headers)\n }\n\n private async exportResponse(\n route: 'exportation-csv' | 'exportation-txt',\n method: 'exportCsvRaw' | 'exportTxtRaw',\n query?: AnswersReportQuery,\n headers?: Record<string, string>,\n ): Promise<Response> {\n if (!this.client.requestRaw) {\n throw new Error(`${method} needs a client with requestRaw (the answer is read as a Response)`)\n }\n return this.client.requestRaw(\n 'GET',\n `${this.basePath}/${route}${this.toQueryString(query)}`,\n undefined,\n headers,\n )\n }\n}\n"],"mappings":";;;;;;;;;AAgBA,IAAa,aAAb,cAAgCA,qCAM9B;CACA,YAAY,QAAmB;AAC7B,QAAM,QAAQ,WAAW;;;;;;CAO3B,AAAS,WAAW,IAAY,SAAiD;AAC/E,SAAO,MAAM,WAAW,IAAI,QAAQ;;;;;;CAOtC,SAAS,OAA4B,SAA4D;AAC/F,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,WAAW,KAAK,cAAc,MAAM,IACrD,QACD;;;;;;;;CASH,UAAU,OAA4B,SAAmD;AACvF,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,kBAAkB,KAAK,cAAc,MAAM,IAC5D,QACD;;;;;;;;CASH,UAAU,OAA4B,SAAmD;AACvF,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,kBAAkB,KAAK,cAAc,MAAM,IAC5D,QACD;;;;;;;;CASH,aAAa,OAA4B,SAAqD;AAC5F,SAAO,KAAK,eAAe,mBAAmB,gBAAgB,OAAO,QAAQ;;;;;;;;CAS/E,aAAa,OAA4B,SAAqD;AAC5F,SAAO,KAAK,eAAe,mBAAmB,gBAAgB,OAAO,QAAQ;;CAG/E,MAAc,eACZ,OACA,QACA,OACA,SACmB;AACnB,MAAI,CAAC,KAAK,OAAO,WACf,OAAM,IAAI,MAAM,GAAG,OAAO,oEAAoE;AAEhG,SAAO,KAAK,OAAO,WACjB,OACA,GAAG,KAAK,SAAS,GAAG,QAAQ,KAAK,cAAc,MAAM,IACrD,QACA,QACD"}
@@ -3,8 +3,7 @@ import { BaseCrudApi } from '../../core/BaseCrudApi';
3
3
  import type { ListQuery } from '../../core/types';
4
4
  import type { Answer, AnswersOverview, AnswersReportQuery, CreateAnswerPayload, UpdateAnswerPayload } from './types';
5
5
  /**
6
- * Answers of the evaluation questions. They are written by the bot flow (`SEND_QUESTION`); the
7
- * CRUD routes exist but validate nothing.
6
+ * Answers of the evaluation questions. They are written by the bot flow (`SEND_QUESTION`).
8
7
  *
9
8
  * Permissions: `evaluation.view` to read, `evaluation.create`/`update`/`destroy` to write.
10
9
  */
@@ -34,5 +33,20 @@ export declare class AnswersApi extends BaseCrudApi<Answer, CreateAnswerPayload,
34
33
  * @permissions overview.evaluation.view
35
34
  */
36
35
  exportTxt(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<string>;
36
+ /**
37
+ * The {@link exportCsv} export as the whole `Response`, to read its headers (`Content-Type`,
38
+ * `Content-Disposition`) as well as the body. Needs a client with `requestRaw`. Errors are thrown
39
+ * as in `exportCsv`.
40
+ * @permissions overview.evaluation.view
41
+ */
42
+ exportCsvRaw(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<Response>;
43
+ /**
44
+ * The {@link exportTxt} export as the whole `Response`, to read its headers (`Content-Type`,
45
+ * `Content-Disposition`) as well as the body. The Content-Type is `plain/text` (not
46
+ * `text/plain`). Needs a client with `requestRaw`. Errors are thrown as in `exportTxt`.
47
+ * @permissions overview.evaluation.view
48
+ */
49
+ exportTxtRaw(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<Response>;
50
+ private exportResponse;
37
51
  }
38
52
  //# sourceMappingURL=AnswersApi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnswersApi.d.ts","sourceRoot":"","sources":["../../../src/apis/answers/AnswersApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EACV,MAAM,EACN,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,SAAS,CAAA;AAEhB;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,WAAW,CACzC,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,CAAC,MAAM,CAAC,EACjB,IAAI,CACL;gBACa,MAAM,EAAE,SAAS;IAI7B;;;OAGG;IACM,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhF;;;OAGG;IACH,QAAQ,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Ae,CAAC;IAOhG;;;;;OAKG;IACH,SAAS,CAAC,KAAK,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAOxF;;;;;OAKG;IACH,SAAS,CAAC,KAAK,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAOxF;;;;;OAKG;IACH,YAAY,CAAC,KAAK,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI7F;;;;;OAKG;IACH,YAAY,CAAC,KAAK,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;YAI/E,cAAc;CAgB7B"}
@@ -2,8 +2,7 @@ import { BaseCrudApi } from "../../core/BaseCrudApi.mjs";
2
2
 
3
3
  //#region src/apis/answers/AnswersApi.ts
4
4
  /**
5
- * Answers of the evaluation questions. They are written by the bot flow (`SEND_QUESTION`); the
6
- * CRUD routes exist but validate nothing.
5
+ * Answers of the evaluation questions. They are written by the bot flow (`SEND_QUESTION`).
7
6
  *
8
7
  * Permissions: `evaluation.view` to read, `evaluation.create`/`update`/`destroy` to write.
9
8
  */
@@ -43,6 +42,28 @@ var AnswersApi = class extends BaseCrudApi {
43
42
  exportTxt(query, headers) {
44
43
  return this.client.get(`${this.basePath}/exportation-txt${this.toQueryString(query)}`, headers);
45
44
  }
45
+ /**
46
+ * The {@link exportCsv} export as the whole `Response`, to read its headers (`Content-Type`,
47
+ * `Content-Disposition`) as well as the body. Needs a client with `requestRaw`. Errors are thrown
48
+ * as in `exportCsv`.
49
+ * @permissions overview.evaluation.view
50
+ */
51
+ exportCsvRaw(query, headers) {
52
+ return this.exportResponse("exportation-csv", "exportCsvRaw", query, headers);
53
+ }
54
+ /**
55
+ * The {@link exportTxt} export as the whole `Response`, to read its headers (`Content-Type`,
56
+ * `Content-Disposition`) as well as the body. The Content-Type is `plain/text` (not
57
+ * `text/plain`). Needs a client with `requestRaw`. Errors are thrown as in `exportTxt`.
58
+ * @permissions overview.evaluation.view
59
+ */
60
+ exportTxtRaw(query, headers) {
61
+ return this.exportResponse("exportation-txt", "exportTxtRaw", query, headers);
62
+ }
63
+ async exportResponse(route, method, query, headers) {
64
+ if (!this.client.requestRaw) throw new Error(`${method} needs a client with requestRaw (the answer is read as a Response)`);
65
+ return this.client.requestRaw("GET", `${this.basePath}/${route}${this.toQueryString(query)}`, void 0, headers);
66
+ }
46
67
  };
47
68
 
48
69
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"AnswersApi.mjs","names":[],"sources":["../../../src/apis/answers/AnswersApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type { ListQuery } from '../../core/types'\nimport type {\n Answer,\n AnswersOverview,\n AnswersReportQuery,\n CreateAnswerPayload,\n UpdateAnswerPayload,\n} from './types'\n\n/**\n * Answers of the evaluation questions. They are written by the bot flow (`SEND_QUESTION`); the\n * CRUD routes exist but validate nothing.\n *\n * Permissions: `evaluation.view` to read, `evaluation.create`/`update`/`destroy` to write.\n */\nexport class AnswersApi extends BaseCrudApi<\n Answer,\n CreateAnswerPayload,\n UpdateAnswerPayload,\n ListQuery<Answer>,\n 'OK'\n> {\n constructor(client: ApiClient) {\n super(client, '/answers')\n }\n\n /**\n * Deletes an answer (soft delete). Resolves to `'OK'`.\n * @permissions evaluation.destroy\n */\n override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {\n return super.deleteById(id, headers)\n }\n\n /**\n * Counts the NPS and CSAT answers of closed tickets. An error answers 500 with a string body.\n * @permissions overview.evaluation.view\n */\n overview(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<AnswersOverview> {\n return this.client.get<AnswersOverview>(\n `${this.basePath}/overview${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Exports the answers as CSV (`,`, header in the language of the user, dates in the timezone of\n * the account), sent as the attachment `evaluation-reports.csv`. An unknown `type` answers 400\n * `{ error: 'Tipo de consulta inválido' }`.\n * @permissions overview.evaluation.view\n */\n exportCsv(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<string> {\n return this.client.get<string>(\n `${this.basePath}/exportation-csv${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Exports the answers as text, one block per answer and the count of unanswered ones at the\n * end, sent as the attachment `evaluation-reports.txt` (Content-Type `plain/text`). An unknown\n * `type` answers 400 `{ error: 'Tipo de consulta inválido' }`.\n * @permissions overview.evaluation.view\n */\n exportTxt(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<string> {\n return this.client.get<string>(\n `${this.basePath}/exportation-txt${this.toQueryString(query)}`,\n headers,\n )\n }\n}\n"],"mappings":";;;;;;;;;AAiBA,IAAa,aAAb,cAAgC,YAM9B;CACA,YAAY,QAAmB;AAC7B,QAAM,QAAQ,WAAW;;;;;;CAO3B,AAAS,WAAW,IAAY,SAAiD;AAC/E,SAAO,MAAM,WAAW,IAAI,QAAQ;;;;;;CAOtC,SAAS,OAA4B,SAA4D;AAC/F,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,WAAW,KAAK,cAAc,MAAM,IACrD,QACD;;;;;;;;CASH,UAAU,OAA4B,SAAmD;AACvF,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,kBAAkB,KAAK,cAAc,MAAM,IAC5D,QACD;;;;;;;;CASH,UAAU,OAA4B,SAAmD;AACvF,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,kBAAkB,KAAK,cAAc,MAAM,IAC5D,QACD"}
1
+ {"version":3,"file":"AnswersApi.mjs","names":[],"sources":["../../../src/apis/answers/AnswersApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type { ListQuery } from '../../core/types'\nimport type {\n Answer,\n AnswersOverview,\n AnswersReportQuery,\n CreateAnswerPayload,\n UpdateAnswerPayload,\n} from './types'\n\n/**\n * Answers of the evaluation questions. They are written by the bot flow (`SEND_QUESTION`).\n *\n * Permissions: `evaluation.view` to read, `evaluation.create`/`update`/`destroy` to write.\n */\nexport class AnswersApi extends BaseCrudApi<\n Answer,\n CreateAnswerPayload,\n UpdateAnswerPayload,\n ListQuery<Answer>,\n 'OK'\n> {\n constructor(client: ApiClient) {\n super(client, '/answers')\n }\n\n /**\n * Deletes an answer (soft delete). Resolves to `'OK'`.\n * @permissions evaluation.destroy\n */\n override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {\n return super.deleteById(id, headers)\n }\n\n /**\n * Counts the NPS and CSAT answers of closed tickets. An error answers 500 with a string body.\n * @permissions overview.evaluation.view\n */\n overview(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<AnswersOverview> {\n return this.client.get<AnswersOverview>(\n `${this.basePath}/overview${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Exports the answers as CSV (`,`, header in the language of the user, dates in the timezone of\n * the account), sent as the attachment `evaluation-reports.csv`. An unknown `type` answers 400\n * `{ error: 'Tipo de consulta inválido' }`.\n * @permissions overview.evaluation.view\n */\n exportCsv(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<string> {\n return this.client.get<string>(\n `${this.basePath}/exportation-csv${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Exports the answers as text, one block per answer and the count of unanswered ones at the\n * end, sent as the attachment `evaluation-reports.txt` (Content-Type `plain/text`). An unknown\n * `type` answers 400 `{ error: 'Tipo de consulta inválido' }`.\n * @permissions overview.evaluation.view\n */\n exportTxt(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<string> {\n return this.client.get<string>(\n `${this.basePath}/exportation-txt${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * The {@link exportCsv} export as the whole `Response`, to read its headers (`Content-Type`,\n * `Content-Disposition`) as well as the body. Needs a client with `requestRaw`. Errors are thrown\n * as in `exportCsv`.\n * @permissions overview.evaluation.view\n */\n exportCsvRaw(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<Response> {\n return this.exportResponse('exportation-csv', 'exportCsvRaw', query, headers)\n }\n\n /**\n * The {@link exportTxt} export as the whole `Response`, to read its headers (`Content-Type`,\n * `Content-Disposition`) as well as the body. The Content-Type is `plain/text` (not\n * `text/plain`). Needs a client with `requestRaw`. Errors are thrown as in `exportTxt`.\n * @permissions overview.evaluation.view\n */\n exportTxtRaw(query?: AnswersReportQuery, headers?: Record<string, string>): Promise<Response> {\n return this.exportResponse('exportation-txt', 'exportTxtRaw', query, headers)\n }\n\n private async exportResponse(\n route: 'exportation-csv' | 'exportation-txt',\n method: 'exportCsvRaw' | 'exportTxtRaw',\n query?: AnswersReportQuery,\n headers?: Record<string, string>,\n ): Promise<Response> {\n if (!this.client.requestRaw) {\n throw new Error(`${method} needs a client with requestRaw (the answer is read as a Response)`)\n }\n return this.client.requestRaw(\n 'GET',\n `${this.basePath}/${route}${this.toQueryString(query)}`,\n undefined,\n headers,\n )\n }\n}\n"],"mappings":";;;;;;;;AAgBA,IAAa,aAAb,cAAgC,YAM9B;CACA,YAAY,QAAmB;AAC7B,QAAM,QAAQ,WAAW;;;;;;CAO3B,AAAS,WAAW,IAAY,SAAiD;AAC/E,SAAO,MAAM,WAAW,IAAI,QAAQ;;;;;;CAOtC,SAAS,OAA4B,SAA4D;AAC/F,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,WAAW,KAAK,cAAc,MAAM,IACrD,QACD;;;;;;;;CASH,UAAU,OAA4B,SAAmD;AACvF,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,kBAAkB,KAAK,cAAc,MAAM,IAC5D,QACD;;;;;;;;CASH,UAAU,OAA4B,SAAmD;AACvF,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,kBAAkB,KAAK,cAAc,MAAM,IAC5D,QACD;;;;;;;;CASH,aAAa,OAA4B,SAAqD;AAC5F,SAAO,KAAK,eAAe,mBAAmB,gBAAgB,OAAO,QAAQ;;;;;;;;CAS/E,aAAa,OAA4B,SAAqD;AAC5F,SAAO,KAAK,eAAe,mBAAmB,gBAAgB,OAAO,QAAQ;;CAG/E,MAAc,eACZ,OACA,QACA,OACA,SACmB;AACnB,MAAI,CAAC,KAAK,OAAO,WACf,OAAM,IAAI,MAAM,GAAG,OAAO,oEAAoE;AAEhG,SAAO,KAAK,OAAO,WACjB,OACA,GAAG,KAAK,SAAS,GAAG,QAAQ,KAAK,cAAc,MAAM,IACrD,QACA,QACD"}
@@ -23,8 +23,7 @@ export type Answer = {
23
23
  /** @deprecated The route drops every `include` (empty whitelist). */
24
24
  export type AnswerRelationships = 'question' | 'ticket';
25
25
  /**
26
- * The route validates nothing: not the question, the ticket nor their account, and the answer is
27
- * saved even for an open ticket.
26
+ * The answer of a question of the account to a ticket of the account (an open ticket included).
28
27
  */
29
28
  export type CreateAnswerPayload = {
30
29
  text: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/apis/answers/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAE9C,MAAM,MAAM,MAAM,GAAG;IACnB,EAAE,EAAE,MAAM,CAAA;IACV;;;OAGG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,WAAW,EAAE,OAAO,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,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AAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAA;CACX,CAAA;AAED,uGAAuG;AACvG,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,CAAA;AAE9E,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACrD,IAAI,EAAE;QACJ,GAAG,EAAE,kBAAkB,CAAA;QACvB,mCAAmC;QACnC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QACjD,2EAA2E;QAC3E,uBAAuB,CAAC,EAAE,OAAO,CAAA;QACjC,mEAAmE;QACnE,MAAM,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;KACrD,CAAA;CACF,CAAA"}
@@ -6,9 +6,6 @@ const require_core_BaseApi = require('../../core/BaseApi.cjs');
6
6
  * Bots. The list route always paginates (`paginate: false` is ignored), so this class does not
7
7
  * extend `BaseCrudApi`. The contexts travel as a list (`BotContextInput` / `BotParsedContext`),
8
8
  * not as the stored map that `BotVersionsApi` serves.
9
- *
10
- * `GET /bots/:id/errors/export` is not exposed: it answers a binary xlsx, and `ApiClient` only
11
- * handles JSON/text bodies.
12
9
  */
13
10
  var BotsApi = class extends require_core_BaseApi.BaseApi {
14
11
  basePath = "/bots";
@@ -74,9 +71,22 @@ var BotsApi = class extends require_core_BaseApi.BaseApi {
74
71
  return this.client.get(`${this.basePath}/${id}/errors${this.toQueryString(query)}`, headers);
75
72
  }
76
73
  /**
74
+ * Exports the failed steps of the bot runs of the last 30 days as an xlsx workbook (binary).
75
+ * Needs a client with `requestRaw`. A period without errors answers 400 `No errors found to
76
+ * export`; an unknown bot answers 404.
77
+ * @permissions bots.view
78
+ */
79
+ async exportErrors(id, headers) {
80
+ if (!this.client.requestRaw) throw new Error("exportErrors needs a client with requestRaw (the answer is a binary xlsx)");
81
+ return (await this.client.requestRaw("GET", `${this.basePath}/${id}/errors/export`, void 0, headers)).arrayBuffer();
82
+ }
83
+ /**
77
84
  * Fires the `API_SIGNAL` trigger of the bot for the contact, with an optional `flag` (read by
78
85
  * the `api_signal_flag` condition). Asynchronous: always resolves with no content, and the
79
- * worker only runs it when the contact has an open ticket.
86
+ * worker only runs it when the contact has an open ticket. The worker runs the flow of `botId`
87
+ * on the engine of the bot of the contact's connection (see `BotSettings.botCreatedVersion`; when
88
+ * the connection has no bot, the engine of the `botId` bot). `triggerSignal` does not reach the
89
+ * bot simulator (there the `API_SIGNAL` path is picked by hand, with no `flag`).
80
90
  * @permissions bots.view
81
91
  */
82
92
  triggerSignal(botId, contactId, flag, headers) {
@@ -94,9 +104,8 @@ var BotsApi = class extends require_core_BaseApi.BaseApi {
94
104
  }
95
105
  /**
96
106
  * Generates a prompt for an AI agent of the bot. COSTS one AI agent credit of the account and
97
- * calls OpenAI. No permission check: any authenticated user. A missing field answers 400; an
98
- * option outside the lists, or the AI agent limit of the account reached
99
- * (`Agent limit reached`), answers 500.
107
+ * calls OpenAI. A missing field answers 400; an option outside the lists, or the AI agent limit
108
+ * of the account reached (`Agent limit reached`), answers 500.
100
109
  */
101
110
  suggestAgentPrompt(body, headers) {
102
111
  return this.client.post(`${this.basePath}/suggest-agent-prompt`, body, headers);
@@ -1 +1 @@
1
- {"version":3,"file":"BotsApi.cjs","names":["BaseApi"],"sources":["../../../src/apis/bots/BotsApi.ts"],"sourcesContent":["import { BaseApi } from '../../core/BaseApi'\nimport type {\n GetByIdQuery,\n HasCreate,\n HasDeleteById,\n HasGetById,\n HasUpdateById,\n ListQuery,\n Paginated,\n} from '../../core/types'\nimport type {\n Bot,\n BotErrorsQuery,\n BotHistory,\n CreateBotPayload,\n SuggestAgentPromptPayload,\n UpdateBotPayload,\n} from './types'\n\n/**\n * Bots. The list route always paginates (`paginate: false` is ignored), so this class does not\n * extend `BaseCrudApi`. The contexts travel as a list (`BotContextInput` / `BotParsedContext`),\n * not as the stored map that `BotVersionsApi` serves.\n *\n * `GET /bots/:id/errors/export` is not exposed: it answers a binary xlsx, and `ApiClient` only\n * handles JSON/text bodies.\n */\nexport class BotsApi\n extends BaseApi\n implements\n HasGetById<Bot>,\n HasCreate<Bot, CreateBotPayload>,\n HasUpdateById<Bot, UpdateBotPayload>,\n HasDeleteById<'OK' | false>\n{\n public readonly basePath = '/bots'\n\n /**\n * Lists the bots of the account. Always paginated, even with `paginate: false`.\n * @permissions bots.view\n */\n getMany(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Paginated<Bot>> {\n return this.client.get<Paginated<Bot>>(`${this.basePath}${this.toQueryString(query)}`, headers)\n }\n\n /**\n * Returns the first bot matching the query, or `null` when none match.\n * @permissions bots.view\n */\n async getOne(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Bot | null> {\n const page = await this.getMany({ ...query, perPage: 1, page: 1 }, headers)\n return page?.data?.[0] ?? null\n }\n\n /**\n * Returns a bot by ID, with `defaultContexts` (the stored map, as a JSON string). An unknown id\n * answers 500, not an empty body.\n * @permissions bots.view\n */\n getById(id: string, query?: GetByIdQuery<Bot>, headers?: Record<string, string>): Promise<Bot> {\n return this.client.get<Bot>(`${this.basePath}/${id}${this.toQueryString(query)}`, headers)\n }\n\n /**\n * Creates a bot and its first version (published, or a draft with `isDraft`). A duplicate name\n * answers 409, unless the account allows duplicate names. Send `flowJson` with `edges`, or the\n * bot never sends a message (SD-2323).\n * @permissions bots.create\n */\n create(body: CreateBotPayload, headers?: Record<string, string>): Promise<Bot> {\n return this.client.post<Bot, CreateBotPayload>(this.basePath, body, headers)\n }\n\n /**\n * Saves the flow (publishing a version, or into the draft with `isDraft`), or only renames the\n * bot with `onlyUpdateBotName`. Resolves to the bot with `defaultContexts` as an object.\n * @permissions bots.view OR bots.update\n */\n updateById(id: string, body: UpdateBotPayload, headers?: Record<string, string>): Promise<Bot> {\n return this.client.put<Bot, UpdateBotPayload>(`${this.basePath}/${id}`, body, headers)\n }\n\n /**\n * Deletes a bot and its versions (hard delete). Today resolves to `false` even when the bot was\n * deleted (the backend destroy returns nothing); it becomes `'OK'` once the destroy returns the\n * bot, as in the other routes. Do not read the result as success or failure. An unknown id\n * answers 500.\n * @permissions bots.view OR bots.destroy\n */\n deleteById(id: string, headers?: Record<string, string>): Promise<'OK' | false> {\n return this.client.delete<'OK' | false>(`${this.basePath}/${id}`, headers)\n }\n\n /**\n * Lists the failed steps of the bot runs, newest first by default. An unknown bot answers an\n * empty page.\n * @permissions bots.view\n */\n getErrors(\n id: string,\n query?: BotErrorsQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<BotHistory>> {\n return this.client.get<Paginated<BotHistory>>(\n `${this.basePath}/${id}/errors${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Fires the `API_SIGNAL` trigger of the bot for the contact, with an optional `flag` (read by\n * the `api_signal_flag` condition). Asynchronous: always resolves with no content, and the\n * worker only runs it when the contact has an open ticket.\n * @permissions bots.view\n */\n triggerSignal(\n botId: string,\n contactId: string,\n flag?: string,\n headers?: Record<string, string>,\n ): Promise<void> {\n return this.client.post<void, { flag: string } | undefined>(\n `${this.basePath}/${botId}/trigger-signal/${contactId}`,\n flag === undefined ? undefined : { flag },\n headers,\n )\n }\n\n /**\n * Answers a pending asynchronous `HTTP_REQUEST` action: `body` becomes the response the bot\n * reads. Resolves with no content. An unknown history answers 404; a history that is not\n * `PENDING`, or of another bot, answers 400. JSON bodies only (the route also takes text, XML\n * and CSV), up to 250 KB.\n * @permissions bots.view\n */\n requestCallback(\n id: string,\n pendingRequestId: string,\n body: unknown,\n headers?: Record<string, string>,\n ): Promise<void> {\n return this.client.post<void, unknown>(\n `${this.basePath}/${id}/request-callback/${pendingRequestId}`,\n body,\n headers,\n )\n }\n\n /**\n * Generates a prompt for an AI agent of the bot. COSTS one AI agent credit of the account and\n * calls OpenAI. No permission check: any authenticated user. A missing field answers 400; an\n * option outside the lists, or the AI agent limit of the account reached\n * (`Agent limit reached`), answers 500.\n */\n suggestAgentPrompt(\n body: SuggestAgentPromptPayload,\n headers?: Record<string, string>,\n ): Promise<string> {\n return this.client.post<string, SuggestAgentPromptPayload>(\n `${this.basePath}/suggest-agent-prompt`,\n body,\n headers,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,IAAa,UAAb,cACUA,6BAMV;CACE,AAAgB,WAAW;;;;;CAM3B,QAAQ,OAAwB,SAA2D;AACzF,SAAO,KAAK,OAAO,IAAoB,GAAG,KAAK,WAAW,KAAK,cAAc,MAAM,IAAI,QAAQ;;;;;;CAOjG,MAAM,OAAO,OAAwB,SAAuD;AAE1F,UADa,MAAM,KAAK,QAAQ;GAAE,GAAG;GAAO,SAAS;GAAG,MAAM;GAAG,EAAE,QAAQ,GAC9D,OAAO,MAAM;;;;;;;CAQ5B,QAAQ,IAAY,OAA2B,SAAgD;AAC7F,SAAO,KAAK,OAAO,IAAS,GAAG,KAAK,SAAS,GAAG,KAAK,KAAK,cAAc,MAAM,IAAI,QAAQ;;;;;;;;CAS5F,OAAO,MAAwB,SAAgD;AAC7E,SAAO,KAAK,OAAO,KAA4B,KAAK,UAAU,MAAM,QAAQ;;;;;;;CAQ9E,WAAW,IAAY,MAAwB,SAAgD;AAC7F,SAAO,KAAK,OAAO,IAA2B,GAAG,KAAK,SAAS,GAAG,MAAM,MAAM,QAAQ;;;;;;;;;CAUxF,WAAW,IAAY,SAAyD;AAC9E,SAAO,KAAK,OAAO,OAAqB,GAAG,KAAK,SAAS,GAAG,MAAM,QAAQ;;;;;;;CAQ5E,UACE,IACA,OACA,SACgC;AAChC,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,GAAG,GAAG,SAAS,KAAK,cAAc,MAAM,IACzD,QACD;;;;;;;;CASH,cACE,OACA,WACA,MACA,SACe;AACf,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,GAAG,MAAM,kBAAkB,aAC5C,SAAS,SAAY,SAAY,EAAE,MAAM,EACzC,QACD;;;;;;;;;CAUH,gBACE,IACA,kBACA,MACA,SACe;AACf,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,GAAG,GAAG,oBAAoB,oBAC3C,MACA,QACD;;;;;;;;CASH,mBACE,MACA,SACiB;AACjB,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,wBACjB,MACA,QACD"}
1
+ {"version":3,"file":"BotsApi.cjs","names":["BaseApi"],"sources":["../../../src/apis/bots/BotsApi.ts"],"sourcesContent":["import { BaseApi } from '../../core/BaseApi'\nimport type {\n GetByIdQuery,\n HasCreate,\n HasDeleteById,\n HasGetById,\n HasUpdateById,\n ListQuery,\n Paginated,\n} from '../../core/types'\nimport type {\n Bot,\n BotErrorsQuery,\n BotHistory,\n CreateBotPayload,\n SuggestAgentPromptPayload,\n UpdateBotPayload,\n} from './types'\n\n/**\n * Bots. The list route always paginates (`paginate: false` is ignored), so this class does not\n * extend `BaseCrudApi`. The contexts travel as a list (`BotContextInput` / `BotParsedContext`),\n * not as the stored map that `BotVersionsApi` serves.\n */\nexport class BotsApi\n extends BaseApi\n implements\n HasGetById<Bot>,\n HasCreate<Bot, CreateBotPayload>,\n HasUpdateById<Bot, UpdateBotPayload>,\n HasDeleteById<'OK' | false>\n{\n public readonly basePath = '/bots'\n\n /**\n * Lists the bots of the account. Always paginated, even with `paginate: false`.\n * @permissions bots.view\n */\n getMany(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Paginated<Bot>> {\n return this.client.get<Paginated<Bot>>(`${this.basePath}${this.toQueryString(query)}`, headers)\n }\n\n /**\n * Returns the first bot matching the query, or `null` when none match.\n * @permissions bots.view\n */\n async getOne(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Bot | null> {\n const page = await this.getMany({ ...query, perPage: 1, page: 1 }, headers)\n return page?.data?.[0] ?? null\n }\n\n /**\n * Returns a bot by ID, with `defaultContexts` (the stored map, as a JSON string). An unknown id\n * answers 500, not an empty body.\n * @permissions bots.view\n */\n getById(id: string, query?: GetByIdQuery<Bot>, headers?: Record<string, string>): Promise<Bot> {\n return this.client.get<Bot>(`${this.basePath}/${id}${this.toQueryString(query)}`, headers)\n }\n\n /**\n * Creates a bot and its first version (published, or a draft with `isDraft`). A duplicate name\n * answers 409, unless the account allows duplicate names. Send `flowJson` with `edges`, or the\n * bot never sends a message (SD-2323).\n * @permissions bots.create\n */\n create(body: CreateBotPayload, headers?: Record<string, string>): Promise<Bot> {\n return this.client.post<Bot, CreateBotPayload>(this.basePath, body, headers)\n }\n\n /**\n * Saves the flow (publishing a version, or into the draft with `isDraft`), or only renames the\n * bot with `onlyUpdateBotName`. Resolves to the bot with `defaultContexts` as an object.\n * @permissions bots.view OR bots.update\n */\n updateById(id: string, body: UpdateBotPayload, headers?: Record<string, string>): Promise<Bot> {\n return this.client.put<Bot, UpdateBotPayload>(`${this.basePath}/${id}`, body, headers)\n }\n\n /**\n * Deletes a bot and its versions (hard delete). Today resolves to `false` even when the bot was\n * deleted (the backend destroy returns nothing); it becomes `'OK'` once the destroy returns the\n * bot, as in the other routes. Do not read the result as success or failure. An unknown id\n * answers 500.\n * @permissions bots.view OR bots.destroy\n */\n deleteById(id: string, headers?: Record<string, string>): Promise<'OK' | false> {\n return this.client.delete<'OK' | false>(`${this.basePath}/${id}`, headers)\n }\n\n /**\n * Lists the failed steps of the bot runs, newest first by default. An unknown bot answers an\n * empty page.\n * @permissions bots.view\n */\n getErrors(\n id: string,\n query?: BotErrorsQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<BotHistory>> {\n return this.client.get<Paginated<BotHistory>>(\n `${this.basePath}/${id}/errors${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Exports the failed steps of the bot runs of the last 30 days as an xlsx workbook (binary).\n * Needs a client with `requestRaw`. A period without errors answers 400 `No errors found to\n * export`; an unknown bot answers 404.\n * @permissions bots.view\n */\n async exportErrors(id: string, headers?: Record<string, string>): Promise<ArrayBuffer> {\n if (!this.client.requestRaw) {\n throw new Error('exportErrors needs a client with requestRaw (the answer is a binary xlsx)')\n }\n const response = await this.client.requestRaw(\n 'GET',\n `${this.basePath}/${id}/errors/export`,\n undefined,\n headers,\n )\n return response.arrayBuffer()\n }\n\n /**\n * Fires the `API_SIGNAL` trigger of the bot for the contact, with an optional `flag` (read by\n * the `api_signal_flag` condition). Asynchronous: always resolves with no content, and the\n * worker only runs it when the contact has an open ticket. The worker runs the flow of `botId`\n * on the engine of the bot of the contact's connection (see `BotSettings.botCreatedVersion`; when\n * the connection has no bot, the engine of the `botId` bot). `triggerSignal` does not reach the\n * bot simulator (there the `API_SIGNAL` path is picked by hand, with no `flag`).\n * @permissions bots.view\n */\n triggerSignal(\n botId: string,\n contactId: string,\n flag?: string,\n headers?: Record<string, string>,\n ): Promise<void> {\n return this.client.post<void, { flag: string } | undefined>(\n `${this.basePath}/${botId}/trigger-signal/${contactId}`,\n flag === undefined ? undefined : { flag },\n headers,\n )\n }\n\n /**\n * Answers a pending asynchronous `HTTP_REQUEST` action: `body` becomes the response the bot\n * reads. Resolves with no content. An unknown history answers 404; a history that is not\n * `PENDING`, or of another bot, answers 400. JSON bodies only (the route also takes text, XML\n * and CSV), up to 250 KB.\n * @permissions bots.view\n */\n requestCallback(\n id: string,\n pendingRequestId: string,\n body: unknown,\n headers?: Record<string, string>,\n ): Promise<void> {\n return this.client.post<void, unknown>(\n `${this.basePath}/${id}/request-callback/${pendingRequestId}`,\n body,\n headers,\n )\n }\n\n /**\n * Generates a prompt for an AI agent of the bot. COSTS one AI agent credit of the account and\n * calls OpenAI. A missing field answers 400; an option outside the lists, or the AI agent limit\n * of the account reached (`Agent limit reached`), answers 500.\n */\n suggestAgentPrompt(\n body: SuggestAgentPromptPayload,\n headers?: Record<string, string>,\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E,OACA,WACA,MACA,SACe;AACf,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,GAAG,MAAM,kBAAkB,aAC5C,SAAS,SAAY,SAAY,EAAE,MAAM,EACzC,QACD;;;;;;;;;CAUH,gBACE,IACA,kBACA,MACA,SACe;AACf,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,GAAG,GAAG,oBAAoB,oBAC3C,MACA,QACD;;;;;;;CAQH,mBACE,MACA,SACiB;AACjB,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,wBACjB,MACA,QACD"}
@@ -5,9 +5,6 @@ import type { Bot, BotErrorsQuery, BotHistory, CreateBotPayload, SuggestAgentPro
5
5
  * Bots. The list route always paginates (`paginate: false` is ignored), so this class does not
6
6
  * extend `BaseCrudApi`. The contexts travel as a list (`BotContextInput` / `BotParsedContext`),
7
7
  * not as the stored map that `BotVersionsApi` serves.
8
- *
9
- * `GET /bots/:id/errors/export` is not exposed: it answers a binary xlsx, and `ApiClient` only
10
- * handles JSON/text bodies.
11
8
  */
12
9
  export declare class BotsApi extends BaseApi implements HasGetById<Bot>, HasCreate<Bot, CreateBotPayload>, HasUpdateById<Bot, UpdateBotPayload>, HasDeleteById<'OK' | false> {
13
10
  readonly basePath = "/bots";
@@ -54,10 +51,20 @@ export declare class BotsApi extends BaseApi implements HasGetById<Bot>, HasCrea
54
51
  * @permissions bots.view
55
52
  */
56
53
  getErrors(id: string, query?: BotErrorsQuery, headers?: Record<string, string>): Promise<Paginated<BotHistory>>;
54
+ /**
55
+ * Exports the failed steps of the bot runs of the last 30 days as an xlsx workbook (binary).
56
+ * Needs a client with `requestRaw`. A period without errors answers 400 `No errors found to
57
+ * export`; an unknown bot answers 404.
58
+ * @permissions bots.view
59
+ */
60
+ exportErrors(id: string, headers?: Record<string, string>): Promise<ArrayBuffer>;
57
61
  /**
58
62
  * Fires the `API_SIGNAL` trigger of the bot for the contact, with an optional `flag` (read by
59
63
  * the `api_signal_flag` condition). Asynchronous: always resolves with no content, and the
60
- * worker only runs it when the contact has an open ticket.
64
+ * worker only runs it when the contact has an open ticket. The worker runs the flow of `botId`
65
+ * on the engine of the bot of the contact's connection (see `BotSettings.botCreatedVersion`; when
66
+ * the connection has no bot, the engine of the `botId` bot). `triggerSignal` does not reach the
67
+ * bot simulator (there the `API_SIGNAL` path is picked by hand, with no `flag`).
61
68
  * @permissions bots.view
62
69
  */
63
70
  triggerSignal(botId: string, contactId: string, flag?: string, headers?: Record<string, string>): Promise<void>;
@@ -71,9 +78,8 @@ export declare class BotsApi extends BaseApi implements HasGetById<Bot>, HasCrea
71
78
  requestCallback(id: string, pendingRequestId: string, body: unknown, headers?: Record<string, string>): Promise<void>;
72
79
  /**
73
80
  * Generates a prompt for an AI agent of the bot. COSTS one AI agent credit of the account and
74
- * calls OpenAI. No permission check: any authenticated user. A missing field answers 400; an
75
- * option outside the lists, or the AI agent limit of the account reached
76
- * (`Agent limit reached`), answers 500.
81
+ * calls OpenAI. A missing field answers 400; an option outside the lists, or the AI agent limit
82
+ * of the account reached (`Agent limit reached`), answers 500.
77
83
  */
78
84
  suggestAgentPrompt(body: SuggestAgentPromptPayload, headers?: Record<string, string>): Promise<string>;
79
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BotsApi.d.ts","sourceRoot":"","sources":["../../../src/apis/bots/BotsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,aAAa,EACb,SAAS,EACT,SAAS,EACV,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EACV,GAAG,EACH,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAEhB;;;;;;;GAOG;AACH,qBAAa,OACX,SAAQ,OACR,YACE,UAAU,CAAC,GAAG,CAAC,EACf,SAAS,CA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AAU,CAAC,CAAC;IAOjC;;;;;OAKG;IACG,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAatF;;;;;;;;OAQG;IACH,aAAa,CACX,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,IAAI,CAAC;IAQhB;;;;;;OAMG;IACH,eAAe,CACb,EAAE,EAAE,MAAM,EACV,gBAAgB,EAAE,MAAM,EACxB,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,IAAI,CAAC;IAQhB;;;;OAIG;IACH,kBAAkB,CAChB,IAAI,EAAE,yBAAyB,EAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC;CAOnB"}
@@ -5,9 +5,6 @@ import { BaseApi } from "../../core/BaseApi.mjs";
5
5
  * Bots. The list route always paginates (`paginate: false` is ignored), so this class does not
6
6
  * extend `BaseCrudApi`. The contexts travel as a list (`BotContextInput` / `BotParsedContext`),
7
7
  * not as the stored map that `BotVersionsApi` serves.
8
- *
9
- * `GET /bots/:id/errors/export` is not exposed: it answers a binary xlsx, and `ApiClient` only
10
- * handles JSON/text bodies.
11
8
  */
12
9
  var BotsApi = class extends BaseApi {
13
10
  basePath = "/bots";
@@ -73,9 +70,22 @@ var BotsApi = class extends BaseApi {
73
70
  return this.client.get(`${this.basePath}/${id}/errors${this.toQueryString(query)}`, headers);
74
71
  }
75
72
  /**
73
+ * Exports the failed steps of the bot runs of the last 30 days as an xlsx workbook (binary).
74
+ * Needs a client with `requestRaw`. A period without errors answers 400 `No errors found to
75
+ * export`; an unknown bot answers 404.
76
+ * @permissions bots.view
77
+ */
78
+ async exportErrors(id, headers) {
79
+ if (!this.client.requestRaw) throw new Error("exportErrors needs a client with requestRaw (the answer is a binary xlsx)");
80
+ return (await this.client.requestRaw("GET", `${this.basePath}/${id}/errors/export`, void 0, headers)).arrayBuffer();
81
+ }
82
+ /**
76
83
  * Fires the `API_SIGNAL` trigger of the bot for the contact, with an optional `flag` (read by
77
84
  * the `api_signal_flag` condition). Asynchronous: always resolves with no content, and the
78
- * worker only runs it when the contact has an open ticket.
85
+ * worker only runs it when the contact has an open ticket. The worker runs the flow of `botId`
86
+ * on the engine of the bot of the contact's connection (see `BotSettings.botCreatedVersion`; when
87
+ * the connection has no bot, the engine of the `botId` bot). `triggerSignal` does not reach the
88
+ * bot simulator (there the `API_SIGNAL` path is picked by hand, with no `flag`).
79
89
  * @permissions bots.view
80
90
  */
81
91
  triggerSignal(botId, contactId, flag, headers) {
@@ -93,9 +103,8 @@ var BotsApi = class extends BaseApi {
93
103
  }
94
104
  /**
95
105
  * Generates a prompt for an AI agent of the bot. COSTS one AI agent credit of the account and
96
- * calls OpenAI. No permission check: any authenticated user. A missing field answers 400; an
97
- * option outside the lists, or the AI agent limit of the account reached
98
- * (`Agent limit reached`), answers 500.
106
+ * calls OpenAI. A missing field answers 400; an option outside the lists, or the AI agent limit
107
+ * of the account reached (`Agent limit reached`), answers 500.
99
108
  */
100
109
  suggestAgentPrompt(body, headers) {
101
110
  return this.client.post(`${this.basePath}/suggest-agent-prompt`, body, headers);
@@ -1 +1 @@
1
- {"version":3,"file":"BotsApi.mjs","names":[],"sources":["../../../src/apis/bots/BotsApi.ts"],"sourcesContent":["import { BaseApi } from '../../core/BaseApi'\nimport type {\n GetByIdQuery,\n HasCreate,\n HasDeleteById,\n HasGetById,\n HasUpdateById,\n ListQuery,\n Paginated,\n} from '../../core/types'\nimport type {\n Bot,\n BotErrorsQuery,\n BotHistory,\n CreateBotPayload,\n SuggestAgentPromptPayload,\n UpdateBotPayload,\n} from './types'\n\n/**\n * Bots. The list route always paginates (`paginate: false` is ignored), so this class does not\n * extend `BaseCrudApi`. The contexts travel as a list (`BotContextInput` / `BotParsedContext`),\n * not as the stored map that `BotVersionsApi` serves.\n *\n * `GET /bots/:id/errors/export` is not exposed: it answers a binary xlsx, and `ApiClient` only\n * handles JSON/text bodies.\n */\nexport class BotsApi\n extends BaseApi\n implements\n HasGetById<Bot>,\n HasCreate<Bot, CreateBotPayload>,\n HasUpdateById<Bot, UpdateBotPayload>,\n HasDeleteById<'OK' | false>\n{\n public readonly basePath = '/bots'\n\n /**\n * Lists the bots of the account. Always paginated, even with `paginate: false`.\n * @permissions bots.view\n */\n getMany(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Paginated<Bot>> {\n return this.client.get<Paginated<Bot>>(`${this.basePath}${this.toQueryString(query)}`, headers)\n }\n\n /**\n * Returns the first bot matching the query, or `null` when none match.\n * @permissions bots.view\n */\n async getOne(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Bot | null> {\n const page = await this.getMany({ ...query, perPage: 1, page: 1 }, headers)\n return page?.data?.[0] ?? null\n }\n\n /**\n * Returns a bot by ID, with `defaultContexts` (the stored map, as a JSON string). An unknown id\n * answers 500, not an empty body.\n * @permissions bots.view\n */\n getById(id: string, query?: GetByIdQuery<Bot>, headers?: Record<string, string>): Promise<Bot> {\n return this.client.get<Bot>(`${this.basePath}/${id}${this.toQueryString(query)}`, headers)\n }\n\n /**\n * Creates a bot and its first version (published, or a draft with `isDraft`). A duplicate name\n * answers 409, unless the account allows duplicate names. Send `flowJson` with `edges`, or the\n * bot never sends a message (SD-2323).\n * @permissions bots.create\n */\n create(body: CreateBotPayload, headers?: Record<string, string>): Promise<Bot> {\n return this.client.post<Bot, CreateBotPayload>(this.basePath, body, headers)\n }\n\n /**\n * Saves the flow (publishing a version, or into the draft with `isDraft`), or only renames the\n * bot with `onlyUpdateBotName`. Resolves to the bot with `defaultContexts` as an object.\n * @permissions bots.view OR bots.update\n */\n updateById(id: string, body: UpdateBotPayload, headers?: Record<string, string>): Promise<Bot> {\n return this.client.put<Bot, UpdateBotPayload>(`${this.basePath}/${id}`, body, headers)\n }\n\n /**\n * Deletes a bot and its versions (hard delete). Today resolves to `false` even when the bot was\n * deleted (the backend destroy returns nothing); it becomes `'OK'` once the destroy returns the\n * bot, as in the other routes. Do not read the result as success or failure. An unknown id\n * answers 500.\n * @permissions bots.view OR bots.destroy\n */\n deleteById(id: string, headers?: Record<string, string>): Promise<'OK' | false> {\n return this.client.delete<'OK' | false>(`${this.basePath}/${id}`, headers)\n }\n\n /**\n * Lists the failed steps of the bot runs, newest first by default. An unknown bot answers an\n * empty page.\n * @permissions bots.view\n */\n getErrors(\n id: string,\n query?: BotErrorsQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<BotHistory>> {\n return this.client.get<Paginated<BotHistory>>(\n `${this.basePath}/${id}/errors${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Fires the `API_SIGNAL` trigger of the bot for the contact, with an optional `flag` (read by\n * the `api_signal_flag` condition). Asynchronous: always resolves with no content, and the\n * worker only runs it when the contact has an open ticket.\n * @permissions bots.view\n */\n triggerSignal(\n botId: string,\n contactId: string,\n flag?: string,\n headers?: Record<string, string>,\n ): Promise<void> {\n return this.client.post<void, { flag: string } | undefined>(\n `${this.basePath}/${botId}/trigger-signal/${contactId}`,\n flag === undefined ? undefined : { flag },\n headers,\n )\n }\n\n /**\n * Answers a pending asynchronous `HTTP_REQUEST` action: `body` becomes the response the bot\n * reads. Resolves with no content. An unknown history answers 404; a history that is not\n * `PENDING`, or of another bot, answers 400. JSON bodies only (the route also takes text, XML\n * and CSV), up to 250 KB.\n * @permissions bots.view\n */\n requestCallback(\n id: string,\n pendingRequestId: string,\n body: unknown,\n headers?: Record<string, string>,\n ): Promise<void> {\n return this.client.post<void, unknown>(\n `${this.basePath}/${id}/request-callback/${pendingRequestId}`,\n body,\n headers,\n )\n }\n\n /**\n * Generates a prompt for an AI agent of the bot. COSTS one AI agent credit of the account and\n * calls OpenAI. No permission check: any authenticated user. A missing field answers 400; an\n * option outside the lists, or the AI agent limit of the account reached\n * (`Agent limit reached`), answers 500.\n */\n suggestAgentPrompt(\n body: SuggestAgentPromptPayload,\n headers?: Record<string, string>,\n ): Promise<string> {\n return this.client.post<string, SuggestAgentPromptPayload>(\n `${this.basePath}/suggest-agent-prompt`,\n body,\n headers,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;AA2BA,IAAa,UAAb,cACU,QAMV;CACE,AAAgB,WAAW;;;;;CAM3B,QAAQ,OAAwB,SAA2D;AACzF,SAAO,KAAK,OAAO,IAAoB,GAAG,KAAK,WAAW,KAAK,cAAc,MAAM,IAAI,QAAQ;;;;;;CAOjG,MAAM,OAAO,OAAwB,SAAuD;AAE1F,UADa,MAAM,KAAK,QAAQ;GAAE,GAAG;GAAO,SAAS;GAAG,MAAM;GAAG,EAAE,QAAQ,GAC9D,OAAO,MAAM;;;;;;;CAQ5B,QAAQ,IAAY,OAA2B,SAAgD;AAC7F,SAAO,KAAK,OAAO,IAAS,GAAG,KAAK,SAAS,GAAG,KAAK,KAAK,cAAc,MAAM,IAAI,QAAQ;;;;;;;;CAS5F,OAAO,MAAwB,SAAgD;AAC7E,SAAO,KAAK,OAAO,KAA4B,KAAK,UAAU,MAAM,QAAQ;;;;;;;CAQ9E,WAAW,IAAY,MAAwB,SAAgD;AAC7F,SAAO,KAAK,OAAO,IAA2B,GAAG,KAAK,SAAS,GAAG,MAAM,MAAM,QAAQ;;;;;;;;;CAUxF,WAAW,IAAY,SAAyD;AAC9E,SAAO,KAAK,OAAO,OAAqB,GAAG,KAAK,SAAS,GAAG,MAAM,QAAQ;;;;;;;CAQ5E,UACE,IACA,OACA,SACgC;AAChC,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,GAAG,GAAG,SAAS,KAAK,cAAc,MAAM,IACzD,QACD;;;;;;;;CASH,cACE,OACA,WACA,MACA,SACe;AACf,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,GAAG,MAAM,kBAAkB,aAC5C,SAAS,SAAY,SAAY,EAAE,MAAM,EACzC,QACD;;;;;;;;;CAUH,gBACE,IACA,kBACA,MACA,SACe;AACf,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,GAAG,GAAG,oBAAoB,oBAC3C,MACA,QACD;;;;;;;;CASH,mBACE,MACA,SACiB;AACjB,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,wBACjB,MACA,QACD"}
1
+ {"version":3,"file":"BotsApi.mjs","names":[],"sources":["../../../src/apis/bots/BotsApi.ts"],"sourcesContent":["import { BaseApi } from '../../core/BaseApi'\nimport type {\n GetByIdQuery,\n HasCreate,\n HasDeleteById,\n HasGetById,\n HasUpdateById,\n ListQuery,\n Paginated,\n} from '../../core/types'\nimport type {\n Bot,\n BotErrorsQuery,\n BotHistory,\n CreateBotPayload,\n SuggestAgentPromptPayload,\n UpdateBotPayload,\n} from './types'\n\n/**\n * Bots. The list route always paginates (`paginate: false` is ignored), so this class does not\n * extend `BaseCrudApi`. The contexts travel as a list (`BotContextInput` / `BotParsedContext`),\n * not as the stored map that `BotVersionsApi` serves.\n */\nexport class BotsApi\n extends BaseApi\n implements\n HasGetById<Bot>,\n HasCreate<Bot, CreateBotPayload>,\n HasUpdateById<Bot, UpdateBotPayload>,\n HasDeleteById<'OK' | false>\n{\n public readonly basePath = '/bots'\n\n /**\n * Lists the bots of the account. Always paginated, even with `paginate: false`.\n * @permissions bots.view\n */\n getMany(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Paginated<Bot>> {\n return this.client.get<Paginated<Bot>>(`${this.basePath}${this.toQueryString(query)}`, headers)\n }\n\n /**\n * Returns the first bot matching the query, or `null` when none match.\n * @permissions bots.view\n */\n async getOne(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Bot | null> {\n const page = await this.getMany({ ...query, perPage: 1, page: 1 }, headers)\n return page?.data?.[0] ?? null\n }\n\n /**\n * Returns a bot by ID, with `defaultContexts` (the stored map, as a JSON string). An unknown id\n * answers 500, not an empty body.\n * @permissions bots.view\n */\n getById(id: string, query?: GetByIdQuery<Bot>, headers?: Record<string, string>): Promise<Bot> {\n return this.client.get<Bot>(`${this.basePath}/${id}${this.toQueryString(query)}`, headers)\n }\n\n /**\n * Creates a bot and its first version (published, or a draft with `isDraft`). A duplicate name\n * answers 409, unless the account allows duplicate names. Send `flowJson` with `edges`, or the\n * bot never sends a message (SD-2323).\n * @permissions bots.create\n */\n create(body: CreateBotPayload, headers?: Record<string, string>): Promise<Bot> {\n return this.client.post<Bot, CreateBotPayload>(this.basePath, body, headers)\n }\n\n /**\n * Saves the flow (publishing a version, or into the draft with `isDraft`), or only renames the\n * bot with `onlyUpdateBotName`. Resolves to the bot with `defaultContexts` as an object.\n * @permissions bots.view OR bots.update\n */\n updateById(id: string, body: UpdateBotPayload, headers?: Record<string, string>): Promise<Bot> {\n return this.client.put<Bot, UpdateBotPayload>(`${this.basePath}/${id}`, body, headers)\n }\n\n /**\n * Deletes a bot and its versions (hard delete). Today resolves to `false` even when the bot was\n * deleted (the backend destroy returns nothing); it becomes `'OK'` once the destroy returns the\n * bot, as in the other routes. Do not read the result as success or failure. An unknown id\n * answers 500.\n * @permissions bots.view OR bots.destroy\n */\n deleteById(id: string, headers?: Record<string, string>): Promise<'OK' | false> {\n return this.client.delete<'OK' | false>(`${this.basePath}/${id}`, headers)\n }\n\n /**\n * Lists the failed steps of the bot runs, newest first by default. An unknown bot answers an\n * empty page.\n * @permissions bots.view\n */\n getErrors(\n id: string,\n query?: BotErrorsQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<BotHistory>> {\n return this.client.get<Paginated<BotHistory>>(\n `${this.basePath}/${id}/errors${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Exports the failed steps of the bot runs of the last 30 days as an xlsx workbook (binary).\n * Needs a client with `requestRaw`. A period without errors answers 400 `No errors found to\n * export`; an unknown bot answers 404.\n * @permissions bots.view\n */\n async exportErrors(id: string, headers?: Record<string, string>): Promise<ArrayBuffer> {\n if (!this.client.requestRaw) {\n throw new Error('exportErrors needs a client with requestRaw (the answer is a binary xlsx)')\n }\n const response = await this.client.requestRaw(\n 'GET',\n `${this.basePath}/${id}/errors/export`,\n undefined,\n headers,\n )\n return response.arrayBuffer()\n }\n\n /**\n * Fires the `API_SIGNAL` trigger of the bot for the contact, with an optional `flag` (read by\n * the `api_signal_flag` condition). Asynchronous: always resolves with no content, and the\n * worker only runs it when the contact has an open ticket. The worker runs the flow of `botId`\n * on the engine of the bot of the contact's connection (see `BotSettings.botCreatedVersion`; when\n * the connection has no bot, the engine of the `botId` bot). `triggerSignal` does not reach the\n * bot simulator (there the `API_SIGNAL` path is picked by hand, with no `flag`).\n * @permissions bots.view\n */\n triggerSignal(\n botId: string,\n contactId: string,\n flag?: string,\n headers?: Record<string, string>,\n ): Promise<void> {\n return this.client.post<void, { flag: string } | undefined>(\n `${this.basePath}/${botId}/trigger-signal/${contactId}`,\n flag === undefined ? undefined : { flag },\n headers,\n )\n }\n\n /**\n * Answers a pending asynchronous `HTTP_REQUEST` action: `body` becomes the response the bot\n * reads. Resolves with no content. An unknown history answers 404; a history that is not\n * `PENDING`, or of another bot, answers 400. JSON bodies only (the route also takes text, XML\n * and CSV), up to 250 KB.\n * @permissions bots.view\n */\n requestCallback(\n id: string,\n pendingRequestId: string,\n body: unknown,\n headers?: Record<string, string>,\n ): Promise<void> {\n return this.client.post<void, unknown>(\n `${this.basePath}/${id}/request-callback/${pendingRequestId}`,\n body,\n headers,\n )\n }\n\n /**\n * Generates a prompt for an AI agent of the bot. COSTS one AI agent credit of the account and\n * calls OpenAI. A missing field answers 400; an option outside the lists, or the AI agent limit\n * of the account reached (`Agent limit reached`), answers 500.\n */\n suggestAgentPrompt(\n body: SuggestAgentPromptPayload,\n headers?: Record<string, string>,\n ): Promise<string> {\n return this.client.post<string, SuggestAgentPromptPayload>(\n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,GAAG,KAAK,SAAS,GAAG,MAAM,kBAAkB,aAC5C,SAAS,SAAY,SAAY,EAAE,MAAM,EACzC,QACD;;;;;;;;;CAUH,gBACE,IACA,kBACA,MACA,SACe;AACf,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,GAAG,GAAG,oBAAoB,oBAC3C,MACA,QACD;;;;;;;CAQH,mBACE,MACA,SACiB;AACjB,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,wBACjB,MACA,QACD"}
@@ -9,7 +9,11 @@ export type BotLimitations = {
9
9
  export type BotSettings = {
10
10
  /** If true, only the first matching rule per trigger fires; otherwise all matching rules fire. */
11
11
  sequentialRuleExecution?: boolean;
12
- /** Version of the bot builder used to create this bot. v3 uses the visual flow builder. */
12
+ /**
13
+ * Version of the bot builder used to create this bot, which also picks the engine that runs it:
14
+ * `v3` (the visual flow builder) runs on the flow engine; `v1`, `v2` or absent, on the legacy
15
+ * engine. The bot simulator always runs the flow engine.
16
+ */
13
17
  botCreatedVersion?: BotCreatedVersion;
14
18
  limitations?: BotLimitations;
15
19
  };
@@ -162,6 +166,11 @@ export type BotActionDataMap = {
162
166
  waitSeconds?: number;
163
167
  };
164
168
  };
169
+ /**
170
+ * Runs on the flow engine (`botCreatedVersion: 'v3'`). `endpointUrl`, `httpMethod`, `retries`,
171
+ * `timeout` and `bodyType` are required to run it: without one of them the step does not run.
172
+ * The bot simulator does not run it.
173
+ */
165
174
  HTTP_REQUEST: {
166
175
  requestName?: string;
167
176
  endpointUrl?: string;
@@ -182,8 +191,9 @@ export type BotActionDataMap = {
182
191
  }[];
183
192
  requestBodyJson?: string;
184
193
  requestBodyXml?: string;
194
+ /** Number of attempts (at least 1), not of retries after the first one. */
185
195
  retries?: number;
186
- /** Timeout in milliseconds. */
196
+ /** Timeout of each attempt, in SECONDS. */
187
197
  timeout?: number;
188
198
  /** Response properties to extract into bot session variables. */
189
199
  variables?: {