@doist/comms-sdk 3.4.1 → 3.6.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.
@@ -35,6 +35,7 @@ export function addCommentRequest(context, params, options) {
35
35
  relativePath: `${ENDPOINT_COMMENTS}/add`,
36
36
  apiToken: context.apiToken,
37
37
  payload,
38
+ headers: context.headers,
38
39
  customFetch: context.customFetch,
39
40
  }).then((response) => context.schema.parse(response.data));
40
41
  }
@@ -47,6 +47,7 @@ export class AttachmentsClient extends BaseClient {
47
47
  baseUri: this.getBaseUri(),
48
48
  relativePath: `${ENDPOINT_FILES}/image/${checkedThreadId}/${id}`,
49
49
  apiToken: this.apiToken,
50
+ headers: this.headers,
50
51
  customFetch: this.customFetch,
51
52
  });
52
53
  return ImageReadResultSchema.parse(response.data);
@@ -88,6 +89,7 @@ export class AttachmentsClient extends BaseClient {
88
89
  additionalFields: {
89
90
  attachment_id: resolveAttachmentId(args.attachmentId),
90
91
  },
92
+ headers: this.headers,
91
93
  customFetch: this.customFetch,
92
94
  });
93
95
  return AttachmentSchema.parse(data);
@@ -10,6 +10,7 @@ export class BaseClient {
10
10
  this.baseUrl = config.baseUrl;
11
11
  this.defaultVersion = config.version || DEFAULT_API_VERSION;
12
12
  this.customFetch = config.customFetch;
13
+ this.headers = config.headers;
13
14
  }
