@doist/comms-sdk 0.10.0 → 0.11.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.
@@ -31,26 +31,55 @@ class ConversationsClient extends base_client_1.BaseClient {
31
31
  : exports.ConversationListSchema;
32
32
  }
33
33
  /**
34
- * Gets all conversations for a workspace.
34
+ * Gets a page of conversations for a workspace, newest activity first.
35
+ * The server returns at most 500 rows per request (20 by default); pass
36
+ * the last row's `lastActive`/`id` as `olderThan`/`beforeId` to fetch
37
+ * the next page. Paired, they form a strict compound boundary, so pages
38
+ * never repeat rows. Omitting `archived` returns active and archived
39
+ * conversations mixed.
35
40
  *
36
41
  * @param args - The arguments for getting conversations.
37
42
  * @param args.workspaceId - The workspace ID.
38
- * @param args.archived - Optional flag to include archived conversations.
43
+ * @param args.archived - Optional flag to filter archived (true) or active (false) conversations.
44
+ * @param args.olderThan - Optional date to get conversations last active before.
45
+ * @param args.beforeId - Optional conversation id. Paired with olderThan it forms the
46
+ * strict compound cursor; alone it pages by conversation id order instead.
47
+ * @param args.limit - Optional page size (server default 20, max 500).
39
48
  * @returns An array of conversation objects.
40
49
  *
41
50
  * @example
42
51
  * ```typescript
43
- * const conversations = await api.conversations.getConversations({ workspaceId: 123 })
44
- * conversations.forEach(c => console.log(c.title))
52
+ * const page = await api.conversations.getConversations({ workspaceId: 123, limit: 500 })
53
+ * const last = page.at(-1)
54
+ * const nextPage = last
55
+ * ? await api.conversations.getConversations({
56
+ * workspaceId: 123,
57
+ * limit: 500,
58
+ * olderThan: last.lastActive,
59
+ * beforeId: last.id,
60
+ * })
61
+ * : []
45
62
  * ```
46
63
  */
47
64
  getConversations(args) {
65
+ // Fields are picked explicitly (matching getThreads/getComments) so a
66
+ // future Date field can't silently reach the generic snake-casing,
67
+ // which would turn it into an empty object on the wire.
68
+ const params = { workspaceId: args.workspaceId };
69
+ if (args.archived != null)
70
+ params.archived = args.archived;
71
+ if (args.olderThan)
72
+ params.olderThanTs = Math.floor(args.olderThan.getTime() / 1000);
73
+ if (args.beforeId != null)
74
+ params.beforeId = args.beforeId;
75
+ if (args.limit != null)
76
+ params.limit = args.limit;
48
77
  return (0, http_client_1.request)({
49
78
  httpMethod: 'GET',
50
79
  baseUri: this.getBaseUri(),
51
80
  relativePath: `${endpoints_1.ENDPOINT_CONVERSATIONS}/get`,
52
81
  apiToken: this.apiToken,
53
- payload: args,
82
+ payload: params,
54
83
  customFetch: this.customFetch,
55
84
  }).then((response) => this.conversationListSchema.parse(response.data));
56
85
  }
