@ikatec/digisac-api-sdk 4.11.0 → 4.13.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 (142) hide show
  1. package/dist/apis/absence/AbsenceApi.cjs +46 -2
  2. package/dist/apis/absence/AbsenceApi.cjs.map +1 -1
  3. package/dist/apis/absence/AbsenceApi.d.ts +38 -4
  4. package/dist/apis/absence/AbsenceApi.d.ts.map +1 -1
  5. package/dist/apis/absence/AbsenceApi.mjs +46 -2
  6. package/dist/apis/absence/AbsenceApi.mjs.map +1 -1
  7. package/dist/apis/absence/types.d.ts +51 -2
  8. package/dist/apis/absence/types.d.ts.map +1 -1
  9. package/dist/apis/activityLog/ActivityLogApi.cjs +10 -1
  10. package/dist/apis/activityLog/ActivityLogApi.cjs.map +1 -1
  11. package/dist/apis/activityLog/ActivityLogApi.d.ts +10 -3
  12. package/dist/apis/activityLog/ActivityLogApi.d.ts.map +1 -1
  13. package/dist/apis/activityLog/ActivityLogApi.mjs +10 -1
  14. package/dist/apis/activityLog/ActivityLogApi.mjs.map +1 -1
  15. package/dist/apis/activityLog/types.d.ts +48 -8
  16. package/dist/apis/activityLog/types.d.ts.map +1 -1
  17. package/dist/apis/categories/types.d.ts +1 -0
  18. package/dist/apis/categories/types.d.ts.map +1 -1
  19. package/dist/apis/creditMovements/CreditMovementsApi.cjs +31 -2
  20. package/dist/apis/creditMovements/CreditMovementsApi.cjs.map +1 -1
  21. package/dist/apis/creditMovements/CreditMovementsApi.d.ts +21 -3
  22. package/dist/apis/creditMovements/CreditMovementsApi.d.ts.map +1 -1
  23. package/dist/apis/creditMovements/CreditMovementsApi.mjs +31 -2
  24. package/dist/apis/creditMovements/CreditMovementsApi.mjs.map +1 -1
  25. package/dist/apis/creditMovements/types.d.ts +73 -2
  26. package/dist/apis/creditMovements/types.d.ts.map +1 -1
  27. package/dist/apis/interactiveMessages/InteractiveMessagesApi.cjs +15 -0
  28. package/dist/apis/interactiveMessages/InteractiveMessagesApi.cjs.map +1 -1
  29. package/dist/apis/interactiveMessages/InteractiveMessagesApi.d.ts +13 -0
  30. package/dist/apis/interactiveMessages/InteractiveMessagesApi.d.ts.map +1 -1
  31. package/dist/apis/interactiveMessages/InteractiveMessagesApi.mjs +15 -0
  32. package/dist/apis/interactiveMessages/InteractiveMessagesApi.mjs.map +1 -1
  33. package/dist/apis/interactiveMessages/types.d.ts +8 -2
  34. package/dist/apis/interactiveMessages/types.d.ts.map +1 -1
  35. package/dist/apis/knowledgeBase/KnowledgeBaseApi.cjs +27 -0
  36. package/dist/apis/knowledgeBase/KnowledgeBaseApi.cjs.map +1 -1
  37. package/dist/apis/knowledgeBase/KnowledgeBaseApi.d.ts +22 -1
  38. package/dist/apis/knowledgeBase/KnowledgeBaseApi.d.ts.map +1 -1
  39. package/dist/apis/knowledgeBase/KnowledgeBaseApi.mjs +27 -0
  40. package/dist/apis/knowledgeBase/KnowledgeBaseApi.mjs.map +1 -1
  41. package/dist/apis/knowledgeBase/types.d.ts +56 -2
  42. package/dist/apis/knowledgeBase/types.d.ts.map +1 -1
  43. package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.cjs +26 -0
  44. package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.cjs.map +1 -1
  45. package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.d.ts +24 -0
  46. package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.d.ts.map +1 -1
  47. package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.mjs +26 -0
  48. package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.mjs.map +1 -1
  49. package/dist/apis/knowledgeBaseItem/types.d.ts +23 -6
  50. package/dist/apis/knowledgeBaseItem/types.d.ts.map +1 -1
  51. package/dist/apis/me/MeApi.cjs +36 -29
  52. package/dist/apis/me/MeApi.cjs.map +1 -1
  53. package/dist/apis/me/MeApi.d.ts +33 -22
  54. package/dist/apis/me/MeApi.d.ts.map +1 -1
  55. package/dist/apis/me/MeApi.mjs +36 -29
  56. package/dist/apis/me/MeApi.mjs.map +1 -1
  57. package/dist/apis/me/types.d.ts +67 -4
  58. package/dist/apis/me/types.d.ts.map +1 -1
  59. package/dist/apis/notifications/NotificationsApi.cjs +50 -2
  60. package/dist/apis/notifications/NotificationsApi.cjs.map +1 -1
  61. package/dist/apis/notifications/NotificationsApi.d.ts +41 -3
  62. package/dist/apis/notifications/NotificationsApi.d.ts.map +1 -1
  63. package/dist/apis/notifications/NotificationsApi.mjs +50 -2
  64. package/dist/apis/notifications/NotificationsApi.mjs.map +1 -1
  65. package/dist/apis/notifications/types.d.ts +54 -8
  66. package/dist/apis/notifications/types.d.ts.map +1 -1
  67. package/dist/apis/serviceAccessManagement/ServiceAccessManagementApi.cjs.map +1 -1
  68. package/dist/apis/serviceAccessManagement/ServiceAccessManagementApi.d.ts +4 -1
  69. package/dist/apis/serviceAccessManagement/ServiceAccessManagementApi.d.ts.map +1 -1
  70. package/dist/apis/serviceAccessManagement/ServiceAccessManagementApi.mjs.map +1 -1
  71. package/dist/apis/serviceAccessManagement/types.d.ts +3 -0
  72. package/dist/apis/serviceAccessManagement/types.d.ts.map +1 -1
  73. package/dist/apis/stickerUsers/StickerUsersApi.cjs.map +1 -1
  74. package/dist/apis/stickerUsers/StickerUsersApi.d.ts +3 -1
  75. package/dist/apis/stickerUsers/StickerUsersApi.d.ts.map +1 -1
  76. package/dist/apis/stickerUsers/StickerUsersApi.mjs.map +1 -1
  77. package/dist/apis/stickerUsers/types.d.ts +4 -0
  78. package/dist/apis/stickerUsers/types.d.ts.map +1 -1
  79. package/dist/apis/stickers/StickersApi.cjs +27 -3
  80. package/dist/apis/stickers/StickersApi.cjs.map +1 -1
  81. package/dist/apis/stickers/StickersApi.d.ts +24 -4
  82. package/dist/apis/stickers/StickersApi.d.ts.map +1 -1
  83. package/dist/apis/stickers/StickersApi.mjs +27 -3
  84. package/dist/apis/stickers/StickersApi.mjs.map +1 -1
  85. package/dist/apis/stickers/types.d.ts +28 -4
  86. package/dist/apis/stickers/types.d.ts.map +1 -1
  87. package/dist/apis/transcripts/TranscriptsApi.cjs +12 -2
  88. package/dist/apis/transcripts/TranscriptsApi.cjs.map +1 -1
  89. package/dist/apis/transcripts/TranscriptsApi.d.ts +11 -5
  90. package/dist/apis/transcripts/TranscriptsApi.d.ts.map +1 -1
  91. package/dist/apis/transcripts/TranscriptsApi.mjs +12 -2
  92. package/dist/apis/transcripts/TranscriptsApi.mjs.map +1 -1
  93. package/dist/apis/transcripts/types.d.ts +4 -0
  94. package/dist/apis/transcripts/types.d.ts.map +1 -1
  95. package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.cjs +51 -0
  96. package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.cjs.map +1 -1
  97. package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.d.ts +44 -2
  98. package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.d.ts.map +1 -1
  99. package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.mjs +51 -0
  100. package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.mjs.map +1 -1
  101. package/dist/apis/whatsappBusinessTemplates/types.d.ts +34 -1
  102. package/dist/apis/whatsappBusinessTemplates/types.d.ts.map +1 -1
  103. package/package.json +1 -1
  104. package/src/apis/absence/AbsenceApi.test.ts +65 -0
  105. package/src/apis/absence/AbsenceApi.ts +77 -4
  106. package/src/apis/absence/types.ts +53 -2
  107. package/src/apis/activityLog/ActivityLogApi.test.ts +44 -0
  108. package/src/apis/activityLog/ActivityLogApi.ts +22 -3
  109. package/src/apis/activityLog/types.ts +47 -8
  110. package/src/apis/categories/types.ts +1 -0
  111. package/src/apis/creditMovements/CreditMovementsApi.test.ts +88 -0
  112. package/src/apis/creditMovements/CreditMovementsApi.ts +73 -2
  113. package/src/apis/creditMovements/types.ts +74 -2
  114. package/src/apis/interactiveMessages/InteractiveMessagesApi.test.ts +59 -0
  115. package/src/apis/interactiveMessages/InteractiveMessagesApi.ts +26 -0
  116. package/src/apis/interactiveMessages/types.ts +8 -2
  117. package/src/apis/knowledgeBase/KnowledgeBaseApi.test.ts +54 -0
  118. package/src/apis/knowledgeBase/KnowledgeBaseApi.ts +61 -1
  119. package/src/apis/knowledgeBase/types.ts +62 -2
  120. package/src/apis/knowledgeBaseItem/KnowledgeBaseItemApi.test.ts +57 -0
  121. package/src/apis/knowledgeBaseItem/KnowledgeBaseItemApi.ts +45 -0
  122. package/src/apis/knowledgeBaseItem/types.ts +23 -6
  123. package/src/apis/me/MeApi.test.ts +45 -1
  124. package/src/apis/me/MeApi.ts +83 -28
  125. package/src/apis/me/types.ts +75 -4
  126. package/src/apis/notifications/NotificationsApi.test.ts +74 -0
  127. package/src/apis/notifications/NotificationsApi.ts +88 -3
  128. package/src/apis/notifications/types.ts +65 -7
  129. package/src/apis/payloads.test-d.ts +82 -2
  130. package/src/apis/serviceAccessManagement/ServiceAccessManagementApi.ts +4 -1
  131. package/src/apis/serviceAccessManagement/types.ts +3 -0
  132. package/src/apis/stickerUsers/StickerUsersApi.ts +3 -1
  133. package/src/apis/stickerUsers/types.ts +4 -0
  134. package/src/apis/stickers/StickersApi.test.ts +58 -0
  135. package/src/apis/stickers/StickersApi.ts +46 -4
  136. package/src/apis/stickers/types.ts +29 -4
  137. package/src/apis/transcripts/TranscriptsApi.test.ts +14 -21
  138. package/src/apis/transcripts/TranscriptsApi.ts +15 -6
  139. package/src/apis/transcripts/types.ts +4 -0
  140. package/src/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.test.ts +86 -0
  141. package/src/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.ts +74 -1
  142. package/src/apis/whatsappBusinessTemplates/types.ts +38 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/apis/whatsappBusinessTemplates/types.ts"],"names":[],"mappings":"AAA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EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,iCAAiC,EAAE,CAAA;IAChD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,mCAAmC,CAAA;IACjD,QAAQ,CAAC,EAAE,gCAAgC,CAAA;IAC3C,QAAQ,CAAC,EAAE,gCAAgC,CAAA;CAC5C,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikatec/digisac-api-sdk",
