@ikatec/digisac-api-sdk 4.4.0 → 4.5.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 (76) hide show
  1. package/dist/apis/cards/CardsApi.cjs +70 -0
  2. package/dist/apis/cards/CardsApi.cjs.map +1 -1
  3. package/dist/apis/cards/CardsApi.d.ts +53 -1
  4. package/dist/apis/cards/CardsApi.d.ts.map +1 -1
  5. package/dist/apis/cards/CardsApi.mjs +70 -0
  6. package/dist/apis/cards/CardsApi.mjs.map +1 -1
  7. package/dist/apis/cards/types.d.ts +84 -0
  8. package/dist/apis/cards/types.d.ts.map +1 -1
  9. package/dist/apis/kanbanBoards/types.d.ts +33 -4
  10. package/dist/apis/kanbanBoards/types.d.ts.map +1 -1
  11. package/dist/apis/kanbanCards/KanbanCardsApi.cjs +8 -0
  12. package/dist/apis/kanbanCards/KanbanCardsApi.cjs.map +1 -1
  13. package/dist/apis/kanbanCards/KanbanCardsApi.d.ts +7 -1
  14. package/dist/apis/kanbanCards/KanbanCardsApi.d.ts.map +1 -1
  15. package/dist/apis/kanbanCards/KanbanCardsApi.mjs +8 -0
  16. package/dist/apis/kanbanCards/KanbanCardsApi.mjs.map +1 -1
  17. package/dist/apis/kanbanCards/types.d.ts +17 -5
  18. package/dist/apis/kanbanCards/types.d.ts.map +1 -1
  19. package/dist/apis/kanbanColumns/KanbanColumnsApi.cjs +9 -0
  20. package/dist/apis/kanbanColumns/KanbanColumnsApi.cjs.map +1 -1
  21. package/dist/apis/kanbanColumns/KanbanColumnsApi.d.ts +8 -1
  22. package/dist/apis/kanbanColumns/KanbanColumnsApi.d.ts.map +1 -1
  23. package/dist/apis/kanbanColumns/KanbanColumnsApi.mjs +9 -0
  24. package/dist/apis/kanbanColumns/KanbanColumnsApi.mjs.map +1 -1
  25. package/dist/apis/kanbanColumns/types.d.ts +14 -3
  26. package/dist/apis/kanbanColumns/types.d.ts.map +1 -1
  27. package/dist/apis/messages/MessagesApi.cjs +4 -1
  28. package/dist/apis/messages/MessagesApi.cjs.map +1 -1
  29. package/dist/apis/messages/MessagesApi.d.ts +5 -2
  30. package/dist/apis/messages/MessagesApi.d.ts.map +1 -1
  31. package/dist/apis/messages/MessagesApi.mjs +4 -1
  32. package/dist/apis/messages/MessagesApi.mjs.map +1 -1
  33. package/dist/apis/messages/types.d.ts +13 -0
  34. package/dist/apis/messages/types.d.ts.map +1 -1
  35. package/dist/apis/pipeline/PipelineApi.cjs +133 -0
  36. package/dist/apis/pipeline/PipelineApi.cjs.map +1 -1
  37. package/dist/apis/pipeline/PipelineApi.d.ts +102 -1
  38. package/dist/apis/pipeline/PipelineApi.d.ts.map +1 -1
  39. package/dist/apis/pipeline/PipelineApi.mjs +133 -0
  40. package/dist/apis/pipeline/PipelineApi.mjs.map +1 -1
  41. package/dist/apis/pipeline/types.d.ts +164 -0
  42. package/dist/apis/pipeline/types.d.ts.map +1 -1
  43. package/dist/apis/tags/TagsApi.cjs +3 -2
  44. package/dist/apis/tags/TagsApi.cjs.map +1 -1
  45. package/dist/apis/tags/TagsApi.d.ts +6 -5
  46. package/dist/apis/tags/TagsApi.d.ts.map +1 -1
  47. package/dist/apis/tags/TagsApi.mjs +3 -2
  48. package/dist/apis/tags/TagsApi.mjs.map +1 -1
  49. package/dist/apis/tags/types.d.ts +5 -0
  50. package/dist/apis/tags/types.d.ts.map +1 -1
  51. package/dist/apis/users/types.d.ts +21 -3
  52. package/dist/apis/users/types.d.ts.map +1 -1
  53. package/package.json +1 -1
  54. package/src/apis/cards/CardsApi.test.ts +128 -0
  55. package/src/apis/cards/CardsApi.ts +124 -1
  56. package/src/apis/cards/types.ts +81 -0
  57. package/src/apis/kanbanBoards/types.ts +36 -4
  58. package/src/apis/kanbanCards/KanbanCardsApi.test.ts +46 -0
  59. package/src/apis/kanbanCards/KanbanCardsApi.ts +23 -1
  60. package/src/apis/kanbanCards/types.ts +18 -5
  61. package/src/apis/kanbanColumns/KanbanColumnsApi.test.ts +46 -0
  62. package/src/apis/kanbanColumns/KanbanColumnsApi.ts +24 -1
  63. package/src/apis/kanbanColumns/types.ts +15 -3
  64. package/src/apis/me/MeApi.test.ts +3 -3
  65. package/src/apis/messages/MessagesApi.test.ts +11 -0
  66. package/src/apis/messages/MessagesApi.ts +6 -3
  67. package/src/apis/messages/types.ts +13 -0
  68. package/src/apis/payloads.test-d.ts +30 -0
  69. package/src/apis/pipeline/PipelineApi.test.ts +193 -0
  70. package/src/apis/pipeline/PipelineApi.ts +274 -1
  71. package/src/apis/pipeline/types.ts +162 -0
  72. package/src/apis/tags/TagsApi.test.ts +5 -0
  73. package/src/apis/tags/TagsApi.ts +8 -6
  74. package/src/apis/tags/types.ts +6 -0
  75. package/src/apis/users/UsersApi.test.ts +3 -3
  76. package/src/apis/users/types.ts +23 -3
