@doist/twist-sdk 2.4.0 → 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,13 +30,16 @@ 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)
@@ -122,15 +125,15 @@ var InboxClient = /** @class */ (function (_super) {
122
125
  }).then(function () { return undefined; });
123
126
  };
124
127
  InboxClient.prototype.archiveAll = function (args, options) {
128
+ var _a;
125
129
  var params = {
126
130
  workspace_id: args.workspaceId,
127
131
  };
128
132
  if (args.channelIds)
129
133
  params.channel_ids = args.channelIds;
130
- if (args.since)
131
- params.since_ts_or_obj_idx = Math.floor(args.since.getTime() / 1000);
132
- if (args.until)
133
- 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);
134
137
  var method = 'POST';
135
138
  var url = "".concat(endpoints_1.ENDPOINT_INBOX, "/archive_all");
136
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
  }
@@ -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(),
@@ -27,13 +27,16 @@ 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)
@@ -119,15 +122,15 @@ var InboxClient = /** @class */ (function (_super) {
119
122
  }).then(function () { return undefined; });
120
123
  };
121
124
  InboxClient.prototype.archiveAll = function (args, options) {
125
+ var _a;
122
126
  var params = {
123
127
  workspace_id: args.workspaceId,
124
128
  };
125
129
  if (args.channelIds)
126
130
  params.channel_ids = args.channelIds;
127
- if (args.since)
128
- params.since_ts_or_obj_idx = Math.floor(args.since.getTime() / 1000);
129
- if (args.until)
130
- 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);
131
134
  var method = 'POST';
132
135
  var url = "".concat(ENDPOINT_INBOX, "/archive_all");
133
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(),
@@ -11,8 +11,10 @@ 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.
18
20
  * @param args.archiveFilter - Optional filter: 'active' (default), 'archived', or 'all'.
@@ -23,7 +25,7 @@ export declare class InboxClient extends BaseClient {
23
25
  * ```typescript
24
26
  * const inbox = await api.inbox.getInbox({
25
27
  * workspaceId: 123,
26
- * since: new Date('2024-01-01')
28
+ * newerThan: new Date('2024-01-01')
27
29
  * })
28
30
  *
29
31
  * // Include archived (done) items alongside active ones
@@ -115,15 +117,16 @@ export declare class InboxClient extends BaseClient {
115
117
  * @param args - The arguments for archiving all.
116
118
  * @param args.workspaceId - The workspace ID.
117
119
  * @param args.channelIds - Optional array of channel IDs to filter by.
118
- * @param args.since - Optional date to filter items since.
119
- * @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.
120
123
  * @param options - Optional configuration. Set `batch: true` to return a descriptor for batch requests.
121
124
  *
122
125
  * @example
123
126
  * ```typescript
124
127
  * await api.inbox.archiveAll({
125
128
  * workspaceId: 123,
126
- * since: new Date('2024-01-01')
129
+ * olderThan: new Date('2024-01-01')
127
130
  * })
128
131
  * ```
129
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>>;
@@ -165,7 +175,11 @@ export declare const ARCHIVE_FILTER_VALUES: readonly ["active", "archived", "all
165
175
  export type ArchiveFilter = (typeof ARCHIVE_FILTER_VALUES)[number];
166
176
  export type GetInboxArgs = {
167
177
  workspaceId: number;
178
+ newerThan?: Date;
179
+ olderThan?: Date;
180
+ /** @deprecated Use `newerThan` instead. */
168
181
  since?: Date;
182
+ /** @deprecated Use `olderThan` instead. */
169
183
  until?: Date;
170
184
  limit?: number;
171
185
  cursor?: string;
@@ -174,8 +188,11 @@ export type GetInboxArgs = {
174
188
  export type ArchiveAllArgs = {
175
189
  workspaceId: number;
176
190
  channelIds?: number[];
177
- since?: Date;
191
+ olderThan?: Date;
192
+ /** @deprecated Use `olderThan` instead. */
178
193
  until?: Date;
194
+ /** @deprecated Not supported by the archive_all endpoint — this value is ignored. */
195
+ since?: Date;
179
196
  };
180
197
  export type AddReactionArgs = {
181
198
  threadId?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/twist-sdk",
3
- "version": "2.4.0",
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/",