3
- "version": "4.11.0",
3
+ "version": "4.13.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -0,0 +1,65 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
2
+ import { AbsenceApi } from './AbsenceApi'
3
+ import type { ApiClient } from '../../core/ApiClient'
4
+
5
+ // ── Mock client factory ──────────────────────────────────────────────
6
+
7
+ function createMockClient(): ApiClient {
8
+ return {
9
+ setAccessToken: vi.fn().mockReturnThis(),
10
+ request: vi.fn(),
11
+ requestRaw: vi.fn(),
12
+ get: vi.fn(),
13
+ post: vi.fn(),
14
+ put: vi.fn(),
15
+ patch: vi.fn(),
16
+ delete: vi.fn(),
17
+ }
18
+ }
19
+
20
+ // ── Tests ────────────────────────────────────────────────────────────
21
+
22
+ describe('AbsenceApi', () => {
23
+ let client: ReturnType<typeof createMockClient>
24
+ let api: AbsenceApi
25
+
26
+ beforeEach(() => {
27
+ client = createMockClient()
28
+ api = new AbsenceApi(client)
29
+ })
30
+
31
+ it('report serializes the query of the report', async () => {
32
+ vi.mocked(client.get).mockResolvedValue({ data: [] })
33
+ await api.report({
34
+ filters: { reason: 'Almoço' },
35
+ sort: 'createdAt',
36
+ order: 'ASC',
37
+ perPage: 50,
38
+ })
39
+ const url = vi.mocked(client.get).mock.calls[0]?.[0] as string
40
+ expect(url).toMatch(/^\/absence\?/)
41
+ expect(decodeURIComponent(url)).toContain('"filters":{"reason":"Almoço"}')
42
+ })
43
+
44
+ it('findOpenAbsence calls client.get with /absence/find-open-absence', async () => {
45
+ vi.mocked(client.get).mockResolvedValue(null)
46
+ await expect(api.findOpenAbsence()).resolves.toBeNull()
47
+ expect(client.get).toHaveBeenCalledWith('/absence/find-open-absence', undefined)
48
+ })
49
+
50
+ it('unlock posts the body to /absence/unlock', async () => {
51
+ vi.mocked(client.post).mockResolvedValue({ success: false, message: 'INVALID_REASON' })
52
+ await expect(api.unlock({ reason: 'Voltei' })).resolves.toEqual({
53
+ success: false,
54
+ message: 'INVALID_REASON',
55
+ })
56
+ expect(client.post).toHaveBeenCalledWith('/absence/unlock', { reason: 'Voltei' }, undefined)
57
+ })
58
+
59
+ it('exportCsv calls client.get with /absence/export-csv and the query', async () => {
60
+ vi.mocked(client.get).mockResolvedValue('Usuário,De,Até,Motivo')
61
+ await api.exportCsv({ timezone: 'America/Sao_Paulo' })
62
+ const url = vi.mocked(client.get).mock.calls[0]?.[0] as string
63
+ expect(url).toMatch(/^\/absence\/export-csv\?/)
64
+ })
65
+ })
@@ -1,17 +1,90 @@
1
1
  import type { ApiClient } from '../../core/ApiClient'
