@doist/twist-sdk 2.7.0 → 2.8.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.
- package/dist/cjs/clients/add-comment-helper.js +1 -2
- package/dist/cjs/clients/base-client.js +10 -0
- package/dist/cjs/clients/channels-client.js +9 -6
- package/dist/cjs/clients/comments-client.js +16 -6
- package/dist/cjs/clients/conversation-messages-client.js +9 -8
- package/dist/cjs/clients/conversations-client.js +11 -8
- package/dist/cjs/clients/inbox-client.js +6 -3
- package/dist/cjs/clients/threads-client.js +18 -9
- package/dist/cjs/clients/workspace-users-client.js +9 -2
- package/dist/cjs/clients/workspaces-client.js +7 -3
- package/dist/cjs/types/entities.js +99 -79
- package/dist/esm/clients/add-comment-helper.js +1 -2
- package/dist/esm/clients/base-client.js +10 -0
- package/dist/esm/clients/channels-client.js +10 -7
- package/dist/esm/clients/comments-client.js +17 -7
- package/dist/esm/clients/conversation-messages-client.js +10 -9
- package/dist/esm/clients/conversations-client.js +12 -9
- package/dist/esm/clients/inbox-client.js +7 -4
- package/dist/esm/clients/threads-client.js +19 -10
- package/dist/esm/clients/workspace-users-client.js +9 -2
- package/dist/esm/clients/workspaces-client.js +8 -4
- package/dist/esm/types/entities.js +92 -78
- package/dist/types/clients/add-comment-helper.d.ts +3 -1
- package/dist/types/clients/base-client.d.ts +4 -0
- package/dist/types/clients/channels-client.d.ts +1 -0
- package/dist/types/clients/comments-client.d.ts +1 -0
- package/dist/types/clients/conversation-messages-client.d.ts +1 -0
- package/dist/types/clients/conversations-client.d.ts +1 -0
- package/dist/types/clients/inbox-client.d.ts +1 -0
- package/dist/types/clients/threads-client.d.ts +2 -0
- package/dist/types/clients/workspace-users-client.d.ts +5 -0
- package/dist/types/clients/workspaces-client.d.ts +1 -0
- package/dist/types/types/entities.d.ts +1539 -185
- package/dist/types/types/requests.d.ts +5 -0
- package/package.json +6 -2
|
@@ -38,7 +38,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
38
38
|
import { z } from 'zod';
|
|
39
39
|
import { ENDPOINT_THREADS } from '../consts/endpoints.js';
|
|
40
40
|
import { request } from '../transport/http-client.js';
|
|
41
|
-
import {
|
|
41
|
+
import { createCommentSchema, createThreadSchema, UnreadThreadSchema, } from '../types/entities.js';
|
|
42
42
|
import { addCommentRequest } from './add-comment-helper.js';
|
|
43
43
|
import { BaseClient } from './base-client.js';
|
|
44
44
|
/**
|
|
@@ -47,9 +47,13 @@ import { BaseClient } from './base-client.js';
|
|
|
47
47
|
var ThreadsClient = /** @class */ (function (_super) {
|
|
48
48
|
__extends(ThreadsClient, _super);
|
|
49
49
|
function ThreadsClient() {
|
|
50
|
-
|
|
50
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
51
|
+
_this.threadSchema = createThreadSchema(_this.getLinkBaseUrl());
|
|
52
|
+
_this.commentSchema = createCommentSchema(_this.getLinkBaseUrl());
|
|
53
|
+
return _this;
|
|
51
54
|
}
|
|
52
55
|
ThreadsClient.prototype.getThreads = function (args, options) {
|
|
56
|
+
var _this = this;
|
|
53
57
|
var method = 'GET';
|
|
54
58
|
var url = "".concat(ENDPOINT_THREADS, "/get");
|
|
55
59
|
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"]);
|
|
@@ -57,7 +61,7 @@ var ThreadsClient = /** @class */ (function (_super) {
|
|
|
57
61
|
var resolvedOlderThan = olderThan ? Math.floor(olderThan.getTime() / 1000) : older_than_ts;
|
|
58
62
|
var params = __assign(__assign(__assign({}, rest), (resolvedNewerThan != null ? { newer_than_ts: resolvedNewerThan } : {})), (resolvedOlderThan != null ? { older_than_ts: resolvedOlderThan } : {}));
|
|
59
63
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
60
|
-
return { method: method, url: url, params: params, schema: z.array(
|
|
64
|
+
return { method: method, url: url, params: params, schema: z.array(this.threadSchema) };
|
|
61
65
|
}
|
|
62
66
|
return request({
|
|
63
67
|
httpMethod: method,
|
|
@@ -66,13 +70,13 @@ var ThreadsClient = /** @class */ (function (_super) {
|
|
|
66
70
|
apiToken: this.apiToken,
|
|
67
71
|
payload: params,
|
|
68
72
|
customFetch: this.customFetch,
|
|
69
|
-
}).then(function (response) { return response.data.map(function (thread) { return
|
|
73
|
+
}).then(function (response) { return response.data.map(function (thread) { return _this.threadSchema.parse(thread); }); });
|
|
70
74
|
};
|
|
71
75
|
ThreadsClient.prototype.getThread = function (id, options) {
|
|
72
76
|
var method = 'GET';
|
|
73
77
|
var url = "".concat(ENDPOINT_THREADS, "/getone");
|
|
74
78
|
var params = { id: id };
|
|
75
|
-
var schema =
|
|
79
|
+
var schema = this.threadSchema;
|
|
76
80
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
77
81
|
return { method: method, url: url, params: params, schema: schema };
|
|
78
82
|
}
|
|
@@ -89,7 +93,7 @@ var ThreadsClient = /** @class */ (function (_super) {
|
|
|
89
93
|
var method = 'POST';
|
|
90
94
|
var url = "".concat(ENDPOINT_THREADS, "/add");
|
|
91
95
|
var params = args;
|
|
92
|
-
var schema =
|
|
96
|
+
var schema = this.threadSchema;
|
|
93
97
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
94
98
|
return { method: method, url: url, params: params, schema: schema };
|
|
95
99
|
}
|
|
@@ -106,7 +110,7 @@ var ThreadsClient = /** @class */ (function (_super) {
|
|
|
106
110
|
var method = 'POST';
|
|
107
111
|
var url = "".concat(ENDPOINT_THREADS, "/update");
|
|
108
112
|
var params = args;
|
|
109
|
-
var schema =
|
|
113
|
+
var schema = this.threadSchema;
|
|
110
114
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
111
115
|
return { method: method, url: url, params: params, schema: schema };
|
|
112
116
|
}
|
|
@@ -354,7 +358,7 @@ var ThreadsClient = /** @class */ (function (_super) {
|
|
|
354
358
|
var method = 'POST';
|
|
355
359
|
var url = "".concat(ENDPOINT_THREADS, "/mute");
|
|
356
360
|
var params = { id: args.id, minutes: args.minutes };
|
|
357
|
-
var schema =
|
|
361
|
+
var schema = this.threadSchema;
|
|
358
362
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
359
363
|
return { method: method, url: url, params: params, schema: schema };
|
|
360
364
|
}
|
|
@@ -371,7 +375,7 @@ var ThreadsClient = /** @class */ (function (_super) {
|
|
|
371
375
|
var method = 'POST';
|
|
372
376
|
var url = "".concat(ENDPOINT_THREADS, "/unmute");
|
|
373
377
|
var params = { id: id };
|
|
374
|
-
var schema =
|
|
378
|
+
var schema = this.threadSchema;
|
|
375
379
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
376
380
|
return { method: method, url: url, params: params, schema: schema };
|
|
377
381
|
}
|
|
@@ -392,7 +396,12 @@ var ThreadsClient = /** @class */ (function (_super) {
|
|
|
392
396
|
};
|
|
393
397
|
ThreadsClient.prototype.addCommentWithAction = function (args, threadAction, options) {
|
|
394
398
|
var id = args.id, rest = __rest(args, ["id"]);
|
|
395
|
-
return addCommentRequest({
|
|
399
|
+
return addCommentRequest({
|
|
400
|
+
baseUri: this.getBaseUri(),
|
|
401
|
+
apiToken: this.apiToken,
|
|
402
|
+
customFetch: this.customFetch,
|
|
403
|
+
schema: this.commentSchema,
|
|
404
|
+
}, __assign({ threadId: id }, rest), __assign(__assign({}, options), { threadAction: threadAction }));
|
|
396
405
|
};
|
|
397
406
|
return ThreadsClient;
|
|
398
407
|
}(BaseClient));
|
|
@@ -13,6 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
+
import { z } from 'zod';
|
|
16
17
|
import { request } from '../transport/http-client.js';
|
|
17
18
|
import { WorkspaceUserSchema } from '../types/entities.js';
|
|
18
19
|
import { BaseClient } from './base-client.js';
|
|
@@ -25,11 +26,17 @@ var WorkspaceUsersClient = /** @class */ (function (_super) {
|
|
|
25
26
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
26
27
|
}
|
|
27
28
|
WorkspaceUsersClient.prototype.getWorkspaceUsers = function (args, options) {
|
|
29
|
+
var _a;
|
|
28
30
|
var method = 'GET';
|
|
29
31
|
var url = 'workspace_users/get';
|
|
30
32
|
var params = { id: args.workspaceId, archived: args.archived };
|
|
33
|
+
var includeRemoved = (_a = args.includeRemoved) !== null && _a !== void 0 ? _a : false;
|
|
34
|
+
function filterRemoved(users) {
|
|
35
|
+
return includeRemoved ? users : users.filter(function (user) { return !user.removed; });
|
|
36
|
+
}
|
|
37
|
+
var responseSchema = z.array(WorkspaceUserSchema).transform(filterRemoved);
|
|
31
38
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
32
|
-
return { method: method, url: url, params: params };
|
|
39
|
+
return { method: method, url: url, params: params, schema: responseSchema };
|
|
33
40
|
}
|
|
34
41
|
return request({
|
|
35
42
|
httpMethod: method,
|
|
@@ -38,7 +45,7 @@ var WorkspaceUsersClient = /** @class */ (function (_super) {
|
|
|
38
45
|
apiToken: this.apiToken,
|
|
39
46
|
payload: params,
|
|
40
47
|
customFetch: this.customFetch,
|
|
41
|
-
}).then(function (response) { return response.data
|
|
48
|
+
}).then(function (response) { return responseSchema.parse(response.data); });
|
|
42
49
|
};
|
|
43
50
|
WorkspaceUsersClient.prototype.getWorkspaceUserIds = function (workspaceId, options) {
|
|
44
51
|
var method = 'GET';
|
|
@@ -13,9 +13,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
+
import { z } from 'zod';
|
|
16
17
|
import { ENDPOINT_WORKSPACES } from '../consts/endpoints.js';
|
|
17
18
|
import { request } from '../transport/http-client.js';
|
|
18
|
-
import {
|
|
19
|
+
import { createChannelSchema, WorkspaceSchema } from '../types/entities.js';
|
|
19
20
|
import { BaseClient } from './base-client.js';
|
|
20
21
|
/**
|
|
21
22
|
* Client for interacting with Twist workspace endpoints.
|
|
@@ -23,7 +24,9 @@ import { BaseClient } from './base-client.js';
|
|
|
23
24
|
var WorkspacesClient = /** @class */ (function (_super) {
|
|
24
25
|
__extends(WorkspacesClient, _super);
|
|
25
26
|
function WorkspacesClient() {
|
|
26
|
-
|
|
27
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
28
|
+
_this.channelSchema = createChannelSchema(_this.getLinkBaseUrl());
|
|
29
|
+
return _this;
|
|
27
30
|
}
|
|
28
31
|
WorkspacesClient.prototype.getWorkspaces = function (options) {
|
|
29
32
|
var method = 'GET';
|
|
@@ -126,11 +129,12 @@ var WorkspacesClient = /** @class */ (function (_super) {
|
|
|
126
129
|
}).then(function () { return undefined; });
|
|
127
130
|
};
|
|
128
131
|
WorkspacesClient.prototype.getPublicChannels = function (id, options) {
|
|
132
|
+
var _this = this;
|
|
129
133
|
var method = 'GET';
|
|
130
134
|
var url = "".concat(ENDPOINT_WORKSPACES, "/get_public_channels");
|
|
131
135
|
var params = { id: id };
|
|
132
136
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
133
|
-
return { method: method, url: url, params: params };
|
|
137
|
+
return { method: method, url: url, params: params, schema: z.array(this.channelSchema) };
|
|
134
138
|
}
|
|
135
139
|
return request({
|
|
136
140
|
httpMethod: method,
|
|
@@ -139,7 +143,7 @@ var WorkspacesClient = /** @class */ (function (_super) {
|
|
|
139
143
|
apiToken: this.apiToken,
|
|
140
144
|
payload: params,
|
|
141
145
|
customFetch: this.customFetch,
|
|
142
|
-
}).then(function (response) { return response.data.map(function (channel) { return
|
|
146
|
+
}).then(function (response) { return response.data.map(function (channel) { return _this.channelSchema.parse(channel); }); });
|
|
143
147
|
};
|
|
144
148
|
return WorkspacesClient;
|
|
145
149
|
}(BaseClient));
|
|
@@ -109,8 +109,7 @@ export var WorkspaceSchema = z.object({
|
|
|
109
109
|
plan: z.enum(WORKSPACE_PLANS).nullable().optional(),
|
|
110
110
|
});
|
|
111
111
|
// Channel entity from API
|
|
112
|
-
export var
|
|
113
|
-
.object({
|
|
112
|
+
export var ChannelObjectSchema = z.object({
|
|
114
113
|
id: z.number(),
|
|
115
114
|
name: z.string(),
|
|
116
115
|
description: z.string().nullable().optional(),
|
|
@@ -128,11 +127,13 @@ export var ChannelSchema = z
|
|
|
128
127
|
icon: z.number().nullable().optional(),
|
|
129
128
|
version: z.number(),
|
|
130
129
|
filters: z.record(z.string(), z.string()).nullable().optional(),
|
|
131
|
-
})
|
|
132
|
-
|
|
130
|
+
});
|
|
131
|
+
export function createChannelSchema(linkBaseUrl) {
|
|
132
|
+
return ChannelObjectSchema.transform(function (data) { return (__assign(__assign({}, data), { url: getFullTwistURL({ workspaceId: data.workspaceId, channelId: data.id }, linkBaseUrl) })); });
|
|
133
|
+
}
|
|
134
|
+
export var ChannelSchema = createChannelSchema();
|
|
133
135
|
// Thread entity from API
|
|
134
|
-
export var
|
|
135
|
-
.object({
|
|
136
|
+
export var ThreadObjectSchema = z.object({
|
|
136
137
|
id: z.number(),
|
|
137
138
|
title: z.string(),
|
|
138
139
|
content: z.string(),
|
|
@@ -195,12 +196,15 @@ export var ThreadSchema = z
|
|
|
195
196
|
})
|
|
196
197
|
.nullable()
|
|
197
198
|
.optional(),
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
199
|
+
});
|
|
200
|
+
export function createThreadSchema(linkBaseUrl) {
|
|
201
|
+
return ThreadObjectSchema.transform(function (data) { return (__assign(__assign({}, data), { url: getFullTwistURL({
|
|
202
|
+
workspaceId: data.workspaceId,
|
|
203
|
+
channelId: data.channelId,
|
|
204
|
+
threadId: data.id,
|
|
205
|
+
}, linkBaseUrl) })); });
|
|
206
|
+
}
|
|
207
|
+
export var ThreadSchema = createThreadSchema();
|
|
204
208
|
// Group entity from API
|
|
205
209
|
export var GroupSchema = z.object({
|
|
206
210
|
id: z.number(),
|
|
@@ -211,8 +215,7 @@ export var GroupSchema = z.object({
|
|
|
211
215
|
version: z.number(),
|
|
212
216
|
});
|
|
213
217
|
// Conversation entity from API
|
|
214
|
-
export var
|
|
215
|
-
.object({
|
|
218
|
+
export var ConversationObjectSchema = z.object({
|
|
216
219
|
id: z.number(),
|
|
217
220
|
workspaceId: z.number(),
|
|
218
221
|
userIds: z.array(z.number()),
|
|
@@ -248,11 +251,13 @@ export var ConversationSchema = z
|
|
|
248
251
|
})
|
|
249
252
|
.nullable()
|
|
250
253
|
.optional(),
|
|
251
|
-
})
|
|
252
|
-
|
|
254
|
+
});
|
|
255
|
+
export function createConversationSchema(linkBaseUrl) {
|
|
256
|
+
return ConversationObjectSchema.transform(function (data) { return (__assign(__assign({}, data), { url: getFullTwistURL({ workspaceId: data.workspaceId, conversationId: data.id }, linkBaseUrl) })); });
|
|
257
|
+
}
|
|
258
|
+
export var ConversationSchema = createConversationSchema();
|
|
253
259
|
// Comment entity from API
|
|
254
|
-
export var
|
|
255
|
-
.object({
|
|
260
|
+
export var CommentObjectSchema = z.object({
|
|
256
261
|
id: z.number(),
|
|
257
262
|
content: z.string(),
|
|
258
263
|
creator: z.number(),
|
|
@@ -277,13 +282,16 @@ export var CommentSchema = z
|
|
|
277
282
|
deletedBy: z.number().nullable().optional(),
|
|
278
283
|
version: z.number().nullable().optional(),
|
|
279
284
|
actions: z.array(z.unknown()).nullable().optional(),
|
|
280
|
-
})
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
285
|
+
});
|
|
286
|
+
export function createCommentSchema(linkBaseUrl) {
|
|
287
|
+
return CommentObjectSchema.transform(function (data) { return (__assign(__assign({}, data), { url: getFullTwistURL({
|
|
288
|
+
workspaceId: data.workspaceId,
|
|
289
|
+
channelId: data.channelId,
|
|
290
|
+
threadId: data.threadId,
|
|
291
|
+
commentId: data.id,
|
|
292
|
+
}, linkBaseUrl) })); });
|
|
293
|
+
}
|
|
294
|
+
export var CommentSchema = createCommentSchema();
|
|
287
295
|
// WorkspaceUser entity from v4 API
|
|
288
296
|
export var WorkspaceUserSchema = BaseUserSchema.extend({
|
|
289
297
|
email: z.string().nullable().optional(),
|
|
@@ -295,8 +303,7 @@ export var WorkspaceUserSchema = BaseUserSchema.extend({
|
|
|
295
303
|
version: z.number(),
|
|
296
304
|
});
|
|
297
305
|
// ConversationMessage entity from API
|
|
298
|
-
export var
|
|
299
|
-
.object({
|
|
306
|
+
export var ConversationMessageObjectSchema = z.object({
|
|
300
307
|
id: z.number(),
|
|
301
308
|
content: z.string(),
|
|
302
309
|
creator: z.number(),
|
|
@@ -313,58 +320,65 @@ export var ConversationMessageSchema = z
|
|
|
313
320
|
directMentions: z.array(z.number()).nullable().optional(),
|
|
314
321
|
version: z.number().nullable().optional(),
|
|
315
322
|
workspaceId: z.number(),
|
|
316
|
-
})
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
323
|
+
});
|
|
324
|
+
export function createConversationMessageSchema(linkBaseUrl) {
|
|
325
|
+
return ConversationMessageObjectSchema.transform(function (data) { return (__assign(__assign({}, data), { url: getFullTwistURL({
|
|
326
|
+
workspaceId: data.workspaceId,
|
|
327
|
+
conversationId: data.conversationId,
|
|
328
|
+
messageId: data.id,
|
|
329
|
+
}, linkBaseUrl) })); });
|
|
330
|
+
}
|
|
331
|
+
export var ConversationMessageSchema = createConversationMessageSchema();
|
|
322
332
|
// InboxThread entity from API - returns full Thread objects with additional inbox metadata
|
|
323
|
-
|
|
324
|
-
.object({
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
})
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
333
|
+
function createInboxThreadObjectSchema(linkBaseUrl) {
|
|
334
|
+
return z.object({
|
|
335
|
+
id: z.number(),
|
|
336
|
+
title: z.string(),
|
|
337
|
+
content: z.string(),
|
|
338
|
+
creator: z.number(),
|
|
339
|
+
creatorName: z.string().nullable().optional(),
|
|
340
|
+
channelId: z.number(),
|
|
341
|
+
workspaceId: z.number(),
|
|
342
|
+
actions: z.array(z.unknown()).nullable().optional(),
|
|
343
|
+
attachments: z.array(AttachmentSchema).nullable().optional(),
|
|
344
|
+
commentCount: z.number(),
|
|
345
|
+
directGroupMentions: z.array(z.number()).nullable().optional(),
|
|
346
|
+
directMentions: z.array(z.number()).nullable().optional(),
|
|
347
|
+
groups: z.array(z.number()).nullable().optional(),
|
|
348
|
+
lastEdited: z.date().nullable().optional(),
|
|
349
|
+
lastObjIndex: z.number().nullable().optional(),
|
|
350
|
+
lastUpdated: z.date(),
|
|
351
|
+
mutedUntil: z.date().nullable().optional(),
|
|
352
|
+
participants: z.array(z.number()).nullable().optional(),
|
|
353
|
+
pinned: z.boolean(),
|
|
354
|
+
pinnedDate: z.date().nullable().optional(),
|
|
355
|
+
posted: z.date(),
|
|
356
|
+
reactions: z.record(z.string(), z.array(z.number())).nullable().optional(),
|
|
357
|
+
recipients: z.array(z.number()).nullable().optional(),
|
|
358
|
+
snippet: z.string(),
|
|
359
|
+
snippetCreator: z.number(),
|
|
360
|
+
snippetMaskAvatarUrl: z.string().nullable().optional(),
|
|
361
|
+
snippetMaskPoster: z.string().nullable().optional(),
|
|
362
|
+
starred: z.boolean(),
|
|
363
|
+
systemMessage: SystemMessageSchema,
|
|
364
|
+
isArchived: z.boolean(),
|
|
365
|
+
inInbox: z.boolean(),
|
|
366
|
+
isSaved: z.boolean().nullable().optional(),
|
|
367
|
+
closed: z.boolean(),
|
|
368
|
+
responders: z.array(z.number()).nullable().optional(),
|
|
369
|
+
lastComment: createCommentSchema(linkBaseUrl).nullable().optional(),
|
|
370
|
+
toEmails: z.array(z.string()).nullable().optional(),
|
|
371
|
+
version: z.number().nullable().optional(),
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
export function createInboxThreadSchema(linkBaseUrl) {
|
|
375
|
+
return createInboxThreadObjectSchema(linkBaseUrl).transform(function (data) { return (__assign(__assign({}, data), { url: getFullTwistURL({
|
|
376
|
+
workspaceId: data.workspaceId,
|
|
377
|
+
channelId: data.channelId,
|
|
378
|
+
threadId: data.id,
|
|
379
|
+
}, linkBaseUrl) })); });
|
|
380
|
+
}
|
|
381
|
+
export var InboxThreadSchema = createInboxThreadSchema();
|
|
368
382
|
// UnreadThread entity from API - simplified thread reference for unread threads
|
|
369
383
|
export var UnreadThreadSchema = z.object({
|
|
370
384
|
threadId: z.number(),
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { BatchRequestDescriptor } from '../types/batch.js';
|
|
2
|
-
import { type Comment } from '../types/entities.js';
|
|
2
|
+
import { type Comment, type createCommentSchema } from '../types/entities.js';
|
|
3
3
|
import type { CustomFetch } from '../types/http.js';
|
|
4
4
|
import type { CreateCommentArgs, ThreadAction } from '../types/requests.js';
|
|
5
5
|
type ClientContext = {
|
|
6
6
|
baseUri: string;
|
|
7
7
|
apiToken: string;
|
|
8
8
|
customFetch?: CustomFetch;
|
|
9
|
+
/** Per-client Comment schema, base-bound for the returned comment's web `url`. */
|
|
10
|
+
schema: ReturnType<typeof createCommentSchema>;
|
|
9
11
|
};
|
|
10
12
|
export declare function addCommentRequest(context: ClientContext, params: CreateCommentArgs, options?: {
|
|
11
13
|
batch?: boolean;
|
|
@@ -28,4 +28,8 @@ export declare class BaseClient {
|
|
|
28
28
|
* @returns Base URI with guaranteed trailing slash for proper URL resolution
|
|
29
29
|
*/
|
|
30
30
|
protected getBaseUri(version?: ApiVersion): string;
|
|
31
|
+
/**
|
|
32
|
+
* Base URL for entity web links, or `undefined` to use getFullTwistURL's default web app.
|
|
33
|
+
*/
|
|
34
|
+
protected getLinkBaseUrl(): string | undefined;
|
|
31
35
|
}
|
|
@@ -6,6 +6,7 @@ import { BaseClient } from './base-client.js';
|
|
|
6
6
|
* Client for interacting with Twist conversation message endpoints.
|
|
7
7
|
*/
|
|
8
8
|
export declare class ConversationMessagesClient extends BaseClient {
|
|
9
|
+
private readonly messageSchema;
|
|
9
10
|
/**
|
|
10
11
|
* Gets all messages in a conversation.
|
|
11
12
|
*
|
|
@@ -6,6 +6,7 @@ import { BaseClient } from './base-client.js';
|
|
|
6
6
|
* Client for interacting with Twist conversation endpoints.
|
|
7
7
|
*/
|
|
8
8
|
export declare class ConversationsClient extends BaseClient {
|
|
9
|
+
private readonly conversationSchema;
|
|
9
10
|
/**
|
|
10
11
|
* Gets all conversations for a workspace.
|
|
11
12
|
*
|
|
@@ -6,6 +6,8 @@ import { BaseClient } from './base-client.js';
|
|
|
6
6
|
* Client for interacting with Twist thread endpoints.
|
|
7
7
|
*/
|
|
8
8
|
export declare class ThreadsClient extends BaseClient {
|
|
9
|
+
private readonly threadSchema;
|
|
10
|
+
private readonly commentSchema;
|
|
9
11
|
/**
|
|
10
12
|
* Gets all threads in a channel.
|
|
11
13
|
*
|
|
@@ -10,9 +10,14 @@ export declare class WorkspaceUsersClient extends BaseClient {
|
|
|
10
10
|
/**
|
|
11
11
|
* Returns a list of workspace user objects for the given workspace id.
|
|
12
12
|
*
|
|
13
|
+
* Removed users are excluded by default; set `args.includeRemoved` to `true` to include them.
|
|
14
|
+
* The Twist API always returns removed users, so the filtering happens client-side (in both the
|
|
15
|
+
* awaited and batch modes).
|
|
16
|
+
*
|
|
13
17
|
* @param args - The arguments for getting workspace users.
|
|
14
18
|
* @param args.workspaceId - The workspace ID.
|
|
15
19
|
* @param args.archived - Optional flag to filter archived users.
|
|
20
|
+
* @param args.includeRemoved - Include users removed from the workspace. Defaults to `false`.
|
|
16
21
|
* @param options - Optional configuration. Set `batch: true` to return a descriptor for batch requests.
|
|
17
22
|
* @returns An array of workspace user objects.
|
|
18
23
|
*
|