@doist/comms-sdk 0.0.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.
Files changed (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +143 -45
  3. package/dist/cjs/authentication.js +211 -0
  4. package/dist/cjs/clients/add-comment-helper.js +70 -0
  5. package/dist/cjs/clients/base-client.js +25 -0
  6. package/dist/cjs/clients/channels-client.js +200 -0
  7. package/dist/cjs/clients/comments-client.js +159 -0
  8. package/dist/cjs/clients/conversation-messages-client.js +158 -0
  9. package/dist/cjs/clients/conversations-client.js +243 -0
  10. package/dist/cjs/clients/groups-client.js +164 -0
  11. package/dist/cjs/clients/inbox-client.js +171 -0
  12. package/dist/cjs/clients/reactions-client.js +97 -0
  13. package/dist/cjs/clients/search-client.js +138 -0
  14. package/dist/cjs/clients/threads-client.js +330 -0
  15. package/dist/cjs/clients/users-client.js +326 -0
  16. package/dist/cjs/clients/workspace-users-client.js +240 -0
  17. package/dist/cjs/clients/workspaces-client.js +166 -0
  18. package/dist/cjs/comms-api.js +66 -0
  19. package/dist/cjs/consts/endpoints.js +32 -0
  20. package/dist/cjs/index.js +48 -0
  21. package/dist/cjs/package.json +1 -0
  22. package/dist/cjs/testUtils/msw-handlers.js +51 -0
  23. package/dist/cjs/testUtils/msw-setup.js +21 -0
  24. package/dist/cjs/testUtils/obsidian-fetch-adapter.js +53 -0
  25. package/dist/cjs/testUtils/test-defaults.js +104 -0
  26. package/dist/cjs/transport/fetch-with-retry.js +136 -0
  27. package/dist/cjs/transport/http-client.js +56 -0
  28. package/dist/cjs/transport/http-dispatcher.js +143 -0
  29. package/dist/cjs/types/api-version.js +8 -0
  30. package/dist/cjs/types/entities.js +411 -0
  31. package/dist/cjs/types/enums.js +37 -0
  32. package/dist/cjs/types/errors.js +12 -0
  33. package/dist/cjs/types/http.js +4 -0
  34. package/dist/cjs/types/index.js +22 -0
  35. package/dist/cjs/types/requests.js +116 -0
  36. package/dist/cjs/utils/case-conversion.js +54 -0
  37. package/dist/cjs/utils/index.js +19 -0
  38. package/dist/cjs/utils/timestamp-conversion.js +49 -0
  39. package/dist/cjs/utils/url-helpers.js +131 -0
  40. package/dist/cjs/utils/uuidv7.js +174 -0
  41. package/dist/esm/authentication.js +203 -0
  42. package/dist/esm/clients/add-comment-helper.js +67 -0
  43. package/dist/esm/clients/base-client.js +21 -0
  44. package/dist/esm/clients/channels-client.js +196 -0
  45. package/dist/esm/clients/comments-client.js +155 -0
  46. package/dist/esm/clients/conversation-messages-client.js +154 -0
  47. package/dist/esm/clients/conversations-client.js +239 -0
  48. package/dist/esm/clients/groups-client.js +160 -0
  49. package/dist/esm/clients/inbox-client.js +167 -0
  50. package/dist/esm/clients/reactions-client.js +93 -0
  51. package/dist/esm/clients/search-client.js +134 -0
  52. package/dist/esm/clients/threads-client.js +326 -0
  53. package/dist/esm/clients/users-client.js +322 -0
  54. package/dist/esm/clients/workspace-users-client.js +236 -0
  55. package/dist/esm/clients/workspaces-client.js +162 -0
  56. package/dist/esm/comms-api.js +62 -0
  57. package/dist/esm/consts/endpoints.js +28 -0
  58. package/dist/esm/index.js +17 -0
  59. package/dist/esm/testUtils/msw-handlers.js +45 -0
  60. package/dist/esm/testUtils/msw-setup.js +18 -0
  61. package/dist/esm/testUtils/obsidian-fetch-adapter.js +50 -0
  62. package/dist/esm/testUtils/test-defaults.js +101 -0
  63. package/dist/esm/transport/fetch-with-retry.js +133 -0
  64. package/dist/esm/transport/http-client.js +51 -0
  65. package/dist/esm/transport/http-dispatcher.js +104 -0
  66. package/dist/esm/types/api-version.js +5 -0
  67. package/dist/esm/types/entities.js +408 -0
  68. package/dist/esm/types/enums.js +34 -0
  69. package/dist/esm/types/errors.js +8 -0
  70. package/dist/esm/types/http.js +1 -0
  71. package/dist/esm/types/index.js +6 -0
  72. package/dist/esm/types/requests.js +113 -0
  73. package/dist/esm/utils/case-conversion.js +47 -0
  74. package/dist/esm/utils/index.js +3 -0
  75. package/dist/esm/utils/timestamp-conversion.js +45 -0
  76. package/dist/esm/utils/url-helpers.js +112 -0
  77. package/dist/esm/utils/uuidv7.js +163 -0
  78. package/dist/types/authentication.d.ts +160 -0
  79. package/dist/types/clients/add-comment-helper.d.ts +29 -0
  80. package/dist/types/clients/base-client.d.ts +28 -0
  81. package/dist/types/clients/channels-client.d.ts +208 -0
  82. package/dist/types/clients/comments-client.d.ts +224 -0
  83. package/dist/types/clients/conversation-messages-client.d.ts +198 -0
  84. package/dist/types/clients/conversations-client.d.ts +346 -0
  85. package/dist/types/clients/groups-client.d.ts +148 -0
  86. package/dist/types/clients/inbox-client.d.ts +96 -0
  87. package/dist/types/clients/reactions-client.d.ts +57 -0
  88. package/dist/types/clients/search-client.d.ts +70 -0
  89. package/dist/types/clients/threads-client.d.ts +536 -0
  90. package/dist/types/clients/users-client.d.ts +250 -0
  91. package/dist/types/clients/workspace-users-client.d.ts +147 -0
  92. package/dist/types/clients/workspaces-client.d.ts +152 -0
  93. package/dist/types/comms-api.d.ts +62 -0
  94. package/dist/types/consts/endpoints.d.ts +24 -0
  95. package/dist/types/index.d.ts +18 -0
  96. package/dist/types/testUtils/msw-handlers.d.ts +28 -0
  97. package/dist/types/testUtils/msw-setup.d.ts +1 -0
  98. package/dist/types/testUtils/obsidian-fetch-adapter.d.ts +29 -0
  99. package/dist/types/testUtils/test-defaults.d.ts +17 -0
  100. package/dist/types/transport/fetch-with-retry.d.ts +4 -0
  101. package/dist/types/transport/http-client.d.ts +13 -0
  102. package/dist/types/transport/http-dispatcher.d.ts +10 -0
  103. package/dist/types/types/api-version.d.ts +6 -0
  104. package/dist/types/types/entities.d.ts +1288 -0
  105. package/dist/types/types/enums.d.ts +55 -0
  106. package/dist/types/types/errors.d.ts +6 -0
  107. package/dist/types/types/http.d.ts +54 -0
  108. package/dist/types/types/index.d.ts +6 -0
  109. package/dist/types/types/requests.d.ts +366 -0
  110. package/dist/types/utils/case-conversion.d.ts +8 -0
  111. package/dist/types/utils/index.d.ts +3 -0
  112. package/dist/types/utils/timestamp-conversion.d.ts +13 -0
  113. package/dist/types/utils/url-helpers.d.ts +88 -0
  114. package/dist/types/utils/uuidv7.d.ts +40 -0
  115. package/package.json +91 -8
@@ -0,0 +1,208 @@
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/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
+ /**
68
+ * Gets all channels for a given workspace.
69
+ *
70
+ * @param args - The arguments for getting channels.
71
+ * @param args.workspaceId - The workspace ID.
72
+ * @param args.archived - Optional flag to include archived channels.
73
+ * @returns An array of channel objects.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const channels = await api.channels.getChannels({ workspaceId: 123 })
78
+ * channels.forEach(ch => console.log(ch.name))
79
+ * ```
80
+ */
81
+ getChannels(args: GetChannelsArgs): Promise<Channel[]>;
82
+ /**
83
+ * Gets a single channel object by id.
84
+ *
85
+ * @param id - The channel ID.
86
+ * @returns The channel object.
87
+ */
88
+ getChannel(id: string): Promise<Channel>;
89
+ /**
90
+ * Creates a new channel. `id` is auto-generated if not supplied — pass your
91
+ * own `id` to keep an optimistic-UI ID stable through the round-trip.
92
+ *
93
+ * @param args - The arguments for creating a channel.
94
+ * @param args.workspaceId - The workspace ID.
95
+ * @param args.name - The channel name.
96
+ * @param args.description - Optional channel description.
97
+ * @param args.color - Optional channel color.
98
+ * @param args.userIds - Optional array of user IDs to add to the channel.
99
+ * @param args.public - Optional flag to make the channel public.
100
+ * @returns The created channel object.
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const channel = await api.channels.createChannel({
105
+ * workspaceId: 123,
106
+ * name: 'Engineering',
107
+ * description: 'Engineering team channel',
108
+ * })
109
+ * ```
110
+ */
111
+ createChannel(args: CreateChannelArgs): Promise<Channel>;
112
+ /**
113
+ * Partial update of an existing channel.
114
+ *
115
+ * @param args - The arguments for updating a channel.
116
+ * @param args.id - The channel ID.
117
+ * @param args.name - Optional new channel name.
118
+ * @param args.description - Optional new channel description.
119
+ * @param args.color - Optional new channel color.
120
+ * @param args.public - Optional flag to change channel visibility.
121
+ * @returns The updated channel object.
122
+ */
123
+ updateChannel(args: UpdateChannelArgs): Promise<Channel>;
124
+ /**
125
+ * Updates the channel's view filter (`only_open` / `all` / `only_closed`).
126
+ *
127
+ * @param args - The arguments for updating the channel filter.
128
+ * @param args.id - The channel ID.
129
+ * @param args.filterClosed - The new filter value.
130
+ */
131
+ updateFilters(args: {
132
+ id: string;
133
+ filterClosed: 'only_open' | 'all' | 'only_closed';
134
+ }): Promise<StatusOk>;
135
+ /**
136
+ * Permanently deletes a channel.
137
+ *
138
+ * @param id - The channel ID.
139
+ */
140
+ deleteChannel(id: string): Promise<StatusOk>;
141
+ /**
142
+ * Archives a channel.
143
+ *
144
+ * @param id - The channel ID.
145
+ */
146
+ archiveChannel(id: string): Promise<StatusOk>;
147
+ /**
148
+ * Unarchives a channel.
149
+ *
150
+ * @param id - The channel ID.
151
+ */
152
+ unarchiveChannel(id: string): Promise<StatusOk>;
153
+ /**
154
+ * Favorites a channel.
155
+ *
156
+ * @param id - The channel ID.
157
+ */
158
+ favoriteChannel(id: string): Promise<StatusOk>;
159
+ /**
160
+ * Unfavorites a channel.
161
+ *
162
+ * @param id - The channel ID.
163
+ */
164
+ unfavoriteChannel(id: string): Promise<StatusOk>;
165
+ /**
166
+ * Adds a user to a channel.
167
+ *
168
+ * @param args - The arguments for adding a user.
169
+ * @param args.id - The channel ID.
170
+ * @param args.userId - The user ID to add.
171
+ *
172
+ * @example
173
+ * ```typescript
174
+ * await api.channels.addUser({ id: '7YpL3oZ4kZ9vP7Q1tR2sX44', userId: 101 })
175
+ * ```
176
+ */
177
+ addUser(args: AddChannelUserArgs): Promise<Channel>;
178
+ /**
179
+ * Adds multiple users to a channel.
180
+ *
181
+ * @param args - The arguments for adding users.
182
+ * @param args.id - The channel ID.
183
+ * @param args.userIds - Array of user IDs to add.
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * await api.channels.addUsers({ id: '7YpL3oZ4kZ9vP7Q1tR2sX44', userIds: [101, 202] })
188
+ * ```
189
+ */
190
+ addUsers(args: AddChannelUsersArgs): Promise<Channel>;
191
+ /**
192
+ * Removes a user from a channel.
193
+ *
194
+ * @param args - The arguments for removing a user.
195
+ * @param args.id - The channel ID.
196
+ * @param args.userId - The user ID to remove.
197
+ */
198
+ removeUser(args: RemoveChannelUserArgs): Promise<Channel>;
199
+ /**
200
+ * Removes multiple users from a channel.
201
+ *
202
+ * @param args - The arguments for removing users.
203
+ * @param args.id - The channel ID.
204
+ * @param args.userIds - Array of user IDs to remove.
205
+ */
206
+ removeUsers(args: RemoveChannelUsersArgs): Promise<Channel>;
207
+ private simple;
208
+ }
@@ -0,0 +1,224 @@
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/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
+ /**
138
+ * Gets all comments for a thread. `newerThan` / `olderThan` (`Date`) are
139
+ * converted to `newer_than_ts` / `older_than_ts` epoch seconds on the
140
+ * wire.
141
+ *
142
+ * @param args - The arguments for getting comments.
143
+ * @param args.threadId - The thread ID.
144
+ * @param args.newerThan - Optional date to get comments newer than.
145
+ * @param args.olderThan - Optional date to get comments older than.
146
+ * @param args.limit - Optional limit on number of comments returned.
147
+ * @returns An array of comment objects.
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * const comments = await api.comments.getComments({
152
+ * threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
153
+ * newerThan: new Date('2024-01-01'),
154
+ * })
155
+ * comments.forEach(c => console.log(c.content))
156
+ * ```
157
+ */
158
+ getComments(args: GetCommentsArgs): Promise<Comment[]>;
159
+ /**
160
+ * Gets a single comment object by id. The API wraps it in `{comment: ...}`.
161
+ *
162
+ * @param id - The comment ID.
163
+ * @returns The comment object.
164
+ */
165
+ getComment(id: string): Promise<Comment>;
166
+ /**
167
+ * Creates a new comment on a thread. `id` is auto-generated if not supplied.
168
+ *
169
+ * @param args - The arguments for creating a comment.
170
+ * @param args.threadId - The thread ID.
171
+ * @param args.content - The comment content.
172
+ * @param args.recipients - Optional array of user IDs to notify directly.
173
+ * @param args.groups - Optional array of custom group IDs to notify.
174
+ * @param args.directMentions - Optional array of user IDs that were @-mentioned in
175
+ * `content`.
176
+ * @param args.notifyAudience - Optional broader audience to notify in addition to
177
+ * `recipients` and `groups`. `'channel'` notifies everyone in the channel;
178
+ * `'thread'` notifies everyone who has interacted with the thread.
179
+ * @param args.attachments - Optional array of {@link Attachment} objects.
180
+ * @returns The created comment object.
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * // Notify everyone who has interacted with the thread, plus two extra users.
185
+ * const comment = await api.comments.createComment({
186
+ * threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
187
+ * content: 'Great idea! Let\'s proceed.',
188
+ * notifyAudience: 'thread',
189
+ * recipients: [101, 202],
190
+ * })
191
+ * ```
192
+ */
193
+ createComment(args: CreateCommentArgs): Promise<Comment>;
194
+ /**
195
+ * Updates a comment's properties.
196
+ *
197
+ * @param args - The arguments for updating a comment.
198
+ * @param args.id - The comment ID.
199
+ * @param args.content - The new comment content.
200
+ * @returns The updated comment object.
201
+ */
202
+ updateComment(args: UpdateCommentArgs): Promise<Comment>;
203
+ /**
204
+ * Permanently deletes a comment.
205
+ *
206
+ * @param id - The comment ID.
207
+ */
208
+ deleteComment(id: string): Promise<StatusOk>;
209
+ /**
210
+ * Marks the user's read position in a thread. Used to track where the user has read up to,
211
+ * so clients can scroll to this position and show a visual indicator (blue line).
212
+ * Comment IDs are strings.
213
+ *
214
+ * @param args - The arguments for marking read position.
215
+ * @param args.threadId - The thread ID.
216
+ * @param args.commentId - The comment ID to mark as the last read position.
217
+ *
218
+ * @example
219
+ * ```typescript
220
+ * await api.comments.markPosition({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', commentId: '7YpL3oZ4kZ9vP7Q1tR2sX41' })
221
+ * ```
222
+ */
223
+ markPosition(args: MarkCommentPositionArgs): Promise<StatusOk>;
224
+ }
@@ -0,0 +1,198 @@
1
+ import { z } from 'zod';
2
+ import { type ConversationMessage, type StatusOk } from '../types/entities.js';
3
+ import type { CreateConversationMessageArgs, GetConversationMessagesArgs, UpdateConversationMessageArgs } from '../types/requests.js';
4
+ import { BaseClient } from './base-client.js';
5
+ export declare const ConversationMessageListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
6
+ id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
7
+ content: z.ZodString;
8
+ creator: z.ZodNumber;
9
+ conversationId: z.ZodString;
10
+ posted: z.ZodDate;
11
+ systemMessage: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>>>;
12
+ attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
13
+ attachmentId: z.ZodString;
14
+ urlType: z.ZodString;
15
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
16
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
+ fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
18
+ fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
19
+ underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
21
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
+ imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
23
+ imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
24
+ duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
+ uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
+ video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
+ videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
29
+ }, z.core.$loose>>>>;
30
+ reactions: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodNumber>>>>;
31
+ actions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnknown>>>;
32
+ objIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
33
+ lastEdited: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
34
+ isDeleted: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
35
+ directGroupMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
36
+ directMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
37
+ version: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
38
+ workspaceId: z.ZodNumber;
39
+ }, z.core.$strip>, z.ZodTransform<{
40
+ url: string;
41
+ id: string;
42
+ content: string;
43
+ creator: number;
44
+ conversationId: string;
45
+ posted: Date;
46
+ workspaceId: number;
47
+ systemMessage?: unknown;
48
+ attachments?: {
49
+ [x: string]: unknown;
50
+ attachmentId: string;
51
+ urlType: string;
52
+ title?: string | null | undefined;
53
+ url?: string | null | undefined;
54
+ fileName?: string | null | undefined;
55
+ fileSize?: number | null | undefined;
56
+ underlyingType?: string | null | undefined;
57
+ description?: string | null | undefined;
58
+ image?: string | null | undefined;
59
+ imageWidth?: number | null | undefined;
60
+ imageHeight?: number | null | undefined;
61
+ duration?: string | null | undefined;
62
+ uploadState?: string | null | undefined;
63
+ video?: string | null | undefined;
64
+ videoType?: string | null | undefined;
65
+ videoAutoPlay?: boolean | null | undefined;
66
+ }[] | null | undefined;
67
+ reactions?: Record<string, number[]> | null | undefined;
68
+ actions?: unknown[] | null | undefined;
69
+ objIndex?: number | null | undefined;
70
+ lastEdited?: Date | null | undefined;
71
+ isDeleted?: boolean | null | undefined;
72
+ directGroupMentions?: string[] | null | undefined;
73
+ directMentions?: number[] | null | undefined;
74
+ version?: number | null | undefined;
75
+ }, {
76
+ id: string;
77
+ content: string;
78
+ creator: number;
79
+ conversationId: string;
80
+ posted: Date;
81
+ workspaceId: number;
82
+ systemMessage?: unknown;
83
+ attachments?: {
84
+ [x: string]: unknown;
85
+ attachmentId: string;
86
+ urlType: string;
87
+ title?: string | null | undefined;
88
+ url?: string | null | undefined;
89
+ fileName?: string | null | undefined;
90
+ fileSize?: number | null | undefined;
91
+ underlyingType?: string | null | undefined;
92
+ description?: string | null | undefined;
93
+ image?: string | null | undefined;
94
+ imageWidth?: number | null | undefined;
95
+ imageHeight?: number | null | undefined;
96
+ duration?: string | null | undefined;
97
+ uploadState?: string | null | undefined;
98
+ video?: string | null | undefined;
99
+ videoType?: string | null | undefined;
100
+ videoAutoPlay?: boolean | null | undefined;
101
+ }[] | null | undefined;
102
+ reactions?: Record<string, number[]> | null | undefined;
103
+ actions?: unknown[] | null | undefined;
104
+ objIndex?: number | null | undefined;
105
+ lastEdited?: Date | null | undefined;
106
+ isDeleted?: boolean | null | undefined;
107
+ directGroupMentions?: string[] | null | undefined;
108
+ directMentions?: number[] | null | undefined;
109
+ version?: number | null | undefined;
110
+ }>>>;
111
+ /**
112
+ * Client for `/api/v1/conversation_messages/`. The SDK auto-generates the
113
+ * message `id` on `createMessage` when the caller doesn't supply one.
114
+ */
115
+ export declare class ConversationMessagesClient extends BaseClient {
116
+ /**
117
+ * Gets all messages in a conversation.
118
+ *
119
+ * @param args - The arguments for getting messages.
120
+ * @param args.conversationId - The conversation ID.
121
+ * @param args.newerThan - Optional date to get messages newer than.
122
+ * @param args.olderThan - Optional date to get messages older than.
123
+ * @param args.limit - Optional limit on number of messages returned.
124
+ * @param args.cursor - Optional cursor for pagination.
125
+ * @returns An array of message objects.
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * const messages = await api.conversationMessages.getMessages({
130
+ * conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
131
+ * newerThan: new Date('2024-01-01'),
132
+ * })
133
+ * ```
134
+ */
135
+ getMessages(args: GetConversationMessagesArgs): Promise<ConversationMessage[]>;
136
+ /**
137
+ * Gets a single conversation message by id.
138
+ *
139
+ * @param id - The message ID.
140
+ * @returns The conversation message object.
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * const message = await api.conversationMessages.getMessage('7YpL3oZ4kZ9vP7Q1tR2sX43')
145
+ * ```
146
+ */
147
+ getMessage(id: string): Promise<ConversationMessage>;
148
+ /**
149
+ * Creates a new message in a conversation. `id` is auto-generated if not
150
+ * supplied.
151
+ *
152
+ * @param args - The arguments for creating a message.
153
+ * @param args.conversationId - The conversation ID.
154
+ * @param args.content - The message content.
155
+ * @param args.attachments - Optional array of {@link Attachment} objects.
156
+ * @param args.actions - Optional array of action objects.
157
+ * @returns The created message object.
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * const message = await api.conversationMessages.createMessage({
162
+ * conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
163
+ * content: 'Thanks for the update!',
164
+ * })
165
+ * ```
166
+ */
167
+ createMessage(args: CreateConversationMessageArgs): Promise<ConversationMessage>;
168
+ /**
169
+ * Updates a conversation message.
170
+ *
171
+ * @param args - The arguments for updating a message.
172
+ * @param args.id - The message ID.
173
+ * @param args.content - The new message content.
174
+ * @param args.attachments - Optional array of {@link Attachment} objects.
175
+ * @returns The updated message object.
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * const message = await api.conversationMessages.updateMessage({
180
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX43',
181
+ * content: 'Updated message content',
182
+ * })
183
+ * ```
184
+ */
185
+ updateMessage(args: UpdateConversationMessageArgs): Promise<ConversationMessage>;
186
+ /**
187
+ * Permanently deletes a conversation message.
188
+ *
189
+ * @param id - The message ID.
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * await api.conversationMessages.deleteMessage('7YpL3oZ4kZ9vP7Q1tR2sX43')
194
+ * ```
195
+ */
196
+ deleteMessage(id: string): Promise<StatusOk>;
197
+ private simple;
198
+ }