@todoist/comms-sdk 0.0.1 → 5.0.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 (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 +508 -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,57 @@
1
+ import type { ReactionObject } from '../types/entities.js';
2
+ import type { AddReactionArgs, GetReactionsArgs, RemoveReactionArgs } from '../types/requests.js';
3
+ import { BaseClient } from './base-client.js';
4
+ /**
5
+ * Client for interacting with Comms reaction endpoints.
6
+ */
7
+ export declare class ReactionsClient extends BaseClient {
8
+ /**
9
+ * Adds an emoji reaction to a thread, comment, or conversation message.
10
+ *
11
+ * @param args - The arguments for adding a reaction.
12
+ * @param args.threadId - Optional thread ID.
13
+ * @param args.commentId - Optional comment ID.
14
+ * @param args.messageId - Optional message ID (for conversation messages).
15
+ * @param args.reaction - The reaction emoji to add.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * await api.reactions.add({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', reaction: '👍' })
20
+ * ```
21
+ */
22
+ add(args: AddReactionArgs): Promise<void>;
23
+ /**
24
+ * Gets reactions for a thread, comment, or conversation message.
25
+ *
26
+ * Returns an object with emoji reactions as keys and arrays of user IDs as
27
+ * values, or null if no reactions.
28
+ *
29
+ * @param args - The arguments for getting reactions.
30
+ * @param args.threadId - Optional thread ID.
31
+ * @param args.commentId - Optional comment ID.
32
+ * @param args.messageId - Optional message ID (for conversation messages).
33
+ * @returns A reaction object with emoji reactions as keys and arrays of user IDs as values, or null if no reactions.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const reactions = await api.reactions.get({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z' })
38
+ * // Returns: { "👍": [101, 202, 303], "❤️": [101, 202] }
39
+ * ```
40
+ */
41
+ get(args: GetReactionsArgs): Promise<ReactionObject>;
42
+ /**
43
+ * Removes an emoji reaction from a thread, comment, or conversation message.
44
+ *
45
+ * @param args - The arguments for removing a reaction.
46
+ * @param args.threadId - Optional thread ID.
47
+ * @param args.commentId - Optional comment ID.
48
+ * @param args.messageId - Optional message ID (for conversation messages).
49
+ * @param args.reaction - The reaction emoji to remove.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * await api.reactions.remove({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', reaction: '👍' })
54
+ * ```
55
+ */
56
+ remove(args: RemoveReactionArgs): Promise<void>;
57
+ }
@@ -0,0 +1,71 @@
1
+ import { type SearchConversationResponse, type SearchResponse, type SearchThreadResponse } from '../types/entities.js';
2
+ import type { SearchArgs, SearchConversationArgs, SearchThreadArgs } from '../types/requests.js';
3
+ import { BaseClient } from './base-client.js';
4
+ /**
5
+ * Client for interacting with Comms search endpoints.
6
+ */
7
+ export declare class SearchClient extends BaseClient {
8
+ /**
9
+ * Searches across all threads and conversations in a workspace.
10
+ *
11
+ * @param args - The arguments for searching.
12
+ * @param args.query - The search query string. Optional when `mentionSelf: true` is set; required otherwise.
13
+ * @param args.workspaceId - The workspace ID to search in.
14
+ * @param args.type - Optional result type. `conversations` matches group chat titles, and its results have no `messageId`. When omitted, results are threads, comments, and messages.
15
+ * @param args.channelIds - Optional array of channel IDs to filter by.
16
+ * @param args.authorIds - Optional array of author user IDs to filter by.
17
+ * @param args.mentionSelf - Optional flag to filter by mentions of the current user. When true, `query` may be omitted.
18
+ * @param args.dateFrom - Optional start date for filtering (YYYY-MM-DD).
19
+ * @param args.dateTo - Optional end date for filtering (YYYY-MM-DD).
20
+ * @param args.limit - Optional limit on number of results returned.
21
+ * @param args.cursor - Optional cursor for pagination.
22
+ * @returns Search results with pagination.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const results = await api.search.search({
27
+ * query: 'important meeting',
28
+ * workspaceId: 123,
29
+ * })
30
+ * ```
31
+ */
32
+ search(args: SearchArgs): Promise<SearchResponse>;
33
+ /**
34
+ * Searches within comments of a specific thread.
35
+ *
36
+ * @param args - The arguments for searching within a thread.
37
+ * @param args.query - The search query string.
38
+ * @param args.threadId - The thread ID to search in.
39
+ * @param args.limit - Optional limit on number of results returned.
40
+ * @param args.cursor - Optional cursor for pagination.
41
+ * @returns Comment IDs that match the search query.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const results = await api.search.searchThread({
46
+ * query: 'deadline',
47
+ * threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
48
+ * })
49
+ * ```
50
+ */
51
+ searchThread(args: SearchThreadArgs): Promise<SearchThreadResponse>;
52
+ /**
53
+ * Searches within messages of a specific conversation.
54
+ *
55
+ * @param args - The arguments for searching within a conversation.
56
+ * @param args.query - The search query string.
57
+ * @param args.conversationId - The conversation ID to search in.
58
+ * @param args.limit - Optional limit on number of results returned.
59
+ * @param args.cursor - Optional cursor for pagination.
60
+ * @returns Message IDs that match the search query.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const results = await api.search.searchConversation({
65
+ * query: 'budget',
66
+ * conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
67
+ * })
68
+ * ```
69
+ */
70
+ searchConversation(args: SearchConversationArgs): Promise<SearchConversationResponse>;
71
+ }
@@ -0,0 +1,547 @@
1
+ import { z } from 'zod';
2
+ import { type Comment, type StatusOk, type Thread, type UnreadThread } from '../types/entities.js';
3
+ import type { CloseThreadArgs, CreateThreadArgs, GetThreadsArgs, MarkThreadReadArgs, MarkThreadUnreadArgs, MarkThreadUnreadForOthersArgs, MoveThreadToChannelArgs, MuteThreadArgs, ReopenThreadArgs, UpdateThreadArgs } from '../types/requests.js';
4
+ import { BaseClient } from './base-client.js';
5
+ export declare const ThreadListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
6
+ id: z.ZodString;
7
+ title: z.ZodString;
8
+ content: z.ZodString;
9
+ creator: z.ZodNumber;
10
+ creatorName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
+ channelId: z.ZodString;
12
+ workspaceId: z.ZodNumber;
13
+ actions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnknown>>>;
14
+ attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
15
+ attachmentId: z.ZodString;
16
+ urlType: z.ZodString;
17
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
18
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
+ fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
+ fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
21
+ underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
23
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
+ imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
25
+ imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
26
+ duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
+ uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
29
+ videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
+ videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
31
+ }, z.core.$loose>>>>;
32
+ commentCount: z.ZodNumber;
33
+ closed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
34
+ directGroupMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
35
+ directMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
36
+ groups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
37
+ lastEdited: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
38
+ lastObjIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
39
+ lastUpdated: z.ZodDate;
40
+ mutedUntil: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
41
+ participants: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
42
+ pinned: z.ZodOptional<z.ZodBoolean>;
43
+ pinnedDate: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
44
+ posted: z.ZodDate;
45
+ reactions: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
46
+ recipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
47
+ responders: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
48
+ snippet: z.ZodString;
49
+ snippetCreator: z.ZodNumber;
50
+ snippetMaskAvatarUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ snippetMaskPoster: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
+ systemMessage: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>>>;
53
+ toEmails: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
54
+ isArchived: z.ZodBoolean;
55
+ isSaved: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
56
+ inInbox: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
57
+ lastComment: z.ZodOptional<z.ZodNullable<z.ZodObject<{
58
+ id: z.ZodString;
59
+ content: z.ZodString;
60
+ creator: z.ZodNumber;
61
+ creatorName: z.ZodString;
62
+ threadId: z.ZodString;
63
+ channelId: z.ZodString;
64
+ posted: z.ZodDate;
65
+ systemMessage: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>>>;
66
+ attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
67
+ attachmentId: z.ZodString;
68
+ urlType: z.ZodString;
69
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
70
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
71
+ fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
+ fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
73
+ underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
74
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
75
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
76
+ imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
77
+ imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
78
+ duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
+ uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
80
+ video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
81
+ videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
+ videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
83
+ }, z.core.$loose>>>>;
84
+ reactions: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodNumber>>>>;
85
+ actions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnknown>>>;
86
+ objIndex: z.ZodNumber;
87
+ lastEdited: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
88
+ deleted: z.ZodBoolean;
89
+ deletedBy: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
90
+ directGroupMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
91
+ directMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
92
+ groups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
93
+ recipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
94
+ toEmails: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
95
+ version: z.ZodNumber;
96
+ workspaceId: z.ZodNumber;
97
+ }, z.core.$strip>>>;
98
+ }, z.core.$strip>, z.ZodTransform<{
99
+ url: string;
100
+ id: string;
101
+ title: string;
102
+ content: string;
103
+ creator: number;
104
+ channelId: string;
105
+ workspaceId: number;
106
+ commentCount: number;
107
+ lastUpdated: Date;
108
+ posted: Date;
109
+ snippet: string;
110
+ snippetCreator: number;
111
+ isArchived: boolean;
112
+ creatorName?: string | null | undefined;
113
+ actions?: unknown[] | null | undefined;
114
+ attachments?: {
115
+ [x: string]: unknown;
116
+ attachmentId: string;
117
+ urlType: string;
118
+ title?: string | null | undefined;
119
+ url?: string | null | undefined;
120
+ fileName?: string | null | undefined;
121
+ fileSize?: number | null | undefined;
122
+ underlyingType?: string | null | undefined;
123
+ description?: string | null | undefined;
124
+ image?: string | null | undefined;
125
+ imageWidth?: number | null | undefined;
126
+ imageHeight?: number | null | undefined;
127
+ duration?: string | null | undefined;
128
+ uploadState?: string | null | undefined;
129
+ video?: string | null | undefined;
130
+ videoType?: string | null | undefined;
131
+ videoAutoPlay?: boolean | null | undefined;
132
+ }[] | null | undefined;
133
+ closed?: boolean | null | undefined;
134
+ directGroupMentions?: string[] | null | undefined;
135
+ directMentions?: number[] | null | undefined;
136
+ groups?: string[] | null | undefined;
137
+ lastEdited?: Date | null | undefined;
138
+ lastObjIndex?: number | null | undefined;
139
+ mutedUntil?: Date | null | undefined;
140
+ participants?: number[] | null | undefined;
141
+ pinned?: boolean | undefined;
142
+ pinnedDate?: Date | null | undefined;
143
+ reactions?: Record<string, unknown> | null | undefined;
144
+ recipients?: number[] | null | undefined;
145
+ responders?: number[] | null | undefined;
146
+ snippetMaskAvatarUrl?: string | null | undefined;
147
+ snippetMaskPoster?: string | null | undefined;
148
+ systemMessage?: unknown;
149
+ toEmails?: string[] | null | undefined;
150
+ isSaved?: boolean | null | undefined;
151
+ inInbox?: boolean | null | undefined;
152
+ lastComment?: {
153
+ id: string;
154
+ content: string;
155
+ creator: number;
156
+ creatorName: string;
157
+ threadId: string;
158
+ channelId: string;
159
+ posted: Date;
160
+ objIndex: number;
161
+ deleted: boolean;
162
+ version: number;
163
+ workspaceId: number;
164
+ systemMessage?: unknown;
165
+ attachments?: {
166
+ [x: string]: unknown;
167
+ attachmentId: string;
168
+ urlType: string;
169
+ title?: string | null | undefined;
170
+ url?: string | null | undefined;
171
+ fileName?: string | null | undefined;
172
+ fileSize?: number | null | undefined;
173
+ underlyingType?: string | null | undefined;
174
+ description?: string | null | undefined;
175
+ image?: string | null | undefined;
176
+ imageWidth?: number | null | undefined;
177
+ imageHeight?: number | null | undefined;
178
+ duration?: string | null | undefined;
179
+ uploadState?: string | null | undefined;
180
+ video?: string | null | undefined;
181
+ videoType?: string | null | undefined;
182
+ videoAutoPlay?: boolean | null | undefined;
183
+ }[] | null | undefined;
184
+ reactions?: Record<string, number[]> | null | undefined;
185
+ actions?: unknown[] | null | undefined;
186
+ lastEdited?: Date | null | undefined;
187
+ deletedBy?: number | null | undefined;
188
+ directGroupMentions?: string[] | null | undefined;
189
+ directMentions?: number[] | null | undefined;
190
+ groups?: string[] | null | undefined;
191
+ recipients?: number[] | null | undefined;
192
+ toEmails?: string[] | null | undefined;
193
+ } | null | undefined;
194
+ }, {
195
+ id: string;
196
+ title: string;
197
+ content: string;
198
+ creator: number;
199
+ channelId: string;
200
+ workspaceId: number;
201
+ commentCount: number;
202
+ lastUpdated: Date;
203
+ posted: Date;
204
+ snippet: string;
205
+ snippetCreator: number;
206
+ isArchived: boolean;
207
+ creatorName?: string | null | undefined;
208
+ actions?: unknown[] | null | undefined;
209
+ attachments?: {
210
+ [x: string]: unknown;
211
+ attachmentId: string;
212
+ urlType: string;
213
+ title?: string | null | undefined;
214
+ url?: string | null | undefined;
215
+ fileName?: string | null | undefined;
216
+ fileSize?: number | null | undefined;
217
+ underlyingType?: string | null | undefined;
218
+ description?: string | null | undefined;
219
+ image?: string | null | undefined;
220
+ imageWidth?: number | null | undefined;
221
+ imageHeight?: number | null | undefined;
222
+ duration?: string | null | undefined;
223
+ uploadState?: string | null | undefined;
224
+ video?: string | null | undefined;
225
+ videoType?: string | null | undefined;
226
+ videoAutoPlay?: boolean | null | undefined;
227
+ }[] | null | undefined;
228
+ closed?: boolean | null | undefined;
229
+ directGroupMentions?: string[] | null | undefined;
230
+ directMentions?: number[] | null | undefined;
231
+ groups?: string[] | null | undefined;
232
+ lastEdited?: Date | null | undefined;
233
+ lastObjIndex?: number | null | undefined;
234
+ mutedUntil?: Date | null | undefined;
235
+ participants?: number[] | null | undefined;
236
+ pinned?: boolean | undefined;
237
+ pinnedDate?: Date | null | undefined;
238
+ reactions?: Record<string, unknown> | null | undefined;
239
+ recipients?: number[] | null | undefined;
240
+ responders?: number[] | null | undefined;
241
+ snippetMaskAvatarUrl?: string | null | undefined;
242
+ snippetMaskPoster?: string | null | undefined;
243
+ systemMessage?: unknown;
244
+ toEmails?: string[] | null | undefined;
245
+ isSaved?: boolean | null | undefined;
246
+ inInbox?: boolean | null | undefined;
247
+ lastComment?: {
248
+ id: string;
249
+ content: string;
250
+ creator: number;
251
+ creatorName: string;
252
+ threadId: string;
253
+ channelId: string;
254
+ posted: Date;
255
+ objIndex: number;
256
+ deleted: boolean;
257
+ version: number;
258
+ workspaceId: number;
259
+ systemMessage?: unknown;
260
+ attachments?: {
261
+ [x: string]: unknown;
262
+ attachmentId: string;
263
+ urlType: string;
264
+ title?: string | null | undefined;
265
+ url?: string | null | undefined;
266
+ fileName?: string | null | undefined;
267
+ fileSize?: number | null | undefined;
268
+ underlyingType?: string | null | undefined;
269
+ description?: string | null | undefined;
270
+ image?: string | null | undefined;
271
+ imageWidth?: number | null | undefined;
272
+ imageHeight?: number | null | undefined;
273
+ duration?: string | null | undefined;
274
+ uploadState?: string | null | undefined;
275
+ video?: string | null | undefined;
276
+ videoType?: string | null | undefined;
277
+ videoAutoPlay?: boolean | null | undefined;
278
+ }[] | null | undefined;
279
+ reactions?: Record<string, number[]> | null | undefined;
280
+ actions?: unknown[] | null | undefined;
281
+ lastEdited?: Date | null | undefined;
282
+ deletedBy?: number | null | undefined;
283
+ directGroupMentions?: string[] | null | undefined;
284
+ directMentions?: number[] | null | undefined;
285
+ groups?: string[] | null | undefined;
286
+ recipients?: number[] | null | undefined;
287
+ toEmails?: string[] | null | undefined;
288
+ } | null | undefined;
289
+ }>>>;
290
+ /**
291
+ * Client for `/api/v1.0/threads/`. The SDK auto-generates the thread `id` on
292
+ * `createThread` when the caller doesn't supply one.
293
+ */
294
+ export declare class ThreadsClient extends BaseClient {
295
+ private readonly linkBaseUrl;
296
+ private readonly threadSchema;
297
+ private readonly threadListSchema;
298
+ private readonly commentSchema;
299
+ /**
300
+ * Gets threads. At least one of `channelId` / `workspaceId` is required.
301
+ * `newerThan` / `olderThan` (`Date`) are converted to the
302
+ * `newer_than_ts` / `older_than_ts` epoch-second params on the wire.
303
+ *
304
+ * @param args - The arguments for getting threads.
305
+ * @param args.workspaceId - The workspace ID.
306
+ * @param args.channelId - Optional channel ID to narrow to a single channel.
307
+ * @param args.archived - Optional flag to include archived threads.
308
+ * @param args.newerThan - Optional date to get threads newer than.
309
+ * @param args.olderThan - Optional date to get threads older than.
310
+ * @param args.limit - Optional limit on number of threads returned.
311
+ * @returns An array of thread objects.
312
+ *
313
+ * @example
314
+ * ```typescript
315
+ * const threads = await api.threads.getThreads({
316
+ * workspaceId: 123,
317
+ * channelId: '7YpL3oZ4kZ9vP7Q1tR2sX44',
318
+ * })
319
+ * threads.forEach(t => console.log(t.title))
320
+ * ```
321
+ */
322
+ getThreads(args: GetThreadsArgs): Promise<Thread[]>;
323
+ /**
324
+ * Gets a single thread object by id.
325
+ *
326
+ * @param id - The thread ID.
327
+ * @returns The thread object.
328
+ */
329
+ getThread(id: string): Promise<Thread>;
330
+ /**
331
+ * Creates a new thread in a channel. `id` is auto-generated if not supplied.
332
+ *
333
+ * @param args - The arguments for creating a thread.
334
+ * @param args.channelId - The channel ID.
335
+ * @param args.title - Optional thread title.
336
+ * @param args.content - The thread content.
337
+ * @param args.recipients - Optional array of user IDs to notify.
338
+ * @param args.groups - Optional array of custom group IDs to notify.
339
+ * @param args.notifyAudience - Optional broader audience to notify in addition to
340
+ * `recipients` and `groups`. `'channel'` notifies everyone in the channel;
341
+ * `'thread'` notifies everyone who has interacted with the thread — but a
342
+ * brand-new thread has no interactions yet, so the backend discards
343
+ * `'thread'` at create time. It is only meaningful on replies (`createComment`).
344
+ * @param args.attachments - Optional array of {@link Attachment}s (from `attachments.upload`).
345
+ * @returns The created thread object.
346
+ *
347
+ * @example
348
+ * ```typescript
349
+ * const thread = await api.threads.createThread({
350
+ * channelId: '7YpL3oZ4kZ9vP7Q1tR2sX44',
351
+ * title: 'New Feature Discussion',
352
+ * content: 'Let\'s discuss the new feature...',
353
+ * notifyAudience: 'channel', // tag "Everyone in channel"
354
+ * })
355
+ * ```
356
+ */
357
+ createThread(args: CreateThreadArgs): Promise<Thread>;
358
+ /**
359
+ * Partial update of an existing thread.
360
+ *
361
+ * @param args - The arguments for updating a thread.
362
+ * @param args.id - The thread ID.
363
+ * @param args.title - Optional new thread title.
364
+ * @param args.content - Optional new thread content.
365
+ * @returns The updated thread object.
366
+ */
367
+ updateThread(args: UpdateThreadArgs): Promise<Thread>;
368
+ /**
369
+ * Permanently deletes a thread.
370
+ *
371
+ * @param id - The thread ID.
372
+ */
373
+ deleteThread(id: string): Promise<StatusOk>;
374
+ /**
375
+ * Saves a thread (formerly "star").
376
+ *
377
+ * @param id - The thread ID.
378
+ */
379
+ saveThread(id: string): Promise<StatusOk>;
380
+ /**
381
+ * Unsaves a thread (formerly "unstar").
382
+ *
383
+ * @param id - The thread ID.
384
+ */
385
+ unsaveThread(id: string): Promise<StatusOk>;
386
+ /**
387
+ * Pins a thread.
388
+ *
389
+ * @param id - The thread ID.
390
+ */
391
+ pinThread(id: string): Promise<StatusOk>;
392
+ /**
393
+ * Unpins a thread.
394
+ *
395
+ * @param id - The thread ID.
396
+ */
397
+ unpinThread(id: string): Promise<StatusOk>;
398
+ /**
399
+ * Moves a thread to another channel.
400
+ *
401
+ * @param args - The arguments for moving a thread.
402
+ * @param args.id - The thread ID.
403
+ * @param args.toChannel - The target channel ID.
404
+ * @returns The updated thread object.
405
+ */
406
+ moveToChannel(args: MoveThreadToChannelArgs): Promise<Thread>;
407
+ /**
408
+ * Marks a thread as read.
409
+ *
410
+ * @param args - The arguments for marking a thread as read.
411
+ * @param args.id - The thread ID.
412
+ * @param args.objIndex - The index of the last known read message.
413
+ */
414
+ markRead(args: MarkThreadReadArgs): Promise<StatusOk>;
415
+ /**
416
+ * Marks a thread as unread.
417
+ *
418
+ * @param args - The arguments for marking a thread as unread.
419
+ * @param args.id - The thread ID.
420
+ * @param args.objIndex - The index of the last unread message. Use -1 to mark the whole thread as unread.
421
+ */
422
+ markUnread(args: MarkThreadUnreadArgs): Promise<StatusOk>;
423
+ /**
424
+ * Marks a thread as unread for others. Useful to notify others about thread changes.
425
+ *
426
+ * @param args - The arguments for marking a thread as unread for others.
427
+ * @param args.id - The thread ID.
428
+ * @param args.objIndex - The index of the last unread message. Use -1 to mark the whole thread as unread.
429
+ */
430
+ markUnreadForOthers(args: MarkThreadUnreadForOthersArgs): Promise<StatusOk>;
431
+ /**
432
+ * Marks every thread in a workspace or channel as read. Exactly one of
433
+ * `workspaceId` / `channelId` should be set.
434
+ *
435
+ * @param args - Either workspaceId or channelId (one is required).
436
+ * @param args.workspaceId - The workspace ID.
437
+ * @param args.channelId - The channel ID.
438
+ *
439
+ * @example
440
+ * ```typescript
441
+ * // Mark all in workspace
442
+ * await api.threads.markAllRead({ workspaceId: 123 })
443
+ *
444
+ * // Mark all in channel
445
+ * await api.threads.markAllRead({ channelId: '7YpL3oZ4kZ9vP7Q1tR2sX44' })
446
+ * ```
447
+ */
448
+ markAllRead(args: {
449
+ workspaceId?: number;
450
+ channelId?: string;
451
+ }): Promise<StatusOk>;
452
+ /**
453
+ * Clears unread threads in a workspace.
454
+ *
455
+ * @param workspaceId - The workspace ID.
456
+ */
457
+ clearUnread(workspaceId: number): Promise<StatusOk>;
458
+ /**
459
+ * Returns unread threads for a workspace, paired with the unread version
460
+ * counter and (optionally) the inbox unread count.
461
+ *
462
+ * @param workspaceId - The workspace ID.
463
+ * @returns Object containing the array of unread thread references, a version counter, and optionally the inbox unread count.
464
+ */
465
+ getUnread(workspaceId: number): Promise<{
466
+ data: UnreadThread[];
467
+ version: number;
468
+ inboxUnread?: number | null;
469
+ }>;
470
+ /**
471
+ * Mutes a thread for a specified number of minutes.
472
+ * When muted, you will not get notified in your inbox about new comments.
473
+ *
474
+ * @param args - The arguments for muting a thread.
475
+ * @param args.id - The thread ID.
476
+ * @param args.minutes - Number of minutes to mute the thread.
477
+ * @returns The updated thread object.
478
+ *
479
+ * @example
480
+ * ```typescript
481
+ * const thread = await api.threads.muteThread({ id: '7YpL3oZ4kZ9vP7Q1tR2sX3z', minutes: 30 })
482
+ * ```
483
+ */
484
+ muteThread(args: MuteThreadArgs): Promise<Thread>;
485
+ /**
486
+ * Unmutes a thread.
487
+ * You will start to see notifications in your inbox again when new comments are added.
488
+ *
489
+ * @param id - The thread ID.
490
+ * @returns The updated thread object.
491
+ */
492
+ unmuteThread(id: string): Promise<Thread>;
493
+ /**
494
+ * Closes a thread by adding a comment with a close action.
495
+ *
496
+ * @param args - The arguments for closing a thread.
497
+ * @param args.id - The thread ID.
498
+ * @param args.content - The comment content.
499
+ * @param args.attachments - Optional array of {@link Attachment} objects.
500
+ * @param args.actions - Optional array of action objects.
501
+ * @param args.recipients - Optional array of user IDs to notify directly.
502
+ * @param args.groups - Optional array of custom group IDs to notify.
503
+ * @param args.directMentions - Optional array of user IDs that were @-mentioned in
504
+ * `content`.
505
+ * @param args.notifyAudience - Optional broader audience to notify in addition to
506
+ * `recipients` and `groups`. `'channel'` notifies everyone in the channel;
507
+ * `'thread'` notifies everyone who has interacted with the thread.
508
+ * @returns The created comment object.
509
+ *
510
+ * @example
511
+ * ```typescript
512
+ * const comment = await api.threads.closeThread({
513
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
514
+ * content: 'Closing this thread — resolved.',
515
+ * })
516
+ * ```
517
+ */
518
+ closeThread(args: CloseThreadArgs): Promise<Comment>;
519
+ /**
520
+ * Reopens a thread by adding a comment with a reopen action.
521
+ *
522
+ * @param args - The arguments for reopening a thread.
523
+ * @param args.id - The thread ID.
524
+ * @param args.content - The comment content.
525
+ * @param args.attachments - Optional array of {@link Attachment} objects.
526
+ * @param args.actions - Optional array of action objects.
527
+ * @param args.recipients - Optional array of user IDs to notify directly.
528
+ * @param args.groups - Optional array of custom group IDs to notify.
529
+ * @param args.directMentions - Optional array of user IDs that were @-mentioned in
530
+ * `content`.
531
+ * @param args.notifyAudience - Optional broader audience to notify in addition to
532
+ * `recipients` and `groups`. `'channel'` notifies everyone in the channel;
533
+ * `'thread'` notifies everyone who has interacted with the thread.
534
+ * @returns The created comment object.
535
+ *
536
+ * @example
537
+ * ```typescript
538
+ * const comment = await api.threads.reopenThread({
539
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
540
+ * content: 'Reopening — need further discussion.',
541
+ * })
542
+ * ```
543
+ */
544
+ reopenThread(args: ReopenThreadArgs): Promise<Comment>;
545
+ private addCommentWithAction;
546
+ private simple;
547
+ }