@doist/comms-sdk 0.1.0-alpha.1 → 0.2.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.
- package/README.md +1 -1
- package/dist/cjs/clients/add-comment-helper.js +18 -2
- package/dist/cjs/clients/base-client.js +11 -5
- package/dist/cjs/clients/channels-client.js +142 -14
- package/dist/cjs/clients/comments-client.js +99 -14
- package/dist/cjs/clients/conversation-messages-client.js +91 -9
- package/dist/cjs/clients/conversations-client.js +166 -15
- package/dist/cjs/clients/groups-client.js +98 -5
- package/dist/cjs/clients/inbox-client.js +102 -16
- package/dist/cjs/clients/reactions-client.js +40 -2
- package/dist/cjs/clients/search-client.js +50 -0
- package/dist/cjs/clients/threads-client.js +238 -24
- package/dist/cjs/clients/users-client.js +138 -11
- package/dist/cjs/clients/workspace-users-client.js +110 -10
- package/dist/cjs/clients/workspaces-client.js +89 -8
- package/dist/cjs/comms-api.js +1 -0
- package/dist/cjs/consts/endpoints.js +8 -3
- package/dist/cjs/testUtils/test-defaults.js +3 -1
- package/dist/cjs/types/api-version.js +8 -0
- package/dist/cjs/types/entities.js +119 -98
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/requests.js +0 -1
- package/dist/cjs/utils/url-helpers.js +3 -1
- package/dist/esm/clients/add-comment-helper.js +18 -2
- package/dist/esm/clients/base-client.js +11 -5
- package/dist/esm/clients/channels-client.js +143 -15
- package/dist/esm/clients/comments-client.js +100 -15
- package/dist/esm/clients/conversation-messages-client.js +92 -10
- package/dist/esm/clients/conversations-client.js +167 -16
- package/dist/esm/clients/groups-client.js +98 -5
- package/dist/esm/clients/inbox-client.js +102 -16
- package/dist/esm/clients/reactions-client.js +40 -2
- package/dist/esm/clients/search-client.js +50 -0
- package/dist/esm/clients/threads-client.js +239 -25
- package/dist/esm/clients/users-client.js +138 -11
- package/dist/esm/clients/workspace-users-client.js +110 -10
- package/dist/esm/clients/workspaces-client.js +90 -9
- package/dist/esm/comms-api.js +1 -0
- package/dist/esm/consts/endpoints.js +8 -3
- package/dist/esm/testUtils/test-defaults.js +2 -0
- package/dist/esm/types/api-version.js +5 -0
- package/dist/esm/types/entities.js +111 -97
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/requests.js +0 -1
- package/dist/esm/utils/url-helpers.js +3 -1
- package/dist/types/clients/add-comment-helper.d.ts +20 -1
- package/dist/types/clients/base-client.d.ts +10 -0
- package/dist/types/clients/channels-client.d.ts +126 -6
- package/dist/types/clients/comments-client.d.ts +77 -6
- package/dist/types/clients/conversation-messages-client.d.ts +79 -5
- package/dist/types/clients/conversations-client.d.ts +146 -3
- package/dist/types/clients/groups-client.d.ts +98 -5
- package/dist/types/clients/inbox-client.d.ts +463 -5
- package/dist/types/clients/reactions-client.d.ts +40 -2
- package/dist/types/clients/search-client.d.ts +50 -0
- package/dist/types/clients/threads-client.d.ts +204 -8
- package/dist/types/clients/users-client.d.ts +138 -11
- package/dist/types/clients/workspace-users-client.d.ts +110 -10
- package/dist/types/clients/workspaces-client.d.ts +82 -7
- package/dist/types/comms-api.d.ts +3 -0
- package/dist/types/consts/endpoints.d.ts +6 -1
- package/dist/types/testUtils/test-defaults.d.ts +1 -0
- package/dist/types/types/api-version.d.ts +6 -0
- package/dist/types/types/entities.d.ts +1654 -126
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/requests.d.ts +2 -21
- package/package.json +1 -1
|
@@ -45,7 +45,9 @@ export function getCommsURL(params) {
|
|
|
45
45
|
* @param baseUrl - Optional base URL (defaults to 'https://comms.todoist.com')
|
|
46
46
|
*/
|
|
47
47
|
export function getFullCommsURL(params, baseUrl = COMMS_BASE_URL) {
|
|
48
|
-
|
|
48
|
+
// Strip a trailing slash so links don't double up — `getCommsURL` paths start with '/'.
|
|
49
|
+
const normalizedBase = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
|
|
50
|
+
return `${normalizedBase}${getCommsURL(params)}`;
|
|
49
51
|
}
|
|
50
52
|
/** Returns the URL for a thread in a channel. */
|
|
51
53
|
export function getThreadURL(params) {
|
|
@@ -1,11 +1,30 @@
|
|
|
1
|
-
import { type Comment } from '../types/entities.js';
|
|
1
|
+
import { type Comment, type createCommentSchema } from '../types/entities.js';
|
|
2
2
|
import type { CustomFetch } from '../types/http.js';
|
|
3
3
|
import type { CreateCommentArgs, ThreadAction } from '../types/requests.js';
|
|
4
4
|
type ClientContext = {
|
|
5
5
|
baseUri: string;
|
|
6
6
|
apiToken: string;
|
|
7
7
|
customFetch?: CustomFetch;
|
|
8
|
+
/** Per-client Comment schema, base-bound for the returned comment's web `url`. */
|
|
9
|
+
schema: ReturnType<typeof createCommentSchema>;
|
|
8
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Internal helper that powers `comments.createComment`,
|
|
13
|
+
* `threads.closeThread`, and `threads.reopenThread`.
|
|
14
|
+
*
|
|
15
|
+
* Normalizes the `notifyAudience` flag into a sentinel `groups` entry,
|
|
16
|
+
* rejects sentinel IDs passed via `groups` / `directGroupMentions`, mints a
|
|
17
|
+
* UUIDv7 `id` when the caller omits one, and posts to `/comments/add`. When
|
|
18
|
+
* `threadAction` is set (`'close'` / `'reopen'`), it is forwarded on the
|
|
19
|
+
* wire so the same request both adds the comment and transitions the
|
|
20
|
+
* parent thread.
|
|
21
|
+
*
|
|
22
|
+
* @param context - Per-call client context (base URI, API token, optional `customFetch`).
|
|
23
|
+
* @param params - The comment payload (`{@link CreateCommentArgs}`).
|
|
24
|
+
* @param options - Optional configuration.
|
|
25
|
+
* @param options.threadAction - When set, also transitions the parent thread (`'close'` or `'reopen'`).
|
|
26
|
+
* @returns The parsed {@link Comment} returned by the API.
|
|
27
|
+
*/
|
|
9
28
|
export declare function addCommentRequest(context: ClientContext, params: CreateCommentArgs, options?: {
|
|
10
29
|
threadAction?: ThreadAction;
|
|
11
30
|
}): Promise<Comment>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import type { ApiVersion } from '../types/api-version.js';
|
|
1
2
|
import type { CustomFetch } from '../types/http.js';
|
|
2
3
|
export type ClientConfig = {
|
|
3
4
|
/** API token for authentication */
|
|
4
5
|
apiToken: string;
|
|
5
6
|
/** Optional custom base URL. If not provided, uses the default Comms API URL */
|
|
6
7
|
baseUrl?: string;
|
|
8
|
+
/** Optional API version. Defaults to 'v1' */
|
|
9
|
+
version?: ApiVersion;
|
|
7
10
|
/** Optional custom fetch implementation for cross-platform compatibility */
|
|
8
11
|
customFetch?: CustomFetch;
|
|
9
12
|
};
|
|
@@ -14,6 +17,7 @@ export type ClientConfig = {
|
|
|
14
17
|
export declare class BaseClient {
|
|
15
18
|
protected readonly apiToken: string;
|
|
16
19
|
protected readonly baseUrl?: string;
|
|
20
|
+
protected readonly defaultVersion: ApiVersion;
|
|
17
21
|
protected readonly customFetch?: CustomFetch;
|
|
18
22
|
constructor(config: ClientConfig);
|
|
19
23
|
/**
|
|
@@ -21,4 +25,10 @@ export declare class BaseClient {
|
|
|
21
25
|
* slash so relative paths resolve cleanly through `URL`.
|
|
22
26
|
*/
|
|
23
27
|
protected getBaseUri(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Base URL for entity web links, or `undefined` to use getFullCommsURL's
|
|
30
|
+
* default web app. Trailing-slash normalization happens in
|
|
31
|
+
* `getFullCommsURL`, so the configured value is returned verbatim.
|
|
32
|
+
*/
|
|
33
|
+
protected getLinkBaseUrl(): string | undefined;
|
|
24
34
|
}
|
|
@@ -64,28 +64,148 @@ export declare const ChannelListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
|
64
64
|
* to keep an optimistic-UI ID stable through the round-trip.
|
|
65
65
|
*/
|
|
66
66
|
export declare class ChannelsClient extends BaseClient {
|
|
67
|
-
|
|
67
|
+
private readonly linkBaseUrl;
|
|
68
|
+
private readonly channelSchema;
|
|
69
|
+
private readonly channelListSchema;
|
|
70
|
+
/**
|
|
71
|
+
* Gets all channels for a given workspace.
|
|
72
|
+
*
|
|
73
|
+
* @param args - The arguments for getting channels.
|
|
74
|
+
* @param args.workspaceId - The workspace ID.
|
|
75
|
+
* @param args.archived - Optional flag to include archived channels.
|
|
76
|
+
* @returns An array of channel objects.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const channels = await api.channels.getChannels({ workspaceId: 123 })
|
|
81
|
+
* channels.forEach(ch => console.log(ch.name))
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
68
84
|
getChannels(args: GetChannelsArgs): Promise<Channel[]>;
|
|
69
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Gets a single channel object by id.
|
|
87
|
+
*
|
|
88
|
+
* @param id - The channel ID.
|
|
89
|
+
* @returns The channel object.
|
|
90
|
+
*/
|
|
70
91
|
getChannel(id: string): Promise<Channel>;
|
|
71
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* Creates a new channel. `id` is auto-generated if not supplied — pass your
|
|
94
|
+
* own `id` to keep an optimistic-UI ID stable through the round-trip.
|
|
95
|
+
*
|
|
96
|
+
* @param args - The arguments for creating a channel.
|
|
97
|
+
* @param args.workspaceId - The workspace ID.
|
|
98
|
+
* @param args.name - The channel name.
|
|
99
|
+
* @param args.description - Optional channel description.
|
|
100
|
+
* @param args.color - Optional channel color.
|
|
101
|
+
* @param args.userIds - Optional array of user IDs to add to the channel.
|
|
102
|
+
* @param args.public - Optional flag to make the channel public.
|
|
103
|
+
* @returns The created channel object.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const channel = await api.channels.createChannel({
|
|
108
|
+
* workspaceId: 123,
|
|
109
|
+
* name: 'Engineering',
|
|
110
|
+
* description: 'Engineering team channel',
|
|
111
|
+
* })
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
72
114
|
createChannel(args: CreateChannelArgs): Promise<Channel>;
|
|
73
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Partial update of an existing channel.
|
|
117
|
+
*
|
|
118
|
+
* @param args - The arguments for updating a channel.
|
|
119
|
+
* @param args.id - The channel ID.
|
|
120
|
+
* @param args.name - Optional new channel name.
|
|
121
|
+
* @param args.description - Optional new channel description.
|
|
122
|
+
* @param args.color - Optional new channel color.
|
|
123
|
+
* @param args.public - Optional flag to change channel visibility.
|
|
124
|
+
* @returns The updated channel object.
|
|
125
|
+
*/
|
|
74
126
|
updateChannel(args: UpdateChannelArgs): Promise<Channel>;
|
|
75
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* Updates the channel's view filter (`only_open` / `all` / `only_closed`).
|
|
129
|
+
*
|
|
130
|
+
* @param args - The arguments for updating the channel filter.
|
|
131
|
+
* @param args.id - The channel ID.
|
|
132
|
+
* @param args.filterClosed - The new filter value.
|
|
133
|
+
*/
|
|
76
134
|
updateFilters(args: {
|
|
77
135
|
id: string;
|
|
78
136
|
filterClosed: 'only_open' | 'all' | 'only_closed';
|
|
79
137
|
}): Promise<StatusOk>;
|
|
80
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Permanently deletes a channel.
|
|
140
|
+
*
|
|
141
|
+
* @param id - The channel ID.
|
|
142
|
+
*/
|
|
81
143
|
deleteChannel(id: string): Promise<StatusOk>;
|
|
144
|
+
/**
|
|
145
|
+
* Archives a channel.
|
|
146
|
+
*
|
|
147
|
+
* @param id - The channel ID.
|
|
148
|
+
*/
|
|
82
149
|
archiveChannel(id: string): Promise<StatusOk>;
|
|
150
|
+
/**
|
|
151
|
+
* Unarchives a channel.
|
|
152
|
+
*
|
|
153
|
+
* @param id - The channel ID.
|
|
154
|
+
*/
|
|
83
155
|
unarchiveChannel(id: string): Promise<StatusOk>;
|
|
156
|
+
/**
|
|
157
|
+
* Favorites a channel.
|
|
158
|
+
*
|
|
159
|
+
* @param id - The channel ID.
|
|
160
|
+
*/
|
|
84
161
|
favoriteChannel(id: string): Promise<StatusOk>;
|
|
162
|
+
/**
|
|
163
|
+
* Unfavorites a channel.
|
|
164
|
+
*
|
|
165
|
+
* @param id - The channel ID.
|
|
166
|
+
*/
|
|
85
167
|
unfavoriteChannel(id: string): Promise<StatusOk>;
|
|
168
|
+
/**
|
|
169
|
+
* Adds a user to a channel.
|
|
170
|
+
*
|
|
171
|
+
* @param args - The arguments for adding a user.
|
|
172
|
+
* @param args.id - The channel ID.
|
|
173
|
+
* @param args.userId - The user ID to add.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* await api.channels.addUser({ id: '7YpL3oZ4kZ9vP7Q1tR2sX44', userId: 101 })
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
86
180
|
addUser(args: AddChannelUserArgs): Promise<Channel>;
|
|
181
|
+
/**
|
|
182
|
+
* Adds multiple users to a channel.
|
|
183
|
+
*
|
|
184
|
+
* @param args - The arguments for adding users.
|
|
185
|
+
* @param args.id - The channel ID.
|
|
186
|
+
* @param args.userIds - Array of user IDs to add.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* await api.channels.addUsers({ id: '7YpL3oZ4kZ9vP7Q1tR2sX44', userIds: [101, 202] })
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
87
193
|
addUsers(args: AddChannelUsersArgs): Promise<Channel>;
|
|
194
|
+
/**
|
|
195
|
+
* Removes a user from a channel.
|
|
196
|
+
*
|
|
197
|
+
* @param args - The arguments for removing a user.
|
|
198
|
+
* @param args.id - The channel ID.
|
|
199
|
+
* @param args.userId - The user ID to remove.
|
|
200
|
+
*/
|
|
88
201
|
removeUser(args: RemoveChannelUserArgs): Promise<Channel>;
|
|
202
|
+
/**
|
|
203
|
+
* Removes multiple users from a channel.
|
|
204
|
+
*
|
|
205
|
+
* @param args - The arguments for removing users.
|
|
206
|
+
* @param args.id - The channel ID.
|
|
207
|
+
* @param args.userIds - Array of user IDs to remove.
|
|
208
|
+
*/
|
|
89
209
|
removeUsers(args: RemoveChannelUsersArgs): Promise<Channel>;
|
|
90
210
|
private simple;
|
|
91
211
|
}
|
|
@@ -134,24 +134,95 @@ export declare const CommentListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
|
134
134
|
* on `createComment` when the caller doesn't supply one.
|
|
135
135
|
*/
|
|
136
136
|
export declare class CommentsClient extends BaseClient {
|
|
137
|
+
private readonly linkBaseUrl;
|
|
138
|
+
private readonly commentSchema;
|
|
139
|
+
private readonly commentListSchema;
|
|
140
|
+
private readonly wrappedCommentSchema;
|
|
137
141
|
/**
|
|
138
|
-
*
|
|
142
|
+
* Gets all comments for a thread. `newerThan` / `olderThan` (`Date`) are
|
|
139
143
|
* converted to `newer_than_ts` / `older_than_ts` epoch seconds on the
|
|
140
144
|
* wire.
|
|
145
|
+
*
|
|
146
|
+
* @param args - The arguments for getting comments.
|
|
147
|
+
* @param args.threadId - The thread ID.
|
|
148
|
+
* @param args.newerThan - Optional date to get comments newer than.
|
|
149
|
+
* @param args.olderThan - Optional date to get comments older than.
|
|
150
|
+
* @param args.limit - Optional limit on number of comments returned.
|
|
151
|
+
* @returns An array of comment objects.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const comments = await api.comments.getComments({
|
|
156
|
+
* threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
|
|
157
|
+
* newerThan: new Date('2024-01-01'),
|
|
158
|
+
* })
|
|
159
|
+
* comments.forEach(c => console.log(c.content))
|
|
160
|
+
* ```
|
|
141
161
|
*/
|
|
142
162
|
getComments(args: GetCommentsArgs): Promise<Comment[]>;
|
|
143
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* Gets a single comment object by id. The API wraps it in `{comment: ...}`.
|
|
165
|
+
*
|
|
166
|
+
* @param id - The comment ID.
|
|
167
|
+
* @returns The comment object.
|
|
168
|
+
*/
|
|
144
169
|
getComment(id: string): Promise<Comment>;
|
|
145
170
|
/**
|
|
146
|
-
* Creates a new comment. `id` is auto-generated if not supplied.
|
|
171
|
+
* Creates a new comment on a thread. `id` is auto-generated if not supplied.
|
|
172
|
+
*
|
|
173
|
+
* @param args - The arguments for creating a comment.
|
|
174
|
+
* @param args.threadId - The thread ID.
|
|
175
|
+
* @param args.content - The comment content.
|
|
176
|
+
* @param args.recipients - Optional array of user IDs to notify directly.
|
|
177
|
+
* @param args.groups - Optional array of custom group IDs to notify.
|
|
178
|
+
* @param args.directMentions - Optional array of user IDs that were @-mentioned in
|
|
179
|
+
* `content`.
|
|
180
|
+
* @param args.notifyAudience - Optional broader audience to notify in addition to
|
|
181
|
+
* `recipients` and `groups`. `'channel'` notifies everyone in the channel;
|
|
182
|
+
* `'thread'` notifies everyone who has interacted with the thread.
|
|
183
|
+
* @param args.attachments - Optional array of {@link Attachment} objects.
|
|
184
|
+
* @returns The created comment object.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* // Notify everyone who has interacted with the thread, plus two extra users.
|
|
189
|
+
* const comment = await api.comments.createComment({
|
|
190
|
+
* threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
|
|
191
|
+
* content: 'Great idea! Let\'s proceed.',
|
|
192
|
+
* notifyAudience: 'thread',
|
|
193
|
+
* recipients: [101, 202],
|
|
194
|
+
* })
|
|
195
|
+
* ```
|
|
147
196
|
*/
|
|
148
197
|
createComment(args: CreateCommentArgs): Promise<Comment>;
|
|
149
|
-
/**
|
|
198
|
+
/**
|
|
199
|
+
* Updates a comment's properties.
|
|
200
|
+
*
|
|
201
|
+
* @param args - The arguments for updating a comment.
|
|
202
|
+
* @param args.id - The comment ID.
|
|
203
|
+
* @param args.content - The new comment content.
|
|
204
|
+
* @returns The updated comment object.
|
|
205
|
+
*/
|
|
150
206
|
updateComment(args: UpdateCommentArgs): Promise<Comment>;
|
|
151
|
-
/**
|
|
207
|
+
/**
|
|
208
|
+
* Permanently deletes a comment.
|
|
209
|
+
*
|
|
210
|
+
* @param id - The comment ID.
|
|
211
|
+
*/
|
|
152
212
|
deleteComment(id: string): Promise<StatusOk>;
|
|
153
213
|
/**
|
|
154
|
-
* Marks the user's read position in a thread.
|
|
214
|
+
* Marks the user's read position in a thread. Used to track where the user has read up to,
|
|
215
|
+
* so clients can scroll to this position and show a visual indicator (blue line).
|
|
216
|
+
* Comment IDs are strings.
|
|
217
|
+
*
|
|
218
|
+
* @param args - The arguments for marking read position.
|
|
219
|
+
* @param args.threadId - The thread ID.
|
|
220
|
+
* @param args.commentId - The comment ID to mark as the last read position.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* await api.comments.markPosition({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', commentId: '7YpL3oZ4kZ9vP7Q1tR2sX41' })
|
|
225
|
+
* ```
|
|
155
226
|
*/
|
|
156
227
|
markPosition(args: MarkCommentPositionArgs): Promise<StatusOk>;
|
|
157
228
|
}
|
|
@@ -113,15 +113,89 @@ export declare const ConversationMessageListSchema: z.ZodArray<z.ZodPipe<z.ZodOb
|
|
|
113
113
|
* message `id` on `createMessage` when the caller doesn't supply one.
|
|
114
114
|
*/
|
|
115
115
|
export declare class ConversationMessagesClient extends BaseClient {
|
|
116
|
-
|
|
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
|
+
*/
|
|
117
138
|
getMessages(args: GetConversationMessagesArgs): Promise<ConversationMessage[]>;
|
|
118
|
-
/**
|
|
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
|
+
*/
|
|
119
150
|
getMessage(id: string): Promise<ConversationMessage>;
|
|
120
|
-
/**
|
|
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
|
+
*/
|
|
121
170
|
createMessage(args: CreateConversationMessageArgs): Promise<ConversationMessage>;
|
|
122
|
-
/**
|
|
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
|
+
*/
|
|
123
188
|
updateMessage(args: UpdateConversationMessageArgs): Promise<ConversationMessage>;
|
|
124
|
-
/**
|
|
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
|
+
*/
|
|
125
199
|
deleteMessage(id: string): Promise<StatusOk>;
|
|
126
200
|
private simple;
|
|
127
201
|
}
|
|
@@ -163,29 +163,144 @@ export declare const ConversationListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
|
163
163
|
* already-assigned `id` and your generated one is silently dropped.
|
|
164
164
|
*/
|
|
165
165
|
export declare class ConversationsClient extends BaseClient {
|
|
166
|
-
|
|
166
|
+
private readonly linkBaseUrl;
|
|
167
|
+
private readonly conversationSchema;
|
|
168
|
+
private readonly conversationListSchema;
|
|
169
|
+
/**
|
|
170
|
+
* Gets all conversations for a workspace.
|
|
171
|
+
*
|
|
172
|
+
* @param args - The arguments for getting conversations.
|
|
173
|
+
* @param args.workspaceId - The workspace ID.
|
|
174
|
+
* @param args.archived - Optional flag to include archived conversations.
|
|
175
|
+
* @returns An array of conversation objects.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* const conversations = await api.conversations.getConversations({ workspaceId: 123 })
|
|
180
|
+
* conversations.forEach(c => console.log(c.title))
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
167
183
|
getConversations(args: GetConversationsArgs): Promise<Conversation[]>;
|
|
168
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* Gets a single conversation object by id.
|
|
186
|
+
*
|
|
187
|
+
* @param id - The conversation ID.
|
|
188
|
+
* @returns The conversation object.
|
|
189
|
+
*/
|
|
169
190
|
getConversation(id: string): Promise<Conversation>;
|
|
170
191
|
/**
|
|
171
192
|
* Gets an existing 1:1 / group conversation with `userIds`, or creates a
|
|
172
193
|
* new one. `id` is auto-generated if not supplied — on dedupe, the
|
|
173
194
|
* backend returns the existing conversation's `id` instead.
|
|
195
|
+
*
|
|
196
|
+
* @param args - The arguments for getting or creating a conversation.
|
|
197
|
+
* @param args.workspaceId - The workspace ID.
|
|
198
|
+
* @param args.userIds - Array of user IDs to include in the conversation.
|
|
199
|
+
* @returns The conversation object (existing or newly created).
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* const conversation = await api.conversations.getOrCreateConversation({
|
|
204
|
+
* workspaceId: 123,
|
|
205
|
+
* userIds: [101, 202, 303],
|
|
206
|
+
* })
|
|
207
|
+
* ```
|
|
174
208
|
*/
|
|
175
209
|
getOrCreateConversation(args: GetOrCreateConversationArgs): Promise<Conversation>;
|
|
176
|
-
/**
|
|
210
|
+
/**
|
|
211
|
+
* Updates a conversation's title.
|
|
212
|
+
*
|
|
213
|
+
* @param args - The arguments for updating a conversation.
|
|
214
|
+
* @param args.id - The conversation ID.
|
|
215
|
+
* @param args.title - The new title for the conversation.
|
|
216
|
+
* @param args.archived - Optional flag to archive/unarchive the conversation.
|
|
217
|
+
* @returns The updated conversation object.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* const conversation = await api.conversations.updateConversation({
|
|
222
|
+
* id: '7YpL3oZ4kZ9vP7Q1tR2sX42',
|
|
223
|
+
* title: 'New Title',
|
|
224
|
+
* })
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
177
227
|
updateConversation(args: UpdateConversationArgs): Promise<Conversation>;
|
|
228
|
+
/**
|
|
229
|
+
* Archives a conversation.
|
|
230
|
+
*
|
|
231
|
+
* @param id - The conversation ID.
|
|
232
|
+
* @returns The updated conversation object.
|
|
233
|
+
*/
|
|
178
234
|
archiveConversation(id: string): Promise<Conversation>;
|
|
235
|
+
/**
|
|
236
|
+
* Unarchives a conversation.
|
|
237
|
+
*
|
|
238
|
+
* @param id - The conversation ID.
|
|
239
|
+
* @returns The updated conversation object.
|
|
240
|
+
*/
|
|
179
241
|
unarchiveConversation(id: string): Promise<Conversation>;
|
|
242
|
+
/**
|
|
243
|
+
* Adds a user to a conversation.
|
|
244
|
+
*
|
|
245
|
+
* @param args - The arguments for adding a user.
|
|
246
|
+
* @param args.id - The conversation ID.
|
|
247
|
+
* @param args.userId - The user ID to add.
|
|
248
|
+
* @returns The updated conversation object.
|
|
249
|
+
*/
|
|
180
250
|
addUser(args: AddConversationUserArgs): Promise<Conversation>;
|
|
251
|
+
/**
|
|
252
|
+
* Adds multiple users to a conversation.
|
|
253
|
+
*
|
|
254
|
+
* @param args - The arguments for adding users.
|
|
255
|
+
* @param args.id - The conversation ID.
|
|
256
|
+
* @param args.userIds - Array of user IDs to add.
|
|
257
|
+
* @returns The updated conversation object.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* await api.conversations.addUsers({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', userIds: [101, 202] })
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
181
264
|
addUsers(args: AddConversationUsersArgs): Promise<Conversation>;
|
|
265
|
+
/**
|
|
266
|
+
* Removes a user from a conversation.
|
|
267
|
+
*
|
|
268
|
+
* @param args - The arguments for removing a user.
|
|
269
|
+
* @param args.id - The conversation ID.
|
|
270
|
+
* @param args.userId - The user ID to remove.
|
|
271
|
+
* @returns The updated conversation object.
|
|
272
|
+
*/
|
|
182
273
|
removeUser(args: RemoveConversationUserArgs): Promise<Conversation>;
|
|
274
|
+
/**
|
|
275
|
+
* Removes multiple users from a conversation.
|
|
276
|
+
*
|
|
277
|
+
* @param args - The arguments for removing users.
|
|
278
|
+
* @param args.id - The conversation ID.
|
|
279
|
+
* @param args.userIds - Array of user IDs to remove.
|
|
280
|
+
* @returns The updated conversation object.
|
|
281
|
+
*/
|
|
183
282
|
removeUsers(args: RemoveConversationUsersArgs): Promise<Conversation>;
|
|
283
|
+
/**
|
|
284
|
+
* Marks a conversation as read.
|
|
285
|
+
*
|
|
286
|
+
* @param args - The arguments for marking as read.
|
|
287
|
+
* @param args.id - The conversation ID.
|
|
288
|
+
* @param args.objIndex - Optional index of the message to mark as last read.
|
|
289
|
+
* @param args.messageId - Optional message ID to mark as last read.
|
|
290
|
+
*/
|
|
184
291
|
markRead(args: {
|
|
185
292
|
id: string;
|
|
186
293
|
objIndex?: number;
|
|
187
294
|
messageId?: string;
|
|
188
295
|
}): Promise<StatusOk>;
|
|
296
|
+
/**
|
|
297
|
+
* Marks a conversation as unread.
|
|
298
|
+
*
|
|
299
|
+
* @param args - The arguments for marking as unread.
|
|
300
|
+
* @param args.id - The conversation ID.
|
|
301
|
+
* @param args.objIndex - Optional index of the message to mark as last unread.
|
|
302
|
+
* @param args.messageId - Optional message ID to mark as last unread.
|
|
303
|
+
*/
|
|
189
304
|
markUnread(args: {
|
|
190
305
|
id: string;
|
|
191
306
|
objIndex?: number;
|
|
@@ -194,13 +309,41 @@ export declare class ConversationsClient extends BaseClient {
|
|
|
194
309
|
/**
|
|
195
310
|
* Returns unread conversations for a workspace, paired with the unread
|
|
196
311
|
* version counter.
|
|
312
|
+
*
|
|
313
|
+
* @param workspaceId - The workspace ID.
|
|
314
|
+
* @returns Object containing the array of unread conversation references and a version counter.
|
|
197
315
|
*/
|
|
198
316
|
getUnread(workspaceId: number): Promise<{
|
|
199
317
|
data: UnreadConversation[];
|
|
200
318
|
version: number;
|
|
201
319
|
}>;
|
|
320
|
+
/**
|
|
321
|
+
* Clears all unread conversations for a workspace.
|
|
322
|
+
*
|
|
323
|
+
* @param workspaceId - The workspace ID.
|
|
324
|
+
*/
|
|
202
325
|
clearUnread(workspaceId: number): Promise<StatusOk>;
|
|
326
|
+
/**
|
|
327
|
+
* Mutes a conversation for a specified number of minutes.
|
|
328
|
+
* The user will receive no notifications from this conversation during that period.
|
|
329
|
+
*
|
|
330
|
+
* @param args - The arguments for muting a conversation.
|
|
331
|
+
* @param args.id - The conversation ID.
|
|
332
|
+
* @param args.minutes - Number of minutes to mute the conversation.
|
|
333
|
+
* @returns The updated conversation object.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```typescript
|
|
337
|
+
* const conversation = await api.conversations.muteConversation({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', minutes: 30 })
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
203
340
|
muteConversation(args: MuteConversationArgs): Promise<Conversation>;
|
|
341
|
+
/**
|
|
342
|
+
* Unmutes a conversation.
|
|
343
|
+
*
|
|
344
|
+
* @param id - The conversation ID.
|
|
345
|
+
* @returns The updated conversation object.
|
|
346
|
+
*/
|
|
204
347
|
unmuteConversation(id: string): Promise<Conversation>;
|
|
205
348
|
private simple;
|
|
206
349
|
}
|