2
2
  import { BaseCrudApi } from '../../core/BaseCrudApi'
3
- import type { GetByIdQuery } from '../../core/types'
4
- import type { Absence, CreateAbsencePayload, UpdateAbsencePayload } from './types'
3
+ import type { GetByIdQuery, Paginated } from '../../core/types'
4
+ import type {
5
+ Absence,
6
+ AbsenceReportItem,
7
+ AbsenceReportQuery,
8
+ CreateAbsencePayload,
9
+ UnlockAbsencePayload,
10
+ UnlockAbsenceResponse,
11
+ UpdateAbsencePayload,
12
+ } from './types'
5
13
 
6
14
  /**
7
- * Absences of the users. The backend serves the report (`GET /absence`), `POST /absence` and
8
- * `PUT /absence/:id`; there is no read by id nor delete.
15
+ * Absences of the users. The backend serves the report (`GET /absence`, `GET /absence/export-csv`),
16
+ * `GET /absence/find-open-absence`, `POST /absence`, `POST /absence/unlock` and `PUT /absence/:id`; there is
17
+ * no read by id nor delete. Creating an absence sets the status of the user to `away` and `unlock` sets it
18
+ * back to `online` (both emit `user.updated` to the webhooks).
9
19
  */
10
20
  export class AbsenceApi extends BaseCrudApi<Absence, CreateAbsencePayload, UpdateAbsencePayload> {
11
21
  constructor(client: ApiClient) {
12
22
  super(client, '/absence')
13
23
  }
14
24
 
25
+ /**
26
+ * The absence report of the account (`GET /absence`), always paginated, with its own query (the rows are
27
+ * raw: see `AbsenceReportItem`). Prefer it to `getMany`, whose `where`/`include`/`paginate` the backend
28
+ * ignores. Requires both permissions, always: without them it answers 403
29
+ * `MISSING_ABSENCE_REPORT_PERMISSION`.
30
+ * @permissions overview.absence.view AND myAccount.absence
31
+ */
32
+ report(
33
+ query?: AbsenceReportQuery,
34
+ headers?: Record<string, string>,
35
+ ): Promise<Paginated<AbsenceReportItem>> {
36
+ return this.client.get<Paginated<AbsenceReportItem>>(
37
+ `${this.basePath}${this.toQueryString(query)}`,
38
+ headers,
39
+ )
40
+ }
41
+
42
+ /**
43
+ * Creates an absence for the current user (whatever `userId` says) and sets the user `away`. Resolves the
44
+ * stored absence (raw, without `user`).
45
+ * @permissions myAccount.absence
46
+ */
47
+ override create(body: CreateAbsencePayload, headers?: Record<string, string>): Promise<Absence> {
48
+ return super.create(body, headers)
49
+ }
50
+
51
+ /**
52
+ * The open absence of the current user, or `null` — also `null` while `settings.absence.enabled` is off.
53
+ * @permissions myAccount.absence
54
+ */
55
+ findOpenAbsence(headers?: Record<string, string>): Promise<AbsenceReportItem | null> {
56
+ return this.client.get<AbsenceReportItem | null>(`${this.basePath}/find-open-absence`, headers)
57
+ }
58
+
59
+ /**
60
+ * Ends an absence (the open one of the user when `id` is absent) and sets the user `online`. The refusals
61
+ * of `settings.absence` come with status 200 (`INVALID_REASON`, `INVALID_PASSWORD`); without an open
62
+ * absence it answers 500.
63
+ * @permissions myAccount.absence
64
+ */
65
+ unlock(
66
+ body: UnlockAbsencePayload,
67
+ headers?: Record<string, string>,
68
+ ): Promise<UnlockAbsenceResponse> {
69
+ return this.client.post<UnlockAbsenceResponse, UnlockAbsencePayload>(
70
+ `${this.basePath}/unlock`,
71
+ body,
72
+ headers,
73
+ )
74
+ }
75
+
76
+ /**
77
+ * Exports the report as CSV (`Usuário, De, Até, Motivo`; an open absence shows `Em andamento`), sent as
78
+ * the attachment `<yyyy-MM-dd>_absence-control.csv`.
79
+ * @permissions overview.absence.view AND myAccount.absence
80
+ */
81
+ exportCsv(query?: AbsenceReportQuery, headers?: Record<string, string>): Promise<string> {
82
+ return this.client.get<string>(
83
+ `${this.basePath}/export-csv${this.toQueryString(query)}`,
84
+ headers,
85
+ )
86
+ }
87
+
15
88
  /** @deprecated Not served: the backend has no GET /absence/:id, so this route answers 404. */
16
89
  override getById(
17
90
  id: string,
@@ -1,5 +1,6 @@
1
1
  import type { User } from '../users'
2
2
 
3
+ /** An absence as `PUT /absence/:id` answers it (the transformer of the backend). */
3
4
  export type Absence = {
4
5
  id: string
5
6
  accountId: string
@@ -8,7 +9,8 @@ export type Absence = {
8
9
  endedAt: string | null
9
10
  createdAt: string
10
11
  updatedAt: string
11
- deletedAt: string | null
12
+ /** @deprecated Not a field of the backend: the model has no soft delete. */
13
+ deletedAt?: string | null
12
14
  // relationships
13
15
  user?: User
14
16
  }
@@ -16,7 +18,9 @@ export type Absence = {
16
18
  export type AbsenceRelationships = 'user'
17
19
 
18
20
  export type CreateAbsencePayload = {
19
- userId: string
21
+ /** Ignored: the backend creates the absence for the current user. */
22
+ userId?: string
23
+ /** Up to 255 characters. */
20
24
  reason?: string
21
25
  }
22
26
 
@@ -24,3 +28,50 @@ export type UpdateAbsencePayload = {
24
28
  reason?: string
25
29
  endedAt?: string | null
26
30
  }
31
+
32
+ /** Columns the report can be sorted by (an unknown one falls back to the default order). */
33
+ export type AbsenceReportSortField = 'user' | 'createdAt' | 'endedAt'
34
+
35
+ /**
36
+ * Query of the absence report (`GET /absence` and `GET /absence/export-csv`). The backend ignores
37
+ * `where` and `include`: it reads only these fields.
38
+ */
39
+ export type AbsenceReportQuery = {
40
+ filters?: {
41
+ userId?: string
42
+ reason?: string
43
+ /** Absences created at or after this date. An invalid date answers 400 `Invalid date.`. */
44
+ createdAt?: string
45
+ /** Absences ended at or before this date. */
46
+ endedAt?: string
47
+ }
48
+ sort?: AbsenceReportSortField
49
+ /** Only `'ASC'` sorts ascending: any other value sorts descending. */
50
+ order?: 'ASC' | 'DESC'
51
+ page?: number
52
+ /** Up to 200 (a larger value is clamped, not refused). Defaults to 15. */
53
+ perPage?: number
54
+ /** IANA zone of the dates of the CSV export (e.g. `America/Sao_Paulo`). */
55
+ timezone?: string
56
+ }
57
+
58
+ /**
59
+ * A row of the report: the stored absence with its user, both raw (not transformed).
60
+ */
61
+ export type AbsenceReportItem = Omit<Absence, 'deletedAt' | 'user'> & {
62
+ user?: Record<string, unknown>
63
+ }
64
+
65
+ /** The body of `unlock`: the absence to end (the open one of the user when `id` is absent). */
66
+ export type UnlockAbsencePayload = {
67
+ id?: string
68
+ /** Required when `settings.absence.reason_required` is on. */
69
+ reason?: string
70
+ /** Required when `settings.absence.password_required` is on: the password of the user. */
71
+ password?: string
72
+ }
73
+
74
+ /** What `unlock` answers: the business refusals come with status 200. */
75
+ export type UnlockAbsenceResponse =
76
+ | { success: true }
77
+ | { success: false; message: 'INVALID_REASON' | 'INVALID_PASSWORD' }
@@ -0,0 +1,44 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
2
+ import { ActivityLogApi } from './ActivityLogApi'
3
+ import type { ApiClient } from '../../core/ApiClient'
4
+
5
+ // ── Mock client factory ──────────────────────────────────────────────
6
+
7
+ function createMockClient(): ApiClient {
8
+ return {
9
+ setAccessToken: vi.fn().mockReturnThis(),
10
+ request: vi.fn(),
11
+ requestRaw: vi.fn(),
12
+ get: vi.fn(),
13
+ post: vi.fn(),
14
+ put: vi.fn(),
15
+ patch: vi.fn(),
16
+ delete: vi.fn(),
17
+ }
18
+ }
19
+
20
+ // ── Tests ────────────────────────────────────────────────────────────
21
+
22
+ describe('ActivityLogApi', () => {
23
+ let client: ReturnType<typeof createMockClient>
24
+ let api: ActivityLogApi
25
+
26
+ beforeEach(() => {
27
+ client = createMockClient()
28
+ api = new ActivityLogApi(client)
29
+ })
30
+
31
+ it('exportCsv calls client.get with /log/export-csv and the period', async () => {
32
+ vi.mocked(client.get).mockResolvedValue('csv')
33
+ await api.exportCsv({ filters: { from: '2026-10-01', to: '2026-10-17' } })
34
+ const url = vi.mocked(client.get).mock.calls[0]?.[0] as string
35
+ expect(url).toMatch(/^\/log\/export-csv\?/)
36
+ expect(decodeURIComponent(url)).toContain('"from":"2026-10-01"')
37
+ })
38
+
39
+ it('create posts the stored fields of the log', async () => {
40
+ const body = { resourceType: 'contact', resourceId: 'c-1', event: 'update', data: { a: 1 } }
41
+ await api.create(body)
42
+ expect(client.post).toHaveBeenCalledWith('/log', body, undefined)
43
+ })
44
+ })
@@ -1,20 +1,39 @@
1
1
  import type { ApiClient } from '../../core/ApiClient'
2
2
  import { BaseCrudApi } from '../../core/BaseCrudApi'
3
- import type { ActivityLog, CreateActivityLogPayload, UpdateActivityLogPayload } from './types'
3
+ import type {
4
+ ActivityLog,
5
+ ActivityLogListQuery,
6
+ CreateActivityLogPayload,
7
+ UpdateActivityLogPayload,
8
+ } from './types'
4
9
 
5
10
  /**
6
11
  * Activity log of the account (stored in MongoDB: the routes answer 503 when it is unavailable).
7
- * The backend serves `GET /log`, `GET /log/:id` and `POST /log`; there is no update or delete.
12
+ * The backend serves `GET /log`, `GET /log/export-csv`, `GET /log/:id` and `POST /log`; there is no update
13
+ * or delete, so an entry created is permanent. `GET /log/:id` takes a MongoDB
14
+ * id (an UUID answers 500).
8
15
  */
9
16
  export class ActivityLogApi extends BaseCrudApi<
10
17
  ActivityLog,
11
18
  CreateActivityLogPayload,
12
- UpdateActivityLogPayload
19
+ UpdateActivityLogPayload,
20
+ ActivityLogListQuery
13
21
  > {
14
22
  constructor(client: ApiClient) {
15
23
  super(client, '/log')
16
24
  }
17
25
 
26
+ /**
27
+ * Exports the entries of the period (`filters.from`/`filters.to`) as CSV, sent as the attachment
28
+ * `exportation.csv`.
29
+ */
30
+ exportCsv(query: ActivityLogListQuery, headers?: Record<string, string>): Promise<string> {
31
+ return this.client.get<string>(
32
+ `${this.basePath}/export-csv${this.toQueryString(query)}`,
33
+ headers,
34
+ )
35
+ }
36
+
18
37
  /** @deprecated Not served: the backend has no PUT /log/:id, so this route answers 404. */
19
38
  override updateById(
20
39
  id: string,
@@ -1,22 +1,61 @@
1
+ import type { ListQuery } from '../../core/types'
2
+
3
+ /**
4
+ * An entry of the activity log (MongoDB). The stored fields are `resourceType`, `resourceId`, `event`,
5
+ * `userId`, `accessTokenId` and `data`. `create` and `getById` answer through a transformer that keeps only
6
+ * `id`, `accountId`, `createdAt` and `updatedAt`; the list answers every stored field plus `user`.
7
+ */
1
8
  export type ActivityLog = {
2
9
  id: string
3
10
  accountId: string
4
- userId: string | null
5
- action: string
6
- entity: string
7
- entityId: string | null
8
- data: Record<string, unknown>
11
+ resourceType?: string
12
+ resourceId?: string | null
13
+ event?: string
14
+ userId?: string | null
15
+ accessTokenId?: string | null
16
+ data?: Record<string, unknown>
9
17
  createdAt: string
10
18
  updatedAt: string
19
+ /** On the list: the user of the entry. */
20
+ user?: { id: string; name: string }
21
+ /** @deprecated Not a field of the backend (it is dropped on create): use `event`. */
22
+ action?: string
23
+ /** @deprecated Not a field of the backend (it is dropped on create): use `resourceType`. */
24
+ entity?: string
25
+ /** @deprecated Not a field of the backend (it is dropped on create): use `resourceId`. */
26
+ entityId?: string | null
11
27
  }
12
28
 
13
29
  export type CreateActivityLogPayload = {
14
- action: string
15
- entity: string
16
- entityId?: string
30
+ resourceType?: string
31
+ resourceId?: string
32
+ event?: string
33
+ userId?: string
34
+ accessTokenId?: string
17
35
  data?: Record<string, unknown>
36
+ /** @deprecated Dropped by the backend (not a field of the log): use `event`. */
37
+ action?: string
38
+ /** @deprecated Dropped by the backend (not a field of the log): use `resourceType`. */
39
+ entity?: string
40
+ /** @deprecated Dropped by the backend (not a field of the log): use `resourceId`. */
41
+ entityId?: string
18
42
  }
19
43
 
20
44
  export type UpdateActivityLogPayload = {
21
45
  data?: Record<string, unknown>
22
46
  }
47
+
48
+ /**
49
+ * Query of the list and of the CSV export. The backend requires `filters.from` and `filters.to` (the
50
+ * period of `createdAt`); the other `filters` match the stored fields.
51
+ */
52
+ export type ActivityLogListQuery = ListQuery<ActivityLog> & {
53
+ filters?: {
54
+ from?: string
55
+ to?: string
56
+ resourceType?: string
57
+ resourceId?: string
58
+ event?: string
59
+ userId?: string
60
+ }
61
+ }
@@ -11,6 +11,7 @@ export type CreateCategoryPayload = {
11
11
  title: string
12
12
  }
13
13
 
14
+ /** The backend requires `title` on the update too (400 without it). */
14
15
  export type UpdateCategoryPayload = {
15
16
  title?: string
16
17
  }
@@ -0,0 +1,88 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
2
+ import { CreditMovementsApi } from './CreditMovementsApi'
3
+ import type { ApiClient } from '../../core/ApiClient'
4
+
5
+ // ── Mock client factory ──────────────────────────────────────────────
6
+
7
+ function createMockClient(): ApiClient {
8
+ return {
9
+ setAccessToken: vi.fn().mockReturnThis(),
10
+ request: vi.fn(),
11
+ requestRaw: vi.fn(),
12
+ get: vi.fn(),
13
+ post: vi.fn(),
14
+ put: vi.fn(),
15
+ patch: vi.fn(),
16
+ delete: vi.fn(),
17
+ }
18
+ }
19
+
20
+ // ── Tests ────────────────────────────────────────────────────────────
21
+
22
+ describe('CreditMovementsApi', () => {
23
+ let client: ReturnType<typeof createMockClient>
24
+ let api: CreditMovementsApi
25
+
26
+ beforeEach(() => {
27
+ client = createMockClient()
28
+ api = new CreditMovementsApi(client)
29
+ })
30
+
31
+ it('balances calls client.get with /credit-movements/balances', async () => {
32
+ await api.balances()
33
+ expect(client.get).toHaveBeenCalledWith('/credit-movements/balances', undefined)
34
+ })
35
+
36
+ it('balance posts the service type to /credit-movements/balance', async () => {
37
+ vi.mocked(client.post).mockResolvedValue(20)
38
+ await expect(api.balance('sms-wavy')).resolves.toBe(20)
39
+ expect(client.post).toHaveBeenCalledWith(
40
+ '/credit-movements/balance',
41
+ { serviceType: 'sms-wavy' },
42
+ undefined,
43
+ )
44
+ })
45
+
46
+ it('balancesV2 serializes the period', async () => {
47
+ await api.balancesV2({ from: '2026-10-01', to: '2026-10-17' })
48
+ const url = vi.mocked(client.get).mock.calls[0]?.[0] as string
49
+ expect(url).toMatch(/^\/credit-movements\/v2\/balances\?/)
50
+ expect(decodeURIComponent(url)).toContain('"from":"2026-10-01"')
51
+ })
52
+
53
+ it('balancesV2 sends no query without a period', async () => {
54
+ await api.balancesV2()
55
+ expect(client.get).toHaveBeenCalledWith('/credit-movements/v2/balances', undefined)
56
+ })
57
+
58
+ it('totalServices serializes the filters and the page', async () => {
59
+ await api.totalServices({
60
+ filters: { from: '2026-10-01', to: '2026-10-17', serviceType: 'summary' },
61
+ page: 1,
62
+ })
63
+ const url = vi.mocked(client.get).mock.calls[0]?.[0] as string
64
+ expect(url).toMatch(/^\/credit-movements\/total-services\?/)
65
+ expect(decodeURIComponent(url)).toContain('"page":1')
66
+ })
67
+
68
+ it('exportXlsx resolves the binary body of requestRaw', async () => {
69
+ const requestRaw = vi.fn().mockResolvedValue(new Response(new ArrayBuffer(4)))
70
+ client.requestRaw = requestRaw
71
+ const result = await api.exportXlsx({
72
+ from: '2026-10-01',
73
+ to: '2026-10-17',
74
+ where: { $and: [] },
75
+ })
76
+ expect(result.byteLength).toBe(4)
77
+ const [method, url] = requestRaw.mock.calls[0] ?? []
78
+ expect(method).toBe('GET')
79
+ expect(url).toMatch(/^\/credit-movements\/export\?/)
80
+ })
81
+
82
+ it('exportXlsx refuses a client without requestRaw', async () => {
83
+ const withoutRaw: ApiClient = { ...client, requestRaw: undefined }
84
+ await expect(
85
+ new CreditMovementsApi(withoutRaw).exportXlsx({ from: 'a', to: 'b', where: { $and: [] } }),
86
+ ).rejects.toThrow('requestRaw')
87
+ })
88
+ })
@@ -4,12 +4,19 @@ import type {
4
4
  CreditMovement,
5
5
  CreateCreditMovementPayload,
6
6
  UpdateCreditMovementPayload,
7
+ CreditBalances,
8
+ CreditBalanceV2,
9
+ CreditBalancesV2Query,
10
+ CreditMovementServiceType,
11
+ CreditMovementsExportQuery,
12
+ CreditTotalServices,
13
+ CreditTotalServicesQuery,
7
14
  } from './types'
8
15
 
9
16
  /**
10
17
  * Credit movements of the account (SMS and AI credits), only for reading: the writes are super
11
- * admin routes (`/admin/credit-movements`). The backend serves only `GET /credit-movements` and
12
- * `GET /credit-movements/:id`.
18
+ * admin routes (`/admin/credit-movements`). Besides the list and the read by id, the backend serves the
19
+ * balances, the totals per connection and the xlsx export.
13
20
  */
14
21
  export class CreditMovementsApi extends BaseCrudApi<
15
22
  CreditMovement,
@@ -41,4 +48,68 @@ export class CreditMovementsApi extends BaseCrudApi<
41
48
  override deleteById(id: string, headers?: Record<string, string>): Promise<CreditMovement> {
42
49
  return super.deleteById(id, headers)
43
50
  }
51
+
52
+ /** The balance of each service type of the account. */
53
+ balances(headers?: Record<string, string>): Promise<CreditBalances> {
54
+ return this.client.get<CreditBalances>(`${this.basePath}/balances`, headers)
55
+ }
56
+
57
+ /**
58
+ * The balance of one service type (a read, despite the POST). Without `serviceType` the route answers 500.
59
+ */
60
+ balance(
61
+ serviceType: CreditMovementServiceType,
62
+ headers?: Record<string, string>,
63
+ ): Promise<number> {
64
+ return this.client.post<number, { serviceType: CreditMovementServiceType }>(
65
+ `${this.basePath}/balance`,
66
+ { serviceType },
67
+ headers,
68
+ )
69
+ }
70
+
71
+ /** The balances of the period by service type and connection (`ins` without the trial credits). */
72
+ balancesV2(
73
+ query?: CreditBalancesV2Query,
74
+ headers?: Record<string, string>,
75
+ ): Promise<Record<CreditMovementServiceType, CreditBalanceV2>> {
76
+ return this.client.get<Record<CreditMovementServiceType, CreditBalanceV2>>(
77
+ `${this.basePath}/v2/balances${this.toQueryString(query)}`,
78
+ headers,
79
+ )
80
+ }
81
+
82
+ /**
83
+ * The total of credits of each connection in the period (five per page). Resolves `undefined` (no body)
84
+ * when `filters.from`, `filters.to`, `filters.serviceType` or `page` is missing.
85
+ */
86
+ totalServices(
87
+ query: CreditTotalServicesQuery,
88
+ headers?: Record<string, string>,
89
+ ): Promise<CreditTotalServices | undefined> {
90
+ return this.client.get<CreditTotalServices | undefined>(
91
+ `${this.basePath}/total-services${this.toQueryString(query)}`,
92
+ headers,
93
+ )
94
+ }
95
+
96
+ /**
97
+ * Exports the movements of the period as an xlsx workbook (binary). Needs a client with `requestRaw`.
98
+ * Without `where.$and` the route answers 500.
99
+ */
100
+ async exportXlsx(
101
+ query: CreditMovementsExportQuery,
102
+ headers?: Record<string, string>,
103
+ ): Promise<ArrayBuffer> {
104
+ if (!this.client.requestRaw) {
105
+ throw new Error('exportXlsx needs a client with requestRaw (the answer is a binary xlsx)')
106
+ }
107
+ const response = await this.client.requestRaw(
108
+ 'GET',
109
+ `${this.basePath}/export${this.toQueryString(query)}`,
110
+ undefined,
111
+ headers,
112
+ )
113
+ return response.arrayBuffer()
114
+ }
44
115
  }