@ikatec/digisac-api-sdk 4.12.0 → 4.14.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 (114) 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/creditMovements/CreditMovementsApi.cjs +31 -2
  18. package/dist/apis/creditMovements/CreditMovementsApi.cjs.map +1 -1
  19. package/dist/apis/creditMovements/CreditMovementsApi.d.ts +21 -3
  20. package/dist/apis/creditMovements/CreditMovementsApi.d.ts.map +1 -1
  21. package/dist/apis/creditMovements/CreditMovementsApi.mjs +31 -2
  22. package/dist/apis/creditMovements/CreditMovementsApi.mjs.map +1 -1
  23. package/dist/apis/creditMovements/types.d.ts +73 -2
  24. package/dist/apis/creditMovements/types.d.ts.map +1 -1
  25. package/dist/apis/knowledgeBase/KnowledgeBaseApi.cjs +27 -0
  26. package/dist/apis/knowledgeBase/KnowledgeBaseApi.cjs.map +1 -1
  27. package/dist/apis/knowledgeBase/KnowledgeBaseApi.d.ts +22 -1
  28. package/dist/apis/knowledgeBase/KnowledgeBaseApi.d.ts.map +1 -1
  29. package/dist/apis/knowledgeBase/KnowledgeBaseApi.mjs +27 -0
  30. package/dist/apis/knowledgeBase/KnowledgeBaseApi.mjs.map +1 -1
  31. package/dist/apis/knowledgeBase/types.d.ts +56 -2
  32. package/dist/apis/knowledgeBase/types.d.ts.map +1 -1
  33. package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.cjs +26 -0
  34. package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.cjs.map +1 -1
  35. package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.d.ts +24 -0
  36. package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.d.ts.map +1 -1
  37. package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.mjs +26 -0
  38. package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.mjs.map +1 -1
  39. package/dist/apis/knowledgeBaseItem/types.d.ts +23 -6
  40. package/dist/apis/knowledgeBaseItem/types.d.ts.map +1 -1
  41. package/dist/apis/notifications/NotificationsApi.cjs +50 -2
  42. package/dist/apis/notifications/NotificationsApi.cjs.map +1 -1
  43. package/dist/apis/notifications/NotificationsApi.d.ts +41 -3
  44. package/dist/apis/notifications/NotificationsApi.d.ts.map +1 -1
  45. package/dist/apis/notifications/NotificationsApi.mjs +50 -2
  46. package/dist/apis/notifications/NotificationsApi.mjs.map +1 -1
  47. package/dist/apis/notifications/types.d.ts +57 -8
  48. package/dist/apis/notifications/types.d.ts.map +1 -1
  49. package/dist/apis/serviceAccessManagement/ServiceAccessManagementApi.cjs.map +1 -1
  50. package/dist/apis/serviceAccessManagement/ServiceAccessManagementApi.d.ts +4 -1
  51. package/dist/apis/serviceAccessManagement/ServiceAccessManagementApi.d.ts.map +1 -1
  52. package/dist/apis/serviceAccessManagement/ServiceAccessManagementApi.mjs.map +1 -1
  53. package/dist/apis/serviceAccessManagement/types.d.ts +3 -0
  54. package/dist/apis/serviceAccessManagement/types.d.ts.map +1 -1
  55. package/dist/apis/services/ServicesApi.cjs +10 -0
  56. package/dist/apis/services/ServicesApi.cjs.map +1 -1
  57. package/dist/apis/services/ServicesApi.d.ts +9 -1
  58. package/dist/apis/services/ServicesApi.d.ts.map +1 -1
  59. package/dist/apis/services/ServicesApi.mjs +10 -0
  60. package/dist/apis/services/ServicesApi.mjs.map +1 -1
  61. package/dist/apis/services/types.d.ts +10 -0
  62. package/dist/apis/services/types.d.ts.map +1 -1
  63. package/dist/apis/stickerUsers/StickerUsersApi.cjs.map +1 -1
  64. package/dist/apis/stickerUsers/StickerUsersApi.d.ts +3 -1
  65. package/dist/apis/stickerUsers/StickerUsersApi.d.ts.map +1 -1
  66. package/dist/apis/stickerUsers/StickerUsersApi.mjs.map +1 -1
  67. package/dist/apis/stickerUsers/types.d.ts +4 -0
  68. package/dist/apis/stickerUsers/types.d.ts.map +1 -1
  69. package/dist/apis/stickers/StickersApi.cjs +27 -3
  70. package/dist/apis/stickers/StickersApi.cjs.map +1 -1
  71. package/dist/apis/stickers/StickersApi.d.ts +24 -4
  72. package/dist/apis/stickers/StickersApi.d.ts.map +1 -1
  73. package/dist/apis/stickers/StickersApi.mjs +27 -3
  74. package/dist/apis/stickers/StickersApi.mjs.map +1 -1
  75. package/dist/apis/stickers/types.d.ts +31 -4
  76. package/dist/apis/stickers/types.d.ts.map +1 -1
  77. package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.cjs +1 -2
  78. package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.cjs.map +1 -1
  79. package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.d.ts +1 -2
  80. package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.d.ts.map +1 -1
  81. package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.mjs +1 -2
  82. package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.mjs.map +1 -1
  83. package/package.json +1 -1
  84. package/src/apis/absence/AbsenceApi.test.ts +65 -0
  85. package/src/apis/absence/AbsenceApi.ts +77 -4
  86. package/src/apis/absence/types.ts +53 -2
  87. package/src/apis/activityLog/ActivityLogApi.test.ts +44 -0
  88. package/src/apis/activityLog/ActivityLogApi.ts +22 -3
  89. package/src/apis/activityLog/types.ts +47 -8
  90. package/src/apis/creditMovements/CreditMovementsApi.test.ts +88 -0
  91. package/src/apis/creditMovements/CreditMovementsApi.ts +73 -2
  92. package/src/apis/creditMovements/types.ts +74 -2
  93. package/src/apis/knowledgeBase/KnowledgeBaseApi.test.ts +54 -0
  94. package/src/apis/knowledgeBase/KnowledgeBaseApi.ts +61 -1
  95. package/src/apis/knowledgeBase/types.ts +62 -2
  96. package/src/apis/knowledgeBaseItem/KnowledgeBaseItemApi.test.ts +57 -0
  97. package/src/apis/knowledgeBaseItem/KnowledgeBaseItemApi.ts +45 -0
  98. package/src/apis/knowledgeBaseItem/types.ts +23 -6
  99. package/src/apis/me/MeApi.test.ts +1 -1
  100. package/src/apis/notifications/NotificationsApi.test.ts +74 -0
  101. package/src/apis/notifications/NotificationsApi.ts +88 -3
  102. package/src/apis/notifications/types.ts +68 -7
  103. package/src/apis/payloads.test-d.ts +66 -0
  104. package/src/apis/serviceAccessManagement/ServiceAccessManagementApi.ts +4 -1
  105. package/src/apis/serviceAccessManagement/types.ts +3 -0
  106. package/src/apis/services/ServicesApi.test.ts +11 -0
  107. package/src/apis/services/ServicesApi.ts +21 -0
  108. package/src/apis/services/types.ts +12 -0
  109. package/src/apis/stickerUsers/StickerUsersApi.ts +3 -1
  110. package/src/apis/stickerUsers/types.ts +4 -0
  111. package/src/apis/stickers/StickersApi.test.ts +58 -0
  112. package/src/apis/stickers/StickersApi.ts +46 -4
  113. package/src/apis/stickers/types.ts +32 -4
  114. package/src/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.ts +1 -2