@@ -106,6 +106,9 @@ exports.GetCommentsArgsSchema = zod_1.z.object({
106
106
  exports.GetConversationsArgsSchema = zod_1.z.object({
107
107
  workspaceId: zod_1.z.number(),
108
108
  archived: zod_1.z.boolean().nullable().optional(),
109
+ olderThan: zod_1.z.date().nullable().optional(),
110
+ beforeId: zod_1.z.string().nullable().optional(),
111
+ limit: zod_1.z.number().nullable().optional(),
109
112
  });
110
113
  exports.GetOrCreateConversationArgsSchema = zod_1.z.object({
111
114
  workspaceId: zod_1.z.number(),
@@ -28,26 +28,55 @@ export class ConversationsClient extends BaseClient {
28
28
  : ConversationListSchema;
29
29
  }
30
30
  /**
31
- * Gets all conversations for a workspace.
31
+ * Gets a page of conversations for a workspace, newest activity first.
32
+ * The server returns at most 500 rows per request (20 by default); pass
33
+ * the last row's `lastActive`/`id` as `olderThan`/`beforeId` to fetch
34
+ * the next page. Paired, they form a strict compound boundary, so pages
35
+ * never repeat rows. Omitting `archived` returns active and archived
36
+ * conversations mixed.
32
37
  *
33
38
  * @param args - The arguments for getting conversations.
34
39
  * @param args.workspaceId - The workspace ID.
35
- * @param args.archived - Optional flag to include archived conversations.
40
+ * @param args.archived - Optional flag to filter archived (true) or active (false) conversations.
41
+ * @param args.olderThan - Optional date to get conversations last active before.
42
+ * @param args.beforeId - Optional conversation id. Paired with olderThan it forms the
43
+ * strict compound cursor; alone it pages by conversation id order instead.
44
+ * @param args.limit - Optional page size (server default 20, max 500).
36
45
  * @returns An array of conversation objects.
37
46
  *
38
47
  * @example
39
48
  * ```typescript
40
- * const conversations = await api.conversations.getConversations({ workspaceId: 123 })
41
- * conversations.forEach(c => console.log(c.title))
49
+ * const page = await api.conversations.getConversations({ workspaceId: 123, limit: 500 })
50
+ * const last = page.at(-1)
51
+ * const nextPage = last
52
+ * ? await api.conversations.getConversations({
53
+ * workspaceId: 123,
54
+ * limit: 500,
55
+ * olderThan: last.lastActive,
56
+ * beforeId: last.id,
57
+ * })
58
+ * : []
42
59
  * ```
43
60
  */
44
61
  getConversations(args) {
62
+ // Fields are picked explicitly (matching getThreads/getComments) so a
63
+ // future Date field can't silently reach the generic snake-casing,
64
+ // which would turn it into an empty object on the wire.
65
+ const params = { workspaceId: args.workspaceId };
66
+ if (args.archived != null)
67
+ params.archived = args.archived;
68
+ if (args.olderThan)
69
+ params.olderThanTs = Math.floor(args.olderThan.getTime() / 1000);
70
+ if (args.beforeId != null)
71
+ params.beforeId = args.beforeId;
72
+ if (args.limit != null)
73
+ params.limit = args.limit;
45
74
  return request({
46
75
  httpMethod: 'GET',
47
76
  baseUri: this.getBaseUri(),
48
77
  relativePath: `${ENDPOINT_CONVERSATIONS}/get`,
49
78
  apiToken: this.apiToken,
50
- payload: args,
79
+ payload: params,
51
80
  customFetch: this.customFetch,
52
81
  }).then((response) => this.conversationListSchema.parse(response.data));
53
82
  }
@@ -103,6 +103,9 @@ export const GetCommentsArgsSchema = z.object({
103
103
  export const GetConversationsArgsSchema = z.object({
104
104
  workspaceId: z.number(),
105
105
  archived: z.boolean().nullable().optional(),
106
+ olderThan: z.date().nullable().optional(),
107
+ beforeId: z.string().nullable().optional(),
108
+ limit: z.number().nullable().optional(),
106
109
  });
107
110
  export const GetOrCreateConversationArgsSchema = z.object({
108
111
  workspaceId: z.number(),
@@ -167,17 +167,34 @@ export declare class ConversationsClient extends BaseClient {
167
167
  private readonly conversationSchema;
168
168
  private readonly conversationListSchema;
169
169
  /**
170
- * Gets all conversations for a workspace.
170
+ * Gets a page of conversations for a workspace, newest activity first.
171
+ * The server returns at most 500 rows per request (20 by default); pass
172
+ * the last row's `lastActive`/`id` as `olderThan`/`beforeId` to fetch
173
+ * the next page. Paired, they form a strict compound boundary, so pages
174
+ * never repeat rows. Omitting `archived` returns active and archived
175
+ * conversations mixed.
171
176
  *
172
177
  * @param args - The arguments for getting conversations.
173
178
  * @param args.workspaceId - The workspace ID.
174
- * @param args.archived - Optional flag to include archived conversations.
179
+ * @param args.archived - Optional flag to filter archived (true) or active (false) conversations.
180
+ * @param args.olderThan - Optional date to get conversations last active before.
181
+ * @param args.beforeId - Optional conversation id. Paired with olderThan it forms the
182
+ * strict compound cursor; alone it pages by conversation id order instead.
183
+ * @param args.limit - Optional page size (server default 20, max 500).
175
184
  * @returns An array of conversation objects.
176
185
  *
177
186
  * @example
178
187
  * ```typescript
179
- * const conversations = await api.conversations.getConversations({ workspaceId: 123 })
180
- * conversations.forEach(c => console.log(c.title))
188
+ * const page = await api.conversations.getConversations({ workspaceId: 123, limit: 500 })
189
+ * const last = page.at(-1)
190
+ * const nextPage = last
191
+ * ? await api.conversations.getConversations({
192
+ * workspaceId: 123,
193
+ * limit: 500,
194
+ * olderThan: last.lastActive,
195
+ * beforeId: last.id,
196
+ * })
197
+ * : []
181
198
  * ```
182
199
  */
183
200
  getConversations(args: GetConversationsArgs): Promise<Conversation[]>;
@@ -164,6 +164,9 @@ export type GetCommentsArgs = z.infer<typeof GetCommentsArgsSchema>;
164
164
  export declare const GetConversationsArgsSchema: z.ZodObject<{
165
165
  workspaceId: z.ZodNumber;
166
166
  archived: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
167
+ olderThan: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
168
+ beforeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
169
+ limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
167
170
  }, z.core.$strip>;
168
171
  export type GetConversationsArgs = z.infer<typeof GetConversationsArgsSchema>;
169
172
  export declare const GetOrCreateConversationArgsSchema: z.ZodObject<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/comms-sdk",
3
- "version": "0.10.0",
3
+ "version": "0.11.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/",