@doist/comms-sdk 2.0.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/esm/utils/multipart-upload.js +73 -15
  2. package/dist/esm/utils/url-helpers.js +104 -16
  3. package/dist/types/utils/multipart-upload.d.ts +3 -4
  4. package/dist/types/utils/url-helpers.d.ts +41 -0
  5. package/package.json +5 -10
  6. package/dist/cjs/authentication.js +0 -256
  7. package/dist/cjs/clients/add-comment-helper.js +0 -43
  8. package/dist/cjs/clients/attachments-client.js +0 -71
  9. package/dist/cjs/clients/base-client.js +0 -33
  10. package/dist/cjs/clients/channels-client.js +0 -211
  11. package/dist/cjs/clients/comments-client.js +0 -175
  12. package/dist/cjs/clients/conversation-messages-client.js +0 -169
  13. package/dist/cjs/clients/conversations-client.js +0 -283
  14. package/dist/cjs/clients/groups-client.js +0 -172
  15. package/dist/cjs/clients/hooks-client.js +0 -52
  16. package/dist/cjs/clients/inbox-client.js +0 -184
  17. package/dist/cjs/clients/notify-audience.js +0 -45
  18. package/dist/cjs/clients/reactions-client.js +0 -97
  19. package/dist/cjs/clients/search-client.js +0 -138
  20. package/dist/cjs/clients/threads-client.js +0 -364
  21. package/dist/cjs/clients/users-client.js +0 -326
  22. package/dist/cjs/clients/workspace-users-client.js +0 -252
  23. package/dist/cjs/clients/workspaces-client.js +0 -174
  24. package/dist/cjs/comms-api.js +0 -70
  25. package/dist/cjs/consts/endpoints.js +0 -34
  26. package/dist/cjs/index.js +0 -53
  27. package/dist/cjs/migration.js +0 -96
  28. package/dist/cjs/package.json +0 -1
  29. package/dist/cjs/testUtils/msw-handlers.js +0 -51
  30. package/dist/cjs/testUtils/msw-setup.js +0 -35
  31. package/dist/cjs/testUtils/obsidian-fetch-adapter.js +0 -53
  32. package/dist/cjs/testUtils/test-defaults.js +0 -106
  33. package/dist/cjs/transport/fetch-with-retry.js +0 -146
  34. package/dist/cjs/transport/http-client.js +0 -56
  35. package/dist/cjs/transport/http-dispatcher.js +0 -190
  36. package/dist/cjs/types/api-version.js +0 -8
  37. package/dist/cjs/types/entities.js +0 -496
  38. package/dist/cjs/types/enums.js +0 -37
  39. package/dist/cjs/types/errors.js +0 -12
  40. package/dist/cjs/types/http.js +0 -4
  41. package/dist/cjs/types/index.js +0 -22
  42. package/dist/cjs/types/requests.js +0 -183
  43. package/dist/cjs/utils/case-conversion.js +0 -54
  44. package/dist/cjs/utils/index.js +0 -19
  45. package/dist/cjs/utils/multipart-upload.js +0 -144
  46. package/dist/cjs/utils/timestamp-conversion.js +0 -58
  47. package/dist/cjs/utils/url-helpers.js +0 -133
  48. package/dist/cjs/utils/uuidv7.js +0 -182
