@todoist/comms-sdk 0.0.1 → 5.0.1

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 (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +182 -39
  3. package/dist/esm/authentication.js +247 -0
  4. package/dist/esm/clients/add-comment-helper.js +41 -0
  5. package/dist/esm/clients/attachments-client.js +99 -0
  6. package/dist/esm/clients/base-client.js +30 -0
  7. package/dist/esm/clients/channels-client.js +209 -0
  8. package/dist/esm/clients/comments-client.js +177 -0
  9. package/dist/esm/clients/conversation-messages-client.js +167 -0
  10. package/dist/esm/clients/conversations-client.js +281 -0
  11. package/dist/esm/clients/groups-client.js +170 -0
  12. package/dist/esm/clients/hooks-client.js +50 -0
  13. package/dist/esm/clients/inbox-client.js +186 -0
  14. package/dist/esm/clients/notify-audience.js +43 -0
  15. package/dist/esm/clients/reactions-client.js +96 -0
  16. package/dist/esm/clients/search-client.js +140 -0
  17. package/dist/esm/clients/threads-client.js +363 -0
  18. package/dist/esm/clients/users-client.js +368 -0
  19. package/dist/esm/clients/workspace-users-client.js +299 -0
  20. package/dist/esm/clients/workspaces-client.js +177 -0
  21. package/dist/esm/comms-api.js +67 -0
  22. package/dist/esm/consts/endpoints.js +31 -0
  23. package/dist/esm/index.js +20 -0
  24. package/dist/esm/migration.js +92 -0
  25. package/dist/esm/testUtils/msw-handlers.js +45 -0
  26. package/dist/esm/testUtils/msw-setup.js +32 -0
  27. package/dist/esm/testUtils/obsidian-fetch-adapter.js +50 -0
  28. package/dist/esm/testUtils/test-defaults.js +103 -0
  29. package/dist/esm/transport/fetch-with-retry.js +240 -0
  30. package/dist/esm/transport/http-client.js +53 -0
  31. package/dist/esm/transport/http-dispatcher.js +149 -0
  32. package/dist/esm/types/api-version.js +5 -0
  33. package/dist/esm/types/entities.js +515 -0
  34. package/dist/esm/types/enums.js +34 -0
  35. package/dist/esm/types/errors.js +82 -0
  36. package/dist/esm/types/http.js +1 -0
  37. package/dist/esm/types/index.js +6 -0
  38. package/dist/esm/types/requests.js +184 -0
  39. package/dist/esm/utils/case-conversion.js +47 -0
  40. package/dist/esm/utils/conversation-title.js +110 -0
  41. package/dist/esm/utils/headers.js +29 -0
  42. package/dist/esm/utils/index.js +5 -0
  43. package/dist/esm/utils/multipart-upload.js +198 -0
  44. package/dist/esm/utils/reply-recipients.js +111 -0
  45. package/dist/esm/utils/timestamp-conversion.js +54 -0
  46. package/dist/esm/utils/url-helpers.js +202 -0
  47. package/dist/esm/utils/uuidv7.js +170 -0
  48. package/dist/types/authentication.d.ts +183 -0
  49. package/dist/types/clients/add-comment-helper.d.ts +32 -0
  50. package/dist/types/clients/attachments-client.d.ts +55 -0
  51. package/dist/types/clients/base-client.d.ts +37 -0
  52. package/dist/types/clients/channels-client.d.ts +211 -0
  53. package/dist/types/clients/comments-client.d.ts +228 -0
  54. package/dist/types/clients/conversation-messages-client.d.ts +201 -0
  55. package/dist/types/clients/conversations-client.d.ts +366 -0
  56. package/dist/types/clients/groups-client.d.ts +148 -0
  57. package/dist/types/clients/hooks-client.d.ts +29 -0
  58. package/dist/types/clients/inbox-client.d.ts +478 -0
  59. package/dist/types/clients/notify-audience.d.ts +22 -0
  60. package/dist/types/clients/reactions-client.d.ts +57 -0
  61. package/dist/types/clients/search-client.d.ts +71 -0
  62. package/dist/types/clients/threads-client.d.ts +547 -0
  63. package/dist/types/clients/users-client.d.ts +280 -0
  64. package/dist/types/clients/workspace-users-client.d.ts +172 -0
  65. package/dist/types/clients/workspaces-client.d.ts +154 -0
  66. package/dist/types/comms-api.d.ts +73 -0
  67. package/dist/types/consts/endpoints.d.ts +27 -0
  68. package/dist/types/index.d.ts +21 -0
  69. package/dist/types/migration.d.ts +78 -0
  70. package/dist/types/testUtils/msw-handlers.d.ts +28 -0
  71. package/dist/types/testUtils/msw-setup.d.ts +1 -0
  72. package/dist/types/testUtils/obsidian-fetch-adapter.d.ts +29 -0
  73. package/dist/types/testUtils/test-defaults.d.ts +17 -0
  74. package/dist/types/transport/fetch-with-retry.d.ts +4 -0
  75. package/dist/types/transport/http-client.d.ts +14 -0
  76. package/dist/types/transport/http-dispatcher.d.ts +46 -0
  77. package/dist/types/types/api-version.d.ts +6 -0
  78. package/dist/types/types/entities.d.ts +3081 -0
  79. package/dist/types/types/enums.d.ts +55 -0
  80. package/dist/types/types/errors.d.ts +57 -0
  81. package/dist/types/types/http.d.ts +60 -0
  82. package/dist/types/types/index.d.ts +6 -0
  83. package/dist/types/types/requests.d.ts +604 -0
  84. package/dist/types/utils/case-conversion.d.ts +8 -0
  85. package/dist/types/utils/conversation-title.d.ts +84 -0
  86. package/dist/types/utils/headers.d.ts +13 -0
  87. package/dist/types/utils/index.d.ts +6 -0
  88. package/dist/types/utils/multipart-upload.d.ts +59 -0
  89. package/dist/types/utils/reply-recipients.d.ts +60 -0
  90. package/dist/types/utils/timestamp-conversion.d.ts +13 -0
  91. package/dist/types/utils/url-helpers.d.ts +129 -0
  92. package/dist/types/utils/uuidv7.d.ts +42 -0
  93. package/package.json +80 -8
@@ -0,0 +1,201 @@
1
+ import { z } from 'zod';
2
+ import { type ConversationMessage, type StatusOk } from '../types/entities.js';
3
+ import type { CreateConversationMessageArgs, GetConversationMessagesArgs, UpdateConversationMessageArgs } from '../types/requests.js';
4
+ import { BaseClient } from './base-client.js';
5
+ export declare const ConversationMessageListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
6
+ id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
7
+ content: z.ZodString;
8
+ creator: z.ZodNumber;
9
+ conversationId: z.ZodString;
10
+ posted: z.ZodDate;
11
+ systemMessage: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>>>;
12
+ attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
13
+ attachmentId: z.ZodString;
14
+ urlType: z.ZodString;
15
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
16
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
+ fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
18
+ fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
19
+ underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
21
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
+ imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
23
+ imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
24
+ duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
+ uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
+ video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
+ videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
29
+ }, z.core.$loose>>>>;
30
+ reactions: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodNumber>>>>;
31
+ actions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnknown>>>;
32
+ objIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
33
+ lastEdited: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
34
+ isDeleted: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
35
+ directGroupMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
36
+ directMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
37
+ version: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
38
+ workspaceId: z.ZodNumber;
39
+ }, z.core.$strip>, z.ZodTransform<{
40
+ url: string;
41
+ id: string;
42
+ content: string;
43
+ creator: number;
44
+ conversationId: string;
45
+ posted: Date;
46
+ workspaceId: number;
47
+ systemMessage?: unknown;
48
+ attachments?: {
49
+ [x: string]: unknown;
50
+ attachmentId: string;
51
+ urlType: string;
52
+ title?: string | null | undefined;
53
+ url?: string | null | undefined;
54
+ fileName?: string | null | undefined;
55
+ fileSize?: number | null | undefined;
56
+ underlyingType?: string | null | undefined;
57
+ description?: string | null | undefined;
58
+ image?: string | null | undefined;
59
+ imageWidth?: number | null | undefined;
60
+ imageHeight?: number | null | undefined;
61
+ duration?: string | null | undefined;
62
+ uploadState?: string | null | undefined;
63
+ video?: string | null | undefined;
64
+ videoType?: string | null | undefined;
65
+ videoAutoPlay?: boolean | null | undefined;
66
+ }[] | null | undefined;
67
+ reactions?: Record<string, number[]> | null | undefined;
68
+ actions?: unknown[] | null | undefined;
69
+ objIndex?: number | null | undefined;
70
+ lastEdited?: Date | null | undefined;
71
+ isDeleted?: boolean | null | undefined;
72
+ directGroupMentions?: string[] | null | undefined;
73
+ directMentions?: number[] | null | undefined;
74
+ version?: number | null | undefined;
75
+ }, {
76
+ id: string;
77
+ content: string;
78
+ creator: number;
79
+ conversationId: string;
80
+ posted: Date;
81
+ workspaceId: number;
82
+ systemMessage?: unknown;
83
+ attachments?: {
84
+ [x: string]: unknown;
85
+ attachmentId: string;
86
+ urlType: string;
87
+ title?: string | null | undefined;
88
+ url?: string | null | undefined;
89
+ fileName?: string | null | undefined;
90
+ fileSize?: number | null | undefined;
91
+ underlyingType?: string | null | undefined;
92
+ description?: string | null | undefined;
93
+ image?: string | null | undefined;
94
+ imageWidth?: number | null | undefined;
95
+ imageHeight?: number | null | undefined;
96
+ duration?: string | null | undefined;
97
+ uploadState?: string | null | undefined;
98
+ video?: string | null | undefined;
99
+ videoType?: string | null | undefined;
100
+ videoAutoPlay?: boolean | null | undefined;
101
+ }[] | null | undefined;
102
+ reactions?: Record<string, number[]> | null | undefined;
103
+ actions?: unknown[] | null | undefined;
104
+ objIndex?: number | null | undefined;
105
+ lastEdited?: Date | null | undefined;
106
+ isDeleted?: boolean | null | undefined;
107
+ directGroupMentions?: string[] | null | undefined;
108
+ directMentions?: number[] | null | undefined;
109
+ version?: number | null | undefined;
110
+ }>>>;
111
+ /**
112
+ * Client for `/api/v1.0/conversation_messages/`. The SDK auto-generates the
113
+ * message `id` on `createMessage` when the caller doesn't supply one.
114
+ */
115
+ export declare class ConversationMessagesClient extends BaseClient {
116
+ private readonly linkBaseUrl;
117
+ private readonly messageSchema;
118
+ private readonly messageListSchema;
119
+ /**
120
+ * Gets all messages in a conversation.
121
+ *
122
+ * @param args - The arguments for getting messages.
123
+ * @param args.conversationId - The conversation ID.
124
+ * @param args.newerThan - Optional date to get messages newer than.
125
+ * @param args.olderThan - Optional date to get messages older than.
126
+ * @param args.limit - Optional limit on number of messages returned.
127
+ * @param args.cursor - Optional cursor for pagination.
128
+ * @returns An array of message objects.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const messages = await api.conversationMessages.getMessages({
133
+ * conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
134
+ * newerThan: new Date('2024-01-01'),
135
+ * })
136
+ * ```
137
+ */
138
+ getMessages(args: GetConversationMessagesArgs): Promise<ConversationMessage[]>;
139
+ /**
140
+ * Gets a single conversation message by id.
141
+ *
142
+ * @param id - The message ID.
143
+ * @returns The conversation message object.
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * const message = await api.conversationMessages.getMessage('7YpL3oZ4kZ9vP7Q1tR2sX43')
148
+ * ```
149
+ */
150
+ getMessage(id: string): Promise<ConversationMessage>;
151
+ /**
152
+ * Creates a new message in a conversation. `id` is auto-generated if not
153
+ * supplied.
154
+ *
155
+ * @param args - The arguments for creating a message.
156
+ * @param args.conversationId - The conversation ID.
157
+ * @param args.content - The message content.
158
+ * @param args.attachments - Optional array of {@link Attachment} objects.
159
+ * @param args.actions - Optional array of action objects.
160
+ * @returns The created message object.
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * const message = await api.conversationMessages.createMessage({
165
+ * conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
166
+ * content: 'Thanks for the update!',
167
+ * })
168
+ * ```
169
+ */
170
+ createMessage(args: CreateConversationMessageArgs): Promise<ConversationMessage>;
171
+ /**
172
+ * Updates a conversation message.
173
+ *
174
+ * @param args - The arguments for updating a message.
175
+ * @param args.id - The message ID.
176
+ * @param args.content - The new message content.
177
+ * @param args.attachments - Optional array of {@link Attachment} objects.
178
+ * @returns The updated message object.
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * const message = await api.conversationMessages.updateMessage({
183
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX43',
184
+ * content: 'Updated message content',
185
+ * })
186
+ * ```
187
+ */
188
+ updateMessage(args: UpdateConversationMessageArgs): Promise<ConversationMessage>;
189
+ /**
190
+ * Permanently deletes a conversation message.
191
+ *
192
+ * @param id - The message ID.
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * await api.conversationMessages.deleteMessage('7YpL3oZ4kZ9vP7Q1tR2sX43')
197
+ * ```
198
+ */
199
+ deleteMessage(id: string): Promise<StatusOk>;
200
+ private simple;
201
+ }
@@ -0,0 +1,366 @@
1
+ import { z } from 'zod';
2
+ import { type Conversation, type StatusOk, type UnreadConversation } from '../types/entities.js';
3
+ import type { AddConversationUserArgs, AddConversationUsersArgs, GetConversationsArgs, GetOrCreateConversationArgs, MuteConversationArgs, RemoveConversationUserArgs, RemoveConversationUsersArgs, UpdateConversationArgs } from '../types/requests.js';
4
+ import { BaseClient } from './base-client.js';
5
+ export declare const ConversationListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
6
+ id: z.ZodString;
7
+ workspaceId: z.ZodNumber;
8
+ userIds: z.ZodArray<z.ZodNumber>;
9
+ messageCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
10
+ lastObjIndex: z.ZodNumber;
11
+ snippet: z.ZodString;
12
+ snippetCreators: z.ZodArray<z.ZodNumber>;
13
+ lastActive: z.ZodDate;
14
+ mutedUntil: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
15
+ archived: z.ZodBoolean;
16
+ created: z.ZodDate;
17
+ creator: z.ZodNumber;
18
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
+ private: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
20
+ lastMessage: z.ZodOptional<z.ZodNullable<z.ZodObject<{
21
+ id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
22
+ content: z.ZodString;
23
+ creator: z.ZodNumber;
24
+ conversationId: z.ZodString;
25
+ posted: z.ZodDate;
26
+ systemMessage: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>>>;
27
+ attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
28
+ attachmentId: z.ZodString;
29
+ urlType: z.ZodString;
30
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
31
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
+ fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
34
+ underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
35
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
37
+ imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
38
+ imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
39
+ duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
40
+ uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
41
+ video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
42
+ videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
43
+ videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
44
+ }, z.core.$loose>>>>;
45
+ reactions: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodNumber>>>>;
46
+ actions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnknown>>>;
47
+ objIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
48
+ lastEdited: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
49
+ deleted: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
50
+ directGroupMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
51
+ directMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
52
+ version: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
53
+ workspaceId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
54
+ }, z.core.$strip>>>;
55
+ }, z.core.$strip>, z.ZodTransform<{
56
+ url: string;
57
+ id: string;
58
+ workspaceId: number;
59
+ userIds: number[];
60
+ lastObjIndex: number;
61
+ snippet: string;
62
+ snippetCreators: number[];
63
+ lastActive: Date;
64
+ archived: boolean;
65
+ created: Date;
66
+ creator: number;
67
+ messageCount?: number | null | undefined;
68
+ mutedUntil?: Date | null | undefined;
69
+ title?: string | null | undefined;
70
+ private?: boolean | null | undefined;
71
+ lastMessage?: {
72
+ id: string;
73
+ content: string;
74
+ creator: number;
75
+ conversationId: string;
76
+ posted: Date;
77
+ systemMessage?: unknown;
78
+ attachments?: {
79
+ [x: string]: unknown;
80
+ attachmentId: string;
81
+ urlType: string;
82
+ title?: string | null | undefined;
83
+ url?: string | null | undefined;
84
+ fileName?: string | null | undefined;
85
+ fileSize?: number | null | undefined;
86
+ underlyingType?: string | null | undefined;
87
+ description?: string | null | undefined;
88
+ image?: string | null | undefined;
89
+ imageWidth?: number | null | undefined;
90
+ imageHeight?: number | null | undefined;
91
+ duration?: string | null | undefined;
92
+ uploadState?: string | null | undefined;
93
+ video?: string | null | undefined;
94
+ videoType?: string | null | undefined;
95
+ videoAutoPlay?: boolean | null | undefined;
96
+ }[] | null | undefined;
97
+ reactions?: Record<string, number[]> | null | undefined;
98
+ actions?: unknown[] | null | undefined;
99
+ objIndex?: number | null | undefined;
100
+ lastEdited?: Date | null | undefined;
101
+ deleted?: boolean | null | undefined;
102
+ directGroupMentions?: string[] | null | undefined;
103
+ directMentions?: number[] | null | undefined;
104
+ version?: number | null | undefined;
105
+ workspaceId?: number | null | undefined;
106
+ } | null | undefined;
107
+ }, {
108
+ id: string;
109
+ workspaceId: number;
110
+ userIds: number[];
111
+ lastObjIndex: number;
112
+ snippet: string;
113
+ snippetCreators: number[];
114
+ lastActive: Date;
115
+ archived: boolean;
116
+ created: Date;
117
+ creator: number;
118
+ messageCount?: number | null | undefined;
119
+ mutedUntil?: Date | null | undefined;
120
+ title?: string | null | undefined;
121
+ private?: boolean | null | undefined;
122
+ lastMessage?: {
123
+ id: string;
124
+ content: string;
125
+ creator: number;
126
+ conversationId: string;
127
+ posted: Date;
128
+ systemMessage?: unknown;
129
+ attachments?: {
130
+ [x: string]: unknown;
131
+ attachmentId: string;
132
+ urlType: string;
133
+ title?: string | null | undefined;
134
+ url?: string | null | undefined;
135
+ fileName?: string | null | undefined;
136
+ fileSize?: number | null | undefined;
137
+ underlyingType?: string | null | undefined;
138
+ description?: string | null | undefined;
139
+ image?: string | null | undefined;
140
+ imageWidth?: number | null | undefined;
141
+ imageHeight?: number | null | undefined;
142
+ duration?: string | null | undefined;
143
+ uploadState?: string | null | undefined;
144
+ video?: string | null | undefined;
145
+ videoType?: string | null | undefined;
146
+ videoAutoPlay?: boolean | null | undefined;
147
+ }[] | null | undefined;
148
+ reactions?: Record<string, number[]> | null | undefined;
149
+ actions?: unknown[] | null | undefined;
150
+ objIndex?: number | null | undefined;
151
+ lastEdited?: Date | null | undefined;
152
+ deleted?: boolean | null | undefined;
153
+ directGroupMentions?: string[] | null | undefined;
154
+ directMentions?: number[] | null | undefined;
155
+ version?: number | null | undefined;
156
+ workspaceId?: number | null | undefined;
157
+ } | null | undefined;
158
+ }>>>;
159
+ /**
160
+ * Client for `/api/v1.0/conversations/`. `getOrCreate` requires an `id` (the
161
+ * SDK auto-generates one for new conversations); the backend dedupes on
162
+ * `userIds`, so an existing conversation will be returned with its own
163
+ * already-assigned `id` and your generated one is silently dropped.
164
+ */
165
+ export declare class ConversationsClient extends BaseClient {
166
+ private readonly linkBaseUrl;
167
+ private readonly conversationSchema;
168
+ private readonly conversationListSchema;
169
+ /**
170
+ * Gets a page of conversations for a workspace, newest activity first.
171
+ * The server returns at most 500 rows per request (20 by default); pass
172
+ * the last row's `lastActive`/`id` as `olderThan`/`beforeId` to fetch
173
+ * the next page. Paired, they form a strict compound boundary, so pages
174
+ * never repeat rows. Omitting `archived` returns active and archived
175
+ * conversations mixed.
176
+ *
177
+ * @param args - The arguments for getting conversations.
178
+ * @param args.workspaceId - The workspace ID.
179
+ * @param args.archived - Optional flag to filter archived (true) or active (false) conversations.
180
+ * @param args.olderThan - Optional date to get conversations last active before.
181
+ * @param args.beforeId - Optional conversation id. Paired with olderThan it forms the
182
+ * strict compound cursor; alone it pages by conversation id order instead.
183
+ * @param args.limit - Optional page size (server default 20, max 500).
184
+ * @returns An array of conversation objects.
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * const page = await api.conversations.getConversations({ workspaceId: 123, limit: 500 })
189
+ * const last = page.at(-1)
190
+ * const nextPage = last
191
+ * ? await api.conversations.getConversations({
192
+ * workspaceId: 123,
193
+ * limit: 500,
194
+ * olderThan: last.lastActive,
195
+ * beforeId: last.id,
196
+ * })
197
+ * : []
198
+ * ```
199
+ */
200
+ getConversations(args: GetConversationsArgs): Promise<Conversation[]>;
201
+ /**
202
+ * Gets a single conversation object by id.
203
+ *
204
+ * @param id - The conversation ID.
205
+ * @returns The conversation object.
206
+ */
207
+ getConversation(id: string): Promise<Conversation>;
208
+ /**
209
+ * Gets an existing 1:1 / group conversation with `userIds`, or creates a
210
+ * new one. `id` is auto-generated if not supplied — on dedupe, the
211
+ * backend returns the existing conversation's `id` instead.
212
+ *
213
+ * @param args - The arguments for getting or creating a conversation.
214
+ * @param args.workspaceId - The workspace ID.
215
+ * @param args.userIds - Array of user IDs to include in the conversation.
216
+ * @returns The conversation object (existing or newly created).
217
+ *
218
+ * @example
219
+ * ```typescript
220
+ * const conversation = await api.conversations.getOrCreateConversation({
221
+ * workspaceId: 123,
222
+ * userIds: [101, 202, 303],
223
+ * })
224
+ * ```
225
+ */
226
+ getOrCreateConversation(args: GetOrCreateConversationArgs): Promise<Conversation>;
227
+ /**
228
+ * Updates a conversation's title.
229
+ *
230
+ * @param args - The arguments for updating a conversation.
231
+ * @param args.id - The conversation ID.
232
+ * @param args.title - The new title for the conversation.
233
+ * @param args.archived - Optional flag to archive/unarchive the conversation.
234
+ * @returns The updated conversation object.
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * const conversation = await api.conversations.updateConversation({
239
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX42',
240
+ * title: 'New Title',
241
+ * })
242
+ * ```
243
+ */
244
+ updateConversation(args: UpdateConversationArgs): Promise<Conversation>;
245
+ /**
246
+ * Archives a conversation.
247
+ *
248
+ * @param id - The conversation ID.
249
+ * @returns The updated conversation object.
250
+ */
251
+ archiveConversation(id: string): Promise<Conversation>;
252
+ /**
253
+ * Unarchives a conversation.
254
+ *
255
+ * @param id - The conversation ID.
256
+ * @returns The updated conversation object.
257
+ */
258
+ unarchiveConversation(id: string): Promise<Conversation>;
259
+ /**
260
+ * Adds a user to a conversation.
261
+ *
262
+ * @param args - The arguments for adding a user.
263
+ * @param args.id - The conversation ID.
264
+ * @param args.userId - The user ID to add.
265
+ * @returns The updated conversation object.
266
+ */
267
+ addUser(args: AddConversationUserArgs): Promise<Conversation>;
268
+ /**
269
+ * Adds multiple users to a conversation.
270
+ *
271
+ * @param args - The arguments for adding users.
272
+ * @param args.id - The conversation ID.
273
+ * @param args.userIds - Array of user IDs to add.
274
+ * @returns The updated conversation object.
275
+ *
276
+ * @example
277
+ * ```typescript
278
+ * await api.conversations.addUsers({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', userIds: [101, 202] })
279
+ * ```
280
+ */
281
+ addUsers(args: AddConversationUsersArgs): Promise<Conversation>;
282
+ /**
283
+ * Removes a user from a conversation.
284
+ *
285
+ * @param args - The arguments for removing a user.
286
+ * @param args.id - The conversation ID.
287
+ * @param args.userId - The user ID to remove.
288
+ * @returns The updated conversation object.
289
+ */
290
+ removeUser(args: RemoveConversationUserArgs): Promise<Conversation>;
291
+ /**
292
+ * Removes multiple users from a conversation.
293
+ *
294
+ * @param args - The arguments for removing users.
295
+ * @param args.id - The conversation ID.
296
+ * @param args.userIds - Array of user IDs to remove.
297
+ * @returns The updated conversation object.
298
+ */
299
+ removeUsers(args: RemoveConversationUsersArgs): Promise<Conversation>;
300
+ /**
301
+ * Marks a conversation as read.
302
+ *
303
+ * @param args - The arguments for marking as read.
304
+ * @param args.id - The conversation ID.
305
+ * @param args.objIndex - Optional index of the message to mark as last read.
306
+ * @param args.messageId - Optional message ID to mark as last read.
307
+ */
308
+ markRead(args: {
309
+ id: string;
310
+ objIndex?: number;
311
+ messageId?: string;
312
+ }): Promise<StatusOk>;
313
+ /**
314
+ * Marks a conversation as unread.
315
+ *
316
+ * @param args - The arguments for marking as unread.
317
+ * @param args.id - The conversation ID.
318
+ * @param args.objIndex - Optional index of the message to mark as last unread.
319
+ * @param args.messageId - Optional message ID to mark as last unread.
320
+ */
321
+ markUnread(args: {
322
+ id: string;
323
+ objIndex?: number;
324
+ messageId?: string;
325
+ }): Promise<StatusOk>;
326
+ /**
327
+ * Returns unread conversations for a workspace, paired with the unread
328
+ * version counter.
329
+ *
330
+ * @param workspaceId - The workspace ID.
331
+ * @returns Object containing the array of unread conversation references and a version counter.
332
+ */
333
+ getUnread(workspaceId: number): Promise<{
334
+ data: UnreadConversation[];
335
+ version: number;
336
+ }>;
337
+ /**
338
+ * Clears all unread conversations for a workspace.
339
+ *
340
+ * @param workspaceId - The workspace ID.
341
+ */
342
+ clearUnread(workspaceId: number): Promise<StatusOk>;
343
+ /**
344
+ * Mutes a conversation for a specified number of minutes.
345
+ * The user will receive no notifications from this conversation during that period.
346
+ *
347
+ * @param args - The arguments for muting a conversation.
348
+ * @param args.id - The conversation ID.
349
+ * @param args.minutes - Number of minutes to mute the conversation.
350
+ * @returns The updated conversation object.
351
+ *
352
+ * @example
353
+ * ```typescript
354
+ * const conversation = await api.conversations.muteConversation({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', minutes: 30 })
355
+ * ```
356
+ */
357
+ muteConversation(args: MuteConversationArgs): Promise<Conversation>;
358
+ /**
359
+ * Unmutes a conversation.
360
+ *
361
+ * @param id - The conversation ID.
362
+ * @returns The updated conversation object.
363
+ */
364
+ unmuteConversation(id: string): Promise<Conversation>;
365
+ private simple;
366
+ }