@@ -1,4 +1,5 @@
1
1
  import type { Department } from '../departments/types'
2
+ import type { WhereClause } from '../../core/types'
2
3
 
3
4
  export type PipelineStageStatus = {
4
5
  id: string
@@ -95,3 +96,164 @@ export type UpdatePipelinePayload = {
95
96
  goBack?: boolean
96
97
  permissionToViewCard?: boolean | null
97
98
  }
99
+
100
+ /** Codes the stage routes answer (as a JSON string, with 200) instead of the stage. */
101
+ export type PipelineStageRefusal = 'STAGES_LIMIT' | 'STAGE_ALREADY_EXIST'
102
+
103
+ export type PipelineStageStatusInput = {
104
+ /** Send the `id` of an existing status to keep it on update; omit it to create one. */
105
+ id?: string
106
+ name: string
107
+ position: number
108
+ }
109
+
110
+ export type PipelineStageReasonInput = {
111
+ /** Send the `id` of an existing reason to keep it on update; omit it to create one. */
112
+ id?: string
113
+ name: string
114
+ position: number
115
+ isWon?: boolean
116
+ }
117
+
118
+ export type CreatePipelineStagePayload = {
119
+ /** Up to 255 characters; must not repeat the name of another stage of the pipeline. */
120
+ name: string
121
+ pipelineId: string
122
+ /** Must be truthy — the backend `required` rule refuses `0`. */
123
+ position: number
124
+ /** Up to 10. */
125
+ statuses?: PipelineStageStatusInput[]
126
+ /** Up to 20. */
127
+ reasons?: PipelineStageReasonInput[]
128
+ }
129
+
130
+ export type UpdatePipelineStagePayload = CreatePipelineStagePayload & {
131
+ /**
132
+ * The stage id. Send it: the duplicate-name check compares against the `id` of the body,
133
+ * so without it keeping the current name answers `'STAGE_ALREADY_EXIST'`.
134
+ */
135
+ id?: string
136
+ }
137
+
138
+ /**
139
+ * Where the cards of a deleted stage go:
140
+ * - `typeAction: 'move'` moves them to `idNewStage` (a stage of the same pipeline), clearing
141
+ * status, reason and result;
142
+ * - without `typeAction`, they are archived and moved to the first stage of the pipeline.
143
+ */
144
+ export type DeletePipelineStagePayload = {
145
+ typeAction?: 'move'
146
+ idNewStage?: string
147
+ /**
148
+ * Author of the card movements written by `'move'` — the backend reads it from the body, not
149
+ * from the token (the UI sends the logged user). Without it, moving a stage that has cards
150
+ * fails with 500 (`CardMovement.userId cannot be null`) after the cards were already moved,
151
+ * and the stage is kept.
152
+ */
153
+ user?: { id: string }
154
+ }
155
+
156
+ /** Answer of the stage deletion; `'PIPELINES_MIN_STAGES'` = refused, the pipeline keeps 2 stages. */
157
+ export type DeletePipelineStageResult = 'MESSAGE_STAGE_DELETED' | 'PIPELINES_MIN_STAGES'
158
+
159
+ export type PipelineStatusRef = { id: string; name: string }
160
+
161
+ /** `GET /pipelines/status/{id}`: the status plus how many cards use it. */
162
+ export type PipelineStageStatusWithCount = PipelineStageStatus & { cardsCount: number }
163
+
164
+ /**
165
+ * What happens to the cards of a deleted status: `'keep-without-status'` clears their status,
166
+ * `'move-to-another'` sets `newStatusId` (not validated by the backend).
167
+ */
168
+ export type DeletePipelineStatusPayload =
169
+ | { action: 'keep-without-status' }
170
+ | { action: 'move-to-another'; newStatusId: string }
171
+
172
+ export type PipelineAutomationType = 'notification'
173
+
174
+ export type PipelineAutomationConfig = {
175
+ notify?: 'high' | 'medium' | 'medium-high'
176
+ frequency?: 'daily' | 'weekly' | 'biweekly' | 'monthly'
177
+ day?: string
178
+ from?: { high?: string; medium?: string }
179
+ recipient?: 'admin' | 'owner' | 'both'
180
+ }
181
+
182
+ export type PipelineAutomation = {
183
+ id: string
184
+ pipelineId: string
185
+ type: PipelineAutomationType
186
+ isArchived: boolean | null
187
+ archivedAt: string | null
188
+ config: PipelineAutomationConfig
189
+ createdAt: string
190
+ updatedAt: string
191
+ }
192
+
193
+ export type CreatePipelineAutomationPayload = {
194
+ pipelineId: string
195
+ /** The backend does not validate it (any string is stored); `'notification'` is the only one used. */
196
+ type: PipelineAutomationType
197
+ config?: PipelineAutomationConfig
198
+ isArchived?: boolean
199
+ }
200
+
201
+ /** The backend validator requires `pipelineId` and `type` on update too. */
202
+ export type UpdatePipelineAutomationPayload = CreatePipelineAutomationPayload
203
+
204
+ /** Card date filters of the CSV export; the UI sends `'YYYY-MM-DD HH:mm:ss'`. */
205
+ export type ExportPipelinePayload = {
206
+ /** Without both `createdAt*`, the range defaults to now (empty export). */
207
+ createdAtInit?: string
208
+ createdAtFinal?: string
209
+ /** With both `wonAt*`, only won cards are exported. */
210
+ wonAtInit?: string
211
+ wonAtFinal?: string
212
+ }
213
+
214
+ export type PipelinesWithTotalsQuery = {
215
+ /** `accountId` is always injected by the backend. `$and[].createdAt` filters the cards. */
216
+ where?: WhereClause<PipelineRecord>
217
+ order?: [string, 'ASC' | 'DESC'][]
218
+ limit?: number
219
+ /** `true` lists only the pipelines that are not archived. */
220
+ archive?: boolean
221
+ }
222
+
223
+ export type PipelineTotals = {
224
+ id: string
225
+ name: string
226
+ total: number | null
227
+ totalSuccess: number | null
228
+ totalFailed: number | null
229
+ /** A bigint, sent as a string. */
230
+ totalCards: string
231
+ }
232
+
233
+ /**
234
+ * Pipelines without stages are left out; there is no pagination. With a `createdAt` filter, only
235
+ * the stages that have matching cards are listed, but `totals` still has every stage.
236
+ */
237
+ export type PipelinesWithTotals = {
238
+ data: (PipelineRecord & { stages: PipelineStage[]; totals: PipelineTotals[] })[]
239
+ }
240
+
241
+ /** Card filters of the stage totals (same as the board filters of the UI). */
242
+ export type PipelineStageTotalsFilters = {
243
+ status?: { value: string }
244
+ service?: { id: string }
245
+ nameTitle?: string
246
+ /** `DD/MM/YYYY`. */
247
+ createdFrom?: string
248
+ createdUntil?: string
249
+ owner?: { id: string; value?: string }
250
+ wonFrom?: string
251
+ wonUntil?: string
252
+ }
253
+
254
+ export type PipelineStageTotals = PipelineStage & {
255
+ totalCards: number
256
+ totalCardsValue: number
257
+ totalWonCardsValue: number
258
+ totalLostCardsValue: number
259
+ }
@@ -38,6 +38,11 @@ describe('TagsApi', () => {
38
38
  expect(result).toBe('OK')
39
39
  })
40
40
 
41
+ it('resolves to false when no link changed', async () => {
42
+ vi.mocked(client.post).mockResolvedValue(false)
43
+ await expect(api.attachContacts('t1', { where: { id: 'c1' } })).resolves.toBe(false)
44
+ })
45
+
41
46
  it('forwards custom headers', async () => {
42
47
  await api.attachContacts('t1', { where: { id: 'c1' } }, headers)
43
48
  expect(client.post).toHaveBeenCalledWith(
@@ -5,6 +5,7 @@ import type {
5
5
  AttachTagsToDepartmentsPayload,
6
6
  CreateTagPayload,
7
7
  Tag,
8
+ TagContactsLinkResult,
8
9
  UpdateTagPayload,
9
10
  } from './types'
10
11
 
@@ -14,15 +15,16 @@ export class TagsApi extends BaseCrudApi<Tag, CreateTagPayload, UpdateTagPayload
14
15
  }
15
16
 
16
17
  /**
17
- * Adds the tag to every contact of the account that matches the selection. Resolves to `'OK'`.
18
+ * Adds the tag to every contact of the account that matches the selection. Resolves to `'OK'`,
19
+ * or `false` when every contact already had the tag.
18
20
  * @permissions tags.view
19
21
  */
20
22
  attachContacts(
21
23
  id: string,
22
24
  body: ContactsSelection,
23
25
  headers?: Record<string, string>,
24
- ): Promise<string> {
25
- return this.client.post<string, ContactsSelection>(
26
+ ): Promise<TagContactsLinkResult> {
27
+ return this.client.post<TagContactsLinkResult, ContactsSelection>(
26
28
  `${this.basePath}/${id}/contacts`,
27
29
  body,
28
30
  headers,
@@ -31,15 +33,15 @@ export class TagsApi extends BaseCrudApi<Tag, CreateTagPayload, UpdateTagPayload
31
33
 
32
34
  /**
33
35
  * Removes the tag from every contact of the account that matches the selection. Resolves to
34
- * `'OK'`.
36
+ * `'OK'`, or `false` when no contact had the tag.
35
37
  * @permissions tags.view OR tags.destroy
36
38
  */
37
39
  detachContacts(
38
40
  id: string,
39
41
  body: ContactsSelection,
40
42
  headers?: Record<string, string>,
41
- ): Promise<string> {
42
- return this.client.request<string, ContactsSelection>(
43
+ ): Promise<TagContactsLinkResult> {
44
+ return this.client.request<TagContactsLinkResult, ContactsSelection>(
43
45
  'DELETE',
44
46
  `${this.basePath}/${id}/contacts`,
45
47
  body,
@@ -28,6 +28,12 @@ export type UpdateTagPayload = {
28
28
  backgroundColor?: string | null
29
29
  }
30
30
 
31
+ /**
32
+ * Result of linking or unlinking a tag and the contacts of a selection: `'OK'` when at least one
33
+ * link changed, `false` when nothing changed (every contact already had, or did not have, the tag).
34
+ */
35
+ export type TagContactsLinkResult = 'OK' | false
36
+
31
37
  /**
32
38
  * Body for `POST /tags/attach-many-departments`. An empty `departmentIds` makes the tags
33
39
  * available to every department.
@@ -32,15 +32,15 @@ const user: User = {
32
32
  email: 'alice@example.com',
33
33
  phoneNumber: null,
34
34
  branch: null,
35
- isSuperAdmin: false,
36
35
  isClientUser: false,
37
- active: true,
38
36
  language: 'pt-BR',
39
37
  isFirstLogin: false,
40
38
  status: 'offline',
41
39
  clientsStatus: { web: 'offline', app: 'offline' },
42
- offlineAt: null,
43
40
  isActiveInternalChat: false,
41
+ internalChatToken: null,
42
+ noteReference: false,
43
+ data: {},
44
44
  passwordExpiresAt: null,
45
45
  otpAuthActive: false,
46
46
  preferences: {},
@@ -9,21 +9,39 @@ export type UserPreferences = {
9
9
  isShowTagsChat?: boolean
10
10
  }
11
11
 
12
+ export type UserData = {
13
+ /** Push token of the mobile app; cleared (`null`) when the user is archived. */
14
+ expoPushToken?: string | null
15
+ [key: string]: unknown
16
+ }
17
+
18
+ /** A connection the user is restricted to (`GET /users/:id` of a non-admin user). */
19
+ export type UserRestrictedService = {
20
+ id: string
21
+ name: string
22
+ }
23
+
24
+ /**
25
+ * A user as the API answers it (`userTransformer`). `isSuperAdmin`, `active` and `offlineAt` exist in
26
+ * the database but are never answered.
27
+ */
12
28
  export type User = {
13
29
  id: string
14
30
  name: string
15
31
  email: string
16
32
  phoneNumber: string | null
17
33
  branch: string | null
18
- isSuperAdmin: boolean
19
34
  isClientUser: boolean
20
- active: boolean
21
35
  language: string
22
36
  isFirstLogin: boolean
23
37
  status: UserStatus
24
38
  clientsStatus: Record<string, string> | null
25
- offlineAt: string | null
26
39
  isActiveInternalChat: boolean
40
+ /** Token of the internal chat; `null` right after the creation, regenerated on every write of the user. */
41
+ internalChatToken: string | null
42
+ /** Set by the backend from an internal flag of the user. */
43
+ noteReference: boolean
44
+ data: UserData
27
45
  passwordExpiresAt: string | null
28
46
  otpAuthActive: boolean | null
29
47
  preferences: UserPreferences
@@ -37,6 +55,8 @@ export type User = {
37
55
  timetable?: Timetable | null
38
56
  roles?: Role[]
39
57
  departments?: Department[]
58
+ /** Only in `GET /users/:id`, for a user without an admin role. */
59
+ restrictedServices?: UserRestrictedService[]
40
60
  }
41
61
 
42
62
  export type UserRelationships = 'timetable' | 'roles' | 'departments'