@todoist/comms-sdk 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +187 -2
- package/dist/esm/authentication.js +247 -0
- package/dist/esm/clients/add-comment-helper.js +41 -0
- package/dist/esm/clients/attachments-client.js +99 -0
- package/dist/esm/clients/base-client.js +30 -0
- package/dist/esm/clients/channels-client.js +209 -0
- package/dist/esm/clients/comments-client.js +177 -0
- package/dist/esm/clients/conversation-messages-client.js +167 -0
- package/dist/esm/clients/conversations-client.js +281 -0
- package/dist/esm/clients/groups-client.js +170 -0
- package/dist/esm/clients/hooks-client.js +50 -0
- package/dist/esm/clients/inbox-client.js +186 -0
- package/dist/esm/clients/notify-audience.js +43 -0
- package/dist/esm/clients/reactions-client.js +96 -0
- package/dist/esm/clients/search-client.js +140 -0
- package/dist/esm/clients/threads-client.js +363 -0
- package/dist/esm/clients/users-client.js +368 -0
- package/dist/esm/clients/workspace-users-client.js +299 -0
- package/dist/esm/clients/workspaces-client.js +177 -0
- package/dist/esm/comms-api.js +67 -0
- package/dist/esm/consts/endpoints.js +31 -0
- package/dist/esm/index.js +20 -0
- package/dist/esm/migration.js +92 -0
- package/dist/esm/testUtils/msw-handlers.js +45 -0
- package/dist/esm/testUtils/msw-setup.js +32 -0
- package/dist/esm/testUtils/obsidian-fetch-adapter.js +50 -0
- package/dist/esm/testUtils/test-defaults.js +103 -0
- package/dist/esm/transport/fetch-with-retry.js +240 -0
- package/dist/esm/transport/http-client.js +53 -0
- package/dist/esm/transport/http-dispatcher.js +149 -0
- package/dist/esm/types/api-version.js +5 -0
- package/dist/esm/types/entities.js +508 -0
- package/dist/esm/types/enums.js +34 -0
- package/dist/esm/types/errors.js +82 -0
- package/dist/esm/types/http.js +1 -0
- package/dist/esm/types/index.js +6 -0
- package/dist/esm/types/requests.js +184 -0
- package/dist/esm/utils/case-conversion.js +47 -0
- package/dist/esm/utils/conversation-title.js +110 -0
- package/dist/esm/utils/headers.js +29 -0
- package/dist/esm/utils/index.js +5 -0
- package/dist/esm/utils/multipart-upload.js +198 -0
- package/dist/esm/utils/reply-recipients.js +111 -0
- package/dist/esm/utils/timestamp-conversion.js +54 -0
- package/dist/esm/utils/url-helpers.js +202 -0
- package/dist/esm/utils/uuidv7.js +170 -0
- package/dist/types/authentication.d.ts +183 -0
- package/dist/types/clients/add-comment-helper.d.ts +32 -0
- package/dist/types/clients/attachments-client.d.ts +55 -0
- package/dist/types/clients/base-client.d.ts +37 -0
- package/dist/types/clients/channels-client.d.ts +211 -0
- package/dist/types/clients/comments-client.d.ts +228 -0
- package/dist/types/clients/conversation-messages-client.d.ts +201 -0
- package/dist/types/clients/conversations-client.d.ts +366 -0
- package/dist/types/clients/groups-client.d.ts +148 -0
- package/dist/types/clients/hooks-client.d.ts +29 -0
- package/dist/types/clients/inbox-client.d.ts +478 -0
- package/dist/types/clients/notify-audience.d.ts +22 -0
- package/dist/types/clients/reactions-client.d.ts +57 -0
- package/dist/types/clients/search-client.d.ts +71 -0
- package/dist/types/clients/threads-client.d.ts +547 -0
- package/dist/types/clients/users-client.d.ts +280 -0
- package/dist/types/clients/workspace-users-client.d.ts +172 -0
- package/dist/types/clients/workspaces-client.d.ts +154 -0
- package/dist/types/comms-api.d.ts +73 -0
- package/dist/types/consts/endpoints.d.ts +27 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/migration.d.ts +78 -0
- package/dist/types/testUtils/msw-handlers.d.ts +28 -0
- package/dist/types/testUtils/msw-setup.d.ts +1 -0
- package/dist/types/testUtils/obsidian-fetch-adapter.d.ts +29 -0
- package/dist/types/testUtils/test-defaults.d.ts +17 -0
- package/dist/types/transport/fetch-with-retry.d.ts +4 -0
- package/dist/types/transport/http-client.d.ts +14 -0
- package/dist/types/transport/http-dispatcher.d.ts +46 -0
- package/dist/types/types/api-version.d.ts +6 -0
- package/dist/types/types/entities.d.ts +3081 -0
- package/dist/types/types/enums.d.ts +55 -0
- package/dist/types/types/errors.d.ts +57 -0
- package/dist/types/types/http.d.ts +60 -0
- package/dist/types/types/index.d.ts +6 -0
- package/dist/types/types/requests.d.ts +604 -0
- package/dist/types/utils/case-conversion.d.ts +8 -0
- package/dist/types/utils/conversation-title.d.ts +84 -0
- package/dist/types/utils/headers.d.ts +13 -0
- package/dist/types/utils/index.d.ts +6 -0
- package/dist/types/utils/multipart-upload.d.ts +59 -0
- package/dist/types/utils/reply-recipients.d.ts +60 -0
- package/dist/types/utils/timestamp-conversion.d.ts +13 -0
- package/dist/types/utils/url-helpers.d.ts +129 -0
- package/dist/types/utils/uuidv7.d.ts +42 -0
- package/package.json +81 -5
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type Attachment } from '../types/entities.js';
|
|
3
|
+
import type { UploadAttachmentArgs } from '../types/requests.js';
|
|
4
|
+
import { BaseClient } from './base-client.js';
|
|
5
|
+
export declare const IMAGE_READ_MIME_TYPES: readonly ["image/jpeg", "image/png", "image/webp"];
|
|
6
|
+
export type ImageReadMimeType = (typeof IMAGE_READ_MIME_TYPES)[number];
|
|
7
|
+
export declare const ImageReadResultSchema: z.ZodObject<{
|
|
8
|
+
mimeType: z.ZodEnum<{
|
|
9
|
+
"image/png": "image/png";
|
|
10
|
+
"image/jpeg": "image/jpeg";
|
|
11
|
+
"image/webp": "image/webp";
|
|
12
|
+
}>;
|
|
13
|
+
dataBase64: z.ZodString;
|
|
14
|
+
byteLength: z.ZodNumber;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type ImageReadResult = z.infer<typeof ImageReadResultSchema>;
|
|
17
|
+
/**
|
|
18
|
+
* Client for uploading attachments and reading thread images.
|
|
19
|
+
*
|
|
20
|
+
* Attachments are uploaded independently, then referenced by passing the returned
|
|
21
|
+
* {@link Attachment} into the `attachments` array of `comments.createComment`,
|
|
22
|
+
* `conversationMessages.createMessage`, and similar calls.
|
|
23
|
+
*/
|
|
24
|
+
export declare class AttachmentsClient extends BaseClient {
|
|
25
|
+
/** Read one thread image under the caller's content scope. */
|
|
26
|
+
readImage(uploadId: string, threadId: string): Promise<ImageReadResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Uploads a file and returns the created {@link Attachment}.
|
|
29
|
+
*
|
|
30
|
+
* Mirrors the canonical multipart upload: `POST /attachments/upload` with the `file`
|
|
31
|
+
* binary plus `workspace_id`, `file_name`, `file_size`, `attachment_id`, and
|
|
32
|
+
* `underlying_type` form fields.
|
|
33
|
+
*
|
|
34
|
+
* @param args - The file to upload and optional metadata.
|
|
35
|
+
* @returns The created attachment, ready to attach to a comment or message.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import { readFile } from 'node:fs/promises'
|
|
40
|
+
*
|
|
41
|
+
* const attachment = await api.attachments.upload({
|
|
42
|
+
* workspaceId: 12345,
|
|
43
|
+
* file: await readFile('./diagram.png'),
|
|
44
|
+
* fileName: 'diagram.png',
|
|
45
|
+
* })
|
|
46
|
+
*
|
|
47
|
+
* await api.comments.createComment({
|
|
48
|
+
* threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
|
|
49
|
+
* content: 'See attached',
|
|
50
|
+
* attachments: [attachment],
|
|
51
|
+
* })
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
upload(args: UploadAttachmentArgs): Promise<Attachment>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ApiVersion } from '../types/api-version.js';
|
|
2
|
+
import type { CustomFetch, CustomHeaders } from '../types/http.js';
|
|
3
|
+
export type ClientConfig = {
|
|
4
|
+
/** API token for authentication */
|
|
5
|
+
apiToken: string;
|
|
6
|
+
/** Optional custom base URL. If not provided, uses the default Comms API URL */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/** Optional API version. Defaults to 'v1.0' */
|
|
9
|
+
version?: ApiVersion;
|
|
10
|
+
/** Optional custom fetch implementation for cross-platform compatibility */
|
|
11
|
+
customFetch?: CustomFetch;
|
|
12
|
+
/** Optional headers sent with every request, or a function called once per request */
|
|
13
|
+
headers?: CustomHeaders;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Base class for every Comms API client. Centralizes URL handling and
|
|
17
|
+
* config so individual clients stay focused on their endpoints.
|
|
18
|
+
*/
|
|
19
|
+
export declare class BaseClient {
|
|
20
|
+
protected readonly apiToken: string;
|
|
21
|
+
protected readonly baseUrl?: string;
|
|
22
|
+
protected readonly defaultVersion: ApiVersion;
|
|
23
|
+
protected readonly customFetch?: CustomFetch;
|
|
24
|
+
protected readonly headers?: CustomHeaders;
|
|
25
|
+
constructor(config: ClientConfig);
|
|
26
|
+
/**
|
|
27
|
+
* Returns the base URI for an API request, with a guaranteed trailing
|
|
28
|
+
* slash so relative paths resolve cleanly through `URL`.
|
|
29
|
+
*/
|
|
30
|
+
protected getBaseUri(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Base URL for entity web links, or `undefined` to use getFullCommsURL's
|
|
33
|
+
* default web app. Trailing-slash normalization happens in
|
|
34
|
+
* `getFullCommsURL`, so the configured value is returned verbatim.
|
|
35
|
+
*/
|
|
36
|
+
protected getLinkBaseUrl(): string | undefined;
|
|
37
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type Channel, type StatusOk } from '../types/entities.js';
|
|
3
|
+
import type { AddChannelUserArgs, AddChannelUsersArgs, CreateChannelArgs, GetChannelsArgs, RemoveChannelUserArgs, RemoveChannelUsersArgs, UpdateChannelArgs } from '../types/requests.js';
|
|
4
|
+
import { BaseClient } from './base-client.js';
|
|
5
|
+
export declare const ChannelListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
9
|
+
creator: z.ZodNumber;
|
|
10
|
+
userIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
|
|
11
|
+
color: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
12
|
+
public: z.ZodBoolean;
|
|
13
|
+
workspaceId: z.ZodNumber;
|
|
14
|
+
archived: z.ZodBoolean;
|
|
15
|
+
created: z.ZodDate;
|
|
16
|
+
useDefaultRecipients: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
17
|
+
defaultGroups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
18
|
+
defaultRecipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
|
|
19
|
+
isFavorited: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
20
|
+
icon: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
21
|
+
version: z.ZodNumber;
|
|
22
|
+
filters: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
23
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
24
|
+
url: string;
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
creator: number;
|
|
28
|
+
public: boolean;
|
|
29
|
+
workspaceId: number;
|
|
30
|
+
archived: boolean;
|
|
31
|
+
created: Date;
|
|
32
|
+
version: number;
|
|
33
|
+
description?: string | null | undefined;
|
|
34
|
+
userIds?: number[] | null | undefined;
|
|
35
|
+
color?: number | null | undefined;
|
|
36
|
+
useDefaultRecipients?: boolean | null | undefined;
|
|
37
|
+
defaultGroups?: string[] | null | undefined;
|
|
38
|
+
defaultRecipients?: number[] | null | undefined;
|
|
39
|
+
isFavorited?: boolean | null | undefined;
|
|
40
|
+
icon?: number | null | undefined;
|
|
41
|
+
filters?: Record<string, string> | null | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
creator: number;
|
|
46
|
+
public: boolean;
|
|
47
|
+
workspaceId: number;
|
|
48
|
+
archived: boolean;
|
|
49
|
+
created: Date;
|
|
50
|
+
version: number;
|
|
51
|
+
description?: string | null | undefined;
|
|
52
|
+
userIds?: number[] | null | undefined;
|
|
53
|
+
color?: number | null | undefined;
|
|
54
|
+
useDefaultRecipients?: boolean | null | undefined;
|
|
55
|
+
defaultGroups?: string[] | null | undefined;
|
|
56
|
+
defaultRecipients?: number[] | null | undefined;
|
|
57
|
+
isFavorited?: boolean | null | undefined;
|
|
58
|
+
icon?: number | null | undefined;
|
|
59
|
+
filters?: Record<string, string> | null | undefined;
|
|
60
|
+
}>>>;
|
|
61
|
+
/**
|
|
62
|
+
* Client for `/api/v1.0/channels/`. The SDK auto-generates an `id` on
|
|
63
|
+
* `createChannel` when the caller doesn't supply one — pass your own `id`
|
|
64
|
+
* to keep an optimistic-UI ID stable through the round-trip.
|
|
65
|
+
*/
|
|
66
|
+
export declare class ChannelsClient extends BaseClient {
|
|
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
|
+
*/
|
|
84
|
+
getChannels(args: GetChannelsArgs): Promise<Channel[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Gets a single channel object by id.
|
|
87
|
+
*
|
|
88
|
+
* @param id - The channel ID.
|
|
89
|
+
* @returns The channel object.
|
|
90
|
+
*/
|
|
91
|
+
getChannel(id: string): Promise<Channel>;
|
|
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
|
+
*/
|
|
114
|
+
createChannel(args: CreateChannelArgs): Promise<Channel>;
|
|
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
|
+
*/
|
|
126
|
+
updateChannel(args: UpdateChannelArgs): Promise<Channel>;
|
|
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
|
+
*/
|
|
134
|
+
updateFilters(args: {
|
|
135
|
+
id: string;
|
|
136
|
+
filterClosed: 'only_open' | 'all' | 'only_closed';
|
|
137
|
+
}): Promise<StatusOk>;
|
|
138
|
+
/**
|
|
139
|
+
* Permanently deletes a channel.
|
|
140
|
+
*
|
|
141
|
+
* @param id - The channel ID.
|
|
142
|
+
*/
|
|
143
|
+
deleteChannel(id: string): Promise<StatusOk>;
|
|
144
|
+
/**
|
|
145
|
+
* Archives a channel.
|
|
146
|
+
*
|
|
147
|
+
* @param id - The channel ID.
|
|
148
|
+
*/
|
|
149
|
+
archiveChannel(id: string): Promise<StatusOk>;
|
|
150
|
+
/**
|
|
151
|
+
* Unarchives a channel.
|
|
152
|
+
*
|
|
153
|
+
* @param id - The channel ID.
|
|
154
|
+
*/
|
|
155
|
+
unarchiveChannel(id: string): Promise<StatusOk>;
|
|
156
|
+
/**
|
|
157
|
+
* Favorites a channel.
|
|
158
|
+
*
|
|
159
|
+
* @param id - The channel ID.
|
|
160
|
+
*/
|
|
161
|
+
favoriteChannel(id: string): Promise<StatusOk>;
|
|
162
|
+
/**
|
|
163
|
+
* Unfavorites a channel.
|
|
164
|
+
*
|
|
165
|
+
* @param id - The channel ID.
|
|
166
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
209
|
+
removeUsers(args: RemoveChannelUsersArgs): Promise<Channel>;
|
|
210
|
+
private simple;
|
|
211
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type Comment, type StatusOk } from '../types/entities.js';
|
|
3
|
+
import type { CreateCommentArgs, GetCommentsArgs, MarkCommentPositionArgs, UpdateCommentArgs } from '../types/requests.js';
|
|
4
|
+
import { BaseClient } from './base-client.js';
|
|
5
|
+
export declare const CommentListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
content: z.ZodString;
|
|
8
|
+
creator: z.ZodNumber;
|
|
9
|
+
threadId: z.ZodString;
|
|
10
|
+
workspaceId: z.ZodNumber;
|
|
11
|
+
conversationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
12
|
+
posted: z.ZodDate;
|
|
13
|
+
lastEdited: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
14
|
+
directMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
|
|
15
|
+
directGroupMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
16
|
+
systemMessage: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>>>;
|
|
17
|
+
attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
18
|
+
attachmentId: z.ZodString;
|
|
19
|
+
urlType: z.ZodString;
|
|
20
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
21
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
22
|
+
fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
23
|
+
fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
24
|
+
underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
25
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
26
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
+
imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
28
|
+
imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
29
|
+
duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
|
+
video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
|
+
videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
34
|
+
}, z.core.$loose>>>>;
|
|
35
|
+
reactions: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
36
|
+
objIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
37
|
+
creatorName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
38
|
+
channelId: z.ZodString;
|
|
39
|
+
recipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
|
|
40
|
+
groups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
41
|
+
toEmails: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
42
|
+
deleted: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
43
|
+
deletedBy: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
44
|
+
version: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
45
|
+
actions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnknown>>>;
|
|
46
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
47
|
+
url: string;
|
|
48
|
+
id: string;
|
|
49
|
+
content: string;
|
|
50
|
+
creator: number;
|
|
51
|
+
threadId: string;
|
|
52
|
+
workspaceId: number;
|
|
53
|
+
posted: Date;
|
|
54
|
+
channelId: string;
|
|
55
|
+
conversationId?: string | null | undefined;
|
|
56
|
+
lastEdited?: Date | null | undefined;
|
|
57
|
+
directMentions?: number[] | null | undefined;
|
|
58
|
+
directGroupMentions?: string[] | null | undefined;
|
|
59
|
+
systemMessage?: unknown;
|
|
60
|
+
attachments?: {
|
|
61
|
+
[x: string]: unknown;
|
|
62
|
+
attachmentId: string;
|
|
63
|
+
urlType: string;
|
|
64
|
+
title?: string | null | undefined;
|
|
65
|
+
url?: string | null | undefined;
|
|
66
|
+
fileName?: string | null | undefined;
|
|
67
|
+
fileSize?: number | null | undefined;
|
|
68
|
+
underlyingType?: string | null | undefined;
|
|
69
|
+
description?: string | null | undefined;
|
|
70
|
+
image?: string | null | undefined;
|
|
71
|
+
imageWidth?: number | null | undefined;
|
|
72
|
+
imageHeight?: number | null | undefined;
|
|
73
|
+
duration?: string | null | undefined;
|
|
74
|
+
uploadState?: string | null | undefined;
|
|
75
|
+
video?: string | null | undefined;
|
|
76
|
+
videoType?: string | null | undefined;
|
|
77
|
+
videoAutoPlay?: boolean | null | undefined;
|
|
78
|
+
}[] | null | undefined;
|
|
79
|
+
reactions?: Record<string, unknown> | null | undefined;
|
|
80
|
+
objIndex?: number | null | undefined;
|
|
81
|
+
creatorName?: string | null | undefined;
|
|
82
|
+
recipients?: number[] | null | undefined;
|
|
83
|
+
groups?: string[] | null | undefined;
|
|
84
|
+
toEmails?: string[] | null | undefined;
|
|
85
|
+
deleted?: boolean | null | undefined;
|
|
86
|
+
deletedBy?: number | null | undefined;
|
|
87
|
+
version?: number | null | undefined;
|
|
88
|
+
actions?: unknown[] | null | undefined;
|
|
89
|
+
}, {
|
|
90
|
+
id: string;
|
|
91
|
+
content: string;
|
|
92
|
+
creator: number;
|
|
93
|
+
threadId: string;
|
|
94
|
+
workspaceId: number;
|
|
95
|
+
posted: Date;
|
|
96
|
+
channelId: string;
|
|
97
|
+
conversationId?: string | null | undefined;
|
|
98
|
+
lastEdited?: Date | null | undefined;
|
|
99
|
+
directMentions?: number[] | null | undefined;
|
|
100
|
+
directGroupMentions?: string[] | null | undefined;
|
|
101
|
+
systemMessage?: unknown;
|
|
102
|
+
attachments?: {
|
|
103
|
+
[x: string]: unknown;
|
|
104
|
+
attachmentId: string;
|
|
105
|
+
urlType: string;
|
|
106
|
+
title?: string | null | undefined;
|
|
107
|
+
url?: string | null | undefined;
|
|
108
|
+
fileName?: string | null | undefined;
|
|
109
|
+
fileSize?: number | null | undefined;
|
|
110
|
+
underlyingType?: string | null | undefined;
|
|
111
|
+
description?: string | null | undefined;
|
|
112
|
+
image?: string | null | undefined;
|
|
113
|
+
imageWidth?: number | null | undefined;
|
|
114
|
+
imageHeight?: number | null | undefined;
|
|
115
|
+
duration?: string | null | undefined;
|
|
116
|
+
uploadState?: string | null | undefined;
|
|
117
|
+
video?: string | null | undefined;
|
|
118
|
+
videoType?: string | null | undefined;
|
|
119
|
+
videoAutoPlay?: boolean | null | undefined;
|
|
120
|
+
}[] | null | undefined;
|
|
121
|
+
reactions?: Record<string, unknown> | null | undefined;
|
|
122
|
+
objIndex?: number | null | undefined;
|
|
123
|
+
creatorName?: string | null | undefined;
|
|
124
|
+
recipients?: number[] | null | undefined;
|
|
125
|
+
groups?: string[] | null | undefined;
|
|
126
|
+
toEmails?: string[] | null | undefined;
|
|
127
|
+
deleted?: boolean | null | undefined;
|
|
128
|
+
deletedBy?: number | null | undefined;
|
|
129
|
+
version?: number | null | undefined;
|
|
130
|
+
actions?: unknown[] | null | undefined;
|
|
131
|
+
}>>>;
|
|
132
|
+
/**
|
|
133
|
+
* Client for `/api/v1.0/comments/`. The SDK auto-generates the comment `id`
|
|
134
|
+
* on `createComment` when the caller doesn't supply one.
|
|
135
|
+
*/
|
|
136
|
+
export declare class CommentsClient extends BaseClient {
|
|
137
|
+
private readonly linkBaseUrl;
|
|
138
|
+
private readonly commentSchema;
|
|
139
|
+
private readonly commentListSchema;
|
|
140
|
+
/**
|
|
141
|
+
* Gets all comments for a thread. `newerThan` / `olderThan` (`Date`) are
|
|
142
|
+
* converted to `newer_than_ts` / `older_than_ts` epoch seconds on the
|
|
143
|
+
* wire.
|
|
144
|
+
*
|
|
145
|
+
* @param args - The arguments for getting comments.
|
|
146
|
+
* @param args.threadId - The thread ID.
|
|
147
|
+
* @param args.newerThan - Optional date to get comments newer than.
|
|
148
|
+
* @param args.olderThan - Optional date to get comments older than.
|
|
149
|
+
* @param args.limit - Optional limit on number of comments returned.
|
|
150
|
+
* @returns An array of comment objects.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const comments = await api.comments.getComments({
|
|
155
|
+
* threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
|
|
156
|
+
* newerThan: new Date('2024-01-01'),
|
|
157
|
+
* })
|
|
158
|
+
* comments.forEach(c => console.log(c.content))
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
getComments(args: GetCommentsArgs): Promise<Comment[]>;
|
|
162
|
+
/**
|
|
163
|
+
* Gets a single comment object by id. The `getone` endpoint returns the
|
|
164
|
+
* comment object directly (the same shape as `add`), not wrapped.
|
|
165
|
+
*
|
|
166
|
+
* @param id - The comment ID.
|
|
167
|
+
* @returns The comment object.
|
|
168
|
+
*/
|
|
169
|
+
getComment(id: string): Promise<Comment>;
|
|
170
|
+
/**
|
|
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
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
createComment(args: CreateCommentArgs): Promise<Comment>;
|
|
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
|
+
*/
|
|
206
|
+
updateComment(args: UpdateCommentArgs): Promise<Comment>;
|
|
207
|
+
/**
|
|
208
|
+
* Permanently deletes a comment.
|
|
209
|
+
*
|
|
210
|
+
* @param id - The comment ID.
|
|
211
|
+
*/
|
|
212
|
+
deleteComment(id: string): Promise<StatusOk>;
|
|
213
|
+
/**
|
|
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
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
markPosition(args: MarkCommentPositionArgs): Promise<StatusOk>;
|
|
228
|
+
}
|