@@ -91,4 +91,15 @@ describe('ServicesApi', () => {
91
91
  })
92
92
  },
93
93
  )
94
+
95
+ describe('accessManagement', () => {
96
+ it('posts the users and the deny flag to /services/:id/access-management', async () => {
97
+ vi.mocked(client.post).mockResolvedValue({ message: '1 users denied access.' })
98
+ const body = { userIds: ['u-1'], deny: true }
99
+ await expect(api.accessManagement('svc-1', body)).resolves.toEqual({
100
+ message: '1 users denied access.',
101
+ })
102
+ expect(client.post).toHaveBeenCalledWith('/services/svc-1/access-management', body, undefined)
103
+ })
104
+ })
94
105
  })
@@ -6,6 +6,8 @@ import type {
6
6
  ServiceLimits,
7
7
  UpdateServicePayload,
8
8
  ArchiveServicePayload,
9
+ ServiceAccessManagementPayload,
10
+ ServiceAccessManagementResponse,
9
11
  } from './types'
10
12
 
11
13
  export class ServicesApi extends ArchivableCrudApi<
@@ -109,4 +111,23 @@ export class ServicesApi extends ArchivableCrudApi<
109
111
  restart(id: string, headers?: Record<string, string>): Promise<'OK'> {
110
112
  return this.client.post<'OK'>(`${this.basePath}/${id}/restart`, undefined, headers)
111
113
  }
