@doist/comms-sdk 0.1.0-alpha.1 → 0.2.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.
- package/README.md +1 -1
- package/dist/cjs/clients/add-comment-helper.js +17 -0
- package/dist/cjs/clients/base-client.js +3 -5
- package/dist/cjs/clients/channels-client.js +123 -6
- package/dist/cjs/clients/comments-client.js +75 -9
- package/dist/cjs/clients/conversation-messages-client.js +76 -5
- package/dist/cjs/clients/conversations-client.js +143 -3
- package/dist/cjs/clients/groups-client.js +98 -5
- package/dist/cjs/clients/inbox-client.js +87 -14
- 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 +211 -16
- 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 +80 -7
- 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/index.js +1 -0
- package/dist/cjs/types/requests.js +0 -1
- package/dist/esm/clients/add-comment-helper.js +17 -0
- package/dist/esm/clients/base-client.js +3 -5
- package/dist/esm/clients/channels-client.js +123 -6
- package/dist/esm/clients/comments-client.js +75 -9
- package/dist/esm/clients/conversation-messages-client.js +76 -5
- package/dist/esm/clients/conversations-client.js +143 -3
- package/dist/esm/clients/groups-client.js +98 -5
- package/dist/esm/clients/inbox-client.js +87 -14
- 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 +211 -16
- 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 +80 -7
- 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/index.js +1 -0
- package/dist/esm/types/requests.js +0 -1
- package/dist/types/clients/add-comment-helper.d.ts +17 -0
- package/dist/types/clients/base-client.d.ts +4 -0
- package/dist/types/clients/channels-client.d.ts +123 -6
- package/dist/types/clients/comments-client.d.ts +73 -6
- package/dist/types/clients/conversation-messages-client.d.ts +76 -5
- package/dist/types/clients/conversations-client.d.ts +143 -3
- package/dist/types/clients/groups-client.d.ts +98 -5
- package/dist/types/clients/inbox-client.d.ts +81 -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 +200 -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 +80 -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/index.d.ts +1 -0
- package/dist/types/types/requests.d.ts +2 -21
- package/package.json +1 -1
|
@@ -11,15 +11,30 @@ export const CommentListSchema = z.array(CommentSchema);
|
|
|
11
11
|
*/
|
|
12
12
|
export class CommentsClient extends BaseClient {
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Gets all comments for a thread. `newerThan` / `olderThan` (`Date`) are
|
|
15
15
|
* converted to `newer_than_ts` / `older_than_ts` epoch seconds on the
|
|
16
16
|
* wire.
|
|
17
|
+
*
|
|
18
|
+
* @param args - The arguments for getting comments.
|
|
19
|
+
* @param args.threadId - The thread ID.
|
|
20
|
+
* @param args.newerThan - Optional date to get comments newer than.
|
|
21
|
+
* @param args.olderThan - Optional date to get comments older than.
|
|
22
|
+
* @param args.limit - Optional limit on number of comments returned.
|
|
23
|
+
* @returns An array of comment objects.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const comments = await api.comments.getComments({
|
|
28
|
+
* threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
|
|
29
|
+
* newerThan: new Date('2024-01-01'),
|
|
30
|
+
* })
|
|
31
|
+
* comments.forEach(c => console.log(c.content))
|
|
32
|
+
* ```
|
|
17
33
|
*/
|
|
18
34
|
getComments(args) {
|
|
19
35
|
const params = { threadId: args.threadId };
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
params.newerThanTs = Math.floor(newerThan.getTime() / 1000);
|
|
36
|
+
if (args.newerThan)
|
|
37
|
+
params.newerThanTs = Math.floor(args.newerThan.getTime() / 1000);
|
|
23
38
|
if (args.olderThan)
|
|
24
39
|
params.olderThanTs = Math.floor(args.olderThan.getTime() / 1000);
|
|
25
40
|
if (args.limit)
|
|
@@ -33,7 +48,12 @@ export class CommentsClient extends BaseClient {
|
|
|
33
48
|
customFetch: this.customFetch,
|
|
34
49
|
}).then((response) => CommentListSchema.parse(response.data));
|
|
35
50
|
}
|
|
36
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Gets a single comment object by id. The API wraps it in `{comment: ...}`.
|
|
53
|
+
*
|
|
54
|
+
* @param id - The comment ID.
|
|
55
|
+
* @returns The comment object.
|
|
56
|
+
*/
|
|
37
57
|
getComment(id) {
|
|
38
58
|
const wrappedSchema = z.object({ comment: CommentSchema }).transform((data) => data.comment);
|
|
39
59
|
return request({
|
|
@@ -46,12 +66,43 @@ export class CommentsClient extends BaseClient {
|
|
|
46
66
|
}).then((response) => wrappedSchema.parse(response.data));
|
|
47
67
|
}
|
|
48
68
|
/**
|
|
49
|
-
* Creates a new comment. `id` is auto-generated if not supplied.
|
|
69
|
+
* Creates a new comment on a thread. `id` is auto-generated if not supplied.
|
|
70
|
+
*
|
|
71
|
+
* @param args - The arguments for creating a comment.
|
|
72
|
+
* @param args.threadId - The thread ID.
|
|
73
|
+
* @param args.content - The comment content.
|
|
74
|
+
* @param args.recipients - Optional array of user IDs to notify directly.
|
|
75
|
+
* @param args.groups - Optional array of custom group IDs to notify.
|
|
76
|
+
* @param args.directMentions - Optional array of user IDs that were @-mentioned in
|
|
77
|
+
* `content`.
|
|
78
|
+
* @param args.notifyAudience - Optional broader audience to notify in addition to
|
|
79
|
+
* `recipients` and `groups`. `'channel'` notifies everyone in the channel;
|
|
80
|
+
* `'thread'` notifies everyone who has interacted with the thread.
|
|
81
|
+
* @param args.attachments - Optional array of {@link Attachment} objects.
|
|
82
|
+
* @returns The created comment object.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* // Notify everyone who has interacted with the thread, plus two extra users.
|
|
87
|
+
* const comment = await api.comments.createComment({
|
|
88
|
+
* threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
|
|
89
|
+
* content: 'Great idea! Let\'s proceed.',
|
|
90
|
+
* notifyAudience: 'thread',
|
|
91
|
+
* recipients: [101, 202],
|
|
92
|
+
* })
|
|
93
|
+
* ```
|
|
50
94
|
*/
|
|
51
95
|
createComment(args) {
|
|
52
96
|
return addCommentRequest({ baseUri: this.getBaseUri(), apiToken: this.apiToken, customFetch: this.customFetch }, args);
|
|
53
97
|
}
|
|
54
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* Updates a comment's properties.
|
|
100
|
+
*
|
|
101
|
+
* @param args - The arguments for updating a comment.
|
|
102
|
+
* @param args.id - The comment ID.
|
|
103
|
+
* @param args.content - The new comment content.
|
|
104
|
+
* @returns The updated comment object.
|
|
105
|
+
*/
|
|
55
106
|
updateComment(args) {
|
|
56
107
|
return request({
|
|
57
108
|
httpMethod: 'POST',
|
|
@@ -62,7 +113,11 @@ export class CommentsClient extends BaseClient {
|
|
|
62
113
|
customFetch: this.customFetch,
|
|
63
114
|
}).then((response) => CommentSchema.parse(response.data));
|
|
64
115
|
}
|
|
65
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Permanently deletes a comment.
|
|
118
|
+
*
|
|
119
|
+
* @param id - The comment ID.
|
|
120
|
+
*/
|
|
66
121
|
deleteComment(id) {
|
|
67
122
|
return request({
|
|
68
123
|
httpMethod: 'POST',
|
|
@@ -74,7 +129,18 @@ export class CommentsClient extends BaseClient {
|
|
|
74
129
|
}).then((response) => StatusOkSchema.parse(response.data));
|
|
75
130
|
}
|
|
76
131
|
/**
|
|
77
|
-
* Marks the user's read position in a thread.
|
|
132
|
+
* Marks the user's read position in a thread. Used to track where the user has read up to,
|
|
133
|
+
* so clients can scroll to this position and show a visual indicator (blue line).
|
|
134
|
+
* Comment IDs are strings.
|
|
135
|
+
*
|
|
136
|
+
* @param args - The arguments for marking read position.
|
|
137
|
+
* @param args.threadId - The thread ID.
|
|
138
|
+
* @param args.commentId - The comment ID to mark as the last read position.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* await api.comments.markPosition({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', commentId: '7YpL3oZ4kZ9vP7Q1tR2sX41' })
|
|
143
|
+
* ```
|
|
78
144
|
*/
|
|
79
145
|
markPosition(args) {
|
|
80
146
|
return request({
|
|
@@ -10,7 +10,25 @@ export const ConversationMessageListSchema = z.array(ConversationMessageSchema);
|
|
|
10
10
|
* message `id` on `createMessage` when the caller doesn't supply one.
|
|
11
11
|
*/
|
|
12
12
|
export class ConversationMessagesClient extends BaseClient {
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Gets all messages in a conversation.
|
|
15
|
+
*
|
|
16
|
+
* @param args - The arguments for getting messages.
|
|
17
|
+
* @param args.conversationId - The conversation ID.
|
|
18
|
+
* @param args.newerThan - Optional date to get messages newer than.
|
|
19
|
+
* @param args.olderThan - Optional date to get messages older than.
|
|
20
|
+
* @param args.limit - Optional limit on number of messages returned.
|
|
21
|
+
* @param args.cursor - Optional cursor for pagination.
|
|
22
|
+
* @returns An array of message objects.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const messages = await api.conversationMessages.getMessages({
|
|
27
|
+
* conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
|
|
28
|
+
* newerThan: new Date('2024-01-01'),
|
|
29
|
+
* })
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
14
32
|
getMessages(args) {
|
|
15
33
|
const params = { conversationId: args.conversationId };
|
|
16
34
|
if (args.newerThan)
|
|
@@ -30,11 +48,39 @@ export class ConversationMessagesClient extends BaseClient {
|
|
|
30
48
|
customFetch: this.customFetch,
|
|
31
49
|
}).then((response) => ConversationMessageListSchema.parse(response.data));
|
|
32
50
|
}
|
|
33
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Gets a single conversation message by id.
|
|
53
|
+
*
|
|
54
|
+
* @param id - The message ID.
|
|
55
|
+
* @returns The conversation message object.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const message = await api.conversationMessages.getMessage('7YpL3oZ4kZ9vP7Q1tR2sX43')
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
34
62
|
getMessage(id) {
|
|
35
63
|
return this.simple('GET', 'getone', { id }, ConversationMessageSchema);
|
|
36
64
|
}
|
|
37
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new message in a conversation. `id` is auto-generated if not
|
|
67
|
+
* supplied.
|
|
68
|
+
*
|
|
69
|
+
* @param args - The arguments for creating a message.
|
|
70
|
+
* @param args.conversationId - The conversation ID.
|
|
71
|
+
* @param args.content - The message content.
|
|
72
|
+
* @param args.attachments - Optional array of {@link Attachment} objects.
|
|
73
|
+
* @param args.actions - Optional array of action objects.
|
|
74
|
+
* @returns The created message object.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const message = await api.conversationMessages.createMessage({
|
|
79
|
+
* conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
|
|
80
|
+
* content: 'Thanks for the update!',
|
|
81
|
+
* })
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
38
84
|
createMessage(args) {
|
|
39
85
|
const params = {
|
|
40
86
|
conversationId: args.conversationId,
|
|
@@ -53,7 +99,23 @@ export class ConversationMessagesClient extends BaseClient {
|
|
|
53
99
|
params.notify = args.notify;
|
|
54
100
|
return this.simple('POST', 'add', params, ConversationMessageSchema);
|
|
55
101
|
}
|
|
56
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* Updates a conversation message.
|
|
104
|
+
*
|
|
105
|
+
* @param args - The arguments for updating a message.
|
|
106
|
+
* @param args.id - The message ID.
|
|
107
|
+
* @param args.content - The new message content.
|
|
108
|
+
* @param args.attachments - Optional array of {@link Attachment} objects.
|
|
109
|
+
* @returns The updated message object.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const message = await api.conversationMessages.updateMessage({
|
|
114
|
+
* id: '7YpL3oZ4kZ9vP7Q1tR2sX43',
|
|
115
|
+
* content: 'Updated message content',
|
|
116
|
+
* })
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
57
119
|
updateMessage(args) {
|
|
58
120
|
const params = { id: args.id, content: args.content };
|
|
59
121
|
if (args.attachments)
|
|
@@ -66,7 +128,16 @@ export class ConversationMessagesClient extends BaseClient {
|
|
|
66
128
|
params.directGroupMentions = args.directGroupMentions;
|
|
67
129
|
return this.simple('POST', 'update', params, ConversationMessageSchema);
|
|
68
130
|
}
|
|
69
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* Permanently deletes a conversation message.
|
|
133
|
+
*
|
|
134
|
+
* @param id - The message ID.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* await api.conversationMessages.deleteMessage('7YpL3oZ4kZ9vP7Q1tR2sX43')
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
70
141
|
deleteMessage(id) {
|
|
71
142
|
return this.simple('POST', 'remove', { id }, StatusOkSchema);
|
|
72
143
|
}
|
|
@@ -16,7 +16,20 @@ const GetUnreadResponseSchema = z.object({
|
|
|
16
16
|
* already-assigned `id` and your generated one is silently dropped.
|
|
17
17
|
*/
|
|
18
18
|
export class ConversationsClient extends BaseClient {
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Gets all conversations for a workspace.
|
|
21
|
+
*
|
|
22
|
+
* @param args - The arguments for getting conversations.
|
|
23
|
+
* @param args.workspaceId - The workspace ID.
|
|
24
|
+
* @param args.archived - Optional flag to include archived conversations.
|
|
25
|
+
* @returns An array of conversation objects.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const conversations = await api.conversations.getConversations({ workspaceId: 123 })
|
|
30
|
+
* conversations.forEach(c => console.log(c.title))
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
20
33
|
getConversations(args) {
|
|
21
34
|
return request({
|
|
22
35
|
httpMethod: 'GET',
|
|
@@ -27,7 +40,12 @@ export class ConversationsClient extends BaseClient {
|
|
|
27
40
|
customFetch: this.customFetch,
|
|
28
41
|
}).then((response) => ConversationListSchema.parse(response.data));
|
|
29
42
|
}
|
|
30
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Gets a single conversation object by id.
|
|
45
|
+
*
|
|
46
|
+
* @param id - The conversation ID.
|
|
47
|
+
* @returns The conversation object.
|
|
48
|
+
*/
|
|
31
49
|
getConversation(id) {
|
|
32
50
|
return this.simple('GET', 'getone', { id }, ConversationSchema);
|
|
33
51
|
}
|
|
@@ -35,54 +53,176 @@ export class ConversationsClient extends BaseClient {
|
|
|
35
53
|
* Gets an existing 1:1 / group conversation with `userIds`, or creates a
|
|
36
54
|
* new one. `id` is auto-generated if not supplied — on dedupe, the
|
|
37
55
|
* backend returns the existing conversation's `id` instead.
|
|
56
|
+
*
|
|
57
|
+
* @param args - The arguments for getting or creating a conversation.
|
|
58
|
+
* @param args.workspaceId - The workspace ID.
|
|
59
|
+
* @param args.userIds - Array of user IDs to include in the conversation.
|
|
60
|
+
* @returns The conversation object (existing or newly created).
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const conversation = await api.conversations.getOrCreateConversation({
|
|
65
|
+
* workspaceId: 123,
|
|
66
|
+
* userIds: [101, 202, 303],
|
|
67
|
+
* })
|
|
68
|
+
* ```
|
|
38
69
|
*/
|
|
39
70
|
getOrCreateConversation(args) {
|
|
40
71
|
return this.simple('GET', 'get_or_create', { ...args, id: resolveCreateId(args.id) }, ConversationSchema);
|
|
41
72
|
}
|
|
42
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Updates a conversation's title.
|
|
75
|
+
*
|
|
76
|
+
* @param args - The arguments for updating a conversation.
|
|
77
|
+
* @param args.id - The conversation ID.
|
|
78
|
+
* @param args.title - The new title for the conversation.
|
|
79
|
+
* @param args.archived - Optional flag to archive/unarchive the conversation.
|
|
80
|
+
* @returns The updated conversation object.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const conversation = await api.conversations.updateConversation({
|
|
85
|
+
* id: '7YpL3oZ4kZ9vP7Q1tR2sX42',
|
|
86
|
+
* title: 'New Title',
|
|
87
|
+
* })
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
43
90
|
updateConversation(args) {
|
|
44
91
|
const params = { id: args.id, title: args.title };
|
|
45
92
|
if (args.archived !== undefined)
|
|
46
93
|
params.archived = args.archived;
|
|
47
94
|
return this.simple('POST', 'update', params, ConversationSchema);
|
|
48
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Archives a conversation.
|
|
98
|
+
*
|
|
99
|
+
* @param id - The conversation ID.
|
|
100
|
+
* @returns The updated conversation object.
|
|
101
|
+
*/
|
|
49
102
|
archiveConversation(id) {
|
|
50
103
|
return this.simple('GET', 'archive', { id }, ConversationSchema);
|
|
51
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Unarchives a conversation.
|
|
107
|
+
*
|
|
108
|
+
* @param id - The conversation ID.
|
|
109
|
+
* @returns The updated conversation object.
|
|
110
|
+
*/
|
|
52
111
|
unarchiveConversation(id) {
|
|
53
112
|
return this.simple('GET', 'unarchive', { id }, ConversationSchema);
|
|
54
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Adds a user to a conversation.
|
|
116
|
+
*
|
|
117
|
+
* @param args - The arguments for adding a user.
|
|
118
|
+
* @param args.id - The conversation ID.
|
|
119
|
+
* @param args.userId - The user ID to add.
|
|
120
|
+
* @returns The updated conversation object.
|
|
121
|
+
*/
|
|
55
122
|
addUser(args) {
|
|
56
123
|
return this.simple('POST', 'add_user', { ...args }, ConversationSchema);
|
|
57
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Adds multiple users to a conversation.
|
|
127
|
+
*
|
|
128
|
+
* @param args - The arguments for adding users.
|
|
129
|
+
* @param args.id - The conversation ID.
|
|
130
|
+
* @param args.userIds - Array of user IDs to add.
|
|
131
|
+
* @returns The updated conversation object.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* await api.conversations.addUsers({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', userIds: [101, 202] })
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
58
138
|
addUsers(args) {
|
|
59
139
|
return this.simple('POST', 'add_users', { ...args }, ConversationSchema);
|
|
60
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Removes a user from a conversation.
|
|
143
|
+
*
|
|
144
|
+
* @param args - The arguments for removing a user.
|
|
145
|
+
* @param args.id - The conversation ID.
|
|
146
|
+
* @param args.userId - The user ID to remove.
|
|
147
|
+
* @returns The updated conversation object.
|
|
148
|
+
*/
|
|
61
149
|
removeUser(args) {
|
|
62
150
|
return this.simple('POST', 'remove_user', { ...args }, ConversationSchema);
|
|
63
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Removes multiple users from a conversation.
|
|
154
|
+
*
|
|
155
|
+
* @param args - The arguments for removing users.
|
|
156
|
+
* @param args.id - The conversation ID.
|
|
157
|
+
* @param args.userIds - Array of user IDs to remove.
|
|
158
|
+
* @returns The updated conversation object.
|
|
159
|
+
*/
|
|
64
160
|
removeUsers(args) {
|
|
65
161
|
return this.simple('POST', 'remove_users', { ...args }, ConversationSchema);
|
|
66
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Marks a conversation as read.
|
|
165
|
+
*
|
|
166
|
+
* @param args - The arguments for marking as read.
|
|
167
|
+
* @param args.id - The conversation ID.
|
|
168
|
+
* @param args.objIndex - Optional index of the message to mark as last read.
|
|
169
|
+
* @param args.messageId - Optional message ID to mark as last read.
|
|
170
|
+
*/
|
|
67
171
|
markRead(args) {
|
|
68
172
|
return this.simple('POST', 'mark_read', { ...args }, StatusOkSchema);
|
|
69
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Marks a conversation as unread.
|
|
176
|
+
*
|
|
177
|
+
* @param args - The arguments for marking as unread.
|
|
178
|
+
* @param args.id - The conversation ID.
|
|
179
|
+
* @param args.objIndex - Optional index of the message to mark as last unread.
|
|
180
|
+
* @param args.messageId - Optional message ID to mark as last unread.
|
|
181
|
+
*/
|
|
70
182
|
markUnread(args) {
|
|
71
183
|
return this.simple('POST', 'mark_unread', { ...args }, StatusOkSchema);
|
|
72
184
|
}
|
|
73
185
|
/**
|
|
74
186
|
* Returns unread conversations for a workspace, paired with the unread
|
|
75
187
|
* version counter.
|
|
188
|
+
*
|
|
189
|
+
* @param workspaceId - The workspace ID.
|
|
190
|
+
* @returns Object containing the array of unread conversation references and a version counter.
|
|
76
191
|
*/
|
|
77
192
|
getUnread(workspaceId) {
|
|
78
193
|
return this.simple('GET', 'get_unread', { workspaceId }, GetUnreadResponseSchema);
|
|
79
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Clears all unread conversations for a workspace.
|
|
197
|
+
*
|
|
198
|
+
* @param workspaceId - The workspace ID.
|
|
199
|
+
*/
|
|
80
200
|
clearUnread(workspaceId) {
|
|
81
201
|
return this.simple('GET', 'clear_unread', { workspaceId }, StatusOkSchema);
|
|
82
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Mutes a conversation for a specified number of minutes.
|
|
205
|
+
* The user will receive no notifications from this conversation during that period.
|
|
206
|
+
*
|
|
207
|
+
* @param args - The arguments for muting a conversation.
|
|
208
|
+
* @param args.id - The conversation ID.
|
|
209
|
+
* @param args.minutes - Number of minutes to mute the conversation.
|
|
210
|
+
* @returns The updated conversation object.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const conversation = await api.conversations.muteConversation({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', minutes: 30 })
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
83
217
|
muteConversation(args) {
|
|
84
218
|
return this.simple('GET', 'mute', { ...args }, ConversationSchema);
|
|
85
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Unmutes a conversation.
|
|
222
|
+
*
|
|
223
|
+
* @param id - The conversation ID.
|
|
224
|
+
* @returns The updated conversation object.
|
|
225
|
+
*/
|
|
86
226
|
unmuteConversation(id) {
|
|
87
227
|
return this.simple('GET', 'unmute', { id }, ConversationSchema);
|
|
88
228
|
}
|
|
@@ -15,7 +15,18 @@ export const GroupListSchema = z.array(GroupSchema);
|
|
|
15
15
|
* `workspace_id` alongside the group `id`.
|
|
16
16
|
*/
|
|
17
17
|
export class GroupsClient extends BaseClient {
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Gets all groups for a given workspace.
|
|
20
|
+
*
|
|
21
|
+
* @param workspaceId - The workspace ID.
|
|
22
|
+
* @returns An array of group objects.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const groups = await api.groups.getGroups(123)
|
|
27
|
+
* groups.forEach(g => console.log(g.name))
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
19
30
|
getGroups(workspaceId) {
|
|
20
31
|
return request({
|
|
21
32
|
httpMethod: 'GET',
|
|
@@ -26,31 +37,113 @@ export class GroupsClient extends BaseClient {
|
|
|
26
37
|
customFetch: this.customFetch,
|
|
27
38
|
}).then((response) => GroupListSchema.parse(response.data));
|
|
28
39
|
}
|
|
29
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Gets a single group object by id. Requires `workspaceId`.
|
|
42
|
+
*
|
|
43
|
+
* @param args - The arguments for getting a group.
|
|
44
|
+
* @param args.id - The group ID.
|
|
45
|
+
* @param args.workspaceId - The workspace ID.
|
|
46
|
+
* @returns The group object.
|
|
47
|
+
*/
|
|
30
48
|
getGroup(args) {
|
|
31
49
|
return this.simple('GET', 'getone', { ...args }, GroupSchema);
|
|
32
50
|
}
|
|
33
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new group. `id` is auto-generated if not supplied.
|
|
53
|
+
*
|
|
54
|
+
* @param args - The arguments for creating a group.
|
|
55
|
+
* @param args.workspaceId - The workspace ID.
|
|
56
|
+
* @param args.name - The group name.
|
|
57
|
+
* @param args.id - Optional caller-supplied group ID (for optimistic-UI workflows).
|
|
58
|
+
* @param args.description - Optional group description.
|
|
59
|
+
* @param args.userIds - Optional array of user IDs to add to the group.
|
|
60
|
+
* @returns The created group object.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const group = await api.groups.createGroup({
|
|
65
|
+
* workspaceId: 123,
|
|
66
|
+
* name: 'Engineering Team',
|
|
67
|
+
* userIds: [1, 2, 3],
|
|
68
|
+
* })
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
34
71
|
createGroup(args) {
|
|
35
72
|
return this.simple('POST', 'add', { ...args, id: resolveCreateId(args.id) }, GroupSchema);
|
|
36
73
|
}
|
|
37
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Updates a group's properties. Requires `workspaceId`.
|
|
76
|
+
*
|
|
77
|
+
* @param args - The arguments for updating a group.
|
|
78
|
+
* @param args.id - The group ID.
|
|
79
|
+
* @param args.workspaceId - The workspace ID.
|
|
80
|
+
* @param args.name - Optional new group name.
|
|
81
|
+
* @param args.description - Optional new group description.
|
|
82
|
+
* @returns The updated group object.
|
|
83
|
+
*/
|
|
38
84
|
updateGroup(args) {
|
|
39
85
|
return this.simple('POST', 'update', { ...args }, GroupSchema);
|
|
40
86
|
}
|
|
41
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Permanently deletes a group. Requires `workspaceId`.
|
|
89
|
+
*
|
|
90
|
+
* @param args - The arguments for deleting a group.
|
|
91
|
+
* @param args.id - The group ID.
|
|
92
|
+
* @param args.workspaceId - The workspace ID.
|
|
93
|
+
*/
|
|
42
94
|
deleteGroup(args) {
|
|
43
95
|
return this.simple('POST', 'remove', { ...args }, StatusOkSchema);
|
|
44
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Adds a user to a group.
|
|
99
|
+
*
|
|
100
|
+
* @param args - The arguments for adding a user.
|
|
101
|
+
* @param args.id - The group ID.
|
|
102
|
+
* @param args.workspaceId - The workspace ID.
|
|
103
|
+
* @param args.userId - The user ID to add.
|
|
104
|
+
*/
|
|
45
105
|
addUser(args) {
|
|
46
106
|
return this.simple('POST', 'add_user', { ...args }, StatusOkSchema);
|
|
47
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Adds multiple users to a group.
|
|
110
|
+
*
|
|
111
|
+
* @param args - The arguments for adding users.
|
|
112
|
+
* @param args.id - The group ID.
|
|
113
|
+
* @param args.workspaceId - The workspace ID.
|
|
114
|
+
* @param args.userIds - Array of user IDs to add.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* await api.groups.addUsers({
|
|
119
|
+
* id: '7YpL3oZ4kZ9vP7Q1tR2sX45',
|
|
120
|
+
* workspaceId: 123,
|
|
121
|
+
* userIds: [101, 202, 303],
|
|
122
|
+
* })
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
48
125
|
addUsers(args) {
|
|
49
126
|
return this.simple('POST', 'add_users', { ...args }, StatusOkSchema);
|
|
50
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Removes a user from a group.
|
|
130
|
+
*
|
|
131
|
+
* @param args - The arguments for removing a user.
|
|
132
|
+
* @param args.id - The group ID.
|
|
133
|
+
* @param args.workspaceId - The workspace ID.
|
|
134
|
+
* @param args.userId - The user ID to remove.
|
|
135
|
+
*/
|
|
51
136
|
removeUser(args) {
|
|
52
137
|
return this.simple('POST', 'remove_user', { ...args }, StatusOkSchema);
|
|
53
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Removes multiple users from a group.
|
|
141
|
+
*
|
|
142
|
+
* @param args - The arguments for removing users.
|
|
143
|
+
* @param args.id - The group ID.
|
|
144
|
+
* @param args.workspaceId - The workspace ID.
|
|
145
|
+
* @param args.userIds - Array of user IDs to remove.
|
|
146
|
+
*/
|
|
54
147
|
removeUsers(args) {
|
|
55
148
|
return this.simple('POST', 'remove_users', { ...args }, StatusOkSchema);
|
|
56
149
|
}
|