14
15
  /**
15
16
  * Returns the base URI for an API request, with a guaranteed trailing
@@ -43,6 +43,7 @@ export class ChannelsClient extends BaseClient {
43
43
  relativePath: `${ENDPOINT_CHANNELS}/get`,
44
44
  apiToken: this.apiToken,
45
45
  payload: args,
46
+ headers: this.headers,
46
47
  customFetch: this.customFetch,
47
48
  }).then((response) => this.channelListSchema.parse(response.data));
48
49
  }
@@ -201,6 +202,7 @@ export class ChannelsClient extends BaseClient {
201
202
  relativePath: `${ENDPOINT_CHANNELS}/${suffix}`,
202
203
  apiToken: this.apiToken,
203
204
  payload: params,
205
+ headers: this.headers,
204
206
  customFetch: this.customFetch,
205
207
  }).then((response) => schema.parse(response.data));
206
208
  }
@@ -56,6 +56,7 @@ export class CommentsClient extends BaseClient {
56
56
  relativePath: `${ENDPOINT_COMMENTS}/get`,
57
57
  apiToken: this.apiToken,
58
58
  payload: params,
59
+ headers: this.headers,
59
60
  customFetch: this.customFetch,
60
61
  }).then((response) => this.commentListSchema.parse(response.data));
61
62
  }
@@ -73,6 +74,7 @@ export class CommentsClient extends BaseClient {
73
74
  relativePath: `${ENDPOINT_COMMENTS}/getone`,
74
75
  apiToken: this.apiToken,
75
76
  payload: { id },
77
+ headers: this.headers,
76
78
  customFetch: this.customFetch,
77
79
  }).then((response) => this.commentSchema.parse(response.data));
78
80
  }
@@ -107,6 +109,7 @@ export class CommentsClient extends BaseClient {
107
109
  return addCommentRequest({
108
110
  baseUri: this.getBaseUri(),
109
111
  apiToken: this.apiToken,
112
+ headers: this.headers,
110
113
  customFetch: this.customFetch,
111
114
  schema: this.commentSchema,
112
115
  }, args);
@@ -126,6 +129,7 @@ export class CommentsClient extends BaseClient {
126
129
  relativePath: `${ENDPOINT_COMMENTS}/update`,
127
130
  apiToken: this.apiToken,
128
131
  payload: { ...args },
132
+ headers: this.headers,
129
133
  customFetch: this.customFetch,
130
134
  }).then((response) => this.commentSchema.parse(response.data));
131
135
  }
@@ -141,6 +145,7 @@ export class CommentsClient extends BaseClient {
141
145
  relativePath: `${ENDPOINT_COMMENTS}/remove`,
142
146
  apiToken: this.apiToken,
143
147
  payload: { id },
148
+ headers: this.headers,
144
149
  customFetch: this.customFetch,
145
150
  }).then((response) => StatusOkSchema.parse(response.data));
146
151
  }
@@ -165,6 +170,7 @@ export class CommentsClient extends BaseClient {
165
170
  relativePath: `${ENDPOINT_COMMENTS}/mark_position`,
166
171
  apiToken: this.apiToken,
167
172
  payload: { threadId: args.threadId, commentId: args.commentId },
173
+ headers: this.headers,
168
174
  customFetch: this.customFetch,
169
175
  }).then((response) => StatusOkSchema.parse(response.data));
170
176
  }
@@ -56,6 +56,7 @@ export class ConversationMessagesClient extends BaseClient {
56
56
  relativePath: `${ENDPOINT_CONVERSATION_MESSAGES}/get`,
57
57
  apiToken: this.apiToken,
58
58
  payload: params,
59
+ headers: this.headers,
59
60
  customFetch: this.customFetch,
60
61
  }).then((response) => this.messageListSchema.parse(response.data));
61
62
  }
@@ -159,6 +160,7 @@ export class ConversationMessagesClient extends BaseClient {
159
160
  relativePath: `${ENDPOINT_CONVERSATION_MESSAGES}/${suffix}`,
160
161
  apiToken: this.apiToken,
161
162
  payload: params,
163
+ headers: this.headers,
162
164
  customFetch: this.customFetch,
163
165
  }).then((response) => schema.parse(response.data));
164
166
  }
@@ -77,6 +77,7 @@ export class ConversationsClient extends BaseClient {
77
77
  relativePath: `${ENDPOINT_CONVERSATIONS}/get`,
78
78
  apiToken: this.apiToken,
79
79
  payload: params,
80
+ headers: this.headers,
80
81
  customFetch: this.customFetch,
81
82
  }).then((response) => this.conversationListSchema.parse(response.data));
82
83
  }
@@ -273,6 +274,7 @@ export class ConversationsClient extends BaseClient {
273
274
  relativePath: `${ENDPOINT_CONVERSATIONS}/${suffix}`,
274
275
  apiToken: this.apiToken,
275
276
  payload: params,
277
+ headers: this.headers,
276
278
  customFetch: this.customFetch,
277
279
  }).then((response) => schema.parse(response.data));
278
280
  }
@@ -34,6 +34,7 @@ export class GroupsClient extends BaseClient {
34
34
  relativePath: `${ENDPOINT_GROUPS}/get`,
35
35
  apiToken: this.apiToken,
36
36
  payload: { workspaceId },
37
+ headers: this.headers,
37
38
  customFetch: this.customFetch,
38
39
  }).then((response) => GroupListSchema.parse(response.data));
39
40
  }
@@ -162,6 +163,7 @@ export class GroupsClient extends BaseClient {
162
163
  relativePath: `${ENDPOINT_GROUPS}/${suffix}`,
163
164
  apiToken: this.apiToken,
164
165
  payload: params,
166
+ headers: this.headers,
165
167
  customFetch: this.customFetch,
166
168
  }).then((response) => schema.parse(response.data));
167
169
  }
@@ -26,6 +26,7 @@ export class HooksClient extends BaseClient {
26
26
  relativePath: `${ENDPOINT_HOOKS}/subscribe`,
27
27
  apiToken: this.apiToken,
28
28
  payload: args,
29
+ headers: this.headers,
29
30
  customFetch: this.customFetch,
30
31
  }).then((response) => HookSubscribeResponseSchema.parse(response.data));
31
32
  }
@@ -42,6 +43,7 @@ export class HooksClient extends BaseClient {
42
43
  relativePath: `${ENDPOINT_HOOKS}/unsubscribe`,
43
44
  apiToken: this.apiToken,
44
45
  payload: args,
46
+ headers: this.headers,
45
47
  customFetch: this.customFetch,
46
48
  }).then((response) => StatusOkSchema.parse(response.data));
47
49
  }
@@ -61,6 +61,7 @@ export class InboxClient extends BaseClient {
61
61
  relativePath: `${ENDPOINT_INBOX}/get`,
62
62
  apiToken: this.apiToken,
63
63
  payload: params,
64
+ headers: this.headers,
64
65
  customFetch: this.customFetch,
65
66
  }).then((response) => this.inboxThreadListSchema.parse(response.data));
66
67
  }
@@ -83,6 +84,7 @@ export class InboxClient extends BaseClient {
83
84
  relativePath: `${ENDPOINT_INBOX}/get_count`,
84
85
  apiToken: this.apiToken,
85
86
  payload: { workspace_id: workspaceId },
87
+ headers: this.headers,
86
88
  customFetch: this.customFetch,
87
89
  }).then((response) => response.data.data);
88
90
  }
@@ -103,6 +105,7 @@ export class InboxClient extends BaseClient {
103
105
  relativePath: `${ENDPOINT_INBOX}/archive`,
104
106
  apiToken: this.apiToken,
105
107
  payload: { id },
108
+ headers: this.headers,
106
109
  customFetch: this.customFetch,
107
110
  }).then(() => undefined);
108
111
  }
@@ -123,6 +126,7 @@ export class InboxClient extends BaseClient {
123
126
  relativePath: `${ENDPOINT_INBOX}/unarchive`,
124
127
  apiToken: this.apiToken,
125
128
  payload: { id },
129
+ headers: this.headers,
126
130
  customFetch: this.customFetch,
127
131
  }).then(() => undefined);
128
132
  }
@@ -143,6 +147,7 @@ export class InboxClient extends BaseClient {
143
147
  relativePath: `${ENDPOINT_INBOX}/mark_all_read`,
144
148
  apiToken: this.apiToken,
145
149
  payload: { workspace_id: workspaceId },
150
+ headers: this.headers,
146
151
  customFetch: this.customFetch,
147
152
  }).then(() => undefined);
148
153
  }
@@ -174,6 +179,7 @@ export class InboxClient extends BaseClient {
174
179
  relativePath: `${ENDPOINT_INBOX}/archive_all`,
175
180
  apiToken: this.apiToken,
176
181
  payload: params,
182
+ headers: this.headers,
177
183
  customFetch: this.customFetch,
178
184
  }).then(() => undefined);
179
185
  }
@@ -35,6 +35,7 @@ export class ReactionsClient extends BaseClient {
35
35
  relativePath: `${ENDPOINT_REACTIONS}/add`,
36
36
  apiToken: this.apiToken,
37
37
  payload: { ...reactionTarget(args), reaction: args.reaction },
38
+ headers: this.headers,
38
39
  customFetch: this.customFetch,
39
40
  }).then(() => undefined);
40
41
  }
@@ -63,6 +64,7 @@ export class ReactionsClient extends BaseClient {
63
64
  relativePath: `${ENDPOINT_REACTIONS}/get`,
64
65
  apiToken: this.apiToken,
65
66
  payload: reactionTarget(args),
67
+ headers: this.headers,
66
68
  customFetch: this.customFetch,
67
69
  }).then((response) => response.data);
68
70
  }
@@ -87,6 +89,7 @@ export class ReactionsClient extends BaseClient {
87
89
  relativePath: `${ENDPOINT_REACTIONS}/remove`,
88
90
  apiToken: this.apiToken,
89
91
  payload: { ...reactionTarget(args), reaction: args.reaction },
92
+ headers: this.headers,
90
93
  customFetch: this.customFetch,
91
94
  }).then(() => undefined);
92
95
  }
@@ -53,6 +53,7 @@ export class SearchClient extends BaseClient {
53
53
  relativePath: ENDPOINT_SEARCH,
54
54
  apiToken: this.apiToken,
55
55
  payload: params,
56
+ headers: this.headers,
56
57
  customFetch: this.customFetch,
57
58
  }).then((response) => ({
58
59
  ...response.data,
@@ -92,6 +93,7 @@ export class SearchClient extends BaseClient {
92
93
  relativePath: `${ENDPOINT_SEARCH}/thread`,
93
94
  apiToken: this.apiToken,
94
95
  payload: params,
96
+ headers: this.headers,
95
97
  customFetch: this.customFetch,
96
98
  }).then((response) => response.data);
97
99
  }
@@ -128,6 +130,7 @@ export class SearchClient extends BaseClient {
128
130
  relativePath: `${ENDPOINT_SEARCH}/conversation`,
129
131
  apiToken: this.apiToken,
130
132
  payload: params,
133
+ headers: this.headers,
131
134
  customFetch: this.customFetch,
132
135
  }).then((response) => response.data);
133
136
  }
@@ -72,6 +72,7 @@ export class ThreadsClient extends BaseClient {
72
72
  relativePath: `${ENDPOINT_THREADS}/get`,
73
73
  apiToken: this.apiToken,
74
74
  payload: params,
75
+ headers: this.headers,
75
76
  customFetch: this.customFetch,
76
77
  }).then((response) => this.threadListSchema.parse(response.data));
77
78
  }
@@ -343,6 +344,7 @@ export class ThreadsClient extends BaseClient {
343
344
  return addCommentRequest({
344
345
  baseUri: this.getBaseUri(),
345
346
  apiToken: this.apiToken,
347
+ headers: this.headers,
346
348
  customFetch: this.customFetch,
347
349
  schema: this.commentSchema,
348
350
  }, { threadId: resolveReferenceId(id, 'id'), ...rest }, { threadAction });
@@ -354,6 +356,7 @@ export class ThreadsClient extends BaseClient {
354
356
  relativePath: `${ENDPOINT_THREADS}/${suffix}`,
355
357
  apiToken: this.apiToken,
356
358
  payload: params,
359
+ headers: this.headers,
357
360
  customFetch: this.customFetch,
358
361
  }).then((response) => schema.parse(response.data));
359
362
  }
@@ -92,6 +92,7 @@ export class UsersClient extends BaseClient {
92
92
  relativePath: `${ENDPOINT_USERS}/mfa/challenge`,
93
93
  apiToken: undefined,
94
94
  payload: args,
95
+ headers: this.headers,
95
96
  customFetch: this.customFetch,
96
97
  }).then((response) => response.data);
97
98
  }
@@ -103,6 +104,7 @@ export class UsersClient extends BaseClient {
103
104
  relativePath: `${ENDPOINT_USERS}/logout`,
104
105
  apiToken: this.apiToken,
105
106
  payload: undefined,
107
+ headers: this.headers,
106
108
  customFetch: this.customFetch,
107
109
  }).then(() => undefined);
108
110
  }
@@ -246,6 +248,7 @@ export class UsersClient extends BaseClient {
246
248
  relativePath: `${ENDPOINT_USERS}/validate_token`,
247
249
  apiToken: undefined,
248
250
  payload: { token },
251
+ headers: this.headers,
249
252
  customFetch: this.customFetch,
250
253
  }).then(() => undefined);
251
254
  }
@@ -268,6 +271,7 @@ export class UsersClient extends BaseClient {
268
271
  relativePath: `${ENDPOINT_USERS}/heartbeat`,
269
272
  apiToken: this.apiToken,
270
273
  payload: args,
274
+ headers: this.headers,
271
275
  customFetch: this.customFetch,
272
276
  }).then(() => undefined);
273
277
  }
@@ -283,6 +287,7 @@ export class UsersClient extends BaseClient {
283
287
  relativePath: `${ENDPOINT_USERS}/reset_presence`,
284
288
  apiToken: this.apiToken,
285
289
  payload: { workspaceId },
290
+ headers: this.headers,
286
291
  customFetch: this.customFetch,
287
292
  }).then(() => undefined);
288
293
  }
@@ -299,6 +304,7 @@ export class UsersClient extends BaseClient {
299
304
  relativePath: `${ENDPOINT_USERS}/check_email`,
300
305
  apiToken: undefined,
301
306
  payload: { email },
307
+ headers: this.headers,
302
308
  customFetch: this.customFetch,
303
309
  }).then((response) => response.data);
304
310
  }
@@ -315,6 +321,7 @@ export class UsersClient extends BaseClient {
315
321
  relativePath: `${ENDPOINT_USERS}/get_unsubscribe_settings`,
316
322
  apiToken: this.apiToken,
317
323
  payload: undefined,
324
+ headers: this.headers,
318
325
  customFetch: this.customFetch,
319
326
  }).then((response) => response.data);
320
327
  }
@@ -331,6 +338,7 @@ export class UsersClient extends BaseClient {
331
338
  relativePath: `${ENDPOINT_USERS}/update_unsubscribe_settings`,
332
339
  apiToken: this.apiToken,
333
340
  payload: settings,
341
+ headers: this.headers,
334
342
  customFetch: this.customFetch,
335
343
  }).then((response) => response.data);
336
344
  }
@@ -341,6 +349,7 @@ export class UsersClient extends BaseClient {
341
349
  relativePath: url,
342
350
  apiToken: this.apiToken,
343
351
  payload: params,
352
+ headers: this.headers,
344
353
  customFetch: this.customFetch,
345
354
  }).then((response) => schema.parse(response.data));
346
355
  }
@@ -352,6 +361,7 @@ export class UsersClient extends BaseClient {
352
361
  relativePath: url,
353
362
  apiToken: authed ? this.apiToken : undefined,
354
363
  payload: params,
364
+ headers: this.headers,
355
365
  customFetch: this.customFetch,
356
366
  }).then((response) => schema.parse(response.data));
357
367
  }
@@ -32,6 +32,7 @@ export class WorkspaceUsersClient extends BaseClient {
32
32
  relativePath: 'workspace_users/get',
33
33
  apiToken: this.apiToken,
34
34
  payload: { id: args.workspaceId, archived: args.archived },
35
+ headers: this.headers,
35
36
  customFetch: this.customFetch,
36
37
  }).then((response) => {
37
38
  const rawUsers = includeRemoved
@@ -53,6 +54,7 @@ export class WorkspaceUsersClient extends BaseClient {
53
54
  relativePath: 'workspace_users/get_ids',
54
55
  apiToken: this.apiToken,
55
56
  payload: { id: workspaceId },
57
+ headers: this.headers,
56
58
  customFetch: this.customFetch,
57
59
  }).then((response) => response.data);
58
60
  }
@@ -78,6 +80,7 @@ export class WorkspaceUsersClient extends BaseClient {
78
80
  relativePath: 'workspace_users/getone',
79
81
  apiToken: this.apiToken,
80
82
  payload: { id: args.workspaceId, user_id: args.userId },
83
+ headers: this.headers,
81
84
  customFetch: this.customFetch,
82
85
  }).then((response) => VisibleWorkspaceUserSchema.parse(response.data));
83
86
  }
@@ -105,6 +108,7 @@ export class WorkspaceUsersClient extends BaseClient {
105
108
  relativePath: 'workspace_users/get_by_email',
106
109
  apiToken: this.apiToken,
107
110
  payload: { id: args.workspaceId, email: args.email },
111
+ headers: this.headers,
108
112
  customFetch: this.customFetch,
109
113
  }).then((response) => VisibleWorkspaceUserSchema.parse(response.data));
110
114
  }
@@ -123,6 +127,7 @@ export class WorkspaceUsersClient extends BaseClient {
123
127
  relativePath: 'workspace_users/get_info',
124
128
  apiToken: this.apiToken,
125
129
  payload: { id: args.workspaceId, user_id: args.userId },
130
+ headers: this.headers,
126
131
  customFetch: this.customFetch,
127
132
  }).then((response) => response.data);
128
133
  }
@@ -150,6 +155,7 @@ export class WorkspaceUsersClient extends BaseClient {
150
155
  relativePath: 'workspace_users/get_local_time',
151
156
  apiToken: this.apiToken,
152
157
  payload: { id: args.workspaceId, user_id: args.userId },
158
+ headers: this.headers,
153
159
  customFetch: this.customFetch,
154
160
  }).then((response) => response.data);
155
161
  }
@@ -173,6 +179,7 @@ export class WorkspaceUsersClient extends BaseClient {
173
179
  email: args.email,
174
180
  userType: args.userType,
175
181
  },
182
+ headers: this.headers,
176
183
  customFetch: this.customFetch,
177
184
  }).then((response) => WorkspaceUserSchema.parse(response.data));
178
185
  }
@@ -198,6 +205,7 @@ export class WorkspaceUsersClient extends BaseClient {
198
205
  email: args.email,
199
206
  userId: args.userId,
200
207
  },
208
+ headers: this.headers,
201
209
  customFetch: this.customFetch,
202
210
  }).then((response) => WorkspaceUserSchema.parse(response.data));
203
211
  }
@@ -220,6 +228,7 @@ export class WorkspaceUsersClient extends BaseClient {
220
228
  email: args.email,
221
229
  userId: args.userId,
222
230
  },
231
+ headers: this.headers,
223
232
  customFetch: this.customFetch,
224
233
  }).then(() => undefined);
225
234
  }
@@ -242,6 +251,7 @@ export class WorkspaceUsersClient extends BaseClient {
242
251
  email: args.email,
243
252
  userId: args.userId,
244
253
  },
254
+ headers: this.headers,
245
255
  customFetch: this.customFetch,
246
256
  }).then(() => undefined);
247
257
  }
@@ -35,6 +35,7 @@ export class WorkspacesClient extends BaseClient {
35
35
  relativePath: `${ENDPOINT_WORKSPACES}/get`,
36
36
  apiToken: this.apiToken,
37
37
  payload: undefined,
38
+ headers: this.headers,
38
39
  customFetch: this.customFetch,
39
40
  }).then((response) => response.data.map((workspace) => WorkspaceSchema.parse(workspace)));
40
41
  }
@@ -57,6 +58,7 @@ export class WorkspacesClient extends BaseClient {
57
58
  relativePath: `${ENDPOINT_WORKSPACES}/getone`,
58
59
  apiToken: this.apiToken,
59
60
  payload: { id },
61
+ headers: this.headers,
60
62
  customFetch: this.customFetch,
61
63
  }).then((response) => WorkspaceSchema.parse(response.data));
62
64
  }
@@ -78,6 +80,7 @@ export class WorkspacesClient extends BaseClient {
78
80
  relativePath: `${ENDPOINT_WORKSPACES}/get_default`,
79
81
  apiToken: this.apiToken,
80
82
  payload: undefined,
83
+ headers: this.headers,
81
84
  customFetch: this.customFetch,
82
85
  }).then((response) => WorkspaceSchema.parse(response.data));
83
86
  }
@@ -100,6 +103,7 @@ export class WorkspacesClient extends BaseClient {
100
103
  relativePath: `${ENDPOINT_WORKSPACES}/add`,
101
104
  apiToken: this.apiToken,
102
105
  payload: { name },
106
+ headers: this.headers,
103
107
  customFetch: this.customFetch,
104
108
  }).then((response) => WorkspaceSchema.parse(response.data));
105
109
  }
@@ -122,6 +126,7 @@ export class WorkspacesClient extends BaseClient {
122
126
  relativePath: `${ENDPOINT_WORKSPACES}/update`,
123
127
  apiToken: this.apiToken,
124
128
  payload: { id, name },
129
+ headers: this.headers,
125
130
  customFetch: this.customFetch,
126
131
  }).then((response) => WorkspaceSchema.parse(response.data));
127
132
  }
@@ -142,6 +147,7 @@ export class WorkspacesClient extends BaseClient {
142
147
  relativePath: `${ENDPOINT_WORKSPACES}/remove`,
143
148
  apiToken: this.apiToken,
144
149
  payload: { id },
150
+ headers: this.headers,
145
151
  customFetch: this.customFetch,
146
152
  }).then(() => undefined);
147
153
  }
@@ -164,6 +170,7 @@ export class WorkspacesClient extends BaseClient {
164
170
  relativePath: `${ENDPOINT_WORKSPACES}/get_public_channels`,
165
171
  apiToken: this.apiToken,
166
172
  payload: { id },
173
+ headers: this.headers,
167
174
  customFetch: this.customFetch,
168
175
  }).then((response) => this.channelListSchema.parse(response.data));
169
176
  }
@@ -37,6 +37,7 @@ export class CommsApi {
37
37
  baseUrl: options?.baseUrl,
38
38
  version: options?.version,
39
39
  customFetch: options?.customFetch,
40
+ headers: options?.headers,
40
41
  };
41
42
  this.users = new UsersClient(clientConfig);
42
43
  this.workspaces = new WorkspacesClient(clientConfig);
@@ -21,15 +21,16 @@ const defaultHeaders = {
21
21
  function getAuthHeader(apiToken) {
22
22
  return `Bearer ${apiToken}`;
23
23
  }
24
- function getRequestConfiguration(baseURL, apiToken, requestId) {
24
+ function getRequestConfiguration(baseURL, apiToken, requestId, customHeaders) {
25
25
  const authHeader = apiToken ? { Authorization: getAuthHeader(apiToken) } : undefined;
26
26
  const requestIdHeader = requestId ? { 'X-Request-Id': requestId } : undefined;
27
- const headers = { ...defaultHeaders, ...authHeader, ...requestIdHeader };
27
+ // Custom headers sit below auth and request id so they can never clobber them.
28
+ const headers = { ...defaultHeaders, ...customHeaders, ...authHeader, ...requestIdHeader };
28
29
  return { baseURL, headers, timeout: 30000 };
29
30
  }
30
31
  export async function request(args) {
31
- const { httpMethod, baseUri, relativePath, apiToken, payload, requestId, customFetch } = args;
32
- const config = getRequestConfiguration(baseUri, apiToken, requestId);
32
+ const { httpMethod, baseUri, relativePath, apiToken, payload, requestId, headers, customFetch, } = args;
33
+ const config = getRequestConfiguration(baseUri, apiToken, requestId, headers);
33
34
  const url = new URL(relativePath, config.baseURL).toString();
34
35
  const options = {
35
36
  method: httpMethod,
@@ -49,6 +49,10 @@ export const AttachmentSchema = z.object(attachmentShape).loose();
49
49
  // this strips unknown keys so caller typos / off-spec fields are dropped instead
50
50
  // of being forwarded on the wire. Use this for `*Args` request schemas.
51
51
  export const RequestAttachmentSchema = z.object(attachmentShape);
52
+ // Clients that don't model `scope` can store `{}`, and the backend omits unset fields.
53
+ export const StatusEffectSchema = z.object({
54
+ scope: z.object({ mode: z.string().optional() }).optional(),
55
+ });
52
56
  // Shared user status. It lives on the Todoist account, so Comms, Todoist and
53
57
  // automations all see the same one. `activeUntil` is an RFC 3339 string, and an
54
58
  // expired status is returned as `null` rather than as an expired object.
@@ -58,10 +62,8 @@ export const UserStatusSchema = z.object({
58
62
  activeUntil: z.string().nullable().optional(),
59
63
  effects: z
60
64
  .object({
61
- // Clients that don't model `scope` can store `{}`, and the backend omits unset fields.
62
- pauseNotifications: z
63
- .object({ scope: z.object({ mode: z.string().optional() }).optional() })
64
- .optional(),
65
+ pauseNotifications: StatusEffectSchema.optional(),
66
+ pauseActivity: StatusEffectSchema.optional(),
65
67
  })
66
68
  .optional(),
67
69
  });
@@ -164,7 +164,7 @@ function buildMultipartBody(args) {
164
164
  * the returned shape with the appropriate schema.
165
165
  */