@@ -1,496 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SearchResultSchema = exports.ConversationSearchResultSchema = exports.ThreadSearchResultSchema = exports.SEARCH_RESULT_TYPES = exports.UnreadConversationSchema = exports.UnreadThreadSchema = exports.InboxThreadSchema = exports.ConversationMessageSchema = exports.ConversationMessageObjectSchema = exports.VisibleWorkspaceUserSchema = exports.RestrictedWorkspaceUserSchema = exports.WorkspaceUserSchema = exports.CommentSchema = exports.CommentObjectSchema = exports.ConversationSchema = exports.ConversationObjectSchema = exports.GroupSchema = exports.ThreadSchema = exports.ThreadObjectSchema = exports.ChannelSchema = exports.ChannelObjectSchema = exports.WorkspaceSchema = exports.UserSchema = exports.BaseUserSchema = exports.RequestAttachmentSchema = exports.AttachmentSchema = exports.HookSubscribeResponseSchema = exports.StatusOkSchema = exports.SystemMessageSchema = void 0;
4
- exports.createChannelSchema = createChannelSchema;
5
- exports.createThreadSchema = createThreadSchema;
6
- exports.createConversationSchema = createConversationSchema;
7
- exports.createCommentSchema = createCommentSchema;
8
- exports.isRestrictedWorkspaceUser = isRestrictedWorkspaceUser;
9
- exports.createConversationMessageSchema = createConversationMessageSchema;
10
- exports.createInboxThreadObjectSchema = createInboxThreadObjectSchema;
11
- exports.createInboxThreadSchema = createInboxThreadSchema;
12
- const zod_1 = require("zod");
13
- const url_helpers_1 = require("../utils/url-helpers");
14
- const enums_1 = require("./enums");
15
- // EVERYONE / EVERYONE_IN_THREAD / GROUP_ID_MARKERS / GroupId / GroupIdMarker
16
- // are defined in `./enums` (re-exported through `./index`) to keep this
17
- // module from depending back on `./enums` for them. They're available
18
- // from the same public surface (`@doist/comms-sdk`) either way.
19
- // Reusable schema for system messages that can be either a string or an
20
- // object. Nullable — the backend returns `null` when there is no system
21
- // message.
22
- exports.SystemMessageSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.unknown()]).nullable().optional();
23
- /**
24
- * Shared `{ status: "ok" }` response shape. Pinned to the literal `'ok'`
25
- * so a regression on the backend (e.g. a status code change) surfaces as
26
- * a parse error here instead of being silently typed away. Most write
27
- * endpoints that don't return an entity use this — archive / unarchive /
28
- * mark-read / mark-all-read / mute / clear-unread / etc.
29
- */
30
- exports.StatusOkSchema = zod_1.z.object({ status: zod_1.z.literal('ok') });
31
- exports.HookSubscribeResponseSchema = exports.StatusOkSchema.extend({
32
- id: zod_1.z.number().int(),
33
- });
34
- // Attachment entity from API. Mirrors the canonical backend shape produced
35
- // by `unify_attachments` / `validate_file_attachment_json`. Only
36
- // `attachmentId` and `urlType` are guaranteed; everything else depends on
37
- // the attachment kind (file vs image vs link preview vs unfurled GIF).
38
- // Loose: unknown keys from the backend pass through rather than being
39
- // stripped, so newly-added or off-spec fields stay accessible to callers.
40
- const attachmentShape = {
41
- attachmentId: zod_1.z.string(),
42
- urlType: zod_1.z.string(),
43
- title: zod_1.z.string().nullable().optional(),
44
- url: zod_1.z.string().nullable().optional(),
45
- fileName: zod_1.z.string().nullable().optional(),
46
- fileSize: zod_1.z.number().int().nonnegative().nullable().optional(),
47
- underlyingType: zod_1.z.string().nullable().optional(),
48
- description: zod_1.z.string().nullable().optional(),
49
- image: zod_1.z.string().nullable().optional(),
50
- imageWidth: zod_1.z.number().int().nonnegative().nullable().optional(),
51
- imageHeight: zod_1.z.number().int().nonnegative().nullable().optional(),
52
- duration: zod_1.z.string().nullable().optional(),
53
- uploadState: zod_1.z.string().nullable().optional(),
54
- video: zod_1.z.string().nullable().optional(),
55
- videoType: zod_1.z.string().nullable().optional(),
56
- videoAutoPlay: zod_1.z.boolean().nullable().optional(),
57
- };
58
- exports.AttachmentSchema = zod_1.z.object(attachmentShape).loose();
59
- // Request-side attachment schema. Unlike the loose response `AttachmentSchema`,
60
- // this strips unknown keys so caller typos / off-spec fields are dropped instead
61
- // of being forwarded on the wire. Use this for `*Args` request schemas.
62
- exports.RequestAttachmentSchema = zod_1.z.object(attachmentShape);
63
- // Fields shared by `User` and `WorkspaceUser`. Profile fields
64
- // (`fullName`, `imageId`, avatar URLs) are sourced from Todoist-ID.
65
- exports.BaseUserSchema = zod_1.z.object({
66
- id: zod_1.z.number(),
67
- fullName: zod_1.z.string(),
68
- shortName: zod_1.z.string(),
69
- firstName: zod_1.z.string().nullable().optional(),
70
- timezone: zod_1.z.string(),
71
- removed: zod_1.z.boolean(),
72
- imageId: zod_1.z.string().nullable().optional(),
73
- avatarUrls: zod_1.z
74
- .object({
75
- s35: zod_1.z.string(),
76
- s60: zod_1.z.string(),
77
- s195: zod_1.z.string(),
78
- s640: zod_1.z.string(),
79
- })
80
- .nullable()
81
- .optional(),
82
- restricted: zod_1.z.boolean().nullable().optional(),
83
- setupPending: zod_1.z.boolean().nullable().optional(),
84
- });
85
- // User entity from API.
86
- exports.UserSchema = exports.BaseUserSchema.extend({
87
- email: zod_1.z.email(),
88
- clientId: zod_1.z.string().nullable().optional(),
89
- cometChannel: zod_1.z.string().nullable().optional(),
90
- lang: zod_1.z.string(),
91
- cometServer: zod_1.z.string().nullable().optional(),
92
- token: zod_1.z.string().nullable().optional(),
93
- scheduledBanners: zod_1.z.array(zod_1.z.string()).nullable().optional(),
94
- });
95
- // Workspace entity from API. `default_conversation` is a base58 UUIDv7
96
- // string. `avatar_id` is kept (unlike the User rename to `image_id`,
97
- // which is a User-only change per Comms_API_changes.md PR #125).
98
- // `plan` is intentionally `z.string()` — see {@link WORKSPACE_PLANS}.
99
- exports.WorkspaceSchema = zod_1.z.object({
100
- id: zod_1.z.number(),
101
- name: zod_1.z.string(),
102
- defaultConversation: zod_1.z.string().nullable().optional(),
103
- creator: zod_1.z.number(),
104
- created: zod_1.z.date(),
105
- avatarId: zod_1.z.string().nullable().optional(),
106
- avatarUrls: zod_1.z
107
- .object({
108
- s35: zod_1.z.string(),
109
- s60: zod_1.z.string(),
110
- s195: zod_1.z.string(),
111
- s640: zod_1.z.string(),
112
- })
113
- .nullable()
114
- .optional(),
115
- plan: zod_1.z.string().nullable().optional(),
116
- });
117
- exports.ChannelObjectSchema = zod_1.z.object({
118
- id: zod_1.z.string(),
119
- name: zod_1.z.string(),
120
- description: zod_1.z.string().nullable().optional(),
121
- creator: zod_1.z.number(),
122
- userIds: zod_1.z.array(zod_1.z.number()).nullable().optional(),
123
- color: zod_1.z.number().nullable().optional(),
124
- public: zod_1.z.boolean(),
125
- workspaceId: zod_1.z.number(),
126
- archived: zod_1.z.boolean(),
127
- created: zod_1.z.date(),
128
- useDefaultRecipients: zod_1.z.boolean().nullable().optional(),
129
- defaultGroups: zod_1.z.array(zod_1.z.string()).nullable().optional(),
130
- defaultRecipients: zod_1.z.array(zod_1.z.number()).nullable().optional(),
131
- isFavorited: zod_1.z.boolean().nullable().optional(),
132
- icon: zod_1.z.number().nullable().optional(),
133
- version: zod_1.z.number(),
134
- filters: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).nullable().optional(),
135
- });
136
- function createChannelSchema(linkBaseUrl) {
137
- return exports.ChannelObjectSchema.transform((data) => ({
138
- ...data,
139
- url: (0, url_helpers_1.getFullCommsURL)({ workspaceId: data.workspaceId, channelId: data.id }, linkBaseUrl),
140
- }));
141
- }
142
- exports.ChannelSchema = createChannelSchema();
143
- // Thread entity from API. `pinned` (boolean) and `pinnedDate` are both
144
- // surfaced — `pinned` is kept for Zapier/webhook clients.
145
- exports.ThreadObjectSchema = zod_1.z.object({
146
- id: zod_1.z.string(),
147
- title: zod_1.z.string(),
148
- content: zod_1.z.string(),
149
- creator: zod_1.z.number(),
150
- creatorName: zod_1.z.string().nullable().optional(),
151
- channelId: zod_1.z.string(),
152
- workspaceId: zod_1.z.number(),
153
- actions: zod_1.z.array(zod_1.z.unknown()).nullable().optional(),
154
- attachments: zod_1.z.array(exports.AttachmentSchema).nullable().optional(),
155
- commentCount: zod_1.z.number(),
156
- closed: zod_1.z.boolean().nullable().optional(),
157
- directGroupMentions: zod_1.z.array(zod_1.z.string()).nullable().optional(),
158
- directMentions: zod_1.z.array(zod_1.z.number()).nullable().optional(),
159
- groups: zod_1.z.array(zod_1.z.string()).nullable().optional(),
160
- lastEdited: zod_1.z.date().nullable().optional(),
161
- lastObjIndex: zod_1.z.number().nullable().optional(),
162
- lastUpdated: zod_1.z.date(),
163
- mutedUntil: zod_1.z.date().nullable().optional(),
164
- participants: zod_1.z.array(zod_1.z.number()).nullable().optional(),
165
- // Backend wire shape only includes `pinned_ts` (epoch seconds or null);
166
- // response normalization exposes that timestamp as `pinnedDate`.
167
- pinned: zod_1.z.boolean().optional(),
168
- pinnedDate: zod_1.z.date().nullable().optional(),
169
- posted: zod_1.z.date(),
170
- reactions: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullable().optional(),
171
- recipients: zod_1.z.array(zod_1.z.number()).nullable().optional(),
172
- responders: zod_1.z.array(zod_1.z.number()).nullable().optional(),
173
- snippet: zod_1.z.string(),
174
- snippetCreator: zod_1.z.number(),
175
- snippetMaskAvatarUrl: zod_1.z.string().nullable().optional(),
176
- snippetMaskPoster: zod_1.z.string().nullable().optional(),
177
- systemMessage: exports.SystemMessageSchema,
178
- toEmails: zod_1.z.array(zod_1.z.string()).nullable().optional(),
179
- isArchived: zod_1.z.boolean(),
180
- isSaved: zod_1.z.boolean().nullable().optional(),
181
- inInbox: zod_1.z.boolean().nullable().optional(),
182
- lastComment: zod_1.z
183
- .object({
184
- id: zod_1.z.string(),
185
- content: zod_1.z.string(),
186
- creator: zod_1.z.number(),
187
- creatorName: zod_1.z.string(),
188
- threadId: zod_1.z.string(),
189
- channelId: zod_1.z.string(),
190
- posted: zod_1.z.date(),
191
- systemMessage: exports.SystemMessageSchema,
192
- attachments: zod_1.z.array(exports.AttachmentSchema).nullable().optional(),
193
- reactions: zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.number())).nullable().optional(),
194
- actions: zod_1.z.array(zod_1.z.unknown()).nullable().optional(),
195
- objIndex: zod_1.z.number(),
196
- lastEdited: zod_1.z.date().nullable().optional(),
197
- deleted: zod_1.z.boolean(),
198
- deletedBy: zod_1.z.number().nullable().optional(),
199
- directGroupMentions: zod_1.z.array(zod_1.z.string()).nullable().optional(),
200
- directMentions: zod_1.z.array(zod_1.z.number()).nullable().optional(),
201
- groups: zod_1.z.array(zod_1.z.string()).nullable().optional(),
202
- recipients: zod_1.z.array(zod_1.z.number()).nullable().optional(),
203
- toEmails: zod_1.z.array(zod_1.z.string()).nullable().optional(),
204
- version: zod_1.z.number(),
205
- workspaceId: zod_1.z.number(),
206
- })
207
- .nullable()
208
- .optional(),
209
- });
210
- function createThreadSchema(linkBaseUrl) {
211
- return exports.ThreadObjectSchema.transform((data) => ({
212
- ...data,
213
- url: (0, url_helpers_1.getFullCommsURL)({
214
- workspaceId: data.workspaceId,
215
- channelId: data.channelId,
216
- threadId: data.id,
217
- }, linkBaseUrl),
218
- }));
219
- }
220
- exports.ThreadSchema = createThreadSchema();
221
- // Group entity from API. The broadcast markers `EVERYONE` and
222
- // `EVERYONE_IN_THREAD` can appear in place of a real `id` in group-bearing
223
- // fields on threads/comments/channels.
224
- exports.GroupSchema = zod_1.z.object({
225
- id: zod_1.z.string(),
226
- name: zod_1.z.string(),
227
- description: zod_1.z.string().nullable().optional(),
228
- workspaceId: zod_1.z.number(),
229
- userIds: zod_1.z.array(zod_1.z.number()),
230
- version: zod_1.z.number(),
231
- });
232
- // Conversation entity from API.
233
- exports.ConversationObjectSchema = zod_1.z.object({
234
- id: zod_1.z.string(),
235
- workspaceId: zod_1.z.number(),
236
- userIds: zod_1.z.array(zod_1.z.number()),
237
- messageCount: zod_1.z.number().nullable().optional(),
238
- lastObjIndex: zod_1.z.number(),
239
- snippet: zod_1.z.string(),
240
- snippetCreators: zod_1.z.array(zod_1.z.number()),
241
- lastActive: zod_1.z.date(),
242
- mutedUntil: zod_1.z.date().nullable().optional(),
243
- archived: zod_1.z.boolean(),
244
- created: zod_1.z.date(),
245
- creator: zod_1.z.number(),
246
- title: zod_1.z.string().nullable().optional(),
247
- private: zod_1.z.boolean().nullable().optional(),
248
- lastMessage: zod_1.z
249
- .object({
250
- // `id` may be string or number depending on the endpoint; coerced.
251
- id: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform(String),
252
- content: zod_1.z.string(),
253
- creator: zod_1.z.number(),
254
- conversationId: zod_1.z.string(),
255
- posted: zod_1.z.date(),
256
- systemMessage: exports.SystemMessageSchema,
257
- attachments: zod_1.z.array(exports.AttachmentSchema).nullable().optional(),
258
- reactions: zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.number())).nullable().optional(),
259
- actions: zod_1.z.array(zod_1.z.unknown()).nullable().optional(),
260
- objIndex: zod_1.z.number().nullable().optional(),
261
- lastEdited: zod_1.z.date().nullable().optional(),
262
- deleted: zod_1.z.boolean().nullable().optional(),
263
- directGroupMentions: zod_1.z.array(zod_1.z.string()).nullable().optional(),
264
- directMentions: zod_1.z.array(zod_1.z.number()).nullable().optional(),
265
- version: zod_1.z.number().nullable().optional(),
266
- workspaceId: zod_1.z.number().nullable().optional(),
267
- })
268
- .nullable()
269
- .optional(),
270
- });
271
- function createConversationSchema(linkBaseUrl) {
272
- return exports.ConversationObjectSchema.transform((data) => ({
273
- ...data,
274
- url: (0, url_helpers_1.getFullCommsURL)({ workspaceId: data.workspaceId, conversationId: data.id }, linkBaseUrl),
275
- }));
276
- }
277
- exports.ConversationSchema = createConversationSchema();
278
- exports.CommentObjectSchema = zod_1.z.object({
279
- id: zod_1.z.string(),
280
- content: zod_1.z.string(),
281
- creator: zod_1.z.number(),
282
- threadId: zod_1.z.string(),
283
- workspaceId: zod_1.z.number(),
284
- conversationId: zod_1.z.string().nullable().optional(),
285
- posted: zod_1.z.date(),
286
- lastEdited: zod_1.z.date().nullable().optional(),
287
- directMentions: zod_1.z.array(zod_1.z.number()).nullable().optional(),
288
- directGroupMentions: zod_1.z.array(zod_1.z.string()).nullable().optional(),
289
- systemMessage: exports.SystemMessageSchema,
290
- attachments: zod_1.z.array(exports.AttachmentSchema).nullable().optional(),
291
- reactions: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullable().optional(),
292
- objIndex: zod_1.z.number().nullable().optional(),
293
- creatorName: zod_1.z.string().nullable().optional(),
294
- channelId: zod_1.z.string(),
295
- recipients: zod_1.z.array(zod_1.z.number()).nullable().optional(),
296
- groups: zod_1.z.array(zod_1.z.string()).nullable().optional(),
297
- toEmails: zod_1.z.array(zod_1.z.string()).nullable().optional(),
298
- deleted: zod_1.z.boolean().nullable().optional(),
299
- deletedBy: zod_1.z.number().nullable().optional(),
300
- version: zod_1.z.number().nullable().optional(),
301
- actions: zod_1.z.array(zod_1.z.unknown()).nullable().optional(),
302
- });
303
- function createCommentSchema(linkBaseUrl) {
304
- return exports.CommentObjectSchema.transform((data) => ({
305
- ...data,
306
- url: (0, url_helpers_1.getFullCommsURL)({
307
- workspaceId: data.workspaceId,
308
- channelId: data.channelId,
309
- threadId: data.threadId,
310
- commentId: data.id,
311
- }, linkBaseUrl),
312
- }));
313
- }
314
- exports.CommentSchema = createCommentSchema();
315
- exports.WorkspaceUserSchema = exports.BaseUserSchema.extend({
316
- email: zod_1.z.string().nullable().optional(),
317
- userType: zod_1.z.enum(enums_1.USER_TYPES),
318
- dateFormat: zod_1.z.string().nullable().optional(),
319
- theme: zod_1.z.number().int().nullable().optional(),
320
- timeFormat: zod_1.z.string().nullable().optional(),
321
- version: zod_1.z.number(),
322
- });
323
- // Reduced user shape the backend substitutes when the viewer may not see a
324
- // user's full profile — the user has been removed from the workspace, or the
325
- // viewer is a guest with no visibility of them. `full_name` / `short_name`
326
- // carry the first name only, and neither `timezone` nor `user_type` is sent,
327
- // so those cannot be modelled on this branch.
328
- exports.RestrictedWorkspaceUserSchema = exports.BaseUserSchema.omit({ timezone: true }).extend({
329
- restricted: zod_1.z.literal(true),
330
- version: zod_1.z.number(),
331
- });
332
- // A workspace user as the current viewer sees them. Endpoints that resolve a
333
- // single user by id or email return either shape, discriminated by
334
- // `restricted`; narrow with {@link isRestrictedWorkspaceUser}. Endpoints that
335
- // list a workspace's own members always return the full shape.
336
- exports.VisibleWorkspaceUserSchema = zod_1.z.union([
337
- exports.WorkspaceUserSchema,
338
- exports.RestrictedWorkspaceUserSchema,
339
- ]);
340
- /**
341
- * Narrows a {@link VisibleWorkspaceUser} to the reduced shape, which has no
342
- * `timezone` and no `userType`.
343
- *
344
- * @param user - The user to check.
345
- * @returns `true` when the viewer only gets the restricted profile.
346
- *
347
- * @example
348
- * ```typescript
349
- * const user = await api.workspaceUsers.getUserById({ workspaceId: 123, userId: 456 })
350
- * const zone = isRestrictedWorkspaceUser(user) ? 'UTC' : user.timezone
351
- * ```
352
- */
353
- function isRestrictedWorkspaceUser(user) {
354
- return user.restricted === true;
355
- }
356
- // ConversationMessage entity from API. `id` is widened to `string | number`
357
- // (coerced to a string post-parse) because the backend currently emits
358
- // either shape depending on the endpoint; the URL/reaction helpers accept
359
- // both.
360
- exports.ConversationMessageObjectSchema = zod_1.z.object({
361
- id: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform(String),
362
- content: zod_1.z.string(),
363
- creator: zod_1.z.number(),
364
- conversationId: zod_1.z.string(),
365
- posted: zod_1.z.date(),
366
- systemMessage: exports.SystemMessageSchema,
367
- attachments: zod_1.z.array(exports.AttachmentSchema).nullable().optional(),
368
- reactions: zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.number())).nullable().optional(),
369
- actions: zod_1.z.array(zod_1.z.unknown()).nullable().optional(),
370
- objIndex: zod_1.z.number().nullable().optional(),
371
- lastEdited: zod_1.z.date().nullable().optional(),
372
- isDeleted: zod_1.z.boolean().nullable().optional(),
373
- directGroupMentions: zod_1.z.array(zod_1.z.string()).nullable().optional(),
374
- directMentions: zod_1.z.array(zod_1.z.number()).nullable().optional(),
375
- version: zod_1.z.number().nullable().optional(),
376
- workspaceId: zod_1.z.number(),
377
- });
378
- function createConversationMessageSchema(linkBaseUrl) {
379
- return exports.ConversationMessageObjectSchema.transform((data) => ({
380
- ...data,
381
- url: (0, url_helpers_1.getFullCommsURL)({
382
- workspaceId: data.workspaceId,
383
- conversationId: data.conversationId,
384
- messageId: data.id,
385
- }, linkBaseUrl),
386
- }));
387
- }
388
- exports.ConversationMessageSchema = createConversationMessageSchema();
389
- // InboxThread entity from API - returns full Thread objects with additional inbox metadata.
390
- function createInboxThreadObjectSchema(linkBaseUrl) {
391
- return zod_1.z.object({
392
- id: zod_1.z.string(),
393
- title: zod_1.z.string(),
394
- content: zod_1.z.string(),
395
- creator: zod_1.z.number(),
396
- creatorName: zod_1.z.string().nullable().optional(),
397
- channelId: zod_1.z.string(),
398
- workspaceId: zod_1.z.number(),
399
- actions: zod_1.z.array(zod_1.z.unknown()).nullable().optional(),
400
- attachments: zod_1.z.array(exports.AttachmentSchema).nullable().optional(),
401
- commentCount: zod_1.z.number(),
402
- directGroupMentions: zod_1.z.array(zod_1.z.string()).nullable().optional(),
403
- directMentions: zod_1.z.array(zod_1.z.number()).nullable().optional(),
404
- groups: zod_1.z.array(zod_1.z.string()).nullable().optional(),
405
- lastEdited: zod_1.z.date().nullable().optional(),
406
- lastObjIndex: zod_1.z.number().nullable().optional(),
407
- lastUpdated: zod_1.z.date(),
408
- mutedUntil: zod_1.z.date().nullable().optional(),
409
- participants: zod_1.z.array(zod_1.z.number()).nullable().optional(),
410
- // Backend wire shape only includes `pinned_ts` (epoch seconds or null);
411
- // response normalization exposes that timestamp as `pinnedDate`.
412
- pinned: zod_1.z.boolean().optional(),
413
- pinnedDate: zod_1.z.date().nullable().optional(),
414
- posted: zod_1.z.date(),
415
- reactions: zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.number())).nullable().optional(),
416
- recipients: zod_1.z.array(zod_1.z.number()).nullable().optional(),
417
- snippet: zod_1.z.string(),
418
- snippetCreator: zod_1.z.number(),
419
- snippetMaskAvatarUrl: zod_1.z.string().nullable().optional(),
420
- snippetMaskPoster: zod_1.z.string().nullable().optional(),
421
- systemMessage: exports.SystemMessageSchema,
422
- isArchived: zod_1.z.boolean(),
423
- inInbox: zod_1.z.boolean(),
424
- isSaved: zod_1.z.boolean().nullable().optional(),
425
- closed: zod_1.z.boolean(),
426
- responders: zod_1.z.array(zod_1.z.number()).nullable().optional(),
427
- lastComment: createCommentSchema(linkBaseUrl).nullable().optional(),
428
- toEmails: zod_1.z.array(zod_1.z.string()).nullable().optional(),
429
- version: zod_1.z.number().nullable().optional(),
430
- });
431
- }
432
- function createInboxThreadSchema(linkBaseUrl) {
433
- return createInboxThreadObjectSchema(linkBaseUrl).transform((data) => ({
434
- ...data,
435
- url: (0, url_helpers_1.getFullCommsURL)({
436
- workspaceId: data.workspaceId,
437
- channelId: data.channelId,
438
- threadId: data.id,
439
- }, linkBaseUrl),
440
- }));
441
- }
442
- exports.InboxThreadSchema = createInboxThreadSchema();
443
- // UnreadThread entity from API - simplified thread reference.
444
- exports.UnreadThreadSchema = zod_1.z.object({
445
- threadId: zod_1.z.string(),
446
- channelId: zod_1.z.string(),
447
- objIndex: zod_1.z.number(),
448
- directMention: zod_1.z.boolean(),
449
- });
450
- // UnreadConversation entity from API - simplified conversation reference.
451
- exports.UnreadConversationSchema = zod_1.z.object({
452
- conversationId: zod_1.z.string(),
453
- objIndex: zod_1.z.number(),
454
- directMention: zod_1.z.boolean(),
455
- });
456
- // SearchResult entity from API.
457
- // The API emits 'thread' and 'conversation' results: a match inside a
458
- // comment is returned as a 'thread' result with `commentId` set, and a match inside a
459
- // message as a 'conversation' result with `messageId` set.
460
- const searchResultBaseShape = {
461
- /**
462
- * Opaque search-result key in the form `thread_<threadId>` or
463
- * `conversation_<conversationId>`. Unique per result; not a Comms object id — use
464
- * `threadId`, `conversationId`, `commentId`, or `messageId` to reference objects.
465
- */
466
- id: zod_1.z.string(),
467
- snippet: zod_1.z.string(),
468
- snippetCreatorId: zod_1.z.number(),
469
- snippetLastUpdated: zod_1.z.date(),
470
- channelId: zod_1.z.string().nullable().optional(),
471
- channelName: zod_1.z.string().nullable().optional(),
472
- channelColor: zod_1.z.number().nullable().optional(),
473
- title: zod_1.z.string().nullable().optional(),
474
- closed: zod_1.z.boolean().nullable().optional(),
475
- };
476
- exports.SEARCH_RESULT_TYPES = ['thread', 'conversation'];
477
- exports.ThreadSearchResultSchema = zod_1.z.object({
478
- ...searchResultBaseShape,
479
- type: zod_1.z.literal('thread'),
480
- /** The owning thread id. */
481
- threadId: zod_1.z.string(),
482
- /** The matched comment id, set when the match is a comment. */
483
- commentId: zod_1.z.string().nullable().optional(),
484
- });
485
- exports.ConversationSearchResultSchema = zod_1.z.object({
486
- ...searchResultBaseShape,
487
- type: zod_1.z.literal('conversation'),
488
- /** The owning conversation id. */
489
- conversationId: zod_1.z.string(),
490
- /** The matched message id. */
491
- messageId: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform(String).nullable().optional(),
492
- });
493
- exports.SearchResultSchema = zod_1.z.discriminatedUnion('type', [
494
- exports.ThreadSearchResultSchema,
495
- exports.ConversationSearchResultSchema,
496
- ]);
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NOTIFY_AUDIENCE_GROUP_IDS = exports.NOTIFY_AUDIENCES = exports.WORKSPACE_PLANS = exports.USER_TYPES = exports.GROUP_ID_MARKERS = exports.EVERYONE_IN_THREAD = exports.EVERYONE = void 0;
4
- /**
5
- * Marker constants for the two "broadcast" group recipients. These appear
6
- * in group-bearing fields (`Thread.groups`, `Comment.groups`,
7
- * `Channel.defaultGroups`, `directGroupMentions`, etc.) in place of a
8
- * real group ID and tell the backend to notify "everyone in the channel"
9
- * or "everyone in the thread" respectively. Input and output are
10
- * symmetric. Defined here (and not in `./entities`) so that `enums`
11
- * stays leaf-level — `entities` imports from `enums`, never the reverse.
12
- */
13
- exports.EVERYONE = 'EVERYONE';
14
- exports.EVERYONE_IN_THREAD = 'EVERYONE_IN_THREAD';
15
- /** Union of the two broadcast group markers. */
16
- exports.GROUP_ID_MARKERS = [exports.EVERYONE, exports.EVERYONE_IN_THREAD];
17
- // User types for workspace users
18
- exports.USER_TYPES = ['USER', 'GUEST', 'ADMIN'];
19
- // Workspace plans. The known values today are `'free'`, `'unlimited'`,
20
- // and `'business'`, but the backend can introduce new plan names without
21
- // coordinating a SDK release — so the schema accepts any string and the
22
- // const array stays as a hint for autocomplete only.
23
- exports.WORKSPACE_PLANS = ['free', 'unlimited', 'business'];
24
- // Audiences that comment-creating endpoints can target alongside (or instead
25
- // of) individual `recipients` / custom `groups`.
26
- exports.NOTIFY_AUDIENCES = ['channel', 'thread'];
27
- /**
28
- * Internal mapping from {@link NotifyAudience} to the broadcast marker IDs
29
- * (`EVERYONE` / `EVERYONE_IN_THREAD`) that comment- and thread-creation
30
- * endpoints use on the wire. SDK consumers should use {@link NotifyAudience}
31
- * via `notifyAudience` on the request args rather than passing these IDs
32
- * directly.
33
- */
34
- exports.NOTIFY_AUDIENCE_GROUP_IDS = {
35
- channel: exports.EVERYONE,
36
- thread: exports.EVERYONE_IN_THREAD,
37
- };
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommsRequestError = void 0;
4
- const ts_custom_error_1 = require("ts-custom-error");
5
- class CommsRequestError extends ts_custom_error_1.CustomError {
6
- constructor(message, httpStatusCode, responseData) {
7
- super(message);
8
- this.httpStatusCode = httpStatusCode;
9
- this.responseData = responseData;
10
- }
11
- }
12
- exports.CommsRequestError = CommsRequestError;
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HTTP_METHODS = void 0;
4
- exports.HTTP_METHODS = ['POST', 'GET', 'PUT', 'PATCH', 'DELETE'];
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./api-version"), exports);
18
- __exportStar(require("./entities"), exports);
19
- __exportStar(require("./enums"), exports);
20
- __exportStar(require("./errors"), exports);
21
- __exportStar(require("./http"), exports);
22
- __exportStar(require("./requests"), exports);