@doist/twist-sdk 2.7.0 → 2.9.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.
- package/dist/cjs/clients/add-comment-helper.js +1 -2
- package/dist/cjs/clients/attachments-client.js +124 -0
- 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/consts/endpoints.js +2 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/twist-api.js +2 -0
- package/dist/cjs/types/entities.js +99 -79
- package/dist/cjs/utils/multipart-upload.js +154 -0
- package/dist/esm/clients/add-comment-helper.js +1 -2
- package/dist/esm/clients/attachments-client.js +121 -0
- 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/consts/endpoints.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/twist-api.js +2 -0
- package/dist/esm/types/entities.js +92 -78
- package/dist/esm/utils/multipart-upload.js +150 -0
- package/dist/types/clients/add-comment-helper.d.ts +3 -1
- package/dist/types/clients/attachments-client.d.ts +39 -0
- 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/consts/endpoints.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/twist-api.d.ts +2 -0
- package/dist/types/types/entities.d.ts +1539 -185
- package/dist/types/types/requests.d.ts +22 -0
- package/dist/types/utils/multipart-upload.d.ts +53 -0
- package/package.json +6 -2
|
@@ -16,7 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
import { z } from 'zod';
|
|
17
17
|
import { ENDPOINT_COMMENTS } from '../consts/endpoints.js';
|
|
18
18
|
import { request } from '../transport/http-client.js';
|
|
19
|
-
import {
|
|
19
|
+
import { createCommentSchema } from '../types/entities.js';
|
|
20
20
|
import { addCommentRequest } from './add-comment-helper.js';
|
|
21
21
|
import { BaseClient } from './base-client.js';
|
|
22
22
|
/**
|
|
@@ -25,9 +25,12 @@ import { BaseClient } from './base-client.js';
|
|
|
25
25
|
var CommentsClient = /** @class */ (function (_super) {
|
|
26
26
|
__extends(CommentsClient, _super);
|
|
27
27
|
function CommentsClient() {
|
|
28
|
-
|
|
28
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
29
|
+
_this.commentSchema = createCommentSchema(_this.getLinkBaseUrl());
|
|
30
|
+
return _this;
|
|
29
31
|
}
|
|
30
32
|
CommentsClient.prototype.getComments = function (args, options) {
|
|
33
|
+
var _this = this;
|
|
31
34
|
var _a;
|
|
32
35
|
var params = {
|
|
33
36
|
thread_id: args.threadId,
|
|
@@ -42,7 +45,7 @@ var CommentsClient = /** @class */ (function (_super) {
|
|
|
42
45
|
var method = 'GET';
|
|
43
46
|
var url = "".concat(ENDPOINT_COMMENTS, "/get");
|
|
44
47
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
45
|
-
return { method: method, url: url, params: params, schema: z.array(
|
|
48
|
+
return { method: method, url: url, params: params, schema: z.array(this.commentSchema) };
|
|
46
49
|
}
|
|
47
50
|
return request({
|
|
48
51
|
httpMethod: method,
|
|
@@ -51,14 +54,16 @@ var CommentsClient = /** @class */ (function (_super) {
|
|
|
51
54
|
apiToken: this.apiToken,
|
|
52
55
|
payload: params,
|
|
53
56
|
customFetch: this.customFetch,
|
|
54
|
-
}).then(function (response) { return response.data.map(function (comment) { return
|
|
57
|
+
}).then(function (response) { return response.data.map(function (comment) { return _this.commentSchema.parse(comment); }); });
|
|
55
58
|
};
|
|
56
59
|
CommentsClient.prototype.getComment = function (id, options) {
|
|
57
60
|
var method = 'GET';
|
|
58
61
|
var url = "".concat(ENDPOINT_COMMENTS, "/getone");
|
|
59
62
|
var params = { id: id };
|
|
60
63
|
// The API wraps the response in {"comment": {...}}, so we need to unwrap it
|
|
61
|
-
var wrappedSchema = z
|
|
64
|
+
var wrappedSchema = z
|
|
65
|
+
.object({ comment: this.commentSchema })
|
|
66
|
+
.transform(function (data) { return data.comment; });
|
|
62
67
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
63
68
|
return { method: method, url: url, params: params, schema: wrappedSchema };
|
|
64
69
|
}
|
|
@@ -72,13 +77,18 @@ var CommentsClient = /** @class */ (function (_super) {
|
|
|
72
77
|
}).then(function (response) { return wrappedSchema.parse(response.data); });
|
|
73
78
|
};
|
|
74
79
|
CommentsClient.prototype.createComment = function (args, options) {
|
|
75
|
-
return addCommentRequest({
|
|
80
|
+
return addCommentRequest({
|
|
81
|
+
baseUri: this.getBaseUri(),
|
|
82
|
+
apiToken: this.apiToken,
|
|
83
|
+
customFetch: this.customFetch,
|
|
84
|
+
schema: this.commentSchema,
|
|
85
|
+
}, args, options);
|
|
76
86
|
};
|
|
77
87
|
CommentsClient.prototype.updateComment = function (args, options) {
|
|
78
88
|
var method = 'POST';
|
|
79
89
|
var url = "".concat(ENDPOINT_COMMENTS, "/update");
|
|
80
90
|
var params = args;
|
|
81
|
-
var schema =
|
|
91
|
+
var schema = this.commentSchema;
|
|
82
92
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
83
93
|
return { method: method, url: url, params: params, schema: schema };
|
|
84
94
|
}
|
|
@@ -16,7 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
import { z } from 'zod';
|
|
17
17
|
import { ENDPOINT_CONVERSATION_MESSAGES } from '../consts/endpoints.js';
|
|
18
18
|
import { request } from '../transport/http-client.js';
|
|
19
|
-
import {
|
|
19
|
+
import { createConversationMessageSchema } from '../types/entities.js';
|
|
20
20
|
import { BaseClient } from './base-client.js';
|
|
21
21
|
/**
|
|
22
22
|
* Client for interacting with Twist conversation message endpoints.
|
|
@@ -24,9 +24,12 @@ import { BaseClient } from './base-client.js';
|
|
|
24
24
|
var ConversationMessagesClient = /** @class */ (function (_super) {
|
|
25
25
|
__extends(ConversationMessagesClient, _super);
|
|
26
26
|
function ConversationMessagesClient() {
|
|
27
|
-
|
|
27
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
28
|
+
_this.messageSchema = createConversationMessageSchema(_this.getLinkBaseUrl());
|
|
29
|
+
return _this;
|
|
28
30
|
}
|
|
29
31
|
ConversationMessagesClient.prototype.getMessages = function (args, options) {
|
|
32
|
+
var _this = this;
|
|
30
33
|
var params = {
|
|
31
34
|
conversation_id: args.conversationId,
|
|
32
35
|
};
|
|
@@ -41,7 +44,7 @@ var ConversationMessagesClient = /** @class */ (function (_super) {
|
|
|
41
44
|
var method = 'GET';
|
|
42
45
|
var url = "".concat(ENDPOINT_CONVERSATION_MESSAGES, "/get");
|
|
43
46
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
44
|
-
return { method: method, url: url, params: params, schema: z.array(
|
|
47
|
+
return { method: method, url: url, params: params, schema: z.array(this.messageSchema) };
|
|
45
48
|
}
|
|
46
49
|
return request({
|
|
47
50
|
httpMethod: method,
|
|
@@ -50,15 +53,13 @@ var ConversationMessagesClient = /** @class */ (function (_super) {
|
|
|
50
53
|
apiToken: this.apiToken,
|
|
51
54
|
payload: params,
|
|
52
55
|
customFetch: this.customFetch,
|
|
53
|
-
}).then(function (response) {
|
|
54
|
-
return response.data.map(function (message) { return ConversationMessageSchema.parse(message); });
|
|
55
|
-
});
|
|
56
|
+
}).then(function (response) { return response.data.map(function (message) { return _this.messageSchema.parse(message); }); });
|
|
56
57
|
};
|
|
57
58
|
ConversationMessagesClient.prototype.getMessage = function (id, options) {
|
|
58
59
|
var method = 'GET';
|
|
59
60
|
var url = "".concat(ENDPOINT_CONVERSATION_MESSAGES, "/getone");
|
|
60
61
|
var params = { id: id };
|
|
61
|
-
var schema =
|
|
62
|
+
var schema = this.messageSchema;
|
|
62
63
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
63
64
|
return { method: method, url: url, params: params, schema: schema };
|
|
64
65
|
}
|
|
@@ -82,7 +83,7 @@ var ConversationMessagesClient = /** @class */ (function (_super) {
|
|
|
82
83
|
params.actions = args.actions;
|
|
83
84
|
var method = 'POST';
|
|
84
85
|
var url = "".concat(ENDPOINT_CONVERSATION_MESSAGES, "/add");
|
|
85
|
-
var schema =
|
|
86
|
+
var schema = this.messageSchema;
|
|
86
87
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
87
88
|
return { method: method, url: url, params: params, schema: schema };
|
|
88
89
|
}
|
|
@@ -104,7 +105,7 @@ var ConversationMessagesClient = /** @class */ (function (_super) {
|
|
|
104
105
|
params.attachments = args.attachments;
|
|
105
106
|
var method = 'POST';
|
|
106
107
|
var url = "".concat(ENDPOINT_CONVERSATION_MESSAGES, "/update");
|
|
107
|
-
var schema =
|
|
108
|
+
var schema = this.messageSchema;
|
|
108
109
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
109
110
|
return { method: method, url: url, params: params, schema: schema };
|
|
110
111
|
}
|
|
@@ -16,7 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
import { z } from 'zod';
|
|
17
17
|
import { ENDPOINT_CONVERSATIONS } from '../consts/endpoints.js';
|
|
18
18
|
import { request } from '../transport/http-client.js';
|
|
19
|
-
import {
|
|
19
|
+
import { createConversationSchema, UnreadConversationSchema, } from '../types/entities.js';
|
|
20
20
|
import { BaseClient } from './base-client.js';
|
|
21
21
|
/**
|
|
22
22
|
* Client for interacting with Twist conversation endpoints.
|
|
@@ -24,14 +24,17 @@ import { BaseClient } from './base-client.js';
|
|
|
24
24
|
var ConversationsClient = /** @class */ (function (_super) {
|
|
25
25
|
__extends(ConversationsClient, _super);
|
|
26
26
|
function ConversationsClient() {
|
|
27
|
-
|
|
27
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
28
|
+
_this.conversationSchema = createConversationSchema(_this.getLinkBaseUrl());
|
|
29
|
+
return _this;
|
|
28
30
|
}
|
|
29
31
|
ConversationsClient.prototype.getConversations = function (args, options) {
|
|
32
|
+
var _this = this;
|
|
30
33
|
var method = 'GET';
|
|
31
34
|
var url = "".concat(ENDPOINT_CONVERSATIONS, "/get");
|
|
32
35
|
var params = args;
|
|
33
36
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
34
|
-
return { method: method, url: url, params: params, schema: z.array(
|
|
37
|
+
return { method: method, url: url, params: params, schema: z.array(this.conversationSchema) };
|
|
35
38
|
}
|
|
36
39
|
return request({
|
|
37
40
|
httpMethod: method,
|
|
@@ -41,14 +44,14 @@ var ConversationsClient = /** @class */ (function (_super) {
|
|
|
41
44
|
payload: params,
|
|
42
45
|
customFetch: this.customFetch,
|
|
43
46
|
}).then(function (response) {
|
|
44
|
-
return response.data.map(function (conversation) { return
|
|
47
|
+
return response.data.map(function (conversation) { return _this.conversationSchema.parse(conversation); });
|
|
45
48
|
});
|
|
46
49
|
};
|
|
47
50
|
ConversationsClient.prototype.getConversation = function (id, options) {
|
|
48
51
|
var method = 'GET';
|
|
49
52
|
var url = "".concat(ENDPOINT_CONVERSATIONS, "/getone");
|
|
50
53
|
var params = { id: id };
|
|
51
|
-
var schema =
|
|
54
|
+
var schema = this.conversationSchema;
|
|
52
55
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
53
56
|
return { method: method, url: url, params: params, schema: schema };
|
|
54
57
|
}
|
|
@@ -65,7 +68,7 @@ var ConversationsClient = /** @class */ (function (_super) {
|
|
|
65
68
|
var method = 'POST';
|
|
66
69
|
var url = "".concat(ENDPOINT_CONVERSATIONS, "/get_or_create");
|
|
67
70
|
var params = args;
|
|
68
|
-
var schema =
|
|
71
|
+
var schema = this.conversationSchema;
|
|
69
72
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
70
73
|
return { method: method, url: url, params: params, schema: schema };
|
|
71
74
|
}
|
|
@@ -84,7 +87,7 @@ var ConversationsClient = /** @class */ (function (_super) {
|
|
|
84
87
|
params.archived = args.archived;
|
|
85
88
|
var method = 'POST';
|
|
86
89
|
var url = "".concat(ENDPOINT_CONVERSATIONS, "/update");
|
|
87
|
-
var schema =
|
|
90
|
+
var schema = this.conversationSchema;
|
|
88
91
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
89
92
|
return { method: method, url: url, params: params, schema: schema };
|
|
90
93
|
}
|
|
@@ -255,7 +258,7 @@ var ConversationsClient = /** @class */ (function (_super) {
|
|
|
255
258
|
var method = 'POST';
|
|
256
259
|
var url = "".concat(ENDPOINT_CONVERSATIONS, "/mute");
|
|
257
260
|
var params = { id: args.id, minutes: args.minutes };
|
|
258
|
-
var schema =
|
|
261
|
+
var schema = this.conversationSchema;
|
|
259
262
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
260
263
|
return { method: method, url: url, params: params, schema: schema };
|
|
261
264
|
}
|
|
@@ -272,7 +275,7 @@ var ConversationsClient = /** @class */ (function (_super) {
|
|
|
272
275
|
var method = 'POST';
|
|
273
276
|
var url = "".concat(ENDPOINT_CONVERSATIONS, "/unmute");
|
|
274
277
|
var params = { id: id };
|
|
275
|
-
var schema =
|
|
278
|
+
var schema = this.conversationSchema;
|
|
276
279
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
277
280
|
return { method: method, url: url, params: params, schema: schema };
|
|
278
281
|
}
|
|
@@ -16,7 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
import { z } from 'zod';
|
|
17
17
|
import { ENDPOINT_INBOX } from '../consts/endpoints.js';
|
|
18
18
|
import { request } from '../transport/http-client.js';
|
|
19
|
-
import {
|
|
19
|
+
import { createInboxThreadSchema } from '../types/entities.js';
|
|
20
20
|
import { BaseClient } from './base-client.js';
|
|
21
21
|
/**
|
|
22
22
|
* Client for interacting with Twist inbox endpoints.
|
|
@@ -24,9 +24,12 @@ import { BaseClient } from './base-client.js';
|
|
|
24
24
|
var InboxClient = /** @class */ (function (_super) {
|
|
25
25
|
__extends(InboxClient, _super);
|
|
26
26
|
function InboxClient() {
|
|
27
|
-
|
|
27
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
28
|
+
_this.inboxThreadSchema = createInboxThreadSchema(_this.getLinkBaseUrl());
|
|
29
|
+
return _this;
|
|
28
30
|
}
|
|
29
31
|
InboxClient.prototype.getInbox = function (args, options) {
|
|
32
|
+
var _this = this;
|
|
30
33
|
var _a, _b;
|
|
31
34
|
var params = {
|
|
32
35
|
workspace_id: args.workspaceId,
|
|
@@ -46,7 +49,7 @@ var InboxClient = /** @class */ (function (_super) {
|
|
|
46
49
|
var method = 'GET';
|
|
47
50
|
var url = "".concat(ENDPOINT_INBOX, "/get");
|
|
48
51
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
49
|
-
return { method: method, url: url, params: params, schema: z.array(
|
|
52
|
+
return { method: method, url: url, params: params, schema: z.array(this.inboxThreadSchema) };
|
|
50
53
|
}
|
|
51
54
|
return request({
|
|
52
55
|
httpMethod: method,
|
|
@@ -55,7 +58,7 @@ var InboxClient = /** @class */ (function (_super) {
|
|
|
55
58
|
apiToken: this.apiToken,
|
|
56
59
|
payload: params,
|
|
57
60
|
customFetch: this.customFetch,
|
|
58
|
-
}).then(function (response) { return response.data.map(function (thread) { return
|
|
61
|
+
}).then(function (response) { return response.data.map(function (thread) { return _this.inboxThreadSchema.parse(thread); }); });
|
|
59
62
|
};
|
|
60
63
|
InboxClient.prototype.getCount = function (workspaceId, options) {
|
|
61
64
|
var method = 'GET';
|
|
@@ -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));
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './authentication.js';
|
|
2
2
|
export { BatchBuilder } from './batch-builder.js';
|
|
3
|
+
export { AttachmentsClient } from './clients/attachments-client.js';
|
|
3
4
|
export { ConversationMessagesClient } from './clients/conversation-messages-client.js';
|
|
4
5
|
export { InboxClient } from './clients/inbox-client.js';
|
|
5
6
|
export { ReactionsClient } from './clients/reactions-client.js';
|
package/dist/esm/twist-api.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BatchBuilder } from './batch-builder.js';
|
|
2
|
+
import { AttachmentsClient } from './clients/attachments-client.js';
|
|
2
3
|
import { ChannelsClient } from './clients/channels-client.js';
|
|
3
4
|
import { CommentsClient } from './clients/comments-client.js';
|
|
4
5
|
import { ConversationMessagesClient } from './clients/conversation-messages-client.js';
|
|
@@ -70,6 +71,7 @@ var TwistApi = /** @class */ (function () {
|
|
|
70
71
|
this.inbox = new InboxClient(clientConfig);
|
|
71
72
|
this.reactions = new ReactionsClient(clientConfig);
|
|
72
73
|
this.search = new SearchClient(clientConfig);
|
|
74
|
+
this.attachments = new AttachmentsClient(clientConfig);
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
75
77
|
* Executes multiple API requests in a single HTTP call using the batch endpoint.
|