166
166
  export async function uploadMultipartFile(args) {
167
- const { baseUrl, authToken, endpoint, file, fileName, contentType, additionalFields, maxRetries = 0, requestId, customFetch, } = args;
167
+ const { baseUrl, authToken, endpoint, file, fileName, contentType, additionalFields, maxRetries = 0, requestId, headers: customHeaders, customFetch, } = args;
168
168
  const { blob, fileName: resolvedFileName, contentType: resolvedType, } = toBlob(file, fileName, contentType);
169
169
  const fields = {
170
170
  file_name: resolvedFileName,
@@ -179,6 +179,7 @@ export async function uploadMultipartFile(args) {
179
179
  fields,
180
180
  });
181
181
  const headers = {
182
+ ...customHeaders,
182
183
  Authorization: `Bearer ${authToken}`,
183
184
  // The boundary is ours, so this has to be declared explicitly — `fetch`
184
185
  // only fills it in for a `FormData` body.
@@ -5,6 +5,7 @@ type ClientContext = {
5
5
  baseUri: string;
6
6
  apiToken: string;
7
7
  customFetch?: CustomFetch;
8
+ headers?: Record<string, string>;
8
9
  /** Per-client Comment schema, base-bound for the returned comment's web `url`. */
9
10
  schema: ReturnType<typeof createCommentSchema>;
10
11
  };
@@ -9,6 +9,8 @@ export type ClientConfig = {
9
9
  version?: ApiVersion;
10
10
  /** Optional custom fetch implementation for cross-platform compatibility */
11
11
  customFetch?: CustomFetch;
12
+ /** Optional headers sent with every request */
13
+ headers?: Record<string, string>;
12
14
  };
13
15
  /**
14
16
  * Base class for every Comms API client. Centralizes URL handling and
@@ -19,6 +21,7 @@ export declare class BaseClient {
19
21
  protected readonly baseUrl?: string;
20
22
  protected readonly defaultVersion: ApiVersion;
21
23
  protected readonly customFetch?: CustomFetch;
24
+ protected readonly headers?: Record<string, string>;
22
25
  constructor(config: ClientConfig);
23
26
  /**
24
27
  * Returns the base URI for an API request, with a guaranteed trailing
@@ -21,6 +21,8 @@ export type CommsApiOptions = {
21
21
  version?: ApiVersion;
22
22
  /** Optional custom fetch implementation for cross-platform compatibility (e.g., Obsidian, React Native, Electron). */
23
23
  customFetch?: CustomFetch;
24
+ /** Optional headers sent with every request, e.g. `{ 'Doist-Platform': 'cli' }` for client attribution. Cannot override `Authorization` or `X-Request-Id`. */
25
+ headers?: Record<string, string>;
24
26
  };
25
27
  /**
26
28
  * The main API client for interacting with the Comms REST API.
@@ -7,6 +7,7 @@ export type RequestArgs = {
7
7
  apiToken?: string;
8
8
  payload?: Record<string, unknown>;
9
9
  requestId?: string;
10
+ headers?: Record<string, string>;
10
11
  customFetch?: CustomFetch;
11
12
  };
12
13
  export declare function request<T>(args: RequestArgs): Promise<HttpResponse<T>>;
@@ -54,6 +54,11 @@ export declare const RequestAttachmentSchema: z.ZodObject<{
54
54
  videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
55
55
  }, z.core.$strip>;
56
56
  export type RequestAttachment = z.infer<typeof RequestAttachmentSchema>;
57
+ export declare const StatusEffectSchema: z.ZodObject<{
58
+ scope: z.ZodOptional<z.ZodObject<{
59
+ mode: z.ZodOptional<z.ZodString>;
60
+ }, z.core.$strip>>;
61
+ }, z.core.$strip>;
57
62
  export declare const UserStatusSchema: z.ZodObject<{
58
63
  message: z.ZodString;
59
64
  emoji: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -64,6 +69,11 @@ export declare const UserStatusSchema: z.ZodObject<{
64
69
  mode: z.ZodOptional<z.ZodString>;
65
70
  }, z.core.$strip>>;
66
71
  }, z.core.$strip>>;
72
+ pauseActivity: z.ZodOptional<z.ZodObject<{
73
+ scope: z.ZodOptional<z.ZodObject<{
74
+ mode: z.ZodOptional<z.ZodString>;
75
+ }, z.core.$strip>>;
76
+ }, z.core.$strip>>;
67
77
  }, z.core.$strip>>;
68
78
  }, z.core.$strip>;
69
79
  export type UserStatus = z.infer<typeof UserStatusSchema>;
@@ -93,6 +103,11 @@ export declare const BaseUserSchema: z.ZodObject<{
93
103
  mode: z.ZodOptional<z.ZodString>;
94
104
  }, z.core.$strip>>;
95
105
  }, z.core.$strip>>;
106
+ pauseActivity: z.ZodOptional<z.ZodObject<{
107
+ scope: z.ZodOptional<z.ZodObject<{
108
+ mode: z.ZodOptional<z.ZodString>;
109
+ }, z.core.$strip>>;
110
+ }, z.core.$strip>>;
96
111
  }, z.core.$strip>>;
97
112
  }, z.core.$strip>>>;
98
113
  }, z.core.$strip>;
@@ -122,6 +137,11 @@ export declare const UserSchema: z.ZodObject<{
122
137
  mode: z.ZodOptional<z.ZodString>;
123
138
  }, z.core.$strip>>;
124
139
  }, z.core.$strip>>;
140
+ pauseActivity: z.ZodOptional<z.ZodObject<{
141
+ scope: z.ZodOptional<z.ZodObject<{
142
+ mode: z.ZodOptional<z.ZodString>;
143
+ }, z.core.$strip>>;
144
+ }, z.core.$strip>>;
125
145
  }, z.core.$strip>>;
126
146
  }, z.core.$strip>>>;
127
147
  email: z.ZodEmail;
@@ -1638,6 +1658,11 @@ export declare const WorkspaceUserSchema: z.ZodObject<{
1638
1658
  mode: z.ZodOptional<z.ZodString>;
1639
1659
  }, z.core.$strip>>;
1640
1660
  }, z.core.$strip>>;
1661
+ pauseActivity: z.ZodOptional<z.ZodObject<{
1662
+ scope: z.ZodOptional<z.ZodObject<{
1663
+ mode: z.ZodOptional<z.ZodString>;
1664
+ }, z.core.$strip>>;
1665
+ }, z.core.$strip>>;
1641
1666
  }, z.core.$strip>>;
1642
1667
  }, z.core.$strip>>>;
1643
1668
  email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -1663,6 +1688,11 @@ export declare const RestrictedWorkspaceUserSchema: z.ZodObject<{
1663
1688
  mode: z.ZodOptional<z.ZodString>;
1664
1689
  }, z.core.$strip>>;
1665
1690
  }, z.core.$strip>>;
1691
+ pauseActivity: z.ZodOptional<z.ZodObject<{
1692
+ scope: z.ZodOptional<z.ZodObject<{
1693
+ mode: z.ZodOptional<z.ZodString>;
1694
+ }, z.core.$strip>>;
1695
+ }, z.core.$strip>>;
1666
1696
  }, z.core.$strip>>;
1667
1697
  }, z.core.$strip>>>;
1668
1698
  id: z.ZodNumber;
@@ -1708,6 +1738,11 @@ export declare const VisibleWorkspaceUserSchema: z.ZodUnion<readonly [z.ZodObjec
1708
1738
  mode: z.ZodOptional<z.ZodString>;
1709
1739
  }, z.core.$strip>>;
1710
1740
  }, z.core.$strip>>;
1741
+ pauseActivity: z.ZodOptional<z.ZodObject<{
1742
+ scope: z.ZodOptional<z.ZodObject<{
1743
+ mode: z.ZodOptional<z.ZodString>;
1744
+ }, z.core.$strip>>;
1745
+ }, z.core.$strip>>;
1711
1746
  }, z.core.$strip>>;
1712
1747
  }, z.core.$strip>>>;
1713
1748
  email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -1731,6 +1766,11 @@ export declare const VisibleWorkspaceUserSchema: z.ZodUnion<readonly [z.ZodObjec
1731
1766
  mode: z.ZodOptional<z.ZodString>;
1732
1767
  }, z.core.$strip>>;
1733
1768
  }, z.core.$strip>>;
1769
+ pauseActivity: z.ZodOptional<z.ZodObject<{
1770
+ scope: z.ZodOptional<z.ZodObject<{
1771
+ mode: z.ZodOptional<z.ZodString>;
1772
+ }, z.core.$strip>>;
1773
+ }, z.core.$strip>>;
1734
1774
  }, z.core.$strip>>;
1735
1775
  }, z.core.$strip>>>;
1736
1776
  id: z.ZodNumber;
@@ -185,6 +185,11 @@ export type UpdateUserArgs = {
185
185
  /** Theme ID (0-12). String aliases like `'dark'` are also accepted. */
186
186
  theme?: number | string;
187
187
  };
