@doist/twist-sdk 2.3.1 → 2.4.1

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.
@@ -30,17 +30,22 @@ var InboxClient = /** @class */ (function (_super) {
30
30
  return _super !== null && _super.apply(this, arguments) || this;
31
31
  }
32
32
  InboxClient.prototype.getInbox = function (args, options) {
33
+ var _a, _b;
33
34
  var params = {
34
35
  workspace_id: args.workspaceId,
35
36
  };
36
- if (args.since)
37
- params.newer_than_ts = Math.floor(args.since.getTime() / 1000);
38
- if (args.until)
39
- params.older_than_ts = Math.floor(args.until.getTime() / 1000);
37
+ var newerThan = (_a = args.newerThan) !== null && _a !== void 0 ? _a : args.since;
38
+ if (newerThan)
39
+ params.newer_than_ts = Math.floor(newerThan.getTime() / 1000);
40
+ var olderThan = (_b = args.olderThan) !== null && _b !== void 0 ? _b : args.until;
41
+ if (olderThan)
42
+ params.older_than_ts = Math.floor(olderThan.getTime() / 1000);
40
43
  if (args.limit)
41
44
  params.limit = args.limit;
42
45
  if (args.cursor)
43
46
  params.cursor = args.cursor;
47
+ if (args.archiveFilter)
48
+ params.archive_filter = args.archiveFilter;
44
49
  var method = 'GET';
45
50
  var url = "".concat(endpoints_1.ENDPOINT_INBOX, "/get");
46
51
  if (options === null || options === void 0 ? void 0 : options.batch) {
@@ -120,15 +125,15 @@ var InboxClient = /** @class */ (function (_super) {
120
125
  }).then(function () { return undefined; });
121
126
  };
122
127
  InboxClient.prototype.archiveAll = function (args, options) {
128
+ var _a;
123
129
  var params = {
124
130
  workspace_id: args.workspaceId,
125
131
  };
126
132
  if (args.channelIds)
127
133
  params.channel_ids = args.channelIds;
128
- if (args.since)
129
- params.since_ts_or_obj_idx = Math.floor(args.since.getTime() / 1000);
130
- if (args.until)
131
- params.until_ts_or_obj_idx = Math.floor(args.until.getTime() / 1000);
134
+ var olderThan = (_a = args.olderThan) !== null && _a !== void 0 ? _a : args.until;
135
+ if (olderThan)
136
+ params.older_than_ts = Math.floor(olderThan.getTime() / 1000);
132
137
  var method = 'POST';
133
138
  var url = "".concat(endpoints_1.ENDPOINT_INBOX, "/archive_all");
134
139
  if (options === null || options === void 0 ? void 0 : options.batch) {
@@ -55,7 +55,10 @@ var ThreadsClient = /** @class */ (function (_super) {
55
55
  ThreadsClient.prototype.getThreads = function (args, options) {
56
56
  var method = 'GET';
57
57
  var url = "".concat(endpoints_1.ENDPOINT_THREADS, "/get");
58
- var params = args;
58
+ var newerThan = args.newerThan, olderThan = args.olderThan, newer_than_ts = args.newer_than_ts, older_than_ts = args.older_than_ts, rest = __rest(args, ["newerThan", "olderThan", "newer_than_ts", "older_than_ts"]);
59
+ var resolvedNewerThan = newerThan ? Math.floor(newerThan.getTime() / 1000) : newer_than_ts;
60
+ var resolvedOlderThan = olderThan ? Math.floor(olderThan.getTime() / 1000) : older_than_ts;
61
+ var params = __assign(__assign(__assign({}, rest), (resolvedNewerThan != null ? { newer_than_ts: resolvedNewerThan } : {})), (resolvedOlderThan != null ? { older_than_ts: resolvedOlderThan } : {}));
59
62
  if (options === null || options === void 0 ? void 0 : options.batch) {
60
63
  return { method: method, url: url, params: params, schema: zod_1.z.array(entities_1.ThreadSchema) };
61
64
  }
@@ -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(),
@@ -76,6 +76,9 @@ exports.GetThreadsArgsSchema = zod_1.z.object({
76
76
  workspaceId: zod_1.z.number(),
77
77
  channelId: zod_1.z.number().nullable().optional(),
78
78
  archived: zod_1.z.boolean().nullable().optional(),
79
+ newerThan: zod_1.z.date().nullable().optional(),
80
+ olderThan: zod_1.z.date().nullable().optional(),
81
+ limit: zod_1.z.number().nullable().optional(),
79
82
  });
80
83
  exports.GetCommentsArgsSchema = zod_1.z.object({
81
84
  threadId: zod_1.z.number(),
@@ -93,5 +96,7 @@ exports.GetOrCreateConversationArgsSchema = zod_1.z.object({
93
96
  userIds: zod_1.z.array(zod_1.z.number()),
94
97
  });
95
98
  exports.AWAY_MODE_TYPES = ['parental', 'vacation', 'sickleave', 'other'];
99
+ // Inbox
100
+ exports.ARCHIVE_FILTER_VALUES = ['active', 'archived', 'all'];
96
101
  // Threads
97
102
  exports.THREAD_ACTIONS = ['close', 'reopen'];
@@ -27,17 +27,22 @@ var InboxClient = /** @class */ (function (_super) {
27
27
  return _super !== null && _super.apply(this, arguments) || this;
28
28
  }
29
29
  InboxClient.prototype.getInbox = function (args, options) {
30
+ var _a, _b;
30
31
  var params = {
31
32
  workspace_id: args.workspaceId,
32
33
  };
33
- if (args.since)
34
- params.newer_than_ts = Math.floor(args.since.getTime() / 1000);
35
- if (args.until)
36
- params.older_than_ts = Math.floor(args.until.getTime() / 1000);
34
+ var newerThan = (_a = args.newerThan) !== null && _a !== void 0 ? _a : args.since;
35
+ if (newerThan)
36
+ params.newer_than_ts = Math.floor(newerThan.getTime() / 1000);
37
+ var olderThan = (_b = args.olderThan) !== null && _b !== void 0 ? _b : args.until;
38
+ if (olderThan)
39
+ params.older_than_ts = Math.floor(olderThan.getTime() / 1000);
37
40
  if (args.limit)
38
41
  params.limit = args.limit;
39
42
  if (args.cursor)
40
43
  params.cursor = args.cursor;
44
+ if (args.archiveFilter)
45
+ params.archive_filter = args.archiveFilter;
41
46
  var method = 'GET';
42
47
  var url = "".concat(ENDPOINT_INBOX, "/get");
43
48
  if (options === null || options === void 0 ? void 0 : options.batch) {
@@ -117,15 +122,15 @@ var InboxClient = /** @class */ (function (_super) {
117
122
  }).then(function () { return undefined; });
118
123
  };
119
124
  InboxClient.prototype.archiveAll = function (args, options) {
125
+ var _a;
120
126
  var params = {
121
127
  workspace_id: args.workspaceId,
122
128
  };
123
129
  if (args.channelIds)
124
130
  params.channel_ids = args.channelIds;
125
- if (args.since)
126
- params.since_ts_or_obj_idx = Math.floor(args.since.getTime() / 1000);
127
- if (args.until)
128
- params.until_ts_or_obj_idx = Math.floor(args.until.getTime() / 1000);
131
+ var olderThan = (_a = args.olderThan) !== null && _a !== void 0 ? _a : args.until;
132
+ if (olderThan)
133
+ params.older_than_ts = Math.floor(olderThan.getTime() / 1000);
129
134
  var method = 'POST';
130
135
  var url = "".concat(ENDPOINT_INBOX, "/archive_all");
131
136
  if (options === null || options === void 0 ? void 0 : options.batch) {
@@ -52,7 +52,10 @@ var ThreadsClient = /** @class */ (function (_super) {
52
52
  ThreadsClient.prototype.getThreads = function (args, options) {
53
53
  var method = 'GET';
54
54
  var url = "".concat(ENDPOINT_THREADS, "/get");
55
- var params = args;
55
+ var newerThan = args.newerThan, olderThan = args.olderThan, newer_than_ts = args.newer_than_ts, older_than_ts = args.older_than_ts, rest = __rest(args, ["newerThan", "olderThan", "newer_than_ts", "older_than_ts"]);
56
+ var resolvedNewerThan = newerThan ? Math.floor(newerThan.getTime() / 1000) : newer_than_ts;
57
+ var resolvedOlderThan = olderThan ? Math.floor(olderThan.getTime() / 1000) : older_than_ts;
58
+ var params = __assign(__assign(__assign({}, rest), (resolvedNewerThan != null ? { newer_than_ts: resolvedNewerThan } : {})), (resolvedOlderThan != null ? { older_than_ts: resolvedOlderThan } : {}));
56
59
  if (options === null || options === void 0 ? void 0 : options.batch) {
57
60
  return { method: method, url: url, params: params, schema: z.array(ThreadSchema) };
58
61
  }
@@ -73,6 +73,9 @@ export var GetThreadsArgsSchema = z.object({
73
73
  workspaceId: z.number(),
74
74
  channelId: z.number().nullable().optional(),
75
75
  archived: z.boolean().nullable().optional(),
76
+ newerThan: z.date().nullable().optional(),
77
+ olderThan: z.date().nullable().optional(),
78
+ limit: z.number().nullable().optional(),
76
79
  });
77
80
  export var GetCommentsArgsSchema = z.object({
78
81
  threadId: z.number(),
@@ -90,5 +93,7 @@ export var GetOrCreateConversationArgsSchema = z.object({
90
93
  userIds: z.array(z.number()),
91
94
  });
92
95
  export var AWAY_MODE_TYPES = ['parental', 'vacation', 'sickleave', 'other'];
96
+ // Inbox
97
+ export var ARCHIVE_FILTER_VALUES = ['active', 'archived', 'all'];
93
98
  // Threads
94
99
  export var THREAD_ACTIONS = ['close', 'reopen'];
@@ -11,10 +11,13 @@ export declare class InboxClient extends BaseClient {
11
11
  *
12
12
  * @param args - The arguments for getting inbox.
13
13
  * @param args.workspaceId - The workspace ID.
14
- * @param args.since - Optional date to get items since.
15
- * @param args.until - Optional date to get items until.
14
+ * @param args.newerThan - Optional date to get items newer than.
15
+ * @param args.olderThan - Optional date to get items older than.
16
+ * @param args.since - @deprecated Use `newerThan` instead.
17
+ * @param args.until - @deprecated Use `olderThan` instead.
16
18
  * @param args.limit - Optional limit on number of items returned.
17
19
  * @param args.cursor - Optional cursor for pagination.
20
+ * @param args.archiveFilter - Optional filter: 'active' (default), 'archived', or 'all'.
18
21
  * @param options - Optional configuration. Set `batch: true` to return a descriptor for batch requests.
19
22
  * @returns Inbox threads.
20
23
  *
@@ -22,7 +25,13 @@ export declare class InboxClient extends BaseClient {
22
25
  * ```typescript
23
26
  * const inbox = await api.inbox.getInbox({
24
27
  * workspaceId: 123,
25
- * since: new Date('2024-01-01')
28
+ * newerThan: new Date('2024-01-01')
29
+ * })
30
+ *
31
+ * // Include archived (done) items alongside active ones
32
+ * const allInbox = await api.inbox.getInbox({
33
+ * workspaceId: 123,
34
+ * archiveFilter: 'all'
26
35
  * })
27
36
  * ```
28
37
  */
@@ -108,15 +117,16 @@ export declare class InboxClient extends BaseClient {
108
117
  * @param args - The arguments for archiving all.
109
118
  * @param args.workspaceId - The workspace ID.
110
119
  * @param args.channelIds - Optional array of channel IDs to filter by.
111
- * @param args.since - Optional date to filter items since.
112
- * @param args.until - Optional date to filter items until.
120
+ * @param args.olderThan - Optional date to filter items older than.
121
+ * @param args.until - @deprecated Use `olderThan` instead.
122
+ * @param args.since - @deprecated Not supported by the archive_all endpoint — this value is ignored.
113
123
  * @param options - Optional configuration. Set `batch: true` to return a descriptor for batch requests.
114
124
  *
115
125
  * @example
116
126
  * ```typescript
117
127
  * await api.inbox.archiveAll({
118
128
  * workspaceId: 123,
119
- * since: new Date('2024-01-01')
129
+ * olderThan: new Date('2024-01-01')
120
130
  * })
121
131
  * ```
122
132
  */
@@ -13,8 +13,10 @@ export declare class ThreadsClient extends BaseClient {
13
13
  * @param args.channelId - The channel ID.
14
14
  * @param args.workspaceId - Optional workspace ID.
15
15
  * @param args.archived - Optional flag to include archived threads.
16
- * @param args.newer_than_ts - Optional timestamp to get threads newer than.
17
- * @param args.older_than_ts - Optional timestamp to get threads older than.
16
+ * @param args.newerThan - Optional date to get threads newer than.
17
+ * @param args.olderThan - Optional date to get threads older than.
18
+ * @param args.newer_than_ts - @deprecated Use `newerThan` instead.
19
+ * @param args.older_than_ts - @deprecated Use `olderThan` instead.
18
20
  * @param args.limit - Optional limit on number of threads returned.
19
21
  * @param options - Optional configuration. Set `batch: true` to return a descriptor for batch requests.
20
22
  * @returns An array of thread objects.
@@ -76,8 +76,18 @@ export declare const GetThreadsArgsSchema: z.ZodObject<{
76
76
  workspaceId: z.ZodNumber;
77
77
  channelId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
78
78
  archived: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
79
+ newerThan: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
80
+ olderThan: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
81
+ limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
79
82
  }, z.core.$strip>;
80
- export type GetThreadsArgs = z.infer<typeof GetThreadsArgsSchema>;
83
+ export type GetThreadsArgs = Omit<z.infer<typeof GetThreadsArgsSchema>, 'newerThan' | 'olderThan'> & {
84
+ newerThan?: Date | null;
85
+ olderThan?: Date | null;
86
+ /** @deprecated Use `newerThan` instead. */
87
+ newer_than_ts?: number | null;
88
+ /** @deprecated Use `olderThan` instead. */
89
+ older_than_ts?: number | null;
90
+ };
81
91
  export declare const GetCommentsArgsSchema: z.ZodObject<{
82
92
  threadId: z.ZodNumber;
83
93
  from: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
@@ -161,18 +171,28 @@ export type UpdateConversationMessageArgs = {
161
171
  content: string;
162
172
  attachments?: unknown[];
163
173
  };
174
+ export declare const ARCHIVE_FILTER_VALUES: readonly ["active", "archived", "all"];
175
+ export type ArchiveFilter = (typeof ARCHIVE_FILTER_VALUES)[number];
164
176
  export type GetInboxArgs = {
165
177
  workspaceId: number;
178
+ newerThan?: Date;
179
+ olderThan?: Date;
180
+ /** @deprecated Use `newerThan` instead. */
166
181
  since?: Date;
182
+ /** @deprecated Use `olderThan` instead. */
167
183
  until?: Date;
168
184
  limit?: number;
169
185
  cursor?: string;
186
+ archiveFilter?: ArchiveFilter;
170
187
  };
171
188
  export type ArchiveAllArgs = {
172
189
  workspaceId: number;
173
190
  channelIds?: number[];
174
- since?: Date;
191
+ olderThan?: Date;
192
+ /** @deprecated Use `olderThan` instead. */
175
193
  until?: Date;
194
+ /** @deprecated Not supported by the archive_all endpoint — this value is ignored. */
195
+ since?: Date;
176
196
  };
177
197
  export type AddReactionArgs = {
178
198
  threadId?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/twist-sdk",
3
- "version": "2.3.1",
3
+ "version": "2.4.1",
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/",