@doist/twist-sdk 2.3.0 → 2.4.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,11 +31,15 @@ var CommentsClient = /** @class */ (function (_super) {
31
31
  return _super !== null && _super.apply(this, arguments) || this;
32
32
  }
33
33
  CommentsClient.prototype.getComments = function (args, options) {
34
+ var _a;
34
35
  var params = {
35
36
  thread_id: args.threadId,
36
37
  };
37
- if (args.from)
38
- params.from = Math.floor(args.from.getTime() / 1000);
38
+ var newerThan = (_a = args.newerThan) !== null && _a !== void 0 ? _a : args.from;
39
+ if (newerThan)
40
+ params.newer_than_ts = Math.floor(newerThan.getTime() / 1000);
41
+ if (args.olderThan)
42
+ params.older_than_ts = Math.floor(args.olderThan.getTime() / 1000);
39
43
  if (args.limit)
40
44
  params.limit = args.limit;
41
45
  var method = 'GET';
@@ -41,6 +41,8 @@ var InboxClient = /** @class */ (function (_super) {
41
41
  params.limit = args.limit;
42
42
  if (args.cursor)
43
43
  params.cursor = args.cursor;
44
+ if (args.archiveFilter)
45
+ params.archive_filter = args.archiveFilter;
44
46
  var method = 'GET';
45
47
  var url = "".concat(endpoints_1.ENDPOINT_INBOX, "/get");
46
48
  if (options === null || options === void 0 ? void 0 : options.batch) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.THREAD_ACTIONS = exports.AWAY_MODE_TYPES = exports.GetOrCreateConversationArgsSchema = exports.GetConversationsArgsSchema = exports.GetCommentsArgsSchema = exports.GetThreadsArgsSchema = exports.GetChannelsArgsSchema = exports.CreateMessageArgsSchema = exports.CreateConversationArgsSchema = exports.UpdateCommentArgsSchema = exports.CreateCommentArgsSchema = exports.UpdateThreadArgsSchema = exports.CreateThreadArgsSchema = exports.UpdateChannelArgsSchema = exports.CreateChannelArgsSchema = void 0;
3
+ exports.THREAD_ACTIONS = exports.ARCHIVE_FILTER_VALUES = exports.AWAY_MODE_TYPES = exports.GetOrCreateConversationArgsSchema = exports.GetConversationsArgsSchema = exports.GetCommentsArgsSchema = exports.GetThreadsArgsSchema = exports.GetChannelsArgsSchema = exports.CreateMessageArgsSchema = exports.CreateConversationArgsSchema = exports.UpdateCommentArgsSchema = exports.CreateCommentArgsSchema = exports.UpdateThreadArgsSchema = exports.CreateThreadArgsSchema = exports.UpdateChannelArgsSchema = exports.CreateChannelArgsSchema = void 0;
4
4
  var zod_1 = require("zod");
5
5
  exports.CreateChannelArgsSchema = zod_1.z.object({
6
6
  workspaceId: zod_1.z.number(),
@@ -80,6 +80,8 @@ exports.GetThreadsArgsSchema = zod_1.z.object({
80
80
  exports.GetCommentsArgsSchema = zod_1.z.object({
81
81
  threadId: zod_1.z.number(),
82
82
  from: zod_1.z.date().nullable().optional(),
83
+ newerThan: zod_1.z.date().nullable().optional(),
84
+ olderThan: zod_1.z.date().nullable().optional(),
83
85
  limit: zod_1.z.number().nullable().optional(),
84
86
  });
85
87
  exports.GetConversationsArgsSchema = zod_1.z.object({
@@ -91,5 +93,7 @@ exports.GetOrCreateConversationArgsSchema = zod_1.z.object({
91
93
  userIds: zod_1.z.array(zod_1.z.number()),
92
94
  });
93
95
  exports.AWAY_MODE_TYPES = ['parental', 'vacation', 'sickleave', 'other'];
96
+ // Inbox
97
+ exports.ARCHIVE_FILTER_VALUES = ['active', 'archived', 'all'];
94
98
  // Threads
95
99
  exports.THREAD_ACTIONS = ['close', 'reopen'];
@@ -28,11 +28,15 @@ var CommentsClient = /** @class */ (function (_super) {
28
28
  return _super !== null && _super.apply(this, arguments) || this;
29
29
  }
30
30
  CommentsClient.prototype.getComments = function (args, options) {
31
+ var _a;
31
32
  var params = {
32
33
  thread_id: args.threadId,
33
34
  };
34
- if (args.from)
35
- params.from = Math.floor(args.from.getTime() / 1000);
35
+ var newerThan = (_a = args.newerThan) !== null && _a !== void 0 ? _a : args.from;
36
+ if (newerThan)
37
+ params.newer_than_ts = Math.floor(newerThan.getTime() / 1000);
38
+ if (args.olderThan)
39
+ params.older_than_ts = Math.floor(args.olderThan.getTime() / 1000);
36
40
  if (args.limit)
37
41
  params.limit = args.limit;
38
42
  var method = 'GET';
@@ -38,6 +38,8 @@ var InboxClient = /** @class */ (function (_super) {
38
38
  params.limit = args.limit;
39
39
  if (args.cursor)
40
40
  params.cursor = args.cursor;
41
+ if (args.archiveFilter)
42
+ params.archive_filter = args.archiveFilter;
41
43
  var method = 'GET';
42
44
  var url = "".concat(ENDPOINT_INBOX, "/get");
43
45
  if (options === null || options === void 0 ? void 0 : options.batch) {
@@ -77,6 +77,8 @@ export var GetThreadsArgsSchema = z.object({
77
77
  export var GetCommentsArgsSchema = z.object({
78
78
  threadId: z.number(),
79
79
  from: z.date().nullable().optional(),
80
+ newerThan: z.date().nullable().optional(),
81
+ olderThan: z.date().nullable().optional(),
80
82
  limit: z.number().nullable().optional(),
81
83
  });
82
84
  export var GetConversationsArgsSchema = z.object({
@@ -88,5 +90,7 @@ export var GetOrCreateConversationArgsSchema = z.object({
88
90
  userIds: z.array(z.number()),
89
91
  });
90
92
  export var AWAY_MODE_TYPES = ['parental', 'vacation', 'sickleave', 'other'];
93
+ // Inbox
94
+ export var ARCHIVE_FILTER_VALUES = ['active', 'archived', 'all'];
91
95
  // Threads
92
96
  export var THREAD_ACTIONS = ['close', 'reopen'];
@@ -11,7 +11,9 @@ export declare class CommentsClient extends BaseClient {
11
11
  *
12
12
  * @param args - The arguments for getting comments.
13
13
  * @param args.threadId - The thread ID.
14
- * @param args.from - Optional date to get comments from.
14
+ * @param args.from - @deprecated Use `newerThan` instead.
15
+ * @param args.newerThan - Optional date to get comments newer than.
16
+ * @param args.olderThan - Optional date to get comments older than.
15
17
  * @param args.limit - Optional limit on number of comments returned.
16
18
  * @param options - Optional configuration. Set `batch: true` to return a descriptor for batch requests.
17
19
  * @returns An array of comment objects.
@@ -20,7 +22,7 @@ export declare class CommentsClient extends BaseClient {
20
22
  * ```typescript
21
23
  * const comments = await api.comments.getComments({
22
24
  * threadId: 789,
23
- * from: new Date('2024-01-01')
25
+ * newerThan: new Date('2024-01-01')
24
26
  * })
25
27
  * comments.forEach(c => console.log(c.content))
26
28
  * ```
@@ -15,6 +15,7 @@ export declare class InboxClient extends BaseClient {
15
15
  * @param args.until - Optional date to get items until.
16
16
  * @param args.limit - Optional limit on number of items returned.
17
17
  * @param args.cursor - Optional cursor for pagination.
18
+ * @param args.archiveFilter - Optional filter: 'active' (default), 'archived', or 'all'.
18
19
  * @param options - Optional configuration. Set `batch: true` to return a descriptor for batch requests.
19
20
  * @returns Inbox threads.
20
21
  *
@@ -24,6 +25,12 @@ export declare class InboxClient extends BaseClient {
24
25
  * workspaceId: 123,
25
26
  * since: new Date('2024-01-01')
26
27
  * })
28
+ *
29
+ * // Include archived (done) items alongside active ones
30
+ * const allInbox = await api.inbox.getInbox({
31
+ * workspaceId: 123,
32
+ * archiveFilter: 'all'
33
+ * })
27
34
  * ```
28
35
  */
29
36
  getInbox(args: GetInboxArgs, options: {
@@ -81,9 +81,14 @@ export type GetThreadsArgs = z.infer<typeof GetThreadsArgsSchema>;
81
81
  export declare const GetCommentsArgsSchema: z.ZodObject<{
82
82
  threadId: z.ZodNumber;
83
83
  from: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
84
+ newerThan: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
85
+ olderThan: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
84
86
  limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
85
87
  }, z.core.$strip>;
86
- export type GetCommentsArgs = z.infer<typeof GetCommentsArgsSchema>;
88
+ export type GetCommentsArgs = Omit<z.infer<typeof GetCommentsArgsSchema>, 'from'> & {
89
+ /** @deprecated Use `newerThan` instead. */
90
+ from?: Date | null;
91
+ };
87
92
  export declare const GetConversationsArgsSchema: z.ZodObject<{
88
93
  workspaceId: z.ZodNumber;
89
94
  archived: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
@@ -156,12 +161,15 @@ export type UpdateConversationMessageArgs = {
156
161
  content: string;
157
162
  attachments?: unknown[];
158
163
  };
164
+ export declare const ARCHIVE_FILTER_VALUES: readonly ["active", "archived", "all"];
165
+ export type ArchiveFilter = (typeof ARCHIVE_FILTER_VALUES)[number];
159
166
  export type GetInboxArgs = {
160
167
  workspaceId: number;
161
168
  since?: Date;
162
169
  until?: Date;
163
170
  limit?: number;
164
171
  cursor?: string;
172
+ archiveFilter?: ArchiveFilter;
165
173
  };
166
174
  export type ArchiveAllArgs = {
167
175
  workspaceId: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/twist-sdk",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "A TypeScript wrapper for the Twist REST API.",
5
5
  "author": "Doist developers",
6
6
  "homepage": "https://doist.github.io/twist-sdk-typescript/",