188
+ type StatusEffectArgs = {
189
+ scope?: {
190
+ mode: 'all';
191
+ };
192
+ };
188
193
  export type SetStatusArgs = {
189
194
  /** 1 to 80 characters once trimmed. */
190
195
  message: string;
@@ -193,11 +198,9 @@ export type SetStatusArgs = {
193
198
  activeUntil?: Date | string | null;
194
199
  effects?: {
195
200
  /** Holds back Comms notifications while the status is active. They are not sent later. */
196
- pauseNotifications?: {
197
- scope?: {
198
- mode: 'all';
199
- };
200
- };
201
+ pauseNotifications?: StatusEffectArgs;
202
+ /** Meant to pause Karma and streaks while the status is active. Comms drops it until Doist/comms-backend#1081 ships. */
203
+ pauseActivity?: StatusEffectArgs;
201
204
  };
202
205
  };
203
206
  type SearchArgsCommon = {
@@ -33,6 +33,8 @@ type UploadMultipartFileArgs = {
33
33
  maxRetries?: number;
34
34
  /** Optional request ID for tracing. */
35
35
  requestId?: string;
36
+ /** Optional headers sent with the request. Cannot override `Authorization` or `Content-Type`. */
37
+ headers?: Record<string, string>;
36
38
  /** Optional custom fetch implementation. */
37
39
  customFetch?: CustomFetch;
38
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/comms-sdk",
3
- "version": "3.4.1",
3
+ "version": "3.6.0",
4
4
  "description": "A TypeScript wrapper for the Comms REST API.",
5
5
  "author": "Doist developers",
6
6
  "homepage": "https://doist.github.io/comms-sdk-typescript/",