114
+
115
+ /**
116
+ * Denies the connection to users (`deny: true`) or gives it back (`deny: false`); the admins are skipped. Denying
117
+ * transfers the open tickets of those users in the connection. The rows are read with
118
+ * `ServiceAccessManagementApi.getMany`. An unknown connection answers 404 `Service not found.`; a missing
119
+ * `userIds` or a `deny` that is not a boolean answers 400.
120
+ * @permissions users.update AND services.operate
121
+ */
122
+ accessManagement(
123
+ id: string,
124
+ body: ServiceAccessManagementPayload,
125
+ headers?: Record<string, string>,
126
+ ): Promise<ServiceAccessManagementResponse> {
127
+ return this.client.post<ServiceAccessManagementResponse, ServiceAccessManagementPayload>(
128
+ `${this.basePath}/${id}/access-management`,
129
+ body,
130
+ headers,
131
+ )
132
+ }
112
133
  }
@@ -292,3 +292,15 @@ export type ServiceLimit = {
292
292
 
293
293
  /** Connections used and allowed by the account plan, by connection type. */
294
294
  export type ServiceLimits = Partial<Record<ServiceType, ServiceLimit>>
295
+
296
+ /** The body of `accessManagement`: the users to deny (or give back) the connection to. */
297
+ export type ServiceAccessManagementPayload = {
298
+ userIds: string[]
299
+ /** `true` denies the connection to the users (their open tickets in it are transferred); `false` gives it back. */
300
+ deny: boolean
301
+ }
302
+
303
+ /** What `accessManagement` answers: how many users were denied or given back the connection (no admin is counted). */
304
+ export type ServiceAccessManagementResponse = {
305
+ message: `${number} users denied access.` | `${number} users allowed access.`
306
+ }
@@ -4,7 +4,9 @@ import type { StickerUser } from './types'
4
4
 
5
5
  export class StickerUsersApi extends BaseApi implements HasGetMany<StickerUser> {
6
6
  /**
7
- * Returns a paginated list of sticker-user associations with their related file.
7
+ * The stickers the current user sent recently (`lastSendAt`), paginated; only the `file` include is
8
+ * served. A row is written when the user sends a message of type `sticker` (in the background, after the
9
+ * send).
8
10
  * @permissions stickers.send
9
11
  */
10
12
  getMany(
@@ -10,9 +10,13 @@ export type StickerUser = {
10
10
  createdAt: string
11
11
  updatedAt: string
12
12
  // relationships
13
+ /** @deprecated Not served: the backend only serves the `file` include. */
13
14
  sticker?: Sticker
15
+ /** @deprecated Not served: the backend only serves the `file` include. */
14
16
  user?: User
17
+ /** The image of the sticker. */
15
18
  file?: File
16
19
  }
17
20
 
21
+ /** The backend serves only `file` (`sticker` and `user` are dropped). */
18
22
  export type StickerUserRelationships = 'sticker' | 'user' | 'file'
@@ -0,0 +1,58 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
2
+ import { StickersApi } from './StickersApi'
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('StickersApi', () => {
23
+ let client: ReturnType<typeof createMockClient>
24
+ let api: StickersApi
25
+
26
+ beforeEach(() => {
27
+ client = createMockClient()
28
+ api = new StickersApi(client)
29
+ })
30
+
31
+ it('create posts the image to /stickers', async () => {
32
+ await api.create({ base64: 'iVBOR', name: 'qa' })
33
+ expect(client.post).toHaveBeenCalledWith(
34
+ '/stickers',
35
+ { base64: 'iVBOR', name: 'qa' },
36
+ undefined,
37
+ )
38
+ })
39
+
40
+ it('exist serializes the message and the checksum', async () => {
41
+ vi.mocked(client.get).mockResolvedValue({})
42
+ await expect(api.exist({ messageId: 'm-1', fileChecksum: 'abc' })).resolves.toEqual({})
43
+ const url = vi.mocked(client.get).mock.calls[0]?.[0] as string
44
+ expect(url).toMatch(/^\/stickers\/exist\?/)
45
+ expect(decodeURIComponent(url)).toContain('"fileChecksum":"abc"')
46
+ })
47
+
48
+ it('add posts the message to /stickers/add', async () => {
49
+ await api.add('m-1')
50
+ expect(client.post).toHaveBeenCalledWith('/stickers/add', { messageId: 'm-1' }, undefined)
51
+ })
52
+
53
+ it('remove deletes /stickers/remove/:stickerId', async () => {
54
+ vi.mocked(client.delete).mockResolvedValue('OK')
55
+ await expect(api.remove('s-1')).resolves.toBe('OK')
56
+ expect(client.delete).toHaveBeenCalledWith('/stickers/remove/s-1', undefined)
57
+ })
58
+ })
@@ -1,12 +1,18 @@
1
1
  import type { ApiClient } from '../../core/ApiClient'
2
2
  import { BaseCrudApi } from '../../core/BaseCrudApi'
3
3
  import type { GetByIdQuery } from '../../core/types'
4
- import type { Sticker, CreateStickerPayload, UpdateStickerPayload } from './types'
4
+ import type {
5
+ Sticker,
6
+ CreateStickerPayload,
7
+ UpdateStickerPayload,
8
+ StickerExistQuery,
9
+ } from './types'
5
10
 
6
11
  /**
7
- * Stickers of the account. The backend serves `GET /stickers` and `POST /stickers` (plus
8
- * `GET /stickers/exist`, `POST /stickers/add` and `DELETE /stickers/remove/:stickerId`); there is
9
- * no read by id, update nor `DELETE /stickers/:id`.
12
+ * Stickers of the account: every user of the account sees them. The backend serves `GET /stickers`,
13
+ * `POST /stickers`, `GET /stickers/exist`, `POST /stickers/add` and `DELETE /stickers/remove/:stickerId`;
14
+ * there is no read by id, update nor `DELETE /stickers/:id`. The list accepts only the `file` include.
15
+ * @permissions stickers.send (list) · stickers.management (create, exist, add, remove)
10
16
  */
11
17
  export class StickersApi extends BaseCrudApi<Sticker, CreateStickerPayload, UpdateStickerPayload> {
12
18
  constructor(client: ApiClient) {
@@ -38,4 +44,40 @@ export class StickersApi extends BaseCrudApi<Sticker, CreateStickerPayload, Upda
38
44
  override deleteById(id: string, headers?: Record<string, string>): Promise<Sticker> {
39
45
  return super.deleteById(id, headers)
40
46
  }
47
+
48
+ /**
49
+ * Finds the sticker of the account that came from the message, or from the file of `fileChecksum` or
50
+ * `filehash`. Resolves `{ stickerId }`, or `{}` when there is none; without `messageId` it answers 500
51
+ * `Invalid message ID`.
52
+ */
53
+ exist(
54
+ query: StickerExistQuery,
55
+ headers?: Record<string, string>,
56
+ ): Promise<{ stickerId?: string }> {
57
+ return this.client.get<{ stickerId?: string }>(
58
+ `${this.basePath}/exist${this.toQueryString(query)}`,
59
+ headers,
60
+ )
61
+ }
62
+
63
+ /**
64
+ * Turns the file of a message of the account into a sticker (`type: 'added'`). Idempotent: a sticker that
65
+ * already came from the message (or its file) is answered as is, and a removed one is restored. A message
66
+ * without file answers 500 `Message or file not found`.
67
+ */
68
+ add(messageId: string, headers?: Record<string, string>): Promise<Sticker> {
69
+ return this.client.post<Sticker, { messageId: string }>(
70
+ `${this.basePath}/add`,
71
+ { messageId },
72
+ headers,
73
+ )
74
+ }
75
+
76
+ /**
77
+ * Removes a sticker of the account (soft delete; its file stays in the storage) and clears it from the
78
+ * recent stickers of every user. Resolves the text `'OK'`, or `false` when there is no such sticker.
79
+ */
80
+ remove(stickerId: string, headers?: Record<string, string>): Promise<'OK' | false> {
81
+ return this.client.delete<'OK' | false>(`${this.basePath}/remove/${stickerId}`, headers)
82
+ }
41
83
  }
@@ -1,8 +1,12 @@
1
+ import type { File } from '../files/types'
2
+ import type { Message } from '../messages/types'
1
3
  import type { User } from '../users/types'
2
4
 
5
+ /** A sticker of the account (every user of the account sees it). */
3
6
  export type Sticker = {
4
7
  id: string
5
- type: string
8
+ /** `'created'` (uploaded with `create`) or `'added'` (taken from a message with `add`). */
9
+ type: 'created' | 'added' | (string & {})
6
10
  originFileChecksum: string | null
7
11
  originFilehash: string | null
8
12
  originMessageId: string | null
@@ -10,20 +14,44 @@ export type Sticker = {
10
14
  accountId: string
11
15
  createdAt: string
12
16
  updatedAt: string
13
- deletedAt: string | null
17
+ deletedAt?: string | null
14
18
  // relationships
19
+ /** @deprecated Not served: the backend only serves the `file` include. */
15
20
  user?: User
21
+ /** The image (webp) of the sticker. */
22
+ file?: File
23
+ /** The message the sticker came from (`add`); `null` on a sticker uploaded with `create`. */
24
+ originMessage?: Message | null
16
25
  }
17
26
 
18
- export type StickerRelationships = 'user'
27
+ /** The backend serves only `file` (`user` is dropped). */
28
+ export type StickerRelationships = 'user' | 'file'
19
29
 
30
+ /**
31
+ * Uploads an image as a sticker: the backend converts it to a 512x512 webp (413 when it ends up too large:
32
+ * 100KB static, 500KB animated). `base64` without the `data:...;base64,` prefix.
33
+ */
20
34
  export type CreateStickerPayload = {
21
- type: string
35
+ base64: string
36
+ /** The name of the file (`<name>.webp`). */
37
+ name: string
38
+ /** @deprecated Ignored by the backend: a created sticker is always `'created'`. */
39
+ type?: string
40
+ /** @deprecated Ignored by the backend: use `add` to take a sticker from a message. */
22
41
  originMessageId?: string
42
+ /** @deprecated Ignored by the backend. */
23
43
  originFileChecksum?: string
44
+ /** @deprecated Ignored by the backend. */
24
45
  originFilehash?: string
25
46
  }
26
47
 
27
48
  export type UpdateStickerPayload = {
28
49
  type?: string
29
50
  }
51
+
52
+ /** Query of `exist`: finds a sticker of the account by the message or by the file it came from. */
53
+ export type StickerExistQuery = {
54
+ messageId: string
55
+ fileChecksum?: string
56
+ filehash?: string
57
+ }
@@ -81,8 +81,7 @@ export class WhatsappBusinessTemplatesApi extends BaseCrudApi<
81
81
  }
82
82
 
83
83
  /**
84
- * Reads the template balance from 360Dialog. The backend looks for the 360Dialog connection on the whole platform,
85
- * not only in the account, and calls 360Dialog when it finds one.
84
+ * Reads the template balance from 360Dialog (an external call, when there is a 360Dialog connection).
86
85
  * @permissions hsm.view
87
86
  */
88
87
  resume(headers?: Record<string, string>): Promise<Record<string, unknown>[]> {